node-opcua-crypto 5.3.4 → 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-XDS5YIBC.cjs → chunk-2DISC7JP.cjs} +31 -23
- package/dist/chunk-2DISC7JP.cjs.map +1 -0
- package/dist/{chunk-ULNIL7FF.js → chunk-EJK7NCWU.js} +11 -3
- package/dist/chunk-EJK7NCWU.js.map +1 -0
- package/dist/{chunk-AZUYUXWD.cjs → chunk-FRVYTI7S.cjs} +232 -87
- package/dist/chunk-FRVYTI7S.cjs.map +1 -0
- package/dist/{chunk-P5QLLSP2.js → chunk-NX3DSTD6.js} +224 -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-AZUYUXWD.cjs.map +0 -1
- package/dist/chunk-P5QLLSP2.js.map +0 -1
- package/dist/chunk-ULNIL7FF.js.map +0 -1
- package/dist/chunk-XDS5YIBC.cjs.map +0 -1
|
@@ -652,7 +652,17 @@ function toPem(raw_key, pem) {
|
|
|
652
652
|
} else {
|
|
653
653
|
pemType = pem;
|
|
654
654
|
assert2(["CERTIFICATE REQUEST", "CERTIFICATE", "RSA PRIVATE KEY", "PUBLIC KEY", "X509 CRL"].indexOf(pemType) >= 0);
|
|
655
|
-
const
|
|
655
|
+
const buffer = raw_key;
|
|
656
|
+
if (pemType === "CERTIFICATE" && buffer.length > 0) {
|
|
657
|
+
try {
|
|
658
|
+
const parts = split_der(buffer);
|
|
659
|
+
if (parts.length > 1) {
|
|
660
|
+
return parts.map((cert) => toPem(cert, pem)).join("\n");
|
|
661
|
+
}
|
|
662
|
+
} catch (_err) {
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
const b = buffer.toString("base64");
|
|
656
666
|
const strBody = b.match(/.{1,64}/g)?.join("\n") || "";
|
|
657
667
|
return `-----BEGIN ${pemType}-----
|
|
658
668
|
${strBody}
|
|
@@ -1968,6 +1978,9 @@ __export(index_es_exports, {
|
|
|
1968
1978
|
Choice: () => Choice,
|
|
1969
1979
|
Constructed: () => Constructed,
|
|
1970
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,
|
|
1971
1984
|
DateTime: () => DateTime,
|
|
1972
1985
|
Duration: () => Duration,
|
|
1973
1986
|
EndOfContent: () => EndOfContent,
|
|
@@ -2548,7 +2561,7 @@ function HexBlock(BaseClass) {
|
|
|
2548
2561
|
this.isHexOnly = (_b = params.isHexOnly) !== null && _b !== void 0 ? _b : false;
|
|
2549
2562
|
this.valueHexView = params.valueHex ? BufferSourceConverter.toUint8Array(params.valueHex) : EMPTY_VIEW;
|
|
2550
2563
|
}
|
|
2551
|
-
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
2564
|
+
fromBER(inputBuffer, inputOffset, inputLength, _context) {
|
|
2552
2565
|
const view = inputBuffer instanceof ArrayBuffer ? new Uint8Array(inputBuffer) : inputBuffer;
|
|
2553
2566
|
if (!checkBufferParams(this, view, inputOffset, inputLength)) {
|
|
2554
2567
|
return -1;
|
|
@@ -2609,7 +2622,7 @@ var LocalBaseBlock = class {
|
|
|
2609
2622
|
};
|
|
2610
2623
|
LocalBaseBlock.NAME = "baseBlock";
|
|
2611
2624
|
var ValueBlock = class extends LocalBaseBlock {
|
|
2612
|
-
fromBER(_inputBuffer, _inputOffset, _inputLength) {
|
|
2625
|
+
fromBER(_inputBuffer, _inputOffset, _inputLength, _context) {
|
|
2613
2626
|
throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'");
|
|
2614
2627
|
}
|
|
2615
2628
|
toBER(_sizeOnly, _writer) {
|
|
@@ -2722,31 +2735,21 @@ var LocalIdentificationBlock = class extends HexBlock(LocalBaseBlock) {
|
|
|
2722
2735
|
this.tagNumber = tagNumberMask;
|
|
2723
2736
|
this.blockLength = 1;
|
|
2724
2737
|
} else {
|
|
2725
|
-
let count =
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
intTagNumberBuffer[count - 1] = intBuffer[count] & 127;
|
|
2730
|
-
count++;
|
|
2731
|
-
if (count >= intBuffer.length) {
|
|
2738
|
+
let count = 0;
|
|
2739
|
+
while (true) {
|
|
2740
|
+
const tagByteIndex = count + 1;
|
|
2741
|
+
if (tagByteIndex >= intBuffer.length) {
|
|
2732
2742
|
this.error = "End of input reached before message was fully decoded";
|
|
2733
2743
|
return -1;
|
|
2734
2744
|
}
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
for (let i = 0; i < intTagNumberBuffer.length; i++)
|
|
2739
|
-
tempBufferView2[i] = intTagNumberBuffer[i];
|
|
2740
|
-
intTagNumberBuffer = this.valueHexView = new Uint8Array(tagNumberBufferMaxLength);
|
|
2741
|
-
}
|
|
2745
|
+
count++;
|
|
2746
|
+
if ((intBuffer[tagByteIndex] & 128) === 0)
|
|
2747
|
+
break;
|
|
2742
2748
|
}
|
|
2743
2749
|
this.blockLength = count + 1;
|
|
2744
|
-
intTagNumberBuffer
|
|
2745
|
-
const tempBufferView = new Uint8Array(count);
|
|
2750
|
+
const intTagNumberBuffer = this.valueHexView = new Uint8Array(count);
|
|
2746
2751
|
for (let i = 0; i < count; i++)
|
|
2747
|
-
|
|
2748
|
-
intTagNumberBuffer = this.valueHexView = new Uint8Array(count);
|
|
2749
|
-
intTagNumberBuffer.set(tempBufferView);
|
|
2752
|
+
intTagNumberBuffer[i] = intBuffer[i + 1] & 127;
|
|
2750
2753
|
if (this.blockLength <= 9)
|
|
2751
2754
|
this.tagNumber = utilFromBase(intTagNumberBuffer, 7);
|
|
2752
2755
|
else {
|
|
@@ -2896,8 +2899,8 @@ var BaseBlock = class extends LocalBaseBlock {
|
|
|
2896
2899
|
this.lenBlock = new LocalLengthBlock(parameters);
|
|
2897
2900
|
this.valueBlock = valueBlockType ? new valueBlockType(parameters) : new ValueBlock(parameters);
|
|
2898
2901
|
}
|
|
2899
|
-
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
2900
|
-
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);
|
|
2901
2904
|
if (resultOffset === -1) {
|
|
2902
2905
|
this.error = this.valueBlock.error;
|
|
2903
2906
|
return resultOffset;
|
|
@@ -3033,6 +3036,55 @@ _a$w = Primitive;
|
|
|
3033
3036
|
typeStore.Primitive = _a$w;
|
|
3034
3037
|
})();
|
|
3035
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
|
+
}
|
|
3036
3088
|
function localChangeType(inputObject, newType) {
|
|
3037
3089
|
if (inputObject instanceof newType) {
|
|
3038
3090
|
return inputObject;
|
|
@@ -3044,7 +3096,7 @@ function localChangeType(inputObject, newType) {
|
|
|
3044
3096
|
newObject.valueBeforeDecodeView = inputObject.valueBeforeDecodeView;
|
|
3045
3097
|
return newObject;
|
|
3046
3098
|
}
|
|
3047
|
-
function localFromBER(inputBuffer, inputOffset = 0, inputLength = inputBuffer.length) {
|
|
3099
|
+
function localFromBER(inputBuffer, inputOffset = 0, inputLength = inputBuffer.length, context = createFromBerContext()) {
|
|
3048
3100
|
const incomingOffset = inputOffset;
|
|
3049
3101
|
let returnObject = new BaseBlock({}, ValueBlock);
|
|
3050
3102
|
const baseBlock = new LocalBaseBlock();
|
|
@@ -3063,6 +3115,14 @@ function localFromBER(inputBuffer, inputOffset = 0, inputLength = inputBuffer.le
|
|
|
3063
3115
|
result: returnObject
|
|
3064
3116
|
};
|
|
3065
3117
|
}
|
|
3118
|
+
const nodesLimitError = checkNodesLimit(context);
|
|
3119
|
+
if (nodesLimitError) {
|
|
3120
|
+
returnObject.error = nodesLimitError;
|
|
3121
|
+
return {
|
|
3122
|
+
offset: -1,
|
|
3123
|
+
result: returnObject
|
|
3124
|
+
};
|
|
3125
|
+
}
|
|
3066
3126
|
let resultOffset = returnObject.idBlock.fromBER(inputBuffer, inputOffset, inputLength);
|
|
3067
3127
|
if (returnObject.idBlock.warnings.length) {
|
|
3068
3128
|
returnObject.warnings.concat(returnObject.idBlock.warnings);
|
|
@@ -3089,6 +3149,15 @@ function localFromBER(inputBuffer, inputOffset = 0, inputLength = inputBuffer.le
|
|
|
3089
3149
|
}
|
|
3090
3150
|
inputOffset = resultOffset;
|
|
3091
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
|
+
}
|
|
3092
3161
|
if (!returnObject.idBlock.isConstructed && returnObject.lenBlock.isIndefiniteForm) {
|
|
3093
3162
|
returnObject.error = "Indefinite length form used for primitive encoding form";
|
|
3094
3163
|
return {
|
|
@@ -3227,14 +3296,14 @@ function localFromBER(inputBuffer, inputOffset = 0, inputLength = inputBuffer.le
|
|
|
3227
3296
|
}
|
|
3228
3297
|
}
|
|
3229
3298
|
returnObject = localChangeType(returnObject, newASN1Type);
|
|
3230
|
-
resultOffset = returnObject.fromBER(inputBuffer, inputOffset,
|
|
3299
|
+
resultOffset = returnObject.fromBER(inputBuffer, inputOffset, valueLength, context);
|
|
3231
3300
|
returnObject.valueBeforeDecodeView = inputBuffer.subarray(incomingOffset, incomingOffset + returnObject.blockLength);
|
|
3232
3301
|
return {
|
|
3233
3302
|
offset: resultOffset,
|
|
3234
3303
|
result: returnObject
|
|
3235
3304
|
};
|
|
3236
3305
|
}
|
|
3237
|
-
function fromBER(inputBuffer) {
|
|
3306
|
+
function fromBER(inputBuffer, options = {}) {
|
|
3238
3307
|
if (!inputBuffer.byteLength) {
|
|
3239
3308
|
const result = new BaseBlock({}, ValueBlock);
|
|
3240
3309
|
result.error = "Input buffer has zero length";
|
|
@@ -3243,7 +3312,7 @@ function fromBER(inputBuffer) {
|
|
|
3243
3312
|
result
|
|
3244
3313
|
};
|
|
3245
3314
|
}
|
|
3246
|
-
return localFromBER(BufferSourceConverter.toUint8Array(inputBuffer).slice(), 0, inputBuffer.byteLength);
|
|
3315
|
+
return localFromBER(BufferSourceConverter.toUint8Array(inputBuffer).slice(), 0, inputBuffer.byteLength, createFromBerContext(options));
|
|
3247
3316
|
}
|
|
3248
3317
|
function checkLen(indefiniteLength, length) {
|
|
3249
3318
|
if (indefiniteLength) {
|
|
@@ -3257,8 +3326,9 @@ var LocalConstructedValueBlock = class extends ValueBlock {
|
|
|
3257
3326
|
this.value = value;
|
|
3258
3327
|
this.isIndefiniteForm = isIndefiniteForm;
|
|
3259
3328
|
}
|
|
3260
|
-
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
3329
|
+
fromBER(inputBuffer, inputOffset, inputLength, context) {
|
|
3261
3330
|
const view = BufferSourceConverter.toUint8Array(inputBuffer);
|
|
3331
|
+
const parseContext = context !== null && context !== void 0 ? context : createFromBerContext();
|
|
3262
3332
|
if (!checkBufferParams(this, view, inputOffset, inputLength)) {
|
|
3263
3333
|
return -1;
|
|
3264
3334
|
}
|
|
@@ -3269,7 +3339,7 @@ var LocalConstructedValueBlock = class extends ValueBlock {
|
|
|
3269
3339
|
}
|
|
3270
3340
|
let currentOffset = inputOffset;
|
|
3271
3341
|
while (checkLen(this.isIndefiniteForm, inputLength) > 0) {
|
|
3272
|
-
const returnObject =
|
|
3342
|
+
const returnObject = localFromBERWithChildContext(view, currentOffset, inputLength, parseContext);
|
|
3273
3343
|
if (returnObject.offset === -1) {
|
|
3274
3344
|
this.error = returnObject.result.error;
|
|
3275
3345
|
this.warnings.concat(returnObject.result.warnings);
|
|
@@ -3321,9 +3391,9 @@ var Constructed = class extends BaseBlock {
|
|
|
3321
3391
|
super(parameters, LocalConstructedValueBlock);
|
|
3322
3392
|
this.idBlock.isConstructed = true;
|
|
3323
3393
|
}
|
|
3324
|
-
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
3394
|
+
fromBER(inputBuffer, inputOffset, inputLength, context) {
|
|
3325
3395
|
this.valueBlock.isIndefiniteForm = this.lenBlock.isIndefiniteForm;
|
|
3326
|
-
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);
|
|
3327
3397
|
if (resultOffset === -1) {
|
|
3328
3398
|
this.error = this.valueBlock.error;
|
|
3329
3399
|
return resultOffset;
|
|
@@ -3489,11 +3559,11 @@ var LocalOctetStringValueBlock = class extends HexBlock(LocalConstructedValueBlo
|
|
|
3489
3559
|
super(parameters);
|
|
3490
3560
|
this.isConstructed = isConstructed;
|
|
3491
3561
|
}
|
|
3492
|
-
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
3562
|
+
fromBER(inputBuffer, inputOffset, inputLength, context) {
|
|
3493
3563
|
let resultOffset = 0;
|
|
3494
3564
|
if (this.isConstructed) {
|
|
3495
3565
|
this.isHexOnly = false;
|
|
3496
|
-
resultOffset = LocalConstructedValueBlock.prototype.fromBER.call(this, inputBuffer, inputOffset, inputLength);
|
|
3566
|
+
resultOffset = LocalConstructedValueBlock.prototype.fromBER.call(this, inputBuffer, inputOffset, inputLength, context);
|
|
3497
3567
|
if (resultOffset === -1)
|
|
3498
3568
|
return resultOffset;
|
|
3499
3569
|
for (let i = 0; i < this.value.length; i++) {
|
|
@@ -3550,7 +3620,7 @@ var OctetString = class extends BaseBlock {
|
|
|
3550
3620
|
this.idBlock.tagClass = 1;
|
|
3551
3621
|
this.idBlock.tagNumber = 4;
|
|
3552
3622
|
}
|
|
3553
|
-
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
3623
|
+
fromBER(inputBuffer, inputOffset, inputLength, context) {
|
|
3554
3624
|
this.valueBlock.isConstructed = this.idBlock.isConstructed;
|
|
3555
3625
|
this.valueBlock.isIndefiniteForm = this.lenBlock.isIndefiniteForm;
|
|
3556
3626
|
if (inputLength === 0) {
|
|
@@ -3565,7 +3635,8 @@ var OctetString = class extends BaseBlock {
|
|
|
3565
3635
|
const buf = view.subarray(inputOffset, inputOffset + inputLength);
|
|
3566
3636
|
try {
|
|
3567
3637
|
if (buf.byteLength) {
|
|
3568
|
-
const
|
|
3638
|
+
const parseContext = context !== null && context !== void 0 ? context : createFromBerContext();
|
|
3639
|
+
const asn = localFromBERWithChildContext(buf, 0, buf.byteLength, parseContext);
|
|
3569
3640
|
if (asn.offset !== -1 && asn.offset === inputLength) {
|
|
3570
3641
|
this.valueBlock.value = [asn.result];
|
|
3571
3642
|
}
|
|
@@ -3573,7 +3644,7 @@ var OctetString = class extends BaseBlock {
|
|
|
3573
3644
|
} catch {
|
|
3574
3645
|
}
|
|
3575
3646
|
}
|
|
3576
|
-
return super.fromBER(inputBuffer, inputOffset, inputLength);
|
|
3647
|
+
return super.fromBER(inputBuffer, inputOffset, inputLength, context);
|
|
3577
3648
|
}
|
|
3578
3649
|
onAsciiEncoding() {
|
|
3579
3650
|
if (this.valueBlock.isConstructed || this.valueBlock.value && this.valueBlock.value.length) {
|
|
@@ -3608,13 +3679,13 @@ var LocalBitStringValueBlock = class extends HexBlock(LocalConstructedValueBlock
|
|
|
3608
3679
|
this.isConstructed = isConstructed;
|
|
3609
3680
|
this.blockLength = this.valueHexView.byteLength;
|
|
3610
3681
|
}
|
|
3611
|
-
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
3682
|
+
fromBER(inputBuffer, inputOffset, inputLength, context) {
|
|
3612
3683
|
if (!inputLength) {
|
|
3613
3684
|
return inputOffset;
|
|
3614
3685
|
}
|
|
3615
3686
|
let resultOffset = -1;
|
|
3616
3687
|
if (this.isConstructed) {
|
|
3617
|
-
resultOffset = LocalConstructedValueBlock.prototype.fromBER.call(this, inputBuffer, inputOffset, inputLength);
|
|
3688
|
+
resultOffset = LocalConstructedValueBlock.prototype.fromBER.call(this, inputBuffer, inputOffset, inputLength, context);
|
|
3618
3689
|
if (resultOffset === -1)
|
|
3619
3690
|
return resultOffset;
|
|
3620
3691
|
for (const value of this.value) {
|
|
@@ -3654,7 +3725,8 @@ var LocalBitStringValueBlock = class extends HexBlock(LocalConstructedValueBlock
|
|
|
3654
3725
|
const buf = intBuffer.subarray(1);
|
|
3655
3726
|
try {
|
|
3656
3727
|
if (buf.byteLength) {
|
|
3657
|
-
const
|
|
3728
|
+
const parseContext = context !== null && context !== void 0 ? context : createFromBerContext();
|
|
3729
|
+
const asn = localFromBERWithChildContext(buf, 0, buf.byteLength, parseContext);
|
|
3658
3730
|
if (asn.offset !== -1 && asn.offset === inputLength - 1) {
|
|
3659
3731
|
this.value = [asn.result];
|
|
3660
3732
|
}
|
|
@@ -3711,10 +3783,10 @@ var BitString = class extends BaseBlock {
|
|
|
3711
3783
|
this.idBlock.tagClass = 1;
|
|
3712
3784
|
this.idBlock.tagNumber = 3;
|
|
3713
3785
|
}
|
|
3714
|
-
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
3786
|
+
fromBER(inputBuffer, inputOffset, inputLength, context) {
|
|
3715
3787
|
this.valueBlock.isConstructed = this.idBlock.isConstructed;
|
|
3716
3788
|
this.valueBlock.isIndefiniteForm = this.lenBlock.isIndefiniteForm;
|
|
3717
|
-
return super.fromBER(inputBuffer, inputOffset, inputLength);
|
|
3789
|
+
return super.fromBER(inputBuffer, inputOffset, inputLength, context);
|
|
3718
3790
|
}
|
|
3719
3791
|
onAsciiEncoding() {
|
|
3720
3792
|
if (this.valueBlock.isConstructed || this.valueBlock.value && this.valueBlock.value.length) {
|
|
@@ -5441,6 +5513,59 @@ function verifySchema(inputBuffer, inputSchema) {
|
|
|
5441
5513
|
return compareSchema(asn12.result, asn12.result, inputSchema);
|
|
5442
5514
|
}
|
|
5443
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
|
+
|
|
5444
5569
|
// ../../node_modules/@peculiar/asn1-schema/build/es2015/enums.js
|
|
5445
5570
|
var AsnTypeTypes;
|
|
5446
5571
|
(function(AsnTypeTypes2) {
|
|
@@ -5481,7 +5606,7 @@ var AsnPropTypes;
|
|
|
5481
5606
|
|
|
5482
5607
|
// ../../node_modules/@peculiar/asn1-schema/build/es2015/converters.js
|
|
5483
5608
|
var AsnAnyConverter = {
|
|
5484
|
-
fromASN: (value) => value instanceof Null ? null : value.valueBeforeDecodeView,
|
|
5609
|
+
fromASN: (value) => value instanceof Null ? null : toArrayBuffer(value.valueBeforeDecodeView),
|
|
5485
5610
|
toASN: (value) => {
|
|
5486
5611
|
if (value === null) {
|
|
5487
5612
|
return new Null();
|
|
@@ -5502,7 +5627,7 @@ var AsnEnumeratedConverter = {
|
|
|
5502
5627
|
toASN: (value) => new Enumerated({ value })
|
|
5503
5628
|
};
|
|
5504
5629
|
var AsnBitStringConverter = {
|
|
5505
|
-
fromASN: (value) => value.valueBlock.valueHexView,
|
|
5630
|
+
fromASN: (value) => toArrayBuffer(value.valueBlock.valueHexView),
|
|
5506
5631
|
toASN: (value) => new BitString({ valueHex: value })
|
|
5507
5632
|
};
|
|
5508
5633
|
var AsnObjectIdentifierConverter = {
|
|
@@ -5514,7 +5639,7 @@ var AsnBooleanConverter = {
|
|
|
5514
5639
|
toASN: (value) => new Boolean({ value })
|
|
5515
5640
|
};
|
|
5516
5641
|
var AsnOctetStringConverter = {
|
|
5517
|
-
fromASN: (value) => value.valueBlock.valueHexView,
|
|
5642
|
+
fromASN: (value) => toArrayBuffer(value.valueBlock.valueHexView),
|
|
5518
5643
|
toASN: (value) => new OctetString({ valueHex: value })
|
|
5519
5644
|
};
|
|
5520
5645
|
function createStringConverter(Asn1Type) {
|
|
@@ -5613,10 +5738,9 @@ function isConvertible(target) {
|
|
|
5613
5738
|
}
|
|
5614
5739
|
}
|
|
5615
5740
|
function isTypeOfArray(target) {
|
|
5616
|
-
var _a2;
|
|
5617
5741
|
if (target) {
|
|
5618
5742
|
const proto = Object.getPrototypeOf(target);
|
|
5619
|
-
if (
|
|
5743
|
+
if (proto?.prototype?.constructor === Array) {
|
|
5620
5744
|
return true;
|
|
5621
5745
|
}
|
|
5622
5746
|
return isTypeOfArray(proto);
|
|
@@ -5642,9 +5766,7 @@ function isArrayEqual(bytes1, bytes2) {
|
|
|
5642
5766
|
|
|
5643
5767
|
// ../../node_modules/@peculiar/asn1-schema/build/es2015/schema.js
|
|
5644
5768
|
var AsnSchemaStorage = class {
|
|
5645
|
-
|
|
5646
|
-
this.items = /* @__PURE__ */ new WeakMap();
|
|
5647
|
-
}
|
|
5769
|
+
items = /* @__PURE__ */ new WeakMap();
|
|
5648
5770
|
has(target) {
|
|
5649
5771
|
return this.items.has(target);
|
|
5650
5772
|
}
|
|
@@ -5665,7 +5787,10 @@ var AsnSchemaStorage = class {
|
|
|
5665
5787
|
}
|
|
5666
5788
|
}
|
|
5667
5789
|
createDefault(target) {
|
|
5668
|
-
const schema = {
|
|
5790
|
+
const schema = {
|
|
5791
|
+
type: AsnTypeTypes.Sequence,
|
|
5792
|
+
items: {}
|
|
5793
|
+
};
|
|
5669
5794
|
const parentSchema = this.findParentSchema(target);
|
|
5670
5795
|
if (parentSchema) {
|
|
5671
5796
|
Object.assign(schema, parentSchema);
|
|
@@ -5707,14 +5832,24 @@ var AsnSchemaStorage = class {
|
|
|
5707
5832
|
const Container = item.repeated === "set" ? Set : Sequence;
|
|
5708
5833
|
asn1Item = new Container({
|
|
5709
5834
|
name: "",
|
|
5710
|
-
value: [new Repeated({
|
|
5835
|
+
value: [new Repeated({
|
|
5836
|
+
name,
|
|
5837
|
+
value: asn1Item
|
|
5838
|
+
})]
|
|
5711
5839
|
});
|
|
5712
5840
|
}
|
|
5713
5841
|
if (item.context !== null && item.context !== void 0) {
|
|
5714
5842
|
if (item.implicit) {
|
|
5715
5843
|
if (typeof item.type === "number" || isConvertible(item.type)) {
|
|
5716
5844
|
const Container = item.repeated ? Constructed : Primitive;
|
|
5717
|
-
asn1Value.push(new Container({
|
|
5845
|
+
asn1Value.push(new Container({
|
|
5846
|
+
name,
|
|
5847
|
+
optional,
|
|
5848
|
+
idBlock: {
|
|
5849
|
+
tagClass: 3,
|
|
5850
|
+
tagNumber: item.context
|
|
5851
|
+
}
|
|
5852
|
+
}));
|
|
5718
5853
|
} else {
|
|
5719
5854
|
this.cache(item.type);
|
|
5720
5855
|
const isRepeated = !!item.repeated;
|
|
@@ -5723,14 +5858,20 @@ var AsnSchemaStorage = class {
|
|
|
5723
5858
|
asn1Value.push(new Constructed({
|
|
5724
5859
|
name: !isRepeated ? name : "",
|
|
5725
5860
|
optional,
|
|
5726
|
-
idBlock: {
|
|
5861
|
+
idBlock: {
|
|
5862
|
+
tagClass: 3,
|
|
5863
|
+
tagNumber: item.context
|
|
5864
|
+
},
|
|
5727
5865
|
value
|
|
5728
5866
|
}));
|
|
5729
5867
|
}
|
|
5730
5868
|
} else {
|
|
5731
5869
|
asn1Value.push(new Constructed({
|
|
5732
5870
|
optional,
|
|
5733
|
-
idBlock: {
|
|
5871
|
+
idBlock: {
|
|
5872
|
+
tagClass: 3,
|
|
5873
|
+
tagNumber: item.context
|
|
5874
|
+
},
|
|
5734
5875
|
value: [asn1Item]
|
|
5735
5876
|
}));
|
|
5736
5877
|
}
|
|
@@ -5741,13 +5882,22 @@ var AsnSchemaStorage = class {
|
|
|
5741
5882
|
}
|
|
5742
5883
|
switch (schema.type) {
|
|
5743
5884
|
case AsnTypeTypes.Sequence:
|
|
5744
|
-
return new Sequence({
|
|
5885
|
+
return new Sequence({
|
|
5886
|
+
value: asn1Value,
|
|
5887
|
+
name: ""
|
|
5888
|
+
});
|
|
5745
5889
|
case AsnTypeTypes.Set:
|
|
5746
|
-
return new Set({
|
|
5890
|
+
return new Set({
|
|
5891
|
+
value: asn1Value,
|
|
5892
|
+
name: ""
|
|
5893
|
+
});
|
|
5747
5894
|
case AsnTypeTypes.Choice:
|
|
5748
|
-
return new Choice({
|
|
5895
|
+
return new Choice({
|
|
5896
|
+
value: asn1Value,
|
|
5897
|
+
name: ""
|
|
5898
|
+
});
|
|
5749
5899
|
default:
|
|
5750
|
-
throw new Error(
|
|
5900
|
+
throw new Error("Unsupported ASN1 type in use");
|
|
5751
5901
|
}
|
|
5752
5902
|
}
|
|
5753
5903
|
set(target, schema) {
|
|
@@ -5769,16 +5919,13 @@ var schemaStorage = new AsnSchemaStorage();
|
|
|
5769
5919
|
|
|
5770
5920
|
// ../../node_modules/@peculiar/asn1-schema/build/es2015/errors/schema_validation.js
|
|
5771
5921
|
var AsnSchemaValidationError = class extends Error {
|
|
5772
|
-
|
|
5773
|
-
super(...arguments);
|
|
5774
|
-
this.schemas = [];
|
|
5775
|
-
}
|
|
5922
|
+
schemas = [];
|
|
5776
5923
|
};
|
|
5777
5924
|
|
|
5778
5925
|
// ../../node_modules/@peculiar/asn1-schema/build/es2015/parser.js
|
|
5779
5926
|
var AsnParser = class {
|
|
5780
5927
|
static parse(data, target) {
|
|
5781
|
-
const asn1Parsed = fromBER(data);
|
|
5928
|
+
const asn1Parsed = fromBER(toArrayBuffer(data));
|
|
5782
5929
|
if (asn1Parsed.result.error) {
|
|
5783
5930
|
throw new Error(asn1Parsed.result.error);
|
|
5784
5931
|
}
|
|
@@ -5795,10 +5942,10 @@ var AsnParser = class {
|
|
|
5795
5942
|
schemaStorage.cache(target);
|
|
5796
5943
|
let targetSchema = schema.schema;
|
|
5797
5944
|
const choiceResult = this.handleChoiceTypes(asn1Schema, schema, target, targetSchema);
|
|
5798
|
-
if (choiceResult
|
|
5945
|
+
if (choiceResult?.result) {
|
|
5799
5946
|
return choiceResult.result;
|
|
5800
5947
|
}
|
|
5801
|
-
if (choiceResult
|
|
5948
|
+
if (choiceResult?.targetSchema) {
|
|
5802
5949
|
targetSchema = choiceResult.targetSchema;
|
|
5803
5950
|
}
|
|
5804
5951
|
const sequenceResult = this.handleSequenceTypes(asn1Schema, schema, target, targetSchema);
|
|
@@ -5906,7 +6053,10 @@ var AsnParser = class {
|
|
|
5906
6053
|
static processOptionalChoiceField(asn1Element, schemaItem) {
|
|
5907
6054
|
try {
|
|
5908
6055
|
const value = this.fromASN(asn1Element, schemaItem.type);
|
|
5909
|
-
return {
|
|
6056
|
+
return {
|
|
6057
|
+
processed: true,
|
|
6058
|
+
value
|
|
6059
|
+
};
|
|
5910
6060
|
} catch (err) {
|
|
5911
6061
|
if (err instanceof AsnSchemaValidationError && /Wrong values for Choice type/.test(err.message)) {
|
|
5912
6062
|
return { processed: false };
|
|
@@ -5916,7 +6066,7 @@ var AsnParser = class {
|
|
|
5916
6066
|
}
|
|
5917
6067
|
static handleArrayTypes(asn1Schema, schema, target) {
|
|
5918
6068
|
if (!("value" in asn1Schema.valueBlock && Array.isArray(asn1Schema.valueBlock.value))) {
|
|
5919
|
-
throw new Error(
|
|
6069
|
+
throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");
|
|
5920
6070
|
}
|
|
5921
6071
|
const itemType = schema.itemType;
|
|
5922
6072
|
if (typeof itemType === "number") {
|
|
@@ -5952,8 +6102,7 @@ var AsnParser = class {
|
|
|
5952
6102
|
}
|
|
5953
6103
|
}
|
|
5954
6104
|
static processPrimitiveSchemaItem(asn1SchemaValue, schemaItem, schemaItemType) {
|
|
5955
|
-
|
|
5956
|
-
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);
|
|
5957
6106
|
if (!converter) {
|
|
5958
6107
|
throw new Error("Converter is empty");
|
|
5959
6108
|
}
|
|
@@ -6094,7 +6243,7 @@ var AsnSerializer = class _AsnSerializer {
|
|
|
6094
6243
|
if (schemaItem.implicit) {
|
|
6095
6244
|
if (!schemaItem.repeated && (typeof schemaItem.type === "number" || isConvertible(schemaItem.type))) {
|
|
6096
6245
|
const value = {};
|
|
6097
|
-
value.valueHex = asn1Item instanceof Null ? asn1Item.valueBeforeDecodeView : asn1Item.valueBlock.toBER();
|
|
6246
|
+
value.valueHex = asn1Item instanceof Null ? toArrayBuffer(asn1Item.valueBeforeDecodeView) : asn1Item.valueBlock.toBER();
|
|
6098
6247
|
asn1Value.push(new Primitive({
|
|
6099
6248
|
optional: schemaItem.optional,
|
|
6100
6249
|
idBlock: {
|
|
@@ -6160,9 +6309,7 @@ var AsnSerializer = class _AsnSerializer {
|
|
|
6160
6309
|
}
|
|
6161
6310
|
const items = Array.from(objProp, (element) => converter.toASN(element));
|
|
6162
6311
|
const Container = schemaItem.repeated === "sequence" ? Sequence : Set;
|
|
6163
|
-
asn1Item = new Container({
|
|
6164
|
-
value: items
|
|
6165
|
-
});
|
|
6312
|
+
asn1Item = new Container({ value: items });
|
|
6166
6313
|
} else {
|
|
6167
6314
|
asn1Item = converter.toASN(objProp);
|
|
6168
6315
|
}
|
|
@@ -6173,9 +6320,7 @@ var AsnSerializer = class _AsnSerializer {
|
|
|
6173
6320
|
}
|
|
6174
6321
|
const items = Array.from(objProp, (element) => this.toASN(element));
|
|
6175
6322
|
const Container = schemaItem.repeated === "sequence" ? Sequence : Set;
|
|
6176
|
-
asn1Item = new Container({
|
|
6177
|
-
value: items
|
|
6178
|
-
});
|
|
6323
|
+
asn1Item = new Container({ value: items });
|
|
6179
6324
|
} else {
|
|
6180
6325
|
asn1Item = this.toASN(objProp);
|
|
6181
6326
|
}
|
|
@@ -6193,7 +6338,7 @@ var AsnConvert = class _AsnConvert {
|
|
|
6193
6338
|
return AsnParser.parse(data, target);
|
|
6194
6339
|
}
|
|
6195
6340
|
static toString(data) {
|
|
6196
|
-
const buf =
|
|
6341
|
+
const buf = isBufferSource(data) ? toArrayBuffer(data) : _AsnConvert.serialize(data);
|
|
6197
6342
|
const asn = fromBER(buf);
|
|
6198
6343
|
if (asn.offset === -1) {
|
|
6199
6344
|
throw new Error(`Cannot decode ASN.1 data. ${asn.result.error}`);
|
|
@@ -6632,4 +6777,4 @@ asn1js/build/index.es.js:
|
|
|
6632
6777
|
*
|
|
6633
6778
|
*)
|
|
6634
6779
|
*/
|
|
6635
|
-
//# sourceMappingURL=chunk-
|
|
6780
|
+
//# sourceMappingURL=chunk-NX3DSTD6.js.map
|