@sphereon/oid4vci-common 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 (101) hide show
  1. package/dist/events/index.d.ts +17 -0
  2. package/dist/events/index.d.ts.map +1 -0
  3. package/dist/events/index.js +21 -0
  4. package/dist/events/index.js.map +1 -0
  5. package/dist/experimental/holder-vci.d.ts +13 -0
  6. package/dist/experimental/holder-vci.d.ts.map +1 -0
  7. package/dist/experimental/holder-vci.js +9 -0
  8. package/dist/experimental/holder-vci.js.map +1 -0
  9. package/dist/functions/CredentialOfferUtil.d.ts +3 -3
  10. package/dist/functions/CredentialOfferUtil.d.ts.map +1 -1
  11. package/dist/functions/CredentialOfferUtil.js +71 -28
  12. package/dist/functions/CredentialOfferUtil.js.map +1 -1
  13. package/dist/functions/CredentialRequestUtil.d.ts +3 -3
  14. package/dist/functions/CredentialRequestUtil.d.ts.map +1 -1
  15. package/dist/functions/CredentialRequestUtil.js +13 -4
  16. package/dist/functions/CredentialRequestUtil.js.map +1 -1
  17. package/dist/functions/CredentialResponseUtil.d.ts +3 -1
  18. package/dist/functions/CredentialResponseUtil.d.ts.map +1 -1
  19. package/dist/functions/CredentialResponseUtil.js +1 -1
  20. package/dist/functions/CredentialResponseUtil.js.map +1 -1
  21. package/dist/functions/Encoding.d.ts +7 -6
  22. package/dist/functions/Encoding.d.ts.map +1 -1
  23. package/dist/functions/Encoding.js +9 -8
  24. package/dist/functions/Encoding.js.map +1 -1
  25. package/dist/functions/IssuerMetadataUtils.d.ts +19 -12
  26. package/dist/functions/IssuerMetadataUtils.d.ts.map +1 -1
  27. package/dist/functions/IssuerMetadataUtils.js +155 -88
  28. package/dist/functions/IssuerMetadataUtils.js.map +1 -1
  29. package/dist/functions/ProofUtil.d.ts +38 -0
  30. package/dist/functions/ProofUtil.d.ts.map +1 -0
  31. package/dist/functions/ProofUtil.js +141 -0
  32. package/dist/functions/ProofUtil.js.map +1 -0
  33. package/dist/functions/index.d.ts +1 -0
  34. package/dist/functions/index.d.ts.map +1 -1
  35. package/dist/functions/index.js +1 -0
  36. package/dist/functions/index.js.map +1 -1
  37. package/dist/index.d.ts +5 -0
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +6 -0
  40. package/dist/index.js.map +1 -1
  41. package/dist/types/Authorization.types.d.ts +26 -4
  42. package/dist/types/Authorization.types.d.ts.map +1 -1
  43. package/dist/types/Authorization.types.js +7 -1
  44. package/dist/types/Authorization.types.js.map +1 -1
  45. package/dist/types/CredentialIssuance.types.d.ts +17 -10
  46. package/dist/types/CredentialIssuance.types.d.ts.map +1 -1
  47. package/dist/types/CredentialIssuance.types.js.map +1 -1
  48. package/dist/types/Generic.types.d.ts +104 -17
  49. package/dist/types/Generic.types.d.ts.map +1 -1
  50. package/dist/types/Generic.types.js.map +1 -1
  51. package/dist/types/OpenID4VCIErrors.d.ts +1 -0
  52. package/dist/types/OpenID4VCIErrors.d.ts.map +1 -1
  53. package/dist/types/OpenID4VCIErrors.js +2 -1
  54. package/dist/types/OpenID4VCIErrors.js.map +1 -1
  55. package/dist/types/OpenID4VCIVersions.types.d.ts +1 -0
  56. package/dist/types/OpenID4VCIVersions.types.d.ts.map +1 -1
  57. package/dist/types/OpenID4VCIVersions.types.js +1 -0
  58. package/dist/types/OpenID4VCIVersions.types.js.map +1 -1
  59. package/dist/types/ServerMetadata.d.ts +0 -7
  60. package/dist/types/ServerMetadata.d.ts.map +1 -1
  61. package/dist/types/ServerMetadata.js.map +1 -1
  62. package/dist/types/StateManager.types.d.ts +1 -0
  63. package/dist/types/StateManager.types.d.ts.map +1 -1
  64. package/dist/types/StateManager.types.js.map +1 -1
  65. package/dist/types/index.d.ts +1 -0
  66. package/dist/types/index.d.ts.map +1 -1
  67. package/dist/types/index.js +1 -0
  68. package/dist/types/index.js.map +1 -1
  69. package/dist/types/v1_0_11.types.d.ts +35 -5
  70. package/dist/types/v1_0_11.types.d.ts.map +1 -1
  71. package/dist/types/v1_0_11.types.js.map +1 -1
  72. package/dist/types/v1_0_12.types.d.ts +30 -1
  73. package/dist/types/v1_0_12.types.d.ts.map +1 -1
  74. package/dist/types/v1_0_13.types.d.ts +120 -0
  75. package/dist/types/v1_0_13.types.d.ts.map +1 -0
  76. package/dist/types/v1_0_13.types.js +3 -0
  77. package/dist/types/v1_0_13.types.js.map +1 -0
  78. package/lib/__tests__/CredentialOfferUtil.spec.ts +25 -9
  79. package/lib/__tests__/IssuerMetadataUtils.spec.ts +38 -0
  80. package/lib/events/index.ts +20 -0
  81. package/lib/experimental/holder-vci.ts +19 -0
  82. package/lib/functions/CredentialOfferUtil.ts +78 -26
  83. package/lib/functions/CredentialRequestUtil.ts +23 -8
  84. package/lib/functions/CredentialResponseUtil.ts +4 -4
  85. package/lib/functions/Encoding.ts +10 -8
  86. package/lib/functions/IssuerMetadataUtils.ts +164 -93
  87. package/lib/functions/ProofUtil.ts +185 -0
  88. package/lib/functions/index.ts +1 -0
  89. package/lib/index.ts +7 -0
  90. package/lib/types/Authorization.types.ts +31 -4
  91. package/lib/types/CredentialIssuance.types.ts +26 -10
  92. package/lib/types/Generic.types.ts +150 -27
  93. package/lib/types/OpenID4VCIErrors.ts +1 -0
  94. package/lib/types/OpenID4VCIVersions.types.ts +1 -0
  95. package/lib/types/ServerMetadata.ts +0 -10
  96. package/lib/types/StateManager.types.ts +1 -0
  97. package/lib/types/index.ts +1 -0
  98. package/lib/types/v1_0_11.types.ts +41 -4
  99. package/lib/types/v1_0_12.types.ts +39 -1
  100. package/lib/types/v1_0_13.types.ts +158 -0
  101. package/package.json +3 -11
