From c1bd5ad287a2275da09d1293b9fd623f4543c814 Mon Sep 17 00:00:00 2001 From: Niels Klomp Date: Sun, 17 Mar 2024 16:18:55 +0100 Subject: [PATCH] chore: update typeorm dep --- .../src/session/OpSession.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/siopv2-oid4vp-op-auth/src/session/OpSession.ts b/packages/siopv2-oid4vp-op-auth/src/session/OpSession.ts index 6e93f94fb..1a6d51b82 100644 --- a/packages/siopv2-oid4vp-op-auth/src/session/OpSession.ts +++ b/packages/siopv2-oid4vp-op-auth/src/session/OpSession.ts @@ -100,10 +100,22 @@ export class OpSession { return intersection.map((value) => (didPrefix === false ? value : `did:${value}`)) } - public async getSupportedIdentifiers(): Promise { + public async getSupportedIdentifiers(opts?: {createInCaseNoDIDFound?: boolean}): Promise { // todo: we also need to check signature algo const methods = await this.getSupportedDIDMethods(true) - return await this.context.agent.didManagerFind().then((ids) => ids.filter((id) => methods.includes(id.provider))) + if (methods.length === 0) { + throw Error(`No DID methods are supported`) + } + const identifiers = await this.context.agent.didManagerFind().then((ids) => ids.filter((id) => methods.includes(id.provider))) + if (identifiers.length === 0) { + console.log(`No identifiers available in agent supporting methods ${JSON.stringify(methods)}`) + if (opts?.createInCaseNoDIDFound !== false) { + const identifier = await this.context.agent.didManagerCreate({provider: methods[0]}) + console.log(`Created a new identifier for the SIOP interaction: ${identifier.did}`) + identifiers.push(identifier) + } + } + return identifiers } public async getSupportedDIDs(): Promise {