@privy-io/js-sdk-core 0.64.0 → 0.65.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/client/PrivyInternal.js +1 -1
- package/dist/cjs/embedded/EmbeddedWalletProvider.js +1 -1
- package/dist/cjs/embedded/EmbeddedWalletProvider.js.map +1 -1
- package/dist/cjs/embedded/stack/wallet-api-eth-transaction.js.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/dts/index.d.mts +12 -2
- package/dist/dts/index.d.ts +12 -2
- package/dist/esm/client/PrivyInternal.mjs +1 -1
- package/dist/esm/embedded/EmbeddedWalletProvider.mjs +1 -1
- package/dist/esm/embedded/EmbeddedWalletProvider.mjs.map +1 -1
- package/dist/esm/embedded/stack/wallet-api-eth-transaction.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/package.json +6 -6
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("fetch-retry"),t=require("@privy-io/api-base"),s=require("@privy-io/routes"),i=require("../Error.js"),r=require("../Session.js"),a=require("../toAbortSignalTimeout.js"),n=require("../utils/toSearchParams.js"),o=require("./logger.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"),require("../utils/noop.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 i.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:i}){return`${this.baseUrl}${s.getPathWithParams(e.path,t)}${n.toSearchParams(i)}`}async fetch(e,{body:t,params:s,query:r,headers:a,onRequest:n=this._beforeRequest.bind(this)}){let o=new Request(this.getPath(e,{params:s,query:r}),{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 i.PrivyApiError({...l,status:c.status});return l}async _beforeRequestWithoutInitialize(e){let t=await this.session.getPrivyAccessToken()??await this.session.getCustomerAccessToken(),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:a.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.getAccessTokenInternal(),this.beforeRequestWithoutRefresh(e)}async getAppConfig(){return await this.fetch(s.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){this.logger.error("Unable to load clientId",e)}try{this._analyticsId=this._crypto.randomUUID()}catch(e){this.logger.error("Unable to generate uuidv4",e)}if(this._analyticsId){try{await this._storage.put(l,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(l)}catch(e){this.logger.error("Unable to delete clientId",e)}}async createAnalyticsEvent(e,t){try{await this.fetch(s.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 i.PrivyClientError({code:"storage_error",error:"Unable to access storage"});let t=await this.session.getRefreshToken()??void 0,s=t??"key",r=this._cache.get(s);if(r)return this.logger.debug("[privy:refresh] found in-flight session refresh request, deduping"),await r;let a=this._refreshSession(t,e);this._cache.set(s,a);try{return await a}finally{this._cache.delete(s)}}async _refreshSession(e,r){let a=await this.session.getCustomerAccessToken();if(!this.session.hasRefreshCredentials(a,e??null))throw this.logger.debug("[privy:refresh] missing tokens, skipping request"),await this._initialize(),new i.PrivyApiError({code:t.PrivyErrorCode.MISSING_OR_INVALID_TOKEN,error:"No tokens found in storage",status:401});try{this.logger.debug(`[privy:refresh] fetching: ${s.RefreshSession.path}`);let t=await this.fetch(s.RefreshSession,{body:{refresh_token:e},onRequest:this.beforeRequestWithoutRefresh.bind(this)}),i=t.session_update_action;return this.logger.debug(`[privy:refresh] response: ${i}`),"set"===i&&(await this.session.updateWithTokensResponse(t),this.logger.debug("[privy:refresh] tokens stored")),"clear"===i&&(await this.session.destroyLocalState(),this.logger.debug("[privy:refresh] tokens cleared"),r||this.callbacks?.setUser?.(null)),"ignore"===i&&(t.token&&(await this.session.storeCustomerAccessToken(t.token),this.logger.debug("[privy:refresh] token stored (CAT)")),t.privy_access_token&&(await this.session.storePrivyAccessToken(t.privy_access_token),this.logger.debug("[privy:refresh] token stored (PAT)")),t.identity_token&&(this.logger.debug("[privy:refresh] token stored (IDT)"),await this.session.storeIdentityToken(t.identity_token))),this.logger.debug("[privy:refresh] returning response"),r||this.callbacks?.setUser?.(t.user),t}catch(e){throw this.logger.debug(`[privy:refresh] error: ${e.message??"unknown error"}`),e instanceof i.PrivyApiError&&e.code===t.PrivyErrorCode.MISSING_OR_INVALID_TOKEN&&(await this.session.destroyLocalState(),r||this.callbacks?.setUser?.(null)),e}}async getAccessToken(){let[e,t]=await Promise.all([this.session.getCustomerAccessToken(),this.session.getRefreshToken()]);if(e&&!this.session.tokenIsActive(e)&&this.session.hasRefreshCredentials(e,t)){let t=await this.refreshSession(),s=await this.session.getCustomerAccessToken();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&&!this.session.tokenIsActive(e)?(this.logger.debug("[privy:getAccessToken] unable to refresh inactive token"),this.callbacks?.setUser?.(null),await this.session.destroyLocalState(),null):e}async getAccessTokenInternal(){let e=await this.getAccessToken();return await this.session.getPrivyAccessToken()??e}async getIdentityToken(){return await this.session.getIdentityToken()}async isStorageAccessible(){try{let e=`privy:__storage__test-${this._crypto.randomUUID()}`,t="blobby";await this._storage.put(e,t);let s=await this._storage.get(e);return await this._storage.del(e),s===t}catch(e){return this.logger.error(e),!1}}constructor(e){this._sdkVersion="js-sdk-core:0.
|
|
1
|
+
"use strict";var e=require("fetch-retry"),t=require("@privy-io/api-base"),s=require("@privy-io/routes"),i=require("../Error.js"),r=require("../Session.js"),a=require("../toAbortSignalTimeout.js"),n=require("../utils/toSearchParams.js"),o=require("./logger.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"),require("../utils/noop.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 i.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:i}){return`${this.baseUrl}${s.getPathWithParams(e.path,t)}${n.toSearchParams(i)}`}async fetch(e,{body:t,params:s,query:r,headers:a,onRequest:n=this._beforeRequest.bind(this)}){let o=new Request(this.getPath(e,{params:s,query:r}),{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 i.PrivyApiError({...l,status:c.status});return l}async _beforeRequestWithoutInitialize(e){let t=await this.session.getPrivyAccessToken()??await this.session.getCustomerAccessToken(),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:a.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.getAccessTokenInternal(),this.beforeRequestWithoutRefresh(e)}async getAppConfig(){return await this.fetch(s.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){this.logger.error("Unable to load clientId",e)}try{this._analyticsId=this._crypto.randomUUID()}catch(e){this.logger.error("Unable to generate uuidv4",e)}if(this._analyticsId){try{await this._storage.put(l,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(l)}catch(e){this.logger.error("Unable to delete clientId",e)}}async createAnalyticsEvent(e,t){try{await this.fetch(s.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 i.PrivyClientError({code:"storage_error",error:"Unable to access storage"});let t=await this.session.getRefreshToken()??void 0,s=t??"key",r=this._cache.get(s);if(r)return this.logger.debug("[privy:refresh] found in-flight session refresh request, deduping"),await r;let a=this._refreshSession(t,e);this._cache.set(s,a);try{return await a}finally{this._cache.delete(s)}}async _refreshSession(e,r){let a=await this.session.getCustomerAccessToken();if(!this.session.hasRefreshCredentials(a,e??null))throw this.logger.debug("[privy:refresh] missing tokens, skipping request"),await this._initialize(),new i.PrivyApiError({code:t.PrivyErrorCode.MISSING_OR_INVALID_TOKEN,error:"No tokens found in storage",status:401});try{this.logger.debug(`[privy:refresh] fetching: ${s.RefreshSession.path}`);let t=await this.fetch(s.RefreshSession,{body:{refresh_token:e},onRequest:this.beforeRequestWithoutRefresh.bind(this)}),i=t.session_update_action;return this.logger.debug(`[privy:refresh] response: ${i}`),"set"===i&&(await this.session.updateWithTokensResponse(t),this.logger.debug("[privy:refresh] tokens stored")),"clear"===i&&(await this.session.destroyLocalState(),this.logger.debug("[privy:refresh] tokens cleared"),r||this.callbacks?.setUser?.(null)),"ignore"===i&&(t.token&&(await this.session.storeCustomerAccessToken(t.token),this.logger.debug("[privy:refresh] token stored (CAT)")),t.privy_access_token&&(await this.session.storePrivyAccessToken(t.privy_access_token),this.logger.debug("[privy:refresh] token stored (PAT)")),t.identity_token&&(this.logger.debug("[privy:refresh] token stored (IDT)"),await this.session.storeIdentityToken(t.identity_token))),this.logger.debug("[privy:refresh] returning response"),r||this.callbacks?.setUser?.(t.user),t}catch(e){throw this.logger.debug(`[privy:refresh] error: ${e.message??"unknown error"}`),e instanceof i.PrivyApiError&&e.code===t.PrivyErrorCode.MISSING_OR_INVALID_TOKEN&&(await this.session.destroyLocalState(),r||this.callbacks?.setUser?.(null)),e}}async getAccessToken(){let[e,t]=await Promise.all([this.session.getCustomerAccessToken(),this.session.getRefreshToken()]);if(e&&!this.session.tokenIsActive(e)&&this.session.hasRefreshCredentials(e,t)){let t=await this.refreshSession(),s=await this.session.getCustomerAccessToken();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&&!this.session.tokenIsActive(e)?(this.logger.debug("[privy:getAccessToken] unable to refresh inactive token"),this.callbacks?.setUser?.(null),await this.session.destroyLocalState(),null):e}async getAccessTokenInternal(){let e=await this.getAccessToken();return await this.session.getPrivyAccessToken()??e}async getIdentityToken(){return await this.session.getIdentityToken()}async isStorageAccessible(){try{let e=`privy:__storage__test-${this._crypto.randomUUID()}`,t="blobby";await this._storage.put(e,t);let s=await this._storage.get(e);return await this._storage.del(e),s===t}catch(e){return this.logger.error(e),!1}}constructor(e){this._sdkVersion="js-sdk-core:0.65.1",this._cache=new Map,this.logger=o.toLoggerWithLevel({level:e.logger?.level??e.logLevel??"ERROR",logger:e.logger??console}),this._storage=e.storage,this._crypto=e.crypto,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 r.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})}))}};
|
|
2
2
|
//# sourceMappingURL=PrivyInternal.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("eventemitter3"),t=require("viem"),r=require("@privy-io/ethereum"),a=require("../Error.js"),i=require("../wallet-api/unified-wallet.js"),n=require("./errors.js"),s=require("./stack/walletRpc.js"),o=require("./utils/index.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("./types.js"),require("../utils/encodings.js"),require("../wallet-api/rpc.js"),require("@privy-io/routes"),require("../wallet-api/generate-authorization-signature.js"),require("canonicalize"),require("@privy-io/encoding"),require("../wallet-api/types.js"),require("./stack/wallet-api-eth-transaction.js"),require("./stack/wallet-api-eth-typed-data.js"),require("viem/chains");var h=/*#__PURE__*/c(e);let d=new Set(["eth_sign","personal_sign","eth_signTypedData_v4","csw_signUserOperation","secp256k1_sign"]);class l extends h.default{async request(e){if(d.has(e.method))return this.handleIFrameRpc(e);switch(e.method){case"eth_accounts":case"eth_requestAccounts":return this._account.address?[this._account.address]:[];case"eth_chainId":return`0x${this._chainId.toString(16)}`;case"wallet_switchEthereumChain":return this.handleSwitchEthereumChain(e);case"eth_estimateGas":return this.handleEstimateGas(e);case"eth_signTransaction":{let t=e.params?.[0];return this.handleSignTransaction(t)}case"eth_sendTransaction":{let t=e.params?.[0];return this.handleSendTransaction(t)}case"eth_populateTransactionRequest":{let t=e.params?.[0];return this.handlePopulateTransaction(t)}default:return this.handleJsonRpc(e)}}ensureChainId(e){let t={chainId:this._chainId,...e};return this.internalSwitchEthereumChain(t.chainId),t}internalSwitchEthereumChain(e){e&&Number(e)!==this._chainId&&(this._chainId=Number(e),this._client=o.getPublicClient(this._chainId,this._chains,{rpcUrls:[]},{appId:this._privyInternal.appId}),this.emit("chainChanged",e))}async handlePopulateTransaction(e){let t=this.ensureChainId(e);if(r.isTempoTransactionRequest(t)){let e=r.toViemTempoTransactionSerializable(t),a=await this.requireTempoClient().prepareTransactionRequest({account:t.from??this._account.address,...e});return{...t,...a,type:r.TEMPO_TXN_TYPE_NUMBER}}let a=r.toViemTransactionSerializable(t),{type:i,...n}=await this._client.prepareTransactionRequest({account:t.from??this._account.address,...a});return{...n,type:r.STRING_TO_NUMBER_TXN_TYPE[i]}}async handleSignTransaction(e){let a={...e};for(let e of Object.keys(a)){let r=a[e];"bigint"==typeof r&&(a[e]=t.toHex(r))}return r.isTempoTransactionRequest(a)&&(a.calls=a.calls.map((e=>({...e,value:"bigint"==typeof e.value?t.toHex(e.value):e.value})))),await this.handleIFrameRpc({method:"eth_signTransaction",params:[a]})}async handleSendTransaction(e){let t=await this.handlePopulateTransaction(e),r=await this.handleSignTransaction(t);return await this.handleJsonRpc({method:"eth_sendRawTransaction",params:[r]})}async handleEstimateGas(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for eth_estimateGas");let t=e.params?.[0],a=this.ensureChainId(t);if(r.isTempoTransactionRequest(a)){let e=r.toViemTempoTransactionSerializable(a);return await this.requireTempoClient().estimateGas({account:a.from??this._account.address,...e})}let i=r.toViemTransactionSerializable(a);return await this._client.estimateGas({account:a.from??this._account.address,...i})}handleSwitchEthereumChain(e){let t;if(!e.params||!Array.isArray(e.params))throw new n.EmbeddedProviderError(`Invalid params for ${e.method}`,4200);if("string"==typeof e.params[0])t=e.params[0];else{if(!("chainId"in e.params[0])||"string"!=typeof e.params[0].chainId)throw new n.EmbeddedProviderError(`Invalid params for ${e.method}`,4200);t=e.params[0].chainId}this.internalSwitchEthereumChain(t)}async handleIFrameRpc(e){try{let t=await this._privyInternal.getAccessTokenInternal();if(!t)throw Error("Missing privy token. User must be logged in");this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_started",{method:e.method,address:this._account.address});let r=this._account;if(i.isUnifiedWallet(r)){let{data:a}=await s.walletRpc({context:{app:this._appApi,fetchPrivyRoute:(...e)=>this._privyInternal.fetch(...e),getCompiledPath:(...e)=>this._privyInternal.getPath(...e),signRequest:({message:e})=>this._walletProxy.signWithUserSigner({accessToken:t,message:e})},account:r,rpcRequest:{chainType:"ethereum",request:e}});return a}try{await this._walletProxy.connect({entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier,accessToken:t})}catch(e){let r=n.errorIndicatesRecoveryIsNeeded(e);if(r&&"privy"===this._account.recovery_method)await this._walletProxy.recover({entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier,accessToken:t});else{if(!r||!this._onNeedsRecovery)throw e;{let e;await new Promise((async(t,r)=>{e=setTimeout((()=>r(new a.PrivyClientError({code:"embedded_wallet_recovery_error",error:"User-owned recovery timed out"}))),12e4),await(this._onNeedsRecovery?.({recoveryMethod:this._account.recovery_method,onRecovered:()=>t(!0)}))})).finally((()=>clearTimeout(e)))}}}return(await this._walletProxy.rpcWallet({accessToken:t,request:e,entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier,hdWalletIndex:this._account.wallet_index,chainType:"ethereum"})).response.data}catch(t){console.error(t);let r=t instanceof Error?t.message:"Unable to make wallet request";throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_failed",{method:e.method,address:this._account.address,error:r}),new a.PrivyClientError({code:"embedded_wallet_request_error",error:r})}}async handleJsonRpc(e){return this._client.request(e)}requireTempoClient(){if(!o.isTempoChainId(this._chainId))throw new n.EmbeddedProviderError(`Cannot send a Tempo (type 118) transaction on chain ${this._chainId}`,4901);return this._client}toJSON(){return`PrivyEIP1193Provider { address: '${this._account.address}', chainId: ${this._chainId}, request: [Function] }`}constructor({walletProxy:e,privyInternal:t,account:r,entropyId:a,entropyIdVerifier:i,chains:n,onNeedsRecovery:s,chainId:c=n[0].id,appApi:h}){super(),this._walletProxy=e,this._privyInternal=t,this._account=r,this._entropyId=a,this._entropyIdVerifier=i,this._chainId=c,this._chains=n,this._onNeedsRecovery=s,this._client=o.getPublicClient(c,n,{rpcUrls:[]},{appId:h.appId}),this._appApi=h}}exports.EmbeddedWalletProvider=l;
|
|
1
|
+
"use strict";var e=require("eventemitter3"),t=require("viem"),r=require("@privy-io/ethereum"),a=require("../Error.js"),i=require("../wallet-api/unified-wallet.js"),n=require("./errors.js"),s=require("./stack/walletRpc.js"),o=require("./utils/index.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("./types.js"),require("../utils/encodings.js"),require("../wallet-api/rpc.js"),require("@privy-io/routes"),require("../wallet-api/generate-authorization-signature.js"),require("canonicalize"),require("@privy-io/encoding"),require("../wallet-api/types.js"),require("./stack/wallet-api-eth-transaction.js"),require("./stack/wallet-api-eth-typed-data.js"),require("viem/chains");var h=/*#__PURE__*/c(e);let d=new Set(["eth_sign","personal_sign","eth_signTypedData_v4","csw_signUserOperation","secp256k1_sign"]);class l extends h.default{async request(e){if(d.has(e.method))return this.handleIFrameRpc(e);switch(e.method){case"eth_accounts":case"eth_requestAccounts":return this._account.address?[this._account.address]:[];case"eth_chainId":return`0x${this._chainId.toString(16)}`;case"wallet_switchEthereumChain":return this.handleSwitchEthereumChain(e);case"eth_estimateGas":return this.handleEstimateGas(e);case"eth_signTransaction":{let t=e.params?.[0];return this.handleSignTransaction(t)}case"eth_sendTransaction":{let t=e.params?.[0];return this.handleSendTransaction(t)}case"eth_populateTransactionRequest":{let t=e.params?.[0];return this.handlePopulateTransaction(t)}default:return this.handleJsonRpc(e)}}ensureChainId(e){let t={chainId:this._chainId,...e};return this.internalSwitchEthereumChain(t.chainId),t}internalSwitchEthereumChain(e){e&&Number(e)!==this._chainId&&(this._chainId=Number(e),this._client=o.getPublicClient(this._chainId,this._chains,{rpcUrls:[]},{appId:this._privyInternal.appId}),this.emit("chainChanged",e))}async handlePopulateTransaction(e){let t=this.ensureChainId(e);if(r.isTempoTransactionRequest(t)){let e=r.toViemTempoTransactionSerializable(t),a=r.normalizeViemPreparedTempoTransaction(await this.requireTempoClient().prepareTransactionRequest({account:t.from??this._account.address,...e}),t.gasLimit);return{...t,...a,type:r.TEMPO_TXN_TYPE_NUMBER}}let a=r.toViemTransactionSerializable(t),{type:i,...n}=await this._client.prepareTransactionRequest({account:t.from??this._account.address,...a});return{...n,type:r.STRING_TO_NUMBER_TXN_TYPE[i]}}async handleSignTransaction(e){let a={...e};for(let e of Object.keys(a)){let r=a[e];"bigint"==typeof r&&(a[e]=t.toHex(r))}return r.isTempoTransactionRequest(a)&&(a.calls=a.calls.map((e=>({...e,value:"bigint"==typeof e.value?t.toHex(e.value):e.value})))),await this.handleIFrameRpc({method:"eth_signTransaction",params:[a]})}async handleSendTransaction(e){let t=await this.handlePopulateTransaction(e),r=await this.handleSignTransaction(t);return await this.handleJsonRpc({method:"eth_sendRawTransaction",params:[r]})}async handleEstimateGas(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for eth_estimateGas");let t=e.params?.[0],a=this.ensureChainId(t);if(r.isTempoTransactionRequest(a)){let e=r.toViemTempoTransactionSerializable(a);return await this.requireTempoClient().estimateGas({account:a.from??this._account.address,...e})}let i=r.toViemTransactionSerializable(a);return await this._client.estimateGas({account:a.from??this._account.address,...i})}handleSwitchEthereumChain(e){let t;if(!e.params||!Array.isArray(e.params))throw new n.EmbeddedProviderError(`Invalid params for ${e.method}`,4200);if("string"==typeof e.params[0])t=e.params[0];else{if(!("chainId"in e.params[0])||"string"!=typeof e.params[0].chainId)throw new n.EmbeddedProviderError(`Invalid params for ${e.method}`,4200);t=e.params[0].chainId}this.internalSwitchEthereumChain(t)}async handleIFrameRpc(e){try{let t=await this._privyInternal.getAccessTokenInternal();if(!t)throw Error("Missing privy token. User must be logged in");this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_started",{method:e.method,address:this._account.address});let r=this._account;if(i.isUnifiedWallet(r)){let{data:a}=await s.walletRpc({context:{app:this._appApi,fetchPrivyRoute:(...e)=>this._privyInternal.fetch(...e),getCompiledPath:(...e)=>this._privyInternal.getPath(...e),signRequest:({message:e})=>this._walletProxy.signWithUserSigner({accessToken:t,message:e})},account:r,rpcRequest:{chainType:"ethereum",request:e}});return a}try{await this._walletProxy.connect({entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier,accessToken:t})}catch(e){let r=n.errorIndicatesRecoveryIsNeeded(e);if(r&&"privy"===this._account.recovery_method)await this._walletProxy.recover({entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier,accessToken:t});else{if(!r||!this._onNeedsRecovery)throw e;{let e;await new Promise((async(t,r)=>{e=setTimeout((()=>r(new a.PrivyClientError({code:"embedded_wallet_recovery_error",error:"User-owned recovery timed out"}))),12e4),await(this._onNeedsRecovery?.({recoveryMethod:this._account.recovery_method,onRecovered:()=>t(!0)}))})).finally((()=>clearTimeout(e)))}}}return(await this._walletProxy.rpcWallet({accessToken:t,request:e,entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier,hdWalletIndex:this._account.wallet_index,chainType:"ethereum"})).response.data}catch(t){console.error(t);let r=t instanceof Error?t.message:"Unable to make wallet request";throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_failed",{method:e.method,address:this._account.address,error:r}),new a.PrivyClientError({code:"embedded_wallet_request_error",error:r})}}async handleJsonRpc(e){return this._client.request(e)}requireTempoClient(){if(!o.isTempoChainId(this._chainId))throw new n.EmbeddedProviderError(`Cannot send a Tempo (type 118) transaction on chain ${this._chainId}`,4901);return this._client}toJSON(){return`PrivyEIP1193Provider { address: '${this._account.address}', chainId: ${this._chainId}, request: [Function] }`}constructor({walletProxy:e,privyInternal:t,account:r,entropyId:a,entropyIdVerifier:i,chains:n,onNeedsRecovery:s,chainId:c=n[0].id,appApi:h}){super(),this._walletProxy=e,this._privyInternal=t,this._account=r,this._entropyId=a,this._entropyIdVerifier=i,this._chainId=c,this._chains=n,this._onNeedsRecovery=s,this._client=o.getPublicClient(c,n,{rpcUrls:[]},{appId:h.appId}),this._appApi=h}}exports.EmbeddedWalletProvider=l;
|
|
2
2
|
//# sourceMappingURL=EmbeddedWalletProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmbeddedWalletProvider.js","sources":["../../../src/embedded/EmbeddedWalletProvider.ts"],"names":["IFRAME_PASSTHROUGH_RPC_METHODS","Set","EmbeddedWalletProvider","EventEmitter","request","has","method","this","handleIFrameRpc","_account","address","_chainId","toString","handleSwitchEthereumChain","handleEstimateGas","data","params","handleSignTransaction","handleSendTransaction","handlePopulateTransaction","handleJsonRpc","ensureChainId","tx","ensureTxChainId","chainId","internalSwitchEthereumChain","Number","_client","getPublicClient","_chains","rpcUrls","appId","_privyInternal","emit","txRequest","isTempoTransactionRequest","viemTxn","toViemTempoTransactionSerializable","preparedTxn","requireTempoClient","prepareTransactionRequest","account","from","type","TEMPO_TXN_TYPE_NUMBER","toViemTransactionSerializable","STRING_TO_NUMBER_TXN_TYPE","serializable","key","Object","keys","val","toHex","calls","map","e","call","value","populatedTx","signedTx","Array","isArray","Error","viemTempoTxn","estimateGas","args","newChain","EmbeddedProviderError","token","getAccessTokenInternal","createAnalyticsEvent","isUnifiedWallet","walletRpc","context","app","_appApi","fetchPrivyRoute","fetch","getCompiledPath","getPath","signRequest","message","_walletProxy","signWithUserSigner","accessToken","rpcRequest","chainType","connect","entropyId","_entropyId","entropyIdVerifier","_entropyIdVerifier","needsRecovery","errorIndicatesRecoveryIsNeeded","recovery_method","recover","_onNeedsRecovery","timeout","Promise","async","res","rej","setTimeout","PrivyClientError","code","error","recoveryMethod","onRecovered","finally","clearTimeout","rpcWallet","hdWalletIndex","wallet_index","response","console","isTempoChainId","toJSON","constructor","walletProxy","privyInternal","chains","onNeedsRecovery","id","appApi","super"],"mappings":"
|
|
1
|
+
{"version":3,"file":"EmbeddedWalletProvider.js","sources":["../../../src/embedded/EmbeddedWalletProvider.ts"],"names":["IFRAME_PASSTHROUGH_RPC_METHODS","Set","EmbeddedWalletProvider","EventEmitter","request","has","method","this","handleIFrameRpc","_account","address","_chainId","toString","handleSwitchEthereumChain","handleEstimateGas","data","params","handleSignTransaction","handleSendTransaction","handlePopulateTransaction","handleJsonRpc","ensureChainId","tx","ensureTxChainId","chainId","internalSwitchEthereumChain","Number","_client","getPublicClient","_chains","rpcUrls","appId","_privyInternal","emit","txRequest","isTempoTransactionRequest","viemTxn","toViemTempoTransactionSerializable","preparedTxn","normalizeViemPreparedTempoTransaction","requireTempoClient","prepareTransactionRequest","account","from","gasLimit","type","TEMPO_TXN_TYPE_NUMBER","toViemTransactionSerializable","STRING_TO_NUMBER_TXN_TYPE","serializable","key","Object","keys","val","toHex","calls","map","e","call","value","populatedTx","signedTx","Array","isArray","Error","viemTempoTxn","estimateGas","args","newChain","EmbeddedProviderError","token","getAccessTokenInternal","createAnalyticsEvent","isUnifiedWallet","walletRpc","context","app","_appApi","fetchPrivyRoute","fetch","getCompiledPath","getPath","signRequest","message","_walletProxy","signWithUserSigner","accessToken","rpcRequest","chainType","connect","entropyId","_entropyId","entropyIdVerifier","_entropyIdVerifier","needsRecovery","errorIndicatesRecoveryIsNeeded","recovery_method","recover","_onNeedsRecovery","timeout","Promise","async","res","rej","setTimeout","PrivyClientError","code","error","recoveryMethod","onRecovered","finally","clearTimeout","rpcWallet","hdWalletIndex","wallet_index","response","console","isTempoChainId","toJSON","constructor","walletProxy","privyInternal","chains","onNeedsRecovery","id","appApi","super"],"mappings":"6tBAiFA,IAAMA,EAAiC,IAAIC,IAAI,CAC7C,WACA,gBACA,uBACA,wBACA,mBAGK,MAAMC,UAA+BC,EAAAA,QAiD1C,aAAMC,CAAQA,GAGZ,GAAIJ,EAA+BK,IAAID,EAAQE,QAC7C,OAAOC,KAAKC,gBAAgBJ,GAG9B,OAAQA,EAAQE,QACd,IAAK,eACL,IAAK,sBACH,OAAOC,KAAKE,SAASC,QAAU,CAACH,KAAKE,SAASC,SAAW,GAE3D,IAAK,cACH,MAAO,KAAKH,KAAKI,SAASC,SAAS,MAErC,IAAK,6BACH,OAAOL,KAAKM,0BAA0BT,GAExC,IAAK,kBACH,OAAOG,KAAKO,kBAAkBV,GAEhC,IAAK,sBAAuB,CAC1B,IAAMW,EAAOX,EAAQY,SAAS,GAG9B,OAAOT,KAAKU,sBAAsBF,EACpC,CACA,IAAK,sBAAuB,CAC1B,IAAMA,EAAOX,EAAQY,SAAS,GAG9B,OAAOT,KAAKW,sBAAsBH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,EAASkG,EAAQ,CAAC5F,QAAS,IAAK,CAACC,MAAO8F,EAAO9F,QAC9ExB,KAAKsE,QAAUgD,CACjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet-api-eth-transaction.js","sources":["../../../../src/embedded/stack/wallet-api-eth-transaction.ts"],"names":["quantityToHex","val","BigInt","toString","isHexEncoded","test","Error","bytesToHex","utf8ToBytes","transaction","isTempoTransactionRequest","type","TEMPO_TXN_TYPE_NUMBER","from","chain_id","chainId","nonce","nonce_key","nonceKey","gas_limit","gasLimit","max_fee_per_gas","maxFeePerGas","max_priority_fee_per_gas","maxPriorityFeePerGas","fee_token","feeToken","valid_after","validAfter","valid_before","validBefore","calls","map","e","call","to","data","value","undefined","encodeTransactionData","Buffer","Uint8Array","gas_price","gasPrice"],"mappings":"
|
|
1
|
+
{"version":3,"file":"wallet-api-eth-transaction.js","sources":["../../../../src/embedded/stack/wallet-api-eth-transaction.ts"],"names":["quantityToHex","val","BigInt","toString","isHexEncoded","test","Error","bytesToHex","utf8ToBytes","transaction","isTempoTransactionRequest","type","TEMPO_TXN_TYPE_NUMBER","from","chain_id","chainId","nonce","nonce_key","nonceKey","gas_limit","gasLimit","max_fee_per_gas","maxFeePerGas","max_priority_fee_per_gas","maxPriorityFeePerGas","fee_token","feeToken","valid_after","validAfter","valid_before","validBefore","calls","map","e","call","to","data","value","undefined","encodeTransactionData","Buffer","Uint8Array","gas_price","gasPrice"],"mappings":"uFAkFA,SAASA,EAAcC,GACrB,GAAmB,iBAARA,GAAoB,iBAAOA,EAAkB,CAEtD,MAAO,KADOC,OAAOD,GACHE,SAAS,KAAK,CAGlC,GAAI,iBAAOF,EAAkB,CAC3B,GAAIG,EAAAA,aAAaH,GAAM,OAAOA,EAK9B,IAAK,QAAQI,KAAKJ,GAChB,MAAMK,MAAU,0DAA0DL,KAE5E,OAAOM,EAAAA,WAAWC,EAAAA,YAAYP,GAChC,CAGF,2CAnFO,SACLQ,GAAqF,OAEjFC,EAAAA,0BAA0BD,GA2BvB,CACLE,KAAMC,wBACNC,KAAMJ,EAAYI,KAClBC,SAAUd,EA7BiCS,EA6BPM,SACpCC,MAAOhB,EAAcS,EAAYO,OACjCC,UAAWjB,EAAcS,EAAYS,UACrCC,UAAWnB,EAhCgCS,EAgCNW,UACrCC,gBAAiBrB,EAjC0BS,EAiCAa,cAC3CC,yBAA0BvB,EAAcS,EAAYe,sBACpDC,UAnC2ChB,EAmCpBiB,SACvBC,YAAa3B,EAAcS,EAAYmB,YACvCC,aAAc7B,EAAcS,EAAYqB,aACxCC,MAAOtB,EAAYsB,MAAMC,KAAIC,IAACC,CAC5BC,GAAID,EAAKC,GACTC,KAAMF,EAAKE,KACXC,MAAOrC,EAAckC,EAAKG,YAjCvB,CACLxB,KAAMJ,EAAYI,KAClBsB,GAAI1B,EAAY0B,SAAMG,EACtBtB,MAAOhB,EAAcS,EAAYO,OACjCF,SAAUd,EAAcS,EAAYM,SACpCqB,KAAMG,SAiCqBH,GAC7B,QAAI,IAAOA,EAAAA,MAIS,iBAATA,EAEFhC,EAAAA,aAAagC,GAAQA,EAAO7B,EAAAA,WAAWC,EAAAA,YAAY4B,IAIrD7B,EAAAA,WAAWiC,OAAO3B,KAAK4B,WAAW5B,KAAKuB,IAChD,CA7CUG,CAXsC9B,EAWJ2B,MACxCC,MAAOrC,EAZqCS,EAYX4B,OACjC1B,KAAMF,EAAYE,KAClBQ,UAAWnB,EAdiCS,EAcPW,UACrCsB,UAAW1C,EAfiCS,EAePkC,UACrCtB,gBAAiBrB,EAhB2BS,EAgBDa,cAC3CC,yBAA0BvB,EAjBkBS,EAiBQe,sBAhBxD"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./client/Privy.js"),r=require("./storage/LocalStorage.js"),t=require("./storage/InMemoryStorage.js"),s=require("./Error.js"),i=require("./embedded/errors.js"),o=require("./utils/getUserEmbeddedEthereumWallet.js"),a=require("./utils/getAllUserEmbeddedEthereumWallets.js"),l=require("./utils/getAllUserEmbeddedSolanaWallets.js"),n=require("./utils/getAllUserEmbeddedBitcoinWallets.js"),d=require("./utils/embedded-wallets.js"),u=require("./utils/entropy.js"),p=require("./utils/getUserSmartWallet.js"),c=require("./embedded/utils/index.js"),m=require("./utils/phoneNumberUtils.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./client/Privy.js"),r=require("./storage/LocalStorage.js"),t=require("./storage/InMemoryStorage.js"),s=require("./Error.js"),i=require("./embedded/errors.js"),o=require("./utils/getUserEmbeddedEthereumWallet.js"),a=require("./utils/getAllUserEmbeddedEthereumWallets.js"),l=require("./utils/getAllUserEmbeddedSolanaWallets.js"),n=require("./utils/getAllUserEmbeddedBitcoinWallets.js"),d=require("./utils/embedded-wallets.js"),u=require("./utils/entropy.js"),p=require("./utils/getUserSmartWallet.js"),c=require("./embedded/utils/index.js"),m=require("./embedded/stack/wallet-api-eth-transaction.js"),q=require("./utils/phoneNumberUtils.js"),j=require("./utils/getUserEmbeddedSolanaWallet.js"),g=require("./utils/toObjectKeys.js"),A=require("./utils/getIsTokenUsdc.js"),x=require("./utils/generateWalletIdempotencyKey.js"),b=require("./funding/moonpay.js"),y=require("./funding/coinbase.js"),E=require("./solana/client.js"),h=require("./solana/createSiwsMessage.js"),C=require("./solana/getSolanaRpcEndpointForCluster.js"),S=require("./solana/getSolanaUsdcMintAddressForCluster.js"),W=require("./solana/getSolanaClusterDisplayName.js"),f=require("./types.js"),P=require("@privy-io/chains"),v=require("./utils/formatters.js"),M=require("./wallet-api/generate-authorization-signature.js"),U=require("./wallet-api/create.js"),I=require("./wallet-api/rpc.js"),T=require("./wallet-api/raw-sign.js"),w=require("./wallet-api/get-wallet.js"),R=require("./wallet-api/update-wallet.js"),F=require("./wallet-api/unified-wallet.js"),N=require("./embedded/stack/session-signers.js"),O=require("./solana/ConnectedStandardSolanaWallet.js"),k=require("./index-DzfqDJJ9.js"),L=require("./index-BDWdfIuK.js"),_=require("libphonenumber-js/min");require("./crypto/resolve.js"),require("./client/AppApi.js"),require("@privy-io/routes"),require("./client/CrossAppApi.js"),require("./Token.js"),require("jose"),require("./client/DelegatedWalletsApi.js"),require("./client/EmbeddedWalletApi.js"),require("./embedded/EmbeddedBitcoinWalletProvider.js"),require("./embedded/stack/walletCreate.js"),require("./embedded/EmbeddedWalletProxy.js"),require("./utils/sleep.js"),require("./embedded/EventCallbackQueue.js"),require("./embedded/withMfa.js"),require("./embedded/EmbeddedWalletProvider.js"),require("eventemitter3"),require("viem"),require("@privy-io/ethereum"),require("./embedded/stack/walletRpc.js"),require("./utils/encodings.js"),require("./embedded/stack/wallet-api-eth-typed-data.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("@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("viem/chains"),require("libphonenumber-js/examples.mobile.json"),require("canonicalize"),require("@privy-io/encoding"),require("./wallet-api/types.js"),require("./action/delegatedActions/utils.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"),require("./action/delegatedActions/delegateWallet.js"),require("./action/delegatedActions/revokeWallets.js");exports.default=e.default,exports.LocalStorage=r.LocalStorage,exports.InMemoryCache=t.InMemoryCache,exports.MoonpayApiError=s.MoonpayApiError,exports.PrivyApiError=s.PrivyApiError,exports.PrivyClientError=s.PrivyClientError,exports.createErrorFormatter=s.createErrorFormatter,exports.errorIndicatesMfaCanceled=s.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=o.getUserEmbeddedEthereumWallet,exports.getUserEmbeddedWallet=o.getUserEmbeddedWallet,exports.getAllUserEmbeddedEthereumWallets=a.getAllUserEmbeddedEthereumWallets,exports.getAllUserEmbeddedSolanaWallets=l.getAllUserEmbeddedSolanaWallets,exports.getAllUserEmbeddedBitcoinWallets=n.getAllUserEmbeddedBitcoinWallets,exports.isEmbeddedWalletAccount=d.isEmbeddedWalletAccount,exports.getEntropyDetailsFromAccount=u.getEntropyDetailsFromAccount,exports.getEntropyDetailsFromUser=u.getEntropyDetailsFromUser,exports.getUserSmartWallet=p.getUserSmartWallet,exports.getJsonRpcEndpointFromChain=c.getJsonRpcEndpointFromChain,exports.throwIfInvalidRecoveryUpgradePath=c.throwIfInvalidRecoveryUpgradePath,exports.toWalletApiUnsignedEthTransaction=m.toWalletApiUnsignedEthTransaction,exports.countryCodesAndNumbers=q.countryCodesAndNumbers,exports.formatPhoneNumber=q.formatPhoneNumber,exports.getPhoneCountryCodeAndNumber=q.getPhoneCountryCodeAndNumber,exports.getPlaceholderPhoneNumber=q.getPlaceholderPhoneNumber,exports.lastFourDigits=q.lastFourDigits,exports.phoneNumberTypingFormatter=q.phoneNumberTypingFormatter,exports.validatePhoneNumber=q.validatePhoneNumber,exports.getUserEmbeddedSolanaWallet=j.getUserEmbeddedSolanaWallet,exports.toObjectKeys=g.toObjectKeys,exports.SolanaUsdcAddressMap=A.SolanaUsdcAddressMap,exports.UsdcAddressMap=A.UsdcAddressMap,exports.getIsTokenUsdc=A.getIsTokenUsdc,exports.generateWalletIdempotencyKey=x.generateWalletIdempotencyKey,exports.chainToMoonpayCurrency=b.chainToMoonpayCurrency,exports.fundingMethodToMoonpayPaymentMethod=b.fundingMethodToMoonpayPaymentMethod,exports.isSupportedChainIdForMoonpay=b.isSupportedChainIdForMoonpay,exports.getCoinbaseOnRampUrl=y.getCoinbaseOnRampUrl,exports.isSupportedChainIdForCoinbaseOnramp=y.isSupportedChainIdForCoinbaseOnramp,exports.toCoinbaseAssetId=y.toCoinbaseAssetId,exports.toCoinbaseBlockchainFromChainId=y.toCoinbaseBlockchainFromChainId,exports.SolanaClient=E.SolanaClient,exports.createSiwsMessage=h.createSiwsMessage,exports.getSolanaRpcEndpointForCluster=C.getSolanaRpcEndpointForCluster,exports.getSolanaUsdcMintAddressForCluster=S.getSolanaUsdcMintAddressForCluster,exports.getSolanaClusterDisplayName=W.getSolanaClusterDisplayName,exports.ALL_WALLET_CLIENT_TYPES=f.ALL_WALLET_CLIENT_TYPES,exports.SUPPORTED_CONNECTOR_TYPES=f.SUPPORTED_CONNECTOR_TYPES,exports.formatLamportsAmount=v.formatLamportsAmount,exports.formatTokenAmount=v.formatTokenAmount,exports.formatWalletAddress=v.formatWalletAddress,exports.formatWeiAmount=v.formatWeiAmount,exports.generateAuthorizationSignature=M.generateAuthorizationSignature,exports.create=U.create,exports.rpc=I.rpc,exports.rawSign=T.rawSign,exports.getWallet=w.getWallet,exports.updateWallet=R.updateWallet,exports.isUnifiedWallet=F.isUnifiedWallet,exports.addSessionSigners=N.addSessionSigners,exports.removeSessionSigners=N.removeSessionSigners,exports.ConnectedStandardSolanaWallet=O.ConnectedStandardSolanaWallet,exports.crossApp=k.index,exports.delegatedActions=L.index,Object.defineProperty(exports,"getCountryCallingCode",{enumerable:!0,get:function(){return _.getCountryCallingCode}}),exports.BICONOMY="biconomy",exports.COINBASE_SMART_WALLET="coinbase_smart_wallet",exports.KERNEL="kernel",exports.LIGHT_ACCOUNT="light_account",exports.NEXUS="nexus",exports.SAFE="safe",exports.THIRDWEB="thirdweb",Object.keys(P).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return P[e]}})}));
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"names":[],"mappings":"mkSAewB,yCAEa,uCAEf,+BAEO,8BAMR,qBAJD,wBAEI"}
|
package/dist/dts/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _privy_io_api_types from '@privy-io/api-types';
|
|
2
|
-
import { PasskeyAuthenticatorVerifyResponse, LinkedAccountEmbeddedWallet, LinkedAccountEthereumEmbeddedWallet, LinkedAccountSolanaEmbeddedWallet, User, SmartWalletConfiguration, OAuthTokens, LinkedAccountBitcoinSegwitEmbeddedWallet, LinkedAccountBitcoinTaprootEmbeddedWallet, AuthenticatedUser, OAuthProviderID, SmartWalletType as SmartWalletType$1, CoinbaseOnRampInitInput, MoonpayOnRampSignInput, MfaPasskeyInitRequestBody, MfaSMSInitRequestBody, LinkedAccount, LinkedAccountSmartWallet, CoinbaseOnRampInitResponse, WalletCreateParams, Wallet, WalletRpcParams, WalletRpcResponse, WalletRawSignParams, RawSignResponse, WalletUpdateParams, LinkedAccountEmbeddedWalletWithID } from '@privy-io/api-types';
|
|
2
|
+
import { PasskeyAuthenticatorVerifyResponse, LinkedAccountEmbeddedWallet, LinkedAccountEthereumEmbeddedWallet, LinkedAccountSolanaEmbeddedWallet, User, SmartWalletConfiguration, OAuthTokens, LinkedAccountBitcoinSegwitEmbeddedWallet, LinkedAccountBitcoinTaprootEmbeddedWallet, AuthenticatedUser, OAuthProviderID, SmartWalletType as SmartWalletType$1, CoinbaseOnRampInitInput, MoonpayOnRampSignInput, MfaPasskeyInitRequestBody, MfaSMSInitRequestBody, LinkedAccount, LinkedAccountSmartWallet, UnsignedEthereumTransaction, CoinbaseOnRampInitResponse, WalletCreateParams, Wallet, WalletRpcParams, WalletRpcResponse, WalletRawSignParams, RawSignResponse, WalletUpdateParams, LinkedAccountEmbeddedWalletWithID } from '@privy-io/api-types';
|
|
3
3
|
export { OAuthProviderID } from '@privy-io/api-types';
|
|
4
4
|
import { Chain, RpcConfig } from '@privy-io/chains';
|
|
5
5
|
export * from '@privy-io/chains';
|
|
@@ -8,6 +8,7 @@ import EventEmitter from 'eventemitter3';
|
|
|
8
8
|
import { PrivyErrorCode } from '@privy-io/api-base';
|
|
9
9
|
import { Transaction, VersionedTransaction, Connection, SendOptions } from '@solana/web3.js';
|
|
10
10
|
import { AuthenticationResponseJSON, RegistrationResponseJSON } from '@simplewebauthn/types';
|
|
11
|
+
import { StrictUnsignedTransactionRequest, StrictUnsignedTempoTransactionRequest } from '@privy-io/ethereum';
|
|
11
12
|
import { CountryCode, CountryCallingCode, AsYouType } from 'libphonenumber-js/min';
|
|
12
13
|
export { CountryCallingCode, CountryCode, getCountryCallingCode } from 'libphonenumber-js/min';
|
|
13
14
|
import { Hex, TypedDataDefinition } from 'viem';
|
|
@@ -2143,6 +2144,15 @@ declare function throwIfInvalidRecoveryUpgradePath({ currentRecoveryMethod, upgr
|
|
|
2143
2144
|
upgradeToRecoveryMethod: IEmbeddedWalletRecoveryOptions;
|
|
2144
2145
|
}): boolean;
|
|
2145
2146
|
|
|
2147
|
+
type UnsignedEthereumTransactionType = UnsignedEthereumTransaction;
|
|
2148
|
+
/**
|
|
2149
|
+
* Converts an unsigned transaction request to the format expected by the Wallet API.
|
|
2150
|
+
*
|
|
2151
|
+
* Routes Tempo (type 118 / 0x76) requests through the Tempo serializer and falls
|
|
2152
|
+
* through to the standard EVM serializer for legacy/EIP-2930/EIP-1559 inputs.
|
|
2153
|
+
*/
|
|
2154
|
+
declare function toWalletApiUnsignedEthTransaction(transaction: StrictUnsignedTransactionRequest | StrictUnsignedTempoTransactionRequest): UnsignedEthereumTransactionType;
|
|
2155
|
+
|
|
2146
2156
|
/**
|
|
2147
2157
|
* Do a lightweight validation of phone number. We'll do much heavier validation
|
|
2148
2158
|
* on the backend, so this just needs to be sensible. This hints a default country
|
|
@@ -2850,5 +2860,5 @@ declare const THIRDWEB: "thirdweb";
|
|
|
2850
2860
|
/** @deprecated {@link SmartWalletType} is a well-typed union, use the `'nexus'` literal instead */
|
|
2851
2861
|
declare const NEXUS: "nexus";
|
|
2852
2862
|
|
|
2853
|
-
export { ALL_WALLET_CLIENT_TYPES, BICONOMY, COINBASE_SMART_WALLET, ConnectedStandardSolanaWallet, EmbeddedBitcoinWalletProvider, EmbeddedProviderError, InMemoryCache, KERNEL, LIGHT_ACCOUNT, LocalStorage, MoonpayApiError, NEXUS, PrivyApiError, PrivyClientError, PrivyConnectorError, PrivyEmbeddedWalletErrorCode, PrivyProviderRpcError, ProviderErrors, SAFE, SUPPORTED_CONNECTOR_TYPES, SolanaClient, SolanaUsdcAddressMap, THIRDWEB, UsdcAddressMap, addSessionSigners, chainToMoonpayCurrency, countryCodesAndNumbers, create, createErrorFormatter, createSiwsMessage, index as crossApp, Privy as default, index$2 as delegatedActions, errorIndicatesMaxMfaRetries, errorIndicatesMfaCanceled, errorIndicatesMfaRateLimit, errorIndicatesMfaTimeout, errorIndicatesMfaVerificationFailed, errorIndicatesRecoveryIsNeeded, formatLamportsAmount, formatPhoneNumber, formatTokenAmount, formatWalletAddress, formatWeiAmount, fundingMethodToMoonpayPaymentMethod, generateAuthorizationSignature, generateWalletIdempotencyKey, getAllUserEmbeddedBitcoinWallets, getAllUserEmbeddedEthereumWallets, getAllUserEmbeddedSolanaWallets, getCoinbaseOnRampUrl, getEntropyDetailsFromAccount, getEntropyDetailsFromUser, getIsTokenUsdc, getJsonRpcEndpointFromChain, getPhoneCountryCodeAndNumber, getPlaceholderPhoneNumber, getSolanaClusterDisplayName, getSolanaRpcEndpointForCluster, getSolanaUsdcMintAddressForCluster, getUserEmbeddedEthereumWallet, getUserEmbeddedSolanaWallet, getUserEmbeddedWallet, getUserSmartWallet, getWallet, isEmbeddedWalletAccount, isSupportedChainIdForCoinbaseOnramp, isSupportedChainIdForMoonpay, isUnifiedWallet, lastFourDigits, phoneNumberTypingFormatter, rawSign, removeSessionSigners, rpc, throwIfInvalidRecoveryUpgradePath, toCoinbaseAssetId, toCoinbaseBlockchainFromChainId, toObjectKeys, updateWallet, validatePhoneNumber };
|
|
2863
|
+
export { ALL_WALLET_CLIENT_TYPES, BICONOMY, COINBASE_SMART_WALLET, ConnectedStandardSolanaWallet, EmbeddedBitcoinWalletProvider, EmbeddedProviderError, InMemoryCache, KERNEL, LIGHT_ACCOUNT, LocalStorage, MoonpayApiError, NEXUS, PrivyApiError, PrivyClientError, PrivyConnectorError, PrivyEmbeddedWalletErrorCode, PrivyProviderRpcError, ProviderErrors, SAFE, SUPPORTED_CONNECTOR_TYPES, SolanaClient, SolanaUsdcAddressMap, THIRDWEB, UsdcAddressMap, addSessionSigners, chainToMoonpayCurrency, countryCodesAndNumbers, create, createErrorFormatter, createSiwsMessage, index as crossApp, Privy as default, index$2 as delegatedActions, errorIndicatesMaxMfaRetries, errorIndicatesMfaCanceled, errorIndicatesMfaRateLimit, errorIndicatesMfaTimeout, errorIndicatesMfaVerificationFailed, errorIndicatesRecoveryIsNeeded, formatLamportsAmount, formatPhoneNumber, formatTokenAmount, formatWalletAddress, formatWeiAmount, fundingMethodToMoonpayPaymentMethod, generateAuthorizationSignature, generateWalletIdempotencyKey, getAllUserEmbeddedBitcoinWallets, getAllUserEmbeddedEthereumWallets, getAllUserEmbeddedSolanaWallets, getCoinbaseOnRampUrl, getEntropyDetailsFromAccount, getEntropyDetailsFromUser, getIsTokenUsdc, getJsonRpcEndpointFromChain, getPhoneCountryCodeAndNumber, getPlaceholderPhoneNumber, getSolanaClusterDisplayName, getSolanaRpcEndpointForCluster, getSolanaUsdcMintAddressForCluster, getUserEmbeddedEthereumWallet, getUserEmbeddedSolanaWallet, getUserEmbeddedWallet, getUserSmartWallet, getWallet, isEmbeddedWalletAccount, isSupportedChainIdForCoinbaseOnramp, isSupportedChainIdForMoonpay, isUnifiedWallet, lastFourDigits, phoneNumberTypingFormatter, rawSign, removeSessionSigners, rpc, throwIfInvalidRecoveryUpgradePath, toCoinbaseAssetId, toCoinbaseBlockchainFromChainId, toObjectKeys, toWalletApiUnsignedEthTransaction, updateWallet, validatePhoneNumber };
|
|
2854
2864
|
export type { Cluster, CoinbaseAssetId, CoinbaseWalletClientType, ConnectorType, CreateSiwsMessageOpts, EIP1193Provider, EmbeddedWalletClientType, EmbeddedWalletConfig, EmbeddedWalletRecoveryOptions, EntropyIdVerifier, ErrorMessageMap, ExternalWallet, ExternalWalletMetadata, FundingMethod, FundingProvider, GenerateAuthorizationSignatureInput, GenerateAuthorizationSignatureOutput, IdentifierString, InjectedWalletClientType, LogLevel, Logger, MfaMethod, MfaPromise, MfaSubmitArgs, MfaSubmitPromise, MoonpayTransactionStatus, MoonpayTransactionStatusResponse, OAuthProviderType, OnNeedsRecovery, PaymentOption, PreparedTransactionRequest, PrivyEmbeddedSolanaWalletProvider, PrivyEmbeddedWalletProvider, Quantity, SetRecoveryInput, SmartWalletType, SolanaCluster, SolanaSignAndSendTransactionInput, SolanaSignAndSendTransactionMode, SolanaSignAndSendTransactionOptions, SolanaSignAndSendTransactionOutput, SolanaSignMessageInput, SolanaSignMessageOutput, SolanaSignTransactionInput, SolanaSignTransactionOptions, SolanaSignTransactionOutput, SolanaStandardWallet, SolanaTransactionCommitment, Storage, UnknownWalletClientType, UnsignedTransactionRequest, UnsignedTransactionRequestWithChainId, WalletBranding, WalletClientType, WalletConnectWalletClientType };
|
package/dist/dts/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _privy_io_api_types from '@privy-io/api-types';
|
|
2
|
-
import { PasskeyAuthenticatorVerifyResponse, LinkedAccountEmbeddedWallet, LinkedAccountEthereumEmbeddedWallet, LinkedAccountSolanaEmbeddedWallet, User, SmartWalletConfiguration, OAuthTokens, LinkedAccountBitcoinSegwitEmbeddedWallet, LinkedAccountBitcoinTaprootEmbeddedWallet, AuthenticatedUser, OAuthProviderID, SmartWalletType as SmartWalletType$1, CoinbaseOnRampInitInput, MoonpayOnRampSignInput, MfaPasskeyInitRequestBody, MfaSMSInitRequestBody, LinkedAccount, LinkedAccountSmartWallet, CoinbaseOnRampInitResponse, WalletCreateParams, Wallet, WalletRpcParams, WalletRpcResponse, WalletRawSignParams, RawSignResponse, WalletUpdateParams, LinkedAccountEmbeddedWalletWithID } from '@privy-io/api-types';
|
|
2
|
+
import { PasskeyAuthenticatorVerifyResponse, LinkedAccountEmbeddedWallet, LinkedAccountEthereumEmbeddedWallet, LinkedAccountSolanaEmbeddedWallet, User, SmartWalletConfiguration, OAuthTokens, LinkedAccountBitcoinSegwitEmbeddedWallet, LinkedAccountBitcoinTaprootEmbeddedWallet, AuthenticatedUser, OAuthProviderID, SmartWalletType as SmartWalletType$1, CoinbaseOnRampInitInput, MoonpayOnRampSignInput, MfaPasskeyInitRequestBody, MfaSMSInitRequestBody, LinkedAccount, LinkedAccountSmartWallet, UnsignedEthereumTransaction, CoinbaseOnRampInitResponse, WalletCreateParams, Wallet, WalletRpcParams, WalletRpcResponse, WalletRawSignParams, RawSignResponse, WalletUpdateParams, LinkedAccountEmbeddedWalletWithID } from '@privy-io/api-types';
|
|
3
3
|
export { OAuthProviderID } from '@privy-io/api-types';
|
|
4
4
|
import { Chain, RpcConfig } from '@privy-io/chains';
|
|
5
5
|
export * from '@privy-io/chains';
|
|
@@ -8,6 +8,7 @@ import EventEmitter from 'eventemitter3';
|
|
|
8
8
|
import { PrivyErrorCode } from '@privy-io/api-base';
|
|
9
9
|
import { Transaction, VersionedTransaction, Connection, SendOptions } from '@solana/web3.js';
|
|
10
10
|
import { AuthenticationResponseJSON, RegistrationResponseJSON } from '@simplewebauthn/types';
|
|
11
|
+
import { StrictUnsignedTransactionRequest, StrictUnsignedTempoTransactionRequest } from '@privy-io/ethereum';
|
|
11
12
|
import { CountryCode, CountryCallingCode, AsYouType } from 'libphonenumber-js/min';
|
|
12
13
|
export { CountryCallingCode, CountryCode, getCountryCallingCode } from 'libphonenumber-js/min';
|
|
13
14
|
import { Hex, TypedDataDefinition } from 'viem';
|
|
@@ -2143,6 +2144,15 @@ declare function throwIfInvalidRecoveryUpgradePath({ currentRecoveryMethod, upgr
|
|
|
2143
2144
|
upgradeToRecoveryMethod: IEmbeddedWalletRecoveryOptions;
|
|
2144
2145
|
}): boolean;
|
|
2145
2146
|
|
|
2147
|
+
type UnsignedEthereumTransactionType = UnsignedEthereumTransaction;
|
|
2148
|
+
/**
|
|
2149
|
+
* Converts an unsigned transaction request to the format expected by the Wallet API.
|
|
2150
|
+
*
|
|
2151
|
+
* Routes Tempo (type 118 / 0x76) requests through the Tempo serializer and falls
|
|
2152
|
+
* through to the standard EVM serializer for legacy/EIP-2930/EIP-1559 inputs.
|
|
2153
|
+
*/
|
|
2154
|
+
declare function toWalletApiUnsignedEthTransaction(transaction: StrictUnsignedTransactionRequest | StrictUnsignedTempoTransactionRequest): UnsignedEthereumTransactionType;
|
|
2155
|
+
|
|
2146
2156
|
/**
|
|
2147
2157
|
* Do a lightweight validation of phone number. We'll do much heavier validation
|
|
2148
2158
|
* on the backend, so this just needs to be sensible. This hints a default country
|
|
@@ -2850,5 +2860,5 @@ declare const THIRDWEB: "thirdweb";
|
|
|
2850
2860
|
/** @deprecated {@link SmartWalletType} is a well-typed union, use the `'nexus'` literal instead */
|
|
2851
2861
|
declare const NEXUS: "nexus";
|
|
2852
2862
|
|
|
2853
|
-
export { ALL_WALLET_CLIENT_TYPES, BICONOMY, COINBASE_SMART_WALLET, ConnectedStandardSolanaWallet, EmbeddedBitcoinWalletProvider, EmbeddedProviderError, InMemoryCache, KERNEL, LIGHT_ACCOUNT, LocalStorage, MoonpayApiError, NEXUS, PrivyApiError, PrivyClientError, PrivyConnectorError, PrivyEmbeddedWalletErrorCode, PrivyProviderRpcError, ProviderErrors, SAFE, SUPPORTED_CONNECTOR_TYPES, SolanaClient, SolanaUsdcAddressMap, THIRDWEB, UsdcAddressMap, addSessionSigners, chainToMoonpayCurrency, countryCodesAndNumbers, create, createErrorFormatter, createSiwsMessage, index as crossApp, Privy as default, index$2 as delegatedActions, errorIndicatesMaxMfaRetries, errorIndicatesMfaCanceled, errorIndicatesMfaRateLimit, errorIndicatesMfaTimeout, errorIndicatesMfaVerificationFailed, errorIndicatesRecoveryIsNeeded, formatLamportsAmount, formatPhoneNumber, formatTokenAmount, formatWalletAddress, formatWeiAmount, fundingMethodToMoonpayPaymentMethod, generateAuthorizationSignature, generateWalletIdempotencyKey, getAllUserEmbeddedBitcoinWallets, getAllUserEmbeddedEthereumWallets, getAllUserEmbeddedSolanaWallets, getCoinbaseOnRampUrl, getEntropyDetailsFromAccount, getEntropyDetailsFromUser, getIsTokenUsdc, getJsonRpcEndpointFromChain, getPhoneCountryCodeAndNumber, getPlaceholderPhoneNumber, getSolanaClusterDisplayName, getSolanaRpcEndpointForCluster, getSolanaUsdcMintAddressForCluster, getUserEmbeddedEthereumWallet, getUserEmbeddedSolanaWallet, getUserEmbeddedWallet, getUserSmartWallet, getWallet, isEmbeddedWalletAccount, isSupportedChainIdForCoinbaseOnramp, isSupportedChainIdForMoonpay, isUnifiedWallet, lastFourDigits, phoneNumberTypingFormatter, rawSign, removeSessionSigners, rpc, throwIfInvalidRecoveryUpgradePath, toCoinbaseAssetId, toCoinbaseBlockchainFromChainId, toObjectKeys, updateWallet, validatePhoneNumber };
|
|
2863
|
+
export { ALL_WALLET_CLIENT_TYPES, BICONOMY, COINBASE_SMART_WALLET, ConnectedStandardSolanaWallet, EmbeddedBitcoinWalletProvider, EmbeddedProviderError, InMemoryCache, KERNEL, LIGHT_ACCOUNT, LocalStorage, MoonpayApiError, NEXUS, PrivyApiError, PrivyClientError, PrivyConnectorError, PrivyEmbeddedWalletErrorCode, PrivyProviderRpcError, ProviderErrors, SAFE, SUPPORTED_CONNECTOR_TYPES, SolanaClient, SolanaUsdcAddressMap, THIRDWEB, UsdcAddressMap, addSessionSigners, chainToMoonpayCurrency, countryCodesAndNumbers, create, createErrorFormatter, createSiwsMessage, index as crossApp, Privy as default, index$2 as delegatedActions, errorIndicatesMaxMfaRetries, errorIndicatesMfaCanceled, errorIndicatesMfaRateLimit, errorIndicatesMfaTimeout, errorIndicatesMfaVerificationFailed, errorIndicatesRecoveryIsNeeded, formatLamportsAmount, formatPhoneNumber, formatTokenAmount, formatWalletAddress, formatWeiAmount, fundingMethodToMoonpayPaymentMethod, generateAuthorizationSignature, generateWalletIdempotencyKey, getAllUserEmbeddedBitcoinWallets, getAllUserEmbeddedEthereumWallets, getAllUserEmbeddedSolanaWallets, getCoinbaseOnRampUrl, getEntropyDetailsFromAccount, getEntropyDetailsFromUser, getIsTokenUsdc, getJsonRpcEndpointFromChain, getPhoneCountryCodeAndNumber, getPlaceholderPhoneNumber, getSolanaClusterDisplayName, getSolanaRpcEndpointForCluster, getSolanaUsdcMintAddressForCluster, getUserEmbeddedEthereumWallet, getUserEmbeddedSolanaWallet, getUserEmbeddedWallet, getUserSmartWallet, getWallet, isEmbeddedWalletAccount, isSupportedChainIdForCoinbaseOnramp, isSupportedChainIdForMoonpay, isUnifiedWallet, lastFourDigits, phoneNumberTypingFormatter, rawSign, removeSessionSigners, rpc, throwIfInvalidRecoveryUpgradePath, toCoinbaseAssetId, toCoinbaseBlockchainFromChainId, toObjectKeys, toWalletApiUnsignedEthTransaction, updateWallet, validatePhoneNumber };
|
|
2854
2864
|
export type { Cluster, CoinbaseAssetId, CoinbaseWalletClientType, ConnectorType, CreateSiwsMessageOpts, EIP1193Provider, EmbeddedWalletClientType, EmbeddedWalletConfig, EmbeddedWalletRecoveryOptions, EntropyIdVerifier, ErrorMessageMap, ExternalWallet, ExternalWalletMetadata, FundingMethod, FundingProvider, GenerateAuthorizationSignatureInput, GenerateAuthorizationSignatureOutput, IdentifierString, InjectedWalletClientType, LogLevel, Logger, MfaMethod, MfaPromise, MfaSubmitArgs, MfaSubmitPromise, MoonpayTransactionStatus, MoonpayTransactionStatusResponse, OAuthProviderType, OnNeedsRecovery, PaymentOption, PreparedTransactionRequest, PrivyEmbeddedSolanaWalletProvider, PrivyEmbeddedWalletProvider, Quantity, SetRecoveryInput, SmartWalletType, SolanaCluster, SolanaSignAndSendTransactionInput, SolanaSignAndSendTransactionMode, SolanaSignAndSendTransactionOptions, SolanaSignAndSendTransactionOutput, SolanaSignMessageInput, SolanaSignMessageOutput, SolanaSignTransactionInput, SolanaSignTransactionOptions, SolanaSignTransactionOutput, SolanaStandardWallet, SolanaTransactionCommitment, Storage, UnknownWalletClientType, UnsignedTransactionRequest, UnsignedTransactionRequestWithChainId, WalletBranding, WalletClientType, WalletConnectWalletClientType };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"fetch-retry";import{PrivyErrorCode as t}from"@privy-io/api-base";import{getPathWithParams as s,AppConfig as i,AnalyticsEvent as r,RefreshSession as a}from"@privy-io/routes";import{PrivyClientError as o,PrivyApiError as n}from"../Error.mjs";import{Session as h}from"../Session.mjs";import c from"../toAbortSignalTimeout.mjs";import{toSearchParams as l}from"../utils/toSearchParams.mjs";import{toLoggerWithLevel as g}from"./logger.mjs";import"eventemitter3";import"jose";import"js-cookie";import"../Token.mjs";import"../utils/allSettled.mjs";import"../utils/noop.mjs";let d="privy:caid";class p{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:i}){return`${this.baseUrl}${s(e.path,t)}${l(i)}`}async fetch(e,{body:t,params:s,query:i,headers:r,onRequest:a=this._beforeRequest.bind(this)}){let o=new Request(this.getPath(e,{params:s,query:i}),{method:e.method,body:JSON.stringify(t),headers:r}),h=await a(o),c=await this._fetch(o,h),l=await c.json();if(c.status>299)throw new n({...l,status:c.status});return l}async _beforeRequestWithoutInitialize(e){let t=await this.session.getPrivyAccessToken()??await this.session.getCustomerAccessToken(),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.getAccessTokenInternal(),this.beforeRequestWithoutRefresh(e)}async getAppConfig(){return await this.fetch(i,{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(d);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=this._crypto.randomUUID()}catch(e){this.logger.error("Unable to generate uuidv4",e)}if(this._analyticsId){try{await this._storage.put(d,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(d)}catch(e){this.logger.error("Unable to delete clientId",e)}}async createAnalyticsEvent(e,t){try{await this.fetch(r,{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,s){let i=await this.session.getCustomerAccessToken();if(!this.session.hasRefreshCredentials(i,e??null))throw this.logger.debug("[privy:refresh] missing tokens, skipping request"),await this._initialize(),new n({code:t.MISSING_OR_INVALID_TOKEN,error:"No tokens found in storage",status:401});try{this.logger.debug(`[privy:refresh] fetching: ${a.path}`);let t=await this.fetch(a,{body:{refresh_token:e},onRequest:this.beforeRequestWithoutRefresh.bind(this)}),i=t.session_update_action;return this.logger.debug(`[privy:refresh] response: ${i}`),"set"===i&&(await this.session.updateWithTokensResponse(t),this.logger.debug("[privy:refresh] tokens stored")),"clear"===i&&(await this.session.destroyLocalState(),this.logger.debug("[privy:refresh] tokens cleared"),s||this.callbacks?.setUser?.(null)),"ignore"===i&&(t.token&&(await this.session.storeCustomerAccessToken(t.token),this.logger.debug("[privy:refresh] token stored (CAT)")),t.privy_access_token&&(await this.session.storePrivyAccessToken(t.privy_access_token),this.logger.debug("[privy:refresh] token stored (PAT)")),t.identity_token&&(this.logger.debug("[privy:refresh] token stored (IDT)"),await this.session.storeIdentityToken(t.identity_token))),this.logger.debug("[privy:refresh] returning response"),s||this.callbacks?.setUser?.(t.user),t}catch(e){throw this.logger.debug(`[privy:refresh] error: ${e.message??"unknown error"}`),e instanceof n&&e.code===t.MISSING_OR_INVALID_TOKEN&&(await this.session.destroyLocalState(),s||this.callbacks?.setUser?.(null)),e}}async getAccessToken(){let[e,t]=await Promise.all([this.session.getCustomerAccessToken(),this.session.getRefreshToken()]);if(e&&!this.session.tokenIsActive(e)&&this.session.hasRefreshCredentials(e,t)){let t=await this.refreshSession(),s=await this.session.getCustomerAccessToken();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&&!this.session.tokenIsActive(e)?(this.logger.debug("[privy:getAccessToken] unable to refresh inactive token"),this.callbacks?.setUser?.(null),await this.session.destroyLocalState(),null):e}async getAccessTokenInternal(){let e=await this.getAccessToken();return await this.session.getPrivyAccessToken()??e}async getIdentityToken(){return await this.session.getIdentityToken()}async isStorageAccessible(){try{let e=`privy:__storage__test-${this._crypto.randomUUID()}`,t="blobby";await this._storage.put(e,t);let s=await this._storage.get(e);return await this._storage.del(e),s===t}catch(e){return this.logger.error(e),!1}}constructor(t){this._sdkVersion="js-sdk-core:0.
|
|
1
|
+
import e from"fetch-retry";import{PrivyErrorCode as t}from"@privy-io/api-base";import{getPathWithParams as s,AppConfig as i,AnalyticsEvent as r,RefreshSession as a}from"@privy-io/routes";import{PrivyClientError as o,PrivyApiError as n}from"../Error.mjs";import{Session as h}from"../Session.mjs";import c from"../toAbortSignalTimeout.mjs";import{toSearchParams as l}from"../utils/toSearchParams.mjs";import{toLoggerWithLevel as g}from"./logger.mjs";import"eventemitter3";import"jose";import"js-cookie";import"../Token.mjs";import"../utils/allSettled.mjs";import"../utils/noop.mjs";let d="privy:caid";class p{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:i}){return`${this.baseUrl}${s(e.path,t)}${l(i)}`}async fetch(e,{body:t,params:s,query:i,headers:r,onRequest:a=this._beforeRequest.bind(this)}){let o=new Request(this.getPath(e,{params:s,query:i}),{method:e.method,body:JSON.stringify(t),headers:r}),h=await a(o),c=await this._fetch(o,h),l=await c.json();if(c.status>299)throw new n({...l,status:c.status});return l}async _beforeRequestWithoutInitialize(e){let t=await this.session.getPrivyAccessToken()??await this.session.getCustomerAccessToken(),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.getAccessTokenInternal(),this.beforeRequestWithoutRefresh(e)}async getAppConfig(){return await this.fetch(i,{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(d);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=this._crypto.randomUUID()}catch(e){this.logger.error("Unable to generate uuidv4",e)}if(this._analyticsId){try{await this._storage.put(d,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(d)}catch(e){this.logger.error("Unable to delete clientId",e)}}async createAnalyticsEvent(e,t){try{await this.fetch(r,{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,s){let i=await this.session.getCustomerAccessToken();if(!this.session.hasRefreshCredentials(i,e??null))throw this.logger.debug("[privy:refresh] missing tokens, skipping request"),await this._initialize(),new n({code:t.MISSING_OR_INVALID_TOKEN,error:"No tokens found in storage",status:401});try{this.logger.debug(`[privy:refresh] fetching: ${a.path}`);let t=await this.fetch(a,{body:{refresh_token:e},onRequest:this.beforeRequestWithoutRefresh.bind(this)}),i=t.session_update_action;return this.logger.debug(`[privy:refresh] response: ${i}`),"set"===i&&(await this.session.updateWithTokensResponse(t),this.logger.debug("[privy:refresh] tokens stored")),"clear"===i&&(await this.session.destroyLocalState(),this.logger.debug("[privy:refresh] tokens cleared"),s||this.callbacks?.setUser?.(null)),"ignore"===i&&(t.token&&(await this.session.storeCustomerAccessToken(t.token),this.logger.debug("[privy:refresh] token stored (CAT)")),t.privy_access_token&&(await this.session.storePrivyAccessToken(t.privy_access_token),this.logger.debug("[privy:refresh] token stored (PAT)")),t.identity_token&&(this.logger.debug("[privy:refresh] token stored (IDT)"),await this.session.storeIdentityToken(t.identity_token))),this.logger.debug("[privy:refresh] returning response"),s||this.callbacks?.setUser?.(t.user),t}catch(e){throw this.logger.debug(`[privy:refresh] error: ${e.message??"unknown error"}`),e instanceof n&&e.code===t.MISSING_OR_INVALID_TOKEN&&(await this.session.destroyLocalState(),s||this.callbacks?.setUser?.(null)),e}}async getAccessToken(){let[e,t]=await Promise.all([this.session.getCustomerAccessToken(),this.session.getRefreshToken()]);if(e&&!this.session.tokenIsActive(e)&&this.session.hasRefreshCredentials(e,t)){let t=await this.refreshSession(),s=await this.session.getCustomerAccessToken();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&&!this.session.tokenIsActive(e)?(this.logger.debug("[privy:getAccessToken] unable to refresh inactive token"),this.callbacks?.setUser?.(null),await this.session.destroyLocalState(),null):e}async getAccessTokenInternal(){let e=await this.getAccessToken();return await this.session.getPrivyAccessToken()??e}async getIdentityToken(){return await this.session.getIdentityToken()}async isStorageAccessible(){try{let e=`privy:__storage__test-${this._crypto.randomUUID()}`,t="blobby";await this._storage.put(e,t);let s=await this._storage.get(e);return await this._storage.del(e),s===t}catch(e){return this.logger.error(e),!1}}constructor(t){this._sdkVersion="js-sdk-core:0.65.1",this._cache=new Map,this.logger=g({level:t.logger?.level??t.logLevel??"ERROR",logger:t.logger??console}),this._storage=t.storage,this._crypto=t.crypto,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 h({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{p as PrivyInternal};
|
|
2
2
|
//# sourceMappingURL=PrivyInternal.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"eventemitter3";import{toHex as t}from"viem";import{isTempoTransactionRequest as a,toViemTempoTransactionSerializable as r,
|
|
1
|
+
import e from"eventemitter3";import{toHex as t}from"viem";import{isTempoTransactionRequest as a,toViemTempoTransactionSerializable as r,normalizeViemPreparedTempoTransaction as i,TEMPO_TXN_TYPE_NUMBER as s,toViemTransactionSerializable as n,STRING_TO_NUMBER_TXN_TYPE as o}from"@privy-io/ethereum";import{PrivyClientError as h}from"../Error.mjs";import{isUnifiedWallet as c}from"../wallet-api/unified-wallet.mjs";import{EmbeddedProviderError as d,errorIndicatesRecoveryIsNeeded as l}from"./errors.mjs";import{walletRpc as p}from"./stack/walletRpc.mjs";import{getPublicClient as m,isTempoChainId as u}from"./utils/index.mjs";import"./types.mjs";import"../utils/encodings.mjs";import"../wallet-api/rpc.mjs";import"@privy-io/routes";import"../wallet-api/generate-authorization-signature.mjs";import"canonicalize";import"@privy-io/encoding";import"../wallet-api/types.mjs";import"./stack/wallet-api-eth-transaction.mjs";import"./stack/wallet-api-eth-typed-data.mjs";import"viem/chains";let _=new Set(["eth_sign","personal_sign","eth_signTypedData_v4","csw_signUserOperation","secp256k1_sign"]);class y extends e{async request(e){if(_.has(e.method))return this.handleIFrameRpc(e);switch(e.method){case"eth_accounts":case"eth_requestAccounts":return this._account.address?[this._account.address]:[];case"eth_chainId":return`0x${this._chainId.toString(16)}`;case"wallet_switchEthereumChain":return this.handleSwitchEthereumChain(e);case"eth_estimateGas":return this.handleEstimateGas(e);case"eth_signTransaction":{let t=e.params?.[0];return this.handleSignTransaction(t)}case"eth_sendTransaction":{let t=e.params?.[0];return this.handleSendTransaction(t)}case"eth_populateTransactionRequest":{let t=e.params?.[0];return this.handlePopulateTransaction(t)}default:return this.handleJsonRpc(e)}}ensureChainId(e){let t={chainId:this._chainId,...e};return this.internalSwitchEthereumChain(t.chainId),t}internalSwitchEthereumChain(e){e&&Number(e)!==this._chainId&&(this._chainId=Number(e),this._client=m(this._chainId,this._chains,{rpcUrls:[]},{appId:this._privyInternal.appId}),this.emit("chainChanged",e))}async handlePopulateTransaction(e){let t=this.ensureChainId(e);if(a(t)){let e=r(t),a=i(await this.requireTempoClient().prepareTransactionRequest({account:t.from??this._account.address,...e}),t.gasLimit);return{...t,...a,type:s}}let h=n(t),{type:c,...d}=await this._client.prepareTransactionRequest({account:t.from??this._account.address,...h});return{...d,type:o[c]}}async handleSignTransaction(e){let r={...e};for(let e of Object.keys(r)){let a=r[e];"bigint"==typeof a&&(r[e]=t(a))}return a(r)&&(r.calls=r.calls.map((e=>({...e,value:"bigint"==typeof e.value?t(e.value):e.value})))),await this.handleIFrameRpc({method:"eth_signTransaction",params:[r]})}async handleSendTransaction(e){let t=await this.handlePopulateTransaction(e),a=await this.handleSignTransaction(t);return await this.handleJsonRpc({method:"eth_sendRawTransaction",params:[a]})}async handleEstimateGas(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for eth_estimateGas");let t=e.params?.[0],i=this.ensureChainId(t);if(a(i)){let e=r(i);return await this.requireTempoClient().estimateGas({account:i.from??this._account.address,...e})}let s=n(i);return await this._client.estimateGas({account:i.from??this._account.address,...s})}handleSwitchEthereumChain(e){let t;if(!e.params||!Array.isArray(e.params))throw new d(`Invalid params for ${e.method}`,4200);if("string"==typeof e.params[0])t=e.params[0];else{if(!("chainId"in e.params[0])||"string"!=typeof e.params[0].chainId)throw new d(`Invalid params for ${e.method}`,4200);t=e.params[0].chainId}this.internalSwitchEthereumChain(t)}async handleIFrameRpc(e){try{let t=await this._privyInternal.getAccessTokenInternal();if(!t)throw Error("Missing privy token. User must be logged in");this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_started",{method:e.method,address:this._account.address});let a=this._account;if(c(a)){let{data:r}=await p({context:{app:this._appApi,fetchPrivyRoute:(...e)=>this._privyInternal.fetch(...e),getCompiledPath:(...e)=>this._privyInternal.getPath(...e),signRequest:({message:e})=>this._walletProxy.signWithUserSigner({accessToken:t,message:e})},account:a,rpcRequest:{chainType:"ethereum",request:e}});return r}try{await this._walletProxy.connect({entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier,accessToken:t})}catch(e){let a=l(e);if(a&&"privy"===this._account.recovery_method)await this._walletProxy.recover({entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier,accessToken:t});else{if(!a||!this._onNeedsRecovery)throw e;{let e;await new Promise((async(t,a)=>{e=setTimeout((()=>a(new h({code:"embedded_wallet_recovery_error",error:"User-owned recovery timed out"}))),12e4),await(this._onNeedsRecovery?.({recoveryMethod:this._account.recovery_method,onRecovered:()=>t(!0)}))})).finally((()=>clearTimeout(e)))}}}return(await this._walletProxy.rpcWallet({accessToken:t,request:e,entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier,hdWalletIndex:this._account.wallet_index,chainType:"ethereum"})).response.data}catch(t){console.error(t);let a=t instanceof Error?t.message:"Unable to make wallet request";throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_failed",{method:e.method,address:this._account.address,error:a}),new h({code:"embedded_wallet_request_error",error:a})}}async handleJsonRpc(e){return this._client.request(e)}requireTempoClient(){if(!u(this._chainId))throw new d(`Cannot send a Tempo (type 118) transaction on chain ${this._chainId}`,4901);return this._client}toJSON(){return`PrivyEIP1193Provider { address: '${this._account.address}', chainId: ${this._chainId}, request: [Function] }`}constructor({walletProxy:e,privyInternal:t,account:a,entropyId:r,entropyIdVerifier:i,chains:s,onNeedsRecovery:n,chainId:o=s[0].id,appApi:h}){super(),this._walletProxy=e,this._privyInternal=t,this._account=a,this._entropyId=r,this._entropyIdVerifier=i,this._chainId=o,this._chains=s,this._onNeedsRecovery=n,this._client=m(o,s,{rpcUrls:[]},{appId:h.appId}),this._appApi=h}}export{y as EmbeddedWalletProvider};
|
|
2
2
|
//# sourceMappingURL=EmbeddedWalletProvider.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmbeddedWalletProvider.mjs","sources":["../../../src/embedded/EmbeddedWalletProvider.ts"],"names":["IFRAME_PASSTHROUGH_RPC_METHODS","Set","EmbeddedWalletProvider","EventEmitter","request","has","method","this","handleIFrameRpc","_account","address","_chainId","toString","handleSwitchEthereumChain","handleEstimateGas","data","params","handleSignTransaction","handleSendTransaction","handlePopulateTransaction","handleJsonRpc","ensureChainId","tx","ensureTxChainId","chainId","internalSwitchEthereumChain","Number","_client","getPublicClient","_chains","rpcUrls","appId","_privyInternal","emit","txRequest","isTempoTransactionRequest","viemTxn","toViemTempoTransactionSerializable","preparedTxn","requireTempoClient","prepareTransactionRequest","account","from","type","TEMPO_TXN_TYPE_NUMBER","toViemTransactionSerializable","STRING_TO_NUMBER_TXN_TYPE","serializable","key","Object","keys","val","toHex","calls","map","e","call","value","populatedTx","signedTx","Array","isArray","Error","viemTempoTxn","estimateGas","args","newChain","EmbeddedProviderError","token","getAccessTokenInternal","createAnalyticsEvent","isUnifiedWallet","walletRpc","context","app","_appApi","fetchPrivyRoute","fetch","getCompiledPath","getPath","signRequest","message","_walletProxy","signWithUserSigner","accessToken","rpcRequest","chainType","connect","entropyId","_entropyId","entropyIdVerifier","_entropyIdVerifier","needsRecovery","errorIndicatesRecoveryIsNeeded","recovery_method","recover","_onNeedsRecovery","timeout","Promise","async","res","rej","setTimeout","PrivyClientError","code","error","recoveryMethod","onRecovered","finally","clearTimeout","rpcWallet","hdWalletIndex","wallet_index","response","console","isTempoChainId","toJSON","constructor","walletProxy","privyInternal","chains","onNeedsRecovery","id","appApi","super"],"mappings":"
|
|
1
|
+
{"version":3,"file":"EmbeddedWalletProvider.mjs","sources":["../../../src/embedded/EmbeddedWalletProvider.ts"],"names":["IFRAME_PASSTHROUGH_RPC_METHODS","Set","EmbeddedWalletProvider","EventEmitter","request","has","method","this","handleIFrameRpc","_account","address","_chainId","toString","handleSwitchEthereumChain","handleEstimateGas","data","params","handleSignTransaction","handleSendTransaction","handlePopulateTransaction","handleJsonRpc","ensureChainId","tx","ensureTxChainId","chainId","internalSwitchEthereumChain","Number","_client","getPublicClient","_chains","rpcUrls","appId","_privyInternal","emit","txRequest","isTempoTransactionRequest","viemTxn","toViemTempoTransactionSerializable","preparedTxn","normalizeViemPreparedTempoTransaction","requireTempoClient","prepareTransactionRequest","account","from","gasLimit","type","TEMPO_TXN_TYPE_NUMBER","toViemTransactionSerializable","STRING_TO_NUMBER_TXN_TYPE","serializable","key","Object","keys","val","toHex","calls","map","e","call","value","populatedTx","signedTx","Array","isArray","Error","viemTempoTxn","estimateGas","args","newChain","EmbeddedProviderError","token","getAccessTokenInternal","createAnalyticsEvent","isUnifiedWallet","walletRpc","context","app","_appApi","fetchPrivyRoute","fetch","getCompiledPath","getPath","signRequest","message","_walletProxy","signWithUserSigner","accessToken","rpcRequest","chainType","connect","entropyId","_entropyId","entropyIdVerifier","_entropyIdVerifier","needsRecovery","errorIndicatesRecoveryIsNeeded","recovery_method","recover","_onNeedsRecovery","timeout","Promise","async","res","rej","setTimeout","PrivyClientError","code","error","recoveryMethod","onRecovered","finally","clearTimeout","rpcWallet","hdWalletIndex","wallet_index","response","console","isTempoChainId","toJSON","constructor","walletProxy","privyInternal","chains","onNeedsRecovery","id","appApi","super"],"mappings":"q9BAiFA,IAAMA,EAAiC,IAAIC,IAAI,CAC7C,WACA,gBACA,uBACA,wBACA,mBAGK,MAAMC,UAA+BC,EAiD1C,aAAMC,CAAQA,GAGZ,GAAIJ,EAA+BK,IAAID,EAAQE,QAC7C,OAAOC,KAAKC,gBAAgBJ,GAG9B,OAAQA,EAAQE,QACd,IAAK,eACL,IAAK,sBACH,OAAOC,KAAKE,SAASC,QAAU,CAACH,KAAKE,SAASC,SAAW,GAE3D,IAAK,cACH,MAAO,KAAKH,KAAKI,SAASC,SAAS,MAErC,IAAK,6BACH,OAAOL,KAAKM,0BAA0BT,GAExC,IAAK,kBACH,OAAOG,KAAKO,kBAAkBV,GAEhC,IAAK,sBAAuB,CAC1B,IAAMW,EAAOX,EAAQY,SAAS,GAG9B,OAAOT,KAAKU,sBAAsBF,EACpC,CACA,IAAK,sBAAuB,CAC1B,IAAMA,EAAOX,EAAQY,SAAS,GAG9B,OAAOT,KAAKW,sBAAsBH,EACpC,CACA,IAAK,iCAAkC,CACrC,IAAMA,EAAOX,EAAQY,SAAS,GAG9B,OAAOT,KAAKY,0BAA0BJ,EACxC,CACA,QACE,OAAOR,KAAKa,cAAchB,GAGhC,CAOQiB,aAAAA,CAENC,GACA,IAAMC,EAAkB,CAACC,QAASjB,KAAKI,YAAaW,GAEpD,OADAf,KAAKkB,4BAA4BF,EAAgBC,SAC1CD,CACT,CAMA,2BAAAE,CAAoCD,GAC7BA,GAAWE,OAAOF,KAAajB,KAAKI,WAEzCJ,KAAKI,SAAWe,OAAOF,GACvBjB,KAAKoB,QAAUC,EACbrB,K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MAAOxB,GAC5E,CACF,CAEA,mBAAc/D,CAAchB,GAC1B,OAAOG,KAAKoB,QAAQvB,QAAQA,EAC9B,CAGA,kBAAAoC,GACE,IAAK6E,EAAe9G,KAAKI,UACvB,MAAM,IAAI0D,EACR,uDAAuD9D,KAAKI,WAC5D,MAKJ,OAAOJ,KAAKoB,OAAO,CAGrB2F,MAAAA,GAEE,MAAO,oCAAoC/G,KAAKE,SAASC,sBAAsBH,KAAKI,iCACtF,CAnVA4G,WAAAA,EACEC,YAAAA,EACAC,cAAAA,EACA/E,QAAAA,EACAgD,UAAAA,EACAE,kBAAAA,EACA8B,OAAAA,EACAC,gBAAAA,EACAnG,QAAAA,EAAUkG,EAAO,GAAGE,GACpBC,OAAAA,IAEAC,QACAvH,KAAK6E,aAAeoC,EACpBjH,KAAKyB,eAAiByF,EACtBlH,KAAKE,SAAWiC,EAChBnC,KAAKoF,WAAaD,EAClBnF,KAAKsF,mBAAqBD,EAC1BrF,KAAKI,SAAWa,EAChBjB,KAAKsB,QAAU6F,EACfnH,KAAK2F,iBAAmByB,EACxBpH,KAAKoB,QAAUC,EAAgBJ,EAASkG,EAAQ,CAAC5F,QAAS,IAAK,CAACC,MAAO8F,EAAO9F,QAC9ExB,KAAKsE,QAAUgD,CACjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet-api-eth-transaction.mjs","sources":["../../../../src/embedded/stack/wallet-api-eth-transaction.ts"],"names":["toWalletApiUnsignedEthTransaction","transaction","isTempoTransactionRequest","type","TEMPO_TXN_TYPE_NUMBER","from","chain_id","quantityToHex","chainId","nonce","nonce_key","nonceKey","gas_limit","gasLimit","max_fee_per_gas","maxFeePerGas","max_priority_fee_per_gas","maxPriorityFeePerGas","fee_token","feeToken","valid_after","validAfter","valid_before","validBefore","calls","map","e","call","to","data","value","undefined","encodeTransactionData","isHexEncoded","bytesToHex","utf8ToBytes","Buffer","Uint8Array","gas_price","gasPrice","val","BigInt","toString","test","Error"],"mappings":"
|
|
1
|
+
{"version":3,"file":"wallet-api-eth-transaction.mjs","sources":["../../../../src/embedded/stack/wallet-api-eth-transaction.ts"],"names":["toWalletApiUnsignedEthTransaction","transaction","isTempoTransactionRequest","type","TEMPO_TXN_TYPE_NUMBER","from","chain_id","quantityToHex","chainId","nonce","nonce_key","nonceKey","gas_limit","gasLimit","max_fee_per_gas","maxFeePerGas","max_priority_fee_per_gas","maxPriorityFeePerGas","fee_token","feeToken","valid_after","validAfter","valid_before","validBefore","calls","map","e","call","to","data","value","undefined","encodeTransactionData","isHexEncoded","bytesToHex","utf8ToBytes","Buffer","Uint8Array","gas_price","gasPrice","val","BigInt","toString","test","Error"],"mappings":"oLAkBO,SAASA,EACdC,GAAqF,OAEjFC,EAA0BD,GA2BvB,CACLE,KAAMC,EACNC,KAAMJ,EAAYI,KAClBC,SAAUC,EA7BiCN,EA6BPO,SACpCC,MAAOF,EAAcN,EAAYQ,OACjCC,UAAWH,EAAcN,EAAYU,UACrCC,UAAWL,EAhCgCN,EAgCNY,UACrCC,gBAAiBP,EAjC0BN,EAiCAc,cAC3CC,yBAA0BT,EAAcN,EAAYgB,sBACpDC,UAnC2CjB,EAmCpBkB,SACvBC,YAAab,EAAcN,EAAYoB,YACvCC,aAAcf,EAAcN,EAAYsB,aACxCC,MAAOvB,EAAYuB,MAAMC,KAAIC,IAACC,CAC5BC,GAAID,EAAKC,GACTC,KAAMF,EAAKE,KACXC,MAAOvB,EAAcoB,EAAKG,YAjCvB,CACLzB,KAAMJ,EAAYI,KAClBuB,GAAI3B,EAAY2B,SAAMG,EACtBtB,MAAOF,EAAcN,EAAYQ,OACjCH,SAAUC,EAAcN,EAAYO,SACpCqB,KAAMG,SAiCqBH,GAC7B,QAAI,IAAOA,EAAAA,MAIS,iBAATA,EAEFI,EAAaJ,GAAQA,EAAOK,EAAWC,EAAYN,IAIrDK,EAAWE,OAAO/B,KAAKgC,WAAWhC,KAAKwB,IAChD,CA7CUG,CAXsC/B,EAWJ4B,MACxCC,MAAOvB,EAZqCN,EAYX6B,OACjC3B,KAAMF,EAAYE,KAClBS,UAAWL,EAdiCN,EAcPY,UACrCyB,UAAW/B,EAfiCN,EAePsC,UACrCzB,gBAAiBP,EAhB2BN,EAgBDc,cAC3CC,yBAA0BT,EAjBkBN,EAiBQgB,sBAhBxD,CAyDA,SAASV,EAAciC,GACrB,GAAmB,iBAARA,GAAoB,iBAAOA,EAAkB,CAEtD,MAAO,KADOC,OAAOD,GACHE,SAAS,KAAK,CAGlC,GAAI,iBAAOF,EAAkB,CAC3B,GAAIP,EAAaO,GAAM,OAAOA,EAK9B,IAAK,QAAQG,KAAKH,GAChB,MAAMI,MAAU,0DAA0DJ,KAE5E,OAAON,EAAWC,EAAYK,GAChC,CAGF"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"./client/Privy.mjs";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{isEmbeddedWalletAccount}from"./utils/embedded-wallets.mjs";export{getEntropyDetailsFromAccount,getEntropyDetailsFromUser}from"./utils/entropy.mjs";export{getUserSmartWallet}from"./utils/getUserSmartWallet.mjs";export{getJsonRpcEndpointFromChain,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{SolanaUsdcAddressMap,UsdcAddressMap,getIsTokenUsdc}from"./utils/getIsTokenUsdc.mjs";export{generateWalletIdempotencyKey}from"./utils/generateWalletIdempotencyKey.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{generateAuthorizationSignature}from"./wallet-api/generate-authorization-signature.mjs";export{create}from"./wallet-api/create.mjs";export{rpc}from"./wallet-api/rpc.mjs";export{rawSign}from"./wallet-api/raw-sign.mjs";export{getWallet}from"./wallet-api/get-wallet.mjs";export{updateWallet}from"./wallet-api/update-wallet.mjs";export{isUnifiedWallet}from"./wallet-api/unified-wallet.mjs";export{addSessionSigners,removeSessionSigners}from"./embedded/stack/session-signers.mjs";export{ConnectedStandardSolanaWallet}from"./solana/ConnectedStandardSolanaWallet.mjs";export{i as crossApp}from"./index-Bu3ySxLM.mjs";export{i as delegatedActions}from"./index-g0cxoRWQ.mjs";export{getCountryCallingCode}from"libphonenumber-js/min";import"./crypto/resolve.mjs";import"./client/AppApi.mjs";import"@privy-io/routes";import"./client/CrossAppApi.mjs";import"./Token.mjs";import"jose";import"./client/DelegatedWalletsApi.mjs";import"./client/EmbeddedWalletApi.mjs";import"./embedded/EmbeddedBitcoinWalletProvider.mjs";import"./embedded/stack/walletCreate.mjs";import"./embedded/EmbeddedWalletProxy.mjs";import"./utils/sleep.mjs";import"./embedded/EventCallbackQueue.mjs";import"./embedded/withMfa.mjs";import"./embedded/EmbeddedWalletProvider.mjs";import"eventemitter3";import"viem";import"@privy-io/ethereum";import"./embedded/stack/walletRpc.mjs";import"./utils/encodings.mjs";import"./embedded/stack/wallet-api-eth-
|
|
1
|
+
import e from"./client/Privy.mjs";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{isEmbeddedWalletAccount}from"./utils/embedded-wallets.mjs";export{getEntropyDetailsFromAccount,getEntropyDetailsFromUser}from"./utils/entropy.mjs";export{getUserSmartWallet}from"./utils/getUserSmartWallet.mjs";export{getJsonRpcEndpointFromChain,throwIfInvalidRecoveryUpgradePath}from"./embedded/utils/index.mjs";export{toWalletApiUnsignedEthTransaction}from"./embedded/stack/wallet-api-eth-transaction.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{SolanaUsdcAddressMap,UsdcAddressMap,getIsTokenUsdc}from"./utils/getIsTokenUsdc.mjs";export{generateWalletIdempotencyKey}from"./utils/generateWalletIdempotencyKey.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{generateAuthorizationSignature}from"./wallet-api/generate-authorization-signature.mjs";export{create}from"./wallet-api/create.mjs";export{rpc}from"./wallet-api/rpc.mjs";export{rawSign}from"./wallet-api/raw-sign.mjs";export{getWallet}from"./wallet-api/get-wallet.mjs";export{updateWallet}from"./wallet-api/update-wallet.mjs";export{isUnifiedWallet}from"./wallet-api/unified-wallet.mjs";export{addSessionSigners,removeSessionSigners}from"./embedded/stack/session-signers.mjs";export{ConnectedStandardSolanaWallet}from"./solana/ConnectedStandardSolanaWallet.mjs";export{i as crossApp}from"./index-Bu3ySxLM.mjs";export{i as delegatedActions}from"./index-g0cxoRWQ.mjs";export{getCountryCallingCode}from"libphonenumber-js/min";import"./crypto/resolve.mjs";import"./client/AppApi.mjs";import"@privy-io/routes";import"./client/CrossAppApi.mjs";import"./Token.mjs";import"jose";import"./client/DelegatedWalletsApi.mjs";import"./client/EmbeddedWalletApi.mjs";import"./embedded/EmbeddedBitcoinWalletProvider.mjs";import"./embedded/stack/walletCreate.mjs";import"./embedded/EmbeddedWalletProxy.mjs";import"./utils/sleep.mjs";import"./embedded/EventCallbackQueue.mjs";import"./embedded/withMfa.mjs";import"./embedded/EmbeddedWalletProvider.mjs";import"eventemitter3";import"viem";import"@privy-io/ethereum";import"./embedded/stack/walletRpc.mjs";import"./utils/encodings.mjs";import"./embedded/stack/wallet-api-eth-typed-data.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"@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"viem/chains";import"libphonenumber-js/examples.mobile.json";import"canonicalize";import"@privy-io/encoding";import"./wallet-api/types.mjs";import"./action/delegatedActions/utils.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";import"./action/delegatedActions/delegateWallet.mjs";import"./action/delegatedActions/revokeWallets.mjs";const t="biconomy",r="coinbase_smart_wallet",o="kernel",s="light_account",m="safe",a="thirdweb",l="nexus";export{t as BICONOMY,r as COINBASE_SMART_WALLET,o as KERNEL,s as LIGHT_ACCOUNT,l as NEXUS,m as SAFE,a as THIRDWEB,e as default};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/index.ts"],"names":["BICONOMY","COINBASE_SMART_WALLET","KERNEL","LIGHT_ACCOUNT","SAFE","THIRDWEB","NEXUS"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/index.ts"],"names":["BICONOMY","COINBASE_SMART_WALLET","KERNEL","LIGHT_ACCOUNT","SAFE","THIRDWEB","NEXUS"],"mappings":"o9MAeO,MAAMA,EAAW,WAEXC,EAAwB,wBAExBC,EAAS,SAETC,EAAgB,gBAEhBC,EAAO,OAEPC,EAAW,WAEXC,EAAQ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@privy-io/js-sdk-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.65.1",
|
|
4
4
|
"description": "Vanilla JS client for the Privy Auth API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"authentication",
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
"js-cookie": "^3.0.5",
|
|
59
59
|
"libphonenumber-js": "^1.10.44",
|
|
60
60
|
"set-cookie-parser": "^2.6.0",
|
|
61
|
-
"@privy-io/
|
|
62
|
-
"@privy-io/ethereum": "0.1.0",
|
|
61
|
+
"@privy-io/api-base": "1.9.0",
|
|
63
62
|
"@privy-io/chains": "0.3.0",
|
|
64
|
-
"@privy-io/
|
|
65
|
-
"@privy-io/
|
|
63
|
+
"@privy-io/encoding": "0.1.3",
|
|
64
|
+
"@privy-io/ethereum": "0.1.1",
|
|
65
|
+
"@privy-io/routes": "0.2.1"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@metamask/eth-sig-util": "^8.2.0",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
},
|
|
101
101
|
"peerDependencies": {
|
|
102
102
|
"permissionless": "^0.2.47",
|
|
103
|
-
"viem": "2.
|
|
103
|
+
"viem": "2.48.11"
|
|
104
104
|
},
|
|
105
105
|
"peerDependenciesMeta": {
|
|
106
106
|
"permissionless": {
|