@accelbyte/sdk 3.0.8 → 4.0.1

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/dist/index.d.ts CHANGED
@@ -1,48 +1,13 @@
1
- import { InternalAxiosRequestConfig, AxiosResponse, AxiosError, AxiosRequestConfig, AxiosInstance, Method } from 'axios';
2
- import { z, ZodError } from 'zod';
1
+ import { AxiosRequestConfig, InternalAxiosRequestConfig, AxiosResponse, AxiosInstance, AxiosError } from 'axios';
2
+ import { ZodTypeAny, z, ZodError } from 'zod';
3
3
 
4
- declare type EjectId = number;
5
- declare type RequestInterceptor = (config: InternalAxiosRequestConfig) => InternalAxiosRequestConfig | Promise<InternalAxiosRequestConfig>;
6
- declare type ResponseInterceptor = (response: AxiosResponse) => AxiosResponse | Promise<AxiosResponse>;
7
- declare type ErrorInterceptor$1 = (error: AxiosError) => Promise<unknown> | unknown;
8
- declare const injectRequestInterceptors: (requestInterceptor: RequestInterceptor, errorInterceptor: ErrorInterceptor$1) => EjectId;
9
- declare const injectResponseInterceptors: (responseInterceptor: ResponseInterceptor, errorInterceptor: ErrorInterceptor$1) => EjectId;
10
- declare class Network {
11
- static create(...configs: AxiosRequestConfig[]): AxiosInstance;
12
- static withBearerToken(accessToken: string, config?: AxiosRequestConfig): AxiosInstance;
13
- static setDeviceTokenCookie: () => void;
14
- static removeDeviceTokenCookie: () => void;
15
- static getFormUrlEncodedData: (data: any) => URLSearchParams;
16
- }
17
-
18
- /**
19
- * This interface is used to override the values set when Accelbyte.SDK was initialized.
20
- * For example, you can override the headers in a certain API call by passing `config.headers`:
21
- *
22
- * ```ts
23
- * Platform.ItemApi(sdk, {
24
- * config: {
25
- * headers: {
26
- * Authorization: "Bearer ..."
27
- * }
28
- * }
29
- * }).getLocale_ByItemId(itemId)
30
- * ```
31
- */
32
- interface ApiArgs {
33
- config?: SDKRequestConfig;
34
- namespace?: string;
35
- }
36
- interface CustomInterceptors {
37
- request: RequestInterceptor;
38
- response: ResponseInterceptor;
39
- error: ErrorInterceptor$1;
40
- }
41
- declare type ApiError = {
42
- errorCode: number | string;
43
- errorMessage: string;
4
+ type MakeOptional<Type, UnionKeys extends keyof Type> = Omit<Type, UnionKeys> & Partial<Pick<Type, UnionKeys>>;
5
+ type MakeRequired<T, K extends keyof T> = T & {
6
+ [P in K]-?: T[P];
44
7
  };
45
- interface SDKOptions {
8
+ declare function isType<T extends ZodTypeAny>(schema: T, data: unknown): data is z.infer<T>;
9
+
10
+ interface CoreConfig {
46
11
  /**
47
12
  * The client ID for the SDK. This value is retrieved from Admin Portal, OAuth Clients.
48
13
  */
@@ -61,81 +26,99 @@ interface SDKOptions {
61
26
  */
62
27
  namespace: string;
63
28
  /**
64
- * Custom interceptors for axios. If not provided, by default the SDK will send a POST request
65
- * to `/iam/v3/oauth/token` whenever there is a `401 Unauthenticated` response status.
29
+ * When "false" is provided, the SDK bypasses Zod Schema Validation.
30
+ * Default is "true".
66
31
  */
67
- customInterceptors?: CustomInterceptors;
32
+ useSchemaValidation: boolean;
33
+ }
34
+ interface AxiosConfig {
35
+ interceptors?: Interceptor[];
36
+ request?: AxiosRequestConfig;
37
+ }
38
+ type Interceptor = {
39
+ type: 'request';
40
+ name: string;
41
+ onRequest?: (config: InternalAxiosRequestConfig) => InternalAxiosRequestConfig | Promise<InternalAxiosRequestConfig>;
42
+ onError?: (error: unknown) => unknown;
43
+ } | {
44
+ type: 'response';
45
+ name: string;
46
+ onSuccess?: (response: AxiosResponse<unknown>) => AxiosResponse<unknown>;
47
+ onError?: (error: unknown) => unknown;
48
+ };
49
+ interface SdkConstructorParam {
50
+ coreConfig: MakeOptional<CoreConfig, 'useSchemaValidation'>;
51
+ axiosConfig?: AxiosConfig;
52
+ }
53
+ interface SdkSetConfigParam {
54
+ coreConfig?: Partial<CoreConfig>;
55
+ axiosConfig?: AxiosConfig;
56
+ }
57
+ type ApiError = {
58
+ errorCode: number | string;
59
+ errorMessage: string;
60
+ };
61
+ type TokenConfig = {
62
+ accessToken?: string;
63
+ refreshToken?: string | null;
64
+ };
65
+
66
+ declare const AccelByte: {
67
+ SDK: (param: SdkConstructorParam) => AccelByteSDK;
68
+ };
69
+ declare class AccelByteSDK {
70
+ private coreConfig;
71
+ private axiosConfig;
72
+ private axiosInstance;
73
+ private token;
74
+ constructor({ coreConfig, axiosConfig }: SdkConstructorParam);
75
+ private createAxiosInstance;
68
76
  /**
69
- * Use when in internal Accelbyte network. Must be used in server only environment.
70
- * When value is true, it will call `http://{service-name}/{path}` instead of `baseURL`
77
+ * Assembles and returns the current Axios instance along with core and Axios configurations.
71
78
  */
72
- useInternalNetwork?: boolean;
79
+ assembly(): {
80
+ axiosInstance: AxiosInstance;
81
+ coreConfig: CoreConfig;
82
+ axiosConfig: MakeRequired<AxiosConfig, "request">;
83
+ };
73
84
  /**
74
- * default is "true". When "false" is provided, the SDK bypasses Zod Schema Validation
85
+ * Creates a new instance of AccelByteSDK with a shallow copy of the current configurations.
86
+ * Optionally allows excluding interceptors.
87
+ * @param {boolean} [opts.interceptors] - Whether to include interceptors in the clone. Default is true.
88
+ * @returns {AccelByteSDK} A new instance of AccelByteSDK with the cloned configuration.
75
89
  */
76
- useSchemaValidation?: boolean;
77
- }
78
- interface SDKEvents {
90
+ clone(opts?: {
91
+ interceptors?: boolean;
92
+ }): AccelByteSDK;
79
93
  /**
80
- * The callback fired when the session expires.
94
+ * Adds interceptors to the current Axios configuration.
81
95
  */
82
- onSessionExpired?: () => void;
96
+ addInterceptors(interceptors: Interceptor[]): AccelByteSDK;
83
97
  /**
84
- * The callback fired when user session is retrieved, which can be from
85
- * logging in, or refreshing access token.
98
+ * Removes interceptors from the Axios configuration. Can remove all interceptors or filter specific ones.
99
+ * @param {function} [filterCallback] - Optional filter function to remove specific interceptors.
86
100
  */
87
- onGetUserSession?: (accessToken: string, refreshToken: string) => void;
101
+ removeInterceptors(): AccelByteSDK;
102
+ removeInterceptors(filterCallback: (interceptor: Interceptor) => boolean): AccelByteSDK;
88
103
  /**
89
- * The callback fired when there are legal changes, usually related to user age.
90
- * [Docs reference](https://docs.accelbyte.io/gaming-services/knowledge-base/api-endpoints-error-codes/#10130---user-under-age).
104
+ * Updates the SDK's core and Axios configurations.
105
+ * Merges the provided configurations with the current ones.
91
106
  */
92
- onUserEligibilityChange?: () => void;
107
+ setConfig({ coreConfig, axiosConfig }: SdkSetConfigParam): this;
93
108
  /**
94
- * The callback fired whenever there is a 429 response error (request being throttled/rate-limited).
109
+ * Set accessToken and refreshToken and updates the Axios request headers to use Bearer authentication.
95
110
  */
96
- onTooManyRequest?: (error: AxiosError) => void;
111
+ setToken(token: TokenConfig): void;
97
112
  /**
98
- * The callback fired whenever there is a non-specific response error.
113
+ * Removes the currently set token.
99
114
  */
100
- onError?: (error: AxiosError) => void;
101
- }
102
- interface SDKRequestConfig<D = any> {
103
- url?: string;
104
- method?: Method | string;
105
- baseURL?: string;
106
- headers?: Record<string, string | number | boolean>;
107
- params?: any;
108
- paramsSerializer?: (params: any) => string;
109
- data?: D;
110
- timeout?: number;
111
- timeoutErrorMessage?: string;
112
- signal?: AbortSignal;
113
- withCredentials?: boolean;
115
+ removeToken(): void;
116
+ /**
117
+ * Retrieves the current token configuration.
118
+ */
119
+ getToken(): TokenConfig;
114
120
  }
115
121
 
116
- /**
117
- * This is the main SDK
118
- */
119
- interface AccelbyteSDK {
120
- refreshTokens: (accessToken: string | undefined | null, refreshToken?: string | undefined | null) => void;
121
- assembly: () => {
122
- config: SDKRequestConfig<any>;
123
- namespace: string;
124
- clientId: string;
125
- redirectURI: string;
126
- baseURL: string;
127
- refreshToken?: string;
128
- useSchemaValidation?: boolean;
129
- };
130
- }
131
- declare const Accelbyte: {
132
- SDK: ({ options, config, onEvents }: {
133
- options: SDKOptions;
134
- config?: SDKRequestConfig<any> | undefined;
135
- onEvents?: SDKEvents | undefined;
136
- }) => AccelbyteSDK;
137
- };
138
-
139
122
  declare enum IamErrorCode {
140
123
  InternalServerError = 20000,
141
124
  UnauthorizedAccess = 20001,
@@ -159,117 +142,34 @@ declare const ERROR_CODE_LINK_DELETION_ACCOUNT = 10135;
159
142
  declare const ERROR_CODE_TOKEN_EXPIRED = 10196;
160
143
  declare const ERROR_USER_BANNED = 10134;
161
144
 
162
- declare class ApiUtils {
163
- static mergedConfigs: (config: SDKRequestConfig, overrides?: ApiArgs | undefined) => SDKRequestConfig;
164
- static is4xxError: (error: unknown) => boolean;
165
- }
166
-
167
- declare class BrowserHelper {
168
- static isOnBrowser: () => false | Document;
169
- }
170
-
171
- declare class CodeGenUtil {
172
- /**
173
- * Returns a hash code from a string
174
- * @param {String} str The string to hash.
175
- * @return {Number} A 32bit integer
176
- * @see http://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/
177
- */
178
- static hashCode(str: string): number;
179
- static getFormUrlEncodedData: (data: Record<string, any>) => URLSearchParams;
180
- }
181
-
182
- declare class DesktopChecker {
183
- private static desktopApp;
184
- static isDesktopApp(): boolean;
185
- private static isInIframe;
186
- private static isElectron;
187
- }
188
-
189
- declare class UrlHelper {
190
- static isCompleteURLString: (urlString: string) => boolean;
191
- static trimSlashFromStringEnd(pathString: string): string;
192
- static trimSlashFromStringStart(pathString: string): string;
193
- static trimSlashFromStringEdges(pathString: string): string;
194
- static combinePaths(...paths: string[]): string;
195
- static combineURLPaths(urlString: string, ...paths: string[]): string;
196
- static removeQueryParam(fullUrlString: string, param: string): string;
197
- }
198
-
199
- declare class RefreshSession {
200
- static KEY: string;
201
- static isLocked: () => boolean;
202
- static lock: (expiry: number) => void;
203
- static unlock: () => void;
204
- static sleepAsync: (timeInMs: number) => Promise<unknown>;
205
- static isBearerAuth: (config?: AxiosRequestConfig<any> | undefined) => boolean;
206
- }
207
-
208
- declare type IResponseError = Error | AxiosError;
209
- declare type IDataStatus<D> = {
210
- data: D;
211
- status: number;
212
- };
213
- declare type IResponse<D> = {
214
- response: IDataStatus<D>;
215
- error: null;
216
- } | {
217
- response: null;
218
- error: IResponseError;
219
- };
220
- declare class Validate {
221
- static validateOrReturnResponse<D>(useSchemaValidation: boolean, networkCall: () => Promise<AxiosResponse<D>>, Codec: z.ZodType<D>, modelName: string): Promise<IResponse<D>>;
222
- static responseType<D>(networkCall: () => Promise<AxiosResponse<D>>, Codec: z.ZodType<D>, modelName: string): Promise<IResponse<D>>;
223
- static unsafeResponse<D>(networkCall: () => Promise<AxiosResponse<D>>): Promise<IResponse<D>>;
224
- static safeParse<D>(data: unknown, Codec: z.ZodType<D>): D | null;
225
- }
226
- declare class DecodeError extends Error {
227
- constructor({ error, response, modelName }: {
228
- error: ZodError;
229
- response: AxiosResponse;
230
- modelName: string;
231
- });
232
- }
233
-
234
- declare class SdkDevice {
235
- static ID_KEY: string;
236
- static TYPE: {
237
- MOBILE: string;
238
- DESKTOP: string;
239
- };
240
- static getType: () => string;
241
- static generateUUID: () => string;
242
- static getDeviceId: () => string;
243
- }
244
-
245
145
  declare const TokenWithDeviceCookieResponseV3: z.ZodObject<{
246
146
  access_token: z.ZodString;
247
- auth_trust_id: z.ZodNullable<z.ZodOptional<z.ZodString>>;
248
- bans: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
147
+ auth_trust_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
148
+ bans: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
249
149
  ban: z.ZodString;
250
- disabledDate: z.ZodNullable<z.ZodOptional<z.ZodString>>;
150
+ disabledDate: z.ZodOptional<z.ZodNullable<z.ZodString>>;
251
151
  enabled: z.ZodBoolean;
252
152
  endDate: z.ZodString;
253
153
  targetedNamespace: z.ZodString;
254
154
  }, "strip", z.ZodTypeAny, {
255
- disabledDate?: string | null | undefined;
256
155
  ban: string;
257
156
  enabled: boolean;
258
157
  endDate: string;
259
158
  targetedNamespace: string;
260
- }, {
261
159
  disabledDate?: string | null | undefined;
160
+ }, {
262
161
  ban: string;
263
162
  enabled: boolean;
264
163
  endDate: string;
265
164
  targetedNamespace: string;
165
+ disabledDate?: string | null | undefined;
266
166
  }>, "many">>>;
267
- display_name: z.ZodNullable<z.ZodOptional<z.ZodString>>;
167
+ display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
268
168
  expires_in: z.ZodNumber;
269
- is_comply: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
270
- jflgs: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
169
+ is_comply: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
170
+ jflgs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
271
171
  namespace: z.ZodString;
272
- namespace_roles: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
172
+ namespace_roles: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
273
173
  namespace: z.ZodString;
274
174
  roleId: z.ZodString;
275
175
  }, "strip", z.ZodTypeAny, {
@@ -282,42 +182,54 @@ declare const TokenWithDeviceCookieResponseV3: z.ZodObject<{
282
182
  permissions: z.ZodArray<z.ZodObject<{
283
183
  action: z.ZodNumber;
284
184
  resource: z.ZodString;
285
- schedAction: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
286
- schedCron: z.ZodNullable<z.ZodOptional<z.ZodString>>;
287
- schedRange: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
185
+ schedAction: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
186
+ schedCron: z.ZodOptional<z.ZodNullable<z.ZodString>>;
187
+ schedRange: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
288
188
  }, "strip", z.ZodTypeAny, {
189
+ action: number;
190
+ resource: string;
289
191
  schedAction?: number | null | undefined;
290
192
  schedCron?: string | null | undefined;
291
193
  schedRange?: string[] | null | undefined;
194
+ }, {
292
195
  action: number;
293
196
  resource: string;
294
- }, {
295
197
  schedAction?: number | null | undefined;
296
198
  schedCron?: string | null | undefined;
297
199
  schedRange?: string[] | null | undefined;
298
- action: number;
299
- resource: string;
300
200
  }>, "many">;
301
- platform_id: z.ZodNullable<z.ZodOptional<z.ZodString>>;
302
- platform_user_id: z.ZodNullable<z.ZodOptional<z.ZodString>>;
303
- refresh_expires_in: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
304
- refresh_token: z.ZodNullable<z.ZodOptional<z.ZodString>>;
305
- roles: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
201
+ platform_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
202
+ platform_user_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
203
+ refresh_expires_in: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
204
+ refresh_token: z.ZodOptional<z.ZodNullable<z.ZodString>>;
205
+ roles: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
306
206
  scope: z.ZodString;
307
- simultaneous_platform_id: z.ZodNullable<z.ZodOptional<z.ZodString>>;
308
- simultaneous_platform_user_id: z.ZodNullable<z.ZodOptional<z.ZodString>>;
207
+ simultaneous_platform_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
208
+ simultaneous_platform_user_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
309
209
  token_type: z.ZodString;
310
- unique_display_name: z.ZodNullable<z.ZodOptional<z.ZodString>>;
311
- user_id: z.ZodNullable<z.ZodOptional<z.ZodString>>;
312
- xuid: z.ZodNullable<z.ZodOptional<z.ZodString>>;
210
+ unique_display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
211
+ user_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
212
+ xuid: z.ZodOptional<z.ZodNullable<z.ZodString>>;
313
213
  }, "strip", z.ZodTypeAny, {
214
+ namespace: string;
215
+ access_token: string;
216
+ expires_in: number;
217
+ permissions: {
218
+ action: number;
219
+ resource: string;
220
+ schedAction?: number | null | undefined;
221
+ schedCron?: string | null | undefined;
222
+ schedRange?: string[] | null | undefined;
223
+ }[];
224
+ scope: string;
225
+ token_type: string;
314
226
  auth_trust_id?: string | null | undefined;
315
227
  bans?: {
316
- disabledDate?: string | null | undefined;
317
228
  ban: string;
318
229
  enabled: boolean;
319
230
  endDate: string;
320
231
  targetedNamespace: string;
232
+ disabledDate?: string | null | undefined;
321
233
  }[] | null | undefined;
322
234
  display_name?: string | null | undefined;
323
235
  is_comply?: boolean | null | undefined;
@@ -336,26 +248,26 @@ declare const TokenWithDeviceCookieResponseV3: z.ZodObject<{
336
248
  unique_display_name?: string | null | undefined;
337
249
  user_id?: string | null | undefined;
338
250
  xuid?: string | null | undefined;
251
+ }, {
339
252
  namespace: string;
340
253
  access_token: string;
341
254
  expires_in: number;
342
255
  permissions: {
256
+ action: number;
257
+ resource: string;
343
258
  schedAction?: number | null | undefined;
344
259
  schedCron?: string | null | undefined;
345
260
  schedRange?: string[] | null | undefined;
346
- action: number;
347
- resource: string;
348
261
  }[];
349
262
  scope: string;
350
263
  token_type: string;
351
- }, {
352
264
  auth_trust_id?: string | null | undefined;
353
265
  bans?: {
354
- disabledDate?: string | null | undefined;
355
266
  ban: string;
356
267
  enabled: boolean;
357
268
  endDate: string;
358
269
  targetedNamespace: string;
270
+ disabledDate?: string | null | undefined;
359
271
  }[] | null | undefined;
360
272
  display_name?: string | null | undefined;
361
273
  is_comply?: boolean | null | undefined;
@@ -374,37 +286,183 @@ declare const TokenWithDeviceCookieResponseV3: z.ZodObject<{
374
286
  unique_display_name?: string | null | undefined;
375
287
  user_id?: string | null | undefined;
376
288
  xuid?: string | null | undefined;
377
- namespace: string;
378
- access_token: string;
379
- expires_in: number;
380
- permissions: {
381
- schedAction?: number | null | undefined;
382
- schedCron?: string | null | undefined;
383
- schedRange?: string[] | null | undefined;
384
- action: number;
385
- resource: string;
386
- }[];
387
- scope: string;
388
- token_type: string;
389
289
  }>;
390
290
  interface TokenWithDeviceCookieResponseV3 extends z.TypeOf<typeof TokenWithDeviceCookieResponseV3> {
391
291
  }
392
292
 
393
- declare type RefreshArgs = {
293
+ type ResponseError = Error | AxiosError;
294
+ type Response<T> = {
295
+ response: AxiosResponse<T>;
296
+ error: null;
297
+ } | {
298
+ response: null;
299
+ error: ResponseError;
300
+ };
301
+ declare class Validate {
302
+ static validateOrReturnResponse<D>(useSchemaValidation: boolean, networkCall: () => Promise<AxiosResponse<D>>, Codec: z.ZodType<D>, modelName: string): Promise<Response<D>>;
303
+ static responseType<D>(networkCall: () => Promise<AxiosResponse<D>>, Codec: z.ZodType<D>, modelName: string): Promise<Response<D>>;
304
+ static unsafeResponse<D>(networkCall: () => Promise<AxiosResponse<D>>): Promise<Response<D>>;
305
+ static safeParse<D>(data: unknown, Codec: z.ZodType<D>): D | null;
306
+ }
307
+ declare class DecodeError extends Error {
308
+ constructor({ error, response, modelName }: {
309
+ error: ZodError;
310
+ response: AxiosResponse;
311
+ modelName: string;
312
+ });
313
+ }
314
+
315
+ declare enum GrantTokenUrls {
316
+ GRANT_TOKEN = "/iam/v3/oauth/token",
317
+ GRANT_TOKEN_V4 = "/iam/v4/oauth/token"
318
+ }
319
+ type GrantTokenUrlString = `${GrantTokenUrls}`;
320
+ type RefreshArgs = {
394
321
  axiosConfig: AxiosRequestConfig;
395
322
  refreshToken?: string;
396
323
  clientId: string;
324
+ tokenUrl?: GrantTokenUrlString;
325
+ };
326
+ declare class RefreshToken {
327
+ private config;
328
+ private interceptors;
329
+ constructor({ config, interceptors }: {
330
+ config: RefreshArgs;
331
+ interceptors?: Interceptor[];
332
+ });
333
+ runWithLock: () => Promise<Partial<TokenWithDeviceCookieResponseV3> | false>;
334
+ run: () => Promise<false | TokenWithDeviceCookieResponseV3>;
335
+ refreshToken: () => Promise<Response<TokenWithDeviceCookieResponseV3>>;
336
+ }
337
+ type SessionExpiredInterceptorOptions = {
338
+ /**
339
+ * The client ID used by the SDK, obtained from the Admin Portal under OAuth Clients.
340
+ */
341
+ clientId: string;
342
+ /**
343
+ * An optional array of URLs that should be ignored when handling session expiration.
344
+ * Default to `['/iam/v3/oauth/token', '/iam/v4/oauth/token', '/iam/v3/oauth/revoke']`
345
+ */
346
+ expectedErrorUrls?: string[];
347
+ /**
348
+ * A callback function that retrieves the current refresh token.
349
+ */
350
+ getRefreshToken?: () => string | undefined;
351
+ /**
352
+ * The URL endpoint for obtaining a new token. Defaults to `'/iam/v3/oauth/token'`.
353
+ */
354
+ tokenUrl?: GrantTokenUrlString;
355
+ /**
356
+ * A callback function triggered when the session has expired.
357
+ */
358
+ onSessionExpired: () => void;
359
+ /**
360
+ * A callback function triggered when successfully get new session.
361
+ */
362
+ onGetUserSession?: (accessToken: string, refreshToken: string) => void;
363
+ };
364
+ declare const createAuthInterceptor: ({ clientId, onSessionExpired, onGetUserSession, expectedErrorUrls, getRefreshToken, tokenUrl }: SessionExpiredInterceptorOptions) => Interceptor;
365
+ type RefreshSessioNInterceptorOptions = {
366
+ /**
367
+ * The URL endpoint for obtaining a new token. Defaults to `'/iam/v3/oauth/token'`.
368
+ */
369
+ tokenUrl?: GrantTokenUrlString;
370
+ };
371
+ declare const createRefreshSessionInterceptor: (options?: RefreshSessioNInterceptorOptions) => Interceptor;
372
+ type GetSessionInterceptorOptions = {
373
+ /**
374
+ * The URL endpoint for obtaining a new token. Defaults to `'/iam/v3/oauth/token'`.
375
+ */
376
+ tokenUrl?: GrantTokenUrlString;
377
+ /**
378
+ * A callback function triggered when successfully get new session.
379
+ */
380
+ onGetUserSession: (accessToken: string, refreshToken: string) => void;
397
381
  };
398
- declare const refreshWithLock: ({ axiosConfig, refreshToken, clientId }: RefreshArgs) => Promise<Partial<TokenWithDeviceCookieResponseV3> | false>;
399
- declare const doRefreshSession: ({ axiosConfig, clientId, refreshToken }: RefreshArgs) => () => Promise<false | TokenWithDeviceCookieResponseV3>;
400
- declare const injectAuthInterceptors: (clientId: string, getSDKConfig: () => AxiosRequestConfig, onSessionExpired?: (() => void) | undefined, onGetUserSession?: ((accessToken: string, refreshToken: string) => void) | undefined, getRefreshToken?: (() => string | undefined) | undefined) => void;
382
+ declare const createGetSessionInterceptor: ({ tokenUrl, onGetUserSession }: GetSessionInterceptorOptions) => Interceptor;
401
383
 
402
- declare type ErrorInterceptor = {
403
- baseUrl: string;
404
- onUserEligibilityChange?: () => void;
405
- onError?: (error: AxiosError) => void;
406
- onTooManyRequest?: (error: AxiosError) => void;
384
+ declare const BASE_PATHS: readonly ["/achievement", "/basic", "/buildinfo", "/chat", "/cloudsave", "/content-management", "/differ", "/dsmcontroller", "/event", "/game-telemetry", "/gdpr", "/group", "/iam", "/leaderboard", "/agreement", "/lobby", "/match2", "/matchmaking", "/odin-config", "/platform", "/qosm", "/reporting", "/seasonpass", "/session", "/sessionbrowser", "/social", "/ugc", "/config"];
385
+ type BasePath = (typeof BASE_PATHS)[number] | (string & {});
386
+
387
+ type CreateCustomPathInterceptorOptions = {
388
+ /**
389
+ * A list of objects specifying which service base paths should be replaced.
390
+ * For example, providing `{'/iam': '/iam-test'}` will redirect all `'/iam'` requests to `'/iam-test'`.
391
+ */
392
+ basePath: Partial<Record<BasePath, string>>;
393
+ /**
394
+ * Indicates whether to use the internal AccelByte network. This should only be used in a server environment.
395
+ * When set to true, requests will be made to `http://{service-name}/{path}` instead of the `baseURL`.
396
+ */
397
+ isInternalNetwork?: boolean;
407
398
  };
408
- declare const injectErrorInterceptors: ({ baseUrl, onError, onTooManyRequest, onUserEligibilityChange }: ErrorInterceptor) => void;
399
+ declare const createCustomPathInterceptor: ({ basePath, isInternalNetwork }: CreateCustomPathInterceptorOptions) => Interceptor;
400
+
401
+ declare const ErrorInterceptors: Array<Interceptor>;
402
+
403
+ declare class ApiUtils {
404
+ static mergeAxiosConfigs: (config: AxiosRequestConfig, overrides?: AxiosRequestConfig) => AxiosRequestConfig;
405
+ static is4xxError: (error: unknown) => boolean;
406
+ }
407
+
408
+ declare class BrowserHelper {
409
+ static isOnBrowser: () => false | Document;
410
+ }
411
+
412
+ declare class CodeGenUtil {
413
+ /**
414
+ * Returns a hash code from a string
415
+ * @param {String} str The string to hash.
416
+ * @return {Number} A 32bit integer
417
+ * @see http://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/
418
+ */
419
+ static hashCode(str: string): number;
420
+ static getFormUrlEncodedData: (data: Record<string, any>) => URLSearchParams;
421
+ }
422
+
423
+ declare class DesktopChecker {
424
+ private static desktopApp;
425
+ static isDesktopApp(): boolean;
426
+ private static isInIframe;
427
+ private static isElectron;
428
+ }
429
+
430
+ declare class Network {
431
+ static create(...configs: AxiosRequestConfig[]): AxiosInstance;
432
+ static withBearerToken(accessToken: string, config?: AxiosRequestConfig): AxiosInstance;
433
+ static setDeviceTokenCookie: () => void;
434
+ static removeDeviceTokenCookie: () => void;
435
+ static getFormUrlEncodedData: (data: any) => URLSearchParams;
436
+ }
437
+
438
+ declare class RefreshSession {
439
+ static KEY: string;
440
+ static isLocked: () => boolean;
441
+ static lock: (expiry: number) => void;
442
+ static unlock: () => void;
443
+ static sleepAsync: (timeInMs: number) => Promise<unknown>;
444
+ static isBearerAuth: (config?: AxiosRequestConfig) => boolean;
445
+ }
446
+
447
+ declare class SdkDevice {
448
+ static ID_KEY: string;
449
+ static TYPE: {
450
+ MOBILE: string;
451
+ DESKTOP: string;
452
+ };
453
+ static getType: () => string;
454
+ static generateUUID: () => string;
455
+ static getDeviceId: () => string;
456
+ }
457
+
458
+ declare class UrlHelper {
459
+ static isCompleteURLString: (urlString: string) => boolean;
460
+ static trimSlashFromStringEnd(pathString: string): string;
461
+ static trimSlashFromStringStart(pathString: string): string;
462
+ static trimSlashFromStringEdges(pathString: string): string;
463
+ static combinePaths(...paths: string[]): string;
464
+ static combineURLPaths(urlString: string, ...paths: string[]): string;
465
+ static removeQueryParam(fullUrlString: string, param: string): string;
466
+ }
409
467
 
410
- export { Accelbyte, AccelbyteSDK, ApiArgs, ApiError, ApiUtils, BrowserHelper, CodeGenUtil, CustomInterceptors, DecodeError, DesktopChecker, ERROR_CODE_LINK_DELETION_ACCOUNT, ERROR_CODE_TOKEN_EXPIRED, ERROR_LINK_ANOTHER_3RD_PARTY_ACCOUNT, ERROR_USER_BANNED, ErrorInterceptor$1 as ErrorInterceptor, IDataStatus, IResponse, IResponseError, IamErrorCode, Network, RefreshSession, RequestInterceptor, ResponseInterceptor, SDKEvents, SDKOptions, SDKRequestConfig, SdkDevice, UrlHelper, Validate, doRefreshSession, injectAuthInterceptors, injectErrorInterceptors, injectRequestInterceptors, injectResponseInterceptors, refreshWithLock };
468
+ export { AccelByte, AccelByteSDK, type ApiError, ApiUtils, type AxiosConfig, BrowserHelper, CodeGenUtil, type CoreConfig, DecodeError, DesktopChecker, ERROR_CODE_LINK_DELETION_ACCOUNT, ERROR_CODE_TOKEN_EXPIRED, ERROR_LINK_ANOTHER_3RD_PARTY_ACCOUNT, ERROR_USER_BANNED, ErrorInterceptors, IamErrorCode, type Interceptor, type MakeOptional, type MakeRequired, Network, RefreshSession, RefreshToken, type Response, type ResponseError, type SdkConstructorParam, SdkDevice, type SdkSetConfigParam, type TokenConfig, UrlHelper, Validate, createAuthInterceptor, createCustomPathInterceptor, createGetSessionInterceptor, createRefreshSessionInterceptor, isType };