accesly 0.1.0 → 0.1.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.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -67,6 +67,12 @@ interface AcceslyContextType {
|
|
|
67
67
|
sendPayment: (params: SendPaymentParams) => Promise<{
|
|
68
68
|
txHash: string;
|
|
69
69
|
}>;
|
|
70
|
+
/** Rotate wallet keys (generates new keypair, updates contract) */
|
|
71
|
+
rotateKeys: () => Promise<{
|
|
72
|
+
newStellarAddress: string;
|
|
73
|
+
}>;
|
|
74
|
+
/** Get transaction history */
|
|
75
|
+
getTransactions: (limit?: number) => Promise<TransactionRecord[]>;
|
|
70
76
|
/** Refresh the balance */
|
|
71
77
|
refreshBalance: () => Promise<void>;
|
|
72
78
|
/** Refresh wallet info */
|
package/dist/index.d.ts
CHANGED
|
@@ -67,6 +67,12 @@ interface AcceslyContextType {
|
|
|
67
67
|
sendPayment: (params: SendPaymentParams) => Promise<{
|
|
68
68
|
txHash: string;
|
|
69
69
|
}>;
|
|
70
|
+
/** Rotate wallet keys (generates new keypair, updates contract) */
|
|
71
|
+
rotateKeys: () => Promise<{
|
|
72
|
+
newStellarAddress: string;
|
|
73
|
+
}>;
|
|
74
|
+
/** Get transaction history */
|
|
75
|
+
getTransactions: (limit?: number) => Promise<TransactionRecord[]>;
|
|
70
76
|
/** Refresh the balance */
|
|
71
77
|
refreshBalance: () => Promise<void>;
|
|
72
78
|
/** Refresh wallet info */
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime');var O="accesly_auth",ce="https://accesly.vercel.app",U=class{constructor(e,r){this.appId=e,this.baseUrl=r||ce;}setTokens(e){localStorage.setItem(O,JSON.stringify(e));}getTokens(){let e=localStorage.getItem(O);if(!e)return null;try{return JSON.parse(e)}catch{return null}}clearTokens(){localStorage.removeItem(O);}hasSession(){return this.getTokens()!==null}async request(e,r={},o=true){let d=this.getTokens(),h={"Content-Type":"application/json","x-accesly-key":this.appId,...d?{Authorization:`Bearer ${d.accessToken}`}:{}},i=await fetch(`${this.baseUrl}${e}`,{...r,headers:{...h,...r.headers}});if(i.status===401&&o&&d?.refreshToken){if(await this.refreshToken(d.refreshToken))return this.request(e,r,false);throw this.clearTokens(),new Error("Session expired. Please reconnect.")}if(!i.ok){let m=await i.json().catch(()=>({}));throw new Error(m.error||m.details||`Request failed: ${i.status}`)}return i.json()}async refreshToken(e){try{let r=await fetch(`${this.baseUrl}/api/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:e})});if(!r.ok)return !1;let o=await r.json(),d=this.getTokens();return d&&this.setTokens({...d,accessToken:o.accessToken,refreshToken:o.refreshToken,expiresAt:o.expiresAt}),!0}catch{return false}}async getWalletInfo(){return this.request("/api/wallet/info")}async createWallet(){return this.request("/api/wallet/create",{method:"POST"})}async getBalance(){return this.request("/api/wallet/balance")}async sendPayment(e){return this.request("/api/wallet/send",{method:"POST",body:JSON.stringify(e)})}async getTransactions(e=20){return this.request(`/api/wallet/transactions?limit=${e}`)}async rotateKeys(){return this.request("/api/wallet/rotate",{method:"POST"})}};function X(a,e){return new Promise((r,o)=>{let d=window.screenX+(window.innerWidth-450)/2,h=window.screenY+(window.innerHeight-600)/2,i=window.open(`${a}/auth/popup?appId=${e}`,"accesly-auth",`width=450,height=600,left=${d},top=${h},toolbar=no,menubar=no`);if(!i){o(new Error("Failed to open popup. Please allow popups for this site."));return}function m(u){u.origin.includes(new URL(a).host)&&(u.data?.type==="accesly-auth-success"&&(p(),r(u.data.payload)),u.data?.type==="accesly-auth-error"&&(p(),o(new Error(u.data.error||"Authentication failed"))));}let b=setInterval(()=>{i.closed&&(p(),o(new Error("Authentication cancelled")));},500);function p(){window.removeEventListener("message",m),clearInterval(b);}window.addEventListener("message",m);})}var _=react.createContext(null),ue="https://accesly.vercel.app";function ye({children:a,...e}){let r=e.baseUrl||ue,o=react.useMemo(()=>new U(e.appId,r),[e.appId,r]),[d,h]=react.useState(null),[i,m]=react.useState(null),[b,p]=react.useState(true),[u,C]=react.useState(false),[P,v]=react.useState(null);react.useEffect(()=>{o.hasSession()?S():p(false);},[o]),react.useEffect(()=>{if(!d)return;T();let l=setInterval(T,15e3);return ()=>clearInterval(l)},[d]);async function S(){v(null);try{let l=await o.getWalletInfo();h(l.wallet),e.onConnect?.(l.wallet);}catch(l){if(l.message?.includes("404")||l.message?.includes("not found")){await L();return}l.message?.includes("Session expired")&&(o.clearTokens(),h(null)),v(l.message);}finally{p(false);}}async function L(){C(true),v(null);try{await o.createWallet();let l=await o.getWalletInfo();h(l.wallet),e.onConnect?.(l.wallet);}catch(l){v(l.message);}finally{C(false),p(false);}}async function T(){try{let A=(await o.getBalance()).balances.find(D=>D.asset==="native");m(A?.balance||"0");}catch{}}let M=react.useCallback(async()=>{v(null);try{let l=await X(r,e.appId);o.setTokens(l),p(!0),await S();}catch(l){l.message!=="Authentication cancelled"&&v(l.message);}},[r,e.appId,o]),E=react.useCallback(()=>{o.clearTokens(),h(null),m(null),v(null),e.onDisconnect?.();},[o,e.onDisconnect]),F=react.useCallback(async l=>o.sendPayment(l),[o]),$=react.useCallback(async()=>{await T();},[o]),G=react.useCallback(async()=>{await S();},[o]),q={loading:b,creating:u,wallet:d,balance:i,error:P,connect:M,disconnect:E,sendPayment:F,refreshBalance:$,refreshWallet:G};return jsxRuntime.jsx(_.Provider,{value:q,children:a})}function R(){let a=react.useContext(_);if(!a)throw new Error('useAccesly must be used within an <AcceslyProvider>. Wrap your app with <AcceslyProvider appId="acc_xxxxx">.');return a}function K({onClose:a,onConnect:e}){return jsxRuntime.jsx("div",{style:w.overlay,onClick:a,children:jsxRuntime.jsxs("div",{style:w.modal,onClick:r=>r.stopPropagation(),children:[jsxRuntime.jsx("button",{onClick:a,style:w.closeBtn,children:jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),jsxRuntime.jsx("div",{style:w.iconWrapper,children:jsxRuntime.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"#667eea",strokeWidth:"1.5",children:[jsxRuntime.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2.5"}),jsxRuntime.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]})}),jsxRuntime.jsx("h2",{style:w.title,children:"Connect to Accesly"}),jsxRuntime.jsx("p",{style:w.subtitle,children:"Choose how you want to connect"}),jsxRuntime.jsxs("button",{onClick:e,style:w.googleBtn,children:[jsxRuntime.jsxs("svg",{style:w.googleIcon,viewBox:"0 0 24 24",children:[jsxRuntime.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z",fill:"#4285F4"}),jsxRuntime.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),jsxRuntime.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z",fill:"#FBBC05"}),jsxRuntime.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]}),"Continue with Google"]}),jsxRuntime.jsx("p",{style:w.footer,children:"Powered by Accesly"})]})})}var w={overlay:{position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:99999,padding:"1rem",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},modal:{position:"relative",backgroundColor:"#141428",borderRadius:"20px",border:"1px solid #2a2a4a",padding:"2rem",width:"100%",maxWidth:"380px",textAlign:"center"},closeBtn:{position:"absolute",top:"1rem",right:"1rem",background:"none",border:"none",color:"#64748b",cursor:"pointer",padding:"4px"},iconWrapper:{width:"56px",height:"56px",borderRadius:"16px",backgroundColor:"rgba(102, 126, 234, 0.1)",border:"1px solid rgba(102, 126, 234, 0.2)",display:"flex",alignItems:"center",justifyContent:"center",margin:"0 auto 1rem"},title:{fontSize:"1.3rem",fontWeight:700,color:"#e2e8f0",margin:"0 0 0.25rem"},subtitle:{color:"#64748b",fontSize:"0.85rem",margin:"0 0 1.5rem"},googleBtn:{display:"flex",alignItems:"center",justifyContent:"center",gap:"0.75rem",padding:"0.85rem 1.5rem",backgroundColor:"#1a1a2e",color:"#e2e8f0",border:"1px solid #2a2a4a",borderRadius:"12px",fontSize:"0.95rem",fontWeight:500,cursor:"pointer",width:"100%",marginBottom:"1.25rem"},googleIcon:{width:"20px",height:"20px",flexShrink:0},footer:{color:"#475569",fontSize:"0.7rem",margin:0}};function Y({onClose:a}){let{wallet:e,balance:r,disconnect:o,sendPayment:d,refreshBalance:h}=R(),[i,m]=react.useState("wallet"),[b,p]=react.useState(""),[u,C]=react.useState(""),[P,v]=react.useState(""),[S,L]=react.useState(false),[T,M]=react.useState(null),[E,F]=react.useState(null),[$,G]=react.useState([]),[q,l]=react.useState(false),[A,D]=react.useState(null);if(react.useEffect(()=>{i==="activity"&&$.length===0&&Z();},[i]),!e)return null;async function Z(){l(true);try{let s=await fetch("/api/wallet/transactions?limit=20");}catch{}finally{l(false);}}async function ee(){if(!(!b||!u)){L(true),F(null);try{let s=await d({destination:b,amount:u,memo:P||void 0});M(s.txHash),h();}catch(s){F(s.message);}finally{L(false);}}}function V(s,y=6,N=6){return s.length<=y+N+3?s:`${s.slice(0,y)}...${s.slice(-N)}`}async function j(s,y){await navigator.clipboard.writeText(s),D(y),setTimeout(()=>D(null),1500);}function te(){o(),a();}let ne=r?parseFloat(r).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}):"---",oe=he(e.stellarAddress),re=[{key:"wallet",label:"Wallet"},{key:"activity",label:"Activity"},{key:"account",label:"Account"},{key:"security",label:"Security"}];return jsxRuntime.jsx("div",{style:t.overlay,onClick:a,children:jsxRuntime.jsxs("div",{style:t.panel,onClick:s=>s.stopPropagation(),children:[jsxRuntime.jsxs("div",{style:t.header,children:[jsxRuntime.jsx("button",{onClick:a,style:t.closeBtn,children:jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),jsxRuntime.jsx("div",{style:{...t.identicon,backgroundColor:oe}}),jsxRuntime.jsx("p",{style:t.headerAddr,children:V(e.stellarAddress,8,8)}),jsxRuntime.jsxs("p",{style:t.headerBalance,children:[ne," ",jsxRuntime.jsx("span",{style:t.headerCurrency,children:"XLM"})]})]}),jsxRuntime.jsx("div",{style:t.tabBar,children:re.map(s=>jsxRuntime.jsx("button",{onClick:()=>m(s.key),style:{...t.tab,...i===s.key?t.tabActive:{}},children:s.label},s.key))}),jsxRuntime.jsxs("div",{style:t.content,children:[i==="wallet"&&ae(),i==="activity"&&se(),i==="account"&&le(),i==="security"&&ie()]})]})});function ae(){return T?jsxRuntime.jsxs("div",{style:t.centeredCol,children:[jsxRuntime.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"#34d399",strokeWidth:"2",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10"}),jsxRuntime.jsx("polyline",{points:"8 12 11 15 16 9"})]}),jsxRuntime.jsx("p",{style:{color:"#34d399",fontWeight:600,margin:"0.5rem 0"},children:"Payment Sent"}),jsxRuntime.jsxs("p",{style:{color:"#64748b",fontSize:"0.75rem",fontFamily:"monospace"},children:[T.slice(0,12),"...",T.slice(-12)]}),jsxRuntime.jsx("button",{onClick:()=>{M(null),p(""),C(""),v("");},style:t.primaryBtn,children:"Done"})]}):jsxRuntime.jsxs("div",{style:t.walletTab,children:[jsxRuntime.jsxs("div",{style:t.formGroup,children:[jsxRuntime.jsx("label",{style:t.formLabel,children:"Destination"}),jsxRuntime.jsx("input",{type:"text",placeholder:"G...",value:b,onChange:s=>p(s.target.value),maxLength:56,style:t.formInput})]}),jsxRuntime.jsxs("div",{style:t.formGroup,children:[jsxRuntime.jsx("label",{style:t.formLabel,children:"Amount (XLM)"}),jsxRuntime.jsx("input",{type:"number",placeholder:"0.00",value:u,onChange:s=>C(s.target.value),min:"0.0000001",step:"any",style:t.formInput})]}),jsxRuntime.jsxs("div",{style:t.formGroup,children:[jsxRuntime.jsx("label",{style:t.formLabel,children:"Memo (optional)"}),jsxRuntime.jsx("input",{type:"text",placeholder:"What is this for?",value:P,onChange:s=>v(s.target.value),maxLength:28,style:t.formInput})]}),E&&jsxRuntime.jsx("p",{style:t.error,children:E}),jsxRuntime.jsx("button",{onClick:ee,disabled:S||!b||!u,style:{...t.primaryBtn,opacity:S||!b||!u?.5:1},children:S?"Sending...":"Send Payment"}),jsxRuntime.jsx("button",{onClick:()=>j(e.stellarAddress,"receive"),style:t.receiveBtn,children:A==="receive"?"Address Copied!":"Copy Address to Receive"})]})}function se(){return jsxRuntime.jsx("p",{style:t.emptyText,children:"Transaction history coming soon."})}function le(){let s=[{label:"Email",value:e.email,key:"email"},{label:"Contract ID",value:e.contractId,key:"contract",copy:true},{label:"Stellar Address",value:e.stellarAddress,key:"stellar",copy:true},{label:"Public Key",value:e.publicKey,key:"pubkey",copy:true},{label:"Created",value:new Date(e.createdAt).toLocaleDateString(),key:"created"}];return jsxRuntime.jsx("div",{style:t.fieldList,children:s.map(y=>jsxRuntime.jsxs("div",{style:t.field,children:[jsxRuntime.jsx("span",{style:t.fieldLabel,children:y.label}),y.copy?jsxRuntime.jsx("button",{onClick:()=>j(y.value,y.key),style:{...t.copyBtn,color:A===y.key?"#34d399":"#a5b4fc",borderColor:A===y.key?"#34d399":"#2a2a4a"},children:A===y.key?"Copied!":V(y.value,8,8)}):jsxRuntime.jsx("span",{style:t.fieldValue,children:y.value})]},y.key))})}function ie(){return jsxRuntime.jsxs("div",{style:t.securityTab,children:[jsxRuntime.jsxs("div",{style:t.fieldList,children:[jsxRuntime.jsxs("div",{style:t.field,children:[jsxRuntime.jsx("span",{style:t.fieldLabel,children:"Recovery"}),jsxRuntime.jsx("span",{style:{...t.fieldValue,color:"#34d399"},children:"Protected"})]}),jsxRuntime.jsxs("div",{style:t.field,children:[jsxRuntime.jsx("span",{style:t.fieldLabel,children:"Method"}),jsxRuntime.jsxs("span",{style:t.fieldValue,children:["Google (",e.email,")"]})]})]}),jsxRuntime.jsxs("button",{onClick:te,style:t.disconnectBtn,children:[jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),jsxRuntime.jsx("polyline",{points:"16 17 21 12 16 7"}),jsxRuntime.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]}),"Disconnect"]})]})}}function he(a){let e=0;for(let r=0;r<a.length;r++)e=a.charCodeAt(r)+((e<<5)-e);return `hsl(${Math.abs(e)%360}, 65%, 55%)`}var t={overlay:{position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:99999,padding:"1rem",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},panel:{backgroundColor:"#0f0f1e",borderRadius:"20px",border:"1px solid #2a2a4a",width:"100%",maxWidth:"420px",maxHeight:"85vh",display:"flex",flexDirection:"column",overflow:"hidden"},header:{position:"relative",display:"flex",flexDirection:"column",alignItems:"center",padding:"1.5rem 1.5rem 1rem",background:"linear-gradient(180deg, #1a1a3a 0%, #0f0f1e 100%)"},closeBtn:{position:"absolute",top:"1rem",right:"1rem",background:"none",border:"none",color:"#64748b",cursor:"pointer",padding:"4px"},identicon:{width:"48px",height:"48px",borderRadius:"50%",marginBottom:"0.5rem"},headerAddr:{fontFamily:"monospace",fontSize:"0.8rem",color:"#8b8ba7",margin:"0 0 0.25rem"},headerBalance:{fontSize:"1.75rem",fontWeight:700,color:"#ffffff",margin:0},headerCurrency:{fontSize:"0.85rem",fontWeight:500,color:"#8b8ba7"},tabBar:{display:"flex",borderBottom:"1px solid #2a2a4a",padding:"0 0.5rem"},tab:{flex:1,padding:"0.75rem 0.5rem",background:"none",border:"none",borderBottom:"2px solid transparent",color:"#64748b",fontSize:"0.8rem",fontWeight:500,cursor:"pointer",transition:"color 0.2s, border-color 0.2s",borderRadius:0},tabActive:{color:"#e2e8f0",borderBottomColor:"#667eea"},content:{flex:1,overflowY:"auto",padding:"1rem 1.25rem 1.25rem"},walletTab:{display:"flex",flexDirection:"column",gap:"0.75rem"},formGroup:{display:"flex",flexDirection:"column",gap:"0.3rem"},formLabel:{color:"#8b8ba7",fontSize:"0.75rem",fontWeight:500},formInput:{backgroundColor:"#1a1a2e",border:"1px solid #2a2a4a",borderRadius:"8px",padding:"0.65rem 0.75rem",color:"#e2e8f0",fontSize:"0.9rem",outline:"none",width:"100%",boxSizing:"border-box",fontFamily:"inherit"},primaryBtn:{backgroundColor:"#667eea",color:"#fff",border:"none",borderRadius:"10px",padding:"0.75rem",fontSize:"0.95rem",fontWeight:600,cursor:"pointer",width:"100%",marginTop:"0.25rem"},receiveBtn:{backgroundColor:"transparent",color:"#a5b4fc",border:"1.5px solid #4a4a7a",borderRadius:"10px",padding:"0.65rem",fontSize:"0.85rem",fontWeight:600,cursor:"pointer",width:"100%"},error:{color:"#f87171",fontSize:"0.8rem",margin:0,padding:"0.4rem 0.6rem",backgroundColor:"rgba(248, 113, 113, 0.1)",borderRadius:"6px"},centeredCol:{display:"flex",flexDirection:"column",alignItems:"center",gap:"0.5rem",padding:"1rem 0"},fieldList:{display:"flex",flexDirection:"column"},field:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0.6rem 0",borderBottom:"1px solid #1a1a2e"},fieldLabel:{color:"#8b8ba7",fontSize:"0.8rem"},fieldValue:{color:"#e2e8f0",fontSize:"0.8rem",fontWeight:500},copyBtn:{background:"none",border:"1px solid #2a2a4a",color:"#a5b4fc",padding:"0.2rem 0.5rem",borderRadius:"4px",fontSize:"0.72rem",fontFamily:"monospace",cursor:"pointer",transition:"color 0.2s, border-color 0.2s"},securityTab:{display:"flex",flexDirection:"column",gap:"1rem"},disconnectBtn:{display:"flex",alignItems:"center",justifyContent:"center",gap:"0.5rem",width:"100%",padding:"0.65rem",backgroundColor:"transparent",color:"#f87171",border:"1px solid rgba(248, 113, 113, 0.2)",borderRadius:"10px",fontSize:"0.85rem",fontWeight:500,cursor:"pointer"},emptyText:{color:"#64748b",fontSize:"0.85rem",textAlign:"center",padding:"2rem 0"}};function be(){let{wallet:a,balance:e,loading:r,creating:o,connect:d}=R(),[h,i]=react.useState(false),[m,b]=react.useState(false);if(r)return jsxRuntime.jsx("div",{style:x.pillLoading,children:jsxRuntime.jsx("div",{style:x.spinner})});if(!a)return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{onClick:()=>i(true),style:o?x.pill:x.connectBtn,disabled:o,children:o?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:x.spinnerSmall}),jsxRuntime.jsx("span",{style:x.pillText,children:"Creating wallet..."})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2.5"}),jsxRuntime.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),"Connect Wallet"]})}),h&&jsxRuntime.jsx(K,{onClose:()=>i(false),onConnect:async()=>{i(false),await d();}})]});let p=a.stellarAddress,u=`${p.slice(0,4)}...${p.slice(-4)}`,C=e?`${parseFloat(e).toFixed(2)} XLM`:"--- XLM",P=xe(p);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("button",{onClick:()=>b(true),style:x.pill,children:[jsxRuntime.jsx("div",{style:{...x.identicon,backgroundColor:P}}),jsxRuntime.jsx("span",{style:x.pillAddr,children:u}),jsxRuntime.jsx("span",{style:x.divider}),jsxRuntime.jsx("span",{style:x.pillBalance,children:C})]}),m&&jsxRuntime.jsx(Y,{onClose:()=>b(false)})]})}function xe(a){let e=0;for(let r=0;r<a.length;r++)e=a.charCodeAt(r)+((e<<5)-e);return `hsl(${Math.abs(e)%360}, 65%, 55%)`}var x={connectBtn:{display:"flex",alignItems:"center",gap:"0.6rem",padding:"0.85rem 1.75rem",background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",color:"#fff",border:"none",borderRadius:"12px",fontSize:"1rem",fontWeight:600,cursor:"pointer",transition:"transform 0.15s, box-shadow 0.15s",boxShadow:"0 4px 15px rgba(102, 126, 234, 0.4)",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},pill:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.5rem 0.85rem",backgroundColor:"#1a1a2e",border:"1px solid #2a2a4a",borderRadius:"50px",cursor:"pointer",transition:"border-color 0.2s, box-shadow 0.2s",color:"#e2e8f0",fontSize:"0.85rem",fontWeight:500,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},pillLoading:{display:"flex",alignItems:"center",justifyContent:"center",padding:"0.5rem 1.5rem",backgroundColor:"#1a1a2e",border:"1px solid #2a2a4a",borderRadius:"50px",height:"42px"},identicon:{width:"24px",height:"24px",borderRadius:"50%",flexShrink:0},pillAddr:{fontFamily:"monospace",fontSize:"0.8rem",color:"#e2e8f0"},divider:{width:"1px",height:"16px",backgroundColor:"#3a3a5a"},pillBalance:{fontSize:"0.8rem",color:"#8b8ba7",fontWeight:500},pillText:{fontSize:"0.8rem",color:"#8b8ba7"},spinner:{width:"20px",height:"20px",border:"2px solid #2a2a4a",borderTop:"2px solid #667eea",borderRadius:"50%",animation:"accesly-spin 1s linear infinite"},spinnerSmall:{width:"16px",height:"16px",border:"2px solid #2a2a4a",borderTop:"2px solid #667eea",borderRadius:"50%",animation:"accesly-spin 1s linear infinite",flexShrink:0}};if(typeof document<"u"){let a="accesly-keyframes";if(!document.getElementById(a)){let e=document.createElement("style");e.id=a,e.textContent=`
|
|
1
|
+
'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime');var X="accesly_auth",Ce="https://accesly.vercel.app",I=class extends Error{constructor(n,i){super(n),this.name="AcceslyApiError",this.status=i;}},G=class{constructor(n,i){this.appId=n,this.baseUrl=i||Ce;}setTokens(n){localStorage.setItem(X,JSON.stringify(n));}getTokens(){let n=localStorage.getItem(X);if(!n)return null;try{return JSON.parse(n)}catch{return null}}clearTokens(){localStorage.removeItem(X);}hasSession(){return this.getTokens()!==null}async request(n,i={},a=true){let p=this.getTokens(),b={"Content-Type":"application/json","x-accesly-key":this.appId,...p?{Authorization:`Bearer ${p.accessToken}`}:{}},u=await fetch(`${this.baseUrl}${n}`,{...i,headers:{...b,...i.headers}});if(u.status===401&&a&&p?.refreshToken){if(await this.refreshToken(p.refreshToken))return this.request(n,i,false);throw this.clearTokens(),new Error("Session expired. Please reconnect.")}if(!u.ok){let f=await u.json().catch(()=>({}));throw new I(f.error||f.details||`Request failed: ${u.status}`,u.status)}return u.json()}async refreshToken(n){try{let i=await fetch(`${this.baseUrl}/api/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:n})});if(!i.ok)return !1;let a=await i.json(),p=this.getTokens();return p&&this.setTokens({...p,accessToken:a.accessToken,refreshToken:a.refreshToken,expiresAt:a.expiresAt}),!0}catch{return false}}async getWalletInfo(){return this.request("/api/wallet/info")}async createWallet(){return this.request("/api/wallet/create",{method:"POST"})}async getBalance(){return this.request("/api/wallet/balance")}async sendPayment(n){return this.request("/api/wallet/send",{method:"POST",body:JSON.stringify(n)})}async getTransactions(n=20){return this.request(`/api/wallet/transactions?limit=${n}`)}async rotateKeys(){return this.request("/api/wallet/rotate",{method:"POST"})}};function re(l,n){return new Promise((i,a)=>{let p=window.screenX+(window.innerWidth-450)/2,b=window.screenY+(window.innerHeight-600)/2,u=window.open(`${l}/auth/popup?appId=${n}`,"accesly-auth",`width=450,height=600,left=${p},top=${b},toolbar=no,menubar=no`);if(!u){a(new Error("Failed to open popup. Please allow popups for this site."));return}function f(x){x.origin.includes(new URL(l).host)&&(x.data?.type==="accesly-auth-success"&&(d(),i(x.data.payload)),x.data?.type==="accesly-auth-error"&&(d(),a(new Error(x.data.error||"Authentication failed"))));}let C=setInterval(()=>{u.closed&&(d(),a(new Error("Authentication cancelled")));},500);function d(){window.removeEventListener("message",f),clearInterval(C);}window.addEventListener("message",f);})}var J=react.createContext(null),Ae="https://accesly.vercel.app";function Be({children:l,...n}){let i=n.baseUrl||Ae,a=react.useMemo(()=>new G(n.appId,i),[n.appId,i]),[p,b]=react.useState(null),[u,f]=react.useState(null),[C,d]=react.useState(true),[x,S]=react.useState(false),[w,m]=react.useState(null);react.useEffect(()=>{a.hasSession()?B():d(false);},[a]),react.useEffect(()=>{if(!p)return;P();let s=setInterval(P,15e3);return ()=>clearInterval(s)},[p]);async function B(){m(null);try{let s=await a.getWalletInfo();b(s.wallet),n.onConnect?.(s.wallet);}catch(s){if(s instanceof I&&s.status===404){await T();return}s instanceof I&&s.status===401&&(a.clearTokens(),b(null)),m(s.message);}finally{d(false);}}async function T(){S(true),m(null);try{await a.createWallet();let s=await a.getWalletInfo();b(s.wallet),n.onConnect?.(s.wallet);}catch(s){m(s.message);}finally{S(false),d(false);}}async function P(){try{let O=(await a.getBalance()).balances.find(K=>K.asset==="native");f(O?.balance||"0");}catch{}}let E=react.useCallback(async()=>{m(null);try{let s=await re(i,n.appId);a.setTokens(s),d(!0),await B();}catch(s){s.message!=="Authentication cancelled"&&m(s.message);}},[i,n.appId,a]),U=react.useCallback(()=>{a.clearTokens(),b(null),f(null),m(null),n.onDisconnect?.();},[a,n.onDisconnect]),R=react.useCallback(async s=>a.sendPayment(s),[a]),$=react.useCallback(async()=>a.rotateKeys(),[a]),L=react.useCallback(async(s=20)=>(await a.getTransactions(s)).transactions,[a]),H=react.useCallback(async()=>{await P();},[a]),V=react.useCallback(async()=>{await B();},[a]),z={loading:C,creating:x,wallet:p,balance:u,error:w,connect:E,disconnect:U,sendPayment:R,rotateKeys:$,getTransactions:L,refreshBalance:H,refreshWallet:V};return jsxRuntime.jsx(J.Provider,{value:z,children:l})}function D(){let l=react.useContext(J);if(!l)throw new Error('useAccesly must be used within an <AcceslyProvider>. Wrap your app with <AcceslyProvider appId="acc_xxxxx">.');return l}function ie({onClose:l,onConnect:n}){return jsxRuntime.jsx("div",{style:k.overlay,onClick:l,children:jsxRuntime.jsxs("div",{style:k.modal,onClick:i=>i.stopPropagation(),children:[jsxRuntime.jsx("button",{onClick:l,style:k.closeBtn,children:jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),jsxRuntime.jsx("div",{style:k.iconWrapper,children:jsxRuntime.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"#667eea",strokeWidth:"1.5",children:[jsxRuntime.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2.5"}),jsxRuntime.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]})}),jsxRuntime.jsx("h2",{style:k.title,children:"Connect to Accesly"}),jsxRuntime.jsx("p",{style:k.subtitle,children:"Choose how you want to connect"}),jsxRuntime.jsxs("button",{onClick:n,style:k.googleBtn,children:[jsxRuntime.jsxs("svg",{style:k.googleIcon,viewBox:"0 0 24 24",children:[jsxRuntime.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z",fill:"#4285F4"}),jsxRuntime.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),jsxRuntime.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z",fill:"#FBBC05"}),jsxRuntime.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]}),"Continue with Google"]}),jsxRuntime.jsx("p",{style:k.footer,children:"Powered by Accesly"})]})})}var k={overlay:{position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:99999,padding:"1rem",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},modal:{position:"relative",backgroundColor:"#141428",borderRadius:"20px",border:"1px solid #2a2a4a",padding:"2rem",width:"100%",maxWidth:"380px",textAlign:"center"},closeBtn:{position:"absolute",top:"1rem",right:"1rem",background:"none",border:"none",color:"#64748b",cursor:"pointer",padding:"4px"},iconWrapper:{width:"56px",height:"56px",borderRadius:"16px",backgroundColor:"rgba(102, 126, 234, 0.1)",border:"1px solid rgba(102, 126, 234, 0.2)",display:"flex",alignItems:"center",justifyContent:"center",margin:"0 auto 1rem"},title:{fontSize:"1.3rem",fontWeight:700,color:"#e2e8f0",margin:"0 0 0.25rem"},subtitle:{color:"#64748b",fontSize:"0.85rem",margin:"0 0 1.5rem"},googleBtn:{display:"flex",alignItems:"center",justifyContent:"center",gap:"0.75rem",padding:"0.85rem 1.5rem",backgroundColor:"#1a1a2e",color:"#e2e8f0",border:"1px solid #2a2a4a",borderRadius:"12px",fontSize:"0.95rem",fontWeight:500,cursor:"pointer",width:"100%",marginBottom:"1.25rem"},googleIcon:{width:"20px",height:"20px",flexShrink:0},footer:{color:"#475569",fontSize:"0.7rem",margin:0}};function le({onClose:l}){let{wallet:n,balance:i,disconnect:a,sendPayment:p,rotateKeys:b,getTransactions:u,refreshBalance:f,refreshWallet:C}=D(),[d,x]=react.useState("wallet"),[S,w]=react.useState("main"),[m,B]=react.useState(""),[T,P]=react.useState(""),[E,U]=react.useState(""),[R,$]=react.useState(false),[L,H]=react.useState(null),[V,z]=react.useState(null),[s,O]=react.useState([]),[K,Y]=react.useState(false),[N,Q]=react.useState(false),[Z,ee]=react.useState(null),[_,te]=react.useState(null);if(react.useEffect(()=>{d==="activity"&&s.length===0&&de();},[d]),!n)return null;async function de(){Y(true);try{let o=await u(20);O(o);}catch{}finally{Y(false);}}async function pe(){if(!(!m||!T)){$(true),z(null);try{let o=await p({destination:m,amount:T,memo:E||void 0});H(o.txHash),f();}catch(o){z(o.message);}finally{$(false);}}}function ue(){H(null),B(""),P(""),U(""),z(null),w("main");}async function ye(){if(confirm("This will generate a new keypair and update your contract. Continue?")){Q(true),ee(null);try{await b(),await C();}catch(o){ee(o.message);}finally{Q(false);}}}function fe(){a(),l();}function j(o,c=6,oe=6){return o.length<=c+oe+3?o:`${o.slice(0,c)}...${o.slice(-oe)}`}async function ne(o,c){await navigator.clipboard.writeText(o),te(c),setTimeout(()=>te(null),1500);}function me(o){let c=Math.floor((Date.now()-new Date(o).getTime())/1e3);return c<60?"just now":c<3600?`${Math.floor(c/60)}m ago`:c<86400?`${Math.floor(c/3600)}h ago`:c<172800?"yesterday":`${Math.floor(c/86400)}d ago`}let ge=i?parseFloat(i).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}):"---",he=Re(n.stellarAddress),be=[{key:"wallet",label:"Wallet"},{key:"activity",label:"Activity"},{key:"account",label:"Account"},{key:"security",label:"Security"}];return jsxRuntime.jsx("div",{style:e.overlay,onClick:l,children:jsxRuntime.jsxs("div",{style:e.panel,onClick:o=>o.stopPropagation(),children:[jsxRuntime.jsxs("div",{style:e.header,children:[jsxRuntime.jsx("button",{onClick:l,style:e.closeBtn,children:jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),jsxRuntime.jsx("div",{style:{...e.identicon,backgroundColor:he}}),jsxRuntime.jsx("p",{style:e.headerAddr,children:j(n.stellarAddress,8,8)}),jsxRuntime.jsxs("p",{style:e.headerBalance,children:[ge," ",jsxRuntime.jsx("span",{style:e.headerCurrency,children:"XLM"})]})]}),jsxRuntime.jsx("div",{style:e.tabBar,children:be.map(o=>jsxRuntime.jsx("button",{onClick:()=>{x(o.key),w("main");},style:{...e.tab,...d===o.key?e.tabActive:{}},children:o.label},o.key))}),jsxRuntime.jsxs("div",{style:e.content,children:[d==="wallet"&&xe(),d==="activity"&&ve(),d==="account"&&we(),d==="security"&&ke()]})]})});function xe(){return L?jsxRuntime.jsxs("div",{style:e.centeredCol,children:[jsxRuntime.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"#34d399",strokeWidth:"2",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10"}),jsxRuntime.jsx("polyline",{points:"8 12 11 15 16 9"})]}),jsxRuntime.jsx("p",{style:{color:"#34d399",fontWeight:600,margin:"0.5rem 0"},children:"Payment Sent"}),jsxRuntime.jsxs("p",{style:{color:"#64748b",fontSize:"0.75rem",fontFamily:"monospace"},children:[L.slice(0,12),"...",L.slice(-12)]}),jsxRuntime.jsx("button",{onClick:ue,style:e.primaryBtn,children:"Done"})]}):S==="send"?jsxRuntime.jsxs("div",{style:e.subView,children:[jsxRuntime.jsxs("button",{onClick:()=>w("main"),style:e.backBtn,children:[jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("polyline",{points:"15 18 9 12 15 6"})}),"Back"]}),jsxRuntime.jsxs("div",{style:e.formGroup,children:[jsxRuntime.jsx("label",{style:e.formLabel,children:"Destination"}),jsxRuntime.jsx("input",{type:"text",placeholder:"G...",value:m,onChange:o=>B(o.target.value),maxLength:56,style:e.formInput})]}),jsxRuntime.jsxs("div",{style:e.formGroup,children:[jsxRuntime.jsx("label",{style:e.formLabel,children:"Amount (XLM)"}),jsxRuntime.jsx("input",{type:"number",placeholder:"0.00",value:T,onChange:o=>P(o.target.value),min:"0.0000001",step:"any",style:e.formInput})]}),jsxRuntime.jsxs("div",{style:e.formGroup,children:[jsxRuntime.jsx("label",{style:e.formLabel,children:"Memo (optional)"}),jsxRuntime.jsx("input",{type:"text",placeholder:"What is this for?",value:E,onChange:o=>U(o.target.value),maxLength:28,style:e.formInput})]}),V&&jsxRuntime.jsx("p",{style:e.error,children:V}),jsxRuntime.jsx("button",{onClick:pe,disabled:R||!m||!T,style:{...e.primaryBtn,opacity:R||!m||!T?.5:1},children:R?"Sending...":"Send Payment"})]}):S==="receive"?jsxRuntime.jsxs("div",{style:e.subView,children:[jsxRuntime.jsxs("button",{onClick:()=>w("main"),style:e.backBtn,children:[jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("polyline",{points:"15 18 9 12 15 6"})}),"Back"]}),jsxRuntime.jsxs("div",{style:e.centeredCol,children:[jsxRuntime.jsx("div",{style:e.receiveIconBig,children:jsxRuntime.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"#34d399",strokeWidth:"2",children:[jsxRuntime.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsxRuntime.jsx("polyline",{points:"19 12 12 19 5 12"})]})}),jsxRuntime.jsx("p",{style:{color:"#e2e8f0",fontWeight:600,fontSize:"1rem",margin:0},children:"Receive XLM"}),jsxRuntime.jsx("p",{style:{color:"#64748b",fontSize:"0.8rem",margin:0,textAlign:"center"},children:"Share your Stellar address to receive payments"}),jsxRuntime.jsx("div",{style:e.addressBox,children:jsxRuntime.jsx("span",{style:e.addressText,children:n.stellarAddress})}),jsxRuntime.jsx("button",{onClick:()=>ne(n.stellarAddress,"receive"),style:e.primaryBtn,children:_==="receive"?"Copied!":"Copy Address"})]})]}):jsxRuntime.jsx("div",{style:e.walletTab,children:jsxRuntime.jsxs("div",{style:e.actionRow,children:[jsxRuntime.jsxs("button",{onClick:()=>w("send"),style:e.actionBtn,children:[jsxRuntime.jsx("div",{style:e.actionIcon,children:jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[jsxRuntime.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),jsxRuntime.jsx("polyline",{points:"5 12 12 5 19 12"})]})}),jsxRuntime.jsx("span",{style:e.actionLabel,children:"Send"})]}),jsxRuntime.jsxs("button",{onClick:()=>w("receive"),style:e.actionBtn,children:[jsxRuntime.jsx("div",{style:{...e.actionIcon,...e.actionIconReceive},children:jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[jsxRuntime.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsxRuntime.jsx("polyline",{points:"19 12 12 19 5 12"})]})}),jsxRuntime.jsx("span",{style:e.actionLabel,children:"Receive"})]})]})})}function ve(){return K&&s.length===0?jsxRuntime.jsx("p",{style:e.emptyText,children:"Loading transactions..."}):s.length===0?jsxRuntime.jsx("p",{style:e.emptyText,children:"No transactions yet"}):jsxRuntime.jsx("div",{style:e.txList,children:s.map(o=>jsxRuntime.jsxs("div",{style:e.txRow,children:[jsxRuntime.jsx("div",{style:{...e.txIcon,backgroundColor:o.type==="received"?"rgba(52, 211, 153, 0.15)":"rgba(248, 113, 113, 0.15)"},children:jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:o.type==="received"?"#34d399":"#f87171",strokeWidth:"2.5",children:o.type==="received"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsxRuntime.jsx("polyline",{points:"19 12 12 19 5 12"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),jsxRuntime.jsx("polyline",{points:"5 12 12 5 19 12"})]})})}),jsxRuntime.jsxs("div",{style:e.txDetails,children:[jsxRuntime.jsx("span",{style:e.txType,children:o.type==="received"?"Received":"Sent"}),jsxRuntime.jsxs("span",{style:e.txCounterparty,children:[o.type==="received"?"from ":"to ",j(o.counterparty)]})]}),jsxRuntime.jsxs("div",{style:e.txAmountCol,children:[jsxRuntime.jsxs("span",{style:{...e.txAmount,color:o.type==="received"?"#34d399":"#f87171"},children:[o.type==="received"?"+":"-",parseFloat(o.amount).toLocaleString("en-US",{maximumFractionDigits:2})," ",o.asset]}),jsxRuntime.jsx("span",{style:e.txTime,children:me(o.createdAt)})]})]},o.id))})}function we(){let o=[{label:"Email",value:n.email,key:"email"},{label:"Contract ID",value:n.contractId,key:"contract",copy:true},{label:"Stellar Address",value:n.stellarAddress,key:"stellar",copy:true},{label:"Public Key",value:n.publicKey,key:"pubkey",copy:true},{label:"Created",value:new Date(n.createdAt).toLocaleDateString(),key:"created"}];return jsxRuntime.jsx("div",{style:e.fieldList,children:o.map(c=>jsxRuntime.jsxs("div",{style:e.field,children:[jsxRuntime.jsx("span",{style:e.fieldLabel,children:c.label}),c.copy?jsxRuntime.jsx("button",{onClick:()=>ne(c.value,c.key),style:{...e.copyBtn,color:_===c.key?"#34d399":"#a5b4fc",borderColor:_===c.key?"#34d399":"#2a2a4a"},children:_===c.key?"Copied!":j(c.value,8,8)}):jsxRuntime.jsx("span",{style:e.fieldValue,children:c.value})]},c.key))})}function ke(){return jsxRuntime.jsxs("div",{style:e.securityTab,children:[jsxRuntime.jsxs("div",{style:e.fieldList,children:[jsxRuntime.jsxs("div",{style:e.field,children:[jsxRuntime.jsx("span",{style:e.fieldLabel,children:"Recovery"}),jsxRuntime.jsx("span",{style:{...e.fieldValue,color:"#34d399"},children:"Protected"})]}),jsxRuntime.jsxs("div",{style:e.field,children:[jsxRuntime.jsx("span",{style:e.fieldLabel,children:"Method"}),jsxRuntime.jsxs("span",{style:e.fieldValue,children:["Google (",n.email,")"]})]}),n.recoverySigners&&n.recoverySigners.length>0&&jsxRuntime.jsxs("div",{style:e.field,children:[jsxRuntime.jsx("span",{style:e.fieldLabel,children:"Signer"}),jsxRuntime.jsx("span",{style:e.fieldValue,children:j(n.recoverySigners[0].publicKey)})]})]}),Z&&jsxRuntime.jsx("p",{style:e.error,children:Z}),jsxRuntime.jsxs("button",{onClick:ye,disabled:N,style:{...e.rotateBtn,opacity:N?.5:1},children:[jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("path",{d:"M21 2v6h-6"}),jsxRuntime.jsx("path",{d:"M3 12a9 9 0 0 1 15-6.7L21 8"}),jsxRuntime.jsx("path",{d:"M3 22v-6h6"}),jsxRuntime.jsx("path",{d:"M21 12a9 9 0 0 1-15 6.7L3 16"})]}),N?"Rotating...":"Rotate Keys"]}),jsxRuntime.jsxs("button",{onClick:fe,style:e.disconnectBtn,children:[jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),jsxRuntime.jsx("polyline",{points:"16 17 21 12 16 7"}),jsxRuntime.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]}),"Disconnect"]})]})}}function Re(l){let n=0;for(let i=0;i<l.length;i++)n=l.charCodeAt(i)+((n<<5)-n);return `hsl(${Math.abs(n)%360}, 65%, 55%)`}var e={overlay:{position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:99999,padding:"1rem",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},panel:{backgroundColor:"#0f0f1e",borderRadius:"20px",border:"1px solid #2a2a4a",width:"100%",maxWidth:"420px",maxHeight:"85vh",display:"flex",flexDirection:"column",overflow:"hidden"},header:{position:"relative",display:"flex",flexDirection:"column",alignItems:"center",padding:"1.5rem 1.5rem 1rem",background:"linear-gradient(180deg, #1a1a3a 0%, #0f0f1e 100%)"},closeBtn:{position:"absolute",top:"1rem",right:"1rem",background:"none",border:"none",color:"#64748b",cursor:"pointer",padding:"4px"},identicon:{width:"48px",height:"48px",borderRadius:"50%",marginBottom:"0.5rem"},headerAddr:{fontFamily:"monospace",fontSize:"0.8rem",color:"#8b8ba7",margin:"0 0 0.25rem"},headerBalance:{fontSize:"1.75rem",fontWeight:700,color:"#ffffff",margin:0},headerCurrency:{fontSize:"0.85rem",fontWeight:500,color:"#8b8ba7"},tabBar:{display:"flex",borderBottom:"1px solid #2a2a4a",padding:"0 0.5rem"},tab:{flex:1,padding:"0.75rem 0.5rem",background:"none",border:"none",borderBottom:"2px solid transparent",color:"#64748b",fontSize:"0.8rem",fontWeight:500,cursor:"pointer",transition:"color 0.2s, border-color 0.2s",borderRadius:0},tabActive:{color:"#e2e8f0",borderBottomColor:"#667eea"},content:{flex:1,overflowY:"auto",padding:"1rem 1.25rem 1.25rem"},walletTab:{display:"flex",flexDirection:"column",gap:"1rem"},actionRow:{display:"flex",gap:"1rem",justifyContent:"center"},actionBtn:{display:"flex",flexDirection:"column",alignItems:"center",gap:"0.5rem",padding:"1.25rem 1.5rem",backgroundColor:"#1a1a2e",border:"1px solid #2a2a4a",borderRadius:"16px",cursor:"pointer",transition:"border-color 0.2s",flex:1},actionIcon:{width:"44px",height:"44px",borderRadius:"50%",backgroundColor:"rgba(102, 126, 234, 0.15)",display:"flex",alignItems:"center",justifyContent:"center",color:"#667eea"},actionIconReceive:{backgroundColor:"rgba(52, 211, 153, 0.15)",color:"#34d399"},actionLabel:{fontSize:"0.85rem",fontWeight:500,color:"#e2e8f0"},subView:{display:"flex",flexDirection:"column",gap:"0.75rem"},backBtn:{display:"flex",alignItems:"center",gap:"0.25rem",background:"none",border:"none",color:"#8b8ba7",fontSize:"0.8rem",cursor:"pointer",padding:"0 0 0.25rem",width:"fit-content"},formGroup:{display:"flex",flexDirection:"column",gap:"0.3rem"},formLabel:{color:"#8b8ba7",fontSize:"0.75rem",fontWeight:500},formInput:{backgroundColor:"#1a1a2e",border:"1px solid #2a2a4a",borderRadius:"8px",padding:"0.65rem 0.75rem",color:"#e2e8f0",fontSize:"0.9rem",outline:"none",width:"100%",boxSizing:"border-box",fontFamily:"inherit"},primaryBtn:{backgroundColor:"#667eea",color:"#fff",border:"none",borderRadius:"10px",padding:"0.75rem",fontSize:"0.95rem",fontWeight:600,cursor:"pointer",width:"100%",marginTop:"0.25rem"},error:{color:"#f87171",fontSize:"0.8rem",margin:0,padding:"0.4rem 0.6rem",backgroundColor:"rgba(248, 113, 113, 0.1)",borderRadius:"6px"},centeredCol:{display:"flex",flexDirection:"column",alignItems:"center",gap:"0.5rem",padding:"1rem 0"},receiveIconBig:{width:"64px",height:"64px",borderRadius:"50%",backgroundColor:"rgba(52, 211, 153, 0.15)",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"0.25rem"},addressBox:{backgroundColor:"#1a1a2e",border:"1px solid #2a2a4a",borderRadius:"8px",padding:"0.75rem",width:"100%",marginTop:"0.5rem"},addressText:{fontFamily:"monospace",fontSize:"0.7rem",color:"#a5b4fc",wordBreak:"break-all",lineHeight:1.5},txList:{display:"flex",flexDirection:"column"},txRow:{display:"flex",alignItems:"center",gap:"0.75rem",padding:"0.65rem 0",borderBottom:"1px solid #1a1a2e"},txIcon:{width:"36px",height:"36px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},txDetails:{display:"flex",flexDirection:"column",flex:1,minWidth:0},txType:{color:"#e2e8f0",fontSize:"0.85rem",fontWeight:500},txCounterparty:{color:"#64748b",fontSize:"0.7rem",fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},txAmountCol:{display:"flex",flexDirection:"column",alignItems:"flex-end",flexShrink:0},txAmount:{fontSize:"0.85rem",fontWeight:600},txTime:{color:"#64748b",fontSize:"0.65rem"},emptyText:{color:"#64748b",fontSize:"0.85rem",textAlign:"center",padding:"2rem 0"},fieldList:{display:"flex",flexDirection:"column"},field:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0.6rem 0",borderBottom:"1px solid #1a1a2e"},fieldLabel:{color:"#8b8ba7",fontSize:"0.8rem"},fieldValue:{color:"#e2e8f0",fontSize:"0.8rem",fontWeight:500},copyBtn:{background:"none",border:"1px solid #2a2a4a",color:"#a5b4fc",padding:"0.2rem 0.5rem",borderRadius:"4px",fontSize:"0.72rem",fontFamily:"monospace",cursor:"pointer",transition:"color 0.2s, border-color 0.2s"},securityTab:{display:"flex",flexDirection:"column",gap:"1rem"},rotateBtn:{display:"flex",alignItems:"center",justifyContent:"center",gap:"0.5rem",width:"100%",padding:"0.65rem",backgroundColor:"transparent",color:"#f59e0b",border:"1px solid rgba(245, 158, 11, 0.3)",borderRadius:"10px",fontSize:"0.85rem",fontWeight:600,cursor:"pointer"},disconnectBtn:{display:"flex",alignItems:"center",justifyContent:"center",gap:"0.5rem",width:"100%",padding:"0.65rem",backgroundColor:"transparent",color:"#f87171",border:"1px solid rgba(248, 113, 113, 0.2)",borderRadius:"10px",fontSize:"0.85rem",fontWeight:500,cursor:"pointer"}};function Le(){let{wallet:l,balance:n,loading:i,creating:a,connect:p}=D(),[b,u]=react.useState(false),[f,C]=react.useState(false);if(i)return jsxRuntime.jsx("div",{style:v.pillLoading,children:jsxRuntime.jsx("div",{style:v.spinner})});if(!l)return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{onClick:()=>u(true),style:a?v.pill:v.connectBtn,disabled:a,children:a?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:v.spinnerSmall}),jsxRuntime.jsx("span",{style:v.pillText,children:"Creating wallet..."})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2.5"}),jsxRuntime.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),"Connect Wallet"]})}),b&&jsxRuntime.jsx(ie,{onClose:()=>u(false),onConnect:async()=>{u(false),await p();}})]});let d=l.stellarAddress,x=`${d.slice(0,4)}...${d.slice(-4)}`,S=n?`${parseFloat(n).toFixed(2)} XLM`:"--- XLM",w=ze(d);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("button",{onClick:()=>C(true),style:v.pill,children:[jsxRuntime.jsx("div",{style:{...v.identicon,backgroundColor:w}}),jsxRuntime.jsx("span",{style:v.pillAddr,children:x}),jsxRuntime.jsx("span",{style:v.divider}),jsxRuntime.jsx("span",{style:v.pillBalance,children:S})]}),f&&jsxRuntime.jsx(le,{onClose:()=>C(false)})]})}function ze(l){let n=0;for(let i=0;i<l.length;i++)n=l.charCodeAt(i)+((n<<5)-n);return `hsl(${Math.abs(n)%360}, 65%, 55%)`}var v={connectBtn:{display:"flex",alignItems:"center",gap:"0.6rem",padding:"0.85rem 1.75rem",background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",color:"#fff",border:"none",borderRadius:"12px",fontSize:"1rem",fontWeight:600,cursor:"pointer",transition:"transform 0.15s, box-shadow 0.15s",boxShadow:"0 4px 15px rgba(102, 126, 234, 0.4)",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},pill:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.5rem 0.85rem",backgroundColor:"#1a1a2e",border:"1px solid #2a2a4a",borderRadius:"50px",cursor:"pointer",transition:"border-color 0.2s, box-shadow 0.2s",color:"#e2e8f0",fontSize:"0.85rem",fontWeight:500,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},pillLoading:{display:"flex",alignItems:"center",justifyContent:"center",padding:"0.5rem 1.5rem",backgroundColor:"#1a1a2e",border:"1px solid #2a2a4a",borderRadius:"50px",height:"42px"},identicon:{width:"24px",height:"24px",borderRadius:"50%",flexShrink:0},pillAddr:{fontFamily:"monospace",fontSize:"0.8rem",color:"#e2e8f0"},divider:{width:"1px",height:"16px",backgroundColor:"#3a3a5a"},pillBalance:{fontSize:"0.8rem",color:"#8b8ba7",fontWeight:500},pillText:{fontSize:"0.8rem",color:"#8b8ba7"},spinner:{width:"20px",height:"20px",border:"2px solid #2a2a4a",borderTop:"2px solid #667eea",borderRadius:"50%",animation:"accesly-spin 1s linear infinite"},spinnerSmall:{width:"16px",height:"16px",border:"2px solid #2a2a4a",borderTop:"2px solid #667eea",borderRadius:"50%",animation:"accesly-spin 1s linear infinite",flexShrink:0}};if(typeof document<"u"){let l="accesly-keyframes";if(!document.getElementById(l)){let n=document.createElement("style");n.id=l,n.textContent=`
|
|
2
2
|
@keyframes accesly-spin {
|
|
3
3
|
to { transform: rotate(360deg); }
|
|
4
4
|
}
|
|
5
|
-
`,document.head.appendChild(
|
|
5
|
+
`,document.head.appendChild(n);}}exports.AcceslyProvider=Be;exports.ConnectButton=Le;exports.useAccesly=D;//# sourceMappingURL=index.js.map
|
|
6
6
|
//# sourceMappingURL=index.js.map
|