UNPKG

pkcs-ts

Version:

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

152 lines 12.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_AuthenticatedData = exports._decode_AuthenticatedData = exports._extension_additions_list_spec_for_AuthenticatedData = exports._root_component_type_list_2_spec_for_AuthenticatedData = exports._root_component_type_list_1_spec_for_AuthenticatedData = exports.AuthenticatedData = exports._encode_Version = exports._decode_Version = exports._encode_RecipientInfos = exports._decode_RecipientInfos = exports._encode_OriginatorInfo = exports._decode_OriginatorInfo = exports.OriginatorInfo = exports._encode_MessageAuthenticationCodeAlgorithmIdentifier = exports._decode_MessageAuthenticationCodeAlgorithmIdentifier = exports._encode_MessageAuthenticationCode = exports._decode_MessageAuthenticationCode = exports._encode_DigestAlgorithmIdentifier = exports._decode_DigestAlgorithmIdentifier = exports._encode_ContentInfo = exports._decode_ContentInfo = exports.ContentInfo = 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 ContentInfo_ta_1 = require("../PKCS7/ContentInfo.ta"); const DigestAlgorithmIdentifier_ta_1 = require("../PKCS7/DigestAlgorithmIdentifier.ta"); const MessageAuthenticationCode_ta_1 = require("../PKCS7/MessageAuthenticationCode.ta"); const MessageAuthenticationCodeAlgorithmIdentifier_ta_1 = require("../PKCS7/MessageAuthenticationCodeAlgorithmIdentifier.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 ContentInfo_ta_2 = require("../PKCS7/ContentInfo.ta"); Object.defineProperty(exports, "ContentInfo", { enumerable: true, get: function () { return ContentInfo_ta_2.ContentInfo; } }); Object.defineProperty(exports, "_decode_ContentInfo", { enumerable: true, get: function () { return ContentInfo_ta_2._decode_ContentInfo; } }); Object.defineProperty(exports, "_encode_ContentInfo", { enumerable: true, get: function () { return ContentInfo_ta_2._encode_ContentInfo; } }); var DigestAlgorithmIdentifier_ta_2 = require("../PKCS7/DigestAlgorithmIdentifier.ta"); Object.defineProperty(exports, "_decode_DigestAlgorithmIdentifier", { enumerable: true, get: function () { return DigestAlgorithmIdentifier_ta_2._decode_DigestAlgorithmIdentifier; } }); Object.defineProperty(exports, "_encode_DigestAlgorithmIdentifier", { enumerable: true, get: function () { return DigestAlgorithmIdentifier_ta_2._encode_DigestAlgorithmIdentifier; } }); var MessageAuthenticationCode_ta_2 = require("../PKCS7/MessageAuthenticationCode.ta"); Object.defineProperty(exports, "_decode_MessageAuthenticationCode", { enumerable: true, get: function () { return MessageAuthenticationCode_ta_2._decode_MessageAuthenticationCode; } }); Object.defineProperty(exports, "_encode_MessageAuthenticationCode", { enumerable: true, get: function () { return MessageAuthenticationCode_ta_2._encode_MessageAuthenticationCode; } }); var MessageAuthenticationCodeAlgorithmIdentifier_ta_2 = require("../PKCS7/MessageAuthenticationCodeAlgorithmIdentifier.ta"); Object.defineProperty(exports, "_decode_MessageAuthenticationCodeAlgorithmIdentifier", { enumerable: true, get: function () { return MessageAuthenticationCodeAlgorithmIdentifier_ta_2._decode_MessageAuthenticationCodeAlgorithmIdentifier; } }); Object.defineProperty(exports, "_encode_MessageAuthenticationCodeAlgorithmIdentifier", { enumerable: true, get: function () { return MessageAuthenticationCodeAlgorithmIdentifier_ta_2._encode_MessageAuthenticationCodeAlgorithmIdentifier; } }); 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 AuthenticatedData { constructor(version, originatorInfo, recipientInfos, macAlgorithm, digestAlgorithm, contentInfo, authenticatedAttributes, messageAuthenticationCode, unauthenticatedAttributes) { this.version = version; this.originatorInfo = originatorInfo; this.recipientInfos = recipientInfos; this.macAlgorithm = macAlgorithm; this.digestAlgorithm = digestAlgorithm; this.contentInfo = contentInfo; this.authenticatedAttributes = authenticatedAttributes; this.messageAuthenticationCode = messageAuthenticationCode; this.unauthenticatedAttributes = unauthenticatedAttributes; } static _from_object(_o) { return new AuthenticatedData(_o.version, _o.originatorInfo, _o.recipientInfos, _o.macAlgorithm, _o.digestAlgorithm, _o.contentInfo, _o.authenticatedAttributes, _o.messageAuthenticationCode, _o.unauthenticatedAttributes); } } exports.AuthenticatedData = AuthenticatedData; exports._root_component_type_list_1_spec_for_AuthenticatedData = [ 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("macAlgorithm", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), new $.ComponentSpec("digestAlgorithm", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 1), undefined, undefined), new $.ComponentSpec("contentInfo", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), new $.ComponentSpec("authenticatedAttributes", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 2), undefined, undefined), new $.ComponentSpec("messageAuthenticationCode", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 4), undefined, undefined), new $.ComponentSpec("unauthenticatedAttributes", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 3), undefined, undefined), ]; exports._root_component_type_list_2_spec_for_AuthenticatedData = []; exports._extension_additions_list_spec_for_AuthenticatedData = []; let _cached_decoder_for_AuthenticatedData = null; function _decode_AuthenticatedData(el) { if (!_cached_decoder_for_AuthenticatedData) { _cached_decoder_for_AuthenticatedData = function (el) { let version; let originatorInfo; let recipientInfos; let macAlgorithm; let digestAlgorithm; let contentInfo; let authenticatedAttributes; let messageAuthenticationCode; let unauthenticatedAttributes; 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); }, macAlgorithm: (_el) => { macAlgorithm = MessageAuthenticationCodeAlgorithmIdentifier_ta_1._decode_MessageAuthenticationCodeAlgorithmIdentifier(_el); }, digestAlgorithm: (_el) => { digestAlgorithm = $._decode_implicit(() => DigestAlgorithmIdentifier_ta_1._decode_DigestAlgorithmIdentifier)(_el); }, contentInfo: (_el) => { contentInfo = ContentInfo_ta_1._decode_ContentInfo(_el); }, authenticatedAttributes: (_el) => { authenticatedAttributes = $._decode_implicit(() => Attributes_ta_1._decode_Attributes)(_el); }, messageAuthenticationCode: (_el) => { messageAuthenticationCode = MessageAuthenticationCode_ta_1._decode_MessageAuthenticationCode(_el); }, unauthenticatedAttributes: (_el) => { unauthenticatedAttributes = $._decode_implicit(() => Attributes_ta_1._decode_Attributes)(_el); }, }; $._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_AuthenticatedData, exports._extension_additions_list_spec_for_AuthenticatedData, exports._root_component_type_list_2_spec_for_AuthenticatedData, undefined); return new AuthenticatedData(version, originatorInfo, recipientInfos, macAlgorithm, digestAlgorithm, contentInfo, authenticatedAttributes, messageAuthenticationCode, unauthenticatedAttributes); }; } return _cached_decoder_for_AuthenticatedData(el); } exports._decode_AuthenticatedData = _decode_AuthenticatedData; let _cached_encoder_for_AuthenticatedData = null; function _encode_AuthenticatedData(value, elGetter) { if (!_cached_encoder_for_AuthenticatedData) { _cached_encoder_for_AuthenticatedData = 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), MessageAuthenticationCodeAlgorithmIdentifier_ta_1._encode_MessageAuthenticationCodeAlgorithmIdentifier(value.macAlgorithm, $.BER), value.digestAlgorithm === undefined ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 1, () => DigestAlgorithmIdentifier_ta_1._encode_DigestAlgorithmIdentifier, $.BER)(value.digestAlgorithm, $.BER), ContentInfo_ta_1._encode_ContentInfo(value.contentInfo, $.BER), value.authenticatedAttributes === undefined ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 2, () => Attributes_ta_1._encode_Attributes, $.BER)(value.authenticatedAttributes, $.BER), MessageAuthenticationCode_ta_1._encode_MessageAuthenticationCode(value.messageAuthenticationCode, $.BER), value.unauthenticatedAttributes === undefined ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 3, () => Attributes_ta_1._encode_Attributes, $.BER)(value.unauthenticatedAttributes, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_AuthenticatedData(value, elGetter); } exports._encode_AuthenticatedData = _encode_AuthenticatedData; //# sourceMappingURL=AuthenticatedData.ta.js.map