@wildboar/pki-stub
Version:
X.510 PKI-Stub ASN.1 data structures in TypeScript
148 lines • 5.7 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._get_encoder_for_FingerPrint = exports._get_decoder_for_FingerPrint = exports._extension_additions_list_spec_for_FingerPrint = exports._root_component_type_list_2_spec_for_FingerPrint = exports._root_component_type_list_1_spec_for_FingerPrint = exports.FingerPrint = void 0;
/* eslint-disable */
const asn1_ts_1 = require("asn1-ts");
const $ = require("asn1-ts/dist/node/functional");
const AlgorithmIdentifier_ta_1 = require("../PKI-Stub/AlgorithmIdentifier.ta");
/* START_OF_SYMBOL_DEFINITION FingerPrint */
/**
* @summary FingerPrint
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* FingerPrint {ToBeFingerprinted} ::= SEQUENCE {
* algorithmIdentifier AlgorithmIdentifier{{SupportedAlgorithms}},
* fingerprint BIT STRING,
* ... }
* ```
*
* @class
*/
class FingerPrint {
constructor(
/**
* @summary `algorithmIdentifier`.
* @public
* @readonly
*/
algorithmIdentifier,
/**
* @summary `fingerprint`.
* @public
* @readonly
*/
fingerprint,
/**
* @summary Extensions that are not recognized.
* @public
* @readonly
*/
_unrecognizedExtensionsList = []) {
this.algorithmIdentifier = algorithmIdentifier;
this.fingerprint = fingerprint;
this._unrecognizedExtensionsList = _unrecognizedExtensionsList;
}
/**
* @summary Restructures an object into a FingerPrint
* @description
*
* This takes an `object` and converts it to a `FingerPrint`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `FingerPrint`.
* @returns {FingerPrint}
*/
static _from_object(_o) {
return new FingerPrint(_o.algorithmIdentifier, _o.fingerprint, _o._unrecognizedExtensionsList);
}
}
exports.FingerPrint = FingerPrint;
/* END_OF_SYMBOL_DEFINITION FingerPrint */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_FingerPrint */
/**
* @summary The Leading Root Component Types of FingerPrint
* @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_FingerPrint = [
new $.ComponentSpec("algorithmIdentifier", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
new $.ComponentSpec("fingerprint", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 3), undefined, undefined),
];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_FingerPrint */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_FingerPrint */
/**
* @summary The Trailing Root Component Types of FingerPrint
* @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_FingerPrint = [];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_FingerPrint */
/* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_FingerPrint */
/**
* @summary The Extension Addition Component Types of FingerPrint
* @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_FingerPrint = [];
/* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_FingerPrint */
/* START_OF_SYMBOL_DEFINITION _get_decoder_for_FingerPrint */
/**
* @summary Returns a function that will decode an ASN.1 element into a(n) FingerPrint
* @function
* @param {_Element} el The element being decoded.
* @returns A function that will decode an ASN.1 element.
*/
function _get_decoder_for_FingerPrint(_decode_ToBeFingerprinted) {
return function (el) {
const sequence = el.sequence;
if (sequence.length < 2) {
throw new asn1_ts_1.ASN1ConstructionError("FingerPrint contained only " +
sequence.length.toString() +
" elements.");
}
sequence[0].name = "algorithmIdentifier";
sequence[1].name = "fingerprint";
let algorithmIdentifier;
let fingerprint;
algorithmIdentifier = AlgorithmIdentifier_ta_1._decode_AlgorithmIdentifier(sequence[0]);
fingerprint = $._decodeBitString(sequence[1]);
return new FingerPrint(algorithmIdentifier, fingerprint, sequence.slice(2));
};
}
exports._get_decoder_for_FingerPrint = _get_decoder_for_FingerPrint;
/* END_OF_SYMBOL_DEFINITION _get_decoder_for_FingerPrint */
/* START_OF_SYMBOL_DEFINITION _get_encoder_for_FingerPrint */
/**
* @summary Returns a function that will encode a(n) FingerPrint into an ASN.1 Element.
* @function
* @returns A function that will encode a(n) FingerPrint as an ASN.1 element.
*/
function _get_encoder_for_FingerPrint(_encode_ToBeFingerprinted) {
return function (value, elGetter) {
var _a;
const components = [
/* REQUIRED */ AlgorithmIdentifier_ta_1._encode_AlgorithmIdentifier(value.algorithmIdentifier, $.BER),
/* REQUIRED */ $._encodeBitString(value.fingerprint, $.BER),
...(_a = value._unrecognizedExtensionsList) !== null && _a !== void 0 ? _a : [],
];
return $._encodeSequence(components, $.BER);
};
}
exports._get_encoder_for_FingerPrint = _get_encoder_for_FingerPrint;
/* END_OF_SYMBOL_DEFINITION _get_encoder_for_FingerPrint */
/* eslint-enable */
//# sourceMappingURL=FingerPrint.ta.js.map