@sphereon/oid4vci-client 0.2.0 → 0.4.1-unstable.247

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 (116) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +494 -371
  3. package/dist/AccessTokenClient.d.ts +30 -0
  4. package/dist/AccessTokenClient.d.ts.map +1 -0
  5. package/dist/AccessTokenClient.js +226 -0
  6. package/dist/AccessTokenClient.js.map +1 -0
  7. package/dist/AuthorizationDetailsBuilder.d.ts +11 -0
  8. package/dist/AuthorizationDetailsBuilder.d.ts.map +1 -0
  9. package/dist/AuthorizationDetailsBuilder.js +44 -0
  10. package/dist/AuthorizationDetailsBuilder.js.map +1 -0
  11. package/dist/CredentialOffer.d.ts +6 -0
  12. package/dist/CredentialOffer.d.ts.map +1 -0
  13. package/dist/CredentialOffer.js +49 -0
  14. package/dist/CredentialOffer.js.map +1 -0
  15. package/dist/CredentialRequestClient.d.ts +29 -0
  16. package/dist/CredentialRequestClient.d.ts.map +1 -0
  17. package/dist/CredentialRequestClient.js +63 -0
  18. package/dist/CredentialRequestClient.js.map +1 -0
  19. package/dist/CredentialRequestClientBuilderV1_0_09.d.ts +29 -0
  20. package/dist/CredentialRequestClientBuilderV1_0_09.d.ts.map +1 -0
  21. package/dist/CredentialRequestClientBuilderV1_0_09.js +63 -0
  22. package/dist/CredentialRequestClientBuilderV1_0_09.js.map +1 -0
  23. package/dist/{main/lib/MetadataClient.d.ts → MetadataClient.d.ts} +39 -38
  24. package/dist/MetadataClient.d.ts.map +1 -0
  25. package/dist/MetadataClient.js +148 -0
  26. package/dist/MetadataClient.js.map +1 -0
  27. package/dist/OpenID4VCIClient.d.ts +72 -0
  28. package/dist/OpenID4VCIClient.d.ts.map +1 -0
  29. package/dist/OpenID4VCIClient.js +361 -0
  30. package/dist/OpenID4VCIClient.js.map +1 -0
  31. package/dist/ProofOfPossessionBuilder.d.ts +35 -0
  32. package/dist/ProofOfPossessionBuilder.d.ts.map +1 -0
  33. package/dist/ProofOfPossessionBuilder.js +120 -0
  34. package/dist/ProofOfPossessionBuilder.js.map +1 -0
  35. package/dist/{main/lib/functions → functions}/Encoding.d.ts +20 -17
  36. package/dist/functions/Encoding.d.ts.map +1 -0
  37. package/dist/functions/Encoding.js +144 -0
  38. package/dist/functions/Encoding.js.map +1 -0
  39. package/dist/functions/HttpUtils.d.ts +24 -0
  40. package/dist/functions/HttpUtils.d.ts.map +1 -0
  41. package/dist/functions/HttpUtils.js +93 -0
  42. package/dist/functions/HttpUtils.js.map +1 -0
  43. package/dist/functions/ProofUtil.d.ts +29 -0
  44. package/dist/functions/ProofUtil.d.ts.map +1 -0
  45. package/dist/functions/ProofUtil.js +103 -0
  46. package/dist/functions/ProofUtil.js.map +1 -0
  47. package/dist/functions/index.d.ts +4 -0
  48. package/dist/functions/index.d.ts.map +1 -0
  49. package/dist/{main/lib/functions → functions}/index.js +20 -20
  50. package/dist/functions/index.js.map +1 -0
  51. package/dist/index.d.ts +9 -0
  52. package/dist/index.d.ts.map +1 -0
  53. package/dist/{main/lib/index.js → index.js} +25 -24
  54. package/dist/index.js.map +1 -0
  55. package/lib/AccessTokenClient.ts +270 -0
  56. package/lib/AuthorizationDetailsBuilder.ts +46 -0
  57. package/lib/CredentialOffer.ts +55 -0
  58. package/lib/CredentialRequestClient.ts +77 -0
  59. package/lib/CredentialRequestClientBuilderV1_0_09.ts +99 -0
  60. package/lib/MetadataClient.ts +147 -0
  61. package/lib/OpenID4VCIClient.ts +477 -0
  62. package/lib/ProofOfPossessionBuilder.ts +156 -0
  63. package/lib/__tests__/AccessTokenClient.spec.ts +221 -0
  64. package/lib/__tests__/AuthorizationDetailsBuilder.spec.ts +65 -0
  65. package/lib/__tests__/AuthzFlowType.spec.ts +39 -0
  66. package/lib/__tests__/CredentialRequestClient.spec.ts +261 -0
  67. package/lib/__tests__/CredentialRequestClientBuilder.spec.ts +103 -0
  68. package/lib/__tests__/HttpUtils.spec.ts +37 -0
  69. package/lib/__tests__/IT.spec.ts +155 -0
  70. package/lib/__tests__/IssuanceInitiation.spec.ts +37 -0
  71. package/lib/__tests__/JsonURIConversions.spec.ts +86 -0
  72. package/lib/__tests__/MetadataClient.spec.ts +198 -0
  73. package/lib/__tests__/MetadataMocks.ts +428 -0
  74. package/lib/__tests__/OpenID4VCIClient.spec.ts +166 -0
  75. package/lib/__tests__/OpenID4VCIClientPAR.spec.ts +112 -0
  76. package/lib/__tests__/ProofOfPossessionBuilder.spec.ts +109 -0
  77. package/lib/__tests__/data/VciDataFixtures.ts +744 -0
  78. package/lib/functions/Encoding.ts +138 -0
  79. package/lib/functions/HttpUtils.ts +106 -0
  80. package/lib/functions/ProofUtil.ts +128 -0
  81. package/{dist/main/lib/functions/index.d.ts → lib/functions/index.ts} +3 -3
  82. package/lib/index.ts +8 -0
  83. package/package.json +68 -71
  84. package/CHANGELOG.md +0 -21
  85. package/dist/main/index.d.ts +0 -1
  86. package/dist/main/index.js +0 -18
  87. package/dist/main/lib/AccessTokenClient.d.ts +0 -20
  88. package/dist/main/lib/AccessTokenClient.js +0 -141
  89. package/dist/main/lib/CredentialRequestClient.d.ts +0 -31
  90. package/dist/main/lib/CredentialRequestClient.js +0 -66
  91. package/dist/main/lib/CredentialRequestClientBuilder.d.ts +0 -21
  92. package/dist/main/lib/CredentialRequestClientBuilder.js +0 -56
  93. package/dist/main/lib/IssuanceInitiation.d.ts +0 -5
  94. package/dist/main/lib/IssuanceInitiation.js +0 -29
  95. package/dist/main/lib/MetadataClient.js +0 -127
  96. package/dist/main/lib/functions/Encoding.js +0 -138
  97. package/dist/main/lib/functions/HttpUtils.d.ts +0 -17
  98. package/dist/main/lib/functions/HttpUtils.js +0 -133
  99. package/dist/main/lib/functions/ProofUtil.d.ts +0 -9
  100. package/dist/main/lib/functions/ProofUtil.js +0 -76
  101. package/dist/main/lib/index.d.ts +0 -7
  102. package/dist/main/lib/types/Authorization.types.d.ts +0 -66
  103. package/dist/main/lib/types/Authorization.types.js +0 -35
  104. package/dist/main/lib/types/CredentialIssuance.types.d.ts +0 -88
  105. package/dist/main/lib/types/CredentialIssuance.types.js +0 -8
  106. package/dist/main/lib/types/Generic.types.d.ts +0 -19
  107. package/dist/main/lib/types/Generic.types.js +0 -11
  108. package/dist/main/lib/types/OAuth2ASMetadata.d.ts +0 -37
  109. package/dist/main/lib/types/OAuth2ASMetadata.js +0 -3
  110. package/dist/main/lib/types/OID4VCIServerMetadata.d.ts +0 -65
  111. package/dist/main/lib/types/OID4VCIServerMetadata.js +0 -3
  112. package/dist/main/lib/types/Oidc4vciErrors.d.ts +0 -3
  113. package/dist/main/lib/types/Oidc4vciErrors.js +0 -7
  114. package/dist/main/lib/types/index.d.ts +0 -6
  115. package/dist/main/lib/types/index.js +0 -23
  116. package/dist/main/tsconfig.build.tsbuildinfo +0 -1
