@crossmint/client-sdk-react-ui 1.19.1 → 1.19.3
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/chunk-5MDB732A.js +1 -0
- package/dist/{chunk-IWS5P323.cjs → chunk-5VW4FJWT.cjs} +1 -1
- package/dist/chunk-74NYCN24.cjs +1 -0
- package/dist/{chunk-VHH5YO6J.js → chunk-7TP4HRBQ.js} +1 -1
- package/dist/chunk-AITWNSJU.js +1 -0
- package/dist/{chunk-PJJNLC25.cjs → chunk-AJVX2ZQD.cjs} +1 -1
- package/dist/chunk-CJYAAH42.cjs +6 -0
- package/dist/{chunk-G4LRVSOY.cjs → chunk-DORETXMC.cjs} +1 -1
- package/dist/{chunk-IOHFOH6A.js → chunk-EGKXRC35.js} +1 -1
- package/dist/{chunk-NYVBWAX7.js → chunk-EPEB36U6.js} +1 -1
- package/dist/{chunk-5ASQCIUO.js → chunk-FJSNASMB.js} +1 -1
- package/dist/{chunk-BUMEWB2D.js → chunk-FUOIGTSS.js} +1 -1
- package/dist/{chunk-T66BUSHV.cjs → chunk-GVCTRBGR.cjs} +1 -1
- package/dist/{chunk-4OE5NI6E.js → chunk-HRSUSZ6Z.js} +1 -1
- package/dist/chunk-LPL76URZ.js +6 -0
- package/dist/{chunk-HFFTNDOR.cjs → chunk-MKPJJ4JE.cjs} +1 -1
- package/dist/{chunk-PTLQBARH.cjs → chunk-MULULWXN.cjs} +1 -1
- package/dist/{chunk-C44EHIPT.cjs → chunk-PHXKJ6BC.cjs} +1 -1
- package/dist/{chunk-LCMWTOWW.js → chunk-QIBGCNCN.js} +1 -1
- package/dist/{chunk-XZPREGSV.js → chunk-QO3GCPRV.js} +1 -1
- package/dist/{chunk-QOQHRIIO.cjs → chunk-RL7USVCO.cjs} +1 -1
- package/dist/{chunk-3CEBGWSO.cjs → chunk-SXRK2XLZ.cjs} +1 -1
- package/dist/{chunk-QCQ2CJA4.cjs → chunk-ZQS2GGUH.cjs} +1 -1
- package/dist/{chunk-E3WXNW4S.js → chunk-ZW3H2HP4.js} +1 -1
- package/dist/components/CrossmintNFTCollectionView.cjs +1 -1
- package/dist/components/CrossmintNFTCollectionView.js +1 -1
- package/dist/components/CrossmintNFTDetail.cjs +1 -1
- package/dist/components/CrossmintNFTDetail.js +1 -1
- package/dist/components/auth/AuthForm.cjs +1 -1
- package/dist/components/auth/AuthForm.js +1 -1
- package/dist/components/auth/AuthFormBackButton.cjs +1 -1
- package/dist/components/auth/AuthFormBackButton.js +1 -1
- package/dist/components/auth/AuthFormDialog.cjs +1 -1
- package/dist/components/auth/AuthFormDialog.js +1 -1
- package/dist/components/auth/EmbeddedAuthForm.cjs +1 -1
- package/dist/components/auth/EmbeddedAuthForm.js +1 -1
- package/dist/components/auth/methods/email/EmailAuthFlow.cjs +1 -1
- package/dist/components/auth/methods/email/EmailAuthFlow.js +1 -1
- package/dist/components/auth/methods/email/EmailOTPInput.cjs +1 -1
- package/dist/components/auth/methods/email/EmailOTPInput.js +1 -1
- package/dist/components/auth/methods/email/EmailSignIn.cjs +1 -1
- package/dist/components/auth/methods/email/EmailSignIn.js +1 -1
- package/dist/components/auth/methods/farcaster/FarcasterSignIn.cjs +1 -1
- package/dist/components/auth/methods/farcaster/FarcasterSignIn.js +1 -1
- package/dist/components/auth/methods/google/ContinueWithGoogle.cjs +1 -1
- package/dist/components/auth/methods/google/ContinueWithGoogle.js +1 -1
- package/dist/components/auth/methods/google/GoogleSignIn.cjs +1 -1
- package/dist/components/auth/methods/google/GoogleSignIn.js +1 -1
- package/dist/components/auth/methods/twitter/TwitterSignIn.cjs +1 -1
- package/dist/components/auth/methods/twitter/TwitterSignIn.js +1 -1
- package/dist/components/auth/methods/web3/Web3AuthFlow.cjs +1 -1
- package/dist/components/auth/methods/web3/Web3AuthFlow.js +1 -1
- package/dist/components/auth/methods/web3/Web3AuthFlowButton.cjs +1 -1
- package/dist/components/auth/methods/web3/Web3AuthFlowButton.js +1 -1
- package/dist/components/auth/methods/web3/Web3Connectors.cjs +1 -1
- package/dist/components/auth/methods/web3/Web3Connectors.js +1 -1
- package/dist/components/common/Divider.cjs +1 -1
- package/dist/components/common/Divider.js +1 -1
- package/dist/components/embed/v3/CrossmintEmbeddedCheckoutV3.cjs +1 -1
- package/dist/components/embed/v3/CrossmintEmbeddedCheckoutV3.js +1 -1
- package/dist/components/embed/v3/EmbeddedCheckoutV3IFrame.cjs +1 -1
- package/dist/components/embed/v3/EmbeddedCheckoutV3IFrame.js +1 -1
- package/dist/components/embed/v3/index.cjs +1 -1
- package/dist/components/embed/v3/index.js +1 -1
- package/dist/components/hosted/CrossmintPayButton_DEPRECATED.cjs +1 -1
- package/dist/components/hosted/CrossmintPayButton_DEPRECATED.js +1 -1
- package/dist/components/hosted/index.cjs +1 -1
- package/dist/components/hosted/index.js +1 -1
- package/dist/components/hosted/v3/CrossmintHostedCheckoutV3.cjs +1 -1
- package/dist/components/hosted/v3/CrossmintHostedCheckoutV3.js +1 -1
- package/dist/components/hosted/v3/index.cjs +1 -1
- package/dist/components/hosted/v3/index.js +1 -1
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.js +1 -1
- package/dist/consts/version.cjs +1 -1
- package/dist/consts/version.js +1 -1
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/useAuth.cjs +1 -1
- package/dist/hooks/useAuth.js +1 -1
- package/dist/hooks/useCrossmintAuth.cjs +1 -1
- package/dist/hooks/useCrossmintAuth.js +1 -1
- package/dist/hooks/useCrossmintCheckout.cjs +1 -1
- package/dist/hooks/useCrossmintCheckout.js +1 -1
- package/dist/hooks/useOAuthWindowListener.cjs +1 -1
- package/dist/hooks/useOAuthWindowListener.js +1 -1
- package/dist/hooks/useSignerInvisibleIFrame.cjs +1 -1
- package/dist/hooks/useSignerInvisibleIFrame.d.cts +1 -1
- package/dist/hooks/useSignerInvisibleIFrame.d.ts +1 -1
- package/dist/hooks/useSignerInvisibleIFrame.js +1 -1
- package/dist/hooks/useWallet.cjs +1 -1
- package/dist/hooks/useWallet.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/providers/CrossmintAuthProvider.cjs +1 -1
- package/dist/providers/CrossmintAuthProvider.js +1 -1
- package/dist/providers/CrossmintWalletProvider.cjs +1 -1
- package/dist/providers/CrossmintWalletProvider.d.cts +2 -1
- package/dist/providers/CrossmintWalletProvider.d.ts +2 -1
- package/dist/providers/CrossmintWalletProvider.js +1 -1
- package/dist/providers/auth/AuthFormProvider.cjs +1 -1
- package/dist/providers/auth/AuthFormProvider.js +1 -1
- package/dist/providers/auth/web3/DynamicWeb3WalletConnect.cjs +1 -1
- package/dist/providers/auth/web3/DynamicWeb3WalletConnect.js +1 -1
- package/dist/providers/index.cjs +1 -1
- package/dist/providers/index.js +1 -1
- package/dist/providers/signers/CrossmintSignerProvider.cjs +1 -1
- package/dist/providers/signers/CrossmintSignerProvider.d.cts +2 -1
- package/dist/providers/signers/CrossmintSignerProvider.d.ts +2 -1
- package/dist/providers/signers/CrossmintSignerProvider.js +1 -1
- package/dist/types/auth.d.cts +1 -0
- package/dist/types/auth.d.ts +1 -0
- package/dist/utils/createCrossmintApiClient.cjs +1 -1
- package/dist/utils/createCrossmintApiClient.js +1 -1
- package/package.json +4 -4
- package/dist/chunk-ADHZO4XH.cjs +0 -6
- package/dist/chunk-CPRLL4GL.js +0 -1
- package/dist/chunk-IOYFNS7R.js +0 -1
- package/dist/chunk-IQ7CQQXG.cjs +0 -1
- package/dist/chunk-P64NXOJW.js +0 -6
package/dist/chunk-IQ7CQQXG.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk2WSEHVNPcjs = require('./chunk-2WSEHVNP.cjs');var _react = require('react');var _clientsdkwindow = require('@crossmint/client-sdk-window');var _clientsigners = require('@crossmint/client-signers');function l(n){return _chunk2WSEHVNPcjs.d.call(void 0, this,null,function*(){let e=document.createElement("iframe");return e.src=n,e.style.position="absolute",e.style.opacity="0",e.style.pointerEvents="none",e.style.width="0",e.style.height="0",e.style.border="none",e.style.top="-9999px",e.style.left="-9999px",new Promise((t,r)=>{e.onload=()=>t(e),e.onerror=()=>r("Failed to load iframe content"),document.body.appendChild(e)})})}function p(){let n=_react.useRef.call(void 0, null);return _react.useEffect.call(void 0, ()=>(_chunk2WSEHVNPcjs.d.call(void 0, this,null,function*(){try{let t=new URL("https://signers.crossmint.com/"),r=yield l(t.toString());n.current=yield _clientsdkwindow.IFrameWindow.init(r,{targetOrigin:t.origin,incomingEvents:_clientsigners.signerOutboundEvents,outgoingEvents:_clientsigners.signerInboundEvents}),yield n.current.handshakeWithChild()}catch(t){console.error("Failed to initialize or connect to iframe:",t)}}),()=>{n.current}),[]),n}exports.a = p;
|
package/dist/chunk-P64NXOJW.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{a as zt}from"./chunk-7YHGBWRD.js";import{a as Jt}from"./chunk-JSNUJJQJ.js";import{b as te}from"./chunk-4KDASQO6.js";import{a as Zt}from"./chunk-LD3MRJ3F.js";import{a as Bt}from"./chunk-JOMJPVZA.js";import{a as Vt}from"./chunk-EMXNIC4M.js";import{a as Lt,e as Ut,h as Mt,i as Dt}from"./chunk-UDQUVZUQ.js";import{a as Ht,b as _t,c as J}from"./chunk-VHNBXIOC.js";import{a as Rt}from"./chunk-2VBA64WU.js";import{a as G}from"./chunk-TNCETEEL.js";import{a as T}from"./chunk-NBJIJZGO.js";import{a as Kt}from"./chunk-BFHQZOV3.js";import{a as rt}from"./chunk-C22ZEFQD.js";import{a as ee}from"./chunk-ZZYJ6XM2.js";import{a as ft}from"./chunk-RZG2PAKA.js";import{a as gt}from"./chunk-WW6GUXHG.js";import{a as jt}from"./chunk-SFDQPSSP.js";import{a as Xt}from"./chunk-JPJKOERH.js";import{a as Yt}from"./chunk-VWL76U5G.js";import{a as qt}from"./chunk-IOYFNS7R.js";import{a as dt}from"./chunk-UAFW3OWA.js";import{a as Qt}from"./chunk-VLDE23JX.js";import{a as Gt}from"./chunk-C3JRTLQP.js";import{a as $t}from"./chunk-E4TBJMOO.js";import{b as Y}from"./chunk-ROJ6HFVK.js";import{a as oe}from"./chunk-WQVJJ44F.js";import{a as D,b as B,c as Q,d as v}from"./chunk-PXDN3KFO.js";import{createContext as Mo,useContext as Do,useRef as Le,useState as It,useEffect as Bo,useMemo as Ko}from"react";import{CrossmintWallets as Vo}from"@crossmint/wallets-sdk";import{PublicKey as Ho}from"@solana/web3.js";import ct from"bs58";import{useContext as He}from"react";import{createContext as De,useMemo as re,useState as le}from"react";import{createPortal as Be}from"react-dom";import{CrossmintWallets as Ke}from"@crossmint/wallets-sdk";import{jsx as nt,jsxs as Ve}from"react/jsx-runtime";var St=De({status:"not-loaded",getOrCreateWallet:()=>Promise.resolve({startedCreation:!1}),createPasskeySigner:()=>Promise.resolve(null),clearWallet:()=>{}});function ae({children:r,showPasskeyHelpers:e=!0,appearance:o,experimental_enableRecoveryKeys:t=!1}){let[s,i]=le({status:"not-loaded"}),n={walletState:s,setWalletState:i,showPasskeyHelpers:e,appearance:o,experimental_enableRecoveryKeys:t};return t?nt(ft,{children:nt(se,{walletState:s,setWalletState:i,appearance:o,children:nt(ne,B(D({},n),{children:r}))})}):nt(ne,B(D({},n),{children:r}))}function ne({children:r,showPasskeyHelpers:e=!0,appearance:o,walletState:t,setWalletState:s,experimental_enableRecoveryKeys:i}){let{crossmint:n}=Y("CrossmintWalletProvider must be used within CrossmintProvider"),{experimental_getOrCreateWalletWithRecoveryKey:f}=ie({enabled:i!=null?i:!1}),m=re(()=>Ke.from({apiKey:n.apiKey,jwt:n==null?void 0:n.jwt}),[n.apiKey,n.jwt]),[u,a]=le({open:!1}),h=C=>v(this,null,function*(){var c,A;if(t.status=="in-progress")return{startedCreation:!1,reason:"Wallet is already loading."};if(n.jwt==null)return{startedCreation:!1,reason:'Jwt not set in "CrossmintProvider".'};try{s({status:"in-progress"});let P={onWalletCreationStart:l("create-wallet"),onWalletCreationFail:l("create-wallet-error"),onTransactionStart:l("transaction"),onTransactionFail:l("transaction-error")};switch(C.type){case"evm-smart-wallet":{let w={adminSigner:(c=C.args.adminSigner)!=null?c:{type:"evm-passkey"},linkedUser:C.args.linkedUser},g=yield m.getOrCreateWallet("evm-smart-wallet",w,{experimental_callbacks:((A=w.adminSigner)==null?void 0:A.type)==="evm-passkey"?P:void 0});s({status:"loaded",wallet:g,type:"evm-smart-wallet"});break}case"solana-smart-wallet":{let w=yield m.getOrCreateWallet("solana-smart-wallet",C.args);s({status:"loaded",wallet:w,type:"solana-smart-wallet"});break}}}catch(P){console.error("There was an error creating a wallet ",P),s(rt(P))}return{startedCreation:!0}}),l=C=>()=>new Promise(c=>{if(!e){c();return}a({type:C,open:!0,primaryActionOnClick:()=>{a({open:!1}),c()},secondaryActionOnClick:()=>{a({open:!1}),c()}})}),b=()=>{s({status:"not-loaded"})},d=(C,c)=>v(this,null,function*(){return c!=null&&(yield l(c)()),yield Kt(C)}),x=re(()=>B(D({},t),{getOrCreateWallet:h,createPasskeySigner:d,clearWallet:b,experimental_getOrCreateWalletWithRecoveryKey:f}),[t,f]);return Ve(St.Provider,{value:x,children:[r,u.open?Be(nt(Bt,{state:u,appearance:o}),document.body):null]})}function me(){let r=He(St);if(!r)throw new Error("useWallet must be used within CrossmintAuthProvider or CrossmintWalletProvider");return r}import{useContext as Uo}from"react";import{createContext as Wo,useEffect as Tt,useMemo as Re,useRef as ko,useState as ut,useCallback as X}from"react";import{CrossmintAuth as Eo,getCookie as Oo}from"@crossmint/client-sdk-auth";import{validateApiKeyAndGetCrossmintBaseUrl as Fo}from"@crossmint/common-sdk-base";import{SESSION_PREFIX as To}from"@crossmint/common-sdk-auth";import{VisuallyHidden as Fe}from"@radix-ui/react-visually-hidden";import{createContext as Ge,useCallback as je,useContext as ze,useEffect as qe,useState as pt}from"react";import{CrossmintAuthenticationError as $e}from"@crossmint/common-sdk-auth";import{useContext as _e}from"react";function K(){let r=_e(st);if(!r)throw new Error("useCrossmintAuth must be used within a CrossmintAuthProvider");return r}import{jsx as Je}from"react/jsx-runtime";var ue={google:"",twitter:""},ce=Ge(void 0),S=()=>{let r=ze(ce);if(!r)throw new Error("useAuthForm must be used within an AuthFormProvider");return r},de=({setDialogOpen:r,preFetchOAuthUrls:e,initialState:o,children:t})=>{let{crossmintAuth:s}=K(),[i,n]=pt("initial"),[f,m]=pt(null),[u,a]=pt(ue),[h,l]=pt(!0),{loginMethods:b,baseUrl:d,appearance:x,termsOfServiceText:C,authModalTitle:c,defaultEmail:A}=o,P=je(()=>v(void 0,null,function*(){l(!0);try{let y=b.filter(F=>F in ue).map(F=>v(void 0,null,function*(){let N=yield s==null?void 0:s.getOAuthUrl(F);return{[F]:N}})),E=Object.assign({},...yield Promise.all(y));a(E)}catch(p){m(p instanceof $e?p.message:"Unable to load oauth providers. Please try again later.")}finally{l(!1)}}),[b,s]);qe(()=>{e&&P()},[P,e]);let g={step:i,error:f,baseUrl:d,appearance:x,termsOfServiceText:C,authModalTitle:c,loginMethods:b,defaultEmail:A,oauthUrlMap:u,isLoadingOauthUrlMap:h,setDialogOpen:(p,y)=>{r==null||r(p,y),p||setTimeout(()=>n("initial"),250)},setError:m,setStep:n};return Je(ce.Provider,{value:g,children:t})};import Co from"color";import{useState as io}from"react";import{useState as Pt}from"react";import{jsx as fe}from"react/jsx-runtime";var Z=i=>{var n=i,{className:r,iconColor:e,ringColor:o,onClick:t}=n,s=Q(n,["className","iconColor","ringColor","onClick"]);let{setError:f}=S();return fe("button",B(D({className:T("absolute left-4 top-4 min-[480px]:!left-6 min-[480px]:!top-6 rounded-full opacity-70 ring-offset-background text-cm-text-primary transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-cm-accent focus:ring-offset-2 disabled:pointer-events-none",r),onClick:m=>{f(null),t==null||t(m)}},s),{children:fe(jt,{className:"w-6 h-6",style:{color:e}})}))};import{jsx as R,jsxs as it}from"react/jsx-runtime";var Xe=6;function ge({otpEmailData:r,setOtpEmailData:e}){var C,c,A,P,w,g,p,y,E,F,N,V,I,M,H,$,q,O,_,Nt;let{crossmintAuth:o}=K(),{appearance:t,setDialogOpen:s,setStep:i,setError:n}=S(),[f,m]=Pt(""),[u,a]=Pt(!1),[h,l]=Pt(!1),b=()=>v(this,null,function*(){var z,Ct;l(!0);try{let vt=yield o==null?void 0:o.confirmEmailOtp((z=r==null?void 0:r.email)!=null?z:"",(Ct=r==null?void 0:r.emailId)!=null?Ct:"",f);yield o==null?void 0:o.handleRefreshAuthMaterial(vt),s(!1,!0),i("initial")}catch(vt){console.error("Error confirming email OTP",vt),n("Invalid code. Please try again."),a(!0)}finally{l(!1)}}),d=()=>v(this,null,function*(){var z;try{yield o==null?void 0:o.sendEmailOtp((z=r==null?void 0:r.email)!=null?z:"")}catch(Ct){n("Failed to resend code. Please try again.")}});return it("div",{children:[R(Z,{onClick:()=>{i("initial"),e(null)},iconColor:(C=t==null?void 0:t.colors)==null?void 0:C.textPrimary,ringColor:(c=t==null?void 0:t.colors)==null?void 0:c.accent}),it("div",{className:"flex flex-col items-center justify-start w-full",children:[R("div",{className:"relative left-3",children:R(Gt,{customAccentColor:(A=t==null?void 0:t.colors)==null?void 0:A.accent,customButtonBackgroundColor:(P=t==null?void 0:t.colors)==null?void 0:P.buttonBackground,customBackgroundColor:(w=t==null?void 0:t.colors)==null?void 0:w.background})}),R("p",{className:"text-base font-normal mt-4 mb-1 text-center text-cm-text-primary",style:{color:(g=t==null?void 0:t.colors)==null?void 0:g.textPrimary},children:"Check your email"}),it("p",{className:"text-center text-cm-text-secondary px-4",style:{color:(p=t==null?void 0:t.colors)==null?void 0:p.textSecondary},children:["A temporary login code has been sent to"," ",r!=null&&r.email?r.email:"your email address"]}),R("div",{className:"py-8",children:R(Ht,{maxLength:Xe,value:f,onChange:z=>{m(z),a(!1),n(null)},onComplete:b,disabled:h,customStyles:{accent:(E=(y=t==null?void 0:t.colors)==null?void 0:y.accent)!=null?E:"#04AA6D",danger:(N=(F=t==null?void 0:t.colors)==null?void 0:F.danger)!=null?N:"#f44336",border:(I=(V=t==null?void 0:t.colors)==null?void 0:V.border)!=null?I:"#E5E7EB",textPrimary:(H=(M=t==null?void 0:t.colors)==null?void 0:M.textPrimary)!=null?H:"#909ca3",buttonBackground:(q=($=t==null?void 0:t.colors)==null?void 0:$.buttonBackground)!=null?q:"#eff6ff",inputBackground:(_=(O=t==null?void 0:t.colors)==null?void 0:O.inputBackground)!=null?_:"#FFFFFF",borderRadius:t==null?void 0:t.borderRadius},children:it(_t,{children:[R(J,{index:0,hasError:u}),R(J,{index:1,hasError:u}),R(J,{index:2,hasError:u}),R(J,{index:3,hasError:u}),R(J,{index:4,hasError:u}),R(J,{index:5,hasError:u})]})})}),R("div",{className:"text-xs leading-tight text-cm-text-secondary text-center",children:it("span",{style:{color:(Nt=t==null?void 0:t.colors)==null?void 0:Nt.textSecondary},children:["Can't find the email? Check spam folder.",`
|
|
2
|
-
`,"Some emails may take several minutes to arrive."]})}),R(Vt,{initialSeconds:60,appearance:t,countdownText:z=>`Re-send code in ${z}s`,countdownCompleteText:"Re-send code",handleOnClick:d})]})]})}import{useState as Wt}from"react";import no from"color";import{isEmailValid as ht}from"@crossmint/common-sdk-auth";import{ChildWindow as Qe,PopupWindow as Ye}from"@crossmint/client-sdk-window";import{useEffect as Ze,useRef as to,useState as eo}from"react";import{z as yt}from"zod";var tt=r=>{let{crossmintAuth:e}=K(),{oauthUrlMap:o,setError:t}=S(),[s,i]=eo(!1),n=to(null);return Ze(()=>(n.current==null&&(n.current=new Qe(window.opener||window.parent,"*",{incomingEvents:oo})),()=>{n.current!=null&&n.current.off("authMaterialFromPopupCallback")}),[]),{createPopupAndSetupListeners:m=>v(void 0,null,function*(){if(n.current==null)throw new Error("Child window not initialized");i(!0),t(null);let u=new URL(o[r]);if(m!=null){let d=Array.from(u.searchParams.entries());u.search="",m&&u.searchParams.append("provider_login_hint",m),d.forEach(([x,C])=>{u.searchParams.append(x,C)})}let a=yield Ye.init(u.toString(),{awaitToLoad:!1,crossOrigin:!0,width:400,height:700}),h=d=>v(void 0,null,function*(){var x;yield e==null?void 0:e.handleRefreshAuthMaterial(d.oneTimeSecret),(x=n.current)==null||x.off("authMaterialFromPopupCallback"),a.window.close(),i(!1)}),l=d=>{var x;t(d.error),(x=n.current)==null||x.off("errorFromPopupCallback"),a.window.close(),i(!1)};n.current.on("authMaterialFromPopupCallback",h),n.current.on("errorFromPopupCallback",l);let b=setInterval(()=>{var d;a.window.closed&&(clearInterval(b),i(!1),(d=n.current)==null||d.off("authMaterialFromPopupCallback"))},2500)}),isLoading:s}},oo={authMaterialFromPopupCallback:yt.object({oneTimeSecret:yt.string()}),errorFromPopupCallback:yt.object({error:yt.string()})};import{jsx as At,jsxs as ro}from"react/jsx-runtime";function pe({emailInput:r,appearance:e}){var s,i,n,f;let{createPopupAndSetupListeners:o,isLoading:t}=tt("google");return ro("button",{type:"button",className:T("flex items-center gap-2 justify-center h-[32px] px-2.5 border border-cm-border rounded-xl bg-cm-background-primary","hover:bg-cm-hover focus:bg-cm-hover outline-none",t?"cursor-not-allowed hover:bg-cm-muted-primary":""),onClick:t?void 0:()=>o(r.trim().toLowerCase()),style:{backgroundColor:(s=e==null?void 0:e.colors)==null?void 0:s.buttonBackground,borderRadius:e==null?void 0:e.borderRadius},children:[At(gt,{className:"max-h-[18px] max-w-[18px] h-[18px] w-[18px]"}),t?At(G,{style:{color:(i=e==null?void 0:e.colors)==null?void 0:i.textSecondary,fill:(n=e==null?void 0:e.colors)==null?void 0:n.textPrimary,width:"18px",height:"18px"}}):At("span",{className:"text-cm-accent",style:{color:(f=e==null?void 0:e.colors)==null?void 0:f.accent},children:"Continue"})]})}import{Fragment as so,jsx as j,jsxs as kt}from"react/jsx-runtime";function ye({setOtpEmailData:r}){var d,x,C,c,A,P,w,g,p,y,E,F,N,V;let{crossmintAuth:e}=K(),{appearance:o,defaultEmail:t,setStep:s,setError:i}=S(),[n,f]=Wt(t!=null?t:""),[m,u]=Wt(""),[a,h]=Wt(!1),l=n.toLowerCase().includes("@gmail.com")&&!n.toLowerCase().includes("+")&&ht(n)&&!a;function b(I){return v(this,null,function*(){I.preventDefault(),h(!0);try{let M=n.trim().toLowerCase(),H=yield e==null?void 0:e.sendEmailOtp(M);r({email:M,emailId:H.emailId}),s("otp")}catch(M){h(!1),i("Failed to send email. Please try again or contact support.")}})}return j(so,{children:j("div",{className:"flex flex-col items-start justify-start w-full rounded-lg",children:kt("div",{className:"w-full",children:[j("label",{className:"text-cm-text-primary block mb-[5px]",style:{color:(d=o==null?void 0:o.colors)==null?void 0:d.textPrimary},children:"Email"}),kt("form",{role:"form",className:"relative",onSubmit:I=>{if(l){I.preventDefault();return}ht(n)?b(I):I.preventDefault()},noValidate:!0,children:[j("label",{htmlFor:"emailInput",className:"sr-only",children:"Email"}),j("input",{className:T("flex-grow text-cm-text-primary text-left pl-[16px] h-[58px] w-full border border-cm-border rounded-xl bg-cm-background-primary placeholder:text-md","transition-none duration-200 ease-in-out","focus:outline-none focus-ring-custom","placeholder:[color:var(--placeholder-color)]",m?"border-red-500":"",l?"pr-[132px]":"pr-[80px]"),style:{color:(x=o==null?void 0:o.colors)==null?void 0:x.textPrimary,borderRadius:o==null?void 0:o.borderRadius,borderColor:m?(C=o==null?void 0:o.colors)==null?void 0:C.danger:(c=o==null?void 0:o.colors)==null?void 0:c.border,backgroundColor:(A=o==null?void 0:o.colors)==null?void 0:A.inputBackground,"--placeholder-color":(w=(P=o==null?void 0:o.colors)==null?void 0:P.textSecondary)!=null?w:"#67797F","--focus-ring-color":new no((p=(g=o==null?void 0:o.colors)==null?void 0:g.accent)!=null?p:"#04AA6D").alpha(.18).toString()},type:"email",placeholder:"your@email.com",value:n,onChange:I=>{f(I.target.value),u(""),i(null)},readOnly:a,"aria-describedby":"emailError"}),kt("div",{className:"absolute inset-y-0 right-0 flex items-center pr-4",children:[m&&j(dt,{customColor:(y=o==null?void 0:o.colors)==null?void 0:y.danger}),a&&j(G,{style:{color:(E=o==null?void 0:o.colors)==null?void 0:E.textSecondary,fill:(F=o==null?void 0:o.colors)==null?void 0:F.textPrimary}}),l?j(pe,{emailInput:n,appearance:o}):!m&&!a?j("button",{type:"submit",className:T("font-medium text-cm-accent text-nowrap bg-cm-background-primary",ht(n)?"cursor-pointer":"!cursor-not-allowed opacity-60"),style:{color:(N=o==null?void 0:o.colors)==null?void 0:N.accent,backgroundColor:(V=o==null?void 0:o.colors)==null?void 0:V.inputBackground},disabled:!ht(n)||a,children:"Submit"}):null]})]}),m&&j("p",{className:"text-xs text-red-500 mb-2 pt-2",children:m})]})})})}import{jsx as he}from"react/jsx-runtime";function we(){let{step:r}=S(),[e,o]=io(null);return r==="otp"?he(ge,{otpEmailData:e,setOtpEmailData:o}):r==="initial"?he(ye,{setOtpEmailData:o}):null}import{jsx as Et,jsxs as lo}from"react/jsx-runtime";function xe({appearance:r,text:e}){var t,s,i;let{step:o}=S();return o!=="initial"?null:lo("div",{className:"flex items-center justify-center w-full pt-2 pb-3",children:[Et("span",{className:"w-full h-[1px] bg-cm-border",style:{backgroundColor:(t=r==null?void 0:r.colors)==null?void 0:t.border}}),e!=null?Et("p",{className:"flex-none px-2 text-sm text-cm-text-primary",style:{color:(s=r==null?void 0:r.colors)==null?void 0:s.textSecondary},children:e}):null,Et("span",{className:"w-full h-[1px] bg-cm-border",style:{backgroundColor:(i=r==null?void 0:r.colors)==null?void 0:i.border}})]})}import{Fragment as ao,jsx as wt,jsxs as be}from"react/jsx-runtime";function Ce(e){var r=Q(e,[]);var m,u,a,h;let{step:o,appearance:t,isLoadingOauthUrlMap:s}=S(),{createPopupAndSetupListeners:i,isLoading:n}=tt("google"),f=s||n;return o!=="initial"?null:be("button",B(D({className:T("relative flex text-base p-4 bg-cm-muted-primary text-cm-text-primary items-center w-full rounded-xl justify-center","transition-colors duration-200 ease-in-out","hover:bg-cm-hover focus:bg-cm-hover outline-none",f?"cursor-not-allowed hover:bg-cm-muted-primary":""),style:{borderRadius:t==null?void 0:t.borderRadius,backgroundColor:(m=t==null?void 0:t.colors)==null?void 0:m.buttonBackground},onClick:f?void 0:()=>i()},r),{children:[be(ao,{children:[wt(gt,{className:"max-h-[25px] max-w-[25px] h-[25px] w-[25px] absolute left-[18px]"}),f?wt(G,{style:{color:(u=t==null?void 0:t.colors)==null?void 0:u.textSecondary,fill:(a=t==null?void 0:t.colors)==null?void 0:a.textPrimary}}):wt("span",{className:"font-medium",style:{margin:"0px 32px",color:(h=t==null?void 0:t.colors)==null?void 0:h.textPrimary},children:"Sign in with Google"})]}),wt("span",{className:"sr-only",children:"Sign in with Google"})]}))}import{useEffect as Ot,useMemo as mo,useState as uo}from"react";import{useSignIn as co,QRCode as fo}from"@farcaster/auth-kit";import{Fragment as po,jsx as L,jsxs as lt}from"react/jsx-runtime";function ve(){var s,i;let{step:r,appearance:e,setStep:o,setError:t}=S();return r==="initial"?L("div",{children:lt("button",{className:T("relative flex text-base p-4 bg-cm-muted-primary text-cm-text-primary items-center w-full rounded-xl justify-center","transition-colors duration-200 ease-in-out","hover:bg-cm-hover focus:bg-cm-hover outline-none"),style:{borderRadius:e==null?void 0:e.borderRadius,backgroundColor:(s=e==null?void 0:e.colors)==null?void 0:s.buttonBackground},onClick:()=>{o("qrCode"),t(null)},children:[L($t,{className:"max-h-[25px] max-w-[25px] h-[25px] w-[25px] absolute left-[18px]"}),L("span",{className:"font-medium",style:{margin:"0px 32px",color:(i=e==null?void 0:e.colors)==null?void 0:i.textPrimary},children:"Sign in with Farcaster"}),L("span",{className:"sr-only",children:"Sign in with Farcaster"})]})}):r==="qrCode"?L(go,{}):null}function go(){var d,x,C,c,A,P,w,g,p;let{crossmintAuth:r}=K(),{appearance:e,setStep:o,setDialogOpen:t,setError:s}=S(),[i,n]=uo(null),f=mo(()=>({onSuccess:y=>{n(y)}}),[]),{signIn:m,url:u,connect:a,signOut:h,isConnected:l}=co(f),b=y=>v(this,null,function*(){s(null);try{let E=yield r==null?void 0:r.signInWithFarcaster(y);yield r==null?void 0:r.handleRefreshAuthMaterial(E),t(!1),o("initial")}catch(E){console.error("Error during Farcaster sign-in:",E),s("Failed to sign in with Farcaster")}});return Ot(()=>{i!=null&&b(i)},[i]),Ot(()=>{l&&m()},[l]),Ot(()=>{a()},[]),lt("div",{children:[L(Z,{onClick:()=>{h(),o("initial")},iconColor:(d=e==null?void 0:e.colors)==null?void 0:d.textPrimary,ringColor:(x=e==null?void 0:e.colors)==null?void 0:x.accent}),lt("div",{className:"flex flex-col items-center gap-4",children:[lt("div",{className:"text-center",children:[L("h3",{className:"text-lg font-semibold text-cm-text-primary mb-2",style:{color:(C=e==null?void 0:e.colors)==null?void 0:C.textPrimary},children:"Sign in with Farcaster"}),L("p",{className:"text-base font-normal text-cm-text-secondary",style:{color:(c=e==null?void 0:e.colors)==null?void 0:c.textSecondary},children:"Scan with your phone's camera to continue."})]}),L("div",{className:"bg-white aspect-square rounded-lg p-4",style:{backgroundColor:(A=e==null?void 0:e.colors)==null?void 0:A.inputBackground,borderRadius:e==null?void 0:e.borderRadius},children:u!=null?L(fo,{uri:u,size:280}):L("div",{className:"min-h-[246px] flex items-center justify-center",children:L(G,{style:{color:(P=e==null?void 0:e.colors)==null?void 0:P.textSecondary,fill:(w=e==null?void 0:e.colors)==null?void 0:w.textPrimary}})})}),u?lt(po,{children:[L("p",{className:"text-base text-center font-normal text-cm-text-secondary",style:{color:(g=e==null?void 0:e.colors)==null?void 0:g.textSecondary},children:"Alternatively, click on this link to open Warpcast."}),L("a",{href:u,rel:"noopener noreferrer",target:"_blank",className:"text-base font-normal text-cm-link",style:{color:(p=e==null?void 0:e.colors)==null?void 0:p.textLink},children:"Open Warpcast"})]}):null]})]})}import{Fragment as yo,jsx as xt,jsxs as Se}from"react/jsx-runtime";function Pe(e){var r=Q(e,[]);var m,u,a,h;let{step:o,appearance:t,isLoadingOauthUrlMap:s}=S(),{createPopupAndSetupListeners:i,isLoading:n}=tt("twitter"),f=s||n;return o!=="initial"?null:Se("button",B(D({className:T("relative flex text-base p-4 bg-cm-muted-primary text-cm-text-primary items-center w-full rounded-xl justify-center","transition-colors duration-200 ease-in-out","hover:bg-cm-hover focus:bg-cm-hover outline-none",f?"cursor-not-allowed hover:bg-cm-muted-primary":""),style:{borderRadius:t==null?void 0:t.borderRadius,backgroundColor:(m=t==null?void 0:t.colors)==null?void 0:m.buttonBackground},onClick:f?void 0:()=>i()},r),{children:[Se(yo,{children:[xt(Xt,{className:"max-h-[25px] max-w-[25px] h-[25px] w-[25px] absolute left-[18px]"}),f?xt(G,{style:{color:(u=t==null?void 0:t.colors)==null?void 0:u.textSecondary,fill:(a=t==null?void 0:t.colors)==null?void 0:a.textPrimary}}):xt("span",{className:"font-medium",style:{margin:"0px 32px",color:(h=t==null?void 0:t.colors)==null?void 0:h.textPrimary},children:"Sign in with X"})]}),xt("span",{className:"sr-only",children:"Sign in with X"})]}))}import{jsx as bt,jsxs as ho}from"react/jsx-runtime";function Ae(){var s,i,n,f,m;let{step:r,appearance:e,setStep:o,setError:t}=S();return r!=="initial"?null:ho("button",{className:T("relative flex text-base p-4 bg-cm-muted-primary text-cm-text-primary items-center w-full rounded-xl justify-center","transition-colors duration-200 ease-in-out","hover:bg-cm-hover focus:bg-cm-hover outline-none"),style:{borderRadius:e==null?void 0:e.borderRadius,borderColor:(s=e==null?void 0:e.colors)==null?void 0:s.border,backgroundColor:(i=e==null?void 0:e.colors)==null?void 0:i.buttonBackground},onClick:()=>{o("web3"),t(null)},children:[bt(Yt,{className:"h-[21px] w-[21px] absolute left-[20px]",style:{color:(n=e==null?void 0:e.colors)==null?void 0:n.textPrimary}}),bt("span",{className:"font-medium",style:{margin:"0px 32px",color:(f=e==null?void 0:e.colors)==null?void 0:f.textPrimary},children:"Continue with a wallet"}),bt(Qt,{className:"h-[21px] w-[21px] absolute right-[20px]",style:{color:(m=e==null?void 0:e.colors)==null?void 0:m.textSecondary}}),bt("span",{className:"sr-only",children:"Continue with a wallet"})]})}import{DynamicEmbeddedWidget as wo}from"@dynamic-labs/sdk-react-core";import{Fragment as xo,jsx as at,jsxs as bo}from"react/jsx-runtime";function We(){var t,s;let{appearance:r,step:e,setStep:o}=S();return e==="web3"?bo(xo,{children:[at(Z,{onClick:()=>o("initial"),iconColor:(t=r==null?void 0:r.colors)==null?void 0:t.textPrimary,ringColor:(s=r==null?void 0:r.colors)==null?void 0:s.accent}),at("div",{className:"flex flex-col items-center",children:at("div",{className:"flex flex-col gap-[10px] w-full",children:at("div",{className:"widget-container",children:at(wo,{background:"none"})})})})]}):null}import{jsx as ke}from"react/jsx-runtime";function Ee(){let{step:r}=S();return r.startsWith("web3")?ke(We,{}):r==="initial"?ke(Ae,{}):null}import{jsx as U,jsxs as mt}from"react/jsx-runtime";function Oe({className:r}){var m,u,a,h,l,b,d,x,C,c,A,P,w;let{step:e,appearance:o,loginMethods:t,baseUrl:s,error:i,termsOfServiceText:n,authModalTitle:f}=S();return mt("div",{className:T("relative pt-10 pb-[30px] px-6 !min-[480px]:px-10 flex flex-col gap-[10px] antialiased animate-none",r),children:[i!=null?mt("div",{className:"flex items-start justify-start w-full rounded-lg p-2 mt-4 bg-cm-danger-muted",style:{backgroundColor:new Co((u=(m=o==null?void 0:o.colors)==null?void 0:m.danger)!=null?u:"#f44336").alpha(.12).toString()},children:[U("div",{className:"min-w-[20px]",children:U(dt,{customColor:(h=(a=o==null?void 0:o.colors)==null?void 0:a.danger)!=null?h:"#f44336"})}),U("p",{className:"ml-2 text-sm",style:{color:(b=(l=o==null?void 0:o.colors)==null?void 0:l.danger)!=null?b:"#f44336"},children:i})]}):null,e==="initial"?mt("div",{children:[U("h1",{className:"text-2xl font-bold text-cm-text-primary",style:{color:(d=o==null?void 0:o.colors)==null?void 0:d.textPrimary},children:f!=null?f:"Sign in to Crossmint"}),U("p",{className:"text-base font-normal mb-3 text-cm-text-secondary",style:{color:(x=o==null?void 0:o.colors)==null?void 0:x.textSecondary},children:"Access using one of the options below."})]}):null,t.includes("google")?U(Ce,{}):null,t.includes("farcaster")?U(Jt,{baseUrl:s,children:U(ve,{})}):null,t.includes("twitter")?U(Pe,{}):null,t.some(g=>g.startsWith("web3"))?U(Ee,{}):null,t.includes("email")?mt("div",{children:[t.length>1?U(xe,{appearance:o,text:"OR"}):null,U(we,{})]}):null,e==="initial"&&n!=null?mt("div",{className:"text-sm text-center text-cm-text-secondary mt-2",style:{color:(C=o==null?void 0:o.colors)==null?void 0:C.textSecondary},children:[U("style",{children:`
|
|
3
|
-
p a {
|
|
4
|
-
color: ${(A=(c=o==null?void 0:o.colors)==null?void 0:c.textLink)!=null?A:"#1A74E9"};
|
|
5
|
-
}
|
|
6
|
-
`}),n]}):null,e==="initial"||e==="otp"?U(Rt,{className:"mt-1.5 md:mt-4 justify-center",color:(w=(P=o==null?void 0:o.colors)==null?void 0:P.textSecondary)!=null?w:"#67797F"}):null]})}import{useEffect as vo}from"react";import{jsx as et,jsxs as So}from"react/jsx-runtime";function Ft({open:r}){var t,s,i;let{appearance:e,setDialogOpen:o}=S();return vo(()=>{document.body.style.overflow=r?"hidden":""},[r]),et(Lt,{modal:!1,open:r,onOpenChange:o,children:So(Ut,{onInteractOutside:n=>n.preventDefault(),onOpenAutoFocus:n=>n.preventDefault(),closeButtonColor:(t=e==null?void 0:e.colors)==null?void 0:t.textPrimary,closeButtonRingColor:(s=e==null?void 0:e.colors)==null?void 0:s.accent,className:"!p-0 !min-[480px]:p-0",style:{borderRadius:e==null?void 0:e.borderRadius,backgroundColor:(i=e==null?void 0:e.colors)==null?void 0:i.background},children:[et(Fe,{asChild:!0,children:et(Mt,{children:"Crossmint Auth"})}),et(Fe,{asChild:!0,children:et(Dt,{children:"Sign in via Crossmint"})}),et(Oe,{className:"max-w-[448px]"})]})})}import Po from"bs58";import{EthereumWalletConnectors as Te}from"@dynamic-labs/ethereum";import{SolanaWalletConnectors as Ie}from"@dynamic-labs/solana";import{jsx as Ao}from"react/jsx-runtime";function Ne({children:r,apiKeyEnvironment:e,enabled:o}){var m,u;let{crossmintAuth:t}=K(),{appearance:s,loginMethods:i}=S(),n=o?[Te,Ie]:void 0;i.includes("web3:evm-only")?n=[Te]:i.includes("web3:solana-only")&&(n=[Ie]);let f=`.powered-by-dynamic { display: none !important; } .wallet-list__scroll-container { padding: 0px !important; } .wallet-list__search-container { padding-left: 0px !important; padding-right: 0px !important; } .dynamic-footer { display: none !important; } h1 { color: ${(m=s==null?void 0:s.colors)==null?void 0:m.textPrimary} !important; } * { color: ${(u=s==null?void 0:s.colors)==null?void 0:u.textSecondary} !important; }`;return Ao(Zt,{apiKeyEnvironment:e,settings:{walletConnectors:n,cssOverrides:f,events:{onWalletRemoved(){console.log("[CryptoWalletConnectionHandler] onWalletRemoved")},onAuthFlowCancel(){console.log("[CryptoWalletConnectionHandler] onAuthFlowCancel")},onAuthFlowClose(){console.log("[CryptoWalletConnectionHandler] onAuthFlowClose")},onAuthFailure(a,h){console.error("[CryptoWalletConnectionHandler] onAuthFailure",a,h)},onAuthSuccess(a){console.log("[CryptoWalletConnectionHandler] onAuthSuccess",a)}},handlers:{handleConnectedWallet:a=>v(this,null,function*(){var d;console.log("[CryptoWalletConnectionHandler] handleConnectedWallet",a);let h=a.address;if(!h)return console.error("[CryptoWalletConnectionHandler] handleConnectedWallet: address is missing"),!1;let b=(yield te(a))==="solana"?"solana":"evm";try{let x=yield t==null?void 0:t.signInWithSmartWallet(h,b),C=yield(d=a.connector)==null?void 0:d.proveOwnership(h,x.challenge),c=C;if(b==="solana"){let w=Buffer.from(C,"base64");c=Po.encode(w)}let P=(yield t==null?void 0:t.authenticateSmartWallet(h,b,c)).oneTimeSecret;yield t==null?void 0:t.handleRefreshAuthMaterial(P)}catch(x){console.error("[CryptoWalletConnectionHandler] Error authenticating wallet:",x)}return!0})}},children:r},`${e}-${i.join(",")}`)}import{jsx as ot,jsxs as Lo}from"react/jsx-runtime";var Io={crossmintAuth:void 0,login:()=>{},logout:()=>{},jwt:void 0,user:void 0,status:"initializing",getUser:()=>{}},st=Wo(Io),No={createOnLogin:"off",type:"evm-smart-wallet",experimental_enableRecoveryKeys:!1};function ui({embeddedWallets:r=No,children:e,appearance:o,termsOfServiceText:t,prefetchOAuthUrls:s=!0,authModalTitle:i,onLoginSuccess:n,loginMethods:f=["email","google"],refreshRoute:m,logoutRoute:u}){var q;let[a,h]=ut(void 0),{crossmint:l,setJwt:b}=Y("CrossmintAuthProvider must be used within CrossmintProvider"),d=ko(null),x=Re(()=>(d.current||(d.current=Eo.from(l,{callbacks:{onLogout:()=>{b(void 0),h(void 0)},onTokenRefresh:O=>{b(O.jwt),h(O.user)}},refreshRoute:m,logoutRoute:u})),d.current),[]),C=Fo(l.apiKey),[c,A]=ut(!1),[P,w]=ut(!1),[g,p]=ut(void 0),[y,E]=ut(!1),F=f.some(O=>O.startsWith("web3")),N=X(()=>{n==null||n()},[n]);Tt(()=>{if(l.jwt==null){let O=Oo(To);b(O)}w(!0)},[l.jwt,b]),Tt(()=>{l.jwt!=null&&c&&(A(!1),N())},[l.jwt,c,N]);let V=X(O=>{if(l.jwt!=null){console.log("User already logged in");return}O!=null&&typeof O=="string"&&p(O),A(!0)},[l.jwt]),I=X(()=>{x.logout()},[x]),M=X(()=>!P||F&&!y?"initializing":l.jwt!=null?"logged-in":c?"in-progress":"logged-out",[P,l.jwt,c,y,F]),H=X(()=>v(this,null,function*(){if(l.jwt==null){console.log("User not logged in");return}let O=yield x.getUser();h(O)}),[l.jwt,x]),$=Re(()=>({crossmintAuth:x,login:V,logout:I,jwt:l.jwt,user:a,status:M(),getUser:H}),[x,V,I,l.jwt,a,M,H]);return ot(ft,{children:ot(st.Provider,{value:$,children:ot(ae,{showPasskeyHelpers:r.showPasskeyHelpers,appearance:o,experimental_enableRecoveryKeys:(q=r.experimental_enableRecoveryKeys)!=null?q:!1,children:ot(de,{setDialogOpen:(O,_)=>{A(O),_&&N()},preFetchOAuthUrls:M()==="logged-out"&&s,initialState:{appearance:o,loginMethods:f,termsOfServiceText:t,authModalTitle:i,embeddedWallets:r,baseUrl:C,defaultEmail:g},children:Lo(Ne,{enabled:F,apiKeyEnvironment:l.apiKey.includes("production")?"production":"staging",children:[ot(Ro,{embeddedWallets:r,accessToken:l.jwt,setIsDynamicSdkLoaded:E,isWeb3Enabled:F}),e,ot(Ft,{open:c})]})})},l.jwt)})})}function Ro({embeddedWallets:r,accessToken:e,setIsDynamicSdkLoaded:o,isWeb3Enabled:t}){let{getOrCreateWallet:s,clearWallet:i,status:n}=me(),{sdkHasLoaded:f,getAdminSigner:m,cleanup:u,isDynamicWalletConnected:a}=oe(t,o,e),{createOnLogin:h,adminSigner:l,linkedUser:b}=r,d=h==="all-users"&&n==="not-loaded"&&e!=null&&f,x=X(()=>v(this,null,function*(){var P,w;if(!d)return;let c=l,A=r.type;if(a&&(c=(P=yield m())!=null?P:c,A=(w=ee(c==null?void 0:c.type))!=null?w:A),!a&&r.type==null){console.error("[CrossmintAuthProvider] \u26A0\uFE0F embeddedWallets.type is required when no external wallet is connected");return}s({type:A,args:{adminSigner:c,linkedUser:b}})}),[d,s,b,l,r.type,m]),C=X(()=>{e==null&&n==="loaded"&&i(),u()},[n,e,i,u]);return Tt(()=>{x(),C()},[x,C]),null}function Ci(){let r=Uo(st);if(r===void 0)throw new Error("useAuth must be used within an AuthProvider");return r}import{jsx as _o,jsxs as Go}from"react/jsx-runtime";var Ue={timeoutMs:1e4,intervalMs:5e3},Me=Mo(null);function se({children:r,setWalletState:e,appearance:o}){let{crossmint:{apiKey:t,jwt:s}}=Y(),i=Ko(()=>Vo.from({apiKey:t,jwt:s}),[t,s]),n=qt(),[f,m]=It(""),[u,a]=It("initial"),[h,l]=It(!1),b=Le(null),d=Le(null),x=w=>v(this,null,function*(){try{e({status:"in-progress"}),m(w.email);let y=(yield(yield fetch("https://staging.crossmint.com/api/unstable/wallets/ncs/doesnt-matter/public-key",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`,"x-api-key":t},body:JSON.stringify({authId:`email:${w.email}`,signingAlgorithm:"EDDSA_ED25519"})})).json()).publicKey,E=Buffer.from(y,"base64"),F=ct.encode(E),N=yield P(F),V=B(D({},N),{sendTransaction:I=>v(this,null,function*(){return new Promise((M,H)=>{let $=()=>{l(!1),a("initial")},q=()=>v(this,null,function*(){$();try{let _=yield N.sendTransaction(I);M(_)}catch(_){H(_)}}),O=_=>{$(),H(_)};b.current=q,d.current=O,C(w.email).then(q).catch(O)})})});e({status:"loaded",wallet:V,type:"solana-smart-wallet"})}catch(g){throw console.error("There was an error creating a wallet ",g),e(rt(g)),g}});function C(w){return v(this,null,function*(){if(!n.current||s==null)throw new Error("[handleGetRecoverySigner] IFrame window not initialized or JWT not set");return new Promise((g,p)=>v(this,null,function*(){var y;try{let E=yield(y=n.current)==null?void 0:y.sendAction({event:"request:get-public-key",responseEvent:"response:get-public-key",data:{authData:{jwt:s,apiKey:t},data:{chainLayer:"solana"}}});if((E==null?void 0:E.status)==="success")return console.log("Signer already exists, skipping OTP flow"),g();b.current=()=>g(),d.current=F=>p(F),w!=null?yield c(w):(a("initial"),l(!0))}catch(E){console.error("Error getting recovery signer",E),p(E)}}))})}let c=w=>v(this,null,function*(){var g,p;if(!n.current||s==null)throw new Error("[handleSendEmailOTP] IFrame window not initialized or JWT not set");try{console.log("Creating Recovery Key");let y=yield(g=n.current)==null?void 0:g.sendAction({event:"request:create-signer",responseEvent:"response:create-signer",data:{authData:{jwt:s,apiKey:t},data:{chainLayer:"solana",authId:`email:${w}`}}});if(y.status==="error")throw new Error(y.error);if(y.status==="success"&&y.address!=null){console.log("Signer already exists, skipping OTP flow"),a("initial"),l(!1);return}console.log("Proceeding to OTP flow"),a("otp"),l(!0)}catch(y){throw console.error("Error in email submission:",y),(p=d.current)==null||p.call(d,y),y}}),A=w=>v(this,null,function*(){var g,p;if(!n.current||s==null)throw new Error("[handleOTPSubmit] IFrame window not initialized or JWT not set");try{let y=yield n.current.sendAction({event:"request:send-otp",responseEvent:"response:send-otp",data:{authData:{jwt:s,apiKey:t},data:{encryptedOtp:w,chainLayer:"solana"}}});if(y.status==="error")throw new Error(y.error);a("initial"),l(!1),(g=b.current)==null||g.call(b)}catch(y){throw console.error("Error in OTP submission:",y),(p=d.current)==null||p.call(d,y),y}});function P(w){return v(this,null,function*(){if(s==null)throw new Error("[getOrCreateSolanaWalletWithSigner] JWT not set!");try{return yield i.getOrCreateWallet("solana-smart-wallet",{adminSigner:{type:"solana-keypair",address:w,signer:{signMessage:g=>v(this,null,function*(){if(n.current==null)throw new Error("IFrame window not initialized");let p=yield n.current.sendAction({event:"request:sign-message",responseEvent:"response:sign-message",data:{authData:{jwt:s,apiKey:t},data:{message:ct.encode(g),chainLayer:"solana",encoding:"base58"}},options:Ue});if(p.status==="error")throw new Error(p.error);if(p.signature==null)throw new Error("Failed to sign message");return ct.decode(p.signature)}),signTransaction:g=>v(this,null,function*(){var y;console.log("Signing transaction...",g);let p=yield(y=n.current)==null?void 0:y.sendAction({event:"request:sign-transaction",responseEvent:"response:sign-transaction",data:{authData:{jwt:s,apiKey:t},data:{transaction:ct.encode(g.serialize()),chainLayer:"solana",encoding:"base58"}},options:Ue});if((p==null?void 0:p.status)==="error")throw new Error(p.error);if((p==null?void 0:p.signature)==null)throw new Error("Failed to sign transaction");return g.addSignature(new Ho(w),ct.decode(p.signature)),g})}}})}catch(g){throw console.error("Error creating wallet with signer:",g),e(rt(g)),g}})}return Bo(()=>{document.body.style.overflow=h?"hidden":""},[h]),Go(Me.Provider,{value:{experimental_getOrCreateWalletWithRecoveryKey:x},children:[_o(zt,{email:f,setEmail:m,open:h,setOpen:l,step:u,setStep:a,onSubmitOTP:A,onResendOTPCode:c,onSubmitEmail:c,appearance:o}),r]})}function ie({enabled:r=!0}={}){let e=Do(Me);if(!r)return{experimental_getOrCreateWalletWithRecoveryKey:()=>v(this,null,function*(){yield Promise.reject(new Error("useCrossmintSigner is disabled, please set 'experimental_enableRecoveryKeys' to true"))})};if(e===null)throw new Error("useCrossmintSigner must be used within a CrossmintSignerProvider");return e}export{Me as a,se as b,ie as c,St as d,ae as e,me as f,K as g,S as h,de as i,Z as j,Xe as k,ge as l,tt as m,pe as n,ye as o,we as p,xe as q,Ce as r,ve as s,Pe as t,Ae as u,We as v,Ee as w,Oe as x,Ft as y,Ne as z,st as A,ui as B,Ci as C};
|