UNPKG

@wildboar/pkcs

Version:
184 lines 8.82 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_RecipientKeyIdentifier = exports._decode_RecipientKeyIdentifier = exports._extension_additions_list_spec_for_RecipientKeyIdentifier = exports._root_component_type_list_2_spec_for_RecipientKeyIdentifier = exports._root_component_type_list_1_spec_for_RecipientKeyIdentifier = exports.RecipientKeyIdentifier = exports._encode_SubjectKeyIdentifier = exports._decode_SubjectKeyIdentifier = exports._encode_OtherKeyAttribute = exports._decode_OtherKeyAttribute = exports.OtherKeyAttribute = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const OtherKeyAttribute_ta_1 = require("../CryptographicMessageSyntax/OtherKeyAttribute.ta"); const SubjectKeyIdentifier_ta_1 = require("../CryptographicMessageSyntax/SubjectKeyIdentifier.ta"); var OtherKeyAttribute_ta_2 = require("../CryptographicMessageSyntax/OtherKeyAttribute.ta"); Object.defineProperty(exports, "OtherKeyAttribute", { enumerable: true, get: function () { return OtherKeyAttribute_ta_2.OtherKeyAttribute; } }); Object.defineProperty(exports, "_decode_OtherKeyAttribute", { enumerable: true, get: function () { return OtherKeyAttribute_ta_2._decode_OtherKeyAttribute; } }); Object.defineProperty(exports, "_encode_OtherKeyAttribute", { enumerable: true, get: function () { return OtherKeyAttribute_ta_2._encode_OtherKeyAttribute; } }); var SubjectKeyIdentifier_ta_2 = require("../CryptographicMessageSyntax/SubjectKeyIdentifier.ta"); Object.defineProperty(exports, "_decode_SubjectKeyIdentifier", { enumerable: true, get: function () { return SubjectKeyIdentifier_ta_2._decode_SubjectKeyIdentifier; } }); Object.defineProperty(exports, "_encode_SubjectKeyIdentifier", { enumerable: true, get: function () { return SubjectKeyIdentifier_ta_2._encode_SubjectKeyIdentifier; } }); /* START_OF_SYMBOL_DEFINITION RecipientKeyIdentifier */ /** * @summary RecipientKeyIdentifier * @description * * ### ASN.1 Definition: * * ```asn1 * RecipientKeyIdentifier ::= SEQUENCE { * subjectKeyIdentifier SubjectKeyIdentifier, * date GeneralizedTime OPTIONAL, * other OtherKeyAttribute OPTIONAL * } * ``` * * @class */ class RecipientKeyIdentifier { constructor( /** * @summary `subjectKeyIdentifier`. * @public * @readonly */ subjectKeyIdentifier, /** * @summary `date`. * @public * @readonly */ date, /** * @summary `other`. * @public * @readonly */ other) { this.subjectKeyIdentifier = subjectKeyIdentifier; this.date = date; this.other = other; } /** * @summary Restructures an object into a RecipientKeyIdentifier * @description * * This takes an `object` and converts it to a `RecipientKeyIdentifier`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `RecipientKeyIdentifier`. * @returns {RecipientKeyIdentifier} */ static _from_object(_o) { return new RecipientKeyIdentifier(_o.subjectKeyIdentifier, _o.date, _o.other); } } exports.RecipientKeyIdentifier = RecipientKeyIdentifier; /* END_OF_SYMBOL_DEFINITION RecipientKeyIdentifier */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_RecipientKeyIdentifier */ /** * @summary The Leading Root Component Types of RecipientKeyIdentifier * @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_RecipientKeyIdentifier = [ new $.ComponentSpec("subjectKeyIdentifier", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 4), undefined, undefined), new $.ComponentSpec("date", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 24), undefined, undefined), new $.ComponentSpec("other", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_RecipientKeyIdentifier */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_RecipientKeyIdentifier */ /** * @summary The Trailing Root Component Types of RecipientKeyIdentifier * @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_RecipientKeyIdentifier = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_RecipientKeyIdentifier */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_RecipientKeyIdentifier */ /** * @summary The Extension Addition Component Types of RecipientKeyIdentifier * @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_RecipientKeyIdentifier = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_RecipientKeyIdentifier */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_RecipientKeyIdentifier */ let _cached_decoder_for_RecipientKeyIdentifier = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_RecipientKeyIdentifier */ /* START_OF_SYMBOL_DEFINITION _decode_RecipientKeyIdentifier */ /** * @summary Decodes an ASN.1 element into a(n) RecipientKeyIdentifier * @function * @param {_Element} el The element being decoded. * @returns {RecipientKeyIdentifier} The decoded data structure. */ function _decode_RecipientKeyIdentifier(el) { if (!_cached_decoder_for_RecipientKeyIdentifier) { _cached_decoder_for_RecipientKeyIdentifier = function (el) { /* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */ let subjectKeyIdentifier; let date; let other; /* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */ /* START_OF_CALLBACKS_MAP */ const callbacks = { subjectKeyIdentifier: (_el) => { subjectKeyIdentifier = SubjectKeyIdentifier_ta_1._decode_SubjectKeyIdentifier(_el); }, date: (_el) => { date = $._decodeGeneralizedTime(_el); }, other: (_el) => { other = OtherKeyAttribute_ta_1._decode_OtherKeyAttribute(_el); }, }; /* END_OF_CALLBACKS_MAP */ $._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_RecipientKeyIdentifier, exports._extension_additions_list_spec_for_RecipientKeyIdentifier, exports._root_component_type_list_2_spec_for_RecipientKeyIdentifier, undefined); return new RecipientKeyIdentifier( /* SEQUENCE_CONSTRUCTOR_CALL */ subjectKeyIdentifier, date, other); }; } return _cached_decoder_for_RecipientKeyIdentifier(el); } exports._decode_RecipientKeyIdentifier = _decode_RecipientKeyIdentifier; /* END_OF_SYMBOL_DEFINITION _decode_RecipientKeyIdentifier */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_RecipientKeyIdentifier */ let _cached_encoder_for_RecipientKeyIdentifier = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_RecipientKeyIdentifier */ /* START_OF_SYMBOL_DEFINITION _encode_RecipientKeyIdentifier */ /** * @summary Encodes a(n) RecipientKeyIdentifier 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 RecipientKeyIdentifier, encoded as an ASN.1 Element. */ function _encode_RecipientKeyIdentifier(value, elGetter) { if (!_cached_encoder_for_RecipientKeyIdentifier) { _cached_encoder_for_RecipientKeyIdentifier = function (value, elGetter) { return $._encodeSequence([] .concat([ /* REQUIRED */ SubjectKeyIdentifier_ta_1._encode_SubjectKeyIdentifier(value.subjectKeyIdentifier, $.BER), /* IF_ABSENT */ value.date === undefined ? undefined : $._encodeGeneralizedTime(value.date, $.BER), /* IF_ABSENT */ value.other === undefined ? undefined : OtherKeyAttribute_ta_1._encode_OtherKeyAttribute(value.other, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_RecipientKeyIdentifier(value, elGetter); } exports._encode_RecipientKeyIdentifier = _encode_RecipientKeyIdentifier; /* END_OF_SYMBOL_DEFINITION _encode_RecipientKeyIdentifier */ /* eslint-enable */ //# sourceMappingURL=RecipientKeyIdentifier.ta.js.map