@kubun/hub 0.17.1 → 0.17.3

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.
@@ -38,6 +38,20 @@ export type CreateRelayOptions = {
38
38
  * disable the limit for high-op-rate use.
39
39
  */
40
40
  rateLimits?: Partial<HubRateLimits>;
41
+ /**
42
+ * Max size (bytes) of a single relayed RPC request body, forwarded to
43
+ * `@enkaku/http-serve` `ServerTransport`. A body past this is rejected with
44
+ * HTTP 413 before it reaches the hub handlers. Omitted, `@kubun/hub`'s 8 MiB
45
+ * default applies (raised from the transport's own 1 MiB), so a full-scope
46
+ * merkle reconciliation of a modest graph is carried without opting in.
47
+ */
48
+ maxRequestBodySize?: number;
49
+ /**
50
+ * Max buffered bytes per server→client session, forwarded to
51
+ * `@enkaku/http-serve` `ServerTransport`. Omitted, `@kubun/hub`'s 8 MiB
52
+ * default applies (raised from the transport's own 1 MiB).
53
+ */
54
+ maxSessionBufferBytes?: number;
41
55
  retention?: RelayRetentionConfig;
42
56
  defaultRetention?: number;
43
57
  maxRetention?: number;
@@ -64,6 +78,8 @@ export type RelayInternalOptions = {
64
78
  authorize?: AuthorizeHook;
65
79
  allowedOrigin?: string | Array<string>;
66
80
  rateLimits?: Partial<HubRateLimits>;
81
+ maxRequestBodySize?: number;
82
+ maxSessionBufferBytes?: number;
67
83
  retention?: RelayRetentionConfig;
68
84
  defaultRetention?: number;
69
85
  maxRetention?: number;
@@ -11,6 +11,12 @@ const DEFAULT_RETENTION_INTERVAL_SECONDS = 3600;
11
11
  const DEFAULT_SUBSCRIPTION_RETENTION_SECONDS = 90 * 24 * 60 * 60;
12
12
  const DEFAULT_MAX_RETENTION_SECONDS = 30 * 24 * 60 * 60;
13
13
  const DEFAULT_MAX_DEPTH = 1000;
14
+ // Raised from `@enkaku/http-serve`'s own 1 MiB: a relay exists to carry sync
15
+ // frames, and a full-scope merkle reconciliation of a modest graph (~1.5 MiB
16
+ // observed) already exceeds 1 MiB. 8 MiB clears realistic reconciliations with
17
+ // headroom while still bounding a single request.
18
+ const DEFAULT_MAX_REQUEST_BODY_SIZE = 8 * 1024 * 1024;
19
+ const DEFAULT_MAX_SESSION_BUFFER_BYTES = 8 * 1024 * 1024;
14
20
  function resolveAccessRules(auth) {
15
21
  if (auth == null) return {};
16
22
  switch(auth.mode){
@@ -86,7 +92,9 @@ export async function createRelayInternal(options) {
86
92
  }
87
93
  const allowedOrigin = resolveAllowedOrigin(options.allowedOrigin);
88
94
  const transport = new ServerTransport({
89
- allowedOrigin
95
+ allowedOrigin,
96
+ maxRequestBodySize: options.maxRequestBodySize ?? DEFAULT_MAX_REQUEST_BODY_SIZE,
97
+ maxSessionBufferBytes: options.maxSessionBufferBytes ?? DEFAULT_MAX_SESSION_BUFFER_BYTES
90
98
  });
91
99
  const accessRules = resolveAccessRules(options.auth);
92
100
  // `@kumiai/hub-server` assembles the handlers, registry, and Enkaku server for
@@ -229,6 +237,8 @@ export async function createRelay(options) {
229
237
  authorize: options.authorize,
230
238
  allowedOrigin: options.allowedOrigin,
231
239
  rateLimits: options.rateLimits,
240
+ maxRequestBodySize: options.maxRequestBodySize,
241
+ maxSessionBufferBytes: options.maxSessionBufferBytes,
232
242
  retention: options.retention,
233
243
  defaultRetention: options.defaultRetention,
234
244
  maxRetention: options.maxRetention,
package/lib/index.d.ts CHANGED
@@ -36,6 +36,18 @@ export type HubOptions = {
36
36
  * Omitted, its defaults apply. See `CreateRelayOptions.rateLimits`.
37
37
  */
38
38
  rateLimits?: Partial<HubRateLimits>;
39
+ /**
40
+ * Max size (bytes) of a single relayed RPC request body, forwarded to
41
+ * `@enkaku/http-serve`. Omitted, `@kubun/hub`'s 8 MiB default applies (raised
42
+ * from the transport's own 1 MiB). See `CreateRelayOptions.maxRequestBodySize`.
43
+ */
44
+ maxRequestBodySize?: number;
45
+ /**
46
+ * Max buffered bytes per server→client session, forwarded to
47
+ * `@enkaku/http-serve`. Omitted, `@kubun/hub`'s 8 MiB default applies. See
48
+ * `CreateRelayOptions.maxSessionBufferBytes`.
49
+ */
50
+ maxSessionBufferBytes?: number;
39
51
  /** Optional retention scheduler. */
40
52
  retention?: RelayRetentionConfig;
41
53
  /** Optional observers for counters / diagnostics. */
package/lib/index.js CHANGED
@@ -15,6 +15,8 @@ export async function createHub(options) {
15
15
  auth: options.auth,
16
16
  allowedOrigin: options.allowedOrigin,
17
17
  rateLimits: options.rateLimits,
18
+ maxRequestBodySize: options.maxRequestBodySize,
19
+ maxSessionBufferBytes: options.maxSessionBufferBytes,
18
20
  retention: options.retention,
19
21
  observers: options.observers,
20
22
  ownsKysely: false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubun/hub",
3
- "version": "0.17.1",
3
+ "version": "0.17.3",
4
4
  "license": "see LICENSE.md",
5
5
  "sideEffects": false,
6
6
  "type": "module",