@fedify/fedify 1.9.0-pr.428.1588 → 1.9.0-pr.431.1597
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actor-CHOM_AN3.d.cts +128 -0
- package/dist/actor-CfaqWvJb.cjs +37783 -0
- package/dist/{actor-CdM_sJLC.js → actor-Detmisdi.js} +190 -190
- package/dist/{actor-ByOSf9n9.js → actor-Dw7av4Zk.js} +1 -1
- package/dist/{authdocloader-VVd0U8Qg.js → authdocloader-5UJ5Gme-.js} +6 -6
- package/dist/authdocloader-BVYv0Ct8.cjs +58 -0
- package/dist/{authdocloader-CfP6lfxM.js → authdocloader-ZlLoXSxM.js} +3 -3
- package/dist/{builder-mfXmda-W.js → builder-BbKfqPmR.js} +4 -4
- package/dist/chunk-DqRYRqnO.cjs +34 -0
- package/dist/{client-DB8N2RwI.js → client-DgRjF0ha.js} +1 -1
- package/dist/client-DjT_tegg.d.cts +294 -0
- package/dist/compat/mod.cjs +10 -0
- package/dist/compat/mod.d.cts +13 -0
- package/dist/compat/mod.js +5 -5
- package/dist/compat/transformers.test.js +16 -16
- package/dist/compat-DmDDELst.cjs +4 -0
- package/dist/compat-nxUqe4Z-.js +4 -0
- package/dist/context-KXVF2AhH.d.cts +2261 -0
- package/dist/{docloader-XJzCMWY-.js → docloader-BKf9RWX4.js} +4 -4
- package/dist/docloader-D-MrRyHl.d.cts +219 -0
- package/dist/docloader-eqgyMp7h.cjs +4682 -0
- package/dist/{esm-BVYQVacR.js → esm-B_ZjJ1sB.js} +1 -1
- package/dist/federation/builder.test.js +5 -5
- package/dist/federation/collection.test.js +3 -3
- package/dist/federation/handler.test.js +17 -17
- package/dist/federation/inbox.test.js +4 -4
- package/dist/federation/keycache.test.js +4 -4
- package/dist/federation/kv.test.js +3 -3
- package/dist/federation/middleware.test.js +18 -18
- package/dist/federation/mod.cjs +29 -0
- package/dist/federation/mod.d.cts +13 -0
- package/dist/federation/mod.js +15 -15
- package/dist/federation/mq.test.js +3 -3
- package/dist/federation/retry.test.js +3 -3
- package/dist/federation/router.test.js +3 -3
- package/dist/federation/send.test.js +10 -10
- package/dist/{federation-CMX7WzeL.js → federation-D1U8YY9t.js} +3 -3
- package/dist/federation-H2_En3j5.cjs +244 -0
- package/dist/http-B_zBcsai.d.cts +253 -0
- package/dist/{http-B_bBrm6N.js → http-C5XLveZw.js} +2 -2
- package/dist/{http-DYB4M8Pr.js → http-CwlUFNG4.js} +6 -6
- package/dist/http-_vjuGcXn.cjs +826 -0
- package/dist/{inbox-B4k2JQpE.js → inbox-sVXiVBbT.js} +1 -1
- package/dist/key-19P2dWvf.cjs +290 -0
- package/dist/{key-BdBFUTr5.js → key-BCWvPOkD.js} +5 -5
- package/dist/key-CsQ7J8-m.js +10 -0
- package/dist/key-Dt7qJaQT.cjs +10 -0
- package/dist/{key-feGm-IP3.js → key-Jrnr66vx.js} +2 -2
- package/dist/{key-BcVEPl--.js → key-lpATOAE4.js} +3 -3
- package/dist/{keycache-b7FYgzB9.js → keycache-ogQInQck.js} +1 -1
- package/dist/{keys-B7uX1KoX.js → keys-DcGsKtHW.js} +1 -1
- package/dist/kv-63Cil1MD.d.cts +81 -0
- package/dist/{ld-DJCemZO2.js → ld-BSE4jnyK.js} +2 -2
- package/dist/lookup-D96ipStp.cjs +137 -0
- package/dist/{lookup-CIsbr_Qi.js → lookup-D_-F1hLw.js} +4 -4
- package/dist/{lookup-CXaZBmuy.js → lookup-DdxOle8f.js} +1 -1
- package/dist/middleware-B0f850Ei.cjs +17 -0
- package/dist/middleware-B2DFqtJ-.cjs +4240 -0
- package/dist/middleware-COHAbwGs.js +17 -0
- package/dist/{middleware-D5JRdsEc.js → middleware-CuTcPjfP.js} +13 -13
- package/dist/middleware-Dt7C7qpw.js +26 -0
- package/dist/{middleware-e_Gw7sQy.js → middleware-T_y4Bnvw.js} +14 -14
- package/dist/mod-C2tOeRkN.d.cts +1 -0
- package/dist/mod-C3CGxYoF.d.cts +102 -0
- package/dist/mod-COw_caPC.d.cts +266 -0
- package/dist/mod-FZd39qVq.d.cts +1 -0
- package/dist/mod-NKH_G-IY.d.cts +289 -0
- package/dist/mod-YfAcrVbP.d.cts +80 -0
- package/dist/mod-jQ4OODsl.d.cts +113 -0
- package/dist/mod.cjs +152 -0
- package/dist/mod.d.cts +17 -0
- package/dist/mod.js +20 -20
- package/dist/mq-B7R1Q-M5.d.cts +140 -0
- package/dist/nodeinfo/client.test.js +5 -5
- package/dist/nodeinfo/handler.test.js +16 -16
- package/dist/nodeinfo/mod.cjs +13 -0
- package/dist/nodeinfo/mod.d.cts +5 -0
- package/dist/nodeinfo/mod.js +6 -6
- package/dist/nodeinfo/semver.test.js +3 -3
- package/dist/nodeinfo/types.test.js +3 -3
- package/dist/nodeinfo-Co9lJrWl.cjs +4 -0
- package/dist/nodeinfo-DfycQ8Wf.js +4 -0
- package/dist/owner-C9Ry0TOI.d.cts +67 -0
- package/dist/{owner-i9FkgZwa.js → owner-DJtc8evi.js} +2 -2
- package/dist/{proof-Bvtdd-Ul.js → proof-9OMp0o4n.js} +2 -2
- package/dist/{proof-DKGUTtBt.js → proof-BuPk23Er.js} +6 -6
- package/dist/proof-CRHppbRk.cjs +673 -0
- package/dist/runtime/authdocloader.test.js +9 -9
- package/dist/runtime/docloader.test.js +4 -4
- package/dist/runtime/key.test.js +5 -5
- package/dist/runtime/langstr.test.js +3 -3
- package/dist/runtime/mod.cjs +25 -0
- package/dist/runtime/mod.d.cts +6 -0
- package/dist/runtime/mod.js +10 -10
- package/dist/runtime/multibase/multibase.test.js +3 -3
- package/dist/runtime/url.test.js +3 -3
- package/dist/runtime-C58AJWSv.cjs +4 -0
- package/dist/runtime-DPYEDf-o.js +4 -0
- package/dist/{send-Cuw-wTCx.js → send-cXerEJm9.js} +2 -2
- package/dist/sig/http.test.js +8 -8
- package/dist/sig/key.test.js +6 -6
- package/dist/sig/ld.test.js +7 -7
- package/dist/sig/mod.cjs +30 -0
- package/dist/sig/mod.d.cts +8 -0
- package/dist/sig/mod.js +10 -10
- package/dist/sig/owner.test.js +7 -7
- package/dist/sig/proof.test.js +7 -7
- package/dist/sig-ByHXzqUi.cjs +4 -0
- package/dist/sig-Cj3tk-ig.js +4 -0
- package/dist/testing/docloader.test.js +3 -3
- package/dist/testing/mod.js +3 -3
- package/dist/{testing-DUFWSgSt.js → testing-BX6IA3LR.js} +2 -2
- package/dist/{transformers-Dna8Fg7k.js → transformers-BFT6d7J5.js} +3 -3
- package/dist/transformers-CoBS-oFG.cjs +116 -0
- package/dist/{type-DDwsy8fI.js → type-DF9yoIpt.js} +186 -186
- package/dist/types-DcKQIzdO.cjs +488 -0
- package/dist/{types-CuvNqe2X.js → types-Q17QxOOC.js} +4 -4
- package/dist/vocab/actor.test.js +5 -5
- package/dist/vocab/lookup.test.js +4 -4
- package/dist/vocab/mod.cjs +87 -0
- package/dist/vocab/mod.d.cts +6 -0
- package/dist/vocab/mod.js +7 -7
- package/dist/vocab/type.test.js +3 -3
- package/dist/vocab/vocab.test.js +4 -4
- package/dist/{vocab-CEXwobaS.js → vocab-BUc_4ZsW.js} +6 -6
- package/dist/vocab-BzGg7ltX.d.cts +14629 -0
- package/dist/vocab-Du8FV6H1.cjs +282 -0
- package/dist/webfinger/handler.test.js +16 -16
- package/dist/webfinger/lookup.test.js +4 -4
- package/dist/webfinger/mod.cjs +9 -0
- package/dist/webfinger/mod.d.cts +4 -0
- package/dist/webfinger/mod.js +6 -6
- package/dist/webfinger-BjOEdFPs.cjs +4 -0
- package/dist/webfinger-De_bU0iE.js +4 -0
- package/dist/x/cfworkers.cjs +100 -0
- package/dist/x/cfworkers.d.cts +59 -0
- package/dist/x/cfworkers.js +3 -3
- package/dist/x/cfworkers.test.js +3 -3
- package/dist/x/hono.cjs +61 -0
- package/dist/x/hono.d.cts +54 -0
- package/dist/x/hono.js +3 -3
- package/dist/x/sveltekit.cjs +69 -0
- package/dist/x/sveltekit.d.cts +46 -0
- package/dist/x/sveltekit.js +3 -3
- package/package.json +68 -12
- package/dist/compat-Bb5myD13.js +0 -4
- package/dist/key-0hFXQUQz.js +0 -10
- package/dist/middleware-BhQdOVAF.js +0 -17
- package/dist/middleware-DVy3ms0C.js +0 -26
- package/dist/nodeinfo-CyEbLjHs.js +0 -4
- package/dist/runtime-BSkOVUWM.js +0 -4
- package/dist/sig-BXJO--F9.js +0 -4
- package/dist/webfinger-C3GIyXIg.js +0 -4
@@ -0,0 +1,282 @@
|
|
1
|
+
|
2
|
+
const { Temporal } = require("@js-temporal/polyfill");
|
3
|
+
const { URLPattern } = require("urlpattern-polyfill");
|
4
|
+
|
5
|
+
const require_chunk = require('./chunk-DqRYRqnO.cjs');
|
6
|
+
const require_docloader = require('./docloader-eqgyMp7h.cjs');
|
7
|
+
const require_actor = require('./actor-CfaqWvJb.cjs');
|
8
|
+
const require_lookup = require('./lookup-D96ipStp.cjs');
|
9
|
+
const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
|
10
|
+
const __opentelemetry_api = require_chunk.__toESM(require("@opentelemetry/api"));
|
11
|
+
const es_toolkit = require_chunk.__toESM(require("es-toolkit"));
|
12
|
+
|
13
|
+
//#region src/vocab/handle.ts
|
14
|
+
/**
|
15
|
+
* Regular expression to match a fediverse handle in the format `@user@server`
|
16
|
+
* or `user@server`. The `user` part can contain alphanumeric characters and
|
17
|
+
* some special characters except `@`. The `server` part is all characters
|
18
|
+
* after the `@` symbol in the middle.
|
19
|
+
*/
|
20
|
+
const handleRegexp = /^@?((?:[-A-Za-z0-9._~!$&'()*+,;=]|%[A-Fa-f0-9]{2})+)@([^@]+)$/;
|
21
|
+
/**
|
22
|
+
* Parses a fediverse handle in the format `@user@server` or `user@server`.
|
23
|
+
* The `user` part can contain alphanumeric characters and some special
|
24
|
+
* characters except `@`. The `server` part is all characters after the `@`
|
25
|
+
* symbol in the middle.
|
26
|
+
*
|
27
|
+
* @example
|
28
|
+
* ```typescript
|
29
|
+
* const handle = parseFediverseHandle("@username@example.com");
|
30
|
+
* console.log(handle?.username); // "username"
|
31
|
+
* console.log(handle?.host); // "example.com"
|
32
|
+
* ```
|
33
|
+
*
|
34
|
+
* @param handle - The fediverse handle string to parse.
|
35
|
+
* @returns A {@link FediverseHandle} object with `username` and `host`
|
36
|
+
* if the input is valid; otherwise `null`.
|
37
|
+
* @since 1.8.0
|
38
|
+
*/
|
39
|
+
function parseFediverseHandle(handle) {
|
40
|
+
const match = handleRegexp.exec(handle);
|
41
|
+
if (match) return {
|
42
|
+
username: match[1],
|
43
|
+
host: match[2]
|
44
|
+
};
|
45
|
+
return null;
|
46
|
+
}
|
47
|
+
/**
|
48
|
+
* Checks if a string is a valid fediverse handle in the format `@user@server`
|
49
|
+
* or `user@server`. The `user` part can contain alphanumeric characters and
|
50
|
+
* some special characters except `@`. The `server` part is all characters
|
51
|
+
* after the `@` symbol in the middle.
|
52
|
+
*
|
53
|
+
* @example
|
54
|
+
* ```typescript
|
55
|
+
* console.log(isFediverseHandle("@username@example.com")); // true
|
56
|
+
* console.log(isFediverseHandle("username@example.com")); // true
|
57
|
+
* console.log(isFediverseHandle("@username@")); // false
|
58
|
+
* ```
|
59
|
+
*
|
60
|
+
* @param handle - The string to test as a fediverse handle.
|
61
|
+
* @returns `true` if the string matches the fediverse handle pattern;
|
62
|
+
* otherwise `false`.
|
63
|
+
* @since 1.8.0
|
64
|
+
*/
|
65
|
+
function isFediverseHandle(handle) {
|
66
|
+
return handleRegexp.test(handle);
|
67
|
+
}
|
68
|
+
/**
|
69
|
+
* Converts a fediverse handle in the format `@user@server` or `user@server`
|
70
|
+
* to an `acct:` URI, which is a URL-like identifier for ActivityPub actors.
|
71
|
+
*
|
72
|
+
* @example
|
73
|
+
* ```typescript
|
74
|
+
* const identifier = toAcctUrl("@username@example.com");
|
75
|
+
* console.log(identifier?.href); // "acct:username@example.com"
|
76
|
+
* ```
|
77
|
+
*
|
78
|
+
* @param handle - The fediverse handle string to convert.
|
79
|
+
* @returns A `URL` object representing the `acct:` URI if conversion succeeds;
|
80
|
+
* otherwise `null`.
|
81
|
+
* @since 1.8.0
|
82
|
+
*/
|
83
|
+
function toAcctUrl(handle) {
|
84
|
+
const parsed = parseFediverseHandle(handle);
|
85
|
+
if (!parsed) return null;
|
86
|
+
const identifier = new URL(`acct:${parsed.username}@${parsed.host}`);
|
87
|
+
return identifier;
|
88
|
+
}
|
89
|
+
|
90
|
+
//#endregion
|
91
|
+
//#region src/vocab/lookup.ts
|
92
|
+
const logger = (0, __logtape_logtape.getLogger)([
|
93
|
+
"fedify",
|
94
|
+
"vocab",
|
95
|
+
"lookup"
|
96
|
+
]);
|
97
|
+
/**
|
98
|
+
* Looks up an ActivityStreams object by its URI (including `acct:` URIs)
|
99
|
+
* or a fediverse handle (e.g., `@user@server` or `user@server`).
|
100
|
+
*
|
101
|
+
* @example
|
102
|
+
* ``` typescript
|
103
|
+
* // Look up an actor by its fediverse handle:
|
104
|
+
* await lookupObject("@hongminhee@fosstodon.org");
|
105
|
+
* // returning a `Person` object.
|
106
|
+
*
|
107
|
+
* // A fediverse handle can omit the leading '@':
|
108
|
+
* await lookupObject("hongminhee@fosstodon.org");
|
109
|
+
* // returning a `Person` object.
|
110
|
+
*
|
111
|
+
* // A `acct:` URI can be used as well:
|
112
|
+
* await lookupObject("acct:hongminhee@fosstodon.org");
|
113
|
+
* // returning a `Person` object.
|
114
|
+
*
|
115
|
+
* // Look up an object by its URI:
|
116
|
+
* await lookupObject("https://todon.eu/@hongminhee/112060633798771581");
|
117
|
+
* // returning a `Note` object.
|
118
|
+
*
|
119
|
+
* // It can be a `URL` object as well:
|
120
|
+
* await lookupObject(new URL("https://todon.eu/@hongminhee/112060633798771581"));
|
121
|
+
* // returning a `Note` object.
|
122
|
+
* ```
|
123
|
+
*
|
124
|
+
* @param identifier The URI or fediverse handle to look up.
|
125
|
+
* @param options Lookup options.
|
126
|
+
* @returns The object, or `null` if not found.
|
127
|
+
* @since 0.2.0
|
128
|
+
*/
|
129
|
+
async function lookupObject(identifier, options = {}) {
|
130
|
+
const tracerProvider = options.tracerProvider ?? __opentelemetry_api.trace.getTracerProvider();
|
131
|
+
const tracer = tracerProvider.getTracer(require_docloader.deno_default.name, require_docloader.deno_default.version);
|
132
|
+
return await tracer.startActiveSpan("activitypub.lookup_object", async (span) => {
|
133
|
+
try {
|
134
|
+
const result = await lookupObjectInternal(identifier, options);
|
135
|
+
if (result == null) span.setStatus({ code: __opentelemetry_api.SpanStatusCode.ERROR });
|
136
|
+
else {
|
137
|
+
if (result.id != null) span.setAttribute("activitypub.object.id", result.id.href);
|
138
|
+
span.setAttribute("activitypub.object.type", require_actor.getTypeId(result).href);
|
139
|
+
if (result.replyTargetIds.length > 0) span.setAttribute("activitypub.object.in_reply_to", result.replyTargetIds.map((id) => id.href));
|
140
|
+
}
|
141
|
+
return result;
|
142
|
+
} catch (error) {
|
143
|
+
span.setStatus({
|
144
|
+
code: __opentelemetry_api.SpanStatusCode.ERROR,
|
145
|
+
message: String(error)
|
146
|
+
});
|
147
|
+
throw error;
|
148
|
+
} finally {
|
149
|
+
span.end();
|
150
|
+
}
|
151
|
+
});
|
152
|
+
}
|
153
|
+
async function lookupObjectInternal(identifier, options = {}) {
|
154
|
+
const documentLoader = options.documentLoader ?? require_docloader.getDocumentLoader({ userAgent: options.userAgent });
|
155
|
+
if (typeof identifier === "string") identifier = toAcctUrl(identifier) ?? new URL(identifier);
|
156
|
+
let document = null;
|
157
|
+
if (identifier.protocol === "http:" || identifier.protocol === "https:") try {
|
158
|
+
const remoteDoc = await documentLoader(identifier.href, { signal: options.signal });
|
159
|
+
document = remoteDoc.document;
|
160
|
+
} catch (error) {
|
161
|
+
logger.debug("Failed to fetch remote document:\n{error}", { error });
|
162
|
+
}
|
163
|
+
if (document == null) {
|
164
|
+
const jrd = await require_lookup.lookupWebFinger(identifier, {
|
165
|
+
userAgent: options.userAgent,
|
166
|
+
tracerProvider: options.tracerProvider,
|
167
|
+
allowPrivateAddress: "allowPrivateAddress" in options && options.allowPrivateAddress === true,
|
168
|
+
signal: options.signal
|
169
|
+
});
|
170
|
+
if (jrd?.links == null) return null;
|
171
|
+
for (const l of jrd.links) {
|
172
|
+
if (l.type !== "application/activity+json" && !l.type?.match(/application\/ld\+json;\s*profile="https:\/\/www.w3.org\/ns\/activitystreams"/) || l.rel !== "self" || l.href == null) continue;
|
173
|
+
try {
|
174
|
+
const remoteDoc = await documentLoader(l.href, { signal: options.signal });
|
175
|
+
document = remoteDoc.document;
|
176
|
+
break;
|
177
|
+
} catch (error) {
|
178
|
+
logger.debug("Failed to fetch remote document:\n{error}", { error });
|
179
|
+
continue;
|
180
|
+
}
|
181
|
+
}
|
182
|
+
}
|
183
|
+
if (document == null) return null;
|
184
|
+
try {
|
185
|
+
return await require_actor.Object.fromJsonLd(document, {
|
186
|
+
documentLoader,
|
187
|
+
contextLoader: options.contextLoader,
|
188
|
+
tracerProvider: options.tracerProvider
|
189
|
+
});
|
190
|
+
} catch (error) {
|
191
|
+
if (error instanceof TypeError) {
|
192
|
+
logger.debug("Failed to parse JSON-LD document: {error}\n{document}", {
|
193
|
+
error,
|
194
|
+
document
|
195
|
+
});
|
196
|
+
return null;
|
197
|
+
}
|
198
|
+
throw error;
|
199
|
+
}
|
200
|
+
}
|
201
|
+
/**
|
202
|
+
* Traverses a collection, yielding each item in the collection.
|
203
|
+
* If the collection is paginated, it will fetch the next page
|
204
|
+
* automatically.
|
205
|
+
*
|
206
|
+
* @example
|
207
|
+
* ``` typescript
|
208
|
+
* const collection = await lookupObject(collectionUrl);
|
209
|
+
* if (collection instanceof Collection) {
|
210
|
+
* for await (const item of traverseCollection(collection)) {
|
211
|
+
* console.log(item.id?.href);
|
212
|
+
* }
|
213
|
+
* }
|
214
|
+
* ```
|
215
|
+
*
|
216
|
+
* @param collection The collection to traverse.
|
217
|
+
* @param options Options for traversing the collection.
|
218
|
+
* @returns An async iterable of each item in the collection.
|
219
|
+
* @since 1.1.0
|
220
|
+
*/
|
221
|
+
async function* traverseCollection(collection, options = {}) {
|
222
|
+
if (collection.firstId == null) for await (const item of collection.getItems(options)) yield item;
|
223
|
+
else {
|
224
|
+
const interval = Temporal.Duration.from(options.interval ?? { seconds: 0 }).total("millisecond");
|
225
|
+
let page = await collection.getFirst(options);
|
226
|
+
while (page != null) {
|
227
|
+
for await (const item of page.getItems(options)) yield item;
|
228
|
+
if (interval > 0) await (0, es_toolkit.delay)(interval);
|
229
|
+
page = await page.getNext(options);
|
230
|
+
}
|
231
|
+
}
|
232
|
+
}
|
233
|
+
|
234
|
+
//#endregion
|
235
|
+
//#region src/vocab/constants.ts
|
236
|
+
/**
|
237
|
+
* The special public collection for [public addressing]. *Do not mutate this
|
238
|
+
* object.*
|
239
|
+
*
|
240
|
+
* [public addressing]: https://www.w3.org/TR/activitypub/#public-addressing
|
241
|
+
*
|
242
|
+
* @since 0.7.0
|
243
|
+
*/
|
244
|
+
const PUBLIC_COLLECTION = new URL("https://www.w3.org/ns/activitystreams#Public");
|
245
|
+
|
246
|
+
//#endregion
|
247
|
+
Object.defineProperty(exports, 'PUBLIC_COLLECTION', {
|
248
|
+
enumerable: true,
|
249
|
+
get: function () {
|
250
|
+
return PUBLIC_COLLECTION;
|
251
|
+
}
|
252
|
+
});
|
253
|
+
Object.defineProperty(exports, 'isFediverseHandle', {
|
254
|
+
enumerable: true,
|
255
|
+
get: function () {
|
256
|
+
return isFediverseHandle;
|
257
|
+
}
|
258
|
+
});
|
259
|
+
Object.defineProperty(exports, 'lookupObject', {
|
260
|
+
enumerable: true,
|
261
|
+
get: function () {
|
262
|
+
return lookupObject;
|
263
|
+
}
|
264
|
+
});
|
265
|
+
Object.defineProperty(exports, 'parseFediverseHandle', {
|
266
|
+
enumerable: true,
|
267
|
+
get: function () {
|
268
|
+
return parseFediverseHandle;
|
269
|
+
}
|
270
|
+
});
|
271
|
+
Object.defineProperty(exports, 'toAcctUrl', {
|
272
|
+
enumerable: true,
|
273
|
+
get: function () {
|
274
|
+
return toAcctUrl;
|
275
|
+
}
|
276
|
+
});
|
277
|
+
Object.defineProperty(exports, 'traverseCollection', {
|
278
|
+
enumerable: true,
|
279
|
+
get: function () {
|
280
|
+
return traverseCollection;
|
281
|
+
}
|
282
|
+
});
|
@@ -3,30 +3,30 @@
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
4
4
|
globalThis.addEventListener = () => {};
|
5
5
|
|
6
|
-
import { Image, Link, Person } from "../type-
|
6
|
+
import { Image, Link, Person } from "../type-DF9yoIpt.js";
|
7
7
|
import { assertEquals } from "../assert_equals-DSbWqCm3.js";
|
8
8
|
import "../assert-MZs1qjMx.js";
|
9
9
|
import "../assert_instance_of-DHz7EHNU.js";
|
10
10
|
import { MemoryKvStore } from "../kv-CRZrzyXm.js";
|
11
|
-
import { createFederation, handleWebFinger } from "../middleware-
|
11
|
+
import { createFederation, handleWebFinger } from "../middleware-CuTcPjfP.js";
|
12
12
|
import "../semver-dArNLkR9.js";
|
13
|
-
import "../client-
|
14
|
-
import "../lookup-
|
13
|
+
import "../client-DgRjF0ha.js";
|
14
|
+
import "../lookup-DdxOle8f.js";
|
15
15
|
import "../types-BIgY6c-l.js";
|
16
|
-
import "../actor-
|
17
|
-
import "../key-
|
18
|
-
import "../http-
|
19
|
-
import "../authdocloader-
|
20
|
-
import "../ld-
|
21
|
-
import "../owner-
|
22
|
-
import "../proof-
|
23
|
-
import "../inbox-
|
24
|
-
import "../builder-
|
16
|
+
import "../actor-Dw7av4Zk.js";
|
17
|
+
import "../key-Jrnr66vx.js";
|
18
|
+
import "../http-C5XLveZw.js";
|
19
|
+
import "../authdocloader-ZlLoXSxM.js";
|
20
|
+
import "../ld-BSE4jnyK.js";
|
21
|
+
import "../owner-DJtc8evi.js";
|
22
|
+
import "../proof-9OMp0o4n.js";
|
23
|
+
import "../inbox-sVXiVBbT.js";
|
24
|
+
import "../builder-BbKfqPmR.js";
|
25
25
|
import "../collection-CSzG2j1P.js";
|
26
|
-
import "../keycache-
|
26
|
+
import "../keycache-ogQInQck.js";
|
27
27
|
import "../retry-D4GJ670a.js";
|
28
|
-
import "../send-
|
29
|
-
import { createRequestContext, test } from "../testing-
|
28
|
+
import "../send-cXerEJm9.js";
|
29
|
+
import { createRequestContext, test } from "../testing-BX6IA3LR.js";
|
30
30
|
import "../std__assert-X-_kMxKM.js";
|
31
31
|
import "../assert_rejects-DiIiJbZn.js";
|
32
32
|
import "../assert_is_error-BPGph1Jx.js";
|
@@ -3,18 +3,18 @@
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
4
4
|
globalThis.addEventListener = () => {};
|
5
5
|
|
6
|
-
import { lookupWebFinger } from "../type-
|
6
|
+
import { lookupWebFinger } from "../type-DF9yoIpt.js";
|
7
7
|
import { assertEquals } from "../assert_equals-DSbWqCm3.js";
|
8
8
|
import "../assert-MZs1qjMx.js";
|
9
9
|
import "../assert_instance_of-DHz7EHNU.js";
|
10
|
-
import "../lookup-
|
11
|
-
import { test } from "../testing-
|
10
|
+
import "../lookup-DdxOle8f.js";
|
11
|
+
import { test } from "../testing-BX6IA3LR.js";
|
12
12
|
import "../std__assert-X-_kMxKM.js";
|
13
13
|
import "../assert_rejects-DiIiJbZn.js";
|
14
14
|
import "../assert_is_error-BPGph1Jx.js";
|
15
15
|
import "../assert_not_equals-f3m3epl3.js";
|
16
16
|
import "../assert_throws-BOO88avQ.js";
|
17
|
-
import { esm_default } from "../esm-
|
17
|
+
import { esm_default } from "../esm-B_ZjJ1sB.js";
|
18
18
|
import { withTimeout } from "es-toolkit";
|
19
19
|
|
20
20
|
//#region src/webfinger/lookup.test.ts
|
@@ -0,0 +1,9 @@
|
|
1
|
+
|
2
|
+
const { Temporal } = require("@js-temporal/polyfill");
|
3
|
+
const { URLPattern } = require("urlpattern-polyfill");
|
4
|
+
|
5
|
+
require('../docloader-eqgyMp7h.cjs');
|
6
|
+
const require_lookup = require('../lookup-D96ipStp.cjs');
|
7
|
+
require('../webfinger-BjOEdFPs.cjs');
|
8
|
+
|
9
|
+
exports.lookupWebFinger = require_lookup.lookupWebFinger;
|
package/dist/webfinger/mod.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
import "../docloader-
|
6
|
-
import { lookupWebFinger } from "../lookup-
|
7
|
-
import "../webfinger-
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
4
|
+
|
5
|
+
import "../docloader-BKf9RWX4.js";
|
6
|
+
import { lookupWebFinger } from "../lookup-D_-F1hLw.js";
|
7
|
+
import "../webfinger-De_bU0iE.js";
|
8
8
|
|
9
9
|
export { lookupWebFinger };
|
@@ -0,0 +1,100 @@
|
|
1
|
+
|
2
|
+
const { Temporal } = require("@js-temporal/polyfill");
|
3
|
+
const { URLPattern } = require("urlpattern-polyfill");
|
4
|
+
|
5
|
+
const require_chunk = require('../chunk-DqRYRqnO.cjs');
|
6
|
+
const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
|
7
|
+
|
8
|
+
//#region src/x/cfworkers.ts
|
9
|
+
/**
|
10
|
+
* Implementation of the {@link KvStore} interface for Cloudflare Workers KV
|
11
|
+
* binding. This class provides a wrapper around Cloudflare's KV namespace to
|
12
|
+
* store and retrieve JSON-serializable values using structured keys.
|
13
|
+
*
|
14
|
+
* Note that this implementation does not support the {@link KvStore.cas}
|
15
|
+
* operation, as Cloudflare Workers KV does not support atomic compare-and-swap
|
16
|
+
* operations. If you need this functionality, consider using a different
|
17
|
+
* key–value store that supports atomic operations.
|
18
|
+
*
|
19
|
+
* @deprecated This class has been moved to `@fedify/cfworkers` package.
|
20
|
+
* Import `WorkersKvStore` from `@fedify/cfworkers` instead.
|
21
|
+
* This class will be removed in Fedify v2.0.
|
22
|
+
* @since 1.6.0
|
23
|
+
*/
|
24
|
+
var WorkersKvStore = class {
|
25
|
+
#namespace;
|
26
|
+
constructor(namespace) {
|
27
|
+
const logger = (0, __logtape_logtape.getLogger)(["fedify", "cfworkers"]);
|
28
|
+
logger.warn("The `@fedify/fedify/x/cfworkers` module is deprecated; use `WorkersKvStore` from `@fedify/cfworkers` package instead.");
|
29
|
+
this.#namespace = namespace;
|
30
|
+
}
|
31
|
+
#encodeKey(key) {
|
32
|
+
return JSON.stringify(key);
|
33
|
+
}
|
34
|
+
async get(key) {
|
35
|
+
const encodedKey = this.#encodeKey(key);
|
36
|
+
const { value, metadata } = await this.#namespace.getWithMetadata(encodedKey, "json");
|
37
|
+
return metadata == null || metadata.expires < Date.now() ? void 0 : value;
|
38
|
+
}
|
39
|
+
async set(key, value, options) {
|
40
|
+
const encodedKey = this.#encodeKey(key);
|
41
|
+
const metadata = options?.ttl == null ? {} : { expires: Date.now() + options.ttl.total("milliseconds") };
|
42
|
+
await this.#namespace.put(encodedKey, JSON.stringify(value), options?.ttl == null ? { metadata } : {
|
43
|
+
expirationTtl: Math.max(options.ttl.total("seconds"), 60),
|
44
|
+
metadata
|
45
|
+
});
|
46
|
+
}
|
47
|
+
delete(key) {
|
48
|
+
return this.#namespace.delete(this.#encodeKey(key));
|
49
|
+
}
|
50
|
+
};
|
51
|
+
/**
|
52
|
+
* Implementation of the {@link MessageQueue} interface for Cloudflare
|
53
|
+
* Workers Queues binding. This class provides a wrapper around Cloudflare's
|
54
|
+
* Queues to send messages to a queue.
|
55
|
+
*
|
56
|
+
* Note that this implementation does not support the `listen()` method,
|
57
|
+
* as Cloudflare Workers Queues do not support message consumption in the same
|
58
|
+
* way as other message queue systems. Instead, you should use
|
59
|
+
* the {@link Federation.processQueuedTask} method to process messages
|
60
|
+
* passed to the queue.
|
61
|
+
*
|
62
|
+
* @deprecated This class has been moved to `@fedify/cfworkers` package.
|
63
|
+
* Import `WorkersMessageQueue` from `@fedify/cfworkers` instead.
|
64
|
+
* This class will be removed in Fedify v2.0.
|
65
|
+
* @since 1.6.0
|
66
|
+
*/
|
67
|
+
var WorkersMessageQueue = class {
|
68
|
+
#queue;
|
69
|
+
/**
|
70
|
+
* Cloudflare Queues provide automatic retry with exponential backoff
|
71
|
+
* and Dead Letter Queues.
|
72
|
+
* @since 1.7.0
|
73
|
+
*/
|
74
|
+
nativeRetrial = true;
|
75
|
+
constructor(queue) {
|
76
|
+
const logger = (0, __logtape_logtape.getLogger)(["fedify", "cfworkers"]);
|
77
|
+
logger.warn("The `@fedify/fedify/x/cfworkers` module is deprecated; use `WorkersMessageQueue` from `@fedify/cfworkers` package instead.");
|
78
|
+
this.#queue = queue;
|
79
|
+
}
|
80
|
+
enqueue(message, options) {
|
81
|
+
return this.#queue.send(message, {
|
82
|
+
contentType: "json",
|
83
|
+
delaySeconds: options?.delay?.total("seconds") ?? 0
|
84
|
+
});
|
85
|
+
}
|
86
|
+
enqueueMany(messages, options) {
|
87
|
+
const requests = messages.map((msg) => ({
|
88
|
+
body: msg,
|
89
|
+
contentType: "json"
|
90
|
+
}));
|
91
|
+
return this.#queue.sendBatch(requests, { delaySeconds: options?.delay?.total("seconds") ?? 0 });
|
92
|
+
}
|
93
|
+
listen(_handler, _options) {
|
94
|
+
throw new TypeError("WorkersMessageQueue does not support listen(). Use Federation.processQueuedTask() method instead.");
|
95
|
+
}
|
96
|
+
};
|
97
|
+
|
98
|
+
//#endregion
|
99
|
+
exports.WorkersKvStore = WorkersKvStore;
|
100
|
+
exports.WorkersMessageQueue = WorkersMessageQueue;
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import { KvKey, KvStore, KvStoreSetOptions } from "../kv-63Cil1MD.cjs";
|
2
|
+
import { MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions } from "../mq-B7R1Q-M5.cjs";
|
3
|
+
import { KVNamespace, Queue } from "@cloudflare/workers-types/experimental";
|
4
|
+
|
5
|
+
//#region src/x/cfworkers.d.ts
|
6
|
+
|
7
|
+
/**
|
8
|
+
* Implementation of the {@link KvStore} interface for Cloudflare Workers KV
|
9
|
+
* binding. This class provides a wrapper around Cloudflare's KV namespace to
|
10
|
+
* store and retrieve JSON-serializable values using structured keys.
|
11
|
+
*
|
12
|
+
* Note that this implementation does not support the {@link KvStore.cas}
|
13
|
+
* operation, as Cloudflare Workers KV does not support atomic compare-and-swap
|
14
|
+
* operations. If you need this functionality, consider using a different
|
15
|
+
* key–value store that supports atomic operations.
|
16
|
+
*
|
17
|
+
* @deprecated This class has been moved to `@fedify/cfworkers` package.
|
18
|
+
* Import `WorkersKvStore` from `@fedify/cfworkers` instead.
|
19
|
+
* This class will be removed in Fedify v2.0.
|
20
|
+
* @since 1.6.0
|
21
|
+
*/
|
22
|
+
declare class WorkersKvStore implements KvStore {
|
23
|
+
#private;
|
24
|
+
constructor(namespace: KVNamespace<string>);
|
25
|
+
get<T = unknown>(key: KvKey): Promise<T | undefined>;
|
26
|
+
set(key: KvKey, value: unknown, options?: KvStoreSetOptions): Promise<void>;
|
27
|
+
delete(key: KvKey): Promise<void>;
|
28
|
+
}
|
29
|
+
/**
|
30
|
+
* Implementation of the {@link MessageQueue} interface for Cloudflare
|
31
|
+
* Workers Queues binding. This class provides a wrapper around Cloudflare's
|
32
|
+
* Queues to send messages to a queue.
|
33
|
+
*
|
34
|
+
* Note that this implementation does not support the `listen()` method,
|
35
|
+
* as Cloudflare Workers Queues do not support message consumption in the same
|
36
|
+
* way as other message queue systems. Instead, you should use
|
37
|
+
* the {@link Federation.processQueuedTask} method to process messages
|
38
|
+
* passed to the queue.
|
39
|
+
*
|
40
|
+
* @deprecated This class has been moved to `@fedify/cfworkers` package.
|
41
|
+
* Import `WorkersMessageQueue` from `@fedify/cfworkers` instead.
|
42
|
+
* This class will be removed in Fedify v2.0.
|
43
|
+
* @since 1.6.0
|
44
|
+
*/
|
45
|
+
declare class WorkersMessageQueue implements MessageQueue {
|
46
|
+
#private;
|
47
|
+
/**
|
48
|
+
* Cloudflare Queues provide automatic retry with exponential backoff
|
49
|
+
* and Dead Letter Queues.
|
50
|
+
* @since 1.7.0
|
51
|
+
*/
|
52
|
+
readonly nativeRetrial = true;
|
53
|
+
constructor(queue: Queue);
|
54
|
+
enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
|
55
|
+
enqueueMany(messages: any[], options?: MessageQueueEnqueueOptions): Promise<void>;
|
56
|
+
listen(_handler: (message: any) => Promise<void> | void, _options?: MessageQueueListenOptions): Promise<void>;
|
57
|
+
}
|
58
|
+
//#endregion
|
59
|
+
export { WorkersKvStore, WorkersMessageQueue };
|
package/dist/x/cfworkers.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
4
|
+
|
5
5
|
import { getLogger } from "@logtape/logtape";
|
6
6
|
|
7
7
|
//#region src/x/cfworkers.ts
|
package/dist/x/cfworkers.test.js
CHANGED
@@ -3,12 +3,12 @@
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
4
4
|
globalThis.addEventListener = () => {};
|
5
5
|
|
6
|
-
import "../type-
|
6
|
+
import "../type-DF9yoIpt.js";
|
7
7
|
import { assertEquals } from "../assert_equals-DSbWqCm3.js";
|
8
8
|
import "../assert-MZs1qjMx.js";
|
9
9
|
import "../assert_instance_of-DHz7EHNU.js";
|
10
|
-
import "../lookup-
|
11
|
-
import { test } from "../testing-
|
10
|
+
import "../lookup-DdxOle8f.js";
|
11
|
+
import { test } from "../testing-BX6IA3LR.js";
|
12
12
|
import "../std__assert-X-_kMxKM.js";
|
13
13
|
import "../assert_rejects-DiIiJbZn.js";
|
14
14
|
import "../assert_is_error-BPGph1Jx.js";
|
package/dist/x/hono.cjs
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
|
2
|
+
const { Temporal } = require("@js-temporal/polyfill");
|
3
|
+
const { URLPattern } = require("urlpattern-polyfill");
|
4
|
+
|
5
|
+
const require_chunk = require('../chunk-DqRYRqnO.cjs');
|
6
|
+
const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
|
7
|
+
|
8
|
+
//#region src/x/hono.ts
|
9
|
+
/**
|
10
|
+
* Create a Hono middleware to integrate with the {@link Federation} object.
|
11
|
+
*
|
12
|
+
* @deprecated This function has been moved to `@fedify/hono` package.
|
13
|
+
* Import `federation` from `@fedify/hono` instead.
|
14
|
+
* This function will be removed in Fedify v2.0.
|
15
|
+
*
|
16
|
+
* @template TContextData A type of the context data for the {@link Federation}
|
17
|
+
* object.
|
18
|
+
* @template THonoContext A type of the Hono context.
|
19
|
+
* @param federation A {@link Federation} object to integrate with Hono.
|
20
|
+
* @param contextDataFactory A function to create a context data for the
|
21
|
+
* {@link Federation} object.
|
22
|
+
* @returns A Hono middleware.
|
23
|
+
*/
|
24
|
+
function federation(federation$1, contextDataFactory) {
|
25
|
+
const logger = (0, __logtape_logtape.getLogger)([
|
26
|
+
"fedify",
|
27
|
+
"federation",
|
28
|
+
"hono"
|
29
|
+
]);
|
30
|
+
logger.warn("The `@fedify/fedify/x/hono` module is deprecated; use `federation` from `@fedify/hono` package instead.");
|
31
|
+
return async (ctx, next) => {
|
32
|
+
let contextData = contextDataFactory(ctx);
|
33
|
+
if (contextData instanceof Promise) contextData = await contextData;
|
34
|
+
return await federation$1.fetch(ctx.req.raw, {
|
35
|
+
contextData,
|
36
|
+
...integrateFetchOptions(ctx, next)
|
37
|
+
});
|
38
|
+
};
|
39
|
+
}
|
40
|
+
function integrateFetchOptions(ctx, next) {
|
41
|
+
return {
|
42
|
+
async onNotFound(_req) {
|
43
|
+
await next();
|
44
|
+
return ctx.res;
|
45
|
+
},
|
46
|
+
async onNotAcceptable(_req) {
|
47
|
+
await next();
|
48
|
+
if (ctx.res.status !== 404) return ctx.res;
|
49
|
+
return new Response("Not acceptable", {
|
50
|
+
status: 406,
|
51
|
+
headers: {
|
52
|
+
"Content-Type": "text/plain",
|
53
|
+
Vary: "Accept"
|
54
|
+
}
|
55
|
+
});
|
56
|
+
}
|
57
|
+
};
|
58
|
+
}
|
59
|
+
|
60
|
+
//#endregion
|
61
|
+
exports.federation = federation;
|