@c9up/ream 0.2.28 → 0.2.30

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 (293) hide show
  1. package/README.md +5 -6
  2. package/dist/Codemods.d.ts +24 -0
  3. package/dist/Codemods.d.ts.map +1 -1
  4. package/dist/Codemods.js +211 -1
  5. package/dist/Codemods.js.map +1 -1
  6. package/dist/HttpKernel.d.ts.map +1 -1
  7. package/dist/HttpKernel.js +17 -5
  8. package/dist/HttpKernel.js.map +1 -1
  9. package/dist/Ignitor.d.ts +15 -2
  10. package/dist/Ignitor.d.ts.map +1 -1
  11. package/dist/Ignitor.js +33 -23
  12. package/dist/Ignitor.js.map +1 -1
  13. package/dist/bodyparser/BodyParserMiddleware.d.ts +4 -4
  14. package/dist/bodyparser/BodyParserMiddleware.d.ts.map +1 -1
  15. package/dist/bodyparser/BodyParserMiddleware.js +41 -11
  16. package/dist/bodyparser/BodyParserMiddleware.js.map +1 -1
  17. package/dist/bodyparser/MultipartFile.d.ts +21 -15
  18. package/dist/bodyparser/MultipartFile.d.ts.map +1 -1
  19. package/dist/bodyparser/MultipartFile.js +40 -58
  20. package/dist/bodyparser/MultipartFile.js.map +1 -1
  21. package/dist/bodyparser/parseSize.d.ts +7 -4
  22. package/dist/bodyparser/parseSize.d.ts.map +1 -1
  23. package/dist/bodyparser/parseSize.js +12 -17
  24. package/dist/bodyparser/parseSize.js.map +1 -1
  25. package/dist/bodyparser/qsParse.d.ts +20 -1
  26. package/dist/bodyparser/qsParse.d.ts.map +1 -1
  27. package/dist/bodyparser/qsParse.js +78 -25
  28. package/dist/bodyparser/qsParse.js.map +1 -1
  29. package/dist/codemods/source.d.ts +57 -0
  30. package/dist/codemods/source.d.ts.map +1 -0
  31. package/dist/codemods/source.js +282 -0
  32. package/dist/codemods/source.js.map +1 -0
  33. package/dist/console/prompts.d.ts.map +1 -1
  34. package/dist/console/prompts.js +3 -1
  35. package/dist/console/prompts.js.map +1 -1
  36. package/dist/container/Container.d.ts.map +1 -1
  37. package/dist/container/Container.js +61 -71
  38. package/dist/container/Container.js.map +1 -1
  39. package/dist/events/Emitter.d.ts +12 -0
  40. package/dist/events/Emitter.d.ts.map +1 -1
  41. package/dist/events/Emitter.js +36 -9
  42. package/dist/events/Emitter.js.map +1 -1
  43. package/dist/events/helix/helpers.d.ts.map +1 -1
  44. package/dist/events/helix/helpers.js +19 -9
  45. package/dist/events/helix/helpers.js.map +1 -1
  46. package/dist/graphql/GraphQLEngine.d.ts +8 -0
  47. package/dist/graphql/GraphQLEngine.d.ts.map +1 -1
  48. package/dist/graphql/GraphQLEngine.js +79 -12
  49. package/dist/graphql/GraphQLEngine.js.map +1 -1
  50. package/dist/helpers/MessageBuilder.d.ts +4 -2
  51. package/dist/helpers/MessageBuilder.d.ts.map +1 -1
  52. package/dist/helpers/MessageBuilder.js +4 -2
  53. package/dist/helpers/MessageBuilder.js.map +1 -1
  54. package/dist/helpers/errors.d.ts +11 -0
  55. package/dist/helpers/errors.d.ts.map +1 -0
  56. package/dist/helpers/errors.js +17 -0
  57. package/dist/helpers/errors.js.map +1 -0
  58. package/dist/helpers/napi-loader.d.ts.map +1 -1
  59. package/dist/helpers/napi-loader.js +3 -2
  60. package/dist/helpers/napi-loader.js.map +1 -1
  61. package/dist/http/Exception.d.ts +14 -1
  62. package/dist/http/Exception.d.ts.map +1 -1
  63. package/dist/http/Exception.js +10 -2
  64. package/dist/http/Exception.js.map +1 -1
  65. package/dist/http/HttpContext.d.ts +31 -2
  66. package/dist/http/HttpContext.d.ts.map +1 -1
  67. package/dist/http/HttpContext.js +12 -5
  68. package/dist/http/HttpContext.js.map +1 -1
  69. package/dist/http/RedirectBuilder.d.ts +9 -3
  70. package/dist/http/RedirectBuilder.d.ts.map +1 -1
  71. package/dist/http/RedirectBuilder.js +43 -37
  72. package/dist/http/RedirectBuilder.js.map +1 -1
  73. package/dist/http/Request.d.ts +42 -17
  74. package/dist/http/Request.d.ts.map +1 -1
  75. package/dist/http/Request.js +80 -58
  76. package/dist/http/Request.js.map +1 -1
  77. package/dist/http/Response.d.ts +7 -4
  78. package/dist/http/Response.d.ts.map +1 -1
  79. package/dist/http/Response.js +14 -6
  80. package/dist/http/Response.js.map +1 -1
  81. package/dist/http/SseStream.js +6 -7
  82. package/dist/http/SseStream.js.map +1 -1
  83. package/dist/http/permissions.d.ts +25 -0
  84. package/dist/http/permissions.d.ts.map +1 -0
  85. package/dist/http/permissions.js +38 -0
  86. package/dist/http/permissions.js.map +1 -0
  87. package/dist/http-client/HttpClient.d.ts +111 -0
  88. package/dist/http-client/HttpClient.d.ts.map +1 -0
  89. package/dist/http-client/HttpClient.js +386 -0
  90. package/dist/http-client/HttpClient.js.map +1 -0
  91. package/dist/http-client/addresses.d.ts +14 -0
  92. package/dist/http-client/addresses.d.ts.map +1 -0
  93. package/dist/http-client/addresses.js +57 -0
  94. package/dist/http-client/addresses.js.map +1 -0
  95. package/dist/http-client/fake.d.ts +50 -0
  96. package/dist/http-client/fake.d.ts.map +1 -0
  97. package/dist/http-client/fake.js +95 -0
  98. package/dist/http-client/fake.js.map +1 -0
  99. package/dist/http-client/index.d.ts +7 -0
  100. package/dist/http-client/index.d.ts.map +1 -0
  101. package/dist/http-client/index.js +7 -0
  102. package/dist/http-client/index.js.map +1 -0
  103. package/dist/index.d.ts +4 -3
  104. package/dist/index.d.ts.map +1 -1
  105. package/dist/index.js +1 -1
  106. package/dist/index.js.map +1 -1
  107. package/dist/middleware/Pipeline.d.ts.map +1 -1
  108. package/dist/middleware/Pipeline.js +6 -3
  109. package/dist/middleware/Pipeline.js.map +1 -1
  110. package/dist/native/generated.d.ts +93 -36
  111. package/dist/native/generated.d.ts.map +1 -1
  112. package/dist/profiler/Profiler.d.ts.map +1 -1
  113. package/dist/profiler/Profiler.js +4 -1
  114. package/dist/profiler/Profiler.js.map +1 -1
  115. package/dist/profiler/client.generated.d.ts +5 -0
  116. package/dist/profiler/client.generated.d.ts.map +1 -0
  117. package/dist/profiler/client.generated.js +6 -0
  118. package/dist/profiler/client.generated.js.map +1 -0
  119. package/dist/profiler/collectors.d.ts +92 -13
  120. package/dist/profiler/collectors.d.ts.map +1 -1
  121. package/dist/profiler/collectors.js +106 -19
  122. package/dist/profiler/collectors.js.map +1 -1
  123. package/dist/profiler/endpoint.d.ts +2 -1
  124. package/dist/profiler/endpoint.d.ts.map +1 -1
  125. package/dist/profiler/endpoint.js +25 -1
  126. package/dist/profiler/endpoint.js.map +1 -1
  127. package/dist/profiler/index.d.ts +8 -4
  128. package/dist/profiler/index.d.ts.map +1 -1
  129. package/dist/profiler/index.js +11 -4
  130. package/dist/profiler/index.js.map +1 -1
  131. package/dist/profiler/middleware.d.ts.map +1 -1
  132. package/dist/profiler/middleware.js +76 -10
  133. package/dist/profiler/middleware.js.map +1 -1
  134. package/dist/profiler/preview.d.ts +17 -0
  135. package/dist/profiler/preview.d.ts.map +1 -0
  136. package/dist/profiler/preview.js +100 -0
  137. package/dist/profiler/preview.js.map +1 -0
  138. package/dist/profiler/toolbar.d.ts +15 -23
  139. package/dist/profiler/toolbar.d.ts.map +1 -1
  140. package/dist/profiler/toolbar.js +25 -91
  141. package/dist/profiler/toolbar.js.map +1 -1
  142. package/dist/profiler/types.d.ts +6 -1
  143. package/dist/profiler/types.d.ts.map +1 -1
  144. package/dist/router/Router.d.ts +6 -0
  145. package/dist/router/Router.d.ts.map +1 -1
  146. package/dist/router/Router.js +115 -12
  147. package/dist/router/Router.js.map +1 -1
  148. package/dist/rpc/RpcProvider.d.ts +6 -0
  149. package/dist/rpc/RpcProvider.d.ts.map +1 -1
  150. package/dist/rpc/RpcProvider.js +4 -1
  151. package/dist/rpc/RpcProvider.js.map +1 -1
  152. package/dist/rpc/RpcRouter.d.ts +27 -14
  153. package/dist/rpc/RpcRouter.d.ts.map +1 -1
  154. package/dist/rpc/RpcRouter.js +97 -40
  155. package/dist/rpc/RpcRouter.js.map +1 -1
  156. package/dist/scheduler/Scheduler.js +1 -1
  157. package/dist/scheduler/Scheduler.js.map +1 -1
  158. package/dist/scheduler/locks/RedisLockBackend.d.ts.map +1 -1
  159. package/dist/scheduler/locks/RedisLockBackend.js +13 -2
  160. package/dist/scheduler/locks/RedisLockBackend.js.map +1 -1
  161. package/dist/security/CookieSigner.d.ts.map +1 -1
  162. package/dist/security/CookieSigner.js +32 -8
  163. package/dist/security/CookieSigner.js.map +1 -1
  164. package/dist/security/SignedUrl.d.ts.map +1 -1
  165. package/dist/security/SignedUrl.js +16 -19
  166. package/dist/security/SignedUrl.js.map +1 -1
  167. package/dist/server/Server.d.ts +44 -12
  168. package/dist/server/Server.d.ts.map +1 -1
  169. package/dist/server/Server.js +31 -10
  170. package/dist/server/Server.js.map +1 -1
  171. package/dist/server/nativeGrpc.d.ts +27 -0
  172. package/dist/server/nativeGrpc.d.ts.map +1 -0
  173. package/dist/server/nativeGrpc.js +47 -0
  174. package/dist/server/nativeGrpc.js.map +1 -0
  175. package/dist/server/nativeLimits.d.ts +57 -0
  176. package/dist/server/nativeLimits.d.ts.map +1 -0
  177. package/dist/server/nativeLimits.js +75 -0
  178. package/dist/server/nativeLimits.js.map +1 -0
  179. package/dist/session/Session.d.ts +12 -0
  180. package/dist/session/Session.d.ts.map +1 -1
  181. package/dist/session/Session.js +13 -4
  182. package/dist/session/Session.js.map +1 -1
  183. package/dist/session/SessionMiddleware.d.ts.map +1 -1
  184. package/dist/session/SessionMiddleware.js +28 -9
  185. package/dist/session/SessionMiddleware.js.map +1 -1
  186. package/dist/session/config.d.ts +5 -0
  187. package/dist/session/config.d.ts.map +1 -1
  188. package/dist/session/config.js +8 -0
  189. package/dist/session/config.js.map +1 -1
  190. package/dist/session/drivers/MemoryDriver.d.ts.map +1 -1
  191. package/dist/session/drivers/MemoryDriver.js +26 -7
  192. package/dist/session/drivers/MemoryDriver.js.map +1 -1
  193. package/dist/session/errors.d.ts +17 -0
  194. package/dist/session/errors.d.ts.map +1 -1
  195. package/dist/session/errors.js +21 -0
  196. package/dist/session/errors.js.map +1 -1
  197. package/dist/session/templateTags.d.ts +14 -0
  198. package/dist/session/templateTags.d.ts.map +1 -1
  199. package/dist/session/templateTags.js +45 -17
  200. package/dist/session/templateTags.js.map +1 -1
  201. package/dist/storage/StaticMiddleware.d.ts.map +1 -1
  202. package/dist/storage/StaticMiddleware.js +49 -27
  203. package/dist/storage/StaticMiddleware.js.map +1 -1
  204. package/dist/testing/ApiResponse.d.ts.map +1 -1
  205. package/dist/testing/ApiResponse.js +7 -1
  206. package/dist/testing/ApiResponse.js.map +1 -1
  207. package/dist/testing/TestClient.d.ts.map +1 -1
  208. package/dist/testing/TestClient.js +16 -4
  209. package/dist/testing/TestClient.js.map +1 -1
  210. package/dist/utils/Macroable.d.ts +1 -1
  211. package/dist/utils/Macroable.js +2 -2
  212. package/dist/utils/Macroable.js.map +1 -1
  213. package/events.darwin-arm64.node +0 -0
  214. package/events.darwin-x64.node +0 -0
  215. package/events.linux-arm64-gnu.node +0 -0
  216. package/events.linux-x64-gnu.node +0 -0
  217. package/events.win32-x64-msvc.node +0 -0
  218. package/index.darwin-arm64.node +0 -0
  219. package/index.darwin-x64.node +0 -0
  220. package/index.linux-arm64-gnu.node +0 -0
  221. package/index.linux-x64-gnu.node +0 -0
  222. package/index.win32-x64-msvc.node +0 -0
  223. package/package.json +11 -3
  224. package/scheduler.darwin-arm64.node +0 -0
  225. package/scheduler.darwin-x64.node +0 -0
  226. package/scheduler.linux-arm64-gnu.node +0 -0
  227. package/scheduler.linux-x64-gnu.node +0 -0
  228. package/scheduler.win32-x64-msvc.node +0 -0
  229. package/src/Codemods.ts +314 -3
  230. package/src/HttpKernel.ts +18 -7
  231. package/src/Ignitor.ts +58 -26
  232. package/src/bodyparser/BodyParserMiddleware.ts +45 -16
  233. package/src/bodyparser/MultipartFile.ts +46 -67
  234. package/src/bodyparser/parseSize.ts +17 -17
  235. package/src/bodyparser/qsParse.ts +96 -26
  236. package/src/codemods/source.ts +303 -0
  237. package/src/console/prompts.ts +3 -1
  238. package/src/container/Container.ts +97 -81
  239. package/src/events/Emitter.ts +37 -10
  240. package/src/events/helix/helpers.ts +24 -19
  241. package/src/graphql/GraphQLEngine.ts +91 -14
  242. package/src/helpers/MessageBuilder.ts +4 -2
  243. package/src/helpers/errors.ts +16 -0
  244. package/src/helpers/napi-loader.ts +3 -2
  245. package/src/http/Exception.ts +17 -2
  246. package/src/http/HttpContext.ts +34 -5
  247. package/src/http/RedirectBuilder.ts +51 -37
  248. package/src/http/Request.ts +102 -58
  249. package/src/http/Response.ts +15 -7
  250. package/src/http/SseStream.ts +6 -7
  251. package/src/http/permissions.ts +47 -0
  252. package/src/http-client/HttpClient.ts +505 -0
  253. package/src/http-client/addresses.ts +58 -0
  254. package/src/http-client/fake.ts +141 -0
  255. package/src/http-client/index.ts +21 -0
  256. package/src/index.ts +6 -1
  257. package/src/middleware/Pipeline.ts +7 -3
  258. package/src/native/generated.ts +106 -48
  259. package/src/profiler/Profiler.ts +4 -1
  260. package/src/profiler/client/toolbar.css +595 -0
  261. package/src/profiler/client/toolbar.js +1299 -0
  262. package/src/profiler/client.generated.ts +7 -0
  263. package/src/profiler/collectors.ts +156 -19
  264. package/src/profiler/endpoint.ts +27 -1
  265. package/src/profiler/index.ts +17 -3
  266. package/src/profiler/middleware.ts +74 -9
  267. package/src/profiler/preview.ts +104 -0
  268. package/src/profiler/toolbar.ts +28 -91
  269. package/src/profiler/types.ts +6 -1
  270. package/src/router/Router.ts +136 -13
  271. package/src/rpc/RpcProvider.ts +10 -1
  272. package/src/rpc/RpcRouter.ts +129 -45
  273. package/src/scheduler/Scheduler.ts +1 -1
  274. package/src/scheduler/locks/RedisLockBackend.ts +12 -4
  275. package/src/security/CookieSigner.ts +30 -8
  276. package/src/security/SignedUrl.ts +18 -17
  277. package/src/server/Server.ts +60 -12
  278. package/src/server/nativeGrpc.ts +59 -0
  279. package/src/server/nativeLimits.ts +111 -0
  280. package/src/session/Session.ts +29 -4
  281. package/src/session/SessionMiddleware.ts +30 -10
  282. package/src/session/config.ts +7 -0
  283. package/src/session/drivers/MemoryDriver.ts +26 -7
  284. package/src/session/errors.ts +31 -0
  285. package/src/session/templateTags.ts +57 -0
  286. package/src/storage/StaticMiddleware.ts +46 -27
  287. package/src/testing/ApiResponse.ts +7 -1
  288. package/src/testing/TestClient.ts +14 -5
  289. package/src/utils/Macroable.ts +2 -2
  290. package/scripts/build-napi-types.mjs +0 -69
  291. package/scripts/copy-napi.mjs +0 -121
  292. package/scripts/generate-mime.mjs +0 -119
  293. package/scripts/generate-napi-types.mjs +0 -187
