vona-module-a-captcha 5.0.24 → 5.0.26

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.
@@ -7,4 +7,4 @@ export declare const locales: {
7
7
  CaptchaInvalid: string;
8
8
  };
9
9
  };
10
- export declare function $locale<K extends keyof (typeof locales)[TypeLocaleBase]>(key: K): import("vona").ILocaleMagic<`a-captcha::${K}`>;
10
+ export declare function $locale<K extends keyof (typeof locales)[TypeLocaleBase]>(key: K, ...args: any[]): any;
package/dist/index.js CHANGED
@@ -1,20 +1,16 @@
1
1
  import { BeanInfo, BeanBase, uuidv4, beanFullNameFromOnionName, deepExtend, BeanScopeBase, $makeLocaleMagic, createBeanDecorator } from 'vona';
2
+ import { __decorate, __metadata, __param } from 'tslib';
2
3
  import { zodCustomError, getRandomInt } from '@cabloy/utils';
3
4
  import { Interceptor } from 'vona-module-a-aspect';
4
5
  import { Bean, Scope } from 'vona-module-a-bean';
5
6
  import { CacheRedis, BeanCacheRedisBase } from 'vona-module-a-cache';
6
7
  import { Api, v } from 'vona-module-a-openapiutils';
7
- import { Dto, Controller, Web, Arg } from 'vona-module-a-web';
8
+ import { Dto, Web, Arg, Controller } from 'vona-module-a-web';
8
9
  import z from 'zod';
9
10
  import { Passport } from 'vona-module-a-user';
10
11
  import { Hmr } from 'vona-module-a-hmr';
11
12
 
