Loading cli/import_map.g.json +1 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ "mock_fetch": "https://deno.land/x/mock_fetch@0.3.0/mod.ts", "uri-template-router": "npm:uri-template-router@^0.0.16", "url-template": "npm:url-template@^3.1.1", "@fedify/fedify/sig": ".././sig/mod.ts", "@cliffy/ansi": "jsr:@cliffy/ansi@1.0.0-rc.4", "@cliffy/command": "jsr:@cliffy/command@1.0.0-rc.4", "@cliffy/prompt": "jsr:@cliffy/prompt@1.0.0-rc.4", Loading federation/handler.ts +3 −2 Original line number Diff line number Diff line import { getLogger } from "@logtape/logtape"; import { accepts } from "@std/http/negotiation"; import { doesActorOwnKey, verify } from "../httpsig/mod.ts"; import { verifyRequest } from "../sig/http.ts"; import { doesActorOwnKey } from "../sig/owner.ts"; import type { DocumentLoader } from "../runtime/docloader.ts"; import type { Recipient } from "../vocab/actor.ts"; import { Loading Loading @@ -343,7 +344,7 @@ export async function handleInbox<TContextData>( return await onNotFound(request); } } const key = await verify(request, { const key = await verifyRequest(request, { ...context, timeWindow: signatureTimeWindow, }); Loading federation/middleware.test.ts +14 −14 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ import { } from "@std/assert"; import { dirname, join } from "@std/path"; import * as mf from "mock_fetch"; import { sign, verify } from "../httpsig/mod.ts"; import { signRequest, verifyRequest } from "../sig/http.ts"; import { FetchError, getAuthenticatedDocumentLoader, Loading @@ -34,7 +34,7 @@ Deno.test("Federation.createContext()", async (t) => { mf.install(); mf.mock("GET@/object", async (req) => { const v = await verify( const v = await verifyRequest( req, { contextLoader: mockDocumentLoader, Loading Loading @@ -267,7 +267,7 @@ Deno.test("Federation.createContext()", async (t) => { "No actor dispatcher registered", ); const signedReq = await sign( const signedReq = await signRequest( new Request("https://example.com/"), privateKey2, publicKey2.id!, Loading @@ -282,7 +282,7 @@ Deno.test("Federation.createContext()", async (t) => { assertEquals(await signedCtx.getSignedKey(), publicKey2); assertEquals(await signedCtx.getSignedKeyOwner(), null); const signedReq2 = await sign( const signedReq2 = await signRequest( new Request("https://example.com/"), privateKey3, publicKey3.id!, Loading Loading @@ -386,7 +386,7 @@ Deno.test("Federation.setInboxListeners()", async (t) => { inbox.push([ctx, create]); }); let response = await federation.handle( let response = await federation.fetch( new Request("https://example.com/inbox", { method: "POST" }), { contextData: undefined }, ); Loading @@ -402,21 +402,21 @@ Deno.test("Federation.setInboxListeners()", async (t) => { privateKey: privateKey2, publicKey: publicKey2.publicKey!, })); response = await federation.handle( response = await federation.fetch( new Request("https://example.com/inbox", { method: "POST" }), { contextData: undefined }, ); assertEquals(inbox, []); assertEquals(response.status, 401); response = await federation.handle( response = await federation.fetch( new Request("https://example.com/users/no-one/inbox", { method: "POST" }), { contextData: undefined }, ); assertEquals(inbox, []); assertEquals(response.status, 404); response = await federation.handle( response = await federation.fetch( new Request("https://example.com/users/john/inbox", { method: "POST" }), { contextData: undefined }, ); Loading @@ -433,12 +433,12 @@ Deno.test("Federation.setInboxListeners()", async (t) => { await activity.toJsonLd({ contextLoader: mockDocumentLoader }), ), }); request = await sign( request = await signRequest( request, privateKey2, new URL("https://example.com/key2"), ); response = await federation.handle(request, { contextData: undefined }); response = await federation.fetch(request, { contextData: undefined }); assertEquals(inbox.length, 1); assertEquals(inbox[0][1], activity); assertEquals(response.status, 202); Loading @@ -458,12 +458,12 @@ Deno.test("Federation.setInboxListeners()", async (t) => { await activity.toJsonLd({ contextLoader: mockDocumentLoader }), ), }); request = await sign( request = await signRequest( request, privateKey2, new URL("https://example.com/key2"), ); response = await federation.handle(request, { contextData: undefined }); response = await federation.fetch(request, { contextData: undefined }); assertEquals(inbox.length, 1); assertEquals(inbox[0][1], activity); assertEquals(response.status, 202); Loading Loading @@ -515,12 +515,12 @@ Deno.test("Federation.setInboxListeners()", async (t) => { await activity.toJsonLd({ contextLoader: mockDocumentLoader }), ), }); request = await sign( request = await signRequest( request, privateKey2, new URL("https://example.com/key2"), ); const response = await federation.handle(request, { const response = await federation.fetch(request, { contextData: undefined, }); assertEquals(errors.length, 1); Loading federation/send.test.ts +3 −2 Original line number Diff line number Diff line Loading @@ -6,7 +6,8 @@ import { assertStrictEquals, } from "@std/assert"; import * as mf from "mock_fetch"; import { doesActorOwnKey, verify } from "../httpsig/mod.ts"; import { verifyRequest } from "../sig/http.ts"; import { doesActorOwnKey } from "../sig/owner.ts"; import { mockDocumentLoader } from "../testing/docloader.ts"; import { privateKey2, publicKey2 } from "../testing/keys.ts"; import type { Actor } from "../vocab/actor.ts"; Loading Loading @@ -145,7 +146,7 @@ Deno.test("sendActivity()", async (t) => { documentLoader: mockDocumentLoader, contextLoader: mockDocumentLoader, }; const key = await verify(req, options); const key = await verifyRequest(req, options); const activity = await Activity.fromJsonLd(await req.json(), options); if (key != null && await doesActorOwnKey(activity, key, options)) { verified = true; Loading federation/send.ts +2 −2 Original line number Diff line number Diff line import { getLogger } from "@logtape/logtape"; import { sign } from "../httpsig/mod.ts"; import { signRequest } from "../sig/http.ts"; import type { DocumentLoader } from "../runtime/docloader.ts"; import type { Recipient } from "../vocab/actor.ts"; import type { Activity } from "../vocab/mod.ts"; Loading Loading @@ -125,7 +125,7 @@ export async function sendActivity( headers, body: JSON.stringify(jsonLd), }); request = await sign(request, privateKey, keyId); request = await signRequest(request, privateKey, keyId); const response = await fetch(request); if (!response.ok) { let error; Loading Loading
cli/import_map.g.json +1 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ "mock_fetch": "https://deno.land/x/mock_fetch@0.3.0/mod.ts", "uri-template-router": "npm:uri-template-router@^0.0.16", "url-template": "npm:url-template@^3.1.1", "@fedify/fedify/sig": ".././sig/mod.ts", "@cliffy/ansi": "jsr:@cliffy/ansi@1.0.0-rc.4", "@cliffy/command": "jsr:@cliffy/command@1.0.0-rc.4", "@cliffy/prompt": "jsr:@cliffy/prompt@1.0.0-rc.4", Loading
federation/handler.ts +3 −2 Original line number Diff line number Diff line import { getLogger } from "@logtape/logtape"; import { accepts } from "@std/http/negotiation"; import { doesActorOwnKey, verify } from "../httpsig/mod.ts"; import { verifyRequest } from "../sig/http.ts"; import { doesActorOwnKey } from "../sig/owner.ts"; import type { DocumentLoader } from "../runtime/docloader.ts"; import type { Recipient } from "../vocab/actor.ts"; import { Loading Loading @@ -343,7 +344,7 @@ export async function handleInbox<TContextData>( return await onNotFound(request); } } const key = await verify(request, { const key = await verifyRequest(request, { ...context, timeWindow: signatureTimeWindow, }); Loading
federation/middleware.test.ts +14 −14 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ import { } from "@std/assert"; import { dirname, join } from "@std/path"; import * as mf from "mock_fetch"; import { sign, verify } from "../httpsig/mod.ts"; import { signRequest, verifyRequest } from "../sig/http.ts"; import { FetchError, getAuthenticatedDocumentLoader, Loading @@ -34,7 +34,7 @@ Deno.test("Federation.createContext()", async (t) => { mf.install(); mf.mock("GET@/object", async (req) => { const v = await verify( const v = await verifyRequest( req, { contextLoader: mockDocumentLoader, Loading Loading @@ -267,7 +267,7 @@ Deno.test("Federation.createContext()", async (t) => { "No actor dispatcher registered", ); const signedReq = await sign( const signedReq = await signRequest( new Request("https://example.com/"), privateKey2, publicKey2.id!, Loading @@ -282,7 +282,7 @@ Deno.test("Federation.createContext()", async (t) => { assertEquals(await signedCtx.getSignedKey(), publicKey2); assertEquals(await signedCtx.getSignedKeyOwner(), null); const signedReq2 = await sign( const signedReq2 = await signRequest( new Request("https://example.com/"), privateKey3, publicKey3.id!, Loading Loading @@ -386,7 +386,7 @@ Deno.test("Federation.setInboxListeners()", async (t) => { inbox.push([ctx, create]); }); let response = await federation.handle( let response = await federation.fetch( new Request("https://example.com/inbox", { method: "POST" }), { contextData: undefined }, ); Loading @@ -402,21 +402,21 @@ Deno.test("Federation.setInboxListeners()", async (t) => { privateKey: privateKey2, publicKey: publicKey2.publicKey!, })); response = await federation.handle( response = await federation.fetch( new Request("https://example.com/inbox", { method: "POST" }), { contextData: undefined }, ); assertEquals(inbox, []); assertEquals(response.status, 401); response = await federation.handle( response = await federation.fetch( new Request("https://example.com/users/no-one/inbox", { method: "POST" }), { contextData: undefined }, ); assertEquals(inbox, []); assertEquals(response.status, 404); response = await federation.handle( response = await federation.fetch( new Request("https://example.com/users/john/inbox", { method: "POST" }), { contextData: undefined }, ); Loading @@ -433,12 +433,12 @@ Deno.test("Federation.setInboxListeners()", async (t) => { await activity.toJsonLd({ contextLoader: mockDocumentLoader }), ), }); request = await sign( request = await signRequest( request, privateKey2, new URL("https://example.com/key2"), ); response = await federation.handle(request, { contextData: undefined }); response = await federation.fetch(request, { contextData: undefined }); assertEquals(inbox.length, 1); assertEquals(inbox[0][1], activity); assertEquals(response.status, 202); Loading @@ -458,12 +458,12 @@ Deno.test("Federation.setInboxListeners()", async (t) => { await activity.toJsonLd({ contextLoader: mockDocumentLoader }), ), }); request = await sign( request = await signRequest( request, privateKey2, new URL("https://example.com/key2"), ); response = await federation.handle(request, { contextData: undefined }); response = await federation.fetch(request, { contextData: undefined }); assertEquals(inbox.length, 1); assertEquals(inbox[0][1], activity); assertEquals(response.status, 202); Loading Loading @@ -515,12 +515,12 @@ Deno.test("Federation.setInboxListeners()", async (t) => { await activity.toJsonLd({ contextLoader: mockDocumentLoader }), ), }); request = await sign( request = await signRequest( request, privateKey2, new URL("https://example.com/key2"), ); const response = await federation.handle(request, { const response = await federation.fetch(request, { contextData: undefined, }); assertEquals(errors.length, 1); Loading
federation/send.test.ts +3 −2 Original line number Diff line number Diff line Loading @@ -6,7 +6,8 @@ import { assertStrictEquals, } from "@std/assert"; import * as mf from "mock_fetch"; import { doesActorOwnKey, verify } from "../httpsig/mod.ts"; import { verifyRequest } from "../sig/http.ts"; import { doesActorOwnKey } from "../sig/owner.ts"; import { mockDocumentLoader } from "../testing/docloader.ts"; import { privateKey2, publicKey2 } from "../testing/keys.ts"; import type { Actor } from "../vocab/actor.ts"; Loading Loading @@ -145,7 +146,7 @@ Deno.test("sendActivity()", async (t) => { documentLoader: mockDocumentLoader, contextLoader: mockDocumentLoader, }; const key = await verify(req, options); const key = await verifyRequest(req, options); const activity = await Activity.fromJsonLd(await req.json(), options); if (key != null && await doesActorOwnKey(activity, key, options)) { verified = true; Loading
federation/send.ts +2 −2 Original line number Diff line number Diff line import { getLogger } from "@logtape/logtape"; import { sign } from "../httpsig/mod.ts"; import { signRequest } from "../sig/http.ts"; import type { DocumentLoader } from "../runtime/docloader.ts"; import type { Recipient } from "../vocab/actor.ts"; import type { Activity } from "../vocab/mod.ts"; Loading Loading @@ -125,7 +125,7 @@ export async function sendActivity( headers, body: JSON.stringify(jsonLd), }); request = await sign(request, privateKey, keyId); request = await signRequest(request, privateKey, keyId); const response = await fetch(request); if (!response.ok) { let error; Loading