@opexa/portal-sdk 0.54.3 → 0.54.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 +133 -94
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +133 -94
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -104,7 +104,7 @@ interface AnnouncementsQueryVariables {
|
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
106
|
type GameType$1 = 'SLOTS' | 'SPORTS' | 'FISHING' | 'BINGO' | 'LIVE' | 'GAMES' | 'TABLE' | 'SPECIALTY' | 'NUMERICAL' | 'NUMERIC' | 'ARCADE';
|
|
107
|
-
type GameProvider$1 = 'JILI' | 'JILI_BINGO' | 'PGSOFT' | 'FACHAI' | 'BTI' | 'DG' | 'PLAYTECH' | 'E2E' | 'ONEAPI_EVOLUTION' | 'EVOLUTION' | 'EVOLUTION_NETENT' | 'EVOLUTION_REDTIGER' | 'MEGABALL' | 'MEGA2SPIN' | 'DARWIN' | 'RTG' | 'DRBINGO' | 'HOLLYWOODTV' | 'CQ9' | 'JDB' | 'HABANERO' | 'DIGITAIN' | 'SPINIX' | 'JOKER' | 'HACKSAW' | 'EVOLUTIONNETENT' | 'JDBGTF' | 'JDBSPRIBE' | 'MICROGAMING' | 'RELAXGAMING' | 'EVOPLAY' | 'BOOONGO' | 'BGAMING' | 'KINGMAKER' | 'KINGMIDAS' | 'YELLOWBAT' | 'ETENGJUE' | 'SABA' | 'PRAGMATICPLAY' | 'SPRIBE' | 'EZUGI' | 'ALIZE' | 'NO_LIMIT_CITY' | 'BIG_TIME_GAMING' | 'SAGAMING' | 'ONEAPI_SPADEGAMING' | 'JK8' | 'TEST' | 'RUBYPLAY' | 'ORTIZ';
|
|
107
|
+
type GameProvider$1 = 'JILI' | 'JILI_BINGO' | 'PGSOFT' | 'FACHAI' | 'BTI' | 'DG' | 'PLAYTECH' | 'E2E' | 'ONEAPI_EVOLUTION' | 'EVOLUTION' | 'EVOLUTION_NETENT' | 'EVOLUTION_REDTIGER' | 'MEGABALL' | 'MEGA2SPIN' | 'DARWIN' | 'RTG' | 'DRBINGO' | 'HOLLYWOODTV' | 'CQ9' | 'JDB' | 'HABANERO' | 'DIGITAIN' | 'SPINIX' | 'JOKER' | 'HACKSAW' | 'EVOLUTIONNETENT' | 'JDBGTF' | 'JDBSPRIBE' | 'MICROGAMING' | 'RELAXGAMING' | 'EVOPLAY' | 'BOOONGO' | 'BGAMING' | 'KINGMAKER' | 'KINGMIDAS' | 'YELLOWBAT' | 'ETENGJUE' | 'SABA' | 'PRAGMATICPLAY' | 'SPRIBE' | 'EZUGI' | 'ALIZE' | 'NO_LIMIT_CITY' | 'BIG_TIME_GAMING' | 'SAGAMING' | 'ONEAPI_SPADEGAMING' | 'JK8' | 'TEST' | 'RUBYPLAY' | 'ORTIZ' | 'ONEAPI_SUPERBULLGAMING';
|
|
108
108
|
type GameTag$1 = 'HOT' | 'hot' | 'NEW' | 'new' | 'TOP' | 'top' | 'POPULAR' | 'popular' | 'VIRTUAL' | 'virtual' | (string & {});
|
|
109
109
|
interface GamesQueryVariables {
|
|
110
110
|
after?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -104,7 +104,7 @@ interface AnnouncementsQueryVariables {
|
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
106
|
type GameType$1 = 'SLOTS' | 'SPORTS' | 'FISHING' | 'BINGO' | 'LIVE' | 'GAMES' | 'TABLE' | 'SPECIALTY' | 'NUMERICAL' | 'NUMERIC' | 'ARCADE';
|
|
107
|
-
type GameProvider$1 = 'JILI' | 'JILI_BINGO' | 'PGSOFT' | 'FACHAI' | 'BTI' | 'DG' | 'PLAYTECH' | 'E2E' | 'ONEAPI_EVOLUTION' | 'EVOLUTION' | 'EVOLUTION_NETENT' | 'EVOLUTION_REDTIGER' | 'MEGABALL' | 'MEGA2SPIN' | 'DARWIN' | 'RTG' | 'DRBINGO' | 'HOLLYWOODTV' | 'CQ9' | 'JDB' | 'HABANERO' | 'DIGITAIN' | 'SPINIX' | 'JOKER' | 'HACKSAW' | 'EVOLUTIONNETENT' | 'JDBGTF' | 'JDBSPRIBE' | 'MICROGAMING' | 'RELAXGAMING' | 'EVOPLAY' | 'BOOONGO' | 'BGAMING' | 'KINGMAKER' | 'KINGMIDAS' | 'YELLOWBAT' | 'ETENGJUE' | 'SABA' | 'PRAGMATICPLAY' | 'SPRIBE' | 'EZUGI' | 'ALIZE' | 'NO_LIMIT_CITY' | 'BIG_TIME_GAMING' | 'SAGAMING' | 'ONEAPI_SPADEGAMING' | 'JK8' | 'TEST' | 'RUBYPLAY' | 'ORTIZ';
|
|
107
|
+
type GameProvider$1 = 'JILI' | 'JILI_BINGO' | 'PGSOFT' | 'FACHAI' | 'BTI' | 'DG' | 'PLAYTECH' | 'E2E' | 'ONEAPI_EVOLUTION' | 'EVOLUTION' | 'EVOLUTION_NETENT' | 'EVOLUTION_REDTIGER' | 'MEGABALL' | 'MEGA2SPIN' | 'DARWIN' | 'RTG' | 'DRBINGO' | 'HOLLYWOODTV' | 'CQ9' | 'JDB' | 'HABANERO' | 'DIGITAIN' | 'SPINIX' | 'JOKER' | 'HACKSAW' | 'EVOLUTIONNETENT' | 'JDBGTF' | 'JDBSPRIBE' | 'MICROGAMING' | 'RELAXGAMING' | 'EVOPLAY' | 'BOOONGO' | 'BGAMING' | 'KINGMAKER' | 'KINGMIDAS' | 'YELLOWBAT' | 'ETENGJUE' | 'SABA' | 'PRAGMATICPLAY' | 'SPRIBE' | 'EZUGI' | 'ALIZE' | 'NO_LIMIT_CITY' | 'BIG_TIME_GAMING' | 'SAGAMING' | 'ONEAPI_SPADEGAMING' | 'JK8' | 'TEST' | 'RUBYPLAY' | 'ORTIZ' | 'ONEAPI_SUPERBULLGAMING';
|
|
108
108
|
type GameTag$1 = 'HOT' | 'hot' | 'NEW' | 'new' | 'TOP' | 'top' | 'POPULAR' | 'popular' | 'VIRTUAL' | 'virtual' | (string & {});
|
|
109
109
|
interface GamesQueryVariables {
|
|
110
110
|
after?: string;
|
package/dist/index.js
CHANGED
|
@@ -1556,7 +1556,7 @@ gql`
|
|
|
1556
1556
|
}
|
|
1557
1557
|
}
|
|
1558
1558
|
`;
|
|
1559
|
-
var
|
|
1559
|
+
var MEMBER_ACCOUNT_QUERY_DEVELOPMENT = gql`
|
|
1560
1560
|
query MemberAccount {
|
|
1561
1561
|
memberAccount: self {
|
|
1562
1562
|
... on MemberAccount {
|
|
@@ -1596,6 +1596,42 @@ var MEMBER_ACCOUNT_QUERY = gql`
|
|
|
1596
1596
|
}
|
|
1597
1597
|
}
|
|
1598
1598
|
`;
|
|
1599
|
+
var MEMBER_ACCOUNT_QUERY = gql`
|
|
1600
|
+
query MemberAccount {
|
|
1601
|
+
memberAccount: self {
|
|
1602
|
+
... on MemberAccount {
|
|
1603
|
+
id
|
|
1604
|
+
name
|
|
1605
|
+
status
|
|
1606
|
+
realName
|
|
1607
|
+
emailAddress
|
|
1608
|
+
mobileNumber
|
|
1609
|
+
birthDay
|
|
1610
|
+
verified
|
|
1611
|
+
verificationStatus
|
|
1612
|
+
nickName
|
|
1613
|
+
validId
|
|
1614
|
+
mobileNumberVerified
|
|
1615
|
+
mobileNumberVerificationRequired
|
|
1616
|
+
currentMonthlyAchievementPoints
|
|
1617
|
+
achievementPointsLevelUpProgressPercentage
|
|
1618
|
+
currentUniqueGamesCount
|
|
1619
|
+
currentNewGamesCount
|
|
1620
|
+
currentBetsCount
|
|
1621
|
+
currentActiveDaysCount
|
|
1622
|
+
dateTimeLastLeveledUp
|
|
1623
|
+
currentMonthlyTurnover
|
|
1624
|
+
turnoverLevelUpProgressPercentage
|
|
1625
|
+
transactionPassword
|
|
1626
|
+
secretAnswerSubmitted
|
|
1627
|
+
dateTimeCreated
|
|
1628
|
+
dateTimeLastUpdated
|
|
1629
|
+
domain
|
|
1630
|
+
branchCode
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
`;
|
|
1599
1635
|
var MEMBER_VERIFICATION_QUERY = gql`
|
|
1600
1636
|
${FILE_FRAGMENT}
|
|
1601
1637
|
|
|
@@ -3045,12 +3081,16 @@ function createOperationError(code) {
|
|
|
3045
3081
|
// src/services/account.service.ts
|
|
3046
3082
|
var AccountService = class {
|
|
3047
3083
|
client;
|
|
3048
|
-
|
|
3084
|
+
environment;
|
|
3085
|
+
constructor(client, environment) {
|
|
3049
3086
|
this.client = client;
|
|
3087
|
+
this.environment = environment;
|
|
3050
3088
|
}
|
|
3051
3089
|
/** aka `Query.self` */
|
|
3052
3090
|
async memberAccount() {
|
|
3053
|
-
const res = await this.client.request(
|
|
3091
|
+
const res = await this.client.request(
|
|
3092
|
+
this.environment === "production" ? MEMBER_ACCOUNT_QUERY : MEMBER_ACCOUNT_QUERY_DEVELOPMENT
|
|
3093
|
+
);
|
|
3054
3094
|
if (!res.ok) return res;
|
|
3055
3095
|
return {
|
|
3056
3096
|
ok: true,
|
|
@@ -5665,8 +5705,8 @@ function pollable(func, config) {
|
|
|
5665
5705
|
};
|
|
5666
5706
|
}
|
|
5667
5707
|
|
|
5668
|
-
// src/sdk/session-manager
|
|
5669
|
-
var
|
|
5708
|
+
// src/sdk/session-manager.ts
|
|
5709
|
+
var SessionManager = class {
|
|
5670
5710
|
logger;
|
|
5671
5711
|
storageKey = "session";
|
|
5672
5712
|
platformStorageKey = "session/platform";
|
|
@@ -5677,6 +5717,10 @@ var SessionManagerCookie = class {
|
|
|
5677
5717
|
this.authService = config.authService;
|
|
5678
5718
|
this.walletService = config.walletService;
|
|
5679
5719
|
this.logger = config.logger;
|
|
5720
|
+
if (config.sessionPrefix) {
|
|
5721
|
+
this.storageKey = `${config.sessionPrefix}/${this.storageKey}`;
|
|
5722
|
+
this.platformStorageKey = `${config.sessionPrefix}/${this.platformStorageKey}`;
|
|
5723
|
+
}
|
|
5680
5724
|
}
|
|
5681
5725
|
get refreshing() {
|
|
5682
5726
|
return this._refreshing;
|
|
@@ -5685,6 +5729,16 @@ var SessionManagerCookie = class {
|
|
|
5685
5729
|
this._refreshing = value;
|
|
5686
5730
|
}
|
|
5687
5731
|
async create(input) {
|
|
5732
|
+
if (this.isServer) {
|
|
5733
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
5734
|
+
return {
|
|
5735
|
+
ok: false,
|
|
5736
|
+
error: {
|
|
5737
|
+
name: "UnknownError",
|
|
5738
|
+
message: "Server sign in is not supported."
|
|
5739
|
+
}
|
|
5740
|
+
};
|
|
5741
|
+
}
|
|
5688
5742
|
if (input.type === "MAYA") {
|
|
5689
5743
|
localStorage.setItem(this.platformStorageKey, "MAYA");
|
|
5690
5744
|
const f0 = () => this.walletService.mayaSession({ id: input.sessionId });
|
|
@@ -5711,14 +5765,13 @@ var SessionManagerCookie = class {
|
|
|
5711
5765
|
})();
|
|
5712
5766
|
if (!r1.ok) return r1;
|
|
5713
5767
|
const now2 = /* @__PURE__ */ new Date();
|
|
5714
|
-
|
|
5768
|
+
localStorage.setItem(
|
|
5715
5769
|
this.storageKey,
|
|
5716
5770
|
JSON.stringify({
|
|
5717
5771
|
...r1.data,
|
|
5718
5772
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5719
5773
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5720
|
-
})
|
|
5721
|
-
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
5774
|
+
})
|
|
5722
5775
|
);
|
|
5723
5776
|
return {
|
|
5724
5777
|
ok: true,
|
|
@@ -5729,16 +5782,13 @@ var SessionManagerCookie = class {
|
|
|
5729
5782
|
const res2 = await this.authService.createSession(input);
|
|
5730
5783
|
if (res2.ok) {
|
|
5731
5784
|
const now2 = /* @__PURE__ */ new Date();
|
|
5732
|
-
|
|
5785
|
+
localStorage.setItem(
|
|
5733
5786
|
this.storageKey,
|
|
5734
5787
|
JSON.stringify({
|
|
5735
5788
|
...res2.data,
|
|
5736
5789
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5737
5790
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5738
|
-
})
|
|
5739
|
-
{
|
|
5740
|
-
expires: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5741
|
-
}
|
|
5791
|
+
})
|
|
5742
5792
|
);
|
|
5743
5793
|
return {
|
|
5744
5794
|
ok: true,
|
|
@@ -5750,18 +5800,18 @@ var SessionManagerCookie = class {
|
|
|
5750
5800
|
if (input.type === "SOCIALS" || input.type === "TOKEN") {
|
|
5751
5801
|
const res2 = await this.authService.createSession({
|
|
5752
5802
|
type: "SOCIALS",
|
|
5753
|
-
token: input.token
|
|
5803
|
+
token: input.token,
|
|
5804
|
+
channel: input.channel
|
|
5754
5805
|
});
|
|
5755
5806
|
if (res2.ok) {
|
|
5756
5807
|
const now2 = /* @__PURE__ */ new Date();
|
|
5757
|
-
|
|
5808
|
+
localStorage.setItem(
|
|
5758
5809
|
this.storageKey,
|
|
5759
5810
|
JSON.stringify({
|
|
5760
5811
|
...res2.data,
|
|
5761
5812
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5762
5813
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5763
|
-
})
|
|
5764
|
-
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
5814
|
+
})
|
|
5765
5815
|
);
|
|
5766
5816
|
return {
|
|
5767
5817
|
ok: true,
|
|
@@ -5775,14 +5825,13 @@ var SessionManagerCookie = class {
|
|
|
5775
5825
|
const res2 = await this.authService.createSession(input);
|
|
5776
5826
|
if (res2.ok) {
|
|
5777
5827
|
const now2 = /* @__PURE__ */ new Date();
|
|
5778
|
-
|
|
5828
|
+
localStorage.setItem(
|
|
5779
5829
|
this.storageKey,
|
|
5780
5830
|
JSON.stringify({
|
|
5781
5831
|
...res2.data,
|
|
5782
5832
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
5783
5833
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
5784
|
-
})
|
|
5785
|
-
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
5834
|
+
})
|
|
5786
5835
|
);
|
|
5787
5836
|
return {
|
|
5788
5837
|
ok: true,
|
|
@@ -5802,14 +5851,13 @@ var SessionManagerCookie = class {
|
|
|
5802
5851
|
};
|
|
5803
5852
|
}
|
|
5804
5853
|
const now = /* @__PURE__ */ new Date();
|
|
5805
|
-
|
|
5854
|
+
localStorage.setItem(
|
|
5806
5855
|
this.storageKey,
|
|
5807
5856
|
JSON.stringify({
|
|
5808
5857
|
...res.data,
|
|
5809
5858
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
5810
5859
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
5811
|
-
})
|
|
5812
|
-
{}
|
|
5860
|
+
})
|
|
5813
5861
|
);
|
|
5814
5862
|
return {
|
|
5815
5863
|
ok: true,
|
|
@@ -5821,18 +5869,15 @@ var SessionManagerCookie = class {
|
|
|
5821
5869
|
if (res.ok) {
|
|
5822
5870
|
const now = /* @__PURE__ */ new Date();
|
|
5823
5871
|
if (this.isServer) {
|
|
5824
|
-
this.logger.warn("'
|
|
5872
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
5825
5873
|
} else {
|
|
5826
|
-
|
|
5874
|
+
localStorage.setItem(
|
|
5827
5875
|
this.storageKey,
|
|
5828
5876
|
JSON.stringify({
|
|
5829
5877
|
...res.data,
|
|
5830
5878
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
5831
5879
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
5832
|
-
})
|
|
5833
|
-
{
|
|
5834
|
-
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
5835
|
-
}
|
|
5880
|
+
})
|
|
5836
5881
|
);
|
|
5837
5882
|
}
|
|
5838
5883
|
return { ok: true };
|
|
@@ -5842,7 +5887,7 @@ var SessionManagerCookie = class {
|
|
|
5842
5887
|
}
|
|
5843
5888
|
async get() {
|
|
5844
5889
|
if (this.isServer) {
|
|
5845
|
-
this.logger.warn("'
|
|
5890
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
5846
5891
|
return {
|
|
5847
5892
|
ok: true,
|
|
5848
5893
|
data: null
|
|
@@ -5852,7 +5897,7 @@ var SessionManagerCookie = class {
|
|
|
5852
5897
|
await sleep(1e3);
|
|
5853
5898
|
return await this.get();
|
|
5854
5899
|
}
|
|
5855
|
-
const val =
|
|
5900
|
+
const val = localStorage.getItem(this.storageKey);
|
|
5856
5901
|
if (!val) {
|
|
5857
5902
|
return {
|
|
5858
5903
|
ok: true,
|
|
@@ -5866,7 +5911,7 @@ var SessionManagerCookie = class {
|
|
|
5866
5911
|
const refreshTokenExpiresAt = new Date(obj.refreshTokenExpiresAt);
|
|
5867
5912
|
if (isAfter(now, refreshTokenExpiresAt)) {
|
|
5868
5913
|
this.logger.warn("Session expired. Logging out..");
|
|
5869
|
-
|
|
5914
|
+
localStorage.removeItem(this.storageKey);
|
|
5870
5915
|
return {
|
|
5871
5916
|
ok: false,
|
|
5872
5917
|
error: {
|
|
@@ -5883,7 +5928,7 @@ var SessionManagerCookie = class {
|
|
|
5883
5928
|
if (!res.ok) {
|
|
5884
5929
|
this.logger.error(`Failed to refresh session: ${res.error.message}`);
|
|
5885
5930
|
if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
|
|
5886
|
-
|
|
5931
|
+
localStorage.removeItem(this.storageKey);
|
|
5887
5932
|
return {
|
|
5888
5933
|
ok: false,
|
|
5889
5934
|
error: res.error
|
|
@@ -5904,9 +5949,7 @@ var SessionManagerCookie = class {
|
|
|
5904
5949
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
5905
5950
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
5906
5951
|
};
|
|
5907
|
-
|
|
5908
|
-
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
5909
|
-
});
|
|
5952
|
+
localStorage.setItem(this.storageKey, JSON.stringify(obj));
|
|
5910
5953
|
}
|
|
5911
5954
|
return {
|
|
5912
5955
|
ok: true,
|
|
@@ -5924,13 +5967,13 @@ var SessionManagerCookie = class {
|
|
|
5924
5967
|
}
|
|
5925
5968
|
async refresh() {
|
|
5926
5969
|
if (this.isServer) {
|
|
5927
|
-
this.logger.warn("'
|
|
5970
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
5928
5971
|
return {
|
|
5929
5972
|
ok: true,
|
|
5930
5973
|
data: null
|
|
5931
5974
|
};
|
|
5932
5975
|
}
|
|
5933
|
-
const val =
|
|
5976
|
+
const val = localStorage.getItem(this.storageKey);
|
|
5934
5977
|
if (!val) {
|
|
5935
5978
|
return {
|
|
5936
5979
|
ok: true,
|
|
@@ -5947,7 +5990,7 @@ var SessionManagerCookie = class {
|
|
|
5947
5990
|
if (!res.ok) {
|
|
5948
5991
|
this.logger.error(`Failed to refresh session: ${res.error.message}`);
|
|
5949
5992
|
if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
|
|
5950
|
-
|
|
5993
|
+
localStorage.removeItem(this.storageKey);
|
|
5951
5994
|
return {
|
|
5952
5995
|
ok: false,
|
|
5953
5996
|
error: res.error
|
|
@@ -5968,9 +6011,7 @@ var SessionManagerCookie = class {
|
|
|
5968
6011
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
5969
6012
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
5970
6013
|
};
|
|
5971
|
-
|
|
5972
|
-
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
5973
|
-
});
|
|
6014
|
+
localStorage.setItem(this.storageKey, JSON.stringify(obj));
|
|
5974
6015
|
return {
|
|
5975
6016
|
ok: true,
|
|
5976
6017
|
data: obj
|
|
@@ -5987,18 +6028,18 @@ var SessionManagerCookie = class {
|
|
|
5987
6028
|
}
|
|
5988
6029
|
async destroy() {
|
|
5989
6030
|
if (this.isServer) {
|
|
5990
|
-
this.logger.warn("'
|
|
6031
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
5991
6032
|
return;
|
|
5992
6033
|
}
|
|
5993
6034
|
const res = await this.get();
|
|
5994
6035
|
if (res.data?.accessToken) {
|
|
5995
6036
|
await this.authService.destroySession(res.data.accessToken);
|
|
5996
6037
|
}
|
|
5997
|
-
|
|
6038
|
+
localStorage.removeItem(this.storageKey);
|
|
5998
6039
|
}
|
|
5999
6040
|
async verify() {
|
|
6000
6041
|
if (this.isServer) {
|
|
6001
|
-
this.logger.warn("'
|
|
6042
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
6002
6043
|
return true;
|
|
6003
6044
|
}
|
|
6004
6045
|
const s = await this.get();
|
|
@@ -6008,13 +6049,13 @@ var SessionManagerCookie = class {
|
|
|
6008
6049
|
if (!s.data) return true;
|
|
6009
6050
|
const v = await this.authService.verifySession(s.data.accessToken);
|
|
6010
6051
|
if (!v) {
|
|
6011
|
-
|
|
6052
|
+
localStorage.removeItem(this.storageKey);
|
|
6012
6053
|
}
|
|
6013
6054
|
return v;
|
|
6014
6055
|
}
|
|
6015
6056
|
get onMaya() {
|
|
6016
6057
|
if (this.isServer) {
|
|
6017
|
-
this.logger.warn("'
|
|
6058
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
6018
6059
|
return false;
|
|
6019
6060
|
}
|
|
6020
6061
|
return localStorage.getItem(this.platformStorageKey) === "MAYA";
|
|
@@ -6030,9 +6071,7 @@ var SessionManagerCookie = class {
|
|
|
6030
6071
|
return typeof window === "undefined";
|
|
6031
6072
|
}
|
|
6032
6073
|
};
|
|
6033
|
-
|
|
6034
|
-
// src/sdk/session-manager.ts
|
|
6035
|
-
var SessionManager = class {
|
|
6074
|
+
var SessionManagerCookie = class {
|
|
6036
6075
|
logger;
|
|
6037
6076
|
storageKey = "session";
|
|
6038
6077
|
platformStorageKey = "session/platform";
|
|
@@ -6043,10 +6082,6 @@ var SessionManager = class {
|
|
|
6043
6082
|
this.authService = config.authService;
|
|
6044
6083
|
this.walletService = config.walletService;
|
|
6045
6084
|
this.logger = config.logger;
|
|
6046
|
-
if (config.sessionPrefix) {
|
|
6047
|
-
this.storageKey = `${config.sessionPrefix}/${this.storageKey}`;
|
|
6048
|
-
this.platformStorageKey = `${config.sessionPrefix}/${this.platformStorageKey}`;
|
|
6049
|
-
}
|
|
6050
6085
|
}
|
|
6051
6086
|
get refreshing() {
|
|
6052
6087
|
return this._refreshing;
|
|
@@ -6055,16 +6090,6 @@ var SessionManager = class {
|
|
|
6055
6090
|
this._refreshing = value;
|
|
6056
6091
|
}
|
|
6057
6092
|
async create(input) {
|
|
6058
|
-
if (this.isServer) {
|
|
6059
|
-
this.logger.warn("'localStorage' is not available on the server.");
|
|
6060
|
-
return {
|
|
6061
|
-
ok: false,
|
|
6062
|
-
error: {
|
|
6063
|
-
name: "UnknownError",
|
|
6064
|
-
message: "Server sign in is not supported."
|
|
6065
|
-
}
|
|
6066
|
-
};
|
|
6067
|
-
}
|
|
6068
6093
|
if (input.type === "MAYA") {
|
|
6069
6094
|
localStorage.setItem(this.platformStorageKey, "MAYA");
|
|
6070
6095
|
const f0 = () => this.walletService.mayaSession({ id: input.sessionId });
|
|
@@ -6091,13 +6116,14 @@ var SessionManager = class {
|
|
|
6091
6116
|
})();
|
|
6092
6117
|
if (!r1.ok) return r1;
|
|
6093
6118
|
const now2 = /* @__PURE__ */ new Date();
|
|
6094
|
-
|
|
6119
|
+
cookies.set(
|
|
6095
6120
|
this.storageKey,
|
|
6096
6121
|
JSON.stringify({
|
|
6097
6122
|
...r1.data,
|
|
6098
6123
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
6099
6124
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
6100
|
-
})
|
|
6125
|
+
}),
|
|
6126
|
+
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
6101
6127
|
);
|
|
6102
6128
|
return {
|
|
6103
6129
|
ok: true,
|
|
@@ -6108,13 +6134,16 @@ var SessionManager = class {
|
|
|
6108
6134
|
const res2 = await this.authService.createSession(input);
|
|
6109
6135
|
if (res2.ok) {
|
|
6110
6136
|
const now2 = /* @__PURE__ */ new Date();
|
|
6111
|
-
|
|
6137
|
+
cookies.set(
|
|
6112
6138
|
this.storageKey,
|
|
6113
6139
|
JSON.stringify({
|
|
6114
6140
|
...res2.data,
|
|
6115
6141
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
6116
6142
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
6117
|
-
})
|
|
6143
|
+
}),
|
|
6144
|
+
{
|
|
6145
|
+
expires: subMinutes(addDays(now2, 30), 2).getTime()
|
|
6146
|
+
}
|
|
6118
6147
|
);
|
|
6119
6148
|
return {
|
|
6120
6149
|
ok: true,
|
|
@@ -6126,18 +6155,18 @@ var SessionManager = class {
|
|
|
6126
6155
|
if (input.type === "SOCIALS" || input.type === "TOKEN") {
|
|
6127
6156
|
const res2 = await this.authService.createSession({
|
|
6128
6157
|
type: "SOCIALS",
|
|
6129
|
-
token: input.token
|
|
6130
|
-
channel: input.channel
|
|
6158
|
+
token: input.token
|
|
6131
6159
|
});
|
|
6132
6160
|
if (res2.ok) {
|
|
6133
6161
|
const now2 = /* @__PURE__ */ new Date();
|
|
6134
|
-
|
|
6162
|
+
cookies.set(
|
|
6135
6163
|
this.storageKey,
|
|
6136
6164
|
JSON.stringify({
|
|
6137
6165
|
...res2.data,
|
|
6138
6166
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
6139
6167
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
6140
|
-
})
|
|
6168
|
+
}),
|
|
6169
|
+
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
6141
6170
|
);
|
|
6142
6171
|
return {
|
|
6143
6172
|
ok: true,
|
|
@@ -6151,13 +6180,14 @@ var SessionManager = class {
|
|
|
6151
6180
|
const res2 = await this.authService.createSession(input);
|
|
6152
6181
|
if (res2.ok) {
|
|
6153
6182
|
const now2 = /* @__PURE__ */ new Date();
|
|
6154
|
-
|
|
6183
|
+
cookies.set(
|
|
6155
6184
|
this.storageKey,
|
|
6156
6185
|
JSON.stringify({
|
|
6157
6186
|
...res2.data,
|
|
6158
6187
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
6159
6188
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
6160
|
-
})
|
|
6189
|
+
}),
|
|
6190
|
+
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
6161
6191
|
);
|
|
6162
6192
|
return {
|
|
6163
6193
|
ok: true,
|
|
@@ -6177,13 +6207,14 @@ var SessionManager = class {
|
|
|
6177
6207
|
};
|
|
6178
6208
|
}
|
|
6179
6209
|
const now = /* @__PURE__ */ new Date();
|
|
6180
|
-
|
|
6210
|
+
cookies.set(
|
|
6181
6211
|
this.storageKey,
|
|
6182
6212
|
JSON.stringify({
|
|
6183
6213
|
...res.data,
|
|
6184
6214
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
6185
6215
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
6186
|
-
})
|
|
6216
|
+
}),
|
|
6217
|
+
{}
|
|
6187
6218
|
);
|
|
6188
6219
|
return {
|
|
6189
6220
|
ok: true,
|
|
@@ -6195,15 +6226,18 @@ var SessionManager = class {
|
|
|
6195
6226
|
if (res.ok) {
|
|
6196
6227
|
const now = /* @__PURE__ */ new Date();
|
|
6197
6228
|
if (this.isServer) {
|
|
6198
|
-
this.logger.warn("'
|
|
6229
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
6199
6230
|
} else {
|
|
6200
|
-
|
|
6231
|
+
cookies.set(
|
|
6201
6232
|
this.storageKey,
|
|
6202
6233
|
JSON.stringify({
|
|
6203
6234
|
...res.data,
|
|
6204
6235
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
6205
6236
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
6206
|
-
})
|
|
6237
|
+
}),
|
|
6238
|
+
{
|
|
6239
|
+
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
6240
|
+
}
|
|
6207
6241
|
);
|
|
6208
6242
|
}
|
|
6209
6243
|
return { ok: true };
|
|
@@ -6213,7 +6247,7 @@ var SessionManager = class {
|
|
|
6213
6247
|
}
|
|
6214
6248
|
async get() {
|
|
6215
6249
|
if (this.isServer) {
|
|
6216
|
-
this.logger.warn("'
|
|
6250
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
6217
6251
|
return {
|
|
6218
6252
|
ok: true,
|
|
6219
6253
|
data: null
|
|
@@ -6223,7 +6257,7 @@ var SessionManager = class {
|
|
|
6223
6257
|
await sleep(1e3);
|
|
6224
6258
|
return await this.get();
|
|
6225
6259
|
}
|
|
6226
|
-
const val =
|
|
6260
|
+
const val = cookies.get(this.storageKey);
|
|
6227
6261
|
if (!val) {
|
|
6228
6262
|
return {
|
|
6229
6263
|
ok: true,
|
|
@@ -6237,7 +6271,7 @@ var SessionManager = class {
|
|
|
6237
6271
|
const refreshTokenExpiresAt = new Date(obj.refreshTokenExpiresAt);
|
|
6238
6272
|
if (isAfter(now, refreshTokenExpiresAt)) {
|
|
6239
6273
|
this.logger.warn("Session expired. Logging out..");
|
|
6240
|
-
|
|
6274
|
+
cookies.remove(this.storageKey);
|
|
6241
6275
|
return {
|
|
6242
6276
|
ok: false,
|
|
6243
6277
|
error: {
|
|
@@ -6254,7 +6288,7 @@ var SessionManager = class {
|
|
|
6254
6288
|
if (!res.ok) {
|
|
6255
6289
|
this.logger.error(`Failed to refresh session: ${res.error.message}`);
|
|
6256
6290
|
if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
|
|
6257
|
-
|
|
6291
|
+
cookies.remove(this.storageKey);
|
|
6258
6292
|
return {
|
|
6259
6293
|
ok: false,
|
|
6260
6294
|
error: res.error
|
|
@@ -6275,7 +6309,9 @@ var SessionManager = class {
|
|
|
6275
6309
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
6276
6310
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
6277
6311
|
};
|
|
6278
|
-
|
|
6312
|
+
cookies.set(this.storageKey, JSON.stringify(obj), {
|
|
6313
|
+
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
6314
|
+
});
|
|
6279
6315
|
}
|
|
6280
6316
|
return {
|
|
6281
6317
|
ok: true,
|
|
@@ -6293,13 +6329,13 @@ var SessionManager = class {
|
|
|
6293
6329
|
}
|
|
6294
6330
|
async refresh() {
|
|
6295
6331
|
if (this.isServer) {
|
|
6296
|
-
this.logger.warn("'
|
|
6332
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
6297
6333
|
return {
|
|
6298
6334
|
ok: true,
|
|
6299
6335
|
data: null
|
|
6300
6336
|
};
|
|
6301
6337
|
}
|
|
6302
|
-
const val =
|
|
6338
|
+
const val = cookies.get(this.storageKey);
|
|
6303
6339
|
if (!val) {
|
|
6304
6340
|
return {
|
|
6305
6341
|
ok: true,
|
|
@@ -6316,7 +6352,7 @@ var SessionManager = class {
|
|
|
6316
6352
|
if (!res.ok) {
|
|
6317
6353
|
this.logger.error(`Failed to refresh session: ${res.error.message}`);
|
|
6318
6354
|
if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
|
|
6319
|
-
|
|
6355
|
+
cookies.remove(this.storageKey);
|
|
6320
6356
|
return {
|
|
6321
6357
|
ok: false,
|
|
6322
6358
|
error: res.error
|
|
@@ -6337,7 +6373,9 @@ var SessionManager = class {
|
|
|
6337
6373
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
6338
6374
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
6339
6375
|
};
|
|
6340
|
-
|
|
6376
|
+
cookies.set(this.storageKey, JSON.stringify(obj), {
|
|
6377
|
+
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
6378
|
+
});
|
|
6341
6379
|
return {
|
|
6342
6380
|
ok: true,
|
|
6343
6381
|
data: obj
|
|
@@ -6354,18 +6392,18 @@ var SessionManager = class {
|
|
|
6354
6392
|
}
|
|
6355
6393
|
async destroy() {
|
|
6356
6394
|
if (this.isServer) {
|
|
6357
|
-
this.logger.warn("'
|
|
6395
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
6358
6396
|
return;
|
|
6359
6397
|
}
|
|
6360
6398
|
const res = await this.get();
|
|
6361
6399
|
if (res.data?.accessToken) {
|
|
6362
6400
|
await this.authService.destroySession(res.data.accessToken);
|
|
6363
6401
|
}
|
|
6364
|
-
|
|
6402
|
+
cookies.remove(this.storageKey);
|
|
6365
6403
|
}
|
|
6366
6404
|
async verify() {
|
|
6367
6405
|
if (this.isServer) {
|
|
6368
|
-
this.logger.warn("'
|
|
6406
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
6369
6407
|
return true;
|
|
6370
6408
|
}
|
|
6371
6409
|
const s = await this.get();
|
|
@@ -6375,13 +6413,13 @@ var SessionManager = class {
|
|
|
6375
6413
|
if (!s.data) return true;
|
|
6376
6414
|
const v = await this.authService.verifySession(s.data.accessToken);
|
|
6377
6415
|
if (!v) {
|
|
6378
|
-
|
|
6416
|
+
cookies.remove(this.storageKey);
|
|
6379
6417
|
}
|
|
6380
6418
|
return v;
|
|
6381
6419
|
}
|
|
6382
6420
|
get onMaya() {
|
|
6383
6421
|
if (this.isServer) {
|
|
6384
|
-
this.logger.warn("'
|
|
6422
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
6385
6423
|
return false;
|
|
6386
6424
|
}
|
|
6387
6425
|
return localStorage.getItem(this.platformStorageKey) === "MAYA";
|
|
@@ -8048,7 +8086,8 @@ var Sdk = class {
|
|
|
8048
8086
|
new GraphQLClient(walletUrl, graphqlClientConfig)
|
|
8049
8087
|
);
|
|
8050
8088
|
const accountService = new AccountService(
|
|
8051
|
-
new GraphQLClient(accountUrl, graphqlClientConfig)
|
|
8089
|
+
new GraphQLClient(accountUrl, graphqlClientConfig),
|
|
8090
|
+
environment
|
|
8052
8091
|
);
|
|
8053
8092
|
const reportService = new ReportService(
|
|
8054
8093
|
new GraphQLClient(reportUrl, graphqlClientConfig)
|