Skip to content

Commit

Permalink
feat: Reuse existing PEX for performance
Browse files Browse the repository at this point in the history
  • Loading branch information
nklomp committed Feb 6, 2024
1 parent 089ea37 commit 9c8966c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class PresentationExchange implements IAgentPlugin {
readonly schema = schema.IDidAuthSiopOpAuthenticator
private readonly defaultStore: string
private readonly defaultNamespace: string
private readonly pex = new PEX()

readonly methods: IPresentationExchange = {
pexStoreGetDefinition: this.pexStoreGetDefinition.bind(this),
Expand Down Expand Up @@ -117,7 +118,7 @@ export class PresentationExchange implements IAgentPlugin {
async pexDefinitionFilterCredentials(args: IDefinitionCredentialFilterArgs, context: IRequiredContext): Promise<IPEXFilterResult> {
const credentials = await this.pexFilterCredentials(args.credentialFilterOpts ?? {}, context)
const holderDIDs = args.holderDIDs ? toDIDs(args.holderDIDs) : toDIDs(await context.agent.dataStoreORMGetIdentifiers())
const selectResults = new PEX().selectFrom(args.presentationDefinition, credentials ?? [], {
const selectResults = this.pex.selectFrom(args.presentationDefinition, credentials ?? [], {
...args,
holderDIDs,
limitDisclosureSignatureSuites: args.limitDisclosureSignatureSuites ?? ['BbsBlsSignature2020'],
Expand Down
1 change: 0 additions & 1 deletion packages/presentation-exchange/src/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,5 @@ export async function createPEXPresentationSignCallback(
console.log(`PRE MAPPER AGENT ${new Date().toString()}`)
// makes sure we extract an actual JWT from the internal representation in case it is a JWT
return CredentialMapper.storedPresentationToOriginalFormat(vp as OriginalVerifiablePresentation)
console.log(`POST MAPPER AGENT ${new Date().toString()}`)
}
}
3 changes: 1 addition & 2 deletions packages/siopv2-oid4vp-op-auth/src/session/OID4VP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ export class OID4VP {
if (opts?.subjectIsHolder && opts?.holderDID) {
throw Error('Cannot both have subject is holder and a holderDID value at the same time (programming error)')
} else if (
!selectedVerifiableCredentials ||
!selectedVerifiableCredentials.credentials ||
!selectedVerifiableCredentials?.credentials ||
selectedVerifiableCredentials.credentials.length === 0
) {
throw Error('No verifiable verifiableCredentials provided for presentation definition')
Expand Down

0 comments on commit 9c8966c

Please sign in to comment.