@fedify/fedify 1.9.0-pr.428.1588 → 1.9.0-pr.431.1597

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 (153) hide show
  1. package/dist/actor-CHOM_AN3.d.cts +128 -0
  2. package/dist/actor-CfaqWvJb.cjs +37783 -0
  3. package/dist/{actor-CdM_sJLC.js → actor-Detmisdi.js} +190 -190
  4. package/dist/{actor-ByOSf9n9.js → actor-Dw7av4Zk.js} +1 -1
  5. package/dist/{authdocloader-VVd0U8Qg.js → authdocloader-5UJ5Gme-.js} +6 -6
  6. package/dist/authdocloader-BVYv0Ct8.cjs +58 -0
  7. package/dist/{authdocloader-CfP6lfxM.js → authdocloader-ZlLoXSxM.js} +3 -3
  8. package/dist/{builder-mfXmda-W.js → builder-BbKfqPmR.js} +4 -4
  9. package/dist/chunk-DqRYRqnO.cjs +34 -0
  10. package/dist/{client-DB8N2RwI.js → client-DgRjF0ha.js} +1 -1
  11. package/dist/client-DjT_tegg.d.cts +294 -0
  12. package/dist/compat/mod.cjs +10 -0
  13. package/dist/compat/mod.d.cts +13 -0
  14. package/dist/compat/mod.js +5 -5
  15. package/dist/compat/transformers.test.js +16 -16
  16. package/dist/compat-DmDDELst.cjs +4 -0
  17. package/dist/compat-nxUqe4Z-.js +4 -0
  18. package/dist/context-KXVF2AhH.d.cts +2261 -0
  19. package/dist/{docloader-XJzCMWY-.js → docloader-BKf9RWX4.js} +4 -4
  20. package/dist/docloader-D-MrRyHl.d.cts +219 -0
  21. package/dist/docloader-eqgyMp7h.cjs +4682 -0
  22. package/dist/{esm-BVYQVacR.js → esm-B_ZjJ1sB.js} +1 -1
  23. package/dist/federation/builder.test.js +5 -5
  24. package/dist/federation/collection.test.js +3 -3
  25. package/dist/federation/handler.test.js +17 -17
  26. package/dist/federation/inbox.test.js +4 -4
  27. package/dist/federation/keycache.test.js +4 -4
  28. package/dist/federation/kv.test.js +3 -3
  29. package/dist/federation/middleware.test.js +18 -18
  30. package/dist/federation/mod.cjs +29 -0
  31. package/dist/federation/mod.d.cts +13 -0
  32. package/dist/federation/mod.js +15 -15
  33. package/dist/federation/mq.test.js +3 -3
  34. package/dist/federation/retry.test.js +3 -3
  35. package/dist/federation/router.test.js +3 -3
  36. package/dist/federation/send.test.js +10 -10
  37. package/dist/{federation-CMX7WzeL.js → federation-D1U8YY9t.js} +3 -3
  38. package/dist/federation-H2_En3j5.cjs +244 -0
  39. package/dist/http-B_zBcsai.d.cts +253 -0
  40. package/dist/{http-B_bBrm6N.js → http-C5XLveZw.js} +2 -2
  41. package/dist/{http-DYB4M8Pr.js → http-CwlUFNG4.js} +6 -6
  42. package/dist/http-_vjuGcXn.cjs +826 -0
  43. package/dist/{inbox-B4k2JQpE.js → inbox-sVXiVBbT.js} +1 -1
  44. package/dist/key-19P2dWvf.cjs +290 -0
  45. package/dist/{key-BdBFUTr5.js → key-BCWvPOkD.js} +5 -5
  46. package/dist/key-CsQ7J8-m.js +10 -0
  47. package/dist/key-Dt7qJaQT.cjs +10 -0
  48. package/dist/{key-feGm-IP3.js → key-Jrnr66vx.js} +2 -2
  49. package/dist/{key-BcVEPl--.js → key-lpATOAE4.js} +3 -3
  50. package/dist/{keycache-b7FYgzB9.js → keycache-ogQInQck.js} +1 -1
  51. package/dist/{keys-B7uX1KoX.js → keys-DcGsKtHW.js} +1 -1
  52. package/dist/kv-63Cil1MD.d.cts +81 -0
  53. package/dist/{ld-DJCemZO2.js → ld-BSE4jnyK.js} +2 -2
  54. package/dist/lookup-D96ipStp.cjs +137 -0
  55. package/dist/{lookup-CIsbr_Qi.js → lookup-D_-F1hLw.js} +4 -4
  56. package/dist/{lookup-CXaZBmuy.js → lookup-DdxOle8f.js} +1 -1
  57. package/dist/middleware-B0f850Ei.cjs +17 -0
  58. package/dist/middleware-B2DFqtJ-.cjs +4240 -0
  59. package/dist/middleware-COHAbwGs.js +17 -0
  60. package/dist/{middleware-D5JRdsEc.js → middleware-CuTcPjfP.js} +13 -13
  61. package/dist/middleware-Dt7C7qpw.js +26 -0
  62. package/dist/{middleware-e_Gw7sQy.js → middleware-T_y4Bnvw.js} +14 -14
  63. package/dist/mod-C2tOeRkN.d.cts +1 -0
  64. package/dist/mod-C3CGxYoF.d.cts +102 -0
  65. package/dist/mod-COw_caPC.d.cts +266 -0
  66. package/dist/mod-FZd39qVq.d.cts +1 -0
  67. package/dist/mod-NKH_G-IY.d.cts +289 -0
  68. package/dist/mod-YfAcrVbP.d.cts +80 -0
  69. package/dist/mod-jQ4OODsl.d.cts +113 -0
  70. package/dist/mod.cjs +152 -0
  71. package/dist/mod.d.cts +17 -0
  72. package/dist/mod.js +20 -20
  73. package/dist/mq-B7R1Q-M5.d.cts +140 -0
  74. package/dist/nodeinfo/client.test.js +5 -5
  75. package/dist/nodeinfo/handler.test.js +16 -16
  76. package/dist/nodeinfo/mod.cjs +13 -0
  77. package/dist/nodeinfo/mod.d.cts +5 -0
  78. package/dist/nodeinfo/mod.js +6 -6
  79. package/dist/nodeinfo/semver.test.js +3 -3
  80. package/dist/nodeinfo/types.test.js +3 -3
  81. package/dist/nodeinfo-Co9lJrWl.cjs +4 -0
  82. package/dist/nodeinfo-DfycQ8Wf.js +4 -0
  83. package/dist/owner-C9Ry0TOI.d.cts +67 -0
  84. package/dist/{owner-i9FkgZwa.js → owner-DJtc8evi.js} +2 -2
  85. package/dist/{proof-Bvtdd-Ul.js → proof-9OMp0o4n.js} +2 -2
  86. package/dist/{proof-DKGUTtBt.js → proof-BuPk23Er.js} +6 -6
  87. package/dist/proof-CRHppbRk.cjs +673 -0
  88. package/dist/runtime/authdocloader.test.js +9 -9
  89. package/dist/runtime/docloader.test.js +4 -4
  90. package/dist/runtime/key.test.js +5 -5
  91. package/dist/runtime/langstr.test.js +3 -3
  92. package/dist/runtime/mod.cjs +25 -0
  93. package/dist/runtime/mod.d.cts +6 -0
  94. package/dist/runtime/mod.js +10 -10
  95. package/dist/runtime/multibase/multibase.test.js +3 -3
  96. package/dist/runtime/url.test.js +3 -3
  97. package/dist/runtime-C58AJWSv.cjs +4 -0
  98. package/dist/runtime-DPYEDf-o.js +4 -0
  99. package/dist/{send-Cuw-wTCx.js → send-cXerEJm9.js} +2 -2
  100. package/dist/sig/http.test.js +8 -8
  101. package/dist/sig/key.test.js +6 -6
  102. package/dist/sig/ld.test.js +7 -7
  103. package/dist/sig/mod.cjs +30 -0
  104. package/dist/sig/mod.d.cts +8 -0
  105. package/dist/sig/mod.js +10 -10
  106. package/dist/sig/owner.test.js +7 -7
  107. package/dist/sig/proof.test.js +7 -7
  108. package/dist/sig-ByHXzqUi.cjs +4 -0
  109. package/dist/sig-Cj3tk-ig.js +4 -0
  110. package/dist/testing/docloader.test.js +3 -3
  111. package/dist/testing/mod.js +3 -3
  112. package/dist/{testing-DUFWSgSt.js → testing-BX6IA3LR.js} +2 -2
  113. package/dist/{transformers-Dna8Fg7k.js → transformers-BFT6d7J5.js} +3 -3
  114. package/dist/transformers-CoBS-oFG.cjs +116 -0
  115. package/dist/{type-DDwsy8fI.js → type-DF9yoIpt.js} +186 -186
  116. package/dist/types-DcKQIzdO.cjs +488 -0
  117. package/dist/{types-CuvNqe2X.js → types-Q17QxOOC.js} +4 -4
  118. package/dist/vocab/actor.test.js +5 -5
  119. package/dist/vocab/lookup.test.js +4 -4
  120. package/dist/vocab/mod.cjs +87 -0
  121. package/dist/vocab/mod.d.cts +6 -0
  122. package/dist/vocab/mod.js +7 -7
  123. package/dist/vocab/type.test.js +3 -3
  124. package/dist/vocab/vocab.test.js +4 -4
  125. package/dist/{vocab-CEXwobaS.js → vocab-BUc_4ZsW.js} +6 -6
  126. package/dist/vocab-BzGg7ltX.d.cts +14629 -0
  127. package/dist/vocab-Du8FV6H1.cjs +282 -0
  128. package/dist/webfinger/handler.test.js +16 -16
  129. package/dist/webfinger/lookup.test.js +4 -4
  130. package/dist/webfinger/mod.cjs +9 -0
  131. package/dist/webfinger/mod.d.cts +4 -0
  132. package/dist/webfinger/mod.js +6 -6
  133. package/dist/webfinger-BjOEdFPs.cjs +4 -0
  134. package/dist/webfinger-De_bU0iE.js +4 -0
  135. package/dist/x/cfworkers.cjs +100 -0
  136. package/dist/x/cfworkers.d.cts +59 -0
  137. package/dist/x/cfworkers.js +3 -3
  138. package/dist/x/cfworkers.test.js +3 -3
  139. package/dist/x/hono.cjs +61 -0
  140. package/dist/x/hono.d.cts +54 -0
  141. package/dist/x/hono.js +3 -3
  142. package/dist/x/sveltekit.cjs +69 -0
  143. package/dist/x/sveltekit.d.cts +46 -0
  144. package/dist/x/sveltekit.js +3 -3
  145. package/package.json +68 -12
  146. package/dist/compat-Bb5myD13.js +0 -4
  147. package/dist/key-0hFXQUQz.js +0 -10
  148. package/dist/middleware-BhQdOVAF.js +0 -17
  149. package/dist/middleware-DVy3ms0C.js +0 -26
  150. package/dist/nodeinfo-CyEbLjHs.js +0 -4
  151. package/dist/runtime-BSkOVUWM.js +0 -4
  152. package/dist/sig-BXJO--F9.js +0 -4
  153. package/dist/webfinger-C3GIyXIg.js +0 -4
@@ -0,0 +1,488 @@
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 require_docloader = require('./docloader-eqgyMp7h.cjs');
7
+ const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
8
+
9
+ //#region src/nodeinfo/semver.ts
10
+ const MAX_LENGTH = 256;
11
+ /**
12
+ * A single `0`, or a non-zero digit followed by zero or more digits.
13
+ */
14
+ const NUMERIC_IDENTIFIER = "0|[1-9]\\d*";
15
+ /**
16
+ * Zero or more digits, followed by a letter or hyphen, and then zero or more letters, digits, or hyphens.
17
+ */
18
+ const NON_NUMERIC_IDENTIFIER = "\\d*[a-zA-Z-][a-zA-Z0-9-]*";
19
+ /**
20
+ * Three dot-separated numeric identifiers.
21
+ */
22
+ const VERSION_CORE = `(?<major>${NUMERIC_IDENTIFIER})\\.(?<minor>${NUMERIC_IDENTIFIER})\\.(?<patch>${NUMERIC_IDENTIFIER})`;
23
+ /**
24
+ * A numeric identifier, or a non-numeric identifier.
25
+ */
26
+ const PRERELEASE_IDENTIFIER = `(?:${NUMERIC_IDENTIFIER}|${NON_NUMERIC_IDENTIFIER})`;
27
+ /**
28
+ * A hyphen, followed by one or more dot-separated pre-release version identifiers.
29
+ * @example "-pre.release"
30
+ */
31
+ const PRERELEASE = `(?:-(?<prerelease>${PRERELEASE_IDENTIFIER}(?:\\.${PRERELEASE_IDENTIFIER})*))`;
32
+ /**
33
+ * Any combination of digits, letters, or hyphens.
34
+ */
35
+ const BUILD_IDENTIFIER = "[0-9A-Za-z-]+";
36
+ /**
37
+ * A plus sign, followed by one or more period-separated build metadata identifiers.
38
+ * @example "+build.meta"
39
+ */
40
+ const BUILD = `(?:\\+(?<buildmetadata>${BUILD_IDENTIFIER}(?:\\.${BUILD_IDENTIFIER})*))`;
41
+ /**
42
+ * A version, followed optionally by a pre-release version and build metadata.
43
+ */
44
+ const FULL_VERSION = `v?${VERSION_CORE}${PRERELEASE}?${BUILD}?`;
45
+ const FULL_REGEXP = /* @__PURE__ */ new RegExp(`^${FULL_VERSION}$`);
46
+ /**
47
+ * Attempt to parse a string as a semantic version, returning a SemVer object.
48
+ *
49
+ * @example Usage
50
+ * ```ts
51
+ * import { parseSemVer } from "@fedify/fedify/nodeinfo";
52
+ * import { assertEquals } from "@std/assert";
53
+ *
54
+ * const version = parseSemVer("1.2.3");
55
+ * assertEquals(version, {
56
+ * major: 1,
57
+ * minor: 2,
58
+ * patch: 3,
59
+ * prerelease: [],
60
+ * build: [],
61
+ * });
62
+ * ```
63
+ *
64
+ * @throws {TypeError} If the input string is invalid.
65
+ * @param value The version string to parse
66
+ * @returns A valid SemVer
67
+ * @since 1.2.0
68
+ */
69
+ function parseSemVer(value) {
70
+ if (typeof value !== "string") throw new TypeError(`Cannot parse version as version must be a string: received ${typeof value}`);
71
+ if (value.length > MAX_LENGTH) throw new TypeError(`Cannot parse version as version length is too long: length is ${value.length}, max length is ${MAX_LENGTH}`);
72
+ value = value.trim();
73
+ const groups = value.match(FULL_REGEXP)?.groups;
74
+ if (!groups) throw new TypeError(`Cannot parse version: ${value}`);
75
+ const major = parseNumber(groups.major, `Cannot parse version ${value}: invalid major version`);
76
+ const minor = parseNumber(groups.minor, `Cannot parse version ${value}: invalid minor version`);
77
+ const patch = parseNumber(groups.patch, `Cannot parse version ${value}: invalid patch version`);
78
+ const prerelease = groups.prerelease ? parsePrerelease(groups.prerelease) : [];
79
+ const build = groups.buildmetadata ? parseBuild(groups.buildmetadata) : [];
80
+ return {
81
+ major,
82
+ minor,
83
+ patch,
84
+ prerelease,
85
+ build
86
+ };
87
+ }
88
+ /**
89
+ * Returns true if the value is a valid SemVer number.
90
+ *
91
+ * Must be a number. Must not be NaN. Can be positive or negative infinity.
92
+ * Can be between 0 and MAX_SAFE_INTEGER.
93
+ * @param value The value to check
94
+ * @returns True if its a valid semver number
95
+ */
96
+ function isValidNumber(value) {
97
+ return typeof value === "number" && !Number.isNaN(value) && (!Number.isFinite(value) || 0 <= value && value <= Number.MAX_SAFE_INTEGER);
98
+ }
99
+ const NUMERIC_IDENTIFIER_REGEXP = /* @__PURE__ */ new RegExp(`^${NUMERIC_IDENTIFIER}$`);
100
+ function parsePrerelease(prerelease) {
101
+ return prerelease.split(".").filter(Boolean).map((id) => {
102
+ if (NUMERIC_IDENTIFIER_REGEXP.test(id)) {
103
+ const number = Number(id);
104
+ if (isValidNumber(number)) return number;
105
+ }
106
+ return id;
107
+ });
108
+ }
109
+ function parseBuild(buildmetadata) {
110
+ return buildmetadata.split(".").filter(Boolean);
111
+ }
112
+ function parseNumber(input, errorMessage) {
113
+ const number = Number(input);
114
+ if (!isValidNumber(number)) throw new TypeError(errorMessage);
115
+ return number;
116
+ }
117
+ function formatNumber(value) {
118
+ return value.toFixed(0);
119
+ }
120
+ /**
121
+ * Format a SemVer object into a string.
122
+ *
123
+ * @example Usage
124
+ * ```ts
125
+ * import { formatSemVer } from "@fedify/fedify/nodeinfo";
126
+ * import { assertEquals } from "@std/assert";
127
+ *
128
+ * const semver = {
129
+ * major: 1,
130
+ * minor: 2,
131
+ * patch: 3,
132
+ * };
133
+ * assertEquals(formatSemVer(semver), "1.2.3");
134
+ * ```
135
+ *
136
+ * @param version The SemVer to format
137
+ * @returns The string representation of a semantic version.
138
+ * @since 1.2.0
139
+ */
140
+ function formatSemVer(version) {
141
+ const major = formatNumber(version.major);
142
+ const minor = formatNumber(version.minor);
143
+ const patch = formatNumber(version.patch);
144
+ const pre = version.prerelease?.join(".") ?? "";
145
+ const build = version.build?.join(".") ?? "";
146
+ const primary = `${major}.${minor}.${patch}`;
147
+ const release = [primary, pre].filter((v) => v).join("-");
148
+ return [release, build].filter((v) => v).join("+");
149
+ }
150
+
151
+ //#endregion
152
+ //#region src/nodeinfo/client.ts
153
+ const logger = (0, __logtape_logtape.getLogger)([
154
+ "fedify",
155
+ "nodeinfo",
156
+ "client"
157
+ ]);
158
+ async function getNodeInfo(url, options = {}) {
159
+ try {
160
+ let nodeInfoUrl = url;
161
+ if (!options.direct) {
162
+ const wellKnownUrl = new URL("/.well-known/nodeinfo", url);
163
+ const wellKnownResponse = await fetch(wellKnownUrl, { headers: {
164
+ Accept: "application/json",
165
+ "User-Agent": typeof options.userAgent === "string" ? options.userAgent : require_docloader.getUserAgent(options.userAgent)
166
+ } });
167
+ if (!wellKnownResponse.ok) {
168
+ logger.error("Failed to fetch {url}: {status} {statusText}", {
169
+ url: wellKnownUrl.href,
170
+ status: wellKnownResponse.status,
171
+ statusText: wellKnownResponse.statusText
172
+ });
173
+ return void 0;
174
+ }
175
+ const wellKnownRd = await wellKnownResponse.json();
176
+ const link = wellKnownRd?.links?.find((link$1) => link$1 != null && "rel" in link$1 && (link$1.rel === "http://nodeinfo.diaspora.software/ns/schema/2.0" || link$1.rel === "http://nodeinfo.diaspora.software/ns/schema/2.1") && "href" in link$1 && link$1.href != null);
177
+ if (link == null || link.href == null) {
178
+ logger.error("Failed to find a NodeInfo document link from {url}: {resourceDescriptor}", {
179
+ url: wellKnownUrl.href,
180
+ resourceDescriptor: wellKnownRd
181
+ });
182
+ return void 0;
183
+ }
184
+ nodeInfoUrl = link.href;
185
+ }
186
+ const response = await fetch(nodeInfoUrl, { headers: {
187
+ Accept: "application/json",
188
+ "User-Agent": typeof options.userAgent === "string" ? options.userAgent : require_docloader.getUserAgent(options.userAgent)
189
+ } });
190
+ if (!response.ok) {
191
+ logger.error("Failed to fetch NodeInfo document from {url}: {status} {statusText}", {
192
+ url: nodeInfoUrl.toString(),
193
+ status: response.status,
194
+ statusText: response.statusText
195
+ });
196
+ return void 0;
197
+ }
198
+ const data = await response.json();
199
+ if (options.parse === "none") return data;
200
+ return parseNodeInfo(data, { tryBestEffort: options.parse === "best-effort" }) ?? void 0;
201
+ } catch (error) {
202
+ logger.error("Failed to fetch NodeInfo document from {url}: {error}", {
203
+ url: url.toString(),
204
+ error
205
+ });
206
+ return void 0;
207
+ }
208
+ }
209
+ /**
210
+ * Parses a NodeInfo document.
211
+ * @param data A JSON value that complies with the NodeInfo schema.
212
+ * @param options Options for parsing the NodeInfo document.
213
+ * @returns The parsed NodeInfo document if it is valid. Otherwise, `null`
214
+ * is returned.
215
+ * @since 1.2.0
216
+ */
217
+ function parseNodeInfo(data, options = {}) {
218
+ if (typeof data !== "object" || data == null || !("software" in data)) return null;
219
+ const software = parseSoftware(data.software, options);
220
+ if (software == null) return null;
221
+ let protocols = [];
222
+ if ("protocols" in data && Array.isArray(data.protocols)) {
223
+ const ps = data.protocols.map(parseProtocol);
224
+ protocols = ps.filter((p) => p != null);
225
+ if (ps.length != protocols.length && !options.tryBestEffort) return null;
226
+ } else if (!options.tryBestEffort) return null;
227
+ let services;
228
+ if ("services" in data) {
229
+ if (typeof data.services === "object" && data.services != null) {
230
+ const ss = parseServices(data.services, options);
231
+ if (ss == null) {
232
+ if (!options.tryBestEffort) return null;
233
+ } else services = ss;
234
+ } else if (!options.tryBestEffort) return null;
235
+ }
236
+ let openRegistrations;
237
+ if ("openRegistrations" in data) {
238
+ if (typeof data.openRegistrations === "boolean") openRegistrations = data.openRegistrations;
239
+ else if (!options.tryBestEffort) return null;
240
+ }
241
+ let usage = {
242
+ users: {},
243
+ localPosts: 0,
244
+ localComments: 0
245
+ };
246
+ if ("usage" in data) {
247
+ const u = parseUsage(data.usage, options);
248
+ if (u == null) {
249
+ if (!options.tryBestEffort) return null;
250
+ } else usage = u;
251
+ }
252
+ let metadata;
253
+ if ("metadata" in data) {
254
+ if (typeof data.metadata === "object" && data.metadata != null) metadata = Object.fromEntries(Object.entries(data.metadata));
255
+ else if (!options.tryBestEffort) return null;
256
+ }
257
+ const result = {
258
+ software,
259
+ protocols,
260
+ usage
261
+ };
262
+ if (services != null) result.services = services;
263
+ if (openRegistrations != null) result.openRegistrations = openRegistrations;
264
+ if (metadata != null) result.metadata = metadata;
265
+ return result;
266
+ }
267
+ function parseSoftware(data, options = {}) {
268
+ if (typeof data !== "object" || data == null) {
269
+ if (!options.tryBestEffort) data = {};
270
+ return null;
271
+ }
272
+ let name;
273
+ if ("name" in data && typeof data.name === "string" && data.name.match(/^\s*[A-Za-z0-9-]+\s*$/)) {
274
+ if (!data.name.match(/^[a-z0-9-]+$/) && !options.tryBestEffort) return null;
275
+ name = data.name.trim().toLowerCase();
276
+ } else return null;
277
+ let version;
278
+ if ("version" in data && typeof data.version === "string") try {
279
+ version = parseSemVer(data.version);
280
+ } catch {
281
+ if (!options.tryBestEffort) return null;
282
+ const parts = data.version.split(".").map((p) => parseInt(p, 10));
283
+ version = {
284
+ major: !isNaN(parts[0]) ? parts[0] : 0,
285
+ minor: !isNaN(parts[1]) ? parts[1] : 0,
286
+ patch: !isNaN(parts[2]) ? parts[2] : 0,
287
+ build: [],
288
+ prerelease: []
289
+ };
290
+ }
291
+ else {
292
+ if (!options.tryBestEffort) return null;
293
+ version = {
294
+ major: 0,
295
+ minor: 0,
296
+ patch: 0,
297
+ build: [],
298
+ prerelease: []
299
+ };
300
+ }
301
+ let repository;
302
+ if ("repository" in data) {
303
+ if (typeof data.repository === "string") try {
304
+ repository = new URL(data.repository);
305
+ } catch {
306
+ if (!options.tryBestEffort) return null;
307
+ }
308
+ else if (!options.tryBestEffort) return null;
309
+ }
310
+ let homepage;
311
+ if ("homepage" in data) {
312
+ if (typeof data.homepage === "string") try {
313
+ homepage = new URL(data.homepage);
314
+ } catch {
315
+ if (!options.tryBestEffort) return null;
316
+ }
317
+ else if (!options.tryBestEffort) return null;
318
+ }
319
+ const result = {
320
+ name,
321
+ version
322
+ };
323
+ if (repository != null) result.repository = repository;
324
+ if (homepage != null) result.homepage = homepage;
325
+ return result;
326
+ }
327
+ function parseProtocol(data) {
328
+ if (data === "activitypub" || data === "buddycloud" || data === "dfrn" || data === "diaspora" || data === "libertree" || data === "ostatus" || data === "pumpio" || data === "tent" || data === "xmpp" || data === "zot") return data;
329
+ return null;
330
+ }
331
+ function parseServices(data, options = {}) {
332
+ if (!(typeof data === "object") || data == null) {
333
+ if (options.tryBestEffort) return {};
334
+ return null;
335
+ }
336
+ let inbound;
337
+ if ("inbound" in data && Array.isArray(data.inbound)) {
338
+ const is = data.inbound.map(parseInboundService);
339
+ inbound = is.filter((i) => i != null);
340
+ if (is.length > inbound.length && !options.tryBestEffort) return null;
341
+ }
342
+ let outbound;
343
+ if ("outbound" in data && Array.isArray(data.outbound)) {
344
+ const os = data.outbound.map(parseOutboundService);
345
+ outbound = os.filter((o) => o != null);
346
+ if (os.length > outbound.length && !options.tryBestEffort) return null;
347
+ }
348
+ const result = {};
349
+ if (inbound != null) result.inbound = inbound;
350
+ if (outbound != null) result.outbound = outbound;
351
+ return result;
352
+ }
353
+ function parseInboundService(data) {
354
+ if (data === "atom1.0" || data === "gnusocial" || data === "imap" || data === "pnut" || data === "pop3" || data === "pumpio" || data === "rss2.0" || data === "twitter") return data;
355
+ return null;
356
+ }
357
+ function parseOutboundService(data) {
358
+ if (data === "atom1.0" || data === "blogger" || data === "buddycloud" || data === "diaspora" || data === "dreamwidth" || data === "drupal" || data === "facebook" || data === "friendica" || data === "gnusocial" || data === "google" || data === "insanejournal" || data === "libertree" || data === "linkedin" || data === "livejournal" || data === "mediagoblin" || data === "myspace" || data === "pinterest" || data === "pnut" || data === "posterous" || data === "pumpio" || data === "redmatrix" || data === "rss2.0" || data === "smtp" || data === "tent" || data === "tumblr" || data === "twitter" || data === "wordpress" || data === "xmpp") return data;
359
+ return null;
360
+ }
361
+ function parseUsage(data, options = {}) {
362
+ if (typeof data !== "object" || data == null) return null;
363
+ const users = {};
364
+ if ("users" in data && typeof data.users === "object" && data.users != null) {
365
+ if ("total" in data.users) if (typeof data.users.total === "number") users.total = data.users.total;
366
+ else {
367
+ if (!options.tryBestEffort) return null;
368
+ if (typeof data.users.total === "string") {
369
+ const n = parseInt(data.users.total);
370
+ if (!isNaN(n)) users.total = n;
371
+ }
372
+ }
373
+ if ("activeHalfyear" in data.users) if (typeof data.users.activeHalfyear === "number") users.activeHalfyear = data.users.activeHalfyear;
374
+ else {
375
+ if (!options.tryBestEffort) return null;
376
+ if (typeof data.users.activeHalfyear === "string") {
377
+ const n = parseInt(data.users.activeHalfyear);
378
+ if (!isNaN(n)) users.activeHalfyear = n;
379
+ }
380
+ }
381
+ if ("activeMonth" in data.users) if (typeof data.users.activeMonth === "number") users.activeMonth = data.users.activeMonth;
382
+ else {
383
+ if (!options.tryBestEffort) return null;
384
+ if (typeof data.users.activeMonth === "string") {
385
+ const n = parseInt(data.users.activeMonth);
386
+ if (!isNaN(n)) users.activeMonth = n;
387
+ }
388
+ }
389
+ } else if (!options.tryBestEffort) return null;
390
+ let localPosts = 0;
391
+ if ("localPosts" in data) if (typeof data.localPosts === "number") localPosts = data.localPosts;
392
+ else {
393
+ if (!options.tryBestEffort) return null;
394
+ if (typeof data.localPosts === "string") {
395
+ const n = parseInt(data.localPosts);
396
+ if (!isNaN(n)) localPosts = n;
397
+ }
398
+ }
399
+ let localComments = 0;
400
+ if ("localComments" in data) if (typeof data.localComments === "number") localComments = data.localComments;
401
+ else {
402
+ if (!options.tryBestEffort) return null;
403
+ if (typeof data.localComments === "string") {
404
+ const n = parseInt(data.localComments);
405
+ if (!isNaN(n)) localComments = n;
406
+ }
407
+ }
408
+ return {
409
+ users,
410
+ localPosts,
411
+ localComments
412
+ };
413
+ }
414
+
415
+ //#endregion
416
+ //#region src/nodeinfo/types.ts
417
+ /**
418
+ * Converts a {@link NodeInfo} object to a JSON value.
419
+ * @param nodeInfo The {@link NodeInfo} object to convert.
420
+ * @returns The JSON value that complies with the NodeInfo schema.
421
+ * @throws {TypeError} If the {@link NodeInfo} object is invalid.
422
+ */
423
+ function nodeInfoToJson(nodeInfo) {
424
+ if (!nodeInfo.software.name.match(/^[a-z0-9-]+$/)) throw new TypeError("Invalid software name.");
425
+ if (nodeInfo.protocols.length < 1) throw new TypeError("At least one protocol must be supported.");
426
+ if (nodeInfo.usage.users.total != null && (nodeInfo.usage.users.total < 0 || !Number.isInteger(nodeInfo.usage.users.total))) throw new TypeError("Invalid total users.");
427
+ if (nodeInfo.usage.users.activeHalfyear != null && (nodeInfo.usage.users.activeHalfyear < 0 || !Number.isInteger(nodeInfo.usage.users.activeHalfyear))) throw new TypeError("Invalid active halfyear users.");
428
+ if (nodeInfo.usage.users.activeMonth != null && (nodeInfo.usage.users.activeMonth < 0 || !Number.isInteger(nodeInfo.usage.users.activeMonth))) throw new TypeError("Invalid active month users.");
429
+ if (nodeInfo.usage.localPosts < 0 || !Number.isInteger(nodeInfo.usage.localPosts)) throw new TypeError("Invalid local posts.");
430
+ if (nodeInfo.usage.localComments < 0 || !Number.isInteger(nodeInfo.usage.localComments)) throw new TypeError("Invalid local comments.");
431
+ return {
432
+ "$schema": "http://nodeinfo.diaspora.software/ns/schema/2.1#",
433
+ version: "2.1",
434
+ software: {
435
+ name: nodeInfo.software.name,
436
+ version: formatSemVer(nodeInfo.software.version),
437
+ repository: nodeInfo.software.repository?.href,
438
+ homepage: nodeInfo.software.homepage?.href
439
+ },
440
+ protocols: nodeInfo.protocols,
441
+ services: nodeInfo.services == null ? {
442
+ inbound: [],
443
+ outbound: []
444
+ } : {
445
+ inbound: nodeInfo.services.inbound ?? [],
446
+ outbound: nodeInfo.services.outbound ?? []
447
+ },
448
+ openRegistrations: nodeInfo.openRegistrations ?? false,
449
+ usage: {
450
+ users: nodeInfo.usage.users,
451
+ localPosts: nodeInfo.usage.localPosts,
452
+ localComments: nodeInfo.usage.localComments
453
+ },
454
+ metadata: nodeInfo.metadata ?? {}
455
+ };
456
+ }
457
+
458
+ //#endregion
459
+ Object.defineProperty(exports, 'formatSemVer', {
460
+ enumerable: true,
461
+ get: function () {
462
+ return formatSemVer;
463
+ }
464
+ });
465
+ Object.defineProperty(exports, 'getNodeInfo', {
466
+ enumerable: true,
467
+ get: function () {
468
+ return getNodeInfo;
469
+ }
470
+ });
471
+ Object.defineProperty(exports, 'nodeInfoToJson', {
472
+ enumerable: true,
473
+ get: function () {
474
+ return nodeInfoToJson;
475
+ }
476
+ });
477
+ Object.defineProperty(exports, 'parseNodeInfo', {
478
+ enumerable: true,
479
+ get: function () {
480
+ return parseNodeInfo;
481
+ }
482
+ });
483
+ Object.defineProperty(exports, 'parseSemVer', {
484
+ enumerable: true,
485
+ get: function () {
486
+ return parseSemVer;
487
+ }
488
+ });
@@ -1,8 +1,8 @@
1
1
 
2
- import { Temporal } from "@js-temporal/polyfill";
3
- import { URLPattern } from "urlpattern-polyfill";
4
-
5
- import { getUserAgent } from "./docloader-XJzCMWY-.js";
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+
5
+ import { getUserAgent } from "./docloader-BKf9RWX4.js";
6
6
  import { getLogger } from "@logtape/logtape";
7
7
 
8
8
  //#region src/nodeinfo/semver.ts
@@ -3,19 +3,19 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { Application, Group, Organization, Person, Service, __export } from "../type-DDwsy8fI.js";
6
+ import { Application, Group, Organization, Person, Service, __export } from "../type-DF9yoIpt.js";
7
7
  import { assertEquals } from "../assert_equals-DSbWqCm3.js";
8
8
  import { assert } from "../assert-MZs1qjMx.js";
9
9
  import "../assert_instance_of-DHz7EHNU.js";
10
- import "../lookup-CXaZBmuy.js";
11
- import { getActorClassByTypeName, getActorHandle, getActorTypeName, isActor, normalizeActorHandle } from "../actor-ByOSf9n9.js";
12
- import { test } from "../testing-DUFWSgSt.js";
10
+ import "../lookup-DdxOle8f.js";
11
+ import { getActorClassByTypeName, getActorHandle, getActorTypeName, isActor, normalizeActorHandle } from "../actor-Dw7av4Zk.js";
12
+ import { test } from "../testing-BX6IA3LR.js";
13
13
  import { assertStrictEquals } from "../std__assert-X-_kMxKM.js";
