UNPKG

@wildboar/pki-stub

Version:
138 lines 5.74 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_ExtensionAttribute = exports._decode_ExtensionAttribute = exports._extension_additions_list_spec_for_ExtensionAttribute = exports._root_component_type_list_2_spec_for_ExtensionAttribute = exports._root_component_type_list_1_spec_for_ExtensionAttribute = exports.ExtensionAttribute = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); /* START_OF_SYMBOL_DEFINITION ExtensionAttribute */ /** * @summary ExtensionAttribute * @description * * ### ASN.1 Definition: * * ```asn1 * ExtensionAttribute ::= SEQUENCE { * extension-attribute-type * [0] EXTENSION-ATTRIBUTE.&id({ExtensionAttributeTable}), * extension-attribute-value * [1] EXTENSION-ATTRIBUTE.&Type * ({ExtensionAttributeTable}{@extension-attribute-type}) } * ``` * * @class */ class ExtensionAttribute { constructor( /** * @summary `extension_attribute_type`. * @public * @readonly */ extension_attribute_type, /** * @summary `extension_attribute_value`. * @public * @readonly */ extension_attribute_value) { this.extension_attribute_type = extension_attribute_type; this.extension_attribute_value = extension_attribute_value; } /** * @summary Restructures an object into a ExtensionAttribute * @description * * This takes an `object` and converts it to a `ExtensionAttribute`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `ExtensionAttribute`. * @returns {ExtensionAttribute} */ static _from_object(_o) { return new ExtensionAttribute(_o.extension_attribute_type, _o.extension_attribute_value); } } exports.ExtensionAttribute = ExtensionAttribute; /* END_OF_SYMBOL_DEFINITION ExtensionAttribute */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_ExtensionAttribute */ /** * @summary The Leading Root Component Types of ExtensionAttribute * @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_ExtensionAttribute = [ new $.ComponentSpec("extension-attribute-type", false, $.hasTag(asn1_ts_1.ASN1TagClass.context, 0), undefined, undefined), new $.ComponentSpec("extension-attribute-value", false, $.hasTag(asn1_ts_1.ASN1TagClass.context, 1), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_ExtensionAttribute */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_ExtensionAttribute */ /** * @summary The Trailing Root Component Types of ExtensionAttribute * @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_ExtensionAttribute = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_ExtensionAttribute */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_ExtensionAttribute */ /** * @summary The Extension Addition Component Types of ExtensionAttribute * @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_ExtensionAttribute = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_ExtensionAttribute */ /* START_OF_SYMBOL_DEFINITION _decode_ExtensionAttribute */ /** * @summary Decodes an ASN.1 element into a(n) ExtensionAttribute * @function * @param {_Element} el The element being decoded. * @returns {ExtensionAttribute} The decoded data structure. */ function _decode_ExtensionAttribute(el) { const sequence = el.sequence; if (sequence.length < 2) { throw new asn1_ts_1.ASN1ConstructionError("ExtensionAttribute contained only " + sequence.length.toString() + " elements."); } sequence[0].name = "extension-attribute-type"; sequence[1].name = "extension-attribute-value"; let extension_attribute_type; let extension_attribute_value; extension_attribute_type = $._decode_explicit(() => $._decodeInteger)(sequence[0]); extension_attribute_value = $._decode_explicit(() => $._decodeAny)(sequence[1]); return new ExtensionAttribute(extension_attribute_type, extension_attribute_value); } exports._decode_ExtensionAttribute = _decode_ExtensionAttribute; /* END_OF_SYMBOL_DEFINITION _decode_ExtensionAttribute */ /* START_OF_SYMBOL_DEFINITION _encode_ExtensionAttribute */ /** * @summary Encodes a(n) ExtensionAttribute 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 ExtensionAttribute, encoded as an ASN.1 Element. */ function _encode_ExtensionAttribute(value, elGetter) { const components = [ /* REQUIRED */ $._encode_explicit(asn1_ts_1.ASN1TagClass.context, 0, () => $._encodeInteger, $.BER)(value.extension_attribute_type, $.BER), /* REQUIRED */ $._encode_explicit(asn1_ts_1.ASN1TagClass.context, 1, () => $._encodeAny, $.BER)(value.extension_attribute_value, $.BER), ]; return $._encodeSequence(components, $.BER); } exports._encode_ExtensionAttribute = _encode_ExtensionAttribute; /* END_OF_SYMBOL_DEFINITION _encode_ExtensionAttribute */ /* eslint-enable */ //# sourceMappingURL=ExtensionAttribute.ta.js.map