@privy-io/js-sdk-core 0.48.1 → 0.48.2

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";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./AppApi.js"),r=require("./CrossAppApi.js"),i=require("./DelegatedWalletsApi.js"),t=require("./EmbeddedWalletApi.js"),s=require("./MfaPromises.js"),a=require("./PrivyInternal.js"),u=require("./UserApi.js"),d=require("./auth/AuthApi.js"),n=require("./funding/FundingApi.js"),l=require("./mfa/MfaApi.js"),o=require("./recovery/RecoveryApi.js");require("@privy-io/public-api"),require("../Token.js"),require("jose"),require("@privy-io/chains"),require("../Error.js"),require("../embedded/EmbeddedBitcoinWalletProvider.js"),require("../embedded/errors.js"),require("../embedded/types.js"),require("../embedded/utils/index.js"),require("@ethersproject/abstract-signer"),require("@ethersproject/providers"),require("../embedded/gas/arbitrum.js"),require("@ethersproject/bignumber"),require("../embedded/utils/ethers.js"),require("../embedded/gas/bsc.js"),require("../embedded/gas/op-stack.js"),require("@ethersproject/contracts"),require("@ethersproject/transactions"),require("../embedded/gas/polygon.js"),require("@ethersproject/units"),require("fetch-retry"),require("../embedded/utils/gas.js"),require("../embedded/EmbeddedWalletProxy.js"),require("../utils/sleep.js"),require("../embedded/EventCallbackQueue.js"),require("../embedded/withMfa.js"),require("../embedded/EmbeddedWalletProvider.js"),require("eventemitter3"),require("../embedded/methods.js"),require("../embedded/EmbeddedSolanaWalletProvider.js"),require("../solana/getWalletPublicKeyFromTransaction.js"),require("../solana/isVersionedTransaction.js"),require("uuid"),require("@privy-io/api-base"),require("../Session.js"),require("js-cookie"),require("../utils/allSettled.js"),require("../toAbortSignalTimeout.js"),require("../utils/toSearchParams.js"),require("./auth/CustomProviderApi.js"),require("./auth/maybeCreateWalletOnLogin.js"),require("../utils/getUserEmbeddedEthereumWallet.js"),require("../utils/getAllUserEmbeddedEthereumWallets.js"),require("../utils/getUserEmbeddedSolanaWallet.js"),require("../utils/getAllUserEmbeddedSolanaWallets.js"),require("../utils/shouldCreateEmbeddedEthWallet.js"),require("../utils/shouldCreateEmbeddedSolWallet.js"),require("./auth/EmailApi.js"),require("./auth/FarcasterApi.js"),require("./auth/FarcasterV2Api.js"),require("./auth/GuestApi.js"),require("./auth/OAuthApi.js"),require("../pkce.js"),require("./auth/PasskeyApi.js"),require("./auth/PhoneApi.js"),require("./auth/SiweApi.js"),require("./auth/SiwsApi.js"),require("./auth/SmartWalletApi.js"),require("./funding/CoinbaseOnRampApi.js"),require("./funding/MoonpayOnRampApi.js"),require("../funding/moonpay.js"),require("./mfa/MfaPasskeyApi.js"),require("./mfa/MfaSmsApi.js"),require("./recovery/RecoveryICloudApi.js"),require("./recovery/RecoveryOAuthApi.js");exports.default=class{async initialize(){await this._privyInternal._initialize()}setMessagePoster(e){this.embeddedWallet.setMessagePoster(e)}addOAuthTokensListener(e){return this._privyInternal.session.on("oauth_tokens_granted",e),{unsubscribe:()=>{this._privyInternal.session.removeListener("oauth_tokens_granted",e)}}}setCallbacks(e){this._privyInternal.setCallbacks(e)}getAccessToken(){return this._privyInternal.getAccessToken()}getIdentityToken(){return this._privyInternal.getIdentityToken()}getCompiledPath(e,r){return this._privyInternal.getPath(e,r)}async fetchPrivyRoute(e,r){return this._privyInternal.fetch(e,r)}constructor({clientId:p,...q}){this._privyInternal=new a.PrivyInternal({...q,appClientId:p}),this.mfa=new l.default(this._privyInternal),this.mfaPromises=new s.default,this.embeddedWallet=new t.default(this._privyInternal,q.embeddedWalletMessagePoster,q.supportedChains,this.mfa,this.mfaPromises),this.user=new u.default(this._privyInternal),this.app=new e.default(this._privyInternal),this.auth=new d.default(this._privyInternal,this.embeddedWallet,q.storage,q.crypto),this.recovery=new o.default(this._privyInternal,q.storage,q.crypto),this.funding=new n.default(this._privyInternal),this.delegated=new i.default(this._privyInternal),this.crossApp=new r.default(this._privyInternal,q.storage)}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./AppApi.js"),r=require("./CrossAppApi.js"),i=require("./DelegatedWalletsApi.js"),t=require("./EmbeddedWalletApi.js"),s=require("./MfaPromises.js"),a=require("./PrivyInternal.js"),u=require("./UserApi.js"),d=require("./auth/AuthApi.js"),n=require("./funding/FundingApi.js"),l=require("./mfa/MfaApi.js"),o=require("./recovery/RecoveryApi.js");require("@privy-io/public-api"),require("../Token.js"),require("jose"),require("@privy-io/chains"),require("../Error.js"),require("../embedded/EmbeddedBitcoinWalletProvider.js"),require("../embedded/errors.js"),require("../embedded/types.js"),require("../embedded/utils/index.js"),require("@ethersproject/abstract-signer"),require("@ethersproject/providers"),require("../embedded/gas/arbitrum.js"),require("@ethersproject/bignumber"),require("../embedded/utils/ethers.js"),require("../embedded/gas/bsc.js"),require("../embedded/gas/op-stack.js"),require("@ethersproject/contracts"),require("@ethersproject/transactions"),require("../embedded/gas/polygon.js"),require("@ethersproject/units"),require("fetch-retry"),require("../embedded/utils/gas.js"),require("../embedded/EmbeddedWalletProxy.js"),require("../utils/sleep.js"),require("../embedded/EventCallbackQueue.js"),require("../embedded/withMfa.js"),require("../embedded/EmbeddedWalletProvider.js"),require("eventemitter3"),require("../embedded/methods.js"),require("../embedded/EmbeddedSolanaWalletProvider.js"),require("../solana/getWalletPublicKeyFromTransaction.js"),require("../solana/isVersionedTransaction.js"),require("uuid"),require("@privy-io/api-base"),require("../Session.js"),require("js-cookie"),require("../utils/allSettled.js"),require("../toAbortSignalTimeout.js"),require("../utils/toSearchParams.js"),require("./logger.js"),require("../utils/noop.js"),require("./auth/CustomProviderApi.js"),require("./auth/maybeCreateWalletOnLogin.js"),require("../utils/getUserEmbeddedEthereumWallet.js"),require("../utils/getAllUserEmbeddedEthereumWallets.js"),require("../utils/getUserEmbeddedSolanaWallet.js"),require("../utils/getAllUserEmbeddedSolanaWallets.js"),require("../utils/shouldCreateEmbeddedEthWallet.js"),require("../utils/shouldCreateEmbeddedSolWallet.js"),require("./auth/EmailApi.js"),require("./auth/FarcasterApi.js"),require("./auth/FarcasterV2Api.js"),require("./auth/GuestApi.js"),require("./auth/OAuthApi.js"),require("../pkce.js"),require("./auth/PasskeyApi.js"),require("./auth/PhoneApi.js"),require("./auth/SiweApi.js"),require("./auth/SiwsApi.js"),require("./auth/SmartWalletApi.js"),require("./funding/CoinbaseOnRampApi.js"),require("./funding/MoonpayOnRampApi.js"),require("../funding/moonpay.js"),require("./mfa/MfaPasskeyApi.js"),require("./mfa/MfaSmsApi.js"),require("./recovery/RecoveryICloudApi.js"),require("./recovery/RecoveryOAuthApi.js");exports.default=class{async initialize(){await this._privyInternal._initialize()}setMessagePoster(e){this.embeddedWallet.setMessagePoster(e)}addOAuthTokensListener(e){return this._privyInternal.session.on("oauth_tokens_granted",e),{unsubscribe:()=>{this._privyInternal.session.removeListener("oauth_tokens_granted",e)}}}setCallbacks(e){this._privyInternal.setCallbacks(e)}getAccessToken(){return this._privyInternal.getAccessToken()}getIdentityToken(){return this._privyInternal.getIdentityToken()}getCompiledPath(e,r){return this._privyInternal.getPath(e,r)}async fetchPrivyRoute(e,r){return this._privyInternal.fetch(e,r)}get logger(){return this._privyInternal.logger}constructor({clientId:p,...q}){this._privyInternal=new a.PrivyInternal({...q,appClientId:p}),this.mfa=new l.default(this._privyInternal),this.mfaPromises=new s.default,this.embeddedWallet=new t.default(this._privyInternal,q.embeddedWalletMessagePoster,q.supportedChains,this.mfa,this.mfaPromises),this.user=new u.default(this._privyInternal),this.app=new e.default(this._privyInternal),this.auth=new d.default(this._privyInternal,this.embeddedWallet,q.storage,q.crypto),this.recovery=new o.default(this._privyInternal,q.storage,q.crypto),this.funding=new n.default(this._privyInternal),this.delegated=new i.default(this._privyInternal),this.crossApp=new r.default(this._privyInternal,q.storage)}};
@@ -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");function h(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");var c=/*#__PURE__*/h(e);let l="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),c=await this._fetch(o,h),l=await c.json();if(c.status>299)throw new r.PrivyApiError(l);return l}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(l);if("string"==typeof e&&e.length>0)return this._analyticsId=e,e}catch(e){console.error("Unable to load clientId",e)}try{this._analyticsId=t.v4()}catch(e){console.error("Unable to generate uuidv4",e)}if(!this._analyticsId)return null;try{await this._storage.put(l,this._analyticsId)}catch(e){console.error(`Unable to store clientId: ${this._analyticsId}`,e)}return this._analyticsId}async destroyClientAnalyticsId(){try{return await this._storage.del(l)}catch(e){console.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 console.debug("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.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.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.debug(`[privy:refresh] response: ${r}`),t||this.callbacks?.setUser?.(s.user),"set"===r&&(await this.session.updateWithTokensResponse(s),this.debug("[privy:refresh] tokens stored")),"clear"===r&&(await this.session.destroyLocalState(),this.debug("[privy:refresh] tokens cleared"),t||this.callbacks?.setUser?.(null)),"ignore"===r&&s.token&&(await this.session.storeToken(s.token),this.debug("[privy:refresh] access token stored"),s.identity_token&&(this.debug("[privy:refresh] identity token stored"),await this.session.storeIdentityToken(s.identity_token))),this.debug("[privy:refresh] returning response"),s}catch(e){throw this.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.debug("[privy:getAccessToken] expected token received null"),t.token===e&&this.debug("[privy:getAccessToken] expected new token in response received existing"),s===e&&this.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 console.error(e),!1}}debug(e){"DEBUG"===this._logLevel&&console.debug(e)}constructor(e){this._sdkVersion="js-sdk-core:0.48.1",this._cache=new Map,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._logLevel=e.logLevel,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.48.2",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})}))}};
@@ -0,0 +1 @@
1
+ "use strict";var o=require("../utils/noop.js");let e={NONE:Number.NEGATIVE_INFINITY,ERROR:1,WARN:2,INFO:3,DEBUG:Number.POSITIVE_INFINITY};exports.toConsoleLogger=({level:r}={level:"ERROR"})=>({get level(){return r},error:e[r]>=e.ERROR?console.error:o.noop,warn:e[r]>=e.WARN?console.warn:o.noop,info:e[r]>=e.INFO?console.info:o.noop,debug:e[r]>=e.DEBUG?console.debug:o.noop});
package/dist/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./client/Privy.js"),r=require("@privy-io/public-api"),t=require("./storage/LocalStorage.js"),s=require("./storage/InMemoryStorage.js"),o=require("./Error.js"),i=require("./embedded/errors.js"),a=require("./utils/getUserEmbeddedEthereumWallet.js"),n=require("./utils/getAllUserEmbeddedEthereumWallets.js"),l=require("./utils/getAllUserEmbeddedSolanaWallets.js"),d=require("./utils/getAllUserEmbeddedBitcoinWallets.js"),u=require("./utils/entropy.js"),p=require("./utils/getUserSmartWallet.js"),c=require("./embedded/utils/index.js"),m=require("./utils/phoneNumberUtils.js"),j=require("./utils/getUserEmbeddedSolanaWallet.js"),q=require("./utils/toObjectKeys.js"),g=require("./embedded/utils/gas.js"),b=require("./embedded/utils/ethers.js"),A=require("./utils/getIsTokenUsdc.js"),E=require("./funding/moonpay.js"),y=require("./funding/coinbase.js"),x=require("./solana/client.js"),h=require("./solana/createSiwsMessage.js"),C=require("./solana/getSolanaRpcEndpointForCluster.js"),f=require("./solana/getSolanaUsdcMintAddressForCluster.js"),P=require("./solana/getSolanaClusterDisplayName.js"),S=require("./types.js"),T=require("@privy-io/chains"),v=require("./utils/formatters.js"),M=require("./wallet-api/create.js"),W=require("./wallet-api/rpc.js"),I=require("libphonenumber-js/min"),U=require("./index-BDWdfIuK.js"),O=require("./index-DzfqDJJ9.js");require("./client/AppApi.js"),require("./client/CrossAppApi.js"),require("./Token.js"),require("jose"),require("./client/DelegatedWalletsApi.js"),require("./client/EmbeddedWalletApi.js"),require("./embedded/EmbeddedBitcoinWalletProvider.js"),require("./embedded/EmbeddedWalletProxy.js"),require("./utils/sleep.js"),require("./embedded/EventCallbackQueue.js"),require("./embedded/withMfa.js"),require("./embedded/EmbeddedWalletProvider.js"),require("eventemitter3"),require("./embedded/methods.js"),require("./embedded/EmbeddedSolanaWalletProvider.js"),require("./solana/getWalletPublicKeyFromTransaction.js"),require("./solana/isVersionedTransaction.js"),require("./client/MfaPromises.js"),require("./client/PrivyInternal.js"),require("fetch-retry"),require("uuid"),require("@privy-io/api-base"),require("./Session.js"),require("js-cookie"),require("./utils/allSettled.js"),require("./toAbortSignalTimeout.js"),require("./utils/toSearchParams.js"),require("./client/UserApi.js"),require("./client/auth/AuthApi.js"),require("./client/auth/CustomProviderApi.js"),require("./client/auth/maybeCreateWalletOnLogin.js"),require("./utils/shouldCreateEmbeddedEthWallet.js"),require("./utils/shouldCreateEmbeddedSolWallet.js"),require("./client/auth/EmailApi.js"),require("./client/auth/FarcasterApi.js"),require("./client/auth/FarcasterV2Api.js"),require("./client/auth/GuestApi.js"),require("./client/auth/OAuthApi.js"),require("./pkce.js"),require("./client/auth/PasskeyApi.js"),require("./client/auth/PhoneApi.js"),require("./client/auth/SiweApi.js"),require("./client/auth/SiwsApi.js"),require("./client/auth/SmartWalletApi.js"),require("./client/funding/FundingApi.js"),require("./client/funding/CoinbaseOnRampApi.js"),require("./client/funding/MoonpayOnRampApi.js"),require("./client/mfa/MfaApi.js"),require("./client/mfa/MfaPasskeyApi.js"),require("./client/mfa/MfaSmsApi.js"),require("./client/recovery/RecoveryApi.js"),require("./client/recovery/RecoveryICloudApi.js"),require("./client/recovery/RecoveryOAuthApi.js"),require("./embedded/types.js"),require("@ethersproject/abstract-signer"),require("@ethersproject/providers"),require("./embedded/gas/arbitrum.js"),require("@ethersproject/bignumber"),require("./embedded/gas/bsc.js"),require("./embedded/gas/op-stack.js"),require("@ethersproject/contracts"),require("@ethersproject/transactions"),require("./embedded/gas/polygon.js"),require("@ethersproject/units"),require("libphonenumber-js/examples.mobile.json"),require("viem"),require("canonicalize"),require("./action/delegatedActions/delegateWallet.js"),require("./action/delegatedActions/utils.js"),require("./action/delegatedActions/revokeWallets.js"),require("./action/crossApp/loginWithCrossAppAuth.js"),require("./action/crossApp/linkWithCrossAppAuth.js"),require("./index-CARkJvRM.js"),require("./action/crossApp/wallet/signMessage.js"),require("./action/crossApp/wallet/utils/isCrossAppWalletSmart.js"),require("./action/crossApp/wallet/utils/sendCrossAppRequest.js"),require("./action/crossApp/wallet/utils/getCrossAppAccountByWalletAddress.js"),require("./action/crossApp/wallet/utils/getProviderAccessTokenOrRelink.js"),require("./action/crossApp/wallet/utils/throwIfNotLoggedIn.js"),require("./action/crossApp/wallet/signTypedData.js"),require("./utils/typedData/generateDomainType.js"),require("./action/crossApp/wallet/sendTransaction.js"),exports.default=e.default,Object.defineProperty(exports,"BICONOMY",{enumerable:!0,get:function(){return r.BICONOMY}}),Object.defineProperty(exports,"COINBASE_SMART_WALLET",{enumerable:!0,get:function(){return r.COINBASE_SMART_WALLET}}),Object.defineProperty(exports,"KERNEL",{enumerable:!0,get:function(){return r.KERNEL}}),Object.defineProperty(exports,"LIGHT_ACCOUNT",{enumerable:!0,get:function(){return r.LIGHT_ACCOUNT}}),Object.defineProperty(exports,"SAFE",{enumerable:!0,get:function(){return r.SAFE}}),Object.defineProperty(exports,"THIRDWEB",{enumerable:!0,get:function(){return r.THIRDWEB}}),exports.LocalStorage=t.LocalStorage,exports.InMemoryCache=s.InMemoryCache,exports.MoonpayApiError=o.MoonpayApiError,exports.PrivyApiError=o.PrivyApiError,exports.PrivyClientError=o.PrivyClientError,exports.createErrorFormatter=o.createErrorFormatter,exports.errorIndicatesMfaCanceled=o.errorIndicatesMfaCanceled,exports.EmbeddedProviderError=i.EmbeddedProviderError,exports.PrivyConnectorError=i.PrivyConnectorError,exports.PrivyEmbeddedWalletErrorCode=i.PrivyEmbeddedWalletErrorCode,exports.PrivyProviderRpcError=i.PrivyProviderRpcError,exports.ProviderErrors=i.ProviderErrors,exports.errorIndicatesMaxMfaRetries=i.errorIndicatesMaxMfaRetries,exports.errorIndicatesMfaRateLimit=i.errorIndicatesMfaRateLimit,exports.errorIndicatesMfaTimeout=i.errorIndicatesMfaTimeout,exports.errorIndicatesMfaVerificationFailed=i.errorIndicatesMfaVerificationFailed,exports.errorIndicatesRecoveryIsNeeded=i.errorIndicatesRecoveryIsNeeded,exports.getUserEmbeddedEthereumWallet=a.getUserEmbeddedEthereumWallet,exports.getUserEmbeddedWallet=a.getUserEmbeddedWallet,exports.getAllUserEmbeddedEthereumWallets=n.getAllUserEmbeddedEthereumWallets,exports.getAllUserEmbeddedSolanaWallets=l.getAllUserEmbeddedSolanaWallets,exports.getAllUserEmbeddedBitcoinWallets=d.getAllUserEmbeddedBitcoinWallets,exports.getEntropyDetailsFromAccount=u.getEntropyDetailsFromAccount,exports.getEntropyDetailsFromUser=u.getEntropyDetailsFromUser,exports.getUserSmartWallet=p.getUserSmartWallet,exports.getJsonRpcEndpointFromChain=c.getJsonRpcEndpointFromChain,exports.populateTransactionRequest=c.populateTransactionRequest,exports.throwIfInvalidRecoveryUpgradePath=c.throwIfInvalidRecoveryUpgradePath,exports.countryCodesAndNumbers=m.countryCodesAndNumbers,exports.formatPhoneNumber=m.formatPhoneNumber,exports.getPhoneCountryCodeAndNumber=m.getPhoneCountryCodeAndNumber,exports.getPlaceholderPhoneNumber=m.getPlaceholderPhoneNumber,exports.lastFourDigits=m.lastFourDigits,exports.phoneNumberTypingFormatter=m.phoneNumberTypingFormatter,exports.validatePhoneNumber=m.validatePhoneNumber,exports.getUserEmbeddedSolanaWallet=j.getUserEmbeddedSolanaWallet,exports.toObjectKeys=q.toObjectKeys,exports.calculateTotalGasEstimate=g.calculateTotalGasEstimate,exports.QuantityToBigNumber=b.QuantityToBigNumber,exports.convertBigNumberish=b.convertBigNumberish,exports.toEthersUnsignedTransaction=b.toEthersUnsignedTransaction,exports.SolanaUsdcAddressMap=A.SolanaUsdcAddressMap,exports.UsdcAddressMap=A.UsdcAddressMap,exports.getIsTokenUsdc=A.getIsTokenUsdc,exports.chainToMoonpayCurrency=E.chainToMoonpayCurrency,exports.fundingMethodToMoonpayPaymentMethod=E.fundingMethodToMoonpayPaymentMethod,exports.isSupportedChainIdForMoonpay=E.isSupportedChainIdForMoonpay,exports.getCoinbaseOnRampUrl=y.getCoinbaseOnRampUrl,exports.isSupportedChainIdForCoinbaseOnramp=y.isSupportedChainIdForCoinbaseOnramp,exports.toCoinbaseAssetId=y.toCoinbaseAssetId,exports.toCoinbaseBlockchainFromChainId=y.toCoinbaseBlockchainFromChainId,exports.SolanaClient=x.SolanaClient,exports.createSiwsMessage=h.createSiwsMessage,exports.getSolanaRpcEndpointForCluster=C.getSolanaRpcEndpointForCluster,exports.getSolanaUsdcMintAddressForCluster=f.getSolanaUsdcMintAddressForCluster,exports.getSolanaClusterDisplayName=P.getSolanaClusterDisplayName,exports.ALL_WALLET_CLIENT_TYPES=S.ALL_WALLET_CLIENT_TYPES,exports.SUPPORTED_CONNECTOR_TYPES=S.SUPPORTED_CONNECTOR_TYPES,exports.formatLamportsAmount=v.formatLamportsAmount,exports.formatTokenAmount=v.formatTokenAmount,exports.formatWalletAddress=v.formatWalletAddress,exports.formatWeiAmount=v.formatWeiAmount,exports.create=M.create,exports.rpc=W.rpc,Object.defineProperty(exports,"getCountryCallingCode",{enumerable:!0,get:function(){return I.getCountryCallingCode}}),exports.delegatedActions=U.index,exports.crossApp=O.index,Object.keys(T).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return T[e]}})}));
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./client/Privy.js"),r=require("@privy-io/public-api"),t=require("./storage/LocalStorage.js"),s=require("./storage/InMemoryStorage.js"),o=require("./Error.js"),i=require("./embedded/errors.js"),a=require("./utils/getUserEmbeddedEthereumWallet.js"),n=require("./utils/getAllUserEmbeddedEthereumWallets.js"),l=require("./utils/getAllUserEmbeddedSolanaWallets.js"),d=require("./utils/getAllUserEmbeddedBitcoinWallets.js"),u=require("./utils/entropy.js"),p=require("./utils/getUserSmartWallet.js"),c=require("./embedded/utils/index.js"),m=require("./utils/phoneNumberUtils.js"),j=require("./utils/getUserEmbeddedSolanaWallet.js"),q=require("./utils/toObjectKeys.js"),g=require("./embedded/utils/gas.js"),b=require("./embedded/utils/ethers.js"),A=require("./utils/getIsTokenUsdc.js"),E=require("./funding/moonpay.js"),y=require("./funding/coinbase.js"),x=require("./solana/client.js"),h=require("./solana/createSiwsMessage.js"),C=require("./solana/getSolanaRpcEndpointForCluster.js"),f=require("./solana/getSolanaUsdcMintAddressForCluster.js"),P=require("./solana/getSolanaClusterDisplayName.js"),S=require("./types.js"),T=require("@privy-io/chains"),v=require("./utils/formatters.js"),M=require("./wallet-api/create.js"),W=require("./wallet-api/rpc.js"),I=require("libphonenumber-js/min"),U=require("./index-BDWdfIuK.js"),O=require("./index-DzfqDJJ9.js");require("./client/AppApi.js"),require("./client/CrossAppApi.js"),require("./Token.js"),require("jose"),require("./client/DelegatedWalletsApi.js"),require("./client/EmbeddedWalletApi.js"),require("./embedded/EmbeddedBitcoinWalletProvider.js"),require("./embedded/EmbeddedWalletProxy.js"),require("./utils/sleep.js"),require("./embedded/EventCallbackQueue.js"),require("./embedded/withMfa.js"),require("./embedded/EmbeddedWalletProvider.js"),require("eventemitter3"),require("./embedded/methods.js"),require("./embedded/EmbeddedSolanaWalletProvider.js"),require("./solana/getWalletPublicKeyFromTransaction.js"),require("./solana/isVersionedTransaction.js"),require("./client/MfaPromises.js"),require("./client/PrivyInternal.js"),require("fetch-retry"),require("uuid"),require("@privy-io/api-base"),require("./Session.js"),require("js-cookie"),require("./utils/allSettled.js"),require("./toAbortSignalTimeout.js"),require("./utils/toSearchParams.js"),require("./client/logger.js"),require("./utils/noop.js"),require("./client/UserApi.js"),require("./client/auth/AuthApi.js"),require("./client/auth/CustomProviderApi.js"),require("./client/auth/maybeCreateWalletOnLogin.js"),require("./utils/shouldCreateEmbeddedEthWallet.js"),require("./utils/shouldCreateEmbeddedSolWallet.js"),require("./client/auth/EmailApi.js"),require("./client/auth/FarcasterApi.js"),require("./client/auth/FarcasterV2Api.js"),require("./client/auth/GuestApi.js"),require("./client/auth/OAuthApi.js"),require("./pkce.js"),require("./client/auth/PasskeyApi.js"),require("./client/auth/PhoneApi.js"),require("./client/auth/SiweApi.js"),require("./client/auth/SiwsApi.js"),require("./client/auth/SmartWalletApi.js"),require("./client/funding/FundingApi.js"),require("./client/funding/CoinbaseOnRampApi.js"),require("./client/funding/MoonpayOnRampApi.js"),require("./client/mfa/MfaApi.js"),require("./client/mfa/MfaPasskeyApi.js"),require("./client/mfa/MfaSmsApi.js"),require("./client/recovery/RecoveryApi.js"),require("./client/recovery/RecoveryICloudApi.js"),require("./client/recovery/RecoveryOAuthApi.js"),require("./embedded/types.js"),require("@ethersproject/abstract-signer"),require("@ethersproject/providers"),require("./embedded/gas/arbitrum.js"),require("@ethersproject/bignumber"),require("./embedded/gas/bsc.js"),require("./embedded/gas/op-stack.js"),require("@ethersproject/contracts"),require("@ethersproject/transactions"),require("./embedded/gas/polygon.js"),require("@ethersproject/units"),require("libphonenumber-js/examples.mobile.json"),require("viem"),require("canonicalize"),require("./action/delegatedActions/delegateWallet.js"),require("./action/delegatedActions/utils.js"),require("./action/delegatedActions/revokeWallets.js"),require("./action/crossApp/loginWithCrossAppAuth.js"),require("./action/crossApp/linkWithCrossAppAuth.js"),require("./index-CARkJvRM.js"),require("./action/crossApp/wallet/signMessage.js"),require("./action/crossApp/wallet/utils/isCrossAppWalletSmart.js"),require("./action/crossApp/wallet/utils/sendCrossAppRequest.js"),require("./action/crossApp/wallet/utils/getCrossAppAccountByWalletAddress.js"),require("./action/crossApp/wallet/utils/getProviderAccessTokenOrRelink.js"),require("./action/crossApp/wallet/utils/throwIfNotLoggedIn.js"),require("./action/crossApp/wallet/signTypedData.js"),require("./utils/typedData/generateDomainType.js"),require("./action/crossApp/wallet/sendTransaction.js"),exports.default=e.default,Object.defineProperty(exports,"BICONOMY",{enumerable:!0,get:function(){return r.BICONOMY}}),Object.defineProperty(exports,"COINBASE_SMART_WALLET",{enumerable:!0,get:function(){return r.COINBASE_SMART_WALLET}}),Object.defineProperty(exports,"KERNEL",{enumerable:!0,get:function(){return r.KERNEL}}),Object.defineProperty(exports,"LIGHT_ACCOUNT",{enumerable:!0,get:function(){return r.LIGHT_ACCOUNT}}),Object.defineProperty(exports,"SAFE",{enumerable:!0,get:function(){return r.SAFE}}),Object.defineProperty(exports,"THIRDWEB",{enumerable:!0,get:function(){return r.THIRDWEB}}),exports.LocalStorage=t.LocalStorage,exports.InMemoryCache=s.InMemoryCache,exports.MoonpayApiError=o.MoonpayApiError,exports.PrivyApiError=o.PrivyApiError,exports.PrivyClientError=o.PrivyClientError,exports.createErrorFormatter=o.createErrorFormatter,exports.errorIndicatesMfaCanceled=o.errorIndicatesMfaCanceled,exports.EmbeddedProviderError=i.EmbeddedProviderError,exports.PrivyConnectorError=i.PrivyConnectorError,exports.PrivyEmbeddedWalletErrorCode=i.PrivyEmbeddedWalletErrorCode,exports.PrivyProviderRpcError=i.PrivyProviderRpcError,exports.ProviderErrors=i.ProviderErrors,exports.errorIndicatesMaxMfaRetries=i.errorIndicatesMaxMfaRetries,exports.errorIndicatesMfaRateLimit=i.errorIndicatesMfaRateLimit,exports.errorIndicatesMfaTimeout=i.errorIndicatesMfaTimeout,exports.errorIndicatesMfaVerificationFailed=i.errorIndicatesMfaVerificationFailed,exports.errorIndicatesRecoveryIsNeeded=i.errorIndicatesRecoveryIsNeeded,exports.getUserEmbeddedEthereumWallet=a.getUserEmbeddedEthereumWallet,exports.getUserEmbeddedWallet=a.getUserEmbeddedWallet,exports.getAllUserEmbeddedEthereumWallets=n.getAllUserEmbeddedEthereumWallets,exports.getAllUserEmbeddedSolanaWallets=l.getAllUserEmbeddedSolanaWallets,exports.getAllUserEmbeddedBitcoinWallets=d.getAllUserEmbeddedBitcoinWallets,exports.getEntropyDetailsFromAccount=u.getEntropyDetailsFromAccount,exports.getEntropyDetailsFromUser=u.getEntropyDetailsFromUser,exports.getUserSmartWallet=p.getUserSmartWallet,exports.getJsonRpcEndpointFromChain=c.getJsonRpcEndpointFromChain,exports.populateTransactionRequest=c.populateTransactionRequest,exports.throwIfInvalidRecoveryUpgradePath=c.throwIfInvalidRecoveryUpgradePath,exports.countryCodesAndNumbers=m.countryCodesAndNumbers,exports.formatPhoneNumber=m.formatPhoneNumber,exports.getPhoneCountryCodeAndNumber=m.getPhoneCountryCodeAndNumber,exports.getPlaceholderPhoneNumber=m.getPlaceholderPhoneNumber,exports.lastFourDigits=m.lastFourDigits,exports.phoneNumberTypingFormatter=m.phoneNumberTypingFormatter,exports.validatePhoneNumber=m.validatePhoneNumber,exports.getUserEmbeddedSolanaWallet=j.getUserEmbeddedSolanaWallet,exports.toObjectKeys=q.toObjectKeys,exports.calculateTotalGasEstimate=g.calculateTotalGasEstimate,exports.QuantityToBigNumber=b.QuantityToBigNumber,exports.convertBigNumberish=b.convertBigNumberish,exports.toEthersUnsignedTransaction=b.toEthersUnsignedTransaction,exports.SolanaUsdcAddressMap=A.SolanaUsdcAddressMap,exports.UsdcAddressMap=A.UsdcAddressMap,exports.getIsTokenUsdc=A.getIsTokenUsdc,exports.chainToMoonpayCurrency=E.chainToMoonpayCurrency,exports.fundingMethodToMoonpayPaymentMethod=E.fundingMethodToMoonpayPaymentMethod,exports.isSupportedChainIdForMoonpay=E.isSupportedChainIdForMoonpay,exports.getCoinbaseOnRampUrl=y.getCoinbaseOnRampUrl,exports.isSupportedChainIdForCoinbaseOnramp=y.isSupportedChainIdForCoinbaseOnramp,exports.toCoinbaseAssetId=y.toCoinbaseAssetId,exports.toCoinbaseBlockchainFromChainId=y.toCoinbaseBlockchainFromChainId,exports.SolanaClient=x.SolanaClient,exports.createSiwsMessage=h.createSiwsMessage,exports.getSolanaRpcEndpointForCluster=C.getSolanaRpcEndpointForCluster,exports.getSolanaUsdcMintAddressForCluster=f.getSolanaUsdcMintAddressForCluster,exports.getSolanaClusterDisplayName=P.getSolanaClusterDisplayName,exports.ALL_WALLET_CLIENT_TYPES=S.ALL_WALLET_CLIENT_TYPES,exports.SUPPORTED_CONNECTOR_TYPES=S.SUPPORTED_CONNECTOR_TYPES,exports.formatLamportsAmount=v.formatLamportsAmount,exports.formatTokenAmount=v.formatTokenAmount,exports.formatWalletAddress=v.formatWalletAddress,exports.formatWeiAmount=v.formatWeiAmount,exports.create=M.create,exports.rpc=W.rpc,Object.defineProperty(exports,"getCountryCallingCode",{enumerable:!0,get:function(){return I.getCountryCallingCode}}),exports.delegatedActions=U.index,exports.crossApp=O.index,Object.keys(T).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return T[e]}})}));
@@ -0,0 +1 @@
1
+ "use strict";exports.noop=()=>{};
@@ -16,6 +16,18 @@ import { BigNumber, BigNumberish } from '@ethersproject/bignumber';
16
16
  import { UnsignedTransaction } from '@ethersproject/transactions';
17
17
  import { Hex, TypedDataDefinition } from 'viem';
18
18
 
19
+ type LogLevel = 'NONE' | 'ERROR' | 'WARN' | 'INFO' | 'DEBUG';
20
+ /**
21
+ * Interface for a logger for the privy client SDK
22
+ */
23
+ type Logger = {
24
+ readonly level: LogLevel;
25
+ readonly info: Console['log'];
26
+ readonly warn: Console['warn'];
27
+ readonly error: Console['error'];
28
+ readonly debug: Console['debug'];
29
+ };
30
+
19
31
  declare enum PrivyEmbeddedWalletErrorCode {
20
32
  MISSING_OR_INVALID_PRIVY_APP_ID = "missing_or_invalid_privy_app_id",
21
33
  MISSING_OR_INVALID_PRIVY_ACCOUNT_ID = "missing_or_invalid_privy_account_id",
@@ -4873,7 +4885,6 @@ declare class PhoneApi {
4873
4885
  type PrivyEmbeddedWalletProvider = EmbeddedWalletProvider;
4874
4886
  type PrivyEmbeddedSolanaWalletProvider = EmbeddedSolanaWalletProvider;
4875
4887
 
4876
- type LogLevel = 'ERROR' | 'WARN' | 'INFO' | 'DEBUG';
4877
4888
  declare const EMBEDDED_WALLET_CLIENT_TYPES: readonly ["privy"];
4878
4889
  type EmbeddedWalletClientType = (typeof EMBEDDED_WALLET_CLIENT_TYPES)[number];
4879
4890
  declare const INJECTED_WALLET_CLIENT_TYPES: readonly ["metamask", "phantom", "brave_wallet", "rainbow"];
@@ -6785,6 +6796,10 @@ declare class Privy {
6785
6796
  params?: Record<string, string | number>;
6786
6797
  headers?: HeadersInit;
6787
6798
  }): Promise<NonNullable<T['response']>>;
6799
+ /**
6800
+ * Internal logger for the Privy client.
6801
+ */
6802
+ get logger(): Logger;
6788
6803
  }
6789
6804
 
6790
6805
  declare class LocalStorage implements Storage {
@@ -16,6 +16,18 @@ import { BigNumber, BigNumberish } from '@ethersproject/bignumber';
16
16
  import { UnsignedTransaction } from '@ethersproject/transactions';
17
17
  import { Hex, TypedDataDefinition } from 'viem';
18
18
 
19
+ type LogLevel = 'NONE' | 'ERROR' | 'WARN' | 'INFO' | 'DEBUG';
20
+ /**
21
+ * Interface for a logger for the privy client SDK
22
+ */
23
+ type Logger = {
24
+ readonly level: LogLevel;
25
+ readonly info: Console['log'];
26
+ readonly warn: Console['warn'];
27
+ readonly error: Console['error'];
28
+ readonly debug: Console['debug'];
29
+ };
30
+
19
31
  declare enum PrivyEmbeddedWalletErrorCode {
20
32
  MISSING_OR_INVALID_PRIVY_APP_ID = "missing_or_invalid_privy_app_id",
21
33
  MISSING_OR_INVALID_PRIVY_ACCOUNT_ID = "missing_or_invalid_privy_account_id",
@@ -4873,7 +4885,6 @@ declare class PhoneApi {
4873
4885
  type PrivyEmbeddedWalletProvider = EmbeddedWalletProvider;
4874
4886
  type PrivyEmbeddedSolanaWalletProvider = EmbeddedSolanaWalletProvider;
4875
4887
 
4876
- type LogLevel = 'ERROR' | 'WARN' | 'INFO' | 'DEBUG';
4877
4888
  declare const EMBEDDED_WALLET_CLIENT_TYPES: readonly ["privy"];
4878
4889
  type EmbeddedWalletClientType = (typeof EMBEDDED_WALLET_CLIENT_TYPES)[number];
4879
4890
  declare const INJECTED_WALLET_CLIENT_TYPES: readonly ["metamask", "phantom", "brave_wallet", "rainbow"];
@@ -6785,6 +6796,10 @@ declare class Privy {
6785
6796
  params?: Record<string, string | number>;
6786
6797
  headers?: HeadersInit;
6787
6798
  }): Promise<NonNullable<T['response']>>;
6799
+ /**
6800
+ * Internal logger for the Privy client.
6801
+ */
6802
+ get logger(): Logger;
6788
6803
  }
6789
6804
 
6790
6805
  declare class LocalStorage implements Storage {
@@ -1 +1 @@
1
- import e from"./AppApi.mjs";import t from"./CrossAppApi.mjs";import r from"./DelegatedWalletsApi.mjs";import i from"./EmbeddedWalletApi.mjs";import s from"./MfaPromises.mjs";import{PrivyInternal as m}from"./PrivyInternal.mjs";import o from"./UserApi.mjs";import p from"./auth/AuthApi.mjs";import a from"./funding/FundingApi.mjs";import d from"./mfa/MfaApi.mjs";import n from"./recovery/RecoveryApi.mjs";import"@privy-io/public-api";import"../Token.mjs";import"jose";import"@privy-io/chains";import"../Error.mjs";import"../embedded/EmbeddedBitcoinWalletProvider.mjs";import"../embedded/errors.mjs";import"../embedded/types.mjs";import"../embedded/utils/index.mjs";import"@ethersproject/abstract-signer";import"@ethersproject/providers";import"../embedded/gas/arbitrum.mjs";import"@ethersproject/bignumber";import"../embedded/utils/ethers.mjs";import"../embedded/gas/bsc.mjs";import"../embedded/gas/op-stack.mjs";import"@ethersproject/contracts";import"@ethersproject/transactions";import"../embedded/gas/polygon.mjs";import"@ethersproject/units";import"fetch-retry";import"../embedded/utils/gas.mjs";import"../embedded/EmbeddedWalletProxy.mjs";import"../utils/sleep.mjs";import"../embedded/EventCallbackQueue.mjs";import"../embedded/withMfa.mjs";import"../embedded/EmbeddedWalletProvider.mjs";import"eventemitter3";import"../embedded/methods.mjs";import"../embedded/EmbeddedSolanaWalletProvider.mjs";import"../solana/getWalletPublicKeyFromTransaction.mjs";import"../solana/isVersionedTransaction.mjs";import"uuid";import"@privy-io/api-base";import"../Session.mjs";import"js-cookie";import"../utils/allSettled.mjs";import"../toAbortSignalTimeout.mjs";import"../utils/toSearchParams.mjs";import"./auth/CustomProviderApi.mjs";import"./auth/maybeCreateWalletOnLogin.mjs";import"../utils/getUserEmbeddedEthereumWallet.mjs";import"../utils/getAllUserEmbeddedEthereumWallets.mjs";import"../utils/getUserEmbeddedSolanaWallet.mjs";import"../utils/getAllUserEmbeddedSolanaWallets.mjs";import"../utils/shouldCreateEmbeddedEthWallet.mjs";import"../utils/shouldCreateEmbeddedSolWallet.mjs";import"./auth/EmailApi.mjs";import"./auth/FarcasterApi.mjs";import"./auth/FarcasterV2Api.mjs";import"./auth/GuestApi.mjs";import"./auth/OAuthApi.mjs";import"../pkce.mjs";import"./auth/PasskeyApi.mjs";import"./auth/PhoneApi.mjs";import"./auth/SiweApi.mjs";import"./auth/SiwsApi.mjs";import"./auth/SmartWalletApi.mjs";import"./funding/CoinbaseOnRampApi.mjs";import"./funding/MoonpayOnRampApi.mjs";import"../funding/moonpay.mjs";import"./mfa/MfaPasskeyApi.mjs";import"./mfa/MfaSmsApi.mjs";import"./recovery/RecoveryICloudApi.mjs";import"./recovery/RecoveryOAuthApi.mjs";class l{async initialize(){await this._privyInternal._initialize()}setMessagePoster(e){this.embeddedWallet.setMessagePoster(e)}addOAuthTokensListener(e){return this._privyInternal.session.on("oauth_tokens_granted",e),{unsubscribe:()=>{this._privyInternal.session.removeListener("oauth_tokens_granted",e)}}}setCallbacks(e){this._privyInternal.setCallbacks(e)}getAccessToken(){return this._privyInternal.getAccessToken()}getIdentityToken(){return this._privyInternal.getIdentityToken()}getCompiledPath(e,t){return this._privyInternal.getPath(e,t)}async fetchPrivyRoute(e,t){return this._privyInternal.fetch(e,t)}constructor({clientId:l,...h}){this._privyInternal=new m({...h,appClientId:l}),this.mfa=new d(this._privyInternal),this.mfaPromises=new s,this.embeddedWallet=new i(this._privyInternal,h.embeddedWalletMessagePoster,h.supportedChains,this.mfa,this.mfaPromises),this.user=new o(this._privyInternal),this.app=new e(this._privyInternal),this.auth=new p(this._privyInternal,this.embeddedWallet,h.storage,h.crypto),this.recovery=new n(this._privyInternal,h.storage,h.crypto),this.funding=new a(this._privyInternal),this.delegated=new r(this._privyInternal),this.crossApp=new t(this._privyInternal,h.storage)}}export{l as default};
1
+ import e from"./AppApi.mjs";import t from"./CrossAppApi.mjs";import r from"./DelegatedWalletsApi.mjs";import i from"./EmbeddedWalletApi.mjs";import s from"./MfaPromises.mjs";import{PrivyInternal as m}from"./PrivyInternal.mjs";import o from"./UserApi.mjs";import p from"./auth/AuthApi.mjs";import a from"./funding/FundingApi.mjs";import n from"./mfa/MfaApi.mjs";import d from"./recovery/RecoveryApi.mjs";import"@privy-io/public-api";import"../Token.mjs";import"jose";import"@privy-io/chains";import"../Error.mjs";import"../embedded/EmbeddedBitcoinWalletProvider.mjs";import"../embedded/errors.mjs";import"../embedded/types.mjs";import"../embedded/utils/index.mjs";import"@ethersproject/abstract-signer";import"@ethersproject/providers";import"../embedded/gas/arbitrum.mjs";import"@ethersproject/bignumber";import"../embedded/utils/ethers.mjs";import"../embedded/gas/bsc.mjs";import"../embedded/gas/op-stack.mjs";import"@ethersproject/contracts";import"@ethersproject/transactions";import"../embedded/gas/polygon.mjs";import"@ethersproject/units";import"fetch-retry";import"../embedded/utils/gas.mjs";import"../embedded/EmbeddedWalletProxy.mjs";import"../utils/sleep.mjs";import"../embedded/EventCallbackQueue.mjs";import"../embedded/withMfa.mjs";import"../embedded/EmbeddedWalletProvider.mjs";import"eventemitter3";import"../embedded/methods.mjs";import"../embedded/EmbeddedSolanaWalletProvider.mjs";import"../solana/getWalletPublicKeyFromTransaction.mjs";import"../solana/isVersionedTransaction.mjs";import"uuid";import"@privy-io/api-base";import"../Session.mjs";import"js-cookie";import"../utils/allSettled.mjs";import"../toAbortSignalTimeout.mjs";import"../utils/toSearchParams.mjs";import"./logger.mjs";import"../utils/noop.mjs";import"./auth/CustomProviderApi.mjs";import"./auth/maybeCreateWalletOnLogin.mjs";import"../utils/getUserEmbeddedEthereumWallet.mjs";import"../utils/getAllUserEmbeddedEthereumWallets.mjs";import"../utils/getUserEmbeddedSolanaWallet.mjs";import"../utils/getAllUserEmbeddedSolanaWallets.mjs";import"../utils/shouldCreateEmbeddedEthWallet.mjs";import"../utils/shouldCreateEmbeddedSolWallet.mjs";import"./auth/EmailApi.mjs";import"./auth/FarcasterApi.mjs";import"./auth/FarcasterV2Api.mjs";import"./auth/GuestApi.mjs";import"./auth/OAuthApi.mjs";import"../pkce.mjs";import"./auth/PasskeyApi.mjs";import"./auth/PhoneApi.mjs";import"./auth/SiweApi.mjs";import"./auth/SiwsApi.mjs";import"./auth/SmartWalletApi.mjs";import"./funding/CoinbaseOnRampApi.mjs";import"./funding/MoonpayOnRampApi.mjs";import"../funding/moonpay.mjs";import"./mfa/MfaPasskeyApi.mjs";import"./mfa/MfaSmsApi.mjs";import"./recovery/RecoveryICloudApi.mjs";import"./recovery/RecoveryOAuthApi.mjs";class l{async initialize(){await this._privyInternal._initialize()}setMessagePoster(e){this.embeddedWallet.setMessagePoster(e)}addOAuthTokensListener(e){return this._privyInternal.session.on("oauth_tokens_granted",e),{unsubscribe:()=>{this._privyInternal.session.removeListener("oauth_tokens_granted",e)}}}setCallbacks(e){this._privyInternal.setCallbacks(e)}getAccessToken(){return this._privyInternal.getAccessToken()}getIdentityToken(){return this._privyInternal.getIdentityToken()}getCompiledPath(e,t){return this._privyInternal.getPath(e,t)}async fetchPrivyRoute(e,t){return this._privyInternal.fetch(e,t)}get logger(){return this._privyInternal.logger}constructor({clientId:l,...h}){this._privyInternal=new m({...h,appClientId:l}),this.mfa=new n(this._privyInternal),this.mfaPromises=new s,this.embeddedWallet=new i(this._privyInternal,h.embeddedWalletMessagePoster,h.supportedChains,this.mfa,this.mfaPromises),this.user=new o(this._privyInternal),this.app=new e(this._privyInternal),this.auth=new p(this._privyInternal,this.embeddedWallet,h.storage,h.crypto),this.recovery=new d(this._privyInternal,h.storage,h.crypto),this.funding=new a(this._privyInternal),this.delegated=new r(this._privyInternal),this.crossApp=new t(this._privyInternal,h.storage)}}export{l as default};
@@ -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 c}from"../Session.mjs";import l from"../toAbortSignalTimeout.mjs";import{toSearchParams as d}from"../utils/toSearchParams.mjs";import"eventemitter3";import"jose";import"js-cookie";import"../Token.mjs";import"../utils/allSettled.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)}${d(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),c=await this._fetch(n,o),l=await c.json();if(c.status>299)throw new h(l);return l}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:l(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){console.error("Unable to load clientId",e)}try{this._analyticsId=t()}catch(e){console.error("Unable to generate uuidv4",e)}if(!this._analyticsId)return null;try{await this._storage.put(p,this._analyticsId)}catch(e){console.error(`Unable to store clientId: ${this._analyticsId}`,e)}return this._analyticsId}async destroyClientAnalyticsId(){try{return await this._storage.del(p)}catch(e){console.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 console.debug("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.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.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.debug(`[privy:refresh] response: ${i}`),t||this.callbacks?.setUser?.(s.user),"set"===i&&(await this.session.updateWithTokensResponse(s),this.debug("[privy:refresh] tokens stored")),"clear"===i&&(await this.session.destroyLocalState(),this.debug("[privy:refresh] tokens cleared"),t||this.callbacks?.setUser?.(null)),"ignore"===i&&s.token&&(await this.session.storeToken(s.token),this.debug("[privy:refresh] access token stored"),s.identity_token&&(this.debug("[privy:refresh] identity token stored"),await this.session.storeIdentityToken(s.identity_token))),this.debug("[privy:refresh] returning response"),s}catch(e){throw this.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.debug("[privy:getAccessToken] expected token received null"),t.token===e&&this.debug("[privy:getAccessToken] expected new token in response received existing"),s===e&&this.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 console.error(e),!1}}debug(e){"DEBUG"===this._logLevel&&console.debug(e)}constructor(t){this._sdkVersion="js-sdk-core:0.48.1",this._cache=new Map,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._logLevel=t.logLevel,this.callbacks=t.callbacks,this.nativeAppIdentifier=t.nativeAppIdentifier,this.session=new c({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.48.2",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};
@@ -0,0 +1 @@
1
+ import{noop as e}from"../utils/noop.mjs";let o={NONE:Number.NEGATIVE_INFINITY,ERROR:1,WARN:2,INFO:3,DEBUG:Number.POSITIVE_INFINITY};const r=({level:r}={level:"ERROR"})=>({get level(){return r},error:o[r]>=o.ERROR?console.error:e,warn:o[r]>=o.WARN?console.warn:e,info:o[r]>=o.INFO?console.info:e,debug:o[r]>=o.DEBUG?console.debug:e});export{r as toConsoleLogger};
@@ -1 +1 @@
1
- import e from"./client/Privy.mjs";export{BICONOMY,COINBASE_SMART_WALLET,KERNEL,LIGHT_ACCOUNT,SAFE,THIRDWEB}from"@privy-io/public-api";export{LocalStorage}from"./storage/LocalStorage.mjs";export{InMemoryCache}from"./storage/InMemoryStorage.mjs";export{MoonpayApiError,PrivyApiError,PrivyClientError,createErrorFormatter,errorIndicatesMfaCanceled}from"./Error.mjs";export{EmbeddedProviderError,PrivyConnectorError,PrivyEmbeddedWalletErrorCode,PrivyProviderRpcError,ProviderErrors,errorIndicatesMaxMfaRetries,errorIndicatesMfaRateLimit,errorIndicatesMfaTimeout,errorIndicatesMfaVerificationFailed,errorIndicatesRecoveryIsNeeded}from"./embedded/errors.mjs";export{getUserEmbeddedEthereumWallet,getUserEmbeddedWallet}from"./utils/getUserEmbeddedEthereumWallet.mjs";export{getAllUserEmbeddedEthereumWallets}from"./utils/getAllUserEmbeddedEthereumWallets.mjs";export{getAllUserEmbeddedSolanaWallets}from"./utils/getAllUserEmbeddedSolanaWallets.mjs";export{getAllUserEmbeddedBitcoinWallets}from"./utils/getAllUserEmbeddedBitcoinWallets.mjs";export{getEntropyDetailsFromAccount,getEntropyDetailsFromUser}from"./utils/entropy.mjs";export{getUserSmartWallet}from"./utils/getUserSmartWallet.mjs";export{getJsonRpcEndpointFromChain,populateTransactionRequest,throwIfInvalidRecoveryUpgradePath}from"./embedded/utils/index.mjs";export{countryCodesAndNumbers,formatPhoneNumber,getPhoneCountryCodeAndNumber,getPlaceholderPhoneNumber,lastFourDigits,phoneNumberTypingFormatter,validatePhoneNumber}from"./utils/phoneNumberUtils.mjs";export{getUserEmbeddedSolanaWallet}from"./utils/getUserEmbeddedSolanaWallet.mjs";export{toObjectKeys}from"./utils/toObjectKeys.mjs";export{calculateTotalGasEstimate}from"./embedded/utils/gas.mjs";export{QuantityToBigNumber,convertBigNumberish,toEthersUnsignedTransaction}from"./embedded/utils/ethers.mjs";export{SolanaUsdcAddressMap,UsdcAddressMap,getIsTokenUsdc}from"./utils/getIsTokenUsdc.mjs";export{chainToMoonpayCurrency,fundingMethodToMoonpayPaymentMethod,isSupportedChainIdForMoonpay}from"./funding/moonpay.mjs";export{getCoinbaseOnRampUrl,isSupportedChainIdForCoinbaseOnramp,toCoinbaseAssetId,toCoinbaseBlockchainFromChainId}from"./funding/coinbase.mjs";export{SolanaClient}from"./solana/client.mjs";export{createSiwsMessage}from"./solana/createSiwsMessage.mjs";export{getSolanaRpcEndpointForCluster}from"./solana/getSolanaRpcEndpointForCluster.mjs";export{getSolanaUsdcMintAddressForCluster}from"./solana/getSolanaUsdcMintAddressForCluster.mjs";export{getSolanaClusterDisplayName}from"./solana/getSolanaClusterDisplayName.mjs";export{ALL_WALLET_CLIENT_TYPES,SUPPORTED_CONNECTOR_TYPES}from"./types.mjs";export*from"@privy-io/chains";export{formatLamportsAmount,formatTokenAmount,formatWalletAddress,formatWeiAmount}from"./utils/formatters.mjs";export{create}from"./wallet-api/create.mjs";export{rpc}from"./wallet-api/rpc.mjs";export{getCountryCallingCode}from"libphonenumber-js/min";export{i as delegatedActions}from"./index-g0cxoRWQ.mjs";export{i as crossApp}from"./index-Bu3ySxLM.mjs";import"./client/AppApi.mjs";import"./client/CrossAppApi.mjs";import"./Token.mjs";import"jose";import"./client/DelegatedWalletsApi.mjs";import"./client/EmbeddedWalletApi.mjs";import"./embedded/EmbeddedBitcoinWalletProvider.mjs";import"./embedded/EmbeddedWalletProxy.mjs";import"./utils/sleep.mjs";import"./embedded/EventCallbackQueue.mjs";import"./embedded/withMfa.mjs";import"./embedded/EmbeddedWalletProvider.mjs";import"eventemitter3";import"./embedded/methods.mjs";import"./embedded/EmbeddedSolanaWalletProvider.mjs";import"./solana/getWalletPublicKeyFromTransaction.mjs";import"./solana/isVersionedTransaction.mjs";import"./client/MfaPromises.mjs";import"./client/PrivyInternal.mjs";import"fetch-retry";import"uuid";import"@privy-io/api-base";import"./Session.mjs";import"js-cookie";import"./utils/allSettled.mjs";import"./toAbortSignalTimeout.mjs";import"./utils/toSearchParams.mjs";import"./client/UserApi.mjs";import"./client/auth/AuthApi.mjs";import"./client/auth/CustomProviderApi.mjs";import"./client/auth/maybeCreateWalletOnLogin.mjs";import"./utils/shouldCreateEmbeddedEthWallet.mjs";import"./utils/shouldCreateEmbeddedSolWallet.mjs";import"./client/auth/EmailApi.mjs";import"./client/auth/FarcasterApi.mjs";import"./client/auth/FarcasterV2Api.mjs";import"./client/auth/GuestApi.mjs";import"./client/auth/OAuthApi.mjs";import"./pkce.mjs";import"./client/auth/PasskeyApi.mjs";import"./client/auth/PhoneApi.mjs";import"./client/auth/SiweApi.mjs";import"./client/auth/SiwsApi.mjs";import"./client/auth/SmartWalletApi.mjs";import"./client/funding/FundingApi.mjs";import"./client/funding/CoinbaseOnRampApi.mjs";import"./client/funding/MoonpayOnRampApi.mjs";import"./client/mfa/MfaApi.mjs";import"./client/mfa/MfaPasskeyApi.mjs";import"./client/mfa/MfaSmsApi.mjs";import"./client/recovery/RecoveryApi.mjs";import"./client/recovery/RecoveryICloudApi.mjs";import"./client/recovery/RecoveryOAuthApi.mjs";import"./embedded/types.mjs";import"@ethersproject/abstract-signer";import"@ethersproject/providers";import"./embedded/gas/arbitrum.mjs";import"@ethersproject/bignumber";import"./embedded/gas/bsc.mjs";import"./embedded/gas/op-stack.mjs";import"@ethersproject/contracts";import"@ethersproject/transactions";import"./embedded/gas/polygon.mjs";import"@ethersproject/units";import"libphonenumber-js/examples.mobile.json";import"viem";import"canonicalize";import"./action/delegatedActions/delegateWallet.mjs";import"./action/delegatedActions/utils.mjs";import"./action/delegatedActions/revokeWallets.mjs";import"./action/crossApp/loginWithCrossAppAuth.mjs";import"./action/crossApp/linkWithCrossAppAuth.mjs";import"./index-DTAjYY8z.mjs";import"./action/crossApp/wallet/signMessage.mjs";import"./action/crossApp/wallet/utils/isCrossAppWalletSmart.mjs";import"./action/crossApp/wallet/utils/sendCrossAppRequest.mjs";import"./action/crossApp/wallet/utils/getCrossAppAccountByWalletAddress.mjs";import"./action/crossApp/wallet/utils/getProviderAccessTokenOrRelink.mjs";import"./action/crossApp/wallet/utils/throwIfNotLoggedIn.mjs";import"./action/crossApp/wallet/signTypedData.mjs";import"./utils/typedData/generateDomainType.mjs";import"./action/crossApp/wallet/sendTransaction.mjs";export{e as default};
1
+ import e from"./client/Privy.mjs";export{BICONOMY,COINBASE_SMART_WALLET,KERNEL,LIGHT_ACCOUNT,SAFE,THIRDWEB}from"@privy-io/public-api";export{LocalStorage}from"./storage/LocalStorage.mjs";export{InMemoryCache}from"./storage/InMemoryStorage.mjs";export{MoonpayApiError,PrivyApiError,PrivyClientError,createErrorFormatter,errorIndicatesMfaCanceled}from"./Error.mjs";export{EmbeddedProviderError,PrivyConnectorError,PrivyEmbeddedWalletErrorCode,PrivyProviderRpcError,ProviderErrors,errorIndicatesMaxMfaRetries,errorIndicatesMfaRateLimit,errorIndicatesMfaTimeout,errorIndicatesMfaVerificationFailed,errorIndicatesRecoveryIsNeeded}from"./embedded/errors.mjs";export{getUserEmbeddedEthereumWallet,getUserEmbeddedWallet}from"./utils/getUserEmbeddedEthereumWallet.mjs";export{getAllUserEmbeddedEthereumWallets}from"./utils/getAllUserEmbeddedEthereumWallets.mjs";export{getAllUserEmbeddedSolanaWallets}from"./utils/getAllUserEmbeddedSolanaWallets.mjs";export{getAllUserEmbeddedBitcoinWallets}from"./utils/getAllUserEmbeddedBitcoinWallets.mjs";export{getEntropyDetailsFromAccount,getEntropyDetailsFromUser}from"./utils/entropy.mjs";export{getUserSmartWallet}from"./utils/getUserSmartWallet.mjs";export{getJsonRpcEndpointFromChain,populateTransactionRequest,throwIfInvalidRecoveryUpgradePath}from"./embedded/utils/index.mjs";export{countryCodesAndNumbers,formatPhoneNumber,getPhoneCountryCodeAndNumber,getPlaceholderPhoneNumber,lastFourDigits,phoneNumberTypingFormatter,validatePhoneNumber}from"./utils/phoneNumberUtils.mjs";export{getUserEmbeddedSolanaWallet}from"./utils/getUserEmbeddedSolanaWallet.mjs";export{toObjectKeys}from"./utils/toObjectKeys.mjs";export{calculateTotalGasEstimate}from"./embedded/utils/gas.mjs";export{QuantityToBigNumber,convertBigNumberish,toEthersUnsignedTransaction}from"./embedded/utils/ethers.mjs";export{SolanaUsdcAddressMap,UsdcAddressMap,getIsTokenUsdc}from"./utils/getIsTokenUsdc.mjs";export{chainToMoonpayCurrency,fundingMethodToMoonpayPaymentMethod,isSupportedChainIdForMoonpay}from"./funding/moonpay.mjs";export{getCoinbaseOnRampUrl,isSupportedChainIdForCoinbaseOnramp,toCoinbaseAssetId,toCoinbaseBlockchainFromChainId}from"./funding/coinbase.mjs";export{SolanaClient}from"./solana/client.mjs";export{createSiwsMessage}from"./solana/createSiwsMessage.mjs";export{getSolanaRpcEndpointForCluster}from"./solana/getSolanaRpcEndpointForCluster.mjs";export{getSolanaUsdcMintAddressForCluster}from"./solana/getSolanaUsdcMintAddressForCluster.mjs";export{getSolanaClusterDisplayName}from"./solana/getSolanaClusterDisplayName.mjs";export{ALL_WALLET_CLIENT_TYPES,SUPPORTED_CONNECTOR_TYPES}from"./types.mjs";export*from"@privy-io/chains";export{formatLamportsAmount,formatTokenAmount,formatWalletAddress,formatWeiAmount}from"./utils/formatters.mjs";export{create}from"./wallet-api/create.mjs";export{rpc}from"./wallet-api/rpc.mjs";export{getCountryCallingCode}from"libphonenumber-js/min";export{i as delegatedActions}from"./index-g0cxoRWQ.mjs";export{i as crossApp}from"./index-Bu3ySxLM.mjs";import"./client/AppApi.mjs";import"./client/CrossAppApi.mjs";import"./Token.mjs";import"jose";import"./client/DelegatedWalletsApi.mjs";import"./client/EmbeddedWalletApi.mjs";import"./embedded/EmbeddedBitcoinWalletProvider.mjs";import"./embedded/EmbeddedWalletProxy.mjs";import"./utils/sleep.mjs";import"./embedded/EventCallbackQueue.mjs";import"./embedded/withMfa.mjs";import"./embedded/EmbeddedWalletProvider.mjs";import"eventemitter3";import"./embedded/methods.mjs";import"./embedded/EmbeddedSolanaWalletProvider.mjs";import"./solana/getWalletPublicKeyFromTransaction.mjs";import"./solana/isVersionedTransaction.mjs";import"./client/MfaPromises.mjs";import"./client/PrivyInternal.mjs";import"fetch-retry";import"uuid";import"@privy-io/api-base";import"./Session.mjs";import"js-cookie";import"./utils/allSettled.mjs";import"./toAbortSignalTimeout.mjs";import"./utils/toSearchParams.mjs";import"./client/logger.mjs";import"./utils/noop.mjs";import"./client/UserApi.mjs";import"./client/auth/AuthApi.mjs";import"./client/auth/CustomProviderApi.mjs";import"./client/auth/maybeCreateWalletOnLogin.mjs";import"./utils/shouldCreateEmbeddedEthWallet.mjs";import"./utils/shouldCreateEmbeddedSolWallet.mjs";import"./client/auth/EmailApi.mjs";import"./client/auth/FarcasterApi.mjs";import"./client/auth/FarcasterV2Api.mjs";import"./client/auth/GuestApi.mjs";import"./client/auth/OAuthApi.mjs";import"./pkce.mjs";import"./client/auth/PasskeyApi.mjs";import"./client/auth/PhoneApi.mjs";import"./client/auth/SiweApi.mjs";import"./client/auth/SiwsApi.mjs";import"./client/auth/SmartWalletApi.mjs";import"./client/funding/FundingApi.mjs";import"./client/funding/CoinbaseOnRampApi.mjs";import"./client/funding/MoonpayOnRampApi.mjs";import"./client/mfa/MfaApi.mjs";import"./client/mfa/MfaPasskeyApi.mjs";import"./client/mfa/MfaSmsApi.mjs";import"./client/recovery/RecoveryApi.mjs";import"./client/recovery/RecoveryICloudApi.mjs";import"./client/recovery/RecoveryOAuthApi.mjs";import"./embedded/types.mjs";import"@ethersproject/abstract-signer";import"@ethersproject/providers";import"./embedded/gas/arbitrum.mjs";import"@ethersproject/bignumber";import"./embedded/gas/bsc.mjs";import"./embedded/gas/op-stack.mjs";import"@ethersproject/contracts";import"@ethersproject/transactions";import"./embedded/gas/polygon.mjs";import"@ethersproject/units";import"libphonenumber-js/examples.mobile.json";import"viem";import"canonicalize";import"./action/delegatedActions/delegateWallet.mjs";import"./action/delegatedActions/utils.mjs";import"./action/delegatedActions/revokeWallets.mjs";import"./action/crossApp/loginWithCrossAppAuth.mjs";import"./action/crossApp/linkWithCrossAppAuth.mjs";import"./index-DTAjYY8z.mjs";import"./action/crossApp/wallet/signMessage.mjs";import"./action/crossApp/wallet/utils/isCrossAppWalletSmart.mjs";import"./action/crossApp/wallet/utils/sendCrossAppRequest.mjs";import"./action/crossApp/wallet/utils/getCrossAppAccountByWalletAddress.mjs";import"./action/crossApp/wallet/utils/getProviderAccessTokenOrRelink.mjs";import"./action/crossApp/wallet/utils/throwIfNotLoggedIn.mjs";import"./action/crossApp/wallet/signTypedData.mjs";import"./utils/typedData/generateDomainType.mjs";import"./action/crossApp/wallet/sendTransaction.mjs";export{e as default};
@@ -0,0 +1 @@
1
+ const o=()=>{};export{o as noop};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@privy-io/js-sdk-core",
3
- "version": "0.48.1",
3
+ "version": "0.48.2",
4
4
  "description": "Vanilla JS client for the Privy Auth API",
5
5
  "keywords": [
6
6
  "authentication",