@fedify/fedify 2.5.0-dev.2446 → 2.5.0-dev.2448
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/{activity-listener-C-BSbKI7.mjs → activity-listener-CELFAodc.mjs} +8 -4
- package/dist/{builder-Da8b9O6v.mjs → builder-DbC8bn6k.mjs} +5 -5
- package/dist/compat/mod.d.cts +1 -1
- package/dist/compat/mod.d.ts +1 -1
- package/dist/compat/transformers.test.mjs +1 -1
- package/dist/{compound-proof-D1djO5fa.mjs → compound-proof-heeXW2_A.mjs} +2 -2
- package/dist/{context-CQ9H8vNW.d.cts → context-BazwQrHn.d.cts} +304 -4
- package/dist/{context-8Tu9kea0.mjs → context-COHd1Rsh.mjs} +2 -0
- package/dist/{context-BdB54V-A.d.ts → context-GlHrzdSP.d.ts} +304 -4
- package/dist/{deno-eNpfj4oR.mjs → deno-Dpewt_jJ.mjs} +1 -1
- package/dist/{docloader-B-0nqOB1.mjs → docloader-CpsDyqVN.mjs} +2 -2
- package/dist/federation/builder.test.mjs +1 -1
- package/dist/federation/compound-fanout.test.mjs +3 -3
- package/dist/federation/handler-compound-proof.test.mjs +5 -5
- package/dist/federation/handler.test.mjs +21 -6
- package/dist/federation/hashlink-media.test.mjs +2 -2
- package/dist/federation/idempotency.test.mjs +2 -2
- package/dist/federation/inbox-actorless.test.d.mts +2 -0
- package/dist/federation/inbox-actorless.test.mjs +487 -0
- package/dist/federation/inbox-authentication.test.d.mts +2 -0
- package/dist/federation/inbox-authentication.test.mjs +116 -0
- package/dist/federation/inbox-report.test.mjs +5 -5
- package/dist/federation/inbox-view.test.d.mts +2 -0
- package/dist/federation/inbox-view.test.mjs +369 -0
- package/dist/federation/inbox.test.mjs +22 -12
- package/dist/federation/metrics.test.mjs +1 -1
- package/dist/federation/middleware.test.mjs +9 -9
- package/dist/federation/mod.cjs +2 -1
- package/dist/federation/mod.d.cts +3 -3
- package/dist/federation/mod.d.ts +3 -3
- package/dist/federation/mod.js +8 -2
- package/dist/federation/mq.test.mjs +36 -1
- package/dist/federation/outgoing-proof.test.mjs +4 -4
- package/dist/federation/portable-actor.test.mjs +3 -3
- package/dist/federation/portable-chain.test.mjs +3 -3
- package/dist/federation/portable-collection.test.mjs +4 -4
- package/dist/federation/portable-delivery.test.mjs +2 -2
- package/dist/federation/portable-gateway-keys.test.mjs +6 -6
- package/dist/federation/portable-inbox.test.mjs +4 -4
- package/dist/federation/portable-parse-uri.test.mjs +1 -1
- package/dist/federation/portable-route-activity.test.mjs +2 -2
- package/dist/federation/portable.test.mjs +3 -3
- package/dist/federation/send.test.mjs +3 -3
- package/dist/federation/tasks/enqueue.test.mjs +3 -3
- package/dist/federation/tasks/tasks.test.mjs +4 -4
- package/dist/federation/temporal.test.mjs +1 -1
- package/dist/federation/webfinger.test.mjs +2 -2
- package/dist/{federation-BVH7drJA.cjs → federation-D8YexkP1.cjs} +1172 -131
- package/dist/{http-DlNxxW_5.js → http-BBr-VLil.js} +143 -16
- package/dist/{http-BUJ5SFh6.mjs → http-BZkyQIkb.mjs} +4 -4
- package/dist/{http-BfW3wyQ4.cjs → http-CAl7Num5.cjs} +161 -16
- package/dist/inbox-authentication-DflPYlLL.mjs +171 -0
- package/dist/inbox-view-NE9wXdLo.mjs +385 -0
- package/dist/inbox-wDuMKaFW.mjs +312 -0
- package/dist/{kv-cache-D_m3A241.mjs → kv-cache-CTQSfkmp.mjs} +1 -1
- package/dist/{kv-cache-kkBB0vbI.cjs → kv-cache-CjgCOz3i.cjs} +1 -1
- package/dist/{kv-cache-7015lbrx.js → kv-cache-U7uz5nx4.js} +1 -1
- package/dist/{ld-CD2CsPxq.mjs → ld-CQFuiah9.mjs} +52 -9
- package/dist/ld-CcuZ4NZa.d.ts +250 -0
- package/dist/ld-Cel1RRZ5.d.cts +250 -0
- package/dist/{metrics-D3LHk6Z4.mjs → metrics-B-QxRSSR.mjs} +1 -1
- package/dist/{middleware-CCDXvXOG.mjs → middleware-BdlNa8BD.mjs} +1 -1
- package/dist/{middleware-CzoWvrdZ.mjs → middleware-CuVa0UuS.mjs} +459 -98
- package/dist/{middleware-N9eM16XE.js → middleware-P-AZEQMn.js} +1169 -141
- package/dist/mod-B2783_3v.d.cts +154 -0
- package/dist/mod-BHQE-7WQ.d.ts +154 -0
- package/dist/{mod-D0bxB8jS.d.ts → mod-DjZfJj9R.d.ts} +1 -1
- package/dist/{mod-B0dGgQsg.d.cts → mod-DvWOv2Ho.d.cts} +1 -1
- package/dist/mod.cjs +5 -4
- package/dist/mod.d.cts +6 -6
- package/dist/mod.d.ts +6 -6
- package/dist/mod.js +5 -5
- package/dist/{mq-Dm1Wmtm-.mjs → mq-eF96QxUT.mjs} +6 -0
- package/dist/nodeinfo/handler.test.mjs +2 -2
- package/dist/{owner-C5-FVX6t.mjs → owner-ccKkQOAf.mjs} +3 -3
- package/dist/{portable-collection-Cony3_LC.mjs → portable-collection-CndnpXfo.mjs} +2 -2
- package/dist/{portable-collection-CC2zNAje.js → portable-collection-DUlQ3s2M.js} +1 -1
- package/dist/{portable-collection-C-Z1SKDy.cjs → portable-collection-TC-kvkVI.cjs} +1 -1
- package/dist/{portable-key-DNc_flH-.mjs → portable-key-D5tFOoV-.mjs} +1 -1
- package/dist/{proof-Cryb1c70.mjs → proof-DPoF06nz.mjs} +98 -10
- package/dist/{send-AF25pWaJ.mjs → send-CF44O1Df.mjs} +3 -3
- package/dist/sig/compound-proof-discovery.test.mjs +1 -1
- package/dist/sig/compound-proof-producer.test.mjs +1 -1
- package/dist/sig/compound-proof-verification.test.mjs +2 -2
- package/dist/sig/compound-proof.test.mjs +2 -2
- package/dist/sig/http.test.mjs +2 -2
- package/dist/sig/key.test.mjs +1 -1
- package/dist/sig/ld.test.mjs +1 -1
- package/dist/sig/mitra-receive-interop.test.mjs +4 -4
- package/dist/sig/mitra-send-interop.test.mjs +3 -3
- 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 +1 -1
- package/dist/sig/portable-collection.test.mjs +1 -1
- package/dist/sig/portable-interop.test.mjs +3 -3
- package/dist/sig/portable-key.test.mjs +5 -5
- package/dist/sig/proof.test.mjs +44 -4
- package/dist/sig/tootik-request-interop.test.mjs +4 -4
- package/dist/sig/tootik-send-interop.test.mjs +3 -3
- package/dist/sig/verification.test.mjs +3 -3
- package/dist/{temporal-BsAeuUJj.mjs → temporal-XlZ4Wb94.mjs} +1 -1
- package/dist/testing/kv.test.mjs +1 -1
- package/dist/testing/mod.d.mts +262 -2
- package/dist/testing/mod.mjs +2 -2
- package/dist/{testing-t8xDeJZ5.mjs → testing-Dbr21vZk.mjs} +1 -1
- package/dist/utils/docloader.test.mjs +2 -2
- package/dist/utils/kv-cache.test.mjs +1 -1
- package/dist/utils/mod.cjs +1 -1
- package/dist/utils/mod.js +1 -1
- package/package.json +7 -7
- package/dist/inbox-CHvMaIFX.mjs +0 -188
- package/dist/mod-BRpER-B0.d.ts +0 -320
- package/dist/mod-xAfaLS4T.d.cts +0 -320
- package/dist/owner-BF0L9cMt.d.cts +0 -78
- package/dist/owner-BSzr5-I8.d.ts +0 -78
|
@@ -3,7 +3,7 @@ import { URLPattern } from "urlpattern-polyfill";
|
|
|
3
3
|
import { getLogger } from "@logtape/logtape";
|
|
4
4
|
import { Activity, CryptographicKey, DataIntegrityProof, Multikey, Object as Object$1, PUBLIC_COLLECTION, getTypeId, isActor } from "@fedify/vocab";
|
|
5
5
|
import { SpanKind, SpanStatusCode, metrics, trace } from "@opentelemetry/api";
|
|
6
|
-
import { FetchError, UrlError, canonicalizePortableUri, encodeMultibase, formatIri, fromCompatibleEf61Id, getDocumentLoader, getFe34Origin, isGatewayUrl, parseDidKeyVerificationMethod, parseGatewayUrl, parseIri, preloadedContexts, toCompatibleEf61Id } from "@fedify/vocab-runtime";
|
|
6
|
+
import { FetchError, UrlError, canonicalizePortableUri, encodeMultibase, formatIri, fromCompatibleEf61Id, getDocumentLoader, getFe34Origin, isGatewayUrl, isTransientFetchError, parseDidKeyVerificationMethod, parseGatewayUrl, parseIri, preloadedContexts, toCompatibleEf61Id } from "@fedify/vocab-runtime";
|
|
7
7
|
import { getPortableGatewayCandidates, isCompatibleEf61Iri } from "@fedify/vocab-runtime/internal/portable-dereference";
|
|
8
8
|
import { encodeHex } from "byte-encodings/hex";
|
|
9
9
|
import jsonld from "@fedify/vocab-runtime/jsonld";
|
|
@@ -15,7 +15,7 @@ import serialize from "json-canon";
|
|
|
15
15
|
import { ATTR_HTTP_REQUEST_HEADER, ATTR_HTTP_REQUEST_METHOD, ATTR_URL_FULL } from "@opentelemetry/semantic-conventions";
|
|
16
16
|
//#region deno.json
|
|
17
17
|
var name = "@fedify/fedify";
|
|
18
|
-
var version = "2.5.0-dev.
|
|
18
|
+
var version = "2.5.0-dev.2448+756933d0";
|
|
19
19
|
//#endregion
|
|
20
20
|
//#region src/sig/portable-key-id.ts
|
|
21
21
|
const COMPATIBLE_KEY_ID_PATH_PATTERN = /^\/\.well-known\/apgateway\/did(?::|%3A)/i;
|
|
@@ -1616,6 +1616,7 @@ async function fetchActorDocumentInternal(actorId, options, propagateContextFetc
|
|
|
1616
1616
|
actorId: actorId.href,
|
|
1617
1617
|
error
|
|
1618
1618
|
});
|
|
1619
|
+
if (propagateContextFetchErrors) throw new KeyContextFetchError(error);
|
|
1619
1620
|
return null;
|
|
1620
1621
|
}
|
|
1621
1622
|
let object;
|
|
@@ -2562,8 +2563,26 @@ function createMemoizedDocumentLoader(documentLoader) {
|
|
|
2562
2563
|
return cloneRemoteDocument(await remoteDocument);
|
|
2563
2564
|
};
|
|
2564
2565
|
}
|
|
2566
|
+
const effectiveContextLoaderPolicies = /* @__PURE__ */ new WeakMap();
|
|
2567
|
+
/**
|
|
2568
|
+
* Marks a context loader as the *effective* loader of a policy, i.e., one
|
|
2569
|
+
* that already applies what {@link wrapContextLoaderForJsonLd} (`"standard"`)
|
|
2570
|
+
* or {@link getNormalizationContextLoader} (`"normalization"`) would add.
|
|
2571
|
+
* Those functions return a marked loader as is instead of wrapping it again,
|
|
2572
|
+
* so that a caller can observe every response a parse actually uses,
|
|
2573
|
+
* including Fedify's own baseline contexts.
|
|
2574
|
+
* @param loader The effective context loader.
|
|
2575
|
+
* @param policy The policy the loader already applies.
|
|
2576
|
+
* @returns The given loader.
|
|
2577
|
+
* @internal
|
|
2578
|
+
*/
|
|
2579
|
+
function markEffectiveContextLoader(loader, policy) {
|
|
2580
|
+
effectiveContextLoaderPolicies.set(loader, policy);
|
|
2581
|
+
return loader;
|
|
2582
|
+
}
|
|
2565
2583
|
/** @internal */
|
|
2566
2584
|
function wrapContextLoaderForJsonLd(contextLoader) {
|
|
2585
|
+
if (contextLoader != null && effectiveContextLoaderPolicies.has(contextLoader)) return contextLoader;
|
|
2567
2586
|
const loader = contextLoader ?? builtInContextLoader;
|
|
2568
2587
|
return async (url, options) => {
|
|
2569
2588
|
try {
|
|
@@ -2577,6 +2596,7 @@ function wrapContextLoaderForJsonLd(contextLoader) {
|
|
|
2577
2596
|
}
|
|
2578
2597
|
/** @internal */
|
|
2579
2598
|
function getNormalizationContextLoader(contextLoader) {
|
|
2599
|
+
if (contextLoader != null && effectiveContextLoaderPolicies.get(contextLoader) === "normalization") return contextLoader;
|
|
2580
2600
|
const loader = wrapContextLoaderForJsonLd(contextLoader);
|
|
2581
2601
|
return createMemoizedDocumentLoader(async (url, options) => {
|
|
2582
2602
|
if (URL.canParse(url)) {
|
|
@@ -3029,10 +3049,17 @@ function getLdSignatureObject(jsonLd) {
|
|
|
3029
3049
|
* @returns `true` if the document is authentic; `false` otherwise.
|
|
3030
3050
|
*/
|
|
3031
3051
|
async function verifyJsonLd(jsonLd, options = {}) {
|
|
3032
|
-
return await verifyJsonLdInternal(jsonLd, options, true);
|
|
3052
|
+
return (await verifyJsonLdInternal(jsonLd, options, true)).verified;
|
|
3033
3053
|
}
|
|
3034
|
-
/**
|
|
3035
|
-
|
|
3054
|
+
/**
|
|
3055
|
+
* Same as {@link verifyCompactJsonLd}, but also returns the key that verified
|
|
3056
|
+
* the signature, whose `owner` {@link fetchKey} has confirmed.
|
|
3057
|
+
* @param jsonLd The compacted JSON-LD document to verify.
|
|
3058
|
+
* @param options Options for verifying the JSON-LD document.
|
|
3059
|
+
* @returns The result.
|
|
3060
|
+
* @internal
|
|
3061
|
+
*/
|
|
3062
|
+
async function verifyCompactJsonLdDetailed(jsonLd, options = {}) {
|
|
3036
3063
|
return await verifyJsonLdInternal(jsonLd, options, false);
|
|
3037
3064
|
}
|
|
3038
3065
|
async function verifyJsonLdInternal(jsonLd, options, compact) {
|
|
@@ -3042,7 +3069,7 @@ async function verifyJsonLdInternal(jsonLd, options, compact) {
|
|
|
3042
3069
|
}, "linkedData", (observation) => verifyJsonLdInternal(jsonLd, {
|
|
3043
3070
|
...options,
|
|
3044
3071
|
[verificationObservation]: observation
|
|
3045
|
-
}, compact), (value) => value);
|
|
3072
|
+
}, compact), (value) => value.verified);
|
|
3046
3073
|
const observation = options[verificationObservation];
|
|
3047
3074
|
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("ld_signatures.verify", async (span) => {
|
|
3048
3075
|
const start = performance.now();
|
|
@@ -3074,12 +3101,18 @@ async function verifyJsonLdInternal(jsonLd, options, compact) {
|
|
|
3074
3101
|
const key = await verifySignature(compacted, verificationOptions);
|
|
3075
3102
|
if (key == null) {
|
|
3076
3103
|
if (observation?.attempt != null && !hasLdSignatureProperty(jsonLd)) observation.attempt.reason = { type: "noSignature" };
|
|
3077
|
-
return
|
|
3104
|
+
return {
|
|
3105
|
+
verified: false,
|
|
3106
|
+
key: null
|
|
3107
|
+
};
|
|
3078
3108
|
}
|
|
3079
3109
|
if (key.ownerId == null) {
|
|
3080
3110
|
if (observation?.attempt != null) observation.attempt.reason = { type: "missingOwner" };
|
|
3081
3111
|
logger$4.debug("Key {keyId} has no owner.", { keyId: key.id?.href });
|
|
3082
|
-
return
|
|
3112
|
+
return {
|
|
3113
|
+
verified: false,
|
|
3114
|
+
key: null
|
|
3115
|
+
};
|
|
3083
3116
|
}
|
|
3084
3117
|
attributions.delete(key.ownerId.href);
|
|
3085
3118
|
if (attributions.size > 0) {
|
|
@@ -3088,10 +3121,16 @@ async function verifyJsonLdInternal(jsonLd, options, compact) {
|
|
|
3088
3121
|
attributionIds: [...attributions].map((id) => new URL(id))
|
|
3089
3122
|
};
|
|
3090
3123
|
logger$4.debug("Some attributions are not authenticated by the Linked Data Signatures: {attributions}.", { attributions: [...attributions] });
|
|
3091
|
-
return
|
|
3124
|
+
return {
|
|
3125
|
+
verified: false,
|
|
3126
|
+
key: null
|
|
3127
|
+
};
|
|
3092
3128
|
}
|
|
3093
3129
|
verified = true;
|
|
3094
|
-
return
|
|
3130
|
+
return {
|
|
3131
|
+
verified: true,
|
|
3132
|
+
key
|
|
3133
|
+
};
|
|
3095
3134
|
} catch (error) {
|
|
3096
3135
|
threw = true;
|
|
3097
3136
|
span.setStatus({
|
|
@@ -4172,6 +4211,12 @@ async function verifyProofInternal(jsonLd, proof, options, messageDigestCache, r
|
|
|
4172
4211
|
keyId: proof.verificationMethodId.href,
|
|
4173
4212
|
error
|
|
4174
4213
|
});
|
|
4214
|
+
const check = options[verificationObservation]?.check;
|
|
4215
|
+
if (check != null && check.reason == null) check.reason = {
|
|
4216
|
+
type: "keyFetchError",
|
|
4217
|
+
keyId: new URL(proof.verificationMethodId.href),
|
|
4218
|
+
result: { error: error instanceof Error ? error : new Error(String(error)) }
|
|
4219
|
+
};
|
|
4175
4220
|
return null;
|
|
4176
4221
|
}
|
|
4177
4222
|
const publicKey = fetchedKey.key;
|
|
@@ -4700,6 +4745,39 @@ async function verifyPreparedPortableObjectProof(jsonLd, prepared, options, mess
|
|
|
4700
4745
|
* @since 0.10.0
|
|
4701
4746
|
*/
|
|
4702
4747
|
async function verifyObject(cls, jsonLd, options = {}) {
|
|
4748
|
+
const result = await verifyObjectDetailed(cls, jsonLd, options);
|
|
4749
|
+
return result.status === "verified" ? result.object : null;
|
|
4750
|
+
}
|
|
4751
|
+
/**
|
|
4752
|
+
* Same as {@link verifyObject}, but also tells who signed the verified proofs,
|
|
4753
|
+
* and whether a failure was caused by a key that could not be obtained for
|
|
4754
|
+
* a retryable reason.
|
|
4755
|
+
* @param cls The class of the object to verify.
|
|
4756
|
+
* @param jsonLd The JSON-LD object to verify.
|
|
4757
|
+
* @param options Additional options.
|
|
4758
|
+
* @returns The result.
|
|
4759
|
+
* @throws {TypeError} If the object is invalid or unsupported.
|
|
4760
|
+
* @internal
|
|
4761
|
+
*/
|
|
4762
|
+
async function verifyObjectDetailed(cls, jsonLd, options = {}) {
|
|
4763
|
+
const classify = (result, checks) => {
|
|
4764
|
+
if (result != null) return {
|
|
4765
|
+
status: "verified",
|
|
4766
|
+
object: result.object,
|
|
4767
|
+
signers: result.signers
|
|
4768
|
+
};
|
|
4769
|
+
for (const check of checks) {
|
|
4770
|
+
if (check.status === "error" && isTransientFetchError(check.error)) return {
|
|
4771
|
+
status: "unavailable",
|
|
4772
|
+
error: check.error
|
|
4773
|
+
};
|
|
4774
|
+
if (check.status === "rejected" && check.reason.type === "keyFetchError" && isRetryableKeyFetchError(check.reason.result)) return {
|
|
4775
|
+
status: "unavailable",
|
|
4776
|
+
error: "error" in check.reason.result ? check.reason.result.error : /* @__PURE__ */ new Error(`Fetching key ${check.reason.keyId.href} failed with ${check.reason.result.status}.`)
|
|
4777
|
+
};
|
|
4778
|
+
}
|
|
4779
|
+
return { status: "invalid" };
|
|
4780
|
+
};
|
|
4703
4781
|
if (options[verificationObservation]?.attempt == null) {
|
|
4704
4782
|
const observedOptions = {
|
|
4705
4783
|
...options,
|
|
@@ -4711,16 +4789,16 @@ async function verifyObject(cls, jsonLd, options = {}) {
|
|
|
4711
4789
|
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("object_integrity_proofs.verify_object", async (span) => {
|
|
4712
4790
|
try {
|
|
4713
4791
|
return await observeAttempt(observedOptions, "objectIntegrity", async (observation) => {
|
|
4714
|
-
const
|
|
4792
|
+
const result = await verifyObjectCore(cls, jsonLd, {
|
|
4715
4793
|
...options,
|
|
4716
4794
|
[verificationObservation]: observation
|
|
4717
4795
|
});
|
|
4718
|
-
if (
|
|
4796
|
+
if (result == null) {
|
|
4719
4797
|
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
4720
4798
|
span.setAttribute("activitypub.verification.failure_reason", observation.attempt?.reason?.type ?? "signatureVerificationFailed");
|
|
4721
4799
|
}
|
|
4722
|
-
return
|
|
4723
|
-
}, (value) => value
|
|
4800
|
+
return classify(result, observation.attempt?.checks ?? []);
|
|
4801
|
+
}, (value) => value.status === "verified");
|
|
4724
4802
|
} catch (error) {
|
|
4725
4803
|
span.setStatus({
|
|
4726
4804
|
code: SpanStatusCode.ERROR,
|
|
@@ -4732,6 +4810,15 @@ async function verifyObject(cls, jsonLd, options = {}) {
|
|
|
4732
4810
|
}
|
|
4733
4811
|
});
|
|
4734
4812
|
}
|
|
4813
|
+
const checks = options[verificationObservation].attempt.checks;
|
|
4814
|
+
const before = checks.length;
|
|
4815
|
+
return classify(await verifyObjectCore(cls, jsonLd, options), checks.slice(before));
|
|
4816
|
+
}
|
|
4817
|
+
function isRetryableKeyFetchError(result) {
|
|
4818
|
+
if ("error" in result) return isTransientFetchError(result.error);
|
|
4819
|
+
return result.status >= 500 || result.status === 408 || result.status === 429;
|
|
4820
|
+
}
|
|
4821
|
+
async function verifyObjectCore(cls, jsonLd, options) {
|
|
4735
4822
|
const observation = options[verificationObservation];
|
|
4736
4823
|
const logger = getLogger([
|
|
4737
4824
|
"fedify",
|
|
@@ -4744,6 +4831,7 @@ async function verifyObject(cls, jsonLd, options = {}) {
|
|
|
4744
4831
|
const defaultDocumentLoader = getDocumentLoader();
|
|
4745
4832
|
const proofContextLoader = options.contextLoader ?? defaultDocumentLoader;
|
|
4746
4833
|
const attributions = new Set(object.attributionIds.map((uri) => uri.href));
|
|
4834
|
+
const signers = [];
|
|
4747
4835
|
if (object instanceof Activity) for (const uri of object.actorIds) attributions.add(uri.href);
|
|
4748
4836
|
const rawProofValues = isJsonLdNode(jsonLd) ? await getRawProofValues(jsonLd, proofContextLoader) : [];
|
|
4749
4837
|
const rawProofCandidates = isJsonLdNode(jsonLd) ? await parseRawProofCandidates(jsonLd, rawProofValues, options, proofContextLoader) : [];
|
|
@@ -4802,6 +4890,11 @@ async function verifyObject(cls, jsonLd, options = {}) {
|
|
|
4802
4890
|
continue;
|
|
4803
4891
|
}
|
|
4804
4892
|
deleteAuthenticatedAttribution(attributions, key.controllerId, proof.verificationMethodId);
|
|
4893
|
+
const signer = getAuthenticatedController(key.controllerId, proof.verificationMethodId);
|
|
4894
|
+
if (signer != null && !signers.some((s) => s.kind === signer.kind && s.id.href === signer.id.href && s.keyId.href === proof.verificationMethodId.href)) signers.push({
|
|
4895
|
+
...signer,
|
|
4896
|
+
keyId: proof.verificationMethodId
|
|
4897
|
+
});
|
|
4805
4898
|
}
|
|
4806
4899
|
if (acceptedPortableProofs < loadedPortableProofs) {
|
|
4807
4900
|
logger.debug("Some portable proof references could not be dereferenced.");
|
|
@@ -4815,7 +4908,41 @@ async function verifyObject(cls, jsonLd, options = {}) {
|
|
|
4815
4908
|
logger.debug("Some attributions are not authenticated by the proofs: {attributions}.", { attributions: [...attributions] });
|
|
4816
4909
|
return null;
|
|
4817
4910
|
}
|
|
4818
|
-
return
|
|
4911
|
+
return {
|
|
4912
|
+
object,
|
|
4913
|
+
signers
|
|
4914
|
+
};
|
|
4915
|
+
}
|
|
4916
|
+
/**
|
|
4917
|
+
* Tells whom a key that verified an Object Integrity Proof authenticates.
|
|
4918
|
+
* @param key The key, i.e., the proof's verification method.
|
|
4919
|
+
* @returns The signer, or `null` if the key authenticates nobody.
|
|
4920
|
+
* @internal
|
|
4921
|
+
*/
|
|
4922
|
+
function getProofSigner(key) {
|
|
4923
|
+
if (key.id == null || key.controllerId == null) return null;
|
|
4924
|
+
const signer = getAuthenticatedController(key.controllerId, key.id);
|
|
4925
|
+
return signer == null ? null : {
|
|
4926
|
+
...signer,
|
|
4927
|
+
keyId: key.id
|
|
4928
|
+
};
|
|
4929
|
+
}
|
|
4930
|
+
/**
|
|
4931
|
+
* Tells whom a verified proof authenticates: the key's controller if it is an
|
|
4932
|
+
* ordinary actor, or the DID of a portable controller if the verification
|
|
4933
|
+
* method belongs to the same DID.
|
|
4934
|
+
*/
|
|
4935
|
+
function getAuthenticatedController(controllerId, verificationMethodId) {
|
|
4936
|
+
if (!hasCryptographicOrigin(controllerId.href) && !isPortableId(controllerId)) return {
|
|
4937
|
+
kind: "actor",
|
|
4938
|
+
id: controllerId
|
|
4939
|
+
};
|
|
4940
|
+
const did = getPortableDid(controllerId);
|
|
4941
|
+
if (did == null || !hasCryptographicOrigin(verificationMethodId.href) || getPortableDid(verificationMethodId) !== did || !URL.canParse(did)) return null;
|
|
4942
|
+
return {
|
|
4943
|
+
kind: "portableAuthority",
|
|
4944
|
+
id: new URL(did)
|
|
4945
|
+
};
|
|
4819
4946
|
}
|
|
4820
4947
|
function deleteAuthenticatedAttribution(attributions, controllerId, verificationMethodId) {
|
|
4821
4948
|
if (!hasCryptographicOrigin(controllerId.href) && !isPortableId(controllerId)) {
|
|
@@ -6670,4 +6797,4 @@ function timingSafeEqual(a, b) {
|
|
|
6670
6797
|
return result === 0;
|
|
6671
6798
|
}
|
|
6672
6799
|
//#endregion
|
|
6673
|
-
export {
|
|
6800
|
+
export { getVerifiedKeyOwnerEvidence as $, compactJsonLd as A, getRawCanonicalPortableId as At, verifyCompactJsonLdDetailed as B, verifyPortableObjectProofWithRoot as C, observeAttempt as Ct, InvalidContextReferenceError as D, getCanonicalPortableId as Dt, normalizeOutgoingActivityJsonLd as E, getAuthenticationOrigin as Et, hasSignatureLike as F, isPortableUri as Ft, fetchActorDocument as G, verifySignature as H, isClearlyMalformedContextReference as I, isSameObjectId as It, generateCryptoKeyPair as J, fetchKey as K, isInvalidUrlTypeError as L, isSamePublicKey as Lt, detachSignature as M, isCompatibleKeyId as Mt, getNormalizationContextLoader as N, isPortableId as Nt, assertSafeJsonLd as O, getGatewayKeyBase as Ot, hasSignature as P, isPortableKeyId as Pt, MAX_PORTABLE_KEY_TTL as Q, markEffectiveContextLoader as R, name as Rt, verifyPortableObjectProofPolicy as S, validateAcceptSignature as St, verifyProof as T, verificationObservation as Tt, wrapContextLoaderForJsonLd as U, verifyJsonLd as V, exportJwk as W, validateCryptoKey as X, importJwk as Y, verifyKeyOwnership as Z, signObject as _, registerQueueDepthGauge as _t, signRequest as a, isAbortError$1 as at, verifyObjectDetailed as b, fulfillAcceptSignature as bt, verifyRequestDetailed as c, recordCollectionPageItems as ct, InvalidPortableObjectIdError as d, recordDocumentCache as dt, parseKeyOwnerEvidence as et, classifyFep2277CoreType as f, recordFanoutRecipients as ft, preparePortableObjectProofPolicy as g, recordWebFingerHandle as gt, hasProofLike as h, recordOutboxEnqueue as ht, selectRequestSignature as i, instrumentDocumentLoader as it, createSignature as j, hasPortableActor as jt, attachSignature as k, getPortableDid as kt, fetchPortableGatewayKey as l, recordCollectionRequest as lt, getProofSigner as m, recordOutboxActivity as mt, listRequestSignatures as n, getFederationMetrics as nt, validateMaxSignatures as o, recordCircuitBreakerStateChange as ot, createProof as p, recordInboxActivity as pt, fetchKeyDetailed as q, parseRfc9421SignatureInput as r, getRemoteHost as rt, verifyRequest as s, recordCollectionDispatchDuration as st, doubleKnock as t, getDurationMs as tt, resolvePortableActorKey as u, recordCollectionTotalItems as ut, verifyMapLocalProof as v, preloadedOnlyDocumentLoader as vt, verifyPreparedPortableObjectProofPolicy as w, snapshotKey as wt, verifyPortableObjectProof as x, parseAcceptSignature as xt, verifyObject as y, formatAcceptSignature as yt, signJsonLd as z, version as zt };
|
|
@@ -3,12 +3,12 @@ import "urlpattern-polyfill";
|
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { m as parseKeyIdString } from "./portable-key-id-Ca30-hOa.mjs";
|
|
5
5
|
import { a as verificationObservation, i as triedKey, n as observeCheck, t as observeAttempt } from "./verification-Dpfcw8ml.mjs";
|
|
6
|
-
import { n as version, t as name } from "./deno-
|
|
7
|
-
import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-
|
|
6
|
+
import { n as version, t as name } from "./deno-Dpewt_jJ.mjs";
|
|
7
|
+
import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-B-QxRSSR.mjs";
|
|
8
8
|
import { i as validateAcceptSignature, n as fulfillAcceptSignature, r as parseAcceptSignature } from "./accept-CPVqki78.mjs";
|
|
9
9
|
import { a as promoteKeyOwnerEvidence } from "./key-owner-evidence-APB6NpSk.mjs";
|
|
10
|
-
import {
|
|
11
|
-
import { n as resolvePortableActorKey, r as verifyPortableGatewayKeyDocument } from "./portable-key-
|
|
10
|
+
import { D as validateCryptoKey, b as bypassKeyCacheReads, w as fetchKeyDetailed } from "./ld-CQFuiah9.mjs";
|
|
11
|
+
import { n as resolvePortableActorKey, r as verifyPortableGatewayKeyDocument } from "./portable-key-D5tFOoV-.mjs";
|
|
12
12
|
import { getLogger } from "@logtape/logtape";
|
|
13
13
|
import { CryptographicKey } from "@fedify/vocab";
|
|
14
14
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
@@ -17,7 +17,7 @@ json_canon = require_rolldown_runtime.__toESM(json_canon, 1);
|
|
|
17
17
|
let _opentelemetry_semantic_conventions = require("@opentelemetry/semantic-conventions");
|
|
18
18
|
//#region deno.json
|
|
19
19
|
var name = "@fedify/fedify";
|
|
20
|
-
var version = "2.5.0-dev.
|
|
20
|
+
var version = "2.5.0-dev.2448+756933d0";
|
|
21
21
|
//#endregion
|
|
22
22
|
//#region src/sig/portable-key-id.ts
|
|
23
23
|
const COMPATIBLE_KEY_ID_PATH_PATTERN = /^\/\.well-known\/apgateway\/did(?::|%3A)/i;
|
|
@@ -5184,6 +5184,7 @@ async function fetchActorDocumentInternal(actorId, options, propagateContextFetc
|
|
|
5184
5184
|
actorId: actorId.href,
|
|
5185
5185
|
error
|
|
5186
5186
|
});
|
|
5187
|
+
if (propagateContextFetchErrors) throw new KeyContextFetchError(error);
|
|
5187
5188
|
return null;
|
|
5188
5189
|
}
|
|
5189
5190
|
let object;
|
|
@@ -6130,8 +6131,26 @@ function createMemoizedDocumentLoader(documentLoader) {
|
|
|
6130
6131
|
return cloneRemoteDocument(await remoteDocument);
|
|
6131
6132
|
};
|
|
6132
6133
|
}
|
|
6134
|
+
const effectiveContextLoaderPolicies = /* @__PURE__ */ new WeakMap();
|
|
6135
|
+
/**
|
|
6136
|
+
* Marks a context loader as the *effective* loader of a policy, i.e., one
|
|
6137
|
+
* that already applies what {@link wrapContextLoaderForJsonLd} (`"standard"`)
|
|
6138
|
+
* or {@link getNormalizationContextLoader} (`"normalization"`) would add.
|
|
6139
|
+
* Those functions return a marked loader as is instead of wrapping it again,
|
|
6140
|
+
* so that a caller can observe every response a parse actually uses,
|
|
6141
|
+
* including Fedify's own baseline contexts.
|
|
6142
|
+
* @param loader The effective context loader.
|
|
6143
|
+
* @param policy The policy the loader already applies.
|
|
6144
|
+
* @returns The given loader.
|
|
6145
|
+
* @internal
|
|
6146
|
+
*/
|
|
6147
|
+
function markEffectiveContextLoader(loader, policy) {
|
|
6148
|
+
effectiveContextLoaderPolicies.set(loader, policy);
|
|
6149
|
+
return loader;
|
|
6150
|
+
}
|
|
6133
6151
|
/** @internal */
|
|
6134
6152
|
function wrapContextLoaderForJsonLd(contextLoader) {
|
|
6153
|
+
if (contextLoader != null && effectiveContextLoaderPolicies.has(contextLoader)) return contextLoader;
|
|
6135
6154
|
const loader = contextLoader ?? builtInContextLoader;
|
|
6136
6155
|
return async (url, options) => {
|
|
6137
6156
|
try {
|
|
@@ -6145,6 +6164,7 @@ function wrapContextLoaderForJsonLd(contextLoader) {
|
|
|
6145
6164
|
}
|
|
6146
6165
|
/** @internal */
|
|
6147
6166
|
function getNormalizationContextLoader(contextLoader) {
|
|
6167
|
+
if (contextLoader != null && effectiveContextLoaderPolicies.get(contextLoader) === "normalization") return contextLoader;
|
|
6148
6168
|
const loader = wrapContextLoaderForJsonLd(contextLoader);
|
|
6149
6169
|
return createMemoizedDocumentLoader(async (url, options) => {
|
|
6150
6170
|
if (URL.canParse(url)) {
|
|
@@ -6597,10 +6617,17 @@ function getLdSignatureObject(jsonLd) {
|
|
|
6597
6617
|
* @returns `true` if the document is authentic; `false` otherwise.
|
|
6598
6618
|
*/
|
|
6599
6619
|
async function verifyJsonLd(jsonLd, options = {}) {
|
|
6600
|
-
return await verifyJsonLdInternal(jsonLd, options, true);
|
|
6620
|
+
return (await verifyJsonLdInternal(jsonLd, options, true)).verified;
|
|
6601
6621
|
}
|
|
6602
|
-
/**
|
|
6603
|
-
|
|
6622
|
+
/**
|
|
6623
|
+
* Same as {@link verifyCompactJsonLd}, but also returns the key that verified
|
|
6624
|
+
* the signature, whose `owner` {@link fetchKey} has confirmed.
|
|
6625
|
+
* @param jsonLd The compacted JSON-LD document to verify.
|
|
6626
|
+
* @param options Options for verifying the JSON-LD document.
|
|
6627
|
+
* @returns The result.
|
|
6628
|
+
* @internal
|
|
6629
|
+
*/
|
|
6630
|
+
async function verifyCompactJsonLdDetailed(jsonLd, options = {}) {
|
|
6604
6631
|
return await verifyJsonLdInternal(jsonLd, options, false);
|
|
6605
6632
|
}
|
|
6606
6633
|
async function verifyJsonLdInternal(jsonLd, options, compact) {
|
|
@@ -6610,7 +6637,7 @@ async function verifyJsonLdInternal(jsonLd, options, compact) {
|
|
|
6610
6637
|
}, "linkedData", (observation) => verifyJsonLdInternal(jsonLd, {
|
|
6611
6638
|
...options,
|
|
6612
6639
|
[verificationObservation]: observation
|
|
6613
|
-
}, compact), (value) => value);
|
|
6640
|
+
}, compact), (value) => value.verified);
|
|
6614
6641
|
const observation = options[verificationObservation];
|
|
6615
6642
|
return await (options.tracerProvider ?? _opentelemetry_api.trace.getTracerProvider()).getTracer(name, version).startActiveSpan("ld_signatures.verify", async (span) => {
|
|
6616
6643
|
const start = performance.now();
|
|
@@ -6642,12 +6669,18 @@ async function verifyJsonLdInternal(jsonLd, options, compact) {
|
|
|
6642
6669
|
const key = await verifySignature(compacted, verificationOptions);
|
|
6643
6670
|
if (key == null) {
|
|
6644
6671
|
if (observation?.attempt != null && !hasLdSignatureProperty(jsonLd)) observation.attempt.reason = { type: "noSignature" };
|
|
6645
|
-
return
|
|
6672
|
+
return {
|
|
6673
|
+
verified: false,
|
|
6674
|
+
key: null
|
|
6675
|
+
};
|
|
6646
6676
|
}
|
|
6647
6677
|
if (key.ownerId == null) {
|
|
6648
6678
|
if (observation?.attempt != null) observation.attempt.reason = { type: "missingOwner" };
|
|
6649
6679
|
logger$4.debug("Key {keyId} has no owner.", { keyId: key.id?.href });
|
|
6650
|
-
return
|
|
6680
|
+
return {
|
|
6681
|
+
verified: false,
|
|
6682
|
+
key: null
|
|
6683
|
+
};
|
|
6651
6684
|
}
|
|
6652
6685
|
attributions.delete(key.ownerId.href);
|
|
6653
6686
|
if (attributions.size > 0) {
|
|
@@ -6656,10 +6689,16 @@ async function verifyJsonLdInternal(jsonLd, options, compact) {
|
|
|
6656
6689
|
attributionIds: [...attributions].map((id) => new URL(id))
|
|
6657
6690
|
};
|
|
6658
6691
|
logger$4.debug("Some attributions are not authenticated by the Linked Data Signatures: {attributions}.", { attributions: [...attributions] });
|
|
6659
|
-
return
|
|
6692
|
+
return {
|
|
6693
|
+
verified: false,
|
|
6694
|
+
key: null
|
|
6695
|
+
};
|
|
6660
6696
|
}
|
|
6661
6697
|
verified = true;
|
|
6662
|
-
return
|
|
6698
|
+
return {
|
|
6699
|
+
verified: true,
|
|
6700
|
+
key
|
|
6701
|
+
};
|
|
6663
6702
|
} catch (error) {
|
|
6664
6703
|
threw = true;
|
|
6665
6704
|
span.setStatus({
|
|
@@ -7741,6 +7780,12 @@ async function verifyProofInternal(jsonLd, proof, options, messageDigestCache, r
|
|
|
7741
7780
|
keyId: proof.verificationMethodId.href,
|
|
7742
7781
|
error
|
|
7743
7782
|
});
|
|
7783
|
+
const check = options[verificationObservation]?.check;
|
|
7784
|
+
if (check != null && check.reason == null) check.reason = {
|
|
7785
|
+
type: "keyFetchError",
|
|
7786
|
+
keyId: new URL(proof.verificationMethodId.href),
|
|
7787
|
+
result: { error: error instanceof Error ? error : new Error(String(error)) }
|
|
7788
|
+
};
|
|
7744
7789
|
return null;
|
|
7745
7790
|
}
|
|
7746
7791
|
const publicKey = fetchedKey.key;
|
|
@@ -8269,6 +8314,39 @@ async function verifyPreparedPortableObjectProof(jsonLd, prepared, options, mess
|
|
|
8269
8314
|
* @since 0.10.0
|
|
8270
8315
|
*/
|
|
8271
8316
|
async function verifyObject(cls, jsonLd, options = {}) {
|
|
8317
|
+
const result = await verifyObjectDetailed(cls, jsonLd, options);
|
|
8318
|
+
return result.status === "verified" ? result.object : null;
|
|
8319
|
+
}
|
|
8320
|
+
/**
|
|
8321
|
+
* Same as {@link verifyObject}, but also tells who signed the verified proofs,
|
|
8322
|
+
* and whether a failure was caused by a key that could not be obtained for
|
|
8323
|
+
* a retryable reason.
|
|
8324
|
+
* @param cls The class of the object to verify.
|
|
8325
|
+
* @param jsonLd The JSON-LD object to verify.
|
|
8326
|
+
* @param options Additional options.
|
|
8327
|
+
* @returns The result.
|
|
8328
|
+
* @throws {TypeError} If the object is invalid or unsupported.
|
|
8329
|
+
* @internal
|
|
8330
|
+
*/
|
|
8331
|
+
async function verifyObjectDetailed(cls, jsonLd, options = {}) {
|
|
8332
|
+
const classify = (result, checks) => {
|
|
8333
|
+
if (result != null) return {
|
|
8334
|
+
status: "verified",
|
|
8335
|
+
object: result.object,
|
|
8336
|
+
signers: result.signers
|
|
8337
|
+
};
|
|
8338
|
+
for (const check of checks) {
|
|
8339
|
+
if (check.status === "error" && (0, _fedify_vocab_runtime.isTransientFetchError)(check.error)) return {
|
|
8340
|
+
status: "unavailable",
|
|
8341
|
+
error: check.error
|
|
8342
|
+
};
|
|
8343
|
+
if (check.status === "rejected" && check.reason.type === "keyFetchError" && isRetryableKeyFetchError(check.reason.result)) return {
|
|
8344
|
+
status: "unavailable",
|
|
8345
|
+
error: "error" in check.reason.result ? check.reason.result.error : /* @__PURE__ */ new Error(`Fetching key ${check.reason.keyId.href} failed with ${check.reason.result.status}.`)
|
|
8346
|
+
};
|
|
8347
|
+
}
|
|
8348
|
+
return { status: "invalid" };
|
|
8349
|
+
};
|
|
8272
8350
|
if (options[verificationObservation]?.attempt == null) {
|
|
8273
8351
|
const observedOptions = {
|
|
8274
8352
|
...options,
|
|
@@ -8280,16 +8358,16 @@ async function verifyObject(cls, jsonLd, options = {}) {
|
|
|
8280
8358
|
return await (options.tracerProvider ?? _opentelemetry_api.trace.getTracerProvider()).getTracer(name, version).startActiveSpan("object_integrity_proofs.verify_object", async (span) => {
|
|
8281
8359
|
try {
|
|
8282
8360
|
return await observeAttempt(observedOptions, "objectIntegrity", async (observation) => {
|
|
8283
|
-
const
|
|
8361
|
+
const result = await verifyObjectCore(cls, jsonLd, {
|
|
8284
8362
|
...options,
|
|
8285
8363
|
[verificationObservation]: observation
|
|
8286
8364
|
});
|
|
8287
|
-
if (
|
|
8365
|
+
if (result == null) {
|
|
8288
8366
|
span.setStatus({ code: _opentelemetry_api.SpanStatusCode.ERROR });
|
|
8289
8367
|
span.setAttribute("activitypub.verification.failure_reason", observation.attempt?.reason?.type ?? "signatureVerificationFailed");
|
|
8290
8368
|
}
|
|
8291
|
-
return
|
|
8292
|
-
}, (value) => value
|
|
8369
|
+
return classify(result, observation.attempt?.checks ?? []);
|
|
8370
|
+
}, (value) => value.status === "verified");
|
|
8293
8371
|
} catch (error) {
|
|
8294
8372
|
span.setStatus({
|
|
8295
8373
|
code: _opentelemetry_api.SpanStatusCode.ERROR,
|
|
@@ -8301,6 +8379,15 @@ async function verifyObject(cls, jsonLd, options = {}) {
|
|
|
8301
8379
|
}
|
|
8302
8380
|
});
|
|
8303
8381
|
}
|
|
8382
|
+
const checks = options[verificationObservation].attempt.checks;
|
|
8383
|
+
const before = checks.length;
|
|
8384
|
+
return classify(await verifyObjectCore(cls, jsonLd, options), checks.slice(before));
|
|
8385
|
+
}
|
|
8386
|
+
function isRetryableKeyFetchError(result) {
|
|
8387
|
+
if ("error" in result) return (0, _fedify_vocab_runtime.isTransientFetchError)(result.error);
|
|
8388
|
+
return result.status >= 500 || result.status === 408 || result.status === 429;
|
|
8389
|
+
}
|
|
8390
|
+
async function verifyObjectCore(cls, jsonLd, options) {
|
|
8304
8391
|
const observation = options[verificationObservation];
|
|
8305
8392
|
const logger = (0, _logtape_logtape.getLogger)([
|
|
8306
8393
|
"fedify",
|
|
@@ -8313,6 +8400,7 @@ async function verifyObject(cls, jsonLd, options = {}) {
|
|
|
8313
8400
|
const defaultDocumentLoader = (0, _fedify_vocab_runtime.getDocumentLoader)();
|
|
8314
8401
|
const proofContextLoader = options.contextLoader ?? defaultDocumentLoader;
|
|
8315
8402
|
const attributions = new Set(object.attributionIds.map((uri) => uri.href));
|
|
8403
|
+
const signers = [];
|
|
8316
8404
|
if (object instanceof _fedify_vocab.Activity) for (const uri of object.actorIds) attributions.add(uri.href);
|
|
8317
8405
|
const rawProofValues = isJsonLdNode(jsonLd) ? await getRawProofValues(jsonLd, proofContextLoader) : [];
|
|
8318
8406
|
const rawProofCandidates = isJsonLdNode(jsonLd) ? await parseRawProofCandidates(jsonLd, rawProofValues, options, proofContextLoader) : [];
|
|
@@ -8371,6 +8459,11 @@ async function verifyObject(cls, jsonLd, options = {}) {
|
|
|
8371
8459
|
continue;
|
|
8372
8460
|
}
|
|
8373
8461
|
deleteAuthenticatedAttribution(attributions, key.controllerId, proof.verificationMethodId);
|
|
8462
|
+
const signer = getAuthenticatedController(key.controllerId, proof.verificationMethodId);
|
|
8463
|
+
if (signer != null && !signers.some((s) => s.kind === signer.kind && s.id.href === signer.id.href && s.keyId.href === proof.verificationMethodId.href)) signers.push({
|
|
8464
|
+
...signer,
|
|
8465
|
+
keyId: proof.verificationMethodId
|
|
8466
|
+
});
|
|
8374
8467
|
}
|
|
8375
8468
|
if (acceptedPortableProofs < loadedPortableProofs) {
|
|
8376
8469
|
logger.debug("Some portable proof references could not be dereferenced.");
|
|
@@ -8384,7 +8477,41 @@ async function verifyObject(cls, jsonLd, options = {}) {
|
|
|
8384
8477
|
logger.debug("Some attributions are not authenticated by the proofs: {attributions}.", { attributions: [...attributions] });
|
|
8385
8478
|
return null;
|
|
8386
8479
|
}
|
|
8387
|
-
return
|
|
8480
|
+
return {
|
|
8481
|
+
object,
|
|
8482
|
+
signers
|
|
8483
|
+
};
|
|
8484
|
+
}
|
|
8485
|
+
/**
|
|
8486
|
+
* Tells whom a key that verified an Object Integrity Proof authenticates.
|
|
8487
|
+
* @param key The key, i.e., the proof's verification method.
|
|
8488
|
+
* @returns The signer, or `null` if the key authenticates nobody.
|
|
8489
|
+
* @internal
|
|
8490
|
+
*/
|
|
8491
|
+
function getProofSigner(key) {
|
|
8492
|
+
if (key.id == null || key.controllerId == null) return null;
|
|
8493
|
+
const signer = getAuthenticatedController(key.controllerId, key.id);
|
|
8494
|
+
return signer == null ? null : {
|
|
8495
|
+
...signer,
|
|
8496
|
+
keyId: key.id
|
|
8497
|
+
};
|
|
8498
|
+
}
|
|
8499
|
+
/**
|
|
8500
|
+
* Tells whom a verified proof authenticates: the key's controller if it is an
|
|
8501
|
+
* ordinary actor, or the DID of a portable controller if the verification
|
|
8502
|
+
* method belongs to the same DID.
|
|
8503
|
+
*/
|
|
8504
|
+
function getAuthenticatedController(controllerId, verificationMethodId) {
|
|
8505
|
+
if (!hasCryptographicOrigin(controllerId.href) && !isPortableId(controllerId)) return {
|
|
8506
|
+
kind: "actor",
|
|
8507
|
+
id: controllerId
|
|
8508
|
+
};
|
|
8509
|
+
const did = getPortableDid(controllerId);
|
|
8510
|
+
if (did == null || !hasCryptographicOrigin(verificationMethodId.href) || getPortableDid(verificationMethodId) !== did || !URL.canParse(did)) return null;
|
|
8511
|
+
return {
|
|
8512
|
+
kind: "portableAuthority",
|
|
8513
|
+
id: new URL(did)
|
|
8514
|
+
};
|
|
8388
8515
|
}
|
|
8389
8516
|
function deleteAuthenticatedAttribution(attributions, controllerId, verificationMethodId) {
|
|
8390
8517
|
if (!hasCryptographicOrigin(controllerId.href) && !isPortableId(controllerId)) {
|
|
@@ -10402,6 +10529,12 @@ Object.defineProperty(exports, "getPortableDid", {
|
|
|
10402
10529
|
return getPortableDid;
|
|
10403
10530
|
}
|
|
10404
10531
|
});
|
|
10532
|
+
Object.defineProperty(exports, "getProofSigner", {
|
|
10533
|
+
enumerable: true,
|
|
10534
|
+
get: function() {
|
|
10535
|
+
return getProofSigner;
|
|
10536
|
+
}
|
|
10537
|
+
});
|
|
10405
10538
|
Object.defineProperty(exports, "getRawCanonicalPortableId", {
|
|
10406
10539
|
enumerable: true,
|
|
10407
10540
|
get: function() {
|
|
@@ -10516,6 +10649,12 @@ Object.defineProperty(exports, "listRequestSignatures", {
|
|
|
10516
10649
|
return listRequestSignatures;
|
|
10517
10650
|
}
|
|
10518
10651
|
});
|
|
10652
|
+
Object.defineProperty(exports, "markEffectiveContextLoader", {
|
|
10653
|
+
enumerable: true,
|
|
10654
|
+
get: function() {
|
|
10655
|
+
return markEffectiveContextLoader;
|
|
10656
|
+
}
|
|
10657
|
+
});
|
|
10519
10658
|
Object.defineProperty(exports, "name", {
|
|
10520
10659
|
enumerable: true,
|
|
10521
10660
|
get: function() {
|
|
@@ -10696,10 +10835,10 @@ Object.defineProperty(exports, "verificationObservation", {
|
|
|
10696
10835
|
return verificationObservation;
|
|
10697
10836
|
}
|
|
10698
10837
|
});
|
|
10699
|
-
Object.defineProperty(exports, "
|
|
10838
|
+
Object.defineProperty(exports, "verifyCompactJsonLdDetailed", {
|
|
10700
10839
|
enumerable: true,
|
|
10701
10840
|
get: function() {
|
|
10702
|
-
return
|
|
10841
|
+
return verifyCompactJsonLdDetailed;
|
|
10703
10842
|
}
|
|
10704
10843
|
});
|
|
10705
10844
|
Object.defineProperty(exports, "verifyJsonLd", {
|
|
@@ -10726,6 +10865,12 @@ Object.defineProperty(exports, "verifyObject", {
|
|
|
10726
10865
|
return verifyObject;
|
|
10727
10866
|
}
|
|
10728
10867
|
});
|
|
10868
|
+
Object.defineProperty(exports, "verifyObjectDetailed", {
|
|
10869
|
+
enumerable: true,
|
|
10870
|
+
get: function() {
|
|
10871
|
+
return verifyObjectDetailed;
|
|
10872
|
+
}
|
|
10873
|
+
});
|
|
10729
10874
|
Object.defineProperty(exports, "verifyPortableObjectProof", {
|
|
10730
10875
|
enumerable: true,
|
|
10731
10876
|
get: function() {
|