@@ -4,7 +4,9 @@ import { CredentialRequestClient, CredentialRequestClientBuilder, ProofOfPossess
44import {
55 Alg ,
66 CNonceState ,
7- CredentialSupported ,
7+ CredentialConfigurationSupportedV1_0_13 ,
8+ CredentialIssuerMetadataV1_0_13 ,
9+ CredentialRequest ,
810 IssuerCredentialSubjectDisplay ,
911 IssueStatus ,
1012 Jwt ,
@@ -13,17 +15,18 @@ import {
1315 ProofOfPossession ,
1416} from '@sphereon/oid4vci-common'
1517import { CredentialOfferSession } from '@sphereon/oid4vci-common/dist'
16- import { CredentialSupportedBuilderV1_11 , VcIssuer , VcIssuerBuilder } from '@sphereon/oid4vci-issuer'
18+ import { CredentialSupportedBuilderV1_13 , VcIssuer , VcIssuerBuilder } from '@sphereon/oid4vci-issuer'
1719import { MemoryStates } from '@sphereon/oid4vci-issuer'
1820import { CredentialDataSupplierResult } from '@sphereon/oid4vci-issuer/dist/types'
1921import { ICredential , IProofPurpose , IProofType , W3CVerifiableCredential } from '@sphereon/ssi-types'
2022import { DIDDocument } from 'did-resolver'
2123import * as jose from 'jose'
24+ import { v4 } from 'uuid'
2225
23- import { generateDid , getIssuerCallback , verifyCredential } from '../IssuerCallback'
26+ import { generateDid , getIssuerCallbackV1_0_11 , getIssuerCallbackV1_0_13 , verifyCredential } from '../IssuerCallback'
2427
2528const INITIATION_TEST_URI =
26- 'openid-initiate-issuance ://?credential_type=OpenBadgeCredential& issuer=https%3A%2F%2Fjff%2Ewalt%2Eid%2Fissuer-api%2Foidc%2F& pre-authorized_code=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhOTUyZjUxNi1jYWVmLTQ4YjMtODIxYy00OTRkYzgyNjljZjAiLCJwcmUtYXV0aG9yaXplZCI6dHJ1ZX0.YE5DlalcLC2ChGEg47CQDaN1gTxbaQqSclIVqsSAUHE&user_pin_required=false '
29+ 'openid-credential-offer ://?credential_offer=%7B%22credential_issuer%22:%22https://credential- issuer.example.com%22,%22credential_configuration_ids%22:%5B%22UniversityDegreeCredential%22%5D,%22grants%22:%7B%22urn:ietf:params:oauth:grant-type: pre-authorized_code%22:%7B%22pre-authorized_code%22:%22oaKazRN8I0IbtZ0C7JuMn5%22,%22tx_code%22:%7B%22input_mode%22:%22text%22,%22description%22:%22Please%20enter%20the%20serial%20number%20of%20your%20physical%20drivers%20license%22%7D%7D%7D%7D '
2730const IDENTIPROOF_ISSUER_URL = 'https://example.com/credential'
2831const kid = 'did:example:ebfeb1f712ebc6f1c276e12ec21#keys-1'
2932let keypair : KeyPair // Proof of Possession JWT
@@ -37,7 +40,7 @@ async function proofOfPossessionCallbackFunction(args: Jwt, kid?: string): Promi
3740 }
3841 return await new jose . SignJWT ( { ...args . payload } )
3942 . setProtectedHeader ( { ...args . header } )
40- . setIssuedAt ( args . payload . iat ?? Math . round ( + new Date ( ) / 1000 ) )
43+ . setIssuedAt ( args . payload . iat ?? Math . round ( + new Date ( ) / 1000 ) )
4144 . setIssuer ( kid )
4245 . setAudience ( args . payload . aud )
4346 . setExpirationTime ( '2h' )
@@ -85,12 +88,14 @@ describe('issuerCallback', () => {
8588 const clientId = 'sphereon:wallet'
8689
8790 beforeAll ( async ( ) => {
88- const credentialsSupported : CredentialSupported = new CredentialSupportedBuilderV1_11 ( )
89- . withCryptographicSuitesSupported ( 'ES256K' )
91+ const credentialsSupported : Record < string , CredentialConfigurationSupportedV1_0_13 > = new CredentialSupportedBuilderV1_13 ( )
92+ . withCredentialSigningAlgValuesSupported ( 'ES256K' )
9093 . withCryptographicBindingMethod ( 'did' )
9194 . withFormat ( 'jwt_vc_json' )
92- . withTypes ( 'VerifiableCredential' )
93- . withId ( 'UniversityDegree_JWT' )
95+ . withCredentialName ( 'UniversityDegree_JWT' )
96+ . withCredentialDefinition ( {
97+ type : [ 'VerifiableCredential' , 'UniversityDegree_JWT' ] ,
98+ } )
9499 . withCredentialSupportedDisplay ( {
95100 name : 'University Credential' ,
96101 locale : 'en-US' ,
@@ -113,6 +118,7 @@ describe('issuerCallback', () => {
113118 createdAt : + new Date ( ) ,
114119 lastUpdatedAt : + new Date ( ) ,
115120 status : IssueStatus . OFFER_CREATED ,
121+ notification_id : v4 ( ) ,
116122 userPin : '123456' ,
117123 credentialOffer : {
118124 credential_offer : {
@@ -141,14 +147,14 @@ describe('issuerCallback', () => {
141147 const nonces = new MemoryStates < CNonceState > ( )
142148 await nonces . set ( 'test_value' , { cNonce : 'test_value' , createdAt : + new Date ( ) , issuerState : 'existing-state' } )
143149 vcIssuer = new VcIssuerBuilder < DIDDocument > ( )
144- . withAuthorizationServer ( 'https://authorization-server' )
150+ . withAuthorizationServers ( 'https://authorization-server' )
145151 . withCredentialEndpoint ( 'https://credential-endpoint' )
146152 . withCredentialIssuer ( IDENTIPROOF_ISSUER_URL )
147153 . withIssuerDisplay ( {
148154 name : 'example issuer' ,
149155 locale : 'en-US' ,
150156 } )
151- . withCredentialsSupported ( credentialsSupported )
157+ . withCredentialConfigurationsSupported ( credentialsSupported )
152158 . withCredentialOfferStateManager ( stateManager )
153159 . withCNonceStateManager ( nonces )
154160 . withJWTVerifyCallback ( verifyCallbackFunction )
@@ -192,7 +198,7 @@ describe('issuerCallback', () => {
192198 credentialSubject : { } ,
193199 issuanceDate : new Date ( ) . toISOString ( ) ,
194200 }
195- const vc = await getIssuerCallback ( credential , didKey . keyPairs , didKey . didDocument . verificationMethod [ 0 ] . id ) ( { } )
201+ const vc = await getIssuerCallbackV1_0_11 ( credential , didKey . keyPairs , didKey . didDocument . verificationMethod [ 0 ] . id ) ( { } )
196202 expect ( vc ) . toEqual ( {
197203 '@context' : [ 'https://www.w3.org/2018/credentials/v1' , 'https://w3id.org/security/suites/ed25519-2020/v1' ] ,
198204 credentialSubject : { } ,
@@ -211,11 +217,15 @@ describe('issuerCallback', () => {
211217 expect . objectContaining ( { verified : true } ) ,
212218 )
213219 } )
220+
214221 it ( 'Should pass requesting a verifiable credential using the client' , async ( ) => {
215222 const credReqClient = ( await CredentialRequestClientBuilder . fromURI ( { uri : INITIATION_TEST_URI } ) )
216223 . withCredentialEndpoint ( 'https://oidc4vci.demo.spruceid.com/credential' )
224+ . withCredentialEndpointFromMetadata ( {
225+ credential_configurations_supported : { VeriCred : { format : 'jwt_vc_json' } } ,
226+ } as unknown as CredentialIssuerMetadataV1_0_13 )
217227 . withFormat ( 'jwt_vc_json' )
218- . withCredentialType ( 'credentialType ')
228+ . withCredentialIdentifier ( 'VeriCred ')
219229 . withToken ( 'token' )
220230
221231 const jwt : Jwt = {
@@ -236,37 +246,39 @@ describe('issuerCallback', () => {
236246 callbacks : {
237247 signCallback : proofOfPossessionCallbackFunction ,
238248 } ,
239- version : OpenId4VCIVersion . VER_1_0_11 ,
249+ version : OpenId4VCIVersion . VER_1_0_13 ,
240250 } )
241251 . withClientId ( clientId )
242252 . withKid ( kid )
243253 . build ( )
244254
245255 const credentialRequestClient = new CredentialRequestClient ( credReqClient )
246- const credentialRequest = await credentialRequestClient . createCredentialRequest ( {
247- credentialTypes : [ 'VerifiableCredential' ] ,
248- format : 'jwt_vc_json' ,
256+ const credentialRequest : CredentialRequest = await credentialRequestClient . createCredentialRequest ( {
257+ credentialIdentifier : 'VerifiableCredential' ,
258+ // format: 'jwt_vc_json',
249259 proofInput : proof ,
250- version : OpenId4VCIVersion . VER_1_0_11 ,
260+ version : OpenId4VCIVersion . VER_1_0_13 ,
251261 } )
262+
252263 expect ( credentialRequest ) . toEqual ( {
253- format : 'jwt_vc_json' ,
264+ // format: 'jwt_vc_json',
254265 proof : {
255266 jwt : expect . stringContaining ( 'eyJhbGciOiJFUzI1NiIsImtpZCI6ImRpZDpleGFtcGxlOmViZmViMWY3MTJlYmM2ZjFj' ) ,
256267 proof_type : 'jwt' ,
257268 } ,
258- types : [ 'VerifiableCredential' ] ,
269+ credential_identifier : 'VerifiableCredential' ,
259270 } )
260271
261272 const credentialResponse = await vcIssuer . issueCredential ( {
262273 credentialRequest : credentialRequest ,
263274 credential,
264275 responseCNonce : state ,
265- credentialSignerCallback : getIssuerCallback ( credential , didKey . keyPairs , didKey . didDocument . verificationMethod [ 0 ] . id ) ,
276+ credentialSignerCallback : getIssuerCallbackV1_0_13 ( credential , credentialRequest , didKey . keyPairs , didKey . didDocument . verificationMethod [ 0 ] . id ) ,
266277 } )
267278
268279 expect ( credentialResponse ) . toEqual ( {
269280 c_nonce : expect . any ( String ) ,
281+ notification_id : expect . any ( String ) ,
270282 c_nonce_expires_in : 300 ,
271283 credential : {
272284 '@context' : [ 'https://www.w3.org/2018/credentials/v1' , 'https://w3id.org/security/suites/ed25519-2020/v1' ] ,
@@ -284,7 +296,7 @@ describe('issuerCallback', () => {
284296 } ,
285297 type : [ 'VerifiableCredential' ] ,
286298 } ,
287- format : 'jwt_vc_json' ,
299+ // format: 'jwt_vc_json',
288300 } )
289301
290302 await expect (
0 commit comments