Skip to content

Commit

Permalink
chore: update typeorm dep
Browse files Browse the repository at this point in the history
  • Loading branch information
nklomp committed Mar 17, 2024
1 parent f217e91 commit c1bd5ad
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions packages/siopv2-oid4vp-op-auth/src/session/OpSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,22 @@ export class OpSession {
return intersection.map((value) => (didPrefix === false ? value : `did:${value}`))
}

public async getSupportedIdentifiers(): Promise<IIdentifier[]> {
public async getSupportedIdentifiers(opts?: {createInCaseNoDIDFound?: boolean}): Promise<IIdentifier[]> {
// 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<string[]> {
Expand Down

0 comments on commit c1bd5ad

Please sign in to comment.