Skip to content

Commit

Permalink
fix: clientId fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nklomp committed Jun 2, 2024
1 parent cad41fc commit 4fc568b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
8 changes: 4 additions & 4 deletions packages/oid4vci-holder/src/agent/OID4VCIHolder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export class OID4VCIHolder implements IAgentPlugin {
jsonldCryptographicSuitePreferences,
didMethodPreferences,
jwtCryptographicSuitePreferences,
defaultAuthRequestOptions,
defaultAuthorizationRequestOptions,
} = options ?? {}

if (vcFormatPreferences !== undefined && vcFormatPreferences.length > 0) {
Expand All @@ -145,8 +145,8 @@ export class OID4VCIHolder implements IAgentPlugin {
if (jwtCryptographicSuitePreferences !== undefined && jwtCryptographicSuitePreferences.length > 0) {
this.jwtCryptographicSuitePreferences = jwtCryptographicSuitePreferences
}
if (defaultAuthRequestOptions) {
this.defaultAuthorizationRequestOpts = defaultAuthRequestOptions
if (defaultAuthorizationRequestOptions) {
this.defaultAuthorizationRequestOpts = defaultAuthorizationRequestOptions
}
this.onContactIdentityCreated = onContactIdentityCreated
this.onCredentialStored = onCredentialStored
Expand Down Expand Up @@ -175,7 +175,7 @@ export class OID4VCIHolder implements IAgentPlugin {
private async oid4vciHolderGetMachineInterpreter(args: OID4VCIMachineInstanceOpts, context: RequiredContext): Promise<OID4VCIMachineId> {
const authorizationRequestOpts = { ...this.defaultAuthorizationRequestOpts, ...args.authorizationRequestOpts }
const services = {
initiateOID4VCI: (args: InitiateOID4VCIArgs) => this.oid4vciHolderGetCredentialOfferData({ ...args, ...authorizationRequestOpts }, context),
initiateOID4VCI: (args: InitiateOID4VCIArgs) => this.oid4vciHolderGetCredentialOfferData({ ...args, authorizationRequestOpts }, context),
createCredentialSelection: (args: CreateCredentialSelectionArgs) => this.oid4vciHolderCreateCredentialSelection(args, context),
getContact: (args: GetContactArgs) => this.oid4vciHolderGetContact(args, context),
getCredentials: (args: GetCredentialsArgs) => this.oid4vciHolderGetCredentials(args, context),
Expand Down
21 changes: 7 additions & 14 deletions packages/oid4vci-holder/src/link-handler/index.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,34 @@
import { CredentialOfferClient } from '@sphereon/oid4vci-client'
import { convertURIToJsonObject } from '@sphereon/oid4vci-common'
import { AuthorizationRequestOpts, convertURIToJsonObject } from '@sphereon/oid4vci-common'
import { DefaultLinkPriorities, LinkHandlerAdapter } from '@sphereon/ssi-sdk.core'
import { IMachineStatePersistence, interpreterStartOrResume } from '@sphereon/ssi-sdk.xstate-machine-persistence'
import { IAgentContext } from '@veramo/core'
import {
GetMachineArgs,
IOID4VCIHolder,
OID4VCIHolderOptions,
OID4VCIMachineEvents,
OID4VCIMachineInterpreter,
OID4VCIMachineState,
} from '../types/IOID4VCIHolder'
import { GetMachineArgs, IOID4VCIHolder, OID4VCIMachineEvents, OID4VCIMachineInterpreter, OID4VCIMachineState } from '../types/IOID4VCIHolder'

export class OID4VCIHolderLinkHandler extends LinkHandlerAdapter {
private readonly context: IAgentContext<IOID4VCIHolder & IMachineStatePersistence>
private readonly stateNavigationListener:
| ((oid4vciMachine: OID4VCIMachineInterpreter, state: OID4VCIMachineState, navigation?: any) => Promise<void>)
| undefined
private readonly noStateMachinePersistence: boolean
private readonly options?: OID4VCIHolderOptions
private readonly authorizationRequestOpts?: AuthorizationRequestOpts

constructor(
args: Pick<GetMachineArgs, 'stateNavigationListener' | 'options'> & {
args: Pick<GetMachineArgs, 'stateNavigationListener' | 'authorizationRequestOpts'> & {
priority?: number | DefaultLinkPriorities
protocols?: Array<string | RegExp>
noStateMachinePersistence?: boolean
context: IAgentContext<IOID4VCIHolder & IMachineStatePersistence>
},
) {
super({ ...args, id: 'OID4VCIHolder' })
this.options = args.options
this.authorizationRequestOpts = args.authorizationRequestOpts
this.context = args.context
this.noStateMachinePersistence = args.noStateMachinePersistence === true
this.stateNavigationListener = args.stateNavigationListener
}

async handle(url: string | URL, options?: OID4VCIHolderOptions): Promise<void> {
async handle(url: string | URL, authorizationRequestOpts?: AuthorizationRequestOpts): Promise<void> {
const uri = new URL(url).toString()
const offerData = convertURIToJsonObject(uri) as Record<string, unknown>
const hasCode = 'code' in offerData && !!offerData.code && !('issuer' in offerData)
Expand All @@ -48,7 +41,7 @@ export class OID4VCIHolderLinkHandler extends LinkHandlerAdapter {
...(hasCode && { code: code }),
uri,
},
options: { ...this.options, ...options },
authorizationRequestOpts: { ...this.authorizationRequestOpts, ...authorizationRequestOpts },
stateNavigationListener: this.stateNavigationListener,
})

Expand Down
4 changes: 2 additions & 2 deletions packages/oid4vci-holder/src/types/IOID4VCIHolder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export type OID4VCIHolderOptions = {
onIdentifierCreated?: (args: OnIdentifierCreatedArgs) => Promise<void>
vcFormatPreferences?: Array<string>
jsonldCryptographicSuitePreferences?: Array<string>
defaultAuthRequestOptions?: AuthorizationRequestOpts
defaultAuthorizationRequestOptions?: AuthorizationRequestOpts
didMethodPreferences?: Array<SupportedDidMethodEnum>
jwtCryptographicSuitePreferences?: Array<SignatureAlgorithmEnum>
}
Expand All @@ -67,7 +67,7 @@ export type OnIdentifierCreatedArgs = {

export type GetMachineArgs = {
requestData: RequestData
options?: OID4VCIHolderOptions
authorizationRequestOpts?: AuthorizationRequestOpts
stateNavigationListener?: (oid4vciMachine: OID4VCIMachineInterpreter, state: OID4VCIMachineState, navigation?: any) => Promise<void>
}

Expand Down

0 comments on commit 4fc568b

Please sign in to comment.