UNPKG

@wildboar/pkcs

Version:
153 lines 5.88 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_SMIMECapability = exports._decode_SMIMECapability = exports._extension_additions_list_spec_for_SMIMECapability = exports._root_component_type_list_2_spec_for_SMIMECapability = exports._root_component_type_list_1_spec_for_SMIMECapability = exports.SMIMECapability = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); /* START_OF_SYMBOL_DEFINITION SMIMECapability */ /** * @summary SMIMECapability * @description * * ### ASN.1 Definition: * * ```asn1 * SMIMECapability ::= SEQUENCE { * algorithm ALGORITHM.&id ({SMIMEv3Algorithms}), * parameters ALGORITHM.&Type ({SMIMEv3Algorithms}{@algorithm}) * } * ``` * * @class */ class SMIMECapability { constructor( /** * @summary `algorithm`. * @public * @readonly */ algorithm, /** * @summary `parameters`. * @public * @readonly */ parameters) { this.algorithm = algorithm; this.parameters = parameters; } /** * @summary Restructures an object into a SMIMECapability * @description * * This takes an `object` and converts it to a `SMIMECapability`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `SMIMECapability`. * @returns {SMIMECapability} */ static _from_object(_o) { return new SMIMECapability(_o.algorithm, _o.parameters); } } exports.SMIMECapability = SMIMECapability; /* END_OF_SYMBOL_DEFINITION SMIMECapability */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_SMIMECapability */ /** * @summary The Leading Root Component Types of SMIMECapability * @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_SMIMECapability = [ new $.ComponentSpec("algorithm", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 6), undefined, undefined), new $.ComponentSpec("parameters", false, $.hasAnyTag, undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_SMIMECapability */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_SMIMECapability */ /** * @summary The Trailing Root Component Types of SMIMECapability * @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_SMIMECapability = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_SMIMECapability */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_SMIMECapability */ /** * @summary The Extension Addition Component Types of SMIMECapability * @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_SMIMECapability = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_SMIMECapability */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_SMIMECapability */ let _cached_decoder_for_SMIMECapability = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_SMIMECapability */ /* START_OF_SYMBOL_DEFINITION _decode_SMIMECapability */ /** * @summary Decodes an ASN.1 element into a(n) SMIMECapability * @function * @param {_Element} el The element being decoded. * @returns {SMIMECapability} The decoded data structure. */ function _decode_SMIMECapability(el) { if (!_cached_decoder_for_SMIMECapability) { _cached_decoder_for_SMIMECapability = function (el) { const sequence = el.sequence; if (sequence.length < 2) { throw new asn1_ts_1.ASN1ConstructionError("SMIMECapability contained only " + sequence.length.toString() + " elements."); } sequence[0].name = "algorithm"; sequence[1].name = "parameters"; let algorithm; let parameters; algorithm = $._decodeObjectIdentifier(sequence[0]); parameters = $._decodeAny(sequence[1]); return new SMIMECapability(algorithm, parameters); }; } return _cached_decoder_for_SMIMECapability(el); } exports._decode_SMIMECapability = _decode_SMIMECapability; /* END_OF_SYMBOL_DEFINITION _decode_SMIMECapability */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_SMIMECapability */ let _cached_encoder_for_SMIMECapability = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_SMIMECapability */ /* START_OF_SYMBOL_DEFINITION _encode_SMIMECapability */ /** * @summary Encodes a(n) SMIMECapability 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 SMIMECapability, encoded as an ASN.1 Element. */ function _encode_SMIMECapability(value, elGetter) { if (!_cached_encoder_for_SMIMECapability) { _cached_encoder_for_SMIMECapability = function (value, elGetter) { return $._encodeSequence([] .concat([ /* REQUIRED */ $._encodeObjectIdentifier(value.algorithm, $.BER), /* REQUIRED */ $._encodeAny(value.parameters, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_SMIMECapability(value, elGetter); } exports._encode_SMIMECapability = _encode_SMIMECapability; /* END_OF_SYMBOL_DEFINITION _encode_SMIMECapability */ /* eslint-enable */ //# sourceMappingURL=SMIMECapability.ta.js.map