@wildboar/pkcs
Version:
Public Key Cryptography Standard PDUs in TypeScript
175 lines • 6.23 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;
/* eslint-disable */
const asn1_ts_1 = require("asn1-ts");
const $ = require("asn1-ts/dist/node/functional");
/* START_OF_SYMBOL_DEFINITION Path */
/**
* @summary Path
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* Path ::= SEQUENCE {
* path OCTET STRING,
* index INTEGER (0..pkcs15-ub-index) OPTIONAL,
* length [0] INTEGER (0..pkcs15-ub-index) OPTIONAL
* }( WITH COMPONENTS {..., index PRESENT, length PRESENT} | WITH COMPONENTS {..., index ABSENT, length ABSENT})
* ```
*
* @class
*/
class Path {
constructor(
/**
* @summary `path`.
* @public
* @readonly
*/
path,
/**
* @summary `index`.
* @public
* @readonly
*/
index,
/**
* @summary `length`.
* @public
* @readonly
*/
length) {
this.path = path;
this.index = index;
this.length = length;
}
/**
* @summary Restructures an object into a Path
* @description
*
* This takes an `object` and converts it to a `Path`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `Path`.
* @returns {Path}
*/
static _from_object(_o) {
return new Path(_o.path, _o.index, _o.length);
}
}
exports.Path = Path;
/* END_OF_SYMBOL_DEFINITION Path */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_Path */
/**
* @summary The Leading Root Component Types of Path
* @description
*
* This is an array of `ComponentSpec`s that define how to decode the leading root component type list of a SET or SEQUENCE.
*
* @constant
*/
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),
];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_Path */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_Path */
/**
* @summary The Trailing Root Component Types of Path
* @description
*
* This is an array of `ComponentSpec`s that define how to decode the trailing root component type list of a SET or SEQUENCE.
*
* @constant
*/
exports._root_component_type_list_2_spec_for_Path = [];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_Path */
/* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_Path */
/**
* @summary The Extension Addition Component Types of Path
* @description
*
* This is an array of `ComponentSpec`s that define how to decode the extension addition component type list of a SET or SEQUENCE.
*
* @constant
*/
exports._extension_additions_list_spec_for_Path = [];
/* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_Path */
/* START_OF_SYMBOL_DEFINITION _cached_decoder_for_Path */
let _cached_decoder_for_Path = null;
/* END_OF_SYMBOL_DEFINITION _cached_decoder_for_Path */
/* START_OF_SYMBOL_DEFINITION _decode_Path */
/**
* @summary Decodes an ASN.1 element into a(n) Path
* @function
* @param {_Element} el The element being decoded.
* @returns {Path} The decoded data structure.
*/
function _decode_Path(el) {
if (!_cached_decoder_for_Path) {
_cached_decoder_for_Path = function (el) {
/* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */
let path;
let index;
let length;
/* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */
/* START_OF_CALLBACKS_MAP */
const callbacks = {
path: (_el) => {
path = $._decodeOctetString(_el);
},
index: (_el) => {
index = $._decodeInteger(_el);
},
length: (_el) => {
length = $._decode_implicit(() => $._decodeInteger)(_el);
},
};
/* END_OF_CALLBACKS_MAP */
$._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(
/* SEQUENCE_CONSTRUCTOR_CALL */ path, index, length);
};
}
return _cached_decoder_for_Path(el);
}
exports._decode_Path = _decode_Path;
/* END_OF_SYMBOL_DEFINITION _decode_Path */
/* START_OF_SYMBOL_DEFINITION _cached_encoder_for_Path */
let _cached_encoder_for_Path = null;
/* END_OF_SYMBOL_DEFINITION _cached_encoder_for_Path */
/* START_OF_SYMBOL_DEFINITION _encode_Path */
/**
* @summary Encodes a(n) Path into an ASN.1 Element.
* @function
* @param {value} el The element being decoded.
* @param elGetter A function that can be used to get new ASN.1 elements.
* @returns {_Element} The Path, encoded as an ASN.1 Element.
*/
function _encode_Path(value, elGetter) {
if (!_cached_encoder_for_Path) {
_cached_encoder_for_Path = function (value, elGetter) {
return $._encodeSequence([]
.concat([
/* REQUIRED */ $._encodeOctetString(value.path, $.BER),
/* IF_ABSENT */ value.index === undefined
? undefined
: $._encodeInteger(value.index, $.BER),
/* IF_ABSENT */ 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;
/* END_OF_SYMBOL_DEFINITION _encode_Path */
/* eslint-enable */
//# sourceMappingURL=Path.ta.js.map