@opexa/portal-sdk 0.45.3 → 0.45.4

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.d.cts CHANGED
@@ -190,7 +190,7 @@ interface WithdrawalRecordsQueryVariables {
190
190
  dateTimeLastUpdated?: DateFilterField;
191
191
  };
192
192
  }
193
- type CreateWithdrawalError$1 = 'AccountNotVerifiedError' | 'InvalidTransactionPasswordError' | 'InvalidWithdrawalAmountError' | 'MobileNumberNotVerifiedError' | 'NotEnoughBalanceError' | 'WithdrawalDailyLimitExceededError' | 'ReCAPTCHAVerificationFailedError' | 'WalletDoesNotExistError';
193
+ type CreateWithdrawalError$1 = 'AccountNotVerifiedError' | 'InvalidTransactionPasswordError' | 'InvalidWithdrawalAmountError' | 'MobileNumberNotVerifiedError' | 'NotEnoughBalanceError' | 'WithdrawalDailyLimitExceededError' | 'ReCAPTCHAVerificationFailedError' | 'WalletDoesNotExistError' | 'TurnoverRequirementNotYetFulfilledError';
194
194
  interface InstapayBank$1 {
195
195
  id: string;
196
196
  name: string;
package/dist/index.d.ts CHANGED
@@ -190,7 +190,7 @@ interface WithdrawalRecordsQueryVariables {
190
190
  dateTimeLastUpdated?: DateFilterField;
191
191
  };
192
192
  }
