@nocobase/plugin-verification 1.7.0-beta.2 → 1.7.0-beta.21

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.
Files changed (76) hide show
  1. package/dist/client/3a77d3f9954a0a50.js +10 -0
  2. package/dist/client/{providerTypes/index.d.ts → VerificationMenu.d.ts} +5 -4
  3. package/dist/client/c88007c6800b52fb.js +10 -0
  4. package/dist/client/index.d.ts +7 -0
  5. package/dist/client/index.js +1 -1
  6. package/dist/client/locale/index.d.ts +1 -1
  7. package/dist/client/otp-verification/VerificationCode.d.ts +16 -0
  8. package/dist/client/otp-verification/sms/AdminSettingsForm.d.ts +12 -0
  9. package/dist/client/otp-verification/sms/BindForm.d.ts +11 -0
  10. package/dist/client/otp-verification/sms/VerificationForm.d.ts +11 -0
  11. package/dist/client/otp-verification/sms/index.d.ts +26 -0
  12. package/dist/client/otp-verification/sms/provider-manager.d.ts +19 -0
  13. package/dist/client/{VerificationProviders.d.ts → otp-verification/sms/providers/AliyunSettings.d.ts} +1 -1
  14. package/dist/{server/actions/index.d.ts → client/otp-verification/sms/providers/TencentSettings.d.ts} +2 -3
  15. package/dist/client/schemas/verificators.d.ts +66 -0
  16. package/dist/client/verification-manager/index.d.ts +32 -0
  17. package/dist/client/{ProviderOptions.d.ts → verificators/VerificatorSelect.d.ts} +1 -2
  18. package/dist/client/verificators/Verificators.d.ts +12 -0
  19. package/dist/client/verificators/verification-types.d.ts +24 -0
  20. package/dist/collections/verificators.d.ts +50 -0
  21. package/dist/collections/verificators.js +70 -0
  22. package/dist/constants.d.ts +11 -0
  23. package/dist/constants.js +42 -0
  24. package/dist/externalVersion.js +13 -13
  25. package/dist/locale/en-US.json +17 -1
  26. package/dist/locale/nl-NL.json +12 -12
  27. package/dist/locale/zh-CN.json +19 -2
  28. package/dist/node_modules/@alicloud/dysmsapi20170525/dist/client.js +2 -2
  29. package/dist/node_modules/@alicloud/dysmsapi20170525/package.json +1 -1
  30. package/dist/node_modules/@alicloud/openapi-client/dist/client.js +2 -2
  31. package/dist/node_modules/@alicloud/openapi-client/package.json +1 -1
  32. package/dist/node_modules/@alicloud/tea-util/dist/client.js +1 -1
  33. package/dist/node_modules/@alicloud/tea-util/package.json +1 -1
  34. package/dist/node_modules/tencentcloud-sdk-nodejs/package.json +1 -1
  35. package/dist/node_modules/tencentcloud-sdk-nodejs/tencentcloud/index.js +2 -2
  36. package/dist/server/Plugin.d.ts +5 -16
  37. package/dist/server/Plugin.js +57 -72
  38. package/dist/server/actions/verificators.d.ts +18 -0
  39. package/dist/server/actions/verificators.js +175 -0
  40. package/dist/server/{actions/verifications.d.ts → collections/otp-records.d.ts} +2 -2
  41. package/dist/server/collections/otp-records.js +75 -0
  42. package/dist/server/collections/users-verificators.d.ts +14 -0
  43. package/dist/server/collections/users-verificators.js +58 -0
  44. package/dist/server/collections/verificators.d.ts +10 -0
  45. package/dist/server/{actions/index.js → collections/verificators.js} +10 -19
  46. package/dist/server/constants.d.ts +0 -2
  47. package/dist/server/constants.js +2 -8
  48. package/dist/server/index.d.ts +5 -2
  49. package/dist/server/index.js +12 -5
  50. package/dist/server/migrations/20250111192640-providers2verificators.d.ts +14 -0
  51. package/dist/server/migrations/20250111192640-providers2verificators.js +83 -0
  52. package/dist/server/otp-verification/index.d.ts +25 -0
  53. package/dist/server/otp-verification/index.js +94 -0
  54. package/dist/server/otp-verification/sms/index.d.ts +37 -0
  55. package/dist/server/otp-verification/sms/index.js +87 -0
  56. package/dist/server/{providers/Provider.d.ts → otp-verification/sms/providers/index.d.ts} +2 -4
  57. package/dist/server/{providers/Provider.js → otp-verification/sms/providers/index.js} +8 -10
  58. package/dist/server/{providers → otp-verification/sms/providers}/sms-aliyun.d.ts +3 -3
  59. package/dist/server/{providers → otp-verification/sms/providers}/sms-aliyun.js +4 -4
  60. package/dist/server/{providers → otp-verification/sms/providers}/sms-tencent.d.ts +3 -3
  61. package/dist/server/{providers → otp-verification/sms/providers}/sms-tencent.js +4 -4
  62. package/dist/server/otp-verification/sms/resource/sms-otp-providers.d.ts +16 -0
  63. package/dist/server/otp-verification/sms/resource/sms-otp-providers.js +41 -0
  64. package/dist/server/otp-verification/sms/resource/sms-otp.d.ts +18 -0
  65. package/dist/server/otp-verification/sms/resource/sms-otp.js +141 -0
  66. package/dist/server/verification-manager.d.ts +68 -0
  67. package/dist/server/verification-manager.js +223 -0
  68. package/dist/server/verification.d.ts +70 -0
  69. package/dist/server/verification.js +70 -0
  70. package/package.json +8 -6
  71. package/dist/client/7551e1f2e04bca2f.js +0 -10
  72. package/dist/client/providerTypes/sms-aliyun.d.ts +0 -66
  73. package/dist/client/providerTypes/sms-tencent.d.ts +0 -66
  74. package/dist/server/actions/verifications.js +0 -146
  75. package/dist/server/providers/index.d.ts +0 -15
  76. package/dist/server/providers/index.js +0 -52
