@privy-io/expo 0.78.2 → 0.79.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cards.js +11 -11
- package/dist/{chunk-DBIA42HB.js → chunk-CAF26OMV.js} +1 -1
- package/dist/chunk-SNODJ7VS.js +12 -0
- package/dist/{chunk-QAUM76HK.js → chunk-VZ7MMAEX.js} +1 -1
- package/dist/esm/cards.js +11 -11
- package/dist/esm/{chunk-DBIA42HB.js → chunk-CAF26OMV.js} +1 -1
- package/dist/esm/chunk-SNODJ7VS.js +12 -0
- package/dist/esm/{chunk-QAUM76HK.js → chunk-VZ7MMAEX.js} +1 -1
- package/dist/esm/extended-chains.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/passkey.js +1 -1
- package/dist/esm/smart-wallets.js +1 -1
- package/dist/esm/ui.js +1 -1
- package/dist/extended-chains.js +1 -1
- package/dist/index.d.ts +48 -3
- package/dist/index.js +1 -1
- package/dist/passkey.js +1 -1
- package/dist/smart-wallets.js +1 -1
- package/dist/ui.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-V3WU67WL.js +0 -12
- package/dist/esm/chunk-V3WU67WL.js +0 -12
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{na as Ce}from"./chunk-V3WU67WL.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-SNODJ7VS.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 Et,b as Ct,c as Ee}from"./chunk-F7DR7TVR.js";import{a as _t}from"./chunk-3HF374LL.js";import{a as be,b as _,c as T,e as l}from"./chunk-C5WYSLQF.js";import{useEffect as co}from"react";import{create as lo}from"zustand";var kt=lo(()=>({status:"disconnected"})),Ce=()=>kt.getState().onNeedsRecovery,uo=e=>{co(()=>{kt.setState({onNeedsRecovery:e==null?void 0:e.onNeedsRecovery})},[e==null?void 0:e.onNeedsRecovery])};import mo from"@privy-io/js-sdk-core";var Wt={name:"@privy-io/expo",version:"0.79.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 At=({appId:e,clientId:t,storage:n=Ee,supportedChains:r,baseUrl:i,logLevel:a,logger:o,sessions:s,plugins:d})=>{_t();let c=s!=null&&s.mode?{mode:s.mode}:void 0;return new mo({appId:e,clientId:t,plugins:d,supportedChains:r,storage:Ct(n),sdkVersion:`expo:${Wt.version}`,nativeAppIdentifier:Et(),baseUrl:i,logLevel:a,logger:o,sessions:c})};import{useCallback as gt,useContext as ss}from"react";import{PrivyClientError as cs}from"@privy-io/js-sdk-core";import re,{useState as N,useMemo as rs,createContext as os,useCallback as Ne,useRef as he,useEffect as Yr,useContext as ns}from"react";import{AppState as Xr,View as is}from"react-native";import{PrivyClientError as Zr}from"@privy-io/js-sdk-core";import fo from"react-fast-compare";import{create as yo}from"zustand";var _e=yo(()=>{}),xt=e=>_e.setState(t=>fo(t,e)?t:e),x=_e.getState;import vo from"react";import{useCallback as B,useEffect as Tt,useRef as ae,useState as So}from"react";import{AppState as bo}from"react-native";import Eo from"react-native-webview";import*as q from"expo-secure-store";function Pt(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 Ut(e){return l(this,null,function*(){switch(e.event){case"app:secure-storage:get":{let{key:t}=e.data,n=yield q.getItemAsync(ze(t),{keychainAccessible:q.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY}).catch(r=>(console.warn("Failed to get the value from secure store",r),null));return{event:e.event,id:e.id,data:{value:n}}}case"app:secure-storage:remove":{let{key:t}=e.data,n=yield q.deleteItemAsync(ze(t),{keychainAccessible:q.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY}).then(()=>!0).catch(r=>(console.warn("Failed to remove the value from secure store",r),!1));return{event:e.event,id:e.id,data:{success:n}}}case"app:secure-storage:set":{let{key:t,value:n}=e.data,r=yield q.setItemAsync(ze(t),n,{keychainAccessible:q.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY}).then(()=>!0).catch(i=>(console.warn("Failed to write the value to secure store",i),!1));return{event:e.event,id:e.id,data:{success:r}}}}})}var ze=e=>e.replaceAll(":","-");import go from"react-fast-compare";import{createStore as ho,useStore as ke}from"zustand";import{PrivyClientError as wo}from"@privy-io/js-sdk-core";var M=ho()(()=>({user:null,storedUsers:[],proxyStatus:"loading"})),Rt=e=>Lt("onMfaEnrollmentRequired",e),It=e=>Lt("onMfaVerificationRequired",e),U=()=>{var e,t;return(t=(e=M.getState().onMfaEnrollmentRequired)==null?void 0:e.fn)!=null?t:Ft},R=()=>{var e,t;return(t=(e=M.getState().onMfaVerificationRequired)==null?void 0:e.fn)!=null?t:Ft};function b(){return M.getState().user}var Ws=M.subscribe.bind(M);function Ge(e){M.setState(({user:t})=>go(t,e)?{}:{user:e})}var Mt=e=>M.setState({storedUsers:e.users}),ie=e=>M.setState({proxyStatus:e});function I(){return ke(M,e=>e.user)}function As(){return ke(M,e=>!!e.user)}function Ot(){return ke(M,e=>e.storedUsers)}function G(){return ke(M,e=>e.proxyStatus!=="loading")}var Lt=(e,t)=>(M.setState(n=>{let r=n[e];if(r&&r.lock!==t.lock)throw new wo({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}}),()=>{M.setState(n=>n[e]===t?{[e]:void 0}:{})}),Ft=e=>l(void 0,null,function*(){throw e.error});var Co={shouldUseAppBackedStorage:!0},_o=";",ko=500,Wo=(e,t)=>{if(!e)return!1;try{return new URL(e).origin===new URL(t).origin}catch(n){return!1}},Ao=1e3,xo=6e4,Dt=({client:e,isClientReady:t})=>{let n=ae(null),[r,i]=So(0),a=ae(0),o=ae(void 0),s=ae(0),d=ae(void 0);Tt(()=>()=>clearTimeout(d.current),[]);let c=B(f=>{e.logger.info(`[privy:webview] recreating, ${f}`),clearTimeout(d.current),a.current+=1,ie("reloading"),e.embeddedWallet.reload(),i(y=>y+1)},[e]);Tt(()=>{let f=bo.addEventListener("change",y=>l(void 0,null,function*(){var S;if(y==="background")o.current=a.current,e.embeddedWallet.onBackground();else if(y==="active"){let E=(S=o.current)!=null?S:a.current;o.current=void 0,!(yield e.embeddedWallet.ping(ko))&&a.current===E&&(ie("reloading"),e.embeddedWallet.reload())}}));return()=>f.remove()},[e]);let u=B(f=>l(void 0,null,function*(){var E;if(!Wo(f.nativeEvent.url,e.embeddedWallet.getURL()))return;let{data:y}=f.nativeEvent,S=JSON.parse(y);if(s.current=0,Pt(S)){let A=yield Ut(S);(E=n.current)==null||E.postMessage(JSON.stringify(A));return}e.embeddedWallet.onMessage(S)}),[e]),p=B(()=>{clearTimeout(d.current),ie("loaded")},[]),m=B(()=>{e.logger.info("[privy:webview] reloading, load failed"),ie("reloading"),e.embeddedWallet.reload()},[e]),w=B(f=>{let y=Math.min(Ao*be(2,s.current),xo);s.current+=1,e.logger.warn(`[privy:webview] load failed (${f.nativeEvent.code}: ${f.nativeEvent.description}), retrying in ${y}ms`),clearTimeout(d.current),d.current=setTimeout(m,y)},[e,m]),v=B(()=>{c("content process terminated")},[c]),h=B(()=>{c("render process gone")},[c]);return t?vo.createElement(Eo,{key:r,style:{flex:1},ref:f=>{f&&(e.setMessagePoster(f),n.current=f)},cacheEnabled:!1,cacheMode:"LOAD_NO_CACHE",injectedJavaScriptObject:Co,injectedJavaScriptBeforeContentLoaded:_o,source:{uri:e.embeddedWallet.getURL()},webviewDebuggingEnabled:e.logger.level==="DEBUG",onLoad:p,onError:w,onMessage:u,onContentProcessDidTerminate:v,onRenderProcessGone:h}):null};import{useEffect as Gt,useRef as Ro}from"react";import{AppState as Io}from"react-native";import{Platform as Ke}from"react-native";var Po="sdk_initialize";function Nt(){let{major:e,minor:t,patch:n,prerelease:r}=Ke.constants.reactNativeVersion;return{name:Po,properties:{reactNativeVersion:`${e}.${t}.${n}${r!=null?`-${r}`:""}`,operatingSystem:`${Ke.OS}:${Ke.Version}`}}}import{PrivyApiError as qt,PrivyClientError as Uo}from"@privy-io/js-sdk-core";function C(e){return e instanceof Error||e instanceof qt||e instanceof Uo?e:typeof e=="string"?new Error(e):new Error("Unknown error")}var jt=e=>{if(e instanceof qt)return`${e.code}`=="missing_or_invalid_token"?"logged_out":e.status===408||e.status===429||e.status>=500?"transient":"permanent";if(e instanceof TypeError||e instanceof SyntaxError)return"transient";let t=e==null?void 0:e.name;return t==="AbortError"||t==="TimeoutError"?"transient":"permanent"},zt=(e,t)=>e===t||e!==null&&t!==null&&e.name===t.name&&e.message===t.message&&Vt(e)===Vt(t),Vt=e=>"code"in e?String(e.code):void 0;var Kt=({client:e,setIsUserInitialized:t,setError:n})=>{let r=Ro(e);Gt(()=>{r.current=e},[e]),Gt(()=>{let i=!1,a=!1,o=!1,s=!1,d=0,c,u=!1,p=h=>{n(f=>zt(f,h)?f:h),t(!0)},m=()=>l(void 0,null,function*(){o=!0;let h=r.current;try{if(yield h.initialize(),a||(a=!0,h.track(Nt())),yield h.user.get(),i)return;s=!1,p(null)}catch(f){if(i)return;let y=C(f);switch(jt(f)){case"logged_out":{s=!1,p(null);return}case"permanent":{s=!1,p(y);return}case"transient":{if(s=!0,p(y),d<Mo){let S=Math.min(Oo*be(2,d),Lo);d+=1,c=setTimeout(w,S)}return}}}finally{o=!1}}),w=()=>{if(c=void 0,b()){s=!1;return}m()},v=Io.addEventListener("change",h=>{if(h==="background"){u=!0;return}h!=="active"||!u||(u=!1,!(!s||o)&&(clearTimeout(c),w()))});return m(),()=>{i=!0,clearTimeout(c),v.remove()}},[n,t])},Mo=8,Oo=1e3,Lo=6e4;import{useCallback as He,useEffect as $t,useMemo as Je}from"react";import{errorIndicatesRecoveryIsNeeded as To,getAllUserEmbeddedSolanaWallets as Do,getEntropyDetailsFromUser as Qt,PrivyClientError as se}from"@privy-io/js-sdk-core";import{getAllUserEmbeddedSolanaWallets as Be,getEntropyDetailsFromAccount as Bt,getUserEmbeddedEthereumWallet as Fo,PrivyClientError as $}from"@privy-io/js-sdk-core";function Ht(a){return l(this,arguments,function*({client:e,setSolanaWallet:t,createSolanaWalletCallbacks:n,setSolanaRecoveryFlowState:r,opts:i}){var o,s,d;t({status:"creating"});try{let{user:c}=yield e.user.get(),u=Be(c),p=u[0],m=(o=Fo(c))!=null?o:void 0;if(i!=null&&i.recoveryMethod&&i.recoveryMethod!=="privy")throw new $({code:"embedded_wallet_creation_error",error:"Unsupported recovery method for solana wallet."});if(!(i!=null&&i.createAdditional)&&p)throw new $({code:"embedded_wallet_creation_error",error:"Solana wallet already exists for this user. Set `createAdditional` to `true` to create another wallet"});let w,v;if(p){let f=m!=null?m:p,{entropyId:y,entropyIdVerifier:S}=Bt(f),E=Math.max(...u.map(P=>P.wallet_index),0)+1,A=yield e.embeddedWallet.add({chainType:"solana",entropyId:y,entropyIdVerifier:S,hdWalletIndex:E}),k=A.account;if(!k||k.chain_type!=="solana")throw new $({error:"Embedded wallet account not created",code:"embedded_wallet_creation_error"});w=yield e.embeddedWallet.getSolanaProvider(k,y,S,void 0,void 0,void 0,void 0,P=>l(this,null,function*(){return yield U()(P)}),P=>l(this,null,function*(){return yield R()(P)})),v=A.user}else{let f=yield e.embeddedWallet.createSolana({ethereumAccount:m}),y=Be(f.user).find(k=>k.wallet_index===0);if(!y)throw new $({error:"Embedded wallet account not created",code:"embedded_wallet_creation_error"});let S=m!=null?m:y,{entropyId:E,entropyIdVerifier:A}=Bt(S);w=yield e.embeddedWallet.getSolanaProvider(y,E,A,void 0,void 0,void 0,void 0,k=>l(this,null,function*(){return yield U()(k)}),k=>l(this,null,function*(){return yield R()(k)})),v=f.user}let h=Be(v)[0];if(!h)throw new $({code:"embedded_wallet_creation_error",error:"Unknown error creating solana wallet"});return(d=(s=n.current)==null?void 0:s.onSuccess)==null||d.call(s,w),t({status:"connected",publicKey:h.public_key}),r({status:"initial"}),w}catch(c){let u=c instanceof Error?c.message:"Error creating embedded wallet";throw t({status:"error",error:u}),r({status:"initial"}),new $({code:"embedded_wallet_creation_error",error:u})}})}import{PrivyClientError as H}from"@privy-io/js-sdk-core";function We(u){return l(this,arguments,function*({client:e,account:t,setWallet:n,recoverWalletCallbacks:r,recoveryMethod:i,setRecoveryFlowState:a,password:o,recoveryKey:s,recoveryToken:d,recoverySecretOverride:c}){var p,m,w,v;if(!t)throw new H({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});switch(i){case"user-passcode":if(!o)throw new H({code:"embedded_wallet_recovery_error",error:"password is required for user-passcode recovery method"});break;case"google-drive":if(!d)throw new H({code:"embedded_wallet_recovery_error",error:"Recovery token is required for google-drive recovery method"});break;case"icloud":if(!c)throw new H({code:"embedded_wallet_recovery_error",error:"Record name is required for icloud recovery method"});break;case"recovery-encryption-key":if(!s)throw new H({code:"embedded_wallet_recovery_error",error:"recoveryKey is required for recovery-encryption-key recovery method"});break}n({status:"connecting",account:t});try{let h=yield e.embeddedWallet.getEthereumProvider({wallet:t,entropyId:t.address,entropyIdVerifier:"ethereum-address-verifier",recoveryPassword:o,recoveryAccessToken:d,recoverySecretOverride:c,recoveryKey:s,onMfaEnrollmentRequired:f=>l(this,null,function*(){return yield U()(f)}),onMfaVerificationRequired:f=>l(this,null,function*(){return yield R()(f)})});return n({status:"connected",provider:h,account:t}),a({status:"initial"}),(m=(p=r.current)==null?void 0:p.onSuccess)==null||m.call(p,h),h}catch(h){n({status:"needs-recovery",account:t}),a({status:"initial"});let f=new H({code:"embedded_wallet_recovery_error",error:h instanceof Error?h.message:"Error recovering embedded wallet"});throw(v=(w=r.current)==null?void 0:w.onError)==null||v.call(w,f),f}})}function Jt(s){return l(this,arguments,function*({client:e,account:t,entropyId:n,entropyIdVerifier:r,setSolanaWallet:i,recoverSolanaWalletCallbacks:a,setSolanaRecoveryFlowState:o}){var d,c,u,p;i({status:"connecting"});try{let m=yield e.embeddedWallet.getSolanaProvider(t,n,r,void 0,void 0,void 0,void 0,w=>l(this,null,function*(){return yield U()(w)}),w=>l(this,null,function*(){return yield R()(w)}));return i({status:"connected",publicKey:m._publicKey}),o({status:"initial"}),(c=(d=a.current)==null?void 0:d.onSuccess)==null||c.call(d,m),m}catch(m){i({status:"needs-recovery"}),o({status:"initial"});let w=new H({code:"embedded_wallet_recovery_error",error:m instanceof Error?m.message:"Error recovering embedded wallet"});throw(p=(u=a.current)==null?void 0:u.onError)==null||p.call(u,w),w}})}var Yt=({client:e,solanaWallet:t,setSolanaWallet:n,setSolanaRecoveryFlowState:r,createSolanaWalletCallbacks:i,recoverSolanaWalletCallbacks:a})=>{let o=I(),s=Je(()=>Do(o),[o]),d=G(),c=Je(()=>s.length===0?null:Qt(o,s[0]),[o,s]),u=Je(()=>{let v=s.map(S=>{let E=Qt(o,S);return E?{account:S,entropy:E}:null});if(v.some(S=>S===null))return[];let h=void 0,f=void 0,y=void 0;return v.filter(S=>S!==null).map(({account:S,entropy:{entropyId:E,entropyIdVerifier:A}})=>({address:S.address,publicKey:S.address,walletIndex:S.wallet_index,getProvider:()=>e.embeddedWallet.getSolanaProvider(S,E,A,h,f,y,k=>l(void 0,null,function*(){var P;yield(P=Ce())==null?void 0:P(k)}),k=>l(void 0,null,function*(){return yield U()(k)}),k=>l(void 0,null,function*(){return yield R()(k)}))}))},[s,o,e]),p=He(v=>l(void 0,null,function*(){return yield Ht({client:e,setSolanaWallet:n,createSolanaWalletCallbacks:i,setSolanaRecoveryFlowState:r,opts:v})}),[e,i]),m=He(()=>l(void 0,null,function*(){if(!c)throw new se({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});let{entropyId:v,entropyIdVerifier:h}=c;return Jt({client:e,account:s[0],entropyId:v,entropyIdVerifier:h,setSolanaWallet:n,recoverSolanaWalletCallbacks:a,setSolanaRecoveryFlowState:r})}),[e,c,s,a,r,n]),w=He(()=>l(void 0,null,function*(){if(!c)throw n({status:"not-created"}),new se({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});n(v=>v.status==="connected"?{status:"reconnecting"}:{status:"connecting"});try{let{entropyId:v,entropyIdVerifier:h}=c,f=yield e.embeddedWallet.getSolanaProvider(s[0],v,h,void 0,void 0,void 0,void 0,y=>l(void 0,null,function*(){return yield U()(y)}),y=>l(void 0,null,function*(){return yield R()(y)}));return n({status:"connected",publicKey:s[0].public_key}),f}catch(v){throw To(v)?(n({status:"needs-recovery"}),new se({code:"embedded_wallet_needs_recovery",error:"Embedded wallet not loaded on device"})):v instanceof Error?(n({status:"error",error:v.message}),new se({code:"unknown_embedded_wallet_error",error:v.message})):(n({status:"error",error:"Error loading embedded wallet"}),new se({code:"unknown_embedded_wallet_error",error:"Error loading embedded wallet"}))}}),[s,e,c,n]);return $t(()=>{if(!o&&t.status!=="disconnected")return n({status:"disconnected"});d&&w().catch(()=>{})},[d,o]),$t(()=>{t.status==="error"&&t.error.includes("User must be logged in")&&w()},[t.status]),{create:p,recover:m,getProvider:w,wallets:u}};import{useCallback as le,useEffect as or,useMemo as Ho}from"react";import{getUserEmbeddedEthereumWallet as Jo,getUserEmbeddedSolanaWallet as nr,isUnifiedWallet as $o,throwIfInvalidRecoveryUpgradePath as Qo}from"@privy-io/js-sdk-core";import{errorIndicatesRecoveryIsNeeded as Yo,PrivyClientError as O}from"@privy-io/js-sdk-core";import{getUserEmbeddedEthereumWallet as No}from"@privy-io/js-sdk-core";import{PrivyClientError as Q}from"@privy-io/js-sdk-core";function Ae(p){return l(this,arguments,function*({client:e,setWallet:t,createWalletCallbacks:n,recoveryMethod:r,setRecoveryFlowState:i,password:a,recoveryKey:o,recoveryToken:s,recoverySecretOverride:d,iCloudRecordNameOverride:c,solanaAccount:u}){var w,v;switch(r){case"user-passcode":if(!a)throw new Q({code:"embedded_wallet_recovery_error",error:"password is required for user-passcode recovery method"});break;case"recovery-encryption-key":if(!o)throw new Q({code:"embedded_wallet_recovery_error",error:"key is required for recovery-encryption-key recovery method"});break;case"google-drive":if(!s)throw new Q({code:"embedded_wallet_recovery_error",error:"Recovery token is required for google-drive recovery method"});break;case"icloud":if(!d||!c)throw new Q({code:"embedded_wallet_recovery_error",error:"iCloud recovery failed due to inability to store credentials"});break}t({status:"creating",account:null});let m=r==="icloud"?"icloud-native":r;try{let{user:h}=yield e.embeddedWallet.create({password:a,recoveryMethod:m,recoveryKey:o,recoveryToken:s,recoverySecretOverride:d,iCloudRecordNameOverride:c,solanaAccount:u}),f=No(h);if(!f)throw new Q({error:"Embedded wallet account not created",code:"embedded_wallet_creation_error"});let y=yield e.embeddedWallet.getEthereumProvider({wallet:f,entropyId:f.address,entropyIdVerifier:"ethereum-address-verifier",onMfaEnrollmentRequired:S=>l(this,null,function*(){return yield U()(S)}),onMfaVerificationRequired:S=>l(this,null,function*(){return yield R()(S)})});return(v=(w=n.current)==null?void 0:w.onSuccess)==null||v.call(w,y),t({status:"connected",provider:y,account:f}),i({status:"initial"}),y}catch(h){let f=h instanceof Error?h.message:"Error creating embedded wallet";throw t({status:"error",error:f,account:null}),i({status:"initial"}),new Q({code:"embedded_wallet_creation_error",error:f})}})}import{Platform as Zt}from"react-native";import{PrivyClientError as j}from"@privy-io/js-sdk-core";import{Platform as Vo}from"react-native";var Xt=new Set;function xe(e,{isDevelopment:t=__DEV__,reactNativeVersion:n=Vo.constants.reactNativeVersion,warn:r=i=>console.warn(i)}={}){if(!t||Xt.has(e))return;let{major:i,minor:a,patch:o}=n;if(i>0||i===0&&a>=81)return;let d=`[Privy] Upcoming optional dependency change
|
|
2
|
+
|
|
3
|
+
This app uses React Native ${`${i}.${a}.${o}`}. A future @privy-io/expo release will make ${e} optional.
|
|
4
|
+
|
|
5
|
+
`,c=i===0&&a>=79?d+`Upgrade to Expo SDK 54 or React Native 0.81 when possible. If remaining on Expo SDK 53 or React Native 0.79\u20130.80, ensure metro, metro-config, and metro-runtime resolve to version 0.82.5 or newer and transformer.allowOptionalDependencies is enabled.
|
|
6
|
+
|
|
7
|
+
Check Metro with:
|
|
8
|
+
pnpm why metro metro-config metro-runtime
|
|
9
|
+
npm ls metro metro-config metro-runtime
|
|
10
|
+
yarn why metro
|
|
11
|
+
|
|
12
|
+
If these requirements cannot be met, keep ${e} installed.`:d+`Expo SDK 52 and React Native 0.78 or earlier cannot safely omit ${e}. Upgrade to Expo SDK 54 or React Native 0.81, or keep ${e} installed.`;Xt.add(e),r(c)}function er(){return l(this,null,function*(){xe("@privy-io/expo-native-extensions");try{return yield import("@privy-io/expo-native-extensions")}catch(e){throw new j({code:"configuration_error",error:"`@privy-io/expo-native-extensions` is not installed. Install it and rebuild the native app."})}})}function ce(r){return l(this,arguments,function*({user:e,appId:t,client:n}){var s;if(Zt.OS==="android")throw new j({code:"embedded_wallet_recovery_error",error:"iCloud recovery is not supported on Android"});let i=yield er(),a=yield n.recovery.icloudAuth.getICloudConfiguration("expo-ios");if(!(a==null?void 0:a.container_identifier))throw new j({code:"embedded_wallet_recovery_error",error:"An iCloud Container ID must be specified in the Privy Dashboard."});try{let{recoverySecret:d,iCloudRecordName:c}=yield i.writeRecoverySecretToICloud({containerId:a.container_identifier,appId:t,userId:e.id});return{recoverySecret:d,iCloudRecordName:c}}catch(d){if(d instanceof Error){let c=(s=d.message.split("Caused by: ")[1])!=null?s:"Error writing to iCloud";throw new j({code:"embedded_wallet_recovery_error",error:c})}throw new j({code:"embedded_wallet_recovery_error",error:"Error writing to iCloud"})}})}function Pe(r){return l(this,arguments,function*({walletAddress:e,client:t,chainType:n}){var c;if(Zt.OS==="android")throw new j({code:"embedded_wallet_recovery_error",error:"iCloud recovery is not supported on Android"});let i=yield er(),o=(yield t.recovery.getRecoveryKeyMaterial(e,n)).icloud_record_name;if(!o)throw new j({code:"embedded_wallet_recovery_error",error:"iCloud recovery not properly backed up."});let s=yield t.recovery.icloudAuth.getICloudConfiguration("expo-ios"),d=s==null?void 0:s.container_identifier;if(!d)throw new j({code:"embedded_wallet_recovery_error",error:"An iCloud Container ID must be specified in the Privy Dashboard."});try{let{recoverySecret:u}=yield i.readRecoverySecretFromICloud({containerId:d,recordName:o});return{recoverySecret:u}}catch(u){if(u instanceof Error){let p=(c=u.message.split("Caused by: ")[1])!=null?c:"Error writing to iCloud";throw new j({code:"embedded_wallet_recovery_error",error:p})}throw new j({code:"embedded_wallet_recovery_error",error:"Error writing to iCloud"})}})}import*as J from"expo-linking";import*as tr from"expo-web-browser";import{Platform as rr}from"react-native";import{PrivyClientError as X}from"@privy-io/js-sdk-core";import _c from"react-fast-compare";var Y=e=>new Promise(t=>setTimeout(t,e));import{useEffect as qo,useRef as jo}from"react";import{AppState as $e}from"react-native";function Ue(){let e=jo($e.currentState);qo(()=>$e.addEventListener("change",r=>{e.current=r}).remove,[]);function t(){return $e.currentState}return{appState:e,getCurrentAppState:t}}function de(i){return l(this,arguments,function*({provider:e,redirectUri:t,client:n,onError:r}){try{let a;switch(e){case"google-drive":{let{url:c}=yield n.recovery.auth.generateURL(J.createURL(t||"/"));a=c;break}default:throw new X({error:"OAuth invalid provider",code:"embedded_wallet_recovery_error"})}let o=yield tr.openAuthSessionAsync(a);if(rr.OS==="android")return;if(o.type!=="success")throw new X({error:"Recovery OAuth session failed",code:"embedded_wallet_recovery_error"});let{queryParams:s}=J.parse(o.url),d;switch(e){case"google-drive":{let{privy_oauth_state:c,privy_oauth_code:u}=s;if(!u||!c)throw new X({error:"Recovery OAuth invalid credentials",code:"embedded_wallet_recovery_error"});d=yield Re({oAuthCode:u,oAuthState:c,client:n});break}default:throw new X({error:"Recovery OAuth invalid provider",code:"embedded_wallet_recovery_error"})}return d}catch(a){throw r==null||r(C(a)),a}})}function Re(r){return l(this,arguments,function*({oAuthCode:e,oAuthState:t,client:n}){let{access_token:i}=yield n.recovery.auth.authorize(e,t);if(!i)throw new X({error:"OAuth invalid credentials",code:"login_with_oauth_returned_with_invalid_credentials"});return i})}var zo=2*60*1e3;function Go(e){let t;return new Promise((n,r)=>{t=J.addEventListener("url",a=>l(this,[a],function*({url:i}){if(!i)return;let{queryParams:o}=J.parse(i),{privy_oauth_state:s,privy_oauth_code:d}=o!=null?o:{};if(typeof d!="string"||typeof s!="string")return;let c=yield Re({client:e,oAuthCode:d,oAuthState:s});n(c)})),setTimeout(()=>{r(new X({code:"embedded_wallet_set_recovery_error",error:"Failed to complete Google Drive recovery flow"}))},zo)}).finally(()=>{t==null||t.remove()})}function Ie(e){return l(this,null,function*(){let t;rr.OS==="android"&&(t=Go(e));let n=yield de({provider:"google-drive",client:e});return n!=null?n:yield t})}import{getUserEmbeddedWallet as Ko,PrivyClientError as Bo}from"@privy-io/js-sdk-core";function Me(a){return l(this,arguments,function*({client:e,recoveryInput:t,setWalletRecoveryCallbacks:n,setRecoveryFlowState:r,setWallet:i}){var o,s,d,c;try{let{provider:u,user:p}=yield e.embeddedWallet.setRecovery(t),m=u,w=Ko(p);return i({status:"connected",provider:m,account:w}),(s=(o=n.current)==null?void 0:o.onSuccess)==null||s.call(o,m),r({status:"initial"}),m}catch(u){let p=new Bo({code:"embedded_wallet_set_recovery_error",error:u instanceof Error?u.message:"Error setting password on embedded wallet"});throw(c=(d=n.current)==null?void 0:d.onError)==null||c.call(d,p),r({status:"initial"}),p}})}function ir(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 ar=({client:e,appId:t,wallet:n,setWallet:r,setRecoveryFlowState:i,createWalletCallbacks:a,recoverWalletCallbacks:o,setWalletRecoveryCallbacks:s})=>{let d=I(),c=Ho(()=>Jo(d),[d]),u=G(),p=le(f=>l(void 0,null,function*(){var we,ve;if(c)throw new O({error:"This user already has an embedded wallet",code:"embedded_wallet_already_exists"});let{user:y}=yield e.user.get(),{password:S,recoveryMethod:E,recoveryKey:A}=ir(f),k,P,V;if(E==="google-drive"&&(k=yield de({provider:E,client:e,onError:(we=a.current)==null?void 0:we.onError}),i({status:"creating-wallet"}),!k))return null;if(E==="icloud"){if(!y)throw new O({code:"embedded_wallet_recovery_error",error:"User must be loaded before creating a wallet with iCloud."});let{recoverySecret:Ve,iCloudRecordName:ne}=yield ce({user:y,appId:t,client:e});P=Ve,V=ne}return yield Ae({client:e,setWallet:r,createWalletCallbacks:a,recoveryMethod:E,recoveryKey:A,setRecoveryFlowState:i,password:S,recoverySecretOverride:P,iCloudRecordNameOverride:V,solanaAccount:(ve=nr(y))!=null?ve:void 0})}),[e,c,d]),m=le(f=>l(void 0,null,function*(){var E;if(n.status!=="connected")throw new O({code:"attempted_to_set_password_before_connected",error:"Embedded wallet must be connected before setting password"});if(!c)throw new O({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});if(nr(d))throw new O({code:"embedded_wallet_set_recovery_error",error:"Cannot set user-controlled recovery for a user with an embedded Solana wallet."});if($o(c))throw new O({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"});Qo({currentRecoveryMethod:c.recovery_method,upgradeToRecoveryMethod:f.recoveryMethod});let y,S;switch(f.recoveryMethod){case"privy":S=T(_({},f),{wallet:c});break;case"user-passcode":S=T(_({},f),{wallet:c,password:f.password});break;case"google-drive":if(y=yield de({provider:f.recoveryMethod,client:e,onError:(E=s.current)==null?void 0:E.onError}),i({status:"upgrading-recovery"}),!y)return null;S={recoveryMethod:"google-drive",wallet:c,recoveryAccessToken:y};break;case"icloud":if(!d)throw new O({code:"embedded_wallet_recovery_error",error:"User must be loaded before backing up to iCloud."});let{recoverySecret:A,iCloudRecordName:k}=yield ce({user:d,appId:t,client:e});S={recoveryMethod:"icloud-native",recoverySecretOverride:A,iCloudRecordNameOverride:k,wallet:c};break;default:throw new O({code:"embedded_wallet_recovery_error",error:"Unrecognized recovery method"})}return Me({client:e,recoveryInput:S,setWalletRecoveryCallbacks:s,setRecoveryFlowState:i,setWallet:r})}),[e,c,n.status,d]),w=le(f=>l(void 0,null,function*(){return m({recoveryMethod:"user-passcode",password:f})}),[e,c,n.status]),v=le(f=>l(void 0,null,function*(){var P;if(!c)throw new O({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});let{password:y,recoveryMethod:S,recoveryKey:E}=ir(f),A,k;if(S==="google-drive"&&(A=yield de({provider:S,client:e,onError:(P=o.current)==null?void 0:P.onError}),i({status:"recovering"}),!A))return null;if(S==="icloud"){if(!d)throw new O({code:"embedded_wallet_recovery_error",error:"User must be loaded before recovering via iCloud."});let{recoverySecret:V}=yield Pe({client:e,walletAddress:c.address});k=V}return We({client:e,account:c,setWallet:r,recoverWalletCallbacks:o,recoveryMethod:S,setRecoveryFlowState:i,recoveryKey:E,password:y,recoveryToken:A,recoverySecretOverride:k})}),[e,c]),h=le(()=>l(void 0,null,function*(){if(!c)throw r({status:"not-created",account:null}),new O({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});r(f=>f.status==="connected"?{status:"reconnecting",account:c}:{status:"connecting",account:c});try{let f=yield e.embeddedWallet.getEthereumProvider({wallet:c,entropyId:c.address,entropyIdVerifier:"ethereum-address-verifier",onMfaEnrollmentRequired:y=>l(void 0,null,function*(){return yield U()(y)}),onMfaVerificationRequired:y=>l(void 0,null,function*(){return yield R()(y)})});return r({status:"connected",provider:f,account:c}),f}catch(f){throw Yo(f)?(r({status:"needs-recovery",account:c}),new O({code:"embedded_wallet_needs_recovery",error:"Embedded wallet not loaded on device"})):f instanceof Error?(r({status:"error",error:f.message,account:c}),new O({code:"unknown_embedded_wallet_error",error:f.message})):(r({status:"error",error:"Error loading embedded wallet",account:c}),new O({code:"unknown_embedded_wallet_error",error:"Error loading embedded wallet"}))}}),[e,c]);return or(()=>{if(!d&&n.status!=="disconnected")return r({status:"disconnected",account:null});u&&h().catch(()=>{})},[u,d,c]),or(()=>{n.status==="error"&&n.error.includes("User must be logged in")&&h()},[n.status]),{create:p,recover:v,setPassword:w,setRecovery:m,getProvider:h}};import{useEffect as Xo,useState as Zo}from"react";import{PrivyClientError as sr}from"@privy-io/js-sdk-core";var cr=({client:e,isReady:t})=>{let n=I(),r=_e(o=>o==null?void 0:o.customAuth),[i,a]=Zo({status:"initial"});return Xo(()=>{(()=>l(void 0,null,function*(){if(!(r!=null&&r.enabled)){a({status:"not-enabled"});return}a({status:"loading"});let{getCustomAccessToken:s,isLoading:d}=r;if(!(!t||d))try{let c=yield s();if(!c&&n){yield e.auth.logout(),a({status:"done"});return}if(!c){a({status:"done"});return}if(n){a({status:"done"});return}let u=x();if(!(yield e.auth.customProvider.syncWithToken(c,{embedded:u==null?void 0:u.embedded}))){yield e.auth.logout(),a({status:"error",error:new sr({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 sr({error:"Third-party auth failed",code:"third_party_auth_error"})}}))()},[e,n,t,r==null?void 0:r.enabled,r==null?void 0:r.getCustomAccessToken,r==null?void 0:r.isLoading]),{customAuthState:i,customAuthStateIsSettled:i.status!=="loading"&&i.status!=="initial"}};import*as Z from"expo-linking";import{useCallback as en,useEffect as tn,useMemo as rn}from"react";import{Platform as on}from"react-native";import{getUserEmbeddedSolanaWallet as nn,getUserEmbeddedWallet as an}from"@privy-io/js-sdk-core";var dr=({client:e,createWalletCallbacks:t,recoverWalletCallbacks:n,setWalletRecoveryCallbacks:r,recoveryFlowState:i,oAuthState:a,setRecoveryFlowState:o,setWallet:s,appStateVisible:d})=>{let c=Z.useURL(),u=I(),p=rn(()=>an(u),[u]),m=G(),w=en(v=>{var f,y,S,E;let h=C(v);i.status==="creating-wallet"?(y=(f=t.current).onError)==null||y.call(f,C(h)):(E=(S=n.current).onError)==null||E.call(S,C(h)),o({status:"initial"})},[i]);return tn(()=>{function v(){return l(this,null,function*(){var S;if(!c&&i.status!=="initial"&&d&&w(new Error("Recovery OAuth session failed")),!c||i.status==="initial"||a.status!=="initial"||!d||!m)return;let{queryParams:h}=Z.parse(c),{privy_oauth_state:f,privy_oauth_code:y}=h;if(!(!y||!f)){yield Z.openURL(c.split("?")[0]);try{let E=yield Re({oAuthCode:y,oAuthState:f,client:e});if(i.status==="creating-wallet"){let A=(S=nn(u))!=null?S:void 0;yield Ae({client:e,setWallet:s,createWalletCallbacks:t,recoveryMethod:"google-drive",setRecoveryFlowState:o,recoveryToken:E,solanaAccount:A})}else if(i.status==="upgrading-recovery"){if(!p)throw new Error("Embedded wallet not found");yield Me({client:e,recoveryInput:{recoveryMethod:"google-drive",wallet:p,recoveryAccessToken:E},setWalletRecoveryCallbacks:r,setRecoveryFlowState:o,setWallet:s})}else yield We({client:e,account:p,setWallet:s,recoverWalletCallbacks:n,recoveryMethod:"google-drive",setRecoveryFlowState:o,recoveryToken:E})}catch(E){w(E)}}})}on.OS==="android"&&v()},[c,i.status,d,m])};import{useEffect as es,useRef as ts}from"react";import{useCallback as Qe,useContext as sn}from"react";import{PrivyClientError as cn}from"@privy-io/js-sdk-core";var kd=e=>{let{client:t,setSiweState:n,siweState:r}=sn(g),i=Qe(s=>{var c;let d=C(s);return n({status:"error",error:d}),(c=e==null?void 0:e.onError)==null||c.call(e,d),d},[e==null?void 0:e.onError]),a=Qe(u=>l(void 0,[u],function*({wallet:s,from:{domain:d,uri:c}}){var p;try{n({status:"generating-message"});let m=yield t.auth.siwe.init(s,d,c);return n({status:"awaiting-signature"}),(p=e==null?void 0:e.onGenerateMessage)==null||p.call(e,m.message),m.message}catch(m){throw i(m)}}),[t,i,e==null?void 0:e.onGenerateMessage]);return{loginWithSiwe:Qe(u=>l(void 0,[u],function*({signature:s,messageOverride:d,disableSignup:c}){var p;try{if(b())throw new cn({code:"attempted_login_with_siwe_while_already_logged_in",error:"Already logged in, use `useLinkWithSiwe` if you are trying to link a wallet to an existing account"});n({status:"submitting-signature"});let w=x(),v=yield t.auth.siwe.loginWithSiwe(s,void 0,d,c?"no-signup":"login-or-sign-up",{embedded:w==null?void 0:w.embedded});return n({status:"done"}),(p=e==null?void 0:e.onSuccess)==null||p.call(e,v.user,v.is_new_user),v.user}catch(m){throw i(m)}}),[t,i,e==null?void 0:e.onSuccess]),generateSiweMessage:a,state:r}};import{useCallback as lr}from"react";import{createSiwsMessage as ln,PrivyClientError as un}from"@privy-io/js-sdk-core";import{useContext as dn}from"react";var W=()=>{let{client:e}=dn(g);return e};var Fd=()=>{let e=W(),t=lr(s=>l(void 0,[s],function*({wallet:{address:r},from:{domain:i,uri:a},chain:o}){try{let{nonce:d}=yield e.auth.siws.fetchNonce({address:r});return{message:ln({address:r,domain:i,uri:a,nonce:d,chain:o})}}catch(d){throw C(d)}}),[e]),n=lr(s=>l(void 0,[s],function*({signature:r,message:i,wallet:{walletClientType:a,connectorType:o}={}}){try{if(!b())throw new un({code:"attempted_link_siws_before_logged_in",error:"Must be logged in to link a wallet, Use `useLoginWithSiws` to login with a wallet"});let{user:c}=yield e.auth.siws.link({signature:r,message:i,walletClientType:a,connectorType:o});return c}catch(d){throw C(d)}}),[e]);return{generateMessage:t,link:n}};import{useCallback as ur}from"react";import{createSiwsMessage as pn,PrivyClientError as mn}from"@privy-io/js-sdk-core";var Kd=()=>{let e=W(),t=ur(s=>l(void 0,[s],function*({wallet:{address:r},from:{domain:i,uri:a},chain:o}){try{let{nonce:d}=yield e.auth.siws.fetchNonce({address:r});return{message:pn({address:r,domain:i,uri:a,nonce:d,chain:o})}}catch(d){throw C(d)}}),[e]),n=ur(d=>l(void 0,[d],function*({signature:r,message:i,wallet:{walletClientType:a,connectorType:o}={},disableSignup:s}){try{if(b())throw new mn({code:"attempted_login_with_siws_while_already_logged_in",error:"Already logged in, use `useLinkWithSiws` if you are trying to link a wallet to an existing account"});let u=x();return(yield e.auth.siws.login({signature:r,message:i,walletClientType:a,connectorType:o,mode:s?"no-signup":"login-or-sign-up",opts:{embedded:u==null?void 0:u.embedded}})).user}catch(c){throw C(c)}}),[e]);return{generateMessage:t,login:n}};import{useCallback as pr,useContext as fn}from"react";import{PrivyClientError as yn}from"@privy-io/js-sdk-core";var Zd=e=>{let{client:t}=fn(g),n=pr(i=>{var o;let a=C(i);return(o=e==null?void 0:e.onError)==null||o.call(e,a),a},[e==null?void 0:e.onError]);return{unlinkWallet:pr(a=>l(void 0,[a],function*({address:i}){var o;try{if(!b())throw new yn({code:"attempted_unlink_siwe_before_logged_in",error:"Must be logged in to unlink a wallet, Use `useLoginWithSiwe` to login with a wallet"});let{user:d}=yield t.auth.siwe.unlinkWallet(i);return(o=e==null?void 0:e.onSuccess)==null||o.call(e,d),d}catch(s){throw n(s)}}),[t,n,e==null?void 0:e.onSuccess])}};import{useCallback as Ye,useContext as gn,useState as hn}from"react";import{PrivyClientError as mr}from"@privy-io/js-sdk-core";var sl=e=>{let[t,n]=hn(""),{client:r,otpState:i,setOtpState:a}=gn(g),o=Ye(c=>{var p;let u=C(c);return a({status:"error",error:u}),(p=e==null?void 0:e.onError)==null||p.call(e,u),u},[e,a]),s=Ye(u=>l(void 0,[u],function*({email:c}){var p;n(c);try{a({status:"sending-code"});let m=yield r.auth.email.sendCode(c);return a({status:"awaiting-code-input"}),(p=e==null?void 0:e.onSendCodeSuccess)==null||p.call(e,{email:c}),m}catch(m){throw o(m)}}),[r,o,e,a]),d=Ye(p=>l(void 0,[p],function*({code:c,email:u}){var m;try{if(!b())throw new mr({code:"attempted_link_email_before_logged_in",error:"Must be logged in to link an email, Use `useLoginWithEmail` to login with email"});let v=u||t;if(!v)throw new mr({code:"attempted_submit_otp_before_sending",error:"Must `sendCode` with a valid email before calling `linkWithCode`"});a({status:"submitting-code"});let{user:h}=yield r.auth.email.linkWithCode(v,c);return a({status:"done"}),(m=e==null?void 0:e.onLinkSuccess)==null||m.call(e,h),h}catch(w){throw o(w)}}),[t,a,r,e,o]);return{sendCode:s,linkWithCode:d,state:i}};import{useCallback as fr,useContext as wn}from"react";var ml=e=>{let{client:t}=wn(g),n=fr(i=>{var o;let a=C(i);return(o=e==null?void 0:e.onError)==null||o.call(e,a),a},[e==null?void 0:e.onError]);return{unlinkEmail:fr(a=>l(void 0,[a],function*({email:i}){var o;try{let{user:s}=yield t.auth.email.unlink(i);return(o=e==null?void 0:e.onSuccess)==null||o.call(e,s),s}catch(s){throw n(s)}}),[t,e==null?void 0:e.onSuccess,n])}};import{useCallback as Xe,useContext as vn,useState as Sn}from"react";import{PrivyClientError as yr}from"@privy-io/js-sdk-core";var El=e=>{let[t,n]=Sn(""),{client:r,otpState:i,setOtpState:a}=vn(g),o=Xe(c=>{var p;let u=C(c);return a({status:"error",error:u}),(p=e==null?void 0:e.onError)==null||p.call(e,u),u},[e,a]),s=Xe(u=>l(void 0,[u],function*({email:c}){var p;n(c);try{a({status:"sending-code"});let m=yield r.auth.email.sendCode(c);return a({status:"awaiting-code-input"}),(p=e==null?void 0:e.onSendCodeSuccess)==null||p.call(e,{email:c}),m}catch(m){throw o(m)}}),[r,o,e,a]),d=Xe(m=>l(void 0,[m],function*({code:c,email:u,disableSignup:p}){var w;try{if(b()&&!r.isMultiUserModeEnabled)throw new yr({code:"attempted_login_with_email_while_already_logged_in",error:"Already logged in, use `useLinkWithEmail` if you are trying to link an email to an existing account"});let h=u||t;if(!h)throw new yr({code:"attempted_submit_otp_before_sending",error:"Must `sendCode` with a valid email before calling `loginWithCode`"});a({status:"submitting-code"});let f=x(),y=yield r.auth.email.loginWithCode(h,c,p?"no-signup":"login-or-sign-up",{embedded:f==null?void 0:f.embedded});return a({status:"done"}),(w=e==null?void 0:e.onLoginSuccess)==null||w.call(e,y.user,y.is_new_user),y==null?void 0:y.user}catch(v){throw o(v)}}),[t,a,r,e,o]);return{sendCode:s,loginWithCode:d,state:i}};import{useCallback as Ze,useContext as bn,useState as En}from"react";import{PrivyClientError as gr}from"@privy-io/js-sdk-core";var Ul=e=>{let[t,n]=En(""),{client:r,otpState:i,setOtpState:a}=bn(g),o=Ze(c=>{var p;let u=C(c);return a({status:"error",error:u}),(p=e==null?void 0:e.onError)==null||p.call(e,u),u},[e,a]),s=Ze(u=>l(void 0,[u],function*({phone:c}){var p;n(c);try{a({status:"sending-code"});let m=yield r.auth.phone.sendCode(c);return a({status:"awaiting-code-input"}),(p=e==null?void 0:e.onSendCodeSuccess)==null||p.call(e,{phone:c}),m}catch(m){throw o(m)}}),[r,o,e,a]),d=Ze(p=>l(void 0,[p],function*({code:c,phone:u}){var m;try{if(!b())throw new gr({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 gr({code:"attempted_submit_otp_before_sending",error:"Must `sendCode` with a valid phone number before calling `linkWithCode`"});a({status:"submitting-code"});let{user:h}=yield r.auth.phone.linkWithCode(u||t,c);return a({status:"done"}),(m=e==null?void 0:e.onLinkSuccess)==null||m.call(e,h),h}catch(w){throw o(w)}}),[t,a,r,e,o]);return{sendCode:s,linkWithCode:d,state:i}};import{useCallback as et,useContext as Cn,useState as _n}from"react";import{PrivyClientError as hr}from"@privy-io/js-sdk-core";var Nl=e=>{let[t,n]=_n(""),{client:r,otpState:i,setOtpState:a}=Cn(g),o=et(c=>{var p;let u=C(c);return a({status:"error",error:u}),(p=e==null?void 0:e.onError)==null||p.call(e,u),u},[e,a]),s=et(u=>l(void 0,[u],function*({phone:c}){var p;n(c);try{a({status:"sending-code"});let m=yield r.auth.phone.sendCode(c);return a({status:"awaiting-code-input"}),(p=e==null?void 0:e.onSendCodeSuccess)==null||p.call(e,{phone:c}),m}catch(m){throw o(m)}}),[r,o,e,a]),d=et(m=>l(void 0,[m],function*({code:c,phone:u,disableSignup:p}){var w;try{if(b())throw new hr({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 hr({code:"attempted_submit_otp_before_sending",error:"Must `sendCode` with a valid phone number before calling `loginWithCode`"});a({status:"submitting-code"});let f=x(),y=yield r.auth.phone.loginWithCode(u||t,c,p?"no-signup":"login-or-sign-up",{embedded:f==null?void 0:f.embedded});return a({status:"done"}),(w=e==null?void 0:e.onLoginSuccess)==null||w.call(e,y.user,y.is_new_user),y==null?void 0:y.user}catch(v){throw o(v)}}),[t,a,r,e,o]);return{sendCode:s,loginWithCode:d,state:i}};import*as Oe from"expo-linking";import{useCallback as tt,useContext as kn,useRef as Wn}from"react";import{PrivyClientError as ue}from"@privy-io/js-sdk-core";var Hl=e=>{let{appState:t,getCurrentAppState:n}=Ue(),{client:r,farcasterState:i,setFarcasterState:a}=kn(g),o=Wn(!1),s=tt(u=>{var m;let p=C(u);return a({status:"error",error:p}),(m=e==null?void 0:e.onError)==null||m.call(e,p),p},[e==null?void 0:e.onError,a]),d=tt(()=>{o.current=!0},[]);return{linkWithFarcaster:tt((w,...v)=>l(void 0,[w,...v],function*({relyingParty:u,redirectUrl:p},m={pollAttempts:10,pollIntervalMs:1e3}){var h;try{let f=b();if(o.current=!1,!f)throw new ue({code:"attempted_link_farcaster_before_logged_in",error:"Must be logged in to link a Farcaster account."});a({status:"generating-uri"});let{connect_uri:y,channel_token:S}=yield r.auth.farcaster.initializeAuth({relyingParty:u,redirectUrl:Oe.createURL(p!=null?p:"/")});if(!y)throw new ue({code:"failed_to_generate_farcaster_uri",error:"Failed to generate farcaster uri"});if(!S)throw new ue({code:"failed_to_generate_farcaster_channel_token",error:"Failed to generate farcaster channel token"});yield Oe.openURL(y),a({status:"polling-status"});let E=0;for(;E<m.pollAttempts;){if(o.current)throw new ue({code:"farcaster_polling_canceled",error:"Farcaster polling canceled"});if(t.current!=="active"&&n()!=="active"){yield Y(m.pollIntervalMs);continue}let A=yield r.auth.farcaster.getFarcasterStatus({channel_token:S});if(A.state==="completed"){a({status:"submitting-token"});let{user:k}=yield r.auth.farcaster.link(_({channel_token:S},A));return a({status:"done"}),(h=e==null?void 0:e.onSuccess)==null||h.call(e,k),k}E++,yield Y(m.pollIntervalMs)}throw new ue({code:"farcaster_polling_timeout",error:"Farcasting polling timed out"})}catch(f){throw s(f)}}),[r,e==null?void 0:e.onSuccess,s,a]),state:i,cancel:d}};import{useCallback as wr,useContext as An}from"react";var Zl=e=>{let{client:t}=An(g),n=wr(i=>{var o;let a=C(i);return(o=e==null?void 0:e.onError)==null||o.call(e,a),a},[e==null?void 0:e.onError]);return{unlinkFarcaster:wr(a=>l(void 0,[a],function*({fid:i}){var o;try{let{user:s}=yield t.auth.farcaster.unlink({fid:i});return(o=e==null?void 0:e.onSuccess)==null||o.call(e,s),s}catch(s){throw n(s)}}),[t,e==null?void 0:e.onSuccess,n])}};import*as Le from"expo-linking";import{useCallback as nt,useContext as xn,useRef as Pn}from"react";import{PrivyClientError as pe}from"@privy-io/js-sdk-core";var cu=e=>{let{appState:t,getCurrentAppState:n}=Ue(),{client:r,farcasterState:i,setFarcasterState:a}=xn(g),o=Pn(!1),s=nt(u=>{var m;let p=C(u);return a({status:"error",error:p}),(m=e==null?void 0:e.onError)==null||m.call(e,p),p},[e==null?void 0:e.onError,a]),d=nt(()=>{o.current=!0},[]);return{loginWithFarcaster:nt((v,...h)=>l(void 0,[v,...h],function*({relyingParty:u,redirectUrl:p,disableSignup:m},w={pollAttempts:10,pollIntervalMs:1e3}){var f;try{if(o.current=!1,b())throw new pe({code:"attempted_login_with_farcaster_while_already_logged_in",error:"Already logged in, use `useLinkWithFarcaster` if you are trying to link farcaster to an existing account"});a({status:"generating-uri"});let{connect_uri:S,channel_token:E}=yield r.auth.farcaster.initializeAuth({relyingParty:u,redirectUrl:Le.createURL(p!=null?p:"/")});if(!S)throw new pe({code:"failed_to_generate_farcaster_uri",error:"Failed to generate farcaster uri"});if(!E)throw new pe({code:"failed_to_generate_farcaster_channel_token",error:"Failed to generate farcaster channel token"});yield Le.openURL(S),a({status:"polling-status"});let A=0;for(;A<w.pollAttempts;){if(o.current)throw new pe({code:"farcaster_polling_canceled",error:"Farcaster polling canceled"});if(t.current!=="active"&&n()!=="active"){yield Y(w.pollIntervalMs);continue}let k=yield r.auth.farcaster.getFarcasterStatus({channel_token:E});if(k.state==="completed"){a({status:"submitting-token"});let P=x(),V=yield r.auth.farcaster.authenticate(_({channel_token:E,mode:m?"no-signup":"login-or-sign-up"},k),{embedded:P==null?void 0:P.embedded});return a({status:"done"}),(f=e==null?void 0:e.onSuccess)==null||f.call(e,V.user,V.is_new_user),V.user}A++,yield Y(w.pollIntervalMs)}throw new pe({code:"farcaster_polling_timeout",error:"Farcasting polling timed out"})}catch(y){throw s(y)}}),[r,s,e==null?void 0:e.onSuccess,a,t]),state:i,cancel:d}};import{useCallback as vr,useContext as Un}from"react";import{create as Rn}from"zustand";import{PrivyClientError as In}from"@privy-io/js-sdk-core";var it=Rn(()=>({status:"initial"})),K=e=>it.setState(e,!0),Mn=it.getState,wu=()=>{let{client:e}=Un(g),t=it(),n=vr(()=>l(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=C(i);throw K({status:"initial",error:a}),a}}),[e]),r=vr(i=>l(void 0,null,function*(){let a=Mn().status;try{if(b()){let c=new In({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=x(),d=yield e.auth.farcasterV2.authenticate(i,{embedded:s==null?void 0:s.embedded});return K({status:"done"}),setTimeout(()=>K({status:"initial"}),1500),{user:d.user}}catch(o){let s=C(o);throw K({status:a,error:s}),s}}),[e]);return{init:n,login:r,state:t}};import{useContext as On,useMemo as Ln}from"react";import{delegatedActions as Sr}from"@privy-io/js-sdk-core";var _u=()=>{let{client:e}=On(g);return Ln(()=>({delegateWallet:Sr.delegateWallet(e),revokeWallets:Sr.revokeWallets(e)}),[e])};import{useContext as Fn,useMemo as Tn}from"react";import{depositAddress as me}from"@privy-io/js-sdk-core";var Pu=()=>{let{client:e}=Fn(g);return Tn(()=>({getConfig:()=>me.getConfig(e),generateDepositAddress:t=>me.generateDepositAddress(_({privy:e},t)),getDeposit:t=>me.getDeposit(_({privy:e},t)),waitForDeposit:t=>me.waitForDeposit(_({privy:e},t)),waitForCompletion:t=>me.waitForCompletion(_({privy:e},t))}),[e])};import{useContext as Nn,useMemo as Vn}from"react";import{cryptoDepositAccount as Fe}from"@privy-io/js-sdk-core";import{withMfaErrorHandling as Dn}from"@privy-io/js-sdk-core";var D=e=>l(void 0,null,function*(){return Dn({callback:e,onMfaEnrollmentRequired:t=>U()(t),onMfaVerificationRequired:t=>R()(t)})});var Vu=()=>{let{client:e}=Nn(g);return Vn(()=>({createCryptoDepositAccount:t=>D(()=>Fe.createCryptoDepositAccount(e,(...n)=>e.embeddedWallet.signWithUserSigner(...n),t)),getQuote:t=>Fe.getCryptoDepositAccountQuote(e,t),getOrder:t=>Fe.getCryptoDepositAccountOrder(e,t),getNextOrder:t=>Fe.getCryptoDepositAccountNextOrder(e,t)}),[e])};import{useMemo as $n}from"react";import{useContext as zn,useMemo as Gn}from"react";import{addSessionSigners as Kn,getWallet as Bn,isUnifiedWallet as br,removeSessionSigners as Hn,updateWallet as Jn}from"@privy-io/js-sdk-core";import{isEmbeddedWalletAccount as qn}from"@privy-io/js-sdk-core";function jn(e,t){return e.linked_accounts.filter(qn).find(n=>n.address===t)}function at(e){let t=b();if(!t)throw new Error("User must be authenticated to perform this operation");let n=jn(t,e);if(!n)throw new Error(`No wallet found with address ${e}`);return n}var Er=()=>{let{client:e}=zn(g);return Gn(()=>{let t=(n,r)=>l(void 0,null,function*(){yield D(()=>Jn(e,{wallet_id:n},(...a)=>e.embeddedWallet.signWithUserSigner(...a),{additional_signers:r}));let{user:i}=yield e.user.get();if(!i)throw new Error("Could not refresh user");return{user:i}});return{addSigners:i=>l(void 0,[i],function*({address:n,signers:r}){let a=at(n),o=r.map(d=>({signer_id:d.signerId,override_policy_ids:d.policyIds}));if(!br(a)||a.chain_type!=="ethereum"&&a.chain_type!=="solana"||!r.length)return Kn({client:e,wallet:a,signers:o});let s=yield Bn(e,{wallet_id:a.id});return t(a.id,s.additional_signers.concat(o))}),removeSigners:r=>l(void 0,[r],function*({address:n}){let i=at(n);return br(i)?t(i.id,[]):Hn({client:e,wallet:i})})}},[e])};var ep=()=>{let{addSigners:e,removeSigners:t}=Er();return $n(()=>({addSessionSigners:e,removeSessionSigners:t}),[e,t])};import{useContext as Qn,useMemo as Yn}from"react";import{PrivyClientError as _r}from"@privy-io/js-sdk-core";var ap=()=>{let{client:e}=Qn(g);return Yn(()=>({sendCode(r){return l(this,arguments,function*({newEmailAddress:n}){Cr(),yield e.auth.email.sendCode(n)})},updateEmail(i){return l(this,arguments,function*({newEmailAddress:n,code:r}){let{address:a}=Cr(),{user:o}=yield e.auth.email.updateEmail({oldEmailAddress:a,newEmailAddress:n,code:r});return o})}}),[e])};function Cr(){let t=Xn().linked_accounts.find(n=>n.type==="email");if(!t)throw new _r({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 Xn(){let e=b();if(!e)throw new _r({code:"attempted_update_before_logged_in",error:"Must be logged in to update a user profile."});return e}import{useContext as Zn,useMemo as ei}from"react";import{PrivyClientError as Wr}from"@privy-io/js-sdk-core";var mp=()=>{let{client:e}=Zn(g);return ei(()=>({sendCode(r){return l(this,arguments,function*({newPhoneNumber:n}){kr(),yield e.auth.phone.sendCode(n)})},updatePhone(i){return l(this,arguments,function*({newPhoneNumber:n,code:r}){let{phoneNumber:a}=kr(),{user:o}=yield e.auth.phone.updatePhone({oldPhoneNumber:a,newPhoneNumber:n,code:r});return o})}}),[e])};function kr(){let t=ti().linked_accounts.find(n=>n.type==="phone");if(!t)throw new Wr({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 ti(){let e=b();if(!e)throw new Wr({code:"attempted_update_before_logged_in",error:"Must be logged in to update a user profile."});return e}import*as Pr from"expo-linking";import{useCallback as oi,useContext as ni,useMemo as ii}from"react";import{crossApp as ai,PrivyClientError as si}from"@privy-io/js-sdk-core";import*as xr from"expo-linking";import*as fe from"expo-web-browser";import{PrivyClientError as Ar}from"@privy-io/js-sdk-core";var z=(e,t)=>l(void 0,null,function*(){let n=yield fe.openAuthSessionAsync(e,t,{createTask:!1});if(n.type!=="success")throw n.type===fe.WebBrowserResultType.CANCEL||n.type===fe.WebBrowserResultType.DISMISS?new Ar({error:"OAuth session was cancelled",code:"oauth_session_failed"}):new Ar({error:"OAuth session failed",code:"oauth_session_failed"});return ri(n.url)});function ri(e){let{queryParams:t}=xr.parse(e);return t}var kp=()=>{let{client:e}=ni(g),t=ii(()=>ai.loginWithCrossAppAuth({client:e,openAuthSession:z}),[e]);return{loginWithCrossApp:oi(a=>l(void 0,[a],function*({appId:r,redirectUri:i}){if(b())throw new si({code:"attempted_login_with_cross_app_while_already_logged_in",error:"Already logged in, use `linkCrossAppAccount` if you are trying to link a cross app account to an existing account"});let s=x(),{user:d}=yield t({providerAppId:r,redirectUrl:Pr.createURL(i||"/"),loginOptions:{embedded:s==null?void 0:s.embedded}});return{user:d}}),[t])}};import*as Ur 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";var Mp=()=>{let{client:e}=di(g),t=li(()=>ui.linkWithCrossAppAuth({client:e,openAuthSession:z}),[e]);return{linkWithCrossApp:ci(a=>l(void 0,[a],function*({appId:r,redirectUri:i}){if(!b())throw new pi({code:"attempted_link_cross_app_before_logged_in",error:"Must be logged in to link a cross app account, Use `loginWithCrossAppAccount` to login with cross app"});return{user:yield t({providerAppId:r,redirectUrl:Ur.createURL(i||"/")})}}),[t])}};import*as Ir from"expo-linking";import{useContext as mi,useMemo as Rr}from"react";import{crossApp as fi}from"@privy-io/js-sdk-core";var qp=()=>{let{client:e}=mi(g),t=Rr(()=>fi.wallet.signMessage({client:e,openAuthSession:z}),[e]);return Rr(()=>({signMessage:({address:n,message:r,redirectUri:i="/"})=>t({user:b(),address:n,message:r,redirectUrl:Ir.createURL(i)})}),[t])};import*as Or from"expo-linking";import{useContext as yi,useMemo as Mr}from"react";import{crossApp as gi}from"@privy-io/js-sdk-core";var Jp=()=>{let{client:e}=yi(g),t=Mr(()=>gi.wallet.signTypedData({client:e,openAuthSession:z}),[e]);return Mr(()=>({signTypedData:({address:n,typedData:r,redirectUri:i="/"})=>t({user:b(),address:n,typedData:r,redirectUrl:Or.createURL(i)})}),[t])};import*as Fr from"expo-linking";import{useContext as hi,useMemo as Lr}from"react";import{crossApp as wi}from"@privy-io/js-sdk-core";var tm=()=>{let{client:e}=hi(g),t=Lr(()=>wi.wallet.sendTransaction({client:e,openAuthSession:z}),[e]);return Lr(()=>({sendTransaction:({address:n,transaction:r,redirectUri:i="/"})=>t({user:b(),address:n,transaction:r,redirectUrl:Fr.createURL(i)})}),[t])};import{useCallback as vi,useContext as Si}from"react";import{getUserEmbeddedEthereumWallet as bi,getUserEmbeddedSolanaWallet as Ei,isUnifiedWallet as Ci,PrivyClientError as ee,throwIfInvalidRecoveryUpgradePath as _i}from"@privy-io/js-sdk-core";var dm=()=>{let{client:e}=Si(g);return{setRecovery:vi(n=>l(void 0,null,function*(){var s;let r=b(),i=e.app.appId;if(!r)throw new ee({code:"embedded_wallet_recovery_error",error:"User must be loaded before attempting to modify the recovery method."});let a=(s=bi(r))!=null?s:Ei(r);if(!a)throw new ee({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});if(Ci(a))throw new ee({code:"unsupported_wallet_type",error:"Embedded wallet recovery is only supported for on-device execution and this app uses TEE execution. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide"});try{a.chain_type==="ethereum"?yield e.embeddedWallet.getEthereumProvider({wallet:a,entropyId:a.address,entropyIdVerifier:"ethereum-address-verifier"}):a.chain_type==="solana"&&(yield e.embeddedWallet.getSolanaProvider(a,a.address,"solana-address-verifier"))}catch(d){throw new ee({code:"attempted_to_set_password_before_connected",error:"Embedded wallet must be connected before setting password"})}_i({currentRecoveryMethod:a.recovery_method,upgradeToRecoveryMethod:n.recoveryMethod});let o=yield ki({appId:i,client:e,user:r,primaryAccount:a,recoveryParams:n});try{let{user:d}=yield e.embeddedWallet.setRecovery(o);return{user:d}}catch(d){throw new ee({code:"embedded_wallet_set_recovery_error",error:d instanceof Error?d.message:"Error setting password on embedded wallet"})}}),[e])}},ki=a=>l(void 0,[a],function*({appId:e,client:t,user:n,primaryAccount:r,recoveryParams:i}){switch(i.recoveryMethod){case"privy":return{recoveryMethod:"privy",wallet:r};case"user-passcode":return T(_({},i),{wallet:r});case"google-drive":{let o=yield Ie(t);return{recoveryMethod:"google-drive",wallet:r,recoveryAccessToken:o}}case"icloud":{let{recoverySecret:o,iCloudRecordName:s}=yield ce({appId:e,client:t,user:n});return{recoveryMethod:"icloud-native",recoverySecretOverride:o,iCloudRecordNameOverride:s,wallet:r}}case"recovery-encryption-key":return{recoveryMethod:"recovery-encryption-key",wallet:r,recoveryKey:i.recoveryKey};default:throw new ee({code:"embedded_wallet_recovery_error",error:"Unrecognized recovery method"})}});import{useCallback as Wi,useContext as Ai}from"react";import{getUserEmbeddedEthereumWallet as xi,getUserEmbeddedSolanaWallet as Pi,PrivyClientError as ye,isUnifiedWallet as Ui}from"@privy-io/js-sdk-core";var wm=()=>{let{client:e}=Ai(g);return{recover:Wi(n=>l(void 0,null,function*(){var c;let r=b();if(!r)throw new ye({code:"embedded_wallet_recovery_error",error:"User must be loaded before attempting to modify the recovery method."});let i=(c=xi(r))!=null?c:Pi(r);if(!i)throw new ye({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});if(Ui(i))throw new ye({code:"unsupported_wallet_type",error:"User owned wallet recovery is only supported for on-device execution and this app uses TEE execution. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide"});let a,o,s,d;switch(n.recoveryMethod){case"user-passcode":o=n.password;break;case"google-drive":s=yield Ie(e);break;case"icloud":let{recoverySecret:u}=yield Pe({client:e,walletAddress:i.address,chainType:i.chain_type});d=u;break;case"recovery-encryption-key":a=n.recoveryKey;break;case"privy":break;default:throw new ye({code:"unsupported_recovery_method",error:`Unsupported recovery options ${n}`})}try{i.chain_type==="ethereum"?yield e.embeddedWallet.getProvider(i,o,s,d,a):i.chain_type==="solana"&&(yield e.embeddedWallet.getSolanaProvider(i,i.address,"solana-address-verifier",o,s,d))}catch(u){throw new ye({code:"attempted_to_set_password_before_connected",error:"Embedded wallet must be connected before setting password"})}}),[e])}};import{useEffect as Ii}from"react";import{useContext as Ri,useEffect as st}from"react";var ct=(e={})=>{let{wallet:t,createWalletCallbacks:n,recoverWalletCallbacks:r,setWalletRecoveryCallbacks:i}=Ri(g),{onCreateWalletSuccess:a,onCreateWalletError:o,onRecoverWalletError:s,onRecoverWalletSuccess:d,onSetWalletRecoverySuccess:c,onSetWalletRecoveryError:u}=e;return st(()=>{n.current={onSuccess:a,onError:o}},[a,o]),st(()=>{r.current={onSuccess:d,onError:s}},[d,s]),st(()=>{i.current={onSuccess:c,onError:u}},[d,s]),t};var Wm=({onStateChange:e})=>{let t=ct();return Ii(()=>{e(t)},[t])};import{useContext as Mi}from"react";var Um=()=>{let{getIdentityToken:e}=Mi(g);return{getIdentityToken:e}};import{useCallback as Tr,useContext as Oi}from"react";import{PrivyClientError as Li}from"@privy-io/js-sdk-core";var Dm=e=>{let{client:t}=Oi(g),n=Tr(i=>{var o;let a=C(i);return(o=e==null?void 0:e.onError)==null||o.call(e,a),a},[e==null?void 0:e.onError]);return{create:Tr(()=>l(void 0,null,function*(){var i;try{if(b())throw new Li({code:"attempted_to_create_guest_account_for_logged_in_user",error:"Already logged in, you cannot create a guest account"});let o=x(),s=yield t.auth.guest.create({embedded:o==null?void 0:o.embedded});return(i=e==null?void 0:e.onSuccess)==null||i.call(e,s.user,s.is_new_user),s.user}catch(a){throw n(a)}}),[t,n,e==null?void 0:e.onSuccess])}};import{useContext as Fi,useEffect as Dr,useRef as Ti}from"react";var Gm=({onMfaRequired:e,onMfaEnrollmentRequired:t,onMfaVerificationRequired:n})=>{let{client:r}=Fi(g),i=Ti(Symbol("mfa-listener")).current;Dr(()=>{let a=[],o=()=>a.forEach(s=>s());try{t&&a.push(Rt({fn:t,lock:i})),n&&a.push(It({fn:n,lock:i}))}catch(s){throw o(),s}return o},[i,t,n]),Dr(()=>{if(!e)return;let a=()=>l(void 0,null,function*(){var s;let o=b();yield e((s=o==null?void 0:o.mfa_methods.map(({type:d})=>d).filter(d=>d!=="email"))!=null?s:[])});return r.mfaPromises.on("mfaRequired",a),()=>{r.mfaPromises.off("mfaRequired",a)}},[r,e])};import{useCallback as ge,useContext as Gi}from"react";import{PrivyClientError as De}from"@privy-io/js-sdk-core";import{PrivyClientError as Di}from"@privy-io/js-sdk-core";function Te(){return l(this,null,function*(){xe("react-native-passkeys");try{return yield import("react-native-passkeys")}catch(e){return Promise.reject(e)}})}var Ni=(e,t)=>l(void 0,null,function*(){var i;let r=yield(yield Te()).create(Vi(e,t));if(!r)throw new Di({code:"failed_to_create_passkey",error:"Could not create passkey"});return T(_({},r),{type:(i=r.type)!=null?i:"public-key",clientExtensionResults:{}})});function Vi(e,t){return T(_({},t),{rp:e.rp,user:e.user,challenge:e.challenge,pubKeyCredParams:e.pubKeyCredParams,excludeCredentials:e.excludeCredentials,authenticatorSelection:e.authenticatorSelection,timeout:12e4,attestation:void 0})}import{PrivyClientError as qi}from"@privy-io/js-sdk-core";var lt=(e,t)=>l(void 0,null,function*(){var i;let r=yield(yield Te()).get(ji(e,t));if(!r)throw new qi({code:"no_passkey_found_for_challenge",error:"Could not find a matching passkey to login with"});return T(_({},r),{type:(i=r.type)!=null?i:"public-key",clientExtensionResults:{}})});function ji(e,t){return T(_({},t),{rpId:e.rpId,challenge:e.challenge,allowCredentials:e.allowCredentials,userVerification:e.userVerification,timeout:12e4})}function Nr(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 Vr(e){var t,n,r,i;return{challenge:e.challenge,rpId:e.rp_id,extensions:{appid:(t=e.extensions)==null?void 0:t.app_id,credProps:(n=e.extensions)==null?void 0:n.cred_props,hmacCreateSecret:(r=e.extensions)==null?void 0:r.hmac_create_secret},timeout:e.timeout,allowCredentials:(i=e.allow_credentials)==null?void 0:i.map(({id:a,type:o,transports:s})=>({id:a,type:o,transports:s})),userVerification:e.user_verification}}function lf(e){var t,n,r,i,a,o,s,d;return{rp:e.rp,user:{id:e.user.id,name:e.user.name,displayName:e.user.display_name},challenge:e.challenge,pubKeyCredParams:e.pub_key_cred_params,extensions:{hmacCreateSecret:(t=e.extensions)==null?void 0:t.hmac_create_secret,credProps:(r=(n=e.extensions)==null?void 0:n.cred_props)==null?void 0:r.rk,appid:(i=e.extensions)==null?void 0:i.app_id},attestation:e.attestation,excludeCredentials:e.exclude_credentials,authenticatorSelection:{authenticatorAttachment:(a=e.authenticator_selection)==null?void 0:a.authenticator_attachment,residentKey:(o=e.authenticator_selection)==null?void 0:o.resident_key,userVerification:(s=e.authenticator_selection)==null?void 0:s.user_verification,requireResidentKey:(d=e.authenticator_selection)==null?void 0:d.require_resident_key}}}function gf(){let{client:e}=Gi(g),t=ge(o=>l(this,null,function*(){var s,d;switch(o.method){case"sms":yield e.mfa.sms.sendCode({action:"verify"});return;case"passkey":let{options:c}=yield e.mfa.passkey.generateAuthenticationOptions({relying_party:o.relyingParty||((d=(s=x())==null?void 0:s.mfa)==null?void 0:d.relyingParty)});return Vr(c);case"totp":return;default:throw new Error(`Unsupported MFA method: ${o.mfaMethod}`)}}),[e]),n=ge(o=>l(this,null,function*(){var s,d,c,u,p,m,w;switch(o.method){case"totp":case"sms":if(typeof o.mfaCode!="string")throw new De({code:"invalid_mfa_code",error:"Invalid MFA code"});(c=e.mfaPromises.rootPromise.current)==null||c.resolve({mfaMethod:o.method,mfaCode:o.mfaCode,relyingParty:o.relyingParty||((d=(s=x())==null?void 0:s.mfa)==null?void 0:d.relyingParty)||""}),yield new Promise((y,S)=>{e.mfaPromises.submitPromise.current={resolve:y,reject:S}});break;case"passkey":if(typeof o.mfaCode=="string")throw new De({code:"invalid_passkey_response",error:"Invalid authenticator response"});let v=yield lt(o.mfaCode),h=Nr(v);(m=e.mfaPromises.rootPromise.current)==null||m.resolve({mfaMethod:o.method,relyingParty:o.relyingParty||((p=(u=x())==null?void 0:u.mfa)==null?void 0:p.relyingParty)||"",mfaCode:h}),yield new Promise((y,S)=>{e.mfaPromises.submitPromise.current={resolve:y,reject:S}});break;default:let f=new De({code:"unsupported_mfa_method",error:"Unsupported MFA method"});throw(w=e.mfaPromises.rootPromise.current)==null||w.reject(f),f}}),[e]),r=ge(()=>l(this,null,function*(){let o=b();!o||o.mfa_methods.length===0||(yield e.mfa.verifyMfa())}),[e]),i=ge(()=>{var o;(o=e.mfaPromises.rootPromise.current)==null||o.reject(new De({code:"mfa_canceled",error:"MFA canceled"}))},[e]),a=ge(()=>l(this,null,function*(){let o=b();o&&(yield e.mfa.clearMfa({userId:o.id}))}),[e]);return{init:t,submit:n,prompt:r,cancel:i,clear:a}}import{useCallback as ut,useContext as Ki}from"react";function bf(){let{client:e}=Ki(g),t=ut(i=>l(this,null,function*(){switch(i.method){case"sms":case"totp":return yield e.mfa.initEnrollMfa(i);case"passkey":return;default:throw new Error(`Unsupported MFA method: ${i.method}`)}}),[e]),n=ut(i=>l(this,null,function*(){switch(i.method){case"sms":case"totp":case"passkey":yield e.mfa.submitEnrollMfa(i);return;default:throw new Error(`Unsupported MFA method: ${i.method}`)}}),[e]),r=ut(i=>l(this,null,function*(){switch(i.method){case"sms":case"totp":yield e.mfa.unenrollMfa(i.method);return;case"passkey":yield e.mfa.submitEnrollMfa({method:"passkey",credentialIds:[],removeForLogin:i.removeForLogin});return;default:throw new Error(`Unsupported MFA method: ${i.method}`)}}),[e]);return{initMfaEnrollment:t,submitMfaEnrollment:n,unenrollMfa:r}}import{useCallback as Bi,useContext as Hi}from"react";function Wf(){let{client:e}=Hi(g);return{unlink:Bi(i=>l(this,[i],function*({credentialId:n,removeAsMfa:r}){yield e.mfa.unlinkPasskey({credentialId:n,removeAsMfa:r})}),[e])}}import{useCallback as Ji}from"react";import{areAddressesEqual as $i}from"@privy-io/are-addresses-equal";import{getAllUserEmbeddedEthereumWallets as Qi,getAllUserEmbeddedSolanaWallets as Yi,PrivyClientError as Xi}from"@privy-io/js-sdk-core";var Mf=()=>{let e=W();return{importWallet:Ji(a=>l(void 0,[a],function*({privateKey:n,chainType:r,additionalSigners:i}){let{address:o,user:s}=yield e.embeddedWallet.importWallet({privateKey:n,chainType:r,additionalSigners:i}),c=(r==="solana"?Yi(s.user):Qi(s.user)).find(u=>$i(u.address,o));if(!c)throw new Xi({code:"embedded_wallet_creation_error",error:"Failed to import wallet"});return{user:s.user,wallet:c}}),[e])}};import{useCallback as Zi,useMemo as qr}from"react";import{getAllUserEmbeddedEthereumWallets as pt,getEntropyDetailsFromUser as jr,getUserEmbeddedSolanaWallet as ea,PrivyClientError as mt}from"@privy-io/js-sdk-core";var ft=()=>{let e=I(),t=W(),n=qr(()=>{let a=pt(e).map(o=>{let s=jr(e,o);return s?{account:o,entropy:s}:null});return a.some(o=>o===null)?[]:a.filter(o=>o!==null).map(({account:o,entropy:{entropyId:s,entropyIdVerifier:d}})=>({address:o.address,walletIndex:o.wallet_index,chainType:o.chain_type,getProvider:()=>t.embeddedWallet.getEthereumProvider({wallet:o,entropyId:s,entropyIdVerifier:d,onMfaEnrollmentRequired:c=>l(void 0,null,function*(){return yield U()(c)}),onMfaVerificationRequired:c=>l(void 0,null,function*(){return yield R()(c)}),onNeedsRecovery:c=>l(void 0,null,function*(){var u;yield(u=Ce())==null?void 0:u(c)})})}))},[t,e]),r=Zi((...a)=>l(void 0,[...a],function*({createAdditional:i=!1}={}){var p,m,w;let{user:o}=yield t.user.get(),s=pt(o);if(!i&&s.length>0)throw new mt({code:"embedded_wallet_creation_error",error:"Wallet already exists for this user. Set `createAdditional` to `true` to create another wallet"});if(s.length===0){let v=(p=ea(o))!=null?p:void 0,h=yield t.embeddedWallet.create(v?{solanaAccount:v}:{});return ta(h.user),{user:h.user}}let d=jr(o),c=s.map(v=>v.wallet_index).reduce((v,h)=>Math.max(v,h),0)+1,u=yield t.embeddedWallet.add({chainType:"ethereum",hdWalletIndex:c,entropyId:(m=d==null?void 0:d.entropyId)!=null?m:"",entropyIdVerifier:(w=d==null?void 0:d.entropyIdVerifier)!=null?w:"ethereum-address-verifier"});if(!u.account||u.account.chain_type!=="ethereum")throw new mt({code:"embedded_wallet_creation_error",error:"Unknown error creating wallet"});return{user:u.user}}),[t]);return qr(()=>({wallets:n,create:r}),[n,r])};function ta(e){if(!e||pt(e).length===0)throw new mt({code:"embedded_wallet_creation_error",error:"Unknown error creating wallet"})}import{useContext as ra,useEffect as zr}from"react";var oa=(e={})=>{let{solanaWallet:t,createSolanaWalletCallbacks:n,recoverSolanaWalletCallbacks:r}=ra(g),{onCreateWalletSuccess:i,onCreateWalletError:a,onRecoverWalletError:o,onRecoverWalletSuccess:s}=e;return zr(()=>{n.current={onSuccess:i,onError:a}},[i,a]),zr(()=>{r.current={onSuccess:s,onError:o}},[s,o]),t};import{useCallback as na,useMemo as ia}from"react";import{getAllUserEmbeddedBitcoinWallets as Gr,getEntropyDetailsFromUser as Kr,isUnifiedWallet as aa,PrivyClientError as te}from"@privy-io/js-sdk-core";var sa=()=>{let e=I(),t=W(),n=ia(()=>{let i=Kr(e);if(!i)return[];let a=Gr(e),{entropyId:o,entropyIdVerifier:s}=i;return a.map(d=>({address:d.address,walletIndex:d.wallet_index,publicKey:d.public_key,chainType:d.chain_type,getProvider:()=>aa(d)?Promise.reject(new te({code:"unsupported_wallet_type",error:"Bitcoin wallet providers are only supported for on-device execution and this app uses TEE execution. Use the useSignRawHash hook from @privy-io/expo/extended-chains to sign over a hash with this wallet. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide"})):t.embeddedWallet.getBitcoinProvider({wallet:d,entropyId:o,entropyIdVerifier:s})}))},[t,e]),r=na(o=>l(void 0,[o],function*({chainType:i,createAdditional:a=!1}){var f;let s=t.app.getConfig();if(((f=s==null?void 0:s.embedded_wallet_config)==null?void 0:f.mode)==="user-controlled-server-wallets-only")throw i==="bitcoin-segwit"?new te({code:"unsupported_wallet_type",error:"This app uses TEE execution. Use the useCreateWallet hook from @privy-io/expo/extended-chains to create the wallet instead. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide"}):new te({code:"unsupported_wallet_type",error:`Bitcoin (${i}) wallets are only supported for on-device execution and this app uses TEE execution. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide`});let{user:d}=yield t.user.get(),c=Kr(d);if(!c)throw new te({code:"embedded_wallet_creation_error",error:"No existing wallet for this user, create an Ethereum walet first to add a Bitcoin wallet"});let{entropyId:u,entropyIdVerifier:p}=c,m=Gr(d).filter(y=>y.chain_type===i);if(!a&&m.length>0)throw new te({code:"embedded_wallet_creation_error",error:"Wallet already exists for this user. Set `createAdditional` to `true` to create another wallet"});let w=m.length===0?0:Math.max(...m.map(y=>y.wallet_index),0)+1,v=yield t.embeddedWallet.add({chainType:i,hdWalletIndex:w,entropyId:u,entropyIdVerifier:p}),h=v.account;if(!v.user||!h||h.chain_type!=="bitcoin-segwit"&&h.chain_type!=="bitcoin-taproot"||h.chain_type!==i)throw new te({code:"embedded_wallet_creation_error",error:"Unknown error creating wallet"});return{user:v.user,provider:yield t.embeddedWallet.getBitcoinProvider({wallet:T(_({},h),{chain_type:h.chain_type}),entropyId:u,entropyIdVerifier:p})}}),[t]);return{wallets:n,create:r}};import{useContext as ca}from"react";var yt=()=>{let{isReady:e,logout:t,getAccessToken:n,error:r,client:i}=ca(g);return{user:I(),isReady:e,error:r,logout:t,getAccessToken:n,refreshUser:()=>i.user.refreshUser()}};import{useContext as da}from"react";function la(){let{client:e}=da(g);return{acceptTerms:()=>l(this,null,function*(){return e.user.acceptTerms()})}}import{useMemo as ua}from"react";import{generateAuthorizationSignature as pa}from"@privy-io/js-sdk-core";var ma=()=>{let e=W();return ua(()=>({generateAuthorizationSignature(n){return l(this,null,function*(){let{signature:r}=yield pa((...i)=>e.embeddedWallet.signWithUserSigner(...i),n);return{signature:r}})}}),[e])};import{useContext as fa,useMemo as ya}from"react";import{GetEncryptedAuthorizationKey as ga}from"@privy-io/routes";var fy=()=>{let{client:e}=fa(g);return ya(()=>({getEncryptedAuthorizationKey:({id:t})=>e.fetchPrivyRoute(ga,{params:{encrypted_authorization_key_id:t}})}),[e])};import{useCallback as ha}from"react";import{createWalletClient as wa,getAddress as Br,http as va,parseSignature as Sa,zeroAddress as ba}from"viem";import{hashAuthorization as Ea}from"viem/utils";import{getAllUserEmbeddedEthereumWallets as Ca,getJsonRpcEndpointFromChain as _a}from"@privy-io/js-sdk-core";var ka=()=>{let e=I(),{wallets:t}=ft(),n=W();return{signAuthorization:ha((i,a)=>l(void 0,null,function*(){var p,m,w;if(!e)throw new Error("User must be authenticated before signing with a Privy wallet");let o=(w=(m=a==null?void 0:a.address)!=null?m:(p=Ca(e)[0])==null?void 0:p.address)!=null?w:ba,s=t.find(v=>Br(v.address)===Br(o));if(!s)throw new Error("Signing wallet not found.");let d;if(i.chainId===0){if(i.nonce===void 0)throw new Error("nonce is required when chainId is 0 \u2014 chain-agnostic authorizations are replayable across networks");d={chainId:0,address:i.contractAddress,nonce:i.nonce}}else{let h=n.embeddedWallet.chains.find(S=>S.id===i.chainId);if(!h)throw new Error("Error, chain not configured in PrivyProvider config");let f=_a(h,{},n.app.appId);d=yield wa({account:o,chain:h,transport:va(f)}).prepareAuthorization(_({},i))}let u=yield(yield s.getProvider()).request({method:"secp256k1_sign",params:[Ea(d)]});return _(_({},d),Sa(u))}),[t,e,n])}};import{useMemo as Wa}from"react";import{transfer as Aa}from"@privy-io/js-sdk-core";var xa=()=>{let e=W();return Wa(()=>({transfer:(t,n)=>D(()=>Aa(e,(...r)=>e.embeddedWallet.signWithUserSigner(...r),_({wallet_id:t},n)))}),[e])};import{useMemo as Pa}from"react";import{swap as Ua}from"@privy-io/js-sdk-core";var Ra=()=>{let e=W();return Pa(()=>({swap:(t,n)=>D(()=>Ua(e,(...r)=>e.embeddedWallet.signWithUserSigner(...r),_({wallet_id:t},n)))}),[e])};import{useMemo as Ia}from"react";import{earnDeposit as Ma,earnWithdraw as Oa}from"@privy-io/js-sdk-core";var La=()=>{let e=W();return Ia(()=>({deposit:(t,n)=>D(()=>Ma(e,(...r)=>e.embeddedWallet.signWithUserSigner(...r),_({wallet_id:t},n))),withdraw:(t,n)=>D(()=>Oa(e,(...r)=>e.embeddedWallet.signWithUserSigner(...r),_({wallet_id:t},n)))}),[e])};import{useMemo as Fa}from"react";import{PrivyClientError as Ta,updateWallet as Da}from"@privy-io/js-sdk-core";var Na=()=>{let e=W();return Fa(()=>({updateWallet:(t,n)=>l(void 0,null,function*(){yield D(()=>Da(e,{wallet_id:t},(...a)=>e.embeddedWallet.signWithUserSigner(...a),n));let{user:r}=yield e.user.refreshUser(),i=r==null?void 0:r.linked_accounts.find(a=>a.type==="wallet"&&"id"in a&&a.id===t);if(!i)throw new Ta({code:"embedded_wallet_does_not_exist",error:"Updated wallet was not found in the refreshed user."});return{wallet:i}})}),[e])};import{useMemo as Va}from"react";import{getWalletAction as qa,listWalletActions as ja}from"@privy-io/js-sdk-core";var za=()=>{let e=W();return Va(()=>({getAction:(t,n)=>qa(e,{wallet_id:t,action_id:n}),listActions:(t,n)=>ja(e,_({wallet_id:t},n))}),[e])};import{useMemo as Ga}from"react";var Ka=()=>{let e=Ot();return Ga(()=>({users:e}),[e])};import{useMemo as Ba}from"react";var Ha=()=>{let e=W();return Ba(()=>({switchUser:n=>l(void 0,[n],function*({userId:t}){return yield e.user.switchActiveUser({userId:t})})}),[e])};import{useCallback as Xa}from"react";import{PrivyClientError as Za}from"@privy-io/js-sdk-core";import{getAllUserEmbeddedBitcoinWallets as Ja,getUserEmbeddedEthereumWallet as $a,getUserEmbeddedSolanaWallet as Qa,isEmbeddedWalletAccount as Ya,isUnifiedWallet as Hr}from"@privy-io/js-sdk-core";function Jr(e,t){return l(this,null,function*(){var i,a;let n=t.linked_accounts.filter(Ya).filter(o=>!o.imported&&!Hr(o)).filter(o=>o.chain_type==="ethereum"||o.chain_type==="solana"),r=(i=n.find(o=>o.chain_type==="ethereum"&&o.wallet_index===0))!=null?i:n.find(o=>o.chain_type==="solana"&&o.wallet_index===0);if(!r){let o=(a=$a(t))!=null?a:Qa(t);if(o!=null&&o.imported&&!Hr(o))throw new Error("Imported wallets cannot be migrated");return{success:!0,migrated:!1}}if(Ja(t).length>0)throw new Error("Bitcoin wallets cannot be migrated");return r.chain_type==="ethereum"?yield e.embeddedWallet.getProvider(r):r.chain_type==="solana"&&(yield e.embeddedWallet.getSolanaProvider(r,r.address,"solana-address-verifier")),yield e.embeddedWallet.delegateWallets({rootWallet:{address:r.address,chainType:r.chain_type,imported:r.imported},delegatedWallets:n.map(o=>({address:o.address,chainType:o.chain_type,walletIndex:o.wallet_index}))}),yield e.user.get(),{success:!0,migrated:!0}})}var $r=()=>{let e=W();return{migrate:Xa(()=>l(void 0,null,function*(){var a;let n=b(),r=e.app.getConfig();if(((a=r==null?void 0:r.embedded_wallet_config)==null?void 0:a.mode)!=="user-controlled-server-wallets-only")return{success:!0};if(!n)throw new Za({code:"embedded_wallet_before_logged_in",error:"User must be authenticated before migrating wallets"});return Jr(e,n)}),[e])}};var Qr=({disabled:e})=>{let{migrate:t}=$r(),{user:n}=yt(),r=ts(!1);return es(()=>{e||n&&(r.current||(r.current=!0,t().then(i=>{i.migrated&&!r.current&&(console.info("Migrated wallets for user"),r.current=!0)}).catch(i=>{console.debug("Unable to migrate wallets: ",i)}).finally(()=>{r.current=!1})))},[t,n,e]),null};var g=os(null),oe;function Fh(e){return oe?oe.getAccessToken():e!=null&&e.strict?Promise.reject(new Zr({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 Th=e=>{var vt,St,bt;as();let[t,n]=N(Xr.currentState==="active");Yr(()=>{let F=Xr.addEventListener("change",so=>{n(so==="active")});return()=>{F.remove()}},[]),Yr(()=>xt(e.config),[e.config]);let[r,i]=N(!1),[a,o]=N(null),[s,d]=N(!1),[c,u]=N({status:"disconnected",account:null}),[p,m]=N({status:"disconnected"}),[w,v]=N({status:"initial"}),[h,f]=N({status:"initial"}),[y,S]=N({status:"initial"}),[E,A]=N({status:"initial"}),[k,P]=N({status:"initial"}),[V,we]=N({status:"initial"}),[ve,Ve]=N({status:"initial"}),ne=he({}),qe=he({}),je=he({}),ht=he({}),wt=he({}),Se=Ne(F=>{if(F){Ge(F),o(null);return}Ge(null),v({status:"initial"}),f({status:"initial"}),u({status:"disconnected",account:null})},[]),L=rs(()=>{let F=e.storage||Ee;return e.client?oe=e.client:oe=At({appId:e.appId,clientId:e.clientId,supportedChains:e.supportedChains,storage:F,baseUrl:e.baseUrl,logLevel:e.logLevel}),oe.setCallbacks({setUser:Se,setIsReady:d,setStoredUsers:Mt}),oe},[e.client,e.storage,e.appId,e.clientId,e.baseUrl,e.supportedChains,e.logLevel,Se]),eo=Ne(()=>l(void 0,null,function*(){let F=b();yield L.auth.logout(F?{userId:F==null?void 0:F.id}:void 0),Se(null)}),[Se,L]),to=Ne(()=>l(void 0,null,function*(){try{return yield L.getAccessToken()}catch(F){return console.debug(F),null}}),[L]),ro=Ne(()=>L.getIdentityToken(),[L]);Kt({client:L,setIsUserInitialized:i,setError:o});let oo=ar({client:L,appId:e.appId,createWalletCallbacks:ne,recoverWalletCallbacks:qe,setWalletRecoveryCallbacks:je,setRecoveryFlowState:S,wallet:c,setWallet:u}),no=Yt({client:L,createSolanaWalletCallbacks:ht,recoverSolanaWalletCallbacks:wt,setSolanaRecoveryFlowState:A,solanaWallet:p,setSolanaWallet:m});dr({client:L,createWalletCallbacks:ne,recoverWalletCallbacks:qe,setWalletRecoveryCallbacks:je,recoveryFlowState:y,oAuthState:h,setRecoveryFlowState:S,setWallet:u,appStateVisible:t});let{customAuthStateIsSettled:io}=cr({client:L,isReady:r}),ao=G();return re.createElement(re.Fragment,null,re.createElement(g.Provider,{value:{client:L,isReady:ao&&r&&io,error:a,logout:eo,getAccessToken:to,getIdentityToken:ro,wallet:_(_({},c),oo),solanaWallet:_(_({},p),no),oAuthState:h,recoveryFlowState:y,setRecoveryFlowState:S,solanaRecoveryFlowState:E,setSolanaRecoveryFlowState:A,createWalletCallbacks:ne,recoverWalletCallbacks:qe,setWalletRecoveryCallbacks:je,createSolanaWalletCallbacks:ht,recoverSolanaWalletCallbacks:wt,setOAuthState:f,siweState:k,setSiweState:P,otpState:w,setOtpState:v,passkeyState:V,setPasskeyState:we,farcasterState:ve,setFarcasterState:Ve}},e.children,re.createElement(Qr,{disabled:(bt=(St=(vt=e.config)==null?void 0:vt.embedded)==null?void 0:St.disableAutomaticMigration)!=null?bt:!1})),re.createElement(is,{style:{width:0,height:0,overflow:"hidden"}},re.createElement(Dt,{client:L,isClientReady:s})))},as=()=>{if(ns(g))throw new Zr({code:"configuration_error",error:"Found multiple instances of PrivyProvider, ensure there is only one mounted in your application tree."})};var Kh=e=>{let{client:t,setSiweState:n,siweState:r}=ss(g),i=gt(s=>{var c;let d=C(s);return n({status:"error",error:d}),(c=e==null?void 0:e.onError)==null||c.call(e,d),d},[e==null?void 0:e.onError]),a=gt(u=>l(void 0,[u],function*({wallet:s,from:{domain:d,uri:c}}){var p;try{n({status:"generating-message"});let m=yield t.auth.siwe.init(s,d,c);return n({status:"awaiting-signature"}),(p=e==null?void 0:e.onGenerateMessage)==null||p.call(e,m.message),m.message}catch(m){throw i(m)}}),[t,i,e==null?void 0:e.onGenerateMessage]),o=gt(c=>l(void 0,[c],function*({signature:s,messageOverride:d}){var u;try{if(!b())throw new cs({code:"attempted_link_siwe_before_logged_in",error:"Must be logged in to link a wallet, Use `useLoginWithSiwe` to login with a wallet"});n({status:"submitting-signature"});let{user:m}=yield t.auth.siwe.linkWithSiwe(s,void 0,d);return n({status:"done"}),(u=e==null?void 0:e.onSuccess)==null||u.call(e,m),m}catch(p){throw i(p)}}),[t,i,e==null?void 0:e.onSuccess]);return{generateSiweMessage:a,linkWithSiwe:o,state:r}};export{x as a,U as b,R as c,b as d,Ws as e,I as f,As as g,C as h,uo as i,xe as j,Y as k,At as l,Kh as m,kd as n,W as o,Fd as p,Kd as q,Zd as r,sl as s,ml as t,El as u,Ul as v,Nl as w,Hl as x,Zl as y,cu as z,wu as A,_u as B,Pu as C,D,Vu as E,Er as F,ep as G,ap as H,mp as I,kp as J,Mp as K,qp as L,Jp as M,tm as N,dm as O,wm as P,ct as Q,Wm as R,Um as S,Dm as T,Gm as U,Ni as V,lt as W,lf as X,gf as Y,bf as Z,Wf as _,Mf as $,ft as aa,oa as ba,sa as ca,yt as da,la as ea,ma as fa,fy as ga,ka as ha,xa as ia,Ra as ja,La as ka,Na as la,za as ma,Ka as na,Ha as oa,$r as pa,g as qa,Fh as ra,Th as sa};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as R,d as N,h as B,j as T,
|
|
1
|
+
import{a as R,d as N,h as B,j as T,qa as D}from"./chunk-SNODJ7VS.js";import{b as E,c as P,d as F,e as l}from"./chunk-C5WYSLQF.js";import*as O from"expo-linking";import{useCallback as q,useContext as tt,useEffect as et,useRef as it}from"react";import{Platform as ot}from"react-native";import{PrivyClientError as W}from"@privy-io/js-sdk-core";import{PrivyClientError as X}from"@privy-io/js-sdk-core";import{PrivyClientError as K}from"@privy-io/js-sdk-core";function M(){return l(this,null,function*(){T("expo-apple-authentication");try{return yield import("expo-apple-authentication")}catch(t){throw new K({code:"configuration_error",error:"`expo-apple-authentication` is not installed. Install it and rebuild the native app."})}})}function H(u){return l(this,arguments,function*({oauthProviderUrl:t,isLogin:i}){try{let o=yield M();return yield o.signInAsync({state:Y(t),requestedScopes:[o.AppleAuthenticationScope.EMAIL,o.AppleAuthenticationScope.FULL_NAME]})}catch(o){throw o instanceof Error&&"code"in o&&o.code==="ERR_REQUEST_CANCELED"?new X({error:"Apple login was cancelled",code:i?"login_with_oauth_was_cancelled_by_user":"link_with_oauth_was_cancelled_by_user"}):o}})}function Y(t){var u;return(u=new URL(t).searchParams.get("state"))!=null?u:""}import{Platform as Z}from"react-native";function z(t){return Z.select({android:t.replace("x.com","twitter.com"),default:t})}import*as Q from"expo-linking";import*as m from"expo-web-browser";import{PrivyClientError as j}from"@privy-io/js-sdk-core";function V(o){return l(this,arguments,function*({oauthProviderUrl:t,isLogin:i,returnUrl:u}){var a,p;let n=yield m.openAuthSessionAsync(t,u,{createTask:!1});if(n.type===m.WebBrowserResultType.CANCEL||n.type===m.WebBrowserResultType.DISMISS)throw new j({error:"OAuth was cancelled",code:i?"login_with_oauth_was_cancelled_by_user":"link_with_oauth_was_cancelled_by_user"});if(n.type!=="success")throw new j({error:"OAuth session failed",code:i?"failed_to_complete_login_with_oauth":"failed_to_complete_link_with_oauth"});let r=Q.parse(n.url).queryParams;return{authorizationCode:(a=r==null?void 0:r.privy_oauth_code)!=null?a:null,state:(p=r==null?void 0:r.privy_oauth_state)!=null?p:null,resultUrl:n.url}})}var $=(u={})=>{var o=u,{action:t}=o,i=F(o,["action"]);let{oAuthState:n,setOAuthState:r,client:a}=tt(D),p=it(i);return et(()=>{p.current=i},[i]),{start:q(function(Nt){return l(this,arguments,function*({provider:c,redirectUri:d,isLegacyAppleIosBehaviorEnabled:G=!1,disableSignup:J,onAppleOAuthUserInfo:S}){var C,U,L,v;r({status:"loading"});let y=N(),g=t?t==="login":!!!y;try{if(y&&t==="login"&&!a.isMultiUserModeEnabled)throw new W({code:"attempted_login_with_oauth_while_already_logged_in",error:"Already logged in, if trying to link an OAuth account use `useLinkWithOAuth`"});if(!y&&t==="link")throw new W({code:"attempted_link_oauth_before_logged_in",error:"Must be logged in to link an OAuth account, use `useLoginWithOAuth`"});if(__DEV__&&d!=null&&d.includes("://")){let e=d.split("://")[0];console.warn(`redirectUri includes a scheme prefix (${e}://), it should be a path instead, such as '/authenticated'`)}let w=O.createURL(d||"/"),{url:s}=yield a.auth.oauth.generateURL(c,w);c==="twitter"&&(s=z(s));let h,b,A,f,I,k,_;if(ot.OS==="ios"&&c==="apple"&&!G){let e=yield H({oauthProviderUrl:s,isLogin:g});A=e.authorizationCode,f=e.state,_=e,I="raw"}else{let e=yield V({oauthProviderUrl:s,isLogin:g,returnUrl:w});A=e.authorizationCode,f=e.state,k=e.resultUrl}if(!A||!f)throw new W({error:"OAuth invalid credentials",code:g?"login_with_oauth_returned_with_invalid_credentials":"link_with_oauth_returned_with_invalid_credentials"});if(g){let e=R(),x=yield a.auth.oauth.loginWithCode(A,f,c,I,J?"no-signup":"login-or-sign-up",{embedded:e==null?void 0:e.embedded});h=x.user,b=x.is_new_user}else({user:h}=yield a.auth.oauth.linkWithCode(A,f,c,I));return _&&S&&S({fullName:_.fullName,email:_.email}),(U=(C=p.current).onSuccess)==null||U.call(C,h,b),k&&(yield O.openURL(k.split("?")[0])),r({status:"done",isNewUser:b}),h!=null?h:void 0}catch(w){let s=B(w);throw r({status:"error",error:s}),(v=(L=p.current).onError)==null||v.call(L,s),s}})},[a.auth.oauth,t,r]),state:n}};function Pt(t){let{state:i,start:u}=$(P(E({},t),{action:"login"}));return{state:i,login:u}}export{$ as a,Pt as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as u,o as i}from"./chunk-
|
|
1
|
+
import{D as c,d as u,o as i}from"./chunk-SNODJ7VS.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
|
|
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-VZ7MMAEX.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-SNODJ7VS.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};
|
package/dist/esm/passkey.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as K,b as N,c as V,d as D,e as F,f as T,g as M,h as j}from"./chunk-QSWCX5XI.js";import{
|
|
1
|
+
import{a as K,b as N,c as V,d as D,e as F,f as T,g as M,h as j}from"./chunk-QSWCX5XI.js";import{V as _,W as x,X as b,a as w,d as g,h,qa as P}from"./chunk-SNODJ7VS.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,
|
|
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,qa as S}from"./chunk-SNODJ7VS.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};
|