nestjs-base 1.0.17 → 1.0.19
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/controllers/base.controller.d.ts +1 -0
 - package/dist/controllers/base.controller.js.map +1 -1
 - package/dist/tsconfig.build.tsbuildinfo +1 -1
 - package/dist/utils/bcrypt.util.d.ts +2 -2
 - package/dist/utils/bcrypt.util.js.map +1 -1
 - package/dist/utils/svg-captcha.util.d.ts +21 -8
 - package/dist/utils/svg-captcha.util.js +7 -7
 - package/dist/utils/svg-captcha.util.js.map +1 -1
 - package/package.json +1 -1
 
| 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            {"version":3,"file":"bcrypt.util.js","sourceRoot":"","sources":["../../src/utils/bcrypt.util.ts"],"names":[],"mappings":";;;AAAA,iCAAiC; 
     | 
| 
      
 1 
     | 
    
         
            +
            {"version":3,"file":"bcrypt.util.js","sourceRoot":"","sources":["../../src/utils/bcrypt.util.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AAKjC,MAAa,UAAU;IAOrB,MAAM,CAAC,IAAI,CAAC,QAAgB;QAE1B,MAAM,WAAW,GAAG,EAAE,CAAC;QAGvB,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;QAG7C,OAAO,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACzC,CAAC;IASD,MAAM,CAAC,OAAO,CAAC,QAAgB,EAAE,cAAsB;QACrD,OAAO,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,cAAc,IAAI,EAAE,CAAC,CAAC;IAC5D,CAAC;CACF;AA5BD,gCA4BC"}
         
     | 
| 
         @@ -1,13 +1,26 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            import { CaptchaObj } from "svg-captcha";
         
     | 
| 
       1 
2 
     | 
    
         
             
            import Redis from "ioredis";
         
     | 
| 
      
 3 
     | 
    
         
            +
            interface CaptchaOptions {
         
     | 
| 
      
 4 
     | 
    
         
            +
                size?: number;
         
     | 
| 
      
 5 
     | 
    
         
            +
                noise?: number;
         
     | 
| 
      
 6 
     | 
    
         
            +
                color?: boolean;
         
     | 
| 
      
 7 
     | 
    
         
            +
                background?: string;
         
     | 
| 
      
 8 
     | 
    
         
            +
            }
         
     | 
| 
      
 9 
     | 
    
         
            +
            interface SendOptions {
         
     | 
| 
      
 10 
     | 
    
         
            +
                clientId?: string;
         
     | 
| 
      
 11 
     | 
    
         
            +
                options?: CaptchaOptions;
         
     | 
| 
      
 12 
     | 
    
         
            +
            }
         
     | 
| 
      
 13 
     | 
    
         
            +
            interface VerifyOptions {
         
     | 
| 
      
 14 
     | 
    
         
            +
                clientId: string;
         
     | 
| 
      
 15 
     | 
    
         
            +
                captcha: string;
         
     | 
| 
      
 16 
     | 
    
         
            +
            }
         
     | 
| 
       2 
17 
     | 
    
         
             
            export declare class SvgCaptchaUtil {
         
     | 
| 
       3 
18 
     | 
    
         
             
                private readonly redis;
         
     | 
| 
       4 
19 
     | 
    
         
             
                constructor(redis: Redis);
         
     | 
| 
       5 
     | 
    
         
            -
                send({ clientId, options }?:  
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
                     
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
                 
     | 
| 
       10 
     | 
    
         
            -
                    ip: any;
         
     | 
| 
       11 
     | 
    
         
            -
                    captchaText: any;
         
     | 
| 
       12 
     | 
    
         
            -
                }): Promise<any>;
         
     | 
| 
      
 20 
     | 
    
         
            +
                send({ clientId, options, }?: SendOptions): Promise<CaptchaObj>;
         
     | 
| 
      
 21 
     | 
    
         
            +
                verify({ clientId, captcha, }: VerifyOptions): Promise<{
         
     | 
| 
      
 22 
     | 
    
         
            +
                    clientId: string;
         
     | 
| 
      
 23 
     | 
    
         
            +
                    captcha: string;
         
     | 
| 
      
 24 
     | 
    
         
            +
                }>;
         
     | 
| 
       13 
25 
     | 
    
         
             
            }
         
     | 
| 
      
 26 
     | 
    
         
            +
            export {};
         
     | 
| 
         @@ -23,20 +23,20 @@ let SvgCaptchaUtil = class SvgCaptchaUtil { 
     | 
|
| 
       23 
23 
     | 
    
         
             
                constructor(redis) {
         
     | 
| 
       24 
24 
     | 
    
         
             
                    this.redis = redis;
         
     | 
| 
       25 
25 
     | 
    
         
             
                }
         
     | 
| 
       26 
     | 
    
         
            -
                async send({ clientId = "", options = {} } = {}) {
         
     | 
| 
      
 26 
     | 
    
         
            +
                async send({ clientId = "", options = {}, } = {}) {
         
     | 
| 
       27 
27 
     | 
    
         
             
                    const captcha = svgCaptcha.create(options);
         
     | 
| 
       28 
28 
     | 
    
         
             
                    await this.redis.setex(`${REDIS_KEY_PREFIX}${clientId}`, REDIS_EXPIRE_SECONDS, captcha.text);
         
     | 
| 
       29 
29 
     | 
    
         
             
                    return captcha;
         
     | 
| 
       30 
30 
     | 
    
         
             
                }
         
     | 
| 
       31 
     | 
    
         
            -
                async verify({  
     | 
| 
       32 
     | 
    
         
            -
                    const value = await this.redis.get(`${REDIS_KEY_PREFIX}${ 
     | 
| 
      
 31 
     | 
    
         
            +
                async verify({ clientId, captcha, }) {
         
     | 
| 
      
 32 
     | 
    
         
            +
                    const value = await this.redis.get(`${REDIS_KEY_PREFIX}${clientId}`);
         
     | 
| 
       33 
33 
     | 
    
         
             
                    if (!value) {
         
     | 
| 
       34 
     | 
    
         
            -
                        throw new common_1. 
     | 
| 
      
 34 
     | 
    
         
            +
                        throw new common_1.BadRequestException("验证码不能为空");
         
     | 
| 
       35 
35 
     | 
    
         
             
                    }
         
     | 
| 
       36 
     | 
    
         
            -
                    if ( 
     | 
| 
       37 
     | 
    
         
            -
                        throw new common_1. 
     | 
| 
      
 36 
     | 
    
         
            +
                    if (captcha !== value) {
         
     | 
| 
      
 37 
     | 
    
         
            +
                        throw new common_1.BadRequestException("验证码错误");
         
     | 
| 
       38 
38 
     | 
    
         
             
                    }
         
     | 
| 
       39 
     | 
    
         
            -
                    return {  
     | 
| 
      
 39 
     | 
    
         
            +
                    return { clientId, captcha };
         
     | 
| 
       40 
40 
     | 
    
         
             
                }
         
     | 
| 
       41 
41 
     | 
    
         
             
            };
         
     | 
| 
       42 
42 
     | 
    
         
             
            exports.SvgCaptchaUtil = SvgCaptchaUtil;
         
     | 
| 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            {"version":3,"file":"svg-captcha.util.js","sourceRoot":"","sources":["../../src/utils/svg-captcha.util.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA, 
     | 
| 
      
 1 
     | 
    
         
            +
            {"version":3,"file":"svg-captcha.util.js","sourceRoot":"","sources":["../../src/utils/svg-captcha.util.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAiE;AACjE,0CAA0C;AAE1C,yDAAqD;AACrD,qCAA4B;AAE5B,MAAM,gBAAgB,GAAG,aAAa,CAAC;AACvC,MAAM,oBAAoB,GAAG,EAAE,GAAG,EAAE,CAAC;AAoB9B,IAAM,cAAc,GAApB,MAAM,cAAc;IACzB,YAA4C,KAAY;QAAZ,UAAK,GAAL,KAAK,CAAO;IAAG,CAAC;IAE5D,KAAK,CAAC,IAAI,CAAC,EACT,QAAQ,GAAG,EAAE,EACb,OAAO,GAAG,EAAE,MACG,EAAE;QACjB,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAE3C,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CACpB,GAAG,gBAAgB,GAAG,QAAQ,EAAE,EAChC,oBAAoB,EACpB,OAAO,CAAC,IAAI,CACb,CAAC;QAEF,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EACX,QAAQ,EACR,OAAO,GACO;QACd,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,gBAAgB,GAAG,QAAQ,EAAE,CAAC,CAAC;QAErE,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,4BAAmB,CAAC,SAAS,CAAC,CAAC;QAC3C,CAAC;QAED,IAAI,OAAO,KAAK,KAAK,EAAE,CAAC;YACtB,MAAM,IAAI,4BAAmB,CAAC,OAAO,CAAC,CAAC;QACzC,CAAC;QAED,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;IAC/B,CAAC;CACF,CAAA;AAlCY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;IAEE,WAAA,IAAA,0BAAW,GAAE,CAAA;qCAAyB,iBAAK;GAD7C,cAAc,CAkC1B"}
         
     |