UNPKG

pkcs-ts

Version:

PKCS #1 through #15 (Except #11) - Private and Public Keys, Certificates, and More

81 lines 5.04 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; const tslib_1 = require("tslib"); const asn1_ts_1 = require("asn1-ts"); const $ = tslib_1.__importStar(require("asn1-ts/dist/node/functional")); const Attribute_ta_1 = require("x500-ts/dist/node/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"); class EnvelopedData { constructor(version, originatorInfo, recipientInfos, encryptedContentInfo, unprotectedAttrs) { this.version = version; this.originatorInfo = originatorInfo; this.recipientInfos = recipientInfos; this.encryptedContentInfo = encryptedContentInfo; this.unprotectedAttrs = unprotectedAttrs; } static _from_object(_o) { return new EnvelopedData(_o.version, _o.originatorInfo, _o.recipientInfos, _o.encryptedContentInfo, _o.unprotectedAttrs); } } exports.EnvelopedData = EnvelopedData; 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), ]; exports._root_component_type_list_2_spec_for_EnvelopedData = []; exports._extension_additions_list_spec_for_EnvelopedData = []; function _get_decoder_for_EnvelopedData(_decode_Type) { return function (el) { let version; let originatorInfo; let recipientInfos; let encryptedContentInfo; let unprotectedAttrs; 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); }, }; $._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(version, originatorInfo, recipientInfos, encryptedContentInfo, unprotectedAttrs); }; } exports._get_decoder_for_EnvelopedData = _get_decoder_for_EnvelopedData; function _get_encoder_for_EnvelopedData(_encode_Type) { return function (value, elGetter) { return $._encodeSequence([] .concat([ EnvelopedData_version_ta_1._get_encoder_for_EnvelopedData_version(_encode_Type)(value.version, $.BER), value.originatorInfo === undefined ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 0, () => OriginatorInfo_ta_1._encode_OriginatorInfo, $.BER)(value.originatorInfo, $.BER), RecipientInfos_ta_1._encode_RecipientInfos(value.recipientInfos, $.BER), EncryptedContentInfo_ta_1._get_encoder_for_EncryptedContentInfo(_encode_Type)(value.encryptedContentInfo, $.BER), 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; //# sourceMappingURL=EnvelopedData.ta.js.map