@guren/server 2.15.0 → 2.17.0
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/dist/{DocsViewerServiceProvider-qFCaeiUv.js → DocsViewerServiceProvider-D2cuVgtN.js} +7 -12
- package/dist/{Hash-C8aejmi8.js → Hash-D2DFd8xX.js} +7 -57
- package/dist/{HttpException-BkS3euNG.js → HttpException-BlQ2yEmT.js} +2 -79
- package/dist/{Job-BVT813DO.js → Job-DxQK8h3P.js} +24 -179
- package/dist/{McpServiceProvider-BawsYjgN.js → McpServiceProvider-Zihx3Bjq.js} +35 -20
- package/dist/{Random-DbIJ22KQ.js → Random-S0OvCuR8.js} +9 -106
- package/dist/agent/AgentApprovalRequested.d.ts +11 -39
- package/dist/agent/approval-status.d.ts +56 -0
- package/dist/agent/approval.d.ts +76 -187
- package/dist/agent/audit-emitter.d.ts +16 -44
- package/dist/agent/audit.d.ts +20 -56
- package/dist/agent/derive.d.ts +32 -66
- package/dist/agent/dispatch.d.ts +38 -90
- package/dist/agent/events.d.ts +17 -23
- package/dist/agent/gate.d.ts +118 -0
- package/dist/agent/meta-tools.d.ts +18 -46
- package/dist/agent/pipeline.d.ts +234 -0
- package/dist/agent/public.d.ts +6 -25
- package/dist/agent/public.js +1 -1
- package/dist/agent/redact.d.ts +16 -38
- package/dist/agent/scopes.d.ts +55 -69
- package/dist/auth/AgentPrincipalGuard.d.ts +49 -0
- package/dist/auth/AuthManager.d.ts +22 -43
- package/dist/auth/AuthenticatableModel.d.ts +2 -2
- package/dist/auth/SessionGuard.d.ts +0 -1
- package/dist/auth/TokenGuard.d.ts +6 -26
- package/dist/auth/api-token.d.ts +16 -148
- package/dist/auth/context.d.ts +5 -10
- package/dist/auth/email-verification.d.ts +29 -127
- package/dist/auth/index.js +1 -1
- package/dist/auth/oauth/index.d.ts +35 -57
- package/dist/auth/password/DefaultHasher.d.ts +5 -14
- package/dist/auth/password/PasswordHasher.d.ts +5 -13
- package/dist/auth/password/hash-format.d.ts +5 -13
- package/dist/auth/password-reset.d.ts +16 -42
- package/dist/auth/providers/ModelUserProvider.d.ts +3 -4
- package/dist/auth/providers/UserProvider.d.ts +4 -4
- package/dist/auth/signed-token.d.ts +18 -0
- package/dist/auth/types.d.ts +9 -32
- package/dist/auth/utils.d.ts +6 -27
- package/dist/{auth-DkYoAPVn.js → auth-Gg54ppQi.js} +279 -519
- package/dist/authorization/Gate.d.ts +9 -145
- package/dist/authorization/Policy.d.ts +6 -53
- package/dist/authorization/index.js +1 -1
- package/dist/authorization/middleware.d.ts +16 -62
- package/dist/authorization/types.d.ts +8 -64
- package/dist/{authorization-CdfbCj8J.js → authorization-CdEWZZw3.js} +44 -309
- package/dist/broadcasting/BroadcastManager.d.ts +29 -149
- package/dist/broadcasting/channels/Channel.d.ts +1 -19
- package/dist/broadcasting/channels/PresenceChannel.d.ts +1 -55
- package/dist/broadcasting/channels/PrivateChannel.d.ts +1 -23
- package/dist/broadcasting/drivers/MemoryDriver.d.ts +18 -70
- package/dist/broadcasting/drivers/RedisDriver.d.ts +3 -80
- package/dist/broadcasting/drivers/index.d.ts +1 -1
- package/dist/broadcasting/index.d.ts +1 -1
- package/dist/broadcasting/index.js +1 -1
- package/dist/broadcasting/types.d.ts +7 -88
- package/dist/{broadcasting-BwodCA4q.js → broadcasting-B5RzB0A2.js} +87 -414
- package/dist/cache/CacheManager.d.ts +8 -62
- package/dist/cache/TaggedCache.d.ts +2 -35
- package/dist/cache/index.js +1 -1
- package/dist/cache/stores/FileStore.d.ts +2 -36
- package/dist/cache/stores/MemoryStore.d.ts +2 -26
- package/dist/cache/stores/RedisStore.d.ts +1 -29
- package/dist/cache/types.d.ts +21 -128
- package/dist/{cache-BYnZf2FR.js → cache-BOOIr324.js} +19 -198
- package/dist/client-C4TEr_Dd.js +9 -0
- package/dist/console/Command.d.ts +17 -126
- package/dist/console/ConsoleKernel.d.ts +2 -74
- package/dist/console/Input.d.ts +5 -113
- package/dist/console/Output.d.ts +3 -99
- package/dist/console/types.d.ts +3 -33
- package/dist/container/Container.d.ts +12 -103
- package/dist/container/ServiceProvider.d.ts +17 -61
- package/dist/container/bindings.d.ts +5 -26
- package/dist/container/defineModule.d.ts +16 -54
- package/dist/container/definePlugin.d.ts +12 -45
- package/dist/container/types.d.ts +2 -34
- package/dist/context-CXk_umpT.js +21 -0
- package/dist/database/Factory.d.ts +4 -57
- package/dist/database/Seeder.d.ts +8 -46
- package/dist/database/SeederRunner.d.ts +3 -33
- package/dist/database/types.d.ts +3 -24
- package/dist/discovery/AutoDiscovery.d.ts +10 -82
- package/dist/{dispatch-erOS9epZ.js → dispatch-BAwzftws.js} +32 -79
- package/dist/docs-viewer/DocsViewerServiceProvider.d.ts +2 -5
- package/dist/docs-viewer/endpoint.d.ts +5 -11
- package/dist/encryption/Encrypter.d.ts +5 -71
- package/dist/encryption/Hash.d.ts +7 -57
- package/dist/encryption/Random.d.ts +6 -99
- package/dist/encryption/index.js +3 -3
- package/dist/encryption/types.d.ts +10 -72
- package/dist/{encryption-D99Vmls3.js → encryption-uwP3Di4D.js} +9 -78
- package/dist/{endpoint-D6GIqOpe.js → endpoint-BXipU2Jj.js} +6 -12
- package/dist/endpoint-Dsw3Acvq.js +26 -0
- package/dist/errors/ExceptionHandler.d.ts +3 -90
- package/dist/errors/HttpException.d.ts +2 -79
- package/dist/errors/debug-page.d.ts +3 -17
- package/dist/errors/error-page.d.ts +1 -0
- package/dist/errors/exceptions/AuthenticationException.d.ts +2 -24
- package/dist/errors/exceptions/AuthorizationException.d.ts +1 -24
- package/dist/errors/exceptions/MethodNotAllowedException.d.ts +1 -23
- package/dist/errors/exceptions/NotFoundHttpException.d.ts +1 -27
- package/dist/errors/exceptions/ValidationException.d.ts +2 -43
- package/dist/errors/types.d.ts +1 -25
- package/dist/{errors-BgeOl_DC.js → errors-JpkcCjjn.js} +3 -41
- package/dist/events/Event.d.ts +1 -28
- package/dist/events/EventManager.d.ts +5 -107
- package/dist/events/Listener.d.ts +7 -55
- package/dist/events/builtin.d.ts +0 -24
- package/dist/events/index.js +1 -1
- package/dist/events/types.d.ts +4 -22
- package/dist/{events-aIH_bWRx.js → events-DOmAHDeP.js} +11 -191
- package/dist/facades/index.d.ts +2 -14
- package/dist/health/HealthCheck.d.ts +0 -24
- package/dist/health/HealthManager.d.ts +0 -36
- package/dist/health/checks/CacheCheck.d.ts +2 -17
- package/dist/health/checks/CustomCheck.d.ts +0 -9
- package/dist/health/checks/DatabaseCheck.d.ts +2 -17
- package/dist/health/checks/MemoryCheck.d.ts +3 -12
- package/dist/health/checks/RedisCheck.d.ts +1 -13
- package/dist/health/checks/StorageCheck.d.ts +2 -17
- package/dist/health/index.js +1 -1
- package/dist/health/types.d.ts +4 -24
- package/dist/{health-VWdWXRwh.js → health-DQSvUplL.js} +1 -76
- package/dist/hot-disposables-B5BXqaIH.js +167 -0
- package/dist/hot-reload/hot-disposables.d.ts +22 -74
- package/dist/hot-reload/testing.d.ts +4 -9
- package/dist/http/Application.d.ts +77 -205
- package/dist/http/FormRequest.d.ts +4 -55
- package/dist/http/dev-assets.d.ts +13 -31
- package/dist/http/dev-banner.d.ts +2 -5
- package/dist/http/inertia-assets.d.ts +3 -6
- package/dist/http/middleware/capabilities.d.ts +27 -50
- package/dist/http/middleware/cors.d.ts +4 -29
- package/dist/http/middleware/csp.d.ts +2 -25
- package/dist/http/middleware/csrf.d.ts +28 -95
- package/dist/http/middleware/detect-locale.d.ts +7 -27
- package/dist/http/middleware/force-https.d.ts +6 -24
- package/dist/http/middleware/host-authorization.d.ts +2 -12
- package/dist/http/middleware/index.d.ts +1 -1
- package/dist/http/middleware/loopback-guard.d.ts +15 -33
- package/dist/http/middleware/rate-limit.d.ts +29 -126
- package/dist/http/middleware/redirect-safety.d.ts +2 -20
- package/dist/http/middleware/request-id.d.ts +1 -14
- package/dist/http/middleware/request-logging.d.ts +2 -13
- package/dist/http/middleware/response-headers.d.ts +5 -13
- package/dist/http/middleware/security-headers.d.ts +2 -16
- package/dist/http/middleware/session.d.ts +15 -34
- package/dist/http/middleware/validation-errors-cookie.d.ts +7 -18
- package/dist/http/middleware/validation.d.ts +8 -63
- package/dist/http/public-assets.d.ts +11 -7
- package/dist/http/request.d.ts +32 -118
- package/dist/http/resources/CursorPaginator.d.ts +5 -64
- package/dist/http/resources/Paginator.d.ts +7 -84
- package/dist/http/resources/Resource.d.ts +9 -65
- package/dist/http/resources/ResourceCollection.d.ts +5 -39
- package/dist/http/resources/types.d.ts +10 -30
- package/dist/http/static-documents.d.ts +10 -20
- package/dist/http/validation/Validator.d.ts +25 -85
- package/dist/http/validation/rules.d.ts +48 -147
- package/dist/http/validation/types.d.ts +16 -61
- package/dist/http/vite-assets.d.ts +5 -28
- package/dist/http/vite-dev-server.d.ts +6 -9
- package/dist/http/vite-manifest.d.ts +19 -33
- package/dist/i18n/I18nManager.d.ts +12 -78
- package/dist/i18n/Translator.d.ts +3 -54
- package/dist/i18n/index.js +1 -1
- package/dist/i18n/loaders/JsonLoader.d.ts +4 -31
- package/dist/i18n/loaders/MemoryLoader.d.ts +1 -21
- package/dist/i18n/pluralization.d.ts +4 -13
- package/dist/i18n/types.d.ts +17 -69
- package/dist/{i18n-mcWi7LCd.js → i18n-Cg1aajRP.js} +31 -225
- package/dist/index.d.ts +11 -4
- package/dist/index.js +1186 -3040
- package/dist/internal/agent-preflight.d.ts +9 -21
- package/dist/internal/agent-principal.d.ts +32 -0
- package/dist/internal/request.d.ts +6 -19
- package/dist/internal/request.js +1 -1
- package/dist/internal/route-path.d.ts +9 -21
- package/dist/internal/route-path.js +9 -21
- package/dist/internal/zod-compat.d.ts +55 -122
- package/dist/internal/zod-compat.js +39 -70
- package/dist/internal/zod-json-schema.d.ts +18 -54
- package/dist/internal/zod-json-schema.js +46 -123
- package/dist/jsx-runtime.d.ts +3 -8
- package/dist/lambda/index.d.ts +17 -79
- package/dist/lambda/index.js +11 -59
- package/dist/logging/LogManager.d.ts +1 -51
- package/dist/logging/Logger.d.ts +8 -47
- package/dist/logging/channels/ConsoleChannel.d.ts +1 -3
- package/dist/logging/channels/DailyFileChannel.d.ts +1 -3
- package/dist/logging/channels/FileChannel.d.ts +1 -3
- package/dist/logging/daily-file-path.d.ts +7 -16
- package/dist/logging/index.js +1 -1
- package/dist/logging/types.d.ts +13 -45
- package/dist/{logging-B-kngi3q.js → logging-zOY1XCtq.js} +52 -141
- package/dist/{loopback-guard-D0Kc7-xc.js → loopback-guard-DT9gHF0F.js} +41 -92
- package/dist/mail/Mail.d.ts +10 -106
- package/dist/mail/MailManager.d.ts +2 -60
- package/dist/mail/index.js +1 -1
- package/dist/mail/transports/LogTransport.d.ts +1 -4
- package/dist/mail/transports/MemoryTransport.d.ts +1 -63
- package/dist/mail/transports/ResendTransport.d.ts +1 -23
- package/dist/mail/transports/SmtpTransport.d.ts +1 -31
- package/dist/mail/types.d.ts +28 -150
- package/dist/{mail-DfEfSQEr.js → mail-76DWy9lj.js} +31 -289
- package/dist/mcp/McpServiceProvider.d.ts +4 -10
- package/dist/mcp/create-mcp-server.d.ts +42 -57
- package/dist/mcp/endpoint.d.ts +12 -36
- package/dist/mcp/index.js +1 -1
- package/dist/mvc/Controller.d.ts +46 -227
- package/dist/mvc/Router.d.ts +50 -129
- package/dist/mvc/inertia/InertiaEngine.d.ts +18 -48
- package/dist/mvc/inertia/shared.d.ts +6 -19
- package/dist/mvc/mount-route.d.ts +2 -6
- package/dist/mvc/view.d.ts +1 -2
- package/dist/notifications/Notification.d.ts +8 -75
- package/dist/notifications/NotificationManager.d.ts +15 -88
- package/dist/notifications/channels/DatabaseChannel.d.ts +1 -41
- package/dist/notifications/channels/MailChannel.d.ts +2 -31
- package/dist/notifications/channels/MemoryChannel.d.ts +2 -62
- package/dist/notifications/channels/SlackChannel.d.ts +3 -48
- package/dist/notifications/index.js +1 -1
- package/dist/notifications/notifiable-type.d.ts +3 -6
- package/dist/notifications/registry.d.ts +8 -27
- package/dist/notifications/types.d.ts +16 -53
- package/dist/{notifications-BGqmUNZ8.js → notifications-okWFs9ly.js} +37 -335
- package/dist/providers/AuthServiceProvider.d.ts +1 -3
- package/dist/providers/AuthorizationServiceProvider.d.ts +2 -3
- package/dist/providers/BroadcastServiceProvider.d.ts +1 -3
- package/dist/providers/CacheServiceProvider.d.ts +1 -3
- package/dist/providers/EncryptionServiceProvider.d.ts +1 -3
- package/dist/providers/ErrorServiceProvider.d.ts +1 -4
- package/dist/providers/EventServiceProvider.d.ts +1 -3
- package/dist/providers/HealthServiceProvider.d.ts +1 -3
- package/dist/providers/I18nServiceProvider.d.ts +6 -10
- package/dist/providers/InertiaServiceProvider.d.ts +1 -4
- package/dist/providers/LogServiceProvider.d.ts +1 -3
- package/dist/providers/MailServiceProvider.d.ts +1 -3
- package/dist/providers/NotificationServiceProvider.d.ts +1 -3
- package/dist/providers/OAuthServiceProvider.d.ts +1 -3
- package/dist/providers/QueueServiceProvider.d.ts +1 -3
- package/dist/providers/SchedulingServiceProvider.d.ts +1 -3
- package/dist/providers/StorageServiceProvider.d.ts +1 -3
- package/dist/queue/FailedJobReporter.d.ts +1 -24
- package/dist/queue/Job.d.ts +12 -99
- package/dist/queue/QueueManager.d.ts +6 -57
- package/dist/queue/Worker.d.ts +4 -65
- package/dist/queue/drivers/MemoryDriver.d.ts +3 -44
- package/dist/queue/drivers/RedisDriver.d.ts +7 -65
- package/dist/queue/drivers/SqsDriver.d.ts +6 -57
- package/dist/queue/drivers/SyncDriver.d.ts +10 -13
- package/dist/queue/index.js +2 -2
- package/dist/queue/types.d.ts +10 -92
- package/dist/{queue-CXrRK85G.js → queue-CcXCjuJI.js} +32 -260
- package/dist/redis/RedisApiTokenStore.d.ts +4 -56
- package/dist/redis/RedisEmailVerificationStore.d.ts +4 -37
- package/dist/redis/RedisOAuthStateStore.d.ts +2 -10
- package/dist/redis/RedisPasswordResetStore.d.ts +4 -37
- package/dist/redis/RedisRateLimitStore.d.ts +16 -49
- package/dist/redis/RedisSessionStore.d.ts +3 -44
- package/dist/redis/client.d.ts +2 -32
- package/dist/redis/index.js +47 -232
- package/dist/redis/redis-values.d.ts +6 -12
- package/dist/redis/scan-keys.d.ts +1 -4
- package/dist/request-CLOYytGP.js +68 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.js +50 -92
- package/dist/scheduling/CronParser.d.ts +0 -29
- package/dist/scheduling/Schedule.d.ts +1 -153
- package/dist/scheduling/ScheduledTask.d.ts +0 -31
- package/dist/scheduling/Scheduler.d.ts +0 -70
- package/dist/scheduling/index.js +1 -1
- package/dist/scheduling/types.d.ts +4 -65
- package/dist/{scheduling-CPiEdtQd.js → scheduling-C6tcOtUl.js} +2 -287
- package/dist/storage/StorageManager.d.ts +0 -48
- package/dist/storage/drivers/LocalDriver.d.ts +1 -25
- package/dist/storage/drivers/MemoryDriver.d.ts +5 -35
- package/dist/storage/drivers/S3Driver.d.ts +6 -36
- package/dist/storage/drivers/s3-acl.d.ts +5 -10
- package/dist/storage/index.js +1 -1
- package/dist/storage/types.d.ts +27 -265
- package/dist/{storage-TLD9t0Q2.js → storage-BB59f07j.js} +17 -157
- package/dist/support/contained-path.d.ts +10 -20
- package/dist/support/error-polyfill.d.ts +4 -6
- package/dist/support/expiry.d.ts +17 -33
- package/dist/support/expiry.js +17 -33
- package/dist/support/import-map.d.ts +3 -7
- package/dist/support/inertia-defaults.d.ts +5 -10
- package/dist/support/redirect-target.d.ts +4 -6
- package/dist/support/stack-frames.d.ts +11 -50
- package/dist/support/trim-slashes.d.ts +4 -7
- package/dist/support/warn-once.d.ts +2 -6
- package/dist/{trim-slashes-ZJ_VsY5s.js → trim-slashes-BLY9hKAa.js} +4 -7
- package/dist/{vite-manifest-w_RSOvQW.js → vite-manifest-B_Iy5183.js} +34 -58
- package/package.json +2 -2
- package/dist/client-Dd7vLcqp.js +0 -27
- package/dist/context-DoD0c7J_.js +0 -26
- package/dist/endpoint-D-20PiHY.js +0 -46
- package/dist/hot-disposables-WsTX2ySN.js +0 -281
- package/dist/request-CVQwpu2J.js +0 -129
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import * as path$1 from "node:path";
|
|
2
2
|
import * as fs from "node:fs";
|
|
3
3
|
//#region src/logging/types.ts
|
|
4
|
-
/**
|
|
5
|
-
* Log level priority (lower = more severe).
|
|
6
|
-
*/
|
|
4
|
+
/** Log level priority (lower = more severe). */
|
|
7
5
|
const LOG_LEVEL_PRIORITY = {
|
|
8
6
|
emergency: 0,
|
|
9
7
|
alert: 1,
|
|
@@ -29,9 +27,7 @@ const DEFAULT_FILTER_KEYS = [
|
|
|
29
27
|
"ssn",
|
|
30
28
|
"authorization"
|
|
31
29
|
];
|
|
32
|
-
/**
|
|
33
|
-
* Recursively replace values of sensitive keys in a log context object.
|
|
34
|
-
*/
|
|
30
|
+
/** Recursively replace values of sensitive keys in a log context object. */
|
|
35
31
|
function filterSensitiveData(data, filterKeys, replacement = "[FILTERED]") {
|
|
36
32
|
if (filterKeys.length === 0) return data;
|
|
37
33
|
return filterObject(data, new Set(filterKeys.map((k) => k.toLowerCase())), replacement);
|
|
@@ -44,9 +40,19 @@ function filterObject(obj, keySet, replacement) {
|
|
|
44
40
|
else result[key] = value;
|
|
45
41
|
return result;
|
|
46
42
|
}
|
|
43
|
+
const reportLoggingError = (error) => {
|
|
44
|
+
console.error("Logging error:", error);
|
|
45
|
+
};
|
|
47
46
|
/**
|
|
48
|
-
*
|
|
47
|
+
* Whether a channel's `log()` handed back something to wait on. A duck-typed
|
|
48
|
+
* check rather than `instanceof Promise`: a promise created in another realm
|
|
49
|
+
* (a `node:vm` context, a worker's module graph) satisfies the channel
|
|
50
|
+
* contract and would otherwise slip past the reporter as an unhandled rejection.
|
|
49
51
|
*/
|
|
52
|
+
function isPromiseLike(value) {
|
|
53
|
+
return typeof value === "object" && value !== null && typeof value.then === "function";
|
|
54
|
+
}
|
|
55
|
+
/** Logger instance for writing log entries. */
|
|
50
56
|
var Logger = class Logger {
|
|
51
57
|
channels;
|
|
52
58
|
baseContext;
|
|
@@ -58,63 +64,33 @@ var Logger = class Logger {
|
|
|
58
64
|
this.filterKeys = options.filterKeys ?? DEFAULT_FILTER_KEYS;
|
|
59
65
|
this.replacement = options.replacement ?? "[FILTERED]";
|
|
60
66
|
}
|
|
61
|
-
/**
|
|
62
|
-
* Log at emergency level (system is unusable).
|
|
63
|
-
*/
|
|
64
67
|
emergency(message, context = {}) {
|
|
65
68
|
this.log("emergency", message, context);
|
|
66
69
|
}
|
|
67
|
-
/**
|
|
68
|
-
* Log at alert level (action must be taken immediately).
|
|
69
|
-
*/
|
|
70
70
|
alert(message, context = {}) {
|
|
71
71
|
this.log("alert", message, context);
|
|
72
72
|
}
|
|
73
|
-
/**
|
|
74
|
-
* Log at critical level (critical conditions).
|
|
75
|
-
*/
|
|
76
73
|
critical(message, context = {}) {
|
|
77
74
|
this.log("critical", message, context);
|
|
78
75
|
}
|
|
79
|
-
/**
|
|
80
|
-
* Log at error level (error conditions).
|
|
81
|
-
*/
|
|
82
76
|
error(message, context = {}) {
|
|
83
77
|
this.log("error", message, context);
|
|
84
78
|
}
|
|
85
|
-
/**
|
|
86
|
-
* Log at warning level (warning conditions).
|
|
87
|
-
*/
|
|
88
79
|
warning(message, context = {}) {
|
|
89
80
|
this.log("warning", message, context);
|
|
90
81
|
}
|
|
91
|
-
/**
|
|
92
|
-
* Alias for warning().
|
|
93
|
-
*/
|
|
94
82
|
warn(message, context = {}) {
|
|
95
83
|
this.warning(message, context);
|
|
96
84
|
}
|
|
97
|
-
/**
|
|
98
|
-
* Log at notice level (normal but significant conditions).
|
|
99
|
-
*/
|
|
100
85
|
notice(message, context = {}) {
|
|
101
86
|
this.log("notice", message, context);
|
|
102
87
|
}
|
|
103
|
-
/**
|
|
104
|
-
* Log at info level (informational messages).
|
|
105
|
-
*/
|
|
106
88
|
info(message, context = {}) {
|
|
107
89
|
this.log("info", message, context);
|
|
108
90
|
}
|
|
109
|
-
/**
|
|
110
|
-
* Log at debug level (debug-level messages).
|
|
111
|
-
*/
|
|
112
91
|
debug(message, context = {}) {
|
|
113
92
|
this.log("debug", message, context);
|
|
114
93
|
}
|
|
115
|
-
/**
|
|
116
|
-
* Log a message at the specified level.
|
|
117
|
-
*/
|
|
118
94
|
log(level, message, context = {}) {
|
|
119
95
|
const merged = {
|
|
120
96
|
...this.baseContext,
|
|
@@ -127,14 +103,12 @@ var Logger = class Logger {
|
|
|
127
103
|
timestamp: /* @__PURE__ */ new Date()
|
|
128
104
|
};
|
|
129
105
|
for (const channel of this.channels) try {
|
|
130
|
-
channel.log(entry);
|
|
106
|
+
const pending = channel.log(entry);
|
|
107
|
+
if (isPromiseLike(pending)) Promise.resolve(pending).catch(reportLoggingError);
|
|
131
108
|
} catch (error) {
|
|
132
|
-
|
|
109
|
+
reportLoggingError(error);
|
|
133
110
|
}
|
|
134
111
|
}
|
|
135
|
-
/**
|
|
136
|
-
* Create a new logger with additional context.
|
|
137
|
-
*/
|
|
138
112
|
withContext(context) {
|
|
139
113
|
return new Logger(this.channels, {
|
|
140
114
|
...this.baseContext,
|
|
@@ -144,24 +118,15 @@ var Logger = class Logger {
|
|
|
144
118
|
replacement: this.replacement
|
|
145
119
|
});
|
|
146
120
|
}
|
|
147
|
-
/**
|
|
148
|
-
* Create a child logger with additional context (alias for withContext).
|
|
149
|
-
*/
|
|
150
121
|
child(context) {
|
|
151
122
|
return this.withContext(context);
|
|
152
123
|
}
|
|
153
|
-
/**
|
|
154
|
-
* Close all channels.
|
|
155
|
-
*/
|
|
156
124
|
async close() {
|
|
157
125
|
for (const channel of this.channels) if (channel.close) await channel.close();
|
|
158
126
|
}
|
|
159
127
|
};
|
|
160
128
|
//#endregion
|
|
161
129
|
//#region src/logging/channels/ConsoleChannel.ts
|
|
162
|
-
/**
|
|
163
|
-
* ANSI color codes for log levels.
|
|
164
|
-
*/
|
|
165
130
|
const LEVEL_COLORS = {
|
|
166
131
|
emergency: "\x1B[41m\x1B[37m",
|
|
167
132
|
alert: "\x1B[41m\x1B[37m",
|
|
@@ -173,9 +138,7 @@ const LEVEL_COLORS = {
|
|
|
173
138
|
debug: "\x1B[90m"
|
|
174
139
|
};
|
|
175
140
|
const RESET = "\x1B[0m";
|
|
176
|
-
/**
|
|
177
|
-
* Console log channel.
|
|
178
|
-
*/
|
|
141
|
+
/** Console log channel. */
|
|
179
142
|
var ConsoleChannel = class {
|
|
180
143
|
config;
|
|
181
144
|
minLevel;
|
|
@@ -223,9 +186,7 @@ var ConsoleChannel = class {
|
|
|
223
186
|
};
|
|
224
187
|
//#endregion
|
|
225
188
|
//#region src/logging/channels/FileChannel.ts
|
|
226
|
-
/**
|
|
227
|
-
* File log channel.
|
|
228
|
-
*/
|
|
189
|
+
/** File log channel. */
|
|
229
190
|
var FileChannel = class {
|
|
230
191
|
config;
|
|
231
192
|
minLevel;
|
|
@@ -270,27 +231,17 @@ var FileChannel = class {
|
|
|
270
231
|
//#endregion
|
|
271
232
|
//#region src/logging/daily-file-path.ts
|
|
272
233
|
/**
|
|
273
|
-
* The one rule for what a daily-rotated log file is called:
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
* writer keeps appending, the reader stops recognising, and what the operator
|
|
280
|
-
* sees is an empty audit trail rather than an error.
|
|
281
|
-
*
|
|
282
|
-
* Naming only — nothing here touches the filesystem. The reader has to tell
|
|
283
|
-
* "this directory does not exist" apart from "this directory could not be
|
|
284
|
-
* read", and a helper that swallowed the difference on its behalf would put
|
|
285
|
-
* that distinction back out of reach.
|
|
234
|
+
* The one rule for what a daily-rotated log file is called:
|
|
235
|
+
* `dir/name-YYYY-MM-DD.ext`. {@link DailyFileChannel} names what it appends to
|
|
236
|
+
* through this module, and the audit reader behind `guren tool:log` decides
|
|
237
|
+
* what to read through the same one; a second copy drifts silently, leaving an
|
|
238
|
+
* empty audit trail rather than an error. Naming only — nothing here touches
|
|
239
|
+
* the filesystem, so a caller keeps "missing" and "unreadable" apart itself.
|
|
286
240
|
*/
|
|
287
241
|
/**
|
|
288
|
-
* The `YYYY-MM-DD` stamp a file rotated at `date` carries.
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
* instant for every process appending to the same directory — a fleet split
|
|
292
|
-
* across time zones would otherwise write two different files for one day and
|
|
293
|
-
* roll over at as many moments as it has zones.
|
|
242
|
+
* The `YYYY-MM-DD` stamp a file rotated at `date` carries. UTC, because the
|
|
243
|
+
* rotation boundary must be the same instant for every process appending to one
|
|
244
|
+
* directory — a fleet across time zones would write two files for one day.
|
|
294
245
|
*/
|
|
295
246
|
function dailyFileDateStamp(date) {
|
|
296
247
|
return date.toISOString().slice(0, 10);
|
|
@@ -301,16 +252,10 @@ function dailyFilePath(basePath, date) {
|
|
|
301
252
|
return path$1.join(dir, `${name}-${dailyFileDateStamp(date)}${ext}`);
|
|
302
253
|
}
|
|
303
254
|
/**
|
|
304
|
-
* The date stamp of `fileName` if it is one of `basePath`'s dated files,
|
|
305
|
-
* `null`
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
* directory does not need to know the shape it is matching. The base path's
|
|
309
|
-
* own name and extension are escaped before they enter the pattern: a log
|
|
310
|
-
* called `app.v1.log` parses to the name `app.v1`, whose dots would otherwise
|
|
311
|
-
* match any character and let a *different* app's files into another's
|
|
312
|
-
* rotation set — which, for the cleanup that consumes this, means deleting
|
|
313
|
-
* them.
|
|
255
|
+
* The date stamp of `fileName` if it is one of `basePath`'s dated files, else
|
|
256
|
+
* `null` — the inverse of {@link dailyFilePath}. The base name and extension
|
|
257
|
+
* are escaped first: `app.v1.log` would otherwise match another app's files
|
|
258
|
+
* into this rotation set, which for the cleanup consuming it means deleting them.
|
|
314
259
|
*/
|
|
315
260
|
function matchDailyFileDate(basePath, fileName) {
|
|
316
261
|
const { name, ext } = path$1.parse(basePath);
|
|
@@ -322,9 +267,7 @@ function escapeRegExp(text) {
|
|
|
322
267
|
}
|
|
323
268
|
//#endregion
|
|
324
269
|
//#region src/logging/channels/DailyFileChannel.ts
|
|
325
|
-
/**
|
|
326
|
-
* Daily rotating file log channel.
|
|
327
|
-
*/
|
|
270
|
+
/** Daily rotating file log channel. */
|
|
328
271
|
var DailyFileChannel = class {
|
|
329
272
|
config;
|
|
330
273
|
minLevel;
|
|
@@ -385,27 +328,7 @@ var DailyFileChannel = class {
|
|
|
385
328
|
};
|
|
386
329
|
//#endregion
|
|
387
330
|
//#region src/logging/LogManager.ts
|
|
388
|
-
/**
|
|
389
|
-
* Log manager for managing multiple logging channels.
|
|
390
|
-
*
|
|
391
|
-
* @example
|
|
392
|
-
* ```ts
|
|
393
|
-
* const log = new LogManager({
|
|
394
|
-
* default: 'stack',
|
|
395
|
-
* channels: {
|
|
396
|
-
* console: { driver: 'console', level: 'debug' },
|
|
397
|
-
* file: { driver: 'daily', path: './storage/logs/app.log', days: 14 },
|
|
398
|
-
* stack: { driver: 'stack', channels: ['console', 'file'] },
|
|
399
|
-
* }
|
|
400
|
-
* })
|
|
401
|
-
*
|
|
402
|
-
* log.info('User logged in', { userId: user.id })
|
|
403
|
-
* log.error('Payment failed', { orderId, error: error.message })
|
|
404
|
-
*
|
|
405
|
-
* const requestLog = log.withContext({ requestId: ctx.requestId })
|
|
406
|
-
* requestLog.info('Processing request')
|
|
407
|
-
* ```
|
|
408
|
-
*/
|
|
331
|
+
/** Log manager for managing multiple logging channels. */
|
|
409
332
|
var LogManager = class {
|
|
410
333
|
config;
|
|
411
334
|
channelFactories = /* @__PURE__ */ new Map();
|
|
@@ -438,22 +361,34 @@ var LogManager = class {
|
|
|
438
361
|
const channels = config.channels.map((name) => this.resolveChannel(name));
|
|
439
362
|
return {
|
|
440
363
|
log: (entry) => {
|
|
441
|
-
|
|
364
|
+
const failures = [];
|
|
365
|
+
const pending = [];
|
|
366
|
+
for (const channel of channels) try {
|
|
367
|
+
const result = channel.log(entry);
|
|
368
|
+
if (isPromiseLike(result)) pending.push(Promise.resolve(result).then(() => void 0, (error) => {
|
|
369
|
+
failures.push(error);
|
|
370
|
+
}));
|
|
371
|
+
} catch (error) {
|
|
372
|
+
failures.push(error);
|
|
373
|
+
}
|
|
374
|
+
const rethrow = () => {
|
|
375
|
+
if (failures.length === 1) throw failures[0];
|
|
376
|
+
if (failures.length > 1) throw new AggregateError(failures, `${failures.length} of ${channels.length} stack channels failed`);
|
|
377
|
+
};
|
|
378
|
+
if (pending.length === 0) {
|
|
379
|
+
rethrow();
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
return Promise.all(pending).then(rethrow);
|
|
442
383
|
},
|
|
443
384
|
close: async () => {
|
|
444
385
|
for (const channel of channels) if (channel.close) await channel.close();
|
|
445
386
|
}
|
|
446
387
|
};
|
|
447
388
|
}
|
|
448
|
-
/**
|
|
449
|
-
* Register a custom channel driver.
|
|
450
|
-
*/
|
|
451
389
|
registerDriver(name, factory) {
|
|
452
390
|
this.channelFactories.set(name, factory);
|
|
453
391
|
}
|
|
454
|
-
/**
|
|
455
|
-
* Get a logger for a specific channel.
|
|
456
|
-
*/
|
|
457
392
|
channel(name) {
|
|
458
393
|
const channelName = name ?? this.config.default;
|
|
459
394
|
if (!this.loggers.has(channelName)) {
|
|
@@ -462,9 +397,6 @@ var LogManager = class {
|
|
|
462
397
|
}
|
|
463
398
|
return this.loggers.get(channelName);
|
|
464
399
|
}
|
|
465
|
-
/**
|
|
466
|
-
* Get a logger that writes to multiple channels.
|
|
467
|
-
*/
|
|
468
400
|
stack(channelNames) {
|
|
469
401
|
const key = `stack:${channelNames.join(",")}`;
|
|
470
402
|
if (!this.loggers.has(key)) {
|
|
@@ -483,9 +415,6 @@ var LogManager = class {
|
|
|
483
415
|
this.channelInstances.set(name, channel);
|
|
484
416
|
return channel;
|
|
485
417
|
}
|
|
486
|
-
/**
|
|
487
|
-
* Create a logger with additional context using the default channel.
|
|
488
|
-
*/
|
|
489
418
|
withContext(context) {
|
|
490
419
|
return this.channel().withContext(context);
|
|
491
420
|
}
|
|
@@ -516,43 +445,25 @@ var LogManager = class {
|
|
|
516
445
|
debug(message, context) {
|
|
517
446
|
this.channel().debug(message, context);
|
|
518
447
|
}
|
|
519
|
-
/**
|
|
520
|
-
* Close all channel instances.
|
|
521
|
-
*/
|
|
522
448
|
async close() {
|
|
523
449
|
for (const channel of this.channelInstances.values()) if (channel.close) await channel.close();
|
|
524
450
|
this.channelInstances.clear();
|
|
525
451
|
this.loggers.clear();
|
|
526
452
|
}
|
|
527
|
-
/**
|
|
528
|
-
* Get the default channel name.
|
|
529
|
-
*/
|
|
530
453
|
getDefaultChannel() {
|
|
531
454
|
return this.config.default;
|
|
532
455
|
}
|
|
533
|
-
/**
|
|
534
|
-
* Get available channel names.
|
|
535
|
-
*/
|
|
536
456
|
getChannelNames() {
|
|
537
457
|
return Object.keys(this.config.channels);
|
|
538
458
|
}
|
|
539
459
|
};
|
|
540
|
-
/**
|
|
541
|
-
* Create a log manager instance.
|
|
542
|
-
*/
|
|
543
460
|
function createLogManager(config) {
|
|
544
461
|
return new LogManager(config);
|
|
545
462
|
}
|
|
546
463
|
let globalLogManager = null;
|
|
547
|
-
/**
|
|
548
|
-
* Set the global log manager instance.
|
|
549
|
-
*/
|
|
550
464
|
function setLogManager(manager) {
|
|
551
465
|
globalLogManager = manager;
|
|
552
466
|
}
|
|
553
|
-
/**
|
|
554
|
-
* Get the global log manager instance.
|
|
555
|
-
*/
|
|
556
467
|
function getLogManager() {
|
|
557
468
|
if (!globalLogManager) throw new Error("Log manager has not been initialized. Call setLogManager() first.");
|
|
558
469
|
return globalLogManager;
|
|
@@ -1,49 +1,21 @@
|
|
|
1
1
|
//#region src/container/ServiceProvider.ts
|
|
2
2
|
/**
|
|
3
|
-
* Base service provider
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* Your own application, as well as all core services, are bootstrapped via providers.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* export class AppServiceProvider extends ServiceProvider {
|
|
11
|
-
* register(): void {
|
|
12
|
-
* // Register bindings
|
|
13
|
-
* this.container.singleton('db', (c) => new Database(c.make('config')))
|
|
14
|
-
* }
|
|
15
|
-
*
|
|
16
|
-
* boot(): void {
|
|
17
|
-
* // Bootstrap after all providers registered
|
|
18
|
-
* const db = this.container.make<Database>('db')
|
|
19
|
-
* db.connect()
|
|
20
|
-
* }
|
|
21
|
-
* }
|
|
22
|
-
* ```
|
|
3
|
+
* Base service provider: all application and core bootstrapping runs through
|
|
4
|
+
* providers. `register()` binds services before any provider boots; `boot()` runs
|
|
5
|
+
* after every provider has registered.
|
|
23
6
|
*/
|
|
24
7
|
var ServiceProvider = class {
|
|
25
8
|
container;
|
|
26
|
-
/**
|
|
27
|
-
* Whether this provider should be deferred.
|
|
28
|
-
* Deferred providers are only loaded when one of their provided services is requested.
|
|
29
|
-
*/
|
|
9
|
+
/** Load only when one of `provides` is requested. */
|
|
30
10
|
static deferred = false;
|
|
31
|
-
/**
|
|
32
|
-
* The services provided by this provider (for deferred loading).
|
|
33
|
-
*/
|
|
11
|
+
/** Services this provider supplies, for deferred loading. */
|
|
34
12
|
static provides = [];
|
|
35
13
|
constructor(container) {
|
|
36
14
|
this.container = container;
|
|
37
15
|
}
|
|
38
|
-
/**
|
|
39
|
-
* Get the services provided by the provider.
|
|
40
|
-
*/
|
|
41
16
|
provides() {
|
|
42
17
|
return this.constructor.provides;
|
|
43
18
|
}
|
|
44
|
-
/**
|
|
45
|
-
* Check if this provider is deferred.
|
|
46
|
-
*/
|
|
47
19
|
isDeferred() {
|
|
48
20
|
return this.constructor.deferred;
|
|
49
21
|
}
|
|
@@ -57,13 +29,12 @@ var ProviderManager = class {
|
|
|
57
29
|
registered = /* @__PURE__ */ new Set();
|
|
58
30
|
booted = /* @__PURE__ */ new Set();
|
|
59
31
|
deferredProviders = /* @__PURE__ */ new Map();
|
|
32
|
+
/** Per service, the boot of an already-activated deferred provider, so a later loadDeferredProvider() awaits that boot */
|
|
33
|
+
deferredActivations = /* @__PURE__ */ new Map();
|
|
60
34
|
allBooted = false;
|
|
61
35
|
constructor(container) {
|
|
62
36
|
this.container = container;
|
|
63
37
|
}
|
|
64
|
-
/**
|
|
65
|
-
* Register a provider.
|
|
66
|
-
*/
|
|
67
38
|
register(providerOrClass) {
|
|
68
39
|
if (this.allBooted) {
|
|
69
40
|
const name = providerOrClass instanceof ServiceProvider ? providerOrClass.constructor.name : providerOrClass.name;
|
|
@@ -75,65 +46,58 @@ var ProviderManager = class {
|
|
|
75
46
|
else this.providers.push(provider);
|
|
76
47
|
return this;
|
|
77
48
|
}
|
|
78
|
-
/**
|
|
79
|
-
* Register multiple providers.
|
|
80
|
-
*/
|
|
81
49
|
registerMany(providers) {
|
|
82
50
|
for (const provider of providers) this.register(provider);
|
|
83
51
|
return this;
|
|
84
52
|
}
|
|
85
|
-
/**
|
|
86
|
-
* Register all non-deferred providers.
|
|
87
|
-
*/
|
|
88
53
|
async registerAll() {
|
|
89
54
|
for (const provider of this.providers) if (!this.registered.has(provider)) {
|
|
90
55
|
await provider.register();
|
|
91
56
|
this.registered.add(provider);
|
|
92
57
|
}
|
|
93
58
|
}
|
|
94
|
-
/**
|
|
95
|
-
* Boot all registered providers.
|
|
96
|
-
*/
|
|
97
59
|
async bootAll() {
|
|
98
60
|
for (const provider of this.providers) if (!this.booted.has(provider) && this.registered.has(provider)) {
|
|
99
61
|
await provider.boot?.();
|
|
100
62
|
this.booted.add(provider);
|
|
101
63
|
}
|
|
102
64
|
this.allBooted = true;
|
|
103
|
-
if (this.deferredProviders.size > 0) this.container.deferredProviderLoader = (service) => this.
|
|
65
|
+
if (this.deferredProviders.size > 0) this.container.deferredProviderLoader = (service) => this.activateDeferredProvider(service);
|
|
104
66
|
}
|
|
105
67
|
/**
|
|
106
|
-
*
|
|
68
|
+
* Register, boot, and unclaim a deferred provider's services. Resolves once
|
|
69
|
+
* boot() has finished, also when Container.make() already activated it.
|
|
107
70
|
*/
|
|
108
71
|
async loadDeferredProvider(service) {
|
|
72
|
+
await (this.activateDeferredProvider(service) ?? this.deferredActivations.get(service));
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Synchronous half of deferred loading, so a synchronous Container.make() can
|
|
76
|
+
* resolve the service: register() runs before this returns; boot() follows on the
|
|
77
|
+
* returned promise, which make() does not await (a boot failure is an unhandled
|
|
78
|
+
* rejection). Services are unclaimed up front so a re-entrant make() for a sibling
|
|
79
|
+
* service cannot register the provider twice.
|
|
80
|
+
*/
|
|
81
|
+
activateDeferredProvider(service) {
|
|
109
82
|
const provider = this.deferredProviders.get(service);
|
|
110
|
-
if (!provider) return;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
if (!this.booted.has(provider)) {
|
|
83
|
+
if (!provider) return void 0;
|
|
84
|
+
const registering = provider.register();
|
|
85
|
+
this.registered.add(provider);
|
|
86
|
+
this.providers.push(provider);
|
|
87
|
+
for (const providedService of provider.provides()) this.deferredProviders.delete(providedService);
|
|
88
|
+
const activation = Promise.resolve(registering).then(async () => {
|
|
117
89
|
await provider.boot?.();
|
|
118
90
|
this.booted.add(provider);
|
|
119
|
-
}
|
|
120
|
-
for (const providedService of provider.provides()) this.
|
|
91
|
+
});
|
|
92
|
+
for (const providedService of provider.provides()) this.deferredActivations.set(providedService, activation);
|
|
93
|
+
return activation;
|
|
121
94
|
}
|
|
122
|
-
/**
|
|
123
|
-
* Check if a service is provided by a deferred provider.
|
|
124
|
-
*/
|
|
125
95
|
isDeferredService(service) {
|
|
126
96
|
return this.deferredProviders.has(service);
|
|
127
97
|
}
|
|
128
|
-
/**
|
|
129
|
-
* Get all registered providers.
|
|
130
|
-
*/
|
|
131
98
|
getProviders() {
|
|
132
99
|
return [...this.providers];
|
|
133
100
|
}
|
|
134
|
-
/**
|
|
135
|
-
* Get all deferred services.
|
|
136
|
-
*/
|
|
137
101
|
getDeferredServices() {
|
|
138
102
|
return Array.from(this.deferredProviders.keys());
|
|
139
103
|
}
|
|
@@ -144,15 +108,10 @@ const LOOPBACK_HOSTNAMES = /* @__PURE__ */ new Set(["localhost", "[::1]"]);
|
|
|
144
108
|
const LOOPBACK_IPV4 = /^127\.\d+\.\d+\.\d+$/;
|
|
145
109
|
/**
|
|
146
110
|
* Whether an `Origin` header value belongs to the developer's own machine.
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
* domain resolves to 127.0.0.1 so the browser skips preflight.
|
|
152
|
-
*
|
|
153
|
-
* This is a *negative* filter only. A loopback `Origin` is never proof that
|
|
154
|
-
* the caller is local: browsers set the header honestly, but any other
|
|
155
|
-
* client sets it with one flag. Never use it to satisfy the peer check.
|
|
111
|
+
* Only a web page's request carries one; restricting it to loopback blocks
|
|
112
|
+
* cross-site requests and DNS rebinding (an attacker's domain resolving to
|
|
113
|
+
* 127.0.0.1 so the browser skips preflight). A *negative* filter only: any
|
|
114
|
+
* non-browser client sets the header with one flag, so never use it to satisfy the peer check.
|
|
156
115
|
*/
|
|
157
116
|
function isLoopbackOrigin(origin) {
|
|
158
117
|
try {
|
|
@@ -174,17 +133,10 @@ function isLoopbackAddress(address) {
|
|
|
174
133
|
}
|
|
175
134
|
/**
|
|
176
135
|
* The peer address of the current request, when the runtime exposes one.
|
|
177
|
-
*
|
|
178
|
-
* `
|
|
179
|
-
* the
|
|
180
|
-
*
|
|
181
|
-
* endpoints are never meant to sit behind a proxy.
|
|
182
|
-
*
|
|
183
|
-
* `undefined` means "this runtime did not tell us", not "the peer is
|
|
184
|
-
* remote": either the host never passed a `server` through (Node, Vercel's
|
|
185
|
-
* `app.fetch(request)`, in-process test requests), or `requestIP()` itself
|
|
186
|
-
* returned `null`, which Bun does for a socket that is already closed or is
|
|
187
|
-
* not TCP.
|
|
136
|
+
* `Bun.serve` passes `{ server }` through Hono's env, wired by
|
|
137
|
+
* `Application.listen()`; proxy headers are attacker-controlled and ignored.
|
|
138
|
+
* `undefined` means "the runtime did not say", not "remote": no `server` in env
|
|
139
|
+
* (Node, Vercel's `app.fetch(request)`, in-process tests), or `requestIP()` null (closed or non-TCP socket).
|
|
188
140
|
*/
|
|
189
141
|
function clientAddress(ctx) {
|
|
190
142
|
const env = ctx.env;
|
|
@@ -202,13 +154,10 @@ function allowsUnverifiedPeer() {
|
|
|
202
154
|
return typeof process !== "undefined" && process.env.GUREN_ALLOW_UNVERIFIED_PEER === "1";
|
|
203
155
|
}
|
|
204
156
|
/**
|
|
205
|
-
* Restricts an endpoint to the developer's own machine. `resource` names
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
* a peer that is present and not loopback is a remote caller, while a peer
|
|
210
|
-
* the runtime never reported is a deployment the guard cannot vouch for —
|
|
211
|
-
* the developer needs to know which one they are looking at.
|
|
157
|
+
* Restricts an endpoint to the developer's own machine. `resource` names the
|
|
158
|
+
* endpoint in the 403 body (e.g. "the MCP endpoint"). The two denials say
|
|
159
|
+
* different things on purpose: a present non-loopback peer is a remote caller,
|
|
160
|
+
* a peer the runtime never reported is a deployment the guard cannot vouch for.
|
|
212
161
|
*/
|
|
213
162
|
function createLoopbackGuard(resource) {
|
|
214
163
|
return async (ctx, next) => {
|