UNPKG

@wildboar/pkcs

Version:
208 lines 9.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_X509CertificateAttributes = exports._decode_X509CertificateAttributes = exports._extension_additions_list_spec_for_X509CertificateAttributes = exports._root_component_type_list_2_spec_for_X509CertificateAttributes = exports._root_component_type_list_1_spec_for_X509CertificateAttributes = exports.X509CertificateAttributes = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const Certificate_ta_1 = require("@wildboar/x500/src/lib/modules/AuthenticationFramework/Certificate.ta"); const CertificateSerialNumber_ta_1 = require("@wildboar/x500/src/lib/modules/AuthenticationFramework/CertificateSerialNumber.ta"); const Name_ta_1 = require("@wildboar/x500/src/lib/modules/InformationFramework/Name.ta"); const ObjectValue_ta_1 = require("../PKCS-15/ObjectValue.ta"); /* START_OF_SYMBOL_DEFINITION X509CertificateAttributes */ /** * @summary X509CertificateAttributes * @description * * ### ASN.1 Definition: * * ```asn1 * X509CertificateAttributes ::= SEQUENCE { * value ObjectValue { Certificate }, * subject Name OPTIONAL, * issuer [0] Name OPTIONAL, * serialNumber CertificateSerialNumber OPTIONAL, * ... -- For future extensions * } * ``` * * @class */ class X509CertificateAttributes { constructor( /** * @summary `value`. * @public * @readonly */ value, /** * @summary `subject`. * @public * @readonly */ subject, /** * @summary `issuer`. * @public * @readonly */ issuer, /** * @summary `serialNumber`. * @public * @readonly */ serialNumber, /** * @summary Extensions that are not recognized. * @public * @readonly */ _unrecognizedExtensionsList = []) { this.value = value; this.subject = subject; this.issuer = issuer; this.serialNumber = serialNumber; this._unrecognizedExtensionsList = _unrecognizedExtensionsList; } /** * @summary Restructures an object into a X509CertificateAttributes * @description * * This takes an `object` and converts it to a `X509CertificateAttributes`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `X509CertificateAttributes`. * @returns {X509CertificateAttributes} */ static _from_object(_o) { return new X509CertificateAttributes(_o.value, _o.subject, _o.issuer, _o.serialNumber, _o._unrecognizedExtensionsList); } } exports.X509CertificateAttributes = X509CertificateAttributes; /* END_OF_SYMBOL_DEFINITION X509CertificateAttributes */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_X509CertificateAttributes */ /** * @summary The Leading Root Component Types of X509CertificateAttributes * @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_X509CertificateAttributes = [ new $.ComponentSpec("value", false, $.hasAnyTag, undefined, undefined), new $.ComponentSpec("subject", true, $.hasAnyTag, undefined, undefined), new $.ComponentSpec("issuer", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 0), undefined, undefined), new $.ComponentSpec("serialNumber", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_X509CertificateAttributes */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_X509CertificateAttributes */ /** * @summary The Trailing Root Component Types of X509CertificateAttributes * @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_X509CertificateAttributes = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_X509CertificateAttributes */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_X509CertificateAttributes */ /** * @summary The Extension Addition Component Types of X509CertificateAttributes * @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_X509CertificateAttributes = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_X509CertificateAttributes */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_X509CertificateAttributes */ let _cached_decoder_for_X509CertificateAttributes = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_X509CertificateAttributes */ /* START_OF_SYMBOL_DEFINITION _decode_X509CertificateAttributes */ /** * @summary Decodes an ASN.1 element into a(n) X509CertificateAttributes * @function * @param {_Element} el The element being decoded. * @returns {X509CertificateAttributes} The decoded data structure. */ function _decode_X509CertificateAttributes(el) { if (!_cached_decoder_for_X509CertificateAttributes) { _cached_decoder_for_X509CertificateAttributes = function (el) { /* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */ let value; let subject; let issuer; let serialNumber; let _unrecognizedExtensionsList = []; /* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */ /* START_OF_CALLBACKS_MAP */ const callbacks = { value: (_el) => { value = ObjectValue_ta_1._get_decoder_for_ObjectValue(Certificate_ta_1._decode_Certificate)(_el); }, subject: (_el) => { subject = Name_ta_1._decode_Name(_el); }, issuer: (_el) => { issuer = $._decode_explicit(() => Name_ta_1._decode_Name)(_el); }, serialNumber: (_el) => { serialNumber = CertificateSerialNumber_ta_1._decode_CertificateSerialNumber(_el); }, }; /* END_OF_CALLBACKS_MAP */ $._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_X509CertificateAttributes, exports._extension_additions_list_spec_for_X509CertificateAttributes, exports._root_component_type_list_2_spec_for_X509CertificateAttributes, (ext) => { _unrecognizedExtensionsList.push(ext); }); return new X509CertificateAttributes( /* SEQUENCE_CONSTRUCTOR_CALL */ value, subject, issuer, serialNumber, _unrecognizedExtensionsList); }; } return _cached_decoder_for_X509CertificateAttributes(el); } exports._decode_X509CertificateAttributes = _decode_X509CertificateAttributes; /* END_OF_SYMBOL_DEFINITION _decode_X509CertificateAttributes */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_X509CertificateAttributes */ let _cached_encoder_for_X509CertificateAttributes = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_X509CertificateAttributes */ /* START_OF_SYMBOL_DEFINITION _encode_X509CertificateAttributes */ /** * @summary Encodes a(n) X509CertificateAttributes 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 X509CertificateAttributes, encoded as an ASN.1 Element. */ function _encode_X509CertificateAttributes(value, elGetter) { if (!_cached_encoder_for_X509CertificateAttributes) { _cached_encoder_for_X509CertificateAttributes = function (value, elGetter) { return $._encodeSequence([] .concat([ /* REQUIRED */ ObjectValue_ta_1._get_encoder_for_ObjectValue(Certificate_ta_1._encode_Certificate)(value.value, $.BER), /* IF_ABSENT */ value.subject === undefined ? undefined : Name_ta_1._encode_Name(value.subject, $.BER), /* IF_ABSENT */ value.issuer === undefined ? undefined : $._encode_explicit(asn1_ts_1.ASN1TagClass.context, 0, () => Name_ta_1._encode_Name, $.BER)(value.issuer, $.BER), /* IF_ABSENT */ value.serialNumber === undefined ? undefined : CertificateSerialNumber_ta_1._encode_CertificateSerialNumber(value.serialNumber, $.BER), ], value._unrecognizedExtensionsList ? value._unrecognizedExtensionsList : []) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_X509CertificateAttributes(value, elGetter); } exports._encode_X509CertificateAttributes = _encode_X509CertificateAttributes; /* END_OF_SYMBOL_DEFINITION _encode_X509CertificateAttributes */ /* eslint-enable */ //# sourceMappingURL=X509CertificateAttributes.ta.js.map