@nocobase/plugin-verification 1.7.0-beta.8 → 1.8.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.
Files changed (82) hide show
  1. package/dist/client/83b24f85ae99a175.js +10 -0
  2. package/dist/client/937c9eccebc38607.js +10 -0
  3. package/dist/client/{providerTypes/index.d.ts → VerificationMenu.d.ts} +5 -4
  4. package/dist/client/index.d.ts +7 -0
  5. package/dist/client/index.js +1 -1
  6. package/dist/client/locale/index.d.ts +1 -1
  7. package/dist/client/otp-verification/VerificationCode.d.ts +16 -0
  8. package/dist/client/otp-verification/sms/AdminSettingsForm.d.ts +12 -0
  9. package/dist/client/otp-verification/sms/BindForm.d.ts +11 -0
  10. package/dist/client/otp-verification/sms/VerificationForm.d.ts +11 -0
  11. package/dist/client/otp-verification/sms/index.d.ts +26 -0
  12. package/dist/client/otp-verification/sms/provider-manager.d.ts +19 -0
  13. package/dist/client/{VerificationProviders.d.ts → otp-verification/sms/providers/AliyunSettings.d.ts} +1 -1
  14. package/dist/{server/actions/index.d.ts → client/otp-verification/sms/providers/TencentSettings.d.ts} +2 -3
  15. package/dist/client/schemas/verifiers.d.ts +66 -0
  16. package/dist/client/verification-manager/index.d.ts +32 -0
  17. package/dist/client/{ProviderOptions.d.ts → verifiers/VerifierSelect.d.ts} +1 -2
  18. package/dist/client/verifiers/Verifiers.d.ts +12 -0
  19. package/dist/client/verifiers/verification-types.d.ts +24 -0
  20. package/dist/collections/verificators.d.ts +50 -0
  21. package/dist/collections/verificators.js +70 -0
  22. package/dist/collections/verifiers.d.ts +50 -0
  23. package/dist/collections/verifiers.js +70 -0
  24. package/dist/constants.d.ts +11 -0
  25. package/dist/constants.js +42 -0
  26. package/dist/externalVersion.js +14 -13
  27. package/dist/locale/en-US.json +18 -1
  28. package/dist/locale/zh-CN.json +20 -2
  29. package/dist/node_modules/@alicloud/dysmsapi20170525/dist/client.js +2 -2
  30. package/dist/node_modules/@alicloud/dysmsapi20170525/package.json +1 -1
  31. package/dist/node_modules/@alicloud/openapi-client/dist/client.js +2 -2
  32. package/dist/node_modules/@alicloud/openapi-client/package.json +1 -1
  33. package/dist/node_modules/@alicloud/tea-util/dist/client.js +1 -1
  34. package/dist/node_modules/@alicloud/tea-util/package.json +1 -1
  35. package/dist/node_modules/tencentcloud-sdk-nodejs/package.json +1 -1
  36. package/dist/node_modules/tencentcloud-sdk-nodejs/tencentcloud/index.js +2 -2
  37. package/dist/server/Plugin.d.ts +8 -16
  38. package/dist/server/Plugin.js +68 -71
  39. package/dist/server/actions/verifiers.d.ts +18 -0
  40. package/dist/server/actions/verifiers.js +175 -0
  41. package/dist/server/{actions/verifications.d.ts → collections/otp-records.d.ts} +2 -2
  42. package/dist/server/collections/otp-records.js +75 -0
  43. package/dist/server/collections/users-verificators.d.ts +10 -0
  44. package/dist/server/collections/users-verificators.js +58 -0
  45. package/dist/server/collections/users-verifiers.d.ts +14 -0
  46. package/dist/server/collections/users-verifiers.js +58 -0
  47. package/dist/server/collections/verificators.d.ts +10 -0
  48. package/dist/server/{actions/index.js → collections/verificators.js} +10 -19
  49. package/dist/server/collections/verifiers.d.ts +10 -0
  50. package/dist/server/{providers/index.js → collections/verifiers.js} +10 -15
  51. package/dist/server/constants.d.ts +0 -2
  52. package/dist/server/constants.js +2 -8
  53. package/dist/server/index.d.ts +5 -2
  54. package/dist/server/index.js +12 -5
  55. package/dist/server/migrations/20250111192640-providers2verificators.d.ts +14 -0
  56. package/dist/server/migrations/20250111192640-providers2verificators.js +97 -0
  57. package/dist/server/migrations/20250507220644-fix-verifier-typo.d.ts +14 -0
  58. package/dist/server/migrations/20250507220644-fix-verifier-typo.js +86 -0
  59. package/dist/server/otp-verification/index.d.ts +26 -0
  60. package/dist/server/otp-verification/index.js +152 -0
  61. package/dist/server/otp-verification/sms/index.d.ts +37 -0
  62. package/dist/server/otp-verification/sms/index.js +87 -0
  63. package/dist/server/{providers/Provider.d.ts → otp-verification/sms/providers/index.d.ts} +2 -4
  64. package/dist/server/{providers/Provider.js → otp-verification/sms/providers/index.js} +8 -10
  65. package/dist/server/{providers → otp-verification/sms/providers}/sms-aliyun.d.ts +3 -3
  66. package/dist/server/{providers → otp-verification/sms/providers}/sms-aliyun.js +4 -4
  67. package/dist/server/{providers → otp-verification/sms/providers}/sms-tencent.d.ts +3 -3
  68. package/dist/server/{providers → otp-verification/sms/providers}/sms-tencent.js +4 -4
  69. package/dist/server/otp-verification/sms/resource/sms-otp-providers.d.ts +16 -0
  70. package/dist/server/otp-verification/sms/resource/sms-otp-providers.js +41 -0
  71. package/dist/server/otp-verification/sms/resource/sms-otp.d.ts +18 -0
  72. package/dist/server/otp-verification/sms/resource/sms-otp.js +141 -0
  73. package/dist/server/verification-manager.d.ts +68 -0
  74. package/dist/server/verification-manager.js +223 -0
  75. package/dist/server/verification.d.ts +70 -0
  76. package/dist/server/verification.js +70 -0
  77. package/package.json +8 -6
  78. package/dist/client/7551e1f2e04bca2f.js +0 -10
  79. package/dist/client/providerTypes/sms-aliyun.d.ts +0 -66
  80. package/dist/client/providerTypes/sms-tencent.d.ts +0 -66
  81. package/dist/server/actions/verifications.js +0 -146
  82. package/dist/server/providers/index.d.ts +0 -15
