node-opcua-crypto 4.16.0 → 4.16.1
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/LICENSE +23 -23
- package/dist/{chunk-XPM4YIBT.mjs → chunk-JDT2M2NN.mjs} +7 -7
- package/dist/{chunk-F5EAPW2U.mjs → chunk-MGQCHN54.mjs} +339 -202
- package/dist/chunk-MGQCHN54.mjs.map +1 -0
- package/dist/index.js +337 -200
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/source/index.js +337 -200
- package/dist/source/index.js.map +1 -1
- package/dist/source/index.mjs +1 -1
- package/dist/source/index_web.js +337 -200
- package/dist/source/index_web.js.map +1 -1
- package/dist/source/index_web.mjs +1 -1
- package/dist/source_nodejs/index.js +99 -116
- package/dist/source_nodejs/index.js.map +1 -1
- package/dist/source_nodejs/index.mjs +2 -2
- package/package.json +5 -5
- package/dist/chunk-F5EAPW2U.mjs.map +0 -1
- /package/dist/{chunk-XPM4YIBT.mjs.map → chunk-JDT2M2NN.mjs.map} +0 -0
package/dist/source/index_web.js
CHANGED
|
@@ -2195,7 +2195,7 @@ var BufferSourceConverter = class _BufferSourceConverter {
|
|
|
2195
2195
|
}
|
|
2196
2196
|
};
|
|
2197
2197
|
var STRING_TYPE = "string";
|
|
2198
|
-
var HEX_REGEX = /^[0-9a-f]+$/i;
|
|
2198
|
+
var HEX_REGEX = /^[0-9a-f\s]+$/i;
|
|
2199
2199
|
var BASE64_REGEX = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
|
|
2200
2200
|
var BASE64URL_REGEX = /^[a-zA-Z0-9-_]+$/;
|
|
2201
2201
|
var Utf8Converter = class {
|
|
@@ -2643,19 +2643,19 @@ var BIT_STRING_NAME = "BIT STRING";
|
|
|
2643
2643
|
function HexBlock(BaseClass) {
|
|
2644
2644
|
var _a2;
|
|
2645
2645
|
return _a2 = class Some extends BaseClass {
|
|
2646
|
-
constructor(...args) {
|
|
2647
|
-
var _a3;
|
|
2648
|
-
super(...args);
|
|
2649
|
-
const params = args[0] || {};
|
|
2650
|
-
this.isHexOnly = (_a3 = params.isHexOnly) !== null && _a3 !== void 0 ? _a3 : false;
|
|
2651
|
-
this.valueHexView = params.valueHex ? BufferSourceConverter.toUint8Array(params.valueHex) : EMPTY_VIEW;
|
|
2652
|
-
}
|
|
2653
2646
|
get valueHex() {
|
|
2654
2647
|
return this.valueHexView.slice().buffer;
|
|
2655
2648
|
}
|
|
2656
2649
|
set valueHex(value) {
|
|
2657
2650
|
this.valueHexView = new Uint8Array(value);
|
|
2658
2651
|
}
|
|
2652
|
+
constructor(...args) {
|
|
2653
|
+
var _b;
|
|
2654
|
+
super(...args);
|
|
2655
|
+
const params = args[0] || {};
|
|
2656
|
+
this.isHexOnly = (_b = params.isHexOnly) !== null && _b !== void 0 ? _b : false;
|
|
2657
|
+
this.valueHexView = params.valueHex ? BufferSourceConverter.toUint8Array(params.valueHex) : EMPTY_VIEW;
|
|
2658
|
+
}
|
|
2659
2659
|
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
2660
2660
|
const view = inputBuffer instanceof ArrayBuffer ? new Uint8Array(inputBuffer) : inputBuffer;
|
|
2661
2661
|
if (!checkBufferParams(this, view, inputOffset, inputLength)) {
|
|
@@ -2690,12 +2690,6 @@ function HexBlock(BaseClass) {
|
|
|
2690
2690
|
}, _a2.NAME = "hexBlock", _a2;
|
|
2691
2691
|
}
|
|
2692
2692
|
var LocalBaseBlock = class {
|
|
2693
|
-
constructor({ blockLength = 0, error = EMPTY_STRING, warnings = [], valueBeforeDecode = EMPTY_VIEW } = {}) {
|
|
2694
|
-
this.blockLength = blockLength;
|
|
2695
|
-
this.error = error;
|
|
2696
|
-
this.warnings = warnings;
|
|
2697
|
-
this.valueBeforeDecodeView = BufferSourceConverter.toUint8Array(valueBeforeDecode);
|
|
2698
|
-
}
|
|
2699
2693
|
static blockName() {
|
|
2700
2694
|
return this.NAME;
|
|
2701
2695
|
}
|
|
@@ -2705,6 +2699,12 @@ var LocalBaseBlock = class {
|
|
|
2705
2699
|
set valueBeforeDecode(value) {
|
|
2706
2700
|
this.valueBeforeDecodeView = new Uint8Array(value);
|
|
2707
2701
|
}
|
|
2702
|
+
constructor({ blockLength = 0, error = EMPTY_STRING, warnings = [], valueBeforeDecode = EMPTY_VIEW } = {}) {
|
|
2703
|
+
this.blockLength = blockLength;
|
|
2704
|
+
this.error = error;
|
|
2705
|
+
this.warnings = warnings;
|
|
2706
|
+
this.valueBeforeDecodeView = BufferSourceConverter.toUint8Array(valueBeforeDecode);
|
|
2707
|
+
}
|
|
2708
2708
|
toJSON() {
|
|
2709
2709
|
return {
|
|
2710
2710
|
blockName: this.constructor.NAME,
|
|
@@ -2717,10 +2717,10 @@ var LocalBaseBlock = class {
|
|
|
2717
2717
|
};
|
|
2718
2718
|
LocalBaseBlock.NAME = "baseBlock";
|
|
2719
2719
|
var ValueBlock = class extends LocalBaseBlock {
|
|
2720
|
-
fromBER(
|
|
2720
|
+
fromBER(_inputBuffer, _inputOffset, _inputLength) {
|
|
2721
2721
|
throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'");
|
|
2722
2722
|
}
|
|
2723
|
-
toBER(
|
|
2723
|
+
toBER(_sizeOnly, _writer) {
|
|
2724
2724
|
throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'");
|
|
2725
2725
|
}
|
|
2726
2726
|
};
|
|
@@ -3061,7 +3061,9 @@ var BaseBlock = class extends LocalBaseBlock {
|
|
|
3061
3061
|
return Convert.ToHex(this.toBER());
|
|
3062
3062
|
}
|
|
3063
3063
|
onAsciiEncoding() {
|
|
3064
|
-
|
|
3064
|
+
const name = this.constructor.NAME;
|
|
3065
|
+
const value = Convert.ToHex(this.valueBlock.valueBeforeDecodeView);
|
|
3066
|
+
return `${name} : ${value}`;
|
|
3065
3067
|
}
|
|
3066
3068
|
isEqual(other) {
|
|
3067
3069
|
if (this === other) {
|
|
@@ -3077,6 +3079,7 @@ var BaseBlock = class extends LocalBaseBlock {
|
|
|
3077
3079
|
};
|
|
3078
3080
|
BaseBlock.NAME = "BaseBlock";
|
|
3079
3081
|
function prepareIndefiniteForm(baseBlock) {
|
|
3082
|
+
var _a2;
|
|
3080
3083
|
if (baseBlock instanceof typeStore.Constructed) {
|
|
3081
3084
|
for (const value of baseBlock.valueBlock.value) {
|
|
3082
3085
|
if (prepareIndefiniteForm(value)) {
|
|
@@ -3084,21 +3087,21 @@ function prepareIndefiniteForm(baseBlock) {
|
|
|
3084
3087
|
}
|
|
3085
3088
|
}
|
|
3086
3089
|
}
|
|
3087
|
-
return !!baseBlock.lenBlock.isIndefiniteForm;
|
|
3090
|
+
return !!((_a2 = baseBlock.lenBlock) === null || _a2 === void 0 ? void 0 : _a2.isIndefiniteForm);
|
|
3088
3091
|
}
|
|
3089
3092
|
var BaseStringBlock = class extends BaseBlock {
|
|
3090
|
-
constructor({ value = EMPTY_STRING, ...parameters } = {}, stringValueBlockType) {
|
|
3091
|
-
super(parameters, stringValueBlockType);
|
|
3092
|
-
if (value) {
|
|
3093
|
-
this.fromString(value);
|
|
3094
|
-
}
|
|
3095
|
-
}
|
|
3096
3093
|
getValue() {
|
|
3097
3094
|
return this.valueBlock.value;
|
|
3098
3095
|
}
|
|
3099
3096
|
setValue(value) {
|
|
3100
3097
|
this.valueBlock.value = value;
|
|
3101
3098
|
}
|
|
3099
|
+
constructor({ value = EMPTY_STRING, ...parameters } = {}, stringValueBlockType) {
|
|
3100
|
+
super(parameters, stringValueBlockType);
|
|
3101
|
+
if (value) {
|
|
3102
|
+
this.fromString(value);
|
|
3103
|
+
}
|
|
3104
|
+
}
|
|
3102
3105
|
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
3103
3106
|
const resultOffset = this.valueBlock.fromBER(inputBuffer, inputOffset, this.lenBlock.isIndefiniteForm ? inputLength : this.lenBlock.length);
|
|
3104
3107
|
if (resultOffset === -1) {
|
|
@@ -3457,10 +3460,10 @@ _a$v = Constructed;
|
|
|
3457
3460
|
})();
|
|
3458
3461
|
Constructed.NAME = "CONSTRUCTED";
|
|
3459
3462
|
var LocalEndOfContentValueBlock = class extends ValueBlock {
|
|
3460
|
-
fromBER(inputBuffer, inputOffset,
|
|
3463
|
+
fromBER(inputBuffer, inputOffset, _inputLength) {
|
|
3461
3464
|
return inputOffset;
|
|
3462
3465
|
}
|
|
3463
|
-
toBER(
|
|
3466
|
+
toBER(_sizeOnly) {
|
|
3464
3467
|
return EMPTY_BUFFER;
|
|
3465
3468
|
}
|
|
3466
3469
|
};
|
|
@@ -3521,17 +3524,6 @@ _a$t = Null;
|
|
|
3521
3524
|
})();
|
|
3522
3525
|
Null.NAME = "NULL";
|
|
3523
3526
|
var LocalBooleanValueBlock = class extends HexBlock(ValueBlock) {
|
|
3524
|
-
constructor({ value, ...parameters } = {}) {
|
|
3525
|
-
super(parameters);
|
|
3526
|
-
if (parameters.valueHex) {
|
|
3527
|
-
this.valueHexView = BufferSourceConverter.toUint8Array(parameters.valueHex);
|
|
3528
|
-
} else {
|
|
3529
|
-
this.valueHexView = new Uint8Array(1);
|
|
3530
|
-
}
|
|
3531
|
-
if (value) {
|
|
3532
|
-
this.value = value;
|
|
3533
|
-
}
|
|
3534
|
-
}
|
|
3535
3527
|
get value() {
|
|
3536
3528
|
for (const octet of this.valueHexView) {
|
|
3537
3529
|
if (octet > 0) {
|
|
@@ -3543,6 +3535,17 @@ var LocalBooleanValueBlock = class extends HexBlock(ValueBlock) {
|
|
|
3543
3535
|
set value(value) {
|
|
3544
3536
|
this.valueHexView[0] = value ? 255 : 0;
|
|
3545
3537
|
}
|
|
3538
|
+
constructor({ value, ...parameters } = {}) {
|
|
3539
|
+
super(parameters);
|
|
3540
|
+
if (parameters.valueHex) {
|
|
3541
|
+
this.valueHexView = BufferSourceConverter.toUint8Array(parameters.valueHex);
|
|
3542
|
+
} else {
|
|
3543
|
+
this.valueHexView = new Uint8Array(1);
|
|
3544
|
+
}
|
|
3545
|
+
if (value) {
|
|
3546
|
+
this.value = value;
|
|
3547
|
+
}
|
|
3548
|
+
}
|
|
3546
3549
|
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
3547
3550
|
const inputView = BufferSourceConverter.toUint8Array(inputBuffer);
|
|
3548
3551
|
if (!checkBufferParams(this, inputView, inputOffset, inputLength)) {
|
|
@@ -3569,17 +3572,17 @@ var LocalBooleanValueBlock = class extends HexBlock(ValueBlock) {
|
|
|
3569
3572
|
LocalBooleanValueBlock.NAME = "BooleanValueBlock";
|
|
3570
3573
|
var _a$s;
|
|
3571
3574
|
var Boolean = class extends BaseBlock {
|
|
3572
|
-
constructor(parameters = {}) {
|
|
3573
|
-
super(parameters, LocalBooleanValueBlock);
|
|
3574
|
-
this.idBlock.tagClass = 1;
|
|
3575
|
-
this.idBlock.tagNumber = 1;
|
|
3576
|
-
}
|
|
3577
3575
|
getValue() {
|
|
3578
3576
|
return this.valueBlock.value;
|
|
3579
3577
|
}
|
|
3580
3578
|
setValue(value) {
|
|
3581
3579
|
this.valueBlock.value = value;
|
|
3582
3580
|
}
|
|
3581
|
+
constructor(parameters = {}) {
|
|
3582
|
+
super(parameters, LocalBooleanValueBlock);
|
|
3583
|
+
this.idBlock.tagClass = 1;
|
|
3584
|
+
this.idBlock.tagNumber = 1;
|
|
3585
|
+
}
|
|
3583
3586
|
onAsciiEncoding() {
|
|
3584
3587
|
return `${this.constructor.NAME} : ${this.getValue}`;
|
|
3585
3588
|
}
|
|
@@ -3637,7 +3640,7 @@ var LocalOctetStringValueBlock = class extends HexBlock(LocalConstructedValueBlo
|
|
|
3637
3640
|
};
|
|
3638
3641
|
LocalOctetStringValueBlock.NAME = "OctetStringValueBlock";
|
|
3639
3642
|
var _a$r;
|
|
3640
|
-
var OctetString = class
|
|
3643
|
+
var OctetString = class extends BaseBlock {
|
|
3641
3644
|
constructor({ idBlock = {}, lenBlock = {}, ...parameters } = {}) {
|
|
3642
3645
|
var _b, _c;
|
|
3643
3646
|
(_b = parameters.isConstructed) !== null && _b !== void 0 ? _b : parameters.isConstructed = !!((_c = parameters.value) === null || _c === void 0 ? void 0 : _c.length);
|
|
@@ -3675,7 +3678,7 @@ var OctetString = class _OctetString extends BaseBlock {
|
|
|
3675
3678
|
this.valueBlock.value = [asn.result];
|
|
3676
3679
|
}
|
|
3677
3680
|
}
|
|
3678
|
-
} catch
|
|
3681
|
+
} catch {
|
|
3679
3682
|
}
|
|
3680
3683
|
}
|
|
3681
3684
|
return super.fromBER(inputBuffer, inputOffset, inputLength);
|
|
@@ -3684,7 +3687,9 @@ var OctetString = class _OctetString extends BaseBlock {
|
|
|
3684
3687
|
if (this.valueBlock.isConstructed || this.valueBlock.value && this.valueBlock.value.length) {
|
|
3685
3688
|
return Constructed.prototype.onAsciiEncoding.call(this);
|
|
3686
3689
|
}
|
|
3687
|
-
|
|
3690
|
+
const name = this.constructor.NAME;
|
|
3691
|
+
const value = Convert.ToHex(this.valueBlock.valueHexView);
|
|
3692
|
+
return `${name} : ${value}`;
|
|
3688
3693
|
}
|
|
3689
3694
|
getValue() {
|
|
3690
3695
|
if (!this.idBlock.isConstructed) {
|
|
@@ -3692,7 +3697,7 @@ var OctetString = class _OctetString extends BaseBlock {
|
|
|
3692
3697
|
}
|
|
3693
3698
|
const array = [];
|
|
3694
3699
|
for (const content of this.valueBlock.value) {
|
|
3695
|
-
if (content instanceof
|
|
3700
|
+
if (content instanceof _a$r) {
|
|
3696
3701
|
array.push(content.valueBlock.valueHexView);
|
|
3697
3702
|
}
|
|
3698
3703
|
}
|
|
@@ -3762,7 +3767,7 @@ var LocalBitStringValueBlock = class extends HexBlock(LocalConstructedValueBlock
|
|
|
3762
3767
|
this.value = [asn.result];
|
|
3763
3768
|
}
|
|
3764
3769
|
}
|
|
3765
|
-
} catch
|
|
3770
|
+
} catch {
|
|
3766
3771
|
}
|
|
3767
3772
|
}
|
|
3768
3773
|
this.valueHexView = intBuffer.subarray(1);
|
|
@@ -3777,7 +3782,9 @@ var LocalBitStringValueBlock = class extends HexBlock(LocalConstructedValueBlock
|
|
|
3777
3782
|
return new ArrayBuffer(this.valueHexView.byteLength + 1);
|
|
3778
3783
|
}
|
|
3779
3784
|
if (!this.valueHexView.byteLength) {
|
|
3780
|
-
|
|
3785
|
+
const empty = new Uint8Array(1);
|
|
3786
|
+
empty[0] = 0;
|
|
3787
|
+
return empty.buffer;
|
|
3781
3788
|
}
|
|
3782
3789
|
const retView = new Uint8Array(this.valueHexView.length + 1);
|
|
3783
3790
|
retView[0] = this.unusedBits;
|
|
@@ -3827,7 +3834,9 @@ var BitString = class extends BaseBlock {
|
|
|
3827
3834
|
bits.push(byte.toString(2).padStart(8, "0"));
|
|
3828
3835
|
}
|
|
3829
3836
|
const bitsStr = bits.join("");
|
|
3830
|
-
|
|
3837
|
+
const name = this.constructor.NAME;
|
|
3838
|
+
const value = bitsStr.substring(0, bitsStr.length - this.valueBlock.unusedBits);
|
|
3839
|
+
return `${name} : ${value}`;
|
|
3831
3840
|
}
|
|
3832
3841
|
}
|
|
3833
3842
|
};
|
|
@@ -3924,16 +3933,6 @@ function viewSub(first, second) {
|
|
|
3924
3933
|
return firstViewCopy.slice();
|
|
3925
3934
|
}
|
|
3926
3935
|
var LocalIntegerValueBlock = class extends HexBlock(ValueBlock) {
|
|
3927
|
-
constructor({ value, ...parameters } = {}) {
|
|
3928
|
-
super(parameters);
|
|
3929
|
-
this._valueDec = 0;
|
|
3930
|
-
if (parameters.valueHex) {
|
|
3931
|
-
this.setValueHex();
|
|
3932
|
-
}
|
|
3933
|
-
if (value !== void 0) {
|
|
3934
|
-
this.valueDec = value;
|
|
3935
|
-
}
|
|
3936
|
-
}
|
|
3937
3936
|
setValueHex() {
|
|
3938
3937
|
if (this.valueHexView.length >= 4) {
|
|
3939
3938
|
this.warnings.push("Too big Integer for decoding, hex only");
|
|
@@ -3946,6 +3945,16 @@ var LocalIntegerValueBlock = class extends HexBlock(ValueBlock) {
|
|
|
3946
3945
|
}
|
|
3947
3946
|
}
|
|
3948
3947
|
}
|
|
3948
|
+
constructor({ value, ...parameters } = {}) {
|
|
3949
|
+
super(parameters);
|
|
3950
|
+
this._valueDec = 0;
|
|
3951
|
+
if (parameters.valueHex) {
|
|
3952
|
+
this.setValueHex();
|
|
3953
|
+
}
|
|
3954
|
+
if (value !== void 0) {
|
|
3955
|
+
this.valueDec = value;
|
|
3956
|
+
}
|
|
3957
|
+
}
|
|
3949
3958
|
set valueDec(v) {
|
|
3950
3959
|
this._valueDec = v;
|
|
3951
3960
|
this.isHexOnly = false;
|
|
@@ -4058,7 +4067,7 @@ LocalIntegerValueBlock.NAME = "IntegerValueBlock";
|
|
|
4058
4067
|
});
|
|
4059
4068
|
})();
|
|
4060
4069
|
var _a$o;
|
|
4061
|
-
var Integer = class
|
|
4070
|
+
var Integer = class extends BaseBlock {
|
|
4062
4071
|
constructor(parameters = {}) {
|
|
4063
4072
|
super(parameters, LocalIntegerValueBlock);
|
|
4064
4073
|
this.idBlock.tagClass = 1;
|
|
@@ -4088,18 +4097,16 @@ var Integer = class _Integer extends BaseBlock {
|
|
|
4088
4097
|
}
|
|
4089
4098
|
writer.write(view);
|
|
4090
4099
|
}
|
|
4091
|
-
const res = new
|
|
4092
|
-
valueHex: writer.final()
|
|
4093
|
-
});
|
|
4100
|
+
const res = new _a$o({ valueHex: writer.final() });
|
|
4094
4101
|
return res;
|
|
4095
4102
|
}
|
|
4096
4103
|
convertToDER() {
|
|
4097
|
-
const integer = new
|
|
4104
|
+
const integer = new _a$o({ valueHex: this.valueBlock.valueHexView });
|
|
4098
4105
|
integer.valueBlock.toDER();
|
|
4099
4106
|
return integer;
|
|
4100
4107
|
}
|
|
4101
4108
|
convertFromDER() {
|
|
4102
|
-
return new
|
|
4109
|
+
return new _a$o({
|
|
4103
4110
|
valueHex: this.valueBlock.valueHexView[0] === 0 ? this.valueBlock.valueHexView.subarray(1) : this.valueBlock.valueHexView
|
|
4104
4111
|
});
|
|
4105
4112
|
}
|
|
@@ -4362,17 +4369,17 @@ var LocalObjectIdentifierValueBlock = class extends ValueBlock {
|
|
|
4362
4369
|
LocalObjectIdentifierValueBlock.NAME = "ObjectIdentifierValueBlock";
|
|
4363
4370
|
var _a$m;
|
|
4364
4371
|
var ObjectIdentifier = class extends BaseBlock {
|
|
4365
|
-
constructor(parameters = {}) {
|
|
4366
|
-
super(parameters, LocalObjectIdentifierValueBlock);
|
|
4367
|
-
this.idBlock.tagClass = 1;
|
|
4368
|
-
this.idBlock.tagNumber = 6;
|
|
4369
|
-
}
|
|
4370
4372
|
getValue() {
|
|
4371
4373
|
return this.valueBlock.toString();
|
|
4372
4374
|
}
|
|
4373
4375
|
setValue(value) {
|
|
4374
4376
|
this.valueBlock.fromString(value);
|
|
4375
4377
|
}
|
|
4378
|
+
constructor(parameters = {}) {
|
|
4379
|
+
super(parameters, LocalObjectIdentifierValueBlock);
|
|
4380
|
+
this.idBlock.tagClass = 1;
|
|
4381
|
+
this.idBlock.tagNumber = 6;
|
|
4382
|
+
}
|
|
4376
4383
|
onAsciiEncoding() {
|
|
4377
4384
|
return `${this.constructor.NAME} : ${this.valueBlock.toString() || "empty"}`;
|
|
4378
4385
|
}
|
|
@@ -4492,7 +4499,7 @@ var LocalRelativeObjectIdentifierValueBlock = class extends ValueBlock {
|
|
|
4492
4499
|
}
|
|
4493
4500
|
return resultOffset;
|
|
4494
4501
|
}
|
|
4495
|
-
toBER(sizeOnly,
|
|
4502
|
+
toBER(sizeOnly, _writer) {
|
|
4496
4503
|
const retBuffers = [];
|
|
4497
4504
|
for (let i = 0; i < this.value.length; i++) {
|
|
4498
4505
|
const valueBuf = this.value[i].toBER(sizeOnly);
|
|
@@ -4554,17 +4561,17 @@ var LocalRelativeObjectIdentifierValueBlock = class extends ValueBlock {
|
|
|
4554
4561
|
LocalRelativeObjectIdentifierValueBlock.NAME = "RelativeObjectIdentifierValueBlock";
|
|
4555
4562
|
var _a$l;
|
|
4556
4563
|
var RelativeObjectIdentifier = class extends BaseBlock {
|
|
4557
|
-
constructor(parameters = {}) {
|
|
4558
|
-
super(parameters, LocalRelativeObjectIdentifierValueBlock);
|
|
4559
|
-
this.idBlock.tagClass = 1;
|
|
4560
|
-
this.idBlock.tagNumber = 13;
|
|
4561
|
-
}
|
|
4562
4564
|
getValue() {
|
|
4563
4565
|
return this.valueBlock.toString();
|
|
4564
4566
|
}
|
|
4565
4567
|
setValue(value) {
|
|
4566
4568
|
this.valueBlock.fromString(value);
|
|
4567
4569
|
}
|
|
4570
|
+
constructor(parameters = {}) {
|
|
4571
|
+
super(parameters, LocalRelativeObjectIdentifierValueBlock);
|
|
4572
|
+
this.idBlock.tagClass = 1;
|
|
4573
|
+
this.idBlock.tagNumber = 13;
|
|
4574
|
+
}
|
|
4568
4575
|
onAsciiEncoding() {
|
|
4569
4576
|
return `${this.constructor.NAME} : ${this.valueBlock.toString() || "empty"}`;
|
|
4570
4577
|
}
|
|
@@ -4961,7 +4968,8 @@ var GeneralizedTime = class extends UTCTime {
|
|
|
4961
4968
|
this.millisecond = inputDate.getUTCMilliseconds();
|
|
4962
4969
|
}
|
|
4963
4970
|
toDate() {
|
|
4964
|
-
|
|
4971
|
+
const utcDate = Date.UTC(this.year, this.month - 1, this.day, this.hour, this.minute, this.second, this.millisecond);
|
|
4972
|
+
return new Date(utcDate);
|
|
4965
4973
|
}
|
|
4966
4974
|
fromString(inputString) {
|
|
4967
4975
|
let isUTC = false;
|
|
@@ -5210,28 +5218,28 @@ var Repeated = class extends Any {
|
|
|
5210
5218
|
}
|
|
5211
5219
|
};
|
|
5212
5220
|
var RawData = class {
|
|
5213
|
-
constructor({ data = EMPTY_VIEW } = {}) {
|
|
5214
|
-
this.dataView = BufferSourceConverter.toUint8Array(data);
|
|
5215
|
-
}
|
|
5216
5221
|
get data() {
|
|
5217
5222
|
return this.dataView.slice().buffer;
|
|
5218
5223
|
}
|
|
5219
5224
|
set data(value) {
|
|
5220
5225
|
this.dataView = BufferSourceConverter.toUint8Array(value);
|
|
5221
5226
|
}
|
|
5227
|
+
constructor({ data = EMPTY_VIEW } = {}) {
|
|
5228
|
+
this.dataView = BufferSourceConverter.toUint8Array(data);
|
|
5229
|
+
}
|
|
5222
5230
|
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
5223
5231
|
const endLength = inputOffset + inputLength;
|
|
5224
5232
|
this.dataView = BufferSourceConverter.toUint8Array(inputBuffer).subarray(inputOffset, endLength);
|
|
5225
5233
|
return endLength;
|
|
5226
5234
|
}
|
|
5227
|
-
toBER(
|
|
5235
|
+
toBER(_sizeOnly) {
|
|
5228
5236
|
return this.dataView.slice().buffer;
|
|
5229
5237
|
}
|
|
5230
5238
|
};
|
|
5231
5239
|
function compareSchema(root, inputData, inputSchema) {
|
|
5232
5240
|
if (inputSchema instanceof Choice) {
|
|
5233
|
-
for (
|
|
5234
|
-
const result = compareSchema(root, inputData,
|
|
5241
|
+
for (const element of inputSchema.value) {
|
|
5242
|
+
const result = compareSchema(root, inputData, element);
|
|
5235
5243
|
if (result.verified) {
|
|
5236
5244
|
return {
|
|
5237
5245
|
verified: true,
|
|
@@ -5242,9 +5250,7 @@ function compareSchema(root, inputData, inputSchema) {
|
|
|
5242
5250
|
{
|
|
5243
5251
|
const _result = {
|
|
5244
5252
|
verified: false,
|
|
5245
|
-
result: {
|
|
5246
|
-
error: "Wrong values for Choice type"
|
|
5247
|
-
}
|
|
5253
|
+
result: { error: "Wrong values for Choice type" }
|
|
5248
5254
|
};
|
|
5249
5255
|
if (inputSchema.hasOwnProperty(NAME))
|
|
5250
5256
|
_result.name = inputSchema.name;
|
|
@@ -5390,9 +5396,7 @@ function compareSchema(root, inputData, inputSchema) {
|
|
|
5390
5396
|
let admission = 0;
|
|
5391
5397
|
let result = {
|
|
5392
5398
|
verified: false,
|
|
5393
|
-
result: {
|
|
5394
|
-
error: "Unknown error"
|
|
5395
|
-
}
|
|
5399
|
+
result: { error: "Unknown error" }
|
|
5396
5400
|
};
|
|
5397
5401
|
let maxLength = inputSchema.valueBlock.value.length;
|
|
5398
5402
|
if (maxLength > 0) {
|
|
@@ -5769,10 +5773,7 @@ var AsnSchemaStorage = class {
|
|
|
5769
5773
|
}
|
|
5770
5774
|
}
|
|
5771
5775
|
createDefault(target) {
|
|
5772
|
-
const schema = {
|
|
5773
|
-
type: AsnTypeTypes.Sequence,
|
|
5774
|
-
items: {}
|
|
5775
|
-
};
|
|
5776
|
+
const schema = { type: AsnTypeTypes.Sequence, items: {} };
|
|
5776
5777
|
const parentSchema = this.findParentSchema(target);
|
|
5777
5778
|
if (parentSchema) {
|
|
5778
5779
|
Object.assign(schema, parentSchema);
|
|
@@ -5814,26 +5815,14 @@ var AsnSchemaStorage = class {
|
|
|
5814
5815
|
const Container = item.repeated === "set" ? Set : Sequence;
|
|
5815
5816
|
asn1Item = new Container({
|
|
5816
5817
|
name: "",
|
|
5817
|
-
value: [
|
|
5818
|
-
new Repeated({
|
|
5819
|
-
name,
|
|
5820
|
-
value: asn1Item
|
|
5821
|
-
})
|
|
5822
|
-
]
|
|
5818
|
+
value: [new Repeated({ name, value: asn1Item })]
|
|
5823
5819
|
});
|
|
5824
5820
|
}
|
|
5825
5821
|
if (item.context !== null && item.context !== void 0) {
|
|
5826
5822
|
if (item.implicit) {
|
|
5827
5823
|
if (typeof item.type === "number" || isConvertible(item.type)) {
|
|
5828
5824
|
const Container = item.repeated ? Constructed : Primitive;
|
|
5829
|
-
asn1Value.push(new Container({
|
|
5830
|
-
name,
|
|
5831
|
-
optional,
|
|
5832
|
-
idBlock: {
|
|
5833
|
-
tagClass: 3,
|
|
5834
|
-
tagNumber: item.context
|
|
5835
|
-
}
|
|
5836
|
-
}));
|
|
5825
|
+
asn1Value.push(new Container({ name, optional, idBlock: { tagClass: 3, tagNumber: item.context } }));
|
|
5837
5826
|
} else {
|
|
5838
5827
|
this.cache(item.type);
|
|
5839
5828
|
const isRepeated = !!item.repeated;
|
|
@@ -5842,20 +5831,14 @@ var AsnSchemaStorage = class {
|
|
|
5842
5831
|
asn1Value.push(new Constructed({
|
|
5843
5832
|
name: !isRepeated ? name : "",
|
|
5844
5833
|
optional,
|
|
5845
|
-
idBlock: {
|
|
5846
|
-
tagClass: 3,
|
|
5847
|
-
tagNumber: item.context
|
|
5848
|
-
},
|
|
5834
|
+
idBlock: { tagClass: 3, tagNumber: item.context },
|
|
5849
5835
|
value
|
|
5850
5836
|
}));
|
|
5851
5837
|
}
|
|
5852
5838
|
} else {
|
|
5853
5839
|
asn1Value.push(new Constructed({
|
|
5854
5840
|
optional,
|
|
5855
|
-
idBlock: {
|
|
5856
|
-
tagClass: 3,
|
|
5857
|
-
tagNumber: item.context
|
|
5858
|
-
},
|
|
5841
|
+
idBlock: { tagClass: 3, tagNumber: item.context },
|
|
5859
5842
|
value: [asn1Item]
|
|
5860
5843
|
}));
|
|
5861
5844
|
}
|
|
@@ -5911,7 +5894,6 @@ var AsnParser = class {
|
|
|
5911
5894
|
return res;
|
|
5912
5895
|
}
|
|
5913
5896
|
static fromASN(asn1Schema, target) {
|
|
5914
|
-
var _a2;
|
|
5915
5897
|
try {
|
|
5916
5898
|
if (isConvertible(target)) {
|
|
5917
5899
|
const value = new target();
|
|
@@ -5920,104 +5902,259 @@ var AsnParser = class {
|
|
|
5920
5902
|
const schema = schemaStorage.get(target);
|
|
5921
5903
|
schemaStorage.cache(target);
|
|
5922
5904
|
let targetSchema = schema.schema;
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
|
|
5926
|
-
tagClass: 3,
|
|
5927
|
-
tagNumber: asn1Schema.idBlock.tagNumber
|
|
5928
|
-
},
|
|
5929
|
-
value: schema.schema.valueBlock.value
|
|
5930
|
-
});
|
|
5931
|
-
for (const key in schema.items) {
|
|
5932
|
-
delete asn1Schema[key];
|
|
5933
|
-
}
|
|
5905
|
+
const choiceResult = this.handleChoiceTypes(asn1Schema, schema, target, targetSchema);
|
|
5906
|
+
if (choiceResult === null || choiceResult === void 0 ? void 0 : choiceResult.result) {
|
|
5907
|
+
return choiceResult.result;
|
|
5934
5908
|
}
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
throw new AsnSchemaValidationError(`Data does not match to ${target.name} ASN1 schema. ${asn1ComparedSchema.result.error}`);
|
|
5909
|
+
if (choiceResult === null || choiceResult === void 0 ? void 0 : choiceResult.targetSchema) {
|
|
5910
|
+
targetSchema = choiceResult.targetSchema;
|
|
5938
5911
|
}
|
|
5912
|
+
const sequenceResult = this.handleSequenceTypes(asn1Schema, schema, target, targetSchema);
|
|
5939
5913
|
const res = new target();
|
|
5940
5914
|
if (isTypeOfArray(target)) {
|
|
5941
|
-
|
|
5942
|
-
throw new Error(`Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.`);
|
|
5943
|
-
}
|
|
5944
|
-
const itemType = schema.itemType;
|
|
5945
|
-
if (typeof itemType === "number") {
|
|
5946
|
-
const converter = defaultConverter(itemType);
|
|
5947
|
-
if (!converter) {
|
|
5948
|
-
throw new Error(`Cannot get default converter for array item of ${target.name} ASN1 schema`);
|
|
5949
|
-
}
|
|
5950
|
-
return target.from(asn1Schema.valueBlock.value, (element) => converter.fromASN(element));
|
|
5951
|
-
} else {
|
|
5952
|
-
return target.from(asn1Schema.valueBlock.value, (element) => this.fromASN(element, itemType));
|
|
5953
|
-
}
|
|
5915
|
+
return this.handleArrayTypes(asn1Schema, schema, target);
|
|
5954
5916
|
}
|
|
5917
|
+
this.processSchemaItems(schema, sequenceResult, res);
|
|
5918
|
+
return res;
|
|
5919
|
+
} catch (error) {
|
|
5920
|
+
if (error instanceof AsnSchemaValidationError) {
|
|
5921
|
+
error.schemas.push(target.name);
|
|
5922
|
+
}
|
|
5923
|
+
throw error;
|
|
5924
|
+
}
|
|
5925
|
+
}
|
|
5926
|
+
static handleChoiceTypes(asn1Schema, schema, target, targetSchema) {
|
|
5927
|
+
if (asn1Schema.constructor === Constructed && schema.type === AsnTypeTypes.Choice && asn1Schema.idBlock.tagClass === 3) {
|
|
5955
5928
|
for (const key in schema.items) {
|
|
5956
|
-
const asn1SchemaValue = asn1ComparedSchema.result[key];
|
|
5957
|
-
if (!asn1SchemaValue) {
|
|
5958
|
-
continue;
|
|
5959
|
-
}
|
|
5960
5929
|
const schemaItem = schema.items[key];
|
|
5961
|
-
|
|
5962
|
-
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
|
|
5966
|
-
|
|
5967
|
-
|
|
5968
|
-
|
|
5969
|
-
|
|
5970
|
-
|
|
5971
|
-
|
|
5972
|
-
const newItemAsn = fromBER(newItem.toBER(false));
|
|
5973
|
-
if (newItemAsn.offset === -1) {
|
|
5974
|
-
throw new Error(`Cannot parse the child item. ${newItemAsn.result.error}`);
|
|
5975
|
-
}
|
|
5976
|
-
if (!("value" in newItemAsn.result.valueBlock && Array.isArray(newItemAsn.result.valueBlock.value))) {
|
|
5977
|
-
throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");
|
|
5978
|
-
}
|
|
5979
|
-
const value = newItemAsn.result.valueBlock.value;
|
|
5980
|
-
res[key] = Array.from(value, (element) => converter.fromASN(element));
|
|
5981
|
-
} else {
|
|
5982
|
-
res[key] = Array.from(asn1SchemaValue, (element) => converter.fromASN(element));
|
|
5983
|
-
}
|
|
5984
|
-
} else {
|
|
5985
|
-
let value = asn1SchemaValue;
|
|
5986
|
-
if (schemaItem.implicit) {
|
|
5987
|
-
let newItem;
|
|
5988
|
-
if (isConvertible(schemaItemType)) {
|
|
5989
|
-
newItem = new schemaItemType().toSchema("");
|
|
5990
|
-
} else {
|
|
5991
|
-
const Asn1TypeName = AsnPropTypes[schemaItemType];
|
|
5992
|
-
const Asn1Type = index_es_exports[Asn1TypeName];
|
|
5993
|
-
if (!Asn1Type) {
|
|
5994
|
-
throw new Error(`Cannot get '${Asn1TypeName}' class from asn1js module`);
|
|
5995
|
-
}
|
|
5996
|
-
newItem = new Asn1Type();
|
|
5930
|
+
if (schemaItem.context === asn1Schema.idBlock.tagNumber && schemaItem.implicit) {
|
|
5931
|
+
if (typeof schemaItem.type === "function" && schemaStorage.has(schemaItem.type)) {
|
|
5932
|
+
const fieldSchema = schemaStorage.get(schemaItem.type);
|
|
5933
|
+
if (fieldSchema && fieldSchema.type === AsnTypeTypes.Sequence) {
|
|
5934
|
+
const newSeq = new Sequence();
|
|
5935
|
+
if ("value" in asn1Schema.valueBlock && Array.isArray(asn1Schema.valueBlock.value) && "value" in newSeq.valueBlock) {
|
|
5936
|
+
newSeq.valueBlock.value = asn1Schema.valueBlock.value;
|
|
5937
|
+
const fieldValue = this.fromASN(newSeq, schemaItem.type);
|
|
5938
|
+
const res = new target();
|
|
5939
|
+
res[key] = fieldValue;
|
|
5940
|
+
return { result: res };
|
|
5997
5941
|
}
|
|
5998
|
-
newItem.valueBlock = value.valueBlock;
|
|
5999
|
-
value = fromBER(newItem.toBER(false)).result;
|
|
6000
5942
|
}
|
|
6001
|
-
res[key] = converter.fromASN(value);
|
|
6002
5943
|
}
|
|
6003
|
-
}
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
|
|
6010
|
-
|
|
5944
|
+
}
|
|
5945
|
+
}
|
|
5946
|
+
} else if (asn1Schema.constructor === Constructed && schema.type !== AsnTypeTypes.Choice) {
|
|
5947
|
+
const newTargetSchema = new Constructed({
|
|
5948
|
+
idBlock: {
|
|
5949
|
+
tagClass: 3,
|
|
5950
|
+
tagNumber: asn1Schema.idBlock.tagNumber
|
|
5951
|
+
},
|
|
5952
|
+
value: schema.schema.valueBlock.value
|
|
5953
|
+
});
|
|
5954
|
+
for (const key in schema.items) {
|
|
5955
|
+
delete asn1Schema[key];
|
|
5956
|
+
}
|
|
5957
|
+
return { targetSchema: newTargetSchema };
|
|
5958
|
+
}
|
|
5959
|
+
return null;
|
|
5960
|
+
}
|
|
5961
|
+
static handleSequenceTypes(asn1Schema, schema, target, targetSchema) {
|
|
5962
|
+
if (schema.type === AsnTypeTypes.Sequence) {
|
|
5963
|
+
const asn1ComparedSchema = compareSchema({}, asn1Schema, targetSchema);
|
|
5964
|
+
if (!asn1ComparedSchema.verified) {
|
|
5965
|
+
throw new AsnSchemaValidationError(`Data does not match to ${target.name} ASN1 schema.${asn1ComparedSchema.result.error ? ` ${asn1ComparedSchema.result.error}` : ""}`);
|
|
5966
|
+
}
|
|
5967
|
+
return asn1ComparedSchema;
|
|
5968
|
+
} else {
|
|
5969
|
+
const asn1ComparedSchema = compareSchema({}, asn1Schema, targetSchema);
|
|
5970
|
+
if (!asn1ComparedSchema.verified) {
|
|
5971
|
+
throw new AsnSchemaValidationError(`Data does not match to ${target.name} ASN1 schema.${asn1ComparedSchema.result.error ? ` ${asn1ComparedSchema.result.error}` : ""}`);
|
|
5972
|
+
}
|
|
5973
|
+
return asn1ComparedSchema;
|
|
5974
|
+
}
|
|
5975
|
+
}
|
|
5976
|
+
static processRepeatedField(asn1Elements, asn1Index, schemaItem) {
|
|
5977
|
+
let elementsToProcess = asn1Elements.slice(asn1Index);
|
|
5978
|
+
if (elementsToProcess.length === 1 && elementsToProcess[0].constructor.name === "Sequence") {
|
|
5979
|
+
const seq = elementsToProcess[0];
|
|
5980
|
+
if (seq.valueBlock && seq.valueBlock.value && Array.isArray(seq.valueBlock.value)) {
|
|
5981
|
+
elementsToProcess = seq.valueBlock.value;
|
|
5982
|
+
}
|
|
5983
|
+
}
|
|
5984
|
+
if (typeof schemaItem.type === "number") {
|
|
5985
|
+
const converter = defaultConverter(schemaItem.type);
|
|
5986
|
+
if (!converter)
|
|
5987
|
+
throw new Error(`No converter for ASN.1 type ${schemaItem.type}`);
|
|
5988
|
+
return elementsToProcess.filter((el) => el && el.valueBlock).map((el) => {
|
|
5989
|
+
try {
|
|
5990
|
+
return converter.fromASN(el);
|
|
5991
|
+
} catch {
|
|
5992
|
+
return void 0;
|
|
5993
|
+
}
|
|
5994
|
+
}).filter((v) => v !== void 0);
|
|
5995
|
+
} else {
|
|
5996
|
+
return elementsToProcess.filter((el) => el && el.valueBlock).map((el) => {
|
|
5997
|
+
try {
|
|
5998
|
+
return this.fromASN(el, schemaItem.type);
|
|
5999
|
+
} catch {
|
|
6000
|
+
return void 0;
|
|
6001
|
+
}
|
|
6002
|
+
}).filter((v) => v !== void 0);
|
|
6003
|
+
}
|
|
6004
|
+
}
|
|
6005
|
+
static processPrimitiveField(asn1Element, schemaItem) {
|
|
6006
|
+
const converter = defaultConverter(schemaItem.type);
|
|
6007
|
+
if (!converter)
|
|
6008
|
+
throw new Error(`No converter for ASN.1 type ${schemaItem.type}`);
|
|
6009
|
+
return converter.fromASN(asn1Element);
|
|
6010
|
+
}
|
|
6011
|
+
static isOptionalChoiceField(schemaItem) {
|
|
6012
|
+
return schemaItem.optional && typeof schemaItem.type === "function" && schemaStorage.has(schemaItem.type) && schemaStorage.get(schemaItem.type).type === AsnTypeTypes.Choice;
|
|
6013
|
+
}
|
|
6014
|
+
static processOptionalChoiceField(asn1Element, schemaItem) {
|
|
6015
|
+
try {
|
|
6016
|
+
const value = this.fromASN(asn1Element, schemaItem.type);
|
|
6017
|
+
return { processed: true, value };
|
|
6018
|
+
} catch (err) {
|
|
6019
|
+
if (err instanceof AsnSchemaValidationError && /Wrong values for Choice type/.test(err.message)) {
|
|
6020
|
+
return { processed: false };
|
|
6021
|
+
}
|
|
6022
|
+
throw err;
|
|
6023
|
+
}
|
|
6024
|
+
}
|
|
6025
|
+
static handleArrayTypes(asn1Schema, schema, target) {
|
|
6026
|
+
if (!("value" in asn1Schema.valueBlock && Array.isArray(asn1Schema.valueBlock.value))) {
|
|
6027
|
+
throw new Error(`Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.`);
|
|
6028
|
+
}
|
|
6029
|
+
const itemType = schema.itemType;
|
|
6030
|
+
if (typeof itemType === "number") {
|
|
6031
|
+
const converter = defaultConverter(itemType);
|
|
6032
|
+
if (!converter) {
|
|
6033
|
+
throw new Error(`Cannot get default converter for array item of ${target.name} ASN1 schema`);
|
|
6034
|
+
}
|
|
6035
|
+
return target.from(asn1Schema.valueBlock.value, (element) => converter.fromASN(element));
|
|
6036
|
+
} else {
|
|
6037
|
+
return target.from(asn1Schema.valueBlock.value, (element) => this.fromASN(element, itemType));
|
|
6038
|
+
}
|
|
6039
|
+
}
|
|
6040
|
+
static processSchemaItems(schema, asn1ComparedSchema, res) {
|
|
6041
|
+
for (const key in schema.items) {
|
|
6042
|
+
const asn1SchemaValue = asn1ComparedSchema.result[key];
|
|
6043
|
+
if (!asn1SchemaValue) {
|
|
6044
|
+
continue;
|
|
6045
|
+
}
|
|
6046
|
+
const schemaItem = schema.items[key];
|
|
6047
|
+
const schemaItemType = schemaItem.type;
|
|
6048
|
+
let parsedValue;
|
|
6049
|
+
if (typeof schemaItemType === "number" || isConvertible(schemaItemType)) {
|
|
6050
|
+
parsedValue = this.processPrimitiveSchemaItem(asn1SchemaValue, schemaItem, schemaItemType);
|
|
6051
|
+
} else {
|
|
6052
|
+
parsedValue = this.processComplexSchemaItem(asn1SchemaValue, schemaItem, schemaItemType);
|
|
6053
|
+
}
|
|
6054
|
+
if (parsedValue && typeof parsedValue === "object" && "value" in parsedValue && "raw" in parsedValue) {
|
|
6055
|
+
res[key] = parsedValue.value;
|
|
6056
|
+
res[`${key}Raw`] = parsedValue.raw;
|
|
6057
|
+
} else {
|
|
6058
|
+
res[key] = parsedValue;
|
|
6059
|
+
}
|
|
6060
|
+
}
|
|
6061
|
+
}
|
|
6062
|
+
static processPrimitiveSchemaItem(asn1SchemaValue, schemaItem, schemaItemType) {
|
|
6063
|
+
var _a2;
|
|
6064
|
+
const converter = (_a2 = schemaItem.converter) !== null && _a2 !== void 0 ? _a2 : isConvertible(schemaItemType) ? new schemaItemType() : null;
|
|
6065
|
+
if (!converter) {
|
|
6066
|
+
throw new Error("Converter is empty");
|
|
6067
|
+
}
|
|
6068
|
+
if (schemaItem.repeated) {
|
|
6069
|
+
return this.processRepeatedPrimitiveItem(asn1SchemaValue, schemaItem, converter);
|
|
6070
|
+
} else {
|
|
6071
|
+
return this.processSinglePrimitiveItem(asn1SchemaValue, schemaItem, schemaItemType, converter);
|
|
6072
|
+
}
|
|
6073
|
+
}
|
|
6074
|
+
static processRepeatedPrimitiveItem(asn1SchemaValue, schemaItem, converter) {
|
|
6075
|
+
if (schemaItem.implicit) {
|
|
6076
|
+
const Container = schemaItem.repeated === "sequence" ? Sequence : Set;
|
|
6077
|
+
const newItem = new Container();
|
|
6078
|
+
newItem.valueBlock = asn1SchemaValue.valueBlock;
|
|
6079
|
+
const newItemAsn = fromBER(newItem.toBER(false));
|
|
6080
|
+
if (newItemAsn.offset === -1) {
|
|
6081
|
+
throw new Error(`Cannot parse the child item. ${newItemAsn.result.error}`);
|
|
6082
|
+
}
|
|
6083
|
+
if (!("value" in newItemAsn.result.valueBlock && Array.isArray(newItemAsn.result.valueBlock.value))) {
|
|
6084
|
+
throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");
|
|
6085
|
+
}
|
|
6086
|
+
const value = newItemAsn.result.valueBlock.value;
|
|
6087
|
+
return Array.from(value, (element) => converter.fromASN(element));
|
|
6088
|
+
} else {
|
|
6089
|
+
return Array.from(asn1SchemaValue, (element) => converter.fromASN(element));
|
|
6090
|
+
}
|
|
6091
|
+
}
|
|
6092
|
+
static processSinglePrimitiveItem(asn1SchemaValue, schemaItem, schemaItemType, converter) {
|
|
6093
|
+
let value = asn1SchemaValue;
|
|
6094
|
+
if (schemaItem.implicit) {
|
|
6095
|
+
let newItem;
|
|
6096
|
+
if (isConvertible(schemaItemType)) {
|
|
6097
|
+
newItem = new schemaItemType().toSchema("");
|
|
6098
|
+
} else {
|
|
6099
|
+
const Asn1TypeName = AsnPropTypes[schemaItemType];
|
|
6100
|
+
const Asn1Type = index_es_exports[Asn1TypeName];
|
|
6101
|
+
if (!Asn1Type) {
|
|
6102
|
+
throw new Error(`Cannot get '${Asn1TypeName}' class from asn1js module`);
|
|
6103
|
+
}
|
|
6104
|
+
newItem = new Asn1Type();
|
|
6105
|
+
}
|
|
6106
|
+
newItem.valueBlock = value.valueBlock;
|
|
6107
|
+
value = fromBER(newItem.toBER(false)).result;
|
|
6108
|
+
}
|
|
6109
|
+
return converter.fromASN(value);
|
|
6110
|
+
}
|
|
6111
|
+
static processComplexSchemaItem(asn1SchemaValue, schemaItem, schemaItemType) {
|
|
6112
|
+
if (schemaItem.repeated) {
|
|
6113
|
+
if (!Array.isArray(asn1SchemaValue)) {
|
|
6114
|
+
throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");
|
|
6115
|
+
}
|
|
6116
|
+
return Array.from(asn1SchemaValue, (element) => this.fromASN(element, schemaItemType));
|
|
6117
|
+
} else {
|
|
6118
|
+
const valueToProcess = this.handleImplicitTagging(asn1SchemaValue, schemaItem, schemaItemType);
|
|
6119
|
+
if (this.isOptionalChoiceField(schemaItem)) {
|
|
6120
|
+
try {
|
|
6121
|
+
return this.fromASN(valueToProcess, schemaItemType);
|
|
6122
|
+
} catch (err) {
|
|
6123
|
+
if (err instanceof AsnSchemaValidationError && /Wrong values for Choice type/.test(err.message)) {
|
|
6124
|
+
return void 0;
|
|
6011
6125
|
}
|
|
6126
|
+
throw err;
|
|
6012
6127
|
}
|
|
6128
|
+
} else {
|
|
6129
|
+
const parsedValue = this.fromASN(valueToProcess, schemaItemType);
|
|
6130
|
+
if (schemaItem.raw) {
|
|
6131
|
+
return {
|
|
6132
|
+
value: parsedValue,
|
|
6133
|
+
raw: asn1SchemaValue.valueBeforeDecodeView
|
|
6134
|
+
};
|
|
6135
|
+
}
|
|
6136
|
+
return parsedValue;
|
|
6013
6137
|
}
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
|
|
6017
|
-
|
|
6138
|
+
}
|
|
6139
|
+
}
|
|
6140
|
+
static handleImplicitTagging(asn1SchemaValue, schemaItem, schemaItemType) {
|
|
6141
|
+
if (schemaItem.implicit && typeof schemaItem.context === "number") {
|
|
6142
|
+
const schema = schemaStorage.get(schemaItemType);
|
|
6143
|
+
if (schema.type === AsnTypeTypes.Sequence) {
|
|
6144
|
+
const newSeq = new Sequence();
|
|
6145
|
+
if ("value" in asn1SchemaValue.valueBlock && Array.isArray(asn1SchemaValue.valueBlock.value) && "value" in newSeq.valueBlock) {
|
|
6146
|
+
newSeq.valueBlock.value = asn1SchemaValue.valueBlock.value;
|
|
6147
|
+
return newSeq;
|
|
6148
|
+
}
|
|
6149
|
+
} else if (schema.type === AsnTypeTypes.Set) {
|
|
6150
|
+
const newSet = new Set();
|
|
6151
|
+
if ("value" in asn1SchemaValue.valueBlock && Array.isArray(asn1SchemaValue.valueBlock.value) && "value" in newSet.valueBlock) {
|
|
6152
|
+
newSet.valueBlock.value = asn1SchemaValue.valueBlock.value;
|
|
6153
|
+
return newSet;
|
|
6154
|
+
}
|
|
6018
6155
|
}
|
|
6019
|
-
throw error;
|
|
6020
6156
|
}
|
|
6157
|
+
return asn1SchemaValue;
|
|
6021
6158
|
}
|
|
6022
6159
|
};
|
|
6023
6160
|
|
|
@@ -6313,7 +6450,7 @@ pvtsutils/build/index.es.js:
|
|
|
6313
6450
|
(*!
|
|
6314
6451
|
* MIT License
|
|
6315
6452
|
*
|
|
6316
|
-
* Copyright (c) 2017-
|
|
6453
|
+
* Copyright (c) 2017-2024 Peculiar Ventures, LLC
|
|
6317
6454
|
*
|
|
6318
6455
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6319
6456
|
* of this software and associated documentation files (the "Software"), to deal
|