@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,4 +1,4 @@
1
- import { AuthzFlowType, CredentialOfferRequestWithBaseUrl } from '@sphereon/oid4vci-common';
1
+ import { AuthzFlowType, CredentialOfferPayloadV1_0_13, CredentialOfferRequestWithBaseUrl } from '@sphereon/oid4vci-common';
2
2
 
3
3
  export const IDENTIPROOF_ISSUER_URL = 'https://issuer.research.identiproof.io';
4
4
  export const IDENTIPROOF_AS_URL = 'https://auth.research.identiproof.io';
@@ -7,10 +7,50 @@ export const DANUBE_ISSUER_URL = 'https://oidc4vc.uniissuer.io';
7
7
  export const WALT_ISSUER_URL = 'https://jff.walt.id/issuer-api/oidc';
8
8
  export const INITIATION_TEST_HTTPS_URI =
9
9
  'https://server.example.com?issuer=https%3A%2F%2Fserver%2Eexample%2Ecom&credential_type=https%3A%2F%2Fdid%2Eexample%2Eorg%2FhealthCard&credential_type=https%3A%2F%2Fdid%2Eexample%2Eorg%2FdriverLicense&op_state=eyJhbGciOiJSU0Et...FYUaBy';
10
+ export const INITIATION_TEST_HTTPS_URI_V1_0_11 =
11
+ 'https://server.example.com?issuer=https%3A%2F%2Fserver%2Eexample%2Ecom&credential_type=https%3A%2F%2Fdid%2Eexample%2Eorg%2FhealthCard&credential_type=https%3A%2F%2Fdid%2Eexample%2Eorg%2FdriverLicense&op_state=eyJhbGciOiJSU0Et...FYUaBy';
10
12
  export const INITIATION_TEST_URI =
13
+ 'openid-credential-offer://?credential_offer=%7B%22credential_issuer%22%3A%22https%3A%2F%2Fjff.walt.id%2Fissuer-api%2Foidc%2F%22%2C%22credential_configuration_ids%22%3A%5B%22OpenBadgeCredential%22%5D%2C%22grants%22%3A%7B%22urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Apre-authorized_code%22%3A%7B%22pre-authorized_code%22%3A%22eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhOTUyZjUxNi1jYWVmLTQ4YjMtODIxYy00OTRkYzgyNjljZjAiLCJwcmUtYXV0aG9yaXplZCI6dHJ1ZX0.YE5DlalcLC2ChGEg47CQDaN1gTxbaQqSclIVqsSAUHE%22%2C%22tx_code%22%3A%7B%22description%22%3A%22Please%20provide%20the%20one-time%20code%20that%20was%20sent%20via%20e-mail%22%2C%22input_mode%22%3A%22numeric%22%2C%22length%22%3A4%7D%7D%7D%7D';
14
+
15
+ export const INITIATION_TEST_URI_V1_0_08 =
11
16
  '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';
12
17
 
