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

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 (203) hide show
  1. package/README.md +16 -10
  2. package/dist/{actor-BX-pKSuT.js → actor-B9oI1pGu.js} +2 -5
  3. package/dist/{actor-1rvS-py8.d.ts → actor-CYyhXZHp.d.ts} +3 -3
  4. package/dist/{actor-C02Getjh.js → actor-Cg2FBINf.js} +189 -189
  5. package/dist/{assert-DwEa6glZ.js → assert-MZs1qjMx.js} +2 -2
  6. package/dist/{assert_equals-C5gKCm6A.js → assert_equals-DSbWqCm3.js} +9 -9
  7. package/dist/{assert_instance_of-C9QtN-X9.js → assert_instance_of-DHz7EHNU.js} +2 -2
  8. package/dist/{assert_is_error-DQdKoRgb.js → assert_is_error-BPGph1Jx.js} +2 -2
  9. package/dist/{assert_not_equals-7pyUM3Ib.js → assert_not_equals-f3m3epl3.js} +2 -2
  10. package/dist/{assert_rejects-DceVjUlD.js → assert_rejects-DiIiJbZn.js} +4 -4
  11. package/dist/{assert_throws-DTDC_gwN.js → assert_throws-BOO88avQ.js} +3 -3
  12. package/dist/{authdocloader-BbVFhkcz.js → authdocloader-0urt38S6.js} +4 -4
  13. package/dist/{authdocloader-BZs3nvC8.js → authdocloader-BkwhwBf_.js} +4 -5
  14. package/dist/{builder-DuW8p2S3.js → builder-B-wZuoFJ.js} +75 -6
  15. package/dist/{client-DK4qnXK0.d.ts → client-B_KFjN3D.d.ts} +4 -4
  16. package/dist/{client-BD0mI7gk.js → client-Cr3DvU-q.js} +3 -3
  17. package/dist/{collection-Dfb0TPno.js → collection-CSzG2j1P.js} +1 -1
  18. package/dist/compat/mod.d.ts +12 -12
  19. package/dist/compat/mod.js +1 -1
  20. package/dist/compat/transformers.test.js +25 -32
  21. package/dist/{context-BhO5LP_t.d.ts → context-BRl3Ndz3.d.ts} +286 -73
  22. package/dist/{denokv-QWKsIqML.js → denokv-2x6-IpXO.js} +1 -1
  23. package/dist/{docloader-umQd797n.js → docloader-BLgRerm3.js} +41 -40
  24. package/dist/{docloader-DtGccyuM.d.ts → docloader-DJT1UZH4.d.ts} +5 -2
  25. package/dist/{esm-d-9EVGaP.js → esm-CRotYXVH.js} +15 -15
  26. package/dist/federation/builder.test.js +35 -21
  27. package/dist/federation/collection.test.js +13 -11
  28. package/dist/federation/handler.test.js +341 -40
  29. package/dist/federation/inbox.test.js +8 -12
  30. package/dist/federation/keycache.test.js +9 -12
  31. package/dist/federation/kv.test.js +13 -11
  32. package/dist/federation/middleware.test.js +65 -42
  33. package/dist/federation/mod.d.ts +12 -12
  34. package/dist/federation/mod.js +12 -12
  35. package/dist/federation/mq.test.js +15 -13
  36. package/dist/federation/retry.test.js +7 -5
  37. package/dist/federation/router.test.js +12 -11
  38. package/dist/federation/send.test.js +19 -25
  39. package/dist/{federation-C44ekWNP.js → federation-CMX7WzeL.js} +2 -2
  40. package/dist/{http-D59x3pzl.js → http-BkzChfDi.js} +5 -5
  41. package/dist/{http-Cp-0z2Ja.d.ts → http-CMfQwn0N.d.ts} +6 -6
  42. package/dist/{http-CkS9JLmm.js → http-g01-ecph.js} +6 -5
  43. package/dist/{inbox-BjyNe-HL.js → inbox-CpONbSbQ.js} +2 -4
  44. package/dist/{key-jxin-rRq.js → key-B9Yg9Nqz.js} +4 -5
  45. package/dist/{key-Btkh3AwY.js → key-C3aLobhY.js} +4 -4
  46. package/dist/{key-Cf8lNopw.js → key-DdT7xoLD.js} +4 -4
  47. package/dist/key-RnJPgo1m.js +10 -0
  48. package/dist/{keycache-BC5bL06g.js → keycache-BvyhLLHV.js} +2 -2
  49. package/dist/{keys-Dfntfi5m.js → keys-BRSTnUlp.js} +2 -2
  50. package/dist/{kv-DDdb1hMa.d.ts → kv-C7sopW2E.d.ts} +2 -2
  51. package/dist/{kv-D7Yt6pnB.js → kv-CRZrzyXm.js} +1 -1
  52. package/dist/{ld-DwoZFwEd.js → ld-i6KANj32.js} +3 -5
  53. package/dist/{lookup-CAXRxPZ3.js → lookup-BGA_VdZm.js} +115 -8
  54. package/dist/{lookup-gQIU9tXW.js → lookup-D5NvwwsS.js} +2 -2
  55. package/dist/{lookup-m3U6KA0u.d.ts → lookup-DXPWo3Hz.d.ts} +3 -3
  56. package/dist/{middleware-BOHju0mN.js → middleware-BdFHk7bB.js} +629 -24
  57. package/dist/{middleware-cN6r9o1m.js → middleware-Chh21-S_.js} +563 -32
  58. package/dist/middleware-DEwSbDYQ.js +26 -0
  59. package/dist/middleware-DyY-_2Np.js +17 -0
  60. package/dist/{mod-c1I-Ydch.d.ts → mod-Cozftwmt.d.ts} +4 -4
  61. package/dist/{mod-yPzXIjJX.d.ts → mod-DHoWcUrW.d.ts} +6 -6
  62. package/dist/{mod-nlVEnYuj.d.ts → mod-DyY7EVjn.d.ts} +6 -6
  63. package/dist/{mod-BqCBztub.d.ts → mod-DyvbAsBu.d.ts} +6 -6
  64. package/dist/mod.d.ts +15 -15
  65. package/dist/mod.js +12 -12
  66. package/dist/{mq-DYKDDJmp.d.ts → mq-CRGm1e_F.d.ts} +1 -1
  67. package/dist/nodeinfo/client.test.js +15 -15
  68. package/dist/nodeinfo/handler.test.js +30 -39
  69. package/dist/nodeinfo/mod.d.ts +3 -3
  70. package/dist/nodeinfo/mod.js +2 -2
  71. package/dist/nodeinfo/semver.test.js +13 -11
  72. package/dist/nodeinfo/types.test.js +14 -12
  73. package/dist/{owner-BK4eWKBp.d.ts → owner-CfnEgfAc.d.ts} +4 -4
  74. package/dist/{owner-BrSLT3By.js → owner-DSr0c3Yp.js} +3 -4
  75. package/dist/{proof-u4rhYX_R.js → proof-B83O-qBN.js} +4 -6
  76. package/dist/{proof-BDYegzwN.js → proof-a4fXDkG3.js} +7 -7
  77. package/dist/{retry-BiIhZWgD.js → retry-D4GJ670a.js} +1 -1
  78. package/dist/runtime/authdocloader.test.js +18 -24
  79. package/dist/runtime/docloader.test.js +14 -15
  80. package/dist/runtime/key.test.js +14 -19
  81. package/dist/runtime/langstr.test.js +12 -11
  82. package/dist/runtime/mod.d.ts +5 -5
  83. package/dist/runtime/mod.js +6 -6
  84. package/dist/runtime/multibase/multibase.test.js +12 -11
  85. package/dist/runtime/url.test.js +8 -7
  86. package/dist/{semver-DWClQt_5.js → semver-dArNLkR9.js} +1 -1
  87. package/dist/{send-DRDKgORs.js → send-QRloWueE.js} +3 -3
  88. package/dist/sig/http.test.js +40 -23
  89. package/dist/sig/key.test.js +15 -21
  90. package/dist/sig/ld.test.js +13 -19
  91. package/dist/sig/mod.d.ts +7 -7
  92. package/dist/sig/mod.js +6 -6
  93. package/dist/sig/owner.test.js +16 -23
  94. package/dist/sig/proof.test.js +16 -22
  95. package/dist/{std__assert-B3iAixc-.js → std__assert-X-_kMxKM.js} +6 -6
  96. package/dist/testing/docloader.test.js +12 -11
  97. package/dist/testing/mod.d.ts +8622 -2
  98. package/dist/testing/mod.js +4 -2
  99. package/dist/testing-A4u9tSVX.js +302 -0
  100. package/dist/{transformers-ghwJuzGY.js → transformers-Dna8Fg7k.js} +4 -4
  101. package/dist/{vocab-C4cyrUaT.js → type-DHDlfpLg.js} +5246 -185
  102. package/dist/{types-C7C_l-jz.js → types-BIgY6c-l.js} +2 -2
  103. package/dist/{types-D1lhruqy.js → types-DbFIDnXK.js} +4 -4
  104. package/dist/vocab/actor.test.js +143 -149
  105. package/dist/vocab/lookup.test.js +37 -20
  106. package/dist/vocab/mod.d.ts +5 -5
  107. package/dist/vocab/mod.js +4 -4
  108. package/dist/vocab/type.test.js +5 -9
  109. package/dist/vocab/vocab.test.js +54 -58
  110. package/dist/{vocab-BaWeqg9y.js → vocab-DN6Plgg2.js} +6 -6
  111. package/dist/{vocab-B52eQhpN.d.ts → vocab-KgaI50mH.d.ts} +3 -3
  112. package/dist/webfinger/handler.test.js +30 -39
  113. package/dist/webfinger/lookup.test.js +13 -14
  114. package/dist/webfinger/mod.d.ts +3 -3
  115. package/dist/webfinger/mod.js +2 -2
  116. package/dist/x/cfworkers.d.ts +3 -3
  117. package/dist/x/cfworkers.js +1 -1
  118. package/dist/x/cfworkers.test.js +13 -11
  119. package/dist/x/hono.d.ts +16 -16
  120. package/dist/x/hono.js +3 -3
  121. package/dist/x/sveltekit.d.ts +13 -13
  122. package/dist/x/sveltekit.js +2 -2
  123. package/package.json +3 -3
  124. package/dist/chunk-HsBuZ-b2.js +0 -41
  125. package/dist/context-V7yd31ov.js +0 -108
  126. package/dist/docloader-Bh-sDknx.js +0 -68
  127. package/dist/docloader-D5BOqs-9.js +0 -4514
  128. package/dist/key-DqZKjPjH.js +0 -16
  129. package/dist/langstr-DbWheeIS.js +0 -33
  130. package/dist/lookup-DvfZUKur.js +0 -133
  131. package/dist/middleware-31SyXabg.js +0 -33
  132. package/dist/middleware-CGl-YyTa.js +0 -17
  133. package/dist/multibase-DeCHcK8L.js +0 -316
  134. package/dist/router-D3UybECj.js +0 -118
  135. package/dist/testing-BZ0dJ4qn.js +0 -143
  136. package/dist/type-D2s5lmbZ.js +0 -14
  137. package/dist/url-kTAI6_KP.js +0 -68
  138. /package/dist/{vocab → src/vocab}/accept.yaml +0 -0
  139. /package/dist/{vocab → src/vocab}/activity.yaml +0 -0
  140. /package/dist/{vocab → src/vocab}/add.yaml +0 -0
  141. /package/dist/{vocab → src/vocab}/announce.yaml +0 -0
  142. /package/dist/{vocab → src/vocab}/application.yaml +0 -0
  143. /package/dist/{vocab → src/vocab}/arrive.yaml +0 -0
  144. /package/dist/{vocab → src/vocab}/article.yaml +0 -0
  145. /package/dist/{vocab → src/vocab}/audio.yaml +0 -0
  146. /package/dist/{vocab → src/vocab}/block.yaml +0 -0
  147. /package/dist/{vocab → src/vocab}/chatmessage.yaml +0 -0
  148. /package/dist/{vocab → src/vocab}/collection.yaml +0 -0
  149. /package/dist/{vocab → src/vocab}/collectionpage.yaml +0 -0
  150. /package/dist/{vocab → src/vocab}/create.yaml +0 -0
  151. /package/dist/{vocab → src/vocab}/dataintegrityproof.yaml +0 -0
  152. /package/dist/{vocab → src/vocab}/delete.yaml +0 -0
  153. /package/dist/{vocab → src/vocab}/didservice.yaml +0 -0
  154. /package/dist/{vocab → src/vocab}/dislike.yaml +0 -0
  155. /package/dist/{vocab → src/vocab}/document.yaml +0 -0
  156. /package/dist/{vocab → src/vocab}/emoji.yaml +0 -0
  157. /package/dist/{vocab → src/vocab}/emojireact.yaml +0 -0
  158. /package/dist/{vocab → src/vocab}/endpoints.yaml +0 -0
  159. /package/dist/{vocab → src/vocab}/event.yaml +0 -0
  160. /package/dist/{vocab → src/vocab}/export.yaml +0 -0
  161. /package/dist/{vocab → src/vocab}/flag.yaml +0 -0
  162. /package/dist/{vocab → src/vocab}/follow.yaml +0 -0
  163. /package/dist/{vocab → src/vocab}/group.yaml +0 -0
  164. /package/dist/{vocab → src/vocab}/hashtag.yaml +0 -0
  165. /package/dist/{vocab → src/vocab}/ignore.yaml +0 -0
  166. /package/dist/{vocab → src/vocab}/image.yaml +0 -0
  167. /package/dist/{vocab → src/vocab}/intransitiveactivity.yaml +0 -0
  168. /package/dist/{vocab → src/vocab}/invite.yaml +0 -0
  169. /package/dist/{vocab → src/vocab}/join.yaml +0 -0
  170. /package/dist/{vocab → src/vocab}/key.yaml +0 -0
  171. /package/dist/{vocab → src/vocab}/leave.yaml +0 -0
  172. /package/dist/{vocab → src/vocab}/like.yaml +0 -0
  173. /package/dist/{vocab → src/vocab}/link.yaml +0 -0
  174. /package/dist/{vocab → src/vocab}/listen.yaml +0 -0
  175. /package/dist/{vocab → src/vocab}/mention.yaml +0 -0
  176. /package/dist/{vocab → src/vocab}/move.yaml +0 -0
  177. /package/dist/{vocab → src/vocab}/multikey.yaml +0 -0
  178. /package/dist/{vocab → src/vocab}/note.yaml +0 -0
  179. /package/dist/{vocab → src/vocab}/object.yaml +0 -0
  180. /package/dist/{vocab → src/vocab}/offer.yaml +0 -0
  181. /package/dist/{vocab → src/vocab}/orderedcollection.yaml +0 -0
  182. /package/dist/{vocab → src/vocab}/orderedcollectionpage.yaml +0 -0
  183. /package/dist/{vocab → src/vocab}/organization.yaml +0 -0
  184. /package/dist/{vocab → src/vocab}/page.yaml +0 -0
  185. /package/dist/{vocab → src/vocab}/person.yaml +0 -0
  186. /package/dist/{vocab → src/vocab}/place.yaml +0 -0
  187. /package/dist/{vocab → src/vocab}/profile.yaml +0 -0
  188. /package/dist/{vocab → src/vocab}/propertyvalue.yaml +0 -0
  189. /package/dist/{vocab → src/vocab}/question.yaml +0 -0
  190. /package/dist/{vocab → src/vocab}/read.yaml +0 -0
  191. /package/dist/{vocab → src/vocab}/reject.yaml +0 -0
  192. /package/dist/{vocab → src/vocab}/relationship.yaml +0 -0
  193. /package/dist/{vocab → src/vocab}/remove.yaml +0 -0
  194. /package/dist/{vocab → src/vocab}/service.yaml +0 -0
  195. /package/dist/{vocab → src/vocab}/source.yaml +0 -0
  196. /package/dist/{vocab → src/vocab}/tentativeaccept.yaml +0 -0
  197. /package/dist/{vocab → src/vocab}/tentativereject.yaml +0 -0
  198. /package/dist/{vocab → src/vocab}/tombstone.yaml +0 -0
  199. /package/dist/{vocab → src/vocab}/travel.yaml +0 -0
  200. /package/dist/{vocab → src/vocab}/undo.yaml +0 -0
  201. /package/dist/{vocab → src/vocab}/update.yaml +0 -0
  202. /package/dist/{vocab → src/vocab}/video.yaml +0 -0
  203. /package/dist/{vocab → src/vocab}/view.yaml +0 -0
