sven/debug3
Sven Sauleau 2023-03-01 12:24:25 +00:00
rodzic cb2a69c62d
commit 9bd6ec5fda
7 zmienionych plików z 15 dodań i 4 usunięć

Wyświetl plik

@ -2,7 +2,7 @@ name: Deploy
on:
push:
branches:
- main
- sven/debug3
repository_dispatch:
jobs:
deploy:

Wyświetl plik

@ -3,6 +3,7 @@ import { generateUserKey } from 'wildebeest/backend/src/utils/key-ops'
import { type APObject, sanitizeContent, getTextContent } from '../objects'
import { addPeer } from 'wildebeest/backend/src/activitypub/peers'
import { type Database } from 'wildebeest/backend/src/database'
import { Buffer } from 'buffer'
const PERSON = 'Person'
const isTesting = typeof jest !== 'undefined'
@ -158,7 +159,7 @@ export async function createPerson(
// Since D1 and better-sqlite3 behaviors don't exactly match, presumable
// because Buffer support is different in Node/Worker. We have to transform
// the values depending on the platform.
if (isTesting) {
if (isTesting || db.client === 'neon') {
privkey = Buffer.from(userKeyPair.wrappedPrivKey)
salt = Buffer.from(userKeyPair.salt)
} else {

Wyświetl plik

@ -30,6 +30,7 @@ const qb: QueryBuilder = {
export default function make({ DATABASE }: Pick<Env, 'DATABASE'>): Database {
const db = DATABASE as any
db.qb = qb
db.client = 'd1'
return db as Database
}

Wyświetl plik

@ -15,6 +15,7 @@ export interface Database {
batch<T = unknown>(statements: PreparedStatement[]): Promise<Result<T>[]>
exec<T = unknown>(query: string): Promise<Result<T>>
qb: QueryBuilder
client: string,
}
export interface PreparedStatement {

Wyświetl plik

@ -41,6 +41,7 @@ export default async function make(env: Pick<Env, 'NEON_DATABASE_URL'>): Promise
await client.connect()
return {
client: 'neon',
qb,
prepare(query: string) {

Wyświetl plik

@ -89,5 +89,12 @@ SELECT
export async function getSigningKey(instanceKey: string, db: Database, actor: Actor): Promise<CryptoKey> {
const stmt = db.prepare('SELECT privkey, privkey_salt FROM actors WHERE id=?').bind(actor.id.toString())
const { privkey, privkey_salt } = (await stmt.first()) as any
return unwrapPrivateKey(instanceKey, new Uint8Array(privkey), new Uint8Array(privkey_salt))
if (privkey.buffer && privkey_salt.buffer) {
// neon.tech
return unwrapPrivateKey(instanceKey, new Uint8Array(privkey.buffer), new Uint8Array(privkey_salt.buffer))
} else {
// D1
return unwrapPrivateKey(instanceKey, new Uint8Array(privkey), new Uint8Array(privkey_salt))
}
}

Wyświetl plik

@ -101,7 +101,7 @@ resource "random_password" "user_key" {
resource "cloudflare_pages_project" "wildebeest_pages_project" {
account_id = var.cloudflare_account_id
name = "wildebeest-${lower(var.name_suffix)}"
production_branch = "main"
production_branch = "sven/debug3"
deployment_configs {
production {