UNPKG

@wildboar/pkcs

Version:
178 lines 8.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_CommonDataObjectAttributes = exports._decode_CommonDataObjectAttributes = exports._extension_additions_list_spec_for_CommonDataObjectAttributes = exports._root_component_type_list_2_spec_for_CommonDataObjectAttributes = exports._root_component_type_list_1_spec_for_CommonDataObjectAttributes = exports.CommonDataObjectAttributes = exports._encode_Label = exports._decode_Label = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const Label_ta_1 = require("../PKCS-15/Label.ta"); var Label_ta_2 = require("../PKCS-15/Label.ta"); Object.defineProperty(exports, "_decode_Label", { enumerable: true, get: function () { return Label_ta_2._decode_Label; } }); Object.defineProperty(exports, "_encode_Label", { enumerable: true, get: function () { return Label_ta_2._encode_Label; } }); /* START_OF_SYMBOL_DEFINITION CommonDataObjectAttributes */ /** * @summary CommonDataObjectAttributes * @description * * ### ASN.1 Definition: * * ```asn1 * CommonDataObjectAttributes ::= SEQUENCE { * applicationName Label OPTIONAL, * applicationOID OBJECT IDENTIFIER OPTIONAL, * ... -- For future extensions * } (WITH COMPONENTS {..., applicationName PRESENT} | WITH COMPONENTS {..., applicationOID PRESENT}) * ``` * * @class */ class CommonDataObjectAttributes { constructor( /** * @summary `applicationName`. * @public * @readonly */ applicationName, /** * @summary `applicationOID`. * @public * @readonly */ applicationOID, /** * @summary Extensions that are not recognized. * @public * @readonly */ _unrecognizedExtensionsList = []) { this.applicationName = applicationName; this.applicationOID = applicationOID; this._unrecognizedExtensionsList = _unrecognizedExtensionsList; } /** * @summary Restructures an object into a CommonDataObjectAttributes * @description * * This takes an `object` and converts it to a `CommonDataObjectAttributes`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `CommonDataObjectAttributes`. * @returns {CommonDataObjectAttributes} */ static _from_object(_o) { return new CommonDataObjectAttributes(_o.applicationName, _o.applicationOID, _o._unrecognizedExtensionsList); } } exports.CommonDataObjectAttributes = CommonDataObjectAttributes; /* END_OF_SYMBOL_DEFINITION CommonDataObjectAttributes */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_CommonDataObjectAttributes */ /** * @summary The Leading Root Component Types of CommonDataObjectAttributes * @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_CommonDataObjectAttributes = [ new $.ComponentSpec("applicationName", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 12), undefined, undefined), new $.ComponentSpec("applicationOID", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 6), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_CommonDataObjectAttributes */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_CommonDataObjectAttributes */ /** * @summary The Trailing Root Component Types of CommonDataObjectAttributes * @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_CommonDataObjectAttributes = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_CommonDataObjectAttributes */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_CommonDataObjectAttributes */ /** * @summary The Extension Addition Component Types of CommonDataObjectAttributes * @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_CommonDataObjectAttributes = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_CommonDataObjectAttributes */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_CommonDataObjectAttributes */ let _cached_decoder_for_CommonDataObjectAttributes = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_CommonDataObjectAttributes */ /* START_OF_SYMBOL_DEFINITION _decode_CommonDataObjectAttributes */ /** * @summary Decodes an ASN.1 element into a(n) CommonDataObjectAttributes * @function * @param {_Element} el The element being decoded. * @returns {CommonDataObjectAttributes} The decoded data structure. */ function _decode_CommonDataObjectAttributes(el) { if (!_cached_decoder_for_CommonDataObjectAttributes) { _cached_decoder_for_CommonDataObjectAttributes = function (el) { /* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */ let applicationName; let applicationOID; let _unrecognizedExtensionsList = []; /* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */ /* START_OF_CALLBACKS_MAP */ const callbacks = { applicationName: (_el) => { applicationName = Label_ta_1._decode_Label(_el); }, applicationOID: (_el) => { applicationOID = $._decodeObjectIdentifier(_el); }, }; /* END_OF_CALLBACKS_MAP */ $._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_CommonDataObjectAttributes, exports._extension_additions_list_spec_for_CommonDataObjectAttributes, exports._root_component_type_list_2_spec_for_CommonDataObjectAttributes, (ext) => { _unrecognizedExtensionsList.push(ext); }); return new CommonDataObjectAttributes( /* SEQUENCE_CONSTRUCTOR_CALL */ applicationName, applicationOID, _unrecognizedExtensionsList); }; } return _cached_decoder_for_CommonDataObjectAttributes(el); } exports._decode_CommonDataObjectAttributes = _decode_CommonDataObjectAttributes; /* END_OF_SYMBOL_DEFINITION _decode_CommonDataObjectAttributes */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_CommonDataObjectAttributes */ let _cached_encoder_for_CommonDataObjectAttributes = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_CommonDataObjectAttributes */ /* START_OF_SYMBOL_DEFINITION _encode_CommonDataObjectAttributes */ /** * @summary Encodes a(n) CommonDataObjectAttributes 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 CommonDataObjectAttributes, encoded as an ASN.1 Element. */ function _encode_CommonDataObjectAttributes(value, elGetter) { if (!_cached_encoder_for_CommonDataObjectAttributes) { _cached_encoder_for_CommonDataObjectAttributes = function (value, elGetter) { return $._encodeSequence([] .concat([ /* IF_ABSENT */ value.applicationName === undefined ? undefined : Label_ta_1._encode_Label(value.applicationName, $.BER), /* IF_ABSENT */ value.applicationOID === undefined ? undefined : $._encodeObjectIdentifier(value.applicationOID, $.BER), ], value._unrecognizedExtensionsList ? value._unrecognizedExtensionsList : []) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_CommonDataObjectAttributes(value, elGetter); } exports._encode_CommonDataObjectAttributes = _encode_CommonDataObjectAttributes; /* END_OF_SYMBOL_DEFINITION _encode_CommonDataObjectAttributes */ /* eslint-enable */ //# sourceMappingURL=CommonDataObjectAttributes.ta.js.map