This commit is contained in:
Lncvrt committed 2026-02-28 12:25:11 -07:00
1 parent a186243b26
commit 9600a8ea6b
4 files changed
+40 -11

No files matched your search

+7 -4
View File
@@ -14,21 +14,24 @@ import { createHash, createPrivateKey, sign } from 'crypto'
import { and, eq, sql } from 'drizzle-orm'
import { verifyCodes } from './tables'
export const jsonResponse = (data: any, status = 200) => {
const body = JSON.stringify(data)
export const generateSignature = (body: string) => {
const key = Buffer.from(
process.env.PRIVATE_SIGNING_KEY ?? '',
'base64'
).toString('utf-8')
const privateKey = createPrivateKey(key)
const signature = sign(null, Buffer.from(body), privateKey).toString('base64')
return signature
}
export const jsonResponse = (data: any, status = 200) => {
const body = JSON.stringify(data)
return new Response(body, {
status,
headers: {
'Content-Type': 'application/json',
'X-Signature': signature
'X-Signature': generateSignature(body)
}
})
}
+11 -3
View File
@@ -1,4 +1,8 @@
import { getDatabaseConnection, jsonResponse } from '../../../lib/util'
import {
generateSignature,
getDatabaseConnection,
jsonResponse
} from '../../../lib/util'
import { berryDashSplashTexts } from '../../../lib/tables'
import { eq } from 'drizzle-orm'
import { Context } from 'elysia'
@@ -40,9 +44,13 @@ export const handler = async (context: Context) => {
})
.map(i => atob(i.content))
return new Response(data.join('\n'), {
const body = data.join('\n')
return new Response(body, {
status: 200,
headers: { 'Content-Type': 'text/plain' }
headers: {
'Content-Type': 'text/plain',
'X-Signature': generateSignature(body)
}
})
} else {
return jsonResponse(
+11 -2
View File
@@ -1,6 +1,10 @@
import { launcherUpdates } from '../../../lib/tables'
import { desc, eq } from 'drizzle-orm'
import { getDatabaseConnection, jsonResponse } from '../../../lib/util'
import {
generateSignature,
getDatabaseConnection,
jsonResponse
} from '../../../lib/util'
export const handler = async () => {
const dbResult = getDatabaseConnection(0)
@@ -19,5 +23,10 @@ export const handler = async () => {
connection.end()
return version[0].id
return new Response(version[0].id, {
headers: {
'Content-Type': 'application/json',
'X-Signature': generateSignature(version[0].id)
}
})
}
+11 -2
View File
@@ -1,6 +1,10 @@
import { loaderUpdates } from '../../../../lib/tables'
import { desc, eq } from 'drizzle-orm'
import { getDatabaseConnection, jsonResponse } from '../../../../lib/util'
import {
generateSignature,
getDatabaseConnection,
jsonResponse
} from '../../../../lib/util'
export const handler = async () => {
const dbResult = getDatabaseConnection(0)
@@ -19,5 +23,10 @@ export const handler = async () => {
connection.end()
return version[0].id
return new Response(version[0].id, {
headers: {
'Content-Type': 'application/json',
'X-Signature': generateSignature(version[0].id)
}
})
}