@fedify/fedify 2.2.0-pr.708.19 → 2.2.0-pr.710.22

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 (63) hide show
  1. package/dist/{builder-_Q1P6V24.mjs → builder-bnytmADH.mjs} +3 -3
  2. package/dist/compat/public-audience.test.d.mts +2 -0
  3. package/dist/compat/public-audience.test.mjs +162 -0
  4. package/dist/compat/transformers.test.mjs +2 -2
  5. package/dist/{deno-D544KGtd.mjs → deno-sxAmy69e.mjs} +1 -1
  6. package/dist/{docloader-CXAw1Ofx.mjs → docloader-CAcGw6pQ.mjs} +2 -2
  7. package/dist/federation/builder.test.mjs +2 -2
  8. package/dist/federation/collection.test.mjs +1 -1
  9. package/dist/federation/handler.test.mjs +4 -4
  10. package/dist/federation/idempotency.test.mjs +3 -3
  11. package/dist/federation/inbox.test.mjs +1 -1
  12. package/dist/federation/keycache.test.mjs +2 -2
  13. package/dist/federation/kv.test.mjs +1 -1
  14. package/dist/federation/middleware.test.mjs +17 -7
  15. package/dist/federation/mod.cjs +1 -1
  16. package/dist/federation/mod.js +1 -1
  17. package/dist/federation/negotiation.test.mjs +1 -1
  18. package/dist/federation/retry.test.mjs +1 -1
  19. package/dist/federation/send.test.mjs +3 -3
  20. package/dist/federation/webfinger.test.mjs +2 -2
  21. package/dist/{http-6m2N3LCD.mjs → http-BKrXOLjL.mjs} +2 -2
  22. package/dist/{http-BMsHAyvq.cjs → http-C1BAaJ_m.cjs} +1 -1
  23. package/dist/{http-CxVGLNoz.js → http-DI4R9CTK.js} +1 -1
  24. package/dist/{key-CCuaH5jy.mjs → key-CwG1d1a2.mjs} +1 -1
  25. package/dist/{kv-cache-CBQPqEDj.js → kv-cache-BQS2P8gv.js} +1 -1
  26. package/dist/{kv-cache-D0srbjWc.cjs → kv-cache-p33MTfBu.cjs} +1 -1
  27. package/dist/{ld-DN2lsaG8.mjs → ld-t2WD3nYp.mjs} +2 -2
  28. package/dist/{middleware-Ddf57ad_.cjs → middleware-C4JOTHSG.cjs} +1 -1
  29. package/dist/{middleware-Djy1WhXC.mjs → middleware-D545J7x8.mjs} +1 -1
  30. package/dist/{middleware-CDNoFhdO.mjs → middleware-D8r5yKV-.mjs} +17 -15
  31. package/dist/{middleware-C7DGuOYc.js → middleware-RhsXBX0y.js} +4 -3
  32. package/dist/{middleware-DmwNARrQ.cjs → middleware-cGUpoNb_.cjs} +5 -4
  33. package/dist/mod.cjs +4 -4
  34. package/dist/mod.js +4 -4
  35. package/dist/nodeinfo/client.test.mjs +1 -1
  36. package/dist/nodeinfo/handler.test.mjs +2 -2
  37. package/dist/nodeinfo/types.test.mjs +1 -1
  38. package/dist/otel/exporter.test.mjs +1 -1
  39. package/dist/{owner-B34dTvD2.mjs → owner-J1wYUBAp.mjs} +2 -2
  40. package/dist/{proof-3RKiVMZP.cjs → proof-0fe_hpBU.cjs} +221 -38
  41. package/dist/{proof-0cJIZBgO.js → proof-DJiXN7Qc.js} +218 -41
  42. package/dist/{proof-grJLXdIM.mjs → proof-DngAmXc3.mjs} +36 -31
  43. package/dist/public-audience-5WWE-JTr.mjs +181 -0
  44. package/dist/{send-Cqy2NRSV.mjs → send-CCwbKHXy.mjs} +2 -2
  45. package/dist/sig/http.test.mjs +2 -2
  46. package/dist/sig/key.test.mjs +1 -1
  47. package/dist/sig/ld.test.mjs +2 -2
  48. package/dist/sig/mod.cjs +2 -2
  49. package/dist/sig/mod.js +2 -2
  50. package/dist/sig/owner.test.mjs +1 -1
  51. package/dist/sig/proof.test.mjs +60 -2
  52. package/dist/utils/docloader.test.mjs +2 -2
  53. package/dist/utils/mod.cjs +1 -1
  54. package/dist/utils/mod.js +1 -1
  55. package/package.json +5 -5
  56. /package/dist/{activity-listener-Ck3JZ_hR.mjs → activity-listener-CFzUqoCS.mjs} +0 -0
  57. /package/dist/{client-DEpOVgY1.mjs → client-DVu6Fmom.mjs} +0 -0
  58. /package/dist/{collection-BD6-SZ6O.mjs → collection-BQRKGS7L.mjs} +0 -0
  59. /package/dist/{keycache-CCSwkQcY.mjs → keycache-C2t1kvP5.mjs} +0 -0
  60. /package/dist/{kv-tL2TOE9X.mjs → kv-C-TG81Sv.mjs} +0 -0
  61. /package/dist/{negotiation-DnsfFF8I.mjs → negotiation-xb0QR3u_.mjs} +0 -0
  62. /package/dist/{retry-B_E3V_Dx.mjs → retry-CJL0poaU.mjs} +0 -0
  63. /package/dist/{types-DCP0WLdt.mjs → types-CGUnLkU3.mjs} +0 -0
