@opexa/portal-sdk 0.59.72 → 0.59.73
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/README.md +1634 -1634
- package/dist/{chunk-MQC7EE6J.js → chunk-2KACCSX3.js} +17 -3
- package/dist/chunk-2KACCSX3.js.map +1 -0
- package/dist/{chunk-5WRVWQBT.js → chunk-7APXFZ5G.js} +3 -3
- package/dist/chunk-7APXFZ5G.js.map +1 -0
- package/dist/{chunk-ROBGEUSE.js → chunk-WVFSGB7Y.js} +2 -2
- package/dist/chunk-WVFSGB7Y.js.map +1 -0
- package/dist/index.cjs +112 -88
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +101 -91
- package/dist/index.js.map +1 -1
- package/dist/services/index.cjs +14 -0
- package/dist/services/index.cjs.map +1 -1
- package/dist/services/index.d.cts +4 -3
- package/dist/services/index.d.ts +4 -3
- package/dist/services/index.js +2 -2
- package/dist/{types-B8RFcTu9.d.ts → types-C2Mdipgs.d.ts} +13 -1
- package/dist/{types-BqFODW6R.d.cts → types-DXuCcBxY.d.cts} +13 -1
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-5WRVWQBT.js.map +0 -1
- package/dist/chunk-MQC7EE6J.js.map +0 -1
- package/dist/chunk-ROBGEUSE.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CmsPortalService, GameService, ExtensionService, FileService, WalletService, AccountService, ReportService, PortalService, TriggerService, AuthService, getFingerPrint } from './chunk-
|
|
2
|
-
import { GraphQLClient, isPlainObject } from './chunk-
|
|
3
|
-
import './chunk-
|
|
1
|
+
import { CmsPortalService, GameService, ExtensionService, FileService, WalletService, AccountService, ReportService, PortalService, TriggerService, AuthService, getFingerPrint } from './chunk-2KACCSX3.js';
|
|
2
|
+
import { GraphQLClient, isPlainObject } from './chunk-7APXFZ5G.js';
|
|
3
|
+
import './chunk-WVFSGB7Y.js';
|
|
4
4
|
import { ObjectId } from '@opexa/object-id';
|
|
5
5
|
export { ObjectId } from '@opexa/object-id';
|
|
6
6
|
import { Capacitor } from '@capacitor/core';
|
|
@@ -335,8 +335,8 @@ function pollable(func, config) {
|
|
|
335
335
|
};
|
|
336
336
|
}
|
|
337
337
|
|
|
338
|
-
// src/sdk/session-manager.ts
|
|
339
|
-
var
|
|
338
|
+
// src/sdk/session-manager-cookie.ts
|
|
339
|
+
var SessionManagerCookie = class {
|
|
340
340
|
logger;
|
|
341
341
|
storageKey = "session";
|
|
342
342
|
platformStorageKey = "session/platform";
|
|
@@ -347,10 +347,6 @@ var SessionManager = class {
|
|
|
347
347
|
this.authService = config.authService;
|
|
348
348
|
this.walletService = config.walletService;
|
|
349
349
|
this.logger = config.logger;
|
|
350
|
-
if (config.sessionPrefix) {
|
|
351
|
-
this.storageKey = `${config.sessionPrefix}/${this.storageKey}`;
|
|
352
|
-
this.platformStorageKey = `${config.sessionPrefix}/${this.platformStorageKey}`;
|
|
353
|
-
}
|
|
354
350
|
}
|
|
355
351
|
get refreshing() {
|
|
356
352
|
return this._refreshing;
|
|
@@ -359,16 +355,6 @@ var SessionManager = class {
|
|
|
359
355
|
this._refreshing = value;
|
|
360
356
|
}
|
|
361
357
|
async create(input, version = 1) {
|
|
362
|
-
if (this.isServer) {
|
|
363
|
-
this.logger.warn("'localStorage' is not available on the server.");
|
|
364
|
-
return {
|
|
365
|
-
ok: false,
|
|
366
|
-
error: {
|
|
367
|
-
name: "UnknownError",
|
|
368
|
-
message: "Server sign in is not supported."
|
|
369
|
-
}
|
|
370
|
-
};
|
|
371
|
-
}
|
|
372
358
|
if (input.type === "MAYA") {
|
|
373
359
|
localStorage.setItem(this.platformStorageKey, "MAYA");
|
|
374
360
|
const f0 = () => this.walletService.mayaSession({ id: input.sessionId });
|
|
@@ -395,13 +381,14 @@ var SessionManager = class {
|
|
|
395
381
|
})();
|
|
396
382
|
if (!r1.ok) return r1;
|
|
397
383
|
const now2 = /* @__PURE__ */ new Date();
|
|
398
|
-
|
|
384
|
+
cookies.set(
|
|
399
385
|
this.storageKey,
|
|
400
386
|
JSON.stringify({
|
|
401
387
|
...r1.data,
|
|
402
388
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
403
389
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
404
|
-
})
|
|
390
|
+
}),
|
|
391
|
+
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
405
392
|
);
|
|
406
393
|
return {
|
|
407
394
|
ok: true,
|
|
@@ -412,13 +399,16 @@ var SessionManager = class {
|
|
|
412
399
|
const res2 = await this.authService.createSession(input, version);
|
|
413
400
|
if (res2.ok) {
|
|
414
401
|
const now2 = /* @__PURE__ */ new Date();
|
|
415
|
-
|
|
402
|
+
cookies.set(
|
|
416
403
|
this.storageKey,
|
|
417
404
|
JSON.stringify({
|
|
418
405
|
...res2.data,
|
|
419
406
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
420
407
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
421
|
-
})
|
|
408
|
+
}),
|
|
409
|
+
{
|
|
410
|
+
expires: subMinutes(addDays(now2, 30), 2).getTime()
|
|
411
|
+
}
|
|
422
412
|
);
|
|
423
413
|
return {
|
|
424
414
|
ok: true,
|
|
@@ -431,20 +421,20 @@ var SessionManager = class {
|
|
|
431
421
|
const res2 = await this.authService.createSession(
|
|
432
422
|
{
|
|
433
423
|
type: "SOCIALS",
|
|
434
|
-
token: input.token
|
|
435
|
-
channel: input.channel
|
|
424
|
+
token: input.token
|
|
436
425
|
},
|
|
437
426
|
version
|
|
438
427
|
);
|
|
439
428
|
if (res2.ok) {
|
|
440
429
|
const now2 = /* @__PURE__ */ new Date();
|
|
441
|
-
|
|
430
|
+
cookies.set(
|
|
442
431
|
this.storageKey,
|
|
443
432
|
JSON.stringify({
|
|
444
433
|
...res2.data,
|
|
445
434
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
446
435
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
447
|
-
})
|
|
436
|
+
}),
|
|
437
|
+
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
448
438
|
);
|
|
449
439
|
return {
|
|
450
440
|
ok: true,
|
|
@@ -458,13 +448,14 @@ var SessionManager = class {
|
|
|
458
448
|
const res2 = await this.authService.createSession(input, version);
|
|
459
449
|
if (res2.ok) {
|
|
460
450
|
const now2 = /* @__PURE__ */ new Date();
|
|
461
|
-
|
|
451
|
+
cookies.set(
|
|
462
452
|
this.storageKey,
|
|
463
453
|
JSON.stringify({
|
|
464
454
|
...res2.data,
|
|
465
455
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
466
456
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
467
|
-
})
|
|
457
|
+
}),
|
|
458
|
+
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
468
459
|
);
|
|
469
460
|
return {
|
|
470
461
|
ok: true,
|
|
@@ -484,13 +475,14 @@ var SessionManager = class {
|
|
|
484
475
|
};
|
|
485
476
|
}
|
|
486
477
|
const now = /* @__PURE__ */ new Date();
|
|
487
|
-
|
|
478
|
+
cookies.set(
|
|
488
479
|
this.storageKey,
|
|
489
480
|
JSON.stringify({
|
|
490
481
|
...res.data,
|
|
491
482
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
492
483
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
493
|
-
})
|
|
484
|
+
}),
|
|
485
|
+
{}
|
|
494
486
|
);
|
|
495
487
|
return {
|
|
496
488
|
ok: true,
|
|
@@ -502,15 +494,18 @@ var SessionManager = class {
|
|
|
502
494
|
if (res.ok) {
|
|
503
495
|
const now = /* @__PURE__ */ new Date();
|
|
504
496
|
if (this.isServer) {
|
|
505
|
-
this.logger.warn("'
|
|
497
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
506
498
|
} else {
|
|
507
|
-
|
|
499
|
+
cookies.set(
|
|
508
500
|
this.storageKey,
|
|
509
501
|
JSON.stringify({
|
|
510
502
|
...res.data,
|
|
511
503
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
512
504
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
513
|
-
})
|
|
505
|
+
}),
|
|
506
|
+
{
|
|
507
|
+
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
508
|
+
}
|
|
514
509
|
);
|
|
515
510
|
}
|
|
516
511
|
return { ok: true };
|
|
@@ -520,7 +515,7 @@ var SessionManager = class {
|
|
|
520
515
|
}
|
|
521
516
|
async get() {
|
|
522
517
|
if (this.isServer) {
|
|
523
|
-
this.logger.warn("'
|
|
518
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
524
519
|
return {
|
|
525
520
|
ok: true,
|
|
526
521
|
data: null
|
|
@@ -530,7 +525,7 @@ var SessionManager = class {
|
|
|
530
525
|
await sleep(1e3);
|
|
531
526
|
return await this.get();
|
|
532
527
|
}
|
|
533
|
-
const val =
|
|
528
|
+
const val = cookies.get(this.storageKey);
|
|
534
529
|
if (!val) {
|
|
535
530
|
return {
|
|
536
531
|
ok: true,
|
|
@@ -544,7 +539,7 @@ var SessionManager = class {
|
|
|
544
539
|
const refreshTokenExpiresAt = new Date(obj.refreshTokenExpiresAt);
|
|
545
540
|
if (isAfter(now, refreshTokenExpiresAt)) {
|
|
546
541
|
this.logger.warn("Session expired. Logging out..");
|
|
547
|
-
|
|
542
|
+
cookies.remove(this.storageKey);
|
|
548
543
|
return {
|
|
549
544
|
ok: false,
|
|
550
545
|
error: {
|
|
@@ -561,7 +556,7 @@ var SessionManager = class {
|
|
|
561
556
|
if (!res.ok) {
|
|
562
557
|
this.logger.error(`Failed to refresh session: ${res.error.message}`);
|
|
563
558
|
if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
|
|
564
|
-
|
|
559
|
+
cookies.remove(this.storageKey);
|
|
565
560
|
return {
|
|
566
561
|
ok: false,
|
|
567
562
|
error: res.error
|
|
@@ -582,7 +577,9 @@ var SessionManager = class {
|
|
|
582
577
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
583
578
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
584
579
|
};
|
|
585
|
-
|
|
580
|
+
cookies.set(this.storageKey, JSON.stringify(obj), {
|
|
581
|
+
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
582
|
+
});
|
|
586
583
|
}
|
|
587
584
|
return {
|
|
588
585
|
ok: true,
|
|
@@ -600,13 +597,13 @@ var SessionManager = class {
|
|
|
600
597
|
}
|
|
601
598
|
async refresh() {
|
|
602
599
|
if (this.isServer) {
|
|
603
|
-
this.logger.warn("'
|
|
600
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
604
601
|
return {
|
|
605
602
|
ok: true,
|
|
606
603
|
data: null
|
|
607
604
|
};
|
|
608
605
|
}
|
|
609
|
-
const val =
|
|
606
|
+
const val = cookies.get(this.storageKey);
|
|
610
607
|
if (!val) {
|
|
611
608
|
return {
|
|
612
609
|
ok: true,
|
|
@@ -623,7 +620,7 @@ var SessionManager = class {
|
|
|
623
620
|
if (!res.ok) {
|
|
624
621
|
this.logger.error(`Failed to refresh session: ${res.error.message}`);
|
|
625
622
|
if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
|
|
626
|
-
|
|
623
|
+
cookies.remove(this.storageKey);
|
|
627
624
|
return {
|
|
628
625
|
ok: false,
|
|
629
626
|
error: res.error
|
|
@@ -644,7 +641,9 @@ var SessionManager = class {
|
|
|
644
641
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
645
642
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
646
643
|
};
|
|
647
|
-
|
|
644
|
+
cookies.set(this.storageKey, JSON.stringify(obj), {
|
|
645
|
+
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
646
|
+
});
|
|
648
647
|
return {
|
|
649
648
|
ok: true,
|
|
650
649
|
data: obj
|
|
@@ -661,18 +660,18 @@ var SessionManager = class {
|
|
|
661
660
|
}
|
|
662
661
|
async destroy() {
|
|
663
662
|
if (this.isServer) {
|
|
664
|
-
this.logger.warn("'
|
|
663
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
665
664
|
return;
|
|
666
665
|
}
|
|
667
666
|
const res = await this.get();
|
|
668
667
|
if (res.data?.accessToken) {
|
|
669
668
|
await this.authService.destroySession(res.data.accessToken);
|
|
670
669
|
}
|
|
671
|
-
|
|
670
|
+
cookies.remove(this.storageKey);
|
|
672
671
|
}
|
|
673
672
|
async verify() {
|
|
674
673
|
if (this.isServer) {
|
|
675
|
-
this.logger.warn("'
|
|
674
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
676
675
|
return true;
|
|
677
676
|
}
|
|
678
677
|
const s = await this.get();
|
|
@@ -682,13 +681,13 @@ var SessionManager = class {
|
|
|
682
681
|
if (!s.data) return true;
|
|
683
682
|
const v = await this.authService.verifySession(s.data.accessToken);
|
|
684
683
|
if (!v) {
|
|
685
|
-
|
|
684
|
+
cookies.remove(this.storageKey);
|
|
686
685
|
}
|
|
687
686
|
return v;
|
|
688
687
|
}
|
|
689
688
|
get onMaya() {
|
|
690
689
|
if (this.isServer) {
|
|
691
|
-
this.logger.warn("'
|
|
690
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
692
691
|
return false;
|
|
693
692
|
}
|
|
694
693
|
return localStorage.getItem(this.platformStorageKey) === "MAYA";
|
|
@@ -704,7 +703,9 @@ var SessionManager = class {
|
|
|
704
703
|
return typeof window === "undefined";
|
|
705
704
|
}
|
|
706
705
|
};
|
|
707
|
-
|
|
706
|
+
|
|
707
|
+
// src/sdk/session-manager.ts
|
|
708
|
+
var SessionManager = class {
|
|
708
709
|
logger;
|
|
709
710
|
storageKey = "session";
|
|
710
711
|
platformStorageKey = "session/platform";
|
|
@@ -715,6 +716,10 @@ var SessionManagerCookie = class {
|
|
|
715
716
|
this.authService = config.authService;
|
|
716
717
|
this.walletService = config.walletService;
|
|
717
718
|
this.logger = config.logger;
|
|
719
|
+
if (config.sessionPrefix) {
|
|
720
|
+
this.storageKey = `${config.sessionPrefix}/${this.storageKey}`;
|
|
721
|
+
this.platformStorageKey = `${config.sessionPrefix}/${this.platformStorageKey}`;
|
|
722
|
+
}
|
|
718
723
|
}
|
|
719
724
|
get refreshing() {
|
|
720
725
|
return this._refreshing;
|
|
@@ -723,6 +728,16 @@ var SessionManagerCookie = class {
|
|
|
723
728
|
this._refreshing = value;
|
|
724
729
|
}
|
|
725
730
|
async create(input, version = 1) {
|
|
731
|
+
if (this.isServer) {
|
|
732
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
733
|
+
return {
|
|
734
|
+
ok: false,
|
|
735
|
+
error: {
|
|
736
|
+
name: "UnknownError",
|
|
737
|
+
message: "Server sign in is not supported."
|
|
738
|
+
}
|
|
739
|
+
};
|
|
740
|
+
}
|
|
726
741
|
if (input.type === "MAYA") {
|
|
727
742
|
localStorage.setItem(this.platformStorageKey, "MAYA");
|
|
728
743
|
const f0 = () => this.walletService.mayaSession({ id: input.sessionId });
|
|
@@ -749,14 +764,13 @@ var SessionManagerCookie = class {
|
|
|
749
764
|
})();
|
|
750
765
|
if (!r1.ok) return r1;
|
|
751
766
|
const now2 = /* @__PURE__ */ new Date();
|
|
752
|
-
|
|
767
|
+
localStorage.setItem(
|
|
753
768
|
this.storageKey,
|
|
754
769
|
JSON.stringify({
|
|
755
770
|
...r1.data,
|
|
756
771
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
757
772
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
758
|
-
})
|
|
759
|
-
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
773
|
+
})
|
|
760
774
|
);
|
|
761
775
|
return {
|
|
762
776
|
ok: true,
|
|
@@ -767,16 +781,13 @@ var SessionManagerCookie = class {
|
|
|
767
781
|
const res2 = await this.authService.createSession(input, version);
|
|
768
782
|
if (res2.ok) {
|
|
769
783
|
const now2 = /* @__PURE__ */ new Date();
|
|
770
|
-
|
|
784
|
+
localStorage.setItem(
|
|
771
785
|
this.storageKey,
|
|
772
786
|
JSON.stringify({
|
|
773
787
|
...res2.data,
|
|
774
788
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
775
789
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
776
|
-
})
|
|
777
|
-
{
|
|
778
|
-
expires: subMinutes(addDays(now2, 30), 2).getTime()
|
|
779
|
-
}
|
|
790
|
+
})
|
|
780
791
|
);
|
|
781
792
|
return {
|
|
782
793
|
ok: true,
|
|
@@ -789,20 +800,20 @@ var SessionManagerCookie = class {
|
|
|
789
800
|
const res2 = await this.authService.createSession(
|
|
790
801
|
{
|
|
791
802
|
type: "SOCIALS",
|
|
792
|
-
token: input.token
|
|
803
|
+
token: input.token,
|
|
804
|
+
channel: input.channel
|
|
793
805
|
},
|
|
794
806
|
version
|
|
795
807
|
);
|
|
796
808
|
if (res2.ok) {
|
|
797
809
|
const now2 = /* @__PURE__ */ new Date();
|
|
798
|
-
|
|
810
|
+
localStorage.setItem(
|
|
799
811
|
this.storageKey,
|
|
800
812
|
JSON.stringify({
|
|
801
813
|
...res2.data,
|
|
802
814
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
803
815
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
804
|
-
})
|
|
805
|
-
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
816
|
+
})
|
|
806
817
|
);
|
|
807
818
|
return {
|
|
808
819
|
ok: true,
|
|
@@ -816,14 +827,13 @@ var SessionManagerCookie = class {
|
|
|
816
827
|
const res2 = await this.authService.createSession(input, version);
|
|
817
828
|
if (res2.ok) {
|
|
818
829
|
const now2 = /* @__PURE__ */ new Date();
|
|
819
|
-
|
|
830
|
+
localStorage.setItem(
|
|
820
831
|
this.storageKey,
|
|
821
832
|
JSON.stringify({
|
|
822
833
|
...res2.data,
|
|
823
834
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
824
835
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
825
|
-
})
|
|
826
|
-
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
836
|
+
})
|
|
827
837
|
);
|
|
828
838
|
return {
|
|
829
839
|
ok: true,
|
|
@@ -843,14 +853,13 @@ var SessionManagerCookie = class {
|
|
|
843
853
|
};
|
|
844
854
|
}
|
|
845
855
|
const now = /* @__PURE__ */ new Date();
|
|
846
|
-
|
|
856
|
+
localStorage.setItem(
|
|
847
857
|
this.storageKey,
|
|
848
858
|
JSON.stringify({
|
|
849
859
|
...res.data,
|
|
850
860
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
851
861
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
852
|
-
})
|
|
853
|
-
{}
|
|
862
|
+
})
|
|
854
863
|
);
|
|
855
864
|
return {
|
|
856
865
|
ok: true,
|
|
@@ -862,18 +871,15 @@ var SessionManagerCookie = class {
|
|
|
862
871
|
if (res.ok) {
|
|
863
872
|
const now = /* @__PURE__ */ new Date();
|
|
864
873
|
if (this.isServer) {
|
|
865
|
-
this.logger.warn("'
|
|
874
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
866
875
|
} else {
|
|
867
|
-
|
|
876
|
+
localStorage.setItem(
|
|
868
877
|
this.storageKey,
|
|
869
878
|
JSON.stringify({
|
|
870
879
|
...res.data,
|
|
871
880
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
872
881
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
873
|
-
})
|
|
874
|
-
{
|
|
875
|
-
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
876
|
-
}
|
|
882
|
+
})
|
|
877
883
|
);
|
|
878
884
|
}
|
|
879
885
|
return { ok: true };
|
|
@@ -883,7 +889,7 @@ var SessionManagerCookie = class {
|
|
|
883
889
|
}
|
|
884
890
|
async get() {
|
|
885
891
|
if (this.isServer) {
|
|
886
|
-
this.logger.warn("'
|
|
892
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
887
893
|
return {
|
|
888
894
|
ok: true,
|
|
889
895
|
data: null
|
|
@@ -893,7 +899,7 @@ var SessionManagerCookie = class {
|
|
|
893
899
|
await sleep(1e3);
|
|
894
900
|
return await this.get();
|
|
895
901
|
}
|
|
896
|
-
const val =
|
|
902
|
+
const val = localStorage.getItem(this.storageKey);
|
|
897
903
|
if (!val) {
|
|
898
904
|
return {
|
|
899
905
|
ok: true,
|
|
@@ -907,7 +913,7 @@ var SessionManagerCookie = class {
|
|
|
907
913
|
const refreshTokenExpiresAt = new Date(obj.refreshTokenExpiresAt);
|
|
908
914
|
if (isAfter(now, refreshTokenExpiresAt)) {
|
|
909
915
|
this.logger.warn("Session expired. Logging out..");
|
|
910
|
-
|
|
916
|
+
localStorage.removeItem(this.storageKey);
|
|
911
917
|
return {
|
|
912
918
|
ok: false,
|
|
913
919
|
error: {
|
|
@@ -924,7 +930,7 @@ var SessionManagerCookie = class {
|
|
|
924
930
|
if (!res.ok) {
|
|
925
931
|
this.logger.error(`Failed to refresh session: ${res.error.message}`);
|
|
926
932
|
if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
|
|
927
|
-
|
|
933
|
+
localStorage.removeItem(this.storageKey);
|
|
928
934
|
return {
|
|
929
935
|
ok: false,
|
|
930
936
|
error: res.error
|
|
@@ -945,9 +951,7 @@ var SessionManagerCookie = class {
|
|
|
945
951
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
946
952
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
947
953
|
};
|
|
948
|
-
|
|
949
|
-
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
950
|
-
});
|
|
954
|
+
localStorage.setItem(this.storageKey, JSON.stringify(obj));
|
|
951
955
|
}
|
|
952
956
|
return {
|
|
953
957
|
ok: true,
|
|
@@ -965,13 +969,13 @@ var SessionManagerCookie = class {
|
|
|
965
969
|
}
|
|
966
970
|
async refresh() {
|
|
967
971
|
if (this.isServer) {
|
|
968
|
-
this.logger.warn("'
|
|
972
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
969
973
|
return {
|
|
970
974
|
ok: true,
|
|
971
975
|
data: null
|
|
972
976
|
};
|
|
973
977
|
}
|
|
974
|
-
const val =
|
|
978
|
+
const val = localStorage.getItem(this.storageKey);
|
|
975
979
|
if (!val) {
|
|
976
980
|
return {
|
|
977
981
|
ok: true,
|
|
@@ -988,7 +992,7 @@ var SessionManagerCookie = class {
|
|
|
988
992
|
if (!res.ok) {
|
|
989
993
|
this.logger.error(`Failed to refresh session: ${res.error.message}`);
|
|
990
994
|
if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
|
|
991
|
-
|
|
995
|
+
localStorage.removeItem(this.storageKey);
|
|
992
996
|
return {
|
|
993
997
|
ok: false,
|
|
994
998
|
error: res.error
|
|
@@ -1009,9 +1013,7 @@ var SessionManagerCookie = class {
|
|
|
1009
1013
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
1010
1014
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
1011
1015
|
};
|
|
1012
|
-
|
|
1013
|
-
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
1014
|
-
});
|
|
1016
|
+
localStorage.setItem(this.storageKey, JSON.stringify(obj));
|
|
1015
1017
|
return {
|
|
1016
1018
|
ok: true,
|
|
1017
1019
|
data: obj
|
|
@@ -1028,18 +1030,18 @@ var SessionManagerCookie = class {
|
|
|
1028
1030
|
}
|
|
1029
1031
|
async destroy() {
|
|
1030
1032
|
if (this.isServer) {
|
|
1031
|
-
this.logger.warn("'
|
|
1033
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
1032
1034
|
return;
|
|
1033
1035
|
}
|
|
1034
1036
|
const res = await this.get();
|
|
1035
1037
|
if (res.data?.accessToken) {
|
|
1036
1038
|
await this.authService.destroySession(res.data.accessToken);
|
|
1037
1039
|
}
|
|
1038
|
-
|
|
1040
|
+
localStorage.removeItem(this.storageKey);
|
|
1039
1041
|
}
|
|
1040
1042
|
async verify() {
|
|
1041
1043
|
if (this.isServer) {
|
|
1042
|
-
this.logger.warn("'
|
|
1044
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
1043
1045
|
return true;
|
|
1044
1046
|
}
|
|
1045
1047
|
const s = await this.get();
|
|
@@ -1049,13 +1051,13 @@ var SessionManagerCookie = class {
|
|
|
1049
1051
|
if (!s.data) return true;
|
|
1050
1052
|
const v = await this.authService.verifySession(s.data.accessToken);
|
|
1051
1053
|
if (!v) {
|
|
1052
|
-
|
|
1054
|
+
localStorage.removeItem(this.storageKey);
|
|
1053
1055
|
}
|
|
1054
1056
|
return v;
|
|
1055
1057
|
}
|
|
1056
1058
|
get onMaya() {
|
|
1057
1059
|
if (this.isServer) {
|
|
1058
|
-
this.logger.warn("'
|
|
1060
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
1059
1061
|
return false;
|
|
1060
1062
|
}
|
|
1061
1063
|
return localStorage.getItem(this.platformStorageKey) === "MAYA";
|
|
@@ -3879,6 +3881,14 @@ var Sdk = class {
|
|
|
3879
3881
|
data: res.data ? this.transformer.transform.memberWalletAccount(res.data) : null
|
|
3880
3882
|
};
|
|
3881
3883
|
}
|
|
3884
|
+
async memberLevelHistory() {
|
|
3885
|
+
const res = await this.walletService.memberLevelHistory();
|
|
3886
|
+
if (!res.ok) return res;
|
|
3887
|
+
return {
|
|
3888
|
+
ok: true,
|
|
3889
|
+
data: res.data
|
|
3890
|
+
};
|
|
3891
|
+
}
|
|
3882
3892
|
/*
|
|
3883
3893
|
*=============================================
|
|
3884
3894
|
* ANNOUNCEMENT
|