@privy-io/js-sdk-core 0.9.0 → 0.9.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
@@ -1879,7 +1879,7 @@ class $99761f88b99b6cb6$export$2e2bcd8739ae039 {
1879
1879
 
1880
1880
 
1881
1881
  var $af98a8a573bb7c25$exports = {};
1882
- $af98a8a573bb7c25$exports = JSON.parse('{"name":"@privy-io/js-sdk-core","version":"0.9.0","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/**/*.test.ts\\"","test:ci":"npm run test","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.4","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"}}');
1882
+ $af98a8a573bb7c25$exports = JSON.parse('{"name":"@privy-io/js-sdk-core","version":"0.9.1","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/**/*.test.ts\\"","test:ci":"npm run test","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.4","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"}}');
1883
1883
 
1884
1884
 
1885
1885
 
@@ -2087,7 +2087,7 @@ class $5945f4703f62befa$export$9e80c3751b841788 {
2087
2087
  * DO NOT USE DIRECTLY: use `this.#getOrGenerateClientAnalyticsId()` instead
2088
2088
  *
2089
2089
  * Can't be readonly since we set async outside of the constructor
2090
- */ #clientId;
2090
+ */ #_clientId;
2091
2091
  /** Should get overriden by wrapping libraries */ #sdkVersion;
2092
2092
  #fetch;
2093
2093
  /**
@@ -2106,7 +2106,7 @@ class $5945f4703f62befa$export$9e80c3751b841788 {
2106
2106
  this.baseUrl = o.baseUrl ?? $5945f4703f62befa$var$DEFAULT_PRIVY_API_URL;
2107
2107
  this.appId = o.appId;
2108
2108
  this.#storage = o.storage;
2109
- this.#clientId = null;
2109
+ this.#_clientId = null;
2110
2110
  this.#sdkVersion = o.sdkVersion ?? this.#sdkVersion;
2111
2111
  this.callbacks = o.callbacks;
2112
2112
  // If the sdk is being used in a non-browser environment,
@@ -2175,7 +2175,8 @@ class $5945f4703f62befa$export$9e80c3751b841788 {
2175
2175
  headers.set("Authorization", `Bearer ${token}`);
2176
2176
  headers.set("Content-Type", "application/json");
2177
2177
  headers.set("Accept", "application/json");
2178
- headers.set("privy-ca-id", await this.#getOrGenerateClientAnalyticsId());
2178
+ const caid = await this.#getOrGenerateClientAnalyticsId();
2179
+ if (caid) headers.set("privy-ca-id", caid);
2179
2180
  if (this.nativeAppIdentifier) headers.set("x-native-app-identifier", this.nativeAppIdentifier);
2180
2181
  return {
2181
2182
  // 20 second tmeout on all requests, same as react-auth
@@ -2214,22 +2215,28 @@ class $5945f4703f62befa$export$9e80c3751b841788 {
2214
2215
  // If the client analytics ID is not set, generate a new one and store it
2215
2216
  // in storage if possible.
2216
2217
  async #getOrGenerateClientAnalyticsId() {
2217
- if (this.#clientId) return this.#clientId;
2218
+ if (this.#_clientId) return this.#_clientId;
2218
2219
  try {
2219
2220
  const clientAnalyticsId = await this.#storage.get($5945f4703f62befa$var$CLIENT_ANALYTICS_ID_KEY);
2220
2221
  if (typeof clientAnalyticsId === "string" && clientAnalyticsId.length > 0) {
2221
- this.#clientId = clientAnalyticsId;
2222
+ this.#_clientId = clientAnalyticsId;
2222
2223
  return clientAnalyticsId;
2223
2224
  }
2224
- } catch (e) {}
2225
- const clientAnalyticsId = (0, $bwzhE$uuid.v4)();
2226
- this.#clientId = clientAnalyticsId;
2225
+ } catch (e) {
2226
+ console.error("Unable to load clientId", e);
2227
+ }
2228
+ try {
2229
+ this.#_clientId = (0, $bwzhE$uuid.v4)();
2230
+ } catch (e) {
2231
+ console.error("Unable to generate uuidv4", e);
2232
+ }
2233
+ if (!this.#_clientId) return null;
2227
2234
  try {
2228
- await this.#storage.put($5945f4703f62befa$var$CLIENT_ANALYTICS_ID_KEY, clientAnalyticsId);
2229
- return clientAnalyticsId;
2235
+ await this.#storage.put($5945f4703f62befa$var$CLIENT_ANALYTICS_ID_KEY, this.#_clientId);
2230
2236
  } catch (e) {
2231
- return clientAnalyticsId;
2237
+ console.error(`Unable to store clientId: ${this.#_clientId}`, e);
2232
2238
  }
2239
+ return this.#_clientId;
2233
2240
  }
2234
2241
  /**
2235
2242
  * Create analytics event
package/dist/index.mjs CHANGED
@@ -1846,7 +1846,7 @@ class $a3295537bbaaa670$export$2e2bcd8739ae039 {
1846
1846
 
1847
1847
 
1848
1848
  var $53a9b3651331d972$exports = {};
1849
- $53a9b3651331d972$exports = JSON.parse('{"name":"@privy-io/js-sdk-core","version":"0.9.0","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/**/*.test.ts\\"","test:ci":"npm run test","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.4","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"}}');
1849
+ $53a9b3651331d972$exports = JSON.parse('{"name":"@privy-io/js-sdk-core","version":"0.9.1","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/**/*.test.ts\\"","test:ci":"npm run test","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.4","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"}}');
1850
1850
 
