Passed
Pull Request — master (#89)
by Mathieu
01:41
created

server/src/Infrastructure/Adapter/PasswordEncoderAdapter.ts   A

Complexity

Total Complexity 2
Complexity/F 1

Size

Lines of Code 15
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 11
mnd 0
bc 0
fnc 2
dl 0
loc 15
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A PasswordEncoderAdapter.compare 0 3 1
A PasswordEncoderAdapter.hash 0 2 1
1
import {Injectable} from '@nestjs/common';
2
import * as argon2 from 'argon2';
3
import {IPasswordEncoder} from 'src/Application/IPasswordEncoder';
4
5
@Injectable()
6
export class PasswordEncoderAdapter implements IPasswordEncoder {
7
  public hash(payload: string): Promise<string> {
8
    return argon2.hash(payload);
9
  }
10
11
  public compare(hash: string, payload: string): Promise<boolean> {
12
    return argon2.verify(hash, payload);
13
  }
14
}
15