@nocobase/plugin-auth
Advanced tools
Comparing version 0.20.0-alpha.5 to 0.20.0-alpha.6
@@ -1,2 +0,2 @@ | ||
(function(c,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("react"),require("react-router-dom"),require("react-i18next"),require("antd"),require("@formily/shared"),require("@ant-design/icons"),require("@formily/react"),require("@emotion/css"),require("@nocobase/utils/client")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","react","react-router-dom","react-i18next","antd","@formily/shared","@ant-design/icons","@formily/react","@emotion/css","@nocobase/utils/client"],e):(c=typeof globalThis!="undefined"?globalThis:c||self,e(c["@nocobase/plugin-auth"]={},c["@nocobase/client"],c.jsxRuntime,c.react,c["react-router-dom"],c["react-i18next"],c.antd,c["@formily/shared"],c["@ant-design/icons"],c["@formily/react"],c["@emotion/css"],c["@nocobase/utils"]))})(this,function(c,e,n,u,m,x,d,g,y,h,b,E){"use strict";var ae=Object.defineProperty,pe=Object.defineProperties;var ue=Object.getOwnPropertyDescriptors;var $=Object.getOwnPropertySymbols;var le=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable;var P=(c,e,n)=>e in c?ae(c,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):c[e]=n,v=(c,e)=>{for(var n in e||(e={}))le.call(e,n)&&P(c,n,e[n]);if($)for(var n of $(e))me.call(e,n)&&P(c,n,e[n]);return c},T=(c,e)=>pe(c,ue(e));var N=(c,e,n)=>(P(c,typeof e!="symbol"?e+"":e,n),n);var C=(c,e,n)=>new Promise((u,m)=>{var x=y=>{try{g(n.next(y))}catch(h){m(h)}},d=y=>{try{g(n.throw(y))}catch(h){m(h)}},g=y=>y.done?u(y.value):Promise.resolve(y.value).then(x,d);g((n=n.apply(c,e)).next())});const j=t=>{const r=m.useLocation(),o=e.useAPIClient();return u.useEffect(()=>{const i=new URLSearchParams(r.search),s=i.get("authenticator"),a=i.get("token");a&&(o.auth.setToken(a),o.auth.setAuthenticator(s))}),n.jsx(n.Fragment,{children:t.children})},F="auth";function A(){return x.useTranslation([F,"client"],{nsMode:"fallback"})}const I=u.createContext({type:""}),U=u.createContext({types:[]}),B=()=>{const{types:t}=u.useContext(U);return t},k={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":t=>/^[a-zA-Z0-9_-]+$/.test(t)?"":e.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"}}]},L={type:"object",properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues(t){const r=e.useActionContext(),{type:o}=u.useContext(I);return e.useRequest(()=>Promise.resolve({data:{name:`s_${g.uid()}`,authType:o}}),T(v({},t),{refreshDeps:[r.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-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}},O={type:"void",name:"authenticators","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:k,resourceName:"authenticators",dragSort:!0,request:{resource:"authenticators",action:"list",params:{pageSize:50,sort:"sort",appends:[]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:k},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useBulkDestroyAction }}",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:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}",useAction(){const t=e.useAPIClient(),{t:r}=x.useTranslation();return{move(i,s){return C(this,null,function*(){yield t.resource("authenticators").move({sourceId:i.id,targetId:s.id}),d.message.success(r("Saved successfully"),.2)})}}}},properties:{id:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},name:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},authType:{title:'{{t("Auth Type")}}',type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{authType:{type:"string","x-component":"Select","x-read-pretty":!0,enum:"{{ types }}"}}},title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},description:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{description:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{update:{type:"void",title:'{{t("Configure")}}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{t("Configure")}}',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-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{cm.useDestroyAction}}"},"x-disabled":"{{ useCanNotDelete() }}"}}}}}}}}},V=t=>{const r=e.useRecord(),o=e.useRequest(()=>Promise.resolve({data:v({},r.options)}),T(v({},t),{manual:!0})),{run:i}=o,s=e.useActionContext();return u.useEffect(()=>{s.visible&&i()},[s.visible,i]),o},_=t=>{var i;const o=e.usePlugin(f).authTypes.get(t);return(i=o==null?void 0:o.components)==null?void 0:i.AdminSettingsForm},M=h.observer(()=>{const t=h.useForm(),r=e.useRecord(),o=_(t.values.authType||r.authType);return o?n.jsx(o,{}):null}),z=()=>{const{setVisible:t}=e.useActionContext();return{run(){return C(this,null,function*(){t(!1)})}}},Z=()=>{const{t}=x.useTranslation(),[r,o]=u.useState(!1),[i,s]=u.useState(""),a=B(),p=a.map(l=>T(v({},l),{onClick:()=>{o(!0),s(l.value)}}));return n.jsx(e.ActionContextProvider,{value:{visible:r,setVisible:o},children:n.jsxs(I.Provider,{value:{type:i},children:[n.jsx(d.Dropdown,{menu:{items:p},children:n.jsxs(d.Button,{icon:n.jsx(y.PlusOutlined,{}),type:"primary",children:[t("Add new")," ",n.jsx(y.DownOutlined,{})]})}),n.jsx(e.SchemaComponent,{scope:{useCloseAction:z,types:a,setType:s},schema:L})]})})},K=()=>(e.useAsyncData(),!1),W=()=>{const{t}=A(),[r,o]=u.useState([]),i=e.useAPIClient();return e.useRequest(()=>i.resource("authenticators").listTypes().then(s=>{var p;return(((p=s==null?void 0:s.data)==null?void 0:p.data)||[]).map(l=>({key:l.name,label:t(l.title||l.name),value:l.name}))}),{onSuccess:s=>{o(s)}}),n.jsx(d.Card,{bordered:!1,children:n.jsx(U.Provider,{value:{types:r},children:n.jsx(e.SchemaComponent,{schema:O,components:{AddNew:Z,Options:M},scope:{types:r,useValuesFromOptions:V,useCanNotDelete:K,t}})})})},S=u.createContext([]),w=t=>u.useContext(S).find(o=>o.name===t);function G(t){var a;const{data:r}=e.useSystemSettings(),o=e.useAPIClient(),{data:i=[],error:s}=e.useRequest(()=>o.resource("authenticators").publicList().then(p=>{var l;return((l=p==null?void 0:p.data)==null?void 0:l.data)||[]}));if(s)throw s;return n.jsxs("div",{style:{maxWidth:320,margin:"0 auto",paddingTop:"20vh"},children:[n.jsx("h1",{children:(a=r==null?void 0:r.data)==null?void 0:a.title}),n.jsx(S.Provider,{value:i,children:n.jsx(m.Outlet,{})}),n.jsx("div",{className:b.css` | ||
(function(c,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("react"),require("react-router-dom"),require("react-i18next"),require("antd"),require("@formily/shared"),require("@ant-design/icons"),require("@formily/react"),require("@emotion/css"),require("@nocobase/utils/client")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","react","react-router-dom","react-i18next","antd","@formily/shared","@ant-design/icons","@formily/react","@emotion/css","@nocobase/utils/client"],e):(c=typeof globalThis!="undefined"?globalThis:c||self,e(c["@nocobase/plugin-auth"]={},c["@nocobase/client"],c.jsxRuntime,c.react,c["react-router-dom"],c["react-i18next"],c.antd,c["@formily/shared"],c["@ant-design/icons"],c["@formily/react"],c["@emotion/css"],c["@nocobase/utils"]))})(this,function(c,e,n,u,m,x,d,g,y,h,b,E){"use strict";var pe=Object.defineProperty,ue=Object.defineProperties;var le=Object.getOwnPropertyDescriptors;var N=Object.getOwnPropertySymbols;var me=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable;var U=(c,e,n)=>e in c?pe(c,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):c[e]=n,C=(c,e)=>{for(var n in e||(e={}))me.call(e,n)&&U(c,n,e[n]);if(N)for(var n of N(e))de.call(e,n)&&U(c,n,e[n]);return c},T=(c,e)=>ue(c,le(e));var $=(c,e,n)=>(U(c,typeof e!="symbol"?e+"":e,n),n);var v=(c,e,n)=>new Promise((u,m)=>{var x=y=>{try{g(n.next(y))}catch(h){m(h)}},d=y=>{try{g(n.throw(y))}catch(h){m(h)}},g=y=>y.done?u(y.value):Promise.resolve(y.value).then(x,d);g((n=n.apply(c,e)).next())});const j=t=>{const r=m.useLocation(),o=e.useAPIClient();return u.useEffect(()=>{const i=new URLSearchParams(r.search),s=i.get("authenticator"),a=i.get("token");a&&(o.auth.setToken(a),o.auth.setAuthenticator(s))}),n.jsx(n.Fragment,{children:t.children})},F="auth";function A(){return x.useTranslation([F,"client"],{nsMode:"fallback"})}const w=u.createContext({type:""});w.displayName="AuthTypeContext";const P=u.createContext({types:[]});P.displayName="AuthTypesContext";const B=()=>{const{types:t}=u.useContext(P);return t},k={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":t=>/^[a-zA-Z0-9_-]+$/.test(t)?"":e.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"}}]},L={type:"object",properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues(t){const r=e.useActionContext(),{type:o}=u.useContext(w);return e.useRequest(()=>Promise.resolve({data:{name:`s_${g.uid()}`,authType:o}}),T(C({},t),{refreshDeps:[r.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-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}},O={type:"void",name:"authenticators","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:k,resourceName:"authenticators",dragSort:!0,request:{resource:"authenticators",action:"list",params:{pageSize:50,sort:"sort",appends:[]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:k},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useBulkDestroyAction }}",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:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}",useAction(){const t=e.useAPIClient(),{t:r}=x.useTranslation();return{move(i,s){return v(this,null,function*(){yield t.resource("authenticators").move({sourceId:i.id,targetId:s.id}),d.message.success(r("Saved successfully"),.2)})}}}},properties:{id:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},name:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},authType:{title:'{{t("Auth Type")}}',type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{authType:{type:"string","x-component":"Select","x-read-pretty":!0,enum:"{{ types }}"}}},title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},description:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{description:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{update:{type:"void",title:'{{t("Configure")}}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{t("Configure")}}',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-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{cm.useDestroyAction}}"},"x-disabled":"{{ useCanNotDelete() }}"}}}}}}}}},V=t=>{const r=e.useRecord(),o=e.useRequest(()=>Promise.resolve({data:C({},r.options)}),T(C({},t),{manual:!0})),{run:i}=o,s=e.useActionContext();return u.useEffect(()=>{s.visible&&i()},[s.visible,i]),o},_=t=>{var i;const o=e.usePlugin(f).authTypes.get(t);return(i=o==null?void 0:o.components)==null?void 0:i.AdminSettingsForm},M=h.observer(()=>{const t=h.useForm(),r=e.useRecord(),o=_(t.values.authType||r.authType);return o?n.jsx(o,{}):null},{displayName:"Options"}),z=()=>{const{setVisible:t}=e.useActionContext();return{run(){return v(this,null,function*(){t(!1)})}}},Z=()=>{const{t}=x.useTranslation(),[r,o]=u.useState(!1),[i,s]=u.useState(""),a=B(),p=a.map(l=>T(C({},l),{onClick:()=>{o(!0),s(l.value)}}));return n.jsx(e.ActionContextProvider,{value:{visible:r,setVisible:o},children:n.jsxs(w.Provider,{value:{type:i},children:[n.jsx(d.Dropdown,{menu:{items:p},children:n.jsxs(d.Button,{icon:n.jsx(y.PlusOutlined,{}),type:"primary",children:[t("Add new")," ",n.jsx(y.DownOutlined,{})]})}),n.jsx(e.SchemaComponent,{scope:{useCloseAction:z,types:a,setType:s},schema:L})]})})},K=()=>(e.useAsyncData(),!1),W=()=>{const{t}=A(),[r,o]=u.useState([]),i=e.useAPIClient();return e.useRequest(()=>i.resource("authenticators").listTypes().then(s=>{var p;return(((p=s==null?void 0:s.data)==null?void 0:p.data)||[]).map(l=>({key:l.name,label:t(l.title||l.name),value:l.name}))}),{onSuccess:s=>{o(s)}}),n.jsx(d.Card,{bordered:!1,children:n.jsx(P.Provider,{value:{types:r},children:n.jsx(e.SchemaComponent,{schema:O,components:{AddNew:Z,Options:M},scope:{types:r,useValuesFromOptions:V,useCanNotDelete:K,t}})})})},S=u.createContext([]);S.displayName="AuthenticatorsContext";const I=t=>u.useContext(S).find(o=>o.name===t);function G(t){var a;const{data:r}=e.useSystemSettings(),o=e.useAPIClient(),{data:i=[],error:s}=e.useRequest(()=>o.resource("authenticators").publicList().then(p=>{var l;return((l=p==null?void 0:p.data)==null?void 0:l.data)||[]}));if(s)throw s;return n.jsxs("div",{style:{maxWidth:320,margin:"0 auto",paddingTop:"20vh"},children:[n.jsx("h1",{children:(a=r==null?void 0:r.data)==null?void 0:a.title}),n.jsx(S.Provider,{value:i,children:n.jsx(m.Outlet,{})}),n.jsx("div",{className:b.css` | ||
position: absolute; | ||
@@ -7,7 +7,7 @@ bottom: 24px; | ||
text-align: center; | ||
`,children:n.jsx(e.PoweredBy,{})})]})}const H=()=>{var i;const r=e.usePlugin(f).authTypes.getEntities(),o={};for(const[s,a]of r)(i=a.components)!=null&&i.SignInForm&&(o[s]=a.components.SignInForm);return o},J=(t=[])=>{var a;const o=e.usePlugin(f).authTypes.getEntities(),i={};for(const[p,l]of o)(a=l.components)!=null&&a.SignInButton&&(i[p]=l.components.SignInButton);const s=Object.keys(i);return t.filter(p=>s.includes(p.authType)).map((p,l)=>u.createElement(i[p.authType],{key:l,authenticator:p}))},Q=()=>{const{t}=A();e.useCurrentDocumentTitle("Signin"),e.useViewport();const r=H(),o=u.useContext(S),i=J(o);if(!o.length)return n.jsx("div",{style:{color:"#ccc"},children:t("No authentication methods available.")});const s=o.map(a=>{const p=r[a.authType];if(!p)return;const l=`${t("Sign-in")} (${t(a.authTypeTitle||a.authType)})`;return v({component:u.createElement(p,{authenticator:a}),tabTitle:a.title||l},a)}).filter(a=>a);return n.jsxs(d.Space,{direction:"vertical",className:b.css` | ||
`,children:n.jsx(e.PoweredBy,{})})]})}const H=()=>{var i;const r=e.usePlugin(f).authTypes.getEntities(),o={};for(const[s,a]of r)(i=a.components)!=null&&i.SignInForm&&(o[s]=a.components.SignInForm);return o},J=(t=[])=>{var a;const o=e.usePlugin(f).authTypes.getEntities(),i={};for(const[p,l]of o)(a=l.components)!=null&&a.SignInButton&&(i[p]=l.components.SignInButton);const s=Object.keys(i);return t.filter(p=>s.includes(p.authType)).map((p,l)=>u.createElement(i[p.authType],{key:l,authenticator:p}))},Q=()=>{const{t}=A();e.useCurrentDocumentTitle("Signin"),e.useViewport();const r=H(),o=u.useContext(S),i=J(o);if(!o.length)return n.jsx("div",{style:{color:"#ccc"},children:t("No authentication methods available.")});const s=o.map(a=>{const p=r[a.authType];if(!p)return;const l=`${t("Sign-in")} (${t(a.authTypeTitle||a.authType)})`;return C({component:u.createElement(p,{authenticator:a}),tabTitle:a.title||l},a)}).filter(a=>a);return n.jsxs(d.Space,{direction:"vertical",className:b.css` | ||
display: flex; | ||
`,children:[s.length>1?n.jsx(d.Tabs,{items:s.map(a=>({label:a.tabTitle,key:a.name,children:a.component}))}):s.length?n.jsx("div",{children:s[0].component}):n.jsx(n.Fragment,{}),n.jsx(d.Space,{direction:"vertical",className:b.css` | ||
display: flex; | ||
`,children:i})]})};u.createContext({});const q=()=>{var i;const r=e.usePlugin(f).authTypes.getEntities(),o={};for(const[s,a]of r)(i=a.components)!=null&&i.SignUpForm&&(o[s]=a.components.SignUpForm);return o},X=()=>{e.useViewport(),e.useCurrentDocumentTitle("Signup");const t=q(),[r]=m.useSearchParams(),o=r.get("name"),i=w(o),{authType:s}=i||{};return t[s]?u.createElement(t[s],{authenticatorName:o}):n.jsx(m.Navigate,{to:"/not-found",replace:!0})},Y="Email/Password";function R(t="/admin"){const r=m.useNavigate(),[o]=m.useSearchParams();return u.useCallback(()=>{r(o.get("redirect")||"/admin",{replace:!0})},[r,o])}const D=t=>{const r=h.useForm(),o=e.useAPIClient(),i=R(),{refreshAsync:s}=e.useCurrentUserContext();return{run(){return C(this,null,function*(){yield r.submit(),yield o.auth.signIn(r.values,t),yield s(),i()})}}},ee={type:"object",name:"passwordForm","x-component":"FormV2",properties:{account:{type:"string","x-component":"Input","x-validator":`{{(value) => { | ||
`,children:i})]})},X=u.createContext({});X.displayName="SignupPageContext";const q=()=>{var i;const r=e.usePlugin(f).authTypes.getEntities(),o={};for(const[s,a]of r)(i=a.components)!=null&&i.SignUpForm&&(o[s]=a.components.SignUpForm);return o},Y=()=>{e.useViewport(),e.useCurrentDocumentTitle("Signup");const t=q(),[r]=m.useSearchParams(),o=r.get("name"),i=I(o),{authType:s}=i||{};return t[s]?u.createElement(t[s],{authenticatorName:o}):n.jsx(m.Navigate,{to:"/not-found",replace:!0})},R="Email/Password";function ee(t="/admin"){const r=m.useNavigate(),[o]=m.useSearchParams();return u.useCallback(()=>{r(o.get("redirect")||"/admin",{replace:!0})},[r,o])}const D=t=>{const r=h.useForm(),o=e.useAPIClient(),i=ee(),{refreshAsync:s}=e.useCurrentUserContext();return{run(){return v(this,null,function*(){yield r.submit(),yield o.auth.signIn(r.values,t),yield s(),i()})}}},te={type:"object",name:"passwordForm","x-component":"FormV2",properties:{account:{type:"string","x-component":"Input","x-validator":`{{(value) => { | ||
if (!value) { | ||
@@ -23,2 +23,2 @@ return t("Please enter your username or email"); | ||
} | ||
}}}`,"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 }}"}}},te=t=>{const{t:r}=A(),o=t.authenticator,{authType:i,name:s,options:a}=o,l=!!q()[i]&&(a==null?void 0:a.allowSignUp),ie=`/signup?name=${s}`,ce=()=>D(s);return n.jsx(e.SchemaComponent,{schema:ee,scope:{useBasicSignIn:ce,allowSignUp:l,signUpLink:ie,t:r}})},oe=t=>{const r=m.useNavigate(),o=h.useForm(),i=e.useAPIClient(),{t:s}=x.useTranslation();return{run(){return C(this,null,function*(){var p;yield o.submit(),yield i.auth.signUp(o.values,t==null?void 0:t.authenticator),d.message.success(((p=t==null?void 0:t.message)==null?void 0:p.success)||s("Sign up successfully, and automatically jump to the sign in page")),setTimeout(()=>{r("/signin")},2e3)})}}},ne={type:"object",name:g.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")}}'}}}}},se=({authenticatorName:t})=>{const{t:r}=A(),o=()=>oe({authenticator:t}),i=w(t),{options:s}=i;return s!=null&&s.allowSignUp?n.jsx(e.SchemaComponent,{schema:ne,scope:{useBasicSignUp:o,t:r}}):n.jsx(m.Navigate,{to:"/not-found",replace:!0})},re=()=>{const{t}=A();return n.jsx(e.SchemaComponent,{scope:{t},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.")}}'}}}}})};class f extends e.Plugin{constructor(){super(...arguments);N(this,"authTypes",new E.Registry)}registerType(o,i){this.authTypes.register(o,i)}load(){return C(this,null,function*(){this.app.pluginSettingsManager.add(F,{icon:"LoginOutlined",title:`{{t("Authentication", { ns: "${F}" })}}`,Component:W,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:G,SignInPage:Q,SignUpPage:X}),this.app.providers.unshift([j,{}]),this.registerType(Y,{components:{SignInForm:te,SignUpForm:se,AdminSettingsForm:re}})})}}c.AuthPlugin=f,c.AuthenticatorsContext=S,c.default=f,c.useAuthenticator=w,c.useSignIn=D,Object.defineProperties(c,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); | ||
}}}`,"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 }}"}}},oe=t=>{const{t:r}=A(),o=t.authenticator,{authType:i,name:s,options:a}=o,l=!!q()[i]&&(a==null?void 0:a.allowSignUp),ce=`/signup?name=${s}`,ae=()=>D(s);return n.jsx(e.SchemaComponent,{schema:te,scope:{useBasicSignIn:ae,allowSignUp:l,signUpLink:ce,t:r}})},ne=t=>{const r=m.useNavigate(),o=h.useForm(),i=e.useAPIClient(),{t:s}=x.useTranslation();return{run(){return v(this,null,function*(){var p;yield o.submit(),yield i.auth.signUp(o.values,t==null?void 0:t.authenticator),d.message.success(((p=t==null?void 0:t.message)==null?void 0:p.success)||s("Sign up successfully, and automatically jump to the sign in page")),setTimeout(()=>{r("/signin")},2e3)})}}},se={type:"object",name:g.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")}}'}}}}},re=({authenticatorName:t})=>{const{t:r}=A(),o=()=>ne({authenticator:t}),i=I(t),{options:s}=i;return s!=null&&s.allowSignUp?n.jsx(e.SchemaComponent,{schema:se,scope:{useBasicSignUp:o,t:r}}):n.jsx(m.Navigate,{to:"/not-found",replace:!0})},ie=()=>{const{t}=A();return n.jsx(e.SchemaComponent,{scope:{t},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.")}}'}}}}})};class f extends e.Plugin{constructor(){super(...arguments);$(this,"authTypes",new E.Registry)}registerType(o,i){this.authTypes.register(o,i)}load(){return v(this,null,function*(){this.app.pluginSettingsManager.add(F,{icon:"LoginOutlined",title:`{{t("Authentication", { ns: "${F}" })}}`,Component:W,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:G,SignInPage:Q,SignUpPage:Y}),this.app.providers.unshift([j,{}]),this.registerType(R,{components:{SignInForm:oe,SignUpForm:re,AdminSettingsForm:ie}})})}}c.AuthPlugin=f,c.AuthenticatorsContext=S,c.default=f,c.useAuthenticator=I,c.useSignIn=D,Object.defineProperties(c,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); |
module.exports = { | ||
"@nocobase/client": "0.20.0-alpha.5", | ||
"@nocobase/client": "0.20.0-alpha.6", | ||
"react": "18.2.0", | ||
"react-router-dom": "6.21.0", | ||
"@nocobase/utils": "0.20.0-alpha.5", | ||
"@nocobase/auth": "0.20.0-alpha.5", | ||
"@nocobase/database": "0.20.0-alpha.5", | ||
"@nocobase/server": "0.20.0-alpha.5", | ||
"@nocobase/cache": "0.20.0-alpha.5", | ||
"@nocobase/test": "0.20.0-alpha.5", | ||
"@nocobase/utils": "0.20.0-alpha.6", | ||
"@nocobase/auth": "0.20.0-alpha.6", | ||
"@nocobase/database": "0.20.0-alpha.6", | ||
"@nocobase/server": "0.20.0-alpha.6", | ||
"@nocobase/cache": "0.20.0-alpha.6", | ||
"@nocobase/test": "0.20.0-alpha.6", | ||
"antd": "5.12.8", | ||
@@ -17,3 +17,3 @@ "@formily/react": "2.3.0", | ||
"@ant-design/icons": "5.2.6", | ||
"@nocobase/actions": "0.20.0-alpha.5" | ||
"@nocobase/actions": "0.20.0-alpha.6" | ||
}; |
@@ -1,1 +0,1 @@ | ||
{"name":"cron","description":"Cron jobs for your node","version":"2.4.4","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":"lib/cron","scripts":{"lint":"eslint {lib,tests}/*.js","test":"jest --coverage","test:watch":"jest --watch --coverage","test:types":"tsd","prepare":"husky install","release":"semantic-release"},"types":"types/index.d.ts","dependencies":{"@types/luxon":"~3.3.0","luxon":"~3.3.0"},"devDependencies":{"@commitlint/cli":"~17.6.6","@insurgentlab/commitlint-config":"^18.1.0","@insurgentlab/conventional-changelog-preset":"~6.0.3","@semantic-release/changelog":"~6.0.x","@semantic-release/commit-analyzer":"~9.0.x","@semantic-release/git":"~10.0.x","@semantic-release/github":"~8.1.x","@semantic-release/npm":"~10.0.x","@semantic-release/release-notes-generator":"~11.0.x","chai":"~4.2.x","eslint":"~8.36.x","eslint-config-prettier":"^8.7.x","eslint-config-standard":"~17.0.x","eslint-plugin-import":"~2.27.x","eslint-plugin-jest":"~27.2.x","eslint-plugin-n":"~15.6.x","eslint-plugin-prettier":"~4.2.x","eslint-plugin-promise":"~6.1.x","husky":"^8.0.3","jest":"~29.5.x","prettier":"~2.8.x","semantic-release":"~21.0.x","sinon":"^15.0.x","tsd":"^0.28.1"},"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)","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)"],"jest":{"collectCoverage":true,"collectCoverageFrom":["lib/*.js"],"coverageThreshold":{"global":{"statements":80,"branches":80,"functions":70,"lines":80}}},"files":["lib","types","CHANGELOG.md","LICENSE","README.md"],"_lastModified":"2024-03-05T16:27:00.753Z"} | ||
{"name":"cron","description":"Cron jobs for your node","version":"2.4.4","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":"lib/cron","scripts":{"lint":"eslint {lib,tests}/*.js","test":"jest --coverage","test:watch":"jest --watch --coverage","test:types":"tsd","prepare":"husky install","release":"semantic-release"},"types":"types/index.d.ts","dependencies":{"@types/luxon":"~3.3.0","luxon":"~3.3.0"},"devDependencies":{"@commitlint/cli":"~17.6.6","@insurgentlab/commitlint-config":"^18.1.0","@insurgentlab/conventional-changelog-preset":"~6.0.3","@semantic-release/changelog":"~6.0.x","@semantic-release/commit-analyzer":"~9.0.x","@semantic-release/git":"~10.0.x","@semantic-release/github":"~8.1.x","@semantic-release/npm":"~10.0.x","@semantic-release/release-notes-generator":"~11.0.x","chai":"~4.2.x","eslint":"~8.36.x","eslint-config-prettier":"^8.7.x","eslint-config-standard":"~17.0.x","eslint-plugin-import":"~2.27.x","eslint-plugin-jest":"~27.2.x","eslint-plugin-n":"~15.6.x","eslint-plugin-prettier":"~4.2.x","eslint-plugin-promise":"~6.1.x","husky":"^8.0.3","jest":"~29.5.x","prettier":"~2.8.x","semantic-release":"~21.0.x","sinon":"^15.0.x","tsd":"^0.28.1"},"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)","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)"],"jest":{"collectCoverage":true,"collectCoverageFrom":["lib/*.js"],"coverageThreshold":{"global":{"statements":80,"branches":80,"functions":70,"lines":80}}},"files":["lib","types","CHANGELOG.md","LICENSE","README.md"],"_lastModified":"2024-03-08T02:29:49.379Z"} |
{ | ||
"name": "@nocobase/plugin-auth", | ||
"version": "0.20.0-alpha.5", | ||
"version": "0.20.0-alpha.6", | ||
"main": "./dist/server/index.js", | ||
@@ -29,3 +29,3 @@ "homepage": "https://docs.nocobase.com/handbook/auth", | ||
"description.zh-CN": "用户认证管理,包括基础的密码认证、短信认证、SSO 协议的认证等,可扩展。", | ||
"gitHead": "b72d7fdf357a6bc4460ff181644b9014d3dad13b", | ||
"gitHead": "281767b02ce11f9172fb72e5e53ff98bc80b6eaf", | ||
"keywords": [ | ||
@@ -32,0 +32,0 @@ "Authentication" |
1887628