diff --git a/packages/core/src/api.ts b/packages/core/src/api.ts index 4f1bb1a..5afe36e 100644 --- a/packages/core/src/api.ts +++ b/packages/core/src/api.ts @@ -1,29 +1,9 @@ import { z } from 'zod'; +import { vaultValueSchema } from './vault'; -export const createVaultRequestSchema = z.object({ - c: z.string().describe('encrypted content'), - h: z.string().describe('sha256 hash of the encryption key + optional password'), - b: z.boolean().default(true).describe('burn after reading'), - ttl: z.number().describe('time to live (TTL) in milliseconds'), - ips: z.string().default('').optional().describe('IP address or CIDR block restrictions'), - rc: z.number().optional().describe('maximum number of times the secret can be read'), - wh: z - .object({ - u: z.string().url().describe('url of the webhook'), - n: z.string().describe('name of the secret').optional(), - r: z.boolean().default(true).describe('should the webhook be called on read'), - fpk: z - .boolean() - .default(false) - .describe('should the webhook be called for failure to read based on password or key'), - fip: z - .boolean() - .default(false) - .describe('should the webhook be called for failure to read based on ip address'), - b: z.boolean().default(false).describe('should the webhook be called for secret burn'), - }) - .describe('webhook configuration') - .optional(), +export const createVaultRequestSchema = vaultValueSchema.omit({ + cd: true, + dt: true, }); export type CreateVaultRequest = z.infer; diff --git a/packages/core/src/vault.ts b/packages/core/src/vault.ts index fa86013..9d65e3c 100644 --- a/packages/core/src/vault.ts +++ b/packages/core/src/vault.ts @@ -1,4 +1,4 @@ -import z from 'zod'; +import { z } from 'zod'; export const vaultValueSchema = z.object({ c: z.string().describe('encrypted content'), diff --git a/packages/server/src/app.ts b/packages/server/src/app.ts index 7b480a3..6873db9 100644 --- a/packages/server/src/app.ts +++ b/packages/server/src/app.ts @@ -8,7 +8,7 @@ import { validatorCompiler, ZodTypeProvider, } from 'fastify-type-provider-zod'; -import z from 'zod'; +import { z } from 'zod'; import fastifySwagger from '@fastify/swagger'; import fastifySwaggerUI from '@fastify/swagger-ui'; import fastifyRateLimit from '@fastify/rate-limit';