mirror of
https://github.com/kmc7468/arkvault.git
synced 2026-11-04 08:10:28 +09:00
DB 접근 시 Executor를 명시적으로 전달하고 서비스에서 트랜잭션 경계를 관리하도록 인증 및 키 관련 코드를 개선하고 직렬화 실패 시 트랜잭션을 재시도하도록 변경
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5b8621e524
commit
73b2d29b2c
18 files changed
+564
-385
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { HskRepo, MekRepo, type Tx } from "#lib/server/db/index.ts";
|
||||
import { AppError } from "#lib/server/errors.ts";
|
||||
|
||||
const DEK_VERSION_TOLERANCE = 60 * 1000; // 1 minute
|
||||
@@ -8,3 +9,17 @@ export const ensureFreshDekVersion = (dekVersion: Date) => {
|
||||
throw new AppError("BAD_REQUEST", "Invalid DEK version");
|
||||
}
|
||||
};
|
||||
|
||||
// New data must be encrypted with the active keys, which are locked until the transaction ends
|
||||
|
||||
export const ensureActiveMekVersion = async (trx: Tx, userId: number, mekVersion: number) => {
|
||||
if ((await MekRepo.lockActiveMekVersion(trx, userId)) !== mekVersion) {
|
||||
throw new AppError("BAD_REQUEST", "Inactive MEK version");
|
||||
}
|
||||
};
|
||||
|
||||
export const ensureActiveHskVersion = async (trx: Tx, userId: number, hskVersion: number) => {
|
||||
if ((await HskRepo.lockActiveHskVersion(trx, userId)) !== hskVersion) {
|
||||
throw new AppError("BAD_REQUEST", "Inactive HSK version");
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user