From 25a3bec2725be93b9afd58f926bd79848c1d78fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczy=C5=84ski?= Date: Fri, 11 Jul 2025 16:52:29 +0200 Subject: [PATCH] Halo: Allow to provide raw password digest instead of password for signing, fix bug in RN driver (#467) --- core/src.ts/drivers/common.ts | 12 ++++++++++-- core/src.ts/drivers/credential.ts | 18 +++--------------- core/src.ts/drivers/nfc_manager.ts | 2 +- core/src.ts/halo/command_types.ts | 1 + core/src.ts/halo/commands.ts | 14 +++++++++++++- 5 files changed, 28 insertions(+), 19 deletions(-) diff --git a/core/src.ts/drivers/common.ts b/core/src.ts/drivers/common.ts index 3585510..a349242 100644 --- a/core/src.ts/drivers/common.ts +++ b/core/src.ts/drivers/common.ts @@ -41,6 +41,7 @@ import { HaloResponseObject } from "../types.js"; import {Buffer} from 'buffer/index.js'; +import {arr2hex, isWebDebugEnabled} from "../halo/util.js"; async function execHaloCmd(command: HaloCommandObject, options: ExecHaloCmdOptions): Promise { command = Object.assign({}, command); @@ -103,12 +104,19 @@ async function execHaloCmd(command: HaloCommandObject, options: ExecHaloCmdOptio } function checkErrors(res: Buffer) { + const webDebug = isWebDebugEnabled(); + if (res.length === 2 && res[0] === 0xE1) { + if (webDebug) { + console.log('[libhalo] execCredential() command fail:', arr2hex(res)); + } + if (Object.prototype.hasOwnProperty.call(ERROR_CODES, res[1])) { const err = ERROR_CODES[res[1]]; - throw new HaloTagError(err[0], "Tag responded with error: [" + err[0] + "] " + err[1]); + throw new HaloTagError(err[0], err[1]); } else { - throw new HaloLogicError("Tag responded with unknown error: " + res.toString('hex')); + const errCode = arr2hex([res[1]]); + throw new HaloTagError("ERROR_CODE_" + errCode, "Command returned an unknown error: " + arr2hex(res)); } } } diff --git a/core/src.ts/drivers/credential.ts b/core/src.ts/drivers/credential.ts index 3cb5d79..b98fa32 100644 --- a/core/src.ts/drivers/credential.ts +++ b/core/src.ts/drivers/credential.ts @@ -4,11 +4,11 @@ * License: MIT */ -import {HaloTagError, NFCOperationError, NFCMethodNotSupported} from "../halo/exceptions.js"; -import {ERROR_CODES} from "../halo/errors.js"; +import {NFCOperationError, NFCMethodNotSupported} from "../halo/exceptions.js"; import {arr2hex, isWebDebugEnabled} from "../halo/util.js"; import {ExecOptions, ExecReturnStruct} from "../types.js"; import {Buffer} from 'buffer/index.js'; +import {checkErrors} from "./common.js"; async function execCredential(request: Buffer, options: ExecOptions): Promise { const webDebug = isWebDebugEnabled(); @@ -87,19 +87,7 @@ async function execCredential(request: Buffer, options: ExecOptions): Promise