@@ -1,33 +1,47 @@
1
1
  import { W3CVerifiableCredential } from '@sphereon/ssi-types';
2
2
 
3
+ import { ExperimentalSubjectIssuance } from '../experimental/holder-vci';
4
+
3
5
  import { AuthzFlowType } from './Authorization.types';
4
- import { OID4VCICredentialFormat } from './Generic.types';
6
+ import { OID4VCICredentialFormat, TxCode, UniformCredentialRequest } from './Generic.types';
5
7
  import { OpenId4VCIVersion } from './OpenID4VCIVersions.types';
6
- import { CredentialOfferPayloadV1_0_08 } from './v1_0_08.types';
8
+ import { CredentialOfferPayloadV1_0_08, CredentialRequestV1_0_08 } from './v1_0_08.types';
7
9
  import { CredentialOfferPayloadV1_0_09, CredentialOfferV1_0_09 } from './v1_0_09.types';
8
- import { CredentialOfferPayloadV1_0_11, CredentialOfferV1_0_11 } from './v1_0_11.types';
10
+ import { CredentialOfferPayloadV1_0_11, CredentialOfferV1_0_11, CredentialRequestV1_0_11 } from './v1_0_11.types';
11
+ import { CredentialOfferPayloadV1_0_13, CredentialOfferV1_0_13, CredentialRequestV1_0_13 } from './v1_0_13.types';
9
12
 
