mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-12-11 17:50:39 +01:00
2 lines
11 KiB
JavaScript
2 lines
11 KiB
JavaScript
|
import{P as nt,b as lt,a as rt,c as ct,r as k,d as q,I as f,v as V,x as ut,o as dt,J as ft,e as h,f as n,g as r,m as c,p as v,i as a,E as pt,h as e,t as i,U as E,n as T,k as M,l as d,j as p,w as R,F as J,G as L,T as _t,O as mt}from"./app-1b332c21.js";import{F as B}from"./Form-940b5f6c.js";import{_ as ht}from"./OtpDisplay-ec83b57b.js";import{S as vt}from"./Spinner-b3cbad3a.js";import{u as gt}from"./bus-84126a4e.js";/*! 2FAuth version 5.0.0 - Copyright (c) 2023 Bubka - https://github.com/Bubka/2FAuth */const wt={class:"title has-text-grey-dark"},kt={key:0},yt={class:"block is-size-7-mobile"},bt={class:"mb-2"},$t={class:"columns"},Ct={class:"column"},At={class:"block"},xt={class:"card"},Ft={class:"card-content"},zt={class:"media"},St={class:"media-left"},qt={class:"image is-32x32"},Vt={class:"media-content"},Et=["innerHTML"],Tt={class:"subtitle is-6 is-size-7-mobile"},Bt={class:"card-footer"},Nt={class:"block"},Ot={class:"card"},Pt={class:"card-content"},Ut={class:"media"},It={class:"media-left"},Mt={class:"image is-32x32"},Rt={class:"media-content"},Jt={class:"title is-5 has-text-grey"},Lt={class:"subtitle is-6 is-size-7-mobile"},jt={class:"card-footer"},Dt={class:"title is-5 has-text-grey-dark"},Wt={class:"block is-size-7-mobile"},Gt={class:"table is-size-7-mobile is-fullwidth"},Ht=e("thead",null,[e("tr",null,[e("th"),e("th",null,"Plain text"),e("th",null,"QR code"),e("th",null,"JSON")])],-1),Kt=e("th",null,"Google Authenticator",-1),Qt=e("td",null,null,-1),Xt=e("td",null,null,-1),Yt=e("th",null,"Aegis Auth",-1),Zt=e("td",null,null,-1),te=e("th",null,"2FAS auth",-1),ee=e("td",null,null,-1),se=e("td",null,null,-1),oe=e("th",null,"2FAuth",-1),ie=e("td",null,null,-1),ae=e("td",null,null,-1),ne={key:1},le={key:2},re={class:"block is-size-7-mobile"},ce={class:"mb-2"},ue={class:"is-flex is-justify-content-space-between"},de=["onClick","title"],fe=["src","alt"],pe={key:1,class:"is-flex-grow-1 has-ellipsis"},_e={key:2,class:"tags is-flex-wrap-nowrap"},me=["onClick","title"],he=["onClick","title"],ve={key:3,class:"has-nowrap"},ge={key:0,class:"has-text-success"},we={key:1,class:"has-text-danger"},ke={class:"is-size-6 is-size-7-mobile"},ye={class:"is-family-primary has-text-grey"},be={key:0,class:"has-text-danger"},$e={key:1,class:"has-text-warning"},Ce={key:2},Ae={key:0,class:"mt-2 is-size-7 is-pulled-right"},xe={key:1,class:"mt-2 is-size-7 is-pulled-right"},Fe={key:0,class:"control"},Ne={__name:"Import",setup(ze){const j=nt("2fauth"),_=lt(),D=rt(),x=gt(),W=ct(),y=k(null),F=k(null),z=k(null),b=q(new B({service:"",account:"",otp_type:"",icon:"",secret:"",algorithm:"",digits:null,counter:null,period:null})),$=q(new B({file:null,withSecret:!0})),C=q(new B({qrcode:null,withSecret:!0})),g=k(!1);f("twofaccounts.import.qr_code"),f("twofaccounts.import.plain_text");const l=k([]),m=k(!1),A=V(()=>l.value.filter(t=>t.imported==-1&&t.id>-2).length),N=V(()=>l.value.filter(t=>t.id===-1&&t.imported===-1).length),G=V(()=>l.value.filter(t=>t.imported===1).length);ut(g,t=>{var s;t==!1&&((s=y.value)==null||s.clearOTP())}),dt(()=>{x.migrationUri&&(O(x.migrationUri),x.migrationUri=null)});async function O(t){m.value=!0,await ft.migrate(t,{returnError:!0}).then(s=>{s.data.forEach(u=>{u.imported=-1,l.value.push(u)}),U()}).catch(s=>{_.alert({text:f(s.response.data.message)})}),m.value=!1}function H(){var t;confirm(f("twofaccounts.confirm.discard_duplicates"))&&(_.clear(),(t=y.value)==null||t.clearOTP(),l.value=l.value.filter(s=>s.id!==-1))}function K(){var t;confirm(f("twofaccounts.confirm.discard_all"))&&(_.clear(),(t=y.value)==null||t.clearOTP(),l.value=[])}function Q(t){confirm(f("twofaccounts.confirm.discard"))&&l.value.splice(t,1)}async function X(){for(let t=0;t<l.value.length;t++)l.value[t].imported==-1&&await P(t)}async function P(t){b.fill(l.value[t]),await b.post("/api/v1/twofaccounts",{returnError:!0}).then(s=>{l.value[t].imported=1,l.value[t].id=s.data.id,delete s.data.secret,W.items.push(s.data)}).catch(s=>{l.value[t].imported=0,l.value[t].id=0,l.value[t].errors=b.errors.flatten()})}function Y(t){b.fill(l.value[t]),g.value=!0,mt().then(()=>
|