Skip to content

Commit 6b1e5e7

Browse files
committed
Docs: custom WebFinger links
#3
1 parent 41f7246 commit 6b1e5e7

File tree

3 files changed

+64
-3
lines changed

3 files changed

+64
-3
lines changed

docs/bun.lockb

889 Bytes
Binary file not shown.

docs/manual/actor.md

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,67 @@ The `url` property usually refers to the actor's profile page. It is
491491
used as the `links` property of the WebFinger response, with the `rel`
492492
property set to <http://webfinger.net/rel/profile-page>.
493493

494+
> [!TIP]
495+
> You probably want to implement [actor aliases](#actor-aliases) if you want
496+
> to give different URLs to the actor URI and its web profile URL.
497+
498+
If you want to provide links with other `rel` than
499+
<http://webfinger.net/rel/profile-page>, you can put `Link` objects in the
500+
`url` property:
501+
502+
~~~~ typescript{8-16} twoslash
503+
import { type Federation, Person, Link } from "@fedify/fedify";
504+
const federation = null as unknown as Federation<void>;
505+
// ---cut-before---
506+
federation
507+
.setActorDispatcher("/users/{identifier}", async (ctx, identifier) => {
508+
return new Person({
509+
id: ctx.getActorUri(identifier),
510+
preferredUsername: identifier,
511+
urls: [
512+
new URL(`/@${identifier}`, ctx.origin),
513+
new Link({
514+
rel: "alternate",
515+
href: new URL(`/@${identifier}/atom.xml`, ctx.origin),
516+
mediaType: "application/atom+xml",
517+
}),
518+
new Link({
519+
rel: "http://openid.net/specs/connect/1.0/issuer",
520+
href: new URL("/openid", ctx.origin),
521+
}),
522+
],
523+
// Omitted for brevity; see the previous example for details.
524+
});
525+
});
526+
~~~~
527+
528+
With the above example, the WebFinger response will contain the following
529+
`links` property:
530+
531+
~~~~ json
532+
{
533+
"subject": "acct:[email protected]",
534+
"aliases": [
535+
"https://example.com/users/john_doe"
536+
],
537+
"links": [
538+
{
539+
"rel": "http://webfinger.net/rel/profile-page",
540+
"href": "https://example.com/@john_doe"
541+
},
542+
{
543+
"rel": "alternate",
544+
"href": "https://example.com/@john_doe/atom.xml",
545+
"type": "application/atom+xml"
546+
},
547+
{
548+
"rel": "http://openid.net/specs/connect/1.0/issuer",
549+
"href": "https://example.com/openid"
550+
}
551+
]
552+
}
553+
~~~~
554+
494555
### `icon`
495556

496557
*This API is available since Fedify 1.0.0.*
@@ -518,7 +579,7 @@ the corresponding actor's internal identifier or username, or `null` if there
518579
is no corresponding actor:
519580

520581
~~~~ typescript{15-25} twoslash
521-
// @noErrors: 2339 2345 2391 7006
582+
// @noErrors: 2345 2391
522583
import { type Federation } from "@fedify/fedify";
523584
const federation = null as unknown as Federation<void>;
524585
interface User { uuid: string; }
@@ -570,7 +631,7 @@ for the actor's profile URL with the corresponding actor URI.
570631
> in the `~ActorCallbackSetters.mapAlias()` method:
571632
>
572633
> ~~~~ typescript twoslash
573-
> // @noErrors: 2339 2345 2391 7006
634+
> // @noErrors: 2345 7006
574635
> import { type Federation } from "@fedify/fedify";
575636
> const federation = null as unknown as Federation<void>;
576637
> federation.setActorDispatcher(

docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"@braintree/sanitize-url": "^7.1.1",
44
"@deno/kv": "^0.8.4",
55
"@fedify/amqp": "0.1.0",
6-
"@fedify/fedify": "^1.3.2",
6+
"@fedify/fedify": "^1.4.0-dev.594",
77
"@fedify/postgres": "0.2.2",
88
"@fedify/redis": "0.3.0",
99
"@hono/node-server": "^1.13.7",

0 commit comments

Comments
 (0)