@wildboar/pc
Version:
Trusted Computing Group Platform Certificate ASN.1 data structures in TypeScript
166 lines • 7.62 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_URIReference = exports._decode_URIReference = exports._extension_additions_list_spec_for_URIReference = exports._root_component_type_list_2_spec_for_URIReference = exports._root_component_type_list_1_spec_for_URIReference = exports.URIReference = exports._encode_AlgorithmIdentifier = exports._decode_AlgorithmIdentifier = exports.AlgorithmIdentifier = void 0;
/* eslint-disable */
const asn1_ts_1 = require("asn1-ts");
const $ = require("asn1-ts/dist/node/functional");
const AlgorithmIdentifier_ta_1 = require("@wildboar/x500/src/lib/modules/AuthenticationFramework/AlgorithmIdentifier.ta");
var AlgorithmIdentifier_ta_2 = require("@wildboar/x500/src/lib/modules/AuthenticationFramework/AlgorithmIdentifier.ta");
Object.defineProperty(exports, "AlgorithmIdentifier", { enumerable: true, get: function () { return AlgorithmIdentifier_ta_2.AlgorithmIdentifier; } });
Object.defineProperty(exports, "_decode_AlgorithmIdentifier", { enumerable: true, get: function () { return AlgorithmIdentifier_ta_2._decode_AlgorithmIdentifier; } });
Object.defineProperty(exports, "_encode_AlgorithmIdentifier", { enumerable: true, get: function () { return AlgorithmIdentifier_ta_2._encode_AlgorithmIdentifier; } });
/* START_OF_SYMBOL_DEFINITION URIReference */
/**
* @summary URIReference
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* URIReference ::= SEQUENCE {
* uniformResourceIdentifier IA5String (SIZE (1..urimax)),
* hashAlgorithm AlgorithmIdentifier OPTIONAL,
* hashValue BIT STRING OPTIONAL }
* ```
*
* @class
*/
class URIReference {
constructor(
/**
* @summary `uniformResourceIdentifier`.
* @public
* @readonly
*/
uniformResourceIdentifier,
/**
* @summary `hashAlgorithm`.
* @public
* @readonly
*/
hashAlgorithm,
/**
* @summary `hashValue`.
* @public
* @readonly
*/
hashValue) {
this.uniformResourceIdentifier = uniformResourceIdentifier;
this.hashAlgorithm = hashAlgorithm;
this.hashValue = hashValue;
}
/**
* @summary Restructures an object into a URIReference
* @description
*
* This takes an `object` and converts it to a `URIReference`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `URIReference`.
* @returns {URIReference}
*/
static _from_object(_o) {
return new URIReference(_o.uniformResourceIdentifier, _o.hashAlgorithm, _o.hashValue);
}
}
exports.URIReference = URIReference;
/* END_OF_SYMBOL_DEFINITION URIReference */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_URIReference */
/**
* @summary The Leading Root Component Types of URIReference
* @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_URIReference = [
new $.ComponentSpec("uniformResourceIdentifier", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 22), undefined, undefined),
new $.ComponentSpec("hashAlgorithm", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
new $.ComponentSpec("hashValue", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 3), undefined, undefined)
];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_URIReference */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_URIReference */
/**
* @summary The Trailing Root Component Types of URIReference
* @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_URIReference = [];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_URIReference */
/* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_URIReference */
/**
* @summary The Extension Addition Component Types of URIReference
* @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_URIReference = [];
/* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_URIReference */
/* START_OF_SYMBOL_DEFINITION _cached_decoder_for_URIReference */
let _cached_decoder_for_URIReference = null;
/* END_OF_SYMBOL_DEFINITION _cached_decoder_for_URIReference */
/* START_OF_SYMBOL_DEFINITION _decode_URIReference */
/**
* @summary Decodes an ASN.1 element into a(n) URIReference
* @function
* @param {_Element} el The element being decoded.
* @returns {URIReference} The decoded data structure.
*/
function _decode_URIReference(el) {
if (!_cached_decoder_for_URIReference) {
_cached_decoder_for_URIReference = function (el) {
/* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */
let uniformResourceIdentifier;
let hashAlgorithm;
let hashValue;
/* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */
/* START_OF_CALLBACKS_MAP */
const callbacks = {
"uniformResourceIdentifier": (_el) => { uniformResourceIdentifier = $._decodeIA5String(_el); },
"hashAlgorithm": (_el) => { hashAlgorithm = AlgorithmIdentifier_ta_1._decode_AlgorithmIdentifier(_el); },
"hashValue": (_el) => { hashValue = $._decodeBitString(_el); }
};
/* END_OF_CALLBACKS_MAP */
$._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_URIReference, exports._extension_additions_list_spec_for_URIReference, exports._root_component_type_list_2_spec_for_URIReference, undefined);
return new URIReference(/* SEQUENCE_CONSTRUCTOR_CALL */ uniformResourceIdentifier, hashAlgorithm, hashValue);
};
}
return _cached_decoder_for_URIReference(el);
}
exports._decode_URIReference = _decode_URIReference;
/* END_OF_SYMBOL_DEFINITION _decode_URIReference */
/* START_OF_SYMBOL_DEFINITION _cached_encoder_for_URIReference */
let _cached_encoder_for_URIReference = null;
/* END_OF_SYMBOL_DEFINITION _cached_encoder_for_URIReference */
/* START_OF_SYMBOL_DEFINITION _encode_URIReference */
/**
* @summary Encodes a(n) URIReference 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 URIReference, encoded as an ASN.1 Element.
*/
function _encode_URIReference(value, elGetter) {
if (!_cached_encoder_for_URIReference) {
_cached_encoder_for_URIReference = function (value, elGetter) {
return $._encodeSequence([].concat([
/* REQUIRED */ $._encodeIA5String(value.uniformResourceIdentifier, $.BER),
/* IF_ABSENT */ ((value.hashAlgorithm === undefined) ? undefined : AlgorithmIdentifier_ta_1._encode_AlgorithmIdentifier(value.hashAlgorithm, $.BER)),
/* IF_ABSENT */ ((value.hashValue === undefined) ? undefined : $._encodeBitString(value.hashValue, $.BER))
]).filter((c) => (!!c)), $.BER);
};
}
return _cached_encoder_for_URIReference(value, elGetter);
}
exports._encode_URIReference = _encode_URIReference;
/* END_OF_SYMBOL_DEFINITION _encode_URIReference */
/* eslint-enable */
//# sourceMappingURL=URIReference.ta.js.map