@undefineds.co/xpod 0.4.25 → 0.4.27
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/api/ApiServer.d.ts +1 -0
- package/dist/api/ApiServer.js +38 -0
- package/dist/api/ai-config/AiConfigStore.js +18 -6
- package/dist/api/ai-gateway/connect/index.d.ts +1 -0
- package/dist/api/ai-gateway/connect/index.js +39 -18
- package/dist/api/ai-gateway/models/ProviderModelsAdapter.js +5 -2
- package/dist/api/container/common.js +8 -2
- package/dist/api/container/index.js +2 -2
- package/dist/api/container/local.js +6 -3
- package/dist/api/handlers/AiGatewayHandler.d.ts +1 -0
- package/dist/api/handlers/AiGatewayHandler.js +53 -3
- package/dist/api/handlers/AiGatewayManagementHandler.js +9 -0
- package/dist/api/handlers/TaskHandler.js +15 -10
- package/dist/api/network/NetworkEnvironmentConfigurationStore.js +1 -1
- package/dist/api/runs/ManagedRunWorker.d.ts +0 -1
- package/dist/api/runs/ManagedRunWorker.js +2 -14
- package/dist/api/runs/PiAgentRuntimeDriver.d.ts +0 -8
- package/dist/api/runs/PiAgentRuntimeDriver.js +65 -21
- package/dist/api/runs/RunStateCenter.js +1 -0
- package/dist/api/runs/store.d.ts +1 -0
- package/dist/api/runs/store.js +13 -0
- package/dist/api/tasks/TaskMaterializer.js +13 -6
- package/dist/api/tasks/TaskResumeDiagnostics.d.ts +28 -0
- package/dist/api/tasks/TaskResumeDiagnostics.js +148 -0
- package/dist/api/tasks/TaskService.js +40 -23
- package/dist/storage/conditions/StorageETagHandler.d.ts +1 -1
- package/dist/storage/conditions/StorageETagHandler.js +13 -4
- package/dist/util/task-model-diagnostics.d.ts +67 -0
- package/dist/util/task-model-diagnostics.js +118 -0
- package/node_modules/@undefineds.co/ai-connections/dist/AiApiKeyPool.d.ts +1 -0
- package/node_modules/@undefineds.co/ai-connections/dist/AiApiKeyPool.js +2 -1
- package/node_modules/@undefineds.co/ai-connections/dist/AiConnectDialog.d.ts +1 -0
- package/node_modules/@undefineds.co/ai-connections/dist/AiCredentialPoolSection.d.ts +1 -0
- package/node_modules/@undefineds.co/ai-connections/dist/AiCredentialPoolSection.js +10 -10
- package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayKeyRow.d.ts +3 -1
- package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayKeyRow.js +2 -2
- package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayKeysSection.js +77 -23
- package/node_modules/@undefineds.co/ai-connections/dist/AiProviderCard.d.ts +1 -0
- package/node_modules/@undefineds.co/ai-connections/dist/AiSortableCredentialList.js +59 -59
- package/node_modules/@undefineds.co/ai-connections/dist/collection-runtime.js +2 -0
- package/node_modules/@undefineds.co/ai-connections/dist/collections.js +14 -6
- package/node_modules/@undefineds.co/ai-connections/dist/contract/ai-connections-client.d.ts +2 -1
- package/node_modules/@undefineds.co/ai-connections/dist/contract/ai-connections-client.js +1 -0
- package/node_modules/@undefineds.co/ai-connections/dist/contract/client/gateway-model-roles.d.ts +11 -0
- package/node_modules/@undefineds.co/ai-connections/dist/contract/client/gateway-model-roles.js +11 -0
- package/node_modules/@undefineds.co/ai-connections/dist/contract/client/normalize.d.ts +2 -1
- package/node_modules/@undefineds.co/ai-connections/dist/contract/client/normalize.js +12 -5
- package/node_modules/@undefineds.co/ai-connections/dist/contract/client/request.js +10 -2
- package/node_modules/@undefineds.co/ai-connections/dist/contract/client/types.d.ts +10 -0
- package/node_modules/@undefineds.co/ai-connections/package.json +1 -1
- package/node_modules/@undefineds.co/extension-sdk/dist/web.d.ts +1 -0
- package/node_modules/@undefineds.co/extension-sdk/package.json +1 -1
- package/node_modules/@undefineds.co/pod-collections/dist/index.cjs +60 -13
- package/node_modules/@undefineds.co/pod-collections/dist/mapping.d.ts +16 -1
- package/node_modules/@undefineds.co/pod-collections/dist/mapping.js +51 -0
- package/node_modules/@undefineds.co/pod-collections/dist/mutations.js +14 -18
- package/node_modules/@undefineds.co/pod-collections/package.json +1 -1
- package/node_modules/@undefineds.co/shared-ui/dist/list.d.ts +8 -1
- package/node_modules/@undefineds.co/shared-ui/dist/list.js +4 -1
- package/node_modules/@undefineds.co/shared-ui/dist/pod-sign-in/IdpChrome.d.ts +1 -1
- package/node_modules/@undefineds.co/shared-ui/dist/pod-sign-in/IdpChrome.js +2 -2
- package/node_modules/@undefineds.co/shared-ui/dist/pod-sign-in/IdpViews.js +2 -2
- package/node_modules/@undefineds.co/shared-ui/dist/pod-sign-in/PodSignInFrame.d.ts +3 -3
- package/node_modules/@undefineds.co/shared-ui/dist/pod-sign-in/PodSignInFrame.js +5 -5
- package/node_modules/@undefineds.co/shared-ui/dist/pod-sign-in/parts.d.ts +5 -5
- package/node_modules/@undefineds.co/shared-ui/dist/pod-sign-in/parts.js +5 -5
- package/node_modules/@undefineds.co/shared-ui/dist/section-header.js +1 -1
- package/node_modules/@undefineds.co/shared-ui/dist/theme.css +5 -32
- package/node_modules/@undefineds.co/shared-ui/package.json +1 -1
- package/node_modules/@undefineds.co/solid-sdk/package.json +1 -1
- package/package.json +2 -2
- package/static/app/assets/main.css +1 -1
- package/static/app/assets/main.js +1 -1
- package/static/dashboard/assets/AccountAuthBoundary-Dv52SZc6.js +1 -0
- package/static/dashboard/assets/DesktopOidcCallback-DaT_Rumf.js +1 -0
- package/static/dashboard/assets/DevicePages-HjclpIVm.js +2 -0
- package/static/dashboard/assets/ModelsPage-Be2TPd-x.js +11 -0
- package/static/dashboard/assets/{PaneListHeader-Dn5O0mwy.js → PaneListHeader-DtvnRmFq.js} +1 -1
- package/static/dashboard/assets/{PodDeletionAuthorizationPanel-D3NOG6ZM.js → PodDeletionAuthorizationPanel-BJk_8rJq.js} +3 -3
- package/static/dashboard/assets/PodPage-C4gzEspV.js +1 -0
- package/static/dashboard/assets/{SystemSettingsPage-BNQP_Yuc.js → SystemSettingsPage-HaNrP1H1.js} +1 -1
- package/static/dashboard/assets/TasksPage-BdO5K2L7.js +1 -0
- package/static/dashboard/assets/{WebDesktopEntry-vnb4CZWp.js → WebDesktopEntry-Cj9_ZfJU.js} +1 -1
- package/static/dashboard/assets/XpodAiConnectionsPodStore-B7gmXBmC.js +3 -0
- package/static/dashboard/assets/XpodShellApp-D_KY4nCW.js +4 -0
- package/static/dashboard/assets/{account-session-DCUmCop1.js → account-session-DlcKNG7k.js} +1 -1
- package/static/dashboard/assets/{button-By5Bgvmb.js → button-wslF55uZ.js} +1 -1
- package/static/dashboard/assets/collection-runtime-uxxgEu13.js +1 -0
- package/static/dashboard/assets/{createLucideIcon-bunMzPms.js → createLucideIcon-BJQl82Qk.js} +1 -1
- package/static/dashboard/assets/dashboard-CbJ-JkrI.css +1 -0
- package/static/dashboard/assets/{dashboard-mlsg3yaw.js → dashboard-Or0gnkou.js} +2 -2
- package/static/dashboard/assets/index-BqFeOML9.js +1 -0
- package/static/dashboard/assets/{index-DvMG5pHk.js → index-DgKn1twH.js} +2 -2
- package/static/dashboard/assets/{label-Bj03L9xs.js → label-CS6Sx6Zb.js} +1 -1
- package/static/dashboard/assets/list-UyhlCFKk.js +1 -0
- package/static/dashboard/assets/{nav-item-style-BNqWQY6p.js → nav-item-style-CW1Nnorq.js} +1 -1
- package/static/dashboard/assets/{pod-collections-host-KnnGFZHL.js → pod-collections-host-DjK2xf-b.js} +6 -6
- package/static/dashboard/assets/{safe-continuation-D9AhcWiB.js → safe-continuation-ClWAhcma.js} +1 -1
- package/static/dashboard/assets/{section-header-CLCzbOp_.js → section-header-CEIEcco-.js} +1 -1
- package/static/dashboard/assets/{setting-row-DTCec8A2.js → setting-row-CaYv3dfF.js} +1 -1
- package/static/dashboard/assets/xpod-remembered-login-BUF9fin1.js +310 -0
- package/static/dashboard/dashboard.html +2 -2
- package/static/settings/assets/{AccountAuthBoundary-C0og_gIA.js → AccountAuthBoundary-Chqd38oU.js} +1 -1
- package/static/settings/assets/{DesktopOidcCallback-C5q4oFZ0.js → DesktopOidcCallback-VUrOSM_q.js} +1 -1
- package/static/settings/assets/DevicePages-C6qwvWwu.js +2 -0
- package/static/settings/assets/ModelsPage-Ry_dObRQ.js +11 -0
- package/static/settings/assets/{PaneListHeader-DqVlMe2D.js → PaneListHeader-B5RkRqr4.js} +1 -1
- package/static/settings/assets/{PodDeletionAuthorizationPanel-DgVvarVY.js → PodDeletionAuthorizationPanel-DPM-5Izt.js} +3 -3
- package/static/settings/assets/PodPage-CxND6wwc.js +1 -0
- package/static/settings/assets/{SystemSettingsPage-Crzm_DrI.js → SystemSettingsPage-C8EdMkW7.js} +1 -1
- package/static/settings/assets/TasksPage-DuqptEm8.js +1 -0
- package/static/settings/assets/{WebDesktopEntry-BGC5eRF2.js → WebDesktopEntry-BRcyktkv.js} +1 -1
- package/static/settings/assets/XpodAiConnectionsPodStore-CyA_BJVC.js +3 -0
- package/static/settings/assets/XpodShellApp-CsivHJl0.js +4 -0
- package/static/settings/assets/XpodThemeProvider-CbJ-JkrI.css +1 -0
- package/static/settings/assets/{XpodThemeProvider-CB6LepTA.js → XpodThemeProvider-DK3pIdRG.js} +2 -2
- package/static/settings/assets/{account-session-BcLjCj0x.js → account-session-DJOZ03xr.js} +1 -1
- package/static/settings/assets/auth-callback-GIBYEz_7.js +1 -0
- package/static/settings/assets/{button-BObT8pTE.js → button-D3yW-2o1.js} +1 -1
- package/static/settings/assets/collection-runtime-DfGo25mh.js +1 -0
- package/static/settings/assets/{createLucideIcon-BVsUxXpZ.js → createLucideIcon-CacwLsmB.js} +1 -1
- package/static/settings/assets/{index-ktjMkj7-.js → index-r5KRYsKC.js} +1 -1
- package/static/settings/assets/{label-BrqO8_m_.js → label-MJjUmvzG.js} +1 -1
- package/static/settings/assets/list-Ce-5k1MX.js +1 -0
- package/static/settings/assets/{nav-item-style-Di2CxkDU.js → nav-item-style-ZUbL8KOZ.js} +1 -1
- package/static/settings/assets/{pod-collections-host-KnnGFZHL.js → pod-collections-host-DjK2xf-b.js} +6 -6
- package/static/settings/assets/{safe-continuation-Dx6ceJpY.js → safe-continuation-vlBZFSlU.js} +1 -1
- package/static/settings/assets/{section-header-Dtl7yjVr.js → section-header-DGJdEvQw.js} +1 -1
- package/static/settings/assets/{setting-row-BL6Hhe8N.js → setting-row-C7tuFiho.js} +1 -1
- package/static/settings/assets/{settings-DaRBxoZk.js → settings-CyQPih1O.js} +1 -1
- package/static/settings/assets/xpod-remembered-login-D-TzzT5K.js +567 -0
- package/static/settings/auth-callback.html +3 -3
- package/static/settings/settings.html +3 -3
- package/static/dashboard/assets/AccountAuthBoundary-BvoDydRz.js +0 -1
- package/static/dashboard/assets/DesktopOidcCallback-BwIj874x.js +0 -1
- package/static/dashboard/assets/DevicePages-jOjMcvsr.js +0 -2
- package/static/dashboard/assets/ModelsPage-CMTdfqBR.js +0 -11
- package/static/dashboard/assets/PodPage-BueBdJ9_.js +0 -1
- package/static/dashboard/assets/TasksPage-CxtLJiSF.js +0 -1
- package/static/dashboard/assets/XpodAiConnectionsPodStore-wx3Ttupm.js +0 -18
- package/static/dashboard/assets/XpodShellApp-5FWY8-d5.js +0 -4
- package/static/dashboard/assets/collection-runtime-BnomuB0E.js +0 -1
- package/static/dashboard/assets/dashboard-C64R553B.css +0 -1
- package/static/dashboard/assets/xpod-remembered-login-Dr69A0Rv.js +0 -295
- package/static/settings/assets/DevicePages-fyHjjucT.js +0 -2
- package/static/settings/assets/ModelsPage-EyOByLyE.js +0 -11
- package/static/settings/assets/PodPage-DY4Oi9wg.js +0 -1
- package/static/settings/assets/TasksPage-CfXJbnlt.js +0 -1
- package/static/settings/assets/XpodAiConnectionsPodStore-CXcmgKmQ.js +0 -3
- package/static/settings/assets/XpodShellApp-D1PS3Iut.js +0 -4
- package/static/settings/assets/XpodThemeProvider-C64R553B.css +0 -1
- package/static/settings/assets/auth-callback-DSPQ28ar.js +0 -1
- package/static/settings/assets/collection-runtime-DzNbdZGe.js +0 -1
- package/static/settings/assets/index-browser-3WfrNbcG.js +0 -273
- package/static/settings/assets/xpod-remembered-login-Q66DH12t.js +0 -295
package/static/dashboard/assets/{safe-continuation-D9AhcWiB.js → safe-continuation-ClWAhcma.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c,j as $t}from"./dashboard-mlsg3yaw.js";import{r as bt,g as J,b as Gt,c as Y,s as ct,d as yt,A as Wt}from"./account-session-DCUmCop1.js";const Xt="Cloud storage is not ready. Please wait for Xpod to reconnect and try again.",Et=new WeakMap;function it(){typeof window<"u"&&Et.delete(window)}function Jt(t){typeof window<"u"&&Et.set(window,t)}function Yt(t){try{sessionStorage.setItem("provisionCode",t)}catch{}}async function gn(t){const n=kt(t.accountIndex);if(!n)return;const e=ut(t);let o;try{o=await e(n,{headers:{accept:"application/json"},credentials:"omit"})}catch{return}if(!o.ok)return;const f=(await o.json().catch(()=>{}))?.controls?.account?.clientCredentials;if(typeof f!="string"||!f)return;const l=await bt(f,e,n);if(!l)return;const w=new URL(l,n);return w.origin===new URL(n).origin&&w.pathname.startsWith("/.account/")&&!w.username&&!w.password&&!w.hash?{collection:l,webId:t.webId}:void 0}function ut(t){const n=kt(t.accountIndex);return async(e,o)=>{if(t.assertCurrent?.(),!n)throw new Error("Invalid session Account authority");const s=new Headers(e instanceof Request?e.headers:void 0);new Headers(o?.headers).forEach((z,y)=>s.set(y,z)),/^CSS-Account-Token(?:\s|$)/iu.test(s.get("authorization")??"")&&s.delete("authorization");const f={...o,headers:s,credentials:"omit",redirect:"error"},l=new URL(e instanceof Request?e.url:String(e));if(l.origin!==new URL(n).origin||!l.pathname.startsWith("/.account/")||l.username||l.password||l.hash)throw new Error("Session Account request leaves the trusted authority");const w=new Request(e,f),p=e instanceof Request?await t.fetch(w):await t.fetch(w.url,f);try{t.assertCurrent?.()}catch(z){throw p.body?.cancel().catch(()=>{}),z}return p}}function kt(t){try{const n=new URL(t);return!["http:","https:"].includes(n.protocol)||n.username||n.password||n.pathname!=="/.account/"||n.search||n.hash?void 0:n.href}catch{return}}const B="/.account/";function Vt(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}async function mt(t=fetch){if(typeof window>"u")return B;if(!Qt(window.location.hostname)){const o=window.__XPOD__?.idpIndex;if(o!==void 0){try{const s=new URL(o,window.location.origin);if(typeof o=="string"&&o.trim()&&["http:","https:"].includes(s.protocol)&&s.pathname===B&&!s.username&&!s.password&&!s.search&&!s.hash)return it(),s.href}catch{}throw new Error("Server bootstrap did not expose a valid Account index")}}const n=await t(new URL("/provision/status",window.location.origin),{credentials:"include",headers:{accept:"application/json"}});if(n.status===404)return it(),new URL(B,window.location.origin).href;if(!n.ok)throw new Error(`Local provisioning status request failed (${n.status})`);let e;try{e=await n.json()}catch{throw new Error("Local provisioning status response was not valid JSON")}if(!Vt(e)||typeof e.managed!="boolean")throw new Error("Local provisioning status response was not valid");if(e.managed===!1)return it(),new URL(B,window.location.origin).href;if(typeof e.oidcIssuer=="string")try{const o=new URL(e.oidcIssuer);if(["http:","https:"].includes(o.protocol)&&!o.username&&!o.password)return Kt(t),typeof e.provisionCode=="string"&&Yt(e.provisionCode),new URL(B,o).href}catch{}throw new Error("Local provisioning status did not expose a valid OIDC issuer")}function Kt(t){const n=new URL("/provision/status",window.location.origin);Jt(async()=>{const e=await t(n,{credentials:"include",headers:{accept:"application/json"}}),o=e.ok?await e.json().catch(()=>{}):void 0;if(o?.managed!==!0||o?.registered!==!0||typeof o?.provisionCode!="string")throw new Error(Xt);return o.provisionCode})}function Qt(t){return t==="localhost"||t==="::1"||t==="[::1]"||/^127(?:\.\d{1,3}){3}$/u.test(t)}const Zt="/.account/",L="Xpod 登录服务暂时不可用,请稍后重试。",at=[250,750,1500],tn=300,Ct=3e3;function nn(){if(typeof window>"u")return!1;const t=window.location.pathname;return t==="/.account"||t.startsWith("/.account/")}function en(t){const n=t?.account;if(!n)return;const e={...typeof n.id=="string"?{id:n.id}:{},...typeof n.username=="string"?{username:n.username}:{},...typeof n.displayName=="string"?{displayName:n.displayName}:{}};return Object.keys(e).length>0?e:void 0}function At(t){return t?.account?.logout?{status:"authenticated"}:{status:"anonymous",mode:"login"}}function vt(t){return t===502||t===503||t===504}function Rt(t){return t?{status:"error",mode:"login",message:L}:{status:"initializing"}}function It(t){return new Promise(n=>setTimeout(n,t))}function yn({children:t}){const[n,e]=c.useState(),[o,s]=c.useState(null),[f,l]=c.useState(!0),[w,p]=c.useState(null),[z,y]=c.useState(!1),[tt,h]=c.useState({status:"initializing"}),T=c.useRef(0),v=c.useRef(!0),P=c.useRef(0),b=c.useRef(void 0),j=c.useRef(null),O=c.useRef(!1),E=c.useRef(void 0),_=c.useRef(void 0),dt=c.useRef(void 0),[Nt,Pt]=c.useState(0),nt=c.useRef(void 0),et=c.useRef(0),q=c.useRef(0),G=c.useRef(!1),F=c.useCallback(()=>{const r=j.current?.account;return r?.logout?JSON.stringify([b.current,r.id,r.logout,r.clientCredentials]):void 0},[]),R=c.useCallback(()=>{et.current+=1,G.current=!0},[]),g=c.useCallback((r,i,u)=>{const a=F(),d=nt.current,k=_.current;j.current=r,nt.current=i,_.current=u,(a!==F()||d!==i||k!==u)&&R(),G.current=!F()},[F,R]),rt=c.useCallback(()=>{const r=F(),i=et.current,u=J(),a=_.current;let d=!!r&&u===nt.current&&!G.current&&q.current===0;return()=>{if(a)try{if(a!==E.current||a!==_.current)throw new Error("Stale Account source");a.assertCurrent()}catch{d=!1}if(!d||!v.current||G.current||q.current>0||i!==et.current||r!==F()||u!==J())throw d=!1,new Error("Account 登录状态已改变,请重新打开客户端凭据操作。")}},[F]),jt=c.useCallback(r=>{const i=()=>{j.current?.account?.logout&&!_.current||(P.current+=1,(_.current||!j.current?.account?.logout&&E.current)&&(g(null),s(null),O.current=!1,h({status:"initializing"}),l(!0)),Pt(u=>u+1))};return E.current=r,i(),()=>{E.current===r&&(E.current=void 0,i())}},[g]),Ft=c.useCallback(async(r,i)=>{const u=b.current,a=new URL(r instanceof Request?r.url:String(r),u);if(!u||a.origin!==new URL(u).origin||!a.pathname.startsWith("/.account/")||a.username||a.password)throw new Error("Account request outside current authority");const d=rt(),k=_.current;d();const S=await(k?ut({accountIndex:u,fetch:k.fetch,assertCurrent:d}):fetch)(r instanceof Request?r:a.href,{...i,redirect:"error"});try{d()}catch(C){throw S.body?.cancel().catch(()=>{}),C}return S},[rt]),Mt=tt.status==="authenticated",Dt=f||tt.status==="submitting",W=c.useCallback(r=>{(Gt(r)||b.current&&b.current!==r)&&(P.current+=1,T.current+=1,O.current=!1,g(null),s(null),y(!1),h({status:"initializing"})),b.current=r,e(r)},[g]),X=c.useCallback(async()=>{l(!0),p(null),h(r=>r.status==="authenticated"?r:{status:"initializing"});try{const r=await mt();return v.current?(W(r),r):void 0}catch{if(!v.current)return;g(null),s(null),y(!1),p(L),h({status:"error",mode:"login",message:L}),l(!1);return}},[W,g]);c.useEffect(()=>{let r=!0;return mt().then(i=>{r&&v.current&&W(i)}).catch(()=>{!r||!v.current||(g(null),s(null),y(!1),p(L),h({status:"error",mode:"login",message:L}),l(!1))}),()=>{r=!1}},[W,g]),c.useEffect(()=>(v.current=!0,()=>{v.current=!1,R(),P.current+=1}),[R]);const m=c.useCallback(r=>v.current&&r===P.current,[]),ht=c.useCallback(async()=>{const r=new AbortController,i=setTimeout(()=>r.abort(),Ct);try{const u=b.current;if(!u)return!1;const a=await fetch(Y(new URL("oidc/consent/",u)),{headers:ct(void 0,u),credentials:"include",signal:r.signal});return a.ok?!!(await a.json()).client:!1}catch{return!1}finally{clearTimeout(i)}},[]),ot=c.useCallback(async({exposeTransientError:r,generation:i,confirmUnauthenticated:u})=>{const a=b.current;if(!a)return"stale";const d=J(),k=()=>d===J()?!0:(R(),!1);try{const I=await fetch(Y(a),{headers:ct(void 0,a),credentials:"include"});if(!m(i))return"stale";if(!k())return"transient-error";if(I.ok){const S=await I.json();if(!m(i))return"stale";if(!k())return"transient-error";if(!S?.controls||typeof S.controls!="object"||Array.isArray(S.controls))throw new Error("Invalid CSS Account controls response");let C=S.controls,wt;const A=E.current;if(!C.account?.logout&&A&&A!==dt.current&&q.current===0&&new URL(".account/",A.issuer).href===new URL(a).href){h(M=>M.status==="authenticated"?M:{status:"initializing"}),A.assertCurrent();const N=await ut({accountIndex:a,fetch:A.fetch,assertCurrent:()=>A.assertCurrent()})(Y(a),{headers:{accept:"application/json"},signal:AbortSignal.timeout(Ct)});if(!m(i)||A!==E.current)return"stale";if(A.assertCurrent(),!k())return"transient-error";if(N.ok){const M=await N.json();if(!m(i)||A!==E.current)return"stale";if(A.assertCurrent(),!k())return"transient-error";if(!M?.controls||typeof M.controls!="object"||Array.isArray(M.controls))throw new Error("Invalid CSS Account controls response");C=M.controls,C.account?.logout&&(wt=A)}else if(N.status!==401&&N.status!==403){if(vt(N.status)||N.status===408||N.status===429||N.status===500)throw new Error("Transient CSS Account controls response");return T.current+=1,y(!1),R(),p(L),h({status:"error",mode:"login",message:L}),"terminal-error"}}const Ht=++T.current;y(!1),g(C,d,wt),s(C),p(null);const pt=At(C);return O.current=pt.status==="anonymous",h(pt),C.account?.logout&&nn()&&ht().then(gt=>{m(i)&&Ht===T.current&&y(gt)}),"ok"}else{if(I.status===401||I.status===403)return u?(T.current+=1,yt(),O.current=!0,y(!1),g({}),s({}),h({status:"anonymous",mode:"login"}),p(null),"ok"):"unauthenticated";if(T.current+=1,y(!1),vt(I.status))return p(null),h(C=>C.status==="authenticated"?C:Rt(r)),"transient-error";R();const S=`Failed to load account controls (Status: ${I.status})`;return p(S),h({status:"error",mode:"login",message:S}),"terminal-error"}}catch{return m(i)?(T.current+=1,y(!1),p(null),h(I=>I.status==="authenticated"?I:Rt(r)),"transient-error"):"stale"}},[g,ht,m,R]),D=c.useCallback(async()=>{const r=++P.current;for(let i=0;i<=at.length;i+=1){const u=i===at.length,a=await ot({exposeTransientError:u,generation:r});if(a==="unauthenticated")return!m(r)||(await It(tn),!m(r))?"stale":ot({exposeTransientError:!0,generation:r,confirmUnauthenticated:!0});if(a!=="transient-error")return a;if(!m(r)||!u&&(h(d=>d.status==="authenticated"?d:{status:"initializing"}),await It(at[i]),!m(r)))return"stale"}return"transient-error"},[ot,m]);c.useEffect(()=>{if(!n)return;let r=!0;return(async()=>(await D(),r&&v.current&&l(!1)))(),()=>{r=!1}},[D,n,Nt]);const st=c.useCallback(async()=>{const r=await X();if(r&&r===n){const i=await D();if(v.current&&l(!1),i==="ok")return At(j.current)}return{status:"error",mode:"login",message:L}},[D,n,X]),zt=c.useCallback(async()=>{await st()},[st]),qt=c.useCallback(async()=>{q.current+=1,dt.current=E.current;try{R(),P.current+=1,T.current+=1,(_.current||!j.current?.account?.logout)&&(O.current=!1,(b.current??await X())&&await D());const r=b.current,i=j.current?.account?.logout,u=await bt(i,fetch,r);let a=!u&&(!!i||!O.current);if(u)try{const d=await fetch(Y(u),{method:"POST",headers:ct(void 0,r),credentials:"include"});a=!d.ok&&d.status!==401&&d.status!==403}catch{a=!0}if(a){h({status:"error",mode:"login",message:L});return}P.current+=1,T.current+=1,O.current=!0,l(!1),yt(),y(!1),g({}),s({}),p(null),h({status:"anonymous",mode:"login"})}finally{q.current-=1}},[g,D,X,R]),Bt=c.useMemo(()=>en(o),[o]);return $t.jsx(Wt.Provider,{value:{controls:o,isInitializing:f,initError:w,idpIndex:n??Zt,isLoggedIn:Mt,isAnonymous:()=>O.current,bindAccountCapability:rt,authenticating:Dt,hasOidcPending:z,refetchControls:st,registerAccountSession:jt,accountFetch:Ft,retry:zt,logout:qt,accountState:tt,identity:Bt},children:t})}const St=600*1e3,H=2048,x="xpod.safe-continuation.consent.v2",V="xpod.safe-continuation.management.v2",rn=/^\/\.account\/interaction\/([^/?#]+)$/u,on=/^\/\.account\/(?:interaction\/[^/?#]+\/)?account\/([^/?#]+)\//u;function K(){if(!(typeof window>"u"))try{return window.location.origin}catch{return}}function Lt(){if(!(typeof window>"u"))try{return window.sessionStorage}catch{return}}function lt(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Q(t){return typeof t=="string"&&t.length>0&&t.length<=H}function $(t){return Q(t)&&t===t.trim()}function Tt(t){return typeof t=="number"&&Number.isFinite(t)&&t>0}function xt(t){return Q(t)&&rn.test(t)}function sn(t){if(typeof t!="string"||!t||t.length>H)return;const n=cn(t);if(n)return n;if(/^[^/?#:]+$/u.test(t)&&t===t.trim())return t}function cn(t){if(typeof t!="string"||!t||t.length>H)return;let n;try{n=new URL(t,K()??"http://localhost")}catch{return}if(!["http:","https:"].includes(n.protocol)||n.username||n.password)return;const e=on.exec(n.pathname);return e?e[1]:void 0}function mn(t,n){const e=t?.account,o=[n?.id,e?.id,e?.logout,e?.clientCredentials,e?.bindings,e?.pod].map(sn).filter(l=>!!l);if(o.length===0)return;const[s,...f]=o;return f.every(l=>l===s)?s:void 0}function an(t,n=K()){if(!n||typeof t!="string"||!t||t.length>H)return!1;let e;try{e=new URL(t,n)}catch{return!1}return e.origin===n&&!e.username&&!e.password&&e.pathname.startsWith("/.account/")}function Ut(t,n,e=K()){if(!e||!xt(t)||typeof n!="string"||!n||n.length>H)return!1;let o;try{o=new URL(n,e)}catch{return!1}return o.origin===e&&!o.username&&!o.password&&o.pathname===`${t}/oidc/consent/`&&o.search===""&&o.hash===""}function un(t){const n=Lt();if(!n)return null;try{return n.getItem(t)}catch{return null}}function Z(t){const n=un(t);if(n===null)return;let e;try{e=JSON.parse(n)}catch{return}return lt(e)?e:void 0}function U(t){const n=Lt();if(n)try{n.removeItem(t)}catch{}}function Ot(t){const{createdAt:n,expiresAt:e}=t;if(!Tt(n)||!Tt(e))return!1;const o=Date.now();if(n>o)return!1;const s=e-n;return s<=0||s>St||e>n+St?!1:e>o}function _t(t,n){return t.accountId===n.accountId&&t.interaction===n.interaction&&t.returnTo===n.returnTo&&t.createdAt===n.createdAt&&t.expiresAt===n.expiresAt}function ft(t){if(!t||t.kind!=="consent")return null;const{accountId:n,interaction:e,returnTo:o}=t;return!$(n)||!xt(e)||!Q(o)||!Ot(t)||!Ut(e,o)?null:{kind:"consent",accountId:n,interaction:e,returnTo:o,createdAt:t.createdAt,expiresAt:t.expiresAt}}function ln(t){if(!t||t.kind!=="management")return null;const{accountId:n,returnTo:e}=t;return!$(n)||!Q(e)||!Ot(t)||!an(e)?null:{kind:"management",accountId:n,returnTo:e,createdAt:t.createdAt,expiresAt:t.expiresAt}}function fn(t){const n=t?.accountId;if(!$(n))return U(V),null;const e=ln(Z(V));return!e||e.accountId!==n?(U(V),null):e}function Cn(t){const n=fn(t);return U(V),n}function dn(t){const n=t?.accountId;if(!$(n))return U(x),null;const e=ft(Z(x));return!e||e.accountId!==n?(U(x),null):e}function An(t,n,e={}){const o=n?.accountId;if(!$(o))return U(x),null;const s=ft(Z(x));if(!s||s.accountId!==o||!_t(s,t))return U(x),null;try{e.assertCurrent?.()}catch{return null}return U(x),s}async function hn(t,n={}){const e=n.origin??K();if(!e||!Ut(t.interaction,t.returnTo,e))return!1;const o=n.fetch??(typeof fetch=="function"?fetch:void 0);if(!o)return!1;const s=new URL(t.returnTo,e).href;let f;try{n.assertCurrent?.(),f=await o(s,{method:"GET",credentials:"include",redirect:"manual",headers:{accept:"application/json",...n.headers??{}}})}catch{return!1}try{n.assertCurrent?.()}catch{return!1}if(f.redirected===!0||typeof f.status=="number"&&f.status>=300&&f.status<400||!f.ok||typeof f.url=="string"&&f.url&&f.url!==s)return!1;const l=await f.json().catch(()=>{});if(!lt(l))return!1;const w=l.client;return lt(w)&&(typeof w.client_id=="string"||typeof w.client_name=="string")}async function vn(t,n={}){const e=dn(t);if(!e)return null;const o=await hn(e,n),s=ft(Z(x));if(!o||!s||s.accountId!==t.accountId||!_t(s,e))return U(x),null;try{n.assertCurrent?.()}catch{return null}return s}export{yn as A,vn as a,fn as b,hn as c,An as d,Cn as e,ut as f,gn as g,mn as r};
|
|
1
|
+
import{r as c,j as $t}from"./dashboard-Or0gnkou.js";import{r as bt,g as J,b as Gt,c as Y,s as ct,d as yt,A as Wt}from"./account-session-DlcKNG7k.js";const Xt="Cloud storage is not ready. Please wait for Xpod to reconnect and try again.",Et=new WeakMap;function it(){typeof window<"u"&&Et.delete(window)}function Jt(t){typeof window<"u"&&Et.set(window,t)}function Yt(t){try{sessionStorage.setItem("provisionCode",t)}catch{}}async function gn(t){const n=kt(t.accountIndex);if(!n)return;const e=ut(t);let o;try{o=await e(n,{headers:{accept:"application/json"},credentials:"omit"})}catch{return}if(!o.ok)return;const f=(await o.json().catch(()=>{}))?.controls?.account?.clientCredentials;if(typeof f!="string"||!f)return;const l=await bt(f,e,n);if(!l)return;const w=new URL(l,n);return w.origin===new URL(n).origin&&w.pathname.startsWith("/.account/")&&!w.username&&!w.password&&!w.hash?{collection:l,webId:t.webId}:void 0}function ut(t){const n=kt(t.accountIndex);return async(e,o)=>{if(t.assertCurrent?.(),!n)throw new Error("Invalid session Account authority");const s=new Headers(e instanceof Request?e.headers:void 0);new Headers(o?.headers).forEach((z,y)=>s.set(y,z)),/^CSS-Account-Token(?:\s|$)/iu.test(s.get("authorization")??"")&&s.delete("authorization");const f={...o,headers:s,credentials:"omit",redirect:"error"},l=new URL(e instanceof Request?e.url:String(e));if(l.origin!==new URL(n).origin||!l.pathname.startsWith("/.account/")||l.username||l.password||l.hash)throw new Error("Session Account request leaves the trusted authority");const w=new Request(e,f),p=e instanceof Request?await t.fetch(w):await t.fetch(w.url,f);try{t.assertCurrent?.()}catch(z){throw p.body?.cancel().catch(()=>{}),z}return p}}function kt(t){try{const n=new URL(t);return!["http:","https:"].includes(n.protocol)||n.username||n.password||n.pathname!=="/.account/"||n.search||n.hash?void 0:n.href}catch{return}}const B="/.account/";function Vt(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}async function mt(t=fetch){if(typeof window>"u")return B;if(!Qt(window.location.hostname)){const o=window.__XPOD__?.idpIndex;if(o!==void 0){try{const s=new URL(o,window.location.origin);if(typeof o=="string"&&o.trim()&&["http:","https:"].includes(s.protocol)&&s.pathname===B&&!s.username&&!s.password&&!s.search&&!s.hash)return it(),s.href}catch{}throw new Error("Server bootstrap did not expose a valid Account index")}}const n=await t(new URL("/provision/status",window.location.origin),{credentials:"include",headers:{accept:"application/json"}});if(n.status===404)return it(),new URL(B,window.location.origin).href;if(!n.ok)throw new Error(`Local provisioning status request failed (${n.status})`);let e;try{e=await n.json()}catch{throw new Error("Local provisioning status response was not valid JSON")}if(!Vt(e)||typeof e.managed!="boolean")throw new Error("Local provisioning status response was not valid");if(e.managed===!1)return it(),new URL(B,window.location.origin).href;if(typeof e.oidcIssuer=="string")try{const o=new URL(e.oidcIssuer);if(["http:","https:"].includes(o.protocol)&&!o.username&&!o.password)return Kt(t),typeof e.provisionCode=="string"&&Yt(e.provisionCode),new URL(B,o).href}catch{}throw new Error("Local provisioning status did not expose a valid OIDC issuer")}function Kt(t){const n=new URL("/provision/status",window.location.origin);Jt(async()=>{const e=await t(n,{credentials:"include",headers:{accept:"application/json"}}),o=e.ok?await e.json().catch(()=>{}):void 0;if(o?.managed!==!0||o?.registered!==!0||typeof o?.provisionCode!="string")throw new Error(Xt);return o.provisionCode})}function Qt(t){return t==="localhost"||t==="::1"||t==="[::1]"||/^127(?:\.\d{1,3}){3}$/u.test(t)}const Zt="/.account/",L="Xpod 登录服务暂时不可用,请稍后重试。",at=[250,750,1500],tn=300,Ct=3e3;function nn(){if(typeof window>"u")return!1;const t=window.location.pathname;return t==="/.account"||t.startsWith("/.account/")}function en(t){const n=t?.account;if(!n)return;const e={...typeof n.id=="string"?{id:n.id}:{},...typeof n.username=="string"?{username:n.username}:{},...typeof n.displayName=="string"?{displayName:n.displayName}:{}};return Object.keys(e).length>0?e:void 0}function At(t){return t?.account?.logout?{status:"authenticated"}:{status:"anonymous",mode:"login"}}function vt(t){return t===502||t===503||t===504}function Rt(t){return t?{status:"error",mode:"login",message:L}:{status:"initializing"}}function It(t){return new Promise(n=>setTimeout(n,t))}function yn({children:t}){const[n,e]=c.useState(),[o,s]=c.useState(null),[f,l]=c.useState(!0),[w,p]=c.useState(null),[z,y]=c.useState(!1),[tt,h]=c.useState({status:"initializing"}),T=c.useRef(0),v=c.useRef(!0),P=c.useRef(0),b=c.useRef(void 0),j=c.useRef(null),O=c.useRef(!1),E=c.useRef(void 0),_=c.useRef(void 0),dt=c.useRef(void 0),[Nt,Pt]=c.useState(0),nt=c.useRef(void 0),et=c.useRef(0),q=c.useRef(0),G=c.useRef(!1),F=c.useCallback(()=>{const r=j.current?.account;return r?.logout?JSON.stringify([b.current,r.id,r.logout,r.clientCredentials]):void 0},[]),R=c.useCallback(()=>{et.current+=1,G.current=!0},[]),g=c.useCallback((r,i,u)=>{const a=F(),d=nt.current,k=_.current;j.current=r,nt.current=i,_.current=u,(a!==F()||d!==i||k!==u)&&R(),G.current=!F()},[F,R]),rt=c.useCallback(()=>{const r=F(),i=et.current,u=J(),a=_.current;let d=!!r&&u===nt.current&&!G.current&&q.current===0;return()=>{if(a)try{if(a!==E.current||a!==_.current)throw new Error("Stale Account source");a.assertCurrent()}catch{d=!1}if(!d||!v.current||G.current||q.current>0||i!==et.current||r!==F()||u!==J())throw d=!1,new Error("Account 登录状态已改变,请重新打开客户端凭据操作。")}},[F]),jt=c.useCallback(r=>{const i=()=>{j.current?.account?.logout&&!_.current||(P.current+=1,(_.current||!j.current?.account?.logout&&E.current)&&(g(null),s(null),O.current=!1,h({status:"initializing"}),l(!0)),Pt(u=>u+1))};return E.current=r,i(),()=>{E.current===r&&(E.current=void 0,i())}},[g]),Ft=c.useCallback(async(r,i)=>{const u=b.current,a=new URL(r instanceof Request?r.url:String(r),u);if(!u||a.origin!==new URL(u).origin||!a.pathname.startsWith("/.account/")||a.username||a.password)throw new Error("Account request outside current authority");const d=rt(),k=_.current;d();const S=await(k?ut({accountIndex:u,fetch:k.fetch,assertCurrent:d}):fetch)(r instanceof Request?r:a.href,{...i,redirect:"error"});try{d()}catch(C){throw S.body?.cancel().catch(()=>{}),C}return S},[rt]),Mt=tt.status==="authenticated",Dt=f||tt.status==="submitting",W=c.useCallback(r=>{(Gt(r)||b.current&&b.current!==r)&&(P.current+=1,T.current+=1,O.current=!1,g(null),s(null),y(!1),h({status:"initializing"})),b.current=r,e(r)},[g]),X=c.useCallback(async()=>{l(!0),p(null),h(r=>r.status==="authenticated"?r:{status:"initializing"});try{const r=await mt();return v.current?(W(r),r):void 0}catch{if(!v.current)return;g(null),s(null),y(!1),p(L),h({status:"error",mode:"login",message:L}),l(!1);return}},[W,g]);c.useEffect(()=>{let r=!0;return mt().then(i=>{r&&v.current&&W(i)}).catch(()=>{!r||!v.current||(g(null),s(null),y(!1),p(L),h({status:"error",mode:"login",message:L}),l(!1))}),()=>{r=!1}},[W,g]),c.useEffect(()=>(v.current=!0,()=>{v.current=!1,R(),P.current+=1}),[R]);const m=c.useCallback(r=>v.current&&r===P.current,[]),ht=c.useCallback(async()=>{const r=new AbortController,i=setTimeout(()=>r.abort(),Ct);try{const u=b.current;if(!u)return!1;const a=await fetch(Y(new URL("oidc/consent/",u)),{headers:ct(void 0,u),credentials:"include",signal:r.signal});return a.ok?!!(await a.json()).client:!1}catch{return!1}finally{clearTimeout(i)}},[]),ot=c.useCallback(async({exposeTransientError:r,generation:i,confirmUnauthenticated:u})=>{const a=b.current;if(!a)return"stale";const d=J(),k=()=>d===J()?!0:(R(),!1);try{const I=await fetch(Y(a),{headers:ct(void 0,a),credentials:"include"});if(!m(i))return"stale";if(!k())return"transient-error";if(I.ok){const S=await I.json();if(!m(i))return"stale";if(!k())return"transient-error";if(!S?.controls||typeof S.controls!="object"||Array.isArray(S.controls))throw new Error("Invalid CSS Account controls response");let C=S.controls,wt;const A=E.current;if(!C.account?.logout&&A&&A!==dt.current&&q.current===0&&new URL(".account/",A.issuer).href===new URL(a).href){h(M=>M.status==="authenticated"?M:{status:"initializing"}),A.assertCurrent();const N=await ut({accountIndex:a,fetch:A.fetch,assertCurrent:()=>A.assertCurrent()})(Y(a),{headers:{accept:"application/json"},signal:AbortSignal.timeout(Ct)});if(!m(i)||A!==E.current)return"stale";if(A.assertCurrent(),!k())return"transient-error";if(N.ok){const M=await N.json();if(!m(i)||A!==E.current)return"stale";if(A.assertCurrent(),!k())return"transient-error";if(!M?.controls||typeof M.controls!="object"||Array.isArray(M.controls))throw new Error("Invalid CSS Account controls response");C=M.controls,C.account?.logout&&(wt=A)}else if(N.status!==401&&N.status!==403){if(vt(N.status)||N.status===408||N.status===429||N.status===500)throw new Error("Transient CSS Account controls response");return T.current+=1,y(!1),R(),p(L),h({status:"error",mode:"login",message:L}),"terminal-error"}}const Ht=++T.current;y(!1),g(C,d,wt),s(C),p(null);const pt=At(C);return O.current=pt.status==="anonymous",h(pt),C.account?.logout&&nn()&&ht().then(gt=>{m(i)&&Ht===T.current&&y(gt)}),"ok"}else{if(I.status===401||I.status===403)return u?(T.current+=1,yt(),O.current=!0,y(!1),g({}),s({}),h({status:"anonymous",mode:"login"}),p(null),"ok"):"unauthenticated";if(T.current+=1,y(!1),vt(I.status))return p(null),h(C=>C.status==="authenticated"?C:Rt(r)),"transient-error";R();const S=`Failed to load account controls (Status: ${I.status})`;return p(S),h({status:"error",mode:"login",message:S}),"terminal-error"}}catch{return m(i)?(T.current+=1,y(!1),p(null),h(I=>I.status==="authenticated"?I:Rt(r)),"transient-error"):"stale"}},[g,ht,m,R]),D=c.useCallback(async()=>{const r=++P.current;for(let i=0;i<=at.length;i+=1){const u=i===at.length,a=await ot({exposeTransientError:u,generation:r});if(a==="unauthenticated")return!m(r)||(await It(tn),!m(r))?"stale":ot({exposeTransientError:!0,generation:r,confirmUnauthenticated:!0});if(a!=="transient-error")return a;if(!m(r)||!u&&(h(d=>d.status==="authenticated"?d:{status:"initializing"}),await It(at[i]),!m(r)))return"stale"}return"transient-error"},[ot,m]);c.useEffect(()=>{if(!n)return;let r=!0;return(async()=>(await D(),r&&v.current&&l(!1)))(),()=>{r=!1}},[D,n,Nt]);const st=c.useCallback(async()=>{const r=await X();if(r&&r===n){const i=await D();if(v.current&&l(!1),i==="ok")return At(j.current)}return{status:"error",mode:"login",message:L}},[D,n,X]),zt=c.useCallback(async()=>{await st()},[st]),qt=c.useCallback(async()=>{q.current+=1,dt.current=E.current;try{R(),P.current+=1,T.current+=1,(_.current||!j.current?.account?.logout)&&(O.current=!1,(b.current??await X())&&await D());const r=b.current,i=j.current?.account?.logout,u=await bt(i,fetch,r);let a=!u&&(!!i||!O.current);if(u)try{const d=await fetch(Y(u),{method:"POST",headers:ct(void 0,r),credentials:"include"});a=!d.ok&&d.status!==401&&d.status!==403}catch{a=!0}if(a){h({status:"error",mode:"login",message:L});return}P.current+=1,T.current+=1,O.current=!0,l(!1),yt(),y(!1),g({}),s({}),p(null),h({status:"anonymous",mode:"login"})}finally{q.current-=1}},[g,D,X,R]),Bt=c.useMemo(()=>en(o),[o]);return $t.jsx(Wt.Provider,{value:{controls:o,isInitializing:f,initError:w,idpIndex:n??Zt,isLoggedIn:Mt,isAnonymous:()=>O.current,bindAccountCapability:rt,authenticating:Dt,hasOidcPending:z,refetchControls:st,registerAccountSession:jt,accountFetch:Ft,retry:zt,logout:qt,accountState:tt,identity:Bt},children:t})}const St=600*1e3,H=2048,x="xpod.safe-continuation.consent.v2",V="xpod.safe-continuation.management.v2",rn=/^\/\.account\/interaction\/([^/?#]+)$/u,on=/^\/\.account\/(?:interaction\/[^/?#]+\/)?account\/([^/?#]+)\//u;function K(){if(!(typeof window>"u"))try{return window.location.origin}catch{return}}function Lt(){if(!(typeof window>"u"))try{return window.sessionStorage}catch{return}}function lt(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Q(t){return typeof t=="string"&&t.length>0&&t.length<=H}function $(t){return Q(t)&&t===t.trim()}function Tt(t){return typeof t=="number"&&Number.isFinite(t)&&t>0}function xt(t){return Q(t)&&rn.test(t)}function sn(t){if(typeof t!="string"||!t||t.length>H)return;const n=cn(t);if(n)return n;if(/^[^/?#:]+$/u.test(t)&&t===t.trim())return t}function cn(t){if(typeof t!="string"||!t||t.length>H)return;let n;try{n=new URL(t,K()??"http://localhost")}catch{return}if(!["http:","https:"].includes(n.protocol)||n.username||n.password)return;const e=on.exec(n.pathname);return e?e[1]:void 0}function mn(t,n){const e=t?.account,o=[n?.id,e?.id,e?.logout,e?.clientCredentials,e?.bindings,e?.pod].map(sn).filter(l=>!!l);if(o.length===0)return;const[s,...f]=o;return f.every(l=>l===s)?s:void 0}function an(t,n=K()){if(!n||typeof t!="string"||!t||t.length>H)return!1;let e;try{e=new URL(t,n)}catch{return!1}return e.origin===n&&!e.username&&!e.password&&e.pathname.startsWith("/.account/")}function Ut(t,n,e=K()){if(!e||!xt(t)||typeof n!="string"||!n||n.length>H)return!1;let o;try{o=new URL(n,e)}catch{return!1}return o.origin===e&&!o.username&&!o.password&&o.pathname===`${t}/oidc/consent/`&&o.search===""&&o.hash===""}function un(t){const n=Lt();if(!n)return null;try{return n.getItem(t)}catch{return null}}function Z(t){const n=un(t);if(n===null)return;let e;try{e=JSON.parse(n)}catch{return}return lt(e)?e:void 0}function U(t){const n=Lt();if(n)try{n.removeItem(t)}catch{}}function Ot(t){const{createdAt:n,expiresAt:e}=t;if(!Tt(n)||!Tt(e))return!1;const o=Date.now();if(n>o)return!1;const s=e-n;return s<=0||s>St||e>n+St?!1:e>o}function _t(t,n){return t.accountId===n.accountId&&t.interaction===n.interaction&&t.returnTo===n.returnTo&&t.createdAt===n.createdAt&&t.expiresAt===n.expiresAt}function ft(t){if(!t||t.kind!=="consent")return null;const{accountId:n,interaction:e,returnTo:o}=t;return!$(n)||!xt(e)||!Q(o)||!Ot(t)||!Ut(e,o)?null:{kind:"consent",accountId:n,interaction:e,returnTo:o,createdAt:t.createdAt,expiresAt:t.expiresAt}}function ln(t){if(!t||t.kind!=="management")return null;const{accountId:n,returnTo:e}=t;return!$(n)||!Q(e)||!Ot(t)||!an(e)?null:{kind:"management",accountId:n,returnTo:e,createdAt:t.createdAt,expiresAt:t.expiresAt}}function fn(t){const n=t?.accountId;if(!$(n))return U(V),null;const e=ln(Z(V));return!e||e.accountId!==n?(U(V),null):e}function Cn(t){const n=fn(t);return U(V),n}function dn(t){const n=t?.accountId;if(!$(n))return U(x),null;const e=ft(Z(x));return!e||e.accountId!==n?(U(x),null):e}function An(t,n,e={}){const o=n?.accountId;if(!$(o))return U(x),null;const s=ft(Z(x));if(!s||s.accountId!==o||!_t(s,t))return U(x),null;try{e.assertCurrent?.()}catch{return null}return U(x),s}async function hn(t,n={}){const e=n.origin??K();if(!e||!Ut(t.interaction,t.returnTo,e))return!1;const o=n.fetch??(typeof fetch=="function"?fetch:void 0);if(!o)return!1;const s=new URL(t.returnTo,e).href;let f;try{n.assertCurrent?.(),f=await o(s,{method:"GET",credentials:"include",redirect:"manual",headers:{accept:"application/json",...n.headers??{}}})}catch{return!1}try{n.assertCurrent?.()}catch{return!1}if(f.redirected===!0||typeof f.status=="number"&&f.status>=300&&f.status<400||!f.ok||typeof f.url=="string"&&f.url&&f.url!==s)return!1;const l=await f.json().catch(()=>{});if(!lt(l))return!1;const w=l.client;return lt(w)&&(typeof w.client_id=="string"||typeof w.client_name=="string")}async function vn(t,n={}){const e=dn(t);if(!e)return null;const o=await hn(e,n),s=ft(Z(x));if(!o||!s||s.accountId!==t.accountId||!_t(s,e))return U(x),null;try{n.assertCurrent?.()}catch{return null}return s}export{yn as A,vn as a,fn as b,hn as c,An as d,Cn as e,ut as f,gn as g,mn as r};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./dashboard-
|
|
1
|
+
import{j as e}from"./dashboard-Or0gnkou.js";import{c as n,a as m,i as c}from"./button-wslF55uZ.js";const u=m(`inline-flex items-center rounded-lg border px-2.5 py-0.5 text-xs font-semibold transition-all duration-200 ${c}`,{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow-sm shadow-primary/20 hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow-sm shadow-destructive/20 hover:bg-destructive/90",outline:"border-border/40 text-foreground bg-muted/30 backdrop-blur-sm",pending:"border border-dashed border-muted-foreground bg-transparent text-muted-foreground shadow-none hover:bg-transparent"}},defaultVariants:{variant:"default"}});function b({className:r,variant:a,...s}){return e.jsx("div",{className:n(u({variant:a}),r),...s})}function f({title:r,description:a,actions:s,level:d=2,titleClassName:o,className:i,...l}){const t=n("text-sm leading-normal text-foreground",o);return e.jsxs("div",{...l,className:n("flex flex-wrap items-start justify-between gap-3",i),children:[e.jsxs("div",{className:"min-w-0",children:[d===3?e.jsx("h3",{className:t,children:r}):d===4?e.jsx("h4",{className:t,children:r}):e.jsx("h2",{className:t,children:r}),a?e.jsx("p",{className:"mt-1 text-xs leading-normal text-muted-foreground",children:a}):null]}),s?e.jsx("div",{className:"flex min-w-0 max-w-full flex-wrap items-center gap-2",children:s}):null]})}export{b as B,f as S};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as o,j as r}from"./dashboard-
|
|
1
|
+
import{r as o,j as r}from"./dashboard-Or0gnkou.js";import{c as D,P,a as F,u as $}from"./PodDeletionAuthorizationPanel-BJk_8rJq.js";import{u as M,c as j,i as W}from"./button-wslF55uZ.js";import{G as X}from"./xpod-remembered-login-BUF9fin1.js";var J=Object.defineProperty,w=(n,e)=>J(n,"name",{value:e,configurable:!0}),E="Switch",[K,de]=D(E),[Q,y]=K(E);function U(n){const{__scopeSwitch:e,checked:s,children:c,defaultChecked:a,disabled:t,form:i,name:l,onCheckedChange:d,required:h,value:S="on",internal_do_not_use_render:m}=n,[f,b]=$({prop:s,defaultProp:a??!1,onChange:d,caller:E}),[g,C]=o.useState(null),[x,v]=o.useState(null),R=o.useRef(!1),[u,p]=o.useReducer(k=>k+1,0),I=g?!!i||!!g.closest("form"):!0,_={checked:f,setChecked:b,disabled:t,control:g,setControl:C,name:l,form:i,value:S,hasConsumerStoppedPropagationRef:R,userInteractionCount:u,onUserInteraction:p,required:h,defaultChecked:a,isFormControl:I,bubbleInput:x,setBubbleInput:v};return r.jsx(Q,{scope:e,..._,children:H(m)?m(_):c})}w(U,"SwitchProvider");var V="SwitchTrigger",Y=o.forwardRef(w(function({__scopeSwitch:e,onClick:s,...c},a){const{control:t,form:i,value:l,disabled:d,checked:h,required:S,setControl:m,setChecked:f,hasConsumerStoppedPropagationRef:b,onUserInteraction:g,isFormControl:C,bubbleInput:x}=y(V,e),v=M(a,m),R=o.useRef(h);return o.useEffect(()=>{const u=i?t?.ownerDocument.getElementById(i):t?.form;if(u instanceof HTMLFormElement){const p=w(()=>f(R.current),"reset");return u.addEventListener("reset",p),()=>u.removeEventListener("reset",p)}},[t,i,f]),r.jsx(P.button,{type:"button",role:"switch","aria-checked":h,"aria-required":S,"data-state":N(h),"data-disabled":d?"":void 0,disabled:d,value:l,...c,ref:v,onClick:F(s,u=>{g(),f(p=>!p),x&&C&&(b.current=u.isPropagationStopped(),b.current||u.stopPropagation())})})},"SwitchTrigger")),q=o.forwardRef(w(function(e,s){const{__scopeSwitch:c,name:a,checked:t,defaultChecked:i,required:l,disabled:d,value:h,onCheckedChange:S,form:m,...f}=e;return r.jsx(U,{__scopeSwitch:c,checked:t,defaultChecked:i,disabled:d,required:l,onCheckedChange:S,name:a,form:m,value:h,internal_do_not_use_render:({isFormControl:b})=>r.jsxs(r.Fragment,{children:[r.jsx(Y,{...f,ref:s,__scopeSwitch:c}),b&&r.jsx(re,{__scopeSwitch:c})]})})},"Switch")),Z="SwitchThumb",ee=o.forwardRef(w(function(e,s){const{__scopeSwitch:c,...a}=e,t=y(Z,c);return r.jsx(P.span,{"data-state":N(t.checked),"data-disabled":t.disabled?"":void 0,...a,ref:s})},"SwitchThumb")),te="SwitchBubbleInput",re=o.forwardRef(w(function({__scopeSwitch:e,onClick:s,...c},a){const{control:t,hasConsumerStoppedPropagationRef:i,userInteractionCount:l,checked:d,defaultChecked:h,required:S,disabled:m,name:f,value:b,form:g,bubbleInput:C,setBubbleInput:x}=y(te,e),v=M(a,x),R=X(t),u=o.useRef(!1),p=o.useRef(d),I=o.useRef(l);o.useEffect(()=>{const k=C;if(!k)return;const A=window.HTMLInputElement.prototype,T=Object.getOwnPropertyDescriptor(A,"checked").set,B=l!==I.current;I.current=l;const G=p.current!==d;p.current=d;const O=!(B&&i.current);if(G&&T){u.current=!B;const z=new Event("click",{bubbles:O});T.call(k,d),k.dispatchEvent(z),u.current=!1}},[C,d,i,l]);const _=o.useRef(d);return r.jsx(P.input,{type:"checkbox","aria-hidden":!0,defaultChecked:h??_.current,required:S,disabled:m,name:f,value:b,form:g,...c,tabIndex:-1,ref:v,onClick:F(s,k=>{u.current&&k.stopPropagation()}),style:{...c.style,...R,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"SwitchBubbleInput"));function H(n){return typeof n=="function"}w(H,"isFunction");function N(n){return n?"checked":"unchecked"}w(N,"getState");const L=o.forwardRef(({className:n,...e},s)=>r.jsx(q,{className:j("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full","border-2 border-transparent","transition-all duration-200",W,"disabled:cursor-not-allowed disabled:opacity-50","data-[state=checked]:bg-primary","data-[state=unchecked]:bg-muted/50",n),...e,ref:s,children:r.jsx(ee,{className:j("pointer-events-none block h-5 w-5 rounded-full bg-background","shadow-md ring-0","transition-transform duration-200","data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));L.displayName=q.displayName;function ne({label:n,description:e,control:s,className:c,...a}){const t=o.useId(),i=e?`${t}-description`:void 0;return r.jsxs("div",{className:j("flex min-h-16 items-center justify-between gap-3 border-b border-border",c),...a,children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("label",{htmlFor:t,className:"text-sm leading-normal text-foreground",children:n}),e?r.jsx("p",{id:i,className:"mt-1 text-xs leading-normal text-muted-foreground",children:e}):null]}),r.jsx("div",{className:"shrink-0",children:s({id:t,"aria-describedby":i})})]})}function ue({checked:n,onCheckedChange:e,disabled:s,...c}){return r.jsx(ne,{...c,control:({id:a,"aria-describedby":t})=>r.jsx(L,{id:a,checked:n,onCheckedChange:e,disabled:s,"aria-describedby":t})})}export{ne as S,ue as a};
|