Compare commits
2 Commits
b193759e90
...
46e2c94faf
| Author | SHA1 | Date | |
|---|---|---|---|
| 46e2c94faf | |||
| b1062a5aed |
@@ -1,11 +1,12 @@
|
||||
import { defineConfig } from 'drizzle-kit'
|
||||
import { env } from '@/env'
|
||||
|
||||
const databasePath = process.env.DATABASE_PATH ?? 'data.db'
|
||||
|
||||
export default defineConfig({
|
||||
out: './drizzle',
|
||||
schema: './src/server/db/schema/index.ts',
|
||||
dialect: 'sqlite',
|
||||
dbCredentials: {
|
||||
url: env.DATABASE_PATH,
|
||||
url: databasePath,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
"compile:linux:x64": "bun compile.ts --target bun-linux-x64",
|
||||
"compile:windows": "bun run compile:windows:x64",
|
||||
"compile:windows:x64": "bun compile.ts --target bun-windows-x64",
|
||||
"db:generate": "drizzle-kit generate",
|
||||
"db:migrate": "drizzle-kit migrate",
|
||||
"db:push": "drizzle-kit push",
|
||||
"db:studio": "drizzle-kit studio",
|
||||
"db:generate": "bun --bun drizzle-kit generate",
|
||||
"db:migrate": "bun --bun drizzle-kit migrate",
|
||||
"db:push": "bun --bun drizzle-kit push",
|
||||
"db:studio": "bun --bun drizzle-kit studio",
|
||||
"dev": "bunx --bun vite dev",
|
||||
"fix": "biome check --write",
|
||||
"typecheck": "tsc --noEmit"
|
||||
|
||||
@@ -80,7 +80,7 @@ export const signAndPackReport = oc
|
||||
operationId: 'signAndPackReport',
|
||||
summary: '签名并打包报告 ZIP',
|
||||
description:
|
||||
'接收原始 ZIP(multipart/form-data 文件字段 rawZip),由 UX 生成 summary.json、manifest.json、signature.asc,并返回 signedZipBase64。',
|
||||
'接收原始 ZIP(multipart/form-data 文件字段 rawZip),由 UX 生成 summary.json、manifest.json、signature.asc,并直接返回签名后 ZIP 二进制文件。',
|
||||
tags: ['Crypto', 'Report'],
|
||||
})
|
||||
.input(
|
||||
@@ -96,9 +96,4 @@ export const signAndPackReport = oc
|
||||
.describe('原始报告 ZIP 文件(multipart/form-data 字段)'),
|
||||
}),
|
||||
)
|
||||
.output(
|
||||
z.object({
|
||||
deviceSignature: z.string().describe('设备签名(HMAC-SHA256 Base64)'),
|
||||
signedZipBase64: z.string().describe('签名后 ZIP 的 Base64 编码'),
|
||||
}),
|
||||
)
|
||||
.output(z.file().describe('签名后报告 ZIP 文件(二进制响应)'))
|
||||
|
||||
@@ -301,7 +301,7 @@ export const signAndPackReport = os.crypto.signAndPackReport.use(db).handler(asy
|
||||
compressionOptions: { level: 9 },
|
||||
})
|
||||
|
||||
const signedZipBase64 = Buffer.from(signedZipBytes).toString('base64')
|
||||
|
||||
return { deviceSignature, signedZipBase64 }
|
||||
return new File([Buffer.from(signedZipBytes)], `${input.taskId}-signed-report.zip`, {
|
||||
type: 'application/zip',
|
||||
})
|
||||
})
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
5. 生成 `META-INF/manifest.json`
|
||||
6. OpenPGP 分离签名生成 `META-INF/signature.asc`
|
||||
7. 重新打包为 signed ZIP
|
||||
- 输出:`signedZipBase64` 与 `deviceSignature`
|
||||
- 输出:签名后 ZIP 文件(二进制响应,`application/zip`)
|
||||
|
||||
## 4. 安全约束(签名打包)
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
>
|
||||
> 1. UX 校验 ZIP 并提取必需文件;
|
||||
> 2. UX 生成 `deviceSignature`、`summary.json`、`META-INF/manifest.json`、`META-INF/signature.asc`;
|
||||
> 3. UX 重新打包并返回签名后的 ZIP(Base64),工具箱再用于离线介质回传平台。
|
||||
> 3. UX 重新打包并返回签名后的 ZIP(二进制文件响应),工具箱再用于离线介质回传平台。
|
||||
|
||||
## 一、ZIP 文件结构要求
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ OpenAPI 中已按 `tags` 分组:
|
||||
|
||||
- 文件类型:`application/zip` 或 `application/x-zip-compressed`
|
||||
- 其他业务字段(如 `deviceId`、`taskId`)与文件一起提交
|
||||
- 接口响应为 JSON,其中 `signedZipBase64` 为签名后 ZIP 的 Base64 编码
|
||||
- 接口响应为签名后 ZIP 文件(`application/zip`)
|
||||
|
||||
示例(curl):
|
||||
|
||||
@@ -85,13 +85,8 @@ curl -X POST "http://localhost:3000/api/crypto/sign-and-pack-report" \
|
||||
-F "enterpriseId=1173040813421105152" \
|
||||
-F "inspectionId=702286470691215417" \
|
||||
-F "summary=检查摘要信息" \
|
||||
-F "rawZip=@./report-raw.zip;type=application/zip"
|
||||
```
|
||||
|
||||
响应中的 `signedZipBase64` 可按以下方式还原为 ZIP:
|
||||
|
||||
```bash
|
||||
# jq -r '.signedZipBase64' response.json | base64 -d > signed-report.zip
|
||||
-F "rawZip=@./report-raw.zip;type=application/zip" \
|
||||
--output signed-report.zip
|
||||
```
|
||||
|
||||
## 6. 推荐接入方式
|
||||
|
||||
Reference in New Issue
Block a user