keycard-manager
v0.9.7
Published
This project provides tools and libraries for integrating with hardware wallets using smart card technology. It includes functionalities for secure communication, key management, and transaction signing.
Readme
Hardware Wallet Integration
This project provides tools and libraries for integrating with hardware wallets using smart card technology. It includes functionalities for secure communication, key management, and transaction signing.
Features
- Secure Communication: Establish secure channels with hardware wallets.
- Key Management: Generate, store, and manage cryptographic keys.
- Transaction Signing: Sign transactions securely using the hardware wallet.
Installation
To install the package, use npm or yarn:
pnpm install keycard-managerSystem Requirements
This package includes prebuilt native bindings for PC/SC communication. Ensure your system has the required libraries:
- Linux:
libpcsclite1,pcscddaemon running - macOS: None (PC/SC is native)
- Windows: None (WinSCard is native)
See the Getting Started guide for detailed setup instructions.
Usage
Keycard Manager can be used in your project as two different levels of abstraction: a high-level API for common operations and a low-level API for custom commands.
High-Level API
The high-level API provides convenient methods for common tasks such as connecting to the hardware wallet, generating keys, and signing transactions.
import { getKeycardWallet, getKeycardSigner } from 'keycard-manager';
const wallet = await getKeycardWallet();
const signer = getKeycardSigner(wallet);
// Example: Sign a message
const message = 'Hello, World!';
const signature = await signer.signMessage(message);
console.log('Signature:', signature);
// Example: Get address
const address = await wallet.getAddress();
console.log('Address:', address);
// Example: Disconnect
await wallet.disconnect();Low-Level API
The low-level API allows you to interact directly with the hardware wallet by sending predefined commands.
import {
factoryReset,
generateMnemonic,
getEthereumAddress,
getKeycardData,
deriveKey,
setup,
pair,
changePIN,
unpairOthers,
unblockPIN,
sign
} from 'keycard-manager';
// Example: Generate a new mnemonic
const mnemonic = await generateMnemonic();
console.log('Generated Mnemonic:', mnemonic);
// Example: Setup a new keycard
await setup(mnemonic);
const keycard = await getKeycardData();
console.log('Keycard Data:', keycard);
// Example: Get Ethereum address
const address = await getEthereumAddress();
console.log('Ethereum Address:', address);Documentation
For detailed guides and API references, please refer to the documentation.