@@ -6,23 +6,12 @@
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
- import { Context } from '@nocobase/actions';
10
- import { HandlerType } from '@nocobase/resourcer';
11
9
  import { Plugin } from '@nocobase/server';
12
- import { Registry } from '@nocobase/utils';
13
- import { Provider } from '.';
14
- export interface Interceptor {
15
- manual?: boolean;
16
- expiresIn?: number;
17
- getReceiver(ctx: any): string;
18
- getCode?(ctx: any): string;
19
- validate?(ctx: Context, receiver: string): boolean | Promise<boolean>;
20
- }
10
+ import { VerificationManager } from './verification-manager';
11
+ import { SMSOTPProviderManager } from './otp-verification/sms';
21
12
  export default class PluginVerficationServer extends Plugin {
22
- providers: Registry<typeof Provider>;
23
- interceptors: Registry<Interceptor>;
24
- intercept: HandlerType;
25
- install(): Promise<void>;
13
+ verificationManager: VerificationManager;
14
+ smsOTPProviderManager: SMSOTPProviderManager;
26
15
  load(): Promise<void>;
27
- getDefault(): Promise<any>;
16
+ install(): Promise<void>;
28
17
  }
@@ -39,55 +39,69 @@ __export(Plugin_exports, {
39
39
  default: () => PluginVerficationServer
40
40
  });
41
41
  module.exports = __toCommonJS(Plugin_exports);
42
- var import_path = __toESM(require("path"));
43
- var import_database = require("@nocobase/database");
44
42
  var import_server = require("@nocobase/server");
45
43
  var import_utils = require("@nocobase/utils");
46
44
  var import__ = require(".");
