@opexa/portal-sdk 0.57.1 → 0.57.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 +112 -96
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +112 -96
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2134,8 +2134,16 @@ declare class Sdk {
|
|
|
2134
2134
|
constructor(config: SdkConfig);
|
|
2135
2135
|
private _fetch;
|
|
2136
2136
|
private _middleware;
|
|
2137
|
+
/**
|
|
2138
|
+
* @deprecated use `setFetch` instead
|
|
2139
|
+
*/
|
|
2137
2140
|
set fetch(value: typeof globalThis.fetch | null);
|
|
2141
|
+
/**
|
|
2142
|
+
* @deprecated use `getFetch` instead
|
|
2143
|
+
*/
|
|
2138
2144
|
get fetch(): typeof globalThis.fetch | null;
|
|
2145
|
+
setFetch(value: typeof globalThis.fetch | null): Promise<void>;
|
|
2146
|
+
getFetch(): typeof fetch | null;
|
|
2139
2147
|
set middleware(value: GraphQLClientMiddleware);
|
|
2140
2148
|
get middleware(): GraphQLClientMiddleware;
|
|
2141
2149
|
initWebDomain(): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -2134,8 +2134,16 @@ declare class Sdk {
|
|
|
2134
2134
|
constructor(config: SdkConfig);
|
|
2135
2135
|
private _fetch;
|
|
2136
2136
|
private _middleware;
|
|
2137
|
+
/**
|
|
2138
|
+
* @deprecated use `setFetch` instead
|
|
2139
|
+
*/
|
|
2137
2140
|
set fetch(value: typeof globalThis.fetch | null);
|
|
2141
|
+
/**
|
|
2142
|
+
* @deprecated use `getFetch` instead
|
|
2143
|
+
*/
|
|
2138
2144
|
get fetch(): typeof globalThis.fetch | null;
|
|
2145
|
+
setFetch(value: typeof globalThis.fetch | null): Promise<void>;
|
|
2146
|
+
getFetch(): typeof fetch | null;
|
|
2139
2147
|
set middleware(value: GraphQLClientMiddleware);
|
|
2140
2148
|
get middleware(): GraphQLClientMiddleware;
|
|
2141
2149
|
initWebDomain(): void;
|
package/dist/index.js
CHANGED
|
@@ -1656,9 +1656,8 @@ var MEMBER_ACCOUNT_QUERY = gql`
|
|
|
1656
1656
|
}
|
|
1657
1657
|
`;
|
|
1658
1658
|
var MEMBER_WITH_CELLXPERT_DETAILS_QUERY = gql`
|
|
1659
|
-
query
|
|
1660
|
-
|
|
1661
|
-
id
|
|
1659
|
+
query MemberAccountCelleExpertId {
|
|
1660
|
+
memberAccount: self {
|
|
1662
1661
|
... on MemberAccount {
|
|
1663
1662
|
id
|
|
1664
1663
|
cellxpertDetails {
|
|
@@ -3423,8 +3422,8 @@ var AccountService = class {
|
|
|
3423
3422
|
data: res.data.memberAccount
|
|
3424
3423
|
};
|
|
3425
3424
|
}
|
|
3426
|
-
async memberWithCellxpertDetails(
|
|
3427
|
-
const res = await this.client.request(MEMBER_WITH_CELLXPERT_DETAILS_QUERY
|
|
3425
|
+
async memberWithCellxpertDetails() {
|
|
3426
|
+
const res = await this.client.request(MEMBER_WITH_CELLXPERT_DETAILS_QUERY);
|
|
3428
3427
|
if (!res.ok) return res;
|
|
3429
3428
|
return {
|
|
3430
3429
|
ok: true,
|
|
@@ -6272,8 +6271,8 @@ function pollable(func, config) {
|
|
|
6272
6271
|
};
|
|
6273
6272
|
}
|
|
6274
6273
|
|
|
6275
|
-
// src/sdk/session-manager.ts
|
|
6276
|
-
var
|
|
6274
|
+
// src/sdk/session-manager-cookie.ts
|
|
6275
|
+
var SessionManagerCookie = class {
|
|
6277
6276
|
logger;
|
|
6278
6277
|
storageKey = "session";
|
|
6279
6278
|
platformStorageKey = "session/platform";
|
|
@@ -6284,10 +6283,6 @@ var SessionManager = class {
|
|
|
6284
6283
|
this.authService = config.authService;
|
|
6285
6284
|
this.walletService = config.walletService;
|
|
6286
6285
|
this.logger = config.logger;
|
|
6287
|
-
if (config.sessionPrefix) {
|
|
6288
|
-
this.storageKey = `${config.sessionPrefix}/${this.storageKey}`;
|
|
6289
|
-
this.platformStorageKey = `${config.sessionPrefix}/${this.platformStorageKey}`;
|
|
6290
|
-
}
|
|
6291
6286
|
}
|
|
6292
6287
|
get refreshing() {
|
|
6293
6288
|
return this._refreshing;
|
|
@@ -6296,16 +6291,6 @@ var SessionManager = class {
|
|
|
6296
6291
|
this._refreshing = value;
|
|
6297
6292
|
}
|
|
6298
6293
|
async create(input) {
|
|
6299
|
-
if (this.isServer) {
|
|
6300
|
-
this.logger.warn("'localStorage' is not available on the server.");
|
|
6301
|
-
return {
|
|
6302
|
-
ok: false,
|
|
6303
|
-
error: {
|
|
6304
|
-
name: "UnknownError",
|
|
6305
|
-
message: "Server sign in is not supported."
|
|
6306
|
-
}
|
|
6307
|
-
};
|
|
6308
|
-
}
|
|
6309
6294
|
if (input.type === "MAYA") {
|
|
6310
6295
|
localStorage.setItem(this.platformStorageKey, "MAYA");
|
|
6311
6296
|
const f0 = () => this.walletService.mayaSession({ id: input.sessionId });
|
|
@@ -6332,13 +6317,14 @@ var SessionManager = class {
|
|
|
6332
6317
|
})();
|
|
6333
6318
|
if (!r1.ok) return r1;
|
|
6334
6319
|
const now2 = /* @__PURE__ */ new Date();
|
|
6335
|
-
|
|
6320
|
+
cookies.set(
|
|
6336
6321
|
this.storageKey,
|
|
6337
6322
|
JSON.stringify({
|
|
6338
6323
|
...r1.data,
|
|
6339
6324
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
6340
6325
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
6341
|
-
})
|
|
6326
|
+
}),
|
|
6327
|
+
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
6342
6328
|
);
|
|
6343
6329
|
return {
|
|
6344
6330
|
ok: true,
|
|
@@ -6349,13 +6335,16 @@ var SessionManager = class {
|
|
|
6349
6335
|
const res2 = await this.authService.createSession(input);
|
|
6350
6336
|
if (res2.ok) {
|
|
6351
6337
|
const now2 = /* @__PURE__ */ new Date();
|
|
6352
|
-
|
|
6338
|
+
cookies.set(
|
|
6353
6339
|
this.storageKey,
|
|
6354
6340
|
JSON.stringify({
|
|
6355
6341
|
...res2.data,
|
|
6356
6342
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
6357
6343
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
6358
|
-
})
|
|
6344
|
+
}),
|
|
6345
|
+
{
|
|
6346
|
+
expires: subMinutes(addDays(now2, 30), 2).getTime()
|
|
6347
|
+
}
|
|
6359
6348
|
);
|
|
6360
6349
|
return {
|
|
6361
6350
|
ok: true,
|
|
@@ -6367,18 +6356,18 @@ var SessionManager = class {
|
|
|
6367
6356
|
if (input.type === "SOCIALS" || input.type === "TOKEN") {
|
|
6368
6357
|
const res2 = await this.authService.createSession({
|
|
6369
6358
|
type: "SOCIALS",
|
|
6370
|
-
token: input.token
|
|
6371
|
-
channel: input.channel
|
|
6359
|
+
token: input.token
|
|
6372
6360
|
});
|
|
6373
6361
|
if (res2.ok) {
|
|
6374
6362
|
const now2 = /* @__PURE__ */ new Date();
|
|
6375
|
-
|
|
6363
|
+
cookies.set(
|
|
6376
6364
|
this.storageKey,
|
|
6377
6365
|
JSON.stringify({
|
|
6378
6366
|
...res2.data,
|
|
6379
6367
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
6380
6368
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
6381
|
-
})
|
|
6369
|
+
}),
|
|
6370
|
+
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
6382
6371
|
);
|
|
6383
6372
|
return {
|
|
6384
6373
|
ok: true,
|
|
@@ -6392,13 +6381,14 @@ var SessionManager = class {
|
|
|
6392
6381
|
const res2 = await this.authService.createSession(input);
|
|
6393
6382
|
if (res2.ok) {
|
|
6394
6383
|
const now2 = /* @__PURE__ */ new Date();
|
|
6395
|
-
|
|
6384
|
+
cookies.set(
|
|
6396
6385
|
this.storageKey,
|
|
6397
6386
|
JSON.stringify({
|
|
6398
6387
|
...res2.data,
|
|
6399
6388
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
6400
6389
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
6401
|
-
})
|
|
6390
|
+
}),
|
|
6391
|
+
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
6402
6392
|
);
|
|
6403
6393
|
return {
|
|
6404
6394
|
ok: true,
|
|
@@ -6418,13 +6408,14 @@ var SessionManager = class {
|
|
|
6418
6408
|
};
|
|
6419
6409
|
}
|
|
6420
6410
|
const now = /* @__PURE__ */ new Date();
|
|
6421
|
-
|
|
6411
|
+
cookies.set(
|
|
6422
6412
|
this.storageKey,
|
|
6423
6413
|
JSON.stringify({
|
|
6424
6414
|
...res.data,
|
|
6425
6415
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
6426
6416
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
6427
|
-
})
|
|
6417
|
+
}),
|
|
6418
|
+
{}
|
|
6428
6419
|
);
|
|
6429
6420
|
return {
|
|
6430
6421
|
ok: true,
|
|
@@ -6436,15 +6427,18 @@ var SessionManager = class {
|
|
|
6436
6427
|
if (res.ok) {
|
|
6437
6428
|
const now = /* @__PURE__ */ new Date();
|
|
6438
6429
|
if (this.isServer) {
|
|
6439
|
-
this.logger.warn("'
|
|
6430
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
6440
6431
|
} else {
|
|
6441
|
-
|
|
6432
|
+
cookies.set(
|
|
6442
6433
|
this.storageKey,
|
|
6443
6434
|
JSON.stringify({
|
|
6444
6435
|
...res.data,
|
|
6445
6436
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
6446
6437
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
6447
|
-
})
|
|
6438
|
+
}),
|
|
6439
|
+
{
|
|
6440
|
+
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
6441
|
+
}
|
|
6448
6442
|
);
|
|
6449
6443
|
}
|
|
6450
6444
|
return { ok: true };
|
|
@@ -6454,7 +6448,7 @@ var SessionManager = class {
|
|
|
6454
6448
|
}
|
|
6455
6449
|
async get() {
|
|
6456
6450
|
if (this.isServer) {
|
|
6457
|
-
this.logger.warn("'
|
|
6451
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
6458
6452
|
return {
|
|
6459
6453
|
ok: true,
|
|
6460
6454
|
data: null
|
|
@@ -6464,7 +6458,7 @@ var SessionManager = class {
|
|
|
6464
6458
|
await sleep(1e3);
|
|
6465
6459
|
return await this.get();
|
|
6466
6460
|
}
|
|
6467
|
-
const val =
|
|
6461
|
+
const val = cookies.get(this.storageKey);
|
|
6468
6462
|
if (!val) {
|
|
6469
6463
|
return {
|
|
6470
6464
|
ok: true,
|
|
@@ -6478,7 +6472,7 @@ var SessionManager = class {
|
|
|
6478
6472
|
const refreshTokenExpiresAt = new Date(obj.refreshTokenExpiresAt);
|
|
6479
6473
|
if (isAfter(now, refreshTokenExpiresAt)) {
|
|
6480
6474
|
this.logger.warn("Session expired. Logging out..");
|
|
6481
|
-
|
|
6475
|
+
cookies.remove(this.storageKey);
|
|
6482
6476
|
return {
|
|
6483
6477
|
ok: false,
|
|
6484
6478
|
error: {
|
|
@@ -6495,7 +6489,7 @@ var SessionManager = class {
|
|
|
6495
6489
|
if (!res.ok) {
|
|
6496
6490
|
this.logger.error(`Failed to refresh session: ${res.error.message}`);
|
|
6497
6491
|
if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
|
|
6498
|
-
|
|
6492
|
+
cookies.remove(this.storageKey);
|
|
6499
6493
|
return {
|
|
6500
6494
|
ok: false,
|
|
6501
6495
|
error: res.error
|
|
@@ -6516,7 +6510,9 @@ var SessionManager = class {
|
|
|
6516
6510
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
6517
6511
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
6518
6512
|
};
|
|
6519
|
-
|
|
6513
|
+
cookies.set(this.storageKey, JSON.stringify(obj), {
|
|
6514
|
+
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
6515
|
+
});
|
|
6520
6516
|
}
|
|
6521
6517
|
return {
|
|
6522
6518
|
ok: true,
|
|
@@ -6534,13 +6530,13 @@ var SessionManager = class {
|
|
|
6534
6530
|
}
|
|
6535
6531
|
async refresh() {
|
|
6536
6532
|
if (this.isServer) {
|
|
6537
|
-
this.logger.warn("'
|
|
6533
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
6538
6534
|
return {
|
|
6539
6535
|
ok: true,
|
|
6540
6536
|
data: null
|
|
6541
6537
|
};
|
|
6542
6538
|
}
|
|
6543
|
-
const val =
|
|
6539
|
+
const val = cookies.get(this.storageKey);
|
|
6544
6540
|
if (!val) {
|
|
6545
6541
|
return {
|
|
6546
6542
|
ok: true,
|
|
@@ -6557,7 +6553,7 @@ var SessionManager = class {
|
|
|
6557
6553
|
if (!res.ok) {
|
|
6558
6554
|
this.logger.error(`Failed to refresh session: ${res.error.message}`);
|
|
6559
6555
|
if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
|
|
6560
|
-
|
|
6556
|
+
cookies.remove(this.storageKey);
|
|
6561
6557
|
return {
|
|
6562
6558
|
ok: false,
|
|
6563
6559
|
error: res.error
|
|
@@ -6578,7 +6574,9 @@ var SessionManager = class {
|
|
|
6578
6574
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
6579
6575
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
6580
6576
|
};
|
|
6581
|
-
|
|
6577
|
+
cookies.set(this.storageKey, JSON.stringify(obj), {
|
|
6578
|
+
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
6579
|
+
});
|
|
6582
6580
|
return {
|
|
6583
6581
|
ok: true,
|
|
6584
6582
|
data: obj
|
|
@@ -6595,18 +6593,18 @@ var SessionManager = class {
|
|
|
6595
6593
|
}
|
|
6596
6594
|
async destroy() {
|
|
6597
6595
|
if (this.isServer) {
|
|
6598
|
-
this.logger.warn("'
|
|
6596
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
6599
6597
|
return;
|
|
6600
6598
|
}
|
|
6601
6599
|
const res = await this.get();
|
|
6602
6600
|
if (res.data?.accessToken) {
|
|
6603
6601
|
await this.authService.destroySession(res.data.accessToken);
|
|
6604
6602
|
}
|
|
6605
|
-
|
|
6603
|
+
cookies.remove(this.storageKey);
|
|
6606
6604
|
}
|
|
6607
6605
|
async verify() {
|
|
6608
6606
|
if (this.isServer) {
|
|
6609
|
-
this.logger.warn("'
|
|
6607
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
6610
6608
|
return true;
|
|
6611
6609
|
}
|
|
6612
6610
|
const s = await this.get();
|
|
@@ -6616,13 +6614,13 @@ var SessionManager = class {
|
|
|
6616
6614
|
if (!s.data) return true;
|
|
6617
6615
|
const v = await this.authService.verifySession(s.data.accessToken);
|
|
6618
6616
|
if (!v) {
|
|
6619
|
-
|
|
6617
|
+
cookies.remove(this.storageKey);
|
|
6620
6618
|
}
|
|
6621
6619
|
return v;
|
|
6622
6620
|
}
|
|
6623
6621
|
get onMaya() {
|
|
6624
6622
|
if (this.isServer) {
|
|
6625
|
-
this.logger.warn("'
|
|
6623
|
+
this.logger.warn("'client cookies' is not available on the server.");
|
|
6626
6624
|
return false;
|
|
6627
6625
|
}
|
|
6628
6626
|
return localStorage.getItem(this.platformStorageKey) === "MAYA";
|
|
@@ -6638,7 +6636,9 @@ var SessionManager = class {
|
|
|
6638
6636
|
return typeof window === "undefined";
|
|
6639
6637
|
}
|
|
6640
6638
|
};
|
|
6641
|
-
|
|
6639
|
+
|
|
6640
|
+
// src/sdk/session-manager.ts
|
|
6641
|
+
var SessionManager = class {
|
|
6642
6642
|
logger;
|
|
6643
6643
|
storageKey = "session";
|
|
6644
6644
|
platformStorageKey = "session/platform";
|
|
@@ -6649,6 +6649,10 @@ var SessionManagerCookie = class {
|
|
|
6649
6649
|
this.authService = config.authService;
|
|
6650
6650
|
this.walletService = config.walletService;
|
|
6651
6651
|
this.logger = config.logger;
|
|
6652
|
+
if (config.sessionPrefix) {
|
|
6653
|
+
this.storageKey = `${config.sessionPrefix}/${this.storageKey}`;
|
|
6654
|
+
this.platformStorageKey = `${config.sessionPrefix}/${this.platformStorageKey}`;
|
|
6655
|
+
}
|
|
6652
6656
|
}
|
|
6653
6657
|
get refreshing() {
|
|
6654
6658
|
return this._refreshing;
|
|
@@ -6657,6 +6661,16 @@ var SessionManagerCookie = class {
|
|
|
6657
6661
|
this._refreshing = value;
|
|
6658
6662
|
}
|
|
6659
6663
|
async create(input) {
|
|
6664
|
+
if (this.isServer) {
|
|
6665
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
6666
|
+
return {
|
|
6667
|
+
ok: false,
|
|
6668
|
+
error: {
|
|
6669
|
+
name: "UnknownError",
|
|
6670
|
+
message: "Server sign in is not supported."
|
|
6671
|
+
}
|
|
6672
|
+
};
|
|
6673
|
+
}
|
|
6660
6674
|
if (input.type === "MAYA") {
|
|
6661
6675
|
localStorage.setItem(this.platformStorageKey, "MAYA");
|
|
6662
6676
|
const f0 = () => this.walletService.mayaSession({ id: input.sessionId });
|
|
@@ -6683,14 +6697,13 @@ var SessionManagerCookie = class {
|
|
|
6683
6697
|
})();
|
|
6684
6698
|
if (!r1.ok) return r1;
|
|
6685
6699
|
const now2 = /* @__PURE__ */ new Date();
|
|
6686
|
-
|
|
6700
|
+
localStorage.setItem(
|
|
6687
6701
|
this.storageKey,
|
|
6688
6702
|
JSON.stringify({
|
|
6689
6703
|
...r1.data,
|
|
6690
6704
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
6691
6705
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
6692
|
-
})
|
|
6693
|
-
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
6706
|
+
})
|
|
6694
6707
|
);
|
|
6695
6708
|
return {
|
|
6696
6709
|
ok: true,
|
|
@@ -6701,16 +6714,13 @@ var SessionManagerCookie = class {
|
|
|
6701
6714
|
const res2 = await this.authService.createSession(input);
|
|
6702
6715
|
if (res2.ok) {
|
|
6703
6716
|
const now2 = /* @__PURE__ */ new Date();
|
|
6704
|
-
|
|
6717
|
+
localStorage.setItem(
|
|
6705
6718
|
this.storageKey,
|
|
6706
6719
|
JSON.stringify({
|
|
6707
6720
|
...res2.data,
|
|
6708
6721
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
6709
6722
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
6710
|
-
})
|
|
6711
|
-
{
|
|
6712
|
-
expires: subMinutes(addDays(now2, 30), 2).getTime()
|
|
6713
|
-
}
|
|
6723
|
+
})
|
|
6714
6724
|
);
|
|
6715
6725
|
return {
|
|
6716
6726
|
ok: true,
|
|
@@ -6722,18 +6732,18 @@ var SessionManagerCookie = class {
|
|
|
6722
6732
|
if (input.type === "SOCIALS" || input.type === "TOKEN") {
|
|
6723
6733
|
const res2 = await this.authService.createSession({
|
|
6724
6734
|
type: "SOCIALS",
|
|
6725
|
-
token: input.token
|
|
6735
|
+
token: input.token,
|
|
6736
|
+
channel: input.channel
|
|
6726
6737
|
});
|
|
6727
6738
|
if (res2.ok) {
|
|
6728
6739
|
const now2 = /* @__PURE__ */ new Date();
|
|
6729
|
-
|
|
6740
|
+
localStorage.setItem(
|
|
6730
6741
|
this.storageKey,
|
|
6731
6742
|
JSON.stringify({
|
|
6732
6743
|
...res2.data,
|
|
6733
6744
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
6734
6745
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
6735
|
-
})
|
|
6736
|
-
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
6746
|
+
})
|
|
6737
6747
|
);
|
|
6738
6748
|
return {
|
|
6739
6749
|
ok: true,
|
|
@@ -6747,14 +6757,13 @@ var SessionManagerCookie = class {
|
|
|
6747
6757
|
const res2 = await this.authService.createSession(input);
|
|
6748
6758
|
if (res2.ok) {
|
|
6749
6759
|
const now2 = /* @__PURE__ */ new Date();
|
|
6750
|
-
|
|
6760
|
+
localStorage.setItem(
|
|
6751
6761
|
this.storageKey,
|
|
6752
6762
|
JSON.stringify({
|
|
6753
6763
|
...res2.data,
|
|
6754
6764
|
accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
|
|
6755
6765
|
refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
|
|
6756
|
-
})
|
|
6757
|
-
{ expires: subMinutes(addDays(now2, 30), 2).getTime() }
|
|
6766
|
+
})
|
|
6758
6767
|
);
|
|
6759
6768
|
return {
|
|
6760
6769
|
ok: true,
|
|
@@ -6774,14 +6783,13 @@ var SessionManagerCookie = class {
|
|
|
6774
6783
|
};
|
|
6775
6784
|
}
|
|
6776
6785
|
const now = /* @__PURE__ */ new Date();
|
|
6777
|
-
|
|
6786
|
+
localStorage.setItem(
|
|
6778
6787
|
this.storageKey,
|
|
6779
6788
|
JSON.stringify({
|
|
6780
6789
|
...res.data,
|
|
6781
6790
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
6782
6791
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
6783
|
-
})
|
|
6784
|
-
{}
|
|
6792
|
+
})
|
|
6785
6793
|
);
|
|
6786
6794
|
return {
|
|
6787
6795
|
ok: true,
|
|
@@ -6793,18 +6801,15 @@ var SessionManagerCookie = class {
|
|
|
6793
6801
|
if (res.ok) {
|
|
6794
6802
|
const now = /* @__PURE__ */ new Date();
|
|
6795
6803
|
if (this.isServer) {
|
|
6796
|
-
this.logger.warn("'
|
|
6804
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
6797
6805
|
} else {
|
|
6798
|
-
|
|
6806
|
+
localStorage.setItem(
|
|
6799
6807
|
this.storageKey,
|
|
6800
6808
|
JSON.stringify({
|
|
6801
6809
|
...res.data,
|
|
6802
6810
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
6803
6811
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
6804
|
-
})
|
|
6805
|
-
{
|
|
6806
|
-
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
6807
|
-
}
|
|
6812
|
+
})
|
|
6808
6813
|
);
|
|
6809
6814
|
}
|
|
6810
6815
|
return { ok: true };
|
|
@@ -6814,7 +6819,7 @@ var SessionManagerCookie = class {
|
|
|
6814
6819
|
}
|
|
6815
6820
|
async get() {
|
|
6816
6821
|
if (this.isServer) {
|
|
6817
|
-
this.logger.warn("'
|
|
6822
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
6818
6823
|
return {
|
|
6819
6824
|
ok: true,
|
|
6820
6825
|
data: null
|
|
@@ -6824,7 +6829,7 @@ var SessionManagerCookie = class {
|
|
|
6824
6829
|
await sleep(1e3);
|
|
6825
6830
|
return await this.get();
|
|
6826
6831
|
}
|
|
6827
|
-
const val =
|
|
6832
|
+
const val = localStorage.getItem(this.storageKey);
|
|
6828
6833
|
if (!val) {
|
|
6829
6834
|
return {
|
|
6830
6835
|
ok: true,
|
|
@@ -6838,7 +6843,7 @@ var SessionManagerCookie = class {
|
|
|
6838
6843
|
const refreshTokenExpiresAt = new Date(obj.refreshTokenExpiresAt);
|
|
6839
6844
|
if (isAfter(now, refreshTokenExpiresAt)) {
|
|
6840
6845
|
this.logger.warn("Session expired. Logging out..");
|
|
6841
|
-
|
|
6846
|
+
localStorage.removeItem(this.storageKey);
|
|
6842
6847
|
return {
|
|
6843
6848
|
ok: false,
|
|
6844
6849
|
error: {
|
|
@@ -6855,7 +6860,7 @@ var SessionManagerCookie = class {
|
|
|
6855
6860
|
if (!res.ok) {
|
|
6856
6861
|
this.logger.error(`Failed to refresh session: ${res.error.message}`);
|
|
6857
6862
|
if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
|
|
6858
|
-
|
|
6863
|
+
localStorage.removeItem(this.storageKey);
|
|
6859
6864
|
return {
|
|
6860
6865
|
ok: false,
|
|
6861
6866
|
error: res.error
|
|
@@ -6876,9 +6881,7 @@ var SessionManagerCookie = class {
|
|
|
6876
6881
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
6877
6882
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
6878
6883
|
};
|
|
6879
|
-
|
|
6880
|
-
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
6881
|
-
});
|
|
6884
|
+
localStorage.setItem(this.storageKey, JSON.stringify(obj));
|
|
6882
6885
|
}
|
|
6883
6886
|
return {
|
|
6884
6887
|
ok: true,
|
|
@@ -6896,13 +6899,13 @@ var SessionManagerCookie = class {
|
|
|
6896
6899
|
}
|
|
6897
6900
|
async refresh() {
|
|
6898
6901
|
if (this.isServer) {
|
|
6899
|
-
this.logger.warn("'
|
|
6902
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
6900
6903
|
return {
|
|
6901
6904
|
ok: true,
|
|
6902
6905
|
data: null
|
|
6903
6906
|
};
|
|
6904
6907
|
}
|
|
6905
|
-
const val =
|
|
6908
|
+
const val = localStorage.getItem(this.storageKey);
|
|
6906
6909
|
if (!val) {
|
|
6907
6910
|
return {
|
|
6908
6911
|
ok: true,
|
|
@@ -6919,7 +6922,7 @@ var SessionManagerCookie = class {
|
|
|
6919
6922
|
if (!res.ok) {
|
|
6920
6923
|
this.logger.error(`Failed to refresh session: ${res.error.message}`);
|
|
6921
6924
|
if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
|
|
6922
|
-
|
|
6925
|
+
localStorage.removeItem(this.storageKey);
|
|
6923
6926
|
return {
|
|
6924
6927
|
ok: false,
|
|
6925
6928
|
error: res.error
|
|
@@ -6940,9 +6943,7 @@ var SessionManagerCookie = class {
|
|
|
6940
6943
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
6941
6944
|
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
6942
6945
|
};
|
|
6943
|
-
|
|
6944
|
-
expires: subMinutes(addDays(now, 30), 2).getTime()
|
|
6945
|
-
});
|
|
6946
|
+
localStorage.setItem(this.storageKey, JSON.stringify(obj));
|
|
6946
6947
|
return {
|
|
6947
6948
|
ok: true,
|
|
6948
6949
|
data: obj
|
|
@@ -6959,18 +6960,18 @@ var SessionManagerCookie = class {
|
|
|
6959
6960
|
}
|
|
6960
6961
|
async destroy() {
|
|
6961
6962
|
if (this.isServer) {
|
|
6962
|
-
this.logger.warn("'
|
|
6963
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
6963
6964
|
return;
|
|
6964
6965
|
}
|
|
6965
6966
|
const res = await this.get();
|
|
6966
6967
|
if (res.data?.accessToken) {
|
|
6967
6968
|
await this.authService.destroySession(res.data.accessToken);
|
|
6968
6969
|
}
|
|
6969
|
-
|
|
6970
|
+
localStorage.removeItem(this.storageKey);
|
|
6970
6971
|
}
|
|
6971
6972
|
async verify() {
|
|
6972
6973
|
if (this.isServer) {
|
|
6973
|
-
this.logger.warn("'
|
|
6974
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
6974
6975
|
return true;
|
|
6975
6976
|
}
|
|
6976
6977
|
const s = await this.get();
|
|
@@ -6980,13 +6981,13 @@ var SessionManagerCookie = class {
|
|
|
6980
6981
|
if (!s.data) return true;
|
|
6981
6982
|
const v = await this.authService.verifySession(s.data.accessToken);
|
|
6982
6983
|
if (!v) {
|
|
6983
|
-
|
|
6984
|
+
localStorage.removeItem(this.storageKey);
|
|
6984
6985
|
}
|
|
6985
6986
|
return v;
|
|
6986
6987
|
}
|
|
6987
6988
|
get onMaya() {
|
|
6988
6989
|
if (this.isServer) {
|
|
6989
|
-
this.logger.warn("'
|
|
6990
|
+
this.logger.warn("'localStorage' is not available on the server.");
|
|
6990
6991
|
return false;
|
|
6991
6992
|
}
|
|
6992
6993
|
return localStorage.getItem(this.platformStorageKey) === "MAYA";
|
|
@@ -8697,7 +8698,7 @@ var Sdk = class {
|
|
|
8697
8698
|
url: cmsPortalUrl,
|
|
8698
8699
|
site,
|
|
8699
8700
|
platform: sitePlatform,
|
|
8700
|
-
fetch: this.
|
|
8701
|
+
fetch: this.getFetch()
|
|
8701
8702
|
}));
|
|
8702
8703
|
this._fetch = config.fetch ?? null;
|
|
8703
8704
|
this._middleware = config.middleware ?? ((req) => req);
|
|
@@ -8709,7 +8710,7 @@ var Sdk = class {
|
|
|
8709
8710
|
this.miscMiddleware,
|
|
8710
8711
|
this.middleware
|
|
8711
8712
|
],
|
|
8712
|
-
fetch: this.
|
|
8713
|
+
fetch: this.getFetch(),
|
|
8713
8714
|
fetchOptions: {
|
|
8714
8715
|
headers: {
|
|
8715
8716
|
Role: "MEMBER",
|
|
@@ -8789,12 +8790,27 @@ var Sdk = class {
|
|
|
8789
8790
|
}
|
|
8790
8791
|
_fetch = null;
|
|
8791
8792
|
_middleware;
|
|
8793
|
+
/**
|
|
8794
|
+
* @deprecated use `setFetch` instead
|
|
8795
|
+
*/
|
|
8792
8796
|
set fetch(value) {
|
|
8793
8797
|
this._fetch = value;
|
|
8794
8798
|
}
|
|
8799
|
+
/**
|
|
8800
|
+
* @deprecated use `getFetch` instead
|
|
8801
|
+
*/
|
|
8795
8802
|
get fetch() {
|
|
8796
8803
|
return this._fetch;
|
|
8797
8804
|
}
|
|
8805
|
+
async setFetch(value) {
|
|
8806
|
+
return new Promise((resolve) => {
|
|
8807
|
+
this._fetch = value;
|
|
8808
|
+
setTimeout(() => resolve(), 1);
|
|
8809
|
+
});
|
|
8810
|
+
}
|
|
8811
|
+
getFetch() {
|
|
8812
|
+
return this._fetch;
|
|
8813
|
+
}
|
|
8798
8814
|
set middleware(value) {
|
|
8799
8815
|
this._middleware = value;
|
|
8800
8816
|
}
|
|
@@ -9189,7 +9205,7 @@ var Sdk = class {
|
|
|
9189
9205
|
};
|
|
9190
9206
|
}
|
|
9191
9207
|
async memberWithCellxpertDetails() {
|
|
9192
|
-
const res = await this.accountService.memberWithCellxpertDetails(
|
|
9208
|
+
const res = await this.accountService.memberWithCellxpertDetails();
|
|
9193
9209
|
if (!res.ok) return res;
|
|
9194
9210
|
return {
|
|
9195
9211
|
ok: true,
|