API
Evaluate
Description
These three methods are quite similar. The first One receives a presentation definition object, decides the version based upon feature detection and acts accordingly. The other two are specific to their Presentation Exchange definition version.
For more detailed difference between v1 and v2 please read the From V1 to V2 section.
Evaluates whether a presentation submission meets the requested presentation definition Since this method will be used both before and after creating a VerifiablePresentation, we accept both signed and unsigned version of a presentation here.
Parameters
name | type | description |
---|---|---|
presentationDefinition | PresentationDefinition | the presentation definition that initiated the request from the verifier |
presentation | IPresentation | the Presentation object containing the required credentials and a presentation_submission object mapping back to the presentation definition |
Return value
If evaluation is successful, value
will be a non-null PresentationSubmission
mapping the submitted credentials to
the requested inputs.
SelectFrom
Description
These three methods are quite similar. The first One receives a presentation definition object, decides the version based upon feature detection and acts accordingly. The other two are specific to their version.
For more detailed difference between v1 and v2 of the spec please read the From V1 to V2 section.
Gathers the matching credentials that fit a given presentation definition. Please note that there could be multiple results fitting the same criteria. This basically only filters out the credentials that do not match the definition. You, or rather the user, typically has to do a final selection.
selectFrom Parameters
name | type | description |
---|---|---|
presentationDefinition | PresentationDefinition | the presentation definition that initiated the request from the verifier |
credentials | (IVerifiableCredential or JwtWrappedVerifiableCredential or string)[] | the array of verifiable credentials to select from |
{ holderDIDs } | string[] | the holder’s DIDs. this can be found in VerifiablePresentation’s holder property note that a wallet can have many holderDIDs retrieved from different places |
Return value
- If the selection was successful or partially successful, the
matches
array will consist ofSubmissionRequirementMatch
object(s), representing the matching credentials for eachSubmissionRequirement
in thepresentationDefinition
input parameter. - If the selection was not successful, the
errors
array will consist ofChecked
object(s), representing what has failed in your selection process.
PresentationFrom
Description
These three methods are quite similar. The first One receives a presentation definition object, decides the version based upon feature detection and acts accordingly. The other two are specific to their version.
**For more detailed difference between v1 and v2 specification please read the From V1 to V2 section **.
Creates the corresponding Presentation Submission object to be included in the Verifiable Presentation response, which
maps the submitted credentials to the requested inputs in the presentationDefinition
input parameter.
presentationFromV1 Parameters
name | type | description |
---|---|---|
presentationDefinition | PresentationDefinitionV1 | the v1 presentation definition that initiated the request from the verifier |
selectedCredentials | (IVerifiableCredential or JwtWrappedVerifiableCredential or string)[] | the array of verifiable credentials that meet the submission requirements in the presentation definition |
{ holderDID } | string | the holder’s DID. This can be found in IVerifiablePresentation’s holder property note that a wallet can have many holderDIDs retrieved from different places |
presentationFromV2 Parameters
name | type | description |
---|---|---|
presentationDefinition | PresentationDefinitionV2 | the v2 presentation definition that initiated the request from the verifier |
selectedCredentials | (IVerifiableCredential or JwtWrappedVerifiableCredential or string)[] | the array of verifiable credentials that meet the submission requirements in the presentation definition |
{ holderDID } | string | the holder’s DID. This can be found in IVerifiablePresentation’s holder property note that a wallet can have many holderDIDs retrieved from different places |
Return value
If the selected credentials successfully match the submission requirements in the presentation definition, the return
value will be a non-null ‘Presentation’ containing a PresentationSubmission
Validation
Description
A validation utility function for PresentationDefinition
and PresentationSubmission
objects. If you know the version
of your presentation definition you can call version-specific functions. If not you can call the general one (located in
PEX) to first determine the version and then validate the presentation definition object against that version’s specific
rules.
Parameters
name | type | description |
---|---|---|
objToValidate | PresentationDefinition | PresentationSubmission | the presentation definition or presentation submission to be validated |
Return value
The validate
method returns a validated results array NonEmptyArray<Checked>
, with structure:
status can have following values 'info' | 'warn' | 'error'
Definition Version Discovery
Description
A utility function for PresentationDefinition
objects. This method will determine the version of your
presentationDefinition object.
Parameters
name | type | description |
---|---|---|
presentationDefinition | PresentationDefinition | the presentation definition that you need to decide the version for |
Return value
The definitionVersionDiscovery
method returns a version or an error, with following structure: