@tachybase/module-auth 1.3.15 → 1.3.17

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.
@@ -1,14 +1,14 @@
1
- (function(u,r){typeof exports=="object"&&typeof module!="undefined"?r(exports,require("@tachybase/client"),require("@tachybase/utils/client"),require("react/jsx-runtime"),require("react"),require("react-router-dom"),require("@tachybase/schema"),require("react-i18next"),require("antd"),require("@ant-design/icons")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tachybase/utils/client","react/jsx-runtime","react","react-router-dom","@tachybase/schema","react-i18next","antd","@ant-design/icons"],r):(u=typeof globalThis!="undefined"?globalThis:u||self,r(u["@tachybase/module-auth"]={},u["@tachybase/client"],u["@tachybase/utils"],u.jsxRuntime,u.react,u["react-router-dom"],u["@tachybase/schema"],u["react-i18next"],u.antd,u["@ant-design/icons"]))})(this,function(u,r,m,c,l,T,f,w,d,k){"use strict";var Tn=Object.defineProperty,vn=Object.defineProperties;var Sn=Object.getOwnPropertyDescriptors;var z=Object.getOwnPropertySymbols;var Se=Object.prototype.hasOwnProperty,Ce=Object.prototype.propertyIsEnumerable;var ve=(u,r,m)=>r in u?Tn(u,r,{enumerable:!0,configurable:!0,writable:!0,value:m}):u[r]=m,C=(u,r)=>{for(var m in r||(r={}))Se.call(r,m)&&ve(u,m,r[m]);if(z)for(var m of z(r))Ce.call(r,m)&&ve(u,m,r[m]);return u},Y=(u,r)=>vn(u,Sn(r));var Ae=(u,r)=>{var m={};for(var c in u)Se.call(u,c)&&r.indexOf(c)<0&&(m[c]=u[c]);if(u!=null&&z)for(var c of z(u))r.indexOf(c)<0&&Ce.call(u,c)&&(m[c]=u[c]);return m};var A=(u,r,m)=>new Promise((c,l)=>{var T=d=>{try{w(m.next(d))}catch(k){l(k)}},f=d=>{try{w(m.throw(d))}catch(k){l(k)}},w=d=>d.done?c(d.value):Promise.resolve(d.value).then(T,f);w((m=m.apply(u,r)).next())});const we="Email/Password",Ee=e=>{const t=T.useLocation(),n=r.useAPIClient();return l.useEffect(()=>{const o=new URLSearchParams(t.search),i=o.get("authenticator"),s=o.get("token");s&&(n.auth.setToken(s),n.auth.setAuthenticator(i))}),c.jsx(c.Fragment,{children:e.children})},E="auth";function v(){return w.useTranslation([E,"core"],{nsMode:"fallback"})}const j=e=>r.tval(e,{ns:E}),B=l.createContext([]);B.displayName="AuthenticatorsContext";const Z=e=>l.useContext(B).find(n=>n.name===e);function Fe(e){var s;const{data:t}=r.useSystemSettings(),n=r.useAPIClient(),{data:o=[],error:i}=r.useRequest(()=>n.resource("authenticators").publicList().then(a=>{var p;return((p=a==null?void 0:a.data)==null?void 0:p.data)||[]}));if(i)throw i;return c.jsxs("div",{style:{maxWidth:320,margin:"0 auto",paddingTop:"20vh"},children:[c.jsx("h1",{children:(s=t==null?void 0:t.data)==null?void 0:s.title}),c.jsx(B.Provider,{value:o,children:c.jsx(T.Outlet,{})}),c.jsx("div",{className:r.css`
1
+ (function(d,i){typeof exports=="object"&&typeof module!="undefined"?i(exports,require("@tachybase/client"),require("@tachybase/utils/client"),require("react/jsx-runtime"),require("react"),require("react-router-dom"),require("@tachybase/schema"),require("react-i18next"),require("antd"),require("@ant-design/icons")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tachybase/utils/client","react/jsx-runtime","react","react-router-dom","@tachybase/schema","react-i18next","antd","@ant-design/icons"],i):(d=typeof globalThis!="undefined"?globalThis:d||self,i(d["@tachybase/module-auth"]={},d["@tachybase/client"],d["@tachybase/utils"],d.jsxRuntime,d.react,d["react-router-dom"],d["@tachybase/schema"],d["react-i18next"],d.antd,d["@ant-design/icons"]))})(this,function(d,i,g,c,f,C,v,F,x,N){"use strict";var Jt=Object.defineProperty,Qt=Object.defineProperties;var Rt=Object.getOwnPropertyDescriptors;var K=Object.getOwnPropertySymbols;var Ke=Object.prototype.hasOwnProperty,We=Object.prototype.propertyIsEnumerable;var $e=(d,i,g)=>i in d?Jt(d,i,{enumerable:!0,configurable:!0,writable:!0,value:g}):d[i]=g,E=(d,i)=>{for(var g in i||(i={}))Ke.call(i,g)&&$e(d,g,i[g]);if(K)for(var g of K(i))We.call(i,g)&&$e(d,g,i[g]);return d},W=(d,i)=>Qt(d,Rt(i));var Ge=(d,i)=>{var g={};for(var c in d)Ke.call(d,c)&&i.indexOf(c)<0&&(g[c]=d[c]);if(d!=null&&K)for(var c of K(d))i.indexOf(c)<0&&We.call(d,c)&&(g[c]=d[c]);return g};var k=(d,i,g)=>new Promise((c,f)=>{var C=x=>{try{F(g.next(x))}catch(N){f(N)}},v=x=>{try{F(g.throw(x))}catch(N){f(N)}},F=x=>x.done?c(x.value):Promise.resolve(x.value).then(C,v);F((g=g.apply(d,i)).next())});const He="Email/Password",Xe=e=>{const o=C.useLocation(),t=i.useAPIClient();return f.useEffect(()=>{const n=new URLSearchParams(o.search),r=n.get("authenticator"),s=n.get("token");s&&(t.auth.setToken(s),t.auth.setAuthenticator(r))}),c.jsx(c.Fragment,{children:e.children})},P="auth";function w(){return F.useTranslation([P,"core"],{nsMode:"fallback"})}const q=e=>i.tval(e,{ns:P}),j=f.createContext([]);j.displayName="AuthenticatorsContext";const G=e=>f.useContext(j).find(t=>t.name===e);function ze(e){var s;const{data:o}=i.useSystemSettings(),t=i.useAPIClient(),{data:n=[],error:r}=i.useRequest(()=>t.resource("authenticators").publicList().then(a=>{var p;return((p=a==null?void 0:a.data)==null?void 0:p.data)||[]}));if(r)throw r;return c.jsxs("div",{style:{maxWidth:320,margin:"0 auto",paddingTop:"20vh"},children:[c.jsx("h1",{children:(s=o==null?void 0:o.data)==null?void 0:s.title}),c.jsx(j.Provider,{value:n,children:c.jsx(C.Outlet,{})}),c.jsx("div",{className:i.css`
2
2
  position: absolute;
3
3
  bottom: 24px;
4
4
  width: 100%;
5
5
  left: 0;
6
6
  text-align: center;
7
- `,children:c.jsx(r.PoweredBy,{})})]})}const Ie=()=>{var o;const t=r.usePlugin(I).authTypes.getEntities(),n={};for(const[i,s]of t)(o=s.components)!=null&&o.SignInForm&&(n[i]=s.components.SignInForm);return n},ke=(e=[])=>{var s;const n=r.usePlugin(I).authTypes.getEntities(),o={};for(const[a,p]of n)(s=p.components)!=null&&s.SignInButton&&(o[a]=p.components.SignInButton);const i=Object.keys(o);return e.filter(a=>i.includes(a.authType)).map((a,p)=>l.createElement(o[a.authType],{key:p,authenticator:a}))},Pe=()=>{const{t:e}=v();r.useCurrentDocumentTitle("Signin"),r.useViewport();const t=Ie(),n=l.useContext(B),o=ke(n);if(!n.length)return c.jsx("div",{style:{color:"#ccc"},children:e("No authentication methods available.")});const i=n.map(s=>{const a=t[s.authType];if(!a)return;const p=`${e("Sign-in")} (${e(s.authTypeTitle||s.authType)})`;return C({component:l.createElement(a,{authenticator:s}),tabTitle:s.title||s.name==="basic"?p:`${e(s.name)}`},s)}).filter(s=>s);return c.jsxs(d.Space,{direction:"vertical",className:r.css`
7
+ `,children:c.jsx(i.PoweredBy,{})})]})}const Ye=()=>{var n;const o=i.usePlugin(_).authTypes.getEntities(),t={};for(const[r,s]of o)(n=s.components)!=null&&n.SignInForm&&(t[r]=s.components.SignInForm);return t},Ze=(e=[])=>{var s;const t=i.usePlugin(_).authTypes.getEntities(),n={};for(const[a,p]of t)(s=p.components)!=null&&s.SignInButton&&(n[a]=p.components.SignInButton);const r=Object.keys(n);return e.filter(a=>r.includes(a.authType)).map((a,p)=>f.createElement(n[a.authType],{key:p,authenticator:a}))},Je=()=>{const{t:e}=w();i.useCurrentDocumentTitle("Signin"),i.useViewport();const o=Ye(),t=f.useContext(j),n=Ze(t);if(!t.length)return c.jsx("div",{style:{color:"#ccc"},children:e("No authentication methods available.")});const r=t.map(s=>{const a=o[s.authType];if(!a)return;const p=`${e("Sign-in")} (${e(s.authTypeTitle||s.authType)})`;return E({component:f.createElement(a,{authenticator:s}),tabTitle:s.title||s.name==="basic"?p:`${e(s.name)}`},s)}).filter(s=>s);return c.jsxs(x.Space,{direction:"vertical",className:i.css`
8
8
  display: flex;
9
- `,children:[i.length>1?c.jsx(d.Tabs,{items:i.map(s=>({label:s.tabTitle,key:s.name,children:s.component}))}):i.length?c.jsx("div",{children:i[0].component}):c.jsx(c.Fragment,{}),c.jsx(d.Space,{direction:"vertical",className:r.css`
9
+ `,children:[r.length>1?c.jsx(x.Tabs,{items:r.map(s=>({label:s.tabTitle,key:s.name,children:s.component}))}):r.length?c.jsx("div",{children:r[0].component}):c.jsx(c.Fragment,{}),c.jsx(x.Space,{direction:"vertical",className:i.css`
10
10
  display: flex;
11
- `,children:o})]})},Oe=l.createContext({});Oe.displayName="SignupPageContext";const ne=()=>{var o;const t=r.usePlugin(I).authTypes.getEntities(),n={};for(const[i,s]of t)(o=s.components)!=null&&o.SignUpForm&&(n[i]=s.components.SignUpForm);return n},Ne=()=>{r.useViewport(),r.useCurrentDocumentTitle("Signup");const e=ne(),[t]=T.useSearchParams(),n=t.get("name"),o=Z(n),{authType:i}=o||{};return e[i]?l.createElement(e[i],{authenticatorName:n}):c.jsx(T.Navigate,{to:"/not-found",replace:!0})};function _e(e="/admin"){const t=T.useNavigate(),[n]=T.useSearchParams();return l.useCallback(()=>{t(n.get("redirect")||"/admin",{replace:!0})},[t,n])}const oe=e=>{const t=f.useForm(),n=r.useAPIClient(),o=_e(),{refreshAsync:i}=r.useCurrentUserContext();return{run(){return A(this,null,function*(){yield t.submit(),yield n.auth.signIn(t.values,e),yield i(),o()})}}},$e={type:"object",name:"passwordForm","x-component":"FormV2",properties:{account:{type:"string","x-component":"Input","x-validator":`{{(value) => {
11
+ `,children:n})]})},Qe=f.createContext({});Qe.displayName="SignupPageContext";const me=()=>{var n;const o=i.usePlugin(_).authTypes.getEntities(),t={};for(const[r,s]of o)(n=s.components)!=null&&n.SignUpForm&&(t[r]=s.components.SignUpForm);return t},Re=()=>{i.useViewport(),i.useCurrentDocumentTitle("Signup");const e=me(),[o]=C.useSearchParams(),t=o.get("name"),n=G(t),{authType:r}=n||{};return e[r]?f.createElement(e[r],{authenticatorName:t}):c.jsx(C.Navigate,{to:"/not-found",replace:!0})};function et(e="/admin"){const o=C.useNavigate(),[t]=C.useSearchParams();return f.useCallback(()=>{o(t.get("redirect")||"/admin",{replace:!0})},[o,t])}const ye=e=>{const o=v.useForm(),t=i.useAPIClient(),n=et(),{refreshAsync:r}=i.useCurrentUserContext();return{run(){return k(this,null,function*(){yield o.submit(),yield t.auth.signIn(o.values,e),yield r(),n()})}}},tt={type:"object",name:"passwordForm","x-component":"FormV2",properties:{account:{type:"string","x-component":"Input","x-validator":`{{(value) => {
12
12
  if (!value) {
13
13
  return t("Please enter your username or email");
14
14
  }
@@ -19,4 +19,4 @@
19
19
  } else {
20
20
  return /^[^@.<>"'/]{2,16}$/.test(value) || t("Please enter a valid username");
21
21
  }
22
- }}}`,"x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Username/Email")}}',style:{}}},password:{type:"string","x-component":"Password",required:!0,"x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Password")}}',style:{}}},actions:{type:"void","x-component":"div",properties:{submit:{title:'{{t("Sign in")}}',type:"void","x-component":"Action","x-component-props":{htmlType:"submit",block:!0,type:"primary",useAction:"{{ useBasicSignIn }}",style:{width:"100%"}}}}},signUp:{type:"void","x-component":"Link","x-component-props":{to:"{{ signUpLink }}"},"x-content":'{{t("Create an account")}}',"x-visible":"{{ allowSignUp }}"}}},je=e=>{const{t}=v(),n=e.authenticator,{authType:o,name:i,options:s}=n,p=!!ne()[o]&&(s==null?void 0:s.allowSignUp),y=`/signup?name=${i}`,x=()=>oe(i);return c.jsx(r.SchemaComponent,{schema:$e,scope:{useBasicSignIn:x,allowSignUp:p,signUpLink:y,t}})},Be=e=>{const t=T.useNavigate(),n=f.useForm(),o=r.useAPIClient(),{t:i}=w.useTranslation();return{run(){return A(this,null,function*(){var a;yield n.submit(),yield o.auth.signUp(n.values,e==null?void 0:e.authenticator),d.message.success(((a=e==null?void 0:e.message)==null?void 0:a.success)||i("Sign up successfully, and automatically jump to the sign in page")),setTimeout(()=>{t("/signin")},2e3)})}}},De={type:"object",name:f.uid(),"x-component":"FormV2",properties:{username:{type:"string",required:!0,"x-component":"Input","x-validator":{username:!0},"x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Username")}}',style:{}}},password:{type:"string",required:!0,"x-component":"Password","x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Password")}}',checkStrength:!0,style:{}},"x-reactions":[{dependencies:[".confirm_password"],fulfill:{state:{selfErrors:'{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'}}}]},confirm_password:{type:"string",required:!0,"x-component":"Password","x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Confirm password")}}',style:{}},"x-reactions":[{dependencies:[".password"],fulfill:{state:{selfErrors:'{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'}}}]},actions:{type:"void","x-component":"div",properties:{submit:{title:'{{t("Sign up")}}',type:"void","x-component":"Action","x-component-props":{block:!0,type:"primary",htmlType:"submit",useAction:"{{ useBasicSignUp }}",style:{width:"100%"}}}}},link:{type:"void","x-component":"div",properties:{link:{type:"void","x-component":"Link","x-component-props":{to:"/signin"},"x-content":'{{t("Log in with an existing account")}}'}}}}},Ue=({authenticatorName:e})=>{const{t}=v(),n=()=>Be({authenticator:e}),o=Z(e),{options:i}=o;return i!=null&&i.allowSignUp?c.jsx(r.SchemaComponent,{schema:De,scope:{useBasicSignUp:n,t}}):c.jsx(T.Navigate,{to:"/not-found",replace:!0})},Ve=()=>{const{t:e}=v();return c.jsx(r.SchemaComponent,{scope:{t:e},components:{Alert:d.Alert},schema:{type:"object",properties:{public:{type:"object",properties:{allowSignUp:{"x-decorator":"FormItem",type:"boolean",title:'{{t("Allow to sign up")}}',"x-component":"Checkbox","x-component-props":{defaultChecked:!0}}}},notice:{type:"void","x-component":"Alert","x-component-props":{showIcon:!0,message:'{{t("The authentication allows users to sign in via username or email.")}}'}}}}})},Le=()=>{var o;const t=r.usePlugin(I).authTypes.getEntities(),n={};for(const[i,s]of t)(o=s.components)!=null&&o.BindForm&&(n[i]=s.components.BindForm);return n},Me=()=>{const e=r.useRecord(),n=Le()[e.authType];return l.createElement(n,{authenticator:e})},qe={type:"void",name:"authenticatorBind","x-decorator":"TableBlockProvider","x-decorator-props":{collection:{name:"authenticators",sortable:!1,fields:[{interface:"input",type:"string",name:"authType"},{interface:"input",type:"string",name:"title",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}},{interface:"textarea",type:"string",name:"description",uiSchema:{type:"string",title:'{{t("Description")}}',"x-component":"Input"}},{type:"boolean",name:"bind",uiSchema:{type:"boolean",title:'{{t("Bind")}}',"x-component":"Checkbox"}},{type:"string",name:"nickname",uiSchema:{type:"string",title:'{{t("Nickname")}}',"x-component":"Input"}}]},resource:"authenticators",action:"bindTypes",params:{sort:["sort"]},rowKey:"name",showIndex:!0},"x-component":"div",properties:{table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"name"},properties:{authType:{title:'{{t("Auth Type")}}',type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{authType:{type:"string","x-component":"Select","x-read-pretty":!0}}},title:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},description:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{description:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},bind:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{bind:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},nickname:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{nickname:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"TableV2.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{unbind:{"x-visible":'{{ $self.query(".bind").value() }}',type:"void",title:'{{ t("Unbind") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Unbind')}}",content:"{{t('Are you sure to unbind this authenticator?')}}"},useAction:"{{ useUnbindAction }}"}},bind:{"x-visible":'{{ !$self.query(".bind").value() }}',type:"void",title:"{{ t('Bind') }}","x-component":"Action.Link",properties:{modal:{type:"void","x-decorator":"Form",title:"{{ t('Bind') }}","x-component":"Action.Modal","x-component-props":{width:800},properties:{form:{type:"void","x-component":"BindForm"}}}}}}}}}}}}},Ke=()=>{const{refreshCM:e}=r.useCollectionManager_deprecated(),t=r.useAPIClient(),n=r.useRecord();return{run(){return A(this,null,function*(){yield t.resource("authenticators").unbind({authenticator:n.name}),e()})}}},We=()=>{const{t:e}=v();return c.jsx(d.Card,{bordered:!1,children:c.jsx(r.SchemaComponent,{schema:qe,components:{BindForm:Me},scope:{t:e,useUnbindAction:Ke}})})};var V=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function re(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function He(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var ie=He,Ge=typeof V=="object"&&V&&V.Object===Object&&V,Xe=Ge,ze=Xe,Ye=typeof self=="object"&&self&&self.Object===Object&&self,Ze=ze||Ye||Function("return this")(),se=Ze,Je=se,Qe=function(){return Je.Date.now()},Re=Qe,et=/\s/;function tt(e){for(var t=e.length;t--&&et.test(e.charAt(t)););return t}var nt=tt,ot=nt,rt=/^\s+/;function it(e){return e&&e.slice(0,ot(e)+1).replace(rt,"")}var st=it,at=se,ct=at.Symbol,ae=ct,ce=ae,pe=Object.prototype,pt=pe.hasOwnProperty,ut=pe.toString,D=ce?ce.toStringTag:void 0;function lt(e){var t=pt.call(e,D),n=e[D];try{e[D]=void 0;var o=!0}catch(s){}var i=ut.call(e);return o&&(t?e[D]=n:delete e[D]),i}var dt=lt,mt=Object.prototype,yt=mt.toString;function ht(e){return yt.call(e)}var xt=ht,ue=ae,ft=dt,gt=xt,bt="[object Null]",Tt="[object Undefined]",le=ue?ue.toStringTag:void 0;function vt(e){return e==null?e===void 0?Tt:bt:le&&le in Object(e)?ft(e):gt(e)}var St=vt;function Ct(e){return e!=null&&typeof e=="object"}var At=Ct,wt=St,Et=At,Ft="[object Symbol]";function It(e){return typeof e=="symbol"||Et(e)&&wt(e)==Ft}var kt=It,Pt=st,de=ie,Ot=kt,me=NaN,Nt=/^[-+]0x[0-9a-f]+$/i,_t=/^0b[01]+$/i,$t=/^0o[0-7]+$/i,jt=parseInt;function Bt(e){if(typeof e=="number")return e;if(Ot(e))return me;if(de(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=de(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=Pt(e);var n=_t.test(e);return n||$t.test(e)?jt(e.slice(2),n?2:8):Nt.test(e)?me:+e}var Dt=Bt,Ut=ie,J=Re,ye=Dt,Vt="Expected a function",Lt=Math.max,Mt=Math.min;function qt(e,t,n){var o,i,s,a,p,y,x=0,_=!1,b=!1,g=!0;if(typeof e!="function")throw new TypeError(Vt);t=ye(t)||0,Ut(n)&&(_=!!n.leading,b="maxWait"in n,s=b?Lt(ye(n.maxWait)||0,t):s,g="trailing"in n?!!n.trailing:g);function $(h){var S=o,U=i;return o=i=void 0,x=h,a=e.apply(U,S),a}function W(h){return x=h,p=setTimeout(X,t),_?$(h):a}function H(h){var S=h-y,U=h-x,Te=t-S;return b?Mt(Te,s-U):Te}function G(h){var S=h-y,U=h-x;return y===void 0||S>=t||S<0||b&&U>=s}function X(){var h=J();if(G(h))return be(h);p=setTimeout(X,H(h))}function be(h){return p=void 0,g&&o?$(h):(o=i=void 0,a)}function gn(){p!==void 0&&clearTimeout(p),x=0,o=y=i=p=void 0}function bn(){return p===void 0?a:be(J())}function te(){var h=J(),S=G(h);if(o=arguments,i=this,y=h,S){if(p===void 0)return W(y);if(b)return clearTimeout(p),p=setTimeout(X,t),$(y)}return p===void 0&&(p=setTimeout(X,t)),a}return te.cancel=gn,te.flush=bn,te}var Kt=qt;const Wt=re(Kt),L={EMPTY_TOKEN:"EMPTY_TOKEN",EXPIRED_TOKEN:"EXPIRED_TOKEN",INVALID_TOKEN:"INVALID_TOKEN",TOKEN_RENEW_FAILED:"TOKEN_RENEW_FAILED",BLOCKED_TOKEN:"BLOCKED_TOKEN",EXPIRED_SESSION:"EXPIRED_SESSION",NOT_EXIST_USER:"NOT_EXIST_USER",SKIP_TOKEN_RENEW:"SKIP_TOKEN_RENEW",USER_HAS_NO_ROLES_ERR:"USER_HAS_NO_ROLES_ERR"};function Ht(e,t){const n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=new RegExp(`^${n.replace(/\/?$/,"")}(\\/|$)`);return e.replace(o,"/")||e}const Gt=Wt(e=>{e()},3e3,{leading:!0,trailing:!1});function Xt({app:e}){return e.apiClient.axios,[o=>{var s;const i=(s=o==null?void 0:o.headers)==null?void 0:s["x-new-token"];return i&&e.apiClient.auth.setToken(i),o},o=>{var b,g,$,W,H;const i=(g=(b=o==null?void 0:o.response)==null?void 0:b.headers)==null?void 0:g["x-new-token"],s=(W=($=o==null?void 0:o.response)==null?void 0:$.data)==null?void 0:W.errors,a=Array.isArray(s)?s[0]:null,p=e.router.state,{pathname:y,search:x}=p.location,_=e.router.basename;if(i&&e.apiClient.auth.setToken(i),o.status===401&&(a!=null&&a.code)&&L[a.code]&&(e.apiClient.auth.setToken(""),y===e.getHref("signin")&&(a==null?void 0:a.code)!==L.EMPTY_TOKEN&&o.config&&(o.config.skipNotify=!1),(a==null?void 0:a.code)==="USER_HAS_NO_ROLES_ERR"&&(o.config.skipNotify=!0,e.error=a)),o.status===401&&!((H=o.config)!=null&&H.skipAuth)&&(a!=null&&a.code)&&L[a.code]){if(!a||(a==null?void 0:a.code)===L.SKIP_TOKEN_RENEW)throw o;if(y!==e.getHref("signin")){const G=Ht(y,_);Gt(()=>{e.apiClient.auth.setToken(null),e.router.navigate(`/signin?redirect=${G}${x}`,{replace:!0})})}}throw o}]}const Q=l.createContext({type:""});Q.displayName="AuthTypeContext";const R=l.createContext({types:[]});R.displayName="AuthTypesContext";const zt=()=>{const{types:e}=l.useContext(R);return e},Yt=e=>{const t=r.useRecord(),n=r.useRequest(()=>Promise.resolve({data:C({},t.options)}),Y(C({},e),{manual:!0})),{run:o}=n,i=r.useActionContext();return l.useEffect(()=>{i.visible&&o()},[i.visible,o]),n},Zt=e=>{var o;const n=r.usePlugin(I).authTypes.get(e);return(o=n==null?void 0:n.components)==null?void 0:o.AdminSettingsForm},Jt=f.observer(()=>{const e=f.useForm(),t=r.useRecord(),n=Zt(e.values.authType||t.authType);return n?c.jsx(n,{}):null},{displayName:"Options"}),he={name:"authenticators",sortable:!0,fields:[{name:"id",type:"string",interface:"id"},{interface:"input",type:"string",name:"name",uiSchema:{type:"string",title:'{{t("Auth UID")}}',"x-component":"Input","x-validator":e=>/^[a-zA-Z0-9_-]+$/.test(e)?"":r.i18n.t("a-z, A-Z, 0-9, _, -"),required:!0}},{interface:"input",type:"string",name:"authType",uiSchema:{type:"string",title:'{{t("Auth Type")}}',"x-component":"Select",dataSource:"{{ types }}",required:!0}},{interface:"input",type:"string",name:"title",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}},{interface:"textarea",type:"string",name:"description",uiSchema:{type:"string",title:'{{t("Description")}}',"x-component":"Input"}},{type:"boolean",name:"enabled",uiSchema:{type:"boolean",title:'{{t("Enabled")}}',"x-component":"Checkbox"}}]},Qt={type:"object",properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues(e){const t=r.useActionContext(),{type:n}=l.useContext(Q);return r.useRequest(()=>Promise.resolve({data:{name:`s_${f.uid()}`,authType:n}}),Y(C({},e),{refreshDeps:[t.visible]}))}},title:'{{t("Add new")}}',properties:{name:{"x-component":"CollectionField","x-decorator":"FormItem"},authType:{"x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{options:"{{ types }}"}},title:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"Options"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},create:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useCreateDatabaseConnectionAction","x-component-props":{type:"primary"}}}}}}}},Rt={type:"void",name:"authenticators","x-decorator":"TableBlockProvider","x-decorator-props":{collection:he,dragSort:!0,action:"list",params:{pageSize:50,sort:"sort",appends:[]}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{delete:{type:"void",title:'{{t("Delete")}}',"x-action":"destroy","x-decorator":"ACLActionProvider","x-component":"Action","x-use-component-props":"useBulkDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"AddNew","x-component-props":{type:"primary"}}}},table:{type:"array","x-uid":"input","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{id:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},name:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},authType:{title:'{{t("Auth Type")}}',type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{authType:{type:"string","x-component":"Select","x-read-pretty":!0,enum:"{{ types }}"}}},title:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},description:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{description:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"TableV2.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{updateAuthenticator:{type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},"x-decorator":"ACLActionProvider",properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{card:{type:"void","x-acl-action-props":{skipScopeCheck:!1},"x-acl-action":"authenticators:update","x-decorator":"FormBlockProvider","x-use-decorator-props":"useEditFormBlockDecoratorProps","x-decorator-props":{action:"get",dataSource:"main",collection:he},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary"}}}},name:{"x-component":"CollectionField","x-decorator":"FormItem"},authType:{"x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{options:"{{ types }}"}},title:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"Options"}}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-action":"destroy","x-component":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}},"x-disabled":"{{ useCanNotDelete() }}"}}}}}}}}},en=()=>{const{setVisible:e}=r.useActionContext();return{run(){return A(this,null,function*(){e(!1)})}}},tn=()=>{const{t:e}=w.useTranslation(),[t,n]=l.useState(!1),[o,i]=l.useState(""),s=zt(),a=s.map(p=>Y(C({},p),{onClick:()=>{n(!0),i(p.value)}}));return c.jsx(r.ActionContextProvider,{value:{visible:t,setVisible:n},children:c.jsxs(Q.Provider,{value:{type:o},children:[c.jsx(d.Dropdown,{menu:{items:a},children:c.jsxs(d.Button,{icon:c.jsx(k.PlusOutlined,{}),type:"primary",children:[e("Add new")," ",c.jsx(k.DownOutlined,{})]})}),c.jsx(r.SchemaComponent,{scope:{useCloseAction:en,types:s,setType:i},schema:Qt})]})})},nn=()=>{const{data:e}=r.useAsyncData();return!1},on=()=>{const{t:e}=v(),[t,n]=l.useState([]),o=r.useAPIClient();return r.useRequest(()=>o.resource("authenticators").listTypes().then(i=>{var a;return(((a=i==null?void 0:i.data)==null?void 0:a.data)||[]).map(p=>({key:p.name,label:e(p.title||p.name),value:p.name}))}),{onSuccess:i=>{n(i)}}),c.jsx(d.Card,{bordered:!1,children:c.jsx(R.Provider,{value:{types:t},children:c.jsx(r.SchemaComponent,{schema:Rt,components:{AddNew:tn,Options:Jt},scope:{types:t,useValuesFromOptions:Yt,useCanNotDelete:nn,t:e}})})})},{Option:ee}=d.Select,rn=f.connect(e=>{const{t}=v(),b=e,{value:n,onChange:o,minNum:i=1}=b,s=Ae(b,["value","onChange","minNum"]),a=/^(\d*)([a-zA-Z]*)$/,p=n?n.match(a):null;l.useEffect(()=>{p||o("10m")},[p,o]);const[y,x]=p?[parseInt(p[1]),p[2]]:[10,"m"],_=c.jsxs(d.Select,{value:x,onChange:g=>o(`${y}${g}`),style:{width:120},children:[c.jsx(ee,{value:"m",children:t("Minutes")}),c.jsx(ee,{value:"h",children:t("Hours")}),c.jsx(ee,{value:"d",children:t("Days")})]});return c.jsx(d.InputNumber,C({value:y,addonAfter:_,min:i,onChange:g=>o(`${g!=null?g:1}${x}`)},s))},f.mapProps({onInput:"onChange"})),M={InputTime:"InputTime"},sn={[M.InputTime]:rn};var P=1e3,O=P*60,N=O*60,F=N*24,an=F*7,cn=F*365.25,pn=function(e,t){t=t||{};var n=typeof e;if(n==="string"&&e.length>0)return un(e);if(n==="number"&&isFinite(e))return t.long?dn(e):ln(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function un(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]),o=(t[2]||"ms").toLowerCase();switch(o){case"years":case"year":case"yrs":case"yr":case"y":return n*cn;case"weeks":case"week":case"w":return n*an;case"days":case"day":case"d":return n*F;case"hours":case"hour":case"hrs":case"hr":case"h":return n*N;case"minutes":case"minute":case"mins":case"min":case"m":return n*O;case"seconds":case"second":case"secs":case"sec":case"s":return n*P;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function ln(e){var t=Math.abs(e);return t>=F?Math.round(e/F)+"d":t>=N?Math.round(e/N)+"h":t>=O?Math.round(e/O)+"m":t>=P?Math.round(e/P)+"s":e+"ms"}function dn(e){var t=Math.abs(e);return t>=F?q(e,t,F,"day"):t>=N?q(e,t,N,"hour"):t>=O?q(e,t,O,"minute"):t>=P?q(e,t,P,"second"):e+" ms"}function q(e,t,n,o){var i=t>=n*1.5;return Math.round(e/n)+" "+o+(i?"s":"")}const xe=re(pn),fe="token-policy-config",ge="tokenControlConfig",mn=()=>{const e=r.useAPIClient(),t=l.useMemo(()=>f.createForm(),[]);return l.useEffect(()=>{A(this,null,function*(){var o;try{const{data:i}=yield e.resource(ge).get({filterByTk:fe});(o=i==null?void 0:i.data)!=null&&o.config&&t.setValues(i.data.config)}catch(i){console.error(i)}})},[t,e]),{form:t}},yn=()=>{const{message:e}=d.App.useApp(),t=r.useAPIClient(),n=f.useForm(),{t:o}=v();return{type:"primary",onClick(){return A(this,null,function*(){n.clearErrors("*");const{tokenExpirationTime:s,sessionExpirationTime:a,expiredTokenRenewLimit:p}=n.values;if(xe(s)>=xe(a)){n.setFieldState("tokenExpirationTime",x=>{x.feedbacks=[{type:"error",code:"ValidateError",messages:[o("Token validity period must be less than session validity period!")]}]});return}yield n.submit();const y=yield t.resource(ge).update({values:{config:n.values},filterByTk:fe});y&&y.status===200&&e.success(o("Saved successfully!"))})}}},K={useSubmitActionProps:"useSubmitActionProps",useEditForm:"useEditForm"},hn={[K.useEditForm]:mn,[K.useSubmitActionProps]:yn},xn={name:f.uid(),"x-component":"FormV2","x-use-component-props":K.useEditForm,type:"object",properties:{sessionExpirationTime:{type:"string",title:j("Session validity period"),"x-decorator":"FormItem","x-component":M.InputTime,required:!0,description:j("The maximum valid time for each user login. During the session validity, the Token will be automatically updated. After the timeout, the user is required to log in again.")},tokenExpirationTime:{type:"string",title:j("Token validity period"),"x-decorator":"FormItem","x-component":M.InputTime,required:!0,description:j("The validity period of each issued API Token. After the Token expires, if it is within the session validity period and has not exceeded the refresh limit, the server will automatically issue a new Token to maintain the user session, otherwise the user is required to log in again. (Each Token can only be refreshed once)")},expiredTokenRenewLimit:{type:"string",title:"{{t('Expired token refresh limit')}}","x-decorator":"FormItem","x-component":M.InputTime,"x-component-props":{minNum:0},required:!0,description:j("The maximum time limit allowed for refreshing a Token after it expires. After this time limit, the token cannot be automatically renewed, and the user needs to log in again.")},footer:{type:"void","x-component":"ActionBar","x-component-props":{layout:"one-column"},properties:{submit:{title:'{{t("Submit")}}',"x-component":"Action","x-use-component-props":K.useSubmitActionProps}}}}},fn=()=>{const{t:e}=v();return c.jsx(d.Card,{bordered:!1,children:c.jsx(r.SchemaComponent,{schema:xn,scope:C({t:e},hn),components:sn})})};class I extends r.Plugin{constructor(){super(...arguments),this.authTypes=new m.Registry}registerType(t,n){this.authTypes.register(t,n)}load(){return A(this,null,function*(){this.app.systemSettingsManager.add("system-services."+E,{icon:"LoginOutlined",title:`{{t("Authentication", { ns: "${E}" })}}`,Component:on,aclSnippet:"pm.auth.authenticators"}),this.app.userSettingsManager.add(E,{icon:"LoginOutlined",title:`{{t("Authentication login bind", { ns: "${E}" })}}`,Component:We,aclSnippet:"pm.auth.authenticators"}),this.router.add("auth",{Component:"AuthLayout"}),this.router.add("auth.signin",{path:"/signin",Component:"SignInPage"}),this.router.add("auth.signup",{path:"/signup",Component:"SignUpPage"}),this.app.addComponents({AuthLayout:Fe,SignInPage:Pe,SignUpPage:Ne}),this.app.providers.unshift([Ee,{}]),this.registerType(we,{components:{SignInForm:je,SignUpForm:Ue,AdminSettingsForm:Ve}}),this.app.systemSettingsManager.add("security.token-policy",{title:`{{t("Token policy", { ns: "${E}" })}}`,Component:fn,aclSnippet:"pm.security.token-policy",icon:"ApiOutlined",sort:0});const[t,n]=Xt({app:this.app});this.app.apiClient.axios.interceptors.response.handlers.unshift({fulfilled:t,rejected:n,synchronous:!1,runWhen:null})})}}u.AuthenticatorsContext=B,u.PluginAuthClient=I,u.default=I,u.useAuthenticator=Z,u.useSignIn=oe,Object.defineProperties(u,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
22
+ }}}`,"x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Username/Email")}}',style:{}}},password:{type:"string","x-component":"Password",required:!0,"x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Password")}}',style:{}}},actions:{type:"void","x-component":"div",properties:{submit:{title:'{{t("Sign in")}}',type:"void","x-component":"Action","x-component-props":{htmlType:"submit",block:!0,type:"primary",useAction:"{{ useBasicSignIn }}",style:{width:"100%"}}}}},signUp:{type:"void","x-component":"Link","x-component-props":{to:"{{ signUpLink }}"},"x-content":'{{t("Create an account")}}',"x-visible":"{{ allowSignUp }}"}}},nt=e=>{const{t:o}=w(),t=e.authenticator,{authType:n,name:r,options:s}=t,p=!!me()[n]&&(s==null?void 0:s.allowSignUp),h=`/signup?name=${r}`,l=()=>ye(r);return c.jsx(i.SchemaComponent,{schema:tt,scope:{useBasicSignIn:l,allowSignUp:p,signUpLink:h,t:o}})},ot=e=>{const o=C.useNavigate(),t=v.useForm(),n=i.useAPIClient(),{t:r}=F.useTranslation();return{run(){return k(this,null,function*(){var a;yield t.submit(),yield n.auth.signUp(t.values,e==null?void 0:e.authenticator),x.message.success(((a=e==null?void 0:e.message)==null?void 0:a.success)||r("Sign up successfully, and automatically jump to the sign in page")),setTimeout(()=>{o("/signin")},2e3)})}}},rt={type:"object",name:v.uid(),"x-component":"FormV2",properties:{username:{type:"string",required:!0,"x-component":"Input","x-validator":{username:!0},"x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Username")}}',style:{}}},password:{type:"string",required:!0,"x-component":"Password","x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Password")}}',checkStrength:!0,style:{}},"x-reactions":[{dependencies:[".confirm_password"],fulfill:{state:{selfErrors:'{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'}}}]},confirm_password:{type:"string",required:!0,"x-component":"Password","x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Confirm password")}}',style:{}},"x-reactions":[{dependencies:[".password"],fulfill:{state:{selfErrors:'{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'}}}]},actions:{type:"void","x-component":"div",properties:{submit:{title:'{{t("Sign up")}}',type:"void","x-component":"Action","x-component-props":{block:!0,type:"primary",htmlType:"submit",useAction:"{{ useBasicSignUp }}",style:{width:"100%"}}}}},link:{type:"void","x-component":"div",properties:{link:{type:"void","x-component":"Link","x-component-props":{to:"/signin"},"x-content":'{{t("Log in with an existing account")}}'}}}}},it=({authenticatorName:e})=>{const{t:o}=w(),t=()=>ot({authenticator:e}),n=G(e),{options:r}=n;return r!=null&&r.allowSignUp?c.jsx(i.SchemaComponent,{schema:rt,scope:{useBasicSignUp:t,t:o}}):c.jsx(C.Navigate,{to:"/not-found",replace:!0})},st=()=>{const{t:e}=w();return c.jsx(i.SchemaComponent,{scope:{t:e},components:{Alert:x.Alert},schema:{type:"object",properties:{public:{type:"object",properties:{allowSignUp:{"x-decorator":"FormItem",type:"boolean",title:'{{t("Allow to sign up")}}',"x-component":"Checkbox","x-component-props":{defaultChecked:!0}}}},notice:{type:"void","x-component":"Alert","x-component-props":{showIcon:!0,message:'{{t("The authentication allows users to sign in via username or email.")}}'}}}}})},at=()=>{var n;const o=i.usePlugin(_).authTypes.getEntities(),t={};for(const[r,s]of o)(n=s.components)!=null&&n.BindForm&&(t[r]=s.components.BindForm);return t},ct=()=>{const e=i.useRecord(),t=at()[e.authType];return f.createElement(t,{authenticator:e})},ut={type:"void",name:"authenticatorBind","x-decorator":"TableBlockProvider","x-decorator-props":{collection:{name:"authenticators",sortable:!1,fields:[{interface:"input",type:"string",name:"authType"},{interface:"input",type:"string",name:"title",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}},{interface:"textarea",type:"string",name:"description",uiSchema:{type:"string",title:'{{t("Description")}}',"x-component":"Input"}},{type:"boolean",name:"bind",uiSchema:{type:"boolean",title:'{{t("Bind")}}',"x-component":"Checkbox"}},{type:"string",name:"nickname",uiSchema:{type:"string",title:'{{t("Nickname")}}',"x-component":"Input"}}]},resource:"authenticators",action:"bindTypes",params:{sort:["sort"]},rowKey:"name",showIndex:!0},"x-component":"div",properties:{table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"name"},properties:{authType:{title:'{{t("Auth Type")}}',type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{authType:{type:"string","x-component":"Select","x-read-pretty":!0}}},title:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},description:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{description:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},bind:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{bind:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},nickname:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{nickname:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"TableV2.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{unbind:{"x-visible":'{{ $self.query(".bind").value() }}',type:"void",title:'{{ t("Unbind") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Unbind')}}",content:"{{t('Are you sure to unbind this authenticator?')}}"},useAction:"{{ useUnbindAction }}"}},bind:{"x-visible":'{{ !$self.query(".bind").value() }}',type:"void",title:"{{ t('Bind') }}","x-component":"Action.Link",properties:{modal:{type:"void","x-decorator":"Form",title:"{{ t('Bind') }}","x-component":"Action.Modal","x-component-props":{width:800},properties:{form:{type:"void","x-component":"BindForm"}}}}}}}}}}}}},pt=()=>{const{refreshCM:e}=i.useCollectionManager_deprecated(),o=i.useAPIClient(),t=i.useRecord();return{run(){return k(this,null,function*(){yield o.resource("authenticators").unbind({authenticator:t.name}),e()})}}},lt=()=>{const{t:e}=w();return c.jsx(x.Card,{bordered:!1,children:c.jsx(i.SchemaComponent,{schema:ut,components:{BindForm:ct},scope:{t:e,useUnbindAction:pt}})})};var L=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function he(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var H,fe;function xe(){if(fe)return H;fe=1;function e(o){var t=typeof o;return o!=null&&(t=="object"||t=="function")}return H=e,H}var X,ge;function dt(){if(ge)return X;ge=1;var e=typeof L=="object"&&L&&L.Object===Object&&L;return X=e,X}var z,be;function Te(){if(be)return z;be=1;var e=dt(),o=typeof self=="object"&&self&&self.Object===Object&&self,t=e||o||Function("return this")();return z=t,z}var Y,ve;function mt(){if(ve)return Y;ve=1;var e=Te(),o=function(){return e.Date.now()};return Y=o,Y}var Z,Se;function yt(){if(Se)return Z;Se=1;var e=/\s/;function o(t){for(var n=t.length;n--&&e.test(t.charAt(n)););return n}return Z=o,Z}var J,Ce;function ht(){if(Ce)return J;Ce=1;var e=yt(),o=/^\s+/;function t(n){return n&&n.slice(0,e(n)+1).replace(o,"")}return J=t,J}var Q,Ae;function we(){if(Ae)return Q;Ae=1;var e=Te(),o=e.Symbol;return Q=o,Q}var R,Ie;function ft(){if(Ie)return R;Ie=1;var e=we(),o=Object.prototype,t=o.hasOwnProperty,n=o.toString,r=e?e.toStringTag:void 0;function s(a){var p=t.call(a,r),h=a[r];try{a[r]=void 0;var l=!0}catch(m){}var u=n.call(a);return l&&(p?a[r]=h:delete a[r]),u}return R=s,R}var ee,Ee;function xt(){if(Ee)return ee;Ee=1;var e=Object.prototype,o=e.toString;function t(n){return o.call(n)}return ee=t,ee}var te,ke;function gt(){if(ke)return te;ke=1;var e=we(),o=ft(),t=xt(),n="[object Null]",r="[object Undefined]",s=e?e.toStringTag:void 0;function a(p){return p==null?p===void 0?r:n:s&&s in Object(p)?o(p):t(p)}return te=a,te}var ne,Fe;function bt(){if(Fe)return ne;Fe=1;function e(o){return o!=null&&typeof o=="object"}return ne=e,ne}var oe,Pe;function Tt(){if(Pe)return oe;Pe=1;var e=gt(),o=bt(),t="[object Symbol]";function n(r){return typeof r=="symbol"||o(r)&&e(r)==t}return oe=n,oe}var re,_e;function vt(){if(_e)return re;_e=1;var e=ht(),o=xe(),t=Tt(),n=NaN,r=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,a=/^0o[0-7]+$/i,p=parseInt;function h(l){if(typeof l=="number")return l;if(t(l))return n;if(o(l)){var u=typeof l.valueOf=="function"?l.valueOf():l;l=o(u)?u+"":u}if(typeof l!="string")return l===0?l:+l;l=e(l);var m=s.test(l);return m||a.test(l)?p(l.slice(2),m?2:8):r.test(l)?n:+l}return re=h,re}var ie,Oe;function St(){if(Oe)return ie;Oe=1;var e=xe(),o=mt(),t=vt(),n="Expected a function",r=Math.max,s=Math.min;function a(p,h,l){var u,m,y,S,T,A,O=0,Le=!1,B=!1,pe=!0;if(typeof p!="function")throw new TypeError(n);h=t(h)||0,e(l)&&(Le=!!l.leading,B="maxWait"in l,y=B?r(t(l.maxWait)||0,h):y,pe="trailing"in l?!!l.trailing:pe);function le(b){var I=u,D=m;return u=m=void 0,O=b,S=p.apply(D,I),S}function Xt(b){return O=b,T=setTimeout($,h),Le?le(b):S}function zt(b){var I=b-A,D=b-O,Me=h-I;return B?s(Me,y-D):Me}function Ue(b){var I=b-A,D=b-O;return A===void 0||I>=h||I<0||B&&D>=y}function $(){var b=o();if(Ue(b))return Ve(b);T=setTimeout($,zt(b))}function Ve(b){return T=void 0,pe&&u?le(b):(u=m=void 0,S)}function Yt(){T!==void 0&&clearTimeout(T),O=0,u=A=m=T=void 0}function Zt(){return T===void 0?S:Ve(o())}function de(){var b=o(),I=Ue(b);if(u=arguments,m=this,A=b,I){if(T===void 0)return Xt(A);if(B)return clearTimeout(T),T=setTimeout($,h),le(A)}return T===void 0&&(T=setTimeout($,h)),S}return de.cancel=Yt,de.flush=Zt,de}return ie=a,ie}var Ct=St();const At=he(Ct),U={EMPTY_TOKEN:"EMPTY_TOKEN",EXPIRED_TOKEN:"EXPIRED_TOKEN",INVALID_TOKEN:"INVALID_TOKEN",TOKEN_RENEW_FAILED:"TOKEN_RENEW_FAILED",BLOCKED_TOKEN:"BLOCKED_TOKEN",EXPIRED_SESSION:"EXPIRED_SESSION",NOT_EXIST_USER:"NOT_EXIST_USER",SKIP_TOKEN_RENEW:"SKIP_TOKEN_RENEW",USER_HAS_NO_ROLES_ERR:"USER_HAS_NO_ROLES_ERR"};function wt(e,o){const t=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp(`^${t.replace(/\/?$/,"")}(\\/|$)`);return e.replace(n,"/")||e}const It=At(e=>{e()},3e3,{leading:!0,trailing:!1});function Et({app:e}){return e.apiClient.axios,[n=>{var s;const r=(s=n==null?void 0:n.headers)==null?void 0:s["x-new-token"];return r&&e.apiClient.auth.setToken(r),n},n=>{var m,y,S,T,A;const r=(y=(m=n==null?void 0:n.response)==null?void 0:m.headers)==null?void 0:y["x-new-token"],s=(T=(S=n==null?void 0:n.response)==null?void 0:S.data)==null?void 0:T.errors,a=Array.isArray(s)?s[0]:null,p=e.router.state,{pathname:h,search:l}=p.location,u=e.router.basename;if(r&&e.apiClient.auth.setToken(r),n.status===401&&(a!=null&&a.code)&&U[a.code]&&(e.apiClient.auth.setToken(""),h===e.getHref("signin")&&(a==null?void 0:a.code)!==U.EMPTY_TOKEN&&n.config&&(n.config.skipNotify=!1),(a==null?void 0:a.code)==="USER_HAS_NO_ROLES_ERR"&&(n.config.skipNotify=!0,e.error=a)),n.status===401&&!((A=n.config)!=null&&A.skipAuth)&&(a!=null&&a.code)&&U[a.code]){if(!a||(a==null?void 0:a.code)===U.SKIP_TOKEN_RENEW)throw n;if(h!==e.getHref("signin")){const O=wt(h,u);It(()=>{e.apiClient.auth.setToken(null),e.router.navigate(`/signin?redirect=${O}${l}`,{replace:!0})})}}throw n}]}const se=f.createContext({type:""});se.displayName="AuthTypeContext";const ae=f.createContext({types:[]});ae.displayName="AuthTypesContext";const kt=()=>{const{types:e}=f.useContext(ae);return e},Ft=e=>{const o=i.useRecord(),t=i.useRequest(()=>Promise.resolve({data:E({},o.options)}),W(E({},e),{manual:!0})),{run:n}=t,r=i.useActionContext();return f.useEffect(()=>{r.visible&&n()},[r.visible,n]),t},Pt=e=>{var n;const t=i.usePlugin(_).authTypes.get(e);return(n=t==null?void 0:t.components)==null?void 0:n.AdminSettingsForm},_t=v.observer(()=>{const e=v.useForm(),o=i.useRecord(),t=Pt(e.values.authType||o.authType);return t?c.jsx(t,{}):null},{displayName:"Options"}),Ne={name:"authenticators",sortable:!0,fields:[{name:"id",type:"string",interface:"id"},{interface:"input",type:"string",name:"name",uiSchema:{type:"string",title:'{{t("Auth UID")}}',"x-component":"Input","x-validator":e=>/^[a-zA-Z0-9_-]+$/.test(e)?"":i.i18n.t("a-z, A-Z, 0-9, _, -"),required:!0}},{interface:"input",type:"string",name:"authType",uiSchema:{type:"string",title:'{{t("Auth Type")}}',"x-component":"Select",dataSource:"{{ types }}",required:!0}},{interface:"input",type:"string",name:"title",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}},{interface:"textarea",type:"string",name:"description",uiSchema:{type:"string",title:'{{t("Description")}}',"x-component":"Input"}},{type:"boolean",name:"enabled",uiSchema:{type:"boolean",title:'{{t("Enabled")}}',"x-component":"Checkbox"}}]},Ot={type:"object",properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues(e){const o=i.useActionContext(),{type:t}=f.useContext(se);return i.useRequest(()=>Promise.resolve({data:{name:`s_${v.uid()}`,authType:t}}),W(E({},e),{refreshDeps:[o.visible]}))}},title:'{{t("Add new")}}',properties:{name:{"x-component":"CollectionField","x-decorator":"FormItem"},authType:{"x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{options:"{{ types }}"}},title:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"Options"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},create:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useCreateDatabaseConnectionAction","x-component-props":{type:"primary"}}}}}}}},Nt={type:"void",name:"authenticators","x-decorator":"TableBlockProvider","x-decorator-props":{collection:Ne,dragSort:!0,action:"list",params:{pageSize:50,sort:"sort",appends:[]}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{delete:{type:"void",title:'{{t("Delete")}}',"x-action":"destroy","x-decorator":"ACLActionProvider","x-component":"Action","x-use-component-props":"useBulkDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"AddNew","x-component-props":{type:"primary"}}}},table:{type:"array","x-uid":"input","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{id:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},name:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},authType:{title:'{{t("Auth Type")}}',type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{authType:{type:"string","x-component":"Select","x-read-pretty":!0,enum:"{{ types }}"}}},title:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},description:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{description:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"TableV2.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{updateAuthenticator:{type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},"x-decorator":"ACLActionProvider",properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{card:{type:"void","x-acl-action-props":{skipScopeCheck:!1},"x-acl-action":"authenticators:update","x-decorator":"FormBlockProvider","x-use-decorator-props":"useEditFormBlockDecoratorProps","x-decorator-props":{action:"get",dataSource:"main",collection:Ne},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary"}}}},name:{"x-component":"CollectionField","x-decorator":"FormItem"},authType:{"x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{options:"{{ types }}"}},title:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"Options"}}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-action":"destroy","x-component":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}},"x-disabled":"{{ useCanNotDelete() }}"}}}}}}}}},qt=()=>{const{setVisible:e}=i.useActionContext();return{run(){return k(this,null,function*(){e(!1)})}}},jt=()=>{const{t:e}=F.useTranslation(),[o,t]=f.useState(!1),[n,r]=f.useState(""),s=kt(),a=s.map(p=>W(E({},p),{onClick:()=>{t(!0),r(p.value)}}));return c.jsx(i.ActionContextProvider,{value:{visible:o,setVisible:t},children:c.jsxs(se.Provider,{value:{type:n},children:[c.jsx(x.Dropdown,{menu:{items:a},children:c.jsxs(x.Button,{icon:c.jsx(N.PlusOutlined,{}),type:"primary",children:[e("Add new")," ",c.jsx(N.DownOutlined,{})]})}),c.jsx(i.SchemaComponent,{scope:{useCloseAction:qt,types:s,setType:r},schema:Ot})]})})},Bt=()=>{const{data:e}=i.useAsyncData();return!1},Dt=()=>{const{t:e}=w(),[o,t]=f.useState([]),n=i.useAPIClient();return i.useRequest(()=>n.resource("authenticators").listTypes().then(r=>{var a;return(((a=r==null?void 0:r.data)==null?void 0:a.data)||[]).map(p=>({key:p.name,label:e(p.title||p.name),value:p.name}))}),{onSuccess:r=>{t(r)}}),c.jsx(x.Card,{bordered:!1,children:c.jsx(ae.Provider,{value:{types:o},children:c.jsx(i.SchemaComponent,{schema:Nt,components:{AddNew:jt,Options:_t},scope:{types:o,useValuesFromOptions:Ft,useCanNotDelete:Bt,t:e}})})})},{Option:ce}=x.Select,Lt=v.connect(e=>{const{t:o}=w(),m=e,{value:t,onChange:n,minNum:r=1}=m,s=Ge(m,["value","onChange","minNum"]),a=/^(\d*)([a-zA-Z]*)$/,p=t?t.match(a):null;f.useEffect(()=>{p||n("10m")},[p,n]);const[h,l]=p?[parseInt(p[1]),p[2]]:[10,"m"],u=c.jsxs(x.Select,{value:l,onChange:y=>n(`${h}${y}`),style:{width:120},children:[c.jsx(ce,{value:"m",children:o("Minutes")}),c.jsx(ce,{value:"h",children:o("Hours")}),c.jsx(ce,{value:"d",children:o("Days")})]});return c.jsx(x.InputNumber,E({value:h,addonAfter:u,min:r,onChange:y=>n(`${y!=null?y:1}${l}`)},s))},v.mapProps({onInput:"onChange"})),V={InputTime:"InputTime"},Ut={[V.InputTime]:Lt};var ue,qe;function Vt(){if(qe)return ue;qe=1;var e=1e3,o=e*60,t=o*60,n=t*24,r=n*7,s=n*365.25;ue=function(u,m){m=m||{};var y=typeof u;if(y==="string"&&u.length>0)return a(u);if(y==="number"&&isFinite(u))return m.long?h(u):p(u);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(u))};function a(u){if(u=String(u),!(u.length>100)){var m=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(u);if(m){var y=parseFloat(m[1]),S=(m[2]||"ms").toLowerCase();switch(S){case"years":case"year":case"yrs":case"yr":case"y":return y*s;case"weeks":case"week":case"w":return y*r;case"days":case"day":case"d":return y*n;case"hours":case"hour":case"hrs":case"hr":case"h":return y*t;case"minutes":case"minute":case"mins":case"min":case"m":return y*o;case"seconds":case"second":case"secs":case"sec":case"s":return y*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return y;default:return}}}}function p(u){var m=Math.abs(u);return m>=n?Math.round(u/n)+"d":m>=t?Math.round(u/t)+"h":m>=o?Math.round(u/o)+"m":m>=e?Math.round(u/e)+"s":u+"ms"}function h(u){var m=Math.abs(u);return m>=n?l(u,m,n,"day"):m>=t?l(u,m,t,"hour"):m>=o?l(u,m,o,"minute"):m>=e?l(u,m,e,"second"):u+" ms"}function l(u,m,y,S){var T=m>=y*1.5;return Math.round(u/y)+" "+S+(T?"s":"")}return ue}var Mt=Vt();const je=he(Mt),Be="token-policy-config",De="tokenControlConfig",$t=()=>{const e=i.useAPIClient(),o=f.useMemo(()=>v.createForm(),[]);return f.useEffect(()=>{k(null,null,function*(){var n;try{const{data:r}=yield e.resource(De).get({filterByTk:Be});(n=r==null?void 0:r.data)!=null&&n.config&&o.setValues(r.data.config)}catch(r){console.error(r)}})},[o,e]),{form:o}},Kt=()=>{const{message:e}=x.App.useApp(),o=i.useAPIClient(),t=v.useForm(),{t:n}=w();return{type:"primary",onClick(){return k(this,null,function*(){t.clearErrors("*");const{tokenExpirationTime:s,sessionExpirationTime:a,expiredTokenRenewLimit:p}=t.values;if(je(s)>=je(a)){t.setFieldState("tokenExpirationTime",l=>{l.feedbacks=[{type:"error",code:"ValidateError",messages:[n("Token validity period must be less than session validity period!")]}]});return}yield t.submit();const h=yield o.resource(De).update({values:{config:t.values},filterByTk:Be});h&&h.status===200&&e.success(n("Saved successfully!"))})}}},M={useSubmitActionProps:"useSubmitActionProps",useEditForm:"useEditForm"},Wt={[M.useEditForm]:$t,[M.useSubmitActionProps]:Kt},Gt={name:v.uid(),"x-component":"FormV2","x-use-component-props":M.useEditForm,type:"object",properties:{sessionExpirationTime:{type:"string",title:q("Session validity period"),"x-decorator":"FormItem","x-component":V.InputTime,required:!0,description:q("The maximum valid time for each user login. During the session validity, the Token will be automatically updated. After the timeout, the user is required to log in again.")},tokenExpirationTime:{type:"string",title:q("Token validity period"),"x-decorator":"FormItem","x-component":V.InputTime,required:!0,description:q("The validity period of each issued API Token. After the Token expires, if it is within the session validity period and has not exceeded the refresh limit, the server will automatically issue a new Token to maintain the user session, otherwise the user is required to log in again. (Each Token can only be refreshed once)")},expiredTokenRenewLimit:{type:"string",title:"{{t('Expired token refresh limit')}}","x-decorator":"FormItem","x-component":V.InputTime,"x-component-props":{minNum:0},required:!0,description:q("The maximum time limit allowed for refreshing a Token after it expires. After this time limit, the token cannot be automatically renewed, and the user needs to log in again.")},footer:{type:"void","x-component":"ActionBar","x-component-props":{layout:"one-column"},properties:{submit:{title:'{{t("Submit")}}',"x-component":"Action","x-use-component-props":M.useSubmitActionProps}}}}},Ht=()=>{const{t:e}=w();return c.jsx(x.Card,{bordered:!1,children:c.jsx(i.SchemaComponent,{schema:Gt,scope:E({t:e},Wt),components:Ut})})};class _ extends i.Plugin{constructor(){super(...arguments),this.authTypes=new g.Registry}registerType(o,t){this.authTypes.register(o,t)}load(){return k(this,null,function*(){this.app.systemSettingsManager.add("system-services."+P,{icon:"LoginOutlined",title:`{{t("Authentication", { ns: "${P}" })}}`,Component:Dt,aclSnippet:"pm.auth.authenticators"}),this.app.userSettingsManager.add(P,{icon:"LoginOutlined",title:`{{t("Authentication login bind", { ns: "${P}" })}}`,Component:lt,aclSnippet:"pm.auth.authenticators"}),this.router.add("auth",{Component:"AuthLayout"}),this.router.add("auth.signin",{path:"/signin",Component:"SignInPage"}),this.router.add("auth.signup",{path:"/signup",Component:"SignUpPage"}),this.app.addComponents({AuthLayout:ze,SignInPage:Je,SignUpPage:Re}),this.app.providers.unshift([Xe,{}]),this.registerType(He,{components:{SignInForm:nt,SignUpForm:it,AdminSettingsForm:st}}),this.app.systemSettingsManager.add("security.token-policy",{title:`{{t("Token policy", { ns: "${P}" })}}`,Component:Ht,aclSnippet:"pm.security.token-policy",icon:"ApiOutlined",sort:0});const[o,t]=Et({app:this.app});this.app.apiClient.axios.interceptors.response.handlers.unshift({fulfilled:o,rejected:t,synchronous:!1,runWhen:null})})}}d.AuthenticatorsContext=j,d.PluginAuthClient=_,d.default=_,d.useAuthenticator=G,d.useSignIn=ye,Object.defineProperties(d,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,19 +1,19 @@
1
1
  module.exports = {
2
2
  "react": "18.3.1",
3
- "@tachybase/client": "1.3.15",
3
+ "@tachybase/client": "1.3.17",
4
4
  "react-router-dom": "6.28.1",
5
- "@tachybase/utils": "1.3.15",
5
+ "@tachybase/utils": "1.3.17",
6
6
  "axios": "1.7.7",
7
7
  "lodash": "4.17.21",
8
- "@tachybase/auth": "1.3.15",
9
- "@tachybase/database": "1.3.15",
10
- "@tachybase/cache": "1.3.15",
11
- "@tachybase/server": "1.3.15",
12
- "@tachybase/logger": "1.3.15",
13
- "@tachybase/test": "1.3.15",
8
+ "@tachybase/auth": "1.3.17",
9
+ "@tachybase/database": "1.3.17",
10
+ "@tachybase/cache": "1.3.17",
11
+ "@tachybase/server": "1.3.17",
12
+ "@tachybase/logger": "1.3.17",
13
+ "@tachybase/test": "1.3.17",
14
14
  "antd": "5.22.5",
15
- "@tachybase/schema": "1.3.15",
15
+ "@tachybase/schema": "1.3.17",
16
16
  "react-i18next": "15.2.0",
17
17
  "@ant-design/icons": "5.3.7",
18
- "@tachybase/actions": "1.3.15"
18
+ "@tachybase/actions": "1.3.17"
19
19
  };
package/dist/index.js CHANGED
@@ -25,13 +25,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  mod
26
26
  ));
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var src_exports = {};
29
- __export(src_exports, {
28
+ var index_exports = {};
29
+ __export(index_exports, {
30
30
  AuthModel: () => import_server.AuthModel,
31
31
  BasicAuth: () => import_server.BasicAuth,
32
32
  default: () => import_server.default
33
33
  });
34
- module.exports = __toCommonJS(src_exports);
34
+ module.exports = __toCommonJS(index_exports);
35
35
  var import_server = __toESM(require("./server"));
36
36
  // Annotate the CommonJS export names for ESM import in node:
37
37
  0 && (module.exports = {
@@ -1 +1 @@
1
- {"name":"cron","description":"Cron jobs for your node","version":"3.3.1","author":"Nick Campbell <nicholas.j.campbell@gmail.com> (https://github.com/ncb000gt)","bugs":{"url":"https://github.com/kelektiv/node-cron/issues"},"repository":{"type":"git","url":"https://github.com/kelektiv/node-cron.git"},"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc -b tsconfig.build.json","lint:eslint":"eslint src/ tests/","lint:prettier":"prettier ./**/*.{json,md,yml} --check","lint":"npm run lint:eslint && npm run lint:prettier","lint:fix":"npm run lint:eslint -- --fix && npm run lint:prettier -- --write","test":"jest --coverage","test:watch":"jest --watch --coverage","test:fuzz":"jest --testMatch='**/*.fuzz.ts' --coverage=false --testTimeout=120000","prepare":"husky"},"dependencies":{"@types/luxon":"~3.4.0","luxon":"~3.5.0"},"devDependencies":{"@commitlint/cli":"19.6.0","@eslint/js":"^9.14.0","@fast-check/jest":"2.0.3","@insurgent/commitlint-config":"20.0.0","@insurgent/conventional-changelog-preset":"10.0.0","@semantic-release/changelog":"6.0.3","@semantic-release/commit-analyzer":"13.0.0","@semantic-release/git":"10.0.1","@semantic-release/github":"11.0.1","@semantic-release/npm":"12.0.1","@semantic-release/release-notes-generator":"14.0.1","@types/jest":"29.5.14","@types/node":"20.17.9","@types/sinon":"17.0.3","chai":"4.5.0","eslint":"8.57.1","eslint-config-prettier":"9.1.0","eslint-plugin-jest":"27.9.0","eslint-plugin-prettier":"5.2.1","husky":"9.1.7","jest":"29.7.0","lint-staged":"15.2.10","prettier":"3.3.3","semantic-release":"24.2.0","sinon":"17.0.2","ts-jest":"29.2.5","typescript":"5.7.2","typescript-eslint":"^7.2.0"},"keywords":["cron","node cron","node-cron","schedule","scheduler","cronjob","cron job"],"license":"MIT","contributors":["Brandon der Blätter <https://interlucid.com/contact/> (https://github.com/intcreator)","Pierre Cavin <me@sherlox.io> (https://github.com/sheerlox)","Romain Beauxis <toots@rastageeks.org> (https://github.com/toots)","James Padolsey <> (https://github.com/jamespadolsey)","Finn Herpich <fh@three-heads.de> (https://github.com/ErrorProne)","Clifton Cunningham <clifton.cunningham@gmail.com> (https://github.com/cliftonc)","Eric Abouaf <eric.abouaf@gmail.com> (https://github.com/neyric)","humanchimp <morphcham@gmail.com> (https://github.com/humanchimp)","Craig Condon <craig@spiceapps.com> (https://github.com/spiceapps)","Dan Bear <daniel@hulu.com> (https://github.com/danhbear)","Vadim Baryshev <vadimbaryshev@gmail.com> (https://github.com/baryshev)","Leandro Ferrari <lfthomaz@gmail.com> (https://github.com/lfthomaz)","Gregg Zigler <greggzigler@gmail.com> (https://github.com/greggzigler)","Jordan Abderrachid <jabderrachid@gmail.com> (https://github.com/jordanabderrachid)","Masakazu Matsushita <matsukaz@gmail.com> (matsukaz)","Christopher Lunt <me@kirisu.co.uk> (https://github.com/kirisu)"],"files":["dist/**/*.js","dist/**/*.d.ts","CHANGELOG.md","LICENSE","README.md"],"lint-staged":{"*.ts":"eslint src/ tests/ --fix","*.{json,md,yml}":"prettier ./**/*.{json,md,yml} --check --write"},"_lastModified":"2025-07-01T07:54:42.454Z"}
1
+ {"name":"cron","description":"Cron jobs for your node","version":"3.3.1","author":"Nick Campbell <nicholas.j.campbell@gmail.com> (https://github.com/ncb000gt)","bugs":{"url":"https://github.com/kelektiv/node-cron/issues"},"repository":{"type":"git","url":"https://github.com/kelektiv/node-cron.git"},"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc -b tsconfig.build.json","lint:eslint":"eslint src/ tests/","lint:prettier":"prettier ./**/*.{json,md,yml} --check","lint":"npm run lint:eslint && npm run lint:prettier","lint:fix":"npm run lint:eslint -- --fix && npm run lint:prettier -- --write","test":"jest --coverage","test:watch":"jest --watch --coverage","test:fuzz":"jest --testMatch='**/*.fuzz.ts' --coverage=false --testTimeout=120000","prepare":"husky"},"dependencies":{"@types/luxon":"~3.4.0","luxon":"~3.5.0"},"devDependencies":{"@commitlint/cli":"19.6.0","@eslint/js":"^9.14.0","@fast-check/jest":"2.0.3","@insurgent/commitlint-config":"20.0.0","@insurgent/conventional-changelog-preset":"10.0.0","@semantic-release/changelog":"6.0.3","@semantic-release/commit-analyzer":"13.0.0","@semantic-release/git":"10.0.1","@semantic-release/github":"11.0.1","@semantic-release/npm":"12.0.1","@semantic-release/release-notes-generator":"14.0.1","@types/jest":"29.5.14","@types/node":"20.17.9","@types/sinon":"17.0.3","chai":"4.5.0","eslint":"8.57.1","eslint-config-prettier":"9.1.0","eslint-plugin-jest":"27.9.0","eslint-plugin-prettier":"5.2.1","husky":"9.1.7","jest":"29.7.0","lint-staged":"15.2.10","prettier":"3.3.3","semantic-release":"24.2.0","sinon":"17.0.2","ts-jest":"29.2.5","typescript":"5.7.2","typescript-eslint":"^7.2.0"},"keywords":["cron","node cron","node-cron","schedule","scheduler","cronjob","cron job"],"license":"MIT","contributors":["Brandon der Blätter <https://interlucid.com/contact/> (https://github.com/intcreator)","Pierre Cavin <me@sherlox.io> (https://github.com/sheerlox)","Romain Beauxis <toots@rastageeks.org> (https://github.com/toots)","James Padolsey <> (https://github.com/jamespadolsey)","Finn Herpich <fh@three-heads.de> (https://github.com/ErrorProne)","Clifton Cunningham <clifton.cunningham@gmail.com> (https://github.com/cliftonc)","Eric Abouaf <eric.abouaf@gmail.com> (https://github.com/neyric)","humanchimp <morphcham@gmail.com> (https://github.com/humanchimp)","Craig Condon <craig@spiceapps.com> (https://github.com/spiceapps)","Dan Bear <daniel@hulu.com> (https://github.com/danhbear)","Vadim Baryshev <vadimbaryshev@gmail.com> (https://github.com/baryshev)","Leandro Ferrari <lfthomaz@gmail.com> (https://github.com/lfthomaz)","Gregg Zigler <greggzigler@gmail.com> (https://github.com/greggzigler)","Jordan Abderrachid <jabderrachid@gmail.com> (https://github.com/jordanabderrachid)","Masakazu Matsushita <matsukaz@gmail.com> (matsukaz)","Christopher Lunt <me@kirisu.co.uk> (https://github.com/kirisu)"],"files":["dist/**/*.js","dist/**/*.d.ts","CHANGELOG.md","LICENSE","README.md"],"lint-staged":{"*.ts":"eslint src/ tests/ --fix","*.{json,md,yml}":"prettier ./**/*.{json,md,yml} --check --write"},"_lastModified":"2025-07-04T03:56:24.329Z"}
@@ -1 +1 @@
1
- {"name":"ms","version":"2.1.3","description":"Tiny millisecond conversion utility","repository":"vercel/ms","main":"./index","files":["index.js"],"scripts":{"precommit":"lint-staged","lint":"eslint lib/* bin/*","test":"mocha tests.js"},"eslintConfig":{"extends":"eslint:recommended","env":{"node":true,"es6":true}},"lint-staged":{"*.js":["npm run lint","prettier --single-quote --write","git add"]},"license":"MIT","devDependencies":{"eslint":"4.18.2","expect.js":"0.3.1","husky":"0.14.3","lint-staged":"5.0.0","mocha":"4.0.1","prettier":"2.0.5"},"_lastModified":"2025-07-01T07:54:42.552Z"}
1
+ {"name":"ms","version":"2.1.3","description":"Tiny millisecond conversion utility","repository":"vercel/ms","main":"./index","files":["index.js"],"scripts":{"precommit":"lint-staged","lint":"eslint lib/* bin/*","test":"mocha tests.js"},"eslintConfig":{"extends":"eslint:recommended","env":{"node":true,"es6":true}},"lint-staged":{"*.js":["npm run lint","prettier --single-quote --write","git add"]},"license":"MIT","devDependencies":{"eslint":"4.18.2","expect.js":"0.3.1","husky":"0.14.3","lint-staged":"5.0.0","mocha":"4.0.1","prettier":"2.0.5"},"_lastModified":"2025-07-04T03:56:24.425Z"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tachybase/module-auth",
3
3
  "displayName": "Authentication",
4
- "version": "1.3.15",
4
+ "version": "1.3.17",
5
5
  "description": "User authentication management, including password, SMS, and support for Single Sign-On (SSO) protocols, with extensibility.",
6
6
  "keywords": [
7
7
  "Authentication",
@@ -19,18 +19,18 @@
19
19
  "react": "^18.3.1",
20
20
  "react-i18next": "^15.2.0",
21
21
  "react-router-dom": "6.28.1",
22
- "@tachybase/schema": "1.3.15"
22
+ "@tachybase/schema": "1.3.17"
23
23
  },
24
24
  "peerDependencies": {
25
- "@tachybase/actions": "1.3.15",
26
- "@tachybase/auth": "1.3.15",
27
- "@tachybase/cache": "1.3.15",
28
- "@tachybase/database": "1.3.15",
29
- "@tachybase/logger": "1.3.15",
30
- "@tachybase/server": "1.3.15",
31
- "@tachybase/test": "1.3.15",
32
- "@tachybase/client": "1.3.15",
33
- "@tachybase/utils": "1.3.15"
25
+ "@tachybase/actions": "1.3.17",
26
+ "@tachybase/auth": "1.3.17",
27
+ "@tachybase/cache": "1.3.17",
28
+ "@tachybase/database": "1.3.17",
29
+ "@tachybase/logger": "1.3.17",
30
+ "@tachybase/server": "1.3.17",
31
+ "@tachybase/client": "1.3.17",
32
+ "@tachybase/test": "1.3.17",
33
+ "@tachybase/utils": "1.3.17"
34
34
  },
35
35
  "description.zh-CN": "用户认证管理,包括基础的密码认证、短信认证、SSO 协议的认证等,可扩展。",
36
36
  "displayName.zh-CN": "用户认证",