Files
twofauth-rs/public/build/assets/WebAuthn-C_HU0Xj8.js
T
wt cf25e28c28
Rust verification / test (push) Successful in 4m10s
initial commit
2026-10-28 15:59:54 +07:00

2 lines
4.4 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{C as M,u as P,a as j,P as K,a8 as W,o as R,v as q,a1 as y,af as H,d as I,w as d,M as J,e as F,f as p,g as G,h,i as l,j as t,l as _,t as s,k,m as n,q as Q,p as V,F as X,E as Y,n as Z,ak as ee,B as te,$ as se}from"./app-dvJP63FL.js";import{t as ne}from"./tabs-Btun2NN0.js";import{w as ae}from"./webauthnService-D363et0U.js";import{U as ie}from"./index-BJsmINgd.js";import{C as oe}from"./circle-plus-BM92Iipr.js";import"./createLucideIcon-DsaEAGzP.js";const le={key:0,class:"notification is-warning has-text-centered"},re={key:1,class:"notification is-warning has-text-centered"},ue={class:"title is-4"},ce={class:"is-size-7-mobile"},de={class:"mt-3"},pe={key:2,class:"field"},he=["onClick","title"],_e={class:"mt-2 is-size-7 is-pulled-right"},me={class:"title is-4 pt-6"},fe={class:"field"},ge={class:"help"},ve={class:"help mt-3"},Fe={__name:"WebAuthn",setup(be){const w=M(),{t:r}=P(),$=J("2fauth"),i=j(),C=K(),u=se(),f=G(),x=W($.prefix+"returnTo","accounts"),N=W($.prefix+"activeLoginForm","legacy"),o=F([]),g=F(!1),m=te(()=>C.enableSso&&C.useSsoOnly||i.authenticated_by_proxy);R(()=>{L()}),q(()=>i.preferences.useWebauthnOnly,()=>{y.updatePreference("useWebauthnOnly",i.preferences.useWebauthnOnly).then(e=>{u.success({text:r("notification.setting_saved")})})});function S(){if(m.value==!0)return u.warn({text:r("error.unsupported_with_reverseproxy")}),!1;ae.register().then(e=>{f.push({name:"settings.webauthn.editCredential",params:{credentialId:JSON.parse(e.config.data).id}})}).catch(e=>{"webauthn"in e?e.name=="is-warning"?u.warn({text:r(e.message)}):u.alert({text:r(e.message)}):e.response?.status===422?u.alert({text:e.response.data.message}):w.show(e)})}function O(e){confirm(r("confirmation.revoke_device"))&&y.revokeWebauthnDevice(e).then(a=>{o.value=o.value.filter(v=>v.id!==e),o.value.length==0&&(i.preferences.useWebauthnOnly=!1),u.success({text:r("notification.device_revoked")})})}function B(e){return e.alias?e.alias:r("label.my_device")+" (#"+e.id.substring(0,10)+")"}function L(){g.value=!0,y.getWebauthnDevices({returnError:!0}).then(e=>{o.value=e.data}).catch(e=>{e.response.status===403||w.show(e)}).finally(()=>{g.value=!1})}async function D(){N.value="webauthn"}return H(e=>{e.name.startsWith("settings.")||u.clear()}),(e,a)=>{const v=p("Spinner"),z=p("FormCheckbox"),A=p("FormWrapper"),T=p("NavigationButton"),U=p("VueFooter"),E=p("StackLayout");return h(),I(E,null,{header:d(()=>[l(t(ee),{tabs:t(ne),"active-tab":"settings.webauthn.devices",onTabSelected:a[0]||(a[0]=c=>t(f).push({name:c}))},null,8,["tabs"])]),content:d(()=>[l(A,null,{default:d(()=>[t(m)&&t(i).oauth_provider?(h(),_("div",le,s(e.$t("message.sso_only_x_settings_are_disabled",{auth_method:"WebAuthn"})),1)):k("",!0),t(m)&&t(i).authenticated_by_proxy?(h(),_("div",re,s(e.$t("message.auth_handled_by_proxy")+" "+e.$t("message.manage_auth_at_proxy_level")),1)):k("",!0),n("h4",ue,s(e.$t("heading.security_devices")),1),n("div",ce,s(e.$t("message.security_devices_legend")),1),n("div",de,[n("a",{tabindex:"0",class:"is-link",onClick:S,onKeyup:Q(S,["enter"])},[l(t(oe)),V(" "+s(e.$t("link.register_a_new_device")),1)],32)]),t(o).length>0?(h(),_("div",pe,[l(t(ie),null,{default:d(({mode:c})=>[(h(!0),_(X,null,Y(t(o),b=>(h(),_("div",{key:b.id,class:"group-item is-size-5 is-size-6-mobile"},[V(s(B(b))+" ",1),n("button",{type:"button",class:Z(["button tag is-pulled-right",c==="dark"?"is-dark":"is-white"]),onClick:ye=>O(b.id),title:e.$t("tooltip.revoke")},s(e.$t("label.revoke")),11,he)]))),128))]),_:1}),n("div",_e,s(e.$t("message.revoking_a_device_is_permanent")),1)])):k("",!0),l(v,{isVisible:t(g)&&t(o).length===0,type:"list-loading"},null,8,["isVisible"]),n("h4",me,s(e.$t("heading.options")),1),n("div",fe,s(e.$t("message.need_a_security_device_to_enable_options")),1),n("form",null,[l(z,{modelValue:t(i).preferences.useWebauthnOnly,"onUpdate:modelValue":[a[1]||(a[1]=c=>t(i).preferences.useWebauthnOnly=c),a[2]||(a[2]=c=>D())],fieldName:"useWebauthnOnly",label:"field.use_webauthn_only",help:"field.use_webauthn_only.help",isDisabled:t(m)||t(o).length===0},null,8,["modelValue","isDisabled"]),n("p",ge,s(e.$t("field.use_webauthn_only.help_bis")),1),n("p",ve,s(e.$t("field.use_webauthn_only.help_ter")),1)])]),_:1})]),footer:d(()=>[l(U,null,{default:d(()=>[l(T,{action:"close",onClosed:a[3]||(a[3]=c=>t(f).push({name:t(x)})),"current-page-title":e.$t("title.settings.webauthn.devices")},null,8,["current-page-title"])]),_:1})]),_:1})}}};export{Fe as default};