import * as bcrypt from "https://deno.land/x/bcrypt@v0.4.1/mod.ts"; export interface Crypto { hash(value: string): Promise; compare(value: string, hash: string): Promise; } export class BcryptCrypto implements Crypto { public hash(value: string): Promise { return bcrypt.hash(value); } public compare(value: string, hash: string): Promise { return bcrypt.compare(value, hash); } } export class MockCrypto implements Crypto { // deno-lint-ignore require-await public async hash(value: string): Promise { return bcrypt.hashSync(value, bcrypt.genSaltSync(4)); } // deno-lint-ignore require-await public async compare(value: string, hash: string): Promise { return bcrypt.compareSync(value, hash); } }