13
18
  export const INITIATION_TEST: CredentialOfferRequestWithBaseUrl = {
19
+ baseUrl: 'openid-credential-offer://',
20
+ credential_offer: {
21
+ credential_configuration_ids: ['OpenBadgeCredential'],
22
+ credential_issuer: 'https://jff.walt.id/issuer-api/oidc/',
23
+ grants: {
24
+ 'urn:ietf:params:oauth:grant-type:pre-authorized_code': {
25
+ 'pre-authorized_code':
26
+ 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhOTUyZjUxNi1jYWVmLTQ4YjMtODIxYy00OTRkYzgyNjljZjAiLCJwcmUtYXV0aG9yaXplZCI6dHJ1ZX0.YE5DlalcLC2ChGEg47CQDaN1gTxbaQqSclIVqsSAUHE',
27
+ tx_code: {
28
+ length: 4,
29
+ description: 'Please provide the one-time code that was sent via e-mail',
30
+ input_mode: 'numeric',
31
+ },
32
+ },
33
+ },
34
+ } as CredentialOfferPayloadV1_0_13,
35
+ original_credential_offer: {
36
+ credential_issuer: 'https://jff.walt.id/issuer-api/oidc/',
37
+ credential_configuration_ids: ['OpenBadgeCredential'],
38
+ grants: {
39
+ 'urn:ietf:params:oauth:grant-type:pre-authorized_code': {
40
+ 'pre-authorized_code':
41
+ 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhOTUyZjUxNi1jYWVmLTQ4YjMtODIxYy00OTRkYzgyNjljZjAiLCJwcmUtYXV0aG9yaXplZCI6dHJ1ZX0.YE5DlalcLC2ChGEg47CQDaN1gTxbaQqSclIVqsSAUHE',
42
+ tx_code: { description: 'Please provide the one-time code that was sent via e-mail', input_mode: 'numeric', length: 4 },
43
+ },
44
+ },
45
+ } as CredentialOfferPayloadV1_0_13,
46
+ preAuthorizedCode:
47
+ 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhOTUyZjUxNi1jYWVmLTQ4YjMtODIxYy00OTRkYzgyNjljZjAiLCJwcmUtYXV0aG9yaXplZCI6dHJ1ZX0.YE5DlalcLC2ChGEg47CQDaN1gTxbaQqSclIVqsSAUHE',
48
+ scheme: 'openid-credential-offer',
49
+ supportedFlows: [AuthzFlowType.PRE_AUTHORIZED_CODE_FLOW],
50
+ version: 1013,
51
+ userPinRequired: true, // Determined from above tx_code
52
+ };
53
+ export const INITIATION_TEST_V1_0_08: CredentialOfferRequestWithBaseUrl = {
14
54
  baseUrl: 'openid-initiate-issuance://',
15
55
  credential_offer: {
16
56
  credential_issuer: 'https://jff.walt.id/issuer-api/oidc/',
@@ -36,7 +76,7 @@ export const INITIATION_TEST: CredentialOfferRequestWithBaseUrl = {
36
76
  supportedFlows: [AuthzFlowType.PRE_AUTHORIZED_CODE_FLOW],
37
77
  userPinRequired: false,
38
78
  version: 1008,
39
- };
79
+ } as CredentialOfferRequestWithBaseUrl;
40
80
  export const IDENTIPROOF_AS_METADATA = {
41
81
  issuer: 'https://auth.research.identiproof.io',
42
82
  authorization_endpoint: 'https://auth.research.identiproof.io/oauth2/authorize',
@@ -1,8 +1,16 @@
1
- import { CodeChallengeMethod, WellKnownEndpoints } from '@sphereon/oid4vci-common';
1
+ import {
2
+ CodeChallengeMethod,
3
+ CredentialOfferPayloadV1_0_13,
4
+ determineSpecVersionFromOffer,
5
+ determineSpecVersionFromURI,
6
+ OpenId4VCIVersion,
7
+ WellKnownEndpoints,
8
+ } from '@sphereon/oid4vci-common';
2
9
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3
10
  // @ts-ignore
4
11
  import nock from 'nock';
5
12
 
13
+ import { createCredentialOfferURIFromObject } from '../../../issuer/lib';
6
14
  import { OpenID4VCIClient } from '../OpenID4VCIClient';
7
15
 
8
16
  const MOCK_URL = 'https://server.example.com/';
@@ -16,7 +24,7 @@ describe('OpenID4VCIClient should', () => {
16
24
  nock(MOCK_URL).get(WellKnownEndpoints.OPENID_CONFIGURATION).reply(404, {});
17
25
  client = await OpenID4VCIClient.fromURI({
18
26
  clientId: 'test-client',
19
- uri: 'openid-initiate-issuance://?issuer=https://server.example.com&credential_type=TestCredential',
27
+ uri: 'openid-credential-offer://?credential_offer=%7B%22credential_issuer%22%3A%22https%3A%2F%2Fserver.example.com%22%2C%22credential_configuration_ids%22%3A%5B%22TestCredential%22%5D%7D',
20
28
  createAuthorizationRequestURL: false,
21
29
  });
22
30
  });
@@ -102,6 +110,7 @@ describe('OpenID4VCIClient should', () => {
102
110
  codeChallenge: 'mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs',
103
111
  },
104
112
  authorizationRequest: {
113
+ clientId: 'clientId',
105
114
  redirectUri: 'http://localhost:8881/cb',
106
115
  },
107
116
  }),
@@ -170,6 +179,7 @@ describe('OpenID4VCIClient should', () => {
170
179
  'https://server.example.com/v1/auth/authorize?response_type=code&code_challenge_method=S256&code_challenge=mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs&authorization_details=%7B%22type%22%3A%22openid_credential%22%2C%22format%22%3A%22ldp_vc%22%2C%22credential_definition%22%3A%7B%22%40context%22%3A%5B%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fv1%22%2C%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fexamples%2Fv1%22%5D%2C%22types%22%3A%5B%22VerifiableCredential%22%2C%22UniversityDegreeCredential%22%5D%7D%2C%22locations%22%3A%5B%22https%3A%2F%2Fserver%2Eexample%2Ecom%22%5D%7D&redirect_uri=http%3A%2F%2Flocalhost%3A8881%2Fcb&client_id=test-client&scope=openid',
171
180
  );
172
181
  });
182
+
173
183
  it('create an authorization request url with authorization_details and scope', async () => {
174
184
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
175
185
  // @ts-ignore
@@ -200,3 +210,49 @@ describe('OpenID4VCIClient should', () => {
200
210
  );
201
211
  });
202
212
  });
