@opexa/portal-sdk 0.59.77 → 0.59.79
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/{chunk-3WS4U4B7.js → chunk-AIJL2W7N.js} +21 -17
- package/dist/chunk-AIJL2W7N.js.map +1 -0
- package/dist/index.cjs +56 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +38 -12
- package/dist/index.js.map +1 -1
- package/dist/services/index.cjs +19 -15
- package/dist/services/index.cjs.map +1 -1
- package/dist/services/index.d.cts +2 -2
- package/dist/services/index.d.ts +2 -2
- package/dist/services/index.js +1 -1
- package/dist/{types-kTe_j8tm.d.cts → types-CLOj9j8f.d.cts} +6 -2
- package/dist/{types-lZQpMvHU.d.ts → types-vlbILiF3.d.ts} +6 -2
- package/package.json +1 -1
- package/dist/chunk-3WS4U4B7.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -3380,13 +3380,13 @@ var RECENT_GAMES_QUERY = gql`
|
|
|
3380
3380
|
}
|
|
3381
3381
|
`;
|
|
3382
3382
|
var ADD_FAVORITE_GAME_MUTATION = gql`
|
|
3383
|
-
mutation AddFavoriteGame($
|
|
3384
|
-
addFavoriteGame(input:
|
|
3383
|
+
mutation AddFavoriteGame($input: AddFavoriteGameInput!) {
|
|
3384
|
+
addFavoriteGame(input: $input)
|
|
3385
3385
|
}
|
|
3386
3386
|
`;
|
|
3387
3387
|
var REMOVE_FAVORITE_GAME_MUTATION = gql`
|
|
3388
|
-
mutation RemoveFavoriteGame($
|
|
3389
|
-
removeFavoriteGame(input:
|
|
3388
|
+
mutation RemoveFavoriteGame($input: RemoveFavoriteGameInput!) {
|
|
3389
|
+
removeFavoriteGame(input: $input)
|
|
3390
3390
|
}
|
|
3391
3391
|
`;
|
|
3392
3392
|
var WALLET_GAMES_QUERY = gql`
|
|
@@ -4544,26 +4544,26 @@ var AuthService = class {
|
|
|
4544
4544
|
body: JSON.stringify(input),
|
|
4545
4545
|
...version === 4 && { credentials: "include" }
|
|
4546
4546
|
});
|
|
4547
|
-
const
|
|
4547
|
+
const body = await res.json();
|
|
4548
4548
|
if (res.ok) {
|
|
4549
4549
|
return {
|
|
4550
4550
|
ok: true,
|
|
4551
|
-
data
|
|
4551
|
+
data: version !== 1 ? body.data ?? body : body
|
|
4552
4552
|
};
|
|
4553
4553
|
}
|
|
4554
|
-
if (
|
|
4554
|
+
if (body.code === "ACCOUNT_BLACKLISTED") {
|
|
4555
4555
|
return {
|
|
4556
4556
|
ok: false,
|
|
4557
4557
|
error: createOperationError("AccountBlacklistedError")
|
|
4558
4558
|
};
|
|
4559
4559
|
}
|
|
4560
|
-
if (
|
|
4560
|
+
if (body.code === "MEMBER_ACCOUNT_SUSPENDED") {
|
|
4561
4561
|
return {
|
|
4562
4562
|
ok: false,
|
|
4563
4563
|
error: createOperationError("AccountSuspendedError")
|
|
4564
4564
|
};
|
|
4565
4565
|
}
|
|
4566
|
-
if (
|
|
4566
|
+
if (body.code === "INVALID_RECAPTCHA_RESPONSE") {
|
|
4567
4567
|
return {
|
|
4568
4568
|
ok: false,
|
|
4569
4569
|
error: createOperationError("InvalidReCAPTCHAResponseError")
|
|
@@ -4644,20 +4644,20 @@ var AuthService = class {
|
|
|
4644
4644
|
...version === 4 && { credentials: "include" }
|
|
4645
4645
|
}
|
|
4646
4646
|
);
|
|
4647
|
-
const
|
|
4647
|
+
const body = await res.json();
|
|
4648
4648
|
if (res.ok) {
|
|
4649
4649
|
return {
|
|
4650
4650
|
ok: true,
|
|
4651
|
-
data
|
|
4651
|
+
data: version !== 1 ? body.data ?? body : body
|
|
4652
4652
|
};
|
|
4653
4653
|
}
|
|
4654
|
-
if (
|
|
4654
|
+
if (body.code === "ACCOUNT_BLACKLISTED") {
|
|
4655
4655
|
return {
|
|
4656
4656
|
ok: false,
|
|
4657
4657
|
error: createOperationError("AccountBlacklistedError")
|
|
4658
4658
|
};
|
|
4659
4659
|
}
|
|
4660
|
-
if (
|
|
4660
|
+
if (body.code === "MEMBER_ACCOUNT_SUSPENDED") {
|
|
4661
4661
|
return {
|
|
4662
4662
|
ok: false,
|
|
4663
4663
|
error: createOperationError("AccountSuspendedError")
|
|
@@ -4682,8 +4682,12 @@ var AuthService = class {
|
|
|
4682
4682
|
}
|
|
4683
4683
|
async destroySession(accessToken, version = 1) {
|
|
4684
4684
|
const headers = new Headers(this.headers);
|
|
4685
|
-
|
|
4686
|
-
|
|
4685
|
+
headers.append("Authorization", `Bearer ${accessToken}`);
|
|
4686
|
+
if (version === 3 || version === 4) {
|
|
4687
|
+
const fingerprint = await getFingerPrint();
|
|
4688
|
+
if (fingerprint) {
|
|
4689
|
+
headers.append("Fingerprint", fingerprint);
|
|
4690
|
+
}
|
|
4687
4691
|
}
|
|
4688
4692
|
try {
|
|
4689
4693
|
const res = await fetch(
|
|
@@ -7538,6 +7542,7 @@ var SessionManager = class {
|
|
|
7538
7542
|
*/
|
|
7539
7543
|
v4AccessToken = null;
|
|
7540
7544
|
v4AccessTokenExpiresAt = null;
|
|
7545
|
+
v4RefreshPromise = null;
|
|
7541
7546
|
constructor(config) {
|
|
7542
7547
|
this.authService = config.authService;
|
|
7543
7548
|
this.walletService = config.walletService;
|
|
@@ -7556,13 +7561,19 @@ var SessionManager = class {
|
|
|
7556
7561
|
persist(data, version) {
|
|
7557
7562
|
const now = /* @__PURE__ */ new Date();
|
|
7558
7563
|
if (version === 4) {
|
|
7559
|
-
|
|
7564
|
+
if (!data.session || !data.accessToken) {
|
|
7565
|
+
this.logger.error(
|
|
7566
|
+
"Malformed session response: expected 'session' and 'accessToken'."
|
|
7567
|
+
);
|
|
7568
|
+
return false;
|
|
7569
|
+
}
|
|
7570
|
+
this.v4AccessToken = data.accessToken;
|
|
7560
7571
|
this.v4AccessTokenExpiresAt = addMinutes(now, 5).getTime();
|
|
7561
7572
|
localStorage.setItem(
|
|
7562
7573
|
this.storageKey,
|
|
7563
7574
|
JSON.stringify({ version, session: data.session })
|
|
7564
7575
|
);
|
|
7565
|
-
return;
|
|
7576
|
+
return true;
|
|
7566
7577
|
}
|
|
7567
7578
|
localStorage.setItem(
|
|
7568
7579
|
this.storageKey,
|
|
@@ -7573,6 +7584,16 @@ var SessionManager = class {
|
|
|
7573
7584
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
7574
7585
|
})
|
|
7575
7586
|
);
|
|
7587
|
+
return true;
|
|
7588
|
+
}
|
|
7589
|
+
malformedResponseError() {
|
|
7590
|
+
return {
|
|
7591
|
+
ok: false,
|
|
7592
|
+
error: {
|
|
7593
|
+
name: "UnknownError",
|
|
7594
|
+
message: "Something went wrong."
|
|
7595
|
+
}
|
|
7596
|
+
};
|
|
7576
7597
|
}
|
|
7577
7598
|
async create(input, version = 1) {
|
|
7578
7599
|
if (this.isServer) {
|
|
@@ -7610,7 +7631,7 @@ var SessionManager = class {
|
|
|
7610
7631
|
maxAttempt: 5
|
|
7611
7632
|
})();
|
|
7612
7633
|
if (!r1.ok) return r1;
|
|
7613
|
-
this.persist(r1.data, version);
|
|
7634
|
+
if (!this.persist(r1.data, version)) return this.malformedResponseError();
|
|
7614
7635
|
return {
|
|
7615
7636
|
ok: true,
|
|
7616
7637
|
data: null
|
|
@@ -7619,7 +7640,7 @@ var SessionManager = class {
|
|
|
7619
7640
|
if (input.type === "MOBILE_NUMBER") {
|
|
7620
7641
|
const res2 = await this.authService.createSession(input, version);
|
|
7621
7642
|
if (res2.ok) {
|
|
7622
|
-
this.persist(res2.data, version);
|
|
7643
|
+
if (!this.persist(res2.data, version)) return this.malformedResponseError();
|
|
7623
7644
|
return {
|
|
7624
7645
|
ok: true,
|
|
7625
7646
|
data: null
|
|
@@ -7637,7 +7658,7 @@ var SessionManager = class {
|
|
|
7637
7658
|
version
|
|
7638
7659
|
);
|
|
7639
7660
|
if (res2.ok) {
|
|
7640
|
-
this.persist(res2.data, version);
|
|
7661
|
+
if (!this.persist(res2.data, version)) return this.malformedResponseError();
|
|
7641
7662
|
return {
|
|
7642
7663
|
ok: true,
|
|
7643
7664
|
data: null
|
|
@@ -7649,7 +7670,7 @@ var SessionManager = class {
|
|
|
7649
7670
|
localStorage.setItem(this.platformStorageKey, "CABINET");
|
|
7650
7671
|
const res2 = await this.authService.createSession(input, version);
|
|
7651
7672
|
if (res2.ok) {
|
|
7652
|
-
this.persist(res2.data, version);
|
|
7673
|
+
if (!this.persist(res2.data, version)) return this.malformedResponseError();
|
|
7653
7674
|
return {
|
|
7654
7675
|
ok: true,
|
|
7655
7676
|
data: null
|
|
@@ -7667,7 +7688,7 @@ var SessionManager = class {
|
|
|
7667
7688
|
}
|
|
7668
7689
|
};
|
|
7669
7690
|
}
|
|
7670
|
-
this.persist(res.data, version);
|
|
7691
|
+
if (!this.persist(res.data, version)) return this.malformedResponseError();
|
|
7671
7692
|
return {
|
|
7672
7693
|
ok: true,
|
|
7673
7694
|
data: null
|
|
@@ -7678,8 +7699,8 @@ var SessionManager = class {
|
|
|
7678
7699
|
if (res.ok) {
|
|
7679
7700
|
if (this.isServer) {
|
|
7680
7701
|
this.logger.warn("'localStorage' is not available on the server.");
|
|
7681
|
-
} else {
|
|
7682
|
-
this.
|
|
7702
|
+
} else if (!this.persist(res.data, 1)) {
|
|
7703
|
+
return this.malformedResponseError();
|
|
7683
7704
|
}
|
|
7684
7705
|
return { ok: true };
|
|
7685
7706
|
} else {
|
|
@@ -7858,6 +7879,15 @@ var SessionManager = class {
|
|
|
7858
7879
|
return await this.refreshV4(session);
|
|
7859
7880
|
}
|
|
7860
7881
|
async refreshV4(session) {
|
|
7882
|
+
if (this.v4RefreshPromise) return await this.v4RefreshPromise;
|
|
7883
|
+
this.v4RefreshPromise = this.requestV4Refresh(session);
|
|
7884
|
+
try {
|
|
7885
|
+
return await this.v4RefreshPromise;
|
|
7886
|
+
} finally {
|
|
7887
|
+
this.v4RefreshPromise = null;
|
|
7888
|
+
}
|
|
7889
|
+
}
|
|
7890
|
+
async requestV4Refresh(session) {
|
|
7861
7891
|
this.logger.info("Refreshing session...");
|
|
7862
7892
|
this.refreshing = true;
|
|
7863
7893
|
const res = await this.authService.refreshSession(void 0, 4);
|
|
@@ -11808,10 +11838,10 @@ var Sdk = class {
|
|
|
11808
11838
|
};
|
|
11809
11839
|
}
|
|
11810
11840
|
async addFavoriteGame(input) {
|
|
11811
|
-
return await this.portalService.addFavoriteGame(input);
|
|
11841
|
+
return await this.portalService.addFavoriteGame({ input });
|
|
11812
11842
|
}
|
|
11813
11843
|
async removeFavoriteGame(input) {
|
|
11814
|
-
return await this.portalService.removeFavoriteGame(input);
|
|
11844
|
+
return await this.portalService.removeFavoriteGame({ input });
|
|
11815
11845
|
}
|
|
11816
11846
|
/*
|
|
11817
11847
|
*=============================================
|