Skip to content

Commit

Permalink
replace bcrypt with bcrypt.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Prakharnagore committed Jul 21, 2024
1 parent 64a3bb2 commit 6bb98a4
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 393 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ DB_USERNAME=
DB_PASSWORD=
DB_NAME=
REFRESH_TOKEN_SECRET=
JWKS_URI=
JWKS_URI=
PRIVATE_KEY=
414 changes: 29 additions & 385 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
"main": "index.js",
"scripts": {
"dev": "cross-env NODE_ENV=dev nodemon src/server.ts",
"build":"tsc",
"build": "tsc",
"format:check": "prettier . --check",
"format:fix": "prettier . --write",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"prepare": "husky",
"test": "jest --no-cache --coverage --all --runInBand",
"test:watch":"jest --watch --runInBand",
"test:watch": "jest --watch --runInBand",
"start": "ts-node src/index.ts",
"migration:generate": "typeorm-ts-node-commonjs migration:generate",
"migration:run": "typeorm-ts-node-commonjs migration:run",
Expand All @@ -22,6 +22,7 @@
"license": "ISC",
"devDependencies": {
"@types/bcrypt": "^5.0.1",
"@types/bcryptjs": "^2.4.6",
"@types/cookie-parser": "^1.4.7",
"@types/express": "^4.17.21",
"@types/express-validator": "^3.0.0",
Expand Down Expand Up @@ -54,7 +55,7 @@
]
},
"dependencies": {
"bcrypt": "^5.1.1",
"bcryptjs": "^2.4.3",
"cookie-parser": "^1.4.6",
"dotenv": "^16.4.5",
"express": "^4.19.1",
Expand Down
2 changes: 1 addition & 1 deletion src/services/CredentialService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import bcrypt from "bcrypt";
import bcrypt from "bcryptjs";

export class CrendentialService {
async comparePasword(userPasword: string, passwordHash: string) {
Expand Down
2 changes: 1 addition & 1 deletion src/services/UserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Repository } from "typeorm";
import { User } from "../entity/User";
import { LimitedUserData, UserData } from "../types";
import createHttpError from "http-errors";
import bcrypt from "bcrypt";
import bcrypt from "bcryptjs";

export class UserService {
constructor(private userRepository: Repository<User>) {}
Expand Down
2 changes: 1 addition & 1 deletion tests/users/login.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import app from "../../src/app";
import { Roles } from "../../src/constants";
import { User } from "../../src/entity/User";
import { isJwt } from "../utils";
import bcrypt from "bcrypt";
import bcrypt from "bcryptjs";
import request from "supertest";

describe("POST /auth/login", () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/users/register.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ describe("POST /auth/register", () => {
const users = await userRepository.find({ select: ["password"] });
expect(users[0].password).not.toBe(userData.password);
expect(users[0].password).toHaveLength(60);
expect(users[0].password).toMatch(/^\$2b\$\d+\$/);
expect(users[0].password).toMatch(/^\$2[a|b]\$\d+\$/);
});
it("should return 400 status code if email is already exists", async () => {
// Arrange
Expand Down

0 comments on commit 6bb98a4

Please sign in to comment.