node-opcua-crypto 5.1.0 → 5.3.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.
Files changed (44) hide show
  1. package/dist/chunk-7GWSCCWS.cjs +208 -0
  2. package/dist/chunk-7GWSCCWS.cjs.map +1 -0
  3. package/dist/{source/index.js → chunk-ERHE4VFS.cjs} +466 -484
  4. package/dist/chunk-ERHE4VFS.cjs.map +1 -0
  5. package/dist/{chunk-ULG5CYBT.mjs → chunk-KCVNMSLI.js} +330 -252
  6. package/dist/chunk-KCVNMSLI.js.map +1 -0
  7. package/dist/{chunk-UXPULF3W.mjs → chunk-QGNXSXUU.js} +42 -2
  8. package/dist/chunk-QGNXSXUU.js.map +1 -0
  9. package/dist/index.cjs +197 -0
  10. package/dist/index.cjs.map +1 -0
  11. package/dist/index.d.cts +5 -0
  12. package/dist/index.d.ts +3 -3
  13. package/dist/index.js +108 -6673
  14. package/dist/index.js.map +1 -1
  15. package/dist/source/index_web.cjs +155 -0
  16. package/dist/source/index_web.cjs.map +1 -0
  17. package/dist/source/{index_web.d.mts → index_web.d.cts} +184 -159
  18. package/dist/source/index_web.d.ts +183 -158
  19. package/dist/source/index_web.js +80 -6517
  20. package/dist/source/index_web.js.map +1 -1
  21. package/dist/source_nodejs/index.cjs +46 -0
  22. package/dist/source_nodejs/index.cjs.map +1 -0
  23. package/dist/source_nodejs/{index.d.mts → index.d.cts} +29 -2
  24. package/dist/source_nodejs/index.d.ts +28 -1
  25. package/dist/source_nodejs/index.js +31 -4141
  26. package/dist/source_nodejs/index.js.map +1 -1
  27. package/package.json +35 -16
  28. package/dist/chunk-RQA4DO2Z.mjs +0 -1
  29. package/dist/chunk-RQA4DO2Z.mjs.map +0 -1
  30. package/dist/chunk-ULG5CYBT.mjs.map +0 -1
  31. package/dist/chunk-UXPULF3W.mjs.map +0 -1
  32. package/dist/index.d.mts +0 -5
  33. package/dist/index.mjs +0 -184
  34. package/dist/index.mjs.map +0 -1
  35. package/dist/source/index.d.mts +0 -4
  36. package/dist/source/index.d.ts +0 -4
  37. package/dist/source/index.js.map +0 -1
  38. package/dist/source/index.mjs +0 -154
  39. package/dist/source/index.mjs.map +0 -1
  40. package/dist/source/index_web.mjs +0 -153
  41. package/dist/source/index_web.mjs.map +0 -1
  42. package/dist/source_nodejs/index.mjs +0 -35
  43. package/dist/source_nodejs/index.mjs.map +0 -1
  44. /package/dist/{common-DxHkx4Pv.d.mts → common-DxHkx4Pv.d.cts} +0 -0