@@ -0,0 +1,428 @@
1
+ import { CredentialOfferPayloadV1_0_09, CredentialOfferRequestWithBaseUrl, OpenId4VCIVersion } from '@sphereon/oid4vci-common';
2
+
3
+ export const IDENTIPROOF_ISSUER_URL = 'https://issuer.research.identiproof.io';
4
+ export const IDENTIPROOF_AS_URL = 'https://auth.research.identiproof.io';
5
+ export const SPRUCE_ISSUER_URL = 'https://ngi-oidc4vci-test.spruceid.xyz';
6
+ export const DANUBE_ISSUER_URL = 'https://oidc4vc.uniissuer.io';
7
+ export const WALT_ISSUER_URL = 'https://jff.walt.id/issuer-api/oidc';
8
+ export const INITIATION_TEST_HTTPS_URI =
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_URI =
11
+ '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
+
13
+ export const INITIATION_TEST: CredentialOfferRequestWithBaseUrl = {
14
+ baseUrl: 'openid-initiate-issuance://',
15
+ request: {
16
+ credential_type: 'OpenBadgeCredential',
17
+ issuer: 'https://jff.walt.id/issuer-api/oidc/',
18
+ 'pre-authorized_code':
19
+ 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhOTUyZjUxNi1jYWVmLTQ4YjMtODIxYy00OTRkYzgyNjljZjAiLCJwcmUtYXV0aG9yaXplZCI6dHJ1ZX0.YE5DlalcLC2ChGEg47CQDaN1gTxbaQqSclIVqsSAUHE',
20
+ user_pin_required: 'false',
21
+ } as CredentialOfferPayloadV1_0_09,
22
+ version: OpenId4VCIVersion.VER_1_0_09,
23
+ };
24
+ export const IDENTIPROOF_AS_METADATA = {
25
+ issuer: 'https://auth.research.identiproof.io',
26
+ authorization_endpoint: 'https://auth.research.identiproof.io/oauth2/authorize',
27
+ token_endpoint: 'https://auth.research.identiproof.io/oauth2/token',
28
+ token_endpoint_auth_methods_supported: ['client_secret_basic', 'client_secret_post', 'client_secret_jwt', 'private_key_jwt'],
29
+ jwks_uri: 'https://auth.research.identiproof.io/oauth2/jwks',
30
+ response_types_supported: ['code'],
31
+ grant_types_supported: ['authorization_code', 'urn:ietf:params:oauth:grant-type:pre-authorized_code', 'client_credentials', 'refresh_token'],
32
+ revocation_endpoint: 'https://auth.research.identiproof.io/oauth2/revoke',
33
+ revocation_endpoint_auth_methods_supported: ['client_secret_basic', 'client_secret_post', 'client_secret_jwt', 'private_key_jwt'],
34
+ introspection_endpoint: 'https://auth.research.identiproof.io/oauth2/introspect',
35
+ introspection_endpoint_auth_methods_supported: ['client_secret_basic', 'client_secret_post', 'client_secret_jwt', 'private_key_jwt'],
36
+ code_challenge_methods_supported: ['S256'],
37
+ };
38
+
39
+ export const IDENTIPROOF_OID4VCI_METADATA = {
40
+ issuer: 'https://issuer.research.identiproof.io',
41
+ authorization_server: 'https://auth.research.identiproof.io',
42
+ credential_endpoint: 'https://issuer.research.identiproof.io/credential',
43
+ jwks_uri: 'https://issuer.research.identiproof.io/.well-known/did.json',
44
+ credentials_supported: {
45
+ 'Cyber Security Certificate': {
46
+ formats: {
47
+ jwt_vc: {
48
+ types: ['VerifiableCredential', 'Cyber Security Certificate'],
49
+ cryptographic_binding_methods_supported: ['did'],
50
+ cryptographic_suites_supported: ['ES256'],
51
+ },
52
+ },
53
+ },
54
+ OpenBadgeCredential: {
55
+ formats: {
56
+ jwt_vc: {
57
+ types: ['VerifiableCredential', 'OpenBadgeCredential'],
58
+ cryptographic_binding_methods_supported: ['did'],
59
+ cryptographic_suites_supported: ['ES256'],
60
+ },
61
+ },
62
+ },
63
+ OpenBadgeExtendedCredential: {
64
+ formats: {
65
+ jwt_vc: {
66
+ types: ['VerifiableCredential', 'OpenBadgeExtendedCredential'],
67
+ cryptographic_binding_methods_supported: ['did'],
68
+ cryptographic_suites_supported: ['ES256'],
69
+ },
70
+ },
71
+ },
72
+ },
73
+ };
74
+
75
+ export const SPRUCE_OID4VCI_METADATA = {
76
+ issuer: 'https://ngi-oidc4vci-test.spruceid.xyz',
77
+ credential_endpoint: 'https://ngi-oidc4vci-test.spruceid.xyz/credential',
78
+ token_endpoint: 'https://ngi-oidc4vci-test.spruceid.xyz/token',
79
+ jwks_uri: 'https://ngi-oidc4vci-test.spruceid.xyz/jwks',
80
+ grant_types_supported: ['urn:ietf:params:oauth:grant-type:pre-authorized_code'],
81
+ credentials_supported: {
82
+ OpenBadgeCredential: {
83
+ formats: {
84
+ jwt_vc: {
85
+ types: ['VerifiableCredential', 'OpenBadgeCredential'],
86
+ cryptographic_binding_methods_supported: ['did'],
87
+ cryptographic_suites_supported: ['ES256', 'ES256K'],
88
+ },
89
+ ldp_vc: {
90
+ types: ['VerifiableCredential', 'OpenBadgeCredential'],
91
+ cryptographic_binding_methods_supported: ['did'],
92
+ cryptographic_suites_supported: ['Ed25519Signature2018'],
93
+ },
94
+ },
95
+ },
96
+ },
97
+ };
98
+
99
+ export const DANUBE_OIDC_METADATA = {
100
+ response_types_supported: ['code', 'token'],
101
+ credentials_supported: {
102
+ OpenBadgeCredential: {
103
+ display: [
104
+ {
105
+ name: 'Open Badge V3',
106
+ locale: 'en-US',
107
+ logo: { url: 'https://uniissuer.io/images/logo.jpg' },
108
+ },
109
+ ],
110
+ formats: {
111
+ ldp_vc: {
112
+ types: ['VerifiableCredential', 'OpenBadgeCredential'],
113
+ cryptographic_binding_methods_supported: ['did'],
114
+ cryptographic_suites_supported: ['Ed25519Signature2018', 'Ed25519Signature2020', 'EcdsaSecp256k1Signature2019', 'JsonWebSignature2020'],
115
+ },
116
+ jwt_vc: {
117
+ types: ['VerifiableCredential', 'OpenBadgeCredential'],
118
+ cryptographic_binding_methods_supported: ['did'],
119
+ cryptographic_suites_supported: ['Ed25519Signature2018', 'Ed25519Signature2020', 'EcdsaSecp256k1Signature2019', 'JsonWebSignature2020'],
120
+ },
121
+ },
122
+ claims: { achievement: { mandatory: true, value_type: 'object' } },
123
+ },
124
+ VaccinationCertificate: {
125
+ formats: {
126
+ jwt_vc: {
127
+ types: ['VerifiableCredential', 'VaccinationCertificate'],
128
+ cryptographic_binding_methods_supported: ['did'],
129
+ cryptographic_suites_supported: ['Ed25519Signature2018', 'Ed25519Signature2020', 'EcdsaSecp256k1Signature2019', 'JsonWebSignature2020'],
130
+ },
131
+ },
132
+ },
133
+ },
134
+ credential_issuer: {
135
+ display: [
136
+ {
137
+ name: 'Danube Tech',
138
+ locale: 'en-US',
139
+ logo: { url: 'https://uniissuer.io/images/logo.jpg' },
140
+ },
141
+ ],
142
+ },
143
+ code_challenge_methods_supported: ['plain', 'S256'],
144
+ grant_types_supported: ['authorization_code', 'urn:ietf:params:oauth:grant-type:pre-authorized_code'],
145
+ token_endpoint_auth_methods_supported: ['client_secret_post', 'client_secret_basic'],
146
+ authorization_endpoint: 'https://oidc4vc.uniissuer.io/authorize',
147
+ token_endpoint: 'https://oidc4vc.uniissuer.io/token',
148
+ credential_endpoint: 'https://oidc4vc.uniissuer.io/credential',
149
+ };
150
+
151
+ export const WALT_OID4VCI_METADATA = {
152
+ authorization_endpoint: 'https://jff.walt.id/issuer-api/oidc/fulfillPAR',
153
+ token_endpoint: 'https://jff.walt.id/issuer-api/oidc/token',
154
+ pushed_authorization_request_endpoint: 'https://jff.walt.id/issuer-api/oidc/par',
155
+ issuer: 'https://jff.walt.id/issuer-api',
156
+ jwks_uri: 'https://jff.walt.id/issuer-api/oidc',
157
+ grant_types_supported: ['authorization_code', 'urn:ietf:params:oauth:grant-type:pre-authorized_code'],
158
+ request_uri_parameter_supported: true,
159
+ credentials_supported: {
160
+ VerifiableDiploma: {
161
+ display: [{ name: 'VerifiableDiploma' }],
162
+ formats: {
163
+ ldp_vc: {
164
+ cryptographic_binding_methods_supported: ['did'],
165
+ cryptographic_suites_supported: [
166
+ 'Ed25519Signature2018',
167
+ 'Ed25519Signature2020',
168
+ 'EcdsaSecp256k1Signature2019',
169
+ 'RsaSignature2018',
170
+ 'JsonWebSignature2020',
171
+ 'JcsEd25519Signature2020',
172
+ ],
173
+ types: ['VerifiableCredential', 'VerifiableAttestation', 'VerifiableDiploma'],
174
+ },
175
+ jwt_vc: {
176
+ cryptographic_binding_methods_supported: ['did'],
177
+ cryptographic_suites_supported: ['ES256', 'ES256K', 'EdDSA', 'RS256', 'PS256'],
178
+ types: ['VerifiableCredential', 'VerifiableAttestation', 'VerifiableDiploma'],
179
+ },
180
+ },
181
+ },
182
+ VerifiableVaccinationCertificate: {
183
+ display: [{ name: 'VerifiableVaccinationCertificate' }],
184
+ formats: {
185
+ ldp_vc: {
186
+ cryptographic_binding_methods_supported: ['did'],
187
+ cryptographic_suites_supported: [
188
+ 'Ed25519Signature2018',
189
+ 'Ed25519Signature2020',
190
+ 'EcdsaSecp256k1Signature2019',
191
+ 'RsaSignature2018',
192
+ 'JsonWebSignature2020',
193
+ 'JcsEd25519Signature2020',
194
+ ],
195
+ types: ['VerifiableCredential', 'VerifiableAttestation', 'VerifiableVaccinationCertificate'],
196
+ },
197
+ jwt_vc: {
198
+ cryptographic_binding_methods_supported: ['did'],
199
+ cryptographic_suites_supported: ['ES256', 'ES256K', 'EdDSA', 'RS256', 'PS256'],
200
+ types: ['VerifiableCredential', 'VerifiableAttestation', 'VerifiableVaccinationCertificate'],
201
+ },
202
+ },
203
+ },
204
+ Europass: {
205
+ display: [{ name: 'Europass' }],
206
+ formats: {
207
+ ldp_vc: {
208
+ cryptographic_binding_methods_supported: ['did'],
209
+ cryptographic_suites_supported: [
210
+ 'Ed25519Signature2018',
211
+ 'Ed25519Signature2020',
212
+ 'EcdsaSecp256k1Signature2019',
213
+ 'RsaSignature2018',
214
+ 'JsonWebSignature2020',
215
+ 'JcsEd25519Signature2020',
216
+ ],
217
+ types: ['VerifiableCredential', 'VerifiableAttestation', 'Europass'],
218
+ },
219
+ jwt_vc: {
220
+ cryptographic_binding_methods_supported: ['did'],
221
+ cryptographic_suites_supported: ['ES256', 'ES256K', 'EdDSA', 'RS256', 'PS256'],
222
+ types: ['VerifiableCredential', 'VerifiableAttestation', 'Europass'],
223
+ },
224
+ },
225
+ },
226
+ VerifiableMandate: {
227
+ display: [{ name: 'VerifiableMandate' }],
228
+ formats: {
229
+ ldp_vc: {
230
+ cryptographic_binding_methods_supported: ['did'],
231
+ cryptographic_suites_supported: [
232
+ 'Ed25519Signature2018',
233
+ 'Ed25519Signature2020',
234
+ 'EcdsaSecp256k1Signature2019',
235
+ 'RsaSignature2018',
236
+ 'JsonWebSignature2020',
237
+ 'JcsEd25519Signature2020',
238
+ ],
239
+ types: ['VerifiableCredential', 'VerifiableMandate'],
240
+ },
241
+ jwt_vc: {
242
+ cryptographic_binding_methods_supported: ['did'],
243
+ cryptographic_suites_supported: ['ES256', 'ES256K', 'EdDSA', 'RS256', 'PS256'],
244
+ types: ['VerifiableCredential', 'VerifiableMandate'],
245
+ },
246
+ },
247
+ },
248
+ EuropeanBankIdentity: {
249
+ display: [{ name: 'EuropeanBankIdentity' }],
250
+ formats: {
251
+ ldp_vc: {
252
+ cryptographic_binding_methods_supported: ['did'],
253
+ cryptographic_suites_supported: [
254
+ 'Ed25519Signature2018',
255
+ 'Ed25519Signature2020',
256
+ 'EcdsaSecp256k1Signature2019',
257
+ 'RsaSignature2018',
258
+ 'JsonWebSignature2020',
259
+ 'JcsEd25519Signature2020',
260
+ ],
261
+ types: ['VerifiableCredential', 'EuropeanBankIdentity'],
262
+ },
263
+ jwt_vc: {
264
+ cryptographic_binding_methods_supported: ['did'],
265
+ cryptographic_suites_supported: ['ES256', 'ES256K', 'EdDSA', 'RS256', 'PS256'],
266
+ types: ['VerifiableCredential', 'EuropeanBankIdentity'],
267
+ },
268
+ },
269
+ },
270
+ VerifiableAttestation: {
271
+ display: [{ name: 'VerifiableAttestation' }],
272
+ formats: {
273
+ ldp_vc: {
274
+ cryptographic_binding_methods_supported: ['did'],
275
+ cryptographic_suites_supported: [
276
+ 'Ed25519Signature2018',
277
+ 'Ed25519Signature2020',
278
+ 'EcdsaSecp256k1Signature2019',
279
+ 'RsaSignature2018',
280
+ 'JsonWebSignature2020',
281
+ 'JcsEd25519Signature2020',
282
+ ],
283
+ types: ['VerifiableCredential', 'VerifiableAttestation'],
284
+ },
285
+ jwt_vc: {
286
+ cryptographic_binding_methods_supported: ['did'],
287
+ cryptographic_suites_supported: ['ES256', 'ES256K', 'EdDSA', 'RS256', 'PS256'],
288
+ types: ['VerifiableCredential', 'VerifiableAttestation'],
289
+ },
290
+ },
291
+ },
292
+ OpenBadgeCredential: {
293
+ display: [{ name: 'OpenBadgeCredential' }],
294
+ formats: {
295
+ ldp_vc: {
296
+ cryptographic_binding_methods_supported: ['did'],
297
+ cryptographic_suites_supported: [
298
+ 'Ed25519Signature2018',
299
+ 'Ed25519Signature2020',
300
+ 'EcdsaSecp256k1Signature2019',
301
+ 'RsaSignature2018',
302
+ 'JsonWebSignature2020',
303
+ 'JcsEd25519Signature2020',
304
+ ],
305
+ types: ['VerifiableCredential', 'OpenBadgeCredential'],
306
+ },
307
+ jwt_vc: {
308
+ cryptographic_binding_methods_supported: ['did'],
309
+ cryptographic_suites_supported: ['ES256', 'ES256K', 'EdDSA', 'RS256', 'PS256'],
310
+ types: ['VerifiableCredential', 'OpenBadgeCredential'],
311
+ },
312
+ },
313
+ },
314
+ PeerReview: {
315
+ display: [{ name: 'PeerReview' }],
316
+ formats: {
317
+ ldp_vc: {
318
+ cryptographic_binding_methods_supported: ['did'],
319
+ cryptographic_suites_supported: [
320
+ 'Ed25519Signature2018',
321
+ 'Ed25519Signature2020',
322
+ 'EcdsaSecp256k1Signature2019',
323
+ 'RsaSignature2018',
324
+ 'JsonWebSignature2020',
325
+ 'JcsEd25519Signature2020',
326
+ ],
327
+ types: ['VerifiableCredential', 'PeerReview'],
328
+ },
329
+ jwt_vc: {
330
+ cryptographic_binding_methods_supported: ['did'],
331
+ cryptographic_suites_supported: ['ES256', 'ES256K', 'EdDSA', 'RS256', 'PS256'],
332
+ types: ['VerifiableCredential', 'PeerReview'],
333
+ },
334
+ },
335
+ },
336
+ ProofOfResidence: {
337
+ display: [{ name: 'ProofOfResidence' }],
338
+ formats: {
339
+ ldp_vc: {
340
+ cryptographic_binding_methods_supported: ['did'],
341
+ cryptographic_suites_supported: [
342
+ 'Ed25519Signature2018',
343
+ 'Ed25519Signature2020',
344
+ 'EcdsaSecp256k1Signature2019',
345
+ 'RsaSignature2018',
346
+ 'JsonWebSignature2020',
347
+ 'JcsEd25519Signature2020',
348
+ ],
349
+ types: ['VerifiableCredential', 'VerifiableAttestation', 'ProofOfResidence'],
350
+ },
351
+ jwt_vc: {
352
+ cryptographic_binding_methods_supported: ['did'],
353
+ cryptographic_suites_supported: ['ES256', 'ES256K', 'EdDSA', 'RS256', 'PS256'],
354
+ types: ['VerifiableCredential', 'VerifiableAttestation', 'ProofOfResidence'],
355
+ },
356
+ },
357
+ },
358
+ AmletCredential: {
359
+ display: [{ name: 'AmletCredential' }],
360
+ formats: {
361
+ ldp_vc: {
362
+ cryptographic_binding_methods_supported: ['did'],
363
+ cryptographic_suites_supported: [
364
+ 'Ed25519Signature2018',
365
+ 'Ed25519Signature2020',
366
+ 'EcdsaSecp256k1Signature2019',
367
+ 'RsaSignature2018',
368
+ 'JsonWebSignature2020',
369
+ 'JcsEd25519Signature2020',
370
+ ],
371
+ types: ['VerifiableCredential', 'AmletCredential'],
372
+ },
373
+ jwt_vc: {
374
+ cryptographic_binding_methods_supported: ['did'],
375
+ cryptographic_suites_supported: ['ES256', 'ES256K', 'EdDSA', 'RS256', 'PS256'],
376
+ types: ['VerifiableCredential', 'AmletCredential'],
377
+ },
378
+ },
379
+ },
380
+ ParticipantCredential: {
381
+ display: [{ name: 'ParticipantCredential' }],
382
+ formats: {
383
+ ldp_vc: {
384
+ cryptographic_binding_methods_supported: ['did'],
385
+ cryptographic_suites_supported: [
386
+ 'Ed25519Signature2018',
387
+ 'Ed25519Signature2020',
388
+ 'EcdsaSecp256k1Signature2019',
389
+ 'RsaSignature2018',
390
+ 'JsonWebSignature2020',
391
+ 'JcsEd25519Signature2020',
392
+ ],
393
+ types: ['VerifiableCredential', 'ParticipantCredential'],
394
+ },
395
+ jwt_vc: {
396
+ cryptographic_binding_methods_supported: ['did'],
397
+ cryptographic_suites_supported: ['ES256', 'ES256K', 'EdDSA', 'RS256', 'PS256'],
398
+ types: ['VerifiableCredential', 'ParticipantCredential'],
399
+ },
400
+ },
401
+ },
402
+ VerifiableId: {
403
+ display: [{ name: 'VerifiableId' }],
404
+ formats: {
405
+ ldp_vc: {
406
+ cryptographic_binding_methods_supported: ['did'],
407
+ cryptographic_suites_supported: [
408
+ 'Ed25519Signature2018',
409
+ 'Ed25519Signature2020',
410
+ 'EcdsaSecp256k1Signature2019',
411
+ 'RsaSignature2018',
412
+ 'JsonWebSignature2020',
413
+ 'JcsEd25519Signature2020',
414
+ ],
415
+ types: ['VerifiableCredential', 'VerifiableAttestation', 'VerifiableId'],
416
+ },
417
+ jwt_vc: {
418
+ cryptographic_binding_methods_supported: ['did'],
419
+ cryptographic_suites_supported: ['ES256', 'ES256K', 'EdDSA', 'RS256', 'PS256'],
420
+ types: ['VerifiableCredential', 'VerifiableAttestation', 'VerifiableId'],
421
+ },
422
+ },
423
+ },
424
+ },
425
+ credential_issuer: { display: [{ locale: null, name: 'https://jff.walt.id/issuer-api' }] },
426
+ credential_endpoint: 'https://jff.walt.id/issuer-api/oidc/credential',
427
+ subject_types_supported: ['public'],
428
+ };
@@ -0,0 +1,166 @@
1
+ import { AuthzFlowType, CodeChallengeMethod } 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 { OpenID4VCIClient } from '../OpenID4VCIClient';
7
+
8
+ const MOCK_URL = 'https://server.example.com/';
9
+
10
+ describe('OpenID4VCIClient should', () => {
11
+ let client: OpenID4VCIClient;
12
+
13
+ beforeEach(async () => {
14
+ nock(MOCK_URL).get(/.*/).reply(200, {});
15
+ client = await OpenID4VCIClient.fromURI({
16
+ uri: 'openid-initiate-issuance://?issuer=https://server.example.com&credential_type=TestCredential',
17
+ flowType: AuthzFlowType.AUTHORIZATION_CODE_FLOW,
18
+ });
19
+ });
20
+
21
+ afterEach(() => {
22
+ nock.cleanAll();
23
+ });
24
+
25
+ it('should create successfully construct an authorization request url', async () => {
26
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
27
+ // @ts-ignore
28
+ client._endpointMetadata?.issuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
29
+ const url = client.createAuthorizationRequestUrl({
30
+ clientId: 'test-client',
31
+ codeChallengeMethod: CodeChallengeMethod.SHA256,
32
+ codeChallenge: 'mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs',
33
+ scope: 'openid TestCredential',
34
+ redirectUri: 'http://localhost:8881/cb',
35
+ });
36
+
37
+ const urlSearchParams = new URLSearchParams(url.split('?')[1]);
38
+ const scope = urlSearchParams.get('scope')?.split(' ');
39
+
40
+ expect(scope?.[0]).toBe('openid');
41
+ });
42
+ it('throw an error if authorization endpoint is not set in server metadata', async () => {
43
+ expect(() => {
44
+ client.createAuthorizationRequestUrl({
45
+ clientId: 'test-client',
46
+ codeChallengeMethod: CodeChallengeMethod.SHA256,
47
+ codeChallenge: 'mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs',
48
+ scope: 'openid TestCredential',
49
+ redirectUri: 'http://localhost:8881/cb',
50
+ });
51
+ }).toThrow(Error('Server metadata does not contain authorization endpoint'));
52
+ });
53
+ it("injects 'openid' as the first scope if not provided", async () => {
54
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
55
+ // @ts-ignore
56
+ client._endpointMetadata?.issuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
57
+
58
+ const url = client.createAuthorizationRequestUrl({
59
+ clientId: 'test-client',
60
+ codeChallengeMethod: CodeChallengeMethod.SHA256,
61
+ codeChallenge: 'mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs',
62
+ scope: 'TestCredential',
63
+ redirectUri: 'http://localhost:8881/cb',
64
+ });
65
+
66
+ const urlSearchParams = new URLSearchParams(url.split('?')[1]);
67
+ const scope = urlSearchParams.get('scope')?.split(' ');
68
+
69
+ expect(scope?.[0]).toBe('openid');
70
+ });
71
+ it('throw an error if no scope and no authorization_details is provided', async () => {
72
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
73
+ // @ts-ignore
74
+ client._endpointMetadata?.issuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
75
+
76
+ expect(() => {
77
+ client.createAuthorizationRequestUrl({
78
+ clientId: 'test-client',
79
+ codeChallengeMethod: CodeChallengeMethod.SHA256,
80
+ codeChallenge: 'mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs',
81
+ redirectUri: 'http://localhost:8881/cb',
82
+ });
83
+ }).toThrow(Error('Please provide a scope or authorization_details'));
84
+ });
85
+ it('create an authorization request url with authorization_details array property', async () => {
86
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
87
+ // @ts-ignore
88
+ client._endpointMetadata.issuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
89
+
90
+ expect(
91
+ client.createAuthorizationRequestUrl({
92
+ clientId: 'test-client',
93
+ codeChallengeMethod: CodeChallengeMethod.SHA256,
94
+ codeChallenge: 'mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs',
95
+ authorizationDetails: [
96
+ {
97
+ type: 'openid_credential',
98
+ format: 'ldp_vc',
99
+ credential_definition: {
100
+ '@context': ['https://www.w3.org/2018/credentials/v1', 'https://www.w3.org/2018/credentials/examples/v1'],
101
+ types: ['VerifiableCredential', 'UniversityDegreeCredential'],
102
+ },
103
+ },
104
+ {
105
+ type: 'openid_credential',
106
+ format: 'mso_mdoc',
107
+ doctype: 'org.iso.18013.5.1.mDL',
108
+ },
109
+ ],
110
+ redirectUri: 'http://localhost:8881/cb',
111
+ })
112
+ ).toEqual(
113
+ 'https://server.example.com/v1/auth/authorize?response_type=code&client_id=test-client&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%22https%3A%2F%2Fserver%2Eexample%2Ecom%22%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%22https%3A%2F%2Fserver%2Eexample%2Ecom%22%7D%5D&redirect_uri=http%3A%2F%2Flocalhost%3A8881%2Fcb'
114
+ );
115
+ });
116
+ it('create an authorization request url with authorization_details object property', async () => {
117
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
118
+ // @ts-ignore
119
+ client._endpointMetadata.issuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
120
+
121
+ expect(
122
+ client.createAuthorizationRequestUrl({
123
+ clientId: 'test-client',
124
+ codeChallengeMethod: CodeChallengeMethod.SHA256,
125
+ codeChallenge: 'mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs',
126
+ authorizationDetails: {
127
+ type: 'openid_credential',
128
+ format: 'ldp_vc',
129
+ credential_definition: {
130
+ '@context': ['https://www.w3.org/2018/credentials/v1', 'https://www.w3.org/2018/credentials/examples/v1'],
131
+ types: ['VerifiableCredential', 'UniversityDegreeCredential'],
132
+ },
133
+ },
134
+ redirectUri: 'http://localhost:8881/cb',
135
+ })
136
+ ).toEqual(
137
+ 'https://server.example.com/v1/auth/authorize?response_type=code&client_id=test-client&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%22https%3A%2F%2Fserver%2Eexample%2Ecom%22%7D&redirect_uri=http%3A%2F%2Flocalhost%3A8881%2Fcb'
138
+ );
139
+ });
140
+ it('create an authorization request url with authorization_details and scope', async () => {
141
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
142
+ // @ts-ignore
143
+ client._endpointMetadata.issuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
144
+
145
+ expect(
146
+ client.createAuthorizationRequestUrl({
147
+ clientId: 'test-client',
148
+ codeChallengeMethod: CodeChallengeMethod.SHA256,
149
+ codeChallenge: 'mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs',
150
+ authorizationDetails: {
151
+ type: 'openid_credential',
152
+ format: 'ldp_vc',
153
+ locations: ['https://test.com'],
154
+ credential_definition: {
155
+ '@context': ['https://www.w3.org/2018/credentials/v1', 'https://www.w3.org/2018/credentials/examples/v1'],
156
+ types: ['VerifiableCredential', 'UniversityDegreeCredential'],
157
+ },
158
+ },
159
+ scope: 'openid',
160
+ redirectUri: 'http://localhost:8881/cb',
161
+ })
162
+ ).toEqual(
163
+ 'https://server.example.com/v1/auth/authorize?response_type=code&client_id=test-client&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&scope=openid'
164
+ );
165
+ });
166
+ });