@allbluecn/database 0.2.0

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.
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@allbluecn/database",
3
+ "version": "0.2.0",
4
+ "license": "AGPL-3.0-or-later",
5
+ "type": "module",
6
+ "main": "./index.ts",
7
+ "types": "./index.ts",
8
+ "scripts": {
9
+ "generate": "prisma generate",
10
+ "migrate:dev": "prisma migrate dev",
11
+ "migrate:deploy": "prisma migrate deploy",
12
+ "seed": "prisma db seed",
13
+ "test": "vitest",
14
+ "test:run": "vitest run"
15
+ },
16
+ "dependencies": {
17
+ "@allbluecn/shared": "workspace:*",
18
+ "@prisma/adapter-better-sqlite3": "^7.9.0",
19
+ "@prisma/adapter-pg": "7.8.0",
20
+ "@prisma/client": "7.8.0",
21
+ "@types/pg": "^8.20.0",
22
+ "better-sqlite3": "^13.0.1",
23
+ "dotenv": "^16.4.5",
24
+ "pg": "^8.22.0",
25
+ "sqlite-vec": "^0.1.9",
26
+ "bcryptjs": "^3.0.2"
27
+ },
28
+ "devDependencies": {
29
+ "@types/better-sqlite3": "^7.6.13",
30
+ "prisma": "^7.8.0",
31
+ "tsx": "^4.22.0",
32
+ "vitest": "^4.1.10"
33
+ },
34
+ "exports": {
35
+ ".": "./index.ts",
36
+ "./lib/share-utils": "./src/lib/share-utils.ts"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/urmynami/AllBlue.git"
41
+ },
42
+ "homepage": "https://github.com/urmynami/AllBlue#readme",
43
+ "bugs": {
44
+ "url": "https://github.com/urmynami/AllBlue/issues"
45
+ },
46
+ "files": [
47
+ "src",
48
+ "!src/**/*.test.*",
49
+ "!src/**/__tests__/**"
50
+ ]
51
+ }
@@ -0,0 +1,32 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ import bcrypt from "bcryptjs"
19
+
20
+ export async function verifySharePassword(input: string, stored: string): Promise<boolean> {
21
+ if (input === stored) return true
22
+ if (stored.startsWith('$2')) {
23
+ return bcrypt.compare(input, stored)
24
+ }
25
+ return false
26
+ }
27
+
28
+ export async function verifyPrdOwner(prdId: string, userId: string): Promise<boolean> {
29
+ const { prisma } = await import("@allbluecn/database")
30
+ const prd = await prisma.pRD.findUnique({ where: { id: prdId }, select: { userId: true } })
31
+ return prd?.userId === userId
32
+ }