@@ -1,4156 +1,46 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // source_nodejs/index.ts
31
- var source_nodejs_exports = {};
32
- __export(source_nodejs_exports, {
33
- generatePrivateKeyFile: () => generatePrivateKeyFile,
34
- generatePrivateKeyFileAlternate: () => generatePrivateKeyFileAlternate,
35
- getCertificateStore: () => getCertificateStore,
36
- readCertificate: () => readCertificate,
37
- readCertificatePEM: () => readCertificatePEM,
38
- readCertificateRevocationList: () => readCertificateRevocationList,
39
- readCertificateSigningRequest: () => readCertificateSigningRequest,
40
- readPrivateKey: () => readPrivateKey,
41
- readPrivateKeyPEM: () => readPrivateKeyPEM,
42
- readPrivateRsaKey: () => readPrivateRsaKey,
43
- readPublicKey: () => readPublicKey,
44
- readPublicKeyPEM: () => readPublicKeyPEM,
45
- readPublicRsaKey: () => readPublicRsaKey,
46
- setCertificateStore: () => setCertificateStore
47
- });
48
- module.exports = __toCommonJS(source_nodejs_exports);
49
-
50
- // source_nodejs/generate_private_key_filename.ts
51
- var import_node_crypto7 = require("crypto");
52
- var import_node_fs = __toESM(require("fs"));
53
-
54
- // source/common.ts
55
- var import_node_crypto = __toESM(require("crypto"));
56
- var KeyObjectOrig = import_node_crypto.default.KeyObject;
57
- var { createPrivateKey: createPrivateKeyFromNodeJSCrypto } = import_node_crypto.default;
58
-
59
- // source/crypto_explore_certificate.ts
60
- var import_node_assert4 = __toESM(require("assert"));
61
-
62
- // source/asn1.ts
63
- var import_node_assert = __toESM(require("assert"));
64
- function readTag(buf, pos) {
65
- const start = pos;
66
- if (buf.length <= pos) {
67
- throw new Error(`Invalid position : buf.length=${buf.length} pos=${pos}`);
68
- }
69
- const tag = buf.readUInt8(pos);
70
- pos += 1;
71
- let length = buf.readUInt8(pos);
72
- pos += 1;
73
- if (length > 127) {
74
- const nbBytes = length & 127;
75
- length = 0;
76
- for (let i = 0; i < nbBytes; i++) {
77
- length = length * 256 + buf.readUInt8(pos);
78
- pos += 1;
79
- }
80
- }
81
- return { start, tag, position: pos, length };
82
- }
83
-
84
- // source/crypto_utils.ts
85
- var import_node_assert2 = __toESM(require("assert"));
86
- var import_node_constants = __toESM(require("constants"));
87
- var import_node_crypto2 = require("crypto");
88
-
89
- // source/buffer_utils.ts
90
- var createFastUninitializedBuffer = Buffer.allocUnsafe ? Buffer.allocUnsafe : (size) => {
91
- return new Buffer(size);
92
- };
93
-
94
- // source/crypto_utils.ts
95
- var PEM_REGEX = /^(-----BEGIN (.*)-----\r?\n([/+=a-zA-Z0-9\r\n]*)\r?\n-----END \2-----\r?\n?)/gm;
96
- var PEM_TYPE_REGEX = /^(-----BEGIN (.*)-----)/m;
97
- function identifyPemType(rawKey) {
98
- if (Buffer.isBuffer(rawKey)) {
99
- rawKey = rawKey.toString("utf8");
100
- }
101
- const match = PEM_TYPE_REGEX.exec(rawKey);
102
- return !match ? void 0 : match[2];
103
- }
104
- function removeTrailingLF(str) {
105
- const tmp = str.replace(/(\r|\n)+$/m, "").replace(/\r\n/gm, "\n");
106
- return tmp;
107
- }
108
- function toPem(raw_key, pem) {
109
- (0, import_node_assert2.default)(raw_key, "expecting a key");
110
- (0, import_node_assert2.default)(typeof pem === "string");
111
- let pemType = identifyPemType(raw_key);
112
- if (pemType) {
113
- return Buffer.isBuffer(raw_key) ? removeTrailingLF(raw_key.toString("utf8")) : removeTrailingLF(raw_key);
114
- } else {
115
- pemType = pem;
116
- (0, import_node_assert2.default)(["CERTIFICATE REQUEST", "CERTIFICATE", "RSA PRIVATE KEY", "PUBLIC KEY", "X509 CRL"].indexOf(pemType) >= 0);
117
- let b = raw_key.toString("base64");
118
- let str = `-----BEGIN ${pemType}-----
119
- `;
120
- while (b.length) {
121
- str += `${b.substring(0, 64)}
122
- `;
123
- b = b.substring(64);
124
- }
125
- str += `-----END ${pemType}-----`;
126
- return str;
127
- }
128
- }
129
- function convertPEMtoDER(raw_key) {
130
- let match;
131
- let _pemType;
132
- let base64str;
133
- const parts = [];
134
- PEM_REGEX.lastIndex = 0;
135
- match = PEM_REGEX.exec(raw_key);
136
- while (match !== null) {
137
- _pemType = match[2];
138
- base64str = match[3];
139
- base64str = base64str.replace(/\r?\n/g, "");
140
- parts.push(Buffer.from(base64str, "base64"));
141
- match = PEM_REGEX.exec(raw_key);
142
- }
143
- return combine_der(parts);
144
- }
145
- var RSA_PKCS1_OAEP_PADDING = import_node_constants.default.RSA_PKCS1_OAEP_PADDING;
146
- var RSA_PKCS1_PADDING = import_node_constants.default.RSA_PKCS1_PADDING;
147
- (0, import_node_assert2.default)(4 /* RSA_PKCS1_OAEP_PADDING */ === import_node_constants.default.RSA_PKCS1_OAEP_PADDING);
148
- (0, import_node_assert2.default)(1 /* RSA_PKCS1_PADDING */ === import_node_constants.default.RSA_PKCS1_PADDING);
149
-
150
- // source/directory_name.ts
151
- var import_node_assert3 = __toESM(require("assert"));
152
-
153
- // source/crypto_explore_certificate.ts
154
- function split_der(certificateChain) {
155
- const certificate_chain = [];
156
- do {
157
- const block_info = readTag(certificateChain, 0);
158
- const length = block_info.position + block_info.length;
159
- const der_certificate = certificateChain.subarray(0, length);
160
- certificate_chain.push(der_certificate);
161
- certificateChain = certificateChain.subarray(length);
162
- } while (certificateChain.length > 0);
163
- return certificate_chain;
164
- }
165
- function combine_der(certificates) {
166
- for (const cert of certificates) {
167
- const b = split_der(cert);
168
- let sum = 0;
169
- b.forEach((block) => {
170
- const block_info = readTag(block, 0);
171
- (0, import_node_assert4.default)(block_info.position + block_info.length === block.length);
172
- sum += block.length;
173
- });
174
- (0, import_node_assert4.default)(sum === cert.length);
175
- }
176
- return Buffer.concat(certificates);
177
- }
178
-
179
- // source/verify_certificate_signature.ts
180
- var import_node_crypto3 = require("crypto");
181
-
182
- // source/crypto_utils2.ts
183
- var import_node_assert5 = __toESM(require("assert"));
184
- var import_node_crypto4 = require("crypto");
185
-
186
- // source/derived_keys.ts
187
- var import_node_assert7 = __toESM(require("assert"));
188
- var import_node_crypto5 = require("crypto");
189
-
190
- // source/explore_certificate.ts
191
- var import_node_assert6 = __toESM(require("assert"));
192
-
193
- // source/explore_private_key.ts
194
- var doDebug = !!process.env.DEBUG;
195
-
196
- // source/x509/_crypto.ts
197
- var import_node_crypto6 = __toESM(require("crypto"));
198
- var import_webcrypto = require("@peculiar/webcrypto");
199
- var x509 = __toESM(require("@peculiar/x509"));
200
- var x5092 = __toESM(require("@peculiar/x509"));
201
- var doDebug2 = false;
202
- var _crypto;
203
- var ignoreCrypto = process.env.IGNORE_SUBTLE_FROM_CRYPTO;
204
- if (typeof window === "undefined") {
205
- _crypto = import_node_crypto6.default;
206
- if (!_crypto?.subtle || ignoreCrypto) {
207
- _crypto = new import_webcrypto.Crypto();
208
- doDebug2 && console.warn("using @peculiar/webcrypto");
209
- } else {
210
- doDebug2 && console.warn("using nodejs crypto (native)");
211
- }
212
- x509.cryptoProvider.set(_crypto);
213
- } else {
214
- doDebug2 && console.warn("using browser crypto (native)");
215
- _crypto = crypto;
216
- x509.cryptoProvider.set(crypto);
217
- }
218
- function getCrypto() {
219
- return _crypto || crypto || import_node_crypto6.default;
220
- }
221
-
222
- // source/x509/create_key_pair.ts
223
- async function generateKeyPair(modulusLength = 2048) {
224
- const crypto3 = getCrypto();
225
- const alg = {
226
- name: "RSASSA-PKCS1-v1_5",
227
- hash: { name: "SHA-256" },
228
- publicExponent: new Uint8Array([1, 0, 1]),
229
- modulusLength
230
- };
231
- const keys = await crypto3.subtle.generateKey(alg, true, ["sign", "verify"]);
232
- return keys;
233
- }
234
- async function privateKeyToPEM(privateKey) {
235
- const crypto3 = getCrypto();
236
- const privDer = await crypto3.subtle.exportKey("pkcs8", privateKey);
237
- const privPem = x5092.PemConverter.encode(privDer, "PRIVATE KEY");
238
- return { privPem, privDer };
239
- }
240
-
241
- // source/x509/coerce_private_key.ts
242
- var crypto2 = getCrypto();
243
-
244
- // source/x509/_get_attributes.ts
245
- var keyUsageApplication = x5092.KeyUsageFlags.keyEncipherment | x5092.KeyUsageFlags.nonRepudiation | x5092.KeyUsageFlags.dataEncipherment | x5092.KeyUsageFlags.keyCertSign | x5092.KeyUsageFlags.digitalSignature;
246
- var keyUsageCA = x5092.KeyUsageFlags.keyCertSign | x5092.KeyUsageFlags.cRLSign;
247
-
248
- // ../../node_modules/asn1js/build/index.es.js
249
- var index_es_exports = {};
250
- __export(index_es_exports, {
251
- Any: () => Any,
252
- BaseBlock: () => BaseBlock,
253
- BaseStringBlock: () => BaseStringBlock,
254
- BitString: () => BitString,
255
- BmpString: () => BmpString,
256
- Boolean: () => Boolean,
257
- CharacterString: () => CharacterString,
258
- Choice: () => Choice,
259
- Constructed: () => Constructed,
260
- DATE: () => DATE,
261
- DateTime: () => DateTime,
262
- Duration: () => Duration,
263
- EndOfContent: () => EndOfContent,
264
- Enumerated: () => Enumerated,
265
- GeneralString: () => GeneralString,
266
- GeneralizedTime: () => GeneralizedTime,
267
- GraphicString: () => GraphicString,
268
- HexBlock: () => HexBlock,
269
- IA5String: () => IA5String,
270
- Integer: () => Integer,
271
- Null: () => Null,
272
- NumericString: () => NumericString,
273
- ObjectIdentifier: () => ObjectIdentifier,
274
- OctetString: () => OctetString,
275
- Primitive: () => Primitive,
276
- PrintableString: () => PrintableString,
277
- RawData: () => RawData,
278
- RelativeObjectIdentifier: () => RelativeObjectIdentifier,
279
- Repeated: () => Repeated,
280
- Sequence: () => Sequence,
281
- Set: () => Set,
282
- TIME: () => TIME,
283
- TeletexString: () => TeletexString,
284
- TimeOfDay: () => TimeOfDay,
285
- UTCTime: () => UTCTime,
286
- UniversalString: () => UniversalString,
287
- Utf8String: () => Utf8String,
288
- ValueBlock: () => ValueBlock,
289
- VideotexString: () => VideotexString,
290
- ViewWriter: () => ViewWriter,
291
- VisibleString: () => VisibleString,
292
- compareSchema: () => compareSchema,
293
- fromBER: () => fromBER,
294
- verifySchema: () => verifySchema
295
- });
296
-
297
- // ../../node_modules/pvtsutils/build/index.es.js
298
- var ARRAY_BUFFER_NAME = "[object ArrayBuffer]";
299
- var BufferSourceConverter = class _BufferSourceConverter {
300
- static isArrayBuffer(data) {
301
- return Object.prototype.toString.call(data) === ARRAY_BUFFER_NAME;
302
- }
303
- static toArrayBuffer(data) {
304
- if (this.isArrayBuffer(data)) {
305
- return data;
306
- }
307
- if (data.byteLength === data.buffer.byteLength) {
308
- return data.buffer;
309
- }
310
- if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {
311
- return data.buffer;
312
- }
313
- return this.toUint8Array(data.buffer).slice(data.byteOffset, data.byteOffset + data.byteLength).buffer;
314
- }
315
- static toUint8Array(data) {
316
- return this.toView(data, Uint8Array);
317
- }
318
- static toView(data, type) {
319
- if (data.constructor === type) {
320
- return data;
321
- }
322
- if (this.isArrayBuffer(data)) {
323
- return new type(data);
324
- }
325
- if (this.isArrayBufferView(data)) {
326
- return new type(data.buffer, data.byteOffset, data.byteLength);
327
- }
328
- throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");
329
- }
330
- static isBufferSource(data) {
331
- return this.isArrayBufferView(data) || this.isArrayBuffer(data);
332
- }
333
- static isArrayBufferView(data) {
334
- return ArrayBuffer.isView(data) || data && this.isArrayBuffer(data.buffer);
335
- }
336
- static isEqual(a, b) {
337
- const aView = _BufferSourceConverter.toUint8Array(a);
338
- const bView = _BufferSourceConverter.toUint8Array(b);
339
- if (aView.length !== bView.byteLength) {
340
- return false;
341
- }
342
- for (let i = 0; i < aView.length; i++) {
343
- if (aView[i] !== bView[i]) {
344
- return false;
345
- }
346
- }
347
- return true;
348
- }
349
- static concat(...args) {
350
- let buffers;
351
- if (Array.isArray(args[0]) && !(args[1] instanceof Function)) {
352
- buffers = args[0];
353
- } else if (Array.isArray(args[0]) && args[1] instanceof Function) {
354
- buffers = args[0];
355
- } else {
356
- if (args[args.length - 1] instanceof Function) {
357
- buffers = args.slice(0, args.length - 1);
358
- } else {
359
- buffers = args;
360
- }
361
- }
362
- let size = 0;
363
- for (const buffer of buffers) {
364
- size += buffer.byteLength;
365
- }
366
- const res = new Uint8Array(size);
367
- let offset = 0;
368
- for (const buffer of buffers) {
369
- const view = this.toUint8Array(buffer);
370
- res.set(view, offset);
371
- offset += view.length;
372
- }
373
- if (args[args.length - 1] instanceof Function) {
374
- return this.toView(res, args[args.length - 1]);
375
- }
376
- return res.buffer;
377
- }
378
- };
379
- var STRING_TYPE = "string";
380
- var HEX_REGEX = /^[0-9a-f\s]+$/i;
381
- var BASE64_REGEX = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
382
- var BASE64URL_REGEX = /^[a-zA-Z0-9-_]+$/;
383
- var Utf8Converter = class {
384
- static fromString(text) {
385
- const s = unescape(encodeURIComponent(text));
386
- const uintArray = new Uint8Array(s.length);
387
- for (let i = 0; i < s.length; i++) {
388
- uintArray[i] = s.charCodeAt(i);
389
- }
390
- return uintArray.buffer;
391
- }
392
- static toString(buffer) {
393
- const buf = BufferSourceConverter.toUint8Array(buffer);
394
- let encodedString = "";
395
- for (let i = 0; i < buf.length; i++) {
396
- encodedString += String.fromCharCode(buf[i]);
397
- }
398
- const decodedString = decodeURIComponent(escape(encodedString));
399
- return decodedString;
400
- }
401
- };
402
- var Utf16Converter = class {
403
- static toString(buffer, littleEndian = false) {
404
- const arrayBuffer = BufferSourceConverter.toArrayBuffer(buffer);
405
- const dataView = new DataView(arrayBuffer);
406
- let res = "";
407
- for (let i = 0; i < arrayBuffer.byteLength; i += 2) {
408
- const code = dataView.getUint16(i, littleEndian);
409
- res += String.fromCharCode(code);
410
- }
411
- return res;
412
- }
413
- static fromString(text, littleEndian = false) {
414
- const res = new ArrayBuffer(text.length * 2);
415
- const dataView = new DataView(res);
416
- for (let i = 0; i < text.length; i++) {
417
- dataView.setUint16(i * 2, text.charCodeAt(i), littleEndian);
418
- }
419
- return res;
420
- }
421
- };
422
- var Convert = class _Convert {
423
- static isHex(data) {
424
- return typeof data === STRING_TYPE && HEX_REGEX.test(data);
425
- }
426
- static isBase64(data) {
427
- return typeof data === STRING_TYPE && BASE64_REGEX.test(data);
428
- }
429
- static isBase64Url(data) {
430
- return typeof data === STRING_TYPE && BASE64URL_REGEX.test(data);
431
- }
432
- static ToString(buffer, enc = "utf8") {
433
- const buf = BufferSourceConverter.toUint8Array(buffer);
434
- switch (enc.toLowerCase()) {
435
- case "utf8":
436
- return this.ToUtf8String(buf);
437
- case "binary":
438
- return this.ToBinary(buf);
439
- case "hex":
440
- return this.ToHex(buf);
441
- case "base64":
442
- return this.ToBase64(buf);
443
- case "base64url":
444
- return this.ToBase64Url(buf);
445
- case "utf16le":
446
- return Utf16Converter.toString(buf, true);
447
- case "utf16":
448
- case "utf16be":
449
- return Utf16Converter.toString(buf);
450
- default:
451
- throw new Error(`Unknown type of encoding '${enc}'`);
452
- }
453
- }
454
- static FromString(str, enc = "utf8") {
455
- if (!str) {
456
- return new ArrayBuffer(0);
457
- }
458
- switch (enc.toLowerCase()) {
459
- case "utf8":
460
- return this.FromUtf8String(str);
461
- case "binary":
462
- return this.FromBinary(str);
463
- case "hex":
464
- return this.FromHex(str);
465
- case "base64":
466
- return this.FromBase64(str);
467
- case "base64url":
468
- return this.FromBase64Url(str);
469
- case "utf16le":
470
- return Utf16Converter.fromString(str, true);
471
- case "utf16":
472
- case "utf16be":
473
- return Utf16Converter.fromString(str);
474
- default:
475
- throw new Error(`Unknown type of encoding '${enc}'`);
476
- }
477
- }
478
- static ToBase64(buffer) {
479
- const buf = BufferSourceConverter.toUint8Array(buffer);
480
- if (typeof btoa !== "undefined") {
481
- const binary = this.ToString(buf, "binary");
482
- return btoa(binary);
483
- } else {
484
- return Buffer.from(buf).toString("base64");
485
- }
486
- }
487
- static FromBase64(base64) {
488
- const formatted = this.formatString(base64);
489
- if (!formatted) {
490
- return new ArrayBuffer(0);
491
- }
492
- if (!_Convert.isBase64(formatted)) {
493
- throw new TypeError("Argument 'base64Text' is not Base64 encoded");
494
- }
495
- if (typeof atob !== "undefined") {
496
- return this.FromBinary(atob(formatted));
497
- } else {
498
- return new Uint8Array(Buffer.from(formatted, "base64")).buffer;
499
- }
500
- }
501
- static FromBase64Url(base64url) {
502
- const formatted = this.formatString(base64url);
503
- if (!formatted) {
504
- return new ArrayBuffer(0);
505
- }
506
- if (!_Convert.isBase64Url(formatted)) {
507
- throw new TypeError("Argument 'base64url' is not Base64Url encoded");
508
- }
509
- return this.FromBase64(this.Base64Padding(formatted.replace(/\-/g, "+").replace(/\_/g, "/")));
510
- }
511
- static ToBase64Url(data) {
512
- return this.ToBase64(data).replace(/\+/g, "-").replace(/\//g, "_").replace(/\=/g, "");
513
- }
514
- static FromUtf8String(text, encoding = _Convert.DEFAULT_UTF8_ENCODING) {
515
- switch (encoding) {
516
- case "ascii":
517
- return this.FromBinary(text);
518
- case "utf8":
519
- return Utf8Converter.fromString(text);
520
- case "utf16":
521
- case "utf16be":
522
- return Utf16Converter.fromString(text);
523
- case "utf16le":
524
- case "usc2":
525
- return Utf16Converter.fromString(text, true);
526
- default:
527
- throw new Error(`Unknown type of encoding '${encoding}'`);
528
- }
529
- }
530
- static ToUtf8String(buffer, encoding = _Convert.DEFAULT_UTF8_ENCODING) {
531
- switch (encoding) {
532
- case "ascii":
533
- return this.ToBinary(buffer);
534
- case "utf8":
535
- return Utf8Converter.toString(buffer);
536
- case "utf16":
537
- case "utf16be":
538
- return Utf16Converter.toString(buffer);
539
- case "utf16le":
540
- case "usc2":
541
- return Utf16Converter.toString(buffer, true);
542
- default:
543
- throw new Error(`Unknown type of encoding '${encoding}'`);
544
- }
545
- }
546
- static FromBinary(text) {
547
- const stringLength = text.length;
548
- const resultView = new Uint8Array(stringLength);
549
- for (let i = 0; i < stringLength; i++) {
550
- resultView[i] = text.charCodeAt(i);
551
- }
552
- return resultView.buffer;
553
- }
554
- static ToBinary(buffer) {
555
- const buf = BufferSourceConverter.toUint8Array(buffer);
556
- let res = "";
557
- for (let i = 0; i < buf.length; i++) {
558
- res += String.fromCharCode(buf[i]);
559
- }
560
- return res;
561
- }
562
- static ToHex(buffer) {
563
- const buf = BufferSourceConverter.toUint8Array(buffer);
564
- let result = "";
565
- const len = buf.length;
566
- for (let i = 0; i < len; i++) {
567
- const byte = buf[i];
568
- if (byte < 16) {
569
- result += "0";
570
- }
571
- result += byte.toString(16);
572
- }
573
- return result;
574
- }
575
- static FromHex(hexString) {
576
- let formatted = this.formatString(hexString);
577
- if (!formatted) {
578
- return new ArrayBuffer(0);
579
- }
580
- if (!_Convert.isHex(formatted)) {
581
- throw new TypeError("Argument 'hexString' is not HEX encoded");
582
- }
583
- if (formatted.length % 2) {
584
- formatted = `0${formatted}`;
585
- }
586
- const res = new Uint8Array(formatted.length / 2);
587
- for (let i = 0; i < formatted.length; i = i + 2) {
588
- const c = formatted.slice(i, i + 2);
589
- res[i / 2] = parseInt(c, 16);
590
- }
591
- return res.buffer;
592
- }
593
- static ToUtf16String(buffer, littleEndian = false) {
594
- return Utf16Converter.toString(buffer, littleEndian);
595
- }
596
- static FromUtf16String(text, littleEndian = false) {
597
- return Utf16Converter.fromString(text, littleEndian);
598
- }
599
- static Base64Padding(base64) {
600
- const padCount = 4 - base64.length % 4;
601
- if (padCount < 4) {
602
- for (let i = 0; i < padCount; i++) {
603
- base64 += "=";
604
- }
605
- }
606
- return base64;
607
- }
608
- static formatString(data) {
609
- return (data === null || data === void 0 ? void 0 : data.replace(/[\n\r\t ]/g, "")) || "";
610
- }
611
- };
612
- Convert.DEFAULT_UTF8_ENCODING = "utf8";
613
-
614
- // ../../node_modules/pvutils/build/utils.es.js
615
- function utilFromBase(inputBuffer, inputBase) {
616
- let result = 0;
617
- if (inputBuffer.length === 1) {
618
- return inputBuffer[0];
619
- }
620
- for (let i = inputBuffer.length - 1; i >= 0; i--) {
621
- result += inputBuffer[inputBuffer.length - 1 - i] * Math.pow(2, inputBase * i);
622
- }
623
- return result;
624
- }
625
- function utilToBase(value, base, reserved = -1) {
626
- const internalReserved = reserved;
627
- let internalValue = value;
628
- let result = 0;
629
- let biggest = Math.pow(2, base);
630
- for (let i = 1; i < 8; i++) {
631
- if (value < biggest) {
632
- let retBuf;
633
- if (internalReserved < 0) {
634
- retBuf = new ArrayBuffer(i);
635
- result = i;
636
- } else {
637
- if (internalReserved < i) {
638
- return new ArrayBuffer(0);
639
- }
640
- retBuf = new ArrayBuffer(internalReserved);
641
- result = internalReserved;
642
- }
643
- const retView = new Uint8Array(retBuf);
644
- for (let j = i - 1; j >= 0; j--) {
645
- const basis = Math.pow(2, j * base);
646
- retView[result - j - 1] = Math.floor(internalValue / basis);
647
- internalValue -= retView[result - j - 1] * basis;
648
- }
649
- return retBuf;
650
- }
651
- biggest *= Math.pow(2, base);
652
- }
653
- return new ArrayBuffer(0);
654
- }
655
- function utilConcatView(...views) {
656
- let outputLength = 0;
657
- let prevLength = 0;
658
- for (const view of views) {
659
- outputLength += view.length;
660
- }
661
- const retBuf = new ArrayBuffer(outputLength);
662
- const retView = new Uint8Array(retBuf);
663
- for (const view of views) {
664
- retView.set(view, prevLength);
665
- prevLength += view.length;
666
- }
667
- return retView;
668
- }
669
- function utilDecodeTC() {
670
- const buf = new Uint8Array(this.valueHex);
671
- if (this.valueHex.byteLength >= 2) {
672
- const condition1 = buf[0] === 255 && buf[1] & 128;
673
- const condition2 = buf[0] === 0 && (buf[1] & 128) === 0;
674
- if (condition1 || condition2) {
675
- this.warnings.push("Needlessly long format");
676
- }
677
- }
678
- const bigIntBuffer = new ArrayBuffer(this.valueHex.byteLength);
679
- const bigIntView = new Uint8Array(bigIntBuffer);
680
- for (let i = 0; i < this.valueHex.byteLength; i++) {
681
- bigIntView[i] = 0;
682
- }
683
- bigIntView[0] = buf[0] & 128;
684
- const bigInt = utilFromBase(bigIntView, 8);
685
- const smallIntBuffer = new ArrayBuffer(this.valueHex.byteLength);
686
- const smallIntView = new Uint8Array(smallIntBuffer);
687
- for (let j = 0; j < this.valueHex.byteLength; j++) {
688
- smallIntView[j] = buf[j];
689
- }
690
- smallIntView[0] &= 127;
691
- const smallInt = utilFromBase(smallIntView, 8);
692
- return smallInt - bigInt;
693
- }
694
- function utilEncodeTC(value) {
695
- const modValue = value < 0 ? value * -1 : value;
696
- let bigInt = 128;
697
- for (let i = 1; i < 8; i++) {
698
- if (modValue <= bigInt) {
699
- if (value < 0) {
700
- const smallInt = bigInt - modValue;
701
- const retBuf2 = utilToBase(smallInt, 8, i);
702
- const retView2 = new Uint8Array(retBuf2);
703
- retView2[0] |= 128;
704
- return retBuf2;
705
- }
706
- let retBuf = utilToBase(modValue, 8, i);
707
- let retView = new Uint8Array(retBuf);
708
- if (retView[0] & 128) {
709
- const tempBuf = retBuf.slice(0);
710
- const tempView = new Uint8Array(tempBuf);
711
- retBuf = new ArrayBuffer(retBuf.byteLength + 1);
712
- retView = new Uint8Array(retBuf);
713
- for (let k = 0; k < tempBuf.byteLength; k++) {
714
- retView[k + 1] = tempView[k];
715
- }
716
- retView[0] = 0;
717
- }
718
- return retBuf;
719
- }
720
- bigInt *= Math.pow(2, 8);
721
- }
722
- return new ArrayBuffer(0);
723
- }
724
- function isEqualBuffer(inputBuffer1, inputBuffer2) {
725
- if (inputBuffer1.byteLength !== inputBuffer2.byteLength) {
726
- return false;
727
- }
728
- const view1 = new Uint8Array(inputBuffer1);
729
- const view2 = new Uint8Array(inputBuffer2);
730
- for (let i = 0; i < view1.length; i++) {
731
- if (view1[i] !== view2[i]) {
732
- return false;
733
- }
734
- }
735
- return true;
736
- }
737
- function padNumber(inputNumber, fullLength) {
738
- const str = inputNumber.toString(10);
739
- if (fullLength < str.length) {
740
- return "";
741
- }
742
- const dif = fullLength - str.length;
743
- const padding = new Array(dif);
744
- for (let i = 0; i < dif; i++) {
745
- padding[i] = "0";
746
- }
747
- const paddingString = padding.join("");
748
- return paddingString.concat(str);
749
- }
750
- var log2 = Math.log(2);
751
-
752
- // ../../node_modules/asn1js/build/index.es.js
753
- function assertBigInt() {
754
- if (typeof BigInt === "undefined") {
755
- throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.");
756
- }
757
- }
758
- function concat(buffers) {
759
- let outputLength = 0;
760
- let prevLength = 0;
761
- for (let i = 0; i < buffers.length; i++) {
762
- const buffer = buffers[i];
763
- outputLength += buffer.byteLength;
764
- }
765
- const retView = new Uint8Array(outputLength);
766
- for (let i = 0; i < buffers.length; i++) {
767
- const buffer = buffers[i];
768
- retView.set(new Uint8Array(buffer), prevLength);
769
- prevLength += buffer.byteLength;
770
- }
771
- return retView.buffer;
772
- }
773
- function checkBufferParams(baseBlock, inputBuffer, inputOffset, inputLength) {
774
- if (!(inputBuffer instanceof Uint8Array)) {
775
- baseBlock.error = "Wrong parameter: inputBuffer must be 'Uint8Array'";
776
- return false;
777
- }
778
- if (!inputBuffer.byteLength) {
779
- baseBlock.error = "Wrong parameter: inputBuffer has zero length";
780
- return false;
781
- }
782
- if (inputOffset < 0) {
783
- baseBlock.error = "Wrong parameter: inputOffset less than zero";
784
- return false;
785
- }
786
- if (inputLength < 0) {
787
- baseBlock.error = "Wrong parameter: inputLength less than zero";
788
- return false;
789
- }
790
- if (inputBuffer.byteLength - inputOffset - inputLength < 0) {
791
- baseBlock.error = "End of input reached before message was fully decoded (inconsistent offset and length values)";
792
- return false;
793
- }
794
- return true;
795
- }
796
- var ViewWriter = class {
797
- constructor() {
798
- this.items = [];
799
- }
800
- write(buf) {
801
- this.items.push(buf);
802
- }
803
- final() {
804
- return concat(this.items);
805
- }
806
- };
807
- var powers2 = [new Uint8Array([1])];
808
- var digitsString = "0123456789";
809
- var NAME = "name";
810
- var VALUE_HEX_VIEW = "valueHexView";
811
- var IS_HEX_ONLY = "isHexOnly";
812
- var ID_BLOCK = "idBlock";
813
- var TAG_CLASS = "tagClass";
814
- var TAG_NUMBER = "tagNumber";
815
- var IS_CONSTRUCTED = "isConstructed";
816
- var FROM_BER = "fromBER";
817
- var TO_BER = "toBER";
818
- var LOCAL = "local";
819
- var EMPTY_STRING = "";
820
- var EMPTY_BUFFER = new ArrayBuffer(0);
821
- var EMPTY_VIEW = new Uint8Array(0);
822
- var END_OF_CONTENT_NAME = "EndOfContent";
823
- var OCTET_STRING_NAME = "OCTET STRING";
824
- var BIT_STRING_NAME = "BIT STRING";
825
- function HexBlock(BaseClass) {
826
- var _a2;
827
- return _a2 = class Some extends BaseClass {
828
- get valueHex() {
829
- return this.valueHexView.slice().buffer;
830
- }
831
- set valueHex(value) {
832
- this.valueHexView = new Uint8Array(value);
833
- }
834
- constructor(...args) {
835
- var _b;
836
- super(...args);
837
- const params = args[0] || {};
838
- this.isHexOnly = (_b = params.isHexOnly) !== null && _b !== void 0 ? _b : false;
839
- this.valueHexView = params.valueHex ? BufferSourceConverter.toUint8Array(params.valueHex) : EMPTY_VIEW;
840
- }
841
- fromBER(inputBuffer, inputOffset, inputLength) {
842
- const view = inputBuffer instanceof ArrayBuffer ? new Uint8Array(inputBuffer) : inputBuffer;
843
- if (!checkBufferParams(this, view, inputOffset, inputLength)) {
844
- return -1;
845
- }
846
- const endLength = inputOffset + inputLength;
847
- this.valueHexView = view.subarray(inputOffset, endLength);
848
- if (!this.valueHexView.length) {
849
- this.warnings.push("Zero buffer length");
850
- return inputOffset;
851
- }
852
- this.blockLength = inputLength;
853
- return endLength;
854
- }
855
- toBER(sizeOnly = false) {
856
- if (!this.isHexOnly) {
857
- this.error = "Flag 'isHexOnly' is not set, abort";
858
- return EMPTY_BUFFER;
859
- }
860
- if (sizeOnly) {
861
- return new ArrayBuffer(this.valueHexView.byteLength);
862
- }
863
- return this.valueHexView.byteLength === this.valueHexView.buffer.byteLength ? this.valueHexView.buffer : this.valueHexView.slice().buffer;
864
- }
865
- toJSON() {
866
- return {
867
- ...super.toJSON(),
868
- isHexOnly: this.isHexOnly,
869
- valueHex: Convert.ToHex(this.valueHexView)
870
- };
871
- }
872
- }, _a2.NAME = "hexBlock", _a2;
873
- }
874
- var LocalBaseBlock = class {
875
- static blockName() {
876
- return this.NAME;
877
- }
878
- get valueBeforeDecode() {
879
- return this.valueBeforeDecodeView.slice().buffer;
880
- }
881
- set valueBeforeDecode(value) {
882
- this.valueBeforeDecodeView = new Uint8Array(value);
883
- }
884
- constructor({ blockLength = 0, error = EMPTY_STRING, warnings = [], valueBeforeDecode = EMPTY_VIEW } = {}) {
885
- this.blockLength = blockLength;
886
- this.error = error;
887
- this.warnings = warnings;
888
- this.valueBeforeDecodeView = BufferSourceConverter.toUint8Array(valueBeforeDecode);
889
- }
890
- toJSON() {
891
- return {
892
- blockName: this.constructor.NAME,
893
- blockLength: this.blockLength,
894
- error: this.error,
895
- warnings: this.warnings,
896
- valueBeforeDecode: Convert.ToHex(this.valueBeforeDecodeView)
897
- };
898
- }
899
- };
900
- LocalBaseBlock.NAME = "baseBlock";
901
- var ValueBlock = class extends LocalBaseBlock {
902
- fromBER(_inputBuffer, _inputOffset, _inputLength) {
903
- throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'");
904
- }
905
- toBER(_sizeOnly, _writer) {
906
- throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'");
907
- }
908
- };
909
- ValueBlock.NAME = "valueBlock";
910
- var LocalIdentificationBlock = class extends HexBlock(LocalBaseBlock) {
911
- constructor({ idBlock = {} } = {}) {
912
- var _a2, _b, _c, _d;
913
- super();
914
- if (idBlock) {
915
- this.isHexOnly = (_a2 = idBlock.isHexOnly) !== null && _a2 !== void 0 ? _a2 : false;
916
- this.valueHexView = idBlock.valueHex ? BufferSourceConverter.toUint8Array(idBlock.valueHex) : EMPTY_VIEW;
917
- this.tagClass = (_b = idBlock.tagClass) !== null && _b !== void 0 ? _b : -1;
918
- this.tagNumber = (_c = idBlock.tagNumber) !== null && _c !== void 0 ? _c : -1;
919
- this.isConstructed = (_d = idBlock.isConstructed) !== null && _d !== void 0 ? _d : false;
920
- } else {
921
- this.tagClass = -1;
922
- this.tagNumber = -1;
923
- this.isConstructed = false;
924
- }
925
- }
926
- toBER(sizeOnly = false) {
927
- let firstOctet = 0;
928
- switch (this.tagClass) {
929
- case 1:
930
- firstOctet |= 0;
931
- break;
932
- case 2:
933
- firstOctet |= 64;
934
- break;
935
- case 3:
936
- firstOctet |= 128;
937
- break;
938
- case 4:
939
- firstOctet |= 192;
940
- break;
941
- default:
942
- this.error = "Unknown tag class";
943
- return EMPTY_BUFFER;
944
- }
945
- if (this.isConstructed)
946
- firstOctet |= 32;
947
- if (this.tagNumber < 31 && !this.isHexOnly) {
948
- const retView2 = new Uint8Array(1);
949
- if (!sizeOnly) {
950
- let number = this.tagNumber;
951
- number &= 31;
952
- firstOctet |= number;
953
- retView2[0] = firstOctet;
954
- }
955
- return retView2.buffer;
956
- }
957
- if (!this.isHexOnly) {
958
- const encodedBuf = utilToBase(this.tagNumber, 7);
959
- const encodedView = new Uint8Array(encodedBuf);
960
- const size = encodedBuf.byteLength;
961
- const retView2 = new Uint8Array(size + 1);
962
- retView2[0] = firstOctet | 31;
963
- if (!sizeOnly) {
964
- for (let i = 0; i < size - 1; i++)
965
- retView2[i + 1] = encodedView[i] | 128;
966
- retView2[size] = encodedView[size - 1];
967
- }
968
- return retView2.buffer;
969
- }
970
- const retView = new Uint8Array(this.valueHexView.byteLength + 1);
971
- retView[0] = firstOctet | 31;
972
- if (!sizeOnly) {
973
- const curView = this.valueHexView;
974
- for (let i = 0; i < curView.length - 1; i++)
975
- retView[i + 1] = curView[i] | 128;
976
- retView[this.valueHexView.byteLength] = curView[curView.length - 1];
977
- }
978
- return retView.buffer;
979
- }
980
- fromBER(inputBuffer, inputOffset, inputLength) {
981
- const inputView = BufferSourceConverter.toUint8Array(inputBuffer);
982
- if (!checkBufferParams(this, inputView, inputOffset, inputLength)) {
983
- return -1;
984
- }
985
- const intBuffer = inputView.subarray(inputOffset, inputOffset + inputLength);
986
- if (intBuffer.length === 0) {
987
- this.error = "Zero buffer length";
988
- return -1;
989
- }
990
- const tagClassMask = intBuffer[0] & 192;
991
- switch (tagClassMask) {
992
- case 0:
993
- this.tagClass = 1;
994
- break;
995
- case 64:
996
- this.tagClass = 2;
997
- break;
998
- case 128:
999
- this.tagClass = 3;
1000
- break;
1001
- case 192:
1002
- this.tagClass = 4;
1003
- break;
1004
- default:
1005
- this.error = "Unknown tag class";
1006
- return -1;
1007
- }
1008
- this.isConstructed = (intBuffer[0] & 32) === 32;
1009
- this.isHexOnly = false;
1010
- const tagNumberMask = intBuffer[0] & 31;
1011
- if (tagNumberMask !== 31) {
1012
- this.tagNumber = tagNumberMask;
1013
- this.blockLength = 1;
1014
- } else {
1015
- let count = 1;
1016
- let intTagNumberBuffer = this.valueHexView = new Uint8Array(255);
1017
- let tagNumberBufferMaxLength = 255;
1018
- while (intBuffer[count] & 128) {
1019
- intTagNumberBuffer[count - 1] = intBuffer[count] & 127;
1020
- count++;
1021
- if (count >= intBuffer.length) {
1022
- this.error = "End of input reached before message was fully decoded";
1023
- return -1;
1024
- }
1025
- if (count === tagNumberBufferMaxLength) {
1026
- tagNumberBufferMaxLength += 255;
1027
- const tempBufferView2 = new Uint8Array(tagNumberBufferMaxLength);
1028
- for (let i = 0; i < intTagNumberBuffer.length; i++)
1029
- tempBufferView2[i] = intTagNumberBuffer[i];
1030
- intTagNumberBuffer = this.valueHexView = new Uint8Array(tagNumberBufferMaxLength);
1031
- }
1032
- }
1033
- this.blockLength = count + 1;
1034
- intTagNumberBuffer[count - 1] = intBuffer[count] & 127;
1035
- const tempBufferView = new Uint8Array(count);
1036
- for (let i = 0; i < count; i++)
1037
- tempBufferView[i] = intTagNumberBuffer[i];
1038
- intTagNumberBuffer = this.valueHexView = new Uint8Array(count);
1039
- intTagNumberBuffer.set(tempBufferView);
1040
- if (this.blockLength <= 9)
1041
- this.tagNumber = utilFromBase(intTagNumberBuffer, 7);
1042
- else {
1043
- this.isHexOnly = true;
1044
- this.warnings.push("Tag too long, represented as hex-coded");
1045
- }
1046
- }
1047
- if (this.tagClass === 1 && this.isConstructed) {
1048
- switch (this.tagNumber) {
1049
- case 1:
1050
- case 2:
1051
- case 5:
1052
- case 6:
1053
- case 9:
1054
- case 13:
1055
- case 14:
1056
- case 23:
1057
- case 24:
1058
- case 31:
1059
- case 32:
1060
- case 33:
1061
- case 34:
1062
- this.error = "Constructed encoding used for primitive type";
1063
- return -1;
1064
- }
1065
- }
1066
- return inputOffset + this.blockLength;
1067
- }
1068
- toJSON() {
1069
- return {
1070
- ...super.toJSON(),
1071
- tagClass: this.tagClass,
1072
- tagNumber: this.tagNumber,
1073
- isConstructed: this.isConstructed
1074
- };
1075
- }
1076
- };
1077
- LocalIdentificationBlock.NAME = "identificationBlock";
1078
- var LocalLengthBlock = class extends LocalBaseBlock {
1079
- constructor({ lenBlock = {} } = {}) {
1080
- var _a2, _b, _c;
1081
- super();
1082
- this.isIndefiniteForm = (_a2 = lenBlock.isIndefiniteForm) !== null && _a2 !== void 0 ? _a2 : false;
1083
- this.longFormUsed = (_b = lenBlock.longFormUsed) !== null && _b !== void 0 ? _b : false;
1084
- this.length = (_c = lenBlock.length) !== null && _c !== void 0 ? _c : 0;
1085
- }
1086
- fromBER(inputBuffer, inputOffset, inputLength) {
1087
- const view = BufferSourceConverter.toUint8Array(inputBuffer);
1088
- if (!checkBufferParams(this, view, inputOffset, inputLength)) {
1089
- return -1;
1090
- }
1091
- const intBuffer = view.subarray(inputOffset, inputOffset + inputLength);
1092
- if (intBuffer.length === 0) {
1093
- this.error = "Zero buffer length";
1094
- return -1;
1095
- }
1096
- if (intBuffer[0] === 255) {
1097
- this.error = "Length block 0xFF is reserved by standard";
1098
- return -1;
1099
- }
1100
- this.isIndefiniteForm = intBuffer[0] === 128;
1101
- if (this.isIndefiniteForm) {
1102
- this.blockLength = 1;
1103
- return inputOffset + this.blockLength;
1104
- }
1105
- this.longFormUsed = !!(intBuffer[0] & 128);
1106
- if (this.longFormUsed === false) {
1107
- this.length = intBuffer[0];
1108
- this.blockLength = 1;
1109
- return inputOffset + this.blockLength;
1110
- }
1111
- const count = intBuffer[0] & 127;
1112
- if (count > 8) {
1113
- this.error = "Too big integer";
1114
- return -1;
1115
- }
1116
- if (count + 1 > intBuffer.length) {
1117
- this.error = "End of input reached before message was fully decoded";
1118
- return -1;
1119
- }
1120
- const lenOffset = inputOffset + 1;
1121
- const lengthBufferView = view.subarray(lenOffset, lenOffset + count);
1122
- if (lengthBufferView[count - 1] === 0)
1123
- this.warnings.push("Needlessly long encoded length");
1124
- this.length = utilFromBase(lengthBufferView, 8);
1125
- if (this.longFormUsed && this.length <= 127)
1126
- this.warnings.push("Unnecessary usage of long length form");
1127
- this.blockLength = count + 1;
1128
- return inputOffset + this.blockLength;
1129
- }
1130
- toBER(sizeOnly = false) {
1131
- let retBuf;
1132
- let retView;
1133
- if (this.length > 127)
1134
- this.longFormUsed = true;
1135
- if (this.isIndefiniteForm) {
1136
- retBuf = new ArrayBuffer(1);
1137
- if (sizeOnly === false) {
1138
- retView = new Uint8Array(retBuf);
1139
- retView[0] = 128;
1140
- }
1141
- return retBuf;
1142
- }
1143
- if (this.longFormUsed) {
1144
- const encodedBuf = utilToBase(this.length, 8);
1145
- if (encodedBuf.byteLength > 127) {
1146
- this.error = "Too big length";
1147
- return EMPTY_BUFFER;
1148
- }
1149
- retBuf = new ArrayBuffer(encodedBuf.byteLength + 1);
1150
- if (sizeOnly)
1151
- return retBuf;
1152
- const encodedView = new Uint8Array(encodedBuf);
1153
- retView = new Uint8Array(retBuf);
1154
- retView[0] = encodedBuf.byteLength | 128;
1155
- for (let i = 0; i < encodedBuf.byteLength; i++)
1156
- retView[i + 1] = encodedView[i];
1157
- return retBuf;
1158
- }
1159
- retBuf = new ArrayBuffer(1);
1160
- if (sizeOnly === false) {
1161
- retView = new Uint8Array(retBuf);
1162
- retView[0] = this.length;
1163
- }
1164
- return retBuf;
1165
- }
1166
- toJSON() {
1167
- return {
1168
- ...super.toJSON(),
1169
- isIndefiniteForm: this.isIndefiniteForm,
1170
- longFormUsed: this.longFormUsed,
1171
- length: this.length
1172
- };
1173
- }
1174
- };
1175
- LocalLengthBlock.NAME = "lengthBlock";
1176
- var typeStore = {};
1177
- var BaseBlock = class extends LocalBaseBlock {
1178
- constructor({ name = EMPTY_STRING, optional = false, primitiveSchema, ...parameters } = {}, valueBlockType) {
1179
- super(parameters);
1180
- this.name = name;
1181
- this.optional = optional;
1182
- if (primitiveSchema) {
1183
- this.primitiveSchema = primitiveSchema;
1184
- }
1185
- this.idBlock = new LocalIdentificationBlock(parameters);
1186
- this.lenBlock = new LocalLengthBlock(parameters);
1187
- this.valueBlock = valueBlockType ? new valueBlockType(parameters) : new ValueBlock(parameters);
1188
- }
1189
- fromBER(inputBuffer, inputOffset, inputLength) {
1190
- const resultOffset = this.valueBlock.fromBER(inputBuffer, inputOffset, this.lenBlock.isIndefiniteForm ? inputLength : this.lenBlock.length);
1191
- if (resultOffset === -1) {
1192
- this.error = this.valueBlock.error;
1193
- return resultOffset;
1194
- }
1195
- if (!this.idBlock.error.length)
1196
- this.blockLength += this.idBlock.blockLength;
1197
- if (!this.lenBlock.error.length)
1198
- this.blockLength += this.lenBlock.blockLength;
1199
- if (!this.valueBlock.error.length)
1200
- this.blockLength += this.valueBlock.blockLength;
1201
- return resultOffset;
1202
- }
1203
- toBER(sizeOnly, writer) {
1204
- const _writer = writer || new ViewWriter();
1205
- if (!writer) {
1206
- prepareIndefiniteForm(this);
1207
- }
1208
- const idBlockBuf = this.idBlock.toBER(sizeOnly);
1209
- _writer.write(idBlockBuf);
1210
- if (this.lenBlock.isIndefiniteForm) {
1211
- _writer.write(new Uint8Array([128]).buffer);
1212
- this.valueBlock.toBER(sizeOnly, _writer);
1213
- _writer.write(new ArrayBuffer(2));
1214
- } else {
1215
- const valueBlockBuf = this.valueBlock.toBER(sizeOnly);
1216
- this.lenBlock.length = valueBlockBuf.byteLength;
1217
- const lenBlockBuf = this.lenBlock.toBER(sizeOnly);
1218
- _writer.write(lenBlockBuf);
1219
- _writer.write(valueBlockBuf);
1220
- }
1221
- if (!writer) {
1222
- return _writer.final();
1223
- }
1224
- return EMPTY_BUFFER;
1225
- }
1226
- toJSON() {
1227
- const object = {
1228
- ...super.toJSON(),
1229
- idBlock: this.idBlock.toJSON(),
1230
- lenBlock: this.lenBlock.toJSON(),
1231
- valueBlock: this.valueBlock.toJSON(),
1232
- name: this.name,
1233
- optional: this.optional
1234
- };
1235
- if (this.primitiveSchema)
1236
- object.primitiveSchema = this.primitiveSchema.toJSON();
1237
- return object;
1238
- }
1239
- toString(encoding = "ascii") {
1240
- if (encoding === "ascii") {
1241
- return this.onAsciiEncoding();
1242
- }
1243
- return Convert.ToHex(this.toBER());
1244
- }
1245
- onAsciiEncoding() {
1246
- const name = this.constructor.NAME;
1247
- const value = Convert.ToHex(this.valueBlock.valueBeforeDecodeView);
1248
- return `${name} : ${value}`;
1249
- }
1250
- isEqual(other) {
1251
- if (this === other) {
1252
- return true;
1253
- }
1254
- if (!(other instanceof this.constructor)) {
1255
- return false;
1256
- }
1257
- const thisRaw = this.toBER();
1258
- const otherRaw = other.toBER();
1259
- return isEqualBuffer(thisRaw, otherRaw);
1260
- }
1261
- };
1262
- BaseBlock.NAME = "BaseBlock";
1263
- function prepareIndefiniteForm(baseBlock) {
1264
- var _a2;
1265
- if (baseBlock instanceof typeStore.Constructed) {
1266
- for (const value of baseBlock.valueBlock.value) {
1267
- if (prepareIndefiniteForm(value)) {
1268
- baseBlock.lenBlock.isIndefiniteForm = true;
1269
- }
1270
- }
1271
- }
1272
- return !!((_a2 = baseBlock.lenBlock) === null || _a2 === void 0 ? void 0 : _a2.isIndefiniteForm);
1273
- }
1274
- var BaseStringBlock = class extends BaseBlock {
1275
- getValue() {
1276
- return this.valueBlock.value;
1277
- }
1278
- setValue(value) {
1279
- this.valueBlock.value = value;
1280
- }
1281
- constructor({ value = EMPTY_STRING, ...parameters } = {}, stringValueBlockType) {
1282
- super(parameters, stringValueBlockType);
1283
- if (value) {
1284
- this.fromString(value);
1285
- }
1286
- }
1287
- fromBER(inputBuffer, inputOffset, inputLength) {
1288
- const resultOffset = this.valueBlock.fromBER(inputBuffer, inputOffset, this.lenBlock.isIndefiniteForm ? inputLength : this.lenBlock.length);
1289
- if (resultOffset === -1) {
1290
- this.error = this.valueBlock.error;
1291
- return resultOffset;
1292
- }
1293
- this.fromBuffer(this.valueBlock.valueHexView);
1294
- if (!this.idBlock.error.length)
1295
- this.blockLength += this.idBlock.blockLength;
1296
- if (!this.lenBlock.error.length)
1297
- this.blockLength += this.lenBlock.blockLength;
1298
- if (!this.valueBlock.error.length)
1299
- this.blockLength += this.valueBlock.blockLength;
1300
- return resultOffset;
1301
- }
1302
- onAsciiEncoding() {
1303
- return `${this.constructor.NAME} : '${this.valueBlock.value}'`;
1304
- }
1305
- };
1306
- BaseStringBlock.NAME = "BaseStringBlock";
1307
- var LocalPrimitiveValueBlock = class extends HexBlock(ValueBlock) {
1308
- constructor({ isHexOnly = true, ...parameters } = {}) {
1309
- super(parameters);
1310
- this.isHexOnly = isHexOnly;
1311
- }
1312
- };
1313
- LocalPrimitiveValueBlock.NAME = "PrimitiveValueBlock";
1314
- var _a$w;
1315
- var Primitive = class extends BaseBlock {
1316
- constructor(parameters = {}) {
1317
- super(parameters, LocalPrimitiveValueBlock);
1318
- this.idBlock.isConstructed = false;
1319
- }
1320
- };
1321
- _a$w = Primitive;
1322
- (() => {
1323
- typeStore.Primitive = _a$w;
1324
- })();
1325
- Primitive.NAME = "PRIMITIVE";
1326
- function localChangeType(inputObject, newType) {
1327
- if (inputObject instanceof newType) {
1328
- return inputObject;
1329
- }
1330
- const newObject = new newType();
1331
- newObject.idBlock = inputObject.idBlock;
1332
- newObject.lenBlock = inputObject.lenBlock;
1333
- newObject.warnings = inputObject.warnings;
1334
- newObject.valueBeforeDecodeView = inputObject.valueBeforeDecodeView;
1335
- return newObject;
1336
- }
1337
- function localFromBER(inputBuffer, inputOffset = 0, inputLength = inputBuffer.length) {
1338
- const incomingOffset = inputOffset;
1339
- let returnObject = new BaseBlock({}, ValueBlock);
1340
- const baseBlock = new LocalBaseBlock();
1341
- if (!checkBufferParams(baseBlock, inputBuffer, inputOffset, inputLength)) {
1342
- returnObject.error = baseBlock.error;
1343
- return {
1344
- offset: -1,
1345
- result: returnObject
1346
- };
1347
- }
1348
- const intBuffer = inputBuffer.subarray(inputOffset, inputOffset + inputLength);
1349
- if (!intBuffer.length) {
1350
- returnObject.error = "Zero buffer length";
1351
- return {
1352
- offset: -1,
1353
- result: returnObject
1354
- };
1355
- }
1356
- let resultOffset = returnObject.idBlock.fromBER(inputBuffer, inputOffset, inputLength);
1357
- if (returnObject.idBlock.warnings.length) {
1358
- returnObject.warnings.concat(returnObject.idBlock.warnings);
1359
- }
1360
- if (resultOffset === -1) {
1361
- returnObject.error = returnObject.idBlock.error;
1362
- return {
1363
- offset: -1,
1364
- result: returnObject
1365
- };
1366
- }
1367
- inputOffset = resultOffset;
1368
- inputLength -= returnObject.idBlock.blockLength;
1369
- resultOffset = returnObject.lenBlock.fromBER(inputBuffer, inputOffset, inputLength);
1370
- if (returnObject.lenBlock.warnings.length) {
1371
- returnObject.warnings.concat(returnObject.lenBlock.warnings);
1372
- }
1373
- if (resultOffset === -1) {
1374
- returnObject.error = returnObject.lenBlock.error;
1375
- return {
1376
- offset: -1,
1377
- result: returnObject
1378
- };
1379
- }
1380
- inputOffset = resultOffset;
1381
- inputLength -= returnObject.lenBlock.blockLength;
1382
- if (!returnObject.idBlock.isConstructed && returnObject.lenBlock.isIndefiniteForm) {
1383
- returnObject.error = "Indefinite length form used for primitive encoding form";
1384
- return {
1385
- offset: -1,
1386
- result: returnObject
1387
- };
1388
- }
1389
- let newASN1Type = BaseBlock;
1390
- switch (returnObject.idBlock.tagClass) {
1391
- case 1:
1392
- if (returnObject.idBlock.tagNumber >= 37 && returnObject.idBlock.isHexOnly === false) {
1393
- returnObject.error = "UNIVERSAL 37 and upper tags are reserved by ASN.1 standard";
1394
- return {
1395
- offset: -1,
1396
- result: returnObject
1397
- };
1398
- }
1399
- switch (returnObject.idBlock.tagNumber) {
1400
- case 0:
1401
- if (returnObject.idBlock.isConstructed && returnObject.lenBlock.length > 0) {
1402
- returnObject.error = "Type [UNIVERSAL 0] is reserved";
1403
- return {
1404
- offset: -1,
1405
- result: returnObject
1406
- };
1407
- }
1408
- newASN1Type = typeStore.EndOfContent;
1409
- break;
1410
- case 1:
1411
- newASN1Type = typeStore.Boolean;
1412
- break;
1413
- case 2:
1414
- newASN1Type = typeStore.Integer;
1415
- break;
1416
- case 3:
1417
- newASN1Type = typeStore.BitString;
1418
- break;
1419
- case 4:
1420
- newASN1Type = typeStore.OctetString;
1421
- break;
1422
- case 5:
1423
- newASN1Type = typeStore.Null;
1424
- break;
1425
- case 6:
1426
- newASN1Type = typeStore.ObjectIdentifier;
1427
- break;
1428
- case 10:
1429
- newASN1Type = typeStore.Enumerated;
1430
- break;
1431
- case 12:
1432
- newASN1Type = typeStore.Utf8String;
1433
- break;
1434
- case 13:
1435
- newASN1Type = typeStore.RelativeObjectIdentifier;
1436
- break;
1437
- case 14:
1438
- newASN1Type = typeStore.TIME;
1439
- break;
1440
- case 15:
1441
- returnObject.error = "[UNIVERSAL 15] is reserved by ASN.1 standard";
1442
- return {
1443
- offset: -1,
1444
- result: returnObject
1445
- };
1446
- case 16:
1447
- newASN1Type = typeStore.Sequence;
1448
- break;
1449
- case 17:
1450
- newASN1Type = typeStore.Set;
1451
- break;
1452
- case 18:
1453
- newASN1Type = typeStore.NumericString;
1454
- break;
1455
- case 19:
1456
- newASN1Type = typeStore.PrintableString;
1457
- break;
1458
- case 20:
1459
- newASN1Type = typeStore.TeletexString;
1460
- break;
1461
- case 21:
1462
- newASN1Type = typeStore.VideotexString;
1463
- break;
1464
- case 22:
1465
- newASN1Type = typeStore.IA5String;
1466
- break;
1467
- case 23:
1468
- newASN1Type = typeStore.UTCTime;
1469
- break;
1470
- case 24:
1471
- newASN1Type = typeStore.GeneralizedTime;
1472
- break;
1473
- case 25:
1474
- newASN1Type = typeStore.GraphicString;
1475
- break;
1476
- case 26:
1477
- newASN1Type = typeStore.VisibleString;
1478
- break;
1479
- case 27:
1480
- newASN1Type = typeStore.GeneralString;
1481
- break;
1482
- case 28:
1483
- newASN1Type = typeStore.UniversalString;
1484
- break;
1485
- case 29:
1486
- newASN1Type = typeStore.CharacterString;
1487
- break;
1488
- case 30:
1489
- newASN1Type = typeStore.BmpString;
1490
- break;
1491
- case 31:
1492
- newASN1Type = typeStore.DATE;
1493
- break;
1494
- case 32:
1495
- newASN1Type = typeStore.TimeOfDay;
1496
- break;
1497
- case 33:
1498
- newASN1Type = typeStore.DateTime;
1499
- break;
1500
- case 34:
1501
- newASN1Type = typeStore.Duration;
1502
- break;
1503
- default: {
1504
- const newObject = returnObject.idBlock.isConstructed ? new typeStore.Constructed() : new typeStore.Primitive();
1505
- newObject.idBlock = returnObject.idBlock;
1506
- newObject.lenBlock = returnObject.lenBlock;
1507
- newObject.warnings = returnObject.warnings;
1508
- returnObject = newObject;
1509
- }
1510
- }
1511
- break;
1512
- case 2:
1513
- case 3:
1514
- case 4:
1515
- default: {
1516
- newASN1Type = returnObject.idBlock.isConstructed ? typeStore.Constructed : typeStore.Primitive;
1517
- }
1518
- }
1519
- returnObject = localChangeType(returnObject, newASN1Type);
1520
- resultOffset = returnObject.fromBER(inputBuffer, inputOffset, returnObject.lenBlock.isIndefiniteForm ? inputLength : returnObject.lenBlock.length);
1521
- returnObject.valueBeforeDecodeView = inputBuffer.subarray(incomingOffset, incomingOffset + returnObject.blockLength);
1522
- return {
1523
- offset: resultOffset,
1524
- result: returnObject
1525
- };
1526
- }
1527
- function fromBER(inputBuffer) {
1528
- if (!inputBuffer.byteLength) {
1529
- const result = new BaseBlock({}, ValueBlock);
1530
- result.error = "Input buffer has zero length";
1531
- return {
1532
- offset: -1,
1533
- result
1534
- };
1535
- }
1536
- return localFromBER(BufferSourceConverter.toUint8Array(inputBuffer).slice(), 0, inputBuffer.byteLength);
1537
- }
1538
- function checkLen(indefiniteLength, length) {
1539
- if (indefiniteLength) {
1540
- return 1;
1541
- }
1542
- return length;
1543
- }
1544
- var LocalConstructedValueBlock = class extends ValueBlock {
1545
- constructor({ value = [], isIndefiniteForm = false, ...parameters } = {}) {
1546
- super(parameters);
1547
- this.value = value;
1548
- this.isIndefiniteForm = isIndefiniteForm;
1549
- }
1550
- fromBER(inputBuffer, inputOffset, inputLength) {
1551
- const view = BufferSourceConverter.toUint8Array(inputBuffer);
1552
- if (!checkBufferParams(this, view, inputOffset, inputLength)) {
1553
- return -1;
1554
- }
1555
- this.valueBeforeDecodeView = view.subarray(inputOffset, inputOffset + inputLength);
1556
- if (this.valueBeforeDecodeView.length === 0) {
1557
- this.warnings.push("Zero buffer length");
1558
- return inputOffset;
1559
- }
1560
- let currentOffset = inputOffset;
1561
- while (checkLen(this.isIndefiniteForm, inputLength) > 0) {
1562
- const returnObject = localFromBER(view, currentOffset, inputLength);
1563
- if (returnObject.offset === -1) {
1564
- this.error = returnObject.result.error;
1565
- this.warnings.concat(returnObject.result.warnings);
1566
- return -1;
1567
- }
1568
- currentOffset = returnObject.offset;
1569
- this.blockLength += returnObject.result.blockLength;
1570
- inputLength -= returnObject.result.blockLength;
1571
- this.value.push(returnObject.result);
1572
- if (this.isIndefiniteForm && returnObject.result.constructor.NAME === END_OF_CONTENT_NAME) {
1573
- break;
1574
- }
1575
- }
1576
- if (this.isIndefiniteForm) {
1577
- if (this.value[this.value.length - 1].constructor.NAME === END_OF_CONTENT_NAME) {
1578
- this.value.pop();
1579
- } else {
1580
- this.warnings.push("No EndOfContent block encoded");
1581
- }
1582
- }
1583
- return currentOffset;
1584
- }
1585
- toBER(sizeOnly, writer) {
1586
- const _writer = writer || new ViewWriter();
1587
- for (let i = 0; i < this.value.length; i++) {
1588
- this.value[i].toBER(sizeOnly, _writer);
1589
- }
1590
- if (!writer) {
1591
- return _writer.final();
1592
- }
1593
- return EMPTY_BUFFER;
1594
- }
1595
- toJSON() {
1596
- const object = {
1597
- ...super.toJSON(),
1598
- isIndefiniteForm: this.isIndefiniteForm,
1599
- value: []
1600
- };
1601
- for (const value of this.value) {
1602
- object.value.push(value.toJSON());
1603
- }
1604
- return object;
1605
- }
1606
- };
1607
- LocalConstructedValueBlock.NAME = "ConstructedValueBlock";
1608
- var _a$v;
1609
- var Constructed = class extends BaseBlock {
1610
- constructor(parameters = {}) {
1611
- super(parameters, LocalConstructedValueBlock);
1612
- this.idBlock.isConstructed = true;
1613
- }
1614
- fromBER(inputBuffer, inputOffset, inputLength) {
1615
- this.valueBlock.isIndefiniteForm = this.lenBlock.isIndefiniteForm;
1616
- const resultOffset = this.valueBlock.fromBER(inputBuffer, inputOffset, this.lenBlock.isIndefiniteForm ? inputLength : this.lenBlock.length);
1617
- if (resultOffset === -1) {
1618
- this.error = this.valueBlock.error;
1619
- return resultOffset;
1620
- }
1621
- if (!this.idBlock.error.length)
1622
- this.blockLength += this.idBlock.blockLength;
1623
- if (!this.lenBlock.error.length)
1624
- this.blockLength += this.lenBlock.blockLength;
1625
- if (!this.valueBlock.error.length)
1626
- this.blockLength += this.valueBlock.blockLength;
1627
- return resultOffset;
1628
- }
1629
- onAsciiEncoding() {
1630
- const values = [];
1631
- for (const value of this.valueBlock.value) {
1632
- values.push(value.toString("ascii").split("\n").map((o) => ` ${o}`).join("\n"));
1633
- }
1634
- const blockName = this.idBlock.tagClass === 3 ? `[${this.idBlock.tagNumber}]` : this.constructor.NAME;
1635
- return values.length ? `${blockName} :
1636
- ${values.join("\n")}` : `${blockName} :`;
1637
- }
1638
- };
1639
- _a$v = Constructed;
1640
- (() => {
1641
- typeStore.Constructed = _a$v;
1642
- })();
1643
- Constructed.NAME = "CONSTRUCTED";
1644
- var LocalEndOfContentValueBlock = class extends ValueBlock {
1645
- fromBER(inputBuffer, inputOffset, _inputLength) {
1646
- return inputOffset;
1647
- }
1648
- toBER(_sizeOnly) {
1649
- return EMPTY_BUFFER;
1650
- }
1651
- };
1652
- LocalEndOfContentValueBlock.override = "EndOfContentValueBlock";
1653
- var _a$u;
1654
- var EndOfContent = class extends BaseBlock {
1655
- constructor(parameters = {}) {
1656
- super(parameters, LocalEndOfContentValueBlock);
1657
- this.idBlock.tagClass = 1;
1658
- this.idBlock.tagNumber = 0;
1659
- }
1660
- };
1661
- _a$u = EndOfContent;
1662
- (() => {
1663
- typeStore.EndOfContent = _a$u;
1664
- })();
1665
- EndOfContent.NAME = END_OF_CONTENT_NAME;
1666
- var _a$t;
1667
- var Null = class extends BaseBlock {
1668
- constructor(parameters = {}) {
1669
- super(parameters, ValueBlock);
1670
- this.idBlock.tagClass = 1;
1671
- this.idBlock.tagNumber = 5;
1672
- }
1673
- fromBER(inputBuffer, inputOffset, inputLength) {
1674
- if (this.lenBlock.length > 0)
1675
- this.warnings.push("Non-zero length of value block for Null type");
1676
- if (!this.idBlock.error.length)
1677
- this.blockLength += this.idBlock.blockLength;
1678
- if (!this.lenBlock.error.length)
1679
- this.blockLength += this.lenBlock.blockLength;
1680
- this.blockLength += inputLength;
1681
- if (inputOffset + inputLength > inputBuffer.byteLength) {
1682
- this.error = "End of input reached before message was fully decoded (inconsistent offset and length values)";
1683
- return -1;
1684
- }
1685
- return inputOffset + inputLength;
1686
- }
1687
- toBER(sizeOnly, writer) {
1688
- const retBuf = new ArrayBuffer(2);
1689
- if (!sizeOnly) {
1690
- const retView = new Uint8Array(retBuf);
1691
- retView[0] = 5;
1692
- retView[1] = 0;
1693
- }
1694
- if (writer) {
1695
- writer.write(retBuf);
1696
- }
1697
- return retBuf;
1698
- }
1699
- onAsciiEncoding() {
1700
- return `${this.constructor.NAME}`;
1701
- }
1702
- };
1703
- _a$t = Null;
1704
- (() => {
1705
- typeStore.Null = _a$t;
1706
- })();
1707
- Null.NAME = "NULL";
1708
- var LocalBooleanValueBlock = class extends HexBlock(ValueBlock) {
1709
- get value() {
1710
- for (const octet of this.valueHexView) {
1711
- if (octet > 0) {
1712
- return true;
1713
- }
1714
- }
1715
- return false;
1716
- }
1717
- set value(value) {
1718
- this.valueHexView[0] = value ? 255 : 0;
1719
- }
1720
- constructor({ value, ...parameters } = {}) {
1721
- super(parameters);
1722
- if (parameters.valueHex) {
1723
- this.valueHexView = BufferSourceConverter.toUint8Array(parameters.valueHex);
1724
- } else {
1725
- this.valueHexView = new Uint8Array(1);
1726
- }
1727
- if (value) {
1728
- this.value = value;
1729
- }
1730
- }
1731
- fromBER(inputBuffer, inputOffset, inputLength) {
1732
- const inputView = BufferSourceConverter.toUint8Array(inputBuffer);
1733
- if (!checkBufferParams(this, inputView, inputOffset, inputLength)) {
1734
- return -1;
1735
- }
1736
- this.valueHexView = inputView.subarray(inputOffset, inputOffset + inputLength);
1737
- if (inputLength > 1)
1738
- this.warnings.push("Boolean value encoded in more then 1 octet");
1739
- this.isHexOnly = true;
1740
- utilDecodeTC.call(this);
1741
- this.blockLength = inputLength;
1742
- return inputOffset + inputLength;
1743
- }
1744
- toBER() {
1745
- return this.valueHexView.slice();
1746
- }
1747
- toJSON() {
1748
- return {
1749
- ...super.toJSON(),
1750
- value: this.value
1751
- };
1752
- }
1753
- };
1754
- LocalBooleanValueBlock.NAME = "BooleanValueBlock";
1755
- var _a$s;
1756
- var Boolean = class extends BaseBlock {
1757
- getValue() {
1758
- return this.valueBlock.value;
1759
- }
1760
- setValue(value) {
1761
- this.valueBlock.value = value;
1762
- }
1763
- constructor(parameters = {}) {
1764
- super(parameters, LocalBooleanValueBlock);
1765
- this.idBlock.tagClass = 1;
1766
- this.idBlock.tagNumber = 1;
1767
- }
1768
- onAsciiEncoding() {
1769
- return `${this.constructor.NAME} : ${this.getValue}`;
1770
- }
1771
- };
1772
- _a$s = Boolean;
1773
- (() => {
1774
- typeStore.Boolean = _a$s;
1775
- })();
1776
- Boolean.NAME = "BOOLEAN";
1777
- var LocalOctetStringValueBlock = class extends HexBlock(LocalConstructedValueBlock) {
1778
- constructor({ isConstructed = false, ...parameters } = {}) {
1779
- super(parameters);
1780
- this.isConstructed = isConstructed;
1781
- }
1782
- fromBER(inputBuffer, inputOffset, inputLength) {
1783
- let resultOffset = 0;
1784
- if (this.isConstructed) {
1785
- this.isHexOnly = false;
1786
- resultOffset = LocalConstructedValueBlock.prototype.fromBER.call(this, inputBuffer, inputOffset, inputLength);
1787
- if (resultOffset === -1)
1788
- return resultOffset;
1789
- for (let i = 0; i < this.value.length; i++) {
1790
- const currentBlockName = this.value[i].constructor.NAME;
1791
- if (currentBlockName === END_OF_CONTENT_NAME) {
1792
- if (this.isIndefiniteForm)
1793
- break;
1794
- else {
1795
- this.error = "EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only";
1796
- return -1;
1797
- }
1798
- }
1799
- if (currentBlockName !== OCTET_STRING_NAME) {
1800
- this.error = "OCTET STRING may consists of OCTET STRINGs only";
1801
- return -1;
1802
- }
1803
- }
1804
- } else {
1805
- this.isHexOnly = true;
1806
- resultOffset = super.fromBER(inputBuffer, inputOffset, inputLength);
1807
- this.blockLength = inputLength;
1808
- }
1809
- return resultOffset;
1810
- }
1811
- toBER(sizeOnly, writer) {
1812
- if (this.isConstructed)
1813
- return LocalConstructedValueBlock.prototype.toBER.call(this, sizeOnly, writer);
1814
- return sizeOnly ? new ArrayBuffer(this.valueHexView.byteLength) : this.valueHexView.slice().buffer;
1815
- }
1816
- toJSON() {
1817
- return {
1818
- ...super.toJSON(),
1819
- isConstructed: this.isConstructed
1820
- };
1821
- }
1822
- };
1823
- LocalOctetStringValueBlock.NAME = "OctetStringValueBlock";
1824
- var _a$r;
1825
- var OctetString = class extends BaseBlock {
1826
- constructor({ idBlock = {}, lenBlock = {}, ...parameters } = {}) {
1827
- var _b, _c;
1828
- (_b = parameters.isConstructed) !== null && _b !== void 0 ? _b : parameters.isConstructed = !!((_c = parameters.value) === null || _c === void 0 ? void 0 : _c.length);
1829
- super({
1830
- idBlock: {
1831
- isConstructed: parameters.isConstructed,
1832
- ...idBlock
1833
- },
1834
- lenBlock: {
1835
- ...lenBlock,
1836
- isIndefiniteForm: !!parameters.isIndefiniteForm
1837
- },
1838
- ...parameters
1839
- }, LocalOctetStringValueBlock);
1840
- this.idBlock.tagClass = 1;
1841
- this.idBlock.tagNumber = 4;
1842
- }
1843
- fromBER(inputBuffer, inputOffset, inputLength) {
1844
- this.valueBlock.isConstructed = this.idBlock.isConstructed;
1845
- this.valueBlock.isIndefiniteForm = this.lenBlock.isIndefiniteForm;
1846
- if (inputLength === 0) {
1847
- if (this.idBlock.error.length === 0)
1848
- this.blockLength += this.idBlock.blockLength;
1849
- if (this.lenBlock.error.length === 0)
1850
- this.blockLength += this.lenBlock.blockLength;
1851
- return inputOffset;
1852
- }
1853
- if (!this.valueBlock.isConstructed) {
1854
- const view = inputBuffer instanceof ArrayBuffer ? new Uint8Array(inputBuffer) : inputBuffer;
1855
- const buf = view.subarray(inputOffset, inputOffset + inputLength);
1856
- try {
1857
- if (buf.byteLength) {
1858
- const asn = localFromBER(buf, 0, buf.byteLength);
1859
- if (asn.offset !== -1 && asn.offset === inputLength) {
1860
- this.valueBlock.value = [asn.result];
1861
- }
1862
- }
1863
- } catch {
1864
- }
1865
- }
1866
- return super.fromBER(inputBuffer, inputOffset, inputLength);
1867
- }
1868
- onAsciiEncoding() {
1869
- if (this.valueBlock.isConstructed || this.valueBlock.value && this.valueBlock.value.length) {
1870
- return Constructed.prototype.onAsciiEncoding.call(this);
1871
- }
1872
- const name = this.constructor.NAME;
1873
- const value = Convert.ToHex(this.valueBlock.valueHexView);
1874
- return `${name} : ${value}`;
1875
- }
1876
- getValue() {
1877
- if (!this.idBlock.isConstructed) {
1878
- return this.valueBlock.valueHexView.slice().buffer;
1879
- }
1880
- const array = [];
1881
- for (const content of this.valueBlock.value) {
1882
- if (content instanceof _a$r) {
1883
- array.push(content.valueBlock.valueHexView);
1884
- }
1885
- }
1886
- return BufferSourceConverter.concat(array);
1887
- }
1888
- };
1889
- _a$r = OctetString;
1890
- (() => {
1891
- typeStore.OctetString = _a$r;
1892
- })();
1893
- OctetString.NAME = OCTET_STRING_NAME;
1894
- var LocalBitStringValueBlock = class extends HexBlock(LocalConstructedValueBlock) {
1895
- constructor({ unusedBits = 0, isConstructed = false, ...parameters } = {}) {
1896
- super(parameters);
1897
- this.unusedBits = unusedBits;
1898
- this.isConstructed = isConstructed;
1899
- this.blockLength = this.valueHexView.byteLength;
1900
- }
1901
- fromBER(inputBuffer, inputOffset, inputLength) {
1902
- if (!inputLength) {
1903
- return inputOffset;
1904
- }
1905
- let resultOffset = -1;
1906
- if (this.isConstructed) {
1907
- resultOffset = LocalConstructedValueBlock.prototype.fromBER.call(this, inputBuffer, inputOffset, inputLength);
1908
- if (resultOffset === -1)
1909
- return resultOffset;
1910
- for (const value of this.value) {
1911
- const currentBlockName = value.constructor.NAME;
1912
- if (currentBlockName === END_OF_CONTENT_NAME) {
1913
- if (this.isIndefiniteForm)
1914
- break;
1915
- else {
1916
- this.error = "EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only";
1917
- return -1;
1918
- }
1919
- }
1920
- if (currentBlockName !== BIT_STRING_NAME) {
1921
- this.error = "BIT STRING may consists of BIT STRINGs only";
1922
- return -1;
1923
- }
1924
- const valueBlock = value.valueBlock;
1925
- if (this.unusedBits > 0 && valueBlock.unusedBits > 0) {
1926
- this.error = 'Using of "unused bits" inside constructive BIT STRING allowed for least one only';
1927
- return -1;
1928
- }
1929
- this.unusedBits = valueBlock.unusedBits;
1930
- }
1931
- return resultOffset;
1932
- }
1933
- const inputView = BufferSourceConverter.toUint8Array(inputBuffer);
1934
- if (!checkBufferParams(this, inputView, inputOffset, inputLength)) {
1935
- return -1;
1936
- }
1937
- const intBuffer = inputView.subarray(inputOffset, inputOffset + inputLength);
1938
- this.unusedBits = intBuffer[0];
1939
- if (this.unusedBits > 7) {
1940
- this.error = "Unused bits for BitString must be in range 0-7";
1941
- return -1;
1942
- }
1943
- if (!this.unusedBits) {
1944
- const buf = intBuffer.subarray(1);
1945
- try {
1946
- if (buf.byteLength) {
1947
- const asn = localFromBER(buf, 0, buf.byteLength);
1948
- if (asn.offset !== -1 && asn.offset === inputLength - 1) {
1949
- this.value = [asn.result];
1950
- }
1951
- }
1952
- } catch {
1953
- }
1954
- }
1955
- this.valueHexView = intBuffer.subarray(1);
1956
- this.blockLength = intBuffer.length;
1957
- return inputOffset + inputLength;
1958
- }
1959
- toBER(sizeOnly, writer) {
1960
- if (this.isConstructed) {
1961
- return LocalConstructedValueBlock.prototype.toBER.call(this, sizeOnly, writer);
1962
- }
1963
- if (sizeOnly) {
1964
- return new ArrayBuffer(this.valueHexView.byteLength + 1);
1965
- }
1966
- if (!this.valueHexView.byteLength) {
1967
- const empty = new Uint8Array(1);
1968
- empty[0] = 0;
1969
- return empty.buffer;
1970
- }
1971
- const retView = new Uint8Array(this.valueHexView.length + 1);
1972
- retView[0] = this.unusedBits;
1973
- retView.set(this.valueHexView, 1);
1974
- return retView.buffer;
1975
- }
1976
- toJSON() {
1977
- return {
1978
- ...super.toJSON(),
1979
- unusedBits: this.unusedBits,
1980
- isConstructed: this.isConstructed
1981
- };
1982
- }
1983
- };
1984
- LocalBitStringValueBlock.NAME = "BitStringValueBlock";
1985
- var _a$q;
1986
- var BitString = class extends BaseBlock {
1987
- constructor({ idBlock = {}, lenBlock = {}, ...parameters } = {}) {
1988
- var _b, _c;
1989
- (_b = parameters.isConstructed) !== null && _b !== void 0 ? _b : parameters.isConstructed = !!((_c = parameters.value) === null || _c === void 0 ? void 0 : _c.length);
1990
- super({
1991
- idBlock: {
1992
- isConstructed: parameters.isConstructed,
1993
- ...idBlock
1994
- },
1995
- lenBlock: {
1996
- ...lenBlock,
1997
- isIndefiniteForm: !!parameters.isIndefiniteForm
1998
- },
1999
- ...parameters
2000
- }, LocalBitStringValueBlock);
2001
- this.idBlock.tagClass = 1;
2002
- this.idBlock.tagNumber = 3;
2003
- }
2004
- fromBER(inputBuffer, inputOffset, inputLength) {
2005
- this.valueBlock.isConstructed = this.idBlock.isConstructed;
2006
- this.valueBlock.isIndefiniteForm = this.lenBlock.isIndefiniteForm;
2007
- return super.fromBER(inputBuffer, inputOffset, inputLength);
2008
- }
2009
- onAsciiEncoding() {
2010
- if (this.valueBlock.isConstructed || this.valueBlock.value && this.valueBlock.value.length) {
2011
- return Constructed.prototype.onAsciiEncoding.call(this);
2012
- } else {
2013
- const bits = [];
2014
- const valueHex = this.valueBlock.valueHexView;
2015
- for (const byte of valueHex) {
2016
- bits.push(byte.toString(2).padStart(8, "0"));
2017
- }
2018
- const bitsStr = bits.join("");
2019
- const name = this.constructor.NAME;
2020
- const value = bitsStr.substring(0, bitsStr.length - this.valueBlock.unusedBits);
2021
- return `${name} : ${value}`;
2022
- }
2023
- }
2024
- };
2025
- _a$q = BitString;
2026
- (() => {
2027
- typeStore.BitString = _a$q;
2028
- })();
2029
- BitString.NAME = BIT_STRING_NAME;
2030
- var _a$p;
2031
- function viewAdd(first, second) {
2032
- const c = new Uint8Array([0]);
2033
- const firstView = new Uint8Array(first);
2034
- const secondView = new Uint8Array(second);
2035
- let firstViewCopy = firstView.slice(0);
2036
- const firstViewCopyLength = firstViewCopy.length - 1;
2037
- const secondViewCopy = secondView.slice(0);
2038
- const secondViewCopyLength = secondViewCopy.length - 1;
2039
- let value = 0;
2040
- const max = secondViewCopyLength < firstViewCopyLength ? firstViewCopyLength : secondViewCopyLength;
2041
- let counter = 0;
2042
- for (let i = max; i >= 0; i--, counter++) {
2043
- switch (true) {
2044
- case counter < secondViewCopy.length:
2045
- value = firstViewCopy[firstViewCopyLength - counter] + secondViewCopy[secondViewCopyLength - counter] + c[0];
2046
- break;
2047
- default:
2048
- value = firstViewCopy[firstViewCopyLength - counter] + c[0];
2049
- }
2050
- c[0] = value / 10;
2051
- switch (true) {
2052
- case counter >= firstViewCopy.length:
2053
- firstViewCopy = utilConcatView(new Uint8Array([value % 10]), firstViewCopy);
2054
- break;
2055
- default:
2056
- firstViewCopy[firstViewCopyLength - counter] = value % 10;
2057
- }
2058
- }
2059
- if (c[0] > 0)
2060
- firstViewCopy = utilConcatView(c, firstViewCopy);
2061
- return firstViewCopy;
2062
- }
2063
- function power2(n) {
2064
- if (n >= powers2.length) {
2065
- for (let p = powers2.length; p <= n; p++) {
2066
- const c = new Uint8Array([0]);
2067
- let digits = powers2[p - 1].slice(0);
2068
- for (let i = digits.length - 1; i >= 0; i--) {
2069
- const newValue = new Uint8Array([(digits[i] << 1) + c[0]]);
2070
- c[0] = newValue[0] / 10;
2071
- digits[i] = newValue[0] % 10;
2072
- }
2073
- if (c[0] > 0)
2074
- digits = utilConcatView(c, digits);
2075
- powers2.push(digits);
2076
- }
2077
- }
2078
- return powers2[n];
2079
- }
2080
- function viewSub(first, second) {
2081
- let b = 0;
2082
- const firstView = new Uint8Array(first);
2083
- const secondView = new Uint8Array(second);
2084
- const firstViewCopy = firstView.slice(0);
2085
- const firstViewCopyLength = firstViewCopy.length - 1;
2086
- const secondViewCopy = secondView.slice(0);
2087
- const secondViewCopyLength = secondViewCopy.length - 1;
2088
- let value;
2089
- let counter = 0;
2090
- for (let i = secondViewCopyLength; i >= 0; i--, counter++) {
2091
- value = firstViewCopy[firstViewCopyLength - counter] - secondViewCopy[secondViewCopyLength - counter] - b;
2092
- switch (true) {
2093
- case value < 0:
2094
- b = 1;
2095
- firstViewCopy[firstViewCopyLength - counter] = value + 10;
2096
- break;
2097
- default:
2098
- b = 0;
2099
- firstViewCopy[firstViewCopyLength - counter] = value;
2100
- }
2101
- }
2102
- if (b > 0) {
2103
- for (let i = firstViewCopyLength - secondViewCopyLength + 1; i >= 0; i--, counter++) {
2104
- value = firstViewCopy[firstViewCopyLength - counter] - b;
2105
- if (value < 0) {
2106
- b = 1;
2107
- firstViewCopy[firstViewCopyLength - counter] = value + 10;
2108
- } else {
2109
- b = 0;
2110
- firstViewCopy[firstViewCopyLength - counter] = value;
2111
- break;
2112
- }
2113
- }
2114
- }
2115
- return firstViewCopy.slice();
2116
- }
2117
- var LocalIntegerValueBlock = class extends HexBlock(ValueBlock) {
2118
- setValueHex() {
2119
- if (this.valueHexView.length >= 4) {
2120
- this.warnings.push("Too big Integer for decoding, hex only");
2121
- this.isHexOnly = true;
2122
- this._valueDec = 0;
2123
- } else {
2124
- this.isHexOnly = false;
2125
- if (this.valueHexView.length > 0) {
2126
- this._valueDec = utilDecodeTC.call(this);
2127
- }
2128
- }
2129
- }
2130
- constructor({ value, ...parameters } = {}) {
2131
- super(parameters);
2132
- this._valueDec = 0;
2133
- if (parameters.valueHex) {
2134
- this.setValueHex();
2135
- }
2136
- if (value !== void 0) {
2137
- this.valueDec = value;
2138
- }
2139
- }
2140
- set valueDec(v) {
2141
- this._valueDec = v;
2142
- this.isHexOnly = false;
2143
- this.valueHexView = new Uint8Array(utilEncodeTC(v));
2144
- }
2145
- get valueDec() {
2146
- return this._valueDec;
2147
- }
2148
- fromDER(inputBuffer, inputOffset, inputLength, expectedLength = 0) {
2149
- const offset = this.fromBER(inputBuffer, inputOffset, inputLength);
2150
- if (offset === -1)
2151
- return offset;
2152
- const view = this.valueHexView;
2153
- if (view[0] === 0 && (view[1] & 128) !== 0) {
2154
- this.valueHexView = view.subarray(1);
2155
- } else {
2156
- if (expectedLength !== 0) {
2157
- if (view.length < expectedLength) {
2158
- if (expectedLength - view.length > 1)
2159
- expectedLength = view.length + 1;
2160
- this.valueHexView = view.subarray(expectedLength - view.length);
2161
- }
2162
- }
2163
- }
2164
- return offset;
2165
- }
2166
- toDER(sizeOnly = false) {
2167
- const view = this.valueHexView;
2168
- switch (true) {
2169
- case (view[0] & 128) !== 0:
2170
- {
2171
- const updatedView = new Uint8Array(this.valueHexView.length + 1);
2172
- updatedView[0] = 0;
2173
- updatedView.set(view, 1);
2174
- this.valueHexView = updatedView;
2175
- }
2176
- break;
2177
- case (view[0] === 0 && (view[1] & 128) === 0):
2178
- {
2179
- this.valueHexView = this.valueHexView.subarray(1);
2180
- }
2181
- break;
2182
- }
2183
- return this.toBER(sizeOnly);
2184
- }
2185
- fromBER(inputBuffer, inputOffset, inputLength) {
2186
- const resultOffset = super.fromBER(inputBuffer, inputOffset, inputLength);
2187
- if (resultOffset === -1) {
2188
- return resultOffset;
2189
- }
2190
- this.setValueHex();
2191
- return resultOffset;
2192
- }
2193
- toBER(sizeOnly) {
2194
- return sizeOnly ? new ArrayBuffer(this.valueHexView.length) : this.valueHexView.slice().buffer;
2195
- }
2196
- toJSON() {
2197
- return {
2198
- ...super.toJSON(),
2199
- valueDec: this.valueDec
2200
- };
2201
- }
2202
- toString() {
2203
- const firstBit = this.valueHexView.length * 8 - 1;
2204
- let digits = new Uint8Array(this.valueHexView.length * 8 / 3);
2205
- let bitNumber = 0;
2206
- let currentByte;
2207
- const asn1View = this.valueHexView;
2208
- let result = "";
2209
- let flag = false;
2210
- for (let byteNumber = asn1View.byteLength - 1; byteNumber >= 0; byteNumber--) {
2211
- currentByte = asn1View[byteNumber];
2212
- for (let i = 0; i < 8; i++) {
2213
- if ((currentByte & 1) === 1) {
2214
- switch (bitNumber) {
2215
- case firstBit:
2216
- digits = viewSub(power2(bitNumber), digits);
2217
- result = "-";
2218
- break;
2219
- default:
2220
- digits = viewAdd(digits, power2(bitNumber));
2221
- }
2222
- }
2223
- bitNumber++;
2224
- currentByte >>= 1;
2225
- }
2226
- }
2227
- for (let i = 0; i < digits.length; i++) {
2228
- if (digits[i])
2229
- flag = true;
2230
- if (flag)
2231
- result += digitsString.charAt(digits[i]);
2232
- }
2233
- if (flag === false)
2234
- result += digitsString.charAt(0);
2235
- return result;
2236
- }
2237
- };
2238
- _a$p = LocalIntegerValueBlock;
2239
- LocalIntegerValueBlock.NAME = "IntegerValueBlock";
2240
- (() => {
2241
- Object.defineProperty(_a$p.prototype, "valueHex", {
2242
- set: function(v) {
2243
- this.valueHexView = new Uint8Array(v);
2244
- this.setValueHex();
2245
- },
2246
- get: function() {
2247
- return this.valueHexView.slice().buffer;
2248
- }
2249
- });
2250
- })();
2251
- var _a$o;
2252
- var Integer = class extends BaseBlock {
2253
- constructor(parameters = {}) {
2254
- super(parameters, LocalIntegerValueBlock);
2255
- this.idBlock.tagClass = 1;
2256
- this.idBlock.tagNumber = 2;
2257
- }
2258
- toBigInt() {
2259
- assertBigInt();
2260
- return BigInt(this.valueBlock.toString());
2261
- }
2262
- static fromBigInt(value) {
2263
- assertBigInt();
2264
- const bigIntValue = BigInt(value);
2265
- const writer = new ViewWriter();
2266
- const hex = bigIntValue.toString(16).replace(/^-/, "");
2267
- const view = new Uint8Array(Convert.FromHex(hex));
2268
- if (bigIntValue < 0) {
2269
- const first = new Uint8Array(view.length + (view[0] & 128 ? 1 : 0));
2270
- first[0] |= 128;
2271
- const firstInt = BigInt(`0x${Convert.ToHex(first)}`);
2272
- const secondInt = firstInt + bigIntValue;
2273
- const second = BufferSourceConverter.toUint8Array(Convert.FromHex(secondInt.toString(16)));
2274
- second[0] |= 128;
2275
- writer.write(second);
2276
- } else {
2277
- if (view[0] & 128) {
2278
- writer.write(new Uint8Array([0]));
2279
- }
2280
- writer.write(view);
2281
- }
2282
- const res = new _a$o({ valueHex: writer.final() });
2283
- return res;
2284
- }
2285
- convertToDER() {
2286
- const integer = new _a$o({ valueHex: this.valueBlock.valueHexView });
2287
- integer.valueBlock.toDER();
2288
- return integer;
2289
- }
2290
- convertFromDER() {
2291
- return new _a$o({
2292
- valueHex: this.valueBlock.valueHexView[0] === 0 ? this.valueBlock.valueHexView.subarray(1) : this.valueBlock.valueHexView
2293
- });
2294
- }
2295
- onAsciiEncoding() {
2296
- return `${this.constructor.NAME} : ${this.valueBlock.toString()}`;
2297
- }
2298
- };
2299
- _a$o = Integer;
2300
- (() => {
2301
- typeStore.Integer = _a$o;
2302
- })();
2303
- Integer.NAME = "INTEGER";
2304
- var _a$n;
2305
- var Enumerated = class extends Integer {
2306
- constructor(parameters = {}) {
2307
- super(parameters);
2308
- this.idBlock.tagClass = 1;
2309
- this.idBlock.tagNumber = 10;
2310
- }
2311
- };
2312
- _a$n = Enumerated;
2313
- (() => {
2314
- typeStore.Enumerated = _a$n;
2315
- })();
2316
- Enumerated.NAME = "ENUMERATED";
2317
- var LocalSidValueBlock = class extends HexBlock(ValueBlock) {
2318
- constructor({ valueDec = -1, isFirstSid = false, ...parameters } = {}) {
2319
- super(parameters);
2320
- this.valueDec = valueDec;
2321
- this.isFirstSid = isFirstSid;
2322
- }
2323
- fromBER(inputBuffer, inputOffset, inputLength) {
2324
- if (!inputLength) {
2325
- return inputOffset;
2326
- }
2327
- const inputView = BufferSourceConverter.toUint8Array(inputBuffer);
2328
- if (!checkBufferParams(this, inputView, inputOffset, inputLength)) {
2329
- return -1;
2330
- }
2331
- const intBuffer = inputView.subarray(inputOffset, inputOffset + inputLength);
2332
- this.valueHexView = new Uint8Array(inputLength);
2333
- for (let i = 0; i < inputLength; i++) {
2334
- this.valueHexView[i] = intBuffer[i] & 127;
2335
- this.blockLength++;
2336
- if ((intBuffer[i] & 128) === 0)
2337
- break;
2338
- }
2339
- const tempView = new Uint8Array(this.blockLength);
2340
- for (let i = 0; i < this.blockLength; i++) {
2341
- tempView[i] = this.valueHexView[i];
2342
- }
2343
- this.valueHexView = tempView;
2344
- if ((intBuffer[this.blockLength - 1] & 128) !== 0) {
2345
- this.error = "End of input reached before message was fully decoded";
2346
- return -1;
2347
- }
2348
- if (this.valueHexView[0] === 0)
2349
- this.warnings.push("Needlessly long format of SID encoding");
2350
- if (this.blockLength <= 8)
2351
- this.valueDec = utilFromBase(this.valueHexView, 7);
2352
- else {
2353
- this.isHexOnly = true;
2354
- this.warnings.push("Too big SID for decoding, hex only");
2355
- }
2356
- return inputOffset + this.blockLength;
2357
- }
2358
- set valueBigInt(value) {
2359
- assertBigInt();
2360
- let bits = BigInt(value).toString(2);
2361
- while (bits.length % 7) {
2362
- bits = "0" + bits;
2363
- }
2364
- const bytes = new Uint8Array(bits.length / 7);
2365
- for (let i = 0; i < bytes.length; i++) {
2366
- bytes[i] = parseInt(bits.slice(i * 7, i * 7 + 7), 2) + (i + 1 < bytes.length ? 128 : 0);
2367
- }
2368
- this.fromBER(bytes.buffer, 0, bytes.length);
2369
- }
2370
- toBER(sizeOnly) {
2371
- if (this.isHexOnly) {
2372
- if (sizeOnly)
2373
- return new ArrayBuffer(this.valueHexView.byteLength);
2374
- const curView = this.valueHexView;
2375
- const retView2 = new Uint8Array(this.blockLength);
2376
- for (let i = 0; i < this.blockLength - 1; i++)
2377
- retView2[i] = curView[i] | 128;
2378
- retView2[this.blockLength - 1] = curView[this.blockLength - 1];
2379
- return retView2.buffer;
2380
- }
2381
- const encodedBuf = utilToBase(this.valueDec, 7);
2382
- if (encodedBuf.byteLength === 0) {
2383
- this.error = "Error during encoding SID value";
2384
- return EMPTY_BUFFER;
2385
- }
2386
- const retView = new Uint8Array(encodedBuf.byteLength);
2387
- if (!sizeOnly) {
2388
- const encodedView = new Uint8Array(encodedBuf);
2389
- const len = encodedBuf.byteLength - 1;
2390
- for (let i = 0; i < len; i++)
2391
- retView[i] = encodedView[i] | 128;
2392
- retView[len] = encodedView[len];
2393
- }
2394
- return retView;
2395
- }
2396
- toString() {
2397
- let result = "";
2398
- if (this.isHexOnly)
2399
- result = Convert.ToHex(this.valueHexView);
2400
- else {
2401
- if (this.isFirstSid) {
2402
- let sidValue = this.valueDec;
2403
- if (this.valueDec <= 39)
2404
- result = "0.";
2405
- else {
2406
- if (this.valueDec <= 79) {
2407
- result = "1.";
2408
- sidValue -= 40;
2409
- } else {
2410
- result = "2.";
2411
- sidValue -= 80;
2412
- }
2413
- }
2414
- result += sidValue.toString();
2415
- } else
2416
- result = this.valueDec.toString();
2417
- }
2418
- return result;
2419
- }
2420
- toJSON() {
2421
- return {
2422
- ...super.toJSON(),
2423
- valueDec: this.valueDec,
2424
- isFirstSid: this.isFirstSid
2425
- };
2426
- }
2427
- };
2428
- LocalSidValueBlock.NAME = "sidBlock";
2429
- var LocalObjectIdentifierValueBlock = class extends ValueBlock {
2430
- constructor({ value = EMPTY_STRING, ...parameters } = {}) {
2431
- super(parameters);
2432
- this.value = [];
2433
- if (value) {
2434
- this.fromString(value);
2435
- }
2436
- }
2437
- fromBER(inputBuffer, inputOffset, inputLength) {
2438
- let resultOffset = inputOffset;
2439
- while (inputLength > 0) {
2440
- const sidBlock = new LocalSidValueBlock();
2441
- resultOffset = sidBlock.fromBER(inputBuffer, resultOffset, inputLength);
2442
- if (resultOffset === -1) {
2443
- this.blockLength = 0;
2444
- this.error = sidBlock.error;
2445
- return resultOffset;
2446
- }
2447
- if (this.value.length === 0)
2448
- sidBlock.isFirstSid = true;
2449
- this.blockLength += sidBlock.blockLength;
2450
- inputLength -= sidBlock.blockLength;
2451
- this.value.push(sidBlock);
2452
- }
2453
- return resultOffset;
2454
- }
2455
- toBER(sizeOnly) {
2456
- const retBuffers = [];
2457
- for (let i = 0; i < this.value.length; i++) {
2458
- const valueBuf = this.value[i].toBER(sizeOnly);
2459
- if (valueBuf.byteLength === 0) {
2460
- this.error = this.value[i].error;
2461
- return EMPTY_BUFFER;
2462
- }
2463
- retBuffers.push(valueBuf);
2464
- }
2465
- return concat(retBuffers);
2466
- }
2467
- fromString(string) {
2468
- this.value = [];
2469
- let pos1 = 0;
2470
- let pos2 = 0;
2471
- let sid = "";
2472
- let flag = false;
2473
- do {
2474
- pos2 = string.indexOf(".", pos1);
2475
- if (pos2 === -1)
2476
- sid = string.substring(pos1);
2477
- else
2478
- sid = string.substring(pos1, pos2);
2479
- pos1 = pos2 + 1;
2480
- if (flag) {
2481
- const sidBlock = this.value[0];
2482
- let plus = 0;
2483
- switch (sidBlock.valueDec) {
2484
- case 0:
2485
- break;
2486
- case 1:
2487
- plus = 40;
2488
- break;
2489
- case 2:
2490
- plus = 80;
2491
- break;
2492
- default:
2493
- this.value = [];
2494
- return;
2495
- }
2496
- const parsedSID = parseInt(sid, 10);
2497
- if (isNaN(parsedSID))
2498
- return;
2499
- sidBlock.valueDec = parsedSID + plus;
2500
- flag = false;
2501
- } else {
2502
- const sidBlock = new LocalSidValueBlock();
2503
- if (sid > Number.MAX_SAFE_INTEGER) {
2504
- assertBigInt();
2505
- const sidValue = BigInt(sid);
2506
- sidBlock.valueBigInt = sidValue;
2507
- } else {
2508
- sidBlock.valueDec = parseInt(sid, 10);
2509
- if (isNaN(sidBlock.valueDec))
2510
- return;
2511
- }
2512
- if (!this.value.length) {
2513
- sidBlock.isFirstSid = true;
2514
- flag = true;
2515
- }
2516
- this.value.push(sidBlock);
2517
- }
2518
- } while (pos2 !== -1);
2519
- }
2520
- toString() {
2521
- let result = "";
2522
- let isHexOnly = false;
2523
- for (let i = 0; i < this.value.length; i++) {
2524
- isHexOnly = this.value[i].isHexOnly;
2525
- let sidStr = this.value[i].toString();
2526
- if (i !== 0)
2527
- result = `${result}.`;
2528
- if (isHexOnly) {
2529
- sidStr = `{${sidStr}}`;
2530
- if (this.value[i].isFirstSid)
2531
- result = `2.{${sidStr} - 80}`;
2532
- else
2533
- result += sidStr;
2534
- } else
2535
- result += sidStr;
2536
- }
2537
- return result;
2538
- }
2539
- toJSON() {
2540
- const object = {
2541
- ...super.toJSON(),
2542
- value: this.toString(),
2543
- sidArray: []
2544
- };
2545
- for (let i = 0; i < this.value.length; i++) {
2546
- object.sidArray.push(this.value[i].toJSON());
2547
- }
2548
- return object;
2549
- }
2550
- };
2551
- LocalObjectIdentifierValueBlock.NAME = "ObjectIdentifierValueBlock";
2552
- var _a$m;
2553
- var ObjectIdentifier = class extends BaseBlock {
2554
- getValue() {
2555
- return this.valueBlock.toString();
2556
- }
2557
- setValue(value) {
2558
- this.valueBlock.fromString(value);
2559
- }
2560
- constructor(parameters = {}) {
2561
- super(parameters, LocalObjectIdentifierValueBlock);
2562
- this.idBlock.tagClass = 1;
2563
- this.idBlock.tagNumber = 6;
2564
- }
2565
- onAsciiEncoding() {
2566
- return `${this.constructor.NAME} : ${this.valueBlock.toString() || "empty"}`;
2567
- }
2568
- toJSON() {
2569
- return {
2570
- ...super.toJSON(),
2571
- value: this.getValue()
2572
- };
2573
- }
2574
- };
2575
- _a$m = ObjectIdentifier;
2576
- (() => {
2577
- typeStore.ObjectIdentifier = _a$m;
2578
- })();
2579
- ObjectIdentifier.NAME = "OBJECT IDENTIFIER";
2580
- var LocalRelativeSidValueBlock = class extends HexBlock(LocalBaseBlock) {
2581
- constructor({ valueDec = 0, ...parameters } = {}) {
2582
- super(parameters);
2583
- this.valueDec = valueDec;
2584
- }
2585
- fromBER(inputBuffer, inputOffset, inputLength) {
2586
- if (inputLength === 0)
2587
- return inputOffset;
2588
- const inputView = BufferSourceConverter.toUint8Array(inputBuffer);
2589
- if (!checkBufferParams(this, inputView, inputOffset, inputLength))
2590
- return -1;
2591
- const intBuffer = inputView.subarray(inputOffset, inputOffset + inputLength);
2592
- this.valueHexView = new Uint8Array(inputLength);
2593
- for (let i = 0; i < inputLength; i++) {
2594
- this.valueHexView[i] = intBuffer[i] & 127;
2595
- this.blockLength++;
2596
- if ((intBuffer[i] & 128) === 0)
2597
- break;
2598
- }
2599
- const tempView = new Uint8Array(this.blockLength);
2600
- for (let i = 0; i < this.blockLength; i++)
2601
- tempView[i] = this.valueHexView[i];
2602
- this.valueHexView = tempView;
2603
- if ((intBuffer[this.blockLength - 1] & 128) !== 0) {
2604
- this.error = "End of input reached before message was fully decoded";
2605
- return -1;
2606
- }
2607
- if (this.valueHexView[0] === 0)
2608
- this.warnings.push("Needlessly long format of SID encoding");
2609
- if (this.blockLength <= 8)
2610
- this.valueDec = utilFromBase(this.valueHexView, 7);
2611
- else {
2612
- this.isHexOnly = true;
2613
- this.warnings.push("Too big SID for decoding, hex only");
2614
- }
2615
- return inputOffset + this.blockLength;
2616
- }
2617
- toBER(sizeOnly) {
2618
- if (this.isHexOnly) {
2619
- if (sizeOnly)
2620
- return new ArrayBuffer(this.valueHexView.byteLength);
2621
- const curView = this.valueHexView;
2622
- const retView2 = new Uint8Array(this.blockLength);
2623
- for (let i = 0; i < this.blockLength - 1; i++)
2624
- retView2[i] = curView[i] | 128;
2625
- retView2[this.blockLength - 1] = curView[this.blockLength - 1];
2626
- return retView2.buffer;
2627
- }
2628
- const encodedBuf = utilToBase(this.valueDec, 7);
2629
- if (encodedBuf.byteLength === 0) {
2630
- this.error = "Error during encoding SID value";
2631
- return EMPTY_BUFFER;
2632
- }
2633
- const retView = new Uint8Array(encodedBuf.byteLength);
2634
- if (!sizeOnly) {
2635
- const encodedView = new Uint8Array(encodedBuf);
2636
- const len = encodedBuf.byteLength - 1;
2637
- for (let i = 0; i < len; i++)
2638
- retView[i] = encodedView[i] | 128;
2639
- retView[len] = encodedView[len];
2640
- }
2641
- return retView.buffer;
2642
- }
2643
- toString() {
2644
- let result = "";
2645
- if (this.isHexOnly)
2646
- result = Convert.ToHex(this.valueHexView);
2647
- else {
2648
- result = this.valueDec.toString();
2649
- }
2650
- return result;
2651
- }
2652
- toJSON() {
2653
- return {
2654
- ...super.toJSON(),
2655
- valueDec: this.valueDec
2656
- };
2657
- }
2658
- };
2659
- LocalRelativeSidValueBlock.NAME = "relativeSidBlock";
2660
- var LocalRelativeObjectIdentifierValueBlock = class extends ValueBlock {
2661
- constructor({ value = EMPTY_STRING, ...parameters } = {}) {
2662
- super(parameters);
2663
- this.value = [];
2664
- if (value) {
2665
- this.fromString(value);
2666
- }
2667
- }
2668
- fromBER(inputBuffer, inputOffset, inputLength) {
2669
- let resultOffset = inputOffset;
2670
- while (inputLength > 0) {
2671
- const sidBlock = new LocalRelativeSidValueBlock();
2672
- resultOffset = sidBlock.fromBER(inputBuffer, resultOffset, inputLength);
2673
- if (resultOffset === -1) {
2674
- this.blockLength = 0;
2675
- this.error = sidBlock.error;
2676
- return resultOffset;
2677
- }
2678
- this.blockLength += sidBlock.blockLength;
2679
- inputLength -= sidBlock.blockLength;
2680
- this.value.push(sidBlock);
2681
- }
2682
- return resultOffset;
2683
- }
2684
- toBER(sizeOnly, _writer) {
2685
- const retBuffers = [];
2686
- for (let i = 0; i < this.value.length; i++) {
2687
- const valueBuf = this.value[i].toBER(sizeOnly);
2688
- if (valueBuf.byteLength === 0) {
2689
- this.error = this.value[i].error;
2690
- return EMPTY_BUFFER;
2691
- }
2692
- retBuffers.push(valueBuf);
2693
- }
2694
- return concat(retBuffers);
2695
- }
2696
- fromString(string) {
2697
- this.value = [];
2698
- let pos1 = 0;
2699
- let pos2 = 0;
2700
- let sid = "";
2701
- do {
2702
- pos2 = string.indexOf(".", pos1);
2703
- if (pos2 === -1)
2704
- sid = string.substring(pos1);
2705
- else
2706
- sid = string.substring(pos1, pos2);
2707
- pos1 = pos2 + 1;
2708
- const sidBlock = new LocalRelativeSidValueBlock();
2709
- sidBlock.valueDec = parseInt(sid, 10);
2710
- if (isNaN(sidBlock.valueDec))
2711
- return true;
2712
- this.value.push(sidBlock);
2713
- } while (pos2 !== -1);
2714
- return true;
2715
- }
2716
- toString() {
2717
- let result = "";
2718
- let isHexOnly = false;
2719
- for (let i = 0; i < this.value.length; i++) {
2720
- isHexOnly = this.value[i].isHexOnly;
2721
- let sidStr = this.value[i].toString();
2722
- if (i !== 0)
2723
- result = `${result}.`;
2724
- if (isHexOnly) {
2725
- sidStr = `{${sidStr}}`;
2726
- result += sidStr;
2727
- } else
2728
- result += sidStr;
2729
- }
2730
- return result;
2731
- }
2732
- toJSON() {
2733
- const object = {
2734
- ...super.toJSON(),
2735
- value: this.toString(),
2736
- sidArray: []
2737
- };
2738
- for (let i = 0; i < this.value.length; i++)
2739
- object.sidArray.push(this.value[i].toJSON());
2740
- return object;
2741
- }
2742
- };
2743
- LocalRelativeObjectIdentifierValueBlock.NAME = "RelativeObjectIdentifierValueBlock";
2744
- var _a$l;
2745
- var RelativeObjectIdentifier = class extends BaseBlock {
2746
- getValue() {
2747
- return this.valueBlock.toString();
2748
- }
2749
- setValue(value) {
2750
- this.valueBlock.fromString(value);
2751
- }
2752
- constructor(parameters = {}) {
2753
- super(parameters, LocalRelativeObjectIdentifierValueBlock);
2754
- this.idBlock.tagClass = 1;
2755
- this.idBlock.tagNumber = 13;
2756
- }
2757
- onAsciiEncoding() {
2758
- return `${this.constructor.NAME} : ${this.valueBlock.toString() || "empty"}`;
2759
- }
2760
- toJSON() {
2761
- return {
2762
- ...super.toJSON(),
2763
- value: this.getValue()
2764
- };
2765
- }
2766
- };
2767
- _a$l = RelativeObjectIdentifier;
2768
- (() => {
2769
- typeStore.RelativeObjectIdentifier = _a$l;
2770
- })();
2771
- RelativeObjectIdentifier.NAME = "RelativeObjectIdentifier";
2772
- var _a$k;
2773
- var Sequence = class extends Constructed {
2774
- constructor(parameters = {}) {
2775
- super(parameters);
2776
- this.idBlock.tagClass = 1;
2777
- this.idBlock.tagNumber = 16;
2778
- }
2779
- };
2780
- _a$k = Sequence;
2781
- (() => {
2782
- typeStore.Sequence = _a$k;
2783
- })();
2784
- Sequence.NAME = "SEQUENCE";
2785
- var _a$j;
2786
- var Set = class extends Constructed {
2787
- constructor(parameters = {}) {
2788
- super(parameters);
2789
- this.idBlock.tagClass = 1;
2790
- this.idBlock.tagNumber = 17;
2791
- }
2792
- };
2793
- _a$j = Set;
2794
- (() => {
2795
- typeStore.Set = _a$j;
2796
- })();
2797
- Set.NAME = "SET";
2798
- var LocalStringValueBlock = class extends HexBlock(ValueBlock) {
2799
- constructor({ ...parameters } = {}) {
2800
- super(parameters);
2801
- this.isHexOnly = true;
2802
- this.value = EMPTY_STRING;
2803
- }
2804
- toJSON() {
2805
- return {
2806
- ...super.toJSON(),
2807
- value: this.value
2808
- };
2809
- }
2810
- };
2811
- LocalStringValueBlock.NAME = "StringValueBlock";
2812
- var LocalSimpleStringValueBlock = class extends LocalStringValueBlock {
2813
- };
2814
- LocalSimpleStringValueBlock.NAME = "SimpleStringValueBlock";
2815
- var LocalSimpleStringBlock = class extends BaseStringBlock {
2816
- constructor({ ...parameters } = {}) {
2817
- super(parameters, LocalSimpleStringValueBlock);
2818
- }
2819
- fromBuffer(inputBuffer) {
2820
- this.valueBlock.value = String.fromCharCode.apply(null, BufferSourceConverter.toUint8Array(inputBuffer));
2821
- }
2822
- fromString(inputString) {
2823
- const strLen = inputString.length;
2824
- const view = this.valueBlock.valueHexView = new Uint8Array(strLen);
2825
- for (let i = 0; i < strLen; i++)
2826
- view[i] = inputString.charCodeAt(i);
2827
- this.valueBlock.value = inputString;
2828
- }
2829
- };
2830
- LocalSimpleStringBlock.NAME = "SIMPLE STRING";
2831
- var LocalUtf8StringValueBlock = class extends LocalSimpleStringBlock {
2832
- fromBuffer(inputBuffer) {
2833
- this.valueBlock.valueHexView = BufferSourceConverter.toUint8Array(inputBuffer);
2834
- try {
2835
- this.valueBlock.value = Convert.ToUtf8String(inputBuffer);
2836
- } catch (ex) {
2837
- this.warnings.push(`Error during "decodeURIComponent": ${ex}, using raw string`);
2838
- this.valueBlock.value = Convert.ToBinary(inputBuffer);
2839
- }
2840
- }
2841
- fromString(inputString) {
2842
- this.valueBlock.valueHexView = new Uint8Array(Convert.FromUtf8String(inputString));
2843
- this.valueBlock.value = inputString;
2844
- }
2845
- };
2846
- LocalUtf8StringValueBlock.NAME = "Utf8StringValueBlock";
2847
- var _a$i;
2848
- var Utf8String = class extends LocalUtf8StringValueBlock {
2849
- constructor(parameters = {}) {
2850
- super(parameters);
2851
- this.idBlock.tagClass = 1;
2852
- this.idBlock.tagNumber = 12;
2853
- }
2854
- };
2855
- _a$i = Utf8String;
2856
- (() => {
2857
- typeStore.Utf8String = _a$i;
2858
- })();
2859
- Utf8String.NAME = "UTF8String";
2860
- var LocalBmpStringValueBlock = class extends LocalSimpleStringBlock {
2861
- fromBuffer(inputBuffer) {
2862
- this.valueBlock.value = Convert.ToUtf16String(inputBuffer);
2863
- this.valueBlock.valueHexView = BufferSourceConverter.toUint8Array(inputBuffer);
2864
- }
2865
- fromString(inputString) {
2866
- this.valueBlock.value = inputString;
2867
- this.valueBlock.valueHexView = new Uint8Array(Convert.FromUtf16String(inputString));
2868
- }
2869
- };
2870
- LocalBmpStringValueBlock.NAME = "BmpStringValueBlock";
2871
- var _a$h;
2872
- var BmpString = class extends LocalBmpStringValueBlock {
2873
- constructor({ ...parameters } = {}) {
2874
- super(parameters);
2875
- this.idBlock.tagClass = 1;
2876
- this.idBlock.tagNumber = 30;
2877
- }
2878
- };
2879
- _a$h = BmpString;
2880
- (() => {
2881
- typeStore.BmpString = _a$h;
2882
- })();
2883
- BmpString.NAME = "BMPString";
2884
- var LocalUniversalStringValueBlock = class extends LocalSimpleStringBlock {
2885
- fromBuffer(inputBuffer) {
2886
- const copyBuffer = ArrayBuffer.isView(inputBuffer) ? inputBuffer.slice().buffer : inputBuffer.slice(0);
2887
- const valueView = new Uint8Array(copyBuffer);
2888
- for (let i = 0; i < valueView.length; i += 4) {
2889
- valueView[i] = valueView[i + 3];
2890
- valueView[i + 1] = valueView[i + 2];
2891
- valueView[i + 2] = 0;
2892
- valueView[i + 3] = 0;
2893
- }
2894
- this.valueBlock.value = String.fromCharCode.apply(null, new Uint32Array(copyBuffer));
2895
- }
2896
- fromString(inputString) {
2897
- const strLength = inputString.length;
2898
- const valueHexView = this.valueBlock.valueHexView = new Uint8Array(strLength * 4);
2899
- for (let i = 0; i < strLength; i++) {
2900
- const codeBuf = utilToBase(inputString.charCodeAt(i), 8);
2901
- const codeView = new Uint8Array(codeBuf);
2902
- if (codeView.length > 4)
2903
- continue;
2904
- const dif = 4 - codeView.length;
2905
- for (let j = codeView.length - 1; j >= 0; j--)
2906
- valueHexView[i * 4 + j + dif] = codeView[j];
2907
- }
2908
- this.valueBlock.value = inputString;
2909
- }
2910
- };
2911
- LocalUniversalStringValueBlock.NAME = "UniversalStringValueBlock";
2912
- var _a$g;
2913
- var UniversalString = class extends LocalUniversalStringValueBlock {
2914
- constructor({ ...parameters } = {}) {
2915
- super(parameters);
2916
- this.idBlock.tagClass = 1;
2917
- this.idBlock.tagNumber = 28;
2918
- }
2919
- };
2920
- _a$g = UniversalString;
2921
- (() => {
2922
- typeStore.UniversalString = _a$g;
2923
- })();
2924
- UniversalString.NAME = "UniversalString";
2925
- var _a$f;
2926
- var NumericString = class extends LocalSimpleStringBlock {
2927
- constructor(parameters = {}) {
2928
- super(parameters);
2929
- this.idBlock.tagClass = 1;
2930
- this.idBlock.tagNumber = 18;
2931
- }
2932
- };
2933
- _a$f = NumericString;
2934
- (() => {
2935
- typeStore.NumericString = _a$f;
2936
- })();
2937
- NumericString.NAME = "NumericString";
2938
- var _a$e;
2939
- var PrintableString = class extends LocalSimpleStringBlock {
2940
- constructor(parameters = {}) {
2941
- super(parameters);
2942
- this.idBlock.tagClass = 1;
2943
- this.idBlock.tagNumber = 19;
2944
- }
2945
- };
2946
- _a$e = PrintableString;
2947
- (() => {
2948
- typeStore.PrintableString = _a$e;
2949
- })();
2950
- PrintableString.NAME = "PrintableString";
2951
- var _a$d;
2952
- var TeletexString = class extends LocalSimpleStringBlock {
2953
- constructor(parameters = {}) {
2954
- super(parameters);
2955
- this.idBlock.tagClass = 1;
2956
- this.idBlock.tagNumber = 20;
2957
- }
2958
- };
2959
- _a$d = TeletexString;
2960
- (() => {
2961
- typeStore.TeletexString = _a$d;
2962
- })();
2963
- TeletexString.NAME = "TeletexString";
2964
- var _a$c;
2965
- var VideotexString = class extends LocalSimpleStringBlock {
2966
- constructor(parameters = {}) {
2967
- super(parameters);
2968
- this.idBlock.tagClass = 1;
2969
- this.idBlock.tagNumber = 21;
2970
- }
2971
- };
2972
- _a$c = VideotexString;
2973
- (() => {
2974
- typeStore.VideotexString = _a$c;
2975
- })();
2976
- VideotexString.NAME = "VideotexString";
2977
- var _a$b;
2978
- var IA5String = class extends LocalSimpleStringBlock {
2979
- constructor(parameters = {}) {
2980
- super(parameters);
2981
- this.idBlock.tagClass = 1;
2982
- this.idBlock.tagNumber = 22;
2983
- }
2984
- };
2985
- _a$b = IA5String;
2986
- (() => {
2987
- typeStore.IA5String = _a$b;
2988
- })();
2989
- IA5String.NAME = "IA5String";
2990
- var _a$a;
2991
- var GraphicString = class extends LocalSimpleStringBlock {
2992
- constructor(parameters = {}) {
2993
- super(parameters);
2994
- this.idBlock.tagClass = 1;
2995
- this.idBlock.tagNumber = 25;
2996
- }
2997
- };
2998
- _a$a = GraphicString;
2999
- (() => {
3000
- typeStore.GraphicString = _a$a;
3001
- })();
3002
- GraphicString.NAME = "GraphicString";
3003
- var _a$9;
3004
- var VisibleString = class extends LocalSimpleStringBlock {
3005
- constructor(parameters = {}) {
3006
- super(parameters);
3007
- this.idBlock.tagClass = 1;
3008
- this.idBlock.tagNumber = 26;
3009
- }
3010
- };
3011
- _a$9 = VisibleString;
3012
- (() => {
3013
- typeStore.VisibleString = _a$9;
3014
- })();
3015
- VisibleString.NAME = "VisibleString";
3016
- var _a$8;
3017
- var GeneralString = class extends LocalSimpleStringBlock {
3018
- constructor(parameters = {}) {
3019
- super(parameters);
3020
- this.idBlock.tagClass = 1;
3021
- this.idBlock.tagNumber = 27;
3022
- }
3023
- };
3024
- _a$8 = GeneralString;
3025
- (() => {
3026
- typeStore.GeneralString = _a$8;
3027
- })();
3028
- GeneralString.NAME = "GeneralString";
3029
- var _a$7;
3030
- var CharacterString = class extends LocalSimpleStringBlock {
3031
- constructor(parameters = {}) {
3032
- super(parameters);
3033
- this.idBlock.tagClass = 1;
3034
- this.idBlock.tagNumber = 29;
3035
- }
3036
- };
3037
- _a$7 = CharacterString;
3038
- (() => {
3039
- typeStore.CharacterString = _a$7;
3040
- })();
3041
- CharacterString.NAME = "CharacterString";
3042
- var _a$6;
3043
- var UTCTime = class extends VisibleString {
3044
- constructor({ value, valueDate, ...parameters } = {}) {
3045
- super(parameters);
3046
- this.year = 0;
3047
- this.month = 0;
3048
- this.day = 0;
3049
- this.hour = 0;
3050
- this.minute = 0;
3051
- this.second = 0;
3052
- if (value) {
3053
- this.fromString(value);
3054
- this.valueBlock.valueHexView = new Uint8Array(value.length);
3055
- for (let i = 0; i < value.length; i++)
3056
- this.valueBlock.valueHexView[i] = value.charCodeAt(i);
3057
- }
3058
- if (valueDate) {
3059
- this.fromDate(valueDate);
3060
- this.valueBlock.valueHexView = new Uint8Array(this.toBuffer());
3061
- }
3062
- this.idBlock.tagClass = 1;
3063
- this.idBlock.tagNumber = 23;
3064
- }
3065
- fromBuffer(inputBuffer) {
3066
- this.fromString(String.fromCharCode.apply(null, BufferSourceConverter.toUint8Array(inputBuffer)));
3067
- }
3068
- toBuffer() {
3069
- const str = this.toString();
3070
- const buffer = new ArrayBuffer(str.length);
3071
- const view = new Uint8Array(buffer);
3072
- for (let i = 0; i < str.length; i++)
3073
- view[i] = str.charCodeAt(i);
3074
- return buffer;
3075
- }
3076
- fromDate(inputDate) {
3077
- this.year = inputDate.getUTCFullYear();
3078
- this.month = inputDate.getUTCMonth() + 1;
3079
- this.day = inputDate.getUTCDate();
3080
- this.hour = inputDate.getUTCHours();
3081
- this.minute = inputDate.getUTCMinutes();
3082
- this.second = inputDate.getUTCSeconds();
3083
- }
3084
- toDate() {
3085
- return new Date(Date.UTC(this.year, this.month - 1, this.day, this.hour, this.minute, this.second));
3086
- }
3087
- fromString(inputString) {
3088
- const parser = /(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig;
3089
- const parserArray = parser.exec(inputString);
3090
- if (parserArray === null) {
3091
- this.error = "Wrong input string for conversion";
3092
- return;
3093
- }
3094
- const year = parseInt(parserArray[1], 10);
3095
- if (year >= 50)
3096
- this.year = 1900 + year;
3097
- else
3098
- this.year = 2e3 + year;
3099
- this.month = parseInt(parserArray[2], 10);
3100
- this.day = parseInt(parserArray[3], 10);
3101
- this.hour = parseInt(parserArray[4], 10);
3102
- this.minute = parseInt(parserArray[5], 10);
3103
- this.second = parseInt(parserArray[6], 10);
3104
- }
3105
- toString(encoding = "iso") {
3106
- if (encoding === "iso") {
3107
- const outputArray = new Array(7);
3108
- outputArray[0] = padNumber(this.year < 2e3 ? this.year - 1900 : this.year - 2e3, 2);
3109
- outputArray[1] = padNumber(this.month, 2);
3110
- outputArray[2] = padNumber(this.day, 2);
3111
- outputArray[3] = padNumber(this.hour, 2);
3112
- outputArray[4] = padNumber(this.minute, 2);
3113
- outputArray[5] = padNumber(this.second, 2);
3114
- outputArray[6] = "Z";
3115
- return outputArray.join("");
3116
- }
3117
- return super.toString(encoding);
3118
- }
3119
- onAsciiEncoding() {
3120
- return `${this.constructor.NAME} : ${this.toDate().toISOString()}`;
3121
- }
3122
- toJSON() {
3123
- return {
3124
- ...super.toJSON(),
3125
- year: this.year,
3126
- month: this.month,
3127
- day: this.day,
3128
- hour: this.hour,
3129
- minute: this.minute,
3130
- second: this.second
3131
- };
3132
- }
3133
- };
3134
- _a$6 = UTCTime;
3135
- (() => {
3136
- typeStore.UTCTime = _a$6;
3137
- })();
3138
- UTCTime.NAME = "UTCTime";
3139
- var _a$5;
3140
- var GeneralizedTime = class extends UTCTime {
3141
- constructor(parameters = {}) {
3142
- var _b;
3143
- super(parameters);
3144
- (_b = this.millisecond) !== null && _b !== void 0 ? _b : this.millisecond = 0;
3145
- this.idBlock.tagClass = 1;
3146
- this.idBlock.tagNumber = 24;
3147
- }
3148
- fromDate(inputDate) {
3149
- super.fromDate(inputDate);
3150
- this.millisecond = inputDate.getUTCMilliseconds();
3151
- }
3152
- toDate() {
3153
- const utcDate = Date.UTC(this.year, this.month - 1, this.day, this.hour, this.minute, this.second, this.millisecond);
3154
- return new Date(utcDate);
3155
- }
3156
- fromString(inputString) {
3157
- let isUTC = false;
3158
- let timeString = "";
3159
- let dateTimeString = "";
3160
- let fractionPart = 0;
3161
- let parser;
3162
- let hourDifference = 0;
3163
- let minuteDifference = 0;
3164
- if (inputString[inputString.length - 1] === "Z") {
3165
- timeString = inputString.substring(0, inputString.length - 1);
3166
- isUTC = true;
3167
- } else {
3168
- const number = new Number(inputString[inputString.length - 1]);
3169
- if (isNaN(number.valueOf()))
3170
- throw new Error("Wrong input string for conversion");
3171
- timeString = inputString;
3172
- }
3173
- if (isUTC) {
3174
- if (timeString.indexOf("+") !== -1)
3175
- throw new Error("Wrong input string for conversion");
3176
- if (timeString.indexOf("-") !== -1)
3177
- throw new Error("Wrong input string for conversion");
3178
- } else {
3179
- let multiplier = 1;
3180
- let differencePosition = timeString.indexOf("+");
3181
- let differenceString = "";
3182
- if (differencePosition === -1) {
3183
- differencePosition = timeString.indexOf("-");
3184
- multiplier = -1;
3185
- }
3186
- if (differencePosition !== -1) {
3187
- differenceString = timeString.substring(differencePosition + 1);
3188
- timeString = timeString.substring(0, differencePosition);
3189
- if (differenceString.length !== 2 && differenceString.length !== 4)
3190
- throw new Error("Wrong input string for conversion");
3191
- let number = parseInt(differenceString.substring(0, 2), 10);
3192
- if (isNaN(number.valueOf()))
3193
- throw new Error("Wrong input string for conversion");
3194
- hourDifference = multiplier * number;
3195
- if (differenceString.length === 4) {
3196
- number = parseInt(differenceString.substring(2, 4), 10);
3197
- if (isNaN(number.valueOf()))
3198
- throw new Error("Wrong input string for conversion");
3199
- minuteDifference = multiplier * number;
3200
- }
3201
- }
3202
- }
3203
- let fractionPointPosition = timeString.indexOf(".");
3204
- if (fractionPointPosition === -1)
3205
- fractionPointPosition = timeString.indexOf(",");
3206
- if (fractionPointPosition !== -1) {
3207
- const fractionPartCheck = new Number(`0${timeString.substring(fractionPointPosition)}`);
3208
- if (isNaN(fractionPartCheck.valueOf()))
3209
- throw new Error("Wrong input string for conversion");
3210
- fractionPart = fractionPartCheck.valueOf();
3211
- dateTimeString = timeString.substring(0, fractionPointPosition);
3212
- } else
3213
- dateTimeString = timeString;
3214
- switch (true) {
3215
- case dateTimeString.length === 8:
3216
- parser = /(\d{4})(\d{2})(\d{2})/ig;
3217
- if (fractionPointPosition !== -1)
3218
- throw new Error("Wrong input string for conversion");
3219
- break;
3220
- case dateTimeString.length === 10:
3221
- parser = /(\d{4})(\d{2})(\d{2})(\d{2})/ig;
3222
- if (fractionPointPosition !== -1) {
3223
- let fractionResult = 60 * fractionPart;
3224
- this.minute = Math.floor(fractionResult);
3225
- fractionResult = 60 * (fractionResult - this.minute);
3226
- this.second = Math.floor(fractionResult);
3227
- fractionResult = 1e3 * (fractionResult - this.second);
3228
- this.millisecond = Math.floor(fractionResult);
3229
- }
3230
- break;
3231
- case dateTimeString.length === 12:
3232
- parser = /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig;
3233
- if (fractionPointPosition !== -1) {
3234
- let fractionResult = 60 * fractionPart;
3235
- this.second = Math.floor(fractionResult);
3236
- fractionResult = 1e3 * (fractionResult - this.second);
3237
- this.millisecond = Math.floor(fractionResult);
3238
- }
3239
- break;
3240
- case dateTimeString.length === 14:
3241
- parser = /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig;
3242
- if (fractionPointPosition !== -1) {
3243
- const fractionResult = 1e3 * fractionPart;
3244
- this.millisecond = Math.floor(fractionResult);
3245
- }
3246
- break;
3247
- default:
3248
- throw new Error("Wrong input string for conversion");
3249
- }
3250
- const parserArray = parser.exec(dateTimeString);
3251
- if (parserArray === null)
3252
- throw new Error("Wrong input string for conversion");
3253
- for (let j = 1; j < parserArray.length; j++) {
3254
- switch (j) {
3255
- case 1:
3256
- this.year = parseInt(parserArray[j], 10);
3257
- break;
3258
- case 2:
3259
- this.month = parseInt(parserArray[j], 10);
3260
- break;
3261
- case 3:
3262
- this.day = parseInt(parserArray[j], 10);
3263
- break;
3264
- case 4:
3265
- this.hour = parseInt(parserArray[j], 10) + hourDifference;
3266
- break;
3267
- case 5:
3268
- this.minute = parseInt(parserArray[j], 10) + minuteDifference;
3269
- break;
3270
- case 6:
3271
- this.second = parseInt(parserArray[j], 10);
3272
- break;
3273
- default:
3274
- throw new Error("Wrong input string for conversion");
3275
- }
3276
- }
3277
- if (isUTC === false) {
3278
- const tempDate = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond);
3279
- this.year = tempDate.getUTCFullYear();
3280
- this.month = tempDate.getUTCMonth();
3281
- this.day = tempDate.getUTCDay();
3282
- this.hour = tempDate.getUTCHours();
3283
- this.minute = tempDate.getUTCMinutes();
3284
- this.second = tempDate.getUTCSeconds();
3285
- this.millisecond = tempDate.getUTCMilliseconds();
3286
- }
3287
- }
3288
- toString(encoding = "iso") {
3289
- if (encoding === "iso") {
3290
- const outputArray = [];
3291
- outputArray.push(padNumber(this.year, 4));
3292
- outputArray.push(padNumber(this.month, 2));
3293
- outputArray.push(padNumber(this.day, 2));
3294
- outputArray.push(padNumber(this.hour, 2));
3295
- outputArray.push(padNumber(this.minute, 2));
3296
- outputArray.push(padNumber(this.second, 2));
3297
- if (this.millisecond !== 0) {
3298
- outputArray.push(".");
3299
- outputArray.push(padNumber(this.millisecond, 3));
3300
- }
3301
- outputArray.push("Z");
3302
- return outputArray.join("");
3303
- }
3304
- return super.toString(encoding);
3305
- }
3306
- toJSON() {
3307
- return {
3308
- ...super.toJSON(),
3309
- millisecond: this.millisecond
3310
- };
3311
- }
3312
- };
3313
- _a$5 = GeneralizedTime;
3314
- (() => {
3315
- typeStore.GeneralizedTime = _a$5;
3316
- })();
3317
- GeneralizedTime.NAME = "GeneralizedTime";
3318
- var _a$4;
3319
- var DATE = class extends Utf8String {
3320
- constructor(parameters = {}) {
3321
- super(parameters);
3322
- this.idBlock.tagClass = 1;
3323
- this.idBlock.tagNumber = 31;
3324
- }
3325
- };
3326
- _a$4 = DATE;
3327
- (() => {
3328
- typeStore.DATE = _a$4;
3329
- })();
3330
- DATE.NAME = "DATE";
3331
- var _a$3;
3332
- var TimeOfDay = class extends Utf8String {
3333
- constructor(parameters = {}) {
3334
- super(parameters);
3335
- this.idBlock.tagClass = 1;
3336
- this.idBlock.tagNumber = 32;
3337
- }
3338
- };
3339
- _a$3 = TimeOfDay;
3340
- (() => {
3341
- typeStore.TimeOfDay = _a$3;
3342
- })();
3343
- TimeOfDay.NAME = "TimeOfDay";
3344
- var _a$2;
3345
- var DateTime = class extends Utf8String {
3346
- constructor(parameters = {}) {
3347
- super(parameters);
3348
- this.idBlock.tagClass = 1;
3349
- this.idBlock.tagNumber = 33;
3350
- }
3351
- };
3352
- _a$2 = DateTime;
3353
- (() => {
3354
- typeStore.DateTime = _a$2;
3355
- })();
3356
- DateTime.NAME = "DateTime";
3357
- var _a$1;
3358
- var Duration = class extends Utf8String {
3359
- constructor(parameters = {}) {
3360
- super(parameters);
3361
- this.idBlock.tagClass = 1;
3362
- this.idBlock.tagNumber = 34;
3363
- }
3364
- };
3365
- _a$1 = Duration;
3366
- (() => {
3367
- typeStore.Duration = _a$1;
3368
- })();
3369
- Duration.NAME = "Duration";
3370
- var _a;
3371
- var TIME = class extends Utf8String {
3372
- constructor(parameters = {}) {
3373
- super(parameters);
3374
- this.idBlock.tagClass = 1;
3375
- this.idBlock.tagNumber = 14;
3376
- }
3377
- };
3378
- _a = TIME;
3379
- (() => {
3380
- typeStore.TIME = _a;
3381
- })();
3382
- TIME.NAME = "TIME";
3383
- var Any = class {
3384
- constructor({ name = EMPTY_STRING, optional = false } = {}) {
3385
- this.name = name;
3386
- this.optional = optional;
3387
- }
3388
- };
3389
- var Choice = class extends Any {
3390
- constructor({ value = [], ...parameters } = {}) {
3391
- super(parameters);
3392
- this.value = value;
3393
- }
3394
- };
3395
- var Repeated = class extends Any {
3396
- constructor({ value = new Any(), local = false, ...parameters } = {}) {
3397
- super(parameters);
3398
- this.value = value;
3399
- this.local = local;
3400
- }
3401
- };
3402
- var RawData = class {
3403
- get data() {
3404
- return this.dataView.slice().buffer;
3405
- }
3406
- set data(value) {
3407
- this.dataView = BufferSourceConverter.toUint8Array(value);
3408
- }
3409
- constructor({ data = EMPTY_VIEW } = {}) {
3410
- this.dataView = BufferSourceConverter.toUint8Array(data);
3411
- }
3412
- fromBER(inputBuffer, inputOffset, inputLength) {
3413
- const endLength = inputOffset + inputLength;
3414
- this.dataView = BufferSourceConverter.toUint8Array(inputBuffer).subarray(inputOffset, endLength);
3415
- return endLength;
3416
- }
3417
- toBER(_sizeOnly) {
3418
- return this.dataView.slice().buffer;
3419
- }
3420
- };
3421
- function compareSchema(root, inputData, inputSchema) {
3422
- if (inputSchema instanceof Choice) {
3423
- for (const element of inputSchema.value) {
3424
- const result = compareSchema(root, inputData, element);
3425
- if (result.verified) {
3426
- return {
3427
- verified: true,
3428
- result: root
3429
- };
3430
- }
3431
- }
3432
- {
3433
- const _result = {
3434
- verified: false,
3435
- result: { error: "Wrong values for Choice type" }
3436
- };
3437
- if (inputSchema.hasOwnProperty(NAME))
3438
- _result.name = inputSchema.name;
3439
- return _result;
3440
- }
3441
- }
3442
- if (inputSchema instanceof Any) {
3443
- if (inputSchema.hasOwnProperty(NAME))
3444
- root[inputSchema.name] = inputData;
3445
- return {
3446
- verified: true,
3447
- result: root
3448
- };
3449
- }
3450
- if (root instanceof Object === false) {
3451
- return {
3452
- verified: false,
3453
- result: { error: "Wrong root object" }
3454
- };
3455
- }
3456
- if (inputData instanceof Object === false) {
3457
- return {
3458
- verified: false,
3459
- result: { error: "Wrong ASN.1 data" }
3460
- };
3461
- }
3462
- if (inputSchema instanceof Object === false) {
3463
- return {
3464
- verified: false,
3465
- result: { error: "Wrong ASN.1 schema" }
3466
- };
3467
- }
3468
- if (ID_BLOCK in inputSchema === false) {
3469
- return {
3470
- verified: false,
3471
- result: { error: "Wrong ASN.1 schema" }
3472
- };
3473
- }
3474
- if (FROM_BER in inputSchema.idBlock === false) {
3475
- return {
3476
- verified: false,
3477
- result: { error: "Wrong ASN.1 schema" }
3478
- };
3479
- }
3480
- if (TO_BER in inputSchema.idBlock === false) {
3481
- return {
3482
- verified: false,
3483
- result: { error: "Wrong ASN.1 schema" }
3484
- };
3485
- }
3486
- const encodedId = inputSchema.idBlock.toBER(false);
3487
- if (encodedId.byteLength === 0) {
3488
- return {
3489
- verified: false,
3490
- result: { error: "Error encoding idBlock for ASN.1 schema" }
3491
- };
3492
- }
3493
- const decodedOffset = inputSchema.idBlock.fromBER(encodedId, 0, encodedId.byteLength);
3494
- if (decodedOffset === -1) {
3495
- return {
3496
- verified: false,
3497
- result: { error: "Error decoding idBlock for ASN.1 schema" }
3498
- };
3499
- }
3500
- if (inputSchema.idBlock.hasOwnProperty(TAG_CLASS) === false) {
3501
- return {
3502
- verified: false,
3503
- result: { error: "Wrong ASN.1 schema" }
3504
- };
3505
- }
3506
- if (inputSchema.idBlock.tagClass !== inputData.idBlock.tagClass) {
3507
- return {
3508
- verified: false,
3509
- result: root
3510
- };
3511
- }
3512
- if (inputSchema.idBlock.hasOwnProperty(TAG_NUMBER) === false) {
3513
- return {
3514
- verified: false,
3515
- result: { error: "Wrong ASN.1 schema" }
3516
- };
3517
- }
3518
- if (inputSchema.idBlock.tagNumber !== inputData.idBlock.tagNumber) {
3519
- return {
3520
- verified: false,
3521
- result: root
3522
- };
3523
- }
3524
- if (inputSchema.idBlock.hasOwnProperty(IS_CONSTRUCTED) === false) {
3525
- return {
3526
- verified: false,
3527
- result: { error: "Wrong ASN.1 schema" }
3528
- };
3529
- }
3530
- if (inputSchema.idBlock.isConstructed !== inputData.idBlock.isConstructed) {
3531
- return {
3532
- verified: false,
3533
- result: root
3534
- };
3535
- }
3536
- if (!(IS_HEX_ONLY in inputSchema.idBlock)) {
3537
- return {
3538
- verified: false,
3539
- result: { error: "Wrong ASN.1 schema" }
3540
- };
3541
- }
3542
- if (inputSchema.idBlock.isHexOnly !== inputData.idBlock.isHexOnly) {
3543
- return {
3544
- verified: false,
3545
- result: root
3546
- };
3547
- }
3548
- if (inputSchema.idBlock.isHexOnly) {
3549
- if (VALUE_HEX_VIEW in inputSchema.idBlock === false) {
3550
- return {
3551
- verified: false,
3552
- result: { error: "Wrong ASN.1 schema" }
3553
- };
3554
- }
3555
- const schemaView = inputSchema.idBlock.valueHexView;
3556
- const asn1View = inputData.idBlock.valueHexView;
3557
- if (schemaView.length !== asn1View.length) {
3558
- return {
3559
- verified: false,
3560
- result: root
3561
- };
3562
- }
3563
- for (let i = 0; i < schemaView.length; i++) {
3564
- if (schemaView[i] !== asn1View[1]) {
3565
- return {
3566
- verified: false,
3567
- result: root
3568
- };
3569
- }
3570
- }
3571
- }
3572
- if (inputSchema.name) {
3573
- inputSchema.name = inputSchema.name.replace(/^\s+|\s+$/g, EMPTY_STRING);
3574
- if (inputSchema.name)
3575
- root[inputSchema.name] = inputData;
3576
- }
3577
- if (inputSchema instanceof typeStore.Constructed) {
3578
- let admission = 0;
3579
- let result = {
3580
- verified: false,
3581
- result: { error: "Unknown error" }
3582
- };
3583
- let maxLength = inputSchema.valueBlock.value.length;
3584
- if (maxLength > 0) {
3585
- if (inputSchema.valueBlock.value[0] instanceof Repeated) {
3586
- maxLength = inputData.valueBlock.value.length;
3587
- }
3588
- }
3589
- if (maxLength === 0) {
3590
- return {
3591
- verified: true,
3592
- result: root
3593
- };
3594
- }
3595
- if (inputData.valueBlock.value.length === 0 && inputSchema.valueBlock.value.length !== 0) {
3596
- let _optional = true;
3597
- for (let i = 0; i < inputSchema.valueBlock.value.length; i++)
3598
- _optional = _optional && (inputSchema.valueBlock.value[i].optional || false);
3599
- if (_optional) {
3600
- return {
3601
- verified: true,
3602
- result: root
3603
- };
3604
- }
3605
- if (inputSchema.name) {
3606
- inputSchema.name = inputSchema.name.replace(/^\s+|\s+$/g, EMPTY_STRING);
3607
- if (inputSchema.name)
3608
- delete root[inputSchema.name];
3609
- }
3610
- root.error = "Inconsistent object length";
3611
- return {
3612
- verified: false,
3613
- result: root
3614
- };
3615
- }
3616
- for (let i = 0; i < maxLength; i++) {
3617
- if (i - admission >= inputData.valueBlock.value.length) {
3618
- if (inputSchema.valueBlock.value[i].optional === false) {
3619
- const _result = {
3620
- verified: false,
3621
- result: root
3622
- };
3623
- root.error = "Inconsistent length between ASN.1 data and schema";
3624
- if (inputSchema.name) {
3625
- inputSchema.name = inputSchema.name.replace(/^\s+|\s+$/g, EMPTY_STRING);
3626
- if (inputSchema.name) {
3627
- delete root[inputSchema.name];
3628
- _result.name = inputSchema.name;
3629
- }
3630
- }
3631
- return _result;
3632
- }
3633
- } else {
3634
- if (inputSchema.valueBlock.value[0] instanceof Repeated) {
3635
- result = compareSchema(root, inputData.valueBlock.value[i], inputSchema.valueBlock.value[0].value);
3636
- if (result.verified === false) {
3637
- if (inputSchema.valueBlock.value[0].optional)
3638
- admission++;
3639
- else {
3640
- if (inputSchema.name) {
3641
- inputSchema.name = inputSchema.name.replace(/^\s+|\s+$/g, EMPTY_STRING);
3642
- if (inputSchema.name)
3643
- delete root[inputSchema.name];
3644
- }
3645
- return result;
3646
- }
3647
- }
3648
- if (NAME in inputSchema.valueBlock.value[0] && inputSchema.valueBlock.value[0].name.length > 0) {
3649
- let arrayRoot = {};
3650
- if (LOCAL in inputSchema.valueBlock.value[0] && inputSchema.valueBlock.value[0].local)
3651
- arrayRoot = inputData;
3652
- else
3653
- arrayRoot = root;
3654
- if (typeof arrayRoot[inputSchema.valueBlock.value[0].name] === "undefined")
3655
- arrayRoot[inputSchema.valueBlock.value[0].name] = [];
3656
- arrayRoot[inputSchema.valueBlock.value[0].name].push(inputData.valueBlock.value[i]);
3657
- }
3658
- } else {
3659
- result = compareSchema(root, inputData.valueBlock.value[i - admission], inputSchema.valueBlock.value[i]);
3660
- if (result.verified === false) {
3661
- if (inputSchema.valueBlock.value[i].optional)
3662
- admission++;
3663
- else {
3664
- if (inputSchema.name) {
3665
- inputSchema.name = inputSchema.name.replace(/^\s+|\s+$/g, EMPTY_STRING);
3666
- if (inputSchema.name)
3667
- delete root[inputSchema.name];
3668
- }
3669
- return result;
3670
- }
3671
- }
3672
- }
3673
- }
3674
- }
3675
- if (result.verified === false) {
3676
- const _result = {
3677
- verified: false,
3678
- result: root
3679
- };
3680
- if (inputSchema.name) {
3681
- inputSchema.name = inputSchema.name.replace(/^\s+|\s+$/g, EMPTY_STRING);
3682
- if (inputSchema.name) {
3683
- delete root[inputSchema.name];
3684
- _result.name = inputSchema.name;
3685
- }
3686
- }
3687
- return _result;
3688
- }
3689
- return {
3690
- verified: true,
3691
- result: root
3692
- };
3693
- }
3694
- if (inputSchema.primitiveSchema && VALUE_HEX_VIEW in inputData.valueBlock) {
3695
- const asn1 = localFromBER(inputData.valueBlock.valueHexView);
3696
- if (asn1.offset === -1) {
3697
- const _result = {
3698
- verified: false,
3699
- result: asn1.result
3700
- };
3701
- if (inputSchema.name) {
3702
- inputSchema.name = inputSchema.name.replace(/^\s+|\s+$/g, EMPTY_STRING);
3703
- if (inputSchema.name) {
3704
- delete root[inputSchema.name];
3705
- _result.name = inputSchema.name;
3706
- }
3707
- }
3708
- return _result;
3709
- }
3710
- return compareSchema(root, asn1.result, inputSchema.primitiveSchema);
3711
- }
3712
- return {
3713
- verified: true,
3714
- result: root
3715
- };
3716
- }
3717
- function verifySchema(inputBuffer, inputSchema) {
3718
- if (inputSchema instanceof Object === false) {
3719
- return {
3720
- verified: false,
3721
- result: { error: "Wrong ASN.1 schema type" }
3722
- };
3723
- }
3724
- const asn1 = localFromBER(BufferSourceConverter.toUint8Array(inputBuffer));
3725
- if (asn1.offset === -1) {
3726
- return {
3727
- verified: false,
3728
- result: asn1.result
3729
- };
3730
- }
3731
- return compareSchema(asn1.result, asn1.result, inputSchema);
3732
- }
3733
-
3734
- // ../../node_modules/@peculiar/asn1-schema/build/es2015/enums.js
3735
- var AsnTypeTypes;
3736
- (function(AsnTypeTypes2) {
3737
- AsnTypeTypes2[AsnTypeTypes2["Sequence"] = 0] = "Sequence";
3738
- AsnTypeTypes2[AsnTypeTypes2["Set"] = 1] = "Set";
3739
- AsnTypeTypes2[AsnTypeTypes2["Choice"] = 2] = "Choice";
3740
- })(AsnTypeTypes || (AsnTypeTypes = {}));
3741
- var AsnPropTypes;
3742
- (function(AsnPropTypes2) {
3743
- AsnPropTypes2[AsnPropTypes2["Any"] = 1] = "Any";
3744
- AsnPropTypes2[AsnPropTypes2["Boolean"] = 2] = "Boolean";
3745
- AsnPropTypes2[AsnPropTypes2["OctetString"] = 3] = "OctetString";
3746
- AsnPropTypes2[AsnPropTypes2["BitString"] = 4] = "BitString";
3747
- AsnPropTypes2[AsnPropTypes2["Integer"] = 5] = "Integer";
3748
- AsnPropTypes2[AsnPropTypes2["Enumerated"] = 6] = "Enumerated";
3749
- AsnPropTypes2[AsnPropTypes2["ObjectIdentifier"] = 7] = "ObjectIdentifier";
3750
- AsnPropTypes2[AsnPropTypes2["Utf8String"] = 8] = "Utf8String";
3751
- AsnPropTypes2[AsnPropTypes2["BmpString"] = 9] = "BmpString";
3752
- AsnPropTypes2[AsnPropTypes2["UniversalString"] = 10] = "UniversalString";
3753
- AsnPropTypes2[AsnPropTypes2["NumericString"] = 11] = "NumericString";
3754
- AsnPropTypes2[AsnPropTypes2["PrintableString"] = 12] = "PrintableString";
3755
- AsnPropTypes2[AsnPropTypes2["TeletexString"] = 13] = "TeletexString";
3756
- AsnPropTypes2[AsnPropTypes2["VideotexString"] = 14] = "VideotexString";
3757
- AsnPropTypes2[AsnPropTypes2["IA5String"] = 15] = "IA5String";
3758
- AsnPropTypes2[AsnPropTypes2["GraphicString"] = 16] = "GraphicString";
3759
- AsnPropTypes2[AsnPropTypes2["VisibleString"] = 17] = "VisibleString";
3760
- AsnPropTypes2[AsnPropTypes2["GeneralString"] = 18] = "GeneralString";
3761
- AsnPropTypes2[AsnPropTypes2["CharacterString"] = 19] = "CharacterString";
3762
- AsnPropTypes2[AsnPropTypes2["UTCTime"] = 20] = "UTCTime";
3763
- AsnPropTypes2[AsnPropTypes2["GeneralizedTime"] = 21] = "GeneralizedTime";
3764
- AsnPropTypes2[AsnPropTypes2["DATE"] = 22] = "DATE";
3765
- AsnPropTypes2[AsnPropTypes2["TimeOfDay"] = 23] = "TimeOfDay";
3766
- AsnPropTypes2[AsnPropTypes2["DateTime"] = 24] = "DateTime";
3767
- AsnPropTypes2[AsnPropTypes2["Duration"] = 25] = "Duration";
3768
- AsnPropTypes2[AsnPropTypes2["TIME"] = 26] = "TIME";
3769
- AsnPropTypes2[AsnPropTypes2["Null"] = 27] = "Null";
3770
- })(AsnPropTypes || (AsnPropTypes = {}));
3771
-
3772
- // ../../node_modules/@peculiar/asn1-schema/build/es2015/converters.js
3773
- function createStringConverter(Asn1Type) {
3774
- return {
3775
- fromASN: (value) => value.valueBlock.value,
3776
- toASN: (value) => new Asn1Type({ value })
3777
- };
3778
- }
3779
- var AsnUtf8StringConverter = createStringConverter(Utf8String);
3780
- var AsnBmpStringConverter = createStringConverter(BmpString);
3781
- var AsnUniversalStringConverter = createStringConverter(UniversalString);
3782
- var AsnNumericStringConverter = createStringConverter(NumericString);
3783
- var AsnPrintableStringConverter = createStringConverter(PrintableString);
3784
- var AsnTeletexStringConverter = createStringConverter(TeletexString);
3785
- var AsnVideotexStringConverter = createStringConverter(VideotexString);
3786
- var AsnIA5StringConverter = createStringConverter(IA5String);
3787
- var AsnGraphicStringConverter = createStringConverter(GraphicString);
3788
- var AsnVisibleStringConverter = createStringConverter(VisibleString);
3789
- var AsnGeneralStringConverter = createStringConverter(GeneralString);
3790
- var AsnCharacterStringConverter = createStringConverter(CharacterString);
3791
-
3792
- // ../../node_modules/@peculiar/asn1-schema/build/es2015/helper.js
3793
- function isConvertible(target) {
3794
- if (typeof target === "function" && target.prototype) {
3795
- if (target.prototype.toASN && target.prototype.fromASN) {
3796
- return true;
3797
- } else {
3798
- return isConvertible(target.prototype);
3799
- }
3800
- } else {
3801
- return !!(target && typeof target === "object" && "toASN" in target && "fromASN" in target);
3802
- }
3803
- }
3804
-
3805
- // ../../node_modules/@peculiar/asn1-schema/build/es2015/schema.js
3806
- var AsnSchemaStorage = class {
3807
- constructor() {
3808
- this.items = /* @__PURE__ */ new WeakMap();
3809
- }
3810
- has(target) {
3811
- return this.items.has(target);
3812
- }
3813
- get(target, checkSchema = false) {
3814
- const schema = this.items.get(target);
3815
- if (!schema) {
3816
- throw new Error(`Cannot get schema for '${target.prototype.constructor.name}' target`);
3817
- }
3818
- if (checkSchema && !schema.schema) {
3819
- throw new Error(`Schema '${target.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);
3820
- }
3821
- return schema;
3822
- }
3823
- cache(target) {
3824
- const schema = this.get(target);
3825
- if (!schema.schema) {
3826
- schema.schema = this.create(target, true);
3827
- }
3828
- }
3829
- createDefault(target) {
3830
- const schema = { type: AsnTypeTypes.Sequence, items: {} };
3831
- const parentSchema = this.findParentSchema(target);
3832
- if (parentSchema) {
3833
- Object.assign(schema, parentSchema);
3834
- schema.items = Object.assign({}, schema.items, parentSchema.items);
3835
- }
3836
- return schema;
3837
- }
3838
- create(target, useNames) {
3839
- const schema = this.items.get(target) || this.createDefault(target);
3840
- const asn1Value = [];
3841
- for (const key in schema.items) {
3842
- const item = schema.items[key];
3843
- const name = useNames ? key : "";
3844
- let asn1Item;
3845
- if (typeof item.type === "number") {
3846
- const Asn1TypeName = AsnPropTypes[item.type];
3847
- const Asn1Type = index_es_exports[Asn1TypeName];
3848
- if (!Asn1Type) {
3849
- throw new Error(`Cannot get ASN1 class by name '${Asn1TypeName}'`);
3850
- }
3851
- asn1Item = new Asn1Type({ name });
3852
- } else if (isConvertible(item.type)) {
3853
- const instance = new item.type();
3854
- asn1Item = instance.toSchema(name);
3855
- } else if (item.optional) {
3856
- const itemSchema = this.get(item.type);
3857
- if (itemSchema.type === AsnTypeTypes.Choice) {
3858
- asn1Item = new Any({ name });
3859
- } else {
3860
- asn1Item = this.create(item.type, false);
3861
- asn1Item.name = name;
3862
- }
3863
- } else {
3864
- asn1Item = new Any({ name });
3865
- }
3866
- const optional = !!item.optional || item.defaultValue !== void 0;
3867
- if (item.repeated) {
3868
- asn1Item.name = "";
3869
- const Container = item.repeated === "set" ? Set : Sequence;
3870
- asn1Item = new Container({
3871
- name: "",
3872
- value: [new Repeated({ name, value: asn1Item })]
3873
- });
3874
- }
3875
- if (item.context !== null && item.context !== void 0) {
3876
- if (item.implicit) {
3877
- if (typeof item.type === "number" || isConvertible(item.type)) {
3878
- const Container = item.repeated ? Constructed : Primitive;
3879
- asn1Value.push(new Container({ name, optional, idBlock: { tagClass: 3, tagNumber: item.context } }));
3880
- } else {
3881
- this.cache(item.type);
3882
- const isRepeated = !!item.repeated;
3883
- let value = !isRepeated ? this.get(item.type, true).schema : asn1Item;
3884
- value = "valueBlock" in value ? value.valueBlock.value : value.value;
3885
- asn1Value.push(new Constructed({
3886
- name: !isRepeated ? name : "",
3887
- optional,
3888
- idBlock: { tagClass: 3, tagNumber: item.context },
3889
- value
3890
- }));
3891
- }
3892
- } else {
3893
- asn1Value.push(new Constructed({
3894
- optional,
3895
- idBlock: { tagClass: 3, tagNumber: item.context },
3896
- value: [asn1Item]
3897
- }));
3898
- }
3899
- } else {
3900
- asn1Item.optional = optional;
3901
- asn1Value.push(asn1Item);
3902
- }
3903
- }
3904
- switch (schema.type) {
3905
- case AsnTypeTypes.Sequence:
3906
- return new Sequence({ value: asn1Value, name: "" });
3907
- case AsnTypeTypes.Set:
3908
- return new Set({ value: asn1Value, name: "" });
3909
- case AsnTypeTypes.Choice:
3910
- return new Choice({ value: asn1Value, name: "" });
3911
- default:
3912
- throw new Error(`Unsupported ASN1 type in use`);
3913
- }
3914
- }
3915
- set(target, schema) {
3916
- this.items.set(target, schema);
3917
- return this;
3918
- }
3919
- findParentSchema(target) {
3920
- const parent = Object.getPrototypeOf(target);
3921
- if (parent) {
3922
- const schema = this.items.get(parent);
3923
- return schema || this.findParentSchema(parent);
3924
- }
3925
- return null;
3926
- }
3927
- };
3928
-
3929
- // ../../node_modules/@peculiar/asn1-schema/build/es2015/storage.js
3930
- var schemaStorage = new AsnSchemaStorage();
3931
-
3932
- // source_nodejs/generate_private_key_filename.ts
3933
- async function generatePrivateKeyFile(privateKeyFilename, modulusLength) {
3934
- const keys = await generateKeyPair(modulusLength);
3935
- const privateKeyPem = await privateKeyToPEM(keys.privateKey);
3936
- await import_node_fs.default.promises.writeFile(privateKeyFilename, privateKeyPem.privPem, "utf-8");
3937
- privateKeyPem.privPem = "";
3938
- privateKeyPem.privDer = new ArrayBuffer(0);
3939
- }
3940
- async function generatePrivateKeyFileAlternate(privateKeyFilename, modulusLength) {
3941
- const { privateKey } = (0, import_node_crypto7.generateKeyPairSync)("rsa", {
3942
- modulusLength,
3943
- privateKeyEncoding: { type: "pkcs8", format: "pem" },
3944
- publicKeyEncoding: { type: "spki", format: "pem" }
3945
- });
3946
- await import_node_fs.default.promises.writeFile(privateKeyFilename, privateKey, "utf-8");
3947
- }
3948
-
3949
- // source_nodejs/read.ts
3950
- var import_node_assert8 = __toESM(require("assert"));
3951
- var import_node_crypto8 = require("crypto");
3952
- var import_node_fs2 = __toESM(require("fs"));
3953
- var import_node_path = __toESM(require("path"));
3954
- var import_sshpk = __toESM(require("sshpk"));
3955
- function _readPemFile(filename) {
3956
- (0, import_node_assert8.default)(typeof filename === "string");
3957
- return removeTrailingLF(import_node_fs2.default.readFileSync(filename, "utf-8"));
3958
- }
3959
- function _readPemOrDerFileAsDER(filename) {
3960
- if (filename.match(/.*\.der/)) {
3961
- return import_node_fs2.default.readFileSync(filename);
3962
- }
3963
- const raw_key = _readPemFile(filename);
3964
- return convertPEMtoDER(raw_key);
3965
- }
3966
- function readCertificate(filename) {
3967
- return _readPemOrDerFileAsDER(filename);
3968
- }
3969
- function readPublicKey(filename) {
3970
- if (filename.match(/.*\.der/)) {
3971
- const der = import_node_fs2.default.readFileSync(filename);
3972
- return (0, import_node_crypto8.createPublicKey)(der);
3973
- } else {
3974
- const raw_key = _readPemFile(filename);
3975
- return (0, import_node_crypto8.createPublicKey)(raw_key);
3976
- }
3977
- }
3978
- function myCreatePrivateKey(rawKey) {
3979
- if (!import_node_crypto8.createPrivateKey || process.env.NO_CREATE_PRIVATEKEY) {
3980
- if (Buffer.isBuffer(rawKey)) {
3981
- const pemKey = toPem(rawKey, "PRIVATE KEY");
3982
- (0, import_node_assert8.default)(["RSA PRIVATE KEY", "PRIVATE KEY"].indexOf(identifyPemType(pemKey)) >= 0);
3983
- return { hidden: pemKey };
3984
- }
3985
- return { hidden: ensureTrailingLF(rawKey) };
3986
- }
3987
- const backup = process.env.OPENSSL_CONF;
3988
- process.env.OPENSSL_CONF = "/dev/null";
3989
- const retValue = (0, import_node_crypto8.createPrivateKey)(rawKey);
3990
- process.env.OPENSSL_CONF = backup;
3991
- return { hidden: retValue };
3992
- }
3993
- function ensureTrailingLF(str) {
3994
- return str.match(/\n$/) ? str : `${str}
3995
- `;
3996
- }
3997
- function readPrivateKey(filename) {
3998
- if (filename.match(/.*\.der/)) {
3999
- const der = import_node_fs2.default.readFileSync(filename);
4000
- return myCreatePrivateKey(der);
4001
- } else {
4002
- const raw_key = _readPemFile(filename);
4003
- return myCreatePrivateKey(raw_key);
4004
- }
4005
- }
4006
- function readCertificatePEM(filename) {
4007
- return _readPemFile(filename);
4008
- }
4009
- function readPublicKeyPEM(filename) {
4010
- return _readPemFile(filename);
4011
- }
4012
- function readPrivateKeyPEM(filename) {
4013
- return _readPemFile(filename);
4014
- }
4015
- var _g_certificate_store = "";
4016
- function setCertificateStore(store) {
4017
- const old_store = _g_certificate_store;
4018
- _g_certificate_store = store;
4019
- return old_store;
4020
- }
4021
- function getCertificateStore() {
4022
- if (!_g_certificate_store) {
4023
- _g_certificate_store = import_node_path.default.join(__dirname, "../../certificates/");
4024
- }
4025
- return _g_certificate_store;
4026
- }
4027
- function readPrivateRsaKey(filename) {
4028
- if (!import_node_crypto8.createPrivateKey) {
4029
- throw new Error("createPrivateKey is not supported in this environment");
4030
- }
4031
- if (filename.substring(0, 1) !== "." && !import_node_fs2.default.existsSync(filename)) {
4032
- filename = import_node_path.default.join(getCertificateStore(), filename);
4033
- }
4034
- const content = import_node_fs2.default.readFileSync(filename, "utf8");
4035
- const sshKey = import_sshpk.default.parsePrivateKey(content, "auto");
4036
- const key = sshKey.toString("pkcs1");
4037
- const hidden = (0, import_node_crypto8.createPrivateKey)({ format: "pem", type: "pkcs1", key });
4038
- return { hidden };
4039
- }
4040
- function readPublicRsaKey(filename) {
4041
- if (filename.substring(0, 1) !== "." && !import_node_fs2.default.existsSync(filename)) {
4042
- filename = import_node_path.default.join(getCertificateStore(), filename);
4043
- }
4044
- const content = import_node_fs2.default.readFileSync(filename, "utf-8");
4045
- const sshKey = import_sshpk.default.parseKey(content, "ssh");
4046
- const key = sshKey.toString("pkcs1");
4047
- return (0, import_node_crypto8.createPublicKey)({ format: "pem", type: "pkcs1", key });
4048
- }
4049
-
4050
- // source_nodejs/read_certificate_revocation_list.ts
4051
- var import_node_fs3 = __toESM(require("fs"));
4052
- async function readCertificateRevocationList(filename) {
4053
- const crl = await import_node_fs3.default.promises.readFile(filename);
4054
- if (crl[0] === 48 && crl[1] === 130) {
4055
- return crl;
4056
- }
4057
- const raw_crl = crl.toString();
4058
- return convertPEMtoDER(raw_crl);
4059
- }
4060
-
4061
- // source_nodejs/read_certificate_signing_request.ts
4062
- var import_node_fs4 = __toESM(require("fs"));
4063
- async function readCertificateSigningRequest(filename) {
4064
- const csr = await import_node_fs4.default.promises.readFile(filename);
4065
- if (csr[0] === 48 && csr[1] === 130) {
4066
- return csr;
4067
- }
4068
- const raw_crl = csr.toString();
4069
- return convertPEMtoDER(raw_crl);
4070
- }
4071
- // Annotate the CommonJS export names for ESM import in node:
4072
- 0 && (module.exports = {
1
+ import {
2
+ generatePrivateKeyFile,
3
+ generatePrivateKeyFileAlternate,
4
+ getCertificateStore,
5
+ readCertificate,
6
+ readCertificateAsync,
7
+ readCertificatePEM,
8
+ readCertificatePEMAsync,
9
+ readCertificateRevocationList,
10
+ readCertificateSigningRequest,
11
+ readPrivateKey,
12
+ readPrivateKeyAsync,
13
+ readPrivateKeyPEM,
14
+ readPrivateKeyPEMAsync,
15
+ readPrivateRsaKey,
16
+ readPublicKey,
17
+ readPublicKeyAsync,
18
+ readPublicKeyPEM,
19
+ readPublicKeyPEMAsync,
20
+ readPublicRsaKey,
21
+ setCertificateStore
22
+ } from "../chunk-QGNXSXUU.js";
23
+ import "../chunk-KCVNMSLI.js";
24
+ export {
4073
25
  generatePrivateKeyFile,
4074
26
  generatePrivateKeyFileAlternate,
4075
27
  getCertificateStore,
4076
28
  readCertificate,
29
+ readCertificateAsync,
4077
30
  readCertificatePEM,
31
+ readCertificatePEMAsync,
4078
32
  readCertificateRevocationList,
4079
33
  readCertificateSigningRequest,
4080
34
  readPrivateKey,
35
+ readPrivateKeyAsync,
4081
36
  readPrivateKeyPEM,
37
+ readPrivateKeyPEMAsync,
4082
38
  readPrivateRsaKey,
4083
39
  readPublicKey,
40
+ readPublicKeyAsync,
4084
41
  readPublicKeyPEM,
42
+ readPublicKeyPEMAsync,
4085
43
  readPublicRsaKey,
4086
44
  setCertificateStore
4087
- });
4088
- /*! Bundled license information:
4089
-
4090
- pvtsutils/build/index.es.js:
4091
- (*!
4092
- * MIT License
4093
- *
4094
- * Copyright (c) 2017-2024 Peculiar Ventures, LLC
4095
- *
4096
- * Permission is hereby granted, free of charge, to any person obtaining a copy
4097
- * of this software and associated documentation files (the "Software"), to deal
4098
- * in the Software without restriction, including without limitation the rights
4099
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4100
- * copies of the Software, and to permit persons to whom the Software is
4101
- * furnished to do so, subject to the following conditions:
4102
- *
4103
- * The above copyright notice and this permission notice shall be included in all
4104
- * copies or substantial portions of the Software.
4105
- *
4106
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4107
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4108
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4109
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4110
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4111
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
4112
- * SOFTWARE.
4113
- *
4114
- *)
4115
-
4116
- pvutils/build/utils.es.js:
4117
- (*!
4118
- Copyright (c) Peculiar Ventures, LLC
4119
- *)
4120
-
4121
- asn1js/build/index.es.js:
4122
- (*!
4123
- * Copyright (c) 2014, GMO GlobalSign
4124
- * Copyright (c) 2015-2022, Peculiar Ventures
4125
- * All rights reserved.
4126
- *
4127
- * Author 2014-2019, Yury Strozhevsky
4128
- *
4129
- * Redistribution and use in source and binary forms, with or without modification,
4130
- * are permitted provided that the following conditions are met:
4131
- *
4132
- * * Redistributions of source code must retain the above copyright notice, this
4133
- * list of conditions and the following disclaimer.
4134
- *
4135
- * * Redistributions in binary form must reproduce the above copyright notice, this
4136
- * list of conditions and the following disclaimer in the documentation and/or
4137
- * other materials provided with the distribution.
4138
- *
4139
- * * Neither the name of the copyright holder nor the names of its
4140
- * contributors may be used to endorse or promote products derived from
4141
- * this software without specific prior written permission.
4142
- *
4143
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
4144
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
4145
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
4146
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
4147
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
4148
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
4149
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
4150
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
4151
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
4152
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4153
- *
4154
- *)
4155
- */
45
+ };
4156
46
  //# sourceMappingURL=index.js.map