UNPKG

@wildboar/pkcs

Version:
194 lines 8.43 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._get_encoder_for_EnvelopedData = exports._get_decoder_for_EnvelopedData = exports._extension_additions_list_spec_for_EnvelopedData = exports._root_component_type_list_2_spec_for_EnvelopedData = exports._root_component_type_list_1_spec_for_EnvelopedData = exports.EnvelopedData = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const Attribute_ta_1 = require("@wildboar/x500/src/lib/modules/InformationFramework/Attribute.ta"); const OriginatorInfo_ta_1 = require("../CryptographicMessageSyntax/OriginatorInfo.ta"); const RecipientInfos_ta_1 = require("../CryptographicMessageSyntax/RecipientInfos.ta"); const EncryptedContentInfo_ta_1 = require("../PKCS-15/EncryptedContentInfo.ta"); const EnvelopedData_version_ta_1 = require("../PKCS-15/EnvelopedData-version.ta"); /* START_OF_SYMBOL_DEFINITION EnvelopedData */ /** * @summary EnvelopedData * @description * * ### ASN.1 Definition: * * ```asn1 * EnvelopedData {Type} ::= SEQUENCE { * version INTEGER{v0(0),v1(1),v2(2),v3(3),v4(4)}(v0|v1|v2,...), * originatorInfo [0] OriginatorInfo OPTIONAL, * recipientInfos RecipientInfos, * encryptedContentInfo EncryptedContentInfo{Type}, * unprotectedAttrs [1] SET SIZE (1..MAX) OF Attribute OPTIONAL * } * ``` * * @class */ class EnvelopedData { constructor( /** * @summary `version`. * @public * @readonly */ version, /** * @summary `originatorInfo`. * @public * @readonly */ originatorInfo, /** * @summary `recipientInfos`. * @public * @readonly */ recipientInfos, /** * @summary `encryptedContentInfo`. * @public * @readonly */ encryptedContentInfo, /** * @summary `unprotectedAttrs`. * @public * @readonly */ unprotectedAttrs) { this.version = version; this.originatorInfo = originatorInfo; this.recipientInfos = recipientInfos; this.encryptedContentInfo = encryptedContentInfo; this.unprotectedAttrs = unprotectedAttrs; } /** * @summary Restructures an object into a EnvelopedData * @description * * This takes an `object` and converts it to a `EnvelopedData`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `EnvelopedData`. * @returns {EnvelopedData} */ static _from_object(_o) { return new EnvelopedData(_o.version, _o.originatorInfo, _o.recipientInfos, _o.encryptedContentInfo, _o.unprotectedAttrs); } } exports.EnvelopedData = EnvelopedData; /* END_OF_SYMBOL_DEFINITION EnvelopedData */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_EnvelopedData */ /** * @summary The Leading Root Component Types of EnvelopedData * @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_EnvelopedData = [ new $.ComponentSpec("version", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined), new $.ComponentSpec("originatorInfo", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 0), undefined, undefined), new $.ComponentSpec("recipientInfos", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 17), undefined, undefined), new $.ComponentSpec("encryptedContentInfo", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), new $.ComponentSpec("unprotectedAttrs", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 1), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_EnvelopedData */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_EnvelopedData */ /** * @summary The Trailing Root Component Types of EnvelopedData * @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_EnvelopedData = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_EnvelopedData */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_EnvelopedData */ /** * @summary The Extension Addition Component Types of EnvelopedData * @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_EnvelopedData = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_EnvelopedData */ /* START_OF_SYMBOL_DEFINITION _get_decoder_for_EnvelopedData */ /** * @summary Returns a function that will decode an ASN.1 element into a(n) EnvelopedData * @function * @param {_Element} el The element being decoded. * @returns A function that will decode an ASN.1 element. */ function _get_decoder_for_EnvelopedData(_decode_Type) { return function (el) { /* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */ let version; let originatorInfo; let recipientInfos; let encryptedContentInfo; let unprotectedAttrs; /* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */ /* START_OF_CALLBACKS_MAP */ const callbacks = { version: (_el) => { version = EnvelopedData_version_ta_1._get_decoder_for_EnvelopedData_version(_decode_Type)(_el); }, originatorInfo: (_el) => { originatorInfo = $._decode_implicit(() => OriginatorInfo_ta_1._decode_OriginatorInfo)(_el); }, recipientInfos: (_el) => { recipientInfos = RecipientInfos_ta_1._decode_RecipientInfos(_el); }, encryptedContentInfo: (_el) => { encryptedContentInfo = EncryptedContentInfo_ta_1._get_decoder_for_EncryptedContentInfo(_decode_Type)(_el); }, unprotectedAttrs: (_el) => { unprotectedAttrs = $._decode_implicit(() => $._decodeSetOf(() => Attribute_ta_1._decode_Attribute))(_el); }, }; /* END_OF_CALLBACKS_MAP */ $._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_EnvelopedData, exports._extension_additions_list_spec_for_EnvelopedData, exports._root_component_type_list_2_spec_for_EnvelopedData, undefined); return new EnvelopedData( /* SEQUENCE_CONSTRUCTOR_CALL */ version, originatorInfo, recipientInfos, encryptedContentInfo, unprotectedAttrs); }; } exports._get_decoder_for_EnvelopedData = _get_decoder_for_EnvelopedData; /* END_OF_SYMBOL_DEFINITION _get_decoder_for_EnvelopedData */ /* START_OF_SYMBOL_DEFINITION _get_encoder_for_EnvelopedData */ /** * @summary Returns a function that will encode a(n) EnvelopedData into an ASN.1 Element. * @function * @returns A function that will encode a(n) EnvelopedData as an ASN.1 element. */ function _get_encoder_for_EnvelopedData(_encode_Type) { return function (value, elGetter) { return $._encodeSequence([] .concat([ /* REQUIRED */ EnvelopedData_version_ta_1._get_encoder_for_EnvelopedData_version(_encode_Type)(value.version, $.BER), /* IF_ABSENT */ value.originatorInfo === undefined ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 0, () => OriginatorInfo_ta_1._encode_OriginatorInfo, $.BER)(value.originatorInfo, $.BER), /* REQUIRED */ RecipientInfos_ta_1._encode_RecipientInfos(value.recipientInfos, $.BER), /* REQUIRED */ EncryptedContentInfo_ta_1._get_encoder_for_EncryptedContentInfo(_encode_Type)(value.encryptedContentInfo, $.BER), /* IF_ABSENT */ value.unprotectedAttrs === undefined ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 1, () => $._encodeSetOf(() => Attribute_ta_1._encode_Attribute, $.BER), $.BER)(value.unprotectedAttrs, $.BER), ]) .filter((c) => !!c), $.BER); }; } exports._get_encoder_for_EnvelopedData = _get_encoder_for_EnvelopedData; /* END_OF_SYMBOL_DEFINITION _get_encoder_for_EnvelopedData */ /* eslint-enable */ //# sourceMappingURL=EnvelopedData.ta.js.map