UNPKG

pkcs-ts

Version:

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

107 lines 7.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_EnvelopedData = exports._decode_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 = exports._encode_Version = exports._decode_Version = exports._encode_RecipientInfos = exports._decode_RecipientInfos = exports._encode_OriginatorInfo = exports._decode_OriginatorInfo = exports.OriginatorInfo = exports._encode_EncryptedContentInfo = exports._decode_EncryptedContentInfo = exports.EncryptedContentInfo = exports._encode_Attributes = exports._decode_Attributes = 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 Attributes_ta_1 = require("../PKCS7/Attributes.ta"); const EncryptedContentInfo_ta_1 = require("../PKCS7/EncryptedContentInfo.ta"); const OriginatorInfo_ta_1 = require("../PKCS7/OriginatorInfo.ta"); const RecipientInfos_ta_1 = require("../PKCS7/RecipientInfos.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 OriginatorInfo_ta_2 = require("../PKCS7/OriginatorInfo.ta"); Object.defineProperty(exports, "OriginatorInfo", { enumerable: true, get: function () { return OriginatorInfo_ta_2.OriginatorInfo; } }); Object.defineProperty(exports, "_decode_OriginatorInfo", { enumerable: true, get: function () { return OriginatorInfo_ta_2._decode_OriginatorInfo; } }); Object.defineProperty(exports, "_encode_OriginatorInfo", { enumerable: true, get: function () { return OriginatorInfo_ta_2._encode_OriginatorInfo; } }); var RecipientInfos_ta_2 = require("../PKCS7/RecipientInfos.ta"); Object.defineProperty(exports, "_decode_RecipientInfos", { enumerable: true, get: function () { return RecipientInfos_ta_2._decode_RecipientInfos; } }); Object.defineProperty(exports, "_encode_RecipientInfos", { enumerable: true, get: function () { return RecipientInfos_ta_2._encode_RecipientInfos; } }); 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; } }); class EnvelopedData { constructor(version, originatorInfo, recipientInfos, encryptedContentInfo, unprotectedAttributes) { this.version = version; this.originatorInfo = originatorInfo; this.recipientInfos = recipientInfos; this.encryptedContentInfo = encryptedContentInfo; this.unprotectedAttributes = unprotectedAttributes; } static _from_object(_o) { return new EnvelopedData(_o.version, _o.originatorInfo, _o.recipientInfos, _o.encryptedContentInfo, _o.unprotectedAttributes); } } 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("unprotectedAttributes", 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 = []; let _cached_decoder_for_EnvelopedData = null; function _decode_EnvelopedData(el) { if (!_cached_decoder_for_EnvelopedData) { _cached_decoder_for_EnvelopedData = function (el) { let version; let originatorInfo; let recipientInfos; let encryptedContentInfo; let unprotectedAttributes; const callbacks = { version: (_el) => { version = Version_ta_1._decode_Version(_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._decode_EncryptedContentInfo(_el); }, unprotectedAttributes: (_el) => { unprotectedAttributes = $._decode_implicit(() => Attributes_ta_1._decode_Attributes)(_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, unprotectedAttributes); }; } return _cached_decoder_for_EnvelopedData(el); } exports._decode_EnvelopedData = _decode_EnvelopedData; let _cached_encoder_for_EnvelopedData = null; function _encode_EnvelopedData(value, elGetter) { if (!_cached_encoder_for_EnvelopedData) { _cached_encoder_for_EnvelopedData = function (value, elGetter) { return $._encodeSequence([] .concat([ Version_ta_1._encode_Version(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._encode_EncryptedContentInfo(value.encryptedContentInfo, $.BER), 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_EnvelopedData(value, elGetter); } exports._encode_EnvelopedData = _encode_EnvelopedData; //# sourceMappingURL=EnvelopedData.ta.js.map