@sphereon/oid4vci-common 0.8.2-next.6 → 0.8.2-next.87

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 (104) hide show
  1. package/dist/functions/AuthorizationResponseUtil.d.ts +3 -0
  2. package/dist/functions/AuthorizationResponseUtil.d.ts.map +1 -0
  3. package/dist/functions/AuthorizationResponseUtil.js +21 -0
  4. package/dist/functions/AuthorizationResponseUtil.js.map +1 -0
  5. package/dist/functions/CredentialOfferUtil.d.ts +5 -0
  6. package/dist/functions/CredentialOfferUtil.d.ts.map +1 -1
  7. package/dist/functions/CredentialOfferUtil.js +92 -2
  8. package/dist/functions/CredentialOfferUtil.js.map +1 -1
  9. package/dist/functions/CredentialRequestUtil.d.ts +3 -2
  10. package/dist/functions/CredentialRequestUtil.d.ts.map +1 -1
  11. package/dist/functions/CredentialRequestUtil.js +41 -2
  12. package/dist/functions/CredentialRequestUtil.js.map +1 -1
  13. package/dist/functions/CredentialResponseUtil.d.ts +11 -0
  14. package/dist/functions/CredentialResponseUtil.d.ts.map +1 -0
  15. package/dist/functions/CredentialResponseUtil.js +80 -0
  16. package/dist/functions/CredentialResponseUtil.js.map +1 -0
  17. package/dist/functions/Encoding.js +1 -1
  18. package/dist/functions/Encoding.js.map +1 -1
  19. package/dist/functions/FormatUtils.d.ts +15 -0
  20. package/dist/functions/FormatUtils.d.ts.map +1 -0
  21. package/dist/functions/FormatUtils.js +44 -0
  22. package/dist/functions/FormatUtils.js.map +1 -0
  23. package/dist/functions/HttpUtils.d.ts +3 -3
  24. package/dist/functions/HttpUtils.d.ts.map +1 -1
  25. package/dist/functions/HttpUtils.js +2 -2
  26. package/dist/functions/HttpUtils.js.map +1 -1
  27. package/dist/functions/IssuerMetadataUtils.d.ts +8 -1
  28. package/dist/functions/IssuerMetadataUtils.d.ts.map +1 -1
  29. package/dist/functions/IssuerMetadataUtils.js +42 -7
  30. package/dist/functions/IssuerMetadataUtils.js.map +1 -1
  31. package/dist/functions/RandomUtils.d.ts +10 -0
  32. package/dist/functions/RandomUtils.d.ts.map +1 -0
  33. package/dist/functions/RandomUtils.js +73 -0
  34. package/dist/functions/RandomUtils.js.map +1 -0
  35. package/dist/functions/index.d.ts +8 -0
  36. package/dist/functions/index.d.ts.map +1 -1
  37. package/dist/functions/index.js +9 -0
  38. package/dist/functions/index.js.map +1 -1
  39. package/dist/functions/randomBytes.d.ts +7 -0
  40. package/dist/functions/randomBytes.d.ts.map +1 -0
  41. package/dist/functions/randomBytes.js +56 -0
  42. package/dist/functions/randomBytes.js.map +1 -0
  43. package/dist/types/Authorization.types.d.ts +64 -15
  44. package/dist/types/Authorization.types.d.ts.map +1 -1
  45. package/dist/types/Authorization.types.js +30 -9
  46. package/dist/types/Authorization.types.js.map +1 -1
  47. package/dist/types/CredentialIssuance.types.d.ts +5 -1
  48. package/dist/types/CredentialIssuance.types.d.ts.map +1 -1
  49. package/dist/types/CredentialIssuance.types.js +2 -2
  50. package/dist/types/CredentialIssuance.types.js.map +1 -1
  51. package/dist/types/Generic.types.d.ts +63 -18
  52. package/dist/types/Generic.types.d.ts.map +1 -1
  53. package/dist/types/Generic.types.js.map +1 -1
  54. package/dist/types/OpenID4VCIVersions.types.d.ts +1 -0
  55. package/dist/types/OpenID4VCIVersions.types.d.ts.map +1 -1
  56. package/dist/types/OpenID4VCIVersions.types.js +4 -3
  57. package/dist/types/OpenID4VCIVersions.types.js.map +1 -1
  58. package/dist/types/QRCode.types.js +0 -2
  59. package/dist/types/QRCode.types.js.map +1 -1
  60. package/dist/types/ServerMetadata.d.ts +2 -0
  61. package/dist/types/ServerMetadata.d.ts.map +1 -1
  62. package/dist/types/ServerMetadata.js +1 -1
  63. package/dist/types/ServerMetadata.js.map +1 -1
  64. package/dist/types/StateManager.types.d.ts +4 -4
  65. package/dist/types/StateManager.types.d.ts.map +1 -1
  66. package/dist/types/StateManager.types.js +1 -1
  67. package/dist/types/StateManager.types.js.map +1 -1
  68. package/dist/types/Token.types.d.ts +1 -1
  69. package/dist/types/Token.types.d.ts.map +1 -1
  70. package/dist/types/Token.types.js +1 -1
  71. package/dist/types/Token.types.js.map +1 -1
  72. package/dist/types/v1_0_08.types.d.ts +6 -2
  73. package/dist/types/v1_0_08.types.d.ts.map +1 -1
  74. package/dist/types/v1_0_11.types.d.ts +13 -13
  75. package/dist/types/v1_0_11.types.d.ts.map +1 -1
  76. package/dist/types/v1_0_11.types.js.map +1 -1
  77. package/dist/types/v1_0_12.types.d.ts +3 -0
  78. package/dist/types/v1_0_12.types.d.ts.map +1 -0
  79. package/dist/types/v1_0_12.types.js +3 -0
  80. package/dist/types/v1_0_12.types.js.map +1 -0
  81. package/lib/__tests__/CredentialOfferUtil.spec.ts +51 -2
  82. package/lib/__tests__/Encoding.spec.ts +15 -0
  83. package/lib/__tests__/randomBytes.spec.ts +15 -0
  84. package/lib/functions/AuthorizationResponseUtil.ts +18 -0
  85. package/lib/functions/CredentialOfferUtil.ts +89 -1
  86. package/lib/functions/CredentialRequestUtil.ts +46 -3
  87. package/lib/functions/CredentialResponseUtil.ts +90 -0
  88. package/lib/functions/Encoding.ts +1 -1
  89. package/lib/functions/FormatUtils.ts +52 -0
  90. package/lib/functions/HttpUtils.ts +6 -6
  91. package/lib/functions/IssuerMetadataUtils.ts +45 -4
  92. package/lib/functions/RandomUtils.ts +43 -0
  93. package/lib/functions/index.ts +8 -0
  94. package/lib/functions/randomBytes.js +61 -0
  95. package/lib/types/Authorization.types.ts +100 -11
  96. package/lib/types/CredentialIssuance.types.ts +9 -2
  97. package/lib/types/Generic.types.ts +89 -16
  98. package/lib/types/OpenID4VCIVersions.types.ts +2 -1
  99. package/lib/types/QRCode.types.ts +2 -2
  100. package/lib/types/ServerMetadata.ts +2 -0
  101. package/lib/types/v1_0_08.types.ts +7 -2
  102. package/lib/types/v1_0_11.types.ts +19 -16
  103. package/lib/types/v1_0_12.types.ts +4 -0
  104. package/package.json +17 -6
