1.0.4 • Published 2 years ago
@friends-of-software/nest-pwned-password v1.0.4
Description
@friends-of-software/nest-pwned-password
package for Nest,
useful to check if a password has been pwned before. The service calls the
haveibeenpwned API in order to see if the password was leaked.
Installation
$ npm i --save @friends-of-software/nest-pwned-password
Example
After you import the PwnedPasswordModule
in your module, you can use the PwnedPasswordService
.
import { Controller, Get } from '@nestjs/common';
import { PwnedPasswordService } from '@friends-of-software/nest-pwned-password';
@Controller()
export class AppController {
constructor(
private pwnedPasswordService: PwnedPasswordService,
) {}
@Post('has-been-pwned')
async hasBeenPwned(@Body() hasBeenPwnedDto: HasBeenPwnedDto): Promise<{ pwned: boolean; timesPwned: number }> {
return this.pwnedPasswordService.hasPasswordBeenPwned(hasBeenPwnedDto.password);
}
}