@sphereon/oid4vci-client 0.10.3 → 0.10.4-next.119

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.
Files changed (142) hide show
  1. package/README.md +24 -5
  2. package/dist/AccessTokenClient.d.ts +5 -5
  3. package/dist/AccessTokenClient.d.ts.map +1 -1
  4. package/dist/AccessTokenClient.js +51 -37
  5. package/dist/AccessTokenClient.js.map +1 -1
  6. package/dist/AccessTokenClientV1_0_11.d.ts +29 -0
  7. package/dist/AccessTokenClientV1_0_11.d.ts.map +1 -0
  8. package/dist/AccessTokenClientV1_0_11.js +209 -0
  9. package/dist/AccessTokenClientV1_0_11.js.map +1 -0
  10. package/dist/AuthorizationCodeClient.d.ts +9 -4
  11. package/dist/AuthorizationCodeClient.d.ts.map +1 -1
  12. package/dist/AuthorizationCodeClient.js +102 -18
  13. package/dist/AuthorizationCodeClient.js.map +1 -1
  14. package/dist/AuthorizationCodeClientV1_0_11.d.ts +9 -0
  15. package/dist/AuthorizationCodeClientV1_0_11.d.ts.map +1 -0
  16. package/dist/AuthorizationCodeClientV1_0_11.js +134 -0
  17. package/dist/AuthorizationCodeClientV1_0_11.js.map +1 -0
  18. package/dist/CredentialOfferClient.d.ts.map +1 -1
  19. package/dist/CredentialOfferClient.js +18 -13
  20. package/dist/CredentialOfferClient.js.map +1 -1
  21. package/dist/CredentialOfferClientV1_0_11.d.ts +10 -0
  22. package/dist/CredentialOfferClientV1_0_11.d.ts.map +1 -0
  23. package/dist/CredentialOfferClientV1_0_11.js +101 -0
  24. package/dist/CredentialOfferClientV1_0_11.js.map +1 -0
  25. package/dist/CredentialOfferClientV1_0_13.d.ts +10 -0
  26. package/dist/CredentialOfferClientV1_0_13.d.ts.map +1 -0
  27. package/dist/CredentialOfferClientV1_0_13.js +94 -0
  28. package/dist/CredentialOfferClientV1_0_13.js.map +1 -0
  29. package/dist/CredentialRequestClient.d.ts +20 -7
  30. package/dist/CredentialRequestClient.d.ts.map +1 -1
  31. package/dist/CredentialRequestClient.js +46 -30
  32. package/dist/CredentialRequestClient.js.map +1 -1
  33. package/dist/CredentialRequestClientBuilder.d.ts +11 -6
  34. package/dist/CredentialRequestClientBuilder.d.ts.map +1 -1
  35. package/dist/CredentialRequestClientBuilder.js +22 -9
  36. package/dist/CredentialRequestClientBuilder.js.map +1 -1
  37. package/dist/CredentialRequestClientBuilderV1_0_11.d.ts +48 -0
  38. package/dist/CredentialRequestClientBuilderV1_0_11.d.ts.map +1 -0
  39. package/dist/CredentialRequestClientBuilderV1_0_11.js +121 -0
  40. package/dist/CredentialRequestClientBuilderV1_0_11.js.map +1 -0
  41. package/dist/CredentialRequestClientV1_0_11.d.ts +50 -0
  42. package/dist/CredentialRequestClientV1_0_11.d.ts.map +1 -0
  43. package/dist/CredentialRequestClientV1_0_11.js +151 -0
  44. package/dist/CredentialRequestClientV1_0_11.js.map +1 -0
  45. package/dist/MetadataClient.d.ts +5 -15
  46. package/dist/MetadataClient.d.ts.map +1 -1
  47. package/dist/MetadataClient.js +41 -44
  48. package/dist/MetadataClient.js.map +1 -1
  49. package/dist/MetadataClientV1_0_11.d.ts +31 -0
  50. package/dist/MetadataClientV1_0_11.d.ts.map +1 -0
  51. package/dist/MetadataClientV1_0_11.js +182 -0
  52. package/dist/MetadataClientV1_0_11.js.map +1 -0
  53. package/dist/MetadataClientV1_0_13.d.ts +31 -0
  54. package/dist/MetadataClientV1_0_13.d.ts.map +1 -0
  55. package/dist/MetadataClientV1_0_13.js +181 -0
  56. package/dist/MetadataClientV1_0_13.js.map +1 -0
  57. package/dist/OpenID4VCIClient.d.ts +14 -19
  58. package/dist/OpenID4VCIClient.d.ts.map +1 -1
  59. package/dist/OpenID4VCIClient.js +111 -61
  60. package/dist/OpenID4VCIClient.js.map +1 -1
  61. package/dist/OpenID4VCIClientV1_0_11.d.ts +108 -0
  62. package/dist/OpenID4VCIClientV1_0_11.d.ts.map +1 -0
  63. package/dist/OpenID4VCIClientV1_0_11.js +449 -0
  64. package/dist/OpenID4VCIClientV1_0_11.js.map +1 -0
  65. package/dist/OpenID4VCIClientV1_0_13.d.ts +112 -0
  66. package/dist/OpenID4VCIClientV1_0_13.d.ts.map +1 -0
  67. package/dist/OpenID4VCIClientV1_0_13.js +478 -0
  68. package/dist/OpenID4VCIClientV1_0_13.js.map +1 -0
  69. package/dist/ProofOfPossessionBuilder.d.ts +14 -3
  70. package/dist/ProofOfPossessionBuilder.d.ts.map +1 -1
  71. package/dist/ProofOfPossessionBuilder.js +20 -21
  72. package/dist/ProofOfPossessionBuilder.js.map +1 -1
  73. package/dist/functions/OpenIDUtils.d.ts +12 -0
  74. package/dist/functions/OpenIDUtils.d.ts.map +1 -0
  75. package/dist/functions/OpenIDUtils.js +37 -0
  76. package/dist/functions/OpenIDUtils.js.map +1 -0
  77. package/dist/functions/index.d.ts +2 -3
  78. package/dist/functions/index.d.ts.map +1 -1
  79. package/dist/functions/index.js +2 -3
  80. package/dist/functions/index.js.map +1 -1
  81. package/dist/functions/notifications.d.ts +4 -0
  82. package/dist/functions/notifications.d.ts.map +1 -0
  83. package/dist/functions/notifications.js +39 -0
  84. package/dist/functions/notifications.js.map +1 -0
  85. package/dist/index.d.ts +13 -1
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.js +14 -1
  88. package/dist/index.js.map +1 -1
  89. package/dist/types/index.d.ts +2 -0
  90. package/dist/types/index.d.ts.map +1 -1
  91. package/dist/types/index.js +5 -0
  92. package/dist/types/index.js.map +1 -1
  93. package/lib/AccessTokenClient.ts +59 -34
  94. package/lib/AccessTokenClientV1_0_11.ts +250 -0
  95. package/lib/AuthorizationCodeClient.ts +131 -28
  96. package/lib/AuthorizationCodeClientV1_0_11.ts +170 -0
  97. package/lib/CredentialOfferClient.ts +21 -8
  98. package/lib/CredentialOfferClientV1_0_11.ts +112 -0
  99. package/lib/CredentialOfferClientV1_0_13.ts +103 -0
  100. package/lib/CredentialRequestClient.ts +65 -26
  101. package/lib/CredentialRequestClientBuilder.ts +34 -16
  102. package/lib/CredentialRequestClientBuilderV1_0_11.ts +163 -0
  103. package/lib/CredentialRequestClientV1_0_11.ts +197 -0
  104. package/lib/MetadataClient.ts +64 -49
  105. package/lib/MetadataClientV1_0_11.ts +189 -0
  106. package/lib/MetadataClientV1_0_13.ts +188 -0
  107. package/lib/OpenID4VCIClient.ts +132 -68
  108. package/lib/OpenID4VCIClientV1_0_11.ts +635 -0
  109. package/lib/OpenID4VCIClientV1_0_13.ts +677 -0
  110. package/lib/ProofOfPossessionBuilder.ts +41 -11
  111. package/lib/__tests__/AccessTokenClient.spec.ts +40 -12
  112. package/lib/__tests__/AuthorizationDetailsBuilder.spec.ts +0 -12
  113. package/lib/__tests__/CredentialRequestClient.spec.ts +87 -50
  114. package/lib/__tests__/CredentialRequestClientBuilder.spec.ts +18 -12
  115. package/lib/__tests__/CredentialRequestClientV1_0_11.spec.ts +317 -0
  116. package/lib/__tests__/EBSIE2E.spec.test.ts +2 -2
  117. package/lib/__tests__/HttpUtils.spec.ts +1 -1
  118. package/lib/__tests__/IT.spec.ts +264 -14
  119. package/lib/__tests__/IssuanceInitiation.spec.ts +59 -4
  120. package/lib/__tests__/IssuanceInitiationV1_0_11.spec.ts +62 -0
  121. package/lib/__tests__/MattrE2E.spec.test.ts +2 -2
  122. package/lib/__tests__/MetadataClient.spec.ts +53 -3
  123. package/lib/__tests__/MetadataMocks.ts +42 -2
  124. package/lib/__tests__/OpenID4VCIClient.spec.ts +58 -2
  125. package/lib/__tests__/{OpenID4VCIClientPAR.spec.ts → OpenID4VCIClientPARV1_0_11.spec.ts} +5 -5
  126. package/lib/__tests__/OpenID4VCIClientV1_0_11.spec.ts +226 -0
  127. package/lib/__tests__/OpenID4VCIClientV1_0_13.spec.ts +204 -0
  128. package/lib/__tests__/ProofOfPossessionBuilder.spec.ts +1 -1
  129. package/lib/__tests__/SdJwt.spec.ts +36 -30
  130. package/lib/__tests__/SphereonE2E.spec.test.ts +10 -7
  131. package/lib/__tests__/data/VciDataFixtures.ts +712 -27
  132. package/lib/functions/OpenIDUtils.ts +25 -0
  133. package/lib/functions/index.ts +2 -3
  134. package/lib/functions/notifications.ts +32 -0
  135. package/lib/index.ts +16 -1
  136. package/lib/types/index.ts +6 -0
  137. package/package.json +4 -4
  138. package/dist/functions/ProofUtil.d.ts +0 -30
  139. package/dist/functions/ProofUtil.d.ts.map +0 -1
  140. package/dist/functions/ProofUtil.js +0 -106
  141. package/dist/functions/ProofUtil.js.map +0 -1
  142. package/lib/functions/ProofUtil.ts +0 -128
