UNPKG

@wildboar/pkcs

Version:
225 lines (224 loc) 7.82 kB
/* eslint-disable */ import { ASN1TagClass as _TagClass, } from "@wildboar/asn1"; import * as $ from "@wildboar/asn1/functional"; import { _decode_BiometricFlags, _encode_BiometricFlags, } from "../PKCS-15/BiometricFlags.ta.mjs"; import { _decode_BiometricType, _encode_BiometricType, } from "../PKCS-15/BiometricType.ta.mjs"; import { _decode_Path, _encode_Path } from "../PKCS-15/Path.ta.mjs"; import { _decode_Reference, _encode_Reference, } from "../PKCS-15/Reference.ta.mjs"; /** * @summary BiometricAttributes * @description * * ### ASN.1 Definition: * * ```asn1 * BiometricAttributes ::= SEQUENCE { * bioFlags BiometricFlags, * templateId OBJECT IDENTIFIER, * bioType BiometricType, * bioReference Reference DEFAULT 0, * lastChange GeneralizedTime OPTIONAL, * path Path OPTIONAL, * ... -- For future extensions * } * ``` * */ export class BiometricAttributes { bioFlags; templateId; bioType; bioReference; lastChange; path; _unrecognizedExtensionsList; constructor( /** * @summary `bioFlags`. * @public * @readonly */ bioFlags, /** * @summary `templateId`. * @public * @readonly */ templateId, /** * @summary `bioType`. * @public * @readonly */ bioType, /** * @summary `bioReference`. * @public * @readonly */ bioReference, /** * @summary `lastChange`. * @public * @readonly */ lastChange, /** * @summary `path`. * @public * @readonly */ path, /** * @summary Extensions that are not recognized. * @public * @readonly */ _unrecognizedExtensionsList = []) { this.bioFlags = bioFlags; this.templateId = templateId; this.bioType = bioType; this.bioReference = bioReference; this.lastChange = lastChange; this.path = path; this._unrecognizedExtensionsList = _unrecognizedExtensionsList; } /** * @summary Restructures an object into a BiometricAttributes * @description * * This takes an `object` and converts it to a `BiometricAttributes`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `BiometricAttributes`. * @returns {BiometricAttributes} */ static _from_object(_o) { return new BiometricAttributes(_o.bioFlags, _o.templateId, _o.bioType, _o.bioReference, _o.lastChange, _o.path, _o._unrecognizedExtensionsList); } /** * @summary Getter that returns the default value for `bioReference`. * @public * @static * @method */ static get _default_value_for_bioReference() { return 0; } } /** * @summary The Leading Root Component Types of BiometricAttributes * @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_BiometricAttributes = [ new $.ComponentSpec("bioFlags", false, $.hasTag(_TagClass.universal, 3)), new $.ComponentSpec("templateId", false, $.hasTag(_TagClass.universal, 6)), new $.ComponentSpec("bioType", false, $.hasAnyTag), new $.ComponentSpec("bioReference", true, $.hasTag(_TagClass.universal, 2)), new $.ComponentSpec("lastChange", true, $.hasTag(_TagClass.universal, 24)), new $.ComponentSpec("path", true, $.hasTag(_TagClass.universal, 16)), ]; /** * @summary The Trailing Root Component Types of BiometricAttributes * @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_BiometricAttributes = []; /** * @summary The Extension Addition Component Types of BiometricAttributes * @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_BiometricAttributes = []; let _cached_decoder_for_BiometricAttributes = null; /** * @summary Decodes an ASN.1 element into a(n) BiometricAttributes * @function * @param {_Element} el The element being decoded. * @returns {BiometricAttributes} The decoded data structure. */ export function _decode_BiometricAttributes(el) { if (!_cached_decoder_for_BiometricAttributes) { _cached_decoder_for_BiometricAttributes = function (el) { let bioFlags; let templateId; let bioType; let bioReference = BiometricAttributes._default_value_for_bioReference; let lastChange; let path; let _unrecognizedExtensionsList = []; const callbacks = { bioFlags: (_el) => { bioFlags = _decode_BiometricFlags(_el); }, templateId: (_el) => { templateId = $._decodeObjectIdentifier(_el); }, bioType: (_el) => { bioType = _decode_BiometricType(_el); }, bioReference: (_el) => { bioReference = _decode_Reference(_el); }, lastChange: (_el) => { lastChange = $._decodeGeneralizedTime(_el); }, path: (_el) => { path = _decode_Path(_el); }, }; $._parse_sequence(el, callbacks, _root_component_type_list_1_spec_for_BiometricAttributes, _extension_additions_list_spec_for_BiometricAttributes, _root_component_type_list_2_spec_for_BiometricAttributes, (ext) => { _unrecognizedExtensionsList.push(ext); }); return new BiometricAttributes(bioFlags, templateId, bioType, bioReference, lastChange, path, _unrecognizedExtensionsList); }; } return _cached_decoder_for_BiometricAttributes(el); } let _cached_encoder_for_BiometricAttributes = null; /** * @summary Encodes a(n) BiometricAttributes 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 BiometricAttributes, encoded as an ASN.1 Element. */ export function _encode_BiometricAttributes(value, elGetter) { if (!_cached_encoder_for_BiometricAttributes) { _cached_encoder_for_BiometricAttributes = function (value) { return $._encodeSequence([] .concat([ /* REQUIRED */ _encode_BiometricFlags(value.bioFlags, $.BER), /* REQUIRED */ $._encodeObjectIdentifier(value.templateId, $.BER), /* REQUIRED */ _encode_BiometricType(value.bioType, $.BER), /* IF_DEFAULT */ value.bioReference === undefined || $.deepEq(value.bioReference, BiometricAttributes._default_value_for_bioReference) ? undefined : _encode_Reference(value.bioReference, $.BER), /* IF_ABSENT */ value.lastChange === undefined ? undefined : $._encodeGeneralizedTime(value.lastChange, $.BER), /* IF_ABSENT */ value.path === undefined ? undefined : _encode_Path(value.path, $.BER), ], value._unrecognizedExtensionsList ? value._unrecognizedExtensionsList : []) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_BiometricAttributes(value, elGetter); } /* eslint-enable */