UNPKG

@wildboar/pkcs

Version:
177 lines 7.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_PasswordInfo = exports._decode_PasswordInfo = exports._extension_additions_list_spec_for_PasswordInfo = exports._root_component_type_list_2_spec_for_PasswordInfo = exports._root_component_type_list_1_spec_for_PasswordInfo = exports.PasswordInfo = exports._encode_Label = exports._decode_Label = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const AlgorithmIdentifier_ta_1 = require("@wildboar/x500/src/lib/modules/AuthenticationFramework/AlgorithmIdentifier.ta"); const Label_ta_1 = require("../PKCS-15/Label.ta"); var Label_ta_2 = require("../PKCS-15/Label.ta"); Object.defineProperty(exports, "_decode_Label", { enumerable: true, get: function () { return Label_ta_2._decode_Label; } }); Object.defineProperty(exports, "_encode_Label", { enumerable: true, get: function () { return Label_ta_2._encode_Label; } }); /* START_OF_SYMBOL_DEFINITION PasswordInfo */ /** * @summary PasswordInfo * @description * * ### ASN.1 Definition: * * ```asn1 * PasswordInfo ::= SEQUENCE { * hint Label OPTIONAL, * algId AlgorithmIdentifier {{KeyDerivationAlgorithms}}, * ... * } (CONSTRAINED BY {--keyID shall point to a KEKRecipientInfo--}) * ``` * * @class */ class PasswordInfo { constructor( /** * @summary `hint`. * @public * @readonly */ hint, /** * @summary `algId`. * @public * @readonly */ algId, /** * @summary Extensions that are not recognized. * @public * @readonly */ _unrecognizedExtensionsList = []) { this.hint = hint; this.algId = algId; this._unrecognizedExtensionsList = _unrecognizedExtensionsList; } /** * @summary Restructures an object into a PasswordInfo * @description * * This takes an `object` and converts it to a `PasswordInfo`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `PasswordInfo`. * @returns {PasswordInfo} */ static _from_object(_o) { return new PasswordInfo(_o.hint, _o.algId, _o._unrecognizedExtensionsList); } } exports.PasswordInfo = PasswordInfo; /* END_OF_SYMBOL_DEFINITION PasswordInfo */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_PasswordInfo */ /** * @summary The Leading Root Component Types of PasswordInfo * @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_PasswordInfo = [ new $.ComponentSpec("hint", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 12), undefined, undefined), new $.ComponentSpec("algId", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_PasswordInfo */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_PasswordInfo */ /** * @summary The Trailing Root Component Types of PasswordInfo * @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_PasswordInfo = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_PasswordInfo */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_PasswordInfo */ /** * @summary The Extension Addition Component Types of PasswordInfo * @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_PasswordInfo = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_PasswordInfo */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_PasswordInfo */ let _cached_decoder_for_PasswordInfo = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_PasswordInfo */ /* START_OF_SYMBOL_DEFINITION _decode_PasswordInfo */ /** * @summary Decodes an ASN.1 element into a(n) PasswordInfo * @function * @param {_Element} el The element being decoded. * @returns {PasswordInfo} The decoded data structure. */ function _decode_PasswordInfo(el) { if (!_cached_decoder_for_PasswordInfo) { _cached_decoder_for_PasswordInfo = function (el) { /* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */ let hint; let algId; let _unrecognizedExtensionsList = []; /* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */ /* START_OF_CALLBACKS_MAP */ const callbacks = { hint: (_el) => { hint = Label_ta_1._decode_Label(_el); }, algId: (_el) => { algId = AlgorithmIdentifier_ta_1._decode_AlgorithmIdentifier(_el); }, }; /* END_OF_CALLBACKS_MAP */ $._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_PasswordInfo, exports._extension_additions_list_spec_for_PasswordInfo, exports._root_component_type_list_2_spec_for_PasswordInfo, (ext) => { _unrecognizedExtensionsList.push(ext); }); return new PasswordInfo( /* SEQUENCE_CONSTRUCTOR_CALL */ hint, algId, _unrecognizedExtensionsList); }; } return _cached_decoder_for_PasswordInfo(el); } exports._decode_PasswordInfo = _decode_PasswordInfo; /* END_OF_SYMBOL_DEFINITION _decode_PasswordInfo */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_PasswordInfo */ let _cached_encoder_for_PasswordInfo = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_PasswordInfo */ /* START_OF_SYMBOL_DEFINITION _encode_PasswordInfo */ /** * @summary Encodes a(n) PasswordInfo 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 PasswordInfo, encoded as an ASN.1 Element. */ function _encode_PasswordInfo(value, elGetter) { if (!_cached_encoder_for_PasswordInfo) { _cached_encoder_for_PasswordInfo = function (value, elGetter) { return $._encodeSequence([] .concat([ /* IF_ABSENT */ value.hint === undefined ? undefined : Label_ta_1._encode_Label(value.hint, $.BER), /* REQUIRED */ AlgorithmIdentifier_ta_1._encode_AlgorithmIdentifier(value.algId, $.BER), ], value._unrecognizedExtensionsList ? value._unrecognizedExtensionsList : []) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_PasswordInfo(value, elGetter); } exports._encode_PasswordInfo = _encode_PasswordInfo; /* END_OF_SYMBOL_DEFINITION _encode_PasswordInfo */ /* eslint-enable */ //# sourceMappingURL=PasswordInfo.ta.js.map