feat: HSM support

This commit is contained in:
Daniel Hougaard
2024-11-11 21:45:05 +04:00
parent a807f0cf6c
commit 891a1ea2b9
26 changed files with 967 additions and 57 deletions
@@ -4,10 +4,12 @@ import { TableName } from "../schemas";
export async function up(knex: Knex): Promise<void> {
const hasEncryptionStrategy = await knex.schema.hasColumn(TableName.KmsServerRootConfig, "encryptionStrategy");
const hasExported = await knex.schema.hasColumn(TableName.KmsServerRootConfig, "exported");
const hasTimestampsCol = await knex.schema.hasColumn(TableName.KmsServerRootConfig, "createdAt");
await knex.schema.alterTable(TableName.KmsServerRootConfig, (t) => {
if (!hasEncryptionStrategy) t.string("encryptionStrategy").defaultTo("BASIC");
if (!hasExported) t.boolean("exported").defaultTo(false);
if (!hasTimestampsCol) t.timestamps(true, true, true);
});
}
@@ -15,9 +17,11 @@ export async function up(knex: Knex): Promise<void> {
export async function down(knex: Knex): Promise<void> {
const hasEncryptionStrategy = await knex.schema.hasColumn(TableName.KmsServerRootConfig, "encryptionStrategy");
const hasTimestampsCol = await knex.schema.hasColumn(TableName.KmsServerRootConfig, "createdAt");
const hasExported = await knex.schema.hasColumn(TableName.KmsServerRootConfig, "exported");
await knex.schema.alterTable(TableName.KmsServerRootConfig, (t) => {
if (hasEncryptionStrategy) t.dropColumn("encryptionStrategy");
if (hasTimestampsCol) t.dropTimestamps(true);
if (hasExported) t.dropColumn("exported");
});
}
@@ -13,6 +13,7 @@ export const KmsRootConfigSchema = z.object({
id: z.string().uuid(),
encryptedRootKey: zodBuffer,
encryptionStrategy: z.string(),
exported: z.boolean(),
createdAt: z.date(),
updatedAt: z.date()
});