PageSourceSearch

https://woxpas.ai/_next/static/chunks/pages/connect-145096a082a89b73.js

js woxpas.ai collected 2026-10-05 16:00:04 UTC 10,311 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7784],{9507:function(e,t,s){(window.__NEXT_P=window.__NEXT_P||[]).push(["/connect",function(){return s(4450)}])},4450:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return h}});var n=s(2322),r=s(2784),a=s(5632),o=s(7729),l=s.n(o),c=s(6993);let i=()=>(0,n.jsx)("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})}),d=()=>(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),u=()=>(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),x=()=>(0,n.jsx)("svg",{className:"w-4 h-4 text-accent",viewBox:"0 0 20 20",fill:"currentColor",children:(0,n.jsx)("path",{fillRule:"evenodd",d:"M6.267 3.455a3.066 3.066 0 001.745-.723 3.066 3.066 0 013.976 0 3.066 3.066 0 001.745.723 3.066 3.066 0 012.812 2.812c.051.643.304 1.254.723 1.745a3.066 3.066 0 010 3.976 3.066 3.066 0 00-.723 1.745 3.066 3.066 0 01-2.812 2.812 3.066 3.066 0 00-1.745.723 3.066 3.066 0 01-3.976 0 3.066 3.066 0 00-1.745-.723 3.066 3.066 0 01-2.812-2.812 3.066 3.066 0 00-.723-1.745 3.066 3.066 0 010-3.976 3.066 3.066 0 00.723-1.745 3.066 3.066 0 012.812-2.812zm7.44 5.252a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})});function h(){var e,t;let s=(0,a.useRouter)(),o=(0,c.getApiBaseUrl)(),[h,m]=(0,r.useState)(!1),[f,p]=(0,r.useState)(!0),[b,j]=(0,r.useState)([]),[v,g]=(0,r.useState)(""),[w,y]=(0,r.useState)(null),[N,k]=(0,r.useState)(null),[_,C]=(0,r.useState)(!0),[S,T]=(0,r.useState)(!1),[E,R]=(0,r.useState)(null),{auth_request_id:F,client_id:L,client_name:A,scope:M,redirect_uri:U}=s.query;(0,r.useEffect)(()=>{if(!s.isReady)return;let e=(0,c.hasActiveSession)();if(m(e),p(!1),!e){let e=encodeURIComponent(window.location.href);s.push("/login?redirect=".concat(e))}},[s.isReady,s]),(0,r.useEffect)(()=>{(async()=>{if(L)try{let e=await fetch("".concat(o,"/v1/oauth/clients/").concat(encodeURIComponent(L)));if(e.ok){let t=await e.json();y(t)}}catch(e){console.error("Error fetching client info:",e)}})()},[L,o]),(0,r.useEffect)(()=>{let e=async()=>{if(h)try{var e,t;let[s,n]=await Promise.all([(0,c.authFetch)("".concat(o,"/v1/vaults")),(0,c.authFetch)("".concat(o,"/v1/auth/session"))]);if(!s.ok)throw Error("Failed to fetch vaults");let r=await s.json();j(r.vaults||[]);let a=(null===(e=r.vaults)||void 0===e?void 0:e.find(e=>e.is_default))||(null===(t=r.vaults)||void 0===t?void 0:t[0]);if(a&&g(a.vault_id),n.ok){let e=await n.json();k(e.user||null)}}catch(e){console.error("Error fetching data:",e),R("Failed to load your vaults")}finally{C(!1)}};h&&e()},[h,o]);let B=F&&L&&U,O=async()=>{if(v&&F){T(!0),R(null);try{let t=await (0,c.authFetch)("".concat(o,"/v1/oauth/approve"),{method:"POST",headers:{"Content-Type":"application/json","X-CSRF-Token":(0,c.getCsrfToken)()},body:JSON.stringify({auth_request_id:F,vault_id:v})});if(!t.ok){var e;let s=await t.json().catch(()=>({}));throw Error((null===(e=s.error)||void 0===e?void 0:e.message)||"Failed to approve connection")}let s=await t.json();window.location.href=s.callback_url}catch(e){console.error("Error approving connection:",e),R(e instanceof Error?e.message:"Failed to approve connection"),T(!1)}}},P=async()=>{try{let e=(0,c.getCsrfToken)(),t={"Content-Type":"application/json"};e&&(t["X-CSRF-Token"]=e),await fetch("".concat(o,"/v1/auth/logout-with-cookie"),{method:"POST",credentials:"include",headers:t})}catch(e){}"undefined"!=typeof document&&(document.cookie="csrf_token=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT",document.cookie="csrf_token=; path=/; domain=.woxpas.ai; expires=Thu, 01 Jan 1970 00:00:00 GMT");let e=encodeURIComponent(window.location.href);window.location.href="/login?redirect=".concat(e)}
1,W=(M||"read write").split(" ").filter(Boolean),q=(null==w?void 0:w.client_name)||A||L||"Unknown App",I=null!==(t=null==w?void 0:w.is_verified)&&void 0!==t&&t;return f||_?(0,n.jsx)("div",{className:"min-h-screen bg-bg flex items-center justify-center",children:(0,n.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-accent"})}):B?(0,n.jsxs)("div",{className:"min-h-screen bg-bg flex items-center justify-center p-4",children:[(0,n.jsx)(l(),{children:(0,n.jsx)("title",{children:"Connect to Woxpas"})}),(0,n.jsxs)("div",{className:"max-w-md w-full bg-surface border border-border rounded-xl overflow-hidden",children:[(0,n.jsxs)("div",{className:"bg-gradient-to-r from-accent/10 to-accent/5 px-6 py-8 text-center border-b border-border",children:[(null==w?void 0:w.logo_url)?(0,n.jsx)("img",{src:w.logo_url,alt:q,className:"w-16 h-16 rounded-full mx-auto mb-4 object-cover"}):(0,n.jsx)("div",{className:"w-16 h-16 rounded-full bg-accent/10 flex items-center justify-center mx-auto mb-4 text-accent",children:(0,n.jsx)(i,{})}),(0,n.jsx)("h1",{className:"text-xl font-semibold text-text mb-2",children:"Connect to Woxpas"}),(0,n.jsxs)("p",{className:"text-text-secondary flex items-center justify-center gap-1.5",children:[(0,n.jsx)("span",{className:"font-medium text-text",children:q}),I&&(0,n.jsx)(x,{})," ","wants to access your memories"]}),(null==w?void 0:w.description)&&(0,n.jsx)("p",{className:"text-xs text-text-tertiary mt-2",children:w.description})]}),(0,n.jsxs)("div",{className:"px-6 py-6 space-y-6",children:[N&&(0,n.jsx)("div",{className:"p-3 bg-accent/5 border border-accent/20 rounded-lg",children:(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsxs)("p",{className:"text-sm text-text-secondary",children:["Connecting as"," ",(0,n.jsx)("span",{className:"font-medium text-text",children:N.name||N.email}),N.name&&N.email&&(0,n.jsxs)("span",{className:"text-text-tertiary",children:[" (",N.email,")"]})]}),(0,n.jsx)("button",{onClick:P,className:"text-xs text-accent hover:text-accent/80 transition-colors whitespace-nowrap ml-3",children:"Switch"})]})}),E&&(0,n.jsx)("div",{className:"p-3 bg-error/10 border border-error/20 rounded-lg text-error text-sm",children:E}),(0,n.jsxs)("div",{children:[(0,n.jsx)("h3",{className:"text-sm font-medium text-text mb-3",children:"This will allow access to:"}),(0,n.jsxs)("ul",{className:"space-y-2",children:[W.includes("read")&&(0,n.jsxs)("li",{className:"flex items-center gap-3 text-sm text-text-secondary",children:[(0,n.jsx)("div",{className:"w-5 h-5 rounded-full bg-success/10 flex items-center justify-center text-success flex-shrink-0",children:(0,n.jsx)(d,{})}),(0,n.jsx)("span",{children:"Search and read your saved memories"})]}),W.includes("write")&&(0,n.jsxs)("li",{className:"flex items-center gap-3 text-sm text-text-secondary",children:[(0,n.jsx)("div",{className:"w-5 h-5 rounded-full bg-success/10 flex items-center justify-center text-success flex-shrink-0",children:(0,n.jsx)(d,{})}),(0,n.jsx)("span",{children:"Save new memories to your vault"})]})]})]}),b.length>1&&(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"block text-sm font-medium text-text mb-2",children:"Select Vault"}),(0,n.jsx)("select",{value:v,onChange:e=>g(e.target.value),className:"w-full px-3 py-2 bg-bg border border-border rounded-lg text-text focus:outline-none focus:ring-2 focus:ring-accent/50",children:b.map(e=>(0,n.jsxs)("option",{value:e.vault_id,children:[e.name||"Unnamed Vault",e.is_default?" (Default)":""]},e.vault_id))}),(0,n.jsx)("p",{className:"text-xs text-text-tertiary mt-1",children:"Only this vault will be accessible"})]}),1===b.length&&(0,n.jsx)("div",{className:"p-3 bg-bg rounded-lg",children:(0,n.jsxs)("p",{className:"text-sm text-text-secondary",children:["Vault: ",(0,n.jsx)("span",{className:"font-medium text-text",children:(null===(e=b[0])||void 0===e?void 0:e.name)||"Your Vault"})]})})]}),(0,n.jsxs)("div",{className:"px-6 py-4 bg-bg/50 border-t border-border flex gap-3",children:[(0,n.jsx)("button",{onClick:()=>{if(!U||!F){s.push("/app");return}let e=new URLSearchParams({auth_request_id:F,approved:"false"});window.location.href="".concat(U,"?").concat(e.toString())},disabled:S,className:"flex-1 px-4 py-2.5 text-sm font-medium bg-surface border border-border rounded-lg hover:bg-bg transition-colors text-text disabled:opacity-50",children:"Deny"}),(0,n.jsx)("button",{onClick:O,disabled:S||!v,className:"flex-1 px-4 py-2.5 text-sm font-medium bg-accent text-white rounded-lg hover:bg-accent/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2",children:S?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),"Connecting..."]}):"Allow Access"})]}),(0,n.jsx)("div",{className:"px-6 py-3 border-t border-border",children:(0,n.jsx)("p",{className:"text-xs text-text-tertiary text-center",children:"You can revoke this connection anytime in Settings → Developer"})})]})]}):(0,n.jsxs)("div",{className:"min-h-screen bg-bg flex items-center justify-center p-4",children:[(0,n.jsx)(l(),{children:(0,n.jsx)("title",{children:"Invalid Request - Woxpas"})}),(0,n.jsxs)("div",{className:"max-w-md w-full bg-surface border border-border rounded-xl p-6 text-center",children:[(0,n.jsx)("div",{className:"w-16 h-16 rounded-full bg-error/10 flex items-center justify-center mx-auto mb-4",children:(0,n.jsx)(u,{})}),(0,n.jsx)("h1",{className:"text-xl font-semibold text-text mb-2",children:"Invalid Request"}),(0,n.jsx)("p",{className:"text-text-secondary mb-6",children:"This authorization request is missing required parameters or has expired."}),(0,n.jsx)("button",{onClick:()=>s.push("/app"),className:"px-4 py-2 bg-accent text-white rounded-lg hover:bg-accent/90 transition-colors",children:"Go to Dashboard"})]})]})}}
1,7729:function(e,t,s){e.exports=s(8792)}},function(e){e.O(0,[2888,9774,179],function(){return e(e.s=9507)}),_N_E=e.O()}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.