@@ -0,0 +1,181 @@
1
+ import "@js-temporal/polyfill";
2
+ import "urlpattern-polyfill";
3
+ globalThis.addEventListener = () => {};
4
+ import { PUBLIC_COLLECTION } from "@fedify/vocab";
5
+ import { preloadedContexts } from "@fedify/vocab-runtime";
6
+ import { getLogger } from "@logtape/logtape";
7
+ import jsonld from "@fedify/vocab-runtime/jsonld";
8
+ //#region src/compat/public-audience.ts
9
+ const logger = getLogger([
10
+ "fedify",
11
+ "compat",
12
+ "public-audience"
13
+ ]);
14
+ const PUBLIC_ADDRESSING_FIELDS = new Set([
15
+ "to",
16
+ "cc",
17
+ "bto",
18
+ "bcc",
19
+ "audience"
20
+ ]);
21
+ const preloadedOnlyDocumentLoader = (url) => {
22
+ if (url in preloadedContexts) return Promise.resolve({
23
+ contextUrl: null,
24
+ documentUrl: url,
25
+ document: preloadedContexts[url]
26
+ });
27
+ return Promise.reject(/* @__PURE__ */ new Error("Refusing to fetch a non-preloaded JSON-LD context: " + url));
28
+ };
29
+ const AS_CONTEXT_URL = "https://www.w3.org/ns/activitystreams";
30
+ const MAX_TRAVERSAL_DEPTH = 64;
31
+ const KNOWN_SAFE_CONTEXT_URLS = new Set(Object.keys(preloadedContexts));
32
+ function hasPublicCurieInAddressing(value, parentKey, depth = 0) {
33
+ if (typeof value === "string") return parentKey != null && PUBLIC_ADDRESSING_FIELDS.has(parentKey) && (value === "as:Public" || value === "Public");
34
+ if (depth >= MAX_TRAVERSAL_DEPTH) return false;
35
+ if (Array.isArray(value)) return value.some((item) => hasPublicCurieInAddressing(item, parentKey, depth + 1));
36
+ if (typeof value !== "object" || value == null) return false;
37
+ const record = value;
38
+ for (const key of Object.keys(record)) {
39
+ if (key === "@context") continue;
40
+ if (hasPublicCurieInAddressing(record[key], key, depth + 1)) return true;
41
+ }
42
+ return false;
43
+ }
44
+ function rewritePublicAudience(value, parentKey, depth = 0) {
45
+ if (typeof value === "string" && parentKey != null && PUBLIC_ADDRESSING_FIELDS.has(parentKey) && (value === "as:Public" || value === "Public")) return PUBLIC_COLLECTION.href;
46
+ if (depth >= MAX_TRAVERSAL_DEPTH) return value;
47
+ if (Array.isArray(value)) {
48
+ let changed = false;
49
+ const mapped = value.map((item) => {
50
+ const rewritten = rewritePublicAudience(item, parentKey, depth + 1);
51
+ if (rewritten !== item) changed = true;
52
+ return rewritten;
53
+ });
54
+ return changed ? mapped : value;
55
+ }
56
+ if (typeof value !== "object" || value == null) return value;
57
+ const record = value;
58
+ let changed = false;
59
+ const normalized = {};
60
+ for (const key of Object.keys(record)) {
61
+ const rewritten = key === "@context" ? record[key] : rewritePublicAudience(record[key], key, depth + 1);
62
+ if (rewritten !== record[key]) changed = true;
63
+ normalized[key] = rewritten;
64
+ }
65
+ return changed ? normalized : value;
66
+ }
67
+ /**
68
+ * Reports whether `value` carries an `@context` property anywhere inside
69
+ * its subtree (not counting the value itself). A nested `@context` can
70
+ * introduce a local term-definition scope that redefines `as:` or `Public`
71
+ * even when the top-level `@context` is safe, so the fast path must defer
72
+ * to the URDNA2015 equivalence check whenever one is present.
73
+ */
74
+ function hasNestedContext(value, depth = 0) {
75
+ if (depth >= MAX_TRAVERSAL_DEPTH) return true;
76
+ if (Array.isArray(value)) return value.some((item) => hasNestedContext(item, depth + 1));
77
+ if (typeof value !== "object" || value == null) return false;
78
+ const record = value;
79
+ for (const key of Object.keys(record)) {
80
+ if (key === "@context") return true;
81
+ if (hasNestedContext(record[key], depth + 1)) return true;
82
+ }
83
+ return false;
84
+ }
85
+ /**
86
+ * Checks whether the `@context` of a JSON-LD document is guaranteed not
87
+ * to redefine the `as:` prefix or the bare `Public` term. Only documents
88
+ * whose `@context` is a string, or an array of strings, drawn from Fedify's
89
+ * preloaded context set AND including the ActivityStreams URL qualify,
90
+ * AND no nested subtree carries its own `@context` that might redefine
91
+ * those terms within a local scope. When all of that holds the rewrite
92
+ * is provably semantics-preserving and the URDNA2015 equivalence check
93
+ * can be skipped. Any other shape (unknown external URLs, inline
94
+ * objects at the top level, nested `@context` blocks) is treated as
95
+ * potentially unsafe.
96
+ */
97
+ function hasKnownSafeContext(jsonLd) {
98
+ if (typeof jsonLd !== "object" || jsonLd == null) return false;
99
+ const record = jsonLd;
100
+ if (!Object.hasOwn(record, "@context")) return false;
101
+ const ctx = record["@context"];
102
+ const entries = typeof ctx === "string" ? [ctx] : Array.isArray(ctx) ? ctx : null;
103
+ if (entries == null || entries.length === 0) return false;
104
+ let hasAs = false;
105
+ for (const entry of entries) {
106
+ if (typeof entry !== "string") return false;
107
+ if (!KNOWN_SAFE_CONTEXT_URLS.has(entry)) return false;
108
+ if (entry === AS_CONTEXT_URL) hasAs = true;
109
+ }
110
+ if (!hasAs) return false;
111
+ for (const key of Object.keys(record)) {
112
+ if (key === "@context") continue;
113
+ if (hasNestedContext(record[key])) return false;
114
+ }
115
+ return true;
116
+ }
117
+ /**
118
+ * Rewrites the compact `as:Public` / `Public` CURIE appearing in activity
119
+ * addressing fields (`to`, `cc`, `bto`, `bcc`, `audience`) to the fully
120
+ * expanded `https://www.w3.org/ns/activitystreams#Public` URI.
121
+ *
122
+ * Several ActivityPub implementations, Lemmy among them, match these
123
+ * fields as plain URLs without running JSON-LD expansion, and silently
124
+ * drop activities whose public addressing appears in CURIE form. This
125
+ * helper works around that gap.
126
+ *
127
+ * For documents whose `@context` is drawn entirely from Fedify's
128
+ * preloaded context set and includes the ActivityStreams URL, the
129
+ * rewrite is applied directly: the content of every preloaded non-AS
130
+ * context is known not to redefine the `as:` prefix or the bare `Public`
131
+ * term, so the semantics are preserved by construction. Any other
132
+ * shape (an inline object, an unknown external URL, and so on) is
133
+ * treated as potentially unsafe and gated on a JSON-LD equivalence
134
+ * check; both forms are canonicalized with URDNA2015 and the resulting
135
+ * N-Quads are compared. When they differ, the original document is
136
+ * returned unchanged. Canonicalization failures also fall back to the
137
+ * original document.
138
+ *
139
+ * When no `contextLoader` is supplied the helper falls back to an
140
+ * internal loader that resolves only the URLs in Fedify's
141
+ * preloaded-contexts set and rejects every other URL without issuing a
142
+ * network request. That behaviour is deliberately narrower than
143
+ * `@fedify/vocab-runtime`'s `getDocumentLoader()`, which after its
144
+ * `validatePublicUrl` check will happily fetch non-preloaded URLs: the
145
+ * helper is reached from verification paths (`verifyProof()` /
146
+ * `verifyObject()`) that operate on inbound, potentially adversarial
147
+ * JSON-LD, and a default loader that fetches attacker-supplied
148
+ * `@context` URLs on the caller's behalf would be an SSRF vector.
149
+ * Canonicalization failures against the restricted loader fall back to
150
+ * the original document, same as any other canonicalization error.
151
+ * Callers that genuinely need the remote-fetch loader (for example
152
+ * applications that sign local JSON-LD against a custom vocabulary)
153
+ * should pass a `contextLoader` explicitly.
154
+ *
155
+ * Must be called before any signing step that canonicalizes the
156
+ * compact form byte-for-byte (for example, Object Integrity Proofs
157
+ * using the `eddsa-jcs-2022` cryptosuite), so the signed payload
158
+ * matches what is sent on the wire.
159
+ */
160
+ async function normalizePublicAudience(jsonLd, contextLoader) {
161
+ if (!hasPublicCurieInAddressing(jsonLd)) return jsonLd;
162
+ const normalized = rewritePublicAudience(jsonLd);
163
+ if (hasKnownSafeContext(jsonLd)) return normalized;
164
+ const loader = contextLoader ?? preloadedOnlyDocumentLoader;
165
+ try {
166
+ const [before, after] = await Promise.all([jsonld.canonize(jsonLd, {
167
+ format: "application/n-quads",
168
+ documentLoader: loader
169
+ }), jsonld.canonize(normalized, {
170
+ format: "application/n-quads",
171
+ documentLoader: loader
172
+ })]);
173
+ if (before === after) return normalized;
174
+ logger.warn("Expanding the public audience CURIE to its full URI would change the canonical form of the activity; sending the activity as is. This usually means the active JSON-LD context redefines the `as:` prefix or the bare `Public` term.");
175
+ } catch (error) {
176
+ logger.debug("Failed to verify public audience normalization equivalence via JSON-LD canonicalization; sending the activity as is.\n{error}", { error });
177
+ }
178
+ return jsonLd;
179
+ }
180
+ //#endregion
181
+ export { normalizePublicAudience as t };
@@ -1,8 +1,8 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-D544KGtd.mjs";
5
- import { n as doubleKnock } from "./http-6m2N3LCD.mjs";
4
+ import { n as version, t as name } from "./deno-sxAmy69e.mjs";
5
+ import { n as doubleKnock } from "./http-BKrXOLjL.mjs";
6
6
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
7
7
  import { getLogger } from "@logtape/logtape";