@@ -3,15 +3,122 @@
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-DHDlfpLg.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
 
14
- //#region vocab/handle.ts
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
+ //#region src/vocab/handle.ts
15
122
  /**
16
123
  * Regular expression to match a fediverse handle in the format `@user@server`
17
124
  * or `user@server`. The `user` part can contain alphanumeric characters and
@@ -68,7 +175,7 @@ function toAcctUrl(handle) {
68
175
  }
69
176
 
70
177
  //#endregion
71
- //#region vocab/lookup.ts
178
+ //#region src/vocab/lookup.ts
72
179
  const logger = getLogger([
73
180
  "fedify",
74
181
  "vocab",
@@ -212,4 +319,4 @@ async function* traverseCollection(collection, options = {}) {
212
319
  }
213
320
 
214
321
  //#endregion
215
- export { lookupObject, traverseCollection };
322
+ export { Router$1 as Router, RouterError, lookupObject, traverseCollection };
@@ -2,11 +2,11 @@
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-BLgRerm3.js";
6
6
  import { getLogger } from "@logtape/logtape";
7
7
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
8
8
 
9
- //#region webfinger/lookup.ts
9
+ //#region src/webfinger/lookup.ts
10
10
  const logger = getLogger([
11
11
  "fedify",
12
12
  "webfinger",
@@ -1,9 +1,9 @@
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-DJT1UZH4.js";
4
4
  import { TracerProvider } from "@opentelemetry/api";
5
5
 
6
- //#region webfinger/jrd.d.ts
6
+ //#region src/webfinger/jrd.d.ts
7
7
  /**
8
8
  * Describes a resource. See also
9
9
  * [RFC 7033 section 4.4](https://datatracker.ietf.org/doc/html/rfc7033#section-4.4).
@@ -56,7 +56,7 @@ interface Link {
56
56
  properties?: Record<string, string>;
57
57
  }
58
58
  //#endregion
59
- //#region webfinger/lookup.d.ts
59
+ //#region src/webfinger/lookup.d.ts
60
60
  /**
61
61
  * Options for {@link lookupWebFinger}.
62
62
  * @since 1.3.0