@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth 0.34.1-feature.SSISDK.45.135 → 0.34.1-feature.SSISDK.45.189

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/src/functions.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import {
2
- ClientIdScheme,
2
+ ClientIdentifierPrefix,
3
3
  ClientMetadataOpts,
4
4
  InMemoryRPSessionManager,
5
5
  PassBy,
@@ -14,7 +14,7 @@ import {
14
14
  Scope,
15
15
  SubjectType,
16
16
  SupportedVersion,
17
- VerifyJwtCallback,
17
+ VerifyJwtCallback
18
18
  } from '@sphereon/did-auth-siop'
19
19
  import { CreateJwtCallback, JwtHeader, JwtIssuer, JwtPayload, SigningAlgo } from '@sphereon/oid4vc-common'
20
20
  import { IPresentationDefinition } from '@sphereon/pex'
@@ -28,9 +28,8 @@ import {
28
28
  } from '@sphereon/ssi-sdk-ext.identifier-resolution'
29
29
  import { JwtCompactResult } from '@sphereon/ssi-sdk-ext.jwt-service'
30
30
  import { IVerifySdJwtPresentationResult } from '@sphereon/ssi-sdk.sd-jwt'
31
- import { CredentialMapper, Hasher, OriginalVerifiableCredential, PresentationSubmission } from '@sphereon/ssi-types'
31
+ import { CredentialMapper, HasherSync, OriginalVerifiableCredential, PresentationSubmission } from '@sphereon/ssi-types'
32
32
  import { IVerifyCallbackArgs, IVerifyCredentialResult, VerifyCallback } from '@sphereon/wellknown-dids-client'
33
- // import { KeyAlgo, SuppliedSigner } from '@sphereon/ssi-sdk.core'
34
33
  import { TKeyType } from '@veramo/core'
35
34
  import { JWTVerifyOptions } from 'did-jwt'
36
35
  import { Resolvable } from 'did-resolver'
@@ -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 }
@@ -117,7 +115,7 @@ export async function createRPBuilder(args: {
117
115
  const presentationDefinitionItems = await context.agent.pdmGetDefinitions({
118
116
  filter: [
119
117
  {
120
- definitionId: pexOpts.queryId,
118
+ queryId: pexOpts.queryId,
121
119
  version: pexOpts.version,
122
120
  tenantId: pexOpts.tenantId,
123
121
  },
@@ -126,9 +124,8 @@ export async function createRPBuilder(args: {
126
124
 
127
125
  if (presentationDefinitionItems.length > 0) {
128
126
  const presentationDefinitionItem = presentationDefinitionItems[0]
129
- definition = presentationDefinitionItem.definitionPayload
130
127
  if (!dcqlQuery && presentationDefinitionItem.dcqlPayload) {
131
- dcqlQuery = presentationDefinitionItem.dcqlPayload as DcqlQuery // cast from DcqlQueryREST back to valibot DcqlQuery
128
+ dcqlQuery = presentationDefinitionItem.dcqlPayload.dcqlQuery as DcqlQuery // cast from DcqlQueryREST back to valibot DcqlQuery
132
129
  }
133
130
  }
134
131
  }
@@ -161,7 +158,7 @@ export async function createRPBuilder(args: {
161
158
  uniresolverResolution: rpOpts.identifierOpts.resolveOpts?.noUniversalResolverFallback !== true,
162
159
  })
163
160
  //todo: probably wise to first look and see if we actually need the hasher to begin with
164
- let hasher: Hasher | undefined = rpOpts.credentialOpts?.hasher
161
+ let hasher: HasherSync | undefined = rpOpts.credentialOpts?.hasher
165
162
  if (!rpOpts.credentialOpts?.hasher || typeof rpOpts.credentialOpts?.hasher !== 'function') {
166
163
  hasher = defaultHasher
167
164
  }
@@ -197,18 +194,14 @@ export async function createRPBuilder(args: {
197
194
 
198
195
  const oidfOpts = identifierOpts.oidfOpts
199
196
  if (oidfOpts && isExternalIdentifierOIDFEntityIdOpts(oidfOpts)) {
200
- builder.withEntityId(oidfOpts.identifier, PropertyTarget.REQUEST_OBJECT).withClientIdScheme('entity_id', PropertyTarget.REQUEST_OBJECT)
197
+ builder.withEntityId(oidfOpts.identifier, PropertyTarget.REQUEST_OBJECT)
201
198
  } else {
202
199
  const resolution = await context.agent.identifierManagedGet(identifierOpts.idOpts)
203
- builder
204
- .withClientId(
205
- resolution.issuer ?? (isManagedIdentifierDidResult(resolution) ? resolution.did : resolution.jwkThumbprint),
206
- PropertyTarget.REQUEST_OBJECT,
207
- )
208
- .withClientIdScheme(
209
- (resolution.clientIdScheme as ClientIdScheme) ?? (identifierOpts.idOpts.clientIdScheme as ClientIdScheme),
210
- PropertyTarget.REQUEST_OBJECT,
211
- )
200
+ const clientId: string = rpOpts.clientMetadataOpts?.client_id ??
201
+ resolution.issuer ?? (isManagedIdentifierDidResult(resolution) ? resolution.did : resolution.jwkThumbprint)
202
+ const clientIdPrefixed = prefixClientId(clientId)
203
+ builder.withClientId(clientIdPrefixed, 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
  }
@@ -309,3 +299,12 @@ export function getSigningAlgo(type: TKeyType): SigningAlgo {
309
299
  throw Error('Key type not yet supported')
310
300
  }
311
301
  }
302
+
303
+ export function prefixClientId(clientId: string): string {
304
+ // FIXME SSISDK-60
305
+ if (clientId.startsWith('did:')) {
306
+ return `${ClientIdentifierPrefix.DECENTRALIZED_IDENTIFIER}:${clientId}`;
307
+ }
308
+
309
+ return clientId;
310
+ }
@@ -24,13 +24,14 @@ 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 { DcqlQueryPayload, HasherSync } from '@sphereon/ssi-types'
31
+ import { HasherSync } from '@sphereon/ssi-types'
32
32
  import { VerifyCallback } from '@sphereon/wellknown-dids-client'
33
- import { IAgentContext, ICredentialIssuer, ICredentialVerifier, IDIDManager, IKeyManager, IPluginMethodMap, IResolver } from '@veramo/core'
33
+ import { IAgentContext, ICredentialVerifier, IDIDManager, IKeyManager, IPluginMethodMap, IResolver } from '@veramo/core'
34
+ import { DcqlQuery } from 'dcql'
34
35
  import { Resolvable } from 'did-resolver'
35
36
  import { EventEmitter } from 'events'
36
37
 
@@ -108,16 +109,10 @@ export interface IVerifyAuthResponseStateArgs {
108
109
  queryId?: string
109
110
  correlationId: string
110
111
  audience?: string
111
- dcqlQueryPayload?: DcqlQueryPayload
112
+ dcqlQuery?: DcqlQuery
112
113
  }
113
-
114
- export interface IDefinitionPair {
115
- definitionPayload?: IPresentationDefinition
116
- dcqlPayload?: DcqlQueryPayload
117
- }
118
-
119
114
  export interface ImportDefinitionsArgs {
120
- queries: Array<IDefinitionPair>
115
+ importItems: Array<ImportDcqlQueryItem>
121
116
  tenantId?: string
122
117
  version?: string
123
118
  versionControlMode?: VersionControlMode
@@ -204,7 +199,6 @@ export type IRequiredContext = IAgentContext<
204
199
  IDIDManager &
205
200
  IKeyManager &
206
201
  IIdentifierResolution &
207
- ICredentialIssuer &
208
202
  ICredentialValidation &
209
203
  ICredentialVerifier &
210
204
  IPresentationExchange &