UNPKG

bybit-api

Version:

Complete & robust Node.js SDK for Bybit's REST APIs and WebSockets, with TypeScript & strong end to end tests.

31 lines (30 loc) 1.58 kB
export type SignEncodeMethod = 'hex' | 'base64'; export type SignAlgorithm = 'SHA-256' | 'SHA-512'; type KeyType = 'HMAC' | 'RSASSA-PKCS1-v1_5'; /** * Determine the key type based on the secret format * RSA keys contain "-----BEGIN PRIVATE KEY-----" or "-----BEGIN RSA PRIVATE KEY-----" * HMAC keys are plain strings */ export declare function getSignKeyType(secret: string): KeyType; /** * Similar to node crypto's `createHash()` function */ export declare function hashMessage(message: string, method: SignEncodeMethod, algorithm: SignAlgorithm): Promise<string>; /** * Sign a message, with a secret, using the Web Crypto API * Automatically detects key type (HMAC vs RSA) and uses appropriate signing method * RSA keys use base64 encoding, HMAC keys use hex encoding (for backwards compatibility) */ export declare function signMessage(message: string, secret: string, method?: SignEncodeMethod, algorithm?: SignAlgorithm): Promise<string>; /** * Sign binary data (Buffer/Uint8Array) with a secret, using the Web Crypto API * Automatically detects key type (HMAC vs RSA) and uses appropriate signing method * RSA keys use base64 encoding, HMAC keys use hex encoding (for backwards compatibility) * * Note: This function works in both Node.js and browser environments. * In Node.js, you can pass a Buffer. In browsers, pass Uint8Array. */ export declare function signBinaryData(data: Buffer | Uint8Array, secret: string, method?: SignEncodeMethod, algorithm?: SignAlgorithm): Promise<string>; export declare function checkWebCryptoAPISupported(): void; export {};