@@ -0,0 +1,70 @@
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 verification_exports = {};
28
+ __export(verification_exports, {
29
+ Verification: () => Verification
30
+ });
31
+ module.exports = __toCommonJS(verification_exports);
32
+ class Verification {
33
+ verifier;
34
+ ctx;
35
+ options;
36
+ constructor({ ctx, verifier, options }) {
37
+ this.ctx = ctx;
38
+ this.verifier = verifier;
39
+ this.options = options;
40
+ }
41
+ get throughRepo() {
42
+ return this.ctx.db.getRepository("usersVerifiers");
43
+ }
44
+ async onActionComplete(options) {
45
+ }
46
+ async bind(userId, resource, action) {
47
+ throw new Error("Not implemented");
48
+ }
49
+ async getBoundInfo(userId) {
50
+ return this.throughRepo.findOne({
51
+ filter: {
52
+ verifier: this.verifier.name,
53
+ userId
54
+ }
55
+ });
56
+ }
57
+ async getPublicBoundInfo(userId) {
58
+ const boundInfo = await this.getBoundInfo(userId);
59
+ return {
60
+ bound: boundInfo ? true : false
61
+ };
62
+ }
63
+ async validateBoundInfo(boundInfo) {
64
+ return true;
65
+ }
66
+ }
67
+ // Annotate the CommonJS export names for ESM import in node:
68
+ 0 && (module.exports = {
69
+ Verification
70
+ });
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": "verification setting.",
6
- "description.zh-CN": "验证码配置。",
7
- "version": "1.7.0-beta.8",
4
+ "displayName.zh-CN": "验证",
5
+ "description": "User identity verification management, including SMS, TOTP authenticator, with extensibility.",
6
+ "description.zh-CN": "用户身份验证管理,包含短信、TOTP 认证器等,可扩展。",
7
+ "version": "1.8.0-beta.1",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "homepage": "https://docs.nocobase.com/handbook/verification",
@@ -31,8 +31,10 @@
31
31
  "@nocobase/test": "1.x",