@@ -1,25 +1,30 @@
1
- import { AccessTokenRequest, CredentialRequestV1_0_11, CredentialSupportedSdJwtVc } from '@sphereon/oid4vci-common';
1
+ import {
2
+ AccessTokenRequest,
3
+ CredentialConfigurationSupportedV1_0_13,
4
+ CredentialRequestV1_0_13,
5
+ CredentialSupportedSdJwtVc,
6
+ } from '@sphereon/oid4vci-common';
2
7
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3
8
  // @ts-ignore
4
9
  import nock from 'nock';
5
10
 
6
- import { OpenID4VCIClient } from '..';
7
- import { createAccessTokenResponse, IssuerMetadataBuilderV1_11, VcIssuerBuilder } from '../../../issuer';
11
+ import { OpenID4VCIClientV1_0_13 } from '..';
12
+ import { createAccessTokenResponse, IssuerMetadataBuilderV1_13, VcIssuerBuilder } from '../../../issuer';
8
13
 
9
14
  export const UNIT_TEST_TIMEOUT = 30000;
10
15
 
11
16
  const alg = 'ES256';
12
17
  const jwk = { kty: 'EC', crv: 'P-256', x: 'zQOowIC1gWJtdddB5GAt4lau6Lt8Ihy771iAfam-1pc', y: 'cjD_7o3gdQ1vgiQy3_sMGs7WrwCMU9FQYimA3HxnMlw' };
