@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth 0.34.1-fix.171 → 0.34.1-fix.223
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.
- package/dist/index.cjs +93 -93
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -27
- package/dist/index.d.ts +15 -27
- package/dist/index.js +94 -94
- package/dist/index.js.map +1 -1
- package/package.json +17 -17
- package/src/RPInstance.ts +7 -26
- package/src/agent/SIOPv2RP.ts +64 -45
- package/src/functions.ts +40 -44
- package/src/types/ISIOPv2RP.ts +9 -24
package/src/agent/SIOPv2RP.ts
CHANGED
|
@@ -10,6 +10,8 @@ import {
|
|
|
10
10
|
} from '@sphereon/did-auth-siop'
|
|
11
11
|
import { getAgentResolver } from '@sphereon/ssi-sdk-ext.did-utils'
|
|
12
12
|
import { shaHasher as defaultHasher } from '@sphereon/ssi-sdk.core'
|
|
13
|
+
import { validate as isValidUUID } from 'uuid'
|
|
14
|
+
import type { ImportDcqlQueryItem } from '@sphereon/ssi-sdk.pd-manager'
|
|
13
15
|
import {
|
|
14
16
|
AdditionalClaims,
|
|
15
17
|
CredentialMapper,
|
|
@@ -25,7 +27,7 @@ import {
|
|
|
25
27
|
SdJwtDecodedVerifiableCredential
|
|
26
28
|
} from '@sphereon/ssi-types'
|
|
27
29
|
import { IAgentPlugin } from '@veramo/core'
|
|
28
|
-
import {
|
|
30
|
+
import { DcqlQuery } from 'dcql'
|
|
29
31
|
import {
|
|
30
32
|
IAuthorizationRequestPayloads,
|
|
31
33
|
ICreateAuthRequestArgs,
|
|
@@ -84,7 +86,14 @@ export class SIOPv2RP implements IAgentPlugin {
|
|
|
84
86
|
}
|
|
85
87
|
|
|
86
88
|
private async createAuthorizationRequestURI(createArgs: ICreateAuthRequestArgs, context: IRequiredContext): Promise<string> {
|
|
87
|
-
return await this.getRPInstance(
|
|
89
|
+
return await this.getRPInstance(
|
|
90
|
+
{
|
|
91
|
+
createWhenNotPresent: true,
|
|
92
|
+
responseRedirectURI: createArgs.responseRedirectURI,
|
|
93
|
+
...(createArgs.useQueryIdInstance === true && { queryId: createArgs.queryId } ),
|
|
94
|
+
},
|
|
95
|
+
context,
|
|
96
|
+
)
|
|
88
97
|
.then((rp) => rp.createAuthorizationRequestURI(createArgs, context))
|
|
89
98
|
.then((URI) => URI.encodedUri)
|
|
90
99
|
}
|
|
@@ -93,7 +102,7 @@ export class SIOPv2RP implements IAgentPlugin {
|
|
|
93
102
|
createArgs: ICreateAuthRequestArgs,
|
|
94
103
|
context: IRequiredContext,
|
|
95
104
|
): Promise<IAuthorizationRequestPayloads> {
|
|
96
|
-
return await this.getRPInstance({ queryId: createArgs.queryId }, context)
|
|
105
|
+
return await this.getRPInstance({ createWhenNotPresent: true, queryId: createArgs.queryId }, context)
|
|
97
106
|
.then((rp) => rp.createAuthorizationRequest(createArgs, context))
|
|
98
107
|
.then(async (request) => {
|
|
99
108
|
const authRequest: IAuthorizationRequestPayloads = {
|
|
@@ -106,7 +115,7 @@ export class SIOPv2RP implements IAgentPlugin {
|
|
|
106
115
|
}
|
|
107
116
|
|
|
108
117
|
private async siopGetRequestState(args: IGetAuthRequestStateArgs, context: IRequiredContext): Promise<AuthorizationRequestState | undefined> {
|
|
109
|
-
return await this.getRPInstance({ queryId: args.queryId }, context).then((rp) =>
|
|
118
|
+
return await this.getRPInstance({ createWhenNotPresent: false, queryId: args.queryId }, context).then((rp) =>
|
|
110
119
|
rp.get(context).then((rp) =>
|
|
111
120
|
rp.sessionManager.getRequestStateByCorrelationId(args.correlationId, args.errorOnNotFound)
|
|
112
121
|
),
|
|
@@ -117,7 +126,7 @@ export class SIOPv2RP implements IAgentPlugin {
|
|
|
117
126
|
args: IGetAuthResponseStateArgs,
|
|
118
127
|
context: IRequiredContext,
|
|
119
128
|
): Promise<AuthorizationResponseStateWithVerifiedData | undefined> {
|
|
120
|
-
const rpInstance: RPInstance = await this.getRPInstance({ queryId: args.queryId }, context)
|
|
129
|
+
const rpInstance: RPInstance = await this.getRPInstance({ createWhenNotPresent: false, queryId: args.queryId }, context)
|
|
121
130
|
const authorizationResponseState: AuthorizationResponseState | undefined = await rpInstance
|
|
122
131
|
.get(context)
|
|
123
132
|
.then((rp) => rp.sessionManager.getResponseStateByCorrelationId(args.correlationId, args.errorOnNotFound))
|
|
@@ -135,10 +144,8 @@ export class SIOPv2RP implements IAgentPlugin {
|
|
|
135
144
|
hasher = defaultHasher
|
|
136
145
|
}
|
|
137
146
|
|
|
138
|
-
|
|
147
|
+
// FIXME SSISDK-64 currently assuming that all vp tokens are or type EncodedDcqlPresentationVpToken as we only work with DCQL now. But the types still indicate it can be another type of vp token
|
|
139
148
|
const vpToken = responseState.response.payload.vp_token && JSON.parse(responseState.response.payload.vp_token as EncodedDcqlPresentationVpToken)
|
|
140
|
-
const xx = DcqlPresentation.parse(vpToken)
|
|
141
|
-
console.log(`IS DCQL PRESENTATION: ${JSON.stringify(xx)}`)
|
|
142
149
|
const claims = []
|
|
143
150
|
for (const [key, value] of Object.entries(vpToken)) {
|
|
144
151
|
// todo this should also include mdl-mdoc
|
|
@@ -223,7 +230,7 @@ export class SIOPv2RP implements IAgentPlugin {
|
|
|
223
230
|
if (args.state !== 'authorization_request_created') {
|
|
224
231
|
throw Error(`Only 'authorization_request_created' status is supported for this method at this point`)
|
|
225
232
|
}
|
|
226
|
-
return await this.getRPInstance({ queryId: args.queryId }, context)
|
|
233
|
+
return await this.getRPInstance({ createWhenNotPresent: false, queryId: args.queryId }, context)
|
|
227
234
|
// todo: In the SIOP library we need to update the signal method to be more like this method
|
|
228
235
|
.then((rp) =>
|
|
229
236
|
rp.get(context).then(async (rp) => {
|
|
@@ -237,7 +244,7 @@ export class SIOPv2RP implements IAgentPlugin {
|
|
|
237
244
|
}
|
|
238
245
|
|
|
239
246
|
private async siopDeleteState(args: IGetAuthResponseStateArgs, context: IRequiredContext): Promise<boolean> {
|
|
240
|
-
return await this.getRPInstance({ queryId: args.queryId }, context)
|
|
247
|
+
return await this.getRPInstance({ createWhenNotPresent: false, queryId: args.queryId }, context)
|
|
241
248
|
.then((rp) => rp.get(context).then((rp) => rp.sessionManager.deleteStateForCorrelationId(args.correlationId)))
|
|
242
249
|
.then(() => true)
|
|
243
250
|
}
|
|
@@ -250,45 +257,30 @@ export class SIOPv2RP implements IAgentPlugin {
|
|
|
250
257
|
typeof args.authorizationResponse === 'string'
|
|
251
258
|
? (decodeUriAsJson(args.authorizationResponse) as AuthorizationResponsePayload)
|
|
252
259
|
: args.authorizationResponse
|
|
253
|
-
return await this.getRPInstance({ queryId: args.queryId }, context).then((rp) =>
|
|
260
|
+
return await this.getRPInstance({ createWhenNotPresent: false, queryId: args.queryId }, context).then((rp) =>
|
|
254
261
|
rp.get(context).then((rp) =>
|
|
255
262
|
rp.verifyAuthorizationResponse(authResponse, {
|
|
256
263
|
correlationId: args.correlationId,
|
|
257
|
-
|
|
258
|
-
|
|
264
|
+
...(args.dcqlQuery && { dcqlQuery: args.dcqlQuery }),
|
|
265
|
+
audience: args.audience,
|
|
259
266
|
}),
|
|
260
267
|
),
|
|
261
268
|
)
|
|
262
269
|
}
|
|
263
270
|
|
|
264
271
|
private async siopImportDefinitions(args: ImportDefinitionsArgs, context: IRequiredContext): Promise<void> {
|
|
265
|
-
const {
|
|
272
|
+
const { importItems, tenantId, version, versionControlMode } = args
|
|
266
273
|
await Promise.all(
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
return Promise.reject(Error('Either dcqlPayload or definitionPayload must be suppplied'))
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
let definitionId: string
|
|
274
|
-
if (definitionPair.dcqlPayload) {
|
|
275
|
-
DcqlQuery.validate(definitionPair.dcqlPayload.dcqlQuery)
|
|
276
|
-
console.log(`persisting DCQL definition ${definitionPair.dcqlPayload.queryId} with versionControlMode ${versionControlMode}`)
|
|
277
|
-
definitionId = definitionPair.dcqlPayload.queryId
|
|
278
|
-
}
|
|
279
|
-
if (definitionPayload) {
|
|
280
|
-
await context.agent.pexValidateDefinition({ definition: definitionPayload })
|
|
281
|
-
console.log(`persisting PEX definition ${definitionPayload.id} / ${definitionPayload.name} with versionControlMode ${versionControlMode}`)
|
|
282
|
-
definitionId = definitionPayload.id
|
|
283
|
-
}
|
|
274
|
+
importItems.map(async (importItem: ImportDcqlQueryItem) => {
|
|
275
|
+
DcqlQuery.validate(importItem.query)
|
|
276
|
+
console.log(`persisting DCQL definition ${importItem.queryId} with versionControlMode ${versionControlMode}`)
|
|
284
277
|
|
|
285
278
|
return context.agent.pdmPersistDefinition({
|
|
286
279
|
definitionItem: {
|
|
287
|
-
|
|
280
|
+
queryId: importItem.queryId!,
|
|
288
281
|
tenantId: tenantId,
|
|
289
282
|
version: version,
|
|
290
|
-
|
|
291
|
-
dcqlPayload: definitionPair.dcqlPayload,
|
|
283
|
+
query: importItem.query,
|
|
292
284
|
},
|
|
293
285
|
opts: { versionControlMode: versionControlMode },
|
|
294
286
|
})
|
|
@@ -312,9 +304,36 @@ export class SIOPv2RP implements IAgentPlugin {
|
|
|
312
304
|
return undefined
|
|
313
305
|
}
|
|
314
306
|
|
|
315
|
-
async getRPInstance({ queryId, responseRedirectURI }: ISiopRPInstanceArgs, context: IRequiredContext): Promise<RPInstance> {
|
|
316
|
-
|
|
317
|
-
|
|
307
|
+
async getRPInstance({ createWhenNotPresent, queryId, responseRedirectURI }: ISiopRPInstanceArgs, context: IRequiredContext): Promise<RPInstance> {
|
|
308
|
+
let rpInstanceId: string = SIOPv2RP._DEFAULT_OPTS_KEY
|
|
309
|
+
let rpInstance: RPInstance | undefined
|
|
310
|
+
if (queryId) {
|
|
311
|
+
if (this.instances.has(queryId)) {
|
|
312
|
+
rpInstanceId = queryId
|
|
313
|
+
rpInstance = this.instances.get(rpInstanceId)!
|
|
314
|
+
} else if (isValidUUID(queryId)) {
|
|
315
|
+
try {
|
|
316
|
+
// Check whether queryId is actually the PD item id
|
|
317
|
+
const pd = await context.agent.pdmGetDefinition({ itemId: queryId })
|
|
318
|
+
if (this.instances.has(pd.queryId)) {
|
|
319
|
+
rpInstanceId = pd.queryId
|
|
320
|
+
rpInstance = this.instances.get(rpInstanceId)!
|
|
321
|
+
}
|
|
322
|
+
} catch (ignore) {}
|
|
323
|
+
}
|
|
324
|
+
if (createWhenNotPresent) {
|
|
325
|
+
rpInstanceId = queryId
|
|
326
|
+
} else {
|
|
327
|
+
rpInstance = this.instances.get(rpInstanceId)
|
|
328
|
+
}
|
|
329
|
+
} else {
|
|
330
|
+
rpInstance = this.instances.get(rpInstanceId)
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
if (!rpInstance) {
|
|
334
|
+
if (!createWhenNotPresent) {
|
|
335
|
+
return Promise.reject(`No RP instance found for key ${rpInstanceId}`)
|
|
336
|
+
}
|
|
318
337
|
const instanceOpts = this.getInstanceOpts(queryId)
|
|
319
338
|
const rpOpts = await this.getRPOptions(context, { queryId, responseRedirectURI: responseRedirectURI })
|
|
320
339
|
if (!rpOpts.identifierOpts.resolveOpts?.resolver || typeof rpOpts.identifierOpts.resolveOpts.resolver.resolve !== 'function') {
|
|
@@ -329,9 +348,9 @@ export class SIOPv2RP implements IAgentPlugin {
|
|
|
329
348
|
resolverResolution: true,
|
|
330
349
|
})
|
|
331
350
|
}
|
|
332
|
-
|
|
351
|
+
rpInstance = new RPInstance({ rpOpts, pexOpts: instanceOpts })
|
|
352
|
+
this.instances.set(rpInstanceId, rpInstance)
|
|
333
353
|
}
|
|
334
|
-
const rpInstance = this.instances.get(instanceId)!
|
|
335
354
|
if (responseRedirectURI) {
|
|
336
355
|
rpInstance.rpOptions.responseRedirectUri = responseRedirectURI
|
|
337
356
|
}
|
|
@@ -373,22 +392,22 @@ export class SIOPv2RP implements IAgentPlugin {
|
|
|
373
392
|
return options
|
|
374
393
|
}
|
|
375
394
|
|
|
376
|
-
getInstanceOpts(
|
|
395
|
+
getInstanceOpts(queryId?: string): IPEXInstanceOptions | undefined {
|
|
377
396
|
if (!this.opts.instanceOpts) return undefined
|
|
378
397
|
|
|
379
|
-
const instanceOpt =
|
|
398
|
+
const instanceOpt = queryId ? this.opts.instanceOpts.find((i) => i.queryId === queryId) : undefined
|
|
380
399
|
|
|
381
|
-
return instanceOpt ?? this.getDefaultOptions(
|
|
400
|
+
return instanceOpt ?? this.getDefaultOptions(queryId)
|
|
382
401
|
}
|
|
383
402
|
|
|
384
|
-
private getDefaultOptions(
|
|
403
|
+
private getDefaultOptions(queryId: string | undefined) {
|
|
385
404
|
if (!this.opts.instanceOpts) return undefined
|
|
386
405
|
|
|
387
406
|
const defaultOptions = this.opts.instanceOpts.find((i) => i.queryId === 'default')
|
|
388
407
|
if (defaultOptions) {
|
|
389
408
|
const clonedOptions = { ...defaultOptions }
|
|
390
|
-
if (
|
|
391
|
-
clonedOptions.queryId =
|
|
409
|
+
if (queryId !== undefined) {
|
|
410
|
+
clonedOptions.queryId = queryId
|
|
392
411
|
}
|
|
393
412
|
return clonedOptions
|
|
394
413
|
}
|
package/src/functions.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ClientIdentifierPrefix,
|
|
3
3
|
ClientMetadataOpts,
|
|
4
|
+
DcqlQueryLookupCallback,
|
|
4
5
|
InMemoryRPSessionManager,
|
|
5
6
|
PassBy,
|
|
6
7
|
PresentationVerificationCallback,
|
|
@@ -14,7 +15,7 @@ import {
|
|
|
14
15
|
Scope,
|
|
15
16
|
SubjectType,
|
|
16
17
|
SupportedVersion,
|
|
17
|
-
VerifyJwtCallback
|
|
18
|
+
VerifyJwtCallback,
|
|
18
19
|
} from '@sphereon/did-auth-siop'
|
|
19
20
|
import { CreateJwtCallback, JwtHeader, JwtIssuer, JwtPayload, SigningAlgo } from '@sphereon/oid4vc-common'
|
|
20
21
|
import { IPresentationDefinition } from '@sphereon/pex'
|
|
@@ -28,18 +29,13 @@ import {
|
|
|
28
29
|
} from '@sphereon/ssi-sdk-ext.identifier-resolution'
|
|
29
30
|
import { JwtCompactResult } from '@sphereon/ssi-sdk-ext.jwt-service'
|
|
30
31
|
import { IVerifySdJwtPresentationResult } from '@sphereon/ssi-sdk.sd-jwt'
|
|
31
|
-
import {
|
|
32
|
-
CredentialMapper,
|
|
33
|
-
HasherSync,
|
|
34
|
-
OriginalVerifiableCredential,
|
|
35
|
-
PresentationSubmission
|
|
36
|
-
} from '@sphereon/ssi-types'
|
|
32
|
+
import { CredentialMapper, HasherSync, OriginalVerifiableCredential, PresentationSubmission } from '@sphereon/ssi-types'
|
|
37
33
|
import { IVerifyCallbackArgs, IVerifyCredentialResult, VerifyCallback } from '@sphereon/wellknown-dids-client'
|
|
38
34
|
import { TKeyType } from '@veramo/core'
|
|
39
35
|
import { JWTVerifyOptions } from 'did-jwt'
|
|
40
36
|
import { Resolvable } from 'did-resolver'
|
|
41
37
|
import { EventEmitter } from 'events'
|
|
42
|
-
import {
|
|
38
|
+
import { IRequiredContext, IRPOptions, ISIOPIdentifierOptions } from './types/ISIOPv2RP'
|
|
43
39
|
import { DcqlQuery } from 'dcql'
|
|
44
40
|
import { defaultHasher } from '@sphereon/ssi-sdk.core'
|
|
45
41
|
|
|
@@ -47,7 +43,7 @@ export function getRequestVersion(rpOptions: IRPOptions): SupportedVersion {
|
|
|
47
43
|
if (Array.isArray(rpOptions.supportedVersions) && rpOptions.supportedVersions.length > 0) {
|
|
48
44
|
return rpOptions.supportedVersions[0]
|
|
49
45
|
}
|
|
50
|
-
return SupportedVersion.
|
|
46
|
+
return SupportedVersion.OID4VP_v1
|
|
51
47
|
}
|
|
52
48
|
|
|
53
49
|
function getWellKnownDIDVerifyCallback(siopIdentifierOpts: ISIOPIdentifierOptions, context: IRequiredContext) {
|
|
@@ -62,6 +58,31 @@ function getWellKnownDIDVerifyCallback(siopIdentifierOpts: ISIOPIdentifierOption
|
|
|
62
58
|
}
|
|
63
59
|
}
|
|
64
60
|
|
|
61
|
+
export function getDcqlQueryLookupCallback(context: IRequiredContext): DcqlQueryLookupCallback {
|
|
62
|
+
async function dcqlQueryLookup(queryId: string, version?: string, tenantId?: string): Promise<DcqlQuery> {
|
|
63
|
+
// TODO Add caching?
|
|
64
|
+
const result = await context.agent.pdmGetDefinitions({
|
|
65
|
+
filter: [
|
|
66
|
+
{
|
|
67
|
+
queryId,
|
|
68
|
+
...(tenantId && { tenantId }),
|
|
69
|
+
...(version && { version }),
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
id: queryId,
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
})
|
|
76
|
+
if (result && result.length > 0) {
|
|
77
|
+
return result[0].query
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return Promise.reject(Error(`No dcql query found for queryId ${queryId}`))
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return dcqlQueryLookup
|
|
84
|
+
}
|
|
85
|
+
|
|
65
86
|
export function getPresentationVerificationCallback(
|
|
66
87
|
idOpts: ManagedIdentifierOptsOrResult,
|
|
67
88
|
context: IRequiredContext,
|
|
@@ -72,7 +93,7 @@ export function getPresentationVerificationCallback(
|
|
|
72
93
|
): Promise<PresentationVerificationResult> {
|
|
73
94
|
if (CredentialMapper.isSdJwtEncoded(args)) {
|
|
74
95
|
const result: IVerifySdJwtPresentationResult = await context.agent.verifySdJwtPresentation({
|
|
75
|
-
presentation: args
|
|
96
|
+
presentation: args,
|
|
76
97
|
})
|
|
77
98
|
// fixme: investigate the correct way to handle this
|
|
78
99
|
return { verified: !!result.payload }
|
|
@@ -106,34 +127,11 @@ export function getPresentationVerificationCallback(
|
|
|
106
127
|
|
|
107
128
|
export async function createRPBuilder(args: {
|
|
108
129
|
rpOpts: IRPOptions
|
|
109
|
-
pexOpts?: IPEXOptions | undefined
|
|
110
130
|
definition?: IPresentationDefinition
|
|
111
|
-
dcql?: DcqlQuery
|
|
112
131
|
context: IRequiredContext
|
|
113
132
|
}): Promise<RPBuilder> {
|
|
114
|
-
const { rpOpts,
|
|
133
|
+
const { rpOpts, context } = args
|
|
115
134
|
const { identifierOpts } = rpOpts
|
|
116
|
-
let definition: IPresentationDefinition | undefined = args.definition
|
|
117
|
-
let dcqlQuery: DcqlQuery | undefined = args.dcql
|
|
118
|
-
|
|
119
|
-
if (!definition && pexOpts && pexOpts.queryId) {
|
|
120
|
-
const presentationDefinitionItems = await context.agent.pdmGetDefinitions({
|
|
121
|
-
filter: [
|
|
122
|
-
{
|
|
123
|
-
definitionId: pexOpts.queryId,
|
|
124
|
-
version: pexOpts.version,
|
|
125
|
-
tenantId: pexOpts.tenantId,
|
|
126
|
-
},
|
|
127
|
-
],
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
if (presentationDefinitionItems.length > 0) {
|
|
131
|
-
const presentationDefinitionItem = presentationDefinitionItems[0]
|
|
132
|
-
if (!dcqlQuery && presentationDefinitionItem.dcqlPayload) {
|
|
133
|
-
dcqlQuery = presentationDefinitionItem.dcqlPayload.dcqlQuery as DcqlQuery // cast from DcqlQueryREST back to valibot DcqlQuery
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
135
|
|
|
138
136
|
const didMethods = identifierOpts.supportedDIDMethods ?? (await getAgentDIDMethods(context))
|
|
139
137
|
const eventEmitter = rpOpts.eventEmitter ?? new EventEmitter()
|
|
@@ -173,9 +171,7 @@ export async function createRPBuilder(args: {
|
|
|
173
171
|
.withResponseMode(rpOpts.responseMode ?? ResponseMode.POST)
|
|
174
172
|
.withResponseType(ResponseType.VP_TOKEN, PropertyTarget.REQUEST_OBJECT)
|
|
175
173
|
// todo: move to options fill/correct method
|
|
176
|
-
.withSupportedVersions(
|
|
177
|
-
rpOpts.supportedVersions ?? [SupportedVersion.JWT_VC_PRESENTATION_PROFILE_v1, SupportedVersion.SIOPv2_ID1, SupportedVersion.SIOPv2_D11],
|
|
178
|
-
)
|
|
174
|
+
.withSupportedVersions(rpOpts.supportedVersions ?? [SupportedVersion.OID4VP_v1, SupportedVersion.SIOPv2_OID4VP_D28])
|
|
179
175
|
|
|
180
176
|
.withEventEmitter(eventEmitter)
|
|
181
177
|
.withSessionManager(rpOpts.sessionManager ?? new InMemoryRPSessionManager(eventEmitter))
|
|
@@ -194,6 +190,7 @@ export async function createRPBuilder(args: {
|
|
|
194
190
|
context,
|
|
195
191
|
),
|
|
196
192
|
)
|
|
193
|
+
.withDcqlQueryLookup(getDcqlQueryLookupCallback(context))
|
|
197
194
|
.withRevocationVerification(RevocationVerification.NEVER)
|
|
198
195
|
.withPresentationVerification(getPresentationVerificationCallback(identifierOpts.idOpts, context))
|
|
199
196
|
|
|
@@ -202,7 +199,10 @@ export async function createRPBuilder(args: {
|
|
|
202
199
|
builder.withEntityId(oidfOpts.identifier, PropertyTarget.REQUEST_OBJECT)
|
|
203
200
|
} else {
|
|
204
201
|
const resolution = await context.agent.identifierManagedGet(identifierOpts.idOpts)
|
|
205
|
-
const clientId: string =
|
|
202
|
+
const clientId: string =
|
|
203
|
+
rpOpts.clientMetadataOpts?.client_id ??
|
|
204
|
+
resolution.issuer ??
|
|
205
|
+
(isManagedIdentifierDidResult(resolution) ? resolution.did : resolution.jwkThumbprint)
|
|
206
206
|
const clientIdPrefixed = prefixClientId(clientId)
|
|
207
207
|
builder.withClientId(clientIdPrefixed, PropertyTarget.REQUEST_OBJECT)
|
|
208
208
|
}
|
|
@@ -218,10 +218,6 @@ export async function createRPBuilder(args: {
|
|
|
218
218
|
//fixme: this has been removed in the new version of did-auth-siop
|
|
219
219
|
// builder.withWellknownDIDVerifyCallback(getWellKnownDIDVerifyCallback(didOpts, context))
|
|
220
220
|
|
|
221
|
-
if (dcqlQuery) {
|
|
222
|
-
builder.withDcqlQuery(dcqlQuery)
|
|
223
|
-
}
|
|
224
|
-
|
|
225
221
|
if (rpOpts.responseRedirectUri) {
|
|
226
222
|
builder.withResponseRedirectUri(rpOpts.responseRedirectUri)
|
|
227
223
|
}
|
|
@@ -306,8 +302,8 @@ export function getSigningAlgo(type: TKeyType): SigningAlgo {
|
|
|
306
302
|
export function prefixClientId(clientId: string): string {
|
|
307
303
|
// FIXME SSISDK-60
|
|
308
304
|
if (clientId.startsWith('did:')) {
|
|
309
|
-
return `${ClientIdentifierPrefix.DECENTRALIZED_IDENTIFIER}:${clientId}
|
|
305
|
+
return `${ClientIdentifierPrefix.DECENTRALIZED_IDENTIFIER}:${clientId}`
|
|
310
306
|
}
|
|
311
307
|
|
|
312
|
-
return clientId
|
|
308
|
+
return clientId
|
|
313
309
|
}
|
package/src/types/ISIOPv2RP.ts
CHANGED
|
@@ -24,23 +24,17 @@ import { ExternalIdentifierOIDFEntityIdOpts, IIdentifierResolution, ManagedIdent
|
|
|
24
24
|
import { IJwtService } from '@sphereon/ssi-sdk-ext.jwt-service'
|
|
25
25
|
import { ICredentialValidation, SchemaValidation } from '@sphereon/ssi-sdk.credential-validation'
|
|
26
26
|
import { ImDLMdoc } from '@sphereon/ssi-sdk.mdl-mdoc'
|
|
27
|
-
import { IPDManager, VersionControlMode } from '@sphereon/ssi-sdk.pd-manager'
|
|
27
|
+
import { ImportDcqlQueryItem, IPDManager, VersionControlMode } from '@sphereon/ssi-sdk.pd-manager'
|
|
28
28
|
import { IPresentationExchange } from '@sphereon/ssi-sdk.presentation-exchange'
|
|
29
29
|
import { ISDJwtPlugin } from '@sphereon/ssi-sdk.sd-jwt'
|
|
30
30
|
import { AuthorizationRequestStateStatus } from '@sphereon/ssi-sdk.siopv2-oid4vp-common'
|
|
31
|
-
import {
|
|
31
|
+
import { HasherSync } from '@sphereon/ssi-types'
|
|
32
32
|
import { VerifyCallback } from '@sphereon/wellknown-dids-client'
|
|
33
33
|
import { IAgentContext, ICredentialVerifier, IDIDManager, IKeyManager, IPluginMethodMap, IResolver } from '@veramo/core'
|
|
34
|
-
|
|
34
|
+
import { DcqlQuery } from 'dcql'
|
|
35
35
|
import { Resolvable } from 'did-resolver'
|
|
36
36
|
import { EventEmitter } from 'events'
|
|
37
37
|
|
|
38
|
-
export enum VerifiedDataMode {
|
|
39
|
-
NONE = 'none',
|
|
40
|
-
VERIFIED_PRESENTATION = 'vp',
|
|
41
|
-
CREDENTIAL_SUBJECT_FLATTENED = 'cs-flat',
|
|
42
|
-
}
|
|
43
|
-
|
|
44
38
|
export interface ISIOPv2RP extends IPluginMethodMap {
|
|
45
39
|
siopCreateAuthRequestURI(createArgs: ICreateAuthRequestArgs, context: IRequiredContext): Promise<string>
|
|
46
40
|
siopCreateAuthRequestPayloads(createArgs: ICreateAuthRequestArgs, context: IRequiredContext): Promise<IAuthorizationRequestPayloads>
|
|
@@ -89,7 +83,6 @@ export interface IGetAuthResponseStateArgs {
|
|
|
89
83
|
queryId?: string
|
|
90
84
|
errorOnNotFound?: boolean
|
|
91
85
|
progressRequestStateTo?: AuthorizationRequestStateStatus
|
|
92
|
-
//includeVerifiedData?: VerifiedDataMode
|
|
93
86
|
}
|
|
94
87
|
|
|
95
88
|
export interface IUpdateRequestStateArgs {
|
|
@@ -109,16 +102,10 @@ export interface IVerifyAuthResponseStateArgs {
|
|
|
109
102
|
queryId?: string
|
|
110
103
|
correlationId: string
|
|
111
104
|
audience?: string
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export interface IDefinitionPair {
|
|
116
|
-
definitionPayload?: IPresentationDefinition
|
|
117
|
-
dcqlPayload?: DcqlQueryPayload
|
|
105
|
+
dcqlQuery?: DcqlQuery
|
|
118
106
|
}
|
|
119
|
-
|
|
120
107
|
export interface ImportDefinitionsArgs {
|
|
121
|
-
|
|
108
|
+
importItems: Array<ImportDcqlQueryItem>
|
|
122
109
|
tenantId?: string
|
|
123
110
|
version?: string
|
|
124
111
|
versionControlMode?: VersionControlMode
|
|
@@ -142,11 +129,12 @@ export interface IPEXDefinitionPersistArgs extends IPEXInstanceOptions {
|
|
|
142
129
|
}
|
|
143
130
|
|
|
144
131
|
export interface ISiopRPInstanceArgs {
|
|
132
|
+
createWhenNotPresent: boolean
|
|
145
133
|
queryId?: string
|
|
146
134
|
responseRedirectURI?: string
|
|
147
135
|
}
|
|
148
136
|
|
|
149
|
-
export interface IPEXInstanceOptions extends
|
|
137
|
+
export interface IPEXInstanceOptions extends IPresentationOptions {
|
|
150
138
|
rpOpts?: IRPOptions
|
|
151
139
|
}
|
|
152
140
|
|
|
@@ -164,12 +152,9 @@ export interface IRPOptions {
|
|
|
164
152
|
responseRedirectUri?: string
|
|
165
153
|
}
|
|
166
154
|
|
|
167
|
-
export interface
|
|
168
|
-
presentationVerifyCallback?: PresentationVerificationCallback
|
|
169
|
-
// definition?: IPresentationDefinition
|
|
155
|
+
export interface IPresentationOptions {
|
|
170
156
|
queryId: string
|
|
171
|
-
|
|
172
|
-
tenantId?: string
|
|
157
|
+
presentationVerifyCallback?: PresentationVerificationCallback
|
|
173
158
|
}
|
|
174
159
|
|
|
175
160
|
export type VerificationPolicies = {
|