@@ -0,0 +1,21 @@
1
+ /**
2
+ * `@c9up/ream/http-client` — outbound HTTP with an SSRF guard, and its test fake.
3
+ */
4
+
5
+ export { isPublicAddress } from './addresses.js'
6
+ export {
7
+ FakeHttpClient,
8
+ type FakeMatcher,
9
+ type FakeResponse,
10
+ fakeHttp,
11
+ type RecordedRequest,
12
+ } from './fake.js'
13
+ export {
14
+ HttpClient,
15
+ HttpClientError,
16
+ type HttpClientFailure,
17
+ type HttpClientOptions,
18
+ type HttpRequestOptions,
19
+ HttpResponse,
20
+ type OutgoingRequest,
21
+ } from './HttpClient.js'
package/src/index.ts CHANGED
@@ -219,10 +219,12 @@ export { createHttpKernel } from './HttpKernel.js'
219
219
 
220
220
  // ─── Server ─────────────────────────────────────────────────
221
221
 
222
+ export type { NativeGrpcCall, NativeGrpcHandler } from './server/nativeGrpc.js'
222
223
  export type {
223
224
  ErrorHandlerClass,
224
225
  GrpcCall,
225
226
  GrpcHandler,
227
+ GrpcLimits,
226
228
  GrpcReply,
227
229
  LazyImport,
228
230
  MiddlewareClass,
@@ -285,7 +287,10 @@ export type {
285
287
  export {
286
288
  type Codemods,
287
289
  createCodemods,
290
+ type EnvValidationNode,
288
291
  type GeneratedStub,
292
+ type MiddlewarePosition,
293
+ type PreloadEnvironment,
289
294
  type StubState,
290
295
  } from './Codemods.js'
291
296
  export {
@@ -409,4 +414,4 @@ export {
409
414
  StatsTracker,
410
415
  } from './scheduler/index.js'
411
416
 
412
- export const VERSION = '0.2.28'
417
+ export const VERSION = '0.2.30'
@@ -15,6 +15,7 @@ import { debugHttp } from '../debug.js'
15
15
  import { ReamError } from '../errors/ReamError.js'
16
16
  import { E_FORBIDDEN, E_UNAUTHORIZED, E_VALIDATION_ERROR } from '../http/Exception.js'
17
17
  import type { HttpContext } from '../http/HttpContext.js'
18
+ import { holdsPermissions } from '../http/permissions.js'
18
19
 
19
20
  export type MiddlewareFunction = (
20
21
  ctx: HttpContext,
@@ -96,7 +97,10 @@ export async function runValidator(
96
97
  }
97
98
  }
98
99
 
99
- throw new TypeError(
100
+ // A dedicated code, not a TypeError: callers tell this configuration
101
+ // mistake apart from a TypeError raised by a bug inside a rule.
102
+ throw new ReamError(
103
+ 'E_VALIDATOR_UNUSABLE',
100
104
  'Route validator exposes none of validateResultAsync(), validateResult() or validate().',
101
105
  )
102
106
  }
@@ -239,9 +243,9 @@ function createGuardMiddleware(
239
243
  }
240
244
  }
241
245
 
246
+ // A token-authenticated request also needs the token to allow each one.
242
247
  if (permissions && permissions.length > 0) {
243
- const userPerms = ctx.auth.permissions ?? ctx.auth.user?.permissions ?? []
244
- if (!permissions.every((p) => userPerms.includes(p))) {
248
+ if (!(await holdsPermissions(ctx.auth, permissions))) {
245
249
  throw new E_FORBIDDEN('Insufficient permissions', permissions)
246
250
  }
247
251
  }
@@ -31,10 +31,18 @@ export interface NapiResponse {
31
31
  */
32
32
 
33
33
  export interface NapiGrpcCall {
34
+ /**
35
+ * This call, in the ids `onGrpcCancel` reports. Increasing, in the order
36
+ * the calls reach JavaScript.
37
+ */
38
+ id: number
34
39
  /** `/package.Service/Method`. */
35
40
  path: string
36
- /** Request metadata, header names lowercased. */
37
- metadata: Record<string, string>
41
+ /**
42
+ * Request metadata: the request headers, every value of a repeated one
43
+ * in order, names lowercased.
44
+ */
45
+ metadata: Record<string, Array<string>>
38
46
  /** The request message, still encoded. */
39
47
  message: Uint8Array
40
48
  /** Resolved client IP, by the same trusted-proxy rules as `request.ip`. */
@@ -52,6 +60,16 @@ export interface NapiGrpcReply {
52
60
  details?: string
53
61
  }
54
62
 
63
+ /**
64
+ * Message size bounds of the gRPC calls, in bytes; `-1` for none. Omitted:
65
+ * 4 MiB received, no bound sent.
66
+ */
67
+
68
+ export interface NapiGrpcLimits {
69
+ maxReceiveMessageLength?: number
70
+ maxSendMessageLength?: number
71
+ }
72
+
55
73
  /**
56
74
  * Configuration for the wire-level shield filter. Mirrors the Rust
57
75
  * `ShieldConfig` shape; the JS layer constructs it from `ShieldMiddleware`
@@ -74,6 +92,58 @@ export interface NapiRateLimitConfig {
74
92
  windowSecs: number
75
93
  }
76
94
 
95
+ /**
96
+ * The limit of one body parser and the content types it claims. `limit` is
97
+ * in bytes; an omitted field keeps the default.
98
+ */
99
+
100
+ export interface NapiBodyLimit {
101
+ limit?: number
102
+ types?: Array<string>
103
+ }
104
+
105
+ /**
106
+ * Request-body limits per content type, the body parser's sections. Each
107
+ * omitted section keeps the `@adonisjs/bodyparser` default: json, form and
108
+ * raw (`text/*`) 1 MB, multipart 20 MB. A content type no section claims
109
+ * gets the raw limit.
110
+ */
111
+
112
+ export interface NapiBodyLimits {
113
+ json?: NapiBodyLimit
114
+ form?: NapiBodyLimit
115
+ raw?: NapiBodyLimit
116
+ multipart?: NapiMultipartLimit
117
+ }
118
+
119
+ /**
120
+ * The multipart section: its size limit and types, and how many fields
121
+ * and files a body may carry (default 1000 each), enforced while the body
122
+ * is parsed.
123
+ */
124
+
125
+ export interface NapiMultipartLimit {
126
+ limit?: number
127
+ types?: Array<string>
128
+ maxFields?: number
129
+ maxFiles?: number
130
+ }
131
+
132
+ /**
133
+ * Timeouts (milliseconds) and the connection cap, named after the Node
134
+ * `http.Server` settings an Adonis app configures. `0` disables a bound;
135
+ * an omitted field keeps the default: `headersTimeout` 60 000,
136
+ * `requestTimeout` 300 000, `keepAliveTimeout` 5 000, `maxConnections`
137
+ * 10 000.
138
+ */
139
+
140
+ export interface NapiConnectionConfig {
141
+ headersTimeout?: number
142
+ requestTimeout?: number
143
+ keepAliveTimeout?: number
144
+ maxConnections?: number
145
+ }
146
+
77
147
  /**
78
148
  * NAPI-exposed event bus.
79
149
  * Uses shared Tokio runtime (no per-instance runtime).
@@ -111,9 +181,10 @@ export declare class EventBus {
111
181
 
112
182
  export declare class HyperServer {
113
183
  /**
114
- * `host` is the bind address: an IPv4 literal (`0.0.0.0` to accept from
115
- * every interface) or the `localhost` alias. Omitted → loopback only,
116
- * the safe default for a dev machine.
184
+ * `host` is the bind address: an IPv4 or IPv6 literal (`0.0.0.0` or `::`
185
+ * to accept from every interface, a bracketed `[::1]` too) or the
186
+ * `localhost` alias. Omitted → loopback only, the safe default for a dev
187
+ * machine.
117
188
  */
118
189
  constructor(port?: number | undefined | null, host?: string | undefined | null)
119
190
  /**
@@ -130,15 +201,40 @@ export declare class HyperServer {
130
201
  * HTTP requests. Must be called BEFORE `listen()`.
131
202
  *
132
203
  * A rejected promise is answered `INTERNAL`, with nothing of the error
133
- * sent to the client.
204
+ * sent to the client. `limits` bounds the request and reply messages;
205
+ * a request is read, and refused, before the handler is called.
206
+ */
207
+ onGrpc(
208
+ callback: (arg: NapiGrpcCall) => Promise<NapiGrpcReply>,
209
+ limits?: NapiGrpcLimits | undefined | null,
210
+ ): void
211
+ /**
212
+ * Register the function told, with its `id`, about a gRPC call the
213
+ * client gave up on — a reset stream or a closed connection — before the
214
+ * handler answered. A cancel can reach JavaScript before its call does.
134
215
  */
135
- onGrpc(callback: (arg: NapiGrpcCall) => Promise<NapiGrpcReply>): void
216
+ onGrpcCancel(callback: (arg: number) => void): void
136
217
  /**
137
- * Configure the trusted-proxy CIDR list used by `request.ip` resolution.
138
- * Must be called BEFORE `listen()`. Empty list = legacy permissive mode
139
- * (any peer can populate `X-Forwarded-For`).
218
+ * Configure the trusted proxies used by `request.ip` / `request.ips`
219
+ * resolution. Must be called BEFORE `listen()`. Entries are addresses,
220
+ * CIDR ranges (IPv4 or IPv6), IPv4 netmask ranges, the named ranges
221
+ * `loopback` / `linklocal` / `uniquelocal`, or `"*"` (trust every hop).
222
+ * Empty list (the default) = `X-Forwarded-For` ignored, the socket peer
223
+ * is the client. Throws on an entry that is none of these.
140
224
  */
141
225
  configureTrustedProxies(cidrs: Array<string>): void
226
+ /**
227
+ * Configure the request-body limits, applied while the body is read:
228
+ * nothing past a limit is kept, and the request reaches JS without its
229
+ * body and with `bodyTooLarge` set, for the body parser to answer 413
230
+ * once the route is known. Must be called BEFORE `listen()`.
231
+ */
232
+ configureBodyLimits(config: NapiBodyLimits): void
233
+ /**
234
+ * Configure the header / body / keep-alive timeouts and the connection
235
+ * cap. Must be called BEFORE `listen()`.
236
+ */
237
+ configureConnections(config: NapiConnectionConfig): void
142
238
  /**
143
239
  * Install (or replace) the wire-level rate limiter. Pass `None` to
144
240
  * disable. Must be called BEFORE `listen()`.
@@ -254,44 +350,6 @@ export declare class RustScheduler {
254
350
  nextRun(name: string): number | null
255
351
  }
256
352
 
257
- /**
258
- * Sign a JWT payload with HMAC-SHA256 (Rust-native).
259
- * Returns the complete JWT token string.
260
- */
261
-
262
- export declare function jwtSign(payload: string, secret: string): string
263
-
264
- /**
265
- * Verify a JWT token and return the decoded payload JSON string.
266
- * Validates signature (constant-time), exp, and nbf claims.
267
- */
268
-
269
- export declare function jwtVerify(token: string, secret: string): string
270
-
271
- /**
272
- * Hash a password with Argon2id (Rust-native).
273
- * Returns the PHC-formatted hash string.
274
- */
275
-
276
- export declare function argon2Hash(password: string): string
277
-
278
- /** Verify a password against an Argon2id hash. */
279
-
280
- export declare function argon2Verify(password: string, hash: string): boolean
281
-
282
- /**
283
- * Hash a password with bcrypt (Rust-native).
284
- * `rounds` defaults to 12 when not supplied — matches the previous
285
- * warden-engine default and the OWASP-recommended cost floor enforced
286
- * by `sigil-engine`.
287
- */
288
-
289
- export declare function bcryptHash(password: string, rounds?: number | undefined | null): string
290
-
291
- /** Verify a password against a bcrypt hash. */
292
-
293
- export declare function bcryptVerify(password: string, hash: string): boolean
294
-
295
353
  /** Constant-time string comparison. */
296
354
 
297
355
  export declare function constantTimeEq(a: string, b: string): boolean
@@ -68,7 +68,10 @@ export class Profiler {
68
68
  const token = newToken()
69
69
  const startedAt = Date.now()
70
70
  const started = performance.now()
71
- const active: ActiveProfile = { scope: { token, startedAt }, bags: new Map() }
71
+ const active: ActiveProfile = {
72
+ scope: { token, startedAt, elapsed: () => performance.now() - started },
73
+ bags: new Map(),
74
+ }
72
75
 
73
76
  for (const collector of this.#collectors) {
74
77
  // A collector that throws while starting must not fail the request it was