@nocobase/plugin-verification 1.7.0-alpha.1 → 1.7.0-beta.1
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/en-US.json +1 -17
- 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
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
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
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* 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;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
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
|
-
});
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
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
|
-
}
|
|
@@ -1,25 +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 { 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
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
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
|
-
});
|
|
@@ -1,37 +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 { 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 {};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
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
|
-
});
|
|
@@ -1,16 +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 { 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;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
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_otp_providers_exports = {};
|
|
28
|
-
__export(sms_otp_providers_exports, {
|
|
29
|
-
default: () => sms_otp_providers_default
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(sms_otp_providers_exports);
|
|
32
|
-
var sms_otp_providers_default = {
|
|
33
|
-
name: "smsOTPProviders",
|
|
34
|
-
actions: {
|
|
35
|
-
list: async (ctx, next) => {
|
|
36
|
-
const plugin = ctx.app.pm.get("verification");
|
|
37
|
-
ctx.body = plugin.smsOTPProviderManager.listProviders();
|
|
38
|
-
await next();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
};
|
|
@@ -1,18 +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 { Context, Next } from '@nocobase/actions';
|
|
10
|
-
declare function create(ctx: Context, next: Next): Promise<any>;
|
|
11
|
-
declare const _default: {
|
|
12
|
-
name: string;
|
|
13
|
-
actions: {
|
|
14
|
-
create: typeof create;
|
|
15
|
-
publicCreate: typeof create;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
export default _default;
|