@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth 0.34.1-fix.182 → 0.34.1-fix.226
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 +128 -87
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -21
- package/dist/index.d.ts +11 -21
- package/dist/index.js +128 -87
- package/dist/index.js.map +1 -1
- package/package.json +17 -17
- package/src/RPInstance.ts +7 -26
- package/src/agent/SIOPv2RP.ts +106 -48
- package/src/functions.ts +40 -41
- package/src/types/ISIOPv2RP.ts +5 -15
package/src/agent/SIOPv2RP.ts
CHANGED
|
@@ -5,10 +5,12 @@ import {
|
|
|
5
5
|
AuthorizationResponseStateStatus,
|
|
6
6
|
AuthorizationResponseStateWithVerifiedData,
|
|
7
7
|
decodeUriAsJson,
|
|
8
|
-
|
|
8
|
+
EncodedDcqlPresentationVpToken,
|
|
9
|
+
VerifiedAuthorizationResponse
|
|
9
10
|
} from '@sphereon/did-auth-siop'
|
|
10
11
|
import { getAgentResolver } from '@sphereon/ssi-sdk-ext.did-utils'
|
|
11
12
|
import { shaHasher as defaultHasher } from '@sphereon/ssi-sdk.core'
|
|
13
|
+
import { validate as isValidUUID } from 'uuid'
|
|
12
14
|
import type { ImportDcqlQueryItem } from '@sphereon/ssi-sdk.pd-manager'
|
|
13
15
|
import {
|
|
14
16
|
AdditionalClaims,
|
|
@@ -22,7 +24,7 @@ import {
|
|
|
22
24
|
MdocDeviceResponse,
|
|
23
25
|
MdocOid4vpMdocVpToken,
|
|
24
26
|
OriginalVerifiablePresentation,
|
|
25
|
-
SdJwtDecodedVerifiableCredential
|
|
27
|
+
SdJwtDecodedVerifiableCredential
|
|
26
28
|
} from '@sphereon/ssi-types'
|
|
27
29
|
import { IAgentPlugin } from '@veramo/core'
|
|
28
30
|
import { DcqlQuery } from 'dcql'
|
|
@@ -41,8 +43,7 @@ import {
|
|
|
41
43
|
ISiopv2RPOpts,
|
|
42
44
|
IUpdateRequestStateArgs,
|
|
43
45
|
IVerifyAuthResponseStateArgs,
|
|
44
|
-
schema
|
|
45
|
-
VerifiedDataMode,
|
|
46
|
+
schema
|
|
46
47
|
} from '../index'
|
|
47
48
|
import { RPInstance } from '../RPInstance'
|
|
48
49
|
import { ISIOPv2RP } from '../types/ISIOPv2RP'
|
|
@@ -86,7 +87,11 @@ export class SIOPv2RP implements IAgentPlugin {
|
|
|
86
87
|
|
|
87
88
|
private async createAuthorizationRequestURI(createArgs: ICreateAuthRequestArgs, context: IRequiredContext): Promise<string> {
|
|
88
89
|
return await this.getRPInstance(
|
|
89
|
-
{
|
|
90
|
+
{
|
|
91
|
+
createWhenNotPresent: true,
|
|
92
|
+
responseRedirectURI: createArgs.responseRedirectURI,
|
|
93
|
+
...(createArgs.useQueryIdInstance === true && { queryId: createArgs.queryId } ),
|
|
94
|
+
},
|
|
90
95
|
context,
|
|
91
96
|
)
|
|
92
97
|
.then((rp) => rp.createAuthorizationRequestURI(createArgs, context))
|
|
@@ -97,7 +102,7 @@ export class SIOPv2RP implements IAgentPlugin {
|
|
|
97
102
|
createArgs: ICreateAuthRequestArgs,
|
|
98
103
|
context: IRequiredContext,
|
|
99
104
|
): Promise<IAuthorizationRequestPayloads> {
|
|
100
|
-
return await this.getRPInstance({ queryId: createArgs.queryId }, context)
|
|
105
|
+
return await this.getRPInstance({ createWhenNotPresent: true, queryId: createArgs.queryId }, context)
|
|
101
106
|
.then((rp) => rp.createAuthorizationRequest(createArgs, context))
|
|
102
107
|
.then(async (request) => {
|
|
103
108
|
const authRequest: IAuthorizationRequestPayloads = {
|
|
@@ -110,8 +115,10 @@ export class SIOPv2RP implements IAgentPlugin {
|
|
|
110
115
|
}
|
|
111
116
|
|
|
112
117
|
private async siopGetRequestState(args: IGetAuthRequestStateArgs, context: IRequiredContext): Promise<AuthorizationRequestState | undefined> {
|
|
113
|
-
return await this.getRPInstance({ queryId: args.queryId }, context).then((rp) =>
|
|
114
|
-
rp.get(context).then((rp) =>
|
|
118
|
+
return await this.getRPInstance({ createWhenNotPresent: false, queryId: args.queryId }, context).then((rp) =>
|
|
119
|
+
rp.get(context).then((rp) =>
|
|
120
|
+
rp.sessionManager.getRequestStateByCorrelationId(args.correlationId, args.errorOnNotFound)
|
|
121
|
+
),
|
|
115
122
|
)
|
|
116
123
|
}
|
|
117
124
|
|
|
@@ -119,7 +126,7 @@ export class SIOPv2RP implements IAgentPlugin {
|
|
|
119
126
|
args: IGetAuthResponseStateArgs,
|
|
120
127
|
context: IRequiredContext,
|
|
121
128
|
): Promise<AuthorizationResponseStateWithVerifiedData | undefined> {
|
|
122
|
-
const rpInstance: RPInstance = await this.getRPInstance({ queryId: args.queryId }, context)
|
|
129
|
+
const rpInstance: RPInstance = await this.getRPInstance({ createWhenNotPresent: false, queryId: args.queryId }, context)
|
|
123
130
|
const authorizationResponseState: AuthorizationResponseState | undefined = await rpInstance
|
|
124
131
|
.get(context)
|
|
125
132
|
.then((rp) => rp.sessionManager.getResponseStateByCorrelationId(args.correlationId, args.errorOnNotFound))
|
|
@@ -128,11 +135,7 @@ export class SIOPv2RP implements IAgentPlugin {
|
|
|
128
135
|
}
|
|
129
136
|
|
|
130
137
|
const responseState = authorizationResponseState as AuthorizationResponseStateWithVerifiedData
|
|
131
|
-
if (
|
|
132
|
-
responseState.status === AuthorizationResponseStateStatus.VERIFIED &&
|
|
133
|
-
args.includeVerifiedData &&
|
|
134
|
-
args.includeVerifiedData !== VerifiedDataMode.NONE
|
|
135
|
-
) {
|
|
138
|
+
if (responseState.status === AuthorizationResponseStateStatus.VERIFIED) {
|
|
136
139
|
let hasher: HasherSync | undefined
|
|
137
140
|
if (
|
|
138
141
|
CredentialMapper.isSdJwtEncoded(responseState.response.payload.vp_token as OriginalVerifiablePresentation) &&
|
|
@@ -140,19 +143,23 @@ export class SIOPv2RP implements IAgentPlugin {
|
|
|
140
143
|
) {
|
|
141
144
|
hasher = defaultHasher
|
|
142
145
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
146
|
+
|
|
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
|
|
148
|
+
const vpToken = responseState.response.payload.vp_token && JSON.parse(responseState.response.payload.vp_token as EncodedDcqlPresentationVpToken)
|
|
149
|
+
const claims = []
|
|
150
|
+
for (const [key, value] of Object.entries(vpToken)) {
|
|
151
|
+
// todo this should also include mdl-mdoc
|
|
152
|
+
const presentationDecoded = CredentialMapper.decodeVerifiablePresentation(
|
|
153
|
+
value as OriginalVerifiablePresentation,
|
|
154
|
+
//todo: later we want to conditionally pass in options for mdl-mdoc here
|
|
155
|
+
hasher,
|
|
156
|
+
)
|
|
157
|
+
console.log(`presentationDecoded: ${JSON.stringify(presentationDecoded)}`)
|
|
158
|
+
|
|
159
|
+
const allClaims: AdditionalClaims = {}
|
|
160
|
+
const presentationOrClaims = this.presentationOrClaimsFrom(presentationDecoded)
|
|
161
|
+
if ('verifiableCredential' in presentationOrClaims) {
|
|
162
|
+
for (const credential of presentationOrClaims.verifiableCredential) {
|
|
156
163
|
const vc = credential as IVerifiableCredential
|
|
157
164
|
const schemaValidationResult = await context.agent.cvVerifySchema({
|
|
158
165
|
credential,
|
|
@@ -175,11 +182,34 @@ export class SIOPv2RP implements IAgentPlugin {
|
|
|
175
182
|
allClaims[key] = value
|
|
176
183
|
}
|
|
177
184
|
})
|
|
185
|
+
|
|
186
|
+
claims.push({
|
|
187
|
+
id: key,
|
|
188
|
+
type: vc.type[0],
|
|
189
|
+
claims: allClaims
|
|
190
|
+
})
|
|
191
|
+
}
|
|
192
|
+
} else {
|
|
193
|
+
claims.push({
|
|
194
|
+
id: key,
|
|
195
|
+
type: (presentationDecoded as SdJwtDecodedVerifiableCredential).decodedPayload.vct,
|
|
196
|
+
claims: presentationOrClaims
|
|
197
|
+
})
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
responseState.verifiedData = {
|
|
202
|
+
...(responseState.response.payload.vp_token && {
|
|
203
|
+
authorization_response: {
|
|
204
|
+
vp_token: typeof responseState.response.payload.vp_token === 'string'
|
|
205
|
+
? JSON.parse(responseState.response.payload.vp_token)
|
|
206
|
+
: responseState.response.payload.vp_token
|
|
178
207
|
}
|
|
179
|
-
|
|
180
|
-
|
|
208
|
+
}),
|
|
209
|
+
...(claims.length > 0 && { credential_claims: claims })
|
|
181
210
|
}
|
|
182
211
|
}
|
|
212
|
+
|
|
183
213
|
return responseState
|
|
184
214
|
}
|
|
185
215
|
|
|
@@ -189,17 +219,18 @@ export class SIOPv2RP implements IAgentPlugin {
|
|
|
189
219
|
| IVerifiablePresentation
|
|
190
220
|
| SdJwtDecodedVerifiableCredential
|
|
191
221
|
| MdocOid4vpMdocVpToken
|
|
192
|
-
| MdocDeviceResponse
|
|
193
|
-
): AdditionalClaims | IPresentation =>
|
|
194
|
-
CredentialMapper.isSdJwtDecodedCredential(presentationDecoded)
|
|
222
|
+
| MdocDeviceResponse
|
|
223
|
+
): AdditionalClaims | IPresentation => {
|
|
224
|
+
return CredentialMapper.isSdJwtDecodedCredential(presentationDecoded)
|
|
195
225
|
? presentationDecoded.decodedPayload
|
|
196
226
|
: CredentialMapper.toUniformPresentation(presentationDecoded as OriginalVerifiablePresentation)
|
|
227
|
+
}
|
|
197
228
|
|
|
198
229
|
private async siopUpdateRequestState(args: IUpdateRequestStateArgs, context: IRequiredContext): Promise<AuthorizationRequestState> {
|
|
199
230
|
if (args.state !== 'authorization_request_created') {
|
|
200
231
|
throw Error(`Only 'authorization_request_created' status is supported for this method at this point`)
|
|
201
232
|
}
|
|
202
|
-
return await this.getRPInstance({ queryId: args.queryId }, context)
|
|
233
|
+
return await this.getRPInstance({ createWhenNotPresent: false, queryId: args.queryId }, context)
|
|
203
234
|
// todo: In the SIOP library we need to update the signal method to be more like this method
|
|
204
235
|
.then((rp) =>
|
|
205
236
|
rp.get(context).then(async (rp) => {
|
|
@@ -213,7 +244,7 @@ export class SIOPv2RP implements IAgentPlugin {
|
|
|
213
244
|
}
|
|
214
245
|
|
|
215
246
|
private async siopDeleteState(args: IGetAuthResponseStateArgs, context: IRequiredContext): Promise<boolean> {
|
|
216
|
-
return await this.getRPInstance({ queryId: args.queryId }, context)
|
|
247
|
+
return await this.getRPInstance({ createWhenNotPresent: false, queryId: args.queryId }, context)
|
|
217
248
|
.then((rp) => rp.get(context).then((rp) => rp.sessionManager.deleteStateForCorrelationId(args.correlationId)))
|
|
218
249
|
.then(() => true)
|
|
219
250
|
}
|
|
@@ -226,12 +257,12 @@ export class SIOPv2RP implements IAgentPlugin {
|
|
|
226
257
|
typeof args.authorizationResponse === 'string'
|
|
227
258
|
? (decodeUriAsJson(args.authorizationResponse) as AuthorizationResponsePayload)
|
|
228
259
|
: args.authorizationResponse
|
|
229
|
-
return await this.getRPInstance({ queryId: args.queryId }, context).then((rp) =>
|
|
260
|
+
return await this.getRPInstance({ createWhenNotPresent: false, queryId: args.queryId }, context).then((rp) =>
|
|
230
261
|
rp.get(context).then((rp) =>
|
|
231
262
|
rp.verifyAuthorizationResponse(authResponse, {
|
|
232
263
|
correlationId: args.correlationId,
|
|
233
|
-
|
|
234
|
-
|
|
264
|
+
...(args.dcqlQuery && { dcqlQuery: args.dcqlQuery }),
|
|
265
|
+
audience: args.audience,
|
|
235
266
|
}),
|
|
236
267
|
),
|
|
237
268
|
)
|
|
@@ -273,9 +304,36 @@ export class SIOPv2RP implements IAgentPlugin {
|
|
|
273
304
|
return undefined
|
|
274
305
|
}
|
|
275
306
|
|
|
276
|
-
async getRPInstance({ queryId, responseRedirectURI }: ISiopRPInstanceArgs, context: IRequiredContext): Promise<RPInstance> {
|
|
277
|
-
|
|
278
|
-
|
|
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
|
+
}
|
|
279
337
|
const instanceOpts = this.getInstanceOpts(queryId)
|
|
280
338
|
const rpOpts = await this.getRPOptions(context, { queryId, responseRedirectURI: responseRedirectURI })
|
|
281
339
|
if (!rpOpts.identifierOpts.resolveOpts?.resolver || typeof rpOpts.identifierOpts.resolveOpts.resolver.resolve !== 'function') {
|
|
@@ -290,9 +348,9 @@ export class SIOPv2RP implements IAgentPlugin {
|
|
|
290
348
|
resolverResolution: true,
|
|
291
349
|
})
|
|
292
350
|
}
|
|
293
|
-
|
|
351
|
+
rpInstance = new RPInstance({ rpOpts, pexOpts: instanceOpts })
|
|
352
|
+
this.instances.set(rpInstanceId, rpInstance)
|
|
294
353
|
}
|
|
295
|
-
const rpInstance = this.instances.get(instanceId)!
|
|
296
354
|
if (responseRedirectURI) {
|
|
297
355
|
rpInstance.rpOptions.responseRedirectUri = responseRedirectURI
|
|
298
356
|
}
|
|
@@ -334,22 +392,22 @@ export class SIOPv2RP implements IAgentPlugin {
|
|
|
334
392
|
return options
|
|
335
393
|
}
|
|
336
394
|
|
|
337
|
-
getInstanceOpts(
|
|
395
|
+
getInstanceOpts(queryId?: string): IPEXInstanceOptions | undefined {
|
|
338
396
|
if (!this.opts.instanceOpts) return undefined
|
|
339
397
|
|
|
340
|
-
const instanceOpt =
|
|
398
|
+
const instanceOpt = queryId ? this.opts.instanceOpts.find((i) => i.queryId === queryId) : undefined
|
|
341
399
|
|
|
342
|
-
return instanceOpt ?? this.getDefaultOptions(
|
|
400
|
+
return instanceOpt ?? this.getDefaultOptions(queryId)
|
|
343
401
|
}
|
|
344
402
|
|
|
345
|
-
private getDefaultOptions(
|
|
403
|
+
private getDefaultOptions(queryId: string | undefined) {
|
|
346
404
|
if (!this.opts.instanceOpts) return undefined
|
|
347
405
|
|
|
348
406
|
const defaultOptions = this.opts.instanceOpts.find((i) => i.queryId === 'default')
|
|
349
407
|
if (defaultOptions) {
|
|
350
408
|
const clonedOptions = { ...defaultOptions }
|
|
351
|
-
if (
|
|
352
|
-
clonedOptions.queryId =
|
|
409
|
+
if (queryId !== undefined) {
|
|
410
|
+
clonedOptions.queryId = queryId
|
|
353
411
|
}
|
|
354
412
|
return clonedOptions
|
|
355
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'
|
|
@@ -34,7 +35,7 @@ import { TKeyType } from '@veramo/core'
|
|
|
34
35
|
import { JWTVerifyOptions } from 'did-jwt'
|
|
35
36
|
import { Resolvable } from 'did-resolver'
|
|
36
37
|
import { EventEmitter } from 'events'
|
|
37
|
-
import {
|
|
38
|
+
import { IRequiredContext, IRPOptions, ISIOPIdentifierOptions } from './types/ISIOPv2RP'
|
|
38
39
|
import { DcqlQuery } from 'dcql'
|
|
39
40
|
import { defaultHasher } from '@sphereon/ssi-sdk.core'
|
|
40
41
|
|
|
@@ -42,7 +43,7 @@ export function getRequestVersion(rpOptions: IRPOptions): SupportedVersion {
|
|
|
42
43
|
if (Array.isArray(rpOptions.supportedVersions) && rpOptions.supportedVersions.length > 0) {
|
|
43
44
|
return rpOptions.supportedVersions[0]
|
|
44
45
|
}
|
|
45
|
-
return SupportedVersion.
|
|
46
|
+
return SupportedVersion.OID4VP_v1
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
function getWellKnownDIDVerifyCallback(siopIdentifierOpts: ISIOPIdentifierOptions, context: IRequiredContext) {
|
|
@@ -57,6 +58,31 @@ function getWellKnownDIDVerifyCallback(siopIdentifierOpts: ISIOPIdentifierOption
|
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
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
|
+
|
|
60
86
|
export function getPresentationVerificationCallback(
|
|
61
87
|
idOpts: ManagedIdentifierOptsOrResult,
|
|
62
88
|
context: IRequiredContext,
|
|
@@ -101,34 +127,11 @@ export function getPresentationVerificationCallback(
|
|
|
101
127
|
|
|
102
128
|
export async function createRPBuilder(args: {
|
|
103
129
|
rpOpts: IRPOptions
|
|
104
|
-
pexOpts?: IPEXOptions | undefined
|
|
105
130
|
definition?: IPresentationDefinition
|
|
106
|
-
dcql?: DcqlQuery
|
|
107
131
|
context: IRequiredContext
|
|
108
132
|
}): Promise<RPBuilder> {
|
|
109
|
-
const { rpOpts,
|
|
133
|
+
const { rpOpts, context } = args
|
|
110
134
|
const { identifierOpts } = rpOpts
|
|
111
|
-
let definition: IPresentationDefinition | undefined = args.definition
|
|
112
|
-
let dcqlQuery: DcqlQuery | undefined = args.dcql
|
|
113
|
-
|
|
114
|
-
if (!definition && pexOpts && pexOpts.queryId) {
|
|
115
|
-
const presentationDefinitionItems = await context.agent.pdmGetDefinitions({
|
|
116
|
-
filter: [
|
|
117
|
-
{
|
|
118
|
-
queryId: pexOpts.queryId,
|
|
119
|
-
version: pexOpts.version,
|
|
120
|
-
tenantId: pexOpts.tenantId,
|
|
121
|
-
},
|
|
122
|
-
],
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
if (presentationDefinitionItems.length > 0) {
|
|
126
|
-
const presentationDefinitionItem = presentationDefinitionItems[0]
|
|
127
|
-
if (!dcqlQuery && presentationDefinitionItem.dcqlPayload) {
|
|
128
|
-
dcqlQuery = presentationDefinitionItem.dcqlPayload.dcqlQuery as DcqlQuery // cast from DcqlQueryREST back to valibot DcqlQuery
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
135
|
|
|
133
136
|
const didMethods = identifierOpts.supportedDIDMethods ?? (await getAgentDIDMethods(context))
|
|
134
137
|
const eventEmitter = rpOpts.eventEmitter ?? new EventEmitter()
|
|
@@ -168,9 +171,7 @@ export async function createRPBuilder(args: {
|
|
|
168
171
|
.withResponseMode(rpOpts.responseMode ?? ResponseMode.POST)
|
|
169
172
|
.withResponseType(ResponseType.VP_TOKEN, PropertyTarget.REQUEST_OBJECT)
|
|
170
173
|
// todo: move to options fill/correct method
|
|
171
|
-
.withSupportedVersions(
|
|
172
|
-
rpOpts.supportedVersions ?? [SupportedVersion.JWT_VC_PRESENTATION_PROFILE_v1, SupportedVersion.SIOPv2_ID1, SupportedVersion.SIOPv2_D11],
|
|
173
|
-
)
|
|
174
|
+
.withSupportedVersions(rpOpts.supportedVersions ?? [SupportedVersion.OID4VP_v1, SupportedVersion.SIOPv2_OID4VP_D28])
|
|
174
175
|
|
|
175
176
|
.withEventEmitter(eventEmitter)
|
|
176
177
|
.withSessionManager(rpOpts.sessionManager ?? new InMemoryRPSessionManager(eventEmitter))
|
|
@@ -189,6 +190,7 @@ export async function createRPBuilder(args: {
|
|
|
189
190
|
context,
|
|
190
191
|
),
|
|
191
192
|
)
|
|
193
|
+
.withDcqlQueryLookup(getDcqlQueryLookupCallback(context))
|
|
192
194
|
.withRevocationVerification(RevocationVerification.NEVER)
|
|
193
195
|
.withPresentationVerification(getPresentationVerificationCallback(identifierOpts.idOpts, context))
|
|
194
196
|
|
|
@@ -197,11 +199,12 @@ export async function createRPBuilder(args: {
|
|
|
197
199
|
builder.withEntityId(oidfOpts.identifier, PropertyTarget.REQUEST_OBJECT)
|
|
198
200
|
} else {
|
|
199
201
|
const resolution = await context.agent.identifierManagedGet(identifierOpts.idOpts)
|
|
200
|
-
const clientId: string =
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
)
|
|
202
|
+
const clientId: string =
|
|
203
|
+
rpOpts.clientMetadataOpts?.client_id ??
|
|
204
|
+
resolution.issuer ??
|
|
205
|
+
(isManagedIdentifierDidResult(resolution) ? resolution.did : resolution.jwkThumbprint)
|
|
206
|
+
const clientIdPrefixed = prefixClientId(clientId)
|
|
207
|
+
builder.withClientId(clientIdPrefixed, PropertyTarget.REQUEST_OBJECT)
|
|
205
208
|
}
|
|
206
209
|
|
|
207
210
|
if (hasher) {
|
|
@@ -215,10 +218,6 @@ export async function createRPBuilder(args: {
|
|
|
215
218
|
//fixme: this has been removed in the new version of did-auth-siop
|
|
216
219
|
// builder.withWellknownDIDVerifyCallback(getWellKnownDIDVerifyCallback(didOpts, context))
|
|
217
220
|
|
|
218
|
-
if (dcqlQuery) {
|
|
219
|
-
builder.withDcqlQuery(dcqlQuery)
|
|
220
|
-
}
|
|
221
|
-
|
|
222
221
|
if (rpOpts.responseRedirectUri) {
|
|
223
222
|
builder.withResponseRedirectUri(rpOpts.responseRedirectUri)
|
|
224
223
|
}
|
|
@@ -303,8 +302,8 @@ export function getSigningAlgo(type: TKeyType): SigningAlgo {
|
|
|
303
302
|
export function prefixClientId(clientId: string): string {
|
|
304
303
|
// FIXME SSISDK-60
|
|
305
304
|
if (clientId.startsWith('did:')) {
|
|
306
|
-
return `${ClientIdentifierPrefix.DECENTRALIZED_IDENTIFIER}:${clientId}
|
|
305
|
+
return `${ClientIdentifierPrefix.DECENTRALIZED_IDENTIFIER}:${clientId}`
|
|
307
306
|
}
|
|
308
307
|
|
|
309
|
-
return clientId
|
|
308
|
+
return clientId
|
|
310
309
|
}
|
package/src/types/ISIOPv2RP.ts
CHANGED
|
@@ -32,16 +32,9 @@ 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
|
-
|
|
36
35
|
import { Resolvable } from 'did-resolver'
|
|
37
36
|
import { EventEmitter } from 'events'
|
|
38
37
|
|
|
39
|
-
export enum VerifiedDataMode {
|
|
40
|
-
NONE = 'none',
|
|
41
|
-
VERIFIED_PRESENTATION = 'vp',
|
|
42
|
-
CREDENTIAL_SUBJECT_FLATTENED = 'cs-flat',
|
|
43
|
-
}
|
|
44
|
-
|
|
45
38
|
export interface ISIOPv2RP extends IPluginMethodMap {
|
|
46
39
|
siopCreateAuthRequestURI(createArgs: ICreateAuthRequestArgs, context: IRequiredContext): Promise<string>
|
|
47
40
|
siopCreateAuthRequestPayloads(createArgs: ICreateAuthRequestArgs, context: IRequiredContext): Promise<IAuthorizationRequestPayloads>
|
|
@@ -90,11 +83,10 @@ export interface IGetAuthResponseStateArgs {
|
|
|
90
83
|
queryId?: string
|
|
91
84
|
errorOnNotFound?: boolean
|
|
92
85
|
progressRequestStateTo?: AuthorizationRequestStateStatus
|
|
93
|
-
includeVerifiedData?: VerifiedDataMode
|
|
94
86
|
}
|
|
95
87
|
|
|
96
88
|
export interface IUpdateRequestStateArgs {
|
|
97
|
-
queryId
|
|
89
|
+
queryId?: string
|
|
98
90
|
correlationId: string
|
|
99
91
|
state: AuthorizationRequestStateStatus
|
|
100
92
|
error?: string
|
|
@@ -137,11 +129,12 @@ export interface IPEXDefinitionPersistArgs extends IPEXInstanceOptions {
|
|
|
137
129
|
}
|
|
138
130
|
|
|
139
131
|
export interface ISiopRPInstanceArgs {
|
|
132
|
+
createWhenNotPresent: boolean
|
|
140
133
|
queryId?: string
|
|
141
134
|
responseRedirectURI?: string
|
|
142
135
|
}
|
|
143
136
|
|
|
144
|
-
export interface IPEXInstanceOptions extends
|
|
137
|
+
export interface IPEXInstanceOptions extends IPresentationOptions {
|
|
145
138
|
rpOpts?: IRPOptions
|
|
146
139
|
}
|
|
147
140
|
|
|
@@ -159,12 +152,9 @@ export interface IRPOptions {
|
|
|
159
152
|
responseRedirectUri?: string
|
|
160
153
|
}
|
|
161
154
|
|
|
162
|
-
export interface
|
|
163
|
-
presentationVerifyCallback?: PresentationVerificationCallback
|
|
164
|
-
// definition?: IPresentationDefinition
|
|
155
|
+
export interface IPresentationOptions {
|
|
165
156
|
queryId: string
|
|
166
|
-
|
|
167
|
-
tenantId?: string
|
|
157
|
+
presentationVerifyCallback?: PresentationVerificationCallback
|
|
168
158
|
}
|
|
169
159
|
|
|
170
160
|
export type VerificationPolicies = {
|