mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-10-26 20:22:51 +08:00
3 lines
1.4 KiB
JavaScript
3 lines
1.4 KiB
JavaScript
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./auth-DmBaDwOI.js","./index-CXHBmSa5.js","./vendor-react-Bf71BWbF.js","./index-BMPxGQXj.css"])))=>i.map(i=>d[i]);
|
|
import{i as r,d$ as a,e0 as c,_ as u}from"./index-CXHBmSa5.js";const n=(o,e)=>new URL(o.replace(/\/+$/,"")+e,globalThis.location?.href),p=()=>u(()=>import("./auth-DmBaDwOI.js"),__vite__mapDeps([0,1,2,3]),import.meta.url),h={username:"demo",password:"demo"};async function l(o,e){if(r(o))return(await p()).mockDiscovery();const t=await a(n(o,"/api"),{headers:{Accept:"application/json"},cache:"no-store",signal:e});if(!t.ok)throw await c(t);return(await t.json()).auth??null}async function w(o,e){return(await a(n(o,"/api/v1/capabilities"),{headers:{Accept:"application/json"},cache:"no-store",signal:e})).status!==404}function f(o){return o?.mode!=="password"?"token":o.setup_required?"setup":"login"}async function m(o,e,t,s){if(r(o))return(await p()).mockOpenSession(e,t);const i=await a(n(o,`/api/v1/auth/${e}`),{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t),cache:"no-store",signal:s},e==="setup");if(!i.ok)throw await c(i);return i.json()}async function A(o,e,t){if(r(o))return;const s=await a(n(o,"/api/v1/auth/logout"),{method:"POST",headers:{Accept:"application/json",Authorization:"Bearer "+e},cache:"no-store",signal:t});if(!s.ok&&s.status!==401)throw await c(s)}export{h as D,w as a,A as c,l as d,m as o,f as s};
|