@fedify/fedify 2.4.0-dev.2030 → 2.4.0-dev.2047

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/{builder-BYJ5otJa.mjs → builder-Cue1kVHU.mjs} +12 -11
  2. package/dist/compat/mod.d.cts +1 -1
  3. package/dist/compat/mod.d.ts +1 -1
  4. package/dist/compat/transformers.test.mjs +1 -1
  5. package/dist/{compound-proof-BIvUoJxm.mjs → compound-proof-YT4tajyj.mjs} +1 -1
  6. package/dist/{context-uyRUWoZQ.d.ts → context-BJPHhBmD.d.ts} +100 -2
  7. package/dist/{context-BeDnDuF3.d.cts → context-Bh_mJfbD.d.cts} +100 -2
  8. package/dist/{context-CbS35fLr.mjs → context-DG5QeQ8W.mjs} +3 -1
  9. package/dist/{deno-Vj_9wePq.mjs → deno-Dcj6O4LJ.mjs} +1 -1
  10. package/dist/{docloader-qUudHZVH.mjs → docloader-BRlNjHlQ.mjs} +2 -2
  11. package/dist/federation/builder.test.mjs +1 -1
  12. package/dist/federation/compound-fanout.test.mjs +3 -3
  13. package/dist/federation/handler-compound-proof.test.mjs +4 -4
  14. package/dist/federation/handler.test.mjs +6 -6
  15. package/dist/federation/idempotency.test.mjs +2 -2
  16. package/dist/federation/metrics.test.mjs +1 -1
  17. package/dist/federation/middleware.test.mjs +8 -8
  18. package/dist/federation/mod.cjs +1 -1
  19. package/dist/federation/mod.d.cts +3 -3
  20. package/dist/federation/mod.d.ts +3 -3
  21. package/dist/federation/mod.js +1 -1
  22. package/dist/federation/outgoing-proof.test.mjs +5 -5
  23. package/dist/federation/portable.test.d.mts +2 -0
  24. package/dist/federation/portable.test.mjs +430 -0
  25. package/dist/federation/send.test.mjs +3 -3
  26. package/dist/federation/tasks/enqueue.test.mjs +2 -2
  27. package/dist/federation/tasks/tasks.test.mjs +3 -3
  28. package/dist/federation/temporal.test.mjs +1 -1
  29. package/dist/federation/webfinger.test.mjs +115 -2
  30. package/dist/{federation-CTnaljmy.cjs → federation-Bdu06LEl.cjs} +324 -26
  31. package/dist/{http-By8tnmEr.js → http-BmdqHyms.js} +1 -1
  32. package/dist/{http-B5F1JMh0.cjs → http-CGjvl34X.cjs} +1 -1
  33. package/dist/{http-D4WPcJUe.mjs → http-CK6kjLnO.mjs} +3 -3
  34. package/dist/{key-B_Zc5Jbd.mjs → key-CzCAq6D9.mjs} +2 -2
  35. package/dist/{kv-cache-8K70pjtX.cjs → kv-cache-CvEicbrf.cjs} +1 -1
  36. package/dist/{kv-cache-BXdT7pJQ.mjs → kv-cache-YATuzCy-.mjs} +1 -1
  37. package/dist/{kv-cache-BswMKQjC.js → kv-cache-fi_-XZco.js} +1 -1
  38. package/dist/{ld-B16KUSIQ.mjs → ld-CNWm8mJc.mjs} +3 -3
  39. package/dist/{metrics-DpQqUAmh.mjs → metrics-CDoBPWjf.mjs} +1 -1
  40. package/dist/{middleware-BL5HFFVU.mjs → middleware-CF6uz8wa.mjs} +1 -1
  41. package/dist/{middleware-C7_hqDnl.mjs → middleware-CtFNjIUD.mjs} +326 -28
  42. package/dist/{middleware-Cxto6Bq2.js → middleware-Drzx-OID.js} +325 -27
  43. package/dist/{mod-D882_Xsg.d.ts → mod-BofpDIcU.d.ts} +1 -1
  44. package/dist/{mod-x9W0d0Pk.d.cts → mod-DU8aVzQJ.d.cts} +1 -1
  45. package/dist/mod.cjs +4 -4
  46. package/dist/mod.d.cts +4 -4
  47. package/dist/mod.d.ts +4 -4
  48. package/dist/mod.js +4 -4
  49. package/dist/nodeinfo/handler.test.mjs +2 -2
  50. package/dist/{owner-BIOIhZoM.mjs → owner-B3PgGiJ1.mjs} +2 -2
  51. package/dist/{owner-D-E0bT2O.js → owner-CMnmv7S9.js} +16 -3
  52. package/dist/{owner-WUYke16i.cjs → owner-Hurn_ocn.cjs} +16 -3
  53. package/dist/{proof-BVxJu5vv.mjs → proof-fKycdssC.mjs} +18 -5
  54. package/dist/{send-Cr5FJ7iu.mjs → send-BqBILxYE.mjs} +3 -3
  55. package/dist/sig/compound-proof-discovery.test.mjs +1 -1
  56. package/dist/sig/compound-proof-producer.test.mjs +1 -1
  57. package/dist/sig/compound-proof-verification.test.mjs +2 -2
  58. package/dist/sig/compound-proof.test.mjs +2 -2
  59. package/dist/sig/http.test.mjs +2 -2
  60. package/dist/sig/key.test.mjs +1 -1
  61. package/dist/sig/ld.test.mjs +2 -2
  62. package/dist/sig/mod.cjs +2 -2
  63. package/dist/sig/mod.js +2 -2
  64. package/dist/sig/owner.test.mjs +1 -1
  65. package/dist/sig/proof.test.mjs +208 -1
  66. package/dist/{temporal-CCf0lZV3.mjs → temporal-SUiLJ0Co.mjs} +1 -1
  67. package/dist/testing/kv.test.mjs +1 -1
  68. package/dist/testing/mod.d.mts +99 -1
  69. package/dist/testing/mod.mjs +2 -2
  70. package/dist/{testing-hbky2gMN.mjs → testing-By1YYsIK.mjs} +1 -1
  71. package/dist/utils/docloader.test.mjs +2 -2
  72. package/dist/utils/kv-cache.test.mjs +1 -1
  73. package/dist/utils/mod.cjs +1 -1
  74. package/dist/utils/mod.js +1 -1
  75. package/package.json +7 -7
