@fedify/fedify 2.0.1 → 2.0.2-dev.415

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 (98) hide show
  1. package/dist/{builder-CqPrSnE5.js → builder-B55ClH_D.js} +3 -3
  2. package/dist/client-BxMZiQaD.d.ts +224 -0
  3. package/dist/client-C97KOq3x.d.cts +222 -0
  4. package/dist/compat/mod.d.cts +6 -6
  5. package/dist/compat/mod.d.ts +6 -6
  6. package/dist/compat/transformers.test.js +11 -11
  7. package/dist/context-D3QkEtZd.d.cts +2494 -0
  8. package/dist/context-DZJhUmzF.d.ts +2496 -0
  9. package/dist/{deno-CIi8RNND.js → deno-D-Duks4b.js} +1 -1
  10. package/dist/{docloader-CmrEfaGw.js → docloader-Bb4MhBYJ.js} +2 -2
  11. package/dist/federation/builder.test.js +3 -3
  12. package/dist/federation/handler.test.js +19 -19
  13. package/dist/federation/idempotency.test.js +11 -11
  14. package/dist/federation/inbox.test.js +2 -2
  15. package/dist/federation/middleware.test.js +11 -11
  16. package/dist/federation/mod.cjs +4 -4
  17. package/dist/federation/mod.d.cts +6 -6
  18. package/dist/federation/mod.d.ts +6 -6
  19. package/dist/federation/mod.js +4 -4
  20. package/dist/federation/send.test.js +5 -5
  21. package/dist/federation/webfinger.test.js +11 -11
  22. package/dist/{http-CCsNu78I.js → http-C3ipH_7H.js} +1 -1
  23. package/dist/http-Cz3MlXAZ.d.cts +244 -0
  24. package/dist/{http-BjroyS-9.cjs → http-DGYGS8C8.cjs} +1 -1
  25. package/dist/http-DkHdFfrc.d.ts +246 -0
  26. package/dist/{http-Dvox_xrq.js → http-DnP0rGKj.js} +2 -2
  27. package/dist/{inbox-CiTdVhJQ.js → inbox-CbNZlhe6.js} +1 -1
  28. package/dist/{key-C7JS89OH.js → key-DChkqRrm.js} +1 -1
  29. package/dist/kv-BL4nlICN.d.cts +110 -0
  30. package/dist/kv-DXEUEP6z.d.ts +113 -0
  31. package/dist/{kv-cache-BqFnozz0.cjs → kv-cache-Bd2z9in6.cjs} +1 -1
  32. package/dist/{kv-cache-6b2ldIo-.js → kv-cache-CFQBoGCe.js} +1 -1
  33. package/dist/{ld-C8i1kViF.js → ld-CR9Xg8mN.js} +2 -2
  34. package/dist/{middleware-DqJ1cmZE.cjs → middleware-B1XHFs0D.cjs} +8 -83
  35. package/dist/{middleware-B3GuN6Gj.js → middleware-B9frafBa.js} +8 -83
  36. package/dist/middleware-Bt5MUXQg.cjs +12 -0
  37. package/dist/{middleware-0fnsG0v7.js → middleware-ByIcAfxE.js} +11 -11
  38. package/dist/{middleware-CfL_Pd6a.js → middleware-DhlkbIaH.js} +4 -4
  39. package/dist/{middleware-B4Bgz0MJ.js → middleware-OPyIzlKI.js} +14 -89
  40. package/dist/mod-CwZXZJ9d.d.ts +91 -0
  41. package/dist/mod-DPkRU3EK.d.cts +266 -0
  42. package/dist/mod-DUWcVv49.d.ts +268 -0
  43. package/dist/mod-DVwHUI_x.d.cts +80 -0
  44. package/dist/mod-DXsQakeS.d.cts +89 -0
  45. package/dist/mod-Di3W5OdP.d.cts +62 -0
  46. package/dist/mod-DnSsduJF.d.ts +64 -0
  47. package/dist/mod-DosD6NsG.d.ts +82 -0
  48. package/dist/mod.cjs +4 -4
  49. package/dist/mod.d.cts +9 -9
  50. package/dist/mod.d.ts +9 -9
  51. package/dist/mod.js +4 -4
  52. package/dist/nodeinfo/handler.test.js +11 -11
  53. package/dist/nodeinfo/mod.d.cts +1 -1
  54. package/dist/nodeinfo/mod.d.ts +1 -1
  55. package/dist/otel/mod.d.cts +145 -145
  56. package/dist/otel/mod.d.ts +145 -145
  57. package/dist/owner-1AbPBOOZ.d.cts +66 -0
  58. package/dist/{owner-BOSWh-ha.js → owner-DfXg2o90.js} +1 -1
  59. package/dist/owner-gd0Q9FuU.d.ts +68 -0
  60. package/dist/{proof-BeT_MFIx.js → proof-BTvHpR2_.js} +2 -2
  61. package/dist/{proof-D61EYfPl.js → proof-CNhYMIct.js} +1 -1
  62. package/dist/{proof-C8qvlfLD.cjs → proof-DnzISmKI.cjs} +1 -1
  63. package/dist/{send-D7lC06r9.js → send-DaEkUvnr.js} +2 -2
  64. package/dist/sig/http.test.js +3 -3
  65. package/dist/sig/key.test.js +2 -2
  66. package/dist/sig/ld.test.js +3 -3
  67. package/dist/sig/mod.cjs +2 -2
  68. package/dist/sig/mod.d.cts +3 -3
  69. package/dist/sig/mod.d.ts +3 -3
  70. package/dist/sig/mod.js +2 -2
  71. package/dist/sig/owner.test.js +3 -3
  72. package/dist/sig/proof.test.js +3 -3
  73. package/dist/testing/mod.d.ts +4 -23
  74. package/dist/utils/docloader.test.js +4 -4
  75. package/dist/utils/mod.cjs +2 -2
  76. package/dist/utils/mod.d.cts +3 -3
  77. package/dist/utils/mod.d.ts +3 -3
  78. package/dist/utils/mod.js +2 -2
  79. package/package.json +5 -5
  80. package/dist/client-CwkOPN13.d.cts +0 -222
  81. package/dist/client-a7NwzhA2.d.ts +0 -224
  82. package/dist/context-BdNW_8a3.d.cts +0 -2554
  83. package/dist/context-C-GVKcJR.d.ts +0 -2556
  84. package/dist/http-CCEu-x1_.d.cts +0 -253
  85. package/dist/http-CODSJcKx.d.ts +0 -255
  86. package/dist/kv-g9jFc34-.d.cts +0 -110
  87. package/dist/kv-jg_8SMc1.d.ts +0 -113
  88. package/dist/middleware-DILzU8Ot.cjs +0 -12
  89. package/dist/mod-5PNty1K9.d.cts +0 -80
  90. package/dist/mod-BcpEGTWV.d.cts +0 -62
  91. package/dist/mod-COO7VMcm.d.cts +0 -266
  92. package/dist/mod-CevNbUol.d.ts +0 -91
  93. package/dist/mod-CtO31FCx.d.ts +0 -64
  94. package/dist/mod-Da9fNDyC.d.ts +0 -82
  95. package/dist/mod-ErTjUJs9.d.cts +0 -89
  96. package/dist/mod-q2IR8UiH.d.ts +0 -268
  97. package/dist/owner-9yZ5Ibsb.d.cts +0 -66
  98. package/dist/owner-DQYAbVmX.d.ts +0 -68