213
+ describe('should successfully handle isEbsi function', () => {
214
+ it('should return true when calling isEbsi function', async () => {
215
+ nock(MOCK_URL).get(/.*/).reply(200, {});
216
+ nock(MOCK_URL).get(WellKnownEndpoints.OAUTH_AS).reply(404, {});
217
+ nock(MOCK_URL).get(WellKnownEndpoints.OPENID_CONFIGURATION).reply(404, {});
218
+ const client = await OpenID4VCIClient.fromURI({
219
+ clientId: 'test-client',
220
+ uri: 'openid-credential-offer://?credential_offer=%7B%22credential_issuer%22%3A%22https%3A%2F%2Fserver.example.com%22%2C%20%22credentials%22%3A%5B%7B%22format%22%3A%22jwt_vc%22%2C%22types%22%3A%5B%22VerifiableCredential%22%2C%22VerifiableAttestation%22%2C%22CTWalletSameAuthorisedInTime%22%5D%2C%22trust_framework%22%3A%7B%22name%22%3A%22ebsi%22%2C%22type%22%3A%22Accreditation%22%2C%22uri%22%3A%22TIR%20link%20towards%20accreditation%22%7D%7D%5D%7D',
221
+ createAuthorizationRequestURL: false,
222
+ });
223
+
224
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
225
+ // @ts-ignore
226
+ client._state.endpointMetadata?.credentialIssuerMetadata = {
227
+ credentials_supported: {
228
+ TestCredential: {
229
+ trust_framework: {
230
+ name: 'ebsi_trust',
231
+ },
232
+ },
233
+ },
234
+ };
235
+ expect(client.isEBSI()).toBe(true);
236
+ });
237
+ });
238
+
239
+ it('determine to be version 13', async () => {
240
+ const offer = {
241
+ grants: {
242
+ 'urn:ietf:params:oauth:grant-type:pre-authorized_code': {
243
+ 'pre-authorized_code': 'random',
244
+ },
245
+ },
246
+ credential_configuration_ids: ['Omzetbelasting'],
247
+ credential_issuer: 'https://example.com',
248
+ } satisfies CredentialOfferPayloadV1_0_13;
249
+ const offerUri = createCredentialOfferURIFromObject({ credential_offer: offer });
250
+
251
+ expect(determineSpecVersionFromOffer(offer)).toEqual(OpenId4VCIVersion.VER_1_0_13);
252
+ expect(determineSpecVersionFromURI(offerUri)).toEqual(OpenId4VCIVersion.VER_1_0_13);
253
+ });
254
+ it('determine to be version 11', async () => {
255
+ const offerUri =
256
+ '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%22wN39X8fU4FCU2MaykNRkCr%22%2C%22user_pin_required%22%3Afalse%7D%7D%2C%22credentials%22%3A%5B%22dbc2023%22%5D%2C%22credential_issuer%22%3A%22https%3A%2F%2Fssi.dutchblockchaincoalition.org%2Fagent%22%7D';
257
+ expect(determineSpecVersionFromURI(offerUri)).toEqual(OpenId4VCIVersion.VER_1_0_11);
258
+ });
@@ -3,18 +3,18 @@ import { PARMode, WellKnownEndpoints } from '@sphereon/oid4vci-common';
3
3
  // @ts-ignore
4
4
  import nock from 'nock';
5
5
 
6
- import { OpenID4VCIClient } from '../OpenID4VCIClient';
6
+ import { OpenID4VCIClientV1_0_11 } from '../OpenID4VCIClientV1_0_11';
7
7
 
8
8
  const MOCK_URL = 'https://server.example.com/';
