UNPKG

@wildboar/pkcs

Version:
157 lines 5.73 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_OidDO = exports._decode_OidDO = exports._extension_additions_list_spec_for_OidDO = exports._root_component_type_list_2_spec_for_OidDO = exports._root_component_type_list_1_spec_for_OidDO = exports.OidDO = exports._get_encoder_for_ObjectValue = exports._get_decoder_for_ObjectValue = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const ObjectValue_ta_1 = require("../PKCS-15/ObjectValue.ta"); var ObjectValue_ta_2 = require("../PKCS-15/ObjectValue.ta"); Object.defineProperty(exports, "_get_decoder_for_ObjectValue", { enumerable: true, get: function () { return ObjectValue_ta_2._get_decoder_for_ObjectValue; } }); Object.defineProperty(exports, "_get_encoder_for_ObjectValue", { enumerable: true, get: function () { return ObjectValue_ta_2._get_encoder_for_ObjectValue; } }); /* START_OF_SYMBOL_DEFINITION OidDO */ /** * @summary OidDO * @description * * ### ASN.1 Definition: * * ```asn1 * OidDO ::= SEQUENCE { * id OBJECT IDENTIFIER, * value ObjectValue {PKCS15-OPAQUE.&Type} * } * ``` * * @class */ class OidDO { constructor( /** * @summary `id`. * @public * @readonly */ id, /** * @summary `value`. * @public * @readonly */ value) { this.id = id; this.value = value; } /** * @summary Restructures an object into a OidDO * @description * * This takes an `object` and converts it to a `OidDO`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `OidDO`. * @returns {OidDO} */ static _from_object(_o) { return new OidDO(_o.id, _o.value); } } exports.OidDO = OidDO; /* END_OF_SYMBOL_DEFINITION OidDO */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_OidDO */ /** * @summary The Leading Root Component Types of OidDO * @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_OidDO = [ new $.ComponentSpec("id", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 6), undefined, undefined), new $.ComponentSpec("value", false, $.hasAnyTag, undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_OidDO */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_OidDO */ /** * @summary The Trailing Root Component Types of OidDO * @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_OidDO = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_OidDO */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_OidDO */ /** * @summary The Extension Addition Component Types of OidDO * @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_OidDO = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_OidDO */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_OidDO */ let _cached_decoder_for_OidDO = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_OidDO */ /* START_OF_SYMBOL_DEFINITION _decode_OidDO */ /** * @summary Decodes an ASN.1 element into a(n) OidDO * @function * @param {_Element} el The element being decoded. * @returns {OidDO} The decoded data structure. */ function _decode_OidDO(el) { if (!_cached_decoder_for_OidDO) { _cached_decoder_for_OidDO = function (el) { const sequence = el.sequence; if (sequence.length < 2) { throw new asn1_ts_1.ASN1ConstructionError("OidDO contained only " + sequence.length.toString() + " elements."); } sequence[0].name = "id"; sequence[1].name = "value"; let id; let value; id = $._decodeObjectIdentifier(sequence[0]); value = ObjectValue_ta_1._get_decoder_for_ObjectValue($._decodeAny)(sequence[1]); return new OidDO(id, value); }; } return _cached_decoder_for_OidDO(el); } exports._decode_OidDO = _decode_OidDO; /* END_OF_SYMBOL_DEFINITION _decode_OidDO */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_OidDO */ let _cached_encoder_for_OidDO = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_OidDO */ /* START_OF_SYMBOL_DEFINITION _encode_OidDO */ /** * @summary Encodes a(n) OidDO 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 OidDO, encoded as an ASN.1 Element. */ function _encode_OidDO(value, elGetter) { if (!_cached_encoder_for_OidDO) { _cached_encoder_for_OidDO = function (value, elGetter) { return $._encodeSequence([] .concat([ /* REQUIRED */ $._encodeObjectIdentifier(value.id, $.BER), /* REQUIRED */ ObjectValue_ta_1._get_encoder_for_ObjectValue($._encodeAny)(value.value, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_OidDO(value, elGetter); } exports._encode_OidDO = _encode_OidDO; /* END_OF_SYMBOL_DEFINITION _encode_OidDO */ /* eslint-enable */ //# sourceMappingURL=OidDO.ta.js.map