diff --git a/package.json b/package.json index 4c74045..ff17119 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ }, "dependencies": { "@libsql/client": "^0.15.5", + "bcrypt": "^6.0.0", "dotenv": "^16.5.0", "dotenv-expand": "^12.0.2", "drizzle-orm": "^0.43.1", @@ -25,6 +26,7 @@ "devDependencies": { "@antfu/eslint-config": "^4.13.0", "@faker-js/faker": "^9.8.0", + "@types/bcrypt": "^5.0.2", "@types/express": "^5.0.1", "@types/node": "^22.15.17", "drizzle-kit": "^0.31.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6c65a6d..29862a0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,9 @@ importers: '@libsql/client': specifier: ^0.15.5 version: 0.15.5 + bcrypt: + specifier: ^6.0.0 + version: 6.0.0 dotenv: specifier: ^16.5.0 version: 16.5.0 @@ -33,6 +36,9 @@ importers: '@faker-js/faker': specifier: ^9.8.0 version: 9.8.0 + '@types/bcrypt': + specifier: ^5.0.2 + version: 5.0.2 '@types/express': specifier: ^5.0.1 version: 5.0.1 @@ -636,6 +642,9 @@ packages: '@tybys/wasm-util@0.9.0': resolution: {integrity: sha512-6+7nlbMVX/PVDCwaIQ8nTOPveOcFLSt8GcXdx8hD0bt39uWxYT88uXzqTd4fTvqta7oeUJqudepapKNt2DYJFw==} + '@types/bcrypt@5.0.2': + resolution: {integrity: sha512-6atioO8Y75fNcbmj0G7UjI9lXN2pQ/IGJ2FWT4a/btd0Lk9lQalHLKhkgKVZ3r+spnmWUKfbMi1GEe9wyHQfNQ==} + '@types/body-parser@1.19.5': resolution: {integrity: sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg==} @@ -888,6 +897,10 @@ packages: balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} + bcrypt@6.0.0: + resolution: {integrity: sha512-cU8v/EGSrnH+HnxV2z0J7/blxH8gq7Xh2JFT6Aroax7UohdmiJJlxApMxtKfuI7z68NvvVcmR78k2LbT6efhRg==} + engines: {node: '>= 18'} + body-parser@2.2.0: resolution: {integrity: sha512-02qvAaxv8tp7fBa/mw1ga98OGm+eCbqzJOKoRt70sLmfEEi+jyBYVTDGfCL/k06/4EMk/z01gCe7HoCH/f2LTg==} engines: {node: '>=18'} @@ -1908,6 +1921,10 @@ packages: resolution: {integrity: sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==} engines: {node: '>= 0.6'} + node-addon-api@8.3.1: + resolution: {integrity: sha512-lytcDEdxKjGJPTLEfW4mYMigRezMlyJY8W4wxJK8zE533Jlb8L8dRuObJFWg2P+AuOIxoCgKF+2Oq4d4Zd0OUA==} + engines: {node: ^18 || ^20 || >= 21} + node-domexception@1.0.0: resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==} engines: {node: '>=10.5.0'} @@ -1917,6 +1934,10 @@ packages: resolution: {integrity: sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + node-gyp-build@4.8.4: + resolution: {integrity: sha512-LA4ZjwlnUblHVgq0oBF3Jl/6h/Nvs5fzBLwdEF4nuxnFdsfajde4WfxtJr3CaiH+F6ewcIB/q4jQ4UzPyid+CQ==} + hasBin: true + node-releases@2.0.19: resolution: {integrity: sha512-xxOWJsBKtzAq7DY0J+DTzuz58K8e7sJbdgwkbMWQe8UYB6ekmsQ45q0M/tJDsGaZmbC+l7n57UV8Hl5tHxO9uw==} @@ -2839,6 +2860,10 @@ snapshots: tslib: 2.8.1 optional: true + '@types/bcrypt@5.0.2': + dependencies: + '@types/node': 22.15.17 + '@types/body-parser@1.19.5': dependencies: '@types/connect': 3.4.38 @@ -3108,6 +3133,11 @@ snapshots: balanced-match@1.0.2: {} + bcrypt@6.0.0: + dependencies: + node-addon-api: 8.3.1 + node-gyp-build: 4.8.4 + body-parser@2.2.0: dependencies: bytes: 3.1.2 @@ -4329,6 +4359,8 @@ snapshots: negotiator@1.0.0: {} + node-addon-api@8.3.1: {} + node-domexception@1.0.0: {} node-fetch@3.3.2: @@ -4337,6 +4369,8 @@ snapshots: fetch-blob: 3.2.0 formdata-polyfill: 4.0.10 + node-gyp-build@4.8.4: {} + node-releases@2.0.19: {} nth-check@2.1.1: diff --git a/src/db/seed.ts b/src/db/seed.ts index 39e0227..7a4fe6d 100644 --- a/src/db/seed.ts +++ b/src/db/seed.ts @@ -1,8 +1,8 @@ import { db } from "./config"; import { InsertPermission, InsertRole, InsertUser, RolePermissionInsert, UserRoleInsert } from "./domain"; import { permissionsTable, rolesPermissionsTable, rolesTable, usersRolesTable, usersTable } from "./schema"; -import { createHash } from "node:crypto" import { faker } from '@faker-js/faker'; +import bcrypt from "bcrypt"; const permissions: InsertPermission[] = [ {name: "READ"}, @@ -29,13 +29,13 @@ const rolePermission: RolePermissionInsert[] = [ const users: InsertUser[] = faker.helpers.multiple(() => ({ name: faker.person.fullName(), - password: createHash('md5').update(faker.internet.password()).digest('hex'), + password: bcrypt.hashSync(faker.internet.password(), 10), email: faker.internet.email() }), {count: 10}) const exploitedUsers: InsertUser[] = faker.helpers.multiple(() => ({ name: faker.person.fullName(), - password: createHash('md5').update("P@ssword1").digest('hex'), + password: bcrypt.hashSync("P@ssword1", 10), email: faker.internet.email() }), { count: 5 })