@fedify/fedify 2.0.0-pr.449.1725 → 2.0.0-pr.451.1730

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 (193) hide show
  1. package/dist/{actor-T6RyhRgk.d.ts → actor-Cd2CREO0.d.ts} +2 -2
  2. package/dist/{actor-VrXd7EdX.js → actor-Cg8ZhoVF.js} +1 -1
  3. package/dist/{actor-CsRJa7wV.cjs → actor-D020hlx3.cjs} +922 -1451
  4. package/dist/{actor-D6K058Tb.d.cts → actor-DDhZuMGl.d.cts} +2 -2
  5. package/dist/{actor-C0gLJq8I.js → actor-DPD6Gbdn.js} +190 -677
  6. package/dist/{assert_rejects-DiIiJbZn.js → assert_rejects-Ce45JcFg.js} +1 -1
  7. package/dist/{assert_is_error-BPGph1Jx.js → assert_throws-BNXdRGWP.js} +31 -1
  8. package/dist/{builder-JjsppXTK.js → builder-Dn87hy75.js} +3 -4
  9. package/dist/{client-bgSdkFa2.d.ts → client-Bkaw0_PR.d.ts} +1 -1
  10. package/dist/{client-CegPX0Rn.d.cts → client-Cle5j1T1.d.cts} +1 -1
  11. package/dist/{client-BS-GE3XI.js → client-D6-5okV1.js} +1 -1
  12. package/dist/compat/mod.d.cts +11 -11
  13. package/dist/compat/mod.d.ts +12 -12
  14. package/dist/compat/transformers.test.js +20 -20
  15. package/dist/{context-DYCJXr7J.d.cts → context-BOYzcFSe.d.cts} +10 -10
  16. package/dist/{context-B1X8-X33.d.ts → context-DqFifMwj.d.ts} +11 -11
  17. package/dist/{authdocloader-C8LXxsmU.js → docloader-B2BFBGqv.js} +18 -8
  18. package/dist/{esm-CvUgdJZ_.js → esm-CU0Dnk7T.js} +11 -11
  19. package/dist/federation/builder.test.js +8 -10
  20. package/dist/federation/collection.test.js +7 -9
  21. package/dist/federation/handler.test.js +25 -26
  22. package/dist/federation/idempotency.test.js +25 -26
  23. package/dist/federation/inbox.test.js +4 -6
  24. package/dist/federation/keycache.test.js +3 -4
  25. package/dist/federation/kv.test.js +6 -8
  26. package/dist/federation/middleware.test.js +26 -27
  27. package/dist/federation/mod.cjs +10 -11
  28. package/dist/federation/mod.d.cts +10 -10
  29. package/dist/federation/mod.d.ts +12 -12
  30. package/dist/federation/mod.js +10 -11
  31. package/dist/federation/mq.test.js +8 -10
  32. package/dist/federation/negotiation.test.js +7 -9
  33. package/dist/federation/retry.test.js +4 -5
  34. package/dist/federation/router.test.js +6 -8
  35. package/dist/federation/send.test.js +13 -15
  36. package/dist/{http-D-e6AFwR.d.cts → http-B6SKO6NJ.d.cts} +2 -2
  37. package/dist/{http-D6Uj2x2y.d.ts → http-BE7aFuqn.d.ts} +2 -2
  38. package/dist/{http-D_BI5KHC.cjs → http-DMsjudj8.cjs} +289 -9
  39. package/dist/{http-DbyMqL2X.js → http-DN0v2zoF.js} +2 -2
  40. package/dist/{http-DVQEn98K.js → http-DcDb8r1W.js} +256 -6
  41. package/dist/{inbox-DQlf_-Dz.js → inbox-CgGy7Hzc.js} +1 -1
  42. package/dist/{key-BSJX6n9o.js → key-jSvnymAk.js} +3 -2
  43. package/dist/{keycache-CcIfdj0m.js → keycache-IVLjlAK9.js} +1 -1
  44. package/dist/{keys-DnSaJmvD.js → keys-BKM2Mqu2.js} +2 -1
  45. package/dist/{docloader-BdF5STdg.cjs → kv-cache-BHIupktM.cjs} +69 -651
  46. package/dist/kv-cache-DNvS-egZ.js +4236 -0
  47. package/dist/{docloader-AMdJU291.js → kv-cache-ydIs4Ul6.js} +68 -596
  48. package/dist/{ld-CAJ6Q2od.js → ld-CcsryBo0.js} +3 -2
  49. package/dist/{lookup-BGCuyJRy.js → lookup-BV3A9Zbc.js} +63 -2
  50. package/dist/{type-COb6KNlm.js → lookup-BbEekiru.js} +588 -5303
  51. package/dist/{lookup-B2Bsau2g.cjs → lookup-CMAGfQ1Q.cjs} +78 -5
  52. package/dist/{middleware-1oxZY_0z.js → middleware-D-vPitR-.js} +11 -11
  53. package/dist/{middleware-BDqkoMAQ.js → middleware-Dm8sXYUr.js} +18 -17
  54. package/dist/middleware-DzA970CF.js +16 -0
  55. package/dist/middleware-VpoC5jyA.js +26 -0
  56. package/dist/middleware-W_-inBoE.cjs +16 -0
  57. package/dist/{middleware-D0XMPoN8.cjs → middleware-ekn2KaOw.cjs} +31 -31
  58. package/dist/{mod-CxkWO3Mg.d.cts → mod--K7l84wp.d.cts} +3 -2
  59. package/dist/{mod-DBzN0aCM.d.ts → mod-CB80AlIA.d.ts} +1 -1
  60. package/dist/mod-CLKu6Uo_.d.cts +107 -0
  61. package/dist/{mod-Djzcw2ry.d.cts → mod-COlOrmr9.d.cts} +3 -3
  62. package/dist/{mod-DlU8ISoa.d.ts → mod-CRENK2dd.d.ts} +3 -2
  63. package/dist/{mod-DcKxhFQ8.d.ts → mod-CaWbCg0N.d.ts} +2 -2
  64. package/dist/mod-Cm97bAiT.d.ts +109 -0
  65. package/dist/{mod-twdvV2hR.d.cts → mod-D9XZsft2.d.cts} +2 -2
  66. package/dist/{mod-BhUKmBJD.d.ts → mod-DLIidI_j.d.ts} +3 -3
  67. package/dist/{mod-jQ4OODsl.d.cts → mod-DuclhZjh.d.cts} +1 -1
  68. package/dist/mod.cjs +21 -32
  69. package/dist/mod.d.cts +14 -14
  70. package/dist/mod.d.ts +17 -17
  71. package/dist/mod.js +15 -16
  72. package/dist/nodeinfo/client.test.js +8 -10
  73. package/dist/nodeinfo/handler.test.js +24 -25
  74. package/dist/nodeinfo/mod.cjs +3 -3
  75. package/dist/nodeinfo/mod.d.cts +2 -3
  76. package/dist/nodeinfo/mod.d.ts +3 -4
  77. package/dist/nodeinfo/mod.js +3 -3
  78. package/dist/nodeinfo/types.test.js +7 -9
  79. package/dist/{owner-hd9lvQcP.d.ts → owner-CktUdA0h.d.ts} +3 -3
  80. package/dist/{owner-BN_tO3cY.d.cts → owner-dkg5OpSC.d.cts} +3 -3
  81. package/dist/{owner-CaIfLBwg.js → owner-n5c_oZ_M.js} +3 -2
  82. package/dist/{proof-CKXppjee.js → proof-CLwByIT1.js} +5 -4
  83. package/dist/{proof-AhyVJcNZ.cjs → proof-CZfrp13P.cjs} +17 -16
  84. package/dist/{proof-BQwXHakc.js → proof-CsFR7fiS.js} +2 -2
  85. package/dist/request-BbHkedIU.d.cts +35 -0
  86. package/dist/request-DKGQaofB.js +184 -0
  87. package/dist/request-U1t6zZtk.d.ts +39 -0
  88. package/dist/request-XHWUW2bi.cjs +208 -0
  89. package/dist/{send-DQd3R1Oc.js → send-eW9JIzQV.js} +2 -2
  90. package/dist/sig/http.test.js +12 -13
  91. package/dist/sig/key.test.js +9 -11
  92. package/dist/sig/ld.test.js +8 -10
  93. package/dist/sig/mod.cjs +10 -11
  94. package/dist/sig/mod.d.cts +6 -7
  95. package/dist/sig/mod.d.ts +6 -7
  96. package/dist/sig/mod.js +6 -7
  97. package/dist/sig/owner.test.js +10 -12
  98. package/dist/sig/proof.test.js +13 -14
  99. package/dist/testing/docloader.test.js +6 -8
  100. package/dist/testing/mod.d.ts +3 -62
  101. package/dist/testing/mod.js +2 -3
  102. package/dist/{testing-BljKU-GG.js → testing-ClYSmXdi.js} +1 -2
  103. package/dist/{types-DI0yutHB.cjs → types-BT0xc4-R.cjs} +3 -3
  104. package/dist/{types-CEn4wB51.js → types-DaPoJTSc.js} +1 -1
  105. package/dist/{runtime/authdocloader.test.js → utils/docloader.test.js} +13 -15
  106. package/dist/utils/kv-cache.test.js +208 -0
  107. package/dist/utils/mod.cjs +14 -0
  108. package/dist/utils/mod.d.cts +6 -0
  109. package/dist/utils/mod.d.ts +8 -0
  110. package/dist/utils/mod.js +12 -0
  111. package/dist/utils/request.test.js +48 -0
  112. package/dist/utils/url.test.js +41 -0
  113. package/dist/vocab/actor.test.js +8 -10
  114. package/dist/vocab/lookup.test.js +7 -9
  115. package/dist/vocab/mod.cjs +4 -4
  116. package/dist/vocab/mod.d.cts +4 -5
  117. package/dist/vocab/mod.d.ts +4 -5
  118. package/dist/vocab/mod.js +4 -4
  119. package/dist/vocab/type.test.js +2 -3
  120. package/dist/vocab/vocab.test.js +9 -10
  121. package/dist/{vocab-NZXL5Pr-.cjs → vocab-CxTuoEVd.cjs} +6 -5
  122. package/dist/{vocab-Dw1-yVGg.d.cts → vocab-DCBw44JZ.d.cts} +2 -21
  123. package/dist/{vocab-BI0Ak5lL.d.ts → vocab-ivDKb439.d.ts} +2 -21
  124. package/dist/{vocab-CkWH9P5l.js → vocab-yFT-fQBj.js} +4 -3
  125. package/dist/webfinger/handler.test.js +24 -25
  126. package/dist/webfinger/lookup.test.js +7 -9
  127. package/dist/webfinger/mod.cjs +3 -3
  128. package/dist/webfinger/mod.d.cts +2 -3
  129. package/dist/webfinger/mod.d.ts +2 -3
  130. package/dist/webfinger/mod.js +3 -3
  131. package/dist/x/cfworkers.d.cts +1 -1
  132. package/dist/x/cfworkers.d.ts +2 -2
  133. package/dist/x/cfworkers.test.js +6 -8
  134. package/dist/x/hono.d.cts +10 -10
  135. package/dist/x/hono.d.ts +11 -11
  136. package/dist/x/sveltekit.d.cts +10 -10
  137. package/dist/x/sveltekit.d.ts +11 -11
  138. package/package.json +16 -14
  139. package/dist/assert_throws-BOO88avQ.js +0 -39
  140. package/dist/authdocloader-6F9IP-VO.js +0 -52
  141. package/dist/authdocloader-BkuVo8LL.cjs +0 -58
  142. package/dist/docloader-CxWcuWqQ.d.ts +0 -221
  143. package/dist/docloader-D-MrRyHl.d.cts +0 -219
  144. package/dist/key-BBzfhQGE.js +0 -10
  145. package/dist/key-BMz_uAnc.cjs +0 -10
  146. package/dist/key-D-RgWfcf.cjs +0 -290
  147. package/dist/key-DFefr8X2.js +0 -260
  148. package/dist/key-DW2DrPGl.js +0 -10
  149. package/dist/lookup-C3pnuyiD.js +0 -331
  150. package/dist/middleware-B8WWe8Q2.js +0 -26
  151. package/dist/middleware-DipQbJmB.js +0 -17
  152. package/dist/middleware-mLaQeD_Z.cjs +0 -17
  153. package/dist/mod-CerN_Sza.d.ts +0 -104
  154. package/dist/mod-Cj1tHXBR.d.cts +0 -102
  155. package/dist/runtime/docloader.test.js +0 -522
  156. package/dist/runtime/key.test.js +0 -103
  157. package/dist/runtime/langstr.test.d.ts +0 -3
  158. package/dist/runtime/langstr.test.js +0 -39
  159. package/dist/runtime/link.test.d.ts +0 -3
  160. package/dist/runtime/link.test.js +0 -61
  161. package/dist/runtime/mod.cjs +0 -25
  162. package/dist/runtime/mod.d.cts +0 -6
  163. package/dist/runtime/mod.d.ts +0 -8
  164. package/dist/runtime/mod.js +0 -13
  165. package/dist/runtime/multibase/multibase.test.d.ts +0 -3
  166. package/dist/runtime/multibase/multibase.test.js +0 -358
  167. package/dist/runtime/url.test.js +0 -45
  168. /package/dist/{assert_not_equals-f3m3epl3.js → assert_not_equals-C80BG-_5.js} +0 -0
  169. /package/dist/{collection-CcnIw1qY.js → collection-BzWsN9pB.js} +0 -0
  170. /package/dist/{denokv-Bv33Xxea.js → denokv-CCssOzMJ.js} +0 -0
  171. /package/dist/{federation-H2_En3j5.cjs → federation-DOuZpcAw.cjs} +0 -0
  172. /package/dist/{federation-D1U8YY9t.js → federation-pZJsapBn.js} +0 -0
  173. /package/dist/{kv-63Cil1MD.d.cts → kv-BMKIFXNW.d.cts} +0 -0
  174. /package/dist/{kv-C7sopW2E.d.ts → kv-Dt06smFt.d.ts} +0 -0
  175. /package/dist/{mod-1pDWKvUL.d.ts → mod-B-ZQqbGe.d.ts} +0 -0
  176. /package/dist/{mod-g0xFzAP9.d.ts → mod-CjsiSl7_.d.ts} +0 -0
  177. /package/dist/{mq-CRGm1e_F.d.ts → mq-CPRJk4mZ.d.ts} +0 -0
  178. /package/dist/{negotiation-5NPJL6zp.js → negotiation-C4nFufNk.js} +0 -0
  179. /package/dist/{nodeinfo-DfycQ8Wf.js → nodeinfo-B0UefMXO.js} +0 -0
  180. /package/dist/{nodeinfo-Co9lJrWl.cjs → nodeinfo-ByTd7HpT.cjs} +0 -0
  181. /package/dist/{retry-D4GJ670a.js → retry-CfF8Gn4d.js} +0 -0
  182. /package/dist/{runtime-C58AJWSv.cjs → sig-DE_NC_VQ.cjs} +0 -0
  183. /package/dist/{runtime-DPYEDf-o.js → sig-Dx59zAgn.js} +0 -0
  184. /package/dist/{std__assert-X-_kMxKM.js → std__assert-DWivtrGR.js} +0 -0
  185. /package/dist/{types-BSuWJsOm.js → types-C2XVl6gj.js} +0 -0
  186. /package/dist/{runtime → utils}/docloader.test.d.ts +0 -0
  187. /package/dist/{runtime/authdocloader.test.d.ts → utils/kv-cache.test.d.ts} +0 -0
  188. /package/dist/{runtime/key.test.d.ts → utils/request.test.d.ts} +0 -0
  189. /package/dist/{runtime → utils}/url.test.d.ts +0 -0
  190. /package/dist/{sig-ByHXzqUi.cjs → utils-B6yXfxAQ.cjs} +0 -0
  191. /package/dist/{sig-Cj3tk-ig.js → utils-BXMGcmqK.js} +0 -0
  192. /package/dist/{webfinger-BjOEdFPs.cjs → webfinger-C949bxcD.cjs} +0 -0
  193. /package/dist/{webfinger-De_bU0iE.js → webfinger-qG8R5jc3.js} +0 -0