13
18
 
14
- const issuerMetadata = new IssuerMetadataBuilderV1_11()
19
+ const issuerMetadata = new IssuerMetadataBuilderV1_13()
15
20
  .withCredentialIssuer('https://example.com')
16
- .withCredentialEndpoint('https://credenital-endpoint.example.com')
21
+ .withCredentialEndpoint('https://credential-endpoint.example.com')
17
22
  .withTokenEndpoint('https://token-endpoint.example.com')
18
- .addSupportedCredential({
23
+ .addCredentialConfigurationsSupported('SdJwtCredentialId', {
19
24
  format: 'vc+sd-jwt',
20
- vct: 'SdJwtCredential',
25
+ vct: 'SdJwtCredentialId',
21
26
  id: 'SdJwtCredentialId',
22
- })
27
+ } as CredentialConfigurationSupportedV1_0_13)
23
28
  .build();
24
29
 
25
30
  const vcIssuer = new VcIssuerBuilder()
@@ -43,7 +48,7 @@ const vcIssuer = new VcIssuerBuilder()
43
48
  },
44
49
  payload: {
45
50
  aud: issuerMetadata.credential_issuer,
46
- iat: +new Date()/1000,
51
+ iat: +new Date() / 1000,
47
52
  nonce: 'a-c-nonce',
48
53
  },
