@fedify/fedify 2.3.0-dev.1013 → 2.3.0-dev.1034

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 (95) hide show
  1. package/dist/{builder-CROLcFVM.mjs → builder-y06Dq5bp.mjs} +14 -4
  2. package/dist/chunk-QSgtlS85.mjs +29 -0
  3. package/dist/compat/mod.d.cts +1 -1
  4. package/dist/compat/mod.d.ts +1 -1
  5. package/dist/compat/outgoing-jsonld.test.mjs +1 -1
  6. package/dist/compat/public-audience.test.mjs +1 -1
  7. package/dist/compat/transformers.test.mjs +2 -2
  8. package/dist/{context-Dk_tacqz.mjs → context-7Azky82W.mjs} +3 -2
  9. package/dist/{context-BDl7Y6f-.d.cts → context-BKLGj9QO.d.cts} +24 -1
  10. package/dist/{context-zTZAI3KP.d.ts → context-DrNqYkPw.d.ts} +24 -1
  11. package/dist/{deno-Ctd-K-t6.mjs → deno-DB1H1VHx.mjs} +1 -1
  12. package/dist/{docloader-q9QT51g3.mjs → docloader-3HwiWeYL.mjs} +2 -2
  13. package/dist/{esm-DVILvP5e.mjs → esm-DhnRLoG9.mjs} +1 -24
  14. package/dist/execAsync-eck5rbtb.mjs +13 -0
  15. package/dist/federation/builder.test.mjs +8 -3
  16. package/dist/federation/collection.test.mjs +1 -1
  17. package/dist/federation/handler.test.mjs +48 -11
  18. package/dist/federation/idempotency.test.mjs +4 -4
  19. package/dist/federation/inbox.test.mjs +1 -1
  20. package/dist/federation/keycache.test.mjs +2 -2
  21. package/dist/federation/kv.test.mjs +1 -1
  22. package/dist/federation/middleware.test.mjs +138 -15
  23. package/dist/federation/mod.cjs +1 -1
  24. package/dist/federation/mod.d.cts +2 -2
  25. package/dist/federation/mod.d.ts +2 -2
  26. package/dist/federation/mod.js +1 -1
  27. package/dist/federation/negotiation.test.mjs +1 -1
  28. package/dist/federation/retry.test.mjs +1 -1
  29. package/dist/federation/send.test.mjs +4540 -11
  30. package/dist/federation/webfinger.test.mjs +3 -3
  31. package/dist/getMachineId-bsd-DqZ4QRFp.mjs +29 -0
  32. package/dist/getMachineId-darwin-DMbbW3m7.mjs +26 -0
  33. package/dist/getMachineId-linux-lyeD2ug3.mjs +22 -0
  34. package/dist/getMachineId-unsupported-JuKr57jY.mjs +17 -0
  35. package/dist/getMachineId-win-Dxyf5pJq.mjs +28 -0
  36. package/dist/{http-1NL30qCe.js → http-BUr93aO6.js} +1 -1
  37. package/dist/{http-CX_zHeOD.mjs → http-D9zG-L9N.mjs} +3 -3
  38. package/dist/{http-Du1Jgf2P.cjs → http-FnUTcdMf.cjs} +1 -1
  39. package/dist/{key-C1Oto4it.mjs → key-CV57mOYH.mjs} +1 -1
  40. package/dist/{kv-cache-aGOwL6Vj.cjs → kv-cache-BG9O8wVV.cjs} +1 -1
  41. package/dist/{kv-cache-CsC3P4uu.js → kv-cache-C3esyJFP.js} +1 -1
  42. package/dist/{ld-Dl1HIB1a.mjs → ld-sUf94RJ8.mjs} +2 -2
  43. package/dist/{middleware-BiFLcrEX.cjs → middleware-CKkBrsOD.cjs} +203 -32
  44. package/dist/{middleware-C1cf3_6V.mjs → middleware-cMxbPxDe.mjs} +1 -1
  45. package/dist/{middleware-CKJC8DRf.js → middleware-fAuUxD9-.js} +203 -32
  46. package/dist/{middleware-BwC5U8zJ.cjs → middleware-ohzkLsW4.cjs} +1 -1
  47. package/dist/{middleware-CEWDB8EB.mjs → middleware-pb2EqN_r.mjs} +75 -27
  48. package/dist/{mod-ckCOmoCz.d.ts → mod-B8Z8mBLk.d.ts} +1 -1
  49. package/dist/{mod-BghZgD_U.d.cts → mod-DClCOv0M.d.cts} +1 -1
  50. package/dist/mod.cjs +4 -4
  51. package/dist/mod.d.cts +2 -2
  52. package/dist/mod.d.ts +2 -2
  53. package/dist/mod.js +4 -4
  54. package/dist/nodeinfo/client.test.mjs +2 -2
  55. package/dist/nodeinfo/handler.test.mjs +3 -3
  56. package/dist/nodeinfo/types.test.mjs +1 -1
  57. package/dist/otel/exporter.test.mjs +25 -22
  58. package/dist/otel/mod.cjs +6 -5
  59. package/dist/otel/mod.d.cts +3 -2
  60. package/dist/otel/mod.d.ts +3 -2
  61. package/dist/otel/mod.js +6 -5
  62. package/dist/{outgoing-jsonld-CNmZLixq.mjs → outgoing-jsonld-Bi7n-dEy.mjs} +1 -1
  63. package/dist/{owner-CEWFJlqo.mjs → owner-DsPgl527.mjs} +2 -2
  64. package/dist/{proof-CDA3f-i5.cjs → proof-BhJpq_J9.cjs} +1 -1
  65. package/dist/{proof-BFyPVl1r.mjs → proof-iVfYyJpY.mjs} +4 -4
  66. package/dist/{proof-Dedf8md5.js → proof-k4mEvvdS.js} +1 -1
  67. package/dist/send-D-vYdfC6.mjs +306 -0
  68. package/dist/sig/accept.test.mjs +1 -1
  69. package/dist/sig/http.test.mjs +4 -4
  70. package/dist/sig/key.test.mjs +2 -2
  71. package/dist/sig/ld.test.mjs +3 -3
  72. package/dist/sig/mod.cjs +2 -2
  73. package/dist/sig/mod.js +2 -2
  74. package/dist/sig/owner.test.mjs +2 -2
  75. package/dist/sig/proof.test.mjs +3 -3
  76. package/dist/testing/mod.d.mts +18 -1
  77. package/dist/testing/mod.mjs +1 -1
  78. package/dist/utils/docloader.test.mjs +4 -4
  79. package/dist/utils/kv-cache.test.mjs +1 -1
  80. package/dist/utils/mod.cjs +1 -1
  81. package/dist/utils/mod.js +1 -1
  82. package/package.json +7 -6
  83. package/dist/send-BJickEP4.mjs +0 -193
  84. /package/dist/{accept-CPkZzmGN.mjs → accept-CceiKpCy.mjs} +0 -0
  85. /package/dist/{activity-listener-ell7W1s9.mjs → activity-listener-tztVvlNb.mjs} +0 -0
  86. /package/dist/{client-D_1QpnWt.mjs → client-CIiz1WX7.mjs} +0 -0
  87. /package/dist/{collection-D-HqUuA2.mjs → collection-CA3V5zyK.mjs} +0 -0
  88. /package/dist/{keycache-EGATflN-.mjs → keycache-BeU0LCII.mjs} +0 -0
  89. /package/dist/{keys-DGu1NFwu.mjs → keys-C3kae-6B.mjs} +0 -0
  90. /package/dist/{kv-cache-U__xU4qR.mjs → kv-cache-Bmv7tUzz.mjs} +0 -0
  91. /package/dist/{kv-rV3vodCc.mjs → kv-x2IvBUyq.mjs} +0 -0
  92. /package/dist/{negotiation-SQvQgUqe.mjs → negotiation-VnHNB0Q5.mjs} +0 -0
  93. /package/dist/{public-audience-DYFHzm_c.mjs → public-audience-PVTwU_Ex.mjs} +0 -0
  94. /package/dist/{retry-bMXBL97A.mjs → retry-_VvV0h9f.mjs} +0 -0
  95. /package/dist/{types-J53Kw7so.mjs → types-BFowWFTT.mjs} +0 -0
