Skip to content

Commit

Permalink
chore: add hasher option on did auth siop authenticator
Browse files Browse the repository at this point in the history
  • Loading branch information
Brummos committed Jan 21, 2025
1 parent ba19df3 commit 7fa6278
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export const sendAuthorizationChallengeRequest = async (args: SendAuthorizationC
return oid4vciClient.acquireAuthorizationChallengeCode({
clientId: oid4vciClient.clientId ?? uuidv4(),
...(authSession && { authSession }),
...(openID4VCIClientState.credentialOffer?.preAuthorizedCode && { issuerState: openID4VCIClientState.credentialOffer?.preAuthorizedCode }),
...(openID4VCIClientState.credentialOffer?.issuerState && { issuerState: openID4VCIClientState.credentialOffer?.issuerState }),
...(!authSession && openID4VCIClientState.credentialOffer?.preAuthorizedCode && { issuerState: openID4VCIClientState.credentialOffer?.preAuthorizedCode }),
...(!authSession && openID4VCIClientState.credentialOffer?.issuerState && { issuerState: openID4VCIClientState.credentialOffer?.issuerState }),
...(presentationDuringIssuanceSession && { presentationDuringIssuanceSession })
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
NonPersistedIdentity,
Party,
} from '@sphereon/ssi-sdk.data-store'
import { Loggers } from '@sphereon/ssi-types'
import { Hasher, Loggers } from '@sphereon/ssi-types'
import { IAgentPlugin } from '@veramo/core'
import { v4 as uuidv4 } from 'uuid'
import {
Expand Down Expand Up @@ -84,6 +84,7 @@ export class DidAuthSiopOpAuthenticator implements IAgentPlugin {
siopGetSelectableCredentials: this.siopGetSelectableCredentials.bind(this),
}

private readonly hasher?: Hasher
private readonly sessions: Map<string, OpSession>
private readonly customApprovals: Record<string, (verifiedAuthorizationRequest: VerifiedAuthorizationRequest, sessionId: string) => Promise<void>>
private readonly presentationSignCallback?: PresentationSignCallback
Expand All @@ -97,13 +98,14 @@ export class DidAuthSiopOpAuthenticator implements IAgentPlugin {
customApprovals?: Record<string, (verifiedAuthorizationRequest: VerifiedAuthorizationRequest, sessionId: string) => Promise<void>>,
options?: DidAuthSiopOpAuthenticatorOptions,
) {
const { onContactIdentityCreated, onIdentifierCreated } = options ?? {}
const { onContactIdentityCreated, onIdentifierCreated, hasher } = { ...options }
this.onContactIdentityCreated = onContactIdentityCreated
this.onIdentifierCreated = onIdentifierCreated

this.sessions = new Map<string, OpSession>()
this.customApprovals = customApprovals || {}
this.presentationSignCallback = presentationSignCallback
this.hasher = hasher
}

public async onEvent(event: any, context: RequiredContext): Promise<void> {
Expand Down Expand Up @@ -340,7 +342,7 @@ export class DidAuthSiopOpAuthenticator implements IAgentPlugin {
return Promise.reject(Error('Missing authorization request data in context'))
}

const pex = new PEX()
const pex = new PEX({ hasher: this.hasher })
const verifiableCredentialsWithDefinition: Array<VerifiableCredentialsWithDefinition> = []

authorizationRequestData.presentationDefinitions?.forEach((presentationDefinition) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import { IIssuanceBranding } from '@sphereon/ssi-sdk.issuance-branding'
import { IAgentContext, IDIDManager, IIdentifier, IResolver } from '@veramo/core'
import { IDidAuthSiopOpAuthenticator } from '../IDidAuthSiopOpAuthenticator'
import { Siopv2MachineContext, Siopv2MachineInterpreter, Siopv2MachineState } from '../machine'
import { Hasher } from '@sphereon/ssi-types'

export type DidAuthSiopOpAuthenticatorOptions = {
onContactIdentityCreated?: (args: OnContactIdentityCreatedArgs) => Promise<void>
onIdentifierCreated?: (args: OnIdentifierCreatedArgs) => Promise<void>
hasher?: Hasher
}

export type GetMachineArgs = {
Expand Down

0 comments on commit 7fa6278

Please sign in to comment.