@@ -3,136 +3,58 @@
3
3
  const { URLPattern } = require("urlpattern-polyfill");
4
4
 
5
5
  const require_chunk = require('./chunk-DqRYRqnO.cjs');
6
+ const require_request = require('./request-XHWUW2bi.cjs');
7
+ const require_lookup = require('./lookup-CMAGfQ1Q.cjs');
8
+ const require_http = require('./http-DMsjudj8.cjs');
6
9
  const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
7
- const node_process = require_chunk.__toESM(require("node:process"));
8
- const node_dns_promises = require_chunk.__toESM(require("node:dns/promises"));
9
- const node_net = require_chunk.__toESM(require("node:net"));
10
+ const __fedify_vocab_runtime = require_chunk.__toESM(require("@fedify/vocab-runtime"));
11
+ const __fxts_core = require_chunk.__toESM(require("@fxts/core"));
10
12
 
11
- //#region deno.json
12
- var name = "@fedify/fedify";
13
- var version = "2.0.0-pr.449.1725+70c3284b";
14
- var license = "MIT";
15
- var exports$1 = {
16
- ".": "./src/mod.ts",
17
- "./compat": "./src/compat/mod.ts",
18
- "./federation": "./src/federation/mod.ts",
19
- "./nodeinfo": "./src/nodeinfo/mod.ts",
20
- "./runtime": "./src/runtime/mod.ts",
21
- "./sig": "./src/sig/mod.ts",
22
- "./testing": "./src/testing/mod.ts",
23
- "./vocab": "./src/vocab/mod.ts",
24
- "./webfinger": "./src/webfinger/mod.ts",
25
- "./x/cfworkers": "./src/x/cfworkers.ts",
26
- "./x/denokv": "./src/x/denokv.ts",
27
- "./x/fresh": "./src/x/fresh.ts",
28
- "./x/hono": "./src/x/hono.ts",
29
- "./x/sveltekit": "./src/x/sveltekit.ts"
30
- };
31
- var imports = {
32
- "@cfworker/json-schema": "npm:@cfworker/json-schema@^4.1.1",
33
- "@multiformats/base-x": "npm:@multiformats/base-x@^4.0.1",
34
- "@opentelemetry/api": "npm:@opentelemetry/api@^1.9.0",
35
- "@opentelemetry/semantic-conventions": "npm:@opentelemetry/semantic-conventions@^1.27.0",
36
- "@std/assert": "jsr:@std/assert@^0.226.0",
37
- "@std/testing": "jsr:@std/testing@^0.224.0",
38
- "@std/url": "jsr:@std/url@^0.225.1",
39
- "asn1js": "npm:asn1js@^3.0.5",
40
- "byte-encodings": "npm:byte-encodings@^1.0.11",
41
- "es-toolkit": "jsr:@es-toolkit/es-toolkit@^1.39.5",
42
- "fast-check": "npm:fast-check@^3.22.0",
43
- "fetch-mock": "npm:fetch-mock@^12.5.2",
44
- "json-canon": "npm:json-canon@^1.0.1",
45
- "jsonld": "npm:jsonld@^8.3.2",
46
- "multicodec": "npm:multicodec@^3.2.1",
47
- "pkijs": "npm:pkijs@^3.2.4",
48
- "structured-field-values": "npm:structured-field-values@^2.0.4",
49
- "uri-template-router": "npm:uri-template-router@^0.0.17",
50
- "url-template": "npm:url-template@^3.1.1"
51
- };
52
- var include = ["src/vocab/vocab.ts"];
53
- var exclude = [
54
- ".test-report.xml",
55
- "apidoc/",
56
- "dist/",
57
- "node_modules/",
58
- "npm/",
59
- "pnpm-lock.yaml",
60
- "src/cfworkers/dist/",
61
- "src/cfworkers/fixtures/",
62
- "src/cfworkers/imports.ts",
63
- "src/cfworkers/README.md",
64
- "src/cfworkers/server.ts",
65
- "src/cfworkers/server.js",
66
- "src/cfworkers/server.js.map",
67
- "src/codegen/schema.yaml",
68
- "src/vocab/*.yaml",
69
- "!src/vocab/vocab.ts"
70
- ];
71
- var tasks = {
72
- "codegen": "GENPATH=vocab-$(deno eval \"console.log(crypto.randomUUID());\").ts && deno run --allow-read --allow-write --check src/codegen/main.ts src/vocab/ ../runtime/ src/vocab/$GENPATH && deno fmt src/vocab/$GENPATH && mv src/vocab/$GENPATH src/vocab/vocab.ts && deno cache src/vocab/vocab.ts && deno check src/vocab/vocab.ts",
73
- "cache": {
74
- "command": "deno cache src/mod.ts",
75
- "dependencies": ["codegen"]
76
- },
77
- "check": {
78
- "command": "deno fmt --check && deno lint && deno check src/**/*.ts",
79
- "dependencies": ["codegen"]
80
- },
81
- "test": {
82
- "command": "deno test --check --doc --allow-read --allow-write --allow-env --unstable-kv --trace-leaks --parallel",
83
- "dependencies": ["codegen"]
84
- },
85
- "coverage": "deno task test --clean --coverage && deno coverage --html coverage",
86
- "bench": {
87
- "command": "deno bench --allow-read --allow-write --allow-net --allow-env --allow-run --unstable-kv",
88
- "dependencies": ["codegen"]
89
- },
90
- "apidoc": {
91
- "command": "deno doc --html --name=Fedify --output=apidoc/ src/mod.ts",
92
- "dependencies": ["codegen"]
93
- },
94
- "publish": {
95
- "command": "deno publish",
96
- "dependencies": ["codegen"]
97
- },
98
- "pnpm:install": "pnpm install --silent",
99
- "pnpm:build": {
100
- "command": "pnpm exec tsdown",
101
- "dependencies": ["codegen", "pnpm:install"]
102
- },
103
- "test:node": {
104
- "command": "cd dist/ && node --test",
105
- "dependencies": ["pnpm:build"]
106
- },
107
- "test:bun": {
108
- "command": "cd dist/ && bun test --timeout 60000",
109
- "dependencies": ["pnpm:build"]
110
- },
111
- "test:cfworkers": {
112
- "command": "pnpm exec wrangler deploy --dry-run --outdir src/cfworkers && node --import=tsx src/cfworkers/client.ts",
113
- "dependencies": ["pnpm:build"]
114
- },
115
- "test-all": { "dependencies": [
116
- "check",
117
- "test",
118
- "test:node",
119
- "test:bun",
120
- "test:cfworkers"
121
- ] }
122
- };
123
- var deno_default = {
124
- name,
125
- version,
126
- license,
127
- exports: exports$1,
128
- imports,
129
- include,
130
- exclude,
131
- tasks
132
- };
13
+ //#region src/utils/docloader.ts
14
+ const logger$1 = (0, __logtape_logtape.getLogger)([
15
+ "fedify",
16
+ "utils",
17
+ "docloader"
18
+ ]);
19
+ /**
20
+ * Gets an authenticated {@link DocumentLoader} for the given identity.
21
+ * Note that an authenticated document loader intentionally does not cache
22
+ * the fetched documents.
23
+ * @param identity The identity to get the document loader for.
24
+ * The actor's key pair.
25
+ * @param options The options for the document loader.
26
+ * @returns The authenticated document loader.
27
+ * @throws {TypeError} If the key is invalid or unsupported.
28
+ * @since 0.4.0
29
+ */
30
+ function getAuthenticatedDocumentLoader(identity, { allowPrivateAddress, userAgent, specDeterminer, tracerProvider } = {}) {
31
+ require_http.validateCryptoKey(identity.privateKey);
32
+ async function load(url, options) {
33
+ if (!allowPrivateAddress) try {
34
+ await require_lookup.validatePublicUrl(url);
35
+ } catch (error) {
36
+ if (error instanceof require_lookup.UrlError) logger$1.error("Disallowed private URL: {url}", {
37
+ url,
38
+ error
39
+ });
40
+ throw error;
41
+ }
42
+ const originalRequest = require_request.createActivityPubRequest(url, { userAgent });
43
+ const response = await require_http.doubleKnock(originalRequest, identity, {
44
+ specDeterminer,
45
+ log: (0, __fxts_core.curry)(require_request.logRequest)(logger$1),
46
+ tracerProvider,
47
+ signal: options?.signal
48
+ });
49
+ return (0, __fedify_vocab_runtime.getRemoteDocument)(url, response, load);
50
+ }
51
+ return load;
52
+ }
53
+ const _fetchDocumentLoader = (0, __fedify_vocab_runtime.getDocumentLoader)();
54
+ const _fetchDocumentLoader_allowPrivateAddress = (0, __fedify_vocab_runtime.getDocumentLoader)({ allowPrivateAddress: true });
133
55
 
