@fedify/fedify 1.8.1-pr.315.1090 → 1.8.1-pr.318.1225

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 (130) hide show
  1. package/README.md +4 -1
  2. package/dist/{actor-BX-pKSuT.js → actor-C5n4A944.js} +1 -4
  3. package/dist/{actor-1rvS-py8.d.ts → actor-CWNAGvnO.d.ts} +2 -2
  4. package/dist/{actor-C02Getjh.js → actor-s5mQBwHr.js} +179 -179
  5. package/dist/{assert_rejects-DceVjUlD.js → assert_rejects-AjlKk-Vo.js} +1 -1
  6. package/dist/{assert_throws-DTDC_gwN.js → assert_throws-CqMKbTh_.js} +1 -1
  7. package/dist/{authdocloader-BZs3nvC8.js → authdocloader-4RSyvLgz.js} +4 -5
  8. package/dist/{authdocloader-BbVFhkcz.js → authdocloader-CPaXUreA.js} +4 -4
  9. package/dist/{builder-DuW8p2S3.js → builder-CChGxW97.js} +74 -5
  10. package/dist/{client-BD0mI7gk.js → client-49mgdebk.js} +2 -2
  11. package/dist/{client-DK4qnXK0.d.ts → client-B0IOer6B.d.ts} +1 -1
  12. package/dist/compat/mod.d.ts +11 -11
  13. package/dist/compat/mod.js +1 -1
  14. package/dist/compat/transformers.test.js +20 -27
  15. package/dist/{context-BhO5LP_t.d.ts → context-BNA3vzcr.d.ts} +273 -60
  16. package/dist/{docloader-DtGccyuM.d.ts → docloader-CLolPVL_.d.ts} +2 -11
  17. package/dist/{docloader-umQd797n.js → docloader-DfooRmPz.js} +26 -13
  18. package/dist/{esm-d-9EVGaP.js → esm-3l5DpT9c.js} +1 -1
  19. package/dist/federation/builder.test.js +30 -16
  20. package/dist/federation/collection.test.js +9 -7
  21. package/dist/federation/handler.test.js +336 -35
  22. package/dist/federation/inbox.test.js +6 -10
  23. package/dist/federation/keycache.test.js +4 -7
  24. package/dist/federation/kv.test.js +8 -6
  25. package/dist/federation/middleware.test.js +58 -35
  26. package/dist/federation/mod.d.ts +11 -11
  27. package/dist/federation/mod.js +11 -11
  28. package/dist/federation/mq.test.js +10 -8
  29. package/dist/federation/retry.test.js +5 -3
  30. package/dist/federation/router.test.js +8 -7
  31. package/dist/federation/send.test.js +15 -21
  32. package/dist/{http-Cp-0z2Ja.d.ts → http-COez3YdK.d.ts} +4 -4
  33. package/dist/{http-CkS9JLmm.js → http-CsGPBDOo.js} +5 -4
  34. package/dist/{http-D59x3pzl.js → http-DyZD6UXI.js} +4 -4
  35. package/dist/{inbox-BjyNe-HL.js → inbox-DVl0Nqfm.js} +1 -3
  36. package/dist/{key-Btkh3AwY.js → key-CNNi5ktf.js} +3 -3
  37. package/dist/{key-jxin-rRq.js → key-CvnCx-As.js} +3 -4
  38. package/dist/{key-Cf8lNopw.js → key-MvqIkRnS.js} +4 -4
  39. package/dist/key-X4-XaJF1.js +10 -0
  40. package/dist/{keycache-BC5bL06g.js → keycache-BZR7b67J.js} +1 -1
  41. package/dist/{keys-Dfntfi5m.js → keys-CFFCiRYU.js} +1 -1
  42. package/dist/{kv-DDdb1hMa.d.ts → kv-BqOK6zss.d.ts} +1 -1
  43. package/dist/{ld-DwoZFwEd.js → ld-BDA3JCwf.js} +2 -4
  44. package/dist/{lookup-CAXRxPZ3.js → lookup-DcB1UuZA.js} +116 -10
  45. package/dist/{lookup-gQIU9tXW.js → lookup-mq8Ba5Kb.js} +2 -3
  46. package/dist/{lookup-m3U6KA0u.d.ts → lookup-tSXYzgYs.d.ts} +1 -7
  47. package/dist/{middleware-BOHju0mN.js → middleware-BKoKlIe8.js} +617 -12
  48. package/dist/middleware-CJiChbvg.js +26 -0
  49. package/dist/middleware-D6H2vPkH.js +17 -0
  50. package/dist/{middleware-cN6r9o1m.js → middleware-XOfMDFVl.js} +556 -25
  51. package/dist/{mod-yPzXIjJX.d.ts → mod-Bf-mThHd.d.ts} +4 -4
  52. package/dist/{mod-BqCBztub.d.ts → mod-C2jQirfr.d.ts} +2 -7
  53. package/dist/{mod-nlVEnYuj.d.ts → mod-CxD6XXBN.d.ts} +5 -5
  54. package/dist/{mod-c1I-Ydch.d.ts → mod-UTC30uNC.d.ts} +2 -2
  55. package/dist/mod.d.ts +14 -14
  56. package/dist/mod.js +11 -11
  57. package/dist/nodeinfo/client.test.js +11 -11
  58. package/dist/nodeinfo/handler.test.js +25 -34
  59. package/dist/nodeinfo/mod.d.ts +3 -3
  60. package/dist/nodeinfo/mod.js +2 -2
  61. package/dist/nodeinfo/semver.test.js +9 -7
  62. package/dist/nodeinfo/types.test.js +10 -8
  63. package/dist/{owner-BK4eWKBp.d.ts → owner-BlxMNrL4.d.ts} +3 -3
  64. package/dist/{owner-BrSLT3By.js → owner-D_-GBbn-.js} +2 -3
  65. package/dist/{proof-u4rhYX_R.js → proof-BnFHVB6H.js} +3 -5
  66. package/dist/{proof-BDYegzwN.js → proof-C94_doNG.js} +4 -4
  67. package/dist/runtime/authdocloader.test.js +14 -20
  68. package/dist/runtime/docloader.test.js +9 -10
  69. package/dist/runtime/key.test.js +10 -15
  70. package/dist/runtime/langstr.test.js +8 -7
  71. package/dist/runtime/mod.d.ts +5 -5
  72. package/dist/runtime/mod.js +6 -6
  73. package/dist/runtime/multibase/multibase.test.js +8 -7
  74. package/dist/runtime/url.test.js +5 -4
  75. package/dist/{send-DRDKgORs.js → send-DcuZAIY1.js} +2 -2
  76. package/dist/sig/http.test.js +36 -19
  77. package/dist/sig/key.test.js +11 -17
  78. package/dist/sig/ld.test.js +10 -16
  79. package/dist/sig/mod.d.ts +7 -7
  80. package/dist/sig/mod.js +6 -6
  81. package/dist/sig/owner.test.js +12 -19
  82. package/dist/sig/proof.test.js +12 -18
  83. package/dist/testing/docloader.test.js +8 -7
  84. package/dist/testing/mod.d.ts +8599 -1
  85. package/dist/testing/mod.js +4 -2
  86. package/dist/testing-C4oxyGxC.js +302 -0
  87. package/dist/{transformers-ghwJuzGY.js → transformers-DJRB0yFF.js} +3 -3
  88. package/dist/{vocab-C4cyrUaT.js → type-CFzYOYUt.js} +5255 -183
  89. package/dist/{types-D1lhruqy.js → types-Cr8o5d6d.js} +1 -1
  90. package/dist/{types-C7C_l-jz.js → types-n7HI7VFr.js} +1 -1
  91. package/dist/vocab/actor.test.js +10 -16
  92. package/dist/vocab/lookup.test.js +11 -86
  93. package/dist/vocab/mod.d.ts +5 -5
  94. package/dist/vocab/mod.js +4 -4
  95. package/dist/vocab/type.test.js +3 -7
  96. package/dist/vocab/vocab.test.js +9 -13
  97. package/dist/{vocab-BaWeqg9y.js → vocab-BwGxoM8R.js} +6 -7
  98. package/dist/{vocab-B52eQhpN.d.ts → vocab-Cyrb7_co.d.ts} +1 -1
  99. package/dist/webfinger/handler.test.js +25 -34
  100. package/dist/webfinger/lookup.test.js +9 -64
  101. package/dist/webfinger/mod.d.ts +3 -3
  102. package/dist/webfinger/mod.js +2 -2
  103. package/dist/x/cfworkers.d.ts +1 -1
  104. package/dist/x/cfworkers.test.js +8 -6
  105. package/dist/x/hono.d.ts +14 -14
  106. package/dist/x/hono.js +2 -2
  107. package/dist/x/sveltekit.d.ts +11 -11
  108. package/dist/x/sveltekit.js +1 -1
  109. package/package.json +1 -1
  110. package/dist/chunk-HsBuZ-b2.js +0 -41
  111. package/dist/context-V7yd31ov.js +0 -108
  112. package/dist/docloader-Bh-sDknx.js +0 -68
  113. package/dist/docloader-D5BOqs-9.js +0 -4514
  114. package/dist/key-DqZKjPjH.js +0 -16
  115. package/dist/langstr-DbWheeIS.js +0 -33
  116. package/dist/lookup-DvfZUKur.js +0 -133
  117. package/dist/middleware-31SyXabg.js +0 -33
  118. package/dist/middleware-CGl-YyTa.js +0 -17
  119. package/dist/multibase-DeCHcK8L.js +0 -316
  120. package/dist/router-D3UybECj.js +0 -118
  121. package/dist/testing-BZ0dJ4qn.js +0 -143
  122. package/dist/type-D2s5lmbZ.js +0 -14
  123. package/dist/url-kTAI6_KP.js +0 -68
  124. /package/dist/{assert_is_error-DQdKoRgb.js → assert_is_error-CeVBLPsZ.js} +0 -0
  125. /package/dist/{assert_not_equals-7pyUM3Ib.js → assert_not_equals-D2R2nl5h.js} +0 -0
  126. /package/dist/{collection-Dfb0TPno.js → collection-D5V3UzU3.js} +0 -0
  127. /package/dist/{denokv-QWKsIqML.js → denokv-DK9P5Jq7.js} +0 -0
  128. /package/dist/{retry-BiIhZWgD.js → retry-BnpVRGFC.js} +0 -0
  129. /package/dist/{semver-DWClQt_5.js → semver-DCqorrj5.js} +0 -0
  130. /package/dist/{std__assert-B3iAixc-.js → std__assert-BQdmxyzF.js} +0 -0
