mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-12-03 22:01:45 +01:00
3 lines
14 KiB
JavaScript
Vendored
3 lines
14 KiB
JavaScript
Vendored
import{Z as J,_ as mt,l as _,m as n,d as a,y as pt,j as d,i as f,e as t,f as o,n as $,V as X,h as B,a as ht,u as vt,b as gt,r as b,c as D,H as v,x as H,s as _t,o as yt,J as bt,k as T,t as i,g,w as W,C as K,G as kt,F as Q,D as Z,U as wt,L as $t,P as xt}from"./app-CzxRjCVM.js";import{F as P}from"./Form-EFIuWKGI.js";import{_ as Ct}from"./OtpDisplay-ytUtG8ZN.js";import{S as At}from"./Spinner-C-V0HKYn.js";import{u as St}from"./bus-BNAtGMCo.js";/*! 2FAuth version 5.4.3 - Copyright (c) 2024 Bubka - https://github.com/Bubka/2FAuth */const Ft=["for","innerHTML"],It=["disabled","id","value","placeholder","maxlength","aria-describedby","aria-invalid","aria-errormessage"],Et=["id","innerHTML"],zt=Object.assign({inheritAttrs:!1},{__name:"FormTextarea",props:{modelValue:[String,Number,Boolean],label:{type:String,default:""},fieldName:{type:String,default:"",required:!0},fieldError:[String],placeholder:{type:String,default:""},help:{type:String,default:""},size:{type:String,default:""},hasOffset:{type:Boolean,default:!1},isDisabled:{type:Boolean,default:!1},maxLength:{type:Number,default:null},isIndented:Boolean,leftIcon:"",rightIcon:"",idSuffix:{type:String,default:""}},setup(r){const k=r,{inputId:m}=J(k.inputType,k.fieldName+k.idSuffix),{valErrorId:L}=mt(k.fieldName),x=J("legend",k.fieldName).inputId;return(w,p)=>{const C=_("FontAwesomeIcon"),A=_("FieldError");return n(),a("div",{class:$(["mb-3",{"pt-3":r.hasOffset,"is-flex":r.isIndented}])},[r.isIndented?(n(),a("div",{key:0,class:"mx-2 pr-1",style:pt({opacity:r.isDisabled?"0.5":"1"})},[d(C,{class:"has-text-grey",icon:["fas","chevron-right"],transform:"rotate-135"})],4)):f("",!0),t("div",{class:$(["field",{"is-flex-grow-5":r.isIndented}])},[r.label?(n(),a("label",{key:0,for:o(m),class:"label",innerHTML:w.$t(r.label)},null,8,Ft)):f("",!0),t("div",{class:$(["control",{"has-icons-left":r.leftIcon,"has-icons-right":r.rightIcon}])},[t("textarea",X({disabled:r.isDisabled,id:o(m),class:["textarea",r.size],value:r.modelValue,placeholder:r.placeholder},w.$attrs,{onInput:p[0]||(p[0]=h=>w.$emit("update:modelValue",h.target.value)),onChange:p[1]||(p[1]=h=>w.$emit("change:modelValue",h.target.value)),maxlength:r.maxLength,"aria-describedby":r.help?o(x):void 0,"aria-invalid":r.fieldError!=null,"aria-errormessage":r.fieldError!=null?o(L):void 0}),null,16,It)],2),r.fieldError!=null?(n(),B(A,{key:1,error:r.fieldError,field:r.fieldName},null,8,["error","field"])):f("",!0),r.help?(n(),a("p",{key:2,id:o(x),class:"help",innerHTML:w.$t(r.help)},null,8,Et)):f("",!0)],2)],2)}}}),Vt={class:"title has-text-grey-dark"},Tt={key:0},Nt={class:"block is-size-7-mobile"},qt={class:"mb-2"},Bt={class:"columns"},Lt={class:"column"},Mt={class:"block"},Ot={class:"card"},Dt={class:"card-content"},Ht={class:"media"},Pt={class:"media-left"},Ut={class:"image is-32x32"},Rt={class:"media-content"},jt=["innerHTML"],Gt={class:"subtitle is-6 is-size-7-mobile"},Jt={class:"card-footer"},Wt={class:"block"},Kt={class:"card"},Qt={class:"card-content"},Zt={class:"media"},Xt={class:"media-left"},Yt={class:"image is-32x32"},te={class:"media-content"},ee={class:"title is-5 has-text-grey"},se={class:"subtitle is-6 is-size-7-mobile"},oe={class:"card-footer"},ie={class:"block"},le={class:"card"},ne={class:"card-content"},ae={class:"media"},re={class:"media-left"},de={class:"image is-32x32"},ue={class:"media-content"},ce=["innerHTML"],fe={class:"subtitle is-6 is-size-7-mobile"},me={class:"content"},pe={class:"card-footer"},he={class:"title is-5 has-text-grey-dark"},ve={class:"block is-size-7-mobile"},ge={class:"table is-size-7-mobile is-fullwidth"},_e={key:1},ye={key:2},be={class:"block is-size-7-mobile"},ke={class:"mb-2"},we={class:"is-flex is-justify-content-space-between"},$e=["onClick","title"],xe=["src"],Ce={key:1,class:"is-flex-grow-1 has-ellipsis"},Ae={key:2,class:"tags is-flex-wrap-nowrap"},Se=["onClick","title"],Fe=["onClick","title"],Ie={key:3,class:"has-nowrap"},Ee={key:0,class:"has-text-success"},ze={key:1,class:"has-text-danger"},Ve={class:"is-size-6 is-size-7-mobile"},Te={class:"is-family-primary has-text-grey"},Ne={key:0,class:"has-text-danger"},qe={key:1,class:"has-text-warning"},Be={key:2},Le={key:0,class:"mt-2 is-size-7 is-pulled-right"},Me={key:1,class:"mt-2 is-size-7 is-pulled-right"},Oe={key:0,class:"control"},je={__name:"Import",setup(r){const k=$t("2fauth"),m=ht(),L=vt(),x=St(),w=gt(),p=b(null),C=b(null),A=b(null),h=b(null),N=b(null),F=D(new P({service:"",account:"",otp_type:"",icon:"",secret:"",algorithm:"",digits:null,counter:null,period:null})),I=D(new P({file:null,withSecret:!0})),E=D(new P({qrcode:null,withSecret:!0})),S=b(!1);v("twofaccounts.import.qr_code"),v("twofaccounts.import.plain_text");const u=b([]),y=b(!1),z=H(()=>u.value.filter(e=>e.imported==-1&&e.id>-2).length),U=H(()=>u.value.filter(e=>e.id===-1&&e.imported===-1).length),Y=H(()=>u.value.filter(e=>e.imported===1).length);_t(S,e=>{var s;e==!1&&((s=p.value)==null||s.clearOTP())}),yt(()=>{x.migrationUri&&(M(x.migrationUri),x.migrationUri=null)});async function M(e){y.value=!0,await bt.migrate(e,{returnError:!0}).then(s=>{s.data.forEach(c=>{c.imported=-1,u.value.push(c)}),j(),h.value=N.value=null}).catch(s=>{m.alert({text:v(s.response.data.message)})}),y.value=!1}function tt(){var e;confirm(v("twofaccounts.confirm.discard_duplicates"))&&(m.clear(),(e=p.value)==null||e.clearOTP(),u.value=u.value.filter(s=>s.id!==-1))}function et(){var e;confirm(v("twofaccounts.confirm.discard_all"))&&(m.clear(),(e=p.value)==null||e.clearOTP(),u.value=[])}function st(e){confirm(v("twofaccounts.confirm.discard"))&&u.value.splice(e,1)}async function ot(){for(let e=0;e<u.value.length;e++)u.value[e].imported==-1&&await R(e)}async function R(e){F.fill(u.value[e]),await F.post("/api/v1/twofaccounts",{returnError:!0}).then(s=>{u.value[e].imported=1,u.value[e].id=s.data.id,delete s.data.secret,w.items.push(s.data)}).catch(s=>{u.value[e].imported=0,u.value[e].id=0,u.value[e].errors=F.errors.flatten()})}function it(e){F.fill(u.value[e]),S.value=!0,xt().then(()=>{p.value.show()})}function lt(){I.clear(),y.value=!0,I.file=C.value.files[0],I.upload("/api/v1/twofaccounts/migration",{returnError:!0}).then(e=>{e.data.forEach(s=>{s.imported=-1,u.value.push(s)}),j()}).catch(e=>{e.response.status===422?e.response.data.errors.file==null&&m.alert({text:v("errors.invalid_2fa_data")}):m.alert({text:e.response.data.message})}),y.value=!1}function nt(){E.clear(),y.value=!0,E.qrcode=A.value.files[0],E.upload("/api/v1/qrcode/decode",{returnError:!0}).then(e=>{M(e.data.data)}).catch(e=>{e.response.status===422?e.response.data.errors.qrcode==null&&m.alert({text:v("errors.invalid_2fa_data")}):m.alert({text:e.response.data.message})}),y.value=!1}function j(){m.success({text:v("twofaccounts.import.x_valid_accounts_found",{count:z.value})})}function at(){N.value=null,h.value?M(h.value):N.value=v("validation.required",{attribute:"Direct input"})}return(e,s)=>{const c=_("FontAwesomeIcon"),G=_("FieldError"),rt=_("RouterLink"),dt=_("ButtonBackCloseCancel"),ut=_("VueFooter"),ct=_("ResponsiveWidthWrapper"),ft=_("modal");return n(),B(o(wt),null,{default:T(({mode:q})=>[t("div",null,[d(ct,null,{default:T(()=>[t("h1",Vt,i(e.$t("twofaccounts.import.import")),1),!o(y)&&o(u).length==0?(n(),a("div",Tt,[t("div",Nt,[t("p",qt,i(e.$t("twofaccounts.import.import_legend")),1),t("p",null,i(e.$t("twofaccounts.import.import_legend_afterpart")),1)]),t("div",Bt,[t("div",Lt,[t("div",Mt,[t("div",Ot,[t("div",Dt,[t("div",Ht,[t("div",Pt,[t("figure",Ut,[d(c,{icon:["fas","qrcode"],size:"2x",class:$(q=="dark"?"has-text-grey-darker":"has-text-grey-lighter")},null,8,["class"])])]),t("div",Rt,[t("p",{class:"title is-5 has-text-grey",innerHTML:e.$t("twofaccounts.import.qr_code")},null,8,jt),t("p",Gt,i(e.$t("twofaccounts.import.supported_formats_for_qrcode_upload")),1)])]),o(E).errors.hasAny("qrcode")?(n(),B(G,{key:0,error:o(E).errors.get("qrcode"),field:"qrcode"},null,8,["error"])):f("",!0)]),t("footer",Jt,[d(rt,{id:"btnCapture",to:{name:"capture"},class:"card-footer-item"},{default:T(()=>[g(i(e.$t("twofaccounts.import.scan")),1)]),_:1}),t("a",{role:"button",tabindex:"0",class:"card-footer-item is-relative",onClick:s[0]||(s[0]=l=>o(A).click()),onKeyup:s[1]||(s[1]=W(l=>o(A).click(),["enter"]))},[t("input",{inert:"",tabindex:"-1",class:"file-input",type:"file",accept:"image/*",onChange:nt,ref_key:"qrcodeInput",ref:A},null,544),g(" "+i(e.$t("twofaccounts.import.upload")),1)],32)])])]),t("div",Wt,[t("div",Kt,[t("div",Qt,[t("div",Zt,[t("div",Xt,[t("figure",Yt,[d(c,{icon:["fas","file-lines"],size:"2x",class:$(q=="dark"?"has-text-grey-darker":"has-text-grey-lighter")},null,8,["class"])])]),t("div",te,[t("p",ee,i(e.$t("twofaccounts.import.text_file")),1),t("p",se,i(e.$t("twofaccounts.import.supported_formats_for_file_upload")),1)])]),o(I).errors.hasAny("file")?(n(),B(G,{key:0,error:o(I).errors.get("file"),field:"file"},null,8,["error"])):f("",!0)]),t("footer",oe,[t("a",{role:"button",tabindex:"0",class:"card-footer-item is-relative",onClick:s[2]||(s[2]=l=>o(C).click()),onKeyup:s[3]||(s[3]=W(l=>o(C).click(),["enter"]))},[t("input",{inert:"",tabindex:"-1",class:"file-input",type:"file",accept:"text/plain,application/json,text/csv,.2fas",onChange:lt,ref_key:"fileInput",ref:C},null,544),g(" "+i(e.$t("twofaccounts.import.upload")),1)],32)])])]),t("div",ie,[t("div",le,[t("div",ne,[t("div",ae,[t("div",re,[t("figure",de,[d(c,{icon:["fas","align-left"],size:"2x",class:$(q=="dark"?"has-text-grey-darker":"has-text-grey-lighter")},null,8,["class"])])]),t("div",ue,[t("p",{class:"title is-5 has-text-grey",innerHTML:e.$t("twofaccounts.import.direct_input")},null,8,ce),t("p",fe,i(e.$t("twofaccounts.import.expected_format_for_direct_input")),1)])]),t("div",me,[d(zt,{modelValue:o(h),"onUpdate:modelValue":s[4]||(s[4]=l=>K(h)?h.value=l:null),fieldError:o(N),fieldName:"payload",rows:"5",size:"is-small"},null,8,["modelValue","fieldError"])])]),t("footer",pe,[t("a",{role:"button",tabindex:"0",class:"card-footer-item is-relative",onClick:kt(at,["stop"])},i(e.$t("commons.submit")),1)])])])])]),t("h2",he,i(e.$t("twofaccounts.import.supported_migration_formats")),1),t("div",ve,[d(c,{icon:["fas","fa-triangle-exclamation"],class:"has-text-warning-dark"}),g(" "+i(e.$t("twofaccounts.import.do_not_set_password_or_encryption")),1)]),t("table",ge,[s[26]||(s[26]=t("thead",null,[t("tr",null,[t("th"),t("th",null,"Plain text"),t("th",null,"QR code"),t("th",null,"JSON")])],-1)),t("tbody",null,[t("tr",null,[s[12]||(s[12]=t("th",null,"Google Authenticator",-1)),s[13]||(s[13]=t("td",null,null,-1)),t("td",null,[d(c,{icon:["fas","circle-check"]})]),s[14]||(s[14]=t("td",null,null,-1))]),t("tr",null,[s[15]||(s[15]=t("th",null,"Aegis Auth",-1)),t("td",null,[d(c,{icon:["fas","circle-check"]})]),s[16]||(s[16]=t("td",null,null,-1)),t("td",null,[d(c,{icon:["fas","circle-check"]})])]),t("tr",null,[s[17]||(s[17]=t("th",null,"2FAS auth",-1)),s[18]||(s[18]=t("td",null,null,-1)),s[19]||(s[19]=t("td",null,null,-1)),t("td",null,[d(c,{icon:["fas","circle-check"]})])]),t("tr",null,[s[20]||(s[20]=t("th",null,"FreeOTP+",-1)),t("td",null,[d(c,{icon:["fas","circle-check"]})]),s[21]||(s[21]=t("td",null,null,-1)),s[22]||(s[22]=t("td",null,null,-1))]),t("tr",null,[s[23]||(s[23]=t("th",null,"2FAuth",-1)),s[24]||(s[24]=t("td",null,null,-1)),s[25]||(s[25]=t("td",null,null,-1)),t("td",null,[d(c,{icon:["fas","circle-check"]})])])])])])):o(y)&&o(u).length===0?(n(),a("div",_e,[d(At,{type:"fullscreen-overlay",isVisible:!0,message:"twofaccounts.import.parsing_data"})])):(n(),a("div",ye,[t("div",be,[t("p",ke,i(e.$t("twofaccounts.import.submitted_data_parsed_now_accounts_are_awaiting_import")),1),t("p",null,i(e.$t("twofaccounts.import.use_buttons_to_save_or_discard")),1)]),(n(!0),a(Q,null,Z(o(u),(l,O)=>(n(),a("div",{key:l.name,class:"group-item is-size-5 is-size-6-mobile"},[t("div",we,[l.id>-2&&l.imported!==0?(n(),a("div",{key:0,class:"is-flex-grow-1 has-ellipsis is-clickable",onClick:V=>it(O),title:e.$t("twofaccounts.import.generate_a_test_password")},[l.icon&&o(L).preferences.showAccountsIcons?(n(),a("img",{key:0,role:"presentation",class:"import-icon",src:o(k).config.subdirectory+"/storage/icons/"+l.icon,alt:""},null,8,xe)):f("",!0),g(" "+i(l.account),1)],8,$e)):(n(),a("div",Ce,i(l.account),1)),l.imported===-1?(n(),a("div",Ae,[t("button",{type:"button",class:$(["button tag",{"is-dark has-text-grey-light":q=="dark"}]),onClick:V=>st(O),title:e.$t("twofaccounts.import.discard_this_account")},[d(c,{icon:["fas","trash"]})],10,Se),l.id>-2?(n(),a("button",{key:0,type:"button",class:"button tag is-link",onClick:V=>R(O),title:e.$t("twofaccounts.import.import_this_account")},i(e.$t("twofaccounts.import.to_import")),9,Fe)):f("",!0)])):(n(),a("div",Ie,[l.imported===1?(n(),a("span",Ee,[g(i(e.$t("twofaccounts.import.imported"))+" ",1),d(c,{icon:["fas","check"]})])):(n(),a("span",ze,[g(i(e.$t("twofaccounts.import.failure"))+" ",1),d(c,{icon:["fas","times"]})]))]))]),t("div",Ve,[t("div",Te,i(e.$t("twofaccounts.import.issuer"))+": "+i(l.service),1),l.id===-2?(n(),a("div",Ne,[d(c,{class:"mr-1",icon:["fas","times-circle"]}),g(i(l.secret),1)])):f("",!0),l.id===-1&&l.imported!==1&&!l.errors?(n(),a("div",qe,[d(c,{class:"mr-1",icon:["fas","exclamation-circle"]}),g(i(e.$t("twofaccounts.import.possible_duplicate")),1)])):f("",!0),l.errors?(n(),a("ul",Be,[(n(!0),a(Q,null,Z(l.errors,V=>(n(),a("li",{key:V,class:"has-text-danger"},i(V),1))),128))])):f("",!0)])]))),128)),o(z)>0?(n(),a("div",Le,[o(U)?(n(),a("button",{key:0,onClick:s[5]||(s[5]=l=>tt()),type:"button",class:"has-text-grey button is-small is-ghost"},i(e.$t("twofaccounts.import.discard_duplicates"))+" ("+i(o(U))+")",1)):f("",!0),t("button",{onClick:s[6]||(s[6]=l=>et()),type:"button",class:"has-text-grey button is-small is-ghost"},i(e.$t("twofaccounts.import.discard_all")),1)])):f("",!0),o(Y)==o(u).length?(n(),a("div",Me,[t("button",{onClick:s[7]||(s[7]=l=>u.value=[]),type:"button",class:"has-text-grey button is-small is-ghost"},i(e.$t("commons.clear")),1)])):f("",!0)])),d(ut,{showButtons:!0},{default:T(()=>[o(z)>0?(n(),a("p",Oe,[t("button",{type:"button",class:"button is-link is-rounded is-focus",onClick:ot},[t("span",null,i(e.$t("twofaccounts.import.import_all"))+" ("+i(o(z))+")",1)])])):f("",!0),d(dt,{returnTo:{name:"accounts"},action:o(z)>0?"cancel":"close"},null,8,["action"])]),_:1})]),_:2},1024),d(ft,{modelValue:o(S),"onUpdate:modelValue":s[11]||(s[11]=l=>K(S)?S.value=l:null)},{default:T(()=>[d(Ct,X({ref_key:"otpDisplay",ref:p},o(F).data(),{onIncrementHotp:s[8]||(s[8]=()=>{}),onValidationError:s[9]||(s[9]=()=>{}),onPleaseCloseMe:s[10]||(s[10]=l=>S.value=!1)}),null,16)]),_:1},8,["modelValue"])])]),_:1})}}};export{je as default};
|
|
//# sourceMappingURL=Import-CWswmNcW.js.map
|