generate secret and validate iv position is number
This commit is contained in:
parent
bc2be3302a
commit
3d73f9fa95
4 changed files with 29 additions and 3 deletions
|
|
@ -13,6 +13,7 @@
|
|||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||
"format": "prettier --write .",
|
||||
"generate-secret": "bun ./scripts/generate-secret.ts",
|
||||
"lint": "prettier --check . && eslint .",
|
||||
"test:unit": "vitest",
|
||||
"test": "bun run test:unit -- --run && bun run test:e2e",
|
||||
|
|
@ -44,7 +45,7 @@
|
|||
"@sveltejs/adapter-auto": "^3.0.0",
|
||||
"@sveltejs/kit": "^2.15.3",
|
||||
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
||||
"@types/bun": "^1.1.14",
|
||||
"@types/bun": "^1.1.15",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"daisyui": "^4.12.22",
|
||||
"eslint": "^9.7.0",
|
||||
|
|
|
|||
6
scripts/generate-secret.ts
Normal file
6
scripts/generate-secret.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import { randomBytes } from 'node:crypto';
|
||||
|
||||
console.log('SECRET: ', {
|
||||
password: randomBytes(16).toString('hex'),
|
||||
salt: randomBytes(16).toString('hex'),
|
||||
});
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import { PhoneRegex } from '../src/lib/regex/phone';
|
||||
import { z } from 'zod';
|
||||
import { PhoneRegex } from '../src/lib/regex/phone';
|
||||
|
||||
const ValidateEnvironment = () => {
|
||||
const { success, error } = z
|
||||
|
|
@ -9,7 +9,22 @@ const ValidateEnvironment = () => {
|
|||
TWILIO_PHONE_NUMBER: z.string().regex(PhoneRegex),
|
||||
SECRETS_PASSWORD: z.string().length(32),
|
||||
SECRETS_SALT: z.string().min(16),
|
||||
SECRETS_IV_POSITION: z.number().positive(),
|
||||
SECRETS_IV_POSITION: z.string().transform((val, ctx) => {
|
||||
const parsed = parseInt(val);
|
||||
if (isNaN(parsed)) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: 'Not a number',
|
||||
});
|
||||
|
||||
// This is a special symbol you can use to
|
||||
// return early from the transform function.
|
||||
// It has type `never` so it does not affect the
|
||||
// inferred return type.
|
||||
return z.NEVER;
|
||||
}
|
||||
return parsed;
|
||||
}),
|
||||
})
|
||||
.safeParse(process.env);
|
||||
|
||||
|
|
|
|||
4
src/routes/app/settings/+page.svelte
Normal file
4
src/routes/app/settings/+page.svelte
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<script lang="ts">
|
||||
</script>
|
||||
|
||||
<div class="container"></div>
|
||||
Loading…
Add table
Reference in a new issue