@fedify/fedify 0.7.0 → 0.8.0-dev.140
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of @fedify/fedify might be problematic. Click here for more details.
- package/CHANGES.md +37 -1
- package/README.md +3 -3
- package/esm/deps/jsr.io/@std/encoding/0.220.1/hex.js +99 -0
- package/esm/federation/collection.js +43 -1
- package/esm/federation/handler.js +36 -6
- package/esm/federation/middleware.js +77 -9
- package/esm/federation/send.js +10 -8
- package/esm/httpsig/mod.js +1 -1
- package/esm/mod.js +3 -2
- package/package.json +1 -1
- package/types/deps/jsr.io/@std/encoding/0.220.1/hex.d.ts +24 -0
- package/types/deps/jsr.io/@std/encoding/0.220.1/hex.d.ts.map +1 -0
- package/types/federation/callback.d.ts +3 -3
- package/types/federation/callback.d.ts.map +1 -1
- package/types/federation/collection.d.ts +19 -0
- package/types/federation/collection.d.ts.map +1 -1
- package/types/federation/collection.test.d.ts.map +1 -0
- package/types/federation/context.d.ts +27 -3
- package/types/federation/context.d.ts.map +1 -1
- package/types/federation/handler.d.ts +13 -9
- package/types/federation/handler.d.ts.map +1 -1
- package/types/federation/middleware.d.ts +17 -10
- package/types/federation/middleware.d.ts.map +1 -1
- package/types/federation/queue.d.ts +1 -0
- package/types/federation/queue.d.ts.map +1 -1
- package/types/federation/send.d.ts +10 -5
- package/types/federation/send.d.ts.map +1 -1
- package/types/httpsig/mod.d.ts +1 -1
- package/types/mod.d.ts +3 -2
- package/types/mod.d.ts.map +1 -1
- package/types/testing/context.d.ts.map +1 -1
- package/types/vocab/actor.d.ts +24 -0
- package/types/vocab/actor.d.ts.map +1 -1
package/CHANGES.md
CHANGED
@@ -3,6 +3,42 @@
|
|
3
3
|
Fedify changelog
|
4
4
|
================
|
5
5
|
|
6
|
+
Version 0.8.0
|
7
|
+
-------------
|
8
|
+
|
9
|
+
To be released.
|
10
|
+
|
11
|
+
- Implemented [followers collection synchronization mechanism][FEP-8fcf].
|
12
|
+
|
13
|
+
- Added `RequestContext.sendActivity()` overload that takes `"followers"`
|
14
|
+
as the second parameter.
|
15
|
+
- Added the second type parameter to `CollectionCallbackSetters`
|
16
|
+
interface.
|
17
|
+
- Added the second type parameter to `CollectionDispatcher` type.
|
18
|
+
- Added the fourth parameter to `CollectionDispatcher` type.
|
19
|
+
- Added the second type parameter to `CollectionCounter` type.
|
20
|
+
- Added the third parameter to `CollectionCounter` type.
|
21
|
+
- Added the second type parameter to `CollectionCursor` type.
|
22
|
+
- Added the third parameter to `CollectionCursor` type.
|
23
|
+
|
24
|
+
- Relaxed the required type for activity recipients.
|
25
|
+
|
26
|
+
- Added `Recipient` interface.
|
27
|
+
- The type of the second parameter of `Context.sendActivity()` method
|
28
|
+
became `Recipient | Recipient[]` (was `Actor | Actor[]`). However,
|
29
|
+
since `Recipient` is a supertype of `Actor`, the existing code should
|
30
|
+
work without any change.
|
31
|
+
|
32
|
+
- Followers collection now has to consist of `Recipient` objects only.
|
33
|
+
(It could consist of `URL`s as well as `Actor`s before.)
|
34
|
+
|
35
|
+
- The type of `Federation.setFollowersDispatcher()` method's second
|
36
|
+
parameter became `CollectionDispatcher<Recipient, TContextData, URL>`
|
37
|
+
(was `CollectionDispatcher<Actor | URL, TContextData>`).
|
38
|
+
|
39
|
+
[FEP-8fcf]: https://codeberg.org/fediverse/fep/src/branch/main/fep/8fcf/fep-8fcf.md
|
40
|
+
|
41
|
+
|
6
42
|
Version 0.7.0
|
7
43
|
-------------
|
8
44
|
|
@@ -38,7 +74,7 @@ Released on April 23, 2024.
|
|
38
74
|
- Activity Vocabulary classes now have `typeId` static property.
|
39
75
|
|
40
76
|
- Dispatcher setters and inbox listener setters in `Federation` now take
|
41
|
-
a path as
|
77
|
+
a path as `` `${string}{handle}${string}` `` instead of `string`
|
42
78
|
so that it is more type-safe.
|
43
79
|
|
44
80
|
- Added generalized object dispatchers. [[#33]]
|
package/README.md
CHANGED
@@ -38,9 +38,9 @@ The rough roadmap is to implement the following features out of the box:
|
|
38
38
|
If you want to know more about the project, please take a look at the following
|
39
39
|
resources:
|
40
40
|
|
41
|
-
- [Tutorial](https://fedify.dev/tutorial
|
42
|
-
- [Manual](https://fedify.dev/manual
|
43
|
-
([Unstable](https://unstable.fedify.dev/manual
|
41
|
+
- [Tutorial](https://fedify.dev/tutorial)
|
42
|
+
- [Manual](https://fedify.dev/manual)
|
43
|
+
([Unstable](https://unstable.fedify.dev/manual))
|
44
44
|
- [API reference][JSR]
|
45
45
|
- [Examples](https://github.com/dahlia/fedify/tree/main/examples)
|
46
46
|
|
@@ -0,0 +1,99 @@
|
|
1
|
+
// Copyright 2009 The Go Authors. All rights reserved.
|
2
|
+
// https://github.com/golang/go/blob/master/LICENSE
|
3
|
+
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
4
|
+
// This module is browser compatible.
|
5
|
+
/**
|
6
|
+
* Port of the Go
|
7
|
+
* {@link https://github.com/golang/go/blob/go1.12.5/src/encoding/hex/hex.go | encoding/hex}
|
8
|
+
* library.
|
9
|
+
*
|
10
|
+
* This module is browser compatible.
|
11
|
+
*
|
12
|
+
* @example
|
13
|
+
* ```ts
|
14
|
+
* import {
|
15
|
+
* decodeHex,
|
16
|
+
* encodeHex,
|
17
|
+
* } from "@std/encoding/hex";
|
18
|
+
*
|
19
|
+
* const binary = new TextEncoder().encode("abc");
|
20
|
+
* const encoded = encodeHex(binary);
|
21
|
+
* console.log(encoded);
|
22
|
+
* // => "616263"
|
23
|
+
*
|
24
|
+
* console.log(decodeHex(encoded));
|
25
|
+
* // => Uint8Array(3) [ 97, 98, 99 ]
|
26
|
+
* ```
|
27
|
+
*
|
28
|
+
* @module
|
29
|
+
*/
|
30
|
+
import { validateBinaryLike } from "./_util.js";
|
31
|
+
const hexTable = new TextEncoder().encode("0123456789abcdef");
|
32
|
+
const textEncoder = new TextEncoder();
|
33
|
+
const textDecoder = new TextDecoder();
|
34
|
+
function errInvalidByte(byte) {
|
35
|
+
return new TypeError(`Invalid byte '${String.fromCharCode(byte)}'`);
|
36
|
+
}
|
37
|
+
function errLength() {
|
38
|
+
return new RangeError("Odd length hex string");
|
39
|
+
}
|
40
|
+
/** Converts a hex character into its value. */
|
41
|
+
function fromHexChar(byte) {
|
42
|
+
// '0' <= byte && byte <= '9'
|
43
|
+
if (48 <= byte && byte <= 57)
|
44
|
+
return byte - 48;
|
45
|
+
// 'a' <= byte && byte <= 'f'
|
46
|
+
if (97 <= byte && byte <= 102)
|
47
|
+
return byte - 97 + 10;
|
48
|
+
// 'A' <= byte && byte <= 'F'
|
49
|
+
if (65 <= byte && byte <= 70)
|
50
|
+
return byte - 65 + 10;
|
51
|
+
throw errInvalidByte(byte);
|
52
|
+
}
|
53
|
+
/**
|
54
|
+
* Converts data into a hex-encoded string.
|
55
|
+
*
|
56
|
+
* @example
|
57
|
+
* ```ts
|
58
|
+
* import { encodeHex } from "@std/encoding/hex";
|
59
|
+
*
|
60
|
+
* encodeHex("abc"); // "616263"
|
61
|
+
* ```
|
62
|
+
*/
|
63
|
+
export function encodeHex(src) {
|
64
|
+
const u8 = validateBinaryLike(src);
|
65
|
+
const dst = new Uint8Array(u8.length * 2);
|
66
|
+
for (let i = 0; i < dst.length; i++) {
|
67
|
+
const v = u8[i];
|
68
|
+
dst[i * 2] = hexTable[v >> 4];
|
69
|
+
dst[i * 2 + 1] = hexTable[v & 0x0f];
|
70
|
+
}
|
71
|
+
return textDecoder.decode(dst);
|
72
|
+
}
|
73
|
+
/**
|
74
|
+
* Decodes the given hex-encoded string. If the input is malformed, an error is
|
75
|
+
* thrown.
|
76
|
+
*
|
77
|
+
* @example
|
78
|
+
* ```ts
|
79
|
+
* import { decodeHex } from "@std/encoding/hex";
|
80
|
+
*
|
81
|
+
* decodeHex("616263"); // Uint8Array(3) [ 97, 98, 99 ]
|
82
|
+
* ```
|
83
|
+
*/
|
84
|
+
export function decodeHex(src) {
|
85
|
+
const u8 = textEncoder.encode(src);
|
86
|
+
const dst = new Uint8Array(u8.length / 2);
|
87
|
+
for (let i = 0; i < dst.length; i++) {
|
88
|
+
const a = fromHexChar(u8[i * 2]);
|
89
|
+
const b = fromHexChar(u8[i * 2 + 1]);
|
90
|
+
dst[i] = (a << 4) | b;
|
91
|
+
}
|
92
|
+
if (u8.length % 2 === 1) {
|
93
|
+
// Check for invalid char before reporting bad length,
|
94
|
+
// since the invalid char (if present) is an earlier problem.
|
95
|
+
fromHexChar(u8[dst.length * 2]);
|
96
|
+
throw errLength();
|
97
|
+
}
|
98
|
+
return dst;
|
99
|
+
}
|
@@ -1 +1,43 @@
|
|
1
|
-
|
1
|
+
import * as dntShim from "../_dnt.shims.js";
|
2
|
+
import { encodeHex } from "../deps/jsr.io/@std/encoding/0.220.1/hex.js";
|
3
|
+
/**
|
4
|
+
* Calculates the [partial follower collection digest][1].
|
5
|
+
*
|
6
|
+
* [1]: https://codeberg.org/fediverse/fep/src/branch/main/fep/8fcf/fep-8fcf.md#partial-follower-collection-digest
|
7
|
+
* @param uris The URIs to calculate the digest. Duplicate URIs are ignored.
|
8
|
+
* @returns The digest.
|
9
|
+
*/
|
10
|
+
export async function digest(uris) {
|
11
|
+
const processed = new Set();
|
12
|
+
const encoder = new TextEncoder();
|
13
|
+
const result = new Uint8Array(32);
|
14
|
+
for (const uri of uris) {
|
15
|
+
const u = uri instanceof URL ? uri.href : uri;
|
16
|
+
if (processed.has(u))
|
17
|
+
continue;
|
18
|
+
processed.add(u);
|
19
|
+
const encoded = encoder.encode(u);
|
20
|
+
const digest = new Uint8Array(await dntShim.crypto.subtle.digest("SHA-256", encoded));
|
21
|
+
for (let i = 0; i < 32; i++) {
|
22
|
+
result[i] ^= digest[i];
|
23
|
+
}
|
24
|
+
}
|
25
|
+
return result;
|
26
|
+
}
|
27
|
+
/**
|
28
|
+
* Builds [`Collection-Synchronization`][1] header content.
|
29
|
+
*
|
30
|
+
* [1]: https://codeberg.org/fediverse/fep/src/branch/main/fep/8fcf/fep-8fcf.md#the-collection-synchronization-http-header
|
31
|
+
*
|
32
|
+
* @param collectionId The sender's followers collection URI.
|
33
|
+
* @param actorIds The actor URIs to digest.
|
34
|
+
* @returns The header content.
|
35
|
+
*/
|
36
|
+
export async function buildCollectionSynchronizationHeader(collectionId, actorIds) {
|
37
|
+
const [anyActorId] = actorIds;
|
38
|
+
const baseUrl = new URL(anyActorId);
|
39
|
+
const url = new URL(collectionId);
|
40
|
+
url.searchParams.set("base-url", `${baseUrl.origin}/`);
|
41
|
+
const hash = encodeHex(await digest(actorIds));
|
42
|
+
return `collectionId="${collectionId}", url="${url}", digest="${hash}"`;
|
43
|
+
}
|
@@ -2,7 +2,7 @@ import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { getLogger } from "@logtape/logtape";
|
3
3
|
import { accepts } from "../deps/jsr.io/@std/http/0.220.1/negotiation.js";
|
4
4
|
import { doesActorOwnKey, verify } from "../httpsig/mod.js";
|
5
|
-
import { Activity, OrderedCollection, OrderedCollectionPage, } from "../vocab/vocab.js";
|
5
|
+
import { Activity, Link, Object, OrderedCollection, OrderedCollectionPage, } from "../vocab/vocab.js";
|
6
6
|
export function acceptsJsonLd(request) {
|
7
7
|
const types = accepts(request);
|
8
8
|
if (types == null)
|
@@ -61,7 +61,7 @@ export async function handleObject(request, { values, context, objectDispatcher,
|
|
61
61
|
},
|
62
62
|
});
|
63
63
|
}
|
64
|
-
export async function handleCollection(request, { handle, context, collectionCallbacks, onUnauthorized, onNotFound, onNotAcceptable, }) {
|
64
|
+
export async function handleCollection(request, { name, handle, filter, filterPredicate, context, collectionCallbacks, onUnauthorized, onNotFound, onNotAcceptable, }) {
|
65
65
|
if (collectionCallbacks == null)
|
66
66
|
return await onNotFound(request);
|
67
67
|
const url = new URL(request.url);
|
@@ -71,13 +71,13 @@ export async function handleCollection(request, { handle, context, collectionCal
|
|
71
71
|
const firstCursor = await collectionCallbacks.firstCursor?.(context, handle);
|
72
72
|
const totalItems = await collectionCallbacks.counter?.(context, handle);
|
73
73
|
if (firstCursor == null) {
|
74
|
-
const page = await collectionCallbacks.dispatcher(context, handle, null);
|
74
|
+
const page = await collectionCallbacks.dispatcher(context, handle, null, filter);
|
75
75
|
if (page == null)
|
76
76
|
return await onNotFound(request);
|
77
77
|
const { items } = page;
|
78
78
|
collection = new OrderedCollection({
|
79
79
|
totalItems: totalItems == null ? null : Number(totalItems),
|
80
|
-
items,
|
80
|
+
items: filterCollectionItems(items, name, filterPredicate),
|
81
81
|
});
|
82
82
|
}
|
83
83
|
else {
|
@@ -97,7 +97,7 @@ export async function handleCollection(request, { handle, context, collectionCal
|
|
97
97
|
}
|
98
98
|
}
|
99
99
|
else {
|
100
|
-
const page = await collectionCallbacks.dispatcher(context, handle, cursor);
|
100
|
+
const page = await collectionCallbacks.dispatcher(context, handle, cursor, filter);
|
101
101
|
if (page == null)
|
102
102
|
return await onNotFound(request);
|
103
103
|
const { items, prevCursor, nextCursor } = page;
|
@@ -113,7 +113,12 @@ export async function handleCollection(request, { handle, context, collectionCal
|
|
113
113
|
}
|
114
114
|
const partOf = new URL(context.url);
|
115
115
|
partOf.searchParams.delete("cursor");
|
116
|
-
collection = new OrderedCollectionPage({
|
116
|
+
collection = new OrderedCollectionPage({
|
117
|
+
prev,
|
118
|
+
next,
|
119
|
+
items: filterCollectionItems(items, name, filterPredicate),
|
120
|
+
partOf,
|
121
|
+
});
|
117
122
|
}
|
118
123
|
if (!acceptsJsonLd(request))
|
119
124
|
return await onNotAcceptable(request);
|
@@ -132,6 +137,31 @@ export async function handleCollection(request, { handle, context, collectionCal
|
|
132
137
|
},
|
133
138
|
});
|
134
139
|
}
|
140
|
+
function filterCollectionItems(items, collectionName, filterPredicate) {
|
141
|
+
const result = [];
|
142
|
+
let logged = false;
|
143
|
+
for (const item of items) {
|
144
|
+
let mappedItem;
|
145
|
+
if (item instanceof Object || item instanceof Link || item instanceof URL) {
|
146
|
+
mappedItem = item;
|
147
|
+
}
|
148
|
+
else if (item.id == null)
|
149
|
+
continue;
|
150
|
+
else
|
151
|
+
mappedItem = item.id;
|
152
|
+
if (filterPredicate != null && !filterPredicate(item)) {
|
153
|
+
if (!logged) {
|
154
|
+
getLogger(["fedify", "federation", "collection"]).warn(`The ${collectionName} collection apparently does not implement ` +
|
155
|
+
"filtering. This may result in a large response payload. " +
|
156
|
+
"Please consider implementing filtering for the collection.");
|
157
|
+
logged = true;
|
158
|
+
}
|
159
|
+
continue;
|
160
|
+
}
|
161
|
+
result.push(mappedItem);
|
162
|
+
}
|
163
|
+
return result;
|
164
|
+
}
|
135
165
|
export async function handleInbox(request, { handle, context, kv, kvPrefix, actorDispatcher, inboxListeners, inboxErrorHandler, onNotFound, }) {
|
136
166
|
const logger = getLogger(["fedify", "federation", "inbox"]);
|
137
167
|
if (actorDispatcher == null) {
|
@@ -7,6 +7,7 @@ import { handleNodeInfo, handleNodeInfoJrd } from "../nodeinfo/handler.js";
|
|
7
7
|
import { fetchDocumentLoader, getAuthenticatedDocumentLoader, kvCache, } from "../runtime/docloader.js";
|
8
8
|
import { Activity, CryptographicKey } from "../vocab/mod.js";
|
9
9
|
import { handleWebFinger } from "../webfinger/handler.js";
|
10
|
+
import { buildCollectionSynchronizationHeader } from "./collection.js";
|
10
11
|
import { handleActor, handleCollection, handleInbox, handleObject, } from "./handler.js";
|
11
12
|
import { Router, RouterError } from "./router.js";
|
12
13
|
import { extractInboxes, sendActivity } from "./send.js";
|
@@ -89,6 +90,7 @@ export class Federation {
|
|
89
90
|
inbox: message.inbox,
|
90
91
|
activity: message.activity,
|
91
92
|
trial: message.trial,
|
93
|
+
headers: message.headers,
|
92
94
|
};
|
93
95
|
let activity = null;
|
94
96
|
try {
|
@@ -104,6 +106,7 @@ export class Federation {
|
|
104
106
|
activity,
|
105
107
|
inbox: new URL(message.inbox),
|
106
108
|
documentLoader,
|
109
|
+
headers: new Headers(message.headers),
|
107
110
|
});
|
108
111
|
}
|
109
112
|
catch (error) {
|
@@ -181,7 +184,9 @@ export class Federation {
|
|
181
184
|
}
|
182
185
|
return new URL(path, url);
|
183
186
|
},
|
184
|
-
getObjectUri: (
|
187
|
+
getObjectUri: (
|
188
|
+
// deno-lint-ignore no-explicit-any
|
189
|
+
cls, values) => {
|
185
190
|
const callbacks = this.#objectCallbacks[cls.typeId.href];
|
186
191
|
if (callbacks == null) {
|
187
192
|
throw new RouterError("No object dispatcher registered.");
|
@@ -257,7 +262,28 @@ export class Federation {
|
|
257
262
|
const senderPair = "handle" in sender
|
258
263
|
? await getKeyPairFromHandle(sender.handle)
|
259
264
|
: sender;
|
260
|
-
|
265
|
+
const opts = { ...options };
|
266
|
+
let expandedRecipients;
|
267
|
+
if (Array.isArray(recipients)) {
|
268
|
+
expandedRecipients = recipients;
|
269
|
+
}
|
270
|
+
else if (recipients === "followers") {
|
271
|
+
if (!("handle" in sender)) {
|
272
|
+
throw new Error("If recipients is 'followers', sender must be an actor handle.");
|
273
|
+
}
|
274
|
+
expandedRecipients = [];
|
275
|
+
for await (const recipient of this.#getFollowers(reqCtx, sender.handle)) {
|
276
|
+
expandedRecipients.push(recipient);
|
277
|
+
}
|
278
|
+
const collectionId = this.#router.build("followers", sender);
|
279
|
+
opts.collectionSync = collectionId == null
|
280
|
+
? undefined
|
281
|
+
: new URL(collectionId, url).href;
|
282
|
+
}
|
283
|
+
else {
|
284
|
+
expandedRecipients = [recipients];
|
285
|
+
}
|
286
|
+
return await this.sendActivity(senderPair, expandedRecipients, activity, opts);
|
261
287
|
},
|
262
288
|
};
|
263
289
|
if (request == null)
|
@@ -557,6 +583,29 @@ export class Federation {
|
|
557
583
|
};
|
558
584
|
return setters;
|
559
585
|
}
|
586
|
+
async *#getFollowers(context, handle) {
|
587
|
+
if (this.#followersCallbacks == null) {
|
588
|
+
throw new Error("No followers collection dispatcher registered.");
|
589
|
+
}
|
590
|
+
const result = await this.#followersCallbacks.dispatcher(context, handle, null);
|
591
|
+
if (result != null) {
|
592
|
+
for (const recipient of result.items)
|
593
|
+
yield recipient;
|
594
|
+
return;
|
595
|
+
}
|
596
|
+
if (this.#followersCallbacks.firstCursor == null) {
|
597
|
+
throw new Error("No first cursor dispatcher registered for followers collection.");
|
598
|
+
}
|
599
|
+
let cursor = await this.#followersCallbacks.firstCursor(context, handle);
|
600
|
+
while (cursor != null) {
|
601
|
+
const result = await this.#followersCallbacks.dispatcher(context, handle, cursor);
|
602
|
+
if (result == null)
|
603
|
+
break;
|
604
|
+
for (const recipient of result.items)
|
605
|
+
yield recipient;
|
606
|
+
cursor = result.nextCursor ?? null;
|
607
|
+
}
|
608
|
+
}
|
560
609
|
/**
|
561
610
|
* Assigns the URL path for the inbox and starts setting inbox listeners.
|
562
611
|
*
|
@@ -628,7 +677,7 @@ export class Federation {
|
|
628
677
|
* @param options Options for sending the activity.
|
629
678
|
* @throws {TypeError} If the activity to send does not have an actor.
|
630
679
|
*/
|
631
|
-
async sendActivity({ keyId, privateKey }, recipients, activity, { preferSharedInbox, immediate } = {}) {
|
680
|
+
async sendActivity({ keyId, privateKey }, recipients, activity, { preferSharedInbox, immediate, collectionSync } = {}) {
|
632
681
|
const logger = getLogger(["fedify", "federation", "outbox"]);
|
633
682
|
if (activity.actorId == null) {
|
634
683
|
logger.error("Activity {activityId} to send does not have an actor.", { activity, activityId: activity?.id?.href });
|
@@ -646,7 +695,7 @@ export class Federation {
|
|
646
695
|
preferSharedInbox,
|
647
696
|
});
|
648
697
|
logger.debug("Sending activity {activityId} to inboxes:\n{inboxes}", {
|
649
|
-
inboxes:
|
698
|
+
inboxes: globalThis.Object.keys(inboxes),
|
650
699
|
activityId: activity.id?.href,
|
651
700
|
activity,
|
652
701
|
});
|
@@ -660,13 +709,16 @@ export class Federation {
|
|
660
709
|
logger.debug("Sending activity immediately without queue since queue is not set.", { activityId: activity.id?.href, activity });
|
661
710
|
}
|
662
711
|
const promises = [];
|
663
|
-
for (const inbox
|
712
|
+
for (const inbox in inboxes) {
|
664
713
|
promises.push(sendActivity({
|
665
714
|
keyId,
|
666
715
|
privateKey,
|
667
716
|
activity,
|
668
|
-
inbox,
|
717
|
+
inbox: new URL(inbox),
|
669
718
|
documentLoader,
|
719
|
+
headers: collectionSync == null ? undefined : new Headers({
|
720
|
+
"Collection-Synchronization": await buildCollectionSynchronizationHeader(collectionSync, inboxes[inbox]),
|
721
|
+
}),
|
670
722
|
}));
|
671
723
|
}
|
672
724
|
await Promise.all(promises);
|
@@ -675,14 +727,17 @@ export class Federation {
|
|
675
727
|
logger.debug("Enqueuing activity {activityId} to send later.", { activityId: activity.id?.href, activity });
|
676
728
|
const privateKeyJwk = await exportJwk(privateKey);
|
677
729
|
const activityJson = await activity.toJsonLd({ documentLoader });
|
678
|
-
for (const inbox
|
730
|
+
for (const inbox in inboxes) {
|
679
731
|
const message = {
|
680
732
|
type: "outbox",
|
681
733
|
keyId: keyId.href,
|
682
734
|
privateKey: privateKeyJwk,
|
683
735
|
activity: activityJson,
|
684
|
-
inbox
|
736
|
+
inbox,
|
685
737
|
trial: 0,
|
738
|
+
headers: collectionSync == null ? {} : {
|
739
|
+
"Collection-Synchronization": await buildCollectionSynchronizationHeader(collectionSync, inboxes[inbox]),
|
740
|
+
},
|
686
741
|
};
|
687
742
|
this.#queue.enqueue(message);
|
688
743
|
}
|
@@ -765,6 +820,7 @@ export class Federation {
|
|
765
820
|
}
|
766
821
|
case "outbox":
|
767
822
|
return await handleCollection(request, {
|
823
|
+
name: "outbox",
|
768
824
|
handle: route.values.handle,
|
769
825
|
context,
|
770
826
|
collectionCallbacks: this.#outboxCallbacks,
|
@@ -793,6 +849,7 @@ export class Federation {
|
|
793
849
|
});
|
794
850
|
case "following":
|
795
851
|
return await handleCollection(request, {
|
852
|
+
name: "following",
|
796
853
|
handle: route.values.handle,
|
797
854
|
context,
|
798
855
|
collectionCallbacks: this.#followingCallbacks,
|
@@ -800,15 +857,26 @@ export class Federation {
|
|
800
857
|
onNotFound,
|
801
858
|
onNotAcceptable,
|
802
859
|
});
|
803
|
-
case "followers":
|
860
|
+
case "followers": {
|
861
|
+
let baseUrl = url.searchParams.get("base-url");
|
862
|
+
if (baseUrl != null) {
|
863
|
+
const u = new URL(baseUrl);
|
864
|
+
baseUrl = `${u.origin}/`;
|
865
|
+
}
|
804
866
|
return await handleCollection(request, {
|
867
|
+
name: "followers",
|
805
868
|
handle: route.values.handle,
|
806
869
|
context,
|
870
|
+
filter: baseUrl != null ? new URL(baseUrl) : undefined,
|
871
|
+
filterPredicate: baseUrl != null
|
872
|
+
? ((i) => (i instanceof URL ? i.href : i.id?.href ?? "").startsWith(baseUrl))
|
873
|
+
: undefined,
|
807
874
|
collectionCallbacks: this.#followersCallbacks,
|
808
875
|
onUnauthorized,
|
809
876
|
onNotFound,
|
810
877
|
onNotAcceptable,
|
811
878
|
});
|
879
|
+
}
|
812
880
|
default: {
|
813
881
|
const response = onNotFound(request);
|
814
882
|
return response instanceof Promise ? await response : response;
|
package/esm/federation/send.js
CHANGED
@@ -4,7 +4,7 @@ import { sign } from "../httpsig/mod.js";
|
|
4
4
|
* Extracts the inbox URLs from recipients.
|
5
5
|
* @param parameters The parameters to extract the inboxes.
|
6
6
|
* See also {@link ExtractInboxesParameters}.
|
7
|
-
* @returns The inbox
|
7
|
+
* @returns The inboxes as a map of inbox URL to actor URIs.
|
8
8
|
*/
|
9
9
|
export function extractInboxes({ recipients, preferSharedInbox }) {
|
10
10
|
const inboxes = {};
|
@@ -12,10 +12,12 @@ export function extractInboxes({ recipients, preferSharedInbox }) {
|
|
12
12
|
const inbox = preferSharedInbox
|
13
13
|
? recipient.endpoints?.sharedInbox ?? recipient.inboxId
|
14
14
|
: recipient.inboxId;
|
15
|
-
if (inbox != null)
|
16
|
-
inboxes[inbox.href]
|
15
|
+
if (inbox != null && recipient.id != null) {
|
16
|
+
inboxes[inbox.href] ??= new Set();
|
17
|
+
inboxes[inbox.href].add(recipient.id.href);
|
18
|
+
}
|
17
19
|
}
|
18
|
-
return
|
20
|
+
return inboxes;
|
19
21
|
}
|
20
22
|
/**
|
21
23
|
* Sends an {@link Activity} to an inbox.
|
@@ -24,17 +26,17 @@ export function extractInboxes({ recipients, preferSharedInbox }) {
|
|
24
26
|
* See also {@link SendActivityParameters}.
|
25
27
|
* @throws {Error} If the activity fails to send.
|
26
28
|
*/
|
27
|
-
export async function sendActivity({ activity, privateKey, keyId, inbox, documentLoader, }) {
|
29
|
+
export async function sendActivity({ activity, privateKey, keyId, inbox, documentLoader, headers, }) {
|
28
30
|
const logger = getLogger(["fedify", "federation", "outbox"]);
|
29
31
|
if (activity.actorId == null) {
|
30
32
|
throw new TypeError("The activity to send must have at least one actor property.");
|
31
33
|
}
|
32
34
|
const jsonLd = await activity.toJsonLd({ documentLoader });
|
35
|
+
headers = new Headers(headers);
|
36
|
+
headers.set("Content-Type", "application/activity+json");
|
33
37
|
let request = new Request(inbox, {
|
34
38
|
method: "POST",
|
35
|
-
headers
|
36
|
-
"Content-Type": "application/activity+json",
|
37
|
-
},
|
39
|
+
headers,
|
38
40
|
body: JSON.stringify(jsonLd),
|
39
41
|
});
|
40
42
|
request = await sign(request, privateKey, keyId);
|
package/esm/httpsig/mod.js
CHANGED
@@ -197,7 +197,7 @@ export async function doesActorOwnKey(activity, key, documentLoader) {
|
|
197
197
|
* @param keyId The ID of the key to check, or the key itself.
|
198
198
|
* @param documentLoader The document loader to use for fetching the key and its owner.
|
199
199
|
* @returns The actor that owns the key, or `null` if the key has no known owner.
|
200
|
-
* @
|
200
|
+
* @since 0.7.0
|
201
201
|
*/
|
202
202
|
export async function getKeyOwner(keyId, documentLoader) {
|
203
203
|
let object;
|
package/esm/mod.js
CHANGED
@@ -28,8 +28,9 @@
|
|
28
28
|
* following resources:
|
29
29
|
*
|
30
30
|
* - [GitHub](https://github.com/dahlia/fedify)
|
31
|
-
* -
|
32
|
-
*
|
31
|
+
* - [Tutorial](https://fedify.dev/tutorial)
|
32
|
+
* - [Manual](https://fedify.dev/manual)
|
33
|
+
* ([Unstable](https://unstable.fedify.dev/manual))
|
33
34
|
* - [Examples](https://github.com/dahlia/fedify/tree/main/examples)
|
34
35
|
*
|
35
36
|
* [ActivityPub]: https://www.w3.org/TR/activitypub/
|
package/package.json
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
/**
|
2
|
+
* Converts data into a hex-encoded string.
|
3
|
+
*
|
4
|
+
* @example
|
5
|
+
* ```ts
|
6
|
+
* import { encodeHex } from "@std/encoding/hex";
|
7
|
+
*
|
8
|
+
* encodeHex("abc"); // "616263"
|
9
|
+
* ```
|
10
|
+
*/
|
11
|
+
export declare function encodeHex(src: string | Uint8Array | ArrayBuffer): string;
|
12
|
+
/**
|
13
|
+
* Decodes the given hex-encoded string. If the input is malformed, an error is
|
14
|
+
* thrown.
|
15
|
+
*
|
16
|
+
* @example
|
17
|
+
* ```ts
|
18
|
+
* import { decodeHex } from "@std/encoding/hex";
|
19
|
+
*
|
20
|
+
* decodeHex("616263"); // Uint8Array(3) [ 97, 98, 99 ]
|
21
|
+
* ```
|
22
|
+
*/
|
23
|
+
export declare function decodeHex(src: string): Uint8Array;
|
24
|
+
//# sourceMappingURL=hex.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"hex.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/0.220.1/hex.ts"],"names":[],"mappings":"AAyDA;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,MAAM,CAUxE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAiBjD"}
|
@@ -37,19 +37,19 @@ export type ObjectDispatcher<TContextData, TObject extends Object, TParam extend
|
|
37
37
|
*
|
38
38
|
* @typeParam TContextData The context data to pass to the {@link Context}.
|
39
39
|
*/
|
40
|
-
export type CollectionDispatcher<TItem, TContextData> = (context: RequestContext<TContextData>, handle: string, cursor: string | null) => PageItems<TItem> | null | Promise<PageItems<TItem> | null>;
|
40
|
+
export type CollectionDispatcher<TItem, TContextData, TFilter> = (context: RequestContext<TContextData>, handle: string, cursor: string | null, filter?: TFilter) => PageItems<TItem> | null | Promise<PageItems<TItem> | null>;
|
41
41
|
/**
|
42
42
|
* A callback that counts the number of items in a collection.
|
43
43
|
*
|
44
44
|
* @typeParam TContextData The context data to pass to the {@link Context}.
|
45
45
|
*/
|
46
|
-
export type CollectionCounter<TContextData> = (context: RequestContext<TContextData>, handle: string) => number | bigint | null | Promise<number | bigint | null>;
|
46
|
+
export type CollectionCounter<TContextData, TFilter> = (context: RequestContext<TContextData>, handle: string, filter?: TFilter) => number | bigint | null | Promise<number | bigint | null>;
|
47
47
|
/**
|
48
48
|
* A callback that returns a cursor for a collection.
|
49
49
|
*
|
50
50
|
* @typeParam TContextData The context data to pass to the {@link Context}.
|
51
51
|
*/
|
52
|
-
export type CollectionCursor<TContextData> = (context: RequestContext<TContextData>, handle: string) => string | null | Promise<string | null>;
|
52
|
+
export type CollectionCursor<TContextData, TFilter> = (context: RequestContext<TContextData>, handle: string, filter?: TFilter) => string | null | Promise<string | null>;
|
53
53
|
/**
|
54
54
|
* A callback that listens for activities in an inbox.
|
55
55
|
*
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"callback.d.ts","sourceRoot":"","sources":["../../src/federation/callback.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,CAAC,YAAY,IAAI,CAC7C,OAAO,EAAE,cAAc,CAAC,YAAY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AAM,EACd,SAAS,EAAE,gBAAgB,GAAG,IAAI,EAClC,cAAc,EAAE,KAAK,GAAG,IAAI,KACzB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAEhC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,wBAAwB,CAAC,YAAY,EAAE,MAAM,SAAS,MAAM,IAAI,CAC1E,OAAO,EAAE,cAAc,CAAC,YAAY,CAAC,EACrC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,SAAS,EAAE,gBAAgB,GAAG,IAAI,EAClC,cAAc,EAAE,KAAK,GAAG,IAAI,KACzB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC"}
|
@@ -1,3 +1,4 @@
|
|
1
|
+
/// <reference types="node" />
|
1
2
|
/**
|
2
3
|
* A page of items.
|
3
4
|
*/
|
@@ -6,4 +7,22 @@ export interface PageItems<TItem> {
|
|
6
7
|
nextCursor?: string | null;
|
7
8
|
items: TItem[];
|
8
9
|
}
|
10
|
+
/**
|
11
|
+
* Calculates the [partial follower collection digest][1].
|
12
|
+
*
|
13
|
+
* [1]: https://codeberg.org/fediverse/fep/src/branch/main/fep/8fcf/fep-8fcf.md#partial-follower-collection-digest
|
14
|
+
* @param uris The URIs to calculate the digest. Duplicate URIs are ignored.
|
15
|
+
* @returns The digest.
|
16
|
+
*/
|
17
|
+
export declare function digest(uris: Iterable<string | URL>): Promise<Uint8Array>;
|
18
|
+
/**
|
19
|
+
* Builds [`Collection-Synchronization`][1] header content.
|
20
|
+
*
|
21
|
+
* [1]: https://codeberg.org/fediverse/fep/src/branch/main/fep/8fcf/fep-8fcf.md#the-collection-synchronization-http-header
|
22
|
+
*
|
23
|
+
* @param collectionId The sender's followers collection URI.
|
24
|
+
* @param actorIds The actor URIs to digest.
|
25
|
+
* @returns The header content.
|
26
|
+
*/
|
27
|
+
export declare function buildCollectionSynchronizationHeader(collectionId: string | URL, actorIds: Iterable<string | URL>): Promise<string>;
|
9
28
|
//# sourceMappingURL=collection.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../src/federation/collection.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../src/federation/collection.ts"],"names":[],"mappings":";AAGA;;GAEG;AACH,MAAM,WAAW,SAAS,CAAC,KAAK;IAC9B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,KAAK,EAAE,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAsB,MAAM,CAC1B,IAAI,EAAE,QAAQ,CAAC,MAAM,GAAG,GAAG,CAAC,GAC3B,OAAO,CAAC,UAAU,CAAC,CAiBrB;AAED;;;;;;;;GAQG;AACH,wBAAsB,oCAAoC,CACxD,YAAY,EAAE,MAAM,GAAG,GAAG,EAC1B,QAAQ,EAAE,QAAQ,CAAC,MAAM,GAAG,GAAG,CAAC,GAC/B,OAAO,CAAC,MAAM,CAAC,CAOjB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"collection.test.d.ts","sourceRoot":"","sources":["../../src/federation/collection.test.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC"}
|
@@ -2,7 +2,7 @@
|
|
2
2
|
/// <reference types="node" />
|
3
3
|
import * as dntShim from "../_dnt.shims.js";
|
4
4
|
import type { DocumentLoader } from "../runtime/docloader.js";
|
5
|
-
import type { Actor } from "../vocab/actor.js";
|
5
|
+
import type { Actor, Recipient } from "../vocab/actor.js";
|
6
6
|
import type { Activity, CryptographicKey, Object } from "../vocab/mod.js";
|
7
7
|
/**
|
8
8
|
* A context.
|
@@ -122,14 +122,13 @@ export interface Context<TContextData> {
|
|
122
122
|
* @param recipients The recipients of the activity.
|
123
123
|
* @param activity The activity to send.
|
124
124
|
* @param options Options for sending the activity.
|
125
|
-
* @throws {Error} If the sender is not valid.
|
126
125
|
*/
|
127
126
|
sendActivity(sender: {
|
128
127
|
keyId: URL;
|
129
128
|
privateKey: dntShim.CryptoKey;
|
130
129
|
} | {
|
131
130
|
handle: string;
|
132
|
-
}, recipients:
|
131
|
+
}, recipients: Recipient | Recipient[], activity: Activity, options?: SendActivityOptions): Promise<void>;
|
133
132
|
}
|
134
133
|
/**
|
135
134
|
* A context for a request.
|
@@ -191,6 +190,31 @@ export interface RequestContext<TContextData> extends Context<TContextData> {
|
|
191
190
|
* @since 0.7.0
|
192
191
|
*/
|
193
192
|
getSignedKeyOwner(): Promise<Actor | null>;
|
193
|
+
/**
|
194
|
+
* Sends an activity to recipients' inboxes.
|
195
|
+
* @param sender The sender's handle or the sender's key pair.
|
196
|
+
* @param recipients The recipients of the activity.
|
197
|
+
* @param activity The activity to send.
|
198
|
+
* @param options Options for sending the activity.
|
199
|
+
*/
|
200
|
+
sendActivity(sender: {
|
201
|
+
keyId: URL;
|
202
|
+
privateKey: dntShim.CryptoKey;
|
203
|
+
} | {
|
204
|
+
handle: string;
|
205
|
+
}, recipients: Recipient | Recipient[], activity: Activity, options?: SendActivityOptions): Promise<void>;
|
206
|
+
/**
|
207
|
+
* Sends an activity to the outboxes of the sender's followers.
|
208
|
+
* @param sender The sender's handle.
|
209
|
+
* @param recipients In this case, it must be `"followers"`.
|
210
|
+
* @param activity The activity to send.
|
211
|
+
* @param options Options for sending the activity.
|
212
|
+
* @throws {Error} If no followers collection is registered.
|
213
|
+
* @since 0.8.0
|
214
|
+
*/
|
215
|
+
sendActivity(sender: {
|
216
|
+
handle: string;
|
217
|
+
}, recipients: "followers", activity: Activity, options?: SendActivityOptions): Promise<void>;
|
194
218
|
}
|
195
219
|
/**
|
196
220
|
* Options for {@link Context.sendActivity} method and
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/federation/context.ts"],"names":[],"mappings":";;AAAA,OAAO,KAA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,EAE9B,GAAG,EAAE,CAAC,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG;QAAE,MAAM,EAAE,GAAG,CAAA;KAAE,EACxD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IAE3B;;;;;;;;;;;OAWG;IACH,YAAY,IAAI,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IAEjD;;;;;;;;;;;;OAYG;IACH,iBAAiB,IAAI,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;IAE3C;;;;;;OAMG;IACH,YAAY,CACV,MAAM,EAAE;QAAE,KAAK,EAAE,GAAG,CAAC;QAAC,UAAU,EAAE,OAAO,CAAC,SAAS,CAAA;KAAE,GAAG;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,EAC1E,UAAU,EAAE,SAAS,GAAG,SAAS,EAAE,EACnC,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB;;;;;;;;OAQG;IACH,YAAY,CACV,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,EAC1B,UAAU,EAAE,WAAW,EACvB,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB"}
|
@@ -1,7 +1,8 @@
|
|
1
1
|
/// <reference types="node" />
|
2
2
|
/// <reference types="node" />
|
3
3
|
import type { DocumentLoader } from "../runtime/docloader.js";
|
4
|
-
import
|
4
|
+
import type { Recipient } from "../vocab/actor.js";
|
5
|
+
import { Activity, Link, Object } from "../vocab/vocab.js";
|
5
6
|
import type { ActorDispatcher, AuthorizePredicate, CollectionCounter, CollectionCursor, CollectionDispatcher, InboxErrorHandler, InboxListener, ObjectAuthorizePredicate, ObjectDispatcher } from "./callback.js";
|
6
7
|
import type { RequestContext } from "./context.js";
|
7
8
|
import type { KvKey, KvStore } from "./kv.js";
|
@@ -29,37 +30,40 @@ export declare function handleObject<TContextData>(request: Request, { values, c
|
|
29
30
|
/**
|
30
31
|
* Callbacks for handling a collection.
|
31
32
|
*/
|
32
|
-
export interface CollectionCallbacks<TItem, TContextData> {
|
33
|
+
export interface CollectionCallbacks<TItem, TContextData, TFilter> {
|
33
34
|
/**
|
34
35
|
* A callback that dispatches a collection.
|
35
36
|
*/
|
36
|
-
dispatcher: CollectionDispatcher<TItem, TContextData>;
|
37
|
+
dispatcher: CollectionDispatcher<TItem, TContextData, TFilter>;
|
37
38
|
/**
|
38
39
|
* A callback that counts the number of items in a collection.
|
39
40
|
*/
|
40
|
-
counter?: CollectionCounter<TContextData>;
|
41
|
+
counter?: CollectionCounter<TContextData, TFilter>;
|
41
42
|
/**
|
42
43
|
* A callback that returns the first cursor for a collection.
|
43
44
|
*/
|
44
|
-
firstCursor?: CollectionCursor<TContextData>;
|
45
|
+
firstCursor?: CollectionCursor<TContextData, TFilter>;
|
45
46
|
/**
|
46
47
|
* A callback that returns the last cursor for a collection.
|
47
48
|
*/
|
48
|
-
lastCursor?: CollectionCursor<TContextData>;
|
49
|
+
lastCursor?: CollectionCursor<TContextData, TFilter>;
|
49
50
|
/**
|
50
51
|
* A callback that determines if a request is authorized to access the collection.
|
51
52
|
*/
|
52
53
|
authorizePredicate?: AuthorizePredicate<TContextData>;
|
53
54
|
}
|
54
|
-
export interface CollectionHandlerParameters<TItem, TContextData> {
|
55
|
+
export interface CollectionHandlerParameters<TItem, TContextData, TFilter> {
|
56
|
+
name: string;
|
55
57
|
handle: string;
|
58
|
+
filter?: TFilter;
|
59
|
+
filterPredicate?: (item: TItem) => boolean;
|
56
60
|
context: RequestContext<TContextData>;
|
57
|
-
collectionCallbacks?: CollectionCallbacks<TItem, TContextData>;
|
61
|
+
collectionCallbacks?: CollectionCallbacks<TItem, TContextData, TFilter>;
|
58
62
|
onUnauthorized(request: Request): Response | Promise<Response>;
|
59
63
|
onNotFound(request: Request): Response | Promise<Response>;
|
60
64
|
onNotAcceptable(request: Request): Response | Promise<Response>;
|
61
65
|
}
|
62
|
-
export declare function handleCollection<TItem extends URL | Object | Link, TContextData>(request: Request, { handle, context, collectionCallbacks, onUnauthorized, onNotFound, onNotAcceptable, }: CollectionHandlerParameters<TItem, TContextData>): Promise<Response>;
|
66
|
+
export declare function handleCollection<TItem extends URL | Object | Link | Recipient, TContextData, TFilter>(request: Request, { name, handle, filter, filterPredicate, context, collectionCallbacks, onUnauthorized, onNotFound, onNotAcceptable, }: CollectionHandlerParameters<TItem, TContextData, TFilter>): Promise<Response>;
|
63
67
|
export interface InboxHandlerParameters<TContextData> {
|
64
68
|
handle: string | null;
|
65
69
|
context: RequestContext<TContextData>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/federation/handler.ts"],"names":[],"mappings":";;AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EACL,QAAQ,EACR,
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/federation/handler.ts"],"names":[],"mappings":";;AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EACL,QAAQ,EACR,IAAI,EACJ,MAAM,EAGP,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EAC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AQ,CAAC,CAAC;CAC5D;AAED,wBAAsB,WAAW,CAAC,YAAY,EAC5C,OAAO,EAAE,OAAO,EAChB,EACE,MAAM,EACN,OAAO,EACP,EAAE,EACF,QAAQ,EACR,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,UAAU,GACX,EAAE,sBAAsB,CAAC,YAAY,CAAC,GACtC,OAAO,CAAC,QAAQ,CAAC,CA6HnB;AAED;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,cAAc,EAAE,cAAc,CAAC;CAChC;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,QAAQ,CAAC,CAOnB;AAED;;;;;;;;GAQG;AACH,wBAAsB,6BAA6B,CACjD,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAK1B"}
|
@@ -3,7 +3,7 @@
|
|
3
3
|
import * as dntShim from "../_dnt.shims.js";
|
4
4
|
import { Temporal } from "@js-temporal/polyfill";
|
5
5
|
import { type AuthenticatedDocumentLoaderFactory, type DocumentLoader } from "../runtime/docloader.js";
|
6
|
-
import type { Actor } from "../vocab/actor.js";
|
6
|
+
import type { Actor, Recipient } from "../vocab/actor.js";
|
7
7
|
import { Activity, type Object } from "../vocab/mod.js";
|
8
8
|
import type { ActorDispatcher, ActorKeyPairDispatcher, AuthorizePredicate, CollectionCounter, CollectionCursor, CollectionDispatcher, InboxErrorHandler, InboxListener, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectDispatcher, OutboxErrorHandler } from "./callback.js";
|
9
9
|
import type { Context, RequestContext, SendActivityOptions } from "./context.js";
|
@@ -266,7 +266,7 @@ export declare class Federation<TContextData> {
|
|
266
266
|
* @param dispatcher An outbox dispatcher callback to register.
|
267
267
|
* @throws {@link RouterError} Thrown if the path pattern is invalid.
|
268
268
|
*/
|
269
|
-
setOutboxDispatcher(path: `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Activity, TContextData>): CollectionCallbackSetters<TContextData>;
|
269
|
+
setOutboxDispatcher(path: `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Activity, TContextData, void>): CollectionCallbackSetters<TContextData, void>;
|
270
270
|
/**
|
271
271
|
* Registers a following collection dispatcher.
|
272
272
|
* @param path The URI path pattern for the following collection. The syntax
|
@@ -278,7 +278,7 @@ export declare class Federation<TContextData> {
|
|
278
278
|
* callbacks.
|
279
279
|
* @throws {RouterError} Thrown if the path pattern is invalid.
|
280
280
|
*/
|
281
|
-
setFollowingDispatcher(path: `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Actor | URL, TContextData>): CollectionCallbackSetters<TContextData>;
|
281
|
+
setFollowingDispatcher(path: `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Actor | URL, TContextData, void>): CollectionCallbackSetters<TContextData, void>;
|
282
282
|
/**
|
283
283
|
* Registers a followers collection dispatcher.
|
284
284
|
* @param path The URI path pattern for the followers collection. The syntax
|
@@ -290,7 +290,7 @@ export declare class Federation<TContextData> {
|
|
290
290
|
* callbacks.
|
291
291
|
* @throws {@link RouterError} Thrown if the path pattern is invalid.
|
292
292
|
*/
|
293
|
-
setFollowersDispatcher(path: `${string}{handle}${string}`, dispatcher: CollectionDispatcher<
|
293
|
+
setFollowersDispatcher(path: `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Recipient, TContextData, URL>): CollectionCallbackSetters<TContextData, URL>;
|
294
294
|
/**
|
295
295
|
* Assigns the URL path for the inbox and starts setting inbox listeners.
|
296
296
|
*
|
@@ -334,7 +334,7 @@ export declare class Federation<TContextData> {
|
|
334
334
|
sendActivity({ keyId, privateKey }: {
|
335
335
|
keyId: URL;
|
336
336
|
privateKey: dntShim.CryptoKey;
|
337
|
-
}, recipients:
|
337
|
+
}, recipients: Recipient | Recipient[], activity: Activity, { preferSharedInbox, immediate, collectionSync }?: SendActivityInternalOptions): Promise<void>;
|
338
338
|
/**
|
339
339
|
* Handles a request related to federation. If a request is not related to
|
340
340
|
* federation, the `onNotFound` or `onNotAcceptable` callback is called.
|
@@ -438,33 +438,36 @@ export interface ObjectCallbackSetters<TContextData, TObject extends Object, TPa
|
|
438
438
|
}
|
439
439
|
/**
|
440
440
|
* Additional settings for a collection dispatcher.
|
441
|
+
*
|
442
|
+
* @typeParam TContextData The context data to pass to the {@link Context}.
|
443
|
+
* @typeParam TFilter The type of filter for the collection.
|
441
444
|
*/
|
442
|
-
export interface CollectionCallbackSetters<TContextData> {
|
445
|
+
export interface CollectionCallbackSetters<TContextData, TFilter> {
|
443
446
|
/**
|
444
447
|
* Sets the counter for the collection.
|
445
448
|
* @param counter A callback that returns the number of items in the collection.
|
446
449
|
* @returns The setters object so that settings can be chained.
|
447
450
|
*/
|
448
|
-
setCounter(counter: CollectionCounter<TContextData>): CollectionCallbackSetters<TContextData>;
|
451
|
+
setCounter(counter: CollectionCounter<TContextData, TFilter>): CollectionCallbackSetters<TContextData, TFilter>;
|
449
452
|
/**
|
450
453
|
* Sets the first cursor for the collection.
|
451
454
|
* @param cursor The cursor for the first item in the collection.
|
452
455
|
* @returns The setters object so that settings can be chained.
|
453
456
|
*/
|
454
|
-
setFirstCursor(cursor: CollectionCursor<TContextData>): CollectionCallbackSetters<TContextData>;
|
457
|
+
setFirstCursor(cursor: CollectionCursor<TContextData, TFilter>): CollectionCallbackSetters<TContextData, TFilter>;
|
455
458
|
/**
|
456
459
|
* Sets the last cursor for the collection.
|
457
460
|
* @param cursor The cursor for the last item in the collection.
|
458
461
|
* @returns The setters object so that settings can be chained.
|
459
462
|
*/
|
460
|
-
setLastCursor(cursor: CollectionCursor<TContextData>): CollectionCallbackSetters<TContextData>;
|
463
|
+
setLastCursor(cursor: CollectionCursor<TContextData, TFilter>): CollectionCallbackSetters<TContextData, TFilter>;
|
461
464
|
/**
|
462
465
|
* Specifies the conditions under which requests are authorized.
|
463
466
|
* @param predicate A callback that returns whether a request is authorized.
|
464
467
|
* @returns The setters object so that settings can be chained.
|
465
468
|
* @since 0.7.0
|
466
469
|
*/
|
467
|
-
authorize(predicate: AuthorizePredicate<TContextData>): CollectionCallbackSetters<TContextData>;
|
470
|
+
authorize(predicate: AuthorizePredicate<TContextData>): CollectionCallbackSetters<TContextData, TFilter>;
|
468
471
|
}
|
469
472
|
/**
|
470
473
|
* Registry for inbox listeners for different activity types.
|
@@ -487,4 +490,8 @@ export interface InboxListenerSetter<TContextData> {
|
|
487
490
|
*/
|
488
491
|
onError(handler: InboxErrorHandler<TContextData>): InboxListenerSetter<TContextData>;
|
489
492
|
}
|
493
|
+
interface SendActivityInternalOptions extends SendActivityOptions {
|
494
|
+
collectionSync?: string;
|
495
|
+
}
|
496
|
+
export {};
|
490
497
|
//# sourceMappingURL=middleware.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/federation/middleware.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAKjD,OAAO,EACL,KAAK,kCAAkC,EACvC,KAAK,cAAc,EAIpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/federation/middleware.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAKjD,OAAO,EACL,KAAK,kCAAkC,EACvC,KAAK,cAAc,EAIpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,E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O,CAAC,CAAC;IAEpD;;;;;OAKG;IACH,SAAS,CACP,SAAS,EAAE,kBAAkB,CAAC,YAAY,CAAC,GAC1C,yBAAyB,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;CACrD;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB,CAAC,YAAY;IAC/C;;;;;;OAMG;IACH,EAAE,CAAC,SAAS,SAAS,QAAQ,EAE3B,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,SAAS,EACvC,QAAQ,EAAE,aAAa,CAAC,YAAY,EAAE,SAAS,CAAC,GAC/C,mBAAmB,CAAC,YAAY,CAAC,CAAC;IAErC;;;;;;OAMG;IACH,OAAO,CACL,OAAO,EAAE,iBAAiB,CAAC,YAAY,CAAC,GACvC,mBAAmB,CAAC,YAAY,CAAC,CAAC;CACtC;AAED,UAAU,2BAA4B,SAAQ,mBAAmB;IAC/D,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/federation/queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC;IAC/B,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/federation/queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC;IAC/B,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC"}
|
@@ -1,7 +1,8 @@
|
|
1
1
|
/// <reference types="node" />
|
2
|
+
/// <reference types="node" />
|
2
3
|
import * as dntShim from "../_dnt.shims.js";
|
3
4
|
import type { DocumentLoader } from "../runtime/docloader.js";
|
4
|
-
import type {
|
5
|
+
import type { Recipient } from "../vocab/actor.js";
|
5
6
|
import type { Activity } from "../vocab/mod.js";
|
6
7
|
/**
|
7
8
|
* Parameters for {@link extractInboxes}.
|
@@ -10,7 +11,7 @@ export interface ExtractInboxesParameters {
|
|
10
11
|
/**
|
11
12
|
* Actors to extract the inboxes from.
|
12
13
|
*/
|
13
|
-
recipients:
|
14
|
+
recipients: Recipient[];
|
14
15
|
/**
|
15
16
|
* Whether to prefer the shared inbox over the personal inbox.
|
16
17
|
* Defaults to `false`.
|
@@ -21,9 +22,9 @@ export interface ExtractInboxesParameters {
|
|
21
22
|
* Extracts the inbox URLs from recipients.
|
22
23
|
* @param parameters The parameters to extract the inboxes.
|
23
24
|
* See also {@link ExtractInboxesParameters}.
|
24
|
-
* @returns The inbox
|
25
|
+
* @returns The inboxes as a map of inbox URL to actor URIs.
|
25
26
|
*/
|
26
|
-
export declare function extractInboxes({ recipients, preferSharedInbox }: ExtractInboxesParameters): Set<
|
27
|
+
export declare function extractInboxes({ recipients, preferSharedInbox }: ExtractInboxesParameters): Record<string, Set<string>>;
|
27
28
|
/**
|
28
29
|
* Parameters for {@link sendActivity}.
|
29
30
|
*/
|
@@ -48,6 +49,10 @@ export interface SendActivityParameters {
|
|
48
49
|
* The document loader to use for JSON-LD context retrieval.
|
49
50
|
*/
|
50
51
|
documentLoader?: DocumentLoader;
|
52
|
+
/**
|
53
|
+
* Additional headers to include in the request.
|
54
|
+
*/
|
55
|
+
headers?: Headers;
|
51
56
|
}
|
52
57
|
/**
|
53
58
|
* Sends an {@link Activity} to an inbox.
|
@@ -56,5 +61,5 @@ export interface SendActivityParameters {
|
|
56
61
|
* See also {@link SendActivityParameters}.
|
57
62
|
* @throws {Error} If the activity fails to send.
|
58
63
|
*/
|
59
|
-
export declare function sendActivity({ activity, privateKey, keyId, inbox, documentLoader, }: SendActivityParameters): Promise<void>;
|
64
|
+
export declare function sendActivity({ activity, privateKey, keyId, inbox, documentLoader, headers, }: SendActivityParameters): Promise<void>;
|
60
65
|
//# sourceMappingURL=send.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../src/federation/send.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../src/federation/send.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAG5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,UAAU,EAAE,SAAS,EAAE,CAAC;IAExB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,EAAE,UAAU,EAAE,iBAAiB,EAAE,EAAE,wBAAwB,GAC1D,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAY7B;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,QAAQ,EAAE,QAAQ,CAAC;IAEnB;;OAEG;IACH,UAAU,EAAE,OAAO,CAAC,SAAS,CAAC;IAE9B;;OAEG;IACH,KAAK,EAAE,GAAG,CAAC;IAEX;;OAEG;IACH,KAAK,EAAE,GAAG,CAAC;IAEX;;OAEG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,EACE,QAAQ,EACR,UAAU,EACV,KAAK,EACL,KAAK,EACL,cAAc,EACd,OAAO,GACR,EAAE,sBAAsB,GACxB,OAAO,CAAC,IAAI,CAAC,CAmCf"}
|
package/types/httpsig/mod.d.ts
CHANGED
@@ -51,7 +51,7 @@ export declare function doesActorOwnKey(activity: Activity, key: CryptographicKe
|
|
51
51
|
* @param keyId The ID of the key to check, or the key itself.
|
52
52
|
* @param documentLoader The document loader to use for fetching the key and its owner.
|
53
53
|
* @returns The actor that owns the key, or `null` if the key has no known owner.
|
54
|
-
* @
|
54
|
+
* @since 0.7.0
|
55
55
|
*/
|
56
56
|
export declare function getKeyOwner(keyId: URL | CryptographicKey, documentLoader: DocumentLoader): Promise<Actor | null>;
|
57
57
|
//# sourceMappingURL=mod.d.ts.map
|
package/types/mod.d.ts
CHANGED
@@ -28,8 +28,9 @@
|
|
28
28
|
* following resources:
|
29
29
|
*
|
30
30
|
* - [GitHub](https://github.com/dahlia/fedify)
|
31
|
-
* -
|
32
|
-
*
|
31
|
+
* - [Tutorial](https://fedify.dev/tutorial)
|
32
|
+
* - [Manual](https://fedify.dev/manual)
|
33
|
+
* ([Unstable](https://unstable.fedify.dev/manual))
|
33
34
|
* - [Examples](https://github.com/dahlia/fedify/tree/main/examples)
|
34
35
|
*
|
35
36
|
* [ActivityPub]: https://www.w3.org/TR/activitypub/
|
package/types/mod.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/testing/context.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAIxE,wBAAgB,aAAa,CAAC,YAAY,EACxC,EACE,IAAI,EACJ,cAAc,EACd,cAAc,EACd,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,WAAW,EACX,iBAAiB,EACjB,YAAY,GACb,EAAE,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,GAAG;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,GACzD,OAAO,CAAC,YAAY,CAAC,CA2BvB;AAED,wBAAgB,oBAAoB,CAAC,YAAY,EAC/C,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,GAAG;IAC5C,GAAG,EAAE,GAAG,CAAC;IACT,IAAI,EAAE,YAAY,CAAC;CACpB,GACA,cAAc,CAAC,YAAY,CAAC,
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/testing/context.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAIxE,wBAAgB,aAAa,CAAC,YAAY,EACxC,EACE,IAAI,EACJ,cAAc,EACd,cAAc,EACd,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,WAAW,EACX,iBAAiB,EACjB,YAAY,GACb,EAAE,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,GAAG;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,GACzD,OAAO,CAAC,YAAY,CAAC,CA2BvB;AAED,wBAAgB,oBAAoB,CAAC,YAAY,EAC/C,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,GAAG;IAC5C,GAAG,EAAE,GAAG,CAAC;IACT,IAAI,EAAE,YAAY,CAAC;CACpB,GACA,cAAc,CAAC,YAAY,CAAC,CAa9B"}
|
package/types/vocab/actor.d.ts
CHANGED
@@ -50,4 +50,28 @@ export declare function getActorClassByTypeName(typeName: ActorTypeName): typeof
|
|
50
50
|
* @since 0.4.0
|
51
51
|
*/
|
52
52
|
export declare function getActorHandle(actor: Actor | URL): Promise<`@${string}@${string}`>;
|
53
|
+
/**
|
54
|
+
* The object that can be a recipient of an activity.
|
55
|
+
*
|
56
|
+
* Note that every {@link Actor} is also a {@link Recipient}.
|
57
|
+
*/
|
58
|
+
export interface Recipient {
|
59
|
+
/**
|
60
|
+
* The URI of the actor.
|
61
|
+
*/
|
62
|
+
readonly id: URL | null;
|
63
|
+
/**
|
64
|
+
* The URI of the actor's inbox.
|
65
|
+
*/
|
66
|
+
readonly inboxId: URL | null;
|
67
|
+
/**
|
68
|
+
* The endpoints of the actor.
|
69
|
+
*/
|
70
|
+
readonly endpoints?: {
|
71
|
+
/**
|
72
|
+
* The URI of the actor's shared inbox.
|
73
|
+
*/
|
74
|
+
sharedInbox: URL | null;
|
75
|
+
} | null;
|
76
|
+
}
|
53
77
|
//# sourceMappingURL=actor.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"actor.d.ts","sourceRoot":"","sources":["../../src/vocab/actor.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,YAAY,CA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