@wildboar/qc
Version:
Qualified Certificates in TypeScript
178 lines (177 loc) • 6.39 kB
JavaScript
/* eslint-disable */
import { ASN1TagClass as _TagClass, } from "@wildboar/asn1";
import * as $ from "@wildboar/asn1/functional";
import { _decode_AlgorithmIdentifier, _encode_AlgorithmIdentifier, } from "@wildboar/x500/AuthenticationFramework";
import { _decode_TypeOfBiometricData, _encode_TypeOfBiometricData, } from "../PKIXqualified97/TypeOfBiometricData.ta.mjs";
/**
* @summary BiometricData
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* BiometricData ::= SEQUENCE {
* typeOfBiometricData TypeOfBiometricData,
* hashAlgorithm AlgorithmIdentifier,
* biometricDataHash OCTET STRING,
* sourceDataUri IA5String OPTIONAL,
* ... -- For future extensions -- }
* ```
*
*/
export class BiometricData {
typeOfBiometricData;
hashAlgorithm;
biometricDataHash;
sourceDataUri;
_unrecognizedExtensionsList;
constructor(
/**
* @summary `typeOfBiometricData`.
* @public
* @readonly
*/
typeOfBiometricData,
/**
* @summary `hashAlgorithm`.
* @public
* @readonly
*/
hashAlgorithm,
/**
* @summary `biometricDataHash`.
* @public
* @readonly
*/
biometricDataHash,
/**
* @summary `sourceDataUri`.
* @public
* @readonly
*/
sourceDataUri,
/**
* @summary Extensions that are not recognized.
* @public
* @readonly
*/
_unrecognizedExtensionsList = []) {
this.typeOfBiometricData = typeOfBiometricData;
this.hashAlgorithm = hashAlgorithm;
this.biometricDataHash = biometricDataHash;
this.sourceDataUri = sourceDataUri;
this._unrecognizedExtensionsList = _unrecognizedExtensionsList;
}
/**
* @summary Restructures an object into a BiometricData
* @description
*
* This takes an `object` and converts it to a `BiometricData`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `BiometricData`.
* @returns {BiometricData}
*/
static _from_object(_o) {
return new BiometricData(_o.typeOfBiometricData, _o.hashAlgorithm, _o.biometricDataHash, _o.sourceDataUri, _o._unrecognizedExtensionsList);
}
}
/**
* @summary The Leading Root Component Types of BiometricData
* @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
*/
export const _root_component_type_list_1_spec_for_BiometricData = [
new $.ComponentSpec("typeOfBiometricData", false, $.hasAnyTag),
new $.ComponentSpec("hashAlgorithm", false, $.hasTag(_TagClass.universal, 16)),
new $.ComponentSpec("biometricDataHash", false, $.hasTag(_TagClass.universal, 4)),
new $.ComponentSpec("sourceDataUri", true, $.hasTag(_TagClass.universal, 22)),
];
/**
* @summary The Trailing Root Component Types of BiometricData
* @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
*/
export const _root_component_type_list_2_spec_for_BiometricData = [];
/**
* @summary The Extension Addition Component Types of BiometricData
* @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
*/
export const _extension_additions_list_spec_for_BiometricData = [];
let _cached_decoder_for_BiometricData = null;
/**
* @summary Decodes an ASN.1 element into a(n) BiometricData
* @function
* @param {_Element} el The element being decoded.
* @returns {BiometricData} The decoded data structure.
*/
export function _decode_BiometricData(el) {
if (!_cached_decoder_for_BiometricData) {
_cached_decoder_for_BiometricData = function (el) {
let typeOfBiometricData;
let hashAlgorithm;
let biometricDataHash;
let sourceDataUri;
let _unrecognizedExtensionsList = [];
const callbacks = {
typeOfBiometricData: (_el) => {
typeOfBiometricData = _decode_TypeOfBiometricData(_el);
},
hashAlgorithm: (_el) => {
hashAlgorithm = _decode_AlgorithmIdentifier(_el);
},
biometricDataHash: (_el) => {
biometricDataHash = $._decodeOctetString(_el);
},
sourceDataUri: (_el) => {
sourceDataUri = $._decodeIA5String(_el);
},
};
$._parse_sequence(el, callbacks, _root_component_type_list_1_spec_for_BiometricData, _extension_additions_list_spec_for_BiometricData, _root_component_type_list_2_spec_for_BiometricData, (ext) => {
_unrecognizedExtensionsList.push(ext);
});
return new BiometricData(typeOfBiometricData, hashAlgorithm, biometricDataHash, sourceDataUri, _unrecognizedExtensionsList);
};
}
return _cached_decoder_for_BiometricData(el);
}
let _cached_encoder_for_BiometricData = null;
/**
* @summary Encodes a(n) BiometricData into an ASN.1 Element.
* @function
* @param value The element being encoded.
* @param elGetter A function that can be used to get new ASN.1 elements.
* @returns {_Element} The BiometricData, encoded as an ASN.1 Element.
*/
export function _encode_BiometricData(value, elGetter) {
if (!_cached_encoder_for_BiometricData) {
_cached_encoder_for_BiometricData = function (value) {
return $._encodeSequence([]
.concat([
/* REQUIRED */ _encode_TypeOfBiometricData(value.typeOfBiometricData, $.BER),
/* REQUIRED */ _encode_AlgorithmIdentifier(value.hashAlgorithm, $.BER),
/* REQUIRED */ $._encodeOctetString(value.biometricDataHash, $.BER),
/* IF_ABSENT */ value.sourceDataUri === undefined
? undefined
: $._encodeIA5String(value.sourceDataUri, $.BER),
], value._unrecognizedExtensionsList
? value._unrecognizedExtensionsList
: [])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_BiometricData(value, elGetter);
}
/* eslint-enable */