@@ -0,0 +1,246 @@
1
+ import { Temporal } from "@js-temporal/polyfill";
2
+ import { URLPattern } from "urlpattern-polyfill";
3
+ import { CryptographicKey, Multikey } from "@fedify/vocab";
4
+ import { TracerProvider } from "@opentelemetry/api";
5
+ import { DocumentLoader } from "@fedify/vocab-runtime";
6
+
7
+ //#region src/sig/key.d.ts
8
+
9
+ /**
10
+ * Generates a key pair which is appropriate for Fedify.
11
+ * @param algorithm The algorithm to use. Currently only RSASSA-PKCS1-v1_5 and
12
+ * Ed25519 are supported.
13
+ * @returns The generated key pair.
14
+ * @throws {TypeError} If the algorithm is unsupported.
15
+ */
16
+ declare function generateCryptoKeyPair(algorithm?: "RSASSA-PKCS1-v1_5" | "Ed25519"): Promise<CryptoKeyPair>;
17
+ /**
18
+ * Exports a key in JWK format.
19
+ * @param key The key to export. Either public or private key.
20
+ * @returns The exported key in JWK format. The key is suitable for
21
+ * serialization and storage.
22
+ * @throws {TypeError} If the key is invalid or unsupported.
23
+ */
24
+ declare function exportJwk(key: CryptoKey): Promise<JsonWebKey>;
25
+ /**
26
+ * Imports a key from JWK format.
27
+ * @param jwk The key in JWK format.
28
+ * @param type Which type of key to import, either `"public"` or `"private"`.
29
+ * @returns The imported key.
30
+ * @throws {TypeError} If the key is invalid or unsupported.
31
+ */
32
+ declare function importJwk(jwk: JsonWebKey, type: "public" | "private"): Promise<CryptoKey>;
33
+ /**
34
+ * Options for {@link fetchKey}.
35
+ * @since 1.3.0
36
+ */
37
+ interface FetchKeyOptions {
38
+ /**
39
+ * The document loader for loading remote JSON-LD documents.
40
+ */
41
+ documentLoader?: DocumentLoader;
42
+ /**
43
+ * The context loader for loading remote JSON-LD contexts.
44
+ */
45
+ contextLoader?: DocumentLoader;
46
+ /**
47
+ * The key cache to use for caching public keys.
48
+ * @since 0.12.0
49
+ */
50
+ keyCache?: KeyCache;
51
+ /**
52
+ * The OpenTelemetry tracer provider to use for tracing. If omitted,
53
+ * the global tracer provider is used.
54
+ * @since 1.3.0
55
+ */
56
+ tracerProvider?: TracerProvider;
57
+ }
58
+ /**
59
+ * The result of {@link fetchKey}.
60
+ * @since 1.3.0
61
+ */
62
+ interface FetchKeyResult<T extends CryptographicKey | Multikey> {
63
+ /**
64
+ * The fetched (or cached) key.
65
+ */
66
+ readonly key: T & {
67
+ publicKey: CryptoKey;
68
+ } | null;
69
+ /**
70
+ * Whether the key is fetched from the cache.
71
+ */
72
+ readonly cached: boolean;
73
+ }
74
+ /**
75
+ * Fetches a {@link CryptographicKey} or {@link Multikey} from the given URL.
76
+ * If the given URL contains an {@link Actor} object, it tries to find
77
+ * the corresponding key in the `publicKey` or `assertionMethod` property.
78
+ * @template T The type of the key to fetch. Either {@link CryptographicKey}
79
+ * or {@link Multikey}.
80
+ * @param keyId The URL of the key.
81
+ * @param cls The class of the key to fetch. Either {@link CryptographicKey}
82
+ * or {@link Multikey}.
83
+ * @param options Options for fetching the key. See {@link FetchKeyOptions}.
84
+ * @returns The fetched key or `null` if the key is not found.
85
+ * @since 1.3.0
86
+ */
87
+ declare function fetchKey<T extends CryptographicKey | Multikey>(keyId: URL | string, cls: (new (...args: any[]) => T) & {
88
+ fromJsonLd(jsonLd: unknown, options: {
89
+ documentLoader?: DocumentLoader;
90
+ contextLoader?: DocumentLoader;
91
+ tracerProvider?: TracerProvider;
92
+ }): Promise<T>;
93
+ }, options?: FetchKeyOptions): Promise<FetchKeyResult<T>>;
94
+ /**
95
+ * A cache for storing cryptographic keys.
96
+ * @since 0.12.0
97
+ */
98
+ interface KeyCache {
99
+ /**
100
+ * Gets a key from the cache.
101
+ * @param keyId The key ID.
102
+ * @returns The key if found, `null` if the key is not available (e.g.,
103
+ * fetching the key was tried but failed), or `undefined`
104
+ * if the cache is not available.
105
+ */
106
+ get(keyId: URL): Promise<CryptographicKey | Multikey | null | undefined>;
107
+ /**
108
+ * Sets a key to the cache.
109
+ *
110
+ * Note that this caches unavailable keys (i.e., `null`) as well,
111
+ * and it is recommended to make unavailable keys expire after a short period.
112
+ * @param keyId The key ID.
113
+ * @param key The key to cache. `null` means the key is not available
114
+ * (e.g., fetching the key was tried but failed).
115
+ */
116
+ set(keyId: URL, key: CryptographicKey | Multikey | null): Promise<void>;
117
+ }
118
+ //#endregion
119
+ //#region src/sig/http.d.ts
120
+ /**
121
+ * The standard to use for signing and verifying HTTP signatures.
122
+ * @since 1.6.0
123
+ */
124
+ type HttpMessageSignaturesSpec = "draft-cavage-http-signatures-12" | "rfc9421";
125
+ /**
126
+ * Options for {@link signRequest}.
127
+ * @since 1.3.0
128
+ */
129
+ interface SignRequestOptions {
130
+ /**
131
+ * The HTTP message signatures specification to use for signing.
132
+ * @default `"draft-cavage-http-signatures-12"`
133
+ * @since 1.6.0
134
+ */
135
+ spec?: HttpMessageSignaturesSpec;
136
+ /**
137
+ * The current time. If not specified, the current time is used. This is
138
+ * useful for testing.
139
+ * @since 1.6.0
140
+ */
141
+ currentTime?: Temporal.Instant;
142
+ /**
143
+ * The request body as ArrayBuffer. If provided, avoids cloning the request body.
144
+ * @since 1.7.7
145
+ */
146
+ body?: ArrayBuffer | null;
147
+ /**
148
+ * The OpenTelemetry tracer provider. If omitted, the global tracer provider
149
+ * is used.
150
+ */
151
+ tracerProvider?: TracerProvider;
152
+ }
153
+ /**
154
+ * Signs a request using the given private key.
155
+ * @param request The request to sign.
156
+ * @param privateKey The private key to use for signing.
157
+ * @param keyId The key ID to use for the signature. It will be used by the
158
+ * verifier.
159
+ * @returns The signed request.
160
+ * @throws {TypeError} If the private key is invalid or unsupported.
161
+ */
162
+ declare function signRequest(request: Request, privateKey: CryptoKey, keyId: URL, options?: SignRequestOptions): Promise<Request>;
163
+ /**
164
+ * Options for {@link verifyRequest}.
165
+ */
166
+ interface VerifyRequestOptions {
167
+ /**
168
+ * The document loader to use for fetching the public key.
169
+ */
170
+ documentLoader?: DocumentLoader;
171
+ /**
172
+ * The context loader to use for JSON-LD context retrieval.
173
+ */
174
+ contextLoader?: DocumentLoader;
175
+ /**
176
+ * The time window to allow for the request date. The actual time window is
177
+ * twice the value of this option, with the current time as the center.
178
+ * Or if it is `false`, no time check is performed.
179
+ *
180
+ * An hour by default.
181
+ */
182
+ timeWindow?: Temporal.Duration | Temporal.DurationLike | false;
183
+ /**
184
+ * The current time. If not specified, the current time is used. This is
185
+ * useful for testing.
186
+ */
187
+ currentTime?: Temporal.Instant;
188
+ /**
189
+ * The key cache to use for caching public keys.
190
+ * @since 0.12.0
191
+ */
192
+ keyCache?: KeyCache;
193
+ /**
194
+ * The HTTP message signatures specification to use for verifying.
195
+ * @default `"draft-cavage-http-signatures-12"`
196
+ * @since 1.6.0
197
+ */
198
+ spec?: HttpMessageSignaturesSpec;
199
+ /**
200
+ * The OpenTelemetry tracer provider. If omitted, the global tracer provider
201
+ * is used.
202
+ * @since 1.3.0
203
+ */
204
+ tracerProvider?: TracerProvider;
205
+ }
206
+ /**
207
+ * Verifies the signature of a request.
208
+ *
209
+ * Note that this function consumes the request body, so it should not be used
210
+ * if the request body is already consumed. Consuming the request body after
211
+ * calling this function is okay, since this function clones the request
212
+ * under the hood.
213
+ *
214
+ * @param request The request to verify.
215
+ * @param options Options for verifying the request.
216
+ * @returns The public key of the verified signature, or `null` if the signature
217
+ * could not be verified.
218
+ */
219
+ declare function verifyRequest(request: Request, options?: VerifyRequestOptions): Promise<CryptographicKey | null>;
220
+ /**
221
+ * A spec determiner for HTTP Message Signatures.
222
+ * It determines the spec to use for signing requests.
223
+ * It is used for double-knocking
224
+ * (see <https://swicg.github.io/activitypub-http-signature/#how-to-upgrade-supported-versions>).
225
+ * @since 1.6.0
226
+ */
227
+ interface HttpMessageSignaturesSpecDeterminer {
228
+ /**
229
+ * Determines the spec to use for signing requests.
230
+ * @param origin The origin of the URL to make the request to.
231
+ * @returns The spec to use for signing requests.
232
+ */
233
+ determineSpec(origin: string): HttpMessageSignaturesSpec | Promise<HttpMessageSignaturesSpec>;
234
+ /**
235
+ * Remembers the successfully used spec for the given origin.
236
+ * @param origin The origin of the URL that was requested.
237
+ * @param spec The spec to remember.
238
+ */
239
+ rememberSpec(origin: string, spec: HttpMessageSignaturesSpec): void | Promise<void>;
240
+ }
241
+ /**
242
+ * The options for double-knock requests.
243
+ * @since 1.6.0
244
+ */
245
+ //#endregion
246
+ export { FetchKeyOptions, FetchKeyResult, HttpMessageSignaturesSpec, HttpMessageSignaturesSpecDeterminer, KeyCache, SignRequestOptions, VerifyRequestOptions, exportJwk, fetchKey, generateCryptoKeyPair, importJwk, signRequest, verifyRequest };
@@ -3,8 +3,8 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { deno_default } from "./deno-CIi8RNND.js";
7
- import { fetchKey, validateCryptoKey } from "./key-C7JS89OH.js";
6
+ import { deno_default } from "./deno-D-Duks4b.js";
7
+ import { fetchKey, validateCryptoKey } from "./key-DChkqRrm.js";
8
8
  import { getLogger } from "@logtape/logtape";
