@fedify/fedify 2.4.0-dev.1995 → 2.4.0-dev.2027
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/dist/{assert-CebeUf0C.mjs → assert-D1Eafmd_.mjs} +1 -1
- package/dist/{assert_equals-CBlRfA-_.mjs → assert_equals-Z6IcEbWU.mjs} +2 -28
- package/dist/{assert_exists-DtzkXC47.mjs → assert_exists-cffSpJ7X.mjs} +1 -1
- package/dist/{assert_false-3pLLLsO4.mjs → assert_false-CPdRnc3E.mjs} +1 -1
- package/dist/{assert_greater_or_equal-BApOTh1h.mjs → assert_greater_or_equal-BlafOF4-.mjs} +2 -1
- package/dist/{assert_instance_of-g3WcyYNR.mjs → assert_instance_of-mrXWWNY-.mjs} +1 -1
- package/dist/{assert_not_equals-BN7yDMWe.mjs → assert_not_equals-CpPK2t89.mjs} +2 -1
- package/dist/{assert_rejects-wFbSPn1O.mjs → assert_rejects-CTptdYck.mjs} +2 -2
- package/dist/{assert_strict_equals-Bpjl4Psw.mjs → assert_strict_equals-CYvBmkpC.mjs} +2 -1
- package/dist/{assert_throws-BJ5wuvR2.mjs → assert_throws-BYITOvPO.mjs} +2 -1
- package/dist/assertion_error-B-cx0fFA.mjs +31 -0
- package/dist/{builder-D0DxgOV5.mjs → builder-BM255b90.mjs} +2 -2
- package/dist/compat/outgoing-jsonld.test.mjs +71 -3
- package/dist/compat/public-audience.test.mjs +3 -3
- package/dist/compat/secured-document.test.d.mts +2 -0
- package/dist/compat/secured-document.test.mjs +58 -0
- package/dist/compat/transformers.test.mjs +4 -4
- package/dist/{compound-proof-CJnWc6c-.mjs → compound-proof-CPvNisT2.mjs} +1 -1
- package/dist/{deno-CABhzCb_.mjs → deno-BcZNXlJn.mjs} +1 -1
- package/dist/{docloader-BbGSL0Xq.mjs → docloader-iHi0-9mK.mjs} +2 -2
- package/dist/federation/builder.test.mjs +5 -5
- package/dist/federation/circuit-breaker.test.mjs +3 -3
- package/dist/federation/collection.test.mjs +2 -2
- package/dist/federation/compound-fanout.test.d.mts +2 -0
- package/dist/federation/compound-fanout.test.mjs +228 -0
- package/dist/federation/handler-compound-proof.test.mjs +5 -5
- package/dist/federation/handler.test.mjs +11 -11
- package/dist/federation/idempotency.test.mjs +4 -4
- package/dist/federation/inbox.test.mjs +2 -2
- package/dist/federation/keycache.test.mjs +3 -3
- package/dist/federation/kv.test.mjs +2 -2
- package/dist/federation/metrics.test.mjs +4 -4
- package/dist/federation/middleware.test.mjs +17 -17
- package/dist/federation/mod.cjs +1 -1
- package/dist/federation/mod.js +1 -1
- package/dist/federation/mq.test.mjs +7 -6
- package/dist/federation/negotiation.test.mjs +3 -3
- package/dist/federation/retry.test.mjs +3 -2
- package/dist/federation/router.test.mjs +5 -5
- package/dist/federation/send.test.mjs +11 -11
- package/dist/federation/tasks/enqueue.test.mjs +1 -1
- package/dist/federation/tasks/tasks.test.mjs +2 -2
- package/dist/federation/temporal.test.mjs +4 -4
- package/dist/federation/webfinger.test.mjs +4 -4
- package/dist/{federation-DCEHQk4G.cjs → federation-C0ijTwhx.cjs} +21 -5
- package/dist/{http-CRFns-UE.cjs → http-CWXKwHPv.cjs} +1 -1
- package/dist/{http-9WyuldYh.js → http-KZWtR1H8.js} +1 -1
- package/dist/{http-D9urSO2D.mjs → http-fIK5D83n.mjs} +3 -3
- package/dist/{key-Ccs8cnd7.mjs → key-Xb1hVVZO.mjs} +2 -2
- package/dist/{kv-cache-lKyFn_Dn.mjs → kv-cache-CU1rmQFB.mjs} +1 -1
- package/dist/{kv-cache-DXT9vmIg.cjs → kv-cache-Dos4tOWb.cjs} +1 -1
- package/dist/{kv-cache-DtmXhPXG.js → kv-cache-HOO6BsuW.js} +1 -1
- package/dist/{ld-qup__MAW.mjs → ld-DFHvxLtx.mjs} +3 -3
- package/dist/{metrics-CISXCvB1.mjs → metrics-D7RydU_p.mjs} +1 -1
- package/dist/{middleware-CzvJvPHK.mjs → middleware-BsYD_ufs.mjs} +32 -16
- package/dist/{middleware-DkrU2WhY.mjs → middleware-DgU5bJnn.mjs} +1 -1
- package/dist/{middleware-DsfWajaD.js → middleware-iffqYoTV.js} +21 -5
- package/dist/{mod-UDwMjuHM.d.ts → mod-CNRAxXEb.d.ts} +1 -5
- package/dist/{mod-CbKDOnCt.d.cts → mod-CVQFWefn.d.cts} +1 -5
- package/dist/mod.cjs +4 -4
- package/dist/mod.d.cts +1 -1
- package/dist/mod.d.ts +1 -1
- package/dist/mod.js +4 -4
- package/dist/nodeinfo/client.test.mjs +2 -2
- package/dist/nodeinfo/handler.test.mjs +3 -3
- package/dist/nodeinfo/types.test.mjs +3 -3
- package/dist/otel/exporter.test.mjs +2 -2
- package/dist/{outgoing-jsonld-B5Ne7JoL.mjs → outgoing-jsonld-4IJqPYos.mjs} +11 -9
- package/dist/{owner-BIPEZGiU.js → owner-B7lgRMdU.js} +127 -35
- package/dist/{owner-CRoq8Spb.mjs → owner-D53bUI-n.mjs} +2 -2
- package/dist/{owner-CVA7L9MA.cjs → owner-DffLVeYC.cjs} +126 -34
- package/dist/{proof-BDxNVZ3E.mjs → proof-4ADU3qy0.mjs} +80 -23
- package/dist/{public-audience-Cc2YJ3ip.mjs → public-audience--klBIOk1.mjs} +13 -9
- package/dist/secured-document-CxzZZ9nL.mjs +35 -0
- package/dist/{send-BzM5GLyn.mjs → send-n-W6bG7y.mjs} +3 -3
- package/dist/sig/compound-proof-discovery.test.mjs +3 -3
- package/dist/sig/compound-proof-verification.test.mjs +5 -5
- package/dist/sig/compound-proof.test.mjs +145 -58
- package/dist/sig/http.test.mjs +11 -10
- package/dist/sig/key.test.mjs +6 -6
- package/dist/sig/ld.test.mjs +9 -9
- package/dist/sig/mod.cjs +2 -2
- package/dist/sig/mod.d.cts +1 -1
- package/dist/sig/mod.d.ts +1 -1
- package/dist/sig/mod.js +2 -2
- package/dist/sig/owner.test.mjs +5 -5
- package/dist/sig/proof.test.mjs +9 -9
- package/dist/std__assert-DvMDRPes.mjs +8 -0
- package/dist/{temporal-Dv6Qv-8k.mjs → temporal-BFUyXrYg.mjs} +1 -1
- package/dist/testing/kv.test.mjs +2 -2
- package/dist/utils/docloader.test.mjs +5 -5
- 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 +6 -6
- package/dist/std__assert-CxFT0MNt.mjs +0 -8
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { Temporal } from "temporal-polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
5
|
-
import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-
|
|
6
|
-
import { r as fetchKey, s as validateCryptoKey } from "./key-
|
|
7
|
-
import { n as preloadedOnlyDocumentLoader } from "./public-audience
|
|
8
|
-
import { r as normalizeOutgoingActivityJsonLd } from "./outgoing-jsonld-
|
|
9
|
-
import { c as getNormalizationContextLoader } from "./ld-
|
|
4
|
+
import { n as version, t as name } from "./deno-BcZNXlJn.mjs";
|
|
5
|
+
import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-D7RydU_p.mjs";
|
|
6
|
+
import { r as fetchKey, s as validateCryptoKey } from "./key-Xb1hVVZO.mjs";
|
|
7
|
+
import { n as preloadedOnlyDocumentLoader } from "./public-audience--klBIOk1.mjs";
|
|
8
|
+
import { r as normalizeOutgoingActivityJsonLd } from "./outgoing-jsonld-4IJqPYos.mjs";
|
|
9
|
+
import { c as getNormalizationContextLoader } from "./ld-DFHvxLtx.mjs";
|
|
10
10
|
import { getLogger } from "@logtape/logtape";
|
|
11
11
|
import { Activity, DataIntegrityProof, Multikey, getTypeId } from "@fedify/vocab";
|
|
12
12
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
13
|
-
import { formatIri, getDocumentLoader, getFe34Origin, haveSameFe34Origin, parseIri } from "@fedify/vocab-runtime";
|
|
13
|
+
import { encodeMultibase, formatIri, getDocumentLoader, getFe34Origin, haveSameFe34Origin, parseIri } from "@fedify/vocab-runtime";
|
|
14
14
|
import { encodeHex } from "byte-encodings/hex";
|
|
15
15
|
import jsonld from "@fedify/vocab-runtime/jsonld";
|
|
16
|
+
import { isPlainJsonTree, retainSignedRepresentation } from "@fedify/vocab-runtime/internal/signed-representation";
|
|
16
17
|
import serialize from "json-canon";
|
|
17
18
|
//#region src/sig/proof.ts
|
|
18
19
|
/**
|
|
@@ -68,17 +69,49 @@ function hasProofLike(jsonLd) {
|
|
|
68
69
|
};
|
|
69
70
|
return Array.isArray(proof) ? proof.some(isProofLike) : isProofLike(proof);
|
|
70
71
|
}
|
|
72
|
+
function isJsonMap(value) {
|
|
73
|
+
return typeof value === "object" && value != null && !Array.isArray(value);
|
|
74
|
+
}
|
|
71
75
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* @
|
|
78
|
-
*
|
|
79
|
-
*
|
|
76
|
+
* Assembles the secured JSON document from the bytes that were just signed.
|
|
77
|
+
*
|
|
78
|
+
* The document is not re-derived from the vocabulary object: it is
|
|
79
|
+
* `compactMsg`, the value whose JCS form was hashed, with the serialized
|
|
80
|
+
* proof added. Every part of it is then checked against the digests and the
|
|
81
|
+
* signature that {@link createProofInternal} produced, so a document that is
|
|
82
|
+
* returned verifies under the map-local compound-proof profile by
|
|
83
|
+
* construction. Anything that does not check out yields `null`, and the
|
|
84
|
+
* caller simply does not retain a representation.
|
|
80
85
|
*/
|
|
81
|
-
async function
|
|
86
|
+
async function captureSecuredDocument(proof, compactMsg, msgCanon, proofCanon, proofValue, contextLoader) {
|
|
87
|
+
if (!isJsonMap(compactMsg)) return null;
|
|
88
|
+
const documentContext = compactMsg["@context"];
|
|
89
|
+
if (documentContext == null) return null;
|
|
90
|
+
if (globalThis.Object.hasOwn(compactMsg, "proof")) return null;
|
|
91
|
+
try {
|
|
92
|
+
const proofJson = await proof.toJsonLd({
|
|
93
|
+
format: "compact",
|
|
94
|
+
contextLoader,
|
|
95
|
+
context: documentContext
|
|
96
|
+
});
|
|
97
|
+
if (!isJsonMap(proofJson)) return null;
|
|
98
|
+
const { proofValue: serializedProofValue, ...proofConfiguration } = proofJson;
|
|
99
|
+
if (serializedProofValue !== proofValue) return null;
|
|
100
|
+
if (serialize(proofConfiguration) !== proofCanon) return null;
|
|
101
|
+
const securedDocument = {
|
|
102
|
+
...structuredClone(compactMsg),
|
|
103
|
+
proof: structuredClone(proofJson)
|
|
104
|
+
};
|
|
105
|
+
const { proof: _embeddedProof, ...unsecuredDocument } = securedDocument;
|
|
106
|
+
if (serialize(unsecuredDocument) !== msgCanon) return null;
|
|
107
|
+
if (!isPlainJsonTree(securedDocument)) return null;
|
|
108
|
+
return securedDocument;
|
|
109
|
+
} catch (error) {
|
|
110
|
+
logger.debug("Failed to capture the secured JSON document for a created proof; the signed object will not preserve its representation when it is embedded in another object.\n{error}", { error });
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async function createProofInternal(object, privateKey, keyId, { contextLoader, context, created } = {}, capture = false) {
|
|
82
115
|
validateCryptoKey(privateKey, "private");
|
|
83
116
|
if (privateKey.algorithm.name !== "Ed25519") throw new TypeError("Unsupported algorithm: " + privateKey.algorithm.name);
|
|
84
117
|
let compactMsg = await object.clone({ proofs: [] }).toJsonLd({
|
|
@@ -86,7 +119,7 @@ async function createProof(object, privateKey, keyId, { contextLoader, context,
|
|
|
86
119
|
contextLoader,
|
|
87
120
|
context
|
|
88
121
|
});
|
|
89
|
-
compactMsg = await normalizeOutgoingActivityJsonLd(compactMsg, contextLoader);
|
|
122
|
+
compactMsg = await normalizeOutgoingActivityJsonLd(compactMsg, contextLoader, { preserveNestedSecuredDocuments: true });
|
|
90
123
|
const msgCanon = serialize(compactMsg);
|
|
91
124
|
const encoder = new TextEncoder();
|
|
92
125
|
const msgBytes = encoder.encode(msgCanon);
|
|
@@ -105,14 +138,32 @@ async function createProof(object, privateKey, keyId, { contextLoader, context,
|
|
|
105
138
|
const digest = new Uint8Array(proofDigest.byteLength + msgDigest.byteLength);
|
|
106
139
|
digest.set(new Uint8Array(proofDigest), 0);
|
|
107
140
|
digest.set(new Uint8Array(msgDigest), proofDigest.byteLength);
|
|
108
|
-
const sig = await crypto.subtle.sign("Ed25519", privateKey, digest);
|
|
109
|
-
|
|
141
|
+
const sig = new Uint8Array(await crypto.subtle.sign("Ed25519", privateKey, digest));
|
|
142
|
+
const proof = new DataIntegrityProof({
|
|
110
143
|
cryptosuite: "eddsa-jcs-2022",
|
|
111
144
|
verificationMethod: keyId,
|
|
112
145
|
proofPurpose: "assertionMethod",
|
|
113
|
-
created
|
|
114
|
-
proofValue:
|
|
146
|
+
created,
|
|
147
|
+
proofValue: sig
|
|
115
148
|
});
|
|
149
|
+
return {
|
|
150
|
+
proof,
|
|
151
|
+
securedDocument: capture ? await captureSecuredDocument(proof, compactMsg, msgCanon, proofCanon, new TextDecoder().decode(encodeMultibase("base58btc", sig)), contextLoader) : null
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Creates a proof for the given object.
|
|
156
|
+
* @param object The object to create a proof for.
|
|
157
|
+
* @param privateKey The private key to sign the proof with.
|
|
158
|
+
* @param keyId The key ID to use in the proof. It will be used by the verifier.
|
|
159
|
+
* @param options Additional options. See also {@link CreateProofOptions}.
|
|
160
|
+
* @returns The created proof.
|
|
161
|
+
* @throws {TypeError} If the private key is invalid or unsupported.
|
|
162
|
+
* @since 0.10.0
|
|
163
|
+
*/
|
|
164
|
+
async function createProof(object, privateKey, keyId, options = {}) {
|
|
165
|
+
const { proof } = await createProofInternal(object, privateKey, keyId, options);
|
|
166
|
+
return proof;
|
|
116
167
|
}
|
|
117
168
|
/**
|
|
118
169
|
* Signs the given object with the private key and returns the signed object.
|
|
@@ -130,13 +181,19 @@ async function signObject(object, privateKey, keyId, options = {}) {
|
|
|
130
181
|
if (object.id != null) span.setAttribute("activitypub.object.id", object.id.href);
|
|
131
182
|
const existingProofs = [];
|
|
132
183
|
for await (const proof of object.getProofs(options)) existingProofs.push(proof);
|
|
133
|
-
const proof = await
|
|
184
|
+
const { proof, securedDocument } = await createProofInternal(object, privateKey, keyId, options, existingProofs.length < 1);
|
|
134
185
|
if (span.isRecording()) {
|
|
135
186
|
if (proof.cryptosuite != null) span.setAttribute("object_integrity_proofs.cryptosuite", proof.cryptosuite);
|
|
136
187
|
if (proof.verificationMethodId != null) span.setAttribute("object_integrity_proofs.key_id", proof.verificationMethodId.href);
|
|
137
188
|
if (proof.proofValue != null) span.setAttribute("object_integrity_proofs.signature", encodeHex(proof.proofValue));
|
|
138
189
|
}
|
|
139
|
-
|
|
190
|
+
const signed = object.clone({ proofs: [...existingProofs, proof] });
|
|
191
|
+
if (securedDocument != null) retainSignedRepresentation(signed, securedDocument);
|
|
192
|
+
else if (existingProofs.length > 0) logger.debug("The object {objectId} already had {proofCount} proof(s), so its signed representation is not retained for embedding; the map-local compound-proof profile accepts exactly one direct proof per map.", {
|
|
193
|
+
objectId: object.id?.href,
|
|
194
|
+
proofCount: existingProofs.length
|
|
195
|
+
});
|
|
196
|
+
return signed;
|
|
140
197
|
} catch (error) {
|
|
141
198
|
span.setStatus({
|
|
142
199
|
code: SpanStatusCode.ERROR,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "temporal-polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
+
import { t as isSelfContainedSecuredDocument } from "./secured-document-CxzZZ9nL.mjs";
|
|
4
5
|
import { getLogger } from "@logtape/logtape";
|
|
5
6
|
import { PUBLIC_COLLECTION } from "@fedify/vocab";
|
|
6
7
|
import { preloadedContexts } from "@fedify/vocab-runtime";
|
|
@@ -40,37 +41,39 @@ const PUBLIC_ADDRESSING_FIELDS = /* @__PURE__ */ new Set([
|
|
|
40
41
|
const AS_CONTEXT_URL = "https://www.w3.org/ns/activitystreams";
|
|
41
42
|
const MAX_TRAVERSAL_DEPTH = 64;
|
|
42
43
|
const KNOWN_SAFE_CONTEXT_URLS = new Set(Object.keys(preloadedContexts));
|
|
43
|
-
function hasPublicCurieInAddressing(value, parentKey, depth = 0) {
|
|
44
|
+
function hasPublicCurieInAddressing(value, preserveSecured, parentKey, depth = 0) {
|
|
44
45
|
if (typeof value === "string") return parentKey != null && PUBLIC_ADDRESSING_FIELDS.has(parentKey) && (value === "as:Public" || value === "Public");
|
|
45
46
|
if (depth >= MAX_TRAVERSAL_DEPTH) return false;
|
|
46
|
-
if (Array.isArray(value)) return value.some((item) => hasPublicCurieInAddressing(item, parentKey, depth + 1));
|
|
47
|
+
if (Array.isArray(value)) return value.some((item) => hasPublicCurieInAddressing(item, preserveSecured, parentKey, depth + 1));
|
|
47
48
|
if (typeof value !== "object" || value == null) return false;
|
|
49
|
+
if (preserveSecured && depth > 0 && isSelfContainedSecuredDocument(value)) return false;
|
|
48
50
|
const record = value;
|
|
49
51
|
for (const key of Object.keys(record)) {
|
|
50
52
|
if (record.type === "Follow" && key === "object" && (record[key] === "as:Public" || record[key] === "Public")) return true;
|
|
51
53
|
if (key === "@context") continue;
|
|
52
|
-
if (hasPublicCurieInAddressing(record[key], key, depth + 1)) return true;
|
|
54
|
+
if (hasPublicCurieInAddressing(record[key], preserveSecured, key, depth + 1)) return true;
|
|
53
55
|
}
|
|
54
56
|
return false;
|
|
55
57
|
}
|
|
56
|
-
function rewritePublicAudience(value, parentKey, depth = 0) {
|
|
58
|
+
function rewritePublicAudience(value, preserveSecured, parentKey, depth = 0) {
|
|
57
59
|
if (typeof value === "string" && parentKey != null && PUBLIC_ADDRESSING_FIELDS.has(parentKey) && (value === "as:Public" || value === "Public")) return PUBLIC_COLLECTION.href;
|
|
58
60
|
if (depth >= MAX_TRAVERSAL_DEPTH) return value;
|
|
59
61
|
if (Array.isArray(value)) {
|
|
60
62
|
let changed = false;
|
|
61
63
|
const mapped = value.map((item) => {
|
|
62
|
-
const rewritten = rewritePublicAudience(item, parentKey, depth + 1);
|
|
64
|
+
const rewritten = rewritePublicAudience(item, preserveSecured, parentKey, depth + 1);
|
|
63
65
|
if (rewritten !== item) changed = true;
|
|
64
66
|
return rewritten;
|
|
65
67
|
});
|
|
66
68
|
return changed ? mapped : value;
|
|
67
69
|
}
|
|
68
70
|
if (typeof value !== "object" || value == null) return value;
|
|
71
|
+
if (preserveSecured && depth > 0 && isSelfContainedSecuredDocument(value)) return value;
|
|
69
72
|
const record = value;
|
|
70
73
|
let changed = false;
|
|
71
74
|
const normalized = Object.create(null);
|
|
72
75
|
for (const key of Object.keys(record)) {
|
|
73
|
-
const rewritten = key === "@context" ? record[key] : record.type === "Follow" && key === "object" && (record[key] === "as:Public" || record[key] === "Public") ? PUBLIC_COLLECTION.href : rewritePublicAudience(record[key], key, depth + 1);
|
|
76
|
+
const rewritten = key === "@context" ? record[key] : record.type === "Follow" && key === "object" && (record[key] === "as:Public" || record[key] === "Public") ? PUBLIC_COLLECTION.href : rewritePublicAudience(record[key], preserveSecured, key, depth + 1);
|
|
74
77
|
if (rewritten !== record[key]) changed = true;
|
|
75
78
|
normalized[key] = rewritten;
|
|
76
79
|
}
|
|
@@ -169,9 +172,10 @@ function hasKnownSafeContext(jsonLd) {
|
|
|
169
172
|
* using the `eddsa-jcs-2022` cryptosuite), so the signed payload
|
|
170
173
|
* matches what is sent on the wire.
|
|
171
174
|
*/
|
|
172
|
-
async function normalizePublicAudience(jsonLd, contextLoader) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
+
async function normalizePublicAudience(jsonLd, contextLoader, options = {}) {
|
|
176
|
+
const preserveSecured = options.preserveNestedSecuredDocuments ?? false;
|
|
177
|
+
if (!hasPublicCurieInAddressing(jsonLd, preserveSecured)) return jsonLd;
|
|
178
|
+
const normalized = rewritePublicAudience(jsonLd, preserveSecured);
|
|
175
179
|
if (hasKnownSafeContext(jsonLd)) return normalized;
|
|
176
180
|
const loader = contextLoader ?? preloadedOnlyDocumentLoader;
|
|
177
181
|
try {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import "temporal-polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
globalThis.addEventListener = () => {};
|
|
4
|
+
//#region src/compat/secured-document.ts
|
|
5
|
+
function isJsonMap(value) {
|
|
6
|
+
return typeof value === "object" && value != null && !Array.isArray(value);
|
|
7
|
+
}
|
|
8
|
+
function isNonEmptyString(value) {
|
|
9
|
+
return typeof value === "string" && value.length > 0;
|
|
10
|
+
}
|
|
11
|
+
function hasDataIntegrityProofType(value) {
|
|
12
|
+
return (Array.isArray(value) ? value : [value]).some((type) => type === "DataIntegrityProof" || type === "https://w3id.org/security#DataIntegrityProof");
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Checks whether a JSON value is a complete, self-contained secured document:
|
|
16
|
+
* a map with its own `@context` and exactly one direct, map-valued `proof`
|
|
17
|
+
* that carries every member `eddsa-jcs-2022` proof generation produces.
|
|
18
|
+
*
|
|
19
|
+
* This is deliberately stricter than {@link hasProofLike}, which exists to
|
|
20
|
+
* decide whether a document is worth verifying. Here a false positive would
|
|
21
|
+
* silently suppress a wire-compatibility fix on an ordinary document, so a
|
|
22
|
+
* partial or malformed proof does not qualify.
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
function isSelfContainedSecuredDocument(value) {
|
|
27
|
+
if (!isJsonMap(value)) return false;
|
|
28
|
+
if (!Object.hasOwn(value, "@context") || value["@context"] == null) return false;
|
|
29
|
+
if (!Object.hasOwn(value, "proof")) return false;
|
|
30
|
+
const proof = value.proof;
|
|
31
|
+
if (!isJsonMap(proof)) return false;
|
|
32
|
+
return hasDataIntegrityProofType(proof.type) && isNonEmptyString(proof.cryptosuite) && isNonEmptyString(proof.created) && isNonEmptyString(proof.verificationMethod) && isNonEmptyString(proof.proofPurpose) && isNonEmptyString(proof.proofValue);
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { isSelfContainedSecuredDocument as t };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "temporal-polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
5
|
-
import { n as getDurationMs, r as getFederationMetrics } from "./metrics-
|
|
6
|
-
import { n as doubleKnock } from "./http-
|
|
4
|
+
import { n as version, t as name } from "./deno-BcZNXlJn.mjs";
|
|
5
|
+
import { n as getDurationMs, r as getFederationMetrics } from "./metrics-D7RydU_p.mjs";
|
|
6
|
+
import { n as doubleKnock } from "./http-fIK5D83n.mjs";
|
|
7
7
|
import { getLogger } from "@logtape/logtape";
|
|
8
8
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
9
9
|
import { FetchError, UrlError, validatePublicUrl } from "@fedify/vocab-runtime";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "temporal-polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { t as assertEquals } from "../assert_equals-
|
|
5
|
-
import "../std__assert-
|
|
6
|
-
import { n as inspectCompoundPortableObjectApplicability, t as discoverCompoundProofDocuments } from "../compound-proof-
|
|
4
|
+
import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
|
|
5
|
+
import "../std__assert-DvMDRPes.mjs";
|
|
6
|
+
import { n as inspectCompoundPortableObjectApplicability, t as discoverCompoundProofDocuments } from "../compound-proof-CPvNisT2.mjs";
|
|
7
7
|
import { t as map_local_create_note_default } from "../map-local-create-note-B0SeXJms.mjs";
|
|
8
8
|
import { test } from "@fedify/fixture";
|
|
9
9
|
//#region src/sig/compound-proof-discovery.test.ts
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import "temporal-polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { t as assertEquals } from "../assert_equals-
|
|
5
|
-
import "../std__assert-
|
|
6
|
-
import { t as assert } from "../assert-
|
|
7
|
-
import { i as verifyMapLocalProof, s as verifyPortableObjectProofPolicy } from "../proof-
|
|
8
|
-
import { i as verifyCompoundProofDocuments, r as verifyCompoundPortableObjectProofs } from "../compound-proof-
|
|
4
|
+
import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
|
|
5
|
+
import "../std__assert-DvMDRPes.mjs";
|
|
6
|
+
import { t as assert } from "../assert-D1Eafmd_.mjs";
|
|
7
|
+
import { i as verifyMapLocalProof, s as verifyPortableObjectProofPolicy } from "../proof-4ADU3qy0.mjs";
|
|
8
|
+
import { i as verifyCompoundProofDocuments, r as verifyCompoundPortableObjectProofs } from "../compound-proof-CPvNisT2.mjs";
|
|
9
9
|
import { t as map_local_create_note_default } from "../map-local-create-note-B0SeXJms.mjs";
|
|
10
10
|
import { t as map_local_context_conflict_default } from "../map-local-context-conflict-DOYEEJ3u.mjs";
|
|
11
11
|
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { Temporal } from "temporal-polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { t as assertEquals } from "../assert_equals-
|
|
5
|
-
import "../std__assert-
|
|
6
|
-
import { t as assert } from "../assert-
|
|
4
|
+
import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
|
|
5
|
+
import "../std__assert-DvMDRPes.mjs";
|
|
6
|
+
import { t as assert } from "../assert-D1Eafmd_.mjs";
|
|
7
7
|
import { n as ed25519PrivateKey, r as ed25519PublicKey } from "../keys-DIJNHW-Y.mjs";
|
|
8
|
-
import { n as preloadedOnlyDocumentLoader } from "../public-audience
|
|
9
|
-
import { r as normalizeOutgoingActivityJsonLd } from "../outgoing-jsonld-
|
|
10
|
-
import { c as verifyProof, r as signObject } from "../proof-
|
|
8
|
+
import { n as preloadedOnlyDocumentLoader } from "../public-audience--klBIOk1.mjs";
|
|
9
|
+
import { r as normalizeOutgoingActivityJsonLd } from "../outgoing-jsonld-4IJqPYos.mjs";
|
|
10
|
+
import { c as verifyProof, r as signObject } from "../proof-4ADU3qy0.mjs";
|
|
11
|
+
import { i as verifyCompoundProofDocuments } from "../compound-proof-CPvNisT2.mjs";
|
|
11
12
|
import { t as map_local_create_note_default } from "../map-local-create-note-B0SeXJms.mjs";
|
|
12
13
|
import { t as map_local_context_conflict_default } from "../map-local-context-conflict-DOYEEJ3u.mjs";
|
|
13
|
-
import { Create, DataIntegrityProof, Note } from "@fedify/vocab";
|
|
14
|
+
import { Create, DataIntegrityProof, Note, Question } from "@fedify/vocab";
|
|
14
15
|
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
15
16
|
import { encodeMultibase, exportDidKey, parseIri } from "@fedify/vocab-runtime";
|
|
16
17
|
import { encodeHex } from "byte-encodings/hex";
|
|
@@ -46,6 +47,16 @@ const options = {
|
|
|
46
47
|
contextLoader: mockDocumentLoader,
|
|
47
48
|
documentLoader: mockDocumentLoader
|
|
48
49
|
};
|
|
50
|
+
const inboundOptions = {
|
|
51
|
+
contextLoader: preloadedOnlyDocumentLoader,
|
|
52
|
+
documentLoader: preloadedOnlyDocumentLoader
|
|
53
|
+
};
|
|
54
|
+
const compoundLimits = {
|
|
55
|
+
maxDepth: 16,
|
|
56
|
+
maxMaps: 32,
|
|
57
|
+
maxProofs: 8,
|
|
58
|
+
maxBytes: 16384
|
|
59
|
+
};
|
|
49
60
|
async function parseProof(document) {
|
|
50
61
|
const proof = document.proof;
|
|
51
62
|
assert(proof != null && typeof proof === "object" && !Array.isArray(proof));
|
|
@@ -171,10 +182,6 @@ test("the context-conflict vector records valid proofs and divergent semantics",
|
|
|
171
182
|
hashes: map_local_context_conflict_default.hashes.inner,
|
|
172
183
|
proofValue: map_local_context_conflict_default.proofValues.inner
|
|
173
184
|
});
|
|
174
|
-
const inboundOptions = {
|
|
175
|
-
contextLoader: preloadedOnlyDocumentLoader,
|
|
176
|
-
documentLoader: preloadedOnlyDocumentLoader
|
|
177
|
-
};
|
|
178
185
|
const verifiedInner = await verifyProof(embedded, await parseProof(embedded), inboundOptions);
|
|
179
186
|
assertEquals(verifiedInner != null, map_local_context_conflict_default.expectedVerification.original.inner);
|
|
180
187
|
assertEquals(verifiedInner?.id, conflictVectorInnerKeyId);
|
|
@@ -226,10 +233,9 @@ test("the raw same-context baseline verifies map-locally", async () => {
|
|
|
226
233
|
assertEquals(replacementInnerKey?.id, vectorInnerKeyId);
|
|
227
234
|
assertEquals(await verifyProof(replaced, await parseProof(replaced), options) != null, map_local_create_note_default.expectedVerification.replacedInnerProof.outer);
|
|
228
235
|
});
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
id: parseIri(`ap+ef61://${innerDid}/objects/distinct-context`),
|
|
236
|
+
async function signDistinctContextNote(created, path) {
|
|
237
|
+
return await signObject(new Note({
|
|
238
|
+
id: parseIri(`ap+ef61://${innerDid}/objects/${path}`),
|
|
233
239
|
attribution: parseIri(`ap+ef61://${innerDid}/actor`),
|
|
234
240
|
content: "A portable note with its own context"
|
|
235
241
|
}), ed25519PrivateKey, innerKeyId, {
|
|
@@ -237,65 +243,131 @@ test("typed Create serialization bypasses a parsed child's JSON-LD cache", async
|
|
|
237
243
|
context: distinctInnerContext,
|
|
238
244
|
created
|
|
239
245
|
});
|
|
240
|
-
|
|
246
|
+
}
|
|
247
|
+
async function serializeOutgoing(object, context) {
|
|
248
|
+
return await normalizeOutgoingActivityJsonLd(await object.toJsonLd({
|
|
241
249
|
format: "compact",
|
|
242
250
|
...options,
|
|
243
|
-
context:
|
|
244
|
-
}), mockDocumentLoader);
|
|
245
|
-
|
|
246
|
-
|
|
251
|
+
context: context ?? options.context
|
|
252
|
+
}), mockDocumentLoader, { preserveNestedSecuredDocuments: true });
|
|
253
|
+
}
|
|
254
|
+
async function signOuterCreate(created, path, child) {
|
|
255
|
+
return await signObject(new Create({
|
|
256
|
+
id: parseIri(`ap+ef61://${outerDid}/activities/${path}`),
|
|
247
257
|
actor: parseIri(`ap+ef61://${outerDid}/actor`),
|
|
248
|
-
object:
|
|
258
|
+
object: child
|
|
249
259
|
}), outerPrivateKey, outerKeyId, {
|
|
250
260
|
...options,
|
|
251
261
|
created
|
|
252
|
-
})
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
test("typed Create serialization embeds the signed child representation", async () => {
|
|
265
|
+
const created = Temporal.Instant.from("2023-02-24T23:36:38Z");
|
|
266
|
+
const inner = await signDistinctContextNote(created, "distinct-context");
|
|
267
|
+
assert(inner instanceof Note);
|
|
268
|
+
const standaloneInner = await serializeOutgoing(inner, distinctInnerContext);
|
|
269
|
+
const outer = await signOuterCreate(created, "distinct-context", inner);
|
|
270
|
+
assert(outer instanceof Create);
|
|
271
|
+
const compound = await serializeOutgoing(outer);
|
|
256
272
|
const embedded = compound.object;
|
|
257
273
|
const embeddedProof = embedded.proof;
|
|
258
|
-
|
|
259
|
-
assertEquals(
|
|
260
|
-
assertEquals(
|
|
261
|
-
assertEquals(embedded
|
|
262
|
-
assertEquals(
|
|
263
|
-
assertEquals(
|
|
264
|
-
const compactedStandalone = structuredClone(standaloneInner);
|
|
265
|
-
const compactedStandaloneProof = compactedStandalone.proof;
|
|
266
|
-
delete compactedStandalone["@context"];
|
|
267
|
-
delete compactedStandaloneProof["@context"];
|
|
268
|
-
assertEquals(embedded, compactedStandalone);
|
|
269
|
-
assertEquals((await verifyProof(standaloneInner, standaloneProof, options))?.id, innerKeyId);
|
|
270
|
-
const rewrittenContext = structuredClone(standaloneInner);
|
|
271
|
-
rewrittenContext["@context"] = context;
|
|
272
|
-
assertEquals(await verifyProof(rewrittenContext, standaloneProof, options), null);
|
|
273
|
-
assertEquals(await verifyProof(embedded, standaloneProof, options), null);
|
|
274
|
+
assertEquals(embedded["@context"], distinctInnerContext);
|
|
275
|
+
assertEquals(embeddedProof["@context"], distinctInnerContext);
|
|
276
|
+
assertEquals(compound["@context"], context);
|
|
277
|
+
assertEquals(serialize(embedded), serialize(standaloneInner));
|
|
278
|
+
assertEquals(embedded.type, "Note");
|
|
279
|
+
assertEquals((await verifyProof(embedded, await parseProof(embedded), options))?.id, innerKeyId);
|
|
274
280
|
assertEquals((await verifyProof(compound, await parseProof(compound), options))?.id, outerKeyId);
|
|
281
|
+
const mapLocal = await verifyCompoundProofDocuments(compound, compoundLimits, inboundOptions);
|
|
282
|
+
assertEquals(mapLocal.status, "ok");
|
|
283
|
+
assert(mapLocal.status === "ok");
|
|
284
|
+
assert(mapLocal.verified);
|
|
285
|
+
assertEquals(mapLocal.documents.map(({ path, verified }) => ({
|
|
286
|
+
path,
|
|
287
|
+
verified
|
|
288
|
+
})), [{
|
|
289
|
+
path: "/object",
|
|
290
|
+
verified: true
|
|
291
|
+
}, {
|
|
292
|
+
path: "",
|
|
293
|
+
verified: true
|
|
294
|
+
}]);
|
|
295
|
+
});
|
|
296
|
+
test("tampering with an embedded signed child invalidates both proofs", async () => {
|
|
297
|
+
const created = Temporal.Instant.from("2023-02-24T23:36:38Z");
|
|
298
|
+
const tampered = await serializeOutgoing(await signOuterCreate(created, "tampered", await signDistinctContextNote(created, "tampered")));
|
|
299
|
+
const tamperedInner = tampered.object;
|
|
300
|
+
tamperedInner.content = "A tampered portable note";
|
|
301
|
+
assertEquals(await verifyProof(tamperedInner, await parseProof(tamperedInner), options), null);
|
|
302
|
+
assertEquals(await verifyProof(tampered, await parseProof(tampered), options), null);
|
|
303
|
+
});
|
|
304
|
+
test("replacing an embedded child proof invalidates only the outer proof", async () => {
|
|
305
|
+
const created = Temporal.Instant.from("2023-02-24T23:36:38Z");
|
|
306
|
+
const replacementCreated = Temporal.Instant.from("2023-02-25T23:36:38Z");
|
|
307
|
+
const inner = await signDistinctContextNote(created, "replaced-proof");
|
|
308
|
+
const replacementProof = (await serializeOutgoing(await signDistinctContextNote(replacementCreated, "replaced-proof"), distinctInnerContext)).proof;
|
|
309
|
+
const compound = await serializeOutgoing(await signOuterCreate(created, "replaced-proof", inner));
|
|
310
|
+
const replacedInner = compound.object;
|
|
311
|
+
replacedInner.proof = replacementProof;
|
|
312
|
+
assertEquals((await verifyProof(replacedInner, await parseProof(replacedInner), options))?.id, innerKeyId);
|
|
313
|
+
assertEquals(await verifyProof(compound, await parseProof(compound), options), null);
|
|
314
|
+
});
|
|
315
|
+
test("cloning or re-signing a signed child drops its retained representation", async () => {
|
|
316
|
+
const created = Temporal.Instant.from("2023-02-24T23:36:38Z");
|
|
317
|
+
const inner = await signDistinctContextNote(created, "cloned");
|
|
318
|
+
const cloned = inner.clone({});
|
|
319
|
+
assert(cloned instanceof Note);
|
|
320
|
+
const clonedEmbedded = (await serializeOutgoing(await signOuterCreate(created, "cloned", cloned))).object;
|
|
321
|
+
assertEquals(clonedEmbedded["@context"], void 0);
|
|
322
|
+
assertEquals(clonedEmbedded.proof["@context"], void 0);
|
|
323
|
+
const reSignedEmbedded = (await serializeOutgoing(await signOuterCreate(created, "re-signed", await signObject(inner, ed25519PrivateKey, innerKeyId, {
|
|
324
|
+
...options,
|
|
325
|
+
context: distinctInnerContext,
|
|
326
|
+
created
|
|
327
|
+
})))).object;
|
|
328
|
+
assertEquals(reSignedEmbedded["@context"], void 0);
|
|
329
|
+
});
|
|
330
|
+
test("mutating a signed child does not change its embedded representation", async () => {
|
|
331
|
+
const created = Temporal.Instant.from("2023-02-24T23:36:38Z");
|
|
332
|
+
const inner = await signDistinctContextNote(created, "mutated");
|
|
333
|
+
const standaloneInner = await serializeOutgoing(inner, distinctInnerContext);
|
|
334
|
+
const proof = (await Array.fromAsync(inner.getProofs(options)))[0];
|
|
335
|
+
assert(proof.proofValue != null);
|
|
336
|
+
proof.proofValue[0] ^= 255;
|
|
337
|
+
const embedded = (await serializeOutgoing(await signOuterCreate(created, "mutated", inner))).object;
|
|
338
|
+
assertEquals(serialize(embedded), serialize(standaloneInner));
|
|
339
|
+
assertEquals((await verifyProof(embedded, await parseProof(embedded), options))?.id, innerKeyId);
|
|
340
|
+
});
|
|
341
|
+
test("a signed child is embedded through a compactable ancestor too", async () => {
|
|
342
|
+
const inner = await signDistinctContextNote(Temporal.Instant.from("2023-02-24T23:36:38Z"), "compactable-parent");
|
|
343
|
+
const standaloneInner = await serializeOutgoing(inner, distinctInnerContext);
|
|
344
|
+
const wrapper = new Note({
|
|
345
|
+
id: parseIri(`ap+ef61://${innerDid}/objects/wrapper`),
|
|
346
|
+
attachments: [inner]
|
|
347
|
+
});
|
|
348
|
+
const embedded = (await new Question({
|
|
349
|
+
id: parseIri(`ap+ef61://${outerDid}/objects/question`),
|
|
350
|
+
exclusiveOptions: [wrapper]
|
|
351
|
+
}).toJsonLd()).oneOf.attachment;
|
|
352
|
+
assertEquals(serialize(embedded), serialize(standaloneInner));
|
|
353
|
+
assertEquals((await verifyProof(embedded, await parseProof(embedded), options))?.id, innerKeyId);
|
|
354
|
+
});
|
|
355
|
+
test("typed Create serialization bypasses a parsed child's JSON-LD cache", async () => {
|
|
356
|
+
const created = Temporal.Instant.from("2023-02-24T23:36:38Z");
|
|
357
|
+
const standaloneInner = await serializeOutgoing(await signDistinctContextNote(created, "reparsed-context"), distinctInnerContext);
|
|
358
|
+
const standaloneProof = await parseProof(standaloneInner);
|
|
275
359
|
const reparsedInner = await Note.fromJsonLd(standaloneInner, {
|
|
276
360
|
contextLoader: mockDocumentLoader,
|
|
277
361
|
documentLoader: mockDocumentLoader
|
|
278
362
|
});
|
|
279
363
|
assert(reparsedInner instanceof Note);
|
|
280
364
|
assertEquals(await reparsedInner.toJsonLd(), standaloneInner);
|
|
281
|
-
const reparsedCompound = await
|
|
282
|
-
id: parseIri(`ap+ef61://${outerDid}/activities/reparsed-context`),
|
|
283
|
-
actor: parseIri(`ap+ef61://${outerDid}/actor`),
|
|
284
|
-
object: reparsedInner
|
|
285
|
-
}), outerPrivateKey, outerKeyId, {
|
|
286
|
-
...options,
|
|
287
|
-
created
|
|
288
|
-
})).toJsonLd({
|
|
289
|
-
format: "compact",
|
|
290
|
-
...options
|
|
291
|
-
}), mockDocumentLoader);
|
|
365
|
+
const reparsedCompound = await serializeOutgoing(await signOuterCreate(created, "reparsed-context", reparsedInner));
|
|
292
366
|
const reparsedEmbedded = reparsedCompound.object;
|
|
293
367
|
const reparsedEmbeddedProof = reparsedEmbedded.proof;
|
|
294
368
|
assertEquals(reparsedEmbedded["@context"], void 0);
|
|
295
369
|
assertEquals(reparsedEmbeddedProof["@context"], void 0);
|
|
296
370
|
assertEquals(reparsedEmbeddedProof.proofValue, standaloneInner.proof.proofValue);
|
|
297
|
-
assertEquals(reparsedEmbedded, compactedStandalone);
|
|
298
|
-
assertEquals(reparsedEmbedded, embedded);
|
|
299
371
|
assertEquals(await verifyProof(reparsedEmbedded, standaloneProof, options), null);
|
|
300
372
|
assertEquals((await verifyProof(reparsedCompound, await parseProof(reparsedCompound), options))?.id, outerKeyId);
|
|
301
373
|
});
|
|
@@ -305,10 +377,6 @@ test("verifyProof() does not invent a missing child context", async () => {
|
|
|
305
377
|
const receivedInnerProof = receivedInner.proof;
|
|
306
378
|
delete receivedInner["@context"];
|
|
307
379
|
delete receivedInnerProof["@context"];
|
|
308
|
-
const inboundOptions = {
|
|
309
|
-
contextLoader: preloadedOnlyDocumentLoader,
|
|
310
|
-
documentLoader: preloadedOnlyDocumentLoader
|
|
311
|
-
};
|
|
312
380
|
const snapshot = structuredClone(received);
|
|
313
381
|
const proof = await DataIntegrityProof.fromJsonLd(received.proof, inboundOptions);
|
|
314
382
|
assertEquals(await verifyProof(received, proof, inboundOptions), null);
|
|
@@ -320,5 +388,24 @@ test("verifyProof() does not invent a missing child context", async () => {
|
|
|
320
388
|
guessedInnerProof["@context"] = structuredClone(guessed["@context"]);
|
|
321
389
|
assertEquals((await verifyProof(guessed, proof, inboundOptions))?.id, outerKeyId);
|
|
322
390
|
});
|
|
391
|
+
test("signing a document too deep to retain still succeeds", async () => {
|
|
392
|
+
const created = Temporal.Instant.from("2023-02-24T23:36:38Z");
|
|
393
|
+
let deep = new Note({
|
|
394
|
+
id: parseIri(`ap+ef61://${innerDid}/objects/deep-leaf`),
|
|
395
|
+
content: "A portable note nested past the retention bounds"
|
|
396
|
+
});
|
|
397
|
+
for (let i = 0; i < 40; i++) deep = new Note({
|
|
398
|
+
id: parseIri(`ap+ef61://${innerDid}/objects/deep-${i}`),
|
|
399
|
+
attachments: [deep]
|
|
400
|
+
});
|
|
401
|
+
const signed = await signObject(deep, ed25519PrivateKey, innerKeyId, {
|
|
402
|
+
...options,
|
|
403
|
+
context: distinctInnerContext,
|
|
404
|
+
created
|
|
405
|
+
});
|
|
406
|
+
assertEquals((await Array.fromAsync(signed.getProofs(options))).length, 1);
|
|
407
|
+
const embedded = (await serializeOutgoing(await signOuterCreate(created, "deep", signed))).object;
|
|
408
|
+
assertEquals(embedded["@context"], void 0);
|
|
409
|
+
});
|
|
323
410
|
//#endregion
|
|
324
411
|
export {};
|
package/dist/sig/http.test.mjs
CHANGED
|
@@ -2,16 +2,17 @@ import { Temporal } from "temporal-polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { t as esm_default } from "../esm-BHXXx4Wx.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import { t as
|
|
7
|
-
import { t as
|
|
8
|
-
import { t as
|
|
9
|
-
import { t as
|
|
10
|
-
import "../
|
|
11
|
-
import
|
|
12
|
-
import { t as
|
|
13
|
-
import { t as
|
|
14
|
-
import {
|
|
5
|
+
import { t as AssertionError } from "../assertion_error-B-cx0fFA.mjs";
|
|
6
|
+
import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
|
|
7
|
+
import { t as assertExists } from "../assert_exists-cffSpJ7X.mjs";
|
|
8
|
+
import { t as assertFalse } from "../assert_false-CPdRnc3E.mjs";
|
|
9
|
+
import { t as assertGreaterOrEqual } from "../assert_greater_or_equal-BlafOF4-.mjs";
|
|
10
|
+
import { t as assertThrows } from "../assert_throws-BYITOvPO.mjs";
|
|
11
|
+
import "../std__assert-DvMDRPes.mjs";
|
|
12
|
+
import { t as assertRejects } from "../assert_rejects-CTptdYck.mjs";
|
|
13
|
+
import { t as assert } from "../assert-D1Eafmd_.mjs";
|
|
14
|
+
import { t as exportJwk } from "../key-Xb1hVVZO.mjs";
|
|
15
|
+
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-fIK5D83n.mjs";
|
|
15
16
|
import { i as rsaPrivateKey2, l as rsaPublicKey5, o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-DIJNHW-Y.mjs";
|
|
16
17
|
import { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
17
18
|
import { FetchError, exportSpki } from "@fedify/vocab-runtime";
|
package/dist/sig/key.test.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import "temporal-polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { t as assertEquals } from "../assert_equals-
|
|
5
|
-
import { t as assertThrows } from "../assert_throws-
|
|
6
|
-
import "../std__assert-
|
|
7
|
-
import { t as assertRejects } from "../assert_rejects-
|
|
8
|
-
import { t as assert } from "../assert-
|
|
9
|
-
import { a as generateCryptoKeyPair, i as fetchKeyDetailed, o as importJwk, r as fetchKey, s as validateCryptoKey, t as exportJwk } from "../key-
|
|
4
|
+
import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
|
|
5
|
+
import { t as assertThrows } from "../assert_throws-BYITOvPO.mjs";
|
|
6
|
+
import "../std__assert-DvMDRPes.mjs";
|
|
7
|
+
import { t as assertRejects } from "../assert_rejects-CTptdYck.mjs";
|
|
8
|
+
import { t as assert } from "../assert-D1Eafmd_.mjs";
|
|
9
|
+
import { a as generateCryptoKeyPair, i as fetchKeyDetailed, o as importJwk, r as fetchKey, s as validateCryptoKey, t as exportJwk } from "../key-Xb1hVVZO.mjs";
|
|
10
10
|
import { c as rsaPublicKey3, i as rsaPrivateKey2, o as rsaPublicKey1, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DIJNHW-Y.mjs";
|
|
11
11
|
import { CryptographicKey, Multikey } from "@fedify/vocab";
|
|
12
12
|
import { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|