Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hazae41/ledger
Private and supply-chain hardened Ledger controller for TypeScript
https://github.com/hazae41/ledger
Last synced: about 2 months ago
JSON representation
Private and supply-chain hardened Ledger controller for TypeScript
- Host: GitHub
- URL: https://github.com/hazae41/ledger
- Owner: hazae41
- Created: 2024-05-09T10:46:55.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-09-01T04:47:57.000Z (3 months ago)
- Last Synced: 2024-10-07T22:37:20.836Z (2 months ago)
- Language: TypeScript
- Size: 56.6 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
- awesome-ccamel - hazae41/ledger - Private and supply-chain hardened Ledger controller for TypeScript (TypeScript)
README
# Ledger
Private and supply-chain hardened Ledger controller for TypeScript
```bash
npm i @hazae41/ledger
```[**Node Package 📦**](https://www.npmjs.com/package/@hazae41/ledger)
## Features
### Current features
- 100% TypeScript and ESM
- No external dependencies
- Rust-like patterns
- No network code
- No tracking## Usage
### Get USB connector
```tsx
/** Will open a popup using navigator.usb */
const device = Ledger.USB.getOrRequestDeviceOrThrow()
const connector = Ledger.USB.connectOrThrow(device)
```### Get address and/or uncompressed public key at path
```tsx
import { Ledger } from "@hazae41/ledger"const { address, uncompressedPublicKey } = await Ledger.Ethereum.getAddressOrThrow(connector, "44'/60'/0'/0/0")
```### Verify and get address and/or uncompressed public key at path
Ask the user to verify the address and get it
```tsx
import { Ledger } from "@hazae41/ledger"const { address, uncompressedPublicKey } = await Ledger.Ethereum.verifyAndGetAddressOrThrow(connector, "44'/60'/0'/0/0")
```### Sign a personal message at path
```tsx
import { Ledger } from "@hazae41/ledger"
import { ZeroHexSignature } from "@hazae41/cubane"const message = new TextEncoder().encode("Hello World")
const rsvSignature = await Ledger.Ethereum.signPersonalMessageOrThrow(connector, "44'/60'/0'/0/0", message)
const zeroHexSignature = ZeroHexSignature.fromOrThrow(rsvSignature)
```### Sign a transaction at path
```tsx
import { Ledger } from "@hazae41/ledger"
import { ZeroHexSignature } from "@hazae41/cubane"const transaction = ethers.utils.arrayify(ethers.Transaction.from({
chainId,
nonce,
to,
value,
data
gasLimit,
gasPrice,
}).unsignedSerialized)const rsvSignature = await Ledger.Ethereum.signTransactionOrThrow(connector, "44'/60'/0'/0/0", transaction)
const zeroHexSignature = ZeroHexSignature.fromOrThrow(rsvSignature)
```### Sign EIP712 typed message at path
```tsx
import { Ledger } from "@hazae41/ledger"
import { ZeroHexSignature } from "@hazae41/cubane"const rsvSignature = await Ledger.Ethereum.signEIP712HashedMessageOrThrow(connector, "44'/60'/0'/0/0", domain, message)
const zeroHexSignature = ZeroHexSignature.fromOrThrow(rsvSignature)
```