@@ -1,193 +0,0 @@
1
- import "@js-temporal/polyfill";
2
- import "urlpattern-polyfill";
3
- globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-Ctd-K-t6.mjs";
5
- import { n as doubleKnock } from "./http-CX_zHeOD.mjs";
6
- import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
7
- import { getLogger } from "@logtape/logtape";
8
- //#region src/federation/send.ts
9
- /**
10
- * Extracts the inbox URLs from recipients.
11
- * @param parameters The parameters to extract the inboxes.
12
- * See also {@link ExtractInboxesParameters}.
13
- * @returns The inboxes as a map of inbox URL to actor URIs.
14
- */
15
- function extractInboxes({ recipients, preferSharedInbox, excludeBaseUris }) {
16
- const inboxes = {};
17
- for (const recipient of recipients) {
18
- let inbox;
19
- let sharedInbox = false;
20
- if (preferSharedInbox && recipient.endpoints?.sharedInbox != null) {
21
- inbox = recipient.endpoints.sharedInbox;
22
- sharedInbox = true;
23
- } else inbox = recipient.inboxId;
24
- if (inbox != null && recipient.id != null) {
25
- if (excludeBaseUris != null && excludeBaseUris.some((u) => u.origin === inbox?.origin)) continue;
26
- inboxes[inbox.href] ??= {
27
- actorIds: /* @__PURE__ */ new Set(),
28
- sharedInbox
29
- };
30
- inboxes[inbox.href].actorIds.add(recipient.id.href);
31
- }
32
- }
33
- return inboxes;
34
- }
35
- /**
36
- * Sends an {@link Activity} to an inbox.
37
- *
38
- * @param parameters The parameters for sending the activity.
39
- * See also {@link SendActivityParameters}.
40
- * @throws {Error} If the activity fails to send.
41
- */
42
- function sendActivity(options) {
43
- const tracerProvider = options.tracerProvider ?? trace.getTracerProvider();
44
- return tracerProvider.getTracer(name, version).startActiveSpan("activitypub.send_activity", {
45
- kind: SpanKind.CLIENT,
46
- attributes: { "activitypub.shared_inbox": options.sharedInbox ?? false }
47
- }, async (span) => {
48
- if (options.activityId != null) span.setAttribute("activitypub.activity.id", options.activityId);
49
- if (options.activityType != null) span.setAttribute("activitypub.activity.type", options.activityType);
50
- try {
51
- await sendActivityInternal({
52
- ...options,
53
- tracerProvider
54
- }, span);
55
- } catch (e) {
56
- span.setStatus({
57
- code: SpanStatusCode.ERROR,
58
- message: String(e)
59
- });
60
- throw e;
61
- } finally {
62
- span.end();
63
- }
64
- });
65
- }
66
- const MAX_ERROR_RESPONSE_BODY_BYTES = 1024;
67
- async function readLimitedResponseBody(response, maxBytes) {
68
- if (response.body == null) return "";
69
- const reader = response.body.getReader();
70
- const decoder = new TextDecoder();
71
- const chunks = [];
72
- let totalBytes = 0;
73
- let truncated = false;
74
- try {
75
- while (true) {
76
- const { done, value } = await reader.read();
77
- if (done) break;
78
- if (totalBytes + value.length > maxBytes) {
79
- const remaining = maxBytes - totalBytes;
80
- if (remaining > 0) chunks.push(decoder.decode(value.slice(0, remaining), { stream: true }));
81
- truncated = true;
82
- break;
83
- }
84
- chunks.push(decoder.decode(value, { stream: true }));
85
- totalBytes += value.length;
86
- }
87
- } finally {
88
- reader.releaseLock();
89
- }
90
- let result = chunks.join("");
91
- if (truncated) result += "… (truncated)";
92
- return result;
93
- }
94
- async function sendActivityInternal({ activity, activityId, keys, inbox, headers, specDeterminer, tracerProvider }, span) {
95
- const logger = getLogger([
96
- "fedify",
97
- "federation",
98
- "outbox"
99
- ]);
100
- headers = new Headers(headers);
101
- headers.set("Content-Type", "application/activity+json");
102
- const request = new Request(inbox, {
103
- method: "POST",
104
- headers,
105
- body: JSON.stringify(activity)
106
- });
107
- let rsaKey = null;
108
- for (const key of keys) if (key.privateKey.algorithm.name === "RSASSA-PKCS1-v1_5") {
109
- rsaKey = key;
110
- break;
111
- }
112
- if (rsaKey == null) logger.warn("No supported key found to sign the request to {inbox}. The request will be sent without a signature. In order to sign the request, at least one RSASSA-PKCS1-v1_5 key must be provided.", {
113
- inbox: inbox.href,
114
- keys: keys.map((pair) => ({
115
- keyId: pair.keyId.href,
116
- privateKey: pair.privateKey
117
- }))
118
- });
119
- let response;
120
- try {
121
- response = rsaKey == null ? await fetch(request) : await doubleKnock(request, rsaKey, {
122
- tracerProvider,
123
- specDeterminer
124
- });
125
- } catch (error) {
126
- logger.error("Failed to send activity {activityId} to {inbox}:\n{error}", {
127
- activityId,
128
- inbox: inbox.href,
129
- error
130
- });
131
- throw error;
132
- }
133
- if (!response.ok) {
134
- let error;
135
- try {
136
- error = await readLimitedResponseBody(response, MAX_ERROR_RESPONSE_BODY_BYTES);
137
- } catch (_) {
138
- error = "";
139
- }
140
- logger.error("Failed to send activity {activityId} to {inbox} ({status} {statusText}):\n{error}", {
141
- activityId,
142
- inbox: inbox.href,
143
- status: response.status,
144
- statusText: response.statusText,
145
- error
146
- });
147
- throw new SendActivityError(inbox, response.status, `Failed to send activity ${activityId} to ${inbox.href} (${response.status} ${response.statusText}):\n${error}`, error);
148
- }
149
- span.addEvent("activitypub.activity.sent", {
150
- "activitypub.activity.json": JSON.stringify(activity),
151
- "activitypub.inbox.url": inbox.href,
152
- "activitypub.activity.id": activityId ?? ""
153
- });
154
- }
155
- /**
156
- * An error that is thrown when an activity fails to send to a remote inbox.
157
- * It contains structured information about the failure, including the HTTP
158
- * status code, the inbox URL, and the response body.
159
- * @since 2.0.0
160
- */
161
- var SendActivityError = class extends Error {
162
- /**
163
- * The inbox URL that the activity was being sent to.
164
- */
165
- inbox;
166
- /**
167
- * The HTTP status code returned by the inbox.
168
- */
169
- statusCode;
170
- /**
171
- * The response body from the inbox, if any. Note that this may be
172
- * truncated to a maximum of 1 KiB to prevent excessive memory consumption
173
- * when remote servers return large error pages (e.g., Cloudflare error pages).
174
- * If truncated, the string will end with `"… (truncated)"`.
175
- */
176
- responseBody;
177
- /**
178
- * Creates a new {@link SendActivityError}.
179
- * @param inbox The inbox URL.
180
- * @param statusCode The HTTP status code.
181
- * @param message The error message.
182
- * @param responseBody The response body.
183
- */
184
- constructor(inbox, statusCode, message, responseBody) {
185
- super(message);
186
- this.name = "SendActivityError";
187
- this.inbox = inbox;
188
- this.statusCode = statusCode;
189
- this.responseBody = responseBody;
190
- }
191
- };
192
- //#endregion
193
- export { extractInboxes as n, sendActivity as r, SendActivityError as t };
File without changes
File without changes
File without changes
File without changes