@tachybase/module-auth 0.23.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +14 -0
- package/README.md +117 -0
- package/client.d.ts +2 -0
- package/client.js +65 -0
- package/dist/client/AuthProvider.d.ts +2 -0
- package/dist/client/authenticator.d.ts +12 -0
- package/dist/client/basic/Options.d.ts +2 -0
- package/dist/client/basic/SignInForm.d.ts +9 -0
- package/dist/client/basic/SignUpForm.d.ts +13 -0
- package/dist/client/basic/index.d.ts +3 -0
- package/dist/client/bind/AuthenticatorBind.d.ts +2 -0
- package/dist/client/bind/BindForm.d.ts +5 -0
- package/dist/client/bind/schemas/authenticators.d.ts +2 -0
- package/dist/client/index.d.ts +30 -0
- package/dist/client/index.js +22 -0
- package/dist/client/locale/index.d.ts +2 -0
- package/dist/client/pages/AuthLayout.d.ts +2 -0
- package/dist/client/pages/SignInPage.d.ts +13 -0
- package/dist/client/pages/SignUpPage.d.ts +20 -0
- package/dist/client/pages/index.d.ts +3 -0
- package/dist/client/settings/Authenticator.d.ts +2 -0
- package/dist/client/settings/Options.d.ts +4 -0
- package/dist/client/settings/authType.d.ts +15 -0
- package/dist/client/settings/schemas/authenticators.d.ts +3 -0
- package/dist/externalVersion.js +16 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +40 -0
- package/dist/locale/en-US.json +31 -0
- package/dist/locale/ko_KR.json +26 -0
- package/dist/locale/zh-CN.json +31 -0
- package/dist/node_modules/cron/LICENSE +8 -0
- package/dist/node_modules/cron/dist/constants.d.ts +74 -0
- package/dist/node_modules/cron/dist/constants.js +78 -0
- package/dist/node_modules/cron/dist/errors.d.ts +5 -0
- package/dist/node_modules/cron/dist/errors.js +13 -0
- package/dist/node_modules/cron/dist/index.d.ts +6 -0
- package/dist/node_modules/cron/dist/index.js +1 -0
- package/dist/node_modules/cron/dist/job.d.ts +30 -0
- package/dist/node_modules/cron/dist/job.js +222 -0
- package/dist/node_modules/cron/dist/time.d.ts +33 -0
- package/dist/node_modules/cron/dist/time.js +444 -0
- package/dist/node_modules/cron/dist/types/cron.types.d.ts +50 -0
- package/dist/node_modules/cron/dist/types/cron.types.js +3 -0
- package/dist/node_modules/cron/dist/types/utils.d.ts +3 -0
- package/dist/node_modules/cron/dist/types/utils.js +3 -0
- package/dist/node_modules/cron/dist/utils.d.ts +2 -0
- package/dist/node_modules/cron/dist/utils.js +8 -0
- package/dist/node_modules/cron/package.json +1 -0
- package/dist/preset.d.ts +3 -0
- package/dist/preset.js +34 -0
- package/dist/server/actions/auth.d.ts +8 -0
- package/dist/server/actions/auth.js +40 -0
- package/dist/server/actions/authenticators.d.ts +10 -0
- package/dist/server/actions/authenticators.js +153 -0
- package/dist/server/basic-auth.d.ts +10 -0
- package/dist/server/basic-auth.js +176 -0
- package/dist/server/collections/authenticators.d.ts +5 -0
- package/dist/server/collections/authenticators.js +117 -0
- package/dist/server/collections/token-blacklist.d.ts +2 -0
- package/dist/server/collections/token-blacklist.js +42 -0
- package/dist/server/collections/users-authenticators.d.ts +6 -0
- package/dist/server/collections/users-authenticators.js +85 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.js +42 -0
- package/dist/server/locale/en-US.d.ts +9 -0
- package/dist/server/locale/en-US.js +30 -0
- package/dist/server/locale/fr-FR.d.ts +9 -0
- package/dist/server/locale/fr-FR.js +30 -0
- package/dist/server/locale/index.d.ts +3 -0
- package/dist/server/locale/index.js +43 -0
- package/dist/server/locale/ja-JP.d.ts +5 -0
- package/dist/server/locale/ja-JP.js +26 -0
- package/dist/server/locale/pt-BR.d.ts +9 -0
- package/dist/server/locale/pt-BR.js +30 -0
- package/dist/server/locale/zh-CN.d.ts +11 -0
- package/dist/server/locale/zh-CN.js +32 -0
- package/dist/server/migrations/20230506152253-basic-authenticator.d.ts +6 -0
- package/dist/server/migrations/20230506152253-basic-authenticator.js +44 -0
- package/dist/server/migrations/20230607174500-update-basic.d.ts +6 -0
- package/dist/server/migrations/20230607174500-update-basic.js +47 -0
- package/dist/server/migrations/20231218132032-fix-allow-signup.d.ts +6 -0
- package/dist/server/migrations/20231218132032-fix-allow-signup.js +55 -0
- package/dist/server/model/authenticator.d.ts +10 -0
- package/dist/server/model/authenticator.js +81 -0
- package/dist/server/plugin.d.ts +11 -0
- package/dist/server/plugin.js +132 -0
- package/dist/server/storer.d.ts +16 -0
- package/dist/server/storer.js +69 -0
- package/dist/server/token-blacklist.d.ts +17 -0
- package/dist/server/token-blacklist.js +86 -0
- package/dist/swagger/index.d.ts +754 -0
- package/dist/swagger/index.js +787 -0
- package/package.json +34 -0
- package/server.d.ts +2 -0
- package/server.js +65 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
> @tachybase/module-auth@0.23.2 build /Users/seal/Documents/projects/tachybase/packages/module-auth
|
|
4
|
+
> tachybase-build --no-dts @tachybase/module-auth
|
|
5
|
+
|
|
6
|
+
[33m[33mThe CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.[39m[39m
|
|
7
|
+
[4m[95m@tachybase/module-auth[39m[24m: [1mmodule-auth[22m build start
|
|
8
|
+
[4m[95m@tachybase/module-auth[39m[24m: build plugin client
|
|
9
|
+
[2K[1G[2K[1G[2K[1G[2K[1G[4m[95m@tachybase/module-auth[39m[24m: build plugin server source
|
|
10
|
+
[4m[95m@tachybase/module-auth[39m[24m: delete server files
|
|
11
|
+
[4m[95m@tachybase/module-auth[39m[24m: build plugin server dependencies
|
|
12
|
+
[4m[95m@tachybase/module-auth[39m[24m: These packages [33mcron[39m will be [3mbundled[23m to dist/node_modules. These packages [33m@tachybase/auth, @tachybase/database, @tachybase/cache, @tachybase/server, @tachybase/actions[39m will be [3mexclude[23m.
|
|
13
|
+
[4m[95m@tachybase/module-auth[39m[24m: write external version
|
|
14
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Auth
|
|
2
|
+
|
|
3
|
+
提供基础认证功能和扩展认证器管理功能。
|
|
4
|
+
|
|
5
|
+
## 使用方法
|
|
6
|
+
|
|
7
|
+
### 认证器管理
|
|
8
|
+
页面:应用配置 - 认证
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
<img src="https://s2.loli.net/2023/05/15/NdriQZvBuE6hGRS.png" width="800px" />
|
|
12
|
+
|
|
13
|
+
#### 内置认证器
|
|
14
|
+
- 名称:basic
|
|
15
|
+
- 认证类型:邮箱密码登录
|
|
16
|
+
|
|
17
|
+
<img src="https://s2.loli.net/2023/05/15/HC4gtx9fQPrqvac.png" width="300px" />
|
|
18
|
+
|
|
19
|
+
<img src="https://s2.loli.net/2023/05/15/fcLqypdhOxnksbg.png" width="300px" />
|
|
20
|
+
|
|
21
|
+
#### 增加认证器
|
|
22
|
+
Add new - 选择认证类型
|
|
23
|
+
|
|
24
|
+
<img src="https://s2.loli.net/2023/05/15/CR7UTDt2WzbEfgs.png" width="300px" />
|
|
25
|
+
|
|
26
|
+
#### 启用/禁用
|
|
27
|
+
Actions - Edit - 勾选/取消Enabled
|
|
28
|
+
|
|
29
|
+
<img src="https://s2.loli.net/2023/05/15/2utpSHly9fzCKX5.png" width="400px" />
|
|
30
|
+
|
|
31
|
+
#### 配置认证器
|
|
32
|
+
Actions - Edit
|
|
33
|
+
|
|
34
|
+
## 开发一个登录插件
|
|
35
|
+
### 接口
|
|
36
|
+
Tachybase内核提供了扩展登录方式的接入和管理。扩展登录插件的核心逻辑处理,需要继承内核的`Auth`类,并对相应的标准接口进行实现。
|
|
37
|
+
参考`core/auth/auth.ts`
|
|
38
|
+
|
|
39
|
+
```TypeScript
|
|
40
|
+
import { Auth } from '@tachybase/auth';
|
|
41
|
+
|
|
42
|
+
class CustomAuth extends Auth {
|
|
43
|
+
set user(user) {}
|
|
44
|
+
get user() {}
|
|
45
|
+
|
|
46
|
+
async check() {}
|
|
47
|
+
async signIn() {}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
多数情况下,扩展的用户登录方式也将沿用现有的jwt逻辑来生成用户访问API的凭证,插件也可以继承`BaseAuth`类以便复用部分逻辑代码,如`check`, `signIn`接口。
|
|
52
|
+
|
|
53
|
+
```TypeScript
|
|
54
|
+
import { BaseAuth } from '@tachybase/auth';
|
|
55
|
+
|
|
56
|
+
class CustomAuth extends BaseAuth {
|
|
57
|
+
constructor(config: AuthConfig) {
|
|
58
|
+
const userCollection = config.ctx.db.getCollection('users');
|
|
59
|
+
super({ ...config, userCollection });
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async validate() {}
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 用户数据
|
|
67
|
+
|
|
68
|
+
`@tachybase/module-auth`插件提供了`usersAuthenticators`表来建立users和authenticators,即用户和认证方式的关联。
|
|
69
|
+
通常情况下,扩展登录方式用`users`和`usersAuthenticators`来存储相应的用户数据即可,特殊情况下才需要自己新增Collection.
|
|
70
|
+
`users`存储的是最基础的用户数据,邮箱、昵称和密码。
|
|
71
|
+
`usersAuthenticators`存储扩展登录方式数据
|
|
72
|
+
- uuid: 该种认证方式的用户唯一标识,如手机号、微信openid等
|
|
73
|
+
- meta: JSON字段,其他需要保存的信息
|
|
74
|
+
- userId: 用户id
|
|
75
|
+
- authenticator:认证器名字
|
|
76
|
+
|
|
77
|
+
对于用户操作,`Authenticator`模型也提供了几个封装的方法,可以在`CustomAuth`类中通过`this.authenticator[方法名]`使用:
|
|
78
|
+
- `findUser(uuid: string): UserModel` - 查询用户
|
|
79
|
+
- `newUser(uuid: string, values?: any): UserModel` - 创建新用户
|
|
80
|
+
- `findOrCreateUser(uuid: string, userValues?: any): UserModel` - 查找或创建新用户
|
|
81
|
+
|
|
82
|
+
### 注册
|
|
83
|
+
扩展的登录方式需要向内核注册。
|
|
84
|
+
```TypeScript
|
|
85
|
+
async load() {
|
|
86
|
+
this.app.authManager.registerTypes('custom-auth-type', {
|
|
87
|
+
auth: CustomAuth,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 客户端API
|
|
93
|
+
#### OptionsComponentProvider
|
|
94
|
+
可供用户配置的认证器配置项
|
|
95
|
+
- authType 认证方式
|
|
96
|
+
- component 配置组件
|
|
97
|
+
```TypeScript
|
|
98
|
+
<OptionsComponentProvider authType="custom-auth-type" component={Options} />
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
`Options`组件使用的值是`authenticator`的`options`字段,如果有需要暴露在前端的配置,应该放在`options.public`字段中。`authenticators:publicList`接口会返回`options.public`字段的值。
|
|
102
|
+
|
|
103
|
+
#### SigninPageProvider
|
|
104
|
+
自定义登录页界面
|
|
105
|
+
- authType 认证方式
|
|
106
|
+
- tabTitle 登录页tab标题
|
|
107
|
+
- component 登录页组件
|
|
108
|
+
|
|
109
|
+
#### SignupPageProvider
|
|
110
|
+
自定义注册页界面
|
|
111
|
+
- authType 认证方式
|
|
112
|
+
- component 注册页组件
|
|
113
|
+
|
|
114
|
+
#### SigninPageExtensionProvider
|
|
115
|
+
自定义登录页下方的扩展内容
|
|
116
|
+
- authType 认证方式
|
|
117
|
+
- component 扩展组件
|
package/client.d.ts
ADDED
package/client.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
4
|
+
if (typeof WeakMap !== 'function') return null;
|
|
5
|
+
var cacheBabelInterop = new WeakMap();
|
|
6
|
+
var cacheNodeInterop = new WeakMap();
|
|
7
|
+
return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) {
|
|
8
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
9
|
+
})(nodeInterop);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
13
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
14
|
+
return obj;
|
|
15
|
+
}
|
|
16
|
+
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
|
17
|
+
return { default: obj };
|
|
18
|
+
}
|
|
19
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
20
|
+
if (cache && cache.has(obj)) {
|
|
21
|
+
return cache.get(obj);
|
|
22
|
+
}
|
|
23
|
+
var newObj = {};
|
|
24
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
25
|
+
for (var key in obj) {
|
|
26
|
+
if (key !== 'default' && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
27
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
28
|
+
if (desc && (desc.get || desc.set)) {
|
|
29
|
+
Object.defineProperty(newObj, key, desc);
|
|
30
|
+
} else {
|
|
31
|
+
newObj[key] = obj[key];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
newObj.default = obj;
|
|
36
|
+
if (cache) {
|
|
37
|
+
cache.set(obj, newObj);
|
|
38
|
+
}
|
|
39
|
+
return newObj;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
var _index = _interopRequireWildcard(require('./dist/client'));
|
|
43
|
+
|
|
44
|
+
Object.defineProperty(exports, '__esModule', {
|
|
45
|
+
value: true,
|
|
46
|
+
});
|
|
47
|
+
var _exportNames = {};
|
|
48
|
+
Object.defineProperty(exports, 'default', {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function get() {
|
|
51
|
+
return _index.default;
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
Object.keys(_index).forEach(function (key) {
|
|
56
|
+
if (key === 'default' || key === '__esModule') return;
|
|
57
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
58
|
+
if (key in exports && exports[key] === _index[key]) return;
|
|
59
|
+
Object.defineProperty(exports, key, {
|
|
60
|
+
enumerable: true,
|
|
61
|
+
get: function get() {
|
|
62
|
+
return _index[key];
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type Authenticator = {
|
|
2
|
+
name: string;
|
|
3
|
+
authType: string;
|
|
4
|
+
authTypeTitle: string;
|
|
5
|
+
title?: string;
|
|
6
|
+
options?: {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
};
|
|
9
|
+
sort?: number;
|
|
10
|
+
};
|
|
11
|
+
export declare const AuthenticatorsContext: import("react").Context<Authenticator[]>;
|
|
12
|
+
export declare const useAuthenticator: (name: string) => Authenticator;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Authenticator } from '../authenticator';
|
|
3
|
+
export declare function useRedirect(next?: string): () => void;
|
|
4
|
+
export declare const useSignIn: (authenticator: string) => {
|
|
5
|
+
run(): Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
export declare const SignInForm: (props: {
|
|
8
|
+
authenticator: Authenticator;
|
|
9
|
+
}) => React.JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface UseSignupProps {
|
|
3
|
+
authenticator?: string;
|
|
4
|
+
message?: {
|
|
5
|
+
success?: string;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export declare const useSignUp: (props?: UseSignupProps) => {
|
|
9
|
+
run(): Promise<void>;
|
|
10
|
+
};
|
|
11
|
+
export declare const SignUpForm: ({ authenticatorName: name }: {
|
|
12
|
+
authenticatorName: string;
|
|
13
|
+
}) => React.JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
import { Plugin } from '@tachybase/client';
|
|
3
|
+
import { Registry } from '@tachybase/utils/client';
|
|
4
|
+
import { Authenticator as AuthenticatorType } from './authenticator';
|
|
5
|
+
export type AuthOptions = {
|
|
6
|
+
components: Partial<{
|
|
7
|
+
SignInForm: ComponentType<{
|
|
8
|
+
authenticator: AuthenticatorType;
|
|
9
|
+
}>;
|
|
10
|
+
SignInButton: ComponentType<{
|
|
11
|
+
authenticator: AuthenticatorType;
|
|
12
|
+
}>;
|
|
13
|
+
SignUpForm: ComponentType<{
|
|
14
|
+
authenticatorName: string;
|
|
15
|
+
}>;
|
|
16
|
+
AdminSettingsForm: ComponentType;
|
|
17
|
+
BindForm: ComponentType<{
|
|
18
|
+
authenticator: AuthenticatorType;
|
|
19
|
+
}>;
|
|
20
|
+
}>;
|
|
21
|
+
};
|
|
22
|
+
export declare class PluginAuthClient extends Plugin {
|
|
23
|
+
authTypes: Registry<AuthOptions>;
|
|
24
|
+
registerType(authType: string, options: AuthOptions): void;
|
|
25
|
+
load(): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
export { AuthenticatorsContext, useAuthenticator } from './authenticator';
|
|
28
|
+
export type { Authenticator } from './authenticator';
|
|
29
|
+
export { useSignIn } from './basic';
|
|
30
|
+
export default PluginAuthClient;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
(function(c,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@tachybase/client"),require("@tachybase/utils/client"),require("react/jsx-runtime"),require("react"),require("react-router-dom"),require("@tachybase/schema"),require("react-i18next"),require("antd"),require("@ant-design/icons")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tachybase/utils/client","react/jsx-runtime","react","react-router-dom","@tachybase/schema","react-i18next","antd","@ant-design/icons"],e):(c=typeof globalThis!="undefined"?globalThis:c||self,e(c["@tachybase/module-auth"]={},c["@tachybase/client"],c["@tachybase/utils"],c.jsxRuntime,c.react,c["react-router-dom"],c["@tachybase/schema"],c["react-i18next"],c.antd,c["@ant-design/icons"]))})(this,function(c,e,l,a,u,y,x,h,d,C){"use strict";var me=Object.defineProperty,de=Object.defineProperties;var ye=Object.getOwnPropertyDescriptors;var B=Object.getOwnPropertySymbols;var xe=Object.prototype.hasOwnProperty,he=Object.prototype.propertyIsEnumerable;var I=(c,e,l)=>e in c?me(c,e,{enumerable:!0,configurable:!0,writable:!0,value:l}):c[e]=l,f=(c,e)=>{for(var l in e||(e={}))xe.call(e,l)&&I(c,l,e[l]);if(B)for(var l of B(e))he.call(e,l)&&I(c,l,e[l]);return c},S=(c,e)=>de(c,ye(e));var V=(c,e,l)=>I(c,typeof e!="symbol"?e+"":e,l);var b=(c,e,l)=>new Promise((a,u)=>{var y=d=>{try{h(l.next(d))}catch(C){u(C)}},x=d=>{try{h(l.throw(d))}catch(C){u(C)}},h=d=>d.done?a(d.value):Promise.resolve(d.value).then(y,x);h((l=l.apply(c,e)).next())});const $="Email/Password",q=t=>{const n=y.useLocation(),o=e.useAPIClient();return u.useEffect(()=>{const s=new URLSearchParams(n.search),r=s.get("authenticator"),i=s.get("token");i&&(o.auth.setToken(i),o.auth.setAuthenticator(r))}),a.jsx(a.Fragment,{children:t.children})},T="auth";function v(){return h.useTranslation([T,"core"],{nsMode:"fallback"})}const A=u.createContext([]);A.displayName="AuthenticatorsContext";const F=t=>u.useContext(A).find(o=>o.name===t);function N(t){var i;const{data:n}=e.useSystemSettings(),o=e.useAPIClient(),{data:s=[],error:r}=e.useRequest(()=>o.resource("authenticators").publicList().then(p=>{var m;return((m=p==null?void 0:p.data)==null?void 0:m.data)||[]}));if(r)throw r;return a.jsxs("div",{style:{maxWidth:320,margin:"0 auto",paddingTop:"20vh"},children:[a.jsx("h1",{children:(i=n==null?void 0:n.data)==null?void 0:i.title}),a.jsx(A.Provider,{value:s,children:a.jsx(y.Outlet,{})}),a.jsx("div",{className:e.css`
|
|
2
|
+
position: absolute;
|
|
3
|
+
bottom: 24px;
|
|
4
|
+
width: 100%;
|
|
5
|
+
left: 0;
|
|
6
|
+
text-align: center;
|
|
7
|
+
`,children:a.jsx(e.PoweredBy,{})})]})}const E=()=>{var s;const n=e.usePlugin(g).authTypes.getEntities(),o={};for(const[r,i]of n)(s=i.components)!=null&&s.SignInForm&&(o[r]=i.components.SignInForm);return o},L=(t=[])=>{var i;const o=e.usePlugin(g).authTypes.getEntities(),s={};for(const[p,m]of o)(i=m.components)!=null&&i.SignInButton&&(s[p]=m.components.SignInButton);const r=Object.keys(s);return t.filter(p=>r.includes(p.authType)).map((p,m)=>u.createElement(s[p.authType],{key:m,authenticator:p}))},O=()=>{const{t}=v();e.useCurrentDocumentTitle("Signin"),e.useViewport();const n=E(),o=u.useContext(A),s=L(o);if(!o.length)return a.jsx("div",{style:{color:"#ccc"},children:t("No authentication methods available.")});const r=o.map(i=>{const p=n[i.authType];if(!p)return;const m=`${t("Sign-in")} (${t(i.authTypeTitle||i.authType)})`;return f({component:u.createElement(p,{authenticator:i}),tabTitle:i.title||m},i)}).filter(i=>i);return a.jsxs(d.Space,{direction:"vertical",className:e.css`
|
|
8
|
+
display: flex;
|
|
9
|
+
`,children:[r.length>1?a.jsx(d.Tabs,{items:r.map(i=>({label:i.tabTitle,key:i.name,children:i.component}))}):r.length?a.jsx("div",{children:r[0].component}):a.jsx(a.Fragment,{}),a.jsx(d.Space,{direction:"vertical",className:e.css`
|
|
10
|
+
display: flex;
|
|
11
|
+
`,children:s})]})},j=u.createContext({});j.displayName="SignupPageContext";const k=()=>{var s;const n=e.usePlugin(g).authTypes.getEntities(),o={};for(const[r,i]of n)(s=i.components)!=null&&s.SignUpForm&&(o[r]=i.components.SignUpForm);return o},M=()=>{e.useViewport(),e.useCurrentDocumentTitle("Signup");const t=k(),[n]=y.useSearchParams(),o=n.get("name"),s=F(o),{authType:r}=s||{};return t[r]?u.createElement(t[r],{authenticatorName:o}):a.jsx(y.Navigate,{to:"/not-found",replace:!0})};function _(t="/admin"){const n=y.useNavigate(),[o]=y.useSearchParams();return u.useCallback(()=>{n(o.get("redirect")||"/admin",{replace:!0})},[n,o])}const U=t=>{const n=x.useForm(),o=e.useAPIClient(),s=_(),{refreshAsync:r}=e.useCurrentUserContext();return{run(){return b(this,null,function*(){yield n.submit(),yield o.auth.signIn(n.values,t),yield r(),s()})}}},z={type:"object",name:"passwordForm","x-component":"FormV2",properties:{account:{type:"string","x-component":"Input","x-validator":`{{(value) => {
|
|
12
|
+
if (!value) {
|
|
13
|
+
return t("Please enter your username or email");
|
|
14
|
+
}
|
|
15
|
+
if (value.includes('@')) {
|
|
16
|
+
if (!/^[\\w-]+(\\.[\\w-]+)*@[\\w-]+(\\.[\\w-]+)+$/.test(value)) {
|
|
17
|
+
return t("Please enter a valid email");
|
|
18
|
+
}
|
|
19
|
+
} else {
|
|
20
|
+
return /^[^@.<>"'/]{2,16}$/.test(value) || t("Please enter a valid username");
|
|
21
|
+
}
|
|
22
|
+
}}}`,"x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Username/Email")}}',style:{}}},password:{type:"string","x-component":"Password",required:!0,"x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Password")}}',style:{}}},actions:{type:"void","x-component":"div",properties:{submit:{title:'{{t("Sign in")}}',type:"void","x-component":"Action","x-component-props":{htmlType:"submit",block:!0,type:"primary",useAction:"{{ useBasicSignIn }}",style:{width:"100%"}}}}},signUp:{type:"void","x-component":"Link","x-component-props":{to:"{{ signUpLink }}"},"x-content":'{{t("Create an account")}}',"x-visible":"{{ allowSignUp }}"}}},K=t=>{const{t:n}=v(),o=t.authenticator,{authType:s,name:r,options:i}=o,m=!!k()[s]&&(i==null?void 0:i.allowSignUp),ue=`/signup?name=${r}`,le=()=>U(r);return a.jsx(e.SchemaComponent,{schema:z,scope:{useBasicSignIn:le,allowSignUp:m,signUpLink:ue,t:n}})},Z=t=>{const n=y.useNavigate(),o=x.useForm(),s=e.useAPIClient(),{t:r}=h.useTranslation();return{run(){return b(this,null,function*(){var p;yield o.submit(),yield s.auth.signUp(o.values,t==null?void 0:t.authenticator),d.message.success(((p=t==null?void 0:t.message)==null?void 0:p.success)||r("Sign up successfully, and automatically jump to the sign in page")),setTimeout(()=>{n("/signin")},2e3)})}}},W={type:"object",name:x.uid(),"x-component":"FormV2",properties:{username:{type:"string",required:!0,"x-component":"Input","x-validator":{username:!0},"x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Username")}}',style:{}}},password:{type:"string",required:!0,"x-component":"Password","x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Password")}}',checkStrength:!0,style:{}},"x-reactions":[{dependencies:[".confirm_password"],fulfill:{state:{selfErrors:'{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'}}}]},confirm_password:{type:"string",required:!0,"x-component":"Password","x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Confirm password")}}',style:{}},"x-reactions":[{dependencies:[".password"],fulfill:{state:{selfErrors:'{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'}}}]},actions:{type:"void","x-component":"div",properties:{submit:{title:'{{t("Sign up")}}',type:"void","x-component":"Action","x-component-props":{block:!0,type:"primary",htmlType:"submit",useAction:"{{ useBasicSignUp }}",style:{width:"100%"}}}}},link:{type:"void","x-component":"div",properties:{link:{type:"void","x-component":"Link","x-component-props":{to:"/signin"},"x-content":'{{t("Log in with an existing account")}}'}}}}},G=({authenticatorName:t})=>{const{t:n}=v(),o=()=>Z({authenticator:t}),s=F(t),{options:r}=s;return r!=null&&r.allowSignUp?a.jsx(e.SchemaComponent,{schema:W,scope:{useBasicSignUp:o,t:n}}):a.jsx(y.Navigate,{to:"/not-found",replace:!0})},H=()=>{const{t}=v();return a.jsx(e.SchemaComponent,{scope:{t},components:{Alert:d.Alert},schema:{type:"object",properties:{public:{type:"object",properties:{allowSignUp:{"x-decorator":"FormItem",type:"boolean",title:'{{t("Allow to sign up")}}',"x-component":"Checkbox","x-component-props":{defaultChecked:!0}}}},notice:{type:"void","x-component":"Alert","x-component-props":{showIcon:!0,message:'{{t("The authentication allows users to sign in via username or email.")}}'}}}}})},J=()=>{var s;const n=e.usePlugin(g).authTypes.getEntities(),o={};for(const[r,i]of n)(s=i.components)!=null&&s.BindForm&&(o[r]=i.components.BindForm);return o},Q=()=>{const t=e.useRecord(),o=J()[t.authType];return u.createElement(o,{authenticator:t})},X={type:"void",name:"authenticatorBind","x-decorator":"TableBlockProvider","x-decorator-props":{collection:{name:"authenticators",sortable:!1,fields:[{interface:"input",type:"string",name:"authType"},{interface:"input",type:"string",name:"title",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}},{interface:"textarea",type:"string",name:"description",uiSchema:{type:"string",title:'{{t("Description")}}',"x-component":"Input"}},{type:"boolean",name:"bind",uiSchema:{type:"boolean",title:'{{t("Bind")}}',"x-component":"Checkbox"}},{type:"string",name:"nickname",uiSchema:{type:"string",title:'{{t("Nickname")}}',"x-component":"Input"}}]},resource:"authenticators",action:"bindTypes",params:{sort:["sort"]},rowKey:"name",showIndex:!0},"x-component":"div",properties:{table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"name"},properties:{authType:{title:'{{t("Auth Type")}}',type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{authType:{type:"string","x-component":"Select","x-read-pretty":!0}}},title:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},description:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{description:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},bind:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{bind:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},nickname:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{nickname:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"TableV2.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{unbind:{"x-visible":'{{ $self.query(".bind").value() }}',type:"void",title:'{{ t("Unbind") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Unbind')}}",content:"{{t('Are you sure to unbind this authenticator?')}}"},useAction:"{{ useUnbindAction }}"}},bind:{"x-visible":'{{ !$self.query(".bind").value() }}',type:"void",title:"{{ t('Bind') }}","x-component":"Action.Link",properties:{modal:{type:"void","x-decorator":"Form",title:"{{ t('Bind') }}","x-component":"Action.Modal","x-component-props":{width:800},properties:{form:{type:"void","x-component":"BindForm"}}}}}}}}}}}}},Y=()=>{const{refreshCM:t}=e.useCollectionManager_deprecated(),n=e.useAPIClient(),o=e.useRecord();return{run(){return b(this,null,function*(){yield n.resource("authenticators").unbind({authenticator:o.name}),t()})}}},R=()=>{const{t}=v();return a.jsx(d.Card,{bordered:!1,children:a.jsx(e.SchemaComponent,{schema:X,components:{BindForm:Q},scope:{t,useUnbindAction:Y}})})},w=u.createContext({type:""});w.displayName="AuthTypeContext";const P=u.createContext({types:[]});P.displayName="AuthTypesContext";const ee=()=>{const{types:t}=u.useContext(P);return t},te=t=>{const n=e.useRecord(),o=e.useRequest(()=>Promise.resolve({data:f({},n.options)}),S(f({},t),{manual:!0})),{run:s}=o,r=e.useActionContext();return u.useEffect(()=>{r.visible&&s()},[r.visible,s]),o},oe=t=>{var s;const o=e.usePlugin(g).authTypes.get(t);return(s=o==null?void 0:o.components)==null?void 0:s.AdminSettingsForm},ne=x.observer(()=>{const t=x.useForm(),n=e.useRecord(),o=oe(t.values.authType||n.authType);return o?a.jsx(o,{}):null},{displayName:"Options"}),D={name:"authenticators",sortable:!0,fields:[{name:"id",type:"string",interface:"id"},{interface:"input",type:"string",name:"name",uiSchema:{type:"string",title:'{{t("Auth UID")}}',"x-component":"Input","x-validator":t=>/^[a-zA-Z0-9_-]+$/.test(t)?"":e.i18n.t("a-z, A-Z, 0-9, _, -"),required:!0}},{interface:"input",type:"string",name:"authType",uiSchema:{type:"string",title:'{{t("Auth Type")}}',"x-component":"Select",dataSource:"{{ types }}",required:!0}},{interface:"input",type:"string",name:"title",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}},{interface:"textarea",type:"string",name:"description",uiSchema:{type:"string",title:'{{t("Description")}}',"x-component":"Input"}},{type:"boolean",name:"enabled",uiSchema:{type:"boolean",title:'{{t("Enabled")}}',"x-component":"Checkbox"}}]},re={type:"object",properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues(t){const n=e.useActionContext(),{type:o}=u.useContext(w);return e.useRequest(()=>Promise.resolve({data:{name:`s_${x.uid()}`,authType:o}}),S(f({},t),{refreshDeps:[n.visible]}))}},title:'{{t("Add new")}}',properties:{name:{"x-component":"CollectionField","x-decorator":"FormItem"},authType:{"x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{options:"{{ types }}"}},title:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"Options"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}},se={type:"void",name:"authenticators","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:D,resourceName:"authenticators",dragSort:!0,request:{resource:"authenticators",action:"list",params:{pageSize:50,sort:"sort",appends:[]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:D},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"AddNew","x-component-props":{type:"primary"}}}},table:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}",useAction(){const t=e.useAPIClient(),{t:n}=h.useTranslation();return{move(s,r){return b(this,null,function*(){yield t.resource("authenticators").move({sourceId:s.id,targetId:r.id}),d.message.success(n("Saved successfully"),.2)})}}}},properties:{id:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},name:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},authType:{title:'{{t("Auth Type")}}',type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{authType:{type:"string","x-component":"Select","x-read-pretty":!0,enum:"{{ types }}"}}},title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},description:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{description:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{update:{type:"void",title:'{{t("Configure")}}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{t("Configure")}}',properties:{name:{"x-component":"CollectionField","x-decorator":"FormItem"},authType:{"x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{options:"{{ types }}"}},title:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"Options"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{cm.useDestroyAction}}"},"x-disabled":"{{ useCanNotDelete() }}"}}}}}}}}},ie=()=>{const{setVisible:t}=e.useActionContext();return{run(){return b(this,null,function*(){t(!1)})}}},ae=()=>{const{t}=h.useTranslation(),[n,o]=u.useState(!1),[s,r]=u.useState(""),i=ee(),p=i.map(m=>S(f({},m),{onClick:()=>{o(!0),r(m.value)}}));return a.jsx(e.ActionContextProvider,{value:{visible:n,setVisible:o},children:a.jsxs(w.Provider,{value:{type:s},children:[a.jsx(d.Dropdown,{menu:{items:p},children:a.jsxs(d.Button,{icon:a.jsx(C.PlusOutlined,{}),type:"primary",children:[t("Add new")," ",a.jsx(C.DownOutlined,{})]})}),a.jsx(e.SchemaComponent,{scope:{useCloseAction:ie,types:i,setType:r},schema:re})]})})},ce=()=>(e.useAsyncData(),!1),pe=()=>{const{t}=v(),[n,o]=u.useState([]),s=e.useAPIClient();return e.useRequest(()=>s.resource("authenticators").listTypes().then(r=>{var p;return(((p=r==null?void 0:r.data)==null?void 0:p.data)||[]).map(m=>({key:m.name,label:t(m.title||m.name),value:m.name}))}),{onSuccess:r=>{o(r)}}),a.jsx(d.Card,{bordered:!1,children:a.jsx(P.Provider,{value:{types:n},children:a.jsx(e.SchemaComponent,{schema:se,components:{AddNew:ae,Options:ne},scope:{types:n,useValuesFromOptions:te,useCanNotDelete:ce,t}})})})};class g extends e.Plugin{constructor(){super(...arguments);V(this,"authTypes",new l.Registry)}registerType(o,s){this.authTypes.register(o,s)}load(){return b(this,null,function*(){this.app.systemSettingsManager.add("system-services."+T,{icon:"LoginOutlined",title:`{{t("Authentication", { ns: "${T}" })}}`,Component:pe,aclSnippet:"pm.auth.authenticators"}),this.app.userSettingsManager.add(T,{icon:"LoginOutlined",title:`{{t("Authentication login bind", { ns: "${T}" })}}`,Component:R,aclSnippet:"pm.auth.authenticators"}),this.router.add("auth",{Component:"AuthLayout"}),this.router.add("auth.signin",{path:"/signin",Component:"SignInPage"}),this.router.add("auth.signup",{path:"/signup",Component:"SignUpPage"}),this.app.addComponents({AuthLayout:N,SignInPage:O,SignUpPage:M}),this.app.providers.unshift([q,{}]),this.registerType($,{components:{SignInForm:K,SignUpForm:G,AdminSettingsForm:H}})})}}c.AuthenticatorsContext=A,c.PluginAuthClient=g,c.default=g,c.useAuthenticator=F,c.useSignIn=U,Object.defineProperties(c,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AuthOptions } from '..';
|
|
3
|
+
export declare const useSignInForms: () => {
|
|
4
|
+
[authType: string]: AuthOptions["components"]["SignInForm"];
|
|
5
|
+
};
|
|
6
|
+
export declare const useSignInButtons: (authenticators?: any[]) => React.CElement<{
|
|
7
|
+
key: number;
|
|
8
|
+
authenticator: any;
|
|
9
|
+
}, React.Component<{
|
|
10
|
+
key: number;
|
|
11
|
+
authenticator: any;
|
|
12
|
+
}, any, any>>[];
|
|
13
|
+
export declare const SignInPage: () => React.JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React, { FunctionComponent } from 'react';
|
|
2
|
+
import { AuthOptions } from '..';
|
|
3
|
+
export declare const SignupPageContext: React.Context<{
|
|
4
|
+
[authType: string]: {
|
|
5
|
+
component: FunctionComponent<{
|
|
6
|
+
name: string;
|
|
7
|
+
}>;
|
|
8
|
+
};
|
|
9
|
+
}>;
|
|
10
|
+
export declare const SignupPageProvider: (props: {
|
|
11
|
+
authType: string;
|
|
12
|
+
component: FunctionComponent<{
|
|
13
|
+
name: string;
|
|
14
|
+
}>;
|
|
15
|
+
children: React.ReactNode;
|
|
16
|
+
}) => React.JSX.Element;
|
|
17
|
+
export declare const useSignUpForms: () => {
|
|
18
|
+
[authType: string]: AuthOptions["components"]["SignUpForm"];
|
|
19
|
+
};
|
|
20
|
+
export declare const SignUpPage: () => React.JSX.Element;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const useValuesFromOptions: (options: any) => import("@tachybase/client").UseRequestResult<unknown>;
|
|
3
|
+
export declare const useAdminSettingsForm: (authType: string) => React.ComponentType;
|
|
4
|
+
export declare const Options: React.MemoExoticComponent<import("@tachybase/schema").ReactFC<unknown>>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const AuthTypeContext: import("react").Context<{
|
|
2
|
+
type: string;
|
|
3
|
+
}>;
|
|
4
|
+
export declare const AuthTypesContext: import("react").Context<{
|
|
5
|
+
types: {
|
|
6
|
+
key: string;
|
|
7
|
+
label: string;
|
|
8
|
+
value: string;
|
|
9
|
+
}[];
|
|
10
|
+
}>;
|
|
11
|
+
export declare const useAuthTypes: () => {
|
|
12
|
+
key: string;
|
|
13
|
+
label: string;
|
|
14
|
+
value: string;
|
|
15
|
+
}[];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
"react": "18.3.1",
|
|
3
|
+
"@tachybase/client": "0.23.8",
|
|
4
|
+
"react-router-dom": "6.28.1",
|
|
5
|
+
"@tachybase/utils": "0.23.8",
|
|
6
|
+
"@tachybase/auth": "0.23.8",
|
|
7
|
+
"@tachybase/database": "0.23.8",
|
|
8
|
+
"@tachybase/cache": "0.23.8",
|
|
9
|
+
"@tachybase/server": "0.23.8",
|
|
10
|
+
"@tachybase/test": "0.23.8",
|
|
11
|
+
"antd": "5.22.5",
|
|
12
|
+
"@tachybase/schema": "0.23.8",
|
|
13
|
+
"react-i18next": "15.2.0",
|
|
14
|
+
"@ant-design/icons": "5.3.7",
|
|
15
|
+
"@tachybase/actions": "0.23.8"
|
|
16
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AuthModel, BasicAuth, default } from './server';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var src_exports = {};
|
|
29
|
+
__export(src_exports, {
|
|
30
|
+
AuthModel: () => import_server.AuthModel,
|
|
31
|
+
BasicAuth: () => import_server.BasicAuth,
|
|
32
|
+
default: () => import_server.default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(src_exports);
|
|
35
|
+
var import_server = __toESM(require("./server"));
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
AuthModel,
|
|
39
|
+
BasicAuth
|
|
40
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Allow to sign in with": "Allow to sign in with",
|
|
3
|
+
"Allow to sign up": "Allow to sign up",
|
|
4
|
+
"Are you sure to unbind this authenticator?": "Are you sure to unbind this authenticator?",
|
|
5
|
+
"Auth Type": "Auth Type",
|
|
6
|
+
"Auth UID": "Auth UID",
|
|
7
|
+
"Authentication": "Authentication",
|
|
8
|
+
"Authentication login bind": "Authentication login bind",
|
|
9
|
+
"Authenticators": "Authenticators",
|
|
10
|
+
"Bind": "Bind",
|
|
11
|
+
"No authentication methods available.": "No authentication methods available.",
|
|
12
|
+
"Not a valid cellphone number, please re-enter": "Not a valid cellphone number, please re-enter",
|
|
13
|
+
"Not allowed to sign up": "Not allowed to sign up",
|
|
14
|
+
"Please enter a valid email": "Please enter a valid email",
|
|
15
|
+
"Please enter a valid username": "Please enter a valid username",
|
|
16
|
+
"Please enter your username or email": "Please enter your username or email",
|
|
17
|
+
"Please keep and enable at least one authenticator": "Please keep and enable at least one authenticator",
|
|
18
|
+
"SMS": "SMS",
|
|
19
|
+
"Sign in via email": "Sign in via email",
|
|
20
|
+
"Sign in via password": "Sign in via password",
|
|
21
|
+
"Sign-in": "Sign-in",
|
|
22
|
+
"The authentication allows users to sign in via username or email.": "The authentication allows users to sign in via username or email.",
|
|
23
|
+
"The password is inconsistent, please re-enter": "The password is inconsistent, please re-enter",
|
|
24
|
+
"The password is incorrect, please re-enter": "The password is incorrect, please re-enter",
|
|
25
|
+
"The phone number has been registered, please login directly": "The phone number has been registered, please login directly",
|
|
26
|
+
"The phone number is not registered, please register first": "The phone number is not registered, please register first",
|
|
27
|
+
"The username or email is incorrect, please re-enter": "The username or email is incorrect, please re-enter",
|
|
28
|
+
"Unbind": "Unbind",
|
|
29
|
+
"User can bind or unbind the sign in type": "User can bind or unbind the sign in type",
|
|
30
|
+
"Username/Email": "Username/Email"
|
|
31
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Allow to sign in with": "다음으로 로그인 허용",
|
|
3
|
+
"Allow to sign up": "가입 허용",
|
|
4
|
+
"Auth Type": "인증 유형",
|
|
5
|
+
"Auth UID": "인증 UID",
|
|
6
|
+
"Authentication": "인증",
|
|
7
|
+
"Authenticators": "인증기",
|
|
8
|
+
"No authentication methods available.": "사용 가능한 인증 방법이 없습니다.",
|
|
9
|
+
"Not a valid cellphone number, please re-enter": "유효하지 않은 휴대폰 번호입니다. 다시 입력하세요.",
|
|
10
|
+
"Not allowed to sign up": "가입할 수 없음",
|
|
11
|
+
"Please enter a valid email": "유효한 이메일을 입력하세요.",
|
|
12
|
+
"Please enter a valid username": "유효한 사용자 이름을 입력하세요.",
|
|
13
|
+
"Please enter your username or email": "사용자 이름 또는 이메일을 입력하세요.",
|
|
14
|
+
"Please keep and enable at least one authenticator": "최소한 하나의 인증기를 유지하고 활성화하세요.",
|
|
15
|
+
"SMS": "SMS",
|
|
16
|
+
"Sign in via email": "이메일로 로그인",
|
|
17
|
+
"Sign in via password": "비밀번호로 로그인",
|
|
18
|
+
"Sign-in": "로그인",
|
|
19
|
+
"The authentication allows users to sign in via username or email.": "이 인증 방식을 사용하면 사용자가 사용자 이름 또는 이메일로 로그인할 수 있습니다.",
|
|
20
|
+
"The password is inconsistent, please re-enter": "비밀번호가 일치하지 않습니다. 다시 입력하세요.",
|
|
21
|
+
"The password is incorrect, please re-enter": "비밀번호가 잘못되었습니다. 다시 입력하세요.",
|
|
22
|
+
"The phone number has been registered, please login directly": "전화번호가 이미 등록되어 있습니다. 직접 로그인하세요.",
|
|
23
|
+
"The phone number is not registered, please register first": "전화번호가 등록되어 있지 않습니다. 먼저 등록하세요.",
|
|
24
|
+
"The username or email is incorrect, please re-enter": "사용자 이름 또는 이메일이 잘못되었습니다. 다시 입력하세요.",
|
|
25
|
+
"Username/Email": "사용자 이름/이메일"
|
|
26
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Allow to sign in with": "允许使用以下方式登录",
|
|
3
|
+
"Allow to sign up": "允许注册",
|
|
4
|
+
"Are you sure to unbind this authenticator?": "确定要解绑该认证器吗?",
|
|
5
|
+
"Auth Type": "认证类型",
|
|
6
|
+
"Auth UID": "认证标识",
|
|
7
|
+
"Authentication": "认证方式",
|
|
8
|
+
"Authentication login bind": "认证登录绑定",
|
|
9
|
+
"Authenticators": "认证器",
|
|
10
|
+
"Bind": "绑定",
|
|
11
|
+
"No authentication methods available.": "没有可用的认证方式。",
|
|
12
|
+
"Not a valid cellphone number, please re-enter": "不是有效的手机号,请重新输入",
|
|
13
|
+
"Not allowed to sign up": "禁止注册",
|
|
14
|
+
"Please enter a valid email": "请输入有效的邮箱",
|
|
15
|
+
"Please enter a valid username": "请输入有效的用户名",
|
|
16
|
+
"Please enter your username or email": "请输入用户名或邮箱",
|
|
17
|
+
"Please keep and enable at least one authenticator": "请至少保留并启用一个认证器",
|
|
18
|
+
"SMS": "短信",
|
|
19
|
+
"Sign in via email": "邮箱登录",
|
|
20
|
+
"Sign in via password": "密码登录",
|
|
21
|
+
"Sign-in": "登录",
|
|
22
|
+
"The authentication allows users to sign in via username or email.": "该认证方式支持用户通过用户名或邮箱登录。",
|
|
23
|
+
"The password is inconsistent, please re-enter": "密码不一致,请重新输入",
|
|
24
|
+
"The password is incorrect, please re-enter": "密码有误,请重新输入",
|
|
25
|
+
"The phone number has been registered, please login directly": "手机号已注册,请直接登录",
|
|
26
|
+
"The phone number is not registered, please register first": "手机号未注册,请先注册",
|
|
27
|
+
"The username or email is incorrect, please re-enter": "用户名或邮箱有误,请重新输入",
|
|
28
|
+
"Unbind": "解绑",
|
|
29
|
+
"User can bind or unbind the sign in type": "用户可以绑定或解绑登录方式",
|
|
30
|
+
"Username/Email": "用户名/邮箱"
|
|
31
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
Copyright © 2017 Nicholas Campbell <nicholas.j.campbell@gmail.com>
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
5
|
+
|
|
6
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|