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