@accelbyte/sdk 0.0.0-dev-20240910111050 → 0.0.0-dev-20240911051006
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/node/index.cjs +42 -2
- package/dist/cjs/node/index.cjs.map +1 -1
- package/dist/es/browser/index.browser.js +42 -2
- package/dist/es/browser/index.browser.js.map +1 -1
- package/dist/es/node/index.node.js +42 -2
- package/dist/es/node/index.node.js.map +1 -1
- package/dist/index.d.ts +29 -0
- package/package.json +2 -2
package/dist/cjs/node/index.cjs
CHANGED
|
@@ -197,8 +197,23 @@ var AccelByteSDK = class _AccelByteSDK {
|
|
|
197
197
|
this.token = {};
|
|
198
198
|
}
|
|
199
199
|
createAxiosInstance() {
|
|
200
|
-
|
|
200
|
+
const axiosInstance = Network.create({ baseURL: this.coreConfig.baseURL, ...this.axiosConfig.request });
|
|
201
|
+
const interceptors = this.axiosConfig.interceptors;
|
|
202
|
+
if (interceptors) {
|
|
203
|
+
for (const interceptor of interceptors) {
|
|
204
|
+
if (interceptor.type === "request") {
|
|
205
|
+
axiosInstance.interceptors.request.use(interceptor == null ? void 0 : interceptor.onRequest, interceptor.onError);
|
|
206
|
+
}
|
|
207
|
+
if (interceptor.type === "response") {
|
|
208
|
+
axiosInstance.interceptors.response.use(interceptor == null ? void 0 : interceptor.onSuccess, interceptor.onError);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return axiosInstance;
|
|
201
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* Assembles and returns the current Axios instance along with core and Axios configurations.
|
|
216
|
+
*/
|
|
202
217
|
assembly() {
|
|
203
218
|
return {
|
|
204
219
|
axiosInstance: this.axiosInstance,
|
|
@@ -206,6 +221,12 @@ var AccelByteSDK = class _AccelByteSDK {
|
|
|
206
221
|
axiosConfig: this.axiosConfig
|
|
207
222
|
};
|
|
208
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* Creates a new instance of AccelByteSDK with a shallow copy of the current configurations.
|
|
226
|
+
* Optionally allows excluding interceptors.
|
|
227
|
+
* @param {boolean} [opts.interceptors] - Whether to include interceptors in the clone. Default is true.
|
|
228
|
+
* @returns {AccelByteSDK} A new instance of AccelByteSDK with the cloned configuration.
|
|
229
|
+
*/
|
|
209
230
|
clone(opts) {
|
|
210
231
|
const newConfigs = {
|
|
211
232
|
coreConfig: { ...this.coreConfig },
|
|
@@ -216,6 +237,9 @@ var AccelByteSDK = class _AccelByteSDK {
|
|
|
216
237
|
}
|
|
217
238
|
return new _AccelByteSDK(newConfigs);
|
|
218
239
|
}
|
|
240
|
+
/**
|
|
241
|
+
* Adds interceptors to the current Axios configuration.
|
|
242
|
+
*/
|
|
219
243
|
addInterceptors(interceptors) {
|
|
220
244
|
if (!this.axiosConfig.interceptors) {
|
|
221
245
|
this.axiosConfig.interceptors = [];
|
|
@@ -228,12 +252,18 @@ var AccelByteSDK = class _AccelByteSDK {
|
|
|
228
252
|
if (!((_a = this.axiosConfig) == null ? void 0 : _a.interceptors)) return this;
|
|
229
253
|
if (!filterCallback) {
|
|
230
254
|
this.axiosConfig.interceptors = void 0;
|
|
255
|
+
this.axiosInstance.interceptors.request.clear();
|
|
256
|
+
this.axiosInstance.interceptors.response.clear();
|
|
231
257
|
return this;
|
|
232
258
|
}
|
|
233
259
|
this.axiosConfig.interceptors = this.axiosConfig.interceptors.filter(filterCallback);
|
|
234
260
|
this.axiosInstance = this.createAxiosInstance();
|
|
235
261
|
return this;
|
|
236
262
|
}
|
|
263
|
+
/**
|
|
264
|
+
* Updates the SDK's core and Axios configurations.
|
|
265
|
+
* Merges the provided configurations with the current ones.
|
|
266
|
+
*/
|
|
237
267
|
setConfig({ coreConfig, axiosConfig }) {
|
|
238
268
|
this.coreConfig = {
|
|
239
269
|
...this.coreConfig,
|
|
@@ -241,11 +271,15 @@ var AccelByteSDK = class _AccelByteSDK {
|
|
|
241
271
|
};
|
|
242
272
|
this.axiosConfig = {
|
|
243
273
|
...this.axiosConfig,
|
|
244
|
-
...axiosConfig
|
|
274
|
+
...axiosConfig == null ? void 0 : axiosConfig.interceptors,
|
|
275
|
+
request: ApiUtils.mergeAxiosConfigs(this.axiosConfig.request, axiosConfig == null ? void 0 : axiosConfig.request)
|
|
245
276
|
};
|
|
246
277
|
this.axiosInstance = this.createAxiosInstance();
|
|
247
278
|
return this;
|
|
248
279
|
}
|
|
280
|
+
/**
|
|
281
|
+
* Set accessToken and refreshToken and updates the Axios request headers to use Bearer authentication.
|
|
282
|
+
*/
|
|
249
283
|
setToken(token) {
|
|
250
284
|
this.token = {
|
|
251
285
|
...this.token,
|
|
@@ -258,9 +292,15 @@ var AccelByteSDK = class _AccelByteSDK {
|
|
|
258
292
|
};
|
|
259
293
|
this.axiosInstance = this.createAxiosInstance();
|
|
260
294
|
}
|
|
295
|
+
/**
|
|
296
|
+
* Removes the currently set token.
|
|
297
|
+
*/
|
|
261
298
|
removeToken() {
|
|
262
299
|
this.token = {};
|
|
263
300
|
}
|
|
301
|
+
/**
|
|
302
|
+
* Retrieves the current token configuration.
|
|
303
|
+
*/
|
|
264
304
|
getToken() {
|
|
265
305
|
return this.token;
|
|
266
306
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/index.node.ts","../../../src/polyfills/node.ts","../../../src/utils/ApiUtils.ts","../../../src/utils/Network.ts","../../../src/utils/SdkDevice.ts","../../../src/AccelByteSDK.ts","../../../src/constants/IamErrorCode.ts","../../../src/constants/LinkAccount.ts","../../../src/interceptors/AuthInterceptors.ts","../../../src/utils/DesktopChecker.ts","../../../src/utils/BrowserHelper.ts","../../../src/utils/RefreshSession.ts","../../../../sdk-iam/src/generated-definitions/TokenWithDeviceCookieResponseV3.ts","../../../../sdk-iam/src/generated-definitions/JwtBanV3.ts","../../../../sdk-iam/src/generated-definitions/NamespaceRole.ts","../../../../sdk-iam/src/generated-definitions/PermissionV3.ts","../../../src/utils/CodeGenUtil.ts","../../../src/utils/Validate.ts","../../../src/interceptors/AuthInterceptorDeps.ts","../../../src/constants/paths.ts","../../../src/interceptors/CustomPathInterceptor.ts","../../../src/interceptors/ErrorInterceptor.ts","../../../src/utils/Type.ts","../../../src/utils/UrlHelper.ts"],"sourcesContent":["/*\n * Copyright (c) 2022 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\n\n// This needs to be imported otherwise the polyfill will appear after all of the code bundles.\nimport './polyfills/node'\nexport * from './index'\n","/*\n * Copyright (c) 2018-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nimport { webcrypto } from 'crypto'\n\nif (!global.crypto) {\n global.crypto = webcrypto as unknown as Crypto\n}\n","/*\n * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\n\nimport axios, { AxiosRequestConfig } from 'axios'\n\nexport class ApiUtils {\n static mergeAxiosConfigs = (config: AxiosRequestConfig, overrides?: AxiosRequestConfig): AxiosRequestConfig => {\n return {\n ...config,\n ...overrides,\n headers: {\n ...config?.headers,\n ...overrides?.headers\n }\n }\n }\n\n static is4xxError = (error: unknown): boolean => {\n if (axios.isAxiosError(error) && error.response) {\n return error.response.status >= 400 && error.response.status <= 499\n }\n return false\n }\n}\n","/*\n * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nimport axios, { AxiosInstance, AxiosRequestConfig } from 'axios'\nimport qs from 'query-string'\nimport { SdkDevice } from './SdkDevice'\n\nexport class Network {\n static create(...configs: AxiosRequestConfig[]): AxiosInstance {\n const axiosInstance = axios.create(\n Object.assign(\n {\n paramsSerializer: qs.stringify\n },\n ...configs\n )\n )\n\n return axiosInstance\n }\n\n static withBearerToken(accessToken: string, config?: AxiosRequestConfig): AxiosInstance {\n return Network.create(config || {}, {\n headers: { Authorization: `Bearer ${accessToken}` }\n })\n }\n\n static setDeviceTokenCookie = () => {\n const deviceId = SdkDevice.getDeviceId()\n document.cookie = `device_token=${deviceId}; path=/;`\n }\n\n static removeDeviceTokenCookie = () => {\n document.cookie = `device_token=; expires=${new Date(0).toUTCString()}`\n }\n\n static getFormUrlEncodedData = (data: any): URLSearchParams => {\n const formPayload = new URLSearchParams()\n const formKeys = Object.keys(data) as []\n formKeys.forEach(key => {\n if (data[key]) formPayload.append(key, data[key])\n })\n return formPayload\n }\n}\n","/*\n * Copyright (c) 2022 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nimport * as uuid from 'uuid'\n\nexport class SdkDevice {\n static ID_KEY = 'deviceId'\n\n static TYPE = {\n MOBILE: 'mobile',\n DESKTOP: 'desktop'\n }\n\n static getType = () => {\n return isMobile() ? SdkDevice.TYPE.MOBILE : SdkDevice.TYPE.DESKTOP\n }\n\n static generateUUID = () => {\n const deviceIdInUUID = uuid.v4().split('-').join('')\n localStorage.setItem(SdkDevice.ID_KEY, deviceIdInUUID)\n return deviceIdInUUID\n }\n\n static getDeviceId = () => {\n return localStorage.getItem(this.ID_KEY) || this.generateUUID()\n }\n}\n\n/*\n Below function is copied from npm 'is-mobile'\n */\nconst mobileRE =\n /(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\nconst tabletRE = /android|ipad|playbook|silk/i\n\nconst isMobile = (opts?: any) => {\n if (!opts) opts = {}\n let ua = opts.ua\n if (!ua && typeof navigator !== 'undefined') ua = navigator.userAgent\n if (ua && ua.headers && typeof ua.headers['user-agent'] === 'string') {\n ua = ua.headers['user-agent']\n }\n if (typeof ua !== 'string') return false\n\n let result = mobileRE.test(ua) || (!!opts.tablet && tabletRE.test(ua))\n\n if (\n !result &&\n opts.tablet &&\n opts.featureDetect &&\n navigator &&\n navigator.maxTouchPoints > 1 &&\n ua.indexOf('Macintosh') !== -1 &&\n ua.indexOf('Safari') !== -1\n ) {\n result = true\n }\n\n return result\n}\n","/*\n * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\n\nimport { AxiosInstance, AxiosRequestConfig } from 'axios'\nimport { AxiosConfig, CoreConfig, Interceptor, SdkConstructorParam, SdkSetConfigParam, TokenConfig } from './Types'\nimport { ApiUtils } from './utils/ApiUtils'\nimport { Network } from './utils/Network'\nimport { MakeRequired } from './utils/Type'\n\nexport const AccelByte = {\n SDK: (param: SdkConstructorParam) => {\n return new AccelByteSDK(param)\n }\n}\n\nexport class AccelByteSDK {\n private coreConfig: CoreConfig\n private axiosConfig: AxiosConfig\n private axiosInstance: AxiosInstance\n private token: TokenConfig\n\n constructor({ coreConfig, axiosConfig }: SdkConstructorParam) {\n this.coreConfig = {\n ...coreConfig,\n useSchemaValidation: coreConfig.useSchemaValidation ?? true\n }\n this.axiosConfig = {\n /**\n * when user create a variable to store intercepters and passed into sdk\n * the sdk will use the variable as reference value,\n * so when new interceptor added, reference value will also has the new interceptor,\n * to avoid this we create shallow copy for the interceptors\n */\n interceptors: axiosConfig?.interceptors ? [...axiosConfig.interceptors] : undefined,\n request: {\n timeout: 60000,\n withCredentials: true,\n ...axiosConfig?.request,\n headers: {\n 'Content-Type': 'application/json',\n ...axiosConfig?.request?.headers\n }\n }\n }\n this.axiosInstance = this.createAxiosInstance()\n this.token = {}\n }\n\n private createAxiosInstance() {\n return Network.create({ baseURL: this.coreConfig.baseURL, ...this.axiosConfig.request })\n }\n\n assembly() {\n return {\n axiosInstance: this.axiosInstance,\n coreConfig: this.coreConfig,\n axiosConfig: this.axiosConfig as MakeRequired<AxiosConfig, 'request'>\n }\n }\n\n clone(opts?: { interceptors?: boolean }): AccelByteSDK {\n const newConfigs = {\n coreConfig: { ...this.coreConfig },\n axiosConfig: { ...this.axiosConfig }\n }\n\n if (opts?.interceptors === false) {\n delete newConfigs.axiosConfig.interceptors\n }\n\n return new AccelByteSDK(newConfigs)\n }\n\n addInterceptors(interceptors: Interceptor[]): AccelByteSDK {\n if (!this.axiosConfig.interceptors) {\n this.axiosConfig.interceptors = []\n }\n\n this.axiosConfig.interceptors.push(...interceptors)\n\n return this\n }\n\n // Method overloads.\n removeInterceptors(): AccelByteSDK\n removeInterceptors(filterCallback: (interceptor: Interceptor) => boolean): AccelByteSDK\n\n removeInterceptors(filterCallback?: (interceptor: Interceptor) => boolean) {\n if (!this.axiosConfig?.interceptors) return this\n if (!filterCallback) {\n this.axiosConfig.interceptors = undefined\n return this\n }\n\n this.axiosConfig.interceptors = this.axiosConfig.interceptors.filter(filterCallback)\n this.axiosInstance = this.createAxiosInstance()\n return this\n }\n\n setConfig({ coreConfig, axiosConfig }: SdkSetConfigParam) {\n this.coreConfig = {\n ...this.coreConfig,\n ...coreConfig\n }\n this.axiosConfig = {\n ...this.axiosConfig,\n ...axiosConfig\n }\n this.axiosInstance = this.createAxiosInstance()\n\n return this\n }\n\n setToken(token: TokenConfig) {\n this.token = {\n ...this.token,\n ...token\n }\n const configOverride = { headers: { Authorization: this.token.accessToken ? `Bearer ${this.token.accessToken}` : '' } }\n this.axiosConfig = {\n ...this.axiosConfig,\n request: ApiUtils.mergeAxiosConfigs(this.axiosInstance.defaults as AxiosRequestConfig, configOverride)\n }\n this.axiosInstance = this.createAxiosInstance()\n }\n\n removeToken() {\n this.token = {}\n }\n\n getToken() {\n return this.token\n }\n}\n","/*\n * Copyright (c) 2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\n\n// More detail: https://github.com/AccelByte/go-restful-plugins/blob/master/pkg/auth/iam/event.go\nexport enum IamErrorCode {\n InternalServerError = 20000,\n UnauthorizedAccess = 20001,\n ValidationError = 20002,\n ForbiddenAccess = 20003,\n TooManyRequests = 20007,\n UserNotFound = 20008,\n TokenIsExpired = 20011,\n InsufficientPermissions = 20013,\n InvalidAudience = 20014,\n InsufficientScope = 20015,\n UnableToParseRequestBody = 20019,\n InvalidPaginationParameters = 20021,\n TokenIsNotUserToken = 20022,\n InvalidRefererHeader = 20023,\n SubdomainMismatch = 20030\n}\n","/*\n * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\n\nexport const ERROR_LINK_ANOTHER_3RD_PARTY_ACCOUNT = 10200\nexport const ERROR_CODE_LINK_DELETION_ACCOUNT = 10135\nexport const ERROR_CODE_TOKEN_EXPIRED = 10196\nexport const ERROR_USER_BANNED = 10134\n","/*\n * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nimport axios, { AxiosError, AxiosRequestConfig } from 'axios'\nimport { Interceptor } from '../Types'\nimport { DesktopChecker } from '../utils/DesktopChecker'\nimport { Network } from '../utils/Network'\nimport { RefreshSession } from '../utils/RefreshSession'\nimport { OAuth20$, OAuth20V4$, TokenWithDeviceCookieResponseV3 } from './AuthInterceptorDeps'\n\nconst REFRESH_EXPIRY = 1000\nconst REFRESH_EXPIRY_UPDATE_RATE = 500\nconst REFRESH_EXPIRY_CHECK_RATE = 1000\n\nenum GrantTokenUrls {\n GRANT_TOKEN = '/iam/v3/oauth/token',\n GRANT_TOKEN_V4 = '/iam/v4/oauth/token'\n}\n\nenum LoginUrls {\n REVOKE = '/iam/v3/oauth/revoke'\n}\n\ntype GrantTokenUrlString = `${GrantTokenUrls}`\n\ntype RefreshArgs = {\n axiosConfig: AxiosRequestConfig\n refreshToken?: string\n clientId: string\n tokenUrl?: GrantTokenUrlString\n}\n\nconst noOp = () => {}\n\nexport class RefreshToken {\n private config: RefreshArgs\n private interceptors: Interceptor[]\n\n constructor({ config, interceptors }: { config: RefreshArgs; interceptors?: Interceptor[] }) {\n this.config = config\n this.interceptors = interceptors || []\n }\n\n // Return Promise<true> if refresh in any tab is successful;\n runWithLock = (): Promise<Partial<TokenWithDeviceCookieResponseV3> | false> => {\n //\n if (RefreshSession.isLocked()) {\n return Promise.resolve().then(async () => {\n // This block is executed when other tab / request is refreshing\n while (RefreshSession.isLocked()) {\n await RefreshSession.sleepAsync(REFRESH_EXPIRY_CHECK_RATE)\n }\n return {}\n })\n }\n\n RefreshSession.lock(REFRESH_EXPIRY)\n let isLocallyRefreshingToken = true\n\n ;(async () => {\n // eslint-disable-next-line no-unmodified-loop-condition\n while (isLocallyRefreshingToken) {\n RefreshSession.lock(REFRESH_EXPIRY)\n await RefreshSession.sleepAsync(REFRESH_EXPIRY_UPDATE_RATE)\n }\n })()\n\n return Promise.resolve()\n .then(() => this.run())\n .finally(() => {\n isLocallyRefreshingToken = false\n RefreshSession.unlock()\n })\n }\n\n run = async () => {\n const { axiosConfig, refreshToken } = this.config\n // we need this to check if app use “withCredentials: false” and don’t have refreshToken it should return false,\n // because we track it as a logout user, if not do this even user logout on the desktop app (that use withCredentials: false)\n // will automatically login with refreshSession\n if (DesktopChecker.isDesktopApp() && !axiosConfig.withCredentials && !refreshToken) {\n return false\n }\n\n const result = await this.refreshToken()\n if (result.error) {\n return false\n }\n\n return result.response.data\n }\n\n refreshToken = () => {\n const { axiosConfig, refreshToken, clientId, tokenUrl } = this.config\n const config = {\n ...axiosConfig,\n withCredentials: false,\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n Authorization: `Basic ${Buffer.from(`${clientId}:`).toString('base64')}`\n }\n }\n const axios = Network.create(config)\n\n for (const interceptor of this.interceptors) {\n if (interceptor.type === 'request') {\n axios.interceptors.request.use(interceptor?.onRequest, interceptor.onError)\n }\n\n if (interceptor.type === 'response') {\n axios.interceptors.response.use(interceptor?.onSuccess, interceptor.onError)\n }\n }\n\n const payload = {\n refresh_token: refreshToken || undefined,\n client_id: clientId,\n grant_type: 'refresh_token'\n } as const\n\n if (tokenUrl === GrantTokenUrls.GRANT_TOKEN_V4) {\n return new OAuth20V4$(axios).postOauthToken_v4(payload)\n }\n\n const oauth20 = new OAuth20$(axios)\n return oauth20.postOauthToken(payload)\n }\n}\n\nconst refreshComplete = (\n error: AxiosError,\n tokenResponse: Partial<TokenWithDeviceCookieResponseV3> | false,\n onSessionExpired: (() => void) | undefined,\n axiosConfig: AxiosRequestConfig,\n errorConfig: AxiosRequestConfig\n) => {\n //\n if (tokenResponse) {\n const { access_token } = tokenResponse\n\n // desktop\n if (!axiosConfig.withCredentials && access_token) {\n return axios({\n ...errorConfig,\n headers: {\n ...errorConfig.headers,\n Authorization: `Bearer ${access_token}`\n }\n })\n // web\n } else {\n return axios(errorConfig)\n }\n }\n\n if (onSessionExpired) {\n onSessionExpired()\n }\n throw error\n}\n\ntype SessionExpiredInterceptorOptions = {\n /**\n * The client ID used by the SDK, obtained from the Admin Portal under OAuth Clients.\n */\n clientId: string\n\n /**\n * An optional array of URLs that should be ignored when handling session expiration.\n * Default to `['/iam/v3/oauth/token', '/iam/v4/oauth/token', '/iam/v3/oauth/revoke']`\n */\n expectedErrorUrls?: string[]\n\n /**\n * A callback function that retrieves the current refresh token.\n */\n getRefreshToken: () => string | undefined\n\n /**\n * The URL endpoint for obtaining a new token. Defaults to `'/iam/v3/oauth/token'`.\n */\n tokenUrl?: GrantTokenUrlString\n /**\n * A callback function triggered when the session has expired.\n */\n onSessionExpired: () => void\n\n /**\n * A callback function triggered when successfully get new session.\n */\n onGetUserSession?: (accessToken: string, refreshToken: string) => void\n}\n\nexport const createAuthInterceptor = ({\n clientId,\n onSessionExpired,\n onGetUserSession,\n expectedErrorUrls = Object.values({ ...LoginUrls, ...GrantTokenUrls }),\n getRefreshToken,\n tokenUrl = GrantTokenUrls.GRANT_TOKEN\n}: SessionExpiredInterceptorOptions): Interceptor => {\n return {\n type: 'response',\n name: 'session-expired',\n onError: e => {\n const error = e as AxiosError\n const { config, response } = error\n\n if (axios.isCancel(error)) {\n // expected case, exit\n return Promise.reject(error)\n }\n\n if (!response) {\n console.warn(`sdk:ERR_INTERNET_DISCONNECTED ${config?.baseURL}${config?.url}. ${(error as AxiosError).message}\\n`)\n }\n\n if (response?.status === 401) {\n const { url } = config || {}\n const axiosConfig = config as AxiosRequestConfig\n const refreshToken = getRefreshToken()\n\n // expected business case, exit\n if (!url || (url && expectedErrorUrls.includes(url))) {\n return Promise.reject(error)\n }\n\n const refresh = new RefreshToken({\n config: { axiosConfig, clientId, refreshToken, tokenUrl },\n interceptors: [\n createRefreshSessionInterceptor({ tokenUrl }),\n createGetSessionInterceptor({ onGetUserSession: onGetUserSession || noOp, tokenUrl })\n ]\n })\n\n // need to lock on the desktop as well to prevent multiple token request\n return refresh.runWithLock().then(tokenResponse => {\n return refreshComplete(error, tokenResponse, onSessionExpired, axiosConfig, config || {})\n })\n }\n\n return Promise.reject(error)\n }\n }\n}\n\ntype RefreshSessioNInterceptorOptions = {\n /**\n * The URL endpoint for obtaining a new token. Defaults to `'/iam/v3/oauth/token'`.\n */\n tokenUrl?: GrantTokenUrlString\n}\n\nexport const createRefreshSessionInterceptor = (options?: RefreshSessioNInterceptorOptions): Interceptor => {\n const { tokenUrl = GrantTokenUrls.GRANT_TOKEN } = options || {}\n\n return {\n type: 'request',\n name: 'refresh-session',\n onError: error => Promise.reject(error),\n onRequest: async config => {\n // need to lock on the desktop as well to sleep other request before refresh session is done\n const isRefreshTokenUrl = config.url === tokenUrl\n // eslint-disable-next-line no-unmodified-loop-condition\n while (RefreshSession.isLocked() && !isRefreshTokenUrl) {\n await RefreshSession.sleepAsync(200)\n }\n return config\n }\n }\n}\n\ntype GetSessionInterceptorOptions = {\n /**\n * The URL endpoint for obtaining a new token. Defaults to `'/iam/v3/oauth/token'`.\n */\n tokenUrl?: GrantTokenUrlString\n\n /**\n * A callback function triggered when successfully get new session.\n */\n onGetUserSession: (accessToken: string, refreshToken: string) => void\n}\n\nexport const createGetSessionInterceptor = ({\n tokenUrl = GrantTokenUrls.GRANT_TOKEN,\n onGetUserSession\n}: GetSessionInterceptorOptions): Interceptor => ({\n type: 'response',\n name: 'get-session',\n onError: error => Promise.reject(error),\n onSuccess: response => {\n const { config, status } = response\n\n if (config.url === tokenUrl && status === 200) {\n // @ts-ignore\n const { access_token, refresh_token } = response.data as TokenWithDeviceCookieResponseV3\n\n if (access_token) {\n onGetUserSession(access_token, refresh_token ?? '')\n }\n }\n\n return response\n }\n})\n","/*\n * Copyright (c) 2022 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nexport class DesktopChecker {\n private static desktopApp = DesktopChecker.isElectron()\n\n static isDesktopApp() {\n return DesktopChecker.desktopApp && !DesktopChecker.isInIframe()\n }\n\n private static isInIframe() {\n try {\n return window.self !== window.top\n } catch (error) {\n return true\n }\n }\n\n // borrowed from https://github.com/cheton/is-electron\n private static isElectron() {\n // @ts-ignore Renderer process\n if (typeof window !== 'undefined' && typeof window.process === 'object' && window.process.type === 'renderer') {\n return true\n }\n // Main process\n if (typeof process !== 'undefined' && typeof process.versions === 'object' && !!process.versions.electron) {\n return true\n }\n // Detect the user agent when the `nodeIntegration` option is set to false\n if (typeof navigator === 'object' && typeof navigator.userAgent === 'string' && navigator.userAgent.indexOf('Electron') >= 0) {\n return true\n }\n return false\n }\n}\n","/*\n * Copyright (c) 2022 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nexport class BrowserHelper {\n static isOnBrowser = () => {\n return typeof window !== 'undefined' && window.document\n }\n}\n","/*\n * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nimport { AxiosRequestConfig } from 'axios'\nimport { BrowserHelper } from './BrowserHelper'\n\nexport class RefreshSession {\n // --\n static KEY = 'RefreshSession.lock'\n\n static isLocked = (): boolean => {\n if (!BrowserHelper.isOnBrowser()) return false\n const lockStatus = localStorage.getItem(RefreshSession.KEY)\n if (!lockStatus) {\n return false\n }\n const lockExpiry = Number(lockStatus)\n if (isNaN(lockExpiry)) {\n return false\n }\n return lockExpiry > new Date().getTime()\n }\n\n static lock = (expiry: number) => {\n if (!BrowserHelper.isOnBrowser()) return\n localStorage.setItem(RefreshSession.KEY, `${new Date().getTime() + expiry}`)\n }\n\n static unlock = () => {\n if (!BrowserHelper.isOnBrowser()) return\n localStorage.removeItem(RefreshSession.KEY)\n }\n\n static sleepAsync = (timeInMs: number) => new Promise(resolve => setTimeout(resolve, timeInMs))\n\n static isBearerAuth = (config?: AxiosRequestConfig) => {\n // @ts-ignore\n if (config?.headers?.Authorization?.toLowerCase().indexOf('bearer') > -1) {\n return true\n }\n return false\n }\n}\n","/*\n * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nimport { z } from 'zod'\nimport { JwtBanV3 } from './JwtBanV3.js'\nimport { NamespaceRole } from './NamespaceRole.js'\nimport { PermissionV3 } from './PermissionV3.js'\n\nexport const TokenWithDeviceCookieResponseV3 = z.object({\n access_token: z.string(),\n auth_trust_id: z.string().nullish(),\n bans: z.array(JwtBanV3).nullish(),\n display_name: z.string().nullish(),\n expires_in: z.number().int(),\n is_comply: z.boolean().nullish(),\n jflgs: z.number().int().nullish(),\n namespace: z.string(),\n namespace_roles: z.array(NamespaceRole).nullish(),\n permissions: z.array(PermissionV3),\n platform_id: z.string().nullish(),\n platform_user_id: z.string().nullish(),\n refresh_expires_in: z.number().int().nullish(),\n refresh_token: z.string().nullish(),\n roles: z.array(z.string()).nullish(),\n scope: z.string(),\n simultaneous_platform_id: z.string().nullish(),\n simultaneous_platform_user_id: z.string().nullish(),\n token_type: z.string(),\n unique_display_name: z.string().nullish(),\n user_id: z.string().nullish(),\n xuid: z.string().nullish()\n})\n\nexport interface TokenWithDeviceCookieResponseV3 extends z.TypeOf<typeof TokenWithDeviceCookieResponseV3> {}\n","/*\n * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nimport { z } from 'zod'\n\nexport const JwtBanV3 = z.object({\n ban: z.string(),\n disabledDate: z.string().nullish(),\n enabled: z.boolean(),\n endDate: z.string(),\n targetedNamespace: z.string()\n})\n\nexport interface JwtBanV3 extends z.TypeOf<typeof JwtBanV3> {}\n","/*\n * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nimport { z } from 'zod'\n\nexport const NamespaceRole = z.object({ namespace: z.string(), roleId: z.string() })\n\nexport interface NamespaceRole extends z.TypeOf<typeof NamespaceRole> {}\n","/*\n * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nimport { z } from 'zod'\n\nexport const PermissionV3 = z.object({\n action: z.number().int(),\n resource: z.string(),\n schedAction: z.number().int().nullish(),\n schedCron: z.string().nullish(),\n schedRange: z.array(z.string()).nullish()\n})\n\nexport interface PermissionV3 extends z.TypeOf<typeof PermissionV3> {}\n","/*\n * Copyright (c) 2022 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nexport class CodeGenUtil {\n /**\n * Returns a hash code from a string\n * @param {String} str The string to hash.\n * @return {Number} A 32bit integer\n * @see http://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/\n */\n static hashCode(str: string): number {\n let hash = 0\n for (let i = 0, len = str.length; i < len; i++) {\n const chr = str.charCodeAt(i)\n hash = (hash << 5) - hash + chr\n hash |= 0 // Convert to 32bit integer\n }\n return hash\n }\n\n static getFormUrlEncodedData = (data: Record<string, any>): URLSearchParams => {\n const formPayload = new URLSearchParams()\n const formKeys = Object.keys(data) as []\n formKeys.forEach(key => {\n if (typeof data[key] !== 'undefined') formPayload.append(key, data[key])\n })\n return formPayload\n }\n}\n","/*\n * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nimport { AxiosError, AxiosResponse } from 'axios'\nimport { z, ZodError } from 'zod'\n\nexport type ResponseError = Error | AxiosError\n\nexport type Response<T> =\n | {\n response: AxiosResponse<T>\n error: null\n }\n | {\n response: null\n error: ResponseError\n }\n\nexport class Validate {\n static validateOrReturnResponse<D>(\n useSchemaValidation: boolean,\n networkCall: () => Promise<AxiosResponse<D>>,\n Codec: z.ZodType<D>,\n modelName: string\n ) {\n return useSchemaValidation ? Validate.responseType(() => networkCall(), Codec, modelName) : Validate.unsafeResponse(() => networkCall())\n }\n\n static responseType<D>(networkCall: () => Promise<AxiosResponse<D>>, Codec: z.ZodType<D>, modelName: string) {\n return wrapNetworkCallSafely<D>(async () => {\n const response = await networkCall()\n const decodeResult = Codec.safeParse(response.data)\n if (!decodeResult.success && response.status !== 204) {\n throw new DecodeError({ error: decodeResult.error, response, modelName })\n }\n return response\n })\n }\n\n static unsafeResponse<D>(networkCall: () => Promise<AxiosResponse<D>>) {\n return wrapNetworkCallSafely<D>(() => networkCall())\n }\n\n static safeParse<D>(data: unknown, Codec: z.ZodType<D>): D | null {\n const result = Codec.safeParse(data)\n if (result.success) {\n return result.data\n }\n return null\n }\n}\n\nasync function wrapNetworkCallSafely<D>(networkCallFunction: () => Promise<AxiosResponse<D>>): Promise<Response<D>> {\n try {\n const response = await networkCallFunction()\n return { response, error: null }\n } catch (error) {\n return { response: null, error: <Error>error }\n }\n}\n\nexport class DecodeError extends Error {\n constructor({ error, response, modelName }: { error: ZodError; response: AxiosResponse; modelName: string }) {\n const msg = `response from url \"${response.config.url}\" doesn't match model \"${modelName}\"`\n super(msg)\n console.error(msg, error)\n }\n}\n","/*\n * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nimport { AxiosInstance, AxiosRequestConfig } from 'axios'\nimport { TokenWithDeviceCookieResponseV3 } from '~/iam-definitions/TokenWithDeviceCookieResponseV3'\nimport { CodeGenUtil } from '../utils/CodeGenUtil'\nimport { Response, Validate } from '../utils/Validate'\n\nexport { TokenWithDeviceCookieResponseV3 }\n\n/*\n * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\n\nexport class OAuth20$ {\n // @ts-ignore\n constructor(private axiosInstance: AxiosInstance) {}\n\n postOauthToken<T = TokenWithDeviceCookieResponseV3>(data: {\n grant_type: 'authorization_code' | 'client_credentials' | 'password' | 'refresh_token'\n username?: string | null\n password?: string | null\n code?: string | null\n code_verifier?: string | null\n client_id?: string | null\n redirect_uri?: string | null\n refresh_token?: string | null\n extend_exp?: boolean | null\n }): Promise<Response<T>> {\n const params = {} as AxiosRequestConfig\n const url = '/iam/v3/oauth/token'\n const resultPromise = this.axiosInstance.post(url, CodeGenUtil.getFormUrlEncodedData(data), {\n ...params,\n headers: { ...params.headers, 'content-type': 'application/x-www-form-urlencoded' }\n })\n\n return Validate.responseType(() => resultPromise, TokenWithDeviceCookieResponseV3, 'TokenWithDeviceCookieResponseV3')\n }\n}\n\nexport class OAuth20V4$ {\n // @ts-ignore\n // prettier-ignore\n constructor(private axiosInstance: AxiosInstance) {}\n\n /**\n * This endpoint supports grant type: 1. Grant Type == <code>authorization_code</code>: It generates the user token by given the authorization code which generated in "/iam/v3/authenticate" API response. It should also pass in the redirect_uri, which should be the same as generating the authorization code request. 2. Grant Type == <code>password</code>: The grant type to use for authenticating a user, whether it's by email / username and password combination or through platform. 3. Grant Type == <code>refresh_token</code>: Used to get a new access token for a valid refresh token. 4. Grant Type == <code>client_credentials</code>: It generates a token by checking the client credentials provided through Authorization header. 5. Grant Type == <code>urn:ietf:params:oauth:grant-type:extend_client_credentials</code>: 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 & permission. 2. The scope will be fixed as 'extend'. 3. There will have a new field 'extend_namespace', the value is from token request body. 6. Grant Type == <code>urn:ietf:params:oauth:grant-type:login_queue_ticket</code>: 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's active bans with its expiry date. List of ban types can be obtained from /bans. ## Device Cookie Validation _**For grant type "password" only**_ Device Cookie is used to protect the user account from brute force login attack, <a target="_blank" href="https://owasp.org/www-community/Slow_Down_Online_Guessing_Attacks_with_Device_Cookies">more detail from OWASP<a>. 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 "unknown". Align with General Data Protection Regulation in Europe, user login history will be kept within 28 days by default" ## 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't accepted required legal policy, the field <code>is_comply</code> will be false in response and responsed token will have no permission. action code: 10703\n */\n postOauthToken_v4(\n data: {\n grant_type:\n | 'authorization_code'\n | 'client_credentials'\n | 'password'\n | 'refresh_token'\n | 'urn:ietf:params:oauth:grant-type:extend_client_credentials'\n | 'urn:ietf:params:oauth:grant-type:login_queue_ticket'\n additionalData?: string | null\n client_id?: string | null\n client_secret?: string | null\n code?: string | null\n code_verifier?: string | null\n extendNamespace?: string | null\n extend_exp?: boolean | null\n login_queue_ticket?: string | null\n password?: string | null\n redirect_uri?: string | null\n refresh_token?: string | null\n username?: string | null\n },\n queryParams?: { code_challenge?: string | null; code_challenge_method?: 'S256' | 'plain' }\n ): Promise<Response<TokenWithDeviceCookieResponseV3>> {\n const params = { code_challenge_method: 'plain', ...queryParams } as AxiosRequestConfig\n const url = '/iam/v4/oauth/token'\n const resultPromise = this.axiosInstance.post(url, CodeGenUtil.getFormUrlEncodedData(data), {\n ...params,\n headers: { ...params.headers, 'content-type': 'application/x-www-form-urlencoded' }\n })\n\n return Validate.responseType(() => resultPromise, TokenWithDeviceCookieResponseV3, 'TokenWithDeviceCookieResponseV3')\n }\n}\n","/*\n * Copyright (c) 2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nexport const BASE_PATHS = [\n '/achievement',\n '/basic',\n '/buildinfo',\n '/chat',\n '/cloudsave',\n '/content-management',\n '/differ',\n '/dsmcontroller',\n '/event',\n '/game-telemetry',\n '/gdpr',\n '/group',\n '/iam',\n '/leaderboard',\n '/agreement',\n '/lobby',\n '/match2',\n '/matchmaking',\n '/odin-config',\n '/platform',\n '/qosm',\n '/reporting',\n '/seasonpass',\n '/session',\n '/sessionbrowser',\n '/social',\n '/ugc',\n '/config'\n] as const\n\nexport type BasePath = (typeof BASE_PATHS)[number] | (string & {})\n\nexport const INTERNAL_SERVICES = {\n '/achievement': 'justice-achievement-service',\n '/basic': 'justice-basic-service',\n '/buildinfo': 'justice-buildinfo-service',\n '/chat': 'justice-chat-service',\n '/cloudsave': 'justice-cloudsave-service',\n '/content-management': 'justice-odin-content-management-service',\n '/differ': 'justice-differ',\n '/dsmcontroller': 'justice-dsm-controller-service',\n '/event': 'justice-event-log-service',\n '/game-telemetry': 'analytics-game-telemetry-api',\n '/gdpr': 'justice-gdpr-service',\n '/group': 'justice-group-service',\n '/iam': 'justice-iam-service',\n '/leaderboard': 'justice-leaderboard-service',\n '/agreement': 'justice-legal-service', // sdk-legal\n '/lobby': 'justice-lobby-server',\n '/match2': 'justice-matchmaking-v2', // sdk-matchmaking\n '/matchmaking': 'justice-matchmaking', // sdk-matchmaking-v1\n '/odin-config': 'justice-odin-config-service',\n '/platform': 'justice-platform-service',\n '/qosm': 'justice-qos-manager-service',\n '/reporting': 'justice-reporting-service',\n '/seasonpass': 'justice-seasonpass-service',\n '/session': 'justice-session-service',\n '/sessionbrowser': 'justice-session-browser-service',\n '/social': 'justice-social-service',\n '/ugc': 'justice-ugc-service',\n '/config': 'justice-config-service'\n} as const\n","/*\n * Copyright (c) 2023-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\n\nimport { BasePath, INTERNAL_SERVICES } from '../constants/paths'\nimport { Interceptor } from '../Types'\n\ntype CreateCustomPathInterceptorOptions = {\n /**\n * A list of objects specifying which service base paths should be replaced.\n * For example, providing `{'/iam': '/iam-test'}` will redirect all `'/iam'` requests to `'/iam-test'`.\n */\n basePath: Partial<Record<BasePath, string>>\n\n /**\n * Indicates whether to use the internal AccelByte network. This should only be used in a server environment.\n * When set to true, requests will be made to `http://{service-name}/{path}` instead of the `baseURL`.\n */\n isInternalNetwork?: boolean\n}\n\nexport const createCustomPathInterceptor = ({ basePath, isInternalNetwork }: CreateCustomPathInterceptorOptions): Interceptor => {\n return {\n type: 'request',\n name: 'custom-base-path',\n onRequest: async config => {\n const { url } = config\n if (url) {\n const firstPath = url.split('/')[1]\n const servicePath = `/${firstPath}`\n const newBasePath: string | undefined = basePath?.[servicePath]\n const internalPath = INTERNAL_SERVICES?.[servicePath]\n\n if (isInternalNetwork && internalPath) {\n config.baseURL = `http://${internalPath}`\n }\n\n if (newBasePath) {\n config.url = config.url?.replace(servicePath, newBasePath)\n }\n }\n return config\n },\n onError: error => Promise.reject(error)\n }\n}\n","/*\n * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nimport { AxiosError } from 'axios'\nimport { Interceptor } from '../Types'\n\nconst ERROR_ELIGIBILITY_CODE = 13130\n\nexport const ErrorInterceptors: Array<Interceptor> = [\n {\n type: 'response',\n name: 'user-eligibilitiy-change',\n onError: e => {\n const error = e as AxiosError<any>\n if (error.response) {\n const { response } = error\n if (response?.status === 403 && (response?.config as any).url.includes(process.env.BASE_URL) && response?.config.withCredentials) {\n if (response.data.errorCode === ERROR_ELIGIBILITY_CODE) {\n // onUserEligibilityChange()\n }\n }\n }\n\n return Promise.reject(error)\n }\n },\n {\n type: 'response',\n name: 'too-many-request',\n onError: e => {\n const error = e as AxiosError<any>\n if (error.response) {\n const { response } = error\n if (response?.status === 429 /* TooManyRequests */) {\n // onTooManyRequest(error)\n }\n }\n\n return Promise.reject(error)\n }\n }\n]\n","/*\n * Copyright (c) 2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\n\nimport { z, ZodTypeAny } from 'zod'\n\nexport type MakeOptional<Type, UnionKeys extends keyof Type> = Omit<Type, UnionKeys> & Partial<Pick<Type, UnionKeys>>\nexport type MakeRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] }\n\nexport function isType<T extends ZodTypeAny>(schema: T, data: unknown): data is z.infer<T> {\n return schema.safeParse(data).success\n}\n","/*\n * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nexport class UrlHelper {\n static isCompleteURLString = (urlString: string) => {\n try {\n const url = new URL(urlString)\n return url.hostname !== ''\n } catch (error) {}\n return false\n }\n\n static trimSlashFromStringEnd(pathString: string) {\n let newString = pathString\n while (newString[newString.length - 1] === '/') {\n newString = newString.slice(0, -1)\n }\n return newString\n }\n\n static trimSlashFromStringStart(pathString: string) {\n let newString = pathString\n while (newString[0] === '/') {\n newString = newString.slice(1)\n }\n return newString\n }\n\n static trimSlashFromStringEdges(pathString: string) {\n return UrlHelper.trimSlashFromStringStart(this.trimSlashFromStringEnd(pathString))\n }\n\n static combinePaths(...paths: string[]) {\n const completePath = paths.join('/')\n // Replace 2 or more consecutive slashes with a single slash.\n // This is also the behavior from Node's `path.join`.\n return completePath.replace(/\\/{2,}/g, '/')\n }\n\n static combineURLPaths(urlString: string, ...paths: string[]) {\n const url = new URL(urlString)\n const { origin } = url\n const pathname = UrlHelper.trimSlashFromStringEdges(UrlHelper.combinePaths(url.pathname, ...paths))\n return new URL(pathname, origin).toString()\n }\n\n static removeQueryParam(fullUrlString: string, param: string) {\n const url = new URL(fullUrlString)\n const params = url.searchParams\n const pathname = this.trimSlashFromStringEnd(url.pathname)\n\n // Remove the query parameter\n params.delete(param)\n\n // Preserving other URL attributes\n let newUrlString: string\n if (params.toString() === '') newUrlString = `${url.origin}${pathname}${url.hash}`\n else newUrlString = `${url.origin}${pathname}?${params.toString()}${url.hash}`\n\n return newUrlString\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKA,oBAA0B;AAE1B,IAAI,CAAC,O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,uBAAuB,IAAI,QAAQ;AAGzD,WAAO,OAAO,KAAK;AAGnB,QAAI;AACJ,QAAI,OAAO,SAAS,MAAM,GAAI,gBAAe,GAAG,IAAI,MAAM,GAAG,QAAQ,GAAG,IAAI,IAAI;AAAA,QAC3E,gBAAe,GAAG,IAAI,MAAM,GAAG,QAAQ,IAAI,OAAO,SAAS,CAAC,GAAG,IAAI,IAAI;AAE5E,WAAO;AAAA,EACT;AACF;AA1Da,WACJ,sBAAsB,CAAC,cAAsB;AAClD,MAAI;AACF,UAAM,MAAM,IAAI,IAAI,SAAS;AAC7B,WAAO,IAAI,aAAa;AAAA,EAC1B,SAAS,OAAO;AAAA,EAAC;AACjB,SAAO;AACT;AAPK,IAAM,YAAN;","names":["axios","import_axios","axios","qs","IamErrorCode","import_axios","import_zod","import_zod","import_zod","GrantTokenUrls","LoginUrls","axios"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/index.node.ts","../../../src/polyfills/node.ts","../../../src/utils/ApiUtils.ts","../../../src/utils/Network.ts","../../../src/utils/SdkDevice.ts","../../../src/AccelByteSDK.ts","../../../src/constants/IamErrorCode.ts","../../../src/constants/LinkAccount.ts","../../../src/interceptors/AuthInterceptors.ts","../../../src/utils/DesktopChecker.ts","../../../src/utils/BrowserHelper.ts","../../../src/utils/RefreshSession.ts","../../../../sdk-iam/src/generated-definitions/TokenWithDeviceCookieResponseV3.ts","../../../../sdk-iam/src/generated-definitions/JwtBanV3.ts","../../../../sdk-iam/src/generated-definitions/NamespaceRole.ts","../../../../sdk-iam/src/generated-definitions/PermissionV3.ts","../../../src/utils/CodeGenUtil.ts","../../../src/utils/Validate.ts","../../../src/interceptors/AuthInterceptorDeps.ts","../../../src/constants/paths.ts","../../../src/interceptors/CustomPathInterceptor.ts","../../../src/interceptors/ErrorInterceptor.ts","../../../src/utils/Type.ts","../../../src/utils/UrlHelper.ts"],"sourcesContent":["/*\n * Copyright (c) 2022 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\n\n// This needs to be imported otherwise the polyfill will appear after all of the code bundles.\nimport './polyfills/node'\nexport * from './index'\n","/*\n * Copyright (c) 2018-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nimport { webcrypto } from 'crypto'\n\nif (!global.crypto) {\n global.crypto = webcrypto as unknown as Crypto\n}\n","/*\n * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\n\nimport axios, { AxiosRequestConfig } from 'axios'\n\nexport class ApiUtils {\n static mergeAxiosConfigs = (config: AxiosRequestConfig, overrides?: AxiosRequestConfig): AxiosRequestConfig => {\n return {\n ...config,\n ...overrides,\n headers: {\n ...config?.headers,\n ...overrides?.headers\n }\n }\n }\n\n static is4xxError = (error: unknown): boolean => {\n if (axios.isAxiosError(error) && error.response) {\n return error.response.status >= 400 && error.response.status <= 499\n }\n return false\n }\n}\n","/*\n * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nimport axios, { AxiosInstance, AxiosRequestConfig } from 'axios'\nimport qs from 'query-string'\nimport { SdkDevice } from './SdkDevice'\n\nexport class Network {\n static create(...configs: AxiosRequestConfig[]): AxiosInstance {\n const axiosInstance = axios.create(\n Object.assign(\n {\n paramsSerializer: qs.stringify\n },\n ...configs\n )\n )\n\n return axiosInstance\n }\n\n static withBearerToken(accessToken: string, config?: AxiosRequestConfig): AxiosInstance {\n return Network.create(config || {}, {\n headers: { Authorization: `Bearer ${accessToken}` }\n })\n }\n\n static setDeviceTokenCookie = () => {\n const deviceId = SdkDevice.getDeviceId()\n document.cookie = `device_token=${deviceId}; path=/;`\n }\n\n static removeDeviceTokenCookie = () => {\n document.cookie = `device_token=; expires=${new Date(0).toUTCString()}`\n }\n\n static getFormUrlEncodedData = (data: any): URLSearchParams => {\n const formPayload = new URLSearchParams()\n const formKeys = Object.keys(data) as []\n formKeys.forEach(key => {\n if (data[key]) formPayload.append(key, data[key])\n })\n return formPayload\n }\n}\n","/*\n * Copyright (c) 2022 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nimport * as uuid from 'uuid'\n\nexport class SdkDevice {\n static ID_KEY = 'deviceId'\n\n static TYPE = {\n MOBILE: 'mobile',\n DESKTOP: 'desktop'\n }\n\n static getType = () => {\n return isMobile() ? SdkDevice.TYPE.MOBILE : SdkDevice.TYPE.DESKTOP\n }\n\n static generateUUID = () => {\n const deviceIdInUUID = uuid.v4().split('-').join('')\n localStorage.setItem(SdkDevice.ID_KEY, deviceIdInUUID)\n return deviceIdInUUID\n }\n\n static getDeviceId = () => {\n return localStorage.getItem(this.ID_KEY) || this.generateUUID()\n }\n}\n\n/*\n Below function is copied from npm 'is-mobile'\n */\nconst mobileRE =\n /(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\nconst tabletRE = /android|ipad|playbook|silk/i\n\nconst isMobile = (opts?: any) => {\n if (!opts) opts = {}\n let ua = opts.ua\n if (!ua && typeof navigator !== 'undefined') ua = navigator.userAgent\n if (ua && ua.headers && typeof ua.headers['user-agent'] === 'string') {\n ua = ua.headers['user-agent']\n }\n if (typeof ua !== 'string') return false\n\n let result = mobileRE.test(ua) || (!!opts.tablet && tabletRE.test(ua))\n\n if (\n !result &&\n opts.tablet &&\n opts.featureDetect &&\n navigator &&\n navigator.maxTouchPoints > 1 &&\n ua.indexOf('Macintosh') !== -1 &&\n ua.indexOf('Safari') !== -1\n ) {\n result = true\n }\n\n return result\n}\n","/*\n * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\n\nimport { AxiosInstance, AxiosRequestConfig } from 'axios'\nimport { AxiosConfig, CoreConfig, Interceptor, SdkConstructorParam, SdkSetConfigParam, TokenConfig } from './Types'\nimport { ApiUtils } from './utils/ApiUtils'\nimport { Network } from './utils/Network'\nimport { MakeRequired } from './utils/Type'\n\nexport const AccelByte = {\n SDK: (param: SdkConstructorParam) => {\n return new AccelByteSDK(param)\n }\n}\n\nexport class AccelByteSDK {\n private coreConfig: CoreConfig\n private axiosConfig: AxiosConfig\n private axiosInstance: AxiosInstance\n private token: TokenConfig\n\n constructor({ coreConfig, axiosConfig }: SdkConstructorParam) {\n this.coreConfig = {\n ...coreConfig,\n useSchemaValidation: coreConfig.useSchemaValidation ?? true\n }\n this.axiosConfig = {\n /**\n * when user create a variable to store intercepters and passed into sdk\n * the sdk will use the variable as reference value,\n * so when new interceptor added, reference value will also has the new interceptor,\n * to avoid this we create shallow copy for the interceptors\n */\n interceptors: axiosConfig?.interceptors ? [...axiosConfig.interceptors] : undefined,\n request: {\n timeout: 60000,\n withCredentials: true,\n ...axiosConfig?.request,\n headers: {\n 'Content-Type': 'application/json',\n ...axiosConfig?.request?.headers\n }\n }\n }\n this.axiosInstance = this.createAxiosInstance()\n this.token = {}\n }\n\n private createAxiosInstance() {\n const axiosInstance = Network.create({ baseURL: this.coreConfig.baseURL, ...this.axiosConfig.request })\n const interceptors = this.axiosConfig.interceptors\n\n if (interceptors) {\n for (const interceptor of interceptors) {\n if (interceptor.type === 'request') {\n axiosInstance.interceptors.request.use(interceptor?.onRequest, interceptor.onError)\n }\n\n if (interceptor.type === 'response') {\n axiosInstance.interceptors.response.use(interceptor?.onSuccess, interceptor.onError)\n }\n }\n }\n\n return axiosInstance\n }\n\n /**\n * Assembles and returns the current Axios instance along with core and Axios configurations.\n */\n assembly() {\n return {\n axiosInstance: this.axiosInstance,\n coreConfig: this.coreConfig,\n axiosConfig: this.axiosConfig as MakeRequired<AxiosConfig, 'request'>\n }\n }\n\n /**\n * Creates a new instance of AccelByteSDK with a shallow copy of the current configurations.\n * Optionally allows excluding interceptors.\n * @param {boolean} [opts.interceptors] - Whether to include interceptors in the clone. Default is true.\n * @returns {AccelByteSDK} A new instance of AccelByteSDK with the cloned configuration.\n */\n clone(opts?: { interceptors?: boolean }): AccelByteSDK {\n const newConfigs = {\n coreConfig: { ...this.coreConfig },\n axiosConfig: { ...this.axiosConfig }\n }\n\n if (opts?.interceptors === false) {\n delete newConfigs.axiosConfig.interceptors\n }\n\n return new AccelByteSDK(newConfigs)\n }\n\n /**\n * Adds interceptors to the current Axios configuration.\n */\n addInterceptors(interceptors: Interceptor[]): AccelByteSDK {\n if (!this.axiosConfig.interceptors) {\n this.axiosConfig.interceptors = []\n }\n\n this.axiosConfig.interceptors.push(...interceptors)\n\n return this\n }\n\n /**\n * Removes interceptors from the Axios configuration. Can remove all interceptors or filter specific ones.\n * @param {function} [filterCallback] - Optional filter function to remove specific interceptors.\n */\n removeInterceptors(): AccelByteSDK\n removeInterceptors(filterCallback: (interceptor: Interceptor) => boolean): AccelByteSDK\n\n removeInterceptors(filterCallback?: (interceptor: Interceptor) => boolean) {\n if (!this.axiosConfig?.interceptors) return this\n if (!filterCallback) {\n this.axiosConfig.interceptors = undefined\n this.axiosInstance.interceptors.request.clear()\n this.axiosInstance.interceptors.response.clear()\n return this\n }\n\n this.axiosConfig.interceptors = this.axiosConfig.interceptors.filter(filterCallback)\n this.axiosInstance = this.createAxiosInstance()\n return this\n }\n\n /**\n * Updates the SDK's core and Axios configurations.\n * Merges the provided configurations with the current ones.\n */\n setConfig({ coreConfig, axiosConfig }: SdkSetConfigParam) {\n this.coreConfig = {\n ...this.coreConfig,\n ...coreConfig\n }\n this.axiosConfig = {\n ...this.axiosConfig,\n ...axiosConfig?.interceptors,\n request: ApiUtils.mergeAxiosConfigs(this.axiosConfig.request as AxiosRequestConfig, axiosConfig?.request)\n }\n this.axiosInstance = this.createAxiosInstance()\n\n return this\n }\n\n /**\n * Set accessToken and refreshToken and updates the Axios request headers to use Bearer authentication.\n */\n setToken(token: TokenConfig) {\n this.token = {\n ...this.token,\n ...token\n }\n const configOverride = { headers: { Authorization: this.token.accessToken ? `Bearer ${this.token.accessToken}` : '' } }\n this.axiosConfig = {\n ...this.axiosConfig,\n request: ApiUtils.mergeAxiosConfigs(this.axiosInstance.defaults as AxiosRequestConfig, configOverride)\n }\n this.axiosInstance = this.createAxiosInstance()\n }\n\n /**\n * Removes the currently set token.\n */\n removeToken() {\n this.token = {}\n }\n\n /**\n * Retrieves the current token configuration.\n */\n getToken() {\n return this.token\n }\n}\n","/*\n * Copyright (c) 2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\n\n// More detail: https://github.com/AccelByte/go-restful-plugins/blob/master/pkg/auth/iam/event.go\nexport enum IamErrorCode {\n InternalServerError = 20000,\n UnauthorizedAccess = 20001,\n ValidationError = 20002,\n ForbiddenAccess = 20003,\n TooManyRequests = 20007,\n UserNotFound = 20008,\n TokenIsExpired = 20011,\n InsufficientPermissions = 20013,\n InvalidAudience = 20014,\n InsufficientScope = 20015,\n UnableToParseRequestBody = 20019,\n InvalidPaginationParameters = 20021,\n TokenIsNotUserToken = 20022,\n InvalidRefererHeader = 20023,\n SubdomainMismatch = 20030\n}\n","/*\n * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\n\nexport const ERROR_LINK_ANOTHER_3RD_PARTY_ACCOUNT = 10200\nexport const ERROR_CODE_LINK_DELETION_ACCOUNT = 10135\nexport const ERROR_CODE_TOKEN_EXPIRED = 10196\nexport const ERROR_USER_BANNED = 10134\n","/*\n * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nimport axios, { AxiosError, AxiosRequestConfig } from 'axios'\nimport { Interceptor } from '../Types'\nimport { DesktopChecker } from '../utils/DesktopChecker'\nimport { Network } from '../utils/Network'\nimport { RefreshSession } from '../utils/RefreshSession'\nimport { OAuth20$, OAuth20V4$, TokenWithDeviceCookieResponseV3 } from './AuthInterceptorDeps'\n\nconst REFRESH_EXPIRY = 1000\nconst REFRESH_EXPIRY_UPDATE_RATE = 500\nconst REFRESH_EXPIRY_CHECK_RATE = 1000\n\nenum GrantTokenUrls {\n GRANT_TOKEN = '/iam/v3/oauth/token',\n GRANT_TOKEN_V4 = '/iam/v4/oauth/token'\n}\n\nenum LoginUrls {\n REVOKE = '/iam/v3/oauth/revoke'\n}\n\ntype GrantTokenUrlString = `${GrantTokenUrls}`\n\ntype RefreshArgs = {\n axiosConfig: AxiosRequestConfig\n refreshToken?: string\n clientId: string\n tokenUrl?: GrantTokenUrlString\n}\n\nconst noOp = () => {}\n\nexport class RefreshToken {\n private config: RefreshArgs\n private interceptors: Interceptor[]\n\n constructor({ config, interceptors }: { config: RefreshArgs; interceptors?: Interceptor[] }) {\n this.config = config\n this.interceptors = interceptors || []\n }\n\n // Return Promise<true> if refresh in any tab is successful;\n runWithLock = (): Promise<Partial<TokenWithDeviceCookieResponseV3> | false> => {\n //\n if (RefreshSession.isLocked()) {\n return Promise.resolve().then(async () => {\n // This block is executed when other tab / request is refreshing\n while (RefreshSession.isLocked()) {\n await RefreshSession.sleepAsync(REFRESH_EXPIRY_CHECK_RATE)\n }\n return {}\n })\n }\n\n RefreshSession.lock(REFRESH_EXPIRY)\n let isLocallyRefreshingToken = true\n\n ;(async () => {\n // eslint-disable-next-line no-unmodified-loop-condition\n while (isLocallyRefreshingToken) {\n RefreshSession.lock(REFRESH_EXPIRY)\n await RefreshSession.sleepAsync(REFRESH_EXPIRY_UPDATE_RATE)\n }\n })()\n\n return Promise.resolve()\n .then(() => this.run())\n .finally(() => {\n isLocallyRefreshingToken = false\n RefreshSession.unlock()\n })\n }\n\n run = async () => {\n const { axiosConfig, refreshToken } = this.config\n // we need this to check if app use “withCredentials: false” and don’t have refreshToken it should return false,\n // because we track it as a logout user, if not do this even user logout on the desktop app (that use withCredentials: false)\n // will automatically login with refreshSession\n if (DesktopChecker.isDesktopApp() && !axiosConfig.withCredentials && !refreshToken) {\n return false\n }\n\n const result = await this.refreshToken()\n if (result.error) {\n return false\n }\n\n return result.response.data\n }\n\n refreshToken = () => {\n const { axiosConfig, refreshToken, clientId, tokenUrl } = this.config\n const config = {\n ...axiosConfig,\n withCredentials: false,\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n Authorization: `Basic ${Buffer.from(`${clientId}:`).toString('base64')}`\n }\n }\n const axios = Network.create(config)\n\n for (const interceptor of this.interceptors) {\n if (interceptor.type === 'request') {\n axios.interceptors.request.use(interceptor?.onRequest, interceptor.onError)\n }\n\n if (interceptor.type === 'response') {\n axios.interceptors.response.use(interceptor?.onSuccess, interceptor.onError)\n }\n }\n\n const payload = {\n refresh_token: refreshToken || undefined,\n client_id: clientId,\n grant_type: 'refresh_token'\n } as const\n\n if (tokenUrl === GrantTokenUrls.GRANT_TOKEN_V4) {\n return new OAuth20V4$(axios).postOauthToken_v4(payload)\n }\n\n const oauth20 = new OAuth20$(axios)\n return oauth20.postOauthToken(payload)\n }\n}\n\nconst refreshComplete = (\n error: AxiosError,\n tokenResponse: Partial<TokenWithDeviceCookieResponseV3> | false,\n onSessionExpired: (() => void) | undefined,\n axiosConfig: AxiosRequestConfig,\n errorConfig: AxiosRequestConfig\n) => {\n //\n if (tokenResponse) {\n const { access_token } = tokenResponse\n\n // desktop\n if (!axiosConfig.withCredentials && access_token) {\n return axios({\n ...errorConfig,\n headers: {\n ...errorConfig.headers,\n Authorization: `Bearer ${access_token}`\n }\n })\n // web\n } else {\n return axios(errorConfig)\n }\n }\n\n if (onSessionExpired) {\n onSessionExpired()\n }\n throw error\n}\n\ntype SessionExpiredInterceptorOptions = {\n /**\n * The client ID used by the SDK, obtained from the Admin Portal under OAuth Clients.\n */\n clientId: string\n\n /**\n * An optional array of URLs that should be ignored when handling session expiration.\n * Default to `['/iam/v3/oauth/token', '/iam/v4/oauth/token', '/iam/v3/oauth/revoke']`\n */\n expectedErrorUrls?: string[]\n\n /**\n * A callback function that retrieves the current refresh token.\n */\n getRefreshToken: () => string | undefined\n\n /**\n * The URL endpoint for obtaining a new token. Defaults to `'/iam/v3/oauth/token'`.\n */\n tokenUrl?: GrantTokenUrlString\n /**\n * A callback function triggered when the session has expired.\n */\n onSessionExpired: () => void\n\n /**\n * A callback function triggered when successfully get new session.\n */\n onGetUserSession?: (accessToken: string, refreshToken: string) => void\n}\n\nexport const createAuthInterceptor = ({\n clientId,\n onSessionExpired,\n onGetUserSession,\n expectedErrorUrls = Object.values({ ...LoginUrls, ...GrantTokenUrls }),\n getRefreshToken,\n tokenUrl = GrantTokenUrls.GRANT_TOKEN\n}: SessionExpiredInterceptorOptions): Interceptor => {\n return {\n type: 'response',\n name: 'session-expired',\n onError: e => {\n const error = e as AxiosError\n const { config, response } = error\n\n if (axios.isCancel(error)) {\n // expected case, exit\n return Promise.reject(error)\n }\n\n if (!response) {\n console.warn(`sdk:ERR_INTERNET_DISCONNECTED ${config?.baseURL}${config?.url}. ${(error as AxiosError).message}\\n`)\n }\n\n if (response?.status === 401) {\n const { url } = config || {}\n const axiosConfig = config as AxiosRequestConfig\n const refreshToken = getRefreshToken()\n\n // expected business case, exit\n if (!url || (url && expectedErrorUrls.includes(url))) {\n return Promise.reject(error)\n }\n\n const refresh = new RefreshToken({\n config: { axiosConfig, clientId, refreshToken, tokenUrl },\n interceptors: [\n createRefreshSessionInterceptor({ tokenUrl }),\n createGetSessionInterceptor({ onGetUserSession: onGetUserSession || noOp, tokenUrl })\n ]\n })\n\n // need to lock on the desktop as well to prevent multiple token request\n return refresh.runWithLock().then(tokenResponse => {\n return refreshComplete(error, tokenResponse, onSessionExpired, axiosConfig, config || {})\n })\n }\n\n return Promise.reject(error)\n }\n }\n}\n\ntype RefreshSessioNInterceptorOptions = {\n /**\n * The URL endpoint for obtaining a new token. Defaults to `'/iam/v3/oauth/token'`.\n */\n tokenUrl?: GrantTokenUrlString\n}\n\nexport const createRefreshSessionInterceptor = (options?: RefreshSessioNInterceptorOptions): Interceptor => {\n const { tokenUrl = GrantTokenUrls.GRANT_TOKEN } = options || {}\n\n return {\n type: 'request',\n name: 'refresh-session',\n onError: error => Promise.reject(error),\n onRequest: async config => {\n // need to lock on the desktop as well to sleep other request before refresh session is done\n const isRefreshTokenUrl = config.url === tokenUrl\n // eslint-disable-next-line no-unmodified-loop-condition\n while (RefreshSession.isLocked() && !isRefreshTokenUrl) {\n await RefreshSession.sleepAsync(200)\n }\n return config\n }\n }\n}\n\ntype GetSessionInterceptorOptions = {\n /**\n * The URL endpoint for obtaining a new token. Defaults to `'/iam/v3/oauth/token'`.\n */\n tokenUrl?: GrantTokenUrlString\n\n /**\n * A callback function triggered when successfully get new session.\n */\n onGetUserSession: (accessToken: string, refreshToken: string) => void\n}\n\nexport const createGetSessionInterceptor = ({\n tokenUrl = GrantTokenUrls.GRANT_TOKEN,\n onGetUserSession\n}: GetSessionInterceptorOptions): Interceptor => ({\n type: 'response',\n name: 'get-session',\n onError: error => Promise.reject(error),\n onSuccess: response => {\n const { config, status } = response\n\n if (config.url === tokenUrl && status === 200) {\n // @ts-ignore\n const { access_token, refresh_token } = response.data as TokenWithDeviceCookieResponseV3\n\n if (access_token) {\n onGetUserSession(access_token, refresh_token ?? '')\n }\n }\n\n return response\n }\n})\n","/*\n * Copyright (c) 2022 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nexport class DesktopChecker {\n private static desktopApp = DesktopChecker.isElectron()\n\n static isDesktopApp() {\n return DesktopChecker.desktopApp && !DesktopChecker.isInIframe()\n }\n\n private static isInIframe() {\n try {\n return window.self !== window.top\n } catch (error) {\n return true\n }\n }\n\n // borrowed from https://github.com/cheton/is-electron\n private static isElectron() {\n // @ts-ignore Renderer process\n if (typeof window !== 'undefined' && typeof window.process === 'object' && window.process.type === 'renderer') {\n return true\n }\n // Main process\n if (typeof process !== 'undefined' && typeof process.versions === 'object' && !!process.versions.electron) {\n return true\n }\n // Detect the user agent when the `nodeIntegration` option is set to false\n if (typeof navigator === 'object' && typeof navigator.userAgent === 'string' && navigator.userAgent.indexOf('Electron') >= 0) {\n return true\n }\n return false\n }\n}\n","/*\n * Copyright (c) 2022 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nexport class BrowserHelper {\n static isOnBrowser = () => {\n return typeof window !== 'undefined' && window.document\n }\n}\n","/*\n * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nimport { AxiosRequestConfig } from 'axios'\nimport { BrowserHelper } from './BrowserHelper'\n\nexport class RefreshSession {\n // --\n static KEY = 'RefreshSession.lock'\n\n static isLocked = (): boolean => {\n if (!BrowserHelper.isOnBrowser()) return false\n const lockStatus = localStorage.getItem(RefreshSession.KEY)\n if (!lockStatus) {\n return false\n }\n const lockExpiry = Number(lockStatus)\n if (isNaN(lockExpiry)) {\n return false\n }\n return lockExpiry > new Date().getTime()\n }\n\n static lock = (expiry: number) => {\n if (!BrowserHelper.isOnBrowser()) return\n localStorage.setItem(RefreshSession.KEY, `${new Date().getTime() + expiry}`)\n }\n\n static unlock = () => {\n if (!BrowserHelper.isOnBrowser()) return\n localStorage.removeItem(RefreshSession.KEY)\n }\n\n static sleepAsync = (timeInMs: number) => new Promise(resolve => setTimeout(resolve, timeInMs))\n\n static isBearerAuth = (config?: AxiosRequestConfig) => {\n // @ts-ignore\n if (config?.headers?.Authorization?.toLowerCase().indexOf('bearer') > -1) {\n return true\n }\n return false\n }\n}\n","/*\n * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nimport { z } from 'zod'\nimport { JwtBanV3 } from './JwtBanV3.js'\nimport { NamespaceRole } from './NamespaceRole.js'\nimport { PermissionV3 } from './PermissionV3.js'\n\nexport const TokenWithDeviceCookieResponseV3 = z.object({\n access_token: z.string(),\n auth_trust_id: z.string().nullish(),\n bans: z.array(JwtBanV3).nullish(),\n display_name: z.string().nullish(),\n expires_in: z.number().int(),\n is_comply: z.boolean().nullish(),\n jflgs: z.number().int().nullish(),\n namespace: z.string(),\n namespace_roles: z.array(NamespaceRole).nullish(),\n permissions: z.array(PermissionV3),\n platform_id: z.string().nullish(),\n platform_user_id: z.string().nullish(),\n refresh_expires_in: z.number().int().nullish(),\n refresh_token: z.string().nullish(),\n roles: z.array(z.string()).nullish(),\n scope: z.string(),\n simultaneous_platform_id: z.string().nullish(),\n simultaneous_platform_user_id: z.string().nullish(),\n token_type: z.string(),\n unique_display_name: z.string().nullish(),\n user_id: z.string().nullish(),\n xuid: z.string().nullish()\n})\n\nexport interface TokenWithDeviceCookieResponseV3 extends z.TypeOf<typeof TokenWithDeviceCookieResponseV3> {}\n","/*\n * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nimport { z } from 'zod'\n\nexport const JwtBanV3 = z.object({\n ban: z.string(),\n disabledDate: z.string().nullish(),\n enabled: z.boolean(),\n endDate: z.string(),\n targetedNamespace: z.string()\n})\n\nexport interface JwtBanV3 extends z.TypeOf<typeof JwtBanV3> {}\n","/*\n * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nimport { z } from 'zod'\n\nexport const NamespaceRole = z.object({ namespace: z.string(), roleId: z.string() })\n\nexport interface NamespaceRole extends z.TypeOf<typeof NamespaceRole> {}\n","/*\n * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nimport { z } from 'zod'\n\nexport const PermissionV3 = z.object({\n action: z.number().int(),\n resource: z.string(),\n schedAction: z.number().int().nullish(),\n schedCron: z.string().nullish(),\n schedRange: z.array(z.string()).nullish()\n})\n\nexport interface PermissionV3 extends z.TypeOf<typeof PermissionV3> {}\n","/*\n * Copyright (c) 2022 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nexport class CodeGenUtil {\n /**\n * Returns a hash code from a string\n * @param {String} str The string to hash.\n * @return {Number} A 32bit integer\n * @see http://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/\n */\n static hashCode(str: string): number {\n let hash = 0\n for (let i = 0, len = str.length; i < len; i++) {\n const chr = str.charCodeAt(i)\n hash = (hash << 5) - hash + chr\n hash |= 0 // Convert to 32bit integer\n }\n return hash\n }\n\n static getFormUrlEncodedData = (data: Record<string, any>): URLSearchParams => {\n const formPayload = new URLSearchParams()\n const formKeys = Object.keys(data) as []\n formKeys.forEach(key => {\n if (typeof data[key] !== 'undefined') formPayload.append(key, data[key])\n })\n return formPayload\n }\n}\n","/*\n * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nimport { AxiosError, AxiosResponse } from 'axios'\nimport { z, ZodError } from 'zod'\n\nexport type ResponseError = Error | AxiosError\n\nexport type Response<T> =\n | {\n response: AxiosResponse<T>\n error: null\n }\n | {\n response: null\n error: ResponseError\n }\n\nexport class Validate {\n static validateOrReturnResponse<D>(\n useSchemaValidation: boolean,\n networkCall: () => Promise<AxiosResponse<D>>,\n Codec: z.ZodType<D>,\n modelName: string\n ) {\n return useSchemaValidation ? Validate.responseType(() => networkCall(), Codec, modelName) : Validate.unsafeResponse(() => networkCall())\n }\n\n static responseType<D>(networkCall: () => Promise<AxiosResponse<D>>, Codec: z.ZodType<D>, modelName: string) {\n return wrapNetworkCallSafely<D>(async () => {\n const response = await networkCall()\n const decodeResult = Codec.safeParse(response.data)\n if (!decodeResult.success && response.status !== 204) {\n throw new DecodeError({ error: decodeResult.error, response, modelName })\n }\n return response\n })\n }\n\n static unsafeResponse<D>(networkCall: () => Promise<AxiosResponse<D>>) {\n return wrapNetworkCallSafely<D>(() => networkCall())\n }\n\n static safeParse<D>(data: unknown, Codec: z.ZodType<D>): D | null {\n const result = Codec.safeParse(data)\n if (result.success) {\n return result.data\n }\n return null\n }\n}\n\nasync function wrapNetworkCallSafely<D>(networkCallFunction: () => Promise<AxiosResponse<D>>): Promise<Response<D>> {\n try {\n const response = await networkCallFunction()\n return { response, error: null }\n } catch (error) {\n return { response: null, error: <Error>error }\n }\n}\n\nexport class DecodeError extends Error {\n constructor({ error, response, modelName }: { error: ZodError; response: AxiosResponse; modelName: string }) {\n const msg = `response from url \"${response.config.url}\" doesn't match model \"${modelName}\"`\n super(msg)\n console.error(msg, error)\n }\n}\n","/*\n * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nimport { AxiosInstance, AxiosRequestConfig } from 'axios'\nimport { TokenWithDeviceCookieResponseV3 } from '~/iam-definitions/TokenWithDeviceCookieResponseV3'\nimport { CodeGenUtil } from '../utils/CodeGenUtil'\nimport { Response, Validate } from '../utils/Validate'\n\nexport { TokenWithDeviceCookieResponseV3 }\n\n/*\n * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\n\nexport class OAuth20$ {\n // @ts-ignore\n constructor(private axiosInstance: AxiosInstance) {}\n\n postOauthToken<T = TokenWithDeviceCookieResponseV3>(data: {\n grant_type: 'authorization_code' | 'client_credentials' | 'password' | 'refresh_token'\n username?: string | null\n password?: string | null\n code?: string | null\n code_verifier?: string | null\n client_id?: string | null\n redirect_uri?: string | null\n refresh_token?: string | null\n extend_exp?: boolean | null\n }): Promise<Response<T>> {\n const params = {} as AxiosRequestConfig\n const url = '/iam/v3/oauth/token'\n const resultPromise = this.axiosInstance.post(url, CodeGenUtil.getFormUrlEncodedData(data), {\n ...params,\n headers: { ...params.headers, 'content-type': 'application/x-www-form-urlencoded' }\n })\n\n return Validate.responseType(() => resultPromise, TokenWithDeviceCookieResponseV3, 'TokenWithDeviceCookieResponseV3')\n }\n}\n\nexport class OAuth20V4$ {\n // @ts-ignore\n // prettier-ignore\n constructor(private axiosInstance: AxiosInstance) {}\n\n /**\n * This endpoint supports grant type: 1. Grant Type == <code>authorization_code</code>: It generates the user token by given the authorization code which generated in "/iam/v3/authenticate" API response. It should also pass in the redirect_uri, which should be the same as generating the authorization code request. 2. Grant Type == <code>password</code>: The grant type to use for authenticating a user, whether it's by email / username and password combination or through platform. 3. Grant Type == <code>refresh_token</code>: Used to get a new access token for a valid refresh token. 4. Grant Type == <code>client_credentials</code>: It generates a token by checking the client credentials provided through Authorization header. 5. Grant Type == <code>urn:ietf:params:oauth:grant-type:extend_client_credentials</code>: 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 & permission. 2. The scope will be fixed as 'extend'. 3. There will have a new field 'extend_namespace', the value is from token request body. 6. Grant Type == <code>urn:ietf:params:oauth:grant-type:login_queue_ticket</code>: 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's active bans with its expiry date. List of ban types can be obtained from /bans. ## Device Cookie Validation _**For grant type "password" only**_ Device Cookie is used to protect the user account from brute force login attack, <a target="_blank" href="https://owasp.org/www-community/Slow_Down_Online_Guessing_Attacks_with_Device_Cookies">more detail from OWASP<a>. 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 "unknown". Align with General Data Protection Regulation in Europe, user login history will be kept within 28 days by default" ## 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't accepted required legal policy, the field <code>is_comply</code> will be false in response and responsed token will have no permission. action code: 10703\n */\n postOauthToken_v4(\n data: {\n grant_type:\n | 'authorization_code'\n | 'client_credentials'\n | 'password'\n | 'refresh_token'\n | 'urn:ietf:params:oauth:grant-type:extend_client_credentials'\n | 'urn:ietf:params:oauth:grant-type:login_queue_ticket'\n additionalData?: string | null\n client_id?: string | null\n client_secret?: string | null\n code?: string | null\n code_verifier?: string | null\n extendNamespace?: string | null\n extend_exp?: boolean | null\n login_queue_ticket?: string | null\n password?: string | null\n redirect_uri?: string | null\n refresh_token?: string | null\n username?: string | null\n },\n queryParams?: { code_challenge?: string | null; code_challenge_method?: 'S256' | 'plain' }\n ): Promise<Response<TokenWithDeviceCookieResponseV3>> {\n const params = { code_challenge_method: 'plain', ...queryParams } as AxiosRequestConfig\n const url = '/iam/v4/oauth/token'\n const resultPromise = this.axiosInstance.post(url, CodeGenUtil.getFormUrlEncodedData(data), {\n ...params,\n headers: { ...params.headers, 'content-type': 'application/x-www-form-urlencoded' }\n })\n\n return Validate.responseType(() => resultPromise, TokenWithDeviceCookieResponseV3, 'TokenWithDeviceCookieResponseV3')\n }\n}\n","/*\n * Copyright (c) 2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nexport const BASE_PATHS = [\n '/achievement',\n '/basic',\n '/buildinfo',\n '/chat',\n '/cloudsave',\n '/content-management',\n '/differ',\n '/dsmcontroller',\n '/event',\n '/game-telemetry',\n '/gdpr',\n '/group',\n '/iam',\n '/leaderboard',\n '/agreement',\n '/lobby',\n '/match2',\n '/matchmaking',\n '/odin-config',\n '/platform',\n '/qosm',\n '/reporting',\n '/seasonpass',\n '/session',\n '/sessionbrowser',\n '/social',\n '/ugc',\n '/config'\n] as const\n\nexport type BasePath = (typeof BASE_PATHS)[number] | (string & {})\n\nexport const INTERNAL_SERVICES = {\n '/achievement': 'justice-achievement-service',\n '/basic': 'justice-basic-service',\n '/buildinfo': 'justice-buildinfo-service',\n '/chat': 'justice-chat-service',\n '/cloudsave': 'justice-cloudsave-service',\n '/content-management': 'justice-odin-content-management-service',\n '/differ': 'justice-differ',\n '/dsmcontroller': 'justice-dsm-controller-service',\n '/event': 'justice-event-log-service',\n '/game-telemetry': 'analytics-game-telemetry-api',\n '/gdpr': 'justice-gdpr-service',\n '/group': 'justice-group-service',\n '/iam': 'justice-iam-service',\n '/leaderboard': 'justice-leaderboard-service',\n '/agreement': 'justice-legal-service', // sdk-legal\n '/lobby': 'justice-lobby-server',\n '/match2': 'justice-matchmaking-v2', // sdk-matchmaking\n '/matchmaking': 'justice-matchmaking', // sdk-matchmaking-v1\n '/odin-config': 'justice-odin-config-service',\n '/platform': 'justice-platform-service',\n '/qosm': 'justice-qos-manager-service',\n '/reporting': 'justice-reporting-service',\n '/seasonpass': 'justice-seasonpass-service',\n '/session': 'justice-session-service',\n '/sessionbrowser': 'justice-session-browser-service',\n '/social': 'justice-social-service',\n '/ugc': 'justice-ugc-service',\n '/config': 'justice-config-service'\n} as const\n","/*\n * Copyright (c) 2023-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\n\nimport { BasePath, INTERNAL_SERVICES } from '../constants/paths'\nimport { Interceptor } from '../Types'\n\ntype CreateCustomPathInterceptorOptions = {\n /**\n * A list of objects specifying which service base paths should be replaced.\n * For example, providing `{'/iam': '/iam-test'}` will redirect all `'/iam'` requests to `'/iam-test'`.\n */\n basePath: Partial<Record<BasePath, string>>\n\n /**\n * Indicates whether to use the internal AccelByte network. This should only be used in a server environment.\n * When set to true, requests will be made to `http://{service-name}/{path}` instead of the `baseURL`.\n */\n isInternalNetwork?: boolean\n}\n\nexport const createCustomPathInterceptor = ({ basePath, isInternalNetwork }: CreateCustomPathInterceptorOptions): Interceptor => {\n return {\n type: 'request',\n name: 'custom-base-path',\n onRequest: async config => {\n const { url } = config\n if (url) {\n const firstPath = url.split('/')[1]\n const servicePath = `/${firstPath}`\n const newBasePath: string | undefined = basePath?.[servicePath]\n const internalPath = INTERNAL_SERVICES?.[servicePath]\n\n if (isInternalNetwork && internalPath) {\n config.baseURL = `http://${internalPath}`\n }\n\n if (newBasePath) {\n config.url = config.url?.replace(servicePath, newBasePath)\n }\n }\n return config\n },\n onError: error => Promise.reject(error)\n }\n}\n","/*\n * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nimport { AxiosError } from 'axios'\nimport { Interceptor } from '../Types'\n\nconst ERROR_ELIGIBILITY_CODE = 13130\n\nexport const ErrorInterceptors: Array<Interceptor> = [\n {\n type: 'response',\n name: 'user-eligibilitiy-change',\n onError: e => {\n const error = e as AxiosError<any>\n if (error.response) {\n const { response } = error\n if (response?.status === 403 && (response?.config as any).url.includes(process.env.BASE_URL) && response?.config.withCredentials) {\n if (response.data.errorCode === ERROR_ELIGIBILITY_CODE) {\n // onUserEligibilityChange()\n }\n }\n }\n\n return Promise.reject(error)\n }\n },\n {\n type: 'response',\n name: 'too-many-request',\n onError: e => {\n const error = e as AxiosError<any>\n if (error.response) {\n const { response } = error\n if (response?.status === 429 /* TooManyRequests */) {\n // onTooManyRequest(error)\n }\n }\n\n return Promise.reject(error)\n }\n }\n]\n","/*\n * Copyright (c) 2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\n\nimport { z, ZodTypeAny } from 'zod'\n\nexport type MakeOptional<Type, UnionKeys extends keyof Type> = Omit<Type, UnionKeys> & Partial<Pick<Type, UnionKeys>>\nexport type MakeRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] }\n\nexport function isType<T extends ZodTypeAny>(schema: T, data: unknown): data is z.infer<T> {\n return schema.safeParse(data).success\n}\n","/*\n * Copyright (c) 2022-2024 AccelByte Inc. All Rights Reserved\n * This is licensed software from AccelByte Inc, for limitations\n * and restrictions contact your company contract manager.\n */\nexport class UrlHelper {\n static isCompleteURLString = (urlString: string) => {\n try {\n const url = new URL(urlString)\n return url.hostname !== ''\n } catch (error) {}\n return false\n }\n\n static trimSlashFromStringEnd(pathString: string) {\n let newString = pathString\n while (newString[newString.length - 1] === '/') {\n newString = newString.slice(0, -1)\n }\n return newString\n }\n\n static trimSlashFromStringStart(pathString: string) {\n let newString = pathString\n while (newString[0] === '/') {\n newString = newString.slice(1)\n }\n return newString\n }\n\n static trimSlashFromStringEdges(pathString: string) {\n return UrlHelper.trimSlashFromStringStart(this.trimSlashFromStringEnd(pathString))\n }\n\n static combinePaths(...paths: string[]) {\n const completePath = paths.join('/')\n // Replace 2 or more consecutive slashes with a single slash.\n // This is also the behavior from Node's `path.join`.\n return completePath.replace(/\\/{2,}/g, '/')\n }\n\n static combineURLPaths(urlString: string, ...paths: string[]) {\n const url = new URL(urlString)\n const { origin } = url\n const pathname = UrlHelper.trimSlashFromStringEdges(UrlHelper.combinePaths(url.pathname, ...paths))\n return new URL(pathname, origin).toString()\n }\n\n static removeQueryParam(fullUrlString: string, param: string) {\n const url = new URL(fullUrlString)\n const params = url.searchParams\n const pathname = this.trimSlashFromStringEnd(url.pathname)\n\n // Remove the query parameter\n params.delete(param)\n\n // Preserving other URL attributes\n let newUrlString: string\n if (params.toString() === '') newUrlString = `${url.origin}${pathname}${url.hash}`\n else newUrlString = `${url.origin}${pathname}?${params.toString()}${url.hash}`\n\n return newUrlString\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKA,oBAA0B;AAE1B,IAAI,CAAC,OAAO,QAAQ;AAClB,SAAO,SAAS;AAClB;;;ACHA,mBAA0C;AAEnC,IAAM,WAAN,MAAe;AAkBtB;AAlBa,SACJ,oBAAoB,CAAC,QAA4B,cAAuD;AAC7G,SAAO;AAAA,IACL,GAAG;AAAA,IACH,GAAG;AAAA,IACH,SAAS;AAAA,MACP,GAAG,iCAAQ;AAAA,MACX,GAAG,uCAAW;AAAA,IAChB;AAAA,EACF;AACF;AAVW,SAYJ,aAAa,CAAC,UAA4B;AAC/C,MAAI,aAAAA,QAAM,aAAa,KAAK,KAAK,MAAM,UAAU;AAC/C,WAAO,MAAM,SAAS,UAAU,OAAO,MAAM,SAAS,UAAU;AAAA,EAClE;AACA,SAAO;AACT;;;ACpBF,IAAAC,gBAAyD;AACzD,0BAAe;;;ACDf,WAAsB;AAEf,IAAM,aAAN,MAAM,WAAU;AAqBvB;AArBa,WACJ,SAAS;AADL,WAGJ,OAAO;AAAA,EACZ,QAAQ;AAAA,EACR,SAAS;AACX;AANW,WAQJ,UAAU,MAAM;A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AAGzD,WAAO,OAAO,KAAK;AAGnB,QAAI;AACJ,QAAI,OAAO,SAAS,MAAM,GAAI,gBAAe,GAAG,IAAI,MAAM,GAAG,QAAQ,GAAG,IAAI,IAAI;AAAA,QAC3E,gBAAe,GAAG,IAAI,MAAM,GAAG,QAAQ,IAAI,OAAO,SAAS,CAAC,GAAG,IAAI,IAAI;AAE5E,WAAO;AAAA,EACT;AACF;AA1Da,WACJ,sBAAsB,CAAC,cAAsB;AAClD,MAAI;AACF,UAAM,MAAM,IAAI,IAAI,SAAS;AAC7B,WAAO,IAAI,aAAa;AAAA,EAC1B,SAAS,OAAO;AAAA,EAAC;AACjB,SAAO;AACT;AAPK,IAAM,YAAN;","names":["axios","import_axios","axios","qs","IamErrorCode","import_axios","import_zod","import_zod","import_zod","GrantTokenUrls","LoginUrls","axios"]}
|
|
@@ -135,8 +135,23 @@ var AccelByteSDK = class _AccelByteSDK {
|
|
|
135
135
|
this.token = {};
|
|
136
136
|
}
|
|
137
137
|
createAxiosInstance() {
|
|
138
|
-
|
|
138
|
+
const axiosInstance = Network.create({ baseURL: this.coreConfig.baseURL, ...this.axiosConfig.request });
|
|
139
|
+
const interceptors = this.axiosConfig.interceptors;
|
|
140
|
+
if (interceptors) {
|
|
141
|
+
for (const interceptor of interceptors) {
|
|
142
|
+
if (interceptor.type === "request") {
|
|
143
|
+
axiosInstance.interceptors.request.use(interceptor?.onRequest, interceptor.onError);
|
|
144
|
+
}
|
|
145
|
+
if (interceptor.type === "response") {
|
|
146
|
+
axiosInstance.interceptors.response.use(interceptor?.onSuccess, interceptor.onError);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return axiosInstance;
|
|
139
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Assembles and returns the current Axios instance along with core and Axios configurations.
|
|
154
|
+
*/
|
|
140
155
|
assembly() {
|
|
141
156
|
return {
|
|
142
157
|
axiosInstance: this.axiosInstance,
|
|
@@ -144,6 +159,12 @@ var AccelByteSDK = class _AccelByteSDK {
|
|
|
144
159
|
axiosConfig: this.axiosConfig
|
|
145
160
|
};
|
|
146
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* Creates a new instance of AccelByteSDK with a shallow copy of the current configurations.
|
|
164
|
+
* Optionally allows excluding interceptors.
|
|
165
|
+
* @param {boolean} [opts.interceptors] - Whether to include interceptors in the clone. Default is true.
|
|
166
|
+
* @returns {AccelByteSDK} A new instance of AccelByteSDK with the cloned configuration.
|
|
167
|
+
*/
|
|
147
168
|
clone(opts) {
|
|
148
169
|
const newConfigs = {
|
|
149
170
|
coreConfig: { ...this.coreConfig },
|
|
@@ -154,6 +175,9 @@ var AccelByteSDK = class _AccelByteSDK {
|
|
|
154
175
|
}
|
|
155
176
|
return new _AccelByteSDK(newConfigs);
|
|
156
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
* Adds interceptors to the current Axios configuration.
|
|
180
|
+
*/
|
|
157
181
|
addInterceptors(interceptors) {
|
|
158
182
|
if (!this.axiosConfig.interceptors) {
|
|
159
183
|
this.axiosConfig.interceptors = [];
|
|
@@ -165,12 +189,18 @@ var AccelByteSDK = class _AccelByteSDK {
|
|
|
165
189
|
if (!this.axiosConfig?.interceptors) return this;
|
|
166
190
|
if (!filterCallback) {
|
|
167
191
|
this.axiosConfig.interceptors = void 0;
|
|
192
|
+
this.axiosInstance.interceptors.request.clear();
|
|
193
|
+
this.axiosInstance.interceptors.response.clear();
|
|
168
194
|
return this;
|
|
169
195
|
}
|
|
170
196
|
this.axiosConfig.interceptors = this.axiosConfig.interceptors.filter(filterCallback);
|
|
171
197
|
this.axiosInstance = this.createAxiosInstance();
|
|
172
198
|
return this;
|
|
173
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* Updates the SDK's core and Axios configurations.
|
|
202
|
+
* Merges the provided configurations with the current ones.
|
|
203
|
+
*/
|
|
174
204
|
setConfig({ coreConfig, axiosConfig }) {
|
|
175
205
|
this.coreConfig = {
|
|
176
206
|
...this.coreConfig,
|
|
@@ -178,11 +208,15 @@ var AccelByteSDK = class _AccelByteSDK {
|
|
|
178
208
|
};
|
|
179
209
|
this.axiosConfig = {
|
|
180
210
|
...this.axiosConfig,
|
|
181
|
-
...axiosConfig
|
|
211
|
+
...axiosConfig?.interceptors,
|
|
212
|
+
request: ApiUtils.mergeAxiosConfigs(this.axiosConfig.request, axiosConfig?.request)
|
|
182
213
|
};
|
|
183
214
|
this.axiosInstance = this.createAxiosInstance();
|
|
184
215
|
return this;
|
|
185
216
|
}
|
|
217
|
+
/**
|
|
218
|
+
* Set accessToken and refreshToken and updates the Axios request headers to use Bearer authentication.
|
|
219
|
+
*/
|
|
186
220
|
setToken(token) {
|
|
187
221
|
this.token = {
|
|
188
222
|
...this.token,
|
|
@@ -195,9 +229,15 @@ var AccelByteSDK = class _AccelByteSDK {
|
|
|
195
229
|
};
|
|
196
230
|
this.axiosInstance = this.createAxiosInstance();
|
|
197
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* Removes the currently set token.
|
|
234
|
+
*/
|
|
198
235
|
removeToken() {
|
|
199
236
|
this.token = {};
|
|
200
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* Retrieves the current token configuration.
|
|
240
|
+
*/
|
|
201
241
|
getToken() {
|
|
202
242
|
return this.token;
|
|
203
243
|
}
|