pkcs-ts
Version:
PKCS #1 through #15 (Except #11) - Private and Public Keys, Certificates, and More
70 lines • 3.07 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_Path = exports._decode_Path = exports._extension_additions_list_spec_for_Path = exports._root_component_type_list_2_spec_for_Path = exports._root_component_type_list_1_spec_for_Path = exports.Path = void 0;
const tslib_1 = require("tslib");
const asn1_ts_1 = require("asn1-ts");
const $ = tslib_1.__importStar(require("asn1-ts/dist/node/functional"));
class Path {
constructor(path, index, length) {
this.path = path;
this.index = index;
this.length = length;
}
static _from_object(_o) {
return new Path(_o.path, _o.index, _o.length);
}
}
exports.Path = Path;
exports._root_component_type_list_1_spec_for_Path = [
new $.ComponentSpec("path", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 4), undefined, undefined),
new $.ComponentSpec("index", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined),
new $.ComponentSpec("length", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 0), undefined, undefined),
];
exports._root_component_type_list_2_spec_for_Path = [];
exports._extension_additions_list_spec_for_Path = [];
let _cached_decoder_for_Path = null;
function _decode_Path(el) {
if (!_cached_decoder_for_Path) {
_cached_decoder_for_Path = function (el) {
let path;
let index;
let length;
const callbacks = {
path: (_el) => {
path = $._decodeOctetString(_el);
},
index: (_el) => {
index = $._decodeInteger(_el);
},
length: (_el) => {
length = $._decode_implicit(() => $._decodeInteger)(_el);
},
};
$._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_Path, exports._extension_additions_list_spec_for_Path, exports._root_component_type_list_2_spec_for_Path, undefined);
return new Path(path, index, length);
};
}
return _cached_decoder_for_Path(el);
}
exports._decode_Path = _decode_Path;
let _cached_encoder_for_Path = null;
function _encode_Path(value, elGetter) {
if (!_cached_encoder_for_Path) {
_cached_encoder_for_Path = function (value, elGetter) {
return $._encodeSequence([]
.concat([
$._encodeOctetString(value.path, $.BER),
value.index === undefined
? undefined
: $._encodeInteger(value.index, $.BER),
value.length === undefined
? undefined
: $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 0, () => $._encodeInteger, $.BER)(value.length, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_Path(value, elGetter);
}
exports._encode_Path = _encode_Path;
//# sourceMappingURL=Path.ta.js.map