2FAuth/public/build/assets/WebAuthn-d2d_eYIa.js
2024-05-29 15:29:30 +02:00

2 lines
3.7 KiB
JavaScript
Vendored
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{R as z,a as U,b as L,u as M,a2 as R,r as b,o as A,s as D,I as v,a1 as E,e as h,f as d,g as _,m as o,h as s,p as g,i as t,l as y,t as i,w as H,j as k,F as I,E as j,U as K,n as J,H as r}from"./app-BsP-5XS6.js";import{_ as P}from"./SettingTabs-BfWoNH2z.js";import{w as q}from"./webauthnService-Cj6-OgRY.js";import{S as G}from"./Spinner-CewaMSJd.js";/*! 2FAuth version 5.2.0 - Copyright (c) 2024 Bubka - https://github.com/Bubka/2FAuth */const Q={class:"options-tabs"},X=["innerHTML"],Y={class:"title is-4 has-text-grey-light"},Z={class:"is-size-7-mobile"},ee={class:"mt-3"},te={key:1,class:"field"},se=["onClick","title"],ne={class:"mt-2 is-size-7 is-pulled-right"},ae={class:"title is-4 pt-6 has-text-grey-light"},oe={class:"field"},de={__name:"WebAuthn",setup(ie){const C=z("2fauth"),l=U(),n=L(),W=M(),$=R(C.prefix+"returnTo","accounts"),a=b([]),p=b(!1),f=b(!1);A(()=>{x()}),D(()=>l.preferences.useWebauthnOnly,()=>{v.updatePreference("useWebauthnOnly",l.preferences.useWebauthnOnly).then(e=>{n.success({text:r("settings.forms.setting_saved")})})});function w(){if(f==!0)return n.warn({text:r("errors.unsupported_with_reverseproxy")}),!1;q.register().then(e=>{W.push({name:"settings.webauthn.editCredential",params:{credentialId:JSON.parse(e.config.data).id}})}).catch(e=>{var u;"webauthn"in e?e.name=="is-warning"?n.warn({text:r(e.message)}):n.alert({text:r(e.message)}):((u=e.response)==null?void 0:u.status)===422?n.alert({text:e.response.data.message}):n.error(e)})}function F(e){confirm(r("auth.confirm.revoke_device"))&&v.revokeWebauthnDevice(e).then(u=>{a.value=a.value.filter(m=>m.id!==e),a.value.length==0&&(l.preferences.useWebauthnOnly=!1),n.success({text:r("auth.webauthn.device_revoked")})})}function V(e){return e.alias?e.alias:r("auth.webauthn.my_device")+" (#"+e.id.substring(0,10)+")"}function x(){p.value=!0,v.getWebauthnDevices({returnError:!0}).then(e=>{a.value=e.data}).catch(e=>{e.response.status===405?f.value=!0:n.error(e)}).finally(()=>{p.value=!1})}return E(e=>{e.name.startsWith("settings.")||n.clear()}),(e,u)=>{const m=h("FontAwesomeIcon"),B=h("FormCheckbox"),S=h("ButtonBackCloseCancel"),T=h("VueFooter"),N=h("FormWrapper");return d(),_("div",null,[o(P,{activeTab:"settings.webauthn.devices"},null,8,["activeTab"]),s("div",Q,[o(N,null,{default:g(()=>[t(f)?(d(),_("div",{key:0,class:"notification is-warning has-text-centered",innerHTML:e.$t("auth.auth_handled_by_proxy")},null,8,X)):y("",!0),s("h4",Y,i(e.$t("auth.webauthn.security_devices")),1),s("div",Z,i(e.$t("auth.webauthn.security_devices_legend")),1),s("div",ee,[s("a",{tabindex:"0",onClick:w,onKeyup:H(w,["enter"])},[o(m,{icon:["fas","plus-circle"]}),k(" "+i(e.$t("auth.webauthn.register_a_new_device")),1)],32)]),t(a).length>0?(d(),_("div",te,[(d(!0),_(I,null,j(t(a),c=>(d(),_("div",{key:c.id,class:"group-item is-size-5 is-size-6-mobile"},[k(i(V(c))+" ",1),o(t(K),null,{default:g(({mode:O})=>[s("button",{class:J(["button tag is-pulled-right",O==="dark"?"is-dark":"is-white"]),onClick:re=>F(c.id),title:e.$t("settings.revoke")},i(e.$t("settings.revoke")),11,se)]),_:2},1024)]))),128)),s("div",ne,i(e.$t("auth.webauthn.revoking_a_device_is_permanent")),1)])):y("",!0),o(G,{isVisible:t(p)&&t(a).length===0},null,8,["isVisible"]),s("h4",ae,i(e.$t("auth.webauthn.options")),1),s("div",oe,i(e.$t("auth.webauthn.need_a_security_device_to_enable_options")),1),s("form",null,[o(B,{modelValue:t(l).preferences.useWebauthnOnly,"onUpdate:modelValue":u[0]||(u[0]=c=>t(l).preferences.useWebauthnOnly=c),fieldName:"useWebauthnOnly",label:"auth.webauthn.use_webauthn_only.label",help:"auth.webauthn.use_webauthn_only.help",disabled:t(f)||t(a).length===0},null,8,["modelValue","disabled"])]),o(T,{showButtons:!0},{default:g(()=>[o(S,{returnTo:{name:t($)},action:"close"},null,8,["returnTo"])]),_:1})]),_:1})])])}}};export{de as default};