adminizer 4.1.0-build.38 → 4.1.0-build.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/app.js +27 -31
- package/assets/login-BWs195kG.js +6 -0
- package/assets/manifest.json +1 -1
- package/controllers/login.js +16 -7
- package/interfaces/adminpanelConfig.d.ts +4 -0
- package/package.json +1 -1
- package/system/defaults.js +2 -1
- package/assets/login-BMJ97XcF.js +0 -6
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{r as te,q as Fe,S as He,j as a,J as Oe}from"./app.js";import{c as ze}from"./compiler-runtime-Cj7rbuyn.js";import{L as xe}from"./label-GEoZpZr4.js";import{I as be}from"./input-B7wUhbil.js";import{Icon as pe}from"./icon-CqJOMij7.js";import{B as _e}from"./button-BV-GbIpN.js";import{T as De,t as Ee}from"./sonner-Dp8PyHu_.js";import ue from"./input-error-DFk1EyT_.js";import{i as Ge}from"./use-appearance-DeUiDZ72.js";import{c as Ke}from"./createLucideIcon-BFG25zNo.js";import{L as qe}from"./loader-circle-Utah5tGx.js";import"./index-DN1K56yz.js";import"./index-DU8vYhyh.js";import"./utils-DjqsqOe8.js";/**
|
|
2
|
+
* @license lucide-react v0.485.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const Ve=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],ke=Ke("user",Ve),ve=(e,t,s)=>{let r=1n,n=e%s;for(;t;)t&1n&&(r=r*n%s),n=n*n%s,t=t>>1n;return r};function re(e,t,s){return typeof e=="bigint"&&typeof t=="bigint"&&typeof s=="bigint"?ve(e,t,s):Number(ve(BigInt(e),BigInt(t),BigInt(s)))}const k=crypto,We=new TextEncoder,Xe=new TextDecoder("utf-8",{ignoreBOM:!0}),Y={encode:e=>We.encode(e),decode:e=>Xe.decode(e)},Ne=(()=>{const t=[..."0123456789abcdef"],s=new Array(256);for(let r=0;r<256;r++)s[r]=`${t[r>>>4&15]}${t[r&15]}`;return s})(),Je=(()=>{const e={};for(let t=0;t<256;t++){const s=Ne[t],r=s[0],n=r.toUpperCase(),c=s[1],o=c.toUpperCase();e[s]=t,e[`${r}${o}`]=t,e[`${n}${c}`]=t,e[`${n}${o}`]=t}return e})(),Ye=e=>!(e.length%2||!/^[a-fA-F0-9]*$/.test(e)),fe={encode:e=>{let t="";for(let s=0,r=e.length;s<r;s++)t+=Ne[e[s]];return t},encodeStr:e=>fe.encode(Y.encode(e)),decode:e=>{const t=e.length/2,s=new Uint8Array(t);for(let r=0;r<t;r++)s[r]=Je[e.slice(r*2,r*2+2)];return s},decodeStr:e=>Y.decode(fe.decode(e)),is:Ye},Ie=e=>fe.encode(e),Se=new TextEncoder,se=e=>{const t=async o=>o instanceof Uint8Array?k.subtle.importKey("raw",o,{name:"PBKDF2"},!1,["deriveBits"]):typeof o=="string"?t(Se.encode(o.normalize())):o,s=(o,i,l,d)=>(i=typeof i=="string"?Se.encode(i):i,k.subtle.deriveBits({name:"PBKDF2",salt:i,iterations:l,hash:{name:e}},o,d)),r=async(o,i,l,d)=>{const p=await t(o);return await s(p,i,l,d*8)},n=async(o,i,l,d)=>new Uint8Array(await r(o,i,l,d)),c=async(o,i,l,d)=>Ie(await n(o,i,l,d));return c.buffer=r,c.hex=c,c.uint8=n,c},Te={sha1:se("SHA-1"),sha256:se("SHA-256"),sha384:se("SHA-384"),sha512:se("SHA-512")},ge=e=>{const t=new Uint8Array(e);return k.getRandomValues(t),t},Qe=new TextEncoder,oe=e=>{const t=n=>(n=typeof n=="string"?Qe.encode(n):n,k.subtle.digest(e,n)),s=async n=>new Uint8Array(await t(n)),r=async n=>Ie(await s(n));return r.buffer=t,r.hex=r,r.uint8=s,r};oe("SHA-1");const Le=oe("SHA-256");oe("SHA-384");oe("SHA-512");const w={encode:e=>{if(e!==e>>0)throw new Error("Invalid 32-bit integer");const t=e>>24&255,s=e>>16&255,r=e>>8&255,n=e>>0&255;return new Uint8Array([t,s,r,n])},decode:e=>{if(e.length!==4)throw new Error("Invalid 32-bit integer");const t=e[0],s=e[1],r=e[2],n=e[3];return(t<<24)+(s<<16)+(r<<8)+(n<<0)}},Ue=e=>{const t=e.reduce((r,n)=>r+n.byteLength,0),s=new Uint8Array(t);for(let r=0,n=0,c=e.length;n<c;n++)s.set(e[n],r),r+=e[n].byteLength;return s},Ze=async(e,t,s,r)=>{e=typeof e=="string"?Y.encode(e):e,s=typeof s=="string"?Y.encode(s):s||ge(32),s=s.length===32?s:await Le.uint8(s);const n=new Uint8Array([1]),c=Math.max(1,r||0),o=await Te.sha256.uint8(t,s,c,32),i=await k.subtle.importKey("raw",o,"AES-GCM",!1,["encrypt"]),l=ge(16),d=await k.subtle.encrypt({name:"AES-GCM",iv:l,length:256,tagLength:128},i,e),p=new Uint8Array(d);return Ue([n,s,w.encode(c),l,p])},en=async(e,t)=>{if(e[0]!==1)throw new Error("Unsupported encrypted archive version");const r=e.subarray(1,33),n=w.decode(e.subarray(33,37)),c=e.subarray(37,53),o=e.subarray(53),i=await Te.sha256.uint8(t,r,n,32),l=await k.subtle.importKey("raw",i,"AES-GCM",!1,["decrypt"]),d=await k.subtle.decrypt({name:"AES-GCM",iv:c,length:256,tagLength:128},l,o);return new Uint8Array(d)},je=Object.freeze(Object.defineProperty({__proto__:null,decrypt:en,encrypt:Ze},Symbol.toStringTag,{value:"Module"}));function J(e){let t,s=0;return()=>((!t||s===t.length)&&(t=new e(65536/(e.BYTES_PER_ELEMENT*8)),s=0,k.getRandomValues(t)),t[s++])}function nn(e,t){let s=0,r=t;return()=>(r===t&&(s=e(),r=0),s&1<<r++?1:0)}const Q={get1:nn(J(Uint8Array),8),get8:J(Uint8Array),get16:J(Uint16Array),get32:J(Uint32Array),get64:J(BigUint64Array)},tn=Object.assign(()=>BigInt(Q.get1()),{BITS:1}),sn=Object.assign(()=>BigInt(Q.get8()),{BITS:8}),rn=Object.assign(()=>BigInt(Q.get16()),{BITS:16}),on=Object.assign(()=>BigInt(Q.get32()),{BITS:32}),cn=Object.assign(()=>Q.get64(),{BITS:64}),f=e=>{const t=e<=1?tn:e<=8?sn:e<=16?rn:e<=32?on:cn,s=t.BITS;if(e===s)return t();if(e===128)return t()<<64n|t();if(e===160)return f(128)<<32n|f(32);if(e===192)return f(128)<<64n|f(64);if(e===224)return f(160)<<64n|f(64);if(e===256)return f(128)<<128n|f(128);if(e===384)return f(256)<<128n|f(128);if(e===512)return f(256)<<256n|f(256);if(e===1024)return f(512)<<512n|f(512);if(e===2048)return f(1024)<<1024n|f(1024);let r=0,n=0n;for(;r<e;){const c=Math.min(s,e-r),o=2n**BigInt(c)-1n,l=t()&o;if(e===c)return l;n=r?n|l<<BigInt(r):l,r+=c}return n},Me=(e,t)=>{if(e=BigInt(e),t=BigInt(t),e<0n||t<0n)throw new Error("Negative ranges are not supported");if(t<=e)throw new Error('"max" must be at least equal to "min" plus 1');const s=t-e-1n,r=s.toString(2).length;for(;;){const n=f(r);if(!(n>s))return n+e}},Ce=[2n,3n,5n,7n,11n,13n,17n,19n,23n,29n,31n,37n,41n,43n,47n,53n,59n,61n,67n,71n,73n,79n,83n,89n,97n,101n,103n,107n,109n,113n,127n,131n,137n,139n,149n,151n,157n,163n,167n,173n,179n,181n,191n,193n,197n,199n,211n,223n,227n,229n,233n,239n,241n,251n,257n,263n,269n,271n,277n,281n,283n,293n,307n,311n,313n,317n,331n,337n,347n,349n,353n,359n,367n,373n,379n,383n,389n,397n,401n,409n,419n,421n,431n,433n,439n,443n,449n,457n,461n,463n,467n,479n,487n,491n,499n,503n,509n,521n,523n,541n,547n,557n,563n,569n,571n,577n,587n,593n,599n,601n,607n,613n,617n,619n,631n,641n,643n,647n,653n,659n,661n,673n,677n,683n,691n,701n,709n,719n,727n,733n,739n,743n,751n,757n,761n,769n,773n,787n,797n,809n,811n,821n,823n,827n,829n,839n,853n,857n,859n,863n,877n,881n,883n,887n,907n,911n,919n,929n,937n,941n,947n,953n,967n,971n,977n,983n,991n,997n],an=(e,t=8)=>{if(e<=1n)return!1;for(let n=0,c=Ce.length;n<c;n++){const o=Ce[n];if(e%o===0n)return e===o}if(e<=1000n)return!1;let s=0n,r=e-1n;for(;(r&1n)===0n;)s+=1n,r>>=1n;for(let n=0;n<t;n++){const c=Me(2n,e-2n);let o=re(c,r,e),i=0n;for(let l=0;l<s;l++){if(i=re(o,2n,e),i===1n&&o!==1n&&o!==e-1n)return!1;o=i}if(i!==1n)return!1}return!0},Be=(e,t=8)=>{let s=f(e);for((s&1n)===0n&&(s+=1n);;){if(an(s,t))return s;s+=2n}},x={encode:e=>{let t=0n;for(let s=0,r=e.length;s<r;s++)t|=BigInt(e[s])<<(BigInt(r)-BigInt(s)-1n)*8n;return t},decode:e=>{if(e<0n)throw new Error("Negative BigInts are not supported");const t=[];for(;e;)t.push(Number(e&0xffn)),e>>=8n;return new Uint8Array(t.reverse())}},Ae={archive:e=>{const[t,s,r,n,c]=e,o=x.decode(t),i=w.encode(o.length),l=x.decode(s),d=w.encode(l.length),p=x.decode(r),h=w.encode(p.length),g=x.decode(n),m=w.encode(g.length);return Ue([i,o,d,l,h,p,m,g,c])},unarchive:e=>{const s=e.slice(0,4),r=w.decode(s),n=4,c=e.slice(n,n+r),o=x.encode(c),i=n+r,l=e.slice(i,i+4),d=w.decode(l),p=i+4,h=e.slice(p,p+d),g=x.encode(h),m=p+d,y=e.slice(m,m+4),v=w.decode(y),u=m+4,N=e.slice(u,u+v),S=x.encode(N),b=u+v,I=e.slice(b,b+4),_=w.decode(I),j=b+4,C=e.slice(j,j+_),B=x.encode(C),A=j+_,E=e.slice(A);return[o,g,S,B,E]}},ln=(e,t,s)=>{let r=e%s;if(t<=BigInt(Number.MAX_SAFE_INTEGER))for(let n=Number(t);n>0;n--)r=r*r%s;else for(let n=t;n>0n;n--)r=r*r%s;return r%s},dn={generate:async e=>{const t=e.primeBits??100,s=e.primeRounds??20,r=e.opsPerSecond??33e5,n=e.duration??1e3,c=e.message,o=Be(t,s),i=Be(t,s),l=o*i,d=(o-1n)*(i-1n),p=r,h=n,g=BigInt(Math.round(Math.max(1,p/1e3)*h)),m=await Le.uint8(ge(32)),y=c,v=await je.encrypt(y,m),u=Me(1n,l-1n),N=re(2n,g,d),S=re(u,N,l),b=x.encode(m)+S;return Ae.archive([l,u,g,b,v])},solve:async e=>{const[t,s,r,n,c]=Ae.unarchive(e),o=ln(s,r,t),i=x.decode(n-o),l=await je.decrypt(c,i);return Y.decode(l)}};function An(){const e=ze.c(85),[t,s]=te.useState(!1);let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=[],e[0]=r):r=e[0],te.useEffect(fn,r);const n=Fe(),c=Array.isArray(n.props.captchaTask)&&n.props.captchaTask.length>0,[o,i]=te.useState("I'm not a robot"),[l,d]=te.useState(!1);let p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p={login:"",password:"",captchaSolution:""},e[1]=p):p=e[1];const{post:h,data:g,setData:m,processing:y,transform:v,errors:u,clearErrors:N}=He(p);let S;e[2]!==c||e[3]!==n.props.captchaTask||e[4]!==n.props.submitLink||e[5]!==h||e[6]!==v?(S=T=>{if(T.preventDefault(),!c){h(n.props.submitLink,{onError:un});return}s(!0),i("Solving CAPTCHA..."),d(!1),(async()=>{try{await function(Re){return new Promise($e=>setTimeout($e,Re))}(100);const ye=new Uint8Array(n.props.captchaTask),Pe=await dn.solve(ye);i("Verification complete!"),s(!1),d(!0),v(we=>({...we,captchaSolution:Pe})),h(n.props.submitLink,{onError:pn})}catch(me){console.error("Error solving CAPTCHA:",me),i("Error solving CAPTCHA. Try again.")}})()},e[2]=c,e[3]=n.props.captchaTask,e[4]=n.props.submitLink,e[5]=h,e[6]=v,e[7]=S):S=e[7];const b=S;let I;e[8]!==N||e[9]!==m?(I=(T,he)=>{N(),m(T,he)},e[8]=N,e[9]=m,e[10]=I):I=e[10];const _=I;let j;e[11]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsx(De,{position:"top-center",richColors:!0,closeButton:!0}),e[11]=j):j=e[11];let C;e[12]!==n.props.title?(C=a.jsx("h1",{className:"font-medium mb-6 text-xl",children:n.props.title}),e[12]=n.props.title,e[13]=C):C=e[13];let B;e[14]!==n.props.description?(B=n.props.description&&a.jsx("p",{className:"font-thin mb-6 text-xs pb-10",children:n.props.description}),e[14]=n.props.description,e[15]=B):B=e[15];let A;e[16]!==u.captchaSolution||e[17]!==c?(A=c&&a.jsx(ue,{message:u.captchaSolution}),e[16]=u.captchaSolution,e[17]=c,e[18]=A):A=e[18];let E;e[19]!==n.props.login?(E=a.jsx(xe,{htmlFor:"login",children:n.props.login}),e[19]=n.props.login,e[20]=E):E=e[20];let Z;e[21]===Symbol.for("react.memo_cache_sentinel")?(Z=a.jsx(pe,{iconNode:ke,className:"size-5 absolute inset-2"}),e[21]=Z):Z=e[21];const ce=`pl-10 ${u.login?"border-red-500":""}`,ie=y||t;let L;e[22]!==_?(L=T=>{_("login",T.target.value)},e[22]=_,e[23]=L):L=e[23];let U;e[24]!==g.login||e[25]!==n.props.login||e[26]!==ce||e[27]!==ie||e[28]!==L?(U=a.jsx(be,{id:"login",className:ce,type:"text",required:!0,tabIndex:1,autoComplete:"username",value:g.login,disabled:ie,onChange:L,placeholder:n.props.login}),e[24]=g.login,e[25]=n.props.login,e[26]=ce,e[27]=ie,e[28]=L,e[29]=U):U=e[29];let M;e[30]!==u.login?(M=a.jsx(ue,{message:u.login}),e[30]=u.login,e[31]=M):M=e[31];let P;e[32]!==U||e[33]!==M?(P=a.jsxs("div",{className:"relative",children:[Z,U,M]}),e[32]=U,e[33]=M,e[34]=P):P=e[34];let R;e[35]!==P||e[36]!==E?(R=a.jsxs("div",{className:"grid gap-4",children:[E,P]}),e[35]=P,e[36]=E,e[37]=R):R=e[37];let $;e[38]!==n.props.password?($=a.jsx(xe,{htmlFor:"login",children:n.props.password}),e[38]=n.props.password,e[39]=$):$=e[39];let ee;e[40]===Symbol.for("react.memo_cache_sentinel")?(ee=a.jsx(pe,{iconNode:ke,className:"size-5 absolute inset-2"}),e[40]=ee):ee=e[40];const ae=`pl-10 ${u.password?"border-red-500":""}`,le=y||t;let F;e[41]!==_?(F=T=>{_("password",T.target.value)},e[41]=_,e[42]=F):F=e[42];let H;e[43]!==g.password||e[44]!==n.props.password||e[45]!==ae||e[46]!==le||e[47]!==F?(H=a.jsx(be,{id:"password",className:ae,type:"password",required:!0,disabled:le,tabIndex:1,autoComplete:"current-password",value:g.password,onChange:F,placeholder:n.props.password}),e[43]=g.password,e[44]=n.props.password,e[45]=ae,e[46]=le,e[47]=F,e[48]=H):H=e[48];let O;e[49]!==u.password?(O=a.jsx(ue,{message:u.password}),e[49]=u.password,e[50]=O):O=e[50];let z;e[51]!==H||e[52]!==O?(z=a.jsxs("div",{className:"relative",children:[ee,H,O]}),e[51]=H,e[52]=O,e[53]=z):z=e[53];let D;e[54]!==$||e[55]!==z?(D=a.jsxs("div",{className:"grid gap-4",children:[$,z]}),e[54]=$,e[55]=z,e[56]=D):D=e[56];const de=y||t;let G;e[57]!==n.props.submitButton||e[58]!==de?(G=a.jsx(_e,{type:"submit",className:"w-fit",disabled:de,children:n.props.submitButton}),e[57]=n.props.submitButton,e[58]=de,e[59]=G):G=e[59];let K;e[60]!==t||e[61]!==n.props.registerLink||e[62]!==y?(K=n.props.registerLink&&a.jsx(_e,{asChild:!0,variant:"outline",children:a.jsx(Oe,{href:n.props.registerLink.link,className:`${y||t} ? 'pointer-events-none opacity-50' : ''`,children:n.props.registerLink.title})}),e[60]=t,e[61]=n.props.registerLink,e[62]=y,e[63]=K):K=e[63];let q;e[64]!==G||e[65]!==K?(q=a.jsxs("div",{className:"flex gap-4",children:[G,K]}),e[64]=G,e[65]=K,e[66]=q):q=e[66];let V;e[67]!==R||e[68]!==D||e[69]!==q||e[70]!==A?(V=a.jsxs("div",{className:"grid gap-5",children:[A,R,D,q]}),e[67]=R,e[68]=D,e[69]=q,e[70]=A,e[71]=V):V=e[71];let W;e[72]!==o||e[73]!==t||e[74]!==c||e[75]!==l?(W=c&&a.jsxs("div",{className:"bg-white rounded-lg shadow-lg p-4 mt-6 flex items-center space-x-4",children:[a.jsxs("div",{className:"relative",children:[a.jsx("div",{className:"w-10 h-10 bg-blue-100 rounded-full flex items-center justify-center",children:a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 text-yellow-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 2l3.09 6.26L22 9.27l-5 4.87L18.18 22 12 18.27 5.82 22 7 14.14l-5-4.87 6.91-1.01L12 2z"})})}),a.jsx("div",{className:`${t?"":"hidden"}`,children:a.jsx(pe,{iconNode:qe,className:"animate-spin size-6 absolute inset-0 m-auto !text-gray-600"})})]}),a.jsx("div",{className:"text-gray-600 font-semibold",children:o}),a.jsx("div",{className:`transition-opacity ${l?"opacity-100 visible":"opacity-0 invisible"}`,children:a.jsx("svg",{id:"checkmark",xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 text-green-500",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:a.jsx("path",{className:"checkmark",strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})})]}),e[72]=o,e[73]=t,e[74]=c,e[75]=l,e[76]=W):W=e[76];let X;e[77]!==b||e[78]!==V||e[79]!==W?(X=a.jsxs("form",{onSubmit:b,children:[V,W]}),e[77]=b,e[78]=V,e[79]=W,e[80]=X):X=e[80];let ne;return e[81]!==X||e[82]!==C||e[83]!==B?(ne=a.jsxs("div",{className:"bg-sidebar flex min-h-svh w-full justify-center",children:[j,a.jsxs("div",{className:"rounded-xl border bg-card text-card-foreground shadow p-6 max-w-sm w-full h-fit mt-[15%]",children:[C,B,X]})]}),e[81]=X,e[82]=C,e[83]=B,e[84]=ne):ne=e[84],ne}function pn(e){for(const t of Object.keys(e))Ee.error(e[t])}function un(e){for(const t of Object.keys(e))Ee.error(e[t])}function fn(){Ge()}export{An as default};
|
package/assets/manifest.json
CHANGED
package/controllers/login.js
CHANGED
|
@@ -33,10 +33,12 @@ export default async function login(req, res) {
|
|
|
33
33
|
}
|
|
34
34
|
return req.Inertia.redirect(`${req.adminizer.config.routePrefix}/`);
|
|
35
35
|
}
|
|
36
|
-
// Verify CAPTCHA solution
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
// Verify CAPTCHA solution if enabled
|
|
37
|
+
if (req.adminizer.config.auth.captcha !== false) {
|
|
38
|
+
const isCaptchaValid = powCaptcha.check(captchaSolution, `login:${req.ip}`);
|
|
39
|
+
if (!isCaptchaValid) {
|
|
40
|
+
return inertiaAdminMessage(req, "Invalid CAPTCHA solution", 'captchaSolution');
|
|
41
|
+
}
|
|
40
42
|
}
|
|
41
43
|
if (!user) {
|
|
42
44
|
return inertiaAdminMessage(req, "Wrong username", 'login');
|
|
@@ -66,8 +68,11 @@ export default async function login(req, res) {
|
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
70
|
if (req.method.toUpperCase() === "GET") {
|
|
69
|
-
// Generate new CAPTCHA
|
|
70
|
-
|
|
71
|
+
// Generate new CAPTCHA task if enabled
|
|
72
|
+
let captchaTask = [];
|
|
73
|
+
if (req.adminizer.config.auth.captcha !== false) {
|
|
74
|
+
captchaTask = await powCaptcha.getJob(`login:${req.ip}`);
|
|
75
|
+
}
|
|
71
76
|
return req.Inertia.render({
|
|
72
77
|
component: 'login',
|
|
73
78
|
props: {
|
|
@@ -97,7 +102,11 @@ export default async function login(req, res) {
|
|
|
97
102
|
async function inertiaAdminMessage(req, message, messageType) {
|
|
98
103
|
Adminizer.log.warn(message);
|
|
99
104
|
const powCaptcha = new POWCaptcha();
|
|
100
|
-
|
|
105
|
+
// Generate new CAPTCHA task if enabled
|
|
106
|
+
let captchaTask = [];
|
|
107
|
+
if (req.adminizer.config.auth.captcha !== false) {
|
|
108
|
+
captchaTask = await powCaptcha.getJob(`login:${req.ip}`);
|
|
109
|
+
}
|
|
101
110
|
let errors = {};
|
|
102
111
|
errors[messageType] = message;
|
|
103
112
|
return req.Inertia.render({
|
|
@@ -30,7 +30,11 @@ export interface AdminpanelConfig {
|
|
|
30
30
|
* by default is false
|
|
31
31
|
*/
|
|
32
32
|
auth?: {
|
|
33
|
+
/** Enable or disable authentication for admin panel */
|
|
33
34
|
enable: boolean;
|
|
35
|
+
/** Enable crypto-puzzle CAPTCHA (default: true) */
|
|
36
|
+
captcha?: boolean;
|
|
37
|
+
/** Description displayed on login page */
|
|
34
38
|
description?: string;
|
|
35
39
|
};
|
|
36
40
|
/**
|
package/package.json
CHANGED
package/system/defaults.js
CHANGED
package/assets/login-BMJ97XcF.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{r as ie,q as Ke,S as qe,j as i,J as Ve}from"./app.js";import{c as We}from"./compiler-runtime-Cj7rbuyn.js";import{L as Be}from"./label-GEoZpZr4.js";import{I as Ce}from"./input-B7wUhbil.js";import{Icon as we}from"./icon-CqJOMij7.js";import{B as Ae}from"./button-BV-GbIpN.js";import{T as Xe,t as Je}from"./sonner-Dp8PyHu_.js";import xe from"./input-error-DFk1EyT_.js";import{i as Ye}from"./use-appearance-DeUiDZ72.js";import{c as Qe}from"./createLucideIcon-BFG25zNo.js";import{L as Ze}from"./loader-circle-Utah5tGx.js";import"./index-DN1K56yz.js";import"./index-DU8vYhyh.js";import"./utils-DjqsqOe8.js";/**
|
|
2
|
-
* @license lucide-react v0.485.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const en=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],Ne=Qe("user",en),Ee=(e,t,s)=>{let r=1n,n=e%s;for(;t;)t&1n&&(r=r*n%s),n=n*n%s,t=t>>1n;return r};function ae(e,t,s){return typeof e=="bigint"&&typeof t=="bigint"&&typeof s=="bigint"?Ee(e,t,s):Number(Ee(BigInt(e),BigInt(t),BigInt(s)))}const S=crypto,nn=new TextEncoder,tn=new TextDecoder("utf-8",{ignoreBOM:!0}),ee={encode:e=>nn.encode(e),decode:e=>tn.decode(e)},Pe=(()=>{const t=[..."0123456789abcdef"],s=new Array(256);for(let r=0;r<256;r++)s[r]=`${t[r>>>4&15]}${t[r&15]}`;return s})(),sn=(()=>{const e={};for(let t=0;t<256;t++){const s=Pe[t],r=s[0],n=r.toUpperCase(),c=s[1],o=c.toUpperCase();e[s]=t,e[`${r}${o}`]=t,e[`${n}${c}`]=t,e[`${n}${o}`]=t}return e})(),rn=e=>!(e.length%2||!/^[a-fA-F0-9]*$/.test(e)),be={encode:e=>{let t="";for(let s=0,r=e.length;s<r;s++)t+=Pe[e[s]];return t},encodeStr:e=>be.encode(ee.encode(e)),decode:e=>{const t=e.length/2,s=new Uint8Array(t);for(let r=0;r<t;r++)s[r]=sn[e.slice(r*2,r*2+2)];return s},decodeStr:e=>ee.decode(be.decode(e)),is:rn},Re=e=>be.encode(e),Ie=new TextEncoder,le=e=>{const t=async o=>o instanceof Uint8Array?S.subtle.importKey("raw",o,{name:"PBKDF2"},!1,["deriveBits"]):typeof o=="string"?t(Ie.encode(o.normalize())):o,s=(o,l,a,d)=>(l=typeof l=="string"?Ie.encode(l):l,S.subtle.deriveBits({name:"PBKDF2",salt:l,iterations:a,hash:{name:e}},o,d)),r=async(o,l,a,d)=>{const u=await t(o);return await s(u,l,a,d*8)},n=async(o,l,a,d)=>new Uint8Array(await r(o,l,a,d)),c=async(o,l,a,d)=>Re(await n(o,l,a,d));return c.buffer=r,c.hex=c,c.uint8=n,c},$e={sha1:le("SHA-1"),sha256:le("SHA-256"),sha384:le("SHA-384"),sha512:le("SHA-512")},_e=e=>{const t=new Uint8Array(e);return S.getRandomValues(t),t},on=new TextEncoder,de=e=>{const t=n=>(n=typeof n=="string"?on.encode(n):n,S.subtle.digest(e,n)),s=async n=>new Uint8Array(await t(n)),r=async n=>Re(await s(n));return r.buffer=t,r.hex=r,r.uint8=s,r};de("SHA-1");const Fe=de("SHA-256");de("SHA-384");de("SHA-512");const b={encode:e=>{if(e!==e>>0)throw new Error("Invalid 32-bit integer");const t=e>>24&255,s=e>>16&255,r=e>>8&255,n=e>>0&255;return new Uint8Array([t,s,r,n])},decode:e=>{if(e.length!==4)throw new Error("Invalid 32-bit integer");const t=e[0],s=e[1],r=e[2],n=e[3];return(t<<24)+(s<<16)+(r<<8)+(n<<0)}},He=e=>{const t=e.reduce((r,n)=>r+n.byteLength,0),s=new Uint8Array(t);for(let r=0,n=0,c=e.length;n<c;n++)s.set(e[n],r),r+=e[n].byteLength;return s},cn=async(e,t,s,r)=>{e=typeof e=="string"?ee.encode(e):e,s=typeof s=="string"?ee.encode(s):s||_e(32),s=s.length===32?s:await Fe.uint8(s);const n=new Uint8Array([1]),c=Math.max(1,r||0),o=await $e.sha256.uint8(t,s,c,32),l=await S.subtle.importKey("raw",o,"AES-GCM",!1,["encrypt"]),a=_e(16),d=await S.subtle.encrypt({name:"AES-GCM",iv:a,length:256,tagLength:128},l,e),u=new Uint8Array(d);return He([n,s,b.encode(c),a,u])},ln=async(e,t)=>{if(e[0]!==1)throw new Error("Unsupported encrypted archive version");const r=e.subarray(1,33),n=b.decode(e.subarray(33,37)),c=e.subarray(37,53),o=e.subarray(53),l=await $e.sha256.uint8(t,r,n,32),a=await S.subtle.importKey("raw",l,"AES-GCM",!1,["decrypt"]),d=await S.subtle.decrypt({name:"AES-GCM",iv:c,length:256,tagLength:128},a,o);return new Uint8Array(d)},Le=Object.freeze(Object.defineProperty({__proto__:null,decrypt:ln,encrypt:cn},Symbol.toStringTag,{value:"Module"}));function Z(e){let t,s=0;return()=>((!t||s===t.length)&&(t=new e(65536/(e.BYTES_PER_ELEMENT*8)),s=0,S.getRandomValues(t)),t[s++])}function an(e,t){let s=0,r=t;return()=>(r===t&&(s=e(),r=0),s&1<<r++?1:0)}const ne={get1:an(Z(Uint8Array),8),get8:Z(Uint8Array),get16:Z(Uint16Array),get32:Z(Uint32Array),get64:Z(BigUint64Array)},dn=Object.assign(()=>BigInt(ne.get1()),{BITS:1}),fn=Object.assign(()=>BigInt(ne.get8()),{BITS:8}),un=Object.assign(()=>BigInt(ne.get16()),{BITS:16}),pn=Object.assign(()=>BigInt(ne.get32()),{BITS:32}),gn=Object.assign(()=>ne.get64(),{BITS:64}),f=e=>{const t=e<=1?dn:e<=8?fn:e<=16?un:e<=32?pn:gn,s=t.BITS;if(e===s)return t();if(e===128)return t()<<64n|t();if(e===160)return f(128)<<32n|f(32);if(e===192)return f(128)<<64n|f(64);if(e===224)return f(160)<<64n|f(64);if(e===256)return f(128)<<128n|f(128);if(e===384)return f(256)<<128n|f(128);if(e===512)return f(256)<<256n|f(256);if(e===1024)return f(512)<<512n|f(512);if(e===2048)return f(1024)<<1024n|f(1024);let r=0,n=0n;for(;r<e;){const c=Math.min(s,e-r),o=2n**BigInt(c)-1n,a=t()&o;if(e===c)return a;n=r?n|a<<BigInt(r):a,r+=c}return n},Oe=(e,t)=>{if(e=BigInt(e),t=BigInt(t),e<0n||t<0n)throw new Error("Negative ranges are not supported");if(t<=e)throw new Error('"max" must be at least equal to "min" plus 1');const s=t-e-1n,r=s.toString(2).length;for(;;){const n=f(r);if(!(n>s))return n+e}},Te=[2n,3n,5n,7n,11n,13n,17n,19n,23n,29n,31n,37n,41n,43n,47n,53n,59n,61n,67n,71n,73n,79n,83n,89n,97n,101n,103n,107n,109n,113n,127n,131n,137n,139n,149n,151n,157n,163n,167n,173n,179n,181n,191n,193n,197n,199n,211n,223n,227n,229n,233n,239n,241n,251n,257n,263n,269n,271n,277n,281n,283n,293n,307n,311n,313n,317n,331n,337n,347n,349n,353n,359n,367n,373n,379n,383n,389n,397n,401n,409n,419n,421n,431n,433n,439n,443n,449n,457n,461n,463n,467n,479n,487n,491n,499n,503n,509n,521n,523n,541n,547n,557n,563n,569n,571n,577n,587n,593n,599n,601n,607n,613n,617n,619n,631n,641n,643n,647n,653n,659n,661n,673n,677n,683n,691n,701n,709n,719n,727n,733n,739n,743n,751n,757n,761n,769n,773n,787n,797n,809n,811n,821n,823n,827n,829n,839n,853n,857n,859n,863n,877n,881n,883n,887n,907n,911n,919n,929n,937n,941n,947n,953n,967n,971n,977n,983n,991n,997n],hn=(e,t=8)=>{if(e<=1n)return!1;for(let n=0,c=Te.length;n<c;n++){const o=Te[n];if(e%o===0n)return e===o}if(e<=1000n)return!1;let s=0n,r=e-1n;for(;(r&1n)===0n;)s+=1n,r>>=1n;for(let n=0;n<t;n++){const c=Oe(2n,e-2n);let o=ae(c,r,e),l=0n;for(let a=0;a<s;a++){if(l=ae(o,2n,e),l===1n&&o!==1n&&o!==e-1n)return!1;o=l}if(l!==1n)return!1}return!0},Ue=(e,t=8)=>{let s=f(e);for((s&1n)===0n&&(s+=1n);;){if(hn(s,t))return s;s+=2n}},_={encode:e=>{let t=0n;for(let s=0,r=e.length;s<r;s++)t|=BigInt(e[s])<<(BigInt(r)-BigInt(s)-1n)*8n;return t},decode:e=>{if(e<0n)throw new Error("Negative BigInts are not supported");const t=[];for(;e;)t.push(Number(e&0xffn)),e>>=8n;return new Uint8Array(t.reverse())}},Me={archive:e=>{const[t,s,r,n,c]=e,o=_.decode(t),l=b.encode(o.length),a=_.decode(s),d=b.encode(a.length),u=_.decode(r),h=b.encode(u.length),m=_.decode(n),g=b.encode(m.length);return He([l,o,d,a,h,u,g,m,c])},unarchive:e=>{const s=e.slice(0,4),r=b.decode(s),n=4,c=e.slice(n,n+r),o=_.encode(c),l=n+r,a=e.slice(l,l+4),d=b.decode(a),u=l+4,h=e.slice(u,u+d),m=_.encode(h),g=u+d,A=e.slice(g,g+4),p=b.decode(A),y=g+4,k=e.slice(y,y+p),N=_.encode(k),w=y+p,v=e.slice(w,w+4),E=b.decode(v),x=w+4,j=e.slice(x,x+E),B=_.encode(j),C=x+E,L=e.slice(C);return[o,m,N,B,L]}},mn=(e,t,s)=>{let r=e%s;if(t<=BigInt(Number.MAX_SAFE_INTEGER))for(let n=Number(t);n>0;n--)r=r*r%s;else for(let n=t;n>0n;n--)r=r*r%s;return r%s},yn={generate:async e=>{const t=e.primeBits??100,s=e.primeRounds??20,r=e.opsPerSecond??33e5,n=e.duration??1e3,c=e.message,o=Ue(t,s),l=Ue(t,s),a=o*l,d=(o-1n)*(l-1n),u=r,h=n,m=BigInt(Math.round(Math.max(1,u/1e3)*h)),g=await Fe.uint8(_e(32)),A=c,p=await Le.encrypt(A,g),y=Oe(1n,a-1n),k=ae(2n,m,d),N=ae(y,k,a),w=_.encode(g)+N;return Me.archive([a,y,m,w,p])},solve:async e=>{const[t,s,r,n,c]=Me.unarchive(e),o=mn(s,r,t),l=_.decode(n-o),a=await Le.decrypt(c,l);return ee.decode(a)}};function Un(){const e=We.c(91),[t,s]=ie.useState(!1);let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=[],e[0]=r):r=e[0],ie.useEffect(xn,r);const n=Ke(),[c,o]=ie.useState("I'm not a robot"),[l,a]=ie.useState(!1);let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d={login:"",password:"",captchaSolution:""},e[1]=d):d=e[1];const{post:u,data:h,setData:m,processing:g,transform:A,errors:p,clearErrors:y}=qe(d);let k;e[2]!==n.props.captchaTask||e[3]!==n.props.submitLink||e[4]!==u||e[5]!==A?(k=I=>{I.preventDefault(),s(!0),o("Solving CAPTCHA..."),a(!1),(async()=>{try{await function(De){return new Promise(Ge=>setTimeout(Ge,De))}(100);const ke=new Uint8Array(n.props.captchaTask),ze=await yn.solve(ke);o("Verification complete!"),s(!1),a(!0),A(je=>({...je,captchaSolution:ze})),u(n.props.submitLink,{onError:wn})}catch(Se){console.error("Error solving CAPTCHA:",Se),o("Error solving CAPTCHA. Try again.")}})()},e[2]=n.props.captchaTask,e[3]=n.props.submitLink,e[4]=u,e[5]=A,e[6]=k):k=e[6];const N=k;let w;e[7]!==y||e[8]!==m?(w=(I,ve)=>{y(),m(I,ve)},e[7]=y,e[8]=m,e[9]=w):w=e[9];const v=w;let E;e[10]===Symbol.for("react.memo_cache_sentinel")?(E=i.jsx(Xe,{position:"top-center",richColors:!0,closeButton:!0}),e[10]=E):E=e[10];let x;e[11]!==n.props.title?(x=i.jsx("h1",{className:"font-medium mb-6 text-xl",children:n.props.title}),e[11]=n.props.title,e[12]=x):x=e[12];let j;e[13]!==n.props.description?(j=n.props.description&&i.jsx("p",{className:"font-thin mb-6 text-xs pb-10",children:n.props.description}),e[13]=n.props.description,e[14]=j):j=e[14];let B;e[15]!==p.captchaSolution?(B=i.jsx(xe,{message:p.captchaSolution}),e[15]=p.captchaSolution,e[16]=B):B=e[16];let C;e[17]!==n.props.login?(C=i.jsx(Be,{htmlFor:"login",children:n.props.login}),e[17]=n.props.login,e[18]=C):C=e[18];let L;e[19]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx(we,{iconNode:Ne,className:"size-5 absolute inset-2"}),e[19]=L):L=e[19];const fe=`pl-10 ${p.login?"border-red-500":""}`,ue=g||t;let T;e[20]!==v?(T=I=>{v("login",I.target.value)},e[20]=v,e[21]=T):T=e[21];let U;e[22]!==h.login||e[23]!==n.props.login||e[24]!==fe||e[25]!==ue||e[26]!==T?(U=i.jsx(Ce,{id:"login",className:fe,type:"text",required:!0,tabIndex:1,autoComplete:"username",value:h.login,disabled:ue,onChange:T,placeholder:n.props.login}),e[22]=h.login,e[23]=n.props.login,e[24]=fe,e[25]=ue,e[26]=T,e[27]=U):U=e[27];let M;e[28]!==p.login?(M=i.jsx(xe,{message:p.login}),e[28]=p.login,e[29]=M):M=e[29];let P;e[30]!==U||e[31]!==M?(P=i.jsxs("div",{className:"relative",children:[L,U,M]}),e[30]=U,e[31]=M,e[32]=P):P=e[32];let R;e[33]!==P||e[34]!==C?(R=i.jsxs("div",{className:"grid gap-4",children:[C,P]}),e[33]=P,e[34]=C,e[35]=R):R=e[35];let $;e[36]!==n.props.password?($=i.jsx(Be,{htmlFor:"login",children:n.props.password}),e[36]=n.props.password,e[37]=$):$=e[37];let te;e[38]===Symbol.for("react.memo_cache_sentinel")?(te=i.jsx(we,{iconNode:Ne,className:"size-5 absolute inset-2"}),e[38]=te):te=e[38];const pe=`pl-10 ${p.password?"border-red-500":""}`,ge=g||t;let F;e[39]!==v?(F=I=>{v("password",I.target.value)},e[39]=v,e[40]=F):F=e[40];let H;e[41]!==h.password||e[42]!==n.props.password||e[43]!==pe||e[44]!==ge||e[45]!==F?(H=i.jsx(Ce,{id:"password",className:pe,type:"password",required:!0,disabled:ge,tabIndex:1,autoComplete:"current-password",value:h.password,onChange:F,placeholder:n.props.password}),e[41]=h.password,e[42]=n.props.password,e[43]=pe,e[44]=ge,e[45]=F,e[46]=H):H=e[46];let O;e[47]!==p.password?(O=i.jsx(xe,{message:p.password}),e[47]=p.password,e[48]=O):O=e[48];let z;e[49]!==H||e[50]!==O?(z=i.jsxs("div",{className:"relative",children:[te,H,O]}),e[49]=H,e[50]=O,e[51]=z):z=e[51];let D;e[52]!==$||e[53]!==z?(D=i.jsxs("div",{className:"grid gap-4",children:[$,z]}),e[52]=$,e[53]=z,e[54]=D):D=e[54];const he=g||t;let G;e[55]!==n.props.submitButton||e[56]!==he?(G=i.jsx(Ae,{type:"submit",className:"w-fit",disabled:he,children:n.props.submitButton}),e[55]=n.props.submitButton,e[56]=he,e[57]=G):G=e[57];let K;e[58]!==t||e[59]!==n.props.registerLink||e[60]!==g?(K=n.props.registerLink&&i.jsx(Ae,{asChild:!0,variant:"outline",children:i.jsx(Ve,{href:n.props.registerLink.link,className:`${g||t} ? 'pointer-events-none opacity-50' : ''`,children:n.props.registerLink.title})}),e[58]=t,e[59]=n.props.registerLink,e[60]=g,e[61]=K):K=e[61];let q;e[62]!==G||e[63]!==K?(q=i.jsxs("div",{className:"flex gap-4",children:[G,K]}),e[62]=G,e[63]=K,e[64]=q):q=e[64];let V;e[65]!==R||e[66]!==D||e[67]!==q||e[68]!==B?(V=i.jsxs("div",{className:"grid gap-5",children:[B,R,D,q]}),e[65]=R,e[66]=D,e[67]=q,e[68]=B,e[69]=V):V=e[69];let se;e[70]===Symbol.for("react.memo_cache_sentinel")?(se=i.jsx("div",{className:"w-10 h-10 bg-blue-100 rounded-full flex items-center justify-center",children:i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 text-yellow-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 2l3.09 6.26L22 9.27l-5 4.87L18.18 22 12 18.27 5.82 22 7 14.14l-5-4.87 6.91-1.01L12 2z"})})}),e[70]=se):se=e[70];const me=`${t?"":"hidden"}`;let re;e[71]===Symbol.for("react.memo_cache_sentinel")?(re=i.jsx(we,{iconNode:Ze,className:"animate-spin size-6 absolute inset-0 m-auto !text-gray-600"}),e[71]=re):re=e[71];let W;e[72]!==me?(W=i.jsxs("div",{className:"relative",children:[se,i.jsx("div",{className:me,children:re})]}),e[72]=me,e[73]=W):W=e[73];let X;e[74]!==c?(X=i.jsx("div",{className:"text-gray-600 font-semibold",children:c}),e[74]=c,e[75]=X):X=e[75];const ye=`transition-opacity ${l?"opacity-100 visible":"opacity-0 invisible"}`;let oe;e[76]===Symbol.for("react.memo_cache_sentinel")?(oe=i.jsx("svg",{id:"checkmark",xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 text-green-500",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:i.jsx("path",{className:"checkmark",strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),e[76]=oe):oe=e[76];let J;e[77]!==ye?(J=i.jsx("div",{className:ye,children:oe}),e[77]=ye,e[78]=J):J=e[78];let Y;e[79]!==W||e[80]!==X||e[81]!==J?(Y=i.jsxs("div",{className:"bg-white rounded-lg shadow-lg p-4 mt-6 flex items-center space-x-4",children:[W,X,J]}),e[79]=W,e[80]=X,e[81]=J,e[82]=Y):Y=e[82];let Q;e[83]!==N||e[84]!==V||e[85]!==Y?(Q=i.jsxs("form",{onSubmit:N,children:[V,Y]}),e[83]=N,e[84]=V,e[85]=Y,e[86]=Q):Q=e[86];let ce;return e[87]!==Q||e[88]!==x||e[89]!==j?(ce=i.jsxs("div",{className:"bg-sidebar flex min-h-svh w-full justify-center",children:[E,i.jsxs("div",{className:"rounded-xl border bg-card text-card-foreground shadow p-6 max-w-sm w-full h-fit mt-[15%]",children:[x,j,Q]})]}),e[87]=Q,e[88]=x,e[89]=j,e[90]=ce):ce=e[90],ce}function wn(e){for(const t of Object.keys(e))Je.error(e[t])}function xn(){Ye()}export{Un as default};
|