@sphereon/ssi-sdk.siopv2-oid4vp-op-auth 0.34.1-next.299 → 0.34.1-next.322

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,332 +1,181 @@
1
- // import { PresentationDefinitionWithLocation, PresentationExchange } from '@sphereon/did-auth-siop'
2
- // import { SelectResults, Status, SubmissionRequirementMatch } from '@sphereon/pex'
3
- //import { Format } from '@sphereon/pex-models'
4
- // import {
5
- // //isManagedIdentifierDidResult,
6
- // isOID4VCIssuerIdentifier,
7
- // ManagedIdentifierOptsOrResult,
8
- // ManagedIdentifierResult,
9
- // } from '@sphereon/ssi-sdk-ext.identifier-resolution'
10
- // import { defaultHasher,
11
- // // ProofOptions
12
- // } from '@sphereon/ssi-sdk.core'
13
- //import { UniqueDigitalCredential, verifiableCredentialForRoleFilter } from '@sphereon/ssi-sdk.credential-store'
14
- //import { CredentialRole, FindDigitalCredentialArgs } from '@sphereon/ssi-sdk.data-store-types'
1
+ import type { PartialSdJwtKbJwt } from '@sphereon/pex/dist/main/lib/index.js'
2
+ import { calculateSdHash } from '@sphereon/pex/dist/main/lib/utils/index.js'
3
+ import { isManagedIdentifierDidResult, ManagedIdentifierOptsOrResult } from '@sphereon/ssi-sdk-ext.identifier-resolution'
4
+ import { UniqueDigitalCredential } from '@sphereon/ssi-sdk.credential-store'
5
+ import { defaultGenerateDigest } from '@sphereon/ssi-sdk.sd-jwt'
15
6
  import {
16
- //CompactJWT,
7
+ CredentialMapper,
8
+ DocumentFormat,
17
9
  HasherSync,
18
- //IProof, OriginalVerifiableCredential
10
+ Loggers,
11
+ OriginalVerifiableCredential,
12
+ SdJwtDecodedVerifiableCredential,
13
+ WrappedVerifiableCredential,
19
14
  } from '@sphereon/ssi-types'
20
- import {
21
- //DEFAULT_JWT_PROOF_TYPE,
22
- //IGetPresentationExchangeArgs,
23
- IOID4VPArgs,
24
- //VerifiableCredentialsWithDefinition,
25
- //VerifiablePresentationWithDefinition,
26
- } from '../types'
27
- //import { createOID4VPPresentationSignCallback } from './functions'
28
- import { OpSession } from './OpSession'
15
+ import { LOGGER_NAMESPACE, RequiredContext } from '../types'
16
+
17
+ const CLOCK_SKEW = 120
18
+ const logger = Loggers.DEFAULT.get(LOGGER_NAMESPACE)
29
19
 
30
- // FIXME SSISDK-44 add support for DCQL presentations
20
+ export interface PresentationBuilderContext {
21
+ nonce: string
22
+ audience: string // clientId or origin
23
+ agent: RequiredContext['agent']
24
+ clockSkew?: number
25
+ hasher?: HasherSync
26
+ }
31
27
 
