@privy-io/react-auth 2.6.1 → 2.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/cjs/AwaitingEvmToSolBridgingScreen-pmGmvR1q.js +22 -0
  2. package/dist/cjs/abstract-smart-wallets.js +1 -1
  3. package/dist/cjs/farcaster.js +1 -1
  4. package/dist/cjs/getEmbeddedConnectedWallet-CGj_I0cc.js +2 -0
  5. package/dist/cjs/importWallet-Du1BO6qb.js +1 -0
  6. package/dist/cjs/index.js +5 -22
  7. package/dist/cjs/internal-context-D5TgeQk8.js +1 -0
  8. package/dist/cjs/prepareFundingModalData-C2_ED32S.js +1 -0
  9. package/dist/cjs/smart-wallets-CoYci1bf.js +1 -0
  10. package/dist/cjs/smart-wallets.js +1 -1
  11. package/dist/cjs/solana.js +1 -1
  12. package/dist/cjs/ui.js +2 -2
  13. package/dist/cjs/useActiveWallet-CaLK0Ao4.js +1 -0
  14. package/dist/cjs/useFundWallet-92y-LJjK.js +1 -0
  15. package/dist/dts/farcaster.d.mts +1 -1
  16. package/dist/dts/farcaster.d.ts +1 -1
  17. package/dist/dts/index.d.mts +46 -8
  18. package/dist/dts/index.d.ts +46 -8
  19. package/dist/dts/smart-wallets.d.mts +1 -1
  20. package/dist/dts/smart-wallets.d.ts +1 -1
  21. package/dist/dts/solana.d.mts +4 -4
  22. package/dist/dts/solana.d.ts +4 -4
  23. package/dist/dts/{types-cJoXquFV.d.mts → types-CcosPsy6.d.mts} +1 -1
  24. package/dist/dts/{types-cJoXquFV.d.ts → types-CcosPsy6.d.ts} +1 -1
  25. package/dist/dts/ui.d.mts +1 -1
  26. package/dist/dts/ui.d.ts +1 -1
  27. package/dist/dts/{useSolanaWallets-C6q1MrJz.d.mts → useSolanaWallets-BHduxJmW.d.mts} +1 -1
  28. package/dist/dts/{useSolanaWallets-C6q1MrJz.d.ts → useSolanaWallets-BHduxJmW.d.ts} +1 -1
  29. package/dist/esm/AwaitingEvmToSolBridgingScreen-DnBONxHo.mjs +22 -0
  30. package/dist/esm/abstract-smart-wallets.mjs +1 -1
  31. package/dist/esm/farcaster.mjs +1 -1
  32. package/dist/esm/getEmbeddedConnectedWallet-Cyt02rK3.mjs +2 -0
  33. package/dist/esm/importWallet-Bqr-aqzk.mjs +1 -0
  34. package/dist/esm/index.mjs +5 -22
  35. package/dist/esm/internal-context-CL_EG4e1.mjs +1 -0
  36. package/dist/esm/prepareFundingModalData-Bkg2jc5P.mjs +1 -0
  37. package/dist/esm/smart-wallets-KrlR2oLu.mjs +1 -0
  38. package/dist/esm/smart-wallets.mjs +1 -1
  39. package/dist/esm/solana.mjs +1 -1
  40. package/dist/esm/ui.mjs +2 -2
  41. package/dist/esm/useActiveWallet-SKrFBYMY.mjs +1 -0
  42. package/dist/esm/useFundWallet-BvMwnH48.mjs +1 -0
  43. package/package.json +3 -3
  44. package/dist/cjs/getEmbeddedConnectedWallet-DTU4T9TJ.js +0 -1
  45. package/dist/cjs/getPublicClient-hVv5ZSWd.js +0 -1
  46. package/dist/cjs/importWallet-CqIkwxB-.js +0 -1
  47. package/dist/cjs/internal-context-DV3MljLU.js +0 -1
  48. package/dist/cjs/paths-BGBZ-6Nl.js +0 -1
  49. package/dist/cjs/prepareFundingModalData-BCNQSbXb.js +0 -1
  50. package/dist/cjs/smart-wallets-BJE1oUqH.js +0 -1
  51. package/dist/cjs/useActiveWallet-CLPPplpC.js +0 -6
  52. package/dist/cjs/useFundWallet-BLEO3WzQ.js +0 -1
  53. package/dist/cjs/useWallets-Dmyb5a0t.js +0 -1
  54. package/dist/esm/getEmbeddedConnectedWallet-CSSBWE2p.mjs +0 -1
  55. package/dist/esm/getPublicClient-wHgCncHx.mjs +0 -1
  56. package/dist/esm/importWallet-CJLTGjPg.mjs +0 -1
  57. package/dist/esm/internal-context-mSHyF0Gq.mjs +0 -1
  58. package/dist/esm/paths-Q47X90aK.mjs +0 -1
  59. package/dist/esm/prepareFundingModalData-due26ueW.mjs +0 -1
  60. package/dist/esm/smart-wallets-dP5AzE1-.mjs +0 -1
  61. package/dist/esm/useActiveWallet-C8nSK6cE.mjs +0 -6
  62. package/dist/esm/useFundWallet-DR5oafbj.mjs +0 -1
  63. package/dist/esm/useWallets-DTpjk5Rk.mjs +0 -1
