@fedify/fedify 1.8.0-dev.952 → 1.8.0-dev.955

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 (75) hide show
  1. package/dist/{actor-EzU7ndeu.js → actor-BBNX2iin.js} +3 -3
  2. package/dist/{actor-BWFxNSnR.js → actor-CBeFHn58.js} +179 -179
  3. package/dist/{authdocloader-h0v96Scc.js → authdocloader-BQea-C8q.js} +3 -3
  4. package/dist/{authdocloader-BQKkNzeH.js → authdocloader-a6SFhSoj.js} +3 -3
  5. package/dist/{builder-DbBHCZXD.js → builder-kgS4fcQG.js} +3 -3
  6. package/dist/{client-yKecM_0d.js → client-BdGjFA8O.js} +1 -1
  7. package/dist/compat/mod.d.ts +3 -3
  8. package/dist/compat/transformers.test.js +17 -17
  9. package/dist/{context-y90aX3KP.d.ts → context-BRIf4bt7.d.ts} +1 -1
  10. package/dist/{context-CKwXdbmG.js → context-DxZmwaWK.js} +2 -2
  11. package/dist/{docloader-onqGGiQb.js → docloader-C1p4hcZh.js} +1 -1
  12. package/dist/{docloader-BFuRHsay.js → docloader-COdyz_hE.js} +1 -1
  13. package/dist/federation/builder.test.js +4 -4
  14. package/dist/federation/handler.test.js +19 -19
  15. package/dist/federation/inbox.test.js +3 -3
  16. package/dist/federation/keycache.test.js +3 -3
  17. package/dist/federation/middleware.test.js +18 -18
  18. package/dist/federation/mod.d.ts +2 -2
  19. package/dist/federation/mod.js +10 -10
  20. package/dist/federation/send.test.js +9 -9
  21. package/dist/{http-BkeuJbKU.js → http-BuOvzL3j.js} +3 -3
  22. package/dist/{http-Dm8W6Xii.js → http-CcTgpQTe.js} +3 -3
  23. package/dist/{inbox-B33dAqgO.js → inbox-C3Dqtty9.js} +2 -2
  24. package/dist/{key-tL6-pWKv.js → key-BBfdU8O1.js} +5 -5
  25. package/dist/{key-kDZgr5No.js → key-BKa6LUKn.js} +3 -3
  26. package/dist/{key-DgNRq-3b.js → key-BsUPcX5c.js} +4 -4
  27. package/dist/{key-Cn9gw2pj.js → key-CUUNKU04.js} +2 -2
  28. package/dist/{keycache-Bnl-7eYm.js → keycache-Be2iUcxZ.js} +1 -1
  29. package/dist/{keys-DuQwoYwB.js → keys-Bm-REG0i.js} +1 -1
  30. package/dist/{ld-BTb4k201.js → ld-D8W0sK5u.js} +3 -3
  31. package/dist/{lookup-C7tY3Xdt.js → lookup-BBIBMJMW.js} +1 -1
  32. package/dist/{lookup-BT8SOdcA.js → lookup-CjiXiLHr.js} +1 -1
  33. package/dist/{lookup-M0i1aD0a.js → lookup-i0w8oyqI.js} +61 -9
  34. package/dist/{middleware-C37kF-sp.js → middleware-Aj4Aipev.js} +15 -15
  35. package/dist/{middleware-ClwV-KmF.js → middleware-B-pNPoWJ.js} +10 -10
  36. package/dist/middleware-B45mAes5.js +17 -0
  37. package/dist/middleware-_mJMW7Dl.js +33 -0
  38. package/dist/{mod-CaGwZaei.d.ts → mod-B8p4fzWu.d.ts} +1 -1
  39. package/dist/{mod-BzLUzgBJ.d.ts → mod-BFwgZ7_K.d.ts} +75 -1
  40. package/dist/mod.d.ts +4 -4
  41. package/dist/mod.js +11 -11
  42. package/dist/nodeinfo/client.test.js +2 -2
  43. package/dist/nodeinfo/handler.test.js +18 -18
  44. package/dist/nodeinfo/mod.js +2 -2
  45. package/dist/{owner-eYr4V3my.js → owner-m_iHLHvB.js} +3 -3
  46. package/dist/{proof-DMkP6wLl.js → proof-DFAPxBIn.js} +3 -3
  47. package/dist/{proof-gll-kzgh.js → proof-VlYFbdZH.js} +3 -3
  48. package/dist/runtime/authdocloader.test.js +8 -8
  49. package/dist/runtime/docloader.test.js +1 -1
  50. package/dist/runtime/key.test.js +5 -5
  51. package/dist/runtime/mod.js +6 -6
  52. package/dist/{send-qy1MbuwP.js → send-IbnPrZ-l.js} +2 -2
  53. package/dist/sig/http.test.js +7 -7
  54. package/dist/sig/key.test.js +6 -6
  55. package/dist/sig/ld.test.js +7 -7
  56. package/dist/sig/mod.js +6 -6
  57. package/dist/sig/owner.test.js +8 -8
  58. package/dist/sig/proof.test.js +7 -7
  59. package/dist/{types-Bzi8SON9.js → types-BXDdVms7.js} +1 -1
  60. package/dist/vocab/actor.test.js +4 -4
  61. package/dist/vocab/lookup.test.js +4 -4
  62. package/dist/vocab/mod.d.ts +2 -2
  63. package/dist/vocab/mod.js +5 -5
  64. package/dist/vocab/type.test.js +2 -2
  65. package/dist/vocab/vocab.test.js +3 -3
  66. package/dist/{vocab-DPfUWFNl.js → vocab-CKbd7bbv.js} +178 -178
  67. package/dist/{vocab-CKWclA_p.js → vocab-_zju-sjw.js} +83 -10
  68. package/dist/webfinger/handler.test.js +18 -18
  69. package/dist/webfinger/lookup.test.js +2 -2
  70. package/dist/webfinger/mod.js +2 -2
  71. package/dist/x/hono.d.ts +2 -2
  72. package/dist/x/sveltekit.d.ts +2 -2
  73. package/package.json +1 -1
  74. package/dist/middleware-BYv6Ixgi.js +0 -33
  75. package/dist/middleware-DzQMeTkq.js +0 -17
