@opexa/portal-sdk 0.52.1 → 0.52.3
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 +91 -93
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -3
- package/dist/index.d.ts +10 -3
- package/dist/index.js +91 -93
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5518,8 +5518,8 @@ function pollable(func, config) {
|
|
|
5518
5518
|
};
|
|
5519
5519
|
}
|
|
5520
5520
|
|
|
5521
|
-
// src/sdk/session-manager
|
|
5522
|
-
var
|
|
5521
|
+
// src/sdk/session-manager.ts
|
|
5522
|
+
var SessionManager = class {
|
|
5523
5523
|
logger;
|
|
5524
5524
|
storageKey = "session";
|
|
5525
5525
|
platformStorageKey = "session/platform";
|
|
@@ -5530,6 +5530,10 @@ var SessionManagerCookie = class {
|
|
|
5530
5530
|
this.authService = config.authService;
|
|
5531
5531
|
this.walletService = config.walletService;
|
|
5532
5532
|
this.logger = config.logger;
|
|
5533
|
+
if (config.sessionPrefix) {
|
|
5534
|
+
this.storageKey = `${config.sessionPrefix}/${this.storageKey}`;
|
|
5535
|
+
this.platformStorageKey = `${config.sessionPrefix}/${this.platformStorageKey}`;
|
|
5536
|
+
}
|
|
5533
5537
|
}
|
|
5534
5538
|
get refreshing() {
|
|
5535
5539
|
return this._refreshing;
|
|
@@ -5538,6 +5542,16 @@ var SessionManagerCookie = class {
|
|
|
5538
5542
|
this._refreshing = value;
|
|
5539
5543
|
}
|
|
5540
5544
|
async create(input) {
|
|
5545
|
+
if (this.isServer) {
|
|
5546
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
5547
|
+
return {
|
|
5548
|
+
ok: false,
|
|
5549
|
+
error: {
|
|
5550
|
+
name: "UnknownError",
|
|
5551
|
+
message: "Server sign in is not supported."
|
|
5552
|
+
}
|
|
5553
|
+
};
|
|
5554
|
+
}
|
|
5541
5555
|
if (input.type === "MAYA") {
|
|
5542
5556
|
localStorage.setItem(this.platformStorageKey, "MAYA");
|
|
5543
5557
|
const f0 = () => this.walletService.mayaSession({ id: input.sessionId });
|
|
@@ -5564,14 +5578,13 @@ var SessionManagerCookie = class {
|
|
|
5564
5578
|
})();
|
|
5565
5579
|
if (!r1.ok) return r1;
|
|
5566
5580
|
const now2 = /* @__PURE__ */ new Date();
|
|
5567
|
-
|
|
5581
|
+
localStorage.setItem(
|
|
5568
5582
|
this.storageKey,
|
|
5569
5583
|
JSON.stringify({
|
|
5570
5584
|
...r1.data,
|
|
5571
5585
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5572
5586
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5573
|
-
})
|
|
5574
|
-
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
5587
|
+
})
|
|
5575
5588
|
);
|
|
5576
5589
|
return {
|
|
5577
5590
|
ok: true,
|
|
@@ -5582,16 +5595,13 @@ var SessionManagerCookie = class {
|
|
|
5582
5595
|
const res2 = await this.authService.createSession(input);
|
|
5583
5596
|
if (res2.ok) {
|
|
5584
5597
|
const now2 = /* @__PURE__ */ new Date();
|
|
5585
|
-
|
|
5598
|
+
localStorage.setItem(
|
|
5586
5599
|
this.storageKey,
|
|
5587
5600
|
JSON.stringify({
|
|
5588
5601
|
...res2.data,
|
|
5589
5602
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5590
5603
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5591
|
-
})
|
|
5592
|
-
{
|
|
5593
|
-
expires: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5594
|
-
}
|
|
5604
|
+
})
|
|
5595
5605
|
);
|
|
5596
5606
|
return {
|
|
5597
5607
|
ok: true,
|
|
@@ -5603,18 +5613,18 @@ var SessionManagerCookie = class {
|
|
|
5603
5613
|
if (input.type === "SOCIALS" || input.type === "TOKEN") {
|
|
5604
5614
|
const res2 = await this.authService.createSession({
|
|
5605
5615
|
type: "SOCIALS",
|
|
5606
|
-
token: input.token
|
|
5616
|
+
token: input.token,
|
|
5617
|
+
channel: input.channel
|
|
5607
5618
|
});
|
|
5608
5619
|
if (res2.ok) {
|
|
5609
5620
|
const now2 = /* @__PURE__ */ new Date();
|
|
5610
|
-
|
|
5621
|
+
localStorage.setItem(
|
|
5611
5622
|
this.storageKey,
|
|
5612
5623
|
JSON.stringify({
|
|
5613
5624
|
...res2.data,
|
|
5614
5625
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5615
5626
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5616
|
-
})
|
|
5617
|
-
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
5627
|
+
})
|
|
5618
5628
|
);
|
|
5619
5629
|
return {
|
|
5620
5630
|
ok: true,
|
|
@@ -5628,14 +5638,13 @@ var SessionManagerCookie = class {
|
|
|
5628
5638
|
const res2 = await this.authService.createSession(input);
|
|
5629
5639
|
if (res2.ok) {
|
|
5630
5640
|
const now2 = /* @__PURE__ */ new Date();
|
|
5631
|
-
|
|
5641
|
+
localStorage.setItem(
|
|
5632
5642
|
this.storageKey,
|
|
5633
5643
|
JSON.stringify({
|
|
5634
5644
|
...res2.data,
|
|
5635
5645
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5636
5646
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5637
|
-
})
|
|
5638
|
-
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
5647
|
+
})
|
|
5639
5648
|
);
|
|
5640
5649
|
return {
|
|
5641
5650
|
ok: true,
|
|
@@ -5655,14 +5664,13 @@ var SessionManagerCookie = class {
|
|
|
5655
5664
|
};
|
|
5656
5665
|
}
|
|
5657
5666
|
const now = /* @__PURE__ */ new Date();
|
|
5658
|
-
|
|
5667
|
+
localStorage.setItem(
|
|
5659
5668
|
this.storageKey,
|
|
5660
5669
|
JSON.stringify({
|
|
5661
5670
|
...res.data,
|
|
5662
5671
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
5663
5672
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
5664
|
-
})
|
|
5665
|
-
{}
|
|
5673
|
+
})
|
|
5666
5674
|
);
|
|
5667
5675
|
return {
|
|
5668
5676
|
ok: true,
|
|
@@ -5674,18 +5682,15 @@ var SessionManagerCookie = class {
|
|
|
5674
5682
|
if (res.ok) {
|
|
5675
5683
|
const now = /* @__PURE__ */ new Date();
|
|
5676
5684
|
if (this.isServer) {
|
|
5677
|
-
this.logger.warn("'
|
|
5685
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
5678
5686
|
} else {
|
|
5679
|
-
|
|
5687
|
+
localStorage.setItem(
|
|
5680
5688
|
this.storageKey,
|
|
5681
5689
|
JSON.stringify({
|
|
5682
5690
|
...res.data,
|
|
5683
5691
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
5684
5692
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
5685
|
-
})
|
|
5686
|
-
{
|
|
5687
|
-
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
5688
|
-
}
|
|
5693
|
+
})
|
|
5689
5694
|
);
|
|
5690
5695
|
}
|
|
5691
5696
|
return { ok: true };
|
|
@@ -5695,7 +5700,7 @@ var SessionManagerCookie = class {
|
|
|
5695
5700
|
}
|
|
5696
5701
|
async get() {
|
|
5697
5702
|
if (this.isServer) {
|
|
5698
|
-
this.logger.warn("'
|
|
5703
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
5699
5704
|
return {
|
|
5700
5705
|
ok: true,
|
|
5701
5706
|
data: null
|
|
@@ -5705,7 +5710,7 @@ var SessionManagerCookie = class {
|
|
|
5705
5710
|
await sleep(1e3);
|
|
5706
5711
|
return await this.get();
|
|
5707
5712
|
}
|
|
5708
|
-
const val =
|
|
5713
|
+
const val = localStorage.getItem(this.storageKey);
|
|
5709
5714
|
if (!val) {
|
|
5710
5715
|
return {
|
|
5711
5716
|
ok: true,
|
|
@@ -5719,7 +5724,7 @@ var SessionManagerCookie = class {
|
|
|
5719
5724
|
const refreshTokenExpiresAt = new Date(obj.refreshTokenExpiresAt);
|
|
5720
5725
|
if (isAfter(now, refreshTokenExpiresAt)) {
|
|
5721
5726
|
this.logger.warn("Session expired. Logging out..");
|
|
5722
|
-
|
|
5727
|
+
localStorage.removeItem(this.storageKey);
|
|
5723
5728
|
return {
|
|
5724
5729
|
ok: false,
|
|
5725
5730
|
error: {
|
|
@@ -5736,7 +5741,7 @@ var SessionManagerCookie = class {
|
|
|
5736
5741
|
if (!res.ok) {
|
|
5737
5742
|
this.logger.error(`Failed to refresh session: ${res.error.message}`);
|
|
5738
5743
|
if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
|
|
5739
|
-
|
|
5744
|
+
localStorage.removeItem(this.storageKey);
|
|
5740
5745
|
return {
|
|
5741
5746
|
ok: false,
|
|
5742
5747
|
error: res.error
|
|
@@ -5757,9 +5762,7 @@ var SessionManagerCookie = class {
|
|
|
5757
5762
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
5758
5763
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
5759
5764
|
};
|
|
5760
|
-
|
|
5761
|
-
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
5762
|
-
});
|
|
5765
|
+
localStorage.setItem(this.storageKey, JSON.stringify(obj));
|
|
5763
5766
|
}
|
|
5764
5767
|
return {
|
|
5765
5768
|
ok: true,
|
|
@@ -5777,13 +5780,13 @@ var SessionManagerCookie = class {
|
|
|
5777
5780
|
}
|
|
5778
5781
|
async refresh() {
|
|
5779
5782
|
if (this.isServer) {
|
|
5780
|
-
this.logger.warn("'
|
|
5783
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
5781
5784
|
return {
|
|
5782
5785
|
ok: true,
|
|
5783
5786
|
data: null
|
|
5784
5787
|
};
|
|
5785
5788
|
}
|
|
5786
|
-
const val =
|
|
5789
|
+
const val = localStorage.getItem(this.storageKey);
|
|
5787
5790
|
if (!val) {
|
|
5788
5791
|
return {
|
|
5789
5792
|
ok: true,
|
|
@@ -5800,7 +5803,7 @@ var SessionManagerCookie = class {
|
|
|
5800
5803
|
if (!res.ok) {
|
|
5801
5804
|
this.logger.error(`Failed to refresh session: ${res.error.message}`);
|
|
5802
5805
|
if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
|
|
5803
|
-
|
|
5806
|
+
localStorage.removeItem(this.storageKey);
|
|
5804
5807
|
return {
|
|
5805
5808
|
ok: false,
|
|
5806
5809
|
error: res.error
|
|
@@ -5821,9 +5824,7 @@ var SessionManagerCookie = class {
|
|
|
5821
5824
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
5822
5825
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
5823
5826
|
};
|
|
5824
|
-
|
|
5825
|
-
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
5826
|
-
});
|
|
5827
|
+
localStorage.setItem(this.storageKey, JSON.stringify(obj));
|
|
5827
5828
|
return {
|
|
5828
5829
|
ok: true,
|
|
5829
5830
|
data: obj
|
|
@@ -5840,18 +5841,18 @@ var SessionManagerCookie = class {
|
|
|
5840
5841
|
}
|
|
5841
5842
|
async destroy() {
|
|
5842
5843
|
if (this.isServer) {
|
|
5843
|
-
this.logger.warn("'
|
|
5844
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
5844
5845
|
return;
|
|
5845
5846
|
}
|
|
5846
5847
|
const res = await this.get();
|
|
5847
5848
|
if (res.data?.accessToken) {
|
|
5848
5849
|
await this.authService.destroySession(res.data.accessToken);
|
|
5849
5850
|
}
|
|
5850
|
-
|
|
5851
|
+
localStorage.removeItem(this.storageKey);
|
|
5851
5852
|
}
|
|
5852
5853
|
async verify() {
|
|
5853
5854
|
if (this.isServer) {
|
|
5854
|
-
this.logger.warn("'
|
|
5855
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
5855
5856
|
return true;
|
|
5856
5857
|
}
|
|
5857
5858
|
const s = await this.get();
|
|
@@ -5861,13 +5862,13 @@ var SessionManagerCookie = class {
|
|
|
5861
5862
|
if (!s.data) return true;
|
|
5862
5863
|
const v = await this.authService.verifySession(s.data.accessToken);
|
|
5863
5864
|
if (!v) {
|
|
5864
|
-
|
|
5865
|
+
localStorage.removeItem(this.storageKey);
|
|
5865
5866
|
}
|
|
5866
5867
|
return v;
|
|
5867
5868
|
}
|
|
5868
5869
|
get onMaya() {
|
|
5869
5870
|
if (this.isServer) {
|
|
5870
|
-
this.logger.warn("'
|
|
5871
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
5871
5872
|
return false;
|
|
5872
5873
|
}
|
|
5873
5874
|
return localStorage.getItem(this.platformStorageKey) === "MAYA";
|
|
@@ -5883,9 +5884,7 @@ var SessionManagerCookie = class {
|
|
|
5883
5884
|
return typeof window === "undefined";
|
|
5884
5885
|
}
|
|
5885
5886
|
};
|
|
5886
|
-
|
|
5887
|
-
// src/sdk/session-manager.ts
|
|
5888
|
-
var SessionManager = class {
|
|
5887
|
+
var SessionManagerCookie = class {
|
|
5889
5888
|
logger;
|
|
5890
5889
|
storageKey = "session";
|
|
5891
5890
|
platformStorageKey = "session/platform";
|
|
@@ -5896,10 +5895,6 @@ var SessionManager = class {
|
|
|
5896
5895
|
this.authService = config.authService;
|
|
5897
5896
|
this.walletService = config.walletService;
|
|
5898
5897
|
this.logger = config.logger;
|
|
5899
|
-
if (config.sessionPrefix) {
|
|
5900
|
-
this.storageKey = `${config.sessionPrefix}/${this.storageKey}`;
|
|
5901
|
-
this.platformStorageKey = `${config.sessionPrefix}/${this.platformStorageKey}`;
|
|
5902
|
-
}
|
|
5903
5898
|
}
|
|
5904
5899
|
get refreshing() {
|
|
5905
5900
|
return this._refreshing;
|
|
@@ -5908,16 +5903,6 @@ var SessionManager = class {
|
|
|
5908
5903
|
this._refreshing = value;
|
|
5909
5904
|
}
|
|
5910
5905
|
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
5906
|
if (input.type === "MAYA") {
|
|
5922
5907
|
localStorage.setItem(this.platformStorageKey, "MAYA");
|
|
5923
5908
|
const f0 = () => this.walletService.mayaSession({ id: input.sessionId });
|
|
@@ -5944,13 +5929,14 @@ var SessionManager = class {
|
|
|
5944
5929
|
})();
|
|
5945
5930
|
if (!r1.ok) return r1;
|
|
5946
5931
|
const now2 = /* @__PURE__ */ new Date();
|
|
5947
|
-
|
|
5932
|
+
cookies.set(
|
|
5948
5933
|
this.storageKey,
|
|
5949
5934
|
JSON.stringify({
|
|
5950
5935
|
...r1.data,
|
|
5951
5936
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5952
5937
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5953
|
-
})
|
|
5938
|
+
}),
|
|
5939
|
+
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
5954
5940
|
);
|
|
5955
5941
|
return {
|
|
5956
5942
|
ok: true,
|
|
@@ -5961,13 +5947,16 @@ var SessionManager = class {
|
|
|
5961
5947
|
const res2 = await this.authService.createSession(input);
|
|
5962
5948
|
if (res2.ok) {
|
|
5963
5949
|
const now2 = /* @__PURE__ */ new Date();
|
|
5964
|
-
|
|
5950
|
+
cookies.set(
|
|
5965
5951
|
this.storageKey,
|
|
5966
5952
|
JSON.stringify({
|
|
5967
5953
|
...res2.data,
|
|
5968
5954
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5969
5955
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5970
|
-
})
|
|
5956
|
+
}),
|
|
5957
|
+
{
|
|
5958
|
+
expires: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5959
|
+
}
|
|
5971
5960
|
);
|
|
5972
5961
|
return {
|
|
5973
5962
|
ok: true,
|
|
@@ -5979,18 +5968,18 @@ var SessionManager = class {
|
|
|
5979
5968
|
if (input.type === "SOCIALS" || input.type === "TOKEN") {
|
|
5980
5969
|
const res2 = await this.authService.createSession({
|
|
5981
5970
|
type: "SOCIALS",
|
|
5982
|
-
token: input.token
|
|
5983
|
-
channel: input.channel
|
|
5971
|
+
token: input.token
|
|
5984
5972
|
});
|
|
5985
5973
|
if (res2.ok) {
|
|
5986
5974
|
const now2 = /* @__PURE__ */ new Date();
|
|
5987
|
-
|
|
5975
|
+
cookies.set(
|
|
5988
5976
|
this.storageKey,
|
|
5989
5977
|
JSON.stringify({
|
|
5990
5978
|
...res2.data,
|
|
5991
5979
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5992
5980
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5993
|
-
})
|
|
5981
|
+
}),
|
|
5982
|
+
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
5994
5983
|
);
|
|
5995
5984
|
return {
|
|
5996
5985
|
ok: true,
|
|
@@ -6004,13 +5993,14 @@ var SessionManager = class {
|
|
|
6004
5993
|
const res2 = await this.authService.createSession(input);
|
|
6005
5994
|
if (res2.ok) {
|
|
6006
5995
|
const now2 = /* @__PURE__ */ new Date();
|
|
6007
|
-
|
|
5996
|
+
cookies.set(
|
|
6008
5997
|
this.storageKey,
|
|
6009
5998
|
JSON.stringify({
|
|
6010
5999
|
...res2.data,
|
|
6011
6000
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
6012
6001
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
6013
|
-
})
|
|
6002
|
+
}),
|
|
6003
|
+
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
6014
6004
|
);
|
|
6015
6005
|
return {
|
|
6016
6006
|
ok: true,
|
|
@@ -6030,13 +6020,14 @@ var SessionManager = class {
|
|
|
6030
6020
|
};
|
|
6031
6021
|
}
|
|
6032
6022
|
const now = /* @__PURE__ */ new Date();
|
|
6033
|
-
|
|
6023
|
+
cookies.set(
|
|
6034
6024
|
this.storageKey,
|
|
6035
6025
|
JSON.stringify({
|
|
6036
6026
|
...res.data,
|
|
6037
6027
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
6038
6028
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
6039
|
-
})
|
|
6029
|
+
}),
|
|
6030
|
+
{}
|
|
6040
6031
|
);
|
|
6041
6032
|
return {
|
|
6042
6033
|
ok: true,
|
|
@@ -6048,15 +6039,18 @@ var SessionManager = class {
|
|
|
6048
6039
|
if (res.ok) {
|
|
6049
6040
|
const now = /* @__PURE__ */ new Date();
|
|
6050
6041
|
if (this.isServer) {
|
|
6051
|
-
this.logger.warn("'
|
|
6042
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
6052
6043
|
} else {
|
|
6053
|
-
|
|
6044
|
+
cookies.set(
|
|
6054
6045
|
this.storageKey,
|
|
6055
6046
|
JSON.stringify({
|
|
6056
6047
|
...res.data,
|
|
6057
6048
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
6058
6049
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
6059
|
-
})
|
|
6050
|
+
}),
|
|
6051
|
+
{
|
|
6052
|
+
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
6053
|
+
}
|
|
6060
6054
|
);
|
|
6061
6055
|
}
|
|
6062
6056
|
return { ok: true };
|
|
@@ -6066,7 +6060,7 @@ var SessionManager = class {
|
|
|
6066
6060
|
}
|
|
6067
6061
|
async get() {
|
|
6068
6062
|
if (this.isServer) {
|
|
6069
|
-
this.logger.warn("'
|
|
6063
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
6070
6064
|
return {
|
|
6071
6065
|
ok: true,
|
|
6072
6066
|
data: null
|
|
@@ -6076,7 +6070,7 @@ var SessionManager = class {
|
|
|
6076
6070
|
await sleep(1e3);
|
|
6077
6071
|
return await this.get();
|
|
6078
6072
|
}
|
|
6079
|
-
const val =
|
|
6073
|
+
const val = cookies.get(this.storageKey);
|
|
6080
6074
|
if (!val) {
|
|
6081
6075
|
return {
|
|
6082
6076
|
ok: true,
|
|
@@ -6090,7 +6084,7 @@ var SessionManager = class {
|
|
|
6090
6084
|
const refreshTokenExpiresAt = new Date(obj.refreshTokenExpiresAt);
|
|
6091
6085
|
if (isAfter(now, refreshTokenExpiresAt)) {
|
|
6092
6086
|
this.logger.warn("Session expired. Logging out..");
|
|
6093
|
-
|
|
6087
|
+
cookies.remove(this.storageKey);
|
|
6094
6088
|
return {
|
|
6095
6089
|
ok: false,
|
|
6096
6090
|
error: {
|
|
@@ -6107,7 +6101,7 @@ var SessionManager = class {
|
|
|
6107
6101
|
if (!res.ok) {
|
|
6108
6102
|
this.logger.error(`Failed to refresh session: ${res.error.message}`);
|
|
6109
6103
|
if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
|
|
6110
|
-
|
|
6104
|
+
cookies.remove(this.storageKey);
|
|
6111
6105
|
return {
|
|
6112
6106
|
ok: false,
|
|
6113
6107
|
error: res.error
|
|
@@ -6128,7 +6122,9 @@ var SessionManager = class {
|
|
|
6128
6122
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
6129
6123
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
6130
6124
|
};
|
|
6131
|
-
|
|
6125
|
+
cookies.set(this.storageKey, JSON.stringify(obj), {
|
|
6126
|
+
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
6127
|
+
});
|
|
6132
6128
|
}
|
|
6133
6129
|
return {
|
|
6134
6130
|
ok: true,
|
|
@@ -6146,13 +6142,13 @@ var SessionManager = class {
|
|
|
6146
6142
|
}
|
|
6147
6143
|
async refresh() {
|
|
6148
6144
|
if (this.isServer) {
|
|
6149
|
-
this.logger.warn("'
|
|
6145
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
6150
6146
|
return {
|
|
6151
6147
|
ok: true,
|
|
6152
6148
|
data: null
|
|
6153
6149
|
};
|
|
6154
6150
|
}
|
|
6155
|
-
const val =
|
|
6151
|
+
const val = cookies.get(this.storageKey);
|
|
6156
6152
|
if (!val) {
|
|
6157
6153
|
return {
|
|
6158
6154
|
ok: true,
|
|
@@ -6169,7 +6165,7 @@ var SessionManager = class {
|
|
|
6169
6165
|
if (!res.ok) {
|
|
6170
6166
|
this.logger.error(`Failed to refresh session: ${res.error.message}`);
|
|
6171
6167
|
if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
|
|
6172
|
-
|
|
6168
|
+
cookies.remove(this.storageKey);
|
|
6173
6169
|
return {
|
|
6174
6170
|
ok: false,
|
|
6175
6171
|
error: res.error
|
|
@@ -6190,7 +6186,9 @@ var SessionManager = class {
|
|
|
6190
6186
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
6191
6187
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
6192
6188
|
};
|
|
6193
|
-
|
|
6189
|
+
cookies.set(this.storageKey, JSON.stringify(obj), {
|
|
6190
|
+
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
6191
|
+
});
|
|
6194
6192
|
return {
|
|
6195
6193
|
ok: true,
|
|
6196
6194
|
data: obj
|
|
@@ -6207,18 +6205,18 @@ var SessionManager = class {
|
|
|
6207
6205
|
}
|
|
6208
6206
|
async destroy() {
|
|
6209
6207
|
if (this.isServer) {
|
|
6210
|
-
this.logger.warn("'
|
|
6208
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
6211
6209
|
return;
|
|
6212
6210
|
}
|
|
6213
6211
|
const res = await this.get();
|
|
6214
6212
|
if (res.data?.accessToken) {
|
|
6215
6213
|
await this.authService.destroySession(res.data.accessToken);
|
|
6216
6214
|
}
|
|
6217
|
-
|
|
6215
|
+
cookies.remove(this.storageKey);
|
|
6218
6216
|
}
|
|
6219
6217
|
async verify() {
|
|
6220
6218
|
if (this.isServer) {
|
|
6221
|
-
this.logger.warn("'
|
|
6219
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
6222
6220
|
return true;
|
|
6223
6221
|
}
|
|
6224
6222
|
const s = await this.get();
|
|
@@ -6228,13 +6226,13 @@ var SessionManager = class {
|
|
|
6228
6226
|
if (!s.data) return true;
|
|
6229
6227
|
const v = await this.authService.verifySession(s.data.accessToken);
|
|
6230
6228
|
if (!v) {
|
|
6231
|
-
|
|
6229
|
+
cookies.remove(this.storageKey);
|
|
6232
6230
|
}
|
|
6233
6231
|
return v;
|
|
6234
6232
|
}
|
|
6235
6233
|
get onMaya() {
|
|
6236
6234
|
if (this.isServer) {
|
|
6237
|
-
this.logger.warn("'
|
|
6235
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
6238
6236
|
return false;
|
|
6239
6237
|
}
|
|
6240
6238
|
return localStorage.getItem(this.platformStorageKey) === "MAYA";
|
|
@@ -9097,8 +9095,8 @@ var Sdk = class {
|
|
|
9097
9095
|
data: res.data.map(this.transformer.transform.promo)
|
|
9098
9096
|
};
|
|
9099
9097
|
}
|
|
9100
|
-
async availablePromos() {
|
|
9101
|
-
const res = await this.walletService.availablePromos();
|
|
9098
|
+
async availablePromos(input) {
|
|
9099
|
+
const res = await this.walletService.availablePromos(input);
|
|
9102
9100
|
if (!res.ok) return res;
|
|
9103
9101
|
return {
|
|
9104
9102
|
ok: true,
|
|
@@ -9825,7 +9823,7 @@ var ENDPOINTS = {
|
|
|
9825
9823
|
portal: "https://portal.opexa.io/graphql",
|
|
9826
9824
|
trigger: "https://trigger.staging.atalos.io/graphql",
|
|
9827
9825
|
static: "https://static.atalos.io",
|
|
9828
|
-
cmsPortal: "https://portal-api.opexacms.io",
|
|
9826
|
+
cmsPortal: "https://portal-api.staging.opexacms.io",
|
|
9829
9827
|
opexapay: "https://external.opexapay.opexa.io"
|
|
9830
9828
|
}
|
|
9831
9829
|
};
|