@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth 0.34.1-fix.166 → 0.34.1-fix.167

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.
@@ -10,18 +10,18 @@ import {
10
10
  import { getAgentResolver } from '@sphereon/ssi-sdk-ext.did-utils'
11
11
  import { shaHasher as defaultHasher } from '@sphereon/ssi-sdk.core'
12
12
  import {
13
- AdditionalClaims,
13
+ //AdditionalClaims,
14
14
  CredentialMapper,
15
15
  HasherSync,
16
- ICredentialSubject,
17
- IPresentation,
18
- IVerifiableCredential,
19
- IVerifiablePresentation,
20
- JwtDecodedVerifiablePresentation,
21
- MdocDeviceResponse,
22
- MdocOid4vpMdocVpToken,
16
+ //ICredentialSubject,
17
+ //IPresentation,
18
+ //IVerifiableCredential,
19
+ //IVerifiablePresentation,
20
+ //JwtDecodedVerifiablePresentation,
21
+ //MdocDeviceResponse,
22
+ //MdocOid4vpMdocVpToken,
23
23
  OriginalVerifiablePresentation,
24
- SdJwtDecodedVerifiableCredential,
24
+ //SdJwtDecodedVerifiableCredential,
25
25
  } from '@sphereon/ssi-types'
26
26
  import { IAgentPlugin } from '@veramo/core'
27
27
  import { DcqlQuery } from 'dcql'
@@ -41,7 +41,7 @@ import {
41
41
  IUpdateRequestStateArgs,
42
42
  IVerifyAuthResponseStateArgs,
43
43
  schema,
44
- VerifiedDataMode,
44
+ // VerifiedDataMode,
45
45
  } from '../index'
46
46
  import { RPInstance } from '../RPInstance'
47
47
  import { ISIOPv2RP } from '../types/ISIOPv2RP'
@@ -126,10 +126,11 @@ export class SIOPv2RP implements IAgentPlugin {
126
126
  }
127
127
 
128
128
  const responseState = authorizationResponseState as AuthorizationResponseStateWithVerifiedData
129
- if (
130
- responseState.status === AuthorizationResponseStateStatus.VERIFIED &&
131
- args.includeVerifiedData &&
132
- args.includeVerifiedData !== VerifiedDataMode.NONE
129
+ if (responseState.status === AuthorizationResponseStateStatus.VERIFIED
130
+
131
+ //&&
132
+ // args.includeVerifiedData &&
133
+ // args.includeVerifiedData !== VerifiedDataMode.NONE
133
134
  ) {
134
135
  let hasher: HasherSync | undefined
135
136
  if (
@@ -144,54 +145,70 @@ export class SIOPv2RP implements IAgentPlugin {
144
145
  //todo: later we want to conditionally pass in options for mdl-mdoc here
145
146
  hasher,
146
147
  )
147
- switch (args.includeVerifiedData) {
148
- case VerifiedDataMode.VERIFIED_PRESENTATION:
149
- responseState.response.payload.verifiedData = this.presentationOrClaimsFrom(presentationDecoded)
150
- break
151
- case VerifiedDataMode.CREDENTIAL_SUBJECT_FLATTENED: // TODO debug cs-flat for SD-JWT
152
- const allClaims: AdditionalClaims = {}
153
- for (const credential of this.presentationOrClaimsFrom(presentationDecoded).verifiableCredential || []) {
154
- const vc = credential as IVerifiableCredential
155
- const schemaValidationResult = await context.agent.cvVerifySchema({
156
- credential,
157
- hasher,
158
- validationPolicy: rpInstance.rpOptions.verificationPolicies?.schemaValidation,
159
- })
160
- if (!schemaValidationResult.result) {
161
- responseState.status = AuthorizationResponseStateStatus.ERROR
162
- responseState.error = new Error(schemaValidationResult.error)
163
- return responseState
164
- }
165
-
166
- const credentialSubject = vc.credentialSubject as ICredentialSubject & AdditionalClaims
167
- if (!('id' in allClaims)) {
168
- allClaims['id'] = credentialSubject.id
169
- }
148
+ console.log(`presentationDecoded: ${JSON.stringify(presentationDecoded)}`)
170
149
 
171
- Object.entries(credentialSubject).forEach(([key, value]) => {
172
- if (!(key in allClaims)) {
173
- allClaims[key] = value
174
- }
175
- })
150
+ responseState.verifiedData = {
151
+ ...(responseState.response.payload.vp_token && {
152
+ authorization_response: {
153
+ vp_token: typeof responseState.response.payload.vp_token === 'string'
154
+ ? JSON.parse(responseState.response.payload.vp_token)
155
+ : responseState.response.payload.vp_token
176
156
  }
177
- responseState.verifiedData = allClaims
178
- break
157
+ }),
158
+
159
+ // TODO use ??
160
+ credential_claims: []//(this.presentationOrClaimsFrom(presentationDecoded).verifiableCredential || []).map()
179
161
  }
162
+
163
+ // switch (args.includeVerifiedData) {
164
+ // case VerifiedDataMode.VERIFIED_PRESENTATION:
165
+ // responseState.response.payload.verifiedData = this.presentationOrClaimsFrom(presentationDecoded)
166
+ // break
167
+ // case VerifiedDataMode.CREDENTIAL_SUBJECT_FLATTENED: // TODO debug cs-flat for SD-JWT
168
+ // const allClaims: AdditionalClaims = {}
169
+ // for (const credential of this.presentationOrClaimsFrom(presentationDecoded).verifiableCredential || []) {
170
+ // const vc = credential as IVerifiableCredential
171
+ // const schemaValidationResult = await context.agent.cvVerifySchema({
172
+ // credential,
173
+ // hasher,
174
+ // validationPolicy: rpInstance.rpOptions.verificationPolicies?.schemaValidation,
175
+ // })
176
+ // if (!schemaValidationResult.result) {
177
+ // responseState.status = AuthorizationResponseStateStatus.ERROR
178
+ // responseState.error = new Error(schemaValidationResult.error)
179
+ // return responseState
180
+ // }
181
+ //
182
+ // const credentialSubject = vc.credentialSubject as ICredentialSubject & AdditionalClaims
183
+ // if (!('id' in allClaims)) {
184
+ // allClaims['id'] = credentialSubject.id
185
+ // }
186
+ //
187
+ // Object.entries(credentialSubject).forEach(([key, value]) => {
188
+ // if (!(key in allClaims)) {
189
+ // allClaims[key] = value
190
+ // }
191
+ // })
192
+ // }
193
+ // responseState.verifiedData = allClaims
194
+ // break
195
+ // }
180
196
  }
181
197
  return responseState
182
198
  }
183
199
 
184
- private presentationOrClaimsFrom = (
185
- presentationDecoded:
186
- | JwtDecodedVerifiablePresentation
187
- | IVerifiablePresentation
188
- | SdJwtDecodedVerifiableCredential
189
- | MdocOid4vpMdocVpToken
190
- | MdocDeviceResponse,
191
- ): AdditionalClaims | IPresentation =>
192
- CredentialMapper.isSdJwtDecodedCredential(presentationDecoded)
193
- ? presentationDecoded.decodedPayload
194
- : CredentialMapper.toUniformPresentation(presentationDecoded as OriginalVerifiablePresentation)
200
+ // private presentationOrClaimsFrom = (
201
+ // presentationDecoded:
202
+ // | JwtDecodedVerifiablePresentation
203
+ // | IVerifiablePresentation
204
+ // | SdJwtDecodedVerifiableCredential
205
+ // | MdocOid4vpMdocVpToken
206
+ // | MdocDeviceResponse
207
+ // | DcqlPresentation
208
+ // ): AdditionalClaims | IPresentation =>
209
+ // CredentialMapper.isSdJwtDecodedCredential(presentationDecoded)
210
+ // ? presentationDecoded.decodedPayload
211
+ // : CredentialMapper.toUniformPresentation(presentationDecoded as OriginalVerifiablePresentation)
195
212
 
196
213
  private async siopUpdateRequestState(args: IUpdateRequestStateArgs, context: IRequiredContext): Promise<AuthorizationRequestState> {
197
214
  if (args.state !== 'authorization_request_created') {
@@ -89,11 +89,11 @@ export interface IGetAuthResponseStateArgs {
89
89
  queryId?: string
90
90
  errorOnNotFound?: boolean
91
91
  progressRequestStateTo?: AuthorizationRequestStateStatus
92
- includeVerifiedData?: VerifiedDataMode
92
+ //includeVerifiedData?: VerifiedDataMode
93
93
  }
94
94
 
95
95
  export interface IUpdateRequestStateArgs {
96
- queryId: string
96
+ queryId?: string
97
97
  correlationId: string
98
98
  state: AuthorizationRequestStateStatus
99
99
  error?: string