@crossmint/client-sdk-react-ui 1.3.24 → 1.4.1

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/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var Mt=Object.defineProperty,Ft=Object.defineProperties;var Ot=Object.getOwnPropertyDescriptors;var k=Object.getOwnPropertySymbols;var J=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable;var z=(t,e,o)=>e in t?Mt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,u=(t,e)=>{for(var o in e||(e={}))J.call(e,o)&&z(t,o,e[o]);if(k)for(var o of k(e))G.call(e,o)&&z(t,o,e[o]);return t},q=(t,e)=>Ft(t,Ot(e));var v=(t,e)=>{var o={};for(var r in t)J.call(t,r)&&e.indexOf(r)<0&&(o[r]=t[r]);if(t!=null&&k)for(var r of k(t))e.indexOf(r)<0&&G.call(t,r)&&(o[r]=t[r]);return o};var f=(t,e,o)=>new Promise((r,n)=>{var l=s=>{try{i(o.next(s))}catch(a){n(a)}},c=s=>{try{i(o.throw(s))}catch(a){n(a)}},i=s=>s.done?r(s.value):Promise.resolve(s.value).then(l,c);i((o=o.apply(t,e)).next())});import{install as eo}from"@twind/core";import{defineConfig as Bt}from"@twind/core";import Dt from"@twind/preset-tailwind";var X=Bt({presets:[Dt()]});import{assertValidNFTCollectionViewProps as jt,getNFTCollectionViewSrc as Lt}from"@crossmint/client-sdk-base";var Q="1.3.24";var y=Q;import{jsx as Ut}from"react/jsx-runtime";function uo(t){jt(t);let e=Lt(t,y);return Ut("iframe",{src:e,width:"100%",height:"100%",style:{flexGrow:"1",border:"none",margin:"0",padding:"0"},role:"nft-collection-view"})}import{assertValidValidateNFTDetailProps as _t,getNFTDetailSrc as Ht}from"@crossmint/client-sdk-base";import{jsx as Kt}from"react/jsx-runtime";function ho(t){_t(t);let e=Ht(t,y);return Kt("iframe",{src:e,width:"100%",height:"100%",style:{flexGrow:"1",border:"none",margin:"0",padding:"0"},role:"nft-details"})}import{isCryptoEmbeddedCheckoutProps as ae,isFiatEmbeddedCheckoutProps as le}from"@crossmint/client-sdk-base";import{isCryptoEmbeddedCheckoutPropsWithSigner as ee}from"@crossmint/client-sdk-base";import Xt from"bs58";import{IncomingInternalEvents as et,OutgoingInternalEvents as ot,crossmintIFrameService as Qt,embeddedCheckoutPropsToUpdatableParamsPayload as Zt}from"@crossmint/client-sdk-base";import $t from"lodash.isequal";import{useEffect as Yt,useRef as zt}from"react";function w(t,e){let o=zt(e);Yt(()=>{if(e.some((n,l)=>!$t(n,o.current[l])))return o.current=e,t()},[e])}import{useEffect as Z,useState as tt}from"react";import{IncomingInternalEvents as Jt,crossmintIFrameService as Gt}from"@crossmint/client-sdk-base";import{jsx as qt}from"react/jsx-runtime";function E(o){var r=o,{onInternalEvent:t}=r,e=v(r,["onInternalEvent"]);let{getUrl:n,listenToEvents:l,listenToInternalEvents:c}=Gt(e),[i,s]=tt(0),[a]=tt(n(e));return Z(()=>{let m=l(d=>{var p;return(p=e.onEvent)==null?void 0:p.call(e,d.data)});return()=>{m()}},[]),Z(()=>{let m=c(d=>{let{type:p,payload:h}=d.data;p===Jt.UI_HEIGHT_CHANGED&&s(h.height),t==null||t(d.data)});return()=>{m()}},[]),qt("iframe",{src:a,id:"crossmint-embedded-checkout.iframe",role:"crossmint-embedded-checkout.iframe",allow:"payment *",style:{boxShadow:"none",border:"none",padding:"0px",width:"100%",minWidth:"100%",overflow:"hidden",display:"block",userSelect:"none",transform:"translate(0px)",opacity:"1",transition:"ease 0s, opacity 0.4s ease 0.1s",height:`${i}px`}})}import{jsx as te}from"react/jsx-runtime";function R(t){let{emitInternalEvent:e}=Qt(t),{signer:o,paymentMethod:r}=t;function n(s){let{type:a,payload:m}=s;if(a===et.CRYPTO_PAYMENT_INCOMING_TRANSACTION){let{serializedTransaction:d}=m;console.log("[Crossmint] Received incoming transaction",d),l(d)}if(a===et.CRYPTO_CHAIN_SWITCH){let{chain:d}=m;console.log("[Crossmint] Received change of chain",d);let p=o.handleChainSwitch;if(p==null)throw new Error("switchNetwork function should have been defined");p(d)}}function l(s){return f(this,null,function*(){try{let a;switch(r){case"SOL":a=yield c(o,s);break;case"ETH":a=yield i(o,s);break;default:throw new Error(`Unsupported payment method ${r}`)}console.log("[Crossmint] Signed and sent transaction",a),e({type:ot.CRYPTO_PAYMENT_USER_ACCEPTED,payload:{txId:a}})}catch(a){console.error("[Crossmint] Failed to sign and send transaction",a),e({type:ot.CRYPTO_PAYMENT_USER_REJECTED,payload:{}})}})}function c(s,a){return f(this,null,function*(){let{Transaction:m}=yield import("@solana/web3.js"),d=m.from(Xt.decode(a));return console.log("[Crossmint] Deserialized SOL transaction",d),yield s.signAndSendTransaction(d)})}function i(s,a){return f(this,null,function*(){let{parse:m}=yield import("@ethersproject/transactions"),d=m(a);return console.log("[Crossmint] Deserialized ETH transaction",d),yield s.signAndSendTransaction(d)})}return w(()=>{e({type:"params-update",payload:Zt(t)})},[t.signer.address,t.recipient,t.mintConfig,t.locale,t.currency,t.whPassThroughArgs,..."chain"in t.signer?[t.signer.chain]:[]]),te(E,u({onInternalEvent:n},t))}import{jsx as oe}from"react/jsx-runtime";function rt(t){if(!ee(t))throw new Error("Invalid parameters: signer is required in versions < 2.0.0");return oe(R,u({},t))}import{crossmintIFrameService as re,embeddedCheckoutPropsToUpdatableParamsPayload as ne}from"@crossmint/client-sdk-base";import{jsx as se}from"react/jsx-runtime";function M(t){let{emitInternalEvent:e}=re(t);return w(()=>{e({type:"params-update",payload:ne(t)})},[t.recipient,t.mintConfig,t.locale,t.currency,t.whPassThroughArgs]),se(E,u({},t))}import{jsx as ie}from"react/jsx-runtime";function nt(t){return ie(M,u({},t))}import{jsx as st}from"react/jsx-runtime";function Zo(t){if(le(t))return st(nt,u({},t));if(ae(t))return st(rt,u({},t));throw new Error("Unsupported: Fiat is the only supported payment method.")}import{useMemo as fe}from"react";import{useState as ge}from"react";import{clientNames as Ce,crossmintModalService as he,crossmintPayButtonService as ye}from"@crossmint/client-sdk-base";import{useEffect as de,useState as me}from"react";function F(){let[t,e]=me(!0);return de(()=>{e(!1)},[]),{isServerSideRendering:t}}import{createUseStyles as ce}from"react-jss";var ue="#1e1e1e",it=t=>t==="light",at=t=>({buttonBgColor:it(t)?"white":ue,paragraphColor:it(t)?"black":"white"}),pe={"@global":{"@import":"url('https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap')"},crossmintButton:{display:"flex","flex-direction":"row","align-items":"center",padding:"0.875rem 0.875rem","font-weight":"900",transition:"opacity ease-in-out 0.25s","border-radius":"0.5rem","font-family":'"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif',outline:"none",border:"none","box-shadow":"0px 8px 15px rgba(0, 0, 0, 0.1)","justify-content":"center",background:({buttonBgColor:t})=>t,"&:hover:enabled":{opacity:"0.6",cursor:"pointer"}},crossmintImg:{width:"21px",height:"21px","margin-right":"0.875rem"},crossmintParagraph:{color:({paragraphColor:t})=>t,margin:"0"}},lt=ce(pe);import{Fragment as Ee,jsx as O,jsxs as we}from"react/jsx-runtime";function pr(t){let Y=t,{className:e,disabled:o,onClick:r,style:n,tabIndex:l,theme:c="dark",mintTo:i,emailTo:s,listingId:a,auctionId:m,showOverlay:d=!0,mintConfig:p,whPassThroughArgs:h,environment:C,paymentMethod:b,preferredSigninMethod:Ct,dismissOverlayOnClick:ht,prepay:yt,locale:K="en-US",currency:wt="usd",successCallbackURL:Et="",failureCallbackURL:bt="",loginEmail:St="",projectId:kt,getButtonText:W,checkoutProps:$={experimental:!1,display:"same-tab",paymentMethods:["fiat","ETH","SOL"]}}=Y,A=v(Y,["className","disabled","onClick","style","tabIndex","theme","mintTo","emailTo","listingId","auctionId","showOverlay","mintConfig","whPassThroughArgs","environment","paymentMethod","preferredSigninMethod","dismissOverlayOnClick","prepay","locale","currency","successCallbackURL","failureCallbackURL","loginEmail","projectId","getButtonText","checkoutProps"]),vt="clientId"in A?A.clientId:A.collectionId,[S,Pt]=ge(!1),{isServerSideRendering:xt}=F(),{connect:It}=he({clientId:vt,projectId:kt,showOverlay:d,dismissOverlayOnClick:ht,setConnecting:Pt,libVersion:y,environment:C,clientName:Ce.reactUi,locale:K,currency:wt,successCallbackURL:Et,failureCallbackURL:bt,loginEmail:St}),{getButtonText:Tt,handleClick:Wt}=ye({onClick:r,connecting:S,paymentMethod:b,locale:K,checkoutProps:$}),At=Rt=>Wt(Rt,()=>{It(p,i,s,a,h,b,Ct,yt,$)}),N=lt(at(c)),Nt=fe(()=>O("span",{className:N.crossmintParagraph,role:"button-paragraph",children:W!=null?W(S,b||"fiat"):Tt(S)}),[S,W,b]);return O(Ee,{children:!xt&&we("button",{className:`${N.crossmintButton} ${e||""}`,disabled:o,onClick:At,style:u({},n),tabIndex:l,children:[O("img",{className:N.crossmintImg,src:"https://www.crossmint.io/assets/crossmint/logo.svg",alt:"Crossmint logo"}),Nt]})})}import{createContext as be,useCallback as Se,useContext as ke,useMemo as ve,useRef as Pe,useState as xe}from"react";import{createCrossmint as Ie}from"@crossmint/common-sdk-base";import{jsx as Te}from"react/jsx-runtime";var dt=be(null);function wr({children:t,apiKey:e,overrideBaseUrl:o}){let[r,n]=xe(0),l=Pe(new Proxy(Ie({apiKey:e,overrideBaseUrl:o}),{set(s,a,m){return a==="jwt"&&s.jwt!==m&&n(d=>d+1),Reflect.set(s,a,m)}})),c=Se(s=>{s!==l.current.jwt&&(l.current.jwt=s)},[]),i=ve(()=>({get crossmint(){return l.current},setJwt:c}),[c,r]);return Te(dt.Provider,{value:i,children:t})}function P(t){let e=ke(dt);if(e==null)throw new Error(t!=null?t:"useCrossmint must be used within a CrossmintProvider");return e}import{useContext as Oe}from"react";import{createContext as We,useMemo as Ae,useState as Ne}from"react";import{SmartWalletError as mt,SmartWalletSDK as Re}from"@crossmint/client-sdk-smart-wallet";import{jsx as Fe}from"react/jsx-runtime";var B=We({status:"not-loaded",getOrCreateWallet:()=>({startedCreation:!1}),clearWallet:()=>{}});function ct({children:t,defaultChain:e}){let{crossmint:o}=P("CrossmintWalletProvider must be used within CrossmintProvider"),r=Ae(()=>Re.init({clientApiKey:o.apiKey}),[o.apiKey]),[n,l]=Ne({status:"not-loaded"}),c=(s={type:"evm-smart-wallet",signer:{type:"PASSKEY"}})=>n.status=="in-progress"?(console.log("Wallet already loading"),{startedCreation:!1,reason:"Wallet is already loading."}):o.jwt==null?{startedCreation:!1,reason:'Jwt not set in "CrossmintProvider".'}:(f(this,null,function*(){try{l({status:"in-progress"});let m=yield r.getOrCreateWallet({jwt:o.jwt},e,s);l({status:"loaded",wallet:m})}catch(m){console.error("There was an error creating a wallet ",m),l(Me(m))}}),{startedCreation:!0}),i=()=>{l({status:"not-loaded"})};return Fe(B.Provider,{value:q(u({},n),{getOrCreateWallet:c,clearWallet:i}),children:t})}function Me(t){if(t instanceof mt)return{status:"loading-error",error:t};let e=t instanceof Error?t.message:String(t),o=t instanceof Error?t.stack:void 0;return{status:"loading-error",error:new mt(`Unknown Wallet Error: ${e}`,o)}}function ut(){let t=Oe(B);if(!t)throw new Error("useWallet must be used within CrossmintAuthProvider or CrossmintWalletProvider");return t}import{useContext as to}from"react";import{createContext as Ye,useEffect as I,useState as ze}from"react";import{createPortal as Je}from"react-dom";import{validateApiKeyAndGetCrossmintBaseUrl as Ge}from"@crossmint/common-sdk-base";import{Dialog as je,Transition as V}from"@headlessui/react";import{Fragment as j,useEffect as Le,useRef as Ue,useState as _e}from"react";import{z as x}from"zod";import{IFrameWindow as He}from"@crossmint/client-sdk-window";import{jsx as pt,jsxs as Be}from"react/jsx-runtime";function D({className:t}){return Be("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[pt("path",{d:"M18 6 6 18"}),pt("path",{d:"m6 6 12 12"})]})}import{clsx as De}from"clsx";import{twMerge as Ve}from"tailwind-merge";function ft(...t){return Ve(De(t))}import{jsx as g,jsxs as gt}from"react/jsx-runtime";var Ke={jwtToken:x.object({jwtToken:x.string()})},$e={closeWindow:x.object({closeWindow:x.string()})};function U({setModalOpen:t,setJwtToken:e,apiKey:o,baseUrl:r,appearance:n}){var m,d,p,h;let l=`${r}sdk/auth/frame?apiKey=${o}`;n!=null&&(l+=`&uiConfig=${encodeURIComponent(JSON.stringify(n))}`);let c=Ue(null),[i,s]=_e(null);Le(()=>{if(i!=null)return i.on("jwtToken",C=>{e(C.jwtToken),i.off("jwtToken"),i.send("closeWindow",{closeWindow:"closeWindow"}),(i==null?void 0:i.iframe.contentWindow)!=null&&i.iframe.contentWindow.close(),t(!1)}),()=>{i&&(i.off("jwtToken"),i.iframe.contentWindow!=null&&i.iframe.contentWindow.close())}},[i,e,t]);let a=()=>f(this,null,function*(){if(c.current==null){console.error("Something wrong happened, please try again");return}let C=yield He.init(c.current,{incomingEvents:Ke,outgoingEvents:$e});s(C)});return g(V.Root,{show:!0,as:j,children:gt(je,{as:"div",style:L.dialog,onClose:()=>t(!1),children:[g(V.Child,{as:j,enter:"ease-out duration-400",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-400",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:g("div",{style:L.transitionBegin})}),g(V.Child,{as:j,enter:"ease-out duration-400",enterFrom:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",enterTo:"opacity-100 translate-y-0 sm:scale-100",leave:"ease-in duration-400",leaveFrom:"opacity-100 translate-y-0 sm:scale-100",leaveTo:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",children:gt("div",{style:L.transitionEnd,onClick:C=>C.stopPropagation(),children:[g("div",{style:{position:"relative",width:"100%"},children:g("button",{type:"button","aria-label":"Close",style:{width:"1.5rem",position:"absolute",right:"1.5rem",top:"1.5rem",cursor:"pointer",color:(d=(m=n==null?void 0:n.colors)==null?void 0:m.border)!=null?d:"#909ca3",outlineOffset:"4px",borderRadius:"100%"},onClick:()=>t(!1),children:g(D,{})})}),g("iframe",{ref:c,src:l,onLoad:a,title:"Authentication Modal",className:ft("w-full h-[500px] border pt-12 pb-8",(p=n==null?void 0:n.colors)!=null&&p.border?`border-[${n.colors.border}]`:"border-[#D0D5DD]",n!=null&&n.borderRadius?`rounded-[${n.borderRadius}]`:"rounded-2xl",(h=n==null?void 0:n.colors)!=null&&h.background?`bg-[${n.colors.background}]`:"bg-white")})]})})]})})}var L={dialog:{display:"flex",justifyContent:"center",alignItems:"center",overflowY:"auto",position:"fixed",top:0,right:0,bottom:0,left:0,zIndex:20},transitionBegin:{background:"rgba(139, 151, 151, 0.2)",backdropFilter:"blur(2px)",position:"fixed",top:0,right:0,bottom:0,left:0,transitionProperty:"opacity",transitionTimingFunction:"cubic-bezier(0.4, 0, 0.2, 1)",transitionDuration:"300ms",zIndex:-10},transitionEnd:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%",maxWidth:"448px",borderRadius:"0.75rem",boxShadow:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",zIndex:30}};import{Fragment as Ze,jsx as T,jsxs as Qe}from"react/jsx-runtime";var _="crossmint-session",H=Ye({login:()=>{},logout:()=>{},status:"logged-out"});function Xr({embeddedWallets:t,children:e,appearance:o}){let{crossmint:r,setJwt:n}=P("CrossmintAuthProvider must be used within CrossmintProvider"),l=Ge(r.apiKey),[c,i]=ze(!1);I(()=>{let d=Xe();d!=null&&n(d)},[]);let s=()=>{if(r.jwt!=null){console.log("User already logged in");return}i(!0)},a=()=>{document.cookie=`${_}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`,n(void 0)};I(()=>{r.jwt!=null&&i(!1)},[r.jwt]),I(()=>{r.jwt&&(document.cookie=`${_}=${r.jwt}; path=/;SameSite=Lax;`)},[r.jwt]);let m=()=>r.jwt!=null?"logged-in":c?"in-progress":"logged-out";return T(H.Provider,{value:{login:s,logout:a,jwt:r.jwt,status:m()},children:Qe(ct,{defaultChain:t.defaultChain,children:[T(qe,{embeddedWallets:t,accessToken:r.jwt,children:e}),c?Je(T(U,{baseUrl:l,setModalOpen:i,setJwtToken:n,apiKey:r.apiKey,appearance:o}),document.body):null]})})}function qe({embeddedWallets:t,children:e,accessToken:o}){let{getOrCreateWallet:r,clearWallet:n,status:l}=ut();return I(()=>{t.createOnLogin==="all-users"&&l==="not-loaded"&&o!=null&&r({type:t.type,signer:{type:"PASSKEY"}}),l==="loaded"&&o==null&&n()},[o,l]),T(Ze,{children:e})}function Xe(){let t=document.cookie.split("; ").find(e=>e.startsWith(_));return t?t.split("=")[1]:void 0}function on(){let t=to(H);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t}import{CrossmintEvents as un,useCrossmintEvents as pn}from"@crossmint/client-sdk-base";import{Chain as gn,SmartWalletError as Cn,UserWalletAlreadyCreatedError as hn,AdminAlreadyUsedError as yn,AdminMismatchError as wn,PasskeyMismatchError as En,PasskeyPromptError as bn,PasskeyRegistrationError as Sn,PasskeyIncompatibleAuthenticatorError as kn,ConfigError as vn,SmartWalletsNotEnabledError as Pn,EVMSendTransactionError as xn,EVMSendTransactionExecutionRevertedError as In}from"@crossmint/client-sdk-smart-wallet";eo(X);export{yn as AdminAlreadyUsedError,wn as AdminMismatchError,H as AuthContext,gn as Chain,vn as ConfigError,Xr as CrossmintAuthProvider,un as CrossmintEvents,uo as CrossmintNFTCollectionView,ho as CrossmintNFTDetail,pr as CrossmintPayButton,Zo as CrossmintPaymentElement,wr as CrossmintProvider,ct as CrossmintWalletProvider,xn as EVMSendTransactionError,In as EVMSendTransactionExecutionRevertedError,kn as PasskeyIncompatibleAuthenticatorError,En as PasskeyMismatchError,bn as PasskeyPromptError,Sn as PasskeyRegistrationError,Cn as SmartWalletError,Pn as SmartWalletsNotEnabledError,hn as UserWalletAlreadyCreatedError,B as WalletContext,on as useAuth,P as useCrossmint,pn as useCrossmintEvents,ut as useWallet};
1
+ var Vt=Object.defineProperty,Lt=Object.defineProperties;var jt=Object.getOwnPropertyDescriptors;var P=Object.getOwnPropertySymbols;var Z=Object.prototype.hasOwnProperty,tt=Object.prototype.propertyIsEnumerable;var Q=(t,e,o)=>e in t?Vt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,p=(t,e)=>{for(var o in e||(e={}))Z.call(e,o)&&Q(t,o,e[o]);if(P)for(var o of P(e))tt.call(e,o)&&Q(t,o,e[o]);return t},et=(t,e)=>Lt(t,jt(e));var T=(t,e)=>{var o={};for(var r in t)Z.call(t,r)&&e.indexOf(r)<0&&(o[r]=t[r]);if(t!=null&&P)for(var r of P(t))e.indexOf(r)<0&&tt.call(t,r)&&(o[r]=t[r]);return o};var h=(t,e,o)=>new Promise((r,n)=>{var i=l=>{try{a(o.next(l))}catch(s){n(s)}},m=l=>{try{a(o.throw(l))}catch(s){n(s)}},a=l=>l.done?r(l.value):Promise.resolve(l.value).then(i,m);a((o=o.apply(t,e)).next())});import{install as po}from"@twind/core";import{defineConfig as Ht}from"@twind/core";import Kt from"@twind/preset-tailwind";var ot=Ht({presets:[Kt()]});import{assertValidNFTCollectionViewProps as Jt,getNFTCollectionViewSrc as Yt}from"@crossmint/client-sdk-base";var rt="1.4.1";var E=rt;import{jsx as zt}from"react/jsx-runtime";function vo(t){Jt(t);let e=Yt(t,E);return zt("iframe",{src:e,width:"100%",height:"100%",style:{flexGrow:"1",border:"none",margin:"0",padding:"0"},role:"nft-collection-view"})}import{assertValidValidateNFTDetailProps as Gt,getNFTDetailSrc as Xt}from"@crossmint/client-sdk-base";import{jsx as qt}from"react/jsx-runtime";function Wo(t){Gt(t);let e=Xt(t,E);return qt("iframe",{src:e,width:"100%",height:"100%",style:{flexGrow:"1",border:"none",margin:"0",padding:"0"},role:"nft-details"})}import{isCryptoEmbeddedCheckoutProps as pe,isFiatEmbeddedCheckoutProps as he}from"@crossmint/client-sdk-base";import{isCryptoEmbeddedCheckoutPropsWithSigner as le}from"@crossmint/client-sdk-base";import ne from"bs58";import{IncomingInternalEvents as it,OutgoingInternalEvents as at,crossmintIFrameService as se,embeddedCheckoutPropsToUpdatableParamsPayload as ie}from"@crossmint/client-sdk-base";import Qt from"lodash.isequal";import{useEffect as Zt,useRef as te}from"react";function w(t,e){let o=te(e);Zt(()=>{if(e.some((n,i)=>!Qt(n,o.current[i])))return o.current=e,t()},[e])}import{useEffect as nt,useState as st}from"react";import{IncomingInternalEvents as ee,crossmintIFrameService as oe}from"@crossmint/client-sdk-base";import{jsx as re}from"react/jsx-runtime";function k(o){var r=o,{onInternalEvent:t}=r,e=T(r,["onInternalEvent"]);let{getUrl:n,listenToEvents:i,listenToInternalEvents:m}=oe(e),[a,l]=st(0),[s]=st(n(e));return nt(()=>{let c=i(d=>{var u;return(u=e.onEvent)==null?void 0:u.call(e,d.data)});return()=>{c()}},[]),nt(()=>{let c=m(d=>{let{type:u,payload:g}=d.data;u===ee.UI_HEIGHT_CHANGED&&l(g.height),t==null||t(d.data)});return()=>{c()}},[]),re("iframe",{src:s,id:"crossmint-embedded-checkout.iframe",role:"crossmint-embedded-checkout.iframe",allow:"payment *",style:{boxShadow:"none",border:"none",padding:"0px",width:"100%",minWidth:"100%",overflow:"hidden",display:"block",userSelect:"none",transform:"translate(0px)",opacity:"1",transition:"ease 0s, opacity 0.4s ease 0.1s",height:`${a}px`}})}import{jsx as ae}from"react/jsx-runtime";function O(t){let{emitInternalEvent:e}=se(t),{signer:o,paymentMethod:r}=t;function n(l){let{type:s,payload:c}=l;if(s===it.CRYPTO_PAYMENT_INCOMING_TRANSACTION){let{serializedTransaction:d}=c;console.log("[Crossmint] Received incoming transaction",d),i(d)}if(s===it.CRYPTO_CHAIN_SWITCH){let{chain:d}=c;console.log("[Crossmint] Received change of chain",d);let u=o.handleChainSwitch;if(u==null)throw new Error("switchNetwork function should have been defined");u(d)}}function i(l){return h(this,null,function*(){try{let s;switch(r){case"SOL":s=yield m(o,l);break;case"ETH":s=yield a(o,l);break;default:throw new Error(`Unsupported payment method ${r}`)}console.log("[Crossmint] Signed and sent transaction",s),e({type:at.CRYPTO_PAYMENT_USER_ACCEPTED,payload:{txId:s}})}catch(s){console.error("[Crossmint] Failed to sign and send transaction",s),e({type:at.CRYPTO_PAYMENT_USER_REJECTED,payload:{}})}})}function m(l,s){return h(this,null,function*(){let{Transaction:c}=yield import("@solana/web3.js"),d=c.from(ne.decode(s));return console.log("[Crossmint] Deserialized SOL transaction",d),yield l.signAndSendTransaction(d)})}function a(l,s){return h(this,null,function*(){let{parse:c}=yield import("@ethersproject/transactions"),d=c(s);return console.log("[Crossmint] Deserialized ETH transaction",d),yield l.signAndSendTransaction(d)})}return w(()=>{e({type:"params-update",payload:ie(t)})},[t.signer.address,t.recipient,t.mintConfig,t.locale,t.currency,t.whPassThroughArgs,..."chain"in t.signer?[t.signer.chain]:[]]),ae(k,p({onInternalEvent:n},t))}import{jsx as ce}from"react/jsx-runtime";function lt(t){if(!le(t))throw new Error("Invalid parameters: signer is required in versions < 2.0.0");return ce(O,p({},t))}import{crossmintIFrameService as de,embeddedCheckoutPropsToUpdatableParamsPayload as me}from"@crossmint/client-sdk-base";import{jsx as ue}from"react/jsx-runtime";function D(t){let{emitInternalEvent:e}=de(t);return w(()=>{e({type:"params-update",payload:me(t)})},[t.recipient,t.mintConfig,t.locale,t.currency,t.whPassThroughArgs]),ue(k,p({},t))}import{jsx as fe}from"react/jsx-runtime";function ct(t){return fe(D,p({},t))}import{jsx as dt}from"react/jsx-runtime";function mr(t){if(he(t))return dt(ct,p({},t));if(pe(t))return dt(lt,p({},t));throw new Error("Unsupported: Fiat is the only supported payment method.")}import{useMemo as ke}from"react";import{useState as be}from"react";import{clientNames as Se,crossmintModalService as ve,crossmintPayButtonService as Pe}from"@crossmint/client-sdk-base";import{useEffect as ge,useState as Ce}from"react";function U(){let[t,e]=Ce(!0);return ge(()=>{e(!1)},[]),{isServerSideRendering:t}}import{createUseStyles as ye}from"react-jss";var Ee="#1e1e1e",mt=t=>t==="light",ut=t=>({buttonBgColor:mt(t)?"white":Ee,paragraphColor:mt(t)?"black":"white"}),we={"@global":{"@import":"url('https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap')"},crossmintButton:{display:"flex","flex-direction":"row","align-items":"center",padding:"0.875rem 0.875rem","font-weight":"900",transition:"opacity ease-in-out 0.25s","border-radius":"0.5rem","font-family":'"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif',outline:"none",border:"none","box-shadow":"0px 8px 15px rgba(0, 0, 0, 0.1)","justify-content":"center",background:({buttonBgColor:t})=>t,"&:hover:enabled":{opacity:"0.6",cursor:"pointer"}},crossmintImg:{width:"21px",height:"21px","margin-right":"0.875rem"},crossmintParagraph:{color:({paragraphColor:t})=>t,margin:"0"}},ft=ye(we);import{Fragment as xe,jsx as _,jsxs as Te}from"react/jsx-runtime";function Pr(t){let q=t,{className:e,disabled:o,onClick:r,style:n,tabIndex:i,theme:m="dark",mintTo:a,emailTo:l,listingId:s,auctionId:c,showOverlay:d=!0,mintConfig:u,whPassThroughArgs:g,environment:f,paymentMethod:S,preferredSigninMethod:St,dismissOverlayOnClick:vt,prepay:Pt,locale:G="en-US",currency:Tt="usd",successCallbackURL:xt="",failureCallbackURL:It="",loginEmail:Wt="",projectId:At,getButtonText:F,checkoutProps:X={experimental:!1,display:"same-tab",paymentMethods:["fiat","ETH","SOL"]}}=q,M=T(q,["className","disabled","onClick","style","tabIndex","theme","mintTo","emailTo","listingId","auctionId","showOverlay","mintConfig","whPassThroughArgs","environment","paymentMethod","preferredSigninMethod","dismissOverlayOnClick","prepay","locale","currency","successCallbackURL","failureCallbackURL","loginEmail","projectId","getButtonText","checkoutProps"]),Rt="clientId"in M?M.clientId:M.collectionId,[v,Ft]=be(!1),{isServerSideRendering:Mt}=U(),{connect:Nt}=ve({clientId:Rt,projectId:At,showOverlay:d,dismissOverlayOnClick:vt,setConnecting:Ft,libVersion:E,environment:f,clientName:Se.reactUi,locale:G,currency:Tt,successCallbackURL:xt,failureCallbackURL:It,loginEmail:Wt}),{getButtonText:Ot,handleClick:Dt}=Pe({onClick:r,connecting:v,paymentMethod:S,locale:G,checkoutProps:X}),Ut=Bt=>Dt(Bt,()=>{Nt(u,a,l,s,g,S,St,Pt,X)}),N=ft(ut(m)),_t=ke(()=>_("span",{className:N.crossmintParagraph,role:"button-paragraph",children:F!=null?F(v,S||"fiat"):Ot(v)}),[v,F,S]);return _(xe,{children:!Mt&&Te("button",{className:`${N.crossmintButton} ${e||""}`,disabled:o,onClick:Ut,style:p({},n),tabIndex:i,children:[_("img",{className:N.crossmintImg,src:"https://www.crossmint.io/assets/crossmint/logo.svg",alt:"Crossmint logo"}),_t]})})}import{createContext as Ie,useCallback as pt,useContext as We,useMemo as Ae,useRef as Re,useState as Fe}from"react";import{createCrossmint as Me}from"@crossmint/common-sdk-base";import{jsx as Ne}from"react/jsx-runtime";var ht=Ie(null);function Rr({children:t,apiKey:e,overrideBaseUrl:o}){let[r,n]=Fe(0),i=Re(new Proxy(Me({apiKey:e,overrideBaseUrl:o}),{set(s,c,d){return c==="jwt"&&s.jwt!==d&&n(u=>u+1),c==="refreshToken"&&s.refreshToken!==d&&n(u=>u+1),Reflect.set(s,c,d)}})),m=pt(s=>{s!==i.current.jwt&&(i.current.jwt=s)},[]),a=pt(s=>{s!==i.current.refreshToken&&(i.current.refreshToken=s)},[]),l=Ae(()=>({get crossmint(){return i.current},setJwt:m,setRefreshToken:a}),[m,a,r]);return Ne(ht.Provider,{value:l,children:t})}function x(t){let e=We(ht);if(e==null)throw new Error(t!=null?t:"useCrossmint must be used within a CrossmintProvider");return e}import{useContext as Le}from"react";import{createContext as Oe,useMemo as De,useState as Ue}from"react";import{SmartWalletError as gt,SmartWalletSDK as _e}from"@crossmint/client-sdk-smart-wallet";import{jsx as Ve}from"react/jsx-runtime";var B=Oe({status:"not-loaded",getOrCreateWallet:()=>({startedCreation:!1}),clearWallet:()=>{}});function Ct({children:t,defaultChain:e}){let{crossmint:o}=x("CrossmintWalletProvider must be used within CrossmintProvider"),r=De(()=>_e.init({clientApiKey:o.apiKey}),[o.apiKey]),[n,i]=Ue({status:"not-loaded"}),m=(l={type:"evm-smart-wallet",signer:{type:"PASSKEY"}})=>n.status=="in-progress"?(console.log("Wallet already loading"),{startedCreation:!1,reason:"Wallet is already loading."}):o.jwt==null?{startedCreation:!1,reason:'Jwt not set in "CrossmintProvider".'}:(h(this,null,function*(){try{i({status:"in-progress"});let c=yield r.getOrCreateWallet({jwt:o.jwt},e,l);i({status:"loaded",wallet:c})}catch(c){console.error("There was an error creating a wallet ",c),i(Be(c))}}),{startedCreation:!0}),a=()=>{i({status:"not-loaded"})};return Ve(B.Provider,{value:et(p({},n),{getOrCreateWallet:m,clearWallet:a}),children:t})}function Be(t){if(t instanceof gt)return{status:"loading-error",error:t};let e=t instanceof Error?t.message:String(t),o=t instanceof Error?t.stack:void 0;return{status:"loading-error",error:new gt(`Unknown Wallet Error: ${e}`,o)}}function yt(){let t=Le(B);if(!t)throw new Error("useWallet must be used within CrossmintAuthProvider or CrossmintWalletProvider");return t}import{useContext as io}from"react";var I="crossmint-session",b="crossmint-refresh-token";function W(t){let e=document.cookie.split("; ").find(o=>o.startsWith(t));return e?e.split("=")[1]:void 0}function V(t,e,o){let r=o?new Date(o).toUTCString():"";document.cookie=`${t}=${e}; ${o?`expires=${r};`:""} path=/; SameSite=Lax;`}function L(t){document.cookie=`${t}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`}import{createContext as Qe,useEffect as Y,useState as Ze}from"react";import{createPortal as to}from"react-dom";import{CrossmintAuthService as eo}from"@crossmint/client-sdk-auth-core/client";import{validateApiKeyAndGetCrossmintBaseUrl as oo}from"@crossmint/common-sdk-base";import{Dialog as $e,Transition as H}from"@headlessui/react";import{Fragment as K,useEffect as Je,useRef as Ye,useState as ze}from"react";import{z as y}from"zod";import{IFrameWindow as Ge}from"@crossmint/client-sdk-window";import{jsx as Et,jsxs as je}from"react/jsx-runtime";function j({className:t}){return je("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[Et("path",{d:"M18 6 6 18"}),Et("path",{d:"m6 6 12 12"})]})}import{clsx as He}from"clsx";import{twMerge as Ke}from"tailwind-merge";function wt(...t){return Ke(He(t))}import{jsx as C,jsxs as kt}from"react/jsx-runtime";var Xe={authMaterialFromAuthFrame:y.object({jwtToken:y.string(),refreshToken:y.object({secret:y.string(),expiresAt:y.string()})})},qe={closeWindow:y.object({closeWindow:y.string()})};function J({setModalOpen:t,setAuthMaterial:e,apiKey:o,baseUrl:r,appearance:n}){var c,d,u,g;let i=`${r}sdk/auth/frame?apiKey=${o}`;n!=null&&(i+=`&uiConfig=${encodeURIComponent(JSON.stringify(n))}`);let m=Ye(null),[a,l]=ze(null);Je(()=>{if(a!=null)return a.on("authMaterialFromAuthFrame",f=>{e(f),a.off("authMaterialFromAuthFrame"),a.send("closeWindow",{closeWindow:"closeWindow"}),(a==null?void 0:a.iframe.contentWindow)!=null&&a.iframe.contentWindow.close(),t(!1)}),()=>{a&&(a.off("authMaterialFromAuthFrame"),a.iframe.contentWindow!=null&&a.iframe.contentWindow.close())}},[a,e,t]);let s=()=>h(this,null,function*(){if(m.current==null){console.error("Something wrong happened, please try again");return}let f=yield Ge.init(m.current,{incomingEvents:Xe,outgoingEvents:qe});l(f)});return C(H.Root,{show:!0,as:K,children:kt($e,{as:"div",style:$.dialog,onClose:()=>t(!1),children:[C(H.Child,{as:K,enter:"ease-out duration-400",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-400",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:C("div",{style:$.transitionBegin})}),C(H.Child,{as:K,enter:"ease-out duration-400",enterFrom:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",enterTo:"opacity-100 translate-y-0 sm:scale-100",leave:"ease-in duration-400",leaveFrom:"opacity-100 translate-y-0 sm:scale-100",leaveTo:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",children:kt("div",{style:$.transitionEnd,onClick:f=>f.stopPropagation(),children:[C("div",{style:{position:"relative",width:"100%"},children:C("button",{type:"button","aria-label":"Close",style:{width:"1.5rem",position:"absolute",right:"1.5rem",top:"1.5rem",cursor:"pointer",color:(d=(c=n==null?void 0:n.colors)==null?void 0:c.border)!=null?d:"#909ca3",outlineOffset:"4px",borderRadius:"100%"},onClick:()=>t(!1),children:C(j,{})})}),C("iframe",{ref:m,src:i,onLoad:s,title:"Authentication Modal",className:wt("w-full h-[500px] border pt-12 pb-8",(u=n==null?void 0:n.colors)!=null&&u.border?`border-[${n.colors.border}]`:"border-[#D0D5DD]",n!=null&&n.borderRadius?`rounded-[${n.borderRadius}]`:"rounded-2xl",(g=n==null?void 0:n.colors)!=null&&g.background?`bg-[${n.colors.background}]`:"bg-white")})]})})]})})}var $={dialog:{display:"flex",justifyContent:"center",alignItems:"center",overflowY:"auto",position:"fixed",top:0,right:0,bottom:0,left:0,zIndex:20},transitionBegin:{background:"rgba(139, 151, 151, 0.2)",backdropFilter:"blur(2px)",position:"fixed",top:0,right:0,bottom:0,left:0,transitionProperty:"opacity",transitionTimingFunction:"cubic-bezier(0.4, 0, 0.2, 1)",transitionDuration:"300ms",zIndex:-10},transitionEnd:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%",maxWidth:"448px",borderRadius:"0.75rem",boxShadow:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",zIndex:30}};import{Fragment as so,jsx as A,jsxs as no}from"react/jsx-runtime";var z=Qe({login:()=>{},logout:()=>{},status:"logged-out"});function fn({embeddedWallets:t,children:e,appearance:o}){let{crossmint:r,setJwt:n,setRefreshToken:i}=x("CrossmintAuthProvider must be used within CrossmintProvider"),m=new eo(r.apiKey),a=oo(r.apiKey),[l,s]=Ze(!1),c=f=>{V(I,f.jwtToken),V(b,f.refreshToken.secret,f.refreshToken.expiresAt),n(f.jwtToken),i(f.refreshToken.secret)},d=()=>{L(I),L(b),n(void 0),i(void 0)};bt({crossmintAuthService:m,setAuthMaterial:c,logout:d});let u=()=>{if(r.jwt!=null){console.log("User already logged in");return}s(!0)};Y(()=>{if(r.jwt==null){let f=W(I);n(f)}},[]),Y(()=>{r.jwt!=null&&s(!1)},[r.jwt]);let g=()=>r.jwt!=null?"logged-in":l?"in-progress":"logged-out";return A(z.Provider,{value:{login:u,logout:d,jwt:r.jwt,refreshToken:r.refreshToken,status:g()},children:no(Ct,{defaultChain:t.defaultChain,children:[A(ro,{embeddedWallets:t,accessToken:r.jwt,children:e}),l?to(A(J,{baseUrl:a,setModalOpen:s,setAuthMaterial:c,apiKey:r.apiKey,appearance:o}),document.body):null]})})}function ro({embeddedWallets:t,children:e,accessToken:o}){let{getOrCreateWallet:r,clearWallet:n,status:i}=yt();return Y(()=>{t.createOnLogin==="all-users"&&i==="not-loaded"&&o!=null&&r({type:t.type,signer:{type:"PASSKEY"}}),i==="loaded"&&o==null&&n()},[o,i]),A(so,{children:e})}function yn(){let t=io(z);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t}import{useCallback as ao,useEffect as lo,useRef as co}from"react";import{getJWTExpiration as mo}from"@crossmint/client-sdk-auth-core/client";import{queueTask as uo}from"@crossmint/client-sdk-base";var fo=120,R=null;function bt({crossmintAuthService:t,setAuthMaterial:e,logout:o}){let r=co(null),n=ao(()=>{if(R!=null)return R;let i=W(b);i!=null&&(R=h(this,null,function*(){try{let m=yield t.refreshAuthMaterial(i);e(m);let a=mo(m.jwtToken);if(a==null)throw new Error("Invalid JWT");let l=Date.now()/1e3,s=a-l-fo;if(s>0){let c=Date.now()+s*1e3;r.current=uo(n,c)}}catch(m){o(),console.error(m)}finally{R=null}}))},[]);lo(()=>(n(),()=>{r.current&&r.current.cancel()}),[])}import{CrossmintEvents as Mn,useCrossmintEvents as Nn}from"@crossmint/client-sdk-base";import{Chain as Dn,SmartWalletError as Un,UserWalletAlreadyCreatedError as _n,AdminAlreadyUsedError as Bn,AdminMismatchError as Vn,PasskeyMismatchError as Ln,PasskeyPromptError as jn,PasskeyRegistrationError as Hn,PasskeyIncompatibleAuthenticatorError as Kn,ConfigError as $n,SmartWalletsNotEnabledError as Jn,EVMSendTransactionError as Yn,EVMSendTransactionExecutionRevertedError as zn}from"@crossmint/client-sdk-smart-wallet";po(ot);export{Bn as AdminAlreadyUsedError,Vn as AdminMismatchError,z as AuthContext,Dn as Chain,$n as ConfigError,fn as CrossmintAuthProvider,Mn as CrossmintEvents,vo as CrossmintNFTCollectionView,Wo as CrossmintNFTDetail,Pr as CrossmintPayButton,mr as CrossmintPaymentElement,Rr as CrossmintProvider,Ct as CrossmintWalletProvider,Yn as EVMSendTransactionError,zn as EVMSendTransactionExecutionRevertedError,Kn as PasskeyIncompatibleAuthenticatorError,Ln as PasskeyMismatchError,jn as PasskeyPromptError,Hn as PasskeyRegistrationError,Un as SmartWalletError,Jn as SmartWalletsNotEnabledError,_n as UserWalletAlreadyCreatedError,B as WalletContext,yn as useAuth,x as useCrossmint,Nn as useCrossmintEvents,bt as useRefreshToken,yt as useWallet};
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/twind.config.ts","../src/components/CrossmintNFTCollectionView.tsx","../package.json","../src/consts/version.ts","../src/components/CrossmintNFTDetail.tsx","../src/components/embed/index.tsx","../src/components/embed/crypto/CryptoEmbeddedCheckout.tsx","../src/components/embed/crypto/CryptoEmbeddedCheckoutIFrame.tsx","../src/hooks/useDeepEffect.ts","../src/components/embed/EmbeddedCheckoutIFrame.tsx","../src/components/embed/fiat/FiatEmbeddedCheckoutIFrame.tsx","../src/components/embed/fiat/FiatEmbeddedCheckout.tsx","../src/components/hosted/CrossmintPayButton.tsx","../src/hooks/useEnvironment.ts","../src/components/hosted/styles.ts","../src/hooks/useCrossmint.tsx","../src/hooks/useWallet.ts","../src/providers/CrossmintWalletProvider.tsx","../src/hooks/useAuth.ts","../src/providers/CrossmintAuthProvider.tsx","../src/components/auth/AuthModal.tsx","../src/icons/x.tsx","../src/utils/classNames.ts"],"sourcesContent":["import { install } from \"@twind/core\";\n\nimport twindConfig from \"./twind.config\";\n\n// Initialize twind with custom configuration\n// This sets up the CSS-in-JS styling solution for the entire application\ninstall(twindConfig);\n\nexport * from \"./components\";\nexport * from \"./hooks\";\nexport * from \"./providers\";\n\nexport { CrossmintEvents, useCrossmintEvents } from \"@crossmint/client-sdk-base\";\nexport {\n type EVMSmartWallet,\n type ExternalSigner,\n type PasskeySigner,\n Chain,\n SmartWalletError,\n UserWalletAlreadyCreatedError,\n AdminAlreadyUsedError,\n AdminMismatchError,\n PasskeyMismatchError,\n PasskeyPromptError,\n PasskeyRegistrationError,\n PasskeyIncompatibleAuthenticatorError,\n ConfigError,\n SmartWalletsNotEnabledError,\n EVMSendTransactionError,\n EVMSendTransactionExecutionRevertedError,\n} from \"@crossmint/client-sdk-smart-wallet\";\nexport type { CrossmintEvent, CrossmintEventMap } from \"@crossmint/client-sdk-base\";\n","import { defineConfig } from \"@twind/core\";\nimport presetTailwind from \"@twind/preset-tailwind\";\n\nexport default defineConfig({\n presets: [presetTailwind(/* options */)],\n /* config */\n});\n","import { assertValidNFTCollectionViewProps, getNFTCollectionViewSrc } from \"@crossmint/client-sdk-base\";\nimport type { NFTCollectionViewProps } from \"@crossmint/common-sdk-base\";\n\nimport { LIB_VERSION } from \"../consts/version\";\n\nexport function CrossmintNFTCollectionView(props: NFTCollectionViewProps) {\n assertValidNFTCollectionViewProps(props);\n\n const src = getNFTCollectionViewSrc(props, LIB_VERSION);\n\n return (\n <iframe\n src={src}\n width=\"100%\"\n height=\"100%\"\n style={{\n flexGrow: \"1\",\n border: \"none\",\n margin: \"0\",\n padding: \"0\",\n }}\n role=\"nft-collection-view\"\n />\n );\n}\n","{\n \"name\": \"@crossmint/client-sdk-react-ui\",\n \"version\": \"1.3.24\",\n \"repository\": \"https://github.com/Crossmint/crossmint-sdk\",\n \"license\": \"Apache-2.0\",\n \"author\": \"Paella Labs Inc\",\n \"sideEffects\": false,\n \"type\": \"module\",\n \"exports\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"files\": [\n \"dist\",\n \"src\",\n \"LICENSE\"\n ],\n \"scripts\": {\n \"build\": \"tsup src/index.ts --clean --external react,react-dom --format esm,cjs --outDir ./dist --minify --dts --sourcemap\",\n \"dev\": \"tsup src/index.ts --clean --external react,react-dom --format esm,cjs --outDir ./dist --dts --sourcemap --watch\",\n \"test\": \"vitest run\"\n },\n \"dependencies\": {\n \"@crossmint/client-sdk-auth-core\": \"workspace:*\",\n \"@crossmint/client-sdk-base\": \"workspace:*\",\n \"@crossmint/client-sdk-smart-wallet\": \"workspace:*\",\n \"@crossmint/client-sdk-window\": \"workspace:*\",\n \"@crossmint/common-sdk-base\": \"workspace:*\",\n \"@ethersproject/transactions\": \"5.7.0\",\n \"@headlessui/react\": \"2.1.5\",\n \"@solana/web3.js\": \"1.95.1\",\n \"@twind/core\": \"1.1.3\",\n \"@twind/preset-tailwind\": \"1.1.4\",\n \"bs58\": \"5.0.0\",\n \"clsx\": \"2.1.1\",\n \"lodash.isequal\": \"4.5.0\",\n \"react-jss\": \"10.10.0\",\n \"tailwind-merge\": \"2.4.0\",\n \"tailwindcss\": \"3.4.10\",\n \"zod\": \"3.22.4\"\n },\n \"devDependencies\": {\n \"@types/lodash.isequal\": \"4.5.6\",\n \"@types/react\": \"^18.3.0\",\n \"@types/react-dom\": \"^18.3.0\",\n \"react\": \"^18.3.0\",\n \"react-dom\": \"^18.3.0\"\n },\n \"peerDependencies\": {\n \"react\": \">=17.0.2\",\n \"react-dom\": \">=17.0.2\"\n }\n}\n","import { version } from \"../../package.json\";\n\nexport const LIB_VERSION = version;\n","import { assertValidValidateNFTDetailProps, getNFTDetailSrc } from \"@crossmint/client-sdk-base\";\nimport type { NFTDetailProps } from \"@crossmint/common-sdk-base\";\n\nimport { LIB_VERSION } from \"../consts/version\";\n\nexport function CrossmintNFTDetail(props: NFTDetailProps) {\n assertValidValidateNFTDetailProps(props);\n\n const src = getNFTDetailSrc(props, LIB_VERSION);\n\n return (\n <iframe\n src={src}\n width=\"100%\"\n height=\"100%\"\n style={{\n flexGrow: \"1\",\n border: \"none\",\n margin: \"0\",\n padding: \"0\",\n }}\n role=\"nft-details\"\n />\n );\n}\n","import {\n type CrossmintEmbeddedCheckoutProps,\n isCryptoEmbeddedCheckoutProps,\n isFiatEmbeddedCheckoutProps,\n} from \"@crossmint/client-sdk-base\";\n\nimport { CrossmintCryptoEmbeddedCheckout } from \"./crypto/CryptoEmbeddedCheckout\";\nimport { CrossmintFiatEmbeddedCheckout } from \"./fiat/FiatEmbeddedCheckout\";\n\n// TODO: Rename to CrossmintEmbeddedCheckout on v2 major publish, prior announcement since its a breaking change\nexport function CrossmintPaymentElement(props: CrossmintEmbeddedCheckoutProps) {\n if (isFiatEmbeddedCheckoutProps(props)) {\n return <CrossmintFiatEmbeddedCheckout {...props} />;\n }\n if (isCryptoEmbeddedCheckoutProps(props)) {\n return <CrossmintCryptoEmbeddedCheckout {...props} />;\n }\n throw new Error(\"Unsupported: Fiat is the only supported payment method.\");\n}\n","import { type CryptoEmbeddedCheckoutProps, isCryptoEmbeddedCheckoutPropsWithSigner } from \"@crossmint/client-sdk-base\";\n\nimport CryptoEmbeddedCheckoutIFrame from \"./CryptoEmbeddedCheckoutIFrame\";\n\nexport function CrossmintCryptoEmbeddedCheckout(props: CryptoEmbeddedCheckoutProps) {\n if (!isCryptoEmbeddedCheckoutPropsWithSigner(props)) {\n throw new Error(\"Invalid parameters: signer is required in versions < 2.0.0\");\n }\n\n return <CryptoEmbeddedCheckoutIFrame {...props} />;\n}\n","import bs58 from \"bs58\";\n\nimport {\n type CryptoEmbeddedCheckoutPropsWithSigner,\n type ETHEmbeddedCheckoutSigner,\n type IncomingInternalEvent,\n IncomingInternalEvents,\n OutgoingInternalEvents,\n type SOLEmbeddedCheckoutSigner,\n crossmintIFrameService,\n embeddedCheckoutPropsToUpdatableParamsPayload,\n} from \"@crossmint/client-sdk-base\";\nimport type { EVMBlockchainIncludingTestnet } from \"@crossmint/common-sdk-base\";\n\nimport useDeepEffect from \"../../../hooks/useDeepEffect\";\nimport CrossmintEmbeddedCheckoutIFrame from \"../EmbeddedCheckoutIFrame\";\n\nexport default function CryptoEmbeddedCheckoutIFrame(props: CryptoEmbeddedCheckoutPropsWithSigner) {\n const { emitInternalEvent } = crossmintIFrameService(props);\n\n const { signer, paymentMethod } = props;\n\n function onInternalEvent(event: IncomingInternalEvent) {\n const { type, payload } = event;\n\n if (type === IncomingInternalEvents.CRYPTO_PAYMENT_INCOMING_TRANSACTION) {\n const { serializedTransaction } = payload;\n console.log(\"[Crossmint] Received incoming transaction\", serializedTransaction);\n handleIncomingTransaction(serializedTransaction);\n }\n\n if (type === IncomingInternalEvents.CRYPTO_CHAIN_SWITCH) {\n const { chain } = payload;\n console.log(\"[Crossmint] Received change of chain\", chain);\n\n const handleChainSwitch = (signer as ETHEmbeddedCheckoutSigner).handleChainSwitch;\n if (handleChainSwitch == null) {\n throw new Error(\"switchNetwork function should have been defined\");\n }\n handleChainSwitch(chain as EVMBlockchainIncludingTestnet);\n }\n }\n\n async function handleIncomingTransaction(serializedTransaction: string) {\n try {\n let txId: string;\n switch (paymentMethod) {\n case \"SOL\":\n txId = await handleSOLTransaction(signer, serializedTransaction);\n break;\n case \"ETH\":\n txId = await handleETHTransaction(signer, serializedTransaction);\n break;\n default:\n throw new Error(`Unsupported payment method ${paymentMethod}`);\n }\n\n console.log(\"[Crossmint] Signed and sent transaction\", txId);\n emitInternalEvent({\n type: OutgoingInternalEvents.CRYPTO_PAYMENT_USER_ACCEPTED,\n payload: {\n txId,\n },\n });\n } catch (e) {\n console.error(\"[Crossmint] Failed to sign and send transaction\", e);\n emitInternalEvent({\n type: OutgoingInternalEvents.CRYPTO_PAYMENT_USER_REJECTED,\n payload: {},\n });\n }\n }\n\n async function handleSOLTransaction(signer: SOLEmbeddedCheckoutSigner, serializedTransaction: string) {\n // @ts-ignore - Error becasue we dont use 'module' field in tsconfig, which is expected because we use tsup to compile\n const { Transaction } = await import(\"@solana/web3.js\");\n const transaction = Transaction.from(bs58.decode(serializedTransaction));\n console.log(\"[Crossmint] Deserialized SOL transaction\", transaction);\n\n return await signer.signAndSendTransaction(transaction);\n }\n\n async function handleETHTransaction(signer: ETHEmbeddedCheckoutSigner, serializedTransaction: string) {\n // @ts-ignore - Error becasue we dont use 'module' field in tsconfig, which is expected because we use tsup to compile\n const { parse: parseTransaction } = await import(\"@ethersproject/transactions\");\n const transaction = parseTransaction(serializedTransaction);\n console.log(\"[Crossmint] Deserialized ETH transaction\", transaction);\n\n return await signer.signAndSendTransaction(transaction);\n }\n\n useDeepEffect(() => {\n emitInternalEvent({\n type: \"params-update\",\n payload: embeddedCheckoutPropsToUpdatableParamsPayload(props),\n });\n }, [\n props.signer.address,\n props.recipient,\n props.mintConfig,\n props.locale,\n props.currency,\n props.whPassThroughArgs,\n ...(\"chain\" in props.signer ? [props.signer.chain] : []),\n ]);\n\n return <CrossmintEmbeddedCheckoutIFrame onInternalEvent={onInternalEvent} {...props} />;\n}\n","import isEqual from \"lodash.isequal\";\nimport { type DependencyList, type EffectCallback, useEffect, useRef } from \"react\";\n\nexport default function useDeepEffect(callback: EffectCallback, dependencies: DependencyList): void {\n const dependenciesRef = useRef(dependencies);\n\n useEffect(() => {\n const hasChanged = dependencies.some((dep, i) => !isEqual(dep, dependenciesRef.current[i]));\n\n if (hasChanged) {\n dependenciesRef.current = dependencies;\n return callback();\n }\n }, [dependencies]);\n}\n","import { useEffect, useState } from \"react\";\n\nimport {\n type CrossmintEmbeddedCheckoutProps,\n type IncomingInternalEvent,\n IncomingInternalEvents,\n crossmintIFrameService,\n} from \"@crossmint/client-sdk-base\";\n\ntype CrossmintEmbeddedCheckoutIFrameProps = CrossmintEmbeddedCheckoutProps & {\n onInternalEvent?: (event: IncomingInternalEvent) => void;\n};\n\nexport default function CrossmintEmbeddedCheckoutIFrame({\n onInternalEvent,\n ...props\n}: CrossmintEmbeddedCheckoutIFrameProps) {\n const { getUrl, listenToEvents, listenToInternalEvents } = crossmintIFrameService(props);\n\n const [height, setHeight] = useState(0);\n const [url] = useState(getUrl(props));\n\n // Public events\n useEffect(() => {\n const clearListener = listenToEvents((event) => props.onEvent?.(event.data));\n\n return () => {\n clearListener();\n };\n }, []);\n\n // Internal events\n useEffect(() => {\n const clearListener = listenToInternalEvents((event) => {\n const { type, payload } = event.data;\n\n if (type === IncomingInternalEvents.UI_HEIGHT_CHANGED) {\n setHeight(payload.height);\n }\n\n onInternalEvent?.(event.data);\n });\n\n return () => {\n clearListener();\n };\n }, []);\n\n return (\n <iframe\n src={url}\n id=\"crossmint-embedded-checkout.iframe\"\n role=\"crossmint-embedded-checkout.iframe\"\n allow=\"payment *\"\n style={{\n boxShadow: \"none\",\n border: \"none\",\n padding: \"0px\",\n width: \"100%\",\n minWidth: \"100%\",\n overflow: \"hidden\",\n display: \"block\",\n userSelect: \"none\",\n transform: \"translate(0px)\",\n opacity: \"1\",\n transition: \"ease 0s, opacity 0.4s ease 0.1s\",\n height: `${height}px`,\n }}\n />\n );\n}\n","import {\n type FiatEmbeddedCheckoutProps,\n crossmintIFrameService,\n embeddedCheckoutPropsToUpdatableParamsPayload,\n} from \"@crossmint/client-sdk-base\";\n\nimport useDeepEffect from \"../../../hooks/useDeepEffect\";\nimport CrossmintEmbeddedCheckoutIFrame from \"../EmbeddedCheckoutIFrame\";\n\nexport default function FiatEmbeddedCheckoutIFrame(props: FiatEmbeddedCheckoutProps) {\n const { emitInternalEvent } = crossmintIFrameService(props);\n\n useDeepEffect(() => {\n emitInternalEvent({\n type: \"params-update\",\n payload: embeddedCheckoutPropsToUpdatableParamsPayload(props),\n });\n }, [props.recipient, props.mintConfig, props.locale, props.currency, props.whPassThroughArgs]);\n\n return <CrossmintEmbeddedCheckoutIFrame {...props} />;\n}\n","import type { FiatEmbeddedCheckoutProps } from \"@crossmint/client-sdk-base\";\n\nimport FiatEmbeddedCheckoutIFrame from \"../../../components/embed/fiat/FiatEmbeddedCheckoutIFrame\";\n\nexport function CrossmintFiatEmbeddedCheckout(props: FiatEmbeddedCheckoutProps) {\n return <FiatEmbeddedCheckoutIFrame {...props} />;\n}\n","import { type CSSProperties, type MouseEvent, useMemo } from \"react\";\nimport { useState } from \"react\";\n\nimport {\n type CheckoutProps,\n type CrossmintPayButtonProps,\n clientNames,\n crossmintModalService,\n crossmintPayButtonService,\n} from \"@crossmint/client-sdk-base\";\n\nimport { LIB_VERSION } from \"../../consts/version\";\nimport useEnvironment from \"../../hooks/useEnvironment\";\nimport { formatProps, useStyles } from \"./styles\";\n\nexport type CrossmintPayButtonReactProps = CrossmintPayButtonProps & {\n onClick?: (e: MouseEvent<HTMLButtonElement>) => void;\n style?: CSSProperties;\n};\n\nexport function CrossmintPayButton(buttonProps: CrossmintPayButtonReactProps) {\n const {\n className,\n disabled,\n onClick,\n style,\n tabIndex,\n theme = \"dark\",\n mintTo,\n emailTo,\n listingId,\n auctionId,\n showOverlay = true,\n mintConfig,\n whPassThroughArgs,\n environment,\n paymentMethod,\n preferredSigninMethod,\n dismissOverlayOnClick,\n prepay,\n locale = \"en-US\",\n currency = \"usd\",\n successCallbackURL = \"\",\n failureCallbackURL = \"\",\n loginEmail = \"\",\n projectId,\n getButtonText,\n checkoutProps = {\n experimental: false,\n display: \"same-tab\",\n paymentMethods: [\"fiat\", \"ETH\", \"SOL\"],\n } as CheckoutProps,\n ...props\n } = buttonProps;\n\n const collectionId = \"clientId\" in props ? props.clientId : props.collectionId;\n\n const [connecting, setConnecting] = useState(false);\n const { isServerSideRendering } = useEnvironment();\n\n const { connect } = crossmintModalService({\n clientId: collectionId,\n projectId,\n showOverlay,\n dismissOverlayOnClick,\n setConnecting,\n libVersion: LIB_VERSION,\n environment,\n clientName: clientNames.reactUi,\n locale,\n currency,\n successCallbackURL,\n failureCallbackURL,\n loginEmail,\n });\n\n const { getButtonText: getButtonTextInternal, handleClick } = crossmintPayButtonService({\n onClick,\n connecting,\n paymentMethod,\n locale,\n checkoutProps,\n });\n\n const _handleClick = (event: MouseEvent<HTMLButtonElement>) =>\n handleClick(event, () => {\n connect(\n mintConfig,\n mintTo,\n emailTo,\n listingId,\n whPassThroughArgs,\n paymentMethod,\n preferredSigninMethod,\n prepay,\n checkoutProps\n );\n });\n\n const classes = useStyles(formatProps(theme));\n\n const content = useMemo(() => {\n return (\n <span className={classes.crossmintParagraph} role=\"button-paragraph\">\n {getButtonText != null\n ? getButtonText(connecting, paymentMethod || \"fiat\")\n : getButtonTextInternal(connecting)}\n </span>\n );\n }, [connecting, getButtonText, paymentMethod]);\n\n return (\n <>\n {!isServerSideRendering && (\n <button\n className={`${classes.crossmintButton} ${className || \"\"}`}\n disabled={disabled}\n onClick={_handleClick}\n style={{ ...style }}\n tabIndex={tabIndex}\n >\n <img\n className={classes.crossmintImg}\n src=\"https://www.crossmint.io/assets/crossmint/logo.svg\"\n alt=\"Crossmint logo\"\n />\n {content}\n </button>\n )}\n </>\n );\n}\n","import { useEffect, useState } from \"react\";\n\nexport default function useEnvironment() {\n const [isServerSideRendering, setIsServerSideRendering] = useState(true);\n useEffect(() => {\n setIsServerSideRendering(false);\n }, []);\n\n return { isServerSideRendering };\n}\n","import { type Styles, createUseStyles } from \"react-jss\";\n\nconst DARK_BG = \"#1e1e1e\";\n\nconst themeIsLight = (theme: string) => theme === \"light\";\n\nexport const formatProps = (theme: string): CustomStylingProps => ({\n buttonBgColor: themeIsLight(theme) ? \"white\" : DARK_BG,\n paragraphColor: themeIsLight(theme) ? \"black\" : \"white\",\n});\n\nexport type Classes<Name extends string | number | symbol = string> = Record<Name, string>;\ninterface CustomStylingProps {\n buttonBgColor?: string;\n paragraphColor?: string;\n}\n\nconst styles: Styles<\"crossmintButton\" | \"crossmintImg\" | \"crossmintParagraph\" | \"@global\", CustomStylingProps> = {\n \"@global\": {\n \"@import\":\n \"url('https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap')\",\n },\n crossmintButton: {\n display: \"flex\",\n \"flex-direction\": \"row\",\n \"align-items\": \"center\",\n padding: \"0.875rem 0.875rem\",\n \"font-weight\": \"900\",\n transition: \"opacity ease-in-out 0.25s\",\n \"border-radius\": \"0.5rem\",\n \"font-family\": `\"Inter\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen, Ubuntu, Cantarell, \"Open Sans\", \"Helvetica Neue\", sans-serif`,\n outline: \"none\",\n border: \"none\",\n \"box-shadow\": \"0px 8px 15px rgba(0, 0, 0, 0.1)\",\n \"justify-content\": \"center\",\n background: ({ buttonBgColor }: CustomStylingProps) => buttonBgColor,\n\n \"&:hover:enabled\": {\n opacity: \"0.6\",\n cursor: \"pointer\",\n },\n },\n crossmintImg: {\n width: \"21px\",\n height: \"21px\",\n \"margin-right\": \"0.875rem\",\n },\n crossmintParagraph: {\n color: ({ paragraphColor }: CustomStylingProps) => paragraphColor,\n margin: \"0\",\n },\n};\n\nexport const useStyles: (\n data?: CustomStylingProps & {\n theme?: any;\n }\n) => Classes<\"crossmintButton\" | \"crossmintImg\" | \"crossmintParagraph\" | \"@global\"> = createUseStyles(styles);\n","import { type ReactNode, createContext, useCallback, useContext, useMemo, useRef, useState } from \"react\";\n\nimport { type Crossmint, createCrossmint } from \"@crossmint/common-sdk-base\";\n\nexport interface CrossmintContext {\n crossmint: Crossmint;\n setJwt: (jwt: string | undefined) => void;\n}\n\nconst CrossmintContext = createContext<CrossmintContext | null>(null);\n\nexport function CrossmintProvider({\n children,\n apiKey,\n overrideBaseUrl,\n}: Omit<Crossmint, \"jwt\"> & {\n children: ReactNode;\n}) {\n const [version, setVersion] = useState(0);\n\n const crossmintRef = useRef<Crossmint>(\n new Proxy<Crossmint>(createCrossmint({ apiKey, overrideBaseUrl }), {\n set(target, prop, value) {\n if (prop === \"jwt\" && target.jwt !== value) {\n setVersion((v) => v + 1);\n }\n return Reflect.set(target, prop, value);\n },\n })\n );\n\n const setJwt = useCallback((jwt: string | undefined) => {\n if (jwt !== crossmintRef.current.jwt) {\n crossmintRef.current.jwt = jwt;\n }\n }, []);\n\n const value = useMemo(\n () => ({\n get crossmint() {\n return crossmintRef.current;\n },\n setJwt,\n }),\n [setJwt, version]\n );\n\n return <CrossmintContext.Provider value={value}>{children}</CrossmintContext.Provider>;\n}\n\nexport function useCrossmint(missingContextMessage?: string) {\n const context = useContext(CrossmintContext);\n if (context == null) {\n throw new Error(missingContextMessage ?? \"useCrossmint must be used within a CrossmintProvider\");\n }\n return context;\n}\n","import { useContext } from \"react\";\n\nimport { WalletContext } from \"../providers/CrossmintWalletProvider\";\n\nexport function useWallet() {\n const walletContext = useContext(WalletContext);\n\n if (!walletContext) {\n throw new Error(\"useWallet must be used within CrossmintAuthProvider or CrossmintWalletProvider\");\n }\n\n return walletContext;\n}\n","import { type ReactNode, createContext, useMemo, useState } from \"react\";\n\nimport {\n type EVMSmartWallet,\n type EVMSmartWalletChain,\n SmartWalletError,\n SmartWalletSDK,\n type WalletParams,\n} from \"@crossmint/client-sdk-smart-wallet\";\n\nimport { useCrossmint } from \"../hooks\";\n\ntype WalletStatus = \"not-loaded\" | \"in-progress\" | \"loaded\" | \"loading-error\";\ntype ValidWalletState =\n | { status: \"not-loaded\" | \"in-progress\" }\n | { status: \"loaded\"; wallet: EVMSmartWallet }\n | { status: \"loading-error\"; error: SmartWalletError };\n\ntype WalletContext = {\n status: WalletStatus;\n wallet?: EVMSmartWallet;\n error?: SmartWalletError;\n getOrCreateWallet: (config?: WalletConfig) => { startedCreation: boolean; reason?: string };\n clearWallet: () => void;\n};\n\nexport const WalletContext = createContext<WalletContext>({\n status: \"not-loaded\",\n getOrCreateWallet: () => ({ startedCreation: false }),\n clearWallet: () => {},\n});\n\nexport type WalletConfig = WalletParams & { type: \"evm-smart-wallet\" };\n\nexport function CrossmintWalletProvider({\n children,\n defaultChain,\n}: {\n children: ReactNode;\n defaultChain: EVMSmartWalletChain;\n}) {\n const { crossmint } = useCrossmint(\"CrossmintWalletProvider must be used within CrossmintProvider\");\n const smartWalletSDK = useMemo(() => SmartWalletSDK.init({ clientApiKey: crossmint.apiKey }), [crossmint.apiKey]);\n\n const [state, setState] = useState<ValidWalletState>({ status: \"not-loaded\" });\n\n const getOrCreateWallet = (config: WalletConfig = { type: \"evm-smart-wallet\", signer: { type: \"PASSKEY\" } }) => {\n if (state.status == \"in-progress\") {\n console.log(\"Wallet already loading\");\n return { startedCreation: false, reason: \"Wallet is already loading.\" };\n }\n\n if (crossmint.jwt == null) {\n return { startedCreation: false, reason: `Jwt not set in \"CrossmintProvider\".` };\n }\n\n const internalCall = async () => {\n try {\n setState({ status: \"in-progress\" });\n const wallet = await smartWalletSDK.getOrCreateWallet(\n { jwt: crossmint.jwt as string },\n defaultChain,\n config\n );\n setState({ status: \"loaded\", wallet });\n } catch (error: unknown) {\n console.error(\"There was an error creating a wallet \", error);\n setState(deriveErrorState(error));\n }\n };\n\n internalCall();\n return { startedCreation: true };\n };\n\n const clearWallet = () => {\n setState({ status: \"not-loaded\" });\n };\n\n return (\n <WalletContext.Provider value={{ ...state, getOrCreateWallet, clearWallet }}>{children}</WalletContext.Provider>\n );\n}\n\nfunction deriveErrorState(error: unknown): { status: \"loading-error\"; error: SmartWalletError } {\n if (error instanceof SmartWalletError) {\n return { status: \"loading-error\", error };\n }\n\n const message = error instanceof Error ? error.message : String(error);\n const stack = error instanceof Error ? error.stack : undefined;\n return { status: \"loading-error\", error: new SmartWalletError(`Unknown Wallet Error: ${message}`, stack) };\n}\n","import { useContext } from \"react\";\n\nimport { AuthContext } from \"../providers\";\n\nexport function useAuth() {\n const context = useContext(AuthContext);\n if (context === undefined) {\n throw new Error(\"useAuth must be used within an AuthProvider\");\n }\n return context;\n}\n","import { type ReactNode, createContext, useEffect, useState } from \"react\";\nimport { createPortal } from \"react-dom\";\n\nimport type { EVMSmartWalletChain } from \"@crossmint/client-sdk-smart-wallet\";\nimport { type UIConfig, validateApiKeyAndGetCrossmintBaseUrl } from \"@crossmint/common-sdk-base\";\n\nimport AuthModal from \"../components/auth/AuthModal\";\nimport { useCrossmint, useWallet } from \"../hooks\";\nimport { CrossmintWalletProvider } from \"./CrossmintWalletProvider\";\n\nconst SESSION_PREFIX = \"crossmint-session\";\n\nexport type CrossmintAuthWalletConfig = {\n defaultChain: EVMSmartWalletChain;\n createOnLogin: \"all-users\" | \"off\";\n type: \"evm-smart-wallet\";\n};\n\nexport type CrossmintAuthProviderProps = {\n embeddedWallets: CrossmintAuthWalletConfig;\n appearance?: UIConfig;\n children: ReactNode;\n};\n\ntype AuthStatus = \"logged-in\" | \"logged-out\" | \"in-progress\";\n\ntype AuthContextType = {\n login: () => void;\n logout: () => void;\n jwt?: string;\n status: AuthStatus;\n};\n\nexport const AuthContext = createContext<AuthContextType>({\n login: () => {},\n logout: () => {},\n status: \"logged-out\",\n});\n\nexport function CrossmintAuthProvider({ embeddedWallets, children, appearance }: CrossmintAuthProviderProps) {\n const { crossmint, setJwt } = useCrossmint(\"CrossmintAuthProvider must be used within CrossmintProvider\");\n const crossmintBaseUrl = validateApiKeyAndGetCrossmintBaseUrl(crossmint.apiKey);\n const [modalOpen, setModalOpen] = useState(false);\n\n useEffect(() => {\n const session = sessionFromClient();\n if (session != null) {\n setJwt(session);\n }\n }, []);\n\n const login = () => {\n if (crossmint.jwt != null) {\n console.log(\"User already logged in\");\n return;\n }\n\n setModalOpen(true);\n };\n\n const logout = () => {\n document.cookie = `${SESSION_PREFIX}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;\n setJwt(undefined);\n };\n\n useEffect(() => {\n if (crossmint.jwt == null) {\n return;\n }\n\n setModalOpen(false);\n }, [crossmint.jwt]);\n\n useEffect(() => {\n if (crossmint.jwt) {\n document.cookie = `${SESSION_PREFIX}=${crossmint.jwt}; path=/;SameSite=Lax;`;\n }\n }, [crossmint.jwt]);\n\n const getAuthStatus = (): AuthStatus => {\n if (crossmint.jwt != null) {\n return \"logged-in\";\n }\n if (modalOpen) {\n return \"in-progress\";\n }\n return \"logged-out\";\n };\n\n return (\n <AuthContext.Provider\n value={{\n login,\n logout,\n jwt: crossmint.jwt,\n status: getAuthStatus(),\n }}\n >\n <CrossmintWalletProvider defaultChain={embeddedWallets.defaultChain}>\n <WalletManager embeddedWallets={embeddedWallets} accessToken={crossmint.jwt}>\n {children}\n </WalletManager>\n {modalOpen\n ? createPortal(\n <AuthModal\n baseUrl={crossmintBaseUrl}\n setModalOpen={setModalOpen}\n setJwtToken={setJwt}\n apiKey={crossmint.apiKey}\n appearance={appearance}\n />,\n\n document.body\n )\n : null}\n </CrossmintWalletProvider>\n </AuthContext.Provider>\n );\n}\n\nfunction WalletManager({\n embeddedWallets,\n children,\n accessToken,\n}: {\n embeddedWallets: CrossmintAuthWalletConfig;\n children: ReactNode;\n accessToken: string | undefined;\n}) {\n const { getOrCreateWallet, clearWallet, status } = useWallet();\n\n useEffect(() => {\n if (embeddedWallets.createOnLogin === \"all-users\" && status === \"not-loaded\" && accessToken != null) {\n getOrCreateWallet({\n type: embeddedWallets.type,\n signer: { type: \"PASSKEY\" },\n });\n }\n\n if (status === \"loaded\" && accessToken == null) {\n clearWallet();\n }\n }, [accessToken, status]);\n\n return <>{children}</>;\n}\n\nfunction sessionFromClient(): string | undefined {\n const crossmintSession = document.cookie.split(\"; \").find((row) => row.startsWith(SESSION_PREFIX));\n return crossmintSession ? crossmintSession.split(\"=\")[1] : undefined;\n}\n","import { Dialog, Transition } from \"@headlessui/react\";\nimport { type CSSProperties, Fragment, useEffect, useRef, useState } from \"react\";\nimport { z } from \"zod\";\n\nimport { IFrameWindow } from \"@crossmint/client-sdk-window\";\nimport type { UIConfig } from \"@crossmint/common-sdk-base\";\n\nimport X from \"../../icons/x\";\nimport { classNames } from \"../../utils/classNames\";\n\nconst incomingModalIframeEvents = {\n jwtToken: z.object({\n jwtToken: z.string(),\n }),\n};\n\nconst outgoingModalIframeEvents = {\n closeWindow: z.object({\n closeWindow: z.string(),\n }),\n};\n\ntype IncomingModalIframeEventsType = {\n jwtToken: typeof incomingModalIframeEvents.jwtToken;\n};\n\ntype OutgoingModalIframeEventsType = {\n closeWindow: typeof outgoingModalIframeEvents.closeWindow;\n};\n\ntype AuthModalProps = {\n setModalOpen: (open: boolean) => void;\n setJwtToken: (jwtToken: string) => void;\n apiKey: string;\n baseUrl: string;\n appearance?: UIConfig;\n};\n\nexport default function AuthModal({ setModalOpen, setJwtToken, apiKey, baseUrl, appearance }: AuthModalProps) {\n let iframeSrc = `${baseUrl}sdk/auth/frame?apiKey=${apiKey}`;\n if (appearance != null) {\n // The appearance object is serialized into a query parameter\n iframeSrc += `&uiConfig=${encodeURIComponent(JSON.stringify(appearance))}`;\n }\n\n const iframeRef = useRef<HTMLIFrameElement | null>(null);\n const [iframe, setIframe] = useState<IFrameWindow<\n IncomingModalIframeEventsType,\n OutgoingModalIframeEventsType\n > | null>(null);\n\n useEffect(() => {\n if (iframe == null) {\n return;\n }\n\n iframe.on(\"jwtToken\", (data) => {\n setJwtToken(data.jwtToken);\n iframe.off(\"jwtToken\");\n\n iframe.send(\"closeWindow\", {\n closeWindow: \"closeWindow\",\n });\n\n if (iframe?.iframe.contentWindow != null) {\n iframe.iframe.contentWindow.close();\n }\n setModalOpen(false);\n });\n\n return () => {\n if (iframe) {\n iframe.off(\"jwtToken\");\n\n if (iframe.iframe.contentWindow != null) {\n iframe.iframe.contentWindow.close();\n }\n }\n };\n }, [iframe, setJwtToken, setModalOpen]);\n\n const handleIframeLoaded = async () => {\n if (iframeRef.current == null) {\n // The iframe should be load, here we should log on DD if possible\n console.error(\"Something wrong happened, please try again\");\n return;\n }\n\n const initIframe = await IFrameWindow.init(iframeRef.current, {\n incomingEvents: incomingModalIframeEvents,\n outgoingEvents: outgoingModalIframeEvents,\n });\n setIframe(initIframe);\n };\n\n return (\n <Transition.Root show as={Fragment}>\n <Dialog as=\"div\" style={styles.dialog} onClose={() => setModalOpen(false)}>\n <Transition.Child\n as={Fragment}\n enter=\"ease-out duration-400\"\n enterFrom=\"opacity-0\"\n enterTo=\"opacity-100\"\n leave=\"ease-in duration-400\"\n leaveFrom=\"opacity-100\"\n leaveTo=\"opacity-0\"\n >\n <div style={styles.transitionBegin} />\n </Transition.Child>\n <Transition.Child\n as={Fragment}\n enter=\"ease-out duration-400\"\n enterFrom=\"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95\"\n enterTo=\"opacity-100 translate-y-0 sm:scale-100\"\n leave=\"ease-in duration-400\"\n leaveFrom=\"opacity-100 translate-y-0 sm:scale-100\"\n leaveTo=\"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95\"\n >\n <div style={styles.transitionEnd} onClick={(e) => e.stopPropagation()}>\n <div style={{ position: \"relative\", width: \"100%\" }}>\n <button\n type=\"button\"\n aria-label=\"Close\"\n style={{\n width: \"1.5rem\",\n position: \"absolute\",\n right: \"1.5rem\",\n top: \"1.5rem\",\n cursor: \"pointer\",\n color: appearance?.colors?.border ?? \"#909ca3\",\n outlineOffset: \"4px\",\n borderRadius: \"100%\",\n }}\n onClick={() => setModalOpen(false)}\n >\n <X />\n </button>\n </div>\n <iframe\n ref={iframeRef}\n src={iframeSrc}\n onLoad={handleIframeLoaded}\n title=\"Authentication Modal\"\n className={classNames(\n \"w-full h-[500px] border pt-12 pb-8\",\n appearance?.colors?.border\n ? `border-[${appearance.colors.border}]`\n : \"border-[#D0D5DD]\",\n appearance?.borderRadius ? `rounded-[${appearance.borderRadius}]` : \"rounded-2xl\",\n appearance?.colors?.background ? `bg-[${appearance.colors.background}]` : \"bg-white\"\n )}\n />\n </div>\n </Transition.Child>\n </Dialog>\n </Transition.Root>\n );\n}\n\nconst styles: { [key: string]: CSSProperties } = {\n dialog: {\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n overflowY: \"auto\",\n position: \"fixed\",\n top: 0,\n right: 0,\n bottom: 0,\n left: 0,\n zIndex: 20,\n },\n transitionBegin: {\n background: \"rgba(139, 151, 151, 0.2)\",\n backdropFilter: \"blur(2px)\",\n position: \"fixed\",\n top: 0,\n right: 0,\n bottom: 0,\n left: 0,\n transitionProperty: \"opacity\",\n transitionTimingFunction: \"cubic-bezier(0.4, 0, 0.2, 1)\",\n transitionDuration: \"300ms\",\n zIndex: -10,\n },\n transitionEnd: {\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n width: \"100%\",\n maxWidth: \"448px\",\n borderRadius: \"0.75rem\",\n boxShadow: \"0 1px 2px 0 rgba(0, 0, 0, 0.05)\",\n zIndex: 30,\n },\n};\n","export default function X({ className }: { className?: string }) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className={className}\n >\n <path d=\"M18 6 6 18\" />\n <path d=\"m6 6 12 12\" />\n </svg>\n );\n}\n","import { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\n/**\n * Combines multiple class names into a single string.\n *\n * @param inputs - The class names to combine.\n * @returns The combined class names as a string.\n */\nexport function classNames(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n"],"mappings":"kyBAAA,OAAS,WAAAA,OAAe,cCAxB,OAAS,gBAAAC,OAAoB,cAC7B,OAAOC,OAAoB,yBAE3B,IAAOC,EAAQF,GAAa,CACxB,QAAS,CAACC,GAA4B,CAAC,CAE3C,CAAC,ECND,OAAS,qCAAAE,GAAmC,2BAAAC,OAA+B,6BCEvE,IAAAC,EAAW,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AAwC,CAC7C,IAAMa,EAAmB,SAAS,OAAO,MAAM,IAAI,EAAE,KAAMC,GAAQA,EAAI,WAAW/B,CAAc,CAAC,EACjG,OAAO8B,EAAmBA,EAAiB,MAAM,GAAG,EAAE,CAAC,EAAI,MAC/D,CDlJO,SAASE,IAAU,CACtB,IAAMC,EAAUC,GAAWC,CAAW,EACtC,GAAIF,IAAY,OACZ,MAAM,IAAI,MAAM,6CAA6C,EAEjE,OAAOA,CACX,CnBEA,OAAS,mBAAAG,GAAiB,sBAAAC,OAA0B,6BACpD,OAII,SAAAC,GACA,oBAAAC,GACA,iCAAAC,GACA,yBAAAC,GACA,sBAAAC,GACA,wBAAAC,GACA,sBAAAC,GACA,4BAAAC,GACA,yCAAAC,GACA,eAAAC,GACA,+BAAAC,GACA,2BAAAC,GACA,4CAAAC,OACG,qCAxBPC,GAAQC,CAAW","names":["install","defineConfig","presetTailwind","twind_config_default","assertValidNFTCollectionViewProps","getNFTCollectionViewSrc","version","LIB_VERSION","version","jsx","CrossmintNFTCollectionView","props","assertValidNFTCollectionViewProps","src","getNFTCollectionViewSrc","LIB_VERSION","assertValidValidateNFTDetailProps","getNFTDetailSrc","jsx","CrossmintNFTDetail","props","assertValidValidateNFTDetailProps","src","getNFTDetailSrc","LIB_VERSION","isCryptoEmbeddedCheckoutProps","isFiatEmbeddedCheckoutProps","isCryptoEmbeddedCheckoutPropsWithSigner","bs58","IncomingInternalEvents","OutgoingInternalEvents","crossmintIFrameService","embeddedCheckoutPropsToUpdatableParamsPayload","isEqual","useEffect","useRef","useDeepEffect","callback","dependencies","dependenciesRef","dep","i","useEffect","useState","IncomingInternalEvents","crossmintIFrameService","jsx","CrossmintEmbeddedCheckoutIFrame","_a","_b","onInternalEvent","props","__objRest","getUrl","listenToEvents","listenToInternalEvents","crossmintIFrameService","height","setHeight","useState","url","useEffect","clearListener","event","type","payload","IncomingInternalEvents","jsx","CryptoEmbeddedCheckoutIFrame","props","emitInternalEvent","crossmintIFrameService","signer","paymentMethod","onInternalEvent","event","type","payload","IncomingInternalEvents","serializedTransaction","handleIncomingTransaction","chain","handleChainSwitch","__async","txId","handleSOLTransaction","handleETHTransaction","OutgoingInternalEvents","e","Transaction","transaction","bs58","parseTransaction","useDeepEffect","embeddedCheckoutPropsToUpdatableParamsPayload","CrossmintEmbeddedCheckoutIFrame","__spreadValues","jsx","CrossmintCryptoEmbeddedCheckout","props","isCryptoEmbeddedCheckoutPropsWithSigner","CryptoEmbeddedCheckoutIFrame","__spreadValues","crossmintIFrameService","embeddedCheckoutPropsToUpdatableParamsPayload","jsx","FiatEmbeddedCheckoutIFrame","props","emitInternalEvent","crossmintIFrameService","useDeepEffect","embeddedCheckoutPropsToUpdatableParamsPayload","CrossmintEmbeddedCheckoutIFrame","__spreadValues","jsx","CrossmintFiatEmbeddedCheckout","props","FiatEmbeddedCheckoutIFrame","__spreadValues","jsx","CrossmintPaymentElement","props","isFiatEmbeddedCheckoutProps","CrossmintFiatEmbeddedCheckout","__spreadValues","isCryptoEmbeddedCheckoutProps","CrossmintCryptoEmbeddedCheckout","useMemo","useState","clientNames","crossmintModalService","crossmintPayButtonService","useEffect","useState","useEnvironment","isServerSideRendering","setIsServerSideRendering","createUseStyles","DARK_BG","themeIsLight","theme","formatProps","styles","buttonBgColor","paragraphColor","useStyles","Fragment","jsx","jsxs","CrossmintPayButton","buttonProps","_a","className","disabled","onClick","style","tabIndex","theme","mintTo","emailTo","listingId","auctionId","showOverlay","mintConfig","whPassThroughArgs","environment","paymentMethod","preferredSigninMethod","dismissOverlayOnClick","prepay","locale","currency","successCallbackURL","failureCallbackURL","loginEmail","projectId","getButtonText","checkoutProps","props","__objRest","collectionId","connecting","setConnecting","useState","isServerSideRendering","useEnvironment","connect","crossmintModalService","LIB_VERSION","clientNames","getButtonTextInternal","handleClick","crossmintPayButtonService","_handleClick","event","classes","useStyles","formatProps","content","useMemo","__spreadValues","createContext","useCallback","useContext","useMemo","useRef","useState","createCrossmint","jsx","CrossmintContext","CrossmintProvider","children","apiKey","overrideBaseUrl","version","setVersion","crossmintRef","target","prop","value","v","setJwt","jwt","useCrossmint","missingContextMessage","context","useContext","createContext","useMemo","useState","SmartWalletError","SmartWalletSDK","jsx","WalletContext","createContext","CrossmintWalletProvider","children","defaultChain","crossmint","useCrossmint","smartWalletSDK","useMemo","SmartWalletSDK","state","setState","useState","getOrCreateWallet","config","__async","wallet","error","deriveErrorState","clearWallet","__spreadProps","__spreadValues","SmartWalletError","message","stack","useWallet","walletContext","useContext","WalletContext","useContext","createContext","useEffect","useState","createPortal","validateApiKeyAndGetCrossmintBaseUrl","Dialog","Transition","Fragment","useEffect","useRef","useState","z","IFrameWindow","jsx","jsxs","X","className","clsx","twMerge","classNames","inputs","jsx","jsxs","incomingModalIframeEvents","z","outgoingModalIframeEvents","AuthModal","setModalOpen","setJwtToken","apiKey","baseUrl","appearance","_a","_b","_c","_d","iframeSrc","iframeRef","useRef","iframe","setIframe","useState","useEffect","data","handleIframeLoaded","__async","initIframe","IFrameWindow","Transition","Fragment","Dialog","styles","e","X","classNames","Fragment","jsx","jsxs","SESSION_PREFIX","AuthContext","createContext","CrossmintAuthProvider","embeddedWallets","children","appearance","crossmint","setJwt","useCrossmint","crossmintBaseUrl","validateApiKeyAndGetCrossmintBaseUrl","modalOpen","setModalOpen","useState","useEffect","session","sessionFromClient","login","logout","getAuthStatus","CrossmintWalletProvider","WalletManager","createPortal","AuthModal","accessToken","getOrCreateWallet","clearWallet","status","useWallet","crossmintSession","row","useAuth","context","useContext","AuthContext","CrossmintEvents","useCrossmintEvents","Chain","SmartWalletError","UserWalletAlreadyCreatedError","AdminAlreadyUsedError","AdminMismatchError","PasskeyMismatchError","PasskeyPromptError","PasskeyRegistrationError","PasskeyIncompatibleAuthenticatorError","ConfigError","SmartWalletsNotEnabledError","EVMSendTransactionError","EVMSendTransactionExecutionRevertedError","install","twind_config_default"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/twind.config.ts","../src/components/CrossmintNFTCollectionView.tsx","../package.json","../src/consts/version.ts","../src/components/CrossmintNFTDetail.tsx","../src/components/embed/index.tsx","../src/components/embed/crypto/CryptoEmbeddedCheckout.tsx","../src/components/embed/crypto/CryptoEmbeddedCheckoutIFrame.tsx","../src/hooks/useDeepEffect.ts","../src/components/embed/EmbeddedCheckoutIFrame.tsx","../src/components/embed/fiat/FiatEmbeddedCheckoutIFrame.tsx","../src/components/embed/fiat/FiatEmbeddedCheckout.tsx","../src/components/hosted/CrossmintPayButton.tsx","../src/hooks/useEnvironment.ts","../src/components/hosted/styles.ts","../src/hooks/useCrossmint.tsx","../src/hooks/useWallet.ts","../src/providers/CrossmintWalletProvider.tsx","../src/hooks/useAuth.ts","../src/utils/authCookies.ts","../src/providers/CrossmintAuthProvider.tsx","../src/components/auth/AuthModal.tsx","../src/icons/x.tsx","../src/utils/classNames.ts","../src/hooks/useRefreshToken.ts"],"sourcesContent":["import { install } from \"@twind/core\";\n\nimport twindConfig from \"./twind.config\";\n\n// Initialize twind with custom configuration\n// This sets up the CSS-in-JS styling solution for the entire application\ninstall(twindConfig);\n\nexport * from \"./components\";\nexport * from \"./hooks\";\nexport * from \"./providers\";\n\nexport { CrossmintEvents, useCrossmintEvents } from \"@crossmint/client-sdk-base\";\nexport {\n type EVMSmartWallet,\n type PasskeySigner,\n Chain,\n SmartWalletError,\n UserWalletAlreadyCreatedError,\n AdminAlreadyUsedError,\n AdminMismatchError,\n PasskeyMismatchError,\n PasskeyPromptError,\n PasskeyRegistrationError,\n PasskeyIncompatibleAuthenticatorError,\n ConfigError,\n SmartWalletsNotEnabledError,\n EVMSendTransactionError,\n EVMSendTransactionExecutionRevertedError,\n} from \"@crossmint/client-sdk-smart-wallet\";\nexport type { CrossmintEvent, CrossmintEventMap } from \"@crossmint/client-sdk-base\";\n","import { defineConfig } from \"@twind/core\";\nimport presetTailwind from \"@twind/preset-tailwind\";\n\nexport default defineConfig({\n presets: [presetTailwind(/* options */)],\n /* config */\n});\n","import { assertValidNFTCollectionViewProps, getNFTCollectionViewSrc } from \"@crossmint/client-sdk-base\";\nimport type { NFTCollectionViewProps } from \"@crossmint/common-sdk-base\";\n\nimport { LIB_VERSION } from \"../consts/version\";\n\nexport function CrossmintNFTCollectionView(props: NFTCollectionViewProps) {\n assertValidNFTCollectionViewProps(props);\n\n const src = getNFTCollectionViewSrc(props, LIB_VERSION);\n\n return (\n <iframe\n src={src}\n width=\"100%\"\n height=\"100%\"\n style={{\n flexGrow: \"1\",\n border: \"none\",\n margin: \"0\",\n padding: \"0\",\n }}\n role=\"nft-collection-view\"\n />\n );\n}\n","{\n \"name\": \"@crossmint/client-sdk-react-ui\",\n \"version\": \"1.4.1\",\n \"repository\": \"https://github.com/Crossmint/crossmint-sdk\",\n \"license\": \"Apache-2.0\",\n \"author\": \"Paella Labs Inc\",\n \"sideEffects\": false,\n \"type\": \"module\",\n \"exports\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"files\": [\n \"dist\",\n \"src\",\n \"LICENSE\"\n ],\n \"scripts\": {\n \"build\": \"tsup src/index.ts --clean --external react,react-dom --format esm,cjs --outDir ./dist --minify --dts --sourcemap\",\n \"dev\": \"tsup src/index.ts --clean --external react,react-dom --format esm,cjs --outDir ./dist --dts --sourcemap --watch\",\n \"test\": \"vitest run\"\n },\n \"dependencies\": {\n \"@crossmint/client-sdk-auth-core\": \"workspace:*\",\n \"@crossmint/client-sdk-base\": \"workspace:*\",\n \"@crossmint/client-sdk-smart-wallet\": \"workspace:*\",\n \"@crossmint/client-sdk-window\": \"workspace:*\",\n \"@crossmint/common-sdk-base\": \"workspace:*\",\n \"@ethersproject/transactions\": \"5.7.0\",\n \"@headlessui/react\": \"2.1.5\",\n \"@solana/web3.js\": \"1.95.1\",\n \"@twind/core\": \"1.1.3\",\n \"@twind/preset-tailwind\": \"1.1.4\",\n \"bs58\": \"5.0.0\",\n \"clsx\": \"2.1.1\",\n \"lodash.isequal\": \"4.5.0\",\n \"react-jss\": \"10.10.0\",\n \"tailwind-merge\": \"2.4.0\",\n \"tailwindcss\": \"3.4.10\",\n \"zod\": \"3.22.4\"\n },\n \"devDependencies\": {\n \"@types/lodash.isequal\": \"4.5.6\",\n \"@types/react\": \"^18.3.0\",\n \"@types/react-dom\": \"^18.3.0\",\n \"react\": \"^18.3.0\",\n \"react-dom\": \"^18.3.0\"\n },\n \"peerDependencies\": {\n \"react\": \">=17.0.2\",\n \"react-dom\": \">=17.0.2\"\n }\n}\n","import { version } from \"../../package.json\";\n\nexport const LIB_VERSION = version;\n","import { assertValidValidateNFTDetailProps, getNFTDetailSrc } from \"@crossmint/client-sdk-base\";\nimport type { NFTDetailProps } from \"@crossmint/common-sdk-base\";\n\nimport { LIB_VERSION } from \"../consts/version\";\n\nexport function CrossmintNFTDetail(props: NFTDetailProps) {\n assertValidValidateNFTDetailProps(props);\n\n const src = getNFTDetailSrc(props, LIB_VERSION);\n\n return (\n <iframe\n src={src}\n width=\"100%\"\n height=\"100%\"\n style={{\n flexGrow: \"1\",\n border: \"none\",\n margin: \"0\",\n padding: \"0\",\n }}\n role=\"nft-details\"\n />\n );\n}\n","import {\n type CrossmintEmbeddedCheckoutProps,\n isCryptoEmbeddedCheckoutProps,\n isFiatEmbeddedCheckoutProps,\n} from \"@crossmint/client-sdk-base\";\n\nimport { CrossmintCryptoEmbeddedCheckout } from \"./crypto/CryptoEmbeddedCheckout\";\nimport { CrossmintFiatEmbeddedCheckout } from \"./fiat/FiatEmbeddedCheckout\";\n\n// TODO: Rename to CrossmintEmbeddedCheckout on v2 major publish, prior announcement since its a breaking change\nexport function CrossmintPaymentElement(props: CrossmintEmbeddedCheckoutProps) {\n if (isFiatEmbeddedCheckoutProps(props)) {\n return <CrossmintFiatEmbeddedCheckout {...props} />;\n }\n if (isCryptoEmbeddedCheckoutProps(props)) {\n return <CrossmintCryptoEmbeddedCheckout {...props} />;\n }\n throw new Error(\"Unsupported: Fiat is the only supported payment method.\");\n}\n","import { type CryptoEmbeddedCheckoutProps, isCryptoEmbeddedCheckoutPropsWithSigner } from \"@crossmint/client-sdk-base\";\n\nimport CryptoEmbeddedCheckoutIFrame from \"./CryptoEmbeddedCheckoutIFrame\";\n\nexport function CrossmintCryptoEmbeddedCheckout(props: CryptoEmbeddedCheckoutProps) {\n if (!isCryptoEmbeddedCheckoutPropsWithSigner(props)) {\n throw new Error(\"Invalid parameters: signer is required in versions < 2.0.0\");\n }\n\n return <CryptoEmbeddedCheckoutIFrame {...props} />;\n}\n","import bs58 from \"bs58\";\n\nimport {\n type CryptoEmbeddedCheckoutPropsWithSigner,\n type ETHEmbeddedCheckoutSigner,\n type IncomingInternalEvent,\n IncomingInternalEvents,\n OutgoingInternalEvents,\n type SOLEmbeddedCheckoutSigner,\n crossmintIFrameService,\n embeddedCheckoutPropsToUpdatableParamsPayload,\n} from \"@crossmint/client-sdk-base\";\nimport type { EVMBlockchainIncludingTestnet } from \"@crossmint/common-sdk-base\";\n\nimport useDeepEffect from \"../../../hooks/useDeepEffect\";\nimport CrossmintEmbeddedCheckoutIFrame from \"../EmbeddedCheckoutIFrame\";\n\nexport default function CryptoEmbeddedCheckoutIFrame(props: CryptoEmbeddedCheckoutPropsWithSigner) {\n const { emitInternalEvent } = crossmintIFrameService(props);\n\n const { signer, paymentMethod } = props;\n\n function onInternalEvent(event: IncomingInternalEvent) {\n const { type, payload } = event;\n\n if (type === IncomingInternalEvents.CRYPTO_PAYMENT_INCOMING_TRANSACTION) {\n const { serializedTransaction } = payload;\n console.log(\"[Crossmint] Received incoming transaction\", serializedTransaction);\n handleIncomingTransaction(serializedTransaction);\n }\n\n if (type === IncomingInternalEvents.CRYPTO_CHAIN_SWITCH) {\n const { chain } = payload;\n console.log(\"[Crossmint] Received change of chain\", chain);\n\n const handleChainSwitch = (signer as ETHEmbeddedCheckoutSigner).handleChainSwitch;\n if (handleChainSwitch == null) {\n throw new Error(\"switchNetwork function should have been defined\");\n }\n handleChainSwitch(chain as EVMBlockchainIncludingTestnet);\n }\n }\n\n async function handleIncomingTransaction(serializedTransaction: string) {\n try {\n let txId: string;\n switch (paymentMethod) {\n case \"SOL\":\n txId = await handleSOLTransaction(signer, serializedTransaction);\n break;\n case \"ETH\":\n txId = await handleETHTransaction(signer, serializedTransaction);\n break;\n default:\n throw new Error(`Unsupported payment method ${paymentMethod}`);\n }\n\n console.log(\"[Crossmint] Signed and sent transaction\", txId);\n emitInternalEvent({\n type: OutgoingInternalEvents.CRYPTO_PAYMENT_USER_ACCEPTED,\n payload: {\n txId,\n },\n });\n } catch (e) {\n console.error(\"[Crossmint] Failed to sign and send transaction\", e);\n emitInternalEvent({\n type: OutgoingInternalEvents.CRYPTO_PAYMENT_USER_REJECTED,\n payload: {},\n });\n }\n }\n\n async function handleSOLTransaction(signer: SOLEmbeddedCheckoutSigner, serializedTransaction: string) {\n // @ts-ignore - Error becasue we dont use 'module' field in tsconfig, which is expected because we use tsup to compile\n const { Transaction } = await import(\"@solana/web3.js\");\n const transaction = Transaction.from(bs58.decode(serializedTransaction));\n console.log(\"[Crossmint] Deserialized SOL transaction\", transaction);\n\n return await signer.signAndSendTransaction(transaction);\n }\n\n async function handleETHTransaction(signer: ETHEmbeddedCheckoutSigner, serializedTransaction: string) {\n // @ts-ignore - Error becasue we dont use 'module' field in tsconfig, which is expected because we use tsup to compile\n const { parse: parseTransaction } = await import(\"@ethersproject/transactions\");\n const transaction = parseTransaction(serializedTransaction);\n console.log(\"[Crossmint] Deserialized ETH transaction\", transaction);\n\n return await signer.signAndSendTransaction(transaction);\n }\n\n useDeepEffect(() => {\n emitInternalEvent({\n type: \"params-update\",\n payload: embeddedCheckoutPropsToUpdatableParamsPayload(props),\n });\n }, [\n props.signer.address,\n props.recipient,\n props.mintConfig,\n props.locale,\n props.currency,\n props.whPassThroughArgs,\n ...(\"chain\" in props.signer ? [props.signer.chain] : []),\n ]);\n\n return <CrossmintEmbeddedCheckoutIFrame onInternalEvent={onInternalEvent} {...props} />;\n}\n","import isEqual from \"lodash.isequal\";\nimport { type DependencyList, type EffectCallback, useEffect, useRef } from \"react\";\n\nexport default function useDeepEffect(callback: EffectCallback, dependencies: DependencyList): void {\n const dependenciesRef = useRef(dependencies);\n\n useEffect(() => {\n const hasChanged = dependencies.some((dep, i) => !isEqual(dep, dependenciesRef.current[i]));\n\n if (hasChanged) {\n dependenciesRef.current = dependencies;\n return callback();\n }\n }, [dependencies]);\n}\n","import { useEffect, useState } from \"react\";\n\nimport {\n type CrossmintEmbeddedCheckoutProps,\n type IncomingInternalEvent,\n IncomingInternalEvents,\n crossmintIFrameService,\n} from \"@crossmint/client-sdk-base\";\n\ntype CrossmintEmbeddedCheckoutIFrameProps = CrossmintEmbeddedCheckoutProps & {\n onInternalEvent?: (event: IncomingInternalEvent) => void;\n};\n\nexport default function CrossmintEmbeddedCheckoutIFrame({\n onInternalEvent,\n ...props\n}: CrossmintEmbeddedCheckoutIFrameProps) {\n const { getUrl, listenToEvents, listenToInternalEvents } = crossmintIFrameService(props);\n\n const [height, setHeight] = useState(0);\n const [url] = useState(getUrl(props));\n\n // Public events\n useEffect(() => {\n const clearListener = listenToEvents((event) => props.onEvent?.(event.data));\n\n return () => {\n clearListener();\n };\n }, []);\n\n // Internal events\n useEffect(() => {\n const clearListener = listenToInternalEvents((event) => {\n const { type, payload } = event.data;\n\n if (type === IncomingInternalEvents.UI_HEIGHT_CHANGED) {\n setHeight(payload.height);\n }\n\n onInternalEvent?.(event.data);\n });\n\n return () => {\n clearListener();\n };\n }, []);\n\n return (\n <iframe\n src={url}\n id=\"crossmint-embedded-checkout.iframe\"\n role=\"crossmint-embedded-checkout.iframe\"\n allow=\"payment *\"\n style={{\n boxShadow: \"none\",\n border: \"none\",\n padding: \"0px\",\n width: \"100%\",\n minWidth: \"100%\",\n overflow: \"hidden\",\n display: \"block\",\n userSelect: \"none\",\n transform: \"translate(0px)\",\n opacity: \"1\",\n transition: \"ease 0s, opacity 0.4s ease 0.1s\",\n height: `${height}px`,\n }}\n />\n );\n}\n","import {\n type FiatEmbeddedCheckoutProps,\n crossmintIFrameService,\n embeddedCheckoutPropsToUpdatableParamsPayload,\n} from \"@crossmint/client-sdk-base\";\n\nimport useDeepEffect from \"../../../hooks/useDeepEffect\";\nimport CrossmintEmbeddedCheckoutIFrame from \"../EmbeddedCheckoutIFrame\";\n\nexport default function FiatEmbeddedCheckoutIFrame(props: FiatEmbeddedCheckoutProps) {\n const { emitInternalEvent } = crossmintIFrameService(props);\n\n useDeepEffect(() => {\n emitInternalEvent({\n type: \"params-update\",\n payload: embeddedCheckoutPropsToUpdatableParamsPayload(props),\n });\n }, [props.recipient, props.mintConfig, props.locale, props.currency, props.whPassThroughArgs]);\n\n return <CrossmintEmbeddedCheckoutIFrame {...props} />;\n}\n","import type { FiatEmbeddedCheckoutProps } from \"@crossmint/client-sdk-base\";\n\nimport FiatEmbeddedCheckoutIFrame from \"../../../components/embed/fiat/FiatEmbeddedCheckoutIFrame\";\n\nexport function CrossmintFiatEmbeddedCheckout(props: FiatEmbeddedCheckoutProps) {\n return <FiatEmbeddedCheckoutIFrame {...props} />;\n}\n","import { type CSSProperties, type MouseEvent, useMemo } from \"react\";\nimport { useState } from \"react\";\n\nimport {\n type CheckoutProps,\n type CrossmintPayButtonProps,\n clientNames,\n crossmintModalService,\n crossmintPayButtonService,\n} from \"@crossmint/client-sdk-base\";\n\nimport { LIB_VERSION } from \"../../consts/version\";\nimport useEnvironment from \"../../hooks/useEnvironment\";\nimport { formatProps, useStyles } from \"./styles\";\n\nexport type CrossmintPayButtonReactProps = CrossmintPayButtonProps & {\n onClick?: (e: MouseEvent<HTMLButtonElement>) => void;\n style?: CSSProperties;\n};\n\nexport function CrossmintPayButton(buttonProps: CrossmintPayButtonReactProps) {\n const {\n className,\n disabled,\n onClick,\n style,\n tabIndex,\n theme = \"dark\",\n mintTo,\n emailTo,\n listingId,\n auctionId,\n showOverlay = true,\n mintConfig,\n whPassThroughArgs,\n environment,\n paymentMethod,\n preferredSigninMethod,\n dismissOverlayOnClick,\n prepay,\n locale = \"en-US\",\n currency = \"usd\",\n successCallbackURL = \"\",\n failureCallbackURL = \"\",\n loginEmail = \"\",\n projectId,\n getButtonText,\n checkoutProps = {\n experimental: false,\n display: \"same-tab\",\n paymentMethods: [\"fiat\", \"ETH\", \"SOL\"],\n } as CheckoutProps,\n ...props\n } = buttonProps;\n\n const collectionId = \"clientId\" in props ? props.clientId : props.collectionId;\n\n const [connecting, setConnecting] = useState(false);\n const { isServerSideRendering } = useEnvironment();\n\n const { connect } = crossmintModalService({\n clientId: collectionId,\n projectId,\n showOverlay,\n dismissOverlayOnClick,\n setConnecting,\n libVersion: LIB_VERSION,\n environment,\n clientName: clientNames.reactUi,\n locale,\n currency,\n successCallbackURL,\n failureCallbackURL,\n loginEmail,\n });\n\n const { getButtonText: getButtonTextInternal, handleClick } = crossmintPayButtonService({\n onClick,\n connecting,\n paymentMethod,\n locale,\n checkoutProps,\n });\n\n const _handleClick = (event: MouseEvent<HTMLButtonElement>) =>\n handleClick(event, () => {\n connect(\n mintConfig,\n mintTo,\n emailTo,\n listingId,\n whPassThroughArgs,\n paymentMethod,\n preferredSigninMethod,\n prepay,\n checkoutProps\n );\n });\n\n const classes = useStyles(formatProps(theme));\n\n const content = useMemo(() => {\n return (\n <span className={classes.crossmintParagraph} role=\"button-paragraph\">\n {getButtonText != null\n ? getButtonText(connecting, paymentMethod || \"fiat\")\n : getButtonTextInternal(connecting)}\n </span>\n );\n }, [connecting, getButtonText, paymentMethod]);\n\n return (\n <>\n {!isServerSideRendering && (\n <button\n className={`${classes.crossmintButton} ${className || \"\"}`}\n disabled={disabled}\n onClick={_handleClick}\n style={{ ...style }}\n tabIndex={tabIndex}\n >\n <img\n className={classes.crossmintImg}\n src=\"https://www.crossmint.io/assets/crossmint/logo.svg\"\n alt=\"Crossmint logo\"\n />\n {content}\n </button>\n )}\n </>\n );\n}\n","import { useEffect, useState } from \"react\";\n\nexport default function useEnvironment() {\n const [isServerSideRendering, setIsServerSideRendering] = useState(true);\n useEffect(() => {\n setIsServerSideRendering(false);\n }, []);\n\n return { isServerSideRendering };\n}\n","import { type Styles, createUseStyles } from \"react-jss\";\n\nconst DARK_BG = \"#1e1e1e\";\n\nconst themeIsLight = (theme: string) => theme === \"light\";\n\nexport const formatProps = (theme: string): CustomStylingProps => ({\n buttonBgColor: themeIsLight(theme) ? \"white\" : DARK_BG,\n paragraphColor: themeIsLight(theme) ? \"black\" : \"white\",\n});\n\nexport type Classes<Name extends string | number | symbol = string> = Record<Name, string>;\ninterface CustomStylingProps {\n buttonBgColor?: string;\n paragraphColor?: string;\n}\n\nconst styles: Styles<\"crossmintButton\" | \"crossmintImg\" | \"crossmintParagraph\" | \"@global\", CustomStylingProps> = {\n \"@global\": {\n \"@import\":\n \"url('https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap')\",\n },\n crossmintButton: {\n display: \"flex\",\n \"flex-direction\": \"row\",\n \"align-items\": \"center\",\n padding: \"0.875rem 0.875rem\",\n \"font-weight\": \"900\",\n transition: \"opacity ease-in-out 0.25s\",\n \"border-radius\": \"0.5rem\",\n \"font-family\": `\"Inter\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen, Ubuntu, Cantarell, \"Open Sans\", \"Helvetica Neue\", sans-serif`,\n outline: \"none\",\n border: \"none\",\n \"box-shadow\": \"0px 8px 15px rgba(0, 0, 0, 0.1)\",\n \"justify-content\": \"center\",\n background: ({ buttonBgColor }: CustomStylingProps) => buttonBgColor,\n\n \"&:hover:enabled\": {\n opacity: \"0.6\",\n cursor: \"pointer\",\n },\n },\n crossmintImg: {\n width: \"21px\",\n height: \"21px\",\n \"margin-right\": \"0.875rem\",\n },\n crossmintParagraph: {\n color: ({ paragraphColor }: CustomStylingProps) => paragraphColor,\n margin: \"0\",\n },\n};\n\nexport const useStyles: (\n data?: CustomStylingProps & {\n theme?: any;\n }\n) => Classes<\"crossmintButton\" | \"crossmintImg\" | \"crossmintParagraph\" | \"@global\"> = createUseStyles(styles);\n","import { type ReactNode, createContext, useCallback, useContext, useMemo, useRef, useState } from \"react\";\n\nimport { type Crossmint, createCrossmint } from \"@crossmint/common-sdk-base\";\n\nexport interface CrossmintContext {\n crossmint: Crossmint;\n setJwt: (jwt: string | undefined) => void;\n setRefreshToken: (refreshToken: string | undefined) => void;\n}\n\nconst CrossmintContext = createContext<CrossmintContext | null>(null);\n\nexport function CrossmintProvider({\n children,\n apiKey,\n overrideBaseUrl,\n}: Omit<Crossmint, \"jwt\"> & {\n children: ReactNode;\n}) {\n const [version, setVersion] = useState(0);\n\n const crossmintRef = useRef<Crossmint>(\n new Proxy<Crossmint>(createCrossmint({ apiKey, overrideBaseUrl }), {\n set(target, prop, value) {\n if (prop === \"jwt\" && target.jwt !== value) {\n setVersion((v) => v + 1);\n }\n if (prop === \"refreshToken\" && target.refreshToken !== value) {\n setVersion((v) => v + 1);\n }\n return Reflect.set(target, prop, value);\n },\n })\n );\n\n const setJwt = useCallback((jwt: string | undefined) => {\n if (jwt !== crossmintRef.current.jwt) {\n crossmintRef.current.jwt = jwt;\n }\n }, []);\n\n const setRefreshToken = useCallback((refreshToken: string | undefined) => {\n if (refreshToken !== crossmintRef.current.refreshToken) {\n crossmintRef.current.refreshToken = refreshToken;\n }\n }, []);\n\n const value = useMemo(\n () => ({\n get crossmint() {\n return crossmintRef.current;\n },\n setJwt,\n setRefreshToken,\n }),\n [setJwt, setRefreshToken, version]\n );\n\n return <CrossmintContext.Provider value={value}>{children}</CrossmintContext.Provider>;\n}\n\nexport function useCrossmint(missingContextMessage?: string) {\n const context = useContext(CrossmintContext);\n if (context == null) {\n throw new Error(missingContextMessage ?? \"useCrossmint must be used within a CrossmintProvider\");\n }\n return context;\n}\n","import { useContext } from \"react\";\n\nimport { WalletContext } from \"../providers/CrossmintWalletProvider\";\n\nexport function useWallet() {\n const walletContext = useContext(WalletContext);\n\n if (!walletContext) {\n throw new Error(\"useWallet must be used within CrossmintAuthProvider or CrossmintWalletProvider\");\n }\n\n return walletContext;\n}\n","import { type ReactNode, createContext, useMemo, useState } from \"react\";\n\nimport {\n type EVMSmartWallet,\n type EVMSmartWalletChain,\n SmartWalletError,\n SmartWalletSDK,\n type WalletParams,\n} from \"@crossmint/client-sdk-smart-wallet\";\n\nimport { useCrossmint } from \"../hooks\";\n\ntype WalletStatus = \"not-loaded\" | \"in-progress\" | \"loaded\" | \"loading-error\";\ntype ValidWalletState =\n | { status: \"not-loaded\" | \"in-progress\" }\n | { status: \"loaded\"; wallet: EVMSmartWallet }\n | { status: \"loading-error\"; error: SmartWalletError };\n\ntype WalletContext = {\n status: WalletStatus;\n wallet?: EVMSmartWallet;\n error?: SmartWalletError;\n getOrCreateWallet: (config?: WalletConfig) => { startedCreation: boolean; reason?: string };\n clearWallet: () => void;\n};\n\nexport const WalletContext = createContext<WalletContext>({\n status: \"not-loaded\",\n getOrCreateWallet: () => ({ startedCreation: false }),\n clearWallet: () => {},\n});\n\nexport type WalletConfig = WalletParams & { type: \"evm-smart-wallet\" };\n\nexport function CrossmintWalletProvider({\n children,\n defaultChain,\n}: {\n children: ReactNode;\n defaultChain: EVMSmartWalletChain;\n}) {\n const { crossmint } = useCrossmint(\"CrossmintWalletProvider must be used within CrossmintProvider\");\n const smartWalletSDK = useMemo(() => SmartWalletSDK.init({ clientApiKey: crossmint.apiKey }), [crossmint.apiKey]);\n\n const [state, setState] = useState<ValidWalletState>({ status: \"not-loaded\" });\n\n const getOrCreateWallet = (config: WalletConfig = { type: \"evm-smart-wallet\", signer: { type: \"PASSKEY\" } }) => {\n if (state.status == \"in-progress\") {\n console.log(\"Wallet already loading\");\n return { startedCreation: false, reason: \"Wallet is already loading.\" };\n }\n\n if (crossmint.jwt == null) {\n return { startedCreation: false, reason: `Jwt not set in \"CrossmintProvider\".` };\n }\n\n const internalCall = async () => {\n try {\n setState({ status: \"in-progress\" });\n const wallet = await smartWalletSDK.getOrCreateWallet(\n { jwt: crossmint.jwt as string },\n defaultChain,\n config\n );\n setState({ status: \"loaded\", wallet });\n } catch (error: unknown) {\n console.error(\"There was an error creating a wallet \", error);\n setState(deriveErrorState(error));\n }\n };\n\n internalCall();\n return { startedCreation: true };\n };\n\n const clearWallet = () => {\n setState({ status: \"not-loaded\" });\n };\n\n return (\n <WalletContext.Provider value={{ ...state, getOrCreateWallet, clearWallet }}>{children}</WalletContext.Provider>\n );\n}\n\nfunction deriveErrorState(error: unknown): { status: \"loading-error\"; error: SmartWalletError } {\n if (error instanceof SmartWalletError) {\n return { status: \"loading-error\", error };\n }\n\n const message = error instanceof Error ? error.message : String(error);\n const stack = error instanceof Error ? error.stack : undefined;\n return { status: \"loading-error\", error: new SmartWalletError(`Unknown Wallet Error: ${message}`, stack) };\n}\n","import { useContext } from \"react\";\n\nimport { AuthContext } from \"../providers\";\n\nexport function useAuth() {\n const context = useContext(AuthContext);\n if (context === undefined) {\n throw new Error(\"useAuth must be used within an AuthProvider\");\n }\n return context;\n}\n","export const SESSION_PREFIX = \"crossmint-session\";\nexport const REFRESH_TOKEN_PREFIX = \"crossmint-refresh-token\";\n\nexport function getCookie(name: string): string | undefined {\n const crossmintRefreshToken = document.cookie.split(\"; \").find((row) => row.startsWith(name));\n return crossmintRefreshToken ? crossmintRefreshToken.split(\"=\")[1] : undefined;\n}\n\nexport function setCookie(name: string, value: string, expiresAt?: string) {\n const expiresInUtc = expiresAt ? new Date(expiresAt).toUTCString() : \"\";\n document.cookie = `${name}=${value}; ${expiresAt ? `expires=${expiresInUtc};` : \"\"} path=/; SameSite=Lax;`;\n}\n\nexport function deleteCookie(name: string) {\n document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;\n}\n","import { REFRESH_TOKEN_PREFIX, SESSION_PREFIX, deleteCookie, getCookie, setCookie } from \"@/utils/authCookies\";\nimport { type ReactNode, createContext, useEffect, useState } from \"react\";\nimport { createPortal } from \"react-dom\";\n\nimport { CrossmintAuthService } from \"@crossmint/client-sdk-auth-core/client\";\nimport type { EVMSmartWalletChain } from \"@crossmint/client-sdk-smart-wallet\";\nimport { type UIConfig, validateApiKeyAndGetCrossmintBaseUrl } from \"@crossmint/common-sdk-base\";\n\nimport AuthModal from \"../components/auth/AuthModal\";\nimport { type AuthMaterial, useCrossmint, useRefreshToken, useWallet } from \"../hooks\";\nimport { CrossmintWalletProvider } from \"./CrossmintWalletProvider\";\n\nexport type CrossmintAuthWalletConfig = {\n defaultChain: EVMSmartWalletChain;\n createOnLogin: \"all-users\" | \"off\";\n type: \"evm-smart-wallet\";\n};\n\nexport type CrossmintAuthProviderProps = {\n embeddedWallets: CrossmintAuthWalletConfig;\n appearance?: UIConfig;\n children: ReactNode;\n};\n\ntype AuthStatus = \"logged-in\" | \"logged-out\" | \"in-progress\";\n\ntype AuthContextType = {\n login: () => void;\n logout: () => void;\n jwt?: string;\n refreshToken?: string;\n status: AuthStatus;\n};\n\nexport const AuthContext = createContext<AuthContextType>({\n login: () => {},\n logout: () => {},\n status: \"logged-out\",\n});\n\nexport function CrossmintAuthProvider({ embeddedWallets, children, appearance }: CrossmintAuthProviderProps) {\n const { crossmint, setJwt, setRefreshToken } = useCrossmint(\n \"CrossmintAuthProvider must be used within CrossmintProvider\"\n );\n const crossmintAuthService = new CrossmintAuthService(crossmint.apiKey);\n const crossmintBaseUrl = validateApiKeyAndGetCrossmintBaseUrl(crossmint.apiKey);\n const [modalOpen, setModalOpen] = useState(false);\n\n const setAuthMaterial = (authMaterial: AuthMaterial) => {\n setCookie(SESSION_PREFIX, authMaterial.jwtToken);\n setCookie(REFRESH_TOKEN_PREFIX, authMaterial.refreshToken.secret, authMaterial.refreshToken.expiresAt);\n setJwt(authMaterial.jwtToken);\n setRefreshToken(authMaterial.refreshToken.secret);\n };\n\n const logout = () => {\n deleteCookie(SESSION_PREFIX);\n deleteCookie(REFRESH_TOKEN_PREFIX);\n setJwt(undefined);\n setRefreshToken(undefined);\n };\n\n useRefreshToken({ crossmintAuthService, setAuthMaterial, logout });\n\n const login = () => {\n if (crossmint.jwt != null) {\n console.log(\"User already logged in\");\n return;\n }\n\n setModalOpen(true);\n };\n\n useEffect(() => {\n if (crossmint.jwt == null) {\n const jwt = getCookie(SESSION_PREFIX);\n setJwt(jwt);\n }\n }, []);\n\n useEffect(() => {\n if (crossmint.jwt == null) {\n return;\n }\n\n setModalOpen(false);\n }, [crossmint.jwt]);\n\n const getAuthStatus = (): AuthStatus => {\n if (crossmint.jwt != null) {\n return \"logged-in\";\n }\n if (modalOpen) {\n return \"in-progress\";\n }\n return \"logged-out\";\n };\n\n return (\n <AuthContext.Provider\n value={{\n login,\n logout,\n jwt: crossmint.jwt,\n refreshToken: crossmint.refreshToken,\n status: getAuthStatus(),\n }}\n >\n <CrossmintWalletProvider defaultChain={embeddedWallets.defaultChain}>\n <WalletManager embeddedWallets={embeddedWallets} accessToken={crossmint.jwt}>\n {children}\n </WalletManager>\n {modalOpen\n ? createPortal(\n <AuthModal\n baseUrl={crossmintBaseUrl}\n setModalOpen={setModalOpen}\n setAuthMaterial={setAuthMaterial}\n apiKey={crossmint.apiKey}\n appearance={appearance}\n />,\n\n document.body\n )\n : null}\n </CrossmintWalletProvider>\n </AuthContext.Provider>\n );\n}\n\nfunction WalletManager({\n embeddedWallets,\n children,\n accessToken,\n}: {\n embeddedWallets: CrossmintAuthWalletConfig;\n children: ReactNode;\n accessToken: string | undefined;\n}) {\n const { getOrCreateWallet, clearWallet, status } = useWallet();\n\n useEffect(() => {\n if (embeddedWallets.createOnLogin === \"all-users\" && status === \"not-loaded\" && accessToken != null) {\n getOrCreateWallet({\n type: embeddedWallets.type,\n signer: { type: \"PASSKEY\" },\n });\n }\n\n if (status === \"loaded\" && accessToken == null) {\n clearWallet();\n }\n }, [accessToken, status]);\n\n return <>{children}</>;\n}\n","import { Dialog, Transition } from \"@headlessui/react\";\nimport { type CSSProperties, Fragment, useEffect, useRef, useState } from \"react\";\nimport { z } from \"zod\";\n\nimport { IFrameWindow } from \"@crossmint/client-sdk-window\";\nimport type { UIConfig } from \"@crossmint/common-sdk-base\";\n\nimport X from \"../../icons/x\";\nimport { classNames } from \"../../utils/classNames\";\n\nconst incomingModalIframeEvents = {\n authMaterialFromAuthFrame: z.object({\n jwtToken: z.string(),\n refreshToken: z.object({\n secret: z.string(),\n expiresAt: z.string(),\n }),\n }),\n};\n\nconst outgoingModalIframeEvents = {\n closeWindow: z.object({\n closeWindow: z.string(),\n }),\n};\n\ntype IncomingModalIframeEventsType = {\n authMaterialFromAuthFrame: typeof incomingModalIframeEvents.authMaterialFromAuthFrame;\n};\n\ntype OutgoingModalIframeEventsType = {\n closeWindow: typeof outgoingModalIframeEvents.closeWindow;\n};\n\ntype AuthModalProps = {\n setModalOpen: (open: boolean) => void;\n setAuthMaterial: (authMaterial: { jwtToken: string; refreshToken: { secret: string; expiresAt: string } }) => void;\n apiKey: string;\n baseUrl: string;\n appearance?: UIConfig;\n};\n\nexport default function AuthModal({ setModalOpen, setAuthMaterial, apiKey, baseUrl, appearance }: AuthModalProps) {\n let iframeSrc = `${baseUrl}sdk/auth/frame?apiKey=${apiKey}`;\n if (appearance != null) {\n // The appearance object is serialized into a query parameter\n iframeSrc += `&uiConfig=${encodeURIComponent(JSON.stringify(appearance))}`;\n }\n\n const iframeRef = useRef<HTMLIFrameElement | null>(null);\n const [iframe, setIframe] = useState<IFrameWindow<\n IncomingModalIframeEventsType,\n OutgoingModalIframeEventsType\n > | null>(null);\n\n useEffect(() => {\n if (iframe == null) {\n return;\n }\n\n iframe.on(\"authMaterialFromAuthFrame\", (data) => {\n setAuthMaterial(data);\n iframe.off(\"authMaterialFromAuthFrame\");\n\n iframe.send(\"closeWindow\", {\n closeWindow: \"closeWindow\",\n });\n\n if (iframe?.iframe.contentWindow != null) {\n iframe.iframe.contentWindow.close();\n }\n setModalOpen(false);\n });\n\n return () => {\n if (iframe) {\n iframe.off(\"authMaterialFromAuthFrame\");\n\n if (iframe.iframe.contentWindow != null) {\n iframe.iframe.contentWindow.close();\n }\n }\n };\n }, [iframe, setAuthMaterial, setModalOpen]);\n\n const handleIframeLoaded = async () => {\n if (iframeRef.current == null) {\n // The iframe should be load, here we should log on DD if possible\n console.error(\"Something wrong happened, please try again\");\n return;\n }\n\n const initIframe = await IFrameWindow.init(iframeRef.current, {\n incomingEvents: incomingModalIframeEvents,\n outgoingEvents: outgoingModalIframeEvents,\n });\n setIframe(initIframe);\n };\n\n return (\n <Transition.Root show as={Fragment}>\n <Dialog as=\"div\" style={styles.dialog} onClose={() => setModalOpen(false)}>\n <Transition.Child\n as={Fragment}\n enter=\"ease-out duration-400\"\n enterFrom=\"opacity-0\"\n enterTo=\"opacity-100\"\n leave=\"ease-in duration-400\"\n leaveFrom=\"opacity-100\"\n leaveTo=\"opacity-0\"\n >\n <div style={styles.transitionBegin} />\n </Transition.Child>\n <Transition.Child\n as={Fragment}\n enter=\"ease-out duration-400\"\n enterFrom=\"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95\"\n enterTo=\"opacity-100 translate-y-0 sm:scale-100\"\n leave=\"ease-in duration-400\"\n leaveFrom=\"opacity-100 translate-y-0 sm:scale-100\"\n leaveTo=\"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95\"\n >\n <div style={styles.transitionEnd} onClick={(e) => e.stopPropagation()}>\n <div style={{ position: \"relative\", width: \"100%\" }}>\n <button\n type=\"button\"\n aria-label=\"Close\"\n style={{\n width: \"1.5rem\",\n position: \"absolute\",\n right: \"1.5rem\",\n top: \"1.5rem\",\n cursor: \"pointer\",\n color: appearance?.colors?.border ?? \"#909ca3\",\n outlineOffset: \"4px\",\n borderRadius: \"100%\",\n }}\n onClick={() => setModalOpen(false)}\n >\n <X />\n </button>\n </div>\n <iframe\n ref={iframeRef}\n src={iframeSrc}\n onLoad={handleIframeLoaded}\n title=\"Authentication Modal\"\n className={classNames(\n \"w-full h-[500px] border pt-12 pb-8\",\n appearance?.colors?.border\n ? `border-[${appearance.colors.border}]`\n : \"border-[#D0D5DD]\",\n appearance?.borderRadius ? `rounded-[${appearance.borderRadius}]` : \"rounded-2xl\",\n appearance?.colors?.background ? `bg-[${appearance.colors.background}]` : \"bg-white\"\n )}\n />\n </div>\n </Transition.Child>\n </Dialog>\n </Transition.Root>\n );\n}\n\nconst styles: { [key: string]: CSSProperties } = {\n dialog: {\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n overflowY: \"auto\",\n position: \"fixed\",\n top: 0,\n right: 0,\n bottom: 0,\n left: 0,\n zIndex: 20,\n },\n transitionBegin: {\n background: \"rgba(139, 151, 151, 0.2)\",\n backdropFilter: \"blur(2px)\",\n position: \"fixed\",\n top: 0,\n right: 0,\n bottom: 0,\n left: 0,\n transitionProperty: \"opacity\",\n transitionTimingFunction: \"cubic-bezier(0.4, 0, 0.2, 1)\",\n transitionDuration: \"300ms\",\n zIndex: -10,\n },\n transitionEnd: {\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n width: \"100%\",\n maxWidth: \"448px\",\n borderRadius: \"0.75rem\",\n boxShadow: \"0 1px 2px 0 rgba(0, 0, 0, 0.05)\",\n zIndex: 30,\n },\n};\n","export default function X({ className }: { className?: string }) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className={className}\n >\n <path d=\"M18 6 6 18\" />\n <path d=\"m6 6 12 12\" />\n </svg>\n );\n}\n","import { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\n/**\n * Combines multiple class names into a single string.\n *\n * @param inputs - The class names to combine.\n * @returns The combined class names as a string.\n */\nexport function classNames(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n","import { useCallback, useEffect, useRef } from \"react\";\n\nimport type { CrossmintAuthService } from \"@crossmint/client-sdk-auth-core/client\";\nimport { getJWTExpiration } from \"@crossmint/client-sdk-auth-core/client\";\nimport { queueTask, type CancellableTask } from \"@crossmint/client-sdk-base\";\n\nimport { REFRESH_TOKEN_PREFIX, getCookie } from \"../utils/authCookies\";\n\n// 2 minutes before jwt expiration\nconst TIME_BEFORE_EXPIRING_JWT_IN_SECONDS = 120;\n\nexport type AuthMaterial = {\n jwtToken: string;\n refreshToken: {\n secret: string;\n expiresAt: string;\n };\n};\n\ntype UseAuthTokenRefreshProps = {\n crossmintAuthService: CrossmintAuthService;\n setAuthMaterial: (authMaterial: AuthMaterial) => void;\n logout: () => void;\n};\n\n// Makes sure that everything inside the async IIFE has finished running before it can be called again.\n// The actual promise just holds that IIFE until it has finished running and it's then set to null\nlet refreshPromise: Promise<void> | null = null;\n\nexport function useRefreshToken({ crossmintAuthService, setAuthMaterial, logout }: UseAuthTokenRefreshProps) {\n const refreshTaskRef = useRef<CancellableTask | null>(null);\n\n const refreshAuthMaterial = useCallback(() => {\n if (refreshPromise != null) {\n return refreshPromise;\n }\n\n const refreshToken = getCookie(REFRESH_TOKEN_PREFIX);\n if (refreshToken != null) {\n refreshPromise = (async () => {\n try {\n const result = await crossmintAuthService.refreshAuthMaterial(refreshToken);\n setAuthMaterial(result);\n const jwtExpiration = getJWTExpiration(result.jwtToken);\n\n if (jwtExpiration == null) {\n throw new Error(\"Invalid JWT\");\n }\n\n const currentTime = Date.now() / 1000;\n const timeToExpire = jwtExpiration - currentTime - TIME_BEFORE_EXPIRING_JWT_IN_SECONDS;\n if (timeToExpire > 0) {\n const endTime = Date.now() + timeToExpire * 1000;\n refreshTaskRef.current = queueTask(refreshAuthMaterial, endTime);\n }\n } catch (error) {\n logout();\n console.error(error);\n } finally {\n refreshPromise = null;\n }\n })();\n }\n }, []);\n\n useEffect(() => {\n refreshAuthMaterial();\n return () => {\n if (refreshTaskRef.current) {\n refreshTaskRef.current.cancel();\n }\n };\n }, []);\n}\n"],"mappings":"syBAAA,OAAS,WAAAA,OAA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ACA,iCAAAC,GACA,yBAAAC,GACA,sBAAAC,GACA,wBAAAC,GACA,sBAAAC,GACA,4BAAAC,GACA,yCAAAC,GACA,eAAAC,GACA,+BAAAC,GACA,2BAAAC,GACA,4CAAAC,OACG,qCAvBPC,GAAQC,EAAW","names":["install","defineConfig","presetTailwind","twind_config_default","assertValidNFTCollectionViewProps","getNFTCollectionViewSrc","version","LIB_VERSION","version","jsx","CrossmintNFTCollectionView","props","assertValidNFTCollectionViewProps","src","getNFTCollectionViewSrc","LIB_VERSION","assertValidValidateNFTDetailProps","getNFTDetailSrc","jsx","CrossmintNFTDetail","props","assertValidValidateNFTDetailProps","src","getNFTDetailSrc","LIB_VERSION","isCryptoEmbeddedCheckoutProps","isFiatEmbeddedCheckoutProps","isCryptoEmbeddedCheckoutPropsWithSigner","bs58","IncomingInternalEvents","OutgoingInternalEvents","crossmintIFrameService","embeddedCheckoutPropsToUpdatableParamsPayload","isEqual","useEffect","useRef","useDeepEffect","callback","dependencies","dependenciesRef","dep","useEffect","useState","IncomingInternalEvents","crossmintIFrameService","jsx","CrossmintEmbeddedCheckoutIFrame","_a","_b","onInternalEvent","props","__objRest","getUrl","listenToEvents","listenToInternalEvents","crossmintIFrameService","height","setHeight","useState","url","useEffect","clearListener","event","type","payload","IncomingInternalEvents","jsx","CryptoEmbeddedCheckoutIFrame","props","emitInternalEvent","crossmintIFrameService","signer","paymentMethod","onInternalEvent","event","type","payload","IncomingInternalEvents","serializedTransaction","handleIncomingTransaction","chain","handleChainSwitch","__async","txId","handleSOLTransaction","handleETHTransaction","OutgoingInternalEvents","e","Transaction","transaction","bs58","parseTransaction","useDeepEffect","embeddedCheckoutPropsToUpdatableParamsPayload","CrossmintEmbeddedCheckoutIFrame","__spreadValues","jsx","CrossmintCryptoEmbeddedCheckout","props","isCryptoEmbeddedCheckoutPropsWithSigner","CryptoEmbeddedCheckoutIFrame","__spreadValues","crossmintIFrameService","embeddedCheckoutPropsToUpdatableParamsPayload","jsx","FiatEmbeddedCheckoutIFrame","props","emitInternalEvent","crossmintIFrameService","useDeepEffect","embeddedCheckoutPropsToUpdatableParamsPayload","CrossmintEmbeddedCheckoutIFrame","__spreadValues","jsx","CrossmintFiatEmbeddedCheckout","props","FiatEmbeddedCheckoutIFrame","__spreadValues","jsx","CrossmintPaymentElement","props","isFiatEmbeddedCheckoutProps","CrossmintFiatEmbeddedCheckout","__spreadValues","isCryptoEmbeddedCheckoutProps","CrossmintCryptoEmbeddedCheckout","useMemo","useState","clientNames","crossmintModalService","crossmintPayButtonService","useEffect","useState","useEnvironment","isServerSideRendering","setIsServerSideRendering","createUseStyles","DARK_BG","themeIsLight","theme","formatProps","styles","buttonBgColor","paragraphColor","useStyles","Fragment","jsx","jsxs","CrossmintPayButton","buttonProps","_a","className","disabled","onClick","style","tabIndex","theme","mintTo","emailTo","listingId","auctionId","showOverlay","mintConfig","whPassThroughArgs","environment","paymentMethod","preferredSigninMethod","dismissOverlayOnClick","prepay","locale","currency","successCallbackURL","failureCallbackURL","loginEmail","projectId","getButtonText","checkoutProps","props","__objRest","collectionId","connecting","setConnecting","useState","isServerSideRendering","useEnvironment","connect","crossmintModalService","LIB_VERSION","clientNames","getButtonTextInternal","handleClick","crossmintPayButtonService","_handleClick","event","classes","useStyles","formatProps","content","useMemo","__spreadValues","createContext","useCallback","useContext","useMemo","useRef","useState","createCrossmint","jsx","CrossmintContext","CrossmintProvider","children","apiKey","overrideBaseUrl","version","setVersion","crossmintRef","target","prop","value","v","setJwt","jwt","setRefreshToken","refreshToken","useCrossmint","missingContextMessage","context","useContext","createContext","useMemo","useState","SmartWalletError","SmartWalletSDK","jsx","WalletContext","createContext","CrossmintWalletProvider","children","defaultChain","crossmint","useCrossmint","smartWalletSDK","useMemo","SmartWalletSDK","state","setState","useState","getOrCreateWallet","config","__async","wallet","error","deriveErrorState","clearWallet","__spreadProps","__spreadValues","SmartWalletError","message","stack","useWallet","walletContext","useContext","WalletContext","useContext","SESSION_PREFIX","REFRESH_TOKEN_PREFIX","getCookie","name","crossmintRefreshToken","row","setCookie","value","expiresAt","expiresInUtc","deleteCookie","createContext","useEffect","useState","createPortal","CrossmintAuthService","validateApiKeyAndGetCrossmintBaseUrl","Dialog","Transition","Fragment","useEffect","useRef","useState","z","IFrameWindow","jsx","jsxs","X","className","clsx","twMerge","classNames","inputs","jsx","jsxs","incomingModalIframeEvents","z","outgoingModalIframeEvents","AuthModal","setModalOpen","setAuthMaterial","apiKey","baseUrl","appearance","_a","_b","_c","_d","iframeSrc","iframeRef","useRef","iframe","setIframe","useState","useEffect","data","handleIframeLoaded","__async","initIframe","IFrameWindow","Transition","Fragment","Dialog","styles","e","X","classNames","Fragment","jsx","jsxs","AuthContext","createContext","CrossmintAuthProvider","embeddedWallets","children","appearance","crossmint","setJwt","setRefreshToken","useCrossmint","crossmintAuthService","CrossmintAuthService","crossmintBaseUrl","validateApiKeyAndGetCrossmintBaseUrl","modalOpen","setModalOpen","useState","setAuthMaterial","authMaterial","setCookie","SESSION_PREFIX","REFRESH_TOKEN_PREFIX","logout","deleteCookie","useRefreshToken","login","useEffect","jwt","getCookie","getAuthStatus","CrossmintWalletProvider","WalletManager","createPortal","AuthModal","accessToken","getOrCreateWallet","clearWallet","status","useWallet","useAuth","context","useContext","AuthContext","useCallback","useEffect","useRef","getJWTExpiration","queueTask","TIME_BEFORE_EXPIRING_JWT_IN_SECONDS","refreshPromise","useRefreshToken","crossmintAuthService","setAuthMaterial","logout","refreshTaskRef","useRef","refreshAuthMaterial","useCallback","refreshToken","getCookie","REFRESH_TOKEN_PREFIX","__async","result","jwtExpiration","getJWTExpiration","currentTime","timeToExpire","endTime","queueTask","error","useEffect","CrossmintEvents","useCrossmintEvents","Chain","SmartWalletError","UserWalletAlreadyCreatedError","AdminAlreadyUsedError","AdminMismatchError","PasskeyMismatchError","PasskeyPromptError","PasskeyRegistrationError","PasskeyIncompatibleAuthenticatorError","ConfigError","SmartWalletsNotEnabledError","EVMSendTransactionError","EVMSendTransactionExecutionRevertedError","install","twind_config_default"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crossmint/client-sdk-react-ui",
3
- "version": "1.3.24",
3
+ "version": "1.4.1",
4
4
  "repository": "https://github.com/Crossmint/crossmint-sdk",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Paella Labs Inc",
@@ -31,11 +31,11 @@
31
31
  "tailwind-merge": "2.4.0",
32
32
  "tailwindcss": "3.4.10",
33
33
  "zod": "3.22.4",
34
- "@crossmint/client-sdk-auth-core": "1.1.7",
35
- "@crossmint/client-sdk-base": "1.2.7",
36
- "@crossmint/client-sdk-smart-wallet": "0.1.17",
34
+ "@crossmint/client-sdk-auth-core": "1.2.0",
35
+ "@crossmint/client-sdk-base": "1.2.8",
36
+ "@crossmint/client-sdk-smart-wallet": "0.1.18",
37
37
  "@crossmint/client-sdk-window": "0.0.10",
38
- "@crossmint/common-sdk-base": "0.1.4"
38
+ "@crossmint/common-sdk-base": "0.2.0"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/lodash.isequal": "4.5.6",
@@ -9,8 +9,12 @@ import X from "../../icons/x";
9
9
  import { classNames } from "../../utils/classNames";
10
10
 
11
11
  const incomingModalIframeEvents = {
12
- jwtToken: z.object({
12
+ authMaterialFromAuthFrame: z.object({
13
13
  jwtToken: z.string(),
14
+ refreshToken: z.object({
15
+ secret: z.string(),
16
+ expiresAt: z.string(),
17
+ }),
14
18
  }),
15
19
  };
16
20
 
@@ -21,7 +25,7 @@ const outgoingModalIframeEvents = {
21
25
  };
22
26
 
23
27
  type IncomingModalIframeEventsType = {
24
- jwtToken: typeof incomingModalIframeEvents.jwtToken;
28
+ authMaterialFromAuthFrame: typeof incomingModalIframeEvents.authMaterialFromAuthFrame;
25
29
  };
26
30
 
27
31
  type OutgoingModalIframeEventsType = {
@@ -30,13 +34,13 @@ type OutgoingModalIframeEventsType = {
30
34
 
31
35
  type AuthModalProps = {
32
36
  setModalOpen: (open: boolean) => void;
33
- setJwtToken: (jwtToken: string) => void;
37
+ setAuthMaterial: (authMaterial: { jwtToken: string; refreshToken: { secret: string; expiresAt: string } }) => void;
34
38
  apiKey: string;
35
39
  baseUrl: string;
36
40
  appearance?: UIConfig;
37
41
  };
38
42
 
39
- export default function AuthModal({ setModalOpen, setJwtToken, apiKey, baseUrl, appearance }: AuthModalProps) {
43
+ export default function AuthModal({ setModalOpen, setAuthMaterial, apiKey, baseUrl, appearance }: AuthModalProps) {
40
44
  let iframeSrc = `${baseUrl}sdk/auth/frame?apiKey=${apiKey}`;
41
45
  if (appearance != null) {
42
46
  // The appearance object is serialized into a query parameter
@@ -54,9 +58,9 @@ export default function AuthModal({ setModalOpen, setJwtToken, apiKey, baseUrl,
54
58
  return;
55
59
  }
56
60
 
57
- iframe.on("jwtToken", (data) => {
58
- setJwtToken(data.jwtToken);
59
- iframe.off("jwtToken");
61
+ iframe.on("authMaterialFromAuthFrame", (data) => {
62
+ setAuthMaterial(data);
63
+ iframe.off("authMaterialFromAuthFrame");
60
64
 
61
65
  iframe.send("closeWindow", {
62
66
  closeWindow: "closeWindow",
@@ -70,14 +74,14 @@ export default function AuthModal({ setModalOpen, setJwtToken, apiKey, baseUrl,
70
74
 
71
75
  return () => {
72
76
  if (iframe) {
73
- iframe.off("jwtToken");
77
+ iframe.off("authMaterialFromAuthFrame");
74
78
 
75
79
  if (iframe.iframe.contentWindow != null) {
76
80
  iframe.iframe.contentWindow.close();
77
81
  }
78
82
  }
79
83
  };
80
- }, [iframe, setJwtToken, setModalOpen]);
84
+ }, [iframe, setAuthMaterial, setModalOpen]);
81
85
 
82
86
  const handleIframeLoaded = async () => {
83
87
  if (iframeRef.current == null) {
@@ -1,3 +1,4 @@
1
1
  export * from "./useCrossmint";
2
2
  export * from "./useWallet";
3
3
  export * from "./useAuth";
4
+ export * from "./useRefreshToken";