node-opcua-crypto 5.3.5 → 5.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-CHOBVT6V.cjs → chunk-2DISC7JP.cjs} +23 -23
- package/dist/{chunk-CHOBVT6V.cjs.map → chunk-2DISC7JP.cjs.map} +1 -1
- package/dist/{chunk-ZGFOQAZK.js → chunk-EJK7NCWU.js} +2 -2
- package/dist/{chunk-LRB5Q533.cjs → chunk-FRVYTI7S.cjs} +222 -87
- package/dist/chunk-FRVYTI7S.cjs.map +1 -0
- package/dist/{chunk-JHDYJSUT.js → chunk-NX3DSTD6.js} +214 -79
- package/dist/chunk-NX3DSTD6.js.map +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.js +2 -2
- package/dist/source/index_web.cjs +2 -2
- package/dist/source/index_web.js +1 -1
- package/dist/source_nodejs/index.cjs +3 -3
- package/dist/source_nodejs/index.js +2 -2
- package/package.json +4 -4
- package/dist/chunk-JHDYJSUT.js.map +0 -1
- package/dist/chunk-LRB5Q533.cjs.map +0 -1
- /package/dist/{chunk-ZGFOQAZK.js.map → chunk-EJK7NCWU.js.map} +0 -0
|
@@ -659,7 +659,7 @@ function toPem(raw_key, pem) {
|
|
|
659
659
|
if (parts.length > 1) {
|
|
660
660
|
return parts.map((cert) => toPem(cert, pem)).join("\n");
|
|
661
661
|
}
|
|
662
|
-
} catch (
|
|
662
|
+
} catch (_err) {
|
|
663
663
|
}
|
|
664
664
|
}
|
|
665
665
|
const b = buffer.toString("base64");
|
|
@@ -1978,6 +1978,9 @@ __export(index_es_exports, {
|
|
|
1978
1978
|
Choice: () => Choice,
|
|
1979
1979
|
Constructed: () => Constructed,
|
|
1980
1980
|
DATE: () => DATE,
|
|
1981
|
+
DEFAULT_MAX_CONTENT_LENGTH: () => DEFAULT_MAX_CONTENT_LENGTH,
|
|
1982
|
+
DEFAULT_MAX_DEPTH: () => DEFAULT_MAX_DEPTH,
|
|
1983
|
+
DEFAULT_MAX_NODES: () => DEFAULT_MAX_NODES,
|
|
1981
1984
|
DateTime: () => DateTime,
|
|
1982
1985
|
Duration: () => Duration,
|
|
1983
1986
|
EndOfContent: () => EndOfContent,
|
|
@@ -2558,7 +2561,7 @@ function HexBlock(BaseClass) {
|
|
|
2558
2561
|
this.isHexOnly = (_b = params.isHexOnly) !== null && _b !== void 0 ? _b : false;
|
|
2559
2562
|
this.valueHexView = params.valueHex ? BufferSourceConverter.toUint8Array(params.valueHex) : EMPTY_VIEW;
|
|
2560
2563
|
}
|
|
2561
|
-
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
2564
|
+
fromBER(inputBuffer, inputOffset, inputLength, _context) {
|
|
2562
2565
|
const view = inputBuffer instanceof ArrayBuffer ? new Uint8Array(inputBuffer) : inputBuffer;
|
|
2563
2566
|
if (!checkBufferParams(this, view, inputOffset, inputLength)) {
|
|
2564
2567
|
return -1;
|
|
@@ -2619,7 +2622,7 @@ var LocalBaseBlock = class {
|
|
|
2619
2622
|
};
|
|
2620
2623
|
LocalBaseBlock.NAME = "baseBlock";
|
|
2621
2624
|
var ValueBlock = class extends LocalBaseBlock {
|
|
2622
|
-
fromBER(_inputBuffer, _inputOffset, _inputLength) {
|
|
2625
|
+
fromBER(_inputBuffer, _inputOffset, _inputLength, _context) {
|
|
2623
2626
|
throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'");
|
|
2624
2627
|
}
|
|
2625
2628
|
toBER(_sizeOnly, _writer) {
|
|
@@ -2732,31 +2735,21 @@ var LocalIdentificationBlock = class extends HexBlock(LocalBaseBlock) {
|
|
|
2732
2735
|
this.tagNumber = tagNumberMask;
|
|
2733
2736
|
this.blockLength = 1;
|
|
2734
2737
|
} else {
|
|
2735
|
-
let count =
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
intTagNumberBuffer[count - 1] = intBuffer[count] & 127;
|
|
2740
|
-
count++;
|
|
2741
|
-
if (count >= intBuffer.length) {
|
|
2738
|
+
let count = 0;
|
|
2739
|
+
while (true) {
|
|
2740
|
+
const tagByteIndex = count + 1;
|
|
2741
|
+
if (tagByteIndex >= intBuffer.length) {
|
|
2742
2742
|
this.error = "End of input reached before message was fully decoded";
|
|
2743
2743
|
return -1;
|
|
2744
2744
|
}
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
for (let i = 0; i < intTagNumberBuffer.length; i++)
|
|
2749
|
-
tempBufferView2[i] = intTagNumberBuffer[i];
|
|
2750
|
-
intTagNumberBuffer = this.valueHexView = new Uint8Array(tagNumberBufferMaxLength);
|
|
2751
|
-
}
|
|
2745
|
+
count++;
|
|
2746
|
+
if ((intBuffer[tagByteIndex] & 128) === 0)
|
|
2747
|
+
break;
|
|
2752
2748
|
}
|
|
2753
2749
|
this.blockLength = count + 1;
|
|
2754
|
-
intTagNumberBuffer
|
|
2755
|
-
const tempBufferView = new Uint8Array(count);
|
|
2750
|
+
const intTagNumberBuffer = this.valueHexView = new Uint8Array(count);
|
|
2756
2751
|
for (let i = 0; i < count; i++)
|
|
2757
|
-
|
|
2758
|
-
intTagNumberBuffer = this.valueHexView = new Uint8Array(count);
|
|
2759
|
-
intTagNumberBuffer.set(tempBufferView);
|
|
2752
|
+
intTagNumberBuffer[i] = intBuffer[i + 1] & 127;
|
|
2760
2753
|
if (this.blockLength <= 9)
|
|
2761
2754
|
this.tagNumber = utilFromBase(intTagNumberBuffer, 7);
|
|
2762
2755
|
else {
|
|
@@ -2906,8 +2899,8 @@ var BaseBlock = class extends LocalBaseBlock {
|
|
|
2906
2899
|
this.lenBlock = new LocalLengthBlock(parameters);
|
|
2907
2900
|
this.valueBlock = valueBlockType ? new valueBlockType(parameters) : new ValueBlock(parameters);
|
|
2908
2901
|
}
|
|
2909
|
-
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
2910
|
-
const resultOffset = this.valueBlock.fromBER(inputBuffer, inputOffset, this.lenBlock.isIndefiniteForm ? inputLength : this.lenBlock.length);
|
|
2902
|
+
fromBER(inputBuffer, inputOffset, inputLength, context) {
|
|
2903
|
+
const resultOffset = this.valueBlock.fromBER(inputBuffer, inputOffset, this.lenBlock.isIndefiniteForm ? inputLength : this.lenBlock.length, context);
|
|
2911
2904
|
if (resultOffset === -1) {
|
|
2912
2905
|
this.error = this.valueBlock.error;
|
|
2913
2906
|
return resultOffset;
|
|
@@ -3043,6 +3036,55 @@ _a$w = Primitive;
|
|
|
3043
3036
|
typeStore.Primitive = _a$w;
|
|
3044
3037
|
})();
|
|
3045
3038
|
Primitive.NAME = "PRIMITIVE";
|
|
3039
|
+
var DEFAULT_MAX_DEPTH = 100;
|
|
3040
|
+
var DEFAULT_MAX_NODES = 1e4;
|
|
3041
|
+
var DEFAULT_MAX_CONTENT_LENGTH = 16 * 1024 * 1024;
|
|
3042
|
+
var MAX_DEPTH_EXCEEDED_ERROR = "Maximum ASN.1 nesting depth exceeded";
|
|
3043
|
+
var MAX_NODES_EXCEEDED_ERROR = "Maximum ASN.1 node count exceeded";
|
|
3044
|
+
var MAX_CONTENT_LENGTH_EXCEEDED_ERROR = "Maximum ASN.1 content length exceeded";
|
|
3045
|
+
function createFromBerContext(options = {}) {
|
|
3046
|
+
var _a2, _b, _c;
|
|
3047
|
+
return {
|
|
3048
|
+
depth: 0,
|
|
3049
|
+
maxDepth: (_a2 = options.maxDepth) !== null && _a2 !== void 0 ? _a2 : DEFAULT_MAX_DEPTH,
|
|
3050
|
+
nodesCount: 0,
|
|
3051
|
+
maxNodes: (_b = options.maxNodes) !== null && _b !== void 0 ? _b : DEFAULT_MAX_NODES,
|
|
3052
|
+
maxContentLength: (_c = options.maxContentLength) !== null && _c !== void 0 ? _c : DEFAULT_MAX_CONTENT_LENGTH
|
|
3053
|
+
};
|
|
3054
|
+
}
|
|
3055
|
+
function createErrorResult(error) {
|
|
3056
|
+
const result = new BaseBlock({}, ValueBlock);
|
|
3057
|
+
result.error = error;
|
|
3058
|
+
return {
|
|
3059
|
+
offset: -1,
|
|
3060
|
+
result
|
|
3061
|
+
};
|
|
3062
|
+
}
|
|
3063
|
+
function checkNodesLimit(context) {
|
|
3064
|
+
context.nodesCount += 1;
|
|
3065
|
+
if (context.nodesCount > context.maxNodes) {
|
|
3066
|
+
return MAX_NODES_EXCEEDED_ERROR;
|
|
3067
|
+
}
|
|
3068
|
+
return void 0;
|
|
3069
|
+
}
|
|
3070
|
+
function checkContentLengthLimit(inputLength, context) {
|
|
3071
|
+
if (inputLength > context.maxContentLength) {
|
|
3072
|
+
return MAX_CONTENT_LENGTH_EXCEEDED_ERROR;
|
|
3073
|
+
}
|
|
3074
|
+
return void 0;
|
|
3075
|
+
}
|
|
3076
|
+
function localFromBERWithChildContext(inputBuffer, inputOffset, inputLength, context) {
|
|
3077
|
+
const childDepth = context.depth + 1;
|
|
3078
|
+
if (childDepth > context.maxDepth) {
|
|
3079
|
+
return createErrorResult(MAX_DEPTH_EXCEEDED_ERROR);
|
|
3080
|
+
}
|
|
3081
|
+
context.depth = childDepth;
|
|
3082
|
+
try {
|
|
3083
|
+
return localFromBER(inputBuffer, inputOffset, inputLength, context);
|
|
3084
|
+
} finally {
|
|
3085
|
+
context.depth -= 1;
|
|
3086
|
+
}
|
|
3087
|
+
}
|
|
3046
3088
|
function localChangeType(inputObject, newType) {
|
|
3047
3089
|
if (inputObject instanceof newType) {
|
|
3048
3090
|
return inputObject;
|
|
@@ -3054,7 +3096,7 @@ function localChangeType(inputObject, newType) {
|
|
|
3054
3096
|
newObject.valueBeforeDecodeView = inputObject.valueBeforeDecodeView;
|
|
3055
3097
|
return newObject;
|
|
3056
3098
|
}
|
|
3057
|
-
function localFromBER(inputBuffer, inputOffset = 0, inputLength = inputBuffer.length) {
|
|
3099
|
+
function localFromBER(inputBuffer, inputOffset = 0, inputLength = inputBuffer.length, context = createFromBerContext()) {
|
|
3058
3100
|
const incomingOffset = inputOffset;
|
|
3059
3101
|
let returnObject = new BaseBlock({}, ValueBlock);
|
|
3060
3102
|
const baseBlock = new LocalBaseBlock();
|
|
@@ -3073,6 +3115,14 @@ function localFromBER(inputBuffer, inputOffset = 0, inputLength = inputBuffer.le
|
|
|
3073
3115
|
result: returnObject
|
|
3074
3116
|
};
|
|
3075
3117
|
}
|
|
3118
|
+
const nodesLimitError = checkNodesLimit(context);
|
|
3119
|
+
if (nodesLimitError) {
|
|
3120
|
+
returnObject.error = nodesLimitError;
|
|
3121
|
+
return {
|
|
3122
|
+
offset: -1,
|
|
3123
|
+
result: returnObject
|
|
3124
|
+
};
|
|
3125
|
+
}
|
|
3076
3126
|
let resultOffset = returnObject.idBlock.fromBER(inputBuffer, inputOffset, inputLength);
|
|
3077
3127
|
if (returnObject.idBlock.warnings.length) {
|
|
3078
3128
|
returnObject.warnings.concat(returnObject.idBlock.warnings);
|
|
@@ -3099,6 +3149,15 @@ function localFromBER(inputBuffer, inputOffset = 0, inputLength = inputBuffer.le
|
|
|
3099
3149
|
}
|
|
3100
3150
|
inputOffset = resultOffset;
|
|
3101
3151
|
inputLength -= returnObject.lenBlock.blockLength;
|
|
3152
|
+
const valueLength = returnObject.lenBlock.isIndefiniteForm ? inputLength : returnObject.lenBlock.length;
|
|
3153
|
+
const contentLengthError = checkContentLengthLimit(valueLength, context);
|
|
3154
|
+
if (contentLengthError) {
|
|
3155
|
+
returnObject.error = contentLengthError;
|
|
3156
|
+
return {
|
|
3157
|
+
offset: -1,
|
|
3158
|
+
result: returnObject
|
|
3159
|
+
};
|
|
3160
|
+
}
|
|
3102
3161
|
if (!returnObject.idBlock.isConstructed && returnObject.lenBlock.isIndefiniteForm) {
|
|
3103
3162
|
returnObject.error = "Indefinite length form used for primitive encoding form";
|
|
3104
3163
|
return {
|
|
@@ -3237,14 +3296,14 @@ function localFromBER(inputBuffer, inputOffset = 0, inputLength = inputBuffer.le
|
|
|
3237
3296
|
}
|
|
3238
3297
|
}
|
|
3239
3298
|
returnObject = localChangeType(returnObject, newASN1Type);
|
|
3240
|
-
resultOffset = returnObject.fromBER(inputBuffer, inputOffset,
|
|
3299
|
+
resultOffset = returnObject.fromBER(inputBuffer, inputOffset, valueLength, context);
|
|
3241
3300
|
returnObject.valueBeforeDecodeView = inputBuffer.subarray(incomingOffset, incomingOffset + returnObject.blockLength);
|
|
3242
3301
|
return {
|
|
3243
3302
|
offset: resultOffset,
|
|
3244
3303
|
result: returnObject
|
|
3245
3304
|
};
|
|
3246
3305
|
}
|
|
3247
|
-
function fromBER(inputBuffer) {
|
|
3306
|
+
function fromBER(inputBuffer, options = {}) {
|
|
3248
3307
|
if (!inputBuffer.byteLength) {
|
|
3249
3308
|
const result = new BaseBlock({}, ValueBlock);
|
|
3250
3309
|
result.error = "Input buffer has zero length";
|
|
@@ -3253,7 +3312,7 @@ function fromBER(inputBuffer) {
|
|
|
3253
3312
|
result
|
|
3254
3313
|
};
|
|
3255
3314
|
}
|
|
3256
|
-
return localFromBER(BufferSourceConverter.toUint8Array(inputBuffer).slice(), 0, inputBuffer.byteLength);
|
|
3315
|
+
return localFromBER(BufferSourceConverter.toUint8Array(inputBuffer).slice(), 0, inputBuffer.byteLength, createFromBerContext(options));
|
|
3257
3316
|
}
|
|
3258
3317
|
function checkLen(indefiniteLength, length) {
|
|
3259
3318
|
if (indefiniteLength) {
|
|
@@ -3267,8 +3326,9 @@ var LocalConstructedValueBlock = class extends ValueBlock {
|
|
|
3267
3326
|
this.value = value;
|
|
3268
3327
|
this.isIndefiniteForm = isIndefiniteForm;
|
|
3269
3328
|
}
|
|
3270
|
-
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
3329
|
+
fromBER(inputBuffer, inputOffset, inputLength, context) {
|
|
3271
3330
|
const view = BufferSourceConverter.toUint8Array(inputBuffer);
|
|
3331
|
+
const parseContext = context !== null && context !== void 0 ? context : createFromBerContext();
|
|
3272
3332
|
if (!checkBufferParams(this, view, inputOffset, inputLength)) {
|
|
3273
3333
|
return -1;
|
|
3274
3334
|
}
|
|
@@ -3279,7 +3339,7 @@ var LocalConstructedValueBlock = class extends ValueBlock {
|
|
|
3279
3339
|
}
|
|
3280
3340
|
let currentOffset = inputOffset;
|
|
3281
3341
|
while (checkLen(this.isIndefiniteForm, inputLength) > 0) {
|
|
3282
|
-
const returnObject =
|
|
3342
|
+
const returnObject = localFromBERWithChildContext(view, currentOffset, inputLength, parseContext);
|
|
3283
3343
|
if (returnObject.offset === -1) {
|
|
3284
3344
|
this.error = returnObject.result.error;
|
|
3285
3345
|
this.warnings.concat(returnObject.result.warnings);
|
|
@@ -3331,9 +3391,9 @@ var Constructed = class extends BaseBlock {
|
|
|
3331
3391
|
super(parameters, LocalConstructedValueBlock);
|
|
3332
3392
|
this.idBlock.isConstructed = true;
|
|
3333
3393
|
}
|
|
3334
|
-
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
3394
|
+
fromBER(inputBuffer, inputOffset, inputLength, context) {
|
|
3335
3395
|
this.valueBlock.isIndefiniteForm = this.lenBlock.isIndefiniteForm;
|
|
3336
|
-
const resultOffset = this.valueBlock.fromBER(inputBuffer, inputOffset, this.lenBlock.isIndefiniteForm ? inputLength : this.lenBlock.length);
|
|
3396
|
+
const resultOffset = this.valueBlock.fromBER(inputBuffer, inputOffset, this.lenBlock.isIndefiniteForm ? inputLength : this.lenBlock.length, context);
|
|
3337
3397
|
if (resultOffset === -1) {
|
|
3338
3398
|
this.error = this.valueBlock.error;
|
|
3339
3399
|
return resultOffset;
|
|
@@ -3499,11 +3559,11 @@ var LocalOctetStringValueBlock = class extends HexBlock(LocalConstructedValueBlo
|
|
|
3499
3559
|
super(parameters);
|
|
3500
3560
|
this.isConstructed = isConstructed;
|
|
3501
3561
|
}
|
|
3502
|
-
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
3562
|
+
fromBER(inputBuffer, inputOffset, inputLength, context) {
|
|
3503
3563
|
let resultOffset = 0;
|
|
3504
3564
|
if (this.isConstructed) {
|
|
3505
3565
|
this.isHexOnly = false;
|
|
3506
|
-
resultOffset = LocalConstructedValueBlock.prototype.fromBER.call(this, inputBuffer, inputOffset, inputLength);
|
|
3566
|
+
resultOffset = LocalConstructedValueBlock.prototype.fromBER.call(this, inputBuffer, inputOffset, inputLength, context);
|
|
3507
3567
|
if (resultOffset === -1)
|
|
3508
3568
|
return resultOffset;
|
|
3509
3569
|
for (let i = 0; i < this.value.length; i++) {
|
|
@@ -3560,7 +3620,7 @@ var OctetString = class extends BaseBlock {
|
|
|
3560
3620
|
this.idBlock.tagClass = 1;
|
|
3561
3621
|
this.idBlock.tagNumber = 4;
|
|
3562
3622
|
}
|
|
3563
|
-
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
3623
|
+
fromBER(inputBuffer, inputOffset, inputLength, context) {
|
|
3564
3624
|
this.valueBlock.isConstructed = this.idBlock.isConstructed;
|
|
3565
3625
|
this.valueBlock.isIndefiniteForm = this.lenBlock.isIndefiniteForm;
|
|
3566
3626
|
if (inputLength === 0) {
|
|
@@ -3575,7 +3635,8 @@ var OctetString = class extends BaseBlock {
|
|
|
3575
3635
|
const buf = view.subarray(inputOffset, inputOffset + inputLength);
|
|
3576
3636
|
try {
|
|
3577
3637
|
if (buf.byteLength) {
|
|
3578
|
-
const
|
|
3638
|
+
const parseContext = context !== null && context !== void 0 ? context : createFromBerContext();
|
|
3639
|
+
const asn = localFromBERWithChildContext(buf, 0, buf.byteLength, parseContext);
|
|
3579
3640
|
if (asn.offset !== -1 && asn.offset === inputLength) {
|
|
3580
3641
|
this.valueBlock.value = [asn.result];
|
|
3581
3642
|
}
|
|
@@ -3583,7 +3644,7 @@ var OctetString = class extends BaseBlock {
|
|
|
3583
3644
|
} catch {
|
|
3584
3645
|
}
|
|
3585
3646
|
}
|
|
3586
|
-
return super.fromBER(inputBuffer, inputOffset, inputLength);
|
|
3647
|
+
return super.fromBER(inputBuffer, inputOffset, inputLength, context);
|
|
3587
3648
|
}
|
|
3588
3649
|
onAsciiEncoding() {
|
|
3589
3650
|
if (this.valueBlock.isConstructed || this.valueBlock.value && this.valueBlock.value.length) {
|
|
@@ -3618,13 +3679,13 @@ var LocalBitStringValueBlock = class extends HexBlock(LocalConstructedValueBlock
|
|
|
3618
3679
|
this.isConstructed = isConstructed;
|
|
3619
3680
|
this.blockLength = this.valueHexView.byteLength;
|
|
3620
3681
|
}
|
|
3621
|
-
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
3682
|
+
fromBER(inputBuffer, inputOffset, inputLength, context) {
|
|
3622
3683
|
if (!inputLength) {
|
|
3623
3684
|
return inputOffset;
|
|
3624
3685
|
}
|
|
3625
3686
|
let resultOffset = -1;
|
|
3626
3687
|
if (this.isConstructed) {
|
|
3627
|
-
resultOffset = LocalConstructedValueBlock.prototype.fromBER.call(this, inputBuffer, inputOffset, inputLength);
|
|
3688
|
+
resultOffset = LocalConstructedValueBlock.prototype.fromBER.call(this, inputBuffer, inputOffset, inputLength, context);
|
|
3628
3689
|
if (resultOffset === -1)
|
|
3629
3690
|
return resultOffset;
|
|
3630
3691
|
for (const value of this.value) {
|
|
@@ -3664,7 +3725,8 @@ var LocalBitStringValueBlock = class extends HexBlock(LocalConstructedValueBlock
|
|
|
3664
3725
|
const buf = intBuffer.subarray(1);
|
|
3665
3726
|
try {
|
|
3666
3727
|
if (buf.byteLength) {
|
|
3667
|
-
const
|
|
3728
|
+
const parseContext = context !== null && context !== void 0 ? context : createFromBerContext();
|
|
3729
|
+
const asn = localFromBERWithChildContext(buf, 0, buf.byteLength, parseContext);
|
|
3668
3730
|
if (asn.offset !== -1 && asn.offset === inputLength - 1) {
|
|
3669
3731
|
this.value = [asn.result];
|
|
3670
3732
|
}
|
|
@@ -3721,10 +3783,10 @@ var BitString = class extends BaseBlock {
|
|
|
3721
3783
|
this.idBlock.tagClass = 1;
|
|
3722
3784
|
this.idBlock.tagNumber = 3;
|
|
3723
3785
|
}
|
|
3724
|
-
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
3786
|
+
fromBER(inputBuffer, inputOffset, inputLength, context) {
|
|
3725
3787
|
this.valueBlock.isConstructed = this.idBlock.isConstructed;
|
|
3726
3788
|
this.valueBlock.isIndefiniteForm = this.lenBlock.isIndefiniteForm;
|
|
3727
|
-
return super.fromBER(inputBuffer, inputOffset, inputLength);
|
|
3789
|
+
return super.fromBER(inputBuffer, inputOffset, inputLength, context);
|
|
3728
3790
|
}
|
|
3729
3791
|
onAsciiEncoding() {
|
|
3730
3792
|
if (this.valueBlock.isConstructed || this.valueBlock.value && this.valueBlock.value.length) {
|
|
@@ -5451,6 +5513,59 @@ function verifySchema(inputBuffer, inputSchema) {
|
|
|
5451
5513
|
return compareSchema(asn12.result, asn12.result, inputSchema);
|
|
5452
5514
|
}
|
|
5453
5515
|
|
|
5516
|
+
// ../../node_modules/@peculiar/utils/build/esm/bytes/buffer-source.js
|
|
5517
|
+
var ARRAY_BUFFER_TAG = "[object ArrayBuffer]";
|
|
5518
|
+
var SHARED_ARRAY_BUFFER_TAG = "[object SharedArrayBuffer]";
|
|
5519
|
+
function tagOf(value) {
|
|
5520
|
+
return Object.prototype.toString.call(value);
|
|
5521
|
+
}
|
|
5522
|
+
function isArrayBufferViewLike(value) {
|
|
5523
|
+
if (ArrayBuffer.isView(value)) {
|
|
5524
|
+
return true;
|
|
5525
|
+
}
|
|
5526
|
+
if (!value || typeof value !== "object") {
|
|
5527
|
+
return false;
|
|
5528
|
+
}
|
|
5529
|
+
const view = value;
|
|
5530
|
+
return typeof view.byteOffset === "number" && typeof view.byteLength === "number" && isArrayBufferLike(view.buffer);
|
|
5531
|
+
}
|
|
5532
|
+
function isArrayBuffer(value) {
|
|
5533
|
+
return tagOf(value) === ARRAY_BUFFER_TAG;
|
|
5534
|
+
}
|
|
5535
|
+
function isSharedArrayBuffer(value) {
|
|
5536
|
+
return typeof SharedArrayBuffer !== "undefined" && tagOf(value) === SHARED_ARRAY_BUFFER_TAG;
|
|
5537
|
+
}
|
|
5538
|
+
function isArrayBufferLike(value) {
|
|
5539
|
+
return isArrayBuffer(value) || isSharedArrayBuffer(value);
|
|
5540
|
+
}
|
|
5541
|
+
function isArrayBufferView(value) {
|
|
5542
|
+
return isArrayBufferViewLike(value);
|
|
5543
|
+
}
|
|
5544
|
+
function isBufferSource(value) {
|
|
5545
|
+
return isArrayBufferLike(value) || isArrayBufferView(value);
|
|
5546
|
+
}
|
|
5547
|
+
function assertBufferSource(value) {
|
|
5548
|
+
if (!isBufferSource(value)) {
|
|
5549
|
+
throw new TypeError("Expected ArrayBuffer, SharedArrayBuffer, or ArrayBufferView");
|
|
5550
|
+
}
|
|
5551
|
+
}
|
|
5552
|
+
function toUint8Array(data) {
|
|
5553
|
+
assertBufferSource(data);
|
|
5554
|
+
if (isArrayBufferLike(data)) {
|
|
5555
|
+
return new Uint8Array(data);
|
|
5556
|
+
}
|
|
5557
|
+
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
5558
|
+
}
|
|
5559
|
+
function toArrayBuffer(data) {
|
|
5560
|
+
assertBufferSource(data);
|
|
5561
|
+
if (isArrayBuffer(data)) {
|
|
5562
|
+
return data;
|
|
5563
|
+
}
|
|
5564
|
+
const buffer = new ArrayBuffer(data.byteLength);
|
|
5565
|
+
new Uint8Array(buffer).set(toUint8Array(data));
|
|
5566
|
+
return buffer;
|
|
5567
|
+
}
|
|
5568
|
+
|
|
5454
5569
|
// ../../node_modules/@peculiar/asn1-schema/build/es2015/enums.js
|
|
5455
5570
|
var AsnTypeTypes;
|
|
5456
5571
|
(function(AsnTypeTypes2) {
|
|
@@ -5491,7 +5606,7 @@ var AsnPropTypes;
|
|
|
5491
5606
|
|
|
5492
5607
|
// ../../node_modules/@peculiar/asn1-schema/build/es2015/converters.js
|
|
5493
5608
|
var AsnAnyConverter = {
|
|
5494
|
-
fromASN: (value) => value instanceof Null ? null : value.valueBeforeDecodeView,
|
|
5609
|
+
fromASN: (value) => value instanceof Null ? null : toArrayBuffer(value.valueBeforeDecodeView),
|
|
5495
5610
|
toASN: (value) => {
|
|
5496
5611
|
if (value === null) {
|
|
5497
5612
|
return new Null();
|
|
@@ -5512,7 +5627,7 @@ var AsnEnumeratedConverter = {
|
|
|
5512
5627
|
toASN: (value) => new Enumerated({ value })
|
|
5513
5628
|
};
|
|
5514
5629
|
var AsnBitStringConverter = {
|
|
5515
|
-
fromASN: (value) => value.valueBlock.valueHexView,
|
|
5630
|
+
fromASN: (value) => toArrayBuffer(value.valueBlock.valueHexView),
|
|
5516
5631
|
toASN: (value) => new BitString({ valueHex: value })
|
|
5517
5632
|
};
|
|
5518
5633
|
var AsnObjectIdentifierConverter = {
|
|
@@ -5524,7 +5639,7 @@ var AsnBooleanConverter = {
|
|
|
5524
5639
|
toASN: (value) => new Boolean({ value })
|
|
5525
5640
|
};
|
|
5526
5641
|
var AsnOctetStringConverter = {
|
|
5527
|
-
fromASN: (value) => value.valueBlock.valueHexView,
|
|
5642
|
+
fromASN: (value) => toArrayBuffer(value.valueBlock.valueHexView),
|
|
5528
5643
|
toASN: (value) => new OctetString({ valueHex: value })
|
|
5529
5644
|
};
|
|
5530
5645
|
function createStringConverter(Asn1Type) {
|
|
@@ -5623,10 +5738,9 @@ function isConvertible(target) {
|
|
|
5623
5738
|
}
|
|
5624
5739
|
}
|
|
5625
5740
|
function isTypeOfArray(target) {
|
|
5626
|
-
var _a2;
|
|
5627
5741
|
if (target) {
|
|
5628
5742
|
const proto = Object.getPrototypeOf(target);
|
|
5629
|
-
if (
|
|
5743
|
+
if (proto?.prototype?.constructor === Array) {
|
|
5630
5744
|
return true;
|
|
5631
5745
|
}
|
|
5632
5746
|
return isTypeOfArray(proto);
|
|
@@ -5652,9 +5766,7 @@ function isArrayEqual(bytes1, bytes2) {
|
|
|
5652
5766
|
|
|
5653
5767
|
// ../../node_modules/@peculiar/asn1-schema/build/es2015/schema.js
|
|
5654
5768
|
var AsnSchemaStorage = class {
|
|
5655
|
-
|
|
5656
|
-
this.items = /* @__PURE__ */ new WeakMap();
|
|
5657
|
-
}
|
|
5769
|
+
items = /* @__PURE__ */ new WeakMap();
|
|
5658
5770
|
has(target) {
|
|
5659
5771
|
return this.items.has(target);
|
|
5660
5772
|
}
|
|
@@ -5675,7 +5787,10 @@ var AsnSchemaStorage = class {
|
|
|
5675
5787
|
}
|
|
5676
5788
|
}
|
|
5677
5789
|
createDefault(target) {
|
|
5678
|
-
const schema = {
|
|
5790
|
+
const schema = {
|
|
5791
|
+
type: AsnTypeTypes.Sequence,
|
|
5792
|
+
items: {}
|
|
5793
|
+
};
|
|
5679
5794
|
const parentSchema = this.findParentSchema(target);
|
|
5680
5795
|
if (parentSchema) {
|
|
5681
5796
|
Object.assign(schema, parentSchema);
|
|
@@ -5717,14 +5832,24 @@ var AsnSchemaStorage = class {
|
|
|
5717
5832
|
const Container = item.repeated === "set" ? Set : Sequence;
|
|
5718
5833
|
asn1Item = new Container({
|
|
5719
5834
|
name: "",
|
|
5720
|
-
value: [new Repeated({
|
|
5835
|
+
value: [new Repeated({
|
|
5836
|
+
name,
|
|
5837
|
+
value: asn1Item
|
|
5838
|
+
})]
|
|
5721
5839
|
});
|
|
5722
5840
|
}
|
|
5723
5841
|
if (item.context !== null && item.context !== void 0) {
|
|
5724
5842
|
if (item.implicit) {
|
|
5725
5843
|
if (typeof item.type === "number" || isConvertible(item.type)) {
|
|
5726
5844
|
const Container = item.repeated ? Constructed : Primitive;
|
|
5727
|
-
asn1Value.push(new Container({
|
|
5845
|
+
asn1Value.push(new Container({
|
|
5846
|
+
name,
|
|
5847
|
+
optional,
|
|
5848
|
+
idBlock: {
|
|
5849
|
+
tagClass: 3,
|
|
5850
|
+
tagNumber: item.context
|
|
5851
|
+
}
|
|
5852
|
+
}));
|
|
5728
5853
|
} else {
|
|
5729
5854
|
this.cache(item.type);
|
|
5730
5855
|
const isRepeated = !!item.repeated;
|
|
@@ -5733,14 +5858,20 @@ var AsnSchemaStorage = class {
|
|
|
5733
5858
|
asn1Value.push(new Constructed({
|
|
5734
5859
|
name: !isRepeated ? name : "",
|
|
5735
5860
|
optional,
|
|
5736
|
-
idBlock: {
|
|
5861
|
+
idBlock: {
|
|
5862
|
+
tagClass: 3,
|
|
5863
|
+
tagNumber: item.context
|
|
5864
|
+
},
|
|
5737
5865
|
value
|
|
5738
5866
|
}));
|
|
5739
5867
|
}
|
|
5740
5868
|
} else {
|
|
5741
5869
|
asn1Value.push(new Constructed({
|
|
5742
5870
|
optional,
|
|
5743
|
-
idBlock: {
|
|
5871
|
+
idBlock: {
|
|
5872
|
+
tagClass: 3,
|
|
5873
|
+
tagNumber: item.context
|
|
5874
|
+
},
|
|
5744
5875
|
value: [asn1Item]
|
|
5745
5876
|
}));
|
|
5746
5877
|
}
|
|
@@ -5751,13 +5882,22 @@ var AsnSchemaStorage = class {
|
|
|
5751
5882
|
}
|
|
5752
5883
|
switch (schema.type) {
|
|
5753
5884
|
case AsnTypeTypes.Sequence:
|
|
5754
|
-
return new Sequence({
|
|
5885
|
+
return new Sequence({
|
|
5886
|
+
value: asn1Value,
|
|
5887
|
+
name: ""
|
|
5888
|
+
});
|
|
5755
5889
|
case AsnTypeTypes.Set:
|
|
5756
|
-
return new Set({
|
|
5890
|
+
return new Set({
|
|
5891
|
+
value: asn1Value,
|
|
5892
|
+
name: ""
|
|
5893
|
+
});
|
|
5757
5894
|
case AsnTypeTypes.Choice:
|
|
5758
|
-
return new Choice({
|
|
5895
|
+
return new Choice({
|
|
5896
|
+
value: asn1Value,
|
|
5897
|
+
name: ""
|
|
5898
|
+
});
|
|
5759
5899
|
default:
|
|
5760
|
-
throw new Error(
|
|
5900
|
+
throw new Error("Unsupported ASN1 type in use");
|
|
5761
5901
|
}
|
|
5762
5902
|
}
|
|
5763
5903
|
set(target, schema) {
|
|
@@ -5779,16 +5919,13 @@ var schemaStorage = new AsnSchemaStorage();
|
|
|
5779
5919
|
|
|
5780
5920
|
// ../../node_modules/@peculiar/asn1-schema/build/es2015/errors/schema_validation.js
|
|
5781
5921
|
var AsnSchemaValidationError = class extends Error {
|
|
5782
|
-
|
|
5783
|
-
super(...arguments);
|
|
5784
|
-
this.schemas = [];
|
|
5785
|
-
}
|
|
5922
|
+
schemas = [];
|
|
5786
5923
|
};
|
|
5787
5924
|
|
|
5788
5925
|
// ../../node_modules/@peculiar/asn1-schema/build/es2015/parser.js
|
|
5789
5926
|
var AsnParser = class {
|
|
5790
5927
|
static parse(data, target) {
|
|
5791
|
-
const asn1Parsed = fromBER(data);
|
|
5928
|
+
const asn1Parsed = fromBER(toArrayBuffer(data));
|
|
5792
5929
|
if (asn1Parsed.result.error) {
|
|
5793
5930
|
throw new Error(asn1Parsed.result.error);
|
|
5794
5931
|
}
|
|
@@ -5805,10 +5942,10 @@ var AsnParser = class {
|
|
|
5805
5942
|
schemaStorage.cache(target);
|
|
5806
5943
|
let targetSchema = schema.schema;
|
|
5807
5944
|
const choiceResult = this.handleChoiceTypes(asn1Schema, schema, target, targetSchema);
|
|
5808
|
-
if (choiceResult
|
|
5945
|
+
if (choiceResult?.result) {
|
|
5809
5946
|
return choiceResult.result;
|
|
5810
5947
|
}
|
|
5811
|
-
if (choiceResult
|
|
5948
|
+
if (choiceResult?.targetSchema) {
|
|
5812
5949
|
targetSchema = choiceResult.targetSchema;
|
|
5813
5950
|
}
|
|
5814
5951
|
const sequenceResult = this.handleSequenceTypes(asn1Schema, schema, target, targetSchema);
|
|
@@ -5916,7 +6053,10 @@ var AsnParser = class {
|
|
|
5916
6053
|
static processOptionalChoiceField(asn1Element, schemaItem) {
|
|
5917
6054
|
try {
|
|
5918
6055
|
const value = this.fromASN(asn1Element, schemaItem.type);
|
|
5919
|
-
return {
|
|
6056
|
+
return {
|
|
6057
|
+
processed: true,
|
|
6058
|
+
value
|
|
6059
|
+
};
|
|
5920
6060
|
} catch (err) {
|
|
5921
6061
|
if (err instanceof AsnSchemaValidationError && /Wrong values for Choice type/.test(err.message)) {
|
|
5922
6062
|
return { processed: false };
|
|
@@ -5926,7 +6066,7 @@ var AsnParser = class {
|
|
|
5926
6066
|
}
|
|
5927
6067
|
static handleArrayTypes(asn1Schema, schema, target) {
|
|
5928
6068
|
if (!("value" in asn1Schema.valueBlock && Array.isArray(asn1Schema.valueBlock.value))) {
|
|
5929
|
-
throw new Error(
|
|
6069
|
+
throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");
|
|
5930
6070
|
}
|
|
5931
6071
|
const itemType = schema.itemType;
|
|
5932
6072
|
if (typeof itemType === "number") {
|
|
@@ -5962,8 +6102,7 @@ var AsnParser = class {
|
|
|
5962
6102
|
}
|
|
5963
6103
|
}
|
|
5964
6104
|
static processPrimitiveSchemaItem(asn1SchemaValue, schemaItem, schemaItemType) {
|
|
5965
|
-
|
|
5966
|
-
const converter = (_a2 = schemaItem.converter) !== null && _a2 !== void 0 ? _a2 : isConvertible(schemaItemType) ? new schemaItemType() : null;
|
|
6105
|
+
const converter = schemaItem.converter ?? (isConvertible(schemaItemType) ? new schemaItemType() : null);
|
|
5967
6106
|
if (!converter) {
|
|
5968
6107
|
throw new Error("Converter is empty");
|
|
5969
6108
|
}
|
|
@@ -6104,7 +6243,7 @@ var AsnSerializer = class _AsnSerializer {
|
|
|
6104
6243
|
if (schemaItem.implicit) {
|
|
6105
6244
|
if (!schemaItem.repeated && (typeof schemaItem.type === "number" || isConvertible(schemaItem.type))) {
|
|
6106
6245
|
const value = {};
|
|
6107
|
-
value.valueHex = asn1Item instanceof Null ? asn1Item.valueBeforeDecodeView : asn1Item.valueBlock.toBER();
|
|
6246
|
+
value.valueHex = asn1Item instanceof Null ? toArrayBuffer(asn1Item.valueBeforeDecodeView) : asn1Item.valueBlock.toBER();
|
|
6108
6247
|
asn1Value.push(new Primitive({
|
|
6109
6248
|
optional: schemaItem.optional,
|
|
6110
6249
|
idBlock: {
|
|
@@ -6170,9 +6309,7 @@ var AsnSerializer = class _AsnSerializer {
|
|
|
6170
6309
|
}
|
|
6171
6310
|
const items = Array.from(objProp, (element) => converter.toASN(element));
|
|
6172
6311
|
const Container = schemaItem.repeated === "sequence" ? Sequence : Set;
|
|
6173
|
-
asn1Item = new Container({
|
|
6174
|
-
value: items
|
|
6175
|
-
});
|
|
6312
|
+
asn1Item = new Container({ value: items });
|
|
6176
6313
|
} else {
|
|
6177
6314
|
asn1Item = converter.toASN(objProp);
|
|
6178
6315
|
}
|
|
@@ -6183,9 +6320,7 @@ var AsnSerializer = class _AsnSerializer {
|
|
|
6183
6320
|
}
|
|
6184
6321
|
const items = Array.from(objProp, (element) => this.toASN(element));
|
|
6185
6322
|
const Container = schemaItem.repeated === "sequence" ? Sequence : Set;
|
|
6186
|
-
asn1Item = new Container({
|
|
6187
|
-
value: items
|
|
6188
|
-
});
|
|
6323
|
+
asn1Item = new Container({ value: items });
|
|
6189
6324
|
} else {
|
|
6190
6325
|
asn1Item = this.toASN(objProp);
|
|
6191
6326
|
}
|
|
@@ -6203,7 +6338,7 @@ var AsnConvert = class _AsnConvert {
|
|
|
6203
6338
|
return AsnParser.parse(data, target);
|
|
6204
6339
|
}
|
|
6205
6340
|
static toString(data) {
|
|
6206
|
-
const buf =
|
|
6341
|
+
const buf = isBufferSource(data) ? toArrayBuffer(data) : _AsnConvert.serialize(data);
|
|
6207
6342
|
const asn = fromBER(buf);
|
|
6208
6343
|
if (asn.offset === -1) {
|
|
6209
6344
|
throw new Error(`Cannot decode ASN.1 data. ${asn.result.error}`);
|
|
@@ -6642,4 +6777,4 @@ asn1js/build/index.es.js:
|
|
|
6642
6777
|
*
|
|
6643
6778
|
*)
|
|
6644
6779
|
*/
|
|
6645
|
-
//# sourceMappingURL=chunk-
|
|
6780
|
+
//# sourceMappingURL=chunk-NX3DSTD6.js.map
|