@fedify/fedify 2.0.0-pr.412.1559 → 2.0.0-pr.412.1794
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/README.md +3 -0
- package/dist/{actor-Cc6B76eG.js → actor-BXHc5r-q.js} +1 -1
- package/dist/actor-Ba9Z1eNJ.cjs +42079 -0
- package/dist/{actor-C22bXuuC.d.ts → actor-DqFajh9s.d.ts} +2 -2
- package/dist/{actor-CTAuCsWy.js → actor-DzhunPC_.js} +7058 -2722
- package/dist/actor-f2NtjyCg.d.cts +128 -0
- package/dist/{assert_rejects-DiIiJbZn.js → assert_rejects-Ce45JcFg.js} +1 -1
- package/dist/{assert_is_error-BPGph1Jx.js → assert_throws-BNXdRGWP.js} +31 -1
- package/dist/{builder-BOEBObR8.js → builder-u7usRsT3.js} +13 -8
- package/dist/chunk-DqRYRqnO.cjs +34 -0
- package/dist/client-94iWEfQa.d.cts +222 -0
- package/dist/{client-DF8anIB5.d.ts → client-BsGzbnV-.d.ts} +3 -75
- package/dist/{client-De-z2UnN.js → client-pY7-3icS.js} +3 -22
- package/dist/compat/mod.cjs +10 -0
- package/dist/compat/mod.d.cts +12 -0
- package/dist/compat/mod.d.ts +11 -12
- package/dist/compat/mod.js +5 -5
- package/dist/compat/transformers.test.js +20 -20
- package/dist/compat-DmDDELst.cjs +4 -0
- package/dist/compat-nxUqe4Z-.js +4 -0
- package/dist/{context-9gCpIkiz.d.ts → context-DG0huGW-.d.ts} +184 -127
- package/dist/context-DJ8aSy2Q.d.cts +2312 -0
- package/dist/{authdocloader-CLgDGafZ.js → docloader-CrbAy9Oc.js} +17 -8
- package/dist/{esm-CHdxdkuH.js → esm-C-Qa1zEM.js} +11 -11
- package/dist/federation/builder.test.js +9 -12
- package/dist/federation/collection.test.js +7 -9
- package/dist/federation/handler.test.js +27 -148
- package/dist/federation/idempotency.test.js +201 -0
- package/dist/federation/inbox.test.js +4 -6
- package/dist/federation/keycache.test.js +3 -4
- package/dist/federation/kv.test.js +7 -8
- package/dist/federation/middleware.test.js +242 -64
- package/dist/federation/mod.cjs +27 -0
- package/dist/federation/mod.d.cts +12 -0
- package/dist/federation/mod.d.ts +12 -13
- package/dist/federation/mod.js +13 -15
- package/dist/federation/mq.test.js +8 -10
- package/dist/federation/negotiation.test.js +26 -0
- package/dist/federation/retry.test.js +4 -5
- package/dist/federation/router.test.js +6 -8
- package/dist/federation/send.test.js +13 -15
- package/dist/federation-CRpdnOMS.cjs +244 -0
- package/dist/{federation-CMX7WzeL.js → federation-jcR8-ZxP.js} +3 -3
- package/dist/fixtures/media.example.com/avatars/test-avatar.jpg.json +6 -0
- package/dist/{http-DqSNLFNY.d.ts → http-BbO0ejuk.d.ts} +2 -2
- package/dist/{http-l0TEupZK.js → http-CUVx-vzb.js} +260 -10
- package/dist/{http-CcdM1brU.js → http-D2kIm9la.js} +3 -3
- package/dist/http-Dofes42e.cjs +1106 -0
- package/dist/http-M8k5mKc0.d.cts +253 -0
- package/dist/{inbox-B6DZbGNf.js → inbox-HjG5peXY.js} +24 -7
- package/dist/{key-CzLv1phF.js → key-CxdLUFS6.js} +3 -2
- package/dist/{keycache-B8HdZJSt.js → keycache-bU7COwsh.js} +1 -1
- package/dist/{keys-zZwiKkfx.js → keys-DMHs8XNn.js} +2 -1
- package/dist/kv-Bxr0Q87_.d.cts +81 -0
- package/dist/kv-cache-CGXcDejL.js +122 -0
- package/dist/kv-cache-DN9pfMBe.js +94 -0
- package/dist/kv-cache-Dkvbn6rg.cjs +134 -0
- package/dist/{ld-CBcQdZ6N.js → ld-CIhvSCCr.js} +5 -4
- package/dist/lookup-CHkCVZTU.js +260 -0
- package/dist/lookup-CfFkONZD.cjs +272 -0
- package/dist/{type-SK-d7Tbw.js → lookup-DQRtjvb1.js} +7266 -7087
- package/dist/middleware-Bot7EEwV.js +26 -0
- package/dist/middleware-CFJgmUMW.cjs +15 -0
- package/dist/{middleware-BRgu1IH8.js → middleware-CJlj5Olw.js} +86 -181
- package/dist/middleware-CjHl2NHA.js +15 -0
- package/dist/middleware-D74TgW2E.cjs +4225 -0
- package/dist/{middleware-CxEkcFW0.js → middleware-DMk2Mdn9.js} +117 -127
- package/dist/mod-0noXw66R.d.cts +107 -0
- package/dist/mod-B-hUPT2N.d.cts +1 -0
- package/dist/{mod-Drmz72EK.d.ts → mod-B2iOw50L.d.ts} +3 -3
- package/dist/mod-B9M-8jm2.d.ts +109 -0
- package/dist/{mod-Cxt4Kpf6.d.ts → mod-BlVovdcy.d.ts} +20 -2
- package/dist/{mod-Bqxcp7eN.d.ts → mod-BoHnwOCs.d.ts} +2 -2
- package/dist/mod-BxRCHTz-.d.cts +307 -0
- package/dist/mod-C2tOeRkN.d.cts +1 -0
- package/dist/mod-C58MZ7Wx.d.cts +113 -0
- package/dist/mod-DJcZDvjA.d.cts +80 -0
- package/dist/mod-DgdBYYa0.d.cts +266 -0
- package/dist/{mod-DBzN0aCM.d.ts → mod-Ds0mpFZU.d.ts} +1 -1
- package/dist/mod.cjs +137 -0
- package/dist/mod.d.cts +16 -0
- package/dist/mod.d.ts +16 -17
- package/dist/mod.js +19 -21
- package/dist/mq-DcJPkXD5.d.cts +140 -0
- package/dist/negotiation-C4nFufNk.js +71 -0
- package/dist/nodeinfo/client.test.js +30 -111
- package/dist/nodeinfo/handler.test.js +25 -26
- package/dist/nodeinfo/mod.cjs +10 -0
- package/dist/nodeinfo/mod.d.cts +3 -0
- package/dist/nodeinfo/mod.d.ts +3 -5
- package/dist/nodeinfo/mod.js +6 -7
- package/dist/nodeinfo/types.test.js +8 -15
- package/dist/nodeinfo-BnthBobC.js +4 -0
- package/dist/nodeinfo-CdN0rEnZ.cjs +4 -0
- package/dist/owner-B4HbyP8s.d.cts +67 -0
- package/dist/{owner-VEIjmR8r.js → owner-Dvh7mBvr.js} +3 -2
- package/dist/{owner-CQPnQVtf.d.ts → owner-kQRGVXG1.d.ts} +3 -3
- package/dist/proof-D0uThUvD.cjs +674 -0
- package/dist/{proof-DoSQAGkE.js → proof-Dgy35fzc.js} +3 -3
- package/dist/{proof-tgUlT8hw.js → proof-fqzaMJ4g.js} +11 -10
- package/dist/{send-BzS7w-QF.js → send-Drp20VO9.js} +2 -2
- package/dist/sig/http.test.js +13 -14
- package/dist/sig/key.test.js +9 -11
- package/dist/sig/ld.test.js +8 -10
- package/dist/sig/mod.cjs +28 -0
- package/dist/sig/mod.d.cts +6 -0
- package/dist/sig/mod.d.ts +5 -7
- package/dist/sig/mod.js +8 -10
- package/dist/sig/owner.test.js +10 -12
- package/dist/sig/proof.test.js +13 -14
- package/dist/sig-C34-oHBl.js +4 -0
- package/dist/sig-YYj5tCnr.cjs +4 -0
- package/dist/testing/docloader.test.js +6 -8
- package/dist/testing/mod.d.ts +387 -224
- package/dist/testing/mod.js +2 -3
- package/dist/{testing-Z2omCvKy.js → testing-g4UC4liW.js} +1 -2
- package/dist/{transformers-Dna8Fg7k.js → transformers-BFT6d7J5.js} +3 -3
- package/dist/transformers-CoBS-oFG.cjs +116 -0
- package/dist/{types-DgPvoUWN.js → types-BtUjyi5y.js} +8 -169
- package/dist/{types-BIgY6c-l.js → types-C2XVl6gj.js} +1 -3
- package/dist/types-CWgzGaqk.cjs +315 -0
- package/dist/{runtime/authdocloader.test.js → utils/docloader.test.js} +14 -15
- package/dist/utils/kv-cache.test.js +209 -0
- package/dist/utils/mod.cjs +12 -0
- package/dist/utils/mod.d.cts +5 -0
- package/dist/utils/mod.d.ts +7 -0
- package/dist/utils/mod.js +11 -0
- package/dist/utils-D-Va7aXC.js +4 -0
- package/dist/utils-DyRU1gdZ.cjs +4 -0
- package/dist/vocab/actor.test.js +8 -10
- package/dist/vocab/lookup.test.js +257 -9
- package/dist/vocab/mod.cjs +86 -0
- package/dist/vocab/mod.d.cts +4 -0
- package/dist/vocab/mod.d.ts +3 -5
- package/dist/vocab/mod.js +6 -7
- package/dist/vocab/type.test.js +2 -3
- package/dist/vocab/vocab.test.js +438 -15
- package/dist/{vocab-SOE1ifCr.d.ts → vocab-BCWe1Ih5.d.ts} +292 -21
- package/dist/{vocab-CvD6Vbml.js → vocab-BnR3nIU9.js} +26 -17
- package/dist/vocab-CeDBzu-f.d.cts +14903 -0
- package/dist/{lookup-Bn_HEC_d.js → vocab-DFaWWYDn.cjs} +108 -139
- package/dist/webfinger/handler.test.js +24 -25
- package/dist/webfinger/lookup.test.js +7 -9
- package/dist/webfinger/mod.cjs +8 -0
- package/dist/webfinger/mod.d.cts +2 -0
- package/dist/webfinger/mod.d.ts +1 -3
- package/dist/webfinger/mod.js +5 -6
- package/dist/webfinger-C72Y8lrh.js +4 -0
- package/dist/webfinger-vAtLmxOF.cjs +4 -0
- package/dist/x/cfworkers.cjs +100 -0
- package/dist/x/cfworkers.d.cts +59 -0
- package/dist/x/cfworkers.d.ts +2 -2
- package/dist/x/cfworkers.js +3 -3
- package/dist/x/cfworkers.test.js +6 -8
- package/dist/x/hono.cjs +61 -0
- package/dist/x/hono.d.cts +53 -0
- package/dist/x/hono.d.ts +10 -11
- package/dist/x/hono.js +3 -3
- package/dist/x/sveltekit.cjs +69 -0
- package/dist/x/sveltekit.d.cts +45 -0
- package/dist/x/sveltekit.d.ts +10 -11
- package/dist/x/sveltekit.js +3 -3
- package/package.json +79 -23
- package/dist/assert_throws-BOO88avQ.js +0 -39
- package/dist/authdocloader-BFVqUbyo.js +0 -52
- package/dist/compat-Bb5myD13.js +0 -4
- package/dist/docloader-CxWcuWqQ.d.ts +0 -221
- package/dist/docloader-DEhniCVa.js +0 -4615
- package/dist/key-CUZQgVlf.js +0 -10
- package/dist/key-Deb0_wWL.js +0 -10
- package/dist/key-DxA6xRtZ.js +0 -260
- package/dist/lookup-dtdr2ftf.js +0 -131
- package/dist/middleware-BE_geSiJ.js +0 -17
- package/dist/middleware-BnU6hzVp.js +0 -26
- package/dist/mod-TFoH2Ql8.d.ts +0 -104
- package/dist/nodeinfo/semver.test.js +0 -143
- package/dist/nodeinfo-CyEbLjHs.js +0 -4
- package/dist/runtime/docloader.test.js +0 -522
- package/dist/runtime/key.test.js +0 -103
- package/dist/runtime/langstr.test.d.ts +0 -3
- package/dist/runtime/langstr.test.js +0 -39
- package/dist/runtime/mod.d.ts +0 -8
- package/dist/runtime/mod.js +0 -13
- package/dist/runtime/multibase/multibase.test.d.ts +0 -3
- package/dist/runtime/multibase/multibase.test.js +0 -358
- package/dist/runtime/url.test.d.ts +0 -3
- package/dist/runtime/url.test.js +0 -45
- package/dist/runtime-BSkOVUWM.js +0 -4
- package/dist/semver-dArNLkR9.js +0 -149
- package/dist/sig-BXJO--F9.js +0 -4
- package/dist/webfinger-C3GIyXIg.js +0 -4
- /package/dist/{assert_not_equals-f3m3epl3.js → assert_not_equals-C80BG-_5.js} +0 -0
- /package/dist/{collection-CSzG2j1P.js → collection-BzWsN9pB.js} +0 -0
- /package/dist/{denokv-Bv33Xxea.js → denokv-CCssOzMJ.js} +0 -0
- /package/dist/{nodeinfo/semver.test.d.ts → federation/idempotency.test.d.ts} +0 -0
- /package/dist/{runtime/authdocloader.test.d.ts → federation/negotiation.test.d.ts} +0 -0
- /package/dist/{kv-C7sopW2E.d.ts → kv-BKNZ-Tb-.d.ts} +0 -0
- /package/dist/{mod-1pDWKvUL.d.ts → mod-CVgZgliM.d.ts} +0 -0
- /package/dist/{mod-g0xFzAP9.d.ts → mod-xIj-IT58.d.ts} +0 -0
- /package/dist/{mq-CRGm1e_F.d.ts → mq-CUKlBw08.d.ts} +0 -0
- /package/dist/{retry-D4GJ670a.js → retry-CfF8Gn4d.js} +0 -0
- /package/dist/{std__assert-X-_kMxKM.js → std__assert-DWivtrGR.js} +0 -0
- /package/dist/{runtime → utils}/docloader.test.d.ts +0 -0
- /package/dist/{runtime/key.test.d.ts → utils/kv-cache.test.d.ts} +0 -0
@@ -1,123 +1,15 @@
|
|
1
1
|
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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_lookup = require('./lookup-CfFkONZD.cjs');
|
7
|
+
const require_actor = require('./actor-Ba9Z1eNJ.cjs');
|
8
|
+
const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
|
9
|
+
const __opentelemetry_api = require_chunk.__toESM(require("@opentelemetry/api"));
|
10
|
+
const __fedify_vocab_runtime = require_chunk.__toESM(require("@fedify/vocab-runtime"));
|
11
|
+
const es_toolkit = require_chunk.__toESM(require("es-toolkit"));
|
12
12
|
|
13
|
-
//#region src/federation/router.ts
|
14
|
-
function cloneInnerRouter(router) {
|
15
|
-
const clone = new Router();
|
16
|
-
clone.nid = router.nid;
|
17
|
-
clone.fsm = cloneDeep(router.fsm);
|
18
|
-
clone.routeSet = new Set(router.routeSet);
|
19
|
-
clone.templateRouteMap = new Map(router.templateRouteMap);
|
20
|
-
clone.valueRouteMap = new Map(router.valueRouteMap);
|
21
|
-
clone.hierarchy = cloneDeep(router.hierarchy);
|
22
|
-
return clone;
|
23
|
-
}
|
24
|
-
/**
|
25
|
-
* URL router and constructor based on URI Template
|
26
|
-
* ([RFC 6570](https://tools.ietf.org/html/rfc6570)).
|
27
|
-
*/
|
28
|
-
var Router$1 = class Router$1 {
|
29
|
-
#router;
|
30
|
-
#templates;
|
31
|
-
#templateStrings;
|
32
|
-
/**
|
33
|
-
* Whether to ignore trailing slashes when matching paths.
|
34
|
-
* @since 1.6.0
|
35
|
-
*/
|
36
|
-
trailingSlashInsensitive;
|
37
|
-
/**
|
38
|
-
* Create a new {@link Router}.
|
39
|
-
* @param options Options for the router.
|
40
|
-
*/
|
41
|
-
constructor(options = {}) {
|
42
|
-
this.#router = new Router();
|
43
|
-
this.#templates = {};
|
44
|
-
this.#templateStrings = {};
|
45
|
-
this.trailingSlashInsensitive = options.trailingSlashInsensitive ?? false;
|
46
|
-
}
|
47
|
-
clone() {
|
48
|
-
const clone = new Router$1({ trailingSlashInsensitive: this.trailingSlashInsensitive });
|
49
|
-
clone.#router = cloneInnerRouter(this.#router);
|
50
|
-
clone.#templates = { ...this.#templates };
|
51
|
-
clone.#templateStrings = { ...this.#templateStrings };
|
52
|
-
return clone;
|
53
|
-
}
|
54
|
-
/**
|
55
|
-
* Checks if a path name exists in the router.
|
56
|
-
* @param name The name of the path.
|
57
|
-
* @returns `true` if the path name exists, otherwise `false`.
|
58
|
-
*/
|
59
|
-
has(name) {
|
60
|
-
return name in this.#templates;
|
61
|
-
}
|
62
|
-
/**
|
63
|
-
* Adds a new path rule to the router.
|
64
|
-
* @param template The path pattern.
|
65
|
-
* @param name The name of the path.
|
66
|
-
* @returns The names of the variables in the path pattern.
|
67
|
-
*/
|
68
|
-
add(template, name) {
|
69
|
-
if (!template.startsWith("/")) throw new RouterError("Path must start with a slash.");
|
70
|
-
const rule = this.#router.addTemplate(template, {}, name);
|
71
|
-
this.#templates[name] = parseTemplate(template);
|
72
|
-
this.#templateStrings[name] = template;
|
73
|
-
return new Set(rule.variables.map((v) => v.varname));
|
74
|
-
}
|
75
|
-
/**
|
76
|
-
* Resolves a path name and values from a URL, if any match.
|
77
|
-
* @param url The URL to resolve.
|
78
|
-
* @returns The name of the path and its values, if any match. Otherwise,
|
79
|
-
* `null`.
|
80
|
-
*/
|
81
|
-
route(url) {
|
82
|
-
let match = this.#router.resolveURI(url);
|
83
|
-
if (match == null) {
|
84
|
-
if (!this.trailingSlashInsensitive) return null;
|
85
|
-
url = url.endsWith("/") ? url.replace(/\/+$/, "") : `${url}/`;
|
86
|
-
match = this.#router.resolveURI(url);
|
87
|
-
if (match == null) return null;
|
88
|
-
}
|
89
|
-
return {
|
90
|
-
name: match.matchValue,
|
91
|
-
template: this.#templateStrings[match.matchValue],
|
92
|
-
values: match.params
|
93
|
-
};
|
94
|
-
}
|
95
|
-
/**
|
96
|
-
* Constructs a URL/path from a path name and values.
|
97
|
-
* @param name The name of the path.
|
98
|
-
* @param values The values to expand the path with.
|
99
|
-
* @returns The URL/path, if the name exists. Otherwise, `null`.
|
100
|
-
*/
|
101
|
-
build(name, values) {
|
102
|
-
if (name in this.#templates) return this.#templates[name].expand(values);
|
103
|
-
return null;
|
104
|
-
}
|
105
|
-
};
|
106
|
-
/**
|
107
|
-
* An error thrown by the {@link Router}.
|
108
|
-
*/
|
109
|
-
var RouterError = class extends Error {
|
110
|
-
/**
|
111
|
-
* Create a new {@link RouterError}.
|
112
|
-
* @param message The error message.
|
113
|
-
*/
|
114
|
-
constructor(message) {
|
115
|
-
super(message);
|
116
|
-
this.name = "RouterError";
|
117
|
-
}
|
118
|
-
};
|
119
|
-
|
120
|
-
//#endregion
|
121
13
|
//#region src/vocab/handle.ts
|
122
14
|
/**
|
123
15
|
* Regular expression to match a fediverse handle in the format `@user@server`
|
@@ -153,6 +45,27 @@ function parseFediverseHandle(handle) {
|
|
153
45
|
return null;
|
154
46
|
}
|
155
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
|
+
/**
|
156
69
|
* Converts a fediverse handle in the format `@user@server` or `user@server`
|
157
70
|
* to an `acct:` URI, which is a URL-like identifier for ActivityPub actors.
|
158
71
|
*
|
@@ -176,7 +89,7 @@ function toAcctUrl(handle) {
|
|
176
89
|
|
177
90
|
//#endregion
|
178
91
|
//#region src/vocab/lookup.ts
|
179
|
-
const logger = getLogger([
|
92
|
+
const logger = (0, __logtape_logtape.getLogger)([
|
180
93
|
"fedify",
|
181
94
|
"vocab",
|
182
95
|
"lookup"
|
@@ -214,21 +127,21 @@ const logger = getLogger([
|
|
214
127
|
* @since 0.2.0
|
215
128
|
*/
|
216
129
|
async function lookupObject(identifier, options = {}) {
|
217
|
-
const tracerProvider = options.tracerProvider ?? trace.getTracerProvider();
|
218
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
130
|
+
const tracerProvider = options.tracerProvider ?? __opentelemetry_api.trace.getTracerProvider();
|
131
|
+
const tracer = tracerProvider.getTracer(require_lookup.deno_default.name, require_lookup.deno_default.version);
|
219
132
|
return await tracer.startActiveSpan("activitypub.lookup_object", async (span) => {
|
220
133
|
try {
|
221
134
|
const result = await lookupObjectInternal(identifier, options);
|
222
|
-
if (result == null) span.setStatus({ code: SpanStatusCode.ERROR });
|
135
|
+
if (result == null) span.setStatus({ code: __opentelemetry_api.SpanStatusCode.ERROR });
|
223
136
|
else {
|
224
137
|
if (result.id != null) span.setAttribute("activitypub.object.id", result.id.href);
|
225
|
-
span.setAttribute("activitypub.object.type", getTypeId(result).href);
|
138
|
+
span.setAttribute("activitypub.object.type", require_actor.getTypeId(result).href);
|
226
139
|
if (result.replyTargetIds.length > 0) span.setAttribute("activitypub.object.in_reply_to", result.replyTargetIds.map((id) => id.href));
|
227
140
|
}
|
228
141
|
return result;
|
229
142
|
} catch (error) {
|
230
143
|
span.setStatus({
|
231
|
-
code: SpanStatusCode.ERROR,
|
144
|
+
code: __opentelemetry_api.SpanStatusCode.ERROR,
|
232
145
|
message: String(error)
|
233
146
|
});
|
234
147
|
throw error;
|
@@ -238,17 +151,16 @@ async function lookupObject(identifier, options = {}) {
|
|
238
151
|
});
|
239
152
|
}
|
240
153
|
async function lookupObjectInternal(identifier, options = {}) {
|
241
|
-
const documentLoader = options.documentLoader ?? getDocumentLoader({ userAgent: options.userAgent });
|
154
|
+
const documentLoader = options.documentLoader ?? (0, __fedify_vocab_runtime.getDocumentLoader)({ userAgent: options.userAgent });
|
242
155
|
if (typeof identifier === "string") identifier = toAcctUrl(identifier) ?? new URL(identifier);
|
243
|
-
let
|
156
|
+
let remoteDoc = null;
|
244
157
|
if (identifier.protocol === "http:" || identifier.protocol === "https:") try {
|
245
|
-
|
246
|
-
document = remoteDoc.document;
|
158
|
+
remoteDoc = await documentLoader(identifier.href, { signal: options.signal });
|
247
159
|
} catch (error) {
|
248
160
|
logger.debug("Failed to fetch remote document:\n{error}", { error });
|
249
161
|
}
|
250
|
-
if (
|
251
|
-
const jrd = await lookupWebFinger(identifier, {
|
162
|
+
if (remoteDoc == null) {
|
163
|
+
const jrd = await require_lookup.lookupWebFinger(identifier, {
|
252
164
|
userAgent: options.userAgent,
|
253
165
|
tracerProvider: options.tracerProvider,
|
254
166
|
allowPrivateAddress: "allowPrivateAddress" in options && options.allowPrivateAddress === true,
|
@@ -258,8 +170,7 @@ async function lookupObjectInternal(identifier, options = {}) {
|
|
258
170
|
for (const l of jrd.links) {
|
259
171
|
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;
|
260
172
|
try {
|
261
|
-
|
262
|
-
document = remoteDoc.document;
|
173
|
+
remoteDoc = await documentLoader(l.href, { signal: options.signal });
|
263
174
|
break;
|
264
175
|
} catch (error) {
|
265
176
|
logger.debug("Failed to fetch remote document:\n{error}", { error });
|
@@ -267,23 +178,34 @@ async function lookupObjectInternal(identifier, options = {}) {
|
|
267
178
|
}
|
268
179
|
}
|
269
180
|
}
|
270
|
-
if (
|
181
|
+
if (remoteDoc == null) return null;
|
182
|
+
let object;
|
271
183
|
try {
|
272
|
-
|
184
|
+
object = await require_actor.Object.fromJsonLd(remoteDoc.document, {
|
273
185
|
documentLoader,
|
274
186
|
contextLoader: options.contextLoader,
|
275
|
-
tracerProvider: options.tracerProvider
|
187
|
+
tracerProvider: options.tracerProvider,
|
188
|
+
baseUrl: new URL(remoteDoc.documentUrl)
|
276
189
|
});
|
277
190
|
} catch (error) {
|
278
191
|
if (error instanceof TypeError) {
|
279
192
|
logger.debug("Failed to parse JSON-LD document: {error}\n{document}", {
|
280
|
-
|
281
|
-
|
193
|
+
...remoteDoc,
|
194
|
+
error
|
282
195
|
});
|
283
196
|
return null;
|
284
197
|
}
|
285
198
|
throw error;
|
286
199
|
}
|
200
|
+
if (options.crossOrigin !== "trust" && object.id != null && object.id.origin !== new URL(remoteDoc.documentUrl).origin) {
|
201
|
+
if (options.crossOrigin === "throw") throw new Error(`The object's @id (${object.id.href}) has a different origin than the document URL (${remoteDoc.documentUrl}); refusing to return the object. If you want to bypass this check and are aware of the security implications, set the crossOrigin option to "trust".`);
|
202
|
+
logger.warn("The object's @id ({objectId}) has a different origin than the document URL ({documentUrl}); refusing to return the object. If you want to bypass this check and are aware of the security implications, set the crossOrigin option to \"trust\".", {
|
203
|
+
...remoteDoc,
|
204
|
+
objectId: object.id.href
|
205
|
+
});
|
206
|
+
return null;
|
207
|
+
}
|
208
|
+
return object;
|
287
209
|
}
|
288
210
|
/**
|
289
211
|
* Traverses a collection, yielding each item in the collection.
|
@@ -312,11 +234,58 @@ async function* traverseCollection(collection, options = {}) {
|
|
312
234
|
let page = await collection.getFirst(options);
|
313
235
|
while (page != null) {
|
314
236
|
for await (const item of page.getItems(options)) yield item;
|
315
|
-
if (interval > 0) await delay(interval);
|
237
|
+
if (interval > 0) await (0, es_toolkit.delay)(interval);
|
316
238
|
page = await page.getNext(options);
|
317
239
|
}
|
318
240
|
}
|
319
241
|
}
|
320
242
|
|
321
243
|
//#endregion
|
322
|
-
|
244
|
+
//#region src/vocab/constants.ts
|
245
|
+
/**
|
246
|
+
* The special public collection for [public addressing]. *Do not mutate this
|
247
|
+
* object.*
|
248
|
+
*
|
249
|
+
* [public addressing]: https://www.w3.org/TR/activitypub/#public-addressing
|
250
|
+
*
|
251
|
+
* @since 0.7.0
|
252
|
+
*/
|
253
|
+
const PUBLIC_COLLECTION = new URL("https://www.w3.org/ns/activitystreams#Public");
|
254
|
+
|
255
|
+
//#endregion
|
256
|
+
Object.defineProperty(exports, 'PUBLIC_COLLECTION', {
|
257
|
+
enumerable: true,
|
258
|
+
get: function () {
|
259
|
+
return PUBLIC_COLLECTION;
|
260
|
+
}
|
261
|
+
});
|
262
|
+
Object.defineProperty(exports, 'isFediverseHandle', {
|
263
|
+
enumerable: true,
|
264
|
+
get: function () {
|
265
|
+
return isFediverseHandle;
|
266
|
+
}
|
267
|
+
});
|
268
|
+
Object.defineProperty(exports, 'lookupObject', {
|
269
|
+
enumerable: true,
|
270
|
+
get: function () {
|
271
|
+
return lookupObject;
|
272
|
+
}
|
273
|
+
});
|
274
|
+
Object.defineProperty(exports, 'parseFediverseHandle', {
|
275
|
+
enumerable: true,
|
276
|
+
get: function () {
|
277
|
+
return parseFediverseHandle;
|
278
|
+
}
|
279
|
+
});
|
280
|
+
Object.defineProperty(exports, 'toAcctUrl', {
|
281
|
+
enumerable: true,
|
282
|
+
get: function () {
|
283
|
+
return toAcctUrl;
|
284
|
+
}
|
285
|
+
});
|
286
|
+
Object.defineProperty(exports, 'traverseCollection', {
|
287
|
+
enumerable: true,
|
288
|
+
get: function () {
|
289
|
+
return traverseCollection;
|
290
|
+
}
|
291
|
+
});
|
@@ -3,35 +3,34 @@
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
4
4
|
globalThis.addEventListener = () => {};
|
5
5
|
|
6
|
-
import { Image, Link, Person } from "../
|
6
|
+
import { Image, Link, Person } from "../lookup-DQRtjvb1.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-
|
12
|
-
import "../
|
13
|
-
import "../
|
14
|
-
import "../
|
15
|
-
import "../
|
16
|
-
import "../
|
17
|
-
import "../
|
18
|
-
import "../
|
19
|
-
import "../
|
20
|
-
import "../
|
21
|
-
import "../
|
22
|
-
import "../
|
23
|
-
import "../
|
24
|
-
import "../
|
25
|
-
import "../
|
26
|
-
import "../
|
27
|
-
import "../retry-
|
28
|
-
import "../send-
|
29
|
-
import { createRequestContext, test } from "../testing-
|
30
|
-
import "../std__assert-
|
31
|
-
import "../assert_rejects-
|
32
|
-
import "../
|
33
|
-
import "../assert_not_equals-
|
34
|
-
import "../assert_throws-BOO88avQ.js";
|
11
|
+
import { createFederation, handleWebFinger } from "../middleware-CJlj5Olw.js";
|
12
|
+
import "../client-pY7-3icS.js";
|
13
|
+
import "../types-C2XVl6gj.js";
|
14
|
+
import "../actor-BXHc5r-q.js";
|
15
|
+
import "../key-CxdLUFS6.js";
|
16
|
+
import "../http-D2kIm9la.js";
|
17
|
+
import "../ld-CIhvSCCr.js";
|
18
|
+
import "../owner-Dvh7mBvr.js";
|
19
|
+
import "../proof-Dgy35fzc.js";
|
20
|
+
import "../docloader-CrbAy9Oc.js";
|
21
|
+
import "../kv-cache-DN9pfMBe.js";
|
22
|
+
import "../inbox-HjG5peXY.js";
|
23
|
+
import "../builder-u7usRsT3.js";
|
24
|
+
import "../collection-BzWsN9pB.js";
|
25
|
+
import "../keycache-bU7COwsh.js";
|
26
|
+
import "../negotiation-C4nFufNk.js";
|
27
|
+
import "../retry-CfF8Gn4d.js";
|
28
|
+
import "../send-Drp20VO9.js";
|
29
|
+
import { createRequestContext, test } from "../testing-g4UC4liW.js";
|
30
|
+
import "../std__assert-DWivtrGR.js";
|
31
|
+
import "../assert_rejects-Ce45JcFg.js";
|
32
|
+
import "../assert_throws-BNXdRGWP.js";
|
33
|
+
import "../assert_not_equals-C80BG-_5.js";
|
35
34
|
|
36
35
|
//#region src/webfinger/handler.test.ts
|
37
36
|
test("handleWebFinger()", async (t) => {
|
@@ -3,18 +3,16 @@
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
4
4
|
globalThis.addEventListener = () => {};
|
5
5
|
|
6
|
-
import { lookupWebFinger } from "../
|
6
|
+
import { lookupWebFinger } from "../lookup-DQRtjvb1.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 "../
|
11
|
-
import
|
12
|
-
import "../
|
13
|
-
import "../
|
14
|
-
import "../
|
15
|
-
import "../
|
16
|
-
import "../assert_throws-BOO88avQ.js";
|
17
|
-
import { esm_default } from "../esm-CHdxdkuH.js";
|
10
|
+
import { test } from "../testing-g4UC4liW.js";
|
11
|
+
import "../std__assert-DWivtrGR.js";
|
12
|
+
import "../assert_rejects-Ce45JcFg.js";
|
13
|
+
import "../assert_throws-BNXdRGWP.js";
|
14
|
+
import "../assert_not_equals-C80BG-_5.js";
|
15
|
+
import { esm_default } from "../esm-C-Qa1zEM.js";
|
18
16
|
import { withTimeout } from "es-toolkit";
|
19
17
|
|
20
18
|
//#region src/webfinger/lookup.test.ts
|
@@ -0,0 +1,8 @@
|
|
1
|
+
|
2
|
+
const { Temporal } = require("@js-temporal/polyfill");
|
3
|
+
const { URLPattern } = require("urlpattern-polyfill");
|
4
|
+
|
5
|
+
const require_lookup = require('../lookup-CfFkONZD.cjs');
|
6
|
+
require('../webfinger-vAtLmxOF.cjs');
|
7
|
+
|
8
|
+
exports.lookupWebFinger = require_lookup.lookupWebFinger;
|
package/dist/webfinger/mod.d.ts
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
3
|
-
import "../
|
4
|
-
import "../docloader-CxWcuWqQ.js";
|
5
|
-
import { Link, LookupWebFingerOptions, ResourceDescriptor, lookupWebFinger } from "../mod-DBzN0aCM.js";
|
3
|
+
import { Link, LookupWebFingerOptions, ResourceDescriptor, lookupWebFinger } from "../mod-Ds0mpFZU.js";
|
6
4
|
export { Link, LookupWebFingerOptions, ResourceDescriptor, lookupWebFinger };
|
package/dist/webfinger/mod.js
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
import "../
|
6
|
-
import
|
7
|
-
import "../webfinger-C3GIyXIg.js";
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
4
|
+
|
5
|
+
import { lookupWebFinger } from "../lookup-CHkCVZTU.js";
|
6
|
+
import "../webfinger-C72Y8lrh.js";
|
8
7
|
|
9
8
|
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-Bxr0Q87_.cjs";
|
2
|
+
import { MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions } from "../mq-DcJPkXD5.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.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
3
|
-
import { KvKey, KvStore, KvStoreSetOptions } from "../kv-
|
4
|
-
import { MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions } from "../mq-
|
3
|
+
import { KvKey, KvStore, KvStoreSetOptions } from "../kv-BKNZ-Tb-.js";
|
4
|
+
import { MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions } from "../mq-CUKlBw08.js";
|
5
5
|
import { KVNamespace, Queue } from "@cloudflare/workers-types/experimental";
|
6
6
|
|
7
7
|
//#region src/x/cfworkers.d.ts
|
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
|