@wildboar/pc
Version:
Trusted Computing Group Platform Certificate ASN.1 data structures in TypeScript
152 lines • 6.45 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_ComponentAddress = exports._decode_ComponentAddress = exports._extension_additions_list_spec_for_ComponentAddress = exports._root_component_type_list_2_spec_for_ComponentAddress = exports._root_component_type_list_1_spec_for_ComponentAddress = exports.ComponentAddress = exports._encode_AddressType = exports._decode_AddressType = void 0;
/* eslint-disable */
const asn1_ts_1 = require("asn1-ts");
const $ = require("asn1-ts/dist/node/functional");
const AddressType_ta_1 = require("../PlatformCertificateProfile/AddressType.ta");
var AddressType_ta_2 = require("../PlatformCertificateProfile/AddressType.ta");
Object.defineProperty(exports, "_decode_AddressType", { enumerable: true, get: function () { return AddressType_ta_2._decode_AddressType; } });
Object.defineProperty(exports, "_encode_AddressType", { enumerable: true, get: function () { return AddressType_ta_2._encode_AddressType; } });
/* START_OF_SYMBOL_DEFINITION ComponentAddress */
/**
* @summary ComponentAddress
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* ComponentAddress ::= SEQUENCE {
* addressType AddressType,
* addressValue UTF8String (SIZE (1..strmax)) }
* ```
*
* @class
*/
class ComponentAddress {
constructor(
/**
* @summary `addressType`.
* @public
* @readonly
*/
addressType,
/**
* @summary `addressValue`.
* @public
* @readonly
*/
addressValue) {
this.addressType = addressType;
this.addressValue = addressValue;
}
/**
* @summary Restructures an object into a ComponentAddress
* @description
*
* This takes an `object` and converts it to a `ComponentAddress`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `ComponentAddress`.
* @returns {ComponentAddress}
*/
static _from_object(_o) {
return new ComponentAddress(_o.addressType, _o.addressValue);
}
}
exports.ComponentAddress = ComponentAddress;
/* END_OF_SYMBOL_DEFINITION ComponentAddress */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_ComponentAddress */
/**
* @summary The Leading Root Component Types of ComponentAddress
* @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_ComponentAddress = [
new $.ComponentSpec("addressType", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 6), undefined, undefined),
new $.ComponentSpec("addressValue", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 12), undefined, undefined)
];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_ComponentAddress */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_ComponentAddress */
/**
* @summary The Trailing Root Component Types of ComponentAddress
* @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_ComponentAddress = [];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_ComponentAddress */
/* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_ComponentAddress */
/**
* @summary The Extension Addition Component Types of ComponentAddress
* @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_ComponentAddress = [];
/* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_ComponentAddress */
/* START_OF_SYMBOL_DEFINITION _cached_decoder_for_ComponentAddress */
let _cached_decoder_for_ComponentAddress = null;
/* END_OF_SYMBOL_DEFINITION _cached_decoder_for_ComponentAddress */
/* START_OF_SYMBOL_DEFINITION _decode_ComponentAddress */
/**
* @summary Decodes an ASN.1 element into a(n) ComponentAddress
* @function
* @param {_Element} el The element being decoded.
* @returns {ComponentAddress} The decoded data structure.
*/
function _decode_ComponentAddress(el) {
if (!_cached_decoder_for_ComponentAddress) {
_cached_decoder_for_ComponentAddress = function (el) {
const sequence = el.sequence;
if (sequence.length < 2) {
throw new asn1_ts_1.ASN1ConstructionError("ComponentAddress contained only " + sequence.length.toString() + " elements.");
}
sequence[0].name = "addressType";
sequence[1].name = "addressValue";
let addressType;
let addressValue;
addressType = AddressType_ta_1._decode_AddressType(sequence[0]);
addressValue = $._decodeUTF8String(sequence[1]);
return new ComponentAddress(addressType, addressValue);
};
}
return _cached_decoder_for_ComponentAddress(el);
}
exports._decode_ComponentAddress = _decode_ComponentAddress;
/* END_OF_SYMBOL_DEFINITION _decode_ComponentAddress */
/* START_OF_SYMBOL_DEFINITION _cached_encoder_for_ComponentAddress */
let _cached_encoder_for_ComponentAddress = null;
/* END_OF_SYMBOL_DEFINITION _cached_encoder_for_ComponentAddress */
/* START_OF_SYMBOL_DEFINITION _encode_ComponentAddress */
/**
* @summary Encodes a(n) ComponentAddress 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 ComponentAddress, encoded as an ASN.1 Element.
*/
function _encode_ComponentAddress(value, elGetter) {
if (!_cached_encoder_for_ComponentAddress) {
_cached_encoder_for_ComponentAddress = function (value, elGetter) {
return $._encodeSequence([].concat([
/* REQUIRED */ AddressType_ta_1._encode_AddressType(value.addressType, $.BER),
/* REQUIRED */ $._encodeUTF8String(value.addressValue, $.BER)
]).filter((c) => (!!c)), $.BER);
};
}
return _cached_encoder_for_ComponentAddress(value, elGetter);
}
exports._encode_ComponentAddress = _encode_ComponentAddress;
/* END_OF_SYMBOL_DEFINITION _encode_ComponentAddress */
/* eslint-enable */
//# sourceMappingURL=ComponentAddress.ta.js.map