9
9
  import { CryptographicKey } from "@fedify/vocab";
10
10
  import { SpanStatusCode, trace } from "@opentelemetry/api";
@@ -3,7 +3,7 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { deno_default } from "./deno-CIi8RNND.js";
6
+ import { deno_default } from "./deno-D-Duks4b.js";
7
7
  import { getLogger } from "@logtape/logtape";
8
8
  import { Activity, getTypeId } from "@fedify/vocab";
9
9
  import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
@@ -3,7 +3,7 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { deno_default } from "./deno-CIi8RNND.js";
6
+ import { deno_default } from "./deno-D-Duks4b.js";
7
7
  import { getLogger } from "@logtape/logtape";
8
8
  import { CryptographicKey, Object as Object$1, isActor } from "@fedify/vocab";
9
9
  import { getDocumentLoader } from "@fedify/vocab-runtime";
@@ -0,0 +1,110 @@
1
+ //#region src/federation/kv.d.ts
2
+ /**
3
+ * A key for a key–value store. An array of one or more strings.
4
+ *
5
+ * @since 0.5.0
6
+ */
7
+ type KvKey = readonly [string] | readonly [string, ...string[]];
8
+ /**
9
+ * Additional options for setting a value in a key–value store.
10
+ *
11
+ * @since 0.5.0
12
+ */
13
+ interface KvStoreSetOptions {
14
+ /**
15
+ * The time-to-live (TTL) for the value.
16
+ */
17
+ ttl?: Temporal.Duration;
18
+ }
19
+ /**
20
+ * An entry returned by the {@link KvStore.list} method.
21
+ *
22
+ * @since 1.10.0
23
+ */
24
+ interface KvStoreListEntry {
25
+ /**
26
+ * The key of the entry.
27
+ */
28
+ readonly key: KvKey;
29
+ /**
30
+ * The value of the entry.
31
+ */
32
+ readonly value: unknown;
33
+ }
34
+ /**
35
+ * An abstract interface for a key–value store.
36
+ *
37
+ * @since 0.5.0
38
+ */
39
+ interface KvStore {
40
+ /**
41
+ * Gets the value for the given key.
42
+ * @param key The key to get the value for.
43
+ * @returns The value for the key, or `undefined` if the key does not exist.
44
+ * @template T The type of the value to get.
45
+ */
46
+ get<T = unknown>(key: KvKey): Promise<T | undefined>;
47
+ /**
48
+ * Sets the value for the given key.
49
+ * @param key The key to set the value for.
50
+ * @param value The value to set.
51
+ * @param options Additional options for setting the value.
52
+ */
53
+ set(key: KvKey, value: unknown, options?: KvStoreSetOptions): Promise<void>;
54
+ /**
55
+ * Deletes the value for the given key.
56
+ * @param key The key to delete.
57
+ */
58
+ delete(key: KvKey): Promise<void>;
59
+ /**
60
+ * Compare-and-swap (CAS) operation for the key–value store.
61
+ * @param key The key to perform the CAS operation on.
62
+ * @param expectedValue The expected value for the key.
63
+ * @param newValue The new value to set if the expected value matches.
64
+ * @param options Additional options for setting the value.
65
+ * @return `true` if the CAS operation was successful, `false` otherwise.
66
+ * @since 1.8.0
67
+ */
68
+ cas?: (key: KvKey, expectedValue: unknown, newValue: unknown, options?: KvStoreSetOptions) => Promise<boolean>;
69
+ /**
70
+ * Lists all entries in the store that match the given prefix.
71
+ * If no prefix is given, all entries are returned.
72
+ * @param prefix The prefix to filter keys by. If not specified, all entries
73
+ * are returned.
74
+ * @returns An async iterable of entries matching the prefix.
75
+ * @since 1.10.0
76
+ * @since 2.0.0 This method is now required instead of optional.
77
+ */
78
+ list(prefix?: KvKey): AsyncIterable<KvStoreListEntry>;
79
+ }
80
+ /**
81
+ * A key–value store that stores values in memory.
82
+ * Do not use this in production as it does not persist values.
83
+ *
84
+ * @since 0.5.0
85
+ */
86
+ declare class MemoryKvStore implements KvStore {
87
+ #private;
88
+ /**
89
+ * {@inheritDoc KvStore.get}
90
+ */
91
+ get<T = unknown>(key: KvKey): Promise<T | undefined>;
92
+ /**
93
+ * {@inheritDoc KvStore.set}
94
+ */
95
+ set(key: KvKey, value: unknown, options?: KvStoreSetOptions): Promise<void>;
96
+ /**
97
+ * {@inheritDoc KvStore.delete}
98
+ */
99
+ delete(key: KvKey): Promise<void>;
100
+ /**
101
+ * {@inheritDoc KvStore.cas}
102
+ */
103
+ cas(key: KvKey, expectedValue: unknown, newValue: unknown, options?: KvStoreSetOptions): Promise<boolean>;
104
+ /**
105
+ * {@inheritDoc KvStore.list}
106
+ */
107
+ list(prefix?: KvKey): AsyncIterable<KvStoreListEntry>;
108
+ }
109
+ //#endregion
110
+ export { KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MemoryKvStore };
@@ -0,0 +1,113 @@
1
+ import { Temporal } from "@js-temporal/polyfill";
2
+ import { URLPattern } from "urlpattern-polyfill";
3
+
4
+ //#region src/federation/kv.d.ts
5
+ /**
6
+ * A key for a key–value store. An array of one or more strings.
7
+ *
8
+ * @since 0.5.0
9
+ */
10
+ type KvKey = readonly [string] | readonly [string, ...string[]];
11
+ /**
12
+ * Additional options for setting a value in a key–value store.
13
+ *
14
+ * @since 0.5.0
15
+ */
16
+ interface KvStoreSetOptions {
17
+ /**
18
+ * The time-to-live (TTL) for the value.
19
+ */
20
+ ttl?: Temporal.Duration;
21
+ }
22
+ /**
23
+ * An entry returned by the {@link KvStore.list} method.
24
+ *
25
+ * @since 1.10.0
26
+ */
27
+ interface KvStoreListEntry {
28
+ /**
29
+ * The key of the entry.
30
+ */
31
+ readonly key: KvKey;
32
+ /**
33
+ * The value of the entry.
34
+ */
35
+ readonly value: unknown;
36
+ }
37
+ /**
38
+ * An abstract interface for a key–value store.
39
+ *
40
+ * @since 0.5.0
41
+ */
42
+ interface KvStore {
43
+ /**
44
+ * Gets the value for the given key.
45
+ * @param key The key to get the value for.
46
+ * @returns The value for the key, or `undefined` if the key does not exist.
47
+ * @template T The type of the value to get.
48
+ */
49
+ get<T = unknown>(key: KvKey): Promise<T | undefined>;
50
+ /**
51
+ * Sets the value for the given key.
52
+ * @param key The key to set the value for.
53
+ * @param value The value to set.
54
+ * @param options Additional options for setting the value.
55
+ */
56
+ set(key: KvKey, value: unknown, options?: KvStoreSetOptions): Promise<void>;
57
+ /**
58
+ * Deletes the value for the given key.
59
+ * @param key The key to delete.
60
+ */
61
+ delete(key: KvKey): Promise<void>;
62
+ /**
63
+ * Compare-and-swap (CAS) operation for the key–value store.
64
+ * @param key The key to perform the CAS operation on.
65
+ * @param expectedValue The expected value for the key.
66
+ * @param newValue The new value to set if the expected value matches.
67
+ * @param options Additional options for setting the value.
68
+ * @return `true` if the CAS operation was successful, `false` otherwise.
69
+ * @since 1.8.0
70
+ */
71
+ cas?: (key: KvKey, expectedValue: unknown, newValue: unknown, options?: KvStoreSetOptions) => Promise<boolean>;
72
+ /**
73
+ * Lists all entries in the store that match the given prefix.
74
+ * If no prefix is given, all entries are returned.
75
+ * @param prefix The prefix to filter keys by. If not specified, all entries
76
+ * are returned.
77
+ * @returns An async iterable of entries matching the prefix.
78
+ * @since 1.10.0
79
+ * @since 2.0.0 This method is now required instead of optional.
80
+ */
81
+ list(prefix?: KvKey): AsyncIterable<KvStoreListEntry>;
82
+ }
83
+ /**
84
+ * A key–value store that stores values in memory.
85
+ * Do not use this in production as it does not persist values.
86
+ *
87
+ * @since 0.5.0
88
+ */
89
+ declare class MemoryKvStore implements KvStore {
90
+ #private;
91
+ /**
92
+ * {@inheritDoc KvStore.get}
93
+ */
94
+ get<T = unknown>(key: KvKey): Promise<T | undefined>;
95
+ /**
96
+ * {@inheritDoc KvStore.set}
97
+ */
98
+ set(key: KvKey, value: unknown, options?: KvStoreSetOptions): Promise<void>;
99
+ /**
100
+ * {@inheritDoc KvStore.delete}
101
+ */
102
+ delete(key: KvKey): Promise<void>;
103
+ /**
104
+ * {@inheritDoc KvStore.cas}
105
+ */
106
+ cas(key: KvKey, expectedValue: unknown, newValue: unknown, options?: KvStoreSetOptions): Promise<boolean>;
107
+ /**
108
+ * {@inheritDoc KvStore.list}
109
+ */
110
+ list(prefix?: KvKey): AsyncIterable<KvStoreListEntry>;
111
+ }
112
+ //#endregion
113
+ export { KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MemoryKvStore };
@@ -3,7 +3,7 @@
3
3
  const { URLPattern } = require("urlpattern-polyfill");