9
- describe('OpenID4VCIClient', () => {
10
- let client: OpenID4VCIClient;
9
+ describe('OpenID4VCIClientV1_0_11', () => {
10
+ let client: OpenID4VCIClientV1_0_11;
11
11
 
12
12
  beforeEach(async () => {
13
13
  nock(MOCK_URL).get(/.*/).reply(200, {});
14
14
  nock(MOCK_URL).get(WellKnownEndpoints.OAUTH_AS).reply(404, {});
15
15
  nock(MOCK_URL).get(WellKnownEndpoints.OPENID_CONFIGURATION).reply(404, {});
16
16
  nock(`${MOCK_URL}`).post('/v1/auth/par').reply(201, { request_uri: 'test_uri', expires_in: 90 });
17
- client = await OpenID4VCIClient.fromURI({
17
+ client = await OpenID4VCIClientV1_0_11.fromURI({
18
18
  createAuthorizationRequestURL: false,
19
19
  clientId: 'test-client',
20
20
  uri: 'openid-initiate-issuance://?issuer=https://server.example.com&credential_type=TestCredential',
@@ -59,7 +59,7 @@ describe('OpenID4VCIClient', () => {
59
59
  redirectUri: 'http://localhost:8881/cb',
60
60
  },
61
61
  }),
62
- ).rejects.toThrow(Error('Could not create authorization details from credential offer. Please pass in explicit details'));
62
+ ).rejects.toThrow('Could not create authorization details from credential offer. Please pass in explicit details');
63
63
  });
64
64
 
65
65
  it('should not fail when only authorization_details is present', async () => {
@@ -0,0 +1,226 @@
1
+ import { CodeChallengeMethod, WellKnownEndpoints } from '@sphereon/oid4vci-common';
2
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3
+ // @ts-ignore
4
+ import nock from 'nock';
5
+
6
+ import { OpenID4VCIClientV1_0_11 } from '../OpenID4VCIClientV1_0_11';
7
+
8
+ const MOCK_URL = 'https://server.example.com/';
9
+
10
+ describe('OpenID4VCIClientV1_0_11 should', () => {
11
+ let client: OpenID4VCIClientV1_0_11;
12
+
13
+ beforeEach(async () => {
14
+ nock(MOCK_URL).get(/.*/).reply(200, {});
15
+ nock(MOCK_URL).get(WellKnownEndpoints.OAUTH_AS).reply(404, {});
16
+ nock(MOCK_URL).get(WellKnownEndpoints.OPENID_CONFIGURATION).reply(404, {});
17
+ client = await OpenID4VCIClientV1_0_11.fromURI({
18
+ clientId: 'test-client',
19
+ uri: 'openid-initiate-issuance://?issuer=https://server.example.com&credential_type=TestCredential',
20
+ createAuthorizationRequestURL: false,
21
+ });
22
+ });
23
+
24
+ afterEach(() => {
25
+ nock.cleanAll();
26
+ });
27
+
28
+ it('should successfully construct an authorization request url', async () => {
29
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
30
+ // @ts-ignore
31
+ client._state.endpointMetadata?.credentialIssuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
32
+ const url = await client.createAuthorizationRequestUrl({
33
+ authorizationRequest: {
34
+ scope: 'openid TestCredential',
35
+ redirectUri: 'http://localhost:8881/cb',
36
+ },
37
+ });
38
+
39
+ const urlSearchParams = new URLSearchParams(url.split('?')[1]);
40
+ const scope = urlSearchParams.get('scope')?.split(' ');
41
+
42
+ expect(scope?.[0]).toBe('openid');
43
+ });
44
+ it('throw an error if authorization endpoint is not set in server metadata', async () => {
45
+ await expect(
46
+ client.createAuthorizationRequestUrl({
47
+ authorizationRequest: {
48
+ scope: 'openid TestCredential',
49
+ redirectUri: 'http://localhost:8881/cb',
50
+ },
51
+ }),
52
+ ).rejects.toThrow(Error('Server metadata does not contain authorization endpoint'));
53
+ });
54
+ it("injects 'openid' as the first scope if not provided", async () => {
55
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
56
+ // @ts-ignore
57
+ client._state.endpointMetadata?.credentialIssuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
58
+
59
+ const url = await client.createAuthorizationRequestUrl({
60
+ pkce: {
61
+ codeChallengeMethod: CodeChallengeMethod.S256,
62
+ codeChallenge: 'mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs',
63
+ },
64
+ authorizationRequest: {
65
+ scope: 'TestCredential',
66
+ redirectUri: 'http://localhost:8881/cb',
67
+ },
68
+ });
69
+
70
+ const urlSearchParams = new URLSearchParams(url.split('?')[1]);
71
+ const scope = urlSearchParams.get('scope')?.split(' ');
72
+
73
+ expect(scope?.[0]).toBe('openid');
74
+ });
75
+ it('throw an error if no scope and no authorization_details is provided', async () => {
76
+ nock(MOCK_URL).get(/.*/).reply(200, {});
77
+ nock(MOCK_URL).get(WellKnownEndpoints.OAUTH_AS).reply(200, {});
78
+ nock(MOCK_URL).get(WellKnownEndpoints.OPENID_CONFIGURATION).reply(200, {});
79
+ // Use a client with issuer only to trigger the error
80
+ client = await OpenID4VCIClientV1_0_11.fromCredentialIssuer({
81
+ credentialIssuer: MOCK_URL,
82
+ createAuthorizationRequestURL: false,
83
+ retrieveServerMetadata: false,
84
+ });
85
+
86
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
87
+ // @ts-ignore
88
+ client._state.endpointMetadata = {
89
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
90
+ // @ts-ignore
91
+ credentialIssuerMetadata: {
92
+ authorization_endpoint: `${MOCK_URL}v1/auth/authorize`,
93
+ token_endpoint: `${MOCK_URL}/token`,
94
+ },
95
+ };
96
+ // client._state.endpointMetadata.credentialIssuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
97
+
98
+ await expect(
99
+ client.createAuthorizationRequestUrl({
100
+ pkce: {
101
+ codeChallengeMethod: CodeChallengeMethod.S256,
102
+ codeChallenge: 'mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs',
103
+ },
104
+ authorizationRequest: {
105
+ redirectUri: 'http://localhost:8881/cb',
106
+ },
107
+ }),
108
+ ).rejects.toThrow(Error('Please provide a scope or authorization_details if no credential offer is present'));
109
+ });
110
+ it('create an authorization request url with authorization_details array property', async () => {
111
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
112
+ // @ts-ignore
113
+ client._state.endpointMetadata?.credentialIssuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
114
+
115
+ await expect(
116
+ client.createAuthorizationRequestUrl({
117
+ pkce: {
118
+ codeChallengeMethod: CodeChallengeMethod.S256,
119
+ codeChallenge: 'mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs',
120
+ },
121
+ authorizationRequest: {
122
+ authorizationDetails: [
123
+ {
124
+ type: 'openid_credential',
125
+ format: 'ldp_vc',
126
+ credential_definition: {
127
+ '@context': ['https://www.w3.org/2018/credentials/v1', 'https://www.w3.org/2018/credentials/examples/v1'],
128
+ types: ['VerifiableCredential', 'UniversityDegreeCredential'],
129
+ },
130
+ },
131
+ {
132
+ type: 'openid_credential',
133
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
134
+ // @ts-ignore
135
+ format: 'mso_mdoc',
136
+ doctype: 'org.iso.18013.5.1.mDL',
137
+ },
138
+ ],
139
+ redirectUri: 'http://localhost:8881/cb',
140
+ },
141
+ }),
142
+ ).resolves.toEqual(
143
+ 'https://server.example.com/v1/auth/authorize?response_type=code&code_challenge_method=S256&code_challenge=mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs&authorization_details=%5B%7B%22type%22%3A%22openid_credential%22%2C%22format%22%3A%22ldp_vc%22%2C%22credential_definition%22%3A%7B%22%40context%22%3A%5B%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fv1%22%2C%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fexamples%2Fv1%22%5D%2C%22types%22%3A%5B%22VerifiableCredential%22%2C%22UniversityDegreeCredential%22%5D%7D%2C%22locations%22%3A%5B%22https%3A%2F%2Fserver%2Eexample%2Ecom%22%5D%7D%2C%7B%22type%22%3A%22openid_credential%22%2C%22format%22%3A%22mso_mdoc%22%2C%22doctype%22%3A%22org%2Eiso%2E18013%2E5%2E1%2EmDL%22%2C%22locations%22%3A%5B%22https%3A%2F%2Fserver%2Eexample%2Ecom%22%5D%7D%5D&redirect_uri=http%3A%2F%2Flocalhost%3A8881%2Fcb&client_id=test-client&scope=openid',
144
+ );
145
+ });
146
+ it('create an authorization request url with authorization_details object property', async () => {
147
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
148
+ // @ts-ignore
149
+ client._state.endpointMetadata?.credentialIssuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
150
+
151
+ await expect(
152
+ client.createAuthorizationRequestUrl({
153
+ pkce: {
154
+ codeChallengeMethod: CodeChallengeMethod.S256,
155
+ codeChallenge: 'mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs',
156
+ },
157
+ authorizationRequest: {
158
+ authorizationDetails: {
159
+ type: 'openid_credential',
160
+ format: 'ldp_vc',
161
+ credential_definition: {
162
+ '@context': ['https://www.w3.org/2018/credentials/v1', 'https://www.w3.org/2018/credentials/examples/v1'],
163
+ types: ['VerifiableCredential', 'UniversityDegreeCredential'],
164
+ },
165
+ },
166
+ redirectUri: 'http://localhost:8881/cb',
167
+ },
168
+ }),
169
+ ).resolves.toEqual(
170
+ 'https://server.example.com/v1/auth/authorize?response_type=code&code_challenge_method=S256&code_challenge=mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs&authorization_details=%7B%22type%22%3A%22openid_credential%22%2C%22format%22%3A%22ldp_vc%22%2C%22credential_definition%22%3A%7B%22%40context%22%3A%5B%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fv1%22%2C%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fexamples%2Fv1%22%5D%2C%22types%22%3A%5B%22VerifiableCredential%22%2C%22UniversityDegreeCredential%22%5D%7D%2C%22locations%22%3A%5B%22https%3A%2F%2Fserver%2Eexample%2Ecom%22%5D%7D&redirect_uri=http%3A%2F%2Flocalhost%3A8881%2Fcb&client_id=test-client&scope=openid',
171
+ );
172
+ });
173
+ it('create an authorization request url with authorization_details and scope', async () => {
174
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
175
+ // @ts-ignore
176
+ client._state.endpointMetadata.credentialIssuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
177
+
178
+ await expect(
179
+ client.createAuthorizationRequestUrl({
180
+ pkce: {
181
+ codeChallengeMethod: CodeChallengeMethod.S256,
182
+ codeChallenge: 'mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs',
183
+ },
184
+ authorizationRequest: {
185
+ authorizationDetails: {
186
+ type: 'openid_credential',
187
+ format: 'ldp_vc',
188
+ locations: ['https://test.com'],
189
+ credential_definition: {
190
+ '@context': ['https://www.w3.org/2018/credentials/v1', 'https://www.w3.org/2018/credentials/examples/v1'],
191
+ types: ['VerifiableCredential', 'UniversityDegreeCredential'],
192
+ },
193
+ },
194
+ scope: 'openid',
195
+ redirectUri: 'http://localhost:8881/cb',
196
+ },
197
+ }),
198
+ ).resolves.toEqual(
199
+ 'https://server.example.com/v1/auth/authorize?response_type=code&code_challenge_method=S256&code_challenge=mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs&authorization_details=%7B%22type%22%3A%22openid_credential%22%2C%22format%22%3A%22ldp_vc%22%2C%22locations%22%3A%5B%22https%3A%2F%2Ftest%2Ecom%22%2C%22https%3A%2F%2Fserver%2Eexample%2Ecom%22%5D%2C%22credential_definition%22%3A%7B%22%40context%22%3A%5B%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fv1%22%2C%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fexamples%2Fv1%22%5D%2C%22types%22%3A%5B%22VerifiableCredential%22%2C%22UniversityDegreeCredential%22%5D%7D%7D&redirect_uri=http%3A%2F%2Flocalhost%3A8881%2Fcb&client_id=test-client&scope=openid',
200
+ );
201
+ });
202
+ });
203
+
204
+ it('should return true when calling isEbsi function', async () => {
205
+ nock(MOCK_URL).get(/.*/).reply(200, {});
206
+ nock(MOCK_URL).get(WellKnownEndpoints.OAUTH_AS).reply(404, {});
207
+ nock(MOCK_URL).get(WellKnownEndpoints.OPENID_CONFIGURATION).reply(404, {});
208
+ const client = await OpenID4VCIClientV1_0_11.fromURI({
209
+ clientId: 'test-client',
210
+ uri: 'openid-credential-offer://?credential_offer=%7B%22credential_issuer%22%3A%22https%3A%2F%2Fserver.example.com%22%2C%20%22credentials%22%3A%5B%7B%22format%22%3A%22jwt_vc%22%2C%22types%22%3A%5B%22VerifiableCredential%22%2C%22VerifiableAttestation%22%2C%22CTWalletSameAuthorisedInTime%22%5D%2C%22trust_framework%22%3A%7B%22name%22%3A%22ebsi%22%2C%22type%22%3A%22Accreditation%22%2C%22uri%22%3A%22TIR%20link%20towards%20accreditation%22%7D%7D%5D%7D',
211
+ createAuthorizationRequestURL: false,
212
+ });
213
+
214
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
215
+ // @ts-ignore
216
+ client._state.endpointMetadata?.credentialIssuerMetadata = {
217
+ credentials_supported: {
218
+ TestCredential: {
219
+ trust_framework: {
220
+ name: 'ebsi_trust',
221
+ },
222
+ },
223
+ },
224
+ };
225
+ expect(client.isEBSI()).toBe(true);
226
+ });
@@ -0,0 +1,204 @@
1
+ import { CodeChallengeMethod, WellKnownEndpoints } from '@sphereon/oid4vci-common';
2
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3
+ // @ts-ignore
4
+ import nock from 'nock';
5
+
6
+ import { OpenID4VCIClientV1_0_13 } from '../OpenID4VCIClientV1_0_13';
7
+
8
+ const MOCK_URL = 'https://server.example.com/';
9
+
10
+ describe('OpenID4VCIClientV1_0_13 should', () => {
11
+ let client: OpenID4VCIClientV1_0_13;
12
+
13
+ beforeEach(async () => {
14
+ nock(MOCK_URL).get(/.*/).reply(200, {});
15
+ nock(MOCK_URL).get(WellKnownEndpoints.OAUTH_AS).reply(404, {});
16
+ nock(MOCK_URL).get(WellKnownEndpoints.OPENID_CONFIGURATION).reply(404, {});
17
+ client = await OpenID4VCIClientV1_0_13.fromURI({
18
+ clientId: 'test-client',
19
+ uri: 'openid-credential-offer://?credential_offer=%7B%22credential_issuer%22%3A%22https%3A%2F%2Fserver.example.com%22%2C%22credential_configuration_ids%22%3A%5B%22TestCredential%22%5D%7D',
20
+ createAuthorizationRequestURL: false,
21
+ });
22
+ });
23
+
24
+ afterEach(() => {
25
+ nock.cleanAll();
26
+ });
27
+
28
+ it('should successfully construct an authorization request url', async () => {
29
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
30
+ // @ts-ignore
31
+ client._state.endpointMetadata?.credentialIssuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
32
+ const url = await client.createAuthorizationRequestUrl({
33
+ authorizationRequest: {
34
+ scope: 'openid TestCredential',
35
+ redirectUri: 'http://localhost:8881/cb',
36
+ },
37
+ });
38
+
39
+ const urlSearchParams = new URLSearchParams(url.split('?')[1]);
40
+ const scope = urlSearchParams.get('scope')?.split(' ');
41
+
42
+ expect(scope?.[0]).toBe('openid');
43
+ });
44
+ it('throw an error if authorization endpoint is not set in server metadata', async () => {
45
+ await expect(
46
+ client.createAuthorizationRequestUrl({
47
+ authorizationRequest: {
48
+ scope: 'openid TestCredential',
49
+ redirectUri: 'http://localhost:8881/cb',
50
+ },
51
+ }),
52
+ ).rejects.toThrow(Error('Server metadata does not contain authorization endpoint'));
53
+ });
54
+ it("injects 'openid' as the first scope if not provided", async () => {
55
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
56
+ // @ts-ignore
57
+ client._state.endpointMetadata?.credentialIssuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
58
+
59
+ const url = await client.createAuthorizationRequestUrl({
60
+ pkce: {
61
+ codeChallengeMethod: CodeChallengeMethod.S256,
62
+ codeChallenge: 'mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs',
63
+ },
64
+ authorizationRequest: {
65
+ scope: 'TestCredential',
66
+ redirectUri: 'http://localhost:8881/cb',
67
+ },
68
+ });
69
+
70
+ const urlSearchParams = new URLSearchParams(url.split('?')[1]);
71
+ const scope = urlSearchParams.get('scope')?.split(' ');
72
+
73
+ expect(scope?.[0]).toBe('openid');
74
+ });
75
+ it('throw an error if no scope and no authorization_details is provided', async () => {
76
+ nock(MOCK_URL).get(/.*/).reply(200, {});
77
+ nock(MOCK_URL).get(WellKnownEndpoints.OAUTH_AS).reply(200, {});
78
+ nock(MOCK_URL).get(WellKnownEndpoints.OPENID_CONFIGURATION).reply(200, {});
79
+ // Use a client with issuer only to trigger the error
80
+ client = await OpenID4VCIClientV1_0_13.fromCredentialIssuer({
81
+ credentialIssuer: MOCK_URL,
82
+ createAuthorizationRequestURL: false,
83
+ retrieveServerMetadata: false,
84
+ });
85
+
86
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
87
+ // @ts-ignore
88
+ client._state.endpointMetadata = {
89
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
90
+ // @ts-ignore
91
+ credentialIssuerMetadata: {
92
+ authorization_endpoint: `${MOCK_URL}v1/auth/authorize`,
93
+ token_endpoint: `${MOCK_URL}/token`,
94
+ },
95
+ };
96
+ // client._state.endpointMetadata.credentialIssuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
97
+
98
+ await expect(
99
+ client.createAuthorizationRequestUrl({
100
+ pkce: {
101
+ codeChallengeMethod: CodeChallengeMethod.S256,
102
+ codeChallenge: 'mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs',
103
+ },
104
+ authorizationRequest: {
105
+ clientId: 'clientId',
106
+ redirectUri: 'http://localhost:8881/cb',
107
+ },
108
+ }),
109
+ ).rejects.toThrow(Error('Please provide a scope or authorization_details if no credential offer is present'));
110
+ });
111
+ it('create an authorization request url with authorization_details array property', async () => {
112
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
113
+ // @ts-ignore
114
+ client._state.endpointMetadata?.credentialIssuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
115
+
116
+ await expect(
117
+ client.createAuthorizationRequestUrl({
118
+ pkce: {
119
+ codeChallengeMethod: CodeChallengeMethod.S256,
120
+ codeChallenge: 'mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs',
121
+ },
122
+ authorizationRequest: {
123
+ authorizationDetails: [
124
+ {
125
+ type: 'openid_credential',
126
+ format: 'ldp_vc',
127
+ credential_definition: {
128
+ '@context': ['https://www.w3.org/2018/credentials/v1', 'https://www.w3.org/2018/credentials/examples/v1'],
129
+ types: ['VerifiableCredential', 'UniversityDegreeCredential'],
130
+ },
131
+ },
132
+ {
133
+ type: 'openid_credential',
134
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
135
+ // @ts-ignore
136
+ format: 'mso_mdoc',
137
+ doctype: 'org.iso.18013.5.1.mDL',
138
+ },
139
+ ],
140
+ redirectUri: 'http://localhost:8881/cb',
141
+ },
142
+ }),
143
+ ).resolves.toEqual(
144
+ 'https://server.example.com/v1/auth/authorize?response_type=code&code_challenge_method=S256&code_challenge=mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs&authorization_details=%5B%7B%22type%22%3A%22openid_credential%22%2C%22format%22%3A%22ldp_vc%22%2C%22credential_definition%22%3A%7B%22%40context%22%3A%5B%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fv1%22%2C%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fexamples%2Fv1%22%5D%2C%22types%22%3A%5B%22VerifiableCredential%22%2C%22UniversityDegreeCredential%22%5D%7D%2C%22locations%22%3A%5B%22https%3A%2F%2Fserver%2Eexample%2Ecom%22%5D%7D%2C%7B%22type%22%3A%22openid_credential%22%2C%22format%22%3A%22mso_mdoc%22%2C%22doctype%22%3A%22org%2Eiso%2E18013%2E5%2E1%2EmDL%22%2C%22locations%22%3A%5B%22https%3A%2F%2Fserver%2Eexample%2Ecom%22%5D%7D%5D&redirect_uri=http%3A%2F%2Flocalhost%3A8881%2Fcb&client_id=test-client&scope=openid',
145
+ );
146
+ });
147
+ it('create an authorization request url with authorization_details object property', async () => {
148
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
149
+ // @ts-ignore
150
+ client._state.endpointMetadata?.credentialIssuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
151
+
152
+ await expect(
153
+ client.createAuthorizationRequestUrl({
154
+ pkce: {
155
+ codeChallengeMethod: CodeChallengeMethod.S256,
156
+ codeChallenge: 'mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs',
157
+ },
158
+ authorizationRequest: {
159
+ authorizationDetails: {
160
+ type: 'openid_credential',
161
+ format: 'ldp_vc',
162
+ credential_definition: {
163
+ '@context': ['https://www.w3.org/2018/credentials/v1', 'https://www.w3.org/2018/credentials/examples/v1'],
164
+ types: ['VerifiableCredential', 'UniversityDegreeCredential'],
165
+ },
166
+ },
167
+ redirectUri: 'http://localhost:8881/cb',
168
+ },
169
+ }),
170
+ ).resolves.toEqual(
171
+ 'https://server.example.com/v1/auth/authorize?response_type=code&code_challenge_method=S256&code_challenge=mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs&authorization_details=%7B%22type%22%3A%22openid_credential%22%2C%22format%22%3A%22ldp_vc%22%2C%22credential_definition%22%3A%7B%22%40context%22%3A%5B%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fv1%22%2C%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fexamples%2Fv1%22%5D%2C%22types%22%3A%5B%22VerifiableCredential%22%2C%22UniversityDegreeCredential%22%5D%7D%2C%22locations%22%3A%5B%22https%3A%2F%2Fserver%2Eexample%2Ecom%22%5D%7D&redirect_uri=http%3A%2F%2Flocalhost%3A8881%2Fcb&client_id=test-client&scope=openid',
172
+ );
173
+ });
174
+
175
+ it('create an authorization request url with authorization_details and scope', async () => {
176
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
177
+ // @ts-ignore
178
+ client._state.endpointMetadata.credentialIssuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
179
+
180
+ await expect(
181
+ client.createAuthorizationRequestUrl({
182
+ pkce: {
183
+ codeChallengeMethod: CodeChallengeMethod.S256,
184
+ codeChallenge: 'mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs',
185
+ },
186
+ authorizationRequest: {
187
+ authorizationDetails: {
188
+ type: 'openid_credential',
189
+ format: 'ldp_vc',
190
+ locations: ['https://test.com'],
191
+ credential_definition: {
192
+ '@context': ['https://www.w3.org/2018/credentials/v1', 'https://www.w3.org/2018/credentials/examples/v1'],
193
+ types: ['VerifiableCredential', 'UniversityDegreeCredential'],
194
+ },
195
+ },
196
+ scope: 'openid',
197
+ redirectUri: 'http://localhost:8881/cb',
198
+ },
199
+ }),
200
+ ).resolves.toEqual(
201
+ 'https://server.example.com/v1/auth/authorize?response_type=code&code_challenge_method=S256&code_challenge=mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs&authorization_details=%7B%22type%22%3A%22openid_credential%22%2C%22format%22%3A%22ldp_vc%22%2C%22locations%22%3A%5B%22https%3A%2F%2Ftest%2Ecom%22%2C%22https%3A%2F%2Fserver%2Eexample%2Ecom%22%5D%2C%22credential_definition%22%3A%7B%22%40context%22%3A%5B%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fv1%22%2C%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fexamples%2Fv1%22%5D%2C%22types%22%3A%5B%22VerifiableCredential%22%2C%22UniversityDegreeCredential%22%5D%7D%7D&redirect_uri=http%3A%2F%2Flocalhost%3A8881%2Fcb&client_id=test-client&scope=openid',
202
+ );
203
+ });
204
+ });
@@ -9,7 +9,7 @@ import { IDENTIPROOF_ISSUER_URL } from './MetadataMocks';
9
9
 
10
10
  const jwt: Jwt = {
11
11
  header: { alg: Alg.ES256, kid: 'did:example:ebfeb1f712ebc6f1c276e12ec21/keys/1', typ: 'jwt' },
12
- payload: { iss: 'sphereon:wallet', nonce: 'tZignsnFbp', jti: 'tZignsnFbp223', aud: IDENTIPROOF_ISSUER_URL, iat: Date.now()/1000 },
12
+ payload: { iss: 'sphereon:wallet', nonce: 'tZignsnFbp', jti: 'tZignsnFbp223', aud: IDENTIPROOF_ISSUER_URL, iat: Date.now() / 1000 },
13
13
  };
14
14
 
15
15
  const kid = 'did:example:ebfeb1f712ebc6f1c276e12ec21/keys/1';