14
14
  import { assertFalse, assertRejects } from "../assert_rejects-DiIiJbZn.js";
15
15
  import "../assert_is_error-BPGph1Jx.js";
16
16
  import "../assert_not_equals-f3m3epl3.js";
17
17
  import { assertThrows } from "../assert_throws-BOO88avQ.js";
18
- import { esm_default } from "../esm-BVYQVacR.js";
18
+ import { esm_default } from "../esm-B_ZjJ1sB.js";
19
19
 
20
20
  //#region ../../node_modules/.pnpm/fast-check@3.23.2/node_modules/fast-check/lib/esm/check/precondition/PreconditionFailure.js
21
21
  var PreconditionFailure = class PreconditionFailure extends Error {
@@ -3,18 +3,18 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { Collection, Note, Object as Object$1, Person } from "../type-DDwsy8fI.js";
6
+ import { Collection, Note, Object as Object$1, Person } from "../type-DF9yoIpt.js";
7
7
  import { assertEquals } from "../assert_equals-DSbWqCm3.js";
8
8
  import "../assert-MZs1qjMx.js";
9
9
  import { assertInstanceOf } from "../assert_instance_of-DHz7EHNU.js";
10
- import { lookupObject, traverseCollection } from "../lookup-CXaZBmuy.js";
11
- import { mockDocumentLoader, test } from "../testing-DUFWSgSt.js";
10
+ import { lookupObject, traverseCollection } from "../lookup-DdxOle8f.js";
11
+ import { mockDocumentLoader, test } from "../testing-BX6IA3LR.js";
12
12
  import "../std__assert-X-_kMxKM.js";
13
13
  import "../assert_rejects-DiIiJbZn.js";
14
14
  import "../assert_is_error-BPGph1Jx.js";
15
15
  import "../assert_not_equals-f3m3epl3.js";
16
16
  import "../assert_throws-BOO88avQ.js";
17
- import { esm_default } from "../esm-BVYQVacR.js";
17
+ import { esm_default } from "../esm-B_ZjJ1sB.js";
18
18
 
19
19
  //#region src/vocab/lookup.test.ts
20
20
  test("lookupObject()", {
@@ -0,0 +1,87 @@
1
+
2
+ const { Temporal } = require("@js-temporal/polyfill");
3
+ const { URLPattern } = require("urlpattern-polyfill");
4
+
5
+ require('../docloader-eqgyMp7h.cjs');
6
+ const require_actor = require('../actor-CfaqWvJb.cjs');
7
+ require('../lookup-D96ipStp.cjs');
8
+ const require_vocab = require('../vocab-Du8FV6H1.cjs');
9
+
10
+ exports.Accept = require_actor.Accept;
11
+ exports.Activity = require_actor.Activity;
12
+ exports.Add = require_actor.Add;
13
+ exports.Announce = require_actor.Announce;
14
+ exports.Application = require_actor.Application;
15
+ exports.Arrive = require_actor.Arrive;
16
+ exports.Article = require_actor.Article;
17
+ exports.Audio = require_actor.Audio;
18
+ exports.Block = require_actor.Block;
19
+ exports.ChatMessage = require_actor.ChatMessage;
20
+ exports.Collection = require_actor.Collection;
21
+ exports.CollectionPage = require_actor.CollectionPage;
22
+ exports.Create = require_actor.Create;
23
+ exports.CryptographicKey = require_actor.CryptographicKey;
24
+ exports.DataIntegrityProof = require_actor.DataIntegrityProof;
25
+ exports.Delete = require_actor.Delete;
26
+ exports.DidService = require_actor.DidService;
27
+ exports.Dislike = require_actor.Dislike;
28
+ exports.Document = require_actor.Document;
29
+ exports.Emoji = require_actor.Emoji;
30
+ exports.EmojiReact = require_actor.EmojiReact;
31
+ exports.Endpoints = require_actor.Endpoints;
32
+ exports.Event = require_actor.Event;
33
+ exports.Export = require_actor.Export;
34
+ exports.Flag = require_actor.Flag;
35
+ exports.Follow = require_actor.Follow;
36
+ exports.Group = require_actor.Group;
37
+ exports.Hashtag = require_actor.Hashtag;
38
+ exports.Ignore = require_actor.Ignore;
39
+ exports.Image = require_actor.Image;
40
+ exports.IntransitiveActivity = require_actor.IntransitiveActivity;
41
+ exports.Invite = require_actor.Invite;
42
+ exports.Join = require_actor.Join;
43
+ exports.Leave = require_actor.Leave;
44
+ exports.Like = require_actor.Like;
45
+ exports.Link = require_actor.Link;
46
+ exports.Listen = require_actor.Listen;
47
+ exports.Mention = require_actor.Mention;
48
+ exports.Move = require_actor.Move;
49
+ exports.Multikey = require_actor.Multikey;
50
+ exports.Note = require_actor.Note;
51
+ exports.Object = require_actor.Object$1;
52
+ exports.Offer = require_actor.Offer;
53
+ exports.OrderedCollection = require_actor.OrderedCollection;
54
+ exports.OrderedCollectionPage = require_actor.OrderedCollectionPage;
55
+ exports.Organization = require_actor.Organization;
56
+ exports.PUBLIC_COLLECTION = require_vocab.PUBLIC_COLLECTION;
57
+ exports.Page = require_actor.Page;
58
+ exports.Person = require_actor.Person;
59
+ exports.Place = require_actor.Place;
60
+ exports.Profile = require_actor.Profile;
61
+ exports.PropertyValue = require_actor.PropertyValue;
62
+ exports.Question = require_actor.Question;
63
+ exports.Read = require_actor.Read;
64
+ exports.Reject = require_actor.Reject;
65
+ exports.Relationship = require_actor.Relationship;
66
+ exports.Remove = require_actor.Remove;
67
+ exports.Service = require_actor.Service;
68
+ exports.Source = require_actor.Source;
69
+ exports.TentativeAccept = require_actor.TentativeAccept;
70
+ exports.TentativeReject = require_actor.TentativeReject;
71
+ exports.Tombstone = require_actor.Tombstone;
72
+ exports.Travel = require_actor.Travel;
73
+ exports.Undo = require_actor.Undo;
74
+ exports.Update = require_actor.Update;
75
+ exports.Video = require_actor.Video;
76
+ exports.View = require_actor.View;
77
+ exports.getActorClassByTypeName = require_actor.getActorClassByTypeName;
78
+ exports.getActorHandle = require_actor.getActorHandle;
79
+ exports.getActorTypeName = require_actor.getActorTypeName;
80
+ exports.getTypeId = require_actor.getTypeId;
81
+ exports.isActor = require_actor.isActor;
82
+ exports.isFediverseHandle = require_vocab.isFediverseHandle;
83
+ exports.lookupObject = require_vocab.lookupObject;
84
+ exports.normalizeActorHandle = require_actor.normalizeActorHandle;
85
+ exports.parseFediverseHandle = require_vocab.parseFediverseHandle;
86
+ exports.toAcctUrl = require_vocab.toAcctUrl;
87
+ exports.traverseCollection = require_vocab.traverseCollection;
@@ -0,0 +1,6 @@
1
+ import "../kv-63Cil1MD.cjs";
2
+ import "../docloader-D-MrRyHl.cjs";
3
+ import { Accept, Activity, Add, Announce, Application, Arrive, Article, Audio, Block, ChatMessage, Collection, CollectionPage, Create, CryptographicKey, DataIntegrityProof, Delete, DidService, Dislike, Document, Emoji, EmojiReact, Endpoints, Event, Export, Flag, Follow, Group, Hashtag, Ignore, Image, IntransitiveActivity, Invite, Join, Leave, Like, Link, Listen, Mention, Move, Multikey, Note, Object as Object$1, Offer, OrderedCollection, OrderedCollectionPage, Organization, Page, Person, Place, Profile, PropertyValue, Question, Read, Reject, Relationship, Remove, Service, Source, TentativeAccept, TentativeReject, Tombstone, Travel, Undo, Update, Video, View } from "../vocab-BzGg7ltX.cjs";
4
+ import { Actor, ActorTypeName, GetActorHandleOptions, NormalizeActorHandleOptions, Recipient, getActorClassByTypeName, getActorHandle, getActorTypeName, isActor, normalizeActorHandle } from "../actor-CHOM_AN3.cjs";
5
+ import { FediverseHandle, LookupObjectOptions, PUBLIC_COLLECTION, TraverseCollectionOptions, getTypeId, isFediverseHandle, lookupObject, parseFediverseHandle, toAcctUrl, traverseCollection } from "../mod-NKH_G-IY.cjs";
6
+ export { Accept, Activity, Actor, ActorTypeName, Add, Announce, Application, Arrive, Article, Audio, Block, ChatMessage, Collection, CollectionPage, Create, CryptographicKey, DataIntegrityProof, Delete, DidService, Dislike, Document, Emoji, EmojiReact, Endpoints, Event, Export, FediverseHandle, Flag, Follow, GetActorHandleOptions, Group, Hashtag, Ignore, Image, IntransitiveActivity, Invite, Join, Leave, Like, Link, Listen, LookupObjectOptions, Mention, Move, Multikey, NormalizeActorHandleOptions, Note, Object$1 as Object, Offer, OrderedCollection, OrderedCollectionPage, Organization, PUBLIC_COLLECTION, Page, Person, Place, Profile, PropertyValue, Question, Read, Recipient, Reject, Relationship, Remove, Service, Source, TentativeAccept, TentativeReject, Tombstone, Travel, TraverseCollectionOptions, Undo, Update, Video, View, getActorClassByTypeName, getActorHandle, getActorTypeName, getTypeId, isActor, isFediverseHandle, lookupObject, normalizeActorHandle, parseFediverseHandle, toAcctUrl, traverseCollection };
package/dist/vocab/mod.js CHANGED
@@ -1,10 +1,10 @@
1
1
 
2
- import { Temporal } from "@js-temporal/polyfill";
3
- import { URLPattern } from "urlpattern-polyfill";
4
-
5
- import "../docloader-XJzCMWY-.js";
6
- import { Accept, Activity, Add, Announce, Application, Arrive, Article, Audio, Block, ChatMessage, Collection, CollectionPage, Create, CryptographicKey, DataIntegrityProof, Delete, DidService, Dislike, Document, Emoji, EmojiReact, Endpoints, Event, Export, Flag, Follow, Group, Hashtag, Ignore, Image, IntransitiveActivity, Invite, Join, Leave, Like, Link, Listen, Mention, Move, Multikey, Note, Object as Object$1, Offer, OrderedCollection, OrderedCollectionPage, Organization, Page, Person, Place, Profile, PropertyValue, Question, Read, Reject, Relationship, Remove, Service, Source, TentativeAccept, TentativeReject, Tombstone, Travel, Undo, Update, Video, View, getActorClassByTypeName, getActorHandle, getActorTypeName, getTypeId, isActor, normalizeActorHandle } from "../actor-CdM_sJLC.js";
7
- import "../lookup-CIsbr_Qi.js";
8
- import { PUBLIC_COLLECTION, isFediverseHandle, lookupObject, parseFediverseHandle, toAcctUrl, traverseCollection } from "../vocab-CEXwobaS.js";
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+
5
+ import "../docloader-BKf9RWX4.js";
6
+ import { Accept, Activity, Add, Announce, Application, Arrive, Article, Audio, Block, ChatMessage, Collection, CollectionPage, Create, CryptographicKey, DataIntegrityProof, Delete, DidService, Dislike, Document, Emoji, EmojiReact, Endpoints, Event, Export, Flag, Follow, Group, Hashtag, Ignore, Image, IntransitiveActivity, Invite, Join, Leave, Like, Link, Listen, Mention, Move, Multikey, Note, Object as Object$1, Offer, OrderedCollection, OrderedCollectionPage, Organization, Page, Person, Place, Profile, PropertyValue, Question, Read, Reject, Relationship, Remove, Service, Source, TentativeAccept, TentativeReject, Tombstone, Travel, Undo, Update, Video, View, getActorClassByTypeName, getActorHandle, getActorTypeName, getTypeId, isActor, normalizeActorHandle } from "../actor-Detmisdi.js";
7
+ import "../lookup-D_-F1hLw.js";
8
+ import { PUBLIC_COLLECTION, isFediverseHandle, lookupObject, parseFediverseHandle, toAcctUrl, traverseCollection } from "../vocab-BUc_4ZsW.js";
9
9
 
10
10
  export { Accept, Activity, Add, Announce, Application, Arrive, Article, Audio, Block, ChatMessage, Collection, CollectionPage, Create, CryptographicKey, DataIntegrityProof, Delete, DidService, Dislike, Document, Emoji, EmojiReact, Endpoints, Event, Export, Flag, Follow, Group, Hashtag, Ignore, Image, IntransitiveActivity, Invite, Join, Leave, Like, Link, Listen, Mention, Move, Multikey, Note, Object$1 as Object, Offer, OrderedCollection, OrderedCollectionPage, Organization, PUBLIC_COLLECTION, Page, Person, Place, Profile, PropertyValue, Question, Read, Reject, Relationship, Remove, Service, Source, TentativeAccept, TentativeReject, Tombstone, Travel, Undo, Update, Video, View, getActorClassByTypeName, getActorHandle, getActorTypeName, getTypeId, isActor, isFediverseHandle, lookupObject, normalizeActorHandle, parseFediverseHandle, toAcctUrl, traverseCollection };