@privy-io/react-auth 2.19.0 → 2.19.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/abstract-smart-wallets.js +1 -1
- package/dist/cjs/extended-chains.js +1 -1
- package/dist/cjs/farcaster.js +1 -1
- package/dist/cjs/{frame-B38H7ILa.js → frame-8JZCzmCf.js} +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/{internal-context-BChQoYJ7.js → internal-context-B_aIJuQh.js} +1 -1
- package/dist/cjs/{paths-CdRs2pll.js → paths-B00ZrFQm.js} +1 -1
- package/dist/cjs/{privy-provider-CENM9vOZ.js → privy-provider-DSwXDdcX.js} +25 -25
- package/dist/cjs/{smart-wallets-B8cmx9jP.js → smart-wallets-IHcyZonv.js} +1 -1
- package/dist/cjs/smart-wallets.js +1 -1
- package/dist/cjs/solana.js +1 -1
- package/dist/cjs/ui.js +1 -1
- package/dist/cjs/{use-sign-with-user-signer-YijW4Qvj.js → use-sign-with-user-signer-BQ_24mRh.js} +1 -1
- package/dist/cjs/{useActiveWallet-ChBjCxdS.js → useActiveWallet-Dv_ZghMS.js} +1 -1
- package/dist/cjs/{useFundWallet-ChzgQztK.js → useFundWallet-B6An-q7Z.js} +1 -1
- package/dist/dts/extended-chains.d.mts +2 -2
- package/dist/dts/extended-chains.d.ts +2 -2
- package/dist/dts/farcaster.d.mts +2 -2
- package/dist/dts/farcaster.d.ts +2 -2
- package/dist/dts/index.d.mts +89 -99
- package/dist/dts/index.d.ts +89 -99
- package/dist/dts/smart-wallets.d.mts +2 -2
- package/dist/dts/smart-wallets.d.ts +2 -2
- package/dist/dts/solana.d.mts +5 -5
- package/dist/dts/solana.d.ts +5 -5
- package/dist/dts/{types-C5FjymFC.d.mts → types-ZqHmGCwO.d.mts} +40 -6
- package/dist/dts/{types-C5FjymFC.d.ts → types-ZqHmGCwO.d.ts} +40 -6
- package/dist/dts/ui.d.mts +2 -2
- package/dist/dts/ui.d.ts +2 -2
- package/dist/dts/{useSolanaWallets-C_wdD6lb.d.mts → useSolanaWallets-idhSZbQC.d.mts} +1 -1
- package/dist/dts/{useSolanaWallets-C_wdD6lb.d.ts → useSolanaWallets-idhSZbQC.d.ts} +1 -1
- package/dist/esm/abstract-smart-wallets.mjs +1 -1
- package/dist/esm/extended-chains.mjs +1 -1
- package/dist/esm/farcaster.mjs +1 -1
- package/dist/esm/{frame-FpttHlk8.mjs → frame-DMd4vZ0H.mjs} +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/{internal-context-DelFGnzS.mjs → internal-context-qdNgTV5f.mjs} +1 -1
- package/dist/esm/{paths-CYLUXo_U.mjs → paths-DCwuPDUk.mjs} +1 -1
- package/dist/esm/privy-provider-B0E_t4-_.mjs +29 -0
- package/dist/esm/{smart-wallets-Cp5Kl2CX.mjs → smart-wallets-BuX2Ltru.mjs} +1 -1
- package/dist/esm/smart-wallets.mjs +1 -1
- package/dist/esm/solana.mjs +1 -1
- package/dist/esm/ui.mjs +1 -1
- package/dist/esm/{use-sign-with-user-signer-DCN1LHu1.mjs → use-sign-with-user-signer-DnNPDfxp.mjs} +1 -1
- package/dist/esm/{useActiveWallet-Bu4Myhqk.mjs → useActiveWallet-Cqbk2Bwf.mjs} +1 -1
- package/dist/esm/{useFundWallet-DpRl0Fim.mjs → useFundWallet-BjGzb-ri.mjs} +1 -1
- package/package.json +4 -4
- package/dist/esm/privy-provider-BrsjzEmo.mjs +0 -29
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("@abstract-foundation/agw-client"),r=require("@abstract-foundation/agw-client/actions"),n=require("viem"),t=require("viem/accounts"),i=require("viem/chains"),o=require("./use-sign-with-user-signer-
|
|
1
|
+
"use strict";var e=require("@abstract-foundation/agw-client"),r=require("@abstract-foundation/agw-client/actions"),n=require("viem"),t=require("viem/accounts"),i=require("viem/chains"),o=require("./use-sign-with-user-signer-BQ_24mRh.js"),a=require("./privy-provider-DSwXDdcX.js"),c=require("./internal-context-B_aIJuQh.js"),s=require("./getEmbeddedConnectedWallet-DTU4T9TJ.js"),l=require("./smart-wallets-IHcyZonv.js");require("react"),require("react/jsx-runtime"),require("mipd"),require("react-device-detect"),require("viem/utils"),require("@privy-io/js-sdk-core"),require("./paths-B00ZrFQm.js"),require("ofetch"),require("uuid"),require("jose"),require("eventemitter3"),require("@coinbase/wallet-sdk"),require("@privy-io/ethereum"),require("@marsidev/react-turnstile"),require("styled-components"),require("tinycolor2"),require("@heroicons/react/24/outline/DevicePhoneMobileIcon"),require("@heroicons/react/24/outline/FingerPrintIcon"),require("@heroicons/react/24/outline/PhoneIcon"),require("@heroicons/react/24/outline/ShieldCheckIcon"),require("@heroicons/react/24/outline/ArrowLeftIcon"),require("@heroicons/react/24/outline/ArrowRightIcon"),require("@heroicons/react/24/outline/QuestionMarkCircleIcon"),require("@heroicons/react/24/outline/XMarkIcon"),require("@heroicons/react/24/outline/CalendarIcon"),require("@heroicons/react/24/outline/ExclamationTriangleIcon"),require("@heroicons/react/24/outline/ChevronDownIcon"),require("zustand"),require("@headlessui/react"),require("@heroicons/react/24/outline/CheckIcon"),require("@heroicons/react/24/outline/Square2StackIcon"),require("@walletconnect/ethereum-provider"),require("fast-password-entropy"),require("secure-password-utilities"),require("secure-password-utilities/wordlists"),require("@heroicons/react/24/outline/UserCircleIcon"),require("@heroicons/react/24/outline/EnvelopeIcon"),require("@heroicons/react/20/solid/CheckIcon"),require("@heroicons/react/24/outline/WalletIcon"),require("@heroicons/react/24/outline/ExclamationCircleIcon"),require("@heroicons/react/24/outline/ArrowTopRightOnSquareIcon"),require("@heroicons/react/24/solid/DocumentCheckIcon"),require("@heroicons/react/24/solid/XCircleIcon"),require("@heroicons/react/24/solid/CheckCircleIcon"),require("@heroicons/react/24/outline"),require("@tanstack/react-virtual"),require("qrcode"),require("@heroicons/react/24/solid/ArrowsRightLeftIcon"),require("@heroicons/react/24/outline/ChevronRightIcon"),require("@heroicons/react/24/outline/LockClosedIcon"),require("@heroicons/react/24/outline/PencilSquareIcon"),require("@heroicons/react/24/outline/ArrowPathIcon"),require("@heroicons/react/24/outline/EyeIcon"),require("@heroicons/react/24/outline/EyeSlashIcon"),require("@heroicons/react/24/outline/KeyIcon"),require("@heroicons/react/24/outline/ArrowDownTrayIcon"),require("@heroicons/react/24/outline/ClipboardDocumentCheckIcon"),require("@heroicons/react/24/outline/DocumentDuplicateIcon"),require("@heroicons/react/24/solid/LockClosedIcon"),require("@heroicons/react/24/outline/CheckCircleIcon"),require("@heroicons/react/24/outline/InformationCircleIcon"),require("@heroicons/react/24/outline/CreditCardIcon"),require("@heroicons/react/24/outline/QrCodeIcon"),require("@heroicons/react/24/outline/GlobeAltIcon"),require("@heroicons/react/24/outline/ClipboardDocumentIcon"),require("@heroicons/react/24/outline/CloudArrowUpIcon"),require("@heroicons/react/24/outline/NoSymbolIcon"),require("@heroicons/react/24/outline/ClockIcon"),require("@heroicons/react/24/outline/TrashIcon"),require("@heroicons/react/24/solid/CheckBadgeIcon"),require("@heroicons/react/24/solid/IdentificationIcon"),require("@heroicons/react/24/outline/MinusCircleIcon"),require("@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon"),require("@heroicons/react/24/solid/ShieldCheckIcon"),require("js-cookie"),require("permissionless"),require("permissionless/accounts"),require("permissionless/clients/pimlico"),require("viem/account-abstraction"),exports.useAbstractSmartWallets=function(){let{user:u}=o.usePrivyContext(),{hideWalletUIs:d,openPrivyModal:h,chains:p,appId:q,rpcConfig:g,client:y}=c.usePrivyInternal(),m=a.useAppConfig(),{wallets:I}=a.useWallets(),{setModalData:v}=a.usePrivyModal(),C=o.getPrivyEthereumWallet(u),T=!!C&&o.getIsUnifiedWallet(C),f=async(r=i.abstractTestnet.id)=>{let o=s.getEmbeddedConnectedWallet(I);if(!o)throw Error("No connected wallet found");let c="string"==typeof r?n.hexToNumber(r):r;if(![i.abstractTestnet.id,2741].includes(c))throw Error("Error, only Abstract chains are supported");let l=p.find((e=>e.id===c));if(!l)throw Error("Chain not configured");await o.switchChain(l.id);let u=await o.getEthereumProvider(),d=n.createWalletClient({account:o.address,transport:n.custom(u)}),h=t.toAccount({address:o.address,signMessage:d.signMessage,signTransaction:d.signTransaction,signTypedData:d.signTypedData});return await e.createAbstractClient({chain:l,transport:n.http(a.getJsonRpcEndpointFromChain(l,g,q)),publicTransport:n.http(a.getJsonRpcEndpointFromChain(l,g,q)),signer:h})};return{signMessage:async({message:e},r)=>{let n=await f(r);return new Promise((async(r,t)=>{let{entropyId:i,entropyIdVerifier:o}=a.getEntropyDetailsForUser(u);d.current=!0,v({connectWallet:{recoveryMethod:C.recoveryMethod,connectingWalletAddress:C.address,isUnifiedWallet:T,entropyId:i,entropyIdVerifier:o,onCompleteNavigateTo:a.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"personal_sign",data:e,confirmAndSign:()=>n.signMessage({message:e}),onSuccess:e=>r(e),onFailure:t,uiOptions:{isCancellable:!0}}}),h(a.EmbeddedWalletConnectingScreen)})).finally((()=>{d.current=!1}))},signTypedData:async(e,r)=>{let n=await f(r);return new Promise((async(r,t)=>{d.current=!0;let{entropyId:i,entropyIdVerifier:o}=a.getEntropyDetailsForUser(u);v({connectWallet:{recoveryMethod:C.recoveryMethod,connectingWalletAddress:C.address,isUnifiedWallet:T,entropyId:i,entropyIdVerifier:o,onCompleteNavigateTo:a.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:e,confirmAndSign:()=>n.signTypedData(e),onSuccess:e=>r(e),onFailure:t,uiOptions:{isCancellable:!0}}}),h(a.EmbeddedWalletConnectingScreen)})).finally((()=>{d.current=!1}))},sendTransaction:async e=>{let n=await f(e.chainId),t=[],i="calls"in e&&void 0!==e.calls;return t=i?[...e.calls]:[e],new Promise((async(o,c)=>{d.current=!0;let{entropyId:s,entropyIdVerifier:p}=a.getEntropyDetailsForUser(u);v({connectWallet:{recoveryMethod:C.recoveryMethod,connectingWalletAddress:C.address,isUnifiedWallet:T,entropyId:s,entropyIdVerifier:p,onCompleteNavigateTo:a.SendTransactionScreen,onFailure:()=>{}},sendTransaction:{transactionRequests:l.callsToTransactionRequests({calls:t,chain:n.chain,maxPriorityFeePerGas:e.maxPriorityFeePerGas,maxFeePerGas:e.maxFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0}),entropyId:s,entropyIdVerifier:p,transactingWalletAddress:n.account.address,transactingWalletIndex:void 0,prepareTransactionRequest:async()=>{let t=i?r.getBatchTransactionObject(n.account.address,e):e;return await n.prepareAbstractTransactionRequest(t)},scanTransaction:async()=>{if(!y)throw Error("Privy client not found");let t=i?r.getBatchTransactionObject(n.account.address,e):e,o=await n.prepareAbstractTransactionRequest(t);return await y.scanTransaction({metadata:{domain:m.embeddedWallets.transactionScanning.domain},chain_id:e.chainId.toString(),request:{method:"eth_sendTransaction",params:[{from:o.from,to:o.to,value:o.value?.toString(),gas:o.gas?.toString(),gasPrice:o.gasPrice?.toString(),nonce:o.nonce?.toString(),data:o.data,eip_712_meta:{paymaster_params:{paymaster:o.paymaster,paymaster_input:o.paymasterInput}}}]}})},signOnly:!1,getIsSponsored:async()=>void 0!==e.paymaster&&void 0!==e.paymasterInput,onConfirm:()=>i?n.sendTransactionBatch(e):n.sendTransaction(e),onSuccess:e=>o(e.hash),onFailure:c,uiOptions:{isCancellable:!0}}}),h(a.EmbeddedWalletConnectingScreen)})).finally((()=>{d.current=!1}))},signTransaction:async e=>{let n=await f(e.chainId),t=[],i="calls"in e&&void 0!==e.calls;return t=i?[...e.calls]:[e],new Promise((async(o,c)=>{d.current=!0;let{entropyId:s,entropyIdVerifier:p}=a.getEntropyDetailsForUser(u);v({connectWallet:{recoveryMethod:C.recoveryMethod,connectingWalletAddress:C.address,isUnifiedWallet:T,entropyId:s,entropyIdVerifier:p,onCompleteNavigateTo:a.SendTransactionScreen,onFailure:()=>{}},sendTransaction:{transactionRequests:l.callsToTransactionRequests({calls:t,chain:n.chain,maxPriorityFeePerGas:e.maxPriorityFeePerGas,maxFeePerGas:e.maxFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0}),entropyId:s,entropyIdVerifier:p,transactingWalletAddress:n.account.address,transactingWalletIndex:void 0,prepareTransactionRequest:async()=>{let t=i?r.getBatchTransactionObject(n.account.address,e):e;return await n.prepareAbstractTransactionRequest(t)},scanTransaction:async()=>{if(!y)throw Error("Privy client not found");let t=i?r.getBatchTransactionObject(n.account.address,e):e,o=await n.prepareAbstractTransactionRequest(t);return await y.scanTransaction({metadata:{domain:m.embeddedWallets.transactionScanning.domain},chain_id:e.chainId.toString(),request:{method:"eth_sendTransaction",params:[{from:o.from,to:o.to,value:o.value?.toString(),gas:o.gas?.toString(),gasPrice:o.gasPrice?.toString(),nonce:o.nonce?.toString(),data:o.data}]}})},signOnly:!0,getIsSponsored:async()=>void 0!==e.paymaster&&void 0!==e.paymasterInput,onConfirm:async()=>{let t=i?r.getBatchTransactionObject(n.account.address,e):e,o=await n.prepareAbstractTransactionRequest(t);return n.signTransaction(o)},onSuccess:e=>o(e.hash),onFailure:c,uiOptions:{isCancellable:!0}}}),h(a.EmbeddedWalletConnectingScreen)})).finally((()=>{d.current=!1}))}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react"),r=require("@privy-io/js-sdk-core"),t=require("./internal-context-
|
|
1
|
+
"use strict";var e=require("react"),r=require("@privy-io/js-sdk-core"),t=require("./internal-context-B_aIJuQh.js"),i=require("./use-sign-with-user-signer-BQ_24mRh.js");require("viem");exports.useCreateWallet=()=>{let{refreshSessionAndUser:i,privy:a}=t.usePrivyInternal();return e.useMemo((()=>({async createWallet(e){let t=await r.create(a,{request:{chain_type:e.chainType}}),s=await i();if(!s)throw Error("User must be authenticated before creating a Privy wallet");return{user:s,wallet:t}}})),[i,a])},exports.useSignRawHash=()=>{let{user:a}=i.usePrivyContext(),{privy:s}=t.usePrivyInternal(),{signWithUserSigner:n}=i.useSignWithUserSigner();return e.useMemo((()=>({async signRawHash({address:e,chainType:t,hash:u}){if(!a)throw Error("User must be authenticated before signing");let l=i.getAllPrivyWalletsForChainType(a,t).filter((e=>i.getIsUnifiedWallet(e))).find((r=>r.address===e));if(!l)throw Error("Wallet not found");let o=await r.rawSign(s,n,{wallet_id:l.id,params:{hash:u}});if(o.data&&"signature"in o.data&&"hex"===o.data.encoding)return{signature:o.data.signature};throw Error("Failed to sign")}})),[s])};
|
package/dist/cjs/farcaster.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react"),r=require("./frame-
|
|
1
|
+
"use strict";var e=require("react"),r=require("./frame-8JZCzmCf.js"),t=require("./paths-B00ZrFQm.js"),i=require("./internal-context-B_aIJuQh.js");require("ofetch");exports.useLoginToFrame=()=>{let{client:a,setAuthenticated:s,setUser:n}=i.usePrivyInternal();return{initLoginToFrame:e.useCallback((async()=>{let e=new r.FarcasterFramesFlow;if(!a)throw new t.PrivyClientError("Must initialize Privy client first.");return a.startAuthFlow(e),await e.init()}),[a]),loginToFrame:e.useCallback((async({message:e,signature:i})=>{if(!a)throw new t.PrivyClientError("Must initialize Privy client first.");if(!(a.authFlow instanceof r.FarcasterFramesFlow))throw new t.PrivyClientError("Must initialize Farcaster frame flow first.");let l=(e=>{let r=e.match(/farcaster:\/\/fid\/(\d+)/);return r&&r[1]?parseInt(r[1],10):null})(e);if(!l)throw new t.PrivyClientError("Invalid message format; could not parse Farcaster ID.");a.authFlow.setAuthData({message:e,signature:i,fid:l});let{user:u}=await a.authenticate();return u&&(n(u),s(!0)),u}),[a,n,s])}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("./paths-
|
|
1
|
+
"use strict";var t=require("./paths-B00ZrFQm.js");exports.FarcasterFramesFlow=class{async init(){if(!this.api)throw new t.PrivyClientError("Auth flow has no API instance");let{nonce:i,expires_at:r}=await this.api.post(t.initFarcasterV2Path,{});return{nonce:i,expiresAt:r}}async authenticate(){if(!this.message||!this.signature||!this.fid)throw new t.PrivyClientError("Auth flow has no message, signature, or fid");if(!this.api)throw new t.PrivyClientError("Auth flow has no API instance");try{let i=await this.api.post(t.authenticateFarcasterV2Path,{message:this.message,signature:this.signature,fid:this.fid});if(!i)throw new t.PrivyClientError("No response from authentication");return i}catch(i){throw t.formatApiError(i)}}async link(){throw Error("Not implemented")}setAuthData({message:t,signature:i,fid:r}){this.message=t,this.signature=i,this.fid=r}constructor(){this.meta={}}};
|
package/dist/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("./privy-provider-CENM9vOZ.js"),r=require("react"),t=require("./paths-CdRs2pll.js"),o=require("./internal-context-BChQoYJ7.js"),s=require("./use-sign-with-user-signer-YijW4Qvj.js"),n=require("./useActiveWallet-ChBjCxdS.js"),i=require("./frame-B38H7ILa.js"),a=require("@privy-io/public-api"),l=require("react/jsx-runtime"),u=require("@heroicons/react/24/outline/QuestionMarkCircleIcon"),c=require("@heroicons/react/24/outline/ShieldCheckIcon"),d=require("viem"),h=require("viem/utils"),y=require("@privy-io/js-sdk-core"),p=require("./getEmbeddedConnectedWallet-DTU4T9TJ.js"),w=require("viem/accounts");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("mipd"),require("react-device-detect"),require("uuid"),require("jose"),require("eventemitter3"),require("@coinbase/wallet-sdk"),require("@privy-io/ethereum"),require("@marsidev/react-turnstile"),require("styled-components"),require("tinycolor2"),require("@heroicons/react/24/outline/DevicePhoneMobileIcon"),require("@heroicons/react/24/outline/FingerPrintIcon"),require("@heroicons/react/24/outline/PhoneIcon"),require("@heroicons/react/24/outline/ArrowLeftIcon"),require("@heroicons/react/24/outline/ArrowRightIcon"),require("@heroicons/react/24/outline/XMarkIcon"),require("@heroicons/react/24/outline/CalendarIcon"),require("@heroicons/react/24/outline/ExclamationTriangleIcon"),require("@heroicons/react/24/outline/ChevronDownIcon"),require("zustand"),require("@headlessui/react"),require("@heroicons/react/24/outline/CheckIcon"),require("@heroicons/react/24/outline/Square2StackIcon"),require("@walletconnect/ethereum-provider"),require("fast-password-entropy"),require("secure-password-utilities"),require("secure-password-utilities/wordlists"),require("@heroicons/react/24/outline/UserCircleIcon"),require("@heroicons/react/24/outline/EnvelopeIcon"),require("@heroicons/react/20/solid/CheckIcon"),require("@heroicons/react/24/outline/WalletIcon"),require("@heroicons/react/24/outline/ExclamationCircleIcon"),require("@heroicons/react/24/outline/ArrowTopRightOnSquareIcon"),require("@heroicons/react/24/solid/DocumentCheckIcon"),require("@heroicons/react/24/solid/XCircleIcon"),require("@heroicons/react/24/solid/CheckCircleIcon"),require("@heroicons/react/24/outline"),require("@tanstack/react-virtual"),require("qrcode"),require("@heroicons/react/24/solid/ArrowsRightLeftIcon"),require("@heroicons/react/24/outline/ChevronRightIcon"),require("@heroicons/react/24/outline/LockClosedIcon"),require("@heroicons/react/24/outline/PencilSquareIcon"),require("@heroicons/react/24/outline/ArrowPathIcon"),require("@heroicons/react/24/outline/EyeIcon"),require("@heroicons/react/24/outline/EyeSlashIcon"),require("@heroicons/react/24/outline/KeyIcon"),require("@heroicons/react/24/outline/ArrowDownTrayIcon"),require("@heroicons/react/24/outline/ClipboardDocumentCheckIcon"),require("@heroicons/react/24/outline/DocumentDuplicateIcon"),require("@heroicons/react/24/solid/LockClosedIcon"),require("@heroicons/react/24/outline/CheckCircleIcon"),require("@heroicons/react/24/outline/InformationCircleIcon"),require("@heroicons/react/24/outline/CreditCardIcon"),require("@heroicons/react/24/outline/QrCodeIcon"),require("@heroicons/react/24/outline/GlobeAltIcon"),require("ofetch"),require("@heroicons/react/24/outline/ClipboardDocumentIcon"),require("@heroicons/react/24/outline/CloudArrowUpIcon"),require("@heroicons/react/24/outline/NoSymbolIcon"),require("@heroicons/react/24/outline/ClockIcon"),require("@heroicons/react/24/outline/TrashIcon"),require("@heroicons/react/24/solid/CheckBadgeIcon"),require("@heroicons/react/24/solid/IdentificationIcon"),require("@heroicons/react/24/outline/MinusCircleIcon"),require("@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon"),require("@heroicons/react/24/solid/ShieldCheckIcon"),require("js-cookie");var C=/*#__PURE__*/g(u),v=/*#__PURE__*/g(c);const m=()=>{let{setModalData:t}=e.usePrivyModal(),{openModal:n,privy:i,closePrivyModal:l}=o.usePrivyInternal(),{user:u}=s.usePrivyContext();return r.useMemo((()=>({verify:async({standalone:r=!0}={standalone:!0})=>new Promise(((o,s)=>u?0===u.mfaMethods.length?o():(t((t=>({...t,mfaVerify:{onSuccess:async()=>{r?await l({shouldCallAuthOnSuccess:!1,isSuccess:!0}):e.useCorePrivyStateStore.setState({inProgressMfaFlow:void 0}),o()},onFailure:async t=>{r?await l({shouldCallAuthOnSuccess:!1,isSuccess:!1}):e.useCorePrivyStateStore.setState({inProgressMfaFlow:void 0}),s(t)},sendSmsCode:async()=>{throw Error("Not enabled")},verifySmsCode:async()=>{throw Error("Not enabled")},verifyTotpCode:async e=>{await i.fetchPrivyRoute(a.MfaAuthTotpVerify,{body:{code:e}})},generateOptions:async()=>e.transformOptionsToCamelCase((await i.fetchPrivyRoute(a.MfaAuthPasskeyInit,{body:{}})).options),verifyPasskey:async r=>{let t=await import("@simplewebauthn/browser"),o=await t.startAuthentication(r);await i.fetchPrivyRoute(a.MfaAuthPasskeyVerify,{body:{authenticator_response:e.transformResponseToSnakeCase(o)}})}}}))),void(r?n(e.MfaAuthVerifyFlowScreen):e.useCorePrivyStateStore.setState({inProgressMfaFlow:"auth"}))):s(Error("Must be logged in to verify MFA"))))})),[i,t,n,l])},A={component:()=>{let{user:t,ready:o}=s.usePrivyContext(),{app:n,data:i,onUserCloseViaDialogOrKeybindRef:a}=e.usePrivyModal(),[u,c]=r.useState(null),[d,h]=r.useState(null),[y,p]=r.useState(null),[w,g]=r.useState(!1),[m,A]=r.useState(!1),[f,P]=r.useState(),E=async()=>{f?k(f):t?await S({user:t}):k(Error("Must be logged in to manage MFA")),setTimeout((()=>{c(null),h(null)}),500)};if(a.current=E,!i?.mfaEnroll)throw Error("Missing modal data for MFA enrollment screen.");let{onFailure:k,onSuccess:S,mfaMethods:x,verify:W,generateTotpSecret:I,enrollTotp:T,unenrollTotp:b,enrollPasskey:U}=i.mfaEnroll,M=t?.mfaMethods.includes("sms"),R=t?.mfaMethods.includes("totp"),q=t?.mfaMethods.includes("passkey"),O=!!t?.phone,F=t?.linkedAccounts.filter((e=>"passkey"===e.type)).map((e=>e.credentialId))??[];function N(){c(null),h(null),P(void 0)}async function _(e=F){try{P(void 0),A(!0);let r=await U(e);return await S({user:r})}catch(e){P(e)}finally{A(!1),g(!1)}}if(!o||!t||!n)/*#__PURE__*/return l.jsxs(l.Fragment,{children:[/*#__PURE__*/l.jsx(e.ModalHeader,{onClose:E},"header"),/*#__PURE__*/l.jsx(e.AppLogoContainer,{children:/*#__PURE__*/l.jsx(e.MfaShieldIcon,{})}),/*#__PURE__*/l.jsx(e.Container,{children:/*#__PURE__*/l.jsx(e.Loader,{})}),/*#__PURE__*/l.jsx(e.ModalFooter,{})]});if("sms"===u)return null;if("totp"===u)/*#__PURE__*/return l.jsxs(l.Fragment,{children:[/*#__PURE__*/l.jsx(e.ModalHeader,{backFn:N,onClose:E},"header"),/*#__PURE__*/l.jsx(e.IconWrapper,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/l.jsx(C.default,{})}),/*#__PURE__*/l.jsx(e.Title,{children:"Remove authenticator app verification?"}),/*#__PURE__*/l.jsxs(e.SubTitle,{children:["MFA adds an extra layer of security to your ",n?.name," account. Make sure you have other methods to secure your account."]}),/*#__PURE__*/l.jsx(e.BottomSection,{children:/*#__PURE__*/l.jsx(e.PrimaryButton,{$warn:!0,onClick:async function(){try{P(void 0),A(!0);let e=await b();return await S({user:e})}catch(e){P(e)}finally{A(!1),c(null)}},loading:m,children:"Remove"})}),/*#__PURE__*/l.jsx(e.ModalFooter,{})]});if("passkey"===u){let r=i.mfaEnroll.shouldUnlinkOnUnenrollMfa??!0;/*#__PURE__*/return l.jsxs(l.Fragment,{children:[/*#__PURE__*/l.jsx(e.ModalHeader,{backFn:N,onClose:E},"header"),/*#__PURE__*/l.jsx(e.IconWrapper,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/l.jsx(C.default,{})}),/*#__PURE__*/l.jsx(e.Title,{children:"Are you sure you want to remove this passkey?"}),/*#__PURE__*/l.jsx(e.SubTitle,{children:r?"Removing your passkey will remove as both a verification method and a login method.":"Removing your passkey will remove as a verification method."}),/*#__PURE__*/l.jsx(e.BottomSection,{children:/*#__PURE__*/l.jsx(e.PrimaryButton,{$warn:!0,onClick:async function(){try{P(void 0),A(!0);let e=await U([]);return await S({user:e})}catch(e){P(e)}finally{A(!1),c(null)}},loading:m,children:"Remove"})}),/*#__PURE__*/l.jsx(e.ModalFooter,{})]})}return 0!==x.length||M||R||q?"sms"===d?null:"totp"===d&&y?/*#__PURE__*/l.jsx(e.EnrollTotp,{onClose:E,onReset:N,submitEnrollmentWithTotp:e=>async function(e){try{P(void 0),A(!0);let r=await T(e);return await S({user:r})}catch(e){P(e)}finally{A(!1),c(null)}}(e.mfaCode),error:f,totpInfo:{...y,appName:n?.name||"Privy"}}):"passkey"===d?/*#__PURE__*/l.jsx(e.EnrollPasskey,{onReset:N,onClose:E,submitEnrollmentWithPasskey:_}):/*#__PURE__*/l.jsx(e.EnrollLandingScreen,{showIntro:!1,userMfaMethods:t.mfaMethods,appMfaMethods:n.mfa.methods,userHasAuthSms:O,onBackToIntro:()=>{},handleSelectMethod:async function(e){P(void 0);try{await W()}catch(e){return void P(e)}return"totp"===e?(h(e),p(null),void I().then((({totpSecret:e,totpAuthUrl:r})=>{p({authUrl:r,secret:e})})).catch((()=>{p(null),N()}))):"passkey"===e&&1===F.length?await _():void h(e)},isTotpLoading:"totp"===d&&!y,isPasskeyLoading:w,error:f,onClose:E,setRemovingMfaMethod:async function(e){P(void 0);try{await W()}catch(e){return void P(e)}c(e)}}):/*#__PURE__*/l.jsxs(l.Fragment,{children:[/*#__PURE__*/l.jsx(e.ModalHeader,{onClose:E},"header"),/*#__PURE__*/l.jsx(e.IconWrapper,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/l.jsx(v.default,{})}),/*#__PURE__*/l.jsx(e.Title,{children:"Add more security"}),/*#__PURE__*/l.jsxs(e.SubTitle,{children:[n?.name," does not have any verification methods enabled."]}),/*#__PURE__*/l.jsx(e.BottomSection,{children:/*#__PURE__*/l.jsx(e.PrimaryButton,{onClick:E,children:"Close"})}),/*#__PURE__*/l.jsx(e.ModalFooter,{})]})}};const f=()=>{let{ready:t,wallets:n}=e.useWallets(),{user:i}=s.usePrivyContext(),{rpcConfig:a,chains:l,appId:u}=o.usePrivyInternal();return{signAuthorization:r.useCallback((async(r,o)=>{let c;if(!i)throw Error("User must be authenticated before signing with a Privy wallet");if(!t)throw Error("Wallets are not ready");let y=o?.address??s.getPrivyEthereumWallet(i)?.address??d.zeroAddress,p=n.find((e=>d.getAddress(e.address)===d.getAddress(y)));if(!p)throw Error("Signing wallet not found.");let w=r.chainId??Number(p.chainId.split(":")[1]);if(0===w)c={chainId:0,address:r.contractAddress,nonce:r.nonce??0};else{let t=l.find((e=>e.id===w));if(!t)throw Error("Error, chain not configured in PrivyProvider config");let o=d.createWalletClient({account:y,chain:t,transport:d.http(e.getJsonRpcEndpointFromChain(t,a,u))});c=await o.prepareAuthorization({...r})}let g=await p.getEthereumProvider(),C=await g.request({method:"secp256k1_sign",params:[h.hashAuthorization(c)]});return{...c,...d.parseSignature(C)}}),[t,n,i,l])}},P=f;let E=async(e,r,o,s,n)=>{if(!e)throw s("linkAccount","onError",t.PrivyErrorCode.MUST_BE_AUTHENTICATED,{linkMethod:n}),new t.PrivyClientError("User must be authenticated before linking an account.");if(!r?.linkedAccounts.some((e=>e.type.includes(n))))throw new t.PrivyClientError(`OAuth account of type ${n} not linked to the account.`);await o(n)};exports.Captcha=e.Captcha,exports.ConnectorManager=e.ConnectorManager,exports.EthereumWalletConnector=e.EthereumWalletConnector,exports.LoginModal=e.LoginModal,exports.PrivyClient=e.PrivyClient,exports.PrivyProvider=e.PrivyProvider,exports.VERSION=e.VERSION,exports.WalletConnector=e.WalletConnector,exports.errorIndicatesMaxMfaRetries=e.errorIndicatesMaxMfaRetries,exports.errorIndicatesMfaTimeout=e.errorIndicatesMfaTimeout,exports.errorIndicatesMfaVerificationFailed=e.errorIndicatesMfaVerificationFailed,exports.getAccessToken=e.getCustomerAccessToken,exports.useCreateWallet=e.useCreateWallet,exports.useIdentityToken=e.useIdentityToken,exports.useImportWallet=e.useImportWallet,exports.useLogout=e.useLogout,exports.useMfa=e.useMfa,exports.useMfaEnrollment=e.useMfaEnrollment,exports.usePrivy=e.usePrivy,exports.useRegisterMfaListener=e.useRegisterMfaListener,exports.useSolanaWallets=e.useSolanaWallets,exports.useSyncJwtBasedAuthState=e.useSyncJwtBasedAuthState,exports.useWallets=e.useWallets,exports.useActiveWallet=n.useActiveWallet,exports.useConnectWallet=n.useConnectWallet,exports.useFundWallet=n.useFundWallet,exports.useLogin=n.useLogin,Object.defineProperty(exports,"SUPPORTED_CHAINS",{enumerable:!0,get:function(){return y.DEFAULT_SUPPORTED_CHAINS}}),Object.defineProperty(exports,"addPrivyRpcToChain",{enumerable:!0,get:function(){return y.addPrivyRpcToChain}}),Object.defineProperty(exports,"addRpcUrlOverrideToChain",{enumerable:!0,get:function(){return y.addRpcUrlOverrideToChain}}),exports.getEmbeddedConnectedWallet=p.getEmbeddedConnectedWallet,exports.toViemAccount=async({wallet:e})=>{let r=await e.getEthereumProvider();return w.toAccount({address:e.address,sign:async({hash:t})=>{if("privy"!==e.walletClientType)throw new y.PrivyClientError({error:"Unprefixed signing is not supported by external wallets.",code:"unsupported_wallet_type"});return await r.request({method:"secp256k1_sign",params:[t]})},signMessage:async({message:t})=>await r.request({method:"personal_sign",params:[t,e.address]}),signTypedData:async t=>await r.request({method:"eth_signTypedData_v4",params:[e.address,t]}),signTransaction:async e=>await r.request({method:"eth_signTransaction",params:[e]})})},exports.useAuthMfa=m,exports.useAuthMfaEnrollment=()=>{let t=e.useAppConfig(),{setModalData:s}=e.usePrivyModal(),{verify:n}=m(),{openModal:i,privy:l,closePrivyModal:u,refreshSessionAndUser:c,setUser:d}=o.usePrivyInternal();return r.useMemo((()=>({enroll:async()=>new Promise(((e,r)=>{s({mfaEnroll:{onSuccess:async r=>{await u({shouldCallAuthOnSuccess:!1,isSuccess:!0}),e(r)},onFailure:async e=>{await u({shouldCallAuthOnSuccess:!1,isSuccess:!1}),r(e)},verify:()=>n({standalone:!1}),shouldUnlinkOnUnenrollMfa:!0,mfaMethods:t.mfa.methods,sendSmsCode:async()=>{throw Error("Not enabled")},enrollSms:async()=>{throw Error("Not enabled")},unenrollSms:async()=>{throw Error("Not enabled")},generateTotpSecret:async()=>await l.fetchPrivyRoute(a.MfaAuthTotpInit,{body:{}}),enrollTotp:async e=>{await l.fetchPrivyRoute(a.MfaAuthTotpEnroll,{body:{code:e}});let r=await c();return d(r),r},unenrollTotp:async()=>{await l.fetchPrivyRoute(a.MfaAuthTotpUnenroll,{body:{}});let e=await c();return d(e),e},enrollPasskey:async e=>{await l.fetchPrivyRoute(a.MfaAuthPasskeyEnrollment,{body:{credential_ids:e,remove_for_login:!0}});let r=await c();return d(r),r}}}),i(A)}))})),[l,s,i,u])},exports.useAuthorizationSignature=()=>{let{signWithUserSigner:e}=s.useSignWithUserSigner();return r.useMemo((()=>({async generateAuthorizationSignature(r){let{signature:t}=await y.generateAuthorizationSignature(e,r);return{signature:t}}})),[e])},exports.useConnectBaseAccount=()=>{let{connectBaseAccount:e}=o.usePrivyInternal();return{connectBaseAccount:e}},exports.useConnectCoinbaseSmartWallet=()=>{let{connectCoinbaseSmartWallet:e}=o.usePrivyInternal();return{connectCoinbaseSmartWallet:e}},exports.useConnectOrCreateWallet=r=>{let{connectOrCreateWallet:t}=s.usePrivyContext();return e.usePrivyEventSubscription("connectOrCreateWallet",r),{connectOrCreateWallet:t}},exports.useCrossAppAccounts=()=>{let{startCrossAppAuthFlow:e,unlinkCrossAppAccount:r,signMessageWithCrossAppWallet:t,signTypedDataWithCrossAppWallet:o,sendTransactionWithCrossAppWallet:n}=s.usePrivyContext();return{loginWithCrossAppAccount:({appId:r})=>e({appId:r,action:"login"}),linkCrossAppAccount:({appId:r})=>e({appId:r,action:"link"}),unlinkCrossAppAccount:r,signMessage:t,signTypedData:o,sendTransaction:n}},exports.useCustomAuth=r=>{let t=e.useJwtAuthFlowState();return e.usePrivyEventSubscription("customAuth",r),{status:t}},exports.useDelegatedActions=()=>{let{revokeDelegatedWallets:e,delegateWallet:r}=o.usePrivyInternal();return{delegateWallet:async({address:e,chainType:t})=>await r({address:e,chainType:t,showDelegationUIs:!0}),revokeWallets:async()=>await e({showDelegationUIs:!0})}},exports.useFarcasterSigner=function(){let{getFarcasterSignerPublicKey:e,signFarcasterMessage:r,requestFarcasterSignerFromWarpcast:t}=s.usePrivyContext();return{getFarcasterSignerPublicKey:e,signFarcasterMessage:r,requestFarcasterSignerFromWarpcast:t}},exports.useGuestAccounts=function(){let r=e.useAppConfig(),{getAccessToken:n}=s.usePrivyContext(),i=e.useEmitPrivyEvent(),{client:a,setUser:l,setAuthenticated:u,setIsNewUser:c,initializeWalletProxy:d}=o.usePrivyInternal(),{create:h}=e.useCreateWalletInternal();return{createGuestAccount:async()=>{if(!r.id||!a)throw Error("SDK not yet ready");a.startAuthFlow(new e.GuestFlow(r.id));try{let o=await a.authenticate(),s=o.user,y=o.isNewUser??!1;if(!s)throw new t.PrivyClientError("Unable to authenticate guest account");let p=await n(),w=await d(e.WALLET_PROXY_TIMEOUT);if(p&&w)try{let t=e.shouldCreateEmbeddedEthWallet(s,r.embeddedWallets.ethereum.createOnLogin),o=e.shouldCreateEmbeddedSolWallet(s,r.embeddedWallets.solana.createOnLogin);t&&o?(s=(await h({chainType:"ethereum",latestUser:s})).user,s=(await h({chainType:"solana",latestUser:s})).user):o?s=(await h({chainType:"solana",latestUser:s})).user:t?s=(await h({chainType:"ethereum",latestUser:s})).user:l(s)}catch(e){l(s),console.warn("Unable to create embedded wallet for guest account")}return c(y),u(!0),i("login","onComplete",{user:s,isNewUser:y,wasAlreadyAuthenticated:!1,loginMethod:"guest",loginAccount:null}),s}catch(e){throw i("login","onError",e.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}}}},exports.useHeadlessDelegatedActions=()=>{let{revokeDelegatedWallets:e,delegateWallet:r}=o.usePrivyInternal();return{delegateWallet:async({address:e,chainType:t})=>await r({address:e,chainType:t,showDelegationUIs:!1}),revokeWallets:async()=>await e({showDelegationUIs:!1})}},exports.useLinkAccount=function(t){let{linkEmail:o,linkPhone:n,linkWallet:i,linkGoogle:a,linkApple:l,linkTwitter:u,linkDiscord:c,linkGithub:d,linkLinkedIn:h,linkTiktok:y,linkLine:p,linkSpotify:w,linkInstagram:g,linkTelegram:C,linkFarcaster:v,linkPasskey:m}=r.useContext(s.PrivyContext);return e.usePrivyEventSubscription("linkAccount",t),{linkEmail:o,linkPhone:n,linkWallet:i,linkGoogle:a,linkApple:l,linkTwitter:u,linkDiscord:c,linkGithub:d,linkLinkedIn:h,linkTiktok:y,linkLine:p,linkSpotify:w,linkInstagram:g,linkFarcaster:v,linkTelegram:C,linkPasskey:m}},exports.useLinkJwtAccount=function(s){let{client:n}=o.usePrivyInternal(),[i,a]=r.useState({status:"initial"});return{linkWithCustomJwt:r.useCallback((async r=>{try{a({status:"initial"}),n.startAuthFlow(new e.CustomJwtAccountFlow(r)),a({status:"loading"});let{user:t}=await n.link();if(!t)throw Error("Error, user not found");let o=t.linkedAccounts.filter((e=>"custom_auth"===e.type)).sort(((e,r)=>r.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime())).at(0);return a({status:"done"}),s?.onSuccess?.({user:t,linkMethod:"custom",linkedAccount:o}),{user:t}}catch(r){throw a({status:"error",error:r}),s?.onError?.(r.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:"custom"}),r}}),[n.startAuthFlow,n.link]),state:i}},exports.useLinkWithPasskey=e=>{let{initLinkWithPasskey:s,linkWithPasskey:n,passkeyAuthState:i,setPasskeyAuthState:a}=o.usePrivyInternal();return{linkWithPasskey:r.useCallback((async()=>{try{await s();let r=await n();if(!r)throw Error("Error, user not found");let t=r.linkedAccounts.filter((e=>"passkey"===e.type)).sort(((e,r)=>r.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime()))[0];e?.onSuccess?.({user:r,linkMethod:"passkey",linkedAccount:t})}catch(r){throw a({status:"error",error:r}),e?.onError?.(r.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),r}}),[n]),state:i}},exports.useLinkWithSiwe=s=>{let n=e.useCaptcha(),{siweState:i,setSiweState:a,linkWithSiwe:l,generateSiweMessage:u}=o.usePrivyInternal();return{generateSiweMessage:r.useCallback((async({address:e,chainId:r})=>{try{if(!e||!r)throw Error("wallet address and chainId required to generate nonce");return await u({address:e,chainId:r}).then((e=>e))}catch(e){throw a({status:"error",error:e}),s?.onError?.(e.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),e}}),[u]),linkWithSiwe:r.useCallback((async({signature:r,message:o,chainId:i,walletClientType:u,connectorType:c})=>{try{if(n.enabled&&"success"!==n.status)throw new e.CaptchaError(n.error,null,t.PrivyErrorCode.CAPTCHA_FAILURE);let{user:a,linkedAccount:d}=await l({message:o,signature:r,chainId:i,walletClientType:u,connectorType:c});d&&s?.onSuccess?.({user:a,linkMethod:"siwe",linkedAccount:d})}catch(r){throw a({status:"error",error:r}),s?.onError?.(r.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),r}}),[l,n.status]),state:i}},exports.useLoginWithEmail=s=>{let n=e.useCaptcha(),{emailOtpState:i,setEmailOtpState:a,initLoginWithEmail:l,loginWithCode:u}=o.usePrivyInternal();return{sendCode:r.useCallback((async({email:r,disableSignup:o})=>{try{let s;if(!r)throw Error("Email required to send OTP code");if(n.enabled&&"error"===n.status)throw new e.CaptchaError(n.error,null,t.PrivyErrorCode.CAPTCHA_FAILURE);return n.enabled&&"success"!==n.status&&(n.execute(),s=await n.waitForResult()),await l({email:r,captchaToken:s,disableSignup:o,withPrivyUi:!1})}catch(r){throw a({status:"error",error:r}),s?.onError?.(r.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR),r}}),[l]),loginWithCode:r.useCallback((async({code:r})=>{try{if(n.enabled&&"error"===n.status)throw new e.CaptchaError(n.error,null,t.PrivyErrorCode.CAPTCHA_FAILURE);let{user:o,isNewUser:i,wasAlreadyAuthenticated:a,linkedAccount:l}=await u(r);s?.onComplete?.({user:o,isNewUser:i,wasAlreadyAuthenticated:a,loginMethod:"email",loginAccount:l})}catch(r){throw a({status:"error",error:r}),s?.onError?.(r.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR),r}}),[u,n.status]),state:i}},exports.useLoginWithFarcasterV2=()=>{let{client:e,setAuthenticated:s,setUser:n}=o.usePrivyInternal();return r.useMemo((()=>({init:async()=>{if(!e)throw new t.PrivyClientError("Must initialize Privy client first.");let r=new i.FarcasterFramesFlow;return e.startAuthFlow(r),await r.init()},login:async({fid:r,message:o,signature:a})=>{if(!e)throw new t.PrivyClientError("Must initialize Privy client first.");if(!(e.authFlow instanceof i.FarcasterFramesFlow))throw new t.PrivyClientError("Must initialize Farcaster frame flow first.");e.authFlow.setAuthData({message:o,signature:a,fid:r});let{user:l}=await e.authenticate();if(!l)throw new t.PrivyClientError("Failed to login with Farcaster V2");return n(l),s(!0),{user:l}}})),[e,n,s])},exports.useLoginWithOAuth=n=>{e.usePrivyEventSubscription("login",n);let i=e.useCaptcha(),a=e.useIsServerConfigLoaded(),{ready:l,user:u}=s.usePrivyContext(),{initLoginWithHeadlessOAuth:c,loginWithHeadlessOAuth:d,oAuthState:h,setOAuthState:y,isHeadlessOAuthLoading:p}=o.usePrivyInternal(),w=r.useCallback((async r=>{try{if(i.enabled&&"success"!==i.status)throw new e.CaptchaError(i.error,null,t.PrivyErrorCode.CAPTCHA_FAILURE);return await c(r.provider,i.token,r.disableSignup)}catch(r){throw y({status:"error",error:r}),r}}),[c,i]),g=r.useCallback((async()=>{let r=e.detectCompletingOAuthFlow();try{if(u)return console.warn("Cannot login with OAuth when already logged in"),u;if(!r.inProgress)throw Error("Cannot login with OAuth because no OAuth flow is in progress");if(r.popupFlow)return}catch(r){throw y({status:"error",error:r}),r}try{return await d(r)}catch(r){throw y({status:"error",error:r}),r}finally{e.stripUrlOAuthParamsAndRemoveStateCode()}}),[d]);return r.useEffect((()=>{let r=e.detectCompletingOAuthFlow();l&&a&&r.inProgress&&!r.withPrivyUi&&!r.popupFlow&&g().catch((()=>{}))}),[l,a]),{initOAuth:w,loading:p,state:h}},exports.useLoginWithPasskey=s=>{let n=e.useCaptcha(),{initLoginWithPasskey:i,loginWithPasskey:a,passkeyAuthState:l,setPasskeyAuthState:u}=o.usePrivyInternal();return{loginWithPasskey:r.useCallback((async r=>{try{let o;if(n.enabled&&"error"===n.status)throw new e.CaptchaError(n.error,null,t.PrivyErrorCode.CAPTCHA_FAILURE);n.enabled&&"success"!==n.status&&(n.execute(),o=await n.waitForResult()),await i({captchaToken:o,withPrivyUi:!1});let{user:l,isNewUser:u,wasAlreadyAuthenticated:c,loginAccount:d}=await a(r);s?.onComplete?.({user:l,isNewUser:u,wasAlreadyAuthenticated:c,loginMethod:"passkey",loginAccount:d})}catch(r){throw u({status:"error",error:r}),s?.onError?.(r.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR),r}}),[a,n.status]),state:l}},exports.useLoginWithSiwe=s=>{let n=e.useCaptcha(),{siweState:i,setSiweState:a,client:l,generateSiweMessage:u,loginWithSiwe:c}=o.usePrivyInternal();return{generateSiweNonce:r.useCallback((async r=>{try{let o;if(n.enabled&&"error"===n.status)throw new e.CaptchaError(n.error,null,t.PrivyErrorCode.CAPTCHA_FAILURE);n.enabled&&"success"!==n.status&&(n.execute(),o=await n.waitForResult()),a({status:"generating-message"});let s=await l.generateSiweNonce({address:r?.address,captchaToken:o});return a({status:"awaiting-signature"}),s}catch(r){throw a({status:"error",error:r}),s?.onError?.(r.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR),r}}),[l,n]),generateSiweMessage:r.useCallback((async({address:e,chainId:r})=>{try{return await u({address:e,chainId:r})}catch(e){throw a({status:"error",error:e}),s?.onError?.(e.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}}),[u]),loginWithSiwe:r.useCallback((async({message:r,signature:o,disableSignup:i})=>{try{let a;if(n.enabled&&"error"===n.status)throw new e.CaptchaError(n.error,null,t.PrivyErrorCode.CAPTCHA_FAILURE);n.enabled&&"success"!==n.status&&(n.execute(),a=await n.waitForResult());let l=await c({message:r,signature:o,captchaToken:a,disableSignup:i});return s?.onComplete?.({user:l,isNewUser:!1,wasAlreadyAuthenticated:!1,loginMethod:"siwe",loginAccount:null}),l}catch(r){throw a({status:"error",error:r}),s?.onError?.(r.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR),r}}),[c,n.status]),state:i}},exports.useLoginWithSms=s=>{let n=e.useCaptcha(),{smsOtpState:i,setSmsOtpState:a,initLoginWithSms:l,loginWithCode:u}=o.usePrivyInternal();return{sendCode:r.useCallback((async({phoneNumber:r,disableSignup:o})=>{try{let s;if(!r)throw Error("SMS required to send OTP code");if(n.enabled&&"error"===n.status)throw new e.CaptchaError(n.error,null,t.PrivyErrorCode.CAPTCHA_FAILURE);return n.enabled&&"success"!==n.status&&(n.execute(),s=await n.waitForResult()),await l({phoneNumber:r,captchaToken:s,disableSignup:o,withPrivyUi:!1})}catch(r){throw a({status:"error",error:r}),s?.onError?.(r.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR),r}}),[l]),loginWithCode:r.useCallback((async({code:r})=>{try{if(n.enabled&&"success"!==n.status)throw new e.CaptchaError(n.error,null,t.PrivyErrorCode.CAPTCHA_FAILURE);let{user:o,isNewUser:i,wasAlreadyAuthenticated:a,linkedAccount:l}=await u(r);s?.onComplete?.({user:o,isNewUser:i,wasAlreadyAuthenticated:a,loginMethod:"sms",loginAccount:l})}catch(r){throw a({status:"error",error:r}),s?.onError?.(r.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR),r}}),[u,n.status]),state:i}},exports.useLoginWithTelegram=s=>{let n=e.useCaptcha(),{initLoginWithTelegram:i,loginWithTelegram:a,telegramAuthState:l,setTelegramAuthState:u}=o.usePrivyInternal();return{login:r.useCallback((async r=>{try{if(n.enabled&&"success"!==n.status)throw new e.CaptchaError(n.error,null,t.PrivyErrorCode.CAPTCHA_FAILURE);await i(n.token,r?.disableSignup);let{user:o,isNewUser:l,loginAccount:u,wasAlreadyAuthenticated:c}=await a({intent:"login"});s?.onComplete?.({user:o,isNewUser:l,wasAlreadyAuthenticated:c,loginMethod:"telegram",loginAccount:u})}catch(r){throw u({status:"error",error:r}),s?.onError?.(r.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR),r}}),[i,a,n]),state:l}},exports.useModalStatus=()=>{let{isModalOpen:e}=r.useContext(s.PrivyContext);return{isOpen:e}},exports.useOAuthTokens=function(r){let{authenticated:t,user:n}=s.usePrivyContext(),{initLoginWithOAuth:i}=o.usePrivyInternal(),a=e.useEmitPrivyEvent();return e.usePrivyEventSubscription("oAuthAuthorization",r),{reauthorize:e=>E(t,n,i,a,e.provider)}},exports.useRecoverEmbeddedWallet=()=>{let{user:n}=s.usePrivyContext(),{walletProxy:i}=o.usePrivyInternal();return{recover:r.useCallback((async r=>{if(!i)throw Error("Wallet proxy is not ready");let o=await e.getAccessToken();if(!n||!o)throw new t.PrivyClientError("User must be logged in before attempting to modify the recovery method.");let{entropyId:s,entropyIdVerifier:a}=e.getEntropyDetailsForUser(n);try{await i.recover({entropyId:s,entropyIdVerifier:a,accessToken:o,...r})}catch{throw new t.PrivyClientError("Unable to recover wallets")}}),[i,n])}},exports.useSendTransaction=function(t){let{sendTransaction:o}=r.useContext(s.PrivyContext);return e.usePrivyEventSubscription("sendTransaction",t),{sendTransaction:o}},exports.useSessionSigners=()=>{let{addSessionSignersInternal:r,removeSessionSignersInternal:n}=(()=>{let{getAccessToken:r,user:n}=s.usePrivyContext(),i=o.usePrivyInternal(),{signWithUserSigner:a}=s.useSignWithUserSigner(),l=async({wallet:e,additional_signers:o})=>{let s=await r();if(!n||!s)throw new t.PrivyClientError("User must be authenticated and have an embedded wallet to delegate actions.");if(!e.id)throw new t.PrivyClientError("Wallet to add signers to must have ID on server");if(!i.walletProxy)throw new t.PrivyClientError("Wallet proxy not initialized.");await y.updateWallet(i.privy,{wallet_id:e.id},a,{additional_signers:o})};return{addSessionSignersInternal:async({address:o,signers:a})=>{let u=await r();if(!n||!u)throw new t.PrivyClientError("User must be authenticated and have an embedded wallet to add a session signer.");let c=i.walletProxy??await i.initializeWalletProxy(15e3);if(!c)throw new t.PrivyClientError("Wallet proxy not initialized.");let d=s.getPrivyWalletWithAddress(n,o);if(!d)throw new t.PrivyClientError("Address to add signers too is not associated with current user.");if(s.getIsUnifiedWallet(d)){if(0===a.length)throw new t.PrivyClientError("Must specify at least one signer to add.");let r=[...(await y.getWallet(i.privy,{wallet_id:d.id})).additional_signers,...e.parseAdditionalSigners(a)];await l({wallet:d,additional_signers:r})}else{if(d.delegated)return{user:n};if(a.length>0)throw new t.PrivyClientError("Specifying signers in addSessionSigners is only supported for TEE execution and this app uses On-device execution. Pass an empty array for signers instead. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide");let r=e.getDelegatedWalletsData({address:o,user:n}),s=e.getRootWalletDataForDelegation({address:o,user:n});await i.recoverEmbeddedWallet({address:o}),await c.createDelegatedAction({accessToken:u,rootWallet:s,delegatedWallets:[r]})}let h=await i.refreshSessionAndUser();if(!h)throw Error("Could not refresh user");return{user:h}},removeSessionSignersInternal:async({address:e})=>{let o=await r();if(!n||!o)throw new t.PrivyClientError("User must be authenticated and have an embedded wallet to delegate actions.");if(!(i.walletProxy??await i.initializeWalletProxy(15e3)))throw new t.PrivyClientError("Wallet proxy not initialized.");let a=s.getPrivyWalletWithAddress(n,e);if(!a)throw new t.PrivyClientError("Address to remove signers from is not associated with current user.");s.getIsUnifiedWallet(a)?await l({wallet:a,additional_signers:[]}):await i.client.revokeDelegatedWallet();let u=await i.refreshSessionAndUser();if(!u)throw Error("Could not refresh user");return{user:u}}}})();return{addSessionSigners:async({address:e,signers:t})=>r({address:e,signers:t}),removeSessionSigners:async({address:e})=>n({address:e})}},exports.useSetWalletPassword=function(t){let{setWalletPassword:o}=r.useContext(s.PrivyContext);return e.usePrivyEventSubscription("setWalletPassword",t),{setWalletPassword:o}},exports.useSetWalletRecovery=function(t){let{setWalletRecovery:o}=r.useContext(s.PrivyContext);return e.usePrivyEventSubscription("setWalletRecovery",t),{setWalletRecovery:o}},exports.useSign7702Authorization=f,exports.useSignAuthorization=P,exports.useSignMessage=function(t){let{signMessage:o}=r.useContext(s.PrivyContext);return e.usePrivyEventSubscription("signMessage",t),{signMessage:o}},exports.useSignTransaction=function(){let{signTransaction:e}=r.useContext(s.PrivyContext);return{signTransaction:e}},exports.useSignTypedData=function(t){let{signTypedData:o}=r.useContext(s.PrivyContext);return e.usePrivyEventSubscription("signTypedData",t),{signTypedData:o}},exports.useSignupWithPasskey=s=>{let n=e.useCaptcha(),{initSignupWithPasskey:i,signupWithPasskey:a,passkeyAuthState:l,setPasskeyAuthState:u}=o.usePrivyInternal();return{signupWithPasskey:r.useCallback((async()=>{try{let r;if(n.enabled&&"error"===n.status)throw new e.CaptchaError(n.error,null,t.PrivyErrorCode.CAPTCHA_FAILURE);n.enabled&&"success"!==n.status&&(n.execute(),r=await n.waitForResult()),await i({captchaToken:r,withPrivyUi:!1});let{user:o,isNewUser:l,wasAlreadyAuthenticated:u,loginAccount:c}=await a();s?.onComplete?.({user:o,isNewUser:l,wasAlreadyAuthenticated:u,loginMethod:"passkey",loginAccount:c})}catch(e){throw u({status:"error",error:e}),s?.onError?.(e.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}}),[a,n.status]),state:l}},exports.useSubscribeToJwtAuthWithFlag=function({isAuthenticated:t,isLoading:o,...s}){let n=r.useRef();r.useEffect((()=>{o||n.current?.()}),[t,o]);let i=r.useCallback((e=>(n.current=e,()=>{n.current=void 0})),[]);return e.useSyncJwtBasedAuthState({...s,subscribe:i})},exports.useToken=function(t){let{getAccessToken:o}=r.useContext(s.PrivyContext);return e.usePrivyEventSubscription("accessToken",t),{getAccessToken:o}},exports.useUpdateAccount=function(t){let{updateEmail:o,updatePhone:n}=r.useContext(s.PrivyContext);return e.usePrivyEventSubscription("update",t),{updateEmail:o,updatePhone:n}},exports.useUpdateEmail=n=>{let{user:i}=s.usePrivyContext(),{loginWithCode:a,emailOtpState:l,setEmailOtpState:u,client:c,inProgressAuthFlowRef:d,inProgressLoginOrLinkMethodRef:h}=o.usePrivyInternal();return{state:l,sendCode:r.useCallback((async({newEmailAddress:r})=>{try{if(!i?.email)throw Error("User is required to have an email address to update it.");let t=new e.UpdateEmailFlow(i.email.address,r);c.startAuthFlow(t),await t.sendCodeEmail({withPrivyUi:!1})}catch(r){u({status:"error",error:r}),n?.onError?.(r.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:"email"})}}),[i?.email]),verifyCode:r.useCallback((async({code:e})=>{try{if(!i?.email)throw Error("User is required to have an email address to update it.");d.current="update",h.current="email";let{user:r,linkedAccount:t}=await a(e);return n?.onSuccess?.({user:r,updateMethod:"email",updatedAccount:t}),{user:r}}catch(e){u({status:"error",error:e}),n?.onError?.(e.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:"email"})}}),[i?.email])}},exports.useUser=()=>{let{setUser:e,client:t}=r.useContext(o.InternalPrivyContext),{user:n}=r.useContext(s.PrivyContext);return{user:n,refreshUser:r.useCallback((async()=>{let r=await(t?.updateUserAndIdToken());return e(r??null),r}),[t,e])}};
|
|
1
|
+
"use strict";var e=require("./privy-provider-DSwXDdcX.js"),r=require("react"),t=require("./paths-B00ZrFQm.js"),o=require("./internal-context-B_aIJuQh.js"),s=require("./use-sign-with-user-signer-BQ_24mRh.js"),n=require("./useActiveWallet-Dv_ZghMS.js"),a=require("./frame-8JZCzmCf.js"),i=require("@privy-io/public-api"),l=require("react/jsx-runtime"),u=require("@heroicons/react/24/outline/QuestionMarkCircleIcon"),c=require("@heroicons/react/24/outline/ShieldCheckIcon"),d=require("viem"),h=require("viem/utils"),y=require("@privy-io/js-sdk-core"),p=require("./getEmbeddedConnectedWallet-DTU4T9TJ.js"),w=require("viem/accounts");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("mipd"),require("react-device-detect"),require("uuid"),require("jose"),require("eventemitter3"),require("@coinbase/wallet-sdk"),require("@privy-io/ethereum"),require("@marsidev/react-turnstile"),require("styled-components"),require("tinycolor2"),require("@heroicons/react/24/outline/DevicePhoneMobileIcon"),require("@heroicons/react/24/outline/FingerPrintIcon"),require("@heroicons/react/24/outline/PhoneIcon"),require("@heroicons/react/24/outline/ArrowLeftIcon"),require("@heroicons/react/24/outline/ArrowRightIcon"),require("@heroicons/react/24/outline/XMarkIcon"),require("@heroicons/react/24/outline/CalendarIcon"),require("@heroicons/react/24/outline/ExclamationTriangleIcon"),require("@heroicons/react/24/outline/ChevronDownIcon"),require("zustand"),require("@headlessui/react"),require("@heroicons/react/24/outline/CheckIcon"),require("@heroicons/react/24/outline/Square2StackIcon"),require("@walletconnect/ethereum-provider"),require("fast-password-entropy"),require("secure-password-utilities"),require("secure-password-utilities/wordlists"),require("@heroicons/react/24/outline/UserCircleIcon"),require("@heroicons/react/24/outline/EnvelopeIcon"),require("@heroicons/react/20/solid/CheckIcon"),require("@heroicons/react/24/outline/WalletIcon"),require("@heroicons/react/24/outline/ExclamationCircleIcon"),require("@heroicons/react/24/outline/ArrowTopRightOnSquareIcon"),require("@heroicons/react/24/solid/DocumentCheckIcon"),require("@heroicons/react/24/solid/XCircleIcon"),require("@heroicons/react/24/solid/CheckCircleIcon"),require("@heroicons/react/24/outline"),require("@tanstack/react-virtual"),require("qrcode"),require("@heroicons/react/24/solid/ArrowsRightLeftIcon"),require("@heroicons/react/24/outline/ChevronRightIcon"),require("@heroicons/react/24/outline/LockClosedIcon"),require("@heroicons/react/24/outline/PencilSquareIcon"),require("@heroicons/react/24/outline/ArrowPathIcon"),require("@heroicons/react/24/outline/EyeIcon"),require("@heroicons/react/24/outline/EyeSlashIcon"),require("@heroicons/react/24/outline/KeyIcon"),require("@heroicons/react/24/outline/ArrowDownTrayIcon"),require("@heroicons/react/24/outline/ClipboardDocumentCheckIcon"),require("@heroicons/react/24/outline/DocumentDuplicateIcon"),require("@heroicons/react/24/solid/LockClosedIcon"),require("@heroicons/react/24/outline/CheckCircleIcon"),require("@heroicons/react/24/outline/InformationCircleIcon"),require("@heroicons/react/24/outline/CreditCardIcon"),require("@heroicons/react/24/outline/QrCodeIcon"),require("@heroicons/react/24/outline/GlobeAltIcon"),require("ofetch"),require("@heroicons/react/24/outline/ClipboardDocumentIcon"),require("@heroicons/react/24/outline/CloudArrowUpIcon"),require("@heroicons/react/24/outline/NoSymbolIcon"),require("@heroicons/react/24/outline/ClockIcon"),require("@heroicons/react/24/outline/TrashIcon"),require("@heroicons/react/24/solid/CheckBadgeIcon"),require("@heroicons/react/24/solid/IdentificationIcon"),require("@heroicons/react/24/outline/MinusCircleIcon"),require("@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon"),require("@heroicons/react/24/solid/ShieldCheckIcon"),require("js-cookie");var C=/*#__PURE__*/g(u),v=/*#__PURE__*/g(c);const m=()=>{let{setModalData:t}=e.usePrivyModal(),{openModal:n,privy:a,closePrivyModal:l}=o.usePrivyInternal(),{user:u}=s.usePrivyContext();return r.useMemo((()=>({verify:async({standalone:r=!0}={standalone:!0})=>new Promise(((o,s)=>u?0===u.mfaMethods.length?o():(t((t=>({...t,mfaVerify:{onSuccess:async()=>{r?await l({shouldCallAuthOnSuccess:!1,isSuccess:!0}):e.useCorePrivyStateStore.setState({inProgressMfaFlow:void 0}),o()},onFailure:async t=>{r?await l({shouldCallAuthOnSuccess:!1,isSuccess:!1}):e.useCorePrivyStateStore.setState({inProgressMfaFlow:void 0}),s(t)},sendSmsCode:async()=>{throw Error("Not enabled")},verifySmsCode:async()=>{throw Error("Not enabled")},verifyTotpCode:async e=>{await a.fetchPrivyRoute(i.MfaAuthTotpVerify,{body:{code:e}})},generateOptions:async()=>e.transformOptionsToCamelCase((await a.fetchPrivyRoute(i.MfaAuthPasskeyInit,{body:{}})).options),verifyPasskey:async r=>{let t=await import("@simplewebauthn/browser"),o=await t.startAuthentication(r);await a.fetchPrivyRoute(i.MfaAuthPasskeyVerify,{body:{authenticator_response:e.transformResponseToSnakeCase(o)}})}}}))),void(r?n(e.MfaAuthVerifyFlowScreen):e.useCorePrivyStateStore.setState({inProgressMfaFlow:"auth"}))):s(Error("Must be logged in to verify MFA"))))})),[a,t,n,l])},A={component:()=>{let{user:t,ready:o}=s.usePrivyContext(),{app:n,data:a,onUserCloseViaDialogOrKeybindRef:i}=e.usePrivyModal(),[u,c]=r.useState(null),[d,h]=r.useState(null),[y,p]=r.useState(null),[w,g]=r.useState(!1),[m,A]=r.useState(!1),[f,P]=r.useState(),E=async()=>{f?k(f):t?await S({user:t}):k(Error("Must be logged in to manage MFA")),setTimeout((()=>{c(null),h(null)}),500)};if(i.current=E,!a?.mfaEnroll)throw Error("Missing modal data for MFA enrollment screen.");let{onFailure:k,onSuccess:S,mfaMethods:x,verify:W,generateTotpSecret:I,enrollTotp:T,unenrollTotp:b,enrollPasskey:U}=a.mfaEnroll,M=t?.mfaMethods.includes("sms"),R=t?.mfaMethods.includes("totp"),q=t?.mfaMethods.includes("passkey"),O=!!t?.phone,F=t?.linkedAccounts.filter((e=>"passkey"===e.type)).map((e=>e.credentialId))??[];function N(){c(null),h(null),P(void 0)}async function _(e=F){try{P(void 0),A(!0);let r=await U(e);return await S({user:r})}catch(e){P(e)}finally{A(!1),g(!1)}}if(!o||!t||!n)/*#__PURE__*/return l.jsxs(l.Fragment,{children:[/*#__PURE__*/l.jsx(e.ModalHeader,{onClose:E},"header"),/*#__PURE__*/l.jsx(e.AppLogoContainer,{children:/*#__PURE__*/l.jsx(e.MfaShieldIcon,{})}),/*#__PURE__*/l.jsx(e.Container,{children:/*#__PURE__*/l.jsx(e.Loader,{})}),/*#__PURE__*/l.jsx(e.ModalFooter,{})]});if("sms"===u)return null;if("totp"===u)/*#__PURE__*/return l.jsxs(l.Fragment,{children:[/*#__PURE__*/l.jsx(e.ModalHeader,{backFn:N,onClose:E},"header"),/*#__PURE__*/l.jsx(e.IconWrapper,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/l.jsx(C.default,{})}),/*#__PURE__*/l.jsx(e.Title,{children:"Remove authenticator app verification?"}),/*#__PURE__*/l.jsxs(e.SubTitle,{children:["MFA adds an extra layer of security to your ",n?.name," account. Make sure you have other methods to secure your account."]}),/*#__PURE__*/l.jsx(e.BottomSection,{children:/*#__PURE__*/l.jsx(e.PrimaryButton,{$warn:!0,onClick:async function(){try{P(void 0),A(!0);let e=await b();return await S({user:e})}catch(e){P(e)}finally{A(!1),c(null)}},loading:m,children:"Remove"})}),/*#__PURE__*/l.jsx(e.ModalFooter,{})]});if("passkey"===u){let r=a.mfaEnroll.shouldUnlinkOnUnenrollMfa??!0;/*#__PURE__*/return l.jsxs(l.Fragment,{children:[/*#__PURE__*/l.jsx(e.ModalHeader,{backFn:N,onClose:E},"header"),/*#__PURE__*/l.jsx(e.IconWrapper,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/l.jsx(C.default,{})}),/*#__PURE__*/l.jsx(e.Title,{children:"Are you sure you want to remove this passkey?"}),/*#__PURE__*/l.jsx(e.SubTitle,{children:r?"Removing your passkey will remove as both a verification method and a login method.":"Removing your passkey will remove as a verification method."}),/*#__PURE__*/l.jsx(e.BottomSection,{children:/*#__PURE__*/l.jsx(e.PrimaryButton,{$warn:!0,onClick:async function(){try{P(void 0),A(!0);let e=await U([]);return await S({user:e})}catch(e){P(e)}finally{A(!1),c(null)}},loading:m,children:"Remove"})}),/*#__PURE__*/l.jsx(e.ModalFooter,{})]})}return 0!==x.length||M||R||q?"sms"===d?null:"totp"===d&&y?/*#__PURE__*/l.jsx(e.EnrollTotp,{onClose:E,onReset:N,submitEnrollmentWithTotp:e=>async function(e){try{P(void 0),A(!0);let r=await T(e);return await S({user:r})}catch(e){P(e)}finally{A(!1),c(null)}}(e.mfaCode),error:f,totpInfo:{...y,appName:n?.name||"Privy"}}):"passkey"===d?/*#__PURE__*/l.jsx(e.EnrollPasskey,{onReset:N,onClose:E,submitEnrollmentWithPasskey:_}):/*#__PURE__*/l.jsx(e.EnrollLandingScreen,{showIntro:!1,userMfaMethods:t.mfaMethods,appMfaMethods:n.mfa.methods,userHasAuthSms:O,onBackToIntro:()=>{},handleSelectMethod:async function(e){P(void 0);try{await W()}catch(e){return void P(e)}return"totp"===e?(h(e),p(null),void I().then((({totpSecret:e,totpAuthUrl:r})=>{p({authUrl:r,secret:e})})).catch((()=>{p(null),N()}))):"passkey"===e&&1===F.length?await _():void h(e)},isTotpLoading:"totp"===d&&!y,isPasskeyLoading:w,error:f,onClose:E,setRemovingMfaMethod:async function(e){P(void 0);try{await W()}catch(e){return void P(e)}c(e)}}):/*#__PURE__*/l.jsxs(l.Fragment,{children:[/*#__PURE__*/l.jsx(e.ModalHeader,{onClose:E},"header"),/*#__PURE__*/l.jsx(e.IconWrapper,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/l.jsx(v.default,{})}),/*#__PURE__*/l.jsx(e.Title,{children:"Add more security"}),/*#__PURE__*/l.jsxs(e.SubTitle,{children:[n?.name," does not have any verification methods enabled."]}),/*#__PURE__*/l.jsx(e.BottomSection,{children:/*#__PURE__*/l.jsx(e.PrimaryButton,{onClick:E,children:"Close"})}),/*#__PURE__*/l.jsx(e.ModalFooter,{})]})}};const f=()=>{let{ready:t,wallets:n}=e.useWallets(),{user:a}=s.usePrivyContext(),{rpcConfig:i,chains:l,appId:u}=o.usePrivyInternal();return{signAuthorization:r.useCallback((async(r,o)=>{let c;if(!a)throw Error("User must be authenticated before signing with a Privy wallet");if(!t)throw Error("Wallets are not ready");let y=o?.address??s.getPrivyEthereumWallet(a)?.address??d.zeroAddress,p=n.find((e=>d.getAddress(e.address)===d.getAddress(y)));if(!p)throw Error("Signing wallet not found.");let w=r.chainId??Number(p.chainId.split(":")[1]);if(0===w)c={chainId:0,address:r.contractAddress,nonce:r.nonce??0};else{let t=l.find((e=>e.id===w));if(!t)throw Error("Error, chain not configured in PrivyProvider config");let o=d.createWalletClient({account:y,chain:t,transport:d.http(e.getJsonRpcEndpointFromChain(t,i,u))});c=await o.prepareAuthorization({...r})}let g=await p.getEthereumProvider(),C=await g.request({method:"secp256k1_sign",params:[h.hashAuthorization(c)]});return{...c,...d.parseSignature(C)}}),[t,n,a,l])}},P=f;let E=async(e,r,o,s,n)=>{if(!e)throw s("linkAccount","onError",t.PrivyErrorCode.MUST_BE_AUTHENTICATED,{linkMethod:n}),new t.PrivyClientError("User must be authenticated before linking an account.");if(!r?.linkedAccounts.some((e=>e.type.includes(n))))throw new t.PrivyClientError(`OAuth account of type ${n} not linked to the account.`);await o(n)};exports.Captcha=e.Captcha,exports.ConnectorManager=e.ConnectorManager,exports.EthereumWalletConnector=e.EthereumWalletConnector,exports.LoginModal=e.LoginModal,exports.PrivyClient=e.PrivyClient,exports.PrivyProvider=e.PrivyProvider,exports.VERSION=e.VERSION,exports.WalletConnector=e.WalletConnector,exports.errorIndicatesMaxMfaRetries=e.errorIndicatesMaxMfaRetries,exports.errorIndicatesMfaTimeout=e.errorIndicatesMfaTimeout,exports.errorIndicatesMfaVerificationFailed=e.errorIndicatesMfaVerificationFailed,exports.getAccessToken=e.getCustomerAccessToken,exports.useCreateWallet=e.useCreateWallet,exports.useIdentityToken=e.useIdentityToken,exports.useImportWallet=e.useImportWallet,exports.useLogout=e.useLogout,exports.useMfa=e.useMfa,exports.useMfaEnrollment=e.useMfaEnrollment,exports.usePrivy=e.usePrivy,exports.useRegisterMfaListener=e.useRegisterMfaListener,exports.useSolanaWallets=e.useSolanaWallets,exports.useSyncJwtBasedAuthState=e.useSyncJwtBasedAuthState,exports.useWallets=e.useWallets,exports.useActiveWallet=n.useActiveWallet,exports.useConnectWallet=n.useConnectWallet,exports.useFundWallet=n.useFundWallet,exports.useLogin=n.useLogin,Object.defineProperty(exports,"SUPPORTED_CHAINS",{enumerable:!0,get:function(){return y.DEFAULT_SUPPORTED_CHAINS}}),Object.defineProperty(exports,"addPrivyRpcToChain",{enumerable:!0,get:function(){return y.addPrivyRpcToChain}}),Object.defineProperty(exports,"addRpcUrlOverrideToChain",{enumerable:!0,get:function(){return y.addRpcUrlOverrideToChain}}),exports.getEmbeddedConnectedWallet=p.getEmbeddedConnectedWallet,exports.toViemAccount=async({wallet:e})=>{let r=await e.getEthereumProvider();return w.toAccount({address:e.address,sign:async({hash:t})=>{if("privy"!==e.walletClientType)throw new y.PrivyClientError({error:"Unprefixed signing is not supported by external wallets.",code:"unsupported_wallet_type"});return await r.request({method:"secp256k1_sign",params:[t]})},signMessage:async({message:t})=>await r.request({method:"personal_sign",params:[t,e.address]}),signTypedData:async t=>await r.request({method:"eth_signTypedData_v4",params:[e.address,t]}),signTransaction:async e=>await r.request({method:"eth_signTransaction",params:[e]})})},exports.useAuthMfa=m,exports.useAuthMfaEnrollment=()=>{let t=e.useAppConfig(),{setModalData:s}=e.usePrivyModal(),{verify:n}=m(),{openModal:a,privy:l,closePrivyModal:u,refreshSessionAndUser:c,setUser:d}=o.usePrivyInternal();return r.useMemo((()=>({enroll:async()=>new Promise(((e,r)=>{s({mfaEnroll:{onSuccess:async r=>{await u({shouldCallAuthOnSuccess:!1,isSuccess:!0}),e(r)},onFailure:async e=>{await u({shouldCallAuthOnSuccess:!1,isSuccess:!1}),r(e)},verify:()=>n({standalone:!1}),shouldUnlinkOnUnenrollMfa:!0,mfaMethods:t.mfa.methods,sendSmsCode:async()=>{throw Error("Not enabled")},enrollSms:async()=>{throw Error("Not enabled")},unenrollSms:async()=>{throw Error("Not enabled")},generateTotpSecret:async()=>await l.fetchPrivyRoute(i.MfaAuthTotpInit,{body:{}}),enrollTotp:async e=>{await l.fetchPrivyRoute(i.MfaAuthTotpEnroll,{body:{code:e}});let r=await c();return d(r),r},unenrollTotp:async()=>{await l.fetchPrivyRoute(i.MfaAuthTotpUnenroll,{body:{}});let e=await c();return d(e),e},enrollPasskey:async e=>{await l.fetchPrivyRoute(i.MfaAuthPasskeyEnrollment,{body:{credential_ids:e,remove_for_login:!0}});let r=await c();return d(r),r}}}),a(A)}))})),[l,s,a,u])},exports.useAuthorizationSignature=()=>{let{signWithUserSigner:e}=s.useSignWithUserSigner();return r.useMemo((()=>({async generateAuthorizationSignature(r){let{signature:t}=await y.generateAuthorizationSignature(e,r);return{signature:t}}})),[e])},exports.useBaseAccountSdk=()=>{let{baseAccountSdk:e}=o.usePrivyInternal();return{baseAccountSdk:e}},exports.useConnectBaseAccount=()=>{let{connectBaseAccount:e}=o.usePrivyInternal();return{connectBaseAccount:e}},exports.useConnectCoinbaseSmartWallet=()=>{let{connectCoinbaseSmartWallet:e}=o.usePrivyInternal();return{connectCoinbaseSmartWallet:e}},exports.useConnectOrCreateWallet=r=>{let{connectOrCreateWallet:t}=s.usePrivyContext();return e.usePrivyEventSubscription("connectOrCreateWallet",r),{connectOrCreateWallet:t}},exports.useCrossAppAccounts=()=>{let{startCrossAppAuthFlow:e,unlinkCrossAppAccount:r,signMessageWithCrossAppWallet:t,signTypedDataWithCrossAppWallet:o,sendTransactionWithCrossAppWallet:n}=s.usePrivyContext();return{loginWithCrossAppAccount:({appId:r})=>e({appId:r,action:"login"}),linkCrossAppAccount:({appId:r})=>e({appId:r,action:"link"}),unlinkCrossAppAccount:r,signMessage:t,signTypedData:o,sendTransaction:n}},exports.useCustomAuth=r=>{let t=e.useJwtAuthFlowState();return e.usePrivyEventSubscription("customAuth",r),{status:t}},exports.useDelegatedActions=()=>{let{revokeDelegatedWallets:e,delegateWallet:r}=o.usePrivyInternal();return{delegateWallet:async({address:e,chainType:t})=>await r({address:e,chainType:t,showDelegationUIs:!0}),revokeWallets:async()=>await e({showDelegationUIs:!0})}},exports.useFarcasterSigner=function(){let{getFarcasterSignerPublicKey:e,signFarcasterMessage:r,requestFarcasterSignerFromWarpcast:t}=s.usePrivyContext();return{getFarcasterSignerPublicKey:e,signFarcasterMessage:r,requestFarcasterSignerFromWarpcast:t}},exports.useGuestAccounts=function(){let r=e.useAppConfig(),{getAccessToken:n}=s.usePrivyContext(),a=e.useEmitPrivyEvent(),{client:i,setUser:l,setAuthenticated:u,setIsNewUser:c,initializeWalletProxy:d}=o.usePrivyInternal(),{create:h}=e.useCreateWalletInternal();return{createGuestAccount:async()=>{if(!r.id||!i)throw Error("SDK not yet ready");i.startAuthFlow(new e.GuestFlow(r.id));try{let o=await i.authenticate(),s=o.user,y=o.isNewUser??!1;if(!s)throw new t.PrivyClientError("Unable to authenticate guest account");let p=await n(),w=await d(e.WALLET_PROXY_TIMEOUT);if(p&&w)try{let t=e.shouldCreateEmbeddedEthWallet(s,r.embeddedWallets.ethereum.createOnLogin),o=e.shouldCreateEmbeddedSolWallet(s,r.embeddedWallets.solana.createOnLogin);t&&o?(s=(await h({chainType:"ethereum",latestUser:s})).user,s=(await h({chainType:"solana",latestUser:s})).user):o?s=(await h({chainType:"solana",latestUser:s})).user:t?s=(await h({chainType:"ethereum",latestUser:s})).user:l(s)}catch(e){l(s),console.warn("Unable to create embedded wallet for guest account")}return c(y),u(!0),a("login","onComplete",{user:s,isNewUser:y,wasAlreadyAuthenticated:!1,loginMethod:"guest",loginAccount:null}),s}catch(e){throw a("login","onError",e.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}}}},exports.useHeadlessDelegatedActions=()=>{let{revokeDelegatedWallets:e,delegateWallet:r}=o.usePrivyInternal();return{delegateWallet:async({address:e,chainType:t})=>await r({address:e,chainType:t,showDelegationUIs:!1}),revokeWallets:async()=>await e({showDelegationUIs:!1})}},exports.useLinkAccount=function(t){let{linkEmail:o,linkPhone:n,linkWallet:a,linkGoogle:i,linkApple:l,linkTwitter:u,linkDiscord:c,linkGithub:d,linkLinkedIn:h,linkTiktok:y,linkLine:p,linkSpotify:w,linkInstagram:g,linkTelegram:C,linkFarcaster:v,linkPasskey:m}=r.useContext(s.PrivyContext);return e.usePrivyEventSubscription("linkAccount",t),{linkEmail:o,linkPhone:n,linkWallet:a,linkGoogle:i,linkApple:l,linkTwitter:u,linkDiscord:c,linkGithub:d,linkLinkedIn:h,linkTiktok:y,linkLine:p,linkSpotify:w,linkInstagram:g,linkFarcaster:v,linkTelegram:C,linkPasskey:m}},exports.useLinkJwtAccount=function(s){let{client:n}=o.usePrivyInternal(),[a,i]=r.useState({status:"initial"});return{linkWithCustomJwt:r.useCallback((async r=>{try{i({status:"initial"}),n.startAuthFlow(new e.CustomJwtAccountFlow(r)),i({status:"loading"});let{user:t}=await n.link();if(!t)throw Error("Error, user not found");let o=t.linkedAccounts.filter((e=>"custom_auth"===e.type)).sort(((e,r)=>r.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime())).at(0);return i({status:"done"}),s?.onSuccess?.({user:t,linkMethod:"custom",linkedAccount:o}),{user:t}}catch(r){throw i({status:"error",error:r}),s?.onError?.(r.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:"custom"}),r}}),[n.startAuthFlow,n.link]),state:a}},exports.useLinkWithPasskey=e=>{let{initLinkWithPasskey:s,linkWithPasskey:n,passkeyAuthState:a,setPasskeyAuthState:i}=o.usePrivyInternal();return{linkWithPasskey:r.useCallback((async()=>{try{await s();let r=await n();if(!r)throw Error("Error, user not found");let t=r.linkedAccounts.filter((e=>"passkey"===e.type)).sort(((e,r)=>r.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime()))[0];e?.onSuccess?.({user:r,linkMethod:"passkey",linkedAccount:t})}catch(r){throw i({status:"error",error:r}),e?.onError?.(r.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),r}}),[n]),state:a}},exports.useLinkWithSiwe=s=>{let n=e.useCaptcha(),{siweState:a,setSiweState:i,linkWithSiwe:l,generateSiweMessage:u}=o.usePrivyInternal();return{generateSiweMessage:r.useCallback((async({address:e,chainId:r})=>{try{if(!e||!r)throw Error("wallet address and chainId required to generate nonce");return await u({address:e,chainId:r}).then((e=>e))}catch(e){throw i({status:"error",error:e}),s?.onError?.(e.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),e}}),[u]),linkWithSiwe:r.useCallback((async({signature:r,message:o,chainId:a,walletClientType:u,connectorType:c})=>{try{if(n.enabled&&"success"!==n.status)throw new e.CaptchaError(n.error,null,t.PrivyErrorCode.CAPTCHA_FAILURE);let{user:i,linkedAccount:d}=await l({message:o,signature:r,chainId:a,walletClientType:u,connectorType:c});d&&s?.onSuccess?.({user:i,linkMethod:"siwe",linkedAccount:d})}catch(r){throw i({status:"error",error:r}),s?.onError?.(r.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),r}}),[l,n.status]),state:a}},exports.useLoginWithEmail=s=>{let n=e.useCaptcha(),{emailOtpState:a,setEmailOtpState:i,initLoginWithEmail:l,loginWithCode:u}=o.usePrivyInternal();return{sendCode:r.useCallback((async({email:r,disableSignup:o})=>{try{let s;if(!r)throw Error("Email required to send OTP code");if(n.enabled&&"error"===n.status)throw new e.CaptchaError(n.error,null,t.PrivyErrorCode.CAPTCHA_FAILURE);return n.enabled&&"success"!==n.status&&(n.execute(),s=await n.waitForResult()),await l({email:r,captchaToken:s,disableSignup:o,withPrivyUi:!1})}catch(r){throw i({status:"error",error:r}),s?.onError?.(r.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR),r}}),[l]),loginWithCode:r.useCallback((async({code:r})=>{try{if(n.enabled&&"error"===n.status)throw new e.CaptchaError(n.error,null,t.PrivyErrorCode.CAPTCHA_FAILURE);let{user:o,isNewUser:a,wasAlreadyAuthenticated:i,linkedAccount:l}=await u(r);s?.onComplete?.({user:o,isNewUser:a,wasAlreadyAuthenticated:i,loginMethod:"email",loginAccount:l})}catch(r){throw i({status:"error",error:r}),s?.onError?.(r.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR),r}}),[u,n.status]),state:a}},exports.useLoginWithFarcasterV2=()=>{let{client:e,setAuthenticated:s,setUser:n}=o.usePrivyInternal();return r.useMemo((()=>({init:async()=>{if(!e)throw new t.PrivyClientError("Must initialize Privy client first.");let r=new a.FarcasterFramesFlow;return e.startAuthFlow(r),await r.init()},login:async({fid:r,message:o,signature:i})=>{if(!e)throw new t.PrivyClientError("Must initialize Privy client first.");if(!(e.authFlow instanceof a.FarcasterFramesFlow))throw new t.PrivyClientError("Must initialize Farcaster frame flow first.");e.authFlow.setAuthData({message:o,signature:i,fid:r});let{user:l}=await e.authenticate();if(!l)throw new t.PrivyClientError("Failed to login with Farcaster V2");return n(l),s(!0),{user:l}}})),[e,n,s])},exports.useLoginWithOAuth=n=>{e.usePrivyEventSubscription("login",n);let a=e.useCaptcha(),i=e.useIsServerConfigLoaded(),{ready:l,user:u}=s.usePrivyContext(),{initLoginWithHeadlessOAuth:c,loginWithHeadlessOAuth:d,oAuthState:h,setOAuthState:y,isHeadlessOAuthLoading:p}=o.usePrivyInternal(),w=r.useCallback((async r=>{try{if(a.enabled&&"success"!==a.status)throw new e.CaptchaError(a.error,null,t.PrivyErrorCode.CAPTCHA_FAILURE);return await c(r.provider,a.token,r.disableSignup)}catch(r){throw y({status:"error",error:r}),r}}),[c,a]),g=r.useCallback((async()=>{let r=e.detectCompletingOAuthFlow();try{if(u)return console.warn("Cannot login with OAuth when already logged in"),u;if(!r.inProgress)throw Error("Cannot login with OAuth because no OAuth flow is in progress");if(r.popupFlow)return}catch(r){throw y({status:"error",error:r}),r}try{return await d(r)}catch(r){throw y({status:"error",error:r}),r}finally{e.stripUrlOAuthParamsAndRemoveStateCode()}}),[d]);return r.useEffect((()=>{let r=e.detectCompletingOAuthFlow();l&&i&&r.inProgress&&!r.withPrivyUi&&!r.popupFlow&&g().catch((()=>{}))}),[l,i]),{initOAuth:w,loading:p,state:h}},exports.useLoginWithPasskey=s=>{let n=e.useCaptcha(),{initLoginWithPasskey:a,loginWithPasskey:i,passkeyAuthState:l,setPasskeyAuthState:u}=o.usePrivyInternal();return{loginWithPasskey:r.useCallback((async r=>{try{let o;if(n.enabled&&"error"===n.status)throw new e.CaptchaError(n.error,null,t.PrivyErrorCode.CAPTCHA_FAILURE);n.enabled&&"success"!==n.status&&(n.execute(),o=await n.waitForResult()),await a({captchaToken:o,withPrivyUi:!1});let{user:l,isNewUser:u,wasAlreadyAuthenticated:c,loginAccount:d}=await i(r);s?.onComplete?.({user:l,isNewUser:u,wasAlreadyAuthenticated:c,loginMethod:"passkey",loginAccount:d})}catch(r){throw u({status:"error",error:r}),s?.onError?.(r.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR),r}}),[i,n.status]),state:l}},exports.useLoginWithSiwe=s=>{let n=e.useCaptcha(),{siweState:a,setSiweState:i,client:l,generateSiweMessage:u,loginWithSiwe:c}=o.usePrivyInternal();return{generateSiweNonce:r.useCallback((async r=>{try{let o;if(n.enabled&&"error"===n.status)throw new e.CaptchaError(n.error,null,t.PrivyErrorCode.CAPTCHA_FAILURE);n.enabled&&"success"!==n.status&&(n.execute(),o=await n.waitForResult()),i({status:"generating-message"});let s=await l.generateSiweNonce({address:r?.address,captchaToken:o});return i({status:"awaiting-signature"}),s}catch(r){throw i({status:"error",error:r}),s?.onError?.(r.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR),r}}),[l,n]),generateSiweMessage:r.useCallback((async({address:r,chainId:o})=>{try{let s;if(n.enabled&&"error"===n.status)throw new e.CaptchaError(n.error,null,t.PrivyErrorCode.CAPTCHA_FAILURE);return n.enabled&&"success"!==n.status&&(n.execute(),s=await n.waitForResult()),await u({address:r,chainId:o,captchaToken:s})}catch(r){throw i({status:"error",error:r}),s?.onError?.(r.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR),r}}),[u,n]),loginWithSiwe:r.useCallback((async({message:r,signature:o,disableSignup:a})=>{try{let i;if(n.enabled&&"error"===n.status)throw new e.CaptchaError(n.error,null,t.PrivyErrorCode.CAPTCHA_FAILURE);n.enabled&&"success"!==n.status&&(n.execute(),i=await n.waitForResult());let l=await c({message:r,signature:o,captchaToken:i,disableSignup:a});return s?.onComplete?.({user:l,isNewUser:!1,wasAlreadyAuthenticated:!1,loginMethod:"siwe",loginAccount:null}),l}catch(r){throw i({status:"error",error:r}),s?.onError?.(r.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR),r}}),[c,n.status]),state:a}},exports.useLoginWithSms=s=>{let n=e.useCaptcha(),{smsOtpState:a,setSmsOtpState:i,initLoginWithSms:l,loginWithCode:u}=o.usePrivyInternal();return{sendCode:r.useCallback((async({phoneNumber:r,disableSignup:o})=>{try{let s;if(!r)throw Error("SMS required to send OTP code");if(n.enabled&&"error"===n.status)throw new e.CaptchaError(n.error,null,t.PrivyErrorCode.CAPTCHA_FAILURE);return n.enabled&&"success"!==n.status&&(n.execute(),s=await n.waitForResult()),await l({phoneNumber:r,captchaToken:s,disableSignup:o,withPrivyUi:!1})}catch(r){throw i({status:"error",error:r}),s?.onError?.(r.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR),r}}),[l]),loginWithCode:r.useCallback((async({code:r})=>{try{if(n.enabled&&"error"===n.status)throw new e.CaptchaError(n.error,null,t.PrivyErrorCode.CAPTCHA_FAILURE);let{user:o,isNewUser:a,wasAlreadyAuthenticated:i,linkedAccount:l}=await u(r);s?.onComplete?.({user:o,isNewUser:a,wasAlreadyAuthenticated:i,loginMethod:"sms",loginAccount:l})}catch(r){throw i({status:"error",error:r}),s?.onError?.(r.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR),r}}),[u,n.status]),state:a}},exports.useLoginWithTelegram=s=>{let n=e.useCaptcha(),{initLoginWithTelegram:a,loginWithTelegram:i,telegramAuthState:l,setTelegramAuthState:u}=o.usePrivyInternal();return{login:r.useCallback((async r=>{try{if(n.enabled&&"success"!==n.status)throw new e.CaptchaError(n.error,null,t.PrivyErrorCode.CAPTCHA_FAILURE);await a(n.token,r?.disableSignup);let{user:o,isNewUser:l,loginAccount:u,wasAlreadyAuthenticated:c}=await i({intent:"login"});s?.onComplete?.({user:o,isNewUser:l,wasAlreadyAuthenticated:c,loginMethod:"telegram",loginAccount:u})}catch(r){throw u({status:"error",error:r}),s?.onError?.(r.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR),r}}),[a,i,n]),state:l}},exports.useModalStatus=()=>{let{isModalOpen:e}=r.useContext(s.PrivyContext);return{isOpen:e}},exports.useOAuthTokens=function(r){let{authenticated:t,user:n}=s.usePrivyContext(),{initLoginWithOAuth:a}=o.usePrivyInternal(),i=e.useEmitPrivyEvent();return e.usePrivyEventSubscription("oAuthAuthorization",r),{reauthorize:e=>E(t,n,a,i,e.provider)}},exports.useRecoverEmbeddedWallet=()=>{let{user:n}=s.usePrivyContext(),{walletProxy:a}=o.usePrivyInternal();return{recover:r.useCallback((async r=>{if(!a)throw Error("Wallet proxy is not ready");let o=await e.getAccessToken();if(!n||!o)throw new t.PrivyClientError("User must be logged in before attempting to modify the recovery method.");let{entropyId:s,entropyIdVerifier:i}=e.getEntropyDetailsForUser(n);try{await a.recover({entropyId:s,entropyIdVerifier:i,accessToken:o,...r})}catch{throw new t.PrivyClientError("Unable to recover wallets")}}),[a,n])}},exports.useSendTransaction=function(t){let{sendTransaction:o}=r.useContext(s.PrivyContext);return e.usePrivyEventSubscription("sendTransaction",t),{sendTransaction:o}},exports.useSessionSigners=()=>{let{addSessionSignersInternal:r,removeSessionSignersInternal:n}=(()=>{let{getAccessToken:r,user:n}=s.usePrivyContext(),a=o.usePrivyInternal(),{signWithUserSigner:i}=s.useSignWithUserSigner(),l=async({wallet:e,additional_signers:o})=>{let s=await r();if(!n||!s)throw new t.PrivyClientError("User must be authenticated and have an embedded wallet to delegate actions.");if(!e.id)throw new t.PrivyClientError("Wallet to add signers to must have ID on server");if(!a.walletProxy)throw new t.PrivyClientError("Wallet proxy not initialized.");await y.updateWallet(a.privy,{wallet_id:e.id},i,{additional_signers:o})};return{addSessionSignersInternal:async({address:o,signers:i})=>{let u=await r();if(!n||!u)throw new t.PrivyClientError("User must be authenticated and have an embedded wallet to add a session signer.");let c=a.walletProxy??await a.initializeWalletProxy(15e3);if(!c)throw new t.PrivyClientError("Wallet proxy not initialized.");let d=s.getPrivyWalletWithAddress(n,o);if(!d)throw new t.PrivyClientError("Address to add signers too is not associated with current user.");if(s.getIsUnifiedWallet(d)){if(0===i.length)throw new t.PrivyClientError("Must specify at least one signer to add.");let r=[...(await y.getWallet(a.privy,{wallet_id:d.id})).additional_signers,...e.parseAdditionalSigners(i)];await l({wallet:d,additional_signers:r})}else{if(d.delegated)return{user:n};if(i.length>0)throw new t.PrivyClientError("Specifying signers in addSessionSigners is only supported for TEE execution and this app uses On-device execution. Pass an empty array for signers instead. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide");let r=e.getDelegatedWalletsData({address:o,user:n}),s=e.getRootWalletDataForDelegation({address:o,user:n});await a.recoverEmbeddedWallet({address:o}),await c.createDelegatedAction({accessToken:u,rootWallet:s,delegatedWallets:[r]})}let h=await a.refreshSessionAndUser();if(!h)throw Error("Could not refresh user");return{user:h}},removeSessionSignersInternal:async({address:e})=>{let o=await r();if(!n||!o)throw new t.PrivyClientError("User must be authenticated and have an embedded wallet to delegate actions.");if(!(a.walletProxy??await a.initializeWalletProxy(15e3)))throw new t.PrivyClientError("Wallet proxy not initialized.");let i=s.getPrivyWalletWithAddress(n,e);if(!i)throw new t.PrivyClientError("Address to remove signers from is not associated with current user.");s.getIsUnifiedWallet(i)?await l({wallet:i,additional_signers:[]}):await a.client.revokeDelegatedWallet();let u=await a.refreshSessionAndUser();if(!u)throw Error("Could not refresh user");return{user:u}}}})();return{addSessionSigners:async({address:e,signers:t})=>r({address:e,signers:t}),removeSessionSigners:async({address:e})=>n({address:e})}},exports.useSetWalletPassword=function(t){let{setWalletPassword:o}=r.useContext(s.PrivyContext);return e.usePrivyEventSubscription("setWalletPassword",t),{setWalletPassword:o}},exports.useSetWalletRecovery=function(t){let{setWalletRecovery:o}=r.useContext(s.PrivyContext);return e.usePrivyEventSubscription("setWalletRecovery",t),{setWalletRecovery:o}},exports.useSign7702Authorization=f,exports.useSignAuthorization=P,exports.useSignMessage=function(t){let{signMessage:o}=r.useContext(s.PrivyContext);return e.usePrivyEventSubscription("signMessage",t),{signMessage:o}},exports.useSignTransaction=function(){let{signTransaction:e}=r.useContext(s.PrivyContext);return{signTransaction:e}},exports.useSignTypedData=function(t){let{signTypedData:o}=r.useContext(s.PrivyContext);return e.usePrivyEventSubscription("signTypedData",t),{signTypedData:o}},exports.useSignupWithPasskey=s=>{let n=e.useCaptcha(),{initSignupWithPasskey:a,signupWithPasskey:i,passkeyAuthState:l,setPasskeyAuthState:u}=o.usePrivyInternal();return{signupWithPasskey:r.useCallback((async()=>{try{let r;if(n.enabled&&"error"===n.status)throw new e.CaptchaError(n.error,null,t.PrivyErrorCode.CAPTCHA_FAILURE);n.enabled&&"success"!==n.status&&(n.execute(),r=await n.waitForResult()),await a({captchaToken:r,withPrivyUi:!1});let{user:o,isNewUser:l,wasAlreadyAuthenticated:u,loginAccount:c}=await i();s?.onComplete?.({user:o,isNewUser:l,wasAlreadyAuthenticated:u,loginMethod:"passkey",loginAccount:c})}catch(e){throw u({status:"error",error:e}),s?.onError?.(e.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}}),[i,n.status]),state:l}},exports.useSubscribeToJwtAuthWithFlag=function({isAuthenticated:t,isLoading:o,...s}){let n=r.useRef();r.useEffect((()=>{o||n.current?.()}),[t,o]);let a=r.useCallback((e=>(n.current=e,()=>{n.current=void 0})),[]);return e.useSyncJwtBasedAuthState({...s,subscribe:a})},exports.useToken=function(t){let{getAccessToken:o}=r.useContext(s.PrivyContext);return e.usePrivyEventSubscription("accessToken",t),{getAccessToken:o}},exports.useUpdateAccount=function(t){let{updateEmail:o,updatePhone:n}=r.useContext(s.PrivyContext);return e.usePrivyEventSubscription("update",t),{updateEmail:o,updatePhone:n}},exports.useUpdateEmail=n=>{let{user:a}=s.usePrivyContext(),{loginWithCode:i,emailOtpState:l,setEmailOtpState:u,client:c,inProgressAuthFlowRef:d,inProgressLoginOrLinkMethodRef:h}=o.usePrivyInternal();return{state:l,sendCode:r.useCallback((async({newEmailAddress:r})=>{try{if(!a?.email)throw Error("User is required to have an email address to update it.");let t=new e.UpdateEmailFlow(a.email.address,r);c.startAuthFlow(t),await t.sendCodeEmail({withPrivyUi:!1})}catch(r){u({status:"error",error:r}),n?.onError?.(r.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:"email"})}}),[a?.email]),verifyCode:r.useCallback((async({code:e})=>{try{if(!a?.email)throw Error("User is required to have an email address to update it.");d.current="update",h.current="email";let{user:r,linkedAccount:t}=await i(e);return n?.onSuccess?.({user:r,updateMethod:"email",updatedAccount:t}),{user:r}}catch(e){u({status:"error",error:e}),n?.onError?.(e.privyErrorCode||t.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:"email"})}}),[a?.email])}},exports.useUser=()=>{let{setUser:e,client:t}=r.useContext(o.InternalPrivyContext),{user:n}=r.useContext(s.PrivyContext);return{user:n,refreshUser:r.useCallback((async()=>{let r=await(t?.updateUserAndIdToken());return e(r??null),r}),[t,e])}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("react");const e=()=>{throw Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")},i=/*#__PURE__*/t.createContext({setAuthenticated:e,setUser:e,setIsNewUser:e,isNewUserThisSession:!1,walletConnectionStatus:null,setWalletConnectionStatus:e,connectors:[],solanaWallets:[],rpcConfig:{rpcUrls:{}},showFiatPrices:!0,chains:[],clientAnalyticsId:null,pendingTransaction:null,client:null,privy:null,appId:"notAdded",onCustomAuthAuthenticated:e,hideWalletUIs:{current:!1},nativeTokenSymbolForChainId:e,initializeWalletProxy:e,getAuthMeta:e,getAuthFlow:e,closePrivyModal:e,openPrivyModal:e,connectWallet:e,initLoginWithWallet:e,loginWithWallet:e,initLoginWithFarcaster:e,loginWithFarcaster:e,loginWithCode:e,initLoginWithEmail:e,initLoginWithSms:e,initUpdateEmail:e,initUpdatePhone:e,resendEmailCode:e,resendSmsCode:e,initLoginWithHeadlessOAuth:e,loginWithHeadlessOAuth:e,crossAppAuthFlow:e,initLoginWithOAuth:e,loginWithOAuth:e,passkeyAuthState:{status:"initial"},setPasskeyAuthState:e,initSignupWithPasskey:e,signupWithPasskey:e,initLoginWithPasskey:e,loginWithPasskey:e,initLinkWithPasskey:e,linkWithPasskey:e,refreshSessionAndUser:e,walletProxy:null,createAnalyticsEvent:e,acceptTerms:e,getUsdTokenPrice:e,getUsdPriceForSol:e,getSplTokenMetadata:e,recoverEmbeddedWallet:e,updateWallets:e,fundWallet:e,openModal:e,setReadyToTrue:e,requestFarcasterSignerStatus:e,initLoginWithTelegram:e,loginWithTelegram:e,generateSiweMessage:e,generateSiweMessageForSmartWallet:e,loginWithSiwe:e,linkWithSiwe:e,linkSmartWallet:e,delegateWallet:e,revokeDelegatedWallets:e,exportSolanaWallet:e,connectCoinbaseSmartWallet:e,connectBaseAccount:e,initiateAccountTransfer:e,emailOtpState:{status:"initial"},setEmailOtpState:e,smsOtpState:{status:"initial"},setSmsOtpState:e,siweState:{status:"initial"},setSiweState:e,oAuthState:{status:"initial"},setOAuthState:e,telegramAuthState:{status:"initial"},setTelegramAuthState:e,isHeadlessOAuthLoading:!1,isHeadlessSigning:e,inProgressAuthFlowRef:{current:null},inProgressLoginOrLinkMethodRef:{current:null}});exports.InternalPrivyContext=i,exports.notImplemented=e,exports.notImplementedWithMessage=t=>()=>{throw Error(t.trim())},exports.usePrivyInternal=()=>t.useContext(i);
|
|
1
|
+
"use strict";var t=require("react");const e=()=>{throw Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")},i=/*#__PURE__*/t.createContext({setAuthenticated:e,setUser:e,setIsNewUser:e,isNewUserThisSession:!1,walletConnectionStatus:null,setWalletConnectionStatus:e,connectors:[],solanaWallets:[],rpcConfig:{rpcUrls:{}},showFiatPrices:!0,chains:[],clientAnalyticsId:null,pendingTransaction:null,client:null,privy:null,appId:"notAdded",onCustomAuthAuthenticated:e,hideWalletUIs:{current:!1},nativeTokenSymbolForChainId:e,initializeWalletProxy:e,getAuthMeta:e,getAuthFlow:e,closePrivyModal:e,openPrivyModal:e,connectWallet:e,initLoginWithWallet:e,loginWithWallet:e,initLoginWithFarcaster:e,loginWithFarcaster:e,loginWithCode:e,initLoginWithEmail:e,initLoginWithSms:e,initUpdateEmail:e,initUpdatePhone:e,resendEmailCode:e,resendSmsCode:e,initLoginWithHeadlessOAuth:e,loginWithHeadlessOAuth:e,crossAppAuthFlow:e,initLoginWithOAuth:e,loginWithOAuth:e,passkeyAuthState:{status:"initial"},setPasskeyAuthState:e,initSignupWithPasskey:e,signupWithPasskey:e,initLoginWithPasskey:e,loginWithPasskey:e,initLinkWithPasskey:e,linkWithPasskey:e,refreshSessionAndUser:e,walletProxy:null,createAnalyticsEvent:e,acceptTerms:e,getUsdTokenPrice:e,getUsdPriceForSol:e,getSplTokenMetadata:e,recoverEmbeddedWallet:e,updateWallets:e,fundWallet:e,openModal:e,setReadyToTrue:e,requestFarcasterSignerStatus:e,initLoginWithTelegram:e,loginWithTelegram:e,generateSiweMessage:e,generateSiweMessageForSmartWallet:e,loginWithSiwe:e,linkWithSiwe:e,linkSmartWallet:e,delegateWallet:e,revokeDelegatedWallets:e,exportSolanaWallet:e,connectCoinbaseSmartWallet:e,connectBaseAccount:e,initiateAccountTransfer:e,emailOtpState:{status:"initial"},setEmailOtpState:e,smsOtpState:{status:"initial"},setSmsOtpState:e,siweState:{status:"initial"},setSiweState:e,oAuthState:{status:"initial"},setOAuthState:e,telegramAuthState:{status:"initial"},setTelegramAuthState:e,isHeadlessOAuthLoading:!1,isHeadlessSigning:e,inProgressAuthFlowRef:{current:null},inProgressLoginOrLinkMethodRef:{current:null},baseAccountSdk:void 0,setBaseAccountSdk:e});exports.InternalPrivyContext=i,exports.notImplemented=e,exports.notImplementedWithMessage=t=>()=>{throw Error(t.trim())},exports.usePrivyInternal=()=>t.useContext(i);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t,e=require("ofetch");class s extends Error{toString(){return`${this.type}${this.privyErrorCode?`-${this.privyErrorCode}`:""}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}constructor(t,e,s){super(t),e instanceof Error&&(this.cause=e),this.privyErrorCode=s}}class a extends s{constructor(t,e,s,a,r,i){super(s,a,r),this.type=t,this.status=e,this.data=i}}class r extends s{constructor(t,e,s){super(t,e,s),this.type="client_error"}}const i=t=>t instanceof s?t:t instanceof Error?new r(t.message,t):new r(`Internal error: ${t}`);var n=((t={}).OAUTH_ACCOUNT_SUSPENDED="oauth_account_suspended",t.MISSING_OR_INVALID_PRIVY_APP_ID="missing_or_invalid_privy_app_id",t.MISSING_OR_INVALID_PRIVY_ACCOUNT_ID="missing_or_invalid_privy_account_id",t.MISSING_OR_INVALID_TOKEN="missing_or_invalid_token",t.INVALID_DATA="invalid_data",t.INVALID_CAPTCHA="invalid_captcha",t.LINKED_TO_ANOTHER_USER="linked_to_another_user",t.CANNOT_LINK_MORE_OF_TYPE="cannot_link_more_of_type",t.FAILED_TO_LINK_ACCOUNT="failed_to_link_account",t.FAILED_TO_UPDATE_ACCOUNT="failed_to_update_account",t.USER_EXITED_UPDATE_FLOW="exited_update_flow",t.ALLOWLIST_REJECTED="allowlist_rejected",t.OAUTH_USER_DENIED="oauth_user_denied",t.OAUTH_UNEXPECTED="oauth_unexpected",t.UNKNOWN_AUTH_ERROR="unknown_auth_error",t.USER_EXITED_AUTH_FLOW="exited_auth_flow",t.USER_EXITED_LINK_FLOW="exited_link_flow",t.USER_EXITED_SET_PASSWORD_FLOW="user_exited_set_password_flow",t.MUST_BE_AUTHENTICATED="must_be_authenticated",t.UNKNOWN_CONNECT_WALLET_ERROR="unknown_connect_wallet_error",t.GENERIC_CONNECT_WALLET_ERROR="generic_connect_wallet_error",t.CLIENT_REQUEST_TIMEOUT="client_request_timeout",t.INVALID_CREDENTIALS="invalid_credentials",t.MISSING_MFA_CREDENTIALS="missing_or_invalid_mfa",t.UNKNOWN_MFA_ERROR="unknown_mfa_error",t.EMBEDDED_WALLET_ALREADY_EXISTS="embedded_wallet_already_exists",t.EMBEDDED_WALLET_NOT_FOUND="embedded_wallet_not_found",t.EMBEDDED_WALLET_CREATE_ERROR="embedded_wallet_create_error",t.UNKNOWN_EMBEDDED_WALLET_ERROR="unknown_embedded_wallet_error",t.EMBEDDED_WALLET_PASSWORD_UNCONFIRMED="embedded_wallet_password_unconfirmed",t.EMBEDDED_WALLET_PASSWORD_ALREADY_EXISTS="embedded_wallet_password_already_exists",t.EMBEDDED_WALLET_RECOVERY_ALREADY_EXISTS="embedded_wallet_recovery_already_exists",t.TRANSACTION_FAILURE="transaction_failure",t.UNSUPPORTED_CHAIN_ID="unsupported_chain_id",t.NOT_SUPPORTED="not_supported",t.CAPTCHA_TIMEOUT="captcha_timeout",t.INVALID_MESSAGE="invalid_message",t.UNABLE_TO_SIGN="unable_to_sign",t.CAPTCHA_FAILURE="captcha_failure",t.CAPTCHA_DISABLED="captcha_disabled",t.SESSION_STORAGE_UNAVAILABLE="session_storage_unavailable",t.TOO_MANY_REQUESTS="too_many_requests",t.USER_LIMIT_REACHED="max_accounts_reached",t.DISALLOWED_LOGIN_METHOD="disallowed_login_method",t.DISALLOWED_PLUS_EMAIL="disallowed_plus_email",t.PASSKEY_NOT_ALLOWED="passkey_not_allowed",t.USER_DOES_NOT_EXIST="user_does_not_exist",t.INSUFFICIENT_BALANCE="insufficient_balance",t.ACCOUNT_TRANSFER_REQUIRED="account_transfer_required",t.BUFFER_NOT_DEFINED="buffer_not_defined",t.UNSUPPORTED_WALLET_TYPE="unsupported_wallet_type",t);exports.PrivyApiError=a,exports.PrivyClientError=r,exports.PrivyConnectorError=class extends s{constructor(t,e,s){super(t,e,s),this.type="connector_error"}},exports.PrivyEmbeddedWalletError=class extends r{constructor(t="Embedded wallet error",e){super(t,e,"unknown_embedded_wallet_error")}},exports.PrivyError=s,exports.PrivyErrorCode=n,exports.PrivyNotReadyError=class extends r{constructor(){super("Method called before `ready`. Ensure you wait until `ready` is true before calling.")}},exports.PrivyTimeoutError=class extends r{constructor(){super("Request timed out",void 0,"client_request_timeout")}},exports.PrivyUnauthenticatedError=class extends r{constructor(t="User must be authenticated"){super(t,void 0,"must_be_authenticated")}},exports.PrivyUserLimitReachedError=class extends r{constructor(t){super("This application is in development mode and must be upgraded to production to log in new users.",t,"max_accounts_reached")}},exports.acceptTermsPath="/api/v1/users/me/accept_terms",exports.analyticsEventsPath="/api/v1/analytics_events",exports.authenticateFarcasterV2Path="api/v2/farcaster/authenticate",exports.coinbaseOnRampInitPath="/api/v1/funding/coinbase_on_ramp/init",exports.coinbaseOnRampStatusPath="/api/v1/funding/coinbase_on_ramp/status",exports.customJwtAccountAuthenticatePath="/api/v1/custom_jwt_account/authenticate",exports.customJwtAccountLinkPath="/api/v1/custom_jwt_account/link",exports.delegatedActionsRevokePath="/api/v1/wallets/revoke",exports.farcasterAuthenticatePath="/api/v1/farcaster/authenticate",exports.farcasterInitPath="/api/v1/farcaster/init",exports.farcasterLinkPath="/api/v1/farcaster/link",exports.farcasterStatusPath="/api/v1/farcaster/status",exports.formatApiError=t=>{if(t instanceof s)return t;if(!(t instanceof e.FetchError))return i(t);if(!t.response)return new a("api_error",null,t.message,t);let{type:r,message:n,error:o,code:_}=t.data;return new a(r||"ApiError",t.response.status,n||o,t,_,t.data)},exports.formatPrivyError=i,exports.guestAccountAuthenticatePath="/api/v1/guest/authenticate",exports.initFarcasterV2Path="api/v2/farcaster/init",exports.mfaPasskeyInitPath="/api/v1/mfa/passkeys/init",exports.mfaPasswordlessSmsInitPath="/api/v1/mfa/passwordless_sms/init",exports.moonpayPluginOnRampPath="/api/v1/plugins/moonpay_on_ramp/sign",exports.oAuthAuthenticatePath="/api/v1/oauth/authenticate",exports.oAuthInitPath="/api/v1/oauth/init",exports.oAuthLinkPath="/api/v1/oauth/link",exports.passkeyAuthenticatePath="/api/v1/passkeys/authenticate",exports.passkeyInitAuthenticatePath="/api/v1/passkeys/authenticate/init",exports.passkeyInitLinkPath="/api/v1/passkeys/link/init",exports.passkeyInitRegisterPath="/api/v1/passkeys/register/init",exports.passkeyLinkPath="/api/v1/passkeys/link",exports.passkeyRegisterPath="/api/v1/passkeys/register",exports.passwordlessAuthenticatePath="/api/v1/passwordless/authenticate",exports.passwordlessInitPath="/api/v1/passwordless/init",exports.passwordlessLinkPath="/api/v1/passwordless/link",exports.passwordlessSmsAuthenticatePath="/api/v1/passwordless_sms/authenticate",exports.passwordlessSmsInitPath="/api/v1/passwordless_sms/init",exports.passwordlessSmsLinkPath="/api/v1/passwordless_sms/link",exports.recoveryOAuthAuthenticatePath="/api/v1/recovery/oauth/authenticate",exports.recoveryOAuthInitICloudPath="/api/v1/recovery/oauth/init_icloud",exports.recoveryOAuthInitPath="/api/v1/recovery/oauth/init",exports.sessionsLogoutPath="/api/v1/sessions/logout",exports.sessionsRefreshPath="/api/v1/sessions",exports.siweAuthenticatePath="/api/v1/siwe/authenticate",exports.siweInitPath="/api/v1/siwe/init",exports.siweLinkPath="/api/v1/siwe/link",exports.siwsAuthenticatePath="/api/v1/siws/authenticate",exports.siwsInitPath="/api/v1/siws/init",exports.siwsLinkPath="/api/v1/siws/link",exports.siwsUnlinkWalletPath="/api/v1/siws/unlink",exports.smartWalletLinkPath="/api/v1/siwe/link_smart_wallet",exports.telegramAccountAuthenticatePath="/api/v1/telegram/authenticate",exports.telegramAccountLinkPath="/api/v1/telegram/link",exports.telegramAccountTransferPath="/api/v1/telegram/transfer",exports.telegramAccountUnlinkPath="/api/v1/telegram/unlink",exports.transactionScanningPath="/api/v1/scan/transaction",exports.transferEmailPath="/api/v1/passwordless/transfer",exports.transferFarcasterPath="/api/v1/farcaster/transfer",exports.transferOAuthPath="/api/v1/oauth/transfer",exports.transferPhonePath="/api/v1/passwordless_sms/transfer",exports.transferWalletPath="/api/v1/siwe/transfer",exports.unlinkEmailPath="/api/v1/passwordless/unlink",exports.unlinkFarcasterPath="/api/v1/farcaster/unlink",exports.unlinkOAuthPath="/api/v1/oauth/unlink",exports.unlinkPhonePath="/api/v1/passwordless_sms/unlink",exports.unlinkWalletPath="/api/v1/siwe/unlink",exports.updateEmailPath="/api/v1/passwordless/update",exports.updatePhonePath="/api/v1/passwordless_sms/update",exports.usersMePath="/api/v1/users/me";
|
|
1
|
+
"use strict";var t,e=require("ofetch");class s extends Error{toString(){return`${this.type}${this.privyErrorCode?`-${this.privyErrorCode}`:""}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}constructor(t,e,s){super(t),e instanceof Error&&(this.cause=e),this.privyErrorCode=s}}class a extends s{constructor(t,e,s,a,r,i){super(s,a,r),this.type=t,this.status=e,this.data=i}}class r extends s{constructor(t,e,s){super(t,e,s),this.type="client_error"}}const i=t=>t instanceof s?t:t instanceof Error?new r(t.message,t):new r(`Internal error: ${t}`);var n=((t={}).OAUTH_ACCOUNT_SUSPENDED="oauth_account_suspended",t.MISSING_OR_INVALID_PRIVY_APP_ID="missing_or_invalid_privy_app_id",t.MISSING_OR_INVALID_PRIVY_ACCOUNT_ID="missing_or_invalid_privy_account_id",t.MISSING_OR_INVALID_TOKEN="missing_or_invalid_token",t.INVALID_DATA="invalid_data",t.INVALID_CAPTCHA="invalid_captcha",t.LINKED_TO_ANOTHER_USER="linked_to_another_user",t.CANNOT_LINK_MORE_OF_TYPE="cannot_link_more_of_type",t.FAILED_TO_LINK_ACCOUNT="failed_to_link_account",t.FAILED_TO_UPDATE_ACCOUNT="failed_to_update_account",t.USER_EXITED_UPDATE_FLOW="exited_update_flow",t.ALLOWLIST_REJECTED="allowlist_rejected",t.OAUTH_USER_DENIED="oauth_user_denied",t.OAUTH_UNEXPECTED="oauth_unexpected",t.UNKNOWN_AUTH_ERROR="unknown_auth_error",t.USER_EXITED_AUTH_FLOW="exited_auth_flow",t.USER_EXITED_LINK_FLOW="exited_link_flow",t.USER_EXITED_SET_PASSWORD_FLOW="user_exited_set_password_flow",t.MUST_BE_AUTHENTICATED="must_be_authenticated",t.UNKNOWN_CONNECT_WALLET_ERROR="unknown_connect_wallet_error",t.GENERIC_CONNECT_WALLET_ERROR="generic_connect_wallet_error",t.CLIENT_REQUEST_TIMEOUT="client_request_timeout",t.INVALID_CREDENTIALS="invalid_credentials",t.MISSING_MFA_CREDENTIALS="missing_or_invalid_mfa",t.UNKNOWN_MFA_ERROR="unknown_mfa_error",t.EMBEDDED_WALLET_ALREADY_EXISTS="embedded_wallet_already_exists",t.EMBEDDED_WALLET_NOT_FOUND="embedded_wallet_not_found",t.EMBEDDED_WALLET_CREATE_ERROR="embedded_wallet_create_error",t.UNKNOWN_EMBEDDED_WALLET_ERROR="unknown_embedded_wallet_error",t.EMBEDDED_WALLET_PASSWORD_UNCONFIRMED="embedded_wallet_password_unconfirmed",t.EMBEDDED_WALLET_PASSWORD_ALREADY_EXISTS="embedded_wallet_password_already_exists",t.EMBEDDED_WALLET_RECOVERY_ALREADY_EXISTS="embedded_wallet_recovery_already_exists",t.TRANSACTION_FAILURE="transaction_failure",t.UNSUPPORTED_CHAIN_ID="unsupported_chain_id",t.NOT_SUPPORTED="not_supported",t.CAPTCHA_TIMEOUT="captcha_timeout",t.INVALID_MESSAGE="invalid_message",t.UNABLE_TO_SIGN="unable_to_sign",t.CAPTCHA_FAILURE="captcha_failure",t.CAPTCHA_DISABLED="captcha_disabled",t.SESSION_STORAGE_UNAVAILABLE="session_storage_unavailable",t.TOO_MANY_REQUESTS="too_many_requests",t.USER_LIMIT_REACHED="max_accounts_reached",t.DISALLOWED_LOGIN_METHOD="disallowed_login_method",t.DISALLOWED_PLUS_EMAIL="disallowed_plus_email",t.PASSKEY_NOT_ALLOWED="passkey_not_allowed",t.USER_DOES_NOT_EXIST="user_does_not_exist",t.INSUFFICIENT_BALANCE="insufficient_balance",t.ACCOUNT_TRANSFER_REQUIRED="account_transfer_required",t.BUFFER_NOT_DEFINED="buffer_not_defined",t.UNSUPPORTED_WALLET_TYPE="unsupported_wallet_type",t);exports.PrivyApiError=a,exports.PrivyClientError=r,exports.PrivyConnectorError=class extends s{constructor(t,e,s){super(t,e,s),this.type="connector_error"}},exports.PrivyEmbeddedWalletError=class extends r{constructor(t="Embedded wallet error",e){super(t,e,"unknown_embedded_wallet_error")}},exports.PrivyError=s,exports.PrivyErrorCode=n,exports.PrivyNotReadyError=class extends r{constructor(){super("Method called before `ready`. Ensure you wait until `ready` is true before calling.")}},exports.PrivyTimeoutError=class extends r{constructor(){super("Request timed out",void 0,"client_request_timeout")}},exports.PrivyUnauthenticatedError=class extends r{constructor(t="User must be authenticated"){super(t,void 0,"must_be_authenticated")}},exports.PrivyUserLimitReachedError=class extends r{constructor(t){super("This application is in development mode and must be upgraded to production to log in new users.",t,"max_accounts_reached")}},exports.acceptTermsPath="/api/v1/users/me/accept_terms",exports.analyticsEventsPath="/api/v1/analytics_events",exports.authenticateFarcasterV2Path="api/v2/farcaster/authenticate",exports.coinbaseOnRampInitPath="/api/v1/funding/coinbase_on_ramp/init",exports.coinbaseOnRampStatusPath="/api/v1/funding/coinbase_on_ramp/status",exports.customJwtAccountAuthenticatePath="/api/v1/custom_jwt_account/authenticate",exports.customJwtAccountLinkPath="/api/v1/custom_jwt_account/link",exports.delegatedActionsRevokePath="/api/v1/wallets/revoke",exports.farcasterAuthenticatePath="/api/v1/farcaster/authenticate",exports.farcasterInitPath="/api/v1/farcaster/init",exports.farcasterLinkPath="/api/v1/farcaster/link",exports.farcasterStatusPath="/api/v1/farcaster/status",exports.formatApiError=t=>{if(t instanceof s)return t;if(!(t instanceof e.FetchError))return i(t);if(!t.response)return new a("api_error",null,t.message,t);let{type:r,message:n,error:o,code:_}=t.data;return new a(r||"ApiError",t.response.status,n||o,t,_,t.data)},exports.formatPrivyError=i,exports.guestAccountAuthenticatePath="/api/v1/guest/authenticate",exports.initFarcasterV2Path="api/v2/farcaster/init",exports.mfaPasskeyInitPath="/api/v1/mfa/passkeys/init",exports.mfaPasswordlessSmsInitPath="/api/v1/mfa/passwordless_sms/init",exports.moonpayPluginOnRampPath="/api/v1/plugins/moonpay_on_ramp/sign",exports.oAuthAuthenticatePath="/api/v1/oauth/authenticate",exports.oAuthInitPath="/api/v1/oauth/init",exports.oAuthLinkPath="/api/v1/oauth/link",exports.passkeyAuthenticatePath="/api/v1/passkeys/authenticate",exports.passkeyInitAuthenticatePath="/api/v1/passkeys/authenticate/init",exports.passkeyInitLinkPath="/api/v1/passkeys/link/init",exports.passkeyInitRegisterPath="/api/v1/passkeys/register/init",exports.passkeyLinkPath="/api/v1/passkeys/link",exports.passkeyRegisterPath="/api/v1/passkeys/register",exports.passwordlessAuthenticatePath="/api/v1/passwordless/authenticate",exports.passwordlessInitPath="/api/v1/passwordless/init",exports.passwordlessLinkPath="/api/v1/passwordless/link",exports.passwordlessSmsAuthenticatePath="/api/v1/passwordless_sms/authenticate",exports.passwordlessSmsInitPath="/api/v1/passwordless_sms/init",exports.passwordlessSmsLinkPath="/api/v1/passwordless_sms/link",exports.recoveryOAuthAuthenticatePath="/api/v1/recovery/oauth/authenticate",exports.recoveryOAuthInitICloudPath="/api/v1/recovery/oauth/init_icloud",exports.recoveryOAuthInitPath="/api/v1/recovery/oauth/init",exports.sessionsLogoutPath="/api/v1/sessions/logout",exports.sessionsRefreshPath="/api/v1/sessions",exports.siweAuthenticatePath="/api/v1/siwe/authenticate",exports.siweInitPath="/api/v1/siwe/init",exports.siweLinkPath="/api/v1/siwe/link",exports.siwsAuthenticatePath="/api/v1/siws/authenticate",exports.siwsInitPath="/api/v1/siws/init",exports.siwsLinkPath="/api/v1/siws/link",exports.siwsTransferPath="/api/v1/siws/transfer",exports.siwsUnlinkWalletPath="/api/v1/siws/unlink",exports.smartWalletLinkPath="/api/v1/siwe/link_smart_wallet",exports.telegramAccountAuthenticatePath="/api/v1/telegram/authenticate",exports.telegramAccountLinkPath="/api/v1/telegram/link",exports.telegramAccountTransferPath="/api/v1/telegram/transfer",exports.telegramAccountUnlinkPath="/api/v1/telegram/unlink",exports.transactionScanningPath="/api/v1/scan/transaction",exports.transferEmailPath="/api/v1/passwordless/transfer",exports.transferFarcasterPath="/api/v1/farcaster/transfer",exports.transferOAuthPath="/api/v1/oauth/transfer",exports.transferPhonePath="/api/v1/passwordless_sms/transfer",exports.transferWalletPath="/api/v1/siwe/transfer",exports.unlinkEmailPath="/api/v1/passwordless/unlink",exports.unlinkFarcasterPath="/api/v1/farcaster/unlink",exports.unlinkOAuthPath="/api/v1/oauth/unlink",exports.unlinkPhonePath="/api/v1/passwordless_sms/unlink",exports.unlinkWalletPath="/api/v1/siwe/unlink",exports.updateEmailPath="/api/v1/passwordless/update",exports.updatePhonePath="/api/v1/passwordless_sms/update",exports.usersMePath="/api/v1/users/me";
|