mirror of
https://github.com/arx-research/libhalo.git
synced 2026-01-09 13:18:04 -05:00
Core: Connect with the new ISO7816 AID (#484)
This commit is contained in:
committed by
GitHub
parent
e21450be5a
commit
e5216c2f8a
@@ -22,6 +22,7 @@ import {
|
||||
} from "./ws_server.js";
|
||||
import {execHaloCmdPCSC} from "@arx-research/libhalo/api/desktop";
|
||||
import {ConnectSimulatorOptions, HaloCommandObject, Reader} from "@arx-research/libhalo/types";
|
||||
import {ISO7816_SELECT_CMDS} from "@arx-research/libhalo/api/common";
|
||||
import {Namespace} from "argparse";
|
||||
import {INFC, SimNFC} from "./simulator_nfc.js";
|
||||
import fs from "fs";
|
||||
@@ -48,15 +49,21 @@ let stopPCSCTimeout: number | null = null;
|
||||
let isConnected = false;
|
||||
let isClosing = false;
|
||||
|
||||
async function checkCard(reader: Reader) {
|
||||
async function checkCard(reader: Reader): Promise<boolean> {
|
||||
// try to select Halo ETH Core Layer
|
||||
try {
|
||||
const resSelect = await reader.transmit(Buffer.from("00A4040007481199130E9F0100", "hex"), 255);
|
||||
return resSelect.compare(Buffer.from([0x90, 0x00])) === 0;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
return false;
|
||||
for (const aid of ISO7816_SELECT_CMDS) {
|
||||
try {
|
||||
const resSelect = await reader.transmit(Buffer.from(aid, "hex"), 255);
|
||||
|
||||
if (resSelect.slice(-2).compare(Buffer.from([0x90, 0x00])) === 0) {
|
||||
return true;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function ensureSimulator() {
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
integrity sha512-96Z2IP3mYmF1Xg2cDm8f1gWGf/HUVedQ3FMifV4kG/PQ4yEP51xDtRAEfhVNt5f/uzpNkZHwWQuUcu6D6K+Ekw==
|
||||
|
||||
"@arx-research/libhalo@../core":
|
||||
version "1.10.16"
|
||||
version "1.15.0"
|
||||
dependencies:
|
||||
buffer "^6.0.3"
|
||||
elliptic "^6.6.1"
|
||||
ethers "^6.13.5"
|
||||
jose "^6.0.10"
|
||||
jose "^6.0.13"
|
||||
js-sha256 "^0.11.0"
|
||||
pbkdf2 "^3.1.2"
|
||||
qrcode "^1.5.4"
|
||||
@@ -2009,10 +2009,10 @@ jest-worker@^27.4.5:
|
||||
merge-stream "^2.0.0"
|
||||
supports-color "^8.0.0"
|
||||
|
||||
jose@^6.0.10:
|
||||
version "6.0.10"
|
||||
resolved "https://registry.yarnpkg.com/jose/-/jose-6.0.10.tgz#52d96e1a671b4c02e13b71e0d35abea2e774712b"
|
||||
integrity sha512-skIAxZqcMkOrSwjJvplIPYrlXGpxTPnro2/QWTDCxAdWQrSTV5/KqspMWmi5WAx5+ULswASJiZ0a+1B/Lxt9cw==
|
||||
jose@^6.0.13:
|
||||
version "6.1.3"
|
||||
resolved "https://registry.yarnpkg.com/jose/-/jose-6.1.3.tgz#8453d7be88af7bb7d64a0481d6a35a0145ba3ea5"
|
||||
integrity sha512-0TpaTfihd4QMNwrz/ob2Bp7X04yuxJkjRGi4aKmOqwhov54i6u79oCv7T+C7lo70MKH6BesI3vscD1yb/yzKXQ==
|
||||
|
||||
js-sha256@^0.11.0:
|
||||
version "0.11.0"
|
||||
|
||||
Reference in New Issue
Block a user