@nocobase/plugin-verification 0.8.0-alpha.8 → 0.8.1-alpha.3
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/client.d.ts +4 -0
- package/client.js +30 -0
- package/lib/client/ProviderOptions.d.ts +3 -0
- package/lib/client/ProviderOptions.js +81 -0
- package/lib/client/Shortcut.d.ts +1 -0
- package/lib/client/Shortcut.js +78 -0
- package/lib/client/VerificationProviders.d.ts +2 -0
- package/lib/client/VerificationProviders.js +55 -0
- package/lib/client/index.d.ts +3 -0
- package/lib/client/index.js +74 -0
- package/lib/client/locale/index.d.ts +3 -0
- package/lib/client/locale/index.js +47 -0
- package/lib/client/locale/zh-CN.d.ts +12 -0
- package/lib/client/locale/zh-CN.js +19 -0
- package/lib/client/providerTypes/index.d.ts +4 -0
- package/lib/client/providerTypes/index.js +25 -0
- package/lib/client/providerTypes/sms-aliyun.d.ts +57 -0
- package/lib/client/providerTypes/sms-aliyun.js +45 -0
- package/lib/client/schemas/providers.d.ts +355 -0
- package/lib/client/schemas/providers.js +356 -0
- package/lib/index.d.ts +1 -4
- package/lib/index.js +3 -34
- package/lib/{Plugin.d.ts → server/Plugin.d.ts} +1 -1
- package/lib/{Plugin.js → server/Plugin.js} +22 -4
- package/lib/{actions → server/actions}/index.d.ts +0 -0
- package/lib/{actions → server/actions}/index.js +0 -0
- package/lib/{actions → server/actions}/verifications.d.ts +0 -0
- package/lib/{actions → server/actions}/verifications.js +12 -5
- package/lib/{collections → server/collections}/verifications.d.ts +0 -0
- package/lib/{collections → server/collections}/verifications.js +0 -0
- package/lib/{collections → server/collections}/verifications_providers.d.ts +0 -0
- package/lib/{collections → server/collections}/verifications_providers.js +3 -0
- package/lib/{constants.d.ts → server/constants.d.ts} +0 -0
- package/lib/{constants.js → server/constants.js} +0 -0
- package/lib/server/index.d.ts +4 -0
- package/lib/server/index.js +46 -0
- package/lib/{locale → server/locale}/index.d.ts +0 -0
- package/lib/{locale → server/locale}/index.js +0 -0
- package/lib/{locale → server/locale}/zh-CN.d.ts +1 -0
- package/lib/{locale → server/locale}/zh-CN.js +2 -1
- package/lib/{providers → server/providers}/index.d.ts +0 -0
- package/lib/{providers → server/providers}/index.js +0 -0
- package/lib/{providers → server/providers}/sms-aliyun.d.ts +0 -0
- package/lib/{providers → server/providers}/sms-aliyun.js +1 -0
- package/package.json +7 -7
- package/server.d.ts +4 -0
- package/server.js +30 -0
- package/src/client/ProviderOptions.tsx +22 -0
- package/src/client/Shortcut.tsx +20 -0
- package/src/client/VerificationProviders.tsx +19 -0
- package/src/client/index.tsx +41 -0
- package/src/client/locale/index.ts +16 -0
- package/src/client/locale/zh-CN.ts +13 -0
- package/src/client/providerTypes/index.ts +9 -0
- package/src/client/providerTypes/sms-aliyun.ts +39 -0
- package/src/client/schemas/providers.ts +330 -0
- package/src/index.ts +1 -5
- package/src/{Plugin.ts → server/Plugin.ts} +13 -2
- package/src/{__tests__ → server/__tests__}/Plugin.test.ts +1 -3
- package/src/{__tests__ → server/__tests__}/collections/authors.ts +0 -0
- package/src/{__tests__ → server/__tests__}/index.ts +0 -0
- package/src/{actions → server/actions}/index.ts +0 -0
- package/src/{actions → server/actions}/verifications.ts +5 -3
- package/src/{collections → server/collections}/verifications.ts +0 -0
- package/src/{collections → server/collections}/verifications_providers.ts +4 -0
- package/src/{constants.ts → server/constants.ts} +0 -0
- package/src/server/index.ts +5 -0
- package/src/{locale → server/locale}/index.ts +0 -0
- package/src/{locale → server/locale}/zh-CN.ts +2 -1
- package/src/{providers → server/providers}/index.ts +0 -0
- package/src/{providers → server/providers}/sms-aliyun.ts +1 -0
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
function _shared() {
|
|
9
|
+
const data = require("@formily/shared");
|
|
10
|
+
|
|
11
|
+
_shared = function _shared() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _client() {
|
|
19
|
+
const data = require("@nocobase/client");
|
|
20
|
+
|
|
21
|
+
_client = function _client() {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var _locale = require("../locale");
|
|
29
|
+
|
|
30
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
31
|
+
|
|
32
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
33
|
+
|
|
34
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
35
|
+
|
|
36
|
+
const collection = {
|
|
37
|
+
name: 'verifications_providers',
|
|
38
|
+
fields: [{
|
|
39
|
+
type: 'string',
|
|
40
|
+
name: 'id',
|
|
41
|
+
interface: 'input',
|
|
42
|
+
uiSchema: {
|
|
43
|
+
title: '{{t("ID")}}',
|
|
44
|
+
type: 'string',
|
|
45
|
+
'x-component': 'Input',
|
|
46
|
+
required: true
|
|
47
|
+
}
|
|
48
|
+
}, {
|
|
49
|
+
type: 'string',
|
|
50
|
+
name: 'title',
|
|
51
|
+
interface: 'input',
|
|
52
|
+
uiSchema: {
|
|
53
|
+
title: '{{t("Title")}}',
|
|
54
|
+
type: 'string',
|
|
55
|
+
'x-component': 'Input',
|
|
56
|
+
required: true
|
|
57
|
+
}
|
|
58
|
+
}, {
|
|
59
|
+
type: 'string',
|
|
60
|
+
name: 'type',
|
|
61
|
+
interface: 'select',
|
|
62
|
+
uiSchema: {
|
|
63
|
+
title: `{{t("Provider type", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
64
|
+
type: 'string',
|
|
65
|
+
'x-component': 'Select',
|
|
66
|
+
required: true,
|
|
67
|
+
enum: [{
|
|
68
|
+
label: `{{t("Aliyun SMS", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
69
|
+
value: 'sms-aliyun'
|
|
70
|
+
}]
|
|
71
|
+
}
|
|
72
|
+
}, {
|
|
73
|
+
type: 'radio',
|
|
74
|
+
name: 'default',
|
|
75
|
+
interface: 'checkbox',
|
|
76
|
+
uiSchema: {
|
|
77
|
+
title: '{{t("Default")}}',
|
|
78
|
+
type: 'boolean',
|
|
79
|
+
'x-component': 'Checkbox'
|
|
80
|
+
}
|
|
81
|
+
}]
|
|
82
|
+
};
|
|
83
|
+
var _default = {
|
|
84
|
+
type: 'void',
|
|
85
|
+
name: 'providers',
|
|
86
|
+
'x-decorator': 'ResourceActionProvider',
|
|
87
|
+
'x-decorator-props': {
|
|
88
|
+
collection,
|
|
89
|
+
resourceName: 'verifications_providers',
|
|
90
|
+
request: {
|
|
91
|
+
resource: 'verifications_providers',
|
|
92
|
+
action: 'list',
|
|
93
|
+
params: {
|
|
94
|
+
pageSize: 50,
|
|
95
|
+
sort: ['-default', 'id'],
|
|
96
|
+
appends: []
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
'x-component': 'CollectionProvider',
|
|
101
|
+
'x-component-props': {
|
|
102
|
+
collection
|
|
103
|
+
},
|
|
104
|
+
properties: {
|
|
105
|
+
actions: {
|
|
106
|
+
type: 'void',
|
|
107
|
+
'x-component': 'ActionBar',
|
|
108
|
+
'x-component-props': {
|
|
109
|
+
style: {
|
|
110
|
+
marginBottom: 16
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
properties: {
|
|
114
|
+
delete: {
|
|
115
|
+
type: 'void',
|
|
116
|
+
title: '{{t("Delete")}}',
|
|
117
|
+
'x-component': 'Action',
|
|
118
|
+
'x-component-props': {
|
|
119
|
+
useAction: '{{ cm.useBulkDestroyAction }}',
|
|
120
|
+
confirm: {
|
|
121
|
+
title: "{{t('Delete')}}",
|
|
122
|
+
content: "{{t('Are you sure you want to delete it?')}}"
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
create: {
|
|
127
|
+
type: 'void',
|
|
128
|
+
title: '{{t("Add new")}}',
|
|
129
|
+
'x-component': 'Action',
|
|
130
|
+
'x-component-props': {
|
|
131
|
+
type: 'primary'
|
|
132
|
+
},
|
|
133
|
+
properties: {
|
|
134
|
+
drawer: {
|
|
135
|
+
type: 'void',
|
|
136
|
+
'x-component': 'Action.Drawer',
|
|
137
|
+
'x-decorator': 'Form',
|
|
138
|
+
'x-decorator-props': {
|
|
139
|
+
useValues(options) {
|
|
140
|
+
const ctx = (0, _client().useActionContext)();
|
|
141
|
+
return (0, _client().useRequest)(() => Promise.resolve({
|
|
142
|
+
data: {
|
|
143
|
+
name: `s_${(0, _shared().uid)()}`
|
|
144
|
+
}
|
|
145
|
+
}), _objectSpread(_objectSpread({}, options), {}, {
|
|
146
|
+
refreshDeps: [ctx.visible]
|
|
147
|
+
}));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
},
|
|
151
|
+
title: '{{t("Add new")}}',
|
|
152
|
+
properties: {
|
|
153
|
+
id: {
|
|
154
|
+
'x-component': 'CollectionField',
|
|
155
|
+
'x-decorator': 'FormItem',
|
|
156
|
+
description: '{{t("Identifier for program usage. Support letters, numbers and underscores, must start with an letter.")}}'
|
|
157
|
+
},
|
|
158
|
+
title: {
|
|
159
|
+
'x-component': 'CollectionField',
|
|
160
|
+
'x-decorator': 'FormItem'
|
|
161
|
+
},
|
|
162
|
+
type: {
|
|
163
|
+
'x-component': 'CollectionField',
|
|
164
|
+
'x-decorator': 'FormItem'
|
|
165
|
+
},
|
|
166
|
+
options: {
|
|
167
|
+
type: 'object',
|
|
168
|
+
'x-component': 'ProviderOptions'
|
|
169
|
+
},
|
|
170
|
+
default: {
|
|
171
|
+
'x-component': 'CollectionField',
|
|
172
|
+
'x-decorator': 'FormItem'
|
|
173
|
+
},
|
|
174
|
+
footer: {
|
|
175
|
+
type: 'void',
|
|
176
|
+
'x-component': 'Action.Drawer.Footer',
|
|
177
|
+
properties: {
|
|
178
|
+
cancel: {
|
|
179
|
+
title: '{{t("Cancel")}}',
|
|
180
|
+
'x-component': 'Action',
|
|
181
|
+
'x-component-props': {
|
|
182
|
+
useAction: '{{ cm.useCancelAction }}'
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
submit: {
|
|
186
|
+
title: '{{t("Submit")}}',
|
|
187
|
+
'x-component': 'Action',
|
|
188
|
+
'x-component-props': {
|
|
189
|
+
type: 'primary',
|
|
190
|
+
useAction: '{{ cm.useCreateAction }}'
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
table: {
|
|
202
|
+
type: 'void',
|
|
203
|
+
'x-uid': 'input',
|
|
204
|
+
'x-component': 'Table.Void',
|
|
205
|
+
'x-component-props': {
|
|
206
|
+
rowKey: 'id',
|
|
207
|
+
rowSelection: {
|
|
208
|
+
type: 'checkbox'
|
|
209
|
+
},
|
|
210
|
+
useDataSource: '{{ cm.useDataSourceFromRAC }}'
|
|
211
|
+
},
|
|
212
|
+
properties: {
|
|
213
|
+
id: {
|
|
214
|
+
type: 'void',
|
|
215
|
+
'x-decorator': 'Table.Column.Decorator',
|
|
216
|
+
'x-component': 'Table.Column',
|
|
217
|
+
properties: {
|
|
218
|
+
id: {
|
|
219
|
+
type: 'string',
|
|
220
|
+
'x-component': 'CollectionField',
|
|
221
|
+
'x-read-pretty': true
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
title: {
|
|
226
|
+
type: 'void',
|
|
227
|
+
'x-decorator': 'Table.Column.Decorator',
|
|
228
|
+
'x-component': 'Table.Column',
|
|
229
|
+
properties: {
|
|
230
|
+
title: {
|
|
231
|
+
type: 'string',
|
|
232
|
+
'x-component': 'CollectionField',
|
|
233
|
+
'x-read-pretty': true
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
type: {
|
|
238
|
+
type: 'void',
|
|
239
|
+
'x-decorator': 'Table.Column.Decorator',
|
|
240
|
+
'x-component': 'Table.Column',
|
|
241
|
+
properties: {
|
|
242
|
+
type: {
|
|
243
|
+
type: 'string',
|
|
244
|
+
'x-component': 'CollectionField',
|
|
245
|
+
'x-read-pretty': true
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
default: {
|
|
250
|
+
type: 'void',
|
|
251
|
+
'x-decorator': 'Table.Column.Decorator',
|
|
252
|
+
'x-component': 'Table.Column',
|
|
253
|
+
properties: {
|
|
254
|
+
default: {
|
|
255
|
+
type: 'boolean',
|
|
256
|
+
'x-component': 'CollectionField',
|
|
257
|
+
'x-read-pretty': true
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
actions: {
|
|
262
|
+
type: 'void',
|
|
263
|
+
title: '{{t("Actions")}}',
|
|
264
|
+
'x-component': 'Table.Column',
|
|
265
|
+
properties: {
|
|
266
|
+
actions: {
|
|
267
|
+
type: 'void',
|
|
268
|
+
'x-component': 'Space',
|
|
269
|
+
'x-component-props': {
|
|
270
|
+
split: '|'
|
|
271
|
+
},
|
|
272
|
+
properties: {
|
|
273
|
+
update: {
|
|
274
|
+
type: 'void',
|
|
275
|
+
title: '{{t("Edit")}}',
|
|
276
|
+
'x-component': 'Action.Link',
|
|
277
|
+
'x-component-props': {
|
|
278
|
+
type: 'primary'
|
|
279
|
+
},
|
|
280
|
+
properties: {
|
|
281
|
+
drawer: {
|
|
282
|
+
type: 'void',
|
|
283
|
+
'x-component': 'Action.Drawer',
|
|
284
|
+
'x-decorator': 'Form',
|
|
285
|
+
'x-decorator-props': {
|
|
286
|
+
useValues: '{{ cm.useValuesFromRecord }}'
|
|
287
|
+
},
|
|
288
|
+
title: '{{t("Edit")}}',
|
|
289
|
+
properties: {
|
|
290
|
+
id: {
|
|
291
|
+
'x-component': 'CollectionField',
|
|
292
|
+
'x-decorator': 'FormItem'
|
|
293
|
+
},
|
|
294
|
+
title: {
|
|
295
|
+
'x-component': 'CollectionField',
|
|
296
|
+
'x-decorator': 'FormItem'
|
|
297
|
+
},
|
|
298
|
+
type: {
|
|
299
|
+
'x-component': 'CollectionField',
|
|
300
|
+
'x-decorator': 'FormItem',
|
|
301
|
+
'x-disabled': true
|
|
302
|
+
},
|
|
303
|
+
options: {
|
|
304
|
+
type: 'object',
|
|
305
|
+
'x-component': 'ProviderOptions'
|
|
306
|
+
},
|
|
307
|
+
default: {
|
|
308
|
+
'x-component': 'CollectionField',
|
|
309
|
+
'x-decorator': 'FormItem'
|
|
310
|
+
},
|
|
311
|
+
footer: {
|
|
312
|
+
type: 'void',
|
|
313
|
+
'x-component': 'Action.Drawer.Footer',
|
|
314
|
+
properties: {
|
|
315
|
+
cancel: {
|
|
316
|
+
title: '{{t("Cancel")}}',
|
|
317
|
+
'x-component': 'Action',
|
|
318
|
+
'x-component-props': {
|
|
319
|
+
useAction: '{{ cm.useCancelAction }}'
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
submit: {
|
|
323
|
+
title: '{{t("Submit")}}',
|
|
324
|
+
'x-component': 'Action',
|
|
325
|
+
'x-component-props': {
|
|
326
|
+
type: 'primary',
|
|
327
|
+
useAction: '{{ cm.useUpdateAction }}'
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
delete: {
|
|
337
|
+
type: 'void',
|
|
338
|
+
title: '{{ t("Delete") }}',
|
|
339
|
+
'x-component': 'Action.Link',
|
|
340
|
+
'x-component-props': {
|
|
341
|
+
confirm: {
|
|
342
|
+
title: "{{t('Delete record')}}",
|
|
343
|
+
content: "{{t('Are you sure you want to delete it?')}}"
|
|
344
|
+
},
|
|
345
|
+
useAction: '{{cm.useDestroyAction}}'
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
exports.default = _default;
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -3,44 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
var _exportNames = {
|
|
7
|
-
namespace: true,
|
|
8
|
-
Provider: true
|
|
9
|
-
};
|
|
10
|
-
Object.defineProperty(exports, "Provider", {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function get() {
|
|
13
|
-
return _providers.Provider;
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
6
|
Object.defineProperty(exports, "default", {
|
|
17
7
|
enumerable: true,
|
|
18
8
|
get: function get() {
|
|
19
|
-
return
|
|
9
|
+
return _server.default;
|
|
20
10
|
}
|
|
21
11
|
});
|
|
22
|
-
exports.namespace = void 0;
|
|
23
|
-
|
|
24
|
-
var _constants = require("./constants");
|
|
25
|
-
|
|
26
|
-
Object.keys(_constants).forEach(function (key) {
|
|
27
|
-
if (key === "default" || key === "__esModule") return;
|
|
28
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
29
|
-
if (key in exports && exports[key] === _constants[key]) return;
|
|
30
|
-
Object.defineProperty(exports, key, {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function get() {
|
|
33
|
-
return _constants[key];
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
var _providers = require("./providers");
|
|
39
|
-
|
|
40
|
-
var _Plugin = _interopRequireDefault(require("./Plugin"));
|
|
41
|
-
|
|
42
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
43
12
|
|
|
44
|
-
|
|
13
|
+
var _server = _interopRequireDefault(require("./server"));
|
|
45
14
|
|
|
46
|
-
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -5,7 +5,6 @@ import { Registry } from '@nocobase/utils';
|
|
|
5
5
|
import { Provider } from './providers';
|
|
6
6
|
export interface Interceptor {
|
|
7
7
|
manual?: boolean;
|
|
8
|
-
provider: string;
|
|
9
8
|
expiresIn?: number;
|
|
10
9
|
getReceiver(ctx: any): string;
|
|
11
10
|
getCode?(ctx: any): string;
|
|
@@ -17,4 +16,5 @@ export default class VerificationPlugin extends Plugin {
|
|
|
17
16
|
intercept: HandlerType;
|
|
18
17
|
install(): Promise<void>;
|
|
19
18
|
load(): Promise<void>;
|
|
19
|
+
getDefault(): Promise<any>;
|
|
20
20
|
}
|
|
@@ -109,8 +109,10 @@ class VerificationPlugin extends _server().Plugin {
|
|
|
109
109
|
|
|
110
110
|
if (!item) {
|
|
111
111
|
return context.throw(400, {
|
|
112
|
-
code: '
|
|
113
|
-
message: '
|
|
112
|
+
code: 'InvalidVerificationCode',
|
|
113
|
+
message: context.t('Verification code is invalid', {
|
|
114
|
+
ns: _.namespace
|
|
115
|
+
})
|
|
114
116
|
});
|
|
115
117
|
} // TODO: code should be removed if exists in values
|
|
116
118
|
// context.action.mergeParams({
|
|
@@ -145,7 +147,7 @@ class VerificationPlugin extends _server().Plugin {
|
|
|
145
147
|
INIT_ALI_SMS_VERIFY_CODE_TEMPLATE = _process$env.INIT_ALI_SMS_VERIFY_CODE_TEMPLATE,
|
|
146
148
|
INIT_ALI_SMS_VERIFY_CODE_SIGN = _process$env.INIT_ALI_SMS_VERIFY_CODE_SIGN;
|
|
147
149
|
|
|
148
|
-
if (INIT_ALI_SMS_ACCESS_KEY && INIT_ALI_SMS_ACCESS_KEY_SECRET && INIT_ALI_SMS_VERIFY_CODE_TEMPLATE && INIT_ALI_SMS_VERIFY_CODE_SIGN) {
|
|
150
|
+
if (DEFAULT_SMS_VERIFY_CODE_PROVIDER && INIT_ALI_SMS_ACCESS_KEY && INIT_ALI_SMS_ACCESS_KEY_SECRET && INIT_ALI_SMS_VERIFY_CODE_TEMPLATE && INIT_ALI_SMS_VERIFY_CODE_SIGN) {
|
|
149
151
|
const ProviderRepo = _this2.db.getRepository('verifications_providers');
|
|
150
152
|
|
|
151
153
|
yield ProviderRepo.create({
|
|
@@ -159,7 +161,8 @@ class VerificationPlugin extends _server().Plugin {
|
|
|
159
161
|
endpoint: INIT_ALI_SMS_ENDPOINT,
|
|
160
162
|
sign: INIT_ALI_SMS_VERIFY_CODE_SIGN,
|
|
161
163
|
template: INIT_ALI_SMS_VERIFY_CODE_TEMPLATE
|
|
162
|
-
}
|
|
164
|
+
},
|
|
165
|
+
default: true
|
|
163
166
|
}
|
|
164
167
|
});
|
|
165
168
|
}
|
|
@@ -202,6 +205,21 @@ class VerificationPlugin extends _server().Plugin {
|
|
|
202
205
|
};
|
|
203
206
|
}());
|
|
204
207
|
app.acl.allow('verifications', 'create');
|
|
208
|
+
app.acl.allow('verifications_providers', '*', 'allowConfigure');
|
|
209
|
+
})();
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
getDefault() {
|
|
213
|
+
var _this4 = this;
|
|
214
|
+
|
|
215
|
+
return _asyncToGenerator(function* () {
|
|
216
|
+
const providerRepo = _this4.db.getRepository('verifications_providers');
|
|
217
|
+
|
|
218
|
+
return providerRepo.findOne({
|
|
219
|
+
filter: {
|
|
220
|
+
default: true
|
|
221
|
+
}
|
|
222
|
+
});
|
|
205
223
|
})();
|
|
206
224
|
}
|
|
207
225
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -85,7 +85,9 @@ function _create() {
|
|
|
85
85
|
|
|
86
86
|
const ProviderRepo = context.db.getRepository('verifications_providers');
|
|
87
87
|
const providerItem = yield ProviderRepo.findOne({
|
|
88
|
-
|
|
88
|
+
filter: {
|
|
89
|
+
default: true
|
|
90
|
+
}
|
|
89
91
|
});
|
|
90
92
|
|
|
91
93
|
if (!providerItem) {
|
|
@@ -98,7 +100,9 @@ function _create() {
|
|
|
98
100
|
if (!receiver) {
|
|
99
101
|
return context.throw(400, {
|
|
100
102
|
code: 'InvalidReceiver',
|
|
101
|
-
message: '
|
|
103
|
+
message: context.t('Not a valid cellphone number, please re-enter', {
|
|
104
|
+
ns: _.namespace
|
|
105
|
+
})
|
|
102
106
|
});
|
|
103
107
|
}
|
|
104
108
|
|
|
@@ -151,9 +155,12 @@ function _create() {
|
|
|
151
155
|
switch (error.name) {
|
|
152
156
|
case 'InvalidReceiver':
|
|
153
157
|
// TODO: message should consider email and other providers, maybe use "receiver"
|
|
154
|
-
return context.throw(400,
|
|
155
|
-
|
|
156
|
-
|
|
158
|
+
return context.throw(400, {
|
|
159
|
+
code: 'InvalidReceiver',
|
|
160
|
+
message: context.t('Not a valid cellphone number, please re-enter', {
|
|
161
|
+
ns: _.namespace
|
|
162
|
+
})
|
|
163
|
+
});
|
|
157
164
|
|
|
158
165
|
case 'RateLimit':
|
|
159
166
|
return context.throw(429, context.t('You are trying so frequently, please slow down', {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
namespace: true,
|
|
8
|
+
Provider: true
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "Provider", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function get() {
|
|
13
|
+
return _providers.Provider;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(exports, "default", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function get() {
|
|
19
|
+
return _Plugin.default;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
exports.namespace = void 0;
|
|
23
|
+
|
|
24
|
+
var _constants = require("./constants");
|
|
25
|
+
|
|
26
|
+
Object.keys(_constants).forEach(function (key) {
|
|
27
|
+
if (key === "default" || key === "__esModule") return;
|
|
28
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
29
|
+
if (key in exports && exports[key] === _constants[key]) return;
|
|
30
|
+
Object.defineProperty(exports, key, {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function get() {
|
|
33
|
+
return _constants[key];
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
var _providers = require("./providers");
|
|
39
|
+
|
|
40
|
+
var _Plugin = _interopRequireDefault(require("./Plugin"));
|
|
41
|
+
|
|
42
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
43
|
+
|
|
44
|
+
const namespace = require('../../package.json').name;
|
|
45
|
+
|
|
46
|
+
exports.namespace = namespace;
|
|
File without changes
|
|
File without changes
|
|
@@ -8,6 +8,7 @@ var _default = {
|
|
|
8
8
|
'Verification send failed, please try later or contact to administrator': '验证码发送失败,请稍后重试或联系管理员',
|
|
9
9
|
'Not a valid cellphone number, please re-enter': '不是有效的手机号,请重新输入',
|
|
10
10
|
"Please don't retry in {{time}} seconds": '请 {{time}} 秒后再试',
|
|
11
|
-
'You are trying so frequently, please slow down': '您的操作太频繁,请稍后再试'
|
|
11
|
+
'You are trying so frequently, please slow down': '您的操作太频繁,请稍后再试',
|
|
12
|
+
'Verification code is invalid': '无效的验证码'
|
|
12
13
|
};
|
|
13
14
|
exports.default = _default;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-verification",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1-alpha.3",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"licenses": [
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
"@alicloud/dysmsapi20170525": "2.0.17",
|
|
14
14
|
"@alicloud/openapi-client": "0.4.1",
|
|
15
15
|
"@alicloud/tea-util": "1.4.4",
|
|
16
|
-
"@nocobase/actions": "0.8.
|
|
17
|
-
"@nocobase/resourcer": "0.8.
|
|
18
|
-
"@nocobase/server": "0.8.
|
|
19
|
-
"@nocobase/utils": "0.8.
|
|
16
|
+
"@nocobase/actions": "0.8.1-alpha.3",
|
|
17
|
+
"@nocobase/resourcer": "0.8.1-alpha.3",
|
|
18
|
+
"@nocobase/server": "0.8.1-alpha.3",
|
|
19
|
+
"@nocobase/utils": "0.8.1-alpha.3"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@nocobase/test": "0.8.
|
|
22
|
+
"@nocobase/test": "0.8.1-alpha.3"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "e03df3df5962b99d9fbf5b6e33fbe2b23f14f3d3"
|
|
25
25
|
}
|
package/server.d.ts
ADDED