@accelbyte/sdk 3.0.7 → 4.0.0
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/README.md +572 -2
- package/dist/cjs/node/index.cjs +900 -832
- package/dist/cjs/node/index.cjs.map +1 -1
- package/dist/es/browser/index.browser.js +838 -792
- package/dist/es/browser/index.browser.js.map +1 -1
- package/dist/es/node/index.node.js +843 -793
- package/dist/es/node/index.node.js.map +1 -1
- package/dist/index.d.ts +312 -237
- package/package.json +40 -12
package/dist/index.d.ts
CHANGED
|
@@ -1,48 +1,13 @@
|
|
|
1
|
-
import { InternalAxiosRequestConfig, AxiosResponse,
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
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,198 +26,150 @@ interface SDKOptions {
|
|
|
61
26
|
*/
|
|
62
27
|
namespace: string;
|
|
63
28
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
29
|
+
* When "false" is provided, the SDK bypasses Zod Schema Validation.
|
|
30
|
+
* Default is "true".
|
|
66
31
|
*/
|
|
67
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
79
|
+
assembly(): {
|
|
80
|
+
axiosInstance: AxiosInstance;
|
|
81
|
+
coreConfig: CoreConfig;
|
|
82
|
+
axiosConfig: MakeRequired<AxiosConfig, "request">;
|
|
83
|
+
};
|
|
73
84
|
/**
|
|
74
|
-
*
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
90
|
+
clone(opts?: {
|
|
91
|
+
interceptors?: boolean;
|
|
92
|
+
}): AccelByteSDK;
|
|
79
93
|
/**
|
|
80
|
-
*
|
|
94
|
+
* Adds interceptors to the current Axios configuration.
|
|
81
95
|
*/
|
|
82
|
-
|
|
96
|
+
addInterceptors(interceptors: Interceptor[]): AccelByteSDK;
|
|
83
97
|
/**
|
|
84
|
-
*
|
|
85
|
-
*
|
|
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
|
-
|
|
101
|
+
removeInterceptors(): AccelByteSDK;
|
|
102
|
+
removeInterceptors(filterCallback: (interceptor: Interceptor) => boolean): AccelByteSDK;
|
|
88
103
|
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
104
|
+
* Updates the SDK's core and Axios configurations.
|
|
105
|
+
* Merges the provided configurations with the current ones.
|
|
91
106
|
*/
|
|
92
|
-
|
|
107
|
+
setConfig({ coreConfig, axiosConfig }: SdkSetConfigParam): this;
|
|
93
108
|
/**
|
|
94
|
-
*
|
|
109
|
+
* Set accessToken and refreshToken and updates the Axios request headers to use Bearer authentication.
|
|
95
110
|
*/
|
|
96
|
-
|
|
111
|
+
setToken(token: TokenConfig): void;
|
|
97
112
|
/**
|
|
98
|
-
*
|
|
113
|
+
* Removes the currently set token.
|
|
99
114
|
*/
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
options: SDKOptions;
|
|
134
|
-
config?: SDKRequestConfig<any> | undefined;
|
|
135
|
-
onEvents?: SDKEvents | undefined;
|
|
136
|
-
}) => AccelbyteSDK;
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
declare const VALIDATION_ERROR_CODE = 20002;
|
|
122
|
+
declare enum IamErrorCode {
|
|
123
|
+
InternalServerError = 20000,
|
|
124
|
+
UnauthorizedAccess = 20001,
|
|
125
|
+
ValidationError = 20002,
|
|
126
|
+
ForbiddenAccess = 20003,
|
|
127
|
+
TooManyRequests = 20007,
|
|
128
|
+
UserNotFound = 20008,
|
|
129
|
+
TokenIsExpired = 20011,
|
|
130
|
+
InsufficientPermissions = 20013,
|
|
131
|
+
InvalidAudience = 20014,
|
|
132
|
+
InsufficientScope = 20015,
|
|
133
|
+
UnableToParseRequestBody = 20019,
|
|
134
|
+
InvalidPaginationParameters = 20021,
|
|
135
|
+
TokenIsNotUserToken = 20022,
|
|
136
|
+
InvalidRefererHeader = 20023,
|
|
137
|
+
SubdomainMismatch = 20030
|
|
138
|
+
}
|
|
140
139
|
|
|
141
140
|
declare const ERROR_LINK_ANOTHER_3RD_PARTY_ACCOUNT = 10200;
|
|
142
141
|
declare const ERROR_CODE_LINK_DELETION_ACCOUNT = 10135;
|
|
143
142
|
declare const ERROR_CODE_TOKEN_EXPIRED = 10196;
|
|
144
143
|
declare const ERROR_USER_BANNED = 10134;
|
|
145
144
|
|
|
146
|
-
declare class ApiUtils {
|
|
147
|
-
static mergedConfigs: (config: SDKRequestConfig, overrides?: ApiArgs | undefined) => SDKRequestConfig;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
declare class BrowserHelper {
|
|
151
|
-
static isOnBrowser: () => false | Document;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
declare class CodeGenUtil {
|
|
155
|
-
/**
|
|
156
|
-
* Returns a hash code from a string
|
|
157
|
-
* @param {String} str The string to hash.
|
|
158
|
-
* @return {Number} A 32bit integer
|
|
159
|
-
* @see http://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/
|
|
160
|
-
*/
|
|
161
|
-
static hashCode(str: string): number;
|
|
162
|
-
static getFormUrlEncodedData: (data: Record<string, any>) => URLSearchParams;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
declare class DesktopChecker {
|
|
166
|
-
private static desktopApp;
|
|
167
|
-
static isDesktopApp(): boolean;
|
|
168
|
-
private static isInIframe;
|
|
169
|
-
private static isElectron;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
declare class UrlHelper {
|
|
173
|
-
static isCompleteURLString: (urlString: string) => boolean;
|
|
174
|
-
static trimSlashFromStringEnd(pathString: string): string;
|
|
175
|
-
static trimSlashFromStringStart(pathString: string): string;
|
|
176
|
-
static trimSlashFromStringEdges(pathString: string): string;
|
|
177
|
-
static combinePaths(...paths: string[]): string;
|
|
178
|
-
static combineURLPaths(urlString: string, ...paths: string[]): string;
|
|
179
|
-
static removeQueryParam(fullUrlString: string, param: string): string;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
declare class RefreshSession {
|
|
183
|
-
static KEY: string;
|
|
184
|
-
static isLocked: () => boolean;
|
|
185
|
-
static lock: (expiry: number) => void;
|
|
186
|
-
static unlock: () => void;
|
|
187
|
-
static sleepAsync: (timeInMs: number) => Promise<unknown>;
|
|
188
|
-
static isBearerAuth: (config?: AxiosRequestConfig<any> | undefined) => boolean;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
declare type IResponseError = Error | AxiosError;
|
|
192
|
-
declare type IDataStatus<D> = {
|
|
193
|
-
data: D;
|
|
194
|
-
status: number;
|
|
195
|
-
};
|
|
196
|
-
declare type IResponse<D> = {
|
|
197
|
-
response: IDataStatus<D>;
|
|
198
|
-
error: null;
|
|
199
|
-
} | {
|
|
200
|
-
response: null;
|
|
201
|
-
error: IResponseError;
|
|
202
|
-
};
|
|
203
|
-
declare class Validate {
|
|
204
|
-
static validateOrReturnResponse<D>(useSchemaValidation: boolean, networkCall: () => Promise<AxiosResponse<D>>, Codec: z.ZodType<D>, modelName: string): Promise<IResponse<D>>;
|
|
205
|
-
static responseType<D>(networkCall: () => Promise<AxiosResponse<D>>, Codec: z.ZodType<D>, modelName: string): Promise<IResponse<D>>;
|
|
206
|
-
static unsafeResponse<D>(networkCall: () => Promise<AxiosResponse<D>>): Promise<IResponse<D>>;
|
|
207
|
-
static safeParse<D>(data: unknown, Codec: z.ZodType<D>): D | null;
|
|
208
|
-
}
|
|
209
|
-
declare class DecodeError extends Error {
|
|
210
|
-
constructor({ error, response, modelName }: {
|
|
211
|
-
error: ZodError;
|
|
212
|
-
response: AxiosResponse;
|
|
213
|
-
modelName: string;
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
declare class SdkDevice {
|
|
218
|
-
static ID_KEY: string;
|
|
219
|
-
static TYPE: {
|
|
220
|
-
MOBILE: string;
|
|
221
|
-
DESKTOP: string;
|
|
222
|
-
};
|
|
223
|
-
static getType: () => string;
|
|
224
|
-
static generateUUID: () => string;
|
|
225
|
-
static getDeviceId: () => string;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
145
|
declare const TokenWithDeviceCookieResponseV3: z.ZodObject<{
|
|
229
146
|
access_token: z.ZodString;
|
|
230
|
-
auth_trust_id: z.
|
|
231
|
-
bans: z.
|
|
147
|
+
auth_trust_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
148
|
+
bans: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
232
149
|
ban: z.ZodString;
|
|
233
|
-
disabledDate: z.
|
|
150
|
+
disabledDate: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
234
151
|
enabled: z.ZodBoolean;
|
|
235
152
|
endDate: z.ZodString;
|
|
236
153
|
targetedNamespace: z.ZodString;
|
|
237
154
|
}, "strip", z.ZodTypeAny, {
|
|
238
|
-
disabledDate?: string | null | undefined;
|
|
239
155
|
ban: string;
|
|
240
156
|
enabled: boolean;
|
|
241
157
|
endDate: string;
|
|
242
158
|
targetedNamespace: string;
|
|
243
|
-
}, {
|
|
244
159
|
disabledDate?: string | null | undefined;
|
|
160
|
+
}, {
|
|
245
161
|
ban: string;
|
|
246
162
|
enabled: boolean;
|
|
247
163
|
endDate: string;
|
|
248
164
|
targetedNamespace: string;
|
|
165
|
+
disabledDate?: string | null | undefined;
|
|
249
166
|
}>, "many">>>;
|
|
250
|
-
display_name: z.
|
|
167
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
251
168
|
expires_in: z.ZodNumber;
|
|
252
|
-
is_comply: z.
|
|
253
|
-
jflgs: z.
|
|
169
|
+
is_comply: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
170
|
+
jflgs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
254
171
|
namespace: z.ZodString;
|
|
255
|
-
namespace_roles: z.
|
|
172
|
+
namespace_roles: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
256
173
|
namespace: z.ZodString;
|
|
257
174
|
roleId: z.ZodString;
|
|
258
175
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -265,42 +182,54 @@ declare const TokenWithDeviceCookieResponseV3: z.ZodObject<{
|
|
|
265
182
|
permissions: z.ZodArray<z.ZodObject<{
|
|
266
183
|
action: z.ZodNumber;
|
|
267
184
|
resource: z.ZodString;
|
|
268
|
-
schedAction: z.
|
|
269
|
-
schedCron: z.
|
|
270
|
-
schedRange: z.
|
|
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">>>;
|
|
271
188
|
}, "strip", z.ZodTypeAny, {
|
|
189
|
+
action: number;
|
|
190
|
+
resource: string;
|
|
272
191
|
schedAction?: number | null | undefined;
|
|
273
192
|
schedCron?: string | null | undefined;
|
|
274
193
|
schedRange?: string[] | null | undefined;
|
|
194
|
+
}, {
|
|
275
195
|
action: number;
|
|
276
196
|
resource: string;
|
|
277
|
-
}, {
|
|
278
197
|
schedAction?: number | null | undefined;
|
|
279
198
|
schedCron?: string | null | undefined;
|
|
280
199
|
schedRange?: string[] | null | undefined;
|
|
281
|
-
action: number;
|
|
282
|
-
resource: string;
|
|
283
200
|
}>, "many">;
|
|
284
|
-
platform_id: z.
|
|
285
|
-
platform_user_id: z.
|
|
286
|
-
refresh_expires_in: z.
|
|
287
|
-
refresh_token: z.
|
|
288
|
-
roles: z.
|
|
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">>>;
|
|
289
206
|
scope: z.ZodString;
|
|
290
|
-
simultaneous_platform_id: z.
|
|
291
|
-
simultaneous_platform_user_id: z.
|
|
207
|
+
simultaneous_platform_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
208
|
+
simultaneous_platform_user_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
292
209
|
token_type: z.ZodString;
|
|
293
|
-
unique_display_name: z.
|
|
294
|
-
user_id: z.
|
|
295
|
-
xuid: z.
|
|
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>>;
|
|
296
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;
|
|
297
226
|
auth_trust_id?: string | null | undefined;
|
|
298
227
|
bans?: {
|
|
299
|
-
disabledDate?: string | null | undefined;
|
|
300
228
|
ban: string;
|
|
301
229
|
enabled: boolean;
|
|
302
230
|
endDate: string;
|
|
303
231
|
targetedNamespace: string;
|
|
232
|
+
disabledDate?: string | null | undefined;
|
|
304
233
|
}[] | null | undefined;
|
|
305
234
|
display_name?: string | null | undefined;
|
|
306
235
|
is_comply?: boolean | null | undefined;
|
|
@@ -319,26 +248,26 @@ declare const TokenWithDeviceCookieResponseV3: z.ZodObject<{
|
|
|
319
248
|
unique_display_name?: string | null | undefined;
|
|
320
249
|
user_id?: string | null | undefined;
|
|
321
250
|
xuid?: string | null | undefined;
|
|
251
|
+
}, {
|
|
322
252
|
namespace: string;
|
|
323
253
|
access_token: string;
|
|
324
254
|
expires_in: number;
|
|
325
255
|
permissions: {
|
|
256
|
+
action: number;
|
|
257
|
+
resource: string;
|
|
326
258
|
schedAction?: number | null | undefined;
|
|
327
259
|
schedCron?: string | null | undefined;
|
|
328
260
|
schedRange?: string[] | null | undefined;
|
|
329
|
-
action: number;
|
|
330
|
-
resource: string;
|
|
331
261
|
}[];
|
|
332
262
|
scope: string;
|
|
333
263
|
token_type: string;
|
|
334
|
-
}, {
|
|
335
264
|
auth_trust_id?: string | null | undefined;
|
|
336
265
|
bans?: {
|
|
337
|
-
disabledDate?: string | null | undefined;
|
|
338
266
|
ban: string;
|
|
339
267
|
enabled: boolean;
|
|
340
268
|
endDate: string;
|
|
341
269
|
targetedNamespace: string;
|
|
270
|
+
disabledDate?: string | null | undefined;
|
|
342
271
|
}[] | null | undefined;
|
|
343
272
|
display_name?: string | null | undefined;
|
|
344
273
|
is_comply?: boolean | null | undefined;
|
|
@@ -357,37 +286,183 @@ declare const TokenWithDeviceCookieResponseV3: z.ZodObject<{
|
|
|
357
286
|
unique_display_name?: string | null | undefined;
|
|
358
287
|
user_id?: string | null | undefined;
|
|
359
288
|
xuid?: string | null | undefined;
|
|
360
|
-
namespace: string;
|
|
361
|
-
access_token: string;
|
|
362
|
-
expires_in: number;
|
|
363
|
-
permissions: {
|
|
364
|
-
schedAction?: number | null | undefined;
|
|
365
|
-
schedCron?: string | null | undefined;
|
|
366
|
-
schedRange?: string[] | null | undefined;
|
|
367
|
-
action: number;
|
|
368
|
-
resource: string;
|
|
369
|
-
}[];
|
|
370
|
-
scope: string;
|
|
371
|
-
token_type: string;
|
|
372
289
|
}>;
|
|
373
290
|
interface TokenWithDeviceCookieResponseV3 extends z.TypeOf<typeof TokenWithDeviceCookieResponseV3> {
|
|
374
291
|
}
|
|
375
292
|
|
|
376
|
-
|
|
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 = {
|
|
377
321
|
axiosConfig: AxiosRequestConfig;
|
|
378
322
|
refreshToken?: string;
|
|
379
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;
|
|
380
370
|
};
|
|
381
|
-
declare const
|
|
382
|
-
|
|
383
|
-
|
|
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;
|
|
381
|
+
};
|
|
382
|
+
declare const createGetSessionInterceptor: ({ tokenUrl, onGetUserSession }: GetSessionInterceptorOptions) => Interceptor;
|
|
383
|
+
|
|
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 & {});
|
|
384
386
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
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;
|
|
390
398
|
};
|
|
391
|
-
declare const
|
|
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
|
+
}
|
|
392
467
|
|
|
393
|
-
export {
|
|
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 };
|