Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling of optional property in fields object fails #150

Open
maycon-mello opened this issue Apr 8, 2024 · 3 comments
Open

Handling of optional property in fields object fails #150

maycon-mello opened this issue Apr 8, 2024 · 3 comments

Comments

@maycon-mello
Copy link

maycon-mello commented Apr 8, 2024

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
@nklomp
Copy link
Contributor

nklomp commented Apr 10, 2024

Yeah good one. Probably what we will do is create a new release of the models/OpenAPI schema's, which means this error will not be present. But actually taking the optionality into account will have to wait a small bit. So will leave this ticket open

@nklomp
Copy link
Contributor

nklomp commented Apr 24, 2024

Okay this has been added to https://github.com/Sphereon-Opensource/PEX/releases/tag/v3.3.2
Will leave this ticket open, as I only added support for the property. We do nothing with it at present

@nklomp nklomp reopened this Apr 24, 2024
@cykoder
Copy link

cykoder commented May 7, 2024

@nklomp the optional field still produces an error when using definitionVersionDiscovery or evaluatePresentation, looks like its missing from resources/presentation_definition_v2.schema.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants