@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.
Files changed (204) hide show
  1. package/README.md +3 -0
  2. package/dist/{actor-Cc6B76eG.js → actor-BXHc5r-q.js} +1 -1
  3. package/dist/actor-Ba9Z1eNJ.cjs +42079 -0
  4. package/dist/{actor-C22bXuuC.d.ts → actor-DqFajh9s.d.ts} +2 -2
  5. package/dist/{actor-CTAuCsWy.js → actor-DzhunPC_.js} +7058 -2722
  6. package/dist/actor-f2NtjyCg.d.cts +128 -0
  7. package/dist/{assert_rejects-DiIiJbZn.js → assert_rejects-Ce45JcFg.js} +1 -1
  8. package/dist/{assert_is_error-BPGph1Jx.js → assert_throws-BNXdRGWP.js} +31 -1
  9. package/dist/{builder-BOEBObR8.js → builder-u7usRsT3.js} +13 -8
  10. package/dist/chunk-DqRYRqnO.cjs +34 -0
  11. package/dist/client-94iWEfQa.d.cts +222 -0
  12. package/dist/{client-DF8anIB5.d.ts → client-BsGzbnV-.d.ts} +3 -75
  13. package/dist/{client-De-z2UnN.js → client-pY7-3icS.js} +3 -22
  14. package/dist/compat/mod.cjs +10 -0
  15. package/dist/compat/mod.d.cts +12 -0
  16. package/dist/compat/mod.d.ts +11 -12
  17. package/dist/compat/mod.js +5 -5
  18. package/dist/compat/transformers.test.js +20 -20
  19. package/dist/compat-DmDDELst.cjs +4 -0
  20. package/dist/compat-nxUqe4Z-.js +4 -0
  21. package/dist/{context-9gCpIkiz.d.ts → context-DG0huGW-.d.ts} +184 -127
  22. package/dist/context-DJ8aSy2Q.d.cts +2312 -0
  23. package/dist/{authdocloader-CLgDGafZ.js → docloader-CrbAy9Oc.js} +17 -8
  24. package/dist/{esm-CHdxdkuH.js → esm-C-Qa1zEM.js} +11 -11
  25. package/dist/federation/builder.test.js +9 -12
  26. package/dist/federation/collection.test.js +7 -9
  27. package/dist/federation/handler.test.js +27 -148
  28. package/dist/federation/idempotency.test.js +201 -0
  29. package/dist/federation/inbox.test.js +4 -6
  30. package/dist/federation/keycache.test.js +3 -4
  31. package/dist/federation/kv.test.js +7 -8
  32. package/dist/federation/middleware.test.js +242 -64
  33. package/dist/federation/mod.cjs +27 -0
  34. package/dist/federation/mod.d.cts +12 -0
  35. package/dist/federation/mod.d.ts +12 -13
  36. package/dist/federation/mod.js +13 -15
  37. package/dist/federation/mq.test.js +8 -10
  38. package/dist/federation/negotiation.test.js +26 -0
  39. package/dist/federation/retry.test.js +4 -5
  40. package/dist/federation/router.test.js +6 -8
  41. package/dist/federation/send.test.js +13 -15
  42. package/dist/federation-CRpdnOMS.cjs +244 -0
  43. package/dist/{federation-CMX7WzeL.js → federation-jcR8-ZxP.js} +3 -3
  44. package/dist/fixtures/media.example.com/avatars/test-avatar.jpg.json +6 -0
  45. package/dist/{http-DqSNLFNY.d.ts → http-BbO0ejuk.d.ts} +2 -2
  46. package/dist/{http-l0TEupZK.js → http-CUVx-vzb.js} +260 -10
  47. package/dist/{http-CcdM1brU.js → http-D2kIm9la.js} +3 -3
  48. package/dist/http-Dofes42e.cjs +1106 -0
  49. package/dist/http-M8k5mKc0.d.cts +253 -0
  50. package/dist/{inbox-B6DZbGNf.js → inbox-HjG5peXY.js} +24 -7
  51. package/dist/{key-CzLv1phF.js → key-CxdLUFS6.js} +3 -2
  52. package/dist/{keycache-B8HdZJSt.js → keycache-bU7COwsh.js} +1 -1
  53. package/dist/{keys-zZwiKkfx.js → keys-DMHs8XNn.js} +2 -1
  54. package/dist/kv-Bxr0Q87_.d.cts +81 -0
  55. package/dist/kv-cache-CGXcDejL.js +122 -0
  56. package/dist/kv-cache-DN9pfMBe.js +94 -0
  57. package/dist/kv-cache-Dkvbn6rg.cjs +134 -0
  58. package/dist/{ld-CBcQdZ6N.js → ld-CIhvSCCr.js} +5 -4
  59. package/dist/lookup-CHkCVZTU.js +260 -0
  60. package/dist/lookup-CfFkONZD.cjs +272 -0
  61. package/dist/{type-SK-d7Tbw.js → lookup-DQRtjvb1.js} +7266 -7087
  62. package/dist/middleware-Bot7EEwV.js +26 -0
  63. package/dist/middleware-CFJgmUMW.cjs +15 -0
  64. package/dist/{middleware-BRgu1IH8.js → middleware-CJlj5Olw.js} +86 -181
  65. package/dist/middleware-CjHl2NHA.js +15 -0
  66. package/dist/middleware-D74TgW2E.cjs +4225 -0
  67. package/dist/{middleware-CxEkcFW0.js → middleware-DMk2Mdn9.js} +117 -127
  68. package/dist/mod-0noXw66R.d.cts +107 -0
  69. package/dist/mod-B-hUPT2N.d.cts +1 -0
  70. package/dist/{mod-Drmz72EK.d.ts → mod-B2iOw50L.d.ts} +3 -3
  71. package/dist/mod-B9M-8jm2.d.ts +109 -0
  72. package/dist/{mod-Cxt4Kpf6.d.ts → mod-BlVovdcy.d.ts} +20 -2
  73. package/dist/{mod-Bqxcp7eN.d.ts → mod-BoHnwOCs.d.ts} +2 -2
  74. package/dist/mod-BxRCHTz-.d.cts +307 -0
  75. package/dist/mod-C2tOeRkN.d.cts +1 -0
  76. package/dist/mod-C58MZ7Wx.d.cts +113 -0
  77. package/dist/mod-DJcZDvjA.d.cts +80 -0
  78. package/dist/mod-DgdBYYa0.d.cts +266 -0
  79. package/dist/{mod-DBzN0aCM.d.ts → mod-Ds0mpFZU.d.ts} +1 -1
  80. package/dist/mod.cjs +137 -0
  81. package/dist/mod.d.cts +16 -0
  82. package/dist/mod.d.ts +16 -17
  83. package/dist/mod.js +19 -21
  84. package/dist/mq-DcJPkXD5.d.cts +140 -0
  85. package/dist/negotiation-C4nFufNk.js +71 -0
  86. package/dist/nodeinfo/client.test.js +30 -111
  87. package/dist/nodeinfo/handler.test.js +25 -26
  88. package/dist/nodeinfo/mod.cjs +10 -0
  89. package/dist/nodeinfo/mod.d.cts +3 -0
  90. package/dist/nodeinfo/mod.d.ts +3 -5
  91. package/dist/nodeinfo/mod.js +6 -7
  92. package/dist/nodeinfo/types.test.js +8 -15
  93. package/dist/nodeinfo-BnthBobC.js +4 -0
  94. package/dist/nodeinfo-CdN0rEnZ.cjs +4 -0
  95. package/dist/owner-B4HbyP8s.d.cts +67 -0
  96. package/dist/{owner-VEIjmR8r.js → owner-Dvh7mBvr.js} +3 -2
  97. package/dist/{owner-CQPnQVtf.d.ts → owner-kQRGVXG1.d.ts} +3 -3
  98. package/dist/proof-D0uThUvD.cjs +674 -0
  99. package/dist/{proof-DoSQAGkE.js → proof-Dgy35fzc.js} +3 -3
  100. package/dist/{proof-tgUlT8hw.js → proof-fqzaMJ4g.js} +11 -10
  101. package/dist/{send-BzS7w-QF.js → send-Drp20VO9.js} +2 -2
  102. package/dist/sig/http.test.js +13 -14
  103. package/dist/sig/key.test.js +9 -11
  104. package/dist/sig/ld.test.js +8 -10
  105. package/dist/sig/mod.cjs +28 -0
  106. package/dist/sig/mod.d.cts +6 -0
  107. package/dist/sig/mod.d.ts +5 -7
  108. package/dist/sig/mod.js +8 -10
  109. package/dist/sig/owner.test.js +10 -12
  110. package/dist/sig/proof.test.js +13 -14
  111. package/dist/sig-C34-oHBl.js +4 -0
  112. package/dist/sig-YYj5tCnr.cjs +4 -0
  113. package/dist/testing/docloader.test.js +6 -8
  114. package/dist/testing/mod.d.ts +387 -224
  115. package/dist/testing/mod.js +2 -3
  116. package/dist/{testing-Z2omCvKy.js → testing-g4UC4liW.js} +1 -2
  117. package/dist/{transformers-Dna8Fg7k.js → transformers-BFT6d7J5.js} +3 -3
  118. package/dist/transformers-CoBS-oFG.cjs +116 -0
  119. package/dist/{types-DgPvoUWN.js → types-BtUjyi5y.js} +8 -169
  120. package/dist/{types-BIgY6c-l.js → types-C2XVl6gj.js} +1 -3
  121. package/dist/types-CWgzGaqk.cjs +315 -0
  122. package/dist/{runtime/authdocloader.test.js → utils/docloader.test.js} +14 -15
  123. package/dist/utils/kv-cache.test.js +209 -0
  124. package/dist/utils/mod.cjs +12 -0
  125. package/dist/utils/mod.d.cts +5 -0
  126. package/dist/utils/mod.d.ts +7 -0
  127. package/dist/utils/mod.js +11 -0
  128. package/dist/utils-D-Va7aXC.js +4 -0
  129. package/dist/utils-DyRU1gdZ.cjs +4 -0
  130. package/dist/vocab/actor.test.js +8 -10
  131. package/dist/vocab/lookup.test.js +257 -9
  132. package/dist/vocab/mod.cjs +86 -0
  133. package/dist/vocab/mod.d.cts +4 -0
  134. package/dist/vocab/mod.d.ts +3 -5
  135. package/dist/vocab/mod.js +6 -7
  136. package/dist/vocab/type.test.js +2 -3
  137. package/dist/vocab/vocab.test.js +438 -15
  138. package/dist/{vocab-SOE1ifCr.d.ts → vocab-BCWe1Ih5.d.ts} +292 -21
  139. package/dist/{vocab-CvD6Vbml.js → vocab-BnR3nIU9.js} +26 -17
  140. package/dist/vocab-CeDBzu-f.d.cts +14903 -0
  141. package/dist/{lookup-Bn_HEC_d.js → vocab-DFaWWYDn.cjs} +108 -139
  142. package/dist/webfinger/handler.test.js +24 -25
  143. package/dist/webfinger/lookup.test.js +7 -9
  144. package/dist/webfinger/mod.cjs +8 -0
  145. package/dist/webfinger/mod.d.cts +2 -0
  146. package/dist/webfinger/mod.d.ts +1 -3
  147. package/dist/webfinger/mod.js +5 -6
  148. package/dist/webfinger-C72Y8lrh.js +4 -0
  149. package/dist/webfinger-vAtLmxOF.cjs +4 -0
  150. package/dist/x/cfworkers.cjs +100 -0
  151. package/dist/x/cfworkers.d.cts +59 -0
  152. package/dist/x/cfworkers.d.ts +2 -2
  153. package/dist/x/cfworkers.js +3 -3
  154. package/dist/x/cfworkers.test.js +6 -8
  155. package/dist/x/hono.cjs +61 -0
  156. package/dist/x/hono.d.cts +53 -0
  157. package/dist/x/hono.d.ts +10 -11
  158. package/dist/x/hono.js +3 -3
  159. package/dist/x/sveltekit.cjs +69 -0
  160. package/dist/x/sveltekit.d.cts +45 -0
  161. package/dist/x/sveltekit.d.ts +10 -11
  162. package/dist/x/sveltekit.js +3 -3
  163. package/package.json +79 -23
  164. package/dist/assert_throws-BOO88avQ.js +0 -39
  165. package/dist/authdocloader-BFVqUbyo.js +0 -52
  166. package/dist/compat-Bb5myD13.js +0 -4
  167. package/dist/docloader-CxWcuWqQ.d.ts +0 -221
  168. package/dist/docloader-DEhniCVa.js +0 -4615
  169. package/dist/key-CUZQgVlf.js +0 -10
  170. package/dist/key-Deb0_wWL.js +0 -10
  171. package/dist/key-DxA6xRtZ.js +0 -260
  172. package/dist/lookup-dtdr2ftf.js +0 -131
  173. package/dist/middleware-BE_geSiJ.js +0 -17
  174. package/dist/middleware-BnU6hzVp.js +0 -26
  175. package/dist/mod-TFoH2Ql8.d.ts +0 -104
  176. package/dist/nodeinfo/semver.test.js +0 -143
  177. package/dist/nodeinfo-CyEbLjHs.js +0 -4
  178. package/dist/runtime/docloader.test.js +0 -522
  179. package/dist/runtime/key.test.js +0 -103
  180. package/dist/runtime/langstr.test.d.ts +0 -3
  181. package/dist/runtime/langstr.test.js +0 -39
  182. package/dist/runtime/mod.d.ts +0 -8
  183. package/dist/runtime/mod.js +0 -13
  184. package/dist/runtime/multibase/multibase.test.d.ts +0 -3
  185. package/dist/runtime/multibase/multibase.test.js +0 -358
  186. package/dist/runtime/url.test.d.ts +0 -3
  187. package/dist/runtime/url.test.js +0 -45
  188. package/dist/runtime-BSkOVUWM.js +0 -4
  189. package/dist/semver-dArNLkR9.js +0 -149
  190. package/dist/sig-BXJO--F9.js +0 -4
  191. package/dist/webfinger-C3GIyXIg.js +0 -4
  192. /package/dist/{assert_not_equals-f3m3epl3.js → assert_not_equals-C80BG-_5.js} +0 -0
  193. /package/dist/{collection-CSzG2j1P.js → collection-BzWsN9pB.js} +0 -0
  194. /package/dist/{denokv-Bv33Xxea.js → denokv-CCssOzMJ.js} +0 -0
  195. /package/dist/{nodeinfo/semver.test.d.ts → federation/idempotency.test.d.ts} +0 -0
  196. /package/dist/{runtime/authdocloader.test.d.ts → federation/negotiation.test.d.ts} +0 -0
  197. /package/dist/{kv-C7sopW2E.d.ts → kv-BKNZ-Tb-.d.ts} +0 -0
  198. /package/dist/{mod-1pDWKvUL.d.ts → mod-CVgZgliM.d.ts} +0 -0
  199. /package/dist/{mod-g0xFzAP9.d.ts → mod-xIj-IT58.d.ts} +0 -0
  200. /package/dist/{mq-CRGm1e_F.d.ts → mq-CUKlBw08.d.ts} +0 -0
  201. /package/dist/{retry-D4GJ670a.js → retry-CfF8Gn4d.js} +0 -0
  202. /package/dist/{std__assert-X-_kMxKM.js → std__assert-DWivtrGR.js} +0 -0
  203. /package/dist/{runtime → utils}/docloader.test.d.ts +0 -0
  204. /package/dist/{runtime/key.test.d.ts → utils/kv-cache.test.d.ts} +0 -0