@@ -3,14 +3,121 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { deno_default, getDocumentLoader } from "./docloader-D5BOqs-9.js";
7
- import { Object as Object$1 } from "./vocab-C4cyrUaT.js";
8
- import { lookupWebFinger } from "./lookup-DvfZUKur.js";
9
- import { getTypeId } from "./type-D2s5lmbZ.js";
10
- import { delay } from "es-toolkit";
6
+ import { Object as Object$1, deno_default, getDocumentLoader, getTypeId, lookupWebFinger } from "./type-CFzYOYUt.js";
7
+ import { cloneDeep, delay } from "es-toolkit";
11
8
  import { getLogger } from "@logtape/logtape";
12
9
  import { SpanStatusCode, trace } from "@opentelemetry/api";
10
+ import { Router } from "uri-template-router";
11
+ import { parseTemplate } from "url-template";
13
12
 
13
+ //#region 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
14
121
  //#region vocab/handle.ts
15
122
  /**
16
123
  * Regular expression to match a fediverse handle in the format `@user@server`
@@ -135,7 +242,7 @@ async function lookupObjectInternal(identifier, options = {}) {
135
242
  if (typeof identifier === "string") identifier = toAcctUrl(identifier) ?? new URL(identifier);
136
243
  let document = null;
137
244
  if (identifier.protocol === "http:" || identifier.protocol === "https:") try {
138
- const remoteDoc = await documentLoader(identifier.href, { signal: options.signal });
245
+ const remoteDoc = await documentLoader(identifier.href);
139
246
  document = remoteDoc.document;
140
247
  } catch (error) {
141
248
  logger.debug("Failed to fetch remote document:\n{error}", { error });
@@ -144,14 +251,13 @@ async function lookupObjectInternal(identifier, options = {}) {
144
251
  const jrd = await lookupWebFinger(identifier, {
145
252
  userAgent: options.userAgent,
146
253
  tracerProvider: options.tracerProvider,
147
- allowPrivateAddress: "allowPrivateAddress" in options && options.allowPrivateAddress === true,
148
- signal: options.signal
254
+ allowPrivateAddress: "allowPrivateAddress" in options && options.allowPrivateAddress === true
149
255
  });
150
256
  if (jrd?.links == null) return null;
151
257
  for (const l of jrd.links) {
152
258
  if (l.type !== "application/activity+json" && !l.type?.match(/application\/ld\+json;\s*profile="https:\/\/www.w3.org\/ns\/activitystreams"/) || l.rel !== "self") continue;
153
259
  try {
154
- const remoteDoc = await documentLoader(l.href, { signal: options.signal });
260
+ const remoteDoc = await documentLoader(l.href);
155
261
  document = remoteDoc.document;
156
262
  break;
157
263
  } catch (error) {
@@ -212,4 +318,4 @@ async function* traverseCollection(collection, options = {}) {
212
318
  }
213
319
 
214
320
  //#endregion
215
- export { lookupObject, traverseCollection };
321
+ export { Router$1 as Router, RouterError, lookupObject, traverseCollection };
@@ -2,7 +2,7 @@
2
2
  import { Temporal } from "@js-temporal/polyfill";
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
 
5
- import { UrlError, deno_default, getUserAgent, validatePublicUrl } from "./docloader-umQd797n.js";
5
+ import { UrlError, deno_default, getUserAgent, validatePublicUrl } from "./docloader-DfooRmPz.js";
6
6
  import { getLogger } from "@logtape/logtape";
7
7
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
8
8
 
@@ -79,8 +79,7 @@ async function lookupWebFingerInternal(resource, options = {}) {
79
79
  Accept: "application/jrd+json",
80
80
  "User-Agent": typeof options.userAgent === "string" ? options.userAgent : getUserAgent(options.userAgent)
81
81
  },
82
- redirect: "manual",
83
- signal: options.signal
82
+ redirect: "manual"
84
83
  });
85
84
  } catch (error) {
86
85
  logger.debug("Failed to fetch WebFinger resource descriptor: {error}", {
@@ -1,6 +1,6 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { GetUserAgentOptions } from "./docloader-DtGccyuM.js";
3
+ import { GetUserAgentOptions } from "./docloader-CLolPVL_.js";
4
4
  import { TracerProvider } from "@opentelemetry/api";
5
5
 
6
6
  //#region webfinger/jrd.d.ts
@@ -89,12 +89,6 @@ interface LookupWebFingerOptions {
89
89
  * is used.
90
90
  */
91
91
  tracerProvider?: TracerProvider;
92
- /**
93
- * AbortSignal for cancelling the request.
94
- * @since 1.8.0
95
- * @
96
- */
97
- signal?: AbortSignal;
98
92
  }
99
93
  /**
100
94
  * Looks up a WebFinger resource.