Loading CHANGES.md +4 −0 Original line number Diff line number Diff line Loading @@ -119,12 +119,16 @@ To be released. - Ephemeral actors now have the following properties: `summary`, `following`, `followers`, `outbox`, `manuallyApprovesFollowers`, and `url`. - Improved the compatibility of the `fedify inbox` command with Misskey and Mitra. - Added more log messages using the [LogTape] library. Currently the below logger categories are used: - `["fedify", "sig", "proof"]` - `["fedify", "sig", "key"]` - `["fedify", "vocab", "lookup"]` - `["fedify", "webfinger", "lookup"]` [#54]: https://github.com/dahlia/fedify/issues/54 [#55]: https://github.com/dahlia/fedify/issues/55 Loading cli/inbox.tsx +2 −2 Original line number Diff line number Diff line Loading @@ -141,8 +141,7 @@ federation url: new URL("https://fedify.dev/logo.png"), mediaType: "image/png", }), publicKeys: (await ctx.getActorKeyPairs(handle)) .map((pair) => pair.cryptographicKey), publicKey: (await ctx.getActorKeyPairs(handle))[0].cryptographicKey, assertionMethods: (await ctx.getActorKeyPairs(handle)) .map((pair) => pair.multikey), url: ctx.getActorUri(handle), Loading Loading @@ -209,6 +208,7 @@ federation { handle }, follower, new Accept({ id: new URL(`#accepts/${follower.id?.href}`, ctx.getActorUri("i")), actor: ctx.getActorUri(handle), object: activity.id, }), Loading vocab/lookup.ts +13 −7 Original line number Diff line number Diff line import { getLogger } from "@logtape/logtape"; import { type DocumentLoader, fetchDocumentLoader, Loading @@ -5,6 +6,8 @@ import { import { lookupWebFinger } from "../webfinger/lookup.ts"; import { Object } from "./vocab.ts"; const logger = getLogger(["fedify", "vocab", "lookup"]); /** * Options for the `lookupObject` function. * Loading Loading @@ -73,8 +76,8 @@ export async function lookupObject( try { const remoteDoc = await documentLoader(identifier.href); document = remoteDoc.document; } catch (_) { // Silently ignore errors. } catch (error) { logger.debug("Failed to fetch remote document:\n{error}", { error }); } } if (document == null) { Loading @@ -91,8 +94,8 @@ export async function lookupObject( const remoteDoc = await documentLoader(l.href); document = remoteDoc.document; break; } catch (_) { // Silently ignore errors. } catch (error) { logger.debug("Failed to fetch remote document:\n{error}", { error }); continue; } } Loading @@ -103,8 +106,11 @@ export async function lookupObject( documentLoader, contextLoader: options.contextLoader, }); } catch (e) { if (e instanceof TypeError) return null; throw e; } catch (error) { if (error instanceof TypeError) { logger.debug("Failed to parse JSON-LD document:\n{error}", { error }); return null; } throw error; } } webfinger/lookup.ts +25 −2 Original line number Diff line number Diff line import { getLogger } from "@logtape/logtape"; import type { ResourceDescriptor } from "./jrd.ts"; const logger = getLogger(["fedify", "webfinger", "lookup"]); /** * Looks up a WebFinger resource. * @param resource The resource URL to look up. Loading @@ -22,6 +25,10 @@ export async function lookupWebFinger( let url = new URL(`https://${server}/.well-known/webfinger`); url.searchParams.set("resource", resource.href); while (true) { logger.debug( "Fetching WebFinger resource descriptor from {url}...", { url: url.href }, ); const response = await fetch(url, { headers: { Accept: "application/jrd+json" }, redirect: "manual", Loading @@ -33,11 +40,27 @@ export async function lookupWebFinger( url = new URL(response.headers.get("Location")!); continue; } if (!response.ok) return null; if (!response.ok) { logger.debug( "Failed to fetch WebFinger resource descriptor: {status} {statusText}.", { url: url.href, status: response.status, statusText: response.statusText, }, ); return null; } try { return await response.json() as ResourceDescriptor; } catch (e) { if (e instanceof SyntaxError) return null; if (e instanceof SyntaxError) { logger.debug( "Failed to parse WebFinger resource descriptor as JSON: {error}", { error: e }, ); return null; } throw e; } } Loading Loading
CHANGES.md +4 −0 Original line number Diff line number Diff line Loading @@ -119,12 +119,16 @@ To be released. - Ephemeral actors now have the following properties: `summary`, `following`, `followers`, `outbox`, `manuallyApprovesFollowers`, and `url`. - Improved the compatibility of the `fedify inbox` command with Misskey and Mitra. - Added more log messages using the [LogTape] library. Currently the below logger categories are used: - `["fedify", "sig", "proof"]` - `["fedify", "sig", "key"]` - `["fedify", "vocab", "lookup"]` - `["fedify", "webfinger", "lookup"]` [#54]: https://github.com/dahlia/fedify/issues/54 [#55]: https://github.com/dahlia/fedify/issues/55 Loading
cli/inbox.tsx +2 −2 Original line number Diff line number Diff line Loading @@ -141,8 +141,7 @@ federation url: new URL("https://fedify.dev/logo.png"), mediaType: "image/png", }), publicKeys: (await ctx.getActorKeyPairs(handle)) .map((pair) => pair.cryptographicKey), publicKey: (await ctx.getActorKeyPairs(handle))[0].cryptographicKey, assertionMethods: (await ctx.getActorKeyPairs(handle)) .map((pair) => pair.multikey), url: ctx.getActorUri(handle), Loading Loading @@ -209,6 +208,7 @@ federation { handle }, follower, new Accept({ id: new URL(`#accepts/${follower.id?.href}`, ctx.getActorUri("i")), actor: ctx.getActorUri(handle), object: activity.id, }), Loading
vocab/lookup.ts +13 −7 Original line number Diff line number Diff line import { getLogger } from "@logtape/logtape"; import { type DocumentLoader, fetchDocumentLoader, Loading @@ -5,6 +6,8 @@ import { import { lookupWebFinger } from "../webfinger/lookup.ts"; import { Object } from "./vocab.ts"; const logger = getLogger(["fedify", "vocab", "lookup"]); /** * Options for the `lookupObject` function. * Loading Loading @@ -73,8 +76,8 @@ export async function lookupObject( try { const remoteDoc = await documentLoader(identifier.href); document = remoteDoc.document; } catch (_) { // Silently ignore errors. } catch (error) { logger.debug("Failed to fetch remote document:\n{error}", { error }); } } if (document == null) { Loading @@ -91,8 +94,8 @@ export async function lookupObject( const remoteDoc = await documentLoader(l.href); document = remoteDoc.document; break; } catch (_) { // Silently ignore errors. } catch (error) { logger.debug("Failed to fetch remote document:\n{error}", { error }); continue; } } Loading @@ -103,8 +106,11 @@ export async function lookupObject( documentLoader, contextLoader: options.contextLoader, }); } catch (e) { if (e instanceof TypeError) return null; throw e; } catch (error) { if (error instanceof TypeError) { logger.debug("Failed to parse JSON-LD document:\n{error}", { error }); return null; } throw error; } }
webfinger/lookup.ts +25 −2 Original line number Diff line number Diff line import { getLogger } from "@logtape/logtape"; import type { ResourceDescriptor } from "./jrd.ts"; const logger = getLogger(["fedify", "webfinger", "lookup"]); /** * Looks up a WebFinger resource. * @param resource The resource URL to look up. Loading @@ -22,6 +25,10 @@ export async function lookupWebFinger( let url = new URL(`https://${server}/.well-known/webfinger`); url.searchParams.set("resource", resource.href); while (true) { logger.debug( "Fetching WebFinger resource descriptor from {url}...", { url: url.href }, ); const response = await fetch(url, { headers: { Accept: "application/jrd+json" }, redirect: "manual", Loading @@ -33,11 +40,27 @@ export async function lookupWebFinger( url = new URL(response.headers.get("Location")!); continue; } if (!response.ok) return null; if (!response.ok) { logger.debug( "Failed to fetch WebFinger resource descriptor: {status} {statusText}.", { url: url.href, status: response.status, statusText: response.statusText, }, ); return null; } try { return await response.json() as ResourceDescriptor; } catch (e) { if (e instanceof SyntaxError) return null; if (e instanceof SyntaxError) { logger.debug( "Failed to parse WebFinger resource descriptor as JSON: {error}", { error: e }, ); return null; } throw e; } } Loading