You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

3 lines
7.4 KiB

import{q as ae,s as S,x as ne,y as he,z as ke,A as ye,B as U,C as oe,D as ge,E as me,F as ve,G as we,H as Se,I as $e,J as z,f,i as Oe,e as je,l as Ee,n as xe,j as w,o as k,c as X,u as i,w as M,d as E,t as m,k as Y,K as Pe,L as A,h as L,M as Ce,O as H,b as J,_ as Ie,g as Me}from"./NcSettingsSection-DFav6ob5-Dvi4WdiE.chunk.mjs";import{g as Ae,e as ce,s as se,N as T}from"./check-BUfWmAQ9.chunk.mjs";import{c as Le}from"./index-C0zE9_k9.chunk.mjs";let re;const B=e=>re=e,ue=Symbol();function D(e){return e&&typeof e=="object"&&Object.prototype.toString.call(e)==="[object Object]"&&typeof e.toJSON!="function"}var N;(function(e){e.direct="direct",e.patchObject="patch object",e.patchFunction="patch function"})(N||(N={}));function Ne(){const e=ae(!0),n=e.run(()=>S({}));let t=[],a=[];const o=ne({install(u){B(o),o._a=u,u.provide(ue,o),u.config.globalProperties.$pinia=o,a.forEach(c=>t.push(c)),a=[]},use(u){return this._a?t.push(u):a.push(u),this},_p:t,_a:null,_e:e,_s:new Map,state:n});return o}const ie=()=>{};function Z(e,n,t,a=ie){e.push(n);const o=()=>{const u=e.indexOf(n);u>-1&&(e.splice(u,1),a())};return!t&&me()&&ve(o),o}function x(e,...n){e.slice().forEach(t=>{t(...n)})}const Fe=e=>e(),ee=Symbol(),R=Symbol();function K(e,n){e instanceof Map&&n instanceof Map?n.forEach((t,a)=>e.set(a,t)):e instanceof Set&&n instanceof Set&&n.forEach(e.add,e);for(const t in n){if(!n.hasOwnProperty(t))continue;const a=n[t],o=e[t];D(o)&&D(a)&&e.hasOwnProperty(t)&&!U(a)&&!oe(a)?e[t]=K(o,a):e[t]=a}return e}const Te=Symbol();function Ue(e){return!D(e)||!Object.prototype.hasOwnProperty.call(e,Te)}const{assign:v}=Object;function Be(e){return!!(U(e)&&e.effect)}function Ge(e,n,t,a){const{state:o,actions:u,getters:c}=n,y=t.state.value[e];let g;function d(){y||(t.state.value[e]=o?o():{});const _=$e(t.state.value[e]);return v(_,u,Object.keys(c||{}).reduce((h,$)=>(h[$]=ne(z(()=>{B(t);const O=t._s.get(e);return c[$].call(O,O)})),h),{}))}return g=de(e,d,n,t,a,!0),g}function de(e,n,t={},a,o,u){let c;const y=v({actions:{}},t),g={deep:!0};let d,_,h=[],$=[],O;const j=a.state.value[e];!u&&!j&&(a.state.value[e]={}),S({});let W;function Q(s){let r;d=_=!1,typeof s=="function"?(s(a.state.value[e]),r={type:N.patchFunction,storeId:e,events:O}):(K(a.state.value[e],s),r={type:N.patchObject,payload:s,storeId:e,events:O});const l=W=Symbol();Se().then(()=>{W===l&&(d=!0)}),_=!0,x(h,r,a.state.value[e])}const le=u?function(){const{state:s}=t,r=s?s():{};this.$patch(l=>{v(l,r)})}:ie;function pe(){c.stop(),h=[],$=[],a._s.delete(e)}const V=(s,r="")=>{if(ee in s)return s[R]=r,s;const l=function(){B(a);const F=Array.from(arguments),C=[],G=[];function be(p){C.push(p)}function _e(p){G.push(p)}x($,{args:F,name:l[R],store:b,after:be,onError:_e});let I;try{I=s.apply(this&&this.$id===e?this:b,F)}catch(p){throw x(G,p),p}return I instanceof Promise?I.then(p=>(x(C,p),p)).catch(p=>(x(G,p),Promise.reject(p))):(x(C,I),I)};return l[ee]=!0,l[R]=r,l},fe={_p:a,$id:e,$onAction:Z.bind(null,$),$patch:Q,$reset:le,$subscribe(s,r={}){const l=Z(h,s,r.detached,()=>F()),F=c.run(()=>we(()=>a.state.value[e],C=>{(r.flush==="sync"?_:d)&&s({storeId:e,type:N.direct,events:O},C)},v({},g,r)));return l},$dispose:pe},b=ye(fe);a._s.set(e,b);const P=(a._a&&a._a.runWithContext||Fe)(()=>a._e.run(()=>(c=ae()).run(()=>n({action:V}))));for(const s in P){const r=P[s];if(U(r)&&!Be(r)||oe(r))u||(j&&Ue(r)&&(U(r)?r.value=j[s]:K(r,j[s])),a.state.value[e][s]=r);else if(typeof r=="function"){const l=V(r,s);P[s]=l,y.actions[s]=r}}return v(b,P),v(ge(b),P),Object.defineProperty(b,"$state",{get:()=>a.state.value[e],set:s=>{Q(r=>{v(r,s)})}}),a._p.forEach(s=>{v(b,c.run(()=>s({store:b,app:a._a,pinia:a,options:y})))}),j&&u&&t.hydrate&&t.hydrate(b.$state,j),d=!0,_=!0,b}function He(e,n,t){let a;const o=typeof n=="function";a=o?t:n;function u(c,y){const g=ke();return c=c||(g?he(ue,null):null),c&&B(c),c=re,c._s.has(e)||(o?de(e,n,a,c):Ge(e,a,c)),c._s.get(e)}return u.$id=e,u}const Je=Ae().detectLogLevel().setApp("twofactor_backupcodes").build();function Re(e){const n=ce().theming.name||"Nextcloud",t=window.open("",f("twofactor_backupcodes","{name} backup codes",{name:n}));if(!t)throw se(f("twofactor_backupcodes","Unable to open a new tab for printing")),new Error("Unable to open a new tab for printing");const a=t.document.createElement("h1");a.textContent=f("twofactor_backupcodes","{name} backup codes",{name:n});const o=t.document.createElement("pre");for(const u of e){const c=t.document.createTextNode(u);o.appendChild(c),o.appendChild(t.document.createElement("br"))}t.document.body.innerHTML="",t.document.body.appendChild(a),t.document.body.appendChild(o),t.print(),t.close()}async function qe(){const e=Oe("/apps/twofactor_backupcodes/settings/create"),{data:n}=await je.post(e);return n}const q=Ee("twofactor_backupcodes","state"),ze=He("twofactor_backupcodes",()=>{const e=S(q.enabled),n=S(q.total),t=S(q.used),a=S([]);async function o(){e.value=!1;const{codes:u,state:c}=await qe();e.value=c.enabled,n.value=c.total,t.value=c.used,a.value=u}return{enabled:e,total:n,used:t,codes:a,generate:o}}),De=["aria-label"],Ke=xe({__name:"PersonalSettings",setup(e){const n=ce().theming.name??"Nextcloud",t=ze(),a=S(!1),o=z(()=>t.codes&&t.codes.length>0),u=n+"-backup-codes.txt",c=z(()=>o.value?"data:text/plain,"+encodeURIComponent(t.codes.reduce((d,_)=>d+_+`
`,"")):"");async function y(){await Le(),a.value=!0;try{await t.generate()}catch(d){Je.error("Error generating backup codes",{error:d}),se(f("twofactor_backupcodes","An error occurred while generating your backup codes"))}finally{a.value=!1}}function g(){Re(!t.codes||t.codes.length===0?[]:t.codes)}return(d,_)=>(k(),w("div",{class:H(d.$style.backupcodesSettings)},[i(t).enabled?(k(),w(A,{key:1},[L("p",null,[o.value?(k(),w(A,{key:1},[E(m(i(f)("twofactor_backupcodes","These are your backup codes. Please save and/or print them as you will not be able to read the codes again later."))+" ",1),L("ul",{"aria-label":i(f)("twofactor_backupcodes","List of backup codes")},[(k(!0),w(A,null,Ce(i(t).codes,h=>(k(),w("li",{key:h,class:H(d.$style.backupcodesSettings__code)},m(h),3))),128))],8,De)],64)):(k(),w(A,{key:0},[E(m(i(f)("twofactor_backupcodes","Backup codes have been generated. {used} of {total} codes have been used.",{used:i(t).used,total:i(t).total})),1)],64))]),L("p",{class:H(d.$style.backupcodesSettings__actions)},[J(i(T),{id:"generate-backup-codes",variant:"error",onClick:y},{default:M(()=>[E(m(i(f)("twofactor_backupcodes","Regenerate backup codes")),1)]),_:1}),o.value?(k(),w(A,{key:0},[J(i(T),{onClick:g},{default:M(()=>[E(m(i(f)("twofactor_backupcodes","Print backup codes")),1)]),_:1}),J(i(T),{href:c.value,download:u,variant:"primary"},{default:M(()=>[E(m(i(f)("twofactor_backupcodes","Save backup codes")),1)]),_:1},8,["href"])],64)):Y("",!0)],2),L("p",null,[L("em",null,m(i(f)("twofactor_backupcodes","If you regenerate backup codes, you automatically invalidate old codes.")),1)])],64)):(k(),X(i(T),{key:0,disabled:a.value,variant:"primary",onClick:y},{icon:M(()=>[a.value?(k(),X(i(Pe),{key:0})):Y("",!0)]),default:M(()=>[E(" "+m(i(f)("twofactor_backupcodes","Generate backup codes")),1)]),_:1},8,["disabled"]))],2))}}),We="_backupcodesSettings_bnkw8_2",Qe="_backupcodesSettings__code_bnkw8_7",Ve="_backupcodesSettings__actions_bnkw8_13",Xe={backupcodesSettings:We,backupcodesSettings__code:Qe,backupcodesSettings__actions:Ve},Ye={$style:Xe},Ze=Ie(Ke,[["__cssModules",Ye]]),et=Ne(),te=Me(Ze);te.use(et),te.mount("#twofactor-backupcodes-settings");
//# sourceMappingURL=twofactor_backupcodes-settings-personal.mjs.map