12
- var _dec$8, _dec2$8, _class$8;
13
- let InterceptorCaptchaVerify = (_dec$8 = Interceptor({
14
- bodyField: 'captcha'
15
- }), _dec2$8 = BeanInfo({
16
- module: "a-captcha"
17
- }), _dec$8(_class$8 = _dec2$8(_class$8 = class InterceptorCaptchaVerify extends BeanBase {
13
+ let InterceptorCaptchaVerify = class InterceptorCaptchaVerify extends BeanBase {
18
14
  async execute(options, next) {
19
15
  // scene
20
16
  const sceneName = options.scene;
@@ -30,17 +26,19 @@ let InterceptorCaptchaVerify = (_dec$8 = Interceptor({
30
26
  // next
31
27
  return next();
32
28
  }
33
- }) || _class$8) || _class$8);
29
+ };
30
+ InterceptorCaptchaVerify = __decorate([Interceptor({
31
+ bodyField: 'captcha'
32
+ }), BeanInfo({
33
+ module: "a-captcha"
34
+ })], InterceptorCaptchaVerify);
34
35
 
35
36
  const SymbolCacheSceneProviders = Symbol('SymbolCacheSceneProviders');
36
37
  function clearAllCacheSceneProviders(app) {
37
38
  delete app.meta[SymbolCacheSceneProviders];
38
39
  }
39
40
 
40
- var _dec$7, _dec2$7, _class$7;
41
- let BeanCaptcha = (_dec$7 = Bean(), _dec2$7 = BeanInfo({
42
- module: "a-captcha"
43
- }), _dec$7(_class$7 = _dec2$7(_class$7 = class BeanCaptcha extends BeanBase {
41
+ let BeanCaptcha = class BeanCaptcha extends BeanBase {
44
42
  async create(sceneName) {
45
43
  // resolve provider
46
44
  const provider = await this._resolveProvider(sceneName);
@@ -235,103 +233,52 @@ let BeanCaptcha = (_dec$7 = Bean(), _dec2$7 = BeanInfo({
235
233
  }
236
234
  return providersNew;
237
235
  }
238
- }) || _class$7) || _class$7);
236
+ };
237
+ BeanCaptcha = __decorate([Bean(), BeanInfo({
238
+ module: "a-captcha"
239
+ })], BeanCaptcha);
239
240
  async function resolverDefault(_ctx, providers) {
240
241
  const keys = Object.keys(providers);
241
242
  const index = getRandomInt(keys.length, 0);
242
243
  return keys[index];
243
244
  }
244
245
 
245
- var _dec$6, _dec2$6, _class$6;
246
- let CacheRedisCaptcha = (_dec$6 = CacheRedis({
246
+ let CacheRedisCaptcha = class CacheRedisCaptcha extends BeanCacheRedisBase {};
247
+ CacheRedisCaptcha = __decorate([CacheRedis({
247
248
  disableTransactionCompensate: true
248
- }), _dec2$6 = BeanInfo({
249
+ }), BeanInfo({
249
250
  module: "a-captcha"
250
- }), _dec$6(_class$6 = _dec2$6(_class$6 = class CacheRedisCaptcha extends BeanCacheRedisBase {}) || _class$6) || _class$6);
251
-
252
- function _applyDecoratedDescriptor(i, e, r, n, l) {
253
- var a = {};
254
- return Object.keys(n).forEach(function (i) {
255
- a[i] = n[i];
256
- }), a.enumerable = !!a.enumerable, a.configurable = !!a.configurable, ("value" in a || a.initializer) && (a.writable = true), a = r.slice().reverse().reduce(function (r, n) {
257
- return n(i, e, r) || r;
258
- }, a), l && void 0 !== a.initializer && (a.value = a.initializer ? a.initializer.call(l) : void 0, a.initializer = void 0), void 0 === a.initializer ? (Object.defineProperty(i, e, a), null) : a;
259
- }
260
- function _initializerDefineProperty(e, i, r, l) {
261
- r && Object.defineProperty(e, i, {
262
- enumerable: r.enumerable,
263
- configurable: r.configurable,
264
- writable: r.writable,
265
- value: r.initializer ? r.initializer.call(l) : void 0
266
- });
267
- }
251
+ })], CacheRedisCaptcha);
268
252
 
269
- var _dec$5, _dec2$5, _dec3$2, _dec4$2, _dec5$2, _dec6$2, _dec7$1, _dec8$1, _dec9$1, _dec0$1, _class$5, _class2$2, _descriptor$1, _descriptor2$1, _descriptor3, _descriptor4;
270
- let DtoCaptchaData = (_dec$5 = Dto(), _dec2$5 = BeanInfo({
271
- module: "a-captcha"
272
- }), _dec3$2 = Api.field(), _dec4$2 = Reflect.metadata("design:type", String), _dec5$2 = Api.field(z.string()), _dec6$2 = Reflect.metadata("design:type", Object), _dec7$1 = Api.field(v.optional()), _dec8$1 = Reflect.metadata("design:type", Object), _dec9$1 = Api.field(), _dec0$1 = Reflect.metadata("design:type", Object), _dec$5(_class$5 = _dec2$5(_class$5 = (_class2$2 = class DtoCaptchaData {
253
+ let DtoCaptchaData = class DtoCaptchaData {
273
254
  constructor() {
274
- _initializerDefineProperty(this, "id", _descriptor$1, this);
275
- _initializerDefineProperty(this, "provider", _descriptor2$1, this);
276
- _initializerDefineProperty(this, "token", _descriptor3, this);
277
- _initializerDefineProperty(this, "payload", _descriptor4, this);
255
+ this.id = void 0;
256
+ this.provider = void 0;
257
+ this.token = void 0;
258
+ this.payload = void 0;
278
259
  }
279
- }, _descriptor$1 = _applyDecoratedDescriptor(_class2$2.prototype, "id", [_dec3$2, _dec4$2], {
280
- configurable: true,
281
- enumerable: true,
282
- writable: true,
283
- initializer: null
284
- }), _descriptor2$1 = _applyDecoratedDescriptor(_class2$2.prototype, "provider", [_dec5$2, _dec6$2], {
285
- configurable: true,
286
- enumerable: true,
287
- writable: true,
288
- initializer: null
289
- }), _descriptor3 = _applyDecoratedDescriptor(_class2$2.prototype, "token", [_dec7$1, _dec8$1], {
290
- configurable: true,
291
- enumerable: true,
292
- writable: true,
293
- initializer: null
294
- }), _descriptor4 = _applyDecoratedDescriptor(_class2$2.prototype, "payload", [_dec9$1, _dec0$1], {
295
- configurable: true,
296
- enumerable: true,
297
- writable: true,
298
- initializer: null
299
- }), _class2$2)) || _class$5) || _class$5);
300
-
301
- var _dec$4, _dec2$4, _dec3$1, _dec4$1, _dec5$1, _dec6$1, _class$4, _class2$1, _descriptor, _descriptor2;
302
- let DtoCaptchaVerify = (_dec$4 = Dto(), _dec2$4 = BeanInfo({
260
+ };
261
+ __decorate([Api.field(), __metadata("design:type", String)], DtoCaptchaData.prototype, "id", void 0);
262
+ __decorate([Api.field(z.string()), __metadata("design:type", Object)], DtoCaptchaData.prototype, "provider", void 0);
263
+ __decorate([Api.field(v.optional()), __metadata("design:type", Object)], DtoCaptchaData.prototype, "token", void 0);
264
+ __decorate([Api.field(), __metadata("design:type", Object)], DtoCaptchaData.prototype, "payload", void 0);
265
+ DtoCaptchaData = __decorate([Dto(), BeanInfo({
303
266
  module: "a-captcha"
304
- }), _dec3$1 = Api.field(), _dec4$1 = Reflect.metadata("design:type", String), _dec5$1 = Api.field(), _dec6$1 = Reflect.metadata("design:type", Object), _dec$4(_class$4 = _dec2$4(_class$4 = (_class2$1 = class DtoCaptchaVerify {
267
+ })], DtoCaptchaData);
268
+
269
+ let DtoCaptchaVerify = class DtoCaptchaVerify {
305
270
  constructor() {
306
- _initializerDefineProperty(this, "id", _descriptor, this);
307
- _initializerDefineProperty(this, "token", _descriptor2, this);
271
+ this.id = void 0;
272
+ this.token = void 0;
308
273
  }
309
- }, _descriptor = _applyDecoratedDescriptor(_class2$1.prototype, "id", [_dec3$1, _dec4$1], {
310
- configurable: true,
311
- enumerable: true,
312
- writable: true,
313
- initializer: null
314
- }), _descriptor2 = _applyDecoratedDescriptor(_class2$1.prototype, "token", [_dec5$1, _dec6$1], {
315
- configurable: true,
316
- enumerable: true,
317
- writable: true,
318
- initializer: null
319
- }), _class2$1)) || _class$4) || _class$4);
320
-
321
- var _dec$3, _dec2$3, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec0, _dec1, _dec10, _dec11, _dec12, _dec13, _dec14, _dec15, _dec16, _dec17, _dec18, _dec19, _dec20, _class$3, _class2;
322
- let ControllerCaptcha = (_dec$3 = Controller('captcha'), _dec2$3 = BeanInfo({
274
+ };
275
+ __decorate([Api.field(), __metadata("design:type", String)], DtoCaptchaVerify.prototype, "id", void 0);
276
+ __decorate([Api.field(), __metadata("design:type", Object)], DtoCaptchaVerify.prototype, "token", void 0);
277
+ DtoCaptchaVerify = __decorate([Dto(), BeanInfo({
323
278
  module: "a-captcha"
324
- }), _dec3 = Web.post('create'), _dec4 = Api.body(DtoCaptchaData), _dec5 = Passport.public(), _dec6 = function (target, key) {
325
- return Arg.body('scene')(target, key, 0);
326
- }, _dec7 = Reflect.metadata("design:type", Function), _dec8 = Reflect.metadata("design:paramtypes", [String]), _dec9 = Web.post('refresh'), _dec0 = Api.body(DtoCaptchaData), _dec1 = Passport.public(), _dec10 = function (target, key) {
327
- return Arg.body('id')(target, key, 0);
328
- }, _dec11 = function (target, key) {
329
- return Arg.body('scene')(target, key, 1);
330
- }, _dec12 = Reflect.metadata("design:type", Function), _dec13 = Reflect.metadata("design:paramtypes", [String, String]), _dec14 = Web.post('verifyImmediate'), _dec15 = Api.body(z.string()), _dec16 = Passport.public(), _dec17 = function (target, key) {
331
- return Arg.body('id')(target, key, 0);
332
- }, _dec18 = function (target, key) {
333
- return Arg.body('token')(target, key, 1);
334
- }, _dec19 = Reflect.metadata("design:type", Function), _dec20 = Reflect.metadata("design:paramtypes", [String, Object]), _dec$3(_class$3 = _dec2$3(_class$3 = (_class2 = class ControllerCaptcha extends BeanBase {
279
+ })], DtoCaptchaVerify);
280
+
281
+ let ControllerCaptcha = class ControllerCaptcha extends BeanBase {
335
282
  async create(scene) {
336
283
  return await this.bean.captcha.create(scene);
337
284
  }
@@ -343,25 +290,31 @@ let ControllerCaptcha = (_dec$3 = Controller('captcha'), _dec2$3 = BeanInfo({
343
290
  if (!verified) this.app.throw(403);
344
291
  return verified;
345
292
  }
346
- }, _applyDecoratedDescriptor(_class2.prototype, "create", [_dec3, _dec4, _dec5, _dec6, _dec7, _dec8], Object.getOwnPropertyDescriptor(_class2.prototype, "create"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "refresh", [_dec9, _dec0, _dec1, _dec10, _dec11, _dec12, _dec13], Object.getOwnPropertyDescriptor(_class2.prototype, "refresh"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "verifyImmediate", [_dec14, _dec15, _dec16, _dec17, _dec18, _dec19, _dec20], Object.getOwnPropertyDescriptor(_class2.prototype, "verifyImmediate"), _class2.prototype), _class2)) || _class$3) || _class$3);
347
-
348
- var _dec$2, _dec2$2, _class$2;
349
- let HmrCaptchaProvider = (_dec$2 = Hmr(), _dec2$2 = BeanInfo({
293
+ };
294
+ __decorate([Web.post('create'), Api.body(DtoCaptchaData), Passport.public(), __param(0, Arg.body('scene')), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], ControllerCaptcha.prototype, "create", null);
295
+ __decorate([Web.post('refresh'), Api.body(DtoCaptchaData), Passport.public(), __param(0, Arg.body('id')), __param(1, Arg.body('scene')), __metadata("design:type", Function), __metadata("design:paramtypes", [String, String]), __metadata("design:returntype", Promise)], ControllerCaptcha.prototype, "refresh", null);
296
+ __decorate([Web.post('verifyImmediate'), Api.body(z.string()), Passport.public(), __param(0, Arg.body('id')), __param(1, Arg.body('token')), __metadata("design:type", Function), __metadata("design:paramtypes", [String, Object]), __metadata("design:returntype", Promise)], ControllerCaptcha.prototype, "verifyImmediate", null);
297
+ ControllerCaptcha = __decorate([Controller('captcha'), BeanInfo({
350
298
  module: "a-captcha"
351
- }), _dec$2(_class$2 = _dec2$2(_class$2 = class HmrCaptchaProvider extends BeanBase {
299
+ })], ControllerCaptcha);
300
+
301
+ let HmrCaptchaProvider = class HmrCaptchaProvider extends BeanBase {
352
302
  async reload(_beanOptions) {
353
303
  clearAllCacheSceneProviders(this.app);
354
304
  }
355
- }) || _class$2) || _class$2);
356
-
357
- var _dec$1, _dec2$1, _class$1;
358
- let HmrCaptchaScene = (_dec$1 = Hmr(), _dec2$1 = BeanInfo({
305
+ };
306
+ HmrCaptchaProvider = __decorate([Hmr(), BeanInfo({
359
307
  module: "a-captcha"
360
- }), _dec$1(_class$1 = _dec2$1(_class$1 = class HmrCaptchaScene extends BeanBase {
308
+ })], HmrCaptchaProvider);
309
+
310
+ let HmrCaptchaScene = class HmrCaptchaScene extends BeanBase {
361
311
  async reload(_beanOptions) {
362
312
  clearAllCacheSceneProviders(this.app);
363
313
  }
364
- }) || _class$1) || _class$1);
314
+ };
315
+ HmrCaptchaScene = __decorate([Hmr(), BeanInfo({
316
+ module: "a-captcha"
317
+ })], HmrCaptchaScene);
365
318
 
366
319
  function config(app) {
367
320
  const showToken = !app.meta.isProd;
@@ -376,11 +329,10 @@ function config(app) {
376
329
  };
377
330
  }
378
331
 
379
- var _dec, _dec2, _class;
380
- let ScopeModuleACaptcha = (_dec = Scope(), _dec2 = BeanInfo({
332
+ let ScopeModuleACaptcha = class ScopeModuleACaptcha extends BeanScopeBase {};
333
+ ScopeModuleACaptcha = __decorate([Scope(), BeanInfo({
381
334
  module: "a-captcha"
382
- }), _dec(_class = _dec2(_class = class ScopeModuleACaptcha extends BeanScopeBase {}) || _class) || _class);
383
-
335
+ })], ScopeModuleACaptcha);
384
336
  /** scope: end */
385
337
 
386
338
  var locale_en_us = {
@@ -395,8 +347,8 @@ const locales = {
395
347
  'en-us': locale_en_us,
396
348
  'zh-cn': locale_zh_cn
397
349
  };
398
- function $locale(key) {
399
- return $makeLocaleMagic(`a-captcha::${key}`);
350
+ function $locale(key, ...args) {
351
+ return $makeLocaleMagic(`a-captcha::${key}`, ...args);
400
352
  }
401
353
 
402
354
  function CaptchaProvider(options) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-module-a-captcha",
3
3
  "type": "module",
4
- "version": "5.0.24",
4
+ "version": "5.0.26",
5
5
  "title": "a-captcha",
6
6
  "vonaModule": {
7
7
  "dependencies": {},