@sphereon/oid4vci-client 0.12.1-unstable.6 → 0.12.1-unstable.7

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.
@@ -4,7 +4,7 @@ import {
4
4
  CredentialOfferRequestWithBaseUrl,
5
5
  Jwt,
6
6
  OpenId4VCIVersion,
7
- ProofOfPossession,
7
+ ProofOfPossession, resolveCredentialOfferURI,
8
8
  WellKnownEndpoints
9
9
  } from '@sphereon/oid4vci-common'
10
10
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -36,11 +36,27 @@ const jwtWithoutDid = {
36
36
  payload: { iss: 'test-clientId', nonce: 'tZignsnFbp', jti: 'tZignsnFbp223', aud: ISSUER_URL },
37
37
  };
38
38
 
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
+ }
39
59
  describe('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
- }
44
60
  beforeEach(() => {
45
61
  nock.cleanAll();
46
62
  });
@@ -57,8 +73,6 @@ describe('OID4VCI-Client should', () => {
57
73
  interval: 2025101300,
58
74
  token_type: 'Bearer',
59
75
  };
60
- const mockedVC =
61
- 'eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSIsImh0dHBzOi8vd3d3LnczLm9yZy8yMDE4L2NyZWRlbnRpYWxzL2V4YW1wbGVzL3YxIl0sImlkIjoiaHR0cDovL2V4YW1wbGUuZWR1L2NyZWRlbnRpYWxzLzM3MzIiLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIiwiVW5pdmVyc2l0eURlZ3JlZUNyZWRlbnRpYWwiXSwiaXNzdWVyIjoiaHR0cHM6Ly9leGFtcGxlLmVkdS9pc3N1ZXJzLzU2NTA0OSIsImlzc3VhbmNlRGF0ZSI6IjIwMTAtMDEtMDFUMDA6MDA6MDBaIiwiY3JlZGVudGlhbFN1YmplY3QiOnsiaWQiOiJkaWQ6ZXhhbXBsZTplYmZlYjFmNzEyZWJjNmYxYzI3NmUxMmVjMjEiLCJkZWdyZWUiOnsidHlwZSI6IkJhY2hlbG9yRGVncmVlIiwibmFtZSI6IkJhY2hlbG9yIG9mIFNjaWVuY2UgYW5kIEFydHMifX19LCJpc3MiOiJodHRwczovL2V4YW1wbGUuZWR1L2lzc3VlcnMvNTY1MDQ5IiwibmJmIjoxMjYyMzA0MDAwLCJqdGkiOiJodHRwOi8vZXhhbXBsZS5lZHUvY3JlZGVudGlhbHMvMzczMiIsInN1YiI6ImRpZDpleGFtcGxlOmViZmViMWY3MTJlYmM2ZjFjMjc2ZTEyZWMyMSJ9.z5vgMTK1nfizNCg5N-niCOL3WUIAL7nXy-nGhDZYO_-PNGeE-0djCpWAMH8fD8eWSID5PfkPBYkx_dfLJnQ7NA';
62
76
  const INITIATE_QR_V1_0_08 =
63
77
  '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';
64
78
  const OFFER_QR_V1_0_08 =
@@ -72,9 +86,6 @@ describe('OID4VCI-Client should', () => {
72
86
  const HTTPS_OFFER_QR_PRE_AUTHORIZED_v13 =
73
87
  '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';
74
88
 
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
-
78
89
  function succeedWithAFullFlowWithClientSetup() {
79
90
  nock(IDENTIPROOF_ISSUER_URL).get('/.well-known/openid-credential-issuer').reply(200, JSON.stringify(IDENTIPROOF_OID4VCI_METADATA));
80
91
  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', () => {
350
361
  },
351
362
  UNIT_TEST_TIMEOUT,
352
363
  );
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
+ });
353
416
 
354
417
  it(
355
418
  'succeed with a full flow without the client and without did',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sphereon/oid4vci-client",
3
- "version": "0.12.1-unstable.6+19b0704",
3
+ "version": "0.12.1-unstable.7+f655bf0",
4
4
  "description": "OpenID for Verifiable Credential Issuance (OpenID4VCI) client",
5
5
  "source": "lib/index.ts",
6
6
  "main": "dist/index.js",
@@ -15,7 +15,7 @@
15
15
  "build": "tsc"
16
16
  },
17
17
  "dependencies": {
18
- "@sphereon/oid4vci-common": "0.12.1-unstable.6+19b0704",
18
+ "@sphereon/oid4vci-common": "0.12.1-unstable.7+f655bf0",
19
19
  "@sphereon/ssi-types": "0.25.1-unstable.87",
20
20
  "cross-fetch": "^3.1.8",
21
21
  "debug": "^4.3.4"
@@ -69,5 +69,5 @@
69
69
  "OIDC4VCI",
70
70
  "OID4VCI"
71
71
  ],
72
- "gitHead": "19b07046aaf213c3feb4f4b8c61f4eb97f8504cc"
72
+ "gitHead": "f655bf063128e94e0f6e4b54a2437ea975bc0d34"
73
73
  }