4
4
 
5
5
  const require_chunk = require('./chunk-CGaQZ11T.cjs');
6
- const require_http = require('./http-BjroyS-9.cjs');
6
+ const require_http = require('./http-DGYGS8C8.cjs');
7
7
  const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
8
8
  const es_toolkit = require_chunk.__toESM(require("es-toolkit"));
9
9
  const __fedify_vocab_runtime = require_chunk.__toESM(require("@fedify/vocab-runtime"));
@@ -2,7 +2,7 @@
2
2
  import { Temporal } from "@js-temporal/polyfill";
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
 
5
- import { doubleKnock, validateCryptoKey } from "./http-CCsNu78I.js";
5
+ import { doubleKnock, validateCryptoKey } from "./http-C3ipH_7H.js";
6
6
  import { getLogger } from "@logtape/logtape";
7
7
  import { curry } from "es-toolkit";
8
8
  import { UrlError, createActivityPubRequest, getRemoteDocument, logRequest, preloadedContexts, validatePublicUrl } from "@fedify/vocab-runtime";
@@ -3,8 +3,8 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { deno_default } from "./deno-CIi8RNND.js";
7
- import { fetchKey, validateCryptoKey } from "./key-C7JS89OH.js";
6
+ import { deno_default } from "./deno-D-Duks4b.js";
7
+ import { fetchKey, validateCryptoKey } from "./key-DChkqRrm.js";
8
8
  import { getLogger } from "@logtape/logtape";
