UNPKG

@wildboar/pkcs

Version:
187 lines 8.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_EncryptedData = exports._decode_EncryptedData = exports._extension_additions_list_spec_for_EncryptedData = exports._root_component_type_list_2_spec_for_EncryptedData = exports._root_component_type_list_1_spec_for_EncryptedData = exports.EncryptedData = exports._encode_Version = exports._decode_Version = exports._encode_EncryptedContentInfo = exports._decode_EncryptedContentInfo = exports.EncryptedContentInfo = exports._encode_Attributes = exports._decode_Attributes = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const Attributes_ta_1 = require("../PKCS7/Attributes.ta"); const EncryptedContentInfo_ta_1 = require("../PKCS7/EncryptedContentInfo.ta"); const Version_ta_1 = require("../PKCS7/Version.ta"); var Attributes_ta_2 = require("../PKCS7/Attributes.ta"); Object.defineProperty(exports, "_decode_Attributes", { enumerable: true, get: function () { return Attributes_ta_2._decode_Attributes; } }); Object.defineProperty(exports, "_encode_Attributes", { enumerable: true, get: function () { return Attributes_ta_2._encode_Attributes; } }); var EncryptedContentInfo_ta_2 = require("../PKCS7/EncryptedContentInfo.ta"); Object.defineProperty(exports, "EncryptedContentInfo", { enumerable: true, get: function () { return EncryptedContentInfo_ta_2.EncryptedContentInfo; } }); Object.defineProperty(exports, "_decode_EncryptedContentInfo", { enumerable: true, get: function () { return EncryptedContentInfo_ta_2._decode_EncryptedContentInfo; } }); Object.defineProperty(exports, "_encode_EncryptedContentInfo", { enumerable: true, get: function () { return EncryptedContentInfo_ta_2._encode_EncryptedContentInfo; } }); var Version_ta_2 = require("../PKCS7/Version.ta"); Object.defineProperty(exports, "_decode_Version", { enumerable: true, get: function () { return Version_ta_2._decode_Version; } }); Object.defineProperty(exports, "_encode_Version", { enumerable: true, get: function () { return Version_ta_2._encode_Version; } }); /* START_OF_SYMBOL_DEFINITION EncryptedData */ /** * @summary EncryptedData * @description * * ### ASN.1 Definition: * * ```asn1 * EncryptedData ::= SEQUENCE { * version Version, * encryptedContentInfo EncryptedContentInfo, * unprotectedAttributes [1] Attributes OPTIONAL * } * ``` * * @class */ class EncryptedData { constructor( /** * @summary `version`. * @public * @readonly */ version, /** * @summary `encryptedContentInfo`. * @public * @readonly */ encryptedContentInfo, /** * @summary `unprotectedAttributes`. * @public * @readonly */ unprotectedAttributes) { this.version = version; this.encryptedContentInfo = encryptedContentInfo; this.unprotectedAttributes = unprotectedAttributes; } /** * @summary Restructures an object into a EncryptedData * @description * * This takes an `object` and converts it to a `EncryptedData`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `EncryptedData`. * @returns {EncryptedData} */ static _from_object(_o) { return new EncryptedData(_o.version, _o.encryptedContentInfo, _o.unprotectedAttributes); } } exports.EncryptedData = EncryptedData; /* END_OF_SYMBOL_DEFINITION EncryptedData */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_EncryptedData */ /** * @summary The Leading Root Component Types of EncryptedData * @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_EncryptedData = [ new $.ComponentSpec("version", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined), new $.ComponentSpec("encryptedContentInfo", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), new $.ComponentSpec("unprotectedAttributes", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 1), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_EncryptedData */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_EncryptedData */ /** * @summary The Trailing Root Component Types of EncryptedData * @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_EncryptedData = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_EncryptedData */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_EncryptedData */ /** * @summary The Extension Addition Component Types of EncryptedData * @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_EncryptedData = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_EncryptedData */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_EncryptedData */ let _cached_decoder_for_EncryptedData = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_EncryptedData */ /* START_OF_SYMBOL_DEFINITION _decode_EncryptedData */ /** * @summary Decodes an ASN.1 element into a(n) EncryptedData * @function * @param {_Element} el The element being decoded. * @returns {EncryptedData} The decoded data structure. */ function _decode_EncryptedData(el) { if (!_cached_decoder_for_EncryptedData) { _cached_decoder_for_EncryptedData = function (el) { /* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */ let version; let encryptedContentInfo; let unprotectedAttributes; /* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */ /* START_OF_CALLBACKS_MAP */ const callbacks = { version: (_el) => { version = Version_ta_1._decode_Version(_el); }, encryptedContentInfo: (_el) => { encryptedContentInfo = EncryptedContentInfo_ta_1._decode_EncryptedContentInfo(_el); }, unprotectedAttributes: (_el) => { unprotectedAttributes = $._decode_implicit(() => Attributes_ta_1._decode_Attributes)(_el); }, }; /* END_OF_CALLBACKS_MAP */ $._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_EncryptedData, exports._extension_additions_list_spec_for_EncryptedData, exports._root_component_type_list_2_spec_for_EncryptedData, undefined); return new EncryptedData( /* SEQUENCE_CONSTRUCTOR_CALL */ version, encryptedContentInfo, unprotectedAttributes); }; } return _cached_decoder_for_EncryptedData(el); } exports._decode_EncryptedData = _decode_EncryptedData; /* END_OF_SYMBOL_DEFINITION _decode_EncryptedData */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_EncryptedData */ let _cached_encoder_for_EncryptedData = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_EncryptedData */ /* START_OF_SYMBOL_DEFINITION _encode_EncryptedData */ /** * @summary Encodes a(n) EncryptedData 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 EncryptedData, encoded as an ASN.1 Element. */ function _encode_EncryptedData(value, elGetter) { if (!_cached_encoder_for_EncryptedData) { _cached_encoder_for_EncryptedData = function (value, elGetter) { return $._encodeSequence([] .concat([ /* REQUIRED */ Version_ta_1._encode_Version(value.version, $.BER), /* REQUIRED */ EncryptedContentInfo_ta_1._encode_EncryptedContentInfo(value.encryptedContentInfo, $.BER), /* IF_ABSENT */ value.unprotectedAttributes === undefined ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 1, () => Attributes_ta_1._encode_Attributes, $.BER)(value.unprotectedAttributes, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_EncryptedData(value, elGetter); } exports._encode_EncryptedData = _encode_EncryptedData; /* END_OF_SYMBOL_DEFINITION _encode_EncryptedData */ /* eslint-enable */ //# sourceMappingURL=EncryptedData.ta.js.map