@fedify/fedify 2.4.0-dev.2099 → 2.4.0-dev.2103
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/{builder-Bno54o_-.mjs → builder-CHht75pX.mjs} +2 -2
- 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-X3SxXVbc.mjs → compound-proof-DKKH_Nr1.mjs} +2 -2
- package/dist/{context-MORIQJIh.d.ts → context-CfJE_oQu.d.ts} +73 -11
- package/dist/{context-DlZhxdFT.mjs → context-CoNRxGYp.mjs} +2 -1
- package/dist/{context-C43spTGI.d.cts → context-mDTxTw-S.d.cts} +73 -11
- package/dist/{deno-dxdvl2XZ.mjs → deno-CkjiYK_Z.mjs} +1 -1
- package/dist/{docloader-eBxQDsk9.mjs → docloader-C1hAJnWc.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 +4 -4
- package/dist/federation/handler.test.mjs +6 -6
- package/dist/federation/hashlink-media.test.mjs +2 -2
- package/dist/federation/idempotency.test.mjs +2 -2
- package/dist/federation/metrics.test.mjs +1 -1
- package/dist/federation/middleware.test.mjs +8 -8
- package/dist/federation/mod.cjs +1 -1
- package/dist/federation/mod.d.cts +2 -2
- package/dist/federation/mod.d.ts +2 -2
- package/dist/federation/mod.js +1 -1
- package/dist/federation/outgoing-proof.test.mjs +5 -5
- package/dist/federation/portable-actor.test.d.mts +2 -0
- package/dist/federation/portable-actor.test.mjs +446 -0
- package/dist/federation/portable-gateway-keys.test.mjs +4 -4
- package/dist/federation/portable-inbox.test.mjs +25 -4
- package/dist/federation/portable.test.mjs +3 -3
- package/dist/federation/send.test.mjs +3 -3
- package/dist/federation/tasks/enqueue.test.mjs +2 -2
- package/dist/federation/tasks/tasks.test.mjs +3 -3
- package/dist/federation/temporal.test.mjs +1 -1
- package/dist/federation/webfinger.test.mjs +2 -2
- package/dist/{federation-C4Ef3JKa.cjs → federation-C1dL6SiT.cjs} +70 -11
- package/dist/{http-DsgawTd8.mjs → http-BU-8fUrz.mjs} +4 -4
- package/dist/{http-C8cZTE3Y.cjs → http-Cala2Grs.cjs} +1 -1
- package/dist/{http-D-rbr_Sy.js → http-tTlTeFa0.js} +1 -1
- package/dist/{key-DYfmjnmp.mjs → key-I8gLBkcf.mjs} +2 -2
- package/dist/{kv-cache-Dvd-Q-E2.cjs → kv-cache-Bl5EBFrU.cjs} +1 -1
- package/dist/{kv-cache-DIxwMeNi.js → kv-cache-CxQu_cd4.js} +1 -1
- package/dist/{kv-cache-EvOgrFsS.mjs → kv-cache-DJFoGRWQ.mjs} +1 -1
- package/dist/{ld-B00wWHzc.mjs → ld-wiJbqJHa.mjs} +3 -3
- package/dist/{metrics-BP3vdBpb.mjs → metrics-BCAa5-kE.mjs} +1 -1
- package/dist/{middleware-CeBVBa61.mjs → middleware-6p2dYEVA.mjs} +1 -1
- package/dist/{middleware-CcXMe400.js → middleware-B6IVTVL0.js} +70 -11
- package/dist/{middleware-Br1_d-Ga.mjs → middleware-FnITXhtz.mjs} +80 -21
- package/dist/{mod-DMI4DbOo.d.cts → mod-B3OzOobN.d.cts} +1 -1
- package/dist/{mod-BL5BQHCq.d.ts → mod-BYvPz_T0.d.ts} +1 -1
- package/dist/mod.cjs +5 -5
- package/dist/mod.d.cts +2 -2
- package/dist/mod.d.ts +2 -2
- package/dist/mod.js +5 -5
- package/dist/nodeinfo/handler.test.mjs +2 -2
- package/dist/{owner-BJPDRDRq.mjs → owner-BJp47LxN.mjs} +3 -3
- package/dist/{owner-DSzH7wro.cjs → owner-DCt8W_Cv.cjs} +1 -1
- package/dist/{owner-U12fDpQW.js → owner-j5yrbXS1.js} +1 -1
- package/dist/{portable-key-D0mWbV9G.mjs → portable-key-B5oKE_wZ.mjs} +1 -1
- package/dist/{proof-ChjBwnep.mjs → proof-BE4T5zF6.mjs} +4 -4
- package/dist/{send-yFX0E-ye.mjs → send-BFITuKHw.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 +2 -2
- package/dist/sig/mod.cjs +3 -3
- package/dist/sig/mod.js +3 -3
- package/dist/sig/owner.test.mjs +1 -1
- package/dist/sig/portable-collection.test.mjs +2 -2
- package/dist/sig/portable-key.test.mjs +3 -3
- package/dist/sig/proof.test.mjs +3 -3
- package/dist/{sig-C85KqAcx.js → sig-CJHdGk9w.js} +2 -2
- package/dist/{sig-B689Nj7y.cjs → sig-CRTRoouH.cjs} +2 -2
- package/dist/{temporal-Dl9x-Qw4.mjs → temporal-CyDDbE4i.mjs} +1 -1
- package/dist/testing/kv.test.mjs +1 -1
- package/dist/testing/mod.d.mts +73 -11
- package/dist/testing/mod.mjs +2 -2
- package/dist/{testing-CO_cEvQc.mjs → testing-BWq1dCzx.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
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
2
2
|
const require_rolldown_runtime = require("./rolldown-runtime-Dmm3t92W.cjs");
|
|
3
3
|
const require_transformers = require("./transformers-BalCrSsr.cjs");
|
|
4
|
-
const require_http = require("./http-
|
|
4
|
+
const require_http = require("./http-Cala2Grs.cjs");
|
|
5
5
|
const require_types = require("./types-Be2zbyeG.cjs");
|
|
6
|
-
const require_owner = require("./owner-
|
|
7
|
-
const require_kv_cache = require("./kv-cache-
|
|
6
|
+
const require_owner = require("./owner-DCt8W_Cv.cjs");
|
|
7
|
+
const require_kv_cache = require("./kv-cache-Bl5EBFrU.cjs");
|
|
8
8
|
let _logtape_logtape = require("@logtape/logtape");
|
|
9
9
|
let _fedify_uri_template = require("@fedify/uri-template");
|
|
10
10
|
let _fedify_vocab = require("@fedify/vocab");
|
|
@@ -2411,6 +2411,8 @@ function acceptsJsonLd(request) {
|
|
|
2411
2411
|
const PORTABLE_OBJECT_CONTENT_TYPE = "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"";
|
|
2412
2412
|
const GATEWAY_OBJECT_PATH_PATTERN = /^\/\.well-known\/apgateway\/did(?::|%3A)/i;
|
|
2413
2413
|
const BARE_DID_PATTERN = /^did:[a-z0-9]+:[^/?#]+$/i;
|
|
2414
|
+
const DID_KEY_PREFIX = "did:key:";
|
|
2415
|
+
const BASE58BTC_MULTIBASE_PATTERN = /^z[1-9A-HJ-NP-Za-km-z]+$/;
|
|
2414
2416
|
const GATEWAY_PATH_PREFIX = "/.well-known/apgateway/";
|
|
2415
2417
|
const HASHLINK_SCHEME_PATTERN = /^hl(?::|%3A)/i;
|
|
2416
2418
|
/**
|
|
@@ -2446,6 +2448,15 @@ function parsePortableGatewayRequest(url) {
|
|
|
2446
2448
|
throw error;
|
|
2447
2449
|
}
|
|
2448
2450
|
const authority = (0, _fedify_vocab_runtime.getFe34Origin)(id);
|
|
2451
|
+
try {
|
|
2452
|
+
assertBase58BtcDidKey(authority);
|
|
2453
|
+
} catch (error) {
|
|
2454
|
+
if (error instanceof TypeError) return {
|
|
2455
|
+
type: "malformed",
|
|
2456
|
+
error
|
|
2457
|
+
};
|
|
2458
|
+
throw error;
|
|
2459
|
+
}
|
|
2449
2460
|
const href = id.href;
|
|
2450
2461
|
return {
|
|
2451
2462
|
type: "object",
|
|
@@ -2464,12 +2475,26 @@ function parsePortableGatewayRequest(url) {
|
|
|
2464
2475
|
* @param authority The bare DID, e.g., `did:key:z6Mk...`.
|
|
2465
2476
|
* @param path The object path, e.g., `/notes/123`.
|
|
2466
2477
|
* @returns The portable ID.
|
|
2467
|
-
* @throws {TypeError} If the authority is not a bare DID
|
|
2478
|
+
* @throws {TypeError} If the authority is not a bare DID, or it is
|
|
2479
|
+
* a `did:key` DID that is not encoded in base58-btc.
|
|
2468
2480
|
*/
|
|
2469
2481
|
function buildPortableUri(authority, path) {
|
|
2470
2482
|
if (typeof authority !== "string" || !BARE_DID_PATTERN.test(authority)) throw new TypeError("The authority of a portable ID must be a DID without a path, query, or fragment.");
|
|
2471
|
-
(0, _fedify_vocab_runtime.getFe34Origin)(authority);
|
|
2472
|
-
|
|
2483
|
+
const did = (0, _fedify_vocab_runtime.getFe34Origin)(authority);
|
|
2484
|
+
assertBase58BtcDidKey(did);
|
|
2485
|
+
return (0, _fedify_vocab_runtime.parseIri)(`ap+ef61://${did}${path}`);
|
|
2486
|
+
}
|
|
2487
|
+
/**
|
|
2488
|
+
* Checks that a normalized DID, if it is a `did:key` DID, is encoded in
|
|
2489
|
+
* base58-btc, as FEP-ef61 requires so that the same key does not yield two
|
|
2490
|
+
* portable IDs. This only checks the encoding, not whether the DID is
|
|
2491
|
+
* a valid key.
|
|
2492
|
+
* @param did The DID normalized by `getFe34Origin()`.
|
|
2493
|
+
* @throws {TypeError} If the DID is a `did:key` DID that is not encoded in
|
|
2494
|
+
* base58-btc.
|
|
2495
|
+
*/
|
|
2496
|
+
function assertBase58BtcDidKey(did) {
|
|
2497
|
+
if (did.startsWith(DID_KEY_PREFIX) && !BASE58BTC_MULTIBASE_PATTERN.test(did.slice(8))) throw new TypeError("The did:key authority of a portable ID must be encoded in base58-btc, i.e., start with z.");
|
|
2473
2498
|
}
|
|
2474
2499
|
/**
|
|
2475
2500
|
* Recognizes an FEP-ef61 gateway request for a resource addressed by
|
|
@@ -3409,8 +3434,9 @@ async function handleObject(request, { values, context, objectDispatcher, author
|
|
|
3409
3434
|
}
|
|
3410
3435
|
/**
|
|
3411
3436
|
* Handles an FEP-ef61 gateway request for a portable object through an object
|
|
3412
|
-
* dispatcher
|
|
3413
|
-
*
|
|
3437
|
+
* dispatcher, or the actor dispatcher adapted to one. The object is served
|
|
3438
|
+
* only if its ID canonically matches the requested portable ID and it
|
|
3439
|
+
* satisfies the FEP-ef61 proof policy.
|
|
3414
3440
|
* @template TContextData The context data to pass to the context.
|
|
3415
3441
|
* @param request The HTTP request.
|
|
3416
3442
|
* @param parameters The parameters for handling the portable object.
|
|
@@ -8240,17 +8266,39 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
8240
8266
|
});
|
|
8241
8267
|
}
|
|
8242
8268
|
const route = this.router.route(portable.path);
|
|
8243
|
-
|
|
8269
|
+
const isActor = route != null && (route.name === "actor" || route.name.startsWith("actorAlias:"));
|
|
8270
|
+
if (route == null || !isActor && !route.name.startsWith("object:")) {
|
|
8244
8271
|
metricState.endpoint = "not_found";
|
|
8245
8272
|
return await onNotFound(request);
|
|
8246
8273
|
}
|
|
8247
8274
|
metricState.routeTemplate = PORTABLE_GATEWAY_ROUTE_PREFIX + route.template;
|
|
8248
|
-
metricState.endpoint = "object";
|
|
8275
|
+
metricState.endpoint = isActor ? "actor" : "object";
|
|
8249
8276
|
span.updateName(`${request.method} ${metricState.routeTemplate}`);
|
|
8250
8277
|
if (!acceptsJsonLd(request)) {
|
|
8251
8278
|
metricState.endpoint = "not_acceptable";
|
|
8252
8279
|
return await onNotAcceptable(request);
|
|
8253
8280
|
}
|
|
8281
|
+
if (isActor) {
|
|
8282
|
+
const identifier = route.name.startsWith("actorAlias:") ? route.name.substring(11) : route.values.identifier;
|
|
8283
|
+
const context = this.#createContext(request, contextData, {
|
|
8284
|
+
invokedFromActorDispatcher: { identifier },
|
|
8285
|
+
portableRequest: portable.portableRequest
|
|
8286
|
+
});
|
|
8287
|
+
const actorDispatcher = this.actorCallbacks?.dispatcher;
|
|
8288
|
+
const authorizePredicate = this.actorCallbacks?.authorizePredicate;
|
|
8289
|
+
return await handlePortableObject(request, {
|
|
8290
|
+
values: { identifier },
|
|
8291
|
+
context,
|
|
8292
|
+
objectDispatcher: actorDispatcher == null ? void 0 : async (ctx) => {
|
|
8293
|
+
const actor = await actorDispatcher(ctx, identifier);
|
|
8294
|
+
return actor instanceof _fedify_vocab.Tombstone ? null : actor;
|
|
8295
|
+
},
|
|
8296
|
+
authorizePredicate: authorizePredicate == null ? void 0 : (ctx) => authorizePredicate(ctx, identifier),
|
|
8297
|
+
canonicalId: portable.canonicalId,
|
|
8298
|
+
onUnauthorized,
|
|
8299
|
+
onNotFound
|
|
8300
|
+
});
|
|
8301
|
+
}
|
|
8254
8302
|
const typeId = route.name.replace(/^object:/, "");
|
|
8255
8303
|
const callbacks = this.objectCallbacks[typeId];
|
|
8256
8304
|
const cls = this.objectTypeIds[typeId];
|
|
@@ -8614,9 +8662,17 @@ var ContextImpl = class ContextImpl {
|
|
|
8614
8662
|
return new URL(path, this.canonicalOrigin);
|
|
8615
8663
|
}
|
|
8616
8664
|
getActorUri(identifier) {
|
|
8665
|
+
return new URL(this.#getActorPath(identifier), this.canonicalOrigin);
|
|
8666
|
+
}
|
|
8667
|
+
getPortableActorUri(identifier, authority) {
|
|
8668
|
+
const path = this.#getActorPath(identifier);
|
|
8669
|
+
if (authority == null) throw new TypeError("The authority of a portable ID is required outside an FEP-ef61 gateway request.");
|
|
8670
|
+
return buildPortableUri(authority, path);
|
|
8671
|
+
}
|
|
8672
|
+
#getActorPath(identifier) {
|
|
8617
8673
|
const path = this.federation.router.build(`actorAlias:${identifier}`, {}) ?? this.federation.router.build("actor", { identifier });
|
|
8618
8674
|
if (path == null) throw new _fedify_uri_template.RouterError("No actor dispatcher registered.");
|
|
8619
|
-
return
|
|
8675
|
+
return path;
|
|
8620
8676
|
}
|
|
8621
8677
|
getObjectUri(cls, values) {
|
|
8622
8678
|
return new URL(this.#getObjectPath(cls, values), this.canonicalOrigin);
|
|
@@ -9259,6 +9315,9 @@ var RequestContextImpl = class RequestContextImpl extends ContextImpl {
|
|
|
9259
9315
|
request: this.request
|
|
9260
9316
|
});
|
|
9261
9317
|
}
|
|
9318
|
+
getPortableActorUri(identifier, authority) {
|
|
9319
|
+
return super.getPortableActorUri(identifier, authority ?? this.portableRequest?.authority);
|
|
9320
|
+
}
|
|
9262
9321
|
getPortableObjectUri(cls, values, authority) {
|
|
9263
9322
|
return super.getPortableObjectUri(cls, values, authority ?? this.portableRequest?.authority);
|
|
9264
9323
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
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-
|
|
4
|
+
import { n as version, t as name } from "./deno-CkjiYK_Z.mjs";
|
|
5
|
+
import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-BCAa5-kE.mjs";
|
|
6
6
|
import { i as validateAcceptSignature, n as fulfillAcceptSignature, r as parseAcceptSignature } from "./accept-CPVqki78.mjs";
|
|
7
|
-
import { i as fetchKeyDetailed, s as validateCryptoKey } from "./key-
|
|
8
|
-
import { n as verifyPortableGatewayKeyDocument } from "./portable-key-
|
|
7
|
+
import { i as fetchKeyDetailed, s as validateCryptoKey } from "./key-I8gLBkcf.mjs";
|
|
8
|
+
import { n as verifyPortableGatewayKeyDocument } from "./portable-key-B5oKE_wZ.mjs";
|
|
9
9
|
import { getLogger } from "@logtape/logtape";
|
|
10
10
|
import { CryptographicKey } from "@fedify/vocab";
|
|
11
11
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
@@ -16,7 +16,7 @@ json_canon = require_rolldown_runtime.__toESM(json_canon, 1);
|
|
|
16
16
|
let _opentelemetry_semantic_conventions = require("@opentelemetry/semantic-conventions");
|
|
17
17
|
//#region deno.json
|
|
18
18
|
var name = "@fedify/fedify";
|
|
19
|
-
var version = "2.4.0-dev.
|
|
19
|
+
var version = "2.4.0-dev.2103+3be829c0";
|
|
20
20
|
//#endregion
|
|
21
21
|
//#region src/sig/portable-key-id.ts
|
|
22
22
|
const COMPATIBLE_KEY_ID_PATH_PATTERN = /^\/\.well-known\/apgateway\/did(?::|%3A)/i;
|
|
@@ -14,7 +14,7 @@ import serialize from "json-canon";
|
|
|
14
14
|
import { ATTR_HTTP_REQUEST_HEADER, ATTR_HTTP_REQUEST_METHOD, ATTR_URL_FULL } from "@opentelemetry/semantic-conventions";
|
|
15
15
|
//#region deno.json
|
|
16
16
|
var name = "@fedify/fedify";
|
|
17
|
-
var version = "2.4.0-dev.
|
|
17
|
+
var version = "2.4.0-dev.2103+3be829c0";
|
|
18
18
|
//#endregion
|
|
19
19
|
//#region src/sig/portable-key-id.ts
|
|
20
20
|
const COMPATIBLE_KEY_ID_PATH_PATTERN = /^\/\.well-known\/apgateway\/did(?::|%3A)/i;
|
|
@@ -1,8 +1,8 @@
|
|
|
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 { _ as recordKeyLookup, n as getDurationMs, t as classifyFetchError } from "./metrics-
|
|
4
|
+
import { n as version, t as name } from "./deno-CkjiYK_Z.mjs";
|
|
5
|
+
import { _ as recordKeyLookup, n as getDurationMs, t as classifyFetchError } from "./metrics-BCAa5-kE.mjs";
|
|
6
6
|
import { a as isCompatibleKeyId, o as isPortableActorDocument, s as isPortableId } from "./portable-key-id-Bva5iT3W.mjs";
|
|
7
7
|
import { getLogger } from "@logtape/logtape";
|
|
8
8
|
import { CryptographicKey, Multikey, Object as Object$1, isActor } from "@fedify/vocab";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
2
|
-
const require_http = require("./http-
|
|
2
|
+
const require_http = require("./http-Cala2Grs.cjs");
|
|
3
3
|
let _logtape_logtape = require("@logtape/logtape");
|
|
4
4
|
let _fedify_vocab_runtime = require("@fedify/vocab-runtime");
|
|
5
5
|
let es_toolkit = require("es-toolkit");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Temporal } from "temporal-polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import { H as validateCryptoKey, et as recordDocumentCache, t as doubleKnock } from "./http-
|
|
3
|
+
import { H as validateCryptoKey, et as recordDocumentCache, t as doubleKnock } from "./http-tTlTeFa0.js";
|
|
4
4
|
import { getLogger } from "@logtape/logtape";
|
|
5
5
|
import { UrlError, createActivityPubRequest, getRemoteDocument, logRequest, preloadedContexts, validatePublicUrl } from "@fedify/vocab-runtime";
|
|
6
6
|
import { curry } from "es-toolkit";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Temporal } from "temporal-polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { p as recordDocumentCache } from "./metrics-
|
|
4
|
+
import { p as recordDocumentCache } from "./metrics-BCAa5-kE.mjs";
|
|
5
5
|
import { getLogger } from "@logtape/logtape";
|
|
6
6
|
import { preloadedContexts } from "@fedify/vocab-runtime";
|
|
7
7
|
//#region src/utils/kv-cache.ts
|
|
@@ -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, s as measureSignatureKeyFetch } from "./metrics-
|
|
6
|
-
import { r as fetchKey, s as validateCryptoKey } from "./key-
|
|
4
|
+
import { n as version, t as name } from "./deno-CkjiYK_Z.mjs";
|
|
5
|
+
import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-BCAa5-kE.mjs";
|
|
6
|
+
import { r as fetchKey, s as validateCryptoKey } from "./key-I8gLBkcf.mjs";
|
|
7
7
|
import { getLogger } from "@logtape/logtape";
|
|
8
8
|
import { Activity, CryptographicKey, Object as Object$1, getTypeId } from "@fedify/vocab";
|
|
9
9
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "temporal-polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
4
|
+
import { n as version, t as name } from "./deno-CkjiYK_Z.mjs";
|
|
5
5
|
import { metrics } from "@opentelemetry/api";
|
|
6
6
|
import { FetchError } from "@fedify/vocab-runtime";
|
|
7
7
|
//#region src/federation/metrics.ts
|
|
@@ -2,10 +2,10 @@ import { Temporal } from "temporal-polyfill";
|
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
3
|
import { t as __exportAll } from "./rolldown-runtime-BC-Eo5Mj.js";
|
|
4
4
|
import { r as getDefaultActivityTransformers } from "./transformers-DAtXl_Kc.js";
|
|
5
|
-
import { $ as recordCollectionTotalItems, A as isInvalidUrlTypeError, C as compactJsonLd, D as hasSignature, E as getNormalizationContextLoader, F as wrapContextLoaderForJsonLd, G as getFederationMetrics, H as validateCryptoKey, I as exportJwk, J as isAbortError, K as getRemoteHost, M as verifyCompactJsonLd, O as hasSignatureLike, Q as recordCollectionRequest, T as detachSignature, V as importJwk, W as getDurationMs, X as recordCollectionDispatchDuration, Y as recordCircuitBreakerStateChange, Z as recordCollectionPageItems, _ as verifyPortableObjectProofWithRoot, _t as isPortableId, at as recordWebFingerHandle, b as InvalidContextReferenceError, bt as name, ct as formatAcceptSignature, d as hasProofLike, f as signObject, ft as getCanonicalPortableId, g as verifyPortableObjectProofPolicy, gt as isCompatibleKeyId, h as verifyPortableObjectProof, ht as hasPortableActor, i as selectRequestSignature, it as recordOutboxEnqueue, j as signJsonLd, k as isClearlyMalformedContextReference, l as InvalidPortableObjectIdError, m as verifyObject, mt as getPortableDid, n as listRequestSignatures, nt as recordInboxActivity, o as verifyRequest, ot as registerQueueDepthGauge, p as verifyMapLocalProof, pt as getGatewayKeyBase, q as instrumentDocumentLoader, r as parseRfc9421SignatureInput, rt as recordOutboxActivity, s as verifyRequestDetailed, st as preloadedOnlyDocumentLoader, t as doubleKnock, tt as recordFanoutRecipients, vt as isPortableUri, x as assertSafeJsonLd, xt as version, y as normalizeOutgoingActivityJsonLd } from "./http-
|
|
5
|
+
import { $ as recordCollectionTotalItems, A as isInvalidUrlTypeError, C as compactJsonLd, D as hasSignature, E as getNormalizationContextLoader, F as wrapContextLoaderForJsonLd, G as getFederationMetrics, H as validateCryptoKey, I as exportJwk, J as isAbortError, K as getRemoteHost, M as verifyCompactJsonLd, O as hasSignatureLike, Q as recordCollectionRequest, T as detachSignature, V as importJwk, W as getDurationMs, X as recordCollectionDispatchDuration, Y as recordCircuitBreakerStateChange, Z as recordCollectionPageItems, _ as verifyPortableObjectProofWithRoot, _t as isPortableId, at as recordWebFingerHandle, b as InvalidContextReferenceError, bt as name, ct as formatAcceptSignature, d as hasProofLike, f as signObject, ft as getCanonicalPortableId, g as verifyPortableObjectProofPolicy, gt as isCompatibleKeyId, h as verifyPortableObjectProof, ht as hasPortableActor, i as selectRequestSignature, it as recordOutboxEnqueue, j as signJsonLd, k as isClearlyMalformedContextReference, l as InvalidPortableObjectIdError, m as verifyObject, mt as getPortableDid, n as listRequestSignatures, nt as recordInboxActivity, o as verifyRequest, ot as registerQueueDepthGauge, p as verifyMapLocalProof, pt as getGatewayKeyBase, q as instrumentDocumentLoader, r as parseRfc9421SignatureInput, rt as recordOutboxActivity, s as verifyRequestDetailed, st as preloadedOnlyDocumentLoader, t as doubleKnock, tt as recordFanoutRecipients, vt as isPortableUri, x as assertSafeJsonLd, xt as version, y as normalizeOutgoingActivityJsonLd } from "./http-tTlTeFa0.js";
|
|
6
6
|
import { a as MAX_BODY_SIZE, i as BodyTooLargeError, n as getNodeInfo, o as readBoundedText, t as nodeInfoToJson } from "./types-C_cNlNVK.js";
|
|
7
|
-
import { n as getKeyOwner, t as doesActorOwnKey } from "./owner-
|
|
8
|
-
import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-
|
|
7
|
+
import { n as getKeyOwner, t as doesActorOwnKey } from "./owner-j5yrbXS1.js";
|
|
8
|
+
import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-CxQu_cd4.js";
|
|
9
9
|
import { getLogger, withContext } from "@logtape/logtape";
|
|
10
10
|
import { Router, RouterError, assertPath } from "@fedify/uri-template";
|
|
11
11
|
import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, Tombstone, getTypeId, lookupObject, traverseCollection } from "@fedify/vocab";
|
|
@@ -2408,6 +2408,8 @@ function acceptsJsonLd(request) {
|
|
|
2408
2408
|
const PORTABLE_OBJECT_CONTENT_TYPE = "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"";
|
|
2409
2409
|
const GATEWAY_OBJECT_PATH_PATTERN = /^\/\.well-known\/apgateway\/did(?::|%3A)/i;
|
|
2410
2410
|
const BARE_DID_PATTERN = /^did:[a-z0-9]+:[^/?#]+$/i;
|
|
2411
|
+
const DID_KEY_PREFIX = "did:key:";
|
|
2412
|
+
const BASE58BTC_MULTIBASE_PATTERN = /^z[1-9A-HJ-NP-Za-km-z]+$/;
|
|
2411
2413
|
const GATEWAY_PATH_PREFIX = "/.well-known/apgateway/";
|
|
2412
2414
|
const HASHLINK_SCHEME_PATTERN = /^hl(?::|%3A)/i;
|
|
2413
2415
|
/**
|
|
@@ -2443,6 +2445,15 @@ function parsePortableGatewayRequest(url) {
|
|
|
2443
2445
|
throw error;
|
|
2444
2446
|
}
|
|
2445
2447
|
const authority = getFe34Origin(id);
|
|
2448
|
+
try {
|
|
2449
|
+
assertBase58BtcDidKey(authority);
|
|
2450
|
+
} catch (error) {
|
|
2451
|
+
if (error instanceof TypeError) return {
|
|
2452
|
+
type: "malformed",
|
|
2453
|
+
error
|
|
2454
|
+
};
|
|
2455
|
+
throw error;
|
|
2456
|
+
}
|
|
2446
2457
|
const href = id.href;
|
|
2447
2458
|
return {
|
|
2448
2459
|
type: "object",
|
|
@@ -2461,12 +2472,26 @@ function parsePortableGatewayRequest(url) {
|
|
|
2461
2472
|
* @param authority The bare DID, e.g., `did:key:z6Mk...`.
|
|
2462
2473
|
* @param path The object path, e.g., `/notes/123`.
|
|
2463
2474
|
* @returns The portable ID.
|
|
2464
|
-
* @throws {TypeError} If the authority is not a bare DID
|
|
2475
|
+
* @throws {TypeError} If the authority is not a bare DID, or it is
|
|
2476
|
+
* a `did:key` DID that is not encoded in base58-btc.
|
|
2465
2477
|
*/
|
|
2466
2478
|
function buildPortableUri(authority, path) {
|
|
2467
2479
|
if (typeof authority !== "string" || !BARE_DID_PATTERN.test(authority)) throw new TypeError("The authority of a portable ID must be a DID without a path, query, or fragment.");
|
|
2468
|
-
getFe34Origin(authority);
|
|
2469
|
-
|
|
2480
|
+
const did = getFe34Origin(authority);
|
|
2481
|
+
assertBase58BtcDidKey(did);
|
|
2482
|
+
return parseIri(`ap+ef61://${did}${path}`);
|
|
2483
|
+
}
|
|
2484
|
+
/**
|
|
2485
|
+
* Checks that a normalized DID, if it is a `did:key` DID, is encoded in
|
|
2486
|
+
* base58-btc, as FEP-ef61 requires so that the same key does not yield two
|
|
2487
|
+
* portable IDs. This only checks the encoding, not whether the DID is
|
|
2488
|
+
* a valid key.
|
|
2489
|
+
* @param did The DID normalized by `getFe34Origin()`.
|
|
2490
|
+
* @throws {TypeError} If the DID is a `did:key` DID that is not encoded in
|
|
2491
|
+
* base58-btc.
|
|
2492
|
+
*/
|
|
2493
|
+
function assertBase58BtcDidKey(did) {
|
|
2494
|
+
if (did.startsWith(DID_KEY_PREFIX) && !BASE58BTC_MULTIBASE_PATTERN.test(did.slice(8))) throw new TypeError("The did:key authority of a portable ID must be encoded in base58-btc, i.e., start with z.");
|
|
2470
2495
|
}
|
|
2471
2496
|
/**
|
|
2472
2497
|
* Recognizes an FEP-ef61 gateway request for a resource addressed by
|
|
@@ -3403,8 +3428,9 @@ async function handleObject(request, { values, context, objectDispatcher, author
|
|
|
3403
3428
|
}
|
|
3404
3429
|
/**
|
|
3405
3430
|
* Handles an FEP-ef61 gateway request for a portable object through an object
|
|
3406
|
-
* dispatcher
|
|
3407
|
-
*
|
|
3431
|
+
* dispatcher, or the actor dispatcher adapted to one. The object is served
|
|
3432
|
+
* only if its ID canonically matches the requested portable ID and it
|
|
3433
|
+
* satisfies the FEP-ef61 proof policy.
|
|
3408
3434
|
* @template TContextData The context data to pass to the context.
|
|
3409
3435
|
* @param request The HTTP request.
|
|
3410
3436
|
* @param parameters The parameters for handling the portable object.
|
|
@@ -8143,17 +8169,39 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
8143
8169
|
});
|
|
8144
8170
|
}
|
|
8145
8171
|
const route = this.router.route(portable.path);
|
|
8146
|
-
|
|
8172
|
+
const isActor = route != null && (route.name === "actor" || route.name.startsWith("actorAlias:"));
|
|
8173
|
+
if (route == null || !isActor && !route.name.startsWith("object:")) {
|
|
8147
8174
|
metricState.endpoint = "not_found";
|
|
8148
8175
|
return await onNotFound(request);
|
|
8149
8176
|
}
|
|
8150
8177
|
metricState.routeTemplate = PORTABLE_GATEWAY_ROUTE_PREFIX + route.template;
|
|
8151
|
-
metricState.endpoint = "object";
|
|
8178
|
+
metricState.endpoint = isActor ? "actor" : "object";
|
|
8152
8179
|
span.updateName(`${request.method} ${metricState.routeTemplate}`);
|
|
8153
8180
|
if (!acceptsJsonLd(request)) {
|
|
8154
8181
|
metricState.endpoint = "not_acceptable";
|
|
8155
8182
|
return await onNotAcceptable(request);
|
|
8156
8183
|
}
|
|
8184
|
+
if (isActor) {
|
|
8185
|
+
const identifier = route.name.startsWith("actorAlias:") ? route.name.substring(11) : route.values.identifier;
|
|
8186
|
+
const context = this.#createContext(request, contextData, {
|
|
8187
|
+
invokedFromActorDispatcher: { identifier },
|
|
8188
|
+
portableRequest: portable.portableRequest
|
|
8189
|
+
});
|
|
8190
|
+
const actorDispatcher = this.actorCallbacks?.dispatcher;
|
|
8191
|
+
const authorizePredicate = this.actorCallbacks?.authorizePredicate;
|
|
8192
|
+
return await handlePortableObject(request, {
|
|
8193
|
+
values: { identifier },
|
|
8194
|
+
context,
|
|
8195
|
+
objectDispatcher: actorDispatcher == null ? void 0 : async (ctx) => {
|
|
8196
|
+
const actor = await actorDispatcher(ctx, identifier);
|
|
8197
|
+
return actor instanceof Tombstone ? null : actor;
|
|
8198
|
+
},
|
|
8199
|
+
authorizePredicate: authorizePredicate == null ? void 0 : (ctx) => authorizePredicate(ctx, identifier),
|
|
8200
|
+
canonicalId: portable.canonicalId,
|
|
8201
|
+
onUnauthorized,
|
|
8202
|
+
onNotFound
|
|
8203
|
+
});
|
|
8204
|
+
}
|
|
8157
8205
|
const typeId = route.name.replace(/^object:/, "");
|
|
8158
8206
|
const callbacks = this.objectCallbacks[typeId];
|
|
8159
8207
|
const cls = this.objectTypeIds[typeId];
|
|
@@ -8517,9 +8565,17 @@ var ContextImpl = class ContextImpl {
|
|
|
8517
8565
|
return new URL(path, this.canonicalOrigin);
|
|
8518
8566
|
}
|
|
8519
8567
|
getActorUri(identifier) {
|
|
8568
|
+
return new URL(this.#getActorPath(identifier), this.canonicalOrigin);
|
|
8569
|
+
}
|
|
8570
|
+
getPortableActorUri(identifier, authority) {
|
|
8571
|
+
const path = this.#getActorPath(identifier);
|
|
8572
|
+
if (authority == null) throw new TypeError("The authority of a portable ID is required outside an FEP-ef61 gateway request.");
|
|
8573
|
+
return buildPortableUri(authority, path);
|
|
8574
|
+
}
|
|
8575
|
+
#getActorPath(identifier) {
|
|
8520
8576
|
const path = this.federation.router.build(`actorAlias:${identifier}`, {}) ?? this.federation.router.build("actor", { identifier });
|
|
8521
8577
|
if (path == null) throw new RouterError("No actor dispatcher registered.");
|
|
8522
|
-
return
|
|
8578
|
+
return path;
|
|
8523
8579
|
}
|
|
8524
8580
|
getObjectUri(cls, values) {
|
|
8525
8581
|
return new URL(this.#getObjectPath(cls, values), this.canonicalOrigin);
|
|
@@ -9162,6 +9218,9 @@ var RequestContextImpl = class RequestContextImpl extends ContextImpl {
|
|
|
9162
9218
|
request: this.request
|
|
9163
9219
|
});
|
|
9164
9220
|
}
|
|
9221
|
+
getPortableActorUri(identifier, authority) {
|
|
9222
|
+
return super.getPortableActorUri(identifier, authority ?? this.portableRequest?.authority);
|
|
9223
|
+
}
|
|
9165
9224
|
getPortableObjectUri(cls, values, authority) {
|
|
9166
9225
|
return super.getPortableObjectUri(cls, values, authority ?? this.portableRequest?.authority);
|
|
9167
9226
|
}
|
|
@@ -1,28 +1,28 @@
|
|
|
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 { a as instrumentDocumentLoader, b as recordWebFingerHandle, c as recordCircuitBreakerStateChange, d as recordCollectionRequest, f as recordCollectionTotalItems, g as recordInboxActivity, h as recordFanoutRecipients, i as getRemoteHost, l as recordCollectionDispatchDuration, n as getDurationMs, o as isAbortError, r as getFederationMetrics, u as recordCollectionPageItems, v as recordOutboxActivity, x as registerQueueDepthGauge, y as recordOutboxEnqueue } from "./metrics-
|
|
4
|
+
import { n as version, t as name } from "./deno-CkjiYK_Z.mjs";
|
|
5
|
+
import { a as instrumentDocumentLoader, b as recordWebFingerHandle, c as recordCircuitBreakerStateChange, d as recordCollectionRequest, f as recordCollectionTotalItems, g as recordInboxActivity, h as recordFanoutRecipients, i as getRemoteHost, l as recordCollectionDispatchDuration, n as getDurationMs, o as isAbortError, r as getFederationMetrics, u as recordCollectionPageItems, v as recordOutboxActivity, x as registerQueueDepthGauge, y as recordOutboxEnqueue } from "./metrics-BCAa5-kE.mjs";
|
|
6
6
|
import { t as formatAcceptSignature } from "./accept-CPVqki78.mjs";
|
|
7
7
|
import { a as isCompatibleKeyId, c as isPortableUri, i as hasPortableActor, n as getGatewayKeyBase, r as getPortableDid, s as isPortableId, t as getCanonicalPortableId } from "./portable-key-id-Bva5iT3W.mjs";
|
|
8
|
-
import { o as importJwk, s as validateCryptoKey, t as exportJwk } from "./key-
|
|
8
|
+
import { o as importJwk, s as validateCryptoKey, t as exportJwk } from "./key-I8gLBkcf.mjs";
|
|
9
9
|
import { r as normalizeOutgoingActivityJsonLd } from "./outgoing-jsonld-4IJqPYos.mjs";
|
|
10
|
-
import { _ as wrapContextLoaderForJsonLd, a as compactJsonLd, c as getNormalizationContextLoader, d as isClearlyMalformedContextReference, f as isInvalidUrlTypeError, l as hasSignature, m as verifyCompactJsonLd, p as signJsonLd, r as assertSafeJsonLd, s as detachSignature, t as InvalidContextReferenceError, u as hasSignatureLike } from "./ld-
|
|
11
|
-
import { i as signObject, l as verifyPortableObjectProofWithRoot, o as verifyObject, r as hasProofLike, s as verifyPortableObjectProof, t as InvalidPortableObjectIdError } from "./proof-
|
|
12
|
-
import { a as listRequestSignatures, c as selectRequestSignature, d as verifyRequest, f as verifyRequestDetailed, s as parseRfc9421SignatureInput } from "./http-
|
|
13
|
-
import { t as getAuthenticatedDocumentLoader } from "./docloader-
|
|
14
|
-
import { n as kvCache } from "./kv-cache-
|
|
10
|
+
import { _ as wrapContextLoaderForJsonLd, a as compactJsonLd, c as getNormalizationContextLoader, d as isClearlyMalformedContextReference, f as isInvalidUrlTypeError, l as hasSignature, m as verifyCompactJsonLd, p as signJsonLd, r as assertSafeJsonLd, s as detachSignature, t as InvalidContextReferenceError, u as hasSignatureLike } from "./ld-wiJbqJHa.mjs";
|
|
11
|
+
import { i as signObject, l as verifyPortableObjectProofWithRoot, o as verifyObject, r as hasProofLike, s as verifyPortableObjectProof, t as InvalidPortableObjectIdError } from "./proof-BE4T5zF6.mjs";
|
|
12
|
+
import { a as listRequestSignatures, c as selectRequestSignature, d as verifyRequest, f as verifyRequestDetailed, s as parseRfc9421SignatureInput } from "./http-BU-8fUrz.mjs";
|
|
13
|
+
import { t as getAuthenticatedDocumentLoader } from "./docloader-C1hAJnWc.mjs";
|
|
14
|
+
import { n as kvCache } from "./kv-cache-DJFoGRWQ.mjs";
|
|
15
15
|
import { d as readBoundedText, l as BodyTooLargeError, t as getNodeInfo, u as MAX_BODY_SIZE } from "./client-DpnpgjyX.mjs";
|
|
16
16
|
import { t as nodeInfoToJson } from "./types-DE_LV1JB.mjs";
|
|
17
|
-
import { n as getKeyOwner, t as doesActorOwnKey } from "./owner-
|
|
18
|
-
import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "./send-
|
|
19
|
-
import { n as FederationBuilderImpl, t as ACTOR_ALIAS_PREFIX } from "./builder-
|
|
17
|
+
import { n as getKeyOwner, t as doesActorOwnKey } from "./owner-BJp47LxN.mjs";
|
|
18
|
+
import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "./send-BFITuKHw.mjs";
|
|
19
|
+
import { n as FederationBuilderImpl, t as ACTOR_ALIAS_PREFIX } from "./builder-CHht75pX.mjs";
|
|
20
20
|
import { t as CircuitBreaker } from "./circuit-breaker-C5NqoLBJ.mjs";
|
|
21
21
|
import { t as buildCollectionSynchronizationHeader } from "./collection-CnnP1UAv.mjs";
|
|
22
|
-
import { a as verifyCompoundPortableObjectProofs, i as inspectCompoundPortableObjectApplicability, r as findUnsupportedCompoundProofShape, t as containsCompoundPortableObject } from "./compound-proof-
|
|
22
|
+
import { a as verifyCompoundPortableObjectProofs, i as inspectCompoundPortableObjectApplicability, r as findUnsupportedCompoundProofShape, t as containsCompoundPortableObject } from "./compound-proof-DKKH_Nr1.mjs";
|
|
23
23
|
import { t as KvKeyCache } from "./keycache-BUDHB5rY.mjs";
|
|
24
24
|
import { t as acceptsJsonLd } from "./negotiation-CCocWT_N.mjs";
|
|
25
|
-
import { t as hasMalformedKnownTemporalLiteral } from "./temporal-
|
|
25
|
+
import { t as hasMalformedKnownTemporalLiteral } from "./temporal-CyDDbE4i.mjs";
|
|
26
26
|
import { t as createExponentialBackoffPolicy } from "./retry-zX5xw5e0.mjs";
|
|
27
27
|
import { t as TaskCodec } from "./codec-C6rTrpIp.mjs";
|
|
28
28
|
import { getLogger, withContext } from "@logtape/logtape";
|
|
@@ -522,6 +522,8 @@ async function routeActivity({ context: ctx, json, originalJson, normalizedActiv
|
|
|
522
522
|
const PORTABLE_OBJECT_CONTENT_TYPE = "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"";
|
|
523
523
|
const GATEWAY_OBJECT_PATH_PATTERN = /^\/\.well-known\/apgateway\/did(?::|%3A)/i;
|
|
524
524
|
const BARE_DID_PATTERN = /^did:[a-z0-9]+:[^/?#]+$/i;
|
|
525
|
+
const DID_KEY_PREFIX = "did:key:";
|
|
526
|
+
const BASE58BTC_MULTIBASE_PATTERN = /^z[1-9A-HJ-NP-Za-km-z]+$/;
|
|
525
527
|
const GATEWAY_PATH_PREFIX = "/.well-known/apgateway/";
|
|
526
528
|
const HASHLINK_SCHEME_PATTERN = /^hl(?::|%3A)/i;
|
|
527
529
|
/**
|
|
@@ -557,6 +559,15 @@ function parsePortableGatewayRequest(url) {
|
|
|
557
559
|
throw error;
|
|
558
560
|
}
|
|
559
561
|
const authority = getFe34Origin(id);
|
|
562
|
+
try {
|
|
563
|
+
assertBase58BtcDidKey(authority);
|
|
564
|
+
} catch (error) {
|
|
565
|
+
if (error instanceof TypeError) return {
|
|
566
|
+
type: "malformed",
|
|
567
|
+
error
|
|
568
|
+
};
|
|
569
|
+
throw error;
|
|
570
|
+
}
|
|
560
571
|
const href = id.href;
|
|
561
572
|
return {
|
|
562
573
|
type: "object",
|
|
@@ -575,12 +586,26 @@ function parsePortableGatewayRequest(url) {
|
|
|
575
586
|
* @param authority The bare DID, e.g., `did:key:z6Mk...`.
|
|
576
587
|
* @param path The object path, e.g., `/notes/123`.
|
|
577
588
|
* @returns The portable ID.
|
|
578
|
-
* @throws {TypeError} If the authority is not a bare DID
|
|
589
|
+
* @throws {TypeError} If the authority is not a bare DID, or it is
|
|
590
|
+
* a `did:key` DID that is not encoded in base58-btc.
|
|
579
591
|
*/
|
|
580
592
|
function buildPortableUri(authority, path) {
|
|
581
593
|
if (typeof authority !== "string" || !BARE_DID_PATTERN.test(authority)) throw new TypeError("The authority of a portable ID must be a DID without a path, query, or fragment.");
|
|
582
|
-
getFe34Origin(authority);
|
|
583
|
-
|
|
594
|
+
const did = getFe34Origin(authority);
|
|
595
|
+
assertBase58BtcDidKey(did);
|
|
596
|
+
return parseIri(`ap+ef61://${did}${path}`);
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* Checks that a normalized DID, if it is a `did:key` DID, is encoded in
|
|
600
|
+
* base58-btc, as FEP-ef61 requires so that the same key does not yield two
|
|
601
|
+
* portable IDs. This only checks the encoding, not whether the DID is
|
|
602
|
+
* a valid key.
|
|
603
|
+
* @param did The DID normalized by `getFe34Origin()`.
|
|
604
|
+
* @throws {TypeError} If the DID is a `did:key` DID that is not encoded in
|
|
605
|
+
* base58-btc.
|
|
606
|
+
*/
|
|
607
|
+
function assertBase58BtcDidKey(did) {
|
|
608
|
+
if (did.startsWith(DID_KEY_PREFIX) && !BASE58BTC_MULTIBASE_PATTERN.test(did.slice(8))) throw new TypeError("The did:key authority of a portable ID must be encoded in base58-btc, i.e., start with z.");
|
|
584
609
|
}
|
|
585
610
|
/**
|
|
586
611
|
* Recognizes an FEP-ef61 gateway request for a resource addressed by
|
|
@@ -1138,8 +1163,9 @@ async function handleObject(request, { values, context, objectDispatcher, author
|
|
|
1138
1163
|
}
|
|
1139
1164
|
/**
|
|
1140
1165
|
* Handles an FEP-ef61 gateway request for a portable object through an object
|
|
1141
|
-
* dispatcher
|
|
1142
|
-
*
|
|
1166
|
+
* dispatcher, or the actor dispatcher adapted to one. The object is served
|
|
1167
|
+
* only if its ID canonically matches the requested portable ID and it
|
|
1168
|
+
* satisfies the FEP-ef61 proof policy.
|
|
1143
1169
|
* @template TContextData The context data to pass to the context.
|
|
1144
1170
|
* @param request The HTTP request.
|
|
1145
1171
|
* @param parameters The parameters for handling the portable object.
|
|
@@ -5469,17 +5495,39 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
5469
5495
|
});
|
|
5470
5496
|
}
|
|
5471
5497
|
const route = this.router.route(portable.path);
|
|
5472
|
-
|
|
5498
|
+
const isActor = route != null && (route.name === "actor" || route.name.startsWith("actorAlias:"));
|
|
5499
|
+
if (route == null || !isActor && !route.name.startsWith("object:")) {
|
|
5473
5500
|
metricState.endpoint = "not_found";
|
|
5474
5501
|
return await onNotFound(request);
|
|
5475
5502
|
}
|
|
5476
5503
|
metricState.routeTemplate = PORTABLE_GATEWAY_ROUTE_PREFIX + route.template;
|
|
5477
|
-
metricState.endpoint = "object";
|
|
5504
|
+
metricState.endpoint = isActor ? "actor" : "object";
|
|
5478
5505
|
span.updateName(`${request.method} ${metricState.routeTemplate}`);
|
|
5479
5506
|
if (!acceptsJsonLd(request)) {
|
|
5480
5507
|
metricState.endpoint = "not_acceptable";
|
|
5481
5508
|
return await onNotAcceptable(request);
|
|
5482
5509
|
}
|
|
5510
|
+
if (isActor) {
|
|
5511
|
+
const identifier = route.name.startsWith("actorAlias:") ? route.name.substring(ACTOR_ALIAS_PREFIX.length) : route.values.identifier;
|
|
5512
|
+
const context = this.#createContext(request, contextData, {
|
|
5513
|
+
invokedFromActorDispatcher: { identifier },
|
|
5514
|
+
portableRequest: portable.portableRequest
|
|
5515
|
+
});
|
|
5516
|
+
const actorDispatcher = this.actorCallbacks?.dispatcher;
|
|
5517
|
+
const authorizePredicate = this.actorCallbacks?.authorizePredicate;
|
|
5518
|
+
return await handlePortableObject(request, {
|
|
5519
|
+
values: { identifier },
|
|
5520
|
+
context,
|
|
5521
|
+
objectDispatcher: actorDispatcher == null ? void 0 : async (ctx) => {
|
|
5522
|
+
const actor = await actorDispatcher(ctx, identifier);
|
|
5523
|
+
return actor instanceof Tombstone ? null : actor;
|
|
5524
|
+
},
|
|
5525
|
+
authorizePredicate: authorizePredicate == null ? void 0 : (ctx) => authorizePredicate(ctx, identifier),
|
|
5526
|
+
canonicalId: portable.canonicalId,
|
|
5527
|
+
onUnauthorized,
|
|
5528
|
+
onNotFound
|
|
5529
|
+
});
|
|
5530
|
+
}
|
|
5483
5531
|
const typeId = route.name.replace(/^object:/, "");
|
|
5484
5532
|
const callbacks = this.objectCallbacks[typeId];
|
|
5485
5533
|
const cls = this.objectTypeIds[typeId];
|
|
@@ -5843,9 +5891,17 @@ var ContextImpl = class ContextImpl {
|
|
|
5843
5891
|
return new URL(path, this.canonicalOrigin);
|
|
5844
5892
|
}
|
|
5845
5893
|
getActorUri(identifier) {
|
|
5894
|
+
return new URL(this.#getActorPath(identifier), this.canonicalOrigin);
|
|
5895
|
+
}
|
|
5896
|
+
getPortableActorUri(identifier, authority) {
|
|
5897
|
+
const path = this.#getActorPath(identifier);
|
|
5898
|
+
if (authority == null) throw new TypeError("The authority of a portable ID is required outside an FEP-ef61 gateway request.");
|
|
5899
|
+
return buildPortableUri(authority, path);
|
|
5900
|
+
}
|
|
5901
|
+
#getActorPath(identifier) {
|
|
5846
5902
|
const path = this.federation.router.build(`actorAlias:${identifier}`, {}) ?? this.federation.router.build("actor", { identifier });
|
|
5847
5903
|
if (path == null) throw new RouterError("No actor dispatcher registered.");
|
|
5848
|
-
return
|
|
5904
|
+
return path;
|
|
5849
5905
|
}
|
|
5850
5906
|
getObjectUri(cls, values) {
|
|
5851
5907
|
return new URL(this.#getObjectPath(cls, values), this.canonicalOrigin);
|
|
@@ -6488,6 +6544,9 @@ var RequestContextImpl = class RequestContextImpl extends ContextImpl {
|
|
|
6488
6544
|
request: this.request
|
|
6489
6545
|
});
|
|
6490
6546
|
}
|
|
6547
|
+
getPortableActorUri(identifier, authority) {
|
|
6548
|
+
return super.getPortableActorUri(identifier, authority ?? this.portableRequest?.authority);
|
|
6549
|
+
}
|
|
6491
6550
|
getPortableObjectUri(cls, values, authority) {
|
|
6492
6551
|
return super.getPortableObjectUri(cls, values, authority ?? this.portableRequest?.authority);
|
|
6493
6552
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import { Wt as WebFingerLinksDispatcher, _t as ActorAliasMapper, u as RequestContext, vt as ActorDispatcher, yt as ActorHandleMapper } from "./context-
|
|
2
|
+
import { Wt as WebFingerLinksDispatcher, _t as ActorAliasMapper, u as RequestContext, vt as ActorDispatcher, yt as ActorHandleMapper } from "./context-mDTxTw-S.cjs";
|
|
3
3
|
import { MeterProvider, Span, Tracer } from "@opentelemetry/api";
|
|
4
4
|
import { RouterError, RouterOptions, RouterRouteResult } from "@fedify/uri-template";
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import { Wt as WebFingerLinksDispatcher, _t as ActorAliasMapper, u as RequestContext, vt as ActorDispatcher, yt as ActorHandleMapper } from "./context-
|
|
2
|
+
import { Wt as WebFingerLinksDispatcher, _t as ActorAliasMapper, u as RequestContext, vt as ActorDispatcher, yt as ActorHandleMapper } from "./context-CfJE_oQu.js";
|
|
3
3
|
import { RouterError, RouterOptions, RouterRouteResult } from "@fedify/uri-template";
|
|
4
4
|
import { MeterProvider, Span, Tracer } from "@opentelemetry/api";
|
|
5
5
|
|
package/dist/mod.cjs
CHANGED
|
@@ -3,14 +3,14 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
require("./rolldown-runtime-Dmm3t92W.cjs");
|
|
4
4
|
const require_transformers = require("./transformers-BalCrSsr.cjs");
|
|
5
5
|
require("./compat/mod.cjs");
|
|
6
|
-
const require_http = require("./http-
|
|
7
|
-
const require_federation = require("./federation-
|
|
6
|
+
const require_http = require("./http-Cala2Grs.cjs");
|
|
7
|
+
const require_federation = require("./federation-C1dL6SiT.cjs");
|
|
8
8
|
const require_types = require("./types-Be2zbyeG.cjs");
|
|
9
|
-
const require_owner = require("./owner-
|
|
10
|
-
const require_kv_cache = require("./kv-cache-
|
|
9
|
+
const require_owner = require("./owner-DCt8W_Cv.cjs");
|
|
10
|
+
const require_kv_cache = require("./kv-cache-Bl5EBFrU.cjs");
|
|
11
11
|
require("./nodeinfo/mod.cjs");
|
|
12
12
|
require("./runtime/mod.cjs");
|
|
13
|
-
const require_sig = require("./sig-
|
|
13
|
+
const require_sig = require("./sig-CRTRoouH.cjs");
|
|
14
14
|
require("./utils/mod.cjs");
|
|
15
15
|
//#endregion
|
|
16
16
|
exports.CircuitBreaker = require_federation.CircuitBreaker;
|