@@ -1 +1 @@
1
- import{createAbstractClient as e}from"@abstract-foundation/agw-client";import{hexToNumber as n,createWalletClient as r,custom as a,http as t}from"viem";import{toAccount as i}from"viem/accounts";import{abstractTestnet as s}from"viem/chains";import{r as o,E as c,u as l,ab as d,M as p}from"./useWallets-DTpjk5Rk.mjs";import{u as m}from"./internal-context-mSHyF0Gq.mjs";import{a as E}from"./getPublicClient-wHgCncHx.mjs";import{g as u}from"./getEmbeddedConnectedWallet-CSSBWE2p.mjs";import{c as y}from"./smart-wallets-dP5AzE1-.mjs";import"viem/utils";import"react/jsx-runtime";import"react";import"tinycolor2";import"ofetch";import"permissionless";import"permissionless/accounts";import"permissionless/clients/pimlico";import"viem/account-abstraction";import"@privy-io/js-sdk-core";function g(){let{user:g}=o(),{hideWalletUIs:f,openPrivyModal:I,chains:T,appId:C,rpcConfig:N}=m(),{wallets:D}=c(),{setModalData:_}=l(),h=async(o=s.id)=>{let c=u(D);if(!c)throw Error("No connected wallet found");let l="string"==typeof o?n(o):o;if(![s.id,2741].includes(l))throw Error("Error, only Abstract chains are supported");let d=T.find((e=>e.id===l));if(!d)throw Error("Chain not configured");await c.switchChain(d.id);let p=await c.getEthereumProvider(),m=r({account:c.address,transport:a(p)}),y=i({address:c.address,signMessage:m.signMessage,signTransaction:m.signTransaction,signTypedData:m.signTypedData});return await e({chain:d,transport:t(E(d,N,C)),publicTransport:t(E(d,N,C)),signer:y})};return{signMessage:async({message:e},n)=>{let r=await h(n);return new Promise((async(n,a)=>{let{entropyId:t,entropyIdVerifier:i}=d(g);f.current=!0,_({connectWallet:{entropyId:t,entropyIdVerifier:i,onCompleteNavigateTo:p.EMBEDDED_WALLET_SIGN_REQUEST_SCREEN,onFailure:()=>{}},signMessage:{method:"personal_sign",data:e,confirmAndSign:()=>r.signMessage({message:e}),onSuccess:e=>n(e),onFailure:a,uiOptions:{isCancellable:!0}}}),I(p.EMBEDDED_WALLET_CONNECTING_SCREEN)})).finally((()=>{f.current=!1}))},signTypedData:async(e,n)=>{let r=await h(n);return new Promise((async(n,a)=>{f.current=!0;let{entropyId:t,entropyIdVerifier:i}=d(g);_({connectWallet:{entropyId:t,entropyIdVerifier:i,onCompleteNavigateTo:p.EMBEDDED_WALLET_SIGN_REQUEST_SCREEN,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:e,confirmAndSign:()=>r.signTypedData(e),onSuccess:e=>n(e),onFailure:a,uiOptions:{isCancellable:!0}}}),I(p.EMBEDDED_WALLET_CONNECTING_SCREEN)})).finally((()=>{f.current=!1}))},sendTransaction:async e=>{let n=await h(e.chainId),r=[],a="calls"in e&&void 0!==e.calls;return r=a?[...e.calls]:[e],new Promise((async(t,i)=>{f.current=!0;let{entropyId:s,entropyIdVerifier:o}=d(g);_({connectWallet:{entropyId:s,entropyIdVerifier:o,onCompleteNavigateTo:p.EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN,onFailure:()=>{}},sendTransaction:{transactionRequests:y({calls:r,chain:n.chain,maxPriorityFeePerGas:e.maxPriorityFeePerGas,maxFeePerGas:e.maxFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0}),entropyId:s,entropyIdVerifier:o,transactingWallet:{address:n.account.address,walletIndex:null},signOnly:!1,getIsSponsored:async()=>void 0!==e.paymaster&&void 0!==e.paymasterInput,onConfirm:()=>a?n.sendTransactionBatch(e):n.sendTransaction(e),onSuccess:e=>t(e.hash),onFailure:i,uiOptions:{isCancellable:!0}}}),I(p.EMBEDDED_WALLET_CONNECTING_SCREEN)})).finally((()=>{f.current=!1}))},signTransaction:async e=>{let n=await h(e.chainId),r=[],a="calls"in e&&void 0!==e.calls;return r=a?[...e.calls]:[e],new Promise((async(t,i)=>{f.current=!0;let{entropyId:s,entropyIdVerifier:o}=d(g);_({connectWallet:{entropyId:s,entropyIdVerifier:o,onCompleteNavigateTo:p.EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN,onFailure:()=>{}},sendTransaction:{transactionRequests:y({calls:r,chain:n.chain,maxPriorityFeePerGas:e.maxPriorityFeePerGas,maxFeePerGas:e.maxFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0}),entropyId:s,entropyIdVerifier:o,transactingWallet:{address:n.account.address,walletIndex:null},signOnly:!0,getIsSponsored:async()=>void 0!==e.paymaster&&void 0!==e.paymasterInput,onConfirm:()=>{if(!a)return n.signTransaction(e);throw Error("Batch transactions not supported for signing")},onSuccess:e=>t(e.hash),onFailure:i,uiOptions:{isCancellable:!0}}}),I(p.EMBEDDED_WALLET_CONNECTING_SCREEN)})).finally((()=>{f.current=!1}))}}}export{g as useAbstractSmartWallets};
1
+ import{createAbstractClient as e}from"@abstract-foundation/agw-client";import{hexToNumber as o,createWalletClient as r,custom as n,http as t}from"viem";import{toAccount as i}from"viem/accounts";import{abstractTestnet as a}from"viem/chains";import{a9 as c,aa as s,aw as l,cQ as p,cN as m,cY as d}from"./AwaitingEvmToSolBridgingScreen-DnBONxHo.mjs";import{a8 as u}from"./internal-context-CL_EG4e1.mjs";import{S as h,a as I,g as y}from"./getEmbeddedConnectedWallet-Cyt02rK3.mjs";import{c as g}from"./smart-wallets-KrlR2oLu.mjs";import"react/jsx-runtime";import"@heroicons/react/24/outline/CheckCircleIcon";import"react";import"styled-components";import"tinycolor2";import"@heroicons/react/24/outline/ArrowLeftIcon";import"@heroicons/react/24/outline/ArrowRightIcon";import"@heroicons/react/24/outline/QuestionMarkCircleIcon";import"@heroicons/react/24/outline/XMarkIcon";import"@heroicons/react/24/outline/CheckIcon";import"@heroicons/react/24/outline/Square2StackIcon";import"react-device-detect";import"@heroicons/react/24/outline/WalletIcon";import"zustand";import"@privy-io/js-sdk-core";import"@walletconnect/ethereum-provider";import"viem/utils";import"eventemitter3";import"@heroicons/react/24/outline/UserCircleIcon";import"@heroicons/react/24/outline/EnvelopeIcon";import"@heroicons/react/20/solid/CheckIcon";import"@heroicons/react/24/outline/PhoneIcon";import"@heroicons/react/24/outline/ExclamationTriangleIcon";import"@heroicons/react/24/outline/ExclamationCircleIcon";import"@heroicons/react/24/outline/ArrowTopRightOnSquareIcon";import"@heroicons/react/24/solid/DocumentCheckIcon";import"@heroicons/react/24/solid/XCircleIcon";import"fast-password-entropy";import"secure-password-utilities";import"secure-password-utilities/wordlists";import"@heroicons/react/24/outline/LockClosedIcon";import"@heroicons/react/24/outline/PencilSquareIcon";import"@heroicons/react/24/solid/CheckCircleIcon";import"@heroicons/react/24/outline/ArrowPathIcon";import"@heroicons/react/24/outline/EyeIcon";import"@heroicons/react/24/outline/EyeSlashIcon";import"@heroicons/react/24/outline/KeyIcon";import"@heroicons/react/24/outline/ArrowDownTrayIcon";import"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import"@heroicons/react/24/outline/DocumentDuplicateIcon";import"@heroicons/react/24/solid/LockClosedIcon";import"@heroicons/react/24/outline/ShieldCheckIcon";import"jose";import"qrcode";import"@heroicons/react/24/outline/FingerPrintIcon";import"@heroicons/react/24/outline/ChevronRightIcon";import"@heroicons/react/24/outline/InformationCircleIcon";import"@heroicons/react/24/outline/CreditCardIcon";import"@heroicons/react/24/outline/QrCodeIcon";import"@heroicons/react/24/solid/ArrowsRightLeftIcon";import"@heroicons/react/24/outline/GlobeAltIcon";import"@headlessui/react";import"@heroicons/react/24/outline/ChevronDownIcon";import"ofetch";import"@heroicons/react/24/outline";import"@heroicons/react/24/outline/ClipboardDocumentIcon";import"permissionless";import"permissionless/accounts";import"permissionless/clients/pimlico";import"viem/account-abstraction";function f(){let{user:f}=c(),{hideWalletUIs:w,openPrivyModal:C,chains:v,appId:T,rpcConfig:P}=u(),{wallets:F}=s(),{setModalData:S}=l(),x=async(c=a.id)=>{let s=y(F);if(!s)throw Error("No connected wallet found");let l="string"==typeof c?o(c):c;if(![a.id,2741].includes(l))throw Error("Error, only Abstract chains are supported");let p=v.find((e=>e.id===l));if(!p)throw Error("Chain not configured");await s.switchChain(p.id);let m=await s.getEthereumProvider(),u=r({account:s.address,transport:n(m)}),h=i({address:s.address,signMessage:u.signMessage,signTransaction:u.signTransaction,signTypedData:u.signTypedData});return await e({chain:p,transport:t(d(p,P,T)),publicTransport:t(d(p,P,T)),signer:h})};return{signMessage:async({message:e},o)=>{let r=await x(o);return new Promise((async(o,n)=>{let{entropyId:t,entropyIdVerifier:i}=p(f);w.current=!0,S({connectWallet:{entropyId:t,entropyIdVerifier:i,onCompleteNavigateTo:h,onFailure:()=>{}},signMessage:{method:"personal_sign",data:e,confirmAndSign:()=>r.signMessage({message:e}),onSuccess:e=>o(e),onFailure:n,uiOptions:{isCancellable:!0}}}),C(I)})).finally((()=>{w.current=!1}))},signTypedData:async(e,o)=>{let r=await x(o);return new Promise((async(o,n)=>{w.current=!0;let{entropyId:t,entropyIdVerifier:i}=p(f);S({connectWallet:{entropyId:t,entropyIdVerifier:i,onCompleteNavigateTo:h,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:e,confirmAndSign:()=>r.signTypedData(e),onSuccess:e=>o(e),onFailure:n,uiOptions:{isCancellable:!0}}}),C(I)})).finally((()=>{w.current=!1}))},sendTransaction:async e=>{let o=await x(e.chainId),r=[],n="calls"in e&&void 0!==e.calls;return r=n?[...e.calls]:[e],new Promise((async(t,i)=>{w.current=!0;let{entropyId:a,entropyIdVerifier:c}=p(f);S({connectWallet:{entropyId:a,entropyIdVerifier:c,onCompleteNavigateTo:m,onFailure:()=>{}},sendTransaction:{transactionRequests:g({calls:r,chain:o.chain,maxPriorityFeePerGas:e.maxPriorityFeePerGas,maxFeePerGas:e.maxFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0}),entropyId:a,entropyIdVerifier:c,transactingWallet:{address:o.account.address,walletIndex:null},signOnly:!1,getIsSponsored:async()=>void 0!==e.paymaster&&void 0!==e.paymasterInput,onConfirm:()=>n?o.sendTransactionBatch(e):o.sendTransaction(e),onSuccess:e=>t(e.hash),onFailure:i,uiOptions:{isCancellable:!0}}}),C(I)})).finally((()=>{w.current=!1}))},signTransaction:async e=>{let o=await x(e.chainId),r=[],n="calls"in e&&void 0!==e.calls;return r=n?[...e.calls]:[e],new Promise((async(t,i)=>{w.current=!0;let{entropyId:a,entropyIdVerifier:c}=p(f);S({connectWallet:{entropyId:a,entropyIdVerifier:c,onCompleteNavigateTo:m,onFailure:()=>{}},sendTransaction:{transactionRequests:g({calls:r,chain:o.chain,maxPriorityFeePerGas:e.maxPriorityFeePerGas,maxFeePerGas:e.maxFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0}),entropyId:a,entropyIdVerifier:c,transactingWallet:{address:o.account.address,walletIndex:null},signOnly:!0,getIsSponsored:async()=>void 0!==e.paymaster&&void 0!==e.paymasterInput,onConfirm:()=>{if(!n)return o.signTransaction(e);throw Error("Batch transactions not supported for signing")},onSuccess:e=>t(e.hash),onFailure:i,uiOptions:{isCancellable:!0}}}),C(I)})).finally((()=>{w.current=!1}))}}}export{f as useAbstractSmartWallets};
@@ -1 +1 @@
1
- import{useCallback as t}from"react";import{P as e,f as i,u as s}from"./internal-context-mSHyF0Gq.mjs";import{a6 as a,a7 as n}from"./paths-Q47X90aK.mjs";import"ofetch";class r{async init(){if(!this.api)throw new e("Auth flow has no API instance");let{nonce:t}=await this.api.post(a,{});return{nonce:t}}async authenticate(){if(!this.message||!this.signature||!this.fid)throw new e("Auth flow has no message, signature, or fid");if(!this.api)throw new e("Auth flow has no API instance");try{let t=await this.api.post(n,{message:this.message,signature:this.signature,fid:this.fid});if(!t)throw new e("No response from authentication");return t}catch(t){throw i(t)}}async link(){throw Error("Not implemented")}setAuthData({message:t,signature:e,fid:i}){this.message=t,this.signature=e,this.fid=i}constructor(){this.meta={}}}const o=()=>{let{client:i,setAuthenticated:a,setUser:n}=s();return{initLoginToFrame:t((async()=>{let t=new r;if(!i)throw new e("Must initialize Privy client first.");return i.startAuthFlow(t),await t.init()}),[i]),loginToFrame:t((async({message:t,signature:s})=>{if(!i)throw new e("Must initialize Privy client first.");if(!(i.authFlow instanceof r))throw new e("Must initialize Farcaster frame flow first.");let o=(t=>{let e=t.match(/farcaster:\/\/fid\/(\d+)/);return e&&e[1]?parseInt(e[1],10):null})(t);if(!o)throw new e("Invalid message format; could not parse Farcaster ID.");i.authFlow.setAuthData({message:t,signature:s,fid:o});let{user:h}=await i.authenticate();return h&&(n(h),a(!0)),h}),[i,n,a])}};export{o as useLoginToFrame};
1
+ import{useCallback as t}from"react";import{P as e,am as i,an as a,f as s,a8 as n}from"./internal-context-CL_EG4e1.mjs";import"ofetch";class r{async init(){if(!this.api)throw new e("Auth flow has no API instance");let{nonce:t}=await this.api.post(i,{});return{nonce:t}}async authenticate(){if(!this.message||!this.signature||!this.fid)throw new e("Auth flow has no message, signature, or fid");if(!this.api)throw new e("Auth flow has no API instance");try{let t=await this.api.post(a,{message:this.message,signature:this.signature,fid:this.fid});if(!t)throw new e("No response from authentication");return t}catch(t){throw s(t)}}async link(){throw Error("Not implemented")}setAuthData({message:t,signature:e,fid:i}){this.message=t,this.signature=e,this.fid=i}constructor(){this.meta={}}}const o=()=>{let{client:i,setAuthenticated:a,setUser:s}=n();return{initLoginToFrame:t((async()=>{let t=new r;if(!i)throw new e("Must initialize Privy client first.");return i.startAuthFlow(t),await t.init()}),[i]),loginToFrame:t((async({message:t,signature:n})=>{if(!i)throw new e("Must initialize Privy client first.");if(!(i.authFlow instanceof r))throw new e("Must initialize Farcaster frame flow first.");let o=(t=>{let e=t.match(/farcaster:\/\/fid\/(\d+)/);return e&&e[1]?parseInt(e[1],10):null})(t);if(!o)throw new e("Invalid message format; could not parse Farcaster ID.");i.authFlow.setAuthData({message:t,signature:n,fid:o});let{user:h}=await i.authenticate();return h&&(s(h),a(!0)),h}),[i,s,a])}};export{o as useLoginToFrame};
@@ -0,0 +1,2 @@
1
+ import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import o from"@heroicons/react/24/solid/XCircleIcon";import{useState as a,useEffect as n,useRef as i,useMemo as l}from"react";import{styled as s}from"styled-components";import{a9 as d,aB as c,aw as p,af as h,d8 as u,d9 as y,bg as m,b5 as g,aK as f,dx as v,cy as w,cz as b,dy as x,bf as C,ap as I,dz as T,bu as E,ct as A,cq as k,dA as S,aC as _,dB as N,dC as D,b7 as P,dD as U,c6 as R,aE as O,dE as V,bm as M}from"./AwaitingEvmToSolBridgingScreen-DnBONxHo.mjs";import{a8 as F}from"./internal-context-CL_EG4e1.mjs";import z from"@heroicons/react/24/outline/ExclamationTriangleIcon";import{isHex as L,hexToString as W}from"viem";import{ProviderErrors as j}from"@privy-io/js-sdk-core";const B=({children:r,theme:o})=>/*#__PURE__*/e($,{$theme:o,children:[/*#__PURE__*/t(z,{width:"1.25rem",color:"dark"===o?"#FDE68A":"var(--privy-color-warn)"}),r]});let $=/*#__PURE__*/s.div.withConfig({displayName:"Container",componentId:"sc-97f152b3-0"})(["display:flex;gap:0.5rem;background-color:",";"," align-items:flex-start;text-align:left;padding:0.5rem 0.75rem;font-size:0.8125rem;font-weight:400;line-height:1.125rem;padding:0.75rem;&&{border-radius:var(--privy-border-radius-sm);}"],(e=>"dark"===e.$theme?"var(--privy-color-background-2)":"var(--privy-color-warn-light)"),(e=>"dark"===e.$theme?"color: #FDE68A;":""));function K(r){let[o,l]=a(r.dimensions.width),[s,d]=a(void 0),c=i(null);n((()=>{if(c.current&&void 0===o){let{width:e}=c.current.getBoundingClientRect();l(e)}let e=getComputedStyle(document.documentElement);d({background:e.getPropertyValue("--privy-color-background"),background2:e.getPropertyValue("--privy-color-background-2"),foreground3:e.getPropertyValue("--privy-color-foreground-3"),foregroundAccent:e.getPropertyValue("--privy-color-foreground-accent"),accent:e.getPropertyValue("--privy-color-accent"),accentDark:e.getPropertyValue("--privy-color-accent-dark"),success:e.getPropertyValue("--privy-color-success")})}),[]);let p="ethereum"===r.walletToExport.chainType&&!r.walletToExport.imported;/*#__PURE__*/return t("div",{ref:c,children:o&&
2
+ /*#__PURE__*/e(G,{children:[/*#__PURE__*/t("iframe",{style:{position:"absolute",zIndex:1},width:o,height:r.dimensions.height,allow:"clipboard-write self *",src:f(r.origin,`/apps/${r.appId}/embedded-wallets/export`,{client_id:r.appClientId,primaryAddress:r.primaryWallet.address,address:r.walletToExport.address,walletIndex:r.walletToExport.walletIndex,width:`${o}px`,caid:r.clientAnalyticsId,phrase_export:p,...s},{token:r.accessToken})}),/*#__PURE__*/t(H,{children:"Loading..."}),p&&/*#__PURE__*/t(H,{children:"Loading..."})]})})}const q={component:()=>{let[o,i]=a(null),{authenticated:l,user:s,getAccessToken:f}=d(),{closePrivyModal:v,createAnalyticsEvent:w,clientAnalyticsId:b}=F(),x=c(),{data:C,onUserCloseViaDialogOrKeybindRef:I}=p(),{onFailure:T,onSuccess:E,origin:A,appId:k,appClientId:S,walletToExport:_,primaryWallet:N}=C.keyExport,D=e=>{v({shouldCallAuthOnSuccess:!1}),T("string"==typeof e?Error(e):e)},P=()=>{v({shouldCallAuthOnSuccess:!1}),E(),w({eventName:"embedded_wallet_key_export_completed",payload:{walletAddress:_.address}})};return n((()=>{if(!l||!_)return D("User must be authenticated before exporting their wallet");f().then(i,D)}),[l,s]),I.current=P,/*#__PURE__*/e(r,{children:[/*#__PURE__*/t(h,{onClose:P}),/*#__PURE__*/e(J,{children:[/*#__PURE__*/t(u,{children:"Transfer wallet"}),/*#__PURE__*/e(y,{children:["Either copy your private key or seed phrase to transfer your wallet."," ",/*#__PURE__*/t("a",{href:"https://privy-io.notion.site/Transferring-your-account-9dab9e16c6034a7ab1ff7fa479b02828",target:"blank",rel:"noopener noreferrer",children:"Learn more"})]}),/*#__PURE__*/t(B,{theme:x.appearance.palette.colorScheme,children:"Never share your private key or seed phrase with anyone."}),/*#__PURE__*/t(m,{isLoading:!1,isPulsing:!1,title:"Your wallet",address:_.address,showIcon:!0}),/*#__PURE__*/t("div",{style:{width:"100%"},children:o&&/*#__PURE__*/t(K,{origin:A,appId:k,appClientId:S,accessToken:o,clientAnalyticsId:b,walletToExport:_,primaryWallet:N,dimensions:{height:"44px"}})})]}),/*#__PURE__*/t(g,{})]})}};let J=/*#__PURE__*/s.div.withConfig({displayName:"EmbeddedWalletScreenContainer",componentId:"sc-f9e8f1f7-0"})(["display:flex;flex-direction:column;gap:1.25rem;text-align:left;"]),G=/*#__PURE__*/s.div.withConfig({displayName:"ButtonContainer",componentId:"sc-f9e8f1f7-1"})(["overflow:visible;position:relative;overflow:none;height:44px;display:flex;gap:12px;"]),H=/*#__PURE__*/s.div.withConfig({displayName:"LoadingButton",componentId:"sc-f9e8f1f7-2"})(["display:flex;align-items:center;justify-content:center;width:100%;height:100%;font-size:16px;font-weight:500;border-radius:var(--privy-border-radius-md);background-color:var(--privy-color-background-2);color:var(--privy-color-foreground-3);"]);const Q={component:()=>{let{authenticated:i,user:s,getAccessToken:c}=d(),{closePrivyModal:u,createAnalyticsEvent:y,walletProxy:m}=F(),{navigate:g,data:f,setModalData:E,onUserCloseViaDialogOrKeybindRef:A}=p(),k=l((()=>Date.now()),[]),[S,_]=a(!1),{onCompleteNavigateTo:N,onFailure:D,shouldForceMFA:P,entropyId:U,entropyIdVerifier:R}=f?.connectWallet,O=e=>{S||(_(!0),D("string"==typeof e?Error(e):e))};n((()=>{let e,t=v(s,U);return i&&t?m?((async()=>{let r=await c();if(!r)return O("User must be authenticated and have a Privy wallet before it can be connected");try{await m.connect({accessToken:r,entropyId:U,entropyIdVerifier:R}),P&&await m.verifyMfa({accessToken:r});let t=(Date.now()-k)/1e3;N===q&&t<1?e=setTimeout((()=>{g(N,!1)}),1e3*(1-t)):g(N,!1)}catch(e){if(w(e)&&"privy"===t.recoveryMethod){let e=await c();if(!e)return O("User must be authenticated and have a Privy wallet before it can be recovered");try{y({eventName:"embedded_wallet_pinless_recovery_started",payload:{walletAddress:t.address}});let r=await(m?.recover({accessToken:e,entropyId:U,entropyIdVerifier:R}));r?.entropyId||O(Error("Unable to recover wallet")),N?g(N):u({shouldCallAuthOnSuccess:!1}),y({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:t.address}}),g(N)}catch(e){O("An error has occurred, please try again.")}}else w(e)&&"privy"!==t.recoveryMethod?(E({...f,recoverWallet:{entropyId:U,entropyIdVerifier:R,onCompleteNavigateTo:N,onFailure:D},recoveryOAuthStatus:{provider:t.recoveryMethod,action:"recover",isInAccountCreateFlow:!1}}),g(b(t.recoveryMethod))):O(e)}})(),()=>clearTimeout(e)):void 0:O("User must be authenticated and have a Privy wallet before it can be connected")}),[i,s,m]);let V=()=>{O("User exited before wallet could be connected"),u({shouldCallAuthOnSuccess:!1})};return A.current=V,/*#__PURE__*/e(r,{children:[/*#__PURE__*/t(h,{onClose:V}),S?/*#__PURE__*/e(r,{children:[/*#__PURE__*/e(x,{children:[/*#__PURE__*/t(o,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}),/*#__PURE__*/t(C,{title:"Something went wrong",description:"We’re on it. Please try again later."})]}),/*#__PURE__*/t(I,{onClick:()=>u({shouldCallAuthOnSuccess:!1}),children:"Close"})]}):/*#__PURE__*/t(T,{}),/*#__PURE__*/t(X,{})]})}};let X=/*#__PURE__*/s.div.withConfig({displayName:"BottomSpacing",componentId:"sc-734db565-0"})(["height:44px;"]);const Y=/*#__PURE__*/s.img.withConfig({displayName:"StyledLogo",componentId:"sc-68c1b1ea-0"})(["&&{height:",";width:",";border-radius:16px;margin-bottom:12px;}"],(e=>"sm"===e.size?"65px":"140px"),(e=>"sm"===e.size?"65px":"140px"));let Z=e=>{if(!L(e))return e;try{return W(e)}catch{return e}},ee=o=>{let{types:a,primaryType:n,...i}=o.typedData;/*#__PURE__*/return e(r,{children:[/*#__PURE__*/t(V,{data:i}),/*#__PURE__*/t(M,{text:(l=o.typedData,JSON.stringify(l,null,2)),itemName:"full payload to clipboard"})," "]});var l};const te={component:()=>{let{authenticated:o}=d(),{initializeWalletProxy:i,closePrivyModal:l}=F(),{navigate:s,data:c,onUserCloseViaDialogOrKeybindRef:m}=p(),[f,v]=a(!0),[w,b]=a(""),[x,C]=a(),[I,T]=a(null),[V,M]=a(!1),z=null!==I;n((()=>{o||s(E)}),[o]),n((()=>{i(A).then((e=>{v(!1),e||(b("An error has occurred, please try again."),C(new k(new S(w,j.E32603_DEFAULT_INTERNAL_ERROR.eipCode))))}))}),[]);let{method:L,data:W,confirmAndSign:B,onSuccess:$,onFailure:K,uiOptions:q}=c.signMessage,J={title:q?.title||"Sign message",description:q?.description||"Signing this message will not cost you any fees.",buttonText:q?.buttonText||"Sign and continue"},G=e=>{e?$(e):K(x||new k(new S("The user rejected the request.",j.E4001_USER_REJECTED_REQUEST.eipCode))),l({shouldCallAuthOnSuccess:!1}),setTimeout((()=>{T(null),b(""),C(void 0)}),200)};return m.current=()=>{G(I)},/*#__PURE__*/e(r,{children:[/*#__PURE__*/t(h,{onClose:()=>G(I)}),/*#__PURE__*/t(_,{}),q?.iconUrl&&"string"==typeof q.iconUrl?/*#__PURE__*/t(ae,{children:/*#__PURE__*/t(Y,{size:"sm",src:q.iconUrl,alt:"app image"})}):null,/*#__PURE__*/t(u,{children:J.title}),/*#__PURE__*/t(y,{children:J.description}),"personal_sign"===L&&/*#__PURE__*/t(N,{children:Z(W)}),"eth_signTypedData_v4"===L&&/*#__PURE__*/t(ee,{typedData:W}),"solana_signMessage"===L&&/*#__PURE__*/t(N,{children:W}),/*#__PURE__*/t(ne,{}),/*#__PURE__*/t(re,{$fail:!0,children:w}),/*#__PURE__*/t(D,{disabled:V||z||f,loading:V,onClick:async()=>{M(!0),b("");try{let e=await B();T(e),M(!1),setTimeout((()=>{G(e)}),P)}catch(e){console.error(e),b("An error has occurred, please try again."),C(new k(new S(w,j.E32603_DEFAULT_INTERNAL_ERROR.eipCode))),M(!1)}},children:V?"Signing...":z?/*#__PURE__*/e(oe,{children:[/*#__PURE__*/t(U,{style:{height:"0.9rem",width:"0.9rem"},strokeWidth:2})," ",/*#__PURE__*/t("span",{children:"Success"})]}):J.buttonText}),q?.isCancellable&&/*#__PURE__*/t(R,{style:{marginTop:"1rem"},onClick:()=>G(null),isSubmitting:!1,children:"Not now"}),/*#__PURE__*/t(O,{}),/*#__PURE__*/t(g,{})]})}};let re=/*#__PURE__*/s.div.withConfig({displayName:"InputHelp",componentId:"sc-1a9f17a4-0"})(["line-height:20px;height:20px;font-size:13px;color:",";display:flex;justify-content:flex-start;width:100%;margin-top:16px;margin-bottom:4px;"],(e=>e.$fail?"var(--privy-color-error)":"var(--privy-color-foreground-3)")),oe=/*#__PURE__*/s.span.withConfig({displayName:"ContentWithIcon",componentId:"sc-1a9f17a4-1"})(["display:flex;align-items:center;gap:8px;"]),ae=/*#__PURE__*/s.div.withConfig({displayName:"IconContainer",componentId:"sc-1a9f17a4-2"})(["display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:82px;"]),ne=/*#__PURE__*/s.div.withConfig({displayName:"Grow",componentId:"sc-1a9f17a4-3"})(["flex-grow:1;"]);function ie(e){return e.find((e=>"privy"===e.walletClientType&&"embedded"===e.connectorType&&!e.imported))??null}export{q as E,te as S,Q as a,ie as g};
@@ -0,0 +1 @@
1
+ import{bW as e,ci as t}from"./AwaitingEvmToSolBridgingScreen-DnBONxHo.mjs";import{j as i,P as r}from"./internal-context-CL_EG4e1.mjs";const a=async({emitPrivyEvent:a,getAccessToken:n,initializeWalletProxy:o,refreshSessionAndUser:s,user:l},{privateKey:c,chainType:E})=>{if(!l)throw a("linkAccount","onError",i.MUST_BE_AUTHENTICATED,{linkMethod:"siwe"}),new r("User must be authenticated before linking an account.");let[T,m]=await Promise.all([n(),o(15e3)]);if(!m||!T)throw a("linkAccount","onError",i.MUST_BE_AUTHENTICATED,{linkMethod:"siwe"}),new r("User must be authenticated before linking an account.");await m.importWallet({privateKey:c,accessToken:T,chainType:E});let w=await s(),u="solana"===E?e(w):t(w);if(!u)throw a("createWallet","onError",i.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to import wallet");return a("createWallet","onSuccess",{wallet:u}),u};export{a as i};