@eluvio/elv-client-js 3.2.27 → 3.2.28

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-client-js",
3
- "version": "3.2.27",
3
+ "version": "3.2.28",
4
4
  "description": "Javascript client for the Eluvio Content Fabric",
5
5
  "main": "src/index.js",
6
6
  "author": "Kevin Talmadge",
@@ -9,6 +9,13 @@ const Ethers = require("ethers");
9
9
  const inBrowser = typeof window !== "undefined";
10
10
  const embedded = inBrowser && window.top !== window.self;
11
11
 
12
+ let localStorageAvailable = false;
13
+ try {
14
+ typeof localStorage !== "undefined" && localStorage.getItem("test");
15
+ localStorageAvailable = true;
16
+ // eslint-disable-next-line no-empty
17
+ } catch(error) {}
18
+
12
19
  /**
13
20
  * Use the <a href="#.Initialize">Initialize</a> method to initialize a new client.
14
21
  *
@@ -129,7 +136,7 @@ class ElvWalletClient {
129
136
  url.searchParams.delete("elvToken");
130
137
 
131
138
  window.history.replaceState("", "", url);
132
- } else if(storeAuthToken && typeof localStorage !== "undefined") {
139
+ } else if(storeAuthToken && localStorageAvailable) {
133
140
  try {
134
141
  // Load saved auth token
135
142
  let savedToken = localStorage.getItem(`__elv-token-${network}`);
@@ -342,7 +349,7 @@ class ElvWalletClient {
342
349
  this.cachedMarketplaces = {};
343
350
 
344
351
  // Delete saved auth token
345
- if(typeof localStorage !== "undefined") {
352
+ if(localStorageAvailable) {
346
353
  try {
347
354
  localStorage.removeItem(`__elv-token-${this.network}`);
348
355
  // eslint-disable-next-line no-empty
@@ -532,7 +539,7 @@ class ElvWalletClient {
532
539
 
533
540
  const token = this.ClientAuthToken();
534
541
 
535
- if(this.storeAuthToken && typeof localStorage !== "undefined") {
542
+ if(this.storeAuthToken && localStorageAvailable) {
536
543
  try {
537
544
  localStorage.setItem(`__elv-token-${this.network}`, token);
538
545
  // eslint-disable-next-line no-empty