44 CredentialOfferRequestWithBaseUrl ,
55 Jwt ,
66 OpenId4VCIVersion ,
7- ProofOfPossession ,
7+ ProofOfPossession , resolveCredentialOfferURI ,
88 WellKnownEndpoints
99} from '@sphereon/oid4vci-common'
1010// eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -36,11 +36,27 @@ const jwtWithoutDid = {
3636 payload : { iss : 'test-clientId' , nonce : 'tZignsnFbp' , jti : 'tZignsnFbp223' , aud : ISSUER_URL } ,
3737} ;
3838
39+ const mockedVC =
40+ 'eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSIsImh0dHBzOi8vd3d3LnczLm9yZy8yMDE4L2NyZWRlbnRpYWxzL2V4YW1wbGVzL3YxIl0sImlkIjoiaHR0cDovL2V4YW1wbGUuZWR1L2NyZWRlbnRpYWxzLzM3MzIiLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIiwiVW5pdmVyc2l0eURlZ3JlZUNyZWRlbnRpYWwiXSwiaXNzdWVyIjoiaHR0cHM6Ly9leGFtcGxlLmVkdS9pc3N1ZXJzLzU2NTA0OSIsImlzc3VhbmNlRGF0ZSI6IjIwMTAtMDEtMDFUMDA6MDA6MDBaIiwiY3JlZGVudGlhbFN1YmplY3QiOnsiaWQiOiJkaWQ6ZXhhbXBsZTplYmZlYjFmNzEyZWJjNmYxYzI3NmUxMmVjMjEiLCJkZWdyZWUiOnsidHlwZSI6IkJhY2hlbG9yRGVncmVlIiwibmFtZSI6IkJhY2hlbG9yIG9mIFNjaWVuY2UgYW5kIEFydHMifX19LCJpc3MiOiJodHRwczovL2V4YW1wbGUuZWR1L2lzc3VlcnMvNTY1MDQ5IiwibmJmIjoxMjYyMzA0MDAwLCJqdGkiOiJodHRwOi8vZXhhbXBsZS5lZHUvY3JlZGVudGlhbHMvMzczMiIsInN1YiI6ImRpZDpleGFtcGxlOmViZmViMWY3MTJlYmM2ZjFjMjc2ZTEyZWMyMSJ9.z5vgMTK1nfizNCg5N-niCOL3WUIAL7nXy-nGhDZYO_-PNGeE-0djCpWAMH8fD8eWSID5PfkPBYkx_dfLJnQ7NA' ;
41+
42+ // Access token mocks
43+ const mockedAccessTokenResponse : AccessTokenResponse = {
44+ access_token : 'ey6546.546654.64565' ,
45+ authorization_pending : false ,
46+ c_nonce : 'c_nonce2022101300' ,
47+ c_nonce_expires_in : 2025101300 ,
48+ interval : 2025101300 ,
49+ token_type : 'Bearer' ,
50+ } ;
51+
52+ const INITIATE_QR_V1_0_13 =
53+ 'openid-credential-offer://?credential_offer=%7B%22credential_issuer%22:%22https://issuer.research.identiproof.io%22,%22credential_configuration_ids%22:%5B%22OpenBadgeCredentialUrl%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,%22length%22:22,%22description%22:%22Please%20enter%20the%20serial%20number%20of%20your%20physical%20drivers%20license%22%7D%7D%7D%7D' ;
54+
55+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
56+ async function proofOfPossessionCallbackFunction ( _args : Jwt , _kid ?: string ) : Promise < string > {
57+ return 'ey.val.ue' ;
58+ }
3959describe ( 'OID4VCI-Client should' , ( ) => {
40- // eslint-disable-next-line @typescript-eslint/no-unused-vars
41- async function proofOfPossessionCallbackFunction ( _args : Jwt , _kid ?: string ) : Promise < string > {
42- return 'ey.val.ue' ;
43- }
4460 beforeEach ( ( ) => {
4561 nock . cleanAll ( ) ;
4662 } ) ;
@@ -57,8 +73,6 @@ describe('OID4VCI-Client should', () => {
5773 interval : 2025101300 ,
5874 token_type : 'Bearer' ,
5975 } ;
60- const mockedVC =
61- 'eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSIsImh0dHBzOi8vd3d3LnczLm9yZy8yMDE4L2NyZWRlbnRpYWxzL2V4YW1wbGVzL3YxIl0sImlkIjoiaHR0cDovL2V4YW1wbGUuZWR1L2NyZWRlbnRpYWxzLzM3MzIiLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIiwiVW5pdmVyc2l0eURlZ3JlZUNyZWRlbnRpYWwiXSwiaXNzdWVyIjoiaHR0cHM6Ly9leGFtcGxlLmVkdS9pc3N1ZXJzLzU2NTA0OSIsImlzc3VhbmNlRGF0ZSI6IjIwMTAtMDEtMDFUMDA6MDA6MDBaIiwiY3JlZGVudGlhbFN1YmplY3QiOnsiaWQiOiJkaWQ6ZXhhbXBsZTplYmZlYjFmNzEyZWJjNmYxYzI3NmUxMmVjMjEiLCJkZWdyZWUiOnsidHlwZSI6IkJhY2hlbG9yRGVncmVlIiwibmFtZSI6IkJhY2hlbG9yIG9mIFNjaWVuY2UgYW5kIEFydHMifX19LCJpc3MiOiJodHRwczovL2V4YW1wbGUuZWR1L2lzc3VlcnMvNTY1MDQ5IiwibmJmIjoxMjYyMzA0MDAwLCJqdGkiOiJodHRwOi8vZXhhbXBsZS5lZHUvY3JlZGVudGlhbHMvMzczMiIsInN1YiI6ImRpZDpleGFtcGxlOmViZmViMWY3MTJlYmM2ZjFjMjc2ZTEyZWMyMSJ9.z5vgMTK1nfizNCg5N-niCOL3WUIAL7nXy-nGhDZYO_-PNGeE-0djCpWAMH8fD8eWSID5PfkPBYkx_dfLJnQ7NA' ;
6276 const INITIATE_QR_V1_0_08 =
6377 'openid-initiate-issuance://?issuer=https%3A%2F%2Fissuer.research.identiproof.io&credential_type=OpenBadgeCredentialUrl&pre-authorized_code=4jLs9xZHEfqcoow0kHE7d1a8hUk6Sy-5bVSV2MqBUGUgiFFQi-ImL62T-FmLIo8hKA1UdMPH0lM1xAgcFkJfxIw9L-lI3mVs0hRT8YVwsEM1ma6N3wzuCdwtMU4bcwKp&user_pin_required=true' ;
6478 const OFFER_QR_V1_0_08 =
@@ -72,9 +86,6 @@ describe('OID4VCI-Client should', () => {
7286 const HTTPS_OFFER_QR_PRE_AUTHORIZED_v13 =
7387 'https://issuer.research.identiproof.io?credential_offer=%7B%0A%20%20%20%20%22credential_issuer%22%3A%20%22https%3A%2F%2Fissuer.research.identiproof.io%22%2C%0A%20%20%20%20%22credential_configuration_ids%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%22UniversityDegreeCredential%22%0A%20%20%20%20%5D%2C%0A%20%20%20%20%22grants%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Apre-authorized_code%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22pre-authorized_code%22%3A%20%22adhjhdjajkdkhjhdj%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22tx_code%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22length%22%3A%204%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22input_mode%22%3A%20%22numeric%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22description%22%3A%20%22Please%20provide%20the%20one-time%20code%20that%20was%20sent%20via%20e-mail%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%7D' ;
7488
75- const INITIATE_QR_V1_0_13 =
76- 'openid-credential-offer://?credential_offer=%7B%22credential_issuer%22:%22https://issuer.research.identiproof.io%22,%22credential_configuration_ids%22:%5B%22OpenBadgeCredentialUrl%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,%22length%22:22,%22description%22:%22Please%20enter%20the%20serial%20number%20of%20your%20physical%20drivers%20license%22%7D%7D%7D%7D' ;
77-
7889 function succeedWithAFullFlowWithClientSetup ( ) {
7990 nock ( IDENTIPROOF_ISSUER_URL ) . get ( '/.well-known/openid-credential-issuer' ) . reply ( 200 , JSON . stringify ( IDENTIPROOF_OID4VCI_METADATA ) ) ;
8091 nock ( IDENTIPROOF_AS_URL ) . get ( '/.well-known/oauth-authorization-server' ) . reply ( 200 , JSON . stringify ( IDENTIPROOF_AS_METADATA ) ) ;
@@ -350,6 +361,58 @@ describe('OID4VCI-Client should', () => {
350361 } ,
351362 UNIT_TEST_TIMEOUT ,
352363 ) ;
364+ } ) ;
365+
366+ describe ( 'OIDVCI-Client for v1_0_13 should' , ( ) => {
367+ const mockedCredentialOffer = {
368+ credential_issuer : 'https://mijnkvk.acc.credenco.com' ,
369+ credential_configuration_ids : [ 'BevoegdheidUittreksel_jwt_vc_json' ] ,
370+ grants : {
371+ authorization_code : {
372+ issuer_state : '32fc4ebf-9e31-4149-9877-e3c0b602d559' ,
373+ } ,
374+ 'urn:ietf:params:oauth:grant-type:pre-authorized_code' : {
375+ 'pre-authorized_code' :
376+ 'eyJhbGciOiJFZERTQSJ9.eyJzdWIiOiIzMmZjNGViZi05ZTMxLTQxNDktOTg3Ny1lM2MwYjYwMmQ1NTkiLCJpc3MiOiJodHRwczovL21pam5rdmsuYWNjLmNyZWRlbmNvLmNvbSIsImF1ZCI6IlRPS0VOIn0.754aiQ87O0vHYSpRvPqAS9cLOgf-pewdeXbpLziRwsxEp9mENfaXpY62muYpzOaWcYmTOydkzhFul-NDYXJZCA' ,
377+ } ,
378+ } ,
379+ } ;
380+
381+ beforeEach ( ( ) => {
382+ // Mock the HTTP GET request to the credential offer URI
383+ nock ( 'https://mijnkvk.acc.credenco.com' )
384+ . get ( '/openid4vc/credentialOffer?id=32fc4ebf-9e31-4149-9877-e3c0b602d559' )
385+ . reply ( 200 , mockedCredentialOffer )
386+ . persist ( ) ; // Use .persist() if you want the mock to remain active for multiple tests
387+ } ) ;
388+
389+ afterEach ( ( ) => {
390+ // Clean up all mocks
391+ nock . cleanAll ( ) ;
392+ } ) ;
393+
394+ /*function succeedWithAFullFlowWithClientSetup() {
395+ nock(IDENTIPROOF_ISSUER_URL).get('/.well-known/openid-credential-issuer').reply(200, JSON.stringify(IDENTIPROOF_OID4VCI_METADATA));
396+ nock(IDENTIPROOF_AS_URL).get('/.well-known/oauth-authorization-server').reply(200, JSON.stringify(IDENTIPROOF_AS_METADATA));
397+ nock(IDENTIPROOF_AS_URL).get(WellKnownEndpoints.OPENID_CONFIGURATION).reply(404, {});
398+ nock(IDENTIPROOF_AS_URL)
399+ .post(/oauth2\/token.*!/)
400+ .reply(200, JSON.stringify(mockedAccessTokenResponse));
401+ nock(ISSUER_URL)
402+ .post(/credential/)
403+ .reply(200, {
404+ format: 'jwt-vc',
405+ credential: mockedVC,
406+ });
407+ }*/
408+
409+ it ( 'should successfully resolve the credential offer URI' , async ( ) => {
410+ const uri = 'https://mijnkvk.acc.credenco.com/openid4vc/credentialOffer?id=32fc4ebf-9e31-4149-9877-e3c0b602d559' ;
411+
412+ const credentialOffer = await resolveCredentialOfferURI ( uri ) ;
413+
414+ expect ( credentialOffer ) . toEqual ( mockedCredentialOffer ) ;
415+ } ) ;
353416
354417 it (
355418 'succeed with a full flow without the client and without did' ,
0 commit comments