vona-module-a-captcha 5.0.26 → 5.0.27

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.
@@ -5,6 +5,7 @@ export declare class BeanCaptcha extends BeanBase {
5
5
  create(sceneName: keyof ICaptchaSceneRecord): Promise<ICaptchaData>;
6
6
  refresh(id: string, sceneName: keyof ICaptchaSceneRecord): Promise<ICaptchaData>;
7
7
  verify(id: string, token: unknown, sceneName: keyof ICaptchaSceneRecord): Promise<boolean>;
8
+ private _verifyInner;
8
9
  verifyImmediate(id: string, token: unknown): Promise<false | string>;
9
10
  getCaptchaData(id: string): Promise<ICaptchaDataCache | undefined>;
10
11
  updateCaptchaToken(id: string, token: unknown): Promise<undefined>;
package/dist/index.js CHANGED
@@ -57,6 +57,7 @@ let BeanCaptcha = class BeanCaptcha extends BeanBase {
57
57
  await this.scope.cacheRedis.captcha.set(captchaData, id, {
58
58
  ttl: provider.options.ttl ?? this.scope.config.captchaProvider.ttl
59
59
  });
60
+ this.$loggerChild('captcha').debug(() => `captcha.create: id:${id}, sceneName:${sceneName}, provider:${provider.name}, token:${captcha.token}`);
60
61
  // result
61
62
  const result = {
62
63
  id,
@@ -90,6 +91,7 @@ let BeanCaptcha = class BeanCaptcha extends BeanBase {
90
91
  await this.scope.cacheRedis.captcha.set(captchaData, id, {
91
92
  ttl: providerOptions.ttl ?? this.scope.config.captchaProvider.ttl
92
93
  });
94
+ this.$loggerChild('captcha').debug(() => `captcha.refresh: id:${id}, sceneName:${sceneName}, provider:${captchaData.provider}, token:${captcha.token}`);
93
95
  // result
94
96
  const result = {
95
97
  id,
@@ -102,7 +104,12 @@ let BeanCaptcha = class BeanCaptcha extends BeanBase {
102
104
  return result;
103
105
  }
104
106
  async verify(id, token, sceneName) {
105
- let captchaData = await this.getCaptchaData(id);
107
+ const captchaData = await this.getCaptchaData(id);
108
+ const verified = await this._verifyInner(captchaData, id, token, sceneName);
109
+ this.$loggerChild('captcha').debug(() => `captcha.verify: id:${id}, sceneName:${sceneName}, provider:${captchaData?.provider}, token:${token}, tokenWanted:${captchaData?.token}`);
110
+ return verified;
111
+ }
112
+ async _verifyInner(captchaData, id, token, sceneName) {
106
113
  if (!captchaData) return false;
107
114
  // scene
108
115
  if (captchaData.scene !== sceneName) return false;
@@ -1,5 +1,6 @@
1
1
  import type { ICaptchaProviderRecord } from './captchaProvider.ts';
2
2
  import type { ICaptchaSceneRecord } from './captchaScene.ts';
3
+ import 'vona';
3
4
  export interface ICaptchaDataCache {
4
5
  scene: keyof ICaptchaSceneRecord;
5
6
  provider: keyof ICaptchaProviderRecord;
@@ -12,3 +13,8 @@ export interface ICaptchaData {
12
13
  token?: unknown;
13
14
  payload: unknown;
14
15
  }
16
+ declare module 'vona' {
17
+ interface ILoggerChildRecord {
18
+ captcha: never;
19
+ }
20
+ }
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.26",
4
+ "version": "5.0.27",
5
5
  "title": "a-captcha",
6
6
  "vonaModule": {
7
7
  "dependencies": {},