@sphereon/oid4vci-common 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.
- package/LICENSE +201 -0
- package/dist/functions/CredentialOfferUtil.d.ts +6 -0
- package/dist/functions/CredentialOfferUtil.d.ts.map +1 -0
- package/dist/functions/CredentialOfferUtil.js +53 -0
- package/dist/functions/CredentialOfferUtil.js.map +1 -0
- package/dist/functions/Encoding.d.ts +4 -0
- package/dist/functions/Encoding.d.ts.map +1 -0
- package/dist/functions/Encoding.js +87 -0
- package/dist/functions/Encoding.js.map +1 -0
- package/dist/functions/TypeConversionUtils.d.ts +2 -0
- package/dist/functions/TypeConversionUtils.d.ts.map +1 -0
- package/dist/functions/TypeConversionUtils.js +8 -0
- package/dist/functions/TypeConversionUtils.js.map +1 -0
- package/dist/functions/index.d.ts +4 -0
- package/dist/functions/index.d.ts.map +1 -0
- package/dist/functions/index.js +20 -0
- package/dist/functions/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/types/Authorization.types.d.ts +198 -0
- package/dist/types/Authorization.types.d.ts.map +1 -0
- package/dist/types/Authorization.types.js +40 -0
- package/dist/types/Authorization.types.js.map +1 -0
- package/dist/types/CredentialIssuance.types.d.ts +134 -0
- package/dist/types/CredentialIssuance.types.d.ts.map +1 -0
- package/dist/types/CredentialIssuance.types.js +21 -0
- package/dist/types/CredentialIssuance.types.js.map +1 -0
- package/dist/types/Generic.types.d.ts +182 -0
- package/dist/types/Generic.types.d.ts.map +1 -0
- package/dist/types/Generic.types.js +31 -0
- package/dist/types/Generic.types.js.map +1 -0
- package/dist/types/OAuth2ASMetadata.d.ts +41 -0
- package/dist/types/OAuth2ASMetadata.d.ts.map +1 -0
- package/dist/types/OAuth2ASMetadata.js +3 -0
- package/dist/types/OAuth2ASMetadata.js.map +1 -0
- package/dist/types/OpenID4VCIErrors.d.ts +34 -0
- package/dist/types/OpenID4VCIErrors.d.ts.map +1 -0
- package/dist/types/OpenID4VCIErrors.js +38 -0
- package/dist/types/OpenID4VCIErrors.js.map +1 -0
- package/dist/types/OpenID4VCIServerMetadata.d.ts +23 -0
- package/dist/types/OpenID4VCIServerMetadata.d.ts.map +1 -0
- package/dist/types/OpenID4VCIServerMetadata.js +3 -0
- package/dist/types/OpenID4VCIServerMetadata.js.map +1 -0
- package/dist/types/OpenID4VCIVersions.types.d.ts +10 -0
- package/dist/types/OpenID4VCIVersions.types.d.ts.map +1 -0
- package/dist/types/OpenID4VCIVersions.types.js +15 -0
- package/dist/types/OpenID4VCIVersions.types.js.map +1 -0
- package/dist/types/StateManager.types.d.ts +21 -0
- package/dist/types/StateManager.types.d.ts.map +1 -0
- package/dist/types/StateManager.types.js +3 -0
- package/dist/types/StateManager.types.js.map +1 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +27 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/v1_0_08.types.d.ts +24 -0
- package/dist/types/v1_0_08.types.d.ts.map +1 -0
- package/dist/types/v1_0_08.types.js +3 -0
- package/dist/types/v1_0_08.types.js.map +1 -0
- package/dist/types/v1_0_09.types.d.ts +17 -0
- package/dist/types/v1_0_09.types.d.ts.map +1 -0
- package/dist/types/v1_0_09.types.js +14 -0
- package/dist/types/v1_0_09.types.js.map +1 -0
- package/dist/types/v1_0_11.types.d.ts +49 -0
- package/dist/types/v1_0_11.types.d.ts.map +1 -0
- package/dist/types/v1_0_11.types.js +14 -0
- package/dist/types/v1_0_11.types.js.map +1 -0
- package/lib/__tests__/CredentialOfferUtil.spec.ts +55 -0
- package/lib/functions/CredentialOfferUtil.ts +58 -0
- package/lib/functions/Encoding.ts +83 -0
- package/lib/functions/TypeConversionUtils.ts +3 -0
- package/lib/functions/index.ts +3 -0
- package/lib/index.ts +2 -0
- package/lib/types/Authorization.types.ts +234 -0
- package/lib/types/CredentialIssuance.types.ts +160 -0
- package/lib/types/Generic.types.ts +215 -0
- package/lib/types/OAuth2ASMetadata.ts +49 -0
- package/lib/types/OpenID4VCIErrors.ts +35 -0
- package/lib/types/OpenID4VCIServerMetadata.ts +31 -0
- package/lib/types/OpenID4VCIVersions.types.ts +10 -0
- package/lib/types/StateManager.types.ts +29 -0
- package/lib/types/index.ts +11 -0
- package/lib/types/v1_0_08.types.ts +25 -0
- package/lib/types/v1_0_09.types.ts +27 -0
- package/lib/types/v1_0_11.types.ts +63 -0
- package/package.json +47 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { ICredentialContextType, IVerifiableCredential, W3CVerifiableCredential } from '@sphereon/ssi-types';
|
|
2
|
+
|
|
3
|
+
import { ProofOfPossession } from './CredentialIssuance.types';
|
|
4
|
+
import { Oauth2ASWithOID4VCIMetadata } from './OpenID4VCIServerMetadata';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Important Note: please be aware that these Common interfaces are based on versions v1_0.11 and v1_0.09
|
|
8
|
+
*/
|
|
9
|
+
export interface CredentialLogo {
|
|
10
|
+
url?: string;
|
|
11
|
+
alt_text?: string;
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export enum CredentialFormatEnum {
|
|
16
|
+
jwt_vc_json = 'jwt_vc_json',
|
|
17
|
+
jwt_vc_json_ld = 'jwt_vc_json_ld',
|
|
18
|
+
ldp_vc = 'ldp_vc',
|
|
19
|
+
mso_mdoc = 'mso_mdoc',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface NameAndLocale {
|
|
23
|
+
name?: string;
|
|
24
|
+
locale?: string;
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface LogoAndColor {
|
|
29
|
+
logo?: CredentialLogo;
|
|
30
|
+
background_color?: string;
|
|
31
|
+
text_color?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type Display = NameAndLocale & LogoAndColor;
|
|
35
|
+
|
|
36
|
+
export interface IssuerMetadata {
|
|
37
|
+
credential_endpoint: string;
|
|
38
|
+
batch_credential_endpoint?: string;
|
|
39
|
+
credentials_supported: CredentialSupported[];
|
|
40
|
+
credential_issuer: string; // REQUIRED. The URL of the Credential Issuer, the Wallet is requested to obtain one or more Credentials from.
|
|
41
|
+
authorization_server?: string;
|
|
42
|
+
token_endpoint?: string;
|
|
43
|
+
display?: Display[];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface CredentialSupportedBrief {
|
|
47
|
+
name?: string;
|
|
48
|
+
types: string[]; // REQUIRED. JSON array designating the types a certain credential type supports
|
|
49
|
+
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
|
|
50
|
+
cryptographic_suites_supported?: string[]; // OPTIONAL. Array of case sensitive strings that identify the cryptographic suites that are supported for the cryptographic_binding_methods_supported
|
|
51
|
+
}
|
|
52
|
+
export type CommonCredentialSupported = CredentialSupportedBrief & {
|
|
53
|
+
format: CredentialFormatEnum | string; //REQUIRED. A JSON string identifying the format of this credential, e.g. jwt_vc_json or ldp_vc.
|
|
54
|
+
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
|
|
55
|
+
display?: Display[]; // OPTIONAL. An array of objects, where each object contains the display properties of the supported credential for a certain language
|
|
56
|
+
/**
|
|
57
|
+
* following properties are non-mso_mdoc specific and we might wanna rethink them when we're going to support mso_mdoc
|
|
58
|
+
*/
|
|
59
|
+
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.
|
|
60
|
+
order?: string[]; //An array of claims.display.name values that lists them in the order they should be displayed by the Wallet.
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export interface CredentialSupportedJwtVcJsonLdAndLdpVc extends CommonCredentialSupported {
|
|
64
|
+
'@context': ICredentialContextType[]; // REQUIRED. JSON array as defined in [VC_DATA], Section 4.1.
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type CredentialSupportedJwtVcJson = CommonCredentialSupported;
|
|
68
|
+
|
|
69
|
+
export type CredentialSupported = CredentialSupportedJwtVcJson | CredentialSupportedJwtVcJsonLdAndLdpVc;
|
|
70
|
+
|
|
71
|
+
export interface CredentialOfferFormat {
|
|
72
|
+
format: CredentialFormatEnum;
|
|
73
|
+
types: string[];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface IssuerCredentialDefinition {
|
|
77
|
+
'@context': ICredentialContextType[];
|
|
78
|
+
types: string[];
|
|
79
|
+
credentialSubject: IssuerCredentialSubject;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface CredentialOfferCredentialDefinition {
|
|
83
|
+
'@context': ICredentialContextType[];
|
|
84
|
+
types: string[];
|
|
85
|
+
CredentialSubject?: IssuerCredentialSubject;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export enum GrantType {
|
|
89
|
+
AUTHORIZATION_CODE = 'authorization_code',
|
|
90
|
+
PRE_AUTHORIZED_CODE = 'urn:ietf:params:oauth:grant-type:pre-authorized_code',
|
|
91
|
+
PASSWORD = 'password',
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface CommonAccessTokenRequest {
|
|
95
|
+
client_id?: string;
|
|
96
|
+
code?: string;
|
|
97
|
+
code_verifier?: string;
|
|
98
|
+
grant_type: GrantType;
|
|
99
|
+
'pre-authorized_code'?: string;
|
|
100
|
+
redirect_uri?: string;
|
|
101
|
+
scope?: string;
|
|
102
|
+
user_pin?: string;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export enum TokenErrorResponse {
|
|
106
|
+
invalid_request = 'invalid_request',
|
|
107
|
+
invalid_grant = 'invalid_grant',
|
|
108
|
+
invalid_client = 'invalid_client', // this code has been added only in v1_0-11, but I've added this to the common interface. @nklomp is this ok?
|
|
109
|
+
invalid_scope = 'invalid_scope',
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface CommonAccessTokenResponse {
|
|
113
|
+
access_token: string;
|
|
114
|
+
scope?: string;
|
|
115
|
+
token_type?: string;
|
|
116
|
+
expires_in?: number; // in seconds
|
|
117
|
+
c_nonce?: string;
|
|
118
|
+
c_nonce_expires_in?: number; // in seconds
|
|
119
|
+
authorization_pending?: boolean;
|
|
120
|
+
interval?: number; // in seconds
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface ErrorResponse extends Response {
|
|
124
|
+
error: string;
|
|
125
|
+
error_description?: string;
|
|
126
|
+
error_uri?: string;
|
|
127
|
+
state?: string;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface CommonCredentialRequest {
|
|
131
|
+
format: string;
|
|
132
|
+
proof?: ProofOfPossession;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface CredentialRequestJwtVcJson extends CommonCredentialRequest {
|
|
136
|
+
format: CredentialFormatEnum.jwt_vc_json;
|
|
137
|
+
types: string[];
|
|
138
|
+
credentialSubject?: IssuerCredentialSubject;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export interface CredentialRequestJwtVcJsonLdAndLdpVc extends CommonCredentialRequest {
|
|
142
|
+
format: CredentialFormatEnum.jwt_vc_json_ld | CredentialFormatEnum.ldp_vc;
|
|
143
|
+
credential_definition: IssuerCredentialDefinition;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface CommonCredentialResponse {
|
|
147
|
+
format: string;
|
|
148
|
+
credential?: W3CVerifiableCredential;
|
|
149
|
+
acceptance_token?: string;
|
|
150
|
+
c_nonce?: string;
|
|
151
|
+
c_nonce_expires_in?: string;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface CredentialResponseJwtVcJsonLdAndLdpVc extends CommonCredentialResponse {
|
|
155
|
+
format: CredentialFormatEnum.jwt_vc_json_ld | CredentialFormatEnum.ldp_vc;
|
|
156
|
+
credential: IVerifiableCredential;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export type IssuerCredentialSubjectDisplay = CredentialSubjectDisplay & Record<string, CredentialSubjectDisplay>;
|
|
160
|
+
|
|
161
|
+
export interface CredentialSubjectDisplay {
|
|
162
|
+
mandatory?: boolean;
|
|
163
|
+
value_type?: string;
|
|
164
|
+
display?: Display[];
|
|
165
|
+
order?: string[]; // An array of claims.display.name values that lists them in the order they should be displayed by the Wallet.
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface IssuerCredentialSubject {
|
|
169
|
+
[key: string]: IssuerCredentialSubjectDisplay;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export interface CredentialResponseJwtVcJson {
|
|
173
|
+
credential: string;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export interface Grant {
|
|
177
|
+
authorization_code?: GrantAuthorizationCode;
|
|
178
|
+
'urn:ietf:params:oauth:grant-type:pre-authorized_code'?: GrantUrnIetf;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export interface GrantAuthorizationCode {
|
|
182
|
+
/**
|
|
183
|
+
* OPTIONAL. String value created by the Credential Issuer and opaque to the Wallet that is used to bind the subsequent
|
|
184
|
+
* Authorization Request with the Credential Issuer to a context set up during previous steps.
|
|
185
|
+
*/
|
|
186
|
+
issuer_state?: string;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export interface GrantUrnIetf {
|
|
190
|
+
/**
|
|
191
|
+
* REQUIRED. The code representing the Credential Issuer's authorization for the Wallet to obtain Credentials of a certain type.
|
|
192
|
+
*/
|
|
193
|
+
'pre-authorized_code': string;
|
|
194
|
+
/**
|
|
195
|
+
* OPTIONAL. Boolean value specifying whether the Credential Issuer expects presentation of a user PIN along with the Token Request
|
|
196
|
+
* in a Pre-Authorized Code Flow. Default is false.
|
|
197
|
+
*/
|
|
198
|
+
user_pin_required: boolean;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export const PRE_AUTH_CODE_LITERAL = 'pre-authorized_code';
|
|
202
|
+
|
|
203
|
+
export enum WellKnownEndpoints {
|
|
204
|
+
OPENID_CONFIGURATION = '/.well-known/openid-configuration',
|
|
205
|
+
OAUTH_AS = '/.well-known/oauth-authorization-server',
|
|
206
|
+
OPENID4VCI_ISSUER = '/.well-known/openid-credential-issuer',
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export interface EndpointMetadata {
|
|
210
|
+
issuer: string;
|
|
211
|
+
token_endpoint: string;
|
|
212
|
+
credential_endpoint: string;
|
|
213
|
+
authorization_endpoint?: string;
|
|
214
|
+
issuerMetadata?: IssuerMetadata | Oauth2ASWithOID4VCIMetadata;
|
|
215
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export interface OAuth2ASMetadata {
|
|
2
|
+
issuer: string;
|
|
3
|
+
authorization_endpoint?: string;
|
|
4
|
+
token_endpoint?: string;
|
|
5
|
+
token_endpoint_auth_methods_supported?: string[];
|
|
6
|
+
token_endpoint_auth_signing_alg_values_supported?: string[];
|
|
7
|
+
|
|
8
|
+
jwks_uri?: string;
|
|
9
|
+
registration_endpoint?: string;
|
|
10
|
+
scopes_supported?: string[];
|
|
11
|
+
response_types_supported: string[];
|
|
12
|
+
response_modes_supported?: string[];
|
|
13
|
+
grant_types_supported?: string[];
|
|
14
|
+
service_documentation?: string;
|
|
15
|
+
ui_locales_supported?: string[];
|
|
16
|
+
op_policy_uri?: string;
|
|
17
|
+
op_tos_uri?: string;
|
|
18
|
+
|
|
19
|
+
revocation_endpoint?: string;
|
|
20
|
+
revocation_endpoint_auth_methods_supported?: string[];
|
|
21
|
+
revocation_endpoint_auth_signing_alg_values_supported?: string[];
|
|
22
|
+
|
|
23
|
+
introspection_endpoint?: string;
|
|
24
|
+
code_challenge_methods_supported?: string[];
|
|
25
|
+
|
|
26
|
+
pushed_authorization_request_endpoint?: string; // The URL of the pushed authorization request endpoint at which a client can post an authorization request to exchange for a request_uri value usable at the authorization server
|
|
27
|
+
// Note that the presence of pushed_authorization_request_endpoint is sufficient for a client to determine that it may use the PAR flow. A request_uri value obtained from the PAR endpoint is usable at the authorization endpoint regardless of other authorization server metadata such as request_uri_parameter_supported or require_request_uri_registration
|
|
28
|
+
require_pushed_authorization_requests?: boolean; // Boolean parameter indicating whether Indicates whether the client is required to use PAR to initiate authorization. If omitted, the default value is false.
|
|
29
|
+
'pre-authorized_grant_anonymous_access_supported': boolean; // OPTIONAL. A JSON Boolean indicating whether the issuer accepts a Token Request with a Pre-Authorized Code but without a client id. The default is false
|
|
30
|
+
|
|
31
|
+
// OIDC values
|
|
32
|
+
frontchannel_logout_supported?: boolean;
|
|
33
|
+
frontchannel_logout_session_supported?: boolean;
|
|
34
|
+
backchannel_logout_supported?: boolean;
|
|
35
|
+
backchannel_logout_session_supported?: boolean;
|
|
36
|
+
userinfo_endpoint?: string;
|
|
37
|
+
check_session_iframe?: string;
|
|
38
|
+
end_session_endpoint?: string;
|
|
39
|
+
acr_values_supported?: string[];
|
|
40
|
+
subject_types_supported?: string[];
|
|
41
|
+
request_object_signing_alg_values_supported?: string[];
|
|
42
|
+
display_values_supported?: string[];
|
|
43
|
+
claim_types_supported?: string[];
|
|
44
|
+
claims_supported?: string[];
|
|
45
|
+
claims_parameter_supported?: boolean;
|
|
46
|
+
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
|
+
[x: string]: any; //We use any, so you can access properties if you know the structure
|
|
49
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Alg } from './CredentialIssuance.types';
|
|
2
|
+
|
|
3
|
+
export const BAD_PARAMS = 'Wrong parameters provided';
|
|
4
|
+
export const URL_NOT_VALID = 'Request url is not valid';
|
|
5
|
+
export const JWS_NOT_VALID = 'JWS is not valid';
|
|
6
|
+
export const PROOF_CANT_BE_CONSTRUCTED = "Proof can't be constructed.";
|
|
7
|
+
export const NO_JWT_PROVIDED = 'No JWT provided';
|
|
8
|
+
export const TYP_ERROR = 'Typ must be "openid4vci-proof+jwt"';
|
|
9
|
+
export const ALG_ERROR = `Algorithm is a required field and must be one of: ${Object.keys(Alg).join(', ')}`;
|
|
10
|
+
export const KID_JWK_X5C_ERROR = 'Only one must be present: kid, jwk or x5c';
|
|
11
|
+
export const AUD_ERROR = 'aud must be the URL of the credential issuer';
|
|
12
|
+
export const IAT_ERROR = 'iat must be the time at which the proof was issued';
|
|
13
|
+
export const NONCE_ERROR = 'nonce must be c_nonce provided by the credential issuer';
|
|
14
|
+
export const JWT_VERIFY_CONFIG_ERROR = 'JWT verify callback not configured correctly.';
|
|
15
|
+
export const ISSUER_CONFIG_ERROR = 'Issuer not configured correctly.';
|
|
16
|
+
export const UNKNOWN_CLIENT_ERROR = 'The client is not known by the issuer';
|
|
17
|
+
export const NO_ISS_IN_AUTHORIZATION_CODE_CONTEXT = 'iss missing in authorization-code context';
|
|
18
|
+
export const ISS_PRESENT_IN_PRE_AUTHORIZED_CODE_CONTEXT = 'iss should be omitted in pre-authorized-code context';
|
|
19
|
+
export const ISS_MUST_BE_CLIENT_ID = 'iss must be the client id';
|
|
20
|
+
export const GRANTS_MUST_NOT_BE_UNDEFINED = 'Grants must not be undefined';
|
|
21
|
+
export const C_NONCE_MISSING_ERROR = 'c_nonce must be present';
|
|
22
|
+
export const CREDENTIAL_MISSING_ERROR = 'Credential must be present in response';
|
|
23
|
+
export const UNSUPPORTED_GRANT_TYPE_ERROR = 'unsupported grant_type';
|
|
24
|
+
export const PRE_AUTHORIZED_CODE_REQUIRED_ERROR = 'pre-authorized_code is required';
|
|
25
|
+
export const USER_PIN_REQUIRED_ERROR = 'User pin is required';
|
|
26
|
+
export const USER_PIN_NOT_REQUIRED_ERROR = 'User pin is not required';
|
|
27
|
+
export const PIN_VALIDATION_ERROR = 'PIN must consist of maximum 8 numeric characters';
|
|
28
|
+
export const PIN_NOT_MATCH_ERROR = 'PIN is invalid';
|
|
29
|
+
export const INVALID_PRE_AUTHORIZED_CODE = 'pre-authorized_code is invalid';
|
|
30
|
+
export const EXPIRED_PRE_AUTHORIZED_CODE = 'pre-authorized_code is expired';
|
|
31
|
+
export const JWT_SIGNER_CALLBACK_REQUIRED_ERROR = 'JWT signer callback function is required';
|
|
32
|
+
export const STATE_MANAGER_REQUIRED_ERROR = 'StateManager instance is required';
|
|
33
|
+
export const NONCE_STATE_MANAGER_REQUIRED_ERROR = 'NonceStateManager instance is required';
|
|
34
|
+
export const PIN_NOT_MATCHING_ERROR = 'PIN does not match';
|
|
35
|
+
export const ACCESS_TOKEN_ISSUER_REQUIRED_ERROR = 'access token issuer is required';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { CredentialFormat } from '@sphereon/ssi-types';
|
|
2
|
+
|
|
3
|
+
import { Display, IssuerCredentialSubject, IssuerMetadata } from './Generic.types';
|
|
4
|
+
import { OAuth2ASMetadata } from './OAuth2ASMetadata';
|
|
5
|
+
|
|
6
|
+
export type Oauth2ASWithOID4VCIMetadata = OAuth2ASMetadata & IssuerMetadata;
|
|
7
|
+
|
|
8
|
+
export interface CredentialIssuer {
|
|
9
|
+
display?: Display; //OPTIONAL. 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:
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html#name-credential-metadata-object
|
|
13
|
+
export interface CredentialMetadata {
|
|
14
|
+
display?: Display[]; //OPTIONAL. An array of objects, where each object contains display properties of a certain Credential for a certain language. Below is a non-exhaustive list of parameters that MAY be included. Note that the display name of the Credential is obtained from display.name and individual claim names from claims.display.name values.
|
|
15
|
+
formats: Formats; //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:
|
|
16
|
+
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
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type OpenID4VCICredentialFormatTypes = CredentialFormat | 'mdl_iso' | 'ac_vc' | string;
|
|
20
|
+
|
|
21
|
+
export interface CredentialFormatSupport {
|
|
22
|
+
types: string[]; //REQUIRED. Array of strings representing a format specific type of a Credential. This value corresponds to type in W3C [VC_DATA] and a doctype in ISO/IEC 18013-5 (mobile Driving License).
|
|
23
|
+
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 as defined in Section 9.1. A non-exhaustive list of valid values defined by this specification are did, jwk, and mso.
|
|
24
|
+
cryptographic_suites_supported?: string[]; //OPTIONAL. Array of case sensitive strings that identify the cryptographic suites that are supported for the cryptographic_binding_methods_supported. Cryptosuites for Credentials in jwt_vc format should use algorithm names defined in IANA JOSE Algorithms Registry. Cryptosuites for Credentials in ldp_vc format should use signature suites names defined in Linked Data Cryptographic Suite Registry.
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
+
[x: string]: any; //We use any, so you can access properties if you know the structure
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type Formats = {
|
|
30
|
+
[format in OpenID4VCICredentialFormatTypes]: CredentialFormatSupport;
|
|
31
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { CredentialOfferV1_0_11 } from './v1_0_11.types';
|
|
2
|
+
|
|
3
|
+
export interface CredentialOfferState {
|
|
4
|
+
clientId?: string;
|
|
5
|
+
credentialOffer: CredentialOfferV1_0_11;
|
|
6
|
+
createdOn: number;
|
|
7
|
+
userPin?: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface CNonceState {
|
|
11
|
+
cNonce: string;
|
|
12
|
+
createdOn: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface IStateManager<T> {
|
|
16
|
+
setState(state: string, payload: T): Promise<void>;
|
|
17
|
+
|
|
18
|
+
getState(state: string): Promise<T | undefined>;
|
|
19
|
+
|
|
20
|
+
hasState(state: string): Promise<boolean>;
|
|
21
|
+
|
|
22
|
+
deleteState(state: string): Promise<boolean>;
|
|
23
|
+
|
|
24
|
+
clearExpiredStates(timestamp?: number): Promise<void>; // clears all expired states compared against timestamp if provided, otherwise current timestamp
|
|
25
|
+
|
|
26
|
+
clearAllStates(): Promise<void>; // clears all states
|
|
27
|
+
|
|
28
|
+
getAssertedState(issuerState: string): Promise<T>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './Authorization.types';
|
|
2
|
+
export * from './CredentialIssuance.types';
|
|
3
|
+
export * from './Generic.types';
|
|
4
|
+
export * from './v1_0_08.types';
|
|
5
|
+
export * from './v1_0_09.types';
|
|
6
|
+
export * from './v1_0_11.types';
|
|
7
|
+
export * from './OAuth2ASMetadata';
|
|
8
|
+
export * from './OpenID4VCIErrors';
|
|
9
|
+
export * from './OpenID4VCIServerMetadata';
|
|
10
|
+
export * from './OpenID4VCIVersions.types';
|
|
11
|
+
export { CredentialOfferState, IStateManager, CNonceState } from '../types/StateManager.types';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CredentialSupportedBrief, Display, IssuerCredentialSubject } from './Generic.types';
|
|
2
|
+
export interface IssuerMetadataV1_0_08 {
|
|
3
|
+
issuer?: string;
|
|
4
|
+
credential_endpoint: string;
|
|
5
|
+
credentials_supported: CredentialSupportedTypeV1_0_08;
|
|
6
|
+
credential_issuer?: {
|
|
7
|
+
display: Display | Display[];
|
|
8
|
+
};
|
|
9
|
+
authorization_server?: string;
|
|
10
|
+
token_endpoint?: string;
|
|
11
|
+
display?: Display[];
|
|
12
|
+
[x: string]: unknown;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface CredentialSupportedTypeV1_0_08 {
|
|
16
|
+
[credentialType: string]: CredentialSupportedV1_0_08;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface CredentialSupportedV1_0_08 {
|
|
20
|
+
display?: Display[];
|
|
21
|
+
formats: {
|
|
22
|
+
[credentialFormat: string]: CredentialSupportedBrief;
|
|
23
|
+
};
|
|
24
|
+
claims?: IssuerCredentialSubject;
|
|
25
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CommonAuthorizationRequest } from './Authorization.types';
|
|
2
|
+
import { CredentialOfferPayload } from './CredentialIssuance.types';
|
|
3
|
+
import { CredentialOfferFormat } from './Generic.types';
|
|
4
|
+
|
|
5
|
+
// https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0-09.html#name-issuance-initiation-request
|
|
6
|
+
export interface CredentialOfferPayloadV1_0_09 {
|
|
7
|
+
issuer: string; //(url) REQUIRED The issuer URL of the Credential issuer, the Wallet is requested to obtain one or more Credentials from.
|
|
8
|
+
credential_type: string[] | string; //(url) REQUIRED A JSON string denoting the type of the Credential the Wallet shall request
|
|
9
|
+
credentials: CredentialOfferFormat[];
|
|
10
|
+
'pre-authorized_code'?: string; //CONDITIONAL the code representing the issuer's authorization for the Wallet to obtain Credentials of a certain type. This code MUST be short-lived and single-use. MUST be present in a pre-authorized code flow.
|
|
11
|
+
user_pin_required?: boolean | string; //OPTIONAL Boolean value specifying whether the issuer expects presentation of a user PIN along with the Token Request in a pre-authorized code flow. Default is false.
|
|
12
|
+
op_state?: string; //(JWT) OPTIONAL String value created by the Credential Issuer and opaque to the Wallet that is used to bind the subsequent authentication request with the Credential Issuer to a context set up during previous steps
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface AuthorizationRequestV1_0_09 extends CommonAuthorizationRequest {
|
|
16
|
+
op_state?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// todo https://sphereon.atlassian.net/browse/VDX-185
|
|
20
|
+
export function isAuthorizationRequestV1_0_09(request: CommonAuthorizationRequest): boolean {
|
|
21
|
+
return request && 'op_state' in request;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// TODO https://sphereon.atlassian.net/browse/VDX-184
|
|
25
|
+
export function isCredentialOfferV1_0_09(request: CredentialOfferPayload): boolean {
|
|
26
|
+
return request && ('issuer' in request || 'op_state' in request);
|
|
27
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { AuthorizationDetailsJwtVcJson, CommonAuthorizationRequest } from './Authorization.types';
|
|
2
|
+
import { CredentialOfferPayload } from './CredentialIssuance.types';
|
|
3
|
+
import { CredentialOfferFormat, Grant, IssuerCredentialDefinition } from './Generic.types';
|
|
4
|
+
|
|
5
|
+
export interface CredentialOfferV1_0_11 {
|
|
6
|
+
credential_offer?: CredentialOfferPayloadV1_0_11;
|
|
7
|
+
credential_offer_uri?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface CommonCredentialOfferPayloadV1_0_11 {
|
|
11
|
+
credential_issuer: string; // REQUIRED. The URL of the Credential Issuer, the Wallet is requested to obtain one or more Credentials from.
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* REQUIRED. A JSON array, where every entry is a JSON object or a JSON string. If the entry is an object,
|
|
15
|
+
* the object contains the data related to a certain credential type the Wallet MAY request.
|
|
16
|
+
* Each object MUST contain a format Claim determining the format of the credential to be requested and
|
|
17
|
+
* further parameters characterising the type of the credential to be requested as defined in Appendix E.
|
|
18
|
+
* If the entry is a string, the string value MUST be one of the id values in one of the objects in the
|
|
19
|
+
* credentials_supported Credential Issuer metadata parameter.
|
|
20
|
+
* When processing, the Wallet MUST resolve this string value to the respective object.
|
|
21
|
+
*/
|
|
22
|
+
credentials: (CredentialOfferFormat | string)[];
|
|
23
|
+
/**
|
|
24
|
+
* OPTIONAL. A JSON object indicating to the Wallet the Grant Types the Credential Issuer's AS is prepared
|
|
25
|
+
* to process for this credential offer. Every grant is represented by a key and an object.
|
|
26
|
+
* The key value is the Grant Type identifier, the object MAY contain parameters either determining the way
|
|
27
|
+
* the Wallet MUST use the particular grant and/or parameters the Wallet MUST send with the respective request(s).
|
|
28
|
+
* If grants is not present or empty, the Wallet MUST determine the Grant Types the Credential Issuer's AS supports
|
|
29
|
+
* using the respective metadata. When multiple grants are present, it's at the Wallet's discretion which one to use.
|
|
30
|
+
*/
|
|
31
|
+
grants?: Grant;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface CredentialOfferJwtVcJsonLdAndLdpVcV1_0_11 extends CommonCredentialOfferPayloadV1_0_11 {
|
|
35
|
+
/**
|
|
36
|
+
* REQUIRED. JSON object containing (and isolating) the detailed description of the credential type.
|
|
37
|
+
* This object MUST be processed using full JSON-LD processing. It consists of the following sub-claims:
|
|
38
|
+
* - @context: REQUIRED. JSON array as defined in Appendix E.1.3.2
|
|
39
|
+
* - types: REQUIRED. JSON array as defined in Appendix E.1.3.2.
|
|
40
|
+
* This claim contains the type values the Wallet shall request in the subsequent Credential Request
|
|
41
|
+
*/
|
|
42
|
+
credential_definition: IssuerCredentialDefinition;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface CredentialOfferJwtVcJsonV1_0_11 extends CommonCredentialOfferPayloadV1_0_11 {
|
|
46
|
+
credentials: (CredentialOfferFormat | string)[]; // look at CommonCredentialOfferPayloadV1_0_11.credentials
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export type CredentialOfferPayloadV1_0_11 = CredentialOfferJwtVcJsonLdAndLdpVcV1_0_11 | CredentialOfferJwtVcJsonV1_0_11;
|
|
50
|
+
|
|
51
|
+
export interface AuthorizationRequestV1_0_11 extends AuthorizationDetailsJwtVcJson, AuthorizationDetailsJwtVcJson {
|
|
52
|
+
issuer_state?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// todo https://sphereon.atlassian.net/browse/VDX-185
|
|
56
|
+
export function isAuthorizationRequestV1_0_11(request: CommonAuthorizationRequest): boolean {
|
|
57
|
+
return request && 'issuer_state' in request;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// TODO https://sphereon.atlassian.net/browse/VDX-184
|
|
61
|
+
export function isCredentialOfferV1_0_11(request: CredentialOfferPayload | CredentialOfferV1_0_11): boolean {
|
|
62
|
+
return request && ('credential_offer' in request || 'credential_offer_uri' in request || 'credential_issuer' in request);
|
|
63
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sphereon/oid4vci-common",
|
|
3
|
+
"version": "0.4.1-unstable.247+0bbe17c",
|
|
4
|
+
"description": "OpenID 4 Verifiable Credential Issuance Common Types",
|
|
5
|
+
"source": "lib/index.ts",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@sphereon/ssi-types": "^0.9.0",
|
|
13
|
+
"jwt-decode": "^3.1.2"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@types/jest": "^29.5.0"
|
|
17
|
+
},
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=16"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"lib/**/*",
|
|
23
|
+
"dist/**/*"
|
|
24
|
+
],
|
|
25
|
+
"prettier": {
|
|
26
|
+
"singleQuote": true,
|
|
27
|
+
"printWidth": 150
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"Sphereon",
|
|
31
|
+
"Verifiable Credentials",
|
|
32
|
+
"OpenID",
|
|
33
|
+
"OpenID for Verifiable Credential Issuance",
|
|
34
|
+
"OAuth2",
|
|
35
|
+
"SSI",
|
|
36
|
+
"OpenID4VCI",
|
|
37
|
+
"OIDC4VCI",
|
|
38
|
+
"OID4VCI"
|
|
39
|
+
],
|
|
40
|
+
"author": "Sphereon",
|
|
41
|
+
"license": "Apache-2.0",
|
|
42
|
+
"private": false,
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
},
|
|
46
|
+
"gitHead": "0bbe17c13de4df95e2fd79b3470a746cc7a5374a"
|
|
47
|
+
}
|