Signature signing

This commit is contained in:
Lncvrt committed 2026-02-28 11:48:00 -07:00
1 parent 5b40359cb8
commit ca2ba26f21
2 files changed
+15 -3

No files matched your search

+1
View File
@@ -9,3 +9,4 @@ BERRYDASH_DB_USER=
BERRYDASH_DB_PASS=
BERRYDASH_DB_NAME=
TURNSTILE_SECRET_KEY=
SIGNING_PRIVATE_KEY=
+14 -3
View File
@@ -10,14 +10,25 @@ import { Context } from 'elysia'
import axios from 'axios'
import FormData from 'form-data'
import nodemailer from 'nodemailer'
import { createHash } from 'crypto'
import { createHash, createSign } from 'crypto'
import { and, eq, sql } from 'drizzle-orm'
import { verifyCodes } from './tables'
const privateKey = `-----BEGIN PRIVATE KEY-----\n${process.env.PRIVATE_SIGNING_KEY}\n-----END PRIVATE KEY-----`
export const jsonResponse = (data: any, status = 200) => {
return new Response(JSON.stringify(data), {
const body = JSON.stringify(data)
const signer = createSign('SHA256')
signer.update(body)
const signature = signer.sign(privateKey, 'base64')
return new Response(body, {
status,
headers: { 'Content-Type': 'application/json' }
headers: {
'Content-Type': 'application/json',
'X-Signature': signature
}
})
}