@nocobase/plugin-auth 2.3.0-alpha.1 → 3.0.0-alpha.2

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.
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ "use strict";(self.webpackChunk_nocobase_plugin_auth_client_v2=self.webpackChunk_nocobase_plugin_auth_client_v2||[]).push([["217"],{264:function(e,t,n){n.r(t),n.d(t,{default:function(){return g}});var r=n(485),a=n(694),l=n(6),i=n(59),o=n(155),u=n.n(o),s=n(442),c=n(488);function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function f(e,t,n,r,a,l,i){try{var o=e[l](i),u=o.value}catch(e){n(e);return}o.done?t(u):Promise.resolve(u).then(r,a)}function d(e,t){if(e){if("string"==typeof e)return m(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return m(e,t)}}var p=["$env"];function h(e){var t,n=(0,c.dE)().t,s=(0,c.kj)(),f=(t=(0,a.useFlowContext)(),(0,o.useMemo)(function(){var e,n,r,a,l=null==(r=t.dataSourceManager)||null==(n=r.getCollection)?void 0:n.call(r,"main","users");return(null!=(e=null==l||null==(a=l.getFields)?void 0:a.call(l))?e:[]).filter(function(e){var t,n;return e&&!(null==(t=e.options)?void 0:t.hidden)&&!e.target&&e.interface&&!(null==(n=e.uiSchema)?void 0:n["x-read-pretty"])})},[t])),p=(0,o.useMemo)(function(){var t;return null!=(t=e.value)?t:[]},[e.value]),h=(0,o.useMemo)(function(){var e=new Set(f.map(function(e){return e.name})),t=p.filter(function(t){return e.has(t.field)}),n=new Set(t.map(function(e){return e.field})),r=!0,a=!1,l=void 0;try{for(var i,o=f[Symbol.iterator]();!(r=(i=o.next()).done);r=!0){var u=i.value;n.has(u.name)||t.push({field:u.name,show:"username"===u.name,required:"username"===u.name})}}catch(e){a=!0,l=e}finally{try{r||null==o.return||o.return()}finally{if(a)throw l}}return t},[f,p]);u().useEffect(function(){var t;p.length===h.length&&p.every(function(e,t){return e.field===h[t].field&&!!e.show==!!h[t].show&&!!e.required==!!h[t].required})||null==(t=e.onChange)||t.call(e,h)},[h]);var y=(0,l.useMemoizedFn)(function(t,n){var r,a=h.map(function(e){if(e.field!==t)return e;var r=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},e,n);return r.required&&(r.show=!0),r.show||(r.required=!1),r});null==(r=e.onChange)||r.call(e,a)}),b=(0,l.useMemoizedFn)(function(e){var t,n,r=f.find(function(t){return t.name===e});return s((null==r||null==(t=r.uiSchema)?void 0:t.title)||(null==r||null==(n=r.options)?void 0:n.title)||e)}),g=(0,o.useMemo)(function(){return[{title:n("Field"),dataIndex:"field",width:200,render:function(e){return u().createElement(i.Tag,null,b(e))}},{title:n("Show"),dataIndex:"show",width:80,align:"center",render:function(e,t){return u().createElement(i.Checkbox,{checked:!!t.show,onChange:function(e){return y(t.field,{show:e.target.checked})}})}},{title:n("Required"),dataIndex:"required",width:80,align:"center",render:function(e,t){return u().createElement(i.Checkbox,{checked:!!t.required,onChange:function(e){return y(t.field,{required:e.target.checked})}})}},{title:"",dataIndex:"_filler",render:function(){return null}}]},[b,n,y]),v=(0,l.useMemoizedFn)(function(t,n){var r,a=h.findIndex(function(e){return e.field===t.field}),l=h.findIndex(function(e){return e.field===n.field});if(!(a<0)&&!(l<0)&&a!==l){var i,o=function(e){if(Array.isArray(e))return m(e)}(h)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(h)||d(h)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),u=(function(e){if(Array.isArray(e))return e}(i=o.splice(a,1))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var a=[],l=!0,i=!1;try{for(r=r.call(e);!(l=(t=r.next()).done)&&(a.push(t.value),1!==a.length);l=!0);}catch(e){i=!0,n=e}finally{try{l||null==r.return||r.return()}finally{if(i)throw n}}return a}}(i)||d(i,1)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0];o.splice(l,0,u),null==(r=e.onChange)||r.call(e,o)}});return u().createElement(r.Table,{rowKey:"field",pagination:!1,columns:g,dataSource:h,isDraggable:!0,onSortEnd:v,sortHandleColumnWidth:32,showIndex:!1})}function y(){var e=(0,c.dE)().t;return u().createElement(u().Fragment,null,u().createElement(i.Form.Item,{name:["options","public","allowSignUp"],label:e("Allow to sign up"),valuePropName:"checked",initialValue:!0},u().createElement(i.Checkbox,null)),u().createElement(i.Form.Item,{label:e("Sign up form"),name:["options","public","signupForm"],validateFirst:!0},u().createElement(h,null)))}function b(){var e,t,n,m=(0,c.dE)().t,d=(0,a.useFlowContext)(),h=i.Form.useFormInstance(),y=i.Form.useWatch(["options","public","enableResetPassword"],h),b=i.Form.useWatch(["options","emailContentType"],h)||"html",g=(e=(0,c.dE)().t,(0,o.useMemo)(function(){return[{name:"$user",title:e("Current user"),type:"object",paths:["$user"],children:[{name:"username",title:e("Username"),type:"string",paths:["$user","username"]},{name:"nickname",title:e("Nickname"),type:"string",paths:["$user","nickname"]},{name:"email",title:e("Email"),type:"string",paths:["$user","email"]}]},{name:"$systemSettings",title:e("System settings"),type:"object",paths:["$systemSettings"],children:[{name:"title",title:e("System title"),type:"string",paths:["$systemSettings","title"]},{name:"logo",title:e("System logo"),type:"string",paths:["$systemSettings","logo"]}]},{name:"$resetLink",title:e("Reset password link"),type:"string",paths:["$resetLink"]},{name:"$resetLinkExpiration",title:e("Reset link expiration (minutes)"),type:"string",paths:["$resetLinkExpiration"]}]},[e])),v=(t=!!y,n=(0,a.useFlowContext)(),(0,l.useRequest)(function(){var e;return(e=function(){var e,t,r,a;return function(e,t){var n,r,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),o=Object.defineProperty;return o(i,"next",{value:u(0)}),o(i,"throw",{value:u(1)}),o(i,"return",{value:u(2)}),"function"==typeof Symbol&&o(i,Symbol.iterator,{value:function(){return this}}),i;function u(o){return function(u){var s=[o,u];if(n)throw TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(l=0)),l;)try{if(n=1,r&&(a=2&s[0]?r.return:s[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,s[1])).done)return a;switch(r=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return l.label++,{value:s[1],done:!1};case 5:l.label++,r=s[1],s=[0];continue;case 7:s=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===s[0]||2===s[0])){l=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){l.label=s[1];break}if(6===s[0]&&l.label<a[1]){l.label=a[1],a=s;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(s);break}a[2]&&l.ops.pop(),l.trys.pop();continue}s=t.call(e,l)}catch(e){s=[6,e],r=0}finally{n=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}}(this,function(l){switch(l.label){case 0:return[4,n.api.resource("notificationChannels").list({filter:{notificationType:"email"},pageSize:50})];case 1:return[2,Array.isArray(a=null!=(e=null==(r=l.sent())||null==(t=r.data)?void 0:t.data)?e:null==r?void 0:r.data)?a:[]]}})},function(){var t=this,n=arguments;return new Promise(function(r,a){var l=e.apply(t,n);function i(e){f(l,r,a,i,o,"next",e)}function o(e){f(l,r,a,i,o,"throw",e)}i(void 0)})})()},{ready:t,cacheKey:"@nocobase/plugin-auth:notificationChannels:email",refreshDeps:[t]})),w=v.data,E=v.loading,S=(0,o.useMemo)(function(){return(w||[]).map(function(e){return{label:e.title,value:e.name}})},[w]);return u().createElement(u().Fragment,null,u().createElement(i.Form.Item,{name:["options","public","enableResetPassword"],label:m("Enable forget password"),valuePropName:"checked",initialValue:!1},u().createElement(i.Checkbox,null)),y?u().createElement(u().Fragment,null,u().createElement(i.Typography.Title,{level:5,style:{marginTop:0}},m("1. Select notification channel")),u().createElement(i.Form.Item,{name:["options","notificationChannel"],label:m("Notification channel (Email)"),extra:m("The notification channel used to send the reset password email, only support email channel"),rules:[{required:!0,message:m("Please select a notification channel")}]},u().createElement(i.Select,{loading:E,options:S,placeholder:m("Select"),notFoundContent:u().createElement("span",null,m("No notification channels found. Please "),u().createElement(s.Link,{to:d.app.pluginSettingsManager.getRoutePath("notification-manager.channels")},m("add one first")),".")})),u().createElement(i.Typography.Title,{level:5},m("2. Configure reset email")),u().createElement(i.Form.Item,{name:["options","emailSubject"],label:m("Subject"),rules:[{required:!0,message:m("Please enter the email subject")}],initialValue:m("defaultResetPasswordEmailSubject")},u().createElement(r.VariableInput,{namespaces:p,extraNodes:g})),u().createElement(i.Form.Item,{name:["options","emailContentType"],label:m("Content type"),initialValue:"html",rules:[{required:!0}]},u().createElement(i.Radio.Group,{options:[{label:"HTML",value:"html"},{label:m("Plain text"),value:"text"}]})),"html"===b?u().createElement(i.Form.Item,{key:"html",name:["options","emailContentHTML"],label:m("Content"),rules:[{required:!0,message:m("Please enter the email content")}],initialValue:m("defaultResetPasswordEmailContentHTML")},u().createElement(r.VariableTextArea,{namespaces:p,extraNodes:g,placeholder:"Hi,",rows:10})):u().createElement(i.Form.Item,{key:"text",name:["options","emailContentText"],label:m("Content"),rules:[{required:!0,message:m("Please enter the email content")}],initialValue:m("defaultResetPasswordEmailContentText")},u().createElement(r.VariableTextArea,{namespaces:p,extraNodes:g,rows:10})),u().createElement(i.Form.Item,{name:["options","resetTokenExpiresIn"],label:m("Reset link expiration"),initialValue:120,rules:[{required:!0,message:m("Please enter the expiration in minutes")}]},u().createElement(i.InputNumber,{min:1,addonAfter:m("Minutes"),style:{width:"100%"}}))):null)}function g(){var e=(0,c.dE)().t;return u().createElement("div",null,u().createElement(i.Alert,{style:{marginBottom:16},type:"info",showIcon:!0,message:e("The authentication allows users to sign in via username or email.")}),u().createElement(i.Tabs,{items:[{key:"signup",label:e("Sign up settings"),forceRender:!0,children:u().createElement(y,null)},{key:"forgot",label:e("Forgot password"),forceRender:!0,children:u().createElement(b,null)}]}))}}}]);
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ "use strict";(self.webpackChunk_nocobase_plugin_auth_client_v2=self.webpackChunk_nocobase_plugin_auth_client_v2||[]).push([["795"],{918:function(e,t,r){r.r(t),r.d(t,{default:function(){return y}});var n=r(59),a=r(485),o=r(155),l=r.n(o),u=r(442),s=r(488),i=r(824),c=r(927);function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function f(e,t,r,n,a,o,l){try{var u=e[o](l),s=u.value}catch(e){r(e);return}u.done?t(s):Promise.resolve(s).then(n,a)}function p(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var o=[],l=!0,u=!1;try{for(a=a.call(e);!(l=(r=a.next()).done)&&(o.push(r.value),!t||o.length!==t);l=!0);}catch(e){u=!0,n=e}finally{try{l||null==a.return||a.return()}finally{if(u)throw n}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return m(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return m(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function y(e){var t,r,m=e.authenticator,y=(0,a.useApp)(),d=(0,s.dE)().t,v=p(n.Form.useForm(),1)[0],h=p((0,o.useState)(""),2),b=h[0],g=h[1],w=p((0,o.useState)(!1),2),E=w[0],P=w[1],S=(0,i.go)(m.name),k=!!(null==m||null==(t=m.options)?void 0:t.allowSignUp),I=!!(null==m||null==(r=m.options)?void 0:r.enableResetPassword),_=(0,c.f1)(y,"auth.signup"),j=(0,c.f1)(y,"auth.forgotPassword");return l().createElement(n.Form,{form:v,layout:"vertical",onFinish:function(e){var t;return(t=function(){var t,r,n,a,o;return function(e,t){var r,n,a,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(l,"next",{value:s(0)}),u(l,"throw",{value:s(1)}),u(l,"return",{value:s(2)}),"function"==typeof Symbol&&u(l,Symbol.iterator,{value:function(){return this}}),l;function s(u){return function(s){var i=[u,s];if(r)throw TypeError("Generator is already executing.");for(;l&&(l=0,i[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&i[0]?n.return:i[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,i[1])).done)return a;switch(n=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,n=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!(a=(a=o.trys).length>0&&a[a.length-1])&&(6===i[0]||2===i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]<a[3])){o.label=i[1];break}if(6===i[0]&&o.label<a[1]){o.label=a[1],a=i;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(i);break}a[2]&&o.ops.pop(),o.trys.pop();continue}i=t.call(e,o)}catch(e){i=[6,e],n=0}finally{r=a=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}}(this,function(l){switch(l.label){case 0:g(""),P(!0),l.label=1;case 1:return l.trys.push([1,3,4,5]),[4,S.run(e)];case 2:return l.sent(),[3,5];case 3:return g((null==(t=l.sent())||null==(o=t.response)||null==(a=o.data)||null==(n=a.errors)||null==(r=n[0])?void 0:r.message)||(null==t?void 0:t.message)||String(t)),[3,5];case 4:return P(!1),[7];case 5:return[2]}})},function(){var e=this,r=arguments;return new Promise(function(n,a){var o=t.apply(e,r);function l(e){f(o,n,a,l,u,"next",e)}function u(e){f(o,n,a,l,u,"throw",e)}l(void 0)})})()}},b?l().createElement(n.Alert,{style:{marginBottom:16},type:"error",showIcon:!0,message:b}):null,l().createElement(n.Form.Item,{name:"account",rules:[{required:!0,message:d("Please enter your username or email")},{validator:function(e,t){return t?String(t).includes("@")?/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(String(t))?Promise.resolve():Promise.reject(Error(d("Please enter a valid email"))):/^[^@<>"'/]{1,50}$/.test(String(t))?Promise.resolve():Promise.reject(Error(d("Please enter a valid username"))):Promise.resolve()}}]},l().createElement(n.Input,{autoComplete:"username",placeholder:d("Username/Email")})),l().createElement(n.Form.Item,{name:"password",rules:[{required:!0,message:d("Please enter a password")}]},l().createElement(n.Input.Password,{autoComplete:"current-password",placeholder:d("Password")})),l().createElement(n.Form.Item,{style:{marginBottom:12}},l().createElement(n.Button,{loading:E,htmlType:"submit",type:"primary",block:!0},d("Sign in"))),l().createElement("div",{style:{display:"flex",justifyContent:"space-between",gap:12}},k?l().createElement(u.Link,{to:"".concat(_,"?name=").concat(m.name)},d("Create an account")):null,I?l().createElement(u.Link,{to:"".concat(j,"?name=").concat(m.name)},d("Forgot password")):null))}}}]);
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ "use strict";(self.webpackChunk_nocobase_plugin_auth_client_v2=self.webpackChunk_nocobase_plugin_auth_client_v2||[]).push([["841"],{720:function(e,t,r){r.r(t),r.d(t,{default:function(){return v}});var n=r(59),a=r(155),l=r.n(a),o=r(442),u=r(230),i=r(953),s=r(485),c=r(488),m=r(295),p=r(927);function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function d(e,t,r,n,a,l,o){try{var u=e[l](o),i=u.value}catch(e){r(e);return}u.done?t(i):Promise.resolve(i).then(n,a)}function h(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,u=!1;try{for(a=a.call(e);!(o=(r=a.next()).done)&&(l.push(r.value),!t||l.length!==t);o=!0);}catch(e){u=!0,n=e}finally{try{o||null==a.return||a.return()}finally{if(u)throw n}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return f(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return f(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e){var t,r=e.authenticatorName,f=(0,s.useApp)(),v=(0,o.useNavigate)(),y=(0,c.dE)().t,b=(0,i.useTranslation)("lm-collections").t,g=(0,m.p)(r),w=h(n.Form.useForm(),1)[0],E=h((0,a.useState)(!1),2),S=E[0],k=E[1],I=h((0,a.useState)(""),2),x=I[0],P=I[1],A=(0,p.f1)(f,"auth.signin"),_=(0,a.useMemo)(function(){var e;return((null==g||null==(e=g.options)?void 0:e.signupForm)||[]).filter(function(e){return null==e?void 0:e.show})},[g]);return(null==g||null==(t=g.options)?void 0:t.allowSignUp)?l().createElement(n.Form,{form:w,layout:"vertical",onFinish:function(e){var t;return(t=function(){var t,a,l,o,u;return function(e,t){var r,n,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(o,"next",{value:i(0)}),u(o,"throw",{value:i(1)}),u(o,"return",{value:i(2)}),"function"==typeof Symbol&&u(o,Symbol.iterator,{value:function(){return this}}),o;function i(u){return function(i){var s=[u,i];if(r)throw TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(l=0)),l;)try{if(r=1,n&&(a=2&s[0]?n.return:s[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,s[1])).done)return a;switch(n=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return l.label++,{value:s[1],done:!1};case 5:l.label++,n=s[1],s=[0];continue;case 7:s=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===s[0]||2===s[0])){l=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){l.label=s[1];break}if(6===s[0]&&l.label<a[1]){l.label=a[1],a=s;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(s);break}a[2]&&l.ops.pop(),l.trys.pop();continue}s=t.call(e,l)}catch(e){s=[6,e],n=0}finally{r=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}}(this,function(i){switch(i.label){case 0:P(""),k(!0),i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,f.apiClient.auth.signUp(e,r)];case 2:return i.sent(),n.message.success(y("Sign up successfully, and automatically jump to the sign in page")),window.setTimeout(function(){v(A,{replace:!0})},2e3),[3,5];case 3:return P((null==(t=i.sent())||null==(u=t.response)||null==(o=u.data)||null==(l=o.errors)||null==(a=l[0])?void 0:a.message)||(null==t?void 0:t.message)||String(t)),[3,5];case 4:return k(!1),[7];case 5:return[2]}})},function(){var e=this,r=arguments;return new Promise(function(n,a){var l=t.apply(e,r);function o(e){d(l,n,a,o,u,"next",e)}function u(e){d(l,n,a,o,u,"throw",e)}o(void 0)})})()}},x?l().createElement(n.Alert,{style:{marginBottom:16},type:"error",showIcon:!0,message:x}):null,_.map(function(e){var t,r,a,o,i,s;return a=(r=(null==e?void 0:e.uiSchema)||{})["x-component"],o=r.title?b(u.Schema.compile(r.title,{t:y})):e.field,i=[],e.required&&i.push({required:!0,message:y("Please enter ".concat(e.field))}),"email"===e.field&&i.push({type:"email",message:y("Please enter a valid email address")}),s=l().createElement(n.Input,null),(null==(t=r.enum)?void 0:t.length)?s=l().createElement(n.Select,{options:r.enum.map(function(e){return{label:e.label||e.value,value:e.value}})}):"Checkbox"===a?s=l().createElement(n.Checkbox,null):("Input.TextArea"===a||"TextArea"===a)&&(s=l().createElement(n.Input.TextArea,{rows:4})),l().createElement(n.Form.Item,{key:e.field,name:e.field,label:o,valuePropName:"Checkbox"===a?"checked":"value",rules:i},s)}),l().createElement(n.Form.Item,{label:y("Password"),name:"password",rules:[{required:!0,message:y("Please enter a password")}]},l().createElement(n.Input.Password,{autoComplete:"new-password"})),l().createElement(n.Form.Item,{label:y("Confirm password"),name:"confirm_password",dependencies:["password"],rules:[{required:!0,message:y("Please enter the same password again")},function(e){var t=e.getFieldValue;return{validator:function(e,r){return r&&t("password")!==r?Promise.reject(Error(y("The passwords entered twice are inconsistent"))):Promise.resolve()}}}]},l().createElement(n.Input.Password,{autoComplete:"new-password"})),l().createElement(n.Form.Item,{style:{marginBottom:12}},l().createElement(n.Button,{loading:S,htmlType:"submit",type:"primary",block:!0},y("Sign up"))),l().createElement(o.Link,{to:A},y("Log in with an existing account"))):l().createElement(o.Navigate,{to:"/not-found",replace:!0})}}}]);
@@ -0,0 +1,26 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ type AuthRouteName = 'auth.signin' | 'auth.signup' | 'auth.forgotPassword' | 'auth.resetPassword';
10
+ type PluginSettingsRouteApplication = {
11
+ pluginSettingsManager: {
12
+ getRouteName: (name: string) => string;
13
+ getRoutePath: (name: string) => string;
14
+ };
15
+ };
16
+ type AuthRouteApplication = PluginSettingsRouteApplication & {
17
+ router: {
18
+ get: (name: string) => {
19
+ path?: string;
20
+ } | undefined;
21
+ };
22
+ };
23
+ export declare function getAuthRoutePath(app: AuthRouteApplication, name: AuthRouteName): string;
24
+ export declare function isStandaloneSettingsApplication(app: PluginSettingsRouteApplication): boolean;
25
+ export declare function getDefaultAuthRedirectPath(app: PluginSettingsRouteApplication): string;
26
+ export {};
@@ -7,4 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react-i18next"),require("react-router-dom"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("ahooks"),require("@nocobase/client-v2"),require("react"),require("antd"),require("@nocobase/utils/client"),require("lodash")):"function"==typeof define&&define.amd?define("@nocobase/plugin-auth/client-v2",["react-i18next","react-router-dom","@formily/react","@ant-design/icons","@nocobase/flow-engine","ahooks","@nocobase/client-v2","react","antd","@nocobase/utils/client","lodash"],t):"object"==typeof exports?exports["@nocobase/plugin-auth/client-v2"]=t(require("react-i18next"),require("react-router-dom"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("ahooks"),require("@nocobase/client-v2"),require("react"),require("antd"),require("@nocobase/utils/client"),require("lodash")):e["@nocobase/plugin-auth/client-v2"]=t(e["react-i18next"],e["react-router-dom"],e["@formily/react"],e["@ant-design/icons"],e["@nocobase/flow-engine"],e.ahooks,e["@nocobase/client-v2"],e.react,e.antd,e["@nocobase/utils/client"],e.lodash)}(self,function(e,t,n,r,o,i,a,u,l,c,s){return function(){var f,p,d,h={432:function(e,t,n){e.exports=n(36).Symbol},77:function(e,t,n){var r=n(432),o=n(444),i=n(371),a=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":a&&a in Object(e)?o(e):i(e)}},625:function(e,t,n){var r=n(531),o=/^\s+/;e.exports=function(e){return e?e.slice(0,r(e)+1).replace(o,""):e}},565:function(e,t,n){e.exports="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g},444:function(e,t,n){var r=n(432),o=Object.prototype,i=o.hasOwnProperty,a=o.toString,u=r?r.toStringTag:void 0;e.exports=function(e){var t=i.call(e,u),n=e[u];try{e[u]=void 0;var r=!0}catch(e){}var o=a.call(e);return r&&(t?e[u]=n:delete e[u]),o}},371:function(e){var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},36:function(e,t,n){var r=n(565),o="object"==typeof self&&self&&self.Object===Object&&self;e.exports=r||o||Function("return this")()},531:function(e){var t=/\s/;e.exports=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n}},738:function(e,t,n){var r=n(130),o=n(593),i=n(909),a=Math.max,u=Math.min;e.exports=function(e,t,n){var l,c,s,f,p,d,h=0,m=!1,y=!1,v=!0;if("function"!=typeof e)throw TypeError("Expected a function");function b(t){var n=l,r=c;return l=c=void 0,h=t,f=e.apply(r,n)}function g(e){var n=e-d,r=e-h;return void 0===d||n>=t||n<0||y&&r>=s}function w(){var e,n,r,i=o();if(g(i))return E(i);p=setTimeout(w,(e=i-d,n=i-h,r=t-e,y?u(r,s-n):r))}function E(e){return(p=void 0,v&&l)?b(e):(l=c=void 0,f)}function S(){var e,n=o(),r=g(n);if(l=arguments,c=this,d=n,r){if(void 0===p)return h=e=d,p=setTimeout(w,t),m?b(e):f;if(y)return clearTimeout(p),p=setTimeout(w,t),b(d)}return void 0===p&&(p=setTimeout(w,t)),f}return t=i(t)||0,r(n)&&(m=!!n.leading,s=(y="maxWait"in n)?a(i(n.maxWait)||0,t):s,v="trailing"in n?!!n.trailing:v),S.cancel=function(){void 0!==p&&clearTimeout(p),h=0,l=d=c=p=void 0},S.flush=function(){return void 0===p?f:E(o())},S}},130:function(e){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},189:function(e){e.exports=function(e){return null!=e&&"object"==typeof e}},733:function(e,t,n){var r=n(77),o=n(189);e.exports=function(e){return"symbol"==typeof e||o(e)&&"[object Symbol]"==r(e)}},593:function(e,t,n){var r=n(36);e.exports=function(){return r.Date.now()}},909:function(e,t,n){var r=n(625),o=n(130),i=n(733),a=0/0,u=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,c=/^0o[0-7]+$/i,s=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(i(e))return a;if(o(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=o(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=r(e);var n=l.test(e);return n||c.test(e)?s(e.slice(2),n?2:8):u.test(e)?a:+e}},829:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return s}});var r=n(59),o=n(155),i=n.n(o),a=n(442),u=n(953),l=n(485),c=n(89);function s(){var e,t=r.theme.useToken().token,n=((0,l.useSystemSettings)()||{}).data,o=(0,u.useTranslation)("lm-collections").t;return i().createElement("div",{style:{maxWidth:320,margin:"0 auto",paddingTop:"20vh",paddingBottom:"20vh"}},i().createElement("div",{style:{position:"fixed",top:t.paddingLG,right:t.paddingLG,color:t.colorText}},i().createElement(l.SwitchLanguage,null)),i().createElement("h1",{style:{textAlign:"center"}},o(null==n||null==(e=n.data)?void 0:e.title)),i().createElement(c.A,null,i().createElement(a.Outlet,null)),i().createElement("div",{style:{position:"absolute",bottom:0,left:0,width:"100%",paddingBottom:t.paddingLG,textAlign:"center",backgroundColor:t.colorBgContainer}},i().createElement(l.PoweredBy,null)))}},826:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return h}});var r=n(59),o=n(155),i=n.n(o),a=n(442),u=n(485),l=n(295),c=n(488),s=n(824);function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function p(e,t,n,r,o,i,a){try{var u=e[i](a),l=u.value}catch(e){n(e);return}u.done?t(l):Promise.resolve(l).then(r,o)}function d(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,u=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){u=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(u)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return f(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return f(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(){var e,t=(0,u.useApp)(),n=(0,c.dE)().t,f=d((0,a.useSearchParams)(),1)[0].get("name"),h=(0,l.p)(f),m=d(r.Form.useForm(),1)[0],y=d((0,o.useState)(!1),2),v=y[0],b=y[1],g=d((0,o.useState)(""),2),w=g[0],E=g[1];return((0,s.rN)(n("Reset password")),null==h||null==(e=h.options)?void 0:e.enableResetPassword)?i().createElement(r.Form,{form:m,layout:"vertical",onFinish:function(e){var o;return(o=function(){var o,i,a,u,l;return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:l(0)}),u(a,"throw",{value:l(1)}),u(a,"return",{value:l(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function l(u){return function(l){var c=[u,l];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(c){switch(c.label){case 0:E(""),b(!0),c.label=1;case 1:return c.trys.push([1,3,4,5]),[4,t.apiClient.auth.lostPassword(e)];case 2:return c.sent(),r.message.success(n("Reset email sent successfully")),m.resetFields(),[3,5];case 3:return E((null==(o=c.sent())||null==(l=o.response)||null==(u=l.data)||null==(a=u.errors)||null==(i=a[0])?void 0:i.message)||(null==o?void 0:o.message)||String(o)),[3,5];case 4:return b(!1),[7];case 5:return[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var i=o.apply(e,t);function a(e){p(i,n,r,a,u,"next",e)}function u(e){p(i,n,r,a,u,"throw",e)}a(void 0)})})()}},w?i().createElement(r.Alert,{style:{marginBottom:16},type:"error",showIcon:!0,message:w}):null,i().createElement(r.Form.Item,{label:n("Reset password"),name:"email",rules:[{required:!0,message:n("Please fill in your email address")},{type:"email",message:n("Please enter a valid email")}]},i().createElement(r.Input,{placeholder:n("Please enter your email")})),i().createElement(r.Form.Item,{style:{marginBottom:12}},i().createElement(r.Button,{loading:v,htmlType:"submit",type:"primary",block:!0},n("Send reset email"))),i().createElement(a.Link,{to:"/signin"},n("Back to login"))):i().createElement(a.Navigate,{to:"/signin",replace:!0})}},622:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return h}});var r=n(59),o=n(155),i=n.n(o),a=n(442),u=n(485),l=n(295),c=n(488),s=n(824);function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function p(e,t,n,r,o,i,a){try{var u=e[i](a),l=u.value}catch(e){n(e);return}u.done?t(l):Promise.resolve(l).then(r,o)}function d(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,u=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){u=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(u)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return f(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return f(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(){var e,t=(0,u.useApp)(),n=(0,c.dE)().t,f=(0,a.useNavigate)(),h=d((0,a.useSearchParams)(),1)[0],m=h.get("resetToken"),y=h.get("name"),v=(0,l.p)(y),b=d(r.Form.useForm(),1)[0],g=d((0,o.useState)(!1),2),w=g[0],E=g[1],S=d((0,o.useState)(!0),2),O=S[0],P=S[1],k=d((0,o.useState)(!1),2),A=k[0],x=k[1],T=d((0,o.useState)(""),2),j=T[0],_=T[1];return((0,s.rN)(n("Reset password")),(0,o.useEffect)(function(){var e=!0;if(!m){E(!0),P(!1);return}return t.apiClient.auth.checkResetToken({resetToken:m}).then(function(){e&&(E(!1),P(!1))}).catch(function(){e&&(E(!0),P(!1))}),function(){e=!1}},[t,m]),null==v||null==(e=v.options)?void 0:e.enableResetPassword)?O||m&&!w?i().createElement(r.Form,{form:b,layout:"vertical",onFinish:function(e){var o;return(o=function(){var o,i,a,u,l;return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:l(0)}),u(a,"throw",{value:l(1)}),u(a,"return",{value:l(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function l(u){return function(l){var c=[u,l];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(c){switch(c.label){case 0:_(""),x(!0),c.label=1;case 1:var s,p;return c.trys.push([1,3,4,5]),[4,t.apiClient.auth.resetPassword((s=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},e),p=p={resetToken:m},Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(p)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(p)).forEach(function(e){Object.defineProperty(s,e,Object.getOwnPropertyDescriptor(p,e))}),s))];case 2:return c.sent(),r.message.success(n("Password reset successful")),window.setTimeout(function(){f("/signin",{replace:!0})},1e3),[3,5];case 3:return _((null==(o=c.sent())||null==(l=o.response)||null==(u=l.data)||null==(a=u.errors)||null==(i=a[0])?void 0:i.message)||(null==o?void 0:o.message)||String(o)),[3,5];case 4:return x(!1),[7];case 5:return[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var i=o.apply(e,t);function a(e){p(i,n,r,a,u,"next",e)}function u(e){p(i,n,r,a,u,"throw",e)}a(void 0)})})()}},j?i().createElement(r.Alert,{style:{marginBottom:16},type:"error",showIcon:!0,message:j}):null,i().createElement(r.Form.Item,{label:n("New password"),name:"password",rules:[{required:!0,message:n("Please enter new password")}]},i().createElement(r.Input.Password,{autoComplete:"new-password"})),i().createElement(r.Form.Item,{label:n("Confirm password"),name:"confirmPassword",dependencies:["password"],rules:[{required:!0,message:n("Please enter the same password again")},function(e){var t=e.getFieldValue;return{validator:function(e,r){return r&&t("password")!==r?Promise.reject(Error(n("The passwords entered twice are inconsistent"))):Promise.resolve()}}}]},i().createElement(r.Input.Password,{autoComplete:"new-password"})),i().createElement(r.Form.Item,{style:{marginBottom:12}},i().createElement(r.Button,{loading:A||O,htmlType:"submit",type:"primary",block:!0},n("Confirm"))),i().createElement(a.Link,{to:"/signin"},n("Go to login"))):i().createElement(r.Result,{status:"403",title:n("Reset link has expired"),extra:i().createElement(r.Button,{type:"primary",onClick:function(){return f("/signin")}},n("Go to login"))}):i().createElement(a.Navigate,{to:"/signin",replace:!0})}},818:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return m}});var r=n(485),o=n(59),i=n(155),a=n.n(i),u=n(442),l=n(295),c=n(824),s=n(488),f=n(434);function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function d(e){var t=(0,r.usePlugin)(f.A);return(0,i.useMemo)(function(){var n={},r=!0,o=!1,i=void 0;try{for(var a,u=t.authTypes.getEntities()[Symbol.iterator]();!(r=(a=u.next()).done);r=!0){var l,c=(l=a.value,function(e){if(Array.isArray(e))return e}(l)||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(l)||function(e){if(e){if("string"==typeof e)return p(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return p(e,2)}}(l)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),s=c[0],f=c[1][e];f&&(n[s]=f)}}catch(e){o=!0,i=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw i}}return n},[t,e])}function h(e){var t=new Map;return function(n){if(e[n])return t.has(n)||t.set(n,(0,i.lazy)(e[n])),t.get(n)}}function m(){var e=(0,r.useApp)(),t=(0,u.useLocation)(),n=(0,u.useNavigate)(),f=(0,s.dE)().t,p=(0,s.kj)(),m=(0,i.useContext)(l.m),y=d("signInFormLoader"),v=d("signInButtonLoader"),b=(0,i.useMemo)(function(){return h(y)},[y]),g=(0,i.useMemo)(function(){return h(v)},[v]);(0,c.rN)(f("Signin")),(0,i.useEffect)(function(){var o=new URLSearchParams(t.search),i=o.get("redirect"),a=(0,r.normalizeV2RedirectPath)(e,i);i!==a&&(o.set("redirect",a),n({pathname:t.pathname,search:"?".concat(o)},{replace:!0}))},[e,t.pathname,t.search,n]);var w=(0,i.useMemo)(function(){return m.map(function(e){var t=b(e.authType);if(!t)return null;var n=p(e.authTypeTitle||e.authType);return{key:e.name,label:e.title||"".concat(f("Sign-in")," (").concat(n,")"),children:a().createElement(i.Suspense,{fallback:a().createElement(o.Spin,null)},a().createElement(t,{authenticator:e}))}}).filter(Boolean)},[m,b,f,p]),E=(0,i.useMemo)(function(){return m.map(function(e,t){var n=g(e.authType);return n?a().createElement(i.Suspense,{key:"".concat(e.name,"-").concat(t),fallback:a().createElement(o.Spin,null)},a().createElement(n,{authenticator:e})):null}).filter(Boolean)},[m,g]);return m.length?a().createElement(o.Space,{direction:"vertical",style:{display:"flex"}},w.length>1?a().createElement(o.Tabs,{items:w}):w.length?w[0].children:null,E.length?a().createElement(o.Space,{direction:"vertical",style:{display:"flex"}},E):null):a().createElement(o.Empty,{description:f("No authentication methods available.")})}},872:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return d}});var r=n(485),o=n(59),i=n(155),a=n.n(i),u=n(442),l=n(295),c=n(824),s=n(488),f=n(434);function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function d(){var e,t=(0,s.dE)().t,n=((function(e){if(Array.isArray(e))return e})(e=(0,u.useSearchParams)())||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),1!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(e)||function(e){if(e){if("string"==typeof e)return p(e,1);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return p(e,1)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0].get("name"),d=(0,l.p)(n),h=(0,r.usePlugin)(f.A),m=(0,i.useMemo)(function(){if(!d)return null;var e,t=null==(e=h.authTypes.get(d.authType))?void 0:e.signUpFormLoader;return t?(0,i.lazy)(t):null},[d,h]);return((0,c.rN)(t("Signup")),d&&m)?a().createElement(i.Suspense,{fallback:a().createElement(o.Spin,null)},a().createElement(m,{authenticatorName:d.name})):a().createElement(o.Empty,{description:t("No authentication methods available.")})}},434:function(e,t,n){"use strict";n.d(t,{A:function(){return x},T:function(){return A}});var r=n(768),o=n(485),i=n(738),a=n.n(i),u=n(258),l=n(488);function c(e,t,n,r,o,i,a){try{var u=e[i](a),l=u.value}catch(e){n(e);return}u.done?t(l):Promise.resolve(l).then(r,o)}function s(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){c(i,r,o,a,u,"next",e)}function u(e){c(i,r,o,a,u,"throw",e)}a(void 0)})}}function f(e,t,n){return t=v(t),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e,E()?Reflect.construct(t,n||[],v(e).constructor):t.apply(e,n))}function p(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}function d(e,t,n){return(d=E()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&g(o,n.prototype),o}).apply(null,arguments)}function h(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function m(e,t,n){return t&&h(e.prototype,t),n&&h(e,n),e}function y(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function v(e){return(v=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function b(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&g(e,t)}function g(e,t){return(g=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function w(e){var t="function"==typeof Map?new Map:void 0;return(w=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return d(e,arguments,v(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),g(n,e)})(e)}function E(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(E=function(){return!!e})()}function S(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:l(0)}),u(a,"throw",{value:l(1)}),u(a,"return",{value:l(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function l(u){return function(l){var c=[u,l];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var O=function(e){function t(){var e;return p(this,t),e=f(this,t,arguments),y(e,"section","preferences"),y(e,"sort",350),y(e,"label","Language"),e}return b(t,e),m(t,[{key:"prepare",value:function(){return s(function(){var e,t,n,r,i;return S(this,function(a){switch(a.label){case 0:return[4,this.context.systemSettings.load()];case 1:return i=(null==(r=a.sent())||null==(e=r.data)?void 0:e.enabledLanguages)||[],this.options=i.map(function(e){var t;return{value:e,label:(null==(t=o.languageCodes[e])?void 0:t.label)||e}}),this.value=(null==(t=(n=this.context.app.apiClient.auth).getLocale)?void 0:t.call(n))||this.context.app.apiClient.auth.locale,this.ready=this.options.length>1,[2]}})}).call(this)}},{key:"onChange",value:function(e){return s(function(){return S(this,function(t){return this.context.app.apiClient.auth.setLocale(e),window.location.reload(),[2]})}).call(this)}}]),t}(o.UserCenterSelectItemModel);y(O,"itemId","language");var P={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"},k=a()(function(e){e()},3e3,{leading:!0,trailing:!1}),A=function(e){function t(){var e;return p(this,t),e=f(this,t,arguments),y(e,"authTypes",new r.Registry),e}return b(t,e),m(t,[{key:"registerType",value:function(e,t){this.authTypes.register(e,t)}},{key:"load",value:function(){return s(function(){return S(this,function(e){return this.app.providers.unshift([u.A,{}]),this.app.flowEngine.registerModels({UserCenterLanguageItemModel:O}),this.addRoutes(),this.registerPresetAuthType(),this.registerSettingsPages(),this.installInterceptors(),[2]})}).call(this)}},{key:"registerSettingsPages",value:function(){var e=this,t=function(t){return e.app.i18n.t(t,{ns:l.CU})};this.pluginSettingsManager.addMenuItem({key:l.CU,title:t("Authentication"),icon:"LoginOutlined",aclSnippet:"pm.auth"}),this.pluginSettingsManager.addPageTabItem({menuKey:l.CU,key:"authenticators",title:t("Authenticators"),icon:"LoginOutlined",aclSnippet:"pm.auth.authenticators",sort:1,componentLoader:function(){return n.e("9").then(n.bind(n,648))}}),this.pluginSettingsManager.addPageTabItem({menuKey:"security",key:"token-policy",title:t("Token policy"),icon:"ApiOutlined",aclSnippet:"pm.security.token-policy",sort:0,componentLoader:function(){return n.e("657").then(n.bind(n,632))}})}},{key:"addRoutes",value:function(){this.router.add("auth",{componentLoader:function(){return Promise.resolve().then(n.bind(n,829))}}),this.router.add("auth.signin",{path:"/signin",skipAuthCheck:!0,componentLoader:function(){return Promise.resolve().then(n.bind(n,818))}}),this.router.add("auth.signup",{path:"/signup",skipAuthCheck:!0,componentLoader:function(){return Promise.resolve().then(n.bind(n,872))}}),this.router.add("auth.forgotPassword",{path:"/forgot-password",skipAuthCheck:!0,componentLoader:function(){return Promise.resolve().then(n.bind(n,826))}}),this.router.add("auth.resetPassword",{path:"/reset-password",skipAuthCheck:!0,componentLoader:function(){return Promise.resolve().then(n.bind(n,622))}})}},{key:"registerPresetAuthType",value:function(){this.registerType("Email/Password",{signInFormLoader:function(){return n.e("795").then(n.bind(n,918))},signUpFormLoader:function(){return n.e("841").then(n.bind(n,720))},adminSettingsFormLoader:function(){return n.e("217").then(n.bind(n,264))}})}},{key:"installInterceptors",value:function(){var e=this;this.app.apiClient.axios.interceptors.response.handlers.unshift({fulfilled:function(t){var n,r=null==t||null==(n=t.headers)?void 0:n["x-new-token"];return r&&e.app.apiClient.auth.setToken(r),t},rejected:function(t){var n,r,i,a,u,l,c,s,f=null==t||null==(r=t.response)||null==(n=r.headers)?void 0:n["x-new-token"],p=null==t||null==(a=t.response)||null==(i=a.data)?void 0:i.errors,d=Array.isArray(p)?p[0]:null,h=(null==(l=e.app.router.router)||null==(u=l.state)?void 0:u.location)||window.location,m=(null==h?void 0:h.pathname)||window.location.pathname,y=(null==t?void 0:t.status)||(null==t||null==(c=t.response)?void 0:c.status);if(f&&e.app.apiClient.auth.setToken(f),401===y&&(null==d?void 0:d.code)&&P[null==d?void 0:d.code]&&(e.app.apiClient.auth.setToken(""),e.app.apiClient.auth.setRole(""),e.app.apiClient.auth.setAuthenticator("")),401===y&&!(null==(s=t.config)?void 0:s.skipAuth)&&(null==d?void 0:d.code)&&P[null==d?void 0:d.code]){if((null==d?void 0:d.code)===P.SKIP_TOKEN_RENEW)throw t;var v=e.app.router.isSkippedAuthCheckRoute(m);if(v&&(t.config.skipNotify=!0),!v){var b=(0,o.getCurrentV2RedirectPath)(e.app,h);return k(function(){e.app.apiClient.auth.setToken(""),e.app.router.navigate("/signin?redirect=".concat(encodeURIComponent(b)),{replace:!0})}),new Promise(function(){})}}throw t},synchronous:!1,runWhen:null})}}]),t}(w(o.Plugin)),x=A},258:function(e,t,n){"use strict";var r=n(485),o=n(155),i=n.n(o),a=n(442);t.A=function(e){var t=e.children,n=(0,r.useApp)(),u=(0,a.useNavigate)(),l=(0,a.useLocation)();return(0,o.useEffect)(function(){var e=new URLSearchParams(l.search),t=e.get("token"),r=e.get("authenticator");if(t){n.apiClient.auth.setToken(t),n.apiClient.auth.setAuthenticator(r),e.delete("token"),e.delete("authenticator");var o=e.toString();u({pathname:l.pathname,search:o?"?".concat(o):""},{replace:!0})}},[n,l.pathname,l.search,u]),i().createElement(i().Fragment,null,t)}},89:function(e,t,n){"use strict";var r=n(59),o=n(155),i=n.n(o),a=n(485),u=n(295);function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}t.A=function(e){var t,n,c=e.children,s=(0,a.useApp)(),f=function(e){if(Array.isArray(e))return e}(t=(0,o.useState)({authenticators:[],error:null,loading:!0}))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(t)||function(e){if(e){if("string"==typeof e)return l(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return l(e,2)}}(t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),p=f[0],d=f[1];return((0,o.useEffect)(function(){var e=!0;return s.apiClient.resource("authenticators").publicList().then(function(t){var n;e&&d({authenticators:(null==t||null==(n=t.data)?void 0:n.data)||[],error:null,loading:!1})}).catch(function(t){e&&d({authenticators:[],error:t,loading:!1})}),function(){e=!1}},[s]),p.loading)?i().createElement("div",{style:{textAlign:"center",marginTop:20}},i().createElement(r.Spin,null)):p.error?i().createElement(r.Alert,{type:"error",showIcon:!0,message:(null==(n=p.error)?void 0:n.message)||"Failed to load authenticators"}):i().createElement(u.m.Provider,{value:p.authenticators},c)}},295:function(e,t,n){"use strict";n.d(t,{m:function(){return o},p:function(){return i}});var r=n(155),o=(0,r.createContext)([]);o.displayName="AuthenticatorsContext";var i=function(e){return(0,r.useContext)(o).find(function(t){return t.name===e})}},824:function(e,t,n){"use strict";n.d(t,{go:function(){return s},rN:function(){return c},wn:function(){return l}});var r=n(155),o=n(442),i=n(485);function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function u(e,t,n,r,o,i,a){try{var u=e[i](a),l=u.value}catch(e){n(e);return}u.done?t(l):Promise.resolve(l).then(r,o)}function l(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"/admin",n=(0,i.useApp)(),u=(0,o.useNavigate)(),l=(function(e){if(Array.isArray(e))return e}(e=(0,o.useSearchParams)())||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),1!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(e)||function(e){if(e){if("string"==typeof e)return a(e,1);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return a(e,1)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0];return(0,r.useCallback)(function(){var e,r;u(function(e,t){if(!t||"/"===t)return e.startsWith("/")?e:"/".concat(e);var n=t.endsWith("/")?t.slice(0,-1):t;return e===n?"/":e.startsWith("".concat(n,"/"))?e.slice(n.length)||"/":e}(l.get("redirect")||t,null==(e=(r=n.router).getBasename)?void 0:e.call(r)),{replace:!0})},[n.router,u,t,l])}function c(e){(0,r.useEffect)(function(){document.title=e},[e])}function s(e){var t=(0,i.useApp)(),n=l();return{run:function(r){var o;return(o=function(){return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:l(0)}),u(a,"throw",{value:l(1)}),u(a,"return",{value:l(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function l(u){return function(l){var c=[u,l];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(o){switch(o.label){case 0:return[4,t.apiClient.auth.signIn(r,e)];case 1:return o.sent(),[4,t.apiClient.request({url:"/auth:check",skipAuth:!0,skipNotify:!0}).catch(function(){})];case 2:return o.sent(),n(),[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var i=o.apply(e,t);function a(e){u(i,n,r,a,l,"next",e)}function l(e){u(i,n,r,a,l,"throw",e)}a(void 0)})})()}}}},488:function(e,t,n){"use strict";n.d(t,{CU:function(){return i},dE:function(){return a},kj:function(){return u}});var r=n(694),o=n(953),i="auth";function a(){return(0,o.useTranslation)([i,"client"],{nsMode:"fallback"})}function u(){var e=(0,r.useFlowEngine)();return function(t){return e.context.t(t,{ns:[i,"client"],nsMode:"fallback"})}}},375:function(e){"use strict";e.exports=r},230:function(e){"use strict";e.exports=n},485:function(e){"use strict";e.exports=a},694:function(e){"use strict";e.exports=o},768:function(e){"use strict";e.exports=c},6:function(e){"use strict";e.exports=i},59:function(e){"use strict";e.exports=l},773:function(e){"use strict";e.exports=s},155:function(e){"use strict";e.exports=u},953:function(t){"use strict";t.exports=e},442:function(e){"use strict";e.exports=t}},m={};function y(e){var t=m[e];if(void 0!==t)return t.exports;var n=m[e]={exports:{}};return h[e](n,n.exports,y),n.exports}y.m=h,y.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return y.d(t,{a:t}),t},y.d=function(e,t){for(var n in t)y.o(t,n)&&!y.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},y.f={},y.e=function(e){return Promise.all(Object.keys(y.f).reduce(function(t,n){return y.f[n](e,t),t},[]))},y.u=function(e){return""+e+"."+({217:"09744ff679406aff",657:"2a9dcca9ddc31ec0",795:"b26178560fd03daa",841:"ac9bfbb0615510e5",9:"c10c60a4ecc4256d"})[e]+".js"},y.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),y.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},v={},y.l=function(e,t,n,r){if(v[e])return void v[e].push(t);if(void 0!==n)for(var o,i,a=document.getElementsByTagName("script"),u=0;u<a.length;u++){var l=a[u];if(l.getAttribute("src")==e||l.getAttribute("data-rspack")=="@nocobase/plugin-auth/client-v2:"+n){o=l;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,y.nc&&o.setAttribute("nonce",y.nc),o.setAttribute("data-rspack","@nocobase/plugin-auth/client-v2:"+n),o.src=e),v[e]=[t];var c=function(t,n){o.onerror=o.onload=null,clearTimeout(s);var r=v[e];if(delete v[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},s=setTimeout(c.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=c.bind(null,o.onerror),o.onload=c.bind(null,o.onload),i&&document.head.appendChild(o)},y.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},y.g.importScripts&&(b=y.g.location+"");var v,b,g=y.g.document;if(!b&&g&&(g.currentScript&&"SCRIPT"===g.currentScript.tagName.toUpperCase()&&(b=g.currentScript.src),!b)){var w=g.getElementsByTagName("script");if(w.length)for(var E=w.length-1;E>-1&&(!b||!/^http(s?):/.test(b));)b=w[E--].src}if(!b)throw Error("Automatic publicPath is not supported in this browser");y.p=b.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),f={889:0},y.f.j=function(e,t){var n=y.o(f,e)?f[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=f[e]=[t,r]});t.push(n[2]=r);var o=y.p+y.u(e),i=Error();y.l(o,function(t){if(y.o(f,e)&&(0!==(n=f[e])&&(f[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}},p=function(e,t){var n,r,o=t[0],i=t[1],a=t[2],u=0;if(o.some(function(e){return 0!==f[e]})){for(n in i)y.o(i,n)&&(y.m[n]=i[n]);a&&a(y)}for(e&&e(t);u<o.length;u++)r=o[u],y.o(f,r)&&f[r]&&f[r][0](),f[r]=0},(d=self.webpackChunk_nocobase_plugin_auth_client_v2=self.webpackChunk_nocobase_plugin_auth_client_v2||[]).forEach(p.bind(null,0)),d.push=p.bind(null,d.push.bind(d));var S={};return!function(){"use strict";var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/@nocobase/plugin-auth/dist/client-v2/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-auth/dist/client-v2/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var a=window.location.pathname||"/",u=a.indexOf(i);e=u>=0?a.slice(0,u+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-auth/dist/client-v2/"}y.p=e}(),!function(){"use strict";y.r(S),y.d(S,{AuthLayout:function(){return o.default},AuthProvider:function(){return c.A},AuthenticatorsContext:function(){return t.m},AuthenticatorsContextProvider:function(){return s.A},ForgotPasswordPage:function(){return u.default},NAMESPACE:function(){return n.CU},PluginAuthClientV2:function(){return e.T},ResetPasswordPage:function(){return l.default},SignInPage:function(){return i.default},SignUpPage:function(){return a.default},default:function(){return e.A},useAuthTranslation:function(){return n.dE},useAuthenticator:function(){return t.p},useDocumentTitle:function(){return r.rN},useRedirect:function(){return r.wn},useSignIn:function(){return r.go},useT:function(){return n.kj}});var e=y(434),t=y(295),n=y(488),r=y(824),o=y(829),i=y(818),a=y(872),u=y(826),l=y(622),c=y(258),s=y(89)}(),S}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react-i18next"),require("react-router-dom"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("ahooks"),require("@nocobase/client-v2"),require("react"),require("antd"),require("@nocobase/utils/client"),require("lodash")):"function"==typeof define&&define.amd?define("@nocobase/plugin-auth/client-v2",["react-i18next","react-router-dom","@formily/react","@ant-design/icons","@nocobase/flow-engine","ahooks","@nocobase/client-v2","react","antd","@nocobase/utils/client","lodash"],t):"object"==typeof exports?exports["@nocobase/plugin-auth/client-v2"]=t(require("react-i18next"),require("react-router-dom"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("ahooks"),require("@nocobase/client-v2"),require("react"),require("antd"),require("@nocobase/utils/client"),require("lodash")):e["@nocobase/plugin-auth/client-v2"]=t(e["react-i18next"],e["react-router-dom"],e["@formily/react"],e["@ant-design/icons"],e["@nocobase/flow-engine"],e.ahooks,e["@nocobase/client-v2"],e.react,e.antd,e["@nocobase/utils/client"],e.lodash)}(self,function(e,t,n,r,o,i,a,u,c,l,s){return function(){var f,p,d,h={432:function(e,t,n){e.exports=n(36).Symbol},77:function(e,t,n){var r=n(432),o=n(444),i=n(371),a=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":a&&a in Object(e)?o(e):i(e)}},625:function(e,t,n){var r=n(531),o=/^\s+/;e.exports=function(e){return e?e.slice(0,r(e)+1).replace(o,""):e}},565:function(e,t,n){e.exports="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g},444:function(e,t,n){var r=n(432),o=Object.prototype,i=o.hasOwnProperty,a=o.toString,u=r?r.toStringTag:void 0;e.exports=function(e){var t=i.call(e,u),n=e[u];try{e[u]=void 0;var r=!0}catch(e){}var o=a.call(e);return r&&(t?e[u]=n:delete e[u]),o}},371:function(e){var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},36:function(e,t,n){var r=n(565),o="object"==typeof self&&self&&self.Object===Object&&self;e.exports=r||o||Function("return this")()},531:function(e){var t=/\s/;e.exports=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n}},738:function(e,t,n){var r=n(130),o=n(593),i=n(909),a=Math.max,u=Math.min;e.exports=function(e,t,n){var c,l,s,f,p,d,h=0,m=!1,v=!1,y=!0;if("function"!=typeof e)throw TypeError("Expected a function");function g(t){var n=c,r=l;return c=l=void 0,h=t,f=e.apply(r,n)}function b(e){var n=e-d,r=e-h;return void 0===d||n>=t||n<0||v&&r>=s}function w(){var e,n,r,i=o();if(b(i))return E(i);p=setTimeout(w,(e=i-d,n=i-h,r=t-e,v?u(r,s-n):r))}function E(e){return(p=void 0,y&&c)?g(e):(c=l=void 0,f)}function S(){var e,n=o(),r=b(n);if(c=arguments,l=this,d=n,r){if(void 0===p)return h=e=d,p=setTimeout(w,t),m?g(e):f;if(v)return clearTimeout(p),p=setTimeout(w,t),g(d)}return void 0===p&&(p=setTimeout(w,t)),f}return t=i(t)||0,r(n)&&(m=!!n.leading,s=(v="maxWait"in n)?a(i(n.maxWait)||0,t):s,y="trailing"in n?!!n.trailing:y),S.cancel=function(){void 0!==p&&clearTimeout(p),h=0,c=d=l=p=void 0},S.flush=function(){return void 0===p?f:E(o())},S}},130:function(e){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},189:function(e){e.exports=function(e){return null!=e&&"object"==typeof e}},733:function(e,t,n){var r=n(77),o=n(189);e.exports=function(e){return"symbol"==typeof e||o(e)&&"[object Symbol]"==r(e)}},593:function(e,t,n){var r=n(36);e.exports=function(){return r.Date.now()}},909:function(e,t,n){var r=n(625),o=n(130),i=n(733),a=0/0,u=/^[-+]0x[0-9a-f]+$/i,c=/^0b[01]+$/i,l=/^0o[0-7]+$/i,s=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(i(e))return a;if(o(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=o(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=r(e);var n=c.test(e);return n||l.test(e)?s(e.slice(2),n?2:8):u.test(e)?a:+e}},829:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return s}});var r=n(59),o=n(155),i=n.n(o),a=n(442),u=n(953),c=n(485),l=n(89);function s(){var e,t=r.theme.useToken().token,n=((0,c.useSystemSettings)()||{}).data,o=(0,u.useTranslation)("lm-collections").t;return i().createElement("div",{style:{maxWidth:320,margin:"0 auto",paddingTop:"20vh",paddingBottom:"20vh"}},i().createElement("div",{style:{position:"fixed",top:t.paddingLG,right:t.paddingLG,color:t.colorText}},i().createElement(c.SwitchLanguage,null)),i().createElement("h1",{style:{textAlign:"center"}},o(null==n||null==(e=n.data)?void 0:e.title)),i().createElement(l.A,null,i().createElement(a.Outlet,null)),i().createElement("div",{style:{position:"absolute",bottom:0,left:0,width:"100%",paddingBottom:t.paddingLG,textAlign:"center",backgroundColor:t.colorBgContainer}},i().createElement(c.PoweredBy,null)))}},826:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return m}});var r=n(59),o=n(155),i=n.n(o),a=n(442),u=n(485),c=n(295),l=n(488),s=n(824),f=n(927);function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function d(e,t,n,r,o,i,a){try{var u=e[i](a),c=u.value}catch(e){n(e);return}u.done?t(c):Promise.resolve(c).then(r,o)}function h(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,u=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){u=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(u)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return p(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return p(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(){var e,t=(0,u.useApp)(),n=(0,l.dE)().t,p=h((0,a.useSearchParams)(),1)[0].get("name"),m=(0,c.p)(p),v=h(r.Form.useForm(),1)[0],y=h((0,o.useState)(!1),2),g=y[0],b=y[1],w=h((0,o.useState)(""),2),E=w[0],S=w[1],P=(0,f.f1)(t,"auth.signin");return((0,s.rN)(n("Reset password")),null==m||null==(e=m.options)?void 0:e.enableResetPassword)?i().createElement(r.Form,{form:v,layout:"vertical",onFinish:function(e){var o;return(o=function(){var o,i,a,u,c;return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:c(0)}),u(a,"throw",{value:c(1)}),u(a,"return",{value:c(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function c(u){return function(c){var l=[u,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(l){switch(l.label){case 0:S(""),b(!0),l.label=1;case 1:return l.trys.push([1,3,4,5]),[4,t.apiClient.auth.lostPassword(e)];case 2:return l.sent(),r.message.success(n("Reset email sent successfully")),v.resetFields(),[3,5];case 3:return S((null==(o=l.sent())||null==(c=o.response)||null==(u=c.data)||null==(a=u.errors)||null==(i=a[0])?void 0:i.message)||(null==o?void 0:o.message)||String(o)),[3,5];case 4:return b(!1),[7];case 5:return[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var i=o.apply(e,t);function a(e){d(i,n,r,a,u,"next",e)}function u(e){d(i,n,r,a,u,"throw",e)}a(void 0)})})()}},E?i().createElement(r.Alert,{style:{marginBottom:16},type:"error",showIcon:!0,message:E}):null,i().createElement(r.Form.Item,{label:n("Reset password"),name:"email",rules:[{required:!0,message:n("Please fill in your email address")},{type:"email",message:n("Please enter a valid email")}]},i().createElement(r.Input,{placeholder:n("Please enter your email")})),i().createElement(r.Form.Item,{style:{marginBottom:12}},i().createElement(r.Button,{loading:g,htmlType:"submit",type:"primary",block:!0},n("Send reset email"))),i().createElement(a.Link,{to:P},n("Back to login"))):i().createElement(a.Navigate,{to:P,replace:!0})}},622:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return m}});var r=n(59),o=n(155),i=n.n(o),a=n(442),u=n(485),c=n(295),l=n(488),s=n(824),f=n(927);function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function d(e,t,n,r,o,i,a){try{var u=e[i](a),c=u.value}catch(e){n(e);return}u.done?t(c):Promise.resolve(c).then(r,o)}function h(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,u=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){u=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(u)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return p(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return p(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(){var e,t=(0,u.useApp)(),n=(0,l.dE)().t,p=(0,a.useNavigate)(),m=h((0,a.useSearchParams)(),1)[0],v=m.get("resetToken"),y=m.get("name"),g=(0,c.p)(y),b=h(r.Form.useForm(),1)[0],w=h((0,o.useState)(!1),2),E=w[0],S=w[1],P=h((0,o.useState)(!0),2),O=P[0],k=P[1],A=h((0,o.useState)(!1),2),x=A[0],T=A[1],j=h((0,o.useState)(""),2),_=j[0],I=j[1],C=(0,f.f1)(t,"auth.signin");return((0,s.rN)(n("Reset password")),(0,o.useEffect)(function(){var e=!0;if(!v){S(!0),k(!1);return}return t.apiClient.auth.checkResetToken({resetToken:v}).then(function(){e&&(S(!1),k(!1))}).catch(function(){e&&(S(!0),k(!1))}),function(){e=!1}},[t,v]),null==g||null==(e=g.options)?void 0:e.enableResetPassword)?O||v&&!E?i().createElement(r.Form,{form:b,layout:"vertical",onFinish:function(e){var o;return(o=function(){var o,i,a,u,c;return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:c(0)}),u(a,"throw",{value:c(1)}),u(a,"return",{value:c(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function c(u){return function(c){var l=[u,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(l){switch(l.label){case 0:I(""),T(!0),l.label=1;case 1:var s,f;return l.trys.push([1,3,4,5]),[4,t.apiClient.auth.resetPassword((s=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},e),f=f={resetToken:v},Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(f)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(f)).forEach(function(e){Object.defineProperty(s,e,Object.getOwnPropertyDescriptor(f,e))}),s))];case 2:return l.sent(),r.message.success(n("Password reset successful")),window.setTimeout(function(){p(C,{replace:!0})},1e3),[3,5];case 3:return I((null==(o=l.sent())||null==(c=o.response)||null==(u=c.data)||null==(a=u.errors)||null==(i=a[0])?void 0:i.message)||(null==o?void 0:o.message)||String(o)),[3,5];case 4:return T(!1),[7];case 5:return[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var i=o.apply(e,t);function a(e){d(i,n,r,a,u,"next",e)}function u(e){d(i,n,r,a,u,"throw",e)}a(void 0)})})()}},_?i().createElement(r.Alert,{style:{marginBottom:16},type:"error",showIcon:!0,message:_}):null,i().createElement(r.Form.Item,{label:n("New password"),name:"password",rules:[{required:!0,message:n("Please enter new password")}]},i().createElement(r.Input.Password,{autoComplete:"new-password"})),i().createElement(r.Form.Item,{label:n("Confirm password"),name:"confirmPassword",dependencies:["password"],rules:[{required:!0,message:n("Please enter the same password again")},function(e){var t=e.getFieldValue;return{validator:function(e,r){return r&&t("password")!==r?Promise.reject(Error(n("The passwords entered twice are inconsistent"))):Promise.resolve()}}}]},i().createElement(r.Input.Password,{autoComplete:"new-password"})),i().createElement(r.Form.Item,{style:{marginBottom:12}},i().createElement(r.Button,{loading:x||O,htmlType:"submit",type:"primary",block:!0},n("Confirm"))),i().createElement(a.Link,{to:C},n("Go to login"))):i().createElement(r.Result,{status:"403",title:n("Reset link has expired"),extra:i().createElement(r.Button,{type:"primary",onClick:function(){return p(C)}},n("Go to login"))}):i().createElement(a.Navigate,{to:C,replace:!0})}},818:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return v}});var r=n(485),o=n(59),i=n(155),a=n.n(i),u=n(442),c=n(295),l=n(824),s=n(488),f=n(434),p=n(927);function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function h(e){var t=(0,r.usePlugin)(f.A);return(0,i.useMemo)(function(){var n={},r=!0,o=!1,i=void 0;try{for(var a,u=t.authTypes.getEntities()[Symbol.iterator]();!(r=(a=u.next()).done);r=!0){var c,l=(c=a.value,function(e){if(Array.isArray(e))return e}(c)||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(c)||function(e){if(e){if("string"==typeof e)return d(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return d(e,2)}}(c)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),s=l[0],f=l[1][e];f&&(n[s]=f)}}catch(e){o=!0,i=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw i}}return n},[t,e])}function m(e){var t=new Map;return function(n){if(e[n])return t.has(n)||t.set(n,(0,i.lazy)(e[n])),t.get(n)}}function v(){var e=(0,r.useApp)(),t=(0,u.useLocation)(),n=(0,u.useNavigate)(),f=(0,s.dE)().t,d=(0,s.kj)(),v=(0,i.useContext)(c.m),y=h("signInFormLoader"),g=h("signInButtonLoader"),b=(0,i.useMemo)(function(){return m(y)},[y]),w=(0,i.useMemo)(function(){return m(g)},[g]);(0,l.rN)(f("Signin")),(0,i.useEffect)(function(){var o=new URLSearchParams(t.search),i=o.get("redirect"),a=(0,r.normalizeV2RedirectPath)(e,i,(0,p.Fo)(e));i!==a&&(o.set("redirect",a),n({pathname:t.pathname,search:"?".concat(o)},{replace:!0}))},[e,t.pathname,t.search,n]);var E=(0,i.useMemo)(function(){return v.map(function(e){var t=b(e.authType);if(!t)return null;var n=d(e.authTypeTitle||e.authType);return{key:e.name,label:e.title||"".concat(f("Sign-in")," (").concat(n,")"),children:a().createElement(i.Suspense,{fallback:a().createElement(o.Spin,null)},a().createElement(t,{authenticator:e}))}}).filter(Boolean)},[v,b,f,d]),S=(0,i.useMemo)(function(){return v.map(function(e,t){var n=w(e.authType);return n?a().createElement(i.Suspense,{key:"".concat(e.name,"-").concat(t),fallback:a().createElement(o.Spin,null)},a().createElement(n,{authenticator:e})):null}).filter(Boolean)},[v,w]);return v.length?a().createElement(o.Space,{direction:"vertical",style:{display:"flex"}},E.length>1?a().createElement(o.Tabs,{items:E}):E.length?E[0].children:null,S.length?a().createElement(o.Space,{direction:"vertical",style:{display:"flex"}},S):null):a().createElement(o.Empty,{description:f("No authentication methods available.")})}},872:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return d}});var r=n(485),o=n(59),i=n(155),a=n.n(i),u=n(442),c=n(295),l=n(824),s=n(488),f=n(434);function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function d(){var e,t=(0,s.dE)().t,n=((function(e){if(Array.isArray(e))return e})(e=(0,u.useSearchParams)())||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),1!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(e)||function(e){if(e){if("string"==typeof e)return p(e,1);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return p(e,1)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0].get("name"),d=(0,c.p)(n),h=(0,r.usePlugin)(f.A),m=(0,i.useMemo)(function(){if(!d)return null;var e,t=null==(e=h.authTypes.get(d.authType))?void 0:e.signUpFormLoader;return t?(0,i.lazy)(t):null},[d,h]);return((0,l.rN)(t("Signup")),d&&m)?a().createElement(i.Suspense,{fallback:a().createElement(o.Spin,null)},a().createElement(m,{authenticatorName:d.name})):a().createElement(o.Empty,{description:t("No authentication methods available.")})}},434:function(e,t,n){"use strict";n.d(t,{A:function(){return T},T:function(){return x}});var r=n(768),o=n(485),i=n(738),a=n.n(i),u=n(927),c=n(258),l=n(488);function s(e,t,n,r,o,i,a){try{var u=e[i](a),c=u.value}catch(e){n(e);return}u.done?t(c):Promise.resolve(c).then(r,o)}function f(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){s(i,r,o,a,u,"next",e)}function u(e){s(i,r,o,a,u,"throw",e)}a(void 0)})}}function p(e,t,n){return t=g(t),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e,S()?Reflect.construct(t,n||[],g(e).constructor):t.apply(e,n))}function d(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}function h(e,t,n){return(h=S()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&w(o,n.prototype),o}).apply(null,arguments)}function m(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function v(e,t,n){return t&&m(e.prototype,t),n&&m(e,n),e}function y(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function g(e){return(g=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function b(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&w(e,t)}function w(e,t){return(w=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function E(e){var t="function"==typeof Map?new Map:void 0;return(E=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return h(e,arguments,g(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),w(n,e)})(e)}function S(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(S=function(){return!!e})()}function P(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:c(0)}),u(a,"throw",{value:c(1)}),u(a,"return",{value:c(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function c(u){return function(c){var l=[u,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var O=function(e){function t(){var e;return d(this,t),e=p(this,t,arguments),y(e,"section","preferences"),y(e,"sort",350),y(e,"label","Language"),e}return b(t,e),v(t,[{key:"prepare",value:function(){return f(function(){var e,t,n,r,i;return P(this,function(a){switch(a.label){case 0:return[4,this.context.systemSettings.load()];case 1:return i=(null==(r=a.sent())||null==(e=r.data)?void 0:e.enabledLanguages)||[],this.options=i.map(function(e){var t;return{value:e,label:(null==(t=o.languageCodes[e])?void 0:t.label)||e}}),this.value=(null==(t=(n=this.context.app.apiClient.auth).getLocale)?void 0:t.call(n))||this.context.app.apiClient.auth.locale,this.ready=this.options.length>1,[2]}})}).call(this)}},{key:"onChange",value:function(e){return f(function(){return P(this,function(t){return this.context.app.apiClient.auth.setLocale(e),window.location.reload(),[2]})}).call(this)}}]),t}(o.UserCenterSelectItemModel);y(O,"itemId","language");var k={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"},A=a()(function(e){e()},3e3,{leading:!0,trailing:!1}),x=function(e){function t(){var e;return d(this,t),e=p(this,t,arguments),y(e,"authTypes",new r.Registry),e}return b(t,e),v(t,[{key:"registerType",value:function(e,t){this.authTypes.register(e,t)}},{key:"load",value:function(){return f(function(){return P(this,function(e){return this.app.providers.unshift([c.A,{}]),this.app.flowEngine.registerModels({UserCenterLanguageItemModel:O}),this.addRoutes(),this.registerPresetAuthType(),this.registerSettingsPages(),this.installInterceptors(),[2]})}).call(this)}},{key:"registerSettingsPages",value:function(){var e=this,t=function(t){return e.app.i18n.t(t,{ns:l.CU})};this.pluginSettingsManager.addMenuItem({key:l.CU,title:t("Authentication"),icon:"LoginOutlined",aclSnippet:"pm.auth"}),this.pluginSettingsManager.addPageTabItem({menuKey:l.CU,key:"authenticators",title:t("Authenticators"),icon:"LoginOutlined",aclSnippet:"pm.auth.authenticators",sort:1,componentLoader:function(){return n.e("9").then(n.bind(n,648))}}),this.pluginSettingsManager.addPageTabItem({menuKey:"security",key:"token-policy",title:t("Token policy"),icon:"ApiOutlined",aclSnippet:"pm.security.token-policy",sort:0,componentLoader:function(){return n.e("657").then(n.bind(n,632))}})}},{key:"addRoutes",value:function(){this.router.add("auth",{componentLoader:function(){return Promise.resolve().then(n.bind(n,829))}}),this.router.add("auth.signin",{path:"/signin",skipAuthCheck:!0,componentLoader:function(){return Promise.resolve().then(n.bind(n,818))}}),this.router.add("auth.signup",{path:"/signup",skipAuthCheck:!0,componentLoader:function(){return Promise.resolve().then(n.bind(n,872))}}),this.router.add("auth.forgotPassword",{path:"/forgot-password",skipAuthCheck:!0,componentLoader:function(){return Promise.resolve().then(n.bind(n,826))}}),this.router.add("auth.resetPassword",{path:"/reset-password",skipAuthCheck:!0,componentLoader:function(){return Promise.resolve().then(n.bind(n,622))}})}},{key:"registerPresetAuthType",value:function(){this.registerType("Email/Password",{signInFormLoader:function(){return n.e("795").then(n.bind(n,918))},signUpFormLoader:function(){return n.e("841").then(n.bind(n,720))},adminSettingsFormLoader:function(){return n.e("217").then(n.bind(n,264))}})}},{key:"installInterceptors",value:function(){var e=this;this.app.apiClient.axios.interceptors.response.handlers.unshift({fulfilled:function(t){var n,r=null==t||null==(n=t.headers)?void 0:n["x-new-token"];return r&&e.app.apiClient.auth.setToken(r),t},rejected:function(t){var n,r,i,a,c,l,s,f,p=null==t||null==(r=t.response)||null==(n=r.headers)?void 0:n["x-new-token"],d=null==t||null==(a=t.response)||null==(i=a.data)?void 0:i.errors,h=Array.isArray(d)?d[0]:null,m=(null==(l=e.app.router.router)||null==(c=l.state)?void 0:c.location)||window.location,v=(null==m?void 0:m.pathname)||window.location.pathname,y=(null==t?void 0:t.status)||(null==t||null==(s=t.response)?void 0:s.status);if(p&&e.app.apiClient.auth.setToken(p),401===y&&(null==h?void 0:h.code)&&k[null==h?void 0:h.code]&&(e.app.apiClient.auth.setToken(""),e.app.apiClient.auth.setRole(""),e.app.apiClient.auth.setAuthenticator("")),401===y&&!(null==(f=t.config)?void 0:f.skipAuth)&&(null==h?void 0:h.code)&&k[null==h?void 0:h.code]){if((null==h?void 0:h.code)===k.SKIP_TOKEN_RENEW)throw t;var g=e.app.router.isSkippedAuthCheckRoute(v);if(g&&(t.config.skipNotify=!0),!g){var b=(0,o.getCurrentV2RedirectPath)(e.app,m);return A(function(){e.app.apiClient.auth.setToken(""),(0,u.Py)(e.app)?(0,o.redirectToV2Signin)(e.app,b):e.app.router.navigate("/signin?redirect=".concat(encodeURIComponent(b)),{replace:!0})}),new Promise(function(){})}}throw t},synchronous:!1,runWhen:null})}}]),t}(E(o.Plugin)),T=x},258:function(e,t,n){"use strict";var r=n(485),o=n(155),i=n.n(o),a=n(442);t.A=function(e){var t=e.children,n=(0,r.useApp)(),u=(0,a.useNavigate)(),c=(0,a.useLocation)();return(0,o.useEffect)(function(){var e=new URLSearchParams(c.search),t=e.get("token"),r=e.get("authenticator");if(t){n.apiClient.auth.setToken(t),n.apiClient.auth.setAuthenticator(r),e.delete("token"),e.delete("authenticator");var o=e.toString();u({pathname:c.pathname,search:o?"?".concat(o):""},{replace:!0})}},[n,c.pathname,c.search,u]),i().createElement(i().Fragment,null,t)}},89:function(e,t,n){"use strict";var r=n(59),o=n(155),i=n.n(o),a=n(485),u=n(295);function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}t.A=function(e){var t,n,l=e.children,s=(0,a.useApp)(),f=function(e){if(Array.isArray(e))return e}(t=(0,o.useState)({authenticators:[],error:null,loading:!0}))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(t)||function(e){if(e){if("string"==typeof e)return c(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return c(e,2)}}(t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),p=f[0],d=f[1];return((0,o.useEffect)(function(){var e=!0;return s.apiClient.resource("authenticators").publicList().then(function(t){var n;e&&d({authenticators:(null==t||null==(n=t.data)?void 0:n.data)||[],error:null,loading:!1})}).catch(function(t){e&&d({authenticators:[],error:t,loading:!1})}),function(){e=!1}},[s]),p.loading)?i().createElement("div",{style:{textAlign:"center",marginTop:20}},i().createElement(r.Spin,null)):p.error?i().createElement(r.Alert,{type:"error",showIcon:!0,message:(null==(n=p.error)?void 0:n.message)||"Failed to load authenticators"}):i().createElement(u.m.Provider,{value:p.authenticators},l)}},927:function(e,t,n){"use strict";n.d(t,{Fo:function(){return a},Py:function(){return i},f1:function(){return o}});var r={"auth.signin":"/signin","auth.signup":"/signup","auth.forgotPassword":"/forgot-password","auth.resetPassword":"/reset-password"};function o(e,t){var n,o=null==(n=e.router.get(t))?void 0:n.path;return"string"==typeof o?o:r[t]}function i(e){return"settings."===e.pluginSettingsManager.getRouteName("")}function a(e){return i(e)?e.pluginSettingsManager.getRoutePath(""):"/"}},295:function(e,t,n){"use strict";n.d(t,{m:function(){return o},p:function(){return i}});var r=n(155),o=(0,r.createContext)([]);o.displayName="AuthenticatorsContext";var i=function(e){return(0,r.useContext)(o).find(function(t){return t.name===e})}},824:function(e,t,n){"use strict";n.d(t,{go:function(){return p},rN:function(){return f},wn:function(){return s}});var r=n(155),o=n(442),i=n(485),a=n(927);function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function c(e,t,n,r,o,i,a){try{var u=e[i](a),c=u.value}catch(e){n(e);return}u.done?t(c):Promise.resolve(c).then(r,o)}function l(e){var t=new URL("/".concat(String(e||"/").trim()).replace(/\/{2,}/g,"/"),window.location.origin).pathname;return"/"===t?t:t.replace(/\/+$/,"")}function s(e){var t,n=(0,i.useApp)(),c=(0,o.useNavigate)(),s=(function(e){if(Array.isArray(e))return e}(t=(0,o.useSearchParams)())||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),1!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(t)||function(e){if(e){if("string"==typeof e)return u(e,1);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return u(e,1)}}(t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0];return(0,r.useCallback)(function(){var t,r,o=s.get("redirect"),u=e||(0,a.Fo)(n),f=o||void 0===e&&(0,a.Py)(n)?(0,i.normalizeV2RedirectPath)(n,o,u):u;!function(e,t){if(!t.startsWith("/")||t.startsWith("//")||t.startsWith("/\\"))return!1;var n,r,o,i,u,c,s=null==(u=(c=e.router).getBasename)?void 0:u.call(c),f=l(e.getPublicPath()),p=(r=l(f).replace(/\/+$/,""),o=l(s||"/"),i=r&&(o===r||o.startsWith("".concat(r,"/")))?o.slice(r.length)||"/":o,(null==(n=/^\/settings(\/(?:apps|_app)\/[^/]+)(?=\/|$)/.exec(i))?void 0:n[1])||""),d=f.split("/");(0,a.Py)(e)||d.pop();var h=l(d.join("/")||"/").replace(/\/+$/,""),m=p?"".concat(h,"/settings").concat(p):"".concat(h,"/settings")||"/settings",v=l(t.split(/[?#]/)[0]);return v===m||v.startsWith("".concat(m,"/"))}(n,f)?c(function(e,t){if(!t||"/"===t)return e.startsWith("/")?e:"/".concat(e);var n=t.endsWith("/")?t.slice(0,-1):t;return e===n?"/":e.startsWith("".concat(n,"/"))?e.slice(n.length)||"/":e}(f,null==(t=(r=n.router).getBasename)?void 0:t.call(r)),{replace:!0}):window.location.replace(f)},[n,c,e,s])}function f(e){(0,r.useEffect)(function(){document.title=e},[e])}function p(e){var t=(0,i.useApp)(),n=s();return{run:function(r){var o;return(o=function(){return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:c(0)}),u(a,"throw",{value:c(1)}),u(a,"return",{value:c(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function c(u){return function(c){var l=[u,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(o){switch(o.label){case 0:return[4,t.apiClient.auth.signIn(r,e)];case 1:return o.sent(),[4,t.apiClient.request({url:"/auth:check",skipAuth:!0,skipNotify:!0}).catch(function(){})];case 2:return o.sent(),n(),[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var i=o.apply(e,t);function a(e){c(i,n,r,a,u,"next",e)}function u(e){c(i,n,r,a,u,"throw",e)}a(void 0)})})()}}}},488:function(e,t,n){"use strict";n.d(t,{CU:function(){return i},dE:function(){return a},kj:function(){return u}});var r=n(694),o=n(953),i="auth";function a(){return(0,o.useTranslation)([i,"client"],{nsMode:"fallback"})}function u(){var e=(0,r.useFlowEngine)();return function(t){return e.context.t(t,{ns:[i,"client"],nsMode:"fallback"})}}},375:function(e){"use strict";e.exports=r},230:function(e){"use strict";e.exports=n},485:function(e){"use strict";e.exports=a},694:function(e){"use strict";e.exports=o},768:function(e){"use strict";e.exports=l},6:function(e){"use strict";e.exports=i},59:function(e){"use strict";e.exports=c},773:function(e){"use strict";e.exports=s},155:function(e){"use strict";e.exports=u},953:function(t){"use strict";t.exports=e},442:function(e){"use strict";e.exports=t}},m={};function v(e){var t=m[e];if(void 0!==t)return t.exports;var n=m[e]={exports:{}};return h[e](n,n.exports,v),n.exports}v.m=h,v.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return v.d(t,{a:t}),t},v.d=function(e,t){for(var n in t)v.o(t,n)&&!v.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},v.f={},v.e=function(e){return Promise.all(Object.keys(v.f).reduce(function(t,n){return v.f[n](e,t),t},[]))},v.u=function(e){return""+e+"."+({217:"1510705562d97555",657:"2a9dcca9ddc31ec0",795:"7100439b59804662",841:"7a31cfa7c5c79d2d",9:"c10c60a4ecc4256d"})[e]+".js"},v.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),v.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},y={},v.l=function(e,t,n,r){if(y[e])return void y[e].push(t);if(void 0!==n)for(var o,i,a=document.getElementsByTagName("script"),u=0;u<a.length;u++){var c=a[u];if(c.getAttribute("src")==e||c.getAttribute("data-rspack")=="@nocobase/plugin-auth/client-v2:"+n){o=c;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,v.nc&&o.setAttribute("nonce",v.nc),o.setAttribute("data-rspack","@nocobase/plugin-auth/client-v2:"+n),o.src=e),y[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(s);var r=y[e];if(delete y[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=l.bind(null,o.onerror),o.onload=l.bind(null,o.onload),i&&document.head.appendChild(o)},v.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},v.g.importScripts&&(g=v.g.location+"");var y,g,b=v.g.document;if(!g&&b&&(b.currentScript&&"SCRIPT"===b.currentScript.tagName.toUpperCase()&&(g=b.currentScript.src),!g)){var w=b.getElementsByTagName("script");if(w.length)for(var E=w.length-1;E>-1&&(!g||!/^http(s?):/.test(g));)g=w[E--].src}if(!g)throw Error("Automatic publicPath is not supported in this browser");v.p=g.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),f={889:0},v.f.j=function(e,t){var n=v.o(f,e)?f[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=f[e]=[t,r]});t.push(n[2]=r);var o=v.p+v.u(e),i=Error();v.l(o,function(t){if(v.o(f,e)&&(0!==(n=f[e])&&(f[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}},p=function(e,t){var n,r,o=t[0],i=t[1],a=t[2],u=0;if(o.some(function(e){return 0!==f[e]})){for(n in i)v.o(i,n)&&(v.m[n]=i[n]);a&&a(v)}for(e&&e(t);u<o.length;u++)r=o[u],v.o(f,r)&&f[r]&&f[r][0](),f[r]=0},(d=self.webpackChunk_nocobase_plugin_auth_client_v2=self.webpackChunk_nocobase_plugin_auth_client_v2||[]).forEach(p.bind(null,0)),d.push=p.bind(null,d.push.bind(d));var S={};return!function(){"use strict";var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/@nocobase/plugin-auth/dist/client-v2/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-auth/dist/client-v2/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var a=window.location.pathname||"/",u=a.indexOf(i);e=u>=0?a.slice(0,u+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-auth/dist/client-v2/"}v.p=e}(),!function(){"use strict";v.r(S),v.d(S,{AuthLayout:function(){return o.default},AuthProvider:function(){return l.A},AuthenticatorsContext:function(){return t.m},AuthenticatorsContextProvider:function(){return s.A},ForgotPasswordPage:function(){return u.default},NAMESPACE:function(){return n.CU},PluginAuthClientV2:function(){return e.T},ResetPasswordPage:function(){return c.default},SignInPage:function(){return i.default},SignUpPage:function(){return a.default},default:function(){return e.A},useAuthTranslation:function(){return n.dE},useAuthenticator:function(){return t.p},useDocumentTitle:function(){return r.rN},useRedirect:function(){return r.wn},useSignIn:function(){return r.go},useT:function(){return n.kj}});var e=v(434),t=v(295),n=v(488),r=v(824),o=v(829),i=v(818),a=v(872),u=v(826),c=v(622),l=v(258),s=v(89)}(),S}()});
@@ -8,21 +8,21 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "2.3.0-alpha.1",
11
+ "@nocobase/client": "3.0.0-alpha.2",
12
12
  "react": "18.2.0",
13
13
  "react-router-dom": "6.30.1",
14
- "@nocobase/utils": "2.3.0-alpha.1",
14
+ "@nocobase/utils": "3.0.0-alpha.2",
15
15
  "axios": "1.7.7",
16
16
  "lodash": "4.18.1",
17
- "@nocobase/client-v2": "2.3.0-alpha.1",
18
- "@nocobase/flow-engine": "2.3.0-alpha.1",
17
+ "@nocobase/client-v2": "3.0.0-alpha.2",
18
+ "@nocobase/flow-engine": "3.0.0-alpha.2",
19
19
  "react-i18next": "11.18.6",
20
- "@nocobase/auth": "2.3.0-alpha.1",
21
- "@nocobase/database": "2.3.0-alpha.1",
22
- "@nocobase/cache": "2.3.0-alpha.1",
23
- "@nocobase/server": "2.3.0-alpha.1",
24
- "@nocobase/logger": "2.3.0-alpha.1",
25
- "@nocobase/test": "2.3.0-alpha.1",
20
+ "@nocobase/auth": "3.0.0-alpha.2",
21
+ "@nocobase/database": "3.0.0-alpha.2",
22
+ "@nocobase/cache": "3.0.0-alpha.2",
23
+ "@nocobase/server": "3.0.0-alpha.2",
24
+ "@nocobase/logger": "3.0.0-alpha.2",
25
+ "@nocobase/test": "3.0.0-alpha.2",
26
26
  "@formily/antd-v5": "1.2.3",
27
27
  "antd": "5.24.2",
28
28
  "@formily/shared": "2.3.7",
@@ -30,6 +30,6 @@ module.exports = {
30
30
  "@emotion/css": "11.13.0",
31
31
  "@ant-design/icons": "5.6.1",
32
32
  "ahooks": "3.7.8",
33
- "@nocobase/actions": "2.3.0-alpha.1",
33
+ "@nocobase/actions": "3.0.0-alpha.2",
34
34
  "@formily/core": "2.3.7"
35
35
  };
package/dist/index.d.ts CHANGED
@@ -6,5 +6,5 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
- export { AuthModel, BasicAuth, buildRedirectPath, defaultTokenPolicyConfig, default, getModernClientPrefix, presetAuthType, resolveSigninPrefix, } from './server';
10
- export type { BuildRedirectPathOptions, ResolveSigninPrefixOptions } from './server';
9
+ export { AuthModel, appendAuthRedirectQuery, BasicAuth, buildRedirectPath, defaultTokenPolicyConfig, default, getModernClientPrefix, presetAuthType, resolveAuthRedirect, resolveSigninPrefix, resolveSubAppSegment, } from './server';
10
+ export type { BuildRedirectPathOptions, AuthRedirectOriginContext, ResolveSigninPrefixOptions } from './server';
package/dist/index.js CHANGED
@@ -38,12 +38,15 @@ var src_exports = {};
38
38
  __export(src_exports, {
39
39
  AuthModel: () => import_server.AuthModel,
40
40
  BasicAuth: () => import_server.BasicAuth,
41
+ appendAuthRedirectQuery: () => import_server.appendAuthRedirectQuery,
41
42
  buildRedirectPath: () => import_server.buildRedirectPath,
42
43
  default: () => import_server.default,
43
44
  defaultTokenPolicyConfig: () => import_server.defaultTokenPolicyConfig,
44
45
  getModernClientPrefix: () => import_server.getModernClientPrefix,
45
46
  presetAuthType: () => import_server.presetAuthType,
46
- resolveSigninPrefix: () => import_server.resolveSigninPrefix
47
+ resolveAuthRedirect: () => import_server.resolveAuthRedirect,
48
+ resolveSigninPrefix: () => import_server.resolveSigninPrefix,
49
+ resolveSubAppSegment: () => import_server.resolveSubAppSegment
47
50
  });
48
51
  module.exports = __toCommonJS(src_exports);
49
52
  var import_server = __toESM(require("./server"));
@@ -51,9 +54,12 @@ var import_server = __toESM(require("./server"));
51
54
  0 && (module.exports = {
52
55
  AuthModel,
53
56
  BasicAuth,
57
+ appendAuthRedirectQuery,
54
58
  buildRedirectPath,
55
59
  defaultTokenPolicyConfig,
56
60
  getModernClientPrefix,
57
61
  presetAuthType,
58
- resolveSigninPrefix
62
+ resolveAuthRedirect,
63
+ resolveSigninPrefix,
64
+ resolveSubAppSegment
59
65
  });
@@ -1 +1 @@
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":"2026-07-16T12:56:43.859Z"}
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":"2026-07-30T05:56:46.431Z"}
@@ -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":"2026-07-16T12:56:43.948Z"}
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":"2026-07-30T05:56:46.530Z"}
@@ -12,5 +12,8 @@ export { presetAuthType } from '../preset';
12
12
  export { defaultTokenPolicyConfig } from '../constants';
13
13
  export { buildRedirectPath, getModernClientPrefix, resolveSigninPrefix } from './utils/buildRedirectPath';
14
14
  export type { BuildRedirectPathOptions, ResolveSigninPrefixOptions } from './utils/buildRedirectPath';
15
+ export { resolveSubAppSegment } from './utils/resolveSubAppSegment';
16
+ export { appendAuthRedirectQuery, resolveAuthRedirect } from './utils/authRedirect';
17
+ export type { AuthRedirectOriginContext } from './utils/authRedirect';
15
18
  export { default } from './plugin';
16
19
  export * from '../constants';
@@ -39,12 +39,15 @@ var server_exports = {};
39
39
  __export(server_exports, {
40
40
  AuthModel: () => import_authenticator.AuthModel,
41
41
  BasicAuth: () => import_basic_auth.BasicAuth,
42
+ appendAuthRedirectQuery: () => import_authRedirect.appendAuthRedirectQuery,
42
43
  buildRedirectPath: () => import_buildRedirectPath.buildRedirectPath,
43
44
  default: () => import_plugin.default,
44
45
  defaultTokenPolicyConfig: () => import_constants.defaultTokenPolicyConfig,
45
46
  getModernClientPrefix: () => import_buildRedirectPath.getModernClientPrefix,
46
47
  presetAuthType: () => import_preset.presetAuthType,
47
- resolveSigninPrefix: () => import_buildRedirectPath.resolveSigninPrefix
48
+ resolveAuthRedirect: () => import_authRedirect.resolveAuthRedirect,
49
+ resolveSigninPrefix: () => import_buildRedirectPath.resolveSigninPrefix,
50
+ resolveSubAppSegment: () => import_resolveSubAppSegment.resolveSubAppSegment
48
51
  });
49
52
  module.exports = __toCommonJS(server_exports);
50
53
  var import_basic_auth = require("./basic-auth");
@@ -52,16 +55,21 @@ var import_authenticator = require("./model/authenticator");
52
55
  var import_preset = require("../preset");
53
56
  var import_constants = require("../constants");
54
57
  var import_buildRedirectPath = require("./utils/buildRedirectPath");
58
+ var import_resolveSubAppSegment = require("./utils/resolveSubAppSegment");
59
+ var import_authRedirect = require("./utils/authRedirect");
55
60
  var import_plugin = __toESM(require("./plugin"));
56
61
  __reExport(server_exports, require("../constants"), module.exports);
57
62
  // Annotate the CommonJS export names for ESM import in node:
58
63
  0 && (module.exports = {
59
64
  AuthModel,
60
65
  BasicAuth,
66
+ appendAuthRedirectQuery,
61
67
  buildRedirectPath,
62
68
  defaultTokenPolicyConfig,
63
69
  getModernClientPrefix,
64
70
  presetAuthType,
71
+ resolveAuthRedirect,
65
72
  resolveSigninPrefix,
73
+ resolveSubAppSegment,
66
74
  ...require("../constants")
67
75
  });
@@ -26,6 +26,7 @@ export declare class TokenController implements TokenControlService {
26
26
  getConfig(): Promise<NumericTokenPolicyConfig>;
27
27
  setConfig(config: TokenPolicyConfig): Promise<void>;
28
28
  removeSessionExpiredTokens(userId: number): Promise<number>;
29
+ private cleanupSessionExpiredTokens;
29
30
  add({ userId, authenticator }: {
30
31
  userId: number;
31
32
  authenticator?: string;
@@ -93,6 +93,13 @@ class TokenController {
93
93
  }
94
94
  });
95
95
  }
96
+ async cleanupSessionExpiredTokens(userId) {
97
+ try {
98
+ await this.removeSessionExpiredTokens(userId);
99
+ } catch (err) {
100
+ this.logger.error(err, { module: "auth", submodule: "token-controller", method: "removeSessionExpiredTokens" });
101
+ }
102
+ }
96
103
  async add({ userId, authenticator }) {
97
104
  const jti = (0, import_crypto.randomUUID)();
98
105
  const currTS = Date.now();
@@ -105,14 +112,10 @@ class TokenController {
105
112
  authenticator
106
113
  };
107
114
  await this.setTokenInfo(jti, data);
108
- try {
109
- if (process.env.DB_DIALECT === "sqlite") {
110
- await this.removeSessionExpiredTokens(userId);
111
- } else {
112
- this.removeSessionExpiredTokens(userId);
113
- }
114
- } catch (err) {
115
- this.logger.error(err, { module: "auth", submodule: "token-controller", method: "removeSessionExpiredTokens" });
115
+ if (process.env.DB_DIALECT === "sqlite") {
116
+ await this.cleanupSessionExpiredTokens(userId);
117
+ } else {
118
+ this.cleanupSessionExpiredTokens(userId);
116
119
  }
117
120
  return data;
118
121
  }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { type OriginContext } from '@nocobase/utils';
10
+ import { type BuildRedirectPathOptions } from './buildRedirectPath';
11
+ export interface AuthRedirectOriginContext extends OriginContext {
12
+ t?(key: string, options?: {
13
+ ns?: string;
14
+ }): string;
15
+ throw(status: number, message: string): never;
16
+ }
17
+ /**
18
+ * Resolve an SSO callback target without creating an open redirect.
19
+ *
20
+ * Existing NocoBase clients use root-relative paths and still need the app
21
+ * public path/sub-app prefix handling provided by `buildRedirectPath`.
22
+ * Standalone Portal development runs on another origin, so an absolute target
23
+ * is also accepted when that origin is trusted by the server's CORS policy.
24
+ */
25
+ export declare function resolveAuthRedirect(ctx: AuthRedirectOriginContext, { appPublicPath, subAppSegment, target }: BuildRedirectPathOptions): {
26
+ safeRedirect: string;
27
+ target: string;
28
+ };
29
+ /** Append or replace callback parameters while preserving query and hash. */
30
+ export declare function appendAuthRedirectQuery(target: string, params: Record<string, string | number | boolean | null | undefined>): string;
@@ -0,0 +1,93 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var authRedirect_exports = {};
28
+ __export(authRedirect_exports, {
29
+ appendAuthRedirectQuery: () => appendAuthRedirectQuery,
30
+ resolveAuthRedirect: () => resolveAuthRedirect
31
+ });
32
+ module.exports = __toCommonJS(authRedirect_exports);
33
+ var import_utils = require("@nocobase/utils");
34
+ var import_preset = require("../../preset");
35
+ var import_buildRedirectPath = require("./buildRedirectPath");
36
+ function getInvalidOriginMessage(ctx) {
37
+ var _a;
38
+ return ((_a = ctx.t) == null ? void 0 : _a.call(ctx, "Invalid sign-in origin", { ns: import_preset.namespace })) || "Invalid sign-in origin";
39
+ }
40
+ function isRootRelativePath(value) {
41
+ return value.startsWith("/") && !value.startsWith("//") && !value.startsWith("/\\");
42
+ }
43
+ function isPortalPath(value, appPublicPath) {
44
+ const normalizedAppPublicPath = (appPublicPath || "").replace(/\/+$/, "");
45
+ const pathname = value.split(/[?#]/, 1)[0];
46
+ if (normalizedAppPublicPath && !pathname.startsWith(`${normalizedAppPublicPath}/`)) {
47
+ return false;
48
+ }
49
+ const pathnameWithinPublicPath = pathname.slice(normalizedAppPublicPath.length);
50
+ return pathnameWithinPublicPath === "/x" || pathnameWithinPublicPath.startsWith("/x/");
51
+ }
52
+ function resolveAbsoluteUrl(ctx, value) {
53
+ let url;
54
+ try {
55
+ url = new URL(value);
56
+ } catch {
57
+ ctx.throw(400, getInvalidOriginMessage(ctx));
58
+ }
59
+ if (!["http:", "https:"].includes(url.protocol) || url.username || url.password) {
60
+ ctx.throw(400, getInvalidOriginMessage(ctx));
61
+ }
62
+ const whitelist = (0, import_utils.getCorsWhitelist)();
63
+ if (!(0, import_utils.isSameOrigin)(ctx, url.origin) && !(whitelist == null ? void 0 : whitelist.has(url.origin))) {
64
+ ctx.throw(400, getInvalidOriginMessage(ctx));
65
+ }
66
+ return url;
67
+ }
68
+ function resolveSafeAuthRedirect(ctx, target) {
69
+ const value = typeof target === "string" ? target.trim() : "";
70
+ if (isRootRelativePath(value)) return value;
71
+ return value ? resolveAbsoluteUrl(ctx, value).toString() : null;
72
+ }
73
+ function resolveAuthRedirect(ctx, { appPublicPath, subAppSegment, target }) {
74
+ const safeRedirect = resolveSafeAuthRedirect(ctx, target) || "/admin";
75
+ const resolvedTarget = isRootRelativePath(safeRedirect) && !isPortalPath(safeRedirect, appPublicPath) ? (0, import_buildRedirectPath.buildRedirectPath)({ appPublicPath, subAppSegment, target: safeRedirect }) : safeRedirect;
76
+ return { safeRedirect, target: resolvedTarget };
77
+ }
78
+ function appendAuthRedirectQuery(target, params) {
79
+ const isAbsolute = /^[a-z][a-z\d+.-]*:/i.test(target);
80
+ const url = new URL(target, "http://nocobase.local");
81
+ for (const [key, value] of Object.entries(params)) {
82
+ if (value === void 0) {
83
+ continue;
84
+ }
85
+ url.searchParams.set(key, value === null ? "" : String(value));
86
+ }
87
+ return isAbsolute ? url.toString() : `${url.pathname}${url.search}${url.hash}`;
88
+ }
89
+ // Annotate the CommonJS export names for ESM import in node:
90
+ 0 && (module.exports = {
91
+ appendAuthRedirectQuery,
92
+ resolveAuthRedirect
93
+ });
@@ -48,8 +48,27 @@ function buildRedirectPath({ appPublicPath, subAppSegment, target }) {
48
48
  function getModernClientPrefix() {
49
49
  return String(process.env.APP_MODERN_CLIENT_PREFIX || "").trim().replace(/^\/+|\/+$/g, "") || "v";
50
50
  }
51
+ function resolveSettingsSigninPrefix(appPublicPath, redirect) {
52
+ if (typeof redirect !== "string") {
53
+ return null;
54
+ }
55
+ const [pathname] = redirect.split(/[?#]/, 1);
56
+ if (appPublicPath && pathname !== appPublicPath && !pathname.startsWith(`${appPublicPath}/`)) {
57
+ return null;
58
+ }
59
+ const pathnameWithinPublicPath = pathname.slice(appPublicPath.length);
60
+ const scopedMatch = pathnameWithinPublicPath.match(/^\/settings\/((?:apps|_app)\/[^/]+)(?:\/|$)/);
61
+ if (scopedMatch) {
62
+ return `${appPublicPath}/settings/${scopedMatch[1]}`;
63
+ }
64
+ return /^\/settings(?:\/|$)/.test(pathnameWithinPublicPath) ? `${appPublicPath}/settings` : null;
65
+ }
51
66
  function resolveSigninPrefix({ appPublicPath, redirect, subAppSegment }) {
52
67
  const normalizedAppPublicPath = (appPublicPath || "").replace(/\/+$/, "");
68
+ const settingsSigninPrefix = resolveSettingsSigninPrefix(normalizedAppPublicPath, redirect);
69
+ if (settingsSigninPrefix) {
70
+ return settingsSigninPrefix;
71
+ }
53
72
  const modernSegment = `/${getModernClientPrefix()}`;
54
73
  const modernMarker = `${normalizedAppPublicPath}${modernSegment}`;
55
74
  const isModernOrigin = typeof redirect === "string" && (redirect === modernMarker || redirect.startsWith(`${modernMarker}/`));
@@ -0,0 +1,17 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ /// <reference types="node" />
10
+ import type { IncomingMessage } from 'http';
11
+ /**
12
+ * Resolve the legacy sub-application URL segment for an authentication
13
+ * redirect. A sub-application reached through its custom domain is mounted at
14
+ * the root, while one reached through the supervisor domain uses
15
+ * `/apps/<name>`.
16
+ */
17
+ export declare function resolveSubAppSegment(req: IncomingMessage, appName?: string | null): Promise<string>;
@@ -0,0 +1,82 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var resolveSubAppSegment_exports = {};
28
+ __export(resolveSubAppSegment_exports, {
29
+ resolveSubAppSegment: () => resolveSubAppSegment
30
+ });
31
+ module.exports = __toCommonJS(resolveSubAppSegment_exports);
32
+ var import_server = require("@nocobase/server");
33
+ function normalizeHostname(value) {
34
+ const host = value == null ? void 0 : value.split(",", 1)[0].trim();
35
+ if (!host) {
36
+ return "";
37
+ }
38
+ try {
39
+ return new URL(`http://${host}`).hostname;
40
+ } catch {
41
+ return "";
42
+ }
43
+ }
44
+ function getRequestHostname(req) {
45
+ const hostnameHeader = req.headers["x-hostname"];
46
+ if (Array.isArray(hostnameHeader)) {
47
+ for (const value of hostnameHeader) {
48
+ const hostname = normalizeHostname(value);
49
+ if (hostname) {
50
+ return hostname;
51
+ }
52
+ }
53
+ } else {
54
+ const hostname = normalizeHostname(hostnameHeader);
55
+ if (hostname) {
56
+ return hostname;
57
+ }
58
+ }
59
+ return (0, import_server.getHostname)(req);
60
+ }
61
+ async function resolveSubAppSegment(req, appName) {
62
+ var _a;
63
+ if (!appName || appName === "main") {
64
+ return "";
65
+ }
66
+ const appSupervisor = import_server.AppSupervisor.getInstance();
67
+ if (!appSupervisor || appSupervisor.runningMode === "single") {
68
+ return "";
69
+ }
70
+ const hostname = getRequestHostname(req);
71
+ if (hostname) {
72
+ const cnameAppName = await ((_a = appSupervisor.getAppNameByCName) == null ? void 0 : _a.call(appSupervisor, hostname));
73
+ if (cnameAppName === appName) {
74
+ return "";
75
+ }
76
+ }
77
+ return `/apps/${appName}`;
78
+ }
79
+ // Annotate the CommonJS export names for ESM import in node:
80
+ 0 && (module.exports = {
81
+ resolveSubAppSegment
82
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-auth",
3
- "version": "2.3.0-alpha.1",
3
+ "version": "3.0.0-alpha.2",
4
4
  "main": "./dist/server/index.js",
5
5
  "homepage": "https://docs.nocobase.com/handbook/auth",
6
6
  "homepage.ru-RU": "https://docs-ru.nocobase.com/handbook/auth",
@@ -31,7 +31,7 @@
31
31
  "description": "User authentication management, including password, SMS, and support for Single Sign-On (SSO) protocols, with extensibility.",
32
32
  "description.ru-RU": "Управление аутентификацией пользователей: пароли, SMS, поддержка протоколов единого входа (SSO) и возможность расширения.",
33
33
  "description.zh-CN": "用户认证管理,包括基础的密码认证、短信认证、SSO 协议的认证等,可扩展。",
34
- "gitHead": "2377df8ceb12549149017f7f14a61207bf6e49a2",
34
+ "gitHead": "a3faea21082b30989301de04591ee1b91fd4e6a5",
35
35
  "keywords": [
36
36
  "Authentication",
37
37
  "Security"
@@ -1,10 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
-
10
- "use strict";(self.webpackChunk_nocobase_plugin_auth_client_v2=self.webpackChunk_nocobase_plugin_auth_client_v2||[]).push([["217"],{264:function(e,t,n){n.r(t),n.d(t,{default:function(){return g}});var r=n(485),a=n(694),l=n(6),i=n(59),o=n(155),u=n.n(o),s=n(442),c=n(488);function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function f(e,t,n,r,a,l,i){try{var o=e[l](i),u=o.value}catch(e){n(e);return}o.done?t(u):Promise.resolve(u).then(r,a)}function d(e,t){if(e){if("string"==typeof e)return m(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return m(e,t)}}var p=["$env"];function h(e){var t,n=(0,c.dE)().t,s=(0,c.kj)(),f=(t=(0,a.useFlowContext)(),(0,o.useMemo)(function(){var e,n,r,a,l=null==(r=t.dataSourceManager)||null==(n=r.getCollection)?void 0:n.call(r,"main","users");return(null!=(e=null==l||null==(a=l.getFields)?void 0:a.call(l))?e:[]).filter(function(e){var t,n;return e&&!(null==(t=e.options)?void 0:t.hidden)&&!e.target&&e.interface&&!(null==(n=e.uiSchema)?void 0:n["x-read-pretty"])})},[t])),p=(0,o.useMemo)(function(){var t;return null!=(t=e.value)?t:[]},[e.value]),h=(0,o.useMemo)(function(){var e=new Set(f.map(function(e){return e.name})),t=p.filter(function(t){return e.has(t.field)}),n=new Set(t.map(function(e){return e.field})),r=!0,a=!1,l=void 0;try{for(var i,o=f[Symbol.iterator]();!(r=(i=o.next()).done);r=!0){var u=i.value;n.has(u.name)||t.push({field:u.name,show:"username"===u.name,required:"username"===u.name})}}catch(e){a=!0,l=e}finally{try{r||null==o.return||o.return()}finally{if(a)throw l}}return t},[f,p]);u().useEffect(function(){var t;p.length===h.length&&p.every(function(e,t){return e.field===h[t].field&&!!e.show==!!h[t].show&&!!e.required==!!h[t].required})||null==(t=e.onChange)||t.call(e,h)},[h]);var y=(0,l.useMemoizedFn)(function(t,n){var r,a=h.map(function(e){if(e.field!==t)return e;var r=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},e,n);return r.required&&(r.show=!0),r.show||(r.required=!1),r});null==(r=e.onChange)||r.call(e,a)}),b=(0,l.useMemoizedFn)(function(e){var t,n,r=f.find(function(t){return t.name===e});return s((null==r||null==(t=r.uiSchema)?void 0:t.title)||(null==r||null==(n=r.options)?void 0:n.title)||e)}),g=(0,o.useMemo)(function(){return[{title:n("Field"),dataIndex:"field",width:200,render:function(e){return u().createElement(i.Tag,null,b(e))}},{title:n("Show"),dataIndex:"show",width:80,align:"center",render:function(e,t){return u().createElement(i.Checkbox,{checked:!!t.show,onChange:function(e){return y(t.field,{show:e.target.checked})}})}},{title:n("Required"),dataIndex:"required",width:80,align:"center",render:function(e,t){return u().createElement(i.Checkbox,{checked:!!t.required,onChange:function(e){return y(t.field,{required:e.target.checked})}})}},{title:"",dataIndex:"_filler",render:function(){return null}}]},[b,n,y]),v=(0,l.useMemoizedFn)(function(t,n){var r,a=h.findIndex(function(e){return e.field===t.field}),l=h.findIndex(function(e){return e.field===n.field});if(!(a<0)&&!(l<0)&&a!==l){var i,o=function(e){if(Array.isArray(e))return m(e)}(h)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(h)||d(h)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),u=(function(e){if(Array.isArray(e))return e}(i=o.splice(a,1))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var a=[],l=!0,i=!1;try{for(r=r.call(e);!(l=(t=r.next()).done)&&(a.push(t.value),1!==a.length);l=!0);}catch(e){i=!0,n=e}finally{try{l||null==r.return||r.return()}finally{if(i)throw n}}return a}}(i)||d(i,1)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0];o.splice(l,0,u),null==(r=e.onChange)||r.call(e,o)}});return u().createElement(r.Table,{rowKey:"field",pagination:!1,columns:g,dataSource:h,isDraggable:!0,onSortEnd:v,sortHandleColumnWidth:32,showIndex:!1})}function y(){var e=(0,c.dE)().t;return u().createElement(u().Fragment,null,u().createElement(i.Form.Item,{name:["options","public","allowSignUp"],label:e("Allow to sign up"),valuePropName:"checked",initialValue:!0},u().createElement(i.Checkbox,null)),u().createElement(i.Form.Item,{label:e("Sign up form"),name:["options","public","signupForm"],validateFirst:!0},u().createElement(h,null)))}function b(){var e,t,n,m=(0,c.dE)().t,d=i.Form.useFormInstance(),h=i.Form.useWatch(["options","public","enableResetPassword"],d),y=i.Form.useWatch(["options","emailContentType"],d)||"html",b=(e=(0,c.dE)().t,(0,o.useMemo)(function(){return[{name:"$user",title:e("Current user"),type:"object",paths:["$user"],children:[{name:"username",title:e("Username"),type:"string",paths:["$user","username"]},{name:"nickname",title:e("Nickname"),type:"string",paths:["$user","nickname"]},{name:"email",title:e("Email"),type:"string",paths:["$user","email"]}]},{name:"$systemSettings",title:e("System settings"),type:"object",paths:["$systemSettings"],children:[{name:"title",title:e("System title"),type:"string",paths:["$systemSettings","title"]},{name:"logo",title:e("System logo"),type:"string",paths:["$systemSettings","logo"]}]},{name:"$resetLink",title:e("Reset password link"),type:"string",paths:["$resetLink"]},{name:"$resetLinkExpiration",title:e("Reset link expiration (minutes)"),type:"string",paths:["$resetLinkExpiration"]}]},[e])),g=(t=!!h,n=(0,a.useFlowContext)(),(0,l.useRequest)(function(){var e;return(e=function(){var e,t,r,a;return function(e,t){var n,r,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),o=Object.defineProperty;return o(i,"next",{value:u(0)}),o(i,"throw",{value:u(1)}),o(i,"return",{value:u(2)}),"function"==typeof Symbol&&o(i,Symbol.iterator,{value:function(){return this}}),i;function u(o){return function(u){var s=[o,u];if(n)throw TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(l=0)),l;)try{if(n=1,r&&(a=2&s[0]?r.return:s[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,s[1])).done)return a;switch(r=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return l.label++,{value:s[1],done:!1};case 5:l.label++,r=s[1],s=[0];continue;case 7:s=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===s[0]||2===s[0])){l=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){l.label=s[1];break}if(6===s[0]&&l.label<a[1]){l.label=a[1],a=s;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(s);break}a[2]&&l.ops.pop(),l.trys.pop();continue}s=t.call(e,l)}catch(e){s=[6,e],r=0}finally{n=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}}(this,function(l){switch(l.label){case 0:return[4,n.api.resource("notificationChannels").list({filter:{notificationType:"email"},pageSize:50})];case 1:return[2,Array.isArray(a=null!=(e=null==(r=l.sent())||null==(t=r.data)?void 0:t.data)?e:null==r?void 0:r.data)?a:[]]}})},function(){var t=this,n=arguments;return new Promise(function(r,a){var l=e.apply(t,n);function i(e){f(l,r,a,i,o,"next",e)}function o(e){f(l,r,a,i,o,"throw",e)}i(void 0)})})()},{ready:t,cacheKey:"@nocobase/plugin-auth:notificationChannels:email",refreshDeps:[t]})),v=g.data,E=g.loading,w=(0,o.useMemo)(function(){return(v||[]).map(function(e){return{label:e.title,value:e.name}})},[v]);return u().createElement(u().Fragment,null,u().createElement(i.Form.Item,{name:["options","public","enableResetPassword"],label:m("Enable forget password"),valuePropName:"checked",initialValue:!1},u().createElement(i.Checkbox,null)),h?u().createElement(u().Fragment,null,u().createElement(i.Typography.Title,{level:5,style:{marginTop:0}},m("1. Select notification channel")),u().createElement(i.Form.Item,{name:["options","notificationChannel"],label:m("Notification channel (Email)"),extra:m("The notification channel used to send the reset password email, only support email channel"),rules:[{required:!0,message:m("Please select a notification channel")}]},u().createElement(i.Select,{loading:E,options:w,placeholder:m("Select"),notFoundContent:u().createElement("span",null,m("No notification channels found. Please "),u().createElement(s.Link,{to:"/admin/settings/notification-manager/channels"},m("add one first")),".")})),u().createElement(i.Typography.Title,{level:5},m("2. Configure reset email")),u().createElement(i.Form.Item,{name:["options","emailSubject"],label:m("Subject"),rules:[{required:!0,message:m("Please enter the email subject")}],initialValue:m("defaultResetPasswordEmailSubject")},u().createElement(r.VariableInput,{namespaces:p,extraNodes:b})),u().createElement(i.Form.Item,{name:["options","emailContentType"],label:m("Content type"),initialValue:"html",rules:[{required:!0}]},u().createElement(i.Radio.Group,{options:[{label:"HTML",value:"html"},{label:m("Plain text"),value:"text"}]})),"html"===y?u().createElement(i.Form.Item,{key:"html",name:["options","emailContentHTML"],label:m("Content"),rules:[{required:!0,message:m("Please enter the email content")}],initialValue:m("defaultResetPasswordEmailContentHTML")},u().createElement(r.VariableTextArea,{namespaces:p,extraNodes:b,placeholder:"Hi,",rows:10})):u().createElement(i.Form.Item,{key:"text",name:["options","emailContentText"],label:m("Content"),rules:[{required:!0,message:m("Please enter the email content")}],initialValue:m("defaultResetPasswordEmailContentText")},u().createElement(r.VariableTextArea,{namespaces:p,extraNodes:b,rows:10})),u().createElement(i.Form.Item,{name:["options","resetTokenExpiresIn"],label:m("Reset link expiration"),initialValue:120,rules:[{required:!0,message:m("Please enter the expiration in minutes")}]},u().createElement(i.InputNumber,{min:1,addonAfter:m("Minutes"),style:{width:"100%"}}))):null)}function g(){var e=(0,c.dE)().t;return u().createElement("div",null,u().createElement(i.Alert,{style:{marginBottom:16},type:"info",showIcon:!0,message:e("The authentication allows users to sign in via username or email.")}),u().createElement(i.Tabs,{items:[{key:"signup",label:e("Sign up settings"),forceRender:!0,children:u().createElement(y,null)},{key:"forgot",label:e("Forgot password"),forceRender:!0,children:u().createElement(b,null)}]}))}}}]);
@@ -1,10 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
-
10
- "use strict";(self.webpackChunk_nocobase_plugin_auth_client_v2=self.webpackChunk_nocobase_plugin_auth_client_v2||[]).push([["795"],{918:function(e,t,r){r.r(t),r.d(t,{default:function(){return f}});var n=r(59),a=r(155),o=r.n(a),l=r(442),u=r(488),i=r(824);function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function c(e,t,r,n,a,o,l){try{var u=e[o](l),i=u.value}catch(e){r(e);return}u.done?t(i):Promise.resolve(i).then(n,a)}function m(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var o=[],l=!0,u=!1;try{for(a=a.call(e);!(l=(r=a.next()).done)&&(o.push(r.value),!t||o.length!==t);l=!0);}catch(e){u=!0,n=e}finally{try{l||null==a.return||a.return()}finally{if(u)throw n}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return s(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return s(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e){var t,r,s=e.authenticator,f=(0,u.dE)().t,p=m(n.Form.useForm(),1)[0],y=m((0,a.useState)(""),2),d=y[0],v=y[1],h=m((0,a.useState)(!1),2),b=h[0],g=h[1],w=(0,i.go)(s.name),E=!!(null==s||null==(t=s.options)?void 0:t.allowSignUp),P=!!(null==s||null==(r=s.options)?void 0:r.enableResetPassword);return o().createElement(n.Form,{form:p,layout:"vertical",onFinish:function(e){var t;return(t=function(){var t,r,n,a,o;return function(e,t){var r,n,a,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(l,"next",{value:i(0)}),u(l,"throw",{value:i(1)}),u(l,"return",{value:i(2)}),"function"==typeof Symbol&&u(l,Symbol.iterator,{value:function(){return this}}),l;function i(u){return function(i){var s=[u,i];if(r)throw TypeError("Generator is already executing.");for(;l&&(l=0,s[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&s[0]?n.return:s[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,s[1])).done)return a;switch(n=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(a=(a=o.trys).length>0&&a[a.length-1])&&(6===s[0]||2===s[0])){o=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){o.label=s[1];break}if(6===s[0]&&o.label<a[1]){o.label=a[1],a=s;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(s);break}a[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}}(this,function(l){switch(l.label){case 0:v(""),g(!0),l.label=1;case 1:return l.trys.push([1,3,4,5]),[4,w.run(e)];case 2:return l.sent(),[3,5];case 3:return v((null==(t=l.sent())||null==(o=t.response)||null==(a=o.data)||null==(n=a.errors)||null==(r=n[0])?void 0:r.message)||(null==t?void 0:t.message)||String(t)),[3,5];case 4:return g(!1),[7];case 5:return[2]}})},function(){var e=this,r=arguments;return new Promise(function(n,a){var o=t.apply(e,r);function l(e){c(o,n,a,l,u,"next",e)}function u(e){c(o,n,a,l,u,"throw",e)}l(void 0)})})()}},d?o().createElement(n.Alert,{style:{marginBottom:16},type:"error",showIcon:!0,message:d}):null,o().createElement(n.Form.Item,{name:"account",rules:[{required:!0,message:f("Please enter your username or email")},{validator:function(e,t){return t?String(t).includes("@")?/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(String(t))?Promise.resolve():Promise.reject(Error(f("Please enter a valid email"))):/^[^@<>"'/]{1,50}$/.test(String(t))?Promise.resolve():Promise.reject(Error(f("Please enter a valid username"))):Promise.resolve()}}]},o().createElement(n.Input,{autoComplete:"username",placeholder:f("Username/Email")})),o().createElement(n.Form.Item,{name:"password",rules:[{required:!0,message:f("Please enter a password")}]},o().createElement(n.Input.Password,{autoComplete:"current-password",placeholder:f("Password")})),o().createElement(n.Form.Item,{style:{marginBottom:12}},o().createElement(n.Button,{loading:b,htmlType:"submit",type:"primary",block:!0},f("Sign in"))),o().createElement("div",{style:{display:"flex",justifyContent:"space-between",gap:12}},E?o().createElement(l.Link,{to:"/signup?name=".concat(s.name)},f("Create an account")):null,P?o().createElement(l.Link,{to:"/forgot-password?name=".concat(s.name)},f("Forgot password")):null))}}}]);
@@ -1,10 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
-
10
- "use strict";(self.webpackChunk_nocobase_plugin_auth_client_v2=self.webpackChunk_nocobase_plugin_auth_client_v2||[]).push([["841"],{720:function(e,t,r){r.r(t),r.d(t,{default:function(){return h}});var n=r(59),a=r(155),l=r.n(a),o=r(442),u=r(230),i=r(953),s=r(485),c=r(488),m=r(295);function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function f(e,t,r,n,a,l,o){try{var u=e[l](o),i=u.value}catch(e){r(e);return}u.done?t(i):Promise.resolve(i).then(n,a)}function d(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,u=!1;try{for(a=a.call(e);!(o=(r=a.next()).done)&&(l.push(r.value),!t||l.length!==t);o=!0);}catch(e){u=!0,n=e}finally{try{o||null==a.return||a.return()}finally{if(u)throw n}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return p(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return p(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(e){var t,r=e.authenticatorName,p=(0,s.useApp)(),h=(0,o.useNavigate)(),v=(0,c.dE)().t,y=(0,i.useTranslation)("lm-collections").t,b=(0,m.p)(r),g=d(n.Form.useForm(),1)[0],w=d((0,a.useState)(!1),2),E=w[0],S=w[1],k=d((0,a.useState)(""),2),I=k[0],x=k[1],P=(0,a.useMemo)(function(){var e;return((null==b||null==(e=b.options)?void 0:e.signupForm)||[]).filter(function(e){return null==e?void 0:e.show})},[b]);return(null==b||null==(t=b.options)?void 0:t.allowSignUp)?l().createElement(n.Form,{form:g,layout:"vertical",onFinish:function(e){var t;return(t=function(){var t,a,l,o,u;return function(e,t){var r,n,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(o,"next",{value:i(0)}),u(o,"throw",{value:i(1)}),u(o,"return",{value:i(2)}),"function"==typeof Symbol&&u(o,Symbol.iterator,{value:function(){return this}}),o;function i(u){return function(i){var s=[u,i];if(r)throw TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(l=0)),l;)try{if(r=1,n&&(a=2&s[0]?n.return:s[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,s[1])).done)return a;switch(n=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return l.label++,{value:s[1],done:!1};case 5:l.label++,n=s[1],s=[0];continue;case 7:s=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===s[0]||2===s[0])){l=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){l.label=s[1];break}if(6===s[0]&&l.label<a[1]){l.label=a[1],a=s;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(s);break}a[2]&&l.ops.pop(),l.trys.pop();continue}s=t.call(e,l)}catch(e){s=[6,e],n=0}finally{r=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}}(this,function(i){switch(i.label){case 0:x(""),S(!0),i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,p.apiClient.auth.signUp(e,r)];case 2:return i.sent(),n.message.success(v("Sign up successfully, and automatically jump to the sign in page")),window.setTimeout(function(){h("/signin",{replace:!0})},2e3),[3,5];case 3:return x((null==(t=i.sent())||null==(u=t.response)||null==(o=u.data)||null==(l=o.errors)||null==(a=l[0])?void 0:a.message)||(null==t?void 0:t.message)||String(t)),[3,5];case 4:return S(!1),[7];case 5:return[2]}})},function(){var e=this,r=arguments;return new Promise(function(n,a){var l=t.apply(e,r);function o(e){f(l,n,a,o,u,"next",e)}function u(e){f(l,n,a,o,u,"throw",e)}o(void 0)})})()}},I?l().createElement(n.Alert,{style:{marginBottom:16},type:"error",showIcon:!0,message:I}):null,P.map(function(e){var t,r,a,o,i,s;return a=(r=(null==e?void 0:e.uiSchema)||{})["x-component"],o=r.title?y(u.Schema.compile(r.title,{t:v})):e.field,i=[],e.required&&i.push({required:!0,message:v("Please enter ".concat(e.field))}),"email"===e.field&&i.push({type:"email",message:v("Please enter a valid email address")}),s=l().createElement(n.Input,null),(null==(t=r.enum)?void 0:t.length)?s=l().createElement(n.Select,{options:r.enum.map(function(e){return{label:e.label||e.value,value:e.value}})}):"Checkbox"===a?s=l().createElement(n.Checkbox,null):("Input.TextArea"===a||"TextArea"===a)&&(s=l().createElement(n.Input.TextArea,{rows:4})),l().createElement(n.Form.Item,{key:e.field,name:e.field,label:o,valuePropName:"Checkbox"===a?"checked":"value",rules:i},s)}),l().createElement(n.Form.Item,{label:v("Password"),name:"password",rules:[{required:!0,message:v("Please enter a password")}]},l().createElement(n.Input.Password,{autoComplete:"new-password"})),l().createElement(n.Form.Item,{label:v("Confirm password"),name:"confirm_password",dependencies:["password"],rules:[{required:!0,message:v("Please enter the same password again")},function(e){var t=e.getFieldValue;return{validator:function(e,r){return r&&t("password")!==r?Promise.reject(Error(v("The passwords entered twice are inconsistent"))):Promise.resolve()}}}]},l().createElement(n.Input.Password,{autoComplete:"new-password"})),l().createElement(n.Form.Item,{style:{marginBottom:12}},l().createElement(n.Button,{loading:E,htmlType:"submit",type:"primary",block:!0},v("Sign up"))),l().createElement(o.Link,{to:"/signin"},v("Log in with an existing account"))):l().createElement(o.Navigate,{to:"/not-found",replace:!0})}}}]);