@liquidcommerce/elements-sdk 2.6.3 → 2.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  import type { ElementsEnv } from '@/enums';
2
+ import type { IAllConfigs } from '@/interfaces/configs/global.interface';
2
3
  export interface IAuthConfig {
3
4
  apiKey: string;
4
5
  env: ElementsEnv;
@@ -9,9 +10,8 @@ export interface IHttpRequestOptions {
9
10
  body?: any;
10
11
  }
11
12
  export interface IAuth {
12
- token: string;
13
- exp: number;
14
- type: 'ACCESS_TOKEN';
13
+ accessToken: string;
14
+ expiration: number;
15
15
  }
16
16
  export interface IApiResponseBase {
17
17
  message: string;
@@ -20,6 +20,10 @@ export interface IApiResponse<T> {
20
20
  message: string;
21
21
  data: T;
22
22
  }
23
+ export interface IAuthWithConfigs {
24
+ auth: IAuth;
25
+ configs: IAllConfigs;
26
+ }
23
27
  export declare class AuthClientService {
24
28
  private static readonly TOKEN_EXPIRATION_BUFFER_MS;
25
29
  private static readonly MAX_RETRIES;
@@ -33,23 +37,28 @@ export declare class AuthClientService {
33
37
  private accessToken;
34
38
  private tokenExpiration;
35
39
  private authPromise;
40
+ private refreshPromise;
36
41
  private constructor();
37
42
  static getInstance(config: IAuthConfig): AuthClientService;
43
+ authenticateAndGetConfigs(): Promise<{
44
+ success: boolean;
45
+ configs?: IAllConfigs;
46
+ }>;
38
47
  authenticate(): Promise<boolean>;
48
+ refreshToken(): Promise<boolean>;
49
+ get<T = any>(path: string, options?: IHttpRequestOptions): Promise<T>;
50
+ post<T = any>(path: string, options?: IHttpRequestOptions): Promise<T>;
39
51
  private performAuthentication;
40
- private isTokenExpired;
52
+ private performTokenRefresh;
41
53
  private request;
42
54
  private handleSuccessResponse;
43
55
  private handleAuthError;
44
56
  private handleErrorResponse;
57
+ private isTokenExpired;
58
+ private clearToken;
45
59
  private buildUrl;
46
60
  private buildHeaders;
47
61
  private getProxyHeaders;
48
62
  private isAuthError;
49
- private clearToken;
50
63
  private shouldRetryNonAuth;
51
- private logNetworkError;
52
- private createNetworkError;
53
- get<T = any>(path: string, options?: IHttpRequestOptions): Promise<T>;
54
- post<T = any>(path: string, options?: IHttpRequestOptions): Promise<T>;
55
64
  }
@@ -37,7 +37,6 @@ export declare class HttpClientService {
37
37
  private logNetworkError;
38
38
  private diagnosePossibleCauses;
39
39
  private enhanceError;
40
- private sanitizeHeaders;
41
40
  private delay;
42
41
  private getFetchImplementation;
43
42
  private fetchAdapter;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "LiquidCommerce Elements SDK",
4
4
  "license": "UNLICENSED",
5
5
  "author": "LiquidCommerce Team",
6
- "version": "2.6.3",
6
+ "version": "2.6.4",
7
7
  "homepage": "https://docs.liquidcommerce.co/elements-sdk",
8
8
  "repository": {
9
9
  "type": "git",