UNPKG

@wildboar/pki-stub

Version:
145 lines 5.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_ScopeRestriction = exports._decode_ScopeRestriction = exports._extension_additions_list_spec_for_ScopeRestriction = exports._root_component_type_list_2_spec_for_ScopeRestriction = exports._root_component_type_list_1_spec_for_ScopeRestriction = exports.ScopeRestriction = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); /* START_OF_SYMBOL_DEFINITION ScopeRestriction */ /** * @summary ScopeRestriction * @description * * ### ASN.1 Definition: * * ```asn1 * ScopeRestriction ::= SEQUENCE { * id SCOPE-RESTRICTION.&id, * restriction SCOPE-RESTRICTION.&Type, * ... } * ``` * * @class */ class ScopeRestriction { constructor( /** * @summary `id`. * @public * @readonly */ id, /** * @summary `restriction`. * @public * @readonly */ restriction, /** * @summary Extensions that are not recognized. * @public * @readonly */ _unrecognizedExtensionsList = []) { this.id = id; this.restriction = restriction; this._unrecognizedExtensionsList = _unrecognizedExtensionsList; } /** * @summary Restructures an object into a ScopeRestriction * @description * * This takes an `object` and converts it to a `ScopeRestriction`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `ScopeRestriction`. * @returns {ScopeRestriction} */ static _from_object(_o) { return new ScopeRestriction(_o.id, _o.restriction, _o._unrecognizedExtensionsList); } } exports.ScopeRestriction = ScopeRestriction; /* END_OF_SYMBOL_DEFINITION ScopeRestriction */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_ScopeRestriction */ /** * @summary The Leading Root Component Types of ScopeRestriction * @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_ScopeRestriction = [ new $.ComponentSpec("id", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 6), undefined, undefined), new $.ComponentSpec("restriction", false, $.hasAnyTag, undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_ScopeRestriction */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_ScopeRestriction */ /** * @summary The Trailing Root Component Types of ScopeRestriction * @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_ScopeRestriction = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_ScopeRestriction */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_ScopeRestriction */ /** * @summary The Extension Addition Component Types of ScopeRestriction * @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_ScopeRestriction = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_ScopeRestriction */ /* START_OF_SYMBOL_DEFINITION _decode_ScopeRestriction */ /** * @summary Decodes an ASN.1 element into a(n) ScopeRestriction * @function * @param {_Element} el The element being decoded. * @returns {ScopeRestriction} The decoded data structure. */ function _decode_ScopeRestriction(el) { const sequence = el.sequence; if (sequence.length < 2) { throw new asn1_ts_1.ASN1ConstructionError("ScopeRestriction contained only " + sequence.length.toString() + " elements."); } sequence[0].name = "id"; sequence[1].name = "restriction"; let id; let restriction; id = $._decodeObjectIdentifier(sequence[0]); restriction = $._decodeAny(sequence[1]); return new ScopeRestriction(id, restriction, sequence.slice(2)); } exports._decode_ScopeRestriction = _decode_ScopeRestriction; /* END_OF_SYMBOL_DEFINITION _decode_ScopeRestriction */ /* START_OF_SYMBOL_DEFINITION _encode_ScopeRestriction */ /** * @summary Encodes a(n) ScopeRestriction 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 ScopeRestriction, encoded as an ASN.1 Element. */ function _encode_ScopeRestriction(value, elGetter) { var _a; const components = [ $._encodeObjectIdentifier(value.id, $.BER), $._encodeAny(value.restriction, $.BER), ...(_a = value._unrecognizedExtensionsList) !== null && _a !== void 0 ? _a : [], ]; return $._encodeSequence(components, $.BER); } exports._encode_ScopeRestriction = _encode_ScopeRestriction; /* END_OF_SYMBOL_DEFINITION _encode_ScopeRestriction */ /* eslint-enable */ //# sourceMappingURL=ScopeRestriction.ta.js.map