UNPKG

@wildboar/pki-stub

Version:
253 lines 9.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_TBSCertAVL = exports._decode_TBSCertAVL = exports._extension_additions_list_spec_for_TBSCertAVL = exports._root_component_type_list_2_spec_for_TBSCertAVL = exports._root_component_type_list_1_spec_for_TBSCertAVL = exports.TBSCertAVL = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const Version_ta_1 = require("../PKI-Stub/Version.ta"); const AvlSerialNumber_ta_1 = require("../PKI-Stub/AvlSerialNumber.ta"); const AlgorithmIdentifier_ta_1 = require("../PKI-Stub/AlgorithmIdentifier.ta"); const Name_ta_1 = require("../PKI-Stub/Name.ta"); const TBSCertAVL_entries_Item_ta_1 = require("../PKI-Stub/TBSCertAVL-entries-Item.ta"); const Extensions_ta_1 = require("../PKI-Stub/Extensions.ta"); /* START_OF_SYMBOL_DEFINITION TBSCertAVL */ /** * @summary TBSCertAVL * @description * * ### ASN.1 Definition: * * ```asn1 * TBSCertAVL ::= SEQUENCE { * version [0] IMPLICIT Version DEFAULT v1, * serialNumber AvlSerialNumber OPTIONAL, * signature AlgorithmIdentifier {{SupportedAlgorithms}}, * issuer Name, * constrained BOOLEAN, * entries SEQUENCE (SIZE (1..MAX)) OF SEQUENCE { * idType CHOICE { * certIdentifier [0] PKCertIdentifier, * entityGroup DistinguishedName, -- only for constrained = FALSE * ... }, * scope [0] IMPLICIT ScopeRestrictions OPTIONAL, * entryExtensions [1] IMPLICIT Extensions OPTIONAL, * ... }, * ..., * ..., * avlExtensions Extensions OPTIONAL } * ``` * * @class */ class TBSCertAVL { constructor( /** * @summary `version`. * @public * @readonly */ version, /** * @summary `serialNumber`. * @public * @readonly */ serialNumber, /** * @summary `signature`. * @public * @readonly */ signature, /** * @summary `issuer`. * @public * @readonly */ issuer, /** * @summary `constrained`. * @public * @readonly */ constrained, /** * @summary `entries`. * @public * @readonly */ entries, /** * @summary Extensions that are not recognized. * @public * @readonly */ _unrecognizedExtensionsList = [], /** * @summary `avlExtensions`. * @public * @readonly */ avlExtensions) { this.version = version; this.serialNumber = serialNumber; this.signature = signature; this.issuer = issuer; this.constrained = constrained; this.entries = entries; this._unrecognizedExtensionsList = _unrecognizedExtensionsList; this.avlExtensions = avlExtensions; } /** * @summary Restructures an object into a TBSCertAVL * @description * * This takes an `object` and converts it to a `TBSCertAVL`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `TBSCertAVL`. * @returns {TBSCertAVL} */ static _from_object(_o) { return new TBSCertAVL(_o.version, _o.serialNumber, _o.signature, _o.issuer, _o.constrained, _o.entries, _o._unrecognizedExtensionsList, _o.avlExtensions); } /** * @summary Getter that returns the default value for `version`. * @public * @static * @method */ static get _default_value_for_version() { return Version_ta_1.v1; } } exports.TBSCertAVL = TBSCertAVL; /* END_OF_SYMBOL_DEFINITION TBSCertAVL */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_TBSCertAVL */ /** * @summary The Leading Root Component Types of TBSCertAVL * @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_TBSCertAVL = [ new $.ComponentSpec("version", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 0), undefined, undefined), new $.ComponentSpec("serialNumber", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined), new $.ComponentSpec("signature", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), new $.ComponentSpec("issuer", false, $.hasAnyTag, undefined, undefined), new $.ComponentSpec("constrained", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 1), undefined, undefined), new $.ComponentSpec("entries", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_TBSCertAVL */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_TBSCertAVL */ /** * @summary The Trailing Root Component Types of TBSCertAVL * @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_TBSCertAVL = [ new $.ComponentSpec("avlExtensions", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_TBSCertAVL */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_TBSCertAVL */ /** * @summary The Extension Addition Component Types of TBSCertAVL * @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_TBSCertAVL = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_TBSCertAVL */ /* START_OF_SYMBOL_DEFINITION _decode_TBSCertAVL */ /** * @summary Decodes an ASN.1 element into a(n) TBSCertAVL * @function * @param {_Element} el The element being decoded. * @returns {TBSCertAVL} The decoded data structure. */ function _decode_TBSCertAVL(el) { /* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */ let version = TBSCertAVL._default_value_for_version; let serialNumber; let signature; let issuer; let constrained; let entries; let _unrecognizedExtensionsList = []; let avlExtensions; /* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */ /* START_OF_CALLBACKS_MAP */ const callbacks = { version: (_el) => { version = $._decode_implicit(() => Version_ta_1._decode_Version)(_el); }, serialNumber: (_el) => { serialNumber = AvlSerialNumber_ta_1._decode_AvlSerialNumber(_el); }, signature: (_el) => { signature = AlgorithmIdentifier_ta_1._decode_AlgorithmIdentifier(_el); }, issuer: (_el) => { issuer = Name_ta_1._decode_Name(_el); }, constrained: (_el) => { constrained = $._decodeBoolean(_el); }, entries: (_el) => { entries = $._decodeSequenceOf(() => TBSCertAVL_entries_Item_ta_1._decode_TBSCertAVL_entries_Item)(_el); }, avlExtensions: (_el) => { avlExtensions = Extensions_ta_1._decode_Extensions(_el); }, }; /* END_OF_CALLBACKS_MAP */ $._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_TBSCertAVL, exports._extension_additions_list_spec_for_TBSCertAVL, exports._root_component_type_list_2_spec_for_TBSCertAVL, (ext) => { _unrecognizedExtensionsList.push(ext); }); return new TBSCertAVL( /* SEQUENCE_CONSTRUCTOR_CALL */ version, serialNumber, signature, issuer, constrained, entries, _unrecognizedExtensionsList, avlExtensions); } exports._decode_TBSCertAVL = _decode_TBSCertAVL; /* END_OF_SYMBOL_DEFINITION _decode_TBSCertAVL */ /* START_OF_SYMBOL_DEFINITION _encode_TBSCertAVL */ /** * @summary Encodes a(n) TBSCertAVL 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 TBSCertAVL, encoded as an ASN.1 Element. */ function _encode_TBSCertAVL(value, elGetter) { var _a, _b; const components = []; if (value.version != TBSCertAVL._default_value_for_version) { const c = $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 0, () => Version_ta_1._encode_Version, $.BER)(value.version, $.BER); components.push(c); } if (value.serialNumber !== undefined) { const c = AvlSerialNumber_ta_1._encode_AvlSerialNumber(value.serialNumber, $.BER); components.push(c); } components.push(AlgorithmIdentifier_ta_1._encode_AlgorithmIdentifier(value.signature, $.BER)); components.push(Name_ta_1._encode_Name(value.issuer, $.BER)); components.push($._encodeBoolean(value.constrained, $.BER)); components.push($._encodeSequenceOf(() => TBSCertAVL_entries_Item_ta_1._encode_TBSCertAVL_entries_Item, $.BER)(value.entries, $.BER)); components.push(...(_a = value._unrecognizedExtensionsList) !== null && _a !== void 0 ? _a : []); if ((_b = value.avlExtensions) === null || _b === void 0 ? void 0 : _b.length) { components.push(Extensions_ta_1._encode_Extensions(value.avlExtensions, $.BER)); } return $._encodeSequence(components, $.BER); } exports._encode_TBSCertAVL = _encode_TBSCertAVL; /* END_OF_SYMBOL_DEFINITION _encode_TBSCertAVL */ /* eslint-enable */ //# sourceMappingURL=TBSCertAVL.ta.js.map