49
54
  },
@@ -65,11 +70,14 @@ describe('sd-jwt vc', () => {
65
70
  const offerUri = await vcIssuer.createCredentialOfferURI({
66
71
  grants: {
67
72
  'urn:ietf:params:oauth:grant-type:pre-authorized_code': {
73
+ tx_code: {
74
+ input_mode: 'text',
75
+ length: 3,
76
+ },
68
77
  'pre-authorized_code': '123',
69
- user_pin_required: false,
70
78
  },
71
79
  },
72
- credentials: ['SdJwtCredentialId'],
80
+ credential_configuration_ids: ['SdJwtCredential'],
73
81
  });
74
82
 
75
83
  nock(vcIssuer.issuerMetadata.credential_issuer).get('/.well-known/openid-credential-issuer').reply(200, JSON.stringify(issuerMetadata));
@@ -77,34 +85,31 @@ describe('sd-jwt vc', () => {
77
85
  nock(vcIssuer.issuerMetadata.credential_issuer).get('/.well-known/oauth-authorization-server').reply(404);
78
86
 
79
87
  expect(offerUri.uri).toEqual(
80
- 'openid-credential-offer://?credential_offer=%7B%22grants%22%3A%7B%22urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Apre-authorized_code%22%3A%7B%22pre-authorized_code%22%3A%22123%22%2C%22user_pin_required%22%3Afalse%7D%7D%2C%22credentials%22%3A%5B%22SdJwtCredentialId%22%5D%2C%22credential_issuer%22%3A%22https%3A%2F%2Fexample.com%22%7D',
88
+ 'openid-credential-offer://?credential_offer=%7B%22grants%22%3A%7B%22urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Apre-authorized_code%22%3A%7B%22pre-authorized_code%22%3A%22123%22%2C%22tx_code%22%3A%7B%22input_mode%22%3A%22text%22%2C%22length%22%3A3%7D%7D%7D%2C%22credential_configuration_ids%22%3A%5B%22SdJwtCredential%22%5D%2C%22credential_issuer%22%3A%22https%3A%2F%2Fexample.com%22%7D',
81
89
  );
82
90
 
83
- const client = await OpenID4VCIClient.fromURI({
91
+ const client = await OpenID4VCIClientV1_0_13.fromURI({
84
92
  uri: offerUri.uri,
85
93
  });
86
94
 
87
95
  expect(client.credentialOffer?.credential_offer).toEqual({
88
96
  credential_issuer: 'https://example.com',
89
- credentials: ['SdJwtCredentialId'],
97
+ credential_configuration_ids: ['SdJwtCredential'],
90
98
  grants: {
91
99
  'urn:ietf:params:oauth:grant-type:pre-authorized_code': {
92
100
  'pre-authorized_code': '123',
93
- user_pin_required: false,
101
+ tx_code: {
102
+ input_mode: 'text',
103
+ length: 3,
104
+ },
94
105
  },
95
106
  },
96
107
  });
97
108
 
98
- const supported = client.getCredentialsSupported(true, 'vc+sd-jwt');
99
- expect(supported).toEqual([
100
- {
101
- vct: 'SdJwtCredential',
102
- format: 'vc+sd-jwt',
103
- id: 'SdJwtCredentialId',
104
- },
105
- ]);
109
+ const supported = client.getCredentialsSupported('vc+sd-jwt');
110
+ expect(supported).toEqual({ SdJwtCredentialId: { format: 'vc+sd-jwt', id: 'SdJwtCredentialId', vct: 'SdJwtCredentialId' } });
106
111
 
107
- const offered = supported[0] as CredentialSupportedSdJwtVc;
112
+ const offered = supported['SdJwtCredentialId'] as CredentialSupportedSdJwtVc;
108
113
 
109
114
  nock(issuerMetadata.token_endpoint as string)
110
115
  .post('/')
@@ -120,13 +125,12 @@ describe('sd-jwt vc', () => {
120
125
  });
121
126
  });
122
127
 
123
- await client.acquireAccessToken({});
124
-
128
+ await client.acquireAccessToken({ pin: '123' });
125
129
  nock(issuerMetadata.credential_endpoint as string)
126
130
  .post('/')
127
131
  .reply(200, async (_, body) =>
128
132
  vcIssuer.issueCredential({
129
- credentialRequest: body as CredentialRequestV1_0_11,
133
+ credentialRequest: { ...(body as CredentialRequestV1_0_13), credential_identifier: offered.vct },
130
134
  credential: {
131
135
  vct: 'Hello',
132
136
  iss: 'did:example:123',
@@ -141,8 +145,8 @@ describe('sd-jwt vc', () => {
141
145
  );
142
146
 
143
147
  const credentials = await client.acquireCredentials({
144
- credentialTypes: [offered.vct],
145
- format: 'vc+sd-jwt',
148
+ credentialIdentifier: offered.vct,
149
+ // format: 'vc+sd-jwt',
146
150
  alg,
147
151
  jwk,
148
152
  proofCallbacks: {
@@ -152,10 +156,12 @@ describe('sd-jwt vc', () => {
152
156
  });
153
157
 
154
158
  expect(credentials).toEqual({
159
+ notification_id: expect.any(String),
160
+ access_token: 'ey.val.ue',
155
161
  c_nonce: 'new-c-nonce',
156
162
  c_nonce_expires_in: 300,
157
163
  credential: 'sd-jwt',
158
- format: 'vc+sd-jwt',
164
+ // format: 'vc+sd-jwt',
159
165
  });
160
166
  },
161
167
  UNIT_TEST_TIMEOUT,
@@ -8,7 +8,7 @@ import debug from 'debug';
8
8
  import { importJWK, JWK, SignJWT } from 'jose';
9
9
  import { v4 } from 'uuid';
10
10
 
11
- import { OpenID4VCIClient } from '..';
11
+ import { OpenID4VCIClientV1_0_11 } from '..';
12
12
 
13
13
  export const UNIT_TEST_TIMEOUT = 60000;
14
14
 
@@ -25,11 +25,12 @@ const jwk: JWK = {
25
25
  // priv hex: 913466d1a38d1d8c0d3c0fb0fc3b633075085a31372bbd2a8022215a88d9d1e5
26
26
  const did = `did:key:z6Mki5ZwZKN1dBQprfJTikUvkDxrHijiiQngkWviMF5gw2Hv`;
27
27
  const kid = `${did}#z6Mki5ZwZKN1dBQprfJTikUvkDxrHijiiQngkWviMF5gw2Hv`;
28
- describe('OID4VCI-Client using Sphereon issuer should', () => {
28
+ // Sphereon infra down rn
29
+ describe.skip('OID4VCI-Client using Sphereon issuer should', () => {
29
30
  async function test(format: 'ldp_vc' | 'jwt_vc_json') {
30
31
  debug.enable('*');
31
32
  const offer = await getCredentialOffer(format);
32
- const client = await OpenID4VCIClient.fromURI({
33
+ const client = await OpenID4VCIClientV1_0_11.fromURI({
33
34
  uri: offer.uri,
34
35
  kid,
35
36
  alg: Alg.EdDSA,
@@ -59,14 +60,14 @@ describe('OID4VCI-Client using Sphereon issuer should', () => {
59
60
  expect(format.startsWith(wrappedVC.format)).toEqual(true);
60
61
  }
61
62
 
62
- xit(
63
+ it(
63
64
  'succeed in a full flow with the client using OpenID4VCI version 11 and ldp_vc',
64
65
  async () => {
65
66
  await test('ldp_vc');
66
67
  },
67
68
  UNIT_TEST_TIMEOUT,
68
69
  );
69
- xit(
70
+ it(
70
71
  'succeed in a full flow with the client using OpenID4VCI version 11 and jwt_vc_json',
71
72
  async () => {
72
73
  await test('jwt_vc_json');
@@ -114,11 +115,13 @@ async function proofOfPossessionCallbackFunction(args: Jwt, kid?: string): Promi
114
115
  .sign(importedJwk);
115
116
  }
116
117
 
118
+ //fixme: bring back this test
117
119
  describe('ismapolis bug report #63, https://github.com/Sphereon-Opensource/OID4VC-demo/issues/63, should', () => {
118
- it('work as expected provided a correct JWT is supplied', async () => {
120
+ // Sphereon infra is not working currently
121
+ it.skip('work as expected provided a correct JWT is supplied', async () => {
119
122
  debug.enable('*');
120
123
  const { uri } = await getCredentialOffer('jwt_vc_json');
121
- const client = await OpenID4VCIClient.fromURI({ uri: uri, clientId: 'test-clientID' });
124
+ const client = await OpenID4VCIClientV1_0_11.fromURI({ uri: uri, clientId: 'test-clientID' });
122
125
  const metadata = await client.retrieveServerMetadata();
123
126
  console.log(JSON.stringify(metadata));
124
127