@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.cjs
CHANGED
|
@@ -5523,8 +5523,8 @@ function pollable(func, config) {
|
|
|
5523
5523
|
};
|
|
5524
5524
|
}
|
|
5525
5525
|
|
|
5526
|
-
// src/sdk/session-manager
|
|
5527
|
-
var
|
|
5526
|
+
// src/sdk/session-manager.ts
|
|
5527
|
+
var SessionManager = class {
|
|
5528
5528
|
logger;
|
|
5529
5529
|
storageKey = "session";
|
|
5530
5530
|
platformStorageKey = "session/platform";
|
|
@@ -5535,6 +5535,10 @@ var SessionManagerCookie = class {
|
|
|
5535
5535
|
this.authService = config.authService;
|
|
5536
5536
|
this.walletService = config.walletService;
|
|
5537
5537
|
this.logger = config.logger;
|
|
5538
|
+
if (config.sessionPrefix) {
|
|
5539
|
+
this.storageKey = `${config.sessionPrefix}/${this.storageKey}`;
|
|
5540
|
+
this.platformStorageKey = `${config.sessionPrefix}/${this.platformStorageKey}`;
|
|
5541
|
+
}
|
|
5538
5542
|
}
|
|
5539
5543
|
get refreshing() {
|
|
5540
5544
|
return this._refreshing;
|
|
@@ -5543,6 +5547,16 @@ var SessionManagerCookie = class {
|
|
|
5543
5547
|
this._refreshing = value;
|
|
5544
5548
|
}
|
|
5545
5549
|
async create(input) {
|
|
5550
|
+
if (this.isServer) {
|
|
5551
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
5552
|
+
return {
|
|
5553
|
+
ok: false,
|
|
5554
|
+
error: {
|
|
5555
|
+
name: "UnknownError",
|
|
5556
|
+
message: "Server sign in is not supported."
|
|
5557
|
+
}
|
|
5558
|
+
};
|
|
5559
|
+
}
|
|
5546
5560
|
if (input.type === "MAYA") {
|
|
5547
5561
|
localStorage.setItem(this.platformStorageKey, "MAYA");
|
|
5548
5562
|
const f0 = () => this.walletService.mayaSession({ id: input.sessionId });
|
|
@@ -5569,14 +5583,13 @@ var SessionManagerCookie = class {
|
|
|
5569
5583
|
})();
|
|
5570
5584
|
if (!r1.ok) return r1;
|
|
5571
5585
|
const now2 = /* @__PURE__ */ new Date();
|
|
5572
|
-
|
|
5586
|
+
localStorage.setItem(
|
|
5573
5587
|
this.storageKey,
|
|
5574
5588
|
JSON.stringify({
|
|
5575
5589
|
...r1.data,
|
|
5576
5590
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5577
5591
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5578
|
-
})
|
|
5579
|
-
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
5592
|
+
})
|
|
5580
5593
|
);
|
|
5581
5594
|
return {
|
|
5582
5595
|
ok: true,
|
|
@@ -5587,16 +5600,13 @@ var SessionManagerCookie = class {
|
|
|
5587
5600
|
const res2 = await this.authService.createSession(input);
|
|
5588
5601
|
if (res2.ok) {
|
|
5589
5602
|
const now2 = /* @__PURE__ */ new Date();
|
|
5590
|
-
|
|
5603
|
+
localStorage.setItem(
|
|
5591
5604
|
this.storageKey,
|
|
5592
5605
|
JSON.stringify({
|
|
5593
5606
|
...res2.data,
|
|
5594
5607
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5595
5608
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5596
|
-
})
|
|
5597
|
-
{
|
|
5598
|
-
expires: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5599
|
-
}
|
|
5609
|
+
})
|
|
5600
5610
|
);
|
|
5601
5611
|
return {
|
|
5602
5612
|
ok: true,
|
|
@@ -5608,18 +5618,18 @@ var SessionManagerCookie = class {
|
|
|
5608
5618
|
if (input.type === "SOCIALS" || input.type === "TOKEN") {
|
|
5609
5619
|
const res2 = await this.authService.createSession({
|
|
5610
5620
|
type: "SOCIALS",
|
|
5611
|
-
token: input.token
|
|
5621
|
+
token: input.token,
|
|
5622
|
+
channel: input.channel
|
|
5612
5623
|
});
|
|
5613
5624
|
if (res2.ok) {
|
|
5614
5625
|
const now2 = /* @__PURE__ */ new Date();
|
|
5615
|
-
|
|
5626
|
+
localStorage.setItem(
|
|
5616
5627
|
this.storageKey,
|
|
5617
5628
|
JSON.stringify({
|
|
5618
5629
|
...res2.data,
|
|
5619
5630
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5620
5631
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5621
|
-
})
|
|
5622
|
-
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
5632
|
+
})
|
|
5623
5633
|
);
|
|
5624
5634
|
return {
|
|
5625
5635
|
ok: true,
|
|
@@ -5633,14 +5643,13 @@ var SessionManagerCookie = class {
|
|
|
5633
5643
|
const res2 = await this.authService.createSession(input);
|
|
5634
5644
|
if (res2.ok) {
|
|
5635
5645
|
const now2 = /* @__PURE__ */ new Date();
|
|
5636
|
-
|
|
5646
|
+
localStorage.setItem(
|
|
5637
5647
|
this.storageKey,
|
|
5638
5648
|
JSON.stringify({
|
|
5639
5649
|
...res2.data,
|
|
5640
5650
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5641
5651
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5642
|
-
})
|
|
5643
|
-
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
5652
|
+
})
|
|
5644
5653
|
);
|
|
5645
5654
|
return {
|
|
5646
5655
|
ok: true,
|
|
@@ -5660,14 +5669,13 @@ var SessionManagerCookie = class {
|
|
|
5660
5669
|
};
|
|
5661
5670
|
}
|
|
5662
5671
|
const now = /* @__PURE__ */ new Date();
|
|
5663
|
-
|
|
5672
|
+
localStorage.setItem(
|
|
5664
5673
|
this.storageKey,
|
|
5665
5674
|
JSON.stringify({
|
|
5666
5675
|
...res.data,
|
|
5667
5676
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
5668
5677
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
5669
|
-
})
|
|
5670
|
-
{}
|
|
5678
|
+
})
|
|
5671
5679
|
);
|
|
5672
5680
|
return {
|
|
5673
5681
|
ok: true,
|
|
@@ -5679,18 +5687,15 @@ var SessionManagerCookie = class {
|
|
|
5679
5687
|
if (res.ok) {
|
|
5680
5688
|
const now = /* @__PURE__ */ new Date();
|
|
5681
5689
|
if (this.isServer) {
|
|
5682
|
-
this.logger.warn("'
|
|
5690
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
5683
5691
|
} else {
|
|
5684
|
-
|
|
5692
|
+
localStorage.setItem(
|
|
5685
5693
|
this.storageKey,
|
|
5686
5694
|
JSON.stringify({
|
|
5687
5695
|
...res.data,
|
|
5688
5696
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
5689
5697
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
5690
|
-
})
|
|
5691
|
-
{
|
|
5692
|
-
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
5693
|
-
}
|
|
5698
|
+
})
|
|
5694
5699
|
);
|
|
5695
5700
|
}
|
|
5696
5701
|
return { ok: true };
|
|
@@ -5700,7 +5705,7 @@ var SessionManagerCookie = class {
|
|
|
5700
5705
|
}
|
|
5701
5706
|
async get() {
|
|
5702
5707
|
if (this.isServer) {
|
|
5703
|
-
this.logger.warn("'
|
|
5708
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
5704
5709
|
return {
|
|
5705
5710
|
ok: true,
|
|
5706
5711
|
data: null
|
|
@@ -5710,7 +5715,7 @@ var SessionManagerCookie = class {
|
|
|
5710
5715
|
await sleep(1e3);
|
|
5711
5716
|
return await this.get();
|
|
5712
5717
|
}
|
|
5713
|
-
const val =
|
|
5718
|
+
const val = localStorage.getItem(this.storageKey);
|
|
5714
5719
|
if (!val) {
|
|
5715
5720
|
return {
|
|
5716
5721
|
ok: true,
|
|
@@ -5724,7 +5729,7 @@ var SessionManagerCookie = class {
|
|
|
5724
5729
|
const refreshTokenExpiresAt = new Date(obj.refreshTokenExpiresAt);
|
|
5725
5730
|
if (isAfter(now, refreshTokenExpiresAt)) {
|
|
5726
5731
|
this.logger.warn("Session expired. Logging out..");
|
|
5727
|
-
|
|
5732
|
+
localStorage.removeItem(this.storageKey);
|
|
5728
5733
|
return {
|
|
5729
5734
|
ok: false,
|
|
5730
5735
|
error: {
|
|
@@ -5741,7 +5746,7 @@ var SessionManagerCookie = class {
|
|
|
5741
5746
|
if (!res.ok) {
|
|
5742
5747
|
this.logger.error(`Failed to refresh session: ${res.error.message}`);
|
|
5743
5748
|
if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
|
|
5744
|
-
|
|
5749
|
+
localStorage.removeItem(this.storageKey);
|
|
5745
5750
|
return {
|
|
5746
5751
|
ok: false,
|
|
5747
5752
|
error: res.error
|
|
@@ -5762,9 +5767,7 @@ var SessionManagerCookie = class {
|
|
|
5762
5767
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
5763
5768
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
5764
5769
|
};
|
|
5765
|
-
|
|
5766
|
-
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
5767
|
-
});
|
|
5770
|
+
localStorage.setItem(this.storageKey, JSON.stringify(obj));
|
|
5768
5771
|
}
|
|
5769
5772
|
return {
|
|
5770
5773
|
ok: true,
|
|
@@ -5782,13 +5785,13 @@ var SessionManagerCookie = class {
|
|
|
5782
5785
|
}
|
|
5783
5786
|
async refresh() {
|
|
5784
5787
|
if (this.isServer) {
|
|
5785
|
-
this.logger.warn("'
|
|
5788
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
5786
5789
|
return {
|
|
5787
5790
|
ok: true,
|
|
5788
5791
|
data: null
|
|
5789
5792
|
};
|
|
5790
5793
|
}
|
|
5791
|
-
const val =
|
|
5794
|
+
const val = localStorage.getItem(this.storageKey);
|
|
5792
5795
|
if (!val) {
|
|
5793
5796
|
return {
|
|
5794
5797
|
ok: true,
|
|
@@ -5805,7 +5808,7 @@ var SessionManagerCookie = class {
|
|
|
5805
5808
|
if (!res.ok) {
|
|
5806
5809
|
this.logger.error(`Failed to refresh session: ${res.error.message}`);
|
|
5807
5810
|
if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
|
|
5808
|
-
|
|
5811
|
+
localStorage.removeItem(this.storageKey);
|
|
5809
5812
|
return {
|
|
5810
5813
|
ok: false,
|
|
5811
5814
|
error: res.error
|
|
@@ -5826,9 +5829,7 @@ var SessionManagerCookie = class {
|
|
|
5826
5829
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
5827
5830
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
5828
5831
|
};
|
|
5829
|
-
|
|
5830
|
-
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
5831
|
-
});
|
|
5832
|
+
localStorage.setItem(this.storageKey, JSON.stringify(obj));
|
|
5832
5833
|
return {
|
|
5833
5834
|
ok: true,
|
|
5834
5835
|
data: obj
|
|
@@ -5845,18 +5846,18 @@ var SessionManagerCookie = class {
|
|
|
5845
5846
|
}
|
|
5846
5847
|
async destroy() {
|
|
5847
5848
|
if (this.isServer) {
|
|
5848
|
-
this.logger.warn("'
|
|
5849
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
5849
5850
|
return;
|
|
5850
5851
|
}
|
|
5851
5852
|
const res = await this.get();
|
|
5852
5853
|
if (res.data?.accessToken) {
|
|
5853
5854
|
await this.authService.destroySession(res.data.accessToken);
|
|
5854
5855
|
}
|
|
5855
|
-
|
|
5856
|
+
localStorage.removeItem(this.storageKey);
|
|
5856
5857
|
}
|
|
5857
5858
|
async verify() {
|
|
5858
5859
|
if (this.isServer) {
|
|
5859
|
-
this.logger.warn("'
|
|
5860
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
5860
5861
|
return true;
|
|
5861
5862
|
}
|
|
5862
5863
|
const s = await this.get();
|
|
@@ -5866,13 +5867,13 @@ var SessionManagerCookie = class {
|
|
|
5866
5867
|
if (!s.data) return true;
|
|
5867
5868
|
const v = await this.authService.verifySession(s.data.accessToken);
|
|
5868
5869
|
if (!v) {
|
|
5869
|
-
|
|
5870
|
+
localStorage.removeItem(this.storageKey);
|
|
5870
5871
|
}
|
|
5871
5872
|
return v;
|
|
5872
5873
|
}
|
|
5873
5874
|
get onMaya() {
|
|
5874
5875
|
if (this.isServer) {
|
|
5875
|
-
this.logger.warn("'
|
|
5876
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
5876
5877
|
return false;
|
|
5877
5878
|
}
|
|
5878
5879
|
return localStorage.getItem(this.platformStorageKey) === "MAYA";
|
|
@@ -5888,9 +5889,7 @@ var SessionManagerCookie = class {
|
|
|
5888
5889
|
return typeof window === "undefined";
|
|
5889
5890
|
}
|
|
5890
5891
|
};
|
|
5891
|
-
|
|
5892
|
-
// src/sdk/session-manager.ts
|
|
5893
|
-
var SessionManager = class {
|
|
5892
|
+
var SessionManagerCookie = class {
|
|
5894
5893
|
logger;
|
|
5895
5894
|
storageKey = "session";
|
|
5896
5895
|
platformStorageKey = "session/platform";
|
|
@@ -5901,10 +5900,6 @@ var SessionManager = class {
|
|
|
5901
5900
|
this.authService = config.authService;
|
|
5902
5901
|
this.walletService = config.walletService;
|
|
5903
5902
|
this.logger = config.logger;
|
|
5904
|
-
if (config.sessionPrefix) {
|
|
5905
|
-
this.storageKey = `${config.sessionPrefix}/${this.storageKey}`;
|
|
5906
|
-
this.platformStorageKey = `${config.sessionPrefix}/${this.platformStorageKey}`;
|
|
5907
|
-
}
|
|
5908
5903
|
}
|
|
5909
5904
|
get refreshing() {
|
|
5910
5905
|
return this._refreshing;
|
|
@@ -5913,16 +5908,6 @@ var SessionManager = class {
|
|
|
5913
5908
|
this._refreshing = value;
|
|
5914
5909
|
}
|
|
5915
5910
|
async create(input) {
|
|
5916
|
-
if (this.isServer) {
|
|
5917
|
-
this.logger.warn("'localStorage' is not available on the server.");
|
|
5918
|
-
return {
|
|
5919
|
-
ok: false,
|
|
5920
|
-
error: {
|
|
5921
|
-
name: "UnknownError",
|
|
5922
|
-
message: "Server sign in is not supported."
|
|
5923
|
-
}
|
|
5924
|
-
};
|
|
5925
|
-
}
|
|
5926
5911
|
if (input.type === "MAYA") {
|
|
5927
5912
|
localStorage.setItem(this.platformStorageKey, "MAYA");
|
|
5928
5913
|
const f0 = () => this.walletService.mayaSession({ id: input.sessionId });
|
|
@@ -5949,13 +5934,14 @@ var SessionManager = class {
|
|
|
5949
5934
|
})();
|
|
5950
5935
|
if (!r1.ok) return r1;
|
|
5951
5936
|
const now2 = /* @__PURE__ */ new Date();
|
|
5952
|
-
|
|
5937
|
+
cookies__default.default.set(
|
|
5953
5938
|
this.storageKey,
|
|
5954
5939
|
JSON.stringify({
|
|
5955
5940
|
...r1.data,
|
|
5956
5941
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5957
5942
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5958
|
-
})
|
|
5943
|
+
}),
|
|
5944
|
+
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
5959
5945
|
);
|
|
5960
5946
|
return {
|
|
5961
5947
|
ok: true,
|
|
@@ -5966,13 +5952,16 @@ var SessionManager = class {
|
|
|
5966
5952
|
const res2 = await this.authService.createSession(input);
|
|
5967
5953
|
if (res2.ok) {
|
|
5968
5954
|
const now2 = /* @__PURE__ */ new Date();
|
|
5969
|
-
|
|
5955
|
+
cookies__default.default.set(
|
|
5970
5956
|
this.storageKey,
|
|
5971
5957
|
JSON.stringify({
|
|
5972
5958
|
...res2.data,
|
|
5973
5959
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5974
5960
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5975
|
-
})
|
|
5961
|
+
}),
|
|
5962
|
+
{
|
|
5963
|
+
expires: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5964
|
+
}
|
|
5976
5965
|
);
|
|
5977
5966
|
return {
|
|
5978
5967
|
ok: true,
|
|
@@ -5984,18 +5973,18 @@ var SessionManager = class {
|
|
|
5984
5973
|
if (input.type === "SOCIALS" || input.type === "TOKEN") {
|
|
5985
5974
|
const res2 = await this.authService.createSession({
|
|
5986
5975
|
type: "SOCIALS",
|
|
5987
|
-
token: input.token
|
|
5988
|
-
channel: input.channel
|
|
5976
|
+
token: input.token
|
|
5989
5977
|
});
|
|
5990
5978
|
if (res2.ok) {
|
|
5991
5979
|
const now2 = /* @__PURE__ */ new Date();
|
|
5992
|
-
|
|
5980
|
+
cookies__default.default.set(
|
|
5993
5981
|
this.storageKey,
|
|
5994
5982
|
JSON.stringify({
|
|
5995
5983
|
...res2.data,
|
|
5996
5984
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5997
5985
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5998
|
-
})
|
|
5986
|
+
}),
|
|
5987
|
+
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
5999
5988
|
);
|
|
6000
5989
|
return {
|
|
6001
5990
|
ok: true,
|
|
@@ -6009,13 +5998,14 @@ var SessionManager = class {
|
|
|
6009
5998
|
const res2 = await this.authService.createSession(input);
|
|
6010
5999
|
if (res2.ok) {
|
|
6011
6000
|
const now2 = /* @__PURE__ */ new Date();
|
|
6012
|
-
|
|
6001
|
+
cookies__default.default.set(
|
|
6013
6002
|
this.storageKey,
|
|
6014
6003
|
JSON.stringify({
|
|
6015
6004
|
...res2.data,
|
|
6016
6005
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
6017
6006
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
6018
|
-
})
|
|
6007
|
+
}),
|
|
6008
|
+
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
6019
6009
|
);
|
|
6020
6010
|
return {
|
|
6021
6011
|
ok: true,
|
|
@@ -6035,13 +6025,14 @@ var SessionManager = class {
|
|
|
6035
6025
|
};
|
|
6036
6026
|
}
|
|
6037
6027
|
const now = /* @__PURE__ */ new Date();
|
|
6038
|
-
|
|
6028
|
+
cookies__default.default.set(
|
|
6039
6029
|
this.storageKey,
|
|
6040
6030
|
JSON.stringify({
|
|
6041
6031
|
...res.data,
|
|
6042
6032
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
6043
6033
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
6044
|
-
})
|
|
6034
|
+
}),
|
|
6035
|
+
{}
|
|
6045
6036
|
);
|
|
6046
6037
|
return {
|
|
6047
6038
|
ok: true,
|
|
@@ -6053,15 +6044,18 @@ var SessionManager = class {
|
|
|
6053
6044
|
if (res.ok) {
|
|
6054
6045
|
const now = /* @__PURE__ */ new Date();
|
|
6055
6046
|
if (this.isServer) {
|
|
6056
|
-
this.logger.warn("'
|
|
6047
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
6057
6048
|
} else {
|
|
6058
|
-
|
|
6049
|
+
cookies__default.default.set(
|
|
6059
6050
|
this.storageKey,
|
|
6060
6051
|
JSON.stringify({
|
|
6061
6052
|
...res.data,
|
|
6062
6053
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
6063
6054
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
6064
|
-
})
|
|
6055
|
+
}),
|
|
6056
|
+
{
|
|
6057
|
+
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
6058
|
+
}
|
|
6065
6059
|
);
|
|
6066
6060
|
}
|
|
6067
6061
|
return { ok: true };
|
|
@@ -6071,7 +6065,7 @@ var SessionManager = class {
|
|
|
6071
6065
|
}
|
|
6072
6066
|
async get() {
|
|
6073
6067
|
if (this.isServer) {
|
|
6074
|
-
this.logger.warn("'
|
|
6068
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
6075
6069
|
return {
|
|
6076
6070
|
ok: true,
|
|
6077
6071
|
data: null
|
|
@@ -6081,7 +6075,7 @@ var SessionManager = class {
|
|
|
6081
6075
|
await sleep(1e3);
|
|
6082
6076
|
return await this.get();
|
|
6083
6077
|
}
|
|
6084
|
-
const val =
|
|
6078
|
+
const val = cookies__default.default.get(this.storageKey);
|
|
6085
6079
|
if (!val) {
|
|
6086
6080
|
return {
|
|
6087
6081
|
ok: true,
|
|
@@ -6095,7 +6089,7 @@ var SessionManager = class {
|
|
|
6095
6089
|
const refreshTokenExpiresAt = new Date(obj.refreshTokenExpiresAt);
|
|
6096
6090
|
if (isAfter(now, refreshTokenExpiresAt)) {
|
|
6097
6091
|
this.logger.warn("Session expired. Logging out..");
|
|
6098
|
-
|
|
6092
|
+
cookies__default.default.remove(this.storageKey);
|
|
6099
6093
|
return {
|
|
6100
6094
|
ok: false,
|
|
6101
6095
|
error: {
|
|
@@ -6112,7 +6106,7 @@ var SessionManager = class {
|
|
|
6112
6106
|
if (!res.ok) {
|
|
6113
6107
|
this.logger.error(`Failed to refresh session: ${res.error.message}`);
|
|
6114
6108
|
if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
|
|
6115
|
-
|
|
6109
|
+
cookies__default.default.remove(this.storageKey);
|
|
6116
6110
|
return {
|
|
6117
6111
|
ok: false,
|
|
6118
6112
|
error: res.error
|
|
@@ -6133,7 +6127,9 @@ var SessionManager = class {
|
|
|
6133
6127
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
6134
6128
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
6135
6129
|
};
|
|
6136
|
-
|
|
6130
|
+
cookies__default.default.set(this.storageKey, JSON.stringify(obj), {
|
|
6131
|
+
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
6132
|
+
});
|
|
6137
6133
|
}
|
|
6138
6134
|
return {
|
|
6139
6135
|
ok: true,
|
|
@@ -6151,13 +6147,13 @@ var SessionManager = class {
|
|
|
6151
6147
|
}
|
|
6152
6148
|
async refresh() {
|
|
6153
6149
|
if (this.isServer) {
|
|
6154
|
-
this.logger.warn("'
|
|
6150
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
6155
6151
|
return {
|
|
6156
6152
|
ok: true,
|
|
6157
6153
|
data: null
|
|
6158
6154
|
};
|
|
6159
6155
|
}
|
|
6160
|
-
const val =
|
|
6156
|
+
const val = cookies__default.default.get(this.storageKey);
|
|
6161
6157
|
if (!val) {
|
|
6162
6158
|
return {
|
|
6163
6159
|
ok: true,
|
|
@@ -6174,7 +6170,7 @@ var SessionManager = class {
|
|
|
6174
6170
|
if (!res.ok) {
|
|
6175
6171
|
this.logger.error(`Failed to refresh session: ${res.error.message}`);
|
|
6176
6172
|
if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
|
|
6177
|
-
|
|
6173
|
+
cookies__default.default.remove(this.storageKey);
|
|
6178
6174
|
return {
|
|
6179
6175
|
ok: false,
|
|
6180
6176
|
error: res.error
|
|
@@ -6195,7 +6191,9 @@ var SessionManager = class {
|
|
|
6195
6191
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
6196
6192
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
6197
6193
|
};
|
|
6198
|
-
|
|
6194
|
+
cookies__default.default.set(this.storageKey, JSON.stringify(obj), {
|
|
6195
|
+
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
6196
|
+
});
|
|
6199
6197
|
return {
|
|
6200
6198
|
ok: true,
|
|
6201
6199
|
data: obj
|
|
@@ -6212,18 +6210,18 @@ var SessionManager = class {
|
|
|
6212
6210
|
}
|
|
6213
6211
|
async destroy() {
|
|
6214
6212
|
if (this.isServer) {
|
|
6215
|
-
this.logger.warn("'
|
|
6213
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
6216
6214
|
return;
|
|
6217
6215
|
}
|
|
6218
6216
|
const res = await this.get();
|
|
6219
6217
|
if (res.data?.accessToken) {
|
|
6220
6218
|
await this.authService.destroySession(res.data.accessToken);
|
|
6221
6219
|
}
|
|
6222
|
-
|
|
6220
|
+
cookies__default.default.remove(this.storageKey);
|
|
6223
6221
|
}
|
|
6224
6222
|
async verify() {
|
|
6225
6223
|
if (this.isServer) {
|
|
6226
|
-
this.logger.warn("'
|
|
6224
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
6227
6225
|
return true;
|
|
6228
6226
|
}
|
|
6229
6227
|
const s = await this.get();
|
|
@@ -6233,13 +6231,13 @@ var SessionManager = class {
|
|
|
6233
6231
|
if (!s.data) return true;
|
|
6234
6232
|
const v = await this.authService.verifySession(s.data.accessToken);
|
|
6235
6233
|
if (!v) {
|
|
6236
|
-
|
|
6234
|
+
cookies__default.default.remove(this.storageKey);
|
|
6237
6235
|
}
|
|
6238
6236
|
return v;
|
|
6239
6237
|
}
|
|
6240
6238
|
get onMaya() {
|
|
6241
6239
|
if (this.isServer) {
|
|
6242
|
-
this.logger.warn("'
|
|
6240
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
6243
6241
|
return false;
|
|
6244
6242
|
}
|
|
6245
6243
|
return localStorage.getItem(this.platformStorageKey) === "MAYA";
|
|
@@ -9102,8 +9100,8 @@ var Sdk = class {
|
|
|
9102
9100
|
data: res.data.map(this.transformer.transform.promo)
|
|
9103
9101
|
};
|
|
9104
9102
|
}
|
|
9105
|
-
async availablePromos() {
|
|
9106
|
-
const res = await this.walletService.availablePromos();
|
|
9103
|
+
async availablePromos(input) {
|
|
9104
|
+
const res = await this.walletService.availablePromos(input);
|
|
9107
9105
|
if (!res.ok) return res;
|
|
9108
9106
|
return {
|
|
9109
9107
|
ok: true,
|
|
@@ -9830,7 +9828,7 @@ var ENDPOINTS = {
|
|
|
9830
9828
|
portal: "https://portal.opexa.io/graphql",
|
|
9831
9829
|
trigger: "https://trigger.staging.atalos.io/graphql",
|
|
9832
9830
|
static: "https://static.atalos.io",
|
|
9833
|
-
cmsPortal: "https://portal-api.opexacms.io",
|
|
9831
|
+
cmsPortal: "https://portal-api.staging.opexacms.io",
|
|
9834
9832
|
opexapay: "https://external.opexapay.opexa.io"
|
|
9835
9833
|
}
|
|
9836
9834
|
};
|