@opexa/portal-sdk 0.27.0 → 0.28.0

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 CHANGED
@@ -4233,6 +4233,7 @@ function pollable(func, config) {
4233
4233
  var SessionManager = class {
4234
4234
  logger;
4235
4235
  storageKey = "session";
4236
+ platformStorageKey = "session/platform";
4236
4237
  authService;
4237
4238
  walletService;
4238
4239
  _refreshing = false;
@@ -4259,6 +4260,7 @@ var SessionManager = class {
4259
4260
  };
4260
4261
  }
4261
4262
  if (input.type === "MAYA") {
4263
+ localStorage.setItem(this.platformStorageKey, "MAYA");
4262
4264
  const f0 = () => this.walletService.mayaSession({ id: input.sessionId });
4263
4265
  const r0 = await pollable(f0, {
4264
4266
  until: (r) => r.ok && r.data?.member != null,
@@ -4338,6 +4340,7 @@ var SessionManager = class {
4338
4340
  return res2;
4339
4341
  }
4340
4342
  if (input.type === "CABINET") {
4343
+ localStorage.setItem(this.platformStorageKey, "CABINET");
4341
4344
  const res2 = await this.authService.createSession(input);
4342
4345
  if (res2.ok) {
4343
4346
  const now2 = /* @__PURE__ */ new Date();
@@ -4508,6 +4511,20 @@ var SessionManager = class {
4508
4511
  }
4509
4512
  return v;
4510
4513
  }
4514
+ get onMaya() {
4515
+ if (this.isServer) {
4516
+ this.logger.warn("'localStorage' is not available on the server.");
4517
+ return false;
4518
+ }
4519
+ return localStorage.getItem(this.platformStorageKey) === "MAYA";
4520
+ }
4521
+ get onCabinet() {
4522
+ if (this.isServer) {
4523
+ this.logger.warn("'localStorage' is not available on the server.");
4524
+ return false;
4525
+ }
4526
+ return localStorage.getItem(this.platformStorageKey) === "CABINET";
4527
+ }
4511
4528
  get isServer() {
4512
4529
  return typeof window === "undefined";
4513
4530
  }
@@ -5469,6 +5486,7 @@ var Sdk = class {
5469
5486
  transformer;
5470
5487
  logger;
5471
5488
  cache;
5489
+ config;
5472
5490
  constructor(config) {
5473
5491
  const {
5474
5492
  /**/
@@ -5555,6 +5573,13 @@ var Sdk = class {
5555
5573
  this.sessionManager = sessionManager;
5556
5574
  this.cmsPortalService = cmsPortalService;
5557
5575
  this.cache = new Cache();
5576
+ this.config = {
5577
+ environment,
5578
+ site,
5579
+ platform,
5580
+ sitePlatform,
5581
+ logs
5582
+ };
5558
5583
  }
5559
5584
  /*
5560
5585
  *=============================================
@@ -5614,6 +5639,14 @@ var Sdk = class {
5614
5639
  */
5615
5640
  get domainMiddleware() {
5616
5641
  return async (request) => {
5642
+ if (this.sessionManager.onMaya) {
5643
+ request.headers.append("Domain", `maya/${this.config.platform}`);
5644
+ return request;
5645
+ }
5646
+ if (this.sessionManager.onCabinet) {
5647
+ request.headers.delete("Domain");
5648
+ return request;
5649
+ }
5617
5650
  const domain = this.domainManager.domain;
5618
5651
  if (domain) request.headers.append("Domain", domain);
5619
5652
  return request;
@@ -5744,6 +5777,8 @@ var Sdk = class {
5744
5777
  ok: true,
5745
5778
  data: res.data ? {
5746
5779
  id: res.data.session.id,
5780
+ maya: this.sessionManager.onMaya,
5781
+ cabinet: this.sessionManager.onCabinet,
5747
5782
  dateTimeCreated: new Date(res.data.session.dateTimeCreated)
5748
5783
  } : null
5749
5784
  };