@opexa/portal-sdk 0.52.2 → 0.52.4
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/index.cjs +108 -92
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +108 -92
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -845,7 +845,25 @@ var CREATE_MAYA_DEPOSIT_MUTATION = gql`
|
|
|
845
845
|
var CREATE_TEST_DEPOSIT_MUTATION = gql`
|
|
846
846
|
mutation CreateTestDeposit($input: CreateTestDepositInput!) {
|
|
847
847
|
createTestDeposit(input: $input) {
|
|
848
|
-
|
|
848
|
+
... on DepositPromoMaximumAmountExceededError {
|
|
849
|
+
__typename
|
|
850
|
+
}
|
|
851
|
+
... on DepositPromoMinimumAmountNotMetError {
|
|
852
|
+
__typename
|
|
853
|
+
}
|
|
854
|
+
... on MaximumDepositAmountExceededError {
|
|
855
|
+
__typename
|
|
856
|
+
}
|
|
857
|
+
... on MinimumDepositAmountNotMetError {
|
|
858
|
+
__typename
|
|
859
|
+
}
|
|
860
|
+
... on MinimumFirstDepositAmountNotMetError {
|
|
861
|
+
__typename
|
|
862
|
+
}
|
|
863
|
+
... on PromoNotEnabledError {
|
|
864
|
+
__typename
|
|
865
|
+
}
|
|
866
|
+
... on WalletDoesNotExistError {
|
|
849
867
|
__typename
|
|
850
868
|
}
|
|
851
869
|
}
|
|
@@ -5518,8 +5536,8 @@ function pollable(func, config) {
|
|
|
5518
5536
|
};
|
|
5519
5537
|
}
|
|
5520
5538
|
|
|
5521
|
-
// src/sdk/session-manager
|
|
5522
|
-
var
|
|
5539
|
+
// src/sdk/session-manager.ts
|
|
5540
|
+
var SessionManager = class {
|
|
5523
5541
|
logger;
|
|
5524
5542
|
storageKey = "session";
|
|
5525
5543
|
platformStorageKey = "session/platform";
|
|
@@ -5530,6 +5548,10 @@ var SessionManagerCookie = class {
|
|
|
5530
5548
|
this.authService = config.authService;
|
|
5531
5549
|
this.walletService = config.walletService;
|
|
5532
5550
|
this.logger = config.logger;
|
|
5551
|
+
if (config.sessionPrefix) {
|
|
5552
|
+
this.storageKey = `${config.sessionPrefix}/${this.storageKey}`;
|
|
5553
|
+
this.platformStorageKey = `${config.sessionPrefix}/${this.platformStorageKey}`;
|
|
5554
|
+
}
|
|
5533
5555
|
}
|
|
5534
5556
|
get refreshing() {
|
|
5535
5557
|
return this._refreshing;
|
|
@@ -5538,6 +5560,16 @@ var SessionManagerCookie = class {
|
|
|
5538
5560
|
this._refreshing = value;
|
|
5539
5561
|
}
|
|
5540
5562
|
async create(input) {
|
|
5563
|
+
if (this.isServer) {
|
|
5564
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
5565
|
+
return {
|
|
5566
|
+
ok: false,
|
|
5567
|
+
error: {
|
|
5568
|
+
name: "UnknownError",
|
|
5569
|
+
message: "Server sign in is not supported."
|
|
5570
|
+
}
|
|
5571
|
+
};
|
|
5572
|
+
}
|
|
5541
5573
|
if (input.type === "MAYA") {
|
|
5542
5574
|
localStorage.setItem(this.platformStorageKey, "MAYA");
|
|
5543
5575
|
const f0 = () => this.walletService.mayaSession({ id: input.sessionId });
|
|
@@ -5564,14 +5596,13 @@ var SessionManagerCookie = class {
|
|
|
5564
5596
|
})();
|
|
5565
5597
|
if (!r1.ok) return r1;
|
|
5566
5598
|
const now2 = /* @__PURE__ */ new Date();
|
|
5567
|
-
|
|
5599
|
+
localStorage.setItem(
|
|
5568
5600
|
this.storageKey,
|
|
5569
5601
|
JSON.stringify({
|
|
5570
5602
|
...r1.data,
|
|
5571
5603
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5572
5604
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5573
|
-
})
|
|
5574
|
-
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
5605
|
+
})
|
|
5575
5606
|
);
|
|
5576
5607
|
return {
|
|
5577
5608
|
ok: true,
|
|
@@ -5582,16 +5613,13 @@ var SessionManagerCookie = class {
|
|
|
5582
5613
|
const res2 = await this.authService.createSession(input);
|
|
5583
5614
|
if (res2.ok) {
|
|
5584
5615
|
const now2 = /* @__PURE__ */ new Date();
|
|
5585
|
-
|
|
5616
|
+
localStorage.setItem(
|
|
5586
5617
|
this.storageKey,
|
|
5587
5618
|
JSON.stringify({
|
|
5588
5619
|
...res2.data,
|
|
5589
5620
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5590
5621
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5591
|
-
})
|
|
5592
|
-
{
|
|
5593
|
-
expires: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5594
|
-
}
|
|
5622
|
+
})
|
|
5595
5623
|
);
|
|
5596
5624
|
return {
|
|
5597
5625
|
ok: true,
|
|
@@ -5603,18 +5631,18 @@ var SessionManagerCookie = class {
|
|
|
5603
5631
|
if (input.type === "SOCIALS" || input.type === "TOKEN") {
|
|
5604
5632
|
const res2 = await this.authService.createSession({
|
|
5605
5633
|
type: "SOCIALS",
|
|
5606
|
-
token: input.token
|
|
5634
|
+
token: input.token,
|
|
5635
|
+
channel: input.channel
|
|
5607
5636
|
});
|
|
5608
5637
|
if (res2.ok) {
|
|
5609
5638
|
const now2 = /* @__PURE__ */ new Date();
|
|
5610
|
-
|
|
5639
|
+
localStorage.setItem(
|
|
5611
5640
|
this.storageKey,
|
|
5612
5641
|
JSON.stringify({
|
|
5613
5642
|
...res2.data,
|
|
5614
5643
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5615
5644
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5616
|
-
})
|
|
5617
|
-
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
5645
|
+
})
|
|
5618
5646
|
);
|
|
5619
5647
|
return {
|
|
5620
5648
|
ok: true,
|
|
@@ -5628,14 +5656,13 @@ var SessionManagerCookie = class {
|
|
|
5628
5656
|
const res2 = await this.authService.createSession(input);
|
|
5629
5657
|
if (res2.ok) {
|
|
5630
5658
|
const now2 = /* @__PURE__ */ new Date();
|
|
5631
|
-
|
|
5659
|
+
localStorage.setItem(
|
|
5632
5660
|
this.storageKey,
|
|
5633
5661
|
JSON.stringify({
|
|
5634
5662
|
...res2.data,
|
|
5635
5663
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5636
5664
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5637
|
-
})
|
|
5638
|
-
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
5665
|
+
})
|
|
5639
5666
|
);
|
|
5640
5667
|
return {
|
|
5641
5668
|
ok: true,
|
|
@@ -5655,14 +5682,13 @@ var SessionManagerCookie = class {
|
|
|
5655
5682
|
};
|
|
5656
5683
|
}
|
|
5657
5684
|
const now = /* @__PURE__ */ new Date();
|
|
5658
|
-
|
|
5685
|
+
localStorage.setItem(
|
|
5659
5686
|
this.storageKey,
|
|
5660
5687
|
JSON.stringify({
|
|
5661
5688
|
...res.data,
|
|
5662
5689
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
5663
5690
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
5664
|
-
})
|
|
5665
|
-
{}
|
|
5691
|
+
})
|
|
5666
5692
|
);
|
|
5667
5693
|
return {
|
|
5668
5694
|
ok: true,
|
|
@@ -5674,18 +5700,15 @@ var SessionManagerCookie = class {
|
|
|
5674
5700
|
if (res.ok) {
|
|
5675
5701
|
const now = /* @__PURE__ */ new Date();
|
|
5676
5702
|
if (this.isServer) {
|
|
5677
|
-
this.logger.warn("'
|
|
5703
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
5678
5704
|
} else {
|
|
5679
|
-
|
|
5705
|
+
localStorage.setItem(
|
|
5680
5706
|
this.storageKey,
|
|
5681
5707
|
JSON.stringify({
|
|
5682
5708
|
...res.data,
|
|
5683
5709
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
5684
5710
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
5685
|
-
})
|
|
5686
|
-
{
|
|
5687
|
-
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
5688
|
-
}
|
|
5711
|
+
})
|
|
5689
5712
|
);
|
|
5690
5713
|
}
|
|
5691
5714
|
return { ok: true };
|
|
@@ -5695,7 +5718,7 @@ var SessionManagerCookie = class {
|
|
|
5695
5718
|
}
|
|
5696
5719
|
async get() {
|
|
5697
5720
|
if (this.isServer) {
|
|
5698
|
-
this.logger.warn("'
|
|
5721
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
5699
5722
|
return {
|
|
5700
5723
|
ok: true,
|
|
5701
5724
|
data: null
|
|
@@ -5705,7 +5728,7 @@ var SessionManagerCookie = class {
|
|
|
5705
5728
|
await sleep(1e3);
|
|
5706
5729
|
return await this.get();
|
|
5707
5730
|
}
|
|
5708
|
-
const val =
|
|
5731
|
+
const val = localStorage.getItem(this.storageKey);
|
|
5709
5732
|
if (!val) {
|
|
5710
5733
|
return {
|
|
5711
5734
|
ok: true,
|
|
@@ -5719,7 +5742,7 @@ var SessionManagerCookie = class {
|
|
|
5719
5742
|
const refreshTokenExpiresAt = new Date(obj.refreshTokenExpiresAt);
|
|
5720
5743
|
if (isAfter(now, refreshTokenExpiresAt)) {
|
|
5721
5744
|
this.logger.warn("Session expired. Logging out..");
|
|
5722
|
-
|
|
5745
|
+
localStorage.removeItem(this.storageKey);
|
|
5723
5746
|
return {
|
|
5724
5747
|
ok: false,
|
|
5725
5748
|
error: {
|
|
@@ -5736,7 +5759,7 @@ var SessionManagerCookie = class {
|
|
|
5736
5759
|
if (!res.ok) {
|
|
5737
5760
|
this.logger.error(`Failed to refresh session: ${res.error.message}`);
|
|
5738
5761
|
if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
|
|
5739
|
-
|
|
5762
|
+
localStorage.removeItem(this.storageKey);
|
|
5740
5763
|
return {
|
|
5741
5764
|
ok: false,
|
|
5742
5765
|
error: res.error
|
|
@@ -5757,9 +5780,7 @@ var SessionManagerCookie = class {
|
|
|
5757
5780
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
5758
5781
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
5759
5782
|
};
|
|
5760
|
-
|
|
5761
|
-
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
5762
|
-
});
|
|
5783
|
+
localStorage.setItem(this.storageKey, JSON.stringify(obj));
|
|
5763
5784
|
}
|
|
5764
5785
|
return {
|
|
5765
5786
|
ok: true,
|
|
@@ -5777,13 +5798,13 @@ var SessionManagerCookie = class {
|
|
|
5777
5798
|
}
|
|
5778
5799
|
async refresh() {
|
|
5779
5800
|
if (this.isServer) {
|
|
5780
|
-
this.logger.warn("'
|
|
5801
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
5781
5802
|
return {
|
|
5782
5803
|
ok: true,
|
|
5783
5804
|
data: null
|
|
5784
5805
|
};
|
|
5785
5806
|
}
|
|
5786
|
-
const val =
|
|
5807
|
+
const val = localStorage.getItem(this.storageKey);
|
|
5787
5808
|
if (!val) {
|
|
5788
5809
|
return {
|
|
5789
5810
|
ok: true,
|
|
@@ -5800,7 +5821,7 @@ var SessionManagerCookie = class {
|
|
|
5800
5821
|
if (!res.ok) {
|
|
5801
5822
|
this.logger.error(`Failed to refresh session: ${res.error.message}`);
|
|
5802
5823
|
if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
|
|
5803
|
-
|
|
5824
|
+
localStorage.removeItem(this.storageKey);
|
|
5804
5825
|
return {
|
|
5805
5826
|
ok: false,
|
|
5806
5827
|
error: res.error
|
|
@@ -5821,9 +5842,7 @@ var SessionManagerCookie = class {
|
|
|
5821
5842
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
5822
5843
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
5823
5844
|
};
|
|
5824
|
-
|
|
5825
|
-
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
5826
|
-
});
|
|
5845
|
+
localStorage.setItem(this.storageKey, JSON.stringify(obj));
|
|
5827
5846
|
return {
|
|
5828
5847
|
ok: true,
|
|
5829
5848
|
data: obj
|
|
@@ -5840,18 +5859,18 @@ var SessionManagerCookie = class {
|
|
|
5840
5859
|
}
|
|
5841
5860
|
async destroy() {
|
|
5842
5861
|
if (this.isServer) {
|
|
5843
|
-
this.logger.warn("'
|
|
5862
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
5844
5863
|
return;
|
|
5845
5864
|
}
|
|
5846
5865
|
const res = await this.get();
|
|
5847
5866
|
if (res.data?.accessToken) {
|
|
5848
5867
|
await this.authService.destroySession(res.data.accessToken);
|
|
5849
5868
|
}
|
|
5850
|
-
|
|
5869
|
+
localStorage.removeItem(this.storageKey);
|
|
5851
5870
|
}
|
|
5852
5871
|
async verify() {
|
|
5853
5872
|
if (this.isServer) {
|
|
5854
|
-
this.logger.warn("'
|
|
5873
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
5855
5874
|
return true;
|
|
5856
5875
|
}
|
|
5857
5876
|
const s = await this.get();
|
|
@@ -5861,13 +5880,13 @@ var SessionManagerCookie = class {
|
|
|
5861
5880
|
if (!s.data) return true;
|
|
5862
5881
|
const v = await this.authService.verifySession(s.data.accessToken);
|
|
5863
5882
|
if (!v) {
|
|
5864
|
-
|
|
5883
|
+
localStorage.removeItem(this.storageKey);
|
|
5865
5884
|
}
|
|
5866
5885
|
return v;
|
|
5867
5886
|
}
|
|
5868
5887
|
get onMaya() {
|
|
5869
5888
|
if (this.isServer) {
|
|
5870
|
-
this.logger.warn("'
|
|
5889
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
5871
5890
|
return false;
|
|
5872
5891
|
}
|
|
5873
5892
|
return localStorage.getItem(this.platformStorageKey) === "MAYA";
|
|
@@ -5883,9 +5902,7 @@ var SessionManagerCookie = class {
|
|
|
5883
5902
|
return typeof window === "undefined";
|
|
5884
5903
|
}
|
|
5885
5904
|
};
|
|
5886
|
-
|
|
5887
|
-
// src/sdk/session-manager.ts
|
|
5888
|
-
var SessionManager = class {
|
|
5905
|
+
var SessionManagerCookie = class {
|
|
5889
5906
|
logger;
|
|
5890
5907
|
storageKey = "session";
|
|
5891
5908
|
platformStorageKey = "session/platform";
|
|
@@ -5896,10 +5913,6 @@ var SessionManager = class {
|
|
|
5896
5913
|
this.authService = config.authService;
|
|
5897
5914
|
this.walletService = config.walletService;
|
|
5898
5915
|
this.logger = config.logger;
|
|
5899
|
-
if (config.sessionPrefix) {
|
|
5900
|
-
this.storageKey = `${config.sessionPrefix}/${this.storageKey}`;
|
|
5901
|
-
this.platformStorageKey = `${config.sessionPrefix}/${this.platformStorageKey}`;
|
|
5902
|
-
}
|
|
5903
5916
|
}
|
|
5904
5917
|
get refreshing() {
|
|
5905
5918
|
return this._refreshing;
|
|
@@ -5908,16 +5921,6 @@ var SessionManager = class {
|
|
|
5908
5921
|
this._refreshing = value;
|
|
5909
5922
|
}
|
|
5910
5923
|
async create(input) {
|
|
5911
|
-
if (this.isServer) {
|
|
5912
|
-
this.logger.warn("'localStorage' is not available on the server.");
|
|
5913
|
-
return {
|
|
5914
|
-
ok: false,
|
|
5915
|
-
error: {
|
|
5916
|
-
name: "UnknownError",
|
|
5917
|
-
message: "Server sign in is not supported."
|
|
5918
|
-
}
|
|
5919
|
-
};
|
|
5920
|
-
}
|
|
5921
5924
|
if (input.type === "MAYA") {
|
|
5922
5925
|
localStorage.setItem(this.platformStorageKey, "MAYA");
|
|
5923
5926
|
const f0 = () => this.walletService.mayaSession({ id: input.sessionId });
|
|
@@ -5944,13 +5947,14 @@ var SessionManager = class {
|
|
|
5944
5947
|
})();
|
|
5945
5948
|
if (!r1.ok) return r1;
|
|
5946
5949
|
const now2 = /* @__PURE__ */ new Date();
|
|
5947
|
-
|
|
5950
|
+
cookies.set(
|
|
5948
5951
|
this.storageKey,
|
|
5949
5952
|
JSON.stringify({
|
|
5950
5953
|
...r1.data,
|
|
5951
5954
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5952
5955
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5953
|
-
})
|
|
5956
|
+
}),
|
|
5957
|
+
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
5954
5958
|
);
|
|
5955
5959
|
return {
|
|
5956
5960
|
ok: true,
|
|
@@ -5961,13 +5965,16 @@ var SessionManager = class {
|
|
|
5961
5965
|
const res2 = await this.authService.createSession(input);
|
|
5962
5966
|
if (res2.ok) {
|
|
5963
5967
|
const now2 = /* @__PURE__ */ new Date();
|
|
5964
|
-
|
|
5968
|
+
cookies.set(
|
|
5965
5969
|
this.storageKey,
|
|
5966
5970
|
JSON.stringify({
|
|
5967
5971
|
...res2.data,
|
|
5968
5972
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5969
5973
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5970
|
-
})
|
|
5974
|
+
}),
|
|
5975
|
+
{
|
|
5976
|
+
expires: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5977
|
+
}
|
|
5971
5978
|
);
|
|
5972
5979
|
return {
|
|
5973
5980
|
ok: true,
|
|
@@ -5979,18 +5986,18 @@ var SessionManager = class {
|
|
|
5979
5986
|
if (input.type === "SOCIALS" || input.type === "TOKEN") {
|
|
5980
5987
|
const res2 = await this.authService.createSession({
|
|
5981
5988
|
type: "SOCIALS",
|
|
5982
|
-
token: input.token
|
|
5983
|
-
channel: input.channel
|
|
5989
|
+
token: input.token
|
|
5984
5990
|
});
|
|
5985
5991
|
if (res2.ok) {
|
|
5986
5992
|
const now2 = /* @__PURE__ */ new Date();
|
|
5987
|
-
|
|
5993
|
+
cookies.set(
|
|
5988
5994
|
this.storageKey,
|
|
5989
5995
|
JSON.stringify({
|
|
5990
5996
|
...res2.data,
|
|
5991
5997
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5992
5998
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5993
|
-
})
|
|
5999
|
+
}),
|
|
6000
|
+
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
5994
6001
|
);
|
|
5995
6002
|
return {
|
|
5996
6003
|
ok: true,
|
|
@@ -6004,13 +6011,14 @@ var SessionManager = class {
|
|
|
6004
6011
|
const res2 = await this.authService.createSession(input);
|
|
6005
6012
|
if (res2.ok) {
|
|
6006
6013
|
const now2 = /* @__PURE__ */ new Date();
|
|
6007
|
-
|
|
6014
|
+
cookies.set(
|
|
6008
6015
|
this.storageKey,
|
|
6009
6016
|
JSON.stringify({
|
|
6010
6017
|
...res2.data,
|
|
6011
6018
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
6012
6019
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
6013
|
-
})
|
|
6020
|
+
}),
|
|
6021
|
+
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
6014
6022
|
);
|
|
6015
6023
|
return {
|
|
6016
6024
|
ok: true,
|
|
@@ -6030,13 +6038,14 @@ var SessionManager = class {
|
|
|
6030
6038
|
};
|
|
6031
6039
|
}
|
|
6032
6040
|
const now = /* @__PURE__ */ new Date();
|
|
6033
|
-
|
|
6041
|
+
cookies.set(
|
|
6034
6042
|
this.storageKey,
|
|
6035
6043
|
JSON.stringify({
|
|
6036
6044
|
...res.data,
|
|
6037
6045
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
6038
6046
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
6039
|
-
})
|
|
6047
|
+
}),
|
|
6048
|
+
{}
|
|
6040
6049
|
);
|
|
6041
6050
|
return {
|
|
6042
6051
|
ok: true,
|
|
@@ -6048,15 +6057,18 @@ var SessionManager = class {
|
|
|
6048
6057
|
if (res.ok) {
|
|
6049
6058
|
const now = /* @__PURE__ */ new Date();
|
|
6050
6059
|
if (this.isServer) {
|
|
6051
|
-
this.logger.warn("'
|
|
6060
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
6052
6061
|
} else {
|
|
6053
|
-
|
|
6062
|
+
cookies.set(
|
|
6054
6063
|
this.storageKey,
|
|
6055
6064
|
JSON.stringify({
|
|
6056
6065
|
...res.data,
|
|
6057
6066
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
6058
6067
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
6059
|
-
})
|
|
6068
|
+
}),
|
|
6069
|
+
{
|
|
6070
|
+
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
6071
|
+
}
|
|
6060
6072
|
);
|
|
6061
6073
|
}
|
|
6062
6074
|
return { ok: true };
|
|
@@ -6066,7 +6078,7 @@ var SessionManager = class {
|
|
|
6066
6078
|
}
|
|
6067
6079
|
async get() {
|
|
6068
6080
|
if (this.isServer) {
|
|
6069
|
-
this.logger.warn("'
|
|
6081
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
6070
6082
|
return {
|
|
6071
6083
|
ok: true,
|
|
6072
6084
|
data: null
|
|
@@ -6076,7 +6088,7 @@ var SessionManager = class {
|
|
|
6076
6088
|
await sleep(1e3);
|
|
6077
6089
|
return await this.get();
|
|
6078
6090
|
}
|
|
6079
|
-
const val =
|
|
6091
|
+
const val = cookies.get(this.storageKey);
|
|
6080
6092
|
if (!val) {
|
|
6081
6093
|
return {
|
|
6082
6094
|
ok: true,
|
|
@@ -6090,7 +6102,7 @@ var SessionManager = class {
|
|
|
6090
6102
|
const refreshTokenExpiresAt = new Date(obj.refreshTokenExpiresAt);
|
|
6091
6103
|
if (isAfter(now, refreshTokenExpiresAt)) {
|
|
6092
6104
|
this.logger.warn("Session expired. Logging out..");
|
|
6093
|
-
|
|
6105
|
+
cookies.remove(this.storageKey);
|
|
6094
6106
|
return {
|
|
6095
6107
|
ok: false,
|
|
6096
6108
|
error: {
|
|
@@ -6107,7 +6119,7 @@ var SessionManager = class {
|
|
|
6107
6119
|
if (!res.ok) {
|
|
6108
6120
|
this.logger.error(`Failed to refresh session: ${res.error.message}`);
|
|
6109
6121
|
if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
|
|
6110
|
-
|
|
6122
|
+
cookies.remove(this.storageKey);
|
|
6111
6123
|
return {
|
|
6112
6124
|
ok: false,
|
|
6113
6125
|
error: res.error
|
|
@@ -6128,7 +6140,9 @@ var SessionManager = class {
|
|
|
6128
6140
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
6129
6141
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
6130
6142
|
};
|
|
6131
|
-
|
|
6143
|
+
cookies.set(this.storageKey, JSON.stringify(obj), {
|
|
6144
|
+
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
6145
|
+
});
|
|
6132
6146
|
}
|
|
6133
6147
|
return {
|
|
6134
6148
|
ok: true,
|
|
@@ -6146,13 +6160,13 @@ var SessionManager = class {
|
|
|
6146
6160
|
}
|
|
6147
6161
|
async refresh() {
|
|
6148
6162
|
if (this.isServer) {
|
|
6149
|
-
this.logger.warn("'
|
|
6163
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
6150
6164
|
return {
|
|
6151
6165
|
ok: true,
|
|
6152
6166
|
data: null
|
|
6153
6167
|
};
|
|
6154
6168
|
}
|
|
6155
|
-
const val =
|
|
6169
|
+
const val = cookies.get(this.storageKey);
|
|
6156
6170
|
if (!val) {
|
|
6157
6171
|
return {
|
|
6158
6172
|
ok: true,
|
|
@@ -6169,7 +6183,7 @@ var SessionManager = class {
|
|
|
6169
6183
|
if (!res.ok) {
|
|
6170
6184
|
this.logger.error(`Failed to refresh session: ${res.error.message}`);
|
|
6171
6185
|
if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
|
|
6172
|
-
|
|
6186
|
+
cookies.remove(this.storageKey);
|
|
6173
6187
|
return {
|
|
6174
6188
|
ok: false,
|
|
6175
6189
|
error: res.error
|
|
@@ -6190,7 +6204,9 @@ var SessionManager = class {
|
|
|
6190
6204
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
6191
6205
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
6192
6206
|
};
|
|
6193
|
-
|
|
6207
|
+
cookies.set(this.storageKey, JSON.stringify(obj), {
|
|
6208
|
+
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
6209
|
+
});
|
|
6194
6210
|
return {
|
|
6195
6211
|
ok: true,
|
|
6196
6212
|
data: obj
|
|
@@ -6207,18 +6223,18 @@ var SessionManager = class {
|
|
|
6207
6223
|
}
|
|
6208
6224
|
async destroy() {
|
|
6209
6225
|
if (this.isServer) {
|
|
6210
|
-
this.logger.warn("'
|
|
6226
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
6211
6227
|
return;
|
|
6212
6228
|
}
|
|
6213
6229
|
const res = await this.get();
|
|
6214
6230
|
if (res.data?.accessToken) {
|
|
6215
6231
|
await this.authService.destroySession(res.data.accessToken);
|
|
6216
6232
|
}
|
|
6217
|
-
|
|
6233
|
+
cookies.remove(this.storageKey);
|
|
6218
6234
|
}
|
|
6219
6235
|
async verify() {
|
|
6220
6236
|
if (this.isServer) {
|
|
6221
|
-
this.logger.warn("'
|
|
6237
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
6222
6238
|
return true;
|
|
6223
6239
|
}
|
|
6224
6240
|
const s = await this.get();
|
|
@@ -6228,13 +6244,13 @@ var SessionManager = class {
|
|
|
6228
6244
|
if (!s.data) return true;
|
|
6229
6245
|
const v = await this.authService.verifySession(s.data.accessToken);
|
|
6230
6246
|
if (!v) {
|
|
6231
|
-
|
|
6247
|
+
cookies.remove(this.storageKey);
|
|
6232
6248
|
}
|
|
6233
6249
|
return v;
|
|
6234
6250
|
}
|
|
6235
6251
|
get onMaya() {
|
|
6236
6252
|
if (this.isServer) {
|
|
6237
|
-
this.logger.warn("'
|
|
6253
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
6238
6254
|
return false;
|
|
6239
6255
|
}
|
|
6240
6256
|
return localStorage.getItem(this.platformStorageKey) === "MAYA";
|
|
@@ -9825,7 +9841,7 @@ var ENDPOINTS = {
|
|
|
9825
9841
|
portal: "https://portal.opexa.io/graphql",
|
|
9826
9842
|
trigger: "https://trigger.staging.atalos.io/graphql",
|
|
9827
9843
|
static: "https://static.atalos.io",
|
|
9828
|
-
cmsPortal: "https://portal-api.opexacms.io",
|
|
9844
|
+
cmsPortal: "https://portal-api.staging.opexacms.io",
|
|
9829
9845
|
opexapay: "https://external.opexapay.opexa.io"
|
|
9830
9846
|
}
|
|
9831
9847
|
};
|