@privy-io/js-sdk-core 0.56.1 → 0.56.2-beta-20251015013331

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.
@@ -1 +1 @@
1
- "use strict";var e=require("fetch-retry"),t=require("uuid"),s=require("@privy-io/api-base"),i=require("@privy-io/public-api"),r=require("../Error.js"),a=require("../Session.js"),n=require("../toAbortSignalTimeout.js"),o=require("../utils/toSearchParams.js"),h=require("./logger.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("eventemitter3"),require("jose"),require("js-cookie"),require("../Token.js"),require("../utils/allSettled.js"),require("../utils/noop.js");var c=/*#__PURE__*/l(e);let g="privy:caid";exports.PrivyInternal=class{setCallbacks(e){this.callbacks={...this.callbacks,...e}}get isReady(){return!!this._config}get config(){return this._config}get caid(){return this._analyticsId}async _initialize(){if(this.isReady)this.callbacks?.setIsReady?.(!0);else{if(!await this.isStorageAccessible())throw new r.PrivyClientError({code:"storage_error",error:"Unable to access storage"});this._config=await this.getAppConfig(),this._config?.custom_api_url&&(this.baseUrl=this._config.custom_api_url,this.session.isUsingServerCookies=!0),this.callbacks?.setIsReady?.(!0),this._sdkVersion.startsWith("react-auth:")||this.createAnalyticsEvent("sdk_initialize",{})}}getPath(e,{params:t,query:s}){return`${this.baseUrl}${i.getPathWithParams(e.path,t)}${o.toSearchParams(s)}`}async fetch(e,{body:t,params:s,query:i,headers:a,onRequest:n=this._beforeRequest.bind(this)}){let o=new Request(this.getPath(e,{params:s,query:i}),{method:e.method,body:JSON.stringify(t),headers:a}),h=await n(o),l=await this._fetch(o,h),c=await l.json();if(l.status>299)throw new r.PrivyApiError(c);return c}async _beforeRequestWithoutInitialize(e){let t=await this.session.getToken(),s=new Headers(e.headers);s.set("privy-app-id",this.appId),this.appClientId&&s.set("privy-client-id",this.appClientId),s.set("privy-client",this._sdkVersion),t&&s.set("Authorization",`Bearer ${t}`),s.set("Content-Type","application/json"),s.set("Accept","application/json");let i=await this._getOrGenerateClientAnalyticsId();return i&&s.set("privy-ca-id",i),this.nativeAppIdentifier&&s.set("x-native-app-identifier",this.nativeAppIdentifier),{signal:n.default(2e4),headers:s,credentials:"include"}}async beforeRequestWithoutRefresh(e){return await this._initialize(),this._beforeRequestWithoutInitialize(e)}async _beforeRequest(e){return await this._initialize(),await this.getAccessToken(),this.beforeRequestWithoutRefresh(e)}async getAppConfig(){return await this.fetch(i.AppConfig,{params:{app_id:this.appId},onRequest:this._beforeRequestWithoutInitialize.bind(this)})}async _getOrGenerateClientAnalyticsId(){if(this._analyticsId)return this._analyticsId;try{let e=await this._storage.get(g);if("string"==typeof e&&e.length>0)return this._analyticsId=e,e}catch(e){this.logger.error("Unable to load clientId",e)}try{this._analyticsId=t.v4()}catch(e){this.logger.error("Unable to generate uuidv4",e)}if(!this._analyticsId)return null;try{await this._storage.put(g,this._analyticsId)}catch(e){this.logger.error(`Unable to store clientId: ${this._analyticsId}`,e)}return this._analyticsId}async destroyClientAnalyticsId(){try{return await this._storage.del(g)}catch(e){this.logger.error("Unable to delete clientId",e)}}async createAnalyticsEvent(e,t){try{await this.fetch(i.AnalyticsEvent,{body:{event_name:e,client_id:await this._getOrGenerateClientAnalyticsId(),payload:t},onRequest:this.beforeRequestWithoutRefresh.bind(this)})}catch(e){}}async refreshSession(e=!1){if(!await this.isStorageAccessible())throw new r.PrivyClientError({code:"storage_error",error:"Unable to access storage"});let t=await this.session.getRefreshToken()??void 0,s=t??"key",i=this._cache.get(s);if(i)return this.logger.debug("[privy:refresh] found in-flight session refresh request, deduping"),await i;let a=this._refreshSession(t,e);this._cache.set(s,a);try{return await a}finally{this._cache.delete(s)}}async _refreshSession(e,t){let a=await this.session.getToken();if(!this.session.hasRefreshCredentials(a,e??null))throw this.logger.debug("[privy:refresh] missing tokens, skipping request"),await this._initialize(),new r.PrivyApiError({code:s.PrivyErrorCode.MISSING_OR_INVALID_TOKEN,error:"No tokens found in storage"});try{this.logger.debug(`[privy:refresh] fetching: ${i.RefreshSession.path}`);let s=await this.fetch(i.RefreshSession,{body:{refresh_token:e},onRequest:this.beforeRequestWithoutRefresh.bind(this)}),r=s.session_update_action;return this.logger.debug(`[privy:refresh] response: ${r}`),t||this.callbacks?.setUser?.(s.user),"set"===r&&(await this.session.updateWithTokensResponse(s),this.logger.debug("[privy:refresh] tokens stored")),"clear"===r&&(await this.session.destroyLocalState(),this.logger.debug("[privy:refresh] tokens cleared"),t||this.callbacks?.setUser?.(null)),"ignore"===r&&s.token&&(await this.session.storeToken(s.token),this.logger.debug("[privy:refresh] access token stored"),s.identity_token&&(this.logger.debug("[privy:refresh] identity token stored"),await this.session.storeIdentityToken(s.identity_token))),this.logger.debug("[privy:refresh] returning response"),s}catch(e){throw this.logger.debug(`[privy:refresh] error: ${e.message??"unknown error"}`),e instanceof r.PrivyApiError&&e.code===s.PrivyErrorCode.MISSING_OR_INVALID_TOKEN&&(await this.session.destroyLocalState(),t||this.callbacks?.setUser?.(null)),e}}async getAccessToken(){let[e,t]=await Promise.all([this.session.getToken(),this.session.getRefreshToken()]);if(!this.session.tokenIsActive(e)&&this.session.hasRefreshCredentials(e,t)){let t=await this.refreshSession(),s=await this.session.getToken();return t.token||this.logger.debug("[privy:getAccessToken] expected token received null"),t.token===e&&this.logger.debug("[privy:getAccessToken] expected new token in response received existing"),s===e&&this.logger.debug("[privy:getAccessToken] expected new token in storage received existing"),t.token??s}return e}async getIdentityToken(){return await this.session.getIdentityToken()}async isStorageAccessible(){try{let e=`privy:__storage__test-${t.v4()}`,s="blobby";await this._storage.put(e,s);let i=await this._storage.get(e);return await this._storage.del(e),i===s}catch(e){return this.logger.error(e),!1}}constructor(e){this._sdkVersion="js-sdk-core:0.56.1",this._cache=new Map,this.logger=h.toConsoleLogger({level:e.logLevel??"ERROR"}),this._storage=e.storage,this._analyticsId=null,this._getOrGenerateClientAnalyticsId(),this.baseUrl=e.baseUrl??"https://auth.privy.io",this.appId=e.appId,this.appClientId=e.appClientId,this._sdkVersion=e.sdkVersion??this._sdkVersion,this.callbacks=e.callbacks,this.nativeAppIdentifier=e.nativeAppIdentifier,this.session=new a.Session({storage:this._storage,isUsingServerCookies:!1,appId:e.appId}),this._fetch=c.default(globalThis.fetch,{retries:3,retryDelay:e=>3**e*500,retryOn:[408,409,425,500,502,503,504]}),this.session.on("error_storing_tokens",(e=>{this.createAnalyticsEvent("error_updating_tokens_in_storage",{reason:e})}))}};
1
+ "use strict";var e=require("fetch-retry"),t=require("uuid"),s=require("@privy-io/api-base"),i=require("@privy-io/public-api"),r=require("../Error.js"),a=require("../Session.js"),n=require("../toAbortSignalTimeout.js"),o=require("../utils/toSearchParams.js"),h=require("./logger.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("eventemitter3"),require("jose"),require("js-cookie"),require("../Token.js"),require("../utils/allSettled.js"),require("../utils/noop.js");var c=/*#__PURE__*/l(e);let g="privy:caid";exports.PrivyInternal=class{setCallbacks(e){this.callbacks={...this.callbacks,...e}}get isReady(){return!!this._config}get config(){return this._config}get caid(){return this._analyticsId}async _initialize(){if(this.isReady)this.callbacks?.setIsReady?.(!0);else{if(!await this.isStorageAccessible())throw new r.PrivyClientError({code:"storage_error",error:"Unable to access storage"});this._config=await this.getAppConfig(),this._config?.custom_api_url&&(this.baseUrl=this._config.custom_api_url,this.session.isUsingServerCookies=!0),this.callbacks?.setIsReady?.(!0),this._sdkVersion.startsWith("react-auth:")||this.createAnalyticsEvent("sdk_initialize",{})}}getPath(e,{params:t,query:s}){return`${this.baseUrl}${i.getPathWithParams(e.path,t)}${o.toSearchParams(s)}`}async fetch(e,{body:t,params:s,query:i,headers:a,onRequest:n=this._beforeRequest.bind(this)}){let o=new Request(this.getPath(e,{params:s,query:i}),{method:e.method,body:JSON.stringify(t),headers:a}),h=await n(o),l=await this._fetch(o,h),c=await l.json();if(l.status>299)throw new r.PrivyApiError(c);return c}async _beforeRequestWithoutInitialize(e){let t=await this.session.getToken(),s=new Headers(e.headers);s.set("privy-app-id",this.appId),this.appClientId&&s.set("privy-client-id",this.appClientId),s.set("privy-client",this._sdkVersion),t&&s.set("Authorization",`Bearer ${t}`),s.set("Content-Type","application/json"),s.set("Accept","application/json");let i=await this._getOrGenerateClientAnalyticsId();return i&&s.set("privy-ca-id",i),this.nativeAppIdentifier&&s.set("x-native-app-identifier",this.nativeAppIdentifier),{signal:n.default(2e4),headers:s,credentials:"include"}}async beforeRequestWithoutRefresh(e){return await this._initialize(),this._beforeRequestWithoutInitialize(e)}async _beforeRequest(e){return await this._initialize(),await this.getAccessToken(),this.beforeRequestWithoutRefresh(e)}async getAppConfig(){return await this.fetch(i.AppConfig,{params:{app_id:this.appId},onRequest:this._beforeRequestWithoutInitialize.bind(this)})}async _getOrGenerateClientAnalyticsId(){if(this._analyticsId)return this._analyticsId;try{let e=await this._storage.get(g);if("string"==typeof e&&e.length>0)return this._analyticsId=e,e}catch(e){this.logger.error("Unable to load clientId",e)}try{this._analyticsId=t.v4()}catch(e){this.logger.error("Unable to generate uuidv4",e)}if(!this._analyticsId)return null;try{await this._storage.put(g,this._analyticsId)}catch(e){this.logger.error(`Unable to store clientId: ${this._analyticsId}`,e)}return this._analyticsId}async destroyClientAnalyticsId(){try{return await this._storage.del(g)}catch(e){this.logger.error("Unable to delete clientId",e)}}async createAnalyticsEvent(e,t){try{await this.fetch(i.AnalyticsEvent,{body:{event_name:e,client_id:await this._getOrGenerateClientAnalyticsId(),payload:t},onRequest:this.beforeRequestWithoutRefresh.bind(this)})}catch(e){}}async refreshSession(e=!1){if(!await this.isStorageAccessible())throw new r.PrivyClientError({code:"storage_error",error:"Unable to access storage"});let t=await this.session.getRefreshToken()??void 0,s=t??"key",i=this._cache.get(s);if(i)return this.logger.debug("[privy:refresh] found in-flight session refresh request, deduping"),await i;let a=this._refreshSession(t,e);this._cache.set(s,a);try{return await a}finally{this._cache.delete(s)}}async _refreshSession(e,t){let a=await this.session.getToken();if(!this.session.hasRefreshCredentials(a,e??null))throw this.logger.debug("[privy:refresh] missing tokens, skipping request"),await this._initialize(),new r.PrivyApiError({code:s.PrivyErrorCode.MISSING_OR_INVALID_TOKEN,error:"No tokens found in storage"});try{this.logger.debug(`[privy:refresh] fetching: ${i.RefreshSession.path}`);let s=await this.fetch(i.RefreshSession,{body:{refresh_token:e},onRequest:this.beforeRequestWithoutRefresh.bind(this)}),r=s.session_update_action;return this.logger.debug(`[privy:refresh] response: ${r}`),t||this.callbacks?.setUser?.(s.user),"set"===r&&(await this.session.updateWithTokensResponse(s),this.logger.debug("[privy:refresh] tokens stored")),"clear"===r&&(await this.session.destroyLocalState(),this.logger.debug("[privy:refresh] tokens cleared"),t||this.callbacks?.setUser?.(null)),"ignore"===r&&s.token&&(await this.session.storeToken(s.token),this.logger.debug("[privy:refresh] access token stored"),s.identity_token&&(this.logger.debug("[privy:refresh] identity token stored"),await this.session.storeIdentityToken(s.identity_token))),this.logger.debug("[privy:refresh] returning response"),s}catch(e){throw this.logger.debug(`[privy:refresh] error: ${e.message??"unknown error"}`),e instanceof r.PrivyApiError&&e.code===s.PrivyErrorCode.MISSING_OR_INVALID_TOKEN&&(await this.session.destroyLocalState(),t||this.callbacks?.setUser?.(null)),e}}async getAccessToken(){let[e,t]=await Promise.all([this.session.getToken(),this.session.getRefreshToken()]);if(!this.session.tokenIsActive(e)&&this.session.hasRefreshCredentials(e,t)){let t=await this.refreshSession(),s=await this.session.getToken();return t.token||this.logger.debug("[privy:getAccessToken] expected token received null"),t.token===e&&this.logger.debug("[privy:getAccessToken] expected new token in response received existing"),s===e&&this.logger.debug("[privy:getAccessToken] expected new token in storage received existing"),t.token??s}return e}async getIdentityToken(){return await this.session.getIdentityToken()}async isStorageAccessible(){try{let e=`privy:__storage__test-${t.v4()}`,s="blobby";await this._storage.put(e,s);let i=await this._storage.get(e);return await this._storage.del(e),i===s}catch(e){return this.logger.error(e),!1}}constructor(e){this._sdkVersion="js-sdk-core:0.56.2-beta-20251015013331",this._cache=new Map,this.logger=h.toConsoleLogger({level:e.logLevel??"ERROR"}),this._storage=e.storage,this._analyticsId=null,this._getOrGenerateClientAnalyticsId(),this.baseUrl=e.baseUrl??"https://auth.privy.io",this.appId=e.appId,this.appClientId=e.appClientId,this._sdkVersion=e.sdkVersion??this._sdkVersion,this.callbacks=e.callbacks,this.nativeAppIdentifier=e.nativeAppIdentifier,this.session=new a.Session({storage:this._storage,isUsingServerCookies:!1,appId:e.appId}),this._fetch=c.default(globalThis.fetch,{retries:3,retryDelay:e=>3**e*500,retryOn:[408,409,425,500,502,503,504]}),this.session.on("error_storing_tokens",(e=>{this.createAnalyticsEvent("error_updating_tokens_in_storage",{reason:e})}))}};
@@ -1,7 +1,7 @@
1
1
  import { Chain, RpcConfig } from '@privy-io/chains';
2
2
  export * from '@privy-io/chains';
3
3
  import * as _privy_io_public_api from '@privy-io/public-api';
4
- import { PasskeyAuthenticateInputType, PrivyEmbeddedWalletAccount, PrivyEthereumEmbeddedWalletAccount, PrivySolanaEmbeddedWalletAccount, PrivyUser, PrivySmartWalletConfigurationResponse, PrivyAuthenticatedUser, OAuthProviderType, SmartWalletType, CoinbaseOnRampInitInput, PrivyMoonpayOnRampSignInput, MfaPasskeyInitInputType, MfaSmsInitInputType, Route, PrivyBitcoinSegwitEmbeddedWalletAccount as PrivyBitcoinSegwitEmbeddedWalletAccount$1, PrivyBitcoinTaprootEmbeddedWalletAccount as PrivyBitcoinTaprootEmbeddedWalletAccount$1, PrivyLinkedAccount, PrivySmartWalletAccount, PrivyCoinbaseOnRampInitResponse, PrivyCoinbaseOnRampInitInput, WalletResponseType, WalletApiCreateInputType, WalletApiRpcResponseType, WalletApiRpcInputType, WalletApiRawSignResponseType, WalletApiRawSignInputType, WalletUpdateInputType, PrivyUnifiedWalletAccount } from '@privy-io/public-api';
4
+ import { PasskeyAuthenticateInputType, PrivyEmbeddedWalletAccount, PrivyEthereumEmbeddedWalletAccount, PrivySolanaEmbeddedWalletAccount, PrivyUser, PrivySmartWalletConfigurationResponse, PrivyAuthenticatedUser, OAuthProviderType, SmartWalletType, CoinbaseOnRampInitInput, PrivyMoonpayOnRampSignInput, MfaPasskeyInitInputType, MfaSmsInitInputType, Route, PrivyBitcoinSegwitEmbeddedWalletAccount as PrivyBitcoinSegwitEmbeddedWalletAccount$1, PrivyBitcoinTaprootEmbeddedWalletAccount as PrivyBitcoinTaprootEmbeddedWalletAccount$1, PrivyLinkedAccount, PrivySmartWalletAccount, PrivyCoinbaseOnRampInitResponse, PrivyCoinbaseOnRampInitInput, WalletApiCreateInputType, WalletResponseType, WalletApiRpcInputType, WalletApiRpcResponseType, WalletApiRawSignInputType, WalletApiRawSignResponseType, WalletUpdateInputType, PrivyUnifiedWalletAccount } from '@privy-io/public-api';
5
5
  export { BICONOMY, COINBASE_SMART_WALLET, KERNEL, LIGHT_ACCOUNT, OAuthProviderType, SAFE, SmartWalletType, THIRDWEB } from '@privy-io/public-api';
6
6
  import EventEmitter from 'eventemitter3';
7
7
  import { PrivyErrorCode } from '@privy-io/api-base';
@@ -1,7 +1,7 @@
1
1
  import { Chain, RpcConfig } from '@privy-io/chains';
2
2
  export * from '@privy-io/chains';
3
3
  import * as _privy_io_public_api from '@privy-io/public-api';
4
- import { PasskeyAuthenticateInputType, PrivyEmbeddedWalletAccount, PrivyEthereumEmbeddedWalletAccount, PrivySolanaEmbeddedWalletAccount, PrivyUser, PrivySmartWalletConfigurationResponse, PrivyAuthenticatedUser, OAuthProviderType, SmartWalletType, CoinbaseOnRampInitInput, PrivyMoonpayOnRampSignInput, MfaPasskeyInitInputType, MfaSmsInitInputType, Route, PrivyBitcoinSegwitEmbeddedWalletAccount as PrivyBitcoinSegwitEmbeddedWalletAccount$1, PrivyBitcoinTaprootEmbeddedWalletAccount as PrivyBitcoinTaprootEmbeddedWalletAccount$1, PrivyLinkedAccount, PrivySmartWalletAccount, PrivyCoinbaseOnRampInitResponse, PrivyCoinbaseOnRampInitInput, WalletResponseType, WalletApiCreateInputType, WalletApiRpcResponseType, WalletApiRpcInputType, WalletApiRawSignResponseType, WalletApiRawSignInputType, WalletUpdateInputType, PrivyUnifiedWalletAccount } from '@privy-io/public-api';
4
+ import { PasskeyAuthenticateInputType, PrivyEmbeddedWalletAccount, PrivyEthereumEmbeddedWalletAccount, PrivySolanaEmbeddedWalletAccount, PrivyUser, PrivySmartWalletConfigurationResponse, PrivyAuthenticatedUser, OAuthProviderType, SmartWalletType, CoinbaseOnRampInitInput, PrivyMoonpayOnRampSignInput, MfaPasskeyInitInputType, MfaSmsInitInputType, Route, PrivyBitcoinSegwitEmbeddedWalletAccount as PrivyBitcoinSegwitEmbeddedWalletAccount$1, PrivyBitcoinTaprootEmbeddedWalletAccount as PrivyBitcoinTaprootEmbeddedWalletAccount$1, PrivyLinkedAccount, PrivySmartWalletAccount, PrivyCoinbaseOnRampInitResponse, PrivyCoinbaseOnRampInitInput, WalletApiCreateInputType, WalletResponseType, WalletApiRpcInputType, WalletApiRpcResponseType, WalletApiRawSignInputType, WalletApiRawSignResponseType, WalletUpdateInputType, PrivyUnifiedWalletAccount } from '@privy-io/public-api';
5
5
  export { BICONOMY, COINBASE_SMART_WALLET, KERNEL, LIGHT_ACCOUNT, OAuthProviderType, SAFE, SmartWalletType, THIRDWEB } from '@privy-io/public-api';
6
6
  import EventEmitter from 'eventemitter3';
7
7
  import { PrivyErrorCode } from '@privy-io/api-base';
@@ -1 +1 @@
1
- import e from"fetch-retry";import{v4 as t}from"uuid";import{PrivyErrorCode as s}from"@privy-io/api-base";import{getPathWithParams as i,AppConfig as r,AnalyticsEvent as a,RefreshSession as n}from"@privy-io/public-api";import{PrivyClientError as o,PrivyApiError as h}from"../Error.mjs";import{Session as l}from"../Session.mjs";import c from"../toAbortSignalTimeout.mjs";import{toSearchParams as g}from"../utils/toSearchParams.mjs";import{toConsoleLogger as d}from"./logger.mjs";import"eventemitter3";import"jose";import"js-cookie";import"../Token.mjs";import"../utils/allSettled.mjs";import"../utils/noop.mjs";let p="privy:caid";class u{setCallbacks(e){this.callbacks={...this.callbacks,...e}}get isReady(){return!!this._config}get config(){return this._config}get caid(){return this._analyticsId}async _initialize(){if(this.isReady)this.callbacks?.setIsReady?.(!0);else{if(!await this.isStorageAccessible())throw new o({code:"storage_error",error:"Unable to access storage"});this._config=await this.getAppConfig(),this._config?.custom_api_url&&(this.baseUrl=this._config.custom_api_url,this.session.isUsingServerCookies=!0),this.callbacks?.setIsReady?.(!0),this._sdkVersion.startsWith("react-auth:")||this.createAnalyticsEvent("sdk_initialize",{})}}getPath(e,{params:t,query:s}){return`${this.baseUrl}${i(e.path,t)}${g(s)}`}async fetch(e,{body:t,params:s,query:i,headers:r,onRequest:a=this._beforeRequest.bind(this)}){let n=new Request(this.getPath(e,{params:s,query:i}),{method:e.method,body:JSON.stringify(t),headers:r}),o=await a(n),l=await this._fetch(n,o),c=await l.json();if(l.status>299)throw new h(c);return c}async _beforeRequestWithoutInitialize(e){let t=await this.session.getToken(),s=new Headers(e.headers);s.set("privy-app-id",this.appId),this.appClientId&&s.set("privy-client-id",this.appClientId),s.set("privy-client",this._sdkVersion),t&&s.set("Authorization",`Bearer ${t}`),s.set("Content-Type","application/json"),s.set("Accept","application/json");let i=await this._getOrGenerateClientAnalyticsId();return i&&s.set("privy-ca-id",i),this.nativeAppIdentifier&&s.set("x-native-app-identifier",this.nativeAppIdentifier),{signal:c(2e4),headers:s,credentials:"include"}}async beforeRequestWithoutRefresh(e){return await this._initialize(),this._beforeRequestWithoutInitialize(e)}async _beforeRequest(e){return await this._initialize(),await this.getAccessToken(),this.beforeRequestWithoutRefresh(e)}async getAppConfig(){return await this.fetch(r,{params:{app_id:this.appId},onRequest:this._beforeRequestWithoutInitialize.bind(this)})}async _getOrGenerateClientAnalyticsId(){if(this._analyticsId)return this._analyticsId;try{let e=await this._storage.get(p);if("string"==typeof e&&e.length>0)return this._analyticsId=e,e}catch(e){this.logger.error("Unable to load clientId",e)}try{this._analyticsId=t()}catch(e){this.logger.error("Unable to generate uuidv4",e)}if(!this._analyticsId)return null;try{await this._storage.put(p,this._analyticsId)}catch(e){this.logger.error(`Unable to store clientId: ${this._analyticsId}`,e)}return this._analyticsId}async destroyClientAnalyticsId(){try{return await this._storage.del(p)}catch(e){this.logger.error("Unable to delete clientId",e)}}async createAnalyticsEvent(e,t){try{await this.fetch(a,{body:{event_name:e,client_id:await this._getOrGenerateClientAnalyticsId(),payload:t},onRequest:this.beforeRequestWithoutRefresh.bind(this)})}catch(e){}}async refreshSession(e=!1){if(!await this.isStorageAccessible())throw new o({code:"storage_error",error:"Unable to access storage"});let t=await this.session.getRefreshToken()??void 0,s=t??"key",i=this._cache.get(s);if(i)return this.logger.debug("[privy:refresh] found in-flight session refresh request, deduping"),await i;let r=this._refreshSession(t,e);this._cache.set(s,r);try{return await r}finally{this._cache.delete(s)}}async _refreshSession(e,t){let i=await this.session.getToken();if(!this.session.hasRefreshCredentials(i,e??null))throw this.logger.debug("[privy:refresh] missing tokens, skipping request"),await this._initialize(),new h({code:s.MISSING_OR_INVALID_TOKEN,error:"No tokens found in storage"});try{this.logger.debug(`[privy:refresh] fetching: ${n.path}`);let s=await this.fetch(n,{body:{refresh_token:e},onRequest:this.beforeRequestWithoutRefresh.bind(this)}),i=s.session_update_action;return this.logger.debug(`[privy:refresh] response: ${i}`),t||this.callbacks?.setUser?.(s.user),"set"===i&&(await this.session.updateWithTokensResponse(s),this.logger.debug("[privy:refresh] tokens stored")),"clear"===i&&(await this.session.destroyLocalState(),this.logger.debug("[privy:refresh] tokens cleared"),t||this.callbacks?.setUser?.(null)),"ignore"===i&&s.token&&(await this.session.storeToken(s.token),this.logger.debug("[privy:refresh] access token stored"),s.identity_token&&(this.logger.debug("[privy:refresh] identity token stored"),await this.session.storeIdentityToken(s.identity_token))),this.logger.debug("[privy:refresh] returning response"),s}catch(e){throw this.logger.debug(`[privy:refresh] error: ${e.message??"unknown error"}`),e instanceof h&&e.code===s.MISSING_OR_INVALID_TOKEN&&(await this.session.destroyLocalState(),t||this.callbacks?.setUser?.(null)),e}}async getAccessToken(){let[e,t]=await Promise.all([this.session.getToken(),this.session.getRefreshToken()]);if(!this.session.tokenIsActive(e)&&this.session.hasRefreshCredentials(e,t)){let t=await this.refreshSession(),s=await this.session.getToken();return t.token||this.logger.debug("[privy:getAccessToken] expected token received null"),t.token===e&&this.logger.debug("[privy:getAccessToken] expected new token in response received existing"),s===e&&this.logger.debug("[privy:getAccessToken] expected new token in storage received existing"),t.token??s}return e}async getIdentityToken(){return await this.session.getIdentityToken()}async isStorageAccessible(){try{let e=`privy:__storage__test-${t()}`,s="blobby";await this._storage.put(e,s);let i=await this._storage.get(e);return await this._storage.del(e),i===s}catch(e){return this.logger.error(e),!1}}constructor(t){this._sdkVersion="js-sdk-core:0.56.1",this._cache=new Map,this.logger=d({level:t.logLevel??"ERROR"}),this._storage=t.storage,this._analyticsId=null,this._getOrGenerateClientAnalyticsId(),this.baseUrl=t.baseUrl??"https://auth.privy.io",this.appId=t.appId,this.appClientId=t.appClientId,this._sdkVersion=t.sdkVersion??this._sdkVersion,this.callbacks=t.callbacks,this.nativeAppIdentifier=t.nativeAppIdentifier,this.session=new l({storage:this._storage,isUsingServerCookies:!1,appId:t.appId}),this._fetch=e(globalThis.fetch,{retries:3,retryDelay:e=>3**e*500,retryOn:[408,409,425,500,502,503,504]}),this.session.on("error_storing_tokens",(e=>{this.createAnalyticsEvent("error_updating_tokens_in_storage",{reason:e})}))}}export{u as PrivyInternal};
1
+ import e from"fetch-retry";import{v4 as t}from"uuid";import{PrivyErrorCode as s}from"@privy-io/api-base";import{getPathWithParams as i,AppConfig as r,AnalyticsEvent as a,RefreshSession as n}from"@privy-io/public-api";import{PrivyClientError as o,PrivyApiError as h}from"../Error.mjs";import{Session as l}from"../Session.mjs";import c from"../toAbortSignalTimeout.mjs";import{toSearchParams as g}from"../utils/toSearchParams.mjs";import{toConsoleLogger as d}from"./logger.mjs";import"eventemitter3";import"jose";import"js-cookie";import"../Token.mjs";import"../utils/allSettled.mjs";import"../utils/noop.mjs";let p="privy:caid";class u{setCallbacks(e){this.callbacks={...this.callbacks,...e}}get isReady(){return!!this._config}get config(){return this._config}get caid(){return this._analyticsId}async _initialize(){if(this.isReady)this.callbacks?.setIsReady?.(!0);else{if(!await this.isStorageAccessible())throw new o({code:"storage_error",error:"Unable to access storage"});this._config=await this.getAppConfig(),this._config?.custom_api_url&&(this.baseUrl=this._config.custom_api_url,this.session.isUsingServerCookies=!0),this.callbacks?.setIsReady?.(!0),this._sdkVersion.startsWith("react-auth:")||this.createAnalyticsEvent("sdk_initialize",{})}}getPath(e,{params:t,query:s}){return`${this.baseUrl}${i(e.path,t)}${g(s)}`}async fetch(e,{body:t,params:s,query:i,headers:r,onRequest:a=this._beforeRequest.bind(this)}){let n=new Request(this.getPath(e,{params:s,query:i}),{method:e.method,body:JSON.stringify(t),headers:r}),o=await a(n),l=await this._fetch(n,o),c=await l.json();if(l.status>299)throw new h(c);return c}async _beforeRequestWithoutInitialize(e){let t=await this.session.getToken(),s=new Headers(e.headers);s.set("privy-app-id",this.appId),this.appClientId&&s.set("privy-client-id",this.appClientId),s.set("privy-client",this._sdkVersion),t&&s.set("Authorization",`Bearer ${t}`),s.set("Content-Type","application/json"),s.set("Accept","application/json");let i=await this._getOrGenerateClientAnalyticsId();return i&&s.set("privy-ca-id",i),this.nativeAppIdentifier&&s.set("x-native-app-identifier",this.nativeAppIdentifier),{signal:c(2e4),headers:s,credentials:"include"}}async beforeRequestWithoutRefresh(e){return await this._initialize(),this._beforeRequestWithoutInitialize(e)}async _beforeRequest(e){return await this._initialize(),await this.getAccessToken(),this.beforeRequestWithoutRefresh(e)}async getAppConfig(){return await this.fetch(r,{params:{app_id:this.appId},onRequest:this._beforeRequestWithoutInitialize.bind(this)})}async _getOrGenerateClientAnalyticsId(){if(this._analyticsId)return this._analyticsId;try{let e=await this._storage.get(p);if("string"==typeof e&&e.length>0)return this._analyticsId=e,e}catch(e){this.logger.error("Unable to load clientId",e)}try{this._analyticsId=t()}catch(e){this.logger.error("Unable to generate uuidv4",e)}if(!this._analyticsId)return null;try{await this._storage.put(p,this._analyticsId)}catch(e){this.logger.error(`Unable to store clientId: ${this._analyticsId}`,e)}return this._analyticsId}async destroyClientAnalyticsId(){try{return await this._storage.del(p)}catch(e){this.logger.error("Unable to delete clientId",e)}}async createAnalyticsEvent(e,t){try{await this.fetch(a,{body:{event_name:e,client_id:await this._getOrGenerateClientAnalyticsId(),payload:t},onRequest:this.beforeRequestWithoutRefresh.bind(this)})}catch(e){}}async refreshSession(e=!1){if(!await this.isStorageAccessible())throw new o({code:"storage_error",error:"Unable to access storage"});let t=await this.session.getRefreshToken()??void 0,s=t??"key",i=this._cache.get(s);if(i)return this.logger.debug("[privy:refresh] found in-flight session refresh request, deduping"),await i;let r=this._refreshSession(t,e);this._cache.set(s,r);try{return await r}finally{this._cache.delete(s)}}async _refreshSession(e,t){let i=await this.session.getToken();if(!this.session.hasRefreshCredentials(i,e??null))throw this.logger.debug("[privy:refresh] missing tokens, skipping request"),await this._initialize(),new h({code:s.MISSING_OR_INVALID_TOKEN,error:"No tokens found in storage"});try{this.logger.debug(`[privy:refresh] fetching: ${n.path}`);let s=await this.fetch(n,{body:{refresh_token:e},onRequest:this.beforeRequestWithoutRefresh.bind(this)}),i=s.session_update_action;return this.logger.debug(`[privy:refresh] response: ${i}`),t||this.callbacks?.setUser?.(s.user),"set"===i&&(await this.session.updateWithTokensResponse(s),this.logger.debug("[privy:refresh] tokens stored")),"clear"===i&&(await this.session.destroyLocalState(),this.logger.debug("[privy:refresh] tokens cleared"),t||this.callbacks?.setUser?.(null)),"ignore"===i&&s.token&&(await this.session.storeToken(s.token),this.logger.debug("[privy:refresh] access token stored"),s.identity_token&&(this.logger.debug("[privy:refresh] identity token stored"),await this.session.storeIdentityToken(s.identity_token))),this.logger.debug("[privy:refresh] returning response"),s}catch(e){throw this.logger.debug(`[privy:refresh] error: ${e.message??"unknown error"}`),e instanceof h&&e.code===s.MISSING_OR_INVALID_TOKEN&&(await this.session.destroyLocalState(),t||this.callbacks?.setUser?.(null)),e}}async getAccessToken(){let[e,t]=await Promise.all([this.session.getToken(),this.session.getRefreshToken()]);if(!this.session.tokenIsActive(e)&&this.session.hasRefreshCredentials(e,t)){let t=await this.refreshSession(),s=await this.session.getToken();return t.token||this.logger.debug("[privy:getAccessToken] expected token received null"),t.token===e&&this.logger.debug("[privy:getAccessToken] expected new token in response received existing"),s===e&&this.logger.debug("[privy:getAccessToken] expected new token in storage received existing"),t.token??s}return e}async getIdentityToken(){return await this.session.getIdentityToken()}async isStorageAccessible(){try{let e=`privy:__storage__test-${t()}`,s="blobby";await this._storage.put(e,s);let i=await this._storage.get(e);return await this._storage.del(e),i===s}catch(e){return this.logger.error(e),!1}}constructor(t){this._sdkVersion="js-sdk-core:0.56.2-beta-20251015013331",this._cache=new Map,this.logger=d({level:t.logLevel??"ERROR"}),this._storage=t.storage,this._analyticsId=null,this._getOrGenerateClientAnalyticsId(),this.baseUrl=t.baseUrl??"https://auth.privy.io",this.appId=t.appId,this.appClientId=t.appClientId,this._sdkVersion=t.sdkVersion??this._sdkVersion,this.callbacks=t.callbacks,this.nativeAppIdentifier=t.nativeAppIdentifier,this.session=new l({storage:this._storage,isUsingServerCookies:!1,appId:t.appId}),this._fetch=e(globalThis.fetch,{retries:3,retryDelay:e=>3**e*500,retryOn:[408,409,425,500,502,503,504]}),this.session.on("error_storing_tokens",(e=>{this.createAnalyticsEvent("error_updating_tokens_in_storage",{reason:e})}))}}export{u as PrivyInternal};
@@ -1 +1 @@
1
- import{isHexEncoded as e,bytesToHex as r,utf8ToBytes as i}from"../../utils/encodings.mjs";function t(t){return{from:t.from,to:t.to??void 0,nonce:n(t.nonce),chain_id:n(t.chainId),data:function(t){if(void 0!==t)return"string"==typeof t?e(t)?t:r(i(t)):r(Buffer.from(Uint8Array.from(t)))}(t.data),value:n(t.value),type:t.type,gas_limit:n(t.gasLimit),gas_price:n(t.gasPrice),max_fee_per_gas:n(t.maxFeePerGas),max_priority_fee_per_gas:n(t.maxPriorityFeePerGas)}}function n(t){if("number"==typeof t||"bigint"==typeof t){return`0x${BigInt(t).toString(16)}`}if("string"==typeof t)return e(t)?t:r(i(t))}export{t as toWalletApiUnsignedEthTransaction};
1
+ import{bytesToHex as e,isHexEncoded as r,utf8ToBytes as i}from"../../utils/encodings.mjs";function t(t){return{from:t.from,to:t.to??void 0,nonce:n(t.nonce),chain_id:n(t.chainId),data:function(t){if(void 0!==t)return"string"==typeof t?r(t)?t:e(i(t)):e(Buffer.from(Uint8Array.from(t)))}(t.data),value:n(t.value),type:t.type,gas_limit:n(t.gasLimit),gas_price:n(t.gasPrice),max_fee_per_gas:n(t.maxFeePerGas),max_priority_fee_per_gas:n(t.maxPriorityFeePerGas)}}function n(t){if("number"==typeof t||"bigint"==typeof t){return`0x${BigInt(t).toString(16)}`}if("string"==typeof t)return r(t)?t:e(i(t))}export{t as toWalletApiUnsignedEthTransaction};
@@ -1 +1 @@
1
- import{createSmartAccountClient as e}from"permissionless";import{toThirdwebSmartAccount as r,toLightSmartAccount as t,toBiconomySmartAccount as a,toKernelSmartAccount as i,toSafeSmartAccount as n}from"permissionless/accounts";import{createPimlicoClient as s}from"permissionless/clients/pimlico";import{http as o}from"viem";import{toCoinbaseSmartAccount as l,entryPoint06Address as c,entryPoint07Address as m}from"viem/account-abstraction";import{THIRDWEB as p,COINBASE_SMART_WALLET as u,LIGHT_ACCOUNT as y,BICONOMY as P,KERNEL as d,SAFE as w}from"@privy-io/public-api";let f={address:c,version:"0.6"},h={address:m,version:"0.7"},v=({owner:e,smartWalletType:s,smartWalletVersion:o,publicClient:c})=>{switch(s){case w:return n({client:c,entryPoint:h,owners:[e],version:"1.4.1"});case d:return i({client:c,version:"0.3.1",entryPoint:h,useMetaFactory:"optional",owners:[e]});case P:return a({client:c,owners:[e],entryPoint:f});case y:return t({client:c,entryPoint:f,owner:e,version:"1.1.0"});case u:return async function({client:e,owner:r,version:t}){let[a]=await r.request({method:"eth_accounts"});if(!a)throw Error("Unable to request embedded owner for eth_accounts");return await l({client:e,owners:[{type:"local",source:"privy",address:a,sign:async({hash:e})=>await r.request({method:"secp256k1_sign",params:[e]})}],version:t})}({client:c,owner:e,version:o??"1"});case p:return r({client:c,entryPoint:h,owner:e});default:throw Error(`Invalid smart account type: ${s}.`)}};const b=async({owner:r,smartWalletType:t,smartWalletVersion:a,chain:i,publicClient:n,bundlerUrl:l,paymasterUrl:c,paymasterContext:m})=>{let p=await v({owner:r,smartWalletType:t,smartWalletVersion:a,publicClient:n}),u=s({transport:o(l),entryPoint:p.entryPoint}),y=c?s({transport:o(c),entryPoint:p.entryPoint}):void 0;return e({account:p,chain:i,paymaster:y,paymasterContext:m,bundlerTransport:o(l),userOperation:{estimateFeesPerGas:async()=>{if(["public.pimlico.io","api.pimlico.io"].some((e=>l.includes(e))))return await u.getUserOperationGasPrice().then((e=>e.fast));if(["rpc.zerodev.app"].some((e=>l.includes(e))))return(await u.request({method:"zd_getUserOperationGasPrice",params:[]})).fast;if(["g.alchemy.com"].some((e=>l.includes(e)))){let[e,r]=await Promise.all([n.getBlock({blockTag:"latest"}),u.request({method:"rundler_maxPriorityFeePerGas",params:[]})]);if(!e.baseFeePerGas||!r)throw Error("Failed to get block or maxPriorityFeePerGasEstimate");return{maxFeePerGas:150n*e.baseFeePerGas/100n+BigInt(r.toString()),maxPriorityFeePerGas:BigInt(r.toString())}}{let e=await n.estimateFeesPerGas(),r=l.includes("api.developer.coinbase.com")?175n:150n;return{...e,maxFeePerGas:e.maxFeePerGas*r/100n,maxPriorityFeePerGas:e.maxPriorityFeePerGas*r/100n}}}}})};export{b as signerToSmartAccountClient};
1
+ import{createSmartAccountClient as e}from"permissionless";import{toThirdwebSmartAccount as r,toLightSmartAccount as t,toBiconomySmartAccount as a,toKernelSmartAccount as i,toSafeSmartAccount as n}from"permissionless/accounts";import{createPimlicoClient as s}from"permissionless/clients/pimlico";import{http as o}from"viem";import{entryPoint07Address as l,entryPoint06Address as c,toCoinbaseSmartAccount as m}from"viem/account-abstraction";import{THIRDWEB as p,COINBASE_SMART_WALLET as u,LIGHT_ACCOUNT as y,BICONOMY as P,KERNEL as d,SAFE as w}from"@privy-io/public-api";let f={address:c,version:"0.6"},h={address:l,version:"0.7"},v=({owner:e,smartWalletType:s,smartWalletVersion:o,publicClient:l})=>{switch(s){case w:return n({client:l,entryPoint:h,owners:[e],version:"1.4.1"});case d:return i({client:l,version:"0.3.1",entryPoint:h,useMetaFactory:"optional",owners:[e]});case P:return a({client:l,owners:[e],entryPoint:f});case y:return t({client:l,entryPoint:f,owner:e,version:"1.1.0"});case u:return async function({client:e,owner:r,version:t}){let[a]=await r.request({method:"eth_accounts"});if(!a)throw Error("Unable to request embedded owner for eth_accounts");return await m({client:e,owners:[{type:"local",source:"privy",address:a,sign:async({hash:e})=>await r.request({method:"secp256k1_sign",params:[e]})}],version:t})}({client:l,owner:e,version:o??"1"});case p:return r({client:l,entryPoint:h,owner:e});default:throw Error(`Invalid smart account type: ${s}.`)}};const b=async({owner:r,smartWalletType:t,smartWalletVersion:a,chain:i,publicClient:n,bundlerUrl:l,paymasterUrl:c,paymasterContext:m})=>{let p=await v({owner:r,smartWalletType:t,smartWalletVersion:a,publicClient:n}),u=s({transport:o(l),entryPoint:p.entryPoint}),y=c?s({transport:o(c),entryPoint:p.entryPoint}):void 0;return e({account:p,chain:i,paymaster:y,paymasterContext:m,bundlerTransport:o(l),userOperation:{estimateFeesPerGas:async()=>{if(["public.pimlico.io","api.pimlico.io"].some((e=>l.includes(e))))return await u.getUserOperationGasPrice().then((e=>e.fast));if(["rpc.zerodev.app"].some((e=>l.includes(e))))return(await u.request({method:"zd_getUserOperationGasPrice",params:[]})).fast;if(["g.alchemy.com"].some((e=>l.includes(e)))){let[e,r]=await Promise.all([n.getBlock({blockTag:"latest"}),u.request({method:"rundler_maxPriorityFeePerGas",params:[]})]);if(!e.baseFeePerGas||!r)throw Error("Failed to get block or maxPriorityFeePerGasEstimate");return{maxFeePerGas:150n*e.baseFeePerGas/100n+BigInt(r.toString()),maxPriorityFeePerGas:BigInt(r.toString())}}{let e=await n.estimateFeesPerGas(),r=l.includes("api.developer.coinbase.com")?175n:150n;return{...e,maxFeePerGas:e.maxFeePerGas*r/100n,maxPriorityFeePerGas:e.maxPriorityFeePerGas*r/100n}}}}})};export{b as signerToSmartAccountClient};
@@ -1 +1 @@
1
- import{mainnet as d,sepolia as e,optimism as c,optimismSepolia as b,polygon as f,polygonAmoy as i,base as a,baseSepolia as D,avalanche as C,avalancheFuji as x,arbitrum as t,arbitrumSepolia as n}from"@privy-io/chains";const E={[d.id]:"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",[e.id]:"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",[c.id]:"0x0b2c639c533813f4aa9d7837caf62653d097ff85",[b.id]:"0x5fd84259d66Cd46123540766Be93DFE6D43130D7",[f.id]:"0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",[i.id]:"0x41e94eb019c0762f9bfcf9fb1e58725bfb0e7582",[a.id]:"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",[D.id]:"0x036CbD53842c5426634e7929541eC2318f3dCF7e",[C.id]:"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",[x.id]:"0x5425890298aed601595a70ab815c96711a31bc65",[t.id]:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",[n.id]:"0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"},F={"mainnet-beta":"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",devnet:"4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",testnet:""};function r(d,e){return d===E[e.id]}export{F as SolanaUsdcAddressMap,E as UsdcAddressMap,r as getIsTokenUsdc};
1
+ import{arbitrumSepolia as d,arbitrum as e,avalancheFuji as c,avalanche as b,baseSepolia as f,base as i,polygonAmoy as a,polygon as D,optimismSepolia as C,optimism as x,sepolia as t,mainnet as n}from"@privy-io/chains";const E={[n.id]:"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",[t.id]:"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",[x.id]:"0x0b2c639c533813f4aa9d7837caf62653d097ff85",[C.id]:"0x5fd84259d66Cd46123540766Be93DFE6D43130D7",[D.id]:"0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",[a.id]:"0x41e94eb019c0762f9bfcf9fb1e58725bfb0e7582",[i.id]:"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",[f.id]:"0x036CbD53842c5426634e7929541eC2318f3dCF7e",[b.id]:"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",[c.id]:"0x5425890298aed601595a70ab815c96711a31bc65",[e.id]:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",[d.id]:"0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"},F={"mainnet-beta":"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",devnet:"4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",testnet:""};function r(d,e){return d===E[e.id]}export{F as SolanaUsdcAddressMap,E as UsdcAddressMap,r as getIsTokenUsdc};
@@ -1 +1 @@
1
- import e from"libphonenumber-js/examples.mobile.json";import{getCountries as n,getCountryCallingCode as o,isPossiblePhoneNumber as r,AsYouType as t,getExampleNumber as l}from"libphonenumber-js/min";export{getCountryCallingCode}from"libphonenumber-js/min";const i=(e,n)=>r(String(e),n),m=(e,n)=>`+${o(n)} ${e}`,p=e=>`*${e.replaceAll("-","").slice(-4)}`,a=e=>new t(e),u=n().map((e=>({code:e,callCode:o(e)}))),s=n=>{let o=l(n,e)?.formatInternational();return o?.substring(o.indexOf(" ")+1)},b=e=>{let n=new t;n.input(e);let o=n.getCountry()||"US",r=n.getCallingCode()||"1";return{countryCode:o,phone:e.replace("+"+r,"")}};export{u as countryCodesAndNumbers,m as formatPhoneNumber,b as getPhoneCountryCodeAndNumber,s as getPlaceholderPhoneNumber,p as lastFourDigits,a as phoneNumberTypingFormatter,i as validatePhoneNumber};
1
+ import e from"libphonenumber-js/examples.mobile.json";import{getCountries as n,getCountryCallingCode as o,AsYouType as r,isPossiblePhoneNumber as t,getExampleNumber as l}from"libphonenumber-js/min";export{getCountryCallingCode}from"libphonenumber-js/min";const i=(e,n)=>t(String(e),n),m=(e,n)=>`+${o(n)} ${e}`,p=e=>`*${e.replaceAll("-","").slice(-4)}`,a=e=>new r(e),u=n().map((e=>({code:e,callCode:o(e)}))),s=n=>{let o=l(n,e)?.formatInternational();return o?.substring(o.indexOf(" ")+1)},b=e=>{let n=new r;n.input(e);let o=n.getCountry()||"US",t=n.getCallingCode()||"1";return{countryCode:o,phone:e.replace("+"+t,"")}};export{u as countryCodesAndNumbers,m as formatPhoneNumber,b as getPhoneCountryCodeAndNumber,s as getPlaceholderPhoneNumber,p as lastFourDigits,a as phoneNumberTypingFormatter,i as validatePhoneNumber};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@privy-io/js-sdk-core",
3
- "version": "0.56.1",
3
+ "version": "0.56.2-beta-20251015013331",
4
4
  "description": "Vanilla JS client for the Privy Auth API",
5
5
  "keywords": [
6
6
  "authentication",
@@ -63,7 +63,7 @@
63
63
  ],
64
64
  "dependencies": {
65
65
  "@privy-io/api-base": "1.7.1",
66
- "@privy-io/public-api": "2.49.0",
66
+ "@privy-io/public-api": "2.50.0-beta-20251015013331",
67
67
  "@privy-io/ethereum": "0.0.2",
68
68
  "canonicalize": "^2.0.0",
69
69
  "@privy-io/chains": "0.0.2",
@@ -98,7 +98,7 @@
98
98
  "@types/text-encoding": "^0.0.37",
99
99
  "glob": "^10.3.12",
100
100
  "msw": "^2.0.13",
101
- "rollup": "^4.28.0",
101
+ "rollup": "4.52.4",
102
102
  "rollup-plugin-copy": "^3.5.0",
103
103
  "rollup-plugin-dts": "^6.1.1",
104
104
  "text-encoding": "^0.7.0",