Skip to content

Handling of optional property in fields object fails  #150

@maycon-mello

Description

@maycon-mello

I'm submitting a ...
[x] bug report
[ ] feature request
[ ] question about the decisions made in the repository
[ ] question about how to use this project

Summary
According to https://identity.foundation/presentation-exchange/#input-descriptor-object:

The fields object MAY contain an optional property. The value of this property MUST be a boolean, wherein true indicates the field is optional, and false or non-presence of the property indicates the field is required.

The library is not able to handle the optional property in the fields object. Filtering or presentation evalutation fails with an InvalidPresentation error.

Other information

Code snippet:

// PEX "version": "3.3.1"
const { PEX } = require("@sphereon/pex");

const pex = new PEX();
const presentationDefinition = {
  id: "test",
  input_descriptors: [
    {
      id: "Test1",
      name: "Testing the optional attribute in the fields object",
      purpose: "Testing purposes",
      constraints: {
        fields: [
          {
            path: ["$.credentialSubject.id"],
          },
          {
            path: ["$.expirationDate"],
            optional: true,
          },
        ],
      },
    },
  ],
};

const result = pex.selectFrom(presentationDefinition, [], []);

Output:

/Users/mzm/test-pex/node_modules/@sphereon/pex/dist/main/lib/types/SSITypesBuilder.js:35
            throw versionResult.error;
            ^
This is not a valid PresentationDefinition
(Use `node --trace-uncaught ...` to show where the exception was thrown)

Node.js v18.17.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions