@fedify/fedify 2.3.0-dev.1131 → 2.3.0-dev.1137
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 +3 -0
- package/dist/{assert-DikXweDx.mjs → assert-OguE97r2.mjs} +1 -1
- package/dist/{assert_instance_of-C4Ri6VuN.mjs → assert_instance_of-DBC5X09g.mjs} +1 -1
- package/dist/{assert_not_equals--wG9hV7u.mjs → assert_not_equals-DkVK8oqV.mjs} +1 -1
- package/dist/{assert_rejects-DQP-q39h.mjs → assert_rejects-DN60FHPX.mjs} +2 -2
- package/dist/{assert_strict_equals-Dmjbg-bA.mjs → assert_strict_equals-XEgZAlrj.mjs} +1 -1
- package/dist/{assert_throws-4NwKEy2q.mjs → assert_throws-BOkhLGYc.mjs} +1 -1
- package/dist/{builder-DckAhD27.mjs → builder-BCkBXxky.mjs} +60 -41
- package/dist/compat/mod.d.cts +1 -1
- package/dist/compat/mod.d.ts +1 -1
- package/dist/compat/outgoing-jsonld.test.mjs +3 -3
- package/dist/compat/public-audience.test.mjs +3 -3
- package/dist/compat/transformers.test.mjs +5 -5
- package/dist/{context-Cq18Gplu.d.ts → context-DCtsSHDv.d.ts} +2 -86
- package/dist/{context-tc6VOOOL.d.cts → context-DI2gRbyN.d.cts} +1 -87
- package/dist/{context-BAE7AKLA.mjs → context-DVoTs_wM.mjs} +1 -1
- package/dist/{deno--CS-SBS9.mjs → deno-B_9yJW3w.mjs} +1 -1
- package/dist/{docloader-k6huZLQL.mjs → docloader-BT89tyFr.mjs} +3 -3
- package/dist/federation/builder.test.mjs +138 -10
- package/dist/federation/collection.test.mjs +3 -3
- package/dist/federation/handler.test.mjs +12 -12
- package/dist/federation/idempotency.test.mjs +6 -6
- package/dist/federation/inbox.test.mjs +3 -3
- package/dist/federation/keycache.test.mjs +5 -5
- package/dist/federation/kv.test.mjs +3 -3
- package/dist/federation/metrics.test.mjs +4 -4
- package/dist/federation/middleware.test.mjs +30 -18
- package/dist/federation/mod.cjs +155 -3
- package/dist/federation/mod.d.cts +2 -2
- package/dist/federation/mod.d.ts +2 -2
- package/dist/federation/mod.js +153 -1
- package/dist/federation/mq.test.mjs +5 -5
- package/dist/federation/negotiation.test.mjs +4 -4
- package/dist/federation/retry.test.mjs +3 -3
- package/dist/federation/router.test.mjs +190 -9
- package/dist/federation/send.test.mjs +16 -16
- package/dist/federation/webfinger.test.mjs +5 -5
- package/dist/{getMachineId-bsd-BY01PL1n.mjs → getMachineId-bsd-etIyxDet.mjs} +1 -1
- package/dist/{getMachineId-darwin-Dr1gkBkp.mjs → getMachineId-darwin-D23zTf4g.mjs} +1 -1
- package/dist/{getMachineId-win-QEYwcJiy.mjs → getMachineId-win-Dpap6v5i.mjs} +1 -1
- package/dist/{http-cqujdCRz.js → http-CToqG5ap.js} +1 -1
- package/dist/{http-CJfvRL7D.cjs → http-CWoeyogl.cjs} +1 -1
- package/dist/{http-IywnQdiX.mjs → http-Cyx5SNuu.mjs} +4 -4
- package/dist/{key-Df3tMleh.mjs → key-CkkMJBjF.mjs} +2 -2
- package/dist/{kv-cache-pEejzYq4.js → kv-cache-CuCn2xvM.js} +1 -1
- package/dist/{kv-cache-L0SMQkcd.cjs → kv-cache-DuEwFYcN.cjs} +1 -1
- package/dist/{kv-cache-q9Ec2ryS.mjs → kv-cache-VHFP42vY.mjs} +1 -1
- package/dist/{ld-BGwiJpl3.mjs → ld-k8yqD2a-.mjs} +3 -3
- package/dist/{metrics-BTOMkW8C.mjs → metrics-iRBg8jTk.mjs} +1 -1
- package/dist/{middleware-B2rtdpFV.cjs → middleware-BWLUrbS9.cjs} +95 -196
- package/dist/{middleware-Dnql59Y8.mjs → middleware-CztxpARM.mjs} +1 -1
- package/dist/{middleware-DtOddSVg.js → middleware-D7FrhN9q.js} +59 -148
- package/dist/{middleware-BB0IbDow.mjs → middleware-DQEgdr83.mjs} +21 -21
- package/dist/mod-C504qevA.d.cts +173 -0
- package/dist/mod-wYfuXeDE.d.ts +173 -0
- package/dist/mod.cjs +6 -6
- package/dist/mod.d.cts +2 -2
- package/dist/mod.d.ts +2 -2
- package/dist/mod.js +5 -5
- package/dist/nodeinfo/client.test.mjs +4 -4
- package/dist/nodeinfo/handler.test.mjs +5 -5
- package/dist/nodeinfo/types.test.mjs +4 -4
- package/dist/otel/exporter.test.mjs +3 -3
- package/dist/{outgoing-jsonld-BNL8AC14.mjs → outgoing-jsonld-BgFLCJQ_.mjs} +1 -1
- package/dist/{owner-CIt4hvmM.mjs → owner-nmXdvXpc.mjs} +2 -2
- package/dist/{proof-B1_u25UV.cjs → proof-CcsIJLTn.cjs} +1 -1
- package/dist/{proof-BYlrRSmZ.mjs → proof-DpwO1T4S.mjs} +5 -5
- package/dist/{proof-DMGIjHYH.js → proof-NRmtrTDu.js} +1 -1
- package/dist/{send-DJFpze7B.mjs → send-DvX2tYyZ.mjs} +3 -3
- package/dist/sig/accept.test.mjs +1 -1
- package/dist/sig/http.test.mjs +9 -9
- package/dist/sig/key.test.mjs +6 -6
- package/dist/sig/ld.test.mjs +7 -7
- package/dist/sig/mod.cjs +2 -2
- package/dist/sig/mod.js +2 -2
- package/dist/sig/owner.test.mjs +6 -6
- package/dist/sig/proof.test.mjs +8 -8
- package/dist/{std__assert-BTEgfoJo.mjs → std__assert-BBjXFNOb.mjs} +4 -4
- package/dist/testing/mod.d.mts +1 -0
- package/dist/testing/mod.mjs +1 -1
- package/dist/utils/docloader.test.mjs +7 -7
- package/dist/utils/kv-cache.test.mjs +1 -1
- package/dist/utils/mod.cjs +1 -1
- package/dist/utils/mod.js +1 -1
- package/package.json +7 -8
- package/dist/mod-CajNYYkt.d.ts +0 -63
- package/dist/mod-DnzgcPcy.d.cts +0 -63
- package/dist/router-BT_F5748.mjs +0 -114
- /package/dist/{accept-CgDcxvjV.mjs → accept-CceiKpCy.mjs} +0 -0
- /package/dist/{activity-listener-BeTGV3wc.mjs → activity-listener-tztVvlNb.mjs} +0 -0
- /package/dist/{assert_equals-Ew3jOFa3.mjs → assert_equals-C-ZRDbaf.mjs} +0 -0
- /package/dist/{client-Bneh_DYR.mjs → client-B_A6mfn3.mjs} +0 -0
- /package/dist/{collection-Cc3DVAhE.mjs → collection-CA3V5zyK.mjs} +0 -0
- /package/dist/{esm-sdtqOUPu.mjs → esm-BQRw925N.mjs} +0 -0
- /package/dist/{execAsync-Dxb7rNf3.mjs → execAsync-DCBrgFiV.mjs} +0 -0
- /package/dist/{getMachineId-linux-Bbhofx-s.mjs → getMachineId-linux-ObI47Hql.mjs} +0 -0
- /package/dist/{getMachineId-unsupported-dIOte2Ct.mjs → getMachineId-unsupported-Ddu-PFeh.mjs} +0 -0
- /package/dist/{keycache-BeU0LCII.mjs → keycache-BYMd8q7F.mjs} +0 -0
- /package/dist/{keys-CSYsOMFG.mjs → keys-C3kae-6B.mjs} +0 -0
- /package/dist/{kv-QHE0oeM3.mjs → kv-x2IvBUyq.mjs} +0 -0
- /package/dist/{negotiation-DDstyBvc.mjs → negotiation-CDW-_gUU.mjs} +0 -0
- /package/dist/{public-audience-c9zmYKgA.mjs → public-audience-N3pyOx2p.mjs} +0 -0
- /package/dist/{retry-_VvV0h9f.mjs → retry-v_sGLH1d.mjs} +0 -0
- /package/dist/{types-D09GN0uZ.mjs → types-BFowWFTT.mjs} +0 -0
|
@@ -2,17 +2,16 @@ const { Temporal } = require("@js-temporal/polyfill");
|
|
|
2
2
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
3
3
|
const require_chunk = require("./chunk-DDcVe30Y.cjs");
|
|
4
4
|
const require_transformers = require("./transformers-NeAONrAq.cjs");
|
|
5
|
-
const require_http = require("./http-
|
|
6
|
-
const require_proof = require("./proof-
|
|
5
|
+
const require_http = require("./http-CWoeyogl.cjs");
|
|
6
|
+
const require_proof = require("./proof-CcsIJLTn.cjs");
|
|
7
7
|
const require_types = require("./types-KC4QAoxe.cjs");
|
|
8
|
-
const require_kv_cache = require("./kv-cache-
|
|
8
|
+
const require_kv_cache = require("./kv-cache-DuEwFYcN.cjs");
|
|
9
9
|
let _logtape_logtape = require("@logtape/logtape");
|
|
10
|
+
let _fedify_uri_template = require("@fedify/uri-template");
|
|
10
11
|
let _fedify_vocab = require("@fedify/vocab");
|
|
11
12
|
let _opentelemetry_api = require("@opentelemetry/api");
|
|
12
|
-
let es_toolkit = require("es-toolkit");
|
|
13
|
-
let uri_template_router = require("uri-template-router");
|
|
14
|
-
let url_template = require("url-template");
|
|
15
13
|
let byte_encodings_hex = require("byte-encodings/hex");
|
|
14
|
+
let es_toolkit = require("es-toolkit");
|
|
16
15
|
let _fedify_vocab_runtime = require("@fedify/vocab-runtime");
|
|
17
16
|
let _opentelemetry_semantic_conventions = require("@opentelemetry/semantic-conventions");
|
|
18
17
|
let _fedify_webfinger = require("@fedify/webfinger");
|
|
@@ -52,126 +51,33 @@ var ActivityListenerSet = class {
|
|
|
52
51
|
}
|
|
53
52
|
};
|
|
54
53
|
//#endregion
|
|
55
|
-
//#region src/federation/
|
|
56
|
-
|
|
57
|
-
const clone = new uri_template_router.Router();
|
|
58
|
-
clone.nid = router.nid;
|
|
59
|
-
clone.fsm = (0, es_toolkit.cloneDeep)(router.fsm);
|
|
60
|
-
clone.routeSet = new Set(router.routeSet);
|
|
61
|
-
clone.templateRouteMap = new Map(router.templateRouteMap);
|
|
62
|
-
clone.valueRouteMap = new Map(router.valueRouteMap);
|
|
63
|
-
clone.hierarchy = (0, es_toolkit.cloneDeep)(router.hierarchy);
|
|
64
|
-
return clone;
|
|
65
|
-
}
|
|
54
|
+
//#region src/federation/builder.ts
|
|
55
|
+
const ACTOR_ALIAS_PREFIX = "actorAlias:";
|
|
66
56
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
57
|
+
* Route options shared by every dispatcher whose path must expose exactly
|
|
58
|
+
* one `{identifier}` variable bound to a single, non-empty value
|
|
59
|
+
* for `setOutboxDispatcher/Listener()`.
|
|
69
60
|
*/
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
#templateStrings;
|
|
74
|
-
/**
|
|
75
|
-
* Whether to ignore trailing slashes when matching paths.
|
|
76
|
-
* @since 1.6.0
|
|
77
|
-
*/
|
|
78
|
-
trailingSlashInsensitive;
|
|
79
|
-
/**
|
|
80
|
-
* Create a new {@link Router}.
|
|
81
|
-
* @param options Options for the router.
|
|
82
|
-
*/
|
|
83
|
-
constructor(options = {}) {
|
|
84
|
-
this.#router = new uri_template_router.Router();
|
|
85
|
-
this.#templates = {};
|
|
86
|
-
this.#templateStrings = {};
|
|
87
|
-
this.trailingSlashInsensitive = options.trailingSlashInsensitive ?? false;
|
|
88
|
-
}
|
|
89
|
-
clone() {
|
|
90
|
-
const clone = new Router({ trailingSlashInsensitive: this.trailingSlashInsensitive });
|
|
91
|
-
clone.#router = cloneInnerRouter(this.#router);
|
|
92
|
-
clone.#templates = { ...this.#templates };
|
|
93
|
-
clone.#templateStrings = { ...this.#templateStrings };
|
|
94
|
-
return clone;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Checks if a path name exists in the router.
|
|
98
|
-
* @param name The name of the path.
|
|
99
|
-
* @returns `true` if the path name exists, otherwise `false`.
|
|
100
|
-
*/
|
|
101
|
-
has(name) {
|
|
102
|
-
return name in this.#templates;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Adds a new path rule to the router.
|
|
106
|
-
* @param template The path pattern.
|
|
107
|
-
* @param name The name of the path.
|
|
108
|
-
* @returns The names of the variables in the path pattern.
|
|
109
|
-
*/
|
|
110
|
-
add(template, name) {
|
|
111
|
-
if (!template.startsWith("/")) throw new RouterError("Path must start with a slash.");
|
|
112
|
-
const rule = this.#router.addTemplate(template, {}, name);
|
|
113
|
-
this.#templates[name] = (0, url_template.parseTemplate)(template);
|
|
114
|
-
this.#templateStrings[name] = template;
|
|
115
|
-
return new Set(rule.variables.map((v) => v.varname));
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Resolves a path name and values from a URL, if any match.
|
|
119
|
-
* @param url The URL to resolve.
|
|
120
|
-
* @returns The name of the path and its values, if any match. Otherwise,
|
|
121
|
-
* `null`.
|
|
122
|
-
*/
|
|
123
|
-
route(url) {
|
|
124
|
-
let match = this.#router.resolveURI(url);
|
|
125
|
-
if (match == null) {
|
|
126
|
-
if (!this.trailingSlashInsensitive) return null;
|
|
127
|
-
url = url.endsWith("/") ? url.replace(/\/+$/, "") : `${url}/`;
|
|
128
|
-
match = this.#router.resolveURI(url);
|
|
129
|
-
if (match == null) return null;
|
|
130
|
-
}
|
|
131
|
-
return {
|
|
132
|
-
name: match.matchValue,
|
|
133
|
-
template: this.#templateStrings[match.matchValue],
|
|
134
|
-
values: match.params
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Constructs a URL/path from a path name and values.
|
|
139
|
-
* @param name The name of the path.
|
|
140
|
-
* @param values The values to expand the path with.
|
|
141
|
-
* @returns The URL/path, if the name exists. Otherwise, `null`.
|
|
142
|
-
*/
|
|
143
|
-
build(name, values) {
|
|
144
|
-
if (name in this.#templates) return this.#templates[name].expand(values);
|
|
145
|
-
return null;
|
|
146
|
-
}
|
|
61
|
+
const identifierSingular = {
|
|
62
|
+
exact: true,
|
|
63
|
+
variables: { identifier: { operatables: [""] } }
|
|
147
64
|
};
|
|
148
65
|
/**
|
|
149
|
-
*
|
|
66
|
+
* Route options shared by every dispatcher whose path must expose
|
|
67
|
+
* `{identifier}` and `{+identifier}` variables bound to the same single,
|
|
68
|
+
* non-empty value for following setters:
|
|
69
|
+
* - `setActorDispatcher()` (actor path)
|
|
70
|
+
* - `setInboxDispatcher/Listener()` (inbox path)
|
|
71
|
+
* - `setFollowingDispatcher()` (following path)
|
|
72
|
+
* - `setFollowersDispatcher()` (followers path)
|
|
73
|
+
* - `setLikedDispatcher()` (liked path)
|
|
74
|
+
* - `setFeaturedDispatcher()` (featured path)
|
|
75
|
+
* - `setFeaturedTagsDispatcher()` (featured tags path)
|
|
150
76
|
*/
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
* @param message The error message.
|
|
155
|
-
*/
|
|
156
|
-
constructor(message) {
|
|
157
|
-
super(message);
|
|
158
|
-
this.name = "RouterError";
|
|
159
|
-
}
|
|
77
|
+
const identifierSingularAllowPlus = {
|
|
78
|
+
exact: true,
|
|
79
|
+
variables: { identifier: { operatables: ["", "+"] } }
|
|
160
80
|
};
|
|
161
|
-
//#endregion
|
|
162
|
-
//#region src/federation/builder.ts
|
|
163
|
-
const ACTOR_ALIAS_PREFIX = "actorAlias:";
|
|
164
|
-
function validateSingleIdentifierVariablePath(path, errorMessage) {
|
|
165
|
-
const operatorMatches = globalThis.Array.from(path.matchAll(/{([+#./;?&]?)([A-Za-z_][A-Za-z0-9_]*)}/g));
|
|
166
|
-
if (operatorMatches.length !== 1 || operatorMatches[0]?.[2] !== "identifier") throw new RouterError(errorMessage);
|
|
167
|
-
if (operatorMatches.some((match) => [
|
|
168
|
-
"?",
|
|
169
|
-
"&",
|
|
170
|
-
"#"
|
|
171
|
-
].includes(match[1]) && match[2] === "identifier")) throw new RouterError(errorMessage);
|
|
172
|
-
const variables = new Router().add(path, "outbox");
|
|
173
|
-
if (variables.size !== 1 || !variables.has("identifier")) throw new RouterError(errorMessage);
|
|
174
|
-
}
|
|
175
81
|
var FederationBuilderImpl = class {
|
|
176
82
|
router;
|
|
177
83
|
actorCallbacks;
|
|
@@ -204,7 +110,7 @@ var FederationBuilderImpl = class {
|
|
|
204
110
|
*/
|
|
205
111
|
#symbolRegistry = /* @__PURE__ */ new Map();
|
|
206
112
|
constructor() {
|
|
207
|
-
this.router = new Router();
|
|
113
|
+
this.router = new _fedify_uri_template.Router();
|
|
208
114
|
this.objectCallbacks = {};
|
|
209
115
|
this.objectTypeIds = {};
|
|
210
116
|
this.collectionCallbacks = {};
|
|
@@ -246,9 +152,9 @@ var FederationBuilderImpl = class {
|
|
|
246
152
|
return _opentelemetry_api.trace.getTracer(require_http.name, require_http.version);
|
|
247
153
|
}
|
|
248
154
|
setActorDispatcher(path, dispatcher) {
|
|
249
|
-
if (this.router.has("actor")) throw new RouterError("Actor dispatcher already set.");
|
|
250
|
-
|
|
251
|
-
|
|
155
|
+
if (this.router.has("actor")) throw new _fedify_uri_template.RouterError("Actor dispatcher already set.");
|
|
156
|
+
(0, _fedify_uri_template.assertPath)(path);
|
|
157
|
+
this.router.add(path, "actor", identifierSingularAllowPlus);
|
|
252
158
|
const callbacks = { dispatcher: async (context, identifier) => {
|
|
253
159
|
const actor = await this._getTracer().startActiveSpan("activitypub.dispatch_actor", {
|
|
254
160
|
kind: _opentelemetry_api.SpanKind.SERVER,
|
|
@@ -348,11 +254,11 @@ var FederationBuilderImpl = class {
|
|
|
348
254
|
return setters;
|
|
349
255
|
},
|
|
350
256
|
mapActorAlias: (path, identifier) => {
|
|
351
|
-
if (identifier === "") throw new RouterError("Identifier cannot be empty.");
|
|
352
|
-
if (this.router.has(`actorAlias:${identifier}`)) throw new RouterError(`Actor alias for "${identifier}" already set.`);
|
|
353
|
-
if (
|
|
257
|
+
if (identifier === "") throw new _fedify_uri_template.RouterError("Identifier cannot be empty.");
|
|
258
|
+
if (this.router.has(`actorAlias:${identifier}`)) throw new _fedify_uri_template.RouterError(`Actor alias for "${identifier}" already set.`);
|
|
259
|
+
if (_fedify_uri_template.Router.variables(path).size > 0) throw new _fedify_uri_template.RouterError("Path for actor alias must have no variables.");
|
|
354
260
|
const existingRoute = this.router.route(path);
|
|
355
|
-
if (existingRoute != null) throw new RouterError(`Actor alias path "${path}" conflicts with existing route "${existingRoute.name}".`);
|
|
261
|
+
if (existingRoute != null) throw new _fedify_uri_template.RouterError(`Actor alias path "${path}" conflicts with existing route "${existingRoute.name}".`);
|
|
356
262
|
this.router.add(path, `${ACTOR_ALIAS_PREFIX}${identifier}`);
|
|
357
263
|
return setters;
|
|
358
264
|
},
|
|
@@ -364,8 +270,9 @@ var FederationBuilderImpl = class {
|
|
|
364
270
|
return setters;
|
|
365
271
|
}
|
|
366
272
|
setNodeInfoDispatcher(path, dispatcher) {
|
|
367
|
-
if (this.router.has("nodeInfo")) throw new RouterError("NodeInfo dispatcher already set.");
|
|
368
|
-
if (
|
|
273
|
+
if (this.router.has("nodeInfo")) throw new _fedify_uri_template.RouterError("NodeInfo dispatcher already set.");
|
|
274
|
+
if (_fedify_uri_template.Router.variables(path).size !== 0) throw new _fedify_uri_template.RouterError("Path for NodeInfo dispatcher must have no variables.");
|
|
275
|
+
this.router.add(path, "nodeInfo");
|
|
369
276
|
this.nodeInfoDispatcher = dispatcher;
|
|
370
277
|
}
|
|
371
278
|
setWebFingerLinksDispatcher(dispatcher) {
|
|
@@ -373,9 +280,10 @@ var FederationBuilderImpl = class {
|
|
|
373
280
|
}
|
|
374
281
|
setObjectDispatcher(cls, path, dispatcher) {
|
|
375
282
|
const routeName = `object:${cls.typeId.href}`;
|
|
376
|
-
if (this.router.has(routeName)) throw new RouterError(`Object dispatcher for ${cls.name} already set.`);
|
|
377
|
-
|
|
378
|
-
|
|
283
|
+
if (this.router.has(routeName)) throw new _fedify_uri_template.RouterError(`Object dispatcher for ${cls.name} already set.`);
|
|
284
|
+
(0, _fedify_uri_template.assertPath)(path);
|
|
285
|
+
const variables = _fedify_uri_template.Router.variables(path);
|
|
286
|
+
this.router.add(path, routeName);
|
|
379
287
|
const callbacks = {
|
|
380
288
|
dispatcher: (ctx, values) => {
|
|
381
289
|
return this._getTracer().startActiveSpan("activitypub.dispatch_object", {
|
|
@@ -413,12 +321,12 @@ var FederationBuilderImpl = class {
|
|
|
413
321
|
return setters;
|
|
414
322
|
}
|
|
415
323
|
setInboxDispatcher(path, dispatcher) {
|
|
416
|
-
if (this.inboxCallbacks != null) throw new RouterError("Inbox dispatcher already set.");
|
|
324
|
+
if (this.inboxCallbacks != null) throw new _fedify_uri_template.RouterError("Inbox dispatcher already set.");
|
|
417
325
|
if (this.router.has("inbox")) {
|
|
418
|
-
if (this.inboxPath !== path) throw new RouterError("Inbox dispatcher path must match inbox listener path.");
|
|
326
|
+
if (this.inboxPath !== path) throw new _fedify_uri_template.RouterError("Inbox dispatcher path must match inbox listener path.");
|
|
419
327
|
} else {
|
|
420
|
-
|
|
421
|
-
|
|
328
|
+
(0, _fedify_uri_template.assertPath)(path);
|
|
329
|
+
this.router.add(path, "inbox", identifierSingularAllowPlus);
|
|
422
330
|
this.inboxPath = path;
|
|
423
331
|
}
|
|
424
332
|
const callbacks = { dispatcher };
|
|
@@ -444,12 +352,12 @@ var FederationBuilderImpl = class {
|
|
|
444
352
|
return setters;
|
|
445
353
|
}
|
|
446
354
|
setOutboxDispatcher(path, dispatcher) {
|
|
447
|
-
if (this.outboxCallbacks != null) throw new RouterError("Outbox dispatcher already set.");
|
|
355
|
+
if (this.outboxCallbacks != null) throw new _fedify_uri_template.RouterError("Outbox dispatcher already set.");
|
|
448
356
|
if (this.router.has("outbox")) {
|
|
449
|
-
if (this.outboxPath !== path) throw new RouterError("Outbox dispatcher path must match outbox listener path.");
|
|
357
|
+
if (this.outboxPath !== path) throw new _fedify_uri_template.RouterError("Outbox dispatcher path must match outbox listener path.");
|
|
450
358
|
} else {
|
|
451
|
-
|
|
452
|
-
this.router.add(path, "outbox");
|
|
359
|
+
(0, _fedify_uri_template.assertPath)(path);
|
|
360
|
+
this.router.add(path, "outbox", identifierSingular);
|
|
453
361
|
this.outboxPath = path;
|
|
454
362
|
}
|
|
455
363
|
const callbacks = { dispatcher };
|
|
@@ -475,12 +383,12 @@ var FederationBuilderImpl = class {
|
|
|
475
383
|
return setters;
|
|
476
384
|
}
|
|
477
385
|
setOutboxListeners(outboxPath) {
|
|
478
|
-
if (this.outboxListeners != null) throw new RouterError("Outbox listeners already set.");
|
|
386
|
+
if (this.outboxListeners != null) throw new _fedify_uri_template.RouterError("Outbox listeners already set.");
|
|
479
387
|
if (this.router.has("outbox")) {
|
|
480
|
-
if (this.outboxPath !== outboxPath) throw new RouterError("Outbox listener path must match outbox dispatcher path.");
|
|
388
|
+
if (this.outboxPath !== outboxPath) throw new _fedify_uri_template.RouterError("Outbox listener path must match outbox dispatcher path.");
|
|
481
389
|
} else {
|
|
482
|
-
|
|
483
|
-
this.router.add(outboxPath, "outbox");
|
|
390
|
+
(0, _fedify_uri_template.assertPath)(outboxPath);
|
|
391
|
+
this.router.add(outboxPath, "outbox", identifierSingular);
|
|
484
392
|
this.outboxPath = outboxPath;
|
|
485
393
|
}
|
|
486
394
|
const listeners = this.outboxListeners = new ActivityListenerSet();
|
|
@@ -501,9 +409,9 @@ var FederationBuilderImpl = class {
|
|
|
501
409
|
return setters;
|
|
502
410
|
}
|
|
503
411
|
setFollowingDispatcher(path, dispatcher) {
|
|
504
|
-
if (this.router.has("following")) throw new RouterError("Following collection dispatcher already set.");
|
|
505
|
-
|
|
506
|
-
|
|
412
|
+
if (this.router.has("following")) throw new _fedify_uri_template.RouterError("Following collection dispatcher already set.");
|
|
413
|
+
(0, _fedify_uri_template.assertPath)(path);
|
|
414
|
+
this.router.add(path, "following", identifierSingularAllowPlus);
|
|
507
415
|
const callbacks = { dispatcher };
|
|
508
416
|
this.followingCallbacks = callbacks;
|
|
509
417
|
const setters = {
|
|
@@ -527,9 +435,9 @@ var FederationBuilderImpl = class {
|
|
|
527
435
|
return setters;
|
|
528
436
|
}
|
|
529
437
|
setFollowersDispatcher(path, dispatcher) {
|
|
530
|
-
if (this.router.has("followers")) throw new RouterError("Followers collection dispatcher already set.");
|
|
531
|
-
|
|
532
|
-
|
|
438
|
+
if (this.router.has("followers")) throw new _fedify_uri_template.RouterError("Followers collection dispatcher already set.");
|
|
439
|
+
(0, _fedify_uri_template.assertPath)(path);
|
|
440
|
+
this.router.add(path, "followers", identifierSingularAllowPlus);
|
|
533
441
|
const callbacks = { dispatcher };
|
|
534
442
|
this.followersCallbacks = callbacks;
|
|
535
443
|
const setters = {
|
|
@@ -553,9 +461,9 @@ var FederationBuilderImpl = class {
|
|
|
553
461
|
return setters;
|
|
554
462
|
}
|
|
555
463
|
setLikedDispatcher(path, dispatcher) {
|
|
556
|
-
if (this.router.has("liked")) throw new RouterError("Liked collection dispatcher already set.");
|
|
557
|
-
|
|
558
|
-
|
|
464
|
+
if (this.router.has("liked")) throw new _fedify_uri_template.RouterError("Liked collection dispatcher already set.");
|
|
465
|
+
(0, _fedify_uri_template.assertPath)(path);
|
|
466
|
+
this.router.add(path, "liked", identifierSingularAllowPlus);
|
|
559
467
|
const callbacks = { dispatcher };
|
|
560
468
|
this.likedCallbacks = callbacks;
|
|
561
469
|
const setters = {
|
|
@@ -579,9 +487,9 @@ var FederationBuilderImpl = class {
|
|
|
579
487
|
return setters;
|
|
580
488
|
}
|
|
581
489
|
setFeaturedDispatcher(path, dispatcher) {
|
|
582
|
-
if (this.router.has("featured")) throw new RouterError("Featured collection dispatcher already set.");
|
|
583
|
-
|
|
584
|
-
|
|
490
|
+
if (this.router.has("featured")) throw new _fedify_uri_template.RouterError("Featured collection dispatcher already set.");
|
|
491
|
+
(0, _fedify_uri_template.assertPath)(path);
|
|
492
|
+
this.router.add(path, "featured", identifierSingularAllowPlus);
|
|
585
493
|
const callbacks = { dispatcher };
|
|
586
494
|
this.featuredCallbacks = callbacks;
|
|
587
495
|
const setters = {
|
|
@@ -605,9 +513,9 @@ var FederationBuilderImpl = class {
|
|
|
605
513
|
return setters;
|
|
606
514
|
}
|
|
607
515
|
setFeaturedTagsDispatcher(path, dispatcher) {
|
|
608
|
-
if (this.router.has("featuredTags")) throw new RouterError("Featured tags collection dispatcher already set.");
|
|
609
|
-
|
|
610
|
-
|
|
516
|
+
if (this.router.has("featuredTags")) throw new _fedify_uri_template.RouterError("Featured tags collection dispatcher already set.");
|
|
517
|
+
(0, _fedify_uri_template.assertPath)(path);
|
|
518
|
+
this.router.add(path, "featuredTags", identifierSingularAllowPlus);
|
|
611
519
|
const callbacks = { dispatcher };
|
|
612
520
|
this.featuredTagsCallbacks = callbacks;
|
|
613
521
|
const setters = {
|
|
@@ -631,16 +539,17 @@ var FederationBuilderImpl = class {
|
|
|
631
539
|
return setters;
|
|
632
540
|
}
|
|
633
541
|
setInboxListeners(inboxPath, sharedInboxPath) {
|
|
634
|
-
if (this.inboxListeners != null) throw new RouterError("Inbox listeners already set.");
|
|
542
|
+
if (this.inboxListeners != null) throw new _fedify_uri_template.RouterError("Inbox listeners already set.");
|
|
635
543
|
if (this.router.has("inbox")) {
|
|
636
|
-
if (this.inboxPath !== inboxPath) throw new RouterError("Inbox listener path must match inbox dispatcher path.");
|
|
544
|
+
if (this.inboxPath !== inboxPath) throw new _fedify_uri_template.RouterError("Inbox listener path must match inbox dispatcher path.");
|
|
637
545
|
} else {
|
|
638
|
-
|
|
639
|
-
|
|
546
|
+
(0, _fedify_uri_template.assertPath)(inboxPath);
|
|
547
|
+
this.router.add(inboxPath, "inbox", identifierSingularAllowPlus);
|
|
640
548
|
this.inboxPath = inboxPath;
|
|
641
549
|
}
|
|
642
550
|
if (sharedInboxPath != null) {
|
|
643
|
-
if (
|
|
551
|
+
if (_fedify_uri_template.Router.variables(sharedInboxPath).size !== 0) throw new _fedify_uri_template.RouterError("Path for shared inbox must have no variables.");
|
|
552
|
+
this.router.add(sharedInboxPath, "sharedInbox");
|
|
644
553
|
}
|
|
645
554
|
const listeners = this.inboxListeners = new ActivityListenerSet();
|
|
646
555
|
const setters = {
|
|
@@ -676,9 +585,11 @@ var FederationBuilderImpl = class {
|
|
|
676
585
|
#setCustomCollectionDispatcher(name, collectionType, itemType, path, dispatcher) {
|
|
677
586
|
const strName = String(name);
|
|
678
587
|
const routeName = `${collectionType}:${this.#uniqueCollectionId(name)}`;
|
|
679
|
-
if (this.router.has(routeName)) throw new RouterError(`Collection dispatcher for ${strName} already set.`);
|
|
680
|
-
if (this.collectionCallbacks[name] != null) throw new RouterError(`Collection dispatcher for ${strName} already set.`);
|
|
681
|
-
|
|
588
|
+
if (this.router.has(routeName)) throw new _fedify_uri_template.RouterError(`Collection dispatcher for ${strName} already set.`);
|
|
589
|
+
if (this.collectionCallbacks[name] != null) throw new _fedify_uri_template.RouterError(`Collection dispatcher for ${strName} already set.`);
|
|
590
|
+
(0, _fedify_uri_template.assertPath)(path);
|
|
591
|
+
if (_fedify_uri_template.Router.variables(path).size < 1) throw new _fedify_uri_template.RouterError("Path for collection dispatcher must have at least one variable.");
|
|
592
|
+
this.router.add(path, routeName);
|
|
682
593
|
const callbacks = { dispatcher };
|
|
683
594
|
this.collectionCallbacks[name] = callbacks;
|
|
684
595
|
this.collectionTypeIds[name] = itemType;
|
|
@@ -2424,7 +2335,7 @@ function handleNodeInfoJrd(_request, context) {
|
|
|
2424
2335
|
type: "application/json; profile=\"http://nodeinfo.diaspora.software/ns/schema/2.1#\""
|
|
2425
2336
|
});
|
|
2426
2337
|
} catch (e) {
|
|
2427
|
-
if (!(e instanceof RouterError)) throw e;
|
|
2338
|
+
if (!(e instanceof _fedify_uri_template.RouterError)) throw e;
|
|
2428
2339
|
}
|
|
2429
2340
|
const response = new Response(JSON.stringify({ links }), { headers: { "Content-Type": "application/jrd+json" } });
|
|
2430
2341
|
return Promise.resolve(response);
|
|
@@ -4034,65 +3945,65 @@ var ContextImpl = class ContextImpl {
|
|
|
4034
3945
|
}
|
|
4035
3946
|
getNodeInfoUri() {
|
|
4036
3947
|
const path = this.federation.router.build("nodeInfo", {});
|
|
4037
|
-
if (path == null) throw new RouterError("No NodeInfo dispatcher registered.");
|
|
3948
|
+
if (path == null) throw new _fedify_uri_template.RouterError("No NodeInfo dispatcher registered.");
|
|
4038
3949
|
return new URL(path, this.canonicalOrigin);
|
|
4039
3950
|
}
|
|
4040
3951
|
getActorUri(identifier) {
|
|
4041
3952
|
const path = this.federation.router.build(`actorAlias:${identifier}`, {}) ?? this.federation.router.build("actor", { identifier });
|
|
4042
|
-
if (path == null) throw new RouterError("No actor dispatcher registered.");
|
|
3953
|
+
if (path == null) throw new _fedify_uri_template.RouterError("No actor dispatcher registered.");
|
|
4043
3954
|
return new URL(path, this.canonicalOrigin);
|
|
4044
3955
|
}
|
|
4045
3956
|
getObjectUri(cls, values) {
|
|
4046
3957
|
const callbacks = this.federation.objectCallbacks[cls.typeId.href];
|
|
4047
|
-
if (callbacks == null) throw new RouterError("No object dispatcher registered.");
|
|
3958
|
+
if (callbacks == null) throw new _fedify_uri_template.RouterError("No object dispatcher registered.");
|
|
4048
3959
|
for (const param of callbacks.parameters) if (!(param in values)) throw new TypeError(`Missing parameter: ${param}`);
|
|
4049
3960
|
const path = this.federation.router.build(`object:${cls.typeId.href}`, values);
|
|
4050
|
-
if (path == null) throw new RouterError("No object dispatcher registered.");
|
|
3961
|
+
if (path == null) throw new _fedify_uri_template.RouterError("No object dispatcher registered.");
|
|
4051
3962
|
return new URL(path, this.canonicalOrigin);
|
|
4052
3963
|
}
|
|
4053
3964
|
getOutboxUri(identifier) {
|
|
4054
3965
|
const path = this.federation.router.build("outbox", { identifier });
|
|
4055
|
-
if (path == null) throw new RouterError("No outbox dispatcher registered.");
|
|
3966
|
+
if (path == null) throw new _fedify_uri_template.RouterError("No outbox dispatcher registered.");
|
|
4056
3967
|
return new URL(path, this.canonicalOrigin);
|
|
4057
3968
|
}
|
|
4058
3969
|
getInboxUri(identifier) {
|
|
4059
3970
|
if (identifier == null) {
|
|
4060
3971
|
const path = this.federation.router.build("sharedInbox", {});
|
|
4061
|
-
if (path == null) throw new RouterError("No shared inbox path registered.");
|
|
3972
|
+
if (path == null) throw new _fedify_uri_template.RouterError("No shared inbox path registered.");
|
|
4062
3973
|
return new URL(path, this.canonicalOrigin);
|
|
4063
3974
|
}
|
|
4064
3975
|
const path = this.federation.router.build("inbox", { identifier });
|
|
4065
|
-
if (path == null) throw new RouterError("No inbox path registered.");
|
|
3976
|
+
if (path == null) throw new _fedify_uri_template.RouterError("No inbox path registered.");
|
|
4066
3977
|
return new URL(path, this.canonicalOrigin);
|
|
4067
3978
|
}
|
|
4068
3979
|
getFollowingUri(identifier) {
|
|
4069
3980
|
const path = this.federation.router.build("following", { identifier });
|
|
4070
|
-
if (path == null) throw new RouterError("No following collection path registered.");
|
|
3981
|
+
if (path == null) throw new _fedify_uri_template.RouterError("No following collection path registered.");
|
|
4071
3982
|
return new URL(path, this.canonicalOrigin);
|
|
4072
3983
|
}
|
|
4073
3984
|
getFollowersUri(identifier) {
|
|
4074
3985
|
const path = this.federation.router.build("followers", { identifier });
|
|
4075
|
-
if (path == null) throw new RouterError("No followers collection path registered.");
|
|
3986
|
+
if (path == null) throw new _fedify_uri_template.RouterError("No followers collection path registered.");
|
|
4076
3987
|
return new URL(path, this.canonicalOrigin);
|
|
4077
3988
|
}
|
|
4078
3989
|
getLikedUri(identifier) {
|
|
4079
3990
|
const path = this.federation.router.build("liked", { identifier });
|
|
4080
|
-
if (path == null) throw new RouterError("No liked collection path registered.");
|
|
3991
|
+
if (path == null) throw new _fedify_uri_template.RouterError("No liked collection path registered.");
|
|
4081
3992
|
return new URL(path, this.canonicalOrigin);
|
|
4082
3993
|
}
|
|
4083
3994
|
getFeaturedUri(identifier) {
|
|
4084
3995
|
const path = this.federation.router.build("featured", { identifier });
|
|
4085
|
-
if (path == null) throw new RouterError("No featured collection path registered.");
|
|
3996
|
+
if (path == null) throw new _fedify_uri_template.RouterError("No featured collection path registered.");
|
|
4086
3997
|
return new URL(path, this.canonicalOrigin);
|
|
4087
3998
|
}
|
|
4088
3999
|
getFeaturedTagsUri(identifier) {
|
|
4089
4000
|
const path = this.federation.router.build("featuredTags", { identifier });
|
|
4090
|
-
if (path == null) throw new RouterError("No featured tags collection path registered.");
|
|
4001
|
+
if (path == null) throw new _fedify_uri_template.RouterError("No featured tags collection path registered.");
|
|
4091
4002
|
return new URL(path, this.canonicalOrigin);
|
|
4092
4003
|
}
|
|
4093
4004
|
getCollectionUri(name, values) {
|
|
4094
4005
|
const path = this.federation.getCollectionPath(name, values);
|
|
4095
|
-
if (path === null) throw new RouterError(`No collection dispatcher registered for "${String(name)}".`);
|
|
4006
|
+
if (path === null) throw new _fedify_uri_template.RouterError(`No collection dispatcher registered for "${String(name)}".`);
|
|
4096
4007
|
return new URL(path, this.canonicalOrigin);
|
|
4097
4008
|
}
|
|
4098
4009
|
parseUri(uri) {
|
|
@@ -4210,7 +4121,7 @@ var ContextImpl = class ContextImpl {
|
|
|
4210
4121
|
try {
|
|
4211
4122
|
actorUri = this.getActorUri(identifier);
|
|
4212
4123
|
} catch (error) {
|
|
4213
|
-
if (error instanceof RouterError) {
|
|
4124
|
+
if (error instanceof _fedify_uri_template.RouterError) {
|
|
4214
4125
|
logger.warn(error.message);
|
|
4215
4126
|
return [];
|
|
4216
4127
|
}
|
|
@@ -4370,7 +4281,7 @@ var ContextImpl = class ContextImpl {
|
|
|
4370
4281
|
if (options.syncCollection) try {
|
|
4371
4282
|
collectionSync = this.getFollowersUri(identifier).href;
|
|
4372
4283
|
} catch (error) {
|
|
4373
|
-
if (!(error instanceof RouterError)) throw error;
|
|
4284
|
+
if (!(error instanceof _fedify_uri_template.RouterError)) throw error;
|
|
4374
4285
|
}
|
|
4375
4286
|
} else expandedRecipients = [recipients];
|
|
4376
4287
|
const opts = {
|
|
@@ -5002,18 +4913,6 @@ function getRequestId(request) {
|
|
|
5002
4913
|
return `req_${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;
|
|
5003
4914
|
}
|
|
5004
4915
|
//#endregion
|
|
5005
|
-
Object.defineProperty(exports, "Router", {
|
|
5006
|
-
enumerable: true,
|
|
5007
|
-
get: function() {
|
|
5008
|
-
return Router;
|
|
5009
|
-
}
|
|
5010
|
-
});
|
|
5011
|
-
Object.defineProperty(exports, "RouterError", {
|
|
5012
|
-
enumerable: true,
|
|
5013
|
-
get: function() {
|
|
5014
|
-
return RouterError;
|
|
5015
|
-
}
|
|
5016
|
-
});
|
|
5017
4916
|
Object.defineProperty(exports, "SendActivityError", {
|
|
5018
4917
|
enumerable: true,
|
|
5019
4918
|
get: function() {
|