chore(): run linter, after fixing config

This commit is contained in:
tiagosiebler
2024-11-08 13:11:24 +00:00
parent 7023b0aa75
commit 9f20a00ecc
14 changed files with 76 additions and 50 deletions

View File

@@ -71,7 +71,7 @@ export default class WsStore {
if (this.hasExistingActiveConnection(key)) {
this.logger.warning(
'WsStore setConnection() overwriting existing open connection: ',
this.getWs(key)
this.getWs(key),
);
}
this.wsState[key] = {
@@ -86,7 +86,7 @@ export default class WsStore {
const ws = this.getWs(key);
this.logger.warning(
'WsStore deleting state for connection still open: ',
ws
ws,
);
ws?.close();
}
@@ -107,7 +107,7 @@ export default class WsStore {
if (this.isWsOpen(key)) {
this.logger.warning(
'WsStore setConnection() overwriting existing open connection: ',
this.getWs(key)
this.getWs(key),
);
}
this.get(key, true)!.ws = wsConnection;

View File

@@ -1,6 +1,6 @@
export async function signMessage(
message: string,
secret: string
secret: string,
): Promise<string> {
const encoder = new TextEncoder();
// eslint-disable-next-line no-undef
@@ -9,21 +9,21 @@ export async function signMessage(
encoder.encode(secret),
{ name: 'HMAC', hash: { name: 'SHA-256' } },
false,
['sign']
['sign'],
);
// eslint-disable-next-line no-undef
const signature = await window.crypto.subtle.sign(
'HMAC',
key,
encoder.encode(message)
encoder.encode(message),
);
return Array.prototype.map
.call(
new Uint8Array(signature),
(x: { toString: (arg0: number) => string }) =>
('00' + x.toString(16)).slice(-2)
('00' + x.toString(16)).slice(-2),
)
.join('');
}

View File

@@ -3,7 +3,7 @@ import { createHmac } from 'crypto';
/** This is async because the browser version uses a promise (browser-support) */
export async function signMessage(
message: string,
secret: string
secret: string,
): Promise<string> {
return createHmac('sha256', secret).update(message).digest('hex');
}

View File

@@ -2,7 +2,12 @@
* Use type guards to narrow down types with minimal efforts.
*/
import { WSAccountOrderEventV5, WSExecutionEventV5, WSOrderbookEventV5, WSPositionEventV5 } from '../types/websocket.events';
import {
WSAccountOrderEventV5,
WSExecutionEventV5,
WSOrderbookEventV5,
WSPositionEventV5,
} from '../types/websocket.events';
/**
* Type guard to detect a V5 orderbook event (delta & snapshots)
@@ -30,7 +35,7 @@ export function isWsOrderbookEventV5(
/**
* Type guard to detect a V5 position event.
*
*
* @param event
* @returns
*/
@@ -86,4 +91,4 @@ export function isWsExecutionEventV5(
}
return event['topic'] === 'execution';
}
}