@@ -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,18 +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'
2224import { v4 } from 'uuid'
2325
24- import { generateDid , getIssuerCallback , verifyCredential } from '../IssuerCallback'
26+ import { generateDid , getIssuerCallbackV1_0_11 , getIssuerCallbackV1_0_13 , verifyCredential } from '../IssuerCallback'
2527
2628const INITIATION_TEST_URI =
27- '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 '
2830const IDENTIPROOF_ISSUER_URL = 'https://example.com/credential'
2931const kid = 'did:example:ebfeb1f712ebc6f1c276e12ec21#keys-1'
3032let keypair : KeyPair // Proof of Possession JWT
@@ -86,12 +88,14 @@ describe('issuerCallback', () => {
8688 const clientId = 'sphereon:wallet'
8789
8890 beforeAll ( async ( ) => {
89- const credentialsSupported : CredentialSupported = new CredentialSupportedBuilderV1_11 ( )
90- . withCryptographicSuitesSupported ( 'ES256K' )
91+ const credentialsSupported : Record < string , CredentialConfigurationSupportedV1_0_13 > = new CredentialSupportedBuilderV1_13 ( )
92+ . withCredentialSigningAlgValuesSupported ( 'ES256K' )
9193 . withCryptographicBindingMethod ( 'did' )
9294 . withFormat ( 'jwt_vc_json' )
93- . withTypes ( 'VerifiableCredential' )
94- . withId ( 'UniversityDegree_JWT' )
95+ . withCredentialName ( 'UniversityDegree_JWT' )
96+ . withCredentialDefinition ( {
97+ type : [ 'VerifiableCredential' , 'UniversityDegree_JWT' ] ,
98+ } )
9599 . withCredentialSupportedDisplay ( {
96100 name : 'University Credential' ,
97101 locale : 'en-US' ,
@@ -143,14 +147,14 @@ describe('issuerCallback', () => {
143147 const nonces = new MemoryStates < CNonceState > ( )
144148 await nonces . set ( 'test_value' , { cNonce : 'test_value' , createdAt : + new Date ( ) , issuerState : 'existing-state' } )
145149 vcIssuer = new VcIssuerBuilder < DIDDocument > ( )
146- . withAuthorizationServer ( 'https://authorization-server' )
150+ . withAuthorizationServers ( 'https://authorization-server' )
147151 . withCredentialEndpoint ( 'https://credential-endpoint' )
148152 . withCredentialIssuer ( IDENTIPROOF_ISSUER_URL )
149153 . withIssuerDisplay ( {
150154 name : 'example issuer' ,
151155 locale : 'en-US' ,
152156 } )
153- . withCredentialsSupported ( credentialsSupported )
157+ . withCredentialConfigurationsSupported ( credentialsSupported )
154158 . withCredentialOfferStateManager ( stateManager )
155159 . withCNonceStateManager ( nonces )
156160 . withJWTVerifyCallback ( verifyCallbackFunction )
@@ -194,7 +198,7 @@ describe('issuerCallback', () => {
194198 credentialSubject : { } ,
195199 issuanceDate : new Date ( ) . toISOString ( ) ,
196200 }
197- 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 ) ( { } )
198202 expect ( vc ) . toEqual ( {
199203 '@context' : [ 'https://www.w3.org/2018/credentials/v1' , 'https://w3id.org/security/suites/ed25519-2020/v1' ] ,
200204 credentialSubject : { } ,
@@ -213,11 +217,15 @@ describe('issuerCallback', () => {
213217 expect . objectContaining ( { verified : true } ) ,
214218 )
215219 } )
220+
216221 it ( 'Should pass requesting a verifiable credential using the client' , async ( ) => {
217222 const credReqClient = ( await CredentialRequestClientBuilder . fromURI ( { uri : INITIATION_TEST_URI } ) )
218223 . 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 )
219227 . withFormat ( 'jwt_vc_json' )
220- . withCredentialType ( 'credentialType ')
228+ . withCredentialIdentifier ( 'VeriCred ')
221229 . withToken ( 'token' )
222230
223231 const jwt : Jwt = {
@@ -238,33 +246,34 @@ describe('issuerCallback', () => {
238246 callbacks : {
239247 signCallback : proofOfPossessionCallbackFunction ,
240248 } ,
241- version : OpenId4VCIVersion . VER_1_0_11 ,
249+ version : OpenId4VCIVersion . VER_1_0_13 ,
242250 } )
243251 . withClientId ( clientId )
244252 . withKid ( kid )
245253 . build ( )
246254
247255 const credentialRequestClient = new CredentialRequestClient ( credReqClient )
248- const credentialRequest = await credentialRequestClient . createCredentialRequest ( {
249- credentialTypes : [ 'VerifiableCredential' ] ,
250- format : 'jwt_vc_json' ,
256+ const credentialRequest : CredentialRequest = await credentialRequestClient . createCredentialRequest ( {
257+ credentialIdentifier : 'VerifiableCredential' ,
258+ // format: 'jwt_vc_json',
251259 proofInput : proof ,
252- version : OpenId4VCIVersion . VER_1_0_11 ,
260+ version : OpenId4VCIVersion . VER_1_0_13 ,
253261 } )
262+
254263 expect ( credentialRequest ) . toEqual ( {
255- format : 'jwt_vc_json' ,
264+ // format: 'jwt_vc_json',
256265 proof : {
257266 jwt : expect . stringContaining ( 'eyJhbGciOiJFUzI1NiIsImtpZCI6ImRpZDpleGFtcGxlOmViZmViMWY3MTJlYmM2ZjFj' ) ,
258267 proof_type : 'jwt' ,
259268 } ,
260- types : [ 'VerifiableCredential' ] ,
269+ credential_identifier : 'VerifiableCredential' ,
261270 } )
262271
263272 const credentialResponse = await vcIssuer . issueCredential ( {
264273 credentialRequest : credentialRequest ,
265274 credential,
266275 responseCNonce : state ,
267- credentialSignerCallback : getIssuerCallback ( credential , didKey . keyPairs , didKey . didDocument . verificationMethod [ 0 ] . id ) ,
276+ credentialSignerCallback : getIssuerCallbackV1_0_13 ( credential , credentialRequest , didKey . keyPairs , didKey . didDocument . verificationMethod [ 0 ] . id ) ,
268277 } )
269278
270279 expect ( credentialResponse ) . toEqual ( {
@@ -287,7 +296,7 @@ describe('issuerCallback', () => {
287296 } ,
288297 type : [ 'VerifiableCredential' ] ,
289298 } ,
290- format : 'jwt_vc_json' ,
299+ // format: 'jwt_vc_json',
291300 } )
292301
293302 await expect (
0 commit comments