@privy-io/expo 0.78.3 → 0.80.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{pa as Ce}from"./chunk-APBCP6B2.js";import{b as r,c as U,d as m}from"./chunk-C5WYSLQF.js";var C=class extends Error{constructor(o,u){super(u);this.code=o,this.error=u}},he=class extends C{constructor(o){super("underlying_error",o instanceof Error?o.message:"An underlying error occurred");this.wrappedError=o}};import qe,{useContext as ve}from"react";import{useMemo as Ue}from"react";import{createContext as be}from"react";var O=be(void 0);var ge="#5B4FFF";function Se({colorScheme:a,accentHex:t}){return a==="dark"?{interactive:t,background:"#22222A",backgroundSecondary:"#010110",backgroundInformation:"#1E1B4B",backgroundTertiary:"#010110",backgroundHighlight:"#052E16",text:"#ffffff",textPlaceholder:"#9498B8",textMuted:"#FFFFFF",textHighlight:"#BBF7D0",textTitle:"#FFFFFF",textInteractive:"#FFFFFF",icon:"#FFFFFF",iconInformation:"#818CF8",iconSubtle:"#919191",privyBrand:"#FFFFFF",success:"#4ADE80",successLight:"#C5F7D7",border:"#474869",borderInformation:"#818CF8",error:"#FCA5A5",errorDark:"#EF4444"}:{interactive:t,background:"#FFFFFF",backgroundSecondary:"#F3F3F3",backgroundInformation:"#E0E7FF",backgroundTertiary:"#FFFFFF",backgroundHighlight:"#F1F2F9",text:"#040217",textPlaceholder:"#9498B8",textMuted:"#64668B",textHighlight:"#64668B",textTitle:"#1A1C29",textInteractive:"#FFFFFF",icon:"#110F2A",iconSubtle:"#9498B8",iconInformation:"#4F46E5",privyBrand:"#010110",success:"#16A34A",successLight:"#DCFCE7",border:"#E2E3F0",borderInformation:"#5B4FFF",error:"#EF4444",errorDark:"#B91C1C"}}function ke({colorScheme:a,accentHex:t}){return{colors:Se({colorScheme:a,accentHex:t}),colorScheme:a}}function Oe({children:a,appearance:t={}}){let{colorScheme:o="light",accentColor:u}=t,{isReady:d,client:l}=ve(Ce),f=Ue(()=>{var B,L;let s=d?l.app.getConfig():void 0,i=(B=s==null?void 0:s.accent_color)!=null?B:void 0;return ke({colorScheme:o,accentHex:(L=u!=null?u:i)!=null?L:ge})},[o,u,d,l]);return qe.createElement(O.Provider,{value:f},a)}import{useContext as He}from"react";var n=()=>{let a=He(O);if(a===void 0)throw new Error("Components calling useTheme must be wrapped in an ElementsThemeProvider");return a};import{useEffect as Ee}from"react";import{useStore as Ve}from"zustand";import{createStore as Ge}from"zustand/vanilla";var H=Ge()(a=>({elementsConfig:null,updateUIMounted:t=>a({elementsConfig:t})})),Ra=()=>{let{elementsConfig:a}=H.getState();if(!(a!==null))throw new C("privy_elements_not_ready","Privy Elements is not mounted")},ba=()=>{let{elementsConfig:a}=H.getState();if(a===null)throw new C("privy_elements_not_ready","Privy Elements is not mounted");return a},qa=()=>Ve(H,a=>{var t;return(t=a.elementsConfig)==null?void 0:t.appearance}),va=a=>{Ee(()=>{let{updateUIMounted:t}=H.getState();return t(a),()=>{t(null)}},[a])};var we={regular:"Inter_400Regular",medium:"Inter_500Medium",semibold:"Inter_600SemiBold"};import h from"react";import{View as We,Text as Pe,StyleSheet as ze}from"react-native";var Xe=h.forwardRef((d,u)=>{var l=d,{style:a,variant:t="default"}=l,o=m(l,["style","variant"]);let{colors:f}=n();return h.createElement(We,r({ref:u,style:[E.alert,t==="info"&&{backgroundColor:f.backgroundInformation,borderColor:f.borderInformation},a]},o))});Xe.displayName="Alert";var Ne=h.forwardRef((u,o)=>{var d=u,{style:a}=d,t=m(d,["style"]);let{colors:l}=n();return h.createElement(Pe,r({ref:o,style:[E.title,{color:l.text},a]},t))});Ne.displayName="AlertTitle";var _e=h.forwardRef((u,o)=>{var d=u,{style:a}=d,t=m(d,["style"]);let{colors:l}=n();return h.createElement(Pe,r({ref:o,style:[E.description,{color:l.text},a]},t))});_e.displayName="AlertDescription";var E=ze.create({alert:{borderRadius:8,alignItems:"center",gap:12,paddingHorizontal:12,paddingVertical:8,flexDirection:"row"},title:{marginBottom:4,fontFamily:we.semibold,fontSize:16},description:{fontSize:14,lineHeight:20}});import{forwardRef as Ke,createElement as ye}from"react";import*as V from"react-native-svg";var I={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},Ae={fill:I.fill,stroke:I.stroke,strokeWidth:I.strokeWidth,strokeLinecap:I.strokeLinecap,strokeLinejoin:I.strokeLinejoin};var e=(a,t)=>{let o=Ke((p,L)=>{var M=p,{color:u="currentColor",size:d=24,strokeWidth:l=2,absoluteStrokeWidth:f,children:s,"data-testid":i}=M,B=m(M,["color","size","strokeWidth","absoluteStrokeWidth","children","data-testid"]);let v=r({stroke:u,strokeWidth:f?Number(l)*24/Number(d):l},B);return ye(V.Svg,r(U(r({ref:L},I),{width:d,height:d,"data-testid":i}),v),[...t.map(([D,Te])=>{let Re=D.charAt(0).toUpperCase()+D.slice(1);return ye(V[Re],r(r(r({},Ae),v),Te))}),...(Array.isArray(s)?s:[s])||[]])});return o.displayName=`${a}`,o};var G=e("ArrowLeftRight",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]]);var T=e("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);var W=e("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);var g=e("ChartLine",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]]);var z=e("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);var X=e("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);var N=e("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);var S=e("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);var k=e("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);var w=e("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);var P=e("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);var _=e("Clock10",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 8 10",key:"atfzqc"}]]);var A=e("CloudUpload",[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]]);var K=e("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);var Z=e("CreditCard",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);var J=e("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);var Q=e("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);var j=e("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);var Y=e("FileCheck",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m9 15 2 2 4-4",key:"1grp1n"}]]);var y=e("FilePen",[["path",{d:"M12.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v9.5",key:"1couwa"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1y4qbx"}]]);var $=e("Files",[["path",{d:"M20 7h-3a2 2 0 0 1-2-2V2",key:"x099mo"}],["path",{d:"M9 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h7l4 4v10a2 2 0 0 1-2 2Z",key:"18t6ie"}],["path",{d:"M3 7.6v12.8A1.6 1.6 0 0 0 4.6 22h9.8",key:"1nja0z"}]]);var ee=e("Fingerprint",[["path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4",key:"1nerag"}],["path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88",key:"o46ks0"}],["path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02",key:"ptglia"}],["path",{d:"M2 12a10 10 0 0 1 18-6",key:"ydlgp0"}],["path",{d:"M2 16h.01",key:"1gqxmh"}],["path",{d:"M21.8 16c.2-2 .131-5.354 0-6",key:"drycrb"}],["path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2",key:"1tidbn"}],["path",{d:"M8.65 22c.21-.66.45-1.32.57-2",key:"13wd9y"}],["path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2",key:"1fr1j5"}]]);var ae=e("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);var te=e("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);var oe=e("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);var ue=e("Phone",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);var de=e("QrCode",[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]]);var le=e("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);var re=e("ScanFace",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 9h.01",key:"x1ddxp"}]]);var fe=e("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);var se=e("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);var ie=e("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);var ce=e("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);var ne=e("Store",[["path",{d:"m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7",key:"ztvudi"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["path",{d:"M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4",key:"2ebpfo"}],["path",{d:"M2 7h20",key:"1fcdvo"}],["path",{d:"M22 7v3a2 2 0 0 1-2 2a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 16 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 12 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 8 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 4 12a2 2 0 0 1-2-2V7",key:"6c3vgh"}]]);var pe=e("UserCheck",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]]);var R=e("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);import c from"react";import{Pressable as Fe,StyleSheet as Ze,View as b}from"react-native";var au=({goBack:a,close:t})=>c.createElement(b,{style:me.navigationBar},c.createElement(b,null,a&&c.createElement(Je,{onPress:a})),c.createElement(b,null,t&&c.createElement(Qe,{onPress:t}))),Je=a=>{let{colors:t}=n();return c.createElement(Fe,r({accessibilityRole:"button",accessibilityLabel:"Back"},a),c.createElement(b,{style:me.backButton},c.createElement(T,{size:24,color:t.icon})))},Qe=a=>{let{colors:t}=n();return c.createElement(Fe,r({accessibilityRole:"button",accessibilityLabel:"Close"},a),c.createElement(b,{style:me.backButton},c.createElement(R,{size:24,color:t.icon})))},me=Ze.create({navigationBar:{height:48,flexDirection:"row",justifyContent:"space-between"},backButton:{width:48,height:48,justifyContent:"center",alignItems:"center"}});import{create as je}from"zustand";var Le=je(()=>null),Ye=()=>{var t;let a=(t=Le.getState())==null?void 0:t.controller;return!a||a.signal.aborted?null:a},du=()=>{var a;(a=Ye())==null||a.abort(),Le.setState(null)},lu=a=>{Le.setState(t=>t&&{step:a})};import x from"react";import{View as Me,Text as ua,Pressable as da,StyleSheet as la}from"react-native";import Ie,{useEffect as $e}from"react";import{Animated as xe,Easing as ea,useAnimatedValue as aa}from"react-native";import ta,{Path as oa}from"react-native-svg";var Be=({color:a})=>{let t=aa(0);$e(()=>{t.setValue(0);let u=xe.loop(xe.timing(t,{toValue:1,duration:1200,useNativeDriver:!0,easing:ea.linear}));return u.start(),()=>u.stop()},[t]);let o=t.interpolate({inputRange:[0,1],outputRange:["0deg","360deg"]});return Ie.createElement(xe.View,{style:{transform:[{rotate:o}]}},Ie.createElement(ta,{width:20,height:20,viewBox:"0 0 20 20",fill:"none"},Ie.createElement(oa,{d:"M19 10a9 9 0 11-6.219-8.56",stroke:a,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})))};var Iu=B=>{var L=B,{variant:a="primary",title:t,destroy:o=!1,loading:u=!1,LeftIcon:d,RightIcon:l,color:f,style:s}=L,i=m(L,["variant","title","destroy","loading","LeftIcon","RightIcon","color","style"]);let{colors:p}=n(),M=o?p.errorDark:p.interactive,v={primary:M,secondary:p.backgroundTertiary,tertiary:p.background}[a],D={primary:p.textInteractive,secondary:p.text,tertiary:M}[a];return x.createElement(da,U(r({},i),{disabled:i.disabled||u}),x.createElement(Me,{style:[q.buttonBox,{backgroundColor:v},a==="secondary"&&q.buttonBoxSecondary,a==="secondary"&&{borderColor:p.border},s]},u?x.createElement(Be,{color:f!=null?f:D}):x.createElement(x.Fragment,null,d,x.createElement(ua,{style:[q.buttonLabel,{color:f!=null?f:D},a==="secondary"&&q.buttonLabelSecondary,a==="tertiary"&&q.buttonLabelTertiary]},t),!!l&&x.createElement(Me,{style:{marginLeft:"auto"}},l))))},q=la.create({buttonBox:{height:54,flexDirection:"row",justifyContent:"center",alignItems:"center",borderRadius:14,paddingHorizontal:16,gap:12},buttonBoxSecondary:{justifyContent:"flex-start",borderWidth:1,borderRadius:12},buttonLabel:{fontFamily:"Inter_600SemiBold",fontSize:16,lineHeight:24},buttonLabelSecondary:{fontFamily:"Inter_400Regular"},buttonLabelTertiary:{fontFamily:"Inter_500Medium"}});import*as F from"expo-web-browser";import{AppState as ra,Platform as De}from"react-native";var gu=a=>{if(!a)return null;try{return new URL(a).protocol==="https:"?a:null}catch(t){return null}},Su=a=>{let t=!1,o=!1,u=null;function d(){o=!0,u==null||u.remove()}function l(f){if(t||o)return;t=!0;let s=!1;u=De.OS==="android"?ra.addEventListener("change",i=>{i==="background"&&(s=!0),i==="active"&&s&&d()}):null,F.openBrowserAsync(f,{createTask:!1}).then(i=>{i.type!==F.WebBrowserResultType.OPENED&&d()}).catch(d)}return a&&l(a),{navigate:l,isClosed:()=>o,dismiss:()=>{o||(d(),t&&De.OS==="ios"&&F.dismissBrowser().catch(()=>{}))}}};export{Oe as a,n as b,Iu as c,G as d,W as e,g as f,z as g,X as h,N as i,S as j,k,w as l,P as m,_ as n,A as o,K as p,Z as q,J as r,Q as s,j as t,Y as u,y as v,$ as w,ee as x,ae as y,te as z,oe as A,ue as B,de as C,le as D,re as E,fe as F,se as G,ie as H,ce as I,ne as J,pe as K,C as L,he as M,Ra as N,ba as O,qa as P,va as Q,we as R,Xe as S,_e as T,au as U,gu as V,Su as W,Le as X,Ye as Y,du as Z,lu as _};
1
+ import{qa as Ce}from"./chunk-MZRVLBIF.js";import{b as r,c as U,d as m}from"./chunk-C5WYSLQF.js";var C=class extends Error{constructor(o,u){super(u);this.code=o,this.error=u}},he=class extends C{constructor(o){super("underlying_error",o instanceof Error?o.message:"An underlying error occurred");this.wrappedError=o}};import qe,{useContext as ve}from"react";import{useMemo as Ue}from"react";import{createContext as be}from"react";var O=be(void 0);var ge="#5B4FFF";function Se({colorScheme:a,accentHex:t}){return a==="dark"?{interactive:t,background:"#22222A",backgroundSecondary:"#010110",backgroundInformation:"#1E1B4B",backgroundTertiary:"#010110",backgroundHighlight:"#052E16",text:"#ffffff",textPlaceholder:"#9498B8",textMuted:"#FFFFFF",textHighlight:"#BBF7D0",textTitle:"#FFFFFF",textInteractive:"#FFFFFF",icon:"#FFFFFF",iconInformation:"#818CF8",iconSubtle:"#919191",privyBrand:"#FFFFFF",success:"#4ADE80",successLight:"#C5F7D7",border:"#474869",borderInformation:"#818CF8",error:"#FCA5A5",errorDark:"#EF4444"}:{interactive:t,background:"#FFFFFF",backgroundSecondary:"#F3F3F3",backgroundInformation:"#E0E7FF",backgroundTertiary:"#FFFFFF",backgroundHighlight:"#F1F2F9",text:"#040217",textPlaceholder:"#9498B8",textMuted:"#64668B",textHighlight:"#64668B",textTitle:"#1A1C29",textInteractive:"#FFFFFF",icon:"#110F2A",iconSubtle:"#9498B8",iconInformation:"#4F46E5",privyBrand:"#010110",success:"#16A34A",successLight:"#DCFCE7",border:"#E2E3F0",borderInformation:"#5B4FFF",error:"#EF4444",errorDark:"#B91C1C"}}function ke({colorScheme:a,accentHex:t}){return{colors:Se({colorScheme:a,accentHex:t}),colorScheme:a}}function Oe({children:a,appearance:t={}}){let{colorScheme:o="light",accentColor:u}=t,{isReady:d,client:l}=ve(Ce),f=Ue(()=>{var B,L;let s=d?l.app.getConfig():void 0,i=(B=s==null?void 0:s.accent_color)!=null?B:void 0;return ke({colorScheme:o,accentHex:(L=u!=null?u:i)!=null?L:ge})},[o,u,d,l]);return qe.createElement(O.Provider,{value:f},a)}import{useContext as He}from"react";var n=()=>{let a=He(O);if(a===void 0)throw new Error("Components calling useTheme must be wrapped in an ElementsThemeProvider");return a};import{useEffect as Ee}from"react";import{useStore as Ve}from"zustand";import{createStore as Ge}from"zustand/vanilla";var H=Ge()(a=>({elementsConfig:null,updateUIMounted:t=>a({elementsConfig:t})})),Ra=()=>{let{elementsConfig:a}=H.getState();if(!(a!==null))throw new C("privy_elements_not_ready","Privy Elements is not mounted")},ba=()=>{let{elementsConfig:a}=H.getState();if(a===null)throw new C("privy_elements_not_ready","Privy Elements is not mounted");return a},qa=()=>Ve(H,a=>{var t;return(t=a.elementsConfig)==null?void 0:t.appearance}),va=a=>{Ee(()=>{let{updateUIMounted:t}=H.getState();return t(a),()=>{t(null)}},[a])};var we={regular:"Inter_400Regular",medium:"Inter_500Medium",semibold:"Inter_600SemiBold"};import h from"react";import{View as We,Text as Pe,StyleSheet as ze}from"react-native";var Xe=h.forwardRef((d,u)=>{var l=d,{style:a,variant:t="default"}=l,o=m(l,["style","variant"]);let{colors:f}=n();return h.createElement(We,r({ref:u,style:[E.alert,t==="info"&&{backgroundColor:f.backgroundInformation,borderColor:f.borderInformation},a]},o))});Xe.displayName="Alert";var Ne=h.forwardRef((u,o)=>{var d=u,{style:a}=d,t=m(d,["style"]);let{colors:l}=n();return h.createElement(Pe,r({ref:o,style:[E.title,{color:l.text},a]},t))});Ne.displayName="AlertTitle";var _e=h.forwardRef((u,o)=>{var d=u,{style:a}=d,t=m(d,["style"]);let{colors:l}=n();return h.createElement(Pe,r({ref:o,style:[E.description,{color:l.text},a]},t))});_e.displayName="AlertDescription";var E=ze.create({alert:{borderRadius:8,alignItems:"center",gap:12,paddingHorizontal:12,paddingVertical:8,flexDirection:"row"},title:{marginBottom:4,fontFamily:we.semibold,fontSize:16},description:{fontSize:14,lineHeight:20}});import{forwardRef as Ke,createElement as ye}from"react";import*as V from"react-native-svg";var I={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},Ae={fill:I.fill,stroke:I.stroke,strokeWidth:I.strokeWidth,strokeLinecap:I.strokeLinecap,strokeLinejoin:I.strokeLinejoin};var e=(a,t)=>{let o=Ke((p,L)=>{var M=p,{color:u="currentColor",size:d=24,strokeWidth:l=2,absoluteStrokeWidth:f,children:s,"data-testid":i}=M,B=m(M,["color","size","strokeWidth","absoluteStrokeWidth","children","data-testid"]);let v=r({stroke:u,strokeWidth:f?Number(l)*24/Number(d):l},B);return ye(V.Svg,r(U(r({ref:L},I),{width:d,height:d,"data-testid":i}),v),[...t.map(([D,Te])=>{let Re=D.charAt(0).toUpperCase()+D.slice(1);return ye(V[Re],r(r(r({},Ae),v),Te))}),...(Array.isArray(s)?s:[s])||[]])});return o.displayName=`${a}`,o};var G=e("ArrowLeftRight",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]]);var T=e("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);var W=e("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);var g=e("ChartLine",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]]);var z=e("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);var X=e("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);var N=e("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);var S=e("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);var k=e("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);var w=e("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);var P=e("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);var _=e("Clock10",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 8 10",key:"atfzqc"}]]);var A=e("CloudUpload",[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]]);var K=e("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);var Z=e("CreditCard",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);var J=e("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);var Q=e("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);var j=e("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);var Y=e("FileCheck",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m9 15 2 2 4-4",key:"1grp1n"}]]);var y=e("FilePen",[["path",{d:"M12.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v9.5",key:"1couwa"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1y4qbx"}]]);var $=e("Files",[["path",{d:"M20 7h-3a2 2 0 0 1-2-2V2",key:"x099mo"}],["path",{d:"M9 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h7l4 4v10a2 2 0 0 1-2 2Z",key:"18t6ie"}],["path",{d:"M3 7.6v12.8A1.6 1.6 0 0 0 4.6 22h9.8",key:"1nja0z"}]]);var ee=e("Fingerprint",[["path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4",key:"1nerag"}],["path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88",key:"o46ks0"}],["path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02",key:"ptglia"}],["path",{d:"M2 12a10 10 0 0 1 18-6",key:"ydlgp0"}],["path",{d:"M2 16h.01",key:"1gqxmh"}],["path",{d:"M21.8 16c.2-2 .131-5.354 0-6",key:"drycrb"}],["path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2",key:"1tidbn"}],["path",{d:"M8.65 22c.21-.66.45-1.32.57-2",key:"13wd9y"}],["path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2",key:"1fr1j5"}]]);var ae=e("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);var te=e("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);var oe=e("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);var ue=e("Phone",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);var de=e("QrCode",[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]]);var le=e("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);var re=e("ScanFace",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 9h.01",key:"x1ddxp"}]]);var fe=e("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);var se=e("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);var ie=e("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);var ce=e("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);var ne=e("Store",[["path",{d:"m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7",key:"ztvudi"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["path",{d:"M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4",key:"2ebpfo"}],["path",{d:"M2 7h20",key:"1fcdvo"}],["path",{d:"M22 7v3a2 2 0 0 1-2 2a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 16 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 12 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 8 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 4 12a2 2 0 0 1-2-2V7",key:"6c3vgh"}]]);var pe=e("UserCheck",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]]);var R=e("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);import c from"react";import{Pressable as Fe,StyleSheet as Ze,View as b}from"react-native";var au=({goBack:a,close:t})=>c.createElement(b,{style:me.navigationBar},c.createElement(b,null,a&&c.createElement(Je,{onPress:a})),c.createElement(b,null,t&&c.createElement(Qe,{onPress:t}))),Je=a=>{let{colors:t}=n();return c.createElement(Fe,r({accessibilityRole:"button",accessibilityLabel:"Back"},a),c.createElement(b,{style:me.backButton},c.createElement(T,{size:24,color:t.icon})))},Qe=a=>{let{colors:t}=n();return c.createElement(Fe,r({accessibilityRole:"button",accessibilityLabel:"Close"},a),c.createElement(b,{style:me.backButton},c.createElement(R,{size:24,color:t.icon})))},me=Ze.create({navigationBar:{height:48,flexDirection:"row",justifyContent:"space-between"},backButton:{width:48,height:48,justifyContent:"center",alignItems:"center"}});import{create as je}from"zustand";var Le=je(()=>null),Ye=()=>{var t;let a=(t=Le.getState())==null?void 0:t.controller;return!a||a.signal.aborted?null:a},du=()=>{var a;(a=Ye())==null||a.abort(),Le.setState(null)},lu=a=>{Le.setState(t=>t&&{step:a})};import x from"react";import{View as Me,Text as ua,Pressable as da,StyleSheet as la}from"react-native";import Ie,{useEffect as $e}from"react";import{Animated as xe,Easing as ea,useAnimatedValue as aa}from"react-native";import ta,{Path as oa}from"react-native-svg";var Be=({color:a})=>{let t=aa(0);$e(()=>{t.setValue(0);let u=xe.loop(xe.timing(t,{toValue:1,duration:1200,useNativeDriver:!0,easing:ea.linear}));return u.start(),()=>u.stop()},[t]);let o=t.interpolate({inputRange:[0,1],outputRange:["0deg","360deg"]});return Ie.createElement(xe.View,{style:{transform:[{rotate:o}]}},Ie.createElement(ta,{width:20,height:20,viewBox:"0 0 20 20",fill:"none"},Ie.createElement(oa,{d:"M19 10a9 9 0 11-6.219-8.56",stroke:a,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})))};var Iu=B=>{var L=B,{variant:a="primary",title:t,destroy:o=!1,loading:u=!1,LeftIcon:d,RightIcon:l,color:f,style:s}=L,i=m(L,["variant","title","destroy","loading","LeftIcon","RightIcon","color","style"]);let{colors:p}=n(),M=o?p.errorDark:p.interactive,v={primary:M,secondary:p.backgroundTertiary,tertiary:p.background}[a],D={primary:p.textInteractive,secondary:p.text,tertiary:M}[a];return x.createElement(da,U(r({},i),{disabled:i.disabled||u}),x.createElement(Me,{style:[q.buttonBox,{backgroundColor:v},a==="secondary"&&q.buttonBoxSecondary,a==="secondary"&&{borderColor:p.border},s]},u?x.createElement(Be,{color:f!=null?f:D}):x.createElement(x.Fragment,null,d,x.createElement(ua,{style:[q.buttonLabel,{color:f!=null?f:D},a==="secondary"&&q.buttonLabelSecondary,a==="tertiary"&&q.buttonLabelTertiary]},t),!!l&&x.createElement(Me,{style:{marginLeft:"auto"}},l))))},q=la.create({buttonBox:{height:54,flexDirection:"row",justifyContent:"center",alignItems:"center",borderRadius:14,paddingHorizontal:16,gap:12},buttonBoxSecondary:{justifyContent:"flex-start",borderWidth:1,borderRadius:12},buttonLabel:{fontFamily:"Inter_600SemiBold",fontSize:16,lineHeight:24},buttonLabelSecondary:{fontFamily:"Inter_400Regular"},buttonLabelTertiary:{fontFamily:"Inter_500Medium"}});import*as F from"expo-web-browser";import{AppState as ra,Platform as De}from"react-native";var gu=a=>{if(!a)return null;try{return new URL(a).protocol==="https:"?a:null}catch(t){return null}},Su=a=>{let t=!1,o=!1,u=null;function d(){o=!0,u==null||u.remove()}function l(f){if(t||o)return;t=!0;let s=!1;u=De.OS==="android"?ra.addEventListener("change",i=>{i==="background"&&(s=!0),i==="active"&&s&&d()}):null,F.openBrowserAsync(f,{createTask:!1}).then(i=>{i.type!==F.WebBrowserResultType.OPENED&&d()}).catch(d)}return a&&l(a),{navigate:l,isClosed:()=>o,dismiss:()=>{o||(d(),t&&De.OS==="ios"&&F.dismissBrowser().catch(()=>{}))}}};export{Oe as a,n as b,Iu as c,G as d,W as e,g as f,z as g,X as h,N as i,S as j,k,w as l,P as m,_ as n,A as o,K as p,Z as q,J as r,Q as s,j as t,Y as u,y as v,$ as w,ee as x,ae as y,te as z,oe as A,ue as B,de as C,le as D,re as E,fe as F,se as G,ie as H,ce as I,ne as J,pe as K,C as L,he as M,Ra as N,ba as O,qa as P,va as Q,we as R,Xe as S,_e as T,au as U,gu as V,Su as W,Le as X,Ye as Y,du as Z,lu as _};
2
2
  /*! Bundled license information:
3
3
 
4
4
  lucide-react-native/dist/esm/defaultAttributes.js:
@@ -0,0 +1,12 @@
1
+ import{a as At,b as xt,c as _e}from"./chunk-F7DR7TVR.js";import{a as Pt}from"./chunk-3HF374LL.js";import{a as Ce,b as W,c as D,e as d}from"./chunk-C5WYSLQF.js";import{useEffect as yo}from"react";import{create as go}from"zustand";var Ut=go(()=>({status:"disconnected"})),ke=()=>Ut.getState().onNeedsRecovery,ho=e=>{yo(()=>{Ut.setState({onNeedsRecovery:e==null?void 0:e.onNeedsRecovery})},[e==null?void 0:e.onNeedsRecovery])};import vo from"@privy-io/js-sdk-core";var Rt={name:"@privy-io/expo",version:"0.80.0",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 We={postMessage:()=>{},reload:()=>{}};var It=({appId:e,clientId:t,storage:n=_e,supportedChains:o,baseUrl:i,logLevel:a,logger:r,sessions:s,plugins:l})=>{Pt();let c=s!=null&&s.mode?{mode:s.mode}:void 0;return new vo({appId:e,clientId:t,plugins:l,supportedChains:o,storage:xt(n),embeddedWalletMessagePoster:We,sdkVersion:`expo:${Rt.version}`,nativeAppIdentifier:At(),baseUrl:i,logLevel:a,logger:r,sessions:c})};import{useCallback as St,useContext as ps}from"react";import{PrivyClientError as ms}from"@privy-io/js-sdk-core";import ne,{useState as V,useMemo as ss,createContext as cs,useCallback as Ge,useRef as be,useEffect as no,useContext as ds}from"react";import{AppState as io,View as ls}from"react-native";import{PrivyClientError as ao}from"@privy-io/js-sdk-core";import bo from"react-fast-compare";import{create as So}from"zustand";var Ae=So(()=>{}),Mt=e=>Ae.setState(t=>bo(t,e)?t:e),U=Ae.getState;import ko from"react";import{useCallback as H,useEffect as Pe,useMemo as Gt,useRef as Y,useState as zt}from"react";import{AppState as Wo}from"react-native";import Ao from"react-native-webview";import*as j from"expo-secure-store";function Ot(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 Lt(e){return d(this,null,function*(){switch(e.event){case"app:secure-storage:get":{let{key:t}=e.data,n=yield j.getItemAsync(Ke(t),{keychainAccessible:j.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY}).catch(o=>(console.warn("Failed to get the value from secure store",o),null));return{event:e.event,id:e.id,data:{value:n}}}case"app:secure-storage:remove":{let{key:t}=e.data,n=yield j.deleteItemAsync(Ke(t),{keychainAccessible:j.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY}).then(()=>!0).catch(o=>(console.warn("Failed to remove the value from secure store",o),!1));return{event:e.event,id:e.id,data:{success:n}}}case"app:secure-storage:set":{let{key:t,value:n}=e.data,o=yield j.setItemAsync(Ke(t),n,{keychainAccessible:j.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:o}}}}})}var Ke=e=>e.replaceAll(":","-");import Eo from"react-fast-compare";import{createStore as Co,useStore as xe}from"zustand";import{PrivyClientError as _o}from"@privy-io/js-sdk-core";var O=Co()(()=>({user:null,storedUsers:[],webViewLoadCount:0})),Ft=e=>qt("onMfaEnrollmentRequired",e),Tt=e=>qt("onMfaVerificationRequired",e),R=()=>{var e,t;return(t=(e=O.getState().onMfaEnrollmentRequired)==null?void 0:e.fn)!=null?t:jt},I=()=>{var e,t;return(t=(e=O.getState().onMfaVerificationRequired)==null?void 0:e.fn)!=null?t:jt};function S(){return O.getState().user}var Ms=O.subscribe.bind(O);function Be(e){O.setState(({user:t})=>Eo(t,e)?{}:{user:e})}var Dt=e=>O.setState({storedUsers:e.users}),Nt=()=>O.setState(({webViewLoadCount:e})=>({webViewLoadCount:e+1}));function M(){return xe(O,e=>e.user)}function Os(){return xe(O,e=>!!e.user)}function Vt(){return xe(O,e=>e.storedUsers)}var He=()=>O.getState().webViewLoadCount;function Q(){return xe(O,e=>e.webViewLoadCount)}var qt=(e,t)=>(O.setState(n=>{let o=n[e];if(o&&o.lock!==t.lock)throw new _o({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}:{})}),jt=e=>d(void 0,null,function*(){throw e.error});var xo={shouldUseAppBackedStorage:!0},Po=";",Uo=500,Ro=(e,t)=>{if(!e)return!1;try{return new URL(e).origin===new URL(t).origin}catch(n){return!1}},Io=1e3,Mo=6e4,Je=e=>{try{return new URL(e).origin}catch(t){return}},Kt=({client:e,isClientReady:t})=>{let n=Y(null),o=Y(!1),[i,a]=zt(null);Pe(()=>{if(i!==null)return;let C=!1;return e.embeddedWallet.getURLAsync().then(A=>{C||a(P=>P!=null?P:A)}),()=>{C=!0}},[e,i]);let r=Gt(()=>i?Je(i):void 0,[i]);Pe(()=>{if(r===void 0||!t)return;let C=e.embeddedWallet.getURL();Je(C)!==r&&(e.logger.info("[privy:webview] navigating to the configured API origin"),e.embeddedWallet.reload(),a(C))},[e,t,r]);let s=Gt(()=>t&&r!==void 0&&Je(e.embeddedWallet.getURL())===r,[e,t,r]),[l,c]=zt(0),u=Y(0),p=Y(void 0),m=Y(0),h=Y(void 0);Pe(()=>()=>clearTimeout(h.current),[]);let b=H(C=>{e.logger.info(`[privy:webview] recreating, ${C}`),clearTimeout(h.current),u.current+=1,e.embeddedWallet.reload(),c(A=>A+1)},[e]);Pe(()=>{let C=Wo.addEventListener("change",A=>d(void 0,null,function*(){var P;if(A==="background")p.current=u.current,e.embeddedWallet.onBackground();else if(A==="active"){let q=(P=p.current)!=null?P:u.current;if(p.current=void 0,!o.current)return;!(yield e.embeddedWallet.ping(Uo))&&u.current===q&&e.embeddedWallet.reload()}}));return()=>C.remove()},[e]);let y=H(C=>d(void 0,null,function*(){var q;if(!Ro(C.nativeEvent.url,e.embeddedWallet.getURL()))return;let{data:A}=C.nativeEvent,P=JSON.parse(A);if(m.current=0,Ot(P)){let B=yield Lt(P);(q=n.current)==null||q.postMessage(JSON.stringify(B));return}e.embeddedWallet.onMessage(P)}),[e]),w=H(()=>{clearTimeout(h.current),Nt()},[]),f=H(()=>{var C;e.logger.info("[privy:webview] reloading, load failed"),e.embeddedWallet.reload(),o.current||(C=n.current)==null||C.reload()},[e]),E=H(C=>{let A=Math.min(Io*Ce(2,m.current),Mo);m.current+=1,e.logger.warn(`[privy:webview] load failed (${C.nativeEvent.code}: ${C.nativeEvent.description}), retrying in ${A}ms`),clearTimeout(h.current),h.current=setTimeout(f,A)},[e,f]),v=H(()=>{b("content process terminated")},[b]),k=H(()=>{b("render process gone")},[b]);return i?ko.createElement(Ao,{key:l,style:{flex:1},ref:C=>{C&&(e.setMessagePoster(s?C:We),n.current=C,o.current=s)},cacheEnabled:!1,cacheMode:"LOAD_NO_CACHE",injectedJavaScriptObject:xo,injectedJavaScriptBeforeContentLoaded:Po,source:{uri:i},webviewDebuggingEnabled:e.logger.level==="DEBUG",onLoad:w,onError:E,onMessage:y,onContentProcessDidTerminate:v,onRenderProcessGone:k}):null};import{useEffect as Xt,useRef as Lo}from"react";import{AppState as Fo}from"react-native";import{Platform as $e}from"react-native";var Oo="sdk_initialize";function Bt(){let{major:e,minor:t,patch:n,prerelease:o}=$e.constants.reactNativeVersion;return{name:Oo,properties:{reactNativeVersion:`${e}.${t}.${n}${o!=null?`-${o}`:""}`,operatingSystem:`${$e.OS}:${$e.Version}`}}}import{PrivyApiError as Jt,PrivyClientError as $t}from"@privy-io/js-sdk-core";function _(e){return e instanceof Error||e instanceof Jt||e instanceof $t?e:typeof e=="string"?new Error(e):new Error("Unknown error")}var Qt=e=>{if(e instanceof Jt)return`${e.code}`=="missing_or_invalid_token"?"logged_out":e.status===408||e.status===429||e.status>=500?"transient":"permanent";if(e instanceof $t&&(e.code==="connection_failed"||e.code==="request_timeout")||e instanceof TypeError||e instanceof SyntaxError)return"transient";let t=e==null?void 0:e.name;return t==="AbortError"||t==="TimeoutError"?"transient":"permanent"},Yt=(e,t)=>e===t||e!==null&&t!==null&&e.name===t.name&&e.message===t.message&&Ht(e)===Ht(t),Ht=e=>"code"in e?String(e.code):void 0;var Zt=({client:e,setIsUserInitialized:t,setError:n})=>{let o=Lo(e);Xt(()=>{o.current=e},[e]),Xt(()=>{let i=!1,a=!1,r=!1,s=!1,l=0,c,u=!1,p=y=>{n(w=>Yt(w,y)?w:y),t(!0)},m=()=>d(void 0,null,function*(){r=!0;let y=o.current;try{if(yield y.initialize(),a||(a=!0,y.track(Bt())),yield y.user.get(),i)return;s=!1,p(null)}catch(w){if(i)return;let f=_(w);switch(Qt(w)){case"logged_out":{s=!1,p(null);return}case"permanent":{s=!1,p(f);return}case"transient":{if(s=!0,p(f),l<To){let E=Math.min(Do*Ce(2,l),No);l+=1,c=setTimeout(h,E)}return}}}finally{r=!1}}),h=()=>{if(c=void 0,S()){s=!1;return}m()},b=Fo.addEventListener("change",y=>{if(y==="background"){u=!0;return}y!=="active"||!u||(u=!1,!(!s||r)&&(clearTimeout(c),h()))});return m(),()=>{i=!0,clearTimeout(c),b.remove()}},[n,t])},To=8,Do=1e3,No=6e4;import{useCallback as Qe,useEffect as Ye,useMemo as Xe,useRef as qo}from"react";import{errorIndicatesRecoveryIsNeeded as jo,getAllUserEmbeddedSolanaWallets as Go,getEntropyDetailsFromUser as nr,PrivyClientError as de}from"@privy-io/js-sdk-core";import{getAllUserEmbeddedSolanaWallets as er,getEntropyDetailsFromAccount as tr,getUserEmbeddedEthereumWallet as Vo,PrivyClientError as ce}from"@privy-io/js-sdk-core";function rr(a){return d(this,arguments,function*({client:e,setSolanaWallet:t,createSolanaWalletCallbacks:n,setSolanaRecoveryFlowState:o,opts:i}){var r,s,l;t({status:"creating"});try{let{user:c}=yield e.user.get(),u=er(c),p=u[0],m=(r=Vo(c))!=null?r:void 0;if(i!=null&&i.recoveryMethod&&i.recoveryMethod!=="privy")throw new ce({code:"embedded_wallet_creation_error",error:"Unsupported recovery method for solana wallet."});if(!(i!=null&&i.createAdditional)&&p)throw new ce({code:"embedded_wallet_creation_error",error:"Solana wallet already exists for this user. Set `createAdditional` to `true` to create another wallet"});let h,b;if(p){let w=m!=null?m:p,{entropyId:f,entropyIdVerifier:E}=tr(w),v=Math.max(...u.map(A=>A.wallet_index),0)+1,k=yield e.embeddedWallet.add({chainType:"solana",entropyId:f,entropyIdVerifier:E,hdWalletIndex:v}),C=k.account;if(!C||C.chain_type!=="solana")throw new ce({error:"Embedded wallet account not created",code:"embedded_wallet_creation_error"});h=yield e.embeddedWallet.getSolanaProvider(C,f,E,void 0,void 0,void 0,void 0,A=>d(this,null,function*(){return yield R()(A)}),A=>d(this,null,function*(){return yield I()(A)})),b=k.user}else{let{user:w,wallet:f}=yield e.embeddedWallet.createSolanaWallet({ethereumAccount:m}),E=m!=null?m:f,{entropyId:v,entropyIdVerifier:k}=tr(E);h=yield e.embeddedWallet.getSolanaProvider(f,v,k,void 0,void 0,void 0,void 0,C=>d(this,null,function*(){return yield R()(C)}),C=>d(this,null,function*(){return yield I()(C)})),b=w.user}let y=er(b)[0];if(!y)throw new ce({code:"embedded_wallet_creation_error",error:"Unknown error creating solana wallet"});return(l=(s=n.current)==null?void 0:s.onSuccess)==null||l.call(s,h),t({status:"connected",publicKey:y.public_key}),o({status:"initial"}),h}catch(c){let u=c instanceof Error?c.message:"Error creating embedded wallet";throw t({status:"error",error:u}),o({status:"initial"}),new ce({code:"embedded_wallet_creation_error",error:u})}})}import{PrivyClientError as J}from"@privy-io/js-sdk-core";function Ue(u){return d(this,arguments,function*({client:e,account:t,setWallet:n,recoverWalletCallbacks:o,recoveryMethod:i,setRecoveryFlowState:a,password:r,recoveryKey:s,recoveryToken:l,recoverySecretOverride:c}){var p,m,h,b;if(!t)throw new J({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});switch(i){case"user-passcode":if(!r)throw new J({code:"embedded_wallet_recovery_error",error:"password is required for user-passcode recovery method"});break;case"google-drive":if(!l)throw new J({code:"embedded_wallet_recovery_error",error:"Recovery token is required for google-drive recovery method"});break;case"icloud":if(!c)throw new J({code:"embedded_wallet_recovery_error",error:"Record name is required for icloud recovery method"});break;case"recovery-encryption-key":if(!s)throw new J({code:"embedded_wallet_recovery_error",error:"recoveryKey is required for recovery-encryption-key recovery method"});break}n({status:"connecting",account:t});try{let y=yield e.embeddedWallet.getEthereumProvider({wallet:t,entropyId:t.address,entropyIdVerifier:"ethereum-address-verifier",recoveryPassword:r,recoveryAccessToken:l,recoverySecretOverride:c,recoveryKey:s,onMfaEnrollmentRequired:w=>d(this,null,function*(){return yield R()(w)}),onMfaVerificationRequired:w=>d(this,null,function*(){return yield I()(w)})});return n({status:"connected",provider:y,account:t}),a({status:"initial"}),(m=(p=o.current)==null?void 0:p.onSuccess)==null||m.call(p,y),y}catch(y){n({status:"needs-recovery",account:t}),a({status:"initial"});let w=new J({code:"embedded_wallet_recovery_error",error:y instanceof Error?y.message:"Error recovering embedded wallet"});throw(b=(h=o.current)==null?void 0:h.onError)==null||b.call(h,w),w}})}function or(s){return d(this,arguments,function*({client:e,account:t,entropyId:n,entropyIdVerifier:o,setSolanaWallet:i,recoverSolanaWalletCallbacks:a,setSolanaRecoveryFlowState:r}){var l,c,u,p;i({status:"connecting"});try{let m=yield e.embeddedWallet.getSolanaProvider(t,n,o,void 0,void 0,void 0,void 0,h=>d(this,null,function*(){return yield R()(h)}),h=>d(this,null,function*(){return yield I()(h)}));return i({status:"connected",publicKey:m._publicKey}),r({status:"initial"}),(c=(l=a.current)==null?void 0:l.onSuccess)==null||c.call(l,m),m}catch(m){i({status:"needs-recovery"}),r({status:"initial"});let h=new J({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,h),h}})}var X=(e,t)=>d(void 0,null,function*(){let n=He();try{yield e()}catch(o){if(He()===n||!t())return;yield e().catch(()=>{})}});var ir=({client:e,solanaWallet:t,setSolanaWallet:n,setSolanaRecoveryFlowState:o,createSolanaWalletCallbacks:i,recoverSolanaWalletCallbacks:a})=>{let r=M(),s=Xe(()=>Go(r),[r]),l=Q(),c=qo(0),u=Xe(()=>s.length===0?null:nr(r,s[0]),[r,s]),p=Xe(()=>{let y=s.map(v=>{let k=nr(r,v);return k?{account:v,entropy:k}:null});if(y.some(v=>v===null))return[];let w=void 0,f=void 0,E=void 0;return y.filter(v=>v!==null).map(({account:v,entropy:{entropyId:k,entropyIdVerifier:C}})=>({address:v.address,publicKey:v.address,walletIndex:v.wallet_index,getProvider:()=>e.embeddedWallet.getSolanaProvider(v,k,C,w,f,E,A=>d(void 0,null,function*(){var P;yield(P=ke())==null?void 0:P(A)}),A=>d(void 0,null,function*(){return yield R()(A)}),A=>d(void 0,null,function*(){return yield I()(A)}))}))},[s,r,e]),m=Qe(y=>d(void 0,null,function*(){return yield rr({client:e,setSolanaWallet:n,createSolanaWalletCallbacks:i,setSolanaRecoveryFlowState:o,opts:y})}),[e,i]),h=Qe(()=>d(void 0,null,function*(){if(!u)throw new de({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});let{entropyId:y,entropyIdVerifier:w}=u;return or({client:e,account:s[0],entropyId:y,entropyIdVerifier:w,setSolanaWallet:n,recoverSolanaWalletCallbacks:a,setSolanaRecoveryFlowState:o})}),[e,u,s,a,o,n]),b=Qe(()=>d(void 0,null,function*(){if(!u)throw n({status:"not-created"}),new de({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});n(f=>f.status==="connected"?{status:"reconnecting"}:{status:"connecting"});let y=c.current,w=f=>{y===c.current&&n(f)};try{let{entropyId:f,entropyIdVerifier:E}=u,v=yield e.embeddedWallet.getSolanaProvider(s[0],f,E,void 0,void 0,void 0,void 0,k=>d(void 0,null,function*(){return yield R()(k)}),k=>d(void 0,null,function*(){return yield I()(k)}));return w({status:"connected",publicKey:s[0].public_key}),v}catch(f){throw jo(f)?(w({status:"needs-recovery"}),new de({code:"embedded_wallet_needs_recovery",error:"Embedded wallet not loaded on device"})):f instanceof Error?(w({status:"error",error:f.message}),new de({code:"unknown_embedded_wallet_error",error:f.message})):(w({status:"error",error:"Error loading embedded wallet"}),new de({code:"unknown_embedded_wallet_error",error:"Error loading embedded wallet"}))}}),[s,e,u,n]);return Ye(()=>{if(c.current+=1,!r){t.status!=="disconnected"&&n({status:"disconnected"});return}let y=c.current;X(b,()=>y===c.current)},[r]),Ye(()=>{if(t.status==="error"){let y=c.current;X(b,()=>y===c.current)}},[l]),Ye(()=>{t.status==="error"&&t.error.includes("User must be logged in")&&b()},[t.status]),{create:m,recover:h,getProvider:b,wallets:p}};import{useCallback as me,useEffect as et,useMemo as Yo,useRef as Xo}from"react";import{getUserEmbeddedEthereumWallet as Zo,getUserEmbeddedSolanaWallet as ur,isUnifiedWallet as en,throwIfInvalidRecoveryUpgradePath as tn}from"@privy-io/js-sdk-core";import{errorIndicatesRecoveryIsNeeded as rn,PrivyClientError as L}from"@privy-io/js-sdk-core";import{PrivyClientError as le}from"@privy-io/js-sdk-core";function Re(p){return d(this,arguments,function*({client:e,setWallet:t,createWalletCallbacks:n,recoveryMethod:o,setRecoveryFlowState:i,password:a,recoveryKey:r,recoveryToken:s,recoverySecretOverride:l,iCloudRecordNameOverride:c,solanaAccount:u}){var h,b;switch(o){case"user-passcode":if(!a)throw new le({code:"embedded_wallet_recovery_error",error:"password is required for user-passcode recovery method"});break;case"recovery-encryption-key":if(!r)throw new le({code:"embedded_wallet_recovery_error",error:"key is required for recovery-encryption-key recovery method"});break;case"google-drive":if(!s)throw new le({code:"embedded_wallet_recovery_error",error:"Recovery token is required for google-drive recovery method"});break;case"icloud":if(!l||!c)throw new le({code:"embedded_wallet_recovery_error",error:"iCloud recovery failed due to inability to store credentials"});break}t({status:"creating",account:null});let m=o==="icloud"?"icloud-native":o;try{let{wallet:y}=yield e.embeddedWallet.createEthereumWallet({password:a,recoveryMethod:m,recoveryKey:r,recoveryToken:s,recoverySecretOverride:l,iCloudRecordNameOverride:c,solanaAccount:u}),w=yield e.embeddedWallet.getEthereumProvider({wallet:y,entropyId:y.address,entropyIdVerifier:"ethereum-address-verifier",onMfaEnrollmentRequired:f=>d(this,null,function*(){return yield R()(f)}),onMfaVerificationRequired:f=>d(this,null,function*(){return yield I()(f)})});return(b=(h=n.current)==null?void 0:h.onSuccess)==null||b.call(h,w),t({status:"connected",provider:w,account:y}),i({status:"initial"}),w}catch(y){let w=y instanceof Error?y.message:"Error creating embedded wallet";throw t({status:"error",error:w,account:null}),i({status:"initial"}),new le({code:"embedded_wallet_creation_error",error:w})}})}import{Platform as sr}from"react-native";import{PrivyClientError as G}from"@privy-io/js-sdk-core";import{Platform as zo}from"react-native";var ar=new Set;function Ie(e,{isDevelopment:t=__DEV__,reactNativeVersion:n=zo.constants.reactNativeVersion,warn:o=i=>console.warn(i)}={}){if(!t||ar.has(e))return;let{major:i,minor:a,patch:r}=n;if(i>0||i===0&&a>=81)return;let l=`[Privy] Upcoming optional dependency change
2
+
3
+ This app uses React Native ${`${i}.${a}.${r}`}. A future @privy-io/expo release will make ${e} optional.
4
+
5
+ `,c=i===0&&a>=79?l+`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.`:l+`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.`;ar.add(e),o(c)}function cr(){return d(this,null,function*(){Ie("@privy-io/expo-native-extensions");try{return yield import("@privy-io/expo-native-extensions")}catch(e){throw new G({code:"configuration_error",error:"`@privy-io/expo-native-extensions` is not installed. Install it and rebuild the native app."})}})}function ue(o){return d(this,arguments,function*({user:e,appId:t,client:n}){var s;if(sr.OS==="android")throw new G({code:"embedded_wallet_recovery_error",error:"iCloud recovery is not supported on Android"});let i=yield cr(),a=yield n.recovery.icloudAuth.getICloudConfiguration("expo-ios");if(!(a==null?void 0:a.container_identifier))throw new G({code:"embedded_wallet_recovery_error",error:"An iCloud Container ID must be specified in the Privy Dashboard."});try{let{recoverySecret:l,iCloudRecordName:c}=yield i.writeRecoverySecretToICloud({containerId:a.container_identifier,appId:t,userId:e.id});return{recoverySecret:l,iCloudRecordName:c}}catch(l){if(l instanceof Error){let c=(s=l.message.split("Caused by: ")[1])!=null?s:"Error writing to iCloud";throw new G({code:"embedded_wallet_recovery_error",error:c})}throw new G({code:"embedded_wallet_recovery_error",error:"Error writing to iCloud"})}})}function Me(o){return d(this,arguments,function*({walletAddress:e,client:t,chainType:n}){var c;if(sr.OS==="android")throw new G({code:"embedded_wallet_recovery_error",error:"iCloud recovery is not supported on Android"});let i=yield cr(),r=(yield t.recovery.getRecoveryKeyMaterial(e,n)).icloud_record_name;if(!r)throw new G({code:"embedded_wallet_recovery_error",error:"iCloud recovery not properly backed up."});let s=yield t.recovery.icloudAuth.getICloudConfiguration("expo-ios"),l=s==null?void 0:s.container_identifier;if(!l)throw new G({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:l,recordName:r});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 G({code:"embedded_wallet_recovery_error",error:p})}throw new G({code:"embedded_wallet_recovery_error",error:"Error writing to iCloud"})}})}import*as $ from"expo-linking";import*as dr from"expo-web-browser";import{Platform as lr}from"react-native";import{PrivyClientError as ee}from"@privy-io/js-sdk-core";import Lc from"react-fast-compare";var Z=e=>new Promise(t=>setTimeout(t,e));import{useEffect as Ko,useRef as Bo}from"react";import{AppState as Ze}from"react-native";function Oe(){let e=Bo(Ze.currentState);Ko(()=>Ze.addEventListener("change",o=>{e.current=o}).remove,[]);function t(){return Ze.currentState}return{appState:e,getCurrentAppState:t}}function pe(i){return d(this,arguments,function*({provider:e,redirectUri:t,client:n,onError:o}){try{let a;switch(e){case"google-drive":{let{url:c}=yield n.recovery.auth.generateURL($.createURL(t||"/"));a=c;break}default:throw new ee({error:"OAuth invalid provider",code:"embedded_wallet_recovery_error"})}let r=yield dr.openAuthSessionAsync(a);if(lr.OS==="android")return;if(r.type!=="success")throw new ee({error:"Recovery OAuth session failed",code:"embedded_wallet_recovery_error"});let{queryParams:s}=$.parse(r.url),l;switch(e){case"google-drive":{let{privy_oauth_state:c,privy_oauth_code:u}=s;if(!u||!c)throw new ee({error:"Recovery OAuth invalid credentials",code:"embedded_wallet_recovery_error"});l=yield Le({oAuthCode:u,oAuthState:c,client:n});break}default:throw new ee({error:"Recovery OAuth invalid provider",code:"embedded_wallet_recovery_error"})}return l}catch(a){throw o==null||o(_(a)),a}})}function Le(o){return d(this,arguments,function*({oAuthCode:e,oAuthState:t,client:n}){let{access_token:i}=yield n.recovery.auth.authorize(e,t);if(!i)throw new ee({error:"OAuth invalid credentials",code:"login_with_oauth_returned_with_invalid_credentials"});return i})}var Ho=2*60*1e3;function Jo(e){let t;return new Promise((n,o)=>{t=$.addEventListener("url",a=>d(this,[a],function*({url:i}){if(!i)return;let{queryParams:r}=$.parse(i),{privy_oauth_state:s,privy_oauth_code:l}=r!=null?r:{};if(typeof l!="string"||typeof s!="string")return;let c=yield Le({client:e,oAuthCode:l,oAuthState:s});n(c)})),setTimeout(()=>{o(new ee({code:"embedded_wallet_set_recovery_error",error:"Failed to complete Google Drive recovery flow"}))},Ho)}).finally(()=>{t==null||t.remove()})}function Fe(e){return d(this,null,function*(){let t;lr.OS==="android"&&(t=Jo(e));let n=yield pe({provider:"google-drive",client:e});return n!=null?n:yield t})}import{getUserEmbeddedWallet as $o,PrivyClientError as Qo}from"@privy-io/js-sdk-core";function Te(a){return d(this,arguments,function*({client:e,recoveryInput:t,setWalletRecoveryCallbacks:n,setRecoveryFlowState:o,setWallet:i}){var r,s,l,c;try{let{provider:u,user:p}=yield e.embeddedWallet.setRecovery(t),m=u,h=$o(p);return i({status:"connected",provider:m,account:h}),(s=(r=n.current)==null?void 0:r.onSuccess)==null||s.call(r,m),o({status:"initial"}),m}catch(u){let p=new Qo({code:"embedded_wallet_set_recovery_error",error:u instanceof Error?u.message:"Error setting password on embedded wallet"});throw(c=(l=n.current)==null?void 0:l.onError)==null||c.call(l,p),o({status:"initial"}),p}})}function pr(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 mr=({client:e,appId:t,wallet:n,setWallet:o,setRecoveryFlowState:i,createWalletCallbacks:a,recoverWalletCallbacks:r,setWalletRecoveryCallbacks:s})=>{let l=M(),c=Yo(()=>Zo(l),[l]),u=Q(),p=Xo(0),m=me(f=>d(void 0,null,function*(){var B,Se;if(c)throw new L({error:"This user already has an embedded wallet",code:"embedded_wallet_already_exists"});let{user:E}=yield e.user.get(),{password:v,recoveryMethod:k,recoveryKey:C}=pr(f),A,P,q;if(k==="google-drive"&&(A=yield pe({provider:k,client:e,onError:(B=a.current)==null?void 0:B.onError}),i({status:"creating-wallet"}),!A))return null;if(k==="icloud"){if(!E)throw new L({code:"embedded_wallet_recovery_error",error:"User must be loaded before creating a wallet with iCloud."});let{recoverySecret:ae,iCloudRecordName:se}=yield ue({user:E,appId:t,client:e});P=ae,q=se}return yield Re({client:e,setWallet:o,createWalletCallbacks:a,recoveryMethod:k,recoveryKey:C,setRecoveryFlowState:i,password:v,recoverySecretOverride:P,iCloudRecordNameOverride:q,solanaAccount:(Se=ur(E))!=null?Se:void 0})}),[e,c,l]),h=me(f=>d(void 0,null,function*(){var k;if(n.status!=="connected")throw new L({code:"attempted_to_set_password_before_connected",error:"Embedded wallet must be connected before setting password"});if(!c)throw new L({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});if(ur(l))throw new L({code:"embedded_wallet_set_recovery_error",error:"Cannot set user-controlled recovery for a user with an embedded Solana wallet."});if(en(c))throw new L({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"});tn({currentRecoveryMethod:c.recovery_method,upgradeToRecoveryMethod:f.recoveryMethod});let E,v;switch(f.recoveryMethod){case"privy":v=D(W({},f),{wallet:c});break;case"user-passcode":v=D(W({},f),{wallet:c,password:f.password});break;case"google-drive":if(E=yield pe({provider:f.recoveryMethod,client:e,onError:(k=s.current)==null?void 0:k.onError}),i({status:"upgrading-recovery"}),!E)return null;v={recoveryMethod:"google-drive",wallet:c,recoveryAccessToken:E};break;case"icloud":if(!l)throw new L({code:"embedded_wallet_recovery_error",error:"User must be loaded before backing up to iCloud."});let{recoverySecret:C,iCloudRecordName:A}=yield ue({user:l,appId:t,client:e});v={recoveryMethod:"icloud-native",recoverySecretOverride:C,iCloudRecordNameOverride:A,wallet:c};break;default:throw new L({code:"embedded_wallet_recovery_error",error:"Unrecognized recovery method"})}return Te({client:e,recoveryInput:v,setWalletRecoveryCallbacks:s,setRecoveryFlowState:i,setWallet:o})}),[e,c,n.status,l]),b=me(f=>d(void 0,null,function*(){return h({recoveryMethod:"user-passcode",password:f})}),[e,c,n.status]),y=me(f=>d(void 0,null,function*(){var P;if(!c)throw new L({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});let{password:E,recoveryMethod:v,recoveryKey:k}=pr(f),C,A;if(v==="google-drive"&&(C=yield pe({provider:v,client:e,onError:(P=r.current)==null?void 0:P.onError}),i({status:"recovering"}),!C))return null;if(v==="icloud"){if(!l)throw new L({code:"embedded_wallet_recovery_error",error:"User must be loaded before recovering via iCloud."});let{recoverySecret:q}=yield Me({client:e,walletAddress:c.address});A=q}return Ue({client:e,account:c,setWallet:o,recoverWalletCallbacks:r,recoveryMethod:v,setRecoveryFlowState:i,recoveryKey:k,password:E,recoveryToken:C,recoverySecretOverride:A})}),[e,c]),w=me(()=>d(void 0,null,function*(){if(!c)throw o({status:"not-created",account:null}),new L({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});o(v=>v.status==="connected"?{status:"reconnecting",account:c}:{status:"connecting",account:c});let f=p.current,E=v=>{f===p.current&&o(v)};try{let v=yield e.embeddedWallet.getEthereumProvider({wallet:c,entropyId:c.address,entropyIdVerifier:"ethereum-address-verifier",onMfaEnrollmentRequired:k=>d(void 0,null,function*(){return yield R()(k)}),onMfaVerificationRequired:k=>d(void 0,null,function*(){return yield I()(k)})});return E({status:"connected",provider:v,account:c}),v}catch(v){throw rn(v)?(E({status:"needs-recovery",account:c}),new L({code:"embedded_wallet_needs_recovery",error:"Embedded wallet not loaded on device"})):v instanceof Error?(E({status:"error",error:v.message,account:c}),new L({code:"unknown_embedded_wallet_error",error:v.message})):(E({status:"error",error:"Error loading embedded wallet",account:c}),new L({code:"unknown_embedded_wallet_error",error:"Error loading embedded wallet"}))}}),[e,c]);return et(()=>{if(p.current+=1,!l){n.status!=="disconnected"&&o({status:"disconnected",account:null});return}let f=p.current;X(w,()=>f===p.current)},[l,c]),et(()=>{if(n.status==="error"){let f=p.current;X(w,()=>f===p.current)}},[u]),et(()=>{n.status==="error"&&n.error.includes("User must be logged in")&&w()},[n.status]),{create:m,recover:y,setPassword:b,setRecovery:h,getProvider:w}};import{useEffect as on,useState as nn}from"react";import{PrivyClientError as fr}from"@privy-io/js-sdk-core";var yr=({client:e,isReady:t})=>{let n=M(),o=Ae(r=>r==null?void 0:r.customAuth),[i,a]=nn({status:"initial"});return on(()=>{(()=>d(void 0,null,function*(){if(!(o!=null&&o.enabled)){a({status:"not-enabled"});return}a({status:"loading"});let{getCustomAccessToken:s,isLoading:l}=o;if(!(!t||l))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=U();if(!(yield e.auth.customProvider.syncWithToken(c,{embedded:u==null?void 0:u.embedded}))){yield e.auth.logout(),a({status:"error",error:new fr({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 fr({error:"Third-party auth failed",code:"third_party_auth_error"})}}))()},[e,n,t,o==null?void 0:o.enabled,o==null?void 0:o.getCustomAccessToken,o==null?void 0:o.isLoading]),{customAuthState:i,customAuthStateIsSettled:i.status!=="loading"&&i.status!=="initial"}};import*as te from"expo-linking";import{useCallback as an,useEffect as sn,useMemo as cn}from"react";import{Platform as dn}from"react-native";import{getUserEmbeddedSolanaWallet as ln,getUserEmbeddedWallet as un}from"@privy-io/js-sdk-core";var gr=({client:e,createWalletCallbacks:t,recoverWalletCallbacks:n,setWalletRecoveryCallbacks:o,recoveryFlowState:i,oAuthState:a,setRecoveryFlowState:r,setWallet:s,appStateVisible:l})=>{let c=te.useURL(),u=M(),p=cn(()=>un(u),[u]),m=Q()>0,h=an(b=>{var w,f,E,v;let y=_(b);i.status==="creating-wallet"?(f=(w=t.current).onError)==null||f.call(w,_(y)):(v=(E=n.current).onError)==null||v.call(E,_(y)),r({status:"initial"})},[i]);return sn(()=>{function b(){return d(this,null,function*(){var E;if(!c&&i.status!=="initial"&&l&&h(new Error("Recovery OAuth session failed")),!c||i.status==="initial"||a.status!=="initial"||!l||!m)return;let{queryParams:y}=te.parse(c),{privy_oauth_state:w,privy_oauth_code:f}=y;if(!(!f||!w)){yield te.openURL(c.split("?")[0]);try{let v=yield Le({oAuthCode:f,oAuthState:w,client:e});if(i.status==="creating-wallet"){let k=(E=ln(u))!=null?E:void 0;yield Re({client:e,setWallet:s,createWalletCallbacks:t,recoveryMethod:"google-drive",setRecoveryFlowState:r,recoveryToken:v,solanaAccount:k})}else if(i.status==="upgrading-recovery"){if(!p)throw new Error("Embedded wallet not found");yield Te({client:e,recoveryInput:{recoveryMethod:"google-drive",wallet:p,recoveryAccessToken:v},setWalletRecoveryCallbacks:o,setRecoveryFlowState:r,setWallet:s})}else yield Ue({client:e,account:p,setWallet:s,recoverWalletCallbacks:n,recoveryMethod:"google-drive",setRecoveryFlowState:r,recoveryToken:v})}catch(v){h(v)}}})}dn.OS==="android"&&b()},[c,i.status,l,m])};import{useEffect as is,useRef as as}from"react";import{useCallback as tt,useContext as pn}from"react";import{PrivyClientError as mn}from"@privy-io/js-sdk-core";var Td=e=>{let{client:t,setSiweState:n,siweState:o}=pn(g),i=tt(s=>{var c;let l=_(s);return n({status:"error",error:l}),(c=e==null?void 0:e.onError)==null||c.call(e,l),l},[e==null?void 0:e.onError]),a=tt(u=>d(void 0,[u],function*({wallet:s,from:{domain:l,uri:c}}){var p;try{n({status:"generating-message"});let m=yield t.auth.siwe.init(s,l,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:tt(u=>d(void 0,[u],function*({signature:s,messageOverride:l,disableSignup:c}){var p;try{if(S())throw new mn({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 h=U(),b=yield t.auth.siwe.loginWithSiwe(s,void 0,l,c?"no-signup":"login-or-sign-up",{embedded:h==null?void 0:h.embedded});return n({status:"done"}),(p=e==null?void 0:e.onSuccess)==null||p.call(e,b.user,b.is_new_user),b.user}catch(m){throw i(m)}}),[t,i,e==null?void 0:e.onSuccess]),generateSiweMessage:a,state:o}};import{useCallback as hr}from"react";import{createSiwsMessage as yn,PrivyClientError as gn}from"@privy-io/js-sdk-core";import{useContext as fn}from"react";var x=()=>{let{client:e}=fn(g);return e};var Jd=()=>{let e=x(),t=hr(s=>d(void 0,[s],function*({wallet:{address:o},from:{domain:i,uri:a},chain:r}){try{let{nonce:l}=yield e.auth.siws.fetchNonce({address:o});return{message:yn({address:o,domain:i,uri:a,nonce:l,chain:r})}}catch(l){throw _(l)}}),[e]),n=hr(s=>d(void 0,[s],function*({signature:o,message:i,wallet:{walletClientType:a,connectorType:r}={}}){try{if(!S())throw new gn({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:o,message:i,walletClientType:a,connectorType:r});return c}catch(l){throw _(l)}}),[e]);return{generateMessage:t,link:n}};import{useCallback as wr}from"react";import{createSiwsMessage as hn,PrivyClientError as wn}from"@privy-io/js-sdk-core";var ol=()=>{let e=x(),t=wr(s=>d(void 0,[s],function*({wallet:{address:o},from:{domain:i,uri:a},chain:r}){try{let{nonce:l}=yield e.auth.siws.fetchNonce({address:o});return{message:hn({address:o,domain:i,uri:a,nonce:l,chain:r})}}catch(l){throw _(l)}}),[e]),n=wr(l=>d(void 0,[l],function*({signature:o,message:i,wallet:{walletClientType:a,connectorType:r}={},disableSignup:s}){try{if(S())throw new wn({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=U();return(yield e.auth.siws.login({signature:o,message:i,walletClientType:a,connectorType:r,mode:s?"no-signup":"login-or-sign-up",opts:{embedded:u==null?void 0:u.embedded}})).user}catch(c){throw _(c)}}),[e]);return{generateMessage:t,login:n}};import{useCallback as vr,useContext as vn}from"react";import{PrivyClientError as bn}from"@privy-io/js-sdk-core";var ul=e=>{let{client:t}=vn(g),n=vr(i=>{var r;let a=_(i);return(r=e==null?void 0:e.onError)==null||r.call(e,a),a},[e==null?void 0:e.onError]);return{unlinkWallet:vr(a=>d(void 0,[a],function*({address:i}){var r;try{if(!S())throw new bn({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:l}=yield t.auth.siwe.unlinkWallet(i);return(r=e==null?void 0:e.onSuccess)==null||r.call(e,l),l}catch(s){throw n(s)}}),[t,n,e==null?void 0:e.onSuccess])}};import{useCallback as rt,useContext as Sn,useState as En}from"react";import{PrivyClientError as br}from"@privy-io/js-sdk-core";var vl=e=>{let[t,n]=En(""),{client:o,otpState:i,setOtpState:a}=Sn(g),r=rt(c=>{var p;let u=_(c);return a({status:"error",error:u}),(p=e==null?void 0:e.onError)==null||p.call(e,u),u},[e,a]),s=rt(u=>d(void 0,[u],function*({email:c}){var p;n(c);try{a({status:"sending-code"});let m=yield o.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 r(m)}}),[o,r,e,a]),l=rt(p=>d(void 0,[p],function*({code:c,email:u}){var m;try{if(!S())throw new br({code:"attempted_link_email_before_logged_in",error:"Must be logged in to link an email, Use `useLoginWithEmail` to login with email"});let b=u||t;if(!b)throw new br({code:"attempted_submit_otp_before_sending",error:"Must `sendCode` with a valid email before calling `linkWithCode`"});a({status:"submitting-code"});let{user:y}=yield o.auth.email.linkWithCode(b,c);return a({status:"done"}),(m=e==null?void 0:e.onLinkSuccess)==null||m.call(e,y),y}catch(h){throw r(h)}}),[t,a,o,e,r]);return{sendCode:s,linkWithCode:l,state:i}};import{useCallback as Sr,useContext as Cn}from"react";var kl=e=>{let{client:t}=Cn(g),n=Sr(i=>{var r;let a=_(i);return(r=e==null?void 0:e.onError)==null||r.call(e,a),a},[e==null?void 0:e.onError]);return{unlinkEmail:Sr(a=>d(void 0,[a],function*({email:i}){var r;try{let{user:s}=yield t.auth.email.unlink(i);return(r=e==null?void 0:e.onSuccess)==null||r.call(e,s),s}catch(s){throw n(s)}}),[t,e==null?void 0:e.onSuccess,n])}};import{useCallback as ot,useContext as _n,useState as kn}from"react";import{PrivyClientError as Er}from"@privy-io/js-sdk-core";var Ol=e=>{let[t,n]=kn(""),{client:o,otpState:i,setOtpState:a}=_n(g),r=ot(c=>{var p;let u=_(c);return a({status:"error",error:u}),(p=e==null?void 0:e.onError)==null||p.call(e,u),u},[e,a]),s=ot(u=>d(void 0,[u],function*({email:c}){var p;n(c);try{a({status:"sending-code"});let m=yield o.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 r(m)}}),[o,r,e,a]),l=ot(m=>d(void 0,[m],function*({code:c,email:u,disableSignup:p}){var h;try{if(S()&&!o.isMultiUserModeEnabled)throw new Er({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 y=u||t;if(!y)throw new Er({code:"attempted_submit_otp_before_sending",error:"Must `sendCode` with a valid email before calling `loginWithCode`"});a({status:"submitting-code"});let w=U(),f=yield o.auth.email.loginWithCode(y,c,p?"no-signup":"login-or-sign-up",{embedded:w==null?void 0:w.embedded});return a({status:"done"}),(h=e==null?void 0:e.onLoginSuccess)==null||h.call(e,f.user,f.is_new_user),f==null?void 0:f.user}catch(b){throw r(b)}}),[t,a,o,e,r]);return{sendCode:s,loginWithCode:l,state:i}};import{useCallback as nt,useContext as Wn,useState as An}from"react";import{PrivyClientError as Cr}from"@privy-io/js-sdk-core";var jl=e=>{let[t,n]=An(""),{client:o,otpState:i,setOtpState:a}=Wn(g),r=nt(c=>{var p;let u=_(c);return a({status:"error",error:u}),(p=e==null?void 0:e.onError)==null||p.call(e,u),u},[e,a]),s=nt(u=>d(void 0,[u],function*({phone:c}){var p;n(c);try{a({status:"sending-code"});let m=yield o.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 r(m)}}),[o,r,e,a]),l=nt(p=>d(void 0,[p],function*({code:c,phone:u}){var m;try{if(!S())throw new Cr({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 Cr({code:"attempted_submit_otp_before_sending",error:"Must `sendCode` with a valid phone number before calling `linkWithCode`"});a({status:"submitting-code"});let{user:y}=yield o.auth.phone.linkWithCode(u||t,c);return a({status:"done"}),(m=e==null?void 0:e.onLinkSuccess)==null||m.call(e,y),y}catch(h){throw r(h)}}),[t,a,o,e,r]);return{sendCode:s,linkWithCode:l,state:i}};import{useCallback as it,useContext as xn,useState as Pn}from"react";import{PrivyClientError as _r}from"@privy-io/js-sdk-core";var Yl=e=>{let[t,n]=Pn(""),{client:o,otpState:i,setOtpState:a}=xn(g),r=it(c=>{var p;let u=_(c);return a({status:"error",error:u}),(p=e==null?void 0:e.onError)==null||p.call(e,u),u},[e,a]),s=it(u=>d(void 0,[u],function*({phone:c}){var p;n(c);try{a({status:"sending-code"});let m=yield o.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 r(m)}}),[o,r,e,a]),l=it(m=>d(void 0,[m],function*({code:c,phone:u,disableSignup:p}){var h;try{if(S())throw new _r({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 _r({code:"attempted_submit_otp_before_sending",error:"Must `sendCode` with a valid phone number before calling `loginWithCode`"});a({status:"submitting-code"});let w=U(),f=yield o.auth.phone.loginWithCode(u||t,c,p?"no-signup":"login-or-sign-up",{embedded:w==null?void 0:w.embedded});return a({status:"done"}),(h=e==null?void 0:e.onLoginSuccess)==null||h.call(e,f.user,f.is_new_user),f==null?void 0:f.user}catch(b){throw r(b)}}),[t,a,o,e,r]);return{sendCode:s,loginWithCode:l,state:i}};import*as De from"expo-linking";import{useCallback as at,useContext as Un,useRef as Rn}from"react";import{PrivyClientError as fe}from"@privy-io/js-sdk-core";var iu=e=>{let{appState:t,getCurrentAppState:n}=Oe(),{client:o,farcasterState:i,setFarcasterState:a}=Un(g),r=Rn(!1),s=at(u=>{var m;let p=_(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]),l=at(()=>{r.current=!0},[]);return{linkWithFarcaster:at((h,...b)=>d(void 0,[h,...b],function*({relyingParty:u,redirectUrl:p},m={pollAttempts:10,pollIntervalMs:1e3}){var y;try{let w=S();if(r.current=!1,!w)throw new fe({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:E}=yield o.auth.farcaster.initializeAuth({relyingParty:u,redirectUrl:De.createURL(p!=null?p:"/")});if(!f)throw new fe({code:"failed_to_generate_farcaster_uri",error:"Failed to generate farcaster uri"});if(!E)throw new fe({code:"failed_to_generate_farcaster_channel_token",error:"Failed to generate farcaster channel token"});yield De.openURL(f),a({status:"polling-status"});let v=0;for(;v<m.pollAttempts;){if(r.current)throw new fe({code:"farcaster_polling_canceled",error:"Farcaster polling canceled"});if(t.current!=="active"&&n()!=="active"){yield Z(m.pollIntervalMs);continue}let k=yield o.auth.farcaster.getFarcasterStatus({channel_token:E});if(k.state==="completed"){a({status:"submitting-token"});let{user:C}=yield o.auth.farcaster.link(W({channel_token:E},k));return a({status:"done"}),(y=e==null?void 0:e.onSuccess)==null||y.call(e,C),C}v++,yield Z(m.pollIntervalMs)}throw new fe({code:"farcaster_polling_timeout",error:"Farcasting polling timed out"})}catch(w){throw s(w)}}),[o,e==null?void 0:e.onSuccess,s,a]),state:i,cancel:l}};import{useCallback as kr,useContext as In}from"react";var uu=e=>{let{client:t}=In(g),n=kr(i=>{var r;let a=_(i);return(r=e==null?void 0:e.onError)==null||r.call(e,a),a},[e==null?void 0:e.onError]);return{unlinkFarcaster:kr(a=>d(void 0,[a],function*({fid:i}){var r;try{let{user:s}=yield t.auth.farcaster.unlink({fid:i});return(r=e==null?void 0:e.onSuccess)==null||r.call(e,s),s}catch(s){throw n(s)}}),[t,e==null?void 0:e.onSuccess,n])}};import*as Ne from"expo-linking";import{useCallback as dt,useContext as Mn,useRef as On}from"react";import{PrivyClientError as ye}from"@privy-io/js-sdk-core";var bu=e=>{let{appState:t,getCurrentAppState:n}=Oe(),{client:o,farcasterState:i,setFarcasterState:a}=Mn(g),r=On(!1),s=dt(u=>{var m;let p=_(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]),l=dt(()=>{r.current=!0},[]);return{loginWithFarcaster:dt((b,...y)=>d(void 0,[b,...y],function*({relyingParty:u,redirectUrl:p,disableSignup:m},h={pollAttempts:10,pollIntervalMs:1e3}){var w;try{if(r.current=!1,S())throw new ye({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:E,channel_token:v}=yield o.auth.farcaster.initializeAuth({relyingParty:u,redirectUrl:Ne.createURL(p!=null?p:"/")});if(!E)throw new ye({code:"failed_to_generate_farcaster_uri",error:"Failed to generate farcaster uri"});if(!v)throw new ye({code:"failed_to_generate_farcaster_channel_token",error:"Failed to generate farcaster channel token"});yield Ne.openURL(E),a({status:"polling-status"});let k=0;for(;k<h.pollAttempts;){if(r.current)throw new ye({code:"farcaster_polling_canceled",error:"Farcaster polling canceled"});if(t.current!=="active"&&n()!=="active"){yield Z(h.pollIntervalMs);continue}let C=yield o.auth.farcaster.getFarcasterStatus({channel_token:v});if(C.state==="completed"){a({status:"submitting-token"});let A=U(),P=yield o.auth.farcaster.authenticate(W({channel_token:v,mode:m?"no-signup":"login-or-sign-up"},C),{embedded:A==null?void 0:A.embedded});return a({status:"done"}),(w=e==null?void 0:e.onSuccess)==null||w.call(e,P.user,P.is_new_user),P.user}k++,yield Z(h.pollIntervalMs)}throw new ye({code:"farcaster_polling_timeout",error:"Farcasting polling timed out"})}catch(f){throw s(f)}}),[o,s,e==null?void 0:e.onSuccess,a,t]),state:i,cancel:l}};import{useCallback as Wr,useContext as Ln}from"react";import{create as Fn}from"zustand";import{PrivyClientError as Tn}from"@privy-io/js-sdk-core";var lt=Fn(()=>({status:"initial"})),K=e=>lt.setState(e,!0),Dn=lt.getState,Uu=()=>{let{client:e}=Ln(g),t=lt(),n=Wr(()=>d(void 0,null,function*(){try{K({status:"fetching-nonce"});let i=yield e.auth.farcasterV2.initializeAuth();return K({status:"awaiting-signature"}),i}catch(i){let a=_(i);throw K({status:"initial",error:a}),a}}),[e]),o=Wr(i=>d(void 0,null,function*(){let a=Dn().status;try{if(S()){let c=new Tn({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 K({status:a,error:c}),c}K({status:"submitting-signature"});let s=U(),l=yield e.auth.farcasterV2.authenticate(i,{embedded:s==null?void 0:s.embedded});return K({status:"done"}),setTimeout(()=>K({status:"initial"}),1500),{user:l.user}}catch(r){let s=_(r);throw K({status:a,error:s}),s}}),[e]);return{init:n,login:o,state:t}};import{useContext as Nn,useMemo as Vn}from"react";import{delegatedActions as Ar}from"@privy-io/js-sdk-core";var Fu=()=>{let{client:e}=Nn(g);return Vn(()=>({delegateWallet:Ar.delegateWallet(e),revokeWallets:Ar.revokeWallets(e)}),[e])};import{useContext as qn,useMemo as jn}from"react";import{depositAddress as ge}from"@privy-io/js-sdk-core";var qu=()=>{let{client:e}=qn(g);return jn(()=>({getConfig:()=>ge.getConfig(e),generateDepositAddress:t=>ge.generateDepositAddress(W({privy:e},t)),getDeposit:t=>ge.getDeposit(W({privy:e},t)),waitForDeposit:t=>ge.waitForDeposit(W({privy:e},t)),waitForCompletion:t=>ge.waitForCompletion(W({privy:e},t))}),[e])};import{useContext as zn,useMemo as Kn}from"react";import{cryptoDepositAccount as Ve}from"@privy-io/js-sdk-core";import{withMfaErrorHandling as Gn}from"@privy-io/js-sdk-core";var N=e=>d(void 0,null,function*(){return Gn({callback:e,onMfaEnrollmentRequired:t=>R()(t),onMfaVerificationRequired:t=>I()(t)})});var Xu=()=>{let{client:e}=zn(g);return Kn(()=>({createCryptoDepositAccount:t=>N(()=>Ve.createCryptoDepositAccount(e,(...n)=>e.embeddedWallet.signWithUserSigner(...n),t)),getQuote:t=>Ve.getCryptoDepositAccountQuote(e,t),getOrder:t=>Ve.getCryptoDepositAccountOrder(e,t),getNextOrder:t=>Ve.getCryptoDepositAccountNextOrder(e,t)}),[e])};import{useMemo as ei}from"react";import{useContext as Jn,useMemo as $n}from"react";import{addSessionSigners as Qn,getWallet as Yn,isUnifiedWallet as xr,removeSessionSigners as Xn,updateWallet as Zn}from"@privy-io/js-sdk-core";import{isEmbeddedWalletAccount as Bn}from"@privy-io/js-sdk-core";function Hn(e,t){return e.linked_accounts.filter(Bn).find(n=>n.address===t)}function ut(e){let t=S();if(!t)throw new Error("User must be authenticated to perform this operation");let n=Hn(t,e);if(!n)throw new Error(`No wallet found with address ${e}`);return n}var Pr=()=>{let{client:e}=Jn(g);return $n(()=>{let t=(n,o)=>d(void 0,null,function*(){yield N(()=>Zn(e,{wallet_id:n},(...a)=>e.embeddedWallet.signWithUserSigner(...a),{additional_signers:o}));let{user:i}=yield e.user.get();if(!i)throw new Error("Could not refresh user");return{user:i}});return{addSigners:i=>d(void 0,[i],function*({address:n,signers:o}){let a=ut(n),r=o.map(l=>({signer_id:l.signerId,override_policy_ids:l.policyIds}));if(!xr(a)||a.chain_type!=="ethereum"&&a.chain_type!=="solana"||!o.length)return Qn({client:e,wallet:a,signers:r});let s=yield Yn(e,{wallet_id:a.id});return t(a.id,s.additional_signers.concat(r))}),removeSigners:o=>d(void 0,[o],function*({address:n}){let i=ut(n);return xr(i)?t(i.id,[]):Xn({client:e,wallet:i})})}},[e])};var pp=()=>{let{addSigners:e,removeSigners:t}=Pr();return ei(()=>({addSessionSigners:e,removeSessionSigners:t}),[e,t])};import{useContext as ti,useMemo as ri}from"react";import{PrivyClientError as Rr}from"@privy-io/js-sdk-core";var wp=()=>{let{client:e}=ti(g);return ri(()=>({sendCode(o){return d(this,arguments,function*({newEmailAddress:n}){Ur(),yield e.auth.email.sendCode(n)})},updateEmail(i){return d(this,arguments,function*({newEmailAddress:n,code:o}){let{address:a}=Ur(),{user:r}=yield e.auth.email.updateEmail({oldEmailAddress:a,newEmailAddress:n,code:o});return r})}}),[e])};function Ur(){let t=oi().linked_accounts.find(n=>n.type==="email");if(!t)throw new Rr({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 oi(){let e=S();if(!e)throw new Rr({code:"attempted_update_before_logged_in",error:"Must be logged in to update a user profile."});return e}import{useContext as ni,useMemo as ii}from"react";import{PrivyClientError as Mr}from"@privy-io/js-sdk-core";var kp=()=>{let{client:e}=ni(g);return ii(()=>({sendCode(o){return d(this,arguments,function*({newPhoneNumber:n}){Ir(),yield e.auth.phone.sendCode(n)})},updatePhone(i){return d(this,arguments,function*({newPhoneNumber:n,code:o}){let{phoneNumber:a}=Ir(),{user:r}=yield e.auth.phone.updatePhone({oldPhoneNumber:a,newPhoneNumber:n,code:o});return r})}}),[e])};function Ir(){let t=ai().linked_accounts.find(n=>n.type==="phone");if(!t)throw new Mr({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 ai(){let e=S();if(!e)throw new Mr({code:"attempted_update_before_logged_in",error:"Must be logged in to update a user profile."});return e}import*as Fr from"expo-linking";import{useCallback as ci,useContext as di,useMemo as li}from"react";import{crossApp as ui,PrivyClientError as pi}from"@privy-io/js-sdk-core";import*as Lr from"expo-linking";import*as he from"expo-web-browser";import{PrivyClientError as Or}from"@privy-io/js-sdk-core";var z=(e,t)=>d(void 0,null,function*(){let n=yield he.openAuthSessionAsync(e,t,{createTask:!1});if(n.type!=="success")throw n.type===he.WebBrowserResultType.CANCEL||n.type===he.WebBrowserResultType.DISMISS?new Or({error:"OAuth session was cancelled",code:"oauth_session_failed"}):new Or({error:"OAuth session failed",code:"oauth_session_failed"});return si(n.url)});function si(e){let{queryParams:t}=Lr.parse(e);return t}var Tp=()=>{let{client:e}=di(g),t=li(()=>ui.loginWithCrossAppAuth({client:e,openAuthSession:z}),[e]);return{loginWithCrossApp:ci(a=>d(void 0,[a],function*({appId:o,redirectUri:i}){if(S())throw new pi({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=U(),{user:l}=yield t({providerAppId:o,redirectUrl:Fr.createURL(i||"/"),loginOptions:{embedded:s==null?void 0:s.embedded}});return{user:l}}),[t])}};import*as Tr from"expo-linking";import{useCallback as mi,useContext as fi,useMemo as yi}from"react";import{crossApp as gi,PrivyClientError as hi}from"@privy-io/js-sdk-core";var Kp=()=>{let{client:e}=fi(g),t=yi(()=>gi.linkWithCrossAppAuth({client:e,openAuthSession:z}),[e]);return{linkWithCrossApp:mi(a=>d(void 0,[a],function*({appId:o,redirectUri:i}){if(!S())throw new hi({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:o,redirectUrl:Tr.createURL(i||"/")})}}),[t])}};import*as Nr from"expo-linking";import{useContext as wi,useMemo as Dr}from"react";import{crossApp as vi}from"@privy-io/js-sdk-core";var Zp=()=>{let{client:e}=wi(g),t=Dr(()=>vi.wallet.signMessage({client:e,openAuthSession:z}),[e]);return Dr(()=>({signMessage:({address:n,message:o,redirectUri:i="/"})=>t({user:S(),address:n,message:o,redirectUrl:Nr.createURL(i)})}),[t])};import*as qr from"expo-linking";import{useContext as bi,useMemo as Vr}from"react";import{crossApp as Si}from"@privy-io/js-sdk-core";var am=()=>{let{client:e}=bi(g),t=Vr(()=>Si.wallet.signTypedData({client:e,openAuthSession:z}),[e]);return Vr(()=>({signTypedData:({address:n,typedData:o,redirectUri:i="/"})=>t({user:S(),address:n,typedData:o,redirectUrl:qr.createURL(i)})}),[t])};import*as Gr from"expo-linking";import{useContext as Ei,useMemo as jr}from"react";import{crossApp as Ci}from"@privy-io/js-sdk-core";var mm=()=>{let{client:e}=Ei(g),t=jr(()=>Ci.wallet.sendTransaction({client:e,openAuthSession:z}),[e]);return jr(()=>({sendTransaction:({address:n,transaction:o,redirectUri:i="/"})=>t({user:S(),address:n,transaction:o,redirectUrl:Gr.createURL(i)})}),[t])};import{useCallback as _i,useContext as ki}from"react";import{getUserEmbeddedEthereumWallet as Wi,getUserEmbeddedSolanaWallet as Ai,isUnifiedWallet as xi,PrivyClientError as re,throwIfInvalidRecoveryUpgradePath as Pi}from"@privy-io/js-sdk-core";var Sm=()=>{let{client:e}=ki(g);return{setRecovery:_i(n=>d(void 0,null,function*(){var s;let o=S(),i=e.app.appId;if(!o)throw new re({code:"embedded_wallet_recovery_error",error:"User must be loaded before attempting to modify the recovery method."});let a=(s=Wi(o))!=null?s:Ai(o);if(!a)throw new re({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});if(xi(a))throw new re({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(l){throw new re({code:"attempted_to_set_password_before_connected",error:"Embedded wallet must be connected before setting password"})}Pi({currentRecoveryMethod:a.recovery_method,upgradeToRecoveryMethod:n.recoveryMethod});let r=yield Ui({appId:i,client:e,user:o,primaryAccount:a,recoveryParams:n});try{let{user:l}=yield e.embeddedWallet.setRecovery(r);return{user:l}}catch(l){throw new re({code:"embedded_wallet_set_recovery_error",error:l instanceof Error?l.message:"Error setting password on embedded wallet"})}}),[e])}},Ui=a=>d(void 0,[a],function*({appId:e,client:t,user:n,primaryAccount:o,recoveryParams:i}){switch(i.recoveryMethod){case"privy":return{recoveryMethod:"privy",wallet:o};case"user-passcode":return D(W({},i),{wallet:o});case"google-drive":{let r=yield Fe(t);return{recoveryMethod:"google-drive",wallet:o,recoveryAccessToken:r}}case"icloud":{let{recoverySecret:r,iCloudRecordName:s}=yield ue({appId:e,client:t,user:n});return{recoveryMethod:"icloud-native",recoverySecretOverride:r,iCloudRecordNameOverride:s,wallet:o}}case"recovery-encryption-key":return{recoveryMethod:"recovery-encryption-key",wallet:o,recoveryKey:i.recoveryKey};default:throw new re({code:"embedded_wallet_recovery_error",error:"Unrecognized recovery method"})}});import{useCallback as Ri,useContext as Ii}from"react";import{getUserEmbeddedEthereumWallet as Mi,getUserEmbeddedSolanaWallet as Oi,PrivyClientError as we,isUnifiedWallet as Li}from"@privy-io/js-sdk-core";var Um=()=>{let{client:e}=Ii(g);return{recover:Ri(n=>d(void 0,null,function*(){var c;let o=S();if(!o)throw new we({code:"embedded_wallet_recovery_error",error:"User must be loaded before attempting to modify the recovery method."});let i=(c=Mi(o))!=null?c:Oi(o);if(!i)throw new we({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});if(Li(i))throw new we({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,r,s,l;switch(n.recoveryMethod){case"user-passcode":r=n.password;break;case"google-drive":s=yield Fe(e);break;case"icloud":let{recoverySecret:u}=yield Me({client:e,walletAddress:i.address,chainType:i.chain_type});l=u;break;case"recovery-encryption-key":a=n.recoveryKey;break;case"privy":break;default:throw new we({code:"unsupported_recovery_method",error:`Unsupported recovery options ${n}`})}try{i.chain_type==="ethereum"?yield e.embeddedWallet.getProvider(i,r,s,l,a):i.chain_type==="solana"&&(yield e.embeddedWallet.getSolanaProvider(i,i.address,"solana-address-verifier",r,s,l))}catch(u){throw new we({code:"attempted_to_set_password_before_connected",error:"Embedded wallet must be connected before setting password"})}}),[e])}};import{useEffect as Ti}from"react";import{useContext as Fi,useEffect as pt}from"react";var mt=(e={})=>{let{wallet:t,createWalletCallbacks:n,recoverWalletCallbacks:o,setWalletRecoveryCallbacks:i}=Fi(g),{onCreateWalletSuccess:a,onCreateWalletError:r,onRecoverWalletError:s,onRecoverWalletSuccess:l,onSetWalletRecoverySuccess:c,onSetWalletRecoveryError:u}=e;return pt(()=>{n.current={onSuccess:a,onError:r}},[a,r]),pt(()=>{o.current={onSuccess:l,onError:s}},[l,s]),pt(()=>{i.current={onSuccess:c,onError:u}},[l,s]),t};var Dm=({onStateChange:e})=>{let t=mt();return Ti(()=>{e(t)},[t])};import{useContext as Di}from"react";var jm=()=>{let{getIdentityToken:e}=Di(g);return{getIdentityToken:e}};import{useCallback as zr,useContext as Ni}from"react";import{PrivyClientError as Vi}from"@privy-io/js-sdk-core";var Qm=e=>{let{client:t}=Ni(g),n=zr(i=>{var r;let a=_(i);return(r=e==null?void 0:e.onError)==null||r.call(e,a),a},[e==null?void 0:e.onError]);return{create:zr(()=>d(void 0,null,function*(){var i;try{if(S())throw new Vi({code:"attempted_to_create_guest_account_for_logged_in_user",error:"Already logged in, you cannot create a guest account"});let r=U(),s=yield t.auth.guest.create({embedded:r==null?void 0:r.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 qi,useEffect as Kr,useRef as ji}from"react";var rf=({onMfaRequired:e,onMfaEnrollmentRequired:t,onMfaVerificationRequired:n})=>{let{client:o}=qi(g),i=ji(Symbol("mfa-listener")).current;Kr(()=>{let a=[],r=()=>a.forEach(s=>s());try{t&&a.push(Ft({fn:t,lock:i})),n&&a.push(Tt({fn:n,lock:i}))}catch(s){throw r(),s}return r},[i,t,n]),Kr(()=>{if(!e)return;let a=()=>d(void 0,null,function*(){var s;let r=S();yield e((s=r==null?void 0:r.mfa_methods.map(({type:l})=>l).filter(l=>l!=="email"))!=null?s:[])});return o.mfaPromises.on("mfaRequired",a),()=>{o.mfaPromises.off("mfaRequired",a)}},[o,e])};import{useCallback as ve,useContext as $i}from"react";import{PrivyClientError as je}from"@privy-io/js-sdk-core";import{PrivyClientError as Gi}from"@privy-io/js-sdk-core";function qe(){return d(this,null,function*(){Ie("react-native-passkeys");try{return yield import("react-native-passkeys")}catch(e){return Promise.reject(e)}})}var zi=(e,t)=>d(void 0,null,function*(){var i;let o=yield(yield qe()).create(Ki(e,t));if(!o)throw new Gi({code:"failed_to_create_passkey",error:"Could not create passkey"});return D(W({},o),{type:(i=o.type)!=null?i:"public-key",clientExtensionResults:{}})});function Ki(e,t){return D(W({},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 Bi}from"@privy-io/js-sdk-core";var yt=(e,t)=>d(void 0,null,function*(){var i;let o=yield(yield qe()).get(Hi(e,t));if(!o)throw new Bi({code:"no_passkey_found_for_challenge",error:"Could not find a matching passkey to login with"});return D(W({},o),{type:(i=o.type)!=null?i:"public-key",clientExtensionResults:{}})});function Hi(e,t){return D(W({},t),{rpId:e.rpId,challenge:e.challenge,allowCredentials:e.allowCredentials,userVerification:e.userVerification,timeout:12e4})}function Br(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 Hr(e){var t,n,o,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:(o=e.extensions)==null?void 0:o.hmac_create_secret},timeout:e.timeout,allowCredentials:(i=e.allow_credentials)==null?void 0:i.map(({id:a,type:r,transports:s})=>({id:a,type:r,transports:s})),userVerification:e.user_verification}}function Ef(e){var t,n,o,i,a,r,s,l;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:(o=(n=e.extensions)==null?void 0:n.cred_props)==null?void 0:o.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:(r=e.authenticator_selection)==null?void 0:r.resident_key,userVerification:(s=e.authenticator_selection)==null?void 0:s.user_verification,requireResidentKey:(l=e.authenticator_selection)==null?void 0:l.require_resident_key}}}function xf(){let{client:e}=$i(g),t=ve(r=>d(this,null,function*(){var s,l;switch(r.method){case"sms":yield e.mfa.sms.sendCode({action:"verify"});return;case"passkey":let{options:c}=yield e.mfa.passkey.generateAuthenticationOptions({relying_party:r.relyingParty||((l=(s=U())==null?void 0:s.mfa)==null?void 0:l.relyingParty)});return Hr(c);case"totp":return;default:throw new Error(`Unsupported MFA method: ${r.mfaMethod}`)}}),[e]),n=ve(r=>d(this,null,function*(){var s,l,c,u,p,m,h;switch(r.method){case"totp":case"sms":if(typeof r.mfaCode!="string")throw new je({code:"invalid_mfa_code",error:"Invalid MFA code"});(c=e.mfaPromises.rootPromise.current)==null||c.resolve({mfaMethod:r.method,mfaCode:r.mfaCode,relyingParty:r.relyingParty||((l=(s=U())==null?void 0:s.mfa)==null?void 0:l.relyingParty)||""}),yield new Promise((f,E)=>{e.mfaPromises.submitPromise.current={resolve:f,reject:E}});break;case"passkey":if(typeof r.mfaCode=="string")throw new je({code:"invalid_passkey_response",error:"Invalid authenticator response"});let b=yield yt(r.mfaCode),y=Br(b);(m=e.mfaPromises.rootPromise.current)==null||m.resolve({mfaMethod:r.method,relyingParty:r.relyingParty||((p=(u=U())==null?void 0:u.mfa)==null?void 0:p.relyingParty)||"",mfaCode:y}),yield new Promise((f,E)=>{e.mfaPromises.submitPromise.current={resolve:f,reject:E}});break;default:let w=new je({code:"unsupported_mfa_method",error:"Unsupported MFA method"});throw(h=e.mfaPromises.rootPromise.current)==null||h.reject(w),w}}),[e]),o=ve(()=>d(this,null,function*(){let r=S();!r||r.mfa_methods.length===0||(yield e.mfa.verifyMfa())}),[e]),i=ve(()=>{var r;(r=e.mfaPromises.rootPromise.current)==null||r.reject(new je({code:"mfa_canceled",error:"MFA canceled"}))},[e]),a=ve(()=>d(this,null,function*(){let r=S();r&&(yield e.mfa.clearMfa({userId:r.id}))}),[e]);return{init:t,submit:n,prompt:o,cancel:i,clear:a}}import{useCallback as gt,useContext as Qi}from"react";function Mf(){let{client:e}=Qi(g),t=gt(i=>d(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=gt(i=>d(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]),o=gt(i=>d(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:o}}import{useCallback as Yi,useContext as Xi}from"react";function Df(){let{client:e}=Xi(g);return{unlink:Yi(i=>d(this,[i],function*({credentialId:n,removeAsMfa:o}){yield e.mfa.unlinkPasskey({credentialId:n,removeAsMfa:o})}),[e])}}import{useCallback as Zi}from"react";import{areAddressesEqual as ea}from"@privy-io/are-addresses-equal";import{getAllUserEmbeddedEthereumWallets as ta,getAllUserEmbeddedSolanaWallets as ra,PrivyClientError as oa}from"@privy-io/js-sdk-core";var Kf=()=>{let e=x();return{importWallet:Zi(a=>d(void 0,[a],function*({privateKey:n,chainType:o,additionalSigners:i}){let{address:r,user:s}=yield e.embeddedWallet.importWallet({privateKey:n,chainType:o,additionalSigners:i}),c=(o==="solana"?ra(s.user):ta(s.user)).find(u=>ea(u.address,r));if(!c)throw new oa({code:"embedded_wallet_creation_error",error:"Failed to import wallet"});return{user:s.user,wallet:c}}),[e])}};import{useCallback as na,useMemo as Jr}from"react";import{getAllUserEmbeddedEthereumWallets as ht,getEntropyDetailsFromUser as $r,getUserEmbeddedSolanaWallet as ia,PrivyClientError as wt}from"@privy-io/js-sdk-core";var vt=()=>{let e=M(),t=x(),n=Jr(()=>{let a=ht(e).map(r=>{let s=$r(e,r);return s?{account:r,entropy:s}:null});return a.some(r=>r===null)?[]:a.filter(r=>r!==null).map(({account:r,entropy:{entropyId:s,entropyIdVerifier:l}})=>({address:r.address,walletIndex:r.wallet_index,chainType:r.chain_type,getProvider:()=>t.embeddedWallet.getEthereumProvider({wallet:r,entropyId:s,entropyIdVerifier:l,onMfaEnrollmentRequired:c=>d(void 0,null,function*(){return yield R()(c)}),onMfaVerificationRequired:c=>d(void 0,null,function*(){return yield I()(c)}),onNeedsRecovery:c=>d(void 0,null,function*(){var u;yield(u=ke())==null?void 0:u(c)})})}))},[t,e]),o=na((...a)=>d(void 0,[...a],function*({createAdditional:i=!1}={}){var p,m,h;let{user:r}=yield t.user.get(),s=ht(r);if(!i&&s.length>0)throw new wt({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 b=(p=ia(r))!=null?p:void 0,{user:y}=yield t.embeddedWallet.createEthereumWallet(b?{solanaAccount:b}:{});return aa(y.user),{user:y.user}}let l=$r(r),c=s.map(b=>b.wallet_index).reduce((b,y)=>Math.max(b,y),0)+1,u=yield t.embeddedWallet.add({chainType:"ethereum",hdWalletIndex:c,entropyId:(m=l==null?void 0:l.entropyId)!=null?m:"",entropyIdVerifier:(h=l==null?void 0:l.entropyIdVerifier)!=null?h:"ethereum-address-verifier"});if(!u.account||u.account.chain_type!=="ethereum")throw new wt({code:"embedded_wallet_creation_error",error:"Unknown error creating wallet"});return{user:u.user}}),[t]);return Jr(()=>({wallets:n,create:o}),[n,o])};function aa(e){if(!e||ht(e).length===0)throw new wt({code:"embedded_wallet_creation_error",error:"Unknown error creating wallet"})}import{useContext as sa,useEffect as Qr}from"react";var ca=(e={})=>{let{solanaWallet:t,createSolanaWalletCallbacks:n,recoverSolanaWalletCallbacks:o}=sa(g),{onCreateWalletSuccess:i,onCreateWalletError:a,onRecoverWalletError:r,onRecoverWalletSuccess:s}=e;return Qr(()=>{n.current={onSuccess:i,onError:a}},[i,a]),Qr(()=>{o.current={onSuccess:s,onError:r}},[s,r]),t};import{useCallback as da,useMemo as la}from"react";import{getAllUserEmbeddedBitcoinWallets as Yr,getEntropyDetailsFromUser as Xr,isUnifiedWallet as ua,PrivyClientError as oe}from"@privy-io/js-sdk-core";var pa=()=>{let e=M(),t=x(),n=la(()=>{let i=Xr(e);if(!i)return[];let a=Yr(e),{entropyId:r,entropyIdVerifier:s}=i;return a.map(l=>({address:l.address,walletIndex:l.wallet_index,publicKey:l.public_key,chainType:l.chain_type,getProvider:()=>ua(l)?Promise.reject(new oe({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:l,entropyId:r,entropyIdVerifier:s})}))},[t,e]),o=da(r=>d(void 0,[r],function*({chainType:i,createAdditional:a=!1}){var w;let s=t.app.getConfig();if(((w=s==null?void 0:s.embedded_wallet_config)==null?void 0:w.mode)==="user-controlled-server-wallets-only")throw i==="bitcoin-segwit"?new oe({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 oe({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:l}=yield t.user.get(),c=Xr(l);if(!c)throw new oe({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=Yr(l).filter(f=>f.chain_type===i);if(!a&&m.length>0)throw new oe({code:"embedded_wallet_creation_error",error:"Wallet already exists for this user. Set `createAdditional` to `true` to create another wallet"});let h=m.length===0?0:Math.max(...m.map(f=>f.wallet_index),0)+1,b=yield t.embeddedWallet.add({chainType:i,hdWalletIndex:h,entropyId:u,entropyIdVerifier:p}),y=b.account;if(!b.user||!y||y.chain_type!=="bitcoin-segwit"&&y.chain_type!=="bitcoin-taproot"||y.chain_type!==i)throw new oe({code:"embedded_wallet_creation_error",error:"Unknown error creating wallet"});return{user:b.user,provider:yield t.embeddedWallet.getBitcoinProvider({wallet:D(W({},y),{chain_type:y.chain_type}),entropyId:u,entropyIdVerifier:p})}}),[t]);return{wallets:n,create:o}};import{useContext as ma}from"react";var bt=()=>{let{isReady:e,logout:t,getAccessToken:n,error:o,client:i}=ma(g);return{user:M(),isReady:e,error:o,logout:t,getAccessToken:n,refreshUser:()=>i.user.refreshUser()}};import{useContext as fa}from"react";function ya(){let{client:e}=fa(g);return{acceptTerms:()=>d(this,null,function*(){return e.user.acceptTerms()})}}import{useMemo as ga}from"react";import{generateAuthorizationSignature as ha}from"@privy-io/js-sdk-core";var wa=()=>{let e=x();return ga(()=>({generateAuthorizationSignature(n){return d(this,null,function*(){let{signature:o}=yield ha((...i)=>e.embeddedWallet.signWithUserSigner(...i),n);return{signature:o}})}}),[e])};import{useContext as va,useMemo as ba}from"react";import{GetEncryptedAuthorizationKey as Sa}from"@privy-io/routes";var Wy=()=>{let{client:e}=va(g);return ba(()=>({getEncryptedAuthorizationKey:({id:t})=>e.fetchPrivyRoute(Sa,{params:{encrypted_authorization_key_id:t}})}),[e])};import{useCallback as Ea}from"react";import{createWalletClient as Ca,getAddress as Zr,http as _a,parseSignature as ka,zeroAddress as Wa}from"viem";import{hashAuthorization as Aa}from"viem/utils";import{getAllUserEmbeddedEthereumWallets as xa,getJsonRpcEndpointFromChain as Pa}from"@privy-io/js-sdk-core";var Ua=()=>{let e=M(),{wallets:t}=vt(),n=x();return{signAuthorization:Ea((i,a)=>d(void 0,null,function*(){var p,m,h;if(!e)throw new Error("User must be authenticated before signing with a Privy wallet");let r=(h=(m=a==null?void 0:a.address)!=null?m:(p=xa(e)[0])==null?void 0:p.address)!=null?h:Wa,s=t.find(b=>Zr(b.address)===Zr(r));if(!s)throw new Error("Signing wallet not found.");let l;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");l={chainId:0,address:i.contractAddress,nonce:i.nonce}}else{let y=n.embeddedWallet.chains.find(E=>E.id===i.chainId);if(!y)throw new Error("Error, chain not configured in PrivyProvider config");let w=Pa(y,{},n.app.appId);l=yield Ca({account:r,chain:y,transport:_a(w)}).prepareAuthorization(W({},i))}let u=yield(yield s.getProvider()).request({method:"secp256k1_sign",params:[Aa(l)]});return W(W({},l),ka(u))}),[t,e,n])}};import{useMemo as Ra}from"react";import{transfer as Ia}from"@privy-io/js-sdk-core";var Ma=()=>{let e=x();return Ra(()=>({transfer:(t,n)=>N(()=>Ia(e,(...o)=>e.embeddedWallet.signWithUserSigner(...o),W({wallet_id:t},n)))}),[e])};import{useMemo as Oa}from"react";import{swap as La}from"@privy-io/js-sdk-core";var Fa=()=>{let e=x();return Oa(()=>({swap:(t,n)=>N(()=>La(e,(...o)=>e.embeddedWallet.signWithUserSigner(...o),W({wallet_id:t},n)))}),[e])};import{useMemo as Ta}from"react";import{earnDeposit as Da,earnWithdraw as Na}from"@privy-io/js-sdk-core";var Va=()=>{let e=x();return Ta(()=>({deposit:(t,n)=>N(()=>Da(e,(...o)=>e.embeddedWallet.signWithUserSigner(...o),W({wallet_id:t},n))),withdraw:(t,n)=>N(()=>Na(e,(...o)=>e.embeddedWallet.signWithUserSigner(...o),W({wallet_id:t},n)))}),[e])};import{useMemo as qa}from"react";import{PrivyClientError as ja,updateWallet as Ga}from"@privy-io/js-sdk-core";var za=()=>{let e=x();return qa(()=>({updateWallet:(t,n)=>d(void 0,null,function*(){yield N(()=>Ga(e,{wallet_id:t},(...a)=>e.embeddedWallet.signWithUserSigner(...a),n));let{user:o}=yield e.user.refreshUser(),i=o==null?void 0:o.linked_accounts.find(a=>a.type==="wallet"&&"id"in a&&a.id===t);if(!i)throw new ja({code:"embedded_wallet_does_not_exist",error:"Updated wallet was not found in the refreshed user."});return{wallet:i}})}),[e])};import{useMemo as Ka}from"react";import{getWalletAction as Ba,listWalletActions as Ha}from"@privy-io/js-sdk-core";var Ja=()=>{let e=x();return Ka(()=>({getAction:(t,n)=>Ba(e,{wallet_id:t,action_id:n}),listActions:(t,n)=>Ha(e,W({wallet_id:t},n))}),[e])};import{useMemo as $a}from"react";var Qa=()=>{let e=Vt();return $a(()=>({users:e}),[e])};import{useMemo as Ya}from"react";var Xa=()=>{let e=x();return Ya(()=>({switchUser:n=>d(void 0,[n],function*({userId:t}){return yield e.user.switchActiveUser({userId:t})})}),[e])};import{useCallback as os}from"react";import{PrivyClientError as ns}from"@privy-io/js-sdk-core";import{getAllUserEmbeddedBitcoinWallets as Za,getUserEmbeddedEthereumWallet as es,getUserEmbeddedSolanaWallet as ts,isEmbeddedWalletAccount as rs,isUnifiedWallet as eo}from"@privy-io/js-sdk-core";function to(e,t){return d(this,null,function*(){var i,a;let n=t.linked_accounts.filter(rs).filter(r=>!r.imported&&!eo(r)).filter(r=>r.chain_type==="ethereum"||r.chain_type==="solana"),o=(i=n.find(r=>r.chain_type==="ethereum"&&r.wallet_index===0))!=null?i:n.find(r=>r.chain_type==="solana"&&r.wallet_index===0);if(!o){let r=(a=es(t))!=null?a:ts(t);if(r!=null&&r.imported&&!eo(r))throw new Error("Imported wallets cannot be migrated");return{success:!0,migrated:!1}}if(Za(t).length>0)throw new Error("Bitcoin wallets cannot be migrated");return o.chain_type==="ethereum"?yield e.embeddedWallet.getProvider(o):o.chain_type==="solana"&&(yield e.embeddedWallet.getSolanaProvider(o,o.address,"solana-address-verifier")),yield e.embeddedWallet.delegateWallets({rootWallet:{address:o.address,chainType:o.chain_type,imported:o.imported},delegatedWallets:n.map(r=>({address:r.address,chainType:r.chain_type,walletIndex:r.wallet_index}))}),yield e.user.get(),{success:!0,migrated:!0}})}var ro=()=>{let e=x();return{migrate:os(()=>d(void 0,null,function*(){var a;let n=S(),o=e.app.getConfig();if(((a=o==null?void 0:o.embedded_wallet_config)==null?void 0:a.mode)!=="user-controlled-server-wallets-only")return{success:!0};if(!n)throw new ns({code:"embedded_wallet_before_logged_in",error:"User must be authenticated before migrating wallets"});return to(e,n)}),[e])}};var oo=({disabled:e})=>{let{migrate:t}=ro(),{user:n}=bt(),o=as(!1);return is(()=>{e||n&&(o.current||(o.current=!0,t().then(i=>{i.migrated&&!o.current&&(console.info("Migrated wallets for user"),o.current=!0)}).catch(i=>{console.debug("Unable to migrate wallets: ",i)}).finally(()=>{o.current=!1})))},[t,n,e]),null};var g=cs(null),ie;function Jh(e){return ie?ie.getAccessToken():e!=null&&e.strict?Promise.reject(new ao({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 $h=e=>{var _t,kt,Wt;us();let[t,n]=V(io.currentState==="active");no(()=>{let T=io.addEventListener("change",fo=>{n(fo==="active")});return()=>{T.remove()}},[]),no(()=>Mt(e.config),[e.config]);let[o,i]=V(!1),[a,r]=V(null),[s,l]=V(!1),[c,u]=V({status:"disconnected",account:null}),[p,m]=V({status:"disconnected"}),[h,b]=V({status:"initial"}),[y,w]=V({status:"initial"}),[f,E]=V({status:"initial"}),[v,k]=V({status:"initial"}),[C,A]=V({status:"initial"}),[P,q]=V({status:"initial"}),[B,Se]=V({status:"initial"}),ae=be({}),se=be({}),ze=be({}),Et=be({}),Ct=be({}),Ee=Ge(T=>{if(T){Be(T),r(null);return}Be(null),b({status:"initial"}),w({status:"initial"}),u({status:"disconnected",account:null})},[]),F=ss(()=>{let T=e.storage||_e;return e.client?ie=e.client:ie=It({appId:e.appId,clientId:e.clientId,supportedChains:e.supportedChains,storage:T,baseUrl:e.baseUrl,logLevel:e.logLevel}),ie.setCallbacks({setUser:Ee,setIsReady:l,setStoredUsers:Dt}),ie},[e.client,e.storage,e.appId,e.clientId,e.baseUrl,e.supportedChains,e.logLevel,Ee]),so=Ge(()=>d(void 0,null,function*(){let T=S();yield F.auth.logout(T?{userId:T==null?void 0:T.id}:void 0),Ee(null)}),[Ee,F]),co=Ge(()=>d(void 0,null,function*(){try{return yield F.getAccessToken()}catch(T){return console.debug(T),null}}),[F]),lo=Ge(()=>F.getIdentityToken(),[F]);Zt({client:F,setIsUserInitialized:i,setError:r});let uo=mr({client:F,appId:e.appId,createWalletCallbacks:ae,recoverWalletCallbacks:se,setWalletRecoveryCallbacks:ze,setRecoveryFlowState:E,wallet:c,setWallet:u}),po=ir({client:F,createSolanaWalletCallbacks:Et,recoverSolanaWalletCallbacks:Ct,setSolanaRecoveryFlowState:k,solanaWallet:p,setSolanaWallet:m});gr({client:F,createWalletCallbacks:ae,recoverWalletCallbacks:se,setWalletRecoveryCallbacks:ze,recoveryFlowState:f,oAuthState:y,setRecoveryFlowState:E,setWallet:u,appStateVisible:t});let{customAuthStateIsSettled:mo}=yr({client:F,isReady:o});return ne.createElement(ne.Fragment,null,ne.createElement(g.Provider,{value:{client:F,isReady:o&&mo,error:a,logout:so,getAccessToken:co,getIdentityToken:lo,wallet:W(W({},c),uo),solanaWallet:W(W({},p),po),oAuthState:y,recoveryFlowState:f,setRecoveryFlowState:E,solanaRecoveryFlowState:v,setSolanaRecoveryFlowState:k,createWalletCallbacks:ae,recoverWalletCallbacks:se,setWalletRecoveryCallbacks:ze,createSolanaWalletCallbacks:Et,recoverSolanaWalletCallbacks:Ct,setOAuthState:w,siweState:C,setSiweState:A,otpState:h,setOtpState:b,passkeyState:P,setPasskeyState:q,farcasterState:B,setFarcasterState:Se}},e.children,ne.createElement(oo,{disabled:(Wt=(kt=(_t=e.config)==null?void 0:_t.embedded)==null?void 0:kt.disableAutomaticMigration)!=null?Wt:!1})),ne.createElement(ls,{style:{width:0,height:0,overflow:"hidden"}},ne.createElement(Kt,{client:F,isClientReady:s})))},us=()=>{if(ds(g))throw new ao({code:"configuration_error",error:"Found multiple instances of PrivyProvider, ensure there is only one mounted in your application tree."})};var ow=e=>{let{client:t,setSiweState:n,siweState:o}=ps(g),i=St(s=>{var c;let l=_(s);return n({status:"error",error:l}),(c=e==null?void 0:e.onError)==null||c.call(e,l),l},[e==null?void 0:e.onError]),a=St(u=>d(void 0,[u],function*({wallet:s,from:{domain:l,uri:c}}){var p;try{n({status:"generating-message"});let m=yield t.auth.siwe.init(s,l,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]),r=St(c=>d(void 0,[c],function*({signature:s,messageOverride:l}){var u;try{if(!S())throw new ms({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,l);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:r,state:o}};export{U as a,R as b,I as c,S as d,Ms as e,M as f,Os as g,_ as h,ho as i,Ie as j,Z as k,It as l,ow as m,Td as n,x as o,Jd as p,ol as q,ul as r,vl as s,kl as t,Ol as u,jl as v,Yl as w,iu as x,uu as y,bu as z,Uu as A,Fu as B,qu as C,N as D,Xu as E,Pr as F,pp as G,wp as H,kp as I,Tp as J,Kp as K,Zp as L,am as M,mm as N,Sm as O,Um as P,mt as Q,Dm as R,jm as S,Qm as T,rf as U,zi as V,yt as W,Ef as X,xf as Y,Mf as Z,Df as _,Kf as $,vt as aa,ca as ba,pa as ca,bt as da,ya as ea,wa as fa,Wy as ga,Ua as ha,Ma as ia,Fa as ja,Va as ka,za as la,Ja as ma,Qa as na,Xa as oa,ro as pa,g as qa,Jh as ra,$h as sa};
@@ -1 +1 @@
1
- import{d as u,o as i}from"./chunk-APBCP6B2.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};
1
+ import{D as c,d as u,o as i}from"./chunk-MZRVLBIF.js";import"./chunk-F7DR7TVR.js";import"./chunk-3HF374LL.js";import{e as a}from"./chunk-C5WYSLQF.js";import{useMemo as g}from"react";import{create as f}from"@privy-io/js-sdk-core";var h=()=>{let e=i();return g(()=>({createWallet(n){return a(this,null,function*(){let s=yield f(e,{request:{chain_type:n.chainType}}),{user:o}=yield e.user.get();return{user:o,wallet:s}})}}),[e])};import{useMemo as m}from"react";import{isEmbeddedWalletAccount as w,isUnifiedWallet as y,PrivyClientError as d,rawSign as C}from"@privy-io/js-sdk-core";var W=()=>{let e=i();return m(()=>({signRawHash(q){return a(this,arguments,function*({address:n,chainType:s,hash:o}){let l=u();if(!l)throw new d({code:"embedded_wallet_before_logged_in",error:"User must be authenticated before signing a raw hash"});let p=l.linked_accounts.filter(w).filter(y).filter(t=>t.chain_type===s).find(t=>t.address===n);if(!p)throw new d({code:"embedded_wallet_does_not_exist",error:"No embedded wallet found for the given address and chain type"});let r=yield c(()=>C(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{h as useCreateWallet,W as useSignRawHash};
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- import{a as jt,b as Et,c as _t,d as Bt,e as Mt,f as qt,g as zt,h as Jt}from"./chunk-QSWCX5XI.js";import{a as f,b as I}from"./chunk-2INMFYSV.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 Nt,n as E,na as bt,o as _,oa as w,p as B,pa as a,q as M,qa as Dt,r as q,ra as Gt,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-APBCP6B2.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 Xt=({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{Xt as AuthBoundary,a as PrivyContext,Gt as PrivyProvider,P as SecureStorageAdapter,v as createPrivyClient,T as dataSuffix,Dt as getAccessToken,zt as hasError,jt as isConnected,_t as isConnecting,qt as isCreating,Bt as isDisconnected,Mt as isNotCreated,Et as isReconnecting,Jt as needsRecovery,Tt as useAcceptTerms,gt as useAuthorizationSignature,lt as useCreateGuestAccount,et as useDepositAddress,Rt as useEarn,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,Nt as useStoredUsers,Wt as useSwap,bt 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,Ht as useUpdateWallet,Ct as useWalletActions};
1
+ import{a as jt,b as Et,c as _t,d as Bt,e as Mt,f as qt,g as zt,h as Jt}from"./chunk-QSWCX5XI.js";import{a as f,b as I}from"./chunk-G3UY4P75.js";import{$ as Pt,A as $,B as tt,C as et,E as ot,F as rt,G as nt,H as ut,I as it,J as pt,K as st,L as ht,M as at,N as ft,O as At,P as Ot,Q as ct,R as mt,S as kt,T as lt,U as yt,Y as xt,Z as dt,_ as Ut,aa as vt,ba as wt,ca as It,da as d,ea as Tt,fa as gt,g as y,ga as Ft,h as x,ha as St,i as G,ia as Lt,ja as Wt,ka as Rt,l as v,la as Ht,m as j,ma as Ct,n as E,na as Nt,o as _,oa as bt,p as B,pa as w,q as M,qa as a,r as q,ra as Dt,s as z,sa as Gt,t as J,u as K,v as Q,w as V,x as X,y as Y,z as Z}from"./chunk-MZRVLBIF.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 Xt=({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{Xt as AuthBoundary,a as PrivyContext,Gt as PrivyProvider,P as SecureStorageAdapter,v as createPrivyClient,T as dataSuffix,Dt as getAccessToken,zt as hasError,jt as isConnected,_t as isConnecting,qt as isCreating,Bt as isDisconnected,Mt as isNotCreated,Et as isReconnecting,Jt as needsRecovery,Tt as useAcceptTerms,gt as useAuthorizationSignature,lt as useCreateGuestAccount,et as useDepositAddress,Rt as useEarn,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,nt as useSessionSigners,At as useSetEmbeddedWalletRecovery,St as useSign7702Authorization,ht as useSignMessageWithCrossApp,at as useSignTypedDataWithCrossApp,rt as useSigners,Nt as useStoredUsers,Wt as useSwap,bt 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,Ht as useUpdateWallet,Ct as useWalletActions};
@@ -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{U as _,V as x,W as b,a as w,d as g,h,pa as P}from"./chunk-APBCP6B2.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
+ 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{V as _,W as x,X as b,a as w,d as g,h,qa as P}from"./chunk-MZRVLBIF.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 L}from"./chunk-QSWCX5XI.js";import{b as k,c as N,d as g,f as v,k as P,o as U,pa as S}from"./chunk-APBCP6B2.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};
1
+ import{b as O,c as R,d as W,f as E,k as I,o as D,qa as v}from"./chunk-MZRVLBIF.js";import"./chunk-F7DR7TVR.js";import"./chunk-3HF374LL.js";import{a as x,b as L,c as N,e as y}from"./chunk-C5WYSLQF.js";import S,{createContext as b,useCallback as it,useContext as h,useEffect as M,useState as V}from"react";import{areAddressesEqual as $}from"@privy-io/are-addresses-equal";import{getAllUserEmbeddedEthereumWallets as G,getDataSuffixPlugin as Y,getUserSmartWallet as A,PrivyClientError as w}from"@privy-io/js-sdk-core";import{createPublicClient as J,http as K}from"viem";import{getJsonRpcEndpointFromChain as z,getUserSmartWallet as Q,PrivyClientError as F}from"@privy-io/js-sdk-core";import{signerToSmartAccountClient as Z}from"@privy-io/js-sdk-core/smart-wallets";var T=m=>y(void 0,[m],function*({chain:t,privyAppId:e,user:n,embeddedWallet:r,smartWalletsConfig:a,client:i,dataSuffix:d}){if(!(a!=null&&a.enabled)||(r==null?void 0:r.status)!=="connected"||!r.account)return;let l=yield i.embeddedWallet.getEthereumProvider({wallet:r.account,entropyId:r.account.address,entropyIdVerifier:"ethereum-address-verifier",onMfaEnrollmentRequired:p=>y(void 0,null,function*(){return yield O()(p)}),onMfaVerificationRequired:p=>y(void 0,null,function*(){return yield R()(p)})}),s=a==null?void 0:a.configured_networks.find(p=>p.chain_id===`eip155:${t.id}`);if(!s)throw new F({code:"chain_not_supported",error:`The chain ${t.name} (eip155:${t.id}) must be configured in the smart wallet configuration in your dashboard`});let f=Q(n),g=f?f.smart_wallet_type:a.smart_wallet_type,u=f?f.smart_wallet_version:a.smart_wallet_version,C=z(t,{rpcUrls:[]},e),_=J({chain:t,transport:K(C)}),o=yield Z({owner:l,smartWalletType:g,smartWalletVersion:u,chain:t,publicClient:_,paymasterContext:at(s.paymaster_url,s.paymaster_context),bundlerUrl:s.bundler_url,paymasterUrl:s.paymaster_url});if(!o)throw new F({code:"smart_wallet_client_error",error:`Failed to create smart wallet client for chain ${t.name} (eip155:${t.id})`});return tt(o,d)});function tt(t,e){return e?t.extend(n=>({sendTransaction:r=>n.sendTransaction(N(L({},r),{dataSuffix:e}))})):t}var et=/paymaster\.biconomy\.io\/api/i;function rt(t){return et.test(t)}var nt={mode:"SPONSORED",calculateGasLimits:!0,expiryDuration:300,sponsorshipInfo:{webhookData:{},smartAccountInfo:{name:"BICONOMY",version:"2.0.0"}}},at=(t,e)=>{if(t&&rt(t))return nt;if(e&&e.policy_id)return{policyId:e.policy_id}};var B=3,ot=500,lt=({children:t})=>S.createElement(dt,null,S.createElement(ut,null,S.createElement(mt,null,t))),q=b({config:void 0}),U=()=>{let{config:t}=h(q);return{config:t}},H=b({smartWalletClient:void 0}),st=()=>{let{smartWalletClient:t,userId:e}=h(H);return{smartWalletClient:t,userId:e}},X=b({client:void 0}),ct=()=>{let{client:t}=h(X),e=ft();return{client:t,getClientForChain:e}},dt=({children:t})=>{let[e,n]=V(void 0),r=D();return M(()=>{!e&&r&&(()=>y(void 0,null,function*(){try{if(!r){console.warn("No client found");return}let i=yield r.app.getSmartWalletConfig();n(i)}catch(i){console.warn("Error generating smart wallet config: ",i)}}))()},[r,e]),S.createElement(q.Provider,{value:{config:e}},t)},ut=({children:t})=>{let{config:e}=U(),{client:n,wallet:r}=h(v),a=E(),i=a==null?void 0:a.id,[d,m]=V(),c=r.status==="connected"?r.account.address.toLowerCase():void 0,l=!!c&&G(a).some(f=>$(f.address,c)),s=e!=null&&e.enabled&&l&&(d==null?void 0:d.userId)===i&&(d==null?void 0:d.signerAddress)===c?d:void 0;return M(()=>{let f=!1;return(()=>y(void 0,null,function*(){var k;m(void 0);let u=W();if(!(e!=null&&e.enabled)||!u||u.id!==i||!c||!l)return;let C=G(u).find(P=>$(P.address,c));if(!C)return;let o=n.embeddedWallet.chains.find(P=>e.configured_networks.map(j=>j.chain_id).includes(`eip155:${P.id}`));if(!o)throw new w({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 p=yield T({chain:o,privyAppId:n.app.appId,user:u,embeddedWallet:{status:r.status,account:C},smartWalletsConfig:e,client:n,dataSuffix:(k=Y(n.plugins))==null?void 0:k.suffix});if(!f){if(!p)throw new w({error:"Could not create smart wallet client",code:"smart_wallet_client_error"});m({smartWalletClient:p,userId:i,signerAddress:c})}}))().catch(u=>{f||n.logger.error("Error creating smart wallet client:",u==null?void 0:u.message)}),()=>{f=!0}},[e,n,i,r.status,c,l]),S.createElement(H.Provider,{value:s!=null?s:{}},t)},mt=({children:t})=>{let{client:e,wallet:n}=h(v),r=E(),a=r==null?void 0:r.id,i=!!A(r),d=n.status,{smartWalletClient:m,userId:c}=st(),{config:l}=U();return M(()=>{let s=!1;return(()=>y(void 0,null,function*(){var u;if(a!==c)return;let g=W();if(!(!m||!g||g.id!==a||i||!(l!=null&&l.enabled)||d!=="connected"))for(let C=0;C<B;C++){if(s||A((u=W())!=null?u:g))return;let _=!1;for(let o=0;o<5;o++){if(s)return;if(yield e.embeddedWallet.ping(ot)){_=!0;break}yield I(200*x(2,o))}if(_)try{let{message:o}=yield e.auth.smartWallet.init({address:m.account.address,chainId:`eip155:${m.chain.id}`}),p=yield m.signMessage({message:o});yield e.auth.smartWallet.link(o,p,l.smart_wallet_type,l.smart_wallet_version);return}catch(o){C===B-1?e.logger.error("Error creating smart wallet:",o==null?void 0:o.message):yield I(500*x(2,C))}}}))(),()=>{s=!0}},[m,a,c,i,l,d,e]),S.createElement(X.Provider,{value:{client:A(r)?m:void 0}},t)},ft=()=>{let{client:t,wallet:e}=h(v),{config:n}=U();return it(a=>y(void 0,[a],function*({chainId:r}){var l;let i=W();if(!i)throw new w({error:"Must be logged in to get a smart wallet client",code:"smart_wallet_client_error"});if(!n||!n.enabled)throw new w({error:"Must have smart wallets enabled to get a smart wallet client",code:"smart_wallet_client_error"});let m=t.embeddedWallet.chains.find(s=>s.id===r);if(!m)throw new w({error:`Could not find chain with id: ${r}`,code:"chain_not_supported"});let c=yield T({chain:m,privyAppId:t.app.appId,user:i,embeddedWallet:e,smartWalletsConfig:n,client:t,dataSuffix:(l=Y(t.plugins))==null?void 0:l.suffix});if(!c)throw new w({error:`Could not create smart wallet client for chain ${r}`,code:"smart_wallet_client_error"});return c}),[n,e,t])};export{lt as SmartWalletsProvider,ct as useSmartWallets};