@nocobase/plugin-verification 1.7.0-beta.7 → 1.7.0-beta.9
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/{providerTypes/index.d.ts → VerificationMenu.d.ts} +5 -4
- package/dist/client/cfedbdcfbe65d5f6.js +10 -0
- package/dist/client/d0b398212e5aa575.js +10 -0
- package/dist/client/index.d.ts +7 -0
- package/dist/client/index.js +1 -1
- package/dist/client/locale/index.d.ts +1 -1
- package/dist/client/otp-verification/VerificationCode.d.ts +16 -0
- package/dist/client/otp-verification/sms/AdminSettingsForm.d.ts +12 -0
- package/dist/client/otp-verification/sms/BindForm.d.ts +11 -0
- package/dist/client/otp-verification/sms/VerificationForm.d.ts +11 -0
- package/dist/client/otp-verification/sms/index.d.ts +26 -0
- package/dist/client/otp-verification/sms/provider-manager.d.ts +19 -0
- package/dist/client/{VerificationProviders.d.ts → otp-verification/sms/providers/AliyunSettings.d.ts} +1 -1
- package/dist/{server/actions/index.d.ts → client/otp-verification/sms/providers/TencentSettings.d.ts} +2 -3
- package/dist/client/schemas/verificators.d.ts +66 -0
- package/dist/client/verification-manager/index.d.ts +32 -0
- package/dist/client/{ProviderOptions.d.ts → verificators/VerificatorSelect.d.ts} +1 -2
- package/dist/client/verificators/Verificators.d.ts +12 -0
- package/dist/client/verificators/verification-types.d.ts +24 -0
- package/dist/collections/verificators.d.ts +50 -0
- package/dist/collections/verificators.js +70 -0
- package/dist/constants.d.ts +11 -0
- package/dist/constants.js +42 -0
- package/dist/externalVersion.js +13 -13
- package/dist/locale/en-US.json +17 -1
- package/dist/locale/zh-CN.json +19 -2
- 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 +5 -16
- package/dist/server/Plugin.js +57 -72
- package/dist/server/actions/verificators.d.ts +18 -0
- package/dist/server/actions/verificators.js +175 -0
- package/dist/server/{actions/verifications.d.ts → collections/otp-records.d.ts} +2 -2
- package/dist/server/collections/otp-records.js +75 -0
- package/dist/server/collections/users-verificators.d.ts +14 -0
- package/dist/server/collections/users-verificators.js +58 -0
- package/dist/server/collections/verificators.d.ts +10 -0
- package/dist/server/{actions/index.js → collections/verificators.js} +10 -19
- package/dist/server/constants.d.ts +0 -2
- package/dist/server/constants.js +2 -8
- package/dist/server/index.d.ts +5 -2
- package/dist/server/index.js +12 -5
- package/dist/server/migrations/20250111192640-providers2verificators.d.ts +14 -0
- package/dist/server/migrations/20250111192640-providers2verificators.js +83 -0
- package/dist/server/otp-verification/index.d.ts +25 -0
- package/dist/server/otp-verification/index.js +94 -0
- package/dist/server/otp-verification/sms/index.d.ts +37 -0
- package/dist/server/otp-verification/sms/index.js +87 -0
- package/dist/server/{providers/Provider.d.ts → otp-verification/sms/providers/index.d.ts} +2 -4
- package/dist/server/{providers/Provider.js → otp-verification/sms/providers/index.js} +8 -10
- package/dist/server/{providers → otp-verification/sms/providers}/sms-aliyun.d.ts +3 -3
- package/dist/server/{providers → otp-verification/sms/providers}/sms-aliyun.js +4 -4
- package/dist/server/{providers → otp-verification/sms/providers}/sms-tencent.d.ts +3 -3
- package/dist/server/{providers → otp-verification/sms/providers}/sms-tencent.js +4 -4
- package/dist/server/otp-verification/sms/resource/sms-otp-providers.d.ts +16 -0
- package/dist/server/otp-verification/sms/resource/sms-otp-providers.js +41 -0
- package/dist/server/otp-verification/sms/resource/sms-otp.d.ts +18 -0
- package/dist/server/otp-verification/sms/resource/sms-otp.js +141 -0
- package/dist/server/verification-manager.d.ts +68 -0
- package/dist/server/verification-manager.js +223 -0
- package/dist/server/verification.d.ts +70 -0
- package/dist/server/verification.js +70 -0
- package/package.json +8 -6
- package/dist/client/7551e1f2e04bca2f.js +0 -10
- package/dist/client/providerTypes/sms-aliyun.d.ts +0 -66
- package/dist/client/providerTypes/sms-tencent.d.ts +0 -66
- package/dist/server/actions/verifications.js +0 -146
- package/dist/server/providers/index.d.ts +0 -15
- package/dist/server/providers/index.js +0 -52
|
@@ -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
|
|
38
|
-
__export(
|
|
39
|
-
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;
|
package/dist/server/constants.js
CHANGED
|
@@ -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
|
});
|
package/dist/server/index.d.ts
CHANGED
|
@@ -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 {
|
|
9
|
+
export { default } from './Plugin';
|
|
10
10
|
export * from './constants';
|
|
11
|
-
export {
|
|
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;
|
package/dist/server/index.js
CHANGED
|
@@ -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
|
-
|
|
41
|
-
|
|
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
|
|
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
|
-
|
|
54
|
-
|
|
58
|
+
SMSOTPVerification,
|
|
59
|
+
SMSProvider,
|
|
60
|
+
Verification,
|
|
61
|
+
VerificationManager,
|
|
55
62
|
namespace,
|
|
56
63
|
...require("./constants")
|
|
57
64
|
});
|
|
@@ -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
|
+
import { Migration } from '@nocobase/server';
|
|
10
|
+
export default class extends Migration {
|
|
11
|
+
on: string;
|
|
12
|
+
appVersion: string;
|
|
13
|
+
up(): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
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 providers2verificators_exports = {};
|
|
28
|
+
__export(providers2verificators_exports, {
|
|
29
|
+
default: () => providers2verificators_default
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(providers2verificators_exports);
|
|
32
|
+
var import_server = require("@nocobase/server");
|
|
33
|
+
var import_utils = require("@nocobase/utils");
|
|
34
|
+
var import_constants = require("../../constants");
|
|
35
|
+
class providers2verificators_default extends import_server.Migration {
|
|
36
|
+
on = "afterLoad";
|
|
37
|
+
// 'beforeLoad' or 'afterLoad'
|
|
38
|
+
appVersion = "<1.6.1";
|
|
39
|
+
async up() {
|
|
40
|
+
const providers = await this.db.getRepository("verifications_providers").find();
|
|
41
|
+
const verificators = [];
|
|
42
|
+
let defaultVerificator;
|
|
43
|
+
providers.forEach((provider) => {
|
|
44
|
+
const verificator = {
|
|
45
|
+
name: `v_${(0, import_utils.uid)()}`,
|
|
46
|
+
title: provider.title,
|
|
47
|
+
verificationType: import_constants.SMS_OTP_VERIFICATION_TYPE,
|
|
48
|
+
options: {
|
|
49
|
+
provider: provider.type,
|
|
50
|
+
settings: provider.options
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
verificators.push(verificator);
|
|
54
|
+
if (provider.default) {
|
|
55
|
+
defaultVerificator = verificator;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
const smsAuth = await this.db.getRepository("authenticators").find({
|
|
59
|
+
filter: {
|
|
60
|
+
authType: "SMS"
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
await this.db.sequelize.transaction(async (transaction) => {
|
|
64
|
+
var _a;
|
|
65
|
+
const verificatorModel = this.db.getModel("verificators");
|
|
66
|
+
await verificatorModel.bulkCreate(verificators, { transaction });
|
|
67
|
+
for (const item of smsAuth) {
|
|
68
|
+
await item.update(
|
|
69
|
+
{
|
|
70
|
+
options: {
|
|
71
|
+
...item.options,
|
|
72
|
+
public: {
|
|
73
|
+
...(_a = item.options) == null ? void 0 : _a.public,
|
|
74
|
+
verificator: defaultVerificator.name
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
{ transaction }
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
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 { Verification } from '../verification';
|
|
10
|
+
export declare class OTPVerification extends Verification {
|
|
11
|
+
expiresIn: number;
|
|
12
|
+
verify({ resource, action, boundInfo, verifyParams }: {
|
|
13
|
+
resource: any;
|
|
14
|
+
action: any;
|
|
15
|
+
boundInfo: any;
|
|
16
|
+
verifyParams: any;
|
|
17
|
+
}): Promise<any>;
|
|
18
|
+
bind(userId: number, resource?: string, action?: string): Promise<{
|
|
19
|
+
uuid: string;
|
|
20
|
+
meta?: any;
|
|
21
|
+
}>;
|
|
22
|
+
onActionComplete({ verifyResult }: {
|
|
23
|
+
verifyResult: any;
|
|
24
|
+
}): Promise<void>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
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 otp_verification_exports = {};
|
|
38
|
+
__export(otp_verification_exports, {
|
|
39
|
+
OTPVerification: () => OTPVerification
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(otp_verification_exports);
|
|
42
|
+
var import_verification = require("../verification");
|
|
43
|
+
var import_constants = require("../constants");
|
|
44
|
+
var import_package = __toESM(require("../../../package.json"));
|
|
45
|
+
class OTPVerification extends import_verification.Verification {
|
|
46
|
+
expiresIn = 120;
|
|
47
|
+
async verify({ resource, action, boundInfo, verifyParams }) {
|
|
48
|
+
const { uuid: receiver } = boundInfo;
|
|
49
|
+
const code = verifyParams.code;
|
|
50
|
+
if (!code) {
|
|
51
|
+
return this.ctx.throw(400, "Verification code is invalid");
|
|
52
|
+
}
|
|
53
|
+
const VerificationRepo = this.ctx.db.getRepository("otpRecords");
|
|
54
|
+
const item = await VerificationRepo.findOne({
|
|
55
|
+
filter: {
|
|
56
|
+
receiver,
|
|
57
|
+
action: `${resource}:${action}`,
|
|
58
|
+
code,
|
|
59
|
+
expiresAt: {
|
|
60
|
+
$dateAfter: /* @__PURE__ */ new Date()
|
|
61
|
+
},
|
|
62
|
+
status: import_constants.CODE_STATUS_UNUSED,
|
|
63
|
+
verificatorName: this.verificator.name
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
if (!item) {
|
|
67
|
+
return this.ctx.throw(400, {
|
|
68
|
+
code: "InvalidVerificationCode",
|
|
69
|
+
message: this.ctx.t("Verification code is invalid", { ns: import_package.default.name })
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return { codeInfo: item };
|
|
73
|
+
}
|
|
74
|
+
async bind(userId, resource, action) {
|
|
75
|
+
const { uuid, code } = this.ctx.action.params.values || {};
|
|
76
|
+
await this.verify({
|
|
77
|
+
resource: resource || "verificators",
|
|
78
|
+
action: action || "bind",
|
|
79
|
+
boundInfo: { uuid },
|
|
80
|
+
verifyParams: { code }
|
|
81
|
+
});
|
|
82
|
+
return { uuid };
|
|
83
|
+
}
|
|
84
|
+
async onActionComplete({ verifyResult }) {
|
|
85
|
+
const { codeInfo } = verifyResult;
|
|
86
|
+
await codeInfo.update({
|
|
87
|
+
status: import_constants.CODE_STATUS_USED
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
92
|
+
0 && (module.exports = {
|
|
93
|
+
OTPVerification
|
|
94
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
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 { Registry } from '@nocobase/utils';
|
|
10
|
+
import { OTPVerification } from '..';
|
|
11
|
+
import { SMSProvider } from './providers';
|
|
12
|
+
type SMSProviderOptions = {
|
|
13
|
+
title: string;
|
|
14
|
+
provider: typeof SMSProvider;
|
|
15
|
+
};
|
|
16
|
+
export declare class SMSOTPProviderManager {
|
|
17
|
+
providers: Registry<SMSProviderOptions>;
|
|
18
|
+
registerProvider(type: string, options: SMSProviderOptions): void;
|
|
19
|
+
listProviders(): {
|
|
20
|
+
name: string;
|
|
21
|
+
title: string;
|
|
22
|
+
}[];
|
|
23
|
+
}
|
|
24
|
+
export declare class SMSOTPVerification extends OTPVerification {
|
|
25
|
+
getProvider(): Promise<SMSProvider>;
|
|
26
|
+
getPublicBoundInfo(userId: number): Promise<{
|
|
27
|
+
bound: boolean;
|
|
28
|
+
publicInfo?: undefined;
|
|
29
|
+
} | {
|
|
30
|
+
bound: boolean;
|
|
31
|
+
publicInfo: string;
|
|
32
|
+
}>;
|
|
33
|
+
validateBoundInfo({ uuid: phone }: {
|
|
34
|
+
uuid: any;
|
|
35
|
+
}): Promise<boolean>;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
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 sms_exports = {};
|
|
28
|
+
__export(sms_exports, {
|
|
29
|
+
SMSOTPProviderManager: () => SMSOTPProviderManager,
|
|
30
|
+
SMSOTPVerification: () => SMSOTPVerification
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(sms_exports);
|
|
33
|
+
var import_utils = require("@nocobase/utils");
|
|
34
|
+
var import__ = require("..");
|
|
35
|
+
class SMSOTPProviderManager {
|
|
36
|
+
providers = new import_utils.Registry();
|
|
37
|
+
registerProvider(type, options) {
|
|
38
|
+
this.providers.register(type, options);
|
|
39
|
+
}
|
|
40
|
+
listProviders() {
|
|
41
|
+
return Array.from(this.providers.getEntities()).map(([providerType, options]) => ({
|
|
42
|
+
name: providerType,
|
|
43
|
+
title: options.title
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
class SMSOTPVerification extends import__.OTPVerification {
|
|
48
|
+
async getProvider() {
|
|
49
|
+
const { provider: providerType, settings } = this.options;
|
|
50
|
+
if (!providerType) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
const plugin = this.ctx.app.pm.get("verification");
|
|
54
|
+
const providerOptions = plugin.smsOTPProviderManager.providers.get(providerType);
|
|
55
|
+
if (!providerOptions) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
const Provider = providerOptions.provider;
|
|
59
|
+
if (!Provider) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
const options = this.ctx.app.environment.renderJsonTemplate(settings);
|
|
63
|
+
return new Provider(options);
|
|
64
|
+
}
|
|
65
|
+
async getPublicBoundInfo(userId) {
|
|
66
|
+
const boundInfo = await this.getBoundInfo(userId);
|
|
67
|
+
if (!boundInfo) {
|
|
68
|
+
return { bound: false };
|
|
69
|
+
}
|
|
70
|
+
const { uuid: phone } = boundInfo;
|
|
71
|
+
return {
|
|
72
|
+
bound: true,
|
|
73
|
+
publicInfo: "*".repeat(phone.length - 4) + phone.slice(-4)
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
async validateBoundInfo({ uuid: phone }) {
|
|
77
|
+
if (!phone) {
|
|
78
|
+
throw new Error(this.ctx.t("Not a valid cellphone number, please re-enter"));
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
84
|
+
0 && (module.exports = {
|
|
85
|
+
SMSOTPProviderManager,
|
|
86
|
+
SMSOTPVerification
|
|
87
|
+
});
|
|
@@ -6,11 +6,9 @@
|
|
|
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 declare class Provider {
|
|
11
|
-
protected plugin: Plugin;
|
|
9
|
+
export declare class SMSProvider {
|
|
12
10
|
protected options: any;
|
|
13
|
-
constructor(
|
|
11
|
+
constructor(options: any);
|
|
14
12
|
send(receiver: string, data: {
|
|
15
13
|
[key: string]: any;
|
|
16
14
|
}): Promise<any>;
|
|
@@ -24,21 +24,19 @@ 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 providers_exports = {};
|
|
28
|
+
__export(providers_exports, {
|
|
29
|
+
SMSProvider: () => SMSProvider
|
|
30
30
|
});
|
|
31
|
-
module.exports = __toCommonJS(
|
|
32
|
-
class
|
|
33
|
-
constructor(
|
|
34
|
-
this.
|
|
35
|
-
this.options = plugin.app.environment.renderJsonTemplate(options);
|
|
31
|
+
module.exports = __toCommonJS(providers_exports);
|
|
32
|
+
class SMSProvider {
|
|
33
|
+
constructor(options) {
|
|
34
|
+
this.options = options;
|
|
36
35
|
}
|
|
37
|
-
options;
|
|
38
36
|
async send(receiver, data) {
|
|
39
37
|
}
|
|
40
38
|
}
|
|
41
39
|
// Annotate the CommonJS export names for ESM import in node:
|
|
42
40
|
0 && (module.exports = {
|
|
43
|
-
|
|
41
|
+
SMSProvider
|
|
44
42
|
});
|
|
@@ -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 { SMSProvider } from '.';
|
|
11
|
+
export default class extends SMSProvider {
|
|
12
12
|
client: DysmsApi;
|
|
13
|
-
constructor(
|
|
13
|
+
constructor(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__ = require(".");
|
|
46
|
+
class sms_aliyun_default extends import__.SMSProvider {
|
|
47
47
|
client;
|
|
48
|
-
constructor(
|
|
49
|
-
super(
|
|
48
|
+
constructor(options) {
|
|
49
|
+
super(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 { SMSProvider } from '.';
|
|
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 SMSProvider {
|
|
12
12
|
client: InstanceType<typeof smsClient>;
|
|
13
|
-
constructor(
|
|
13
|
+
constructor(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__ = require(".");
|
|
44
44
|
const smsClient = tencentcloud.sms.v20210111.Client;
|
|
45
|
-
class sms_tencent_default extends
|
|
45
|
+
class sms_tencent_default extends import__.SMSProvider {
|
|
46
46
|
client;
|
|
47
|
-
constructor(
|
|
48
|
-
super(
|
|
47
|
+
constructor(options) {
|
|
48
|
+
super(options);
|
|
49
49
|
const { secretId, secretKey, region, endpoint } = this.options;
|
|
50
50
|
this.client = new smsClient({
|
|
51
51
|
credential: {
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
name: string;
|
|
12
|
+
actions: {
|
|
13
|
+
list: (ctx: Context, next: Next) => Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export default _default;
|