@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth 0.34.1-feature.SSISDK.50.98 → 0.34.1-feature.SSISDK.50.type.refactor.142
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 +16 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -9
- package/dist/index.d.ts +6 -9
- package/dist/index.js +16 -38
- package/dist/index.js.map +1 -1
- package/package.json +17 -17
- package/src/agent/SIOPv2RP.ts +10 -23
- package/src/functions.ts +9 -19
- package/src/types/ISIOPv2RP.ts +5 -10
package/src/agent/SIOPv2RP.ts
CHANGED
|
@@ -7,6 +7,9 @@ import {
|
|
|
7
7
|
VerifiedAuthorizationResponse,
|
|
8
8
|
} from '@sphereon/did-auth-siop'
|
|
9
9
|
import { getAgentResolver } from '@sphereon/ssi-sdk-ext.did-utils'
|
|
10
|
+
import { shaHasher as defaultHasher } from '@sphereon/ssi-sdk.core'
|
|
11
|
+
|
|
12
|
+
import type { DcqlQueryImportItem } from '@sphereon/ssi-sdk.pd-manager'
|
|
10
13
|
import {
|
|
11
14
|
AdditionalClaims,
|
|
12
15
|
CredentialMapper,
|
|
@@ -45,7 +48,6 @@ import {
|
|
|
45
48
|
import { RPInstance } from '../RPInstance'
|
|
46
49
|
|
|
47
50
|
import { ISIOPv2RP } from '../types/ISIOPv2RP'
|
|
48
|
-
import { shaHasher as defaultHasher } from '@sphereon/ssi-sdk.core'
|
|
49
51
|
|
|
50
52
|
export class SIOPv2RP implements IAgentPlugin {
|
|
51
53
|
private readonly opts: ISiopv2RPOpts
|
|
@@ -227,7 +229,7 @@ export class SIOPv2RP implements IAgentPlugin {
|
|
|
227
229
|
rp.get(context).then((rp) =>
|
|
228
230
|
rp.verifyAuthorizationResponse(authResponse, {
|
|
229
231
|
correlationId: args.correlationId,
|
|
230
|
-
...(args.
|
|
232
|
+
...(args.dcqlQuery ? { dcqlQuery: args.dcqlQuery } : {}),
|
|
231
233
|
audience: args.audience,
|
|
232
234
|
}),
|
|
233
235
|
),
|
|
@@ -235,33 +237,18 @@ export class SIOPv2RP implements IAgentPlugin {
|
|
|
235
237
|
}
|
|
236
238
|
|
|
237
239
|
private async siopImportDefinitions(args: ImportDefinitionsArgs, context: IRequiredContext): Promise<void> {
|
|
238
|
-
const {
|
|
240
|
+
const { importItems, tenantId, version, versionControlMode } = args
|
|
239
241
|
await Promise.all(
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
return Promise.reject(Error('Either dcqlPayload or definitionPayload must be suppplied'))
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
let definitionId: string
|
|
247
|
-
if (definitionPair.dcqlPayload) {
|
|
248
|
-
DcqlQuery.validate(definitionPair.dcqlPayload.dcqlQuery)
|
|
249
|
-
console.log(`persisting DCQL definition ${definitionPair.dcqlPayload.queryId} with versionControlMode ${versionControlMode}`)
|
|
250
|
-
definitionId = definitionPair.dcqlPayload.queryId
|
|
251
|
-
}
|
|
252
|
-
if (definitionPayload) {
|
|
253
|
-
await context.agent.pexValidateDefinition({ definition: definitionPayload })
|
|
254
|
-
console.log(`persisting PEX definition ${definitionPayload.id} / ${definitionPayload.name} with versionControlMode ${versionControlMode}`)
|
|
255
|
-
definitionId = definitionPayload.id
|
|
256
|
-
}
|
|
242
|
+
importItems.map(async (importItem: DcqlQueryImportItem) => {
|
|
243
|
+
DcqlQuery.validate(importItem.dcqlQuery)
|
|
244
|
+
console.log(`persisting DCQL definition ${importItem.queryId} with versionControlMode ${versionControlMode}`)
|
|
257
245
|
|
|
258
246
|
return context.agent.pdmPersistDefinition({
|
|
259
247
|
definitionItem: {
|
|
260
|
-
definitionId:
|
|
248
|
+
definitionId: importItem.queryId!,
|
|
261
249
|
tenantId: tenantId,
|
|
262
250
|
version: version,
|
|
263
|
-
|
|
264
|
-
dcqlPayload: definitionPair.dcqlPayload,
|
|
251
|
+
dcqlQuery: importItem.dcqlQuery,
|
|
265
252
|
},
|
|
266
253
|
opts: { versionControlMode: versionControlMode },
|
|
267
254
|
})
|
package/src/functions.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
ClientIdScheme,
|
|
3
2
|
ClientMetadataOpts,
|
|
4
3
|
InMemoryRPSessionManager,
|
|
5
4
|
PassBy,
|
|
@@ -28,7 +27,7 @@ import {
|
|
|
28
27
|
} from '@sphereon/ssi-sdk-ext.identifier-resolution'
|
|
29
28
|
import { JwtCompactResult } from '@sphereon/ssi-sdk-ext.jwt-service'
|
|
30
29
|
import { IVerifySdJwtPresentationResult } from '@sphereon/ssi-sdk.sd-jwt'
|
|
31
|
-
import { CredentialMapper,
|
|
30
|
+
import { CredentialMapper, HasherSync, OriginalVerifiableCredential, PresentationSubmission } from '@sphereon/ssi-types'
|
|
32
31
|
import { IVerifyCallbackArgs, IVerifyCredentialResult, VerifyCallback } from '@sphereon/wellknown-dids-client'
|
|
33
32
|
// import { KeyAlgo, SuppliedSigner } from '@sphereon/ssi-sdk.core'
|
|
34
33
|
import { TKeyType } from '@veramo/core'
|
|
@@ -69,7 +68,6 @@ export function getPresentationVerificationCallback(
|
|
|
69
68
|
if (CredentialMapper.isSdJwtEncoded(args)) {
|
|
70
69
|
const result: IVerifySdJwtPresentationResult = await context.agent.verifySdJwtPresentation({
|
|
71
70
|
presentation: args,
|
|
72
|
-
kb: true,
|
|
73
71
|
})
|
|
74
72
|
// fixme: investigate the correct way to handle this
|
|
75
73
|
return { verified: !!result.payload }
|
|
@@ -127,8 +125,8 @@ export async function createRPBuilder(args: {
|
|
|
127
125
|
if (presentationDefinitionItems.length > 0) {
|
|
128
126
|
const presentationDefinitionItem = presentationDefinitionItems[0]
|
|
129
127
|
definition = presentationDefinitionItem.definitionPayload
|
|
130
|
-
if (!dcqlQuery && presentationDefinitionItem.
|
|
131
|
-
dcqlQuery = presentationDefinitionItem.
|
|
128
|
+
if (!dcqlQuery && presentationDefinitionItem.dcqlQuery) {
|
|
129
|
+
dcqlQuery = presentationDefinitionItem.dcqlQuery as DcqlQuery // cast from DcqlQueryREST back to valibot DcqlQuery
|
|
132
130
|
}
|
|
133
131
|
}
|
|
134
132
|
}
|
|
@@ -161,7 +159,7 @@ export async function createRPBuilder(args: {
|
|
|
161
159
|
uniresolverResolution: rpOpts.identifierOpts.resolveOpts?.noUniversalResolverFallback !== true,
|
|
162
160
|
})
|
|
163
161
|
//todo: probably wise to first look and see if we actually need the hasher to begin with
|
|
164
|
-
let hasher:
|
|
162
|
+
let hasher: HasherSync | undefined = rpOpts.credentialOpts?.hasher
|
|
165
163
|
if (!rpOpts.credentialOpts?.hasher || typeof rpOpts.credentialOpts?.hasher !== 'function') {
|
|
166
164
|
hasher = defaultHasher
|
|
167
165
|
}
|
|
@@ -197,18 +195,13 @@ export async function createRPBuilder(args: {
|
|
|
197
195
|
|
|
198
196
|
const oidfOpts = identifierOpts.oidfOpts
|
|
199
197
|
if (oidfOpts && isExternalIdentifierOIDFEntityIdOpts(oidfOpts)) {
|
|
200
|
-
builder.withEntityId(oidfOpts.identifier, PropertyTarget.REQUEST_OBJECT)
|
|
198
|
+
builder.withEntityId(oidfOpts.identifier, PropertyTarget.REQUEST_OBJECT)
|
|
201
199
|
} else {
|
|
202
200
|
const resolution = await context.agent.identifierManagedGet(identifierOpts.idOpts)
|
|
203
|
-
builder
|
|
204
|
-
.
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
)
|
|
208
|
-
.withClientIdScheme(
|
|
209
|
-
(resolution.clientIdScheme as ClientIdScheme) ?? (identifierOpts.idOpts.clientIdScheme as ClientIdScheme),
|
|
210
|
-
PropertyTarget.REQUEST_OBJECT,
|
|
211
|
-
)
|
|
201
|
+
builder.withClientId(
|
|
202
|
+
resolution.issuer ?? (isManagedIdentifierDidResult(resolution) ? resolution.did : resolution.jwkThumbprint),
|
|
203
|
+
PropertyTarget.REQUEST_OBJECT,
|
|
204
|
+
)
|
|
212
205
|
}
|
|
213
206
|
|
|
214
207
|
if (hasher) {
|
|
@@ -222,9 +215,6 @@ export async function createRPBuilder(args: {
|
|
|
222
215
|
//fixme: this has been removed in the new version of did-auth-siop
|
|
223
216
|
// builder.withWellknownDIDVerifyCallback(getWellKnownDIDVerifyCallback(didOpts, context))
|
|
224
217
|
|
|
225
|
-
if (definition) {
|
|
226
|
-
builder.withPresentationDefinition({ definition }, PropertyTarget.REQUEST_OBJECT)
|
|
227
|
-
}
|
|
228
218
|
if (dcqlQuery) {
|
|
229
219
|
builder.withDcqlQuery(dcqlQuery)
|
|
230
220
|
}
|
package/src/types/ISIOPv2RP.ts
CHANGED
|
@@ -23,13 +23,14 @@ import { ExternalIdentifierOIDFEntityIdOpts, IIdentifierResolution, ManagedIdent
|
|
|
23
23
|
import { IJwtService } from '@sphereon/ssi-sdk-ext.jwt-service'
|
|
24
24
|
import { ICredentialValidation, SchemaValidation } from '@sphereon/ssi-sdk.credential-validation'
|
|
25
25
|
import { ImDLMdoc } from '@sphereon/ssi-sdk.mdl-mdoc'
|
|
26
|
-
import { IPDManager, VersionControlMode } from '@sphereon/ssi-sdk.pd-manager'
|
|
26
|
+
import { IPDManager, VersionControlMode, DcqlQueryImportItem } from '@sphereon/ssi-sdk.pd-manager'
|
|
27
27
|
import { IPresentationExchange } from '@sphereon/ssi-sdk.presentation-exchange'
|
|
28
28
|
import { ISDJwtPlugin } from '@sphereon/ssi-sdk.sd-jwt'
|
|
29
29
|
import { AuthorizationRequestStateStatus } from '@sphereon/ssi-sdk.siopv2-oid4vp-common'
|
|
30
|
-
import { AdditionalClaims,
|
|
30
|
+
import { AdditionalClaims, HasherSync } from '@sphereon/ssi-types'
|
|
31
31
|
import { VerifyCallback } from '@sphereon/wellknown-dids-client'
|
|
32
32
|
import { IAgentContext, ICredentialIssuer, ICredentialVerifier, IDIDManager, IKeyManager, IPluginMethodMap, IResolver } from '@veramo/core'
|
|
33
|
+
import { DcqlQuery } from 'dcql'
|
|
33
34
|
|
|
34
35
|
import { Resolvable } from 'did-resolver'
|
|
35
36
|
import { EventEmitter } from 'events'
|
|
@@ -107,16 +108,10 @@ export interface IVerifyAuthResponseStateArgs {
|
|
|
107
108
|
definitionId?: string
|
|
108
109
|
correlationId: string
|
|
109
110
|
audience?: string
|
|
110
|
-
|
|
111
|
+
dcqlQuery?: DcqlQuery
|
|
111
112
|
}
|
|
112
|
-
|
|
113
|
-
export interface IDefinitionPair {
|
|
114
|
-
definitionPayload?: IPresentationDefinition
|
|
115
|
-
dcqlPayload?: DcqlQueryPayload
|
|
116
|
-
}
|
|
117
|
-
|
|
118
113
|
export interface ImportDefinitionsArgs {
|
|
119
|
-
|
|
114
|
+
importItems: Array<DcqlQueryImportItem>
|
|
120
115
|
tenantId?: string
|
|
121
116
|
version?: string
|
|
122
117
|
versionControlMode?: VersionControlMode
|