@akad/sdk 1.0.21 → 1.0.23

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.
package/auth/index.d.ts CHANGED
@@ -1,7 +1,15 @@
1
+ import { AxiosInstance } from 'axios';
1
2
  import { Config } from '../base';
2
3
  import { loginType, getTokenType } from './types';
3
4
 
5
+ export declare const postToken: (digitalRefresh: {
6
+ url: string;
7
+ clientId: string;
8
+ clientSecret: string;
9
+ }, headers: Record<string, string> | undefined, axiosClient: AxiosInstance) => Promise<getTokenType>;
4
10
  export declare const createAuth: (config: Config) => {
5
11
  postLogin: (data: loginType) => Promise<loginType>;
6
12
  getToken: (exchangeCode: string) => Promise<getTokenType>;
13
+ postToken: (() => Promise<getTokenType>) | undefined;
14
+ postLogout: () => Promise<void>;
7
15
  };
package/auth/types.d.ts CHANGED
@@ -9,5 +9,6 @@ export declare type loginType = {
9
9
  expiresIn?: number;
10
10
  };
11
11
  export declare type getTokenType = {
12
- accessToken: string;
12
+ accessToken?: string;
13
+ access_token?: string;
13
14
  };
package/base.d.ts CHANGED
@@ -2,26 +2,35 @@ import { AxiosError, AxiosResponse, ResponseType } from 'axios';
2
2
  import { TokenResponse } from './helpers/TokenRefreshManager';
3
3
 
4
4
  export interface Config {
5
- apiVersion: string;
6
- baseUrl?: string;
7
- productCode: string;
5
+ apiVersion?: string;
6
+ baseUrl: string;
7
+ productCode?: string;
8
8
  headers?: Record<string, string>;
9
9
  refreshTokenApiVersion?: string;
10
10
  refreshTokenEndpointPath?: string;
11
+ hasTokenManager?: boolean;
12
+ digitalRefresh?: {
13
+ url: string;
14
+ clientId: string;
15
+ clientSecret: string;
16
+ };
17
+ refreshLogoutUrl?: string;
11
18
  responseInterceptor?: {
12
19
  onFulfilled: (value: AxiosResponse) => AxiosResponse | Promise<typeof value>;
13
20
  onReject: (error: AxiosError) => Promise<typeof error> | Promise<never>;
14
21
  };
15
22
  }
16
23
  export declare const createBase: (config: Config) => {
24
+ axiosClient: import('axios').AxiosInstance;
25
+ getAccessToken: () => string | null;
26
+ setTokens: (tokens: TokenResponse) => void;
27
+ clearTokens: () => void;
17
28
  request: <T>(endpoint: string, options?: {
18
29
  method: string;
19
30
  data: string;
20
31
  contentType?: string;
21
32
  responseType?: ResponseType;
22
33
  headers?: Record<string, string>;
34
+ withCredentials?: boolean;
23
35
  }) => Promise<T>;
24
- getAccessToken: () => string | null;
25
- setTokens: (tokens: TokenResponse) => void;
26
- clearTokens: () => void;
27
36
  };
@@ -1,9 +1,10 @@
1
1
  import { AxiosError, AxiosRequestConfig } from 'axios';
2
2
 
3
3
  export interface TokenResponse {
4
- accessToken: string;
5
- refreshToken: string;
6
- expiresIn: number;
4
+ accessToken?: string;
5
+ refreshToken?: string;
6
+ access_token?: string;
7
+ expiresIn?: number;
7
8
  }
8
9
  export interface QueuedRequest {
9
10
  resolve: (value: AxiosRequestConfig) => void;
@@ -12,9 +13,10 @@ export interface QueuedRequest {
12
13
  }
13
14
  export interface TokenRefreshConfig {
14
15
  baseUrl: string;
15
- apiVersion: string;
16
- refreshTokenEndpointPath: string;
17
- onRefreshToken: (refreshToken: string) => Promise<TokenResponse>;
16
+ refreshTokenEndpointPath?: string;
17
+ onRefreshToken: (refreshToken: string | null) => Promise<TokenResponse>;
18
+ refreshLogoutUrl?: string;
19
+ digitalRefreshUrl?: string;
18
20
  }
19
21
  export declare const createTokenRefreshManager: (config: TokenRefreshConfig) => {
20
22
  getAccessToken: () => string | null;
package/main.d.ts CHANGED
@@ -4,6 +4,8 @@ export default function sdkInitialize(config: Config): {
4
4
  auth: {
5
5
  postLogin: (data: import('./auth/types').loginType) => Promise<import('./auth/types').loginType>;
6
6
  getToken: (exchangeCode: string) => Promise<import('./auth/types').getTokenType>;
7
+ postToken: (() => Promise<import('./auth/types').getTokenType>) | undefined;
8
+ postLogout: () => Promise<void>;
7
9
  };
8
10
  authAkad: {
9
11
  signUp: (data: import('./authAkad/types').SignUpPayload) => Promise<import('./authAkad/types').SignUpResponse>;
@@ -53,15 +55,17 @@ export default function sdkInitialize(config: Config): {
53
55
  getSubscriber: (cnpj: string) => Promise<import('./subscriber/types').getSubscriberType>;
54
56
  };
55
57
  base: {
58
+ axiosClient: import('axios').AxiosInstance;
59
+ getAccessToken: () => string | null;
60
+ setTokens: (tokens: import('./helpers/TokenRefreshManager').TokenResponse) => void;
61
+ clearTokens: () => void;
56
62
  request: <T>(endpoint: string, options?: {
57
63
  method: string;
58
64
  data: string;
59
65
  contentType?: string | undefined;
60
66
  responseType?: import('axios').ResponseType | undefined;
61
67
  headers?: Record<string, string> | undefined;
68
+ withCredentials?: boolean | undefined;
62
69
  } | undefined) => Promise<T>;
63
- getAccessToken: () => string | null;
64
- setTokens: (tokens: import('./helpers/TokenRefreshManager').TokenResponse) => void;
65
- clearTokens: () => void;
66
70
  };
67
71
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akad/sdk",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "main": "./ts-lib.umd.cjs",
5
5
  "module": "./ts-lib.js",
6
6
  "exports": {