@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,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([["835"],{564:function(e,t,n){n.r(t),n.d(t,{VerificatorSelect:function(){return v}});var i=n(156),a=n.n(i),l=n(505),r=n(721),o=n(772),u=n(573),c=n(128),s=n(632),v=(0,l.connect)(function(e){var t=(0,u.SD)().t,n=e.scene,v=e.value,f=e.title,m=e.onChange,p=e.multiple;p=p?"multiple":void 0;var d=(0,o.useAPIClient)(),h=(0,o.useRequest)(function(){return d.resource("verificators").listByScene({scene:n}).then(function(e){var t;return null==e?void 0:null===(t=e.data)||void 0===t?void 0:t.data})}).data||{},g=h.verificators,b=void 0===g?[]:g,E=h.availableTypes,k=(0,i.useMemo)(function(){return null==b?void 0:b.map(function(e){return{label:e.title,value:e.name}})},[b]);return a().createElement(s.FormItem,{label:f||t("Verificators"),extra:a().createElement(a().Fragment,null,t("The following types of verificators are available:"),(void 0===E?[]:E).map(function(e){return l.Schema.compile(e.title,{t:t})}).join(", "),". ",t("Go to")," ",a().createElement(c.Link,{to:"/admin/settings/verification"},t("create verificators")))},a().createElement(r.Select,{allowClear:!0,options:k,value:v,mode:p,onChange:m}))},(0,l.mapReadPretty)(function(){var e,t=(0,l.useField)();return(null===(e=t.value)||void 0===e?void 0:e.length)?a().createElement(o.EllipsisWithTooltip,{ellipsis:!0},t.value.map(function(e){return a().createElement(r.Tag,{key:e.name},e.title)})):null}))}}]);
|
|
@@ -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([["995"],{252:function(e,t,n){n.r(t),n.d(t,{Verificators:function(){return E},useAdminSettingsForm:function(){return T},Settings:function(){return k}});var o=n("156"),r=n.n(o),i=n("772"),c={type:"void",properties:{drawer:{type:"void",title:'{{ t("Add new") }}',"x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useCreateFormProps",properties:{name:{type:"string","x-decorator":"FormItem",title:'{{ t("UID") }}',"x-component":"Input","x-validator":function(e){return/^[a-zA-Z0-9_-]+$/.test(e)?"":"a-z, A-Z, 0-9, _, -"}},title:{type:"string","x-decorator":"FormItem",title:'{{ t("Title") }}',"x-component":"Input"},description:{"x-decorator":"FormItem",type:"string",title:'{{ t("Description") }}',"x-component":"Input.TextArea"},options:{type:"object","x-component":"Settings"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary"},"x-use-component-props":"useCreateActionProps"}}}}}}},s={type:"void",properties:{card:{type:"void","x-component":"CardItem","x-component-props":{heightMode:"fullHeight"},"x-decorator":"TableBlockProvider","x-decorator-props":{collection:"verificators",action:"list"},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:20}},properties:{refresh:{title:"{{t('Refresh')}}","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},bulkDelete:{title:"{{t('Delete')}}","x-action":"destroy","x-component":"Action","x-use-component-props":"useBulkDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},add:{type:"void","x-component":"AddNew",title:"{{t('Add new')}}","x-align":"right"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"name",rowSelection:{type:"checkbox"}},properties:{column1:{type:"void",title:'{{ t("UID") }}',"x-component":"TableV2.Column",properties:{name:{type:"string","x-component":"Input","x-read-pretty":!0}}},column2:{type:"void",title:'{{ t("Title") }}',"x-component":"TableV2.Column",properties:{title:{type:"string","x-component":"Input","x-read-pretty":!0}}},column3:{type:"void",title:'{{ t("Verification type") }}',"x-component":"TableV2.Column",properties:{verificationType:{type:"string","x-component":"Select","x-read-pretty":!0,enum:"{{ types }}"}}},column4:{type:"void",title:'{{ t("Description") }}',"x-component":"TableV2.Column",properties:{description:{type:"string","x-component":"Input.TextArea","x-component-props":{ellipsis:!0},"x-pattern":"readPretty"}}},column5:{type:"void",title:'{{ t("Actions") }}',"x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{edit:{type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useEditFormProps",properties:{title:{type:"string","x-decorator":"FormItem",title:'{{ t("Title") }}',"x-component":"Input"},description:{"x-decorator":"FormItem",type:"string",title:'{{ t("Description") }}',"x-component":"Input.TextArea"},options:{type:"object","x-component":"Settings"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary"},"x-use-component-props":"useEditActionProps"}}}}}}},destroy:{type:"void",title:'{{ t("Delete") }}',"x-action":"destroy","x-component":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}}}}}}}}}}}},p={name:"verificators",autoGenId:!1,fields:[{type:"uid",name:"name",primaryKey:!0},{type:"string",name:"title"},{type:"string",name:"verificationType"},{type:"string",name:"description"},{type:"jsonb",name:"options"},{interface:"m2m",type:"belongsToMany",name:"users",target:"users",foreignKey:"verificator",otherKey:"userId",onDelete:"CASCADE",sourceKey:"name",targetKey:"id",through:"usersVerificators"}]},a=n("573"),u=n("721"),l=n("482"),m=(0,o.createContext)({type:""});m.displayName="VerificationTypeContext";var y=(0,o.createContext)({types:[]});y.displayName="VerificationTypesContext";var d=n("505"),f=n("563"),v=n("875");function x(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function b(e,t,n,o,r,i,c){try{var s=e[i](c),p=s.value}catch(e){n(e);return}s.done?t(p):Promise.resolve(p).then(o,r)}function g(e){return function(){var t=this,n=arguments;return new Promise(function(o,r){var i=e.apply(t,n);function c(e){b(i,o,r,c,s,"next",e)}function s(e){b(i,o,r,c,s,"throw",e)}c(void 0)})}}function A(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,o,r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i=[],c=!0,s=!1;try{for(r=r.call(e);!(c=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);c=!0);}catch(e){s=!0,o=e}finally{try{!c&&null!=r.return&&r.return()}finally{if(s)throw o}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return x(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return x(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(e,t){var n,o,r,i,c={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw TypeError("Generator is already executing.");for(;c;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return c.label++,{value:i[1],done:!1};case 5:c.label++,o=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(r=(r=c.trys).length>0&&r[r.length-1])&&(6===i[0]||2===i[0])){c=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){c.label=i[1];break}if(6===i[0]&&c.label<r[1]){c.label=r[1],r=i;break}if(r&&c.label<r[2]){c.label=r[2],c.ops.push(i);break}r[2]&&c.ops.pop(),c.trys.pop();continue}i=t.call(e,c)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}var C=function(){var e=(0,o.useContext)(m).type;return{form:(0,o.useMemo)(function(){return(0,f.createForm)({initialValues:{name:"v_".concat((0,v.uid)()),verificationType:e}})},[e])}},w=function(){var e=(0,i.useCollectionRecordData)();return{form:(0,o.useMemo)(function(){return(0,f.createForm)({initialValues:e})},[e])}},P=function(){var e=(0,i.useActionContext)().setVisible,t=(0,d.useForm)();return{type:"default",onClick:function(){e(!1),t.reset()}}},S=function(){var e=(0,i.useActionContext)().setVisible,t=u.App.useApp().message,n=(0,d.useForm)(),o=(0,i.useDataBlockResource)(),r=(0,i.useDataBlockRequest)().refresh,c=(0,a.SD)().t;return{type:"primary",onClick:function(){return g(function(){var i;return h(this,function(s){switch(s.label){case 0:return[4,n.submit()];case 1:return s.sent(),i=n.values,[4,o.create({values:i})];case 2:return s.sent(),r(),t.success(c("Saved successfully")),e(!1),n.reset(),[2]}})})()}}},D=function(){var e=(0,i.useActionContext)().setVisible,t=u.App.useApp().message,n=(0,d.useForm)(),o=(0,i.useDataBlockResource)(),r=(0,i.useDataBlockRequest)().refresh,c=(0,i.useCollection)().getFilterTargetKey(),s=(0,a.SD)().t;return{type:"primary",onClick:function(){return g(function(){var i;return h(this,function(p){switch(p.label){case 0:return[4,n.submit()];case 1:return p.sent(),i=n.values,[4,o.update({values:i,filterByTk:i[c]})];case 2:return p.sent(),r(),t.success(s("Saved successfully")),e(!1),n.reset(),[2]}})})()}}},O=function(){var e=(0,a.SD)().t,t=A((0,o.useState)(!1),2),n=t[0],s=t[1],p=A((0,o.useState)(""),2),d=p[0],f=p[1],v=(0,o.useContext)(y).types.map(function(e){var t,n;return t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){var o,r,i;o=e,r=t,i=n[t],r in o?Object.defineProperty(o,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):o[r]=i})}return e}({},e),n=(n={onClick:function(){s(!0),f(e.value)}},n),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n.push.apply(n,o)}return n})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t});return r().createElement(i.ActionContextProvider,{value:{visible:n,setVisible:s}},r().createElement(m.Provider,{value:{type:d}},r().createElement(u.Dropdown,{menu:{items:v}},r().createElement(u.Button,{icon:r().createElement(l.PlusOutlined,null),type:"primary"},e("Add new")," ",r().createElement(l.DownOutlined,null))),r().createElement(i.SchemaComponent,{scope:{setType:f,useCreateFormProps:C},schema:c})))},T=function(e){var t,n=(0,i.usePlugin)("verification").verificationManager.getVerification(e);return null==n?void 0:null===(t=n.components)||void 0===t?void 0:t.AdminSettingsForm},k=(0,d.observer)(function(){var e=(0,d.useForm)(),t=(0,i.useCollectionRecordData)(),n=T(e.values.verificationType||t.verificationType);return n?r().createElement(n,null):null},{displayName:"VerificationSettings"}),E=function(){var e=(0,a.SD)().t,t=A((0,o.useState)([]),2),n=t[0],c=t[1],u=(0,i.useAPIClient)();return(0,i.useRequest)(function(){return u.resource("verificators").listTypes().then(function(t){var n;return((null==t?void 0:null===(n=t.data)||void 0===n?void 0:n.data)||[]).map(function(t){return{key:t.name,label:d.Schema.compile(t.title||t.name,{t:e}),value:t.name}})})},{onSuccess:function(e){c(e)}}),r().createElement(y.Provider,{value:{types:n}},r().createElement(i.ExtendCollectionsProvider,{collections:[p]},r().createElement(i.SchemaComponent,{schema:s,components:{AddNew:O,Settings:k},scope:{types:n,useEditFormProps:w,useCancelActionProps:P,useCreateActionProps:S,useEditActionProps:D}})))}}}]);
|
|
@@ -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 React from 'react';
|
|
10
|
-
export declare const VerificationCode: React.FC<{
|
|
11
|
-
actionType: string;
|
|
12
|
-
verificator: string;
|
|
13
|
-
value: string;
|
|
14
|
-
onChange: (value: any) => void;
|
|
15
|
-
isLogged?: boolean;
|
|
16
|
-
}>;
|
|
@@ -1,12 +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 useAdminSettingsForm: (providerType: string) => any;
|
|
11
|
-
export declare const Settings: React.MemoExoticComponent<import("@formily/react").ReactFC<unknown>>;
|
|
12
|
-
export declare const AdminSettingsForm: React.FC;
|
|
@@ -1,11 +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
|
-
import { VerificationFormProps } from '../../verification-manager';
|
|
11
|
-
export declare const VerificationForm: (props: VerificationFormProps) => React.JSX.Element;
|
|
@@ -1,26 +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
|
-
/// <reference types="react" />
|
|
10
|
-
export declare const smsOTPVerificationOptions: {
|
|
11
|
-
components: {
|
|
12
|
-
VerificationForm: (props: import("../../verification-manager").VerificationFormProps) => import("react").JSX.Element;
|
|
13
|
-
AdminSettingsForm: import("react").FC<{}>;
|
|
14
|
-
BindForm: (props: import("../../verification-manager").BindFormProps) => import("react").JSX.Element;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
export declare const smsAliyunProviderOptions: {
|
|
18
|
-
components: {
|
|
19
|
-
AdminSettingsForm: import("react").FC<{}>;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
export declare const smsTencentProviderOptions: {
|
|
23
|
-
components: {
|
|
24
|
-
AdminSettingsForm: import("react").FC<{}>;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
@@ -1,19 +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 { ComponentType } from 'react';
|
|
10
|
-
export type SMSOTPProviderOptions = {
|
|
11
|
-
components: {
|
|
12
|
-
AdminSettingsForm: ComponentType;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
export declare class SMSOTPProviderManager {
|
|
16
|
-
providers: any;
|
|
17
|
-
registerProvider(type: string, options: SMSOTPProviderOptions): void;
|
|
18
|
-
getProvider(type: string): any;
|
|
19
|
-
}
|
|
@@ -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
|
-
import { ISchema } from '@formily/react';
|
|
10
|
-
export declare const createVerificatorSchema: {
|
|
11
|
-
type: string;
|
|
12
|
-
properties: {
|
|
13
|
-
drawer: {
|
|
14
|
-
type: string;
|
|
15
|
-
title: string;
|
|
16
|
-
'x-component': string;
|
|
17
|
-
'x-decorator': string;
|
|
18
|
-
'x-use-decorator-props': string;
|
|
19
|
-
properties: {
|
|
20
|
-
name: {
|
|
21
|
-
type: string;
|
|
22
|
-
'x-decorator': string;
|
|
23
|
-
title: string;
|
|
24
|
-
'x-component': string;
|
|
25
|
-
'x-validator': (value: string) => "" | "a-z, A-Z, 0-9, _, -";
|
|
26
|
-
};
|
|
27
|
-
title: {
|
|
28
|
-
type: string;
|
|
29
|
-
'x-decorator': string;
|
|
30
|
-
title: string;
|
|
31
|
-
'x-component': string;
|
|
32
|
-
};
|
|
33
|
-
description: {
|
|
34
|
-
'x-decorator': string;
|
|
35
|
-
type: string;
|
|
36
|
-
title: string;
|
|
37
|
-
'x-component': string;
|
|
38
|
-
};
|
|
39
|
-
options: {
|
|
40
|
-
type: string;
|
|
41
|
-
'x-component': string;
|
|
42
|
-
};
|
|
43
|
-
footer: {
|
|
44
|
-
type: string;
|
|
45
|
-
'x-component': string;
|
|
46
|
-
properties: {
|
|
47
|
-
cancel: {
|
|
48
|
-
title: string;
|
|
49
|
-
'x-component': string;
|
|
50
|
-
'x-use-component-props': string;
|
|
51
|
-
};
|
|
52
|
-
submit: {
|
|
53
|
-
title: string;
|
|
54
|
-
'x-component': string;
|
|
55
|
-
'x-component-props': {
|
|
56
|
-
type: string;
|
|
57
|
-
};
|
|
58
|
-
'x-use-component-props': string;
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
export declare const verficatorsSchema: ISchema;
|
|
@@ -1,32 +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 { ComponentType } from 'react';
|
|
10
|
-
export type VerificationFormProps = {
|
|
11
|
-
verificator: string;
|
|
12
|
-
actionType: string;
|
|
13
|
-
boundInfo: any;
|
|
14
|
-
isLogged?: boolean;
|
|
15
|
-
};
|
|
16
|
-
export type BindFormProps = {
|
|
17
|
-
verificator: string;
|
|
18
|
-
actionType: string;
|
|
19
|
-
isLogged?: boolean;
|
|
20
|
-
};
|
|
21
|
-
export type VerificationTypeOptions = {
|
|
22
|
-
components: {
|
|
23
|
-
AdminSettingsForm?: ComponentType;
|
|
24
|
-
VerificationForm: ComponentType<VerificationFormProps>;
|
|
25
|
-
BindForm?: ComponentType<BindFormProps>;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
export declare class VerificationManager {
|
|
29
|
-
verifications: any;
|
|
30
|
-
registerVerificationType(type: string, options: VerificationTypeOptions): void;
|
|
31
|
-
getVerification(type: string): any;
|
|
32
|
-
}
|
|
@@ -1,12 +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 useAdminSettingsForm: (verificationType: string) => any;
|
|
11
|
-
export declare const Settings: React.MemoExoticComponent<import("@formily/react").ReactFC<unknown>>;
|
|
12
|
-
export declare const Verificators: React.FC;
|
|
@@ -1,24 +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
|
-
/// <reference types="react" />
|
|
10
|
-
export declare const VerificationTypeContext: import("react").Context<{
|
|
11
|
-
type: string;
|
|
12
|
-
}>;
|
|
13
|
-
export declare const VerificationTypesContext: import("react").Context<{
|
|
14
|
-
types: {
|
|
15
|
-
key: string;
|
|
16
|
-
label: string;
|
|
17
|
-
value: string;
|
|
18
|
-
}[];
|
|
19
|
-
}>;
|
|
20
|
-
export declare const useVerificationTypes: () => {
|
|
21
|
-
key: string;
|
|
22
|
-
label: string;
|
|
23
|
-
value: string;
|
|
24
|
-
}[];
|
|
@@ -1,50 +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: {
|
|
10
|
-
name: string;
|
|
11
|
-
autoGenId: boolean;
|
|
12
|
-
fields: ({
|
|
13
|
-
type: string;
|
|
14
|
-
name: string;
|
|
15
|
-
primaryKey: boolean;
|
|
16
|
-
interface?: undefined;
|
|
17
|
-
target?: undefined;
|
|
18
|
-
foreignKey?: undefined;
|
|
19
|
-
otherKey?: undefined;
|
|
20
|
-
onDelete?: undefined;
|
|
21
|
-
sourceKey?: undefined;
|
|
22
|
-
targetKey?: undefined;
|
|
23
|
-
through?: undefined;
|
|
24
|
-
} | {
|
|
25
|
-
type: string;
|
|
26
|
-
name: string;
|
|
27
|
-
primaryKey?: undefined;
|
|
28
|
-
interface?: undefined;
|
|
29
|
-
target?: undefined;
|
|
30
|
-
foreignKey?: undefined;
|
|
31
|
-
otherKey?: undefined;
|
|
32
|
-
onDelete?: undefined;
|
|
33
|
-
sourceKey?: undefined;
|
|
34
|
-
targetKey?: undefined;
|
|
35
|
-
through?: undefined;
|
|
36
|
-
} | {
|
|
37
|
-
interface: string;
|
|
38
|
-
type: string;
|
|
39
|
-
name: string;
|
|
40
|
-
target: string;
|
|
41
|
-
foreignKey: string;
|
|
42
|
-
otherKey: string;
|
|
43
|
-
onDelete: string;
|
|
44
|
-
sourceKey: string;
|
|
45
|
-
targetKey: string;
|
|
46
|
-
through: string;
|
|
47
|
-
primaryKey?: undefined;
|
|
48
|
-
})[];
|
|
49
|
-
};
|
|
50
|
-
export default _default;
|
|
@@ -1,70 +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 verificators_exports = {};
|
|
28
|
-
__export(verificators_exports, {
|
|
29
|
-
default: () => verificators_default
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(verificators_exports);
|
|
32
|
-
var verificators_default = {
|
|
33
|
-
name: "verificators",
|
|
34
|
-
autoGenId: false,
|
|
35
|
-
fields: [
|
|
36
|
-
{
|
|
37
|
-
type: "uid",
|
|
38
|
-
name: "name",
|
|
39
|
-
primaryKey: true
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
type: "string",
|
|
43
|
-
name: "title"
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
type: "string",
|
|
47
|
-
name: "verificationType"
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
type: "string",
|
|
51
|
-
name: "description"
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
type: "jsonb",
|
|
55
|
-
name: "options"
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
interface: "m2m",
|
|
59
|
-
type: "belongsToMany",
|
|
60
|
-
name: "users",
|
|
61
|
-
target: "users",
|
|
62
|
-
foreignKey: "verificator",
|
|
63
|
-
otherKey: "userId",
|
|
64
|
-
onDelete: "CASCADE",
|
|
65
|
-
sourceKey: "name",
|
|
66
|
-
targetKey: "id",
|
|
67
|
-
through: "usersVerificators"
|
|
68
|
-
}
|
|
69
|
-
]
|
|
70
|
-
};
|
package/dist/constants.d.ts
DELETED
|
@@ -1,11 +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
|
-
export declare const SMS_OTP_VERIFICATION_TYPE = "sms-otp";
|
|
10
|
-
export declare const PROVIDER_TYPE_SMS_ALIYUN = "sms-aliyun";
|
|
11
|
-
export declare const PROVIDER_TYPE_SMS_TENCENT = "sms-tencent";
|
package/dist/constants.js
DELETED
|
@@ -1,42 +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 constants_exports = {};
|
|
28
|
-
__export(constants_exports, {
|
|
29
|
-
PROVIDER_TYPE_SMS_ALIYUN: () => PROVIDER_TYPE_SMS_ALIYUN,
|
|
30
|
-
PROVIDER_TYPE_SMS_TENCENT: () => PROVIDER_TYPE_SMS_TENCENT,
|
|
31
|
-
SMS_OTP_VERIFICATION_TYPE: () => SMS_OTP_VERIFICATION_TYPE
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(constants_exports);
|
|
34
|
-
const SMS_OTP_VERIFICATION_TYPE = "sms-otp";
|
|
35
|
-
const PROVIDER_TYPE_SMS_ALIYUN = "sms-aliyun";
|
|
36
|
-
const PROVIDER_TYPE_SMS_TENCENT = "sms-tencent";
|
|
37
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
-
0 && (module.exports = {
|
|
39
|
-
PROVIDER_TYPE_SMS_ALIYUN,
|
|
40
|
-
PROVIDER_TYPE_SMS_TENCENT,
|
|
41
|
-
SMS_OTP_VERIFICATION_TYPE
|
|
42
|
-
});
|
|
@@ -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 const _default: {
|
|
11
|
-
listTypes: (ctx: Context, next: Next) => Promise<void>;
|
|
12
|
-
listByScene: (ctx: Context, next: Next) => Promise<any>;
|
|
13
|
-
listByUser: (ctx: Context, next: Next) => Promise<void>;
|
|
14
|
-
listForVerify: (ctx: Context, next: Next) => Promise<any>;
|
|
15
|
-
bind: (ctx: Context, next: Next) => Promise<never>;
|
|
16
|
-
unbind: (ctx: Context, next: Next) => Promise<never>;
|
|
17
|
-
};
|
|
18
|
-
export default _default;
|
|
@@ -1,175 +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 verificators_exports = {};
|
|
38
|
-
__export(verificators_exports, {
|
|
39
|
-
default: () => verificators_default
|
|
40
|
-
});
|
|
41
|
-
module.exports = __toCommonJS(verificators_exports);
|
|
42
|
-
var import_package = __toESM(require("../../../package.json"));
|
|
43
|
-
var verificators_default = {
|
|
44
|
-
listTypes: async (ctx, next) => {
|
|
45
|
-
const plugin = ctx.app.pm.get("verification");
|
|
46
|
-
ctx.body = plugin.verificationManager.listTypes();
|
|
47
|
-
await next();
|
|
48
|
-
},
|
|
49
|
-
listByScene: async (ctx, next) => {
|
|
50
|
-
const { scene } = ctx.action.params || {};
|
|
51
|
-
const plugin = ctx.app.pm.get("verification");
|
|
52
|
-
const verificationTypes = plugin.verificationManager.getVerificationTypesByScene(scene);
|
|
53
|
-
if (!verificationTypes.length) {
|
|
54
|
-
ctx.body = { verificators: [], availableTypes: [] };
|
|
55
|
-
return next();
|
|
56
|
-
}
|
|
57
|
-
const verificators = await ctx.db.getRepository("verificators").find({
|
|
58
|
-
filter: {
|
|
59
|
-
verificationType: verificationTypes.map((item) => item.type)
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
ctx.body = {
|
|
63
|
-
verificators: (verificators || []).map((item) => ({
|
|
64
|
-
name: item.name,
|
|
65
|
-
title: item.title
|
|
66
|
-
})),
|
|
67
|
-
availableTypes: verificationTypes.map((item) => ({
|
|
68
|
-
name: item.type,
|
|
69
|
-
title: item.title
|
|
70
|
-
}))
|
|
71
|
-
};
|
|
72
|
-
await next();
|
|
73
|
-
},
|
|
74
|
-
listByUser: async (ctx, next) => {
|
|
75
|
-
const plugin = ctx.app.pm.get("verification");
|
|
76
|
-
const verificationTypes = plugin.verificationManager.verificationTypes;
|
|
77
|
-
const bindingRequiredTypes = Array.from(verificationTypes.getEntities()).filter(([, options]) => options.bindingRequired).map(([type]) => type);
|
|
78
|
-
const verificators = await ctx.db.getRepository("verificators").find({
|
|
79
|
-
filter: {
|
|
80
|
-
verificationType: bindingRequiredTypes
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
const result = [];
|
|
84
|
-
for (const verificator of verificators) {
|
|
85
|
-
try {
|
|
86
|
-
const verificationType = plugin.verificationManager.verificationTypes.get(verificator.verificationType);
|
|
87
|
-
const Verification = plugin.verificationManager.getVerification(verificator.verificationType);
|
|
88
|
-
const verification = new Verification({ ctx, verificator, options: verificator.options });
|
|
89
|
-
const boundInfo = await verification.getPublicBoundInfo(ctx.auth.user.id);
|
|
90
|
-
result.push({
|
|
91
|
-
...verificator.dataValues,
|
|
92
|
-
title: verificator.title || verificationType.title,
|
|
93
|
-
description: verificator.description || verificationType.description,
|
|
94
|
-
boundInfo
|
|
95
|
-
});
|
|
96
|
-
} catch (error) {
|
|
97
|
-
ctx.log.error(error);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
ctx.body = result;
|
|
101
|
-
await next();
|
|
102
|
-
},
|
|
103
|
-
listForVerify: async (ctx, next) => {
|
|
104
|
-
const { scene } = ctx.action.params || {};
|
|
105
|
-
const plugin = ctx.app.pm.get("verification");
|
|
106
|
-
const verificationTypes = plugin.verificationManager.getVerificationTypesByScene(scene);
|
|
107
|
-
if (!verificationTypes.length) {
|
|
108
|
-
ctx.body = [];
|
|
109
|
-
return next();
|
|
110
|
-
}
|
|
111
|
-
const verificators = await ctx.db.getRepository("verificators").find({
|
|
112
|
-
filter: {
|
|
113
|
-
verificationType: verificationTypes.map((item) => item.type)
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
if (!verificators.length) {
|
|
117
|
-
ctx.body = [];
|
|
118
|
-
return next();
|
|
119
|
-
}
|
|
120
|
-
const result = [];
|
|
121
|
-
for (const verificator of verificators) {
|
|
122
|
-
const verificationType = plugin.verificationManager.verificationTypes.get(verificator.verificationType);
|
|
123
|
-
const Verification = plugin.verificationManager.getVerification(verificator.verificationType);
|
|
124
|
-
const verification = new Verification({ ctx, verificator, options: verificator.options });
|
|
125
|
-
const publicBoundInfo = await verification.getPublicBoundInfo(ctx.auth.user.id);
|
|
126
|
-
if (!(publicBoundInfo == null ? void 0 : publicBoundInfo.bound)) {
|
|
127
|
-
continue;
|
|
128
|
-
}
|
|
129
|
-
result.push({
|
|
130
|
-
name: verificator.name,
|
|
131
|
-
title: verificator.title,
|
|
132
|
-
verificationType: verificator.verificationType,
|
|
133
|
-
verificationTypeTitle: verificationType == null ? void 0 : verificationType.title,
|
|
134
|
-
boundInfo: publicBoundInfo
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
ctx.body = result;
|
|
138
|
-
await next();
|
|
139
|
-
},
|
|
140
|
-
bind: async (ctx, next) => {
|
|
141
|
-
const { verificator: name } = ctx.action.params.values || {};
|
|
142
|
-
const user = ctx.auth.user;
|
|
143
|
-
const verificationPlugin = ctx.app.pm.get("verification");
|
|
144
|
-
const record = await verificationPlugin.verificationManager.getBoundRecord(user.id, name);
|
|
145
|
-
if (record) {
|
|
146
|
-
return ctx.throw(400, ctx.t("You have already bound this verificator", { ns: import_package.default.name }));
|
|
147
|
-
}
|
|
148
|
-
const verificator = await verificationPlugin.verificationManager.getVerificator(name);
|
|
149
|
-
if (!verificator) {
|
|
150
|
-
return ctx.throw(400, ctx.t("Invalid verificator"));
|
|
151
|
-
}
|
|
152
|
-
const Verification = verificationPlugin.verificationManager.getVerification(verificator.verificationType);
|
|
153
|
-
const verification = new Verification({ ctx, verificator, options: verificator.options });
|
|
154
|
-
const { uuid, meta } = await verification.bind(user.id);
|
|
155
|
-
await verificator.addUser(user.id, {
|
|
156
|
-
through: {
|
|
157
|
-
uuid,
|
|
158
|
-
meta
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
ctx.body = {};
|
|
162
|
-
await next();
|
|
163
|
-
},
|
|
164
|
-
unbind: async (ctx, next) => {
|
|
165
|
-
const { unbindVerificator: name } = ctx.action.params.values || {};
|
|
166
|
-
const user = ctx.auth.user;
|
|
167
|
-
const verificationPlugin = ctx.app.pm.get("verification");
|
|
168
|
-
const verificator = await verificationPlugin.verificationManager.getVerificator(name);
|
|
169
|
-
if (!verificator) {
|
|
170
|
-
return ctx.throw(400, ctx.t("Invalid verificator"));
|
|
171
|
-
}
|
|
172
|
-
await verificator.removeUser(user.id);
|
|
173
|
-
await next();
|
|
174
|
-
}
|
|
175
|
-
};
|
|
@@ -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
|
-
declare const _default: import("@nocobase/database").CollectionOptions;
|
|
10
|
-
export default _default;
|