@opexa/portal-sdk 0.51.3 → 0.51.5
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 +103 -88
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +103 -88
- package/dist/index.js.map +1 -1
- package/package.json +15 -2
package/dist/index.js
CHANGED
|
@@ -5427,8 +5427,8 @@ function pollable(func, config) {
|
|
|
5427
5427
|
};
|
|
5428
5428
|
}
|
|
5429
5429
|
|
|
5430
|
-
// src/sdk/session-manager.ts
|
|
5431
|
-
var
|
|
5430
|
+
// src/sdk/session-manager-cookie.ts
|
|
5431
|
+
var SessionManagerCookie = class {
|
|
5432
5432
|
logger;
|
|
5433
5433
|
storageKey = "session";
|
|
5434
5434
|
platformStorageKey = "session/platform";
|
|
@@ -5439,10 +5439,6 @@ var SessionManager = class {
|
|
|
5439
5439
|
this.authService = config.authService;
|
|
5440
5440
|
this.walletService = config.walletService;
|
|
5441
5441
|
this.logger = config.logger;
|
|
5442
|
-
if (config.sessionPrefix) {
|
|
5443
|
-
this.storageKey = `${config.sessionPrefix}/${this.storageKey}`;
|
|
5444
|
-
this.platformStorageKey = `${config.sessionPrefix}/${this.platformStorageKey}`;
|
|
5445
|
-
}
|
|
5446
5442
|
}
|
|
5447
5443
|
get refreshing() {
|
|
5448
5444
|
return this._refreshing;
|
|
@@ -5451,16 +5447,6 @@ var SessionManager = class {
|
|
|
5451
5447
|
this._refreshing = value;
|
|
5452
5448
|
}
|
|
5453
5449
|
async create(input) {
|
|
5454
|
-
if (this.isServer) {
|
|
5455
|
-
this.logger.warn("'localStorage' is not available on the server.");
|
|
5456
|
-
return {
|
|
5457
|
-
ok: false,
|
|
5458
|
-
error: {
|
|
5459
|
-
name: "UnknownError",
|
|
5460
|
-
message: "Server sign in is not supported."
|
|
5461
|
-
}
|
|
5462
|
-
};
|
|
5463
|
-
}
|
|
5464
5450
|
if (input.type === "MAYA") {
|
|
5465
5451
|
localStorage.setItem(this.platformStorageKey, "MAYA");
|
|
5466
5452
|
const f0 = () => this.walletService.mayaSession({ id: input.sessionId });
|
|
@@ -5487,13 +5473,14 @@ var SessionManager = class {
|
|
|
5487
5473
|
})();
|
|
5488
5474
|
if (!r1.ok) return r1;
|
|
5489
5475
|
const now2 = /* @__PURE__ */ new Date();
|
|
5490
|
-
|
|
5476
|
+
cookies.set(
|
|
5491
5477
|
this.storageKey,
|
|
5492
5478
|
JSON.stringify({
|
|
5493
5479
|
...r1.data,
|
|
5494
5480
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5495
5481
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5496
|
-
})
|
|
5482
|
+
}),
|
|
5483
|
+
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
5497
5484
|
);
|
|
5498
5485
|
return {
|
|
5499
5486
|
ok: true,
|
|
@@ -5504,13 +5491,16 @@ var SessionManager = class {
|
|
|
5504
5491
|
const res2 = await this.authService.createSession(input);
|
|
5505
5492
|
if (res2.ok) {
|
|
5506
5493
|
const now2 = /* @__PURE__ */ new Date();
|
|
5507
|
-
|
|
5494
|
+
cookies.set(
|
|
5508
5495
|
this.storageKey,
|
|
5509
5496
|
JSON.stringify({
|
|
5510
5497
|
...res2.data,
|
|
5511
5498
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5512
5499
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5513
|
-
})
|
|
5500
|
+
}),
|
|
5501
|
+
{
|
|
5502
|
+
expires: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5503
|
+
}
|
|
5514
5504
|
);
|
|
5515
5505
|
return {
|
|
5516
5506
|
ok: true,
|
|
@@ -5522,18 +5512,18 @@ var SessionManager = class {
|
|
|
5522
5512
|
if (input.type === "SOCIALS" || input.type === "TOKEN") {
|
|
5523
5513
|
const res2 = await this.authService.createSession({
|
|
5524
5514
|
type: "SOCIALS",
|
|
5525
|
-
token: input.token
|
|
5526
|
-
channel: input.channel
|
|
5515
|
+
token: input.token
|
|
5527
5516
|
});
|
|
5528
5517
|
if (res2.ok) {
|
|
5529
5518
|
const now2 = /* @__PURE__ */ new Date();
|
|
5530
|
-
|
|
5519
|
+
cookies.set(
|
|
5531
5520
|
this.storageKey,
|
|
5532
5521
|
JSON.stringify({
|
|
5533
5522
|
...res2.data,
|
|
5534
5523
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5535
5524
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5536
|
-
})
|
|
5525
|
+
}),
|
|
5526
|
+
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
5537
5527
|
);
|
|
5538
5528
|
return {
|
|
5539
5529
|
ok: true,
|
|
@@ -5547,13 +5537,14 @@ var SessionManager = class {
|
|
|
5547
5537
|
const res2 = await this.authService.createSession(input);
|
|
5548
5538
|
if (res2.ok) {
|
|
5549
5539
|
const now2 = /* @__PURE__ */ new Date();
|
|
5550
|
-
|
|
5540
|
+
cookies.set(
|
|
5551
5541
|
this.storageKey,
|
|
5552
5542
|
JSON.stringify({
|
|
5553
5543
|
...res2.data,
|
|
5554
5544
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5555
5545
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5556
|
-
})
|
|
5546
|
+
}),
|
|
5547
|
+
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
5557
5548
|
);
|
|
5558
5549
|
return {
|
|
5559
5550
|
ok: true,
|
|
@@ -5573,13 +5564,14 @@ var SessionManager = class {
|
|
|
5573
5564
|
};
|
|
5574
5565
|
}
|
|
5575
5566
|
const now = /* @__PURE__ */ new Date();
|
|
5576
|
-
|
|
5567
|
+
cookies.set(
|
|
5577
5568
|
this.storageKey,
|
|
5578
5569
|
JSON.stringify({
|
|
5579
5570
|
...res.data,
|
|
5580
5571
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
5581
5572
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
5582
|
-
})
|
|
5573
|
+
}),
|
|
5574
|
+
{}
|
|
5583
5575
|
);
|
|
5584
5576
|
return {
|
|
5585
5577
|
ok: true,
|
|
@@ -5591,15 +5583,18 @@ var SessionManager = class {
|
|
|
5591
5583
|
if (res.ok) {
|
|
5592
5584
|
const now = /* @__PURE__ */ new Date();
|
|
5593
5585
|
if (this.isServer) {
|
|
5594
|
-
this.logger.warn("'
|
|
5586
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
5595
5587
|
} else {
|
|
5596
|
-
|
|
5588
|
+
cookies.set(
|
|
5597
5589
|
this.storageKey,
|
|
5598
5590
|
JSON.stringify({
|
|
5599
5591
|
...res.data,
|
|
5600
5592
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
5601
5593
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
5602
|
-
})
|
|
5594
|
+
}),
|
|
5595
|
+
{
|
|
5596
|
+
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
5597
|
+
}
|
|
5603
5598
|
);
|
|
5604
5599
|
}
|
|
5605
5600
|
return { ok: true };
|
|
@@ -5609,7 +5604,7 @@ var SessionManager = class {
|
|
|
5609
5604
|
}
|
|
5610
5605
|
async get() {
|
|
5611
5606
|
if (this.isServer) {
|
|
5612
|
-
this.logger.warn("'
|
|
5607
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
5613
5608
|
return {
|
|
5614
5609
|
ok: true,
|
|
5615
5610
|
data: null
|
|
@@ -5619,7 +5614,7 @@ var SessionManager = class {
|
|
|
5619
5614
|
await sleep(1e3);
|
|
5620
5615
|
return await this.get();
|
|
5621
5616
|
}
|
|
5622
|
-
const val =
|
|
5617
|
+
const val = cookies.get(this.storageKey);
|
|
5623
5618
|
if (!val) {
|
|
5624
5619
|
return {
|
|
5625
5620
|
ok: true,
|
|
@@ -5633,7 +5628,7 @@ var SessionManager = class {
|
|
|
5633
5628
|
const refreshTokenExpiresAt = new Date(obj.refreshTokenExpiresAt);
|
|
5634
5629
|
if (isAfter(now, refreshTokenExpiresAt)) {
|
|
5635
5630
|
this.logger.warn("Session expired. Logging out..");
|
|
5636
|
-
|
|
5631
|
+
cookies.remove(this.storageKey);
|
|
5637
5632
|
return {
|
|
5638
5633
|
ok: false,
|
|
5639
5634
|
error: {
|
|
@@ -5650,7 +5645,7 @@ var SessionManager = class {
|
|
|
5650
5645
|
if (!res.ok) {
|
|
5651
5646
|
this.logger.error(`Failed to refresh session: ${res.error.message}`);
|
|
5652
5647
|
if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
|
|
5653
|
-
|
|
5648
|
+
cookies.remove(this.storageKey);
|
|
5654
5649
|
return {
|
|
5655
5650
|
ok: false,
|
|
5656
5651
|
error: res.error
|
|
@@ -5671,7 +5666,9 @@ var SessionManager = class {
|
|
|
5671
5666
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
5672
5667
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
5673
5668
|
};
|
|
5674
|
-
|
|
5669
|
+
cookies.set(this.storageKey, JSON.stringify(obj), {
|
|
5670
|
+
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
5671
|
+
});
|
|
5675
5672
|
}
|
|
5676
5673
|
return {
|
|
5677
5674
|
ok: true,
|
|
@@ -5689,13 +5686,13 @@ var SessionManager = class {
|
|
|
5689
5686
|
}
|
|
5690
5687
|
async refresh() {
|
|
5691
5688
|
if (this.isServer) {
|
|
5692
|
-
this.logger.warn("'
|
|
5689
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
5693
5690
|
return {
|
|
5694
5691
|
ok: true,
|
|
5695
5692
|
data: null
|
|
5696
5693
|
};
|
|
5697
5694
|
}
|
|
5698
|
-
const val =
|
|
5695
|
+
const val = cookies.get(this.storageKey);
|
|
5699
5696
|
if (!val) {
|
|
5700
5697
|
return {
|
|
5701
5698
|
ok: true,
|
|
@@ -5712,7 +5709,7 @@ var SessionManager = class {
|
|
|
5712
5709
|
if (!res.ok) {
|
|
5713
5710
|
this.logger.error(`Failed to refresh session: ${res.error.message}`);
|
|
5714
5711
|
if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
|
|
5715
|
-
|
|
5712
|
+
cookies.remove(this.storageKey);
|
|
5716
5713
|
return {
|
|
5717
5714
|
ok: false,
|
|
5718
5715
|
error: res.error
|
|
@@ -5733,7 +5730,9 @@ var SessionManager = class {
|
|
|
5733
5730
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
5734
5731
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
5735
5732
|
};
|
|
5736
|
-
|
|
5733
|
+
cookies.set(this.storageKey, JSON.stringify(obj), {
|
|
5734
|
+
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
5735
|
+
});
|
|
5737
5736
|
return {
|
|
5738
5737
|
ok: true,
|
|
5739
5738
|
data: obj
|
|
@@ -5750,18 +5749,18 @@ var SessionManager = class {
|
|
|
5750
5749
|
}
|
|
5751
5750
|
async destroy() {
|
|
5752
5751
|
if (this.isServer) {
|
|
5753
|
-
this.logger.warn("'
|
|
5752
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
5754
5753
|
return;
|
|
5755
5754
|
}
|
|
5756
5755
|
const res = await this.get();
|
|
5757
5756
|
if (res.data?.accessToken) {
|
|
5758
5757
|
await this.authService.destroySession(res.data.accessToken);
|
|
5759
5758
|
}
|
|
5760
|
-
|
|
5759
|
+
cookies.remove(this.storageKey);
|
|
5761
5760
|
}
|
|
5762
5761
|
async verify() {
|
|
5763
5762
|
if (this.isServer) {
|
|
5764
|
-
this.logger.warn("'
|
|
5763
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
5765
5764
|
return true;
|
|
5766
5765
|
}
|
|
5767
5766
|
const s = await this.get();
|
|
@@ -5771,13 +5770,13 @@ var SessionManager = class {
|
|
|
5771
5770
|
if (!s.data) return true;
|
|
5772
5771
|
const v = await this.authService.verifySession(s.data.accessToken);
|
|
5773
5772
|
if (!v) {
|
|
5774
|
-
|
|
5773
|
+
cookies.remove(this.storageKey);
|
|
5775
5774
|
}
|
|
5776
5775
|
return v;
|
|
5777
5776
|
}
|
|
5778
5777
|
get onMaya() {
|
|
5779
5778
|
if (this.isServer) {
|
|
5780
|
-
this.logger.warn("'
|
|
5779
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
5781
5780
|
return false;
|
|
5782
5781
|
}
|
|
5783
5782
|
return localStorage.getItem(this.platformStorageKey) === "MAYA";
|
|
@@ -5793,7 +5792,9 @@ var SessionManager = class {
|
|
|
5793
5792
|
return typeof window === "undefined";
|
|
5794
5793
|
}
|
|
5795
5794
|
};
|
|
5796
|
-
|
|
5795
|
+
|
|
5796
|
+
// src/sdk/session-manager.ts
|
|
5797
|
+
var SessionManager = class {
|
|
5797
5798
|
logger;
|
|
5798
5799
|
storageKey = "session";
|
|
5799
5800
|
platformStorageKey = "session/platform";
|
|
@@ -5804,6 +5805,10 @@ var SessionManagerCookie = class {
|
|
|
5804
5805
|
this.authService = config.authService;
|
|
5805
5806
|
this.walletService = config.walletService;
|
|
5806
5807
|
this.logger = config.logger;
|
|
5808
|
+
if (config.sessionPrefix) {
|
|
5809
|
+
this.storageKey = `${config.sessionPrefix}/${this.storageKey}`;
|
|
5810
|
+
this.platformStorageKey = `${config.sessionPrefix}/${this.platformStorageKey}`;
|
|
5811
|
+
}
|
|
5807
5812
|
}
|
|
5808
5813
|
get refreshing() {
|
|
5809
5814
|
return this._refreshing;
|
|
@@ -5812,6 +5817,16 @@ var SessionManagerCookie = class {
|
|
|
5812
5817
|
this._refreshing = value;
|
|
5813
5818
|
}
|
|
5814
5819
|
async create(input) {
|
|
5820
|
+
if (this.isServer) {
|
|
5821
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
5822
|
+
return {
|
|
5823
|
+
ok: false,
|
|
5824
|
+
error: {
|
|
5825
|
+
name: "UnknownError",
|
|
5826
|
+
message: "Server sign in is not supported."
|
|
5827
|
+
}
|
|
5828
|
+
};
|
|
5829
|
+
}
|
|
5815
5830
|
if (input.type === "MAYA") {
|
|
5816
5831
|
localStorage.setItem(this.platformStorageKey, "MAYA");
|
|
5817
5832
|
const f0 = () => this.walletService.mayaSession({ id: input.sessionId });
|
|
@@ -5838,14 +5853,13 @@ var SessionManagerCookie = class {
|
|
|
5838
5853
|
})();
|
|
5839
5854
|
if (!r1.ok) return r1;
|
|
5840
5855
|
const now2 = /* @__PURE__ */ new Date();
|
|
5841
|
-
|
|
5856
|
+
localStorage.setItem(
|
|
5842
5857
|
this.storageKey,
|
|
5843
5858
|
JSON.stringify({
|
|
5844
5859
|
...r1.data,
|
|
5845
5860
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5846
5861
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5847
|
-
})
|
|
5848
|
-
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
5862
|
+
})
|
|
5849
5863
|
);
|
|
5850
5864
|
return {
|
|
5851
5865
|
ok: true,
|
|
@@ -5856,16 +5870,13 @@ var SessionManagerCookie = class {
|
|
|
5856
5870
|
const res2 = await this.authService.createSession(input);
|
|
5857
5871
|
if (res2.ok) {
|
|
5858
5872
|
const now2 = /* @__PURE__ */ new Date();
|
|
5859
|
-
|
|
5873
|
+
localStorage.setItem(
|
|
5860
5874
|
this.storageKey,
|
|
5861
5875
|
JSON.stringify({
|
|
5862
5876
|
...res2.data,
|
|
5863
5877
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5864
5878
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5865
|
-
})
|
|
5866
|
-
{
|
|
5867
|
-
expires: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5868
|
-
}
|
|
5879
|
+
})
|
|
5869
5880
|
);
|
|
5870
5881
|
return {
|
|
5871
5882
|
ok: true,
|
|
@@ -5877,18 +5888,18 @@ var SessionManagerCookie = class {
|
|
|
5877
5888
|
if (input.type === "SOCIALS" || input.type === "TOKEN") {
|
|
5878
5889
|
const res2 = await this.authService.createSession({
|
|
5879
5890
|
type: "SOCIALS",
|
|
5880
|
-
token: input.token
|
|
5891
|
+
token: input.token,
|
|
5892
|
+
channel: input.channel
|
|
5881
5893
|
});
|
|
5882
5894
|
if (res2.ok) {
|
|
5883
5895
|
const now2 = /* @__PURE__ */ new Date();
|
|
5884
|
-
|
|
5896
|
+
localStorage.setItem(
|
|
5885
5897
|
this.storageKey,
|
|
5886
5898
|
JSON.stringify({
|
|
5887
5899
|
...res2.data,
|
|
5888
5900
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5889
5901
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5890
|
-
})
|
|
5891
|
-
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
5902
|
+
})
|
|
5892
5903
|
);
|
|
5893
5904
|
return {
|
|
5894
5905
|
ok: true,
|
|
@@ -5902,14 +5913,13 @@ var SessionManagerCookie = class {
|
|
|
5902
5913
|
const res2 = await this.authService.createSession(input);
|
|
5903
5914
|
if (res2.ok) {
|
|
5904
5915
|
const now2 = /* @__PURE__ */ new Date();
|
|
5905
|
-
|
|
5916
|
+
localStorage.setItem(
|
|
5906
5917
|
this.storageKey,
|
|
5907
5918
|
JSON.stringify({
|
|
5908
5919
|
...res2.data,
|
|
5909
5920
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5910
5921
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5911
|
-
})
|
|
5912
|
-
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
5922
|
+
})
|
|
5913
5923
|
);
|
|
5914
5924
|
return {
|
|
5915
5925
|
ok: true,
|
|
@@ -5929,14 +5939,13 @@ var SessionManagerCookie = class {
|
|
|
5929
5939
|
};
|
|
5930
5940
|
}
|
|
5931
5941
|
const now = /* @__PURE__ */ new Date();
|
|
5932
|
-
|
|
5942
|
+
localStorage.setItem(
|
|
5933
5943
|
this.storageKey,
|
|
5934
5944
|
JSON.stringify({
|
|
5935
5945
|
...res.data,
|
|
5936
5946
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
5937
5947
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
5938
|
-
})
|
|
5939
|
-
{}
|
|
5948
|
+
})
|
|
5940
5949
|
);
|
|
5941
5950
|
return {
|
|
5942
5951
|
ok: true,
|
|
@@ -5948,18 +5957,15 @@ var SessionManagerCookie = class {
|
|
|
5948
5957
|
if (res.ok) {
|
|
5949
5958
|
const now = /* @__PURE__ */ new Date();
|
|
5950
5959
|
if (this.isServer) {
|
|
5951
|
-
this.logger.warn("'
|
|
5960
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
5952
5961
|
} else {
|
|
5953
|
-
|
|
5962
|
+
localStorage.setItem(
|
|
5954
5963
|
this.storageKey,
|
|
5955
5964
|
JSON.stringify({
|
|
5956
5965
|
...res.data,
|
|
5957
5966
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
5958
5967
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
5959
|
-
})
|
|
5960
|
-
{
|
|
5961
|
-
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
5962
|
-
}
|
|
5968
|
+
})
|
|
5963
5969
|
);
|
|
5964
5970
|
}
|
|
5965
5971
|
return { ok: true };
|
|
@@ -5969,7 +5975,7 @@ var SessionManagerCookie = class {
|
|
|
5969
5975
|
}
|
|
5970
5976
|
async get() {
|
|
5971
5977
|
if (this.isServer) {
|
|
5972
|
-
this.logger.warn("'
|
|
5978
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
5973
5979
|
return {
|
|
5974
5980
|
ok: true,
|
|
5975
5981
|
data: null
|
|
@@ -5979,7 +5985,7 @@ var SessionManagerCookie = class {
|
|
|
5979
5985
|
await sleep(1e3);
|
|
5980
5986
|
return await this.get();
|
|
5981
5987
|
}
|
|
5982
|
-
const val =
|
|
5988
|
+
const val = localStorage.getItem(this.storageKey);
|
|
5983
5989
|
if (!val) {
|
|
5984
5990
|
return {
|
|
5985
5991
|
ok: true,
|
|
@@ -5993,7 +5999,7 @@ var SessionManagerCookie = class {
|
|
|
5993
5999
|
const refreshTokenExpiresAt = new Date(obj.refreshTokenExpiresAt);
|
|
5994
6000
|
if (isAfter(now, refreshTokenExpiresAt)) {
|
|
5995
6001
|
this.logger.warn("Session expired. Logging out..");
|
|
5996
|
-
|
|
6002
|
+
localStorage.removeItem(this.storageKey);
|
|
5997
6003
|
return {
|
|
5998
6004
|
ok: false,
|
|
5999
6005
|
error: {
|
|
@@ -6010,7 +6016,7 @@ var SessionManagerCookie = class {
|
|
|
6010
6016
|
if (!res.ok) {
|
|
6011
6017
|
this.logger.error(`Failed to refresh session: ${res.error.message}`);
|
|
6012
6018
|
if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
|
|
6013
|
-
|
|
6019
|
+
localStorage.removeItem(this.storageKey);
|
|
6014
6020
|
return {
|
|
6015
6021
|
ok: false,
|
|
6016
6022
|
error: res.error
|
|
@@ -6031,9 +6037,7 @@ var SessionManagerCookie = class {
|
|
|
6031
6037
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
6032
6038
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
6033
6039
|
};
|
|
6034
|
-
|
|
6035
|
-
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
6036
|
-
});
|
|
6040
|
+
localStorage.setItem(this.storageKey, JSON.stringify(obj));
|
|
6037
6041
|
}
|
|
6038
6042
|
return {
|
|
6039
6043
|
ok: true,
|
|
@@ -6051,13 +6055,13 @@ var SessionManagerCookie = class {
|
|
|
6051
6055
|
}
|
|
6052
6056
|
async refresh() {
|
|
6053
6057
|
if (this.isServer) {
|
|
6054
|
-
this.logger.warn("'
|
|
6058
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
6055
6059
|
return {
|
|
6056
6060
|
ok: true,
|
|
6057
6061
|
data: null
|
|
6058
6062
|
};
|
|
6059
6063
|
}
|
|
6060
|
-
const val =
|
|
6064
|
+
const val = localStorage.getItem(this.storageKey);
|
|
6061
6065
|
if (!val) {
|
|
6062
6066
|
return {
|
|
6063
6067
|
ok: true,
|
|
@@ -6074,7 +6078,7 @@ var SessionManagerCookie = class {
|
|
|
6074
6078
|
if (!res.ok) {
|
|
6075
6079
|
this.logger.error(`Failed to refresh session: ${res.error.message}`);
|
|
6076
6080
|
if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
|
|
6077
|
-
|
|
6081
|
+
localStorage.removeItem(this.storageKey);
|
|
6078
6082
|
return {
|
|
6079
6083
|
ok: false,
|
|
6080
6084
|
error: res.error
|
|
@@ -6095,9 +6099,7 @@ var SessionManagerCookie = class {
|
|
|
6095
6099
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
6096
6100
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
6097
6101
|
};
|
|
6098
|
-
|
|
6099
|
-
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
6100
|
-
});
|
|
6102
|
+
localStorage.setItem(this.storageKey, JSON.stringify(obj));
|
|
6101
6103
|
return {
|
|
6102
6104
|
ok: true,
|
|
6103
6105
|
data: obj
|
|
@@ -6114,18 +6116,18 @@ var SessionManagerCookie = class {
|
|
|
6114
6116
|
}
|
|
6115
6117
|
async destroy() {
|
|
6116
6118
|
if (this.isServer) {
|
|
6117
|
-
this.logger.warn("'
|
|
6119
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
6118
6120
|
return;
|
|
6119
6121
|
}
|
|
6120
6122
|
const res = await this.get();
|
|
6121
6123
|
if (res.data?.accessToken) {
|
|
6122
6124
|
await this.authService.destroySession(res.data.accessToken);
|
|
6123
6125
|
}
|
|
6124
|
-
|
|
6126
|
+
localStorage.removeItem(this.storageKey);
|
|
6125
6127
|
}
|
|
6126
6128
|
async verify() {
|
|
6127
6129
|
if (this.isServer) {
|
|
6128
|
-
this.logger.warn("'
|
|
6130
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
6129
6131
|
return true;
|
|
6130
6132
|
}
|
|
6131
6133
|
const s = await this.get();
|
|
@@ -6135,13 +6137,13 @@ var SessionManagerCookie = class {
|
|
|
6135
6137
|
if (!s.data) return true;
|
|
6136
6138
|
const v = await this.authService.verifySession(s.data.accessToken);
|
|
6137
6139
|
if (!v) {
|
|
6138
|
-
|
|
6140
|
+
localStorage.removeItem(this.storageKey);
|
|
6139
6141
|
}
|
|
6140
6142
|
return v;
|
|
6141
6143
|
}
|
|
6142
6144
|
get onMaya() {
|
|
6143
6145
|
if (this.isServer) {
|
|
6144
|
-
this.logger.warn("'
|
|
6146
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
6145
6147
|
return false;
|
|
6146
6148
|
}
|
|
6147
6149
|
return localStorage.getItem(this.platformStorageKey) === "MAYA";
|
|
@@ -9684,6 +9686,19 @@ var ENDPOINTS = {
|
|
|
9684
9686
|
static: "https://static.atalos.io",
|
|
9685
9687
|
cmsPortal: "https://portal-api.opexacms.io",
|
|
9686
9688
|
opexapay: "https://external.opexapay.opexa.io"
|
|
9689
|
+
},
|
|
9690
|
+
staging: {
|
|
9691
|
+
auth: "https://auth.staging.atalos.io",
|
|
9692
|
+
game: "https://game.staging.atalos.io/graphql",
|
|
9693
|
+
file: "https://file.staging.atalos.io/graphql",
|
|
9694
|
+
report: "https://report.staging.atalos.io/graphql",
|
|
9695
|
+
wallet: "https://wallet.staging.atalos.io/graphql",
|
|
9696
|
+
account: "https://account.staging.atalos.io/graphql",
|
|
9697
|
+
portal: "https://portal.opexa.io/graphql",
|
|
9698
|
+
trigger: "https://trigger.staging.atalos.io/graphql",
|
|
9699
|
+
static: "https://static.atalos.io",
|
|
9700
|
+
cmsPortal: "https://portal-api.opexacms.io",
|
|
9701
|
+
opexapay: "https://external.opexapay.opexa.io"
|
|
9687
9702
|
}
|
|
9688
9703
|
};
|
|
9689
9704
|
|