@fedify/fedify 2.1.23 → 2.1.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/dist/{assert_instance_of-C4Ri6VuN.mjs → assert-BhQd8QHP.mjs} +19 -1
  2. package/dist/{builder-BlCsjkrX.mjs → builder-DsBAef6b.mjs} +3 -3
  3. package/dist/{client-CZWLyLmp.mjs → client-DM72NZuk.mjs} +85 -7
  4. package/dist/compat/mod.d.cts +1 -1
  5. package/dist/compat/mod.d.ts +1 -1
  6. package/dist/compat/transformers.test.mjs +3 -4
  7. package/dist/{context-_l9t359k.d.ts → context-BgU5UWTx.d.ts} +4 -3
  8. package/dist/{context-o22vjzS2.d.cts → context-D4s0Wk3N.d.cts} +4 -3
  9. package/dist/{deno-B_Gwkjh7.mjs → deno-9AaebKOA.mjs} +1 -1
  10. package/dist/docloader-DX96uPUj.mjs +78 -0
  11. package/dist/federation/builder.test.mjs +3 -3
  12. package/dist/federation/collection.test.mjs +2 -2
  13. package/dist/federation/handler.test.mjs +128 -10
  14. package/dist/federation/idempotency.test.mjs +5 -5
  15. package/dist/federation/inbox.test.mjs +1 -1
  16. package/dist/federation/keycache.test.mjs +44 -10
  17. package/dist/federation/kv.test.mjs +2 -2
  18. package/dist/federation/middleware.test.mjs +227 -12
  19. package/dist/federation/mod.cjs +1 -1
  20. package/dist/federation/mod.d.cts +2 -2
  21. package/dist/federation/mod.d.ts +2 -2
  22. package/dist/federation/mod.js +1 -1
  23. package/dist/federation/mq.test.mjs +99 -44
  24. package/dist/federation/negotiation.test.mjs +3 -3
  25. package/dist/federation/retry.test.mjs +1 -1
  26. package/dist/federation/router.test.mjs +2 -2
  27. package/dist/federation/send.test.mjs +202 -7
  28. package/dist/federation/temporal.test.mjs +3 -3
  29. package/dist/federation/webfinger.test.mjs +3 -3
  30. package/dist/{http-DIh9_s_-.mjs → http-B5qAeoJd.mjs} +8 -4
  31. package/dist/{http-Yoq0YGz7.cjs → http-BJEMpnnY.cjs} +171 -7
  32. package/dist/{http-88deUx3Y.js → http-CdJ6n4rA.js} +160 -8
  33. package/dist/{http-BDZeS5om.d.ts → http-Dl00HXr4.d.ts} +1 -1
  34. package/dist/{http-C87EWkO0.d.cts → http-DqZhyEso.d.cts} +1 -1
  35. package/dist/{inbox-BxCHIWPD.mjs → inbox-BSyjaFbo.mjs} +1 -1
  36. package/dist/{key-DywPPmb0.mjs → key-x9f-H7eO.mjs} +154 -6
  37. package/dist/{keycache-CCSwkQcY.mjs → keycache-CaO7wyQA.mjs} +12 -4
  38. package/dist/{kv-cache-HA011rBG.cjs → kv-cache-BDp2c_QE.cjs} +34 -8
  39. package/dist/{kv-cache-rHQOc5rE.js → kv-cache-Dx3QwNBI.js} +35 -9
  40. package/dist/{ld-Ch6FVq7X.mjs → ld-cfUwoi0C.mjs} +3 -3
  41. package/dist/{middleware-itcr4fAv.cjs → middleware-BXJpAXhO.cjs} +1 -1
  42. package/dist/{middleware-CYsQG25-.js → middleware-CP35ElZv.js} +99 -14
  43. package/dist/{middleware-DABFg_Xy.mjs → middleware-DDT9ljTQ.mjs} +1 -1
  44. package/dist/{middleware-D2O8b03q.mjs → middleware-DHHRwSZH.mjs} +31 -20
  45. package/dist/{middleware-CUNIlYzF.cjs → middleware-XXuSt_6b.cjs} +99 -14
  46. package/dist/{mod-CjiK2zrW.d.ts → mod-BLDHhuW0.d.ts} +1 -1
  47. package/dist/{mod-0dF0OeGw.d.cts → mod-Bx80LUTA.d.cts} +1 -1
  48. package/dist/{mod-Bv1elC-b.d.ts → mod-DcAiY74j.d.ts} +1 -1
  49. package/dist/{mod-D5YlzzP3.d.cts → mod-DiuFTYUt.d.cts} +1 -1
  50. package/dist/{mod-dxOnKp2Y.d.cts → mod-DkE98l_7.d.cts} +3 -1
  51. package/dist/{mod-BTWFtZwa.d.ts → mod-DqkY4FDr.d.ts} +3 -1
  52. package/dist/mod.cjs +5 -5
  53. package/dist/mod.d.cts +6 -6
  54. package/dist/mod.d.ts +6 -6
  55. package/dist/mod.js +5 -5
  56. package/dist/nodeinfo/client.test.mjs +77 -2
  57. package/dist/nodeinfo/handler.test.mjs +3 -3
  58. package/dist/nodeinfo/mod.cjs +1 -1
  59. package/dist/nodeinfo/mod.js +1 -1
  60. package/dist/nodeinfo/types.test.mjs +2 -2
  61. package/dist/otel/exporter.test.mjs +2 -2
  62. package/dist/{owner-DEvZuyOE.d.cts → owner-B3hNQCG8.d.cts} +11 -0
  63. package/dist/{owner-CnngXDNJ.d.ts → owner-CiBPcC6F.d.ts} +11 -0
  64. package/dist/owner-DklgvZXn.mjs +175 -0
  65. package/dist/{proof-Dt5GV-xi.mjs → proof-CI4rsVLu.mjs} +2 -2
  66. package/dist/{proof-K3inAqnp.js → proof-Dsa_ZC-M.js} +113 -59
  67. package/dist/{proof-CEn2R6W9.cjs → proof-DzFzyfIc.cjs} +113 -59
  68. package/dist/{send-CqaJDT2z.mjs → send-DJmW6Z-I.mjs} +73 -6
  69. package/dist/sig/accept.test.mjs +1 -1
  70. package/dist/sig/http.test.mjs +45 -5
  71. package/dist/sig/key.test.mjs +171 -4
  72. package/dist/sig/ld.test.mjs +59 -4
  73. package/dist/sig/mod.cjs +2 -2
  74. package/dist/sig/mod.d.cts +3 -3
  75. package/dist/sig/mod.d.ts +3 -3
  76. package/dist/sig/mod.js +2 -2
  77. package/dist/sig/owner.test.mjs +106 -7
  78. package/dist/sig/proof.test.mjs +73 -4
  79. package/dist/{std__assert-Duiq_YC9.mjs → std__assert-BUOJXi-Z.mjs} +1 -26
  80. package/dist/{temporal-G_GDghC-.mjs → temporal-BanFifxu.mjs} +1 -1
  81. package/dist/{types-m8u9L86X.cjs → types-DRPjmHVV.cjs} +101 -5
  82. package/dist/{types-DTONwNqL.js → types-miAYfiGO.js} +85 -7
  83. package/dist/utils/docloader.test.mjs +325 -5
  84. package/dist/utils/kv-cache.test.mjs +1 -1
  85. package/dist/utils/mod.cjs +1 -1
  86. package/dist/utils/mod.d.cts +1 -1
  87. package/dist/utils/mod.d.ts +1 -1
  88. package/dist/utils/mod.js +1 -1
  89. package/dist/vocab/cjs.test.mjs +1 -1
  90. package/package.json +7 -7
  91. package/dist/assert-ddO5KLpe.mjs +0 -23
  92. package/dist/docloader-B-IG1dVk.mjs +0 -52
  93. package/dist/owner-Cygg-fHW.mjs +0 -120
  94. /package/dist/{accept-Dd__NiUL.mjs → accept-BavzedPB.mjs} +0 -0
  95. /package/dist/{collection-BD6-SZ6O.mjs → collection-ChgDTHLz.mjs} +0 -0
  96. /package/dist/{keys-BAK-tUlf.mjs → keys-CtZLJq76.mjs} +0 -0
  97. /package/dist/{kv-tL2TOE9X.mjs → kv-BrZHNugx.mjs} +0 -0
  98. /package/dist/{kv-cache-FsT1ljhs.mjs → kv-cache-DqEKe5E0.mjs} +0 -0
  99. /package/dist/{negotiation-DnsfFF8I.mjs → negotiation-BehA2uul.mjs} +0 -0
  100. /package/dist/{retry-CJL0poaU.mjs → retry-B_E3V_Dx.mjs} +0 -0
  101. /package/dist/{types-DCP0WLdt.mjs → types-C37hquWI.mjs} +0 -0