47
- var import_actions2 = __toESM(require("./actions"));
48
- var import_constants = require("./constants");
49
- var import_providers = __toESM(require("./providers"));
45
+ var import_constants = require("../constants");
46
+ var import_verification_manager = require("./verification-manager");
47
+ var import_sms = require("./otp-verification/sms");
48
+ var import_constants2 = require("../constants");
49
+ var import_verificators = __toESM(require("./actions/verificators"));
50
+ var import_sms_aliyun = __toESM(require("./otp-verification/sms/providers/sms-aliyun"));
51
+ var import_sms_tencent = __toESM(require("./otp-verification/sms/providers/sms-tencent"));
52
+ var import_sms_otp_providers = __toESM(require("./otp-verification/sms/resource/sms-otp-providers"));
53
+ var import_sms_otp = __toESM(require("./otp-verification/sms/resource/sms-otp"));
50
54
  class PluginVerficationServer extends import_server.Plugin {
51
- providers = new import_utils.Registry();
52
- interceptors = new import_utils.Registry();
53
- intercept = async (context, next) => {
54
- const { resourceName, actionName, values } = context.action.params;
55
- const key = `${resourceName}:${actionName}`;
56
- const interceptor = this.interceptors.get(key);
57
- if (!interceptor) {
58
- return context.throw(400);
59
- }
60
- const receiver = interceptor.getReceiver(context);
61
- const content = interceptor.getCode ? interceptor.getCode(context) : values.code;
62
- if (!receiver || !content) {
63
- return context.throw(400);
64
- }
65
- const VerificationRepo = this.db.getRepository("verifications");
66
- const item = await VerificationRepo.findOne({
67
- filter: {
68
- receiver,
69
- type: key,
70
- content,
71
- expiresAt: {
72
- [import_database.Op.gt]: /* @__PURE__ */ new Date()
73
- },
74
- status: import_constants.CODE_STATUS_UNUSED
55
+ verificationManager = new import_verification_manager.VerificationManager({ db: this.db });
56
+ smsOTPProviderManager = new import_sms.SMSOTPProviderManager();
57
+ async load() {
58
+ this.app.dataSourceManager.use(this.verificationManager.middleware());
59
+ this.app.resourceManager.define(import_sms_otp_providers.default);
60
+ this.app.resourceManager.define(import_sms_otp.default);
61
+ Object.entries(import_verificators.default).forEach(
62
+ ([action, handler]) => this.app.resourceManager.registerActionHandler(`verificators:${action}`, handler)
63
+ );
64
+ this.app.acl.allow("verificators", "listByUser", "loggedIn");
65
+ this.app.acl.allow("verificators", "listForVerify", "loggedIn");
66
+ this.app.acl.allow("verificators", "bind", "loggedIn");
67
+ this.app.acl.allow("verificators", "unbind", "loggedIn");
68
+ this.app.acl.allow("smsOTP", "create", "loggedIn");
69
+ this.app.acl.allow("smsOTP", "publicCreate");
70
+ this.app.acl.registerSnippet({
71
+ name: `pm.${this.name}.verificators`,
72
+ actions: ["verificators:*", "smsOTPProviders:*"]
73
+ });
74
+ this.verificationManager.registerVerificationType(import_constants2.SMS_OTP_VERIFICATION_TYPE, {
75
+ title: (0, import_utils.tval)("SMS OTP", { ns: import__.namespace }),
76
+ description: (0, import_utils.tval)("Get one-time codes sent to your phone via SMS to complete authentication requests.", {
77
+ ns: import__.namespace
78
+ }),
79
+ bindingRequired: true,
80
+ verification: import_sms.SMSOTPVerification
81
+ });
82
+ this.verificationManager.addSceneRule(
83
+ (scene, verificationType) => ["auth-sms", "unbind-verificator"].includes(scene) && verificationType === import_constants2.SMS_OTP_VERIFICATION_TYPE
84
+ );
85
+ this.verificationManager.registerAction("verificators:bind", {
86
+ manual: true,
87
+ getBoundInfoFromCtx: (ctx) => {
88
+ return ctx.action.params.values || {};
75
89
  }
76
90
  });
77
- if (!item) {
78
- return context.throw(400, {
79
- code: "InvalidVerificationCode",
80
- message: context.t("Verification code is invalid", { ns: import__.namespace })
81
- });
82
- }
83
- try {
84
- await next();
85
- } finally {
86
- await item.update({
87
- status: import_constants.CODE_STATUS_USED
88
- });
89
- }
90
- };
91
+ this.verificationManager.registerScene("unbind-verificator", {
92
+ actions: {
93
+ "verificators:unbind": {}
94
+ }
95
+ });
96
+ this.smsOTPProviderManager.registerProvider(import_constants.PROVIDER_TYPE_SMS_ALIYUN, {
97
+ title: (0, import_utils.tval)("Aliyun SMS", { ns: import__.namespace }),
98
+ provider: import_sms_aliyun.default
99
+ });
100
+ this.smsOTPProviderManager.registerProvider(import_constants.PROVIDER_TYPE_SMS_TENCENT, {
101
+ title: (0, import_utils.tval)("Tencent SMS", { ns: import__.namespace }),
102
+ provider: import_sms_tencent.default
103
+ });
104
+ }
91
105
  async install() {
92
106
  const {
93
107
  DEFAULT_SMS_VERIFY_CODE_PROVIDER,
@@ -122,33 +136,4 @@ class PluginVerficationServer extends import_server.Plugin {
122
136
  });
123
137
  }
124
138
  }
125
- async load() {
126
- const { app, db, options } = this;
127
- await this.importCollections(import_path.default.resolve(__dirname, "collections"));
128
- await (0, import_providers.default)(this);
129
- (0, import_actions2.default)(this);
130
- const self = this;
131
- app.resourceManager.use(async function verificationIntercept(context, next) {
132
- const { resourceName, actionName, values } = context.action.params;
133
- const key = `${resourceName}:${actionName}`;
134
- const interceptor = self.interceptors.get(key);
135
- if (!interceptor || interceptor.manual) {
136
- return next();
137
- }
138
- return self.intercept(context, next);
139
- });
140
- app.acl.allow("verifications", "create", "public");
141
- this.app.acl.registerSnippet({
142
- name: `pm.${this.name}.providers`,
143
- actions: ["verifications_providers:*"]
144
- });
145
- }
146
- async getDefault() {
147
- const providerRepo = this.db.getRepository("verifications_providers");
148
- return providerRepo.findOne({
149
- filter: {
150
- default: true
151
- }
152
- });
153
- }
154
139
  }
@@ -0,0 +1,18 @@
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 { Context, Next } from '@nocobase/actions';
10
+ declare const _default: {
11
+ listTypes: (ctx: Context, next: Next) => Promise<void>;
12
+ listByScene: (ctx: Context, next: Next) => Promise<any>;
13
+ listByUser: (ctx: Context, next: Next) => Promise<void>;
14
+ listForVerify: (ctx: Context, next: Next) => Promise<any>;
15
+ bind: (ctx: Context, next: Next) => Promise<never>;
16
+ unbind: (ctx: Context, next: Next) => Promise<never>;
17
+ };
18
+ export default _default;
@@ -0,0 +1,175 @@
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 __create = Object.create;
11
+ var __defProp = Object.defineProperty;
12
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
+ var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
15
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16
+ var __export = (target, all) => {
17
+ for (var name in all)
18
+ __defProp(target, name, { get: all[name], enumerable: true });
19
+ };
20
+ var __copyProps = (to, from, except, desc) => {
21
+ if (from && typeof from === "object" || typeof from === "function") {
22
+ for (let key of __getOwnPropNames(from))
23
+ if (!__hasOwnProp.call(to, key) && key !== except)
24
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
+ }
26
+ return to;
27
+ };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
36
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
+ var verificators_exports = {};
38
+ __export(verificators_exports, {
39
+ default: () => verificators_default
40
+ });
41
+ module.exports = __toCommonJS(verificators_exports);
42
+ var import_package = __toESM(require("../../../package.json"));
43
+ var verificators_default = {
44
+ listTypes: async (ctx, next) => {
45
+ const plugin = ctx.app.pm.get("verification");
46
+ ctx.body = plugin.verificationManager.listTypes();
47
+ await next();
48
+ },
49
+ listByScene: async (ctx, next) => {
50
+ const { scene } = ctx.action.params || {};
51
+ const plugin = ctx.app.pm.get("verification");
52
+ const verificationTypes = plugin.verificationManager.getVerificationTypesByScene(scene);
53
+ if (!verificationTypes.length) {
54
+ ctx.body = { verificators: [], availableTypes: [] };
55
+ return next();
56
+ }
57
+ const verificators = await ctx.db.getRepository("verificators").find({
58
+ filter: {
59
+ verificationType: verificationTypes.map((item) => item.type)
60
+ }
61
+ });
62
+ ctx.body = {
63
+ verificators: (verificators || []).map((item) => ({
64
+ name: item.name,
65
+ title: item.title
66
+ })),
67
+ availableTypes: verificationTypes.map((item) => ({
68
+ name: item.type,
69
+ title: item.title
70
+ }))
71
+ };
72
+ await next();
73
+ },
74
+ listByUser: async (ctx, next) => {
75
+ const plugin = ctx.app.pm.get("verification");
76
+ const verificationTypes = plugin.verificationManager.verificationTypes;
77
+ const bindingRequiredTypes = Array.from(verificationTypes.getEntities()).filter(([, options]) => options.bindingRequired).map(([type]) => type);
78
+ const verificators = await ctx.db.getRepository("verificators").find({
79
+ filter: {
80
+ verificationType: bindingRequiredTypes
81
+ }
82
+ });
83
+ const result = [];
84
+ for (const verificator of verificators) {
85
+ try {
86
+ const verificationType = plugin.verificationManager.verificationTypes.get(verificator.verificationType);
87
+ const Verification = plugin.verificationManager.getVerification(verificator.verificationType);
88
+ const verification = new Verification({ ctx, verificator, options: verificator.options });
89
+ const boundInfo = await verification.getPublicBoundInfo(ctx.auth.user.id);
90
+ result.push({
91
+ ...verificator.dataValues,
92
+ title: verificator.title || verificationType.title,
93
+ description: verificator.description || verificationType.description,
94
+ boundInfo
95
+ });
96
+ } catch (error) {
97
+ ctx.log.error(error);
98
+ }
99
+ }
100
+ ctx.body = result;
101
+ await next();
102
+ },
103
+ listForVerify: async (ctx, next) => {
104
+ const { scene } = ctx.action.params || {};
105
+ const plugin = ctx.app.pm.get("verification");
106
+ const verificationTypes = plugin.verificationManager.getVerificationTypesByScene(scene);
107
+ if (!verificationTypes.length) {
108
+ ctx.body = [];
109
+ return next();
110
+ }
111
+ const verificators = await ctx.db.getRepository("verificators").find({
112
+ filter: {
113
+ verificationType: verificationTypes.map((item) => item.type)
114
+ }
115
+ });
116
+ if (!verificators.length) {
117
+ ctx.body = [];
118
+ return next();
119
+ }
120
+ const result = [];
121
+ for (const verificator of verificators) {
122
+ const verificationType = plugin.verificationManager.verificationTypes.get(verificator.verificationType);
123
+ const Verification = plugin.verificationManager.getVerification(verificator.verificationType);
124
+ const verification = new Verification({ ctx, verificator, options: verificator.options });
125
+ const publicBoundInfo = await verification.getPublicBoundInfo(ctx.auth.user.id);
126
+ if (!(publicBoundInfo == null ? void 0 : publicBoundInfo.bound)) {
127
+ continue;
128
+ }
129
+ result.push({
130
+ name: verificator.name,
131
+ title: verificator.title,
132
+ verificationType: verificator.verificationType,
133
+ verificationTypeTitle: verificationType == null ? void 0 : verificationType.title,
134
+ boundInfo: publicBoundInfo
135
+ });
136
+ }
137
+ ctx.body = result;
138
+ await next();
139
+ },
140
+ bind: async (ctx, next) => {
141
+ const { verificator: name } = ctx.action.params.values || {};
142
+ const user = ctx.auth.user;
143
+ const verificationPlugin = ctx.app.pm.get("verification");
144
+ const record = await verificationPlugin.verificationManager.getBoundRecord(user.id, name);
145
+ if (record) {
146
+ return ctx.throw(400, ctx.t("You have already bound this verificator", { ns: import_package.default.name }));
147
+ }
148
+ const verificator = await verificationPlugin.verificationManager.getVerificator(name);
149
+ if (!verificator) {
150
+ return ctx.throw(400, ctx.t("Invalid verificator"));
151
+ }
152
+ const Verification = verificationPlugin.verificationManager.getVerification(verificator.verificationType);
153
+ const verification = new Verification({ ctx, verificator, options: verificator.options });
154
+ const { uuid, meta } = await verification.bind(user.id);
155
+ await verificator.addUser(user.id, {
156
+ through: {
157
+ uuid,
158
+ meta
159
+ }
160
+ });
161
+ ctx.body = {};
162
+ await next();
163
+ },
164
+ unbind: async (ctx, next) => {
165
+ const { unbindVerificator: name } = ctx.action.params.values || {};
166
+ const user = ctx.auth.user;
167
+ const verificationPlugin = ctx.app.pm.get("verification");
168
+ const verificator = await verificationPlugin.verificationManager.getVerificator(name);
169
+ if (!verificator) {
170
+ return ctx.throw(400, ctx.t("Invalid verificator"));
171
+ }
172
+ await verificator.removeUser(user.id);
173
+ await next();
174
+ }
175
+ };
@@ -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
- import { Context, Next } from '@nocobase/actions';
10
- export declare function create(context: Context, next: Next): Promise<never>;
9
+ declare const _default: import("@nocobase/database").CollectionOptions;
10
+ export default _default;
@@ -0,0 +1,75 @@
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 otp_records_exports = {};
28
+ __export(otp_records_exports, {
29
+ default: () => otp_records_default
30
+ });
31
+ module.exports = __toCommonJS(otp_records_exports);
32
+ var import_database = require("@nocobase/database");
33
+ var otp_records_default = (0, import_database.defineCollection)({
34
+ dumpRules: {
35
+ group: "log"
36
+ },
37
+ migrationRules: ["schema-only", "skip"],
38
+ name: "otpRecords",
39
+ shared: true,
40
+ fields: [
41
+ {
42
+ type: "uuid",
43
+ name: "id",
44
+ primaryKey: true
45
+ },
46
+ {
47
+ type: "string",
48
+ name: "action"
49
+ },
50
+ {
51
+ type: "string",
52
+ name: "receiver"
53
+ },
54
+ {
55
+ type: "integer",
56
+ name: "status",
57
+ defaultValue: 0
58
+ },
59
+ {
60
+ type: "unixTimestamp",
61
+ name: "expiresAt",
62
+ accuracy: "millisecond"
63
+ },
64
+ {
65
+ type: "string",
66
+ name: "code"
67
+ },
68
+ {
69
+ type: "belongsTo",
70
+ name: "verificator",
71
+ target: "verificators",
72
+ targetKey: "name"
73
+ }
74
+ ]
75
+ });
@@ -0,0 +1,14 @@
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
+ * Collection for user information of extended authentication methods,
11
+ * such as saml, oicd, oauth, sms, etc.
12
+ */
13
+ declare const _default: import("@nocobase/database").CollectionOptions;
14
+ export default _default;
@@ -0,0 +1,58 @@
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 users_verificators_exports = {};
28
+ __export(users_verificators_exports, {
29
+ default: () => users_verificators_default
30
+ });
31
+ module.exports = __toCommonJS(users_verificators_exports);
32
+ var import_database = require("@nocobase/database");
33
+ var users_verificators_default = (0, import_database.defineCollection)({
34
+ migrationRules: ["schema-only", "overwrite", "skip"],
35
+ name: "usersVerificators",
36
+ createdBy: true,
37
+ updatedBy: true,
38
+ logging: true,
39
+ fields: [
40
+ {
41
+ name: "uuid",
42
+ interface: "input",
43
+ type: "string",
44
+ allowNull: false,
45
+ uiSchema: {
46
+ type: "string",
47
+ title: '{{t("UUID")}}',
48
+ "x-component": "Input",
49
+ required: true
50
+ }
51
+ },
52
+ {
53
+ type: "json",
54
+ name: "meta",
55
+ defaultValue: {}
56
+ }
57
+ ]
58
+ });
@@ -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
+ declare const _default: import("@nocobase/database").CollectionOptions;
10
+ export default _default;
@@ -34,23 +34,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
34
34
  mod
35
35
  ));
