@@ -13,14 +13,14 @@ import {
1313 Jwt ,
1414 JwtVerifyResult ,
1515 OpenId4VCIVersion ,
16- ProofOfPossession
16+ ProofOfPossession ,
1717} from '@sphereon/oid4vci-common'
1818import {
1919 AuthorizationServerMetadataBuilder ,
2020 CredentialSupportedBuilderV1_15 ,
2121 MemoryStates ,
2222 VcIssuer ,
23- VcIssuerBuilder
23+ VcIssuerBuilder ,
2424} from '@sphereon/oid4vci-issuer'
2525import { ICredential , IProofPurpose , IProofType , W3CVerifiableCredential } from '@sphereon/ssi-types'
2626import { DIDDocument } from 'did-resolver'
@@ -67,7 +67,7 @@ async function verifyCallbackFunction(args: { jwt: string; kid?: string }): Prom
6767 const did = kid ! . split ( '#' ) [ 0 ]
6868 const didDocument : DIDDocument = {
6969 '@context' : 'https://www.w3.org/ns/did/v1' ,
70- id : did
70+ id : did ,
7171 }
7272 const alg = result . protectedHeader . alg
7373 return {
@@ -77,8 +77,8 @@ async function verifyCallbackFunction(args: { jwt: string; kid?: string }): Prom
7777 didDocument,
7878 jwt : {
7979 header : result . protectedHeader ,
80- payload : result . payload
81- }
80+ payload : result . payload ,
81+ } ,
8282 }
8383}
8484
@@ -108,35 +108,35 @@ describe('issuerCallback', () => {
108108 . withFormat ( 'jwt_vc_json' )
109109 . withCredentialName ( 'UniversityDegree_JWT' )
110110 . withCredentialDefinition ( {
111- type : [ 'VerifiableCredential' , 'UniversityDegree_JWT' ]
111+ type : [ 'VerifiableCredential' , 'UniversityDegree_JWT' ] ,
112112 } )
113113 . withCredentialSupportedDisplay ( {
114114 name : 'University Credential' ,
115115 locale : 'en-US' ,
116116 logo : {
117117 url : 'https://exampleuniversity.com/public/logo.png' ,
118- alt_text : 'a square logo of a university'
118+ alt_text : 'a square logo of a university' ,
119119 } ,
120120 background_color : '#12107c' ,
121- text_color : '#FFFFFF'
121+ text_color : '#FFFFFF' ,
122122 } )
123123 . withCredentialSupportedDisplay ( {
124124 name : 'University Credential' ,
125125 locale : 'en-US' ,
126126 logo : {
127127 url : 'https://exampleuniversity.com/public/logo.png' ,
128- alt_text : 'a square logo of a university'
128+ alt_text : 'a square logo of a university' ,
129129 } ,
130130 background_color : '#12107c' ,
131131 text_color : '#FFFFFF' ,
132132 credential_subject : {
133133 given_name : [
134134 {
135135 name : 'given name' ,
136- locale : 'en-US'
137- }
138- ]
139- }
136+ locale : 'en-US' ,
137+ } ,
138+ ] ,
139+ } ,
140140 } )
141141 . build ( )
142142 const stateManager = new MemoryStates < CredentialOfferSession > ( )
@@ -158,12 +158,12 @@ describe('issuerCallback', () => {
158158 'pre-authorized_code' : 'test_code' ,
159159 tx_code : {
160160 input_mode : 'numeric' ,
161- length : 6
162- }
163- }
164- }
165- }
166- }
161+ length : 6 ,
162+ } ,
163+ } ,
164+ } ,
165+ } ,
166+ } ,
167167 } )
168168
169169 const nonces = new MemoryStates < CNonceState > ( )
@@ -175,24 +175,23 @@ describe('issuerCallback', () => {
175175 . withAuthorizationMetadata ( authorizationServerMetadata )
176176 . withIssuerDisplay ( {
177177 name : 'example issuer' ,
178- locale : 'en-US'
178+ locale : 'en-US' ,
179179 } )
180180 . withCredentialConfigurationsSupported ( credentialsSupported )
181181 . withCredentialOfferStateManager ( stateManager )
182182 . withCNonceStateManager ( nonces )
183183 . withJWTVerifyCallback ( verifyCallbackFunction )
184- . withCredentialDataSupplier (
185- ( ) =>
186- Promise . resolve ( {
187- credential : {
188- '@context' : [ 'https://www.w3.org/2018/credentials/v1' ] ,
189- type : [ 'VerifiableCredential' ] ,
190- issuer : 'did:key:test' ,
191- issuanceDate : new Date ( ) . toISOString ( ) ,
192- credentialSubject : { }
193- } ,
194- format : 'ldp_vc'
195- } )
184+ . withCredentialDataSupplier ( ( ) =>
185+ Promise . resolve ( {
186+ credential : {
187+ '@context' : [ 'https://www.w3.org/2018/credentials/v1' ] ,
188+ type : [ 'VerifiableCredential' ] ,
189+ issuer : 'did:key:test' ,
190+ issuanceDate : new Date ( ) . toISOString ( ) ,
191+ credentialSubject : { } ,
192+ } ,
193+ format : 'ldp_vc' ,
194+ } ) ,
196195 )
197196 . withCredentialSignerCallback ( ( opts ) =>
198197 Promise . resolve ( {
@@ -202,9 +201,9 @@ describe('issuerCallback', () => {
202201 jwt : 'ye.ye.ye' ,
203202 created : new Date ( ) . toISOString ( ) ,
204203 proofPurpose : IProofPurpose . assertionMethod ,
205- verificationMethod : 'sdfsdfasdfasdfasdfasdfassdfasdf'
206- }
207- } )
204+ verificationMethod : 'sdfsdfasdfasdfasdfasdfassdfasdf' ,
205+ } ,
206+ } ) ,
208207 )
209208 . build ( )
210209 } , 30000 )
@@ -219,12 +218,17 @@ describe('issuerCallback', () => {
219218 type : [ 'VerifiableCredential' ] ,
220219 issuer : didKey . didDocument . id ,
221220 credentialSubject : { } ,
222- issuanceDate : new Date ( ) . toISOString ( )
221+ issuanceDate : new Date ( ) . toISOString ( ) ,
223222 }
224- const vc = await getIssuerCallbackV1_0_15 ( credential , { } as CredentialRequest , didKey . keyPairs , didKey . didDocument . verificationMethod [ 0 ] . id ) ( {
223+ const vc = await getIssuerCallbackV1_0_15 (
224+ credential ,
225+ { } as CredentialRequest ,
226+ didKey . keyPairs ,
227+ didKey . didDocument . verificationMethod [ 0 ] . id ,
228+ ) ( {
225229 credentialRequest : { } as CredentialRequest ,
226230 credential : credential ,
227- jwtVerifyResult : { }
231+ jwtVerifyResult : { } ,
228232 } )
229233 expect ( vc ) . toEqual ( {
230234 '@context' : [ 'https://www.w3.org/2018/credentials/v1' , 'https://w3id.org/security/suites/ed25519-2020/v1' ] ,
@@ -236,12 +240,12 @@ describe('issuerCallback', () => {
236240 proofPurpose : 'assertionMethod' ,
237241 proofValue : expect . any ( String ) ,
238242 type : 'Ed25519Signature2020' ,
239- verificationMethod : expect . any ( String )
243+ verificationMethod : expect . any ( String ) ,
240244 } ,
241- type : [ 'VerifiableCredential' ]
245+ type : [ 'VerifiableCredential' ] ,
242246 } )
243247 await expect ( verifyCredential ( vc , didKey . keyPairs , didKey . didDocument . verificationMethod [ 0 ] . id ) ) . resolves . toEqual (
244- expect . objectContaining ( { verified : true } )
248+ expect . objectContaining ( { verified : true } ) ,
245249 )
246250 } )
247251
@@ -256,32 +260,32 @@ describe('issuerCallback', () => {
256260 VeriCred : {
257261 format : 'jwt_vc_json' ,
258262 credential_definition : {
259- type : [ 'VerifiableCredential' ]
260- }
261- }
262- }
263+ type : [ 'VerifiableCredential' ] ,
264+ } ,
265+ } ,
266+ } ,
263267 } as CredentialIssuerMetadataV1_0_15 )
264268 . withToken ( 'token' )
265269
266270 const jwt : Jwt = {
267271 header : { alg : Alg . ES256 , kid : 'did:example:ebfeb1f712ebc6f1c276e12ec21#keys-1' , typ : 'openid4vci-proof+jwt' } ,
268- payload : { iss : 'sphereon:wallet' , nonce : 'test_value' , jti : 'tZignsnFbp223' , aud : IDENTIPROOF_ISSUER_URL }
272+ payload : { iss : 'sphereon:wallet' , nonce : 'test_value' , jti : 'tZignsnFbp223' , aud : IDENTIPROOF_ISSUER_URL } ,
269273 }
270274
271275 const credential : ICredential = {
272276 '@context' : [ 'https://www.w3.org/2018/credentials/v1' ] ,
273277 type : [ 'VerifiableCredential' ] ,
274278 issuer : didKey . didDocument . id ,
275279 credentialSubject : { } ,
276- issuanceDate : new Date ( ) . toISOString ( )
280+ issuanceDate : new Date ( ) . toISOString ( ) ,
277281 }
278282
279283 const proof : ProofOfPossession = await ProofOfPossessionBuilder . fromJwt ( {
280284 jwt,
281285 callbacks : {
282- signCallback : proofOfPossessionCallbackFunction
286+ signCallback : proofOfPossessionCallbackFunction ,
283287 } ,
284- version : OpenId4VCIVersion . VER_1_0_15
288+ version : OpenId4VCIVersion . VER_1_0_15 ,
285289 } )
286290 . withClientId ( clientId )
287291 . withKid ( kid )
@@ -291,54 +295,61 @@ describe('issuerCallback', () => {
291295 const credentialRequest : CredentialRequest = await credentialRequestClient . createCredentialRequest ( {
292296 credentialConfigurationId : 'UniversityDegree_JWT' ,
293297 proofInput : proof ,
294- version : OpenId4VCIVersion . VER_1_0_15
298+ version : OpenId4VCIVersion . VER_1_0_15 ,
295299 } )
296300
297301 expect ( credentialRequest ) . toEqual ( {
298302 proof : {
299303 jwt : expect . stringContaining ( 'eyJhbGciOiJFUzI1NiIsImtpZCI6ImRpZDpleGFtcGxlOmViZmViMWY3MTJlYmM2ZjFj' ) ,
300- proof_type : 'jwt'
304+ proof_type : 'jwt' ,
301305 } ,
302- credential_configuration_id : 'UniversityDegree_JWT'
306+ credential_configuration_id : 'UniversityDegree_JWT' ,
303307 } )
304308
305309 const credentialResponse = await vcIssuer . issueCredential ( {
306310 credentialRequest : credentialRequest ,
307311 issuerCorrelation : {
308312 preAuthorizedCode : 'test_code' ,
309- issuerState : 'existing-state'
313+ issuerState : 'existing-state' ,
310314 } ,
311315 credential,
312316 responseCNonce : state ,
313- credentialSignerCallback : getIssuerCallbackV1_0_15 ( credential , credentialRequest , didKey . keyPairs , didKey . didDocument . verificationMethod [ 0 ] . id )
317+ credentialSignerCallback : getIssuerCallbackV1_0_15 ( credential , credentialRequest , didKey . keyPairs , didKey . didDocument . verificationMethod [ 0 ] . id ) ,
314318 } )
315319
316320 expect ( credentialResponse ) . toEqual ( {
317321 c_nonce : expect . any ( String ) ,
318322 notification_id : expect . any ( String ) ,
319323 c_nonce_expires_in : 300 ,
320- credentials : [ { // v15 array structure
321- credential : {
322- '@context' : [ 'https://www.w3.org/2018/credentials/v1' , 'https://w3id.org/security/suites/ed25519-2020/v1' ] ,
323- credentialSubject : {
324- id : 'did:example:ebfeb1f712ebc6f1c276e12ec21'
325- } ,
326- issuanceDate : expect . any ( String ) ,
327- issuer : didKey . didDocument . id ,
328- proof : {
329- created : expect . any ( String ) ,
330- proofPurpose : 'assertionMethod' ,
331- proofValue : expect . any ( String ) ,
332- type : 'Ed25519Signature2020' ,
333- verificationMethod : expect . stringContaining ( 'did:key:' )
324+ credentials : [
325+ {
326+ // v15 array structure
327+ credential : {
328+ '@context' : [ 'https://www.w3.org/2018/credentials/v1' , 'https://w3id.org/security/suites/ed25519-2020/v1' ] ,
329+ credentialSubject : {
330+ id : 'did:example:ebfeb1f712ebc6f1c276e12ec21' ,
331+ } ,
332+ issuanceDate : expect . any ( String ) ,
333+ issuer : didKey . didDocument . id ,
334+ proof : {
335+ created : expect . any ( String ) ,
336+ proofPurpose : 'assertionMethod' ,
337+ proofValue : expect . any ( String ) ,
338+ type : 'Ed25519Signature2020' ,
339+ verificationMethod : expect . stringContaining ( 'did:key:' ) ,
340+ } ,
341+ type : [ 'VerifiableCredential' ] ,
334342 } ,
335- type : [ 'VerifiableCredential' ]
336- }
337- } ]
343+ } ,
344+ ] ,
338345 } )
339346
340347 await expect (
341- verifyCredential ( credentialResponse . credentials ! [ 0 ] . credential as W3CVerifiableCredential , didKey . keyPairs , didKey . didDocument . verificationMethod [ 0 ] . id )
348+ verifyCredential (
349+ credentialResponse . credentials ! [ 0 ] . credential as W3CVerifiableCredential ,
350+ didKey . keyPairs ,
351+ didKey . didDocument . verificationMethod [ 0 ] . id ,
352+ ) ,
342353 ) . resolves . toEqual ( expect . objectContaining ( { verified : true } ) )
343354 } )
344355} )
0 commit comments