v3.9.0: feat() upgrade to node lts, feat() upgrade axios, jest and other dependencies, chore(): move some dependencies to optional

This commit is contained in:
tiagosiebler
2024-01-25 14:42:39 +00:00
parent 0c872173c0
commit 7fcf4b0bf4
14 changed files with 4013 additions and 4834 deletions

View File

@@ -66,6 +66,9 @@ interface SignedRequest<T> {
interface UnsignedRequest<T> {
originalParams: T;
paramsWithSign: T;
sign?: string;
timestamp?: number;
recvWindow?: number;
}
type SignMethod = 'v2auth' | 'v5auth';
@@ -187,6 +190,13 @@ export default abstract class BaseRestClient {
isPublicApi?: false | undefined,
): Promise<SignedRequest<TParams>>;
private async prepareSignParams<TParams extends SignedRequestContext = any>(
method: Method,
signMethod: SignMethod,
params?: TParams,
isPublicApi?: boolean,
): Promise<SignedRequest<TParams> | UnsignedRequest<TParams>>;
private async prepareSignParams<TParams extends SignedRequestContext = any>(
method: Method,
signMethod: SignMethod,
@@ -250,7 +260,7 @@ export default abstract class BaseRestClient {
isPublicApi,
);
const headers = {
const headers: AxiosRequestConfig['headers'] = {
'X-BAPI-SIGN-TYPE': 2,
'X-BAPI-API-KEY': this.key,
'X-BAPI-TIMESTAMP': signResult.timestamp,

View File

@@ -1,3 +1,4 @@
import { AxiosResponse } from 'axios';
import { APIRateLimit } from '../types';
import { WebsocketSucceededTopicSubscriptionConfirmationEvent } from '../types/ws-events/succeeded-topic-subscription-confirmation';
import { WebsocketTopicSubscriptionConfirmationEvent } from '../types/ws-events/topic-subscription-confirmation';
@@ -179,10 +180,13 @@ export type RestClientType =
/** Parse V5 rate limit response headers, if enabled */
export function parseRateLimitHeaders(
headers: Record<string, string | undefined> = {},
headers: AxiosResponse['headers'] | undefined,
throwOnFailedRateLimitParse: boolean,
): APIRateLimit | undefined {
try {
if (!headers || typeof headers !== 'object') {
return;
}
const remaining = headers['x-bapi-limit-status'];
const max = headers['x-bapi-limit'];
const resetAt = headers['x-bapi-limit-reset-timestamp'];