edockit 0.3.0 → 0.4.0-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +81 -198
  3. package/TRUSTED-LIST.md +308 -0
  4. package/dist/certificate-3c9dcdac.js +549 -0
  5. package/dist/certificate-3c9dcdac.js.map +1 -0
  6. package/dist/certificate-c7123a37.js +581 -0
  7. package/dist/certificate-c7123a37.js.map +1 -0
  8. package/dist/core/canonicalization/XMLCanonicalizer.d.ts +9 -3
  9. package/dist/core/trustedlist/build.d.ts +41 -0
  10. package/dist/core/trustedlist/bundled-provider.d.ts +2 -0
  11. package/dist/core/trustedlist/contract.d.ts +19 -0
  12. package/dist/core/trustedlist/dom.d.ts +12 -0
  13. package/dist/core/trustedlist/extract.d.ts +6 -0
  14. package/dist/core/trustedlist/http.d.ts +8 -0
  15. package/dist/core/trustedlist/identity.d.ts +7 -0
  16. package/dist/core/trustedlist/index.d.ts +18 -0
  17. package/dist/core/trustedlist/loader.d.ts +5 -0
  18. package/dist/core/trustedlist/matcher.d.ts +11 -0
  19. package/dist/core/trustedlist/normalize.d.ts +14 -0
  20. package/dist/core/trustedlist/reference-provider.d.ts +12 -0
  21. package/dist/core/trustedlist/types.d.ts +114 -0
  22. package/dist/core/unzip.d.ts +0 -0
  23. package/dist/core/verification.d.ts +22 -0
  24. package/dist/data/trusted-list.d.ts +3 -0
  25. package/dist/identity-c9e5052e.js +410 -0
  26. package/dist/identity-c9e5052e.js.map +1 -0
  27. package/dist/identity-fca881b1.js +406 -0
  28. package/dist/identity-fca881b1.js.map +1 -0
  29. package/dist/index.cjs.js +540 -8838
  30. package/dist/index.cjs.js.map +1 -1
  31. package/dist/index.d.ts +4 -2
  32. package/dist/index.esm.js +498 -8795
  33. package/dist/index.esm.js.map +1 -1
  34. package/dist/index.umd.js +23 -17
  35. package/dist/index.umd.js.map +1 -1
  36. package/dist/loader-7a0f771f.js +222 -0
  37. package/dist/loader-7a0f771f.js.map +1 -0
  38. package/dist/loader-ad1a5051.js +217 -0
  39. package/dist/loader-ad1a5051.js.map +1 -0
  40. package/dist/normalize-50862581.js +456 -0
  41. package/dist/normalize-50862581.js.map +1 -0
  42. package/dist/normalize-9626be7c.js +479 -0
  43. package/dist/normalize-9626be7c.js.map +1 -0
  44. package/dist/reference-provider-3838ebfb.js +217 -0
  45. package/dist/reference-provider-3838ebfb.js.map +1 -0
  46. package/dist/reference-provider-9bbbaab8.js +211 -0
  47. package/dist/reference-provider-9bbbaab8.js.map +1 -0
  48. package/dist/trusted-list-build.cjs.js +580 -0
  49. package/dist/trusted-list-build.cjs.js.map +1 -0
  50. package/dist/trusted-list-build.d.ts +4 -0
  51. package/dist/trusted-list-build.esm.js +569 -0
  52. package/dist/trusted-list-build.esm.js.map +1 -0
  53. package/dist/trusted-list-bundled.cjs.js +30439 -0
  54. package/dist/trusted-list-bundled.cjs.js.map +1 -0
  55. package/dist/trusted-list-bundled.d.ts +1 -0
  56. package/dist/trusted-list-bundled.esm.js +30435 -0
  57. package/dist/trusted-list-bundled.esm.js.map +1 -0
  58. package/dist/trusted-list-http.cjs.js +85 -0
  59. package/dist/trusted-list-http.cjs.js.map +1 -0
  60. package/dist/trusted-list-http.d.ts +1 -0
  61. package/dist/trusted-list-http.esm.js +81 -0
  62. package/dist/trusted-list-http.esm.js.map +1 -0
  63. package/dist/trusted-list.cjs.js +38 -0
  64. package/dist/trusted-list.cjs.js.map +1 -0
  65. package/dist/trusted-list.d.ts +9 -0
  66. package/dist/trusted-list.esm.js +13 -0
  67. package/dist/trusted-list.esm.js.map +1 -0
  68. package/package.json +32 -2
