@saasquatch/component-environment 1.0.10 → 1.0.11-1

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.js CHANGED
@@ -554,10 +554,14 @@ function _getInitialValue() {
554
554
  };
555
555
  case "SquatchPortal":
556
556
  const searchParams = new URLSearchParams(document.location.search);
557
- if (searchParams.has("jwt")) {
558
- return userIdentityFromJwt(searchParams.get("jwt"));
559
- }
560
557
  const stored = localStorage.getItem(USER_CONTEXT_NAME);
558
+ console.log({ stored });
559
+ if (searchParams.has("jwt") && !stored) {
560
+ const identity = userIdentityFromJwt(searchParams.get("jwt"));
561
+ localStorage.setItem(USER_CONTEXT_NAME, JSON.stringify(identity));
562
+ console.log({ storedIdentity: identity });
563
+ return identity;
564
+ }
561
565
  if (!stored)
562
566
  return void 0;
563
567
  try {
@@ -584,6 +588,7 @@ function setUserIdentity(identity) {
584
588
  if (identity && getEnvironmentSDK().type === "SquatchPortal") {
585
589
  localStorage.setItem(USER_CONTEXT_NAME, JSON.stringify(identity));
586
590
  } else if (!identity) {
591
+ console.log("removing user identity from local storage");
587
592
  localStorage.removeItem(USER_CONTEXT_NAME);
588
593
  }
589
594
  }
package/dist/index.mjs CHANGED
@@ -505,10 +505,14 @@ function _getInitialValue() {
505
505
  };
506
506
  case "SquatchPortal":
507
507
  const searchParams = new URLSearchParams(document.location.search);
508
- if (searchParams.has("jwt")) {
509
- return userIdentityFromJwt(searchParams.get("jwt"));
510
- }
511
508
  const stored = localStorage.getItem(USER_CONTEXT_NAME);
509
+ console.log({ stored });
510
+ if (searchParams.has("jwt") && !stored) {
511
+ const identity = userIdentityFromJwt(searchParams.get("jwt"));
512
+ localStorage.setItem(USER_CONTEXT_NAME, JSON.stringify(identity));
513
+ console.log({ storedIdentity: identity });
514
+ return identity;
515
+ }
512
516
  if (!stored)
513
517
  return void 0;
514
518
  try {
@@ -535,6 +539,7 @@ function setUserIdentity(identity) {
535
539
  if (identity && getEnvironmentSDK().type === "SquatchPortal") {
536
540
  localStorage.setItem(USER_CONTEXT_NAME, JSON.stringify(identity));
537
541
  } else if (!identity) {
542
+ console.log("removing user identity from local storage");
538
543
  localStorage.removeItem(USER_CONTEXT_NAME);
539
544
  }
540
545
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saasquatch/component-environment",
3
- "version": "1.0.10",
3
+ "version": "1.0.11-1",
4
4
  "description": "Environment and contexts for SaaSquatch components",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",