134
56
  //#endregion
135
- //#region src/runtime/contexts.ts
57
+ //#region src/utils/contexts.ts
136
58
  const preloadedContexts = {
137
59
  "https://www.w3.org/ns/activitystreams": { "@context": {
138
60
  "@vocab": "_:",
@@ -4274,450 +4196,15 @@ const preloadedContexts = {
4274
4196
  }
4275
4197
  } }
4276
4198
  };
4277
- var contexts_default = preloadedContexts;
4278
4199
 
4279
4200
  //#endregion
4280
- //#region src/runtime/link.ts
4281
- const parametersNeedLowerCase = ["rel", "type"];
4282
- const regexpLinkWhitespace = /[\n\r\s\t]/;
4283
- function validateURI(uri) {
4284
- if (uri.includes("\n") || regexpLinkWhitespace.test(uri)) throw new SyntaxError(`\`${uri}\` is not a valid URI!`);
4285
- }
4286
- function* parseLinkFromString(input) {
4287
- const inputFmt = input.replaceAll("\xA0", "").replaceAll("", "");
4288
- for (let cursor = 0; cursor < inputFmt.length; cursor += 1) {
4289
- while (regexpLinkWhitespace.test(inputFmt.charAt(cursor))) cursor += 1;
4290
- if (inputFmt.charAt(cursor) !== "<") throw new SyntaxError(`Unexpected character \`${inputFmt.charAt(cursor)}\` at position ${cursor}; Expect character \`<\`!`);
4291
- cursor += 1;
4292
- const cursorEndUri = inputFmt.indexOf(">", cursor);
4293
- if (cursorEndUri === -1) throw new SyntaxError(`Missing end of URI delimiter character \`>\` after position ${cursor}!`);
4294
- if (cursorEndUri === cursor) throw new SyntaxError(`Missing URI at position ${cursor}!`);
4295
- const uriSlice = inputFmt.slice(cursor, cursorEndUri);
4296
- validateURI(uriSlice);
4297
- const uri = decodeURI(uriSlice);
4298
- const parameters = {};
4299
- cursor = cursorEndUri + 1;
4300
- while (regexpLinkWhitespace.test(inputFmt.charAt(cursor))) cursor += 1;
4301
- if (cursor === inputFmt.length || inputFmt.charAt(cursor) === ",") {
4302
- yield [uri, parameters];
4303
- continue;
4304
- }
4305
- if (inputFmt.charAt(cursor) !== ";") throw new SyntaxError(`Unexpected character \`${inputFmt.charAt(cursor)}\` at position ${cursor}; Expect character \`;\`!`);
4306
- cursor += 1;
4307
- while (cursor < inputFmt.length) {
4308
- while (regexpLinkWhitespace.test(inputFmt.charAt(cursor))) cursor += 1;
4309
- const parameterKey = inputFmt.slice(cursor).match(/^[\w-]+\*?/)?.[0].toLowerCase();
4310
- if (typeof parameterKey === "undefined") throw new SyntaxError(`Unexpected character \`${inputFmt.charAt(cursor)}\` at position ${cursor}; Expect a valid parameter key!`);
4311
- cursor += parameterKey.length;
4312
- while (regexpLinkWhitespace.test(inputFmt.charAt(cursor))) cursor += 1;
4313
- if (cursor === inputFmt.length || inputFmt.charAt(cursor) === ",") {
4314
- parameters[parameterKey] = "";
4315
- break;
4316
- }
4317
- if (inputFmt.charAt(cursor) === ";") {
4318
- parameters[parameterKey] = "";
4319
- cursor += 1;
4320
- continue;
4321
- }
4322
- if (inputFmt.charAt(cursor) !== "=") throw new SyntaxError(`Unexpected character \`${inputFmt.charAt(cursor)}\` at position ${cursor}; Expect character \`=\`!`);
4323
- cursor += 1;
4324
- while (regexpLinkWhitespace.test(inputFmt.charAt(cursor))) cursor += 1;
4325
- let parameterValue = "";
4326
- if (inputFmt.charAt(cursor) === "\"") {
4327
- cursor += 1;
4328
- while (cursor < inputFmt.length) {
4329
- if (inputFmt.charAt(cursor) === "\"") {
4330
- cursor += 1;
4331
- break;
4332
- }
4333
- if (inputFmt.charAt(cursor) === "\\") cursor += 1;
4334
- parameterValue += inputFmt.charAt(cursor);
4335
- cursor += 1;
4336
- }
4337
- } else {
4338
- const cursorDiffParameterValue = inputFmt.slice(cursor).search(/[\s;,]/);
4339
- if (cursorDiffParameterValue === -1) {
4340
- parameterValue += inputFmt.slice(cursor);
4341
- cursor += parameterValue.length;
4342
- } else {
4343
- parameterValue += inputFmt.slice(cursor, cursorDiffParameterValue);
4344
- cursor += cursorDiffParameterValue;
4345
- }
4346
- }
4347
- parameters[parameterKey] = parametersNeedLowerCase.includes(parameterKey) ? parameterValue.toLowerCase() : parameterValue;
4348
- while (regexpLinkWhitespace.test(inputFmt.charAt(cursor))) cursor += 1;
4349
- if (cursor === inputFmt.length || inputFmt.charAt(cursor) === ",") break;
4350
- if (inputFmt.charAt(cursor) === ";") {
4351
- cursor += 1;
4352
- continue;
4353
- }
4354
- throw new SyntaxError(`Unexpected character \`${inputFmt.charAt(cursor)}\` at position ${cursor}; Expect character \`,\`, character \`;\`, or end of the string!`);
4355
- }
4356
- yield [uri, parameters];
4357
- }
4358
- }
4359
- /**
4360
- * Handle the HTTP header `Link` according to the specification RFC 8288.
4361
- */
4362
- var HttpHeaderLink = class HttpHeaderLink {
4363
- get [Symbol.toStringTag]() {
4364
- return "HTTPHeaderLink";
4365
- }
4366
- #entries = [];
4367
- /**
4368
- * Handle the HTTP header `Link` according to the specification RFC 8288.
4369
- * @param {...(string | Headers | HttpHeaderLink | HttpHeaderLinkEntry[] | Response)} inputs Input.
4370
- */
4371
- constructor(...inputs) {
4372
- if (inputs.length > 0) this.add(...inputs);
4373
- }
4374
- /**
4375
- * Add entries.
4376
- * @param {...(string | Headers | HttpHeaderLink | HttpHeaderLinkEntry[] | Response)} inputs Input.
4377
- * @returns {this}
4378
- */
4379
- add(...inputs) {
4380
- for (const input of inputs) if (input instanceof HttpHeaderLink) this.#entries.push(...structuredClone(input.#entries));
4381
- else if (Array.isArray(input)) this.#entries.push(...input.map(([uri, parameters]) => {
4382
- validateURI(uri);
4383
- Object.entries(parameters).forEach(([key, value]) => {
4384
- if (key !== key.toLowerCase() || !/^[\w-]+\*?$/.test(key)) throw new SyntaxError(`\`${key}\` is not a valid parameter key!`);
4385
- if (parametersNeedLowerCase.includes(key) && value !== value.toLowerCase()) throw new SyntaxError(`\`${value}\` is not a valid parameter value!`);
4386
- });
4387
- return [uri, structuredClone(parameters)];
4388
- }));
4389
- else for (const entry of parseLinkFromString((input instanceof Headers || input instanceof Response ? (input instanceof Headers ? input : input.headers).get("Link") : input) ?? "")) this.#entries.push(entry);
4390
- return this;
4391
- }
4392
- /**
4393
- * Return all of the entries.
4394
- * @returns {HttpHeaderLinkEntry[]} Entries.
4395
- */
4396
- entries() {
4397
- return structuredClone(this.#entries);
4398
- }
4399
- /**
4400
- * Get entries by parameter.
4401
- * @param {string} key Key of the parameter.
4402
- * @param {string} value Value of the parameter.
4403
- * @returns {HttpHeaderLinkEntry[]} Entries which match the parameter.
4404
- */
4405
- getByParameter(key, value) {
4406
- if (key !== key.toLowerCase()) throw new SyntaxError(`\`${key}\` is not a valid parameter key!`);
4407
- if (key === "rel") return this.getByRel(value);
4408
- return structuredClone(this.#entries.filter((entry) => {
4409
- return entry[1][key] === value;
4410
- }));
4411
- }
4412
- /**
4413
- * Get entries by parameter `rel`.
4414
- * @param {string} value Value of the parameter `rel`.
4415
- * @returns {HttpHeaderLinkEntry[]} Entries which match the parameter.
4416
- */
4417
- getByRel(value) {
4418
- if (value !== value.toLowerCase()) throw new SyntaxError(`\`${value}\` is not a valid parameter \`rel\` value!`);
4419
- return structuredClone(this.#entries.filter((entity) => {
4420
- return entity[1].rel?.toLowerCase() === value;
4421
- }));
4422
- }
4423
- /**
4424
- * Whether have entries that match parameter.
4425
- * @param {string} key Key of the parameter.
4426
- * @param {string} value Value of the parameter.
4427
- * @returns {boolean} Determine result.
4428
- */
4429
- hasParameter(key, value) {
4430
- return this.getByParameter(key, value).length > 0;
4431
- }
4432
- /**
4433
- * Stringify entries.
4434
- * @returns {string} Stringified entries.
4435
- */
4436
- toString() {
4437
- return this.#entries.map(([uri, parameters]) => {
4438
- return [`<${encodeURI(uri)}>`, ...Object.entries(parameters).map(([key, value]) => {
4439
- return value.length > 0 ? `${key}="${value.replaceAll("\"", "\\\"")}"` : key;
4440
- })].join("; ");
4441
- }).join(", ");
4442
- }
4443
- /**
4444
- * Parse the HTTP header `Link` according to the specification RFC 8288.
4445
- * @param {...(string | Headers | HttpHeaderLink | HttpHeaderLinkEntry[] | Response)} inputs Input.
4446
- * @returns {HttpHeaderLink}
4447
- */
4448
- static parse(...inputs) {
4449
- return new this(...inputs);
4450
- }
4451
- /**
4452
- * Stringify as the HTTP header `Link` according to the specification RFC 8288.
4453
- * @param {...(string | Headers | HttpHeaderLink | HttpHeaderLinkEntry[] | Response)} inputs Input.
4454
- * @returns {string}
4455
- */
4456
- static stringify(...inputs) {
4457
- return new this(...inputs).toString();
4458
- }
4459
- };
4460
-
4461
- //#endregion
4462
- //#region src/runtime/url.ts
4463
- var UrlError = class extends Error {
4464
- constructor(message) {
4465
- super(message);
4466
- this.name = "UrlError";
4467
- }
4468
- };
4469
- /**
4470
- * Validates a URL to prevent SSRF attacks.
4471
- */
4472
- async function validatePublicUrl(url) {
4473
- const parsed = new URL(url);
4474
- if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw new UrlError(`Unsupported protocol: ${parsed.protocol}`);
4475
- let hostname = parsed.hostname;
4476
- if (hostname.startsWith("[") && hostname.endsWith("]")) hostname = hostname.substring(1, hostname.length - 2);
4477
- if (hostname === "localhost") throw new UrlError("Localhost is not allowed");
4478
- if ("Deno" in globalThis && !(0, node_net.isIP)(hostname)) {
4479
- const netPermission = await Deno.permissions.query({ name: "net" });
4480
- if (netPermission.state !== "granted") return;
4481
- }
4482
- if ("Bun" in globalThis) {
4483
- if (hostname === "example.com" || hostname.endsWith(".example.com")) return;
4484
- else if (hostname === "fedify-test.internal") throw new UrlError("Invalid or private address: fedify-test.internal");
4485
- }
4486
- let addresses;
4487
- try {
4488
- addresses = await (0, node_dns_promises.lookup)(hostname, { all: true });
4489
- } catch {
4490
- addresses = [];
4491
- }
4492
- for (const { address, family } of addresses) if (family === 4 && !isValidPublicIPv4Address(address) || family === 6 && !isValidPublicIPv6Address(address) || family < 4 || family === 5 || family > 6) throw new UrlError(`Invalid or private address: ${address}`);
4493
- }
4494
- function isValidPublicIPv4Address(address) {
4495
- const parts = address.split(".");
4496
- const first = parseInt(parts[0]);
4497
- if (first === 0 || first === 10 || first === 127) return false;
4498
- const second = parseInt(parts[1]);
4499
- if (first === 169 && second === 254) return false;
4500
- if (first === 172 && second >= 16 && second <= 31) return false;
4501
- if (first === 192 && second === 168) return false;
4502
- return true;
4503
- }
4504
- function isValidPublicIPv6Address(address) {
4505
- address = expandIPv6Address(address);
4506
- if (address.at(4) !== ":") return false;
4507
- const firstWord = parseInt(address.substring(0, 4), 16);
4508
- return !(firstWord >= 64512 && firstWord <= 65023 || firstWord >= 65152 && firstWord <= 65215 || firstWord === 0 || firstWord >= 65280);
4509
- }
4510
- function expandIPv6Address(address) {
4511
- address = address.toLowerCase();
4512
- if (address === "::") return "0000:0000:0000:0000:0000:0000:0000:0000";
4513
- if (address.startsWith("::")) address = "0000" + address;
4514
- if (address.endsWith("::")) address = address + "0000";
4515
- address = address.replace("::", ":0000".repeat(8 - (address.match(/:/g) || []).length) + ":");
4516
- const parts = address.split(":");
4517
- return parts.map((part) => part.padStart(4, "0")).join(":");
4518
- }
4519
-
4520
- //#endregion
4521
- //#region src/runtime/docloader.ts
4201
+ //#region src/utils/kv-cache.ts
4522
4202
  const logger = (0, __logtape_logtape.getLogger)([
4523
4203
  "fedify",
4524
- "runtime",
4525
- "docloader"
4204
+ "utils",
4205
+ "kv-cache"
4526
4206
  ]);