32
- export class OID4VP {
33
- //private readonly session: OpSession
34
- // private readonly allIdentifiers: string[]
35
- // private readonly hasher?: HasherSync
28
+ /**
29
+ * Extracts the original credential from a UniqueDigitalCredential or WrappedVerifiableCredential
30
+ */
31
+ function extractOriginalCredential(
32
+ credential: UniqueDigitalCredential | WrappedVerifiableCredential | OriginalVerifiableCredential,
33
+ ): OriginalVerifiableCredential {
34
+ if (typeof credential === 'string') {
35
+ return credential
36
+ }
36
37
 
37
- private constructor(args: IOID4VPArgs) {
38
- // const { session,
39
- // // allIdentifiers, hasher = defaultHasher
40
- // } = args
41
- //this.session = session
42
- // this.allIdentifiers = allIdentifiers ?? []
43
- // this.hasher = hasher
38
+ if ('digitalCredential' in credential) {
39
+ // UniqueDigitalCredential
40
+ const udc = credential as UniqueDigitalCredential
41
+ if (udc.originalVerifiableCredential) {
42
+ return udc.originalVerifiableCredential
43
+ }
44
+ return udc.uniformVerifiableCredential as OriginalVerifiableCredential
44
45
  }
45
46
 
46
- public static async init(session: OpSession, allIdentifiers: string[], hasher?: HasherSync): Promise<OID4VP> {
47
- return new OID4VP({ session, allIdentifiers: allIdentifiers ?? (await session.getSupportedDIDs()), hasher })
47
+ if ('original' in credential) {
48
+ // WrappedVerifiableCredential
49
+ return credential.original
48
50
  }
49
51
 
50
- // public async getPresentationDefinitions(): Promise<PresentationDefinitionWithLocation[] | undefined> {
51
- // const definitions = await this.session.getPresentationDefinitions()
52
- // if (definitions) {
53
- // PresentationExchange.assertValidPresentationDefinitionWithLocations(definitions)
54
- // }
55
- // return definitions
56
- // }
52
+ // Already an OriginalVerifiableCredential
53
+ return credential as OriginalVerifiableCredential
54
+ }
55
+
56
+ /**
57
+ * Gets the issuer/holder identifier from ManagedIdentifierOptsOrResult
58
+ */
59
+ function getIdentifierString(identifier: ManagedIdentifierOptsOrResult): string {
60
+ // Check if it's a result type (has 'method' and 'opts' properties)
61
+ if ('opts' in identifier && 'method' in identifier) {
62
+ // It's a ManagedIdentifierResult
63
+ if (isManagedIdentifierDidResult(identifier)) {
64
+ return identifier.did
65
+ }
66
+ }
67
+ // For opts types or other result types, use issuer if available, otherwise kid
68
+ return identifier.issuer ?? identifier.kid ?? ''
69
+ }
70
+
71
+ /**
72
+ * Creates a Verifiable Presentation for a given credential in the appropriate format
73
+ * Ensures nonce/aud (or challenge/domain) are set according to OID4VP draft 28
74
+ */
75
+ export async function createVerifiablePresentationForFormat(
76
+ credential: UniqueDigitalCredential | WrappedVerifiableCredential | OriginalVerifiableCredential,
77
+ identifier: ManagedIdentifierOptsOrResult,
78
+ context: PresentationBuilderContext,
79
+ ): Promise<string | object> {
80
+ // FIXME find proper types
81
+ const { nonce, audience, agent, clockSkew = CLOCK_SKEW } = context
82
+
83
+ const originalCredential = extractOriginalCredential(credential)
84
+ const documentFormat = CredentialMapper.detectDocumentType(originalCredential)
85
+
86
+ logger.debug(`Creating VP for format: ${documentFormat}`)
57
87
 
58
- // private getPresentationExchange(args: IGetPresentationExchangeArgs): PresentationExchange {
59
- // const { verifiableCredentials, allIdentifiers, hasher } = args
60
- //
61
- // return new PresentationExchange({
62
- // allDIDs: allIdentifiers ?? this.allIdentifiers,
63
- // allVerifiableCredentials: verifiableCredentials,
64
- // hasher: hasher ?? this.hasher,
65
- // })
66
- // }
88
+ switch (documentFormat) {
89
+ case DocumentFormat.SD_JWT_VC: {
90
+ // SD-JWT with KB-JWT
91
+ const decodedSdJwt = await CredentialMapper.decodeSdJwtVcAsync(
92
+ typeof originalCredential === 'string' ? originalCredential : (originalCredential as SdJwtDecodedVerifiableCredential).compactSdJwtVc,
93
+ defaultGenerateDigest,
94
+ )
67
95
 
68
- // public async createVerifiablePresentations(
69
- // credentialRole: CredentialRole,
70
- // credentialsWithDefinitions: VerifiableCredentialsWithDefinition[],
71
- // opts?: {
72
- // forceNoCredentialsInVP?: boolean // Allow to create a VP without credentials, like EBSI is using it. Defaults to false
73
- // restrictToFormats?: Format
74
- // restrictToDIDMethods?: string[]
75
- // proofOpts?: ProofOptions
76
- // idOpts?: ManagedIdentifierOptsOrResult
77
- // skipDidResolution?: boolean
78
- // holderDID?: string
79
- // subjectIsHolder?: boolean
80
- // hasher?: HasherSync
81
- // applyFilter?: boolean
82
- // },
83
- // ): Promise<VerifiablePresentationWithDefinition[]> {
84
- // return await Promise.all(credentialsWithDefinitions.map((cred) => this.createVerifiablePresentation(credentialRole, cred, opts)))
85
- // }
96
+ const hashAlg = decodedSdJwt.signedPayload._sd_alg ?? 'sha-256'
97
+ const sdHash = calculateSdHash(decodedSdJwt.compactSdJwtVc, hashAlg, defaultGenerateDigest)
86
98
 
87
- // public async createVerifiablePresentation(
88
- // credentialRole: CredentialRole,
89
- // selectedVerifiableCredentials: VerifiableCredentialsWithDefinition,
90
- // opts?: {
91
- // forceNoCredentialsInVP?: boolean // Allow to create a VP without credentials, like EBSI is using it. Defaults to false
92
- // restrictToFormats?: Format
93
- // restrictToDIDMethods?: string[]
94
- // proofOpts?: ProofOptions
95
- // idOpts?: ManagedIdentifierOptsOrResult
96
- // skipDidResolution?: boolean
97
- // holder?: string
98
- // subjectIsHolder?: boolean
99
- // applyFilter?: boolean
100
- // hasher?: HasherSync
101
- // },
102
- // ): Promise<VerifiablePresentationWithDefinition> {
103
- // const { subjectIsHolder, holder, forceNoCredentialsInVP = false } = { ...opts }
104
- // if (subjectIsHolder && holder) {
105
- // throw Error('Cannot both have subject is holder and a holderDID value at the same time (programming error)')
106
- // }
107
- // if (forceNoCredentialsInVP) {
108
- // selectedVerifiableCredentials.credentials = []
109
- // } else if (!selectedVerifiableCredentials?.credentials || selectedVerifiableCredentials.credentials.length === 0) {
110
- // throw Error('No verifiable verifiableCredentials provided for presentation definition')
111
- // }
112
- //
113
- // // const proofOptions: ProofOptions = {
114
- // // ...opts?.proofOpts,
115
- // // challenge: opts?.proofOpts?.nonce ?? opts?.proofOpts?.challenge ?? this.session.nonce,
116
- // // domain: opts?.proofOpts?.domain ?? (await this.session.getRedirectUri()),
117
- // // }
118
- //
119
- // let idOpts = opts?.idOpts
120
- // if (!idOpts) {
121
- // if (opts?.subjectIsHolder) {
122
- // if (forceNoCredentialsInVP) {
123
- // return Promise.reject(
124
- // Error(
125
- // `Cannot have subject is holder, when force no credentials is being used, as we could never determine the holder then. Please provide holderDID`,
126
- // ),
127
- // )
128
- // }
129
- // const firstUniqueDC = selectedVerifiableCredentials.credentials[0]
130
- // // const firstVC = firstUniqueDC.uniformVerifiableCredential!
131
- // if (typeof firstUniqueDC !== 'object' || !('digitalCredential' in firstUniqueDC)) {
132
- // return Promise.reject(Error('If no opts provided, credentials should be of type UniqueDigitalCredential'))
133
- // }
134
- //
135
- // idOpts = isOID4VCIssuerIdentifier(firstUniqueDC.digitalCredential.kmsKeyRef)
136
- // ? await this.session.context.agent.identifierManagedGetByIssuer({
137
- // identifier: firstUniqueDC.digitalCredential.kmsKeyRef,
138
- // })
139
- // : await this.session.context.agent.identifierManagedGetByKid({
140
- // identifier: firstUniqueDC.digitalCredential.kmsKeyRef,
141
- // kmsKeyRef: firstUniqueDC.digitalCredential.kmsKeyRef,
142
- // })
143
- //
144
- // /*
145
- // const holder = CredentialMapper.isSdJwtDecodedCredential(firstVC)
146
- // ? firstVC.decodedPayload.cnf?.jwk
147
- // ? //TODO SDK-19: convert the JWK to hex and search for the appropriate key and associated DID
148
- // //doesn't apply to did:jwk only, as you can represent any DID key as a JWK. So whenever you encounter a JWK it doesn't mean it had to come from a did:jwk in the system. It just can always be represented as a did:jwk
149
- // `did:jwk:${encodeJoseBlob(firstVC.decodedPayload.cnf?.jwk)}#0`
150
- // : firstVC.decodedPayload.sub
151
- // : Array.isArray(firstVC.credentialSubject)
152
- // ? firstVC.credentialSubject[0].id
153
- // : firstVC.credentialSubject.id
154
- // if (holder) {
155
- // idOpts = { identifier: holder }
156
- // }
157
- // */
158
- // } else if (opts?.holder) {
159
- // idOpts = { identifier: opts.holder }
160
- // }
161
- // }
162
- //
163
- // // We are making sure to filter, in case the user submitted all verifiableCredentials in the wallet/agent. We also make sure to get original formats back
164
- // const vcs = forceNoCredentialsInVP
165
- // ? selectedVerifiableCredentials
166
- // : opts?.applyFilter
167
- // ? await this.filterCredentials(credentialRole, selectedVerifiableCredentials.dcqlQuery, {
168
- // restrictToFormats: opts?.restrictToFormats,
169
- // restrictToDIDMethods: opts?.restrictToDIDMethods,
170
- // filterOpts: {
171
- // verifiableCredentials: selectedVerifiableCredentials.credentials,
172
- // },
173
- // })
174
- // : {
175
- // definition: selectedVerifiableCredentials.dcqlQuery,
176
- // credentials: selectedVerifiableCredentials.credentials,
177
- // }
178
- //
179
- // if (!idOpts) {
180
- // return Promise.reject(Error(`No identifier options present at this point`))
181
- // }
182
- //
183
- // // const signCallback = await createOID4VPPresentationSignCallback({
184
- // // presentationSignCallback: this.session.options.presentationSignCallback,
185
- // // idOpts,
186
- // // context: this.session.context,
187
- // // domain: proofOptions.domain,
188
- // // challenge: proofOptions.challenge,
189
- // // format: opts?.restrictToFormats ?? selectedVerifiableCredentials.dcqlQuery.dcqlQuery.format,
190
- // // skipDidResolution: opts?.skipDidResolution ?? false,
191
- // // })
192
- // const identifier: ManagedIdentifierResult = await this.session.context.agent.identifierManagedGet(idOpts)
193
- // const verifiableCredentials = vcs.credentials.map((credential) =>
194
- // typeof credential === 'object' && 'digitalCredential' in credential ? credential.originalVerifiableCredential! : credential,
195
- // )
196
- // // const presentationResult = await this.getPresentationExchange({
197
- // // verifiableCredentials: verifiableCredentials,
198
- // // allIdentifiers: this.allIdentifiers,
199
- // // hasher: opts?.hasher,
200
- // // }).createVerifiablePresentation(vcs.dcqlQuery.dcqlQuery, verifiableCredentials, signCallback, {
201
- // // proofOptions,
202
- // // // fixme: Update to newer siop-vp to not require dids here. But when Veramo is creating the VP it's still looking at this field to pass into didManagerGet
203
- // // ...(identifier && isManagedIdentifierDidResult(identifier) && { holderDID: identifier.did }),
204
- // // })
205
- //
206
- // const verifiablePresentations = presentationResult.verifiablePresentations.map((verifiablePresentation) =>
207
- // typeof verifiablePresentation !== 'string' &&
208
- // 'proof' in verifiablePresentation &&
209
- // 'jwt' in verifiablePresentation.proof &&
210
- // verifiablePresentation.proof.jwt
211
- // ? verifiablePresentation.proof.jwt
212
- // : verifiablePresentation,
213
- // )
214
- //
215
- // return {
216
- // ...presentationResult,
217
- // verifiablePresentations,
218
- // verifiableCredentials: verifiableCredentials,
219
- // dcqlQuery: selectedVerifiableCredentials.dcqlQuery,
220
- // idOpts,
221
- // }
222
- // }
99
+ const kbJwtPayload: PartialSdJwtKbJwt['payload'] = {
100
+ iat: Math.floor(Date.now() / 1000 - clockSkew),
101
+ sd_hash: sdHash,
102
+ nonce, // Always use the Authorization Request nonce
103
+ aud: audience, // Always use the Client Identifier or Origin
104
+ }
223
105
 
224
- // public async filterCredentialsAgainstAllDefinitions(
225
- // credentialRole: CredentialRole,
226
- // opts?: {
227
- // filterOpts?: {
228
- // verifiableCredentials?: UniqueDigitalCredential[]
229
- // filter?: FindDigitalCredentialArgs
230
- // }
231
- // holderDIDs?: string[]
232
- // restrictToFormats?: Format
233
- // restrictToDIDMethods?: string[]
234
- // },
235
- // ): Promise<VerifiableCredentialsWithDefinition[]> {
236
- // const defs = await this.getPresentationDefinitions()
237
- // const result: VerifiableCredentialsWithDefinition[] = []
238
- // if (defs) {
239
- // for (const definition of defs) {
240
- // result.push(await this.filterCredentials(credentialRole, definition, opts))
241
- // }
242
- // }
243
- // return result
244
- // }
106
+ const presentationResult = await agent.createSdJwtPresentation({
107
+ presentation: decodedSdJwt.compactSdJwtVc,
108
+ kb: {
109
+ payload: kbJwtPayload as any, // FIXME
110
+ },
111
+ })
245
112
 
246
- // public async filterCredentials(
247
- // credentialRole: CredentialRole,
248
- // presentationDefinition: PresentationDefinitionWithLocation,
249
- // opts?: {
250
- // filterOpts?: { verifiableCredentials?: (UniqueDigitalCredential | OriginalVerifiableCredential)[]; filter?: FindDigitalCredentialArgs }
251
- // holderDIDs?: string[]
252
- // restrictToFormats?: Format
253
- // restrictToDIDMethods?: string[]
254
- // },
255
- // ): Promise<VerifiableCredentialsWithDefinition> {
256
- // const udcMap = new Map<OriginalVerifiableCredential, UniqueDigitalCredential | OriginalVerifiableCredential>()
257
- // opts?.filterOpts?.verifiableCredentials?.forEach((credential) => {
258
- // if (typeof credential === 'object' && 'digitalCredential' in credential) {
259
- // udcMap.set(credential.originalVerifiableCredential!, credential)
260
- // } else {
261
- // udcMap.set(credential, credential)
262
- // }
263
- // })
264
- //
265
- // const credentials = (
266
- // await this.filterCredentialsWithSelectionStatus(credentialRole, presentationDefinition, {
267
- // ...opts,
268
- // filterOpts: {
269
- // verifiableCredentials: opts?.filterOpts?.verifiableCredentials?.map((credential) => {
270
- // if (typeof credential === 'object' && 'digitalCredential' in credential) {
271
- // return credential.originalVerifiableCredential!
272
- // } else {
273
- // return credential
274
- // }
275
- // }),
276
- // },
277
- // })
278
- // ).verifiableCredential
279
- //
280
- // return {
281
- // dcqlQuery: presentationDefinition,
282
- // credentials: credentials?.map((vc) => udcMap.get(vc)!) ?? [],
283
- // }
284
- // }
113
+ return presentationResult.presentation
114
+ }
285
115
 
286
- // public async filterCredentialsWithSelectionStatus(
287
- // credentialRole: CredentialRole,
288
- // presentationDefinition: PresentationDefinitionWithLocation,
289
- // opts?: {
290
- // filterOpts?: { verifiableCredentials?: OriginalVerifiableCredential[]; filter?: FindDigitalCredentialArgs }
291
- // holderDIDs?: string[]
292
- // restrictToFormats?: Format
293
- // restrictToDIDMethods?: string[]
294
- // },
295
- // ): Promise<SelectResults> {
296
- // const selectionResults: SelectResults = await this.getPresentationExchange({
297
- // verifiableCredentials: await this.getCredentials(credentialRole, opts?.filterOpts),
298
- // }).selectVerifiableCredentialsForSubmission(presentationDefinition.definition, opts)
299
- // if (selectionResults.errors && selectionResults.errors.length > 0) {
300
- // throw Error(JSON.stringify(selectionResults.errors))
301
- // } else if (selectionResults.areRequiredCredentialsPresent === Status.ERROR) {
302
- // throw Error(`Not all required credentials are available to satisfy the relying party's request`)
303
- // }
304
- //
305
- // const matches: SubmissionRequirementMatch[] | undefined = selectionResults.matches
306
- // if (!matches || matches.length === 0 || !selectionResults.verifiableCredential || selectionResults.verifiableCredential.length === 0) {
307
- // throw Error(JSON.stringify(selectionResults.errors))
308
- // }
309
- // return selectionResults
310
- // }
311
- //
312
- // private async getCredentials(
313
- // credentialRole: CredentialRole,
314
- // filterOpts?: {
315
- // verifiableCredentials?: OriginalVerifiableCredential[]
316
- // filter?: FindDigitalCredentialArgs
317
- // },
318
- // ): Promise<OriginalVerifiableCredential[]> {
319
- // if (filterOpts?.verifiableCredentials && filterOpts.verifiableCredentials.length > 0) {
320
- // return filterOpts.verifiableCredentials
321
- // }
322
- //
323
- // const filter = verifiableCredentialForRoleFilter(credentialRole, filterOpts?.filter)
324
- // const uniqueCredentials = await this.session.context.agent.crsGetUniqueCredentials({ filter })
325
- // return uniqueCredentials.map((uniqueVC: UniqueDigitalCredential) => {
326
- // const vc = uniqueVC.uniformVerifiableCredential!
327
- // const proof = Array.isArray(vc.proof) ? vc.proof : [vc.proof]
328
- // const jwtProof = proof.find((p: IProof) => p?.type === DEFAULT_JWT_PROOF_TYPE)
329
- // return jwtProof ? (jwtProof.jwt as CompactJWT) : vc
330
- // })
331
- // }
116
+ case DocumentFormat.JSONLD: {
117
+ // JSON-LD VC - create JSON-LD VP with challenge and domain in proof
118
+ const vcObject = typeof originalCredential === 'string' ? JSON.parse(originalCredential) : originalCredential
119
+
120
+ const vpObject = {
121
+ '@context': ['https://www.w3.org/2018/credentials/v1'],
122
+ type: ['VerifiablePresentation'],
123
+ verifiableCredential: [vcObject],
124
+ }
125
+
126
+ // Create JSON-LD VP with proof
127
+ return await agent.createVerifiablePresentation({
128
+ presentation: vpObject,
129
+ proofFormat: 'lds',
130
+ challenge: nonce, // Authorization Request nonce as challenge
131
+ domain: audience, // Client Identifier or Origin as domain
132
+ keyRef: identifier.kmsKeyRef || identifier.kid,
133
+ })
134
+ }
135
+
136
+ case DocumentFormat.MSO_MDOC: {
137
+ // ISO mdoc - create mdoc VP token
138
+ // This is a placeholder implementation
139
+ // Full implementation would require:
140
+ // 1. Decode the mdoc using CredentialMapper or mdoc utilities
141
+ // 2. Build proper mdoc VP token with session transcript
142
+ // 3. Include nonce/audience in the session transcript
143
+ logger.warning('mso_mdoc format has basic support - production use requires proper mdoc VP token implementation')
144
+
145
+ return originalCredential
146
+ }
147
+
148
+ default: {
149
+ // JWT VC - create JWT VP with nonce and aud in payload
150
+ const vcJwt = typeof originalCredential === 'string' ? originalCredential : JSON.stringify(originalCredential)
151
+
152
+ const identifierString = getIdentifierString(identifier)
153
+
154
+ // Create VP JWT using agent method
155
+ const vpPayload = {
156
+ iss: identifierString,
157
+ aud: audience, // Client Identifier or Origin
158
+ nonce, // Authorization Request nonce
159
+ vp: {
160
+ '@context': ['https://www.w3.org/2018/credentials/v1'],
161
+ type: ['VerifiablePresentation'],
162
+ holder: identifierString,
163
+ verifiableCredential: [vcJwt],
164
+ },
165
+ iat: Math.floor(Date.now() / 1000 - clockSkew),
166
+ exp: Math.floor(Date.now() / 1000 + 600 + clockSkew), // 10 minutes
167
+ }
168
+
169
+ // Use the agent's JWT creation capability
170
+ const vpJwt = await agent.createVerifiablePresentation({
171
+ presentation: vpPayload.vp,
172
+ proofFormat: 'jwt',
173
+ domain: audience,
174
+ challenge: nonce,
175
+ keyRef: identifier.kmsKeyRef || identifier.kid,
176
+ })
177
+
178
+ return vpJwt.proof?.jwt || vpJwt
179
+ }
180
+ }
332
181
  }
@@ -7,26 +7,18 @@ import {
7
7
  SupportedVersion,
8
8
  URI,
9
9
  Verification,
10
- VerifiedAuthorizationRequest
10
+ VerifiedAuthorizationRequest,
11
11
  } from '@sphereon/did-auth-siop'
12
12
  import { ResolveOpts } from '@sphereon/did-auth-siop-adapter'
13
13
  import { JwtIssuer } from '@sphereon/oid4vc-common'
14
14
  import { getAgentDIDMethods, getAgentResolver } from '@sphereon/ssi-sdk-ext.did-utils'
15
15
  import { JweAlg, JweEnc } from '@sphereon/ssi-sdk-ext.jwt-service'
16
16
  import { encodeBase64url } from '@sphereon/ssi-sdk.core'
17
- import { parseDid } from '@sphereon/ssi-types'
17
+ import { Loggers, parseDid } from '@sphereon/ssi-types'
18
18
  import { IIdentifier, TKeyType } from '@veramo/core'
19
19
  import { v4 } from 'uuid'
20
- import {
21
- IOPOptions,
22
- IOpSessionArgs,
23
- IOpSessionGetOID4VPArgs,
24
- IOpsSendSiopAuthorizationResponseArgs,
25
- IRequiredContext
26
- } from '../types'
20
+ import { IOPOptions, IOpSessionArgs, IOpsSendSiopAuthorizationResponseArgs, IRequiredContext } from '../types'
27
21
  import { createOP } from './functions'
28
- import { OID4VP } from './OID4VP'
29
- import { Loggers } from '@sphereon/ssi-types'
30
22
 
31
23
  const logger = Loggers.DEFAULT.get('sphereon:oid4vp:OpSession')
32
24
 
@@ -213,10 +205,6 @@ export class OpSession {
213
205
  return Promise.resolve(this.verifiedAuthorizationRequest!.responseURI!)
214
206
  }
215
207
 
216
- public async getOID4VP(args: IOpSessionGetOID4VPArgs): Promise<OID4VP> {
217
- return await OID4VP.init(this, args.allIdentifiers ?? [], args.hasher)
218
- }
219
-
220
208
  private async createJarmResponseCallback({
221
209
  responseOpts,
222
210
  }: {
@@ -259,11 +247,7 @@ export class OpSession {
259
247
  }
260
248
 
261
249
  public async sendAuthorizationResponse(args: IOpsSendSiopAuthorizationResponseArgs): Promise<Response> {
262
- const {
263
- responseSignerOpts,
264
- dcqlResponse,
265
- isFirstParty,
266
- } = args
250
+ const { responseSignerOpts, dcqlResponse, isFirstParty } = args
267
251
 
268
252
  const resolveOpts: ResolveOpts = this.options.resolveOpts ?? {
269
253
  resolver: getAgentResolver(this.context, {
package/src/utils/dcql.ts CHANGED
@@ -2,8 +2,10 @@ import { UniqueDigitalCredential } from '@sphereon/ssi-sdk.credential-store'
2
2
  import {
3
3
  CredentialMapper,
4
4
  HasherSync,
5
- OriginalVerifiableCredential, WrappedMdocCredential,
6
- type WrappedSdJwtVerifiableCredential, type WrappedW3CVerifiableCredential
5
+ OriginalVerifiableCredential,
6
+ WrappedMdocCredential,
7
+ type WrappedSdJwtVerifiableCredential,
8
+ type WrappedW3CVerifiableCredential,
7
9
  } from '@sphereon/ssi-types'
8
10
  import { Dcql } from '@sphereon/did-auth-siop'
9
11
  import { DcqlCredential } from 'dcql'
@@ -28,7 +30,9 @@ export function convertToDcqlCredentials(credential: UniqueDigitalCredential | O
28
30
  return Dcql.toDcqlJwtCredential(CredentialMapper.toWrappedVerifiableCredential(originalVerifiableCredential) as WrappedW3CVerifiableCredential)
29
31
  } else if (CredentialMapper.isSdJwtDecodedCredential(originalVerifiableCredential)) {
30
32
  // FIXME: SD-JWT VC vs VCDM2 + SD-JWT would need to be handled here
31
- return Dcql.toDcqlSdJwtCredential(CredentialMapper.toWrappedVerifiableCredential(originalVerifiableCredential) as WrappedSdJwtVerifiableCredential)
33
+ return Dcql.toDcqlSdJwtCredential(
34
+ CredentialMapper.toWrappedVerifiableCredential(originalVerifiableCredential) as WrappedSdJwtVerifiableCredential,
35
+ )
32
36
  } else if (CredentialMapper.isMsoMdocDecodedCredential(originalVerifiableCredential)) {
33
37
  return Dcql.toDcqlMdocCredential(CredentialMapper.toWrappedVerifiableCredential(originalVerifiableCredential) as WrappedMdocCredential)
34
38
  } else if (CredentialMapper.isW3cCredential(originalVerifiableCredential)) {