@@ -1,14 +1,15 @@
1
1
  import { Temporal } from "temporal-polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { r as createRequestContext } from "../context-CbS35fLr.mjs";
4
+ import { r as createRequestContext } from "../context-DG5QeQ8W.mjs";
5
5
  import { t as MemoryKvStore } from "../kv-DCHkaJ9-.mjs";
6
6
  import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
7
7
  import { t as assertNotEquals } from "../assert_not_equals-CpPK2t89.mjs";
8
8
  import "../std__assert-DvMDRPes.mjs";
9
- import { o as createFederation, s as handleWebFinger } from "../middleware-C7_hqDnl.mjs";
9
+ import { o as createFederation, s as handleWebFinger } from "../middleware-CtFNjIUD.mjs";
10
10
  import { Image, Link, Person, Tombstone } from "@fedify/vocab";
11
11
  import { createTestMeterProvider, test } from "@fedify/fixture";
12
+ import { parseIri } from "@fedify/vocab-runtime";
12
13
  //#region src/federation/webfinger.test.ts
13
14
  test("handleWebFinger()", async (t) => {
14
15
  const url = new URL("https://example.com/.well-known/webfinger");
@@ -739,5 +740,117 @@ test("handleWebFinger() records webfinger.handle counter and duration", async (t
739
740
  assertEquals(recorder.getMeasurements("webfinger.handle.duration").length, 0);
740
741
  });
741
742
  });
