@fedify/fedify 2.3.0-dev.1119 → 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-Ond_h57y.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-cSUMk2da.d.ts → context-DCtsSHDv.d.ts} +4 -293
- package/dist/{context-Ch-ZLyTQ.d.cts → context-DI2gRbyN.d.cts} +3 -294
- package/dist/{context-BAE7AKLA.mjs → context-DVoTs_wM.mjs} +1 -1
- package/dist/{deno-DVsHS7rA.mjs → deno-B_9yJW3w.mjs} +1 -1
- package/dist/{docloader-WsWfKaE5.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 +231 -3
- package/dist/federation/middleware.test.mjs +88 -18
- package/dist/federation/mod.cjs +155 -3
- package/dist/federation/mod.d.cts +3 -2
- package/dist/federation/mod.d.ts +3 -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-CouJSFVK.js → http-CToqG5ap.js} +252 -20
- package/dist/{http-CubOB9wq.cjs → http-CWoeyogl.cjs} +263 -19
- package/dist/{http-DUV8ysti.mjs → http-Cyx5SNuu.mjs} +8 -6
- package/dist/{http-D6LP89UO.d.ts → http-VyDTd4G3.d.cts} +8 -1
- package/dist/{http-D6aw3j2U.d.cts → http-lf8Hsd91.d.ts} +8 -1
- package/dist/{key-BoWaYRHm.mjs → key-CkkMJBjF.mjs} +42 -17
- package/dist/{kv-cache-DBNpsneh.js → kv-cache-CuCn2xvM.js} +19 -2
- package/dist/{kv-cache-Dz31ATUT.cjs → kv-cache-DuEwFYcN.cjs} +19 -2
- package/dist/{kv-cache-DihufyAQ.mjs → kv-cache-VHFP42vY.mjs} +19 -1
- package/dist/{ld-B5K1mSuG.mjs → ld-k8yqD2a-.mjs} +3 -3
- package/dist/{metrics-C4attqv0.mjs → metrics-iRBg8jTk.mjs} +209 -2
- package/dist/{middleware-CmsDtIHI.cjs → middleware-BWLUrbS9.cjs} +137 -210
- package/dist/{middleware-BDKFRjue.mjs → middleware-CztxpARM.mjs} +1 -1
- package/dist/{middleware-Dtjz-hSk.js → middleware-D7FrhN9q.js} +101 -162
- package/dist/{middleware-t0jC8I99.mjs → middleware-DQEgdr83.mjs} +64 -36
- package/dist/{mod-BDhgfjP7.d.cts → mod-B0hW12_O.d.cts} +1 -1
- package/dist/mod-C504qevA.d.cts +173 -0
- package/dist/{mod-B-Lin9Sy.d.ts → mod-COIAjwRS.d.ts} +1 -1
- package/dist/{mod-DLrRb0dx.d.ts → mod-DFvNJcNb.d.ts} +54 -3
- package/dist/mod-wYfuXeDE.d.ts +173 -0
- package/dist/{mod-BR_BB0bh.d.cts → mod-yvIXFAEi.d.cts} +54 -3
- package/dist/mod.cjs +6 -6
- package/dist/mod.d.cts +6 -5
- package/dist/mod.d.ts +6 -5
- package/dist/mod.js +5 -5
- package/dist/mq-D-nlpY04.d.ts +208 -0
- package/dist/mq-D8uSFzxe.d.cts +208 -0
- 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-hDxI0ufu.mjs → owner-nmXdvXpc.mjs} +2 -2
- package/dist/{proof-BUWfVr6Q.cjs → proof-CcsIJLTn.cjs} +1 -1
- package/dist/{proof-DhVuz4bc.mjs → proof-DpwO1T4S.mjs} +5 -5
- package/dist/{proof-n60t8o9P.js → proof-NRmtrTDu.js} +1 -1
- package/dist/{send-BPhyR5Oo.mjs → send-DvX2tYyZ.mjs} +3 -3
- package/dist/sig/accept.test.mjs +1 -1
- package/dist/sig/http.test.mjs +13 -9
- package/dist/sig/key.test.mjs +104 -7
- package/dist/sig/ld.test.mjs +7 -7
- package/dist/sig/mod.cjs +2 -2
- package/dist/sig/mod.d.cts +2 -2
- package/dist/sig/mod.d.ts +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 +67 -2
- package/dist/utils/mod.cjs +1 -1
- package/dist/utils/mod.d.cts +1 -1
- package/dist/utils/mod.d.ts +1 -1
- package/dist/utils/mod.js +1 -1
- package/package.json +6 -7
- package/dist/mod-C6E8rkcz.d.ts +0 -63
- package/dist/mod-P9tE2WmM.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
|
@@ -1,16 +1,167 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import "../
|
|
7
|
-
import {
|
|
8
|
-
import { t as
|
|
9
|
-
import {
|
|
4
|
+
import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
5
|
+
import "../std__assert-BBjXFNOb.mjs";
|
|
6
|
+
import { r as assertFalse } from "../assert_rejects-DN60FHPX.mjs";
|
|
7
|
+
import { t as assertThrows } from "../assert_throws-BOkhLGYc.mjs";
|
|
8
|
+
import { t as assert } from "../assert-OguE97r2.mjs";
|
|
9
|
+
import { getLogger } from "@logtape/logtape";
|
|
10
|
+
import { Router, RouterError, assertPath, isPath } from "@fedify/uri-template";
|
|
10
11
|
import { test } from "@fedify/fixture";
|
|
12
|
+
//#region src/federation/router.ts
|
|
13
|
+
const logger = getLogger([
|
|
14
|
+
"fedify",
|
|
15
|
+
"federation",
|
|
16
|
+
"router",
|
|
17
|
+
"deprecated"
|
|
18
|
+
]);
|
|
19
|
+
let deprecationWarned = false;
|
|
20
|
+
function warnDeprecated() {
|
|
21
|
+
if (deprecationWarned) return;
|
|
22
|
+
deprecationWarned = true;
|
|
23
|
+
logger.warn("The `Router` and `RouterError` classes from `@fedify/fedify` are deprecated. Please use `Router` from `@fedify/uri-template` instead.");
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* URL router and constructor based on URI Template
|
|
27
|
+
* ([RFC 6570](https://tools.ietf.org/html/rfc6570)).
|
|
28
|
+
*
|
|
29
|
+
* @deprecated Import `Router` from `@fedify/uri-template` instead. This class
|
|
30
|
+
* remains only for compatibility with older Fedify code. The
|
|
31
|
+
* `@fedify/uri-template` router is the replacement implementation
|
|
32
|
+
* and should be used directly in new code.
|
|
33
|
+
*/
|
|
34
|
+
var Router$1 = class Router$1 {
|
|
35
|
+
#router;
|
|
36
|
+
/**
|
|
37
|
+
* Create a new {@link Router}.
|
|
38
|
+
* @param options Options for the router.
|
|
39
|
+
* @deprecated Use `new Router(options)` from `@fedify/uri-template`
|
|
40
|
+
* instead.
|
|
41
|
+
*/
|
|
42
|
+
constructor(options) {
|
|
43
|
+
this.#router = convertRouterError(() => new Router(options));
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Whether to ignore trailing slashes when matching paths.
|
|
47
|
+
* @deprecated Use `Router` from `@fedify/uri-template` instead. This
|
|
48
|
+
* accessor forwards to the underlying `@fedify/uri-template`
|
|
49
|
+
* router so that post-construction mutation keeps working as
|
|
50
|
+
* in older Fedify code.
|
|
51
|
+
*/
|
|
52
|
+
get trailingSlashInsensitive() {
|
|
53
|
+
return this.#router.trailingSlashInsensitive;
|
|
54
|
+
}
|
|
55
|
+
set trailingSlashInsensitive(value) {
|
|
56
|
+
this.#router.trailingSlashInsensitive = value;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Clones this router.
|
|
60
|
+
* @deprecated Use `Router` from `@fedify/uri-template` instead.
|
|
61
|
+
*/
|
|
62
|
+
clone() {
|
|
63
|
+
return convertRouterError(() => {
|
|
64
|
+
const clone = new Router$1();
|
|
65
|
+
clone.#router = this.#router.clone();
|
|
66
|
+
return clone;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Checks if a path name exists in the router.
|
|
71
|
+
* @param name The name of the path.
|
|
72
|
+
* @returns `true` if the path name exists, otherwise `false`.
|
|
73
|
+
* @deprecated Use `Router` from `@fedify/uri-template` instead.
|
|
74
|
+
*/
|
|
75
|
+
has(name) {
|
|
76
|
+
return convertRouterError(() => this.#router.has(name));
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Adds a new path rule to the router.
|
|
80
|
+
* @param template The path pattern.
|
|
81
|
+
* @param name The name of the path.
|
|
82
|
+
* @returns The names of the variables in the path pattern.
|
|
83
|
+
* @deprecated Use `Router` from `@fedify/uri-template` instead. In this
|
|
84
|
+
* compatibility class, `add()` both registers the route and
|
|
85
|
+
* returns the variables in the path pattern. In
|
|
86
|
+
* `@fedify/uri-template`, these two responsibilities are split:
|
|
87
|
+
* `router.add(template, name)` registers the route and returns
|
|
88
|
+
* `void`, while the pure static method
|
|
89
|
+
* `Router.variables(template)` returns the variable names. To
|
|
90
|
+
* migrate, call `Router.variables(template)` when variables are
|
|
91
|
+
* needed, then call `router.add(template, name)` to register the
|
|
92
|
+
* route.
|
|
93
|
+
*/
|
|
94
|
+
add(template, name) {
|
|
95
|
+
return convertRouterError(() => {
|
|
96
|
+
assertPath(template);
|
|
97
|
+
this.#router.add(template, name);
|
|
98
|
+
return Router.variables(template);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Resolves a path name and values from a URL, if any match.
|
|
103
|
+
* @param url The URL to resolve.
|
|
104
|
+
* @returns The name of the path and its values, if any match. Otherwise,
|
|
105
|
+
* `null`.
|
|
106
|
+
* @deprecated Use `Router` from `@fedify/uri-template` instead. Unlike the
|
|
107
|
+
* stricter `@fedify/uri-template` router, this compatibility
|
|
108
|
+
* method keeps the old Fedify 2.x contract of returning `null`
|
|
109
|
+
* (rather than throwing) for inputs that are not router paths.
|
|
110
|
+
*/
|
|
111
|
+
route(url) {
|
|
112
|
+
return convertRouterError(() => {
|
|
113
|
+
if (!isPath(url)) return null;
|
|
114
|
+
return this.#router.route(url);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Constructs a URL/path from a path name and values.
|
|
119
|
+
* @param name The name of the path.
|
|
120
|
+
* @param values The values to expand the path with.
|
|
121
|
+
* @returns The URL/path, if the name exists. Otherwise, `null`.
|
|
122
|
+
* @deprecated Use `Router` from `@fedify/uri-template` instead.
|
|
123
|
+
*/
|
|
124
|
+
build(name, values) {
|
|
125
|
+
return convertRouterError(() => this.#router.build(name, values));
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* An error thrown by the {@link Router}.
|
|
130
|
+
* @deprecated Import `RouterError` from `@fedify/uri-template` instead.
|
|
131
|
+
*/
|
|
132
|
+
var RouterError$1 = class extends RouterError {
|
|
133
|
+
/**
|
|
134
|
+
* Treats every `RouterError` from `@fedify/uri-template` as an instance of
|
|
135
|
+
* this deprecated class.
|
|
136
|
+
*
|
|
137
|
+
* @deprecated Import `RouterError` from `@fedify/uri-template` instead.
|
|
138
|
+
*/
|
|
139
|
+
static [Symbol.hasInstance](instance) {
|
|
140
|
+
return instance instanceof RouterError;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Create a new {@link RouterError}.
|
|
144
|
+
* @param message The error message.
|
|
145
|
+
* @deprecated Import `RouterError` from `@fedify/uri-template` instead.
|
|
146
|
+
*/
|
|
147
|
+
constructor(message) {
|
|
148
|
+
super(message);
|
|
149
|
+
warnDeprecated();
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
function convertRouterError(func) {
|
|
153
|
+
try {
|
|
154
|
+
warnDeprecated();
|
|
155
|
+
return func();
|
|
156
|
+
} catch (error) {
|
|
157
|
+
if (error instanceof RouterError) throw new RouterError$1(error.message);
|
|
158
|
+
throw error;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
//#endregion
|
|
11
162
|
//#region src/federation/router.test.ts
|
|
12
163
|
function setUp(options = {}) {
|
|
13
|
-
const router = new Router(options);
|
|
164
|
+
const router = new Router$1(options);
|
|
14
165
|
router.add("/users/{name}", "user");
|
|
15
166
|
router.add("/users/{name}/posts/{postId}" + (options.trailingSlashInsensitive ? "/" : ""), "post");
|
|
16
167
|
return router;
|
|
@@ -29,11 +180,11 @@ test("Router.clone()", () => {
|
|
|
29
180
|
assertEquals(original.route("/users/alice/friends"), null);
|
|
30
181
|
});
|
|
31
182
|
test("Router.add()", () => {
|
|
32
|
-
const router = new Router();
|
|
183
|
+
const router = new Router$1();
|
|
33
184
|
assertEquals(router.add("/users", "users"), /* @__PURE__ */ new Set());
|
|
34
185
|
assertEquals(router.add("/users/{name}", "user"), new Set(["name"]));
|
|
35
186
|
assertEquals(router.add("/users/{name}/posts/{postId}", "post"), new Set(["name", "postId"]));
|
|
36
|
-
assertThrows(() => router.add("foo", "name"), RouterError);
|
|
187
|
+
assertThrows(() => router.add("foo", "name"), RouterError$1);
|
|
37
188
|
});
|
|
38
189
|
test("Router.route()", () => {
|
|
39
190
|
let router = setUp();
|
|
@@ -80,6 +231,21 @@ test("Router.route()", () => {
|
|
|
80
231
|
}
|
|
81
232
|
});
|
|
82
233
|
});
|
|
234
|
+
test("Router.trailingSlashInsensitive (post-construction mutation)", () => {
|
|
235
|
+
const router = setUp();
|
|
236
|
+
assertFalse(router.trailingSlashInsensitive);
|
|
237
|
+
assertEquals(router.route("/users/bob/"), null);
|
|
238
|
+
router.trailingSlashInsensitive = true;
|
|
239
|
+
assert(router.trailingSlashInsensitive);
|
|
240
|
+
assertEquals(router.route("/users/bob/"), {
|
|
241
|
+
name: "user",
|
|
242
|
+
template: "/users/{name}",
|
|
243
|
+
values: { name: "bob" }
|
|
244
|
+
});
|
|
245
|
+
router.trailingSlashInsensitive = false;
|
|
246
|
+
assertFalse(router.trailingSlashInsensitive);
|
|
247
|
+
assertEquals(router.route("/users/bob/"), null);
|
|
248
|
+
});
|
|
83
249
|
test("Router.build()", () => {
|
|
84
250
|
const router = setUp();
|
|
85
251
|
assertEquals(router.build("user", { name: "alice" }), "/users/alice");
|
|
@@ -88,5 +254,20 @@ test("Router.build()", () => {
|
|
|
88
254
|
postId: "123"
|
|
89
255
|
}), "/users/alice/posts/123");
|
|
90
256
|
});
|
|
257
|
+
test("Router.route() returns null for non-path inputs", () => {
|
|
258
|
+
const router = setUp();
|
|
259
|
+
assertEquals(router.route("https://example.com/users/alice"), null);
|
|
260
|
+
assertEquals(router.route("users/alice"), null);
|
|
261
|
+
assertEquals(router.route("not a path"), null);
|
|
262
|
+
assertEquals(router.route("/unknown"), null);
|
|
263
|
+
});
|
|
264
|
+
test("Compatibility between RouterErrors", () => {
|
|
265
|
+
const newError = new RouterError("boom");
|
|
266
|
+
assert(newError instanceof RouterError);
|
|
267
|
+
assert(newError instanceof RouterError$1);
|
|
268
|
+
const previousError = new RouterError$1("boom");
|
|
269
|
+
assert(previousError instanceof RouterError$1);
|
|
270
|
+
assert(previousError instanceof RouterError);
|
|
271
|
+
});
|
|
91
272
|
//#endregion
|
|
92
273
|
export {};
|
|
@@ -2,17 +2,17 @@ import "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { n as __require, r as __toESM, t as __commonJSMin } from "../chunk-DNRtMIoB.mjs";
|
|
5
|
-
import { t as assertEquals } from "../assert_equals-
|
|
6
|
-
import "../std__assert-
|
|
7
|
-
import { n as assertGreaterOrEqual, r as assertFalse, t as assertRejects } from "../assert_rejects-
|
|
8
|
-
import { t as assertInstanceOf } from "../assert_instance_of-
|
|
9
|
-
import { t as assertNotEquals } from "../assert_not_equals
|
|
10
|
-
import { t as assert } from "../assert-
|
|
11
|
-
import { t as esm_default } from "../esm-
|
|
12
|
-
import { l as verifyRequest } from "../http-
|
|
13
|
-
import { i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-
|
|
14
|
-
import { t as doesActorOwnKey } from "../owner-
|
|
15
|
-
import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "../send-
|
|
5
|
+
import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
6
|
+
import "../std__assert-BBjXFNOb.mjs";
|
|
7
|
+
import { n as assertGreaterOrEqual, r as assertFalse, t as assertRejects } from "../assert_rejects-DN60FHPX.mjs";
|
|
8
|
+
import { t as assertInstanceOf } from "../assert_instance_of-DBC5X09g.mjs";
|
|
9
|
+
import { t as assertNotEquals } from "../assert_not_equals-DkVK8oqV.mjs";
|
|
10
|
+
import { t as assert } from "../assert-OguE97r2.mjs";
|
|
11
|
+
import { t as esm_default } from "../esm-BQRw925N.mjs";
|
|
12
|
+
import { l as verifyRequest } from "../http-Cyx5SNuu.mjs";
|
|
13
|
+
import { i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-C3kae-6B.mjs";
|
|
14
|
+
import { t as doesActorOwnKey } from "../owner-nmXdvXpc.mjs";
|
|
15
|
+
import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "../send-DvX2tYyZ.mjs";
|
|
16
16
|
import { Activity, Application, Endpoints, Group, Person, Service } from "@fedify/vocab";
|
|
17
17
|
import { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
18
18
|
//#region ../../node_modules/.pnpm/@opentelemetry+sdk-metrics@2.7.1_@opentelemetry+api@1.9.1/node_modules/@opentelemetry/sdk-metrics/build/src/export/AggregationTemporality.js
|
|
@@ -2525,19 +2525,19 @@ var require_getMachineId = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
2525
2525
|
async function getMachineId() {
|
|
2526
2526
|
if (!getMachineIdImpl) switch (process$1.platform) {
|
|
2527
2527
|
case "darwin":
|
|
2528
|
-
getMachineIdImpl = (await import("../getMachineId-darwin-
|
|
2528
|
+
getMachineIdImpl = (await import("../getMachineId-darwin-D23zTf4g.mjs").then((m) => /* @__PURE__ */ __toESM(m.default))).getMachineId;
|
|
2529
2529
|
break;
|
|
2530
2530
|
case "linux":
|
|
2531
|
-
getMachineIdImpl = (await import("../getMachineId-linux-
|
|
2531
|
+
getMachineIdImpl = (await import("../getMachineId-linux-ObI47Hql.mjs").then((m) => /* @__PURE__ */ __toESM(m.default))).getMachineId;
|
|
2532
2532
|
break;
|
|
2533
2533
|
case "freebsd":
|
|
2534
|
-
getMachineIdImpl = (await import("../getMachineId-bsd-
|
|
2534
|
+
getMachineIdImpl = (await import("../getMachineId-bsd-etIyxDet.mjs").then((m) => /* @__PURE__ */ __toESM(m.default))).getMachineId;
|
|
2535
2535
|
break;
|
|
2536
2536
|
case "win32":
|
|
2537
|
-
getMachineIdImpl = (await import("../getMachineId-win-
|
|
2537
|
+
getMachineIdImpl = (await import("../getMachineId-win-Dpap6v5i.mjs").then((m) => /* @__PURE__ */ __toESM(m.default))).getMachineId;
|
|
2538
2538
|
break;
|
|
2539
2539
|
default:
|
|
2540
|
-
getMachineIdImpl = (await import("../getMachineId-unsupported-
|
|
2540
|
+
getMachineIdImpl = (await import("../getMachineId-unsupported-Ddu-PFeh.mjs").then((m) => /* @__PURE__ */ __toESM(m.default))).getMachineId;
|
|
2541
2541
|
break;
|
|
2542
2542
|
}
|
|
2543
2543
|
return getMachineIdImpl();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { r as createRequestContext } from "../context-
|
|
5
|
-
import { t as assertEquals } from "../assert_equals-
|
|
6
|
-
import "../std__assert-
|
|
7
|
-
import { t as MemoryKvStore } from "../kv-
|
|
8
|
-
import { o as createFederation, s as handleWebFinger } from "../middleware-
|
|
4
|
+
import { r as createRequestContext } from "../context-DVoTs_wM.mjs";
|
|
5
|
+
import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
6
|
+
import "../std__assert-BBjXFNOb.mjs";
|
|
7
|
+
import { t as MemoryKvStore } from "../kv-x2IvBUyq.mjs";
|
|
8
|
+
import { o as createFederation, s as handleWebFinger } from "../middleware-DQEgdr83.mjs";
|
|
9
9
|
import { Image, Link, Person, Tombstone } from "@fedify/vocab";
|
|
10
10
|
import { test } from "@fedify/fixture";
|
|
11
11
|
//#region src/federation/webfinger.test.ts
|
|
@@ -2,7 +2,7 @@ import "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { n as __require, t as __commonJSMin } from "./chunk-DNRtMIoB.mjs";
|
|
5
|
-
import { t as require_execAsync } from "./execAsync-
|
|
5
|
+
import { t as require_execAsync } from "./execAsync-DCBrgFiV.mjs";
|
|
6
6
|
//#region ../../node_modules/.pnpm/@opentelemetry+resources@2.7.1_@opentelemetry+api@1.9.1/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId-bsd.js
|
|
7
7
|
var require_getMachineId_bsd = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -2,7 +2,7 @@ import "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { n as __require, t as __commonJSMin } from "./chunk-DNRtMIoB.mjs";
|
|
5
|
-
import { t as require_execAsync } from "./execAsync-
|
|
5
|
+
import { t as require_execAsync } from "./execAsync-DCBrgFiV.mjs";
|
|
6
6
|
//#region ../../node_modules/.pnpm/@opentelemetry+resources@2.7.1_@opentelemetry+api@1.9.1/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId-darwin.js
|
|
7
7
|
var require_getMachineId_darwin = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -2,7 +2,7 @@ import "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { n as __require, t as __commonJSMin } from "./chunk-DNRtMIoB.mjs";
|
|
5
|
-
import { t as require_execAsync } from "./execAsync-
|
|
5
|
+
import { t as require_execAsync } from "./execAsync-DCBrgFiV.mjs";
|
|
6
6
|
//#region ../../node_modules/.pnpm/@opentelemetry+resources@2.7.1_@opentelemetry+api@1.9.1/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId-win.js
|
|
7
7
|
var require_getMachineId_win = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -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.3.0-dev.
|
|
13
|
+
var version = "2.3.0-dev.1137+53a1f26d";
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/sig/accept.ts
|
|
16
16
|
/**
|
|
@@ -171,6 +171,11 @@ var FederationMetrics = class {
|
|
|
171
171
|
fanoutRecipients;
|
|
172
172
|
inboxActivity;
|
|
173
173
|
outboxActivity;
|
|
174
|
+
keyLookup;
|
|
175
|
+
keyLookupDuration;
|
|
176
|
+
documentFetch;
|
|
177
|
+
documentFetchDuration;
|
|
178
|
+
documentCache;
|
|
174
179
|
constructor(meterProvider) {
|
|
175
180
|
const meter = meterProvider.getMeter(name, version);
|
|
176
181
|
this.deliverySent = meter.createCounter("activitypub.delivery.sent", {
|
|
@@ -277,6 +282,58 @@ var FederationMetrics = class {
|
|
|
277
282
|
description: "ActivityPub activities observed at the outbox lifecycle level: queued, retried, or abandoned. Per-recipient delivery counters live on `activitypub.delivery.*`.",
|
|
278
283
|
unit: "{activity}"
|
|
279
284
|
});
|
|
285
|
+
this.keyLookup = meter.createCounter("activitypub.key.lookup", {
|
|
286
|
+
description: "Public-key lookup attempts performed by Fedify, including both cache hits and remote fetches.",
|
|
287
|
+
unit: "{lookup}"
|
|
288
|
+
});
|
|
289
|
+
this.keyLookupDuration = meter.createHistogram("activitypub.key.lookup.duration", {
|
|
290
|
+
description: "Duration of public-key lookups performed by Fedify, including any remote fetch.",
|
|
291
|
+
unit: "ms",
|
|
292
|
+
advice: { explicitBucketBoundaries: [
|
|
293
|
+
5,
|
|
294
|
+
10,
|
|
295
|
+
25,
|
|
296
|
+
50,
|
|
297
|
+
75,
|
|
298
|
+
100,
|
|
299
|
+
250,
|
|
300
|
+
500,
|
|
301
|
+
750,
|
|
302
|
+
1e3,
|
|
303
|
+
2500,
|
|
304
|
+
5e3,
|
|
305
|
+
7500,
|
|
306
|
+
1e4
|
|
307
|
+
] }
|
|
308
|
+
});
|
|
309
|
+
this.documentFetch = meter.createCounter("activitypub.document.fetch", {
|
|
310
|
+
description: "Remote JSON-LD document loader invocations made by Fedify-wrapped loaders.",
|
|
311
|
+
unit: "{fetch}"
|
|
312
|
+
});
|
|
313
|
+
this.documentFetchDuration = meter.createHistogram("activitypub.document.fetch.duration", {
|
|
314
|
+
description: "Duration of remote JSON-LD document loader invocations made by Fedify-wrapped loaders.",
|
|
315
|
+
unit: "ms",
|
|
316
|
+
advice: { explicitBucketBoundaries: [
|
|
317
|
+
5,
|
|
318
|
+
10,
|
|
319
|
+
25,
|
|
320
|
+
50,
|
|
321
|
+
75,
|
|
322
|
+
100,
|
|
323
|
+
250,
|
|
324
|
+
500,
|
|
325
|
+
750,
|
|
326
|
+
1e3,
|
|
327
|
+
2500,
|
|
328
|
+
5e3,
|
|
329
|
+
7500,
|
|
330
|
+
1e4
|
|
331
|
+
] }
|
|
332
|
+
});
|
|
333
|
+
this.documentCache = meter.createCounter("activitypub.document.cache", {
|
|
334
|
+
description: "KV-backed document loader cache lookups, with `hit` or `miss` classification.",
|
|
335
|
+
unit: "{lookup}"
|
|
336
|
+
});
|
|
280
337
|
}
|
|
281
338
|
recordDelivery(inbox, durationMs, success, activityType) {
|
|
282
339
|
const deliveryAttributes = {
|
|
@@ -360,6 +417,36 @@ var FederationMetrics = class {
|
|
|
360
417
|
recordOutboxActivity(result, activityType) {
|
|
361
418
|
this.outboxActivity.add(1, buildActivityLifecycleAttributes(result, activityType));
|
|
362
419
|
}
|
|
420
|
+
recordKeyLookup(attrs) {
|
|
421
|
+
const attributes = {
|
|
422
|
+
"activitypub.lookup.kind": "public_key",
|
|
423
|
+
"activitypub.lookup.result": attrs.result,
|
|
424
|
+
"activitypub.cache.enabled": attrs.cacheEnabled
|
|
425
|
+
};
|
|
426
|
+
if (attrs.remoteUrl != null) attributes["activitypub.remote.host"] = getRemoteHost(attrs.remoteUrl);
|
|
427
|
+
if (attrs.statusCode != null) attributes["http.response.status_code"] = attrs.statusCode;
|
|
428
|
+
this.keyLookup.add(1, attributes);
|
|
429
|
+
this.keyLookupDuration.record(attrs.durationMs, attributes);
|
|
430
|
+
}
|
|
431
|
+
recordDocumentFetch(attrs) {
|
|
432
|
+
const attributes = {
|
|
433
|
+
"activitypub.lookup.kind": attrs.kind,
|
|
434
|
+
"activitypub.lookup.result": attrs.result
|
|
435
|
+
};
|
|
436
|
+
if (attrs.remoteUrl != null) attributes["activitypub.remote.host"] = getRemoteHost(attrs.remoteUrl);
|
|
437
|
+
if (attrs.cacheEnabled != null) attributes["activitypub.cache.enabled"] = attrs.cacheEnabled;
|
|
438
|
+
if (attrs.statusCode != null) attributes["http.response.status_code"] = attrs.statusCode;
|
|
439
|
+
this.documentFetch.add(1, attributes);
|
|
440
|
+
this.documentFetchDuration.record(attrs.durationMs, attributes);
|
|
441
|
+
}
|
|
442
|
+
recordDocumentCache(attrs) {
|
|
443
|
+
const attributes = {
|
|
444
|
+
"activitypub.lookup.kind": attrs.kind,
|
|
445
|
+
"activitypub.lookup.result": attrs.result
|
|
446
|
+
};
|
|
447
|
+
if (attrs.remoteUrl != null) attributes["activitypub.remote.host"] = getRemoteHost(attrs.remoteUrl);
|
|
448
|
+
this.documentCache.add(1, attributes);
|
|
449
|
+
}
|
|
363
450
|
};
|
|
364
451
|
function buildActivityLifecycleAttributes(result, activityType) {
|
|
365
452
|
const attributes = { "activitypub.processing.result": result };
|
|
@@ -448,6 +535,125 @@ function recordOutboxActivity(meterProvider, result, activityType) {
|
|
|
448
535
|
getFederationMetrics(meterProvider).recordOutboxActivity(result, activityType);
|
|
449
536
|
}
|
|
450
537
|
/**
|
|
538
|
+
* Records one measurement on `activitypub.key.lookup` (counter) and
|
|
539
|
+
* `activitypub.key.lookup.duration` (histogram) for a public-key lookup.
|
|
540
|
+
*
|
|
541
|
+
* `activitypub.lookup.kind` is always recorded as `public_key`; the result
|
|
542
|
+
* classification, remote host, HTTP status code (when an HTTP response was
|
|
543
|
+
* received), and `activitypub.cache.enabled` are recorded as attributes on
|
|
544
|
+
* both measurements. Full key URLs and key IDs are deliberately omitted to
|
|
545
|
+
* keep cardinality bounded.
|
|
546
|
+
* @since 2.3.0
|
|
547
|
+
*/
|
|
548
|
+
function recordKeyLookup(meterProvider, attrs) {
|
|
549
|
+
getFederationMetrics(meterProvider).recordKeyLookup(attrs);
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* Records one measurement each on `activitypub.document.fetch` (counter)
|
|
553
|
+
* and `activitypub.document.fetch.duration` (histogram) for one remote
|
|
554
|
+
* JSON-LD document loader invocation, with bounded
|
|
555
|
+
* `activitypub.lookup.kind` and `activitypub.lookup.result` attributes
|
|
556
|
+
* plus the optional remote-host, cache-enabled, and HTTP status-code
|
|
557
|
+
* attributes. Counter and histogram are always recorded together so
|
|
558
|
+
* aggregate rate and latency views stay in sync.
|
|
559
|
+
* @since 2.3.0
|
|
560
|
+
*/
|
|
561
|
+
function recordDocumentFetch(meterProvider, attrs) {
|
|
562
|
+
getFederationMetrics(meterProvider).recordDocumentFetch(attrs);
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Records one `activitypub.document.cache` measurement, classifying the
|
|
566
|
+
* lookup as `hit` (the cache returned an entry) or `miss` (the cache was
|
|
567
|
+
* consulted and returned nothing, prompting a delegate fetch).
|
|
568
|
+
* @since 2.3.0
|
|
569
|
+
*/
|
|
570
|
+
function recordDocumentCache(meterProvider, attrs) {
|
|
571
|
+
getFederationMetrics(meterProvider).recordDocumentCache(attrs);
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
574
|
+
* Classifies a thrown value from a key or document fetch into the bounded
|
|
575
|
+
* {@link LookupResult} taxonomy and, when an HTTP response was received,
|
|
576
|
+
* surfaces its status code.
|
|
577
|
+
*
|
|
578
|
+
* - `FetchError` with a `Response` whose status is `404` or `410`:
|
|
579
|
+
* `result=not_found` and the response status code.
|
|
580
|
+
* - `FetchError` with any other `Response`: `result=error` and the
|
|
581
|
+
* response status code.
|
|
582
|
+
* - `FetchError` without a `Response`: `result=network_error`.
|
|
583
|
+
* - An `AbortError` (typically from a cancelled fetch): `result=network_error`.
|
|
584
|
+
* - A bare `TypeError` (the shape native `fetch()` raises on DNS, connect,
|
|
585
|
+
* and TLS failures before any response is observed):
|
|
586
|
+
* `result=network_error`.
|
|
587
|
+
* - Any other value: `result=error`.
|
|
588
|
+
* @since 2.3.0
|
|
589
|
+
*/
|
|
590
|
+
function classifyFetchError(error) {
|
|
591
|
+
if (error instanceof FetchError) {
|
|
592
|
+
if (error.response != null) {
|
|
593
|
+
const status = error.response.status;
|
|
594
|
+
return {
|
|
595
|
+
result: status === 404 || status === 410 ? "not_found" : "error",
|
|
596
|
+
statusCode: status
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
return { result: "network_error" };
|
|
600
|
+
}
|
|
601
|
+
if (isAbortError$1(error)) return { result: "network_error" };
|
|
602
|
+
if (error instanceof TypeError) return { result: "network_error" };
|
|
603
|
+
return { result: "error" };
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
* Wraps a {@link DocumentLoader} so each invocation records one
|
|
607
|
+
* measurement on `activitypub.document.fetch` (counter) and one on
|
|
608
|
+
* `activitypub.document.fetch.duration` (histogram), classifying the
|
|
609
|
+
* outcome via {@link classifyFetchError} when the wrapped loader throws
|
|
610
|
+
* and as `fetched` on success. The wrapper rethrows whatever the
|
|
611
|
+
* wrapped loader throws so caller behavior is unchanged.
|
|
612
|
+
*
|
|
613
|
+
* The wrapper records the hostname of the requested URL on
|
|
614
|
+
* `activitypub.remote.host` when the URL parses; full URLs, paths, and
|
|
615
|
+
* query strings are deliberately excluded to keep cardinality bounded.
|
|
616
|
+
* HTTP status codes are recorded only when the failure carries a
|
|
617
|
+
* `Response` (currently, when the wrapped loader throws a
|
|
618
|
+
* {@link FetchError} with a non-`null` `response`).
|
|
619
|
+
* @since 2.3.0
|
|
620
|
+
*/
|
|
621
|
+
function instrumentDocumentLoader(loader, options) {
|
|
622
|
+
const meterProvider = options.meterProvider;
|
|
623
|
+
if (meterProvider == null) return loader;
|
|
624
|
+
return async (url, opts) => {
|
|
625
|
+
const start = performance.now();
|
|
626
|
+
let remoteUrl;
|
|
627
|
+
try {
|
|
628
|
+
remoteUrl = new URL(url);
|
|
629
|
+
} catch {
|
|
630
|
+
remoteUrl = void 0;
|
|
631
|
+
}
|
|
632
|
+
try {
|
|
633
|
+
const result = await loader(url, opts);
|
|
634
|
+
recordDocumentFetch(meterProvider, {
|
|
635
|
+
durationMs: getDurationMs(start),
|
|
636
|
+
kind: options.kind,
|
|
637
|
+
result: "fetched",
|
|
638
|
+
remoteUrl,
|
|
639
|
+
cacheEnabled: options.cacheEnabled
|
|
640
|
+
});
|
|
641
|
+
return result;
|
|
642
|
+
} catch (error) {
|
|
643
|
+
const classified = classifyFetchError(error);
|
|
644
|
+
recordDocumentFetch(meterProvider, {
|
|
645
|
+
durationMs: getDurationMs(start),
|
|
646
|
+
kind: options.kind,
|
|
647
|
+
result: classified.result,
|
|
648
|
+
remoteUrl,
|
|
649
|
+
cacheEnabled: options.cacheEnabled,
|
|
650
|
+
statusCode: classified.statusCode
|
|
651
|
+
});
|
|
652
|
+
throw error;
|
|
653
|
+
}
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
451
657
|
* Times an awaited public key fetch and records exactly one
|
|
452
658
|
* `activitypub.signature.key_fetch.duration` measurement, classifying the
|
|
453
659
|
* outcome as `hit`, `fetched`, or `error` based on the `cached` flag and
|
|
@@ -827,24 +1033,48 @@ async function resolveFetchedKey(document, cacheKey, keyId, cls, { documentLoade
|
|
|
827
1033
|
};
|
|
828
1034
|
}
|
|
829
1035
|
async function fetchKeyWithResult(cacheKey, cls, options, onCachedUnavailable, onFetchError) {
|
|
830
|
-
const
|
|
831
|
-
|
|
832
|
-
"sig",
|
|
833
|
-
"key"
|
|
834
|
-
]);
|
|
835
|
-
const keyId = cacheKey.href;
|
|
836
|
-
const keyCache = options.keyCache;
|
|
837
|
-
const cached = await getCachedFetchKey(cacheKey, keyId, cls, keyCache, logger);
|
|
838
|
-
if (cached?.key === null && cached.cached) return await onCachedUnavailable(cacheKey, keyId, keyCache, logger);
|
|
839
|
-
if (cached != null) return cached;
|
|
840
|
-
logger.debug("Fetching key {keyId} to verify signature...", { keyId });
|
|
841
|
-
let document;
|
|
1036
|
+
const start = performance.now();
|
|
1037
|
+
let outcome = { result: "error" };
|
|
842
1038
|
try {
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
1039
|
+
const logger = getLogger([
|
|
1040
|
+
"fedify",
|
|
1041
|
+
"sig",
|
|
1042
|
+
"key"
|
|
1043
|
+
]);
|
|
1044
|
+
const keyId = cacheKey.href;
|
|
1045
|
+
const keyCache = options.keyCache;
|
|
1046
|
+
const cached = await getCachedFetchKey(cacheKey, keyId, cls, keyCache, logger);
|
|
1047
|
+
if (cached?.key === null && cached.cached) {
|
|
1048
|
+
const cachedUnavailable = await onCachedUnavailable(cacheKey, keyId, keyCache, logger);
|
|
1049
|
+
outcome = { result: "hit" };
|
|
1050
|
+
return cachedUnavailable;
|
|
1051
|
+
}
|
|
1052
|
+
if (cached != null) {
|
|
1053
|
+
outcome = { result: "hit" };
|
|
1054
|
+
return cached;
|
|
1055
|
+
}
|
|
1056
|
+
logger.debug("Fetching key {keyId} to verify signature...", { keyId });
|
|
1057
|
+
let document;
|
|
1058
|
+
try {
|
|
1059
|
+
document = (await (options.documentLoader ?? getDocumentLoader())(keyId)).document;
|
|
1060
|
+
} catch (error) {
|
|
1061
|
+
const classified = classifyFetchError(error);
|
|
1062
|
+
const errored = await onFetchError(error, cacheKey, keyId, keyCache, logger);
|
|
1063
|
+
outcome = classified;
|
|
1064
|
+
return errored;
|
|
1065
|
+
}
|
|
1066
|
+
const resolved = await resolveFetchedKey(document, cacheKey, keyId, cls, options, logger);
|
|
1067
|
+
outcome = { result: resolved.key != null ? "fetched" : "invalid" };
|
|
1068
|
+
return resolved;
|
|
1069
|
+
} finally {
|
|
1070
|
+
recordKeyLookup(options.meterProvider, {
|
|
1071
|
+
durationMs: getDurationMs(start),
|
|
1072
|
+
result: outcome.result,
|
|
1073
|
+
remoteUrl: cacheKey,
|
|
1074
|
+
cacheEnabled: options.keyCache != null,
|
|
1075
|
+
statusCode: outcome.statusCode
|
|
1076
|
+
});
|
|
846
1077
|
}
|
|
847
|
-
return await resolveFetchedKey(document, cacheKey, keyId, cls, options, logger);
|
|
848
1078
|
}
|
|
849
1079
|
async function fetchKeyInternal(keyId, cls, options = {}) {
|
|
850
1080
|
return await fetchKeyWithResult(typeof keyId === "string" ? new URL(keyId) : keyId, cls, options, (_cacheKey, _keyId, _keyCache, _logger) => {
|
|
@@ -1426,7 +1656,8 @@ async function verifyRequestDraft(request, span, metricsContext, { documentLoade
|
|
|
1426
1656
|
documentLoader,
|
|
1427
1657
|
contextLoader,
|
|
1428
1658
|
keyCache,
|
|
1429
|
-
tracerProvider
|
|
1659
|
+
tracerProvider,
|
|
1660
|
+
meterProvider
|
|
1430
1661
|
}));
|
|
1431
1662
|
if (fetchError != null) return keyFetchErrorResult(keyIdUrl, fetchError);
|
|
1432
1663
|
if (key == null) return invalidSignatureResult(keyIdUrl);
|
|
@@ -1641,7 +1872,8 @@ async function verifyRequestRfc9421(request, span, metricsContext, { documentLoa
|
|
|
1641
1872
|
documentLoader,
|
|
1642
1873
|
contextLoader,
|
|
1643
1874
|
keyCache,
|
|
1644
|
-
tracerProvider
|
|
1875
|
+
tracerProvider,
|
|
1876
|
+
meterProvider
|
|
1645
1877
|
}));
|
|
1646
1878
|
if (fetchError != null) {
|
|
1647
1879
|
setFailure(keyFetchErrorResult(keyId, fetchError));
|
|
@@ -1944,4 +2176,4 @@ function timingSafeEqual(a, b) {
|
|
|
1944
2176
|
return result === 0;
|
|
1945
2177
|
}
|
|
1946
2178
|
//#endregion
|
|
1947
|
-
export {
|
|
2179
|
+
export { formatAcceptSignature as C, name as D, validateAcceptSignature as E, version as O, recordOutboxEnqueue as S, parseAcceptSignature as T, measureSignatureKeyFetch as _, verifyRequestDetailed as a, recordInboxActivity as b, fetchKeyDetailed as c, validateCryptoKey as d, getDurationMs as f, isAbortError$1 as g, instrumentDocumentLoader as h, verifyRequest as i, generateCryptoKeyPair as l, getRemoteHost as m, parseRfc9421SignatureInput as n, exportJwk as o, getFederationMetrics as p, signRequest as r, fetchKey as s, doubleKnock as t, importJwk as u, recordDocumentCache as v, fulfillAcceptSignature as w, recordOutboxActivity as x, recordFanoutRecipients as y };
|