32
32
  "@nocobase/utils": "1.x"
33
33
  },
34
- "gitHead": "9ad35ee90db98d95dfa660645d155f4f4e81b47c",
34
+ "gitHead": "103935669123174f2942247202e3d9ff15f0d4ed",
35
35
  "keywords": [
36
- "Authentication"
36
+ "Authentication",
37
+ "Verification",
38
+ "Security"
37
39
  ]
38
40
  }
@@ -1,10 +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
- "use strict";(self.webpackChunk_nocobase_plugin_verification=self.webpackChunk_nocobase_plugin_verification||[]).push([["478"],{178:function(e,t,o){o.r(t),o.d(t,{VerificationProviders:function(){return g}});var r=o("772"),n=o("156"),c=o.n(n),i=o("721"),p=o("875"),a=o("573"),l={name:"verifications_providers",fields:[{type:"string",name:"id",interface:"input",uiSchema:{title:'{{t("ID")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Title")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"type",interface:"select",uiSchema:{title:'{{t("Provider type", { ns: "'.concat(a.A7,'" })}}'),type:"string","x-component":"Select",required:!0,enum:[{label:'{{t("Aliyun SMS", { ns: "'.concat(a.A7,'" })}}'),value:"sms-aliyun"},{label:'{{t("Tencent SMS", { ns: "'.concat(a.A7,'" })}}'),value:"sms-tencent"}]}},{type:"radio",name:"default",interface:"checkbox",uiSchema:{title:'{{t("Default")}}',type:"boolean","x-component":"Checkbox"}}]},s={type:"void",name:"providers","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:l,resourceName:"verifications_providers",request:{resource:"verifications_providers",action:"list",params:{pageSize:50,sort:["-default","id"],appends:[]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:l},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"Action","x-component-props":{type:"primary",icon:"PlusOutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:function(e){var t,o,n=(0,r.useActionContext)();return(0,r.useRequest)(function(){return Promise.resolve({data:{name:"s_".concat((0,p.uid)())}})},(t=function(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),r.forEach(function(t){var r,n,c;r=e,n=t,c=o[t],n in r?Object.defineProperty(r,n,{value:c,enumerable:!0,configurable:!0,writable:!0}):r[n]=c})}return e}({},e),o=(o={refreshDeps:[n.visible]},o),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):(function(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);o.push.apply(o,r)}return o})(Object(o)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}),t))}},title:'{{t("Add new")}}',properties:{id:{"x-component":"CollectionField","x-decorator":"FormItem",description:'{{t("Identifier for program usage. Support letters, numbers and underscores, must start with an letter.")}}'},title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"ProviderOptions"},default:{"x-component":"CollectionField","x-decorator":"FormItem"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}},table:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{id:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{id:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},default:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{default:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{update:{type:"void",title:'{{t("Edit")}}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{t("Edit")}}',properties:{id:{"x-component":"CollectionField","x-decorator":"FormItem","x-disabled":!0},title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem","x-disabled":!0},options:{type:"object","x-component":"ProviderOptions"},default:{"x-component":"CollectionField","x-decorator":"FormItem"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{cm.useDestroyAction}}"}}}}}}}}}},m=o("632"),d=o("505"),u=o("749"),y=o("584"),x={type:"object",properties:{accessKeyId:{title:'{{t("Access Key ID", { ns: "'.concat(a.A7,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope"},accessKeySecret:{title:'{{t("Access Key Secret", { ns: "'.concat(a.A7,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope","x-component-props":{password:!0}},endpoint:{title:'{{t("Endpoint", { ns: "'.concat(a.A7,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope"},sign:{title:'{{t("Sign", { ns: "'.concat(a.A7,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope"},template:{title:'{{t("Template code", { ns: "'.concat(a.A7,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope"}}},b={type:"object",properties:{secretId:{title:'{{t("Secret Id", { ns: "'.concat(a.A7,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope"},secretKey:{title:'{{t("Secret Key", { ns: "'.concat(a.A7,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope","x-component-props":{password:!0}},region:{title:'{{t("Region", { ns: "'.concat(a.A7,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope"},endpoint:{title:'{{t("Endpoint", { ns: "'.concat(a.A7,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",default:"sms.tencentcloudapi.com"},SignName:{title:'{{t("Sign name", { ns: "'.concat(a.A7,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope"},SmsSdkAppId:{title:'{{t("Sms sdk app id", { ns: "'.concat(a.A7,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope"},TemplateId:{title:'{{t("Template Id", { ns: "'.concat(a.A7,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope"}}},f=new y.Registry;f.register("sms-aliyun",x),f.register("sms-tencent",b);function A(e,t){(null==t||t>e.length)&&(t=e.length);for(var o=0,r=Array(t);o<t;o++)r[o]=e[o];return r}var v=(0,d.observer)(function(e){var t,o,r=(0,d.useForm)(),i=(0,d.useField)();var p=(t=(0,n.useState)(new d.Schema(f.get(r.values.type)||{})),o=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var o,r,n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var c=[],i=!0,p=!1;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(c.push(o.value),!t||c.length!==t);i=!0);}catch(e){p=!0,r=e}finally{try{!i&&null!=n.return&&n.return()}finally{if(p)throw r}}return c}}(t,2)||function(e,t){if(e){if("string"==typeof e)return A(e,t);var o=Object.prototype.toString.call(e).slice(8,-1);if("Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o)return Array.from(o);if("Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return A(e,t)}}(t,o)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),a=p[0],l=p[1];return(0,u.useUpdateEffect)(function(){r.clearFormGraph("options.*"),l(new d.Schema(f.get(r.values.type)||{}))},[r.values.type]),c().createElement(m.FormLayout,{layout:"vertical"},c().createElement(d.RecursionField,{key:r.values.type||"sms-aliyun",basePath:i.address,onlyRenderProperties:!0,schema:a}))},{displayName:"Verification"});function g(){return c().createElement(i.Card,{bordered:!1},c().createElement(r.SchemaComponent,{schema:s,components:{ProviderOptions:v}}))}}}]);
@@ -1,66 +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
- declare const _default: import("@formily/react").Stringify<{
10
- [key: symbol]: any;
11
- [key: `x-${string}`]: any;
12
- [key: `x-${number}`]: any;
13
- version?: string;
14
- name?: import("@formily/react").SchemaKey;
15
- title?: any;
16
- description?: any;
17
- default?: any;
18
- readOnly?: boolean;
19
- writeOnly?: boolean;
20
- type?: import("@formily/react").SchemaTypes;
21
- enum?: import("@formily/react").SchemaEnum<any>;
22
- const?: any;
23
- multipleOf?: number;
24
- maximum?: number;
25
- exclusiveMaximum?: number;
26
- minimum?: number;
27
- exclusiveMinimum?: number;
28
- maxLength?: number;
29
- minLength?: number;
30
- pattern?: string | RegExp;
31
- maxItems?: number;
32
- minItems?: number;
33
- uniqueItems?: boolean;
34
- maxProperties?: number;
35
- minProperties?: number;
36
- required?: string | boolean | string[];
37
- format?: string;
38
- $ref?: string;
39
- $namespace?: string;
40
- definitions?: import("@formily/react").SchemaProperties<any, any, any, any, any, any, any, any>;
41
- properties?: import("@formily/react").SchemaProperties<any, any, any, any, any, any, any, any>;
42
- items?: import("@formily/react").SchemaItems<any, any, any, any, any, any, any, any>;
43
- additionalItems?: import("@formily/react").Stringify<any>;
44
- patternProperties?: import("@formily/react").SchemaProperties<any, any, any, any, any, any, any, any>;
45
- additionalProperties?: import("@formily/react").Stringify<any>;
46
- "x-value"?: any;
47
- "x-index"?: number;
48
- "x-pattern"?: any;
49
- "x-display"?: any;
50
- "x-validator"?: any;
51
- "x-decorator"?: any;
52
- "x-decorator-props"?: any;
53
- "x-component"?: any;
54
- "x-component-props"?: any;
55
- "x-reactions"?: import("@formily/react").SchemaReactions<any>;
56
- "x-content"?: any;
57
- "x-data"?: any;
58
- "x-visible"?: boolean;
59
- "x-hidden"?: boolean;
60
- "x-disabled"?: boolean;
61
- "x-editable"?: boolean;
62
- "x-read-only"?: boolean;
63
- "x-read-pretty"?: boolean;
64
- "x-compile-omitted"?: string[];
65
- }>;
66
- export default _default;
@@ -1,66 +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
- declare const _default: import("@formily/react").Stringify<{
10
- [key: symbol]: any;
11
- [key: `x-${string}`]: any;
12
- [key: `x-${number}`]: any;
13
- version?: string;
14
- name?: import("@formily/react").SchemaKey;
15
- title?: any;
16
- description?: any;
17
- default?: any;
18
- readOnly?: boolean;
19
- writeOnly?: boolean;
20
- type?: import("@formily/react").SchemaTypes;
21
- enum?: import("@formily/react").SchemaEnum<any>;
22
- const?: any;
23
- multipleOf?: number;
24
- maximum?: number;
25
- exclusiveMaximum?: number;
26
- minimum?: number;
27
- exclusiveMinimum?: number;
28
- maxLength?: number;
29
- minLength?: number;
30
- pattern?: string | RegExp;
31
- maxItems?: number;
32
- minItems?: number;
33
- uniqueItems?: boolean;
34
- maxProperties?: number;
35
- minProperties?: number;
36
- required?: string | boolean | string[];
37
- format?: string;
38
- $ref?: string;
39
- $namespace?: string;
40
- definitions?: import("@formily/react").SchemaProperties<any, any, any, any, any, any, any, any>;
41
- properties?: import("@formily/react").SchemaProperties<any, any, any, any, any, any, any, any>;
42
- items?: import("@formily/react").SchemaItems<any, any, any, any, any, any, any, any>;
43
- additionalItems?: import("@formily/react").Stringify<any>;
44
- patternProperties?: import("@formily/react").SchemaProperties<any, any, any, any, any, any, any, any>;
45
- additionalProperties?: import("@formily/react").Stringify<any>;
46
- "x-value"?: any;
47
- "x-index"?: number;
48
- "x-pattern"?: any;
49
- "x-display"?: any;
50
- "x-validator"?: any;
51
- "x-decorator"?: any;
52
- "x-decorator-props"?: any;
53
- "x-component"?: any;
54
- "x-component-props"?: any;
55
- "x-reactions"?: import("@formily/react").SchemaReactions<any>;
56
- "x-content"?: any;
57
- "x-data"?: any;
58
- "x-visible"?: boolean;
59
- "x-hidden"?: boolean;
60
- "x-disabled"?: boolean;
61
- "x-editable"?: boolean;
62
- "x-read-only"?: boolean;
63
- "x-read-pretty"?: boolean;
64
- "x-compile-omitted"?: string[];
65
- }>;
66
- export default _default;
@@ -1,146 +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 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
- });
@@ -1,15 +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 Plugin from '../Plugin';
10
- import { Provider } from './Provider';
11
- interface Providers {
12
- [key: string]: typeof Provider;
13
- }
14
- export default function (plugin: Plugin, more?: Providers): Promise<void>;
15
- export {};