4527
4207
  /**
4528
- * Error thrown when fetching a JSON-LD document failed.
4529
- */
4530
- var FetchError = class extends Error {
4531
- /**
4532
- * The URL that failed to fetch.
4533
- */
4534
- url;
4535
- /**
4536
- * Constructs a new `FetchError`.
4537
- *
4538
- * @param url The URL that failed to fetch.
4539
- * @param message Error message.
4540
- */
4541
- constructor(url, message) {
4542
- super(message == null ? url.toString() : `${url}: ${message}`);
4543
- this.name = "FetchError";
4544
- this.url = typeof url === "string" ? new URL(url) : url;
4545
- }
4546
- };
4547
- /**
4548
- * Creates a request for the given URL.
4549
- * @param url The URL to create the request for.
4550
- * @param options The options for the request.
4551
- * @returns The created request.
4552
- * @internal
4553
- */
4554
- function createRequest(url, options = {}) {
4555
- return new Request(url, {
4556
- headers: {
4557
- Accept: "application/activity+json, application/ld+json",
4558
- "User-Agent": typeof options.userAgent === "string" ? options.userAgent : getUserAgent(options.userAgent)
4559
- },
4560
- redirect: "manual"
4561
- });
4562
- }
4563
- /**
4564
- * Logs the request.
4565
- * @param request The request to log.
4566
- * @internal
4567
- */
4568
- function logRequest(request) {
4569
- logger.debug("Fetching document: {method} {url} {headers}", {
4570
- method: request.method,
4571
- url: request.url,
4572
- headers: Object.fromEntries(request.headers.entries())
4573
- });
4574
- }
4575
- /**
4576
- * Gets a {@link RemoteDocument} from the given response.
4577
- * @param url The URL of the document to load.
4578
- * @param response The response to get the document from.
4579
- * @param fetch The function to fetch the document.
4580
- * @returns The loaded remote document.
4581
- * @throws {FetchError} If the response is not OK.
4582
- * @internal
4583
- */
4584
- async function getRemoteDocument(url, response, fetch$1) {
4585
- const documentUrl = response.url === "" ? url : response.url;
4586
- const docUrl = new URL(documentUrl);
4587
- if (!response.ok) {
4588
- logger.error("Failed to fetch document: {status} {url} {headers}", {
4589
- status: response.status,
4590
- url: documentUrl,
4591
- headers: Object.fromEntries(response.headers.entries())
4592
- });
4593
- throw new FetchError(documentUrl, `HTTP ${response.status}: ${documentUrl}`);
4594
- }
4595
- const contentType = response.headers.get("Content-Type");
4596
- const jsonLd = contentType == null || contentType === "application/activity+json" || contentType.startsWith("application/activity+json;") || contentType === "application/ld+json" || contentType.startsWith("application/ld+json;");
4597
- const linkHeader = response.headers.get("Link");
4598
- let contextUrl = null;
4599
- if (linkHeader != null) {
4600
- let link;
4601
- try {
4602
- link = new HttpHeaderLink(linkHeader);
4603
- } catch (e) {
4604
- if (e instanceof SyntaxError) link = new HttpHeaderLink();
4605
- else throw e;
4606
- }
4607
- if (jsonLd) {
4608
- const entries = link.getByRel("http://www.w3.org/ns/json-ld#context");
4609
- for (const [uri, params] of entries) if ("type" in params && params.type === "application/ld+json") {
4610
- contextUrl = uri;
4611
- break;
4612
- }
4613
- } else {
4614
- const entries = link.getByRel("alternate");
4615
- for (const [uri, params] of entries) {
4616
- const altUri = new URL(uri, docUrl);
4617
- if ("type" in params && (params.type === "application/activity+json" || params.type === "application/ld+json" || params.type.startsWith("application/ld+json;")) && altUri.href !== docUrl.href) {
4618
- logger.debug("Found alternate document: {alternateUrl} from {url}", {
4619
- alternateUrl: altUri.href,
4620
- url: documentUrl
4621
- });
4622
- return await fetch$1(altUri.href);
4623
- }
4624
- }
4625
- }
4626
- }
4627
- let document;
4628
- if (!jsonLd && (contentType === "text/html" || contentType?.startsWith("text/html;") || contentType === "application/xhtml+xml" || contentType?.startsWith("application/xhtml+xml;"))) {
4629
- const p = /<(a|link)((\s+[a-z][a-z:_-]*=("[^"]*"|'[^']*'|[^\s>]+))+)\s*\/?>/gi;
4630
- const p2 = /\s+([a-z][a-z:_-]*)=("([^"]*)"|'([^']*)'|([^\s>]+))/gi;
4631
- const html = await response.text();
4632
- let m;
4633
- const rawAttribs = [];
4634
- while ((m = p.exec(html)) !== null) rawAttribs.push(m[2]);
4635
- for (const rawAttrs of rawAttribs) {
4636
- let m2;
4637
- const attribs = {};
4638
- while ((m2 = p2.exec(rawAttrs)) !== null) {
4639
- const key = m2[1].toLowerCase();
4640
- const value = m2[3] ?? m2[4] ?? m2[5] ?? "";
4641
- attribs[key] = value;
4642
- }
4643
- if (attribs.rel === "alternate" && "type" in attribs && (attribs.type === "application/activity+json" || attribs.type === "application/ld+json" || attribs.type.startsWith("application/ld+json;")) && "href" in attribs && new URL(attribs.href, docUrl).href !== docUrl.href) {
4644
- logger.debug("Found alternate document: {alternateUrl} from {url}", {
4645
- alternateUrl: attribs.href,
4646
- url: documentUrl
4647
- });
4648
- return await fetch$1(new URL(attribs.href, docUrl).href);
4649
- }
4650
- }
4651
- document = JSON.parse(html);
4652
- } else document = await response.json();
4653
- logger.debug("Fetched document: {status} {url} {headers}", {
4654
- status: response.status,
4655
- url: documentUrl,
4656
- headers: Object.fromEntries(response.headers.entries())
4657
- });
4658
- return {
4659
- contextUrl,
4660
- document,
4661
- documentUrl
4662
- };
4663
- }
4664
- /**
4665
- * Creates a JSON-LD document loader that utilizes the browser's `fetch` API.
4666
- *
4667
- * The created loader preloads the below frequently used contexts by default
4668
- * (unless `options.ignorePreloadedContexts` is set to `true`):
4669
- *
4670
- * - <https://www.w3.org/ns/activitystreams>
4671
- * - <https://w3id.org/security/v1>
4672
- * - <https://w3id.org/security/data-integrity/v1>
4673
- * - <https://www.w3.org/ns/did/v1>
4674
- * - <https://w3id.org/security/multikey/v1>
4675
- * - <https://purl.archive.org/socialweb/webfinger>
4676
- * - <http://schema.org/>
4677
- * @param options Options for the document loader.
4678
- * @returns The document loader.
4679
- * @since 1.3.0
4680
- */
4681
- function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAgent } = {}) {
4682
- async function load(url, options) {
4683
- options?.signal?.throwIfAborted();
4684
- if (!skipPreloadedContexts && url in contexts_default) {
4685
- logger.debug("Using preloaded context: {url}.", { url });
4686
- return {
4687
- contextUrl: null,
4688
- document: contexts_default[url],
4689
- documentUrl: url
4690
- };
4691
- }
4692
- if (!allowPrivateAddress) try {
4693
- await validatePublicUrl(url);
4694
- } catch (error) {
4695
- if (error instanceof UrlError) logger.error("Disallowed private URL: {url}", {
4696
- url,
4697
- error
4698
- });
4699
- throw error;
4700
- }
4701
- const request = createRequest(url, { userAgent });
4702
- logRequest(request);
4703
- const response = await fetch(request, {
4704
- redirect: "manual",
4705
- signal: options?.signal
4706
- });
4707
- if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) return load(response.headers.get("Location"), options);
4708
- return getRemoteDocument(url, response, load);
4709
- }
4710
- return load;
4711
- }
4712
- const _fetchDocumentLoader = getDocumentLoader();
4713
- const _fetchDocumentLoader_allowPrivateAddress = getDocumentLoader({ allowPrivateAddress: true });
4714
- function fetchDocumentLoader(url, arg = false) {
4715
- const allowPrivateAddress = typeof arg === "boolean" ? arg : false;
4716
- logger.warn("fetchDocumentLoader() function is deprecated. Use getDocumentLoader() function instead.");
4717
- const loader = allowPrivateAddress ? _fetchDocumentLoader_allowPrivateAddress : _fetchDocumentLoader;
4718
- return loader(url);
4719
- }
4720
- /**
4721
4208
  * Decorates a {@link DocumentLoader} with a cache backed by a {@link Deno.Kv}.
4722
4209
  * @param parameters The parameters for the cache.
4723
4210
  * @returns The decorated document loader which is cache-enabled.
@@ -4726,30 +4213,16 @@ function kvCache({ loader, kv, prefix, rules }) {
4726
4213
  const keyPrefix = prefix ?? ["_fedify", "remoteDocument"];
4727
4214
  rules ??= [[new URLPattern({}), Temporal.Duration.from({ minutes: 5 })]];
4728
4215
  for (const [p, duration] of rules) if (Temporal.Duration.compare(duration, { days: 30 }) > 0) throw new TypeError("The maximum cache duration is 30 days: " + (p instanceof URLPattern ? `${p.protocol}://${p.username}:${p.password}@${p.hostname}:${p.port}/${p.pathname}?${p.search}#${p.hash}` : p.toString()));
4729
- function matchRule(url) {
4730
- for (const [pattern, duration] of rules) {
4731
- if (typeof pattern === "string") {
4732
- if (url === pattern) return duration;
4733
- continue;
4734
- }
4735
- if (pattern instanceof URL) {
4736
- if (pattern.href == url) return duration;
4737
- continue;
4738
- }
4739
- if (pattern.test(url)) return duration;
4740
- }
4741
- return null;
4742
- }
4743
4216
  return async (url, options) => {
4744
- if (url in contexts_default) {
4217
+ if (url in preloadedContexts) {
4745
4218
  logger.debug("Using preloaded context: {url}.", { url });
4746
4219
  return {
4747
4220
  contextUrl: null,
4748
- document: contexts_default[url],
4221
+ document: preloadedContexts[url],
4749
4222
  documentUrl: url
4750
4223
  };
4751
4224
  }
4752
- const match = matchRule(url);
4225
+ const match = matchRule(url, rules);
4753
4226
  if (match == null) return await loader(url, options);
4754
4227
  const key = [...keyPrefix, url];
4755
4228
  let cache = void 0;
@@ -4776,69 +4249,26 @@ function kvCache({ loader, kv, prefix, rules }) {
4776
4249
  return cache;
4777
4250
  };
4778
4251
  }
4779
- /**
4780
- * Gets the user agent string for the given application and URL.
4781
- * @param options The options for making the user agent string.
4782
- * @returns The user agent string.
4783
- * @since 1.3.0
4784
- */
4785
- function getUserAgent({ software, url } = {}) {
4786
- const fedify = `Fedify/${deno_default.version}`;
4787
- const runtime = globalThis.Deno?.version?.deno != null ? `Deno/${Deno.version.deno}` : globalThis.process?.versions?.bun != null ? `Bun/${node_process.default.versions.bun}` : "navigator" in globalThis && navigator.userAgent === "Cloudflare-Workers" ? navigator.userAgent : globalThis.process?.versions?.node != null ? `Node.js/${node_process.default.versions.node}` : null;
4788
- const userAgent = software == null ? [fedify] : [software, fedify];
4789
- if (runtime != null) userAgent.push(runtime);
4790
- if (url != null) userAgent.push(`+${url.toString()}`);
4791
- const first = userAgent.shift();
4792
- return `${first} (${userAgent.join("; ")})`;
4252
+ function matchRule(url, rules) {
4253
+ for (const [pattern, duration] of rules) {
4254
+ if (typeof pattern === "string") {
4255
+ if (url === pattern) return duration;
4256
+ continue;
4257
+ }
4258
+ if (pattern instanceof URL) {
4259
+ if (pattern.href == url) return duration;
4260
+ continue;
4261
+ }
4262
+ if (pattern.test(url)) return duration;
4263
+ }
4264
+ return null;
4793
4265
  }
4794
4266
 
4795
4267
  //#endregion
4796
- Object.defineProperty(exports, 'FetchError', {
4797
- enumerable: true,
4798
- get: function () {
4799
- return FetchError;
4800
- }
4801
- });
4802
- Object.defineProperty(exports, 'UrlError', {
4803
- enumerable: true,
4804
- get: function () {
4805
- return UrlError;
4806
- }
4807
- });
4808
- Object.defineProperty(exports, 'createRequest', {
4809
- enumerable: true,
4810
- get: function () {
4811
- return createRequest;
4812
- }
4813
- });
4814
- Object.defineProperty(exports, 'deno_default', {
4815
- enumerable: true,
4816
- get: function () {
4817
- return deno_default;
4818
- }
4819
- });
4820
- Object.defineProperty(exports, 'fetchDocumentLoader', {
4268
+ Object.defineProperty(exports, 'getAuthenticatedDocumentLoader', {
4821
4269
  enumerable: true,
4822
4270
  get: function () {
4823
- return fetchDocumentLoader;
4824
- }
4825
- });
4826
- Object.defineProperty(exports, 'getDocumentLoader', {
4827
- enumerable: true,
4828
- get: function () {
4829
- return getDocumentLoader;
4830
- }
4831
- });
4832
- Object.defineProperty(exports, 'getRemoteDocument', {
4833
- enumerable: true,
4834
- get: function () {
4835
- return getRemoteDocument;
4836
- }
4837
- });
4838
- Object.defineProperty(exports, 'getUserAgent', {
4839
- enumerable: true,
4840
- get: function () {
4841
- return getUserAgent;
4271
+ return getAuthenticatedDocumentLoader;
4842
4272
  }
4843
4273
  });
4844
4274
  Object.defineProperty(exports, 'kvCache', {
@@ -4846,16 +4276,4 @@ Object.defineProperty(exports, 'kvCache', {
4846
4276
  get: function () {
4847
4277
  return kvCache;
4848
4278
  }
4849
- });
4850
- Object.defineProperty(exports, 'logRequest', {
4851
- enumerable: true,
4852
- get: function () {
4853
- return logRequest;
4854
- }
4855
- });
4856
- Object.defineProperty(exports, 'validatePublicUrl', {
4857
- enumerable: true,
4858
- get: function () {
4859
- return validatePublicUrl;
4860
- }
4861
4279
  });