10
- export interface CredentialResponse {
13
+ export interface CredentialResponse extends ExperimentalSubjectIssuance {
11
14
  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
- format: OID4VCICredentialFormat /* | OID4VCICredentialFormat[]*/; // REQUIRED. JSON string denoting the format of the issued Credential
15
+ format?: OID4VCICredentialFormat /* | OID4VCICredentialFormat[]*/; // REQUIRED. JSON string denoting the format of the issued Credential TODO: remove when cleaning <v13
13
16
  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
17
  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
15
18
  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
16
19
  c_nonce_expires_in?: number; // OPTIONAL. JSON integer denoting the lifetime in seconds of the c_nonce
20
+ notification_id?: string;
17
21
  }
18
22
 
19
23
  export interface CredentialOfferRequestWithBaseUrl extends UniformCredentialOfferRequest {
20
24
  scheme: string;
21
25
  clientId?: string;
22
26
  baseUrl: string;
23
- userPinRequired: boolean;
27
+ txCode?: TxCode;
24
28
  issuerState?: string;
25
29
  preAuthorizedCode?: string;
30
+ userPinRequired: boolean;
26
31
  }
27
32
 
28
- export type CredentialOffer = CredentialOfferV1_0_09 | CredentialOfferV1_0_11;
33
+ export type CredentialOffer = CredentialOfferV1_0_09 | CredentialOfferV1_0_11 | CredentialOfferV1_0_13;
29
34
 
30
- export type CredentialOfferPayload = (CredentialOfferPayloadV1_0_08 | CredentialOfferPayloadV1_0_09 | CredentialOfferPayloadV1_0_11) & {
35
+ export type CredentialOfferPayloadLatest = CredentialOfferPayloadV1_0_13;
36
+
37
+ export type CredentialRequest = UniformCredentialRequest | CredentialRequestV1_0_13 | CredentialRequestV1_0_11 | CredentialRequestV1_0_08;
38
+
39
+ export type CredentialOfferPayload = (
40
+ | CredentialOfferPayloadV1_0_08
41
+ | CredentialOfferPayloadV1_0_09
42
+ | CredentialOfferPayloadV1_0_11
43
+ | CredentialOfferPayloadV1_0_13
44
+ ) & {
31
45
  [x: string]: any;
32
46
  };
33
47
 
@@ -46,7 +60,8 @@ export interface UniformCredentialOfferRequest extends AssertedUniformCredential
46
60
  supportedFlows: AuthzFlowType[];
47
61
  }
48
62
 
49
- export type UniformCredentialOfferPayload = CredentialOfferPayloadV1_0_11;
63
+ //todo: drop v11
64
+ export type UniformCredentialOfferPayload = CredentialOfferPayloadV1_0_11 | CredentialOfferPayloadV1_0_13;
50
65
 
51
66
  export interface ProofOfPossession {
52
67
  proof_type: 'jwt';
@@ -184,6 +199,7 @@ export interface JWTPayload {
184
199
  nonce?: string; // REQUIRED (string). The value type of this claim MUST be a string, where the value is a c_nonce provided by the credential issuer. //TODO: Marked as required not present in NGI flow
185
200
  jti?: string; // A new nonce chosen by the wallet. Used to prevent replay
186
201
  exp?: number; // Not longer than 5 minutes
202
+ client_id?: string; // (string). The value of this claim MUST be the client_id of the client making the credential request.
187
203
  [s: string]: unknown;
188
204
  }
189
205
 
@@ -196,6 +212,6 @@ export interface JwtVerifyResult<DIDDoc> {
196
212
  alg: string;
197
213
  did?: string;
198
214
  didDocument?: DIDDoc;
199
- x5c?: string;
215
+ x5c?: string[];
200
216
  jwk?: BaseJWK;
201
217
  }
@@ -1,9 +1,23 @@
1
1
  import { ICredentialContextType, IVerifiableCredential, W3CVerifiableCredential } from '@sphereon/ssi-types';
2
2
 
3
+ import { ExperimentalSubjectIssuance } from '../experimental/holder-vci';
4
+
3
5
  import { ProofOfPossession } from './CredentialIssuance.types';
4
6
  import { AuthorizationServerMetadata } from './ServerMetadata';
5
7
  import { CredentialOfferSession } from './StateManager.types';
6
- import { CredentialRequestV1_0_11 } from './v1_0_11.types';
8
+ import { IssuerMetadataV1_0_08 } from './v1_0_08.types';
9
+ import { CredentialRequestV1_0_11, EndpointMetadataResultV1_0_11 } from './v1_0_11.types';
10
+ import {
11
+ CredentialConfigurationSupportedV1_0_13,
12
+ CredentialRequestV1_0_13,
13
+ EndpointMetadataResultV1_0_13,
14
+ IssuerMetadataV1_0_13,
15
+ } from './v1_0_13.types';
16
+
17
+ export type InputCharSet = 'numeric' | 'text';
18
+ export type KeyProofType = 'jwt' | 'cwt' | 'ldp_vp';
19
+
20
+ export type PoPMode = 'pop' | 'jwt'; // Proof of posession, or regular JWT
7
21
 
8
22
  /**
9
23
  * Important Note: please be aware that these Common interfaces are based on versions v1_0.11 and v1_0.09
@@ -48,19 +62,50 @@ export interface CredentialSupplierConfig {
48
62
  export interface CredentialIssuerMetadataOpts {
49
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.
50
64
  batch_credential_endpoint?: string; // OPTIONAL. URL of the Credential Issuer's Batch Credential Endpoint. This URL MUST use the https scheme and MAY contain port, path and query parameter components. If omitted, the Credential Issuer does not support the Batch Credential Endpoint.
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.
65
+ credentials_supported: CredentialConfigurationSupported[]; // 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
66
  credential_issuer: string; // REQUIRED. The Credential Issuer's identifier.
53
67
  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].
55
68
  token_endpoint?: string;
69
+ notification_endpoint?: string;
56
70
  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:
57
71
  credential_supplier_config?: CredentialSupplierConfig;
58
72
  }
59
73
 
74
+ //todo: investigate if these values are enough.
75
+ export type AlgValue = 'RS256' | 'ES256' | 'PS256' | 'HS256' | string;
76
+ export type EncValue = 'A128GCM' | 'A256GCM' | 'A128CBC-HS256' | 'A256CBC-HS512' | string;
77
+
78
+ export interface ResponseEncryption {
79
+ /**
80
+ * REQUIRED. Array containing a list of the JWE [RFC7516] encryption algorithms
81
+ * (alg values) [RFC7518] supported by the Credential and Batch Credential Endpoint to encode the
82
+ * Credential or Batch Credential Response in a JWT
83
+ */
84
+ alg_values_supported: AlgValue[];
85
+
86
+ /**
87
+ * REQUIRED. Array containing a list of the JWE [RFC7516] encryption algorithms
88
+ * (enc values) [RFC7518] supported by the Credential and Batch Credential Endpoint to encode the
89
+ * Credential or Batch Credential Response in a JWT
90
+ */
91
+ enc_values_supported: EncValue[];
92
+
93
+ /**
94
+ * REQUIRED. Boolean value specifying whether the Credential Issuer requires the
95
+ * additional encryption on top of TLS for the Credential Response. If the value is true, the Credential
96
+ * Issuer requires encryption for every Credential Response and therefore the Wallet MUST provide
97
+ * encryption keys in the Credential Request. If the value is false, the Wallet MAY chose whether it
98
+ * provides encryption keys or not.
99
+ */
100
+ encryption_required: boolean;
101
+ }
102
+
60
103
  // 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
61
104
  export interface CredentialIssuerMetadata extends CredentialIssuerMetadataOpts, Partial<AuthorizationServerMetadata> {
62
105
  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].
63
106
  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.
107
+ credential_configurations_supported: Record<string, CredentialConfigurationSupported>; // 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.
108
+ credential_issuer: string; // REQUIRED. The Credential Issuer's identifier.
64
109
  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
110
  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
111
  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.
@@ -71,17 +116,25 @@ export interface CredentialIssuerMetadata extends CredentialIssuerMetadataOpts,
71
116
 
72
117
  export interface CredentialSupportedBrief {
73
118
  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
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
119
+ credential_signing_alg_values_supported?: string[]; // OPTIONAL. Array of case sensitive strings that identify the cryptographic suites that are supported for the cryptographic_binding_methods_supported
75
120
  }
76
121
 
77
- export type CommonCredentialSupported = CredentialSupportedBrief & {
78
- format: OID4VCICredentialFormat | string; //REQUIRED. A JSON string identifying the format of this credential, e.g. jwt_vc_json or ldp_vc.
79
- id?: string; // OPTIONAL. A JSON string identifying the respective object. The value MUST be unique across all credentials_supported entries in the Credential Issuer Metadata
80
- display?: CredentialsSupportedDisplay[]; // OPTIONAL. An array of objects, where each object contains the display properties of the supported credential for a certain language
81
- /**
82
- * following properties are non-mso_mdoc specific and we might wanna rethink them when we're going to support mso_mdoc
83
- */
84
- };
122
+ export interface ProofType {
123
+ proof_signing_alg_values_supported: string[];
124
+ }
125
+
126
+ export type CommonCredentialSupported = CredentialSupportedBrief &
127
+ ExperimentalSubjectIssuance & {
128
+ format: OID4VCICredentialFormat | string; //REQUIRED. A JSON string identifying the format of this credential, e.g. jwt_vc_json or ldp_vc.
129
+ id?: string; // OPTIONAL. A JSON string identifying the respective object. The value MUST be unique across all credentials_supported entries in the Credential Issuer Metadata
130
+ display?: CredentialsSupportedDisplay[]; // OPTIONAL. An array of objects, where each object contains the display properties of the supported credential for a certain language
131
+ scope?: string; // OPTIONAL. A JSON string identifying the scope value that this Credential Issuer supports for this particular Credential. The value can be the same across multiple credential_configurations_supported objects. The Authorization Server MUST be able to uniquely identify the Credential Issuer based on the scope value. The Wallet can use this value in the Authorization Request as defined in Section 5.1.2. Scope values in this Credential Issuer metadata MAY duplicate those in the scopes_supported parameter of the Authorization Server.
132
+ proof_types_supported?: Record<KeyProofType, ProofType>;
133
+
134
+ /**
135
+ * following properties are non-mso_mdoc specific and we might wanna rethink them when we're going to support mso_mdoc
136
+ */
137
+ };
85
138
 
86
139
  export interface CredentialSupportedJwtVcJsonLdAndLdpVc extends CommonCredentialSupported {
87
140
  types: string[]; // REQUIRED. JSON array designating the types a certain credential type supports
@@ -107,7 +160,11 @@ export interface CredentialSupportedSdJwtVc extends CommonCredentialSupported {
107
160
  order?: string[]; //An array of claims.display.name values that lists them in the order they should be displayed by the Wallet.
108
161
  }
109
162
 
110
- export type CredentialSupported = CommonCredentialSupported &
163
+ export type CredentialConfigurationSupported =
164
+ | CredentialConfigurationSupportedV1_0_13
165
+ | (CommonCredentialSupported & (CredentialSupportedJwtVcJson | CredentialSupportedJwtVcJsonLdAndLdpVc | CredentialSupportedSdJwtVc));
166
+
167
+ export type CredentialsSupportedLegacy = CommonCredentialSupported &
111
168
  (CredentialSupportedJwtVcJson | CredentialSupportedJwtVcJsonLdAndLdpVc | CredentialSupportedSdJwtVc);
112
169
 
113
170
  export interface CommonCredentialOfferFormat {
@@ -148,8 +205,7 @@ export type CreateCredentialOfferURIResult = {
148
205
  qrCodeDataUri?: string;
149
206
  session: CredentialOfferSession;
150
207
  userPin?: string;
151
- userPinLength?: number;
152
- userPinRequired: boolean;
208
+ txCode?: TxCode;
153
209
  };
154
210
 
155
211
  export interface JsonLdIssuerCredentialDefinition {
@@ -165,9 +221,9 @@ export interface ErrorResponse extends Response {
165
221
  state?: string;
166
222
  }
167
223
 
168
- export type UniformCredentialRequest = CredentialRequestV1_0_11;
224
+ export type UniformCredentialRequest = CredentialRequestV1_0_11 | CredentialRequestV1_0_13;
169
225
 
170
- export interface CommonCredentialRequest {
226
+ export interface CommonCredentialRequest extends ExperimentalSubjectIssuance {
171
227
  format: OID4VCICredentialFormat /* | OID4VCICredentialFormat[];*/; // for now it seems only one is supported in the spec
172
228
  proof?: ProofOfPossession;
173
229
  }
@@ -189,8 +245,8 @@ export interface CredentialRequestSdJwtVc extends CommonCredentialRequest {
189
245
  claims?: IssuerCredentialSubject;
190
246
  }
191
247
 
192
- export interface CommonCredentialResponse {
193
- format: string;
248
+ export interface CommonCredentialResponse extends ExperimentalSubjectIssuance {
249
+ // format: string; TODO do we still need this for previous version support?
194
250
  credential?: W3CVerifiableCredential;
195
251
  acceptance_token?: string;
196
252
  c_nonce?: string;
@@ -198,17 +254,17 @@ export interface CommonCredentialResponse {
198
254
  }
199
255
 
200
256
  export interface CredentialResponseLdpVc extends CommonCredentialResponse {
201
- format: 'ldp_vc';
257
+ // format: 'ldp_vc';
202
258
  credential: IVerifiableCredential;
203
259
  }
204
260
 
205
261
  export interface CredentialResponseJwtVc {
206
- format: 'jwt_vc_json' | 'jwt_vc_json-ld';
262
+ // format: 'jwt_vc_json' | 'jwt_vc_json-ld'; TODO do we still need this for previous version support?
207
263
  credential: string;
208
264
  }
209
265
 
210
266
  export interface CredentialResponseSdJwtVc {
211
- format: 'vc+sd-jwt';
267
+ // format: 'vc+sd-jwt'; TODO do we still need this for previous version support?
212
268
  credential: string;
213
269
  }
214
270
 
@@ -245,28 +301,95 @@ export interface GrantAuthorizationCode {
245
301
  authorization_server?: string;
246
302
  }
247
303
 
304
+ export interface TxCode {
305
+ /**
306
+ * OPTIONAL. String specifying the input character set. Possible values are numeric (only digits) and text (any characters). The default is numeric.
307
+ */
308
+ input_mode?: InputCharSet;
309
+
310
+ /**
311
+ * OPTIONAL. Integer specifying the length of the Transaction Code. This helps the Wallet to render the input screen and improve the user experience.
312
+ */
313
+ length?: number;
314
+
315
+ /**
316
+ * OPTIONAL. String containing guidance for the Holder of the Wallet on how to obtain the Transaction Code, e.g.,
317
+ * describing over which communication channel it is delivered. The Wallet is RECOMMENDED to display this description
318
+ * next to the Transaction Code input screen to improve the user experience. The length of the string MUST NOT exceed
319
+ * 300 characters. The description does not support internationalization, however the Issuer MAY detect the Holder's
320
+ * language by previous communication or an HTTP Accept-Language header within an HTTP GET request for a Credential Offer URI.
321
+ */
322
+ description?: string;
323
+ }
324
+
248
325
  export interface GrantUrnIetf {
249
326
  /**
250
327
  * REQUIRED. The code representing the Credential Issuer's authorization for the Wallet to obtain Credentials of a certain type.
251
328
  */
329
+ // v12, v13
252
330
  'pre-authorized_code': string;
331
+ // v13
253
332
  /**
254
- * OPTIONAL. Boolean value specifying whether the Credential Issuer expects presentation of a user PIN along with the Token Request
255
- * in a Pre-Authorized Code Flow. Default is false.
333
+ * OPTIONAL. Object specifying whether the Authorization Server expects presentation of a Transaction Code by the
334
+ * End-User along with the Token Request in a Pre-Authorized Code Flow. If the Authorization Server does not expect a
335
+ * Transaction Code, this object is absent; this is the default. The Transaction Code is intended to bind the Pre-Authorized
336
+ * Code to a certain transaction to prevent replay of this code by an attacker that, for example, scanned the QR code while
337
+ * standing behind the legitimate End-User. It is RECOMMENDED to send the Transaction Code via a separate channel. If the Wallet
338
+ * decides to use the Pre-Authorized Code Flow, the Transaction Code value MUST be sent in the tx_code parameter with
339
+ * the respective Token Request as defined in Section 6.1. If no length or description is given, this object may be empty,
340
+ * indicating that a Transaction Code is required.
256
341
  */
257
- user_pin_required: boolean;
342
+ tx_code?: TxCode;
258
343
 
259
- //v12
344
+ // v12, v13
260
345
  /**
261
346
  * 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
347
  */
263
348
  interval?: number;
264
349
 
265
- // v12 feature
350
+ // v12, v13 feature
266
351
  /**
267
352
  * 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
353
  */
269
354
  authorization_server?: string;
355
+
356
+ // v12 feature
357
+ /**
358
+ * OPTIONAL. Boolean value specifying whether the AS
359
+ * expects presentation of the End-User PIN along with the Token Request
360
+ * in a Pre-Authorized Code Flow. Default is false. This PIN is intended
361
+ * to bind the Pre-Authorized Code to a certain transaction to prevent
362
+ * replay of this code by an attacker that, for example, scanned the QR
363
+ * code while standing behind the legitimate End-User. It is RECOMMENDED
364
+ * to send a PIN via a separate channel. If the Wallet decides to use
365
+ * the Pre-Authorized Code Flow, a PIN value MUST be sent in
366
+ * the user_pin parameter with the respective Token Request.
367
+ */
368
+ user_pin_required?: boolean;
270
369
  }
271
370
 
272
371
  export const PRE_AUTH_CODE_LITERAL = 'pre-authorized_code';
372
+
373
+ export type EndpointMetadataResult = EndpointMetadataResultV1_0_13 | EndpointMetadataResultV1_0_11;
374
+
375
+ export type IssuerMetadata = IssuerMetadataV1_0_13 | IssuerMetadataV1_0_08;
376
+
377
+ export type NotificationEventType = 'credential_accepted' | 'credential_failure' | 'credential_deleted';
378
+
379
+ export interface NotificationRequest {
380
+ notification_id: string;
381
+ event: NotificationEventType | string;
382
+ event_description?: string;
383
+ credential?: any; // Experimental support to have a wallet sign a credential. Not part of the spec
384
+ }
385
+
386
+ export type NotificationError = 'invalid_notification_id' | 'invalid_notification_request';
387
+
388
+ export type NotificationResult = {
389
+ error: boolean;
390
+ response?: NotificationErrorResponse;
391
+ };
392
+
393
+ export interface NotificationErrorResponse {
394
+ error: NotificationError | string;
395
+ }
@@ -37,3 +37,4 @@ export const STATE_MANAGER_REQUIRED_ERROR = 'StateManager instance is required';
37
37
  export const NONCE_STATE_MANAGER_REQUIRED_ERROR = 'NonceStateManager instance is required';
38
38
  export const PIN_NOT_MATCHING_ERROR = 'PIN does not match';
39
39
  export const ACCESS_TOKEN_ISSUER_REQUIRED_ERROR = 'access token issuer is required';
40
+ export const WRONG_METADATA_FORMAT = 'Wrong metadata format';
@@ -3,6 +3,7 @@ export enum OpenId4VCIVersion {
3
3
  VER_1_0_09 = 1009,
4
4
  VER_1_0_11 = 1011,
5
5
  VER_1_0_12 = 1012,
6
+ VER_1_0_13 = 1013,
6
7
  VER_UNKNOWN = Number.MAX_VALUE,
7
8
  }
8
9
 
@@ -1,6 +1,3 @@
1
- import { CredentialIssuerMetadata } from './Generic.types';
2
- import { IssuerMetadataV1_0_08 } from './v1_0_08.types';
3
-
4
1
  export interface AuthorizationServerMetadata {
5
2
  issuer: string;
6
3
  authorization_endpoint?: string;
@@ -71,10 +68,3 @@ export interface EndpointMetadata {
71
68
  authorization_server?: string;
72
69
  authorization_endpoint?: string; // Can be undefined in pre-auth flow
73
70
  }
74
- export interface EndpointMetadataResult extends EndpointMetadata {
75
- // The EndpointMetadata are snake-case so they can easily be used in payloads/JSON.
76
- // The values below should not end up in requests/responses directly, so they are using our normal CamelCase convention
77
- authorizationServerType: AuthorizationServerType;
78
- authorizationServerMetadata?: AuthorizationServerMetadata;
79
- credentialIssuerMetadata?: Partial<AuthorizationServerMetadata> & (CredentialIssuerMetadata | IssuerMetadataV1_0_08);
80
- }
@@ -13,6 +13,7 @@ export interface CredentialOfferSession extends StateType {
13
13
  status: IssueStatus;
14
14
  error?: string;
15
15
  lastUpdatedAt: number;
16
+ notification_id: string;
16
17
  issuerState?: string; //todo: Probably good to hash it here, since it would come in from the client and we could match the hash and thus use the client value
17
18
  preAuthorizedCode?: string; //todo: Probably good to hash it here, since it would come in from the client and we could match the hash and thus use the client value
18
19
  }
@@ -4,6 +4,7 @@ export * from './Generic.types';
4
4
  export * from './v1_0_08.types';
5
5
  export * from './v1_0_09.types';
6
6
  export * from './v1_0_11.types';
7
+ export * from './v1_0_13.types';
7
8
  export * from './ServerMetadata';
8
9
  export * from './OpenID4VCIErrors';
9
10
  export * from './OpenID4VCIVersions.types';
@@ -1,4 +1,7 @@
1
- import { AuthorizationDetailsJwtVcJson, CommonAuthorizationRequest } from './Authorization.types';
1
+ import { ExperimentalSubjectIssuance } from '../experimental/holder-vci';
2
+
3
+ import { AuthorizationDetailsJwtVcJson, AuthorizationServerOpts, CommonAuthorizationRequest } from './Authorization.types';
4
+ import { UniformCredentialOffer, UniformCredentialOfferRequest } from './CredentialIssuance.types';
2
5
  import {
3
6
  CommonCredentialRequest,
4
7
  CredentialDataSupplierInput,
@@ -10,14 +13,26 @@ import {
10
13
  Grant,
11
14
  } from './Generic.types';
12
15
  import { QRCodeOpts } from './QRCode.types';
13
- import { AuthorizationServerMetadata } from './ServerMetadata';
16
+ import { AuthorizationServerMetadata, AuthorizationServerType, EndpointMetadata } from './ServerMetadata';
17
+ import { IssuerMetadataV1_0_08 } from './v1_0_08.types';
18
+
19
+ export interface AccessTokenRequestOptsV1_0_11 {
20
+ credentialOffer?: UniformCredentialOffer;
21
+ credentialIssuer?: string;
22
+ asOpts?: AuthorizationServerOpts;
23
+ metadata?: EndpointMetadata;
24
+ codeVerifier?: string; // only required for authorization flow
25
+ code?: string; // only required for authorization flow
26
+ redirectUri?: string; // only required for authorization flow
27
+ pin?: string; // Pin-number. Only used when required
28
+ }
14
29
 
15
30
  export interface CredentialOfferV1_0_11 {
16
31
  credential_offer?: CredentialOfferPayloadV1_0_11;
17
32
  credential_offer_uri?: string;
18
33
  }
19
34
 
20
- export interface CredentialOfferRESTRequest extends CredentialOfferV1_0_11 {
35
+ export interface CredentialOfferRESTRequestV1_0_11 extends CredentialOfferV1_0_11 {
21
36
  baseUri?: string;
22
37
  scheme?: string;
23
38
  pinLength?: number;
@@ -25,6 +40,15 @@ export interface CredentialOfferRESTRequest extends CredentialOfferV1_0_11 {
25
40
  credentialDataSupplierInput?: CredentialDataSupplierInput;
26
41
  }
27
42
 
43
+ export interface CredentialOfferRequestWithBaseUrlV1_0_11 extends UniformCredentialOfferRequest {
44
+ scheme: string;
45
+ clientId?: string;
46
+ baseUrl: string;
47
+ userPinRequired: boolean;
48
+ issuerState?: string;
49
+ preAuthorizedCode?: string;
50
+ }
51
+
28
52
  export interface CredentialOfferPayloadV1_0_11 {
29
53
  /**
30
54
  * REQUIRED. The URL of the Credential Issuer, the Wallet is requested to obtain one or more Credentials from.
@@ -58,11 +82,16 @@ export interface CredentialOfferPayloadV1_0_11 {
58
82
  }
59
83
 
60
84
  export type CredentialRequestV1_0_11 = CommonCredentialRequest &
85
+ ExperimentalSubjectIssuance &
61
86
  (CredentialRequestJwtVcJson | CredentialRequestJwtVcJsonLdAndLdpVc | CredentialRequestSdJwtVc);
62
87
 
63
88
  export interface CredentialIssuerMetadataV1_0_11 extends CredentialIssuerMetadataOpts, Partial<AuthorizationServerMetadata> {
89
+ 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].
64
90
  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.
65
- authorization_server?: string;
91
+ 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].
92
+ 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].
93
+ 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.
94
+ 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.
66
95
  }
67
96
 
68
97
  export interface AuthorizationRequestV1_0_11 extends AuthorizationDetailsJwtVcJson, AuthorizationDetailsJwtVcJson {
@@ -73,3 +102,11 @@ export interface AuthorizationRequestV1_0_11 extends AuthorizationDetailsJwtVcJs
73
102
  export function isAuthorizationRequestV1_0_11(request: CommonAuthorizationRequest): boolean {
74
103
  return request && 'issuer_state' in request;
75
104
  }
105
+
106
+ export interface EndpointMetadataResultV1_0_11 extends EndpointMetadata {
107
+ // The EndpointMetadata are snake-case so they can easily be used in payloads/JSON.
108
+ // The values below should not end up in requests/responses directly, so they are using our normal CamelCase convention
109
+ authorizationServerType: AuthorizationServerType;
110
+ authorizationServerMetadata?: AuthorizationServerMetadata;
111
+ credentialIssuerMetadata?: Partial<AuthorizationServerMetadata> & IssuerMetadataV1_0_08;
112
+ }
@@ -1,4 +1,42 @@
1
- import { CommonCredentialRequest, CredentialRequestJwtVcJson, CredentialRequestJwtVcJsonLdAndLdpVc, CredentialRequestSdJwtVc } from './Generic.types';
1
+ import {
2
+ CommonCredentialRequest,
3
+ CredentialRequestJwtVcJson,
4
+ CredentialRequestJwtVcJsonLdAndLdpVc,
5
+ CredentialRequestSdJwtVc,
6
+ Grant,
7
+ } from './Generic.types';
2
8
 
3
9
  export type CredentialRequestV1_0_12 = CommonCredentialRequest &
4
10
  (CredentialRequestJwtVcJson | CredentialRequestJwtVcJsonLdAndLdpVc | CredentialRequestSdJwtVc);
11
+
12
+ export interface CredentialOfferPayloadV1_0_12 {
13
+ /**
14
+ * REQUIRED. The URL of the Credential Issuer, as defined in Section 11.2.1, from which the Wallet is requested to
15
+ * obtain one or more Credentials. The Wallet uses it to obtain the Credential Issuer's Metadata following the steps
16
+ * defined in Section 11.2.2.
17
+ */
18
+ credential_issuer: string;
19
+
20
+ /**
21
+ * REQUIRED. Array of unique strings that each identify one of the keys in the name/value pairs stored in
22
+ * the credential_configurations_supported Credential Issuer metadata. The Wallet uses these string values
23
+ * to obtain the respective object that contains information about the Credential being offered as defined
24
+ * in Section 11.2.3. For example, these string values can be used to obtain scope values to be used in
25
+ * the Authorization Request.
26
+ */
27
+ credential_configurations: string[];
28
+ /**
29
+ * OPTIONAL. A JSON object indicating to the Wallet the Grant Types the Credential Issuer's AS is prepared
30
+ * to process for this credential offer. Every grant is represented by a key and an object.
31
+ * The key value is the Grant Type identifier, the object MAY contain parameters either determining the way
32
+ * the Wallet MUST use the particular grant and/or parameters the Wallet MUST send with the respective request(s).
33
+ * If grants is not present or empty, the Wallet MUST determine the Grant Types the Credential Issuer's AS supports
34
+ * using the respective metadata. When multiple grants are present, it's at the Wallet's discretion which one to use.
35
+ */
36
+ grants?: Grant;
37
+
38
+ /**
39
+ * 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)
40
+ */
41
+ client_id?: string;
42
+ }