@@ -2,20 +2,97 @@
2
2
  import { Temporal } from "@js-temporal/polyfill";
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
 
5
- import { deno_default, getDocumentLoader } from "./docloader-onqGGiQb.js";
6
- import { Object as Object$1, getTypeId } from "./actor-BWFxNSnR.js";
7
- import { lookupWebFinger } from "./lookup-C7tY3Xdt.js";
5
+ import { deno_default, getDocumentLoader } from "./docloader-C1p4hcZh.js";
6
+ import { Object as Object$1, getTypeId } from "./actor-CBeFHn58.js";
7
+ import { lookupWebFinger } from "./lookup-BBIBMJMW.js";
8
8
  import { getLogger } from "@logtape/logtape";
9
9
  import { SpanStatusCode, trace } from "@opentelemetry/api";
10
10
  import { delay } from "es-toolkit";
11
11
 
12
+ //#region vocab/handle.ts
13
+ /**
14
+ * Regular expression to match a fediverse handle in the format `@user@server`
15
+ * or `user@server`. The `user` part can contain alphanumeric characters and
16
+ * some special characters except `@`. The `server` part is all characters
17
+ * after the `@` symbol in the middle.
18
+ */
19
+ const handleRegexp = /^@?((?:[-A-Za-z0-9._~!$&'()*+,;=]|%[A-Fa-f0-9]{2})+)@([^@]+)$/;
20
+ /**
21
+ * Parses a fediverse handle in the format `@user@server` or `user@server`.
22
+ * The `user` part can contain alphanumeric characters and some special
23
+ * characters except `@`. The `server` part is all characters after the `@`
24
+ * symbol in the middle.
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * const handle = parseFediverseHandle("@username@example.com");
29
+ * console.log(handle?.username); // "username"
30
+ * console.log(handle?.host); // "example.com"
31
+ * ```
32
+ *
33
+ * @param handle - The fediverse handle string to parse.
34
+ * @returns A {@link FediverseHandle} object with `username` and `host`
35
+ * if the input is valid; otherwise `null`.
36
+ * @since 1.8.0
37
+ */
38
+ function parseFediverseHandle(handle) {
39
+ const match = handleRegexp.exec(handle);
40
+ if (match) return {
41
+ username: match[1],
42
+ host: match[2]
43
+ };
44
+ return null;
45
+ }
46
+ /**
47
+ * Checks if a string is a valid fediverse handle in the format `@user@server`
48
+ * or `user@server`. The `user` part can contain alphanumeric characters and
49
+ * some special characters except `@`. The `server` part is all characters
50
+ * after the `@` symbol in the middle.
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * console.log(isFediverseHandle("@username@example.com")); // true
55
+ * console.log(isFediverseHandle("username@example.com")); // true
56
+ * console.log(isFediverseHandle("@username@")); // false
57
+ * ```
58
+ *
59
+ * @param handle - The string to test as a fediverse handle.
60
+ * @returns `true` if the string matches the fediverse handle pattern;
61
+ * otherwise `false`.
62
+ * @since 1.8.0
63
+ */
64
+ function isFediverseHandle(handle) {
65
+ return handleRegexp.test(handle);
66
+ }
67
+ /**
68
+ * Converts a fediverse handle in the format `@user@server` or `user@server`
69
+ * to an `acct:` URI, which is a URL-like identifier for ActivityPub actors.
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * const identifier = toAcctUrl("@username@example.com");
74
+ * console.log(identifier?.href); // "acct:username@example.com"
75
+ * ```
76
+ *
77
+ * @param handle - The fediverse handle string to convert.
78
+ * @returns A `URL` object representing the `acct:` URI if conversion succeeds;
79
+ * otherwise `null`.
80
+ * @since 1.8.0
81
+ */
82
+ function toAcctUrl(handle) {
83
+ const parsed = parseFediverseHandle(handle);
84
+ if (!parsed) return null;
85
+ const identifier = new URL(`acct:${parsed.username}@${parsed.host}`);
86
+ return identifier;
87
+ }
88
+
89
+ //#endregion
12
90
  //#region vocab/lookup.ts
13
91
  const logger = getLogger([
14
92
  "fedify",
15
93
  "vocab",
16
94
  "lookup"
17
95
  ]);
18
- const handleRegexp = /^@?((?:[-A-Za-z0-9._~!$&'()*+,;=]|%[A-Fa-f0-9]{2})+)@([^@]+)$/;
19
96
  /**
20
97
  * Looks up an ActivityStreams object by its URI (including `acct:` URIs)
21
98
  * or a fediverse handle (e.g., `@user@server` or `user@server`).
@@ -74,11 +151,7 @@ async function lookupObject(identifier, options = {}) {
74
151
  }
75
152
  async function lookupObjectInternal(identifier, options = {}) {
76
153
  const documentLoader = options.documentLoader ?? getDocumentLoader({ userAgent: options.userAgent });
77
- if (typeof identifier === "string") {
78
- const match = handleRegexp.exec(identifier);
79
- if (match) identifier = `acct:${match[1]}@${match[2]}`;
80
- identifier = new URL(identifier);
81
- }
154
+ if (typeof identifier === "string") identifier = toAcctUrl(identifier) ?? new URL(identifier);
82
155
  let document = null;
83
156
  if (identifier.protocol === "http:" || identifier.protocol === "https:") try {
84
157
  const remoteDoc = await documentLoader(identifier.href);
@@ -169,4 +242,4 @@ async function* traverseCollection(collection, options = {}) {
169
242
  const PUBLIC_COLLECTION = new URL("https://www.w3.org/ns/activitystreams#Public");
170
243
 
171
244
  //#endregion
172
- export { PUBLIC_COLLECTION, lookupObject, traverseCollection };
245
+ export { PUBLIC_COLLECTION, isFediverseHandle, lookupObject, parseFediverseHandle, toAcctUrl, traverseCollection };
@@ -7,32 +7,32 @@ import { assertEquals } from "../assert_equals-C5gKCm6A.js";
7
7
  import "../assert-DwEa6glZ.js";
8
8
  import "../assert_instance_of-C9QtN-X9.js";
9
9
  import { MemoryKvStore } from "../kv-D7Yt6pnB.js";
10
- import { createFederation, handleWebFinger } from "../middleware-C37kF-sp.js";
11
- import "../docloader-BFuRHsay.js";
10
+ import { createFederation, handleWebFinger } from "../middleware-Aj4Aipev.js";
11
+ import "../docloader-COdyz_hE.js";
12
12
  import "../url-kTAI6_KP.js";
13
13
  import "../semver-DWClQt_5.js";
14
- import "../client-yKecM_0d.js";
14
+ import "../client-BdGjFA8O.js";
15
15
  import "../router-D3UybECj.js";
16
16
  import "../types-C7C_l-jz.js";
17
17
  import "../multibase-DeCHcK8L.js";
18
- import { Image, Link, Person } from "../vocab-DPfUWFNl.js";
18
+ import { Image, Link, Person } from "../vocab-CKbd7bbv.js";
19
19
  import "../langstr-DbWheeIS.js";
20
- import "../lookup-BT8SOdcA.js";
20
+ import "../lookup-CjiXiLHr.js";
21
21
  import "../type-D2s5lmbZ.js";
22
- import "../actor-EzU7ndeu.js";
23
- import "../key-kDZgr5No.js";
24
- import "../http-BkeuJbKU.js";
25
- import "../authdocloader-BQKkNzeH.js";
26
- import "../ld-BTb4k201.js";
27
- import "../owner-eYr4V3my.js";
28
- import "../proof-DMkP6wLl.js";
29
- import "../lookup-M0i1aD0a.js";
30
- import "../inbox-B33dAqgO.js";
31
- import "../builder-DbBHCZXD.js";
22
+ import "../actor-BBNX2iin.js";
23
+ import "../key-BKa6LUKn.js";
24
+ import "../http-BuOvzL3j.js";
25
+ import "../authdocloader-a6SFhSoj.js";
26
+ import "../ld-D8W0sK5u.js";
27
+ import "../owner-m_iHLHvB.js";
28
+ import "../proof-DFAPxBIn.js";
29
+ import "../lookup-i0w8oyqI.js";
30
+ import "../inbox-C3Dqtty9.js";
31
+ import "../builder-kgS4fcQG.js";
32
32
  import "../collection-Dfb0TPno.js";
33
- import "../keycache-Bnl-7eYm.js";
33
+ import "../keycache-Be2iUcxZ.js";
34
34
  import "../retry-BiIhZWgD.js";
35
- import "../send-qy1MbuwP.js";
35
+ import "../send-IbnPrZ-l.js";
36
36
  import { test } from "../testing-BZ0dJ4qn.js";
37
37
  import "../std__assert-B3iAixc-.js";
38
38
  import "../assert_rejects-DceVjUlD.js";
@@ -40,7 +40,7 @@ import "../assert_is_error-DQdKoRgb.js";
40
40
  import "../assert_not_equals-7pyUM3Ib.js";
41
41
  import "../assert_throws-DTDC_gwN.js";
42
42
  import "../docloader-09nVWLAZ.js";
43
- import { createRequestContext } from "../context-CKwXdbmG.js";
43
+ import { createRequestContext } from "../context-DxZmwaWK.js";
44
44
 
45
45
  //#region webfinger/handler.test.ts
46
46
  test("handleWebFinger()", async (t) => {
@@ -6,9 +6,9 @@
6
6
  import { assertEquals } from "../assert_equals-C5gKCm6A.js";
7
7
  import "../assert-DwEa6glZ.js";
8
8
  import "../assert_instance_of-C9QtN-X9.js";
9
- import "../docloader-BFuRHsay.js";
9
+ import "../docloader-COdyz_hE.js";
10
10
  import "../url-kTAI6_KP.js";
11
- import { lookupWebFinger } from "../lookup-BT8SOdcA.js";
11
+ import { lookupWebFinger } from "../lookup-CjiXiLHr.js";
12
12
  import { test } from "../testing-BZ0dJ4qn.js";
13
13
  import "../std__assert-B3iAixc-.js";
14
14
  import "../assert_rejects-DceVjUlD.js";
@@ -2,8 +2,8 @@
2
2
  import { Temporal } from "@js-temporal/polyfill";
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
 
5
- import "../docloader-onqGGiQb.js";
6
- import { lookupWebFinger } from "../lookup-C7tY3Xdt.js";
5
+ import "../docloader-C1p4hcZh.js";
6
+ import { lookupWebFinger } from "../lookup-BBIBMJMW.js";
7
7
  import "../webfinger-C3GIyXIg.js";
8
8
 
9
9
  export { lookupWebFinger };
package/dist/x/hono.d.ts CHANGED
@@ -7,9 +7,9 @@ import "../vocab-By6mpzr-.js";
7
7
  import "../actor-B4TBtqRP.js";
8
8
  import "../http-CP2ZUALI.js";
9
9
  import "../owner-CEv_PfyK.js";
10
- import "../mod-BzLUzgBJ.js";
10
+ import "../mod-BFwgZ7_K.js";
11
11
  import "../lookup-DHNtuVcT.js";
12
- import { Federation } from "../context-y90aX3KP.js";
12
+ import { Federation } from "../context-BRIf4bt7.js";
13
13
  import "../mq-DYKDDJmp.js";
14
14
 
15
15
  //#region x/hono.d.ts
@@ -7,9 +7,9 @@ import "../vocab-By6mpzr-.js";
7
7
  import "../actor-B4TBtqRP.js";
8
8
  import "../http-CP2ZUALI.js";
9
9
  import "../owner-CEv_PfyK.js";
10
- import "../mod-BzLUzgBJ.js";
10
+ import "../mod-BFwgZ7_K.js";
11
11
  import "../lookup-DHNtuVcT.js";
12
- import { Federation } from "../context-y90aX3KP.js";
12
+ import { Federation } from "../context-BRIf4bt7.js";
13
13
  import "../mq-DYKDDJmp.js";
14
14
 
15
15
  //#region x/sveltekit.d.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/fedify",
3
- "version": "1.8.0-dev.952+553492a7",
3
+ "version": "1.8.0-dev.955+0e336a3a",
4
4
  "description": "An ActivityPub server framework",
5
5
  "keywords": [
6
6
  "ActivityPub",
@@ -1,33 +0,0 @@
1
-
2
- import { Temporal } from "@js-temporal/polyfill";
3
- import { URLPattern } from "urlpattern-polyfill";
4
- globalThis.addEventListener = () => {};
5
-
6
- import { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer, createFederation } from "./middleware-C37kF-sp.js";
7
- import "./docloader-BFuRHsay.js";
8
- import "./url-kTAI6_KP.js";
9
- import "./semver-DWClQt_5.js";
10
- import "./client-yKecM_0d.js";
11
- import "./router-D3UybECj.js";
12
- import "./types-C7C_l-jz.js";
13
- import "./multibase-DeCHcK8L.js";
14
- import "./vocab-DPfUWFNl.js";
15
- import "./langstr-DbWheeIS.js";
16
- import "./lookup-BT8SOdcA.js";
17
- import "./type-D2s5lmbZ.js";
18
- import "./actor-EzU7ndeu.js";
19
- import "./key-kDZgr5No.js";
20
- import "./http-BkeuJbKU.js";
21
- import "./authdocloader-BQKkNzeH.js";
22
- import "./ld-BTb4k201.js";
23
- import "./owner-eYr4V3my.js";
24
- import "./proof-DMkP6wLl.js";
25
- import "./lookup-M0i1aD0a.js";
26
- import "./inbox-B33dAqgO.js";
27
- import "./builder-DbBHCZXD.js";
28
- import "./collection-Dfb0TPno.js";
29
- import "./keycache-Bnl-7eYm.js";
30
- import "./retry-BiIhZWgD.js";
31
- import "./send-qy1MbuwP.js";
32
-
33
- export { FederationImpl };
@@ -1,17 +0,0 @@
1
-
2
- import { Temporal } from "@js-temporal/polyfill";
3
- import { URLPattern } from "urlpattern-polyfill";
4
-
5
- import "./transformers-ghwJuzGY.js";
6
- import "./docloader-onqGGiQb.js";
7
- import "./actor-BWFxNSnR.js";
8
- import { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer, createFederation } from "./middleware-ClwV-KmF.js";
9
- import "./lookup-C7tY3Xdt.js";
10
- import "./key-Cn9gw2pj.js";
11
- import "./http-Dm8W6Xii.js";
12
- import "./proof-gll-kzgh.js";
13
- import "./types-Bzi8SON9.js";
14
- import "./authdocloader-h0v96Scc.js";
15
- import "./vocab-CKWclA_p.js";
16
-
17
- export { FederationImpl };