@allbluecn/database 0.4.17 → 0.4.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ export declare function verifySharePassword(input: string, stored: string): Promise<boolean>;
2
+ export declare function verifyPrdOwner(prdId: string, userId: string): Promise<boolean>;
@@ -0,0 +1,17 @@
1
+ import bcrypt from "bcryptjs";
2
+ async function verifySharePassword(input, stored) {
3
+ if (input === stored) return true;
4
+ if (stored.startsWith("$2")) {
5
+ return bcrypt.compare(input, stored);
6
+ }
7
+ return false;
8
+ }
9
+ async function verifyPrdOwner(prdId, userId) {
10
+ const { prisma } = await import("@allbluecn/database");
11
+ const prd = await prisma.pRD.findUnique({ where: { id: prdId }, select: { userId: true } });
12
+ return prd?.userId === userId;
13
+ }
14
+ export {
15
+ verifyPrdOwner,
16
+ verifySharePassword
17
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allbluecn/database",
3
- "version": "0.4.17",
3
+ "version": "0.4.18",
4
4
  "license": "AGPL-3.0-or-later",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -19,6 +19,7 @@
19
19
  },
20
20
  "devDependencies": {
21
21
  "@types/better-sqlite3": "^7.6.13",
22
+ "esbuild": "^0.25.0",
22
23
  "prisma": "^7.8.0",
23
24
  "tsx": "^4.22.0",
24
25
  "vitest": "^4.1.10"
@@ -57,6 +58,7 @@
57
58
  "access": "public"
58
59
  },
59
60
  "scripts": {
61
+ "build": "node ./scripts/build-dist.mjs",
60
62
  "generate": "prisma generate",
61
63
  "migrate:dev": "prisma migrate dev",
62
64
  "migrate:deploy": "prisma migrate deploy",