743
+ test("handleWebFinger() for FEP-ef61 portable actors", async (t) => {
744
+ const did = "did:key:z6Mkabc";
745
+ const compatibleId = `https://example.com/.well-known/apgateway/${did}/actor`;
746
+ const gateways = {
747
+ alice: [new URL("https://example.com")],
748
+ secondary: [new URL("https://primary.example"), new URL("https://example.com")],
749
+ anonymous: [new URL("https://example.com")],
750
+ nogateway: []
751
+ };
752
+ const actorDispatcher = (_ctx, identifier) => {
753
+ if (!(identifier in gateways)) return null;
754
+ return new Person({
755
+ id: parseIri(`ap://${did}/actor`),
756
+ preferredUsername: identifier === "anonymous" ? null : "alice",
757
+ gateways: gateways[identifier]
758
+ });
759
+ };
760
+ const actorAliasMapper = (_ctx, resource) => {
761
+ if (resource.href === compatibleId) return { identifier: "alice" };
762
+ if (resource.protocol === "ap+ef61:") return { identifier: "anonymous" };
763
+ if (resource.href === "acct:anonymous") return { identifier: "anonymous" };
764
+ return null;
765
+ };
766
+ async function query(resource, host = "example.com") {
767
+ const url = new URL(`https://${host}/.well-known/webfinger`);
768
+ url.searchParams.set("resource", resource);
769
+ const context = createRequestContext({
770
+ federation: createFederation({ kv: new MemoryKvStore() }),
771
+ url,
772
+ data: void 0,
773
+ getActorUri(identifier) {
774
+ return new URL(`${url.origin}/users/${identifier}`);
775
+ },
776
+ parseUri: () => null
777
+ });
778
+ return await handleWebFinger(context.request, {
779
+ context,
780
+ actorDispatcher,
781
+ actorAliasMapper,
782
+ onNotFound: () => new Response("Not found", { status: 404 })
783
+ });
784
+ }
785
+ const selfLink = {
786
+ rel: "self",
787
+ href: compatibleId,
788
+ type: "application/activity+json"
789
+ };
790
+ await t.step("acct: on the first gateway", async () => {
791
+ const response = await query("acct:alice@example.com");
792
+ assertEquals(response.status, 200);
793
+ assertEquals(await response.json(), {
794
+ subject: "acct:alice@example.com",
795
+ aliases: [compatibleId],
796
+ links: [selfLink]
797
+ });
798
+ });
799
+ await t.step("acct: on a secondary gateway", async () => {
800
+ const response = await query("acct:secondary@example.com");
801
+ assertEquals(response.status, 200);
802
+ const primaryCompatibleId = `https://primary.example/.well-known/apgateway/${did}/actor`;
803
+ assertEquals(await response.json(), {
804
+ subject: "acct:alice@primary.example",
805
+ aliases: [primaryCompatibleId, "acct:secondary@example.com"],
806
+ links: [{
807
+ ...selfLink,
808
+ href: primaryCompatibleId
809
+ }]
810
+ });
811
+ });
812
+ await t.step("compatible identifier", async () => {
813
+ const response = await query(compatibleId);
814
+ assertEquals(response.status, 200);
815
+ assertEquals(await response.json(), {
816
+ subject: "acct:alice@example.com",
817
+ aliases: [compatibleId],
818
+ links: [selfLink]
819
+ });
820
+ });
821
+ await t.step("portable ID without preferredUsername", async () => {
822
+ const response = await query(`ap://${did}/actor`);
823
+ assertEquals(response.status, 200);
824
+ assertEquals(await response.json(), {
825
+ subject: compatibleId,
826
+ aliases: [],
827
+ links: [selfLink]
828
+ });
829
+ });
830
+ await t.step("acct: without preferredUsername", async () => {
831
+ const response = await query("acct:anonymous@example.com");
832
+ assertEquals(response.status, 200);
833
+ assertEquals(await response.json(), {
834
+ subject: "acct:anonymous@example.com",
835
+ aliases: [compatibleId],
836
+ links: [selfLink]
837
+ });
838
+ });
839
+ await t.step("acct: without a host or preferredUsername", async () => {
840
+ const response = await query("acct:anonymous");
841
+ assertEquals(response.status, 200);
842
+ assertEquals(await response.json(), {
843
+ subject: "acct:anonymous",
844
+ aliases: [compatibleId],
845
+ links: [selfLink]
846
+ });
847
+ });
848
+ await t.step("no gateways", async () => {
849
+ assertEquals((await query("acct:nogateway@example.com")).status, 404);
850
+ });
851
+ await t.step("another host", async () => {
852
+ assertEquals((await query("acct:alice@primary.example")).status, 404);
853
+ });
854
+ });
742
855
  //#endregion
743
856
  export {};