@privy-io/js-sdk-core 0.8.2 → 0.8.3-beta-20231212163447

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
@@ -1860,7 +1860,7 @@ class $99761f88b99b6cb6$export$2e2bcd8739ae039 {
1860
1860
 
1861
1861
 
1862
1862
  var $af98a8a573bb7c25$exports = {};
1863
- $af98a8a573bb7c25$exports = JSON.parse('{"name":"@privy-io/js-sdk-core","version":"0.8.2","description":"Vanilla JS client for the Privy Auth API","keywords":["authentication","authorization","identity","privacy","privy","user data","web3"],"license":"Apache-2.0","source":"./src/index.ts","main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"require":"./dist/index.js","import":"./dist/index.mjs","types":"./dist/index.d.ts"}},"targets":{"main":{"isLibrary":true,"sourceMap":false},"module":{"isLibrary":true,"sourceMap":false}},"files":["dist/**/*","LICENSE","README.md"],"scripts":{"build":"npx parcel build --no-cache","clean":"rm -rf dist .turbo","dev":"npx parcel watch -p 1234","test":"jest --testMatch \\"**/test/unit/**/*.test.ts\\"","test:ci":"npm run test","test-integration":"jest --testMatch \\"**/test/integration/**/*.test.ts\\"","lint":"eslint \\"src/**/*.{ts,tsx,js,jsx}\\" && npx tsc --noEmit","format":"eslint \\"src/**/*.{ts,tsx,js,jsx}\\" --fix"},"devDependencies":{"@privy-io/tsconfig":"*","@privy-io/parcel-config":"*","@tsconfig/node16-strictest-esm":"^1.0.3","@types/text-encoding":"^0.0.37","parcel":"2.10.1"},"dependencies":{"@ethersproject/providers":"^5.7.2","@privy-io/public-api":"*","eventemitter3":"^5.0.1","fetch-retry":"^5.0.6","jose":"^4.11.2","js-cookie":"^3.0.5","text-encoding":"^0.7.0","uuid":">=8 <10"},"author":"privy.io","browserslist":["defaults","node >= 18","not op_mini all"],"publishConfig":{"access":"public"}}');
1863
+ $af98a8a573bb7c25$exports = JSON.parse('{"name":"@privy-io/js-sdk-core","version":"0.8.2","description":"Vanilla JS client for the Privy Auth API","keywords":["authentication","authorization","identity","privacy","privy","user data","web3"],"license":"Apache-2.0","source":"./src/index.ts","main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"require":"./dist/index.js","import":"./dist/index.mjs","types":"./dist/index.d.ts"}},"targets":{"main":{"isLibrary":true,"sourceMap":false},"module":{"isLibrary":true,"sourceMap":false}},"files":["dist/**/*","LICENSE","README.md"],"scripts":{"build":"npx parcel build --no-cache","clean":"rm -rf dist .turbo","dev":"npx parcel watch -p 1234","test":"jest --testMatch \\"**/test/unit/**/*.test.ts\\"","test:ci":"npm run test","test-integration":"jest --testMatch \\"**/test/integration/**/*.test.ts\\"","lint":"eslint \\"src/**/*.{ts,tsx,js,jsx}\\" && npx tsc --noEmit","format":"eslint \\"src/**/*.{ts,tsx,js,jsx}\\" --fix"},"devDependencies":{"@privy-io/tsconfig":"*","@privy-io/parcel-config":"*","@tsconfig/node16-strictest-esm":"^1.0.3","@types/text-encoding":"^0.0.37","parcel":"2.10.1"},"dependencies":{"@ethersproject/providers":"^5.7.2","@privy-io/public-api":"1.4.2","eventemitter3":"^5.0.1","fetch-retry":"^5.0.6","jose":"^4.11.2","js-cookie":"^3.0.5","text-encoding":"^0.7.0","uuid":">=8 <10"},"author":"privy.io","browserslist":["defaults","node >= 18","not op_mini all"],"publishConfig":{"access":"public"}}');
1864
1864
 
1865
1865
 
1866
1866
 
@@ -2059,6 +2059,9 @@ var $6e80017c879d5d9d$export$2e2bcd8739ae039 = $6e80017c879d5d9d$var$toAbortSign
2059
2059
 
2060
2060
 
2061
2061
  const $5945f4703f62befa$var$DEFAULT_PRIVY_API_URL = "https://auth.privy.io";
2062
+ function $5945f4703f62befa$var$isAuthError(error) {
2063
+ return typeof error === "object" && error.code && error.message;
2064
+ }
2062
2065
  class $5945f4703f62befa$export$9e80c3751b841788 {
2063
2066
  #storage;
2064
2067
  #clientId;
@@ -2146,7 +2149,7 @@ class $5945f4703f62befa$export$9e80c3751b841788 {
2146
2149
  headers.set("Accept", "application/json");
2147
2150
  if (this.nativeAppIdentifier) headers.set("x-native-app-identifier", this.nativeAppIdentifier);
2148
2151
  return {
2149
- signal: (0, $6e80017c879d5d9d$export$2e2bcd8739ae039)(3000),
2152
+ signal: (0, $6e80017c879d5d9d$export$2e2bcd8739ae039)(5000),
2150
2153
  headers: headers,
2151
2154
  credentials: "include"
2152
2155
  };
@@ -2214,9 +2217,8 @@ class $5945f4703f62befa$export$9e80c3751b841788 {
2214
2217
  this.callbacks?.setUser(res.user);
2215
2218
  return res;
2216
2219
  } catch (error) {
2217
- // If session cannot be refreshed with current refreshToken, clear local auth state
2218
- // otherwise this will result in a loop that is only escapable by clearing storage
2219
- // in userland
2220
+ if ($5945f4703f62befa$var$isAuthError(error) && error.code === "missing_or_invalid_token") // If session cannot be refreshed with current refreshToken, clear local auth state
2221
+ // otherwise this will result in a loop that is only escapable by clearing storage in userland
2220
2222
  this.session.destroyLocalState();
2221
2223
  throw error;
2222
2224
  }
@@ -2227,7 +2229,6 @@ class $5945f4703f62befa$export$9e80c3751b841788 {
2227
2229
  this.session.hasRefreshCredentials(),
2228
2230
  this.session.hasActiveToken()
2229
2231
  ]);
2230
- // If we have a token and we don't have an active token and we have refresh credentials
2231
2232
  if (existingToken && !activeToken && refreshCreds) try {
2232
2233
  const { token: token } = await this.refreshSession();
2233
2234
  return token;
package/dist/index.mjs CHANGED
@@ -1823,7 +1823,7 @@ class $a3295537bbaaa670$export$2e2bcd8739ae039 {
1823
1823
 
1824
1824
 
1825
1825
  var $53a9b3651331d972$exports = {};
1826
- $53a9b3651331d972$exports = JSON.parse('{"name":"@privy-io/js-sdk-core","version":"0.8.2","description":"Vanilla JS client for the Privy Auth API","keywords":["authentication","authorization","identity","privacy","privy","user data","web3"],"license":"Apache-2.0","source":"./src/index.ts","main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"require":"./dist/index.js","import":"./dist/index.mjs","types":"./dist/index.d.ts"}},"targets":{"main":{"isLibrary":true,"sourceMap":false},"module":{"isLibrary":true,"sourceMap":false}},"files":["dist/**/*","LICENSE","README.md"],"scripts":{"build":"npx parcel build --no-cache","clean":"rm -rf dist .turbo","dev":"npx parcel watch -p 1234","test":"jest --testMatch \\"**/test/unit/**/*.test.ts\\"","test:ci":"npm run test","test-integration":"jest --testMatch \\"**/test/integration/**/*.test.ts\\"","lint":"eslint \\"src/**/*.{ts,tsx,js,jsx}\\" && npx tsc --noEmit","format":"eslint \\"src/**/*.{ts,tsx,js,jsx}\\" --fix"},"devDependencies":{"@privy-io/tsconfig":"*","@privy-io/parcel-config":"*","@tsconfig/node16-strictest-esm":"^1.0.3","@types/text-encoding":"^0.0.37","parcel":"2.10.1"},"dependencies":{"@ethersproject/providers":"^5.7.2","@privy-io/public-api":"*","eventemitter3":"^5.0.1","fetch-retry":"^5.0.6","jose":"^4.11.2","js-cookie":"^3.0.5","text-encoding":"^0.7.0","uuid":">=8 <10"},"author":"privy.io","browserslist":["defaults","node >= 18","not op_mini all"],"publishConfig":{"access":"public"}}');
1826
+ $53a9b3651331d972$exports = JSON.parse('{"name":"@privy-io/js-sdk-core","version":"0.8.2","description":"Vanilla JS client for the Privy Auth API","keywords":["authentication","authorization","identity","privacy","privy","user data","web3"],"license":"Apache-2.0","source":"./src/index.ts","main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"require":"./dist/index.js","import":"./dist/index.mjs","types":"./dist/index.d.ts"}},"targets":{"main":{"isLibrary":true,"sourceMap":false},"module":{"isLibrary":true,"sourceMap":false}},"files":["dist/**/*","LICENSE","README.md"],"scripts":{"build":"npx parcel build --no-cache","clean":"rm -rf dist .turbo","dev":"npx parcel watch -p 1234","test":"jest --testMatch \\"**/test/unit/**/*.test.ts\\"","test:ci":"npm run test","test-integration":"jest --testMatch \\"**/test/integration/**/*.test.ts\\"","lint":"eslint \\"src/**/*.{ts,tsx,js,jsx}\\" && npx tsc --noEmit","format":"eslint \\"src/**/*.{ts,tsx,js,jsx}\\" --fix"},"devDependencies":{"@privy-io/tsconfig":"*","@privy-io/parcel-config":"*","@tsconfig/node16-strictest-esm":"^1.0.3","@types/text-encoding":"^0.0.37","parcel":"2.10.1"},"dependencies":{"@ethersproject/providers":"^5.7.2","@privy-io/public-api":"1.4.2","eventemitter3":"^5.0.1","fetch-retry":"^5.0.6","jose":"^4.11.2","js-cookie":"^3.0.5","text-encoding":"^0.7.0","uuid":">=8 <10"},"author":"privy.io","browserslist":["defaults","node >= 18","not op_mini all"],"publishConfig":{"access":"public"}}');
1827
1827
 
1828
1828
 
1829
1829
 
@@ -2022,6 +2022,9 @@ var $972f0079ffedc5b0$export$2e2bcd8739ae039 = $972f0079ffedc5b0$var$toAbortSign
2022
2022
 
2023
2023
 
2024
2024
  const $83ff42e2a0f1e24a$var$DEFAULT_PRIVY_API_URL = "https://auth.privy.io";
2025
+ function $83ff42e2a0f1e24a$var$isAuthError(error) {
2026
+ return typeof error === "object" && error.code && error.message;
2027
+ }
2025
2028
  class $83ff42e2a0f1e24a$export$9e80c3751b841788 {
2026
2029
  #storage;
2027
2030
  #clientId;
@@ -2109,7 +2112,7 @@ class $83ff42e2a0f1e24a$export$9e80c3751b841788 {
2109
2112
  headers.set("Accept", "application/json");
2110
2113
  if (this.nativeAppIdentifier) headers.set("x-native-app-identifier", this.nativeAppIdentifier);
2111
2114
  return {
2112
- signal: (0, $972f0079ffedc5b0$export$2e2bcd8739ae039)(3000),
2115
+ signal: (0, $972f0079ffedc5b0$export$2e2bcd8739ae039)(5000),
2113
2116
  headers: headers,
2114
2117
  credentials: "include"
2115
2118
  };
@@ -2177,9 +2180,8 @@ class $83ff42e2a0f1e24a$export$9e80c3751b841788 {
2177
2180
  this.callbacks?.setUser(res.user);
2178
2181
  return res;
2179
2182
  } catch (error) {
2180
- // If session cannot be refreshed with current refreshToken, clear local auth state
2181
- // otherwise this will result in a loop that is only escapable by clearing storage
2182
- // in userland
2183
+ if ($83ff42e2a0f1e24a$var$isAuthError(error) && error.code === "missing_or_invalid_token") // If session cannot be refreshed with current refreshToken, clear local auth state
2184
+ // otherwise this will result in a loop that is only escapable by clearing storage in userland
2183
2185
  this.session.destroyLocalState();
2184
2186
  throw error;
2185
2187
  }
@@ -2190,7 +2192,6 @@ class $83ff42e2a0f1e24a$export$9e80c3751b841788 {
2190
2192
  this.session.hasRefreshCredentials(),
2191
2193
  this.session.hasActiveToken()
2192
2194
  ]);
2193
- // If we have a token and we don't have an active token and we have refresh credentials
2194
2195
  if (existingToken && !activeToken && refreshCreds) try {
2195
2196
  const { token: token } = await this.refreshSession();
2196
2197
  return token;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@privy-io/js-sdk-core",
3
- "version": "0.8.2",
3
+ "version": "0.8.3-beta-20231212163447",
4
4
  "description": "Vanilla JS client for the Privy Auth API",
5
5
  "keywords": [
6
6
  "authentication",
@@ -57,7 +57,7 @@
57
57
  },
58
58
  "dependencies": {
59
59
  "@ethersproject/providers": "^5.7.2",
60
- "@privy-io/public-api": "*",
60
+ "@privy-io/public-api": "1.4.3-beta-20231212163447",
61
61
  "eventemitter3": "^5.0.1",
62
62
  "fetch-retry": "^5.0.6",
63
63
  "jose": "^4.11.2",