UNPKG

@wildboar/pkcs

Version:
163 lines 7.38 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_EncapsulatedContentInfo = exports._decode_EncapsulatedContentInfo = exports._extension_additions_list_spec_for_EncapsulatedContentInfo = exports._root_component_type_list_2_spec_for_EncapsulatedContentInfo = exports._root_component_type_list_1_spec_for_EncapsulatedContentInfo = exports.EncapsulatedContentInfo = exports._encode_ContentType = exports._decode_ContentType = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const ContentType_ta_1 = require("../CryptographicMessageSyntax/ContentType.ta"); var ContentType_ta_2 = require("../CryptographicMessageSyntax/ContentType.ta"); Object.defineProperty(exports, "_decode_ContentType", { enumerable: true, get: function () { return ContentType_ta_2._decode_ContentType; } }); Object.defineProperty(exports, "_encode_ContentType", { enumerable: true, get: function () { return ContentType_ta_2._encode_ContentType; } }); /* START_OF_SYMBOL_DEFINITION EncapsulatedContentInfo */ /** * @summary EncapsulatedContentInfo * @description * * ### ASN.1 Definition: * * ```asn1 * EncapsulatedContentInfo ::= SEQUENCE { * eContentType ContentType, * eContent [0] EXPLICIT OCTET STRING OPTIONAL * } * ``` * * @class */ class EncapsulatedContentInfo { constructor( /** * @summary `eContentType`. * @public * @readonly */ eContentType, /** * @summary `eContent`. * @public * @readonly */ eContent) { this.eContentType = eContentType; this.eContent = eContent; } /** * @summary Restructures an object into a EncapsulatedContentInfo * @description * * This takes an `object` and converts it to a `EncapsulatedContentInfo`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `EncapsulatedContentInfo`. * @returns {EncapsulatedContentInfo} */ static _from_object(_o) { return new EncapsulatedContentInfo(_o.eContentType, _o.eContent); } } exports.EncapsulatedContentInfo = EncapsulatedContentInfo; /* END_OF_SYMBOL_DEFINITION EncapsulatedContentInfo */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_EncapsulatedContentInfo */ /** * @summary The Leading Root Component Types of EncapsulatedContentInfo * @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_EncapsulatedContentInfo = [ new $.ComponentSpec("eContentType", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 6), undefined, undefined), new $.ComponentSpec("eContent", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 0), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_EncapsulatedContentInfo */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_EncapsulatedContentInfo */ /** * @summary The Trailing Root Component Types of EncapsulatedContentInfo * @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_EncapsulatedContentInfo = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_EncapsulatedContentInfo */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_EncapsulatedContentInfo */ /** * @summary The Extension Addition Component Types of EncapsulatedContentInfo * @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_EncapsulatedContentInfo = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_EncapsulatedContentInfo */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_EncapsulatedContentInfo */ let _cached_decoder_for_EncapsulatedContentInfo = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_EncapsulatedContentInfo */ /* START_OF_SYMBOL_DEFINITION _decode_EncapsulatedContentInfo */ /** * @summary Decodes an ASN.1 element into a(n) EncapsulatedContentInfo * @function * @param {_Element} el The element being decoded. * @returns {EncapsulatedContentInfo} The decoded data structure. */ function _decode_EncapsulatedContentInfo(el) { if (!_cached_decoder_for_EncapsulatedContentInfo) { _cached_decoder_for_EncapsulatedContentInfo = function (el) { /* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */ let eContentType; let eContent; /* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */ /* START_OF_CALLBACKS_MAP */ const callbacks = { eContentType: (_el) => { eContentType = ContentType_ta_1._decode_ContentType(_el); }, eContent: (_el) => { eContent = $._decode_explicit(() => $._decodeOctetString)(_el); }, }; /* END_OF_CALLBACKS_MAP */ $._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_EncapsulatedContentInfo, exports._extension_additions_list_spec_for_EncapsulatedContentInfo, exports._root_component_type_list_2_spec_for_EncapsulatedContentInfo, undefined); return new EncapsulatedContentInfo( /* SEQUENCE_CONSTRUCTOR_CALL */ eContentType, eContent); }; } return _cached_decoder_for_EncapsulatedContentInfo(el); } exports._decode_EncapsulatedContentInfo = _decode_EncapsulatedContentInfo; /* END_OF_SYMBOL_DEFINITION _decode_EncapsulatedContentInfo */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_EncapsulatedContentInfo */ let _cached_encoder_for_EncapsulatedContentInfo = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_EncapsulatedContentInfo */ /* START_OF_SYMBOL_DEFINITION _encode_EncapsulatedContentInfo */ /** * @summary Encodes a(n) EncapsulatedContentInfo 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 EncapsulatedContentInfo, encoded as an ASN.1 Element. */ function _encode_EncapsulatedContentInfo(value, elGetter) { if (!_cached_encoder_for_EncapsulatedContentInfo) { _cached_encoder_for_EncapsulatedContentInfo = function (value, elGetter) { return $._encodeSequence([] .concat([ /* REQUIRED */ ContentType_ta_1._encode_ContentType(value.eContentType, $.BER), /* IF_ABSENT */ value.eContent === undefined ? undefined : $._encode_explicit(asn1_ts_1.ASN1TagClass.context, 0, () => $._encodeOctetString, $.BER)(value.eContent, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_EncapsulatedContentInfo(value, elGetter); } exports._encode_EncapsulatedContentInfo = _encode_EncapsulatedContentInfo; /* END_OF_SYMBOL_DEFINITION _encode_EncapsulatedContentInfo */ /* eslint-enable */ //# sourceMappingURL=EncapsulatedContentInfo.ta.js.map