@masonitestudios/spartanauth-widgets 1.1.0 → 1.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/sa-widgets.mjs +4 -3
- package/dist/sa-widgets.umd.js +1 -1
- package/package.json +1 -1
package/dist/sa-widgets.mjs
CHANGED
|
@@ -1799,7 +1799,8 @@ const Fu = {
|
|
|
1799
1799
|
startMode: "password",
|
|
1800
1800
|
styles: "",
|
|
1801
1801
|
locale: "en",
|
|
1802
|
-
redirect: ""
|
|
1802
|
+
redirect: "",
|
|
1803
|
+
hideSocial: !1
|
|
1803
1804
|
};
|
|
1804
1805
|
gt("spartan-login", Fu, (e) => {
|
|
1805
1806
|
const [t, n] = w((e.startMode || "password").toLowerCase()), [r, s] = w(""), [i, u] = w(""), [o, C] = w(""), [$, D] = w(""), [k] = w(e.redirect), [ue, fe] = w(!1), [Fe, R] = w(!1), [Z, Y] = w(!1), [oe, H] = w(""), [ne, V] = w(""), [Ae, ye] = w([]), [Ee, B] = w(""), [ee, $e] = w([]), [he, ge] = w(""), [b, me] = w(!1), [Le, be] = w(!1), [ze, qe] = w(""), [Ue, Oe] = w(""), [Ie, Pe] = w(""), [Ne, Ce] = w(""), [xe, Se] = w(""), [A, v] = w(""), [x, j] = w(!1), d = mt(e.locale);
|
|
@@ -1894,7 +1895,7 @@ gt("spartan-login", Fu, (e) => {
|
|
|
1894
1895
|
});
|
|
1895
1896
|
}
|
|
1896
1897
|
function N() {
|
|
1897
|
-
fetch(`${e.domain}/api/v1/sectors/${e.sector}/oauth/providers`, {
|
|
1898
|
+
e.hideSocial || fetch(`${e.domain}/api/v1/sectors/${e.sector}/oauth/providers`, {
|
|
1898
1899
|
method: "GET",
|
|
1899
1900
|
mode: "cors",
|
|
1900
1901
|
cache: "no-cache"
|
|
@@ -2421,7 +2422,7 @@ gt("spartan-login", Fu, (e) => {
|
|
|
2421
2422
|
var p = h(() => t() === "sign-up");
|
|
2422
2423
|
return () => p() ? d.i18n("sa-back") : d.i18n("sa-signup");
|
|
2423
2424
|
})()), a;
|
|
2424
|
-
})()), h(() => h(() => ee().length > 0 && (t() === "password" || t() === "webauthn" || t() === "sign-up"))() && [(() => {
|
|
2425
|
+
})()), h(() => h(() => !e.hideSocial && ee().length > 0 && (t() === "password" || t() === "webauthn" || t() === "sign-up"))() && [(() => {
|
|
2425
2426
|
var a = mu(), p = a.firstChild;
|
|
2426
2427
|
return f(p, () => d.i18n("sa-or")), a;
|
|
2427
2428
|
})(), h(() => ee().map((a) => (() => {
|
package/dist/sa-widgets.umd.js
CHANGED
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
margin-bottom: 0;
|
|
145
145
|
display: block;
|
|
146
146
|
}
|
|
147
|
-
</style><style></style><h1>`),nu=A("<span class=error-message>"),Dt=A("<span>"),ru=A("<input type=text autocomplete=one-time-code required>"),Gt=A("<span class=hint>"),su=A("<input type=password autocomplete=new-password required>"),Ht=A("<button type=submit>"),iu=A("<span class=info-message>"),au=A("<span class=success-message>"),uu=A("<input type=text autocomplete=username>"),ou=A("<input type=password autocomplete=current-password>"),gt=A("<p>"),lu=A("<select>"),cu=A("<option> (<!>)"),du=A("<input type=text>"),Wt=A("<input type=text autocomplete=one-time-code>"),Zt=A("<input type=password autocomplete=new-password>"),fu=A("<span class=checkbox-wrapper><input type=checkbox><span> "),hu=A("<button type=button>"),nt=A("<a class=centered-text href=#>"),pu=A("<div class=social-divider><span>"),Du=A("<button type=button class=social-btn>"),gu=A('<svg width=18 height=18 viewBox="0 0 18 18"xmlns=http://www.w3.org/2000/svg><path d="M17.64 9.2c0-.637-.057-1.251-.164-1.84H9v3.481h4.844c-.209 1.125-.843 2.078-1.796 2.717v2.258h2.908c1.702-1.567 2.684-3.875 2.684-6.615z"fill=#4285F4></path><path d="M9 18c2.43 0 4.467-.806 5.956-2.184l-2.908-2.258c-.806.54-1.837.86-3.048.86-2.344 0-4.328-1.584-5.036-3.711H.957v2.332C2.438 15.983 5.482 18 9 18z"fill=#34A853></path><path d="M3.964 10.707c-.18-.54-.282-1.117-.282-1.707s.102-1.167.282-1.707V4.961H.957C.347 6.175 0 7.548 0 9s.348 2.825.957 4.039l3.007-2.332z"fill=#FBBC05></path><path d="M9 3.58c1.321 0 2.508.454 3.44 1.345l2.582-2.58C13.463.891 11.426 0 9 0 5.482 0 2.438 2.017.957 4.961L3.964 7.293C4.672 5.166 6.656 3.58 9 3.58z"fill=#EA4335>'),mu=A('<svg width=18 height=18 viewBox="0 0 16 16"xmlns=http://www.w3.org/2000/svg><path fill-rule=evenodd d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"fill=currentColor>'),bu=A('<svg width=18 height=18 viewBox="20 16 16 19"xmlns=http://www.w3.org/2000/svg><path d="M28.2226562,20.3846154 C29.0546875,20.3846154 30.0976562,19.8048315 30.71875,19.0317864 C31.28125,18.3312142 31.6914062,17.352829 31.6914062,16.3744437 C31.6914062,16.2415766 31.6796875,16.1087095 31.65625,16 C30.7304687,16.0362365 29.6171875,16.640178 28.9492187,17.4494596 C28.421875,18.06548 27.9414062,19.0317864 27.9414062,20.0222505 C27.9414062,20.1671964 27.9648438,20.3121424 27.9765625,20.3604577 C28.0351562,20.3725366 28.1289062,20.3846154 28.2226562,20.3846154 Z M25.2929688,35 C26.4296875,35 26.9335938,34.214876 28.3515625,34.214876 C29.7929688,34.214876 30.109375,34.9758423 31.375,34.9758423 C32.6171875,34.9758423 33.4492188,33.792117 34.234375,32.6325493 C35.1132812,31.3038779 35.4765625,29.9993643 35.5,29.9389701 C35.4179688,29.9148125 33.0390625,28.9122695 33.0390625,26.0979021 C33.0390625,23.6579784 34.9140625,22.5588048 35.0195312,22.474253 C33.7773438,20.6382708 31.890625,20.5899555 31.375,20.5899555 C29.9804688,20.5899555 28.84375,21.4596313 28.1289062,21.4596313 C27.3554688,21.4596313 26.3359375,20.6382708 25.1289062,20.6382708 C22.8320312,20.6382708 20.5,22.5950413 20.5,26.2911634 C20.5,28.5861411 21.3671875,31.013986 22.4335938,32.5842339 C23.3476562,33.9129053 24.1445312,35 25.2929688,35 Z"fill=currentColor fill-rule=nonzero>'),vu=A('<svg width=18 height=18 viewBox="0 0 24 24"xmlns=http://www.w3.org/2000/svg><path d="M12 1L3 5v6c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V5l-9-4zm0 4a3 3 0 110 6 3 3 0 010-6zm0 14c-2.5 0-4.71-1.28-6-3.22.03-1.99 4-3.08 6-3.08s5.97 1.09 6 3.08c-1.29 1.94-3.5 3.22-6 3.22z"fill=currentColor>'),Cu=A("<div class=loading-overlay part=loading-overlay><slot name=loading>");dt("spartan-login",{domain:"http://127.0.0.1:11000",sector:"0ad5c3e5-0186-4557-8b32-4b36f247bf09",startMode:"password",styles:"",locale:"en",redirect:""},e=>{const[t,n]=C((e.startMode||"password").toLowerCase()),[r,s]=C(""),[i,u]=C(""),[o,w]=C(""),[$,D]=C(""),[k]=C(e.redirect),[oe,he]=C(!1),[ye,R]=C(!1),[X,Q]=C(!1),[le,H]=C(""),[ne,K]=C(""),[Ae,$e]=C([]),[Ee,B]=C(""),[ee,ke]=C([]),[pe,me]=C(""),[b,be]=C(!1),[Je,ve]=C(!1),[je,Ve]=C(""),[Ke,Oe]=C(""),[Ie,Pe]=C(""),[Re,Ce]=C(""),[Se,_e]=C(""),[E,v]=C(""),[x,j]=C(!1),d=ft(e.locale);let _,I=null,N;const L=()=>b()||!!pe();rn(()=>{I&&clearTimeout(I)});try{N=e.styles}catch{N=""}console.log(N),at(async()=>{const l=new URLSearchParams(window.location.search);if(l.get("error")){history.replaceState({},"",window.location.pathname);const De=l.get("error_description");D(De||d.i18n("sa-social-error")),q(),M();return}const F=l.get("code");if(F){history.replaceState({},"",window.location.pathname),be(!0);try{const De=await fetch(`${e.domain}/api/v1/oauth/exchange`,{method:"POST",mode:"cors",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:F})});if(!De.ok)throw new Error(d.i18n("sa-social-error"));const W=await De.json();localStorage.setItem("spartan-token",W.token);const a=_.getRootNode().host;e.redirect!==""?(a.dispatchEvent(new CustomEvent("spartan-login",{bubbles:!0,cancelable:!0,detail:{token:W.token}})),window.location.href=e.redirect):(I=setTimeout(()=>{I=null,be(!1),q(),M()},5e3),a.dispatchEvent(new CustomEvent("spartan-login",{bubbles:!0,cancelable:!0,detail:{token:W.token}})))}catch(De){D(De.message||d.i18n("sa-social-error")),be(!1),q(),M()}return}const ae=l.get("sub");if(ae){Pe(ae);const De=l.get("email");De&&Ce(De);const a=new URLSearchParams(window.location.hash.replace(/^#/,"")).get("otp");a&&_e(a),n("invite");return}if(Kt()&&e.redirect!==""&&window.location.pathname!==e.redirect){window.location.href=e.redirect;return}q(),M()});function q(){fetch(`${e.domain}/api/v1/sectors/${e.sector}/publicsettings`,{method:"GET",mode:"cors",cache:"no-cache",headers:{"Content-Type":"application/json"}}).then(l=>{if(l.ok)return l.json();throw new Error("Network response was not ok.")}).then(l=>{console.log(l),he(l.SelfSignUpAllowed),ve(l.MFARequired||!1)}).catch(l=>{console.log(l),D(l.message)})}function M(){fetch(`${e.domain}/api/v1/sectors/${e.sector}/oauth/providers`,{method:"GET",mode:"cors",cache:"no-cache"}).then(l=>{if(l.ok)return l.json();throw new Error("Failed to load social providers")}).then(l=>{const g=(l.providers||[]).filter(F=>F.enabled);ke(g)}).catch(()=>{})}function U(l){if(pe())return;me(l),D("");const g=window.location.origin+window.location.pathname;fetch(`${e.domain}/api/v1/oauth/${l}/initiate`,{method:"POST",mode:"cors",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify({sectorID:e.sector,redirectURI:g})}).then(F=>{if(F.ok)return F.json();throw new Error(d.i18n("sa-social-error"))}).then(F=>{window.location.href=F.authURL}).catch(F=>{me(""),D(F.message)})}function G(l,g){return D(""),Oe(g),fetch(`${e.domain}/api/v1/signup/mfa/begin`,{method:"POST",mode:"cors",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:l,sectorID:e.sector,transactionId:g})}).then(F=>{if(!F.ok)throw new Error(d.i18n("sa-signup-verify-error"))}).then(()=>{n("signup-verify")}).catch(F=>{D(F.message)})}function ce(){return D(""),fetch(`${e.domain}/api/v1/signup/mfa/verify`,{method:"POST",mode:"cors",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:r(),code:o().toUpperCase().trim(),sectorID:e.sector,transactionId:Ke()})}).then(l=>{if(l.ok)return l.json();throw l.status===400?new Error(d.i18n("sa-signup-verify-error")):new Error(d.i18n("sa-signup-verify-error"))}).then(l=>{Ve(l.token),localStorage.setItem("spartan-token",l.token),_.getRootNode().host.dispatchEvent(new CustomEvent("spartan-login",{bubbles:!0,cancelable:!0,detail:{token:l.token}})),w(""),n("signup-webauthn")}).catch(l=>{D(l.message)})}function J(){b()||(be(!0),D(""),fetch(`${e.domain}/api/v1/webauthn/registration/begin`,{method:"POST",mode:"cors",cache:"no-cache",headers:{"Content-Type":"application/json",Authorization:`bearer ${je()}`},body:JSON.stringify({keyName:"Default",sectorID:e.sector})}).then(l=>{if(!l.ok)throw new Error(d.i18n("sa-signup-webauthn-error"));return l.json()}).then(l=>{const g=Ut(l.Options);return Jt(g).then(F=>{let ae=JSON.parse(JSON.stringify(F));return ae.transactionID=l.TransactionID,ae})}).then(l=>fetch(`${e.domain}/api/v1/webauthn/registration/finish`,{method:"POST",mode:"cors",cache:"no-cache",headers:{"Content-Type":"application/json",Authorization:`bearer ${je()}`},body:JSON.stringify(l)})).then(l=>{if(!l.ok)throw new Error(d.i18n("sa-signup-webauthn-error"));c()}).catch(l=>{D((l==null?void 0:l.message)||String(l))}).finally(()=>{be(!1)}))}function c(){n(e.startMode),e.redirect!==""&&(window.location.href=e.redirect)}function m(){return console.log("login"),D(""),t()==="password"?te():t()==="webauthn"?S():t()==="otp-pick"?de(Ee()):t()==="otp"?Be():t()==="reset-email"?mt():t()==="reset-code"?bt():Promise.resolve()}function O(){return console.log("signup"),D(""),R(!1),fetch(`${e.domain}/api/v1/users`,{method:"POST",mode:"cors",cache:"no-cache",body:JSON.stringify({username:r(),password:i(),sectorID:e.sector})}).then(l=>{if(l.ok)return l.json();throw new Error(d.i18n("sa-error-creating-user"))}).then(l=>{if(console.log(l),Je())return G(r(),l.enrollmentTransactionId||"");R(!0),n(e.startMode)}).catch(l=>{R(!1),D(l.message),console.log(l)})}function S(){return console.log("webauthnLogin"),fetch(`${e.domain}/api/v1/login/webauthn/begin`,{method:"POST",mode:"cors",cache:"no-cache",body:JSON.stringify({username:r(),sectorID:e.sector})}).then(l=>{if(l.ok)return l.json();throw l.status===401?(n("password"),D(d.i18n("webauthn-not-enrolled")),new Error(d.i18n("webauthn-not-enrolled"))):new Error(`${l.status} ${l.statusText}: Network response was not ok.`)}).then(l=>{console.log(l);const g=Ha(l.CredentialAssertion);return console.log("Parsed WebAuthn request options:",g),Za(g).then(F=>{const ae=JSON.stringify(F);let Te=JSON.parse(ae);return Te.transactionID=l.TransactionID,Te})}).then(l=>fetch(`${e.domain}/api/v1/login/webauthn/finish`,{method:"POST",mode:"cors",cache:"no-cache",body:JSON.stringify(l)})).then(re).catch(l=>{D(l.message),console.log(l)})}function te(){return console.log("password login"),fetch(e.domain+"/api/v1/login/password",{method:"post",mode:"cors",cache:"no-cache",body:JSON.stringify({username:r(),password:i(),sectorID:e.sector})}).then(re)}function re(l){return Promise.resolve(l).then(g=>{if(g.ok)return g.json();throw g}).then(g=>{if(console.log(g),localStorage.setItem("spartan-txid",g.transactionID),!g.token){if(g.challengeType==="email_enrollment")return G(r(),g.transactionID||"");if(g.challengeType.indexOf("otp")!==-1)return ie();g.challengeType.indexOf("webauthn")!==-1?(n("webauthn"),D(d.i18n("sa-webauthn-required"))):D(d.i18n("sa-unknown-challenge"));return}localStorage.setItem("spartan-token",g.token);const F=new CustomEvent("spartan-login",{bubbles:!0,cancelable:!0,detail:{token:g.token,transactionID:g.transactionID}});_.getRootNode().host.dispatchEvent(F),k()!==""&&(window.location.href=k())}).catch(g=>g.json().then(F=>{console.log(F.message),D(F.message)}).catch(F=>{console.log(F)}))}function ie(){const l=localStorage.getItem("spartan-txid")||"";return fetch(e.domain+`/api/v1/otp/${encodeURIComponent(r())}?transactionID=${encodeURIComponent(l)}§orID=${encodeURIComponent(e.sector)}`,{method:"get",mode:"cors",cache:"no-cache"}).then(g=>{if(g.ok)return g.json();throw new Error(d.i18n("error-otp-list"))}).then(g=>{const F=g.registrations||[];if(F.length===0){D(d.i18n("sa-otp-no-registrations"));return}if(F.length===1)return de(F[0].ID||"");$e(F),B(F[0].ID||""),n("otp-pick"),D("")}).catch(g=>{D(g.message),console.log(g)})}function de(l){return console.log("begin OTP, registrationID:",l),fetch(e.domain+"/api/v1/login/otp/begin",{method:"post",mode:"cors",cache:"no-cache",body:JSON.stringify({username:r(),transactionID:localStorage.getItem("spartan-txid"),registrationID:l,sectorID:e.sector})}).then(g=>{if(g.ok)return g.json();throw new Error(`${g.status} ${g.statusText}`)}).then(g=>{console.log(g),g.transactionID&&localStorage.setItem("spartan-txid",g.transactionID),w(""),D(""),n("otp")}).catch(g=>{D(g.message),console.log(g)})}function Be(){return console.log("OTP login submit"),fetch(e.domain+"/api/v1/login/otp",{method:"post",mode:"cors",cache:"no-cache",body:JSON.stringify({username:r(),password:o(),transactionID:localStorage.getItem("spartan-txid"),sectorID:e.sector})}).then(re)}function mt(){return console.log("begin password reset"),D(""),Q(!1),fetch(`${e.domain}/api/v1/password/reset/begin`,{method:"POST",mode:"cors",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:r(),sectorID:e.sector})}).then(l=>{if(l.ok)return l.json();throw new Error(d.i18n("sa-reset-error"))}).then(l=>{console.log(l),D(d.i18n("sa-reset-email-sent")),H(""),K(""),n("reset-code")}).catch(l=>{D(l.message),console.log(l)})}function bt(){return console.log("complete password reset"),D(""),fetch(`${e.domain}/api/v1/password/reset/complete`,{method:"POST",mode:"cors",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:r(),code:le().toUpperCase().trim(),newPassword:ne(),sectorID:e.sector})}).then(l=>{if(l.ok)return l.json();throw l.status===400?new Error(d.i18n("sa-reset-error-code")):new Error(d.i18n("sa-reset-error"))}).then(l=>{console.log(l),Q(!0),H(""),K(""),u(""),n(e.startMode)}).catch(l=>{D(l.message),console.log(l)})}async function rt(){if(D(""),!Se()||Se().trim().length===0){D(d.i18n("sa-invite-error-otp"));return}if(!E()||E().length<8){D("Password must be at least 8 characters");return}const l=Ie();if(!l){D("Missing invitation information");return}const g=await fetch(`${e.domain}/api/v1/users/invite/complete`,{method:"POST",mode:"cors",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify({sub:l,otp:Se().toUpperCase().trim(),password:E(),sectorID:e.sector})}).catch(()=>null);if(!g){D(d.i18n("sa-invite-error-generic"));return}if(g.ok){history.replaceState({},"",window.location.pathname);const F=await g.json().catch(()=>({})),ae=_.getRootNode().host;F.token?(localStorage.setItem("spartan-token",F.token),ae.dispatchEvent(new CustomEvent("spartan-login",{bubbles:!0,cancelable:!0,detail:{token:F.token}})),k()!==""?window.location.href=k():e.redirect!==""?window.location.href=e.redirect:(j(!1),Pe(""),Ce(""),_e(""),v(""),n(e.startMode),q(),M())):(j(!0),ae.dispatchEvent(new CustomEvent("spartan-invite-complete",{bubbles:!0,cancelable:!0,detail:{sub:l,success:!0}})),setTimeout(()=>{k()!==""?window.location.href=k():e.redirect!==""?window.location.href=e.redirect:(j(!1),Pe(""),Ce(""),_e(""),v(""),n(e.startMode),q(),M())},2e3))}else{const F=await g.json().catch(()=>({}));g.status===400||String(F.message).includes("invalid OTP")?D(d.i18n("sa-invite-error-otp")):g.status===504||String(F.message).includes("expired")?D(d.i18n("sa-invite-error-expired")):D(F.message||d.i18n("sa-invite-error-generic"))}}return(()=>{var l=tu(),g=l.firstChild,F=g.firstChild,ae=F.nextSibling,Te=ae.nextSibling,De=_;return typeof De=="function"?kt(De,g):_=g,g.addEventListener("submit",W=>{if(W.preventDefault(),b())return;be(!0),(t()==="sign-up"?O():t()==="signup-verify"?ce():t()==="invite"?Promise.resolve(rt()):m()).finally(()=>be(!1))}),f(ae,N),f(Te,(()=>{var W=h(()=>t()==="reset-email"||t()==="reset-code");return()=>W()?d.i18n("sa-reset-password"):h(()=>t()==="signup-verify"||t()==="signup-webauthn")()?d.i18n("sa-signup-mfa-title"):h(()=>t()==="invite")()?d.i18n("sa-complete-invite"):d.i18n("sa-login")})()),f(g,$&&(()=>{var W=nu();return f(W,$),W})(),null),f(g,(()=>{var W=h(()=>!!ye());return()=>W()&&(()=>{var a=Dt();return f(a,()=>d.i18n("sa-signup-complete")),a})()})(),null),f(g,(()=>{var W=h(()=>!!X());return()=>W()&&(()=>{var a=Dt();return f(a,()=>d.i18n("sa-reset-success")),a})()})(),null),f(g,(()=>{var W=h(()=>t()==="invite");return()=>W()&&[h(()=>h(()=>!!Re())()&&(()=>{var a=iu();return f(a,Re),a})()),h(()=>h(()=>!!x())()&&(()=>{var a=au();return f(a,()=>d.i18n("sa-invite-success")),a})()),(()=>{var a=ru();return a.$$input=p=>_e(p.currentTarget.value),y(p=>{var P=d.i18n("sa-invite-otp"),we=b()||x();return P!==p.e&&ue(a,"placeholder",p.e=P),we!==p.t&&(a.disabled=p.t=we),p},{e:void 0,t:void 0}),y(()=>a.value=Se()),a})(),(()=>{var a=Gt();return f(a,()=>d.i18n("sa-invite-otp-hint")),a})(),(()=>{var a=su();return a.$$input=p=>v(p.currentTarget.value),y(p=>{var P=d.i18n("sa-invite-password"),we=b()||x();return P!==p.e&&ue(a,"placeholder",p.e=P),we!==p.t&&(a.disabled=p.t=we),p},{e:void 0,t:void 0}),y(()=>a.value=E()),a})(),(()=>{var a=Gt();return f(a,()=>d.i18n("sa-invite-password-hint")),a})(),(()=>{var a=Ht();return f(a,(()=>{var p=h(()=>!!b());return()=>p()?d.i18n("sa-invite-completing"):d.i18n("sa-invite-submit")})()),y(()=>a.disabled=b()||x()),a})()]})(),null),f(g,(()=>{var W=h(()=>t()!=="invite");return()=>W()&&[(()=>{var a=uu();return a.addEventListener("change",p=>s(p.currentTarget.value)),a.$$input=p=>s(p.currentTarget.value),y(p=>{var P=d.i18n("sa-username"),we=t()==="otp"||t()==="otp-pick"||t()==="reset-code"||t()==="signup-verify"||t()==="signup-webauthn";return P!==p.e&&ue(a,"placeholder",p.e=P),we!==p.t&&(a.disabled=p.t=we),p},{e:void 0,t:void 0}),y(()=>a.value=r()),a})(),h(()=>h(()=>t()!=="sign-up"&&t()!=="signup-verify"&&t()!=="signup-webauthn")()&&[h(()=>h(()=>t()==="password")()&&(()=>{var a=ou();return a.addEventListener("change",p=>u(p.currentTarget.value)),a.$$input=p=>u(p.currentTarget.value),y(()=>ue(a,"placeholder",d.i18n("sa-password"))),y(()=>a.value=i()),a})()),h(()=>h(()=>t()==="webauthn")()&&Dt()),h(()=>h(()=>t()==="otp-pick")()&&[(()=>{var a=gt();return f(a,()=>d.i18n("sa-otp-choose")),a})(),(()=>{var a=lu();return a.addEventListener("change",p=>B(p.currentTarget.value)),f(a,()=>Ae().map(p=>(()=>{var P=cu(),we=P.firstChild,Qt=we.nextSibling;return Qt.nextSibling,f(P,()=>p.DisplayName||p.ID,we),f(P,()=>p.Type,Qt),y(()=>P.value=p.ID),P})())),y(()=>a.value=Ee()),a})()]),h(()=>h(()=>t()==="otp")()&&(()=>{var a=du();return a.$$input=p=>w(p.currentTarget.value),y(()=>ue(a,"placeholder",d.i18n("sa-code"))),y(()=>a.value=o()),a})()),h(()=>h(()=>t()==="reset-code")()&&[(()=>{var a=Wt();return a.$$input=p=>H(p.currentTarget.value),y(()=>ue(a,"placeholder",d.i18n("sa-reset-code"))),y(()=>a.value=le()),a})(),(()=>{var a=Zt();return a.$$input=p=>K(p.currentTarget.value),y(()=>ue(a,"placeholder",d.i18n("sa-new-password"))),y(()=>a.value=ne()),a})()]),h(()=>h(()=>t()==="password"||t()==="webauthn")()&&(()=>{var a=fu(),p=a.firstChild,P=p.nextSibling;return P.firstChild,a.$$click=()=>n(t()==="password"?"webauthn":"password"),f(P,()=>d.i18n("sa-use-password"),null),y(()=>p.checked=t()==="password"),a})())]),h(()=>h(()=>t()==="sign-up")()&&(()=>{var a=Zt();return a.addEventListener("change",p=>u(p.currentTarget.value)),a.$$input=p=>u(p.currentTarget.value),y(()=>ue(a,"placeholder",d.i18n("sa-password"))),y(()=>a.value=i()),a})()),h(()=>h(()=>t()==="signup-verify")()&&[(()=>{var a=gt();return f(a,()=>d.i18n("sa-signup-verify-prompt")),a})(),(()=>{var a=Wt();return a.$$input=p=>w(p.currentTarget.value),y(()=>ue(a,"placeholder",d.i18n("sa-code"))),y(()=>a.value=o()),a})()]),h(()=>h(()=>t()==="signup-webauthn")()&&(()=>{var a=gt();return f(a,()=>d.i18n("sa-signup-webauthn-prompt")),a})()),h(()=>h(()=>t()!=="signup-webauthn")()&&(()=>{var a=Ht();return f(a,(()=>{var p=h(()=>!!b());return()=>p()?d.i18n("sa-loading"):h(()=>t()==="sign-up")()?d.i18n("sa-signup"):h(()=>t()==="otp-pick")()?d.i18n("sa-otp-send-code"):h(()=>t()==="otp")()?d.i18n("sa-otp-verify"):h(()=>t()==="reset-email")()?d.i18n("sa-otp-send-code"):h(()=>t()==="reset-code")()?d.i18n("sa-reset-submit"):h(()=>t()==="signup-verify")()?d.i18n("sa-otp-verify"):d.i18n("sa-login")})()),y(()=>a.disabled=b()),a})()),h(()=>h(()=>t()==="signup-webauthn")()&&[(()=>{var a=hu();return a.$$click=()=>J(),f(a,(()=>{var p=h(()=>!!b());return()=>p()?d.i18n("sa-loading"):d.i18n("sa-signup-webauthn-setup")})()),y(()=>a.disabled=b()),a})(),(()=>{var a=nt();return a.$$click=()=>c(),f(a,()=>d.i18n("sa-signup-webauthn-done")),a})()]),h(()=>h(()=>t()==="password")()&&(()=>{var a=nt();return a.$$click=()=>{D(""),Q(!1),n("reset-email")},f(a,()=>d.i18n("sa-forgot-password")),a})()),h(()=>h(()=>t()==="reset-email"||t()==="reset-code")()&&(()=>{var a=nt();return a.$$click=()=>{D(""),H(""),K(""),n(e.startMode)},f(a,()=>d.i18n("sa-back")),a})()),h(()=>h(()=>!!(oe()&&t()!=="reset-email"&&t()!=="reset-code"&&t()!=="signup-verify"&&t()!=="signup-webauthn"))()&&(()=>{var a=nt();return a.$$click=()=>t()==="sign-up"?n(e.startMode):n("sign-up"),f(a,(()=>{var p=h(()=>t()==="sign-up");return()=>p()?d.i18n("sa-back"):d.i18n("sa-signup")})()),a})()),h(()=>h(()=>ee().length>0&&(t()==="password"||t()==="webauthn"||t()==="sign-up"))()&&[(()=>{var a=pu(),p=a.firstChild;return f(p,()=>d.i18n("sa-or")),a})(),h(()=>ee().map(a=>(()=>{var p=Du();return p.$$click=()=>U(a.provider),f(p,(()=>{var P=h(()=>a.provider==="google");return()=>P()&&gu()})(),null),f(p,(()=>{var P=h(()=>a.provider==="github");return()=>P()&&mu()})(),null),f(p,(()=>{var P=h(()=>a.provider==="apple");return()=>P()&&bu()})(),null),f(p,(()=>{var P=h(()=>a.provider==="oidc");return()=>P()&&vu()})(),null),f(p,(()=>{var P=h(()=>a.provider==="google");return()=>P()?d.i18n("sa-social-google"):h(()=>a.provider==="github")()?d.i18n("sa-social-github"):h(()=>a.provider==="apple")()?d.i18n("sa-social-apple"):d.i18n("sa-social-oidc")})(),null),y(()=>p.disabled=!!pe()||b()),p})()))])]})(),null),f(l,(()=>{var W=h(()=>!!L());return()=>W()&&(()=>{var a=Cu(),p=a.firstChild;return p._$owner=sn(),f(p,()=>d.i18n("sa-loading")),a})()})(),null),l})()}),ot(["input","click"]);var wu=A(`<div class=container><style>.container {
|
|
147
|
+
</style><style></style><h1>`),nu=A("<span class=error-message>"),Dt=A("<span>"),ru=A("<input type=text autocomplete=one-time-code required>"),Gt=A("<span class=hint>"),su=A("<input type=password autocomplete=new-password required>"),Ht=A("<button type=submit>"),iu=A("<span class=info-message>"),au=A("<span class=success-message>"),uu=A("<input type=text autocomplete=username>"),ou=A("<input type=password autocomplete=current-password>"),gt=A("<p>"),lu=A("<select>"),cu=A("<option> (<!>)"),du=A("<input type=text>"),Wt=A("<input type=text autocomplete=one-time-code>"),Zt=A("<input type=password autocomplete=new-password>"),fu=A("<span class=checkbox-wrapper><input type=checkbox><span> "),hu=A("<button type=button>"),nt=A("<a class=centered-text href=#>"),pu=A("<div class=social-divider><span>"),Du=A("<button type=button class=social-btn>"),gu=A('<svg width=18 height=18 viewBox="0 0 18 18"xmlns=http://www.w3.org/2000/svg><path d="M17.64 9.2c0-.637-.057-1.251-.164-1.84H9v3.481h4.844c-.209 1.125-.843 2.078-1.796 2.717v2.258h2.908c1.702-1.567 2.684-3.875 2.684-6.615z"fill=#4285F4></path><path d="M9 18c2.43 0 4.467-.806 5.956-2.184l-2.908-2.258c-.806.54-1.837.86-3.048.86-2.344 0-4.328-1.584-5.036-3.711H.957v2.332C2.438 15.983 5.482 18 9 18z"fill=#34A853></path><path d="M3.964 10.707c-.18-.54-.282-1.117-.282-1.707s.102-1.167.282-1.707V4.961H.957C.347 6.175 0 7.548 0 9s.348 2.825.957 4.039l3.007-2.332z"fill=#FBBC05></path><path d="M9 3.58c1.321 0 2.508.454 3.44 1.345l2.582-2.58C13.463.891 11.426 0 9 0 5.482 0 2.438 2.017.957 4.961L3.964 7.293C4.672 5.166 6.656 3.58 9 3.58z"fill=#EA4335>'),mu=A('<svg width=18 height=18 viewBox="0 0 16 16"xmlns=http://www.w3.org/2000/svg><path fill-rule=evenodd d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"fill=currentColor>'),bu=A('<svg width=18 height=18 viewBox="20 16 16 19"xmlns=http://www.w3.org/2000/svg><path d="M28.2226562,20.3846154 C29.0546875,20.3846154 30.0976562,19.8048315 30.71875,19.0317864 C31.28125,18.3312142 31.6914062,17.352829 31.6914062,16.3744437 C31.6914062,16.2415766 31.6796875,16.1087095 31.65625,16 C30.7304687,16.0362365 29.6171875,16.640178 28.9492187,17.4494596 C28.421875,18.06548 27.9414062,19.0317864 27.9414062,20.0222505 C27.9414062,20.1671964 27.9648438,20.3121424 27.9765625,20.3604577 C28.0351562,20.3725366 28.1289062,20.3846154 28.2226562,20.3846154 Z M25.2929688,35 C26.4296875,35 26.9335938,34.214876 28.3515625,34.214876 C29.7929688,34.214876 30.109375,34.9758423 31.375,34.9758423 C32.6171875,34.9758423 33.4492188,33.792117 34.234375,32.6325493 C35.1132812,31.3038779 35.4765625,29.9993643 35.5,29.9389701 C35.4179688,29.9148125 33.0390625,28.9122695 33.0390625,26.0979021 C33.0390625,23.6579784 34.9140625,22.5588048 35.0195312,22.474253 C33.7773438,20.6382708 31.890625,20.5899555 31.375,20.5899555 C29.9804688,20.5899555 28.84375,21.4596313 28.1289062,21.4596313 C27.3554688,21.4596313 26.3359375,20.6382708 25.1289062,20.6382708 C22.8320312,20.6382708 20.5,22.5950413 20.5,26.2911634 C20.5,28.5861411 21.3671875,31.013986 22.4335938,32.5842339 C23.3476562,33.9129053 24.1445312,35 25.2929688,35 Z"fill=currentColor fill-rule=nonzero>'),vu=A('<svg width=18 height=18 viewBox="0 0 24 24"xmlns=http://www.w3.org/2000/svg><path d="M12 1L3 5v6c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V5l-9-4zm0 4a3 3 0 110 6 3 3 0 010-6zm0 14c-2.5 0-4.71-1.28-6-3.22.03-1.99 4-3.08 6-3.08s5.97 1.09 6 3.08c-1.29 1.94-3.5 3.22-6 3.22z"fill=currentColor>'),Cu=A("<div class=loading-overlay part=loading-overlay><slot name=loading>");dt("spartan-login",{domain:"http://127.0.0.1:11000",sector:"0ad5c3e5-0186-4557-8b32-4b36f247bf09",startMode:"password",styles:"",locale:"en",redirect:"",hideSocial:!1},e=>{const[t,n]=C((e.startMode||"password").toLowerCase()),[r,s]=C(""),[i,u]=C(""),[o,w]=C(""),[$,D]=C(""),[k]=C(e.redirect),[oe,he]=C(!1),[ye,R]=C(!1),[X,Q]=C(!1),[le,H]=C(""),[ne,K]=C(""),[Ae,$e]=C([]),[Ee,B]=C(""),[ee,ke]=C([]),[pe,me]=C(""),[b,be]=C(!1),[Je,ve]=C(!1),[je,Ve]=C(""),[Ke,Oe]=C(""),[Ie,Pe]=C(""),[Re,Ce]=C(""),[Se,_e]=C(""),[E,v]=C(""),[x,j]=C(!1),d=ft(e.locale);let _,I=null,N;const L=()=>b()||!!pe();rn(()=>{I&&clearTimeout(I)});try{N=e.styles}catch{N=""}console.log(N),at(async()=>{const l=new URLSearchParams(window.location.search);if(l.get("error")){history.replaceState({},"",window.location.pathname);const De=l.get("error_description");D(De||d.i18n("sa-social-error")),q(),M();return}const F=l.get("code");if(F){history.replaceState({},"",window.location.pathname),be(!0);try{const De=await fetch(`${e.domain}/api/v1/oauth/exchange`,{method:"POST",mode:"cors",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:F})});if(!De.ok)throw new Error(d.i18n("sa-social-error"));const W=await De.json();localStorage.setItem("spartan-token",W.token);const a=_.getRootNode().host;e.redirect!==""?(a.dispatchEvent(new CustomEvent("spartan-login",{bubbles:!0,cancelable:!0,detail:{token:W.token}})),window.location.href=e.redirect):(I=setTimeout(()=>{I=null,be(!1),q(),M()},5e3),a.dispatchEvent(new CustomEvent("spartan-login",{bubbles:!0,cancelable:!0,detail:{token:W.token}})))}catch(De){D(De.message||d.i18n("sa-social-error")),be(!1),q(),M()}return}const ae=l.get("sub");if(ae){Pe(ae);const De=l.get("email");De&&Ce(De);const a=new URLSearchParams(window.location.hash.replace(/^#/,"")).get("otp");a&&_e(a),n("invite");return}if(Kt()&&e.redirect!==""&&window.location.pathname!==e.redirect){window.location.href=e.redirect;return}q(),M()});function q(){fetch(`${e.domain}/api/v1/sectors/${e.sector}/publicsettings`,{method:"GET",mode:"cors",cache:"no-cache",headers:{"Content-Type":"application/json"}}).then(l=>{if(l.ok)return l.json();throw new Error("Network response was not ok.")}).then(l=>{console.log(l),he(l.SelfSignUpAllowed),ve(l.MFARequired||!1)}).catch(l=>{console.log(l),D(l.message)})}function M(){e.hideSocial||fetch(`${e.domain}/api/v1/sectors/${e.sector}/oauth/providers`,{method:"GET",mode:"cors",cache:"no-cache"}).then(l=>{if(l.ok)return l.json();throw new Error("Failed to load social providers")}).then(l=>{const g=(l.providers||[]).filter(F=>F.enabled);ke(g)}).catch(()=>{})}function U(l){if(pe())return;me(l),D("");const g=window.location.origin+window.location.pathname;fetch(`${e.domain}/api/v1/oauth/${l}/initiate`,{method:"POST",mode:"cors",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify({sectorID:e.sector,redirectURI:g})}).then(F=>{if(F.ok)return F.json();throw new Error(d.i18n("sa-social-error"))}).then(F=>{window.location.href=F.authURL}).catch(F=>{me(""),D(F.message)})}function G(l,g){return D(""),Oe(g),fetch(`${e.domain}/api/v1/signup/mfa/begin`,{method:"POST",mode:"cors",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:l,sectorID:e.sector,transactionId:g})}).then(F=>{if(!F.ok)throw new Error(d.i18n("sa-signup-verify-error"))}).then(()=>{n("signup-verify")}).catch(F=>{D(F.message)})}function ce(){return D(""),fetch(`${e.domain}/api/v1/signup/mfa/verify`,{method:"POST",mode:"cors",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:r(),code:o().toUpperCase().trim(),sectorID:e.sector,transactionId:Ke()})}).then(l=>{if(l.ok)return l.json();throw l.status===400?new Error(d.i18n("sa-signup-verify-error")):new Error(d.i18n("sa-signup-verify-error"))}).then(l=>{Ve(l.token),localStorage.setItem("spartan-token",l.token),_.getRootNode().host.dispatchEvent(new CustomEvent("spartan-login",{bubbles:!0,cancelable:!0,detail:{token:l.token}})),w(""),n("signup-webauthn")}).catch(l=>{D(l.message)})}function J(){b()||(be(!0),D(""),fetch(`${e.domain}/api/v1/webauthn/registration/begin`,{method:"POST",mode:"cors",cache:"no-cache",headers:{"Content-Type":"application/json",Authorization:`bearer ${je()}`},body:JSON.stringify({keyName:"Default",sectorID:e.sector})}).then(l=>{if(!l.ok)throw new Error(d.i18n("sa-signup-webauthn-error"));return l.json()}).then(l=>{const g=Ut(l.Options);return Jt(g).then(F=>{let ae=JSON.parse(JSON.stringify(F));return ae.transactionID=l.TransactionID,ae})}).then(l=>fetch(`${e.domain}/api/v1/webauthn/registration/finish`,{method:"POST",mode:"cors",cache:"no-cache",headers:{"Content-Type":"application/json",Authorization:`bearer ${je()}`},body:JSON.stringify(l)})).then(l=>{if(!l.ok)throw new Error(d.i18n("sa-signup-webauthn-error"));c()}).catch(l=>{D((l==null?void 0:l.message)||String(l))}).finally(()=>{be(!1)}))}function c(){n(e.startMode),e.redirect!==""&&(window.location.href=e.redirect)}function m(){return console.log("login"),D(""),t()==="password"?te():t()==="webauthn"?S():t()==="otp-pick"?de(Ee()):t()==="otp"?Be():t()==="reset-email"?mt():t()==="reset-code"?bt():Promise.resolve()}function O(){return console.log("signup"),D(""),R(!1),fetch(`${e.domain}/api/v1/users`,{method:"POST",mode:"cors",cache:"no-cache",body:JSON.stringify({username:r(),password:i(),sectorID:e.sector})}).then(l=>{if(l.ok)return l.json();throw new Error(d.i18n("sa-error-creating-user"))}).then(l=>{if(console.log(l),Je())return G(r(),l.enrollmentTransactionId||"");R(!0),n(e.startMode)}).catch(l=>{R(!1),D(l.message),console.log(l)})}function S(){return console.log("webauthnLogin"),fetch(`${e.domain}/api/v1/login/webauthn/begin`,{method:"POST",mode:"cors",cache:"no-cache",body:JSON.stringify({username:r(),sectorID:e.sector})}).then(l=>{if(l.ok)return l.json();throw l.status===401?(n("password"),D(d.i18n("webauthn-not-enrolled")),new Error(d.i18n("webauthn-not-enrolled"))):new Error(`${l.status} ${l.statusText}: Network response was not ok.`)}).then(l=>{console.log(l);const g=Ha(l.CredentialAssertion);return console.log("Parsed WebAuthn request options:",g),Za(g).then(F=>{const ae=JSON.stringify(F);let Te=JSON.parse(ae);return Te.transactionID=l.TransactionID,Te})}).then(l=>fetch(`${e.domain}/api/v1/login/webauthn/finish`,{method:"POST",mode:"cors",cache:"no-cache",body:JSON.stringify(l)})).then(re).catch(l=>{D(l.message),console.log(l)})}function te(){return console.log("password login"),fetch(e.domain+"/api/v1/login/password",{method:"post",mode:"cors",cache:"no-cache",body:JSON.stringify({username:r(),password:i(),sectorID:e.sector})}).then(re)}function re(l){return Promise.resolve(l).then(g=>{if(g.ok)return g.json();throw g}).then(g=>{if(console.log(g),localStorage.setItem("spartan-txid",g.transactionID),!g.token){if(g.challengeType==="email_enrollment")return G(r(),g.transactionID||"");if(g.challengeType.indexOf("otp")!==-1)return ie();g.challengeType.indexOf("webauthn")!==-1?(n("webauthn"),D(d.i18n("sa-webauthn-required"))):D(d.i18n("sa-unknown-challenge"));return}localStorage.setItem("spartan-token",g.token);const F=new CustomEvent("spartan-login",{bubbles:!0,cancelable:!0,detail:{token:g.token,transactionID:g.transactionID}});_.getRootNode().host.dispatchEvent(F),k()!==""&&(window.location.href=k())}).catch(g=>g.json().then(F=>{console.log(F.message),D(F.message)}).catch(F=>{console.log(F)}))}function ie(){const l=localStorage.getItem("spartan-txid")||"";return fetch(e.domain+`/api/v1/otp/${encodeURIComponent(r())}?transactionID=${encodeURIComponent(l)}§orID=${encodeURIComponent(e.sector)}`,{method:"get",mode:"cors",cache:"no-cache"}).then(g=>{if(g.ok)return g.json();throw new Error(d.i18n("error-otp-list"))}).then(g=>{const F=g.registrations||[];if(F.length===0){D(d.i18n("sa-otp-no-registrations"));return}if(F.length===1)return de(F[0].ID||"");$e(F),B(F[0].ID||""),n("otp-pick"),D("")}).catch(g=>{D(g.message),console.log(g)})}function de(l){return console.log("begin OTP, registrationID:",l),fetch(e.domain+"/api/v1/login/otp/begin",{method:"post",mode:"cors",cache:"no-cache",body:JSON.stringify({username:r(),transactionID:localStorage.getItem("spartan-txid"),registrationID:l,sectorID:e.sector})}).then(g=>{if(g.ok)return g.json();throw new Error(`${g.status} ${g.statusText}`)}).then(g=>{console.log(g),g.transactionID&&localStorage.setItem("spartan-txid",g.transactionID),w(""),D(""),n("otp")}).catch(g=>{D(g.message),console.log(g)})}function Be(){return console.log("OTP login submit"),fetch(e.domain+"/api/v1/login/otp",{method:"post",mode:"cors",cache:"no-cache",body:JSON.stringify({username:r(),password:o(),transactionID:localStorage.getItem("spartan-txid"),sectorID:e.sector})}).then(re)}function mt(){return console.log("begin password reset"),D(""),Q(!1),fetch(`${e.domain}/api/v1/password/reset/begin`,{method:"POST",mode:"cors",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:r(),sectorID:e.sector})}).then(l=>{if(l.ok)return l.json();throw new Error(d.i18n("sa-reset-error"))}).then(l=>{console.log(l),D(d.i18n("sa-reset-email-sent")),H(""),K(""),n("reset-code")}).catch(l=>{D(l.message),console.log(l)})}function bt(){return console.log("complete password reset"),D(""),fetch(`${e.domain}/api/v1/password/reset/complete`,{method:"POST",mode:"cors",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:r(),code:le().toUpperCase().trim(),newPassword:ne(),sectorID:e.sector})}).then(l=>{if(l.ok)return l.json();throw l.status===400?new Error(d.i18n("sa-reset-error-code")):new Error(d.i18n("sa-reset-error"))}).then(l=>{console.log(l),Q(!0),H(""),K(""),u(""),n(e.startMode)}).catch(l=>{D(l.message),console.log(l)})}async function rt(){if(D(""),!Se()||Se().trim().length===0){D(d.i18n("sa-invite-error-otp"));return}if(!E()||E().length<8){D("Password must be at least 8 characters");return}const l=Ie();if(!l){D("Missing invitation information");return}const g=await fetch(`${e.domain}/api/v1/users/invite/complete`,{method:"POST",mode:"cors",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify({sub:l,otp:Se().toUpperCase().trim(),password:E(),sectorID:e.sector})}).catch(()=>null);if(!g){D(d.i18n("sa-invite-error-generic"));return}if(g.ok){history.replaceState({},"",window.location.pathname);const F=await g.json().catch(()=>({})),ae=_.getRootNode().host;F.token?(localStorage.setItem("spartan-token",F.token),ae.dispatchEvent(new CustomEvent("spartan-login",{bubbles:!0,cancelable:!0,detail:{token:F.token}})),k()!==""?window.location.href=k():e.redirect!==""?window.location.href=e.redirect:(j(!1),Pe(""),Ce(""),_e(""),v(""),n(e.startMode),q(),M())):(j(!0),ae.dispatchEvent(new CustomEvent("spartan-invite-complete",{bubbles:!0,cancelable:!0,detail:{sub:l,success:!0}})),setTimeout(()=>{k()!==""?window.location.href=k():e.redirect!==""?window.location.href=e.redirect:(j(!1),Pe(""),Ce(""),_e(""),v(""),n(e.startMode),q(),M())},2e3))}else{const F=await g.json().catch(()=>({}));g.status===400||String(F.message).includes("invalid OTP")?D(d.i18n("sa-invite-error-otp")):g.status===504||String(F.message).includes("expired")?D(d.i18n("sa-invite-error-expired")):D(F.message||d.i18n("sa-invite-error-generic"))}}return(()=>{var l=tu(),g=l.firstChild,F=g.firstChild,ae=F.nextSibling,Te=ae.nextSibling,De=_;return typeof De=="function"?kt(De,g):_=g,g.addEventListener("submit",W=>{if(W.preventDefault(),b())return;be(!0),(t()==="sign-up"?O():t()==="signup-verify"?ce():t()==="invite"?Promise.resolve(rt()):m()).finally(()=>be(!1))}),f(ae,N),f(Te,(()=>{var W=h(()=>t()==="reset-email"||t()==="reset-code");return()=>W()?d.i18n("sa-reset-password"):h(()=>t()==="signup-verify"||t()==="signup-webauthn")()?d.i18n("sa-signup-mfa-title"):h(()=>t()==="invite")()?d.i18n("sa-complete-invite"):d.i18n("sa-login")})()),f(g,$&&(()=>{var W=nu();return f(W,$),W})(),null),f(g,(()=>{var W=h(()=>!!ye());return()=>W()&&(()=>{var a=Dt();return f(a,()=>d.i18n("sa-signup-complete")),a})()})(),null),f(g,(()=>{var W=h(()=>!!X());return()=>W()&&(()=>{var a=Dt();return f(a,()=>d.i18n("sa-reset-success")),a})()})(),null),f(g,(()=>{var W=h(()=>t()==="invite");return()=>W()&&[h(()=>h(()=>!!Re())()&&(()=>{var a=iu();return f(a,Re),a})()),h(()=>h(()=>!!x())()&&(()=>{var a=au();return f(a,()=>d.i18n("sa-invite-success")),a})()),(()=>{var a=ru();return a.$$input=p=>_e(p.currentTarget.value),y(p=>{var P=d.i18n("sa-invite-otp"),we=b()||x();return P!==p.e&&ue(a,"placeholder",p.e=P),we!==p.t&&(a.disabled=p.t=we),p},{e:void 0,t:void 0}),y(()=>a.value=Se()),a})(),(()=>{var a=Gt();return f(a,()=>d.i18n("sa-invite-otp-hint")),a})(),(()=>{var a=su();return a.$$input=p=>v(p.currentTarget.value),y(p=>{var P=d.i18n("sa-invite-password"),we=b()||x();return P!==p.e&&ue(a,"placeholder",p.e=P),we!==p.t&&(a.disabled=p.t=we),p},{e:void 0,t:void 0}),y(()=>a.value=E()),a})(),(()=>{var a=Gt();return f(a,()=>d.i18n("sa-invite-password-hint")),a})(),(()=>{var a=Ht();return f(a,(()=>{var p=h(()=>!!b());return()=>p()?d.i18n("sa-invite-completing"):d.i18n("sa-invite-submit")})()),y(()=>a.disabled=b()||x()),a})()]})(),null),f(g,(()=>{var W=h(()=>t()!=="invite");return()=>W()&&[(()=>{var a=uu();return a.addEventListener("change",p=>s(p.currentTarget.value)),a.$$input=p=>s(p.currentTarget.value),y(p=>{var P=d.i18n("sa-username"),we=t()==="otp"||t()==="otp-pick"||t()==="reset-code"||t()==="signup-verify"||t()==="signup-webauthn";return P!==p.e&&ue(a,"placeholder",p.e=P),we!==p.t&&(a.disabled=p.t=we),p},{e:void 0,t:void 0}),y(()=>a.value=r()),a})(),h(()=>h(()=>t()!=="sign-up"&&t()!=="signup-verify"&&t()!=="signup-webauthn")()&&[h(()=>h(()=>t()==="password")()&&(()=>{var a=ou();return a.addEventListener("change",p=>u(p.currentTarget.value)),a.$$input=p=>u(p.currentTarget.value),y(()=>ue(a,"placeholder",d.i18n("sa-password"))),y(()=>a.value=i()),a})()),h(()=>h(()=>t()==="webauthn")()&&Dt()),h(()=>h(()=>t()==="otp-pick")()&&[(()=>{var a=gt();return f(a,()=>d.i18n("sa-otp-choose")),a})(),(()=>{var a=lu();return a.addEventListener("change",p=>B(p.currentTarget.value)),f(a,()=>Ae().map(p=>(()=>{var P=cu(),we=P.firstChild,Qt=we.nextSibling;return Qt.nextSibling,f(P,()=>p.DisplayName||p.ID,we),f(P,()=>p.Type,Qt),y(()=>P.value=p.ID),P})())),y(()=>a.value=Ee()),a})()]),h(()=>h(()=>t()==="otp")()&&(()=>{var a=du();return a.$$input=p=>w(p.currentTarget.value),y(()=>ue(a,"placeholder",d.i18n("sa-code"))),y(()=>a.value=o()),a})()),h(()=>h(()=>t()==="reset-code")()&&[(()=>{var a=Wt();return a.$$input=p=>H(p.currentTarget.value),y(()=>ue(a,"placeholder",d.i18n("sa-reset-code"))),y(()=>a.value=le()),a})(),(()=>{var a=Zt();return a.$$input=p=>K(p.currentTarget.value),y(()=>ue(a,"placeholder",d.i18n("sa-new-password"))),y(()=>a.value=ne()),a})()]),h(()=>h(()=>t()==="password"||t()==="webauthn")()&&(()=>{var a=fu(),p=a.firstChild,P=p.nextSibling;return P.firstChild,a.$$click=()=>n(t()==="password"?"webauthn":"password"),f(P,()=>d.i18n("sa-use-password"),null),y(()=>p.checked=t()==="password"),a})())]),h(()=>h(()=>t()==="sign-up")()&&(()=>{var a=Zt();return a.addEventListener("change",p=>u(p.currentTarget.value)),a.$$input=p=>u(p.currentTarget.value),y(()=>ue(a,"placeholder",d.i18n("sa-password"))),y(()=>a.value=i()),a})()),h(()=>h(()=>t()==="signup-verify")()&&[(()=>{var a=gt();return f(a,()=>d.i18n("sa-signup-verify-prompt")),a})(),(()=>{var a=Wt();return a.$$input=p=>w(p.currentTarget.value),y(()=>ue(a,"placeholder",d.i18n("sa-code"))),y(()=>a.value=o()),a})()]),h(()=>h(()=>t()==="signup-webauthn")()&&(()=>{var a=gt();return f(a,()=>d.i18n("sa-signup-webauthn-prompt")),a})()),h(()=>h(()=>t()!=="signup-webauthn")()&&(()=>{var a=Ht();return f(a,(()=>{var p=h(()=>!!b());return()=>p()?d.i18n("sa-loading"):h(()=>t()==="sign-up")()?d.i18n("sa-signup"):h(()=>t()==="otp-pick")()?d.i18n("sa-otp-send-code"):h(()=>t()==="otp")()?d.i18n("sa-otp-verify"):h(()=>t()==="reset-email")()?d.i18n("sa-otp-send-code"):h(()=>t()==="reset-code")()?d.i18n("sa-reset-submit"):h(()=>t()==="signup-verify")()?d.i18n("sa-otp-verify"):d.i18n("sa-login")})()),y(()=>a.disabled=b()),a})()),h(()=>h(()=>t()==="signup-webauthn")()&&[(()=>{var a=hu();return a.$$click=()=>J(),f(a,(()=>{var p=h(()=>!!b());return()=>p()?d.i18n("sa-loading"):d.i18n("sa-signup-webauthn-setup")})()),y(()=>a.disabled=b()),a})(),(()=>{var a=nt();return a.$$click=()=>c(),f(a,()=>d.i18n("sa-signup-webauthn-done")),a})()]),h(()=>h(()=>t()==="password")()&&(()=>{var a=nt();return a.$$click=()=>{D(""),Q(!1),n("reset-email")},f(a,()=>d.i18n("sa-forgot-password")),a})()),h(()=>h(()=>t()==="reset-email"||t()==="reset-code")()&&(()=>{var a=nt();return a.$$click=()=>{D(""),H(""),K(""),n(e.startMode)},f(a,()=>d.i18n("sa-back")),a})()),h(()=>h(()=>!!(oe()&&t()!=="reset-email"&&t()!=="reset-code"&&t()!=="signup-verify"&&t()!=="signup-webauthn"))()&&(()=>{var a=nt();return a.$$click=()=>t()==="sign-up"?n(e.startMode):n("sign-up"),f(a,(()=>{var p=h(()=>t()==="sign-up");return()=>p()?d.i18n("sa-back"):d.i18n("sa-signup")})()),a})()),h(()=>h(()=>!e.hideSocial&&ee().length>0&&(t()==="password"||t()==="webauthn"||t()==="sign-up"))()&&[(()=>{var a=pu(),p=a.firstChild;return f(p,()=>d.i18n("sa-or")),a})(),h(()=>ee().map(a=>(()=>{var p=Du();return p.$$click=()=>U(a.provider),f(p,(()=>{var P=h(()=>a.provider==="google");return()=>P()&&gu()})(),null),f(p,(()=>{var P=h(()=>a.provider==="github");return()=>P()&&mu()})(),null),f(p,(()=>{var P=h(()=>a.provider==="apple");return()=>P()&&bu()})(),null),f(p,(()=>{var P=h(()=>a.provider==="oidc");return()=>P()&&vu()})(),null),f(p,(()=>{var P=h(()=>a.provider==="google");return()=>P()?d.i18n("sa-social-google"):h(()=>a.provider==="github")()?d.i18n("sa-social-github"):h(()=>a.provider==="apple")()?d.i18n("sa-social-apple"):d.i18n("sa-social-oidc")})(),null),y(()=>p.disabled=!!pe()||b()),p})()))])]})(),null),f(l,(()=>{var W=h(()=>!!L());return()=>W()&&(()=>{var a=Cu(),p=a.firstChild;return p._$owner=sn(),f(p,()=>d.i18n("sa-loading")),a})()})(),null),l})()}),ot(["input","click"]);var wu=A(`<div class=container><style>.container {
|
|
148
148
|
background-color: #ffffff;
|
|
149
149
|
border-radius: 10px;
|
|
150
150
|
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|