Skip to content

Commit

Permalink
refactor: remove deprecated ledger u2f transport (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
goga-m authored Mar 15, 2024
1 parent 20ab6c8 commit aa4fb5e
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 141 deletions.
1 change: 0 additions & 1 deletion packages/ledger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
},
"dependencies": {
"@ardenthq/sdk": "workspace:*",
"@ledgerhq/hw-transport-u2f": "^5.36.0-deprecated",
"@ledgerhq/hw-transport-webhid": "^6.20.0",
"@ledgerhq/hw-transport-webusb": "^6.20.0",
"platform": "^1.3.6"
Expand Down
21 changes: 2 additions & 19 deletions packages/ledger/source/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
// Based on https://github.com/near/near-ledger-js/blob/master/supportedTransports.js
import LedgerU2F from "@ledgerhq/hw-transport-u2f";
import LedgerHID from "@ledgerhq/hw-transport-webhid";
import LedgerUSB from "@ledgerhq/hw-transport-webusb";
import platform from "platform";

export class LedgerTransportFactory {
public async supportedTransport(): Promise<LedgerHID | LedgerUSB | LedgerU2F> {
const [supportsHID, supportsUSB, supportsU2F] = await Promise.all([
this.#supportsHID(),
this.#supportsUSB(),
this.#supportsU2F(),
]);
public async supportedTransport(): Promise<typeof LedgerHID | typeof LedgerUSB> {
const [supportsHID, supportsUSB] = await Promise.all([this.#supportsHID(), this.#supportsUSB()]);

if (supportsHID) {
return LedgerHID;
Expand All @@ -20,10 +15,6 @@ export class LedgerTransportFactory {
return LedgerUSB;
}

if (supportsU2F) {
return LedgerU2F;
}

throw new Error("No transports appear to be supported.");
}

Expand All @@ -46,12 +37,4 @@ export class LedgerTransportFactory {
return false;
}
}

async #supportsU2F(): Promise<boolean> {
try {
return await LedgerU2F.isSupported();
} catch {
return false;
}
}
}
Loading

0 comments on commit aa4fb5e

Please sign in to comment.