agentplugged 1.0.6 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -4
- package/dist/agent-commands.js +6446 -499
- package/dist/forge-follow.js +3 -3
- package/dist/{webauthn.js → hash.js} +3463 -564
- package/dist/helpers.js +723 -294
- package/dist/launcher.js +1 -1
- package/dist/main.js +336 -40
- package/dist/method/models.yaml +0 -11
- package/dist/method/skills/workshop/references/create.md +1 -1
- package/dist/product-root.js +88 -116
- package/dist/rolldown-runtime.js +1 -1
- package/dist/webauthn-verify.js +112 -1
- package/dist/webauthn-verify2.js +1 -107
- package/package.json +10 -10
package/dist/helpers.js
CHANGED
|
@@ -2113,7 +2113,7 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
2113
2113
|
exports.utilToBase = utilToBase;
|
|
2114
2114
|
}));
|
|
2115
2115
|
//#endregion
|
|
2116
|
-
//#region ../../node_modules/.pnpm/asn1js@3.0
|
|
2116
|
+
//#region ../../node_modules/.pnpm/asn1js@3.1.0/node_modules/asn1js/build/index.js
|
|
2117
2117
|
/*!
|
|
2118
2118
|
* Copyright (c) 2014, GMO GlobalSign
|
|
2119
2119
|
* Copyright (c) 2015-2022, Peculiar Ventures
|
|
@@ -2181,7 +2181,7 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
2181
2181
|
const retView = new Uint8Array(outputLength);
|
|
2182
2182
|
for (let i = 0; i < buffers.length; i++) {
|
|
2183
2183
|
const buffer = buffers[i];
|
|
2184
|
-
retView.set(new Uint8Array(buffer), prevLength);
|
|
2184
|
+
retView.set(buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer), prevLength);
|
|
2185
2185
|
prevLength += buffer.byteLength;
|
|
2186
2186
|
}
|
|
2187
2187
|
return retView.buffer;
|
|
@@ -2214,14 +2214,14 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
2214
2214
|
this.items = [];
|
|
2215
2215
|
}
|
|
2216
2216
|
write(buf) {
|
|
2217
|
-
this.items.push(buf);
|
|
2217
|
+
this.items.push(buf instanceof ArrayBuffer ? buf : concat([buf]));
|
|
2218
2218
|
}
|
|
2219
2219
|
final() {
|
|
2220
2220
|
return concat(this.items);
|
|
2221
2221
|
}
|
|
2222
2222
|
};
|
|
2223
|
-
const
|
|
2224
|
-
const
|
|
2223
|
+
const ORIGINAL_VIEW_WRITER_WRITE = ViewWriter.prototype.write;
|
|
2224
|
+
const ORIGINAL_VIEW_WRITER_FINAL = ViewWriter.prototype.final;
|
|
2225
2225
|
const NAME = "name";
|
|
2226
2226
|
const VALUE_HEX_VIEW = "valueHexView";
|
|
2227
2227
|
const IS_HEX_ONLY = "isHexOnly";
|
|
@@ -2271,7 +2271,8 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
2271
2271
|
return EMPTY_BUFFER;
|
|
2272
2272
|
}
|
|
2273
2273
|
if (sizeOnly) return new ArrayBuffer(this.valueHexView.byteLength);
|
|
2274
|
-
|
|
2274
|
+
if (this.valueHexView.buffer instanceof ArrayBuffer && this.valueHexView.byteLength === this.valueHexView.buffer.byteLength) return this.valueHexView.buffer;
|
|
2275
|
+
return pvtsutils__namespace.BufferSourceConverter.toArrayBuffer(this.valueHexView);
|
|
2275
2276
|
}
|
|
2276
2277
|
toJSON() {
|
|
2277
2278
|
return {
|
|
@@ -2389,12 +2390,15 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
2389
2390
|
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
2390
2391
|
const inputView = pvtsutils__namespace.BufferSourceConverter.toUint8Array(inputBuffer);
|
|
2391
2392
|
if (!checkBufferParams(this, inputView, inputOffset, inputLength)) return -1;
|
|
2392
|
-
const
|
|
2393
|
-
|
|
2393
|
+
const fastArgs = Number.isInteger(inputOffset) && Number.isInteger(inputLength);
|
|
2394
|
+
const intBuffer = fastArgs ? inputView : inputView.subarray(inputOffset, inputOffset + inputLength);
|
|
2395
|
+
const baseIndex = fastArgs ? inputOffset : 0;
|
|
2396
|
+
const bufferLength = fastArgs ? inputLength : intBuffer.length;
|
|
2397
|
+
if (bufferLength === 0) {
|
|
2394
2398
|
this.error = "Zero buffer length";
|
|
2395
2399
|
return -1;
|
|
2396
2400
|
}
|
|
2397
|
-
switch (intBuffer[
|
|
2401
|
+
switch (intBuffer[baseIndex] & 192) {
|
|
2398
2402
|
case 0:
|
|
2399
2403
|
this.tagClass = 1;
|
|
2400
2404
|
break;
|
|
@@ -2411,9 +2415,9 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
2411
2415
|
this.error = "Unknown tag class";
|
|
2412
2416
|
return -1;
|
|
2413
2417
|
}
|
|
2414
|
-
this.isConstructed = (intBuffer[
|
|
2418
|
+
this.isConstructed = (intBuffer[baseIndex] & 32) === 32;
|
|
2415
2419
|
this.isHexOnly = false;
|
|
2416
|
-
const tagNumberMask = intBuffer[
|
|
2420
|
+
const tagNumberMask = intBuffer[baseIndex] & 31;
|
|
2417
2421
|
if (tagNumberMask !== 31) {
|
|
2418
2422
|
this.tagNumber = tagNumberMask;
|
|
2419
2423
|
this.blockLength = 1;
|
|
@@ -2421,16 +2425,16 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
2421
2425
|
let count = 0;
|
|
2422
2426
|
while (true) {
|
|
2423
2427
|
const tagByteIndex = count + 1;
|
|
2424
|
-
if (tagByteIndex >=
|
|
2428
|
+
if (tagByteIndex >= bufferLength) {
|
|
2425
2429
|
this.error = "End of input reached before message was fully decoded";
|
|
2426
2430
|
return -1;
|
|
2427
2431
|
}
|
|
2428
2432
|
count++;
|
|
2429
|
-
if ((intBuffer[tagByteIndex] & 128) === 0) break;
|
|
2433
|
+
if ((intBuffer[baseIndex + tagByteIndex] & 128) === 0) break;
|
|
2430
2434
|
}
|
|
2431
2435
|
this.blockLength = count + 1;
|
|
2432
2436
|
const intTagNumberBuffer = this.valueHexView = new Uint8Array(count);
|
|
2433
|
-
for (let i = 0; i < count; i++) intTagNumberBuffer[i] = intBuffer[i + 1] & 127;
|
|
2437
|
+
for (let i = 0; i < count; i++) intTagNumberBuffer[i] = intBuffer[baseIndex + i + 1] & 127;
|
|
2434
2438
|
if (this.blockLength <= 9) this.tagNumber = pvutils__namespace.utilFromBase(intTagNumberBuffer, 7);
|
|
2435
2439
|
else {
|
|
2436
2440
|
this.isHexOnly = true;
|
|
@@ -2466,6 +2470,8 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
2466
2470
|
}
|
|
2467
2471
|
};
|
|
2468
2472
|
LocalIdentificationBlock.NAME = "identificationBlock";
|
|
2473
|
+
const ORIGINAL_LOCAL_IDENTIFICATION_TO_BER = LocalIdentificationBlock.prototype.toBER;
|
|
2474
|
+
const ORIGINAL_LOCAL_IDENTIFICATION_FROM_BER = LocalIdentificationBlock.prototype.fromBER;
|
|
2469
2475
|
var LocalLengthBlock = class extends LocalBaseBlock {
|
|
2470
2476
|
constructor({ lenBlock = {} } = {}) {
|
|
2471
2477
|
var _a, _b, _c;
|
|
@@ -2477,32 +2483,35 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
2477
2483
|
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
2478
2484
|
const view = pvtsutils__namespace.BufferSourceConverter.toUint8Array(inputBuffer);
|
|
2479
2485
|
if (!checkBufferParams(this, view, inputOffset, inputLength)) return -1;
|
|
2480
|
-
const
|
|
2481
|
-
|
|
2486
|
+
const fastArgs = Number.isInteger(inputOffset) && Number.isInteger(inputLength);
|
|
2487
|
+
const intBuffer = fastArgs ? view : view.subarray(inputOffset, inputOffset + inputLength);
|
|
2488
|
+
const baseIndex = fastArgs ? inputOffset : 0;
|
|
2489
|
+
const bufferLength = fastArgs ? inputLength : intBuffer.length;
|
|
2490
|
+
if (bufferLength === 0) {
|
|
2482
2491
|
this.error = "Zero buffer length";
|
|
2483
2492
|
return -1;
|
|
2484
2493
|
}
|
|
2485
|
-
if (intBuffer[
|
|
2494
|
+
if (intBuffer[baseIndex] === 255) {
|
|
2486
2495
|
this.error = "Length block 0xFF is reserved by standard";
|
|
2487
2496
|
return -1;
|
|
2488
2497
|
}
|
|
2489
|
-
this.isIndefiniteForm = intBuffer[
|
|
2498
|
+
this.isIndefiniteForm = intBuffer[baseIndex] === 128;
|
|
2490
2499
|
if (this.isIndefiniteForm) {
|
|
2491
2500
|
this.blockLength = 1;
|
|
2492
2501
|
return inputOffset + this.blockLength;
|
|
2493
2502
|
}
|
|
2494
|
-
this.longFormUsed = !!(intBuffer[
|
|
2503
|
+
this.longFormUsed = !!(intBuffer[baseIndex] & 128);
|
|
2495
2504
|
if (this.longFormUsed === false) {
|
|
2496
|
-
this.length = intBuffer[
|
|
2505
|
+
this.length = intBuffer[baseIndex];
|
|
2497
2506
|
this.blockLength = 1;
|
|
2498
2507
|
return inputOffset + this.blockLength;
|
|
2499
2508
|
}
|
|
2500
|
-
const count = intBuffer[
|
|
2509
|
+
const count = intBuffer[baseIndex] & 127;
|
|
2501
2510
|
if (count > 8) {
|
|
2502
2511
|
this.error = "Too big integer";
|
|
2503
2512
|
return -1;
|
|
2504
2513
|
}
|
|
2505
|
-
if (count + 1 >
|
|
2514
|
+
if (count + 1 > bufferLength) {
|
|
2506
2515
|
this.error = "End of input reached before message was fully decoded";
|
|
2507
2516
|
return -1;
|
|
2508
2517
|
}
|
|
@@ -2557,7 +2566,328 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
2557
2566
|
}
|
|
2558
2567
|
};
|
|
2559
2568
|
LocalLengthBlock.NAME = "lengthBlock";
|
|
2569
|
+
const ORIGINAL_LOCAL_LENGTH_TO_BER = LocalLengthBlock.prototype.toBER;
|
|
2570
|
+
const ORIGINAL_LOCAL_LENGTH_FROM_BER = LocalLengthBlock.prototype.fromBER;
|
|
2560
2571
|
const typeStore = {};
|
|
2572
|
+
var _a$y;
|
|
2573
|
+
var _b;
|
|
2574
|
+
var _c;
|
|
2575
|
+
const originalUint8ArraySliceInfo = findMethod(Uint8Array.prototype, "slice");
|
|
2576
|
+
const originalUint8ArrayConstructor = (_a$y = Object.getOwnPropertyDescriptor(Uint8Array.prototype, "constructor")) === null || _a$y === void 0 ? void 0 : _a$y.value;
|
|
2577
|
+
const originalArrayIterator = (_b = Object.getOwnPropertyDescriptor(Array.prototype, Symbol.iterator)) === null || _b === void 0 ? void 0 : _b.value;
|
|
2578
|
+
const intrinsicTypedArrayByteLength = (_c = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype), "byteLength")) === null || _c === void 0 ? void 0 : _c.get;
|
|
2579
|
+
const BUILTIN_DISPATCH_PAYLOAD_THRESHOLD = 16384;
|
|
2580
|
+
const BUILTIN_DISPATCH_MAX_DEPTH = 64;
|
|
2581
|
+
let builtinRegistry;
|
|
2582
|
+
function registerBuiltinEncoder(builtinConstructors, internals) {
|
|
2583
|
+
const nextInternals = internals || builtinRegistry;
|
|
2584
|
+
if (!nextInternals) {
|
|
2585
|
+
builtinRegistry = void 0;
|
|
2586
|
+
return;
|
|
2587
|
+
}
|
|
2588
|
+
builtinRegistry = {
|
|
2589
|
+
...nextInternals,
|
|
2590
|
+
...builtinConstructors
|
|
2591
|
+
};
|
|
2592
|
+
}
|
|
2593
|
+
function dataProperty(object, name) {
|
|
2594
|
+
const descriptor = Object.getOwnPropertyDescriptor(object, name);
|
|
2595
|
+
if (!descriptor || !("value" in descriptor)) return void 0;
|
|
2596
|
+
return descriptor.value;
|
|
2597
|
+
}
|
|
2598
|
+
function intrinsicPayloadByteLength(value) {
|
|
2599
|
+
if (!intrinsicTypedArrayByteLength || !value || typeof value !== "object") return void 0;
|
|
2600
|
+
try {
|
|
2601
|
+
const byteLength = intrinsicTypedArrayByteLength.call(value);
|
|
2602
|
+
return typeof byteLength === "number" ? byteLength : void 0;
|
|
2603
|
+
} catch {
|
|
2604
|
+
return;
|
|
2605
|
+
}
|
|
2606
|
+
}
|
|
2607
|
+
function largePayloadOrChain(block, depth) {
|
|
2608
|
+
if (depth > BUILTIN_DISPATCH_MAX_DEPTH || !block || typeof block !== "object") return false;
|
|
2609
|
+
const valueBlockDescriptor = Object.getOwnPropertyDescriptor(block, "valueBlock");
|
|
2610
|
+
if (!valueBlockDescriptor || !("value" in valueBlockDescriptor)) return false;
|
|
2611
|
+
const valueBlock = valueBlockDescriptor.value;
|
|
2612
|
+
if (!valueBlock || typeof valueBlock !== "object") return false;
|
|
2613
|
+
const payloadDescriptor = Object.getOwnPropertyDescriptor(valueBlock, "valueHexView");
|
|
2614
|
+
if (payloadDescriptor) {
|
|
2615
|
+
if (!("value" in payloadDescriptor)) return false;
|
|
2616
|
+
const byteLength = intrinsicPayloadByteLength(payloadDescriptor.value);
|
|
2617
|
+
return byteLength !== void 0 && byteLength >= BUILTIN_DISPATCH_PAYLOAD_THRESHOLD;
|
|
2618
|
+
}
|
|
2619
|
+
const valuesDescriptor = Object.getOwnPropertyDescriptor(valueBlock, "value");
|
|
2620
|
+
if (!valuesDescriptor || !("value" in valuesDescriptor) || !Array.isArray(valuesDescriptor.value)) return false;
|
|
2621
|
+
const values = valuesDescriptor.value;
|
|
2622
|
+
const lengthDescriptor = Object.getOwnPropertyDescriptor(values, "length");
|
|
2623
|
+
if (!lengthDescriptor || !("value" in lengthDescriptor) || lengthDescriptor.value !== 1) return false;
|
|
2624
|
+
const indexDescriptor = Object.getOwnPropertyDescriptor(values, "0");
|
|
2625
|
+
if (!indexDescriptor || !("value" in indexDescriptor)) return false;
|
|
2626
|
+
return largePayloadOrChain(indexDescriptor.value, depth + 1);
|
|
2627
|
+
}
|
|
2628
|
+
function shouldUseBuiltinEncoder(block) {
|
|
2629
|
+
try {
|
|
2630
|
+
return largePayloadOrChain(block, 0);
|
|
2631
|
+
} catch {
|
|
2632
|
+
return false;
|
|
2633
|
+
}
|
|
2634
|
+
}
|
|
2635
|
+
function sameDataMethod(current, original) {
|
|
2636
|
+
return !!current && "value" in current && current.value === original && current.writable === true && current.enumerable === false && current.configurable === true;
|
|
2637
|
+
}
|
|
2638
|
+
function writerMethodsStable(registry) {
|
|
2639
|
+
return sameDataMethod(Object.getOwnPropertyDescriptor(registry.ViewWriter.prototype, "write"), registry.originalWriterWrite) && sameDataMethod(Object.getOwnPropertyDescriptor(registry.ViewWriter.prototype, "final"), registry.originalWriterFinal);
|
|
2640
|
+
}
|
|
2641
|
+
function findMethod(prototype, name) {
|
|
2642
|
+
let current = prototype;
|
|
2643
|
+
while (current) {
|
|
2644
|
+
const descriptor = Object.getOwnPropertyDescriptor(current, name);
|
|
2645
|
+
if (descriptor) {
|
|
2646
|
+
if ("value" in descriptor && typeof descriptor.value === "function") return {
|
|
2647
|
+
declaringPrototype: current,
|
|
2648
|
+
method: descriptor.value
|
|
2649
|
+
};
|
|
2650
|
+
return;
|
|
2651
|
+
}
|
|
2652
|
+
current = Object.getPrototypeOf(current);
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2655
|
+
function stableInheritedMethod(prototype, name, original) {
|
|
2656
|
+
if (!original) return false;
|
|
2657
|
+
let current = prototype;
|
|
2658
|
+
while (current) {
|
|
2659
|
+
const descriptor = Object.getOwnPropertyDescriptor(current, name);
|
|
2660
|
+
if (current === original.declaringPrototype) return !!descriptor && "value" in descriptor && descriptor.value === original.method;
|
|
2661
|
+
if (descriptor) return false;
|
|
2662
|
+
current = Object.getPrototypeOf(current);
|
|
2663
|
+
}
|
|
2664
|
+
return false;
|
|
2665
|
+
}
|
|
2666
|
+
function prototypeMethod(object, prototype, name, expected) {
|
|
2667
|
+
if (Object.prototype.hasOwnProperty.call(object, name)) return false;
|
|
2668
|
+
if (Object.getPrototypeOf(object) !== prototype) return false;
|
|
2669
|
+
const descriptor = Object.getOwnPropertyDescriptor(prototype, name);
|
|
2670
|
+
return !!descriptor && "value" in descriptor && descriptor.value === expected;
|
|
2671
|
+
}
|
|
2672
|
+
function inheritedMethod(object, name, expected, primitiveConstructor) {
|
|
2673
|
+
if (Object.prototype.hasOwnProperty.call(object, name)) return false;
|
|
2674
|
+
const prototype = Object.getPrototypeOf(object);
|
|
2675
|
+
const originalPrimitiveValuePrototype = Object.getPrototypeOf(primitiveConstructor.prototype);
|
|
2676
|
+
if (prototype !== primitiveConstructor.prototype || Object.getPrototypeOf(prototype) !== originalPrimitiveValuePrototype) return false;
|
|
2677
|
+
if (prototype && Object.getOwnPropertyDescriptor(prototype, name)) return false;
|
|
2678
|
+
const parentDescriptor = Object.getOwnPropertyDescriptor(originalPrimitiveValuePrototype, name);
|
|
2679
|
+
return !!parentDescriptor && "value" in parentDescriptor && parentDescriptor.value === expected;
|
|
2680
|
+
}
|
|
2681
|
+
function plainPayload(value, allowEmpty = false) {
|
|
2682
|
+
if (!(value instanceof Uint8Array) || Object.getPrototypeOf(value) !== Uint8Array.prototype) return void 0;
|
|
2683
|
+
for (const name of [
|
|
2684
|
+
"buffer",
|
|
2685
|
+
"byteOffset",
|
|
2686
|
+
"byteLength",
|
|
2687
|
+
"length",
|
|
2688
|
+
"slice",
|
|
2689
|
+
"constructor"
|
|
2690
|
+
]) if (Object.prototype.hasOwnProperty.call(value, name)) return void 0;
|
|
2691
|
+
const constructorDescriptor = Object.getOwnPropertyDescriptor(Uint8Array.prototype, "constructor");
|
|
2692
|
+
if (!constructorDescriptor || !("value" in constructorDescriptor) || constructorDescriptor.value !== originalUint8ArrayConstructor) return void 0;
|
|
2693
|
+
if (!stableInheritedMethod(Uint8Array.prototype, "slice", originalUint8ArraySliceInfo)) return void 0;
|
|
2694
|
+
try {
|
|
2695
|
+
const buffer = value.buffer;
|
|
2696
|
+
if (!(buffer instanceof ArrayBuffer) || Object.getPrototypeOf(buffer) !== ArrayBuffer.prototype) return void 0;
|
|
2697
|
+
if (Object.prototype.hasOwnProperty.call(buffer, "byteLength")) return void 0;
|
|
2698
|
+
if (value.byteLength !== value.length || !allowEmpty && value.byteLength === 0) return void 0;
|
|
2699
|
+
if (value.byteOffset < 0 || value.byteOffset + value.byteLength > buffer.byteLength) return void 0;
|
|
2700
|
+
} catch {
|
|
2701
|
+
return;
|
|
2702
|
+
}
|
|
2703
|
+
return value;
|
|
2704
|
+
}
|
|
2705
|
+
function validIdBlock(block, constructed, registry) {
|
|
2706
|
+
if (Object.getPrototypeOf(block) !== registry.LocalIdentificationBlock.prototype) return false;
|
|
2707
|
+
if (!prototypeMethod(block, registry.LocalIdentificationBlock.prototype, "toBER", registry.originalIdentificationToBER)) return false;
|
|
2708
|
+
const tagClass = dataProperty(block, "tagClass");
|
|
2709
|
+
const tagNumber = dataProperty(block, "tagNumber");
|
|
2710
|
+
const isConstructed = dataProperty(block, "isConstructed");
|
|
2711
|
+
const isHexOnly = dataProperty(block, "isHexOnly");
|
|
2712
|
+
const valueHexView = dataProperty(block, "valueHexView");
|
|
2713
|
+
if (typeof tagClass !== "number" || !Number.isInteger(tagClass) || tagClass < 1 || tagClass > 4) return false;
|
|
2714
|
+
if (typeof tagNumber !== "number" || !Number.isInteger(tagNumber) || tagNumber < 0) return false;
|
|
2715
|
+
if (isConstructed !== constructed || typeof isHexOnly !== "boolean") return false;
|
|
2716
|
+
if (isHexOnly) return !!plainPayload(valueHexView);
|
|
2717
|
+
return Number.isSafeInteger(tagNumber);
|
|
2718
|
+
}
|
|
2719
|
+
function validLengthBlock(block, allowIndefinite, registry) {
|
|
2720
|
+
if (Object.getPrototypeOf(block) !== registry.LocalLengthBlock.prototype) return false;
|
|
2721
|
+
if (!prototypeMethod(block, registry.LocalLengthBlock.prototype, "toBER", registry.originalLengthToBER)) return false;
|
|
2722
|
+
const indefinite = dataProperty(block, "isIndefiniteForm");
|
|
2723
|
+
const longForm = dataProperty(block, "longFormUsed");
|
|
2724
|
+
const lengthDescriptor = Object.getOwnPropertyDescriptor(block, "length");
|
|
2725
|
+
const length = lengthDescriptor && "value" in lengthDescriptor ? lengthDescriptor.value : void 0;
|
|
2726
|
+
const longFormDescriptor = Object.getOwnPropertyDescriptor(block, "longFormUsed");
|
|
2727
|
+
return typeof indefinite === "boolean" && (indefinite === false || allowIndefinite) && typeof longForm === "boolean" && !!longFormDescriptor && "value" in longFormDescriptor && longFormDescriptor.writable === true && !!lengthDescriptor && "value" in lengthDescriptor && lengthDescriptor.writable === true && typeof length === "number" && Number.isSafeInteger(length) && length >= 0;
|
|
2728
|
+
}
|
|
2729
|
+
function validBaseBlock(block, isConstructed, registry) {
|
|
2730
|
+
const idBlock = dataProperty(block, "idBlock");
|
|
2731
|
+
const lenBlock = dataProperty(block, "lenBlock");
|
|
2732
|
+
return !!idBlock && !!lenBlock && validIdBlock(idBlock, isConstructed, registry) && validLengthBlock(lenBlock, isConstructed, registry);
|
|
2733
|
+
}
|
|
2734
|
+
function constructedChild(block, registry) {
|
|
2735
|
+
const valueBlock = dataProperty(block, "valueBlock");
|
|
2736
|
+
if (!valueBlock || Object.getPrototypeOf(valueBlock) !== registry.LocalConstructedValueBlock.prototype) return void 0;
|
|
2737
|
+
if (!prototypeMethod(valueBlock, registry.LocalConstructedValueBlock.prototype, "toBER", registry.originalConstructedToBER)) return void 0;
|
|
2738
|
+
const values = dataProperty(valueBlock, "value");
|
|
2739
|
+
if (!Array.isArray(values) || Object.getPrototypeOf(values) !== Array.prototype) return void 0;
|
|
2740
|
+
const lengthDescriptor = Object.getOwnPropertyDescriptor(values, "length");
|
|
2741
|
+
if (!lengthDescriptor || !("value" in lengthDescriptor) || lengthDescriptor.value !== 1) return void 0;
|
|
2742
|
+
if (Object.prototype.hasOwnProperty.call(values, Symbol.iterator)) return void 0;
|
|
2743
|
+
const iteratorDescriptor = Object.getOwnPropertyDescriptor(Array.prototype, Symbol.iterator);
|
|
2744
|
+
if (!iteratorDescriptor || !("value" in iteratorDescriptor) || iteratorDescriptor.value !== originalArrayIterator) return void 0;
|
|
2745
|
+
const indexDescriptor = Object.getOwnPropertyDescriptor(values, "0");
|
|
2746
|
+
if (!indexDescriptor || !("value" in indexDescriptor)) return void 0;
|
|
2747
|
+
if (Object.getOwnPropertyNames(values).length !== 2) return void 0;
|
|
2748
|
+
return indexDescriptor.value;
|
|
2749
|
+
}
|
|
2750
|
+
function bitPayload(block, registry) {
|
|
2751
|
+
const valueBlock = dataProperty(block, "valueBlock");
|
|
2752
|
+
if (!valueBlock || Object.getPrototypeOf(valueBlock) !== registry.LocalBitStringValueBlock.prototype) return void 0;
|
|
2753
|
+
if (!prototypeMethod(valueBlock, registry.LocalBitStringValueBlock.prototype, "toBER", registry.originalBitStringToBER)) return void 0;
|
|
2754
|
+
if (dataProperty(valueBlock, "isConstructed") !== false) return void 0;
|
|
2755
|
+
const unusedBits = dataProperty(valueBlock, "unusedBits");
|
|
2756
|
+
if (typeof unusedBits !== "number" || !Number.isInteger(unusedBits) || unusedBits < 0 || unusedBits > 7) return void 0;
|
|
2757
|
+
const payload = plainPayload(dataProperty(valueBlock, "valueHexView"), true);
|
|
2758
|
+
if (!payload) return void 0;
|
|
2759
|
+
return {
|
|
2760
|
+
payload,
|
|
2761
|
+
prefix: Uint8Array.of(payload.byteLength ? unusedBits : 0)
|
|
2762
|
+
};
|
|
2763
|
+
}
|
|
2764
|
+
function primitivePayload(block, kind, registry) {
|
|
2765
|
+
const valueBlock = dataProperty(block, "valueBlock");
|
|
2766
|
+
if (!valueBlock) return void 0;
|
|
2767
|
+
if (kind === "integer") {
|
|
2768
|
+
if (Object.getPrototypeOf(valueBlock) !== registry.LocalIntegerValueBlock.prototype) return void 0;
|
|
2769
|
+
if (!prototypeMethod(valueBlock, registry.LocalIntegerValueBlock.prototype, "toBER", registry.originalIntegerToBER)) return void 0;
|
|
2770
|
+
} else if (kind === "octet") {
|
|
2771
|
+
if (Object.getPrototypeOf(valueBlock) !== registry.LocalOctetStringValueBlock.prototype) return void 0;
|
|
2772
|
+
if (!prototypeMethod(valueBlock, registry.LocalOctetStringValueBlock.prototype, "toBER", registry.originalOctetStringToBER)) return void 0;
|
|
2773
|
+
if (dataProperty(valueBlock, "isConstructed") !== false) return void 0;
|
|
2774
|
+
} else {
|
|
2775
|
+
if (Object.getPrototypeOf(valueBlock) !== registry.LocalPrimitiveValueBlock.prototype) return void 0;
|
|
2776
|
+
if (!inheritedMethod(valueBlock, "toBER", registry.originalPrimitiveToBER, registry.LocalPrimitiveValueBlock)) return void 0;
|
|
2777
|
+
}
|
|
2778
|
+
if (kind === "primitive" && dataProperty(valueBlock, "isHexOnly") !== true) return void 0;
|
|
2779
|
+
if (typeof dataProperty(valueBlock, "isHexOnly") !== "boolean") return void 0;
|
|
2780
|
+
return plainPayload(dataProperty(valueBlock, "valueHexView"));
|
|
2781
|
+
}
|
|
2782
|
+
function validOuterMethod(block, registry) {
|
|
2783
|
+
if (Object.prototype.hasOwnProperty.call(block, "toBER")) return false;
|
|
2784
|
+
let prototype = block;
|
|
2785
|
+
while (prototype) {
|
|
2786
|
+
const descriptor = Object.getOwnPropertyDescriptor(prototype, "toBER");
|
|
2787
|
+
if (descriptor) return "value" in descriptor && descriptor.value === registry.originalBaseBlockToBER;
|
|
2788
|
+
prototype = Object.getPrototypeOf(prototype);
|
|
2789
|
+
}
|
|
2790
|
+
return false;
|
|
2791
|
+
}
|
|
2792
|
+
function isPrimitive(block, type, registry) {
|
|
2793
|
+
const constructor = registry[type];
|
|
2794
|
+
return !!constructor && Object.getPrototypeOf(block) === constructor.prototype;
|
|
2795
|
+
}
|
|
2796
|
+
function isConstructed(block, registry) {
|
|
2797
|
+
return Object.getPrototypeOf(block) === registry.Sequence.prototype || Object.getPrototypeOf(block) === registry.Set.prototype || Object.getPrototypeOf(block) === registry.Constructed.prototype;
|
|
2798
|
+
}
|
|
2799
|
+
function inspectNode(block, depth, registry) {
|
|
2800
|
+
if (depth > BUILTIN_DISPATCH_MAX_DEPTH || !block || typeof block !== "object") return void 0;
|
|
2801
|
+
try {
|
|
2802
|
+
if (!validOuterMethod(block, registry)) return void 0;
|
|
2803
|
+
const primitiveKind = isPrimitive(block, "BitString", registry) ? "bit" : isPrimitive(block, "Integer", registry) ? "integer" : isPrimitive(block, "OctetString", registry) ? "octet" : isPrimitive(block, "Primitive", registry) ? "primitive" : void 0;
|
|
2804
|
+
const constructed = primitiveKind === void 0 && isConstructed(block, registry);
|
|
2805
|
+
if (!primitiveKind && !constructed) return void 0;
|
|
2806
|
+
if (!validBaseBlock(block, constructed, registry)) return void 0;
|
|
2807
|
+
const idBlock = dataProperty(block, "idBlock");
|
|
2808
|
+
const lenBlock = dataProperty(block, "lenBlock");
|
|
2809
|
+
if (!idBlock || !lenBlock) return void 0;
|
|
2810
|
+
if (primitiveKind) {
|
|
2811
|
+
const bit = primitiveKind === "bit" ? bitPayload(block, registry) : void 0;
|
|
2812
|
+
const payload = primitiveKind === "bit" ? bit === null || bit === void 0 ? void 0 : bit.payload : primitivePayload(block, primitiveKind, registry);
|
|
2813
|
+
return payload ? {
|
|
2814
|
+
block,
|
|
2815
|
+
kind: primitiveKind,
|
|
2816
|
+
idBlock,
|
|
2817
|
+
lenBlock,
|
|
2818
|
+
indefinite: false,
|
|
2819
|
+
payload,
|
|
2820
|
+
prefix: bit === null || bit === void 0 ? void 0 : bit.prefix
|
|
2821
|
+
} : void 0;
|
|
2822
|
+
}
|
|
2823
|
+
const child = constructedChild(block, registry);
|
|
2824
|
+
const validatedChild = child && inspectNode(child, depth + 1, registry);
|
|
2825
|
+
const indefinite = dataProperty(lenBlock, "isIndefiniteForm");
|
|
2826
|
+
return validatedChild ? {
|
|
2827
|
+
block,
|
|
2828
|
+
kind: "constructed",
|
|
2829
|
+
idBlock,
|
|
2830
|
+
lenBlock,
|
|
2831
|
+
indefinite: indefinite === true,
|
|
2832
|
+
child: validatedChild
|
|
2833
|
+
} : void 0;
|
|
2834
|
+
} catch {
|
|
2835
|
+
return;
|
|
2836
|
+
}
|
|
2837
|
+
}
|
|
2838
|
+
function buildNode(node, sizeOnly, registry) {
|
|
2839
|
+
var _a, _b;
|
|
2840
|
+
const id = Reflect.apply(registry.originalIdentificationToBER, node.idBlock, [sizeOnly]);
|
|
2841
|
+
if (!(id instanceof ArrayBuffer) || id.byteLength === 0) throw TypeError("Built-in identifier encoding failed");
|
|
2842
|
+
let payload;
|
|
2843
|
+
if (node.kind === "constructed") payload = buildNode(node.child, sizeOnly, registry);
|
|
2844
|
+
else payload = node.payload;
|
|
2845
|
+
const length = (payload instanceof Uint8Array ? payload.byteLength : payload.total) + ((_b = (_a = node.prefix) === null || _a === void 0 ? void 0 : _a.byteLength) !== null && _b !== void 0 ? _b : 0);
|
|
2846
|
+
let len;
|
|
2847
|
+
if (node.indefinite) len = Uint8Array.of(128).buffer;
|
|
2848
|
+
else {
|
|
2849
|
+
node.lenBlock.length = length;
|
|
2850
|
+
len = Reflect.apply(registry.originalLengthToBER, node.lenBlock, [sizeOnly]);
|
|
2851
|
+
if (!(len instanceof ArrayBuffer) || len.byteLength === 0) throw TypeError("Built-in length encoding failed");
|
|
2852
|
+
}
|
|
2853
|
+
const total = id.byteLength + len.byteLength + length + (node.indefinite ? 2 : 0);
|
|
2854
|
+
if (!Number.isSafeInteger(total)) throw RangeError("Built-in encoding is too large");
|
|
2855
|
+
return {
|
|
2856
|
+
id,
|
|
2857
|
+
len,
|
|
2858
|
+
payload,
|
|
2859
|
+
length,
|
|
2860
|
+
total,
|
|
2861
|
+
indefinite: node.indefinite,
|
|
2862
|
+
prefix: node.prefix
|
|
2863
|
+
};
|
|
2864
|
+
}
|
|
2865
|
+
function flatten(node, output, offset, sizeOnly) {
|
|
2866
|
+
output.set(new Uint8Array(node.id), offset);
|
|
2867
|
+
offset += node.id.byteLength;
|
|
2868
|
+
output.set(new Uint8Array(node.len), offset);
|
|
2869
|
+
offset += node.len.byteLength;
|
|
2870
|
+
if (node.prefix) {
|
|
2871
|
+
if (!sizeOnly) output.set(node.prefix, offset);
|
|
2872
|
+
offset += node.prefix.byteLength;
|
|
2873
|
+
}
|
|
2874
|
+
if (node.payload instanceof Uint8Array) {
|
|
2875
|
+
if (!sizeOnly) output.set(node.payload, offset);
|
|
2876
|
+
offset += node.payload.byteLength;
|
|
2877
|
+
} else offset = flatten(node.payload, output, offset, sizeOnly);
|
|
2878
|
+
if (node.indefinite) offset += 2;
|
|
2879
|
+
return offset;
|
|
2880
|
+
}
|
|
2881
|
+
function tryEncodeBuiltin(block, sizeOnly = false) {
|
|
2882
|
+
const registry = builtinRegistry;
|
|
2883
|
+
if (!registry || !writerMethodsStable(registry)) return void 0;
|
|
2884
|
+
const validated = inspectNode(block, 0, registry);
|
|
2885
|
+
if (!validated) return void 0;
|
|
2886
|
+
const node = buildNode(validated, sizeOnly, registry);
|
|
2887
|
+
const output = new Uint8Array(node.total);
|
|
2888
|
+
flatten(node, output, 0, sizeOnly);
|
|
2889
|
+
return output.buffer;
|
|
2890
|
+
}
|
|
2561
2891
|
var BaseBlock = class extends LocalBaseBlock {
|
|
2562
2892
|
constructor({ name = EMPTY_STRING, optional = false, primitiveSchema, ...parameters } = {}, valueBlockType) {
|
|
2563
2893
|
super(parameters);
|
|
@@ -2581,7 +2911,15 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
2581
2911
|
}
|
|
2582
2912
|
toBER(sizeOnly, writer) {
|
|
2583
2913
|
const _writer = writer || new ViewWriter();
|
|
2584
|
-
if (!writer)
|
|
2914
|
+
if (!writer) {
|
|
2915
|
+
prepareIndefiniteForm(this);
|
|
2916
|
+
if (sizeOnly === true || sizeOnly === false || sizeOnly === void 0) {
|
|
2917
|
+
if (shouldUseBuiltinEncoder(this)) {
|
|
2918
|
+
const encoded = tryEncodeBuiltin(this, sizeOnly === true);
|
|
2919
|
+
if (encoded) return encoded;
|
|
2920
|
+
}
|
|
2921
|
+
}
|
|
2922
|
+
}
|
|
2585
2923
|
const idBlockBuf = this.idBlock.toBER(sizeOnly);
|
|
2586
2924
|
_writer.write(idBlockBuf);
|
|
2587
2925
|
if (this.lenBlock.isIndefiniteForm) {
|
|
@@ -2626,6 +2964,7 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
2626
2964
|
}
|
|
2627
2965
|
};
|
|
2628
2966
|
BaseBlock.NAME = "BaseBlock";
|
|
2967
|
+
const ORIGINAL_BASE_BLOCK_TO_BER = BaseBlock.prototype.toBER;
|
|
2629
2968
|
function prepareIndefiniteForm(baseBlock) {
|
|
2630
2969
|
var _a;
|
|
2631
2970
|
if (baseBlock instanceof typeStore.Constructed) {
|
|
@@ -2661,6 +3000,7 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
2661
3000
|
}
|
|
2662
3001
|
};
|
|
2663
3002
|
BaseStringBlock.NAME = "BaseStringBlock";
|
|
3003
|
+
var _a$x;
|
|
2664
3004
|
var LocalPrimitiveValueBlock = class extends HexBlock(ValueBlock) {
|
|
2665
3005
|
constructor({ isHexOnly = true, ...parameters } = {}) {
|
|
2666
3006
|
super(parameters);
|
|
@@ -2668,6 +3008,7 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
2668
3008
|
}
|
|
2669
3009
|
};
|
|
2670
3010
|
LocalPrimitiveValueBlock.NAME = "PrimitiveValueBlock";
|
|
3011
|
+
const ORIGINAL_LOCAL_PRIMITIVE_TO_BER = (_a$x = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(LocalPrimitiveValueBlock.prototype), "toBER")) === null || _a$x === void 0 ? void 0 : _a$x.value;
|
|
2671
3012
|
var _a$w;
|
|
2672
3013
|
var Primitive = class extends BaseBlock {
|
|
2673
3014
|
constructor(parameters = {}) {
|
|
@@ -2680,6 +3021,70 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
2680
3021
|
typeStore.Primitive = _a$w;
|
|
2681
3022
|
})();
|
|
2682
3023
|
Primitive.NAME = "PRIMITIVE";
|
|
3024
|
+
let fastParserRegistry;
|
|
3025
|
+
function registerFastParser(constructors) {
|
|
3026
|
+
fastParserRegistry = {
|
|
3027
|
+
Integer: constructors.Integer,
|
|
3028
|
+
Null: constructors.Null,
|
|
3029
|
+
Sequence: constructors.Sequence
|
|
3030
|
+
};
|
|
3031
|
+
}
|
|
3032
|
+
function fastParserContext(context) {
|
|
3033
|
+
const nodes = Object.getOwnPropertyDescriptor(context, "nodesCount");
|
|
3034
|
+
const maxNodes = Object.getOwnPropertyDescriptor(context, "maxNodes");
|
|
3035
|
+
const maxContentLength = Object.getOwnPropertyDescriptor(context, "maxContentLength");
|
|
3036
|
+
if (!nodes || !("value" in nodes) || nodes.writable !== true) return false;
|
|
3037
|
+
if (!maxNodes || !("value" in maxNodes) || !maxContentLength || !("value" in maxContentLength)) return false;
|
|
3038
|
+
return typeof nodes.value === "number" && Number.isSafeInteger(nodes.value) && nodes.value >= 0 && typeof maxNodes.value === "number" && Number.isSafeInteger(maxNodes.value) && maxNodes.value >= 0 && typeof maxContentLength.value === "number" && Number.isSafeInteger(maxContentLength.value) && maxContentLength.value >= 0 && nodes.value < maxNodes.value;
|
|
3039
|
+
}
|
|
3040
|
+
function fastParserType(store, name, value) {
|
|
3041
|
+
const descriptor = Object.getOwnPropertyDescriptor(store, name);
|
|
3042
|
+
return !!descriptor && "value" in descriptor && descriptor.value === value;
|
|
3043
|
+
}
|
|
3044
|
+
function tryFastFromBER(inputBuffer, inputOffset, inputLength, context) {
|
|
3045
|
+
const registry = fastParserRegistry;
|
|
3046
|
+
if (!registry) return void 0;
|
|
3047
|
+
let Constructor;
|
|
3048
|
+
let length = 0;
|
|
3049
|
+
try {
|
|
3050
|
+
if (Object.getPrototypeOf(inputBuffer) !== Uint8Array.prototype) return void 0;
|
|
3051
|
+
if (!Number.isSafeInteger(inputOffset) || inputOffset < 0 || !Number.isSafeInteger(inputLength) || inputLength < 2) return;
|
|
3052
|
+
if (inputOffset > inputBuffer.byteLength || inputLength > inputBuffer.byteLength - inputOffset) return void 0;
|
|
3053
|
+
const tag = inputBuffer[inputOffset];
|
|
3054
|
+
if (tag !== 2 && tag !== 5 && tag !== 48) return void 0;
|
|
3055
|
+
length = inputBuffer[inputOffset + 1];
|
|
3056
|
+
if (length >= 128 || length > inputLength - 2) return void 0;
|
|
3057
|
+
if (tag === 5 && length !== 0) return void 0;
|
|
3058
|
+
if (!fastParserContext(context)) return void 0;
|
|
3059
|
+
if (length > Object.getOwnPropertyDescriptor(context, "maxContentLength").value) return;
|
|
3060
|
+
const constructorName = tag === 2 ? "Integer" : tag === 5 ? "Null" : "Sequence";
|
|
3061
|
+
Constructor = registry[constructorName];
|
|
3062
|
+
if (!fastParserType(typeStore, constructorName, Constructor)) return void 0;
|
|
3063
|
+
const identificationFromBER = Object.getOwnPropertyDescriptor(LocalIdentificationBlock.prototype, "fromBER");
|
|
3064
|
+
const lengthFromBER = Object.getOwnPropertyDescriptor(LocalLengthBlock.prototype, "fromBER");
|
|
3065
|
+
if (!identificationFromBER || !("value" in identificationFromBER) || identificationFromBER.value !== ORIGINAL_LOCAL_IDENTIFICATION_FROM_BER || !lengthFromBER || !("value" in lengthFromBER) || lengthFromBER.value !== ORIGINAL_LOCAL_LENGTH_FROM_BER) return void 0;
|
|
3066
|
+
} catch {
|
|
3067
|
+
return;
|
|
3068
|
+
}
|
|
3069
|
+
if (!Constructor) return void 0;
|
|
3070
|
+
const result = new Constructor();
|
|
3071
|
+
result.idBlock.tagClass = 1;
|
|
3072
|
+
result.idBlock.tagNumber = inputBuffer[inputOffset] & 31;
|
|
3073
|
+
result.idBlock.isConstructed = inputBuffer[inputOffset] === 48;
|
|
3074
|
+
result.idBlock.isHexOnly = false;
|
|
3075
|
+
result.idBlock.blockLength = 1;
|
|
3076
|
+
result.lenBlock.isIndefiniteForm = false;
|
|
3077
|
+
result.lenBlock.longFormUsed = false;
|
|
3078
|
+
result.lenBlock.length = length;
|
|
3079
|
+
result.lenBlock.blockLength = 1;
|
|
3080
|
+
context.nodesCount += 1;
|
|
3081
|
+
const resultOffset = result.fromBER(inputBuffer, inputOffset + 2, length, context);
|
|
3082
|
+
result.valueBeforeDecodeView = inputBuffer.subarray(inputOffset, inputOffset + result.blockLength);
|
|
3083
|
+
return {
|
|
3084
|
+
offset: resultOffset,
|
|
3085
|
+
result
|
|
3086
|
+
};
|
|
3087
|
+
}
|
|
2683
3088
|
const DEFAULT_MAX_DEPTH = 100;
|
|
2684
3089
|
const DEFAULT_MAX_NODES = 1e4;
|
|
2685
3090
|
const DEFAULT_MAX_CONTENT_LENGTH = 16777216;
|
|
@@ -2687,13 +3092,14 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
2687
3092
|
const MAX_NODES_EXCEEDED_ERROR = "Maximum ASN.1 node count exceeded";
|
|
2688
3093
|
const MAX_CONTENT_LENGTH_EXCEEDED_ERROR = "Maximum ASN.1 content length exceeded";
|
|
2689
3094
|
function createFromBerContext(options = {}) {
|
|
2690
|
-
var _a, _b, _c;
|
|
3095
|
+
var _a, _b, _c, _d;
|
|
2691
3096
|
return {
|
|
2692
3097
|
depth: 0,
|
|
2693
3098
|
maxDepth: (_a = options.maxDepth) !== null && _a !== void 0 ? _a : DEFAULT_MAX_DEPTH,
|
|
2694
3099
|
nodesCount: 0,
|
|
2695
3100
|
maxNodes: (_b = options.maxNodes) !== null && _b !== void 0 ? _b : DEFAULT_MAX_NODES,
|
|
2696
|
-
maxContentLength: (_c = options.maxContentLength) !== null && _c !== void 0 ? _c : DEFAULT_MAX_CONTENT_LENGTH
|
|
3101
|
+
maxContentLength: (_c = options.maxContentLength) !== null && _c !== void 0 ? _c : DEFAULT_MAX_CONTENT_LENGTH,
|
|
3102
|
+
parseEmbedded: (_d = options.parseEmbedded) !== null && _d !== void 0 ? _d : true
|
|
2697
3103
|
};
|
|
2698
3104
|
}
|
|
2699
3105
|
function createErrorResult(error) {
|
|
@@ -2731,17 +3137,15 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
2731
3137
|
return newObject;
|
|
2732
3138
|
}
|
|
2733
3139
|
function localFromBER(inputBuffer, inputOffset = 0, inputLength = inputBuffer.length, context = createFromBerContext()) {
|
|
3140
|
+
const fastResult = tryFastFromBER(inputBuffer, inputOffset, inputLength, context);
|
|
3141
|
+
if (fastResult) return fastResult;
|
|
2734
3142
|
const incomingOffset = inputOffset;
|
|
2735
3143
|
let returnObject = new BaseBlock({}, ValueBlock);
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
returnObject
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
result: returnObject
|
|
2742
|
-
};
|
|
2743
|
-
}
|
|
2744
|
-
if (!inputBuffer.subarray(inputOffset, inputOffset + inputLength).length) {
|
|
3144
|
+
if (!checkBufferParams(returnObject, inputBuffer, inputOffset, inputLength)) return {
|
|
3145
|
+
offset: -1,
|
|
3146
|
+
result: returnObject
|
|
3147
|
+
};
|
|
3148
|
+
if (Number.isInteger(inputOffset) && Number.isInteger(inputLength) ? inputLength === 0 : inputBuffer.subarray(inputOffset, inputOffset + inputLength).length === 0) {
|
|
2745
3149
|
returnObject.error = "Zero buffer length";
|
|
2746
3150
|
return {
|
|
2747
3151
|
offset: -1,
|
|
@@ -2936,7 +3340,8 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
2936
3340
|
result
|
|
2937
3341
|
};
|
|
2938
3342
|
}
|
|
2939
|
-
|
|
3343
|
+
const inputView = pvtsutils__namespace.BufferSourceConverter.toUint8Array(inputBuffer);
|
|
3344
|
+
return localFromBER(options.copyInput === false ? inputView : inputView.slice(), 0, inputBuffer.byteLength, createFromBerContext(options));
|
|
2940
3345
|
}
|
|
2941
3346
|
function checkLen(indefiniteLength, length) {
|
|
2942
3347
|
if (indefiniteLength) return 1;
|
|
@@ -2994,6 +3399,7 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
2994
3399
|
}
|
|
2995
3400
|
};
|
|
2996
3401
|
LocalConstructedValueBlock.NAME = "ConstructedValueBlock";
|
|
3402
|
+
const ORIGINAL_LOCAL_CONSTRUCTED_TO_BER = LocalConstructedValueBlock.prototype.toBER;
|
|
2997
3403
|
var _a$v;
|
|
2998
3404
|
var Constructed = class extends BaseBlock {
|
|
2999
3405
|
constructor(parameters = {}) {
|
|
@@ -3108,7 +3514,7 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
3108
3514
|
return inputOffset + inputLength;
|
|
3109
3515
|
}
|
|
3110
3516
|
toBER() {
|
|
3111
|
-
return this.valueHexView.slice();
|
|
3517
|
+
return this.valueHexView.slice().buffer;
|
|
3112
3518
|
}
|
|
3113
3519
|
toJSON() {
|
|
3114
3520
|
return {
|
|
@@ -3184,6 +3590,7 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
3184
3590
|
}
|
|
3185
3591
|
};
|
|
3186
3592
|
LocalOctetStringValueBlock.NAME = "OctetStringValueBlock";
|
|
3593
|
+
const ORIGINAL_LOCAL_OCTET_STRING_TO_BER = LocalOctetStringValueBlock.prototype.toBER;
|
|
3187
3594
|
var _a$r;
|
|
3188
3595
|
var OctetString = class extends BaseBlock {
|
|
3189
3596
|
constructor({ idBlock = {}, lenBlock = {}, ...parameters } = {}) {
|
|
@@ -3211,7 +3618,7 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
3211
3618
|
if (this.lenBlock.error.length === 0) this.blockLength += this.lenBlock.blockLength;
|
|
3212
3619
|
return inputOffset;
|
|
3213
3620
|
}
|
|
3214
|
-
if (!this.valueBlock.isConstructed) {
|
|
3621
|
+
if (!this.valueBlock.isConstructed && (context === null || context === void 0 ? void 0 : context.parseEmbedded) !== false) {
|
|
3215
3622
|
const buf = (inputBuffer instanceof ArrayBuffer ? new Uint8Array(inputBuffer) : inputBuffer).subarray(inputOffset, inputOffset + inputLength);
|
|
3216
3623
|
try {
|
|
3217
3624
|
if (buf.byteLength) {
|
|
@@ -3282,7 +3689,7 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
3282
3689
|
this.error = "Unused bits for BitString must be in range 0-7";
|
|
3283
3690
|
return -1;
|
|
3284
3691
|
}
|
|
3285
|
-
if (!this.unusedBits) {
|
|
3692
|
+
if (!this.unusedBits && (context === null || context === void 0 ? void 0 : context.parseEmbedded) !== false) {
|
|
3286
3693
|
const buf = intBuffer.subarray(1);
|
|
3287
3694
|
try {
|
|
3288
3695
|
if (buf.byteLength) {
|
|
@@ -3318,6 +3725,7 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
3318
3725
|
}
|
|
3319
3726
|
};
|
|
3320
3727
|
LocalBitStringValueBlock.NAME = "BitStringValueBlock";
|
|
3728
|
+
const ORIGINAL_LOCAL_BIT_STRING_TO_BER = LocalBitStringValueBlock.prototype.toBER;
|
|
3321
3729
|
var _a$q;
|
|
3322
3730
|
var BitString = class extends BaseBlock {
|
|
3323
3731
|
constructor({ idBlock = {}, lenBlock = {}, ...parameters } = {}) {
|
|
@@ -3358,85 +3766,45 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
3358
3766
|
typeStore.BitString = _a$q;
|
|
3359
3767
|
})();
|
|
3360
3768
|
BitString.NAME = BIT_STRING_NAME;
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
const
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
const
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
digits[i] = newValue[0] % 10;
|
|
3399
|
-
}
|
|
3400
|
-
if (c[0] > 0) digits = pvutils__namespace.utilConcatView(c, digits);
|
|
3401
|
-
powers2.push(digits);
|
|
3402
|
-
}
|
|
3403
|
-
return powers2[n];
|
|
3404
|
-
}
|
|
3405
|
-
function viewSub(first, second) {
|
|
3406
|
-
let b = 0;
|
|
3407
|
-
const firstView = new Uint8Array(first);
|
|
3408
|
-
const secondView = new Uint8Array(second);
|
|
3409
|
-
const firstViewCopy = firstView.slice(0);
|
|
3410
|
-
const firstViewCopyLength = firstViewCopy.length - 1;
|
|
3411
|
-
const secondViewCopy = secondView.slice(0);
|
|
3412
|
-
const secondViewCopyLength = secondViewCopy.length - 1;
|
|
3413
|
-
let value;
|
|
3414
|
-
let counter = 0;
|
|
3415
|
-
for (let i = secondViewCopyLength; i >= 0; i--, counter++) {
|
|
3416
|
-
value = firstViewCopy[firstViewCopyLength - counter] - secondViewCopy[secondViewCopyLength - counter] - b;
|
|
3417
|
-
switch (true) {
|
|
3418
|
-
case value < 0:
|
|
3419
|
-
b = 1;
|
|
3420
|
-
firstViewCopy[firstViewCopyLength - counter] = value + 10;
|
|
3421
|
-
break;
|
|
3422
|
-
default:
|
|
3423
|
-
b = 0;
|
|
3424
|
-
firstViewCopy[firstViewCopyLength - counter] = value;
|
|
3425
|
-
}
|
|
3426
|
-
}
|
|
3427
|
-
if (b > 0) for (let i = firstViewCopyLength - secondViewCopyLength + 1; i >= 0; i--, counter++) {
|
|
3428
|
-
value = firstViewCopy[firstViewCopyLength - counter] - b;
|
|
3429
|
-
if (value < 0) {
|
|
3430
|
-
b = 1;
|
|
3431
|
-
firstViewCopy[firstViewCopyLength - counter] = value + 10;
|
|
3432
|
-
} else {
|
|
3433
|
-
b = 0;
|
|
3434
|
-
firstViewCopy[firstViewCopyLength - counter] = value;
|
|
3435
|
-
break;
|
|
3436
|
-
}
|
|
3437
|
-
}
|
|
3438
|
-
return firstViewCopy.slice();
|
|
3769
|
+
function bytesToSignedBigInt(view) {
|
|
3770
|
+
if (!view.byteLength) return BigInt(0);
|
|
3771
|
+
const value = BigInt(`0x${pvtsutils__namespace.Convert.ToHex(view)}`);
|
|
3772
|
+
if (view[0] & 128) return value - (BigInt(1) << BigInt(view.byteLength * 8));
|
|
3773
|
+
return value;
|
|
3774
|
+
}
|
|
3775
|
+
function bytesToSignedDecimal(view) {
|
|
3776
|
+
if (typeof BigInt !== "undefined") return bytesToSignedBigInt(view).toString(10);
|
|
3777
|
+
const BASE = 1e7;
|
|
3778
|
+
const DECIMAL_DIGITS = 7;
|
|
3779
|
+
if (!view.byteLength) return "0";
|
|
3780
|
+
const negative = !!(view[0] & 128);
|
|
3781
|
+
let magnitude = view;
|
|
3782
|
+
if (negative) {
|
|
3783
|
+
magnitude = new Uint8Array(view.length);
|
|
3784
|
+
let carry = 1;
|
|
3785
|
+
for (let i = view.length - 1; i >= 0; i--) {
|
|
3786
|
+
const value = (view[i] ^ 255) + carry;
|
|
3787
|
+
magnitude[i] = value & 255;
|
|
3788
|
+
carry = value >> 8;
|
|
3789
|
+
}
|
|
3790
|
+
}
|
|
3791
|
+
const limbs = [0];
|
|
3792
|
+
for (let index = 0; index < magnitude.length; index++) {
|
|
3793
|
+
let carry = magnitude[index];
|
|
3794
|
+
for (let i = 0; i < limbs.length; i++) {
|
|
3795
|
+
const value = limbs[i] * 256 + carry;
|
|
3796
|
+
limbs[i] = value % BASE;
|
|
3797
|
+
carry = Math.floor(value / BASE);
|
|
3798
|
+
}
|
|
3799
|
+
if (carry) limbs.push(carry);
|
|
3800
|
+
}
|
|
3801
|
+
let top = limbs.length - 1;
|
|
3802
|
+
while (top > 0 && limbs[top] === 0) top--;
|
|
3803
|
+
let result = String(limbs[top]);
|
|
3804
|
+
for (let i = top - 1; i >= 0; i--) result += String(limbs[i]).padStart(DECIMAL_DIGITS, "0");
|
|
3805
|
+
return negative && result !== "0" ? `-${result}` : result;
|
|
3439
3806
|
}
|
|
3807
|
+
var _a$p;
|
|
3440
3808
|
var LocalIntegerValueBlock = class extends HexBlock(ValueBlock) {
|
|
3441
3809
|
setValueHex() {
|
|
3442
3810
|
if (this.valueHexView.length >= 4) {
|
|
@@ -3506,33 +3874,7 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
3506
3874
|
};
|
|
3507
3875
|
}
|
|
3508
3876
|
toString() {
|
|
3509
|
-
|
|
3510
|
-
let digits = new Uint8Array(this.valueHexView.length * 8 / 3);
|
|
3511
|
-
let bitNumber = 0;
|
|
3512
|
-
let currentByte;
|
|
3513
|
-
const asn1View = this.valueHexView;
|
|
3514
|
-
let result = "";
|
|
3515
|
-
let flag = false;
|
|
3516
|
-
for (let byteNumber = asn1View.byteLength - 1; byteNumber >= 0; byteNumber--) {
|
|
3517
|
-
currentByte = asn1View[byteNumber];
|
|
3518
|
-
for (let i = 0; i < 8; i++) {
|
|
3519
|
-
if ((currentByte & 1) === 1) switch (bitNumber) {
|
|
3520
|
-
case firstBit:
|
|
3521
|
-
digits = viewSub(power2(bitNumber), digits);
|
|
3522
|
-
result = "-";
|
|
3523
|
-
break;
|
|
3524
|
-
default: digits = viewAdd(digits, power2(bitNumber));
|
|
3525
|
-
}
|
|
3526
|
-
bitNumber++;
|
|
3527
|
-
currentByte >>= 1;
|
|
3528
|
-
}
|
|
3529
|
-
}
|
|
3530
|
-
for (let i = 0; i < digits.length; i++) {
|
|
3531
|
-
if (digits[i]) flag = true;
|
|
3532
|
-
if (flag) result += digitsString.charAt(digits[i]);
|
|
3533
|
-
}
|
|
3534
|
-
if (flag === false) result += digitsString.charAt(0);
|
|
3535
|
-
return result;
|
|
3877
|
+
return bytesToSignedDecimal(this.valueHexView);
|
|
3536
3878
|
}
|
|
3537
3879
|
};
|
|
3538
3880
|
_a$p = LocalIntegerValueBlock;
|
|
@@ -3548,6 +3890,8 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
3548
3890
|
}
|
|
3549
3891
|
});
|
|
3550
3892
|
})();
|
|
3893
|
+
const ORIGINAL_LOCAL_INTEGER_TO_BER = LocalIntegerValueBlock.prototype.toBER;
|
|
3894
|
+
const ORIGINAL_LOCAL_INTEGER_TO_STRING = LocalIntegerValueBlock.prototype.toString;
|
|
3551
3895
|
var _a$o;
|
|
3552
3896
|
var Integer = class extends BaseBlock {
|
|
3553
3897
|
constructor(parameters = {}) {
|
|
@@ -3557,7 +3901,10 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
3557
3901
|
}
|
|
3558
3902
|
toBigInt() {
|
|
3559
3903
|
assertBigInt();
|
|
3560
|
-
|
|
3904
|
+
const valueBlock = this.valueBlock;
|
|
3905
|
+
const toString = valueBlock.toString;
|
|
3906
|
+
if (toString === ORIGINAL_LOCAL_INTEGER_TO_STRING) return bytesToSignedBigInt(valueBlock.valueHexView);
|
|
3907
|
+
return BigInt(Reflect.apply(toString, valueBlock, []));
|
|
3561
3908
|
}
|
|
3562
3909
|
static fromBigInt(value) {
|
|
3563
3910
|
assertBigInt();
|
|
@@ -3619,15 +3966,27 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
3619
3966
|
const inputView = pvtsutils__namespace.BufferSourceConverter.toUint8Array(inputBuffer);
|
|
3620
3967
|
if (!checkBufferParams(this, inputView, inputOffset, inputLength)) return -1;
|
|
3621
3968
|
const intBuffer = inputView.subarray(inputOffset, inputOffset + inputLength);
|
|
3622
|
-
this.
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3969
|
+
if (this.blockLength === 0 && Number.isInteger(inputOffset) && Number.isInteger(inputLength)) {
|
|
3970
|
+
let sidLength = 0;
|
|
3971
|
+
while (sidLength < inputLength) {
|
|
3972
|
+
const octet = intBuffer[sidLength];
|
|
3973
|
+
sidLength++;
|
|
3974
|
+
if ((octet & 128) === 0) break;
|
|
3975
|
+
}
|
|
3976
|
+
this.blockLength = sidLength;
|
|
3977
|
+
this.valueHexView = new Uint8Array(sidLength);
|
|
3978
|
+
for (let i = 0; i < sidLength; i++) this.valueHexView[i] = intBuffer[i] & 127;
|
|
3979
|
+
} else {
|
|
3980
|
+
this.valueHexView = new Uint8Array(inputLength);
|
|
3981
|
+
for (let i = 0; i < inputLength; i++) {
|
|
3982
|
+
this.valueHexView[i] = intBuffer[i] & 127;
|
|
3983
|
+
this.blockLength++;
|
|
3984
|
+
if ((intBuffer[i] & 128) === 0) break;
|
|
3985
|
+
}
|
|
3986
|
+
const tempView = new Uint8Array(this.blockLength);
|
|
3987
|
+
for (let i = 0; i < this.blockLength; i++) tempView[i] = this.valueHexView[i];
|
|
3988
|
+
this.valueHexView = tempView;
|
|
3989
|
+
}
|
|
3631
3990
|
if ((intBuffer[this.blockLength - 1] & 128) !== 0) {
|
|
3632
3991
|
this.error = "End of input reached before message was fully decoded";
|
|
3633
3992
|
return -1;
|
|
@@ -3655,7 +4014,7 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
3655
4014
|
const retView = new Uint8Array(this.blockLength);
|
|
3656
4015
|
for (let i = 0; i < this.blockLength - 1; i++) retView[i] = curView[i] | 128;
|
|
3657
4016
|
retView[this.blockLength - 1] = curView[this.blockLength - 1];
|
|
3658
|
-
return retView
|
|
4017
|
+
return pvtsutils__namespace.BufferSourceConverter.toArrayBuffer(retView);
|
|
3659
4018
|
}
|
|
3660
4019
|
const encodedBuf = pvutils__namespace.utilToBase(this.valueDec, 7);
|
|
3661
4020
|
if (encodedBuf.byteLength === 0) {
|
|
@@ -3669,7 +4028,7 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
3669
4028
|
for (let i = 0; i < len; i++) retView[i] = encodedView[i] | 128;
|
|
3670
4029
|
retView[len] = encodedView[len];
|
|
3671
4030
|
}
|
|
3672
|
-
return retView;
|
|
4031
|
+
return pvtsutils__namespace.BufferSourceConverter.toArrayBuffer(retView);
|
|
3673
4032
|
}
|
|
3674
4033
|
toString() {
|
|
3675
4034
|
let result = "";
|
|
@@ -3843,15 +4202,27 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
3843
4202
|
const inputView = pvtsutils__namespace.BufferSourceConverter.toUint8Array(inputBuffer);
|
|
3844
4203
|
if (!checkBufferParams(this, inputView, inputOffset, inputLength)) return -1;
|
|
3845
4204
|
const intBuffer = inputView.subarray(inputOffset, inputOffset + inputLength);
|
|
3846
|
-
this.
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
4205
|
+
if (this.blockLength === 0 && Number.isInteger(inputOffset) && Number.isInteger(inputLength)) {
|
|
4206
|
+
let sidLength = 0;
|
|
4207
|
+
while (sidLength < inputLength) {
|
|
4208
|
+
const octet = intBuffer[sidLength];
|
|
4209
|
+
sidLength++;
|
|
4210
|
+
if ((octet & 128) === 0) break;
|
|
4211
|
+
}
|
|
4212
|
+
this.blockLength = sidLength;
|
|
4213
|
+
this.valueHexView = new Uint8Array(sidLength);
|
|
4214
|
+
for (let i = 0; i < sidLength; i++) this.valueHexView[i] = intBuffer[i] & 127;
|
|
4215
|
+
} else {
|
|
4216
|
+
this.valueHexView = new Uint8Array(inputLength);
|
|
4217
|
+
for (let i = 0; i < inputLength; i++) {
|
|
4218
|
+
this.valueHexView[i] = intBuffer[i] & 127;
|
|
4219
|
+
this.blockLength++;
|
|
4220
|
+
if ((intBuffer[i] & 128) === 0) break;
|
|
4221
|
+
}
|
|
4222
|
+
const tempView = new Uint8Array(this.blockLength);
|
|
4223
|
+
for (let i = 0; i < this.blockLength; i++) tempView[i] = this.valueHexView[i];
|
|
4224
|
+
this.valueHexView = tempView;
|
|
4225
|
+
}
|
|
3855
4226
|
if ((intBuffer[this.blockLength - 1] & 128) !== 0) {
|
|
3856
4227
|
this.error = "End of input reached before message was fully decoded";
|
|
3857
4228
|
return -1;
|
|
@@ -4331,7 +4702,7 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
4331
4702
|
}
|
|
4332
4703
|
toString(encoding = "iso") {
|
|
4333
4704
|
if (encoding === "iso") {
|
|
4334
|
-
const outputArray =
|
|
4705
|
+
const outputArray = Array.from({ length: 7 });
|
|
4335
4706
|
outputArray[0] = pvutils__namespace.padNumber(this.year < 2e3 ? this.year - 1900 : this.year - 2e3, 2);
|
|
4336
4707
|
outputArray[1] = pvutils__namespace.padNumber(this.month, 2);
|
|
4337
4708
|
outputArray[2] = pvutils__namespace.padNumber(this.day, 2);
|
|
@@ -4508,7 +4879,7 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
4508
4879
|
outputArray.push(pvutils__namespace.padNumber(this.second, 2));
|
|
4509
4880
|
if (this.millisecond !== 0) {
|
|
4510
4881
|
outputArray.push(".");
|
|
4511
|
-
outputArray.push(pvutils__namespace.padNumber(this.millisecond, 3));
|
|
4882
|
+
outputArray.push(pvutils__namespace.padNumber(this.millisecond, 3).replace(/0+$/, ""));
|
|
4512
4883
|
}
|
|
4513
4884
|
outputArray.push("Z");
|
|
4514
4885
|
return outputArray.join("");
|
|
@@ -4870,6 +5241,40 @@ var require_build = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
4870
5241
|
};
|
|
4871
5242
|
return compareSchema(asn1.result, asn1.result, inputSchema);
|
|
4872
5243
|
}
|
|
5244
|
+
registerBuiltinEncoder({
|
|
5245
|
+
BitString,
|
|
5246
|
+
Integer,
|
|
5247
|
+
OctetString,
|
|
5248
|
+
Primitive,
|
|
5249
|
+
Constructed,
|
|
5250
|
+
Sequence,
|
|
5251
|
+
Set
|
|
5252
|
+
}, {
|
|
5253
|
+
BaseBlock,
|
|
5254
|
+
ViewWriter,
|
|
5255
|
+
LocalIdentificationBlock,
|
|
5256
|
+
LocalLengthBlock,
|
|
5257
|
+
LocalIntegerValueBlock,
|
|
5258
|
+
LocalOctetStringValueBlock,
|
|
5259
|
+
LocalConstructedValueBlock,
|
|
5260
|
+
LocalBitStringValueBlock,
|
|
5261
|
+
LocalPrimitiveValueBlock,
|
|
5262
|
+
originalBaseBlockToBER: ORIGINAL_BASE_BLOCK_TO_BER,
|
|
5263
|
+
originalWriterWrite: ORIGINAL_VIEW_WRITER_WRITE,
|
|
5264
|
+
originalWriterFinal: ORIGINAL_VIEW_WRITER_FINAL,
|
|
5265
|
+
originalIdentificationToBER: ORIGINAL_LOCAL_IDENTIFICATION_TO_BER,
|
|
5266
|
+
originalLengthToBER: ORIGINAL_LOCAL_LENGTH_TO_BER,
|
|
5267
|
+
originalIntegerToBER: ORIGINAL_LOCAL_INTEGER_TO_BER,
|
|
5268
|
+
originalOctetStringToBER: ORIGINAL_LOCAL_OCTET_STRING_TO_BER,
|
|
5269
|
+
originalBitStringToBER: ORIGINAL_LOCAL_BIT_STRING_TO_BER,
|
|
5270
|
+
originalConstructedToBER: ORIGINAL_LOCAL_CONSTRUCTED_TO_BER,
|
|
5271
|
+
originalPrimitiveToBER: ORIGINAL_LOCAL_PRIMITIVE_TO_BER
|
|
5272
|
+
});
|
|
5273
|
+
registerFastParser({
|
|
5274
|
+
Integer,
|
|
5275
|
+
Null,
|
|
5276
|
+
Sequence
|
|
5277
|
+
});
|
|
4873
5278
|
exports.Any = Any;
|
|
4874
5279
|
exports.BaseBlock = BaseBlock;
|
|
4875
5280
|
exports.BaseStringBlock = BaseStringBlock;
|
|
@@ -14751,7 +15156,7 @@ var require_cjs = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
14751
15156
|
tslib_1.__exportStar(require_certification_request_info(), exports);
|
|
14752
15157
|
}));
|
|
14753
15158
|
//#endregion
|
|
14754
|
-
//#region ../../node_modules/.pnpm/@peculiar+x509@2.
|
|
15159
|
+
//#region ../../node_modules/.pnpm/@peculiar+x509@2.2.0/node_modules/@peculiar/x509/build/x509.cjs.js
|
|
14755
15160
|
/*!
|
|
14756
15161
|
* MIT License
|
|
14757
15162
|
*
|
|
@@ -15219,36 +15624,6 @@ var require_x509_cjs = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
15219
15624
|
};
|
|
15220
15625
|
_AsnData_rawData = /* @__PURE__ */ new WeakMap(), _AsnData_options = /* @__PURE__ */ new WeakMap();
|
|
15221
15626
|
AsnData.NAME = "ASN";
|
|
15222
|
-
var Extension = class Extension extends AsnData {
|
|
15223
|
-
constructor(...args) {
|
|
15224
|
-
let raw;
|
|
15225
|
-
let options;
|
|
15226
|
-
if (pvtsutils.BufferSourceConverter.isBufferSource(args[0])) {
|
|
15227
|
-
raw = pvtsutils.BufferSourceConverter.toArrayBuffer(args[0]);
|
|
15228
|
-
options = args[1];
|
|
15229
|
-
} else raw = asn1Schema.AsnConvert.serialize(new asn1X509.Extension({
|
|
15230
|
-
extnID: args[0],
|
|
15231
|
-
critical: args[1],
|
|
15232
|
-
extnValue: new asn1Schema.OctetString(pvtsutils.BufferSourceConverter.toArrayBuffer(args[2]))
|
|
15233
|
-
}));
|
|
15234
|
-
super(raw, asn1X509.Extension, options);
|
|
15235
|
-
}
|
|
15236
|
-
onInit(asn) {
|
|
15237
|
-
this.type = asn.extnID;
|
|
15238
|
-
this.critical = asn.critical;
|
|
15239
|
-
this.value = asn.extnValue.buffer;
|
|
15240
|
-
}
|
|
15241
|
-
toTextObject() {
|
|
15242
|
-
const obj = this.toTextObjectWithoutValue();
|
|
15243
|
-
obj[""] = this.value;
|
|
15244
|
-
return obj;
|
|
15245
|
-
}
|
|
15246
|
-
toTextObjectWithoutValue() {
|
|
15247
|
-
const obj = this.toTextObjectEmpty(this.critical ? "critical" : void 0);
|
|
15248
|
-
if (obj[TextObject.NAME] === Extension.NAME) obj[TextObject.NAME] = OidSerializer.toString(this.type);
|
|
15249
|
-
return obj;
|
|
15250
|
-
}
|
|
15251
|
-
};
|
|
15252
15627
|
var _a;
|
|
15253
15628
|
var CryptoProvider = class CryptoProvider {
|
|
15254
15629
|
static isCryptoKeyPair(data) {
|
|
@@ -15306,6 +15681,69 @@ var require_x509_cjs = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
15306
15681
|
_a = Symbol.toStringTag;
|
|
15307
15682
|
CryptoProvider.DEFAULT = "default";
|
|
15308
15683
|
const cryptoProvider = new CryptoProvider();
|
|
15684
|
+
const selfProducedParseOptions = { berOptions: {
|
|
15685
|
+
maxDepth: Infinity,
|
|
15686
|
+
maxNodes: Infinity,
|
|
15687
|
+
maxContentLength: Infinity
|
|
15688
|
+
} };
|
|
15689
|
+
function toPositiveIntegerOctets(input) {
|
|
15690
|
+
let firstNonZero = 0;
|
|
15691
|
+
while (firstNonZero < input.length - 1 && input[firstNonZero] === 0) firstNonZero++;
|
|
15692
|
+
let serialNumber = input.slice(firstNonZero);
|
|
15693
|
+
if (!serialNumber.length) serialNumber = new Uint8Array([0]);
|
|
15694
|
+
if (serialNumber[0] > 127) {
|
|
15695
|
+
const newSerialNumber = new Uint8Array(serialNumber.length + 1);
|
|
15696
|
+
newSerialNumber[0] = 0;
|
|
15697
|
+
newSerialNumber.set(serialNumber, 1);
|
|
15698
|
+
serialNumber = newSerialNumber;
|
|
15699
|
+
}
|
|
15700
|
+
return serialNumber.buffer;
|
|
15701
|
+
}
|
|
15702
|
+
function normalizeCertificateSerialNumber(input) {
|
|
15703
|
+
return toPositiveIntegerOctets(pvtsutils.BufferSourceConverter.toUint8Array(pvtsutils.Convert.FromHex(input || "")));
|
|
15704
|
+
}
|
|
15705
|
+
function generateCertificateSerialNumber(input, crypto = cryptoProvider.get()) {
|
|
15706
|
+
const inputView = pvtsutils.BufferSourceConverter.toUint8Array(pvtsutils.Convert.FromHex(input || ""));
|
|
15707
|
+
return toPositiveIntegerOctets(inputView.length && inputView.some((o) => o > 0) ? inputView : crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16)));
|
|
15708
|
+
}
|
|
15709
|
+
function getCertificateSerialNumber(raw) {
|
|
15710
|
+
let serialNumber = pvtsutils.BufferSourceConverter.toUint8Array(raw);
|
|
15711
|
+
if (serialNumber.length > 1 && serialNumber[0] === 0 && serialNumber[1] > 127) serialNumber = serialNumber.slice(1);
|
|
15712
|
+
return pvtsutils.Convert.ToHex(serialNumber);
|
|
15713
|
+
}
|
|
15714
|
+
var Extension = class Extension extends AsnData {
|
|
15715
|
+
constructor(...args) {
|
|
15716
|
+
let raw;
|
|
15717
|
+
let options;
|
|
15718
|
+
if (pvtsutils.BufferSourceConverter.isBufferSource(args[0])) {
|
|
15719
|
+
raw = pvtsutils.BufferSourceConverter.toArrayBuffer(args[0]);
|
|
15720
|
+
options = args[1];
|
|
15721
|
+
} else {
|
|
15722
|
+
raw = asn1Schema.AsnConvert.serialize(new asn1X509.Extension({
|
|
15723
|
+
extnID: args[0],
|
|
15724
|
+
critical: args[1],
|
|
15725
|
+
extnValue: new asn1Schema.OctetString(pvtsutils.BufferSourceConverter.toArrayBuffer(args[2]))
|
|
15726
|
+
}));
|
|
15727
|
+
options = selfProducedParseOptions;
|
|
15728
|
+
}
|
|
15729
|
+
super(raw, asn1X509.Extension, options);
|
|
15730
|
+
}
|
|
15731
|
+
onInit(asn) {
|
|
15732
|
+
this.type = asn.extnID;
|
|
15733
|
+
this.critical = asn.critical;
|
|
15734
|
+
this.value = asn.extnValue.buffer;
|
|
15735
|
+
}
|
|
15736
|
+
toTextObject() {
|
|
15737
|
+
const obj = this.toTextObjectWithoutValue();
|
|
15738
|
+
obj[""] = this.value;
|
|
15739
|
+
return obj;
|
|
15740
|
+
}
|
|
15741
|
+
toTextObjectWithoutValue() {
|
|
15742
|
+
const obj = this.toTextObjectEmpty(this.critical ? "critical" : void 0);
|
|
15743
|
+
if (obj[TextObject.NAME] === Extension.NAME) obj[TextObject.NAME] = OidSerializer.toString(this.type);
|
|
15744
|
+
return obj;
|
|
15745
|
+
}
|
|
15746
|
+
};
|
|
15309
15747
|
const OID_REGEX = /^[0-2](?:\.[1-9][0-9]*)+$/;
|
|
15310
15748
|
function isOID(id) {
|
|
15311
15749
|
return new RegExp(OID_REGEX).test(id);
|
|
@@ -15500,53 +15938,62 @@ var require_x509_cjs = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
15500
15938
|
const REGISTERED_ID = "id";
|
|
15501
15939
|
var GeneralName = class extends AsnData {
|
|
15502
15940
|
constructor(...args) {
|
|
15941
|
+
var _a;
|
|
15503
15942
|
let name;
|
|
15504
|
-
|
|
15505
|
-
|
|
15506
|
-
|
|
15507
|
-
|
|
15508
|
-
|
|
15509
|
-
|
|
15510
|
-
|
|
15511
|
-
|
|
15512
|
-
|
|
15513
|
-
|
|
15514
|
-
|
|
15515
|
-
|
|
15516
|
-
|
|
15517
|
-
|
|
15518
|
-
|
|
15519
|
-
|
|
15520
|
-
|
|
15521
|
-
|
|
15522
|
-
|
|
15523
|
-
|
|
15524
|
-
|
|
15525
|
-
|
|
15526
|
-
|
|
15527
|
-
|
|
15528
|
-
|
|
15943
|
+
let options;
|
|
15944
|
+
if (pvtsutils.BufferSourceConverter.isBufferSource(args[0])) {
|
|
15945
|
+
options = args[1];
|
|
15946
|
+
name = asn1Schema.AsnConvert.parse(args[0], asn1X509__namespace.GeneralName, options);
|
|
15947
|
+
} else if (typeof args[0] === "string") {
|
|
15948
|
+
options = selfProducedParseOptions;
|
|
15949
|
+
switch (args[0]) {
|
|
15950
|
+
case DN: {
|
|
15951
|
+
const derName = new Name(args[1]).toArrayBuffer();
|
|
15952
|
+
const asnName = asn1Schema.AsnConvert.parse(derName, asn1X509__namespace.Name, selfProducedParseOptions);
|
|
15953
|
+
name = new asn1X509__namespace.GeneralName({ directoryName: asnName });
|
|
15954
|
+
break;
|
|
15955
|
+
}
|
|
15956
|
+
case DNS:
|
|
15957
|
+
name = new asn1X509__namespace.GeneralName({ dNSName: args[1] });
|
|
15958
|
+
break;
|
|
15959
|
+
case EMAIL:
|
|
15960
|
+
name = new asn1X509__namespace.GeneralName({ rfc822Name: args[1] });
|
|
15961
|
+
break;
|
|
15962
|
+
case GUID: {
|
|
15963
|
+
const matches = new RegExp(GUID_REGEX, "i").exec(args[1]);
|
|
15964
|
+
if (!matches) throw new Error("Cannot parse GUID value. Value doesn't match to regular expression");
|
|
15965
|
+
const hex = matches.slice(1).map((o, i) => {
|
|
15966
|
+
if (i < 3) return pvtsutils.Convert.ToHex(new Uint8Array(pvtsutils.Convert.FromHex(o)).reverse());
|
|
15967
|
+
return o;
|
|
15968
|
+
}).join("");
|
|
15969
|
+
name = new asn1X509__namespace.GeneralName({ otherName: new asn1X509__namespace.OtherName({
|
|
15970
|
+
typeId: id_GUID,
|
|
15971
|
+
value: asn1Schema.AsnConvert.serialize(new asn1Schema.OctetString(pvtsutils.Convert.FromHex(hex)))
|
|
15972
|
+
}) });
|
|
15973
|
+
break;
|
|
15974
|
+
}
|
|
15975
|
+
case IP:
|
|
15976
|
+
name = new asn1X509__namespace.GeneralName({ iPAddress: args[1] });
|
|
15977
|
+
break;
|
|
15978
|
+
case REGISTERED_ID:
|
|
15979
|
+
name = new asn1X509__namespace.GeneralName({ registeredID: args[1] });
|
|
15980
|
+
break;
|
|
15981
|
+
case UPN:
|
|
15982
|
+
name = new asn1X509__namespace.GeneralName({ otherName: new asn1X509__namespace.OtherName({
|
|
15983
|
+
typeId: id_UPN,
|
|
15984
|
+
value: asn1Schema.AsnConvert.serialize(asn1Schema.AsnUtf8StringConverter.toASN(args[1]))
|
|
15985
|
+
}) });
|
|
15986
|
+
break;
|
|
15987
|
+
case URL:
|
|
15988
|
+
name = new asn1X509__namespace.GeneralName({ uniformResourceIdentifier: args[1] });
|
|
15989
|
+
break;
|
|
15990
|
+
default: throw new Error("Cannot create GeneralName. Unsupported type of the name");
|
|
15529
15991
|
}
|
|
15530
|
-
|
|
15531
|
-
|
|
15532
|
-
|
|
15533
|
-
case REGISTERED_ID:
|
|
15534
|
-
name = new asn1X509__namespace.GeneralName({ registeredID: args[1] });
|
|
15535
|
-
break;
|
|
15536
|
-
case UPN:
|
|
15537
|
-
name = new asn1X509__namespace.GeneralName({ otherName: new asn1X509__namespace.OtherName({
|
|
15538
|
-
typeId: id_UPN,
|
|
15539
|
-
value: asn1Schema.AsnConvert.serialize(asn1Schema.AsnUtf8StringConverter.toASN(args[1]))
|
|
15540
|
-
}) });
|
|
15541
|
-
break;
|
|
15542
|
-
case URL:
|
|
15543
|
-
name = new asn1X509__namespace.GeneralName({ uniformResourceIdentifier: args[1] });
|
|
15544
|
-
break;
|
|
15545
|
-
default: throw new Error("Cannot create GeneralName. Unsupported type of the name");
|
|
15992
|
+
} else {
|
|
15993
|
+
name = args[0];
|
|
15994
|
+
options = (_a = args[1]) !== null && _a !== void 0 ? _a : selfProducedParseOptions;
|
|
15546
15995
|
}
|
|
15547
|
-
|
|
15548
|
-
else name = args[0];
|
|
15549
|
-
super(name);
|
|
15996
|
+
super(name, options);
|
|
15550
15997
|
}
|
|
15551
15998
|
onInit(asn) {
|
|
15552
15999
|
if (asn.dNSName != void 0) {
|
|
@@ -15570,7 +16017,7 @@ var require_x509_cjs = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
15570
16017
|
} else if (asn.otherName != void 0) {
|
|
15571
16018
|
if (asn.otherName.typeId === id_GUID) {
|
|
15572
16019
|
this.type = GUID;
|
|
15573
|
-
const guid = asn1Schema.AsnConvert.parse(asn.otherName.value, asn1Schema.OctetString);
|
|
16020
|
+
const guid = asn1Schema.AsnConvert.parse(asn.otherName.value, asn1Schema.OctetString, this.parseOptions);
|
|
15574
16021
|
const matches = new RegExp(GUID_REGEX, "i").exec(pvtsutils.Convert.ToHex(guid));
|
|
15575
16022
|
if (!matches) throw new Error(ERR_GUID);
|
|
15576
16023
|
this.value = matches.slice(1).map((o, i) => {
|
|
@@ -15579,7 +16026,7 @@ var require_x509_cjs = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
15579
16026
|
}).join("-");
|
|
15580
16027
|
} else if (asn.otherName.typeId === id_UPN) {
|
|
15581
16028
|
this.type = UPN;
|
|
15582
|
-
this.value = asn1Schema.AsnConvert.parse(asn.otherName.value, asn1X509__namespace.DirectoryString).toString();
|
|
16029
|
+
this.value = asn1Schema.AsnConvert.parse(asn.otherName.value, asn1X509__namespace.DirectoryString, this.parseOptions).toString();
|
|
15583
16030
|
} else throw new Error(ERR_GN_STRING_FORMAT);
|
|
15584
16031
|
} else throw new Error(ERR_GN_STRING_FORMAT);
|
|
15585
16032
|
}
|
|
@@ -15612,27 +16059,30 @@ var require_x509_cjs = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
15612
16059
|
}
|
|
15613
16060
|
};
|
|
15614
16061
|
var GeneralNames = class extends AsnData {
|
|
15615
|
-
constructor(params) {
|
|
16062
|
+
constructor(params, options) {
|
|
15616
16063
|
let names;
|
|
16064
|
+
let stored = selfProducedParseOptions;
|
|
15617
16065
|
if (params instanceof asn1X509__namespace.GeneralNames) names = params;
|
|
15618
16066
|
else if (Array.isArray(params)) {
|
|
15619
16067
|
const items = [];
|
|
15620
16068
|
for (const name of params) if (name instanceof asn1X509__namespace.GeneralName) items.push(name);
|
|
15621
16069
|
else {
|
|
15622
|
-
const asnName = asn1Schema.AsnConvert.parse(new GeneralName(name.type, name.value).rawData, asn1X509__namespace.GeneralName);
|
|
16070
|
+
const asnName = asn1Schema.AsnConvert.parse(new GeneralName(name.type, name.value).rawData, asn1X509__namespace.GeneralName, selfProducedParseOptions);
|
|
15623
16071
|
items.push(asnName);
|
|
15624
16072
|
}
|
|
15625
16073
|
names = new asn1X509__namespace.GeneralNames(items);
|
|
15626
|
-
} else if (pvtsutils.BufferSourceConverter.isBufferSource(params))
|
|
15627
|
-
|
|
15628
|
-
|
|
16074
|
+
} else if (pvtsutils.BufferSourceConverter.isBufferSource(params)) {
|
|
16075
|
+
names = asn1Schema.AsnConvert.parse(params, asn1X509__namespace.GeneralNames, options);
|
|
16076
|
+
stored = options !== null && options !== void 0 ? options : {};
|
|
16077
|
+
} else throw new Error("Cannot initialize GeneralNames. Incorrect incoming arguments");
|
|
16078
|
+
super(names, stored);
|
|
15629
16079
|
}
|
|
15630
16080
|
onInit(asn) {
|
|
15631
16081
|
const items = [];
|
|
15632
16082
|
for (const asnName of asn) {
|
|
15633
16083
|
let name = null;
|
|
15634
16084
|
try {
|
|
15635
|
-
name = new GeneralName(asnName);
|
|
16085
|
+
name = new GeneralName(asnName, this.parseOptions);
|
|
15636
16086
|
} catch {
|
|
15637
16087
|
continue;
|
|
15638
16088
|
}
|
|
@@ -15897,7 +16347,7 @@ var require_x509_cjs = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
15897
16347
|
super(asn1X509__namespace.id_ce_authorityKeyIdentifier, args[1], asn1Schema.AsnConvert.serialize(value));
|
|
15898
16348
|
} else {
|
|
15899
16349
|
const certId = args[0];
|
|
15900
|
-
const certIdName = certId.name instanceof GeneralNames ? asn1Schema.AsnConvert.parse(certId.name.rawData, asn1X509__namespace.GeneralNames) : certId.name;
|
|
16350
|
+
const certIdName = certId.name instanceof GeneralNames ? asn1Schema.AsnConvert.parse(certId.name.rawData, asn1X509__namespace.GeneralNames, selfProducedParseOptions) : certId.name;
|
|
15901
16351
|
const value = new asn1X509__namespace.AuthorityKeyIdentifier({
|
|
15902
16352
|
authorityCertIssuer: certIdName,
|
|
15903
16353
|
authorityCertSerialNumber: pvtsutils.Convert.FromHex(certId.serialNumber)
|
|
@@ -16195,7 +16645,7 @@ var require_x509_cjs = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
16195
16645
|
if (typeof url === "string") url = new GeneralName("url", url);
|
|
16196
16646
|
value.push(new asn1X509__namespace.AccessDescription({
|
|
16197
16647
|
accessMethod: method,
|
|
16198
|
-
accessLocation: asn1Schema.AsnConvert.parse(url.rawData, asn1X509__namespace.GeneralName)
|
|
16648
|
+
accessLocation: asn1Schema.AsnConvert.parse(url.rawData, asn1X509__namespace.GeneralName, selfProducedParseOptions)
|
|
16199
16649
|
}));
|
|
16200
16650
|
});
|
|
16201
16651
|
}
|
|
@@ -16231,6 +16681,7 @@ var require_x509_cjs = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
16231
16681
|
type,
|
|
16232
16682
|
values
|
|
16233
16683
|
}));
|
|
16684
|
+
options = selfProducedParseOptions;
|
|
16234
16685
|
}
|
|
16235
16686
|
super(raw, asn1X509.Attribute, options);
|
|
16236
16687
|
}
|
|
@@ -16281,7 +16732,7 @@ var require_x509_cjs = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
16281
16732
|
else {
|
|
16282
16733
|
const extensions = args[0];
|
|
16283
16734
|
const value = new asn1X509__namespace.Extensions();
|
|
16284
|
-
for (const extension of extensions) value.push(asn1Schema.AsnConvert.parse(extension.rawData, asn1X509__namespace.Extension));
|
|
16735
|
+
for (const extension of extensions) value.push(asn1Schema.AsnConvert.parse(extension.rawData, asn1X509__namespace.Extension, selfProducedParseOptions));
|
|
16285
16736
|
super(asnPkcs9__namespace.id_pkcs9_at_extensionRequest, [asn1Schema.AsnConvert.serialize(value)]);
|
|
16286
16737
|
}
|
|
16287
16738
|
(_a = this.items) !== null && _a !== void 0 || (this.items = []);
|
|
@@ -16755,16 +17206,16 @@ var require_x509_cjs = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
16755
17206
|
if (!params.keys.privateKey) throw new Error("Bad field 'keys' in 'params' argument. 'privateKey' is empty");
|
|
16756
17207
|
if (!params.keys.publicKey) throw new Error("Bad field 'keys' in 'params' argument. 'publicKey' is empty");
|
|
16757
17208
|
const spki = await crypto.subtle.exportKey("spki", params.keys.publicKey);
|
|
16758
|
-
const asnReq = new asn1Csr.CertificationRequest({ certificationRequestInfo: new asn1Csr.CertificationRequestInfo({ subjectPKInfo: asn1Schema.AsnConvert.parse(spki, asn1X509.SubjectPublicKeyInfo) }) });
|
|
17209
|
+
const asnReq = new asn1Csr.CertificationRequest({ certificationRequestInfo: new asn1Csr.CertificationRequestInfo({ subjectPKInfo: asn1Schema.AsnConvert.parse(spki, asn1X509.SubjectPublicKeyInfo, selfProducedParseOptions) }) });
|
|
16759
17210
|
if (params.name) {
|
|
16760
17211
|
const name = params.name instanceof Name ? params.name : new Name(params.name);
|
|
16761
|
-
asnReq.certificationRequestInfo.subject = asn1Schema.AsnConvert.parse(name.toArrayBuffer(), asn1X509.Name);
|
|
17212
|
+
asnReq.certificationRequestInfo.subject = asn1Schema.AsnConvert.parse(name.toArrayBuffer(), asn1X509.Name, selfProducedParseOptions);
|
|
16762
17213
|
}
|
|
16763
|
-
if (params.attributes) for (const o of params.attributes) asnReq.certificationRequestInfo.attributes.push(asn1Schema.AsnConvert.parse(o.rawData, asn1X509.Attribute));
|
|
17214
|
+
if (params.attributes) for (const o of params.attributes) asnReq.certificationRequestInfo.attributes.push(asn1Schema.AsnConvert.parse(o.rawData, asn1X509.Attribute, selfProducedParseOptions));
|
|
16764
17215
|
if (params.extensions && params.extensions.length) {
|
|
16765
17216
|
const attr = new asn1X509.Attribute({ type: asnPkcs9.id_pkcs9_at_extensionRequest });
|
|
16766
17217
|
const extensions = new asn1X509.Extensions();
|
|
16767
|
-
for (const o of params.extensions) extensions.push(asn1Schema.AsnConvert.parse(o.rawData, asn1X509.Extension));
|
|
17218
|
+
for (const o of params.extensions) extensions.push(asn1Schema.AsnConvert.parse(o.rawData, asn1X509.Extension, selfProducedParseOptions));
|
|
16768
17219
|
attr.values.push(asn1Schema.AsnConvert.serialize(extensions));
|
|
16769
17220
|
asnReq.certificationRequestInfo.attributes.push(attr);
|
|
16770
17221
|
}
|
|
@@ -16783,34 +17234,9 @@ var require_x509_cjs = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
16783
17234
|
}
|
|
16784
17235
|
if (!asnSignature) throw Error("Cannot convert WebCrypto signature value to ASN.1 format");
|
|
16785
17236
|
asnReq.signature = asnSignature;
|
|
16786
|
-
return new Pkcs10CertificateRequest(asn1Schema.AsnConvert.serialize(asnReq));
|
|
17237
|
+
return new Pkcs10CertificateRequest(asn1Schema.AsnConvert.serialize(asnReq), selfProducedParseOptions);
|
|
16787
17238
|
}
|
|
16788
17239
|
};
|
|
16789
|
-
function toPositiveIntegerOctets(input) {
|
|
16790
|
-
let firstNonZero = 0;
|
|
16791
|
-
while (firstNonZero < input.length - 1 && input[firstNonZero] === 0) firstNonZero++;
|
|
16792
|
-
let serialNumber = input.slice(firstNonZero);
|
|
16793
|
-
if (!serialNumber.length) serialNumber = new Uint8Array([0]);
|
|
16794
|
-
if (serialNumber[0] > 127) {
|
|
16795
|
-
const newSerialNumber = new Uint8Array(serialNumber.length + 1);
|
|
16796
|
-
newSerialNumber[0] = 0;
|
|
16797
|
-
newSerialNumber.set(serialNumber, 1);
|
|
16798
|
-
serialNumber = newSerialNumber;
|
|
16799
|
-
}
|
|
16800
|
-
return serialNumber.buffer;
|
|
16801
|
-
}
|
|
16802
|
-
function normalizeCertificateSerialNumber(input) {
|
|
16803
|
-
return toPositiveIntegerOctets(pvtsutils.BufferSourceConverter.toUint8Array(pvtsutils.Convert.FromHex(input || "")));
|
|
16804
|
-
}
|
|
16805
|
-
function generateCertificateSerialNumber(input, crypto = cryptoProvider.get()) {
|
|
16806
|
-
const inputView = pvtsutils.BufferSourceConverter.toUint8Array(pvtsutils.Convert.FromHex(input || ""));
|
|
16807
|
-
return toPositiveIntegerOctets(inputView.length && inputView.some((o) => o > 0) ? inputView : crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16)));
|
|
16808
|
-
}
|
|
16809
|
-
function getCertificateSerialNumber(raw) {
|
|
16810
|
-
let serialNumber = pvtsutils.BufferSourceConverter.toUint8Array(raw);
|
|
16811
|
-
if (serialNumber.length > 1 && serialNumber[0] === 0 && serialNumber[1] > 127) serialNumber = serialNumber.slice(1);
|
|
16812
|
-
return pvtsutils.Convert.ToHex(serialNumber);
|
|
16813
|
-
}
|
|
16814
17240
|
var _X509Certificate_tbs;
|
|
16815
17241
|
var _X509Certificate_serialNumber;
|
|
16816
17242
|
var _X509Certificate_subjectName;
|
|
@@ -17159,10 +17585,13 @@ var require_x509_cjs = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
17159
17585
|
static async create(params, crypto = cryptoProvider.get()) {
|
|
17160
17586
|
var _a;
|
|
17161
17587
|
let spki;
|
|
17588
|
+
let spkiOptions = selfProducedParseOptions;
|
|
17162
17589
|
if (params.publicKey instanceof PublicKey) spki = params.publicKey.rawData;
|
|
17163
17590
|
else if ("publicKey" in params.publicKey) spki = params.publicKey.publicKey.rawData;
|
|
17164
|
-
else if (pvtsutils.BufferSourceConverter.isBufferSource(params.publicKey))
|
|
17165
|
-
|
|
17591
|
+
else if (pvtsutils.BufferSourceConverter.isBufferSource(params.publicKey)) {
|
|
17592
|
+
spki = params.publicKey;
|
|
17593
|
+
spkiOptions = void 0;
|
|
17594
|
+
} else spki = await crypto.subtle.exportKey("spki", params.publicKey);
|
|
17166
17595
|
const serialNumber = generateCertificateSerialNumber(params.serialNumber, crypto);
|
|
17167
17596
|
const notBefore = params.notBefore || /* @__PURE__ */ new Date();
|
|
17168
17597
|
const notAfter = params.notAfter || new Date(notBefore.getTime() + 31536e6);
|
|
@@ -17173,16 +17602,16 @@ var require_x509_cjs = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
17173
17602
|
notBefore,
|
|
17174
17603
|
notAfter
|
|
17175
17604
|
}),
|
|
17176
|
-
extensions: new asn1X509__namespace.Extensions(((_a = params.extensions) === null || _a === void 0 ? void 0 : _a.map((o) => asn1Schema.AsnConvert.parse(o.rawData, asn1X509__namespace.Extension))) || []),
|
|
17177
|
-
subjectPublicKeyInfo: asn1Schema.AsnConvert.parse(spki, asn1X509__namespace.SubjectPublicKeyInfo)
|
|
17605
|
+
extensions: new asn1X509__namespace.Extensions(((_a = params.extensions) === null || _a === void 0 ? void 0 : _a.map((o) => asn1Schema.AsnConvert.parse(o.rawData, asn1X509__namespace.Extension, selfProducedParseOptions))) || []),
|
|
17606
|
+
subjectPublicKeyInfo: asn1Schema.AsnConvert.parse(spki, asn1X509__namespace.SubjectPublicKeyInfo, spkiOptions)
|
|
17178
17607
|
}) });
|
|
17179
17608
|
if (params.subject) {
|
|
17180
17609
|
const name = params.subject instanceof Name ? params.subject : new Name(params.subject);
|
|
17181
|
-
asnX509.tbsCertificate.subject = asn1Schema.AsnConvert.parse(name.toArrayBuffer(), asn1X509__namespace.Name);
|
|
17610
|
+
asnX509.tbsCertificate.subject = asn1Schema.AsnConvert.parse(name.toArrayBuffer(), asn1X509__namespace.Name, selfProducedParseOptions);
|
|
17182
17611
|
}
|
|
17183
17612
|
if (params.issuer) {
|
|
17184
17613
|
const name = params.issuer instanceof Name ? params.issuer : new Name(params.issuer);
|
|
17185
|
-
asnX509.tbsCertificate.issuer = asn1Schema.AsnConvert.parse(name.toArrayBuffer(), asn1X509__namespace.Name);
|
|
17614
|
+
asnX509.tbsCertificate.issuer = asn1Schema.AsnConvert.parse(name.toArrayBuffer(), asn1X509__namespace.Name, selfProducedParseOptions);
|
|
17186
17615
|
}
|
|
17187
17616
|
const defaultSigningAlgorithm = { hash: "SHA-256" };
|
|
17188
17617
|
const signatureAlgorithm = "signingKey" in params ? {
|
|
@@ -17205,7 +17634,7 @@ var require_x509_cjs = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
17205
17634
|
}
|
|
17206
17635
|
if (!asnSignature) throw Error("Cannot convert ASN.1 signature value to WebCrypto format");
|
|
17207
17636
|
asnX509.signatureValue = asnSignature;
|
|
17208
|
-
return new X509Certificate(asn1Schema.AsnConvert.serialize(asnX509));
|
|
17637
|
+
return new X509Certificate(asn1Schema.AsnConvert.serialize(asnX509), selfProducedParseOptions);
|
|
17209
17638
|
}
|
|
17210
17639
|
};
|
|
17211
17640
|
var _X509CrlEntry_serialNumber;
|
|
@@ -17445,11 +17874,11 @@ var require_x509_cjs = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
17445
17874
|
const name = params.issuer instanceof Name ? params.issuer : new Name(params.issuer);
|
|
17446
17875
|
const asnX509Crl = new asn1X509__namespace.CertificateList({ tbsCertList: new asn1X509__namespace.TBSCertList({
|
|
17447
17876
|
version: asn1X509__namespace.Version.v2,
|
|
17448
|
-
issuer: asn1Schema.AsnConvert.parse(name.toArrayBuffer(), asn1X509__namespace.Name),
|
|
17877
|
+
issuer: asn1Schema.AsnConvert.parse(name.toArrayBuffer(), asn1X509__namespace.Name, selfProducedParseOptions),
|
|
17449
17878
|
thisUpdate: new asn1X509.Time(params.thisUpdate || /* @__PURE__ */ new Date())
|
|
17450
17879
|
}) });
|
|
17451
17880
|
if (params.nextUpdate) asnX509Crl.tbsCertList.nextUpdate = new asn1X509.Time(params.nextUpdate);
|
|
17452
|
-
if (params.extensions && params.extensions.length) asnX509Crl.tbsCertList.crlExtensions = new asn1X509__namespace.Extensions(params.extensions.map((o) => asn1Schema.AsnConvert.parse(o.rawData, asn1X509__namespace.Extension)) || []);
|
|
17881
|
+
if (params.extensions && params.extensions.length) asnX509Crl.tbsCertList.crlExtensions = new asn1X509__namespace.Extensions(params.extensions.map((o) => asn1Schema.AsnConvert.parse(o.rawData, asn1X509__namespace.Extension, selfProducedParseOptions)) || []);
|
|
17453
17882
|
if (params.entries && params.entries.length) {
|
|
17454
17883
|
asnX509Crl.tbsCertList.revokedCertificates = [];
|
|
17455
17884
|
for (const entry of params.entries) {
|
|
@@ -17459,7 +17888,7 @@ var require_x509_cjs = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
17459
17888
|
userCertificate,
|
|
17460
17889
|
revocationDate: new asn1X509.Time(entry.revocationDate || /* @__PURE__ */ new Date())
|
|
17461
17890
|
});
|
|
17462
|
-
if ("extensions" in entry && ((_a = entry.extensions) === null || _a === void 0 ? void 0 : _a.length)) revokedCert.crlEntryExtensions = entry.extensions.map((o) => asn1Schema.AsnConvert.parse(o.rawData, asn1X509__namespace.Extension));
|
|
17891
|
+
if ("extensions" in entry && ((_a = entry.extensions) === null || _a === void 0 ? void 0 : _a.length)) revokedCert.crlEntryExtensions = entry.extensions.map((o) => asn1Schema.AsnConvert.parse(o.rawData, asn1X509__namespace.Extension, selfProducedParseOptions));
|
|
17463
17892
|
else revokedCert.crlEntryExtensions = [];
|
|
17464
17893
|
if (!(entry instanceof X509CrlEntry)) {
|
|
17465
17894
|
if (entry.reason) revokedCert.crlEntryExtensions.push(new asn1X509__namespace.Extension({
|
|
@@ -17477,7 +17906,7 @@ var require_x509_cjs = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
17477
17906
|
revokedCert.crlEntryExtensions.push(new asn1X509__namespace.Extension({
|
|
17478
17907
|
extnID: asn1X509__namespace.id_ce_certificateIssuer,
|
|
17479
17908
|
critical: false,
|
|
17480
|
-
extnValue: new asn1Schema.OctetString(asn1Schema.AsnConvert.serialize(asn1Schema.AsnConvert.parse(name.toArrayBuffer(), asn1X509__namespace.Name)))
|
|
17909
|
+
extnValue: new asn1Schema.OctetString(asn1Schema.AsnConvert.serialize(asn1Schema.AsnConvert.parse(name.toArrayBuffer(), asn1X509__namespace.Name, selfProducedParseOptions)))
|
|
17481
17910
|
}));
|
|
17482
17911
|
}
|
|
17483
17912
|
}
|
|
@@ -17500,7 +17929,7 @@ var require_x509_cjs = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
17500
17929
|
}
|
|
17501
17930
|
if (!asnSignature) throw Error("Cannot convert ASN.1 signature value to WebCrypto format");
|
|
17502
17931
|
asnX509Crl.signature = asnSignature;
|
|
17503
|
-
return new X509Crl(asn1Schema.AsnConvert.serialize(asnX509Crl));
|
|
17932
|
+
return new X509Crl(asn1Schema.AsnConvert.serialize(asnX509Crl), selfProducedParseOptions);
|
|
17504
17933
|
}
|
|
17505
17934
|
};
|
|
17506
17935
|
ExtensionFactory.register(asn1X509__namespace.id_ce_basicConstraints, BasicConstraintsExtension);
|