@@ -1,6 +1,6 @@
1
1
  const { Temporal } = require("@js-temporal/polyfill");
2
2
  const { URLPattern } = require("urlpattern-polyfill");
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
- const require_kv_cache = require("../kv-cache-HA011rBG.cjs");
4
+ const require_kv_cache = require("../kv-cache-BDp2c_QE.cjs");
5
5
  exports.getAuthenticatedDocumentLoader = require_kv_cache.getAuthenticatedDocumentLoader;
6
6
  exports.kvCache = require_kv_cache.kvCache;
@@ -1,3 +1,3 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { n as getAuthenticatedDocumentLoader, t as kvCache } from "../mod-dxOnKp2Y.cjs";
2
+ import { n as getAuthenticatedDocumentLoader, t as kvCache } from "../mod-DkE98l_7.cjs";
3
3
  export { getAuthenticatedDocumentLoader, kvCache };
@@ -1,3 +1,3 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { n as getAuthenticatedDocumentLoader, t as kvCache } from "../mod-BTWFtZwa.js";
2
+ import { n as getAuthenticatedDocumentLoader, t as kvCache } from "../mod-DqkY4FDr.js";
3
3
  export { getAuthenticatedDocumentLoader, kvCache };
package/dist/utils/mod.js CHANGED
@@ -1,4 +1,4 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { n as getAuthenticatedDocumentLoader, t as kvCache } from "../kv-cache-rHQOc5rE.js";
3
+ import { n as getAuthenticatedDocumentLoader, t as kvCache } from "../kv-cache-Dx3QwNBI.js";
4
4
  export { getAuthenticatedDocumentLoader, kvCache };
