initial commit, add bitget rest api and websockets connector

This commit is contained in:
Tiago Siebler
2022-10-09 23:01:08 +01:00
commit 0f75ded05c
59 changed files with 15246 additions and 0 deletions

23
src/util/node-support.ts Normal file
View File

@@ -0,0 +1,23 @@
import { createHmac } from 'crypto';
/** This is async because the browser version uses a promise (browser-support) */
export async function signMessage(
message: string,
secret: string,
method: 'hex' | 'base64'
): Promise<string> {
const hmac = createHmac('sha256', secret).update(message);
switch (method) {
case 'hex': {
return hmac.digest('hex');
}
case 'base64': {
return hmac.digest().toString('base64');
}
default: {
((x: never) => {})(method);
throw new Error(`Unhandled sign method: ${method}`);
}
}
}