@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/dist/index.mjs ADDED
@@ -0,0 +1,364 @@
1
+ import { IdentityException } from "@owf/identity-common";
2
+ import { ATTRIBUTE_TYPES, assembleCertificate, parseCertificate, prepareCertificate, stringOtherName, telephoneNumbers } from "@owf/x509";
3
+ //#region src/access-certificate-exception.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
+ var AccessCertificateException = class AccessCertificateException extends IdentityException {
9
+ constructor(message, details) {
10
+ super(message, details);
11
+ Object.setPrototypeOf(this, AccessCertificateException.prototype);
12
+ this.name = "AccessCertificateException";
13
+ }
14
+ };
15
+ //#endregion
16
+ //#region src/constants.ts
17
+ /**
18
+ * Certificate policy identifiers defined in ETSI TS 119 411-8 clause 5.3.
19
+ *
20
+ * `{ itu-t(0) identified-organization(4) etsi(0) eudiwrp(194118) policy-identifiers(1) }`
21
+ */
22
+ const ACCESS_CERTIFICATE_POLICIES = {
23
+ /** Normalized certificate policy for access certificates issued to natural persons */
24
+ "NCP-n-eudiwrp": "0.4.0.194118.1.1",
25
+ /** Normalized certificate policy for access certificates issued to legal persons */
26
+ "NCP-l-eudiwrp": "0.4.0.194118.1.2",
27
+ /** Qualified certificate policy for access certificates issued to natural persons */
28
+ "QCP-n-eudiwrp": "0.4.0.194118.1.3",
29
+ /** Qualified certificate policy for access certificates issued to legal persons */
30
+ "QCP-l-eudiwrp": "0.4.0.194118.1.4"
31
+ };
32
+ const ACCESS_CERTIFICATE_POLICY_INFO = {
33
+ "NCP-n-eudiwrp": {
34
+ subjectType: "natural",
35
+ qualified: false
36
+ },
37
+ "NCP-l-eudiwrp": {
38
+ subjectType: "legal",
39
+ qualified: false
40
+ },
41
+ "QCP-n-eudiwrp": {
42
+ subjectType: "natural",
43
+ qualified: true
44
+ },
45
+ "QCP-l-eudiwrp": {
46
+ subjectType: "legal",
47
+ qualified: true
48
+ }
49
+ };
50
+ //#endregion
51
+ //#region src/semantic-identifier.ts
52
+ const SEMANTIC_IDENTIFIER = /^([A-Z]{3}|[A-Z]{2}:)([A-Z]{2})(?:\+([A-Z0-9]{1,3}))?-(.+)$/;
53
+ /**
54
+ * Parse a semantic identifier per ETSI EN 319 412-1 clauses 5.1.3 and 5.1.4
55
+ * (`<type><country>[+<subdivision>]-<identifier>`). Returns `undefined` when the
56
+ * value does not follow that structure.
57
+ */
58
+ function parseSemanticIdentifier(value) {
59
+ const match = value.match(SEMANTIC_IDENTIFIER);
60
+ if (!match) return void 0;
61
+ const [, type, countryCode, subdivision, identifier] = match;
62
+ return {
63
+ value,
64
+ type,
65
+ countryCode,
66
+ subdivision,
67
+ identifier
68
+ };
69
+ }
70
+ /** Identity type references for legal persons (ETSI EN 319 412-1 clause 5.1.4) */
71
+ const LEGAL_PERSON_IDENTIFIER_TYPES = [
72
+ "VAT",
73
+ "NTR",
74
+ "PSD",
75
+ "LEI"
76
+ ];
77
+ /** Identity type references for natural persons (ETSI EN 319 412-1 clause 5.1.3) */
78
+ const NATURAL_PERSON_IDENTIFIER_TYPES = [
79
+ "PAS",
80
+ "IDC",
81
+ "PNO",
82
+ "TAX",
83
+ "TIN"
84
+ ];
85
+ //#endregion
86
+ //#region src/profile.ts
87
+ const POLICY_BY_OID = new Map(Object.entries(ACCESS_CERTIFICATE_POLICIES).map(([name, oid]) => [oid, name]));
88
+ function deriveSubjectType(policies, certificate) {
89
+ const types = new Set(policies.map((p) => ACCESS_CERTIFICATE_POLICY_INFO[p].subjectType));
90
+ if (types.size === 1) return [...types][0];
91
+ if (types.size > 1) return void 0;
92
+ const { subject } = certificate;
93
+ if (subject.organizationIdentifier) return "legal";
94
+ if (subject.givenName || subject.surname || subject.pseudonym) return "natural";
95
+ }
96
+ /**
97
+ * Interpret a parsed X.509 certificate as a wallet-relying party access certificate
98
+ * (ETSI TS 119 411-8). This does not check conformance; use {@link validateAccessCertificate}.
99
+ */
100
+ function toAccessCertificate(certificate) {
101
+ const policies = certificate.policies.map((p) => POLICY_BY_OID.get(p.oid)).filter((p) => p !== void 0);
102
+ const subjectType = deriveSubjectType(policies, certificate);
103
+ const identifier = subjectType === "natural" ? certificate.subject.serialNumber : certificate.subject.organizationIdentifier;
104
+ const san = certificate.subjectAlternativeNames;
105
+ return {
106
+ certificate,
107
+ policies,
108
+ subjectType,
109
+ qualified: policies.some((p) => ACCESS_CERTIFICATE_POLICY_INFO[p].qualified),
110
+ subjectIdentifier: identifier ? parseSemanticIdentifier(identifier) : void 0,
111
+ contact: {
112
+ uris: san.uris,
113
+ emails: san.emails,
114
+ phoneNumbers: telephoneNumbers(san)
115
+ }
116
+ };
117
+ }
118
+ /**
119
+ * Parse a wallet-relying party access certificate (ETSI TS 119 411-8).
120
+ *
121
+ * Shorthand for `toAccessCertificate(parseCertificate(input))`. Parsing only decodes the
122
+ * certificate; it does not check it against the profile or verify its signature.
123
+ *
124
+ * @param input DER bytes, base64 encoded DER, or PEM
125
+ * @throws X509Exception when the input is not a well-formed X.509 certificate
126
+ */
127
+ function parseAccessCertificate(input) {
128
+ return toAccessCertificate(parseCertificate(input));
129
+ }
130
+ /**
131
+ * The semantic identifier of the wallet-relying party, i.e. the `organizationIdentifier`
132
+ * for legal persons or the `serialNumber` for natural persons. This is the value a
133
+ * registration certificate (ETSI TS 119 475) is bound to via its `sub` claim.
134
+ */
135
+ function getAccessCertificateSubjectIdentifier(accessCertificate) {
136
+ const { subject } = accessCertificate.certificate;
137
+ return accessCertificate.subjectType === "natural" ? subject.serialNumber : subject.organizationIdentifier;
138
+ }
139
+ //#endregion
140
+ //#region src/validate.ts
141
+ const ACCESS_CERTIFICATE_VALIDATION_CODES = {
142
+ UNSUPPORTED_VERSION: "UNSUPPORTED_VERSION",
143
+ NOT_YET_VALID: "NOT_YET_VALID",
144
+ EXPIRED: "EXPIRED",
145
+ CA_CERTIFICATE: "CA_CERTIFICATE",
146
+ MISSING_DIGITAL_SIGNATURE_KEY_USAGE: "MISSING_DIGITAL_SIGNATURE_KEY_USAGE",
147
+ MISSING_POLICY: "MISSING_POLICY",
148
+ CONFLICTING_POLICIES: "CONFLICTING_POLICIES",
149
+ MISSING_CPS_URI: "MISSING_CPS_URI",
150
+ MISSING_CONTACT: "MISSING_CONTACT",
151
+ UNKNOWN_SUBJECT_TYPE: "UNKNOWN_SUBJECT_TYPE",
152
+ MISSING_COMMON_NAME: "MISSING_COMMON_NAME",
153
+ MISSING_COUNTRY_NAME: "MISSING_COUNTRY_NAME",
154
+ MISSING_ORGANIZATION_NAME: "MISSING_ORGANIZATION_NAME",
155
+ MISSING_ORGANIZATION_IDENTIFIER: "MISSING_ORGANIZATION_IDENTIFIER",
156
+ INVALID_ORGANIZATION_IDENTIFIER: "INVALID_ORGANIZATION_IDENTIFIER",
157
+ INVALID_GREECE_COUNTRY_CODE: "INVALID_GREECE_COUNTRY_CODE",
158
+ MISSING_NATURAL_PERSON_NAME: "MISSING_NATURAL_PERSON_NAME",
159
+ MISSING_SERIAL_NUMBER: "MISSING_SERIAL_NUMBER",
160
+ INVALID_SERIAL_NUMBER: "INVALID_SERIAL_NUMBER",
161
+ MISSING_QC_COMPLIANCE: "MISSING_QC_COMPLIANCE",
162
+ QC_TYPE_MISMATCH: "QC_TYPE_MISMATCH"
163
+ };
164
+ const C = ACCESS_CERTIFICATE_VALIDATION_CODES;
165
+ /**
166
+ * Check a parsed access certificate against the certificate profile of ETSI TS 119 411-8
167
+ * clause 6.6.1 and the profiles it references (ETSI EN 319 412-2 / 412-3 / 412-5).
168
+ *
169
+ * This checks the certificate content only. Signature, chain and revocation checks
170
+ * against the trusted list of access certificate providers are out of scope.
171
+ */
172
+ function validateAccessCertificate(accessCertificate, options = {}) {
173
+ const { certificate } = accessCertificate;
174
+ const issues = [];
175
+ const add = (severity, code, message, requirement) => issues.push({
176
+ severity,
177
+ code,
178
+ message,
179
+ requirement
180
+ });
181
+ if (certificate.version !== 3) add("error", C.UNSUPPORTED_VERSION, `Expected an X.509 v3 certificate, got v${certificate.version}`);
182
+ if (options.now !== false) {
183
+ const now = options.now ?? /* @__PURE__ */ new Date();
184
+ if (now < certificate.notBefore) add("error", C.NOT_YET_VALID, `Certificate is not valid before ${certificate.notBefore.toISOString()}`);
185
+ if (now > certificate.notAfter) add("error", C.EXPIRED, `Certificate expired at ${certificate.notAfter.toISOString()}`);
186
+ }
187
+ if (certificate.basicConstraints?.cA) add("error", C.CA_CERTIFICATE, "An access certificate must be an end-entity certificate (cA is true)");
188
+ if (certificate.keyUsage && !certificate.keyUsage.includes("digitalSignature")) add("warning", C.MISSING_DIGITAL_SIGNATURE_KEY_USAGE, "Key usage does not include digitalSignature, which is needed to authenticate the wallet-relying party");
189
+ const acceptedOids = new Set(options.acceptedPolicyOids ?? []);
190
+ const hasAcceptedCustomPolicy = certificate.policies.some((p) => acceptedOids.has(p.oid));
191
+ if (accessCertificate.policies.length === 0 && !hasAcceptedCustomPolicy) add("error", C.MISSING_POLICY, "Certificate does not contain an ETSI TS 119 411-8 certificate policy identifier", "GEN-6.6.1-03");
192
+ if (new Set(accessCertificate.policies.map((p) => ACCESS_CERTIFICATE_POLICY_INFO[p].subjectType)).size > 1) add("error", C.CONFLICTING_POLICIES, `Certificate policies for both natural and legal persons are present: ${accessCertificate.policies.join(", ")}`, "GEN-6.6.1-03");
193
+ if (!certificate.policies.some((p) => p.cpsUris.length > 0)) add("error", C.MISSING_CPS_URI, "Certificate policies do not contain a cpsURI qualifier", "GEN-6.6.1-06");
194
+ const { uris, emails, phoneNumbers } = accessCertificate.contact;
195
+ if (uris.length + emails.length + phoneNumbers.length === 0) add("error", C.MISSING_CONTACT, "Subject alternative name must contain a website (URI), phone number (otherName telephoneNumber) or email address (rfc822Name)", "GEN-6.6.1-07");
196
+ const subject = certificate.subject;
197
+ const subjectType = options.subjectType ?? accessCertificate.subjectType;
198
+ if (!subject.commonName) add("error", C.MISSING_COMMON_NAME, "Subject commonName is missing");
199
+ if (!subject.countryName) add("error", C.MISSING_COUNTRY_NAME, "Subject countryName is missing");
200
+ if (subjectType === "legal") {
201
+ if (!subject.organizationName) add("error", C.MISSING_ORGANIZATION_NAME, "Subject organizationName is missing (ETSI EN 319 412-3)");
202
+ if (!subject.organizationIdentifier) add("error", C.MISSING_ORGANIZATION_IDENTIFIER, "Subject organizationIdentifier is missing", "GEN-6.6.1-05");
203
+ else {
204
+ const identifier = parseSemanticIdentifier(subject.organizationIdentifier);
205
+ if (!identifier) add("error", C.INVALID_ORGANIZATION_IDENTIFIER, `organizationIdentifier "${subject.organizationIdentifier}" is not encoded as specified in ETSI EN 319 412-1 clause 5.1.4`, "GEN-6.6.1-05");
206
+ else if (identifier.countryCode === "GR") add("error", C.INVALID_GREECE_COUNTRY_CODE, "organizationIdentifier must use the country code \"EL\" for Greece", "GEN-6.6.1-05");
207
+ }
208
+ } else if (subjectType === "natural") {
209
+ if (!(subject.givenName || subject.surname) && !subject.pseudonym) add("error", C.MISSING_NATURAL_PERSON_NAME, "Subject must contain givenName and/or surname, or a pseudonym (ETSI EN 319 412-2)");
210
+ if (!subject.serialNumber) add("warning", C.MISSING_SERIAL_NUMBER, "Subject serialNumber is missing; the wallet-relying party has no semantic identifier");
211
+ else if (!parseSemanticIdentifier(subject.serialNumber)) add("warning", C.INVALID_SERIAL_NUMBER, `serialNumber "${subject.serialNumber}" is not a semantic identifier as specified in ETSI EN 319 412-1 clause 5.1.3`);
212
+ } else add("error", C.UNKNOWN_SUBJECT_TYPE, "Unable to determine whether the subject is a natural or a legal person");
213
+ if (accessCertificate.qualified) {
214
+ if (!certificate.qcStatements?.qcCompliance) add("error", C.MISSING_QC_COMPLIANCE, "Qualified access certificates must contain the QcCompliance statement (ETSI EN 319 412-5)", "GEN-6.6.1-02");
215
+ const expectedType = subjectType === "natural" ? "esign" : subjectType === "legal" ? "eseal" : void 0;
216
+ const qcTypes = certificate.qcStatements?.qcTypes ?? [];
217
+ if (expectedType && !qcTypes.includes(expectedType)) add("warning", C.QC_TYPE_MISMATCH, `Expected QcType ${expectedType} for a ${subjectType} person, found ${qcTypes.length ? qcTypes.join(", ") : "none"}`, "GEN-6.6.1-02");
218
+ }
219
+ const errors = issues.filter((i) => i.severity === "error");
220
+ return {
221
+ valid: errors.length === 0,
222
+ errors,
223
+ warnings: issues.filter((i) => i.severity === "warning")
224
+ };
225
+ }
226
+ /**
227
+ * Parse and validate an access certificate, throwing when it does not conform.
228
+ *
229
+ * @throws AccessCertificateException with the validation errors as details
230
+ */
231
+ function parseAndValidateAccessCertificate(input, options) {
232
+ const accessCertificate = parseAccessCertificate(input);
233
+ assertValidAccessCertificate(accessCertificate, options);
234
+ return accessCertificate;
235
+ }
236
+ /**
237
+ * @throws AccessCertificateException with the validation errors as details
238
+ */
239
+ function assertValidAccessCertificate(accessCertificate, options) {
240
+ const result = validateAccessCertificate(accessCertificate, options);
241
+ if (!result.valid) throw new AccessCertificateException(`Invalid access certificate: ${result.errors.map((e) => e.message).join("; ")}`, result.errors);
242
+ }
243
+ //#endregion
244
+ //#region src/create.ts
245
+ function isLegalPerson(options) {
246
+ return ACCESS_CERTIFICATE_POLICY_INFO[options.policy]?.subjectType === "legal";
247
+ }
248
+ function subjectAttributes(options) {
249
+ const ous = (options.subject.organizationalUnitNames ?? []).map((ou) => ["organizationalUnitName", ou]);
250
+ if (isLegalPerson(options)) {
251
+ const s = options.subject;
252
+ return [
253
+ ["countryName", s.countryName],
254
+ ["stateOrProvinceName", s.stateOrProvinceName],
255
+ ["localityName", s.localityName],
256
+ ["organizationName", s.organizationName],
257
+ ...ous,
258
+ ["organizationIdentifier", s.organizationIdentifier],
259
+ ["commonName", s.commonName]
260
+ ];
261
+ }
262
+ const s = options.subject;
263
+ return [
264
+ ["countryName", s.countryName],
265
+ ...ous,
266
+ ["givenName", s.givenName],
267
+ ["surname", s.surname],
268
+ ["pseudonym", s.pseudonym],
269
+ ["serialNumber", s.serialNumber],
270
+ ["commonName", s.commonName]
271
+ ];
272
+ }
273
+ function assertInput(options) {
274
+ if (!ACCESS_CERTIFICATE_POLICIES[options.policy]) throw new AccessCertificateException(`Unknown access certificate policy: ${options.policy}`);
275
+ if (!options.cpsUri) throw new AccessCertificateException("cpsUri is required (GEN-6.6.1-06)");
276
+ const { uris = [], emails = [], phoneNumbers = [] } = options.contact;
277
+ if (uris.length + emails.length + phoneNumbers.length === 0) throw new AccessCertificateException("At least one contact website, email address or phone number is required (GEN-6.6.1-07)");
278
+ if (!/^[A-Z]{2}$/.test(options.subject.countryName)) throw new AccessCertificateException("countryName must be an ISO 3166-1 alpha-2 country code");
279
+ if (isLegalPerson(options)) {
280
+ const identifier = parseSemanticIdentifier(options.subject.organizationIdentifier);
281
+ if (!identifier) throw new AccessCertificateException("organizationIdentifier must be encoded as specified in ETSI EN 319 412-1 clause 5.1.4 (GEN-6.6.1-05)");
282
+ if (identifier.countryCode === "GR") throw new AccessCertificateException("organizationIdentifier must use the country code \"EL\" for Greece");
283
+ }
284
+ }
285
+ /** Map access certificate options to a generic `@owf/x509` certificate template. */
286
+ function toCertificateTemplate(options) {
287
+ assertInput(options);
288
+ const policyInfo = ACCESS_CERTIFICATE_POLICY_INFO[options.policy];
289
+ const cpsUris = [options.cpsUri];
290
+ const { uris = [], emails = [], phoneNumbers = [] } = options.contact;
291
+ return {
292
+ subject: subjectAttributes(options),
293
+ subjectPublicKey: options.subjectPublicKey,
294
+ issuerCertificate: options.issuerCertificate,
295
+ serialNumber: options.serialNumber,
296
+ notBefore: options.notBefore,
297
+ notAfter: options.notAfter,
298
+ signatureAlgorithm: options.signatureAlgorithm,
299
+ basicConstraints: { cA: false },
300
+ keyUsage: options.keyUsage ?? ["digitalSignature"],
301
+ extendedKeyUsage: options.extendedKeyUsage,
302
+ certificatePolicies: [{
303
+ oid: ACCESS_CERTIFICATE_POLICIES[options.policy],
304
+ cpsUris
305
+ }, ...(options.additionalPolicyOids ?? []).map((oid) => ({
306
+ oid,
307
+ cpsUris
308
+ }))],
309
+ subjectAlternativeNames: {
310
+ dnsNames: options.dnsNames,
311
+ uris,
312
+ emails,
313
+ otherNames: phoneNumbers.map((phone) => stringOtherName(ATTRIBUTE_TYPES.telephoneNumber, phone))
314
+ },
315
+ crlDistributionPoints: options.crlDistributionPoints,
316
+ ocspUrls: options.ocspUrls,
317
+ caIssuersUrls: options.caIssuersUrls,
318
+ qcStatements: policyInfo.qualified ? {
319
+ ...options.qcStatements,
320
+ qcTypes: [policyInfo.subjectType === "legal" ? "eseal" : "esign"]
321
+ } : void 0,
322
+ hasher: options.hasher
323
+ };
324
+ }
325
+ /**
326
+ * Build the TBSCertificate of an access certificate per ETSI TS 119 411-8 clause 6.6.1.
327
+ *
328
+ * Sign the returned `tbs` bytes with the issuing CA key wherever that key lives and pass the
329
+ * signature to {@link assembleAccessCertificate}. {@link createAccessCertificate} wraps both
330
+ * steps around a signer callback.
331
+ */
332
+ function prepareAccessCertificate(options) {
333
+ return prepareCertificate(toCertificateTemplate(options));
334
+ }
335
+ /**
336
+ * Combine a prepared TBSCertificate with the signature of the issuing CA.
337
+ *
338
+ * @param signatureEncoding Encoding of ECDSA signatures; WebCrypto produces `ieee-p1363` (default)
339
+ */
340
+ function assembleAccessCertificate(prepared, signature, signatureEncoding) {
341
+ return toAccessCertificate(assembleCertificate(prepared, signature, signatureEncoding));
342
+ }
343
+ /**
344
+ * Create a wallet-relying party access certificate per ETSI TS 119 411-8.
345
+ *
346
+ * The issuing CA key is never passed in: the `signer` callback receives the DER encoded
347
+ * TBSCertificate and returns the signature, so the key can stay in WebCrypto, a KMS or an HSM.
348
+ * Likewise only the public key of the wallet-relying party is needed; a JWK that contains
349
+ * private key material is rejected.
350
+ *
351
+ * @throws AccessCertificateException when the input or the resulting certificate does not
352
+ * satisfy the certificate profile
353
+ */
354
+ async function createAccessCertificate(options) {
355
+ const prepared = await prepareAccessCertificate(options);
356
+ const accessCertificate = assembleAccessCertificate(prepared, await options.signer(prepared.tbs), options.signatureEncoding);
357
+ const result = validateAccessCertificate(accessCertificate, { now: false });
358
+ if (!result.valid) throw new AccessCertificateException(`Created access certificate does not conform: ${result.errors.map((e) => e.message).join("; ")}`, result.errors);
359
+ return accessCertificate;
360
+ }
361
+ //#endregion
362
+ export { ACCESS_CERTIFICATE_POLICIES, ACCESS_CERTIFICATE_POLICY_INFO, ACCESS_CERTIFICATE_VALIDATION_CODES, AccessCertificateException, LEGAL_PERSON_IDENTIFIER_TYPES, NATURAL_PERSON_IDENTIFIER_TYPES, assembleAccessCertificate, assertValidAccessCertificate, createAccessCertificate, getAccessCertificateSubjectIdentifier, parseAccessCertificate, parseAndValidateAccessCertificate, parseSemanticIdentifier, prepareAccessCertificate, toAccessCertificate, toCertificateTemplate, validateAccessCertificate };
363
+
364
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/access-certificate-exception.ts","../src/constants.ts","../src/semantic-identifier.ts","../src/profile.ts","../src/validate.ts","../src/create.ts"],"sourcesContent":["import { IdentityException } from '@owf/identity-common'\n\n/**\n * AccessCertificateException is thrown when an access certificate cannot be\n * parsed, fails validation in an assert helper, or cannot be created.\n */\nexport class AccessCertificateException extends IdentityException {\n constructor(message: string, details?: unknown) {\n super(message, details)\n Object.setPrototypeOf(this, AccessCertificateException.prototype)\n this.name = 'AccessCertificateException'\n }\n}\n","/**\n * Certificate policy identifiers defined in ETSI TS 119 411-8 clause 5.3.\n *\n * `{ itu-t(0) identified-organization(4) etsi(0) eudiwrp(194118) policy-identifiers(1) }`\n */\nexport const ACCESS_CERTIFICATE_POLICIES = {\n /** Normalized certificate policy for access certificates issued to natural persons */\n 'NCP-n-eudiwrp': '0.4.0.194118.1.1',\n /** Normalized certificate policy for access certificates issued to legal persons */\n 'NCP-l-eudiwrp': '0.4.0.194118.1.2',\n /** Qualified certificate policy for access certificates issued to natural persons */\n 'QCP-n-eudiwrp': '0.4.0.194118.1.3',\n /** Qualified certificate policy for access certificates issued to legal persons */\n 'QCP-l-eudiwrp': '0.4.0.194118.1.4',\n} as const\n\nexport type AccessCertificatePolicy = keyof typeof ACCESS_CERTIFICATE_POLICIES\n\n/** Whether an access certificate is issued to a natural or a legal person */\nexport type AccessCertificateSubjectType = 'natural' | 'legal'\n\nexport const ACCESS_CERTIFICATE_POLICY_INFO: Record<\n AccessCertificatePolicy,\n { subjectType: AccessCertificateSubjectType; qualified: boolean }\n> = {\n 'NCP-n-eudiwrp': { subjectType: 'natural', qualified: false },\n 'NCP-l-eudiwrp': { subjectType: 'legal', qualified: false },\n 'QCP-n-eudiwrp': { subjectType: 'natural', qualified: true },\n 'QCP-l-eudiwrp': { subjectType: 'legal', qualified: true },\n}\n","import type { SemanticIdentifier } from './types'\n\nconst SEMANTIC_IDENTIFIER = /^([A-Z]{3}|[A-Z]{2}:)([A-Z]{2})(?:\\+([A-Z0-9]{1,3}))?-(.+)$/\n\n/**\n * Parse a semantic identifier per ETSI EN 319 412-1 clauses 5.1.3 and 5.1.4\n * (`<type><country>[+<subdivision>]-<identifier>`). Returns `undefined` when the\n * value does not follow that structure.\n */\nexport function parseSemanticIdentifier(value: string): SemanticIdentifier | undefined {\n const match = value.match(SEMANTIC_IDENTIFIER)\n if (!match) return undefined\n const [, type, countryCode, subdivision, identifier] = match\n return { value, type, countryCode, subdivision, identifier }\n}\n\n/** Identity type references for legal persons (ETSI EN 319 412-1 clause 5.1.4) */\nexport const LEGAL_PERSON_IDENTIFIER_TYPES = ['VAT', 'NTR', 'PSD', 'LEI'] as const\n\n/** Identity type references for natural persons (ETSI EN 319 412-1 clause 5.1.3) */\nexport const NATURAL_PERSON_IDENTIFIER_TYPES = ['PAS', 'IDC', 'PNO', 'TAX', 'TIN'] as const\n","import { type Certificate, type CertificateInput, parseCertificate, telephoneNumbers } from '@owf/x509'\nimport {\n ACCESS_CERTIFICATE_POLICIES,\n ACCESS_CERTIFICATE_POLICY_INFO,\n type AccessCertificatePolicy,\n type AccessCertificateSubjectType,\n} from './constants'\nimport { parseSemanticIdentifier } from './semantic-identifier'\nimport type { AccessCertificate } from './types'\n\nconst POLICY_BY_OID = new Map<string, AccessCertificatePolicy>(\n Object.entries(ACCESS_CERTIFICATE_POLICIES).map(([name, oid]) => [oid, name as AccessCertificatePolicy])\n)\n\nfunction deriveSubjectType(\n policies: AccessCertificatePolicy[],\n certificate: Certificate\n): AccessCertificateSubjectType | undefined {\n const types = new Set(policies.map((p) => ACCESS_CERTIFICATE_POLICY_INFO[p].subjectType))\n if (types.size === 1) return [...types][0]\n if (types.size > 1) return undefined\n const { subject } = certificate\n if (subject.organizationIdentifier) return 'legal'\n if (subject.givenName || subject.surname || subject.pseudonym) return 'natural'\n return undefined\n}\n\n/**\n * Interpret a parsed X.509 certificate as a wallet-relying party access certificate\n * (ETSI TS 119 411-8). This does not check conformance; use {@link validateAccessCertificate}.\n */\nexport function toAccessCertificate(certificate: Certificate): AccessCertificate {\n const policies = certificate.policies\n .map((p) => POLICY_BY_OID.get(p.oid))\n .filter((p): p is AccessCertificatePolicy => p !== undefined)\n const subjectType = deriveSubjectType(policies, certificate)\n const identifier =\n subjectType === 'natural' ? certificate.subject.serialNumber : certificate.subject.organizationIdentifier\n const san = certificate.subjectAlternativeNames\n\n return {\n certificate,\n policies,\n subjectType,\n qualified: policies.some((p) => ACCESS_CERTIFICATE_POLICY_INFO[p].qualified),\n subjectIdentifier: identifier ? parseSemanticIdentifier(identifier) : undefined,\n contact: { uris: san.uris, emails: san.emails, phoneNumbers: telephoneNumbers(san) },\n }\n}\n\n/**\n * Parse a wallet-relying party access certificate (ETSI TS 119 411-8).\n *\n * Shorthand for `toAccessCertificate(parseCertificate(input))`. Parsing only decodes the\n * certificate; it does not check it against the profile or verify its signature.\n *\n * @param input DER bytes, base64 encoded DER, or PEM\n * @throws X509Exception when the input is not a well-formed X.509 certificate\n */\nexport function parseAccessCertificate(input: CertificateInput): AccessCertificate {\n return toAccessCertificate(parseCertificate(input))\n}\n\n/**\n * The semantic identifier of the wallet-relying party, i.e. the `organizationIdentifier`\n * for legal persons or the `serialNumber` for natural persons. This is the value a\n * registration certificate (ETSI TS 119 475) is bound to via its `sub` claim.\n */\nexport function getAccessCertificateSubjectIdentifier(accessCertificate: AccessCertificate): string | undefined {\n const { subject } = accessCertificate.certificate\n return accessCertificate.subjectType === 'natural' ? subject.serialNumber : subject.organizationIdentifier\n}\n","import type { CertificateInput } from '@owf/x509'\nimport { AccessCertificateException } from './access-certificate-exception'\nimport { ACCESS_CERTIFICATE_POLICY_INFO } from './constants'\nimport { parseAccessCertificate } from './profile'\nimport { parseSemanticIdentifier } from './semantic-identifier'\nimport type {\n AccessCertificate,\n AccessCertificateValidationIssue,\n AccessCertificateValidationOptions,\n AccessCertificateValidationSeverity,\n} from './types'\n\nexport const ACCESS_CERTIFICATE_VALIDATION_CODES = {\n UNSUPPORTED_VERSION: 'UNSUPPORTED_VERSION',\n NOT_YET_VALID: 'NOT_YET_VALID',\n EXPIRED: 'EXPIRED',\n CA_CERTIFICATE: 'CA_CERTIFICATE',\n MISSING_DIGITAL_SIGNATURE_KEY_USAGE: 'MISSING_DIGITAL_SIGNATURE_KEY_USAGE',\n MISSING_POLICY: 'MISSING_POLICY',\n CONFLICTING_POLICIES: 'CONFLICTING_POLICIES',\n MISSING_CPS_URI: 'MISSING_CPS_URI',\n MISSING_CONTACT: 'MISSING_CONTACT',\n UNKNOWN_SUBJECT_TYPE: 'UNKNOWN_SUBJECT_TYPE',\n MISSING_COMMON_NAME: 'MISSING_COMMON_NAME',\n MISSING_COUNTRY_NAME: 'MISSING_COUNTRY_NAME',\n MISSING_ORGANIZATION_NAME: 'MISSING_ORGANIZATION_NAME',\n MISSING_ORGANIZATION_IDENTIFIER: 'MISSING_ORGANIZATION_IDENTIFIER',\n INVALID_ORGANIZATION_IDENTIFIER: 'INVALID_ORGANIZATION_IDENTIFIER',\n INVALID_GREECE_COUNTRY_CODE: 'INVALID_GREECE_COUNTRY_CODE',\n MISSING_NATURAL_PERSON_NAME: 'MISSING_NATURAL_PERSON_NAME',\n MISSING_SERIAL_NUMBER: 'MISSING_SERIAL_NUMBER',\n INVALID_SERIAL_NUMBER: 'INVALID_SERIAL_NUMBER',\n MISSING_QC_COMPLIANCE: 'MISSING_QC_COMPLIANCE',\n QC_TYPE_MISMATCH: 'QC_TYPE_MISMATCH',\n} as const\n\nexport type AccessCertificateValidationCode =\n (typeof ACCESS_CERTIFICATE_VALIDATION_CODES)[keyof typeof ACCESS_CERTIFICATE_VALIDATION_CODES]\n\nexport type AccessCertificateIssue = AccessCertificateValidationIssue<AccessCertificateValidationCode>\n\nexport interface AccessCertificateValidationResult {\n /** `true` when there are no errors; warnings do not affect validity */\n valid: boolean\n errors: AccessCertificateIssue[]\n warnings: AccessCertificateIssue[]\n}\n\nconst C = ACCESS_CERTIFICATE_VALIDATION_CODES\n\n/**\n * Check a parsed access certificate against the certificate profile of ETSI TS 119 411-8\n * clause 6.6.1 and the profiles it references (ETSI EN 319 412-2 / 412-3 / 412-5).\n *\n * This checks the certificate content only. Signature, chain and revocation checks\n * against the trusted list of access certificate providers are out of scope.\n */\nexport function validateAccessCertificate(\n accessCertificate: AccessCertificate,\n options: AccessCertificateValidationOptions = {}\n): AccessCertificateValidationResult {\n const { certificate } = accessCertificate\n const issues: AccessCertificateIssue[] = []\n const add = (\n severity: AccessCertificateValidationSeverity,\n code: AccessCertificateValidationCode,\n message: string,\n requirement?: string\n ) => issues.push({ severity, code, message, requirement })\n\n // X.509 basics\n if (certificate.version !== 3) {\n add('error', C.UNSUPPORTED_VERSION, `Expected an X.509 v3 certificate, got v${certificate.version}`)\n }\n if (options.now !== false) {\n const now = options.now ?? new Date()\n if (now < certificate.notBefore) {\n add('error', C.NOT_YET_VALID, `Certificate is not valid before ${certificate.notBefore.toISOString()}`)\n }\n if (now > certificate.notAfter) {\n add('error', C.EXPIRED, `Certificate expired at ${certificate.notAfter.toISOString()}`)\n }\n }\n if (certificate.basicConstraints?.cA) {\n add('error', C.CA_CERTIFICATE, 'An access certificate must be an end-entity certificate (cA is true)')\n }\n if (certificate.keyUsage && !certificate.keyUsage.includes('digitalSignature')) {\n add(\n 'warning',\n C.MISSING_DIGITAL_SIGNATURE_KEY_USAGE,\n 'Key usage does not include digitalSignature, which is needed to authenticate the wallet-relying party'\n )\n }\n\n // GEN-6.6.1-03: policy identifiers\n const acceptedOids = new Set(options.acceptedPolicyOids ?? [])\n const hasAcceptedCustomPolicy = certificate.policies.some((p) => acceptedOids.has(p.oid))\n if (accessCertificate.policies.length === 0 && !hasAcceptedCustomPolicy) {\n add(\n 'error',\n C.MISSING_POLICY,\n 'Certificate does not contain an ETSI TS 119 411-8 certificate policy identifier',\n 'GEN-6.6.1-03'\n )\n }\n const policySubjectTypes = new Set(\n accessCertificate.policies.map((p) => ACCESS_CERTIFICATE_POLICY_INFO[p].subjectType)\n )\n if (policySubjectTypes.size > 1) {\n add(\n 'error',\n C.CONFLICTING_POLICIES,\n `Certificate policies for both natural and legal persons are present: ${accessCertificate.policies.join(', ')}`,\n 'GEN-6.6.1-03'\n )\n }\n\n // GEN-6.6.1-06: CPS URI\n if (!certificate.policies.some((p) => p.cpsUris.length > 0)) {\n add('error', C.MISSING_CPS_URI, 'Certificate policies do not contain a cpsURI qualifier', 'GEN-6.6.1-06')\n }\n\n // GEN-6.6.1-07: contact information in the SAN\n const { uris, emails, phoneNumbers } = accessCertificate.contact\n if (uris.length + emails.length + phoneNumbers.length === 0) {\n add(\n 'error',\n C.MISSING_CONTACT,\n 'Subject alternative name must contain a website (URI), phone number (otherName telephoneNumber) or email address (rfc822Name)',\n 'GEN-6.6.1-07'\n )\n }\n\n // Subject naming\n const subject = certificate.subject\n const subjectType = options.subjectType ?? accessCertificate.subjectType\n if (!subject.commonName) add('error', C.MISSING_COMMON_NAME, 'Subject commonName is missing')\n if (!subject.countryName) add('error', C.MISSING_COUNTRY_NAME, 'Subject countryName is missing')\n\n if (subjectType === 'legal') {\n if (!subject.organizationName) {\n add('error', C.MISSING_ORGANIZATION_NAME, 'Subject organizationName is missing (ETSI EN 319 412-3)')\n }\n if (!subject.organizationIdentifier) {\n add('error', C.MISSING_ORGANIZATION_IDENTIFIER, 'Subject organizationIdentifier is missing', 'GEN-6.6.1-05')\n } else {\n const identifier = parseSemanticIdentifier(subject.organizationIdentifier)\n if (!identifier) {\n add(\n 'error',\n C.INVALID_ORGANIZATION_IDENTIFIER,\n `organizationIdentifier \"${subject.organizationIdentifier}\" is not encoded as specified in ETSI EN 319 412-1 clause 5.1.4`,\n 'GEN-6.6.1-05'\n )\n } else if (identifier.countryCode === 'GR') {\n add(\n 'error',\n C.INVALID_GREECE_COUNTRY_CODE,\n 'organizationIdentifier must use the country code \"EL\" for Greece',\n 'GEN-6.6.1-05'\n )\n }\n }\n } else if (subjectType === 'natural') {\n if (!(subject.givenName || subject.surname) && !subject.pseudonym) {\n add(\n 'error',\n C.MISSING_NATURAL_PERSON_NAME,\n 'Subject must contain givenName and/or surname, or a pseudonym (ETSI EN 319 412-2)'\n )\n }\n if (!subject.serialNumber) {\n add(\n 'warning',\n C.MISSING_SERIAL_NUMBER,\n 'Subject serialNumber is missing; the wallet-relying party has no semantic identifier'\n )\n } else if (!parseSemanticIdentifier(subject.serialNumber)) {\n add(\n 'warning',\n C.INVALID_SERIAL_NUMBER,\n `serialNumber \"${subject.serialNumber}\" is not a semantic identifier as specified in ETSI EN 319 412-1 clause 5.1.3`\n )\n }\n } else {\n add('error', C.UNKNOWN_SUBJECT_TYPE, 'Unable to determine whether the subject is a natural or a legal person')\n }\n\n // GEN-6.6.1-02: qualified certificates follow ETSI EN 319 412-5\n if (accessCertificate.qualified) {\n if (!certificate.qcStatements?.qcCompliance) {\n add(\n 'error',\n C.MISSING_QC_COMPLIANCE,\n 'Qualified access certificates must contain the QcCompliance statement (ETSI EN 319 412-5)',\n 'GEN-6.6.1-02'\n )\n }\n const expectedType = subjectType === 'natural' ? 'esign' : subjectType === 'legal' ? 'eseal' : undefined\n const qcTypes = certificate.qcStatements?.qcTypes ?? []\n if (expectedType && !qcTypes.includes(expectedType)) {\n add(\n 'warning',\n C.QC_TYPE_MISMATCH,\n `Expected QcType ${expectedType} for a ${subjectType} person, found ${qcTypes.length ? qcTypes.join(', ') : 'none'}`,\n 'GEN-6.6.1-02'\n )\n }\n }\n\n const errors = issues.filter((i) => i.severity === 'error')\n return { valid: errors.length === 0, errors, warnings: issues.filter((i) => i.severity === 'warning') }\n}\n\n/**\n * Parse and validate an access certificate, throwing when it does not conform.\n *\n * @throws AccessCertificateException with the validation errors as details\n */\nexport function parseAndValidateAccessCertificate(\n input: CertificateInput,\n options?: AccessCertificateValidationOptions\n): AccessCertificate {\n const accessCertificate = parseAccessCertificate(input)\n assertValidAccessCertificate(accessCertificate, options)\n return accessCertificate\n}\n\n/**\n * @throws AccessCertificateException with the validation errors as details\n */\nexport function assertValidAccessCertificate(\n accessCertificate: AccessCertificate,\n options?: AccessCertificateValidationOptions\n): void {\n const result = validateAccessCertificate(accessCertificate, options)\n if (!result.valid) {\n throw new AccessCertificateException(\n `Invalid access certificate: ${result.errors.map((e) => e.message).join('; ')}`,\n result.errors\n )\n }\n}\n","import {\n ATTRIBUTE_TYPES,\n assembleCertificate,\n type CertificateTemplate,\n type NameAttributeInput,\n prepareCertificate,\n type SignatureEncoding,\n stringOtherName,\n} from '@owf/x509'\nimport { AccessCertificateException } from './access-certificate-exception'\nimport { ACCESS_CERTIFICATE_POLICIES, ACCESS_CERTIFICATE_POLICY_INFO } from './constants'\nimport { toAccessCertificate } from './profile'\nimport { parseSemanticIdentifier } from './semantic-identifier'\nimport type {\n AccessCertificate,\n CreateAccessCertificateOptions,\n LegalPersonAccessCertificateOptions,\n NaturalPersonSubjectInput,\n PrepareAccessCertificateOptions,\n PreparedAccessCertificate,\n} from './types'\nimport { validateAccessCertificate } from './validate'\n\nfunction isLegalPerson(options: PrepareAccessCertificateOptions): options is LegalPersonAccessCertificateOptions {\n return ACCESS_CERTIFICATE_POLICY_INFO[options.policy]?.subjectType === 'legal'\n}\n\nfunction subjectAttributes(options: PrepareAccessCertificateOptions): NameAttributeInput[] {\n const ous = (options.subject.organizationalUnitNames ?? []).map(\n (ou): NameAttributeInput => ['organizationalUnitName', ou]\n )\n if (isLegalPerson(options)) {\n const s = options.subject\n return [\n ['countryName', s.countryName],\n ['stateOrProvinceName', s.stateOrProvinceName],\n ['localityName', s.localityName],\n ['organizationName', s.organizationName],\n ...ous,\n ['organizationIdentifier', s.organizationIdentifier],\n ['commonName', s.commonName],\n ]\n }\n const s = options.subject as NaturalPersonSubjectInput\n return [\n ['countryName', s.countryName],\n ...ous,\n ['givenName', s.givenName],\n ['surname', s.surname],\n ['pseudonym', s.pseudonym],\n ['serialNumber', s.serialNumber],\n ['commonName', s.commonName],\n ]\n}\n\nfunction assertInput(options: PrepareAccessCertificateOptions): void {\n if (!ACCESS_CERTIFICATE_POLICIES[options.policy]) {\n throw new AccessCertificateException(`Unknown access certificate policy: ${options.policy}`)\n }\n if (!options.cpsUri) {\n throw new AccessCertificateException('cpsUri is required (GEN-6.6.1-06)')\n }\n const { uris = [], emails = [], phoneNumbers = [] } = options.contact\n if (uris.length + emails.length + phoneNumbers.length === 0) {\n throw new AccessCertificateException(\n 'At least one contact website, email address or phone number is required (GEN-6.6.1-07)'\n )\n }\n if (!/^[A-Z]{2}$/.test(options.subject.countryName)) {\n throw new AccessCertificateException('countryName must be an ISO 3166-1 alpha-2 country code')\n }\n if (isLegalPerson(options)) {\n const identifier = parseSemanticIdentifier(options.subject.organizationIdentifier)\n if (!identifier) {\n throw new AccessCertificateException(\n 'organizationIdentifier must be encoded as specified in ETSI EN 319 412-1 clause 5.1.4 (GEN-6.6.1-05)'\n )\n }\n if (identifier.countryCode === 'GR') {\n throw new AccessCertificateException('organizationIdentifier must use the country code \"EL\" for Greece')\n }\n }\n}\n\n/** Map access certificate options to a generic `@owf/x509` certificate template. */\nexport function toCertificateTemplate(options: PrepareAccessCertificateOptions): CertificateTemplate {\n assertInput(options)\n const policyInfo = ACCESS_CERTIFICATE_POLICY_INFO[options.policy]\n const cpsUris = [options.cpsUri]\n const { uris = [], emails = [], phoneNumbers = [] } = options.contact\n\n return {\n subject: subjectAttributes(options),\n subjectPublicKey: options.subjectPublicKey,\n issuerCertificate: options.issuerCertificate,\n serialNumber: options.serialNumber,\n notBefore: options.notBefore,\n notAfter: options.notAfter,\n signatureAlgorithm: options.signatureAlgorithm,\n basicConstraints: { cA: false },\n keyUsage: options.keyUsage ?? ['digitalSignature'],\n extendedKeyUsage: options.extendedKeyUsage,\n certificatePolicies: [\n { oid: ACCESS_CERTIFICATE_POLICIES[options.policy], cpsUris },\n ...(options.additionalPolicyOids ?? []).map((oid) => ({ oid, cpsUris })),\n ],\n subjectAlternativeNames: {\n dnsNames: options.dnsNames,\n uris,\n emails,\n otherNames: phoneNumbers.map((phone) => stringOtherName(ATTRIBUTE_TYPES.telephoneNumber, phone)),\n },\n crlDistributionPoints: options.crlDistributionPoints,\n ocspUrls: options.ocspUrls,\n caIssuersUrls: options.caIssuersUrls,\n qcStatements: policyInfo.qualified\n ? { ...options.qcStatements, qcTypes: [policyInfo.subjectType === 'legal' ? 'eseal' : 'esign'] }\n : undefined,\n hasher: options.hasher,\n }\n}\n\n/**\n * Build the TBSCertificate of an access certificate per ETSI TS 119 411-8 clause 6.6.1.\n *\n * Sign the returned `tbs` bytes with the issuing CA key wherever that key lives and pass the\n * signature to {@link assembleAccessCertificate}. {@link createAccessCertificate} wraps both\n * steps around a signer callback.\n */\nexport function prepareAccessCertificate(options: PrepareAccessCertificateOptions): Promise<PreparedAccessCertificate> {\n return prepareCertificate(toCertificateTemplate(options))\n}\n\n/**\n * Combine a prepared TBSCertificate with the signature of the issuing CA.\n *\n * @param signatureEncoding Encoding of ECDSA signatures; WebCrypto produces `ieee-p1363` (default)\n */\nexport function assembleAccessCertificate(\n prepared: PreparedAccessCertificate,\n signature: Uint8Array,\n signatureEncoding?: SignatureEncoding\n): AccessCertificate {\n return toAccessCertificate(assembleCertificate(prepared, signature, signatureEncoding))\n}\n\n/**\n * Create a wallet-relying party access certificate per ETSI TS 119 411-8.\n *\n * The issuing CA key is never passed in: the `signer` callback receives the DER encoded\n * TBSCertificate and returns the signature, so the key can stay in WebCrypto, a KMS or an HSM.\n * Likewise only the public key of the wallet-relying party is needed; a JWK that contains\n * private key material is rejected.\n *\n * @throws AccessCertificateException when the input or the resulting certificate does not\n * satisfy the certificate profile\n */\nexport async function createAccessCertificate(options: CreateAccessCertificateOptions): Promise<AccessCertificate> {\n const prepared = await prepareAccessCertificate(options)\n const signature = await options.signer(prepared.tbs)\n const accessCertificate = assembleAccessCertificate(prepared, signature, options.signatureEncoding)\n\n const result = validateAccessCertificate(accessCertificate, { now: false })\n if (!result.valid) {\n throw new AccessCertificateException(\n `Created access certificate does not conform: ${result.errors.map((e) => e.message).join('; ')}`,\n result.errors\n )\n }\n return accessCertificate\n}\n"],"mappings":";;;;;;;AAMA,IAAa,6BAAb,MAAa,mCAAmC,kBAAkB;CAChE,YAAY,SAAiB,SAAmB;EAC9C,MAAM,SAAS,OAAO;EACtB,OAAO,eAAe,MAAM,2BAA2B,SAAS;EAChE,KAAK,OAAO;CACd;AACF;;;;;;;;ACPA,MAAa,8BAA8B;;CAEzC,iBAAiB;;CAEjB,iBAAiB;;CAEjB,iBAAiB;;CAEjB,iBAAiB;AACnB;AAOA,MAAa,iCAGT;CACF,iBAAiB;EAAE,aAAa;EAAW,WAAW;CAAM;CAC5D,iBAAiB;EAAE,aAAa;EAAS,WAAW;CAAM;CAC1D,iBAAiB;EAAE,aAAa;EAAW,WAAW;CAAK;CAC3D,iBAAiB;EAAE,aAAa;EAAS,WAAW;CAAK;AAC3D;;;AC3BA,MAAM,sBAAsB;;;;;;AAO5B,SAAgB,wBAAwB,OAA+C;CACrF,MAAM,QAAQ,MAAM,MAAM,mBAAmB;CAC7C,IAAI,CAAC,OAAO,OAAO,KAAA;CACnB,MAAM,GAAG,MAAM,aAAa,aAAa,cAAc;CACvD,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,MADtC,QAAQ,OAAO,SAAS,GAAG,GACsB,QAAQ,iBAAiB;CAElG,MAAM,SAAS,0BAA0B,mBAAmB,EAAE,KAAK,MAAM,CAAC;CAC1E,IAAI,CAAC,OAAO,OACV,MAAM,IAAI,2BACR,gDAAgD,OAAO,OAAO,KAAK,MAAM,EAAE,OAAO,CAAC,CAAC,KAAK,IAAI,KAC7F,OAAO,MACT;CAEF,OAAO;AACT"}
package/package.json CHANGED
@@ -1,6 +1,48 @@
1
1
  {
2
2
  "name": "@owf/eudi-access-certificate",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.0",
4
+ "description": "Parse, validate and create EUDI Wallet-Relying Party access certificates per ETSI TS 119 411-8",
5
+ "files": [
6
+ "dist"
7
+ ],
8
+ "license": "Apache-2.0",
9
+ "exports": "./src/index.ts",
10
+ "homepage": "https://github.com/openwallet-foundation-labs/identity-common-ts/tree/main/packages/eudi-access-certificate",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/openwallet-foundation-labs/identity-common-ts",
14
+ "directory": "packages/eudi-access-certificate"
15
+ },
16
+ "publishConfig": {
17
+ "access": "public",
18
+ "main": "./dist/index.cjs",
19
+ "module": "./dist/index.mjs",
20
+ "types": "./dist/index.d.mts",
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/index.d.mts",
24
+ "import": "./dist/index.mjs",
25
+ "require": "./dist/index.cjs",
26
+ "default": "./dist/index.mjs"
27
+ },
28
+ "./package.json": "./package.json"
29
+ }
30
+ },
31
+ "scripts": {
32
+ "build": "tsdown src/index.ts --format esm,cjs --dts --sourcemap"
33
+ },
34
+ "dependencies": {
35
+ "@owf/identity-common": "workspace:*",
36
+ "@owf/x509": "workspace:*"
37
+ },
38
+ "keywords": [
39
+ "eudi",
40
+ "wallet",
41
+ "access-certificate",
42
+ "relying-party",
43
+ "etsi",
44
+ "ts-119-411-8",
45
+ "x509",
46
+ "eidas"
47
+ ]
48
+ }