UNPKG

@wildboar/pki-stub

Version:
174 lines 6.58 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_Attribute = exports._decode_Attribute = exports._extension_additions_list_spec_for_Attribute = exports._root_component_type_list_2_spec_for_Attribute = exports._root_component_type_list_1_spec_for_Attribute = exports.Attribute = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const Attribute_valuesWithContext_Item_ta_1 = require("../InformationFramework/Attribute-valuesWithContext-Item.ta"); /* START_OF_SYMBOL_DEFINITION Attribute */ /** * @summary Attribute * @description * * ### ASN.1 Definition: * * ```asn1 * Attribute {ATTRIBUTE:SupportedAttributes} ::= SEQUENCE { * type ATTRIBUTE.&id({SupportedAttributes}), * values SET SIZE (0..MAX) OF ATTRIBUTE.&Type({SupportedAttributes}{@type}), * valuesWithContext SET SIZE (1..MAX) OF SEQUENCE { * value ATTRIBUTE.&Type({SupportedAttributes}{@type}), * contextList SET SIZE (1..MAX) OF Context, * ...} OPTIONAL, * ... } * ``` * * @class */ class Attribute { constructor( /** * @summary `type_`. * @public * @readonly */ type_, /** * @summary `values`. * @public * @readonly */ values, /** * @summary `valuesWithContext`. * @public * @readonly */ valuesWithContext, /** * @summary Extensions that are not recognized. * @public * @readonly */ _unrecognizedExtensionsList = []) { this.type_ = type_; this.values = values; this.valuesWithContext = valuesWithContext; this._unrecognizedExtensionsList = _unrecognizedExtensionsList; } /** * @summary Restructures an object into a Attribute * @description * * This takes an `object` and converts it to a `Attribute`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `Attribute`. * @returns {Attribute} */ static _from_object(_o) { return new Attribute(_o.type_, _o.values, _o.valuesWithContext, _o._unrecognizedExtensionsList); } } exports.Attribute = Attribute; /* END_OF_SYMBOL_DEFINITION Attribute */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_Attribute */ /** * @summary The Leading Root Component Types of Attribute * @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_Attribute = [ new $.ComponentSpec("type", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 6), undefined, undefined), new $.ComponentSpec("values", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 17), undefined, undefined), new $.ComponentSpec("valuesWithContext", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 17), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_Attribute */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_Attribute */ /** * @summary The Trailing Root Component Types of Attribute * @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_Attribute = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_Attribute */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_Attribute */ /** * @summary The Extension Addition Component Types of Attribute * @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_Attribute = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_Attribute */ /* START_OF_SYMBOL_DEFINITION _decode_Attribute */ /** * @summary Decodes an ASN.1 element into a(n) Attribute * @function * @param {_Element} el The element being decoded. * @returns {Attribute} The decoded data structure. */ function _decode_Attribute(el) { /* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */ let type_; let values; let valuesWithContext; let _unrecognizedExtensionsList = []; /* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */ /* START_OF_CALLBACKS_MAP */ const callbacks = { type: (_el) => { type_ = $._decodeObjectIdentifier(_el); }, values: (_el) => { values = $._decodeSetOf(() => $._decodeAny)(_el); }, valuesWithContext: (_el) => { valuesWithContext = $._decodeSetOf(() => Attribute_valuesWithContext_Item_ta_1._decode_Attribute_valuesWithContext_Item)(_el); }, }; /* END_OF_CALLBACKS_MAP */ $._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_Attribute, exports._extension_additions_list_spec_for_Attribute, exports._root_component_type_list_2_spec_for_Attribute, (ext) => { _unrecognizedExtensionsList.push(ext); }); return new Attribute( /* SEQUENCE_CONSTRUCTOR_CALL */ type_, values, valuesWithContext, _unrecognizedExtensionsList); } exports._decode_Attribute = _decode_Attribute; /* END_OF_SYMBOL_DEFINITION _decode_Attribute */ /* START_OF_SYMBOL_DEFINITION _encode_Attribute */ /** * @summary Encodes a(n) Attribute 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 Attribute, encoded as an ASN.1 Element. */ function _encode_Attribute(value, elGetter) { var _a; const components = [ /* REQUIRED */ $._encodeObjectIdentifier(value.type_, $.BER), /* REQUIRED */ $._encodeSetOf(() => $._encodeAny, $.BER)(value.values, $.BER), ]; if ((_a = value.valuesWithContext) === null || _a === void 0 ? void 0 : _a.length) { const c = $._encodeSetOf(() => Attribute_valuesWithContext_Item_ta_1._encode_Attribute_valuesWithContext_Item, $.BER)(value.valuesWithContext, $.BER); components.push(c); } components.push(...value._unrecognizedExtensionsList); return $._encodeSequence(components, $.BER); } exports._encode_Attribute = _encode_Attribute; /* END_OF_SYMBOL_DEFINITION _encode_Attribute */ /* eslint-enable */ //# sourceMappingURL=Attribute.ta.js.map