@@ -0,0 +1,61 @@
1
+ 'use strict';
2
+
3
+ // limit of Crypto.getRandomValues()
4
+ // https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues
5
+ const MAX_BYTES = 65536;
6
+
7
+ // Node supports requesting up to this number of bytes
8
+ // https://github.com/nodejs/node/blob/master/lib/internal/crypto/random.js#L48
9
+ const MAX_UINT32 = 4294967295;
10
+
11
+ function oldBrowser() {
12
+ throw new Error('Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11');
13
+ }
14
+
15
+ // eslint-disable-next-line no-undef
16
+ const _global = typeof globalThis !== 'undefined' ? globalThis : global;
17
+
18
+ let crypto = _global.crypto || _global.msCrypto;
19
+ if (!crypto) {
20
+ try {
21
+ // eslint-disable-next-line no-undef
22
+ crypto = require('crypto');
23
+ } catch (err) {
24
+ throw Error('crypto module is not available');
25
+ }
26
+ }
27
+
28
+ if (crypto && crypto.getRandomValues) {
29
+ // eslint-disable-next-line no-undef
30
+ module.exports = randomBytes;
31
+ } else {
32
+ // eslint-disable-next-line no-undef
33
+ module.exports = oldBrowser;
34
+ }
35
+
36
+ function randomBytes(size) {
37
+ // phantomjs needs to throw
38
+ if (size > MAX_UINT32) throw new Error('requested too many random bytes');
39
+
40
+ // eslint-disable-next-line no-undef
41
+ const bytes = Buffer.allocUnsafe(size);
42
+
43
+ if (size > 0) {
44
+ // getRandomValues fails on IE if size == 0
45
+ if (size > MAX_BYTES) {
46
+ // this is the max bytes crypto.getRandomValues
47
+ // can do at once see https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues
48
+ for (let generated = 0; generated < size; generated += MAX_BYTES) {
49
+ // buffer.slice automatically checks if the end is past the end of
50
+ // the buffer so we don't have to here
51
+ crypto.getRandomValues(bytes.slice(generated, generated + MAX_BYTES));
52
+ }
53
+ } else {
54
+ crypto.getRandomValues(bytes);
55
+ }
56
+ }
57
+ return Uint8Array.from(bytes);
58
+ }
59
+
60
+ // eslint-disable-next-line no-undef
61
+ module.exports = { randomBytes };
@@ -1,5 +1,11 @@
1
1
  import { CredentialOfferPayload, UniformCredentialOffer } from './CredentialIssuance.types';
2
- import { ErrorResponse, IssuerCredentialDefinition, IssuerCredentialSubject, OID4VCICredentialFormat, PRE_AUTH_CODE_LITERAL } from './Generic.types';
2
+ import {
3
+ ErrorResponse,
4
+ IssuerCredentialSubject,
5
+ JsonLdIssuerCredentialDefinition,
6
+ OID4VCICredentialFormat,
7
+ PRE_AUTH_CODE_LITERAL,
8
+ } from './Generic.types';
3
9
  import { EndpointMetadata } from './ServerMetadata';
4
10
 
