@fedify/fedify 2.2.0-dev.869 → 2.2.0-pr.695.23
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.
- package/README.md +0 -2
- package/dist/{builder-D8YzbzDN.mjs → builder-_3USSkAi.mjs} +7 -57
- package/dist/compat/mod.d.cts +1 -1
- package/dist/compat/mod.d.ts +1 -1
- package/dist/compat/transformers.test.mjs +1 -1
- package/dist/{context-BGrYMSTk.d.ts → context-78ecvxf5.d.ts} +1 -143
- package/dist/{context-CMUd4wy0.d.cts → context-DYDPdoCb.d.cts} +1 -143
- package/dist/{context-Dk_tacqz.mjs → context-Juj6bdHC.mjs} +2 -17
- package/dist/{deno-DXdMYkAF.mjs → deno-CALl2W-v.mjs} +1 -1
- package/dist/{docloader-D6GGGkLu.mjs → docloader-Cd_GcKDJ.mjs} +2 -2
- package/dist/federation/builder.test.mjs +1 -25
- package/dist/federation/handler.test.mjs +8 -369
- package/dist/federation/idempotency.test.mjs +2 -2
- package/dist/federation/inbox.test.mjs +3 -3
- package/dist/federation/middleware.test.mjs +8 -510
- package/dist/federation/mod.cjs +1 -1
- package/dist/federation/mod.d.cts +3 -3
- package/dist/federation/mod.d.ts +3 -3
- package/dist/federation/mod.js +1 -1
- package/dist/federation/send.test.mjs +3 -3
- package/dist/federation/webfinger.test.mjs +2 -2
- package/dist/{http-Bkl65Xah.cjs → http-BmjzD8cM.cjs} +1 -1
- package/dist/{http-kJLVVuQ4.mjs → http-BoYB66uz.mjs} +2 -2
- package/dist/{http-Bwhs9THj.js → http-Co58ywXN.js} +1 -1
- package/dist/inbox-BRn2Zxr4.mjs +179 -0
- package/dist/{key-DY9YAHVK.mjs → key-CrCG-yLH.mjs} +1 -1
- package/dist/{kv-cache-DTEfriBO.js → kv-cache-DWlJLiMn.js} +1 -1
- package/dist/{kv-cache-PqsOT6Ky.cjs → kv-cache-GmvjgIY4.cjs} +1 -1
- package/dist/{ld-Bittq8I7.mjs → ld-Cj_0JVzk.mjs} +3 -26
- package/dist/{middleware-BE03PkEx.mjs → middleware-B-hCoIdY.mjs} +180 -612
- package/dist/{middleware-DVMQdDWr.cjs → middleware-BXCjmWN2.cjs} +1 -1
- package/dist/{middleware-VSA_KWpd.js → middleware-CLVQBjm2.js} +368 -716
- package/dist/{middleware-ChIzhod7.mjs → middleware-Djvz1scF.mjs} +1 -1
- package/dist/{middleware-DMOqJ2rJ.cjs → middleware-SVMhMPsP.cjs} +365 -718
- package/dist/{mod-BcJHeuv1.d.cts → mod-CEohtXhV.d.cts} +1 -1
- package/dist/{mod-CJXfyw7v.d.ts → mod-CokIUYDr.d.ts} +1 -1
- package/dist/{mod-Cr3f-ACa.d.cts → mod-DoJBjjnO.d.cts} +1 -18
- package/dist/{mod-CR8soWa9.d.ts → mod-DvxszxXC.d.ts} +1 -18
- package/dist/mod.cjs +4 -6
- package/dist/mod.d.cts +5 -5
- package/dist/mod.d.ts +5 -5
- package/dist/mod.js +5 -5
- package/dist/nodeinfo/handler.test.mjs +2 -2
- package/dist/{owner-BZgNaUac.mjs → owner-CQ0ITJYn.mjs} +2 -2
- package/dist/{proof-DX47G5Fd.js → proof-B2qPm5I4.js} +2 -54
- package/dist/{proof-B5TlVvOq.cjs → proof-Bvs3L21X.cjs} +3 -61
- package/dist/{proof-41DPsEcO.mjs → proof-OOosrRgx.mjs} +3 -32
- package/dist/{send-m-XUlhVD.mjs → send-CP34W1Zh.mjs} +2 -2
- package/dist/sig/http.test.mjs +2 -2
- package/dist/sig/key.test.mjs +1 -1
- package/dist/sig/ld.test.mjs +2 -44
- package/dist/sig/mod.cjs +2 -4
- package/dist/sig/mod.d.cts +2 -2
- package/dist/sig/mod.d.ts +2 -2
- package/dist/sig/mod.js +3 -3
- package/dist/sig/owner.test.mjs +1 -1
- package/dist/sig/proof.test.mjs +2 -46
- package/dist/testing/mod.d.mts +1 -149
- package/dist/testing/mod.mjs +2 -2
- package/dist/utils/docloader.test.mjs +2 -2
- package/dist/utils/mod.cjs +1 -1
- package/dist/utils/mod.js +1 -1
- package/package.json +5 -5
- package/dist/activity-listener-Ck3JZ_hR.mjs +0 -40
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import {
|
|
4
|
+
import { n as createRequestContext } from "../context-Juj6bdHC.mjs";
|
|
5
5
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
6
6
|
import "../std__assert-Duiq_YC9.mjs";
|
|
7
7
|
import { t as MemoryKvStore } from "../kv-tL2TOE9X.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { a as createFederation, o as handleWebFinger } from "../middleware-B-hCoIdY.mjs";
|
|
9
9
|
import { test } from "@fedify/fixture";
|
|
10
10
|
import { Image, Link, Person, Tombstone } from "@fedify/vocab";
|
|
11
11
|
//#region src/federation/webfinger.test.ts
|
|
@@ -11,7 +11,7 @@ let _opentelemetry_semantic_conventions = require("@opentelemetry/semantic-conve
|
|
|
11
11
|
let byte_encodings_base64 = require("byte-encodings/base64");
|
|
12
12
|
//#region deno.json
|
|
13
13
|
var name = "@fedify/fedify";
|
|
14
|
-
var version = "2.2.0-
|
|
14
|
+
var version = "2.2.0-pr.695.23+d0b31ca2";
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/sig/accept.ts
|
|
17
17
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
4
|
+
import { n as version, t as name } from "./deno-CALl2W-v.mjs";
|
|
5
5
|
import { i as validateAcceptSignature, n as fulfillAcceptSignature, r as parseAcceptSignature } from "./accept-Dd__NiUL.mjs";
|
|
6
|
-
import { o as validateCryptoKey, r as fetchKeyDetailed } from "./key-
|
|
6
|
+
import { o as validateCryptoKey, r as fetchKeyDetailed } from "./key-CrCG-yLH.mjs";
|
|
7
7
|
import { CryptographicKey } from "@fedify/vocab";
|
|
8
8
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
9
9
|
import { FetchError } from "@fedify/vocab-runtime";
|
|
@@ -10,7 +10,7 @@ import { ATTR_HTTP_REQUEST_HEADER, ATTR_HTTP_REQUEST_METHOD, ATTR_URL_FULL } fro
|
|
|
10
10
|
import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
|
|
11
11
|
//#region deno.json
|
|
12
12
|
var name = "@fedify/fedify";
|
|
13
|
-
var version = "2.2.0-
|
|
13
|
+
var version = "2.2.0-pr.695.23+d0b31ca2";
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/sig/accept.ts
|
|
16
16
|
/**
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
globalThis.addEventListener = () => {};
|
|
4
|
+
import { n as version, t as name } from "./deno-CALl2W-v.mjs";
|
|
5
|
+
import { Activity, getTypeId } from "@fedify/vocab";
|
|
6
|
+
import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
|
|
7
|
+
import { getLogger } from "@logtape/logtape";
|
|
8
|
+
//#region src/federation/inbox.ts
|
|
9
|
+
var InboxListenerSet = class InboxListenerSet {
|
|
10
|
+
#listeners;
|
|
11
|
+
constructor() {
|
|
12
|
+
this.#listeners = /* @__PURE__ */ new Map();
|
|
13
|
+
}
|
|
14
|
+
clone() {
|
|
15
|
+
const clone = new InboxListenerSet();
|
|
16
|
+
clone.#listeners = new Map(this.#listeners);
|
|
17
|
+
return clone;
|
|
18
|
+
}
|
|
19
|
+
add(type, listener) {
|
|
20
|
+
if (this.#listeners.has(type)) throw new TypeError("Listener already set for this type.");
|
|
21
|
+
this.#listeners.set(type, listener);
|
|
22
|
+
}
|
|
23
|
+
dispatchWithClass(activity) {
|
|
24
|
+
let cls = activity.constructor;
|
|
25
|
+
const inboxListeners = this.#listeners;
|
|
26
|
+
if (inboxListeners == null) return null;
|
|
27
|
+
while (true) {
|
|
28
|
+
if (inboxListeners.has(cls)) break;
|
|
29
|
+
if (cls === Activity) return null;
|
|
30
|
+
cls = globalThis.Object.getPrototypeOf(cls);
|
|
31
|
+
}
|
|
32
|
+
const listener = inboxListeners.get(cls);
|
|
33
|
+
return {
|
|
34
|
+
class: cls,
|
|
35
|
+
listener
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
dispatch(activity) {
|
|
39
|
+
return this.dispatchWithClass(activity)?.listener ?? null;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
async function routeActivity({ context: ctx, json, activity, recipient, inboxListeners, inboxContextFactory, inboxErrorHandler, kv, kvPrefixes, queue, span, tracerProvider, idempotencyStrategy }) {
|
|
43
|
+
const logger = getLogger([
|
|
44
|
+
"fedify",
|
|
45
|
+
"federation",
|
|
46
|
+
"inbox"
|
|
47
|
+
]);
|
|
48
|
+
let cacheKey = null;
|
|
49
|
+
if (activity.id != null) {
|
|
50
|
+
const inboxContext = inboxContextFactory(recipient, json, activity.id?.href, getTypeId(activity).href);
|
|
51
|
+
const strategy = idempotencyStrategy ?? "per-inbox";
|
|
52
|
+
let keyString;
|
|
53
|
+
if (typeof strategy === "function") keyString = await strategy(inboxContext, activity);
|
|
54
|
+
else switch (strategy) {
|
|
55
|
+
case "global":
|
|
56
|
+
keyString = activity.id.href;
|
|
57
|
+
break;
|
|
58
|
+
case "per-origin":
|
|
59
|
+
keyString = `${ctx.origin}\n${activity.id.href}`;
|
|
60
|
+
break;
|
|
61
|
+
case "per-inbox":
|
|
62
|
+
keyString = `${ctx.origin}\n${activity.id.href}\n${recipient == null ? "sharedInbox" : `inbox\n${recipient}`}`;
|
|
63
|
+
break;
|
|
64
|
+
default: keyString = `${ctx.origin}\n${activity.id.href}`;
|
|
65
|
+
}
|
|
66
|
+
if (keyString != null) cacheKey = [...kvPrefixes.activityIdempotence, keyString];
|
|
67
|
+
}
|
|
68
|
+
if (cacheKey != null) {
|
|
69
|
+
if (await kv.get(cacheKey) === true) {
|
|
70
|
+
logger.debug("Activity {activityId} has already been processed.", {
|
|
71
|
+
activityId: activity.id?.href,
|
|
72
|
+
activity: json,
|
|
73
|
+
recipient
|
|
74
|
+
});
|
|
75
|
+
span.setStatus({
|
|
76
|
+
code: SpanStatusCode.UNSET,
|
|
77
|
+
message: `Activity ${activity.id?.href} has already been processed.`
|
|
78
|
+
});
|
|
79
|
+
return "alreadyProcessed";
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (activity.actorId == null) {
|
|
83
|
+
logger.error("Missing actor.", { activity: json });
|
|
84
|
+
span.setStatus({
|
|
85
|
+
code: SpanStatusCode.ERROR,
|
|
86
|
+
message: "Missing actor."
|
|
87
|
+
});
|
|
88
|
+
return "missingActor";
|
|
89
|
+
}
|
|
90
|
+
span.setAttribute("activitypub.actor.id", activity.actorId.href);
|
|
91
|
+
if (queue != null) {
|
|
92
|
+
const carrier = {};
|
|
93
|
+
propagation.inject(context.active(), carrier);
|
|
94
|
+
try {
|
|
95
|
+
await queue.enqueue({
|
|
96
|
+
type: "inbox",
|
|
97
|
+
id: crypto.randomUUID(),
|
|
98
|
+
baseUrl: ctx.origin,
|
|
99
|
+
activity: json,
|
|
100
|
+
identifier: recipient,
|
|
101
|
+
attempt: 0,
|
|
102
|
+
started: (/* @__PURE__ */ new Date()).toISOString(),
|
|
103
|
+
traceContext: carrier
|
|
104
|
+
});
|
|
105
|
+
} catch (error) {
|
|
106
|
+
logger.error("Failed to enqueue the incoming activity {activityId}:\n{error}", {
|
|
107
|
+
error,
|
|
108
|
+
activityId: activity.id?.href,
|
|
109
|
+
activity: json,
|
|
110
|
+
recipient
|
|
111
|
+
});
|
|
112
|
+
span.setStatus({
|
|
113
|
+
code: SpanStatusCode.ERROR,
|
|
114
|
+
message: `Failed to enqueue the incoming activity ${activity.id?.href}.`
|
|
115
|
+
});
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
logger.info("Activity {activityId} is enqueued.", {
|
|
119
|
+
activityId: activity.id?.href,
|
|
120
|
+
activity: json,
|
|
121
|
+
recipient
|
|
122
|
+
});
|
|
123
|
+
return "enqueued";
|
|
124
|
+
}
|
|
125
|
+
tracerProvider = tracerProvider ?? trace.getTracerProvider();
|
|
126
|
+
return await tracerProvider.getTracer(name, version).startActiveSpan("activitypub.dispatch_inbox_listener", { kind: SpanKind.INTERNAL }, async (span) => {
|
|
127
|
+
const dispatched = inboxListeners?.dispatchWithClass(activity);
|
|
128
|
+
if (dispatched == null) {
|
|
129
|
+
logger.error("Unsupported activity type:\n{activity}", {
|
|
130
|
+
activity: json,
|
|
131
|
+
recipient
|
|
132
|
+
});
|
|
133
|
+
span.setStatus({
|
|
134
|
+
code: SpanStatusCode.UNSET,
|
|
135
|
+
message: `Unsupported activity type: ${getTypeId(activity).href}`
|
|
136
|
+
});
|
|
137
|
+
span.end();
|
|
138
|
+
return "unsupportedActivity";
|
|
139
|
+
}
|
|
140
|
+
const { class: cls, listener } = dispatched;
|
|
141
|
+
span.updateName(`activitypub.dispatch_inbox_listener ${cls.name}`);
|
|
142
|
+
try {
|
|
143
|
+
await listener(inboxContextFactory(recipient, json, activity?.id?.href, getTypeId(activity).href), activity);
|
|
144
|
+
} catch (error) {
|
|
145
|
+
try {
|
|
146
|
+
await inboxErrorHandler?.(ctx, error);
|
|
147
|
+
} catch (error) {
|
|
148
|
+
logger.error("An unexpected error occurred in inbox error handler:\n{error}", {
|
|
149
|
+
error,
|
|
150
|
+
activityId: activity.id?.href,
|
|
151
|
+
activity: json,
|
|
152
|
+
recipient
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
logger.error("Failed to process the incoming activity {activityId}:\n{error}", {
|
|
156
|
+
error,
|
|
157
|
+
activityId: activity.id?.href,
|
|
158
|
+
activity: json,
|
|
159
|
+
recipient
|
|
160
|
+
});
|
|
161
|
+
span.setStatus({
|
|
162
|
+
code: SpanStatusCode.ERROR,
|
|
163
|
+
message: String(error)
|
|
164
|
+
});
|
|
165
|
+
span.end();
|
|
166
|
+
return "error";
|
|
167
|
+
}
|
|
168
|
+
if (cacheKey != null) await kv.set(cacheKey, true, { ttl: Temporal.Duration.from({ days: 1 }) });
|
|
169
|
+
logger.info("Activity {activityId} has been processed.", {
|
|
170
|
+
activityId: activity.id?.href,
|
|
171
|
+
activity: json,
|
|
172
|
+
recipient
|
|
173
|
+
});
|
|
174
|
+
span.end();
|
|
175
|
+
return "success";
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
//#endregion
|
|
179
|
+
export { routeActivity as n, InboxListenerSet as t };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
4
|
+
import { n as version, t as name } from "./deno-CALl2W-v.mjs";
|
|
5
5
|
import { CryptographicKey, Object as Object$1, isActor } from "@fedify/vocab";
|
|
6
6
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
7
7
|
import { FetchError, getDocumentLoader } from "@fedify/vocab-runtime";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import { d as validateCryptoKey, t as doubleKnock } from "./http-
|
|
3
|
+
import { d as validateCryptoKey, t as doubleKnock } from "./http-Co58ywXN.js";
|
|
4
4
|
import { getLogger } from "@logtape/logtape";
|
|
5
5
|
import { curry } from "es-toolkit";
|
|
6
6
|
import { UrlError, createActivityPubRequest, getRemoteDocument, logRequest, preloadedContexts, validatePublicUrl } from "@fedify/vocab-runtime";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { Temporal } = require("@js-temporal/polyfill");
|
|
2
2
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
3
3
|
require("./chunk-DDcVe30Y.cjs");
|
|
4
|
-
const require_http = require("./http-
|
|
4
|
+
const require_http = require("./http-BmjzD8cM.cjs");
|
|
5
5
|
let _logtape_logtape = require("@logtape/logtape");
|
|
6
6
|
let es_toolkit = require("es-toolkit");
|
|
7
7
|
let _fedify_vocab_runtime = require("@fedify/vocab-runtime");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
5
|
-
import { n as fetchKey, o as validateCryptoKey } from "./key-
|
|
4
|
+
import { n as version, t as name } from "./deno-CALl2W-v.mjs";
|
|
5
|
+
import { n as fetchKey, o as validateCryptoKey } from "./key-CrCG-yLH.mjs";
|
|
6
6
|
import { Activity, CryptographicKey, Object as Object$1, getTypeId } from "@fedify/vocab";
|
|
7
7
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
8
8
|
import { getDocumentLoader } from "@fedify/vocab-runtime";
|
|
@@ -94,29 +94,6 @@ async function signJsonLd(jsonLd, privateKey, keyId, options) {
|
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
96
|
/**
|
|
97
|
-
* Checks if the given JSON-LD document has a Linked Data Signature-like
|
|
98
|
-
* object, without restricting it to a single suite-specific shape.
|
|
99
|
-
* @param jsonLd The JSON-LD document to check.
|
|
100
|
-
* @returns `true` if the document has a signature-like object; `false`
|
|
101
|
-
* otherwise.
|
|
102
|
-
* @since 2.2.0
|
|
103
|
-
*/
|
|
104
|
-
function hasSignatureLike(jsonLd) {
|
|
105
|
-
if (typeof jsonLd !== "object" || jsonLd == null) return false;
|
|
106
|
-
const signature = jsonLd.signature;
|
|
107
|
-
const hasReference = (value) => {
|
|
108
|
-
if (typeof value === "string") return true;
|
|
109
|
-
if (Array.isArray(value)) return value.some(hasReference);
|
|
110
|
-
return typeof value === "object" && value != null && ("id" in value && typeof value.id === "string" || "@id" in value && typeof value["@id"] === "string");
|
|
111
|
-
};
|
|
112
|
-
const hasSignatureObject = (value) => {
|
|
113
|
-
if (typeof value !== "object" || value == null) return false;
|
|
114
|
-
const signatureRecord = value;
|
|
115
|
-
return (typeof signatureRecord.type === "string" || Array.isArray(signatureRecord.type) && signatureRecord.type.some((item) => typeof item === "string")) && (hasReference(signatureRecord.creator) || hasReference(signatureRecord.verificationMethod)) && (typeof signatureRecord.signatureValue === "string" || typeof signatureRecord.jws === "string");
|
|
116
|
-
};
|
|
117
|
-
return Array.isArray(signature) ? signature.some(hasSignatureObject) : hasSignatureObject(signature);
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
97
|
* Checks if the given JSON-LD document has a Linked Data Signature.
|
|
121
98
|
* @param jsonLd The JSON-LD document to check.
|
|
122
99
|
* @returns `true` if the document has a signature; `false` otherwise.
|
|
@@ -276,4 +253,4 @@ async function hashJsonLd(jsonLd, contextLoader) {
|
|
|
276
253
|
return encodeHex(await crypto.subtle.digest("SHA-256", encoder.encode(canon)));
|
|
277
254
|
}
|
|
278
255
|
//#endregion
|
|
279
|
-
export { signJsonLd as a,
|
|
256
|
+
export { signJsonLd as a, hasSignature as i, createSignature as n, verifyJsonLd as o, detachSignature as r, verifySignature as s, attachSignature as t };
|