run linter
This commit is contained in:
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "bybit-api",
|
"name": "bybit-api",
|
||||||
"version": "2.1.10",
|
"version": "2.2.0-beta.1",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "bybit-api",
|
"name": "bybit-api",
|
||||||
"version": "2.1.10",
|
"version": "2.2.0-beta.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.21.0",
|
"axios": "^0.21.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "bybit-api",
|
"name": "bybit-api",
|
||||||
"version": "2.2.0",
|
"version": "2.2.0-beta.1",
|
||||||
"description": "Node.js connector for Bybit's REST APIs and WebSockets, with TypeScript & integration tests.",
|
"description": "Node.js connector for Bybit's REST APIs and WebSockets, with TypeScript & integration tests.",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"types": "lib/index.d.ts",
|
"types": "lib/index.d.ts",
|
||||||
|
|||||||
@@ -18,5 +18,5 @@ export const DefaultLogger = {
|
|||||||
},
|
},
|
||||||
error: (...params: LogParams): void => {
|
error: (...params: LogParams): void => {
|
||||||
console.error(params);
|
console.error(params);
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
import axios, { AxiosRequestConfig, AxiosResponse, Method } from 'axios';
|
import axios, { AxiosRequestConfig, AxiosResponse, Method } from 'axios';
|
||||||
import { APIResponse, APIResponseWithTime } from '../types/shared';
|
|
||||||
|
|
||||||
import { signMessage } from './node-support';
|
import { signMessage } from './node-support';
|
||||||
import {
|
import {
|
||||||
@@ -36,19 +35,12 @@ interface SignedRequest<T> {
|
|||||||
|
|
||||||
export default abstract class BaseRestClient {
|
export default abstract class BaseRestClient {
|
||||||
private timeOffset: number | null;
|
private timeOffset: number | null;
|
||||||
|
|
||||||
private syncTimePromise: null | Promise<any>;
|
private syncTimePromise: null | Promise<any>;
|
||||||
|
|
||||||
private options: RestClientOptions;
|
private options: RestClientOptions;
|
||||||
|
|
||||||
private baseUrl: string;
|
private baseUrl: string;
|
||||||
|
|
||||||
private globalRequestOptions: AxiosRequestConfig;
|
private globalRequestOptions: AxiosRequestConfig;
|
||||||
|
|
||||||
private key: string | undefined;
|
private key: string | undefined;
|
||||||
|
|
||||||
private secret: string | undefined;
|
private secret: string | undefined;
|
||||||
|
|
||||||
private clientType: RestClientType;
|
private clientType: RestClientType;
|
||||||
|
|
||||||
/** Function that calls exchange API to query & resolve server time, used by time sync */
|
/** Function that calls exchange API to query & resolve server time, used by time sync */
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
|
export async function signMessage(
|
||||||
export async function signMessage(message: string, secret: string): Promise<string> {
|
message: string,
|
||||||
|
secret: string
|
||||||
|
): Promise<string> {
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
const key = await window.crypto.subtle.importKey(
|
const key = await window.crypto.subtle.importKey(
|
||||||
'raw',
|
'raw',
|
||||||
@@ -9,10 +11,15 @@ export async function signMessage(message: string, secret: string): Promise<stri
|
|||||||
['sign']
|
['sign']
|
||||||
);
|
);
|
||||||
|
|
||||||
const signature = await window.crypto.subtle.sign('HMAC', key, encoder.encode(message));
|
const signature = await window.crypto.subtle.sign(
|
||||||
|
'HMAC',
|
||||||
|
key,
|
||||||
|
encoder.encode(message)
|
||||||
|
);
|
||||||
|
|
||||||
return Array.prototype.map.call(
|
return Array.prototype.map
|
||||||
new Uint8Array(signature),
|
.call(new Uint8Array(signature), (x: any) =>
|
||||||
(x: any) => ('00'+x.toString(16)).slice(-2)
|
('00' + x.toString(16)).slice(-2)
|
||||||
).join('');
|
)
|
||||||
};
|
.join('');
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user