9
9
  import { Activity, CryptographicKey, Object as Object$1, getTypeId } from "@fedify/vocab";
10
10
  import { getDocumentLoader } from "@fedify/vocab-runtime";
@@ -4,10 +4,10 @@
4
4
 
5
5
  const require_chunk = require('./chunk-CGaQZ11T.cjs');
6
6
  const require_transformers = require('./transformers-3g8GZwkZ.cjs');
7
- const require_http = require('./http-BjroyS-9.cjs');
8
- const require_proof = require('./proof-C8qvlfLD.cjs');
7
+ const require_http = require('./http-DGYGS8C8.cjs');
8
+ const require_proof = require('./proof-DnzISmKI.cjs');
9
9
  const require_types = require('./types-Cd_hszr_.cjs');
10
- const require_kv_cache = require('./kv-cache-BqFnozz0.cjs');
10
+ const require_kv_cache = require('./kv-cache-Bd2z9in6.cjs');
11
11
  const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
12
12
  const __fedify_vocab = require_chunk.__toESM(require("@fedify/vocab"));
13
13
  const __opentelemetry_api = require_chunk.__toESM(require("@opentelemetry/api"));
@@ -339,7 +339,7 @@ var FederationBuilderImpl = class {
339
339
  this.collectionTypeIds = {};
340
340
  }
