Merge branch 'nip86' into 'main'

Draft: Relay management API

See merge request soapbox-pub/ditto!422
This commit is contained in:
Alex Gleason 2025-01-07 02:08:24 +00:00
commit 68f38ade2a
4 changed files with 12 additions and 9 deletions

View file

@ -184,7 +184,7 @@ app.use('/nodeinfo/*', metricsMiddleware, logger(debug));
app.use('/oauth/*', metricsMiddleware, logger(debug));
app.get('/api/v1/streaming', metricsMiddleware, streamingController);
app.get('/relay', metricsMiddleware, relayController);
app.all('/relay', metricsMiddleware, relayController);
app.use(
'*',

View file

@ -0,0 +1,5 @@
import { AppController } from '@/app.ts';
export const managementController: AppController = (c) => {
return c.json({ error: 'Not found' }, 404);
};

View file

@ -178,10 +178,13 @@ const relayController: AppController = (c, next) => {
const upgrade = c.req.header('upgrade');
// NIP-11: https://github.com/nostr-protocol/nips/blob/master/11.md
if (c.req.header('accept') === 'application/nostr+json') {
if (c.req.method === 'GET' && c.req.header('accept') === 'application/nostr+json') {
return relayInfoController(c, next);
}
// NIP-86: https://github.com/nostr-protocol/nips/pull/1325
if (c.req.header('content-type') === 'application/nostr+json+rpc') {}
if (upgrade?.toLowerCase() !== 'websocket') {
return c.text('Please use a Nostr client to connect.', 400);
}

View file

@ -2,16 +2,11 @@ import { HTTPException } from '@hono/hono/http-exception';
import { NostrEvent } from '@nostrify/nostrify';
import { type AppContext, type AppMiddleware } from '@/app.ts';
import { Conf } from '@/config.ts';
import { ReadOnlySigner } from '@/signers/ReadOnlySigner.ts';
import { Storages } from '@/storages.ts';
import { localRequest } from '@/utils/api.ts';
import {
buildAuthEventTemplate,
parseAuthRequest,
type ParseAuthRequestOpts,
validateAuthEvent,
} from '@/utils/nip98.ts';
import { Conf } from '@/config.ts';
import { buildAuthEventTemplate, parseAuthRequest, ParseAuthRequestOpts, validateAuthEvent } from '@/utils/nip98.ts';
/**
* NIP-98 auth.