@@ -1,123 +1,15 @@
1
1
 
2
- import { Temporal } from "@js-temporal/polyfill";
3
- import { URLPattern } from "urlpattern-polyfill";
4
- globalThis.addEventListener = () => {};
5
-
6
- import { Object as Object$1, deno_default, getDocumentLoader, getTypeId, lookupWebFinger } from "./type-SK-d7Tbw.js";
7
- import { cloneDeep, delay } from "es-toolkit";
8
- import { getLogger } from "@logtape/logtape";
9
- import { SpanStatusCode, trace } from "@opentelemetry/api";
10
- import { Router } from "uri-template-router";
11
- import { parseTemplate } from "url-template";
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 document = null;
156
+ let remoteDoc = null;
244
157
  if (identifier.protocol === "http:" || identifier.protocol === "https:") try {
245
- const remoteDoc = await documentLoader(identifier.href, { signal: options.signal });
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 (document == null) {
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
- const remoteDoc = await documentLoader(l.href, { signal: options.signal });
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 (document == null) return null;
181
+ if (remoteDoc == null) return null;
182
+ let object;
271
183
  try {
272
- return await Object$1.fromJsonLd(document, {
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
- error,
281
- document
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
- export { Router$1 as Router, RouterError, lookupObject, traverseCollection };
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 "../type-SK-d7Tbw.js";
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-BRgu1IH8.js";
12
- import "../semver-dArNLkR9.js";
13
- import "../client-De-z2UnN.js";
14
- import "../lookup-Bn_HEC_d.js";
15
- import "../types-BIgY6c-l.js";
16
- import "../actor-Cc6B76eG.js";
17
- import "../key-CzLv1phF.js";
18
- import "../http-CcdM1brU.js";
19
- import "../authdocloader-CLgDGafZ.js";
20
- import "../ld-CBcQdZ6N.js";
21
- import "../owner-VEIjmR8r.js";
22
- import "../proof-DoSQAGkE.js";
23
- import "../inbox-B6DZbGNf.js";
24
- import "../builder-BOEBObR8.js";
25
- import "../collection-CSzG2j1P.js";
26
- import "../keycache-B8HdZJSt.js";
27
- import "../retry-D4GJ670a.js";
28
- import "../send-BzS7w-QF.js";
29
- import { createRequestContext, test } from "../testing-Z2omCvKy.js";
30
- import "../std__assert-X-_kMxKM.js";
31
- import "../assert_rejects-DiIiJbZn.js";
32
- import "../assert_is_error-BPGph1Jx.js";
33
- import "../assert_not_equals-f3m3epl3.js";
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 "../type-SK-d7Tbw.js";
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 "../lookup-Bn_HEC_d.js";
11
- import { test } from "../testing-Z2omCvKy.js";
12
- import "../std__assert-X-_kMxKM.js";
13
- import "../assert_rejects-DiIiJbZn.js";
14
- import "../assert_is_error-BPGph1Jx.js";
15
- import "../assert_not_equals-f3m3epl3.js";
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;
@@ -0,0 +1,2 @@
1
+ import { Link, LookupWebFingerOptions, ResourceDescriptor, lookupWebFinger } from "../mod-C58MZ7Wx.cjs";
2
+ export { Link, LookupWebFingerOptions, ResourceDescriptor, lookupWebFinger };
@@ -1,6 +1,4 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import "../kv-C7sopW2E.js";
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 };
@@ -1,9 +1,8 @@
1
1
 
2
- import { Temporal } from "@js-temporal/polyfill";
3
- import { URLPattern } from "urlpattern-polyfill";
4
-
5
- import "../docloader-DEhniCVa.js";
6
- import { lookupWebFinger } from "../lookup-dtdr2ftf.js";
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,4 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+
@@ -0,0 +1,4 @@
1
+
2
+ const { Temporal } = require("@js-temporal/polyfill");
3
+ const { URLPattern } = require("urlpattern-polyfill");
4
+
@@ -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 };
@@ -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-C7sopW2E.js";
4
- import { MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions } from "../mq-CRGm1e_F.js";
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
@@ -1,7 +1,7 @@
1
1
 
2
- import { Temporal } from "@js-temporal/polyfill";
3
- import { URLPattern } from "urlpattern-polyfill";
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