@akad/sdk 1.0.22 → 1.0.24

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
@@ -9,20 +9,39 @@ export interface Config {
9
9
  refreshTokenApiVersion?: string;
10
10
  refreshTokenEndpointPath?: string;
11
11
  hasTokenManager?: boolean;
12
+ digitalRefresh?: {
13
+ url: string;
14
+ clientId: string;
15
+ clientSecret: string;
16
+ };
17
+ refreshLogoutUrl?: string;
12
18
  responseInterceptor?: {
13
19
  onFulfilled: (value: AxiosResponse) => AxiosResponse | Promise<typeof value>;
14
20
  onReject: (error: AxiosError) => Promise<typeof error> | Promise<never>;
15
21
  };
16
22
  }
23
+ /**
24
+ * Supported data types for request body
25
+ */
26
+ export type RequestData = string | object | FormData;
27
+ /**
28
+ * Options for making HTTP requests
29
+ */
30
+ export interface RequestOptions {
31
+ contentType?: string;
32
+ data?: RequestData;
33
+ headers?: Record<string, string>;
34
+ method?: string;
35
+ responseType?: ResponseType;
36
+ withCredentials?: boolean;
37
+ }
17
38
  export declare const createBase: (config: Config) => {
18
- request: <T>(endpoint: string, options?: {
19
- method: string;
20
- data: string;
21
- contentType?: string;
22
- responseType?: ResponseType;
23
- headers?: Record<string, string>;
24
- }) => Promise<T>;
39
+ axiosClient: import('axios').AxiosInstance;
25
40
  getAccessToken: () => string | null;
26
41
  setTokens: (tokens: TokenResponse) => void;
27
42
  clearTokens: () => void;
43
+ request: <T>(endpoint: string, options?: RequestOptions & {
44
+ method: string;
45
+ data: RequestData;
46
+ }) => Promise<T>;
28
47
  };
@@ -1,5 +1,5 @@
1
1
  import { Config } from '../base';
2
2
 
3
3
  export declare const createEndorsement: (config: Config) => {
4
- putEndorsement: <ReqPayload = unknown, ResPayload = unknown>(data: ReqPayload, attachments?: File | File[]) => Promise<ResPayload>;
4
+ putEndorsement: <ResPayload = unknown>(formData: FormData) => Promise<ResPayload>;
5
5
  };
@@ -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,8 +13,10 @@ export interface QueuedRequest {
12
13
  }
13
14
  export interface TokenRefreshConfig {
14
15
  baseUrl: string;
15
- refreshTokenEndpointPath: string;
16
- onRefreshToken: (refreshToken: string) => Promise<TokenResponse>;
16
+ refreshTokenEndpointPath?: string;
17
+ onRefreshToken: (refreshToken: string | null) => Promise<TokenResponse>;
18
+ refreshLogoutUrl?: string;
19
+ digitalRefreshUrl?: string;
17
20
  }
18
21
  export declare const createTokenRefreshManager: (config: TokenRefreshConfig) => {
19
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>;
@@ -38,7 +40,7 @@ export default function sdkInitialize(config: Config): {
38
40
  getAllBrokerages: (name: string) => Promise<import('./broker/types').BrokerageFirmType>;
39
41
  };
40
42
  endorsement: {
41
- putEndorsement: <ReqPayload = unknown, ResPayload = unknown>(data: ReqPayload, attachments?: File | File[] | undefined) => Promise<ResPayload>;
43
+ putEndorsement: <ResPayload = unknown>(formData: FormData) => Promise<ResPayload>;
42
44
  };
43
45
  plugin: {
44
46
  getCnpjStatus: (cnpj: string, brokerageIdentity?: string | undefined, isBrokerageDefinedAtStart?: boolean | undefined) => Promise<import('./plugin/types').CnpjStatus>;
@@ -53,15 +55,13 @@ export default function sdkInitialize(config: Config): {
53
55
  getSubscriber: (cnpj: string) => Promise<import('./subscriber/types').getSubscriberType>;
54
56
  };
55
57
  base: {
56
- request: <T>(endpoint: string, options?: {
57
- method: string;
58
- data: string;
59
- contentType?: string | undefined;
60
- responseType?: import('axios').ResponseType | undefined;
61
- headers?: Record<string, string> | undefined;
62
- } | undefined) => Promise<T>;
58
+ axiosClient: import('axios').AxiosInstance;
63
59
  getAccessToken: () => string | null;
64
60
  setTokens: (tokens: import('./helpers/TokenRefreshManager').TokenResponse) => void;
65
61
  clearTokens: () => void;
62
+ request: <T>(endpoint: string, options?: (import('./base').RequestOptions & {
63
+ method: string;
64
+ data: import('./base').RequestData;
65
+ }) | undefined) => Promise<T>;
66
66
  };
67
67
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akad/sdk",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "main": "./ts-lib.umd.cjs",
5
5
  "module": "./ts-lib.js",
6
6
  "exports": {