@privy-io/expo 0.78.0 → 0.78.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cards.js +2 -2
- package/dist/{chunk-CN53OAQW.js → chunk-DBIA42HB.js} +1 -1
- package/dist/{chunk-B42N35ZL.js → chunk-QAUM76HK.js} +1 -1
- package/dist/chunk-V3WU67WL.js +12 -0
- package/dist/esm/cards.js +1 -1
- package/dist/esm/{chunk-CN53OAQW.js → chunk-DBIA42HB.js} +1 -1
- package/dist/esm/{chunk-B42N35ZL.js → chunk-QAUM76HK.js} +1 -1
- package/dist/esm/chunk-V3WU67WL.js +12 -0
- package/dist/esm/extended-chains.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/passkey.js +1 -1
- package/dist/esm/smart-wallets.js +1 -1
- package/dist/esm/ui.js +1 -1
- package/dist/extended-chains.js +1 -1
- package/dist/index.d.ts +34 -30
- package/dist/index.js +1 -1
- package/dist/passkey.js +1 -1
- package/dist/smart-wallets.js +1 -1
- package/dist/ui.d.ts +3 -3
- package/dist/ui.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-6LJTXHKE.js +0 -12
- package/dist/esm/chunk-6LJTXHKE.js +0 -12
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import{a as St,b as Et,c as Ee}from"./chunk-F7DR7TVR.js";import{a as Ct}from"./chunk-3HF374LL.js";import{a as Se,b as _,c as T,e as l}from"./chunk-C5WYSLQF.js";import{useEffect as io}from"react";import{create as ao}from"zustand";var _t=ao(()=>({status:"disconnected"})),Ce=()=>_t.getState().onNeedsRecovery,so=e=>{io(()=>{_t.setState({onNeedsRecovery:e==null?void 0:e.onNeedsRecovery})},[e==null?void 0:e.onNeedsRecovery])};import lo from"@privy-io/js-sdk-core";var kt={name:"@privy-io/expo",version:"0.78.2",description:"Expo client for the Privy Auth API",keywords:["authentication","authorization","identity","privacy","privy","user data","react-native","expo","web3"],homepage:"https://docs.privy.io",bugs:{url:"https://privy.io/slack"},license:"Apache-2.0",author:"privy.io",exports:{".":{require:"./dist/index.js",import:"./dist/esm/index.js",types:"./dist/index.d.ts"},"./passkey":{require:"./dist/passkey.js",import:"./dist/esm/passkey.js",types:"./dist/passkey.d.ts"},"./smart-wallets":{require:"./dist/smart-wallets.js",import:"./dist/esm/smart-wallets.js",types:"./dist/smart-wallets.d.ts"},"./extended-chains":{require:"./dist/extended-chains.js",import:"./dist/esm/extended-chains.js",types:"./dist/extended-chains.d.ts"},"./ui":{require:"./dist/ui.js",import:"./dist/esm/ui.js",types:"./dist/ui.d.ts"},"./cards":{require:"./dist/cards.js",import:"./dist/esm/cards.js",types:"./dist/cards.d.ts"},"./connectors":{require:"./dist/connectors.js",import:"./dist/esm/connectors.js",types:"./dist/connectors.d.ts"},"./polyfills":{require:"./dist/polyfills.js",import:"./dist/esm/polyfills.js",types:"./dist/polyfills.d.ts"}},main:"./dist/esm/index.js",source:"./src/index.ts",types:"./dist/index.d.ts",files:["dist/**/*","LICENSE","README.md"],scripts:{build:"tsup --clean --minify","check-types":"tsc --noEmit",clean:"rm -rf dist .turbo *.tsbuildinfo","clean:reset":"rm -rf dist .turbo node_modules *.tsbuildinfo",dev:"tsup --watch",format:"oxlint src --fix","generate-types":"tsup --dts-only",lint:"oxlint src",test:"jest"},browserslist:["defaults","node >= 18","not op_mini all"],dependencies:{"@noble/curves":"catalog:","@privy-io/api-types":"catalog:","@privy-io/are-addresses-equal":"workspace:*","@privy-io/encoding":"workspace:*","@privy-io/js-sdk-core":"workspace:*","@privy-io/routes":"workspace:*","@scure/base":"^1.2.4","react-fast-compare":"^3.2.2",tweetnacl:"catalog:",zustand:"catalog:"},devDependencies:{oxlint:"catalog:package-new","oxlint-tsgolint":"catalog:package-new","@faker-js/faker":"catalog:","@hpke/chacha20poly1305":"catalog:","@hpke/core":"catalog:","@privy-io/eslint-plugin-privy-rules":"workspace:*","@privy-io/tsconfig":"workspace:*","@simplewebauthn/types":"9.0.1","@solana/web3.js":"catalog:","@svgr/core":"^8.1.0","@svgr/plugin-jsx":"^8.1.0","@svgr/plugin-svgo":"^8.1.0","@testing-library/react-native":"^13.1.0","@tsconfig/node16-strictest-esm":"catalog:","@types/jest":"catalog:","@types/react":"catalog:",expo:"57.0.28","expo-apple-authentication":"57.0.2","expo-application":"57.0.3","expo-clipboard":"57.0.2","expo-linking":"57.0.12","expo-secure-store":"57.0.4","expo-web-browser":"57.0.3",jest:"catalog:","jest-expo":"57.0.6","lucide-react-native":"^0.474.0",react:"catalog:","react-native":"0.86.3","react-native-nitro-modules":"catalog:","react-native-quick-base64":"catalog:","react-native-quick-crypto":"catalog:","react-native-webview":"13.16.1","react-test-renderer":"19.2.3",tsup:"^6.2.3",typescript:"catalog:"},peerDependencies:{"@privy-io/expo-native-extensions":"workspace:*","expo-apple-authentication":"*","expo-application":"*","expo-clipboard":"*","expo-linking":"*","expo-secure-store":"*","expo-web-browser":"*",permissionless:"^0.2.47",react:"*","react-native":"*","react-native-passkeys":"catalog:","react-native-qrcode-styled":"0.3.3","react-native-quick-crypto":"^1.0.0","react-native-safe-area-context":"*","react-native-svg":"*","react-native-webview":"*",viem:"^2.57.8"},peerDependenciesMeta:{permissionless:{optional:!0},viem:{optional:!0},"react-native-svg":{optional:!0},"expo-apple-authentication":{optional:!0},"expo-clipboard":{optional:!0},"expo-linking":{optional:!0},"expo-secure-store":{optional:!0},"expo-web-browser":{optional:!0},"react-native-qrcode-styled":{optional:!0},"react-native-safe-area-context":{optional:!0}},publishConfig:{access:"public"}};var Wt=({appId:e,clientId:t,storage:n=Ee,supportedChains:r,baseUrl:i,logLevel:a,logger:o,sessions:s,plugins:d})=>{Ct();let c=s!=null&&s.mode?{mode:s.mode}:void 0;return new lo({appId:e,clientId:t,plugins:d,supportedChains:r,storage:Et(n),sdkVersion:`expo:${kt.version}`,nativeAppIdentifier:St(),baseUrl:i,logLevel:a,logger:o,sessions:c})};import{useCallback as ft,useContext as Ya}from"react";import{PrivyClientError as Xa}from"@privy-io/js-sdk-core";import re,{useState as D,useMemo as Ba,createContext as Ha,useCallback as Ne,useRef as he,useEffect as Jr,useContext as Ja}from"react";import{AppState as $r,View as $a}from"react-native";import{PrivyClientError as Qr}from"@privy-io/js-sdk-core";import uo from"react-fast-compare";import{create as po}from"zustand";var _e=po(()=>{}),At=e=>_e.setState(t=>uo(t,e)?t:e),x=_e.getState;import go from"react";import{useCallback as K,useEffect as Ft,useRef as ae,useState as ho}from"react";import{AppState as wo}from"react-native";import vo from"react-native-webview";import*as V from"expo-secure-store";function xt(e){return typeof e!="object"||e===null||!("event"in e&&typeof e.event=="string")||!("id"in e&&typeof e.id=="string")||!("data"in e&&typeof e.data=="object")||e.data===null?!1:e.event.startsWith("app:secure-storage:")}function Pt(e){return l(this,null,function*(){switch(e.event){case"app:secure-storage:get":{let{key:t}=e.data,n=yield V.getItemAsync(ze(t),{keychainAccessible:V.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY}).catch(r=>(console.warn("Failed to get the value from secure store",r),null));return{event:e.event,id:e.id,data:{value:n}}}case"app:secure-storage:remove":{let{key:t}=e.data,n=yield V.deleteItemAsync(ze(t),{keychainAccessible:V.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY}).then(()=>!0).catch(r=>(console.warn("Failed to remove the value from secure store",r),!1));return{event:e.event,id:e.id,data:{success:n}}}case"app:secure-storage:set":{let{key:t,value:n}=e.data,r=yield V.setItemAsync(ze(t),n,{keychainAccessible:V.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY}).then(()=>!0).catch(i=>(console.warn("Failed to write the value to secure store",i),!1));return{event:e.event,id:e.id,data:{success:r}}}}})}var ze=e=>e.replaceAll(":","-");import mo from"react-fast-compare";import{createStore as yo,useStore as ke}from"zustand";import{PrivyClientError as fo}from"@privy-io/js-sdk-core";var O=yo()(()=>({user:null,storedUsers:[],proxyStatus:"loading"})),Ut=e=>Mt("onMfaEnrollmentRequired",e),Rt=e=>Mt("onMfaVerificationRequired",e),R=()=>{var e,t;return(t=(e=O.getState().onMfaEnrollmentRequired)==null?void 0:e.fn)!=null?t:Lt},I=()=>{var e,t;return(t=(e=O.getState().onMfaVerificationRequired)==null?void 0:e.fn)!=null?t:Lt};function S(){return O.getState().user}var gs=O.subscribe.bind(O);function Ge(e){O.setState(({user:t})=>mo(t,e)?{}:{user:e})}var It=e=>O.setState({storedUsers:e.users}),ie=e=>O.setState({proxyStatus:e});function U(){return ke(O,e=>e.user)}function hs(){return ke(O,e=>!!e.user)}function Ot(){return ke(O,e=>e.storedUsers)}function z(){return ke(O,e=>e.proxyStatus!=="loading")}var Mt=(e,t)=>(O.setState(n=>{let r=n[e];if(r&&r.lock!==t.lock)throw new fo({code:"configuration_error",error:`An MFA handler for ${e} is already registered. Use one hook instance per handler kind, or disable the built-in MFA verification UI.`});return{[e]:t}}),()=>{O.setState(n=>n[e]===t?{[e]:void 0}:{})}),Lt=e=>l(void 0,null,function*(){throw e.error});var bo={shouldUseAppBackedStorage:!0},So=";",Eo=500,Co=(e,t)=>{if(!e)return!1;try{return new URL(e).origin===new URL(t).origin}catch(n){return!1}},_o=1e3,ko=6e4,Tt=({client:e,isClientReady:t})=>{let n=ae(null),[r,i]=ho(0),a=ae(0),o=ae(void 0),s=ae(0),d=ae(void 0);Ft(()=>()=>clearTimeout(d.current),[]);let c=K(y=>{e.logger.info(`[privy:webview] recreating, ${y}`),clearTimeout(d.current),a.current+=1,ie("reloading"),e.embeddedWallet.reload(),i(f=>f+1)},[e]);Ft(()=>{let y=wo.addEventListener("change",f=>l(void 0,null,function*(){var b;if(f==="background")o.current=a.current,e.embeddedWallet.onBackground();else if(f==="active"){let E=(b=o.current)!=null?b:a.current;o.current=void 0,!(yield e.embeddedWallet.ping(Eo))&&a.current===E&&(ie("reloading"),e.embeddedWallet.reload())}}));return()=>y.remove()},[e]);let u=K(y=>l(void 0,null,function*(){var E;if(!Co(y.nativeEvent.url,e.embeddedWallet.getURL()))return;let{data:f}=y.nativeEvent,b=JSON.parse(f);if(s.current=0,xt(b)){let W=yield Pt(b);(E=n.current)==null||E.postMessage(JSON.stringify(W));return}e.embeddedWallet.onMessage(b)}),[e]),p=K(()=>{clearTimeout(d.current),ie("loaded")},[]),m=K(()=>{e.logger.info("[privy:webview] reloading, load failed"),ie("reloading"),e.embeddedWallet.reload()},[e]),w=K(y=>{let f=Math.min(_o*Se(2,s.current),ko);s.current+=1,e.logger.warn(`[privy:webview] load failed (${y.nativeEvent.code}: ${y.nativeEvent.description}), retrying in ${f}ms`),clearTimeout(d.current),d.current=setTimeout(m,f)},[e,m]),v=K(()=>{c("content process terminated")},[c]),h=K(()=>{c("render process gone")},[c]);return t?go.createElement(vo,{key:r,style:{flex:1},ref:y=>{y&&(e.setMessagePoster(y),n.current=y)},cacheEnabled:!1,cacheMode:"LOAD_NO_CACHE",injectedJavaScriptObject:bo,injectedJavaScriptBeforeContentLoaded:So,source:{uri:e.embeddedWallet.getURL()},webviewDebuggingEnabled:e.logger.level==="DEBUG",onLoad:p,onError:w,onMessage:u,onContentProcessDidTerminate:v,onRenderProcessGone:h}):null};import{useEffect as zt,useRef as xo}from"react";import{AppState as Po}from"react-native";import{Platform as Ke}from"react-native";var Wo="sdk_initialize";function Dt(){let{major:e,minor:t,patch:n,prerelease:r}=Ke.constants.reactNativeVersion;return{name:Wo,properties:{reactNativeVersion:`${e}.${t}.${n}${r!=null?`-${r}`:""}`,operatingSystem:`${Ke.OS}:${Ke.Version}`}}}import{PrivyApiError as Vt,PrivyClientError as Ao}from"@privy-io/js-sdk-core";function C(e){return e instanceof Error||e instanceof Vt||e instanceof Ao?e:typeof e=="string"?new Error(e):new Error("Unknown error")}var qt=e=>{if(e instanceof Vt)return`${e.code}`=="missing_or_invalid_token"?"logged_out":e.status===408||e.status===429||e.status>=500?"transient":"permanent";if(e instanceof TypeError||e instanceof SyntaxError)return"transient";let t=e==null?void 0:e.name;return t==="AbortError"||t==="TimeoutError"?"transient":"permanent"},jt=(e,t)=>e===t||e!==null&&t!==null&&e.name===t.name&&e.message===t.message&&Nt(e)===Nt(t),Nt=e=>"code"in e?String(e.code):void 0;var Gt=({client:e,setIsUserInitialized:t,setError:n})=>{let r=xo(e);zt(()=>{r.current=e},[e]),zt(()=>{let i=!1,a=!1,o=!1,s=!1,d=0,c,u=!1,p=h=>{n(y=>jt(y,h)?y:h),t(!0)},m=()=>l(void 0,null,function*(){o=!0;let h=r.current;try{if(yield h.initialize(),a||(a=!0,h.track(Dt())),yield h.user.get(),i)return;s=!1,p(null)}catch(y){if(i)return;let f=C(y);switch(qt(y)){case"logged_out":{s=!1,p(null);return}case"permanent":{s=!1,p(f);return}case"transient":{if(s=!0,p(f),d<Uo){let b=Math.min(Ro*Se(2,d),Io);d+=1,c=setTimeout(w,b)}return}}}finally{o=!1}}),w=()=>{if(c=void 0,S()){s=!1;return}m()},v=Po.addEventListener("change",h=>{if(h==="background"){u=!0;return}h!=="active"||!u||(u=!1,!(!s||o)&&(clearTimeout(c),w()))});return m(),()=>{i=!0,clearTimeout(c),v.remove()}},[n,t])},Uo=8,Ro=1e3,Io=6e4;import{useCallback as He,useEffect as Jt,useMemo as Je}from"react";import{errorIndicatesRecoveryIsNeeded as Mo,getAllUserEmbeddedSolanaWallets as Lo,getEntropyDetailsFromUser as $t,PrivyClientError as se}from"@privy-io/js-sdk-core";import{getAllUserEmbeddedSolanaWallets as Be,getEntropyDetailsFromAccount as Kt,getUserEmbeddedEthereumWallet as Oo,PrivyClientError as J}from"@privy-io/js-sdk-core";function Bt(a){return l(this,arguments,function*({client:e,setSolanaWallet:t,createSolanaWalletCallbacks:n,setSolanaRecoveryFlowState:r,opts:i}){var o,s,d;t({status:"creating"});try{let{user:c}=yield e.user.get(),u=Be(c),p=u[0],m=(o=Oo(c))!=null?o:void 0;if(i!=null&&i.recoveryMethod&&i.recoveryMethod!=="privy")throw new J({code:"embedded_wallet_creation_error",error:"Unsupported recovery method for solana wallet."});if(!(i!=null&&i.createAdditional)&&p)throw new J({code:"embedded_wallet_creation_error",error:"Solana wallet already exists for this user. Set `createAdditional` to `true` to create another wallet"});let w,v;if(p){let y=m!=null?m:p,{entropyId:f,entropyIdVerifier:b}=Kt(y),E=Math.max(...u.map(P=>P.wallet_index),0)+1,W=yield e.embeddedWallet.add({chainType:"solana",entropyId:f,entropyIdVerifier:b,hdWalletIndex:E}),k=W.account;if(!k||k.chain_type!=="solana")throw new J({error:"Embedded wallet account not created",code:"embedded_wallet_creation_error"});w=yield e.embeddedWallet.getSolanaProvider(k,f,b,void 0,void 0,void 0,void 0,P=>l(this,null,function*(){return yield R()(P)}),P=>l(this,null,function*(){return yield I()(P)})),v=W.user}else{let y=yield e.embeddedWallet.createSolana({ethereumAccount:m}),f=Be(y.user).find(k=>k.wallet_index===0);if(!f)throw new J({error:"Embedded wallet account not created",code:"embedded_wallet_creation_error"});let b=m!=null?m:f,{entropyId:E,entropyIdVerifier:W}=Kt(b);w=yield e.embeddedWallet.getSolanaProvider(f,E,W,void 0,void 0,void 0,void 0,k=>l(this,null,function*(){return yield R()(k)}),k=>l(this,null,function*(){return yield I()(k)})),v=y.user}let h=Be(v)[0];if(!h)throw new J({code:"embedded_wallet_creation_error",error:"Unknown error creating solana wallet"});return(d=(s=n.current)==null?void 0:s.onSuccess)==null||d.call(s,w),t({status:"connected",publicKey:h.public_key}),r({status:"initial"}),w}catch(c){let u=c instanceof Error?c.message:"Error creating embedded wallet";throw t({status:"error",error:u}),r({status:"initial"}),new J({code:"embedded_wallet_creation_error",error:u})}})}import{PrivyClientError as B}from"@privy-io/js-sdk-core";function We(u){return l(this,arguments,function*({client:e,account:t,setWallet:n,recoverWalletCallbacks:r,recoveryMethod:i,setRecoveryFlowState:a,password:o,recoveryKey:s,recoveryToken:d,recoverySecretOverride:c}){var p,m,w,v;if(!t)throw new B({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});switch(i){case"user-passcode":if(!o)throw new B({code:"embedded_wallet_recovery_error",error:"password is required for user-passcode recovery method"});break;case"google-drive":if(!d)throw new B({code:"embedded_wallet_recovery_error",error:"Recovery token is required for google-drive recovery method"});break;case"icloud":if(!c)throw new B({code:"embedded_wallet_recovery_error",error:"Record name is required for icloud recovery method"});break;case"recovery-encryption-key":if(!s)throw new B({code:"embedded_wallet_recovery_error",error:"recoveryKey is required for recovery-encryption-key recovery method"});break}n({status:"connecting",account:t});try{let h=yield e.embeddedWallet.getEthereumProvider({wallet:t,entropyId:t.address,entropyIdVerifier:"ethereum-address-verifier",recoveryPassword:o,recoveryAccessToken:d,recoverySecretOverride:c,recoveryKey:s,onMfaEnrollmentRequired:y=>l(this,null,function*(){return yield R()(y)}),onMfaVerificationRequired:y=>l(this,null,function*(){return yield I()(y)})});return n({status:"connected",provider:h,account:t}),a({status:"initial"}),(m=(p=r.current)==null?void 0:p.onSuccess)==null||m.call(p,h),h}catch(h){n({status:"needs-recovery",account:t}),a({status:"initial"});let y=new B({code:"embedded_wallet_recovery_error",error:h instanceof Error?h.message:"Error recovering embedded wallet"});throw(v=(w=r.current)==null?void 0:w.onError)==null||v.call(w,y),y}})}function Ht(s){return l(this,arguments,function*({client:e,account:t,entropyId:n,entropyIdVerifier:r,setSolanaWallet:i,recoverSolanaWalletCallbacks:a,setSolanaRecoveryFlowState:o}){var d,c,u,p;i({status:"connecting"});try{let m=yield e.embeddedWallet.getSolanaProvider(t,n,r,void 0,void 0,void 0,void 0,w=>l(this,null,function*(){return yield R()(w)}),w=>l(this,null,function*(){return yield I()(w)}));return i({status:"connected",publicKey:m._publicKey}),o({status:"initial"}),(c=(d=a.current)==null?void 0:d.onSuccess)==null||c.call(d,m),m}catch(m){i({status:"needs-recovery"}),o({status:"initial"});let w=new B({code:"embedded_wallet_recovery_error",error:m instanceof Error?m.message:"Error recovering embedded wallet"});throw(p=(u=a.current)==null?void 0:u.onError)==null||p.call(u,w),w}})}var Qt=({client:e,solanaWallet:t,setSolanaWallet:n,setSolanaRecoveryFlowState:r,createSolanaWalletCallbacks:i,recoverSolanaWalletCallbacks:a})=>{let o=U(),s=Je(()=>Lo(o),[o]),d=z(),c=Je(()=>s.length===0?null:$t(o,s[0]),[o,s]),u=Je(()=>{let v=s.map(b=>{let E=$t(o,b);return E?{account:b,entropy:E}:null});if(v.some(b=>b===null))return[];let h=void 0,y=void 0,f=void 0;return v.filter(b=>b!==null).map(({account:b,entropy:{entropyId:E,entropyIdVerifier:W}})=>({address:b.address,publicKey:b.address,walletIndex:b.wallet_index,getProvider:()=>e.embeddedWallet.getSolanaProvider(b,E,W,h,y,f,k=>l(void 0,null,function*(){var P;yield(P=Ce())==null?void 0:P(k)}),k=>l(void 0,null,function*(){return yield R()(k)}),k=>l(void 0,null,function*(){return yield I()(k)}))}))},[s,o,e]),p=He(v=>l(void 0,null,function*(){return yield Bt({client:e,setSolanaWallet:n,createSolanaWalletCallbacks:i,setSolanaRecoveryFlowState:r,opts:v})}),[e,i]),m=He(()=>l(void 0,null,function*(){if(!c)throw new se({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});let{entropyId:v,entropyIdVerifier:h}=c;return Ht({client:e,account:s[0],entropyId:v,entropyIdVerifier:h,setSolanaWallet:n,recoverSolanaWalletCallbacks:a,setSolanaRecoveryFlowState:r})}),[e,c,s,a,r,n]),w=He(()=>l(void 0,null,function*(){if(!c)throw n({status:"not-created"}),new se({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});n(v=>v.status==="connected"?{status:"reconnecting"}:{status:"connecting"});try{let{entropyId:v,entropyIdVerifier:h}=c,y=yield e.embeddedWallet.getSolanaProvider(s[0],v,h,void 0,void 0,void 0,void 0,f=>l(void 0,null,function*(){return yield R()(f)}),f=>l(void 0,null,function*(){return yield I()(f)}));return n({status:"connected",publicKey:s[0].public_key}),y}catch(v){throw Mo(v)?(n({status:"needs-recovery"}),new se({code:"embedded_wallet_needs_recovery",error:"Embedded wallet not loaded on device"})):v instanceof Error?(n({status:"error",error:v.message}),new se({code:"unknown_embedded_wallet_error",error:v.message})):(n({status:"error",error:"Error loading embedded wallet"}),new se({code:"unknown_embedded_wallet_error",error:"Error loading embedded wallet"}))}}),[s,e,c,n]);return Jt(()=>{if(!o&&t.status!=="disconnected")return n({status:"disconnected"});d&&w().catch(()=>{})},[d,o]),Jt(()=>{t.status==="error"&&t.error.includes("User must be logged in")&&w()},[t.status]),{create:p,recover:m,getProvider:w,wallets:u}};import{useCallback as le,useEffect as rr,useMemo as Go}from"react";import{getUserEmbeddedEthereumWallet as Ko,getUserEmbeddedSolanaWallet as or,isUnifiedWallet as Bo,throwIfInvalidRecoveryUpgradePath as Ho}from"@privy-io/js-sdk-core";import{errorIndicatesRecoveryIsNeeded as Jo,PrivyClientError as M}from"@privy-io/js-sdk-core";import{getUserEmbeddedEthereumWallet as Fo}from"@privy-io/js-sdk-core";import{PrivyClientError as $}from"@privy-io/js-sdk-core";function Ae(p){return l(this,arguments,function*({client:e,setWallet:t,createWalletCallbacks:n,recoveryMethod:r,setRecoveryFlowState:i,password:a,recoveryKey:o,recoveryToken:s,recoverySecretOverride:d,iCloudRecordNameOverride:c,solanaAccount:u}){var w,v;switch(r){case"user-passcode":if(!a)throw new $({code:"embedded_wallet_recovery_error",error:"password is required for user-passcode recovery method"});break;case"recovery-encryption-key":if(!o)throw new $({code:"embedded_wallet_recovery_error",error:"key is required for recovery-encryption-key recovery method"});break;case"google-drive":if(!s)throw new $({code:"embedded_wallet_recovery_error",error:"Recovery token is required for google-drive recovery method"});break;case"icloud":if(!d||!c)throw new $({code:"embedded_wallet_recovery_error",error:"iCloud recovery failed due to inability to store credentials"});break}t({status:"creating",account:null});let m=r==="icloud"?"icloud-native":r;try{let{user:h}=yield e.embeddedWallet.create({password:a,recoveryMethod:m,recoveryKey:o,recoveryToken:s,recoverySecretOverride:d,iCloudRecordNameOverride:c,solanaAccount:u}),y=Fo(h);if(!y)throw new $({error:"Embedded wallet account not created",code:"embedded_wallet_creation_error"});let f=yield e.embeddedWallet.getEthereumProvider({wallet:y,entropyId:y.address,entropyIdVerifier:"ethereum-address-verifier",onMfaEnrollmentRequired:b=>l(this,null,function*(){return yield R()(b)}),onMfaVerificationRequired:b=>l(this,null,function*(){return yield I()(b)})});return(v=(w=n.current)==null?void 0:w.onSuccess)==null||v.call(w,f),t({status:"connected",provider:f,account:y}),i({status:"initial"}),f}catch(h){let y=h instanceof Error?h.message:"Error creating embedded wallet";throw t({status:"error",error:y,account:null}),i({status:"initial"}),new $({code:"embedded_wallet_creation_error",error:y})}})}import{Platform as Xt}from"react-native";import{PrivyClientError as q}from"@privy-io/js-sdk-core";import{Platform as To}from"react-native";var Yt=new Set;function xe(e,{isDevelopment:t=__DEV__,reactNativeVersion:n=To.constants.reactNativeVersion,warn:r=i=>console.warn(i)}={}){if(!t||Yt.has(e))return;let{major:i,minor:a,patch:o}=n;if(i>0||i===0&&a>=81)return;let d=`[Privy] Upcoming optional dependency change
|
|
2
|
+
|
|
3
|
+
This app uses React Native ${`${i}.${a}.${o}`}. A future @privy-io/expo release will make ${e} optional.
|
|
4
|
+
|
|
5
|
+
`,c=i===0&&a>=79?d+`Upgrade to Expo SDK 54 or React Native 0.81 when possible. If remaining on Expo SDK 53 or React Native 0.79\u20130.80, ensure metro, metro-config, and metro-runtime resolve to version 0.82.5 or newer and transformer.allowOptionalDependencies is enabled.
|
|
6
|
+
|
|
7
|
+
Check Metro with:
|
|
8
|
+
pnpm why metro metro-config metro-runtime
|
|
9
|
+
npm ls metro metro-config metro-runtime
|
|
10
|
+
yarn why metro
|
|
11
|
+
|
|
12
|
+
If these requirements cannot be met, keep ${e} installed.`:d+`Expo SDK 52 and React Native 0.78 or earlier cannot safely omit ${e}. Upgrade to Expo SDK 54 or React Native 0.81, or keep ${e} installed.`;Yt.add(e),r(c)}function Zt(){return l(this,null,function*(){xe("@privy-io/expo-native-extensions");try{return yield import("@privy-io/expo-native-extensions")}catch(e){throw new q({code:"configuration_error",error:"`@privy-io/expo-native-extensions` is not installed. Install it and rebuild the native app."})}})}function ce(r){return l(this,arguments,function*({user:e,appId:t,client:n}){var s;if(Xt.OS==="android")throw new q({code:"embedded_wallet_recovery_error",error:"iCloud recovery is not supported on Android"});let i=yield Zt(),a=yield n.recovery.icloudAuth.getICloudConfiguration("expo-ios");if(!(a==null?void 0:a.container_identifier))throw new q({code:"embedded_wallet_recovery_error",error:"An iCloud Container ID must be specified in the Privy Dashboard."});try{let{recoverySecret:d,iCloudRecordName:c}=yield i.writeRecoverySecretToICloud({containerId:a.container_identifier,appId:t,userId:e.id});return{recoverySecret:d,iCloudRecordName:c}}catch(d){if(d instanceof Error){let c=(s=d.message.split("Caused by: ")[1])!=null?s:"Error writing to iCloud";throw new q({code:"embedded_wallet_recovery_error",error:c})}throw new q({code:"embedded_wallet_recovery_error",error:"Error writing to iCloud"})}})}function Pe(r){return l(this,arguments,function*({walletAddress:e,client:t,chainType:n}){var c;if(Xt.OS==="android")throw new q({code:"embedded_wallet_recovery_error",error:"iCloud recovery is not supported on Android"});let i=yield Zt(),o=(yield t.recovery.getRecoveryKeyMaterial(e,n)).icloud_record_name;if(!o)throw new q({code:"embedded_wallet_recovery_error",error:"iCloud recovery not properly backed up."});let s=yield t.recovery.icloudAuth.getICloudConfiguration("expo-ios"),d=s==null?void 0:s.container_identifier;if(!d)throw new q({code:"embedded_wallet_recovery_error",error:"An iCloud Container ID must be specified in the Privy Dashboard."});try{let{recoverySecret:u}=yield i.readRecoverySecretFromICloud({containerId:d,recordName:o});return{recoverySecret:u}}catch(u){if(u instanceof Error){let p=(c=u.message.split("Caused by: ")[1])!=null?c:"Error writing to iCloud";throw new q({code:"embedded_wallet_recovery_error",error:p})}throw new q({code:"embedded_wallet_recovery_error",error:"Error writing to iCloud"})}})}import*as H from"expo-linking";import*as er from"expo-web-browser";import{Platform as tr}from"react-native";import{PrivyClientError as Y}from"@privy-io/js-sdk-core";import yc from"react-fast-compare";var Q=e=>new Promise(t=>setTimeout(t,e));import{useEffect as Do,useRef as No}from"react";import{AppState as $e}from"react-native";function Ue(){let e=No($e.currentState);Do(()=>$e.addEventListener("change",r=>{e.current=r}).remove,[]);function t(){return $e.currentState}return{appState:e,getCurrentAppState:t}}function de(i){return l(this,arguments,function*({provider:e,redirectUri:t,client:n,onError:r}){try{let a;switch(e){case"google-drive":{let{url:c}=yield n.recovery.auth.generateURL(H.createURL(t||"/"));a=c;break}default:throw new Y({error:"OAuth invalid provider",code:"embedded_wallet_recovery_error"})}let o=yield er.openAuthSessionAsync(a);if(tr.OS==="android")return;if(o.type!=="success")throw new Y({error:"Recovery OAuth session failed",code:"embedded_wallet_recovery_error"});let{queryParams:s}=H.parse(o.url),d;switch(e){case"google-drive":{let{privy_oauth_state:c,privy_oauth_code:u}=s;if(!u||!c)throw new Y({error:"Recovery OAuth invalid credentials",code:"embedded_wallet_recovery_error"});d=yield Re({oAuthCode:u,oAuthState:c,client:n});break}default:throw new Y({error:"Recovery OAuth invalid provider",code:"embedded_wallet_recovery_error"})}return d}catch(a){throw r==null||r(C(a)),a}})}function Re(r){return l(this,arguments,function*({oAuthCode:e,oAuthState:t,client:n}){let{access_token:i}=yield n.recovery.auth.authorize(e,t);if(!i)throw new Y({error:"OAuth invalid credentials",code:"login_with_oauth_returned_with_invalid_credentials"});return i})}var Vo=2*60*1e3;function qo(e){let t;return new Promise((n,r)=>{t=H.addEventListener("url",a=>l(this,[a],function*({url:i}){if(!i)return;let{queryParams:o}=H.parse(i),{privy_oauth_state:s,privy_oauth_code:d}=o!=null?o:{};if(typeof d!="string"||typeof s!="string")return;let c=yield Re({client:e,oAuthCode:d,oAuthState:s});n(c)})),setTimeout(()=>{r(new Y({code:"embedded_wallet_set_recovery_error",error:"Failed to complete Google Drive recovery flow"}))},Vo)}).finally(()=>{t==null||t.remove()})}function Ie(e){return l(this,null,function*(){let t;tr.OS==="android"&&(t=qo(e));let n=yield de({provider:"google-drive",client:e});return n!=null?n:yield t})}import{getUserEmbeddedWallet as jo,PrivyClientError as zo}from"@privy-io/js-sdk-core";function Oe(a){return l(this,arguments,function*({client:e,recoveryInput:t,setWalletRecoveryCallbacks:n,setRecoveryFlowState:r,setWallet:i}){var o,s,d,c;try{let{provider:u,user:p}=yield e.embeddedWallet.setRecovery(t),m=u,w=jo(p);return i({status:"connected",provider:m,account:w}),(s=(o=n.current)==null?void 0:o.onSuccess)==null||s.call(o,m),r({status:"initial"}),m}catch(u){let p=new zo({code:"embedded_wallet_set_recovery_error",error:u instanceof Error?u.message:"Error setting password on embedded wallet"});throw(c=(d=n.current)==null?void 0:d.onError)==null||c.call(d,p),r({status:"initial"}),p}})}function nr(e){return e===void 0?{recoveryMethod:"privy"}:typeof e=="string"?{recoveryMethod:"user-passcode",password:e}:e.recoveryMethod==="user-passcode"?{recoveryMethod:"user-passcode",password:e.password}:e.recoveryMethod==="recovery-encryption-key"?{recoveryMethod:"recovery-encryption-key",recoveryKey:e.recoveryKey}:{recoveryMethod:e.recoveryMethod}}var ir=({client:e,appId:t,wallet:n,setWallet:r,setRecoveryFlowState:i,createWalletCallbacks:a,recoverWalletCallbacks:o,setWalletRecoveryCallbacks:s})=>{let d=U(),c=Go(()=>Ko(d),[d]),u=z(),p=le(y=>l(void 0,null,function*(){var we,ve;if(c)throw new M({error:"This user already has an embedded wallet",code:"embedded_wallet_already_exists"});let{user:f}=yield e.user.get(),{password:b,recoveryMethod:E,recoveryKey:W}=nr(y),k,P,N;if(E==="google-drive"&&(k=yield de({provider:E,client:e,onError:(we=a.current)==null?void 0:we.onError}),i({status:"creating-wallet"}),!k))return null;if(E==="icloud"){if(!f)throw new M({code:"embedded_wallet_recovery_error",error:"User must be loaded before creating a wallet with iCloud."});let{recoverySecret:Ve,iCloudRecordName:ne}=yield ce({user:f,appId:t,client:e});P=Ve,N=ne}return yield Ae({client:e,setWallet:r,createWalletCallbacks:a,recoveryMethod:E,recoveryKey:W,setRecoveryFlowState:i,password:b,recoverySecretOverride:P,iCloudRecordNameOverride:N,solanaAccount:(ve=or(f))!=null?ve:void 0})}),[e,c,d]),m=le(y=>l(void 0,null,function*(){var E;if(n.status!=="connected")throw new M({code:"attempted_to_set_password_before_connected",error:"Embedded wallet must be connected before setting password"});if(!c)throw new M({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});if(or(d))throw new M({code:"embedded_wallet_set_recovery_error",error:"Cannot set user-controlled recovery for a user with an embedded Solana wallet."});if(Bo(c))throw new M({code:"unsupported_wallet_type",error:"Embedded wallet recovery is only supported for on-device execution and this app uses TEE execution. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide"});Ho({currentRecoveryMethod:c.recovery_method,upgradeToRecoveryMethod:y.recoveryMethod});let f,b;switch(y.recoveryMethod){case"privy":b=T(_({},y),{wallet:c});break;case"user-passcode":b=T(_({},y),{wallet:c,password:y.password});break;case"google-drive":if(f=yield de({provider:y.recoveryMethod,client:e,onError:(E=s.current)==null?void 0:E.onError}),i({status:"upgrading-recovery"}),!f)return null;b={recoveryMethod:"google-drive",wallet:c,recoveryAccessToken:f};break;case"icloud":if(!d)throw new M({code:"embedded_wallet_recovery_error",error:"User must be loaded before backing up to iCloud."});let{recoverySecret:W,iCloudRecordName:k}=yield ce({user:d,appId:t,client:e});b={recoveryMethod:"icloud-native",recoverySecretOverride:W,iCloudRecordNameOverride:k,wallet:c};break;default:throw new M({code:"embedded_wallet_recovery_error",error:"Unrecognized recovery method"})}return Oe({client:e,recoveryInput:b,setWalletRecoveryCallbacks:s,setRecoveryFlowState:i,setWallet:r})}),[e,c,n.status,d]),w=le(y=>l(void 0,null,function*(){return m({recoveryMethod:"user-passcode",password:y})}),[e,c,n.status]),v=le(y=>l(void 0,null,function*(){var P;if(!c)throw new M({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});let{password:f,recoveryMethod:b,recoveryKey:E}=nr(y),W,k;if(b==="google-drive"&&(W=yield de({provider:b,client:e,onError:(P=o.current)==null?void 0:P.onError}),i({status:"recovering"}),!W))return null;if(b==="icloud"){if(!d)throw new M({code:"embedded_wallet_recovery_error",error:"User must be loaded before recovering via iCloud."});let{recoverySecret:N}=yield Pe({client:e,walletAddress:c.address});k=N}return We({client:e,account:c,setWallet:r,recoverWalletCallbacks:o,recoveryMethod:b,setRecoveryFlowState:i,recoveryKey:E,password:f,recoveryToken:W,recoverySecretOverride:k})}),[e,c]),h=le(()=>l(void 0,null,function*(){if(!c)throw r({status:"not-created",account:null}),new M({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});r(y=>y.status==="connected"?{status:"reconnecting",account:c}:{status:"connecting",account:c});try{let y=yield e.embeddedWallet.getEthereumProvider({wallet:c,entropyId:c.address,entropyIdVerifier:"ethereum-address-verifier",onMfaEnrollmentRequired:f=>l(void 0,null,function*(){return yield R()(f)}),onMfaVerificationRequired:f=>l(void 0,null,function*(){return yield I()(f)})});return r({status:"connected",provider:y,account:c}),y}catch(y){throw Jo(y)?(r({status:"needs-recovery",account:c}),new M({code:"embedded_wallet_needs_recovery",error:"Embedded wallet not loaded on device"})):y instanceof Error?(r({status:"error",error:y.message,account:c}),new M({code:"unknown_embedded_wallet_error",error:y.message})):(r({status:"error",error:"Error loading embedded wallet",account:c}),new M({code:"unknown_embedded_wallet_error",error:"Error loading embedded wallet"}))}}),[e,c]);return rr(()=>{if(!d&&n.status!=="disconnected")return r({status:"disconnected",account:null});u&&h().catch(()=>{})},[u,d,c]),rr(()=>{n.status==="error"&&n.error.includes("User must be logged in")&&h()},[n.status]),{create:p,recover:v,setPassword:w,setRecovery:m,getProvider:h}};import{useEffect as $o,useState as Qo}from"react";import{PrivyClientError as ar}from"@privy-io/js-sdk-core";var sr=({client:e,isReady:t})=>{let n=U(),r=_e(o=>o==null?void 0:o.customAuth),[i,a]=Qo({status:"initial"});return $o(()=>{(()=>l(void 0,null,function*(){if(!(r!=null&&r.enabled)){a({status:"not-enabled"});return}a({status:"loading"});let{getCustomAccessToken:s,isLoading:d}=r;if(!(!t||d))try{let c=yield s();if(!c&&n){yield e.auth.logout(),a({status:"done"});return}if(!c){a({status:"done"});return}if(n){a({status:"done"});return}let u=x();if(!(yield e.auth.customProvider.syncWithToken(c,{embedded:u==null?void 0:u.embedded}))){yield e.auth.logout(),a({status:"error",error:new ar({error:"Failed to sync with custom auth provider",code:"third_party_auth_error"})});return}a({status:"done"})}catch(c){if(a({status:"error",error:c}),n)throw yield e.auth.logout(),new ar({error:"Third-party auth failed",code:"third_party_auth_error"})}}))()},[e,n,t,r==null?void 0:r.enabled,r==null?void 0:r.getCustomAccessToken,r==null?void 0:r.isLoading]),{customAuthState:i,customAuthStateIsSettled:i.status!=="loading"&&i.status!=="initial"}};import*as X from"expo-linking";import{useCallback as Yo,useEffect as Xo,useMemo as Zo}from"react";import{Platform as en}from"react-native";import{getUserEmbeddedSolanaWallet as tn,getUserEmbeddedWallet as rn}from"@privy-io/js-sdk-core";var cr=({client:e,createWalletCallbacks:t,recoverWalletCallbacks:n,setWalletRecoveryCallbacks:r,recoveryFlowState:i,oAuthState:a,setRecoveryFlowState:o,setWallet:s,appStateVisible:d})=>{let c=X.useURL(),u=U(),p=Zo(()=>rn(u),[u]),m=z(),w=Yo(v=>{var y,f,b,E;let h=C(v);i.status==="creating-wallet"?(f=(y=t.current).onError)==null||f.call(y,C(h)):(E=(b=n.current).onError)==null||E.call(b,C(h)),o({status:"initial"})},[i]);return Xo(()=>{function v(){return l(this,null,function*(){var b;if(!c&&i.status!=="initial"&&d&&w(new Error("Recovery OAuth session failed")),!c||i.status==="initial"||a.status!=="initial"||!d||!m)return;let{queryParams:h}=X.parse(c),{privy_oauth_state:y,privy_oauth_code:f}=h;if(!(!f||!y)){yield X.openURL(c.split("?")[0]);try{let E=yield Re({oAuthCode:f,oAuthState:y,client:e});if(i.status==="creating-wallet"){let W=(b=tn(u))!=null?b:void 0;yield Ae({client:e,setWallet:s,createWalletCallbacks:t,recoveryMethod:"google-drive",setRecoveryFlowState:o,recoveryToken:E,solanaAccount:W})}else if(i.status==="upgrading-recovery"){if(!p)throw new Error("Embedded wallet not found");yield Oe({client:e,recoveryInput:{recoveryMethod:"google-drive",wallet:p,recoveryAccessToken:E},setWalletRecoveryCallbacks:r,setRecoveryFlowState:o,setWallet:s})}else yield We({client:e,account:p,setWallet:s,recoverWalletCallbacks:n,recoveryMethod:"google-drive",setRecoveryFlowState:o,recoveryToken:E})}catch(E){w(E)}}})}en.OS==="android"&&v()},[c,i.status,d,m])};import{useEffect as Ga,useRef as Ka}from"react";import{useCallback as Qe,useContext as on}from"react";import{PrivyClientError as nn}from"@privy-io/js-sdk-core";var fd=e=>{let{client:t,setSiweState:n,siweState:r}=on(g),i=Qe(s=>{var c;let d=C(s);return n({status:"error",error:d}),(c=e==null?void 0:e.onError)==null||c.call(e,d),d},[e==null?void 0:e.onError]),a=Qe(u=>l(void 0,[u],function*({wallet:s,from:{domain:d,uri:c}}){var p;try{n({status:"generating-message"});let m=yield t.auth.siwe.init(s,d,c);return n({status:"awaiting-signature"}),(p=e==null?void 0:e.onGenerateMessage)==null||p.call(e,m.message),m.message}catch(m){throw i(m)}}),[t,i,e==null?void 0:e.onGenerateMessage]);return{loginWithSiwe:Qe(u=>l(void 0,[u],function*({signature:s,messageOverride:d,disableSignup:c}){var p;try{if(S())throw new nn({code:"attempted_login_with_siwe_while_already_logged_in",error:"Already logged in, use `useLinkWithSiwe` if you are trying to link a wallet to an existing account"});n({status:"submitting-signature"});let w=x(),v=yield t.auth.siwe.loginWithSiwe(s,void 0,d,c?"no-signup":"login-or-sign-up",{embedded:w==null?void 0:w.embedded});return n({status:"done"}),(p=e==null?void 0:e.onSuccess)==null||p.call(e,v.user,v.is_new_user),v.user}catch(m){throw i(m)}}),[t,i,e==null?void 0:e.onSuccess]),generateSiweMessage:a,state:r}};import{useCallback as dr}from"react";import{createSiwsMessage as sn,PrivyClientError as cn}from"@privy-io/js-sdk-core";import{useContext as an}from"react";var A=()=>{let{client:e}=an(g);return e};var Wd=()=>{let e=A(),t=dr(o=>l(void 0,[o],function*({wallet:{address:r},from:{domain:i,uri:a}}){try{let{nonce:s}=yield e.auth.siws.fetchNonce({address:r});return{message:sn({address:r,domain:i,uri:a,nonce:s})}}catch(s){throw C(s)}}),[e]),n=dr(s=>l(void 0,[s],function*({signature:r,message:i,wallet:{walletClientType:a,connectorType:o}={}}){try{if(!S())throw new cn({code:"attempted_link_siws_before_logged_in",error:"Must be logged in to link a wallet, Use `useLoginWithSiws` to login with a wallet"});let{user:c}=yield e.auth.siws.link({signature:r,message:i,walletClientType:a,connectorType:o});return c}catch(d){throw C(d)}}),[e]);return{generateMessage:t,link:n}};import{useCallback as lr}from"react";import{createSiwsMessage as dn,PrivyClientError as ln}from"@privy-io/js-sdk-core";var Ld=()=>{let e=A(),t=lr(o=>l(void 0,[o],function*({wallet:{address:r},from:{domain:i,uri:a}}){try{let{nonce:s}=yield e.auth.siws.fetchNonce({address:r});return{message:dn({address:r,domain:i,uri:a,nonce:s})}}catch(s){throw C(s)}}),[e]),n=lr(d=>l(void 0,[d],function*({signature:r,message:i,wallet:{walletClientType:a,connectorType:o}={},disableSignup:s}){try{if(S())throw new ln({code:"attempted_login_with_siws_while_already_logged_in",error:"Already logged in, use `useLinkWithSiws` if you are trying to link a wallet to an existing account"});let u=x();return(yield e.auth.siws.login({signature:r,message:i,walletClientType:a,connectorType:o,mode:s?"no-signup":"login-or-sign-up",opts:{embedded:u==null?void 0:u.embedded}})).user}catch(c){throw C(c)}}),[e]);return{generateMessage:t,login:n}};import{useCallback as ur,useContext as un}from"react";import{PrivyClientError as pn}from"@privy-io/js-sdk-core";var zd=e=>{let{client:t}=un(g),n=ur(i=>{var o;let a=C(i);return(o=e==null?void 0:e.onError)==null||o.call(e,a),a},[e==null?void 0:e.onError]);return{unlinkWallet:ur(a=>l(void 0,[a],function*({address:i}){var o;try{if(!S())throw new pn({code:"attempted_unlink_siwe_before_logged_in",error:"Must be logged in to unlink a wallet, Use `useLoginWithSiwe` to login with a wallet"});let{user:d}=yield t.auth.siwe.unlinkWallet(i);return(o=e==null?void 0:e.onSuccess)==null||o.call(e,d),d}catch(s){throw n(s)}}),[t,n,e==null?void 0:e.onSuccess])}};import{useCallback as Ye,useContext as mn,useState as yn}from"react";import{PrivyClientError as pr}from"@privy-io/js-sdk-core";var Yd=e=>{let[t,n]=yn(""),{client:r,otpState:i,setOtpState:a}=mn(g),o=Ye(c=>{var p;let u=C(c);return a({status:"error",error:u}),(p=e==null?void 0:e.onError)==null||p.call(e,u),u},[e,a]),s=Ye(u=>l(void 0,[u],function*({email:c}){var p;n(c);try{a({status:"sending-code"});let m=yield r.auth.email.sendCode(c);return a({status:"awaiting-code-input"}),(p=e==null?void 0:e.onSendCodeSuccess)==null||p.call(e,{email:c}),m}catch(m){throw o(m)}}),[r,o,e,a]),d=Ye(p=>l(void 0,[p],function*({code:c,email:u}){var m;try{if(!S())throw new pr({code:"attempted_link_email_before_logged_in",error:"Must be logged in to link an email, Use `useLoginWithEmail` to login with email"});let v=u||t;if(!v)throw new pr({code:"attempted_submit_otp_before_sending",error:"Must `sendCode` with a valid email before calling `linkWithCode`"});a({status:"submitting-code"});let{user:h}=yield r.auth.email.linkWithCode(v,c);return a({status:"done"}),(m=e==null?void 0:e.onLinkSuccess)==null||m.call(e,h),h}catch(w){throw o(w)}}),[t,a,r,e,o]);return{sendCode:s,linkWithCode:d,state:i}};import{useCallback as mr,useContext as fn}from"react";var ol=e=>{let{client:t}=fn(g),n=mr(i=>{var o;let a=C(i);return(o=e==null?void 0:e.onError)==null||o.call(e,a),a},[e==null?void 0:e.onError]);return{unlinkEmail:mr(a=>l(void 0,[a],function*({email:i}){var o;try{let{user:s}=yield t.auth.email.unlink(i);return(o=e==null?void 0:e.onSuccess)==null||o.call(e,s),s}catch(s){throw n(s)}}),[t,e==null?void 0:e.onSuccess,n])}};import{useCallback as Xe,useContext as gn,useState as hn}from"react";import{PrivyClientError as yr}from"@privy-io/js-sdk-core";var pl=e=>{let[t,n]=hn(""),{client:r,otpState:i,setOtpState:a}=gn(g),o=Xe(c=>{var p;let u=C(c);return a({status:"error",error:u}),(p=e==null?void 0:e.onError)==null||p.call(e,u),u},[e,a]),s=Xe(u=>l(void 0,[u],function*({email:c}){var p;n(c);try{a({status:"sending-code"});let m=yield r.auth.email.sendCode(c);return a({status:"awaiting-code-input"}),(p=e==null?void 0:e.onSendCodeSuccess)==null||p.call(e,{email:c}),m}catch(m){throw o(m)}}),[r,o,e,a]),d=Xe(m=>l(void 0,[m],function*({code:c,email:u,disableSignup:p}){var w;try{if(S()&&!r.isMultiUserModeEnabled)throw new yr({code:"attempted_login_with_email_while_already_logged_in",error:"Already logged in, use `useLinkWithEmail` if you are trying to link an email to an existing account"});let h=u||t;if(!h)throw new yr({code:"attempted_submit_otp_before_sending",error:"Must `sendCode` with a valid email before calling `loginWithCode`"});a({status:"submitting-code"});let y=x(),f=yield r.auth.email.loginWithCode(h,c,p?"no-signup":"login-or-sign-up",{embedded:y==null?void 0:y.embedded});return a({status:"done"}),(w=e==null?void 0:e.onLoginSuccess)==null||w.call(e,f.user,f.is_new_user),f==null?void 0:f.user}catch(v){throw o(v)}}),[t,a,r,e,o]);return{sendCode:s,loginWithCode:d,state:i}};import{useCallback as Ze,useContext as wn,useState as vn}from"react";import{PrivyClientError as fr}from"@privy-io/js-sdk-core";var bl=e=>{let[t,n]=vn(""),{client:r,otpState:i,setOtpState:a}=wn(g),o=Ze(c=>{var p;let u=C(c);return a({status:"error",error:u}),(p=e==null?void 0:e.onError)==null||p.call(e,u),u},[e,a]),s=Ze(u=>l(void 0,[u],function*({phone:c}){var p;n(c);try{a({status:"sending-code"});let m=yield r.auth.phone.sendCode(c);return a({status:"awaiting-code-input"}),(p=e==null?void 0:e.onSendCodeSuccess)==null||p.call(e,{phone:c}),m}catch(m){throw o(m)}}),[r,o,e,a]),d=Ze(p=>l(void 0,[p],function*({code:c,phone:u}){var m;try{if(!S())throw new fr({code:"attempted_link_sms_before_logged_in",error:"Must be logged in to link a phone number, Use `useLoginWithSMS` to login with a phone number"});if(!(u||t))throw new fr({code:"attempted_submit_otp_before_sending",error:"Must `sendCode` with a valid phone number before calling `linkWithCode`"});a({status:"submitting-code"});let{user:h}=yield r.auth.phone.linkWithCode(u||t,c);return a({status:"done"}),(m=e==null?void 0:e.onLinkSuccess)==null||m.call(e,h),h}catch(w){throw o(w)}}),[t,a,r,e,o]);return{sendCode:s,linkWithCode:d,state:i}};import{useCallback as et,useContext as bn,useState as Sn}from"react";import{PrivyClientError as gr}from"@privy-io/js-sdk-core";var Pl=e=>{let[t,n]=Sn(""),{client:r,otpState:i,setOtpState:a}=bn(g),o=et(c=>{var p;let u=C(c);return a({status:"error",error:u}),(p=e==null?void 0:e.onError)==null||p.call(e,u),u},[e,a]),s=et(u=>l(void 0,[u],function*({phone:c}){var p;n(c);try{a({status:"sending-code"});let m=yield r.auth.phone.sendCode(c);return a({status:"awaiting-code-input"}),(p=e==null?void 0:e.onSendCodeSuccess)==null||p.call(e,{phone:c}),m}catch(m){throw o(m)}}),[r,o,e,a]),d=et(m=>l(void 0,[m],function*({code:c,phone:u,disableSignup:p}){var w;try{if(S())throw new gr({code:"attempted_login_with_sms_while_already_logged_in",error:"Already logged in, use `useLinkWithSMS` if you are trying to link a phone number to an existing account"});if(!(u||t))throw new gr({code:"attempted_submit_otp_before_sending",error:"Must `sendCode` with a valid phone number before calling `loginWithCode`"});a({status:"submitting-code"});let y=x(),f=yield r.auth.phone.loginWithCode(u||t,c,p?"no-signup":"login-or-sign-up",{embedded:y==null?void 0:y.embedded});return a({status:"done"}),(w=e==null?void 0:e.onLoginSuccess)==null||w.call(e,f.user,f.is_new_user),f==null?void 0:f.user}catch(v){throw o(v)}}),[t,a,r,e,o]);return{sendCode:s,loginWithCode:d,state:i}};import*as Me from"expo-linking";import{useCallback as tt,useContext as En,useRef as Cn}from"react";import{PrivyClientError as ue}from"@privy-io/js-sdk-core";var Tl=e=>{let{appState:t,getCurrentAppState:n}=Ue(),{client:r,farcasterState:i,setFarcasterState:a}=En(g),o=Cn(!1),s=tt(u=>{var m;let p=C(u);return a({status:"error",error:p}),(m=e==null?void 0:e.onError)==null||m.call(e,p),p},[e==null?void 0:e.onError,a]),d=tt(()=>{o.current=!0},[]);return{linkWithFarcaster:tt((w,...v)=>l(void 0,[w,...v],function*({relyingParty:u,redirectUrl:p},m={pollAttempts:10,pollIntervalMs:1e3}){var h;try{let y=S();if(o.current=!1,!y)throw new ue({code:"attempted_link_farcaster_before_logged_in",error:"Must be logged in to link a Farcaster account."});a({status:"generating-uri"});let{connect_uri:f,channel_token:b}=yield r.auth.farcaster.initializeAuth({relyingParty:u,redirectUrl:Me.createURL(p!=null?p:"/")});if(!f)throw new ue({code:"failed_to_generate_farcaster_uri",error:"Failed to generate farcaster uri"});if(!b)throw new ue({code:"failed_to_generate_farcaster_channel_token",error:"Failed to generate farcaster channel token"});yield Me.openURL(f),a({status:"polling-status"});let E=0;for(;E<m.pollAttempts;){if(o.current)throw new ue({code:"farcaster_polling_canceled",error:"Farcaster polling canceled"});if(t.current!=="active"&&n()!=="active"){yield Q(m.pollIntervalMs);continue}let W=yield r.auth.farcaster.getFarcasterStatus({channel_token:b});if(W.state==="completed"){a({status:"submitting-token"});let{user:k}=yield r.auth.farcaster.link(_({channel_token:b},W));return a({status:"done"}),(h=e==null?void 0:e.onSuccess)==null||h.call(e,k),k}E++,yield Q(m.pollIntervalMs)}throw new ue({code:"farcaster_polling_timeout",error:"Farcasting polling timed out"})}catch(y){throw s(y)}}),[r,e==null?void 0:e.onSuccess,s,a]),state:i,cancel:d}};import{useCallback as hr,useContext as _n}from"react";var zl=e=>{let{client:t}=_n(g),n=hr(i=>{var o;let a=C(i);return(o=e==null?void 0:e.onError)==null||o.call(e,a),a},[e==null?void 0:e.onError]);return{unlinkFarcaster:hr(a=>l(void 0,[a],function*({fid:i}){var o;try{let{user:s}=yield t.auth.farcaster.unlink({fid:i});return(o=e==null?void 0:e.onSuccess)==null||o.call(e,s),s}catch(s){throw n(s)}}),[t,e==null?void 0:e.onSuccess,n])}};import*as Le from"expo-linking";import{useCallback as nt,useContext as kn,useRef as Wn}from"react";import{PrivyClientError as pe}from"@privy-io/js-sdk-core";var Xl=e=>{let{appState:t,getCurrentAppState:n}=Ue(),{client:r,farcasterState:i,setFarcasterState:a}=kn(g),o=Wn(!1),s=nt(u=>{var m;let p=C(u);return a({status:"error",error:p}),(m=e==null?void 0:e.onError)==null||m.call(e,p),p},[e==null?void 0:e.onError,a]),d=nt(()=>{o.current=!0},[]);return{loginWithFarcaster:nt((v,...h)=>l(void 0,[v,...h],function*({relyingParty:u,redirectUrl:p,disableSignup:m},w={pollAttempts:10,pollIntervalMs:1e3}){var y;try{if(o.current=!1,S())throw new pe({code:"attempted_login_with_farcaster_while_already_logged_in",error:"Already logged in, use `useLinkWithFarcaster` if you are trying to link farcaster to an existing account"});a({status:"generating-uri"});let{connect_uri:b,channel_token:E}=yield r.auth.farcaster.initializeAuth({relyingParty:u,redirectUrl:Le.createURL(p!=null?p:"/")});if(!b)throw new pe({code:"failed_to_generate_farcaster_uri",error:"Failed to generate farcaster uri"});if(!E)throw new pe({code:"failed_to_generate_farcaster_channel_token",error:"Failed to generate farcaster channel token"});yield Le.openURL(b),a({status:"polling-status"});let W=0;for(;W<w.pollAttempts;){if(o.current)throw new pe({code:"farcaster_polling_canceled",error:"Farcaster polling canceled"});if(t.current!=="active"&&n()!=="active"){yield Q(w.pollIntervalMs);continue}let k=yield r.auth.farcaster.getFarcasterStatus({channel_token:E});if(k.state==="completed"){a({status:"submitting-token"});let P=x(),N=yield r.auth.farcaster.authenticate(_({channel_token:E,mode:m?"no-signup":"login-or-sign-up"},k),{embedded:P==null?void 0:P.embedded});return a({status:"done"}),(y=e==null?void 0:e.onSuccess)==null||y.call(e,N.user,N.is_new_user),N.user}W++,yield Q(w.pollIntervalMs)}throw new pe({code:"farcaster_polling_timeout",error:"Farcasting polling timed out"})}catch(f){throw s(f)}}),[r,s,e==null?void 0:e.onSuccess,a,t]),state:i,cancel:d}};import{useCallback as wr,useContext as An}from"react";import{create as xn}from"zustand";import{PrivyClientError as Pn}from"@privy-io/js-sdk-core";var it=xn(()=>({status:"initial"})),G=e=>it.setState(e,!0),Un=it.getState,cu=()=>{let{client:e}=An(g),t=it(),n=wr(()=>l(void 0,null,function*(){try{G({status:"fetching-nonce"});let i=yield e.auth.farcasterV2.initializeAuth();return G({status:"awaiting-signature"}),i}catch(i){let a=C(i);throw G({status:"initial",error:a}),a}}),[e]),r=wr(i=>l(void 0,null,function*(){let a=Un().status;try{if(S()){let c=new Pn({code:"attempted_login_with_farcaster_while_already_logged_in",error:"Already logged in, use a link helper if you are trying to link farcaster to an existing account"});throw G({status:a,error:c}),c}G({status:"submitting-signature"});let s=x(),d=yield e.auth.farcasterV2.authenticate(i,{embedded:s==null?void 0:s.embedded});return G({status:"done"}),setTimeout(()=>G({status:"initial"}),1500),{user:d.user}}catch(o){let s=C(o);throw G({status:a,error:s}),s}}),[e]);return{init:n,login:r,state:t}};import{useContext as Rn,useMemo as In}from"react";import{delegatedActions as vr}from"@privy-io/js-sdk-core";var yu=()=>{let{client:e}=Rn(g);return In(()=>({delegateWallet:vr.delegateWallet(e),revokeWallets:vr.revokeWallets(e)}),[e])};import{useContext as On,useMemo as Mn}from"react";import{depositAddress as me}from"@privy-io/js-sdk-core";var vu=()=>{let{client:e}=On(g);return Mn(()=>({getConfig:()=>me.getConfig(e),generateDepositAddress:t=>me.generateDepositAddress(_({privy:e},t)),getDeposit:t=>me.getDeposit(_({privy:e},t)),waitForDeposit:t=>me.waitForDeposit(_({privy:e},t)),waitForCompletion:t=>me.waitForCompletion(_({privy:e},t))}),[e])};import{useContext as Ln,useMemo as Fn}from"react";import{cryptoDepositAccount as Fe}from"@privy-io/js-sdk-core";var ku=()=>{let{client:e}=Ln(g);return Fn(()=>({createCryptoDepositAccount:t=>Fe.createCryptoDepositAccount(e,(...n)=>e.embeddedWallet.signWithUserSigner(...n),t),getQuote:t=>Fe.getCryptoDepositAccountQuote(e,t),getOrder:t=>Fe.getCryptoDepositAccountOrder(e,t),getNextOrder:t=>Fe.getCryptoDepositAccountNextOrder(e,t)}),[e])};import{useContext as Nn,useMemo as Vn}from"react";import{addSessionSigners as qn,removeSessionSigners as jn}from"@privy-io/js-sdk-core";import{isEmbeddedWalletAccount as Tn}from"@privy-io/js-sdk-core";function Dn(e,t){return e.linked_accounts.filter(Tn).find(n=>n.address===t)}function Z(e){let t=S();if(!t)throw new Error("User must be authenticated to perform this operation");let n=Dn(t,e);if(!n)throw new Error(`No wallet found with address ${e}`);return n}var Mu=()=>{let{client:e}=Nn(g);return Vn(()=>({addSessionSigners:({address:t,signers:n})=>qn({client:e,wallet:Z(t),signers:n.map(r=>({signer_id:r.signerId,override_policy_ids:r.policyIds}))}),removeSessionSigners:({address:t})=>jn({client:e,wallet:Z(t)})}),[e])};import{useContext as zn,useMemo as Gn}from"react";import{addSessionSigners as Kn,removeSessionSigners as Bn}from"@privy-io/js-sdk-core";var Vu=()=>{let{client:e}=zn(g);return Gn(()=>({addSigners:({address:t,signers:n})=>Kn({client:e,wallet:Z(t),signers:n.map(r=>({signer_id:r.signerId,override_policy_ids:r.policyIds}))}),removeSigners:({address:t})=>Bn({client:e,wallet:Z(t)})}),[e])};import{useContext as Hn,useMemo as Jn}from"react";import{PrivyClientError as Sr}from"@privy-io/js-sdk-core";var Bu=()=>{let{client:e}=Hn(g);return Jn(()=>({sendCode(r){return l(this,arguments,function*({newEmailAddress:n}){br(),yield e.auth.email.sendCode(n)})},updateEmail(i){return l(this,arguments,function*({newEmailAddress:n,code:r}){let{address:a}=br(),{user:o}=yield e.auth.email.updateEmail({oldEmailAddress:a,newEmailAddress:n,code:r});return o})}}),[e])};function br(){let t=$n().linked_accounts.find(n=>n.type==="email");if(!t)throw new Sr({code:"attempted_update_email_without_a_linked_email",error:"Must have a linked email account already to update an email address. Use `useLinkEmail` to link an email account."});return t}function $n(){let e=S();if(!e)throw new Sr({code:"attempted_update_before_logged_in",error:"Must be logged in to update a user profile."});return e}import{useContext as Qn,useMemo as Yn}from"react";import{PrivyClientError as Cr}from"@privy-io/js-sdk-core";var Zu=()=>{let{client:e}=Qn(g);return Yn(()=>({sendCode(r){return l(this,arguments,function*({newPhoneNumber:n}){Er(),yield e.auth.phone.sendCode(n)})},updatePhone(i){return l(this,arguments,function*({newPhoneNumber:n,code:r}){let{phoneNumber:a}=Er(),{user:o}=yield e.auth.phone.updatePhone({oldPhoneNumber:a,newPhoneNumber:n,code:r});return o})}}),[e])};function Er(){let t=Xn().linked_accounts.find(n=>n.type==="phone");if(!t)throw new Cr({code:"attempted_update_phone_without_a_linked_phone",error:"Must have a linked phone account already to update a phone number. Use `useLinkSMS` to link a phone number."});return t}function Xn(){let e=S();if(!e)throw new Cr({code:"attempted_update_before_logged_in",error:"Must be logged in to update a user profile."});return e}import*as Wr from"expo-linking";import{useCallback as ei,useContext as ti,useMemo as ri}from"react";import{crossApp as oi,PrivyClientError as ni}from"@privy-io/js-sdk-core";import*as kr from"expo-linking";import*as ye from"expo-web-browser";import{PrivyClientError as _r}from"@privy-io/js-sdk-core";var j=(e,t)=>l(void 0,null,function*(){let n=yield ye.openAuthSessionAsync(e,t,{createTask:!1});if(n.type!=="success")throw n.type===ye.WebBrowserResultType.CANCEL||n.type===ye.WebBrowserResultType.DISMISS?new _r({error:"OAuth session was cancelled",code:"oauth_session_failed"}):new _r({error:"OAuth session failed",code:"oauth_session_failed"});return Zn(n.url)});function Zn(e){let{queryParams:t}=kr.parse(e);return t}var up=()=>{let{client:e}=ti(g),t=ri(()=>oi.loginWithCrossAppAuth({client:e,openAuthSession:j}),[e]);return{loginWithCrossApp:ei(a=>l(void 0,[a],function*({appId:r,redirectUri:i}){if(S())throw new ni({code:"attempted_login_with_cross_app_while_already_logged_in",error:"Already logged in, use `linkCrossAppAccount` if you are trying to link a cross app account to an existing account"});let s=x(),{user:d}=yield t({providerAppId:r,redirectUrl:Wr.createURL(i||"/"),loginOptions:{embedded:s==null?void 0:s.embedded}});return{user:d}}),[t])}};import*as Ar from"expo-linking";import{useCallback as ii,useContext as ai,useMemo as si}from"react";import{crossApp as ci,PrivyClientError as di}from"@privy-io/js-sdk-core";var vp=()=>{let{client:e}=ai(g),t=si(()=>ci.linkWithCrossAppAuth({client:e,openAuthSession:j}),[e]);return{linkWithCrossApp:ii(a=>l(void 0,[a],function*({appId:r,redirectUri:i}){if(!S())throw new di({code:"attempted_link_cross_app_before_logged_in",error:"Must be logged in to link a cross app account, Use `loginWithCrossAppAccount` to login with cross app"});return{user:yield t({providerAppId:r,redirectUrl:Ar.createURL(i||"/")})}}),[t])}};import*as Pr from"expo-linking";import{useContext as li,useMemo as xr}from"react";import{crossApp as ui}from"@privy-io/js-sdk-core";var Ap=()=>{let{client:e}=li(g),t=xr(()=>ui.wallet.signMessage({client:e,openAuthSession:j}),[e]);return xr(()=>({signMessage:({address:n,message:r,redirectUri:i="/"})=>t({user:S(),address:n,message:r,redirectUrl:Pr.createURL(i)})}),[t])};import*as Rr from"expo-linking";import{useContext as pi,useMemo as Ur}from"react";import{crossApp as mi}from"@privy-io/js-sdk-core";var Mp=()=>{let{client:e}=pi(g),t=Ur(()=>mi.wallet.signTypedData({client:e,openAuthSession:j}),[e]);return Ur(()=>({signTypedData:({address:n,typedData:r,redirectUri:i="/"})=>t({user:S(),address:n,typedData:r,redirectUrl:Rr.createURL(i)})}),[t])};import*as Or from"expo-linking";import{useContext as yi,useMemo as Ir}from"react";import{crossApp as fi}from"@privy-io/js-sdk-core";var qp=()=>{let{client:e}=yi(g),t=Ir(()=>fi.wallet.sendTransaction({client:e,openAuthSession:j}),[e]);return Ir(()=>({sendTransaction:({address:n,transaction:r,redirectUri:i="/"})=>t({user:S(),address:n,transaction:r,redirectUrl:Or.createURL(i)})}),[t])};import{useCallback as gi,useContext as hi}from"react";import{getUserEmbeddedEthereumWallet as wi,getUserEmbeddedSolanaWallet as vi,isUnifiedWallet as bi,PrivyClientError as ee,throwIfInvalidRecoveryUpgradePath as Si}from"@privy-io/js-sdk-core";var $p=()=>{let{client:e}=hi(g);return{setRecovery:gi(n=>l(void 0,null,function*(){var s;let r=S(),i=e.app.appId;if(!r)throw new ee({code:"embedded_wallet_recovery_error",error:"User must be loaded before attempting to modify the recovery method."});let a=(s=wi(r))!=null?s:vi(r);if(!a)throw new ee({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});if(bi(a))throw new ee({code:"unsupported_wallet_type",error:"Embedded wallet recovery is only supported for on-device execution and this app uses TEE execution. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide"});try{a.chain_type==="ethereum"?yield e.embeddedWallet.getEthereumProvider({wallet:a,entropyId:a.address,entropyIdVerifier:"ethereum-address-verifier"}):a.chain_type==="solana"&&(yield e.embeddedWallet.getSolanaProvider(a,a.address,"solana-address-verifier"))}catch(d){throw new ee({code:"attempted_to_set_password_before_connected",error:"Embedded wallet must be connected before setting password"})}Si({currentRecoveryMethod:a.recovery_method,upgradeToRecoveryMethod:n.recoveryMethod});let o=yield Ei({appId:i,client:e,user:r,primaryAccount:a,recoveryParams:n});try{let{user:d}=yield e.embeddedWallet.setRecovery(o);return{user:d}}catch(d){throw new ee({code:"embedded_wallet_set_recovery_error",error:d instanceof Error?d.message:"Error setting password on embedded wallet"})}}),[e])}},Ei=a=>l(void 0,[a],function*({appId:e,client:t,user:n,primaryAccount:r,recoveryParams:i}){switch(i.recoveryMethod){case"privy":return{recoveryMethod:"privy",wallet:r};case"user-passcode":return T(_({},i),{wallet:r});case"google-drive":{let o=yield Ie(t);return{recoveryMethod:"google-drive",wallet:r,recoveryAccessToken:o}}case"icloud":{let{recoverySecret:o,iCloudRecordName:s}=yield ce({appId:e,client:t,user:n});return{recoveryMethod:"icloud-native",recoverySecretOverride:o,iCloudRecordNameOverride:s,wallet:r}}case"recovery-encryption-key":return{recoveryMethod:"recovery-encryption-key",wallet:r,recoveryKey:i.recoveryKey};default:throw new ee({code:"embedded_wallet_recovery_error",error:"Unrecognized recovery method"})}});import{useCallback as Ci,useContext as _i}from"react";import{getUserEmbeddedEthereumWallet as ki,getUserEmbeddedSolanaWallet as Wi,PrivyClientError as fe,isUnifiedWallet as Ai}from"@privy-io/js-sdk-core";var nm=()=>{let{client:e}=_i(g);return{recover:Ci(n=>l(void 0,null,function*(){var c;let r=S();if(!r)throw new fe({code:"embedded_wallet_recovery_error",error:"User must be loaded before attempting to modify the recovery method."});let i=(c=ki(r))!=null?c:Wi(r);if(!i)throw new fe({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});if(Ai(i))throw new fe({code:"unsupported_wallet_type",error:"User owned wallet recovery is only supported for on-device execution and this app uses TEE execution. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide"});let a,o,s,d;switch(n.recoveryMethod){case"user-passcode":o=n.password;break;case"google-drive":s=yield Ie(e);break;case"icloud":let{recoverySecret:u}=yield Pe({client:e,walletAddress:i.address,chainType:i.chain_type});d=u;break;case"recovery-encryption-key":a=n.recoveryKey;break;case"privy":break;default:throw new fe({code:"unsupported_recovery_method",error:`Unsupported recovery options ${n}`})}try{i.chain_type==="ethereum"?yield e.embeddedWallet.getProvider(i,o,s,d,a):i.chain_type==="solana"&&(yield e.embeddedWallet.getSolanaProvider(i,i.address,"solana-address-verifier",o,s,d))}catch(u){throw new fe({code:"attempted_to_set_password_before_connected",error:"Embedded wallet must be connected before setting password"})}}),[e])}};import{useEffect as Pi}from"react";import{useContext as xi,useEffect as at}from"react";var st=(e={})=>{let{wallet:t,createWalletCallbacks:n,recoverWalletCallbacks:r,setWalletRecoveryCallbacks:i}=xi(g),{onCreateWalletSuccess:a,onCreateWalletError:o,onRecoverWalletError:s,onRecoverWalletSuccess:d,onSetWalletRecoverySuccess:c,onSetWalletRecoveryError:u}=e;return at(()=>{n.current={onSuccess:a,onError:o}},[a,o]),at(()=>{r.current={onSuccess:d,onError:s}},[d,s]),at(()=>{i.current={onSuccess:c,onError:u}},[d,s]),t};var pm=({onStateChange:e})=>{let t=st();return Pi(()=>{e(t)},[t])};import{useContext as Ui}from"react";var gm=()=>{let{getIdentityToken:e}=Ui(g);return{getIdentityToken:e}};import{useCallback as Mr,useContext as Ri}from"react";import{PrivyClientError as Ii}from"@privy-io/js-sdk-core";var _m=e=>{let{client:t}=Ri(g),n=Mr(i=>{var o;let a=C(i);return(o=e==null?void 0:e.onError)==null||o.call(e,a),a},[e==null?void 0:e.onError]);return{create:Mr(()=>l(void 0,null,function*(){var i;try{if(S())throw new Ii({code:"attempted_to_create_guest_account_for_logged_in_user",error:"Already logged in, you cannot create a guest account"});let o=x(),s=yield t.auth.guest.create({embedded:o==null?void 0:o.embedded});return(i=e==null?void 0:e.onSuccess)==null||i.call(e,s.user,s.is_new_user),s.user}catch(a){throw n(a)}}),[t,n,e==null?void 0:e.onSuccess])}};import{useContext as Oi,useEffect as Lr,useRef as Mi}from"react";var Um=({onMfaRequired:e,onMfaEnrollmentRequired:t,onMfaVerificationRequired:n})=>{let{client:r}=Oi(g),i=Mi(Symbol("mfa-listener")).current;Lr(()=>{let a=[],o=()=>a.forEach(s=>s());try{t&&a.push(Ut({fn:t,lock:i})),n&&a.push(Rt({fn:n,lock:i}))}catch(s){throw o(),s}return o},[i,t,n]),Lr(()=>{if(!e)return;let a=()=>l(void 0,null,function*(){var s;let o=S();yield e((s=o==null?void 0:o.mfa_methods.map(({type:d})=>d).filter(d=>d!=="email"))!=null?s:[])});return r.mfaPromises.on("mfaRequired",a),()=>{r.mfaPromises.off("mfaRequired",a)}},[r,e])};import{useCallback as ge,useContext as qi}from"react";import{PrivyClientError as De}from"@privy-io/js-sdk-core";import{PrivyClientError as Li}from"@privy-io/js-sdk-core";function Te(){return l(this,null,function*(){xe("react-native-passkeys");try{return yield import("react-native-passkeys")}catch(e){return Promise.reject(e)}})}var Fi=(e,t)=>l(void 0,null,function*(){var i;let r=yield(yield Te()).create(Ti(e,t));if(!r)throw new Li({code:"failed_to_create_passkey",error:"Could not create passkey"});return T(_({},r),{type:(i=r.type)!=null?i:"public-key",clientExtensionResults:{}})});function Ti(e,t){return T(_({},t),{rp:e.rp,user:e.user,challenge:e.challenge,pubKeyCredParams:e.pubKeyCredParams,excludeCredentials:e.excludeCredentials,authenticatorSelection:e.authenticatorSelection,timeout:12e4,attestation:void 0})}import{PrivyClientError as Di}from"@privy-io/js-sdk-core";var dt=(e,t)=>l(void 0,null,function*(){var i;let r=yield(yield Te()).get(Ni(e,t));if(!r)throw new Di({code:"no_passkey_found_for_challenge",error:"Could not find a matching passkey to login with"});return T(_({},r),{type:(i=r.type)!=null?i:"public-key",clientExtensionResults:{}})});function Ni(e,t){return T(_({},t),{rpId:e.rpId,challenge:e.challenge,allowCredentials:e.allowCredentials,userVerification:e.userVerification,timeout:12e4})}function Fr(e){var t;return{id:e.id,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},raw_id:e.rawId,type:e.type,authenticator_attachment:(t=e.authenticatorAttachment)!=null?t:"platform",response:{authenticator_data:e.response.authenticatorData,client_data_json:e.response.clientDataJSON,signature:e.response.signature,user_handle:e.response.userHandle}}}function Tr(e){var t,n,r,i;return{challenge:e.challenge,rpId:e.rp_id,extensions:{appid:(t=e.extensions)==null?void 0:t.app_id,credProps:(n=e.extensions)==null?void 0:n.cred_props,hmacCreateSecret:(r=e.extensions)==null?void 0:r.hmac_create_secret},timeout:e.timeout,allowCredentials:(i=e.allow_credentials)==null?void 0:i.map(({id:a,type:o,transports:s})=>({id:a,type:o,transports:s})),userVerification:e.user_verification}}function $m(e){var t,n,r,i,a,o,s,d;return{rp:e.rp,user:{id:e.user.id,name:e.user.name,displayName:e.user.display_name},challenge:e.challenge,pubKeyCredParams:e.pub_key_cred_params,extensions:{hmacCreateSecret:(t=e.extensions)==null?void 0:t.hmac_create_secret,credProps:(r=(n=e.extensions)==null?void 0:n.cred_props)==null?void 0:r.rk,appid:(i=e.extensions)==null?void 0:i.app_id},attestation:e.attestation,excludeCredentials:e.exclude_credentials,authenticatorSelection:{authenticatorAttachment:(a=e.authenticator_selection)==null?void 0:a.authenticator_attachment,residentKey:(o=e.authenticator_selection)==null?void 0:o.resident_key,userVerification:(s=e.authenticator_selection)==null?void 0:s.user_verification,requireResidentKey:(d=e.authenticator_selection)==null?void 0:d.require_resident_key}}}function ty(){let{client:e}=qi(g),t=ge(o=>l(this,null,function*(){var s,d;switch(o.method){case"sms":yield e.mfa.sms.sendCode({action:"verify"});return;case"passkey":let{options:c}=yield e.mfa.passkey.generateAuthenticationOptions({relying_party:o.relyingParty||((d=(s=x())==null?void 0:s.mfa)==null?void 0:d.relyingParty)});return Tr(c);case"totp":return;default:throw new Error(`Unsupported MFA method: ${o.mfaMethod}`)}}),[e]),n=ge(o=>l(this,null,function*(){var s,d,c,u,p,m,w;switch(o.method){case"totp":case"sms":if(typeof o.mfaCode!="string")throw new De({code:"invalid_mfa_code",error:"Invalid MFA code"});(c=e.mfaPromises.rootPromise.current)==null||c.resolve({mfaMethod:o.method,mfaCode:o.mfaCode,relyingParty:o.relyingParty||((d=(s=x())==null?void 0:s.mfa)==null?void 0:d.relyingParty)||""}),yield new Promise((f,b)=>{e.mfaPromises.submitPromise.current={resolve:f,reject:b}});break;case"passkey":if(typeof o.mfaCode=="string")throw new De({code:"invalid_passkey_response",error:"Invalid authenticator response"});let v=yield dt(o.mfaCode),h=Fr(v);(m=e.mfaPromises.rootPromise.current)==null||m.resolve({mfaMethod:o.method,relyingParty:o.relyingParty||((p=(u=x())==null?void 0:u.mfa)==null?void 0:p.relyingParty)||"",mfaCode:h}),yield new Promise((f,b)=>{e.mfaPromises.submitPromise.current={resolve:f,reject:b}});break;default:let y=new De({code:"unsupported_mfa_method",error:"Unsupported MFA method"});throw(w=e.mfaPromises.rootPromise.current)==null||w.reject(y),y}}),[e]),r=ge(()=>l(this,null,function*(){let o=S();!o||o.mfa_methods.length===0||(yield e.mfa.verifyMfa())}),[e]),i=ge(()=>{var o;(o=e.mfaPromises.rootPromise.current)==null||o.reject(new De({code:"mfa_canceled",error:"MFA canceled"}))},[e]),a=ge(()=>l(this,null,function*(){let o=S();o&&(yield e.mfa.clearMfa({userId:o.id}))}),[e]);return{init:t,submit:n,prompt:r,cancel:i,clear:a}}import{useCallback as lt,useContext as ji}from"react";function ay(){let{client:e}=ji(g),t=lt(i=>l(this,null,function*(){switch(i.method){case"sms":case"totp":return yield e.mfa.initEnrollMfa(i);case"passkey":return;default:throw new Error(`Unsupported MFA method: ${i.method}`)}}),[e]),n=lt(i=>l(this,null,function*(){switch(i.method){case"sms":case"totp":case"passkey":yield e.mfa.submitEnrollMfa(i);return;default:throw new Error(`Unsupported MFA method: ${i.method}`)}}),[e]),r=lt(i=>l(this,null,function*(){switch(i.method){case"sms":case"totp":yield e.mfa.unenrollMfa(i.method);return;case"passkey":yield e.mfa.submitEnrollMfa({method:"passkey",credentialIds:[],removeForLogin:i.removeForLogin});return;default:throw new Error(`Unsupported MFA method: ${i.method}`)}}),[e]);return{initMfaEnrollment:t,submitMfaEnrollment:n,unenrollMfa:r}}import{useCallback as zi,useContext as Gi}from"react";function uy(){let{client:e}=Gi(g);return{unlink:zi(i=>l(this,[i],function*({credentialId:n,removeAsMfa:r}){yield e.mfa.unlinkPasskey({credentialId:n,removeAsMfa:r})}),[e])}}import{useCallback as Ki}from"react";import{areAddressesEqual as Bi}from"@privy-io/are-addresses-equal";import{getAllUserEmbeddedEthereumWallets as Hi,getAllUserEmbeddedSolanaWallets as Ji,PrivyClientError as $i}from"@privy-io/js-sdk-core";var wy=()=>{let e=A();return{importWallet:Ki(a=>l(void 0,[a],function*({privateKey:n,chainType:r,additionalSigners:i}){let{address:o,user:s}=yield e.embeddedWallet.importWallet({privateKey:n,chainType:r,additionalSigners:i}),c=(r==="solana"?Ji(s.user):Hi(s.user)).find(u=>Bi(u.address,o));if(!c)throw new $i({code:"embedded_wallet_creation_error",error:"Failed to import wallet"});return{user:s.user,wallet:c}}),[e])}};import{useCallback as Qi,useMemo as Dr}from"react";import{getAllUserEmbeddedEthereumWallets as ut,getEntropyDetailsFromUser as Nr,getUserEmbeddedSolanaWallet as Yi,PrivyClientError as pt}from"@privy-io/js-sdk-core";var mt=()=>{let e=U(),t=A(),n=Dr(()=>{let a=ut(e).map(o=>{let s=Nr(e,o);return s?{account:o,entropy:s}:null});return a.some(o=>o===null)?[]:a.filter(o=>o!==null).map(({account:o,entropy:{entropyId:s,entropyIdVerifier:d}})=>({address:o.address,walletIndex:o.wallet_index,chainType:o.chain_type,getProvider:()=>t.embeddedWallet.getEthereumProvider({wallet:o,entropyId:s,entropyIdVerifier:d,onMfaEnrollmentRequired:c=>l(void 0,null,function*(){return yield R()(c)}),onMfaVerificationRequired:c=>l(void 0,null,function*(){return yield I()(c)}),onNeedsRecovery:c=>l(void 0,null,function*(){var u;yield(u=Ce())==null?void 0:u(c)})})}))},[t,e]),r=Qi((...a)=>l(void 0,[...a],function*({createAdditional:i=!1}={}){var p,m,w;let{user:o}=yield t.user.get(),s=ut(o);if(!i&&s.length>0)throw new pt({code:"embedded_wallet_creation_error",error:"Wallet already exists for this user. Set `createAdditional` to `true` to create another wallet"});if(s.length===0){let v=(p=Yi(o))!=null?p:void 0,h=yield t.embeddedWallet.create(v?{solanaAccount:v}:{});return Xi(h.user),{user:h.user}}let d=Nr(o),c=s.map(v=>v.wallet_index).reduce((v,h)=>Math.max(v,h),0)+1,u=yield t.embeddedWallet.add({chainType:"ethereum",hdWalletIndex:c,entropyId:(m=d==null?void 0:d.entropyId)!=null?m:"",entropyIdVerifier:(w=d==null?void 0:d.entropyIdVerifier)!=null?w:"ethereum-address-verifier"});if(!u.account||u.account.chain_type!=="ethereum")throw new pt({code:"embedded_wallet_creation_error",error:"Unknown error creating wallet"});return{user:u.user}}),[t]);return Dr(()=>({wallets:n,create:r}),[n,r])};function Xi(e){if(!e||ut(e).length===0)throw new pt({code:"embedded_wallet_creation_error",error:"Unknown error creating wallet"})}import{useContext as Zi,useEffect as Vr}from"react";var ea=(e={})=>{let{solanaWallet:t,createSolanaWalletCallbacks:n,recoverSolanaWalletCallbacks:r}=Zi(g),{onCreateWalletSuccess:i,onCreateWalletError:a,onRecoverWalletError:o,onRecoverWalletSuccess:s}=e;return Vr(()=>{n.current={onSuccess:i,onError:a}},[i,a]),Vr(()=>{r.current={onSuccess:s,onError:o}},[s,o]),t};import{useCallback as ta,useMemo as ra}from"react";import{getAllUserEmbeddedBitcoinWallets as qr,getEntropyDetailsFromUser as jr,isUnifiedWallet as oa,PrivyClientError as te}from"@privy-io/js-sdk-core";var na=()=>{let e=U(),t=A(),n=ra(()=>{let i=jr(e);if(!i)return[];let a=qr(e),{entropyId:o,entropyIdVerifier:s}=i;return a.map(d=>({address:d.address,walletIndex:d.wallet_index,publicKey:d.public_key,chainType:d.chain_type,getProvider:()=>oa(d)?Promise.reject(new te({code:"unsupported_wallet_type",error:"Bitcoin wallet providers are only supported for on-device execution and this app uses TEE execution. Use the useSignRawHash hook from @privy-io/expo/extended-chains to sign over a hash with this wallet. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide"})):t.embeddedWallet.getBitcoinProvider({wallet:d,entropyId:o,entropyIdVerifier:s})}))},[t,e]),r=ta(o=>l(void 0,[o],function*({chainType:i,createAdditional:a=!1}){var y;let s=t.app.getConfig();if(((y=s==null?void 0:s.embedded_wallet_config)==null?void 0:y.mode)==="user-controlled-server-wallets-only")throw i==="bitcoin-segwit"?new te({code:"unsupported_wallet_type",error:"This app uses TEE execution. Use the useCreateWallet hook from @privy-io/expo/extended-chains to create the wallet instead. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide"}):new te({code:"unsupported_wallet_type",error:`Bitcoin (${i}) wallets are only supported for on-device execution and this app uses TEE execution. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide`});let{user:d}=yield t.user.get(),c=jr(d);if(!c)throw new te({code:"embedded_wallet_creation_error",error:"No existing wallet for this user, create an Ethereum walet first to add a Bitcoin wallet"});let{entropyId:u,entropyIdVerifier:p}=c,m=qr(d).filter(f=>f.chain_type===i);if(!a&&m.length>0)throw new te({code:"embedded_wallet_creation_error",error:"Wallet already exists for this user. Set `createAdditional` to `true` to create another wallet"});let w=m.length===0?0:Math.max(...m.map(f=>f.wallet_index),0)+1,v=yield t.embeddedWallet.add({chainType:i,hdWalletIndex:w,entropyId:u,entropyIdVerifier:p}),h=v.account;if(!v.user||!h||h.chain_type!=="bitcoin-segwit"&&h.chain_type!=="bitcoin-taproot"||h.chain_type!==i)throw new te({code:"embedded_wallet_creation_error",error:"Unknown error creating wallet"});return{user:v.user,provider:yield t.embeddedWallet.getBitcoinProvider({wallet:T(_({},h),{chain_type:h.chain_type}),entropyId:u,entropyIdVerifier:p})}}),[t]);return{wallets:n,create:r}};import{useContext as ia}from"react";var yt=()=>{let{isReady:e,logout:t,getAccessToken:n,error:r,client:i}=ia(g);return{user:U(),isReady:e,error:r,logout:t,getAccessToken:n,refreshUser:()=>i.user.refreshUser()}};import{useContext as aa}from"react";function sa(){let{client:e}=aa(g);return{acceptTerms:()=>l(this,null,function*(){return e.user.acceptTerms()})}}import{useMemo as ca}from"react";import{generateAuthorizationSignature as da}from"@privy-io/js-sdk-core";var la=()=>{let e=A();return ca(()=>({generateAuthorizationSignature(n){return l(this,null,function*(){let{signature:r}=yield da((...i)=>e.embeddedWallet.signWithUserSigner(...i),n);return{signature:r}})}}),[e])};import{useContext as ua,useMemo as pa}from"react";import{GetEncryptedAuthorizationKey as ma}from"@privy-io/routes";var Zy=()=>{let{client:e}=ua(g);return pa(()=>({getEncryptedAuthorizationKey:({id:t})=>e.fetchPrivyRoute(ma,{params:{encrypted_authorization_key_id:t}})}),[e])};import{useCallback as ya}from"react";import{createWalletClient as fa,getAddress as zr,http as ga,parseSignature as ha,zeroAddress as wa}from"viem";import{hashAuthorization as va}from"viem/utils";import{getAllUserEmbeddedEthereumWallets as ba,getJsonRpcEndpointFromChain as Sa}from"@privy-io/js-sdk-core";var Ea=()=>{let e=U(),{wallets:t}=mt(),n=A();return{signAuthorization:ya((i,a)=>l(void 0,null,function*(){var p,m,w;if(!e)throw new Error("User must be authenticated before signing with a Privy wallet");let o=(w=(m=a==null?void 0:a.address)!=null?m:(p=ba(e)[0])==null?void 0:p.address)!=null?w:wa,s=t.find(v=>zr(v.address)===zr(o));if(!s)throw new Error("Signing wallet not found.");let d;if(i.chainId===0){if(i.nonce===void 0)throw new Error("nonce is required when chainId is 0 \u2014 chain-agnostic authorizations are replayable across networks");d={chainId:0,address:i.contractAddress,nonce:i.nonce}}else{let h=n.embeddedWallet.chains.find(b=>b.id===i.chainId);if(!h)throw new Error("Error, chain not configured in PrivyProvider config");let y=Sa(h,{},n.app.appId);d=yield fa({account:o,chain:h,transport:ga(y)}).prepareAuthorization(_({},i))}let u=yield(yield s.getProvider()).request({method:"secp256k1_sign",params:[va(d)]});return _(_({},d),ha(u))}),[t,e,n])}};import{useMemo as Ca}from"react";import{transfer as _a}from"@privy-io/js-sdk-core";var ka=()=>{let e=A();return Ca(()=>({transfer:(t,n)=>_a(e,(...r)=>e.embeddedWallet.signWithUserSigner(...r),_({wallet_id:t},n))}),[e])};import{useMemo as Wa}from"react";import{PrivyClientError as Aa,updateWallet as xa}from"@privy-io/js-sdk-core";var Pa=()=>{let e=A();return Wa(()=>({updateWallet:(t,n)=>l(void 0,null,function*(){yield xa(e,{wallet_id:t},(...a)=>e.embeddedWallet.signWithUserSigner(...a),n);let{user:r}=yield e.user.refreshUser(),i=r==null?void 0:r.linked_accounts.find(a=>a.type==="wallet"&&"id"in a&&a.id===t);if(!i)throw new Aa({code:"embedded_wallet_does_not_exist",error:"Updated wallet was not found in the refreshed user."});return{wallet:i}})}),[e])};import{useMemo as Ua}from"react";import{getWalletAction as Ra,listWalletActions as Ia}from"@privy-io/js-sdk-core";var Oa=()=>{let e=A();return Ua(()=>({getAction:(t,n)=>Ra(e,{wallet_id:t,action_id:n}),listActions:(t,n)=>Ia(e,_({wallet_id:t},n))}),[e])};import{useMemo as Ma}from"react";var La=()=>{let e=Ot();return Ma(()=>({users:e}),[e])};import{useMemo as Fa}from"react";var Ta=()=>{let e=A();return Fa(()=>({switchUser:n=>l(void 0,[n],function*({userId:t}){return yield e.user.switchActiveUser({userId:t})})}),[e])};import{useCallback as ja}from"react";import{PrivyClientError as za}from"@privy-io/js-sdk-core";import{getAllUserEmbeddedBitcoinWallets as Da,getUserEmbeddedEthereumWallet as Na,getUserEmbeddedSolanaWallet as Va,isEmbeddedWalletAccount as qa,isUnifiedWallet as Gr}from"@privy-io/js-sdk-core";function Kr(e,t){return l(this,null,function*(){var i,a;let n=t.linked_accounts.filter(qa).filter(o=>!o.imported&&!Gr(o)).filter(o=>o.chain_type==="ethereum"||o.chain_type==="solana"),r=(i=n.find(o=>o.chain_type==="ethereum"&&o.wallet_index===0))!=null?i:n.find(o=>o.chain_type==="solana"&&o.wallet_index===0);if(!r){let o=(a=Na(t))!=null?a:Va(t);if(o!=null&&o.imported&&!Gr(o))throw new Error("Imported wallets cannot be migrated");return{success:!0,migrated:!1}}if(Da(t).length>0)throw new Error("Bitcoin wallets cannot be migrated");return r.chain_type==="ethereum"?yield e.embeddedWallet.getProvider(r):r.chain_type==="solana"&&(yield e.embeddedWallet.getSolanaProvider(r,r.address,"solana-address-verifier")),yield e.embeddedWallet.delegateWallets({rootWallet:{address:r.address,chainType:r.chain_type,imported:r.imported},delegatedWallets:n.map(o=>({address:o.address,chainType:o.chain_type,walletIndex:o.wallet_index}))}),yield e.user.get(),{success:!0,migrated:!0}})}var Br=()=>{let e=A();return{migrate:ja(()=>l(void 0,null,function*(){var a;let n=S(),r=e.app.getConfig();if(((a=r==null?void 0:r.embedded_wallet_config)==null?void 0:a.mode)!=="user-controlled-server-wallets-only")return{success:!0};if(!n)throw new za({code:"embedded_wallet_before_logged_in",error:"User must be authenticated before migrating wallets"});return Kr(e,n)}),[e])}};var Hr=({disabled:e})=>{let{migrate:t}=Br(),{user:n}=yt(),r=Ka(!1);return Ga(()=>{e||n&&(r.current||(r.current=!0,t().then(i=>{i.migrated&&!r.current&&(console.info("Migrated wallets for user"),r.current=!0)}).catch(i=>{console.debug("Unable to migrate wallets: ",i)}).finally(()=>{r.current=!1})))},[t,n,e]),null};var g=Ha(null),oe;function ah(e){return oe?oe.getAccessToken():e!=null&&e.strict?Promise.reject(new Qr({code:"attempted_to_read_storage_before_client_initialized",error:"Called `getAccessToken` before client initialized"})):(console.warn("Called `getAccessToken` before client initialized"),Promise.resolve(null))}var sh=e=>{var wt,vt,bt;Qa();let[t,n]=D($r.currentState==="active");Jr(()=>{let F=$r.addEventListener("change",no=>{n(no==="active")});return()=>{F.remove()}},[]),Jr(()=>At(e.config),[e.config]);let[r,i]=D(!1),[a,o]=D(null),[s,d]=D(!1),[c,u]=D({status:"disconnected",account:null}),[p,m]=D({status:"disconnected"}),[w,v]=D({status:"initial"}),[h,y]=D({status:"initial"}),[f,b]=D({status:"initial"}),[E,W]=D({status:"initial"}),[k,P]=D({status:"initial"}),[N,we]=D({status:"initial"}),[ve,Ve]=D({status:"initial"}),ne=he({}),qe=he({}),je=he({}),gt=he({}),ht=he({}),be=Ne(F=>{if(F){Ge(F),o(null);return}Ge(null),v({status:"initial"}),y({status:"initial"}),u({status:"disconnected",account:null})},[]),L=Ba(()=>{let F=e.storage||Ee;return e.client?oe=e.client:oe=Wt({appId:e.appId,clientId:e.clientId,supportedChains:e.supportedChains,storage:F,baseUrl:e.baseUrl,logLevel:e.logLevel}),oe.setCallbacks({setUser:be,setIsReady:d,setStoredUsers:It}),oe},[e.client,e.storage,e.appId,e.clientId,e.baseUrl,e.supportedChains,e.logLevel,be]),Yr=Ne(()=>l(void 0,null,function*(){let F=S();yield L.auth.logout(F?{userId:F==null?void 0:F.id}:void 0),be(null)}),[be,L]),Xr=Ne(()=>l(void 0,null,function*(){try{return yield L.getAccessToken()}catch(F){return console.debug(F),null}}),[L]),Zr=Ne(()=>L.getIdentityToken(),[L]);Gt({client:L,setIsUserInitialized:i,setError:o});let eo=ir({client:L,appId:e.appId,createWalletCallbacks:ne,recoverWalletCallbacks:qe,setWalletRecoveryCallbacks:je,setRecoveryFlowState:b,wallet:c,setWallet:u}),to=Qt({client:L,createSolanaWalletCallbacks:gt,recoverSolanaWalletCallbacks:ht,setSolanaRecoveryFlowState:W,solanaWallet:p,setSolanaWallet:m});cr({client:L,createWalletCallbacks:ne,recoverWalletCallbacks:qe,setWalletRecoveryCallbacks:je,recoveryFlowState:f,oAuthState:h,setRecoveryFlowState:b,setWallet:u,appStateVisible:t});let{customAuthStateIsSettled:ro}=sr({client:L,isReady:r}),oo=z();return re.createElement(re.Fragment,null,re.createElement(g.Provider,{value:{client:L,isReady:oo&&r&&ro,error:a,logout:Yr,getAccessToken:Xr,getIdentityToken:Zr,wallet:_(_({},c),eo),solanaWallet:_(_({},p),to),oAuthState:h,recoveryFlowState:f,setRecoveryFlowState:b,solanaRecoveryFlowState:E,setSolanaRecoveryFlowState:W,createWalletCallbacks:ne,recoverWalletCallbacks:qe,setWalletRecoveryCallbacks:je,createSolanaWalletCallbacks:gt,recoverSolanaWalletCallbacks:ht,setOAuthState:y,siweState:k,setSiweState:P,otpState:w,setOtpState:v,passkeyState:N,setPasskeyState:we,farcasterState:ve,setFarcasterState:Ve}},e.children,re.createElement(Hr,{disabled:(bt=(vt=(wt=e.config)==null?void 0:wt.embedded)==null?void 0:vt.disableAutomaticMigration)!=null?bt:!1})),re.createElement($a,{style:{width:0,height:0,overflow:"hidden"}},re.createElement(Tt,{client:L,isClientReady:s})))},Qa=()=>{if(Ja(g))throw new Qr({code:"configuration_error",error:"Found multiple instances of PrivyProvider, ensure there is only one mounted in your application tree."})};var fh=e=>{let{client:t,setSiweState:n,siweState:r}=Ya(g),i=ft(s=>{var c;let d=C(s);return n({status:"error",error:d}),(c=e==null?void 0:e.onError)==null||c.call(e,d),d},[e==null?void 0:e.onError]),a=ft(u=>l(void 0,[u],function*({wallet:s,from:{domain:d,uri:c}}){var p;try{n({status:"generating-message"});let m=yield t.auth.siwe.init(s,d,c);return n({status:"awaiting-signature"}),(p=e==null?void 0:e.onGenerateMessage)==null||p.call(e,m.message),m.message}catch(m){throw i(m)}}),[t,i,e==null?void 0:e.onGenerateMessage]),o=ft(c=>l(void 0,[c],function*({signature:s,messageOverride:d}){var u;try{if(!S())throw new Xa({code:"attempted_link_siwe_before_logged_in",error:"Must be logged in to link a wallet, Use `useLoginWithSiwe` to login with a wallet"});n({status:"submitting-signature"});let{user:m}=yield t.auth.siwe.linkWithSiwe(s,void 0,d);return n({status:"done"}),(u=e==null?void 0:e.onSuccess)==null||u.call(e,m),m}catch(p){throw i(p)}}),[t,i,e==null?void 0:e.onSuccess]);return{generateSiweMessage:a,linkWithSiwe:o,state:r}};export{x as a,R as b,I as c,S as d,gs as e,U as f,hs as g,C as h,so as i,xe as j,Q as k,Wt as l,fh as m,fd as n,A as o,Wd as p,Ld as q,zd as r,Yd as s,ol as t,pl as u,bl as v,Pl as w,Tl as x,zl as y,Xl as z,cu as A,yu as B,vu as C,ku as D,Mu as E,Vu as F,Bu as G,Zu as H,up as I,vp as J,Ap as K,Mp as L,qp as M,$p as N,nm as O,st as P,pm as Q,gm as R,_m as S,Um as T,Fi as U,dt as V,$m as W,ty as X,ay as Y,uy as Z,wy as _,mt as $,ea as aa,na as ba,yt as ca,sa as da,la as ea,Zy as fa,Ea as ga,ka as ha,Pa as ia,Oa as ja,La as ka,Ta as la,Br as ma,g as na,ah as oa,sh as pa};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{d as u,o as i}from"./chunk-V3WU67WL.js";import"./chunk-F7DR7TVR.js";import"./chunk-3HF374LL.js";import{e as a}from"./chunk-C5WYSLQF.js";import{useMemo as d}from"react";import{create as g}from"@privy-io/js-sdk-core";var f=()=>{let e=i();return d(()=>({createWallet(n){return a(this,null,function*(){let s=yield g(e,{request:{chain_type:n.chainType}}),{user:o}=yield e.user.get();return{user:o,wallet:s}})}}),[e])};import{useMemo as h}from"react";import{isEmbeddedWalletAccount as m,isUnifiedWallet as w,PrivyClientError as c,rawSign as y}from"@privy-io/js-sdk-core";var C=()=>{let e=i();return h(()=>({signRawHash(k){return a(this,arguments,function*({address:n,chainType:s,hash:o}){let l=u();if(!l)throw new c({code:"embedded_wallet_before_logged_in",error:"User must be authenticated before signing a raw hash"});let p=l.linked_accounts.filter(m).filter(w).filter(t=>t.chain_type===s).find(t=>t.address===n);if(!p)throw new c({code:"embedded_wallet_does_not_exist",error:"No embedded wallet found for the given address and chain type"});let r=yield y(e,(...t)=>e.embeddedWallet.signWithUserSigner(...t),{wallet_id:p.id,params:{hash:o}});if(r.data&&"signature"in r.data&&r.data.encoding==="hex")return{signature:r.data.signature};throw new Error("Failed to sign")})}}),[e])};export{f as useCreateWallet,C as useSignRawHash};
|
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Dt,b as Gt,c as jt,d as Et,e as _t,f as Bt,g as Mt,h as qt}from"./chunk-QSWCX5XI.js";import{a as f,b as I}from"./chunk-
|
|
1
|
+
import{a as Dt,b as Gt,c as jt,d as Et,e as _t,f as Bt,g as Mt,h as qt}from"./chunk-QSWCX5XI.js";import{a as f,b as I}from"./chunk-QAUM76HK.js";import{$ as vt,A as $,B as tt,C as et,D as ot,E as rt,F as nt,G as ut,H as it,I as pt,J as st,K as ht,L as at,M as ft,N as At,O as Ot,P as ct,Q as mt,R as kt,S as lt,T as yt,X as xt,Y as dt,Z as Ut,_ as Pt,aa as wt,ba as It,ca as d,da as Tt,ea as gt,fa as Ft,g as y,ga as St,h as x,ha as Lt,i as G,ia as Wt,ja as Rt,ka as Ht,l as v,la as Ct,m as j,ma as w,n as E,na as a,o as _,oa as Nt,p as B,pa as bt,q as M,r as q,s as z,t as J,u as K,v as Q,w as V,x as X,y as Y,z as Z}from"./chunk-V3WU67WL.js";import{c as P}from"./chunk-F7DR7TVR.js";import"./chunk-3HF374LL.js";import{b as m,c as k,e as l}from"./chunk-C5WYSLQF.js";export*from"@privy-io/js-sdk-core";import r from"react";var Qt=({loading:t,error:e,unauthenticated:o,children:i})=>{let{isReady:u,error:p}=d(),U=y();if(!u)return r.createElement(r.Fragment,null,t);if(p&&e){let n=typeof e=="function"?e(p):e;return r.createElement(r.Fragment,null,n)}return U?r.createElement(r.Fragment,null,i):r.createElement(r.Fragment,null,o)};import{createDataSuffixPlugin as T}from"@privy-io/js-sdk-core";function g(t){return f(t)}function F(t){let{state:e,start:o}=f(k(m({},t),{action:"link"}));return{state:e,link:o}}import{useCallback as S,useContext as L,useEffect as W,useRef as R}from"react";var H=t=>{let{client:e}=L(a),o=R(t);return W(()=>{o.current=t},[t]),{unlinkOAuth:S(U=>l(void 0,[U],function*({provider:u,subject:p}){var n,A,s,O;try{let{user:h}=yield e.auth.oauth.unlink(u,p);return(A=(n=o.current)==null?void 0:n.onSuccess)==null||A.call(n,h),h}catch(h){let c=x(h);throw(O=(s=o.current)==null?void 0:s.onError)==null||O.call(s,c),c}}),[e.auth.oauth])}};import{useContext as C,useEffect as N,useRef as b}from"react";var D=t=>{let{client:e}=C(a),o=b(t.onOAuthTokenGrant);o.current=t.onOAuthTokenGrant,N(()=>{let{unsubscribe:i}=e.addOAuthTokensListener(u=>{o.current(u)});return i},[e])};export{Qt as AuthBoundary,a as PrivyContext,bt as PrivyProvider,P as SecureStorageAdapter,v as createPrivyClient,T as dataSuffix,Nt as getAccessToken,Mt as hasError,Dt as isConnected,jt as isConnecting,Bt as isCreating,Et as isDisconnected,_t as isNotCreated,Gt as isReconnecting,qt as needsRecovery,Tt as useAcceptTerms,gt as useAuthorizationSignature,lt as useCreateGuestAccount,et as useDepositAddress,It as useEmbeddedBitcoinWallet,vt as useEmbeddedEthereumWallet,wt as useEmbeddedSolanaWallet,ct as useEmbeddedWallet,mt as useEmbeddedWalletStateChange,Ft as useGetEncryptedAuthorizationKey,ot as useHeadlessCryptoDeposit,tt as useHeadlessDelegatedActions,kt as useIdentityToken,Pt as useImportWallet,z as useLinkEmail,Q as useLinkSMS,st as useLinkWithCrossApp,X as useLinkWithFarcaster,F as useLinkWithOAuth,j as useLinkWithSiwe,B as useLinkWithSiws,pt as useLoginWithCrossApp,K as useLoginWithEmail,Z as useLoginWithFarcaster,$ as useLoginWithFarcasterV2,I as useLoginWithOAuth,V as useLoginWithSMS,E as useLoginWithSiwe,M as useLoginWithSiws,xt as useMfa,dt as useMfaEnrollment,w as useMigrateWallets,g as useOAuthFlow,D as useOAuthTokens,G as useOnNeedsRecovery,d as usePrivy,_ as usePrivyClient,Ot as useRecoverEmbeddedWallet,yt as useRegisterMfaListener,ft as useSendTransactionWithCrossApp,rt as useSessionSigners,At as useSetEmbeddedWalletRecovery,St as useSign7702Authorization,ht as useSignMessageWithCrossApp,at as useSignTypedDataWithCrossApp,nt as useSigners,Ht as useStoredUsers,Ct as useSwitchUser,Lt as useTransfer,J as useUnlinkEmail,Y as useUnlinkFarcaster,H as useUnlinkOAuth,Ut as useUnlinkPasskey,q as useUnlinkWallet,ut as useUpdateEmail,it as useUpdatePhone,Wt as useUpdateWallet,Rt as useWalletActions};
|
package/dist/esm/passkey.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as K,b as N,c as V,d as D,e as F,f as T,g as M,h as j}from"./chunk-QSWCX5XI.js";import{
|
|
1
|
+
import{a as K,b as N,c as V,d as D,e as F,f as T,g as M,h as j}from"./chunk-QSWCX5XI.js";import{U as _,V as x,W as b,a as w,d as g,h,na as P}from"./chunk-V3WU67WL.js";import"./chunk-F7DR7TVR.js";import"./chunk-3HF374LL.js";import{e as p}from"./chunk-C5WYSLQF.js";import{useCallback as W,useContext as R}from"react";import{PrivyClientError as v}from"@privy-io/js-sdk-core";var Y=e=>{let{client:a,passkeyState:d,setPasskeyState:s}=R(P),c=W(o=>{var n;let t=h(o);return s({status:"error",error:t}),(n=e==null?void 0:e.onError)==null||n.call(e,t),t},[e==null?void 0:e.onError]);return{linkWithPasskey:W(n=>p(void 0,[n],function*({relyingParty:o,extra_options:t}){var u;try{if(!g())throw new v({code:"attempted_link_passkey_before_logged_in",error:"Must be logged in to link a passkey."});s({status:"generating-challenege"});let{options:k}=yield a.auth.passkey.generateRegistrationOptions(o);s({status:"awaiting-passkey"});let y=yield _(b(k),t);s({status:"submitting-response"});let{user:m}=yield a.auth.passkey.linkWithPasskey(y,o);return s({status:"done"}),(u=e==null?void 0:e.onSuccess)==null||u.call(e,m),m}catch(r){throw c(r)}}),[a,c,e==null?void 0:e.onSuccess]),state:d}};import{useCallback as O,useContext as H}from"react";import{PrivyClientError as I}from"@privy-io/js-sdk-core";var ie=e=>{let{client:a,passkeyState:d,setPasskeyState:s}=H(P),c=O(o=>{var n;let t=h(o);return s({status:"error",error:t}),(n=e==null?void 0:e.onError)==null||n.call(e,t),t},[e==null?void 0:e.onError]);return{loginWithPasskey:O(n=>p(void 0,[n],function*({relyingParty:o,extra_options:t}){var u,r,k,y;try{if(g())throw new I({code:"attempted_login_with_passkey_while_already_logged_in",error:"Already logged in, use `useLinkWithPasskey` if you are trying to link a passkey to an existing account"});s({status:"generating-challenege"});let{options:i}=yield a.auth.passkey.generateAuthenticationOptions(o);s({status:"awaiting-passkey"});let f=yield x({challenge:i.challenge,rpId:i.rp_id,extensions:{appid:(u=i.extensions)==null?void 0:u.app_id,credProps:(r=i.extensions)==null?void 0:r.cred_props,hmacCreateSecret:(k=i.extensions)==null?void 0:k.hmac_create_secret},timeout:i.timeout,allowCredentials:i.allow_credentials,userVerification:i.user_verification},t);s({status:"submitting-response"});let l=w(),C=yield a.auth.passkey.loginWithPasskey(f,i.challenge,o,{embedded:l==null?void 0:l.embedded});return s({status:"done"}),(y=e==null?void 0:e.onSuccess)==null||y.call(e,C.user,C.is_new_user),C.user}catch(m){throw c(m)}}),[a,c,e==null?void 0:e.onSuccess]),state:d}};import{useCallback as U,useContext as L,useEffect as A,useRef as q}from"react";import{PrivyClientError as J}from"@privy-io/js-sdk-core";var ge=e=>{let{client:a,passkeyState:d,setPasskeyState:s}=L(P),c=q(e);A(()=>{c.current=e},[e]);let S=U(t=>{var u,r;let n=h(t);return s({status:"error",error:n}),(r=(u=c.current)==null?void 0:u.onError)==null||r.call(u,n),n},[s]);return{signupWithPasskey:U(u=>p(void 0,[u],function*({relyingParty:t,extra_options:n}){var r,k;try{if(g())throw new J({code:"attempted_login_with_passkey_while_already_logged_in",error:"Already logged in, use `useLinkWithPasskey` if you are trying to link a passkey to an existing account"});s({status:"generating-challenege"});let{options:m}=yield a.auth.passkey.generateSignupOptions(t);s({status:"awaiting-passkey"});let i=yield _(b(m),n);s({status:"submitting-response"});let f=w(),l=yield a.auth.passkey.signupWithPasskey(i,t,{embedded:f==null?void 0:f.embedded});return s({status:"done"}),(k=(r=c.current)==null?void 0:r.onSuccess)==null||k.call(r,l.user,l.is_new_user),{user:l.user}}catch(y){throw S(y)}}),[a.auth.passkey,S,s]),state:d}};export{M as hasError,K as isConnected,V as isConnecting,T as isCreating,D as isDisconnected,F as isNotCreated,N as isReconnecting,j as needsRecovery,Y as useLinkWithPasskey,ie as useLoginWithPasskey,ge as useSignupWithPasskey};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as L}from"./chunk-QSWCX5XI.js";import{b as k,c as N,d as g,f as v,k as P,na as S,o as U}from"./chunk-V3WU67WL.js";import"./chunk-F7DR7TVR.js";import"./chunk-3HF374LL.js";import{a as _,b as I,c as M,e as d}from"./chunk-C5WYSLQF.js";import p,{createContext as T,useCallback as et,useContext as f,useEffect as E,useState as D}from"react";import{getDataSuffixPlugin as F,getUserSmartWallet as h,PrivyClientError as u}from"@privy-io/js-sdk-core";import{createPublicClient as H,http as X}from"viem";import{getJsonRpcEndpointFromChain as j,getUserSmartWallet as q,PrivyClientError as O}from"@privy-io/js-sdk-core";import{signerToSmartAccountClient as J}from"@privy-io/js-sdk-core/smart-wallets";var x=w=>d(void 0,[w],function*({chain:t,privyAppId:e,user:a,embeddedWallet:r,smartWalletsConfig:n,client:i,dataSuffix:c}){if(!(n!=null&&n.enabled)||!r||!L(r))return;let s=yield i.embeddedWallet.getEthereumProvider({wallet:r.account,entropyId:r.account.address,entropyIdVerifier:"ethereum-address-verifier",onMfaEnrollmentRequired:y=>d(void 0,null,function*(){return yield k()(y)}),onMfaVerificationRequired:y=>d(void 0,null,function*(){return yield N()(y)})}),o=n==null?void 0:n.configured_networks.find(y=>y.chain_id===`eip155:${t.id}`);if(!o)throw new O({code:"chain_not_supported",error:`The chain ${t.name} (eip155:${t.id}) must be configured in the smart wallet configuration in your dashboard`});let l=q(a),C=l?l.smart_wallet_type:n.smart_wallet_type,W=l?l.smart_wallet_version:n.smart_wallet_version,V=j(t,{rpcUrls:[]},e),Y=H({chain:t,transport:X(V)}),A=yield J({owner:s,smartWalletType:C,smartWalletVersion:W,chain:t,publicClient:Y,paymasterContext:tt(o.paymaster_url,o.paymaster_context),bundlerUrl:o.bundler_url,paymasterUrl:o.paymaster_url});if(!A)throw new O({code:"smart_wallet_client_error",error:`Failed to create smart wallet client for chain ${t.name} (eip155:${t.id})`});return K(A,c)});function K(t,e){return e?t.extend(a=>({sendTransaction:r=>a.sendTransaction(M(I({},r),{dataSuffix:e}))})):t}var z=/paymaster\.biconomy\.io\/api/i;function Q(t){return z.test(t)}var Z={mode:"SPONSORED",calculateGasLimits:!0,expiryDuration:300,sponsorshipInfo:{webhookData:{},smartAccountInfo:{name:"BICONOMY",version:"2.0.0"}}},tt=(t,e)=>{if(t&&Q(t))return Z;if(e&&e.policy_id)return{policyId:e.policy_id}};var R=3,rt=500,nt=({children:t})=>p.createElement(lt,null,p.createElement(ot,null,p.createElement(st,null,t))),$=T({config:void 0}),b=()=>{let{config:t}=f($);return{config:t}},G=T({smartWalletClient:void 0}),at=()=>{let{smartWalletClient:t}=f(G);return{smartWalletClient:t}},B=T({client:void 0}),it=()=>{let{client:t}=f(B),e=ct();return{client:t,getClientForChain:e}},lt=({children:t})=>{let[e,a]=D(void 0),r=U();return E(()=>{!e&&r&&(()=>d(void 0,null,function*(){try{if(!r){console.warn("No client found");return}let i=yield r.app.getSmartWalletConfig();a(i)}catch(i){console.warn("Error generating smart wallet config: ",i)}}))()},[r,e]),p.createElement($.Provider,{value:{config:e}},t)},ot=({children:t})=>{let{config:e}=b(),{client:a,wallet:r}=f(S),n=v(),[i,c]=D();return E(()=>{(()=>d(void 0,null,function*(){var l;if(!n&&i&&c(void 0),!(e!=null&&e.enabled)||!n||r.status!=="connected"||n&&i&&r.status==="connected")return;let s=a.embeddedWallet.chains.find(C=>e.configured_networks.map(W=>W.chain_id).includes(`eip155:${C.id}`));if(!s)throw new u({error:"Could not find smart wallets chain configurations for any Privy client configured chains. Please configure smart wallets for your chains in the Privy dashboard.",code:"chain_not_supported"});let o=yield x({chain:s,privyAppId:a.app.appId,user:n,embeddedWallet:r,smartWalletsConfig:e,client:a,dataSuffix:(l=F(a.plugins))==null?void 0:l.suffix});if(!o)throw new u({error:"Could not create smart wallet client",code:"smart_wallet_client_error"});c(o)}))()},[!!(e!=null&&e.enabled),!!a,!!n,r.status]),p.createElement(G.Provider,{value:{smartWalletClient:i}},t)},st=({children:t})=>{let{client:e,wallet:a}=f(S),r=v(),{smartWalletClient:n}=at(),{config:i}=b();return E(()=>{let c=!1;return(()=>d(void 0,null,function*(){var m;if(!(!n||!r||h(r)||!(i!=null&&i.enabled)||a.status!=="connected"))for(let s=0;s<R;s++){if(c||h((m=g())!=null?m:r))return;let o=!1;for(let l=0;l<5;l++){if(c)return;if(yield e.embeddedWallet.ping(rt)){o=!0;break}yield P(200*_(2,l))}if(o)try{let{message:l}=yield e.auth.smartWallet.init({address:n.account.address,chainId:`eip155:${n.chain.id}`}),C=yield n.signMessage({message:l});yield e.auth.smartWallet.link(l,C,i.smart_wallet_type,i.smart_wallet_version);return}catch(l){s===R-1?console.error("Error creating smart wallet:",l):yield P(500*_(2,s))}}}))(),()=>{c=!0}},[!!n,!!r,!!h(r),i,a.status]),p.createElement(B.Provider,{value:{client:h(r)?n:void 0}},t)},ct=()=>{let{client:t,wallet:e}=f(S),{config:a}=b();return et(n=>d(void 0,[n],function*({chainId:r}){var s;let i=g();if(!i)throw new u({error:"Must be logged in to get a smart wallet client",code:"smart_wallet_client_error"});if(!a||!a.enabled)throw new u({error:"Must have smart wallets enabled to get a smart wallet client",code:"smart_wallet_client_error"});let w=t.embeddedWallet.chains.find(o=>o.id===r);if(!w)throw new u({error:`Could not find chain with id: ${r}`,code:"chain_not_supported"});let m=yield x({chain:w,privyAppId:t.app.appId,user:i,embeddedWallet:e,smartWalletsConfig:a,client:t,dataSuffix:(s=F(t.plugins))==null?void 0:s.suffix});if(!m)throw new u({error:`Could not create smart wallet client for chain ${r}`,code:"smart_wallet_client_error"});return m}),[a,e,t])};export{nt as SmartWalletsProvider,it as useSmartWallets};
|