@@ -0,0 +1,581 @@
1
+ /*!
2
+ * MIT License
3
+ * Copyright (c) 2025 Edgars Jēkabsons, ZenomyTech SIA
4
+ */
5
+ 'use strict';
6
+
7
+ var xmldom = require('@xmldom/xmldom');
8
+ var xpath = require('xpath');
9
+ var x509 = require('@peculiar/x509');
10
+
11
+ function _interopNamespace(e) {
12
+ if (e && e.__esModule) return e;
13
+ var n = Object.create(null);
14
+ if (e) {
15
+ Object.keys(e).forEach(function (k) {
16
+ if (k !== 'default') {
17
+ var d = Object.getOwnPropertyDescriptor(e, k);
18
+ Object.defineProperty(n, k, d.get ? d : {
19
+ enumerable: true,
20
+ get: function () { return e[k]; }
21
+ });
22
+ }
23
+ });
24
+ }
25
+ n["default"] = e;
26
+ return Object.freeze(n);
27
+ }
28
+
29
+ var xmldom__namespace = /*#__PURE__*/_interopNamespace(xmldom);
30
+ var xpath__namespace = /*#__PURE__*/_interopNamespace(xpath);
31
+
32
+ /**
33
+ * Recursive DOM traversal to find elements with a given tag name
34
+ * (Fallback method when XPath is not available or fails)
35
+ *
36
+ * @param parent The parent element to search within
37
+ * @param selector CSS-like selector with namespace support (e.g., "ds:SignedInfo, SignedInfo")
38
+ * @returns Array of matching elements
39
+ */
40
+ function findElementsByTagNameRecursive(parent, selector) {
41
+ const results = [];
42
+ const selectors = selector.split(",").map((s) => s.trim());
43
+ // Parse each selector part to extract namespace and local name
44
+ const parsedSelectors = [];
45
+ for (const sel of selectors) {
46
+ const parts = sel.split(/\\:|:/).filter(Boolean);
47
+ if (parts.length === 1) {
48
+ parsedSelectors.push({ name: parts[0] });
49
+ }
50
+ else if (parts.length === 2) {
51
+ parsedSelectors.push({ ns: parts[0], name: parts[1] });
52
+ }
53
+ }
54
+ // Recursive search function - keep the original node references
55
+ function searchNode(node) {
56
+ if (!node)
57
+ return;
58
+ if (node.nodeType === 1) {
59
+ // Element node - make sure we're working with an actual DOM Element
60
+ const element = node;
61
+ const nodeName = element.nodeName;
62
+ const localName = element.localName;
63
+ // Check if this element matches any of our selectors
64
+ for (const sel of parsedSelectors) {
65
+ // Match by full nodeName (which might include namespace prefix)
66
+ if (sel.ns && nodeName === `${sel.ns}:${sel.name}`) {
67
+ results.push(element); // Store the actual DOM element reference
68
+ break;
69
+ }
70
+ // Match by local name only
71
+ if (localName === sel.name || nodeName === sel.name) {
72
+ results.push(element); // Store the actual DOM element reference
73
+ break;
74
+ }
75
+ // Match by checking if nodeName ends with the local name
76
+ if (nodeName.endsWith(`:${sel.name}`)) {
77
+ results.push(element); // Store the actual DOM element reference
78
+ break;
79
+ }
80
+ }
81
+ }
82
+ // Search all child nodes
83
+ if (node.childNodes) {
84
+ for (let i = 0; i < node.childNodes.length; i++) {
85
+ searchNode(node.childNodes[i]);
86
+ }
87
+ }
88
+ }
89
+ searchNode(parent);
90
+ return results;
91
+ }
92
+ // Known XML namespaces used in XML Signatures and related standards
93
+ const NAMESPACES = {
94
+ ds: "http://www.w3.org/2000/09/xmldsig#",
95
+ dsig11: "http://www.w3.org/2009/xmldsig11#",
96
+ dsig2: "http://www.w3.org/2010/xmldsig2#",
97
+ ec: "http://www.w3.org/2001/10/xml-exc-c14n#",
98
+ dsig_more: "http://www.w3.org/2001/04/xmldsig-more#",
99
+ xenc: "http://www.w3.org/2001/04/xmlenc#",
100
+ xenc11: "http://www.w3.org/2009/xmlenc11#",
101
+ xades: "http://uri.etsi.org/01903/v1.3.2#",
102
+ xades141: "http://uri.etsi.org/01903/v1.4.1#",
103
+ asic: "http://uri.etsi.org/02918/v1.2.1#",
104
+ };
105
+ /**
106
+ * Create an XML parser that works in both browser and Node environments
107
+ */
108
+ function createXMLParser() {
109
+ // Check if we're in a browser environment with native DOM support
110
+ if (typeof window !== "undefined" && window.DOMParser) {
111
+ return new window.DOMParser();
112
+ }
113
+ // We're in Node.js, so use xmldom
114
+ return new xmldom__namespace.DOMParser();
115
+ }
116
+ /**
117
+ * Uses XPath to find a single element in an XML document
118
+ *
119
+ * @param parent The parent element or document to search within
120
+ * @param xpathExpression The XPath expression to evaluate
121
+ * @param namespaces Optional namespace mapping (defaults to common XML signature namespaces)
122
+ * @returns The found element or null
123
+ */
124
+ function queryByXPath(parent, xpathExpression, namespaces = NAMESPACES) {
125
+ try {
126
+ // Browser environment with native XPath
127
+ if (typeof document !== "undefined" && typeof document.evaluate === "function") {
128
+ // Use the document that owns the parent node, not the global document
129
+ const ownerDoc = "ownerDocument" in parent ? parent.ownerDocument : parent;
130
+ if (!ownerDoc || typeof ownerDoc.evaluate !== "function") {
131
+ // XMLDocuments from DOMParser don't have evaluate - silently return null
132
+ // (caller should use DOM traversal fallback)
133
+ return null;
134
+ }
135
+ const nsResolver = createNsResolverForBrowser(namespaces);
136
+ const result = ownerDoc.evaluate(xpathExpression, parent, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
137
+ return result.singleNodeValue;
138
+ }
139
+ // Node.js environment with xpath module
140
+ else {
141
+ const xpathLib = xpath__namespace;
142
+ const nsResolver = createNsResolverForNode(namespaces);
143
+ // Use a try-catch here to handle specific XPath issues
144
+ try {
145
+ const nodes = xpathLib.select(xpathExpression, parent, nsResolver);
146
+ return nodes.length > 0 ? nodes[0] : null;
147
+ }
148
+ catch (err) {
149
+ // If we get a namespace error, try a simpler XPath with just local-name()
150
+ if (typeof err === "object" &&
151
+ err !== null &&
152
+ "message" in err &&
153
+ typeof err.message === "string" &&
154
+ err.message.includes("Cannot resolve QName")) {
155
+ // Extract the element name we're looking for from the XPath
156
+ const match = xpathExpression.match(/local-name\(\)='([^']+)'/);
157
+ if (match && match[1]) {
158
+ const elementName = match[1];
159
+ const simplifiedXPath = `.//*[local-name()='${elementName}']`;
160
+ const nodes = xpathLib.select(simplifiedXPath, parent);
161
+ return nodes.length > 0 ? nodes[0] : null;
162
+ }
163
+ }
164
+ throw err; // Re-throw if we couldn't handle it
165
+ }
166
+ }
167
+ }
168
+ catch (e) {
169
+ console.error(`XPath evaluation failed for "${xpathExpression}":`, e);
170
+ return null;
171
+ }
172
+ }
173
+ /**
174
+ * Uses XPath to find all matching elements in an XML document
175
+ *
176
+ * @param parent The parent element or document to search within
177
+ * @param xpathExpression The XPath expression to evaluate
178
+ * @param namespaces Optional namespace mapping (defaults to common XML signature namespaces)
179
+ * @returns Array of matching elements
180
+ */
181
+ function queryAllByXPath(parent, xpathExpression, namespaces = NAMESPACES) {
182
+ try {
183
+ // Browser environment with native XPath
184
+ if (typeof document !== "undefined" && typeof document.evaluate === "function") {
185
+ // Use the document that owns the parent node, not the global document
186
+ const ownerDoc = "ownerDocument" in parent ? parent.ownerDocument : parent;
187
+ if (!ownerDoc || typeof ownerDoc.evaluate !== "function") {
188
+ // XMLDocuments from DOMParser don't have evaluate - silently return empty
189
+ // (caller should use DOM traversal fallback)
190
+ return [];
191
+ }
192
+ const nsResolver = createNsResolverForBrowser(namespaces);
193
+ const result = ownerDoc.evaluate(xpathExpression, parent, nsResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
194
+ const elements = [];
195
+ for (let i = 0; i < result.snapshotLength; i++) {
196
+ elements.push(result.snapshotItem(i));
197
+ }
198
+ return elements;
199
+ }
200
+ // Node.js environment with xpath module
201
+ else {
202
+ const xpathLib = xpath__namespace;
203
+ const nsResolver = createNsResolverForNode(namespaces);
204
+ // Use a try-catch here to handle specific XPath issues
205
+ try {
206
+ const nodes = xpathLib.select(xpathExpression, parent, nsResolver);
207
+ return nodes;
208
+ }
209
+ catch (err) {
210
+ // If we get a namespace error, try a simpler XPath with just local-name()
211
+ if (typeof err === "object" &&
212
+ err !== null &&
213
+ "message" in err &&
214
+ typeof err.message === "string" &&
215
+ err.message.includes("Cannot resolve QName")) {
216
+ // Extract the element name we're looking for from the XPath
217
+ const match = xpathExpression.match(/local-name\(\)='([^']+)'/);
218
+ if (match && match[1]) {
219
+ const elementName = match[1];
220
+ const simplifiedXPath = `.//*[local-name()='${elementName}']`;
221
+ const nodes = xpathLib.select(simplifiedXPath, parent);
222
+ return nodes;
223
+ }
224
+ }
225
+ throw err; // Re-throw if we couldn't handle it
226
+ }
227
+ }
228
+ }
229
+ catch (e) {
230
+ console.error(`XPath evaluation failed for "${xpathExpression}":`, e);
231
+ return [];
232
+ }
233
+ }
234
+ /**
235
+ * Helper function to create a namespace resolver for browser environments
236
+ */
237
+ function createNsResolverForBrowser(namespaces) {
238
+ return function (prefix) {
239
+ if (prefix === null)
240
+ return null;
241
+ return namespaces[prefix] || null;
242
+ };
243
+ }
244
+ /**
245
+ * Helper function to create a namespace resolver for Node.js environments
246
+ */
247
+ function createNsResolverForNode(namespaces) {
248
+ return namespaces;
249
+ }
250
+ /**
251
+ * Converts a CSS-like selector (with namespace support) to an XPath expression
252
+ *
253
+ * @param selector CSS-like selector (e.g., "ds:SignedInfo, SignedInfo")
254
+ * @returns Equivalent XPath expression
255
+ */
256
+ function selectorToXPath(selector) {
257
+ // Split by comma to handle alternative selectors
258
+ const parts = selector.split(",").map((s) => s.trim());
259
+ const xpathParts = [];
260
+ for (const part of parts) {
261
+ // Handle namespaced selectors (both prefix:name and prefix\\:name formats)
262
+ const segments = part.split(/\\:|:/).filter(Boolean);
263
+ if (segments.length === 1) {
264
+ // Simple element name without namespace
265
+ // Match any element with the right local name
266
+ xpathParts.push(`.//*[local-name()='${segments[0]}']`);
267
+ }
268
+ else if (segments.length === 2) {
269
+ // Element with namespace prefix - only use local-name() or specific namespace prefix
270
+ // that we know is registered, avoiding the generic 'ns:' prefix
271
+ xpathParts.push(`.//${segments[0]}:${segments[1]} | .//*[local-name()='${segments[1]}']`);
272
+ }
273
+ }
274
+ // Join with | operator (XPath's OR)
275
+ return xpathParts.join(" | ");
276
+ }
277
+ /**
278
+ * Enhanced querySelector that uses XPath for better namespace handling
279
+ * (Drop-in replacement for the original querySelector function)
280
+ *
281
+ * @param parent The parent element or document to search within
282
+ * @param selector A CSS-like selector (with namespace handling)
283
+ * @returns The found element or null
284
+ */
285
+ function querySelector(parent, selector) {
286
+ // First try native querySelector if we're in a browser
287
+ if (typeof parent.querySelector === "function") {
288
+ try {
289
+ const result = parent.querySelector(selector);
290
+ if (result)
291
+ return result;
292
+ }
293
+ catch (e) {
294
+ // Fallback to XPath if querySelector fails (e.g., due to namespace issues)
295
+ }
296
+ }
297
+ // First try with our enhanced DOM traversal methods (more reliable in some cases)
298
+ const elements = findElementsByTagNameRecursive(parent, selector);
299
+ if (elements.length > 0) {
300
+ return elements[0];
301
+ }
302
+ // Then try XPath as a fallback
303
+ try {
304
+ const xpathExpr = selectorToXPath(selector);
305
+ return queryByXPath(parent, xpathExpr);
306
+ }
307
+ catch (e) {
308
+ console.warn("XPath query failed, using direct DOM traversal as fallback");
309
+ return null;
310
+ }
311
+ }
312
+ /**
313
+ * Enhanced querySelectorAll that uses XPath for better namespace handling
314
+ * (Drop-in replacement for the original querySelectorAll function)
315
+ *
316
+ * @param parent The parent element or document to search within
317
+ * @param selector A CSS-like selector (with namespace handling)
318
+ * @returns Array of matching elements
319
+ */
320
+ function querySelectorAll(parent, selector) {
321
+ // First try native querySelectorAll if we're in a browser
322
+ if (typeof parent.querySelectorAll === "function") {
323
+ try {
324
+ const results = parent.querySelectorAll(selector);
325
+ if (results.length > 0) {
326
+ const elements = [];
327
+ for (let i = 0; i < results.length; i++) {
328
+ elements.push(results[i]);
329
+ }
330
+ return elements;
331
+ }
332
+ }
333
+ catch (e) {
334
+ // Fallback to XPath if querySelectorAll fails (e.g., due to namespace issues)
335
+ }
336
+ }
337
+ // First try with our enhanced DOM traversal methods (more reliable in some cases)
338
+ const elements = findElementsByTagNameRecursive(parent, selector);
339
+ if (elements.length > 0) {
340
+ return elements;
341
+ }
342
+ // Then try XPath as a fallback
343
+ try {
344
+ const xpathExpr = selectorToXPath(selector);
345
+ return queryAllByXPath(parent, xpathExpr);
346
+ }
347
+ catch (e) {
348
+ console.warn("XPath query failed, using direct DOM traversal as fallback");
349
+ return [];
350
+ }
351
+ }
352
+ /**
353
+ * Serialize a DOM node to XML string
354
+ */
355
+ function serializeToXML(node) {
356
+ // Check if we're in a browser environment with native XMLSerializer
357
+ if (typeof window !== "undefined" && window.XMLSerializer) {
358
+ return new window.XMLSerializer().serializeToString(node);
359
+ }
360
+ // Node.js — use xmldom
361
+ return new xmldom__namespace.XMLSerializer().serializeToString(node);
362
+ }
363
+
364
+ /**
365
+ * Format a certificate string as a proper PEM certificate
366
+ * @param certBase64 Base64-encoded certificate
367
+ * @returns Formatted PEM certificate
368
+ */
369
+ function formatPEM(certBase64) {
370
+ if (!certBase64)
371
+ return "";
372
+ // Remove any whitespace from the base64 string
373
+ const cleanBase64 = certBase64.replace(/\s+/g, "");
374
+ // Split the base64 into lines of 64 characters
375
+ const lines = [];
376
+ for (let i = 0; i < cleanBase64.length; i += 64) {
377
+ lines.push(cleanBase64.substring(i, i + 64));
378
+ }
379
+ // Format as PEM certificate
380
+ return `-----BEGIN CERTIFICATE-----\n${lines.join("\n")}\n-----END CERTIFICATE-----`;
381
+ }
382
+ /**
383
+ * Extract subject information from an X.509 certificate
384
+ * @param certificate X509Certificate instance
385
+ * @returns Signer information object
386
+ */
387
+ function extractSignerInfo(certificate) {
388
+ const result = {
389
+ validFrom: certificate.notBefore,
390
+ validTo: certificate.notAfter,
391
+ issuer: {},
392
+ };
393
+ // Try to extract fields using various approaches
394
+ // Approach 1: Try direct access to typed subject properties
395
+ try {
396
+ if (typeof certificate.subject === "object" && certificate.subject !== null) {
397
+ // Handle subject properties
398
+ const subject = certificate.subject;
399
+ result.commonName = subject.commonName;
400
+ result.organization = subject.organizationName;
401
+ result.country = subject.countryName;
402
+ }
403
+ // Handle issuer properties
404
+ if (typeof certificate.issuer === "object" && certificate.issuer !== null) {
405
+ const issuer = certificate.issuer;
406
+ result.issuer.commonName = issuer.commonName;
407
+ result.issuer.organization = issuer.organizationName;
408
+ result.issuer.country = issuer.countryName;
409
+ }
410
+ }
411
+ catch (e) {
412
+ console.warn("Could not extract subject/issuer as objects:", e);
413
+ }
414
+ // Approach 2: Parse subject/issuer as strings if they are strings
415
+ try {
416
+ if (typeof certificate.subject === "string") {
417
+ const subjectStr = certificate.subject;
418
+ // Parse the string format (usually CN=name,O=org,C=country)
419
+ const subjectParts = subjectStr.split(",");
420
+ for (const part of subjectParts) {
421
+ const [key, value] = part.trim().split("=");
422
+ if (key === "CN")
423
+ result.commonName = result.commonName || value;
424
+ if (key === "O")
425
+ result.organization = result.organization || value;
426
+ if (key === "C")
427
+ result.country = result.country || value;
428
+ if (key === "SN")
429
+ result.surname = value;
430
+ if (key === "G" || key === "GN")
431
+ result.givenName = value;
432
+ if (key === "SERIALNUMBER" || key === "2.5.4.5")
433
+ result.serialNumber = value?.replace("PNOLV-", "");
434
+ }
435
+ }
436
+ if (typeof certificate.issuer === "string") {
437
+ const issuerStr = certificate.issuer;
438
+ // Parse the string format
439
+ const issuerParts = issuerStr.split(",");
440
+ for (const part of issuerParts) {
441
+ const [key, value] = part.trim().split("=");
442
+ if (key === "CN")
443
+ result.issuer.commonName = result.issuer.commonName || value;
444
+ if (key === "O")
445
+ result.issuer.organization = result.issuer.organization || value;
446
+ if (key === "C")
447
+ result.issuer.country = result.issuer.country || value;
448
+ }
449
+ }
450
+ }
451
+ catch (e) {
452
+ console.warn("Could not extract subject/issuer as strings:", e);
453
+ }
454
+ // Approach 3: Try to use getField method if available
455
+ try {
456
+ if ("subjectName" in certificate && certificate.subjectName?.getField) {
457
+ const subjectName = certificate.subjectName;
458
+ // Only set if not already set from previous approaches
459
+ result.commonName = result.commonName || subjectName.getField("CN")?.[0];
460
+ result.surname = result.surname || subjectName.getField("SN")?.[0];
461
+ result.givenName = result.givenName || subjectName.getField("G")?.[0];
462
+ result.serialNumber =
463
+ result.serialNumber || subjectName.getField("2.5.4.5")?.[0]?.replace("PNOLV-", "");
464
+ result.country = result.country || subjectName.getField("C")?.[0];
465
+ result.organization = result.organization || subjectName.getField("O")?.[0];
466
+ }
467
+ }
468
+ catch (e) {
469
+ console.warn("Could not extract fields using getField method:", e);
470
+ }
471
+ // Get the serial number from the certificate if not found in subject
472
+ if (!result.serialNumber && certificate.serialNumber) {
473
+ result.serialNumber = certificate.serialNumber;
474
+ }
475
+ return result;
476
+ }
477
+ /**
478
+ * Parse a certificate from base64 data
479
+ * @param certData Base64-encoded certificate data
480
+ * @returns Parsed certificate information
481
+ */
482
+ async function parseCertificate(certData) {
483
+ try {
484
+ let pemCert = certData;
485
+ // Check if it's already in PEM format, if not, convert it
486
+ if (!certData.includes("-----BEGIN CERTIFICATE-----")) {
487
+ // Only clean non-PEM format data before conversion
488
+ const cleanedCertData = certData.replace(/[\r\n\s]/g, "");
489
+ pemCert = formatPEM(cleanedCertData);
490
+ }
491
+ const cert = new x509.X509Certificate(pemCert);
492
+ const signerInfo = extractSignerInfo(cert);
493
+ return {
494
+ subject: {
495
+ commonName: signerInfo.commonName,
496
+ organization: signerInfo.organization,
497
+ country: signerInfo.country,
498
+ surname: signerInfo.surname,
499
+ givenName: signerInfo.givenName,
500
+ serialNumber: signerInfo.serialNumber,
501
+ },
502
+ validFrom: signerInfo.validFrom,
503
+ validTo: signerInfo.validTo,
504
+ issuer: signerInfo.issuer,
505
+ serialNumber: cert.serialNumber,
506
+ };
507
+ }
508
+ catch (error) {
509
+ console.error("Certificate parsing error:", error);
510
+ throw new Error("Failed to parse certificate: " + (error instanceof Error ? error.message : String(error)));
511
+ }
512
+ }
513
+ /**
514
+ * Check if a certificate was valid at a specific time
515
+ * @param cert Certificate object or info
516
+ * @param checkTime The time to check validity against (defaults to current time)
517
+ * @returns Validity check result
518
+ */
519
+ function checkCertificateValidity(cert, checkTime = new Date()) {
520
+ // Extract validity dates based on input type
521
+ const validFrom = "notBefore" in cert ? cert.notBefore : cert.validFrom;
522
+ const validTo = "notAfter" in cert ? cert.notAfter : cert.validTo;
523
+ // Check if certificate is valid at the specified time
524
+ if (checkTime < validFrom) {
525
+ return {
526
+ isValid: false,
527
+ reason: `Certificate not yet valid. Valid from ${validFrom.toISOString()}`,
528
+ };
529
+ }
530
+ if (checkTime > validTo) {
531
+ return {
532
+ isValid: false,
533
+ reason: `Certificate expired. Valid until ${validTo.toISOString()}`,
534
+ };
535
+ }
536
+ return { isValid: true };
537
+ }
538
+ /**
539
+ * Helper function to get signer display name from certificate
540
+ * @param certInfo Certificate information
541
+ * @returns Formatted display name
542
+ */
543
+ function getSignerDisplayName(certInfo) {
544
+ const { subject } = certInfo;
545
+ if (subject.givenName && subject.surname) {
546
+ return `${subject.givenName} ${subject.surname}`;
547
+ }
548
+ if (subject.commonName) {
549
+ return subject.commonName;
550
+ }
551
+ // Fallback to serial number if available
552
+ return subject.serialNumber || "Unknown Signer";
553
+ }
554
+ /**
555
+ * Helper function to format certificate validity period in a human-readable format
556
+ * @param certInfo Certificate information
557
+ * @returns Formatted validity period
558
+ */
559
+ function formatValidityPeriod(certInfo) {
560
+ const { validFrom, validTo } = certInfo;
561
+ const formatDate = (date) => {
562
+ return date.toLocaleDateString(undefined, {
563
+ year: "numeric",
564
+ month: "long",
565
+ day: "numeric",
566
+ });
567
+ };
568
+ return `${formatDate(validFrom)} to ${formatDate(validTo)}`;
569
+ }
570
+
571
+ exports.checkCertificateValidity = checkCertificateValidity;
572
+ exports.createXMLParser = createXMLParser;
573
+ exports.extractSignerInfo = extractSignerInfo;
574
+ exports.formatPEM = formatPEM;
575
+ exports.formatValidityPeriod = formatValidityPeriod;
576
+ exports.getSignerDisplayName = getSignerDisplayName;
577
+ exports.parseCertificate = parseCertificate;
578
+ exports.querySelector = querySelector;
579
+ exports.querySelectorAll = querySelectorAll;
580
+ exports.serializeToXML = serializeToXML;
581
+ //# sourceMappingURL=certificate-c7123a37.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"certificate-c7123a37.js","sources":["../src/utils/xmlParser.ts","../src/core/certificate.ts"],"sourcesContent":[null,null],"names":["xmldom","xpath","X509Certificate"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;;;;;;AAOG;AACa,SAAA,8BAA8B,CAAC,MAAY,EAAE,QAAgB,EAAA;IAC3E,MAAM,OAAO,GAAc,EAAE,CAAC;IAC9B,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;;IAG3D,MAAM,eAAe,GAAyC,EAAE,CA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D;;;;AAIG;AACG,SAAU,oBAAoB,CAAC,QAAyB,EAAA;AAC5D,IAAA,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC;IAE7B,IAAI,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,OAAO,EAAE;QACxC,OAAO,CAAA,EAAG,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,OAAO,CAAA,CAAE,CAAC;KAClD;AAED,IAAA,IAAI,OAAO,CAAC,UAAU,EAAE;QACtB,OAAO,OAAO,CAAC,UAAU,CAAC;KAC3B;;AAGD,IAAA,OAAO,OAAO,CAAC,YAAY,IAAI,gBAAgB,CAAC;AAClD,CAAC;AAED;;;;AAIG;AACG,SAAU,oBAAoB,CAAC,QAAyB,EAAA;AAC5D,IAAA,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC;AAExC,IAAA,MAAM,UAAU,GAAG,CAAC,IAAU,KAAI;AAChC,QAAA,OAAO,IAAI,CAAC,kBAAkB,CAAC,SAAS,EAAE;AACxC,YAAA,IAAI,EAAE,SAAS;AACf,YAAA,KAAK,EAAE,MAAM;AACb,YAAA,GAAG,EAAE,SAAS;AACf,SAAA,CAAC,CAAC;AACL,KAAC,CAAC;IAEF,OAAO,CAAA,EAAG,UAAU,CAAC,SAAS,CAAC,CAAO,IAAA,EAAA,UAAU,CAAC,OAAO,CAAC,CAAA,CAAE,CAAC;AAC9D;;;;;;;;;;;;;"}
@@ -8,8 +8,11 @@ interface CanonMethod {
8
8
  declare const CANONICALIZATION_METHODS: {
9
9
  default: string;
10
10
  "http://www.w3.org/TR/2001/REC-xml-c14n-20010315": string;
11
+ "http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments": string;
11
12
  "http://www.w3.org/2006/12/xml-c14n11": string;
13
+ "http://www.w3.org/2006/12/xml-c14n11#WithComments": string;
12
14
  "http://www.w3.org/2001/10/xml-exc-c14n#": string;
15
+ "http://www.w3.org/2001/10/xml-exc-c14n#WithComments": string;
13
16
  };
14
17
  declare const NODE_TYPES: {
15
18
  ELEMENT_NODE: number;
@@ -19,6 +22,10 @@ interface ExcC14NOptions {
19
22
  inclusiveNamespacePrefixList?: string[];
20
23
  isStartingNode?: boolean;
21
24
  }
25
+ interface CanonicalizeOptions {
26
+ inclusiveNamespacePrefixList?: string[];
27
+ isStartingNode?: boolean;
28
+ }
22
29
  interface WhitespaceInfo {
23
30
  hasMixedContent?: boolean;
24
31
  hasExistingLinebreaks?: boolean;
@@ -39,9 +46,8 @@ declare class XMLCanonicalizer {
39
46
  static collectUsedNamespaces(node: Node, allVisibleNamespaces?: Map<string, string>, inclusivePrefixList?: string[]): Map<string, string>;
40
47
  static isBase64Element(node: Node): boolean;
41
48
  static analyzeWhitespace(node: Node): void;
42
- canonicalize(node: NodeWithWhitespace, visibleNamespaces?: Map<string, string>, options?: {
43
- isStartingNode: boolean;
44
- }): string;
49
+ canonicalize(node: NodeWithWhitespace, visibleNamespaces?: Map<string, string>, options?: CanonicalizeOptions): string;
50
+ private canonicalizeStandard;
45
51
  canonicalizeExclusive(node: NodeWithWhitespace, visibleNamespaces?: Map<string, string>, options?: ExcC14NOptions): string;
46
52
  static c14n(node: Node): string;
47
53
  static c14n11(node: Node): string;