mirror of
https://github.com/xtr-dev/rondevu-client.git
synced 2025-12-13 20:33:25 +00:00
Adds CryptoAdapter interface with WebCryptoAdapter (browser) and
NodeCryptoAdapter (Node.js 19+) implementations.
Changes:
- Created crypto-adapter.ts interface
- Created web-crypto-adapter.ts for browser environments
- Created node-crypto-adapter.ts for Node.js environments
- Updated RondevuAPI to accept optional CryptoAdapter
- Updated Rondevu class to pass crypto adapter through
- Exported adapters and types in index.ts
- Updated README with platform support documentation
- Bumped version to 0.15.0
This allows the client library to work in both browser and Node.js
environments by providing platform-specific crypto implementations.
Example usage in Node.js:
import { Rondevu, NodeCryptoAdapter } from '@xtr-dev/rondevu-client'
const rondevu = new Rondevu({
apiUrl: 'https://api.ronde.vu',
cryptoAdapter: new NodeCryptoAdapter()
})
🤖 Generated with Claude Code
https://claude.com/claude-code
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
49 lines
1.0 KiB
TypeScript
49 lines
1.0 KiB
TypeScript
/**
|
|
* Crypto adapter interface for platform-independent cryptographic operations
|
|
*/
|
|
|
|
export interface Keypair {
|
|
publicKey: string
|
|
privateKey: string
|
|
}
|
|
|
|
/**
|
|
* Platform-independent crypto adapter interface
|
|
* Implementations provide platform-specific crypto operations
|
|
*/
|
|
export interface CryptoAdapter {
|
|
/**
|
|
* Generate an Ed25519 keypair
|
|
*/
|
|
generateKeypair(): Promise<Keypair>
|
|
|
|
/**
|
|
* Sign a message with an Ed25519 private key
|
|
*/
|
|
signMessage(message: string, privateKeyBase64: string): Promise<string>
|
|
|
|
/**
|
|
* Verify an Ed25519 signature
|
|
*/
|
|
verifySignature(
|
|
message: string,
|
|
signatureBase64: string,
|
|
publicKeyBase64: string
|
|
): Promise<boolean>
|
|
|
|
/**
|
|
* Convert Uint8Array to base64 string
|
|
*/
|
|
bytesToBase64(bytes: Uint8Array): string
|
|
|
|
/**
|
|
* Convert base64 string to Uint8Array
|
|
*/
|
|
base64ToBytes(base64: string): Uint8Array
|
|
|
|
/**
|
|
* Generate random bytes
|
|
*/
|
|
randomBytes(length: number): Uint8Array
|
|
}
|