PageSourceSearch

https://app.knovya.com/assets/OAuthConsentPage-3t9jRylD.js

js knovya.com collected 2026-10-07 18:56:28 UTC 6,563 bytes, 6 lines download raw bytes

1import{v as P,a as T,g as A,b as B,h as x,r as n,j as e,as as U,C as E,at as L,U as R,au as z,av as M,aw as H,ax as O,ay as W,az as $,aA as F,aB as D,W as G}from"./index-XUakxwH1.js";import{M as V}from"./site-Do5hMfh1.js";import{A as h,I as g,P as J}from"./IconContainer-MjNzoas7.js";import{B as u}from"./BrandHeader-yndrLY_R.js";import{G as K}from"./GhostBtn-ofWNK39Z.js";import{A as Z}from"./AnimatedCheck-D8DM2JR3.js";import{E as q}from"./ErrorBanner-DJVlgWry.js";import{U as Q}from"./upload-KWEehRoW.js";/**
2 * @license lucide-react v0.488.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const X=[["path",{d:"m15 5 6.3 6.3a2.4 2.4 0 0 1 0 3.4L17 19",key:"1cbfv1"}],["path",{d:"M9.586 5.586A2 2 0 0 0 8.172 5H3a1 1 0 0 0-1 1v5.172a2 2 0 0 0 .586 1.414L8.29 18.29a2.426 2.426 0 0 0 3.42 0l3.58-3.58a2.426 2.426 0 0 0 0-3.42z",key:"135mg7"}],["circle",{cx:"6.5",cy:"9.5",r:".5",fill:"currentColor",key:"5pm5xn"}]],Y=P("tags",X),ee=`${V}/oauth/authorize`,te="/api/v1",f={"notes:read":"consentScopeNotesRead","notes:write":"consentScopeNotesWrite","notes:export":"consentScopeNotesExport","folders:read":"consentScopeFoldersRead","folders:write":"consentScopeFoldersWrite","attachments:read":"consentScopeAttachmentsRead","attachments:write":"consentScopeAttachmentsWrite","tags:read":"consentScopeTagsRead","tags:write":"consentScopeTagsWrite","share:read":"consentScopeShareRead","share:write":"consentScopeShareWrite","versions:read":"consentScopeVersionsRead"},ae={"notes:read":D,"notes:write":F,"notes:export":$,"folders:read":W,"folders:write":O,"attachments:read":H,"attachments:write":Q,"tags:read":M,"tags:write":Y,"share:read":z,"share:write":R,"versions:read":L};function he(){const{t:a}=T("auth"),[r]=A(),m=B(),j=x(t=>t.user),i=x(t=>t.token),[k,p]=n.useState(!1),[_,l]=n.useState(""),[S,v]=n.useState(!1),[o,N]=n.useState(j);n.useEffect(()=>{o||!i||fetch(`${te}/users/me`,{headers:{Authorization:`Bearer ${i}`}}).then(t=>t.ok?t.json():null).then(t=>{t&&N({name:t.name,email:t.email,avatar_url:t.avatar_url})}).catch(()=>{})},[i,o]);const s=n.useMemo(()=>({clientId:r.get("client_id")||"",redirectUri:r.get("redirect_uri")||"",scope:r.get("scope")||"notes:read notes:write folders:read folders:write",state:r.get("state")||"",codeChallenge:r.get("code_challenge")||"",codeChallengeMethod:r.get("code_challenge_method")||"S256",responseType:r.get("response_type")||"code",resource:r.get("resource")||""}),[r]),y=n.useMemo(()=>s.scope.split(/\s+/).filter(Boolean),[s.scope]),d=r.get("client_name")||"MCP Client",C=!!s.codeChallenge&&s.responseType==="code";if(!i){const t=`/oauth/consent?${r.toString()}`;return e.jsx(U,{to:`/login?returnTo=${encodeURIComponent(t)}`,replace:!0})}const b=n.useCallback(async()=>{p(!0),l("");try{const t=await fetch(ee,{method:"POST",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json"},body:JSON.stringify({client_id:s.clientId,redirect_uri:s.redirectUri,scope:s.scope,state:s.state,code_challenge:s.codeChallenge,code_challenge_method:s.codeChallengeMethod,resource:s.resource})}),c=await t.json();if(!t.ok){l(c.error_description||c.error||a("consentError"));return}if(c.redirect_url){v(!0),window.location.href=c.redirect_url;return}l(a("consentError"))}catch{l(a("consentError"))}finally{p(!1)}},[i,s,a]),w=n.useCallback(()=>{if(s.redirectUri){const t=new URLSearchParams({error:"access_denied"});s.state&&t.set("state",s.state),window.location.href=`${s.redirectUri}?${t.toString()}`}else m("/notes")},[s.redirectUri,s.state,m]);if(S)return e.jsx(h,{children:e.jsxs("div",{className:"kn-fadeIn",style:{textAlign:"center"},"data-testid":"auth-oauth-success-screen",children:[e.jsx(u,{size:32,smallWordmark:!0}),e.jsx(g,{variant:"success",children:e.jsx(Z,{size:24,color:"var(--brand)"})}),e.jsx("h1",{className:"kn-auth__title",children:a("oauthSuccessTitle")}),e.jsx("p",{className:"kn-auth__sub",dangerouslySetInnerHTML:{__html:a("oauthSuccessRedirect",{clientName:d})}})]})});if(!C)return e.jsx(h,{children:e.jsxs("div",{className:"kn-fadeIn","data-testid":"auth-oauth-error-screen",children:[e.jsx(u,{size:32,smallWordmark:!0}),e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx(g,{variant:"danger",children:e.jsx(E,{size:26})}),e.jsx("h1",{className:"kn-auth__title",children:a("oauthErrorBadParamsTitle")}),e.jsx("p",{className:"kn-auth__sub",style:{marginBottom:16},dangerouslySetInnerHTML:{__html:a("oauthErrorBadParamsBody")}}),e.jsx("p",{className:"kn-auth__sub kn-auth__sub--small",dangerouslySetInnerHTML:{__html:a("oauthErrorBadParamsHint",{clientName:d})}})]})]})});const I=(o?.name||o?.email||"K")[0].toUpperCase();return e.jsx(h,{wide:!0,children:e.jsxs("div",{className:"kn-fadeIn","data-testid":"auth-oauth-form-screen",children:[e.jsx(u,{size:32,title:a("oauthFormTitle"),sub:e.jsx("span",{dangerouslySetInnerHTML:{__html:a("oauthFormSub",{clientName:d})}})}),e.jsxs("div",{className:"kn-oauth-card","data-testid":"auth-oauth-user-card",children:[e.jsx("div",{className:"kn-oauth-card__label",children:a("oauthUserCardLabel")}),e.jsxs("div",{className:"kn-oauth-user",children:[o?.avatar_url?e.jsx("img",{src:o.avatar_url,alt:"",style:{width:36,height:36,borderRadius:"var(--r-card)",objectFit:"cover"}}):e.jsx("div",{className:"kn-oauth-avatar",children:I}),e.jsxs("div",{className:"kn-oauth-user__info",children:[o?.name&&e.jsx("div",{className:"kn-oauth-user__name",children:o.name}),e.jsx("div",{className:"kn-oauth-user__email",children:o?.email||"…"})]})]})]}),e.jsxs("div",{className:"kn-oauth-card","data-testid":"auth-oauth-scopes-card",children:[e.jsx("div",{className:"kn-oauth-card__label",children:a("oauthScopesLabel")}),e.jsx("p",{className:"kn-oauth-permissions__intro",dangerouslySetInnerHTML:{__html:a("oauthScopesIntro",{clientName:d})}}),y.map(t=>{const c=ae[t];return e.jsxs("div",{className:"kn-oauth-scope","data-testid":`auth-oauth-scope-${t.replace(":","-")}`,children:[e.jsx(G,{size:15,strokeWidth:2.5,className:"kn-oauth-scope__check"}),c&&e.jsx(c,{size:14,className:"kn-oauth-scope__icon"}),e.jsx("span",{className:"kn-oauth-scope__label",children:f[t]?a(f[t]):t})]},t)})]}),_&&e.jsx(q,{message:_,testId:"auth-oauth-error-banner"}),e.jsx(J,{label:a("oauthAuthorizeBtn"),onClick:b,loading:k,testId:"auth-oauth-authorize-btn"}),e.jsx("div",{style:{marginTop:10,display:"flex"},children:e.jsx(K,{label:a("oauthDenyBtn"),onClick:w,testId:"auth-oauth-deny-btn"})}),e.jsx("p",{className:"kn-oauth-hint",children:a("oauthRevokeHint")})]})})}export{he as default};

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.