1851
1851
 
1852
1852
 
@@ -2054,7 +2054,7 @@ class $83ff42e2a0f1e24a$export$9e80c3751b841788 {
2054
2054
  * DO NOT USE DIRECTLY: use `this.#getOrGenerateClientAnalyticsId()` instead
2055
2055
  *
2056
2056
  * Can't be readonly since we set async outside of the constructor
2057
- */ #clientId;
2057
+ */ #_clientId;
2058
2058
  /** Should get overriden by wrapping libraries */ #sdkVersion;
2059
2059
  #fetch;
2060
2060
  /**
@@ -2073,7 +2073,7 @@ class $83ff42e2a0f1e24a$export$9e80c3751b841788 {
2073
2073
  this.baseUrl = o.baseUrl ?? $83ff42e2a0f1e24a$var$DEFAULT_PRIVY_API_URL;
2074
2074
  this.appId = o.appId;
2075
2075
  this.#storage = o.storage;
2076
- this.#clientId = null;
2076
+ this.#_clientId = null;
2077
2077
  this.#sdkVersion = o.sdkVersion ?? this.#sdkVersion;
2078
2078
  this.callbacks = o.callbacks;
2079
2079
  // If the sdk is being used in a non-browser environment,
@@ -2142,7 +2142,8 @@ class $83ff42e2a0f1e24a$export$9e80c3751b841788 {
2142
2142
  headers.set("Authorization", `Bearer ${token}`);
2143
2143
  headers.set("Content-Type", "application/json");
2144
2144
  headers.set("Accept", "application/json");
2145
- headers.set("privy-ca-id", await this.#getOrGenerateClientAnalyticsId());
2145
+ const caid = await this.#getOrGenerateClientAnalyticsId();
2146
+ if (caid) headers.set("privy-ca-id", caid);
2146
2147
  if (this.nativeAppIdentifier) headers.set("x-native-app-identifier", this.nativeAppIdentifier);
2147
2148
  return {
2148
2149
  // 20 second tmeout on all requests, same as react-auth
@@ -2181,22 +2182,28 @@ class $83ff42e2a0f1e24a$export$9e80c3751b841788 {
2181
2182
  // If the client analytics ID is not set, generate a new one and store it
2182
2183
  // in storage if possible.
2183
2184
  async #getOrGenerateClientAnalyticsId() {
2184
- if (this.#clientId) return this.#clientId;
2185
+ if (this.#_clientId) return this.#_clientId;
2185
2186
  try {
2186
2187
  const clientAnalyticsId = await this.#storage.get($83ff42e2a0f1e24a$var$CLIENT_ANALYTICS_ID_KEY);
2187
2188
  if (typeof clientAnalyticsId === "string" && clientAnalyticsId.length > 0) {
2188
- this.#clientId = clientAnalyticsId;
2189
+ this.#_clientId = clientAnalyticsId;
2189
2190
  return clientAnalyticsId;
2190
2191
  }
2191
- } catch (e) {}
2192
- const clientAnalyticsId = (0, $kxB2R$v4)();
2193
- this.#clientId = clientAnalyticsId;
2192
+ } catch (e) {
2193
+ console.error("Unable to load clientId", e);
2194
+ }
2195
+ try {
2196
+ this.#_clientId = (0, $kxB2R$v4)();
2197
+ } catch (e) {
2198
+ console.error("Unable to generate uuidv4", e);
2199
+ }
2200
+ if (!this.#_clientId) return null;
2194
2201
  try {
2195
- await this.#storage.put($83ff42e2a0f1e24a$var$CLIENT_ANALYTICS_ID_KEY, clientAnalyticsId);
2196
- return clientAnalyticsId;
2202
+ await this.#storage.put($83ff42e2a0f1e24a$var$CLIENT_ANALYTICS_ID_KEY, this.#_clientId);
2197
2203
  } catch (e) {
2198
- return clientAnalyticsId;
2204
+ console.error(`Unable to store clientId: ${this.#_clientId}`, e);
2199
2205
  }
2206
+ return this.#_clientId;
2200
2207
  }
2201
2208
  /**
2202
2209
  * Create analytics event
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@privy-io/js-sdk-core",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "Vanilla JS client for the Privy Auth API",
5
5
  "keywords": [
6
6
  "authentication",