193
- type CreateWithdrawalError$1 = 'AccountNotVerifiedError' | 'InvalidTransactionPasswordError' | 'InvalidWithdrawalAmountError' | 'MobileNumberNotVerifiedError' | 'NotEnoughBalanceError' | 'WithdrawalDailyLimitExceededError' | 'ReCAPTCHAVerificationFailedError' | 'WalletDoesNotExistError';
193
+ type CreateWithdrawalError$1 = 'AccountNotVerifiedError' | 'InvalidTransactionPasswordError' | 'InvalidWithdrawalAmountError' | 'MobileNumberNotVerifiedError' | 'NotEnoughBalanceError' | 'WithdrawalDailyLimitExceededError' | 'ReCAPTCHAVerificationFailedError' | 'WalletDoesNotExistError' | 'TurnoverRequirementNotYetFulfilledError';
194
194
  interface InstapayBank$1 {
195
195
  id: string;
196
196
  name: string;
package/dist/index.js CHANGED
@@ -397,6 +397,9 @@ var CREATE_GCASH_WITHDRAWAL_MUTATION = gql`
397
397
  ... on TransactionPasswordNotSetError {
398
398
  __typename
399
399
  }
400
+ ... on TurnoverRequirementNotYetFulfilledError {
401
+ __typename
402
+ }
400
403
  }
401
404
  }
402
405
  `;
@@ -430,6 +433,9 @@ var CREATE_GCASH_STANDARD_CASHIN_WITHDRAWAL_MUTATION = gql`
430
433
  ... on TransactionPasswordNotSetError {
431
434
  __typename
432
435
  }
436
+ ... on TurnoverRequirementNotYetFulfilledError {
437
+ __typename
438
+ }
433
439
  }
434
440
  }
435
441
  `;
@@ -454,6 +460,9 @@ var CREATE_MAYA_WITHDRAWAL_MUTATION = gql`
454
460
  ... on WithdrawalDailyLimitExceededError {
455
461
  __typename
456
462
  }
463
+ ... on TurnoverRequirementNotYetFulfilledError {
464
+ __typename
465
+ }
457
466
  }
458
467
  }
459
468
  `;
@@ -481,6 +490,9 @@ var CREATE_MAYA_APP_WITHDRAWAL_MUTATION = gql`
481
490
  ... on TransactionPasswordNotSetError {
482
491
  __typename
483
492
  }
493
+ ... on TurnoverRequirementNotYetFulfilledError {
494
+ __typename
495
+ }
484
496
  }
485
497
  }
486
498
  `;
@@ -490,6 +502,9 @@ var CREATE_BANK_WITHDRAWAL_MUTATION = gql`
490
502
  ... on MobileNumberNotVerifiedError {
491
503
  __typename
492
504
  }
505
+ ... on TurnoverRequirementNotYetFulfilledError {
506
+ __typename
507
+ }
493
508
  }
494
509
  }
495
510
  `;
@@ -519,6 +534,9 @@ var CREATE_AIO_INSTAPAY_WITHDRAWAL_MUTATION = gql`
519
534
  ... on TransactionPasswordNotSetError {
520
535
  __typename
521
536
  }
537
+ ... on TurnoverRequirementNotYetFulfilledError {
538
+ __typename
539
+ }
522
540
  }
523
541
  }
524
542
  `;
@@ -548,6 +566,9 @@ var CREATE_AIO_INSTAPAY_WITHDRAWAL_MUTATION_NEXT = gql`
548
566
  ... on TransactionPasswordNotSetError {
549
567
  __typename
550
568
  }
569
+ ... on TurnoverRequirementNotYetFulfilledError {
570
+ __typename
571
+ }
551
572
  }
552
573
  }
553
574
  `;
@@ -569,6 +590,9 @@ var CREATE_MANUAL_UPI_WITHDRAWAL_MUTATION = gql`
569
590
  ... on WalletDoesNotExistError {
570
591
  __typename
571
592
  }
593
+ ... on TurnoverRequirementNotYetFulfilledError {
594
+ __typename
595
+ }
572
596
  }
573
597
  }
574
598
  `;
@@ -592,6 +616,9 @@ var CREATE_MANUAL_BANK_WITHDRAWAL_MUTATION = gql`
592
616
  ... on WalletDoesNotExistError {
593
617
  __typename
594
618
  }
619
+ ... on TurnoverRequirementNotYetFulfilledError {
620
+ __typename
621
+ }
595
622
  }
596
623
  }
597
624
  `;
@@ -2625,7 +2652,9 @@ function createOperationError(code) {
2625
2652
  TransactionPasswordNotSetError: "Transaction password is not set",
2626
2653
  UPIReferenceNotAvailableError: "UPI reference is no longer available",
2627
2654
  GCashDirectApiRequestError: "GCash direct API request error",
2628
- VerificationDataIncompleteError: "Verification data is incomplete"
2655
+ VerificationDataIncompleteError: "Verification data is incomplete",
2656
+ TurnoverRequirementNotYetFulfilledError: "Turnover requirement not yet fulfilled",
2657
+ VerificationLockedError: "Verification is locked"
2629
2658
  };
2630
2659
  return {
2631
2660
  name: code,
@@ -5091,8 +5120,8 @@ function pollable(func, config) {
5091
5120
  };
5092
5121
  }
5093
5122
 
5094
- // src/sdk/session-manager-cookie.ts
5095
- var SessionManagerCookie = class {
5123
+ // src/sdk/session-manager.ts
5124
+ var SessionManager = class {
5096
5125
  logger;
5097
5126
  storageKey = "session";
5098
5127
  platformStorageKey = "session/platform";
@@ -5103,6 +5132,10 @@ var SessionManagerCookie = class {
5103
5132
  this.authService = config.authService;
5104
5133
  this.walletService = config.walletService;
5105
5134
  this.logger = config.logger;
5135
+ if (config.sessionPrefix) {
5136
+ this.storageKey = `${config.sessionPrefix}/${this.storageKey}`;
5137
+ this.platformStorageKey = `${config.sessionPrefix}/${this.platformStorageKey}`;
5138
+ }
5106
5139
  }
5107
5140
  get refreshing() {
5108
5141
  return this._refreshing;
@@ -5111,6 +5144,16 @@ var SessionManagerCookie = class {
5111
5144
  this._refreshing = value;
5112
5145
  }
5113
5146
  async create(input) {
5147
+ if (this.isServer) {
5148
+ this.logger.warn("'localStorage' is not available on the server.");
5149
+ return {
5150
+ ok: false,
5151
+ error: {
5152
+ name: "UnknownError",
5153
+ message: "Server sign in is not supported."
5154
+ }
5155
+ };
5156
+ }
5114
5157
  if (input.type === "MAYA") {
5115
5158
  localStorage.setItem(this.platformStorageKey, "MAYA");
5116
5159
  const f0 = () => this.walletService.mayaSession({ id: input.sessionId });
@@ -5137,14 +5180,13 @@ var SessionManagerCookie = class {
5137
5180
  })();
5138
5181
  if (!r1.ok) return r1;
5139
5182
  const now2 = /* @__PURE__ */ new Date();
5140
- cookies.set(
5183
+ localStorage.setItem(
5141
5184
  this.storageKey,
5142
5185
  JSON.stringify({
5143
5186
  ...r1.data,
5144
5187
  accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
5145
5188
  refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
5146
- }),
5147
- { expires: subMinutes(addDays(now2, 30), 2).getTime() }
5189
+ })
5148
5190
  );
5149
5191
  return {
5150
5192
  ok: true,
@@ -5155,16 +5197,13 @@ var SessionManagerCookie = class {
5155
5197
  const res2 = await this.authService.createSession(input);
5156
5198
  if (res2.ok) {
5157
5199
  const now2 = /* @__PURE__ */ new Date();
5158
- cookies.set(
5200
+ localStorage.setItem(
5159
5201
  this.storageKey,
5160
5202
  JSON.stringify({
5161
5203
  ...res2.data,
5162
5204
  accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
5163
5205
  refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
5164
- }),
5165
- {
5166
- expires: subMinutes(addDays(now2, 30), 2).getTime()
5167
- }
5206
+ })
5168
5207
  );
5169
5208
  return {
5170
5209
  ok: true,
@@ -5176,18 +5215,18 @@ var SessionManagerCookie = class {
5176
5215
  if (input.type === "SOCIALS" || input.type === "TOKEN") {
5177
5216
  const res2 = await this.authService.createSession({
5178
5217
  type: "SOCIALS",
5179
- token: input.token
5218
+ token: input.token,
5219
+ channel: input.channel
5180
5220
  });
5181
5221
  if (res2.ok) {
5182
5222
  const now2 = /* @__PURE__ */ new Date();
5183
- cookies.set(
5223
+ localStorage.setItem(
5184
5224
  this.storageKey,
5185
5225
  JSON.stringify({
5186
5226
  ...res2.data,
5187
5227
  accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
5188
5228
  refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
5189
- }),
5190
- { expires: subMinutes(addDays(now2, 30), 2).getTime() }
5229
+ })
5191
5230
  );
5192
5231
  return {
5193
5232
  ok: true,
@@ -5201,14 +5240,13 @@ var SessionManagerCookie = class {
5201
5240
  const res2 = await this.authService.createSession(input);
5202
5241
  if (res2.ok) {
5203
5242
  const now2 = /* @__PURE__ */ new Date();
5204
- cookies.set(
5243
+ localStorage.setItem(
5205
5244
  this.storageKey,
5206
5245
  JSON.stringify({
5207
5246
  ...res2.data,
5208
5247
  accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
5209
5248
  refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
5210
- }),
5211
- { expires: subMinutes(addDays(now2, 30), 2).getTime() }
5249
+ })
5212
5250
  );
5213
5251
  return {
5214
5252
  ok: true,
@@ -5228,14 +5266,13 @@ var SessionManagerCookie = class {
5228
5266
  };
5229
5267
  }
5230
5268
  const now = /* @__PURE__ */ new Date();
5231
- cookies.set(
5269
+ localStorage.setItem(
5232
5270
  this.storageKey,
5233
5271
  JSON.stringify({
5234
5272
  ...res.data,
5235
5273
  accessTokenExpiresAt: addMinutes(now, 8).getTime(),
5236
5274
  refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
5237
- }),
5238
- {}
5275
+ })
5239
5276
  );
5240
5277
  return {
5241
5278
  ok: true,
@@ -5247,18 +5284,15 @@ var SessionManagerCookie = class {
5247
5284
  if (res.ok) {
5248
5285
  const now = /* @__PURE__ */ new Date();
5249
5286
  if (this.isServer) {
5250
- this.logger.warn("'client cookies' is not available on the server.");
5287
+ this.logger.warn("'localStorage' is not available on the server.");
5251
5288
  } else {
5252
- cookies.set(
5289
+ localStorage.setItem(
5253
5290
  this.storageKey,
5254
5291
  JSON.stringify({
5255
5292
  ...res.data,
5256
5293
  accessTokenExpiresAt: addMinutes(now, 8).getTime(),
5257
5294
  refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
5258
- }),
5259
- {
5260
- expires: subMinutes(addDays(now, 30), 2).getTime()
5261
- }
5295
+ })
5262
5296
  );
5263
5297
  }
5264
5298
  return { ok: true };
@@ -5268,7 +5302,7 @@ var SessionManagerCookie = class {
5268
5302
  }
5269
5303
  async get() {
5270
5304
  if (this.isServer) {
5271
- this.logger.warn("'client cookies' is not available on the server.");
5305
+ this.logger.warn("'localStorage' is not available on the server.");
5272
5306
  return {
5273
5307
  ok: true,
5274
5308
  data: null
@@ -5278,7 +5312,7 @@ var SessionManagerCookie = class {
5278
5312
  await sleep(1e3);
5279
5313
  return await this.get();
5280
5314
  }
5281
- const val = cookies.get(this.storageKey);
5315
+ const val = localStorage.getItem(this.storageKey);
5282
5316
  if (!val) {
5283
5317
  return {
5284
5318
  ok: true,
@@ -5292,7 +5326,7 @@ var SessionManagerCookie = class {
5292
5326
  const refreshTokenExpiresAt = new Date(obj.refreshTokenExpiresAt);
5293
5327
  if (isAfter(now, refreshTokenExpiresAt)) {
5294
5328
  this.logger.warn("Session expired. Logging out..");
5295
- cookies.remove(this.storageKey);
5329
+ localStorage.removeItem(this.storageKey);
5296
5330
  return {
5297
5331
  ok: false,
5298
5332
  error: {
@@ -5309,7 +5343,7 @@ var SessionManagerCookie = class {
5309
5343
  if (!res.ok) {
5310
5344
  this.logger.error(`Failed to refresh session: ${res.error.message}`);
5311
5345
  if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
5312
- cookies.remove(this.storageKey);
5346
+ localStorage.removeItem(this.storageKey);
5313
5347
  return {
5314
5348
  ok: false,
5315
5349
  error: res.error
@@ -5330,9 +5364,7 @@ var SessionManagerCookie = class {
5330
5364
  accessTokenExpiresAt: addMinutes(now, 8).getTime(),
5331
5365
  refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
5332
5366
  };
5333
- cookies.set(this.storageKey, JSON.stringify(obj), {
5334
- expires: subMinutes(addDays(now, 30), 2).getTime()
5335
- });
5367
+ localStorage.setItem(this.storageKey, JSON.stringify(obj));
5336
5368
  }
5337
5369
  return {
5338
5370
  ok: true,
@@ -5350,13 +5382,13 @@ var SessionManagerCookie = class {
5350
5382
  }
5351
5383
  async refresh() {
5352
5384
  if (this.isServer) {
5353
- this.logger.warn("'client cookies' is not available on the server.");
5385
+ this.logger.warn("'localStorage' is not available on the server.");
5354
5386
  return {
5355
5387
  ok: true,
5356
5388
  data: null
5357
5389
  };
5358
5390
  }
5359
- const val = cookies.get(this.storageKey);
5391
+ const val = localStorage.getItem(this.storageKey);
5360
5392
  if (!val) {
5361
5393
  return {
5362
5394
  ok: true,
@@ -5373,7 +5405,7 @@ var SessionManagerCookie = class {
5373
5405
  if (!res.ok) {
5374
5406
  this.logger.error(`Failed to refresh session: ${res.error.message}`);
5375
5407
  if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
5376
- cookies.remove(this.storageKey);
5408
+ localStorage.removeItem(this.storageKey);
5377
5409
  return {
5378
5410
  ok: false,
5379
5411
  error: res.error
@@ -5394,9 +5426,7 @@ var SessionManagerCookie = class {
5394
5426
  accessTokenExpiresAt: addMinutes(now, 8).getTime(),
5395
5427
  refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
5396
5428
  };
5397
- cookies.set(this.storageKey, JSON.stringify(obj), {
5398
- expires: subMinutes(addDays(now, 30), 2).getTime()
5399
- });
5429
+ localStorage.setItem(this.storageKey, JSON.stringify(obj));
5400
5430
  return {
5401
5431
  ok: true,
5402
5432
  data: obj
@@ -5413,18 +5443,18 @@ var SessionManagerCookie = class {
5413
5443
  }
5414
5444
  async destroy() {
5415
5445
  if (this.isServer) {
5416
- this.logger.warn("'client cookies' is not available on the server.");
5446
+ this.logger.warn("'localStorage' is not available on the server.");
5417
5447
  return;
5418
5448
  }
5419
5449
  const res = await this.get();
5420
5450
  if (res.data?.accessToken) {
5421
5451
  await this.authService.destroySession(res.data.accessToken);
5422
5452
  }
5423
- cookies.remove(this.storageKey);
5453
+ localStorage.removeItem(this.storageKey);
5424
5454
  }
5425
5455
  async verify() {
5426
5456
  if (this.isServer) {
5427
- this.logger.warn("'client cookies' is not available on the server.");
5457
+ this.logger.warn("'localStorage' is not available on the server.");
5428
5458
  return true;
5429
5459
  }
5430
5460
  const s = await this.get();
@@ -5434,13 +5464,13 @@ var SessionManagerCookie = class {
5434
5464
  if (!s.data) return true;
5435
5465
  const v = await this.authService.verifySession(s.data.accessToken);
5436
5466
  if (!v) {
5437
- cookies.remove(this.storageKey);
5467
+ localStorage.removeItem(this.storageKey);
5438
5468
  }
5439
5469
  return v;
5440
5470
  }
5441
5471
  get onMaya() {
5442
5472
  if (this.isServer) {
5443
- this.logger.warn("'client cookies' is not available on the server.");
5473
+ this.logger.warn("'localStorage' is not available on the server.");
5444
5474
  return false;
5445
5475
  }
5446
5476
  return localStorage.getItem(this.platformStorageKey) === "MAYA";
@@ -5456,9 +5486,7 @@ var SessionManagerCookie = class {
5456
5486
  return typeof window === "undefined";
5457
5487
  }
5458
5488
  };
5459
-
5460
- // src/sdk/session-manager.ts
5461
- var SessionManager = class {
5489
+ var SessionManagerCookie = class {
5462
5490
  logger;
5463
5491
  storageKey = "session";
5464
5492
  platformStorageKey = "session/platform";
@@ -5469,10 +5497,6 @@ var SessionManager = class {
5469
5497
  this.authService = config.authService;
5470
5498
  this.walletService = config.walletService;
5471
5499
  this.logger = config.logger;
5472
- if (config.sessionPrefix) {
5473
- this.storageKey = `${config.sessionPrefix}/${this.storageKey}`;
5474
- this.platformStorageKey = `${config.sessionPrefix}/${this.platformStorageKey}`;
5475
- }
5476
5500
  }
5477
5501
  get refreshing() {
5478
5502
  return this._refreshing;
@@ -5481,16 +5505,6 @@ var SessionManager = class {
5481
5505
  this._refreshing = value;
5482
5506
  }
5483
5507
  async create(input) {
5484
- if (this.isServer) {
5485
- this.logger.warn("'localStorage' is not available on the server.");
5486
- return {
5487
- ok: false,
5488
- error: {
5489
- name: "UnknownError",
5490
- message: "Server sign in is not supported."
5491
- }
5492
- };
5493
- }
5494
5508
  if (input.type === "MAYA") {
5495
5509
  localStorage.setItem(this.platformStorageKey, "MAYA");
5496
5510
  const f0 = () => this.walletService.mayaSession({ id: input.sessionId });
@@ -5517,13 +5531,14 @@ var SessionManager = class {
5517
5531
  })();
5518
5532
  if (!r1.ok) return r1;
5519
5533
  const now2 = /* @__PURE__ */ new Date();
5520
- localStorage.setItem(
5534
+ cookies.set(
5521
5535
  this.storageKey,
5522
5536
  JSON.stringify({
5523
5537
  ...r1.data,
5524
5538
  accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
5525
5539
  refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
5526
- })
5540
+ }),
5541
+ { expires: subMinutes(addDays(now2, 30), 2).getTime() }
5527
5542
  );
5528
5543
  return {
5529
5544
  ok: true,
@@ -5534,13 +5549,16 @@ var SessionManager = class {
5534
5549
  const res2 = await this.authService.createSession(input);
5535
5550
  if (res2.ok) {
5536
5551
  const now2 = /* @__PURE__ */ new Date();
5537
- localStorage.setItem(
5552
+ cookies.set(
5538
5553
  this.storageKey,
5539
5554
  JSON.stringify({
5540
5555
  ...res2.data,
5541
5556
  accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
5542
5557
  refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
5543
- })
5558
+ }),
5559
+ {
5560
+ expires: subMinutes(addDays(now2, 30), 2).getTime()
5561
+ }
5544
5562
  );
5545
5563
  return {
5546
5564
  ok: true,
@@ -5552,18 +5570,18 @@ var SessionManager = class {
5552
5570
  if (input.type === "SOCIALS" || input.type === "TOKEN") {
5553
5571
  const res2 = await this.authService.createSession({
5554
5572
  type: "SOCIALS",
5555
- token: input.token,
5556
- channel: input.channel
5573
+ token: input.token
5557
5574
  });
5558
5575
  if (res2.ok) {
5559
5576
  const now2 = /* @__PURE__ */ new Date();
5560
- localStorage.setItem(
5577
+ cookies.set(
5561
5578
  this.storageKey,
5562
5579
  JSON.stringify({
5563
5580
  ...res2.data,
5564
5581
  accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
5565
5582
  refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
5566
- })
5583
+ }),
5584
+ { expires: subMinutes(addDays(now2, 30), 2).getTime() }
5567
5585
  );
5568
5586
  return {
5569
5587
  ok: true,
@@ -5577,13 +5595,14 @@ var SessionManager = class {
5577
5595
  const res2 = await this.authService.createSession(input);
5578
5596
  if (res2.ok) {
5579
5597
  const now2 = /* @__PURE__ */ new Date();
5580
- localStorage.setItem(
5598
+ cookies.set(
5581
5599
  this.storageKey,
5582
5600
  JSON.stringify({
5583
5601
  ...res2.data,
5584
5602
  accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
5585
5603
  refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
5586
- })
5604
+ }),
5605
+ { expires: subMinutes(addDays(now2, 30), 2).getTime() }
5587
5606
  );
5588
5607
  return {
5589
5608
  ok: true,
@@ -5603,13 +5622,14 @@ var SessionManager = class {
5603
5622
  };
5604
5623
  }
5605
5624
  const now = /* @__PURE__ */ new Date();
5606
- localStorage.setItem(
5625
+ cookies.set(
5607
5626
  this.storageKey,
5608
5627
  JSON.stringify({
5609
5628
  ...res.data,
5610
5629
  accessTokenExpiresAt: addMinutes(now, 8).getTime(),
5611
5630
  refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
5612
- })
5631
+ }),
5632
+ {}
5613
5633
  );
5614
5634
  return {
5615
5635
  ok: true,
@@ -5621,15 +5641,18 @@ var SessionManager = class {
5621
5641
  if (res.ok) {
5622
5642
  const now = /* @__PURE__ */ new Date();
5623
5643
  if (this.isServer) {
5624
- this.logger.warn("'localStorage' is not available on the server.");
5644
+ this.logger.warn("'client cookies' is not available on the server.");
5625
5645
  } else {
5626
- localStorage.setItem(
5646
+ cookies.set(
5627
5647
  this.storageKey,
5628
5648
  JSON.stringify({
5629
5649
  ...res.data,
5630
5650
  accessTokenExpiresAt: addMinutes(now, 8).getTime(),
5631
5651
  refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
5632
- })
5652
+ }),
5653
+ {
5654
+ expires: subMinutes(addDays(now, 30), 2).getTime()
5655
+ }
5633
5656
  );
5634
5657
  }
5635
5658
  return { ok: true };
@@ -5639,7 +5662,7 @@ var SessionManager = class {
5639
5662
  }
5640
5663
  async get() {
5641
5664
  if (this.isServer) {
5642
- this.logger.warn("'localStorage' is not available on the server.");
5665
+ this.logger.warn("'client cookies' is not available on the server.");
5643
5666
  return {
5644
5667
  ok: true,
5645
5668
  data: null
@@ -5649,7 +5672,7 @@ var SessionManager = class {
5649
5672
  await sleep(1e3);
5650
5673
  return await this.get();
5651
5674
  }
5652
- const val = localStorage.getItem(this.storageKey);
5675
+ const val = cookies.get(this.storageKey);
5653
5676
  if (!val) {
5654
5677
  return {
5655
5678
  ok: true,
@@ -5663,7 +5686,7 @@ var SessionManager = class {
5663
5686
  const refreshTokenExpiresAt = new Date(obj.refreshTokenExpiresAt);
5664
5687
  if (isAfter(now, refreshTokenExpiresAt)) {
5665
5688
  this.logger.warn("Session expired. Logging out..");
5666
- localStorage.removeItem(this.storageKey);
5689
+ cookies.remove(this.storageKey);
5667
5690
  return {
5668
5691
  ok: false,
5669
5692
  error: {
@@ -5680,7 +5703,7 @@ var SessionManager = class {
5680
5703
  if (!res.ok) {
5681
5704
  this.logger.error(`Failed to refresh session: ${res.error.message}`);
5682
5705
  if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
5683
- localStorage.removeItem(this.storageKey);
5706
+ cookies.remove(this.storageKey);
5684
5707
  return {
5685
5708
  ok: false,
5686
5709
  error: res.error
@@ -5701,7 +5724,9 @@ var SessionManager = class {
5701
5724
  accessTokenExpiresAt: addMinutes(now, 8).getTime(),
5702
5725
  refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
5703
5726
  };
5704
- localStorage.setItem(this.storageKey, JSON.stringify(obj));
5727
+ cookies.set(this.storageKey, JSON.stringify(obj), {
5728
+ expires: subMinutes(addDays(now, 30), 2).getTime()
5729
+ });
5705
5730
  }
5706
5731
  return {
5707
5732
  ok: true,
@@ -5719,13 +5744,13 @@ var SessionManager = class {
5719
5744
  }
5720
5745
  async refresh() {
5721
5746
  if (this.isServer) {
5722
- this.logger.warn("'localStorage' is not available on the server.");
5747
+ this.logger.warn("'client cookies' is not available on the server.");
5723
5748
  return {
5724
5749
  ok: true,
5725
5750
  data: null
5726
5751
  };
5727
5752
  }
5728
- const val = localStorage.getItem(this.storageKey);
5753
+ const val = cookies.get(this.storageKey);
5729
5754
  if (!val) {
5730
5755
  return {
5731
5756
  ok: true,
@@ -5742,7 +5767,7 @@ var SessionManager = class {
5742
5767
  if (!res.ok) {
5743
5768
  this.logger.error(`Failed to refresh session: ${res.error.message}`);
5744
5769
  if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
5745
- localStorage.removeItem(this.storageKey);
5770
+ cookies.remove(this.storageKey);
5746
5771
  return {
5747
5772
  ok: false,
5748
5773
  error: res.error
@@ -5763,7 +5788,9 @@ var SessionManager = class {
5763
5788
  accessTokenExpiresAt: addMinutes(now, 8).getTime(),
5764
5789
  refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
5765
5790
  };
5766
- localStorage.setItem(this.storageKey, JSON.stringify(obj));
5791
+ cookies.set(this.storageKey, JSON.stringify(obj), {
5792
+ expires: subMinutes(addDays(now, 30), 2).getTime()
5793
+ });
5767
5794
  return {
5768
5795
  ok: true,
5769
5796
  data: obj
@@ -5780,18 +5807,18 @@ var SessionManager = class {
5780
5807
  }
5781
5808
  async destroy() {
5782
5809
  if (this.isServer) {
5783
- this.logger.warn("'localStorage' is not available on the server.");
5810
+ this.logger.warn("'client cookies' is not available on the server.");
5784
5811
  return;
5785
5812
  }
5786
5813
  const res = await this.get();
5787
5814
  if (res.data?.accessToken) {
5788
5815
  await this.authService.destroySession(res.data.accessToken);
5789
5816
  }
5790
- localStorage.removeItem(this.storageKey);
5817
+ cookies.remove(this.storageKey);
5791
5818
  }
5792
5819
  async verify() {
5793
5820
  if (this.isServer) {
5794
- this.logger.warn("'localStorage' is not available on the server.");
5821
+ this.logger.warn("'client cookies' is not available on the server.");
5795
5822
  return true;
5796
5823
  }
5797
5824
  const s = await this.get();
@@ -5801,13 +5828,13 @@ var SessionManager = class {
5801
5828
  if (!s.data) return true;
5802
5829
  const v = await this.authService.verifySession(s.data.accessToken);
5803
5830
  if (!v) {
5804
- localStorage.removeItem(this.storageKey);
5831
+ cookies.remove(this.storageKey);
5805
5832
  }
5806
5833
  return v;
5807
5834
  }
5808
5835
  get onMaya() {
5809
5836
  if (this.isServer) {
5810
- this.logger.warn("'localStorage' is not available on the server.");
5837
+ this.logger.warn("'client cookies' is not available on the server.");
5811
5838
  return false;
5812
5839
  }
5813
5840
  return localStorage.getItem(this.platformStorageKey) === "MAYA";