341
341
  async build(options) {
342
- const { FederationImpl: FederationImpl$1 } = await Promise.resolve().then(() => require("./middleware-DILzU8Ot.cjs"));
342
+ const { FederationImpl: FederationImpl$1 } = await Promise.resolve().then(() => require("./middleware-Bt5MUXQg.cjs"));
343
343
  const f = new FederationImpl$1(options);
344
344
  const trailingSlashInsensitiveValue = f.router.trailingSlashInsensitive;
345
345
  f.router = this.router.clone();
@@ -994,25 +994,7 @@ async function handleActor(request, { identifier, context: context$2, actorDispa
994
994
  return await onNotFound(request);
995
995
  }
996
996
  if (authorizePredicate != null) {
997
- let key = await context$2.getSignedKey();
998
- key = key?.clone({}, { $warning: {
999
- category: [
1000
- "fedify",
1001
- "federation",
1002
- "actor"
1003
- ],
1004
- message: "The third parameter of AuthorizePredicate is deprecated in favor of RequestContext.getSignedKey() method. The third parameter will be removed in a future release."
1005
- } }) ?? null;
1006
- let keyOwner = await context$2.getSignedKeyOwner();
1007
- keyOwner = keyOwner?.clone({}, { $warning: {
1008
- category: [
1009
- "fedify",
1010
- "federation",
1011
- "actor"
1012
- ],
1013
- message: "The fourth parameter of AuthorizePredicate is deprecated in favor of RequestContext.getSignedKeyOwner() method. The fourth parameter will be removed in a future release."
1014
- } }) ?? null;
1015
- if (!await authorizePredicate(context$2, identifier, key, keyOwner)) return await onUnauthorized(request);
997
+ if (!await authorizePredicate(context$2, identifier)) return await onUnauthorized(request);
1016
998
  }
1017
999
  const jsonLd = await actor.toJsonLd(context$2);
1018
1000
  return new Response(JSON.stringify(jsonLd), { headers: {
@@ -1032,25 +1014,7 @@ async function handleObject(request, { values, context: context$2, objectDispatc
1032
1014
  const object = await objectDispatcher(context$2, values);
1033
1015
  if (object == null) return await onNotFound(request);
1034
1016
  if (authorizePredicate != null) {
1035
- let key = await context$2.getSignedKey();
1036
- key = key?.clone({}, { $warning: {
1037
- category: [
1038
- "fedify",
1039
- "federation",
1040
- "object"
1041
- ],
1042
- message: "The third parameter of ObjectAuthorizePredicate is deprecated in favor of RequestContext.getSignedKey() method. The third parameter will be removed in a future release."
1043
- } }) ?? null;
1044
- let keyOwner = await context$2.getSignedKeyOwner();
1045
- keyOwner = keyOwner?.clone({}, { $warning: {
1046
- category: [
1047
- "fedify",
1048
- "federation",
1049
- "object"
1050
- ],
1051
- message: "The fourth parameter of ObjectAuthorizePredicate is deprecated in favor of RequestContext.getSignedKeyOwner() method. The fourth parameter will be removed in a future release."
1052
- } }) ?? null;
1053
- if (!await authorizePredicate(context$2, values, key, keyOwner)) return await onUnauthorized(request);
1017
+ if (!await authorizePredicate(context$2, values)) return await onUnauthorized(request);
1054
1018
  }
1055
1019
  const jsonLd = await object.toJsonLd(context$2);
1056
1020
  return new Response(JSON.stringify(jsonLd), { headers: {
@@ -1182,25 +1146,7 @@ async function handleCollection(request, { name, identifier, uriGetter, filter,
1182
1146
  });
1183
1147
  }
1184
1148
  if (collectionCallbacks.authorizePredicate != null) {
1185
- let key = await context$2.getSignedKey();
1186
- key = key?.clone({}, { $warning: {
1187
- category: [
1188
- "fedify",
1189
- "federation",
1190
- "collection"
1191
- ],
1192
- message: "The third parameter of AuthorizePredicate is deprecated in favor of RequestContext.getSignedKey() method. The third parameter will be removed in a future release."
1193
- } }) ?? null;
1194
- let keyOwner = await context$2.getSignedKeyOwner();
1195
- keyOwner = keyOwner?.clone({}, { $warning: {
1196
- category: [
1197
- "fedify",
1198
- "federation",
1199
- "collection"
1200
- ],
1201
- message: "The fourth parameter of AuthorizePredicate is deprecated in favor of RequestContext.getSignedKeyOwner() method. The fourth parameter will be removed in a future release."
1202
- } }) ?? null;
1203
- if (!await collectionCallbacks.authorizePredicate(context$2, identifier, key, keyOwner)) return await onUnauthorized(request);
1149
+ if (!await collectionCallbacks.authorizePredicate(context$2, identifier)) return await onUnauthorized(request);
1204
1150
  }
1205
1151
  const jsonLd = await collection.toJsonLd(context$2);
1206
1152
  return new Response(JSON.stringify(jsonLd), { headers: {
@@ -1851,28 +1797,7 @@ const verifyDefined = (callbacks) => {
1851
1797
  */
1852
1798
  const authIfNeeded = async (context$2, values, { authorizePredicate: authorize = void 0 }) => {
1853
1799
  if (authorize === void 0) return;
1854
- const key = (await context$2.getSignedKey())?.clone({}, warning.key) ?? null;
1855
- const keyOwner = (await context$2.getSignedKeyOwner())?.clone({}, warning.keyOwner) ?? null;
1856
- if (!await authorize(context$2, values, key, keyOwner)) throw new UnauthorizedError();
1857
- };
1858
- /** Warning messages for `authIfNeeded`. */
1859
- const warning = {
1860
- key: { $warning: {
1861
- category: [
1862
- "fedify",
1863
- "federation",
1864
- "collection"
1865
- ],
1866
- message: "The third parameter of AuthorizePredicate is deprecated in favor of RequestContext.getSignedKey() method. The third parameter will be removed in a future release."
1867
- } },
1868
- keyOwner: { $warning: {
1869
- category: [
1870
- "fedify",
1871
- "federation",
1872
- "collection"
1873
- ],
1874
- message: "The fourth parameter of AuthorizePredicate is deprecated in favor of RequestContext.getSignedKeyOwner() method. The fourth parameter will be removed in a future release."
1875
- } }
1800
+ if (!await authorize(context$2, values)) throw new UnauthorizedError();
1876
1801
  };
1877
1802
  /**
1878
1803
  * Appends a cursor parameter to a URL if the cursor exists.