Compare commits

..

2 Commits

3 changed files with 6 additions and 5 deletions

View File

@@ -55,7 +55,7 @@ export const signAndPackReport = oc
enterpriseId: z.string().min(1), enterpriseId: z.string().min(1),
inspectionId: z.string().min(1), inspectionId: z.string().min(1),
summary: z.string().min(1), summary: z.string().min(1),
rawZipBase64: z.string().min(1), rawZip: z.file().mime(['application/zip', 'application/x-zip-compressed']),
}), }),
) )
.output( .output(

View File

@@ -222,11 +222,12 @@ export const encryptSummary = os.crypto.encryptSummary.use(db).handler(async ({
export const signAndPackReport = os.crypto.signAndPackReport.use(db).handler(async ({ context, input }) => { export const signAndPackReport = os.crypto.signAndPackReport.use(db).handler(async ({ context, input }) => {
const device = await getDevice(context, input.deviceId) const device = await getDevice(context, input.deviceId)
const rawZipBytes = Buffer.from(input.rawZipBase64, 'base64') const rawZipArrayBuffer = await input.rawZip.arrayBuffer()
const rawZipBytes = Buffer.from(rawZipArrayBuffer)
if (rawZipBytes.byteLength === 0 || rawZipBytes.byteLength > MAX_RAW_ZIP_BYTES) { if (rawZipBytes.byteLength === 0 || rawZipBytes.byteLength > MAX_RAW_ZIP_BYTES) {
throw new ORPCError('BAD_REQUEST', { throw new ORPCError('BAD_REQUEST', {
message: 'rawZipBase64 is empty or exceeds max size limit', message: 'rawZip is empty or exceeds max size limit',
}) })
} }
@@ -234,7 +235,7 @@ export const signAndPackReport = os.crypto.signAndPackReport.use(db).handler(asy
checkCRC32: true, checkCRC32: true,
}).catch(() => { }).catch(() => {
throw new ORPCError('BAD_REQUEST', { throw new ORPCError('BAD_REQUEST', {
message: 'rawZipBase64 is not a valid zip file', message: 'rawZip is not a valid zip file',
}) })
}) })

View File

@@ -49,7 +49,7 @@
`crypto.signAndPackReport` `crypto.signAndPackReport`
- 输入:`rawZipBase64` + `taskId` + `inspectionId` + `enterpriseId` + `summary` - 输入:`rawZip``multipart/form-data` 文件字段) + `taskId` + `inspectionId` + `enterpriseId` + `summary`
- UX 在服务端完成: - UX 在服务端完成:
1. 校验并解包原始 ZIP 1. 校验并解包原始 ZIP
2. 计算文件 SHA-256 2. 计算文件 SHA-256