@fedify/fedify 2.0.0-dev.1690 → 2.0.0-dev.170
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/LICENSE +1 -1
- package/README.md +70 -34
- package/dist/{assert_rejects-DiIiJbZn.js → assert_rejects-Ce45JcFg.js} +1 -1
- package/dist/{assert_is_error-BPGph1Jx.js → assert_throws-BNXdRGWP.js} +31 -1
- package/dist/{builder-CYOcDUkj.js → builder-_MVsWtsS.js} +9 -8
- package/dist/{client-bgSdkFa2.d.ts → client-CUTUGgvJ.d.ts} +19 -19
- package/dist/{client-CnOdwLLN.js → client-Dg7OfUDA.js} +28 -23
- package/dist/{client-CegPX0Rn.d.cts → client-by-PEGAJ.d.cts} +19 -19
- package/dist/compat/mod.cjs +1 -1
- package/dist/compat/mod.d.cts +6 -12
- package/dist/compat/mod.d.ts +6 -12
- package/dist/compat/mod.js +1 -1
- package/dist/compat/transformers.test.js +19 -18
- package/dist/context-Bns6uTJq.js +109 -0
- package/dist/{context-ByZprN0S.d.ts → context-C7vzWilY.d.ts} +314 -182
- package/dist/{context-C5BsZkDr.d.cts → context-CrB9RFy5.d.cts} +314 -182
- package/dist/deno-DhWON59o.js +117 -0
- package/dist/{testing-BWNCAbL-.js → dist-B5f6a8Tt.js} +90 -111
- package/dist/{authdocloader-Brax1A32.js → docloader-Cni79dmb.js} +17 -8
- package/dist/{esm-DnIzfEj0.js → esm-DGl7uK1r.js} +32 -17
- package/dist/federation/builder.test.js +11 -11
- package/dist/federation/collection.test.js +5 -8
- package/dist/federation/handler.test.js +111 -24
- package/dist/federation/idempotency.test.js +24 -24
- package/dist/federation/inbox.test.js +5 -6
- package/dist/federation/keycache.test.js +4 -5
- package/dist/federation/kv.test.js +60 -9
- package/dist/federation/middleware.test.js +102 -101
- package/dist/federation/mod.cjs +8 -12
- package/dist/federation/mod.d.cts +7 -13
- package/dist/federation/mod.d.ts +7 -13
- package/dist/federation/mod.js +8 -13
- package/dist/federation/mq.test.js +9 -10
- package/dist/federation/negotiation.test.js +5 -8
- package/dist/federation/retry.test.js +2 -4
- package/dist/federation/router.test.js +6 -8
- package/dist/federation/send.test.js +55 -15
- package/dist/{webfinger/handler.test.js → federation/webfinger.test.js} +25 -24
- package/dist/{federation-H2_En3j5.cjs → federation-B431K2gm.cjs} +22 -0
- package/dist/{federation-D1U8YY9t.js → federation-BbZwNNWj.js} +28 -6
- package/dist/{http-C7vbQwbz.cjs → http-7RQPvAkX.cjs} +410 -14
- package/dist/{http-BxbM8sEy.js → http-CZXlv4xU.js} +371 -11
- package/dist/{http-D-e6AFwR.d.cts → http-ClB3pLcL.d.cts} +2 -2
- package/dist/{http-BNOYnVsU.js → http-CwsBL5_A.js} +3 -2
- package/dist/{http-D6Uj2x2y.d.ts → http-DLBDPal9.d.ts} +2 -2
- package/dist/{inbox-BRru9pX3.js → inbox-CukSCwad.js} +2 -1
- package/dist/{key-1KXru8Ug.js → key-DKkHKzvg.js} +3 -2
- package/dist/{keycache-CN61iGVj.js → keycache-DRxpZ5r9.js} +1 -1
- package/dist/{keys-BPdFKgiy.js → keys-ZbcByPg9.js} +2 -1
- package/dist/{kv-63Cil1MD.d.cts → kv-B4vFhIYL.d.cts} +30 -1
- package/dist/{kv-C7sopW2E.d.ts → kv-CYySNrsn.d.ts} +30 -1
- package/dist/{kv-CRZrzyXm.js → kv-QzKcOQgP.js} +22 -0
- package/dist/kv-cache-BEeqyGER.js +107 -0
- package/dist/kv-cache-BVA7CrnS.cjs +134 -0
- package/dist/kv-cache-HDuc4ZaJ.js +122 -0
- package/dist/{ld-Dv8DNNAT.js → ld-CM6OO5ar.js} +4 -2
- package/dist/middleware--i9t8nKh.js +26 -0
- package/dist/middleware-C567nJlD.cjs +12 -0
- package/dist/middleware-D9oWuacw.js +12 -0
- package/dist/{middleware-DY9B2lL8.js → middleware-DXRcwk_y.js} +185 -192
- package/dist/{middleware-BmoOlgc1.cjs → middleware-TufpQUzj.cjs} +251 -241
- package/dist/{middleware-Bz_A2jeJ.js → middleware-eDeNdyRA.js} +195 -191
- package/dist/mod-0p9zUdzg.d.cts +107 -0
- package/dist/mod-0qnPv4EC.d.cts +62 -0
- package/dist/{mod-Djzcw2ry.d.cts → mod-BrS8tiad.d.cts} +3 -3
- package/dist/mod-C3SOvTD1.d.ts +64 -0
- package/dist/{mod-8DMWKtQE.d.cts → mod-D6pS5_xJ.d.cts} +4 -4
- package/dist/{mod-BhUKmBJD.d.ts → mod-jOa7W503.d.ts} +3 -3
- package/dist/{mod-D6hQoxC5.d.ts → mod-waqu-BL_.d.ts} +4 -4
- package/dist/mod-xc20HhMD.d.ts +109 -0
- package/dist/mod.cjs +17 -112
- package/dist/mod.d.cts +11 -17
- package/dist/mod.d.ts +11 -17
- package/dist/mod.js +11 -17
- package/dist/nodeinfo/client.test.js +7 -10
- package/dist/nodeinfo/handler.test.js +23 -23
- package/dist/nodeinfo/mod.cjs +2 -3
- package/dist/nodeinfo/mod.d.cts +2 -4
- package/dist/nodeinfo/mod.d.ts +2 -4
- package/dist/nodeinfo/mod.js +2 -3
- package/dist/nodeinfo/types.test.js +6 -9
- package/dist/otel/exporter.test.js +893 -0
- package/dist/otel/mod.cjs +256 -0
- package/dist/otel/mod.d.cts +230 -0
- package/dist/otel/mod.d.ts +232 -0
- package/dist/otel/mod.js +255 -0
- package/dist/{owner-e3FYDhsk.js → owner-BOEfZQv2.js} +45 -8
- package/dist/{owner-hd9lvQcP.d.ts → owner-BgI8C-VY.d.ts} +2 -3
- package/dist/{owner-BN_tO3cY.d.cts → owner-C-zfmVAD.d.cts} +2 -3
- package/dist/{proof-B-eqv0Ug.cjs → proof-CaDQpGJD.cjs} +69 -33
- package/dist/{proof-DfgvA3al.js → proof-iYIDiv8I.js} +47 -11
- package/dist/{proof-6gFMwMNJ.js → proof-iw6KtIyj.js} +3 -2
- package/dist/router-D9eI0s4b.js +118 -0
- package/dist/{send-Tl9NOnmO.js → send-Bn8o0mjW.js} +9 -4
- package/dist/sig/http.test.js +11 -13
- package/dist/sig/key.test.js +9 -11
- package/dist/sig/ld.test.js +8 -10
- package/dist/sig/mod.cjs +7 -11
- package/dist/sig/mod.d.cts +3 -7
- package/dist/sig/mod.d.ts +3 -7
- package/dist/sig/mod.js +3 -7
- package/dist/sig/owner.test.js +33 -12
- package/dist/sig/proof.test.js +13 -14
- package/dist/testing/mod.d.ts +183 -7194
- package/dist/testing/mod.js +4 -4
- package/dist/{transformers-CoBS-oFG.cjs → transformers-BjBg6Lag.cjs} +2 -2
- package/dist/{transformers-BFT6d7J5.js → transformers-N_ip_y4P.js} +2 -2
- package/dist/{types-DqxyTxOf.js → types-8l28uC8o.js} +31 -26
- package/dist/{types-zqdWZh4O.cjs → types-B6z6CqIz.cjs} +33 -28
- package/dist/{types-BSuWJsOm.js → types-CPz01LGH.js} +3 -3
- package/dist/{runtime/authdocloader.test.js → utils/docloader.test.js} +13 -15
- package/dist/utils/kv-cache.test.js +211 -0
- package/dist/utils/mod.cjs +10 -0
- package/dist/utils/mod.d.cts +4 -0
- package/dist/utils/mod.d.ts +6 -0
- package/dist/utils/mod.js +9 -0
- package/package.json +34 -75
- package/dist/actor-Be0ThtXy.cjs +0 -42609
- package/dist/actor-ChbPLm6n.js +0 -42135
- package/dist/actor-D6K058Tb.d.cts +0 -128
- package/dist/actor-DuCeRiNh.js +0 -146
- package/dist/actor-T6RyhRgk.d.ts +0 -130
- package/dist/assert_throws-BOO88avQ.js +0 -39
- package/dist/authdocloader-CrxhFL8e.js +0 -52
- package/dist/authdocloader-OSn_teLV.cjs +0 -58
- package/dist/denokv-Bv33Xxea.js +0 -57
- package/dist/docloader-CCqXeagZ.cjs +0 -4861
- package/dist/docloader-CxWcuWqQ.d.ts +0 -221
- package/dist/docloader-D-MrRyHl.d.cts +0 -219
- package/dist/docloader-XK3y2jn5.js +0 -4795
- package/dist/fixtures/activitypub.academy/users/brauca_darradiul.json +0 -83
- package/dist/fixtures/example.com/announce.json +0 -6
- package/dist/fixtures/example.com/collection.json +0 -19
- package/dist/fixtures/example.com/create.json +0 -6
- package/dist/fixtures/example.com/cross-origin-actor.json +0 -6
- package/dist/fixtures/example.com/hong-gildong.json +0 -11
- package/dist/fixtures/example.com/invite.json +0 -7
- package/dist/fixtures/example.com/key.json +0 -7
- package/dist/fixtures/example.com/key2.json +0 -6
- package/dist/fixtures/example.com/object.json +0 -6
- package/dist/fixtures/example.com/orderedcollectionpage.json +0 -24
- package/dist/fixtures/example.com/paged/a.json +0 -13
- package/dist/fixtures/example.com/paged/b.json +0 -16
- package/dist/fixtures/example.com/paged-collection.json +0 -6
- package/dist/fixtures/example.com/person.json +0 -22
- package/dist/fixtures/example.com/person2.json +0 -40
- package/dist/fixtures/example.com/test.json +0 -5
- package/dist/fixtures/example.com/users/handle.json +0 -16
- package/dist/fixtures/example.com/wrong-type.json +0 -3
- package/dist/fixtures/media.example.com/avatars/test-avatar.jpg.json +0 -6
- package/dist/fixtures/oeee.cafe/ap/users/3609fd4e-d51d-4db8-9f04-4189815864dd.json +0 -24
- package/dist/fixtures/remote.domain/users/bob.json +0 -20
- package/dist/fixtures/server.example/users/alice.json +0 -20
- package/dist/fixtures/w3id.org/identity/v1.json +0 -152
- package/dist/fixtures/w3id.org/security/data-integrity/v1.json +0 -74
- package/dist/fixtures/w3id.org/security/multikey/v1.json +0 -35
- package/dist/fixtures/w3id.org/security/v1.json +0 -50
- package/dist/fixtures/wizard.casa/users/hongminhee.json +0 -69
- package/dist/fixtures/www.w3.org/ns/activitystreams.json +0 -379
- package/dist/fixtures/www.w3.org/ns/did/v1.json +0 -58
- package/dist/key-B3uag-rz.js +0 -10
- package/dist/key-BiBmb1Yy.cjs +0 -10
- package/dist/key-DK_nfU4I.js +0 -10
- package/dist/key-Z6ceKnZC.cjs +0 -290
- package/dist/key-jyNTxCvK.js +0 -260
- package/dist/lookup-BPviO8ij.js +0 -131
- package/dist/lookup-hnMAAU5r.cjs +0 -137
- package/dist/lookup-pV0JOsuV.js +0 -331
- package/dist/middleware-CI0-zw4U.js +0 -26
- package/dist/middleware-QNK-W-jE.cjs +0 -17
- package/dist/middleware-_vjt6FWU.js +0 -17
- package/dist/mod-CerN_Sza.d.ts +0 -104
- package/dist/mod-Cj1tHXBR.d.cts +0 -102
- package/dist/mod-CxkWO3Mg.d.cts +0 -307
- package/dist/mod-DBzN0aCM.d.ts +0 -115
- package/dist/mod-DlU8ISoa.d.ts +0 -309
- package/dist/mod-FZd39qVq.d.cts +0 -1
- package/dist/mod-g0xFzAP9.d.ts +0 -2
- package/dist/mod-jQ4OODsl.d.cts +0 -113
- package/dist/mq-B7R1Q-M5.d.cts +0 -140
- package/dist/mq-CRGm1e_F.d.ts +0 -143
- package/dist/runtime/docloader.test.js +0 -522
- package/dist/runtime/key.test.js +0 -103
- package/dist/runtime/langstr.test.d.ts +0 -3
- package/dist/runtime/langstr.test.js +0 -39
- package/dist/runtime/link.test.d.ts +0 -3
- package/dist/runtime/link.test.js +0 -61
- package/dist/runtime/mod.cjs +0 -25
- package/dist/runtime/mod.d.cts +0 -6
- package/dist/runtime/mod.d.ts +0 -8
- package/dist/runtime/mod.js +0 -13
- package/dist/runtime/multibase/multibase.test.d.ts +0 -3
- package/dist/runtime/multibase/multibase.test.js +0 -358
- package/dist/runtime/url.test.d.ts +0 -3
- package/dist/runtime/url.test.js +0 -45
- package/dist/src/vocab/accept.yaml +0 -15
- package/dist/src/vocab/activity.yaml +0 -98
- package/dist/src/vocab/add.yaml +0 -16
- package/dist/src/vocab/announce.yaml +0 -30
- package/dist/src/vocab/application.yaml +0 -324
- package/dist/src/vocab/arrive.yaml +0 -15
- package/dist/src/vocab/article.yaml +0 -46
- package/dist/src/vocab/audio.yaml +0 -11
- package/dist/src/vocab/block.yaml +0 -16
- package/dist/src/vocab/chatmessage.yaml +0 -50
- package/dist/src/vocab/collection.yaml +0 -154
- package/dist/src/vocab/collectionpage.yaml +0 -55
- package/dist/src/vocab/create.yaml +0 -28
- package/dist/src/vocab/dataintegrityproof.yaml +0 -56
- package/dist/src/vocab/delete.yaml +0 -27
- package/dist/src/vocab/didservice.yaml +0 -22
- package/dist/src/vocab/dislike.yaml +0 -14
- package/dist/src/vocab/document.yaml +0 -31
- package/dist/src/vocab/emoji.yaml +0 -12
- package/dist/src/vocab/emojireact.yaml +0 -17
- package/dist/src/vocab/endpoints.yaml +0 -85
- package/dist/src/vocab/event.yaml +0 -11
- package/dist/src/vocab/export.yaml +0 -9
- package/dist/src/vocab/flag.yaml +0 -15
- package/dist/src/vocab/follow.yaml +0 -19
- package/dist/src/vocab/group.yaml +0 -324
- package/dist/src/vocab/hashtag.yaml +0 -14
- package/dist/src/vocab/ignore.yaml +0 -14
- package/dist/src/vocab/image.yaml +0 -9
- package/dist/src/vocab/intransitiveactivity.yaml +0 -15
- package/dist/src/vocab/invite.yaml +0 -14
- package/dist/src/vocab/join.yaml +0 -14
- package/dist/src/vocab/key.yaml +0 -28
- package/dist/src/vocab/leave.yaml +0 -14
- package/dist/src/vocab/like.yaml +0 -16
- package/dist/src/vocab/link.yaml +0 -101
- package/dist/src/vocab/listen.yaml +0 -12
- package/dist/src/vocab/mention.yaml +0 -9
- package/dist/src/vocab/move.yaml +0 -15
- package/dist/src/vocab/multikey.yaml +0 -36
- package/dist/src/vocab/note.yaml +0 -48
- package/dist/src/vocab/object.yaml +0 -404
- package/dist/src/vocab/offer.yaml +0 -15
- package/dist/src/vocab/orderedcollection.yaml +0 -39
- package/dist/src/vocab/orderedcollectionpage.yaml +0 -50
- package/dist/src/vocab/organization.yaml +0 -324
- package/dist/src/vocab/page.yaml +0 -11
- package/dist/src/vocab/person.yaml +0 -324
- package/dist/src/vocab/place.yaml +0 -75
- package/dist/src/vocab/profile.yaml +0 -26
- package/dist/src/vocab/propertyvalue.yaml +0 -32
- package/dist/src/vocab/question.yaml +0 -103
- package/dist/src/vocab/read.yaml +0 -13
- package/dist/src/vocab/reject.yaml +0 -14
- package/dist/src/vocab/relationship.yaml +0 -52
- package/dist/src/vocab/remove.yaml +0 -14
- package/dist/src/vocab/service.yaml +0 -324
- package/dist/src/vocab/source.yaml +0 -26
- package/dist/src/vocab/tentativeaccept.yaml +0 -14
- package/dist/src/vocab/tentativereject.yaml +0 -14
- package/dist/src/vocab/tombstone.yaml +0 -24
- package/dist/src/vocab/travel.yaml +0 -16
- package/dist/src/vocab/undo.yaml +0 -26
- package/dist/src/vocab/update.yaml +0 -58
- package/dist/src/vocab/video.yaml +0 -11
- package/dist/src/vocab/view.yaml +0 -13
- package/dist/testing/docloader.test.js +0 -24
- package/dist/type-C69ZBu7f.js +0 -47010
- package/dist/vocab/actor.test.d.ts +0 -3
- package/dist/vocab/actor.test.js +0 -5965
- package/dist/vocab/lookup.test.d.ts +0 -3
- package/dist/vocab/lookup.test.js +0 -456
- package/dist/vocab/mod.cjs +0 -87
- package/dist/vocab/mod.d.cts +0 -6
- package/dist/vocab/mod.d.ts +0 -8
- package/dist/vocab/mod.js +0 -10
- package/dist/vocab/schema.yaml +0 -247
- package/dist/vocab/type.test.d.ts +0 -3
- package/dist/vocab/type.test.js +0 -25
- package/dist/vocab/vocab.test.d.ts +0 -3
- package/dist/vocab/vocab.test.js +0 -3787
- package/dist/vocab-B39-pFl9.cjs +0 -291
- package/dist/vocab-BI0Ak5lL.d.ts +0 -14924
- package/dist/vocab-BWoeZsME.js +0 -255
- package/dist/vocab-Dw1-yVGg.d.cts +0 -14922
- package/dist/webfinger/handler.test.d.ts +0 -3
- package/dist/webfinger/lookup.test.d.ts +0 -3
- package/dist/webfinger/lookup.test.js +0 -195
- package/dist/webfinger/mod.cjs +0 -9
- package/dist/webfinger/mod.d.cts +0 -4
- package/dist/webfinger/mod.d.ts +0 -6
- package/dist/webfinger/mod.js +0 -9
- package/dist/webfinger-BjOEdFPs.cjs +0 -4
- package/dist/webfinger-De_bU0iE.js +0 -4
- package/dist/x/cfworkers.cjs +0 -100
- package/dist/x/cfworkers.d.cts +0 -59
- package/dist/x/cfworkers.d.ts +0 -61
- package/dist/x/cfworkers.js +0 -98
- package/dist/x/cfworkers.test.d.ts +0 -3
- package/dist/x/cfworkers.test.js +0 -179
- package/dist/x/hono.cjs +0 -61
- package/dist/x/hono.d.cts +0 -54
- package/dist/x/hono.d.ts +0 -56
- package/dist/x/hono.js +0 -60
- package/dist/x/sveltekit.cjs +0 -69
- package/dist/x/sveltekit.d.cts +0 -46
- package/dist/x/sveltekit.d.ts +0 -48
- package/dist/x/sveltekit.js +0 -68
- /package/dist/{assert_not_equals-f3m3epl3.js → assert_not_equals-C80BG-_5.js} +0 -0
- /package/dist/{runtime/authdocloader.test.d.ts → federation/webfinger.test.d.ts} +0 -0
- /package/dist/{mod-1pDWKvUL.d.ts → mod-1E3W847c.d.ts} +0 -0
- /package/dist/{mod-C2tOeRkN.d.cts → mod-C81L6_lQ.d.cts} +0 -0
- /package/dist/{nodeinfo-DfycQ8Wf.js → nodeinfo-BlLsRSiT.js} +0 -0
- /package/dist/{nodeinfo-Co9lJrWl.cjs → nodeinfo-DuMYTpbZ.cjs} +0 -0
- /package/dist/{runtime/docloader.test.d.ts → otel/exporter.test.d.ts} +0 -0
- /package/dist/{runtime-DPYEDf-o.js → sig-CwuONEzF.js} +0 -0
- /package/dist/{runtime-C58AJWSv.cjs → sig-DeXX2xnj.cjs} +0 -0
- /package/dist/{std__assert-X-_kMxKM.js → std__assert-DWivtrGR.js} +0 -0
- /package/dist/{testing → utils}/docloader.test.d.ts +0 -0
- /package/dist/{runtime/key.test.d.ts → utils/kv-cache.test.d.ts} +0 -0
- /package/dist/{sig-ByHXzqUi.cjs → utils-Db0ZmjcD.cjs} +0 -0
- /package/dist/{sig-Cj3tk-ig.js → utils-Wranxuoe.js} +0 -0
package/dist/testing/mod.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import "../
|
|
7
|
-
import "../
|
|
8
|
-
import { createInboxContext, createRequestContext
|
|
6
|
+
import { testDefinitions } from "../dist-B5f6a8Tt.js";
|
|
7
|
+
import "../router-D9eI0s4b.js";
|
|
8
|
+
import { createInboxContext, createRequestContext } from "../context-Bns6uTJq.js";
|
|
9
9
|
|
|
10
|
-
export { createInboxContext, createRequestContext,
|
|
10
|
+
export { createInboxContext, createRequestContext, testDefinitions };
|
|
@@ -41,7 +41,7 @@ function autoIdAssigner(activity, context) {
|
|
|
41
41
|
* activity like this:
|
|
42
42
|
*
|
|
43
43
|
* ```typescript
|
|
44
|
-
* import { Follow, Person } from "@fedify/
|
|
44
|
+
* import { Follow, Person } from "@fedify/vocab";
|
|
45
45
|
* const input = new Follow({
|
|
46
46
|
* id: new URL("http://example.com/activities/1"),
|
|
47
47
|
* actor: new Person({
|
|
@@ -60,7 +60,7 @@ function autoIdAssigner(activity, context) {
|
|
|
60
60
|
* The result of applying this transformer would be:
|
|
61
61
|
*
|
|
62
62
|
* ```typescript
|
|
63
|
-
* import { Follow, Person } from "@fedify/
|
|
63
|
+
* import { Follow, Person } from "@fedify/vocab";
|
|
64
64
|
* const output = new Follow({
|
|
65
65
|
* id: new URL("http://example.com/activities/1"),
|
|
66
66
|
* actor: new URL("http://example.com/actors/1"),
|
|
@@ -40,7 +40,7 @@ function autoIdAssigner(activity, context) {
|
|
|
40
40
|
* activity like this:
|
|
41
41
|
*
|
|
42
42
|
* ```typescript
|
|
43
|
-
* import { Follow, Person } from "@fedify/
|
|
43
|
+
* import { Follow, Person } from "@fedify/vocab";
|
|
44
44
|
* const input = new Follow({
|
|
45
45
|
* id: new URL("http://example.com/activities/1"),
|
|
46
46
|
* actor: new Person({
|
|
@@ -59,7 +59,7 @@ function autoIdAssigner(activity, context) {
|
|
|
59
59
|
* The result of applying this transformer would be:
|
|
60
60
|
*
|
|
61
61
|
* ```typescript
|
|
62
|
-
* import { Follow, Person } from "@fedify/
|
|
62
|
+
* import { Follow, Person } from "@fedify/vocab";
|
|
63
63
|
* const output = new Follow({
|
|
64
64
|
* id: new URL("http://example.com/activities/1"),
|
|
65
65
|
* actor: new URL("http://example.com/actors/1"),
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { Temporal } from "@js-temporal/polyfill";
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
|
|
5
|
-
import { getUserAgent } from "./docloader-XK3y2jn5.js";
|
|
6
5
|
import { getLogger } from "@logtape/logtape";
|
|
6
|
+
import { getUserAgent } from "@fedify/vocab-runtime";
|
|
7
7
|
|
|
8
8
|
//#region src/nodeinfo/client.ts
|
|
9
9
|
const logger = getLogger([
|
|
@@ -110,15 +110,14 @@ function parseNodeInfo(data, options = {}) {
|
|
|
110
110
|
if (typeof data.metadata === "object" && data.metadata != null) metadata = Object.fromEntries(Object.entries(data.metadata));
|
|
111
111
|
else if (!options.tryBestEffort) return null;
|
|
112
112
|
}
|
|
113
|
-
|
|
113
|
+
return {
|
|
114
114
|
software,
|
|
115
115
|
protocols,
|
|
116
|
-
usage
|
|
116
|
+
usage,
|
|
117
|
+
...services != null && { services },
|
|
118
|
+
...openRegistrations != null && { openRegistrations },
|
|
119
|
+
...metadata != null && { metadata }
|
|
117
120
|
};
|
|
118
|
-
if (services != null) result.services = services;
|
|
119
|
-
if (openRegistrations != null) result.openRegistrations = openRegistrations;
|
|
120
|
-
if (metadata != null) result.metadata = metadata;
|
|
121
|
-
return result;
|
|
122
121
|
}
|
|
123
122
|
function parseSoftware(data, options = {}) {
|
|
124
123
|
if (typeof data !== "object" || data == null) {
|
|
@@ -154,13 +153,12 @@ function parseSoftware(data, options = {}) {
|
|
|
154
153
|
}
|
|
155
154
|
else if (!options.tryBestEffort) return null;
|
|
156
155
|
}
|
|
157
|
-
|
|
156
|
+
return {
|
|
158
157
|
name,
|
|
159
|
-
version
|
|
158
|
+
version,
|
|
159
|
+
...repository != null && { repository },
|
|
160
|
+
...homepage != null && { homepage }
|
|
160
161
|
};
|
|
161
|
-
if (repository != null) result.repository = repository;
|
|
162
|
-
if (homepage != null) result.homepage = homepage;
|
|
163
|
-
return result;
|
|
164
162
|
}
|
|
165
163
|
function parseProtocol(data) {
|
|
166
164
|
if (data === "activitypub" || data === "buddycloud" || data === "dfrn" || data === "diaspora" || data === "libertree" || data === "ostatus" || data === "pumpio" || data === "tent" || data === "xmpp" || data === "zot") return data;
|
|
@@ -183,10 +181,10 @@ function parseServices(data, options = {}) {
|
|
|
183
181
|
outbound = os.filter((o) => o != null);
|
|
184
182
|
if (os.length > outbound.length && !options.tryBestEffort) return null;
|
|
185
183
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
184
|
+
return {
|
|
185
|
+
...inbound != null && { inbound },
|
|
186
|
+
...outbound != null && { outbound }
|
|
187
|
+
};
|
|
190
188
|
}
|
|
191
189
|
function parseInboundService(data) {
|
|
192
190
|
if (data === "atom1.0" || data === "gnusocial" || data === "imap" || data === "pnut" || data === "pop3" || data === "pumpio" || data === "rss2.0" || data === "twitter") return data;
|
|
@@ -198,33 +196,40 @@ function parseOutboundService(data) {
|
|
|
198
196
|
}
|
|
199
197
|
function parseUsage(data, options = {}) {
|
|
200
198
|
if (typeof data !== "object" || data == null) return null;
|
|
201
|
-
|
|
199
|
+
let total;
|
|
200
|
+
let activeHalfyear;
|
|
201
|
+
let activeMonth;
|
|
202
202
|
if ("users" in data && typeof data.users === "object" && data.users != null) {
|
|
203
|
-
if ("total" in data.users) if (typeof data.users.total === "number")
|
|
203
|
+
if ("total" in data.users) if (typeof data.users.total === "number") total = data.users.total;
|
|
204
204
|
else {
|
|
205
205
|
if (!options.tryBestEffort) return null;
|
|
206
206
|
if (typeof data.users.total === "string") {
|
|
207
207
|
const n = parseInt(data.users.total);
|
|
208
|
-
if (!isNaN(n))
|
|
208
|
+
if (!isNaN(n)) total = n;
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
|
-
if ("activeHalfyear" in data.users) if (typeof data.users.activeHalfyear === "number")
|
|
211
|
+
if ("activeHalfyear" in data.users) if (typeof data.users.activeHalfyear === "number") activeHalfyear = data.users.activeHalfyear;
|
|
212
212
|
else {
|
|
213
213
|
if (!options.tryBestEffort) return null;
|
|
214
214
|
if (typeof data.users.activeHalfyear === "string") {
|
|
215
215
|
const n = parseInt(data.users.activeHalfyear);
|
|
216
|
-
if (!isNaN(n))
|
|
216
|
+
if (!isNaN(n)) activeHalfyear = n;
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
|
-
if ("activeMonth" in data.users) if (typeof data.users.activeMonth === "number")
|
|
219
|
+
if ("activeMonth" in data.users) if (typeof data.users.activeMonth === "number") activeMonth = data.users.activeMonth;
|
|
220
220
|
else {
|
|
221
221
|
if (!options.tryBestEffort) return null;
|
|
222
222
|
if (typeof data.users.activeMonth === "string") {
|
|
223
223
|
const n = parseInt(data.users.activeMonth);
|
|
224
|
-
if (!isNaN(n))
|
|
224
|
+
if (!isNaN(n)) activeMonth = n;
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
227
|
} else if (!options.tryBestEffort) return null;
|
|
228
|
+
const users = {
|
|
229
|
+
...total != null && { total },
|
|
230
|
+
...activeHalfyear != null && { activeHalfyear },
|
|
231
|
+
...activeMonth != null && { activeMonth }
|
|
232
|
+
};
|
|
228
233
|
let localPosts = 0;
|
|
229
234
|
if ("localPosts" in data) if (typeof data.localPosts === "number") localPosts = data.localPosts;
|
|
230
235
|
else {
|
|
@@ -275,13 +280,13 @@ function nodeInfoToJson(nodeInfo) {
|
|
|
275
280
|
repository: nodeInfo.software.repository?.href,
|
|
276
281
|
homepage: nodeInfo.software.homepage?.href
|
|
277
282
|
},
|
|
278
|
-
protocols: nodeInfo.protocols,
|
|
283
|
+
protocols: [...nodeInfo.protocols],
|
|
279
284
|
services: nodeInfo.services == null ? {
|
|
280
285
|
inbound: [],
|
|
281
286
|
outbound: []
|
|
282
287
|
} : {
|
|
283
|
-
inbound: nodeInfo.services.inbound
|
|
284
|
-
outbound: nodeInfo.services.outbound
|
|
288
|
+
inbound: nodeInfo.services.inbound ? [...nodeInfo.services.inbound] : [],
|
|
289
|
+
outbound: nodeInfo.services.outbound ? [...nodeInfo.services.outbound] : []
|
|
285
290
|
},
|
|
286
291
|
openRegistrations: nodeInfo.openRegistrations ?? false,
|
|
287
292
|
usage: {
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
4
4
|
|
|
5
5
|
const require_chunk = require('./chunk-DqRYRqnO.cjs');
|
|
6
|
-
const require_docloader = require('./docloader-CCqXeagZ.cjs');
|
|
7
6
|
const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
|
|
7
|
+
const __fedify_vocab_runtime = require_chunk.__toESM(require("@fedify/vocab-runtime"));
|
|
8
8
|
|
|
9
9
|
//#region src/nodeinfo/client.ts
|
|
10
10
|
const logger = (0, __logtape_logtape.getLogger)([
|
|
@@ -19,7 +19,7 @@ async function getNodeInfo(url, options = {}) {
|
|
|
19
19
|
const wellKnownUrl = new URL("/.well-known/nodeinfo", url);
|
|
20
20
|
const wellKnownResponse = await fetch(wellKnownUrl, { headers: {
|
|
21
21
|
Accept: "application/json",
|
|
22
|
-
"User-Agent": typeof options.userAgent === "string" ? options.userAgent :
|
|
22
|
+
"User-Agent": typeof options.userAgent === "string" ? options.userAgent : (0, __fedify_vocab_runtime.getUserAgent)(options.userAgent)
|
|
23
23
|
} });
|
|
24
24
|
if (!wellKnownResponse.ok) {
|
|
25
25
|
logger.error("Failed to fetch {url}: {status} {statusText}", {
|
|
@@ -42,7 +42,7 @@ async function getNodeInfo(url, options = {}) {
|
|
|
42
42
|
}
|
|
43
43
|
const response = await fetch(nodeInfoUrl, { headers: {
|
|
44
44
|
Accept: "application/json",
|
|
45
|
-
"User-Agent": typeof options.userAgent === "string" ? options.userAgent :
|
|
45
|
+
"User-Agent": typeof options.userAgent === "string" ? options.userAgent : (0, __fedify_vocab_runtime.getUserAgent)(options.userAgent)
|
|
46
46
|
} });
|
|
47
47
|
if (!response.ok) {
|
|
48
48
|
logger.error("Failed to fetch NodeInfo document from {url}: {status} {statusText}", {
|
|
@@ -111,15 +111,14 @@ function parseNodeInfo(data, options = {}) {
|
|
|
111
111
|
if (typeof data.metadata === "object" && data.metadata != null) metadata = Object.fromEntries(Object.entries(data.metadata));
|
|
112
112
|
else if (!options.tryBestEffort) return null;
|
|
113
113
|
}
|
|
114
|
-
|
|
114
|
+
return {
|
|
115
115
|
software,
|
|
116
116
|
protocols,
|
|
117
|
-
usage
|
|
117
|
+
usage,
|
|
118
|
+
...services != null && { services },
|
|
119
|
+
...openRegistrations != null && { openRegistrations },
|
|
120
|
+
...metadata != null && { metadata }
|
|
118
121
|
};
|
|
119
|
-
if (services != null) result.services = services;
|
|
120
|
-
if (openRegistrations != null) result.openRegistrations = openRegistrations;
|
|
121
|
-
if (metadata != null) result.metadata = metadata;
|
|
122
|
-
return result;
|
|
123
122
|
}
|
|
124
123
|
function parseSoftware(data, options = {}) {
|
|
125
124
|
if (typeof data !== "object" || data == null) {
|
|
@@ -155,13 +154,12 @@ function parseSoftware(data, options = {}) {
|
|
|
155
154
|
}
|
|
156
155
|
else if (!options.tryBestEffort) return null;
|
|
157
156
|
}
|
|
158
|
-
|
|
157
|
+
return {
|
|
159
158
|
name,
|
|
160
|
-
version
|
|
159
|
+
version,
|
|
160
|
+
...repository != null && { repository },
|
|
161
|
+
...homepage != null && { homepage }
|
|
161
162
|
};
|
|
162
|
-
if (repository != null) result.repository = repository;
|
|
163
|
-
if (homepage != null) result.homepage = homepage;
|
|
164
|
-
return result;
|
|
165
163
|
}
|
|
166
164
|
function parseProtocol(data) {
|
|
167
165
|
if (data === "activitypub" || data === "buddycloud" || data === "dfrn" || data === "diaspora" || data === "libertree" || data === "ostatus" || data === "pumpio" || data === "tent" || data === "xmpp" || data === "zot") return data;
|
|
@@ -184,10 +182,10 @@ function parseServices(data, options = {}) {
|
|
|
184
182
|
outbound = os.filter((o) => o != null);
|
|
185
183
|
if (os.length > outbound.length && !options.tryBestEffort) return null;
|
|
186
184
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
185
|
+
return {
|
|
186
|
+
...inbound != null && { inbound },
|
|
187
|
+
...outbound != null && { outbound }
|
|
188
|
+
};
|
|
191
189
|
}
|
|
192
190
|
function parseInboundService(data) {
|
|
193
191
|
if (data === "atom1.0" || data === "gnusocial" || data === "imap" || data === "pnut" || data === "pop3" || data === "pumpio" || data === "rss2.0" || data === "twitter") return data;
|
|
@@ -199,33 +197,40 @@ function parseOutboundService(data) {
|
|
|
199
197
|
}
|
|
200
198
|
function parseUsage(data, options = {}) {
|
|
201
199
|
if (typeof data !== "object" || data == null) return null;
|
|
202
|
-
|
|
200
|
+
let total;
|
|
201
|
+
let activeHalfyear;
|
|
202
|
+
let activeMonth;
|
|
203
203
|
if ("users" in data && typeof data.users === "object" && data.users != null) {
|
|
204
|
-
if ("total" in data.users) if (typeof data.users.total === "number")
|
|
204
|
+
if ("total" in data.users) if (typeof data.users.total === "number") total = data.users.total;
|
|
205
205
|
else {
|
|
206
206
|
if (!options.tryBestEffort) return null;
|
|
207
207
|
if (typeof data.users.total === "string") {
|
|
208
208
|
const n = parseInt(data.users.total);
|
|
209
|
-
if (!isNaN(n))
|
|
209
|
+
if (!isNaN(n)) total = n;
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
|
-
if ("activeHalfyear" in data.users) if (typeof data.users.activeHalfyear === "number")
|
|
212
|
+
if ("activeHalfyear" in data.users) if (typeof data.users.activeHalfyear === "number") activeHalfyear = data.users.activeHalfyear;
|
|
213
213
|
else {
|
|
214
214
|
if (!options.tryBestEffort) return null;
|
|
215
215
|
if (typeof data.users.activeHalfyear === "string") {
|
|
216
216
|
const n = parseInt(data.users.activeHalfyear);
|
|
217
|
-
if (!isNaN(n))
|
|
217
|
+
if (!isNaN(n)) activeHalfyear = n;
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
|
-
if ("activeMonth" in data.users) if (typeof data.users.activeMonth === "number")
|
|
220
|
+
if ("activeMonth" in data.users) if (typeof data.users.activeMonth === "number") activeMonth = data.users.activeMonth;
|
|
221
221
|
else {
|
|
222
222
|
if (!options.tryBestEffort) return null;
|
|
223
223
|
if (typeof data.users.activeMonth === "string") {
|
|
224
224
|
const n = parseInt(data.users.activeMonth);
|
|
225
|
-
if (!isNaN(n))
|
|
225
|
+
if (!isNaN(n)) activeMonth = n;
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
} else if (!options.tryBestEffort) return null;
|
|
229
|
+
const users = {
|
|
230
|
+
...total != null && { total },
|
|
231
|
+
...activeHalfyear != null && { activeHalfyear },
|
|
232
|
+
...activeMonth != null && { activeMonth }
|
|
233
|
+
};
|
|
229
234
|
let localPosts = 0;
|
|
230
235
|
if ("localPosts" in data) if (typeof data.localPosts === "number") localPosts = data.localPosts;
|
|
231
236
|
else {
|
|
@@ -276,13 +281,13 @@ function nodeInfoToJson(nodeInfo) {
|
|
|
276
281
|
repository: nodeInfo.software.repository?.href,
|
|
277
282
|
homepage: nodeInfo.software.homepage?.href
|
|
278
283
|
},
|
|
279
|
-
protocols: nodeInfo.protocols,
|
|
284
|
+
protocols: [...nodeInfo.protocols],
|
|
280
285
|
services: nodeInfo.services == null ? {
|
|
281
286
|
inbound: [],
|
|
282
287
|
outbound: []
|
|
283
288
|
} : {
|
|
284
|
-
inbound: nodeInfo.services.inbound
|
|
285
|
-
outbound: nodeInfo.services.outbound
|
|
289
|
+
inbound: nodeInfo.services.inbound ? [...nodeInfo.services.inbound] : [],
|
|
290
|
+
outbound: nodeInfo.services.outbound ? [...nodeInfo.services.outbound] : []
|
|
286
291
|
},
|
|
287
292
|
openRegistrations: nodeInfo.openRegistrations ?? false,
|
|
288
293
|
usage: {
|
|
@@ -27,13 +27,13 @@ function nodeInfoToJson(nodeInfo) {
|
|
|
27
27
|
repository: nodeInfo.software.repository?.href,
|
|
28
28
|
homepage: nodeInfo.software.homepage?.href
|
|
29
29
|
},
|
|
30
|
-
protocols: nodeInfo.protocols,
|
|
30
|
+
protocols: [...nodeInfo.protocols],
|
|
31
31
|
services: nodeInfo.services == null ? {
|
|
32
32
|
inbound: [],
|
|
33
33
|
outbound: []
|
|
34
34
|
} : {
|
|
35
|
-
inbound: nodeInfo.services.inbound
|
|
36
|
-
outbound: nodeInfo.services.outbound
|
|
35
|
+
inbound: nodeInfo.services.inbound ? [...nodeInfo.services.inbound] : [],
|
|
36
|
+
outbound: nodeInfo.services.outbound ? [...nodeInfo.services.outbound] : []
|
|
37
37
|
},
|
|
38
38
|
openRegistrations: nodeInfo.openRegistrations ?? false,
|
|
39
39
|
usage: {
|
|
@@ -3,25 +3,23 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { mockDocumentLoader, test } from "../dist-B5f6a8Tt.js";
|
|
7
7
|
import { assertEquals } from "../assert_equals-DSbWqCm3.js";
|
|
8
8
|
import "../assert-MZs1qjMx.js";
|
|
9
9
|
import "../assert_instance_of-DHz7EHNU.js";
|
|
10
|
-
import "../
|
|
11
|
-
import "../
|
|
12
|
-
import "../
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
16
|
-
import "../
|
|
17
|
-
import
|
|
18
|
-
import "../
|
|
19
|
-
import "../
|
|
20
|
-
import "
|
|
21
|
-
import { rsaPrivateKey2 } from "../keys-BPdFKgiy.js";
|
|
22
|
-
import { esm_default } from "../esm-DnIzfEj0.js";
|
|
10
|
+
import "../deno-DhWON59o.js";
|
|
11
|
+
import "../key-DKkHKzvg.js";
|
|
12
|
+
import { verifyRequest } from "../http-CwsBL5_A.js";
|
|
13
|
+
import { getAuthenticatedDocumentLoader } from "../docloader-Cni79dmb.js";
|
|
14
|
+
import "../std__assert-DWivtrGR.js";
|
|
15
|
+
import { assertRejects } from "../assert_rejects-Ce45JcFg.js";
|
|
16
|
+
import "../assert_throws-BNXdRGWP.js";
|
|
17
|
+
import "../assert_not_equals-C80BG-_5.js";
|
|
18
|
+
import { rsaPrivateKey2 } from "../keys-ZbcByPg9.js";
|
|
19
|
+
import { esm_default } from "../esm-DGl7uK1r.js";
|
|
20
|
+
import { UrlError } from "@fedify/vocab-runtime";
|
|
23
21
|
|
|
24
|
-
//#region src/
|
|
22
|
+
//#region src/utils/docloader.test.ts
|
|
25
23
|
test("getAuthenticatedDocumentLoader()", async (t) => {
|
|
26
24
|
esm_default.spyGlobal();
|
|
27
25
|
esm_default.get("begin:https://example.com/object", async (cl) => {
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
|
4
|
+
globalThis.addEventListener = () => {};
|
|
5
|
+
|
|
6
|
+
import { mockDocumentLoader, test } from "../dist-B5f6a8Tt.js";
|
|
7
|
+
import { MockKvStore, kvCache } from "../kv-cache-BEeqyGER.js";
|
|
8
|
+
import { preloadedContexts } from "@fedify/vocab-runtime";
|
|
9
|
+
import { deepStrictEqual, throws } from "node:assert";
|
|
10
|
+
|
|
11
|
+
//#region src/utils/kv-cache.test.ts
|
|
12
|
+
test("kvCache()", async (t) => {
|
|
13
|
+
const kv = new MockKvStore();
|
|
14
|
+
await t.step("cached", async () => {
|
|
15
|
+
const loader = kvCache({
|
|
16
|
+
kv,
|
|
17
|
+
loader: mockDocumentLoader,
|
|
18
|
+
rules: [
|
|
19
|
+
["https://example.org/", Temporal.Duration.from({ days: 1 })],
|
|
20
|
+
[new URL("https://example.net/"), Temporal.Duration.from({ days: 1 })],
|
|
21
|
+
[new URLPattern("https://example.com/*"), Temporal.Duration.from({ days: 30 })]
|
|
22
|
+
],
|
|
23
|
+
prefix: ["_test", "cached"]
|
|
24
|
+
});
|
|
25
|
+
const result = await loader("https://example.com/object");
|
|
26
|
+
deepStrictEqual(result, {
|
|
27
|
+
contextUrl: null,
|
|
28
|
+
documentUrl: "https://example.com/object",
|
|
29
|
+
document: {
|
|
30
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
31
|
+
id: "https://example.com/object",
|
|
32
|
+
name: "Fetched object",
|
|
33
|
+
type: "Object"
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
const cache = await kv.get([
|
|
37
|
+
"_test",
|
|
38
|
+
"cached",
|
|
39
|
+
"https://example.com/object"
|
|
40
|
+
]);
|
|
41
|
+
deepStrictEqual(cache, result);
|
|
42
|
+
await kv.set([
|
|
43
|
+
"_test",
|
|
44
|
+
"cached",
|
|
45
|
+
"https://example.org/"
|
|
46
|
+
], {
|
|
47
|
+
contextUrl: null,
|
|
48
|
+
documentUrl: "https://example.org/",
|
|
49
|
+
document: { "id": "https://example.org/" }
|
|
50
|
+
});
|
|
51
|
+
const result2 = await loader("https://example.org/");
|
|
52
|
+
deepStrictEqual(result2, {
|
|
53
|
+
contextUrl: null,
|
|
54
|
+
documentUrl: "https://example.org/",
|
|
55
|
+
document: { "id": "https://example.org/" }
|
|
56
|
+
});
|
|
57
|
+
await kv.set([
|
|
58
|
+
"_test",
|
|
59
|
+
"cached",
|
|
60
|
+
"https://example.net/"
|
|
61
|
+
], {
|
|
62
|
+
contextUrl: null,
|
|
63
|
+
documentUrl: "https://example.net/",
|
|
64
|
+
document: { "id": "https://example.net/" }
|
|
65
|
+
});
|
|
66
|
+
const result3 = await loader("https://example.net/");
|
|
67
|
+
deepStrictEqual(result3, {
|
|
68
|
+
contextUrl: null,
|
|
69
|
+
documentUrl: "https://example.net/",
|
|
70
|
+
document: { "id": "https://example.net/" }
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
await t.step("not cached", async () => {
|
|
74
|
+
const loader = kvCache({
|
|
75
|
+
kv,
|
|
76
|
+
loader: mockDocumentLoader,
|
|
77
|
+
rules: [],
|
|
78
|
+
prefix: ["_test", "not cached"]
|
|
79
|
+
});
|
|
80
|
+
const result = await loader("https://example.com/object");
|
|
81
|
+
deepStrictEqual(result, {
|
|
82
|
+
contextUrl: null,
|
|
83
|
+
documentUrl: "https://example.com/object",
|
|
84
|
+
document: {
|
|
85
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
86
|
+
id: "https://example.com/object",
|
|
87
|
+
name: "Fetched object",
|
|
88
|
+
type: "Object"
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
const cache = await kv.get([
|
|
92
|
+
"test2",
|
|
93
|
+
"not cached",
|
|
94
|
+
"https://example.com/object"
|
|
95
|
+
]);
|
|
96
|
+
deepStrictEqual(cache, void 0);
|
|
97
|
+
});
|
|
98
|
+
await t.step("maximum cache duration", () => {
|
|
99
|
+
throws(() => kvCache({
|
|
100
|
+
kv,
|
|
101
|
+
loader: mockDocumentLoader,
|
|
102
|
+
rules: [["https://example.com/", Temporal.Duration.from({
|
|
103
|
+
days: 30,
|
|
104
|
+
seconds: 1
|
|
105
|
+
})]]
|
|
106
|
+
}), TypeError, "The maximum cache duration is 30 days");
|
|
107
|
+
throws(() => kvCache({
|
|
108
|
+
kv,
|
|
109
|
+
loader: mockDocumentLoader,
|
|
110
|
+
rules: [[new URLPattern("https://example.com/*"), Temporal.Duration.from({
|
|
111
|
+
days: 30,
|
|
112
|
+
seconds: 1
|
|
113
|
+
})]]
|
|
114
|
+
}), TypeError, "The maximum cache duration is 30 days");
|
|
115
|
+
});
|
|
116
|
+
await t.step("on kv store exception", async () => {
|
|
117
|
+
class KvStoreThrowsException {
|
|
118
|
+
get(_key) {
|
|
119
|
+
throw new Error("Failed to get key");
|
|
120
|
+
}
|
|
121
|
+
set(_key, _value, _options) {
|
|
122
|
+
throw new Error("Failed to set key");
|
|
123
|
+
}
|
|
124
|
+
delete(_key) {
|
|
125
|
+
throw new Error("Failed to delete key");
|
|
126
|
+
}
|
|
127
|
+
async *list(_prefix) {
|
|
128
|
+
throw new Error("Failed to list keys");
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const loader = kvCache({
|
|
132
|
+
kv: new KvStoreThrowsException(),
|
|
133
|
+
loader: mockDocumentLoader,
|
|
134
|
+
rules: [
|
|
135
|
+
["https://example.org/", Temporal.Duration.from({ days: 1 })],
|
|
136
|
+
[new URL("https://example.net/"), Temporal.Duration.from({ days: 1 })],
|
|
137
|
+
[new URLPattern("https://example.com/*"), Temporal.Duration.from({ days: 30 })]
|
|
138
|
+
],
|
|
139
|
+
prefix: ["_test", "not cached"]
|
|
140
|
+
});
|
|
141
|
+
const result = await loader("https://example.com/object");
|
|
142
|
+
deepStrictEqual(result, {
|
|
143
|
+
contextUrl: null,
|
|
144
|
+
documentUrl: "https://example.com/object",
|
|
145
|
+
document: {
|
|
146
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
147
|
+
id: "https://example.com/object",
|
|
148
|
+
name: "Fetched object",
|
|
149
|
+
type: "Object"
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
await t.step("preloaded contexts bypass cache", async () => {
|
|
154
|
+
const kv$1 = new MockKvStore();
|
|
155
|
+
let loaderCalled = false;
|
|
156
|
+
const mockLoader = (url) => {
|
|
157
|
+
loaderCalled = true;
|
|
158
|
+
return Promise.resolve({
|
|
159
|
+
contextUrl: null,
|
|
160
|
+
documentUrl: url,
|
|
161
|
+
document: { "mock": "document" }
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
const loader = kvCache({
|
|
165
|
+
kv: kv$1,
|
|
166
|
+
loader: mockLoader,
|
|
167
|
+
prefix: ["_test", "preloaded"]
|
|
168
|
+
});
|
|
169
|
+
const activityStreamsUrl = "https://www.w3.org/ns/activitystreams";
|
|
170
|
+
loaderCalled = false;
|
|
171
|
+
const result = await loader(activityStreamsUrl);
|
|
172
|
+
deepStrictEqual(result, {
|
|
173
|
+
contextUrl: null,
|
|
174
|
+
documentUrl: activityStreamsUrl,
|
|
175
|
+
document: preloadedContexts[activityStreamsUrl]
|
|
176
|
+
});
|
|
177
|
+
deepStrictEqual(loaderCalled, false, "Loader should not be called for preloaded contexts");
|
|
178
|
+
const cachedValue = await kv$1.get([
|
|
179
|
+
"_test",
|
|
180
|
+
"preloaded",
|
|
181
|
+
activityStreamsUrl
|
|
182
|
+
]);
|
|
183
|
+
deepStrictEqual(cachedValue, void 0, "Preloaded contexts should not be cached in KV store");
|
|
184
|
+
const securityUrl = "https://w3id.org/security/v1";
|
|
185
|
+
loaderCalled = false;
|
|
186
|
+
const result2 = await loader(securityUrl);
|
|
187
|
+
deepStrictEqual(result2, {
|
|
188
|
+
contextUrl: null,
|
|
189
|
+
documentUrl: securityUrl,
|
|
190
|
+
document: preloadedContexts[securityUrl]
|
|
191
|
+
});
|
|
192
|
+
deepStrictEqual(loaderCalled, false, "Loader should not be called for preloaded contexts");
|
|
193
|
+
const nonPreloadedUrl = "https://example.com/not-preloaded";
|
|
194
|
+
loaderCalled = false;
|
|
195
|
+
const result3 = await loader(nonPreloadedUrl);
|
|
196
|
+
deepStrictEqual(result3, {
|
|
197
|
+
contextUrl: null,
|
|
198
|
+
documentUrl: nonPreloadedUrl,
|
|
199
|
+
document: { "mock": "document" }
|
|
200
|
+
});
|
|
201
|
+
deepStrictEqual(loaderCalled, true, "Loader should be called for non-preloaded URLs");
|
|
202
|
+
const cachedValue2 = await kv$1.get([
|
|
203
|
+
"_test",
|
|
204
|
+
"preloaded",
|
|
205
|
+
nonPreloadedUrl
|
|
206
|
+
]);
|
|
207
|
+
deepStrictEqual(cachedValue2, result3, "Non-preloaded URLs should be cached");
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
//#endregion
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
const { Temporal } = require("@js-temporal/polyfill");
|
|
3
|
+
const { URLPattern } = require("urlpattern-polyfill");
|
|
4
|
+
|
|
5
|
+
require('../http-7RQPvAkX.cjs');
|
|
6
|
+
const require_kv_cache = require('../kv-cache-BVA7CrnS.cjs');
|
|
7
|
+
require('../utils-Db0ZmjcD.cjs');
|
|
8
|
+
|
|
9
|
+
exports.getAuthenticatedDocumentLoader = require_kv_cache.getAuthenticatedDocumentLoader;
|
|
10
|
+
exports.kvCache = require_kv_cache.kvCache;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
+
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
+
import "../http-DLBDPal9.js";
|
|
4
|
+
import "../kv-CYySNrsn.js";
|
|
5
|
+
import { getAuthenticatedDocumentLoader, kvCache } from "../mod-xc20HhMD.js";
|
|
6
|
+
export { getAuthenticatedDocumentLoader, kvCache };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
|
4
|
+
|
|
5
|
+
import "../http-CZXlv4xU.js";
|
|
6
|
+
import { getAuthenticatedDocumentLoader, kvCache } from "../kv-cache-HDuc4ZaJ.js";
|
|
7
|
+
import "../utils-Wranxuoe.js";
|
|
8
|
+
|
|
9
|
+
export { getAuthenticatedDocumentLoader, kvCache };
|