8
8
  //#region src/federation/send.ts
@@ -7,8 +7,8 @@ import { a as assertExists, t as assertStringIncludes } from "../std__assert-Dui
7
7
  import { n as assertFalse, t as assertRejects } from "../assert_rejects-B-qJtC9Z.mjs";
8
8
  import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
9
9
  import { t as assert } from "../assert-ddO5KLpe.mjs";
10
- import { t as exportJwk } from "../key-CCuaH5jy.mjs";
11
- import { a as parseRfc9421Signature, c as timingSafeEqual, i as formatRfc9421SignatureParameters, l as verifyRequest, n as doubleKnock, o as parseRfc9421SignatureInput, r as formatRfc9421Signature, s as signRequest, t as createRfc9421SignatureBase, u as verifyRequestDetailed } from "../http-6m2N3LCD.mjs";
10
+ import { t as exportJwk } from "../key-CwG1d1a2.mjs";
11
+ import { a as parseRfc9421Signature, c as timingSafeEqual, i as formatRfc9421SignatureParameters, l as verifyRequest, n as doubleKnock, o as parseRfc9421SignatureInput, r as formatRfc9421Signature, s as signRequest, t as createRfc9421SignatureBase, u as verifyRequestDetailed } from "../http-BKrXOLjL.mjs";
12
12
  import { i as rsaPrivateKey2, l as rsaPublicKey5, o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-BAK-tUlf.mjs";
13
13
  import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
14
14
  import { FetchError, exportSpki } from "@fedify/vocab-runtime";
@@ -5,7 +5,7 @@ import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
5
  import "../std__assert-Duiq_YC9.mjs";
6
6
  import { t as assertRejects } from "../assert_rejects-B-qJtC9Z.mjs";
7
7
  import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
8
- import { a as importJwk, i as generateCryptoKeyPair, n as fetchKey, o as validateCryptoKey, r as fetchKeyDetailed, t as exportJwk } from "../key-CCuaH5jy.mjs";
8
+ import { a as importJwk, i as generateCryptoKeyPair, n as fetchKey, o as validateCryptoKey, r as fetchKeyDetailed, t as exportJwk } from "../key-CwG1d1a2.mjs";
9
9
  import { c as rsaPublicKey3, i as rsaPrivateKey2, o as rsaPublicKey1, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-BAK-tUlf.mjs";
10
10
  import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
11
11
  import { CryptographicKey, Multikey } from "@fedify/vocab";
@@ -5,9 +5,9 @@ import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
5
  import { n as assertFalse, t as assertRejects } from "../assert_rejects-B-qJtC9Z.mjs";
6
6
  import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
7
7
  import { t as assert } from "../assert-ddO5KLpe.mjs";
8
- import { i as generateCryptoKeyPair } from "../key-CCuaH5jy.mjs";
8
+ import { i as generateCryptoKeyPair } from "../key-CwG1d1a2.mjs";
9
9
  import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-BAK-tUlf.mjs";
10
- import { a as signJsonLd, i as hasSignatureLike, n as createSignature, o as verifyJsonLd, r as detachSignature, s as verifySignature, t as attachSignature } from "../ld-DN2lsaG8.mjs";
10
+ import { a as signJsonLd, i as hasSignatureLike, n as createSignature, o as verifyJsonLd, r as detachSignature, s as verifySignature, t as attachSignature } from "../ld-t2WD3nYp.mjs";
11
11
  import { mockDocumentLoader, test } from "@fedify/fixture";
12
12
  import { CryptographicKey } from "@fedify/vocab";
13
13
  import { encodeBase64 } from "byte-encodings/base64";
package/dist/sig/mod.cjs CHANGED
@@ -1,8 +1,8 @@
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_http = require("../http-BMsHAyvq.cjs");
5
- const require_proof = require("../proof-3RKiVMZP.cjs");
4
+ const require_http = require("../http-C1BAaJ_m.cjs");
5
+ const require_proof = require("../proof-0fe_hpBU.cjs");
6
6
  exports.attachSignature = require_proof.attachSignature;
7
7
  exports.createProof = require_proof.createProof;
8
8
  exports.createSignature = require_proof.createSignature;
package/dist/sig/mod.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
- import { a as verifyRequestDetailed, c as fetchKeyDetailed, f as formatAcceptSignature, h as validateAcceptSignature, i as verifyRequest, l as generateCryptoKeyPair, m as parseAcceptSignature, o as exportJwk, p as fulfillAcceptSignature, r as signRequest, s as fetchKey, u as importJwk } from "../http-CxVGLNoz.js";
4
- import { a as verifyProof, c as attachSignature, d as hasSignatureLike, f as signJsonLd, i as verifyObject, l as createSignature, m as verifySignature, n as hasProofLike, o as doesActorOwnKey, p as verifyJsonLd, r as signObject, s as getKeyOwner, t as createProof, u as detachSignature } from "../proof-0cJIZBgO.js";
3
+ import { a as verifyRequestDetailed, c as fetchKeyDetailed, f as formatAcceptSignature, h as validateAcceptSignature, i as verifyRequest, l as generateCryptoKeyPair, m as parseAcceptSignature, o as exportJwk, p as fulfillAcceptSignature, r as signRequest, s as fetchKey, u as importJwk } from "../http-DI4R9CTK.js";
4
+ import { a as verifyProof, c as getKeyOwner, d as detachSignature, f as hasSignatureLike, h as verifySignature, i as verifyObject, l as attachSignature, m as verifyJsonLd, n as hasProofLike, p as signJsonLd, r as signObject, s as doesActorOwnKey, t as createProof, u as createSignature } from "../proof-DJiXN7Qc.js";
5
5
  export { attachSignature, createProof, createSignature, detachSignature, doesActorOwnKey, exportJwk, fetchKey, fetchKeyDetailed, formatAcceptSignature, fulfillAcceptSignature, generateCryptoKeyPair, getKeyOwner, hasProofLike, hasSignatureLike, importJwk, parseAcceptSignature, signJsonLd, signObject, signRequest, validateAcceptSignature, verifyJsonLd, verifyObject, verifyProof, verifyRequest, verifyRequestDetailed, verifySignature };
@@ -6,7 +6,7 @@ import "../std__assert-Duiq_YC9.mjs";
6
6
  import { n as assertFalse } from "../assert_rejects-B-qJtC9Z.mjs";
7
7
  import { t as assert } from "../assert-ddO5KLpe.mjs";
8
8
  import { o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-BAK-tUlf.mjs";
9
- import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-B34dTvD2.mjs";
9
+ import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-J1wYUBAp.mjs";
10
10
  import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
11
11
  import { Create, CryptographicKey, lookupObject } from "@fedify/vocab";
12
12
  //#region src/sig/owner.test.ts
@@ -7,9 +7,10 @@ import { n as assertFalse, t as assertRejects } from "../assert_rejects-B-qJtC9Z
7
7
  import { t as assertInstanceOf } from "../assert_instance_of-C4Ri6VuN.mjs";
8
8
  import { t as assert } from "../assert-ddO5KLpe.mjs";
9
9
  import { i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-BAK-tUlf.mjs";
10
- import { a as verifyProof, i as verifyObject, n as hasProofLike, r as signObject, t as createProof } from "../proof-grJLXdIM.mjs";
10
+ import { t as normalizePublicAudience } from "../public-audience-5WWE-JTr.mjs";
11
+ import { a as verifyProof, i as verifyObject, n as hasProofLike, r as signObject, t as createProof } from "../proof-DngAmXc3.mjs";
11
12
  import { mockDocumentLoader, test } from "@fedify/fixture";
12
- import { Create, DataIntegrityProof, Multikey, Note, Place } from "@fedify/vocab";
13
+ import { Create, DataIntegrityProof, Multikey, Note, PUBLIC_COLLECTION, Place } from "@fedify/vocab";
13
14
  import { decodeMultibase, importMultibaseKey } from "@fedify/vocab-runtime";
14
15
  import { decodeHex } from "byte-encodings/hex";
15
16
  //#region src/sig/proof.test.ts
@@ -151,6 +152,39 @@ test("signObject()", async () => {
151
152
  created,
152
153
  contextLoader: mockDocumentLoader
153
154
  }), TypeError, "Unsupported algorithm");
155
+ const signed = await signObject(new Create({
156
+ id: new URL("https://server.example/activities/2"),
157
+ actor: new URL("https://server.example/users/alice"),
158
+ object: new Note({
159
+ id: new URL("https://server.example/objects/2"),
160
+ attribution: new URL("https://server.example/users/alice"),
161
+ content: "Hello public"
162
+ }),
163
+ tos: [PUBLIC_COLLECTION]
164
+ }), fep8b32TestVectorPrivateKey, fep8b32TestVectorKeyId, {
165
+ ...options,
166
+ created
167
+ });
168
+ const [proof] = await Array.fromAsync(signed.getProofs(options));
169
+ assertInstanceOf(proof, DataIntegrityProof);
170
+ const signedJson = await normalizePublicAudience(await signed.toJsonLd(options), mockDocumentLoader);
171
+ assertEquals(signedJson.to, PUBLIC_COLLECTION.href);
172
+ const verifyCache = {};
173
+ const verifyOptions = {
174
+ contextLoader: mockDocumentLoader,
175
+ documentLoader: mockDocumentLoader,
176
+ keyCache: {
177
+ get: (keyId) => Promise.resolve(verifyCache[keyId.href]),
178
+ set: (keyId, key) => {
179
+ verifyCache[keyId.href] = key;
180
+ return Promise.resolve();
181
+ }
182
+ }
183
+ };
184
+ assertInstanceOf(await verifyProof(signedJson, proof, verifyOptions), Multikey);
185
+ const signedJsonWithCurie = await signed.toJsonLd(options);
186
+ assertEquals(signedJsonWithCurie.to, "as:Public");
187
+ assertInstanceOf(await verifyProof(signedJsonWithCurie, proof, verifyOptions), Multikey);
154
188
  });
155
189
  test("hasProofLike()", () => {
156
190
  assert(hasProofLike({ proof: {
@@ -252,6 +286,30 @@ test("verifyProof()", async () => {
252
286
  }
253
287
  }, proof, options), null);
254
288
  assertEquals(await verifyProof(jsonLd, proof.clone({ created: Temporal.Now.instant() }), options), null);
289
+ assertEquals(await verifyProof({
290
+ ...jsonLd,
291
+ "https://w3id.org/security#proof": {
292
+ "@type": ["https://w3id.org/security#DataIntegrityProof"],
293
+ "https://w3id.org/security#proofValue": [{ "@value": "stale" }]
294
+ }
295
+ }, proof, options), expectedKey);
296
+ assertEquals(await verifyProof([jsonLd], proof, options), null);
297
+ assertEquals(await verifyProof({
298
+ "@context": ["https://www.w3.org/ns/activitystreams", "https://attacker.example/ctx"],
299
+ id: "https://server.example/activities/attacker",
300
+ type: "Create",
301
+ actor: "https://server.example/users/alice",
302
+ object: {
303
+ id: "https://server.example/objects/attacker",
304
+ type: "Note",
305
+ attributedTo: "https://server.example/users/alice",
306
+ content: "n/a",
307
+ to: "as:Public"
308
+ }
309
+ }, proof, {
310
+ documentLoader: mockDocumentLoader,
311
+ keyCache: options.keyCache
312
+ }), null);
255
313
  });
256
314
  test("verifyObject()", async () => {
257
315
  const options = {
@@ -5,9 +5,9 @@ import { t as esm_default } from "../esm-DVILvP5e.mjs";
5
5
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
6
6
  import "../std__assert-Duiq_YC9.mjs";
7
7
  import { t as assertRejects } from "../assert_rejects-B-qJtC9Z.mjs";
8
- import { l as verifyRequest } from "../http-6m2N3LCD.mjs";
8
+ import { l as verifyRequest } from "../http-BKrXOLjL.mjs";
9
9
  import { i as rsaPrivateKey2 } from "../keys-BAK-tUlf.mjs";
10
- import { t as getAuthenticatedDocumentLoader } from "../docloader-CXAw1Ofx.mjs";
10
+ import { t as getAuthenticatedDocumentLoader } from "../docloader-CAcGw6pQ.mjs";
11
11
  import { mockDocumentLoader, test } from "@fedify/fixture";
12
12
  import { UrlError } from "@fedify/vocab-runtime";
13
13
  //#region src/utils/docloader.test.ts
@@ -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-D0srbjWc.cjs");
4
+ const require_kv_cache = require("../kv-cache-p33MTfBu.cjs");
5
5
  exports.getAuthenticatedDocumentLoader = require_kv_cache.getAuthenticatedDocumentLoader;
6
6
  exports.kvCache = require_kv_cache.kvCache;
package/dist/utils/mod.js CHANGED
@@ -1,4 +1,4 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
- import { n as getAuthenticatedDocumentLoader, t as kvCache } from "../kv-cache-CBQPqEDj.js";
3
+ import { n as getAuthenticatedDocumentLoader, t as kvCache } from "../kv-cache-BQS2P8gv.js";
4
4
  export { getAuthenticatedDocumentLoader, kvCache };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/fedify",
3
- "version": "2.2.0-pr.708.19+4267edbb",
3
+ "version": "2.2.0-pr.710.22+527afb16",
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.2.0-pr.708.19+4267edbb",
148
- "@fedify/vocab-runtime": "2.2.0-pr.708.19+4267edbb",
149
- "@fedify/webfinger": "2.2.0-pr.708.19+4267edbb"
147
+ "@fedify/vocab": "2.2.0-pr.710.22+527afb16",
148
+ "@fedify/webfinger": "2.2.0-pr.710.22+527afb16",
149
+ "@fedify/vocab-runtime": "2.2.0-pr.710.22+527afb16"
150
150
  },
151
151
  "devDependencies": {
152
152
  "@std/assert": "npm:@jsr/std__assert@^0.226.0",
@@ -159,7 +159,7 @@
159
159
  "typescript": "^5.9.2",
160
160
  "wrangler": "^4.17.0",
161
161
  "@fedify/fixture": "2.0.0",
162
- "@fedify/vocab-tools": "^2.2.0-pr.708.19+4267edbb"
162
+ "@fedify/vocab-tools": "^2.2.0-pr.710.22+527afb16"
163
163
  },
164
164
  "scripts": {
165
165
  "build:self": "tsdown",
File without changes
File without changes
File without changes