@privy-io/js-sdk-core 0.60.8 → 0.61.0
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/Privy.js +1 -1
- package/dist/cjs/client/Privy.js.map +1 -1
- package/dist/cjs/client/PrivyInternal.js +1 -1
- package/dist/cjs/embedded/EmbeddedSolanaWalletProvider.js +1 -1
- package/dist/cjs/embedded/EmbeddedSolanaWalletProvider.js.map +1 -1
- package/dist/cjs/embedded/EmbeddedWalletProvider.js +1 -1
- package/dist/cjs/embedded/EmbeddedWalletProvider.js.map +1 -1
- package/dist/cjs/embedded/index.js +1 -1
- package/dist/cjs/embedded/stack/session-signers.js +1 -1
- package/dist/cjs/embedded/stack/session-signers.js.map +1 -1
- package/dist/cjs/embedded/stack/walletRpc.js +1 -1
- package/dist/cjs/embedded/stack/walletRpc.js.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/wallet-api/generate-authorization-signature.js +1 -1
- package/dist/cjs/wallet-api/generate-authorization-signature.js.map +1 -1
- package/dist/cjs/wallet-api/raw-sign.js +1 -1
- package/dist/cjs/wallet-api/raw-sign.js.map +1 -1
- package/dist/cjs/wallet-api/rpc.js +1 -1
- package/dist/cjs/wallet-api/rpc.js.map +1 -1
- package/dist/cjs/wallet-api/update-wallet.js +1 -1
- package/dist/cjs/wallet-api/update-wallet.js.map +1 -1
- package/dist/dts/index.d.mts +4 -2
- package/dist/dts/index.d.ts +4 -2
- package/dist/esm/client/EmbeddedWalletApi.mjs +1 -1
- package/dist/esm/client/EmbeddedWalletApi.mjs.map +1 -1
- package/dist/esm/client/Privy.mjs +1 -1
- package/dist/esm/client/Privy.mjs.map +1 -1
- package/dist/esm/client/PrivyInternal.mjs +1 -1
- package/dist/esm/embedded/EmbeddedSolanaWalletProvider.mjs +1 -1
- package/dist/esm/embedded/EmbeddedSolanaWalletProvider.mjs.map +1 -1
- package/dist/esm/embedded/EmbeddedWalletProvider.mjs +1 -1
- package/dist/esm/embedded/EmbeddedWalletProvider.mjs.map +1 -1
- package/dist/esm/embedded/index.mjs +1 -1
- package/dist/esm/embedded/stack/session-signers.mjs +1 -1
- package/dist/esm/embedded/stack/session-signers.mjs.map +1 -1
- package/dist/esm/embedded/stack/walletRpc.mjs +1 -1
- package/dist/esm/embedded/stack/walletRpc.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/wallet-api/generate-authorization-signature.mjs +1 -1
- package/dist/esm/wallet-api/generate-authorization-signature.mjs.map +1 -1
- package/dist/esm/wallet-api/raw-sign.mjs +1 -1
- package/dist/esm/wallet-api/raw-sign.mjs.map +1 -1
- package/dist/esm/wallet-api/rpc.mjs +1 -1
- package/dist/esm/wallet-api/rpc.mjs.map +1 -1
- package/dist/esm/wallet-api/update-wallet.mjs +1 -1
- package/dist/esm/wallet-api/update-wallet.mjs.map +1 -1
- package/package.json +5 -4
package/dist/dts/index.d.mts
CHANGED
|
@@ -2618,10 +2618,12 @@ interface GenerateAuthorizationSignatureOutput {
|
|
|
2618
2618
|
* @see {@link https://docs.privy.io/api-reference/authorization-signatures |Authorization signatures}
|
|
2619
2619
|
*
|
|
2620
2620
|
* @param sign A function that signs a wallet request
|
|
2621
|
-
* @param payload The request payload to sign.
|
|
2621
|
+
* @param payload The request payload to sign. Can be a structured request object (which will be
|
|
2622
|
+
* canonicalized to JSON before signing) or a pre-serialized binary payload (`Uint8Array`) that
|
|
2623
|
+
* will be signed directly.
|
|
2622
2624
|
* @returns The user's authorization signature over the API request.
|
|
2623
2625
|
*/
|
|
2624
|
-
declare function generateAuthorizationSignature(sign: SignWalletRequest, payload: GenerateAuthorizationSignatureInput): Promise<GenerateAuthorizationSignatureOutput>;
|
|
2626
|
+
declare function generateAuthorizationSignature(sign: SignWalletRequest, payload: GenerateAuthorizationSignatureInput | Uint8Array): Promise<GenerateAuthorizationSignatureOutput>;
|
|
2625
2627
|
|
|
2626
2628
|
type Input$3 = {
|
|
2627
2629
|
request: WalletCreateParams;
|
package/dist/dts/index.d.ts
CHANGED
|
@@ -2618,10 +2618,12 @@ interface GenerateAuthorizationSignatureOutput {
|
|
|
2618
2618
|
* @see {@link https://docs.privy.io/api-reference/authorization-signatures |Authorization signatures}
|
|
2619
2619
|
*
|
|
2620
2620
|
* @param sign A function that signs a wallet request
|
|
2621
|
-
* @param payload The request payload to sign.
|
|
2621
|
+
* @param payload The request payload to sign. Can be a structured request object (which will be
|
|
2622
|
+
* canonicalized to JSON before signing) or a pre-serialized binary payload (`Uint8Array`) that
|
|
2623
|
+
* will be signed directly.
|
|
2622
2624
|
* @returns The user's authorization signature over the API request.
|
|
2623
2625
|
*/
|
|
2624
|
-
declare function generateAuthorizationSignature(sign: SignWalletRequest, payload: GenerateAuthorizationSignatureInput): Promise<GenerateAuthorizationSignatureOutput>;
|
|
2626
|
+
declare function generateAuthorizationSignature(sign: SignWalletRequest, payload: GenerateAuthorizationSignatureInput | Uint8Array): Promise<GenerateAuthorizationSignatureOutput>;
|
|
2625
2627
|
|
|
2626
2628
|
type Input$3 = {
|
|
2627
2629
|
request: WalletCreateParams;
|
|
@@ -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"../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():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};
|
|
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":"+5CAmEe,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,IAAIG,EAAiB,CACzBC,MAAO,sDACPC,KAAM,yCAIJd,KAAKC,OAAO8B,UAAU,CAC1BtB,YAAAA,KACGF,GAEP,CAKA,IAAOyB,KAAAA,SAAchC,KAAKU,eAAeuB,iBACzC,MAAO,CAACD,KAAAA,EACV,CAEA,wBAAaE,EACXC,OAAAA,EACAC,UAAAA,EACAC,kBAAAA,EACAC,iBAAAA,EACAC,oBAAAA,EACAC,uBAAAA,IASA,IAAKxC,KAAKC,OACR,MAAMO,MAAU,yCAIl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BjD,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","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,IAAMr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B,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,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,2 +1,2 @@
|
|
|
1
|
-
import e from"./AppApi.mjs";import t from"./CrossAppApi.mjs";import i from"./DelegatedWalletsApi.mjs";import r from"./EmbeddedWalletApi.mjs";import
|
|
1
|
+
import e from"./AppApi.mjs";import t from"./CrossAppApi.mjs";import i from"./DelegatedWalletsApi.mjs";import r from"./EmbeddedWalletApi.mjs";import m from"./MfaPromises.mjs";import{PrivyInternal as s}from"./PrivyInternal.mjs";import o from"./UserApi.mjs";import a from"./auth/AuthApi.mjs";import p from"./funding/FundingApi.mjs";import n from"./mfa/MfaApi.mjs";import l from"./recovery/RecoveryApi.mjs";import"@privy-io/routes";import"../Token.mjs";import"jose";import"@privy-io/chains";import"../Error.mjs";import"../embedded/EmbeddedBitcoinWalletProvider.mjs";import"../wallet-api/unified-wallet.mjs";import"../embedded/errors.mjs";import"../embedded/types.mjs";import"../embedded/stack/walletCreate.mjs";import"../wallet-api/create.mjs";import"../embedded/utils/index.mjs";import"viem";import"../embedded/EmbeddedWalletProxy.mjs";import"../utils/sleep.mjs";import"../embedded/EventCallbackQueue.mjs";import"../embedded/withMfa.mjs";import"../embedded/EmbeddedWalletProvider.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"../embedded/EmbeddedSolanaWalletProvider.mjs";import"../solana/getWalletPublicKeyFromTransaction.mjs";import"../solana/isVersionedTransaction.mjs";import"fetch-retry";import"uuid";import"@privy-io/api-base";import"../Session.mjs";import"js-cookie";import"../utils/allSettled.mjs";import"../toAbortSignalTimeout.mjs";import"../utils/toSearchParams.mjs";import"./logger.mjs";import"../utils/noop.mjs";import"./auth/CustomProviderApi.mjs";import"./auth/maybeCreateWalletOnLogin.mjs";import"../utils/getUserEmbeddedEthereumWallet.mjs";import"../utils/getAllUserEmbeddedEthereumWallets.mjs";import"../utils/embedded-wallets.mjs";import"../utils/getUserEmbeddedSolanaWallet.mjs";import"../utils/getAllUserEmbeddedSolanaWallets.mjs";import"../utils/shouldCreateEmbeddedEthWallet.mjs";import"../utils/shouldCreateEmbeddedSolWallet.mjs";import"./auth/EmailApi.mjs";import"./auth/FarcasterApi.mjs";import"./auth/FarcasterV2Api.mjs";import"./auth/GuestApi.mjs";import"./auth/OAuthApi.mjs";import"../pkce.mjs";import"./auth/PasskeyApi.mjs";import"./auth/PhoneApi.mjs";import"./auth/SiweApi.mjs";import"./auth/SiwsApi.mjs";import"./auth/SmartWalletApi.mjs";import"./funding/CoinbaseOnRampApi.mjs";import"./funding/MoonpayOnRampApi.mjs";import"../funding/moonpay.mjs";import"./mfa/MfaPasskeyApi.mjs";import"./mfa/MfaSmsApi.mjs";import"./recovery/RecoveryICloudApi.mjs";import"./recovery/RecoveryOAuthApi.mjs";class d{async initialize(){await this._privyInternal._initialize()}setMessagePoster(e){this.embeddedWallet.setMessagePoster(e)}addOAuthTokensListener(e){return this._privyInternal.session.on("oauth_tokens_granted",e),{unsubscribe:()=>{this._privyInternal.session.removeListener("oauth_tokens_granted",e)}}}setCallbacks(e){this._privyInternal.setCallbacks(e)}getAccessToken(){return this._privyInternal.getAccessToken()}getIdentityToken(){return this._privyInternal.getIdentityToken()}getCompiledPath(e,t){return this._privyInternal.getPath(e,t)}async fetchPrivyRoute(e,t){return this._privyInternal.fetch(e,t)}get logger(){return this._privyInternal.logger}constructor({clientId:d,...h}){this._privyInternal=new s({...h,appClientId:d}),this.mfa=new n(this._privyInternal),this.mfaPromises=new m,this.app=new e(this._privyInternal),this.embeddedWallet=new r(this._privyInternal,h.embeddedWalletMessagePoster,h.supportedChains,this.mfa,this.mfaPromises,this.app),this.user=new o(this._privyInternal),this.auth=new a(this._privyInternal,this.embeddedWallet,h.storage,h.crypto,this.mfa),this.recovery=new l(this._privyInternal,h.storage,h.crypto),this.funding=new p(this._privyInternal),this.delegated=new i(this._privyInternal),this.crossApp=new t(this._privyInternal,h.storage)}}export{d as default};
|
|
2
2
|
//# sourceMappingURL=Privy.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Privy.mjs","sources":["../../../src/client/Privy.ts"],"names":["Privy","initialize","this","_privyInternal","_initialize","setMessagePoster","poster","embeddedWallet","addOAuthTokensListener","listener","session","on","unsubscribe","removeListener","setCallbacks","callbacks","getAccessToken","getIdentityToken","getCompiledPath","r","opts","getPath","fetchPrivyRoute","fetch","logger","constructor","clientId","o","PrivyInternal","appClientId","mfa","MfaApi","mfaPromises","MfaPromises","app","AppApi","EmbeddedWalletApi","embeddedWalletMessagePoster","supportedChains","user","UserApi","auth","AuthApi","storage","crypto","recovery","RecoveryApi","funding","FundingApi","delegated","DelegatedWalletsApi","crossApp","CrossAppApi"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Privy.mjs","sources":["../../../src/client/Privy.ts"],"names":["Privy","initialize","this","_privyInternal","_initialize","setMessagePoster","poster","embeddedWallet","addOAuthTokensListener","listener","session","on","unsubscribe","removeListener","setCallbacks","callbacks","getAccessToken","getIdentityToken","getCompiledPath","r","opts","getPath","fetchPrivyRoute","fetch","logger","constructor","clientId","o","PrivyInternal","appClientId","mfa","MfaApi","mfaPromises","MfaPromises","app","AppApi","EmbeddedWalletApi","embeddedWalletMessagePoster","supportedChains","user","UserApi","auth","AuthApi","storage","crypto","recovery","RecoveryApi","funding","FundingApi","delegated","DelegatedWalletsApi","crossApp","CrossAppApi"],"mappings":"kuFAgFe,MAAMA,EAsGnB,gBAAaC,SACLC,KAAKC,eAAeC,aAC5B,CAEA,gBAAAC,CAAwBC,GACtBJ,KAAKK,eAAeF,iBAAiBC,EACvC,CAQA,sBAAAE,CAA8BC,GAE5B,OADAP,KAAKC,eAAeO,QAAQC,GAAG,uBAAwBF,GAChD,CACLG,YAAa,KACXV,KAAKC,eAAeO,QAAQG,eAAe,uBAAwBJ,EAAAA,EAGzE,CAKA,YAAAK,CAAoBC,GAClBb,KAAKC,eAAeW,aAAaC,EACnC,CAEA,cAAAC,GACE,OAAOd,KAAKC,eAAea,gBAC7B,CAEOC,gBAAAA,GACL,OAAOf,KAAKC,eAAec,kBAC7B,CAEOC,eAAAA,CACLC,EACAC,GAMA,OAAOlB,KAAKC,eAAekB,QAAQF,EAAGC,EACxC,CAEA,qBAAaE,CACXH,EACAC,GAOA,OAAOlB,KAAKC,eAAeoB,MAAMJ,EAAGC,EACtC,CAKA,UAAWI,GACT,OAAOtB,KAAKC,eAAeqB,MAC7B,CA/GA,WAAAC,EAAoBC,SAAAA,KAAaC,IAE/BzB,KAAKC,eAAiB,IAAIyB,EAAc,IACnCD,EACHE,YAAaH,IAIfxB,KAAK4B,IAAM,IAAIC,EAAO7B,KAAKC,gBAC3BD,KAAK8B,YAAc,IAAIC,EAGvB/B,KAAKgC,IAAM,IAAIC,EAAOjC,KAAKC,gBAG3BD,KAAKK,eAAiB,IAAI6B,EACxBlC,KAAKC,eACLwB,EAAEU,4BACFV,EAAEW,gBACFpC,KAAK4B,IACL5B,KAAK8B,YACL9B,KAAKgC,KAIPhC,KAAKqC,KAAO,IAAIC,EAAQtC,KAAKC,gBAC7BD,KAAKuC,KAAO,IAAIC,EACdxC,KAAKC,eACLD,KAAKK,eACLoB,EAAEgB,QACFhB,EAAEiB,OACF1C,KAAK4B,KAEP5B,KAAK2C,SAAW,IAAIC,EAAY5C,KAAKC,eAAgBwB,EAAEgB,QAAShB,EAAEiB,QAClE1C,KAAK6C,QAAU,IAAIC,EAAW9C,KAAKC,gBACnCD,KAAK+C,UAAY,IAAIC,EAAoBhD,KAAKC,gBAC9CD,KAAKiD,SAAW,IAAIC,EAAYlD,KAAKC,eAAgBwB,EAAEgB,QACzD"}
|
|
@@ -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.
|
|
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.0",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{PrivyClientError as e}from"../Error.mjs";import{getWalletPublicKeyFromTransaction as t}from"../solana/getWalletPublicKeyFromTransaction.mjs";import{isVersionedTransaction as r}from"../solana/isVersionedTransaction.mjs";import{isUnifiedWallet as a}from"../wallet-api/unified-wallet.mjs";import{errorIndicatesRecoveryIsNeeded as s}from"./errors.mjs";import{walletRpc as n}from"./stack/walletRpc.mjs";import"./types.mjs";import"../utils/encodings.mjs";import"../wallet-api/rpc.mjs";import"@privy-io/routes";import"../wallet-api/generate-authorization-signature.mjs";import"canonicalize";import"../wallet-api/types.mjs";import"./stack/wallet-api-eth-transaction.mjs";import"./stack/wallet-api-eth-typed-data.mjs";class i{async request(t){if(!await this._privyInternal.getAccessTokenInternal())throw new e({error:"Missing access token",code:"attempted_rpc_call_before_logged_in"});switch(t.method){case"signAndSendTransaction":return await this.handleSignAndSendTransaction(t);case"signTransaction":return await this.handleSignTransaction(t);default:return await this.handleIFrameRpc(t)}}get _publicKey(){return this._account.address}async connectAndRecover(t){if("privy-v2"!==this._account.recovery_method)try{await this._proxy.connect({entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier,accessToken:t})}catch(r){let a=s(r);if(a&&"privy"===this._account.recovery_method)await this._proxy.recover({entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier,accessToken:t});else{if(!a||!this._onNeedsRecovery)throw r;{let t;await new Promise((async(r,a)=>{t=setTimeout((()=>a(new e({code:"embedded_wallet_recovery_error",error:"User-owned recovery timed out"}))),12e4),await(this._onNeedsRecovery?.({recoveryMethod:this._account.recovery_method,onRecovered:()=>r(!0)}))})).finally((()=>clearTimeout(t)))}}}}async signMessageRpc(e,t){let r=this._account;if(!a(r))return(await this._proxy.rpcWallet({accessToken:t,request:e,chainType:"solana",hdWalletIndex:this._account.wallet_index,entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier})).response.data;{let{data:a}=await n({context:{app:this._app,fetchPrivyRoute:(...e)=>this._privyInternal.fetch(...e),getCompiledPath:(...e)=>this._privyInternal.getPath(...e),signRequest:({message:e})=>this._proxy.signWithUserSigner({accessToken:t,message:e})},account:r,rpcRequest:{chainType:"solana",request:e}});return{signature:a}}}async handleIFrameRpc(t){try{let e=await this._privyInternal.getAccessTokenInternal();if(!e)throw Error("Missing privy token. User must be logged in");return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_started",{method:t.method,address:this._account.address}),await this.connectAndRecover(e),await this.signMessageRpc(t,e)}catch(r){console.error(r);let a=r instanceof Error?r.message:"Unable to make wallet request";throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_failed",{method:t.method,address:this._account.address,error:a}),new e({code:"embedded_wallet_request_error",error:a})}}async handleSignAndSendTransaction(a){try{let e=await this._privyInternal.getAccessTokenInternal();if(!e)throw Error("Missing privy token. User must be logged in");this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_started",{method:a.method,address:this._account.address}),await this.connectAndRecover(e);let{transaction:s,connection:n,options:i}=a.params,o=t(s,this._account.address),c=r(s)?Buffer.from(s.message.serialize()):s.serializeMessage(),{signature:d}=await this.signMessageRpc({method:"signMessage",params:{message:c.toString("base64")}},e);return s.addSignature(o,Buffer.from(d,"base64")),{signature:await n.sendRawTransaction(s.serialize(),i)}}catch(t){console.error(t);let r=t instanceof Error?t.message:"Unable to make wallet request";throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_failed",{method:a.method,address:this._account.address,error:r}),new e({code:"embedded_wallet_request_error",error:r})}}async handleSignTransaction(a){try{let e=await this._privyInternal.getAccessTokenInternal();if(!e)throw Error("Missing privy token. User must be logged in");this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_started",{method:a.method,address:this._account.address}),await this.connectAndRecover(e);let{transaction:s}=a.params,n=t(s,this._account.address),i=r(s)?Buffer.from(s.message.serialize()):s.serializeMessage(),{signature:o}=await this.signMessageRpc({method:"signMessage",params:{message:i.toString("base64")}},e);return s.addSignature(n,Buffer.from(o,"base64")),{signedTransaction:s}}catch(t){console.error(t);let r=t instanceof Error?t.message:"Unable to make wallet request";throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_failed",{method:a.method,address:this._account.wallet_index,error:r}),new e({code:"embedded_wallet_request_error",error:r})}}toJSON(){return`PrivyEmbeddedSolanaProvider { address: '${this._account.address}', request: [Function] }`}constructor({proxy:e,privyInternal:t,account:r,entropyId:a,entropyIdVerifier:s,onNeedsRecovery:n,app:i}){this._proxy=e,this._privyInternal=t,this._account=r,this._entropyId=a,this._entropyIdVerifier=s,this._onNeedsRecovery=n,this._app=i}}export{i as EmbeddedSolanaWalletProvider};
|
|
1
|
+
import{PrivyClientError as e}from"../Error.mjs";import{getWalletPublicKeyFromTransaction as t}from"../solana/getWalletPublicKeyFromTransaction.mjs";import{isVersionedTransaction as r}from"../solana/isVersionedTransaction.mjs";import{isUnifiedWallet as a}from"../wallet-api/unified-wallet.mjs";import{errorIndicatesRecoveryIsNeeded as s}from"./errors.mjs";import{walletRpc as n}from"./stack/walletRpc.mjs";import"./types.mjs";import"../utils/encodings.mjs";import"../wallet-api/rpc.mjs";import"@privy-io/routes";import"../wallet-api/generate-authorization-signature.mjs";import"canonicalize";import"@privy-io/encoding";import"../wallet-api/types.mjs";import"./stack/wallet-api-eth-transaction.mjs";import"./stack/wallet-api-eth-typed-data.mjs";class i{async request(t){if(!await this._privyInternal.getAccessTokenInternal())throw new e({error:"Missing access token",code:"attempted_rpc_call_before_logged_in"});switch(t.method){case"signAndSendTransaction":return await this.handleSignAndSendTransaction(t);case"signTransaction":return await this.handleSignTransaction(t);default:return await this.handleIFrameRpc(t)}}get _publicKey(){return this._account.address}async connectAndRecover(t){if("privy-v2"!==this._account.recovery_method)try{await this._proxy.connect({entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier,accessToken:t})}catch(r){let a=s(r);if(a&&"privy"===this._account.recovery_method)await this._proxy.recover({entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier,accessToken:t});else{if(!a||!this._onNeedsRecovery)throw r;{let t;await new Promise((async(r,a)=>{t=setTimeout((()=>a(new e({code:"embedded_wallet_recovery_error",error:"User-owned recovery timed out"}))),12e4),await(this._onNeedsRecovery?.({recoveryMethod:this._account.recovery_method,onRecovered:()=>r(!0)}))})).finally((()=>clearTimeout(t)))}}}}async signMessageRpc(e,t){let r=this._account;if(!a(r))return(await this._proxy.rpcWallet({accessToken:t,request:e,chainType:"solana",hdWalletIndex:this._account.wallet_index,entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier})).response.data;{let{data:a}=await n({context:{app:this._app,fetchPrivyRoute:(...e)=>this._privyInternal.fetch(...e),getCompiledPath:(...e)=>this._privyInternal.getPath(...e),signRequest:({message:e})=>this._proxy.signWithUserSigner({accessToken:t,message:e})},account:r,rpcRequest:{chainType:"solana",request:e}});return{signature:a}}}async handleIFrameRpc(t){try{let e=await this._privyInternal.getAccessTokenInternal();if(!e)throw Error("Missing privy token. User must be logged in");return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_started",{method:t.method,address:this._account.address}),await this.connectAndRecover(e),await this.signMessageRpc(t,e)}catch(r){console.error(r);let a=r instanceof Error?r.message:"Unable to make wallet request";throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_failed",{method:t.method,address:this._account.address,error:a}),new e({code:"embedded_wallet_request_error",error:a})}}async handleSignAndSendTransaction(a){try{let e=await this._privyInternal.getAccessTokenInternal();if(!e)throw Error("Missing privy token. User must be logged in");this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_started",{method:a.method,address:this._account.address}),await this.connectAndRecover(e);let{transaction:s,connection:n,options:i}=a.params,o=t(s,this._account.address),c=r(s)?Buffer.from(s.message.serialize()):s.serializeMessage(),{signature:d}=await this.signMessageRpc({method:"signMessage",params:{message:c.toString("base64")}},e);return s.addSignature(o,Buffer.from(d,"base64")),{signature:await n.sendRawTransaction(s.serialize(),i)}}catch(t){console.error(t);let r=t instanceof Error?t.message:"Unable to make wallet request";throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_failed",{method:a.method,address:this._account.address,error:r}),new e({code:"embedded_wallet_request_error",error:r})}}async handleSignTransaction(a){try{let e=await this._privyInternal.getAccessTokenInternal();if(!e)throw Error("Missing privy token. User must be logged in");this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_started",{method:a.method,address:this._account.address}),await this.connectAndRecover(e);let{transaction:s}=a.params,n=t(s,this._account.address),i=r(s)?Buffer.from(s.message.serialize()):s.serializeMessage(),{signature:o}=await this.signMessageRpc({method:"signMessage",params:{message:i.toString("base64")}},e);return s.addSignature(n,Buffer.from(o,"base64")),{signedTransaction:s}}catch(t){console.error(t);let r=t instanceof Error?t.message:"Unable to make wallet request";throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_failed",{method:a.method,address:this._account.wallet_index,error:r}),new e({code:"embedded_wallet_request_error",error:r})}}toJSON(){return`PrivyEmbeddedSolanaProvider { address: '${this._account.address}', request: [Function] }`}constructor({proxy:e,privyInternal:t,account:r,entropyId:a,entropyIdVerifier:s,onNeedsRecovery:n,app:i}){this._proxy=e,this._privyInternal=t,this._account=r,this._entropyId=a,this._entropyIdVerifier=s,this._onNeedsRecovery=n,this._app=i}}export{i as EmbeddedSolanaWalletProvider};
|
|
2
2
|
//# sourceMappingURL=EmbeddedSolanaWalletProvider.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmbeddedSolanaWalletProvider.mjs","sources":["../../../src/embedded/EmbeddedSolanaWalletProvider.ts"],"names":["EmbeddedSolanaWalletProvider","request","this","_privyInternal","getAccessTokenInternal","PrivyClientError","error","code","method","handleSignAndSendTransaction","handleSignTransaction","handleIFrameRpc","_publicKey","_account","address","connectAndRecover","token","recovery_method","_proxy","connect","entropyId","_entropyId","entropyIdVerifier","_entropyIdVerifier","accessToken","e","needsRecovery","errorIndicatesRecoveryIsNeeded","recover","_onNeedsRecovery","timeout","Promise","async","res","rej","setTimeout","recoveryMethod","onRecovered","finally","clearTimeout","signMessageRpc","account","isUnifiedWallet","rpcWallet","chainType","hdWalletIndex","wallet_index","response","data","walletRpc","context","app","_app","fetchPrivyRoute","args","fetch","getCompiledPath","getPath","signRequest","message","signWithUserSigner","rpcRequest","signature","Error","createAnalyticsEvent","console","transaction","tx","connection","options","params","walletPublicKey","getWalletPublicKeyFromTransaction","serializedMessage","isVersionedTransaction","Buffer","from","serialize","serializeMessage","toString","addSignature","sendRawTransaction","signedTransaction","toJSON","constructor","proxy","privyInternal","onNeedsRecovery"],"mappings":"
|
|
1
|
+
{"version":3,"file":"EmbeddedSolanaWalletProvider.mjs","sources":["../../../src/embedded/EmbeddedSolanaWalletProvider.ts"],"names":["EmbeddedSolanaWalletProvider","request","this","_privyInternal","getAccessTokenInternal","PrivyClientError","error","code","method","handleSignAndSendTransaction","handleSignTransaction","handleIFrameRpc","_publicKey","_account","address","connectAndRecover","token","recovery_method","_proxy","connect","entropyId","_entropyId","entropyIdVerifier","_entropyIdVerifier","accessToken","e","needsRecovery","errorIndicatesRecoveryIsNeeded","recover","_onNeedsRecovery","timeout","Promise","async","res","rej","setTimeout","recoveryMethod","onRecovered","finally","clearTimeout","signMessageRpc","account","isUnifiedWallet","rpcWallet","chainType","hdWalletIndex","wallet_index","response","data","walletRpc","context","app","_app","fetchPrivyRoute","args","fetch","getCompiledPath","getPath","signRequest","message","signWithUserSigner","rpcRequest","signature","Error","createAnalyticsEvent","console","transaction","tx","connection","options","params","walletPublicKey","getWalletPublicKeyFromTransaction","serializedMessage","isVersionedTransaction","Buffer","from","serialize","serializeMessage","toString","addSignature","sendRawTransaction","signedTransaction","toJSON","constructor","proxy","privyInternal","onNeedsRecovery"],"mappings":"uuBA8EO,MAAMA,EA8DX,aAAMC,CAAQA,GAGZ,UAF0BC,KAAKC,eAAeC,yB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,MANKzD,KAAKC,eAAe6D,qBAAqB,iCAAkC,CAC9ExD,OAAQP,EAAQO,OAChBM,QAASZ,KAAKW,SAASiC,aACvBxC,MAAOqD,IAGH,IAAItD,EAAiB,CAACE,KAAM,gCAAiCD,MAAOqD,GAC5E,CACF,CAKAwB,MAAAA,GACE,MAAO,2CAA2CjF,KAAKW,SAASC,iCAAiC,CAzQnGsE,WAAAA,EACEC,MAAAA,EACAC,cAAAA,EACA7C,QAAAA,EACArB,UAAAA,EACAE,kBAAAA,EACAiE,gBAAAA,EACApC,IAAAA,IAEAjD,KAAKgB,OAASmE,EACdnF,KAAKC,eAAiBmF,EACtBpF,KAAKW,SAAW4B,EAChBvC,KAAKmB,WAAaD,EAClBlB,KAAKqB,mBAAqBD,EAC1BpB,KAAK2B,iBAAmB0D,EACxBrF,KAAKkD,KAAOD,CACd"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"eventemitter3";import{toHex as t}from"viem";import{toViemTransactionSerializable as
|
|
1
|
+
import e from"eventemitter3";import{toHex as t}from"viem";import{toViemTransactionSerializable as r,STRING_TO_NUMBER_TXN_TYPE as a}from"@privy-io/ethereum";import{PrivyClientError as i}from"../Error.mjs";import{isUnifiedWallet as s}from"../wallet-api/unified-wallet.mjs";import{EmbeddedProviderError as n,errorIndicatesRecoveryIsNeeded as o}from"./errors.mjs";import{walletRpc as h}from"./stack/walletRpc.mjs";import{getPublicClient as c}from"./utils/index.mjs";import"./types.mjs";import"../utils/encodings.mjs";import"../wallet-api/rpc.mjs";import"@privy-io/routes";import"../wallet-api/generate-authorization-signature.mjs";import"canonicalize";import"@privy-io/encoding";import"../wallet-api/types.mjs";import"./stack/wallet-api-eth-transaction.mjs";import"./stack/wallet-api-eth-typed-data.mjs";let d=new Set(["eth_sign","personal_sign","eth_signTypedData_v4","csw_signUserOperation","secp256k1_sign"]);class p extends e{async request(e){if(d.has(e.method))return this.handleIFrameRpc(e);switch(e.method){case"eth_accounts":case"eth_requestAccounts":return this._account.address?[this._account.address]:[];case"eth_chainId":return`0x${this._chainId.toString(16)}`;case"wallet_switchEthereumChain":return this.handleSwitchEthereumChain(e);case"eth_estimateGas":return this.handleEstimateGas(e);case"eth_signTransaction":{let t=e.params?.[0];return this.handleSignTransaction(t)}case"eth_sendTransaction":{let t=e.params?.[0];return this.handleSendTransaction(t)}case"eth_populateTransactionRequest":{let t=e.params?.[0];return this.handlePopulateTransaction(t)}default:return this.handleJsonRpc(e)}}ensureChainId(e){let t={chainId:this._chainId,...e};return this.internalSwitchEthereumChain(t.chainId),t}internalSwitchEthereumChain(e){e&&Number(e)!==this._chainId&&(this._chainId=Number(e),this._client=c(this._chainId,this._chains,{rpcUrls:[]},{appId:this._privyInternal.appId}),this.emit("chainChanged",e))}async handlePopulateTransaction(e){let t=this.ensureChainId(e),i=r(t),{type:s,...n}=await this._client.prepareTransactionRequest({account:t.from??this._account.address,...i});return{...n,type:a[s]}}async handleSignTransaction(e){let r={...e};for(let e of Object.keys(r)){let a=r[e];a&&"bigint"==typeof a&&(r[e]=t(a))}return await this.handleIFrameRpc({method:"eth_signTransaction",params:[r]})}async handleSendTransaction(e){let t=await this.handlePopulateTransaction(e),r=await this.handleSignTransaction(t);return await this.handleJsonRpc({method:"eth_sendRawTransaction",params:[r]})}async handleEstimateGas(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for eth_estimateGas");let t=e.params?.[0],a=this.ensureChainId(t),i=r(a);return await this._client.estimateGas({account:a.from??this._account.address,...i})}handleSwitchEthereumChain(e){let t;if(!e.params||!Array.isArray(e.params))throw new n(`Invalid params for ${e.method}`,4200);if("string"==typeof e.params[0])t=e.params[0];else{if(!("chainId"in e.params[0])||"string"!=typeof e.params[0].chainId)throw new n(`Invalid params for ${e.method}`,4200);t=e.params[0].chainId}this.internalSwitchEthereumChain(t)}async handleIFrameRpc(e){try{let t=await this._privyInternal.getAccessTokenInternal();if(!t)throw Error("Missing privy token. User must be logged in");this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_started",{method:e.method,address:this._account.address});let r=this._account;if(s(r)){let{data:a}=await h({context:{app:this._appApi,fetchPrivyRoute:(...e)=>this._privyInternal.fetch(...e),getCompiledPath:(...e)=>this._privyInternal.getPath(...e),signRequest:({message:e})=>this._walletProxy.signWithUserSigner({accessToken:t,message:e})},account:r,rpcRequest:{chainType:"ethereum",request:e}});return a}try{await this._walletProxy.connect({entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier,accessToken:t})}catch(e){let r=o(e);if(r&&"privy"===this._account.recovery_method)await this._walletProxy.recover({entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier,accessToken:t});else{if(!r||!this._onNeedsRecovery)throw e;{let e;await new Promise((async(t,r)=>{e=setTimeout((()=>r(new i({code:"embedded_wallet_recovery_error",error:"User-owned recovery timed out"}))),12e4),await(this._onNeedsRecovery?.({recoveryMethod:this._account.recovery_method,onRecovered:()=>t(!0)}))})).finally((()=>clearTimeout(e)))}}}return(await this._walletProxy.rpcWallet({accessToken:t,request:e,entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier,hdWalletIndex:this._account.wallet_index,chainType:"ethereum"})).response.data}catch(t){console.error(t);let r=t instanceof Error?t.message:"Unable to make wallet request";throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_failed",{method:e.method,address:this._account.address,error:r}),new i({code:"embedded_wallet_request_error",error:r})}}async handleJsonRpc(e){return this._client.request(e)}toJSON(){return`PrivyEIP1193Provider { address: '${this._account.address}', chainId: ${this._chainId}, request: [Function] }`}constructor({walletProxy:e,privyInternal:t,account:r,entropyId:a,entropyIdVerifier:i,chains:s,onNeedsRecovery:n,chainId:o=s[0].id,appApi:h}){super(),this._walletProxy=e,this._privyInternal=t,this._account=r,this._entropyId=a,this._entropyIdVerifier=i,this._chainId=o,this._chains=s,this._onNeedsRecovery=n,this._client=c(o,s,{rpcUrls:[]},{appId:h.appId}),this._appApi=h}}export{p as EmbeddedWalletProvider};
|
|
2
2
|
//# sourceMappingURL=EmbeddedWalletProvider.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmbeddedWalletProvider.mjs","sources":["../../../src/embedded/EmbeddedWalletProvider.ts"],"names":["IFRAME_PASSTHROUGH_RPC_METHODS","Set","EmbeddedWalletProvider","EventEmitter","request","has","method","this","handleIFrameRpc","_account","address","_chainId","toString","handleSwitchEthereumChain","handleEstimateGas","data","params","handleSignTransaction","handleSendTransaction","handlePopulateTransaction","handleJsonRpc","ensureChainId","tx","ensureTxChainId","chainId","internalSwitchEthereumChain","Number","_client","getPublicClient","_chains","rpcUrls","appId","_privyInternal","emit","txRequest","viemTxn","toViemTransactionSerializable","type","preparedTxn","prepareTransactionRequest","account","from","STRING_TO_NUMBER_TXN_TYPE","serializable","key","Object","keys","val","toHex","populatedTx","signedTx","Array","isArray","Error","estimateGas","args","newChain","EmbeddedProviderError","token","getAccessTokenInternal","createAnalyticsEvent","isUnifiedWallet","walletRpc","context","app","_appApi","fetchPrivyRoute","fetch","getCompiledPath","getPath","signRequest","message","_walletProxy","signWithUserSigner","accessToken","rpcRequest","chainType","connect","entropyId","_entropyId","entropyIdVerifier","_entropyIdVerifier","e","needsRecovery","errorIndicatesRecoveryIsNeeded","recovery_method","recover","_onNeedsRecovery","timeout","Promise","async","res","rej","setTimeout","PrivyClientError","code","error","recoveryMethod","onRecovered","finally","clearTimeout","rpcWallet","hdWalletIndex","wallet_index","response","console","toJSON","constructor","walletProxy","privyInternal","chains","onNeedsRecovery","id","appApi","super"],"mappings":"
|
|
1
|
+
{"version":3,"file":"EmbeddedWalletProvider.mjs","sources":["../../../src/embedded/EmbeddedWalletProvider.ts"],"names":["IFRAME_PASSTHROUGH_RPC_METHODS","Set","EmbeddedWalletProvider","EventEmitter","request","has","method","this","handleIFrameRpc","_account","address","_chainId","toString","handleSwitchEthereumChain","handleEstimateGas","data","params","handleSignTransaction","handleSendTransaction","handlePopulateTransaction","handleJsonRpc","ensureChainId","tx","ensureTxChainId","chainId","internalSwitchEthereumChain","Number","_client","getPublicClient","_chains","rpcUrls","appId","_privyInternal","emit","txRequest","viemTxn","toViemTransactionSerializable","type","preparedTxn","prepareTransactionRequest","account","from","STRING_TO_NUMBER_TXN_TYPE","serializable","key","Object","keys","val","toHex","populatedTx","signedTx","Array","isArray","Error","estimateGas","args","newChain","EmbeddedProviderError","token","getAccessTokenInternal","createAnalyticsEvent","isUnifiedWallet","walletRpc","context","app","_appApi","fetchPrivyRoute","fetch","getCompiledPath","getPath","signRequest","message","_walletProxy","signWithUserSigner","accessToken","rpcRequest","chainType","connect","entropyId","_entropyId","entropyIdVerifier","_entropyIdVerifier","e","needsRecovery","errorIndicatesRecoveryIsNeeded","recovery_method","recover","_onNeedsRecovery","timeout","Promise","async","res","rej","setTimeout","PrivyClientError","code","error","recoveryMethod","onRecovered","finally","clearTimeout","rpcWallet","hdWalletIndex","wallet_index","response","console","toJSON","constructor","walletProxy","privyInternal","chains","onNeedsRecovery","id","appApi","super"],"mappings":"gyBA0EA,IAAMA,EAAiC,IAAIC,IAAI,CAC7C,WACA,gBACA,uBACA,wBACA,mBAGK,MAAMC,UAA+BC,EAiD1C,aAAMC,CAAQA,GAGZ,GAAIJ,EAA+BK,IAAID,EAAQE,QAC7C,OAAOC,KAAKC,gBAAgBJ,GAG9B,OAAQA,EAAQE,QACd,IAAK,eACL,IAAK,sBACH,OAAOC,KAAKE,SAASC,QAAU,CAACH,KAAKE,SAASC,SAAW,GAE3D,IAAK,cACH,MAAO,KAAKH,KAAKI,SAASC,SAAS,MAErC,IAAK,6BACH,OAAOL,KAAKM,0BAA0BT,GAExC,IAAK,kBACH,OAAOG,KAAKO,kBAAkBV,GAEhC,IAAK,sBAAuB,CAC1B,IAAMW,EAAOX,EAAQY,SAAS,GAC9B,OAAOT,KAAKU,sBAAsBF,EACpC,CACA,IAAK,sBAAuB,CAC1B,IAAMA,EAAOX,EAAQY,SAAS,GAC9B,OAAOT,KAAKW,sBAAsBH,EAC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C,sBAAsBH,KAAKI,iCACtF,CAvRAgG,WAAAA,EACEC,YAAAA,EACAC,cAAAA,EACArE,QAAAA,EACAsC,UAAAA,EACAE,kBAAAA,EACA8B,OAAAA,EACAC,gBAAAA,EACAvF,QAAAA,EAAUsF,EAAO,GAAGE,GACpBC,OAAAA,IAEAC,QACA3G,KAAKiE,aAAeoC,EACpBrG,KAAKyB,eAAiB6E,EACtBtG,KAAKE,SAAW+B,EAChBjC,KAAKwE,WAAaD,EAClBvE,KAAK0E,mBAAqBD,EAC1BzE,KAAKI,SAAWa,EAChBjB,KAAKsB,QAAUiF,EACfvG,KAAKgF,iBAAmBwB,EACxBxG,KAAKoB,QAAUC,EAAgBJ,EAASsF,EAAQ,CAAChF,QAAS,IAAK,CAACC,MAAOkF,EAAOlF,QAC9ExB,KAAK0D,QAAUgD,CACjB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{EmbeddedWalletProvider}from"./EmbeddedWalletProvider.mjs";export{EmbeddedSolanaWalletProvider}from"./EmbeddedSolanaWalletProvider.mjs";export{EmbeddedWalletProxy}from"./EmbeddedWalletProxy.mjs";import"eventemitter3";import"viem";import"@privy-io/ethereum";import"../Error.mjs";import"../wallet-api/unified-wallet.mjs";import"./errors.mjs";import"./types.mjs";import"./stack/walletRpc.mjs";import"../utils/encodings.mjs";import"../wallet-api/rpc.mjs";import"@privy-io/routes";import"../wallet-api/generate-authorization-signature.mjs";import"canonicalize";import"../wallet-api/types.mjs";import"./stack/wallet-api-eth-transaction.mjs";import"./stack/wallet-api-eth-typed-data.mjs";import"./utils/index.mjs";import"../solana/getWalletPublicKeyFromTransaction.mjs";import"../solana/isVersionedTransaction.mjs";import"../utils/sleep.mjs";import"./EventCallbackQueue.mjs";import"./withMfa.mjs";
|
|
1
|
+
export{EmbeddedWalletProvider}from"./EmbeddedWalletProvider.mjs";export{EmbeddedSolanaWalletProvider}from"./EmbeddedSolanaWalletProvider.mjs";export{EmbeddedWalletProxy}from"./EmbeddedWalletProxy.mjs";import"eventemitter3";import"viem";import"@privy-io/ethereum";import"../Error.mjs";import"../wallet-api/unified-wallet.mjs";import"./errors.mjs";import"./types.mjs";import"./stack/walletRpc.mjs";import"../utils/encodings.mjs";import"../wallet-api/rpc.mjs";import"@privy-io/routes";import"../wallet-api/generate-authorization-signature.mjs";import"canonicalize";import"@privy-io/encoding";import"../wallet-api/types.mjs";import"./stack/wallet-api-eth-transaction.mjs";import"./stack/wallet-api-eth-typed-data.mjs";import"./utils/index.mjs";import"../solana/getWalletPublicKeyFromTransaction.mjs";import"../solana/isVersionedTransaction.mjs";import"../utils/sleep.mjs";import"./EventCallbackQueue.mjs";import"./withMfa.mjs";
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{getRootWalletForDelegation as e}from"../../action/delegatedActions/utils.mjs";import{getWallet as t}from"../../wallet-api/get-wallet.mjs";import{isUnifiedWallet as r}from"../../wallet-api/unified-wallet.mjs";import{updateWallet as i}from"../../wallet-api/update-wallet.mjs";import"../../utils/getAllUserEmbeddedEthereumWallets.mjs";import"../../utils/embedded-wallets.mjs";import"../../utils/getAllUserEmbeddedSolanaWallets.mjs";import"../../utils/getUserEmbeddedEthereumWallet.mjs";import"../../utils/getUserEmbeddedSolanaWallet.mjs";import"@privy-io/routes";import"../../wallet-api/generate-authorization-signature.mjs";import"canonicalize";import"../../Error.mjs";async function a({client:a,wallet:s,signers:
|
|
1
|
+
import{getRootWalletForDelegation as e}from"../../action/delegatedActions/utils.mjs";import{getWallet as t}from"../../wallet-api/get-wallet.mjs";import{isUnifiedWallet as r}from"../../wallet-api/unified-wallet.mjs";import{updateWallet as i}from"../../wallet-api/update-wallet.mjs";import"../../utils/getAllUserEmbeddedEthereumWallets.mjs";import"../../utils/embedded-wallets.mjs";import"../../utils/getAllUserEmbeddedSolanaWallets.mjs";import"../../utils/getUserEmbeddedEthereumWallet.mjs";import"../../utils/getUserEmbeddedSolanaWallet.mjs";import"@privy-io/routes";import"../../wallet-api/generate-authorization-signature.mjs";import"canonicalize";import"@privy-io/encoding";import"../../Error.mjs";async function a({client:a,wallet:s,signers:n}){if("ethereum"!==s.chain_type&&"solana"!==s.chain_type)throw Error("Session signers are only supported for Ethereum and Solana wallets");if(r(s)){if(0===n.length)throw Error("Must specify at least one signer to add.");let e={wallet_id:s.id},r=await t(a,e);await i(a,e,o(a),{additional_signers:r.additional_signers.concat(n)})}else{if(s.delegated)return l(a);if(n.length>0)throw Error("Specifying signers in addSessionSigners is only supported for TEE execution and this app uses On-device execution. Pass an empty array for signers instead. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide");let{user:t}=await a.user.get(),r=e(s,t);if(!r)throw Error("Unable to determine root address for delegated address.");await a.embeddedWallet.delegateWallets({rootWallet:{address:r.address,chainType:r.chain_type,imported:r.imported??!1},delegatedWallets:[{address:s.address,chainType:s.chain_type,walletIndex:s.wallet_index}]})}return l(a)}async function s({client:e,wallet:t}){if(r(t)){let r={wallet_id:t.id};await i(e,r,o(e),{additional_signers:[]})}else await e.delegated.revoke();return l(e)}async function l(e){let{user:t}=await e.user.get();if(!t)throw Error("Could not refresh user");return{user:t}}function o(e){return(...t)=>e.embeddedWallet.signWithUserSigner(...t)}export{a as addSessionSigners,s as removeSessionSigners};
|
|
2
2
|
//# sourceMappingURL=session-signers.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-signers.mjs","sources":["../../../../src/embedded/stack/session-signers.ts"],"names":["async","addSessionSigners","client","wallet","signers","chain_type","Error","isUnifiedWallet","length","walletKey","wallet_id","id","walletObject","getWallet","updateWallet","makeWalletApiRequestSigner","additional_signers","concat","delegated","getRefreshedUser","user","get","rootWallet","getRootWalletForDelegation","embeddedWallet","delegateWallets","address","chainType","imported","delegatedWallets","walletIndex","wallet_index","removeSessionSigners","revoke","refreshedUser","args","signWithUserSigner"],"mappings":"
|
|
1
|
+
{"version":3,"file":"session-signers.mjs","sources":["../../../../src/embedded/stack/session-signers.ts"],"names":["async","addSessionSigners","client","wallet","signers","chain_type","Error","isUnifiedWallet","length","walletKey","wallet_id","id","walletObject","getWallet","updateWallet","makeWalletApiRequestSigner","additional_signers","concat","delegated","getRefreshedUser","user","get","rootWallet","getRootWalletForDelegation","embeddedWallet","delegateWallets","address","chainType","imported","delegatedWallets","walletIndex","wallet_index","removeSessionSigners","revoke","refreshedUser","args","signWithUserSigner"],"mappings":"6rBAgCOA,eAAeC,GACpBC,OAAAA,EACAC,OAAAA,EACAC,QAAAA,IAIA,GAAID,aAAAA,EAAOE,YAAmD,WAAtBF,EAAOE,WAC7C,MAAUC,MAAM,sEAGlB,GAAKC,EAAgBJ,GA6Bd,CACL,GAAuB,IAAnBC,EAAQI,OACV,MAAUF,MAAM,4CAGlB,IAAMG,EAAY,CAACC,UAAWP,EAAOQ,IAE/BC,QAAqBC,EAAUX,EAAQO,SAEvCK,EAAaZ,EAAQO,EAAWM,EAA2Bb,GAAS,CACxEc,mBAAoBJ,EAAaI,mBAAmBC,OAAOb,IAE/D,KAzC8B,CAC5B,GAAID,EAAOe,UAET,OAAOC,EAAiBjB,GAG1B,GAAIE,EAAQI,OAAS,EACnB,MAAMF,MACJ,mOAIJ,IAAOc,KAAAA,SAAclB,EAAOkB,KAAKC,MAC3BC,EAAaC,EAA2BpB,EAAQiB,GAEtD,IAAKE,EACH,MAAMhB,MAAU,iEAGZJ,EAAOsB,eAAeC,gBAAgB,CAC1CH,WAAY,CACVI,QAASJ,EAAWI,QACpBC,UAAWL,EAAWjB,WACtBuB,SAAUN,EAAWM,WAAY,GAEnCC,iBAAkB,CAChB,CAACH,QAASvB,EAAOuB,QAASC,UAAWxB,EAAOE,WAAYyB,YAAa3B,EAAO4B,gBAGlF,CAcA,OAAOZ,EAAiBjB,EAC1B,CAkBOF,eAAegC,GACpB9B,OAAAA,EACAC,OAAAA,IAEA,GAAKI,EAAgBJ,GAEd,CACL,IAAMM,EAAY,CAACC,UAAWP,EAAOQ,UAE/BG,EAAaZ,EAAQO,EAAWM,EAA2Bb,GAAS,CACxEc,mBAAoB,IAExB,YAPQd,EAAOgB,UAAUe,SASzB,OAAOd,EAAiBjB,EAC1B,CAEAF,eAAemB,EAAiBjB,GAC9B,IAAOkB,KAAMc,SAAuBhC,EAAOkB,KAAKC,MAChD,IAAKa,EACH,MAAU5B,MAAM,0BAElB,MAAO,CAACc,KAAMc,EAChB,CAEA,SAASnB,EAA2Bb,GAClC,MAAO,IAAIiC,IAASjC,EAAOsB,eAAeY,sBAAsBD,EAClE"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{isHexEncoded as e,bytesToHex as t,utf8ToBytes as a}from"../../utils/encodings.mjs";import{rpc as s}from"../../wallet-api/rpc.mjs";import{toWalletApiUnsignedEthTransaction as n}from"./wallet-api-eth-transaction.mjs";import{toWalletApiTypedData as
|
|
1
|
+
import{isHexEncoded as e,bytesToHex as t,utf8ToBytes as a}from"../../utils/encodings.mjs";import{rpc as s}from"../../wallet-api/rpc.mjs";import{toWalletApiUnsignedEthTransaction as n}from"./wallet-api-eth-transaction.mjs";import{toWalletApiTypedData as i}from"./wallet-api-eth-typed-data.mjs";import"@privy-io/routes";import"../../wallet-api/generate-authorization-signature.mjs";import"canonicalize";import"@privy-io/encoding";import"../../Error.mjs";import"../../wallet-api/types.mjs";async function r({context:r,account:o,rpcRequest:c}){switch(c.chainType){case"ethereum":return async function({context:r,account:o,rpcRequest:c}){switch(c.method){case"personal_sign":{let[e]=c.params,t=await s(r,r.signRequest,{chain_type:"ethereum",method:"personal_sign",wallet_id:o.id,params:e.startsWith("0x")?{message:e.slice(2),encoding:"hex"}:{message:e,encoding:"utf-8"}});if("personal_sign"!==t.method)throw Error("Unable to sign message");return{data:t.data.signature}}case"eth_signTransaction":{let[e]=c.params,t=await s(r,r.signRequest,{chain_type:"ethereum",method:"eth_signTransaction",wallet_id:o.id,params:{transaction:n(e)}});if("eth_signTransaction"!==t.method)throw Error("Unable to sign transaction");return{data:t.data.signed_transaction}}case"eth_signTypedData_v4":{let[,e]=c.params,t=await s(r,r.signRequest,{chain_type:"ethereum",method:c.method,wallet_id:o.id,params:{typed_data:i(e)}});if("eth_signTypedData_v4"!==t.method)throw Error("Unable to sign typed data");return{data:t.data.signature}}case"eth_sign":{let[,n]=c.params,i=await s(r,r.signRequest,{chain_type:"ethereum",method:"secp256k1_sign",wallet_id:o.id,params:{hash:e(n)?n:t(a(n))}});if("secp256k1_sign"!==i.method)throw Error("Unable to sign message");return{data:i.data.signature}}case"secp256k1_sign":{let[n]=c.params,i=await s(r,r.signRequest,{chain_type:"ethereum",method:"secp256k1_sign",wallet_id:o.id,params:{hash:e(n)?n:t(a(n))}});if("secp256k1_sign"!==i.method)throw Error("Unable to sign message");return{data:i.data.signature}}case"csw_signUserOperation":case"eth_sendTransaction":case"eth_populateTransactionRequest":throw Error(`This wallet does not support the method: ${c.method}`)}}({context:r,account:o,rpcRequest:c.request});case"solana":return async function({context:e,account:t,rpcRequest:a}){if("signMessage"===a.method){let{message:n}=a.params,i=await s(e,e.signRequest,{chain_type:"solana",method:"signMessage",wallet_id:t.id,params:{message:n,encoding:"base64"}});if("signMessage"!==i.method)throw Error("Unable to sign message");return{data:i.data.signature}}}({context:r,account:o,rpcRequest:c.request})}}export{r as walletRpc};
|
|
2
2
|
//# sourceMappingURL=walletRpc.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"walletRpc.mjs","sources":["../../../../src/embedded/stack/walletRpc.ts"],"names":["async","walletRpc","context","account","rpcRequest","chainType","method","message","params","response","walletApiRpc","signRequest","chain_type","wallet_id","id","startsWith","slice","encoding","Error","data","signature","transactionRequest","transaction","toWalletApiUnsignedEthTransaction","signed_transaction","typedData","typed_data","toWalletApiTypedData","hash","isHexEncoded","bytesToHex","utf8ToBytes","ethereumWalletRpc","request","messageBase64","solanaWalletRpc"],"mappings":"
|
|
1
|
+
{"version":3,"file":"walletRpc.mjs","sources":["../../../../src/embedded/stack/walletRpc.ts"],"names":["async","walletRpc","context","account","rpcRequest","chainType","method","message","params","response","walletApiRpc","signRequest","chain_type","wallet_id","id","startsWith","slice","encoding","Error","data","signature","transactionRequest","transaction","toWalletApiUnsignedEthTransaction","signed_transaction","typedData","typed_data","toWalletApiTypedData","hash","isHexEncoded","bytesToHex","utf8ToBytes","ethereumWalletRpc","request","messageBase64","solanaWalletRpc"],"mappings":"ueA+BOA,eAAeC,GACpBC,QAAAA,EACAC,QAAAA,EACAC,WAAAA,IAEA,OAAQA,EAAWC,WACjB,IAAK,WACH,OAYNL,gBACEE,QAAAA,EACAC,QAAAA,EACAC,WAAAA,IAEA,OAAQA,EAAWE,QACjB,IAAK,gBAAiB,CACpB,IAAOC,GAAWH,EAAWI,OACvBC,QAAiBC,EAAaR,EAASA,EAAQS,YAAa,CAChEC,WAAY,WACZN,OAAQ,gBACRO,UAAWV,EAAQW,GACnBN,OAAQD,EAAQQ,WAAW,MACvB,CAACR,QAASA,EAAQS,MAAM,GAAIC,SAAU,OACtC,CAACV,QAAAA,EAASU,SAAU,WAG1B,GAAIR,kBAAAA,EAASH,OACX,MAAMY,MAAU,0BAGlB,MAAO,CAACC,KAAMV,EAASU,KAAKC,UAC9B,CACA,IAAK,sBAAuB,CAC1B,IAAOC,GAAsBjB,EAAWI,OAElCC,QAAiBC,EAAaR,EAASA,EAAQS,YAAa,CAChEC,WAAY,WACZN,OAAQ,sBACRO,UAAWV,EAAQW,GACnBN,OAAQ,CAACc,YAAaC,EAAkCF,MAG1D,GAAwB,wBAApBZ,EAASH,OACX,MAAMY,MAAU,8BAGlB,MAAO,CAACC,KAAMV,EAASU,KAAKK,mBAC9B,CACA,IAAK,uBAAwB,CAC3B,IAAM,CAAGC,GAAarB,EAAWI,OAE3BC,QAAiBC,EAAaR,EAASA,EAAQS,YAAa,CAChEC,WAAY,WACZN,OAAQF,EAAWE,OACnBO,UAAWV,EAAQW,GACnBN,OAAQ,CAACkB,WAAYC,EAAqBF,MAG5C,GAAw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,EAASC,QAAAA,EAASC,WAAYA,EAAW6B,UAEvE"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"./client/Privy.mjs";export{LocalStorage}from"./storage/LocalStorage.mjs";export{InMemoryCache}from"./storage/InMemoryStorage.mjs";export{MoonpayApiError,PrivyApiError,PrivyClientError,createErrorFormatter,errorIndicatesMfaCanceled}from"./Error.mjs";export{EmbeddedProviderError,PrivyConnectorError,PrivyEmbeddedWalletErrorCode,PrivyProviderRpcError,ProviderErrors,errorIndicatesMaxMfaRetries,errorIndicatesMfaRateLimit,errorIndicatesMfaTimeout,errorIndicatesMfaVerificationFailed,errorIndicatesRecoveryIsNeeded}from"./embedded/errors.mjs";export{getUserEmbeddedEthereumWallet,getUserEmbeddedWallet}from"./utils/getUserEmbeddedEthereumWallet.mjs";export{getAllUserEmbeddedEthereumWallets}from"./utils/getAllUserEmbeddedEthereumWallets.mjs";export{getAllUserEmbeddedSolanaWallets}from"./utils/getAllUserEmbeddedSolanaWallets.mjs";export{getAllUserEmbeddedBitcoinWallets}from"./utils/getAllUserEmbeddedBitcoinWallets.mjs";export{isEmbeddedWalletAccount}from"./utils/embedded-wallets.mjs";export{getEntropyDetailsFromAccount,getEntropyDetailsFromUser}from"./utils/entropy.mjs";export{getUserSmartWallet}from"./utils/getUserSmartWallet.mjs";export{getJsonRpcEndpointFromChain,throwIfInvalidRecoveryUpgradePath}from"./embedded/utils/index.mjs";export{countryCodesAndNumbers,formatPhoneNumber,getPhoneCountryCodeAndNumber,getPlaceholderPhoneNumber,lastFourDigits,phoneNumberTypingFormatter,validatePhoneNumber}from"./utils/phoneNumberUtils.mjs";export{getUserEmbeddedSolanaWallet}from"./utils/getUserEmbeddedSolanaWallet.mjs";export{toObjectKeys}from"./utils/toObjectKeys.mjs";export{SolanaUsdcAddressMap,UsdcAddressMap,getIsTokenUsdc}from"./utils/getIsTokenUsdc.mjs";export{generateWalletIdempotencyKey}from"./utils/generateWalletIdempotencyKey.mjs";export{chainToMoonpayCurrency,fundingMethodToMoonpayPaymentMethod,isSupportedChainIdForMoonpay}from"./funding/moonpay.mjs";export{getCoinbaseOnRampUrl,isSupportedChainIdForCoinbaseOnramp,toCoinbaseAssetId,toCoinbaseBlockchainFromChainId}from"./funding/coinbase.mjs";export{SolanaClient}from"./solana/client.mjs";export{createSiwsMessage}from"./solana/createSiwsMessage.mjs";export{getSolanaRpcEndpointForCluster}from"./solana/getSolanaRpcEndpointForCluster.mjs";export{getSolanaUsdcMintAddressForCluster}from"./solana/getSolanaUsdcMintAddressForCluster.mjs";export{getSolanaClusterDisplayName}from"./solana/getSolanaClusterDisplayName.mjs";export{ALL_WALLET_CLIENT_TYPES,SUPPORTED_CONNECTOR_TYPES}from"./types.mjs";export*from"@privy-io/chains";export{formatLamportsAmount,formatTokenAmount,formatWalletAddress,formatWeiAmount}from"./utils/formatters.mjs";export{generateAuthorizationSignature}from"./wallet-api/generate-authorization-signature.mjs";export{create}from"./wallet-api/create.mjs";export{rpc}from"./wallet-api/rpc.mjs";export{rawSign}from"./wallet-api/raw-sign.mjs";export{getWallet}from"./wallet-api/get-wallet.mjs";export{updateWallet}from"./wallet-api/update-wallet.mjs";export{isUnifiedWallet}from"./wallet-api/unified-wallet.mjs";export{addSessionSigners,removeSessionSigners}from"./embedded/stack/session-signers.mjs";export{ConnectedStandardSolanaWallet}from"./solana/ConnectedStandardSolanaWallet.mjs";export{i as crossApp}from"./index-Bu3ySxLM.mjs";export{i as delegatedActions}from"./index-g0cxoRWQ.mjs";export{getCountryCallingCode}from"libphonenumber-js/min";import"./client/AppApi.mjs";import"@privy-io/routes";import"./client/CrossAppApi.mjs";import"./Token.mjs";import"jose";import"./client/DelegatedWalletsApi.mjs";import"./client/EmbeddedWalletApi.mjs";import"./embedded/EmbeddedBitcoinWalletProvider.mjs";import"./embedded/stack/walletCreate.mjs";import"./embedded/EmbeddedWalletProxy.mjs";import"./utils/sleep.mjs";import"./embedded/EventCallbackQueue.mjs";import"./embedded/withMfa.mjs";import"./embedded/EmbeddedWalletProvider.mjs";import"eventemitter3";import"viem";import"@privy-io/ethereum";import"./embedded/stack/walletRpc.mjs";import"./utils/encodings.mjs";import"./embedded/stack/wallet-api-eth-transaction.mjs";import"./embedded/stack/wallet-api-eth-typed-data.mjs";import"./embedded/EmbeddedSolanaWalletProvider.mjs";import"./solana/getWalletPublicKeyFromTransaction.mjs";import"./solana/isVersionedTransaction.mjs";import"./client/MfaPromises.mjs";import"./client/PrivyInternal.mjs";import"fetch-retry";import"uuid";import"@privy-io/api-base";import"./Session.mjs";import"js-cookie";import"./utils/allSettled.mjs";import"./toAbortSignalTimeout.mjs";import"./utils/toSearchParams.mjs";import"./client/logger.mjs";import"./utils/noop.mjs";import"./client/UserApi.mjs";import"./client/auth/AuthApi.mjs";import"./client/auth/CustomProviderApi.mjs";import"./client/auth/maybeCreateWalletOnLogin.mjs";import"./utils/shouldCreateEmbeddedEthWallet.mjs";import"./utils/shouldCreateEmbeddedSolWallet.mjs";import"./client/auth/EmailApi.mjs";import"./client/auth/FarcasterApi.mjs";import"./client/auth/FarcasterV2Api.mjs";import"./client/auth/GuestApi.mjs";import"./client/auth/OAuthApi.mjs";import"./pkce.mjs";import"./client/auth/PasskeyApi.mjs";import"./client/auth/PhoneApi.mjs";import"./client/auth/SiweApi.mjs";import"./client/auth/SiwsApi.mjs";import"./client/auth/SmartWalletApi.mjs";import"./client/funding/FundingApi.mjs";import"./client/funding/CoinbaseOnRampApi.mjs";import"./client/funding/MoonpayOnRampApi.mjs";import"./client/mfa/MfaApi.mjs";import"./client/mfa/MfaPasskeyApi.mjs";import"./client/mfa/MfaSmsApi.mjs";import"./client/recovery/RecoveryApi.mjs";import"./client/recovery/RecoveryICloudApi.mjs";import"./client/recovery/RecoveryOAuthApi.mjs";import"./embedded/types.mjs";import"libphonenumber-js/examples.mobile.json";import"canonicalize";import"./wallet-api/types.mjs";import"./action/delegatedActions/utils.mjs";import"./action/crossApp/loginWithCrossAppAuth.mjs";import"./action/crossApp/linkWithCrossAppAuth.mjs";import"./index-DTAjYY8z.mjs";import"./action/crossApp/wallet/signMessage.mjs";import"./action/crossApp/wallet/utils/isCrossAppWalletSmart.mjs";import"./action/crossApp/wallet/utils/sendCrossAppRequest.mjs";import"./action/crossApp/wallet/utils/getCrossAppAccountByWalletAddress.mjs";import"./action/crossApp/wallet/utils/getProviderAccessTokenOrRelink.mjs";import"./action/crossApp/wallet/utils/throwIfNotLoggedIn.mjs";import"./action/crossApp/wallet/signTypedData.mjs";import"./utils/typedData/generateDomainType.mjs";import"./action/crossApp/wallet/sendTransaction.mjs";import"./action/delegatedActions/delegateWallet.mjs";import"./action/delegatedActions/revokeWallets.mjs";const t="biconomy",r="coinbase_smart_wallet",o="kernel",s="light_account",m="safe",a="thirdweb";export{t as BICONOMY,r as COINBASE_SMART_WALLET,o as KERNEL,s as LIGHT_ACCOUNT,m as SAFE,a as THIRDWEB,e as default};
|
|
1
|
+
import e from"./client/Privy.mjs";export{LocalStorage}from"./storage/LocalStorage.mjs";export{InMemoryCache}from"./storage/InMemoryStorage.mjs";export{MoonpayApiError,PrivyApiError,PrivyClientError,createErrorFormatter,errorIndicatesMfaCanceled}from"./Error.mjs";export{EmbeddedProviderError,PrivyConnectorError,PrivyEmbeddedWalletErrorCode,PrivyProviderRpcError,ProviderErrors,errorIndicatesMaxMfaRetries,errorIndicatesMfaRateLimit,errorIndicatesMfaTimeout,errorIndicatesMfaVerificationFailed,errorIndicatesRecoveryIsNeeded}from"./embedded/errors.mjs";export{getUserEmbeddedEthereumWallet,getUserEmbeddedWallet}from"./utils/getUserEmbeddedEthereumWallet.mjs";export{getAllUserEmbeddedEthereumWallets}from"./utils/getAllUserEmbeddedEthereumWallets.mjs";export{getAllUserEmbeddedSolanaWallets}from"./utils/getAllUserEmbeddedSolanaWallets.mjs";export{getAllUserEmbeddedBitcoinWallets}from"./utils/getAllUserEmbeddedBitcoinWallets.mjs";export{isEmbeddedWalletAccount}from"./utils/embedded-wallets.mjs";export{getEntropyDetailsFromAccount,getEntropyDetailsFromUser}from"./utils/entropy.mjs";export{getUserSmartWallet}from"./utils/getUserSmartWallet.mjs";export{getJsonRpcEndpointFromChain,throwIfInvalidRecoveryUpgradePath}from"./embedded/utils/index.mjs";export{countryCodesAndNumbers,formatPhoneNumber,getPhoneCountryCodeAndNumber,getPlaceholderPhoneNumber,lastFourDigits,phoneNumberTypingFormatter,validatePhoneNumber}from"./utils/phoneNumberUtils.mjs";export{getUserEmbeddedSolanaWallet}from"./utils/getUserEmbeddedSolanaWallet.mjs";export{toObjectKeys}from"./utils/toObjectKeys.mjs";export{SolanaUsdcAddressMap,UsdcAddressMap,getIsTokenUsdc}from"./utils/getIsTokenUsdc.mjs";export{generateWalletIdempotencyKey}from"./utils/generateWalletIdempotencyKey.mjs";export{chainToMoonpayCurrency,fundingMethodToMoonpayPaymentMethod,isSupportedChainIdForMoonpay}from"./funding/moonpay.mjs";export{getCoinbaseOnRampUrl,isSupportedChainIdForCoinbaseOnramp,toCoinbaseAssetId,toCoinbaseBlockchainFromChainId}from"./funding/coinbase.mjs";export{SolanaClient}from"./solana/client.mjs";export{createSiwsMessage}from"./solana/createSiwsMessage.mjs";export{getSolanaRpcEndpointForCluster}from"./solana/getSolanaRpcEndpointForCluster.mjs";export{getSolanaUsdcMintAddressForCluster}from"./solana/getSolanaUsdcMintAddressForCluster.mjs";export{getSolanaClusterDisplayName}from"./solana/getSolanaClusterDisplayName.mjs";export{ALL_WALLET_CLIENT_TYPES,SUPPORTED_CONNECTOR_TYPES}from"./types.mjs";export*from"@privy-io/chains";export{formatLamportsAmount,formatTokenAmount,formatWalletAddress,formatWeiAmount}from"./utils/formatters.mjs";export{generateAuthorizationSignature}from"./wallet-api/generate-authorization-signature.mjs";export{create}from"./wallet-api/create.mjs";export{rpc}from"./wallet-api/rpc.mjs";export{rawSign}from"./wallet-api/raw-sign.mjs";export{getWallet}from"./wallet-api/get-wallet.mjs";export{updateWallet}from"./wallet-api/update-wallet.mjs";export{isUnifiedWallet}from"./wallet-api/unified-wallet.mjs";export{addSessionSigners,removeSessionSigners}from"./embedded/stack/session-signers.mjs";export{ConnectedStandardSolanaWallet}from"./solana/ConnectedStandardSolanaWallet.mjs";export{i as crossApp}from"./index-Bu3ySxLM.mjs";export{i as delegatedActions}from"./index-g0cxoRWQ.mjs";export{getCountryCallingCode}from"libphonenumber-js/min";import"./client/AppApi.mjs";import"@privy-io/routes";import"./client/CrossAppApi.mjs";import"./Token.mjs";import"jose";import"./client/DelegatedWalletsApi.mjs";import"./client/EmbeddedWalletApi.mjs";import"./embedded/EmbeddedBitcoinWalletProvider.mjs";import"./embedded/stack/walletCreate.mjs";import"./embedded/EmbeddedWalletProxy.mjs";import"./utils/sleep.mjs";import"./embedded/EventCallbackQueue.mjs";import"./embedded/withMfa.mjs";import"./embedded/EmbeddedWalletProvider.mjs";import"eventemitter3";import"viem";import"@privy-io/ethereum";import"./embedded/stack/walletRpc.mjs";import"./utils/encodings.mjs";import"./embedded/stack/wallet-api-eth-transaction.mjs";import"./embedded/stack/wallet-api-eth-typed-data.mjs";import"./embedded/EmbeddedSolanaWalletProvider.mjs";import"./solana/getWalletPublicKeyFromTransaction.mjs";import"./solana/isVersionedTransaction.mjs";import"./client/MfaPromises.mjs";import"./client/PrivyInternal.mjs";import"fetch-retry";import"uuid";import"@privy-io/api-base";import"./Session.mjs";import"js-cookie";import"./utils/allSettled.mjs";import"./toAbortSignalTimeout.mjs";import"./utils/toSearchParams.mjs";import"./client/logger.mjs";import"./utils/noop.mjs";import"./client/UserApi.mjs";import"./client/auth/AuthApi.mjs";import"./client/auth/CustomProviderApi.mjs";import"./client/auth/maybeCreateWalletOnLogin.mjs";import"./utils/shouldCreateEmbeddedEthWallet.mjs";import"./utils/shouldCreateEmbeddedSolWallet.mjs";import"./client/auth/EmailApi.mjs";import"./client/auth/FarcasterApi.mjs";import"./client/auth/FarcasterV2Api.mjs";import"./client/auth/GuestApi.mjs";import"./client/auth/OAuthApi.mjs";import"./pkce.mjs";import"./client/auth/PasskeyApi.mjs";import"./client/auth/PhoneApi.mjs";import"./client/auth/SiweApi.mjs";import"./client/auth/SiwsApi.mjs";import"./client/auth/SmartWalletApi.mjs";import"./client/funding/FundingApi.mjs";import"./client/funding/CoinbaseOnRampApi.mjs";import"./client/funding/MoonpayOnRampApi.mjs";import"./client/mfa/MfaApi.mjs";import"./client/mfa/MfaPasskeyApi.mjs";import"./client/mfa/MfaSmsApi.mjs";import"./client/recovery/RecoveryApi.mjs";import"./client/recovery/RecoveryICloudApi.mjs";import"./client/recovery/RecoveryOAuthApi.mjs";import"./embedded/types.mjs";import"libphonenumber-js/examples.mobile.json";import"canonicalize";import"@privy-io/encoding";import"./wallet-api/types.mjs";import"./action/delegatedActions/utils.mjs";import"./action/crossApp/loginWithCrossAppAuth.mjs";import"./action/crossApp/linkWithCrossAppAuth.mjs";import"./index-DTAjYY8z.mjs";import"./action/crossApp/wallet/signMessage.mjs";import"./action/crossApp/wallet/utils/isCrossAppWalletSmart.mjs";import"./action/crossApp/wallet/utils/sendCrossAppRequest.mjs";import"./action/crossApp/wallet/utils/getCrossAppAccountByWalletAddress.mjs";import"./action/crossApp/wallet/utils/getProviderAccessTokenOrRelink.mjs";import"./action/crossApp/wallet/utils/throwIfNotLoggedIn.mjs";import"./action/crossApp/wallet/signTypedData.mjs";import"./utils/typedData/generateDomainType.mjs";import"./action/crossApp/wallet/sendTransaction.mjs";import"./action/delegatedActions/delegateWallet.mjs";import"./action/delegatedActions/revokeWallets.mjs";const t="biconomy",r="coinbase_smart_wallet",o="kernel",s="light_account",m="safe",a="thirdweb";export{t as BICONOMY,r as COINBASE_SMART_WALLET,o as KERNEL,s as LIGHT_ACCOUNT,m as SAFE,a as THIRDWEB,e as default};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/index.ts"],"names":["BICONOMY","COINBASE_SMART_WALLET","KERNEL","LIGHT_ACCOUNT","SAFE","THIRDWEB"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/index.ts"],"names":["BICONOMY","COINBASE_SMART_WALLET","KERNEL","LIGHT_ACCOUNT","SAFE","THIRDWEB"],"mappings":"y4MAcO,MAAMA,EAAW,WAEXC,EAAwB,wBAExBC,EAAS,SAETC,EAAgB,gBAEhBC,EAAO,OAEPC,EAAW"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import e from"canonicalize";import{encoding as r}from"@privy-io/encoding";import{PrivyClientError as i}from"../Error.mjs";async function o(o,t){let n;if(t instanceof Uint8Array)n=r.base64.fromBytes(t);else{let o=e(t);if(void 0===o)throw new i({error:"Failed to prepare the payload for signing",code:"invalid_input"});n=r.base64.fromBytes(r.utf8.toBytes(o))}let{signature:a}=await o({message:n});return{signature:a}}export{o as generateAuthorizationSignature};
|
|
2
2
|
//# sourceMappingURL=generate-authorization-signature.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-authorization-signature.mjs","sources":["../../../src/wallet-api/generate-authorization-signature.ts"],"names":["async","generateAuthorizationSignature","sign","payload","
|
|
1
|
+
{"version":3,"file":"generate-authorization-signature.mjs","sources":["../../../src/wallet-api/generate-authorization-signature.ts"],"names":["async","generateAuthorizationSignature","sign","payload","message","Uint8Array","encoding","base64","fromBytes","canonicalJson","canonicalize","PrivyClientError","error","code","utf8","toBytes","signature"],"mappings":"0HAqCOA,eAAeC,EACpBC,EACAC,GAAyD,IAErDC,EACJ,GAAID,aAAmBE,WACrBD,EAAUE,EAASC,OAAOC,UAAUL,OAC/B,CACL,IAAMM,EAAgBC,EAAaP,GACnC,QAAIM,IAAAA,EACF,MAAM,IAAIE,EAAiB,CACzBC,MAAO,4CACPC,KAAM,kBAGVT,EAAUE,EAASC,OAAOC,UAAUF,EAASQ,KAAKC,QAAQN,GAC5D,CAEA,IAAOO,UAAAA,SAAmBd,EAAK,CAACE,QAAAA,IAEhC,MAAO,CAACY,UAAAA,EACV"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{WalletRawSign as r}from"@privy-io/routes";import{generateAuthorizationSignature as
|
|
1
|
+
import{WalletRawSign as r}from"@privy-io/routes";import{generateAuthorizationSignature as i}from"./generate-authorization-signature.mjs";import{PRIVY_REQUEST_EXPIRY_HEADER_NAME as t,DEFAULT_EXPIRY_TIME_MS as a}from"./types.mjs";import"canonicalize";import"@privy-io/encoding";import"../Error.mjs";async function o(o,e,{wallet_id:p,...m}){let n=o.getCompiledPath(r,{params:{wallet_id:p}}),s=String(Date.now()+a),d={version:1,url:n,method:r.method,headers:{"privy-app-id":o.app.appId,[t]:s},body:{...m}},{signature:l}=await i(e,d);return await o.fetchPrivyRoute(r,{body:m,params:{wallet_id:p},headers:{"privy-authorization-signature":l,[t]:s}})}export{o as rawSign};
|
|
2
2
|
//# sourceMappingURL=raw-sign.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"raw-sign.mjs","sources":["../../../src/wallet-api/raw-sign.ts"],"names":["async","rawSign","context","sign","wallet_id","request","url","getCompiledPath","WalletRawSign","params","requestExpiry","String","Date","now","DEFAULT_EXPIRY_TIME_MS","payload","version","method","headers","app","appId","PRIVY_REQUEST_EXPIRY_HEADER_NAME","body","signature","generateAuthorizationSignature","fetchPrivyRoute"],"mappings":"
|
|
1
|
+
{"version":3,"file":"raw-sign.mjs","sources":["../../../src/wallet-api/raw-sign.ts"],"names":["async","rawSign","context","sign","wallet_id","request","url","getCompiledPath","WalletRawSign","params","requestExpiry","String","Date","now","DEFAULT_EXPIRY_TIME_MS","payload","version","method","headers","app","appId","PRIVY_REQUEST_EXPIRY_HEADER_NAME","body","signature","generateAuthorizationSignature","fetchPrivyRoute"],"mappings":"ySAuBOA,eAAeC,EACpBC,EACAC,GACCC,UAAAA,KAAcC,IAEf,IAAMC,EAAMJ,EAAQK,gBAAgBC,EAAe,CAACC,OAAQ,CAACL,UAAAA,KAEvDM,EAAgBC,OAAOC,KAAKC,MAAQC,GAEpCC,EAAU,CACdC,QAAS,EACTV,IAAAA,EACAW,OAAQT,EAAcS,OACtBC,QAAS,CACP,eAAgBhB,EAAQiB,IAAIC,MAC5BC,CAACA,GAAmCX,GAEtCY,KAAM,IACDjB,KAIAkB,UAAAA,SAAmBC,EAA+BrB,EAAMY,GAE/D,aAAab,EAAQuB,gBAAgBjB,EAAe,CAClDc,KAAMjB,EACNI,OAAQ,CAACL,UAAWA,GACpBc,QAAS,CACP,gCAAiCK,EACjCF,CAACA,GAAmCX,IAG1C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{WalletRpc as r}from"@privy-io/routes";import{generateAuthorizationSignature as
|
|
1
|
+
import{WalletRpc as r}from"@privy-io/routes";import{generateAuthorizationSignature as i}from"./generate-authorization-signature.mjs";import{PRIVY_REQUEST_EXPIRY_HEADER_NAME as t,DEFAULT_EXPIRY_TIME_MS as a}from"./types.mjs";import"canonicalize";import"@privy-io/encoding";import"../Error.mjs";async function o(o,e,{wallet_id:p,...m}){let n=o.getCompiledPath(r,{params:{wallet_id:p}}),s=String(Date.now()+a),d={version:1,url:n,method:r.method,headers:{"privy-app-id":o.app.appId,[t]:s},body:{...m}},{signature:l}=await i(e,d);return await o.fetchPrivyRoute(r,{body:m,params:{wallet_id:p},headers:{"privy-authorization-signature":l,[t]:s}})}export{o as rpc};
|
|
2
2
|
//# sourceMappingURL=rpc.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc.mjs","sources":["../../../src/wallet-api/rpc.ts"],"names":["async","rpc","context","sign","wallet_id","request","url","getCompiledPath","WalletRpc","params","requestExpiry","String","Date","now","DEFAULT_EXPIRY_TIME_MS","payload","version","method","headers","app","appId","PRIVY_REQUEST_EXPIRY_HEADER_NAME","body","signature","generateAuthorizationSignature","fetchPrivyRoute"],"mappings":"
|
|
1
|
+
{"version":3,"file":"rpc.mjs","sources":["../../../src/wallet-api/rpc.ts"],"names":["async","rpc","context","sign","wallet_id","request","url","getCompiledPath","WalletRpc","params","requestExpiry","String","Date","now","DEFAULT_EXPIRY_TIME_MS","payload","version","method","headers","app","appId","PRIVY_REQUEST_EXPIRY_HEADER_NAME","body","signature","generateAuthorizationSignature","fetchPrivyRoute"],"mappings":"qSAoBOA,eAAeC,EACpBC,EACAC,GACCC,UAAAA,KAAcC,IAGf,IAAMC,EAAMJ,EAAQK,gBAAgBC,EAAW,CAACC,OAAQ,CAACL,UAAAA,KAEnDM,EAAgBC,OAAOC,KAAKC,MAAQC,GAEpCC,EAAU,CACdC,QAAS,EACTV,IAAAA,EACAW,OAAQT,EAAUS,OAClBC,QAAS,CACP,eAAgBhB,EAAQiB,IAAIC,MAC5BC,CAACA,GAAmCX,GAEtCY,KAAM,IACDjB,KAIAkB,UAAAA,SAAmBC,EAA+BrB,EAAMY,GAE/D,aAAab,EAAQuB,gBAAgBjB,EAAW,CAC9Cc,KAAMjB,EACNI,OAAQ,CACNL,UAAWA,GAEbc,QAAS,CACP,gCAAiCK,EACjCF,CAACA,GAAmCX,IAG1C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{WalletUpdate as
|
|
1
|
+
import{WalletUpdate as i}from"@privy-io/routes";import{generateAuthorizationSignature as r}from"./generate-authorization-signature.mjs";import"canonicalize";import"@privy-io/encoding";import"../Error.mjs";async function t(t,{wallet_id:a},e,o){let p={version:1,url:t.getCompiledPath(i,{params:{wallet_id:a}}),method:i.method,headers:{"privy-app-id":t.app.appId},body:o},{signature:n}=await r(e,p);return await t.fetchPrivyRoute(i,{params:{wallet_id:a},body:o,headers:{"privy-authorization-signature":n}})}export{t as updateWallet};
|
|
2
2
|
//# sourceMappingURL=update-wallet.mjs.map
|