@nocobase/plugin-verification 1.7.0-alpha.1 → 1.7.0-beta.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.
- package/dist/client/7551e1f2e04bca2f.js +10 -0
- package/dist/client/{verificators/VerificatorSelect.d.ts → ProviderOptions.d.ts} +2 -1
- package/dist/client/{otp-verification/sms/providers/TencentSettings.d.ts → VerificationProviders.d.ts} +1 -1
- package/dist/client/index.d.ts +0 -7
- package/dist/client/index.js +1 -1
- package/dist/client/locale/index.d.ts +1 -1
- package/dist/client/{otp-verification/sms/BindForm.d.ts → providerTypes/index.d.ts} +4 -3
- package/dist/client/providerTypes/sms-aliyun.d.ts +66 -0
- package/dist/client/providerTypes/sms-tencent.d.ts +66 -0
- package/dist/externalVersion.js +11 -11
- package/dist/locale/de-DE.json +22 -0
- package/dist/locale/en-US.json +1 -17
- package/dist/locale/nl-NL.json +22 -0
- package/dist/locale/zh-CN.json +2 -19
- package/dist/node_modules/@alicloud/dysmsapi20170525/package.json +1 -1
- package/dist/node_modules/@alicloud/openapi-client/package.json +1 -1
- package/dist/node_modules/@alicloud/tea-util/package.json +1 -1
- package/dist/node_modules/tencentcloud-sdk-nodejs/package.json +1 -1
- package/dist/server/Plugin.d.ts +16 -5
- package/dist/server/Plugin.js +72 -57
- package/dist/{client/otp-verification/sms/providers/AliyunSettings.d.ts → server/actions/index.d.ts} +3 -2
- package/dist/server/{collections/verificators.js → actions/index.js} +19 -10
- package/dist/server/{collections/verificators.d.ts → actions/verifications.d.ts} +2 -2
- package/dist/server/actions/verifications.js +146 -0
- package/dist/server/constants.d.ts +2 -0
- package/dist/server/constants.js +8 -2
- package/dist/server/index.d.ts +2 -5
- package/dist/server/index.js +5 -12
- package/dist/server/{otp-verification/sms/providers/index.d.ts → providers/Provider.d.ts} +4 -2
- package/dist/server/{otp-verification/sms/providers/index.js → providers/Provider.js} +10 -8
- package/dist/server/{migrations/20250111192640-providers2verificators.d.ts → providers/index.d.ts} +6 -5
- package/dist/server/providers/index.js +52 -0
- package/dist/server/{otp-verification/sms/providers → providers}/sms-aliyun.d.ts +3 -3
- package/dist/server/{otp-verification/sms/providers → providers}/sms-aliyun.js +4 -4
- package/dist/server/{otp-verification/sms/providers → providers}/sms-tencent.d.ts +3 -3
- package/dist/server/{otp-verification/sms/providers → providers}/sms-tencent.js +4 -4
- package/package.json +6 -8
- package/dist/client/VerificationMenu.d.ts +0 -13
- package/dist/client/cfedbdcfbe65d5f6.js +0 -10
- package/dist/client/d0b398212e5aa575.js +0 -10
- package/dist/client/otp-verification/VerificationCode.d.ts +0 -16
- package/dist/client/otp-verification/sms/AdminSettingsForm.d.ts +0 -12
- package/dist/client/otp-verification/sms/VerificationForm.d.ts +0 -11
- package/dist/client/otp-verification/sms/index.d.ts +0 -26
- package/dist/client/otp-verification/sms/provider-manager.d.ts +0 -19
- package/dist/client/schemas/verificators.d.ts +0 -66
- package/dist/client/verification-manager/index.d.ts +0 -32
- package/dist/client/verificators/Verificators.d.ts +0 -12
- package/dist/client/verificators/verification-types.d.ts +0 -24
- package/dist/collections/verificators.d.ts +0 -50
- package/dist/collections/verificators.js +0 -70
- package/dist/constants.d.ts +0 -11
- package/dist/constants.js +0 -42
- package/dist/server/actions/verificators.d.ts +0 -18
- package/dist/server/actions/verificators.js +0 -175
- package/dist/server/collections/otp-records.d.ts +0 -10
- package/dist/server/collections/otp-records.js +0 -75
- package/dist/server/collections/users-verificators.d.ts +0 -14
- package/dist/server/collections/users-verificators.js +0 -58
- package/dist/server/migrations/20250111192640-providers2verificators.js +0 -83
- package/dist/server/otp-verification/index.d.ts +0 -25
- package/dist/server/otp-verification/index.js +0 -94
- package/dist/server/otp-verification/sms/index.d.ts +0 -37
- package/dist/server/otp-verification/sms/index.js +0 -87
- package/dist/server/otp-verification/sms/resource/sms-otp-providers.d.ts +0 -16
- package/dist/server/otp-verification/sms/resource/sms-otp-providers.js +0 -41
- package/dist/server/otp-verification/sms/resource/sms-otp.d.ts +0 -18
- package/dist/server/otp-verification/sms/resource/sms-otp.js +0 -141
- package/dist/server/verification-manager.d.ts +0 -68
- package/dist/server/verification-manager.js +0 -223
- package/dist/server/verification.d.ts +0 -70
- package/dist/server/verification.js +0 -70
package/dist/server/Plugin.js
CHANGED
|
@@ -39,69 +39,55 @@ __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");
|
|
42
44
|
var import_server = require("@nocobase/server");
|
|
43
45
|
var import_utils = require("@nocobase/utils");
|
|
44
46
|
var import__ = require(".");
|
|
45
|
-
var
|
|
46
|
-
var
|
|
47
|
-
var
|
|
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"));
|
|
47
|
+
var import_actions2 = __toESM(require("./actions"));
|
|
48
|
+
var import_constants = require("./constants");
|
|
49
|
+
var import_providers = __toESM(require("./providers"));
|
|
54
50
|
class PluginVerficationServer extends import_server.Plugin {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
async
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
this.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
this.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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 || {};
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
this.verificationManager.registerScene("unbind-verificator", {
|
|
92
|
-
actions: {
|
|
93
|
-
"verificators:unbind": {}
|
|
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
|
|
94
75
|
}
|
|
95
76
|
});
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
+
};
|
|
105
91
|
async install() {
|
|
106
92
|
const {
|
|
107
93
|
DEFAULT_SMS_VERIFY_CODE_PROVIDER,
|
|
@@ -136,4 +122,33 @@ class PluginVerficationServer extends import_server.Plugin {
|
|
|
136
122
|
});
|
|
137
123
|
}
|
|
138
124
|
}
|
|
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
|
+
}
|
|
139
154
|
}
|
package/dist/{client/otp-verification/sms/providers/AliyunSettings.d.ts → server/actions/index.d.ts}
RENAMED
|
@@ -6,5 +6,6 @@
|
|
|
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
|
-
|
|
10
|
-
|
|
9
|
+
export default function ({ app }: {
|
|
10
|
+
app: any;
|
|
11
|
+
}): void;
|
|
@@ -34,14 +34,23 @@ 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
|
|
38
|
-
__export(
|
|
39
|
-
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
|
|
37
|
+
var actions_exports = {};
|
|
38
|
+
__export(actions_exports, {
|
|
39
|
+
default: () => actions_default
|
|
47
40
|
});
|
|
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,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
|
-
|
|
10
|
-
export
|
|
9
|
+
import { Context, Next } from '@nocobase/actions';
|
|
10
|
+
export declare function create(context: Context, next: Next): Promise<never>;
|
|
@@ -0,0 +1,146 @@
|
|
|
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 verifications_exports = {};
|
|
38
|
+
__export(verifications_exports, {
|
|
39
|
+
create: () => create
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(verifications_exports);
|
|
42
|
+
var import_actions = __toESM(require("@nocobase/actions"));
|
|
43
|
+
var import_database = require("@nocobase/database");
|
|
44
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
45
|
+
var import_crypto = require("crypto");
|
|
46
|
+
var import_util = require("util");
|
|
47
|
+
var import__ = require("..");
|
|
48
|
+
var import_constants = require("../constants");
|
|
49
|
+
const asyncRandomInt = (0, import_util.promisify)(import_crypto.randomInt);
|
|
50
|
+
async function create(context, next) {
|
|
51
|
+
const plugin = context.app.getPlugin("verification");
|
|
52
|
+
const { values } = context.action.params;
|
|
53
|
+
const interceptor = plugin.interceptors.get(values == null ? void 0 : values.type);
|
|
54
|
+
if (!interceptor) {
|
|
55
|
+
return context.throw(400, "Invalid action type");
|
|
56
|
+
}
|
|
57
|
+
const providerItem = await plugin.getDefault();
|
|
58
|
+
if (!providerItem) {
|
|
59
|
+
console.error(`[verification] no provider for action (${values.type}) provided`);
|
|
60
|
+
return context.throw(500);
|
|
61
|
+
}
|
|
62
|
+
const receiver = interceptor.getReceiver(context);
|
|
63
|
+
if (!receiver) {
|
|
64
|
+
return context.throw(400, {
|
|
65
|
+
code: "InvalidReceiver",
|
|
66
|
+
message: context.t("Not a valid cellphone number, please re-enter", { ns: import__.namespace })
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
const VerificationModel = context.db.getModel("verifications");
|
|
70
|
+
const record = await VerificationModel.findOne({
|
|
71
|
+
where: {
|
|
72
|
+
type: values.type,
|
|
73
|
+
receiver,
|
|
74
|
+
status: import_constants.CODE_STATUS_UNUSED,
|
|
75
|
+
expiresAt: {
|
|
76
|
+
[import_database.Op.gt]: /* @__PURE__ */ new Date()
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
if (record) {
|
|
81
|
+
const seconds = (0, import_dayjs.default)(record.get("expiresAt")).diff((0, import_dayjs.default)(), "seconds");
|
|
82
|
+
return context.throw(429, {
|
|
83
|
+
code: "RateLimit",
|
|
84
|
+
message: context.t("Please don't retry in {{time}} seconds", { time: seconds, ns: import__.namespace })
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const code = (await asyncRandomInt(999999)).toString(10).padStart(6, "0");
|
|
88
|
+
if (interceptor.validate) {
|
|
89
|
+
try {
|
|
90
|
+
await interceptor.validate(context, receiver);
|
|
91
|
+
} catch (err) {
|
|
92
|
+
return context.throw(400, { code: "InvalidReceiver", message: err.message });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const ProviderType = plugin.providers.get(providerItem.get("type"));
|
|
96
|
+
const provider = new ProviderType(plugin, providerItem.get("options"));
|
|
97
|
+
try {
|
|
98
|
+
await provider.send(receiver, { code });
|
|
99
|
+
console.log("verification code sent");
|
|
100
|
+
} catch (error) {
|
|
101
|
+
switch (error.name) {
|
|
102
|
+
case "InvalidReceiver":
|
|
103
|
+
return context.throw(400, {
|
|
104
|
+
code: "InvalidReceiver",
|
|
105
|
+
message: context.t("Not a valid cellphone number, please re-enter", { ns: import__.namespace })
|
|
106
|
+
});
|
|
107
|
+
case "RateLimit":
|
|
108
|
+
return context.throw(429, context.t("You are trying so frequently, please slow down", { ns: import__.namespace }));
|
|
109
|
+
default:
|
|
110
|
+
console.error(error);
|
|
111
|
+
return context.throw(
|
|
112
|
+
500,
|
|
113
|
+
context.t("Verification send failed, please try later or contact to administrator", { ns: import__.namespace })
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const data = {
|
|
118
|
+
id: (0, import_crypto.randomUUID)(),
|
|
119
|
+
type: values.type,
|
|
120
|
+
receiver,
|
|
121
|
+
content: code,
|
|
122
|
+
expiresAt: Date.now() + (interceptor.expiresIn ?? 60) * 1e3,
|
|
123
|
+
status: import_constants.CODE_STATUS_UNUSED,
|
|
124
|
+
providerId: providerItem.get("id")
|
|
125
|
+
};
|
|
126
|
+
context.action.mergeParams(
|
|
127
|
+
{
|
|
128
|
+
values: data
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
values: "overwrite"
|
|
132
|
+
}
|
|
133
|
+
);
|
|
134
|
+
await import_actions.default.create(context, async () => {
|
|
135
|
+
const { body: result } = context;
|
|
136
|
+
context.body = {
|
|
137
|
+
id: result.id,
|
|
138
|
+
expiresAt: result.expiresAt
|
|
139
|
+
};
|
|
140
|
+
return next();
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
144
|
+
0 && (module.exports = {
|
|
145
|
+
create
|
|
146
|
+
});
|
|
@@ -6,5 +6,7 @@
|
|
|
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";
|
|
9
11
|
export declare const CODE_STATUS_UNUSED = 0;
|
|
10
12
|
export declare const CODE_STATUS_USED = 1;
|
package/dist/server/constants.js
CHANGED
|
@@ -27,13 +27,19 @@ 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
|
|
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
|
|
31
33
|
});
|
|
32
34
|
module.exports = __toCommonJS(constants_exports);
|
|
35
|
+
const PROVIDER_TYPE_SMS_ALIYUN = "sms-aliyun";
|
|
36
|
+
const PROVIDER_TYPE_SMS_TENCENT = "sms-tencent";
|
|
33
37
|
const CODE_STATUS_UNUSED = 0;
|
|
34
38
|
const CODE_STATUS_USED = 1;
|
|
35
39
|
// Annotate the CommonJS export names for ESM import in node:
|
|
36
40
|
0 && (module.exports = {
|
|
37
41
|
CODE_STATUS_UNUSED,
|
|
38
|
-
CODE_STATUS_USED
|
|
42
|
+
CODE_STATUS_USED,
|
|
43
|
+
PROVIDER_TYPE_SMS_ALIYUN,
|
|
44
|
+
PROVIDER_TYPE_SMS_TENCENT
|
|
39
45
|
});
|
package/dist/server/index.d.ts
CHANGED
|
@@ -6,10 +6,7 @@
|
|
|
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 { default } from './Plugin';
|
|
9
|
+
export { Interceptor, default } from './Plugin';
|
|
10
10
|
export * from './constants';
|
|
11
|
-
export {
|
|
12
|
-
export { Verification } from './verification';
|
|
13
|
-
export { VerificationManager } from './verification-manager';
|
|
14
|
-
export { SMSProvider } from './otp-verification/sms/providers';
|
|
11
|
+
export { Provider } from './providers/Provider';
|
|
15
12
|
export declare const namespace: string;
|
package/dist/server/index.js
CHANGED
|
@@ -37,10 +37,8 @@ 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
|
-
|
|
41
|
-
|
|
42
|
-
Verification: () => import_verification.Verification,
|
|
43
|
-
VerificationManager: () => import_verification_manager.VerificationManager,
|
|
40
|
+
Interceptor: () => import_Plugin.Interceptor,
|
|
41
|
+
Provider: () => import_Provider.Provider,
|
|
44
42
|
default: () => import_Plugin.default,
|
|
45
43
|
namespace: () => namespace
|
|
46
44
|
});
|
|
@@ -48,17 +46,12 @@ module.exports = __toCommonJS(server_exports);
|
|
|
48
46
|
var import_package = require("../../package.json");
|
|
49
47
|
var import_Plugin = __toESM(require("./Plugin"));
|
|
50
48
|
__reExport(server_exports, require("./constants"), module.exports);
|
|
51
|
-
var
|
|
52
|
-
var import_verification = require("./verification");
|
|
53
|
-
var import_verification_manager = require("./verification-manager");
|
|
54
|
-
var import_providers = require("./otp-verification/sms/providers");
|
|
49
|
+
var import_Provider = require("./providers/Provider");
|
|
55
50
|
const namespace = import_package.name;
|
|
56
51
|
// Annotate the CommonJS export names for ESM import in node:
|
|
57
52
|
0 && (module.exports = {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
Verification,
|
|
61
|
-
VerificationManager,
|
|
53
|
+
Interceptor,
|
|
54
|
+
Provider,
|
|
62
55
|
namespace,
|
|
63
56
|
...require("./constants")
|
|
64
57
|
});
|
|
@@ -6,9 +6,11 @@
|
|
|
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
|
-
|
|
9
|
+
import Plugin from '../Plugin';
|
|
10
|
+
export declare class Provider {
|
|
11
|
+
protected plugin: Plugin;
|
|
10
12
|
protected options: any;
|
|
11
|
-
constructor(options: any);
|
|
13
|
+
constructor(plugin: Plugin, options: any);
|
|
12
14
|
send(receiver: string, data: {
|
|
13
15
|
[key: string]: any;
|
|
14
16
|
}): Promise<any>;
|
|
@@ -24,19 +24,21 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
24
24
|
return to;
|
|
25
25
|
};
|
|
26
26
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
-
var
|
|
28
|
-
__export(
|
|
29
|
-
|
|
27
|
+
var Provider_exports = {};
|
|
28
|
+
__export(Provider_exports, {
|
|
29
|
+
Provider: () => Provider
|
|
30
30
|
});
|
|
31
|
-
module.exports = __toCommonJS(
|
|
32
|
-
class
|
|
33
|
-
constructor(options) {
|
|
34
|
-
this.
|
|
31
|
+
module.exports = __toCommonJS(Provider_exports);
|
|
32
|
+
class Provider {
|
|
33
|
+
constructor(plugin, options) {
|
|
34
|
+
this.plugin = plugin;
|
|
35
|
+
this.options = plugin.app.environment.renderJsonTemplate(options);
|
|
35
36
|
}
|
|
37
|
+
options;
|
|
36
38
|
async send(receiver, data) {
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
41
|
// Annotate the CommonJS export names for ESM import in node:
|
|
40
42
|
0 && (module.exports = {
|
|
41
|
-
|
|
43
|
+
Provider
|
|
42
44
|
});
|
package/dist/server/{migrations/20250111192640-providers2verificators.d.ts → providers/index.d.ts}
RENAMED
|
@@ -6,9 +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
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
up(): Promise<void>;
|
|
9
|
+
import Plugin from '../Plugin';
|
|
10
|
+
import { Provider } from './Provider';
|
|
11
|
+
interface Providers {
|
|
12
|
+
[key: string]: typeof Provider;
|
|
14
13
|
}
|
|
14
|
+
export default function (plugin: Plugin, more?: Providers): Promise<void>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
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 providers_exports = {};
|
|
38
|
+
__export(providers_exports, {
|
|
39
|
+
default: () => providers_default
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(providers_exports);
|
|
42
|
+
var import_constants = require("../constants");
|
|
43
|
+
var import_sms_aliyun = __toESM(require("./sms-aliyun"));
|
|
44
|
+
var import_sms_tencent = __toESM(require("./sms-tencent"));
|
|
45
|
+
async function providers_default(plugin, more = {}) {
|
|
46
|
+
const { providers } = plugin;
|
|
47
|
+
providers.register(import_constants.PROVIDER_TYPE_SMS_ALIYUN, import_sms_aliyun.default);
|
|
48
|
+
providers.register(import_constants.PROVIDER_TYPE_SMS_TENCENT, import_sms_tencent.default);
|
|
49
|
+
for (const [name, provider] of Object.entries({ ...more })) {
|
|
50
|
+
providers.register(name, provider);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
import DysmsApi from '@alicloud/dysmsapi20170525';
|
|
10
|
-
import {
|
|
11
|
-
export default class extends
|
|
10
|
+
import { Provider } from './Provider';
|
|
11
|
+
export default class extends Provider {
|
|
12
12
|
client: DysmsApi;
|
|
13
|
-
constructor(options: any);
|
|
13
|
+
constructor(plugin: any, options: any);
|
|
14
14
|
send(phoneNumbers: any, data?: {}): Promise<never>;
|
|
15
15
|
}
|
|
@@ -42,11 +42,11 @@ module.exports = __toCommonJS(sms_aliyun_exports);
|
|
|
42
42
|
var import_dysmsapi20170525 = __toESM(require("@alicloud/dysmsapi20170525"));
|
|
43
43
|
var OpenApi = __toESM(require("@alicloud/openapi-client"));
|
|
44
44
|
var import_tea_util = require("@alicloud/tea-util");
|
|
45
|
-
var
|
|
46
|
-
class sms_aliyun_default extends
|
|
45
|
+
var import_Provider = require("./Provider");
|
|
46
|
+
class sms_aliyun_default extends import_Provider.Provider {
|
|
47
47
|
client;
|
|
48
|
-
constructor(options) {
|
|
49
|
-
super(options);
|
|
48
|
+
constructor(plugin, options) {
|
|
49
|
+
super(plugin, options);
|
|
50
50
|
const { accessKeyId, accessKeySecret, endpoint } = this.options;
|
|
51
51
|
const config = new OpenApi.Config({
|
|
52
52
|
// 您的 AccessKey ID
|
|
@@ -6,11 +6,11 @@
|
|
|
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 {
|
|
9
|
+
import { Provider } from './Provider';
|
|
10
10
|
declare const smsClient: typeof import("tencentcloud-sdk-nodejs/tencentcloud/services/sms/v20210111/sms_client").Client;
|
|
11
|
-
export default class extends
|
|
11
|
+
export default class extends Provider {
|
|
12
12
|
client: InstanceType<typeof smsClient>;
|
|
13
|
-
constructor(options: any);
|
|
13
|
+
constructor(plugin: any, options: any);
|
|
14
14
|
send(phoneNumbers: any, data: {
|
|
15
15
|
code: string;
|
|
16
16
|
}): Promise<string>;
|
|
@@ -40,12 +40,12 @@ __export(sms_tencent_exports, {
|
|
|
40
40
|
});
|
|
41
41
|
module.exports = __toCommonJS(sms_tencent_exports);
|
|
42
42
|
var tencentcloud = __toESM(require("tencentcloud-sdk-nodejs"));
|
|
43
|
-
var
|
|
43
|
+
var import_Provider = require("./Provider");
|
|
44
44
|
const smsClient = tencentcloud.sms.v20210111.Client;
|
|
45
|
-
class sms_tencent_default extends
|
|
45
|
+
class sms_tencent_default extends import_Provider.Provider {
|
|
46
46
|
client;
|
|
47
|
-
constructor(options) {
|
|
48
|
-
super(options);
|
|
47
|
+
constructor(plugin, options) {
|
|
48
|
+
super(plugin, options);
|
|
49
49
|
const { secretId, secretKey, region, endpoint } = this.options;
|
|
50
50
|
this.client = new smsClient({
|
|
51
51
|
credential: {
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-verification",
|
|
3
3
|
"displayName": "Verification",
|
|
4
|
-
"displayName.zh-CN": "
|
|
5
|
-
"description": "
|
|
6
|
-
"description.zh-CN": "
|
|
7
|
-
"version": "1.7.0-
|
|
4
|
+
"displayName.zh-CN": "验证码",
|
|
5
|
+
"description": "verification setting.",
|
|
6
|
+
"description.zh-CN": "验证码配置。",
|
|
7
|
+
"version": "1.7.0-beta.2",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "./dist/server/index.js",
|
|
10
10
|
"homepage": "https://docs.nocobase.com/handbook/verification",
|
|
@@ -31,10 +31,8 @@
|
|
|
31
31
|
"@nocobase/test": "1.x",
|
|
32
32
|
"@nocobase/utils": "1.x"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "58b206bdfca521e79a69989ca55dd19075dca523",
|
|
35
35
|
"keywords": [
|
|
36
|
-
"Authentication"
|
|
37
|
-
"Verification",
|
|
38
|
-
"Security"
|
|
36
|
+
"Authentication"
|
|
39
37
|
]
|
|
40
38
|
}
|
|
@@ -1,13 +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
|
-
import React from 'react';
|
|
10
|
-
export declare const UserVerificatorsContext: React.Context<{
|
|
11
|
-
refresh: () => void;
|
|
12
|
-
}>;
|
|
13
|
-
export declare const Verification: () => React.JSX.Element;
|