@owf/eudi-access-certificate 0.0.0-stage → 0.0.0
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/README.md +155 -2
- package/dist/index.cjs +381 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +295 -0
- package/dist/index.d.mts +295 -0
- package/dist/index.mjs +364 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +46 -4
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { IdentityException, JsonWebKey } from "@owf/identity-common";
|
|
2
|
+
import { Certificate, CertificateInput, CertificateTemplate, KeyIdentifierHasher, KeyUsageType, PreparedSignedStructure, SignOptions, SignatureAlgorithm, SignatureEncoding } from "@owf/x509";
|
|
3
|
+
//#region src/access-certificate-exception.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* AccessCertificateException is thrown when an access certificate cannot be
|
|
6
|
+
* parsed, fails validation in an assert helper, or cannot be created.
|
|
7
|
+
*/
|
|
8
|
+
export declare class AccessCertificateException extends IdentityException {
|
|
9
|
+
constructor(message: string, details?: unknown);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/constants.d.ts
|
|
13
|
+
/**
|
|
14
|
+
* Certificate policy identifiers defined in ETSI TS 119 411-8 clause 5.3.
|
|
15
|
+
*
|
|
16
|
+
* `{ itu-t(0) identified-organization(4) etsi(0) eudiwrp(194118) policy-identifiers(1) }`
|
|
17
|
+
*/
|
|
18
|
+
export declare const ACCESS_CERTIFICATE_POLICIES: {
|
|
19
|
+
/** Normalized certificate policy for access certificates issued to natural persons */
|
|
20
|
+
readonly 'NCP-n-eudiwrp': '0.4.0.194118.1.1';
|
|
21
|
+
/** Normalized certificate policy for access certificates issued to legal persons */
|
|
22
|
+
readonly 'NCP-l-eudiwrp': '0.4.0.194118.1.2';
|
|
23
|
+
/** Qualified certificate policy for access certificates issued to natural persons */
|
|
24
|
+
readonly 'QCP-n-eudiwrp': '0.4.0.194118.1.3';
|
|
25
|
+
/** Qualified certificate policy for access certificates issued to legal persons */
|
|
26
|
+
readonly 'QCP-l-eudiwrp': '0.4.0.194118.1.4';
|
|
27
|
+
};
|
|
28
|
+
type AccessCertificatePolicy = keyof typeof ACCESS_CERTIFICATE_POLICIES;
|
|
29
|
+
/** Whether an access certificate is issued to a natural or a legal person */
|
|
30
|
+
type AccessCertificateSubjectType = 'natural' | 'legal';
|
|
31
|
+
export declare const ACCESS_CERTIFICATE_POLICY_INFO: Record<AccessCertificatePolicy, {
|
|
32
|
+
subjectType: AccessCertificateSubjectType;
|
|
33
|
+
qualified: boolean;
|
|
34
|
+
}>;
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/types.d.ts
|
|
37
|
+
/**
|
|
38
|
+
* Semantic identifier as defined in ETSI EN 319 412-1 clause 5.1.3 (natural persons,
|
|
39
|
+
* `serialNumber`) and clause 5.1.4 (legal persons, `organizationIdentifier`),
|
|
40
|
+
* e.g. `VATBE-0876866054`, `LEIXG-529900T8BM49AURSDO55` or `PNODE-12345678`.
|
|
41
|
+
*/
|
|
42
|
+
interface SemanticIdentifier {
|
|
43
|
+
/** The complete attribute value */
|
|
44
|
+
value: string;
|
|
45
|
+
/** 3 character identity type reference (e.g. `VAT`, `NTR`, `PSD`, `LEI`, `PAS`, `IDC`, `PNO`, `TAX`, `TIN`) or a 2 character national scheme followed by `:` */
|
|
46
|
+
type: string;
|
|
47
|
+
/** ISO 3166-1 country code (or `EU` / `XG`); Greece is `EL` */
|
|
48
|
+
countryCode: string;
|
|
49
|
+
/** Optional ISO 3166-2 subdivision code following a `+` */
|
|
50
|
+
subdivision?: string;
|
|
51
|
+
/** The identifier within the scheme */
|
|
52
|
+
identifier: string;
|
|
53
|
+
}
|
|
54
|
+
/** GEN-6.6.1-07: contact information of the wallet-relying party taken from the SAN */
|
|
55
|
+
interface AccessCertificateContact {
|
|
56
|
+
/** Website for helpdesk and support (SAN uniformResourceIdentifier) */
|
|
57
|
+
uris: string[];
|
|
58
|
+
/** Email address (SAN rfc822Name) */
|
|
59
|
+
emails: string[];
|
|
60
|
+
/** Phone number (SAN otherName with type-id id-at-telephoneNumber) */
|
|
61
|
+
phoneNumbers: string[];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* A wallet-relying party access certificate: the generic X.509 certificate plus the
|
|
65
|
+
* information ETSI TS 119 411-8 gives meaning to.
|
|
66
|
+
*/
|
|
67
|
+
interface AccessCertificate {
|
|
68
|
+
/** The underlying X.509 certificate, e.g. for signature and revocation checks with `@owf/x509` */
|
|
69
|
+
certificate: Certificate;
|
|
70
|
+
/** The ETSI TS 119 411-8 policies found in the certificate */
|
|
71
|
+
policies: AccessCertificatePolicy[];
|
|
72
|
+
/**
|
|
73
|
+
* Whether the certificate is issued to a natural or legal person. Derived from the
|
|
74
|
+
* TS 119 411-8 policy, falling back to the subject attributes.
|
|
75
|
+
*/
|
|
76
|
+
subjectType?: AccessCertificateSubjectType;
|
|
77
|
+
/** Whether a QCP-n-eudiwrp or QCP-l-eudiwrp policy is present */
|
|
78
|
+
qualified: boolean;
|
|
79
|
+
/** Parsed semantic identifier of the wallet-relying party (`organizationIdentifier` or `serialNumber`) */
|
|
80
|
+
subjectIdentifier?: SemanticIdentifier;
|
|
81
|
+
contact: AccessCertificateContact;
|
|
82
|
+
}
|
|
83
|
+
type AccessCertificateValidationSeverity = 'error' | 'warning';
|
|
84
|
+
interface AccessCertificateValidationIssue<Code extends string = string> {
|
|
85
|
+
code: Code;
|
|
86
|
+
severity: AccessCertificateValidationSeverity;
|
|
87
|
+
message: string;
|
|
88
|
+
/** Requirement identifier of the originating specification, e.g. `GEN-6.6.1-05` */
|
|
89
|
+
requirement?: string;
|
|
90
|
+
}
|
|
91
|
+
interface AccessCertificateValidationOptions {
|
|
92
|
+
/** Reference time for the validity period check; defaults to now. Pass `false` to skip it. */
|
|
93
|
+
now?: Date | false;
|
|
94
|
+
/**
|
|
95
|
+
* GEN-6.6.1-03 allows a TSP allocated policy OID instead of the TS 119 411-8 OIDs.
|
|
96
|
+
* Certificates carrying one of these are accepted without a TS 119 411-8 policy.
|
|
97
|
+
*/
|
|
98
|
+
acceptedPolicyOids?: string[];
|
|
99
|
+
/** Expected subject type, overriding the one derived from the certificate */
|
|
100
|
+
subjectType?: AccessCertificateSubjectType;
|
|
101
|
+
}
|
|
102
|
+
/** Subject of an access certificate issued to a legal person (ETSI EN 319 412-3) */
|
|
103
|
+
interface LegalPersonSubjectInput {
|
|
104
|
+
/** GEN-6.1.1-04: trade name or service name that is recognisable to the user */
|
|
105
|
+
commonName: string;
|
|
106
|
+
organizationName: string;
|
|
107
|
+
/** GEN-6.6.1-05: semantic identifier per ETSI EN 319 412-1 clause 5.1.4 */
|
|
108
|
+
organizationIdentifier: string;
|
|
109
|
+
/** ISO 3166-1 alpha-2 country code */
|
|
110
|
+
countryName: string;
|
|
111
|
+
/** GEN-6.6.1-08: differentiate instances of the same organization */
|
|
112
|
+
organizationalUnitNames?: string[];
|
|
113
|
+
localityName?: string;
|
|
114
|
+
stateOrProvinceName?: string;
|
|
115
|
+
}
|
|
116
|
+
/** Subject of an access certificate issued to a natural person (ETSI EN 319 412-2) */
|
|
117
|
+
interface NaturalPersonSubjectInput {
|
|
118
|
+
commonName: string;
|
|
119
|
+
givenName?: string;
|
|
120
|
+
surname?: string;
|
|
121
|
+
pseudonym?: string;
|
|
122
|
+
/** Semantic identifier per ETSI EN 319 412-1 clause 5.1.3 */
|
|
123
|
+
serialNumber?: string;
|
|
124
|
+
/** ISO 3166-1 alpha-2 country code */
|
|
125
|
+
countryName: string;
|
|
126
|
+
organizationalUnitNames?: string[];
|
|
127
|
+
}
|
|
128
|
+
interface BaseAccessCertificateOptions {
|
|
129
|
+
/** Additional, TSP allocated policy OIDs (GEN-6.6.1-03) */
|
|
130
|
+
additionalPolicyOids?: string[];
|
|
131
|
+
/** GEN-6.6.1-06: URL of the CPS of the access certificate provider */
|
|
132
|
+
cpsUri: string;
|
|
133
|
+
/** GEN-6.6.1-07: at least one website, email address or phone number */
|
|
134
|
+
contact: Partial<AccessCertificateContact>;
|
|
135
|
+
/** Additional DNS names, e.g. for the OpenID4VP `x509_san_dns` client identifier prefix */
|
|
136
|
+
dnsNames?: string[];
|
|
137
|
+
/** Public key of the wallet-relying party as DER SubjectPublicKeyInfo or public JWK */
|
|
138
|
+
subjectPublicKey: Uint8Array | JsonWebKey;
|
|
139
|
+
/** Certificate of the issuing CA; supplies the issuer name and authority key identifier */
|
|
140
|
+
issuerCertificate: CertificateInput;
|
|
141
|
+
/** Positive serial number as bytes or hex string (at most 20 octets) */
|
|
142
|
+
serialNumber: Uint8Array | string;
|
|
143
|
+
notBefore: Date;
|
|
144
|
+
notAfter: Date;
|
|
145
|
+
/** Algorithm the issuing CA key signs with */
|
|
146
|
+
signatureAlgorithm: SignatureAlgorithm;
|
|
147
|
+
/** Defaults to `['digitalSignature']` */
|
|
148
|
+
keyUsage?: KeyUsageType[];
|
|
149
|
+
extendedKeyUsage?: string[];
|
|
150
|
+
crlDistributionPoints?: string[];
|
|
151
|
+
ocspUrls?: string[];
|
|
152
|
+
caIssuersUrls?: string[];
|
|
153
|
+
/** Extra QC statement content for qualified policies */
|
|
154
|
+
qcStatements?: {
|
|
155
|
+
/** Add id-etsi-qcs-QcSSCD */
|
|
156
|
+
qcSSCD?: boolean;
|
|
157
|
+
pds?: {
|
|
158
|
+
url: string;
|
|
159
|
+
language: string;
|
|
160
|
+
}[];
|
|
161
|
+
legislationCountries?: string[];
|
|
162
|
+
};
|
|
163
|
+
/** Adds a subject key identifier extension when provided */
|
|
164
|
+
hasher?: KeyIdentifierHasher;
|
|
165
|
+
}
|
|
166
|
+
interface LegalPersonAccessCertificateOptions extends BaseAccessCertificateOptions {
|
|
167
|
+
policy: 'NCP-l-eudiwrp' | 'QCP-l-eudiwrp';
|
|
168
|
+
subject: LegalPersonSubjectInput;
|
|
169
|
+
}
|
|
170
|
+
interface NaturalPersonAccessCertificateOptions extends BaseAccessCertificateOptions {
|
|
171
|
+
policy: 'NCP-n-eudiwrp' | 'QCP-n-eudiwrp';
|
|
172
|
+
subject: NaturalPersonSubjectInput;
|
|
173
|
+
}
|
|
174
|
+
type PrepareAccessCertificateOptions = LegalPersonAccessCertificateOptions | NaturalPersonAccessCertificateOptions;
|
|
175
|
+
type CreateAccessCertificateOptions = PrepareAccessCertificateOptions & SignOptions;
|
|
176
|
+
type PreparedAccessCertificate = PreparedSignedStructure;
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src/create.d.ts
|
|
179
|
+
/** Map access certificate options to a generic `@owf/x509` certificate template. */
|
|
180
|
+
export declare function toCertificateTemplate(options: PrepareAccessCertificateOptions): CertificateTemplate;
|
|
181
|
+
/**
|
|
182
|
+
* Build the TBSCertificate of an access certificate per ETSI TS 119 411-8 clause 6.6.1.
|
|
183
|
+
*
|
|
184
|
+
* Sign the returned `tbs` bytes with the issuing CA key wherever that key lives and pass the
|
|
185
|
+
* signature to {@link assembleAccessCertificate}. {@link createAccessCertificate} wraps both
|
|
186
|
+
* steps around a signer callback.
|
|
187
|
+
*/
|
|
188
|
+
export declare function prepareAccessCertificate(options: PrepareAccessCertificateOptions): Promise<PreparedAccessCertificate>;
|
|
189
|
+
/**
|
|
190
|
+
* Combine a prepared TBSCertificate with the signature of the issuing CA.
|
|
191
|
+
*
|
|
192
|
+
* @param signatureEncoding Encoding of ECDSA signatures; WebCrypto produces `ieee-p1363` (default)
|
|
193
|
+
*/
|
|
194
|
+
export declare function assembleAccessCertificate(prepared: PreparedAccessCertificate, signature: Uint8Array, signatureEncoding?: SignatureEncoding): AccessCertificate;
|
|
195
|
+
/**
|
|
196
|
+
* Create a wallet-relying party access certificate per ETSI TS 119 411-8.
|
|
197
|
+
*
|
|
198
|
+
* The issuing CA key is never passed in: the `signer` callback receives the DER encoded
|
|
199
|
+
* TBSCertificate and returns the signature, so the key can stay in WebCrypto, a KMS or an HSM.
|
|
200
|
+
* Likewise only the public key of the wallet-relying party is needed; a JWK that contains
|
|
201
|
+
* private key material is rejected.
|
|
202
|
+
*
|
|
203
|
+
* @throws AccessCertificateException when the input or the resulting certificate does not
|
|
204
|
+
* satisfy the certificate profile
|
|
205
|
+
*/
|
|
206
|
+
export declare function createAccessCertificate(options: CreateAccessCertificateOptions): Promise<AccessCertificate>;
|
|
207
|
+
//#endregion
|
|
208
|
+
//#region src/profile.d.ts
|
|
209
|
+
/**
|
|
210
|
+
* Interpret a parsed X.509 certificate as a wallet-relying party access certificate
|
|
211
|
+
* (ETSI TS 119 411-8). This does not check conformance; use {@link validateAccessCertificate}.
|
|
212
|
+
*/
|
|
213
|
+
export declare function toAccessCertificate(certificate: Certificate): AccessCertificate;
|
|
214
|
+
/**
|
|
215
|
+
* Parse a wallet-relying party access certificate (ETSI TS 119 411-8).
|
|
216
|
+
*
|
|
217
|
+
* Shorthand for `toAccessCertificate(parseCertificate(input))`. Parsing only decodes the
|
|
218
|
+
* certificate; it does not check it against the profile or verify its signature.
|
|
219
|
+
*
|
|
220
|
+
* @param input DER bytes, base64 encoded DER, or PEM
|
|
221
|
+
* @throws X509Exception when the input is not a well-formed X.509 certificate
|
|
222
|
+
*/
|
|
223
|
+
export declare function parseAccessCertificate(input: CertificateInput): AccessCertificate;
|
|
224
|
+
/**
|
|
225
|
+
* The semantic identifier of the wallet-relying party, i.e. the `organizationIdentifier`
|
|
226
|
+
* for legal persons or the `serialNumber` for natural persons. This is the value a
|
|
227
|
+
* registration certificate (ETSI TS 119 475) is bound to via its `sub` claim.
|
|
228
|
+
*/
|
|
229
|
+
export declare function getAccessCertificateSubjectIdentifier(accessCertificate: AccessCertificate): string | undefined;
|
|
230
|
+
//#endregion
|
|
231
|
+
//#region src/semantic-identifier.d.ts
|
|
232
|
+
/**
|
|
233
|
+
* Parse a semantic identifier per ETSI EN 319 412-1 clauses 5.1.3 and 5.1.4
|
|
234
|
+
* (`<type><country>[+<subdivision>]-<identifier>`). Returns `undefined` when the
|
|
235
|
+
* value does not follow that structure.
|
|
236
|
+
*/
|
|
237
|
+
export declare function parseSemanticIdentifier(value: string): SemanticIdentifier | undefined;
|
|
238
|
+
/** Identity type references for legal persons (ETSI EN 319 412-1 clause 5.1.4) */
|
|
239
|
+
export declare const LEGAL_PERSON_IDENTIFIER_TYPES: readonly ['VAT', 'NTR', 'PSD', 'LEI'];
|
|
240
|
+
/** Identity type references for natural persons (ETSI EN 319 412-1 clause 5.1.3) */
|
|
241
|
+
export declare const NATURAL_PERSON_IDENTIFIER_TYPES: readonly ['PAS', 'IDC', 'PNO', 'TAX', 'TIN'];
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region src/validate.d.ts
|
|
244
|
+
export declare const ACCESS_CERTIFICATE_VALIDATION_CODES: {
|
|
245
|
+
readonly UNSUPPORTED_VERSION: 'UNSUPPORTED_VERSION';
|
|
246
|
+
readonly NOT_YET_VALID: 'NOT_YET_VALID';
|
|
247
|
+
readonly EXPIRED: 'EXPIRED';
|
|
248
|
+
readonly CA_CERTIFICATE: 'CA_CERTIFICATE';
|
|
249
|
+
readonly MISSING_DIGITAL_SIGNATURE_KEY_USAGE: 'MISSING_DIGITAL_SIGNATURE_KEY_USAGE';
|
|
250
|
+
readonly MISSING_POLICY: 'MISSING_POLICY';
|
|
251
|
+
readonly CONFLICTING_POLICIES: 'CONFLICTING_POLICIES';
|
|
252
|
+
readonly MISSING_CPS_URI: 'MISSING_CPS_URI';
|
|
253
|
+
readonly MISSING_CONTACT: 'MISSING_CONTACT';
|
|
254
|
+
readonly UNKNOWN_SUBJECT_TYPE: 'UNKNOWN_SUBJECT_TYPE';
|
|
255
|
+
readonly MISSING_COMMON_NAME: 'MISSING_COMMON_NAME';
|
|
256
|
+
readonly MISSING_COUNTRY_NAME: 'MISSING_COUNTRY_NAME';
|
|
257
|
+
readonly MISSING_ORGANIZATION_NAME: 'MISSING_ORGANIZATION_NAME';
|
|
258
|
+
readonly MISSING_ORGANIZATION_IDENTIFIER: 'MISSING_ORGANIZATION_IDENTIFIER';
|
|
259
|
+
readonly INVALID_ORGANIZATION_IDENTIFIER: 'INVALID_ORGANIZATION_IDENTIFIER';
|
|
260
|
+
readonly INVALID_GREECE_COUNTRY_CODE: 'INVALID_GREECE_COUNTRY_CODE';
|
|
261
|
+
readonly MISSING_NATURAL_PERSON_NAME: 'MISSING_NATURAL_PERSON_NAME';
|
|
262
|
+
readonly MISSING_SERIAL_NUMBER: 'MISSING_SERIAL_NUMBER';
|
|
263
|
+
readonly INVALID_SERIAL_NUMBER: 'INVALID_SERIAL_NUMBER';
|
|
264
|
+
readonly MISSING_QC_COMPLIANCE: 'MISSING_QC_COMPLIANCE';
|
|
265
|
+
readonly QC_TYPE_MISMATCH: 'QC_TYPE_MISMATCH';
|
|
266
|
+
};
|
|
267
|
+
type AccessCertificateValidationCode = (typeof ACCESS_CERTIFICATE_VALIDATION_CODES)[keyof typeof ACCESS_CERTIFICATE_VALIDATION_CODES];
|
|
268
|
+
type AccessCertificateIssue = AccessCertificateValidationIssue<AccessCertificateValidationCode>;
|
|
269
|
+
interface AccessCertificateValidationResult {
|
|
270
|
+
/** `true` when there are no errors; warnings do not affect validity */
|
|
271
|
+
valid: boolean;
|
|
272
|
+
errors: AccessCertificateIssue[];
|
|
273
|
+
warnings: AccessCertificateIssue[];
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Check a parsed access certificate against the certificate profile of ETSI TS 119 411-8
|
|
277
|
+
* clause 6.6.1 and the profiles it references (ETSI EN 319 412-2 / 412-3 / 412-5).
|
|
278
|
+
*
|
|
279
|
+
* This checks the certificate content only. Signature, chain and revocation checks
|
|
280
|
+
* against the trusted list of access certificate providers are out of scope.
|
|
281
|
+
*/
|
|
282
|
+
export declare function validateAccessCertificate(accessCertificate: AccessCertificate, options?: AccessCertificateValidationOptions): AccessCertificateValidationResult;
|
|
283
|
+
/**
|
|
284
|
+
* Parse and validate an access certificate, throwing when it does not conform.
|
|
285
|
+
*
|
|
286
|
+
* @throws AccessCertificateException with the validation errors as details
|
|
287
|
+
*/
|
|
288
|
+
export declare function parseAndValidateAccessCertificate(input: CertificateInput, options?: AccessCertificateValidationOptions): AccessCertificate;
|
|
289
|
+
/**
|
|
290
|
+
* @throws AccessCertificateException with the validation errors as details
|
|
291
|
+
*/
|
|
292
|
+
export declare function assertValidAccessCertificate(accessCertificate: AccessCertificate, options?: AccessCertificateValidationOptions): void;
|
|
293
|
+
//#endregion
|
|
294
|
+
export type { AccessCertificate, AccessCertificateContact, AccessCertificateIssue, AccessCertificatePolicy, AccessCertificateSubjectType, AccessCertificateValidationCode, AccessCertificateValidationIssue, AccessCertificateValidationOptions, AccessCertificateValidationResult, AccessCertificateValidationSeverity, CreateAccessCertificateOptions, LegalPersonAccessCertificateOptions, LegalPersonSubjectInput, NaturalPersonAccessCertificateOptions, NaturalPersonSubjectInput, PrepareAccessCertificateOptions, PreparedAccessCertificate, SemanticIdentifier };
|
|
295
|
+
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { IdentityException, JsonWebKey } from "@owf/identity-common";
|
|
2
|
+
import { Certificate, CertificateInput, CertificateTemplate, KeyIdentifierHasher, KeyUsageType, PreparedSignedStructure, SignOptions, SignatureAlgorithm, SignatureEncoding } from "@owf/x509";
|
|
3
|
+
//#region src/access-certificate-exception.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* AccessCertificateException is thrown when an access certificate cannot be
|
|
6
|
+
* parsed, fails validation in an assert helper, or cannot be created.
|
|
7
|
+
*/
|
|
8
|
+
export declare class AccessCertificateException extends IdentityException {
|
|
9
|
+
constructor(message: string, details?: unknown);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/constants.d.ts
|
|
13
|
+
/**
|
|
14
|
+
* Certificate policy identifiers defined in ETSI TS 119 411-8 clause 5.3.
|
|
15
|
+
*
|
|
16
|
+
* `{ itu-t(0) identified-organization(4) etsi(0) eudiwrp(194118) policy-identifiers(1) }`
|
|
17
|
+
*/
|
|
18
|
+
export declare const ACCESS_CERTIFICATE_POLICIES: {
|
|
19
|
+
/** Normalized certificate policy for access certificates issued to natural persons */
|
|
20
|
+
readonly 'NCP-n-eudiwrp': '0.4.0.194118.1.1';
|
|
21
|
+
/** Normalized certificate policy for access certificates issued to legal persons */
|
|
22
|
+
readonly 'NCP-l-eudiwrp': '0.4.0.194118.1.2';
|
|
23
|
+
/** Qualified certificate policy for access certificates issued to natural persons */
|
|
24
|
+
readonly 'QCP-n-eudiwrp': '0.4.0.194118.1.3';
|
|
25
|
+
/** Qualified certificate policy for access certificates issued to legal persons */
|
|
26
|
+
readonly 'QCP-l-eudiwrp': '0.4.0.194118.1.4';
|
|
27
|
+
};
|
|
28
|
+
type AccessCertificatePolicy = keyof typeof ACCESS_CERTIFICATE_POLICIES;
|
|
29
|
+
/** Whether an access certificate is issued to a natural or a legal person */
|
|
30
|
+
type AccessCertificateSubjectType = 'natural' | 'legal';
|
|
31
|
+
export declare const ACCESS_CERTIFICATE_POLICY_INFO: Record<AccessCertificatePolicy, {
|
|
32
|
+
subjectType: AccessCertificateSubjectType;
|
|
33
|
+
qualified: boolean;
|
|
34
|
+
}>;
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/types.d.ts
|
|
37
|
+
/**
|
|
38
|
+
* Semantic identifier as defined in ETSI EN 319 412-1 clause 5.1.3 (natural persons,
|
|
39
|
+
* `serialNumber`) and clause 5.1.4 (legal persons, `organizationIdentifier`),
|
|
40
|
+
* e.g. `VATBE-0876866054`, `LEIXG-529900T8BM49AURSDO55` or `PNODE-12345678`.
|
|
41
|
+
*/
|
|
42
|
+
interface SemanticIdentifier {
|
|
43
|
+
/** The complete attribute value */
|
|
44
|
+
value: string;
|
|
45
|
+
/** 3 character identity type reference (e.g. `VAT`, `NTR`, `PSD`, `LEI`, `PAS`, `IDC`, `PNO`, `TAX`, `TIN`) or a 2 character national scheme followed by `:` */
|
|
46
|
+
type: string;
|
|
47
|
+
/** ISO 3166-1 country code (or `EU` / `XG`); Greece is `EL` */
|
|
48
|
+
countryCode: string;
|
|
49
|
+
/** Optional ISO 3166-2 subdivision code following a `+` */
|
|
50
|
+
subdivision?: string;
|
|
51
|
+
/** The identifier within the scheme */
|
|
52
|
+
identifier: string;
|
|
53
|
+
}
|
|
54
|
+
/** GEN-6.6.1-07: contact information of the wallet-relying party taken from the SAN */
|
|
55
|
+
interface AccessCertificateContact {
|
|
56
|
+
/** Website for helpdesk and support (SAN uniformResourceIdentifier) */
|
|
57
|
+
uris: string[];
|
|
58
|
+
/** Email address (SAN rfc822Name) */
|
|
59
|
+
emails: string[];
|
|
60
|
+
/** Phone number (SAN otherName with type-id id-at-telephoneNumber) */
|
|
61
|
+
phoneNumbers: string[];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* A wallet-relying party access certificate: the generic X.509 certificate plus the
|
|
65
|
+
* information ETSI TS 119 411-8 gives meaning to.
|
|
66
|
+
*/
|
|
67
|
+
interface AccessCertificate {
|
|
68
|
+
/** The underlying X.509 certificate, e.g. for signature and revocation checks with `@owf/x509` */
|
|
69
|
+
certificate: Certificate;
|
|
70
|
+
/** The ETSI TS 119 411-8 policies found in the certificate */
|
|
71
|
+
policies: AccessCertificatePolicy[];
|
|
72
|
+
/**
|
|
73
|
+
* Whether the certificate is issued to a natural or legal person. Derived from the
|
|
74
|
+
* TS 119 411-8 policy, falling back to the subject attributes.
|
|
75
|
+
*/
|
|
76
|
+
subjectType?: AccessCertificateSubjectType;
|
|
77
|
+
/** Whether a QCP-n-eudiwrp or QCP-l-eudiwrp policy is present */
|
|
78
|
+
qualified: boolean;
|
|
79
|
+
/** Parsed semantic identifier of the wallet-relying party (`organizationIdentifier` or `serialNumber`) */
|
|
80
|
+
subjectIdentifier?: SemanticIdentifier;
|
|
81
|
+
contact: AccessCertificateContact;
|
|
82
|
+
}
|
|
83
|
+
type AccessCertificateValidationSeverity = 'error' | 'warning';
|
|
84
|
+
interface AccessCertificateValidationIssue<Code extends string = string> {
|
|
85
|
+
code: Code;
|
|
86
|
+
severity: AccessCertificateValidationSeverity;
|
|
87
|
+
message: string;
|
|
88
|
+
/** Requirement identifier of the originating specification, e.g. `GEN-6.6.1-05` */
|
|
89
|
+
requirement?: string;
|
|
90
|
+
}
|
|
91
|
+
interface AccessCertificateValidationOptions {
|
|
92
|
+
/** Reference time for the validity period check; defaults to now. Pass `false` to skip it. */
|
|
93
|
+
now?: Date | false;
|
|
94
|
+
/**
|
|
95
|
+
* GEN-6.6.1-03 allows a TSP allocated policy OID instead of the TS 119 411-8 OIDs.
|
|
96
|
+
* Certificates carrying one of these are accepted without a TS 119 411-8 policy.
|
|
97
|
+
*/
|
|
98
|
+
acceptedPolicyOids?: string[];
|
|
99
|
+
/** Expected subject type, overriding the one derived from the certificate */
|
|
100
|
+
subjectType?: AccessCertificateSubjectType;
|
|
101
|
+
}
|
|
102
|
+
/** Subject of an access certificate issued to a legal person (ETSI EN 319 412-3) */
|
|
103
|
+
interface LegalPersonSubjectInput {
|
|
104
|
+
/** GEN-6.1.1-04: trade name or service name that is recognisable to the user */
|
|
105
|
+
commonName: string;
|
|
106
|
+
organizationName: string;
|
|
107
|
+
/** GEN-6.6.1-05: semantic identifier per ETSI EN 319 412-1 clause 5.1.4 */
|
|
108
|
+
organizationIdentifier: string;
|
|
109
|
+
/** ISO 3166-1 alpha-2 country code */
|
|
110
|
+
countryName: string;
|
|
111
|
+
/** GEN-6.6.1-08: differentiate instances of the same organization */
|
|
112
|
+
organizationalUnitNames?: string[];
|
|
113
|
+
localityName?: string;
|
|
114
|
+
stateOrProvinceName?: string;
|
|
115
|
+
}
|
|
116
|
+
/** Subject of an access certificate issued to a natural person (ETSI EN 319 412-2) */
|
|
117
|
+
interface NaturalPersonSubjectInput {
|
|
118
|
+
commonName: string;
|
|
119
|
+
givenName?: string;
|
|
120
|
+
surname?: string;
|
|
121
|
+
pseudonym?: string;
|
|
122
|
+
/** Semantic identifier per ETSI EN 319 412-1 clause 5.1.3 */
|
|
123
|
+
serialNumber?: string;
|
|
124
|
+
/** ISO 3166-1 alpha-2 country code */
|
|
125
|
+
countryName: string;
|
|
126
|
+
organizationalUnitNames?: string[];
|
|
127
|
+
}
|
|
128
|
+
interface BaseAccessCertificateOptions {
|
|
129
|
+
/** Additional, TSP allocated policy OIDs (GEN-6.6.1-03) */
|
|
130
|
+
additionalPolicyOids?: string[];
|
|
131
|
+
/** GEN-6.6.1-06: URL of the CPS of the access certificate provider */
|
|
132
|
+
cpsUri: string;
|
|
133
|
+
/** GEN-6.6.1-07: at least one website, email address or phone number */
|
|
134
|
+
contact: Partial<AccessCertificateContact>;
|
|
135
|
+
/** Additional DNS names, e.g. for the OpenID4VP `x509_san_dns` client identifier prefix */
|
|
136
|
+
dnsNames?: string[];
|
|
137
|
+
/** Public key of the wallet-relying party as DER SubjectPublicKeyInfo or public JWK */
|
|
138
|
+
subjectPublicKey: Uint8Array | JsonWebKey;
|
|
139
|
+
/** Certificate of the issuing CA; supplies the issuer name and authority key identifier */
|
|
140
|
+
issuerCertificate: CertificateInput;
|
|
141
|
+
/** Positive serial number as bytes or hex string (at most 20 octets) */
|
|
142
|
+
serialNumber: Uint8Array | string;
|
|
143
|
+
notBefore: Date;
|
|
144
|
+
notAfter: Date;
|
|
145
|
+
/** Algorithm the issuing CA key signs with */
|
|
146
|
+
signatureAlgorithm: SignatureAlgorithm;
|
|
147
|
+
/** Defaults to `['digitalSignature']` */
|
|
148
|
+
keyUsage?: KeyUsageType[];
|
|
149
|
+
extendedKeyUsage?: string[];
|
|
150
|
+
crlDistributionPoints?: string[];
|
|
151
|
+
ocspUrls?: string[];
|
|
152
|
+
caIssuersUrls?: string[];
|
|
153
|
+
/** Extra QC statement content for qualified policies */
|
|
154
|
+
qcStatements?: {
|
|
155
|
+
/** Add id-etsi-qcs-QcSSCD */
|
|
156
|
+
qcSSCD?: boolean;
|
|
157
|
+
pds?: {
|
|
158
|
+
url: string;
|
|
159
|
+
language: string;
|
|
160
|
+
}[];
|
|
161
|
+
legislationCountries?: string[];
|
|
162
|
+
};
|
|
163
|
+
/** Adds a subject key identifier extension when provided */
|
|
164
|
+
hasher?: KeyIdentifierHasher;
|
|
165
|
+
}
|
|
166
|
+
interface LegalPersonAccessCertificateOptions extends BaseAccessCertificateOptions {
|
|
167
|
+
policy: 'NCP-l-eudiwrp' | 'QCP-l-eudiwrp';
|
|
168
|
+
subject: LegalPersonSubjectInput;
|
|
169
|
+
}
|
|
170
|
+
interface NaturalPersonAccessCertificateOptions extends BaseAccessCertificateOptions {
|
|
171
|
+
policy: 'NCP-n-eudiwrp' | 'QCP-n-eudiwrp';
|
|
172
|
+
subject: NaturalPersonSubjectInput;
|
|
173
|
+
}
|
|
174
|
+
type PrepareAccessCertificateOptions = LegalPersonAccessCertificateOptions | NaturalPersonAccessCertificateOptions;
|
|
175
|
+
type CreateAccessCertificateOptions = PrepareAccessCertificateOptions & SignOptions;
|
|
176
|
+
type PreparedAccessCertificate = PreparedSignedStructure;
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src/create.d.ts
|
|
179
|
+
/** Map access certificate options to a generic `@owf/x509` certificate template. */
|
|
180
|
+
export declare function toCertificateTemplate(options: PrepareAccessCertificateOptions): CertificateTemplate;
|
|
181
|
+
/**
|
|
182
|
+
* Build the TBSCertificate of an access certificate per ETSI TS 119 411-8 clause 6.6.1.
|
|
183
|
+
*
|
|
184
|
+
* Sign the returned `tbs` bytes with the issuing CA key wherever that key lives and pass the
|
|
185
|
+
* signature to {@link assembleAccessCertificate}. {@link createAccessCertificate} wraps both
|
|
186
|
+
* steps around a signer callback.
|
|
187
|
+
*/
|
|
188
|
+
export declare function prepareAccessCertificate(options: PrepareAccessCertificateOptions): Promise<PreparedAccessCertificate>;
|
|
189
|
+
/**
|
|
190
|
+
* Combine a prepared TBSCertificate with the signature of the issuing CA.
|
|
191
|
+
*
|
|
192
|
+
* @param signatureEncoding Encoding of ECDSA signatures; WebCrypto produces `ieee-p1363` (default)
|
|
193
|
+
*/
|
|
194
|
+
export declare function assembleAccessCertificate(prepared: PreparedAccessCertificate, signature: Uint8Array, signatureEncoding?: SignatureEncoding): AccessCertificate;
|
|
195
|
+
/**
|
|
196
|
+
* Create a wallet-relying party access certificate per ETSI TS 119 411-8.
|
|
197
|
+
*
|
|
198
|
+
* The issuing CA key is never passed in: the `signer` callback receives the DER encoded
|
|
199
|
+
* TBSCertificate and returns the signature, so the key can stay in WebCrypto, a KMS or an HSM.
|
|
200
|
+
* Likewise only the public key of the wallet-relying party is needed; a JWK that contains
|
|
201
|
+
* private key material is rejected.
|
|
202
|
+
*
|
|
203
|
+
* @throws AccessCertificateException when the input or the resulting certificate does not
|
|
204
|
+
* satisfy the certificate profile
|
|
205
|
+
*/
|
|
206
|
+
export declare function createAccessCertificate(options: CreateAccessCertificateOptions): Promise<AccessCertificate>;
|
|
207
|
+
//#endregion
|
|
208
|
+
//#region src/profile.d.ts
|
|
209
|
+
/**
|
|
210
|
+
* Interpret a parsed X.509 certificate as a wallet-relying party access certificate
|
|
211
|
+
* (ETSI TS 119 411-8). This does not check conformance; use {@link validateAccessCertificate}.
|
|
212
|
+
*/
|
|
213
|
+
export declare function toAccessCertificate(certificate: Certificate): AccessCertificate;
|
|
214
|
+
/**
|
|
215
|
+
* Parse a wallet-relying party access certificate (ETSI TS 119 411-8).
|
|
216
|
+
*
|
|
217
|
+
* Shorthand for `toAccessCertificate(parseCertificate(input))`. Parsing only decodes the
|
|
218
|
+
* certificate; it does not check it against the profile or verify its signature.
|
|
219
|
+
*
|
|
220
|
+
* @param input DER bytes, base64 encoded DER, or PEM
|
|
221
|
+
* @throws X509Exception when the input is not a well-formed X.509 certificate
|
|
222
|
+
*/
|
|
223
|
+
export declare function parseAccessCertificate(input: CertificateInput): AccessCertificate;
|
|
224
|
+
/**
|
|
225
|
+
* The semantic identifier of the wallet-relying party, i.e. the `organizationIdentifier`
|
|
226
|
+
* for legal persons or the `serialNumber` for natural persons. This is the value a
|
|
227
|
+
* registration certificate (ETSI TS 119 475) is bound to via its `sub` claim.
|
|
228
|
+
*/
|
|
229
|
+
export declare function getAccessCertificateSubjectIdentifier(accessCertificate: AccessCertificate): string | undefined;
|
|
230
|
+
//#endregion
|
|
231
|
+
//#region src/semantic-identifier.d.ts
|
|
232
|
+
/**
|
|
233
|
+
* Parse a semantic identifier per ETSI EN 319 412-1 clauses 5.1.3 and 5.1.4
|
|
234
|
+
* (`<type><country>[+<subdivision>]-<identifier>`). Returns `undefined` when the
|
|
235
|
+
* value does not follow that structure.
|
|
236
|
+
*/
|
|
237
|
+
export declare function parseSemanticIdentifier(value: string): SemanticIdentifier | undefined;
|
|
238
|
+
/** Identity type references for legal persons (ETSI EN 319 412-1 clause 5.1.4) */
|
|
239
|
+
export declare const LEGAL_PERSON_IDENTIFIER_TYPES: readonly ['VAT', 'NTR', 'PSD', 'LEI'];
|
|
240
|
+
/** Identity type references for natural persons (ETSI EN 319 412-1 clause 5.1.3) */
|
|
241
|
+
export declare const NATURAL_PERSON_IDENTIFIER_TYPES: readonly ['PAS', 'IDC', 'PNO', 'TAX', 'TIN'];
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region src/validate.d.ts
|
|
244
|
+
export declare const ACCESS_CERTIFICATE_VALIDATION_CODES: {
|
|
245
|
+
readonly UNSUPPORTED_VERSION: 'UNSUPPORTED_VERSION';
|
|
246
|
+
readonly NOT_YET_VALID: 'NOT_YET_VALID';
|
|
247
|
+
readonly EXPIRED: 'EXPIRED';
|
|
248
|
+
readonly CA_CERTIFICATE: 'CA_CERTIFICATE';
|
|
249
|
+
readonly MISSING_DIGITAL_SIGNATURE_KEY_USAGE: 'MISSING_DIGITAL_SIGNATURE_KEY_USAGE';
|
|
250
|
+
readonly MISSING_POLICY: 'MISSING_POLICY';
|
|
251
|
+
readonly CONFLICTING_POLICIES: 'CONFLICTING_POLICIES';
|
|
252
|
+
readonly MISSING_CPS_URI: 'MISSING_CPS_URI';
|
|
253
|
+
readonly MISSING_CONTACT: 'MISSING_CONTACT';
|
|
254
|
+
readonly UNKNOWN_SUBJECT_TYPE: 'UNKNOWN_SUBJECT_TYPE';
|
|
255
|
+
readonly MISSING_COMMON_NAME: 'MISSING_COMMON_NAME';
|
|
256
|
+
readonly MISSING_COUNTRY_NAME: 'MISSING_COUNTRY_NAME';
|
|
257
|
+
readonly MISSING_ORGANIZATION_NAME: 'MISSING_ORGANIZATION_NAME';
|
|
258
|
+
readonly MISSING_ORGANIZATION_IDENTIFIER: 'MISSING_ORGANIZATION_IDENTIFIER';
|
|
259
|
+
readonly INVALID_ORGANIZATION_IDENTIFIER: 'INVALID_ORGANIZATION_IDENTIFIER';
|
|
260
|
+
readonly INVALID_GREECE_COUNTRY_CODE: 'INVALID_GREECE_COUNTRY_CODE';
|
|
261
|
+
readonly MISSING_NATURAL_PERSON_NAME: 'MISSING_NATURAL_PERSON_NAME';
|
|
262
|
+
readonly MISSING_SERIAL_NUMBER: 'MISSING_SERIAL_NUMBER';
|
|
263
|
+
readonly INVALID_SERIAL_NUMBER: 'INVALID_SERIAL_NUMBER';
|
|
264
|
+
readonly MISSING_QC_COMPLIANCE: 'MISSING_QC_COMPLIANCE';
|
|
265
|
+
readonly QC_TYPE_MISMATCH: 'QC_TYPE_MISMATCH';
|
|
266
|
+
};
|
|
267
|
+
type AccessCertificateValidationCode = (typeof ACCESS_CERTIFICATE_VALIDATION_CODES)[keyof typeof ACCESS_CERTIFICATE_VALIDATION_CODES];
|
|
268
|
+
type AccessCertificateIssue = AccessCertificateValidationIssue<AccessCertificateValidationCode>;
|
|
269
|
+
interface AccessCertificateValidationResult {
|
|
270
|
+
/** `true` when there are no errors; warnings do not affect validity */
|
|
271
|
+
valid: boolean;
|
|
272
|
+
errors: AccessCertificateIssue[];
|
|
273
|
+
warnings: AccessCertificateIssue[];
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Check a parsed access certificate against the certificate profile of ETSI TS 119 411-8
|
|
277
|
+
* clause 6.6.1 and the profiles it references (ETSI EN 319 412-2 / 412-3 / 412-5).
|
|
278
|
+
*
|
|
279
|
+
* This checks the certificate content only. Signature, chain and revocation checks
|
|
280
|
+
* against the trusted list of access certificate providers are out of scope.
|
|
281
|
+
*/
|
|
282
|
+
export declare function validateAccessCertificate(accessCertificate: AccessCertificate, options?: AccessCertificateValidationOptions): AccessCertificateValidationResult;
|
|
283
|
+
/**
|
|
284
|
+
* Parse and validate an access certificate, throwing when it does not conform.
|
|
285
|
+
*
|
|
286
|
+
* @throws AccessCertificateException with the validation errors as details
|
|
287
|
+
*/
|
|
288
|
+
export declare function parseAndValidateAccessCertificate(input: CertificateInput, options?: AccessCertificateValidationOptions): AccessCertificate;
|
|
289
|
+
/**
|
|
290
|
+
* @throws AccessCertificateException with the validation errors as details
|
|
291
|
+
*/
|
|
292
|
+
export declare function assertValidAccessCertificate(accessCertificate: AccessCertificate, options?: AccessCertificateValidationOptions): void;
|
|
293
|
+
//#endregion
|
|
294
|
+
export type { AccessCertificate, AccessCertificateContact, AccessCertificateIssue, AccessCertificatePolicy, AccessCertificateSubjectType, AccessCertificateValidationCode, AccessCertificateValidationIssue, AccessCertificateValidationOptions, AccessCertificateValidationResult, AccessCertificateValidationSeverity, CreateAccessCertificateOptions, LegalPersonAccessCertificateOptions, LegalPersonSubjectInput, NaturalPersonAccessCertificateOptions, NaturalPersonSubjectInput, PrepareAccessCertificateOptions, PreparedAccessCertificate, SemanticIdentifier };
|
|
295
|
+
//# sourceMappingURL=index.d.mts.map
|