5
11
  export interface CommonAuthorizationRequest {
@@ -64,9 +70,11 @@ export interface CommonAuthorizationRequest {
64
70
  /**
65
71
  * string type added for conformity with our previous code in the client
66
72
  */
67
- export type AuthorizationDetails = AuthorizationDetailsJwtVcJson | AuthorizationRequestJwtVcJsonLdAndLdpVc | string;
73
+ export type AuthorizationDetails =
74
+ | (CommonAuthorizationDetails & (AuthorizationDetailsJwtVcJson | AuthorizationDetailsJwtVcJsonLdAndLdpVc | AuthorizationDetailsSdJwtVc))
75
+ | string;
68
76
 
69
- export type AuthorizationRequest = AuthorizationRequestJwtVcJson | AuthorizationDetailsJwtVcJsonLdAndLdpVc;
77
+ export type AuthorizationRequest = AuthorizationRequestJwtVcJson | AuthorizationRequestJwtVcJsonLdAndLdpVc | AuthorizationRequestSdJwtVc;
70
78
 
71
79
  export interface AuthorizationRequestJwtVcJson extends CommonAuthorizationRequest {
72
80
  authorization_details?: AuthorizationDetailsJwtVcJson[];
@@ -76,6 +84,20 @@ export interface AuthorizationRequestJwtVcJsonLdAndLdpVc extends CommonAuthoriza
76
84
  authorization_details?: AuthorizationDetailsJwtVcJsonLdAndLdpVc[];
77
85
  }
78
86
 
87
+ export interface AuthorizationRequestSdJwtVc extends CommonAuthorizationRequest {
88
+ authorization_details?: AuthorizationDetailsSdJwtVc[];
89
+ }
90
+
91
+ /*
92
+ export interface AuthDetails {
93
+ type: 'openid_credential' | string;
94
+ locations?: string | string[];
95
+ format: CredentialFormat | CredentialFormat[];
96
+
97
+ [s: string]: unknown;
98
+ }
99
+ */
100
+
79
101
  export interface CommonAuthorizationDetails {
80
102
  /**
81
103
  * REQUIRED. JSON string that determines the authorization details type.
@@ -94,12 +116,14 @@ export interface CommonAuthorizationDetails {
94
116
  * the authorization detail's locations common data field MUST be set to the Credential Issuer Identifier value.
95
117
  */
96
118
  locations?: string[];
97
- types: string[]; // This claim contains the type values the Wallet requests authorization for at the issuer.
119
+
98
120
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
99
121
  [key: string]: any;
100
122
  }
101
123
 
102
124
  export interface AuthorizationDetailsJwtVcJson extends CommonAuthorizationDetails {
125
+ format: 'jwt_vc_json' | 'jwt_vc'; // jwt_vc added for backward compat
126
+
103
127
  /**
104
128
  * A JSON object containing a list of key value pairs, where the key identifies the claim offered in the Credential.
105
129
  * The value MAY be a dictionary, which allows to represent the full (potentially deeply nested) structure of the
@@ -107,9 +131,13 @@ export interface AuthorizationDetailsJwtVcJson extends CommonAuthorizationDetail
107
131
  * credential to be issued.
108
132
  */
109
133
  credentialSubject?: IssuerCredentialSubject;
134
+
135
+ types: string[]; // This claim contains the type values the Wallet requests authorization for at the issuer.
110
136
  }
111
137
 
112
138
  export interface AuthorizationDetailsJwtVcJsonLdAndLdpVc extends CommonAuthorizationDetails {
139
+ format: 'ldp_vc' | 'jwt_vc_json-ld';
140
+
113
141
  /**
114
142
  * REQUIRED. JSON object containing (and isolating) the detailed description of the credential type.
115
143
  * This object MUST be processed using full JSON-LD processing. It consists of the following sub-claims:
@@ -117,7 +145,14 @@ export interface AuthorizationDetailsJwtVcJsonLdAndLdpVc extends CommonAuthoriza
117
145
  * - types: REQUIRED. JSON array as defined in Appendix E.1.3.2.
118
146
  * This claim contains the type values the Wallet shall request in the subsequent Credential Request
119
147
  */
120
- credential_definition: IssuerCredentialDefinition;
148
+ credential_definition: JsonLdIssuerCredentialDefinition;
149
+ }
150
+
151
+ export interface AuthorizationDetailsSdJwtVc extends CommonAuthorizationDetails {
152
+ format: 'vc+sd-jwt';
153
+
154
+ vct: string;
155
+ claims?: IssuerCredentialSubject;
121
156
  }
122
157
 
123
158
  export enum GrantTypes {
@@ -136,8 +171,8 @@ export enum ResponseType {
136
171
  }
137
172
 
138
173
  export enum CodeChallengeMethod {
139
- TEXT = 'text',
140
- SHA256 = 'S256',
174
+ plain = 'plain',
175
+ S256 = 'S256',
141
176
  }
142
177
 
143
178
  export interface AuthorizationServerOpts {
@@ -153,8 +188,12 @@ export interface IssuerOpts {
153
188
  fetchMetadata?: boolean;
154
189
  }
155
190
 
191
+ export interface AccessTokenFromAuthorizationResponseOpts extends AccessTokenRequestOpts {
192
+ authorizationResponse: AuthorizationResponse;
193
+ }
156
194
  export interface AccessTokenRequestOpts {
157
- credentialOffer: UniformCredentialOffer;
195
+ credentialOffer?: UniformCredentialOffer;
196
+ credentialIssuer?: string;
158
197
  asOpts?: AuthorizationServerOpts;
159
198
  metadata?: EndpointMetadata;
160
199
  codeVerifier?: string; // only required for authorization flow
@@ -163,22 +202,72 @@ export interface AccessTokenRequestOpts {
163
202
  pin?: string; // Pin-number. Only used when required
164
203
  }
165
204
 
166
- export interface AuthorizationRequestOpts {
205
+ /*export interface AuthorizationRequestOpts {
167
206
  clientId: string;
168
207
  codeChallenge: string;
169
208
  codeChallengeMethod: CodeChallengeMethod;
170
209
  authorizationDetails?: AuthorizationDetails[];
171
210
  redirectUri: string;
172
211
  scope?: string;
212
+ }*/
213
+
214
+ /**
215
+ * Determinse whether PAR should be used when supported
216
+ *
217
+ * REQUIRE: Require PAR, if AS does not support it throw an error
218
+ * AUTO: Use PAR is the AS supports it, otherwise construct a reqular URI,
219
+ * NEVER: Do not use PAR even if the AS supports it (not recommended)
220
+ */
221
+ export enum PARMode {
222
+ REQUIRE,
223
+ AUTO,
224
+ NEVER,
173
225
  }
174
226
 
175
- export interface AuthorizationGrantResponse {
176
- grant_type: string;
227
+ /**
228
+ * Optional options to provide PKCE params like code verifier and challenge yourself, or to disable PKCE altogether. If not provide PKCE will still be used! If individual params are not provide, they will be generated/calculated
229
+ */
230
+ export interface PKCEOpts {
231
+ /**
232
+ * PKCE is enabled by default even if you do not provide these options. Set this to true to disable PKCE
233
+ */
234
+ disabled?: boolean;
235
+
236
+ /**
237
+ * Provide a code_challenge, otherwise it will be calculated using the code_verifier and method
238
+ */
239
+ codeChallenge?: string;
240
+
241
+ /**
242
+ * The code_challenge_method, should always by S256
243
+ */
244
+ codeChallengeMethod?: CodeChallengeMethod;
245
+
246
+ /**
247
+ * Provide a code_verifier, otherwise it will be generated
248
+ */
249
+ codeVerifier?: string;
250
+ }
251
+
252
+ export interface AuthorizationRequestOpts {
253
+ clientId?: string;
254
+ pkce?: PKCEOpts;
255
+ parMode?: PARMode;
256
+ authorizationDetails?: AuthorizationDetails | AuthorizationDetails[];
257
+ redirectUri?: string;
258
+ scope?: string;
259
+ }
260
+
261
+ export interface AuthorizationResponse {
177
262
  code: string;
178
263
  scope?: string;
179
264
  state?: string;
180
265
  }
181
266
 
267
+ export interface AuthorizationGrantResponse extends AuthorizationResponse {
268
+ grant_type: string;
269
+ }
270
+
182
271
  export interface AccessTokenRequest {
183
272
  client_id?: string;
184
273
  code?: string;
@@ -10,13 +10,15 @@ import { CredentialOfferPayloadV1_0_11, CredentialOfferV1_0_11 } from './v1_0_11
10
10
  export interface CredentialResponse {
11
11
  credential?: W3CVerifiableCredential; // OPTIONAL. Contains issued Credential. MUST be present when acceptance_token is not returned. MAY be a JSON string or a JSON object, depending on the Credential format. See Appendix E for the Credential format specific encoding requirements
12
12
  format: OID4VCICredentialFormat /* | OID4VCICredentialFormat[]*/; // REQUIRED. JSON string denoting the format of the issued Credential
13
- acceptance_token?: string; // OPTIONAL. A JSON string containing a security token subsequently used to obtain a Credential. MUST be present when credential is not returned
13
+ transaction_id?: string; //OPTIONAL. A string identifying a Deferred Issuance transaction. This claim is contained in the response if the Credential Issuer was unable to immediately issue the credential. The value is subsequently used to obtain the respective Credential with the Deferred Credential Endpoint (see Section 9). It MUST be present when the credential parameter is not returned. It MUST be invalidated after the credential for which it was meant has been obtained by the Wallet.
14
+ acceptance_token?: string; //deprecated // OPTIONAL. A JSON string containing a security token subsequently used to obtain a Credential. MUST be present when credential is not returned
14
15
  c_nonce?: string; // OPTIONAL. JSON string containing a nonce to be used to create a proof of possession of key material when requesting a Credential (see Section 7.2). When received, the Wallet MUST use this nonce value for its subsequent credential requests until the Credential Issuer provides a fresh nonce
15
16
  c_nonce_expires_in?: number; // OPTIONAL. JSON integer denoting the lifetime in seconds of the c_nonce
16
17
  }
17
18
 
18
19
  export interface CredentialOfferRequestWithBaseUrl extends UniformCredentialOfferRequest {
19
20
  scheme: string;
21
+ clientId?: string;
20
22
  baseUrl: string;
21
23
  userPinRequired: boolean;
22
24
  issuerState?: string;
@@ -25,7 +27,9 @@ export interface CredentialOfferRequestWithBaseUrl extends UniformCredentialOffe
25
27
 
26
28
  export type CredentialOffer = CredentialOfferV1_0_09 | CredentialOfferV1_0_11;
27
29
 
28
- export type CredentialOfferPayload = CredentialOfferPayloadV1_0_08 | CredentialOfferPayloadV1_0_09 | CredentialOfferPayloadV1_0_11;
30
+ export type CredentialOfferPayload = (CredentialOfferPayloadV1_0_08 | CredentialOfferPayloadV1_0_09 | CredentialOfferPayloadV1_0_11) & {
31
+ [x: string]: any;
32
+ };
29
33
 
30
34
  export interface AssertedUniformCredentialOffer extends UniformCredentialOffer {
31
35
  credential_offer: UniformCredentialOfferPayload;
@@ -106,6 +110,7 @@ export interface JWK extends BaseJWK {
106
110
  x5t?: string;
107
111
  'x5t#S256'?: string;
108
112
  x5u?: string;
113
+
109
114
  [propName: string]: unknown;
110
115
  }
111
116
 
@@ -146,6 +151,7 @@ export interface JWSHeaderParameters extends JoseHeaderParameters {
146
151
  alg?: Alg | string; // REQUIRED by the JWT signer
147
152
  b64?: boolean;
148
153
  crit?: string[];
154
+
149
155
  [propName: string]: unknown;
150
156
  }
151
157
 
@@ -171,6 +177,7 @@ export interface JWTPayload {
171
177
 
172
178
  export type JWTSignerCallback = (jwt: Jwt, kid?: string) => Promise<string>;
173
179
  export type JWTVerifyCallback<DIDDoc> = (args: { jwt: string; kid?: string }) => Promise<JwtVerifyResult<DIDDoc>>;
180
+
174
181
  export interface JwtVerifyResult<DIDDoc> {
175
182
  jwt: Jwt;
176
183
  kid?: string;
@@ -15,7 +15,7 @@ export interface ImageInfo {
15
15
  [key: string]: unknown;
16
16
  }
17
17
 
18
- export type OID4VCICredentialFormat = 'jwt_vc_json' | 'jwt_vc_json-ld' | 'ldp_vc' /*| 'mso_mdoc'*/; // we do not support mdocs at this point
18
+ export type OID4VCICredentialFormat = 'jwt_vc_json' | 'jwt_vc_json-ld' | 'ldp_vc' | 'vc+sd-jwt' | 'jwt_vc'; // jwt_vc is added for backwards compat /*| 'mso_mdoc'*/; // we do not support mdocs at this point
19
19
 
20
20
  export interface NameAndLocale {
21
21
  name?: string; // REQUIRED. String value of a display name for the Credential.
@@ -51,6 +51,7 @@ export interface CredentialIssuerMetadataOpts {
51
51
  credentials_supported: CredentialSupported[]; // REQUIRED. A JSON array containing a list of JSON objects, each of them representing metadata about a separate credential type that the Credential Issuer can issue. The JSON objects in the array MUST conform to the structure of the Section 10.2.3.1.
52
52
  credential_issuer: string; // REQUIRED. The Credential Issuer's identifier.
53
53
  authorization_server?: string; // OPTIONAL. Identifier of the OAuth 2.0 Authorization Server (as defined in [RFC8414]) the Credential Issuer relies on for authorization. If this element is omitted, the entity providing the Credential Issuer is also acting as the AS, i.e. the Credential Issuer's identifier is used as the OAuth 2.0 Issuer value to obtain the Authorization Server metadata as per [RFC8414].
54
+ // authorization_servers?: string[]; // OPTIONAL. Array of strings that identify the OAuth 2.0 Authorization Servers (as defined in [RFC8414]) the Credential Issuer relies on for authorization. If this element is omitted, the entity providing the Credential Issuer is also acting as the AS, i.e. the Credential Issuer's identifier is used as the OAuth 2.0 Issuer value to obtain the Authorization Server metadata as per [RFC8414].
54
55
  token_endpoint?: string;
55
56
  display?: MetadataDisplay[]; // An array of objects, where each object contains display properties of a Credential Issuer for a certain language. Below is a non-exhaustive list of valid parameters that MAY be included:
56
57
  credential_supplier_config?: CredentialSupplierConfig;
@@ -58,12 +59,17 @@ export interface CredentialIssuerMetadataOpts {
58
59
 
59
60
  // For now we extend the opts above. Only difference is that the credential endpoint is optional in the Opts, as it can come from other sources. The value is however required in the eventual Issuer Metadata
60
61
  export interface CredentialIssuerMetadata extends CredentialIssuerMetadataOpts, Partial<AuthorizationServerMetadata> {
62
+ authorization_servers?: string[]; // OPTIONAL. Array of strings that identify the OAuth 2.0 Authorization Servers (as defined in [RFC8414]) the Credential Issuer relies on for authorization. If this element is omitted, the entity providing the Credential Issuer is also acting as the AS, i.e. the Credential Issuer's identifier is used as the OAuth 2.0 Issuer value to obtain the Authorization Server metadata as per [RFC8414].
61
63
  credential_endpoint: string; // REQUIRED. URL of the Credential Issuer's Credential Endpoint. This URL MUST use the https scheme and MAY contain port, path and query parameter components.
64
+ credential_response_encryption_alg_values_supported?: string; // OPTIONAL. Array containing a list of the JWE [RFC7516] encryption algorithms (alg values) [RFC7518] supported by the Credential and/or Batch Credential Endpoint to encode the Credential or Batch Credential Response in a JWT [RFC7519].
65
+ credential_response_encryption_enc_values_supported?: string; //OPTIONAL. Array containing a list of the JWE [RFC7516] encryption algorithms (enc values) [RFC7518] supported by the Credential and/or Batch Credential Endpoint to encode the Credential or Batch Credential Response in a JWT [RFC7519].
66
+ require_credential_response_encryption?: boolean; //OPTIONAL. Boolean value specifying whether the Credential Issuer requires additional encryption on top of TLS for the Credential Response and expects encryption parameters to be present in the Credential Request and/or Batch Credential Request, with true indicating support. When the value is true, credential_response_encryption_alg_values_supported parameter MUST also be provided. If omitted, the default value is false.
67
+ credential_identifiers_supported?: boolean; // OPTIONAL. Boolean value specifying whether the Credential Issuer supports returning credential_identifiers parameter in the authorization_details Token Response parameter, with true indicating support. If omitted, the default value is false.
62
68
  }
63
69
 
70
+ // For now we extend the opts above. Only difference is that the credential endpoint is optional in the Opts, as it can come from other sources. The value is however required in the eventual Issuer Metadata
71
+
64
72
  export interface CredentialSupportedBrief {
65
- name?: string; // fixme: Probably should not be here, is part of the display object
66
- types: string[]; // REQUIRED. JSON array designating the types a certain credential type supports
67
73
  cryptographic_binding_methods_supported?: string[]; // OPTIONAL. Array of case sensitive strings that identify how the Credential is bound to the identifier of the End-User who possesses the Credential
68
74
  cryptographic_suites_supported?: string[]; // OPTIONAL. Array of case sensitive strings that identify the cryptographic suites that are supported for the cryptographic_binding_methods_supported
69
75
  }
@@ -75,25 +81,63 @@ export type CommonCredentialSupported = CredentialSupportedBrief & {
75
81
  /**
76
82
  * following properties are non-mso_mdoc specific and we might wanna rethink them when we're going to support mso_mdoc
77
83
  */
78
- credentialSubject?: IssuerCredentialSubject; // OPTIONAL. A JSON object containing a list of key value pairs, where the key identifies the claim offered in the Credential. The value MAY be a dictionary, which allows to represent the full (potentially deeply nested) structure of the verifiable credential to be issued.
79
- order?: string[]; //An array of claims.display.name values that lists them in the order they should be displayed by the Wallet.
80
84
  };
81
85
 
82
86
  export interface CredentialSupportedJwtVcJsonLdAndLdpVc extends CommonCredentialSupported {
87
+ types: string[]; // REQUIRED. JSON array designating the types a certain credential type supports
83
88
  '@context': ICredentialContextType[]; // REQUIRED. JSON array as defined in [VC_DATA], Section 4.1.
89
+ credentialSubject?: IssuerCredentialSubject; // OPTIONAL. A JSON object containing a list of key value pairs, where the key identifies the claim offered in the Credential. The value MAY be a dictionary, which allows to represent the full (potentially deeply nested) structure of the verifiable credential to be issued.
90
+ order?: string[]; //An array of claims.display.name values that lists them in the order they should be displayed by the Wallet.
91
+ format: 'ldp_vc' | 'jwt_vc_json-ld';
84
92
  }
85
93
 
86
94
  export interface CredentialSupportedJwtVcJson extends CommonCredentialSupported {
87
- format: 'jwt_vc_json';
95
+ types: string[]; // REQUIRED. JSON array designating the types a certain credential type supports
96
+ credentialSubject?: IssuerCredentialSubject; // OPTIONAL. A JSON object containing a list of key value pairs, where the key identifies the claim offered in the Credential. The value MAY be a dictionary, which allows to represent the full (potentially deeply nested) structure of the verifiable credential to be issued.
97
+ order?: string[]; //An array of claims.display.name values that lists them in the order they should be displayed by the Wallet.
98
+ format: 'jwt_vc_json' | 'jwt_vc'; // jwt_vc added for backwards compat
88
99
  }
89
100
 
90
- export type CredentialSupported = CommonCredentialSupported & (CredentialSupportedJwtVcJson | CredentialSupportedJwtVcJsonLdAndLdpVc);
101
+ export interface CredentialSupportedSdJwtVc extends CommonCredentialSupported {
102
+ format: 'vc+sd-jwt';
91
103
 
92
- export interface CredentialOfferFormat {
104
+ vct: string;
105
+ claims?: IssuerCredentialSubject;
106
+
107
+ order?: string[]; //An array of claims.display.name values that lists them in the order they should be displayed by the Wallet.
108
+ }
109
+
110
+ export type CredentialSupported = CommonCredentialSupported &
111
+ (CredentialSupportedJwtVcJson | CredentialSupportedJwtVcJsonLdAndLdpVc | CredentialSupportedSdJwtVc);
112
+
113
+ export interface CommonCredentialOfferFormat {
93
114
  format: OID4VCICredentialFormat | string;
94
- types: string[];
95
115
  }
96
116
 
117
+ export interface CredentialOfferFormatJwtVcJsonLdAndLdpVc extends CommonCredentialOfferFormat {
118
+ format: 'ldp_vc' | 'jwt_vc_json-ld';
119
+ // REQUIRED. JSON object containing (and isolating) the detailed description of the credential type. This object MUST be processed using full JSON-LD processing.
120
+ credential_definition: JsonLdIssuerCredentialDefinition;
121
+ }
122
+
123
+ export interface CredentialOfferFormatJwtVcJson extends CommonCredentialOfferFormat {
124
+ format: 'jwt_vc_json' | 'jwt_vc'; // jwt_vc is added for backwards compat
125
+ types: string[]; // REQUIRED. JSON array as defined in Appendix E.1.1.2. This claim contains the type values the Wallet shall request in the subsequent Credential Request.
126
+ }
127
+
128
+ // NOTE: the sd-jwt format is added to oid4vci in a later draft version than currently
129
+ // supported, so there's no defined offer format. However, based on the request structure
130
+ // we support sd-jwt for older drafts of oid4vci as well
131
+ export interface CredentialOfferFormatSdJwtVc extends CommonCredentialOfferFormat {
132
+ format: 'vc+sd-jwt';
133
+
134
+ vct: string;
135
+ claims?: IssuerCredentialSubject;
136
+ }
137
+
138
+ export type CredentialOfferFormat = CommonCredentialOfferFormat &
139
+ (CredentialOfferFormatJwtVcJsonLdAndLdpVc | CredentialOfferFormatJwtVcJson | CredentialOfferFormatSdJwtVc);
140
+
97
141
  /**
98
142
  * Optional storage that can help the credential Data Supplier. For instance to store credential input data during offer creation, if no additional data can be supplied later on
99
143
  */
@@ -108,10 +152,10 @@ export type CreateCredentialOfferURIResult = {
108
152
  userPinRequired: boolean;
109
153
  };
110
154
 
111
- export interface IssuerCredentialDefinition {
155
+ export interface JsonLdIssuerCredentialDefinition {
112
156
  '@context': ICredentialContextType[];
113
157
  types: string[];
114
- credentialSubject: IssuerCredentialSubject;
158
+ credentialSubject?: IssuerCredentialSubject;
115
159
  }
116
160
 
117
161
  export interface ErrorResponse extends Response {
@@ -128,15 +172,21 @@ export interface CommonCredentialRequest {
128
172
  proof?: ProofOfPossession;
129
173
  }
130
174
 
131
- export interface CredentialRequestJwtVc extends CommonCredentialRequest {
132
- format: 'jwt_vc_json' | 'jwt_vc_json-ld';
175
+ export interface CredentialRequestJwtVcJson extends CommonCredentialRequest {
176
+ format: 'jwt_vc_json' | 'jwt_vc'; // jwt_vc for backwards compat
133
177
  types: string[];
134
178
  credentialSubject?: IssuerCredentialSubject;
135
179
  }
136
180
 
137
- export interface CredentialRequestLdpVc extends CommonCredentialRequest {
138
- format: 'ldp_vc';
139
- credential_definition: IssuerCredentialDefinition;
181
+ export interface CredentialRequestJwtVcJsonLdAndLdpVc extends CommonCredentialRequest {
182
+ format: 'ldp_vc' | 'jwt_vc_json-ld';
183
+ credential_definition: JsonLdIssuerCredentialDefinition;
184
+ }
185
+
186
+ export interface CredentialRequestSdJwtVc extends CommonCredentialRequest {
187
+ format: 'vc+sd-jwt';
188
+ vct: string;
189
+ claims?: IssuerCredentialSubject;
140
190
  }
141
191
 
142
192
  export interface CommonCredentialResponse {
@@ -157,6 +207,11 @@ export interface CredentialResponseJwtVc {
157
207
  credential: string;
158
208
  }
159
209
 
210
+ export interface CredentialResponseSdJwtVc {
211
+ format: 'vc+sd-jwt';
212
+ credential: string;
213
+ }
214
+
160
215
  // export type CredentialSubjectDisplay = NameAndLocale[];
161
216
 
162
217
  export type IssuerCredentialSubjectDisplay = CredentialSubjectDisplay & { [key: string]: CredentialSubjectDisplay };
@@ -182,6 +237,12 @@ export interface GrantAuthorizationCode {
182
237
  * Authorization Request with the Credential Issuer to a context set up during previous steps.
183
238
  */
184
239
  issuer_state?: string;
240
+
241
+ // v12 feature
242
+ /**
243
+ * OPTIONAL string that the Wallet can use to identify the Authorization Server to use with this grant type when authorization_servers parameter in the Credential Issuer metadata has multiple entries. MUST NOT be used otherwise. The value of this parameter MUST match with one of the values in the authorization_servers array obtained from the Credential Issuer metadata
244
+ */
245
+ authorization_server?: string;
185
246
  }
186
247
 
187
248
  export interface GrantUrnIetf {
@@ -194,6 +255,18 @@ export interface GrantUrnIetf {
194
255
  * in a Pre-Authorized Code Flow. Default is false.
195
256
  */
196
257
  user_pin_required: boolean;
258
+
259
+ //v12
260
+ /**
261
+ * OPTIONAL. The minimum amount of time in seconds that the Wallet SHOULD wait between polling requests to the token endpoint (in case the Authorization Server responds with error code authorization_pending - see Section 6.3). If no value is provided, Wallets MUST use 5 as the default.
262
+ */
263
+ interval?: number;
264
+
265
+ // v12 feature
266
+ /**
267
+ * OPTIONAL string that the Wallet can use to identify the Authorization Server to use with this grant type when authorization_servers parameter in the Credential Issuer metadata has multiple entries. MUST NOT be used otherwise. The value of this parameter MUST match with one of the values in the authorization_servers array obtained from the Credential Issuer metadata
268
+ */
269
+ authorization_server?: string;
197
270
  }
198
271
 
199
272
  export const PRE_AUTH_CODE_LITERAL = 'pre-authorized_code';
@@ -2,7 +2,8 @@ export enum OpenId4VCIVersion {
2
2
  VER_1_0_08 = 1008,
3
3
  VER_1_0_09 = 1009,
4
4
  VER_1_0_11 = 1011,
5
- VER_UNKNOWN = Number.MIN_VALUE,
5
+ VER_1_0_12 = 1012,
6
+ VER_UNKNOWN = Number.MAX_VALUE,
6
7
  }
7
8
 
8
9
  export enum DefaultURISchemes {
@@ -60,7 +60,7 @@ export interface ComponentOptions {
60
60
  */
61
61
  protectors?: boolean;
62
62
  };
63
- };
63
+ }
64
64
 
65
65
  export interface QRCodeOpts {
66
66
  /**
@@ -224,4 +224,4 @@ export interface QRCodeOpts {
224
224
  * @deafultValue 0.4
225
225
  */
226
226
  dotScale?: number;
227
- };
227
+ }
@@ -49,6 +49,7 @@ export interface AuthorizationServerMetadata {
49
49
 
50
50
  // VCI values. In case an AS provides a credential_endpoint itself
51
51
  credential_endpoint?: string;
52
+ deferred_credential_endpoint?: string;
52
53
 
53
54
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
54
55
  [x: string]: any; //We use any, so you can access properties if you know the structure
@@ -66,6 +67,7 @@ export interface EndpointMetadata {
66
67
  issuer: string;
67
68
  token_endpoint: string;
68
69
  credential_endpoint: string;
70
+ deferred_credential_endpoint?: string;
69
71
  authorization_server?: string;
70
72
  authorization_endpoint?: string; // Can be undefined in pre-auth flow
71
73
  }
@@ -6,7 +6,7 @@ import { CredentialsSupportedDisplay, CredentialSupportedBrief, IssuerCredential
6
6
  export interface CredentialRequestV1_0_08 {
7
7
  type: string;
8
8
  format: CredentialFormat;
9
- proof: ProofOfPossession;
9
+ proof?: ProofOfPossession;
10
10
  }
11
11
 
12
12
  export interface IssuerMetadataV1_0_08 {
@@ -34,11 +34,16 @@ export interface CredentialSupportedTypeV1_0_08 {
34
34
  [credentialType: string]: CredentialSupportedV1_0_08;
35
35
  }
36
36
 
37
+ export interface CredentialSupportedFormatV1_0_08 extends CredentialSupportedBrief {
38
+ name?: string;
39
+ types: string[];
40
+ }
41
+
37
42
  export interface CredentialSupportedV1_0_08 {
38
43
  display?: CredentialsSupportedDisplay[];
39
44
  formats: {
40
45
  // REQUIRED. A JSON object containing a list of key value pairs, where the key is a string identifying the format of the Credential. Below is a non-exhaustive list of valid key values defined by this specification:
41
- [credentialFormat: string]: CredentialSupportedBrief;
46
+ [credentialFormat: string]: CredentialSupportedFormatV1_0_08;
42
47
  };
43
48
  claims?: IssuerCredentialSubject; // REQUIRED. A JSON object containing a list of key value pairs, where the key identifies the claim offered in the Credential. The value is a JSON object detailing the specifics about the support for the claim with a following non-exhaustive list of parameters that MAY be included:
44
49
  }
@@ -2,13 +2,15 @@ import { AuthorizationDetailsJwtVcJson, CommonAuthorizationRequest } from './Aut
2
2
  import {
3
3
  CommonCredentialRequest,
4
4
  CredentialDataSupplierInput,
5
+ CredentialIssuerMetadataOpts,
5
6
  CredentialOfferFormat,
6
- CredentialRequestJwtVc,
7
- CredentialRequestLdpVc,
7
+ CredentialRequestJwtVcJson,
8
+ CredentialRequestSdJwtVc,
8
9
  Grant,
9
- IssuerCredentialDefinition,
10
+ JsonLdIssuerCredentialDefinition,
10
11
  } from './Generic.types';
11
12
  import { QRCodeOpts } from './QRCode.types';
13
+ import { AuthorizationServerMetadata } from './ServerMetadata';
12
14
 
13
15
  export interface CredentialOfferV1_0_11 {
14
16
  credential_offer?: CredentialOfferPayloadV1_0_11;
@@ -23,7 +25,7 @@ export interface CredentialOfferRESTRequest extends CredentialOfferV1_0_11 {
23
25
  credentialDataSupplierInput?: CredentialDataSupplierInput;
24
26
  }
25
27
 
26
- export interface CommonCredentialOfferPayloadV1_0_11 {
28
+ export interface CredentialOfferPayloadV1_0_11 {
27
29
  /**
28
30
  * REQUIRED. The URL of the Credential Issuer, the Wallet is requested to obtain one or more Credentials from.
29
31
  */
@@ -48,24 +50,25 @@ export interface CommonCredentialOfferPayloadV1_0_11 {
48
50
  * using the respective metadata. When multiple grants are present, it's at the Wallet's discretion which one to use.
49
51
  */
50
52
  grants?: Grant;
51
- }
52
53
 
53
- export interface CredentialOfferLdpVcV1_0_11 extends CommonCredentialOfferPayloadV1_0_11 {
54
54
  /**
55
- * REQUIRED. JSON object containing (and isolating) the detailed description of the credential type.
56
- * This object MUST be processed using full JSON-LD processing. It consists of the following sub-claims:
57
- * - @context: REQUIRED. JSON array as defined in Appendix E.1.3.2
58
- * - types: REQUIRED. JSON array as defined in Appendix E.1.3.2.
59
- * This claim contains the type values the Wallet shall request in the subsequent Credential Request
55
+ * Some implementations might include a client_id in the offer. For instance EBSI in a same-device flow. (Cross-device tucks it in the state JWT)
60
56
  */
61
- credential_definition: IssuerCredentialDefinition;
57
+ client_id?: string;
62
58
  }
63
59
 
64
- export type CredentialOfferJwtVcV1_0_11 = CommonCredentialOfferPayloadV1_0_11;
65
-
66
- export type CredentialOfferPayloadV1_0_11 = CommonCredentialOfferPayloadV1_0_11 & (CredentialOfferLdpVcV1_0_11 | CredentialOfferJwtVcV1_0_11);
60
+ export type CredentialRequestV1_0_11 = CommonCredentialRequest &
61
+ (CredentialRequestJwtVcJson | CredentialRequestJwtVcJsonLdAndLdpVcV1_0_11 | CredentialRequestSdJwtVc);
67
62
 
68
- export type CredentialRequestV1_0_11 = CommonCredentialRequest & (CredentialRequestJwtVc | CredentialRequestLdpVc);
63
+ export interface CredentialRequestJwtVcJsonLdAndLdpVcV1_0_11
64
+ extends CommonCredentialRequest,
65
+ Pick<JsonLdIssuerCredentialDefinition, 'credentialSubject' | 'types'> {
66
+ format: 'ldp_vc' | 'jwt_vc_json-ld';
67
+ }
68
+ export interface CredentialIssuerMetadataV1_0_11 extends CredentialIssuerMetadataOpts, Partial<AuthorizationServerMetadata> {
69
+ credential_endpoint: string; // REQUIRED. URL of the Credential Issuer's Credential Endpoint. This URL MUST use the https scheme and MAY contain port, path and query parameter components.
70
+ authorization_server?: string;
71
+ }
69
72
 
70
73
  export interface AuthorizationRequestV1_0_11 extends AuthorizationDetailsJwtVcJson, AuthorizationDetailsJwtVcJson {
71
74
  issuer_state?: string;
@@ -0,0 +1,4 @@
1
+ import { CommonCredentialRequest, CredentialRequestJwtVcJson, CredentialRequestJwtVcJsonLdAndLdpVc, CredentialRequestSdJwtVc } from './Generic.types';
2
+
3
+ export type CredentialRequestV1_0_12 = CommonCredentialRequest &
4
+ (CredentialRequestJwtVcJson | CredentialRequestJwtVcJsonLdAndLdpVc | CredentialRequestSdJwtVc);