@@ -5,7 +5,7 @@ import { createRequire } from "node:module";
5
5
  import { test } from "@fedify/fixture";
6
6
  import { strictEqual } from "node:assert";
7
7
  //#region src/vocab/cjs.test.ts
8
- test("CommonJS vocab entry exports Object", { ignore: "Deno" in globalThis }, () => {
8
+ test("CommonJS vocab entry exports Object", { ignore: "Deno" in globalThis || "navigator" in globalThis && navigator.userAgent === "Cloudflare-Workers" }, () => {
9
9
  const vocab = createRequire(import.meta.url)("./mod.cjs");
10
10
  strictEqual(typeof vocab.Object, "function");
11
11
  strictEqual(typeof vocab.Update, "function");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/fedify",
3
- "version": "2.1.23",
3
+ "version": "2.1.25",
4
4
  "description": "An ActivityPub server framework",
5
5
  "keywords": [
6
6
  "ActivityPub",
@@ -144,9 +144,9 @@
144
144
  "uri-template-router": "^1.0.0",
145
145
  "url-template": "^3.1.1",
146
146
  "urlpattern-polyfill": "^10.1.0",
147
- "@fedify/vocab": "2.1.23",
148
- "@fedify/webfinger": "2.1.23",
149
- "@fedify/vocab-runtime": "2.1.23"
147
+ "@fedify/vocab": "2.1.25",
148
+ "@fedify/vocab-runtime": "2.1.25",
149
+ "@fedify/webfinger": "2.1.25"
150
150
  },
151
151
  "devDependencies": {
152
152
  "@std/assert": "npm:@jsr/std__assert@^0.226.0",
@@ -158,8 +158,8 @@
158
158
  "tsx": "^4.19.4",
159
159
  "typescript": "^6.0.0",
160
160
  "wrangler": "^4.17.0",
161
- "@fedify/vocab-tools": "^2.1.23",
162
- "@fedify/fixture": "2.0.0"
161
+ "@fedify/fixture": "2.0.0",
162
+ "@fedify/vocab-tools": "^2.1.25"
163
163
  },
164
164
  "scripts": {
165
165
  "build:self": "tsdown",
@@ -169,6 +169,6 @@
169
169
  "test": "cd dist/ && node --test",
170
170
  "pretest:bun": "pnpm build",
171
171
  "test:bun": "cd dist/ && bun test --timeout 60000",
172
- "test:cfworkers": "deno task codegen && wrangler deploy --dry-run --outdir src/cfworkers && node --import=tsx src/cfworkers/client.ts"
172
+ "test:cfworkers": "deno task codegen && wrangler deploy --dry-run --outdir src/cfworkers && node --import=tsx scripts/check_cfworkers.ts && node --import=tsx src/cfworkers/client.ts"
173
173
  }
174
174
  }
@@ -1,23 +0,0 @@
1
- import "@js-temporal/polyfill";
2
- import "urlpattern-polyfill";
3
- globalThis.addEventListener = () => {};
4
- import { l as AssertionError } from "./assert_equals-Ew3jOFa3.mjs";
5
- //#region ../../node_modules/.pnpm/@jsr+std__assert@0.226.0/node_modules/@jsr/std__assert/assert.js
6
- /**
7
- * Make an assertion, error will be thrown if `expr` does not have truthy value.
8
- *
9
- * @example Usage
10
- * ```ts no-eval
11
- * import { assert } from "@std/assert/assert";
12
- *
13
- * assert("hello".includes("ello")); // Doesn't throw
14
- * assert("hello".includes("world")); // Throws
15
- * ```
16
- *
17
- * @param expr The expression to test.
18
- * @param msg The optional message to display if the assertion fails.
19
- */ function assert(expr, msg = "") {
20
- if (!expr) throw new AssertionError(msg);
21
- }
22
- //#endregion
23
- export { assert as t };
@@ -1,52 +0,0 @@
1
- import "@js-temporal/polyfill";
2
- import "urlpattern-polyfill";
3
- globalThis.addEventListener = () => {};
4
- import { o as validateCryptoKey } from "./key-DywPPmb0.mjs";
5
- import { n as doubleKnock } from "./http-DIh9_s_-.mjs";
6
- import { curry } from "es-toolkit";
7
- import { UrlError, createActivityPubRequest, getRemoteDocument, logRequest, validatePublicUrl } from "@fedify/vocab-runtime";
8
- import { getLogger } from "@logtape/logtape";
9
- //#region src/utils/docloader.ts
10
- const logger = getLogger([
11
- "fedify",
12
- "utils",
13
- "docloader"
14
- ]);
15
- /**
16
- * Gets an authenticated {@link DocumentLoader} for the given identity.
17
- * Note that an authenticated document loader intentionally does not cache
18
- * the fetched documents.
19
- * @param identity The identity to get the document loader for.
20
- * The actor's key pair.
21
- * @param options The options for the document loader.
22
- * @returns The authenticated document loader.
23
- * @throws {TypeError} If the key is invalid or unsupported.
24
- * @since 0.4.0
25
- */
26
- function getAuthenticatedDocumentLoader(identity, { allowPrivateAddress, userAgent, specDeterminer, tracerProvider } = {}) {
27
- validateCryptoKey(identity.privateKey);
28
- async function load(url, options) {
29
- await validateUrl(url);
30
- return getRemoteDocument(url, await doubleKnock(createActivityPubRequest(url, { userAgent }), identity, {
31
- specDeterminer,
32
- log: curry(logRequest)(logger),
33
- tracerProvider,
34
- signal: options?.signal,
35
- validateRedirect: validateUrl
36
- }), load);
37
- }
38
- async function validateUrl(url) {
39
- if (!allowPrivateAddress) try {
40
- await validatePublicUrl(url);
41
- } catch (error) {
42
- if (error instanceof UrlError) logger.error("Disallowed private URL: {url}", {
43
- url,
44
- error
45
- });
46
- throw error;
47
- }
48
- }
49
- return load;
50
- }
51
- //#endregion
52
- export { getAuthenticatedDocumentLoader as t };
@@ -1,120 +0,0 @@
1
- import "@js-temporal/polyfill";
2
- import "urlpattern-polyfill";
3
- globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-B_Gwkjh7.mjs";
5
- import "./key-DywPPmb0.mjs";
6
- import { CryptographicKey, Object as Object$1, isActor } from "@fedify/vocab";
7
- import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
8
- import { getDocumentLoader } from "@fedify/vocab-runtime";
9
- //#region src/sig/owner.ts
10
- /**
11
- * Checks if the actor of the given activity owns the specified key.
12
- * @param activity The activity to check.
13
- * @param key The public key to check.
14
- * @param options Options for checking the key ownership.
15
- * @returns Whether the actor is the owner of the key.
16
- */
17
- async function doesActorOwnKey(activity, key, options) {
18
- return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("activitypub.verify_key_ownership", {
19
- kind: SpanKind.INTERNAL,
20
- attributes: {
21
- "activitypub.actor.id": activity.actorId?.href ?? "",
22
- "activitypub.key.id": key.id?.href ?? ""
23
- }
24
- }, async (span) => {
25
- try {
26
- if (key.ownerId != null) {
27
- const owns = key.ownerId.href === activity.actorId?.href;
28
- span.setAttribute("activitypub.key_ownership.verified", owns);
29
- span.setAttribute("activitypub.key_ownership.method", "owner_id");
30
- return owns;
31
- }
32
- const actor = await activity.getActor(options);
33
- if (actor == null || !isActor(actor)) {
34
- span.setAttribute("activitypub.key_ownership.verified", false);
35
- span.setAttribute("activitypub.key_ownership.method", "actor_fetch");
36
- return false;
37
- }
38
- for (const publicKeyId of actor.publicKeyIds) if (key.id != null && publicKeyId.href === key.id.href) {
39
- span.setAttribute("activitypub.key_ownership.verified", true);
40
- span.setAttribute("activitypub.key_ownership.method", "actor_fetch");
41
- return true;
42
- }
43
- span.setAttribute("activitypub.key_ownership.verified", false);
44
- span.setAttribute("activitypub.key_ownership.method", "actor_fetch");
45
- return false;
46
- } catch (error) {
47
- span.recordException(error);
48
- span.setStatus({
49
- code: SpanStatusCode.ERROR,
50
- message: String(error)
51
- });
52
- throw error;
53
- } finally {
54
- span.end();
55
- }
56
- });
57
- }
58
- /**
59
- * Gets the actor that owns the specified key. Returns `null` if the key has no
60
- * known owner.
61
- *
62
- * @param keyId The ID of the key to check, or the key itself.
63
- * @param options Options for getting the key owner.
64
- * @returns The actor that owns the key, or `null` if the key has no known
65
- * owner.
66
- * @since 0.7.0
67
- */
68
- async function getKeyOwner(keyId, options) {
69
- const tracerProvider = options.tracerProvider ?? trace.getTracerProvider();
70
- const documentLoader = options.documentLoader ?? getDocumentLoader();
71
- const contextLoader = options.contextLoader ?? getDocumentLoader();
72
- let object;
73
- if (keyId instanceof CryptographicKey) {
74
- object = keyId;
75
- if (object.id == null) return null;
76
- keyId = object.id;
77
- } else {
78
- let keyDoc;
79
- try {
80
- const { document } = await documentLoader(keyId.href);
81
- keyDoc = document;
82
- } catch (_) {
83
- return null;
84
- }
85
- try {
86
- object = await Object$1.fromJsonLd(keyDoc, {
87
- documentLoader,
88
- contextLoader,
89
- tracerProvider
90
- });
91
- } catch (e) {
92
- if (!(e instanceof TypeError)) throw e;
93
- try {
94
- object = await CryptographicKey.fromJsonLd(keyDoc, {
95
- documentLoader,
96
- contextLoader,
97
- tracerProvider
98
- });
99
- } catch (e) {
100
- if (e instanceof TypeError) return null;
101
- throw e;
102
- }
103
- }
104
- }
105
- let owner = null;
106
- if (object instanceof CryptographicKey) {
107
- if (object.ownerId == null) return null;
108
- owner = await object.getOwner({
109
- documentLoader,
110
- contextLoader,
111
- tracerProvider
112
- });
113
- } else if (isActor(object)) owner = object;
114
- else return null;
115
- if (owner == null) return null;
116
- for (const kid of owner.publicKeyIds) if (kid.href === keyId.href) return owner;
117
- return null;
118
- }
119
- //#endregion
120
- export { getKeyOwner as n, doesActorOwnKey as t };
File without changes
File without changes
File without changes
File without changes