@fedify/fedify 1.7.15 → 1.7.16
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/actor-BzWaWDTY.js +146 -0
- package/dist/actor.js +34648 -5
- package/dist/{assert.js → assert-C-mZuSQl.js} +1 -1
- package/dist/{assert_instance_of.js → assert_instance_of-lS0Jr2iu.js} +1 -1
- package/dist/{assert_is_error.js → assert_is_error-CIYFACrT.js} +1 -1
- package/dist/{assert_not_equals.js → assert_not_equals-C1azCAB0.js} +1 -1
- package/dist/{assert_rejects.js → assert_rejects-Bkh5lA1a.js} +2 -2
- package/dist/{assert_throws.js → assert_throws-CmpfkWEM.js} +2 -2
- package/dist/authdocloader-1vrHbYJF.js +51 -0
- package/dist/authdocloader.js +2 -4
- package/dist/{builder.js → builder-8YjpOSrf.js} +5 -5
- package/dist/{client.js → client-CJ3nfMyp.js} +2 -2
- package/dist/compat/transformers.test.js +30 -30
- package/dist/{context.js → context-OXYKUfFL.js} +4 -4
- package/dist/docloader-I3SkMpZK.js +4421 -0
- package/dist/docloader.js +61 -4
- package/dist/{esm.js → esm-BRXvTSrx.js} +1 -1
- package/dist/federation/builder.test.js +17 -17
- package/dist/federation/collection.test.js +8 -8
- package/dist/federation/handler.test.js +36 -36
- package/dist/federation/inbox.test.js +11 -11
- package/dist/federation/keycache.test.js +12 -12
- package/dist/federation/kv.test.js +8 -8
- package/dist/federation/middleware.test.js +39 -39
- package/dist/federation/mq.test.js +10 -10
- package/dist/federation/retry.test.js +5 -5
- package/dist/federation/router.test.js +9 -9
- package/dist/federation/send.test.js +23 -23
- package/dist/http-CiQH4CF3.js +789 -0
- package/dist/http.js +4 -5
- package/dist/{inbox.js → inbox-BqBPO0vG.js} +3 -3
- package/dist/key-Ba-IjS2c.js +259 -0
- package/dist/key-CdNa4Um6.js +16 -0
- package/dist/key.js +1 -7
- package/dist/key2.js +2 -4
- package/dist/{keycache.js → keycache-BdgRTisV.js} +1 -1
- package/dist/{keys.js → keys-CLFIvF3E.js} +1 -1
- package/dist/{ld.js → ld-Dm1tdWDX.js} +4 -4
- package/dist/{lookup2.js → lookup-BumKjgCt.js} +4 -4
- package/dist/lookup-CoCshjhM.js +129 -0
- package/dist/lookup.js +1 -3
- package/dist/middleware-Dvd4BUlF.js +2661 -0
- package/dist/middleware-pC0Ld2I6.js +32 -0
- package/dist/middleware.js +1222 -364
- package/dist/middleware2.js +6 -21
- package/dist/nodeinfo/client.test.js +12 -12
- package/dist/nodeinfo/handler.test.js +34 -34
- package/dist/nodeinfo/semver.test.js +8 -8
- package/dist/nodeinfo/types.test.js +9 -9
- package/dist/{owner.js → owner-BO3ZhyYg.js} +3 -3
- package/dist/proof-Btlfk6hr.js +255 -0
- package/dist/proof.js +330 -8
- package/dist/runtime/authdocloader.test.js +20 -20
- package/dist/runtime/docloader.test.js +13 -13
- package/dist/runtime/key.test.js +15 -15
- package/dist/runtime/langstr.test.js +8 -8
- package/dist/runtime/multibase/multibase.test.js +8 -8
- package/dist/runtime/url.test.js +7 -7
- package/dist/{send.js → send-Dj-482tr.js} +2 -2
- package/dist/sig/http.test.js +20 -20
- package/dist/sig/key.test.js +17 -17
- package/dist/sig/ld.test.js +18 -18
- package/dist/sig/owner.test.js +20 -20
- package/dist/sig/proof.test.js +19 -19
- package/dist/{std__assert.js → std__assert-BdP_WkD-.js} +1 -1
- package/dist/testing/docloader.test.js +8 -8
- package/dist/testing/mod.js +2 -2
- package/dist/{testing.js → testing-qaAD4B0t.js} +1 -1
- package/dist/types-CB_2uuCA.js +51 -0
- package/dist/types.js +397 -3
- package/dist/vocab/actor.test.js +16 -16
- package/dist/vocab/lookup.test.js +17 -17
- package/dist/vocab/type.test.js +9 -9
- package/dist/vocab/vocab.test.js +17 -17
- package/dist/vocab-B8zleLsO.js +34386 -0
- package/dist/vocab.js +133 -34351
- package/dist/webfinger/handler.test.js +34 -34
- package/dist/webfinger/lookup.test.js +11 -11
- package/dist/x/cfworkers.test.js +7 -7
- package/package.json +1 -1
- /package/dist/{assert_equals.js → assert_equals-Dy0MG_Zw.js} +0 -0
- /package/dist/{chunk.js → chunk-DvTpRkcT.js} +0 -0
- /package/dist/{collection.js → collection-XNLQhehO.js} +0 -0
- /package/dist/compat/{transformers.test.d.ts → transformers.test-DnJbd34u.d.ts} +0 -0
- /package/dist/{denokv.js → denokv-NcJeZ6rP.js} +0 -0
- /package/dist/{docloader2.js → docloader-BDSHZfTJ.js} +0 -0
- /package/dist/federation/{builder.test.d.ts → builder.test-Bpt6NOZ6.d.ts} +0 -0
- /package/dist/federation/{collection.test.d.ts → collection.test-DKJ6JOZz.d.ts} +0 -0
- /package/dist/federation/{handler.test.d.ts → handler.test-BMT7uLC0.d.ts} +0 -0
- /package/dist/federation/{inbox.test.d.ts → inbox.test-Do6i02Qp.d.ts} +0 -0
- /package/dist/federation/{keycache.test.d.ts → keycache.test-BT83IPZY.d.ts} +0 -0
- /package/dist/federation/{kv.test.d.ts → kv.test-kFzzF2VN.d.ts} +0 -0
- /package/dist/federation/{middleware.test.d.ts → middleware.test-B1R4_e3-.d.ts} +0 -0
- /package/dist/federation/{mq.test.d.ts → mq.test-l79EQQOe.d.ts} +0 -0
- /package/dist/federation/{retry.test.d.ts → retry.test-BqS50VCX.d.ts} +0 -0
- /package/dist/federation/{router.test.d.ts → router.test-CYQl4po-.d.ts} +0 -0
- /package/dist/federation/{send.test.d.ts → send.test-COUnNUzv.d.ts} +0 -0
- /package/dist/{kv.js → kv-QeuZ51go.js} +0 -0
- /package/dist/{langstr.js → langstr-pFHBDU4y.js} +0 -0
- /package/dist/{multibase.js → multibase-DBcKTV2a.js} +0 -0
- /package/dist/nodeinfo/{client.test.d.ts → client.test-CZLe79hL.d.ts} +0 -0
- /package/dist/nodeinfo/{handler.test.d.ts → handler.test-B-EDZ_hK.d.ts} +0 -0
- /package/dist/nodeinfo/{semver.test.d.ts → semver.test-BEuuQSEM.d.ts} +0 -0
- /package/dist/nodeinfo/{types.test.d.ts → types.test-B5AT89WV.d.ts} +0 -0
- /package/dist/{retry.js → retry-BQet39_l.js} +0 -0
- /package/dist/{router.js → router-BuDkN4RQ.js} +0 -0
- /package/dist/runtime/{authdocloader.test.d.ts → authdocloader.test-hCRKzn9v.d.ts} +0 -0
- /package/dist/runtime/{docloader.test.d.ts → docloader.test-CVd7i_5h.d.ts} +0 -0
- /package/dist/runtime/{key.test.d.ts → key.test-DBsILYSD.d.ts} +0 -0
- /package/dist/runtime/{langstr.test.d.ts → langstr.test-CiKxuuRY.d.ts} +0 -0
- /package/dist/runtime/multibase/{multibase.test.d.ts → multibase.test-Brh6gPBP.d.ts} +0 -0
- /package/dist/runtime/{url.test.d.ts → url.test-DlRqkU2j.d.ts} +0 -0
- /package/dist/{semver.js → semver-D9d-VO-_.js} +0 -0
- /package/dist/sig/{http.test.d.ts → http.test-BpXNAWNI.d.ts} +0 -0
- /package/dist/sig/{key.test.d.ts → key.test-B2iLIugy.d.ts} +0 -0
- /package/dist/sig/{ld.test.d.ts → ld.test-D-cI70Gw.d.ts} +0 -0
- /package/dist/sig/{owner.test.d.ts → owner.test-B_YRjMPj.d.ts} +0 -0
- /package/dist/sig/{proof.test.d.ts → proof.test-BagEM_-4.d.ts} +0 -0
- /package/dist/testing/{docloader.test.d.ts → docloader.test-lrzf6sDZ.d.ts} +0 -0
- /package/dist/testing/{mod.d.ts → mod-3uM8ZvS7.d.ts} +0 -0
- /package/dist/{type.js → type-DFsmi-p1.js} +0 -0
- /package/dist/{url.js → url-BdNvnK9P.js} +0 -0
- /package/dist/vocab/{actor.test.d.ts → actor.test-ClC-iVWk.d.ts} +0 -0
- /package/dist/vocab/{lookup.test.d.ts → lookup.test-Cq1I-27w.d.ts} +0 -0
- /package/dist/vocab/{type.test.d.ts → type.test-bfFiYGcs.d.ts} +0 -0
- /package/dist/vocab/{vocab.test.d.ts → vocab.test-h-ZTisfu.d.ts} +0 -0
- /package/dist/webfinger/{handler.test.d.ts → handler.test-DiUeEDDD.d.ts} +0 -0
- /package/dist/webfinger/{lookup.test.d.ts → lookup.test-D9onm3U3.d.ts} +0 -0
- /package/dist/x/{cfworkers.test.d.ts → cfworkers.test-KXHlJ29z.d.ts} +0 -0
package/dist/middleware2.js
CHANGED
|
@@ -1,32 +1,17 @@
|
|
|
1
1
|
|
|
2
2
|
import { Temporal } from "@js-temporal/polyfill";
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
|
-
globalThis.addEventListener = () => {};
|
|
5
4
|
|
|
6
|
-
import "./
|
|
7
|
-
import { a as createFederation, i as KvSpecDeterminer, n as FederationImpl, r as InboxContextImpl, t as ContextImpl } from "./middleware.js";
|
|
5
|
+
import "./transformers.js";
|
|
8
6
|
import "./docloader.js";
|
|
9
|
-
import "./url.js";
|
|
10
|
-
import "./semver.js";
|
|
11
|
-
import "./client.js";
|
|
12
|
-
import "./router.js";
|
|
13
|
-
import "./types.js";
|
|
14
|
-
import "./multibase.js";
|
|
15
|
-
import "./vocab.js";
|
|
16
|
-
import "./langstr.js";
|
|
17
|
-
import "./lookup.js";
|
|
18
7
|
import "./actor.js";
|
|
8
|
+
import { a as createFederation, i as KvSpecDeterminer, n as FederationImpl, r as InboxContextImpl, t as ContextImpl } from "./middleware.js";
|
|
9
|
+
import "./lookup.js";
|
|
19
10
|
import "./key2.js";
|
|
20
11
|
import "./http.js";
|
|
21
|
-
import "./authdocloader.js";
|
|
22
|
-
import "./ld.js";
|
|
23
|
-
import "./owner.js";
|
|
24
12
|
import "./proof.js";
|
|
25
|
-
import "./
|
|
26
|
-
import "./
|
|
27
|
-
import "./
|
|
28
|
-
import "./collection.js";
|
|
29
|
-
import "./keycache.js";
|
|
30
|
-
import "./send.js";
|
|
13
|
+
import "./types.js";
|
|
14
|
+
import "./authdocloader.js";
|
|
15
|
+
import "./vocab.js";
|
|
31
16
|
|
|
32
17
|
export { FederationImpl };
|
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import "../chunk.js";
|
|
7
|
-
import { t as assertEquals } from "../assert_equals.js";
|
|
8
|
-
import "../docloader.js";
|
|
9
|
-
import "../url.js";
|
|
10
|
-
import "../semver.js";
|
|
11
|
-
import { a as parseProtocol, c as parseUsage, i as parseOutboundService, n as parseInboundService, o as parseServices, r as parseNodeInfo, s as parseSoftware, t as getNodeInfo } from "../client.js";
|
|
12
|
-
import { t as test } from "../testing.js";
|
|
13
|
-
import "../std__assert
|
|
14
|
-
import "../assert_rejects.js";
|
|
15
|
-
import "../assert_is_error.js";
|
|
16
|
-
import "../assert_throws.js";
|
|
17
|
-
import { t as esm_default } from "../esm.js";
|
|
6
|
+
import "../chunk-DvTpRkcT.js";
|
|
7
|
+
import { t as assertEquals } from "../assert_equals-Dy0MG_Zw.js";
|
|
8
|
+
import "../docloader-I3SkMpZK.js";
|
|
9
|
+
import "../url-BdNvnK9P.js";
|
|
10
|
+
import "../semver-D9d-VO-_.js";
|
|
11
|
+
import { a as parseProtocol, c as parseUsage, i as parseOutboundService, n as parseInboundService, o as parseServices, r as parseNodeInfo, s as parseSoftware, t as getNodeInfo } from "../client-CJ3nfMyp.js";
|
|
12
|
+
import { t as test } from "../testing-qaAD4B0t.js";
|
|
13
|
+
import "../std__assert-BdP_WkD-.js";
|
|
14
|
+
import "../assert_rejects-Bkh5lA1a.js";
|
|
15
|
+
import "../assert_is_error-CIYFACrT.js";
|
|
16
|
+
import "../assert_throws-CmpfkWEM.js";
|
|
17
|
+
import { t as esm_default } from "../esm-BRXvTSrx.js";
|
|
18
18
|
|
|
19
19
|
//#region nodeinfo/client.test.ts
|
|
20
20
|
test("getNodeInfo()", async (t) => {
|
|
@@ -3,40 +3,40 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import "../chunk.js";
|
|
7
|
-
import { t as assertEquals } from "../assert_equals.js";
|
|
8
|
-
import { t as MemoryKvStore } from "../kv.js";
|
|
9
|
-
import { a as createFederation, h as handleNodeInfoJrd, m as handleNodeInfo } from "../middleware.js";
|
|
10
|
-
import "../docloader.js";
|
|
11
|
-
import "../url.js";
|
|
12
|
-
import { n as parseSemVer } from "../semver.js";
|
|
13
|
-
import "../client.js";
|
|
14
|
-
import "../router.js";
|
|
15
|
-
import "../types.js";
|
|
16
|
-
import "../multibase.js";
|
|
17
|
-
import "../vocab.js";
|
|
18
|
-
import "../langstr.js";
|
|
19
|
-
import "../lookup.js";
|
|
20
|
-
import "../actor.js";
|
|
21
|
-
import "../
|
|
22
|
-
import "../http.js";
|
|
23
|
-
import "../authdocloader.js";
|
|
24
|
-
import "../ld.js";
|
|
25
|
-
import "../owner.js";
|
|
26
|
-
import "../proof.js";
|
|
27
|
-
import "../
|
|
28
|
-
import "../inbox.js";
|
|
29
|
-
import "../builder.js";
|
|
30
|
-
import "../collection.js";
|
|
31
|
-
import "../keycache.js";
|
|
32
|
-
import "../send.js";
|
|
33
|
-
import { t as test } from "../testing.js";
|
|
34
|
-
import "../std__assert
|
|
35
|
-
import "../assert_rejects.js";
|
|
36
|
-
import "../assert_is_error.js";
|
|
37
|
-
import "../assert_throws.js";
|
|
38
|
-
import "../
|
|
39
|
-
import { n as createRequestContext } from "../context.js";
|
|
6
|
+
import "../chunk-DvTpRkcT.js";
|
|
7
|
+
import { t as assertEquals } from "../assert_equals-Dy0MG_Zw.js";
|
|
8
|
+
import { t as MemoryKvStore } from "../kv-QeuZ51go.js";
|
|
9
|
+
import { a as createFederation, h as handleNodeInfoJrd, m as handleNodeInfo } from "../middleware-Dvd4BUlF.js";
|
|
10
|
+
import "../docloader-I3SkMpZK.js";
|
|
11
|
+
import "../url-BdNvnK9P.js";
|
|
12
|
+
import { n as parseSemVer } from "../semver-D9d-VO-_.js";
|
|
13
|
+
import "../client-CJ3nfMyp.js";
|
|
14
|
+
import "../router-BuDkN4RQ.js";
|
|
15
|
+
import "../types-CB_2uuCA.js";
|
|
16
|
+
import "../multibase-DBcKTV2a.js";
|
|
17
|
+
import "../vocab-B8zleLsO.js";
|
|
18
|
+
import "../langstr-pFHBDU4y.js";
|
|
19
|
+
import "../lookup-CoCshjhM.js";
|
|
20
|
+
import "../actor-BzWaWDTY.js";
|
|
21
|
+
import "../key-Ba-IjS2c.js";
|
|
22
|
+
import "../http-CiQH4CF3.js";
|
|
23
|
+
import "../authdocloader-1vrHbYJF.js";
|
|
24
|
+
import "../ld-Dm1tdWDX.js";
|
|
25
|
+
import "../owner-BO3ZhyYg.js";
|
|
26
|
+
import "../proof-Btlfk6hr.js";
|
|
27
|
+
import "../lookup-BumKjgCt.js";
|
|
28
|
+
import "../inbox-BqBPO0vG.js";
|
|
29
|
+
import "../builder-8YjpOSrf.js";
|
|
30
|
+
import "../collection-XNLQhehO.js";
|
|
31
|
+
import "../keycache-BdgRTisV.js";
|
|
32
|
+
import "../send-Dj-482tr.js";
|
|
33
|
+
import { t as test } from "../testing-qaAD4B0t.js";
|
|
34
|
+
import "../std__assert-BdP_WkD-.js";
|
|
35
|
+
import "../assert_rejects-Bkh5lA1a.js";
|
|
36
|
+
import "../assert_is_error-CIYFACrT.js";
|
|
37
|
+
import "../assert_throws-CmpfkWEM.js";
|
|
38
|
+
import "../docloader-BDSHZfTJ.js";
|
|
39
|
+
import { n as createRequestContext } from "../context-OXYKUfFL.js";
|
|
40
40
|
|
|
41
41
|
//#region nodeinfo/handler.test.ts
|
|
42
42
|
test("handleNodeInfo()", async () => {
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import "../chunk.js";
|
|
7
|
-
import { t as assertEquals } from "../assert_equals.js";
|
|
8
|
-
import { n as parseSemVer, t as formatSemVer } from "../semver.js";
|
|
9
|
-
import { t as test } from "../testing.js";
|
|
10
|
-
import "../std__assert
|
|
11
|
-
import "../assert_rejects.js";
|
|
12
|
-
import "../assert_is_error.js";
|
|
13
|
-
import { t as assertThrows } from "../assert_throws.js";
|
|
6
|
+
import "../chunk-DvTpRkcT.js";
|
|
7
|
+
import { t as assertEquals } from "../assert_equals-Dy0MG_Zw.js";
|
|
8
|
+
import { n as parseSemVer, t as formatSemVer } from "../semver-D9d-VO-_.js";
|
|
9
|
+
import { t as test } from "../testing-qaAD4B0t.js";
|
|
10
|
+
import "../std__assert-BdP_WkD-.js";
|
|
11
|
+
import "../assert_rejects-Bkh5lA1a.js";
|
|
12
|
+
import "../assert_is_error-CIYFACrT.js";
|
|
13
|
+
import { t as assertThrows } from "../assert_throws-CmpfkWEM.js";
|
|
14
14
|
|
|
15
15
|
//#region nodeinfo/semver.test.ts
|
|
16
16
|
test("parseSemVer() handles major", async (t) => {
|
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import "../chunk.js";
|
|
7
|
-
import { t as assertEquals } from "../assert_equals.js";
|
|
8
|
-
import "../semver.js";
|
|
9
|
-
import { t as nodeInfoToJson } from "../types.js";
|
|
10
|
-
import { t as test } from "../testing.js";
|
|
11
|
-
import "../std__assert
|
|
12
|
-
import "../assert_rejects.js";
|
|
13
|
-
import "../assert_is_error.js";
|
|
14
|
-
import { t as assertThrows } from "../assert_throws.js";
|
|
6
|
+
import "../chunk-DvTpRkcT.js";
|
|
7
|
+
import { t as assertEquals } from "../assert_equals-Dy0MG_Zw.js";
|
|
8
|
+
import "../semver-D9d-VO-_.js";
|
|
9
|
+
import { t as nodeInfoToJson } from "../types-CB_2uuCA.js";
|
|
10
|
+
import { t as test } from "../testing-qaAD4B0t.js";
|
|
11
|
+
import "../std__assert-BdP_WkD-.js";
|
|
12
|
+
import "../assert_rejects-Bkh5lA1a.js";
|
|
13
|
+
import "../assert_is_error-CIYFACrT.js";
|
|
14
|
+
import { t as assertThrows } from "../assert_throws-CmpfkWEM.js";
|
|
15
15
|
|
|
16
16
|
//#region nodeinfo/types.test.ts
|
|
17
17
|
test("nodeInfoToJson()", () => {
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import { i as getDocumentLoader } from "./docloader.js";
|
|
7
|
-
import { _ as Object$1, o as CryptographicKey } from "./vocab.js";
|
|
8
|
-
import { i as isActor } from "./actor.js";
|
|
6
|
+
import { i as getDocumentLoader } from "./docloader-I3SkMpZK.js";
|
|
7
|
+
import { _ as Object$1, o as CryptographicKey } from "./vocab-B8zleLsO.js";
|
|
8
|
+
import { i as isActor } from "./actor-BzWaWDTY.js";
|
|
9
9
|
import { trace } from "@opentelemetry/api";
|
|
10
10
|
|
|
11
11
|
//#region sig/owner.ts
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
|
4
|
+
globalThis.addEventListener = () => {};
|
|
5
|
+
|
|
6
|
+
import { d as version, u as name } from "./docloader-I3SkMpZK.js";
|
|
7
|
+
import { h as Multikey, s as DataIntegrityProof, t as Activity } from "./vocab-B8zleLsO.js";
|
|
8
|
+
import { t as getTypeId } from "./type-DFsmi-p1.js";
|
|
9
|
+
import { a as validateCryptoKey, n as fetchKey } from "./key-Ba-IjS2c.js";
|
|
10
|
+
import { getLogger } from "@logtape/logtape";
|
|
11
|
+
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
12
|
+
import { encodeHex } from "byte-encodings/hex";
|
|
13
|
+
import serialize from "json-canon";
|
|
14
|
+
|
|
15
|
+
//#region sig/proof.ts
|
|
16
|
+
const logger = getLogger([
|
|
17
|
+
"fedify",
|
|
18
|
+
"sig",
|
|
19
|
+
"proof"
|
|
20
|
+
]);
|
|
21
|
+
/**
|
|
22
|
+
* Creates a proof for the given object.
|
|
23
|
+
* @param object The object to create a proof for.
|
|
24
|
+
* @param privateKey The private key to sign the proof with.
|
|
25
|
+
* @param keyId The key ID to use in the proof. It will be used by the verifier.
|
|
26
|
+
* @param options Additional options. See also {@link CreateProofOptions}.
|
|
27
|
+
* @returns The created proof.
|
|
28
|
+
* @throws {TypeError} If the private key is invalid or unsupported.
|
|
29
|
+
* @since 0.10.0
|
|
30
|
+
*/
|
|
31
|
+
async function createProof(object, privateKey, keyId, { contextLoader, context: context$1, created } = {}) {
|
|
32
|
+
validateCryptoKey(privateKey, "private");
|
|
33
|
+
if (privateKey.algorithm.name !== "Ed25519") throw new TypeError("Unsupported algorithm: " + privateKey.algorithm.name);
|
|
34
|
+
const compactMsg = await object.clone({ proofs: [] }).toJsonLd({
|
|
35
|
+
format: "compact",
|
|
36
|
+
contextLoader,
|
|
37
|
+
context: context$1
|
|
38
|
+
});
|
|
39
|
+
const msgCanon = serialize(compactMsg);
|
|
40
|
+
const encoder = new TextEncoder();
|
|
41
|
+
const msgBytes = encoder.encode(msgCanon);
|
|
42
|
+
const msgDigest = await crypto.subtle.digest("SHA-256", msgBytes);
|
|
43
|
+
created ??= Temporal.Now.instant();
|
|
44
|
+
const proofCanon = serialize({
|
|
45
|
+
"@context": compactMsg["@context"],
|
|
46
|
+
type: "DataIntegrityProof",
|
|
47
|
+
cryptosuite: "eddsa-jcs-2022",
|
|
48
|
+
verificationMethod: keyId.href,
|
|
49
|
+
proofPurpose: "assertionMethod",
|
|
50
|
+
created: created.toString()
|
|
51
|
+
});
|
|
52
|
+
const proofBytes = encoder.encode(proofCanon);
|
|
53
|
+
const proofDigest = await crypto.subtle.digest("SHA-256", proofBytes);
|
|
54
|
+
const digest = new Uint8Array(proofDigest.byteLength + msgDigest.byteLength);
|
|
55
|
+
digest.set(new Uint8Array(proofDigest), 0);
|
|
56
|
+
digest.set(new Uint8Array(msgDigest), proofDigest.byteLength);
|
|
57
|
+
const sig = await crypto.subtle.sign("Ed25519", privateKey, digest);
|
|
58
|
+
return new DataIntegrityProof({
|
|
59
|
+
cryptosuite: "eddsa-jcs-2022",
|
|
60
|
+
verificationMethod: keyId,
|
|
61
|
+
proofPurpose: "assertionMethod",
|
|
62
|
+
created: created ?? Temporal.Now.instant(),
|
|
63
|
+
proofValue: new Uint8Array(sig)
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Signs the given object with the private key and returns the signed object.
|
|
68
|
+
* @param object The object to create a proof for.
|
|
69
|
+
* @param privateKey The private key to sign the proof with.
|
|
70
|
+
* @param keyId The key ID to use in the proof. It will be used by the verifier.
|
|
71
|
+
* @param options Additional options. See also {@link SignObjectOptions}.
|
|
72
|
+
* @returns The signed object.
|
|
73
|
+
* @throws {TypeError} If the private key is invalid or unsupported.
|
|
74
|
+
* @since 0.10.0
|
|
75
|
+
*/
|
|
76
|
+
async function signObject(object, privateKey, keyId, options = {}) {
|
|
77
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("object_integrity_proofs.sign", { attributes: { "activitypub.object.type": getTypeId(object).href } }, async (span) => {
|
|
78
|
+
try {
|
|
79
|
+
if (object.id != null) span.setAttribute("activitypub.object.id", object.id.href);
|
|
80
|
+
const existingProofs = [];
|
|
81
|
+
for await (const proof$1 of object.getProofs(options)) existingProofs.push(proof$1);
|
|
82
|
+
const proof = await createProof(object, privateKey, keyId, options);
|
|
83
|
+
if (span.isRecording()) {
|
|
84
|
+
if (proof.cryptosuite != null) span.setAttribute("object_integrity_proofs.cryptosuite", proof.cryptosuite);
|
|
85
|
+
if (proof.verificationMethodId != null) span.setAttribute("object_integrity_proofs.key_id", proof.verificationMethodId.href);
|
|
86
|
+
if (proof.proofValue != null) span.setAttribute("object_integrity_proofs.signature", encodeHex(proof.proofValue));
|
|
87
|
+
}
|
|
88
|
+
return object.clone({ proofs: [...existingProofs, proof] });
|
|
89
|
+
} catch (error) {
|
|
90
|
+
span.setStatus({
|
|
91
|
+
code: SpanStatusCode.ERROR,
|
|
92
|
+
message: String(error)
|
|
93
|
+
});
|
|
94
|
+
throw error;
|
|
95
|
+
} finally {
|
|
96
|
+
span.end();
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Verifies the given proof for the object.
|
|
102
|
+
* @param jsonLd The JSON-LD object to verify the proof for. If it contains
|
|
103
|
+
* any proofs, they will be ignored.
|
|
104
|
+
* @param proof The proof to verify.
|
|
105
|
+
* @param options Additional options. See also {@link VerifyProofOptions}.
|
|
106
|
+
* @returns The public key that was used to sign the proof, or `null` if the
|
|
107
|
+
* proof is invalid.
|
|
108
|
+
* @since 0.10.0
|
|
109
|
+
*/
|
|
110
|
+
async function verifyProof(jsonLd, proof, options = {}) {
|
|
111
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("object_integrity_proofs.verify", async (span) => {
|
|
112
|
+
if (span.isRecording()) {
|
|
113
|
+
if (proof.cryptosuite != null) span.setAttribute("object_integrity_proofs.cryptosuite", proof.cryptosuite);
|
|
114
|
+
if (proof.verificationMethodId != null) span.setAttribute("object_integrity_proofs.key_id", proof.verificationMethodId.href);
|
|
115
|
+
if (proof.proofValue != null) span.setAttribute("object_integrity_proofs.signature", encodeHex(proof.proofValue));
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
const key = await verifyProofInternal(jsonLd, proof, options);
|
|
119
|
+
if (key == null) span.setStatus({ code: SpanStatusCode.ERROR });
|
|
120
|
+
return key;
|
|
121
|
+
} catch (error) {
|
|
122
|
+
span.setStatus({
|
|
123
|
+
code: SpanStatusCode.ERROR,
|
|
124
|
+
message: String(error)
|
|
125
|
+
});
|
|
126
|
+
throw error;
|
|
127
|
+
} finally {
|
|
128
|
+
span.end();
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
async function verifyProofInternal(jsonLd, proof, options) {
|
|
133
|
+
if (typeof jsonLd !== "object" || proof.cryptosuite !== "eddsa-jcs-2022" || proof.verificationMethodId == null || proof.proofPurpose !== "assertionMethod" || proof.proofValue == null || proof.created == null) return null;
|
|
134
|
+
const publicKeyPromise = fetchKey(proof.verificationMethodId, Multikey, options);
|
|
135
|
+
const proofCanon = serialize({
|
|
136
|
+
"@context": jsonLd["@context"],
|
|
137
|
+
type: "DataIntegrityProof",
|
|
138
|
+
cryptosuite: proof.cryptosuite,
|
|
139
|
+
verificationMethod: proof.verificationMethodId.href,
|
|
140
|
+
proofPurpose: proof.proofPurpose,
|
|
141
|
+
created: proof.created.toString()
|
|
142
|
+
});
|
|
143
|
+
const encoder = new TextEncoder();
|
|
144
|
+
const proofBytes = encoder.encode(proofCanon);
|
|
145
|
+
const proofDigest = await crypto.subtle.digest("SHA-256", proofBytes);
|
|
146
|
+
const msg = { ...jsonLd };
|
|
147
|
+
if ("proof" in msg) delete msg.proof;
|
|
148
|
+
const msgCanon = serialize(msg);
|
|
149
|
+
const msgBytes = encoder.encode(msgCanon);
|
|
150
|
+
const msgDigest = await crypto.subtle.digest("SHA-256", msgBytes);
|
|
151
|
+
const digest = new Uint8Array(proofDigest.byteLength + msgDigest.byteLength);
|
|
152
|
+
digest.set(new Uint8Array(proofDigest), 0);
|
|
153
|
+
digest.set(new Uint8Array(msgDigest), proofDigest.byteLength);
|
|
154
|
+
let fetchedKey;
|
|
155
|
+
try {
|
|
156
|
+
fetchedKey = await publicKeyPromise;
|
|
157
|
+
} catch (error) {
|
|
158
|
+
logger.debug("Failed to get the key (verificationMethod) for the proof:\n{proof}", {
|
|
159
|
+
proof,
|
|
160
|
+
keyId: proof.verificationMethodId.href,
|
|
161
|
+
error
|
|
162
|
+
});
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
const publicKey = fetchedKey.key;
|
|
166
|
+
if (publicKey == null) {
|
|
167
|
+
logger.debug("Failed to get the key (verificationMethod) for the proof:\n{proof}", {
|
|
168
|
+
proof,
|
|
169
|
+
keyId: proof.verificationMethodId.href
|
|
170
|
+
});
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
if (publicKey.publicKey.algorithm.name !== "Ed25519") {
|
|
174
|
+
if (fetchedKey.cached) {
|
|
175
|
+
logger.debug("The cached key (verificationMethod) for the proof is not a valid Ed25519 key:\n{keyId}; retrying with the freshly fetched key...", {
|
|
176
|
+
proof,
|
|
177
|
+
keyId: proof.verificationMethodId.href
|
|
178
|
+
});
|
|
179
|
+
return await verifyProof(jsonLd, proof, {
|
|
180
|
+
...options,
|
|
181
|
+
keyCache: {
|
|
182
|
+
get: () => Promise.resolve(null),
|
|
183
|
+
set: async (keyId, key) => await options.keyCache?.set(keyId, key)
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
logger.debug("The fetched key (verificationMethod) for the proof is not a valid Ed25519 key:\n{keyId}", {
|
|
188
|
+
proof,
|
|
189
|
+
keyId: proof.verificationMethodId.href
|
|
190
|
+
});
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
if (!await crypto.subtle.verify("Ed25519", publicKey.publicKey, proof.proofValue.slice(), digest)) {
|
|
194
|
+
if (fetchedKey.cached) {
|
|
195
|
+
logger.debug("Failed to verify the proof with the cached key {keyId}; retrying with the freshly fetched key...", {
|
|
196
|
+
keyId: proof.verificationMethodId.href,
|
|
197
|
+
proof
|
|
198
|
+
});
|
|
199
|
+
return await verifyProof(jsonLd, proof, {
|
|
200
|
+
...options,
|
|
201
|
+
keyCache: {
|
|
202
|
+
get: () => Promise.resolve(void 0),
|
|
203
|
+
set: async (keyId, key) => await options.keyCache?.set(keyId, key)
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
logger.debug("Failed to verify the proof with the fetched key {keyId}:\n{proof}", {
|
|
208
|
+
keyId: proof.verificationMethodId.href,
|
|
209
|
+
proof
|
|
210
|
+
});
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
return publicKey;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Verifies the given object. It will verify all the proofs in the object,
|
|
217
|
+
* and succeed only if all the proofs are valid and all attributions and
|
|
218
|
+
* actors are authenticated by the proofs.
|
|
219
|
+
* @typeParam T The type of the object to verify.
|
|
220
|
+
* @param cls The class of the object to verify. It must be a subclass of
|
|
221
|
+
* the {@link Object}.
|
|
222
|
+
* @param jsonLd The JSON-LD object to verify. It's assumed that the object
|
|
223
|
+
* is a compacted JSON-LD representation of a `T` with `@context`.
|
|
224
|
+
* @param options Additional options. See also {@link VerifyObjectOptions}.
|
|
225
|
+
* @returns The object if it's verified, or `null` if it's not.
|
|
226
|
+
* @throws {TypeError} If the object is invalid or unsupported.
|
|
227
|
+
* @since 0.10.0
|
|
228
|
+
*/
|
|
229
|
+
async function verifyObject(cls, jsonLd, options = {}) {
|
|
230
|
+
const logger$1 = getLogger([
|
|
231
|
+
"fedify",
|
|
232
|
+
"sig",
|
|
233
|
+
"proof"
|
|
234
|
+
]);
|
|
235
|
+
const object = await cls.fromJsonLd(jsonLd, options);
|
|
236
|
+
const attributions = new Set(object.attributionIds.map((uri) => uri.href));
|
|
237
|
+
if (object instanceof Activity) for (const uri of object.actorIds) attributions.add(uri.href);
|
|
238
|
+
for await (const proof of object.getProofs(options)) {
|
|
239
|
+
const key = await verifyProof(jsonLd, proof, options);
|
|
240
|
+
if (key === null) return null;
|
|
241
|
+
if (key.controllerId == null) {
|
|
242
|
+
logger$1.debug("Key {keyId} does not have a controller.", { keyId: key.id?.href });
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
attributions.delete(key.controllerId.href);
|
|
246
|
+
}
|
|
247
|
+
if (attributions.size > 0) {
|
|
248
|
+
logger$1.debug("Some attributions are not authenticated by the proofs: {attributions}.", { attributions: [...attributions] });
|
|
249
|
+
return null;
|
|
250
|
+
}
|
|
251
|
+
return object;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
//#endregion
|
|
255
|
+
export { verifyProof as i, signObject as n, verifyObject as r, createProof as t };
|