36
36
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
- var actions_exports = {};
38
- __export(actions_exports, {
39
- default: () => actions_default
37
+ var verificators_exports = {};
38
+ __export(verificators_exports, {
39
+ default: () => verificators_default
40
+ });
41
+ module.exports = __toCommonJS(verificators_exports);
42
+ var import_database = require("@nocobase/database");
43
+ var import_verificators = __toESM(require("../../collections/verificators"));
44
+ var verificators_default = (0, import_database.defineCollection)({
45
+ migrationRules: ["overwrite", "skip"],
46
+ ...import_verificators.default
40
47
  });
41
- module.exports = __toCommonJS(actions_exports);
42
- var verifications = __toESM(require("./verifications"));
43
- function make(name, mod) {
44
- return Object.keys(mod).reduce(
45
- (result, key) => ({
46
- ...result,
47
- [`${name}:${key}`]: mod[key]
48
- }),
49
- {}
50
- );
51
- }
52
- function actions_default({ app }) {
53
- app.actions({
54
- ...make("verifications", verifications)
55
- });
56
- }
@@ -6,7 +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 declare const PROVIDER_TYPE_SMS_ALIYUN = "sms-aliyun";
10
- export declare const PROVIDER_TYPE_SMS_TENCENT = "sms-tencent";
11
9
  export declare const CODE_STATUS_UNUSED = 0;
12
10
  export declare const CODE_STATUS_USED = 1;
@@ -27,19 +27,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
27
27
  var constants_exports = {};
28
28
  __export(constants_exports, {
29
29
  CODE_STATUS_UNUSED: () => CODE_STATUS_UNUSED,
30
- CODE_STATUS_USED: () => CODE_STATUS_USED,
31
- PROVIDER_TYPE_SMS_ALIYUN: () => PROVIDER_TYPE_SMS_ALIYUN,
32
- PROVIDER_TYPE_SMS_TENCENT: () => PROVIDER_TYPE_SMS_TENCENT
30
+ CODE_STATUS_USED: () => CODE_STATUS_USED
33
31
  });
34
32
  module.exports = __toCommonJS(constants_exports);
35
- const PROVIDER_TYPE_SMS_ALIYUN = "sms-aliyun";
36
- const PROVIDER_TYPE_SMS_TENCENT = "sms-tencent";
37
33
  const CODE_STATUS_UNUSED = 0;
38
34
  const CODE_STATUS_USED = 1;
39
35
  // Annotate the CommonJS export names for ESM import in node:
40
36
  0 && (module.exports = {
41
37
  CODE_STATUS_UNUSED,
42
- CODE_STATUS_USED,
43
- PROVIDER_TYPE_SMS_ALIYUN,
44
- PROVIDER_TYPE_SMS_TENCENT
38
+ CODE_STATUS_USED
45
39
  });
@@ -6,7 +6,10 @@
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 { Interceptor, default } from './Plugin';
9
+ export { default } from './Plugin';
10
10
  export * from './constants';
11
- export { Provider } from './providers/Provider';
11
+ export { SMSOTPVerification } from './otp-verification/sms';
12
+ export { Verification } from './verification';
13
+ export { VerificationManager } from './verification-manager';
14
+ export { SMSProvider } from './otp-verification/sms/providers';
12
15
  export declare const namespace: string;
@@ -37,8 +37,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
37
37
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
38
  var server_exports = {};
39
39
  __export(server_exports, {
40
- Interceptor: () => import_Plugin.Interceptor,
41
- Provider: () => import_Provider.Provider,
40
+ SMSOTPVerification: () => import_sms.SMSOTPVerification,
41
+ SMSProvider: () => import_providers.SMSProvider,
42
+ Verification: () => import_verification.Verification,
43
+ VerificationManager: () => import_verification_manager.VerificationManager,
42
44
  default: () => import_Plugin.default,
43
45
  namespace: () => namespace
44
46
  });
@@ -46,12 +48,17 @@ module.exports = __toCommonJS(server_exports);
46
48
  var import_package = require("../../package.json");
47
49
  var import_Plugin = __toESM(require("./Plugin"));
48
50
  __reExport(server_exports, require("./constants"), module.exports);
49
- var import_Provider = require("./providers/Provider");
51
+ var import_sms = require("./otp-verification/sms");
52
+ var import_verification = require("./verification");
53
+ var import_verification_manager = require("./verification-manager");
54
+ var import_providers = require("./otp-verification/sms/providers");
50
55
  const namespace = import_package.name;
51
56
  // Annotate the CommonJS export names for ESM import in node:
52
57
  0 && (module.exports = {
53
- Interceptor,
54
- Provider,
58
+ SMSOTPVerification,
59
+ SMSProvider,
60
+ Verification,
61
+ VerificationManager,
55
62
  namespace,
56
63
  ...require("./constants")
57
64
  });