@accelbyte/sdk 0.2.0-beta.14 → 0.2.0-beta.17
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.js +44 -56
- package/dist/cjs/node/index.js.map +1 -1
- package/dist/es/browser/AccelbyteSdkFactory.js +41 -53
- package/dist/es/browser/AccelbyteSdkFactory.js.map +1 -1
- package/dist/es/browser/api/iam/InputValidationHelper.js +1 -1
- package/dist/es/browser/api/legal/LegalHelper.js +1 -1
- package/dist/es/browser/utils/SdkCache.js +1 -1
- package/dist/es/node/AccelbyteSdkFactory.js +41 -53
- package/dist/es/node/AccelbyteSdkFactory.js.map +1 -1
- package/dist/es/node/api/iam/InputValidationHelper.js +1 -1
- package/dist/es/node/api/legal/LegalHelper.js +1 -1
- package/dist/es/node/utils/SdkCache.js +1 -1
- package/dist/index.d.ts +0 -1
- package/examples/next/package.json +1 -1
- package/examples/next/yarn.lock +43 -10
- package/examples/node/index.js +58 -0
- package/examples/node/index.mjs +33 -33
- package/examples/node/package.json +3 -2
- package/examples/node/yarn.lock +43 -10
- package/examples/vite/package.json +2 -2
- package/examples/vite/yarn.lock +61 -28
- package/package.json +10 -8
- package/CHANGELOG.md +0 -303
package/dist/cjs/node/index.js
CHANGED
|
@@ -6,11 +6,11 @@ var axios = require('axios');
|
|
|
6
6
|
var qs = require('query-string');
|
|
7
7
|
var zod = require('zod');
|
|
8
8
|
var validator = require('@accelbyte/validator');
|
|
9
|
-
var isEmpty = require('validator/lib/isEmpty');
|
|
9
|
+
var isEmpty = require('validator/lib/isEmpty.js');
|
|
10
10
|
var cryptoJs = require('crypto-js');
|
|
11
11
|
var platform = require('platform');
|
|
12
|
-
var isURL = require('validator/lib/isURL');
|
|
13
|
-
var isEqual = require('lodash/isEqual');
|
|
12
|
+
var isURL = require('validator/lib/isURL.js');
|
|
13
|
+
var isEqual = require('lodash/isEqual.js');
|
|
14
14
|
var buffer = require('buffer');
|
|
15
15
|
|
|
16
16
|
function _interopNamespaceDefault(e) {
|
|
@@ -9791,30 +9791,48 @@ var PlatformVersion = {
|
|
|
9791
9791
|
* This is licensed software from AccelByte Inc, for limitations
|
|
9792
9792
|
* and restrictions contact your company contract manager.
|
|
9793
9793
|
*/
|
|
9794
|
-
|
|
9795
|
-
* This is the main SDK class
|
|
9796
|
-
* ----------------
|
|
9797
|
-
* const sdk = await Accelbyte.SDK(..)
|
|
9798
|
-
*
|
|
9799
|
-
* // provide custom axios args
|
|
9800
|
-
* const options = { baseUrl: 'http://service.url', headers: { customHeader1: 'dummy1' } }
|
|
9801
|
-
*
|
|
9802
|
-
* // obtain the service
|
|
9803
|
-
* const {response, error} = sdk.iam.getUser(options)
|
|
9804
|
-
* const {response, error} = sdk.iam.postWhatever(options)
|
|
9805
|
-
* ----------------
|
|
9806
|
-
*/
|
|
9794
|
+
const TIMEOUT_TO_DIAGNOSTICS = 1000; // 1 sec
|
|
9807
9795
|
class AccelbyteSDKFactory {
|
|
9808
9796
|
constructor(options, config, events) {
|
|
9809
|
-
|
|
9810
|
-
|
|
9811
|
-
|
|
9812
|
-
|
|
9813
|
-
|
|
9814
|
-
|
|
9815
|
-
|
|
9816
|
-
|
|
9817
|
-
|
|
9797
|
+
/**
|
|
9798
|
+
* Diagnose all services by comparing them with the sdk codegen versions and raise a WARN log if mismatch
|
|
9799
|
+
*/
|
|
9800
|
+
this.doVersionDiagnostics = () => {
|
|
9801
|
+
const mapServices = {
|
|
9802
|
+
[IamVersion.name]: IamVersion,
|
|
9803
|
+
[BuildinfoVersion.name]: BuildinfoVersion,
|
|
9804
|
+
[PlatformVersion.name]: PlatformVersion,
|
|
9805
|
+
[GdprVersion.name]: GdprVersion,
|
|
9806
|
+
[EventVersion.name]: EventVersion
|
|
9807
|
+
};
|
|
9808
|
+
/* Call /<service-name>/version to pull service version
|
|
9809
|
+
GET https://development.accelbyte.io/iam/version
|
|
9810
|
+
{
|
|
9811
|
+
"buildDate": "2023-02-22T04:12:23+00:00",
|
|
9812
|
+
"gitHash": "abc",
|
|
9813
|
+
"name": "justice-iam-service",
|
|
9814
|
+
"realm": "dev",
|
|
9815
|
+
"version": "5.28.0"
|
|
9816
|
+
}
|
|
9817
|
+
*/
|
|
9818
|
+
const axiosRequest = service_ => Network.create(this.config).get(`/${service_.title}/version`);
|
|
9819
|
+
Promise.all([
|
|
9820
|
+
axiosRequest(IamVersion),
|
|
9821
|
+
axiosRequest(BuildinfoVersion),
|
|
9822
|
+
axiosRequest(BasicVersion),
|
|
9823
|
+
axiosRequest(PlatformVersion),
|
|
9824
|
+
axiosRequest(GdprVersion),
|
|
9825
|
+
axiosRequest(EventVersion)
|
|
9826
|
+
]).then(values => {
|
|
9827
|
+
values.forEach(res => {
|
|
9828
|
+
const remoteService = res.data;
|
|
9829
|
+
const sdkService = mapServices[remoteService.name];
|
|
9830
|
+
if (sdkService?.version !== remoteService.version) {
|
|
9831
|
+
console.log(`WARN: SDK(${sdkService.title}) v${sdkService.version} doesn't match service version ${remoteService.version}`);
|
|
9832
|
+
}
|
|
9833
|
+
});
|
|
9834
|
+
});
|
|
9835
|
+
};
|
|
9818
9836
|
this.getRefreshToken = () => this.refreshToken;
|
|
9819
9837
|
this.getConfig = () => this.config;
|
|
9820
9838
|
this.mergeConfigs = (configOverride) => {
|
|
@@ -9862,6 +9880,7 @@ class AccelbyteSDKFactory {
|
|
|
9862
9880
|
const { baseURL, clientId } = this.options;
|
|
9863
9881
|
injectAuthInterceptors(clientId, this.getConfig, this.events?.onSessionExpired, this.events?.onGetUserSession, this.getRefreshToken);
|
|
9864
9882
|
injectErrorInterceptors(baseURL, this.events?.onUserEligibilityChange, this.events?.onError);
|
|
9883
|
+
setTimeout(() => this.doVersionDiagnostics, TIMEOUT_TO_DIAGNOSTICS);
|
|
9865
9884
|
return {
|
|
9866
9885
|
refreshTokens: (accessToken, refreshToken) => this.refreshTokensImpl(accessToken, refreshToken),
|
|
9867
9886
|
IAM: {
|
|
@@ -9916,37 +9935,6 @@ class AccelbyteSDKFactory {
|
|
|
9916
9935
|
AccelbyteConfig: {
|
|
9917
9936
|
PublicTemplate: (overrides) => ApiFactory.publicTemplateApi(this.config, this.options.namespace, this.override(overrides)),
|
|
9918
9937
|
version: OdinConfigVersion
|
|
9919
|
-
},
|
|
9920
|
-
version: () => {
|
|
9921
|
-
// const vv = [IamVersion, BuildinfoVersion, BasicVersion, PlatformVersion, GdprVersion, EventVersion]
|
|
9922
|
-
// console.log('SDK', vv)
|
|
9923
|
-
// this.compare(IamVersion)
|
|
9924
|
-
// this.compare(BuildinfoVersion)
|
|
9925
|
-
// this.compare(BasicVersion)
|
|
9926
|
-
// this.compare(PlatformVersion)
|
|
9927
|
-
// this.compare(GdprVersion)
|
|
9928
|
-
// this.compare(EventVersion)
|
|
9929
|
-
// let URL1 = "https://www.something.com"
|
|
9930
|
-
// let URL2 = "https://www.something1.com"
|
|
9931
|
-
// let URL3 = "https://www.something2.com"
|
|
9932
|
-
const mapServices = {
|
|
9933
|
-
[IamVersion.name]: IamVersion,
|
|
9934
|
-
[BuildinfoVersion.name]: BuildinfoVersion,
|
|
9935
|
-
[PlatformVersion.name]: PlatformVersion,
|
|
9936
|
-
[GdprVersion.name]: GdprVersion,
|
|
9937
|
-
[EventVersion.name]: EventVersion
|
|
9938
|
-
};
|
|
9939
|
-
const req = service => Network.create(this.config).get(`/${service.title}/version`);
|
|
9940
|
-
console.log('------ GET SERVICE VERSIONS ');
|
|
9941
|
-
Promise.all([req(IamVersion), req(BuildinfoVersion), req(BasicVersion)]).then(values => {
|
|
9942
|
-
values.map(res => {
|
|
9943
|
-
console.log(res.data);
|
|
9944
|
-
const service = [mapServices[res.data.name]];
|
|
9945
|
-
if (service?.version !== res.data.version) {
|
|
9946
|
-
console.log(`WARN: SDK(${service.title}) v${service.version} doesn't match service version ${res.data.version}`);
|
|
9947
|
-
}
|
|
9948
|
-
});
|
|
9949
|
-
});
|
|
9950
9938
|
}
|
|
9951
9939
|
};
|
|
9952
9940
|
}
|