bybit-api
Version:
Complete & robust Node.js SDK for Bybit's REST APIs and WebSockets, with TypeScript & strong end to end tests.
21 lines (20 loc) • 965 B
TypeScript
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>;
export {};