@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.
@@ -1,829 +1,879 @@
1
- import { webcrypto } from 'crypto';
2
- import axios, { HttpStatusCode } from 'axios';
3
- import qs from 'query-string';
4
- import * as uuid from 'uuid';
5
- import { z } from 'zod';
6
-
7
- /*
8
- * Copyright (c) 2018-2024 AccelByte Inc. All Rights Reserved
9
- * This is licensed software from AccelByte Inc, for limitations
10
- * and restrictions contact your company contract manager.
11
- */
12
- if (!global.crypto) {
13
- global.crypto = webcrypto;
1
+ // src/polyfills/node.ts
2
+ import { webcrypto } from "crypto";
3
+ if (!global.crypto) {
4
+ global.crypto = webcrypto;
14
5
  }
15
6
 
16
- var _a;
17
- class SdkDevice {
18
- }
19
- _a = SdkDevice;
20
- SdkDevice.ID_KEY = 'deviceId';
21
- SdkDevice.TYPE = {
22
- MOBILE: 'mobile',
23
- DESKTOP: 'desktop'
24
- };
25
- SdkDevice.getType = () => {
26
- return isMobile() ? SdkDevice.TYPE.MOBILE : SdkDevice.TYPE.DESKTOP;
27
- };
28
- SdkDevice.generateUUID = () => {
29
- const deviceIdInUUID = uuid.v4().split('-').join('');
30
- localStorage.setItem(SdkDevice.ID_KEY, deviceIdInUUID);
31
- return deviceIdInUUID;
32
- };
33
- SdkDevice.getDeviceId = () => {
34
- return localStorage.getItem(_a.ID_KEY) || _a.generateUUID();
35
- };
36
- /*
37
- Bellow function is copied from npm 'is-mobile'
38
- */
39
- const mobileRE = /(android|bb\d+|meego).+mobile|armv7l|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i;
40
- const tabletRE = /android|ipad|playbook|silk/i;
41
- const isMobile = (opts) => {
42
- if (!opts)
43
- opts = {};
44
- let ua = opts.ua;
45
- if (!ua && typeof navigator !== 'undefined')
46
- ua = navigator.userAgent;
47
- if (ua && ua.headers && typeof ua.headers['user-agent'] === 'string') {
48
- ua = ua.headers['user-agent'];
49
- }
50
- if (typeof ua !== 'string')
51
- return false;
52
- let result = mobileRE.test(ua) || (!!opts.tablet && tabletRE.test(ua));
53
- if (!result &&
54
- opts.tablet &&
55
- opts.featureDetect &&
56
- navigator &&
57
- navigator.maxTouchPoints > 1 &&
58
- ua.indexOf('Macintosh') !== -1 &&
59
- ua.indexOf('Safari') !== -1) {
60
- result = true;
61
- }
62
- return result;
7
+ // src/utils/ApiUtils.ts
8
+ import axios from "axios";
9
+ var ApiUtils = class {
10
+ };
11
+ ApiUtils.mergeAxiosConfigs = (config, overrides) => {
12
+ return {
13
+ ...config,
14
+ ...overrides,
15
+ headers: {
16
+ ...config == null ? void 0 : config.headers,
17
+ ...overrides == null ? void 0 : overrides.headers
18
+ }
19
+ };
20
+ };
21
+ ApiUtils.is4xxError = (error) => {
22
+ if (axios.isAxiosError(error) && error.response) {
23
+ return error.response.status >= 400 && error.response.status <= 499;
24
+ }
25
+ return false;
63
26
  };
64
27
 
65
- /*
66
- * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved
67
- * This is licensed software from AccelByte Inc, for limitations
68
- * and restrictions contact your company contract manager.
69
- */
70
- const requestInterceptors = new Map();
71
- const responseInterceptors = new Map();
72
- const injectRequestInterceptors = (requestInterceptor, errorInterceptor) => {
73
- const pair = { interceptor: requestInterceptor, errorInterceptor };
74
- const ejectId = axios.interceptors.request.use(requestInterceptor, errorInterceptor);
75
- requestInterceptors.set(ejectId, pair);
76
- return ejectId;
77
- };
78
- const injectResponseInterceptors = (responseInterceptor, errorInterceptor) => {
79
- const pair = { interceptor: responseInterceptor, errorInterceptor };
80
- const ejectId = axios.interceptors.response.use(responseInterceptor, errorInterceptor);
81
- responseInterceptors.set(ejectId, pair);
82
- return ejectId;
83
- };
84
- const loggerInterceptor = (axiosInstance) => {
85
- axiosInstance.interceptors.request.use(config => {
86
- // Logger.info(config.method?.toUpperCase(), `${config.url}`)
87
- return config;
88
- }, error => {
89
- return Promise.reject(error);
90
- });
91
- };
92
- class Network {
93
- //
94
- static create(...configs) {
95
- const axiosInstance = axios.create(Object.assign({
96
- paramsSerializer: qs.stringify
97
- }, ...configs));
98
- Array.from(requestInterceptors).forEach(([_key, interceptorPair]) => {
99
- const { interceptor, errorInterceptor } = interceptorPair;
100
- axiosInstance.interceptors.request.use(interceptor, errorInterceptor);
101
- });
102
- Array.from(responseInterceptors).forEach(([_key, interceptorPair]) => {
103
- const { interceptor, errorInterceptor } = interceptorPair;
104
- axiosInstance.interceptors.response.use(interceptor, errorInterceptor);
105
- });
106
- loggerInterceptor(axiosInstance);
107
- return axiosInstance;
108
- }
109
- static withBearerToken(accessToken, config) {
110
- return Network.create(config || {}, {
111
- headers: { Authorization: `Bearer ${accessToken}` }
112
- });
113
- }
114
- }
115
- Network.setDeviceTokenCookie = () => {
116
- const deviceId = SdkDevice.getDeviceId();
117
- document.cookie = `device_token=${deviceId}; path=/;`;
118
- };
119
- Network.removeDeviceTokenCookie = () => {
120
- document.cookie = `device_token=; expires=${new Date(0).toUTCString()}`;
121
- };
122
- Network.getFormUrlEncodedData = (data) => {
123
- const formPayload = new URLSearchParams();
124
- const formKeys = Object.keys(data);
125
- formKeys.forEach(key => {
126
- if (data[key])
127
- formPayload.append(key, data[key]);
128
- });
129
- return formPayload;
28
+ // src/utils/Network.ts
29
+ import axios2 from "axios";
30
+ import qs from "query-string";
31
+
32
+ // src/utils/SdkDevice.ts
33
+ import * as uuid from "uuid";
34
+ var _SdkDevice = class _SdkDevice {
35
+ };
36
+ _SdkDevice.ID_KEY = "deviceId";
37
+ _SdkDevice.TYPE = {
38
+ MOBILE: "mobile",
39
+ DESKTOP: "desktop"
40
+ };
41
+ _SdkDevice.getType = () => {
42
+ return isMobile() ? _SdkDevice.TYPE.MOBILE : _SdkDevice.TYPE.DESKTOP;
43
+ };
44
+ _SdkDevice.generateUUID = () => {
45
+ const deviceIdInUUID = uuid.v4().split("-").join("");
46
+ localStorage.setItem(_SdkDevice.ID_KEY, deviceIdInUUID);
47
+ return deviceIdInUUID;
48
+ };
49
+ _SdkDevice.getDeviceId = () => {
50
+ return localStorage.getItem(_SdkDevice.ID_KEY) || _SdkDevice.generateUUID();
51
+ };
52
+ var SdkDevice = _SdkDevice;
53
+ var mobileRE = /(android|bb\d+|meego).+mobile|armv7l|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i;
54
+ var tabletRE = /android|ipad|playbook|silk/i;
55
+ var isMobile = (opts) => {
56
+ if (!opts) opts = {};
57
+ let ua = opts.ua;
58
+ if (!ua && typeof navigator !== "undefined") ua = navigator.userAgent;
59
+ if (ua && ua.headers && typeof ua.headers["user-agent"] === "string") {
60
+ ua = ua.headers["user-agent"];
61
+ }
62
+ if (typeof ua !== "string") return false;
63
+ let result = mobileRE.test(ua) || !!opts.tablet && tabletRE.test(ua);
64
+ if (!result && opts.tablet && opts.featureDetect && navigator && navigator.maxTouchPoints > 1 && ua.indexOf("Macintosh") !== -1 && ua.indexOf("Safari") !== -1) {
65
+ result = true;
66
+ }
67
+ return result;
130
68
  };
131
69
 
132
- /*
133
- * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved
134
- * This is licensed software from AccelByte Inc, for limitations
135
- * and restrictions contact your company contract manager.
136
- */
137
- const ERROR_ELIGIBILITY_CODE = 13130;
138
- const injectErrorInterceptors = ({ baseUrl, onError, onTooManyRequest, onUserEligibilityChange }) => {
139
- injectResponseInterceptors(response => {
140
- return response;
141
- }, (error) => {
142
- if (error.response) {
143
- const { response } = error;
144
- if (response?.status === 403 && response?.config.url.includes(baseUrl) && response?.config.withCredentials) {
145
- if (response.data.errorCode === ERROR_ELIGIBILITY_CODE && onUserEligibilityChange) {
146
- onUserEligibilityChange();
147
- }
148
- }
149
- if (response?.status === HttpStatusCode.TooManyRequests && onTooManyRequest) {
150
- onTooManyRequest(error);
151
- }
152
- }
153
- if (onError) {
154
- onError(error);
155
- }
156
- throw error;
157
- });
70
+ // src/utils/Network.ts
71
+ var _Network = class _Network {
72
+ static create(...configs) {
73
+ const axiosInstance = axios2.create(
74
+ Object.assign(
75
+ {
76
+ paramsSerializer: qs.stringify
77
+ },
78
+ ...configs
79
+ )
80
+ );
81
+ return axiosInstance;
82
+ }
83
+ static withBearerToken(accessToken, config) {
84
+ return _Network.create(config || {}, {
85
+ headers: { Authorization: `Bearer ${accessToken}` }
86
+ });
87
+ }
88
+ };
89
+ _Network.setDeviceTokenCookie = () => {
90
+ const deviceId = SdkDevice.getDeviceId();
91
+ document.cookie = `device_token=${deviceId}; path=/;`;
158
92
  };
93
+ _Network.removeDeviceTokenCookie = () => {
94
+ document.cookie = `device_token=; expires=${(/* @__PURE__ */ new Date(0)).toUTCString()}`;
95
+ };
96
+ _Network.getFormUrlEncodedData = (data) => {
97
+ const formPayload = new URLSearchParams();
98
+ const formKeys = Object.keys(data);
99
+ formKeys.forEach((key) => {
100
+ if (data[key]) formPayload.append(key, data[key]);
101
+ });
102
+ return formPayload;
103
+ };
104
+ var Network = _Network;
159
105
 
160
- /*
161
- * Copyright (c) 2022 AccelByte Inc. All Rights Reserved
162
- * This is licensed software from AccelByte Inc, for limitations
163
- * and restrictions contact your company contract manager.
164
- */
165
- class BrowserHelper {
166
- }
167
- BrowserHelper.isOnBrowser = () => {
168
- return typeof window !== 'undefined' && window.document;
106
+ // src/AccelByteSDK.ts
107
+ var AccelByte = {
108
+ SDK: (param) => {
109
+ return new AccelByteSDK(param);
110
+ }
111
+ };
112
+ var AccelByteSDK = class _AccelByteSDK {
113
+ constructor({ coreConfig, axiosConfig }) {
114
+ var _a;
115
+ this.coreConfig = {
116
+ ...coreConfig,
117
+ useSchemaValidation: coreConfig.useSchemaValidation ?? true
118
+ };
119
+ this.axiosConfig = {
120
+ /**
121
+ * when user create a variable to store intercepters and passed into sdk
122
+ * the sdk will use the variable as reference value,
123
+ * so when new interceptor added, reference value will also has the new interceptor,
124
+ * to avoid this we create shallow copy for the interceptors
125
+ */
126
+ interceptors: (axiosConfig == null ? void 0 : axiosConfig.interceptors) ? [...axiosConfig.interceptors] : void 0,
127
+ request: {
128
+ timeout: 6e4,
129
+ withCredentials: true,
130
+ ...axiosConfig == null ? void 0 : axiosConfig.request,
131
+ headers: {
132
+ "Content-Type": "application/json",
133
+ ...(_a = axiosConfig == null ? void 0 : axiosConfig.request) == null ? void 0 : _a.headers
134
+ }
135
+ }
136
+ };
137
+ this.axiosInstance = this.createAxiosInstance();
138
+ this.token = {};
139
+ }
140
+ createAxiosInstance() {
141
+ const axiosInstance = Network.create({ baseURL: this.coreConfig.baseURL, ...this.axiosConfig.request });
142
+ const interceptors = this.axiosConfig.interceptors;
143
+ if (interceptors) {
144
+ for (const interceptor of interceptors) {
145
+ if (interceptor.type === "request") {
146
+ axiosInstance.interceptors.request.use(interceptor == null ? void 0 : interceptor.onRequest, interceptor.onError);
147
+ }
148
+ if (interceptor.type === "response") {
149
+ axiosInstance.interceptors.response.use(interceptor == null ? void 0 : interceptor.onSuccess, interceptor.onError);
150
+ }
151
+ }
152
+ }
153
+ return axiosInstance;
154
+ }
155
+ /**
156
+ * Assembles and returns the current Axios instance along with core and Axios configurations.
157
+ */
158
+ assembly() {
159
+ return {
160
+ axiosInstance: this.axiosInstance,
161
+ coreConfig: this.coreConfig,
162
+ axiosConfig: this.axiosConfig
163
+ };
164
+ }
165
+ /**
166
+ * Creates a new instance of AccelByteSDK with a shallow copy of the current configurations.
167
+ * Optionally allows excluding interceptors.
168
+ * @param {boolean} [opts.interceptors] - Whether to include interceptors in the clone. Default is true.
169
+ * @returns {AccelByteSDK} A new instance of AccelByteSDK with the cloned configuration.
170
+ */
171
+ clone(opts) {
172
+ const newConfigs = {
173
+ coreConfig: { ...this.coreConfig },
174
+ axiosConfig: { ...this.axiosConfig }
175
+ };
176
+ if ((opts == null ? void 0 : opts.interceptors) === false) {
177
+ delete newConfigs.axiosConfig.interceptors;
178
+ }
179
+ const newSdkInstance = new _AccelByteSDK(newConfigs);
180
+ newSdkInstance.setToken(this.token);
181
+ return newSdkInstance;
182
+ }
183
+ /**
184
+ * Adds interceptors to the current Axios configuration.
185
+ */
186
+ addInterceptors(interceptors) {
187
+ if (!this.axiosConfig.interceptors) {
188
+ this.axiosConfig.interceptors = [];
189
+ }
190
+ this.axiosConfig.interceptors.push(...interceptors);
191
+ return this;
192
+ }
193
+ removeInterceptors(filterCallback) {
194
+ var _a;
195
+ if (!((_a = this.axiosConfig) == null ? void 0 : _a.interceptors)) return this;
196
+ if (!filterCallback) {
197
+ this.axiosConfig.interceptors = void 0;
198
+ this.axiosInstance.interceptors.request.clear();
199
+ this.axiosInstance.interceptors.response.clear();
200
+ return this;
201
+ }
202
+ this.axiosConfig.interceptors = this.axiosConfig.interceptors.filter(filterCallback);
203
+ this.axiosInstance = this.createAxiosInstance();
204
+ return this;
205
+ }
206
+ /**
207
+ * Updates the SDK's core and Axios configurations.
208
+ * Merges the provided configurations with the current ones.
209
+ */
210
+ setConfig({ coreConfig, axiosConfig }) {
211
+ this.coreConfig = {
212
+ ...this.coreConfig,
213
+ ...coreConfig
214
+ };
215
+ this.axiosConfig = {
216
+ ...this.axiosConfig,
217
+ ...axiosConfig == null ? void 0 : axiosConfig.interceptors,
218
+ request: ApiUtils.mergeAxiosConfigs(this.axiosConfig.request, axiosConfig == null ? void 0 : axiosConfig.request)
219
+ };
220
+ this.axiosInstance = this.createAxiosInstance();
221
+ return this;
222
+ }
223
+ /**
224
+ * Set accessToken and refreshToken and updates the Axios request headers to use Bearer authentication.
225
+ */
226
+ setToken(token) {
227
+ this.token = {
228
+ ...this.token,
229
+ ...token
230
+ };
231
+ const configOverride = { headers: { Authorization: this.token.accessToken ? `Bearer ${this.token.accessToken}` : "" } };
232
+ this.axiosConfig = {
233
+ ...this.axiosConfig,
234
+ request: ApiUtils.mergeAxiosConfigs(this.axiosInstance.defaults, configOverride)
235
+ };
236
+ this.axiosInstance = this.createAxiosInstance();
237
+ }
238
+ /**
239
+ * Removes the currently set token.
240
+ */
241
+ removeToken() {
242
+ this.token = {};
243
+ const configOverride = { headers: { Authorization: void 0 } };
244
+ this.axiosConfig = {
245
+ ...this.axiosConfig,
246
+ request: ApiUtils.mergeAxiosConfigs(this.axiosInstance.defaults, configOverride)
247
+ };
248
+ this.axiosInstance = this.createAxiosInstance();
249
+ }
250
+ /**
251
+ * Retrieves the current token configuration.
252
+ */
253
+ getToken() {
254
+ return this.token;
255
+ }
169
256
  };
170
257
 
171
- class RefreshSession {
172
- }
173
- // --
174
- RefreshSession.KEY = 'RefreshSession.lock';
175
- RefreshSession.isLocked = () => {
176
- if (!BrowserHelper.isOnBrowser())
177
- return false;
178
- const lockStatus = localStorage.getItem(RefreshSession.KEY);
179
- if (!lockStatus) {
180
- return false;
181
- }
182
- const lockExpiry = Number(lockStatus);
183
- if (isNaN(lockExpiry)) {
184
- return false;
185
- }
186
- return lockExpiry > new Date().getTime();
187
- };
188
- RefreshSession.lock = (expiry) => {
189
- if (!BrowserHelper.isOnBrowser())
190
- return;
191
- localStorage.setItem(RefreshSession.KEY, `${new Date().getTime() + expiry}`);
192
- };
193
- RefreshSession.unlock = () => {
194
- if (!BrowserHelper.isOnBrowser())
195
- return;
196
- localStorage.removeItem(RefreshSession.KEY);
197
- };
198
- RefreshSession.sleepAsync = (timeInMs) => new Promise(resolve => setTimeout(resolve, timeInMs));
199
- RefreshSession.isBearerAuth = (config) => {
200
- // @ts-ignore
201
- if (config?.headers?.Authorization?.toLowerCase().indexOf('bearer') > -1) {
202
- return true;
203
- }
204
- return false;
258
+ // src/constants/IamErrorCode.ts
259
+ var IamErrorCode = /* @__PURE__ */ ((IamErrorCode2) => {
260
+ IamErrorCode2[IamErrorCode2["InternalServerError"] = 2e4] = "InternalServerError";
261
+ IamErrorCode2[IamErrorCode2["UnauthorizedAccess"] = 20001] = "UnauthorizedAccess";
262
+ IamErrorCode2[IamErrorCode2["ValidationError"] = 20002] = "ValidationError";
263
+ IamErrorCode2[IamErrorCode2["ForbiddenAccess"] = 20003] = "ForbiddenAccess";
264
+ IamErrorCode2[IamErrorCode2["TooManyRequests"] = 20007] = "TooManyRequests";
265
+ IamErrorCode2[IamErrorCode2["UserNotFound"] = 20008] = "UserNotFound";
266
+ IamErrorCode2[IamErrorCode2["TokenIsExpired"] = 20011] = "TokenIsExpired";
267
+ IamErrorCode2[IamErrorCode2["InsufficientPermissions"] = 20013] = "InsufficientPermissions";
268
+ IamErrorCode2[IamErrorCode2["InvalidAudience"] = 20014] = "InvalidAudience";
269
+ IamErrorCode2[IamErrorCode2["InsufficientScope"] = 20015] = "InsufficientScope";
270
+ IamErrorCode2[IamErrorCode2["UnableToParseRequestBody"] = 20019] = "UnableToParseRequestBody";
271
+ IamErrorCode2[IamErrorCode2["InvalidPaginationParameters"] = 20021] = "InvalidPaginationParameters";
272
+ IamErrorCode2[IamErrorCode2["TokenIsNotUserToken"] = 20022] = "TokenIsNotUserToken";
273
+ IamErrorCode2[IamErrorCode2["InvalidRefererHeader"] = 20023] = "InvalidRefererHeader";
274
+ IamErrorCode2[IamErrorCode2["SubdomainMismatch"] = 20030] = "SubdomainMismatch";
275
+ return IamErrorCode2;
276
+ })(IamErrorCode || {});
277
+
278
+ // src/constants/LinkAccount.ts
279
+ var ERROR_LINK_ANOTHER_3RD_PARTY_ACCOUNT = 10200;
280
+ var ERROR_CODE_LINK_DELETION_ACCOUNT = 10135;
281
+ var ERROR_CODE_TOKEN_EXPIRED = 10196;
282
+ var ERROR_USER_BANNED = 10134;
283
+
284
+ // src/interceptors/AuthInterceptors.ts
285
+ import axios3 from "axios";
286
+
287
+ // src/utils/DesktopChecker.ts
288
+ var _DesktopChecker = class _DesktopChecker {
289
+ static isDesktopApp() {
290
+ return _DesktopChecker.desktopApp && !_DesktopChecker.isInIframe();
291
+ }
292
+ static isInIframe() {
293
+ try {
294
+ return window.self !== window.top;
295
+ } catch (error) {
296
+ return true;
297
+ }
298
+ }
299
+ // borrowed from https://github.com/cheton/is-electron
300
+ static isElectron() {
301
+ if (typeof window !== "undefined" && typeof window.process === "object" && window.process.type === "renderer") {
302
+ return true;
303
+ }
304
+ if (typeof process !== "undefined" && typeof process.versions === "object" && !!process.versions.electron) {
305
+ return true;
306
+ }
307
+ if (typeof navigator === "object" && typeof navigator.userAgent === "string" && navigator.userAgent.indexOf("Electron") >= 0) {
308
+ return true;
309
+ }
310
+ return false;
311
+ }
205
312
  };
313
+ _DesktopChecker.desktopApp = _DesktopChecker.isElectron();
314
+ var DesktopChecker = _DesktopChecker;
206
315
 
207
- /*
208
- * Copyright (c) 2022 AccelByte Inc. All Rights Reserved
209
- * This is licensed software from AccelByte Inc, for limitations
210
- * and restrictions contact your company contract manager.
211
- */
212
- class CodeGenUtil {
213
- /**
214
- * Returns a hash code from a string
215
- * @param {String} str The string to hash.
216
- * @return {Number} A 32bit integer
217
- * @see http://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/
218
- */
219
- static hashCode(str) {
220
- let hash = 0;
221
- for (let i = 0, len = str.length; i < len; i++) {
222
- const chr = str.charCodeAt(i);
223
- hash = (hash << 5) - hash + chr;
224
- hash |= 0; // Convert to 32bit integer
225
- }
226
- return hash;
227
- }
228
- }
229
- CodeGenUtil.getFormUrlEncodedData = (data) => {
230
- const formPayload = new URLSearchParams();
231
- const formKeys = Object.keys(data);
232
- formKeys.forEach(key => {
233
- if (typeof data[key] !== 'undefined')
234
- formPayload.append(key, data[key]);
235
- });
236
- return formPayload;
316
+ // src/utils/BrowserHelper.ts
317
+ var BrowserHelper = class {
318
+ };
319
+ BrowserHelper.isOnBrowser = () => {
320
+ return typeof window !== "undefined" && window.document;
237
321
  };
238
322
 
239
- /*
240
- * Copyright (c) 2022 AccelByte Inc. All Rights Reserved
241
- * This is licensed software from AccelByte Inc, for limitations
242
- * and restrictions contact your company contract manager.
243
- */
244
- // TODO replace with Winston
245
- class Logger {
246
- static info(message, object = '') {
247
- _log('info:', message, object);
248
- }
249
- static warn(message, object = '') {
250
- _log('warn:', message, object);
251
- }
252
- static error(message, object = '') {
253
- _log('error:', message, object);
254
- }
255
- }
256
- const _log = (type, message = '', object = '') => {
257
- if (type === 'error:') {
258
- console.error('\x1b[31m%s\x1b[0m', type, message, object);
259
- }
260
- else {
261
- console.log('\x1b[34m%s\x1b[0m', type, message, object); // blue
262
- }
323
+ // src/utils/RefreshSession.ts
324
+ var _RefreshSession = class _RefreshSession {
325
+ };
326
+ // --
327
+ _RefreshSession.KEY = "RefreshSession.lock";
328
+ _RefreshSession.isLocked = () => {
329
+ if (!BrowserHelper.isOnBrowser()) return false;
330
+ const lockStatus = localStorage.getItem(_RefreshSession.KEY);
331
+ if (!lockStatus) {
332
+ return false;
333
+ }
334
+ const lockExpiry = Number(lockStatus);
335
+ if (isNaN(lockExpiry)) {
336
+ return false;
337
+ }
338
+ return lockExpiry > (/* @__PURE__ */ new Date()).getTime();
339
+ };
340
+ _RefreshSession.lock = (expiry) => {
341
+ if (!BrowserHelper.isOnBrowser()) return;
342
+ localStorage.setItem(_RefreshSession.KEY, `${(/* @__PURE__ */ new Date()).getTime() + expiry}`);
343
+ };
344
+ _RefreshSession.unlock = () => {
345
+ if (!BrowserHelper.isOnBrowser()) return;
346
+ localStorage.removeItem(_RefreshSession.KEY);
263
347
  };
348
+ _RefreshSession.sleepAsync = (timeInMs) => new Promise((resolve) => setTimeout(resolve, timeInMs));
349
+ _RefreshSession.isBearerAuth = (config) => {
350
+ var _a, _b;
351
+ if (((_b = (_a = config == null ? void 0 : config.headers) == null ? void 0 : _a.Authorization) == null ? void 0 : _b.toLowerCase().indexOf("bearer")) > -1) {
352
+ return true;
353
+ }
354
+ return false;
355
+ };
356
+ var RefreshSession = _RefreshSession;
264
357
 
265
- class Validate {
266
- static validateOrReturnResponse(useSchemaValidation, networkCall, Codec, modelName) {
267
- return useSchemaValidation ? Validate.responseType(() => networkCall(), Codec, modelName) : Validate.unsafeResponse(() => networkCall());
268
- }
269
- static responseType(networkCall, Codec, modelName) {
270
- return wrapNetworkCallSafely(async () => {
271
- const response = await networkCall();
272
- const decodeResult = Codec.safeParse(response.data);
273
- if (!decodeResult.success && response.status !== 204) {
274
- throw new DecodeError({ error: decodeResult.error, response, modelName });
275
- }
276
- return response;
277
- });
278
- }
279
- static unsafeResponse(networkCall) {
280
- return wrapNetworkCallSafely(() => networkCall());
281
- }
282
- static safeParse(data, Codec) {
283
- const result = Codec.safeParse(data);
284
- if (result.success) {
285
- return result.data;
286
- }
287
- return null;
288
- }
289
- }
290
- async function wrapNetworkCallSafely(networkCallFunction) {
291
- try {
292
- const response = await networkCallFunction();
293
- // Cleanup so we avoid polluting the response
294
- // @ts-ignore
295
- delete response.headers; // perhaps this may be required?
296
- // @ts-ignore
297
- delete response.statusText;
298
- // @ts-ignore
299
- delete response.config; // axios specific
300
- delete response.request;
301
- return { response, error: null };
302
- }
303
- catch (error) {
304
- return { response: null, error: error };
305
- }
306
- }
307
- class DecodeError extends Error {
308
- constructor({ error, response, modelName }) {
309
- const msg = `response from url "${response.config.url}" doesn't match model "${modelName}"`;
310
- super(msg);
311
- Logger.error(msg, error);
312
- }
313
- }
358
+ // ../sdk-iam/src/generated-definitions/TokenWithDeviceCookieResponseV3.ts
359
+ import { z as z4 } from "zod";
314
360
 
315
- /*
316
- * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved
317
- * This is licensed software from AccelByte Inc, for limitations
318
- * and restrictions contact your company contract manager.
319
- */
320
- const JwtBanV3 = z.object({
321
- ban: z.string(),
322
- disabledDate: z.string().nullish(),
323
- enabled: z.boolean(),
324
- endDate: z.string(),
325
- targetedNamespace: z.string()
361
+ // ../sdk-iam/src/generated-definitions/JwtBanV3.ts
362
+ import { z } from "zod";
363
+ var JwtBanV3 = z.object({
364
+ ban: z.string(),
365
+ disabledDate: z.string().nullish(),
366
+ enabled: z.boolean(),
367
+ endDate: z.string(),
368
+ targetedNamespace: z.string()
326
369
  });
327
370
 
328
- /*
329
- * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved
330
- * This is licensed software from AccelByte Inc, for limitations
331
- * and restrictions contact your company contract manager.
332
- */
333
- const NamespaceRole = z.object({ namespace: z.string(), roleId: z.string() });
371
+ // ../sdk-iam/src/generated-definitions/NamespaceRole.ts
372
+ import { z as z2 } from "zod";
373
+ var NamespaceRole = z2.object({ namespace: z2.string(), roleId: z2.string() });
334
374
 
335
- /*
336
- * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved
337
- * This is licensed software from AccelByte Inc, for limitations
338
- * and restrictions contact your company contract manager.
339
- */
340
- const PermissionV3 = z.object({
341
- action: z.number().int(),
342
- resource: z.string(),
343
- schedAction: z.number().int().nullish(),
344
- schedCron: z.string().nullish(),
345
- schedRange: z.array(z.string()).nullish()
375
+ // ../sdk-iam/src/generated-definitions/PermissionV3.ts
376
+ import { z as z3 } from "zod";
377
+ var PermissionV3 = z3.object({
378
+ action: z3.number().int(),
379
+ resource: z3.string(),
380
+ schedAction: z3.number().int().nullish(),
381
+ schedCron: z3.string().nullish(),
382
+ schedRange: z3.array(z3.string()).nullish()
346
383
  });
347
384
 
348
- /*
349
- * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved
350
- * This is licensed software from AccelByte Inc, for limitations
351
- * and restrictions contact your company contract manager.
352
- */
353
- const TokenWithDeviceCookieResponseV3 = z.object({
354
- access_token: z.string(),
355
- auth_trust_id: z.string().nullish(),
356
- bans: z.array(JwtBanV3).nullish(),
357
- display_name: z.string().nullish(),
358
- expires_in: z.number().int(),
359
- is_comply: z.boolean().nullish(),
360
- jflgs: z.number().int().nullish(),
361
- namespace: z.string(),
362
- namespace_roles: z.array(NamespaceRole).nullish(),
363
- permissions: z.array(PermissionV3),
364
- platform_id: z.string().nullish(),
365
- platform_user_id: z.string().nullish(),
366
- refresh_expires_in: z.number().int().nullish(),
367
- refresh_token: z.string().nullish(),
368
- roles: z.array(z.string()).nullish(),
369
- scope: z.string(),
370
- simultaneous_platform_id: z.string().nullish(),
371
- simultaneous_platform_user_id: z.string().nullish(),
372
- token_type: z.string(),
373
- unique_display_name: z.string().nullish(),
374
- user_id: z.string().nullish(),
375
- xuid: z.string().nullish()
385
+ // ../sdk-iam/src/generated-definitions/TokenWithDeviceCookieResponseV3.ts
386
+ var TokenWithDeviceCookieResponseV3 = z4.object({
387
+ access_token: z4.string(),
388
+ auth_trust_id: z4.string().nullish(),
389
+ bans: z4.array(JwtBanV3).nullish(),
390
+ display_name: z4.string().nullish(),
391
+ expires_in: z4.number().int(),
392
+ is_comply: z4.boolean().nullish(),
393
+ jflgs: z4.number().int().nullish(),
394
+ namespace: z4.string(),
395
+ namespace_roles: z4.array(NamespaceRole).nullish(),
396
+ permissions: z4.array(PermissionV3),
397
+ platform_id: z4.string().nullish(),
398
+ platform_user_id: z4.string().nullish(),
399
+ refresh_expires_in: z4.number().int().nullish(),
400
+ refresh_token: z4.string().nullish(),
401
+ roles: z4.array(z4.string()).nullish(),
402
+ scope: z4.string(),
403
+ simultaneous_platform_id: z4.string().nullish(),
404
+ simultaneous_platform_user_id: z4.string().nullish(),
405
+ token_type: z4.string(),
406
+ unique_display_name: z4.string().nullish(),
407
+ user_id: z4.string().nullish(),
408
+ xuid: z4.string().nullish()
376
409
  });
377
410
 
378
- /*
379
- * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved
380
- * This is licensed software from AccelByte Inc, for limitations
381
- * and restrictions contact your company contract manager.
382
- */
383
- class OAuth20$ {
384
- // @ts-ignore
385
- constructor(axiosInstance, namespace) {
386
- this.axiosInstance = axiosInstance;
387
- this.namespace = namespace;
388
- }
389
- postOauthToken(data) {
390
- const params = {};
391
- const url = '/iam/v3/oauth/token';
392
- const resultPromise = this.axiosInstance.post(url, CodeGenUtil.getFormUrlEncodedData(data), {
393
- ...params,
394
- headers: { ...params.headers, 'content-type': 'application/x-www-form-urlencoded' }
395
- });
396
- return Validate.responseType(() => resultPromise, TokenWithDeviceCookieResponseV3, 'TokenWithDeviceCookieResponseV3');
397
- }
398
- }
411
+ // src/utils/CodeGenUtil.ts
412
+ var CodeGenUtil = class {
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) {
420
+ let hash = 0;
421
+ for (let i = 0, len = str.length; i < len; i++) {
422
+ const chr = str.charCodeAt(i);
423
+ hash = (hash << 5) - hash + chr;
424
+ hash |= 0;
425
+ }
426
+ return hash;
427
+ }
428
+ };
429
+ CodeGenUtil.getFormUrlEncodedData = (data) => {
430
+ const formPayload = new URLSearchParams();
431
+ const formKeys = Object.keys(data);
432
+ formKeys.forEach((key) => {
433
+ if (typeof data[key] !== "undefined") formPayload.append(key, data[key]);
434
+ });
435
+ return formPayload;
436
+ };
399
437
 
400
- /*
401
- * Copyright (c) 2022 AccelByte Inc. All Rights Reserved
402
- * This is licensed software from AccelByte Inc, for limitations
403
- * and restrictions contact your company contract manager.
404
- */
405
- class DesktopChecker {
406
- static isDesktopApp() {
407
- return DesktopChecker.desktopApp && !DesktopChecker.isInIframe();
408
- }
409
- static isInIframe() {
410
- try {
411
- return window.self !== window.top;
412
- }
413
- catch (error) {
414
- return true;
415
- }
416
- }
417
- // borrowed from https://github.com/cheton/is-electron
418
- static isElectron() {
419
- // @ts-ignore Renderer process
420
- if (typeof window !== 'undefined' && typeof window.process === 'object' && window.process.type === 'renderer') {
421
- return true;
422
- }
423
- // Main process
424
- if (typeof process !== 'undefined' && typeof process.versions === 'object' && !!process.versions.electron) {
425
- return true;
426
- }
427
- // Detect the user agent when the `nodeIntegration` option is set to false
428
- if (typeof navigator === 'object' && typeof navigator.userAgent === 'string' && navigator.userAgent.indexOf('Electron') >= 0) {
429
- return true;
430
- }
431
- return false;
432
- }
433
- }
434
- DesktopChecker.desktopApp = DesktopChecker.isElectron();
438
+ // src/utils/Validate.ts
439
+ var Validate = class _Validate {
440
+ static validateOrReturnResponse(useSchemaValidation, networkCall, Codec, modelName) {
441
+ return useSchemaValidation ? _Validate.responseType(() => networkCall(), Codec, modelName) : _Validate.unsafeResponse(() => networkCall());
442
+ }
443
+ static responseType(networkCall, Codec, modelName) {
444
+ return wrapNetworkCallSafely(async () => {
445
+ const response = await networkCall();
446
+ const decodeResult = Codec.safeParse(response.data);
447
+ if (!decodeResult.success && response.status !== 204) {
448
+ throw new DecodeError({ error: decodeResult.error, response, modelName });
449
+ }
450
+ return response;
451
+ });
452
+ }
453
+ static unsafeResponse(networkCall) {
454
+ return wrapNetworkCallSafely(() => networkCall());
455
+ }
456
+ static safeParse(data, Codec) {
457
+ const result = Codec.safeParse(data);
458
+ if (result.success) {
459
+ return result.data;
460
+ }
461
+ return null;
462
+ }
463
+ };
464
+ async function wrapNetworkCallSafely(networkCallFunction) {
465
+ try {
466
+ const response = await networkCallFunction();
467
+ return { response, error: null };
468
+ } catch (error) {
469
+ return { response: null, error };
470
+ }
471
+ }
472
+ var DecodeError = class extends Error {
473
+ constructor({ error, response, modelName }) {
474
+ const msg = `response from url "${response.config.url}" doesn't match model "${modelName}"`;
475
+ super(msg);
476
+ console.error(msg, error);
477
+ }
478
+ };
435
479
 
436
- /*
437
- * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved
438
- * This is licensed software from AccelByte Inc, for limitations
439
- * and restrictions contact your company contract manager.
440
- */
441
- const REFRESH_EXPIRY = 1000;
442
- const REFRESH_EXPIRY_UPDATE_RATE = 500;
443
- const REFRESH_EXPIRY_CHECK_RATE = 1000;
444
- var LoginUrls;
445
- (function (LoginUrls) {
446
- LoginUrls["GRANT_TOKEN"] = "/iam/v3/oauth/token";
447
- LoginUrls["REVOKE"] = "/iam/v3/oauth/revoke";
448
- })(LoginUrls || (LoginUrls = {}));
449
- /* eslint camelcase: 0 */
450
- const refreshSession = ({ axiosConfig, refreshToken, clientId }) => {
451
- const config = {
452
- ...axiosConfig,
453
- withCredentials: false,
454
- headers: {
455
- 'Content-Type': 'application/x-www-form-urlencoded',
456
- Authorization: `Basic ${Buffer.from(`${clientId}:`).toString('base64')}`
457
- }
458
- };
459
- const axios = Network.create(config);
460
- const payload = {
461
- refresh_token: refreshToken || undefined,
462
- client_id: clientId,
463
- grant_type: 'refresh_token'
464
- };
465
- const oauth20 = new OAuth20$(axios, 'NAMESPACE-NOT-REQUIRED');
466
- return oauth20.postOauthToken(payload);
467
- };
468
- // Return Promise<true> if refresh in any tab is successful;
469
- const refreshWithLock = ({ axiosConfig, refreshToken, clientId }) => {
470
- //
471
- if (RefreshSession.isLocked()) {
472
- return Promise.resolve().then(async () => {
473
- // This block is executed when other tab / request is refreshing
474
- while (RefreshSession.isLocked()) {
475
- await RefreshSession.sleepAsync(REFRESH_EXPIRY_CHECK_RATE);
476
- }
477
- return {};
478
- });
479
- }
480
- RefreshSession.lock(REFRESH_EXPIRY);
481
- let isLocallyRefreshingToken = true;
482
- (async () => {
483
- // eslint-disable-next-line no-unmodified-loop-condition
484
- while (isLocallyRefreshingToken) {
485
- RefreshSession.lock(REFRESH_EXPIRY);
486
- await RefreshSession.sleepAsync(REFRESH_EXPIRY_UPDATE_RATE);
487
- }
488
- })();
489
- return Promise.resolve()
490
- .then(doRefreshSession({ axiosConfig, clientId, refreshToken }))
491
- .finally(() => {
492
- isLocallyRefreshingToken = false;
493
- RefreshSession.unlock();
494
- });
495
- };
496
- const doRefreshSession = ({ axiosConfig, clientId, refreshToken }) => async () => {
497
- // we need this to check if app use “withCredentials: false” and don’t have refreshToken it should return false,
498
- // because we track it as a logout user, if not do this even user logout on the desktop app (that use withCredentials: false)
499
- // will automatically login with refreshSession
500
- if (DesktopChecker.isDesktopApp() && !axiosConfig.withCredentials && !refreshToken) {
501
- return false;
502
- }
503
- const result = await refreshSession({ axiosConfig, clientId, refreshToken });
504
- if (result.error) {
505
- return false;
506
- }
507
- return result.response.data;
508
- };
509
- const injectAuthInterceptors = (clientId, getSDKConfig, onSessionExpired, onGetUserSession, getRefreshToken) => {
510
- // ===== request
511
- injectRequestInterceptors(async (config) => {
512
- // need to lock on the desktop as well to sleep other request before refresh session is done
513
- const isRefreshTokenUrl = config.url === LoginUrls.GRANT_TOKEN;
514
- // eslint-disable-next-line no-unmodified-loop-condition
515
- while (RefreshSession.isLocked() && !isRefreshTokenUrl) {
516
- await RefreshSession.sleepAsync(200);
517
- }
518
- return config;
519
- }, (error) => {
520
- return Promise.reject(error);
521
- });
522
- // ===== response
523
- injectResponseInterceptors(response => {
524
- const { config, status } = response;
525
- if (config.url === LoginUrls.GRANT_TOKEN && status === 200 && onGetUserSession) {
526
- const { access_token, refresh_token } = response.data;
527
- if (access_token) {
528
- onGetUserSession(access_token, refresh_token ?? '');
529
- }
530
- }
531
- return response;
532
- }, async (error) => {
533
- const { config, response } = error;
534
- if (axios.isCancel(error)) {
535
- // expected case, exit
536
- throw error;
537
- }
538
- if (!response) {
539
- console.error(`injectResponseInterceptors net::ERR_INTERNET_DISCONNECTED ${config?.baseURL}${config?.url}. ${error.message}\n`);
540
- }
541
- if (response?.status === 401) {
542
- const { url } = config || {};
543
- const axiosConfig = getSDKConfig();
544
- const refreshToken = getRefreshToken ? getRefreshToken() : undefined;
545
- // expected business case, exit
546
- // @ts-ignore
547
- if (Object.values(LoginUrls).includes(url)) {
548
- throw error;
549
- }
550
- // need to lock on the desktop as well to prevent multiple token request
551
- return refreshWithLock({ axiosConfig, clientId, refreshToken }).then(tokenResponse => {
552
- return uponRefreshComplete(error, tokenResponse, onSessionExpired, axiosConfig, config || {});
553
- });
554
- }
555
- return Promise.reject(error);
556
- });
557
- };
558
- const uponRefreshComplete = (error, tokenResponse, onSessionExpired, axiosConfig, errorConfig) => {
559
- //
560
- if (tokenResponse) {
561
- const { access_token } = tokenResponse;
562
- // desktop
563
- if (!axiosConfig.withCredentials && access_token) {
564
- return axios({
565
- ...errorConfig,
566
- headers: {
567
- ...errorConfig.headers,
568
- Authorization: `Bearer ${access_token}`
569
- }
570
- });
571
- // web
572
- }
573
- else {
574
- return axios(errorConfig);
575
- }
576
- }
577
- if (onSessionExpired) {
578
- onSessionExpired();
579
- }
580
- throw error;
480
+ // src/interceptors/AuthInterceptorDeps.ts
481
+ var OAuth20$ = class {
482
+ // @ts-ignore
483
+ constructor(axiosInstance) {
484
+ this.axiosInstance = axiosInstance;
485
+ }
486
+ postOauthToken(data) {
487
+ const params = {};
488
+ const url = "/iam/v3/oauth/token";
489
+ const resultPromise = this.axiosInstance.post(url, CodeGenUtil.getFormUrlEncodedData(data), {
490
+ ...params,
491
+ headers: { ...params.headers, "content-type": "application/x-www-form-urlencoded" }
492
+ });
493
+ return Validate.responseType(() => resultPromise, TokenWithDeviceCookieResponseV3, "TokenWithDeviceCookieResponseV3");
494
+ }
495
+ };
496
+ var OAuth20V4$ = class {
497
+ // @ts-ignore
498
+ // prettier-ignore
499
+ constructor(axiosInstance) {
500
+ this.axiosInstance = axiosInstance;
501
+ }
502
+ /**
503
+ * This endpoint supports grant type: 1. Grant Type == &lt;code&gt;authorization_code&lt;/code&gt;: It generates the user token by given the authorization code which generated in &#34;/iam/v3/authenticate&#34; API response. It should also pass in the redirect_uri, which should be the same as generating the authorization code request. 2. Grant Type == &lt;code&gt;password&lt;/code&gt;: The grant type to use for authenticating a user, whether it&#39;s by email / username and password combination or through platform. 3. Grant Type == &lt;code&gt;refresh_token&lt;/code&gt;: Used to get a new access token for a valid refresh token. 4. Grant Type == &lt;code&gt;client_credentials&lt;/code&gt;: It generates a token by checking the client credentials provided through Authorization header. 5. Grant Type == &lt;code&gt;urn:ietf:params:oauth:grant-type:extend_client_credentials&lt;/code&gt;: It generates a token by checking the client credentials provided through Authorization header. It only allows publisher/studio namespace client. In generated token: 1. There wil be no roles, namespace_roles &amp; permission. 2. The scope will be fixed as &#39;extend&#39;. 3. There will have a new field &#39;extend_namespace&#39;, the value is from token request body. 6. Grant Type == &lt;code&gt;urn:ietf:params:oauth:grant-type:login_queue_ticket&lt;/code&gt;: It generates a token by validating the login queue ticket against login queue service. ## Access Token Content Following is the access token’s content: - **namespace**. It is the namespace the token was generated from. - **display_name**. The display name of the sub. It is empty if the token is generated from the client credential - **roles**. The sub’s roles. It is empty if the token is generated from the client credential - **namespace_roles**. The sub’s roles scoped to namespace. Improvement from roles, which make the role scoped to specific namespace instead of global to publisher namespace - **permissions**. The sub or aud’ permissions - **bans**. The sub’s list of bans. It is used by the IAM client for validating the token. - **jflgs**. It stands for Justice Flags. It is a special flag used for storing additional status information regarding the sub. It is implemented as a bit mask. Following explains what each bit represents: - 1: Email Address Verified - 2: Phone Number Verified - 4: Anonymous - 8: Suspicious Login - **aud**. The aud is the targeted resource server. - **iat**. The time the token issues at. It is in Epoch time format - **exp**. The time the token expires. It is in Epoch time format - **client_id**. The UserID. The sub is omitted if the token is generated from client credential - **scope**. The scope of the access request, expressed as a list of space-delimited, case-sensitive strings ## Bans The JWT contains user&#39;s active bans with its expiry date. List of ban types can be obtained from /bans. ## Device Cookie Validation _**For grant type &#34;password&#34; only**_ Device Cookie is used to protect the user account from brute force login attack, &lt;a target=&#34;_blank&#34; href=&#34;https://owasp.org/www-community/Slow_Down_Online_Guessing_Attacks_with_Device_Cookies&#34;&gt;more detail from OWASP&lt;a&gt;. This endpoint will read device cookie from request header **Auth-Trust-Id**. If device cookie not found, it will generate a new one and set it into response body **auth_trust_id** when successfully login. ## Track Login History This endpoint will track login history to detect suspicious login activity, please provide **Device-Id** (alphanumeric) in request header parameter otherwise it will set to &#34;unknown&#34;. Align with General Data Protection Regulation in Europe, user login history will be kept within 28 days by default&#34; ## 2FA remember device To remember device for 2FA, should provide cookie: device_token or header: Device-Token ## Response note If it is a user token request and user hasn&#39;t accepted required legal policy, the field &lt;code&gt;is_comply&lt;/code&gt; will be false in response and responsed token will have no permission. action code: 10703
504
+ */
505
+ postOauthToken_v4(data, queryParams) {
506
+ const params = { code_challenge_method: "plain", ...queryParams };
507
+ const url = "/iam/v4/oauth/token";
508
+ const resultPromise = this.axiosInstance.post(url, CodeGenUtil.getFormUrlEncodedData(data), {
509
+ ...params,
510
+ headers: { ...params.headers, "content-type": "application/x-www-form-urlencoded" }
511
+ });
512
+ return Validate.responseType(() => resultPromise, TokenWithDeviceCookieResponseV3, "TokenWithDeviceCookieResponseV3");
513
+ }
581
514
  };
582
515
 
583
- /*
584
- * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved
585
- * This is licensed software from AccelByte Inc, for limitations
586
- * and restrictions contact your company contract manager.
587
- */
588
- class ApiUtils {
589
- }
590
- ApiUtils.mergedConfigs = (config, overrides) => {
591
- return {
592
- ...config,
593
- ...overrides?.config,
594
- headers: {
595
- ...config.headers,
596
- ...overrides?.config?.headers
597
- }
598
- };
516
+ // src/interceptors/AuthInterceptors.ts
517
+ var REFRESH_EXPIRY = 1e3;
518
+ var REFRESH_EXPIRY_UPDATE_RATE = 500;
519
+ var REFRESH_EXPIRY_CHECK_RATE = 1e3;
520
+ var GrantTokenUrls = /* @__PURE__ */ ((GrantTokenUrls2) => {
521
+ GrantTokenUrls2["GRANT_TOKEN"] = "/iam/v3/oauth/token";
522
+ GrantTokenUrls2["GRANT_TOKEN_V4"] = "/iam/v4/oauth/token";
523
+ return GrantTokenUrls2;
524
+ })(GrantTokenUrls || {});
525
+ var LoginUrls = /* @__PURE__ */ ((LoginUrls2) => {
526
+ LoginUrls2["REVOKE"] = "/iam/v3/oauth/revoke";
527
+ return LoginUrls2;
528
+ })(LoginUrls || {});
529
+ var noOp = () => {
530
+ };
531
+ var RefreshToken = class {
532
+ constructor({ config, interceptors }) {
533
+ // Return Promise<true> if refresh in any tab is successful;
534
+ this.runWithLock = () => {
535
+ if (RefreshSession.isLocked()) {
536
+ return Promise.resolve().then(async () => {
537
+ while (RefreshSession.isLocked()) {
538
+ await RefreshSession.sleepAsync(REFRESH_EXPIRY_CHECK_RATE);
539
+ }
540
+ return {};
541
+ });
542
+ }
543
+ RefreshSession.lock(REFRESH_EXPIRY);
544
+ let isLocallyRefreshingToken = true;
545
+ (async () => {
546
+ while (isLocallyRefreshingToken) {
547
+ RefreshSession.lock(REFRESH_EXPIRY);
548
+ await RefreshSession.sleepAsync(REFRESH_EXPIRY_UPDATE_RATE);
549
+ }
550
+ })();
551
+ return Promise.resolve().then(() => this.run()).finally(() => {
552
+ isLocallyRefreshingToken = false;
553
+ RefreshSession.unlock();
554
+ });
555
+ };
556
+ this.run = async () => {
557
+ const { axiosConfig, refreshToken } = this.config;
558
+ if (DesktopChecker.isDesktopApp() && !axiosConfig.withCredentials && !refreshToken) {
559
+ return false;
560
+ }
561
+ const result = await this.refreshToken();
562
+ if (result.error) {
563
+ return false;
564
+ }
565
+ return result.response.data;
566
+ };
567
+ this.refreshToken = () => {
568
+ const { axiosConfig, refreshToken, clientId, tokenUrl } = this.config;
569
+ const config = {
570
+ ...axiosConfig,
571
+ /**
572
+ * Ideally `withCredentials` should be `true` to make sure that
573
+ * cookies always included when refreshing token
574
+ * especially on cross-origin requests.
575
+ * But if `refreshToken` is provided (e.g. from Launcher),
576
+ * we can set it to false and send refresh_token via payload.
577
+ */
578
+ withCredentials: !refreshToken,
579
+ headers: {
580
+ "Content-Type": "application/x-www-form-urlencoded",
581
+ Authorization: `Basic ${Buffer.from(`${clientId}:`).toString("base64")}`
582
+ }
583
+ };
584
+ const axios4 = Network.create(config);
585
+ for (const interceptor of this.interceptors) {
586
+ if (interceptor.type === "request") {
587
+ axios4.interceptors.request.use(interceptor == null ? void 0 : interceptor.onRequest, interceptor.onError);
588
+ }
589
+ if (interceptor.type === "response") {
590
+ axios4.interceptors.response.use(interceptor == null ? void 0 : interceptor.onSuccess, interceptor.onError);
591
+ }
592
+ }
593
+ const payload = {
594
+ refresh_token: refreshToken || void 0,
595
+ client_id: clientId,
596
+ grant_type: "refresh_token"
597
+ };
598
+ if (tokenUrl === "/iam/v4/oauth/token" /* GRANT_TOKEN_V4 */) {
599
+ return new OAuth20V4$(axios4).postOauthToken_v4(payload);
600
+ }
601
+ const oauth20 = new OAuth20$(axios4);
602
+ return oauth20.postOauthToken(payload);
603
+ };
604
+ this.config = config;
605
+ this.interceptors = interceptors || [];
606
+ }
599
607
  };
608
+ var refreshComplete = (error, tokenResponse, onSessionExpired, axiosConfig, errorConfig) => {
609
+ if (tokenResponse) {
610
+ const { access_token } = tokenResponse;
611
+ if (!axiosConfig.withCredentials && access_token) {
612
+ return axios3({
613
+ ...errorConfig,
614
+ headers: {
615
+ ...errorConfig.headers,
616
+ Authorization: `Bearer ${access_token}`
617
+ }
618
+ });
619
+ } else {
620
+ return axios3(errorConfig);
621
+ }
622
+ }
623
+ if (onSessionExpired) {
624
+ onSessionExpired();
625
+ }
626
+ throw error;
627
+ };
628
+ var createAuthInterceptor = ({
629
+ clientId,
630
+ onSessionExpired,
631
+ onGetUserSession,
632
+ expectedErrorUrls = Object.values({ ...LoginUrls, ...GrantTokenUrls }),
633
+ getRefreshToken,
634
+ tokenUrl = "/iam/v3/oauth/token" /* GRANT_TOKEN */
635
+ }) => {
636
+ return {
637
+ type: "response",
638
+ name: "session-expired",
639
+ onError: (e) => {
640
+ const error = e;
641
+ const { config, response } = error;
642
+ if (axios3.isCancel(error)) {
643
+ return Promise.reject(error);
644
+ }
645
+ if (!response) {
646
+ console.warn(`sdk:ERR_INTERNET_DISCONNECTED ${config == null ? void 0 : config.baseURL}${config == null ? void 0 : config.url}. ${error.message}
647
+ `);
648
+ }
649
+ if ((response == null ? void 0 : response.status) === 401) {
650
+ const { url } = config || {};
651
+ const axiosConfig = config;
652
+ const refreshToken = getRefreshToken == null ? void 0 : getRefreshToken();
653
+ if (!url || url && expectedErrorUrls.includes(url)) {
654
+ return Promise.reject(error);
655
+ }
656
+ const refresh = new RefreshToken({
657
+ config: { axiosConfig, clientId, refreshToken, tokenUrl },
658
+ interceptors: [
659
+ createRefreshSessionInterceptor({ tokenUrl }),
660
+ createGetSessionInterceptor({ onGetUserSession: onGetUserSession || noOp, tokenUrl })
661
+ ]
662
+ });
663
+ return refresh.runWithLock().then((tokenResponse) => {
664
+ return refreshComplete(error, tokenResponse, onSessionExpired, axiosConfig, config || {});
665
+ });
666
+ }
667
+ return Promise.reject(error);
668
+ }
669
+ };
670
+ };
671
+ var createRefreshSessionInterceptor = (options) => {
672
+ const { tokenUrl = "/iam/v3/oauth/token" /* GRANT_TOKEN */ } = options || {};
673
+ return {
674
+ type: "request",
675
+ name: "refresh-session",
676
+ onError: (error) => Promise.reject(error),
677
+ onRequest: async (config) => {
678
+ const isRefreshTokenUrl = config.url === tokenUrl;
679
+ while (RefreshSession.isLocked() && !isRefreshTokenUrl) {
680
+ await RefreshSession.sleepAsync(200);
681
+ }
682
+ return config;
683
+ }
684
+ };
685
+ };
686
+ var createGetSessionInterceptor = ({
687
+ tokenUrl = "/iam/v3/oauth/token" /* GRANT_TOKEN */,
688
+ onGetUserSession
689
+ }) => ({
690
+ type: "response",
691
+ name: "get-session",
692
+ onError: (error) => Promise.reject(error),
693
+ onSuccess: (response) => {
694
+ const { config, status } = response;
695
+ if (config.url === tokenUrl && status === 200) {
696
+ const { access_token, refresh_token } = response.data;
697
+ if (access_token) {
698
+ onGetUserSession(access_token, refresh_token ?? "");
699
+ }
700
+ }
701
+ return response;
702
+ }
703
+ });
600
704
 
601
- /*
602
- * Copyright (c) 2023 AccelByte Inc. All Rights Reserved
603
- * This is licensed software from AccelByte Inc, for limitations
604
- * and restrictions contact your company contract manager.
605
- */
606
- const internalServiceMap = {
607
- '/achievement': 'justice-achievement-service',
608
- '/basic': 'justice-basic-service',
609
- '/buildinfo': 'justice-buildinfo-service',
610
- '/chat': 'justice-chat-service',
611
- '/cloudsave': 'justice-cloudsave-service',
612
- '/content-management': 'justice-odin-content-management-service',
613
- '/differ': 'justice-differ',
614
- '/dsmcontroller': 'justice-dsm-controller-service',
615
- '/event': 'justice-event-log-service',
616
- '/game-telemetry': 'analytics-game-telemetry-api',
617
- '/gdpr': 'justice-gdpr-service',
618
- '/group': 'justice-group-service',
619
- '/iam': 'justice-iam-service',
620
- '/leaderboard': 'justice-leaderboard-service',
621
- '/agreement': 'justice-legal-service',
622
- '/lobby': 'justice-lobby-server',
623
- '/match2': 'justice-matchmaking-v2',
624
- '/matchmaking': 'justice-matchmaking',
625
- '/odin-config': 'justice-odin-config-service',
626
- '/platform': 'justice-platform-service',
627
- '/qosm': 'justice-qos-manager-service',
628
- '/reporting': 'justice-reporting-service',
629
- '/seasonpass': 'justice-seasonpass-service',
630
- '/session': 'justice-session-service',
631
- '/sessionbrowser': 'justice-session-browser-service',
632
- '/social': 'justice-social-service',
633
- '/ugc': 'justice-ugc-service',
634
- '/config': 'justice-config-service'
635
- };
636
- const injectInternalNetworkInterceptors = () => {
637
- injectRequestInterceptors(async (config) => {
638
- const { url } = config;
639
- if (url) {
640
- // url example = "/iam/v1/..."
641
- const firstPath = url.split('/')[1];
642
- const internalServiceName = internalServiceMap[`/${firstPath}`];
643
- if (internalServiceName) {
644
- config.baseURL = `http://${internalServiceName}`;
645
- // final url will be
646
- // http://${service-name}/{url}
647
- }
648
- }
649
- return config;
650
- }, (error) => {
651
- return Promise.reject(error);
652
- });
705
+ // src/constants/paths.ts
706
+ var INTERNAL_SERVICES = {
707
+ "/achievement": "justice-achievement-service",
708
+ "/basic": "justice-basic-service",
709
+ "/buildinfo": "justice-buildinfo-service",
710
+ "/chat": "justice-chat-service",
711
+ "/cloudsave": "justice-cloudsave-service",
712
+ "/content-management": "justice-odin-content-management-service",
713
+ "/differ": "justice-differ",
714
+ "/dsmcontroller": "justice-dsm-controller-service",
715
+ "/event": "justice-event-log-service",
716
+ "/game-telemetry": "analytics-game-telemetry-api",
717
+ "/gdpr": "justice-gdpr-service",
718
+ "/group": "justice-group-service",
719
+ "/iam": "justice-iam-service",
720
+ "/leaderboard": "justice-leaderboard-service",
721
+ "/agreement": "justice-legal-service",
722
+ // sdk-legal
723
+ "/lobby": "justice-lobby-server",
724
+ "/match2": "justice-matchmaking-v2",
725
+ // sdk-matchmaking
726
+ "/matchmaking": "justice-matchmaking",
727
+ // sdk-matchmaking-v1
728
+ "/odin-config": "justice-odin-config-service",
729
+ "/platform": "justice-platform-service",
730
+ "/qosm": "justice-qos-manager-service",
731
+ "/reporting": "justice-reporting-service",
732
+ "/seasonpass": "justice-seasonpass-service",
733
+ "/session": "justice-session-service",
734
+ "/sessionbrowser": "justice-session-browser-service",
735
+ "/social": "justice-social-service",
736
+ "/ugc": "justice-ugc-service",
737
+ "/config": "justice-config-service"
653
738
  };
654
739
 
655
- /*
656
- * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved
657
- * This is licensed software from AccelByte Inc, for limitations
658
- * and restrictions contact your company contract manager.
659
- */
660
- class AccelbyteSDKImpl {
661
- constructor(options, config, events) {
662
- this.getRefreshToken = () => this.refreshToken;
663
- this.getConfig = () => this.config;
664
- this.refreshTokensImpl = (accessToken, refreshToken) => {
665
- if (refreshToken) {
666
- this.refreshToken = refreshToken;
667
- }
668
- const configOverride = { headers: { Authorization: accessToken ? `Bearer ${accessToken}` : '' } };
669
- this.config = ApiUtils.mergedConfigs(this.config, { config: configOverride });
670
- };
671
- this.options = {
672
- ...options
673
- };
674
- this.events = events;
675
- this.config = {
676
- timeout: 60000,
677
- baseURL: options.baseURL,
678
- withCredentials: true,
679
- ...config,
680
- headers: {
681
- 'Content-Type': 'application/json',
682
- ...config?.headers
683
- }
684
- };
685
- // TODO: instead of having a "global" axios interceptors, we can create the instance here.
686
- // ```
687
- // this.axiosInstance = Network.create(...)
688
- // this.axiosInstance.interceptors.use(...)
689
- // ```
690
- // After that, our SDK assembly will return this axiosInstance, which will be used by each of the service SDKs.
691
- // ```
692
- // const { axiosInstance, opts } = sdk.assembly()
693
- // axiosInstance.defaults = {
694
- // ...axiosInstance.defaults,
695
- // ...args.config,
696
- // headers: {
697
- // ...axiosInstance.defaults.headers,
698
- // ...args.config.headers
699
- // }
700
- // }
701
- // ```
702
- // This way, each of the SDK instance will have their own interceptors and will not "pollute"
703
- // the global axios interceptors. It's easier to test in isolation as well, because with the global
704
- // interceptors, we can't isolate test the SDK instance... or maybe we can, with `axios.interceptors.request.clear`,
705
- // but they can't be done in parallel.
706
- }
707
- init() {
708
- const { baseURL, clientId, customInterceptors, useInternalNetwork } = this.options;
709
- if (customInterceptors) {
710
- injectRequestInterceptors(customInterceptors.request, customInterceptors.error);
711
- injectResponseInterceptors(customInterceptors.response, customInterceptors.error);
712
- }
713
- else {
714
- // Default interceptors.
715
- if (useInternalNetwork) {
716
- injectInternalNetworkInterceptors();
717
- }
718
- injectAuthInterceptors(clientId, this.getConfig, this.events?.onSessionExpired, this.events?.onGetUserSession, this.getRefreshToken);
719
- injectErrorInterceptors({
720
- baseUrl: baseURL,
721
- onError: this.events?.onError,
722
- onUserEligibilityChange: this.events?.onUserEligibilityChange,
723
- onTooManyRequest: this.events?.onTooManyRequest
724
- });
725
- }
726
- // TODO reintegrate doVersionDiagnostics later on
727
- // setTimeout(() => this.doVersionDiagnostics(), TIMEOUT_TO_DIAGNOSTICS)
728
- return {
729
- refreshTokens: (accessToken, refreshToken) => this.refreshTokensImpl(accessToken, refreshToken),
730
- assembly: () => {
731
- return {
732
- config: this.config,
733
- namespace: this.options.namespace,
734
- clientId: this.options.clientId,
735
- redirectURI: this.options.redirectURI,
736
- baseURL: this.options.baseURL,
737
- refreshToken: this.refreshToken,
738
- useSchemaValidation: this.options.useSchemaValidation !== undefined ? this.options.useSchemaValidation : true
739
- };
740
- }
741
- };
742
- }
743
- }
744
- const sdkInit = ({ options, config, onEvents }) => {
745
- const sdkFactory = new AccelbyteSDKImpl(options, config, onEvents);
746
- return sdkFactory.init();
747
- };
748
- // ts-prune-ignore-next
749
- const Accelbyte = { SDK: sdkInit };
740
+ // src/interceptors/CustomPathInterceptor.ts
741
+ var createCustomPathInterceptor = ({ basePath, isInternalNetwork }) => {
742
+ return {
743
+ type: "request",
744
+ name: "custom-base-path",
745
+ onRequest: async (config) => {
746
+ var _a, _b;
747
+ const { url } = config;
748
+ if (url) {
749
+ const firstPath = url.split("/")[1];
750
+ const servicePath = `/${firstPath}`;
751
+ const newBasePath = basePath == null ? void 0 : basePath[servicePath];
752
+ const internalPath = (_a = INTERNAL_SERVICES) == null ? void 0 : _a[servicePath];
753
+ if (isInternalNetwork && internalPath) {
754
+ config.baseURL = `http://${internalPath}`;
755
+ }
756
+ if (newBasePath) {
757
+ config.url = (_b = config.url) == null ? void 0 : _b.replace(servicePath, newBasePath);
758
+ }
759
+ }
760
+ return config;
761
+ },
762
+ onError: (error) => Promise.reject(error)
763
+ };
764
+ };
750
765
 
751
- /*
752
- * Copyright (c) 2022 AccelByte Inc. All Rights Reserved
753
- * This is licensed software from AccelByte Inc, for limitations
754
- * and restrictions contact your company contract manager.
755
- */
756
- // ts-prune-ignore-next
757
- const VALIDATION_ERROR_CODE = 20002;
766
+ // src/interceptors/ErrorInterceptor.ts
767
+ var ERROR_ELIGIBILITY_CODE = 13130;
768
+ var ErrorInterceptors = [
769
+ {
770
+ type: "response",
771
+ name: "user-eligibilitiy-change",
772
+ onError: (e) => {
773
+ const error = e;
774
+ if (error.response) {
775
+ const { response } = error;
776
+ if ((response == null ? void 0 : response.status) === 403 && (response == null ? void 0 : response.config).url.includes(process.env.BASE_URL) && (response == null ? void 0 : response.config.withCredentials)) {
777
+ if (response.data.errorCode === ERROR_ELIGIBILITY_CODE) {
778
+ }
779
+ }
780
+ }
781
+ return Promise.reject(error);
782
+ }
783
+ },
784
+ {
785
+ type: "response",
786
+ name: "too-many-request",
787
+ onError: (e) => {
788
+ const error = e;
789
+ if (error.response) {
790
+ const { response } = error;
791
+ if ((response == null ? void 0 : response.status) === 429) {
792
+ }
793
+ }
794
+ return Promise.reject(error);
795
+ }
796
+ }
797
+ ];
758
798
 
759
- /*
760
- * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved
761
- * This is licensed software from AccelByte Inc, for limitations
762
- * and restrictions contact your company contract manager.
763
- */
764
- const ERROR_LINK_ANOTHER_3RD_PARTY_ACCOUNT = 10200;
765
- const ERROR_CODE_LINK_DELETION_ACCOUNT = 10135;
766
- const ERROR_CODE_TOKEN_EXPIRED = 10196;
767
- const ERROR_USER_BANNED = 10134;
799
+ // src/utils/Type.ts
800
+ function isType(schema, data) {
801
+ return schema.safeParse(data).success;
802
+ }
768
803
 
769
- /*
770
- * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved
771
- * This is licensed software from AccelByte Inc, for limitations
772
- * and restrictions contact your company contract manager.
773
- */
774
- class UrlHelper {
775
- static trimSlashFromStringEnd(pathString) {
776
- let newString = pathString;
777
- while (newString[newString.length - 1] === '/') {
778
- newString = newString.slice(0, -1);
779
- }
780
- return newString;
781
- }
782
- static trimSlashFromStringStart(pathString) {
783
- let newString = pathString;
784
- while (newString[0] === '/') {
785
- newString = newString.slice(1);
786
- }
787
- return newString;
788
- }
789
- static trimSlashFromStringEdges(pathString) {
790
- return UrlHelper.trimSlashFromStringStart(this.trimSlashFromStringEnd(pathString));
791
- }
792
- static combinePaths(...paths) {
793
- const completePath = paths.join('/');
794
- // Replace 2 or more consecutive slashes with a single slash.
795
- // This is also the behavior from Node's `path.join`.
796
- return completePath.replace(/\/{2,}/g, '/');
797
- }
798
- static combineURLPaths(urlString, ...paths) {
799
- const url = new URL(urlString);
800
- const { origin } = url;
801
- const pathname = UrlHelper.trimSlashFromStringEdges(UrlHelper.combinePaths(url.pathname, ...paths));
802
- return new URL(pathname, origin).toString();
803
- }
804
- static removeQueryParam(fullUrlString, param) {
805
- const url = new URL(fullUrlString);
806
- const params = url.searchParams;
807
- const pathname = this.trimSlashFromStringEnd(url.pathname);
808
- // Remove the query parameter
809
- params.delete(param);
810
- // Preserving other URL attributes
811
- let newUrlString;
812
- if (params.toString() === '')
813
- newUrlString = `${url.origin}${pathname}${url.hash}`;
814
- else
815
- newUrlString = `${url.origin}${pathname}?${params.toString()}${url.hash}`;
816
- return newUrlString;
817
- }
818
- }
819
- UrlHelper.isCompleteURLString = (urlString) => {
820
- try {
821
- const url = new URL(urlString);
822
- return url.hostname !== '';
823
- }
824
- catch (error) { }
825
- return false;
804
+ // src/utils/UrlHelper.ts
805
+ var _UrlHelper = class _UrlHelper {
806
+ static trimSlashFromStringEnd(pathString) {
807
+ let newString = pathString;
808
+ while (newString[newString.length - 1] === "/") {
809
+ newString = newString.slice(0, -1);
810
+ }
811
+ return newString;
812
+ }
813
+ static trimSlashFromStringStart(pathString) {
814
+ let newString = pathString;
815
+ while (newString[0] === "/") {
816
+ newString = newString.slice(1);
817
+ }
818
+ return newString;
819
+ }
820
+ static trimSlashFromStringEdges(pathString) {
821
+ return _UrlHelper.trimSlashFromStringStart(this.trimSlashFromStringEnd(pathString));
822
+ }
823
+ static combinePaths(...paths) {
824
+ const completePath = paths.join("/");
825
+ return completePath.replace(/\/{2,}/g, "/");
826
+ }
827
+ static combineURLPaths(urlString, ...paths) {
828
+ const url = new URL(urlString);
829
+ const { origin } = url;
830
+ const pathname = _UrlHelper.trimSlashFromStringEdges(_UrlHelper.combinePaths(url.pathname, ...paths));
831
+ return new URL(pathname, origin).toString();
832
+ }
833
+ static removeQueryParam(fullUrlString, param) {
834
+ const url = new URL(fullUrlString);
835
+ const params = url.searchParams;
836
+ const pathname = this.trimSlashFromStringEnd(url.pathname);
837
+ params.delete(param);
838
+ let newUrlString;
839
+ if (params.toString() === "") newUrlString = `${url.origin}${pathname}${url.hash}`;
840
+ else newUrlString = `${url.origin}${pathname}?${params.toString()}${url.hash}`;
841
+ return newUrlString;
842
+ }
826
843
  };
827
-
828
- export { Accelbyte, ApiUtils, BrowserHelper, CodeGenUtil, DecodeError, DesktopChecker, ERROR_CODE_LINK_DELETION_ACCOUNT, ERROR_CODE_TOKEN_EXPIRED, ERROR_LINK_ANOTHER_3RD_PARTY_ACCOUNT, ERROR_USER_BANNED, Network, RefreshSession, SdkDevice, UrlHelper, VALIDATION_ERROR_CODE, Validate, doRefreshSession, injectAuthInterceptors, injectErrorInterceptors, injectRequestInterceptors, injectResponseInterceptors, refreshWithLock };
829
- //# sourceMappingURL=index.node.js.map
844
+ _UrlHelper.isCompleteURLString = (urlString) => {
845
+ try {
846
+ const url = new URL(urlString);
847
+ return url.hostname !== "";
848
+ } catch (error) {
849
+ }
850
+ return false;
851
+ };
852
+ var UrlHelper = _UrlHelper;
853
+ export {
854
+ AccelByte,
855
+ AccelByteSDK,
856
+ ApiUtils,
857
+ BrowserHelper,
858
+ CodeGenUtil,
859
+ DecodeError,
860
+ DesktopChecker,
861
+ ERROR_CODE_LINK_DELETION_ACCOUNT,
862
+ ERROR_CODE_TOKEN_EXPIRED,
863
+ ERROR_LINK_ANOTHER_3RD_PARTY_ACCOUNT,
864
+ ERROR_USER_BANNED,
865
+ ErrorInterceptors,
866
+ IamErrorCode,
867
+ Network,
868
+ RefreshSession,
869
+ RefreshToken,
870
+ SdkDevice,
871
+ UrlHelper,
872
+ Validate,
873
+ createAuthInterceptor,
874
+ createCustomPathInterceptor,
875
+ createGetSessionInterceptor,
876
+ createRefreshSessionInterceptor,
877
+ isType
878
+ };
879
+ //# sourceMappingURL=index.node.js.map