UNPKG

@wildboar/pki-stub

Version:
194 lines 7.96 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_PersonalName = exports._decode_PersonalName = exports._extension_additions_list_spec_for_PersonalName = exports._root_component_type_list_2_spec_for_PersonalName = exports._root_component_type_list_1_spec_for_PersonalName = exports.PersonalName = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); /* START_OF_SYMBOL_DEFINITION PersonalName */ /** * @summary PersonalName * @description * * ### ASN.1 Definition: * * ```asn1 * PersonalName ::= SET { * surname [0] PrintableString(SIZE (1..ub-surname-length)), * given-name * [1] PrintableString(SIZE (1..ub-given-name-length)) OPTIONAL, * initials * [2] PrintableString(SIZE (1..ub-initials-length)) OPTIONAL, * generation-qualifier * [3] PrintableString(SIZE (1..ub-generation-qualifier-length)) OPTIONAL } * ``` * * @class */ class PersonalName { constructor( /** * @summary `surname`. * @public * @readonly */ surname, /** * @summary `given_name`. * @public * @readonly */ given_name, /** * @summary `initials`. * @public * @readonly */ initials, /** * @summary `generation_qualifier`. * @public * @readonly */ generation_qualifier) { this.surname = surname; this.given_name = given_name; this.initials = initials; this.generation_qualifier = generation_qualifier; } /** * @summary Restructures an object into a PersonalName * @description * * This takes an `object` and converts it to a `PersonalName`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `PersonalName`. * @returns {PersonalName} */ static _from_object(_o) { return new PersonalName(_o.surname, _o.given_name, _o.initials, _o.generation_qualifier); } } exports.PersonalName = PersonalName; /* END_OF_SYMBOL_DEFINITION PersonalName */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_PersonalName */ /** * @summary The Leading Root Component Types of PersonalName * @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_PersonalName = [ new $.ComponentSpec("surname", false, $.hasTag(asn1_ts_1.ASN1TagClass.context, 0), undefined, undefined), new $.ComponentSpec("given-name", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 1), undefined, undefined), new $.ComponentSpec("initials", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 2), undefined, undefined), new $.ComponentSpec("generation-qualifier", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 3), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_PersonalName */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_PersonalName */ /** * @summary The Trailing Root Component Types of PersonalName * @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_PersonalName = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_PersonalName */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_PersonalName */ /** * @summary The Extension Addition Component Types of PersonalName * @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_PersonalName = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_PersonalName */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_PersonalName */ let _cached_decoder_for_PersonalName = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_PersonalName */ /* START_OF_SYMBOL_DEFINITION _decode_PersonalName */ /** * @summary Decodes an ASN.1 element into a(n) PersonalName * @function * @param {_Element} el The element being decoded. * @returns {PersonalName} The decoded data structure. */ function _decode_PersonalName(el) { if (!_cached_decoder_for_PersonalName) { _cached_decoder_for_PersonalName = function (el) { /* START_OF_SET_COMPONENT_DECLARATIONS */ let surname; let given_name; let initials; let generation_qualifier; /* END_OF_SET_COMPONENT_DECLARATIONS */ /* START_OF_CALLBACKS_MAP */ const callbacks = { surname: (_el) => { surname = $._decode_explicit(() => $._decodePrintableString)(_el); }, "given-name": (_el) => { given_name = $._decode_explicit(() => $._decodePrintableString)(_el); }, initials: (_el) => { initials = $._decode_explicit(() => $._decodePrintableString)(_el); }, "generation-qualifier": (_el) => { generation_qualifier = $._decode_explicit(() => $._decodePrintableString)(_el); }, }; /* END_OF_CALLBACKS_MAP */ $._parse_set(el, callbacks, exports._root_component_type_list_1_spec_for_PersonalName, exports._extension_additions_list_spec_for_PersonalName, exports._root_component_type_list_2_spec_for_PersonalName, undefined); return new PersonalName( /* SET_CONSTRUCTOR_CALL */ surname, given_name, initials, generation_qualifier); }; } return _cached_decoder_for_PersonalName(el); } exports._decode_PersonalName = _decode_PersonalName; /* END_OF_SYMBOL_DEFINITION _decode_PersonalName */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_PersonalName */ let _cached_encoder_for_PersonalName = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_PersonalName */ /* START_OF_SYMBOL_DEFINITION _encode_PersonalName */ /** * @summary Encodes a(n) PersonalName 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 PersonalName, encoded as an ASN.1 Element. */ function _encode_PersonalName(value, elGetter) { if (!_cached_encoder_for_PersonalName) { _cached_encoder_for_PersonalName = function (value, elGetter) { return $._encodeSet([] .concat([ /* REQUIRED */ $._encode_explicit(asn1_ts_1.ASN1TagClass.context, 0, () => $._encodePrintableString, $.BER)(value.surname, $.BER), /* IF_ABSENT */ value.given_name === undefined ? undefined : $._encode_explicit(asn1_ts_1.ASN1TagClass.context, 1, () => $._encodePrintableString, $.BER)(value.given_name, $.BER), /* IF_ABSENT */ value.initials === undefined ? undefined : $._encode_explicit(asn1_ts_1.ASN1TagClass.context, 2, () => $._encodePrintableString, $.BER)(value.initials, $.BER), /* IF_ABSENT */ value.generation_qualifier === undefined ? undefined : $._encode_explicit(asn1_ts_1.ASN1TagClass.context, 3, () => $._encodePrintableString, $.BER)(value.generation_qualifier, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_PersonalName(value, elGetter); } exports._encode_PersonalName = _encode_PersonalName; /* END_OF_SYMBOL_DEFINITION _encode_PersonalName */ /* eslint-enable */ //# sourceMappingURL=PersonalName.ta.js.map