2FAuth/public/build/assets/WebAuthn-a14caef6.js

2 lines
3.8 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{P as z,a as U,b as L,u as M,a2 as A,r as b,o as D,x as I,$ as K,e as h,f as d,g as _,m as o,h as s,p as v,i as t,l as y,t as i,w as R,j as k,F as j,G as E,U as H,n as P,I as r}from"./app-1b332c21.js";import{_ as G}from"./SettingTabs-52d14fa3.js";import{u as g}from"./userService-5f2b5050.js";import{w as J}from"./webauthnService-839b1903.js";import{S as q}from"./Spinner-b3cbad3a.js";/*! 2FAuth version 5.0.0 - Copyright (c) 2023 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=["onKeyup"],se={key:1,class:"field"},ne=["onClick","title"],ae={class:"mt-2 is-size-7 is-pulled-right"},oe={class:"title is-4 pt-6 has-text-grey-light"},ie={class:"field"},pe={__name:"WebAuthn",setup(re){const C=z("2fauth"),l=U(),n=L(),W=M(),$=A(C.prefix+"returnTo","accounts"),a=b([]),f=b(!1),p=b(!1);D(()=>{V()}),I(()=>l.preferences.useWebauthnOnly,()=>{g.updatePreference("useWebauthnOnly",l.preferences.useWebauthnOnly).then(e=>{n.success({text:r("settings.forms.setting_saved")})})});function w(){if(p==!0)return n.warn({text:r("errors.unsupported_with_reverseproxy")}),!1;J.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 x(e){confirm(r("auth.confirm.revoke_device"))&&g.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 F(e){return e.alias?e.alias:r("auth.webauthn.my_device")+" (#"+e.id.substring(0,10)+")"}function V(){f.value=!0,g.getWebauthnDevices({returnError:!0}).then(e=>{a.value=e.data}).catch(e=>{e.response.status===405?p.value=!0:n.error(e)}).finally(()=>{f.value=!1})}return K(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(G,{activeTab:"settings.webauthn.devices"},null,8,["activeTab"]),s("div",Q,[o(N,null,{default:v(()=>[t(p)?(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:R(w,["enter"])},[o(m,{icon:["fas","plus-circle"]}),k(" "+i(e.$t("auth.webauthn.register_a_new_device")),1)],40,te)]),t(a).length>0?(d(),_("div",se,[(d(!0),_(j,null,E(t(a),c=>(d(),_("div",{key:c.id,class:"group-item is-size-5 is-size-6-mobile"},[k(i(F(c))+" ",1),o(t(H),null,{default:v(({mode:O})=>[s("button",{class:P(["button tag is-pulled-right",O==="dark"?"is-dark":"is-white"]),onClick:ue=>x(c.id),title:e.$t("settings.revoke")},i(e.$t("settings.revoke")),11,ne)]),_:2},1024)]))),128)),s("div",ae,i(e.$t("auth.webauthn.revoking_a_device_is_permanent")),1)])):y("",!0),o(q,{isVisible:t(f)&&t(a).length===0},null,8,["isVisible"]),s("h4",oe,i(e.$t("settings.options")),1),s("div",ie,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(p)||t(a).length===0},null,8,["modelValue","disabled"])]),o(T,{showButtons:!0},{default:v(()=>[o(S,{returnTo:{name:t($)},action:"close"},null,8,["returnTo"])]),_:1})]),_:1})])])}}};export{pe as default};