@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.
- package/README.md +5 -6
- package/dist/Codemods.d.ts +24 -0
- package/dist/Codemods.d.ts.map +1 -1
- package/dist/Codemods.js +211 -1
- package/dist/Codemods.js.map +1 -1
- package/dist/HttpKernel.d.ts.map +1 -1
- package/dist/HttpKernel.js +17 -5
- package/dist/HttpKernel.js.map +1 -1
- package/dist/Ignitor.d.ts +15 -2
- package/dist/Ignitor.d.ts.map +1 -1
- package/dist/Ignitor.js +33 -23
- package/dist/Ignitor.js.map +1 -1
- package/dist/bodyparser/BodyParserMiddleware.d.ts +4 -4
- package/dist/bodyparser/BodyParserMiddleware.d.ts.map +1 -1
- package/dist/bodyparser/BodyParserMiddleware.js +41 -11
- package/dist/bodyparser/BodyParserMiddleware.js.map +1 -1
- package/dist/bodyparser/MultipartFile.d.ts +21 -15
- package/dist/bodyparser/MultipartFile.d.ts.map +1 -1
- package/dist/bodyparser/MultipartFile.js +40 -58
- package/dist/bodyparser/MultipartFile.js.map +1 -1
- package/dist/bodyparser/parseSize.d.ts +7 -4
- package/dist/bodyparser/parseSize.d.ts.map +1 -1
- package/dist/bodyparser/parseSize.js +12 -17
- package/dist/bodyparser/parseSize.js.map +1 -1
- package/dist/bodyparser/qsParse.d.ts +20 -1
- package/dist/bodyparser/qsParse.d.ts.map +1 -1
- package/dist/bodyparser/qsParse.js +78 -25
- package/dist/bodyparser/qsParse.js.map +1 -1
- package/dist/codemods/source.d.ts +57 -0
- package/dist/codemods/source.d.ts.map +1 -0
- package/dist/codemods/source.js +282 -0
- package/dist/codemods/source.js.map +1 -0
- package/dist/console/prompts.d.ts.map +1 -1
- package/dist/console/prompts.js +3 -1
- package/dist/console/prompts.js.map +1 -1
- package/dist/container/Container.d.ts.map +1 -1
- package/dist/container/Container.js +61 -71
- package/dist/container/Container.js.map +1 -1
- package/dist/events/Emitter.d.ts +12 -0
- package/dist/events/Emitter.d.ts.map +1 -1
- package/dist/events/Emitter.js +36 -9
- package/dist/events/Emitter.js.map +1 -1
- package/dist/events/helix/helpers.d.ts.map +1 -1
- package/dist/events/helix/helpers.js +19 -9
- package/dist/events/helix/helpers.js.map +1 -1
- package/dist/graphql/GraphQLEngine.d.ts +8 -0
- package/dist/graphql/GraphQLEngine.d.ts.map +1 -1
- package/dist/graphql/GraphQLEngine.js +79 -12
- package/dist/graphql/GraphQLEngine.js.map +1 -1
- package/dist/helpers/MessageBuilder.d.ts +4 -2
- package/dist/helpers/MessageBuilder.d.ts.map +1 -1
- package/dist/helpers/MessageBuilder.js +4 -2
- package/dist/helpers/MessageBuilder.js.map +1 -1
- package/dist/helpers/errors.d.ts +11 -0
- package/dist/helpers/errors.d.ts.map +1 -0
- package/dist/helpers/errors.js +17 -0
- package/dist/helpers/errors.js.map +1 -0
- package/dist/helpers/napi-loader.d.ts.map +1 -1
- package/dist/helpers/napi-loader.js +3 -2
- package/dist/helpers/napi-loader.js.map +1 -1
- package/dist/http/Exception.d.ts +14 -1
- package/dist/http/Exception.d.ts.map +1 -1
- package/dist/http/Exception.js +10 -2
- package/dist/http/Exception.js.map +1 -1
- package/dist/http/HttpContext.d.ts +31 -2
- package/dist/http/HttpContext.d.ts.map +1 -1
- package/dist/http/HttpContext.js +12 -5
- package/dist/http/HttpContext.js.map +1 -1
- package/dist/http/RedirectBuilder.d.ts +9 -3
- package/dist/http/RedirectBuilder.d.ts.map +1 -1
- package/dist/http/RedirectBuilder.js +43 -37
- package/dist/http/RedirectBuilder.js.map +1 -1
- package/dist/http/Request.d.ts +42 -17
- package/dist/http/Request.d.ts.map +1 -1
- package/dist/http/Request.js +80 -58
- package/dist/http/Request.js.map +1 -1
- package/dist/http/Response.d.ts +7 -4
- package/dist/http/Response.d.ts.map +1 -1
- package/dist/http/Response.js +14 -6
- package/dist/http/Response.js.map +1 -1
- package/dist/http/SseStream.js +6 -7
- package/dist/http/SseStream.js.map +1 -1
- package/dist/http/permissions.d.ts +25 -0
- package/dist/http/permissions.d.ts.map +1 -0
- package/dist/http/permissions.js +38 -0
- package/dist/http/permissions.js.map +1 -0
- package/dist/http-client/HttpClient.d.ts +111 -0
- package/dist/http-client/HttpClient.d.ts.map +1 -0
- package/dist/http-client/HttpClient.js +386 -0
- package/dist/http-client/HttpClient.js.map +1 -0
- package/dist/http-client/addresses.d.ts +14 -0
- package/dist/http-client/addresses.d.ts.map +1 -0
- package/dist/http-client/addresses.js +57 -0
- package/dist/http-client/addresses.js.map +1 -0
- package/dist/http-client/fake.d.ts +50 -0
- package/dist/http-client/fake.d.ts.map +1 -0
- package/dist/http-client/fake.js +95 -0
- package/dist/http-client/fake.js.map +1 -0
- package/dist/http-client/index.d.ts +7 -0
- package/dist/http-client/index.d.ts.map +1 -0
- package/dist/http-client/index.js +7 -0
- package/dist/http-client/index.js.map +1 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/middleware/Pipeline.d.ts.map +1 -1
- package/dist/middleware/Pipeline.js +6 -3
- package/dist/middleware/Pipeline.js.map +1 -1
- package/dist/native/generated.d.ts +93 -36
- package/dist/native/generated.d.ts.map +1 -1
- package/dist/profiler/Profiler.d.ts.map +1 -1
- package/dist/profiler/Profiler.js +4 -1
- package/dist/profiler/Profiler.js.map +1 -1
- package/dist/profiler/client.generated.d.ts +5 -0
- package/dist/profiler/client.generated.d.ts.map +1 -0
- package/dist/profiler/client.generated.js +6 -0
- package/dist/profiler/client.generated.js.map +1 -0
- package/dist/profiler/collectors.d.ts +92 -13
- package/dist/profiler/collectors.d.ts.map +1 -1
- package/dist/profiler/collectors.js +106 -19
- package/dist/profiler/collectors.js.map +1 -1
- package/dist/profiler/endpoint.d.ts +2 -1
- package/dist/profiler/endpoint.d.ts.map +1 -1
- package/dist/profiler/endpoint.js +25 -1
- package/dist/profiler/endpoint.js.map +1 -1
- package/dist/profiler/index.d.ts +8 -4
- package/dist/profiler/index.d.ts.map +1 -1
- package/dist/profiler/index.js +11 -4
- package/dist/profiler/index.js.map +1 -1
- package/dist/profiler/middleware.d.ts.map +1 -1
- package/dist/profiler/middleware.js +76 -10
- package/dist/profiler/middleware.js.map +1 -1
- package/dist/profiler/preview.d.ts +17 -0
- package/dist/profiler/preview.d.ts.map +1 -0
- package/dist/profiler/preview.js +100 -0
- package/dist/profiler/preview.js.map +1 -0
- package/dist/profiler/toolbar.d.ts +15 -23
- package/dist/profiler/toolbar.d.ts.map +1 -1
- package/dist/profiler/toolbar.js +25 -91
- package/dist/profiler/toolbar.js.map +1 -1
- package/dist/profiler/types.d.ts +6 -1
- package/dist/profiler/types.d.ts.map +1 -1
- package/dist/router/Router.d.ts +6 -0
- package/dist/router/Router.d.ts.map +1 -1
- package/dist/router/Router.js +115 -12
- package/dist/router/Router.js.map +1 -1
- package/dist/rpc/RpcProvider.d.ts +6 -0
- package/dist/rpc/RpcProvider.d.ts.map +1 -1
- package/dist/rpc/RpcProvider.js +4 -1
- package/dist/rpc/RpcProvider.js.map +1 -1
- package/dist/rpc/RpcRouter.d.ts +27 -14
- package/dist/rpc/RpcRouter.d.ts.map +1 -1
- package/dist/rpc/RpcRouter.js +97 -40
- package/dist/rpc/RpcRouter.js.map +1 -1
- package/dist/scheduler/Scheduler.js +1 -1
- package/dist/scheduler/Scheduler.js.map +1 -1
- package/dist/scheduler/locks/RedisLockBackend.d.ts.map +1 -1
- package/dist/scheduler/locks/RedisLockBackend.js +13 -2
- package/dist/scheduler/locks/RedisLockBackend.js.map +1 -1
- package/dist/security/CookieSigner.d.ts.map +1 -1
- package/dist/security/CookieSigner.js +32 -8
- package/dist/security/CookieSigner.js.map +1 -1
- package/dist/security/SignedUrl.d.ts.map +1 -1
- package/dist/security/SignedUrl.js +16 -19
- package/dist/security/SignedUrl.js.map +1 -1
- package/dist/server/Server.d.ts +44 -12
- package/dist/server/Server.d.ts.map +1 -1
- package/dist/server/Server.js +31 -10
- package/dist/server/Server.js.map +1 -1
- package/dist/server/nativeGrpc.d.ts +27 -0
- package/dist/server/nativeGrpc.d.ts.map +1 -0
- package/dist/server/nativeGrpc.js +47 -0
- package/dist/server/nativeGrpc.js.map +1 -0
- package/dist/server/nativeLimits.d.ts +57 -0
- package/dist/server/nativeLimits.d.ts.map +1 -0
- package/dist/server/nativeLimits.js +75 -0
- package/dist/server/nativeLimits.js.map +1 -0
- package/dist/session/Session.d.ts +12 -0
- package/dist/session/Session.d.ts.map +1 -1
- package/dist/session/Session.js +13 -4
- package/dist/session/Session.js.map +1 -1
- package/dist/session/SessionMiddleware.d.ts.map +1 -1
- package/dist/session/SessionMiddleware.js +28 -9
- package/dist/session/SessionMiddleware.js.map +1 -1
- package/dist/session/config.d.ts +5 -0
- package/dist/session/config.d.ts.map +1 -1
- package/dist/session/config.js +8 -0
- package/dist/session/config.js.map +1 -1
- package/dist/session/drivers/MemoryDriver.d.ts.map +1 -1
- package/dist/session/drivers/MemoryDriver.js +26 -7
- package/dist/session/drivers/MemoryDriver.js.map +1 -1
- package/dist/session/errors.d.ts +17 -0
- package/dist/session/errors.d.ts.map +1 -1
- package/dist/session/errors.js +21 -0
- package/dist/session/errors.js.map +1 -1
- package/dist/session/templateTags.d.ts +14 -0
- package/dist/session/templateTags.d.ts.map +1 -1
- package/dist/session/templateTags.js +45 -17
- package/dist/session/templateTags.js.map +1 -1
- package/dist/storage/StaticMiddleware.d.ts.map +1 -1
- package/dist/storage/StaticMiddleware.js +49 -27
- package/dist/storage/StaticMiddleware.js.map +1 -1
- package/dist/testing/ApiResponse.d.ts.map +1 -1
- package/dist/testing/ApiResponse.js +7 -1
- package/dist/testing/ApiResponse.js.map +1 -1
- package/dist/testing/TestClient.d.ts.map +1 -1
- package/dist/testing/TestClient.js +16 -4
- package/dist/testing/TestClient.js.map +1 -1
- package/dist/utils/Macroable.d.ts +1 -1
- package/dist/utils/Macroable.js +2 -2
- package/dist/utils/Macroable.js.map +1 -1
- package/events.darwin-arm64.node +0 -0
- package/events.darwin-x64.node +0 -0
- package/events.linux-arm64-gnu.node +0 -0
- package/events.linux-x64-gnu.node +0 -0
- package/events.win32-x64-msvc.node +0 -0
- package/index.darwin-arm64.node +0 -0
- package/index.darwin-x64.node +0 -0
- package/index.linux-arm64-gnu.node +0 -0
- package/index.linux-x64-gnu.node +0 -0
- package/index.win32-x64-msvc.node +0 -0
- package/package.json +11 -3
- package/scheduler.darwin-arm64.node +0 -0
- package/scheduler.darwin-x64.node +0 -0
- package/scheduler.linux-arm64-gnu.node +0 -0
- package/scheduler.linux-x64-gnu.node +0 -0
- package/scheduler.win32-x64-msvc.node +0 -0
- package/src/Codemods.ts +314 -3
- package/src/HttpKernel.ts +18 -7
- package/src/Ignitor.ts +58 -26
- package/src/bodyparser/BodyParserMiddleware.ts +45 -16
- package/src/bodyparser/MultipartFile.ts +46 -67
- package/src/bodyparser/parseSize.ts +17 -17
- package/src/bodyparser/qsParse.ts +96 -26
- package/src/codemods/source.ts +303 -0
- package/src/console/prompts.ts +3 -1
- package/src/container/Container.ts +97 -81
- package/src/events/Emitter.ts +37 -10
- package/src/events/helix/helpers.ts +24 -19
- package/src/graphql/GraphQLEngine.ts +91 -14
- package/src/helpers/MessageBuilder.ts +4 -2
- package/src/helpers/errors.ts +16 -0
- package/src/helpers/napi-loader.ts +3 -2
- package/src/http/Exception.ts +17 -2
- package/src/http/HttpContext.ts +34 -5
- package/src/http/RedirectBuilder.ts +51 -37
- package/src/http/Request.ts +102 -58
- package/src/http/Response.ts +15 -7
- package/src/http/SseStream.ts +6 -7
- package/src/http/permissions.ts +47 -0
- package/src/http-client/HttpClient.ts +505 -0
- package/src/http-client/addresses.ts +58 -0
- package/src/http-client/fake.ts +141 -0
- package/src/http-client/index.ts +21 -0
- package/src/index.ts +6 -1
- package/src/middleware/Pipeline.ts +7 -3
- package/src/native/generated.ts +106 -48
- package/src/profiler/Profiler.ts +4 -1
- package/src/profiler/client/toolbar.css +595 -0
- package/src/profiler/client/toolbar.js +1299 -0
- package/src/profiler/client.generated.ts +7 -0
- package/src/profiler/collectors.ts +156 -19
- package/src/profiler/endpoint.ts +27 -1
- package/src/profiler/index.ts +17 -3
- package/src/profiler/middleware.ts +74 -9
- package/src/profiler/preview.ts +104 -0
- package/src/profiler/toolbar.ts +28 -91
- package/src/profiler/types.ts +6 -1
- package/src/router/Router.ts +136 -13
- package/src/rpc/RpcProvider.ts +10 -1
- package/src/rpc/RpcRouter.ts +129 -45
- package/src/scheduler/Scheduler.ts +1 -1
- package/src/scheduler/locks/RedisLockBackend.ts +12 -4
- package/src/security/CookieSigner.ts +30 -8
- package/src/security/SignedUrl.ts +18 -17
- package/src/server/Server.ts +60 -12
- package/src/server/nativeGrpc.ts +59 -0
- package/src/server/nativeLimits.ts +111 -0
- package/src/session/Session.ts +29 -4
- package/src/session/SessionMiddleware.ts +30 -10
- package/src/session/config.ts +7 -0
- package/src/session/drivers/MemoryDriver.ts +26 -7
- package/src/session/errors.ts +31 -0
- package/src/session/templateTags.ts +57 -0
- package/src/storage/StaticMiddleware.ts +46 -27
- package/src/testing/ApiResponse.ts +7 -1
- package/src/testing/TestClient.ts +14 -5
- package/src/utils/Macroable.ts +2 -2
- package/scripts/build-napi-types.mjs +0 -69
- package/scripts/copy-napi.mjs +0 -121
- package/scripts/generate-mime.mjs +0 -119
- 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.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
}
|
package/src/native/generated.ts
CHANGED
|
@@ -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
|
-
/**
|
|
37
|
-
|
|
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`
|
|
115
|
-
* every interface
|
|
116
|
-
* the safe default for a dev
|
|
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
|
-
|
|
216
|
+
onGrpcCancel(callback: (arg: number) => void): void
|
|
136
217
|
/**
|
|
137
|
-
* Configure the trusted
|
|
138
|
-
* Must be called BEFORE `listen()`.
|
|
139
|
-
* (
|
|
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
|
package/src/profiler/Profiler.ts
CHANGED
|
@@ -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 = {
|
|
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
|