@privy-io/js-sdk-core 0.61.0 → 0.61.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/client/EmbeddedWalletApi.js +1 -1
- package/dist/cjs/client/EmbeddedWalletApi.js.map +1 -1
- package/dist/cjs/client/PrivyInternal.js +1 -1
- package/dist/cjs/client/auth/maybeCreateWalletOnLogin.js +1 -1
- package/dist/cjs/client/auth/maybeCreateWalletOnLogin.js.map +1 -1
- package/dist/dts/index.d.mts +11 -5
- package/dist/dts/index.d.ts +11 -5
- package/dist/dts/smart-wallets.d.mts +2 -1
- package/dist/dts/smart-wallets.d.ts +2 -1
- package/dist/esm/client/EmbeddedWalletApi.mjs +1 -1
- package/dist/esm/client/EmbeddedWalletApi.mjs.map +1 -1
- package/dist/esm/client/PrivyInternal.mjs +1 -1
- package/dist/esm/client/auth/maybeCreateWalletOnLogin.mjs +1 -1
- package/dist/esm/client/auth/maybeCreateWalletOnLogin.mjs.map +1 -1
- package/package.json +12 -11
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@privy-io/chains"),r=require("../Error.js"),t=require("../embedded/EmbeddedBitcoinWalletProvider.js"),o=require("../embedded/errors.js"),i=require("../embedded/stack/walletCreate.js"),d=require("../embedded/utils/index.js"),a=require("../wallet-api/unified-wallet.js"),s=require("../embedded/EmbeddedWalletProxy.js"),n=require("../embedded/EmbeddedWalletProvider.js"),l=require("../embedded/EmbeddedSolanaWalletProvider.js");require("../embedded/types.js"),require("../wallet-api/create.js"),require("@privy-io/routes"),require("viem"),require("../utils/sleep.js"),require("../embedded/EventCallbackQueue.js"),require("../embedded/withMfa.js"),require("eventemitter3"),require("@privy-io/ethereum"),require("../embedded/stack/walletRpc.js"),require("../utils/encodings.js"),require("../wallet-api/rpc.js"),require("../wallet-api/generate-authorization-signature.js"),require("canonicalize"),require("@privy-io/encoding"),require("../wallet-api/types.js"),require("../embedded/stack/wallet-api-eth-transaction.js"),require("../embedded/stack/wallet-api-eth-typed-data.js"),require("../solana/getWalletPublicKeyFromTransaction.js"),require("../solana/isVersionedTransaction.js");exports.default=class{setMessagePoster(e){this._proxy=new s.EmbeddedWalletProxy(e,this._mfaPromises),this._mfa.setProxy(this._proxy)}async signWithUserSigner(e){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");let t=await this._privyInternal.getAccessTokenInternal();if(!t)throw new r.PrivyClientError({error:"User must be logged in to sign a message with the user signer",code:"user_signer_sign_error"});let{signature:o}=await this._proxy.signWithUserSigner({accessToken:t,message:e.message});return{signature:o}}async add(e){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if("user-controlled-server-wallets-only"===this._privyInternal.config?.embedded_wallet_config.mode)await i.walletCreate({context:{app:this._appApi,fetchPrivyRoute:(...e)=>this._privyInternal.fetch(...e),getCompiledPath:(...e)=>this._privyInternal.getPath(...e)},chainType:e.chainType});else{let t=await this._privyInternal.getAccessTokenInternal();if(!t)throw new r.PrivyClientError({error:"User must be logged in to create an embedded wallet",code:"embedded_wallet_creation_error"});await this._proxy.addWallet({accessToken:t,...e})}let{user:t}=await this._privyInternal.refreshSession();return{user:t}}async getBitcoinProvider({wallet:e,entropyId:r,entropyIdVerifier:o,recoveryPassword:i,recoveryAccessToken:d,recoverySecretOverride:s}){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if(!await this._privyInternal.getAccessTokenInternal())throw Error("User must be logged in to create an embedded wallet");return a.isUnifiedWallet(e)||await this._load({entropyId:r,entropyIdVerifier:o,wallet:e,recoveryPassword:i,recoveryAccessToken:d,recoverySecretOverride:s}),new t.EmbeddedBitcoinWalletProvider({account:e,privyInternal:this._privyInternal,proxy:this._proxy,entropyId:r,entropyIdVerifier:o})}async create({password:e,recoveryMethod:t,recoveryToken:o,recoveryKey:d,recoverySecretOverride:a,iCloudRecordNameOverride:s,solanaAccount:n,skipCallbacks:l,idempotencyKey:c}){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if("user-controlled-server-wallets-only"===this._privyInternal.config?.embedded_wallet_config.mode){if(t&&!t.startsWith("privy"))throw new r.PrivyClientError({error:"User-controlled server wallets do not support custom recovery methods",code:"embedded_wallet_creation_error"});await i.walletCreate({context:{app:this._appApi,fetchPrivyRoute:(...e)=>this._privyInternal.fetch(...e),getCompiledPath:(...e)=>this._privyInternal.getPath(...e)},chainType:"ethereum",idempotencyKey:c})}else{let r;if(r=t||(e?"user-passcode":"privy"),e&&"string"!=typeof e)throw Error("Invalid recovery password, must be a string");if("privy"===r&&this._privyInternal.config?.embedded_wallet_config.require_user_password_on_create)throw Error("Password not provided yet is required by App configuration");let i=await this._privyInternal.getAccessTokenInternal();if(!i)throw Error("User must be logged in to create an embedded wallet");let{address:l}=await this._proxy.create({accessToken:i,recoveryMethod:r,recoveryKey:d,recoveryPassword:e,recoveryAccessToken:o,recoverySecretOverride:a,iCloudRecordNameOverride:s,solanaAddress:n?.address});if(!l)throw Error("Failed to create wallet")}return await this._privyInternal.refreshSession(l)}async createSolana(e){if(!this._proxy)throw new r.PrivyClientError({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_creation_error"});if("user-controlled-server-wallets-only"===this._privyInternal.config?.embedded_wallet_config.mode)await i.walletCreate({context:{app:this._appApi,fetchPrivyRoute:(...e)=>this._privyInternal.fetch(...e),getCompiledPath:(...e)=>this._privyInternal.getPath(...e)},chainType:"solana",idempotencyKey:e?.idempotencyKey});else{let t=await this._privyInternal.getAccessTokenInternal();if(!t)throw new r.PrivyClientError({error:"User must be logged in to create an embedded wallet",code:"embedded_wallet_creation_error"});e?.ethereumAccount&&await this.getProvider(e.ethereumAccount);let{publicKey:o}=await this._proxy.createSolana({accessToken:t,ethereumAddress:e?.ethereumAccount?.address});if(!o)throw new r.PrivyClientError({error:"Failed to create wallet",code:"embedded_wallet_creation_error"})}return await this._privyInternal.refreshSession()}async delegateWallets({delegatedWallets:e,rootWallet:t}){if(!this._proxy)throw new r.PrivyClientError({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_creation_error"});let o=await this._privyInternal.getAccessTokenInternal();if(!o)throw new r.PrivyClientError({error:"User must be logged in to create an embedded wallet",code:"embedded_wallet_creation_error"});await this._proxy.delegateWallets({accessToken:o,delegatedWallets:e,rootWallet:t})}async getProvider(e,r,t,o,i){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");return a.isUnifiedWallet(e)||await this._load({wallet:e,entropyId:e.address,entropyIdVerifier:"ethereum-address-verifier",recoveryPassword:r,recoveryKey:i,recoveryAccessToken:t,recoverySecretOverride:o}),new n.EmbeddedWalletProvider({account:e,entropyId:e.address,entropyIdVerifier:"ethereum-address-verifier",privyInternal:this._privyInternal,chains:this._chains,walletProxy:this._proxy,appApi:this._appApi})}async getEthereumProvider({wallet:e,entropyId:r,entropyIdVerifier:t,recoveryPassword:o,recoveryAccessToken:i,recoverySecretOverride:d,recoveryKey:s,onNeedsRecovery:l}){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if(!await this._privyInternal.getAccessTokenInternal())throw Error("User must be logged in to create an embedded wallet");return a.isUnifiedWallet(e)||(!l||o||i||d||s)&&await this._load({entropyId:r,entropyIdVerifier:t,wallet:e,recoveryPassword:o,recoveryAccessToken:i,recoverySecretOverride:d,recoveryKey:s}),new n.EmbeddedWalletProvider({account:e,entropyId:r,entropyIdVerifier:"ethereum-address-verifier",privyInternal:this._privyInternal,chains:this._chains,walletProxy:this._proxy,onNeedsRecovery:l,appApi:this._appApi})}async getSolanaProvider(e,t,o,i,d,s,n){if(!this._proxy)throw new r.PrivyClientError({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_webview_not_loaded"});return a.isUnifiedWallet(e)||(!n||i||d||s)&&await this._load({wallet:e,entropyId:t,entropyIdVerifier:o,recoveryPassword:i,recoveryAccessToken:d,recoverySecretOverride:s}),new l.EmbeddedSolanaWalletProvider({account:e,privyInternal:this._privyInternal,proxy:this._proxy,entropyId:t,entropyIdVerifier:o,onNeedsRecovery:n,app:this._appApi})}async setRecovery(e){let{wallet:t,...o}=e;if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if(a.isUnifiedWallet(t))throw new r.PrivyClientError({error:"This wallet does not support setting recovery methods",code:"unsupported_recovery_method"});d.throwIfInvalidRecoveryUpgradePath({currentRecoveryMethod:t.recovery_method,upgradeToRecoveryMethod:"icloud-native"===o.recoveryMethod?"icloud":o.recoveryMethod}),await this._load("solana"===t.chain_type?{wallet:t,entropyId:t.address,entropyIdVerifier:"solana-address-verifier"}:{wallet:t,entropyId:t.address,entropyIdVerifier:"ethereum-address-verifier"});let i=await this._privyInternal.getAccessTokenInternal();if(!i)throw Error("User must be logged in to interact with embedded wallets");let s=t.recovery_method;this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_set_recovery_started",{address:t.address,target_recovery_method:o.recoveryMethod,existing_recovery_method:s});try{let e;if("user-passcode"===o.recoveryMethod)e={recoveryMethod:"user-passcode",recoveryPassword:o.password};else if("google-drive"===o.recoveryMethod)e={recoveryMethod:"google-drive",recoveryAccessToken:o.recoveryAccessToken};else if("icloud"===o.recoveryMethod)e={recoveryMethod:"icloud",recoveryAccessToken:o.recoveryAccessToken};else if("icloud-native"===o.recoveryMethod)e={recoveryMethod:"icloud-native",iCloudRecordNameOverride:o.iCloudRecordNameOverride,recoverySecretOverride:o.recoverySecretOverride};else if("recovery-encryption-key"===o.recoveryMethod)e={recoveryMethod:"recovery-encryption-key",recoveryKey:o.recoveryKey};else{if("privy"!==o.recoveryMethod)throw Error(`Unknown recovery method: ${o.recoveryMethod}`);e={recoveryMethod:"privy"}}await this._proxy.setRecovery({accessToken:i,entropyId:t.address,entropyIdVerifier:"solana"===t.chain_type?"solana-address-verifier":"ethereum-address-verifier",...e}),this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_set_recovery_completed",{address:t.address,target_recovery_method:o.recoveryMethod,existing_recovery_method:s});let{user:r}=await this._privyInternal.refreshSession();return{user:r,provider:"ethereum"!==t.chain_type?null:new n.EmbeddedWalletProvider({account:t,entropyId:t.address,entropyIdVerifier:"ethereum-address-verifier",privyInternal:this._privyInternal,chains:this._chains,walletProxy:this._proxy,appApi:this._appApi})}}catch(e){throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_set_recovery_failed",{address:t.address,recovery_method:t.recovery_method,error:e instanceof Error?e.message:"Unable to recover wallet"}),e}}getURL(){let e=new URL(`${this._privyInternal.baseUrl}/apps/${this._privyInternal.appId}/embedded-wallets`);return this._privyInternal.caid&&e.searchParams.append("caid",this._privyInternal.caid),this._privyInternal.appClientId&&e.searchParams.append("client_id",this._privyInternal.appClientId),e.href}get chains(){return this._chains}onMessage(e){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");return this._proxy.handleEmbeddedWalletMessages(e)}reload(){this._proxy?this._proxy.reload():console.warn("Attempted to reload proxy before initialized")}async ping(e){try{if(!this._proxy)throw Error("Embedded wallet proxy not initialized");return await this._proxy.ping(e),!0}catch(e){return console.error(e),!1}}async _load({entropyId:e,entropyIdVerifier:r,wallet:t,recoveryPassword:i,recoveryKey:d,recoveryAccessToken:a,recoverySecretOverride:s}){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");let n=await this._privyInternal.getAccessTokenInternal();if(!n)throw Error("User must be logged in to interact with embedded wallets");try{return await this._proxy.connect({accessToken:n,entropyId:e,entropyIdVerifier:r}),e}catch(l){if(o.errorIndicatesRecoveryIsNeeded(l))try{if("privy"===t.recovery_method){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:t.address,recovery_method:t.recovery_method});let o=await this._proxy.recover({accessToken:n,entropyId:e,entropyIdVerifier:r});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:t.address,recovery_method:t.recovery_method}),o.entropyId}if("user-passcode"===t.recovery_method&&i){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:t.address,recovery_method:t.recovery_method});let o=await this._proxy.recover({accessToken:n,recoveryPassword:i,entropyId:e,entropyIdVerifier:r});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:t.address,recovery_method:t.recovery_method}),o.entropyId}if(["google-drive","icloud"].includes(t.recovery_method)&&a){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:t.address,recovery_method:t.recovery_method});let o=await this._proxy.recover({accessToken:n,recoveryAccessToken:a,entropyId:e,entropyIdVerifier:r});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:t.address,recovery_method:t.recovery_method}),o.entropyId}if("icloud"===t.recovery_method&&s){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:t.address,recovery_method:"icloud-native"});let o=await this._proxy.recover({accessToken:n,recoverySecretOverride:s,entropyId:e,entropyIdVerifier:r});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:t.address,recovery_method:"icloud-native"}),o.entropyId}if("recovery-encryption-key"===t.recovery_method&&d){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:t.address,recovery_method:t.recovery_method});let o=await this._proxy.recover({accessToken:n,recoveryKey:d,entropyId:e,entropyIdVerifier:r});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:t.address,recovery_method:t.recovery_method}),o.entropyId}}catch(r){throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_failed",{address:t.address,recovery_method:t.recovery_method,error:r instanceof Error?r.message:`Unable to recover wallet: ${e}`}),r}throw l}}constructor(r,t,o,i,d,a){if(this._chains=Array.from(e.DEFAULT_SUPPORTED_CHAINS),this._privyInternal=r,t&&(this._proxy=new s.EmbeddedWalletProxy(t,d),i.setProxy(this._proxy)),o){let r=e.dedupeSupportedChains(o);this._chains=r}this._mfa=i,this._mfaPromises=d,this._appApi=a}};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@privy-io/chains"),r=require("../Error.js"),t=require("../embedded/EmbeddedBitcoinWalletProvider.js"),o=require("../embedded/errors.js"),i=require("../embedded/stack/walletCreate.js"),d=require("../embedded/utils/index.js"),a=require("../wallet-api/unified-wallet.js"),s=require("../embedded/EmbeddedWalletProxy.js"),n=require("../embedded/EmbeddedWalletProvider.js"),l=require("../embedded/EmbeddedSolanaWalletProvider.js");require("../embedded/types.js"),require("../wallet-api/create.js"),require("@privy-io/routes"),require("viem"),require("../utils/sleep.js"),require("../embedded/EventCallbackQueue.js"),require("../embedded/withMfa.js"),require("eventemitter3"),require("@privy-io/ethereum"),require("../embedded/stack/walletRpc.js"),require("../utils/encodings.js"),require("../wallet-api/rpc.js"),require("../wallet-api/generate-authorization-signature.js"),require("canonicalize"),require("@privy-io/encoding"),require("../wallet-api/types.js"),require("../embedded/stack/wallet-api-eth-transaction.js"),require("../embedded/stack/wallet-api-eth-typed-data.js"),require("../solana/getWalletPublicKeyFromTransaction.js"),require("../solana/isVersionedTransaction.js");exports.default=class{setMessagePoster(e){this._proxy=new s.EmbeddedWalletProxy(e,this._mfaPromises),this._mfa.setProxy(this._proxy)}async signWithUserSigner(e){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");let t=await this._privyInternal.getAccessTokenInternal();if(!t)throw new r.PrivyClientError({error:"User must be logged in to sign a message with the user signer",code:"user_signer_sign_error"});let{signature:o}=await this._proxy.signWithUserSigner({accessToken:t,message:e.message});return{signature:o}}async add(e){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if("user-controlled-server-wallets-only"===this._privyInternal.config?.embedded_wallet_config.mode)await i.walletCreate({context:{app:this._appApi,fetchPrivyRoute:(...e)=>this._privyInternal.fetch(...e),getCompiledPath:(...e)=>this._privyInternal.getPath(...e)},chainType:e.chainType});else{let t=await this._privyInternal.getAccessTokenInternal();if(!t)throw new r.PrivyClientError({error:"User must be logged in to create an embedded wallet",code:"embedded_wallet_creation_error"});await this._proxy.addWallet({accessToken:t,...e})}let{user:t}=await this._privyInternal.refreshSession();return{user:t}}async getBitcoinProvider({wallet:e,entropyId:r,entropyIdVerifier:o,recoveryPassword:i,recoveryAccessToken:d,recoverySecretOverride:s}){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if(!await this._privyInternal.getAccessTokenInternal())throw Error("User must be logged in to create an embedded wallet");return a.isUnifiedWallet(e)||await this._load({entropyId:r,entropyIdVerifier:o,wallet:e,recoveryPassword:i,recoveryAccessToken:d,recoverySecretOverride:s}),new t.EmbeddedBitcoinWalletProvider({account:e,privyInternal:this._privyInternal,proxy:this._proxy,entropyId:r,entropyIdVerifier:o})}async create({password:e,recoveryMethod:t,recoveryToken:o,recoveryKey:d,recoverySecretOverride:a,iCloudRecordNameOverride:s,solanaAccount:n,skipCallbacks:l,idempotencyKey:c}){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if("user-controlled-server-wallets-only"===this._privyInternal.config?.embedded_wallet_config.mode){if(t&&!t.startsWith("privy"))throw new r.PrivyClientError({error:"User-controlled server wallets do not support custom recovery methods",code:"embedded_wallet_creation_error"});await i.walletCreate({context:{app:this._appApi,fetchPrivyRoute:(...e)=>this._privyInternal.fetch(...e),getCompiledPath:(...e)=>this._privyInternal.getPath(...e)},chainType:"ethereum",idempotencyKey:c})}else{let r;if(r=t||(e?"user-passcode":"privy"),e&&"string"!=typeof e)throw Error("Invalid recovery password, must be a string");if("privy"===r&&this._privyInternal.config?.embedded_wallet_config.require_user_password_on_create)throw Error("Password not provided yet is required by App configuration");let i=await this._privyInternal.getAccessTokenInternal();if(!i)throw Error("User must be logged in to create an embedded wallet");let{address:l}=await this._proxy.create({accessToken:i,recoveryMethod:r,recoveryKey:d,recoveryPassword:e,recoveryAccessToken:o,recoverySecretOverride:a,iCloudRecordNameOverride:s,solanaAddress:n?.address});if(!l)throw Error("Failed to create wallet")}return await this._privyInternal.refreshSession(l)}async createSolana(e){if(!this._proxy)throw new r.PrivyClientError({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_creation_error"});if("user-controlled-server-wallets-only"===this._privyInternal.config?.embedded_wallet_config.mode)await i.walletCreate({context:{app:this._appApi,fetchPrivyRoute:(...e)=>this._privyInternal.fetch(...e),getCompiledPath:(...e)=>this._privyInternal.getPath(...e)},chainType:"solana",idempotencyKey:e?.idempotencyKey});else{let t=await this._privyInternal.getAccessTokenInternal();if(!t)throw new r.PrivyClientError({error:"User must be logged in to create an embedded wallet",code:"embedded_wallet_creation_error"});e?.ethereumAccount&&await this.getProvider(e.ethereumAccount);let{publicKey:o}=await this._proxy.createSolana({accessToken:t,ethereumAddress:e?.ethereumAccount?.address});if(!o)throw new r.PrivyClientError({error:"Failed to create wallet",code:"embedded_wallet_creation_error"})}return await this._privyInternal.refreshSession()}async delegateWallets({delegatedWallets:e,rootWallet:t}){if(!this._proxy)throw new r.PrivyClientError({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_creation_error"});let o=await this._privyInternal.getAccessTokenInternal();if(!o)throw new r.PrivyClientError({error:"User must be logged in to create an embedded wallet",code:"embedded_wallet_creation_error"});await this._proxy.delegateWallets({accessToken:o,delegatedWallets:e,rootWallet:t})}async getProvider(e,r,t,o,i){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");return a.isUnifiedWallet(e)||await this._load({wallet:e,entropyId:e.address,entropyIdVerifier:"ethereum-address-verifier",recoveryPassword:r,recoveryKey:i,recoveryAccessToken:t,recoverySecretOverride:o}),new n.EmbeddedWalletProvider({account:e,entropyId:e.address,entropyIdVerifier:"ethereum-address-verifier",privyInternal:this._privyInternal,chains:this._chains,walletProxy:this._proxy,appApi:this._appApi})}async getEthereumProvider({wallet:e,entropyId:r,entropyIdVerifier:t,recoveryPassword:o,recoveryAccessToken:i,recoverySecretOverride:d,recoveryKey:s,onNeedsRecovery:l}){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if(!await this._privyInternal.getAccessTokenInternal())throw Error("User must be logged in to create an embedded wallet");return a.isUnifiedWallet(e)||(!l||o||i||d||s)&&await this._load({entropyId:r,entropyIdVerifier:t,wallet:e,recoveryPassword:o,recoveryAccessToken:i,recoverySecretOverride:d,recoveryKey:s}),new n.EmbeddedWalletProvider({account:e,entropyId:r,entropyIdVerifier:"ethereum-address-verifier",privyInternal:this._privyInternal,chains:this._chains,walletProxy:this._proxy,onNeedsRecovery:l,appApi:this._appApi})}async getSolanaProvider(e,t,o,i,d,s,n){if(!this._proxy)throw new r.PrivyClientError({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_webview_not_loaded"});return a.isUnifiedWallet(e)||(!n||i||d||s)&&await this._load({wallet:e,entropyId:t,entropyIdVerifier:o,recoveryPassword:i,recoveryAccessToken:d,recoverySecretOverride:s}),new l.EmbeddedSolanaWalletProvider({account:e,privyInternal:this._privyInternal,proxy:this._proxy,entropyId:t,entropyIdVerifier:o,onNeedsRecovery:n,app:this._appApi})}async setRecovery(e){let{wallet:t,...o}=e;if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if(a.isUnifiedWallet(t))throw new r.PrivyClientError({error:"This wallet does not support setting recovery methods",code:"unsupported_recovery_method"});d.throwIfInvalidRecoveryUpgradePath({currentRecoveryMethod:t.recovery_method,upgradeToRecoveryMethod:"icloud-native"===o.recoveryMethod?"icloud":o.recoveryMethod}),await this._load("solana"===t.chain_type?{wallet:t,entropyId:t.address,entropyIdVerifier:"solana-address-verifier"}:{wallet:t,entropyId:t.address,entropyIdVerifier:"ethereum-address-verifier"});let i=await this._privyInternal.getAccessTokenInternal();if(!i)throw Error("User must be logged in to interact with embedded wallets");let s=t.recovery_method;this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_set_recovery_started",{address:t.address,target_recovery_method:o.recoveryMethod,existing_recovery_method:s});try{let e;if("user-passcode"===o.recoveryMethod)e={recoveryMethod:"user-passcode",recoveryPassword:o.password};else if("google-drive"===o.recoveryMethod)e={recoveryMethod:"google-drive",recoveryAccessToken:o.recoveryAccessToken};else if("icloud"===o.recoveryMethod)e={recoveryMethod:"icloud",recoveryAccessToken:o.recoveryAccessToken};else if("icloud-native"===o.recoveryMethod)e={recoveryMethod:"icloud-native",iCloudRecordNameOverride:o.iCloudRecordNameOverride,recoverySecretOverride:o.recoverySecretOverride};else if("recovery-encryption-key"===o.recoveryMethod)e={recoveryMethod:"recovery-encryption-key",recoveryKey:o.recoveryKey};else{if("privy"!==o.recoveryMethod)throw Error(`Unknown recovery method: ${o.recoveryMethod}`);e={recoveryMethod:"privy"}}await this._proxy.setRecovery({accessToken:i,entropyId:t.address,entropyIdVerifier:"solana"===t.chain_type?"solana-address-verifier":"ethereum-address-verifier",...e}),this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_set_recovery_completed",{address:t.address,target_recovery_method:o.recoveryMethod,existing_recovery_method:s});let{user:r}=await this._privyInternal.refreshSession();return{user:r,provider:"ethereum"!==t.chain_type?null:new n.EmbeddedWalletProvider({account:t,entropyId:t.address,entropyIdVerifier:"ethereum-address-verifier",privyInternal:this._privyInternal,chains:this._chains,walletProxy:this._proxy,appApi:this._appApi})}}catch(e){throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_set_recovery_failed",{address:t.address,recovery_method:t.recovery_method,error:e instanceof Error?e.message:"Unable to recover wallet"}),e}}getURL(){let e=new URL(`${this._privyInternal.baseUrl}/apps/${this._privyInternal.appId}/embedded-wallets`);return this._privyInternal.caid&&e.searchParams.append("caid",this._privyInternal.caid),this._privyInternal.appClientId&&e.searchParams.append("client_id",this._privyInternal.appClientId),e.href}get chains(){return this._chains}onMessage(e){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");return this._proxy.handleEmbeddedWalletMessages(e)}reload(){this._proxy?this._proxy.reload():this._privyInternal.logger.warn("Attempted to reload proxy before initialized")}async ping(e){try{if(!this._proxy)throw Error("Embedded wallet proxy not initialized");return await this._proxy.ping(e),!0}catch(e){return this._privyInternal.logger.debug(e),!1}}async _load({entropyId:e,entropyIdVerifier:r,wallet:t,recoveryPassword:i,recoveryKey:d,recoveryAccessToken:a,recoverySecretOverride:s}){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");let n=await this._privyInternal.getAccessTokenInternal();if(!n)throw Error("User must be logged in to interact with embedded wallets");try{return await this._proxy.connect({accessToken:n,entropyId:e,entropyIdVerifier:r}),e}catch(l){if(o.errorIndicatesRecoveryIsNeeded(l))try{if("privy"===t.recovery_method){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:t.address,recovery_method:t.recovery_method});let o=await this._proxy.recover({accessToken:n,entropyId:e,entropyIdVerifier:r});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:t.address,recovery_method:t.recovery_method}),o.entropyId}if("user-passcode"===t.recovery_method&&i){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:t.address,recovery_method:t.recovery_method});let o=await this._proxy.recover({accessToken:n,recoveryPassword:i,entropyId:e,entropyIdVerifier:r});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:t.address,recovery_method:t.recovery_method}),o.entropyId}if(["google-drive","icloud"].includes(t.recovery_method)&&a){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:t.address,recovery_method:t.recovery_method});let o=await this._proxy.recover({accessToken:n,recoveryAccessToken:a,entropyId:e,entropyIdVerifier:r});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:t.address,recovery_method:t.recovery_method}),o.entropyId}if("icloud"===t.recovery_method&&s){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:t.address,recovery_method:"icloud-native"});let o=await this._proxy.recover({accessToken:n,recoverySecretOverride:s,entropyId:e,entropyIdVerifier:r});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:t.address,recovery_method:"icloud-native"}),o.entropyId}if("recovery-encryption-key"===t.recovery_method&&d){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:t.address,recovery_method:t.recovery_method});let o=await this._proxy.recover({accessToken:n,recoveryKey:d,entropyId:e,entropyIdVerifier:r});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:t.address,recovery_method:t.recovery_method}),o.entropyId}}catch(r){throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_failed",{address:t.address,recovery_method:t.recovery_method,error:r instanceof Error?r.message:`Unable to recover wallet: ${e}`}),r}throw l}}constructor(r,t,o,i,d,a){if(this._chains=Array.from(e.DEFAULT_SUPPORTED_CHAINS),this._privyInternal=r,t&&(this._proxy=new s.EmbeddedWalletProxy(t,d),i.setProxy(this._proxy)),o){let r=e.dedupeSupportedChains(o);this._chains=r}this._mfa=i,this._mfaPromises=d,this._appApi=a}};
|
|
2
2
|
//# sourceMappingURL=EmbeddedWalletApi.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmbeddedWalletApi.js","sources":["../../../src/client/EmbeddedWalletApi.ts"],"names":["setMessagePoster","poster","this","_proxy","EmbeddedWalletProxy","_mfaPromises","_mfa","setProxy","signWithUserSigner","opts","Error","accessToken","_privyInternal","getAccessTokenInternal","PrivyClientError","error","code","signature","message","add","config","embedded_wallet_config","mode","walletCreate","context","app","_appApi","fetchPrivyRoute","args","fetch","getCompiledPath","getPath","chainType","addWallet","user","refreshSession","getBitcoinProvider","wallet","entropyId","entropyIdVerifier","recoveryPassword","recoveryAccessToken","recoverySecretOverride","isUnifiedWallet","_load","EmbeddedBitcoinWalletProvider","account","privyInternal","proxy","create","password","recoveryMethod","recoveryToken","recoveryKey","iCloudRecordNameOverride","solanaAccount","skipCallbacks","idempotencyKey","walletMode","startsWith","parsedRecoveryMethod","require_user_password_on_create","address","solanaAddress","createSolana","ethereumAccount","getProvider","publicKey","ethereumAddress","delegateWallets","delegatedWallets","rootWallet","EmbeddedWalletProvider","chains","_chains","walletProxy","appApi","getEthereumProvider","onNeedsRecovery","getSolanaProvider","EmbeddedSolanaWalletProvider","setRecovery","setRecoveryInput","recoveryArgs","throwIfInvalidRecoveryUpgradePath","currentRecoveryMethod","recovery_method","upgradeToRecoveryMethod","chain_type","existingRecoveryMethod","createAnalyticsEvent","target_recovery_method","existing_recovery_method","recoveryOnlyArgs","provider","e","getURL","url","URL","baseUrl","appId","caid","searchParams","append","appClientId","href","onMessage","event","handleEmbeddedWalletMessages","reload","console","warn","ping","timeoutMs","connect","err","errorIndicatesRecoveryIsNeeded","recovered","recover","includes","constructor","embeddedWalletMessagePoster","mfa","mfaPromises","Array","from","DEFAULT_SUPPORTED_CHAINS","dedupedChains","dedupeSupportedChains"],"mappings":"4vCAmEe,MAoENA,gBAAAA,CAAiBC,GACtBC,KAAKC,OAAS,IAAIC,EAAAA,oBAAoBH,EAAQC,KAAKG,cACnDH,KAAKI,KAAKC,SAASL,KAAKC,OAC1B,CAWA,wBAAaK,CAAmBC,GAC9B,IAAKP,KAAKC,OACR,MAAMO,MAAU,yCAGlB,IAAMC,QAAoBT,KAAKU,eAAeC,yBAC9C,IAAKF,EACH,MAAM,IAAIG,EAAAA,iBAAiB,CACzBC,MAAO,gEACPC,KAAM,2BAIV,IAAOC,UAAAA,SAAmBf,KAAKC,OAAOK,mBAAmB,CACvDG,YAAAA,EACAO,QAAST,EAAKS,UAGhB,MAAO,CAACD,UAAAA,EACV,CAeA,SAAaE,CAAIV,GAMf,IAAKP,KAAKC,OACR,MAAMO,MAAU,yCAIlB,GAAmB,wCADAR,KAAKU,eAAeQ,QAAQC,uBAAuBC,WAE9DC,EAAAA,aAAa,CACjBC,QAAS,CACPC,IAAKvB,KAAKwB,QACVC,gBAAiB,IAAIC,IAAS1B,KAAKU,eAAeiB,SAASD,GAC3DE,gBAAiB,IAAIF,IAAS1B,KAAKU,eAAemB,WAAWH,IAE/DI,UAAWvB,EAAKuB,gBAEb,CACL,IAAMrB,QAAoBT,KAAKU,eAAeC,yBAC9C,IAAKF,EACH,MAAM,IAAIG,EAAAA,iBAAiB,CACzBC,MAAO,sDACPC,KAAM,yCAIJd,KAAKC,OAAO8B,UAAU,CAC1BtB,YA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yCACA,CACE5B,QAASzB,EAAOyB,QAChBwB,gBAAiB,kBAId+B,EAAU/E,SACnB,CAGA,GAA+B,4BAA3BD,EAAOiD,iBAAiDjC,EAAa,CAClEnD,KAAKU,eAAe8E,qBAAqB,uCAAwC,CACpF5B,QAASzB,EAAOyB,QAChBwB,gBAAiBjD,EAAOiD,kBAG1B,IAAM+B,QAAkBnH,KAAKC,OAAOmH,QAAQ,CAC1C3G,YAAAA,EACA0C,YAAAA,EACAf,UAAAA,EACAC,kBAAAA,IAWF,OARKrC,KAAKU,eAAe8E,qBACvB,yCACA,CACE5B,QAASzB,EAAOyB,QAChBwB,gBAAiBjD,EAAOiD,kBAIrB+B,EAAU/E,SAAS,CAE9B,CAAE,MAAOyD,GAMP,MALK7F,KAAKU,eAAe8E,qBAAqB,sCAAuC,CACnF5B,QAASzB,EAAOyB,QAChBwB,gBAAiBjD,EAAOiD,gBACxBvE,MAAOgF,aAAarF,MAAQqF,EAAE7E,QAAU,6BAA6BoB,MAEjEyD,CACR,CAKA,MAAMoB,CAEV,CACF,CAz6BAK,WAAAA,CACEzE,EACA0E,EACAhD,EACAiD,EACAC,EACA/C,GASA,GAtCD1E,KACOwE,QAAgCkD,MAAMC,KAC5CC,EAAAA,0BA6BA5H,KAAKU,eAAiBmC,EAElB0E,IACFvH,KAAKC,OAAS,IAAIC,sBAAoBqH,EAA6BE,GACnED,EAAInH,SAASL,KAAKC,SAGhBsE,EAAQ,CACV,IAAMsD,EAAgBC,EAAAA,sBAAsBvD,GAC5CvE,KAAKwE,QAAUqD,CACjB,CAEA7H,KAAKI,KAAOoH,EACZxH,KAAKG,aAAesH,EACpBzH,KAAKwB,QAAUkD,CACjB"}
|
|
1
|
+
{"version":3,"file":"EmbeddedWalletApi.js","sources":["../../../src/client/EmbeddedWalletApi.ts"],"names":["setMessagePoster","poster","this","_proxy","EmbeddedWalletProxy","_mfaPromises","_mfa","setProxy","signWithUserSigner","opts","Error","accessToken","_privyInternal","getAccessTokenInternal","PrivyClientError","error","code","signature","message","add","config","embedded_wallet_config","mode","walletCreate","context","app","_appApi","fetchPrivyRoute","args","fetch","getCompiledPath","getPath","chainType","addWallet","user","refreshSession","getBitcoinProvider","wallet","entropyId","entropyIdVerifier","recoveryPassword","recoveryAccessToken","recoverySecretOverride","isUnifiedWallet","_load","EmbeddedBitcoinWalletProvider","account","privyInternal","proxy","create","password","recoveryMethod","recoveryToken","recoveryKey","iCloudRecordNameOverride","solanaAccount","skipCallbacks","idempotencyKey","walletMode","startsWith","parsedRecoveryMethod","require_user_password_on_create","address","solanaAddress","createSolana","ethereumAccount","getProvider","publicKey","ethereumAddress","delegateWallets","delegatedWallets","rootWallet","EmbeddedWalletProvider","chains","_chains","walletProxy","appApi","getEthereumProvider","onNeedsRecovery","getSolanaProvider","EmbeddedSolanaWalletProvider","setRecovery","setRecoveryInput","recoveryArgs","throwIfInvalidRecoveryUpgradePath","currentRecoveryMethod","recovery_method","upgradeToRecoveryMethod","chain_type","existingRecoveryMethod","createAnalyticsEvent","target_recovery_method","existing_recovery_method","recoveryOnlyArgs","provider","e","getURL","url","URL","baseUrl","appId","caid","searchParams","append","appClientId","href","onMessage","event","handleEmbeddedWalletMessages","reload","logger","warn","ping","timeoutMs","debug","connect","err","errorIndicatesRecoveryIsNeeded","recovered","recover","includes","constructor","embeddedWalletMessagePoster","mfa","mfaPromises","Array","from","DEFAULT_SUPPORTED_CHAINS","dedupedChains","dedupeSupportedChains"],"mappings":"4vCAmEe,MAoENA,gBAAAA,CAAiBC,GACtBC,KAAKC,OAAS,IAAIC,EAAAA,oBAAoBH,EAAQC,KAAKG,cACnDH,KAAKI,KAAKC,SAASL,KAAKC,OAC1B,CAWA,wBAAaK,CAAmBC,GAC9B,IAAKP,KAAKC,OACR,MAAMO,MAAU,yCAGlB,IAAMC,QAAoBT,KAAKU,eAAeC,yBAC9C,IAAKF,EACH,MAAM,IAAIG,EAAAA,iBAAiB,CACzBC,MAAO,gEACPC,KAAM,2BAIV,IAAOC,UAAA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qB,CAEV,CACF,CAz6BAK,WAAAA,CACE1E,EACA2E,EACAjD,EACAkD,EACAC,EACAhD,GASA,GAtCD1E,KACOwE,QAAgCmD,MAAMC,KAC5CC,EAAAA,0BA6BA7H,KAAKU,eAAiBmC,EAElB2E,IACFxH,KAAKC,OAAS,IAAIC,sBAAoBsH,EAA6BE,GACnED,EAAIpH,SAASL,KAAKC,SAGhBsE,EAAQ,CACV,IAAMuD,EAAgBC,EAAAA,sBAAsBxD,GAC5CvE,KAAKwE,QAAUsD,CACjB,CAEA9H,KAAKI,KAAOqH,EACZzH,KAAKG,aAAeuH,EACpB1H,KAAKwB,QAAUkD,CACjB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("fetch-retry"),t=require("uuid"),s=require("@privy-io/api-base"),i=require("@privy-io/routes"),r=require("../Error.js"),a=require("../Session.js"),n=require("../toAbortSignalTimeout.js"),o=require("../utils/toSearchParams.js"),h=require("./logger.js");function c(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 l=/*#__PURE__*/c(e);let g="privy:caid";exports.PrivyInternal=class{setCallbacks(e){this.callbacks={...this.callbacks,...e}}get isReady(){return!!this._config}get config(){return this._config}get caid(){return this._analyticsId}async _initialize(){if(this.isReady)this.callbacks?.setIsReady?.(!0);else{if(!await this.isStorageAccessible())throw new r.PrivyClientError({code:"storage_error",error:"Unable to access storage"});this._config=await this.getAppConfig(),this._config?.custom_api_url&&(this.baseUrl=this._config.custom_api_url,this.session.isUsingServerCookies=!0),this.callbacks?.setIsReady?.(!0),this._sdkVersion.startsWith("react-auth:")||this.createAnalyticsEvent("sdk_initialize",{})}}getPath(e,{params:t,query:s}){return`${this.baseUrl}${i.getPathWithParams(e.path,t)}${o.toSearchParams(s)}`}async fetch(e,{body:t,params:s,query:i,headers:a,onRequest:n=this._beforeRequest.bind(this)}){let o=new Request(this.getPath(e,{params:s,query:i}),{method:e.method,body:JSON.stringify(t),headers:a}),h=await n(o),c=await this._fetch(o,h),l=await c.json();if(c.status>299)throw new r.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:n.default(2e4),headers:s,credentials:"include"}}async beforeRequestWithoutRefresh(e){return await this._initialize(),this._beforeRequestWithoutInitialize(e)}async _beforeRequest(e){return await this._initialize(),await this.getAccessTokenInternal(),this.beforeRequestWithoutRefresh(e)}async getAppConfig(){return await this.fetch(i.AppConfig,{params:{app_id:this.appId},onRequest:this._beforeRequestWithoutInitialize.bind(this)})}async _getOrGenerateClientAnalyticsId(){if(this._analyticsId)return this._analyticsId;try{let e=await this._storage.get(g);if("string"==typeof e&&e.length>0)return this._analyticsId=e,e}catch(e){this.logger.error("Unable to load clientId",e)}try{this._analyticsId=t.v4()}catch(e){this.logger.error("Unable to generate uuidv4",e)}if(this._analyticsId){try{await this._storage.put(g,this._analyticsId)}catch(e){this.logger.error(`Unable to store clientId: ${this._analyticsId}`,e)}return this._analyticsId}}async destroyClientAnalyticsId(){try{return await this._storage.del(g)}catch(e){this.logger.error("Unable to delete clientId",e)}}async createAnalyticsEvent(e,t){try{await this.fetch(i.AnalyticsEvent,{body:{event_name:e,client_id:await this._getOrGenerateClientAnalyticsId(),payload:t},onRequest:this.beforeRequestWithoutRefresh.bind(this)})}catch(e){}}async refreshSession(e=!1){if(!await this.isStorageAccessible())throw new r.PrivyClientError({code:"storage_error",error:"Unable to access storage"});let t=await this.session.getRefreshToken()??void 0,s=t??"key",i=this._cache.get(s);if(i)return this.logger.debug("[privy:refresh] found in-flight session refresh request, deduping"),await i;let a=this._refreshSession(t,e);this._cache.set(s,a);try{return await a}finally{this._cache.delete(s)}}async _refreshSession(e,t){let a=await this.session.getCustomerAccessToken();if(!this.session.hasRefreshCredentials(a,e??null))throw this.logger.debug("[privy:refresh] missing tokens, skipping request"),await this._initialize(),new r.PrivyApiError({code:s.PrivyErrorCode.MISSING_OR_INVALID_TOKEN,error:"No tokens found in storage",status:401});try{this.logger.debug(`[privy:refresh] fetching: ${i.RefreshSession.path}`);let s=await this.fetch(i.RefreshSession,{body:{refresh_token:e},onRequest:this.beforeRequestWithoutRefresh.bind(this)}),r=s.session_update_action;return this.logger.debug(`[privy:refresh] response: ${r}`),"set"===r&&(await this.session.updateWithTokensResponse(s),this.logger.debug("[privy:refresh] tokens stored")),"clear"===r&&(await this.session.destroyLocalState(),this.logger.debug("[privy:refresh] tokens cleared"),t||this.callbacks?.setUser?.(null)),"ignore"===r&&(s.token&&(await this.session.storeCustomerAccessToken(s.token),this.logger.debug("[privy:refresh] token stored (CAT)")),s.privy_access_token&&(await this.session.storePrivyAccessToken(s.privy_access_token),this.logger.debug("[privy:refresh] token stored (PAT)")),s.identity_token&&(this.logger.debug("[privy:refresh] token stored (IDT)"),await this.session.storeIdentityToken(s.identity_token))),this.logger.debug("[privy:refresh] returning response"),t||this.callbacks?.setUser?.(s.user),s}catch(e){throw this.logger.debug(`[privy:refresh] error: ${e.message??"unknown error"}`),e instanceof r.PrivyApiError&&e.code===s.PrivyErrorCode.MISSING_OR_INVALID_TOKEN&&(await this.session.destroyLocalState(),t||this.callbacks?.setUser?.(null)),e}}async getAccessToken(){let[e,t]=await Promise.all([this.session.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-${t.v4()}`,s="blobby";await this._storage.put(e,s);let i=await this._storage.get(e);return await this._storage.del(e),i===s}catch(e){return this.logger.error(e),!1}}constructor(e){this._sdkVersion="js-sdk-core:0.61.
|
|
1
|
+
"use strict";var e=require("fetch-retry"),t=require("uuid"),s=require("@privy-io/api-base"),i=require("@privy-io/routes"),r=require("../Error.js"),a=require("../Session.js"),n=require("../toAbortSignalTimeout.js"),o=require("../utils/toSearchParams.js"),h=require("./logger.js");function c(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 l=/*#__PURE__*/c(e);let g="privy:caid";exports.PrivyInternal=class{setCallbacks(e){this.callbacks={...this.callbacks,...e}}get isReady(){return!!this._config}get config(){return this._config}get caid(){return this._analyticsId}async _initialize(){if(this.isReady)this.callbacks?.setIsReady?.(!0);else{if(!await this.isStorageAccessible())throw new r.PrivyClientError({code:"storage_error",error:"Unable to access storage"});this._config=await this.getAppConfig(),this._config?.custom_api_url&&(this.baseUrl=this._config.custom_api_url,this.session.isUsingServerCookies=!0),this.callbacks?.setIsReady?.(!0),this._sdkVersion.startsWith("react-auth:")||this.createAnalyticsEvent("sdk_initialize",{})}}getPath(e,{params:t,query:s}){return`${this.baseUrl}${i.getPathWithParams(e.path,t)}${o.toSearchParams(s)}`}async fetch(e,{body:t,params:s,query:i,headers:a,onRequest:n=this._beforeRequest.bind(this)}){let o=new Request(this.getPath(e,{params:s,query:i}),{method:e.method,body:JSON.stringify(t),headers:a}),h=await n(o),c=await this._fetch(o,h),l=await c.json();if(c.status>299)throw new r.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:n.default(2e4),headers:s,credentials:"include"}}async beforeRequestWithoutRefresh(e){return await this._initialize(),this._beforeRequestWithoutInitialize(e)}async _beforeRequest(e){return await this._initialize(),await this.getAccessTokenInternal(),this.beforeRequestWithoutRefresh(e)}async getAppConfig(){return await this.fetch(i.AppConfig,{params:{app_id:this.appId},onRequest:this._beforeRequestWithoutInitialize.bind(this)})}async _getOrGenerateClientAnalyticsId(){if(this._analyticsId)return this._analyticsId;try{let e=await this._storage.get(g);if("string"==typeof e&&e.length>0)return this._analyticsId=e,e}catch(e){this.logger.error("Unable to load clientId",e)}try{this._analyticsId=t.v4()}catch(e){this.logger.error("Unable to generate uuidv4",e)}if(this._analyticsId){try{await this._storage.put(g,this._analyticsId)}catch(e){this.logger.error(`Unable to store clientId: ${this._analyticsId}`,e)}return this._analyticsId}}async destroyClientAnalyticsId(){try{return await this._storage.del(g)}catch(e){this.logger.error("Unable to delete clientId",e)}}async createAnalyticsEvent(e,t){try{await this.fetch(i.AnalyticsEvent,{body:{event_name:e,client_id:await this._getOrGenerateClientAnalyticsId(),payload:t},onRequest:this.beforeRequestWithoutRefresh.bind(this)})}catch(e){}}async refreshSession(e=!1){if(!await this.isStorageAccessible())throw new r.PrivyClientError({code:"storage_error",error:"Unable to access storage"});let t=await this.session.getRefreshToken()??void 0,s=t??"key",i=this._cache.get(s);if(i)return this.logger.debug("[privy:refresh] found in-flight session refresh request, deduping"),await i;let a=this._refreshSession(t,e);this._cache.set(s,a);try{return await a}finally{this._cache.delete(s)}}async _refreshSession(e,t){let a=await this.session.getCustomerAccessToken();if(!this.session.hasRefreshCredentials(a,e??null))throw this.logger.debug("[privy:refresh] missing tokens, skipping request"),await this._initialize(),new r.PrivyApiError({code:s.PrivyErrorCode.MISSING_OR_INVALID_TOKEN,error:"No tokens found in storage",status:401});try{this.logger.debug(`[privy:refresh] fetching: ${i.RefreshSession.path}`);let s=await this.fetch(i.RefreshSession,{body:{refresh_token:e},onRequest:this.beforeRequestWithoutRefresh.bind(this)}),r=s.session_update_action;return this.logger.debug(`[privy:refresh] response: ${r}`),"set"===r&&(await this.session.updateWithTokensResponse(s),this.logger.debug("[privy:refresh] tokens stored")),"clear"===r&&(await this.session.destroyLocalState(),this.logger.debug("[privy:refresh] tokens cleared"),t||this.callbacks?.setUser?.(null)),"ignore"===r&&(s.token&&(await this.session.storeCustomerAccessToken(s.token),this.logger.debug("[privy:refresh] token stored (CAT)")),s.privy_access_token&&(await this.session.storePrivyAccessToken(s.privy_access_token),this.logger.debug("[privy:refresh] token stored (PAT)")),s.identity_token&&(this.logger.debug("[privy:refresh] token stored (IDT)"),await this.session.storeIdentityToken(s.identity_token))),this.logger.debug("[privy:refresh] returning response"),t||this.callbacks?.setUser?.(s.user),s}catch(e){throw this.logger.debug(`[privy:refresh] error: ${e.message??"unknown error"}`),e instanceof r.PrivyApiError&&e.code===s.PrivyErrorCode.MISSING_OR_INVALID_TOKEN&&(await this.session.destroyLocalState(),t||this.callbacks?.setUser?.(null)),e}}async getAccessToken(){let[e,t]=await Promise.all([this.session.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-${t.v4()}`,s="blobby";await this._storage.put(e,s);let i=await this._storage.get(e);return await this._storage.del(e),i===s}catch(e){return this.logger.error(e),!1}}constructor(e){this._sdkVersion="js-sdk-core:0.61.2",this._cache=new Map,this.logger=h.toLoggerWithLevel({level:e.logger?.level??e.logLevel??"ERROR",logger:e.logger??console}),this._storage=e.storage,this._analyticsId=null,this._getOrGenerateClientAnalyticsId(),this.baseUrl=e.baseUrl??"https://auth.privy.io",this.appId=e.appId,this.appClientId=e.appClientId,this._sdkVersion=e.sdkVersion??this._sdkVersion,this.callbacks=e.callbacks,this.nativeAppIdentifier=e.nativeAppIdentifier,this.session=new a.Session({storage:this._storage,isUsingServerCookies:!1,appId:e.appId}),this._fetch=l.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("../../utils/getUserEmbeddedEthereumWallet.js"),t=require("../../utils/getUserEmbeddedSolanaWallet.js"),r=require("../../utils/shouldCreateEmbeddedEthWallet.js"),
|
|
1
|
+
"use strict";var e=require("../../utils/getUserEmbeddedEthereumWallet.js"),t=require("../../utils/getUserEmbeddedSolanaWallet.js"),r=require("../../utils/shouldCreateEmbeddedEthWallet.js"),l=require("../../utils/shouldCreateEmbeddedSolWallet.js");require("../../utils/getAllUserEmbeddedEthereumWallets.js"),require("../../utils/embedded-wallets.js"),require("../../utils/getAllUserEmbeddedSolanaWallets.js");let a=(e,t)=>({...e,is_new_user:t.is_new_user,oauth_tokens:t.oauth_tokens});exports.maybeCreateWalletOnLogin=async(s,d,u)=>{let o=r.shouldCreateEmbeddedEthWallet(d.user,u?.ethereum?.createOnLogin??"off"),i=l.shouldCreateEmbeddedSolWallet(d.user,u?.solana?.createOnLogin??"off");if(o&&i){let t=await s.create({recoveryMethod:"privy",skipCallbacks:!0});return a(await s.createSolana({ethereumAccount:e.getUserEmbeddedEthereumWallet(t.user)??void 0}),d)}return o?a(await s.create({recoveryMethod:"privy",solanaAccount:t.getUserEmbeddedSolanaWallet(d.user)??void 0}),d):i?a(await s.createSolana({ethereumAccount:e.getUserEmbeddedEthereumWallet(d.user)??void 0}),d):d};
|
|
2
2
|
//# sourceMappingURL=maybeCreateWalletOnLogin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maybeCreateWalletOnLogin.js","sources":["../../../../src/client/auth/maybeCreateWalletOnLogin.ts"],"names":["
|
|
1
|
+
{"version":3,"file":"maybeCreateWalletOnLogin.js","sources":["../../../../src/client/auth/maybeCreateWalletOnLogin.ts"],"names":["withOriginalMeta","walletResult","original","is_new_user","oauth_tokens","async","api","config","shouldCreateEth","shouldCreateEmbeddedEthWallet","user","ethereum","createOnLogin","shouldCreateSol","shouldCreateEmbeddedSolWallet","solana","withEth","create","recoveryMethod","skipCallbacks","createSolana","ethereumAccount","getUserEmbeddedEthereumWallet","undefined","solanaAccount","getUserEmbeddedSolanaWallet"],"mappings":"wZAcA,IAAMA,EAAmB,CACvBC,EACAC,KAAAA,IAEGD,EACHE,YAAaD,EAASC,YACtBC,aAAcF,EAASE,gDAeeC,MACtCC,EACAJ,EACAK,KAGA,IAAMC,EAAkBC,EAAAA,8BACtBP,EAASQ,KACTH,GAAQI,UAAUC,eAAiB,OAE/BC,EAAkBC,EAAAA,8BACtBZ,EAASQ,KACTH,GAAQQ,QAAQH,eAAiB,OAKnC,GAAIJ,GAAmBK,EAAiB,CACtC,IAAMG,QAAgBV,EAAIW,OAAO,CAACC,eAAgB,QAASC,eAAe,IAK1E,OAAOnB,QAJeM,EAAIc,aAAa,CACrCC,gBAAiBC,EAAAA,8BAA8BN,EAAQN,YAASa,IAGjCrB,EACnC,QAGIM,EAMKR,QALeM,EAAIW,OAAO,CAC/BC,eAAgB,QAChBM,cAAeC,EAAAA,4BAA4BvB,EAASQ,YAASa,IAG9BrB,GAI/BW,EAKKb,QAJeM,EAAIc,aAAa,CACrCC,gBAAiBC,gCAA8BpB,EAASQ,YAASa,IAGlCrB,GAI5BA,CAAAA"}
|
package/dist/dts/index.d.mts
CHANGED
|
@@ -1390,7 +1390,7 @@ type CoinbaseWalletClientType = (typeof COINBASE_WALLET_CLIENT_TYPES)[number];
|
|
|
1390
1390
|
type WalletConnectWalletClientType = (typeof WALLET_CONNECT_WALLET_CLIENT_TYPES)[number];
|
|
1391
1391
|
declare const UNKNOWN_WALLET_CLIENT_TYPES: readonly ["unknown"];
|
|
1392
1392
|
type UnknownWalletClientType = (typeof UNKNOWN_WALLET_CLIENT_TYPES)[number];
|
|
1393
|
-
declare const ALL_WALLET_CLIENT_TYPES: ("safe" | "
|
|
1393
|
+
declare const ALL_WALLET_CLIENT_TYPES: ("safe" | "privy" | "metamask" | "phantom" | "brave_wallet" | "rainbow" | "coinbase_wallet" | "trust" | "uniswap" | "zerion" | "argent" | "spot" | "omni" | "cryptocom" | "blockchain" | "safepal" | "bitget_wallet" | "zengo" | "1inch" | "binance" | "exodus" | "mew_wallet" | "alphawallet" | "keyring_pro" | "mathwallet" | "unstoppable" | "obvious" | "ambire" | "internet_money_wallet" | "coin98" | "abc_wallet" | "arculus_wallet" | "haha" | "cling_wallet" | "broearn" | "copiosa" | "burrito_wallet" | "enjin_wallet" | "plasma_wallet" | "avacus" | "bee" | "pitaka" | "pltwallet" | "minerva" | "kryptogo" | "prema" | "slingshot" | "kriptonio" | "timeless" | "secux" | "bitizen" | "blocto" | "safemoon" | "unknown")[];
|
|
1394
1394
|
type WalletClientType = InjectedWalletClientType | CoinbaseWalletClientType | WalletConnectWalletClientType | EmbeddedWalletClientType | UnknownWalletClientType;
|
|
1395
1395
|
declare const SUPPORTED_CONNECTOR_TYPES: readonly ["injected", "wallet_connect", "wallet_connect_v2", "coinbase_wallet", "embedded"];
|
|
1396
1396
|
type ConnectorType = (typeof SUPPORTED_CONNECTOR_TYPES)[number];
|
|
@@ -2431,7 +2431,10 @@ declare const revokeWallets: (client: Privy) => () => Promise<{
|
|
|
2431
2431
|
declare const index$2_delegateWallet: typeof delegateWallet;
|
|
2432
2432
|
declare const index$2_revokeWallets: typeof revokeWallets;
|
|
2433
2433
|
declare namespace index$2 {
|
|
2434
|
-
export {
|
|
2434
|
+
export {
|
|
2435
|
+
index$2_delegateWallet as delegateWallet,
|
|
2436
|
+
index$2_revokeWallets as revokeWallets,
|
|
2437
|
+
};
|
|
2435
2438
|
}
|
|
2436
2439
|
|
|
2437
2440
|
interface LoginWithCrossAppAuthDependencies {
|
|
@@ -2552,7 +2555,8 @@ declare const index$1_sendTransaction: typeof sendTransaction;
|
|
|
2552
2555
|
declare const index$1_signMessage: typeof signMessage;
|
|
2553
2556
|
declare const index$1_signTypedData: typeof signTypedData;
|
|
2554
2557
|
declare namespace index$1 {
|
|
2555
|
-
export {
|
|
2558
|
+
export { index$1_sendTransaction as sendTransaction, index$1_signMessage as signMessage, index$1_signTypedData as signTypedData };
|
|
2559
|
+
export type { index$1_SendTransactionDependencies as SendTransactionDependencies, index$1_SendTransactionInput as SendTransactionInput, index$1_SendTransactionOutput as SendTransactionOutput, index$1_SignMessageDependencies as SignMessageDependencies, index$1_SignMessageInput as SignMessageInput, index$1_SignMessageOutput as SignMessageOutput, index$1_SignTypedDataDependencies as SignTypedDataDependencies, index$1_SignTypedDataInput as SignTypedDataInput, index$1_SignTypedDataOutput as SignTypedDataOutput };
|
|
2556
2560
|
}
|
|
2557
2561
|
|
|
2558
2562
|
type index_LinkWithCrossAppAuthDependencies = LinkWithCrossAppAuthDependencies;
|
|
@@ -2564,7 +2568,8 @@ type index_LoginWithCrossAppAuthOutput = LoginWithCrossAppAuthOutput;
|
|
|
2564
2568
|
declare const index_linkWithCrossAppAuth: typeof linkWithCrossAppAuth;
|
|
2565
2569
|
declare const index_loginWithCrossAppAuth: typeof loginWithCrossAppAuth;
|
|
2566
2570
|
declare namespace index {
|
|
2567
|
-
export {
|
|
2571
|
+
export { index_linkWithCrossAppAuth as linkWithCrossAppAuth, index_loginWithCrossAppAuth as loginWithCrossAppAuth, index$1 as wallet };
|
|
2572
|
+
export type { index_LinkWithCrossAppAuthDependencies as LinkWithCrossAppAuthDependencies, index_LinkWithCrossAppAuthInput as LinkWithCrossAppAuthInput, index_LinkWithCrossAppAuthOutput as LinkWithCrossAppAuthOutput, index_LoginWithCrossAppAuthDependencies as LoginWithCrossAppAuthDependencies, index_LoginWithCrossAppAuthInput as LoginWithCrossAppAuthInput, index_LoginWithCrossAppAuthOutput as LoginWithCrossAppAuthOutput };
|
|
2568
2573
|
}
|
|
2569
2574
|
|
|
2570
2575
|
interface SignWalletRequestInput {
|
|
@@ -2807,4 +2812,5 @@ declare const SAFE: "safe";
|
|
|
2807
2812
|
/** @deprecated {@link SmartWalletType} is a well-typed union, use the `'thirdweb'` literal instead */
|
|
2808
2813
|
declare const THIRDWEB: "thirdweb";
|
|
2809
2814
|
|
|
2810
|
-
export { ALL_WALLET_CLIENT_TYPES, BICONOMY, COINBASE_SMART_WALLET,
|
|
2815
|
+
export { ALL_WALLET_CLIENT_TYPES, BICONOMY, COINBASE_SMART_WALLET, ConnectedStandardSolanaWallet, EmbeddedBitcoinWalletProvider, EmbeddedProviderError, InMemoryCache, KERNEL, LIGHT_ACCOUNT, LocalStorage, MoonpayApiError, 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 };
|
|
2816
|
+
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, 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
|
@@ -1390,7 +1390,7 @@ type CoinbaseWalletClientType = (typeof COINBASE_WALLET_CLIENT_TYPES)[number];
|
|
|
1390
1390
|
type WalletConnectWalletClientType = (typeof WALLET_CONNECT_WALLET_CLIENT_TYPES)[number];
|
|
1391
1391
|
declare const UNKNOWN_WALLET_CLIENT_TYPES: readonly ["unknown"];
|
|
1392
1392
|
type UnknownWalletClientType = (typeof UNKNOWN_WALLET_CLIENT_TYPES)[number];
|
|
1393
|
-
declare const ALL_WALLET_CLIENT_TYPES: ("safe" | "
|
|
1393
|
+
declare const ALL_WALLET_CLIENT_TYPES: ("safe" | "privy" | "metamask" | "phantom" | "brave_wallet" | "rainbow" | "coinbase_wallet" | "trust" | "uniswap" | "zerion" | "argent" | "spot" | "omni" | "cryptocom" | "blockchain" | "safepal" | "bitget_wallet" | "zengo" | "1inch" | "binance" | "exodus" | "mew_wallet" | "alphawallet" | "keyring_pro" | "mathwallet" | "unstoppable" | "obvious" | "ambire" | "internet_money_wallet" | "coin98" | "abc_wallet" | "arculus_wallet" | "haha" | "cling_wallet" | "broearn" | "copiosa" | "burrito_wallet" | "enjin_wallet" | "plasma_wallet" | "avacus" | "bee" | "pitaka" | "pltwallet" | "minerva" | "kryptogo" | "prema" | "slingshot" | "kriptonio" | "timeless" | "secux" | "bitizen" | "blocto" | "safemoon" | "unknown")[];
|
|
1394
1394
|
type WalletClientType = InjectedWalletClientType | CoinbaseWalletClientType | WalletConnectWalletClientType | EmbeddedWalletClientType | UnknownWalletClientType;
|
|
1395
1395
|
declare const SUPPORTED_CONNECTOR_TYPES: readonly ["injected", "wallet_connect", "wallet_connect_v2", "coinbase_wallet", "embedded"];
|
|
1396
1396
|
type ConnectorType = (typeof SUPPORTED_CONNECTOR_TYPES)[number];
|
|
@@ -2431,7 +2431,10 @@ declare const revokeWallets: (client: Privy) => () => Promise<{
|
|
|
2431
2431
|
declare const index$2_delegateWallet: typeof delegateWallet;
|
|
2432
2432
|
declare const index$2_revokeWallets: typeof revokeWallets;
|
|
2433
2433
|
declare namespace index$2 {
|
|
2434
|
-
export {
|
|
2434
|
+
export {
|
|
2435
|
+
index$2_delegateWallet as delegateWallet,
|
|
2436
|
+
index$2_revokeWallets as revokeWallets,
|
|
2437
|
+
};
|
|
2435
2438
|
}
|
|
2436
2439
|
|
|
2437
2440
|
interface LoginWithCrossAppAuthDependencies {
|
|
@@ -2552,7 +2555,8 @@ declare const index$1_sendTransaction: typeof sendTransaction;
|
|
|
2552
2555
|
declare const index$1_signMessage: typeof signMessage;
|
|
2553
2556
|
declare const index$1_signTypedData: typeof signTypedData;
|
|
2554
2557
|
declare namespace index$1 {
|
|
2555
|
-
export {
|
|
2558
|
+
export { index$1_sendTransaction as sendTransaction, index$1_signMessage as signMessage, index$1_signTypedData as signTypedData };
|
|
2559
|
+
export type { index$1_SendTransactionDependencies as SendTransactionDependencies, index$1_SendTransactionInput as SendTransactionInput, index$1_SendTransactionOutput as SendTransactionOutput, index$1_SignMessageDependencies as SignMessageDependencies, index$1_SignMessageInput as SignMessageInput, index$1_SignMessageOutput as SignMessageOutput, index$1_SignTypedDataDependencies as SignTypedDataDependencies, index$1_SignTypedDataInput as SignTypedDataInput, index$1_SignTypedDataOutput as SignTypedDataOutput };
|
|
2556
2560
|
}
|
|
2557
2561
|
|
|
2558
2562
|
type index_LinkWithCrossAppAuthDependencies = LinkWithCrossAppAuthDependencies;
|
|
@@ -2564,7 +2568,8 @@ type index_LoginWithCrossAppAuthOutput = LoginWithCrossAppAuthOutput;
|
|
|
2564
2568
|
declare const index_linkWithCrossAppAuth: typeof linkWithCrossAppAuth;
|
|
2565
2569
|
declare const index_loginWithCrossAppAuth: typeof loginWithCrossAppAuth;
|
|
2566
2570
|
declare namespace index {
|
|
2567
|
-
export {
|
|
2571
|
+
export { index_linkWithCrossAppAuth as linkWithCrossAppAuth, index_loginWithCrossAppAuth as loginWithCrossAppAuth, index$1 as wallet };
|
|
2572
|
+
export type { index_LinkWithCrossAppAuthDependencies as LinkWithCrossAppAuthDependencies, index_LinkWithCrossAppAuthInput as LinkWithCrossAppAuthInput, index_LinkWithCrossAppAuthOutput as LinkWithCrossAppAuthOutput, index_LoginWithCrossAppAuthDependencies as LoginWithCrossAppAuthDependencies, index_LoginWithCrossAppAuthInput as LoginWithCrossAppAuthInput, index_LoginWithCrossAppAuthOutput as LoginWithCrossAppAuthOutput };
|
|
2568
2573
|
}
|
|
2569
2574
|
|
|
2570
2575
|
interface SignWalletRequestInput {
|
|
@@ -2807,4 +2812,5 @@ declare const SAFE: "safe";
|
|
|
2807
2812
|
/** @deprecated {@link SmartWalletType} is a well-typed union, use the `'thirdweb'` literal instead */
|
|
2808
2813
|
declare const THIRDWEB: "thirdweb";
|
|
2809
2814
|
|
|
2810
|
-
export { ALL_WALLET_CLIENT_TYPES, BICONOMY, COINBASE_SMART_WALLET,
|
|
2815
|
+
export { ALL_WALLET_CLIENT_TYPES, BICONOMY, COINBASE_SMART_WALLET, ConnectedStandardSolanaWallet, EmbeddedBitcoinWalletProvider, EmbeddedProviderError, InMemoryCache, KERNEL, LIGHT_ACCOUNT, LocalStorage, MoonpayApiError, 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 };
|
|
2816
|
+
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, SolanaCluster, SolanaSignAndSendTransactionInput, SolanaSignAndSendTransactionMode, SolanaSignAndSendTransactionOptions, SolanaSignAndSendTransactionOutput, SolanaSignMessageInput, SolanaSignMessageOutput, SolanaSignTransactionInput, SolanaSignTransactionOptions, SolanaSignTransactionOutput, SolanaStandardWallet, SolanaTransactionCommitment, Storage, UnknownWalletClientType, UnsignedTransactionRequest, UnsignedTransactionRequestWithChainId, WalletBranding, WalletClientType, WalletConnectWalletClientType };
|
|
@@ -26,4 +26,5 @@ type SmartWalletClientType = Omit<SmartAccountClient<Transport, Chain, SmartAcco
|
|
|
26
26
|
}, TPrimaryType extends string>(args: Omit<SignTypedDataParameters<TTypedData, TPrimaryType, SmartAccount>, 'account'>) => Promise<Hex>;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
export {
|
|
29
|
+
export { signerToSmartAccountClient };
|
|
30
|
+
export type { Call, SmartWalletClientType };
|
|
@@ -26,4 +26,5 @@ type SmartWalletClientType = Omit<SmartAccountClient<Transport, Chain, SmartAcco
|
|
|
26
26
|
}, TPrimaryType extends string>(args: Omit<SignTypedDataParameters<TTypedData, TPrimaryType, SmartAccount>, 'account'>) => Promise<Hex>;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
export {
|
|
29
|
+
export { signerToSmartAccountClient };
|
|
30
|
+
export type { Call, SmartWalletClientType };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{DEFAULT_SUPPORTED_CHAINS as e,dedupeSupportedChains as r}from"@privy-io/chains";import{PrivyClientError as t}from"../Error.mjs";import{EmbeddedBitcoinWalletProvider as o}from"../embedded/EmbeddedBitcoinWalletProvider.mjs";import{errorIndicatesRecoveryIsNeeded as i}from"../embedded/errors.mjs";import{walletCreate as d}from"../embedded/stack/walletCreate.mjs";import{throwIfInvalidRecoveryUpgradePath as a}from"../embedded/utils/index.mjs";import{isUnifiedWallet as s}from"../wallet-api/unified-wallet.mjs";import{EmbeddedWalletProxy as n}from"../embedded/EmbeddedWalletProxy.mjs";import{EmbeddedWalletProvider as c}from"../embedded/EmbeddedWalletProvider.mjs";import{EmbeddedSolanaWalletProvider as l}from"../embedded/EmbeddedSolanaWalletProvider.mjs";import"../embedded/types.mjs";import"../wallet-api/create.mjs";import"@privy-io/routes";import"viem";import"../utils/sleep.mjs";import"../embedded/EventCallbackQueue.mjs";import"../embedded/withMfa.mjs";import"eventemitter3";import"@privy-io/ethereum";import"../embedded/stack/walletRpc.mjs";import"../utils/encodings.mjs";import"../wallet-api/rpc.mjs";import"../wallet-api/generate-authorization-signature.mjs";import"canonicalize";import"@privy-io/encoding";import"../wallet-api/types.mjs";import"../embedded/stack/wallet-api-eth-transaction.mjs";import"../embedded/stack/wallet-api-eth-typed-data.mjs";import"../solana/getWalletPublicKeyFromTransaction.mjs";import"../solana/isVersionedTransaction.mjs";class y{setMessagePoster(e){this._proxy=new n(e,this._mfaPromises),this._mfa.setProxy(this._proxy)}async signWithUserSigner(e){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");let r=await this._privyInternal.getAccessTokenInternal();if(!r)throw new t({error:"User must be logged in to sign a message with the user signer",code:"user_signer_sign_error"});let{signature:o}=await this._proxy.signWithUserSigner({accessToken:r,message:e.message});return{signature:o}}async add(e){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if("user-controlled-server-wallets-only"===this._privyInternal.config?.embedded_wallet_config.mode)await d({context:{app:this._appApi,fetchPrivyRoute:(...e)=>this._privyInternal.fetch(...e),getCompiledPath:(...e)=>this._privyInternal.getPath(...e)},chainType:e.chainType});else{let r=await this._privyInternal.getAccessTokenInternal();if(!r)throw new t({error:"User must be logged in to create an embedded wallet",code:"embedded_wallet_creation_error"});await this._proxy.addWallet({accessToken:r,...e})}let{user:r}=await this._privyInternal.refreshSession();return{user:r}}async getBitcoinProvider({wallet:e,entropyId:r,entropyIdVerifier:t,recoveryPassword:i,recoveryAccessToken:d,recoverySecretOverride:a}){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if(!await this._privyInternal.getAccessTokenInternal())throw Error("User must be logged in to create an embedded wallet");return s(e)||await this._load({entropyId:r,entropyIdVerifier:t,wallet:e,recoveryPassword:i,recoveryAccessToken:d,recoverySecretOverride:a}),new o({account:e,privyInternal:this._privyInternal,proxy:this._proxy,entropyId:r,entropyIdVerifier:t})}async create({password:e,recoveryMethod:r,recoveryToken:o,recoveryKey:i,recoverySecretOverride:a,iCloudRecordNameOverride:s,solanaAccount:n,skipCallbacks:c,idempotencyKey:l}){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if("user-controlled-server-wallets-only"===this._privyInternal.config?.embedded_wallet_config.mode){if(r&&!r.startsWith("privy"))throw new t({error:"User-controlled server wallets do not support custom recovery methods",code:"embedded_wallet_creation_error"});await d({context:{app:this._appApi,fetchPrivyRoute:(...e)=>this._privyInternal.fetch(...e),getCompiledPath:(...e)=>this._privyInternal.getPath(...e)},chainType:"ethereum",idempotencyKey:l})}else{let t;if(t=r||(e?"user-passcode":"privy"),e&&"string"!=typeof e)throw Error("Invalid recovery password, must be a string");if("privy"===t&&this._privyInternal.config?.embedded_wallet_config.require_user_password_on_create)throw Error("Password not provided yet is required by App configuration");let d=await this._privyInternal.getAccessTokenInternal();if(!d)throw Error("User must be logged in to create an embedded wallet");let{address:c}=await this._proxy.create({accessToken:d,recoveryMethod:t,recoveryKey:i,recoveryPassword:e,recoveryAccessToken:o,recoverySecretOverride:a,iCloudRecordNameOverride:s,solanaAddress:n?.address});if(!c)throw Error("Failed to create wallet")}return await this._privyInternal.refreshSession(c)}async createSolana(e){if(!this._proxy)throw new t({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_creation_error"});if("user-controlled-server-wallets-only"===this._privyInternal.config?.embedded_wallet_config.mode)await d({context:{app:this._appApi,fetchPrivyRoute:(...e)=>this._privyInternal.fetch(...e),getCompiledPath:(...e)=>this._privyInternal.getPath(...e)},chainType:"solana",idempotencyKey:e?.idempotencyKey});else{let r=await this._privyInternal.getAccessTokenInternal();if(!r)throw new t({error:"User must be logged in to create an embedded wallet",code:"embedded_wallet_creation_error"});e?.ethereumAccount&&await this.getProvider(e.ethereumAccount);let{publicKey:o}=await this._proxy.createSolana({accessToken:r,ethereumAddress:e?.ethereumAccount?.address});if(!o)throw new t({error:"Failed to create wallet",code:"embedded_wallet_creation_error"})}return await this._privyInternal.refreshSession()}async delegateWallets({delegatedWallets:e,rootWallet:r}){if(!this._proxy)throw new t({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_creation_error"});let o=await this._privyInternal.getAccessTokenInternal();if(!o)throw new t({error:"User must be logged in to create an embedded wallet",code:"embedded_wallet_creation_error"});await this._proxy.delegateWallets({accessToken:o,delegatedWallets:e,rootWallet:r})}async getProvider(e,r,t,o,i){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");return s(e)||await this._load({wallet:e,entropyId:e.address,entropyIdVerifier:"ethereum-address-verifier",recoveryPassword:r,recoveryKey:i,recoveryAccessToken:t,recoverySecretOverride:o}),new c({account:e,entropyId:e.address,entropyIdVerifier:"ethereum-address-verifier",privyInternal:this._privyInternal,chains:this._chains,walletProxy:this._proxy,appApi:this._appApi})}async getEthereumProvider({wallet:e,entropyId:r,entropyIdVerifier:t,recoveryPassword:o,recoveryAccessToken:i,recoverySecretOverride:d,recoveryKey:a,onNeedsRecovery:n}){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if(!await this._privyInternal.getAccessTokenInternal())throw Error("User must be logged in to create an embedded wallet");return s(e)||(!n||o||i||d||a)&&await this._load({entropyId:r,entropyIdVerifier:t,wallet:e,recoveryPassword:o,recoveryAccessToken:i,recoverySecretOverride:d,recoveryKey:a}),new c({account:e,entropyId:r,entropyIdVerifier:"ethereum-address-verifier",privyInternal:this._privyInternal,chains:this._chains,walletProxy:this._proxy,onNeedsRecovery:n,appApi:this._appApi})}async getSolanaProvider(e,r,o,i,d,a,n){if(!this._proxy)throw new t({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_webview_not_loaded"});return s(e)||(!n||i||d||a)&&await this._load({wallet:e,entropyId:r,entropyIdVerifier:o,recoveryPassword:i,recoveryAccessToken:d,recoverySecretOverride:a}),new l({account:e,privyInternal:this._privyInternal,proxy:this._proxy,entropyId:r,entropyIdVerifier:o,onNeedsRecovery:n,app:this._appApi})}async setRecovery(e){let{wallet:r,...o}=e;if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if(s(r))throw new t({error:"This wallet does not support setting recovery methods",code:"unsupported_recovery_method"});a({currentRecoveryMethod:r.recovery_method,upgradeToRecoveryMethod:"icloud-native"===o.recoveryMethod?"icloud":o.recoveryMethod}),await this._load("solana"===r.chain_type?{wallet:r,entropyId:r.address,entropyIdVerifier:"solana-address-verifier"}:{wallet:r,entropyId:r.address,entropyIdVerifier:"ethereum-address-verifier"});let i=await this._privyInternal.getAccessTokenInternal();if(!i)throw Error("User must be logged in to interact with embedded wallets");let d=r.recovery_method;this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_set_recovery_started",{address:r.address,target_recovery_method:o.recoveryMethod,existing_recovery_method:d});try{let e;if("user-passcode"===o.recoveryMethod)e={recoveryMethod:"user-passcode",recoveryPassword:o.password};else if("google-drive"===o.recoveryMethod)e={recoveryMethod:"google-drive",recoveryAccessToken:o.recoveryAccessToken};else if("icloud"===o.recoveryMethod)e={recoveryMethod:"icloud",recoveryAccessToken:o.recoveryAccessToken};else if("icloud-native"===o.recoveryMethod)e={recoveryMethod:"icloud-native",iCloudRecordNameOverride:o.iCloudRecordNameOverride,recoverySecretOverride:o.recoverySecretOverride};else if("recovery-encryption-key"===o.recoveryMethod)e={recoveryMethod:"recovery-encryption-key",recoveryKey:o.recoveryKey};else{if("privy"!==o.recoveryMethod)throw Error(`Unknown recovery method: ${o.recoveryMethod}`);e={recoveryMethod:"privy"}}await this._proxy.setRecovery({accessToken:i,entropyId:r.address,entropyIdVerifier:"solana"===r.chain_type?"solana-address-verifier":"ethereum-address-verifier",...e}),this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_set_recovery_completed",{address:r.address,target_recovery_method:o.recoveryMethod,existing_recovery_method:d});let{user:t}=await this._privyInternal.refreshSession();return{user:t,provider:"ethereum"!==r.chain_type?null:new c({account:r,entropyId:r.address,entropyIdVerifier:"ethereum-address-verifier",privyInternal:this._privyInternal,chains:this._chains,walletProxy:this._proxy,appApi:this._appApi})}}catch(e){throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_set_recovery_failed",{address:r.address,recovery_method:r.recovery_method,error:e instanceof Error?e.message:"Unable to recover wallet"}),e}}getURL(){let e=new URL(`${this._privyInternal.baseUrl}/apps/${this._privyInternal.appId}/embedded-wallets`);return this._privyInternal.caid&&e.searchParams.append("caid",this._privyInternal.caid),this._privyInternal.appClientId&&e.searchParams.append("client_id",this._privyInternal.appClientId),e.href}get chains(){return this._chains}onMessage(e){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");return this._proxy.handleEmbeddedWalletMessages(e)}reload(){this._proxy?this._proxy.reload():console.warn("Attempted to reload proxy before initialized")}async ping(e){try{if(!this._proxy)throw Error("Embedded wallet proxy not initialized");return await this._proxy.ping(e),!0}catch(e){return console.error(e),!1}}async _load({entropyId:e,entropyIdVerifier:r,wallet:t,recoveryPassword:o,recoveryKey:d,recoveryAccessToken:a,recoverySecretOverride:s}){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");let n=await this._privyInternal.getAccessTokenInternal();if(!n)throw Error("User must be logged in to interact with embedded wallets");try{return await this._proxy.connect({accessToken:n,entropyId:e,entropyIdVerifier:r}),e}catch(c){if(i(c))try{if("privy"===t.recovery_method){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:t.address,recovery_method:t.recovery_method});let o=await this._proxy.recover({accessToken:n,entropyId:e,entropyIdVerifier:r});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:t.address,recovery_method:t.recovery_method}),o.entropyId}if("user-passcode"===t.recovery_method&&o){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:t.address,recovery_method:t.recovery_method});let i=await this._proxy.recover({accessToken:n,recoveryPassword:o,entropyId:e,entropyIdVerifier:r});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:t.address,recovery_method:t.recovery_method}),i.entropyId}if(["google-drive","icloud"].includes(t.recovery_method)&&a){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:t.address,recovery_method:t.recovery_method});let o=await this._proxy.recover({accessToken:n,recoveryAccessToken:a,entropyId:e,entropyIdVerifier:r});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:t.address,recovery_method:t.recovery_method}),o.entropyId}if("icloud"===t.recovery_method&&s){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:t.address,recovery_method:"icloud-native"});let o=await this._proxy.recover({accessToken:n,recoverySecretOverride:s,entropyId:e,entropyIdVerifier:r});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:t.address,recovery_method:"icloud-native"}),o.entropyId}if("recovery-encryption-key"===t.recovery_method&&d){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:t.address,recovery_method:t.recovery_method});let o=await this._proxy.recover({accessToken:n,recoveryKey:d,entropyId:e,entropyIdVerifier:r});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:t.address,recovery_method:t.recovery_method}),o.entropyId}}catch(r){throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_failed",{address:t.address,recovery_method:t.recovery_method,error:r instanceof Error?r.message:`Unable to recover wallet: ${e}`}),r}throw c}}constructor(t,o,i,d,a,s){if(this._chains=Array.from(e),this._privyInternal=t,o&&(this._proxy=new n(o,a),d.setProxy(this._proxy)),i){let e=r(i);this._chains=e}this._mfa=d,this._mfaPromises=a,this._appApi=s}}export{y as default};
|
|
1
|
+
import{DEFAULT_SUPPORTED_CHAINS as e,dedupeSupportedChains as r}from"@privy-io/chains";import{PrivyClientError as t}from"../Error.mjs";import{EmbeddedBitcoinWalletProvider as o}from"../embedded/EmbeddedBitcoinWalletProvider.mjs";import{errorIndicatesRecoveryIsNeeded as i}from"../embedded/errors.mjs";import{walletCreate as d}from"../embedded/stack/walletCreate.mjs";import{throwIfInvalidRecoveryUpgradePath as a}from"../embedded/utils/index.mjs";import{isUnifiedWallet as s}from"../wallet-api/unified-wallet.mjs";import{EmbeddedWalletProxy as n}from"../embedded/EmbeddedWalletProxy.mjs";import{EmbeddedWalletProvider as c}from"../embedded/EmbeddedWalletProvider.mjs";import{EmbeddedSolanaWalletProvider as l}from"../embedded/EmbeddedSolanaWalletProvider.mjs";import"../embedded/types.mjs";import"../wallet-api/create.mjs";import"@privy-io/routes";import"viem";import"../utils/sleep.mjs";import"../embedded/EventCallbackQueue.mjs";import"../embedded/withMfa.mjs";import"eventemitter3";import"@privy-io/ethereum";import"../embedded/stack/walletRpc.mjs";import"../utils/encodings.mjs";import"../wallet-api/rpc.mjs";import"../wallet-api/generate-authorization-signature.mjs";import"canonicalize";import"@privy-io/encoding";import"../wallet-api/types.mjs";import"../embedded/stack/wallet-api-eth-transaction.mjs";import"../embedded/stack/wallet-api-eth-typed-data.mjs";import"../solana/getWalletPublicKeyFromTransaction.mjs";import"../solana/isVersionedTransaction.mjs";class y{setMessagePoster(e){this._proxy=new n(e,this._mfaPromises),this._mfa.setProxy(this._proxy)}async signWithUserSigner(e){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");let r=await this._privyInternal.getAccessTokenInternal();if(!r)throw new t({error:"User must be logged in to sign a message with the user signer",code:"user_signer_sign_error"});let{signature:o}=await this._proxy.signWithUserSigner({accessToken:r,message:e.message});return{signature:o}}async add(e){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if("user-controlled-server-wallets-only"===this._privyInternal.config?.embedded_wallet_config.mode)await d({context:{app:this._appApi,fetchPrivyRoute:(...e)=>this._privyInternal.fetch(...e),getCompiledPath:(...e)=>this._privyInternal.getPath(...e)},chainType:e.chainType});else{let r=await this._privyInternal.getAccessTokenInternal();if(!r)throw new t({error:"User must be logged in to create an embedded wallet",code:"embedded_wallet_creation_error"});await this._proxy.addWallet({accessToken:r,...e})}let{user:r}=await this._privyInternal.refreshSession();return{user:r}}async getBitcoinProvider({wallet:e,entropyId:r,entropyIdVerifier:t,recoveryPassword:i,recoveryAccessToken:d,recoverySecretOverride:a}){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if(!await this._privyInternal.getAccessTokenInternal())throw Error("User must be logged in to create an embedded wallet");return s(e)||await this._load({entropyId:r,entropyIdVerifier:t,wallet:e,recoveryPassword:i,recoveryAccessToken:d,recoverySecretOverride:a}),new o({account:e,privyInternal:this._privyInternal,proxy:this._proxy,entropyId:r,entropyIdVerifier:t})}async create({password:e,recoveryMethod:r,recoveryToken:o,recoveryKey:i,recoverySecretOverride:a,iCloudRecordNameOverride:s,solanaAccount:n,skipCallbacks:c,idempotencyKey:l}){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if("user-controlled-server-wallets-only"===this._privyInternal.config?.embedded_wallet_config.mode){if(r&&!r.startsWith("privy"))throw new t({error:"User-controlled server wallets do not support custom recovery methods",code:"embedded_wallet_creation_error"});await d({context:{app:this._appApi,fetchPrivyRoute:(...e)=>this._privyInternal.fetch(...e),getCompiledPath:(...e)=>this._privyInternal.getPath(...e)},chainType:"ethereum",idempotencyKey:l})}else{let t;if(t=r||(e?"user-passcode":"privy"),e&&"string"!=typeof e)throw Error("Invalid recovery password, must be a string");if("privy"===t&&this._privyInternal.config?.embedded_wallet_config.require_user_password_on_create)throw Error("Password not provided yet is required by App configuration");let d=await this._privyInternal.getAccessTokenInternal();if(!d)throw Error("User must be logged in to create an embedded wallet");let{address:c}=await this._proxy.create({accessToken:d,recoveryMethod:t,recoveryKey:i,recoveryPassword:e,recoveryAccessToken:o,recoverySecretOverride:a,iCloudRecordNameOverride:s,solanaAddress:n?.address});if(!c)throw Error("Failed to create wallet")}return await this._privyInternal.refreshSession(c)}async createSolana(e){if(!this._proxy)throw new t({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_creation_error"});if("user-controlled-server-wallets-only"===this._privyInternal.config?.embedded_wallet_config.mode)await d({context:{app:this._appApi,fetchPrivyRoute:(...e)=>this._privyInternal.fetch(...e),getCompiledPath:(...e)=>this._privyInternal.getPath(...e)},chainType:"solana",idempotencyKey:e?.idempotencyKey});else{let r=await this._privyInternal.getAccessTokenInternal();if(!r)throw new t({error:"User must be logged in to create an embedded wallet",code:"embedded_wallet_creation_error"});e?.ethereumAccount&&await this.getProvider(e.ethereumAccount);let{publicKey:o}=await this._proxy.createSolana({accessToken:r,ethereumAddress:e?.ethereumAccount?.address});if(!o)throw new t({error:"Failed to create wallet",code:"embedded_wallet_creation_error"})}return await this._privyInternal.refreshSession()}async delegateWallets({delegatedWallets:e,rootWallet:r}){if(!this._proxy)throw new t({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_creation_error"});let o=await this._privyInternal.getAccessTokenInternal();if(!o)throw new t({error:"User must be logged in to create an embedded wallet",code:"embedded_wallet_creation_error"});await this._proxy.delegateWallets({accessToken:o,delegatedWallets:e,rootWallet:r})}async getProvider(e,r,t,o,i){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");return s(e)||await this._load({wallet:e,entropyId:e.address,entropyIdVerifier:"ethereum-address-verifier",recoveryPassword:r,recoveryKey:i,recoveryAccessToken:t,recoverySecretOverride:o}),new c({account:e,entropyId:e.address,entropyIdVerifier:"ethereum-address-verifier",privyInternal:this._privyInternal,chains:this._chains,walletProxy:this._proxy,appApi:this._appApi})}async getEthereumProvider({wallet:e,entropyId:r,entropyIdVerifier:t,recoveryPassword:o,recoveryAccessToken:i,recoverySecretOverride:d,recoveryKey:a,onNeedsRecovery:n}){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if(!await this._privyInternal.getAccessTokenInternal())throw Error("User must be logged in to create an embedded wallet");return s(e)||(!n||o||i||d||a)&&await this._load({entropyId:r,entropyIdVerifier:t,wallet:e,recoveryPassword:o,recoveryAccessToken:i,recoverySecretOverride:d,recoveryKey:a}),new c({account:e,entropyId:r,entropyIdVerifier:"ethereum-address-verifier",privyInternal:this._privyInternal,chains:this._chains,walletProxy:this._proxy,onNeedsRecovery:n,appApi:this._appApi})}async getSolanaProvider(e,r,o,i,d,a,n){if(!this._proxy)throw new t({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_webview_not_loaded"});return s(e)||(!n||i||d||a)&&await this._load({wallet:e,entropyId:r,entropyIdVerifier:o,recoveryPassword:i,recoveryAccessToken:d,recoverySecretOverride:a}),new l({account:e,privyInternal:this._privyInternal,proxy:this._proxy,entropyId:r,entropyIdVerifier:o,onNeedsRecovery:n,app:this._appApi})}async setRecovery(e){let{wallet:r,...o}=e;if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if(s(r))throw new t({error:"This wallet does not support setting recovery methods",code:"unsupported_recovery_method"});a({currentRecoveryMethod:r.recovery_method,upgradeToRecoveryMethod:"icloud-native"===o.recoveryMethod?"icloud":o.recoveryMethod}),await this._load("solana"===r.chain_type?{wallet:r,entropyId:r.address,entropyIdVerifier:"solana-address-verifier"}:{wallet:r,entropyId:r.address,entropyIdVerifier:"ethereum-address-verifier"});let i=await this._privyInternal.getAccessTokenInternal();if(!i)throw Error("User must be logged in to interact with embedded wallets");let d=r.recovery_method;this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_set_recovery_started",{address:r.address,target_recovery_method:o.recoveryMethod,existing_recovery_method:d});try{let e;if("user-passcode"===o.recoveryMethod)e={recoveryMethod:"user-passcode",recoveryPassword:o.password};else if("google-drive"===o.recoveryMethod)e={recoveryMethod:"google-drive",recoveryAccessToken:o.recoveryAccessToken};else if("icloud"===o.recoveryMethod)e={recoveryMethod:"icloud",recoveryAccessToken:o.recoveryAccessToken};else if("icloud-native"===o.recoveryMethod)e={recoveryMethod:"icloud-native",iCloudRecordNameOverride:o.iCloudRecordNameOverride,recoverySecretOverride:o.recoverySecretOverride};else if("recovery-encryption-key"===o.recoveryMethod)e={recoveryMethod:"recovery-encryption-key",recoveryKey:o.recoveryKey};else{if("privy"!==o.recoveryMethod)throw Error(`Unknown recovery method: ${o.recoveryMethod}`);e={recoveryMethod:"privy"}}await this._proxy.setRecovery({accessToken:i,entropyId:r.address,entropyIdVerifier:"solana"===r.chain_type?"solana-address-verifier":"ethereum-address-verifier",...e}),this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_set_recovery_completed",{address:r.address,target_recovery_method:o.recoveryMethod,existing_recovery_method:d});let{user:t}=await this._privyInternal.refreshSession();return{user:t,provider:"ethereum"!==r.chain_type?null:new c({account:r,entropyId:r.address,entropyIdVerifier:"ethereum-address-verifier",privyInternal:this._privyInternal,chains:this._chains,walletProxy:this._proxy,appApi:this._appApi})}}catch(e){throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_set_recovery_failed",{address:r.address,recovery_method:r.recovery_method,error:e instanceof Error?e.message:"Unable to recover wallet"}),e}}getURL(){let e=new URL(`${this._privyInternal.baseUrl}/apps/${this._privyInternal.appId}/embedded-wallets`);return this._privyInternal.caid&&e.searchParams.append("caid",this._privyInternal.caid),this._privyInternal.appClientId&&e.searchParams.append("client_id",this._privyInternal.appClientId),e.href}get chains(){return this._chains}onMessage(e){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");return this._proxy.handleEmbeddedWalletMessages(e)}reload(){this._proxy?this._proxy.reload():this._privyInternal.logger.warn("Attempted to reload proxy before initialized")}async ping(e){try{if(!this._proxy)throw Error("Embedded wallet proxy not initialized");return await this._proxy.ping(e),!0}catch(e){return this._privyInternal.logger.debug(e),!1}}async _load({entropyId:e,entropyIdVerifier:r,wallet:t,recoveryPassword:o,recoveryKey:d,recoveryAccessToken:a,recoverySecretOverride:s}){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");let n=await this._privyInternal.getAccessTokenInternal();if(!n)throw Error("User must be logged in to interact with embedded wallets");try{return await this._proxy.connect({accessToken:n,entropyId:e,entropyIdVerifier:r}),e}catch(c){if(i(c))try{if("privy"===t.recovery_method){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:t.address,recovery_method:t.recovery_method});let o=await this._proxy.recover({accessToken:n,entropyId:e,entropyIdVerifier:r});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:t.address,recovery_method:t.recovery_method}),o.entropyId}if("user-passcode"===t.recovery_method&&o){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:t.address,recovery_method:t.recovery_method});let i=await this._proxy.recover({accessToken:n,recoveryPassword:o,entropyId:e,entropyIdVerifier:r});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:t.address,recovery_method:t.recovery_method}),i.entropyId}if(["google-drive","icloud"].includes(t.recovery_method)&&a){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:t.address,recovery_method:t.recovery_method});let o=await this._proxy.recover({accessToken:n,recoveryAccessToken:a,entropyId:e,entropyIdVerifier:r});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:t.address,recovery_method:t.recovery_method}),o.entropyId}if("icloud"===t.recovery_method&&s){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:t.address,recovery_method:"icloud-native"});let o=await this._proxy.recover({accessToken:n,recoverySecretOverride:s,entropyId:e,entropyIdVerifier:r});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:t.address,recovery_method:"icloud-native"}),o.entropyId}if("recovery-encryption-key"===t.recovery_method&&d){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:t.address,recovery_method:t.recovery_method});let o=await this._proxy.recover({accessToken:n,recoveryKey:d,entropyId:e,entropyIdVerifier:r});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:t.address,recovery_method:t.recovery_method}),o.entropyId}}catch(r){throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_failed",{address:t.address,recovery_method:t.recovery_method,error:r instanceof Error?r.message:`Unable to recover wallet: ${e}`}),r}throw c}}constructor(t,o,i,d,a,s){if(this._chains=Array.from(e),this._privyInternal=t,o&&(this._proxy=new n(o,a),d.setProxy(this._proxy)),i){let e=r(i);this._chains=e}this._mfa=d,this._mfaPromises=a,this._appApi=s}}export{y as default};
|
|
2
2
|
//# sourceMappingURL=EmbeddedWalletApi.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmbeddedWalletApi.mjs","sources":["../../../src/client/EmbeddedWalletApi.ts"],"names":["EmbeddedWalletApi","setMessagePoster","poster","this","_proxy","EmbeddedWalletProxy","_mfaPromises","_mfa","setProxy","signWithUserSigner","opts","Error","accessToken","_privyInternal","getAccessTokenInternal","PrivyClientError","error","code","signature","message","add","config","embedded_wallet_config","mode","walletCreate","context","app","_appApi","fetchPrivyRoute","args","fetch","getCompiledPath","getPath","chainType","addWallet","user","refreshSession","getBitcoinProvider","wallet","entropyId","entropyIdVerifier","recoveryPassword","recoveryAccessToken","recoverySecretOverride","isUnifiedWallet","_load","EmbeddedBitcoinWalletProvider","account","privyInternal","proxy","create","password","recoveryMethod","recoveryToken","recoveryKey","iCloudRecordNameOverride","solanaAccount","skipCallbacks","idempotencyKey","walletMode","startsWith","parsedRecoveryMethod","require_user_password_on_create","address","solanaAddress","createSolana","ethereumAccount","getProvider","publicKey","ethereumAddress","delegateWallets","delegatedWallets","rootWallet","EmbeddedWalletProvider","chains","_chains","walletProxy","appApi","getEthereumProvider","onNeedsRecovery","getSolanaProvider","EmbeddedSolanaWalletProvider","setRecovery","setRecoveryInput","recoveryArgs","throwIfInvalidRecoveryUpgradePath","currentRecoveryMethod","recovery_method","upgradeToRecoveryMethod","chain_type","existingRecoveryMethod","createAnalyticsEvent","target_recovery_method","existing_recovery_method","recoveryOnlyArgs","provider","e","getURL","url","URL","baseUrl","appId","caid","searchParams","append","appClientId","href","onMessage","event","handleEmbeddedWalletMessages","reload","console","warn","ping","timeoutMs","connect","err","errorIndicatesRecoveryIsNeeded","recovered","recover","includes","constructor","embeddedWalletMessagePoster","mfa","mfaPromises","Array","from","DEFAULT_SUPPORTED_CHAINS","dedupedChains","dedupeSupportedChains"],"mappings":"07CAmEe,MAAMA,EAoEZC,gBAAAA,CAAiBC,GACtBC,KAAKC,OAAS,IAAIC,EAAoBH,EAAQC,KAAKG,cACnDH,KAAKI,KAAKC,SAASL,KAAKC,OAC1B,CAWA,wBAAaK,CAAmBC,GAC9B,IAAKP,KAAKC,OACR,MAAMO,MAAU,yCAGlB,IAAMC,QAAoBT,KAAKU,eAAeC,yBAC9C,IAAKF,EACH,MAAM,IAAIG,EAAiB,CACzBC,MAAO,gEACPC,KAAM,2BAIV,IAAOC,UAAAA,SAAmBf,KAAKC,OAAOK,mBAAmB,CACvDG,YAAAA,EACAO,QAAST,EAAKS,UAGhB,MAAO,CAACD,UAAAA,EACV,CAeA,SAAaE,CAAIV,GAMf,IAAKP,KAAKC,OACR,MAAMO,MAAU,yCAIlB,GAAmB,wCADAR,KAAKU,eAAeQ,QAAQC,uBAAuBC,WAE9DC,EAAa,CACjBC,QAAS,CACPC,IAAKvB,KAAKwB,QACVC,gBAAiB,IAAIC,IAAS1B,KAAKU,eAAeiB,SAASD,GAC3DE,gBAAiB,IAAIF,IAAS1B,KAAKU,eAAemB,WAAWH,IAE/DI,UAAWvB,EAAKuB,gBAEb,CACL,IAAMrB,QAAoBT,KAAKU,eAAeC,yBAC9C,IAAKF,EACH,MAAM,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+B,4BAA3BD,EAAOiD,iBAAiDjC,EAAa,CAClEnD,KAAKU,eAAe8E,qBAAqB,uCAAwC,CACpF5B,QAASzB,EAAOyB,QAChBwB,gBAAiBjD,EAAOiD,kBAG1B,IAAM+B,QAAkBnH,KAAKC,OAAOmH,QAAQ,CAC1C3G,YAAAA,EACA0C,YAAAA,EACAf,UAAAA,EACAC,kBAAAA,IAWF,OARKrC,KAAKU,eAAe8E,qBACvB,yCACA,CACE5B,QAASzB,EAAOyB,QAChBwB,gBAAiBjD,EAAOiD,kBAIrB+B,EAAU/E,SAAS,CAE9B,CAAE,MAAOyD,GAMP,MALK7F,KAAKU,eAAe8E,qBAAqB,sCAAuC,CACnF5B,QAASzB,EAAOyB,QAChBwB,gBAAiBjD,EAAOiD,gBACxBvE,MAAOgF,aAAarF,MAAQqF,EAAE7E,QAAU,6BAA6BoB,MAEjEyD,CACR,CAKA,MAAMoB,CAEV,CACF,CAz6BAK,WAAAA,CACEzE,EACA0E,EACAhD,EACAiD,EACAC,EACA/C,GASA,GAtCD1E,KACOwE,QAAgCkD,MAAMC,KAC5CC,GA6BA5H,KAAKU,eAAiBmC,EAElB0E,IACFvH,KAAKC,OAAS,IAAIC,EAAoBqH,EAA6BE,GACnED,EAAInH,SAASL,KAAKC,SAGhBsE,EAAQ,CACV,IAAMsD,EAAgBC,EAAsBvD,GAC5CvE,KAAKwE,QAAUqD,CACjB,CAEA7H,KAAKI,KAAOoH,EACZxH,KAAKG,aAAesH,EACpBzH,KAAKwB,QAAUkD,CACjB"}
|
|
1
|
+
{"version":3,"file":"EmbeddedWalletApi.mjs","sources":["../../../src/client/EmbeddedWalletApi.ts"],"names":["EmbeddedWalletApi","setMessagePoster","poster","this","_proxy","EmbeddedWalletProxy","_mfaPromises","_mfa","setProxy","signWithUserSigner","opts","Error","accessToken","_privyInternal","getAccessTokenInternal","PrivyClientError","error","code","signature","message","add","config","embedded_wallet_config","mode","walletCreate","context","app","_appApi","fetchPrivyRoute","args","fetch","getCompiledPath","getPath","chainType","addWallet","user","refreshSession","getBitcoinProvider","wallet","entropyId","entropyIdVerifier","recoveryPassword","recoveryAccessToken","recoverySecretOverride","isUnifiedWallet","_load","EmbeddedBitcoinWalletProvider","account","privyInternal","proxy","create","password","recoveryMethod","recoveryToken","recoveryKey","iCloudRecordNameOverride","solanaAccount","skipCallbacks","idempotencyKey","walletMode","startsWith","parsedRecoveryMethod","require_user_password_on_create","address","solanaAddress","createSolana","ethereumAccount","getProvider","publicKey","ethereumAddress","delegateWallets","delegatedWallets","rootWallet","EmbeddedWalletProvider","chains","_chains","walletProxy","appApi","getEthereumProvider","onNeedsRecovery","getSolanaProvider","EmbeddedSolanaWalletProvider","setRecovery","setRecoveryInput","recoveryArgs","throwIfInvalidRecoveryUpgradePath","currentRecoveryMethod","recovery_method","upgradeToRecoveryMethod","chain_type","existingRecoveryMethod","createAnalyticsEvent","target_recovery_method","existing_recovery_method","recoveryOnlyArgs","provider","e","getURL","url","URL","baseUrl","appId","caid","searchParams","append","appClientId","href","onMessage","event","handleEmbeddedWalletMessages","reload","logger","warn","ping","timeoutMs","debug","connect","err","errorIndicatesRecoveryIsNeeded","recovered","recover","includes","constructor","embeddedWalletMessagePoster","mfa","mfaPromises","Array","from","DEFAULT_SUPPORTED_CHAINS","dedupedChains","dedupeSupportedChains"],"mappings":"07CAmEe,MAAMA,EAoEZC,gBAAAA,CAAiBC,GACtBC,KAAKC,OAAS,IAAIC,EAAoBH,EAAQC,KAAKG,cACnDH,KAAKI,KAAKC,SAASL,KAAKC,OAC1B,CAWA,wBAAaK,CAAmBC,GAC9B,IAAKP,KAAKC,OACR,MAAMO,MAAU,yCAGlB,IAAMC,QAAoBT,KAAKU,eAAeC,yBAC9C,IAAKF,EACH,MAAM,IAAIG,EAAiB,CACzBC,MAAO,gEACPC,KAAM,2BAIV,IAAOC,UAAAA,SAAmBf,KAAKC,OAAOK,mBAAmB,CACvDG,YAAAA,EACAO,QAAST,EAAKS,UAGhB,MAAO,CAACD,UA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,EAAsBxD,GAC5CvE,KAAKwE,QAAUsD,CACjB,CAEA9H,KAAKI,KAAOqH,EACZzH,KAAKG,aAAeuH,EACpB1H,KAAKwB,QAAUkD,CACjB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"fetch-retry";import{v4 as t}from"uuid";import{PrivyErrorCode as s}from"@privy-io/api-base";import{getPathWithParams as i,AppConfig as r,AnalyticsEvent as a,RefreshSession as o}from"@privy-io/routes";import{PrivyClientError as n,PrivyApiError as h}from"../Error.mjs";import{Session as c}from"../Session.mjs";import l from"../toAbortSignalTimeout.mjs";import{toSearchParams as g}from"../utils/toSearchParams.mjs";import{toLoggerWithLevel as d}from"./logger.mjs";import"eventemitter3";import"jose";import"js-cookie";import"../Token.mjs";import"../utils/allSettled.mjs";import"../utils/noop.mjs";let p="privy:caid";class u{setCallbacks(e){this.callbacks={...this.callbacks,...e}}get isReady(){return!!this._config}get config(){return this._config}get caid(){return this._analyticsId}async _initialize(){if(this.isReady)this.callbacks?.setIsReady?.(!0);else{if(!await this.isStorageAccessible())throw new n({code:"storage_error",error:"Unable to access storage"});this._config=await this.getAppConfig(),this._config?.custom_api_url&&(this.baseUrl=this._config.custom_api_url,this.session.isUsingServerCookies=!0),this.callbacks?.setIsReady?.(!0),this._sdkVersion.startsWith("react-auth:")||this.createAnalyticsEvent("sdk_initialize",{})}}getPath(e,{params:t,query:s}){return`${this.baseUrl}${i(e.path,t)}${g(s)}`}async fetch(e,{body:t,params:s,query:i,headers:r,onRequest:a=this._beforeRequest.bind(this)}){let o=new Request(this.getPath(e,{params:s,query:i}),{method:e.method,body:JSON.stringify(t),headers:r}),n=await a(o),c=await this._fetch(o,n),l=await c.json();if(c.status>299)throw new h({...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:l(2e4),headers:s,credentials:"include"}}async beforeRequestWithoutRefresh(e){return await this._initialize(),this._beforeRequestWithoutInitialize(e)}async _beforeRequest(e){return await this._initialize(),await this.getAccessTokenInternal(),this.beforeRequestWithoutRefresh(e)}async getAppConfig(){return await this.fetch(r,{params:{app_id:this.appId},onRequest:this._beforeRequestWithoutInitialize.bind(this)})}async _getOrGenerateClientAnalyticsId(){if(this._analyticsId)return this._analyticsId;try{let e=await this._storage.get(p);if("string"==typeof e&&e.length>0)return this._analyticsId=e,e}catch(e){this.logger.error("Unable to load clientId",e)}try{this._analyticsId=t()}catch(e){this.logger.error("Unable to generate uuidv4",e)}if(this._analyticsId){try{await this._storage.put(p,this._analyticsId)}catch(e){this.logger.error(`Unable to store clientId: ${this._analyticsId}`,e)}return this._analyticsId}}async destroyClientAnalyticsId(){try{return await this._storage.del(p)}catch(e){this.logger.error("Unable to delete clientId",e)}}async createAnalyticsEvent(e,t){try{await this.fetch(a,{body:{event_name:e,client_id:await this._getOrGenerateClientAnalyticsId(),payload:t},onRequest:this.beforeRequestWithoutRefresh.bind(this)})}catch(e){}}async refreshSession(e=!1){if(!await this.isStorageAccessible())throw new n({code:"storage_error",error:"Unable to access storage"});let t=await this.session.getRefreshToken()??void 0,s=t??"key",i=this._cache.get(s);if(i)return this.logger.debug("[privy:refresh] found in-flight session refresh request, deduping"),await i;let r=this._refreshSession(t,e);this._cache.set(s,r);try{return await r}finally{this._cache.delete(s)}}async _refreshSession(e,t){let i=await this.session.getCustomerAccessToken();if(!this.session.hasRefreshCredentials(i,e??null))throw this.logger.debug("[privy:refresh] missing tokens, skipping request"),await this._initialize(),new h({code:s.MISSING_OR_INVALID_TOKEN,error:"No tokens found in storage",status:401});try{this.logger.debug(`[privy:refresh] fetching: ${o.path}`);let s=await this.fetch(o,{body:{refresh_token:e},onRequest:this.beforeRequestWithoutRefresh.bind(this)}),i=s.session_update_action;return this.logger.debug(`[privy:refresh] response: ${i}`),"set"===i&&(await this.session.updateWithTokensResponse(s),this.logger.debug("[privy:refresh] tokens stored")),"clear"===i&&(await this.session.destroyLocalState(),this.logger.debug("[privy:refresh] tokens cleared"),t||this.callbacks?.setUser?.(null)),"ignore"===i&&(s.token&&(await this.session.storeCustomerAccessToken(s.token),this.logger.debug("[privy:refresh] token stored (CAT)")),s.privy_access_token&&(await this.session.storePrivyAccessToken(s.privy_access_token),this.logger.debug("[privy:refresh] token stored (PAT)")),s.identity_token&&(this.logger.debug("[privy:refresh] token stored (IDT)"),await this.session.storeIdentityToken(s.identity_token))),this.logger.debug("[privy:refresh] returning response"),t||this.callbacks?.setUser?.(s.user),s}catch(e){throw this.logger.debug(`[privy:refresh] error: ${e.message??"unknown error"}`),e instanceof h&&e.code===s.MISSING_OR_INVALID_TOKEN&&(await this.session.destroyLocalState(),t||this.callbacks?.setUser?.(null)),e}}async getAccessToken(){let[e,t]=await Promise.all([this.session.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-${t()}`,s="blobby";await this._storage.put(e,s);let i=await this._storage.get(e);return await this._storage.del(e),i===s}catch(e){return this.logger.error(e),!1}}constructor(t){this._sdkVersion="js-sdk-core:0.61.
|
|
1
|
+
import e from"fetch-retry";import{v4 as t}from"uuid";import{PrivyErrorCode as s}from"@privy-io/api-base";import{getPathWithParams as i,AppConfig as r,AnalyticsEvent as a,RefreshSession as o}from"@privy-io/routes";import{PrivyClientError as n,PrivyApiError as h}from"../Error.mjs";import{Session as c}from"../Session.mjs";import l from"../toAbortSignalTimeout.mjs";import{toSearchParams as g}from"../utils/toSearchParams.mjs";import{toLoggerWithLevel as d}from"./logger.mjs";import"eventemitter3";import"jose";import"js-cookie";import"../Token.mjs";import"../utils/allSettled.mjs";import"../utils/noop.mjs";let p="privy:caid";class u{setCallbacks(e){this.callbacks={...this.callbacks,...e}}get isReady(){return!!this._config}get config(){return this._config}get caid(){return this._analyticsId}async _initialize(){if(this.isReady)this.callbacks?.setIsReady?.(!0);else{if(!await this.isStorageAccessible())throw new n({code:"storage_error",error:"Unable to access storage"});this._config=await this.getAppConfig(),this._config?.custom_api_url&&(this.baseUrl=this._config.custom_api_url,this.session.isUsingServerCookies=!0),this.callbacks?.setIsReady?.(!0),this._sdkVersion.startsWith("react-auth:")||this.createAnalyticsEvent("sdk_initialize",{})}}getPath(e,{params:t,query:s}){return`${this.baseUrl}${i(e.path,t)}${g(s)}`}async fetch(e,{body:t,params:s,query:i,headers:r,onRequest:a=this._beforeRequest.bind(this)}){let o=new Request(this.getPath(e,{params:s,query:i}),{method:e.method,body:JSON.stringify(t),headers:r}),n=await a(o),c=await this._fetch(o,n),l=await c.json();if(c.status>299)throw new h({...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:l(2e4),headers:s,credentials:"include"}}async beforeRequestWithoutRefresh(e){return await this._initialize(),this._beforeRequestWithoutInitialize(e)}async _beforeRequest(e){return await this._initialize(),await this.getAccessTokenInternal(),this.beforeRequestWithoutRefresh(e)}async getAppConfig(){return await this.fetch(r,{params:{app_id:this.appId},onRequest:this._beforeRequestWithoutInitialize.bind(this)})}async _getOrGenerateClientAnalyticsId(){if(this._analyticsId)return this._analyticsId;try{let e=await this._storage.get(p);if("string"==typeof e&&e.length>0)return this._analyticsId=e,e}catch(e){this.logger.error("Unable to load clientId",e)}try{this._analyticsId=t()}catch(e){this.logger.error("Unable to generate uuidv4",e)}if(this._analyticsId){try{await this._storage.put(p,this._analyticsId)}catch(e){this.logger.error(`Unable to store clientId: ${this._analyticsId}`,e)}return this._analyticsId}}async destroyClientAnalyticsId(){try{return await this._storage.del(p)}catch(e){this.logger.error("Unable to delete clientId",e)}}async createAnalyticsEvent(e,t){try{await this.fetch(a,{body:{event_name:e,client_id:await this._getOrGenerateClientAnalyticsId(),payload:t},onRequest:this.beforeRequestWithoutRefresh.bind(this)})}catch(e){}}async refreshSession(e=!1){if(!await this.isStorageAccessible())throw new n({code:"storage_error",error:"Unable to access storage"});let t=await this.session.getRefreshToken()??void 0,s=t??"key",i=this._cache.get(s);if(i)return this.logger.debug("[privy:refresh] found in-flight session refresh request, deduping"),await i;let r=this._refreshSession(t,e);this._cache.set(s,r);try{return await r}finally{this._cache.delete(s)}}async _refreshSession(e,t){let i=await this.session.getCustomerAccessToken();if(!this.session.hasRefreshCredentials(i,e??null))throw this.logger.debug("[privy:refresh] missing tokens, skipping request"),await this._initialize(),new h({code:s.MISSING_OR_INVALID_TOKEN,error:"No tokens found in storage",status:401});try{this.logger.debug(`[privy:refresh] fetching: ${o.path}`);let s=await this.fetch(o,{body:{refresh_token:e},onRequest:this.beforeRequestWithoutRefresh.bind(this)}),i=s.session_update_action;return this.logger.debug(`[privy:refresh] response: ${i}`),"set"===i&&(await this.session.updateWithTokensResponse(s),this.logger.debug("[privy:refresh] tokens stored")),"clear"===i&&(await this.session.destroyLocalState(),this.logger.debug("[privy:refresh] tokens cleared"),t||this.callbacks?.setUser?.(null)),"ignore"===i&&(s.token&&(await this.session.storeCustomerAccessToken(s.token),this.logger.debug("[privy:refresh] token stored (CAT)")),s.privy_access_token&&(await this.session.storePrivyAccessToken(s.privy_access_token),this.logger.debug("[privy:refresh] token stored (PAT)")),s.identity_token&&(this.logger.debug("[privy:refresh] token stored (IDT)"),await this.session.storeIdentityToken(s.identity_token))),this.logger.debug("[privy:refresh] returning response"),t||this.callbacks?.setUser?.(s.user),s}catch(e){throw this.logger.debug(`[privy:refresh] error: ${e.message??"unknown error"}`),e instanceof h&&e.code===s.MISSING_OR_INVALID_TOKEN&&(await this.session.destroyLocalState(),t||this.callbacks?.setUser?.(null)),e}}async getAccessToken(){let[e,t]=await Promise.all([this.session.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-${t()}`,s="blobby";await this._storage.put(e,s);let i=await this._storage.get(e);return await this._storage.del(e),i===s}catch(e){return this.logger.error(e),!1}}constructor(t){this._sdkVersion="js-sdk-core:0.61.2",this._cache=new Map,this.logger=d({level:t.logger?.level??t.logLevel??"ERROR",logger:t.logger??console}),this._storage=t.storage,this._analyticsId=null,this._getOrGenerateClientAnalyticsId(),this.baseUrl=t.baseUrl??"https://auth.privy.io",this.appId=t.appId,this.appClientId=t.appClientId,this._sdkVersion=t.sdkVersion??this._sdkVersion,this.callbacks=t.callbacks,this.nativeAppIdentifier=t.nativeAppIdentifier,this.session=new c({storage:this._storage,isUsingServerCookies:!1,appId:t.appId}),this._fetch=e(globalThis.fetch,{retries:3,retryDelay:e=>3**e*500,retryOn:[408,409,425,500,502,503,504]}),this.session.on("error_storing_tokens",(e=>{this.createAnalyticsEvent("error_updating_tokens_in_storage",{reason:e})}))}}export{u as PrivyInternal};
|
|
2
2
|
//# sourceMappingURL=PrivyInternal.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{getUserEmbeddedEthereumWallet as e}from"../../utils/getUserEmbeddedEthereumWallet.mjs";import{getUserEmbeddedSolanaWallet as t}from"../../utils/getUserEmbeddedSolanaWallet.mjs";import{shouldCreateEmbeddedEthWallet as
|
|
1
|
+
import{getUserEmbeddedEthereumWallet as e}from"../../utils/getUserEmbeddedEthereumWallet.mjs";import{getUserEmbeddedSolanaWallet as t}from"../../utils/getUserEmbeddedSolanaWallet.mjs";import{shouldCreateEmbeddedEthWallet as r}from"../../utils/shouldCreateEmbeddedEthWallet.mjs";import{shouldCreateEmbeddedSolWallet as a}from"../../utils/shouldCreateEmbeddedSolWallet.mjs";import"../../utils/getAllUserEmbeddedEthereumWallets.mjs";import"../../utils/embedded-wallets.mjs";import"../../utils/getAllUserEmbeddedSolanaWallets.mjs";let o=(e,t)=>({...e,is_new_user:t.is_new_user,oauth_tokens:t.oauth_tokens});const s=async(s,l,m)=>{let i=r(l.user,m?.ethereum?.createOnLogin??"off"),d=a(l.user,m?.solana?.createOnLogin??"off");if(i&&d){let t=await s.create({recoveryMethod:"privy",skipCallbacks:!0});return o(await s.createSolana({ethereumAccount:e(t.user)??void 0}),l)}return i?o(await s.create({recoveryMethod:"privy",solanaAccount:t(l.user)??void 0}),l):d?o(await s.createSolana({ethereumAccount:e(l.user)??void 0}),l):l};export{s as maybeCreateWalletOnLogin};
|
|
2
2
|
//# sourceMappingURL=maybeCreateWalletOnLogin.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maybeCreateWalletOnLogin.mjs","sources":["../../../../src/client/auth/maybeCreateWalletOnLogin.ts"],"names":["maybeCreateWalletOnLogin","async","api","
|
|
1
|
+
{"version":3,"file":"maybeCreateWalletOnLogin.mjs","sources":["../../../../src/client/auth/maybeCreateWalletOnLogin.ts"],"names":["withOriginalMeta","walletResult","original","is_new_user","oauth_tokens","maybeCreateWalletOnLogin","async","api","config","shouldCreateEth","shouldCreateEmbeddedEthWallet","user","ethereum","createOnLogin","shouldCreateSol","shouldCreateEmbeddedSolWallet","solana","withEth","create","recoveryMethod","skipCallbacks","createSolana","ethereumAccount","getUserEmbeddedEthereumWallet","undefined","solanaAccount","getUserEmbeddedSolanaWallet"],"mappings":"+gBAcA,IAAMA,EAAmB,CACvBC,EACAC,KAAAA,IAEGD,EACHE,YAAaD,EAASC,YACtBC,aAAcF,EAASE,eAelB,MAAMC,EAA2BC,MACtCC,EACAL,EACAM,KAGA,IAAMC,EAAkBC,EACtBR,EAASS,KACTH,GAAQI,UAAUC,eAAiB,OAE/BC,EAAkBC,EACtBb,EAASS,KACTH,GAAQQ,QAAQH,eAAiB,OAKnC,GAAIJ,GAAmBK,EAAiB,CACtC,IAAMG,QAAgBV,EAAIW,OAAO,CAACC,eAAgB,QAASC,eAAe,IAK1E,OAAOpB,QAJeO,EAAIc,aAAa,CACrCC,gBAAiBC,EAA8BN,EAAQN,YAASa,IAGjCtB,EACnC,QAGIO,EAMKT,QALeO,EAAIW,OAAO,CAC/BC,eAAgB,QAChBM,cAAeC,EAA4BxB,EAASS,YAASa,IAG9BtB,GAI/BY,EAKKd,QAJeO,EAAIc,aAAa,CACrCC,gBAAiBC,EAA8BrB,EAASS,YAASa,IAGlCtB,GAI5BA,CAAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@privy-io/js-sdk-core",
|
|
3
|
-
"version": "0.61.
|
|
3
|
+
"version": "0.61.2",
|
|
4
4
|
"description": "Vanilla JS client for the Privy Auth API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"authentication",
|
|
@@ -59,14 +59,16 @@
|
|
|
59
59
|
"libphonenumber-js": "^1.10.44",
|
|
60
60
|
"set-cookie-parser": "^2.6.0",
|
|
61
61
|
"uuid": ">=8 <10",
|
|
62
|
-
"@privy-io/api-base": "1.
|
|
63
|
-
"@privy-io/
|
|
64
|
-
"@privy-io/
|
|
65
|
-
"@privy-io/
|
|
66
|
-
"@privy-io/routes": "0.0.
|
|
62
|
+
"@privy-io/api-base": "1.9.0",
|
|
63
|
+
"@privy-io/encoding": "0.1.3",
|
|
64
|
+
"@privy-io/ethereum": "0.0.11",
|
|
65
|
+
"@privy-io/chains": "0.2.0",
|
|
66
|
+
"@privy-io/routes": "0.0.12"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@metamask/eth-sig-util": "^8.2.0",
|
|
70
|
+
"oxlint": "1.57.0",
|
|
71
|
+
"oxlint-tsgolint": "0.18.0",
|
|
70
72
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
71
73
|
"@rollup/plugin-replace": "^6.0.1",
|
|
72
74
|
"@rollup/plugin-swc": "^0.4.0",
|
|
@@ -94,14 +96,13 @@
|
|
|
94
96
|
"rollup-plugin-dts": "^6.1.1",
|
|
95
97
|
"text-encoding": "^0.7.0",
|
|
96
98
|
"ts-jest": "^29.1.1",
|
|
97
|
-
"typescript": "~
|
|
99
|
+
"typescript": "~6.0.2",
|
|
98
100
|
"@privy-io/build-config": "1.0.0",
|
|
99
|
-
"@privy-io/eslint-config-custom": "0.0.0",
|
|
100
101
|
"@privy-io/tsconfig": "0.0.0"
|
|
101
102
|
},
|
|
102
103
|
"peerDependencies": {
|
|
103
104
|
"permissionless": "^0.2.47",
|
|
104
|
-
"viem": "2.47.
|
|
105
|
+
"viem": "2.47.12"
|
|
105
106
|
},
|
|
106
107
|
"peerDependenciesMeta": {
|
|
107
108
|
"permissionless": {
|
|
@@ -122,8 +123,8 @@
|
|
|
122
123
|
"clean:reset": "rm -rf dist .turbo .swc node_modules",
|
|
123
124
|
"dev:code": "rollup --config rollup.dev.mjs --watch",
|
|
124
125
|
"dev:types": "rollup --config rollup.types.mjs --watch",
|
|
125
|
-
"format": "
|
|
126
|
-
"lint": "
|
|
126
|
+
"format": "oxlint src --fix",
|
|
127
|
+
"lint": "oxlint src",
|
|
127
128
|
"test": "jest",
|
|
128
129
|
"test:watch": "pnpm run test -- --watch"
|
|
129
130
|
}
|