From 2a8b0ae5482c30f3b2c41feff92c019943cb3abe Mon Sep 17 00:00:00 2001 From: "@nekomimi.pet" Date: Thu, 13 Nov 2025 08:00:28 -0500 Subject: [PATCH] fix cookie routing --- public/editor/tabs/CLITab.tsx | 92 +++++++++++++++++++++++++++++------ src/index.ts | 10 ++-- src/routes/auth.ts | 28 +++-------- src/routes/domain.ts | 10 +++- src/routes/site.ts | 10 +++- src/routes/user.ts | 12 +++-- src/routes/wisp.ts | 10 +++- 7 files changed, 122 insertions(+), 50 deletions(-) diff --git a/public/editor/tabs/CLITab.tsx b/public/editor/tabs/CLITab.tsx index 64ce462..66ad060 100644 --- a/public/editor/tabs/CLITab.tsx +++ b/public/editor/tabs/CLITab.tsx @@ -16,7 +16,7 @@ export function CLITab() {
Wisp CLI Tool - v0.1.0 + v0.2.0 Alpha
@@ -32,11 +32,20 @@ export function CLITab() {
-

Download CLI

+

Features

+
    +
  • Deploy: Push static sites directly from your terminal
  • +
  • Pull: Download sites from the PDS for development or backup
  • +
  • Serve: Run a local server with real-time firehose updates
  • +
+
+ +
+

Download v0.2.0

- SHA256: 637e325d9668ca745e01493d80dfc72447ef0a889b313e28913ca65c94c7aaae + SHA-1: a8c27ea41c5e2672bfecb3476ece1c801741d759
@@ -59,7 +68,7 @@ export function CLITab() {
- SHA256: 01561656b64826f95b39f13c65c97da8bcc63ecd9f4d7e4e369c8ba8c903c22a + SHA-1: fd7ee689c7600fc953179ea755b0357c8481a622
@@ -73,23 +82,38 @@ export function CLITab() {
- SHA256: 1ff485b9bcf89bc5721a862863c4843cf4530cbcd2489cf200cb24a44f7865a2 + SHA-1: 8bca6992559e19e1d29ab3d2fcc6d09b28e5a485 +
+
+
+ + Windows (x86_64) + + +
+ SHA-1: 90ea3987a06597fa6c42e1df9009e9758e92dd54
-

Basic Usage

+

Deploy a Site

+
+

Pull a Site from PDS

+

+ Download a site from the PDS to your local machine (uses OAuth authentication): +

+ +
+ +
+

Serve a Site Locally with Real-Time Updates

+

+ Run a local server that monitors the firehose for real-time updates (uses OAuth authentication): +

+ +
+

CI/CD with Tangled Spindle

@@ -147,7 +211,7 @@ steps: chmod +x wisp-cli # Deploy to Wisp - ./wisp-cli \\ + ./wisp-cli deploy \\ "$WISP_HANDLE" \\ --path "$SITE_PATH" \\ --site "$SITE_NAME" \\ @@ -210,7 +274,7 @@ steps: chmod +x wisp-cli # Deploy to Wisp - ./wisp-cli \\ + ./wisp-cli deploy \\ "$WISP_HANDLE" \\ --path "$SITE_PATH" \\ --site "$SITE_NAME" \\ diff --git a/src/index.ts b/src/index.ts index 1f6dce8..4ec5048 100644 --- a/src/index.ts +++ b/src/index.ts @@ -70,7 +70,7 @@ export const app = new Elysia({ }, cookie: { secrets: cookieSecret, - sign: true + sign: ['did'] } }) // Observability middleware @@ -105,10 +105,10 @@ export const app = new Elysia({ .onError(observabilityMiddleware('main-app').onError) .use(csrfProtection()) .use(authRoutes(client, cookieSecret)) - .use(wispRoutes(client)) - .use(domainRoutes(client)) - .use(userRoutes(client)) - .use(siteRoutes(client)) + .use(wispRoutes(client, cookieSecret)) + .use(domainRoutes(client, cookieSecret)) + .use(userRoutes(client, cookieSecret)) + .use(siteRoutes(client, cookieSecret)) .use(adminRoutes(cookieSecret)) .use( await staticPlugin({ diff --git a/src/routes/auth.ts b/src/routes/auth.ts index c4e9baf..ed605d5 100644 --- a/src/routes/auth.ts +++ b/src/routes/auth.ts @@ -5,7 +5,12 @@ import { syncSitesFromPDS } from '../lib/sync-sites' import { authenticateRequest } from '../lib/wisp-auth' import { logger } from '../lib/observability' -export const authRoutes = (client: NodeOAuthClient, cookieSecret: string) => new Elysia() +export const authRoutes = (client: NodeOAuthClient, cookieSecret: string) => new Elysia({ + cookie: { + secrets: cookieSecret, + sign: ['did'] + } + }) .post('/api/auth/signin', async (c) => { let handle = 'unknown' try { @@ -74,13 +79,6 @@ export const authRoutes = (client: NodeOAuthClient, cookieSecret: string) => new c.cookie.did.remove() return c.redirect('/?error=auth_failed') } - }, { - cookie: t.Cookie({ - did: t.Optional(t.String()) - }, { - secrets: cookieSecret, - sign: ['did'] - }) }) .post('/api/auth/logout', async (c) => { try { @@ -106,13 +104,6 @@ export const authRoutes = (client: NodeOAuthClient, cookieSecret: string) => new logger.error('[Auth] Logout error', err) return { error: 'Logout failed' } } - }, { - cookie: t.Cookie({ - did: t.Optional(t.String()) - }, { - secrets: cookieSecret, - sign: ['did'] - }) }) .get('/api/auth/status', async (c) => { try { @@ -132,11 +123,4 @@ export const authRoutes = (client: NodeOAuthClient, cookieSecret: string) => new c.cookie.did.remove() return { authenticated: false } } - }, { - cookie: t.Cookie({ - did: t.Optional(t.String()) - }, { - secrets: cookieSecret, - sign: ['did'] - }) }) diff --git a/src/routes/domain.ts b/src/routes/domain.ts index 8ce070c..2bd1ae2 100644 --- a/src/routes/domain.ts +++ b/src/routes/domain.ts @@ -24,8 +24,14 @@ import { createHash } from 'crypto' import { verifyCustomDomain } from '../lib/dns-verify' import { logger } from '../lib/logger' -export const domainRoutes = (client: NodeOAuthClient) => - new Elysia({ prefix: '/api/domain' }) +export const domainRoutes = (client: NodeOAuthClient, cookieSecret: string) => + new Elysia({ + prefix: '/api/domain', + cookie: { + secrets: cookieSecret, + sign: ['did'] + } + }) // Public endpoints (no auth required) .get('/check', async ({ query }) => { try { diff --git a/src/routes/site.ts b/src/routes/site.ts index 7fed391..98dd4c7 100644 --- a/src/routes/site.ts +++ b/src/routes/site.ts @@ -5,8 +5,14 @@ import { Agent } from '@atproto/api' import { deleteSite } from '../lib/db' import { logger } from '../lib/logger' -export const siteRoutes = (client: NodeOAuthClient) => - new Elysia({ prefix: '/api/site' }) +export const siteRoutes = (client: NodeOAuthClient, cookieSecret: string) => + new Elysia({ + prefix: '/api/site', + cookie: { + secrets: cookieSecret, + sign: ['did'] + } + }) .derive(async ({ cookie }) => { const auth = await requireAuth(client, cookie) return { auth } diff --git a/src/routes/user.ts b/src/routes/user.ts index 37e2d2f..4ba63e6 100644 --- a/src/routes/user.ts +++ b/src/routes/user.ts @@ -1,4 +1,4 @@ -import { Elysia } from 'elysia' +import { Elysia, t } from 'elysia' import { requireAuth } from '../lib/wisp-auth' import { NodeOAuthClient } from '@atproto/oauth-client-node' import { Agent } from '@atproto/api' @@ -6,8 +6,14 @@ import { getSitesByDid, getDomainByDid, getCustomDomainsByDid, getWispDomainInfo import { syncSitesFromPDS } from '../lib/sync-sites' import { logger } from '../lib/logger' -export const userRoutes = (client: NodeOAuthClient) => - new Elysia({ prefix: '/api/user' }) +export const userRoutes = (client: NodeOAuthClient, cookieSecret: string) => + new Elysia({ + prefix: '/api/user', + cookie: { + secrets: cookieSecret, + sign: ['did'] + } + }) .derive(async ({ cookie }) => { const auth = await requireAuth(client, cookie) return { auth } diff --git a/src/routes/wisp.ts b/src/routes/wisp.ts index 39b51f1..1c47d0c 100644 --- a/src/routes/wisp.ts +++ b/src/routes/wisp.ts @@ -37,8 +37,14 @@ function isValidSiteName(siteName: string): boolean { return true; } -export const wispRoutes = (client: NodeOAuthClient) => - new Elysia({ prefix: '/wisp' }) +export const wispRoutes = (client: NodeOAuthClient, cookieSecret: string) => + new Elysia({ + prefix: '/wisp', + cookie: { + secrets: cookieSecret, + sign: ['did'] + } + }) .derive(async ({ cookie }) => { const auth = await requireAuth(client, cookie) return { auth } -- 2.54.0