@guren/server 2.33.0 → 2.35.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/{Gate-COWQbA96.js → Gate-BHyDcDKo.js} +58 -10
- package/dist/{HttpException-BlQ2yEmT.js → HttpException-2tfZGamp.js} +8 -2
- package/dist/{McpServiceProvider-BDDr-7lh.js → McpServiceProvider-CXOokGax.js} +1 -1
- package/dist/{Resource-LQT1L4j0.js → Resource-y-7zzZSB.js} +43 -32
- package/dist/agent/scopes.d.ts +7 -0
- package/dist/{api-token-BbgDEd6j.js → api-token-1-INqeVU.js} +187 -2
- package/dist/auth/AuthManager.d.ts +4 -1
- package/dist/auth/TokenGuard.d.ts +4 -1
- package/dist/auth/api-token.d.ts +11 -1
- package/dist/auth/index.js +2 -2
- package/dist/{auth-DRMeSwev.js → auth-CO9MlQNE.js} +16 -24
- package/dist/authorization/Gate.d.ts +9 -5
- package/dist/authorization/index.js +2 -2
- package/dist/{authorization-DEHuBps5.js → authorization-rxx6aprN.js} +1 -1
- package/dist/broadcasting/index.js +1 -1
- package/dist/{broadcasting-CcevVE5Y.js → broadcasting-D04a3R02.js} +3 -2
- package/dist/{context-af2n5abO.js → context--l2HdOhy.js} +1 -1
- package/dist/{dev-banner-CSjrSNZi.js → dev-banner-BUrHz-LF.js} +7 -3
- package/dist/errors/ExceptionHandler.d.ts +7 -2
- package/dist/errors/HttpException.d.ts +6 -0
- package/dist/errors/debug-page.d.ts +1 -1
- package/dist/errors/exceptions/NotFoundHttpException.d.ts +2 -0
- package/dist/errors/redact-query-params.d.ts +16 -0
- package/dist/errors/wants-html.d.ts +7 -0
- package/dist/{errors-JpkcCjjn.js → errors-C8neC8go.js} +1 -1
- package/dist/health/index.js +1 -1
- package/dist/{health-Bg0Xj3aD.js → health-Wi_05kkf.js} +2 -1
- package/dist/http/Application.d.ts +12 -0
- package/dist/http/dev-banner.d.ts +6 -1
- package/dist/http/middleware/csrf.d.ts +1 -1
- package/dist/http/middleware/redirect-safety.d.ts +8 -0
- package/dist/index.js +247 -275
- package/dist/internal/agent-principal.d.ts +12 -3
- package/dist/internal/redact-query-params.d.ts +1 -0
- package/dist/internal/redact-query-params.js +2 -0
- package/dist/internal/testing.d.ts +2 -1
- package/dist/internal/testing.js +4 -4
- package/dist/lambda/index.js +3 -2
- package/dist/mcp/index.js +1 -1
- package/dist/mvc/Controller.d.ts +5 -5
- package/dist/mvc/inertia/InertiaEngine.d.ts +6 -0
- package/dist/notifications/index.js +1 -1
- package/dist/{notifications-R7Uj-aT7.js → notifications-DV5Yr6Fl.js} +2 -1
- package/dist/providers/InertiaServiceProvider.d.ts +7 -0
- package/dist/queue/index.js +1 -1
- package/dist/{queue-CO07wib_.js → queue-K4Bi6NRy.js} +17 -11
- package/dist/redact-query-params-Ba-sAfcP.js +106 -0
- package/dist/runtime/index.js +1 -1
- package/dist/{runtime-error-capture-DzllKc0d.js → runtime-error-capture-DLRXwp0d.js} +2 -2
- package/dist/{runtime-errors-D229wyoc.js → runtime-errors-Dh7nA2-p.js} +1 -1
- package/dist/scheduling/index.js +1 -1
- package/dist/{scheduling-DNV5tj44.js → scheduling-iLkx4gID.js} +2 -1
- package/dist/support/default-headers.d.ts +6 -0
- package/package.json +5 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The principal handoff seam (RFC 0017 §2)
|
|
3
|
-
* and the auth context reads — in either of
|
|
4
|
-
* whole layer. Keyed on the **object identity** of the `Request` handed to
|
|
2
|
+
* The principal handoff seam (RFC 0017 §2) and the scope-gated dispatch mark,
|
|
3
|
+
* a leaf module the pipeline writes and the auth context reads — in either of
|
|
4
|
+
* them, one would import the other's whole layer. Keyed on the **object identity** of the `Request` handed to
|
|
5
5
|
* `app.fetch`, so it has no wire representation to forge, needs no
|
|
6
6
|
* `AsyncLocalStorage` (identical on workerd and Bun), and is collected with the
|
|
7
7
|
* request. `new Request(original)` and `clone()` carry nothing: that is the
|
|
@@ -30,3 +30,12 @@ export interface InstalledAgentPrincipal {
|
|
|
30
30
|
export declare function installAgentPrincipal(request: Request, value: InstalledAgentPrincipal): Request;
|
|
31
31
|
/** The principal installed on this exact request object, or `undefined`. */
|
|
32
32
|
export declare function readAgentPrincipal(request: Request): InstalledAgentPrincipal | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Mark `request` as a tool call the pipeline scope-gated, returning that same
|
|
35
|
+
* object: a token granting only agent tools authenticates such a request and no
|
|
36
|
+
* other. Not `markDispatchedToolRequest()`, which `buildToolRequest` sets for
|
|
37
|
+
* un-gated callers too (`guren tool:call`, `TestApp.agent()`, plugin-webmcp).
|
|
38
|
+
*/
|
|
39
|
+
export declare function markAgentDispatch(request: Request): Request;
|
|
40
|
+
/** Whether the pipeline dispatched this exact request object. */
|
|
41
|
+
export declare function isAgentDispatch(request: Request): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { redactQueryParams, redactedMessage } from '../errors/redact-query-params.js';
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export { Controller } from '../mvc/Controller.js';
|
|
9
9
|
export type { InertiaPageContractLike, InertiaResponseOptions } from '../mvc/Controller.js';
|
|
10
|
-
export { acceptsJson, buildInertiaPage, INERTIA_VARY, serializePage } from '../mvc/inertia/InertiaEngine.js';
|
|
10
|
+
export { acceptsJson, buildInertiaPage, INERTIA_VARY, mergeInertiaVary, serializePage } from '../mvc/inertia/InertiaEngine.js';
|
|
11
|
+
export { withDefaultHeaders } from '../support/default-headers.js';
|
|
11
12
|
export { Resource, JsonResource, collect } from '../http/resources/Resource.js';
|
|
12
13
|
export { ValidationException } from '../errors/exceptions/ValidationException.js';
|
|
13
14
|
export { AuthenticationException } from '../errors/exceptions/AuthenticationException.js';
|
package/dist/internal/testing.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { _ as INERTIA_VARY, f as definePlugin, i as Controller, n as Resource, r as collect, t as JsonResource, u as defineModule, v as acceptsJson, x as
|
|
1
|
+
import { S as serializePage, T as withDefaultHeaders, _ as INERTIA_VARY, f as definePlugin, i as Controller, n as Resource, r as collect, t as JsonResource, u as defineModule, v as acceptsJson, x as mergeInertiaVary, y as buildInertiaPage } from "../Resource-y-7zzZSB.js";
|
|
2
2
|
import { r as formatValidationErrors } from "../request-CLOYytGP.js";
|
|
3
|
-
import { n as ValidationException } from "../errors-
|
|
3
|
+
import { n as ValidationException } from "../errors-C8neC8go.js";
|
|
4
4
|
import { n as ServiceProvider } from "../ServiceProvider-G0YclITd.js";
|
|
5
|
-
import { o as AuthenticationException } from "../context
|
|
6
|
-
export { AuthenticationException, Controller, INERTIA_VARY, JsonResource, Resource, ServiceProvider, ValidationException, acceptsJson, buildInertiaPage, collect, defineModule, definePlugin, formatValidationErrors, serializePage };
|
|
5
|
+
import { o as AuthenticationException } from "../context--l2HdOhy.js";
|
|
6
|
+
export { AuthenticationException, Controller, INERTIA_VARY, JsonResource, Resource, ServiceProvider, ValidationException, acceptsJson, buildInertiaPage, collect, defineModule, definePlugin, formatValidationErrors, mergeInertiaVary, serializePage, withDefaultHeaders };
|
package/dist/lambda/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { n as detectServerlessRuntime } from "../serverless-D96rJb6x.js";
|
|
2
|
+
import { n as redactedMessage } from "../redact-query-params-Ba-sAfcP.js";
|
|
2
3
|
import { a as getJob } from "../Job-0Prk8k0z.js";
|
|
3
4
|
import { t as deserializeQueuedJob } from "../serialize-CKXek0Tr.js";
|
|
4
5
|
import { handle } from "hono/aws-lambda";
|
|
@@ -62,7 +63,7 @@ async function processSqsRecord(record) {
|
|
|
62
63
|
msg: "Error in job.failed() handler",
|
|
63
64
|
messageId: record.messageId,
|
|
64
65
|
job: job.name,
|
|
65
|
-
error: hookError
|
|
66
|
+
error: redactedMessage(hookError)
|
|
66
67
|
});
|
|
67
68
|
}
|
|
68
69
|
throw error;
|
|
@@ -75,7 +76,7 @@ async function processSqsRecord(record) {
|
|
|
75
76
|
queue: job?.queue,
|
|
76
77
|
attempt: job?.attempts,
|
|
77
78
|
maxAttempts: job?.maxAttempts,
|
|
78
|
-
error: error
|
|
79
|
+
error: redactedMessage(error)
|
|
79
80
|
});
|
|
80
81
|
throw error;
|
|
81
82
|
}
|
package/dist/mcp/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as McpServiceProvider } from "../McpServiceProvider-
|
|
1
|
+
import { t as McpServiceProvider } from "../McpServiceProvider-CXOokGax.js";
|
|
2
2
|
export { McpServiceProvider };
|
package/dist/mvc/Controller.d.ts
CHANGED
|
@@ -132,11 +132,11 @@ export declare class Controller {
|
|
|
132
132
|
/** Get the authenticated user ID from the API token. */
|
|
133
133
|
protected apiTokenUserId(): string | number;
|
|
134
134
|
/**
|
|
135
|
-
* Authorize the current user (or guest) for an ability; throws
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
135
|
+
* Authorize the current user (or guest) for an ability; throws AuthorizationException
|
|
136
|
+
* (403) when denied. An ORM record is a plain object, so pass its class beside it:
|
|
137
|
+
* `this.authorize('update', [Post, post])`; an ability with no record takes `Post`
|
|
138
|
+
* or `[Post]`. A bare record or another array that resolves no policy and no gate
|
|
139
|
+
* throws an Error rather than denying.
|
|
140
140
|
*/
|
|
141
141
|
protected authorize(ability: string, ...args: unknown[]): Promise<void>;
|
|
142
142
|
/** Check an ability, answering a denial with `false` rather than a 403: `await this.can('update', [Post, post])`. */
|
|
@@ -115,6 +115,12 @@ export interface InertiaRenderResult {
|
|
|
115
115
|
* partial response to the next full visit.
|
|
116
116
|
*/
|
|
117
117
|
export declare const INERTIA_VARY = "Accept, X-Inertia, X-Inertia-Partial-Component, X-Inertia-Partial-Data, X-Inertia-Partial-Except";
|
|
118
|
+
/**
|
|
119
|
+
* Adds each {@link INERTIA_VARY} token the response's `Vary` does not list yet, so a
|
|
120
|
+
* caller's own `Vary` extends the engine's rather than replacing it. `*` already
|
|
121
|
+
* varies on everything and is left alone.
|
|
122
|
+
*/
|
|
123
|
+
export declare function mergeInertiaVary(headers: Headers): Headers;
|
|
118
124
|
/**
|
|
119
125
|
* {@link inertia} plus the page it sent, for a caller that records the props
|
|
120
126
|
* actually resolved (`Controller.inertia()`'s response marker). The version
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as NotificationManager, c as setNotificationManager, d as getNotification, f as registerNotification, i as MailChannel, l as resolveNotifiableType, n as SlackChannel, o as createNotificationManager, p as Notification, r as DatabaseChannel, s as getNotificationManager, t as MemoryChannel, u as clearNotificationRegistry } from "../notifications-
|
|
1
|
+
import { a as NotificationManager, c as setNotificationManager, d as getNotification, f as registerNotification, i as MailChannel, l as resolveNotifiableType, n as SlackChannel, o as createNotificationManager, p as Notification, r as DatabaseChannel, s as getNotificationManager, t as MemoryChannel, u as clearNotificationRegistry } from "../notifications-DV5Yr6Fl.js";
|
|
2
2
|
export { DatabaseChannel, MailChannel, MemoryChannel, Notification, NotificationManager, SlackChannel, clearNotificationRegistry, createNotificationManager, getNotification, getNotificationManager, registerNotification, resolveNotifiableType, setNotificationManager };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { g as warnDeprecatedSetter, h as warnDeprecatedGetter, i as bindAmbient, n as ambientBinding } from "./default-application-s9SE-Er7.js";
|
|
2
|
+
import { t as redactQueryParams } from "./redact-query-params-Ba-sAfcP.js";
|
|
2
3
|
import { l as registerJob, p as reportRegistryCollision, t as Job } from "./Job-0Prk8k0z.js";
|
|
3
4
|
import { t as parseMailAddress } from "./address-D0Iq-XIH.js";
|
|
4
5
|
//#region src/notifications/Notification.ts
|
|
@@ -136,7 +137,7 @@ var NotificationManager = class {
|
|
|
136
137
|
try {
|
|
137
138
|
await this.channel(channelName).send(notifiable, notification);
|
|
138
139
|
} catch (error) {
|
|
139
|
-
console.error(`Failed to send notification via ${channelName}:`, error);
|
|
140
|
+
console.error(`Failed to send notification via ${channelName}:`, redactQueryParams(error));
|
|
140
141
|
throw error;
|
|
141
142
|
}
|
|
142
143
|
}));
|
|
@@ -8,6 +8,13 @@ export declare class InertiaServiceProvider extends ServiceProvider {
|
|
|
8
8
|
boot(): void;
|
|
9
9
|
/** ValidationException on Inertia requests; others fall through to JSON 422. */
|
|
10
10
|
private registerValidationRenderer;
|
|
11
|
+
/**
|
|
12
|
+
* The request's host, and the one `APP_URL` names (what `config/http.ts`'s host
|
|
13
|
+
* authorization and the auth scaffold's links key on): a proxy that does not
|
|
14
|
+
* forward `Host` hands the app its upstream address instead. `X-Forwarded-Host`
|
|
15
|
+
* is not read, since no app-wide trusted-proxy setting says when it is genuine.
|
|
16
|
+
*/
|
|
17
|
+
private refererHosts;
|
|
11
18
|
/**
|
|
12
19
|
* Auto-inject flashed `errors` into shared props. Scoped to this app's
|
|
13
20
|
* container so a second Application booted in the same process keeps its
|
package/dist/queue/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { a as getJob, d as resolveQueueDriver, f as setQueueDriver, l as registerJob, n as clearJobRegistry, o as getQueueDriver, r as clearQueueDriver, s as getRegisteredJobs, t as Job, u as resolveJobName } from "../Job-0Prk8k0z.js";
|
|
2
|
-
import { a as processJob, c as RedisDriver, i as Worker, l as SyncDriver, n as createQueueManager, o as SqsDriver, r as FailedJobReporter, s as createSqsAdapter, t as QueueManager, u as MemoryDriver } from "../queue-
|
|
2
|
+
import { a as processJob, c as RedisDriver, i as Worker, l as SyncDriver, n as createQueueManager, o as SqsDriver, r as FailedJobReporter, s as createSqsAdapter, t as QueueManager, u as MemoryDriver } from "../queue-K4Bi6NRy.js";
|
|
3
3
|
export { FailedJobReporter, Job, MemoryDriver, QueueManager, RedisDriver, SqsDriver, SyncDriver, Worker, clearJobRegistry, clearQueueDriver, createQueueManager, createSqsAdapter, getJob, getQueueDriver, getRegisteredJobs, processJob, registerJob, resolveJobName, resolveQueueDriver, setQueueDriver };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { t as warnOnce } from "./warn-once-p-IlMjra.js";
|
|
2
|
+
import { n as redactedMessage, t as redactQueryParams } from "./redact-query-params-Ba-sAfcP.js";
|
|
2
3
|
import { a as getJob, i as enqueueJob } from "./Job-0Prk8k0z.js";
|
|
3
4
|
import { t as describeDriverMap } from "./driver-map-BhITaLcy.js";
|
|
4
5
|
import { t as deserializeQueuedJob } from "./serialize-CKXek0Tr.js";
|
|
@@ -32,11 +33,12 @@ var MemoryDriver = class {
|
|
|
32
33
|
this.jobs.delete(jobId);
|
|
33
34
|
}
|
|
34
35
|
async fail(job, error) {
|
|
36
|
+
const { message, stack } = redactQueryParams(error);
|
|
35
37
|
const failedJob = {
|
|
36
38
|
...job,
|
|
37
39
|
failedAt: /* @__PURE__ */ new Date(),
|
|
38
|
-
error:
|
|
39
|
-
stack
|
|
40
|
+
error: message,
|
|
41
|
+
stack
|
|
40
42
|
};
|
|
41
43
|
this.failedJobs.set(job.id, failedJob);
|
|
42
44
|
this.jobs.delete(job.id);
|
|
@@ -117,11 +119,12 @@ var SyncDriver = class {
|
|
|
117
119
|
}
|
|
118
120
|
async delete() {}
|
|
119
121
|
async fail(job, error) {
|
|
122
|
+
const { message, stack } = redactQueryParams(error);
|
|
120
123
|
this.failedJobs.set(job.id, {
|
|
121
124
|
...job,
|
|
122
125
|
failedAt: /* @__PURE__ */ new Date(),
|
|
123
|
-
error:
|
|
124
|
-
stack
|
|
126
|
+
error: message,
|
|
127
|
+
stack
|
|
125
128
|
});
|
|
126
129
|
}
|
|
127
130
|
async size() {
|
|
@@ -332,7 +335,8 @@ var RedisDriver = class {
|
|
|
332
335
|
await this.run("gurenQueueDelete", this.jobKey(jobId), jobId, reservationToken ?? "", this.prefix);
|
|
333
336
|
}
|
|
334
337
|
async fail(job, error) {
|
|
335
|
-
|
|
338
|
+
const { message, stack } = redactQueryParams(error);
|
|
339
|
+
await this.run("gurenQueueFail", this.jobKey(job.id), this.pendingKey(job.queue), this.reservedKey(job.queue), this.failedKey(job.queue), job.id, job.reservationToken ?? "", (/* @__PURE__ */ new Date()).toISOString(), message, stack ?? "", job.attempts);
|
|
336
340
|
}
|
|
337
341
|
async size(queue) {
|
|
338
342
|
return this.redis.zcard(this.pendingKey(queue));
|
|
@@ -554,11 +558,12 @@ var SqsDriver = class {
|
|
|
554
558
|
await this.acknowledge(jobId);
|
|
555
559
|
}
|
|
556
560
|
async fail(job, error) {
|
|
561
|
+
const { message, stack } = redactQueryParams(error);
|
|
557
562
|
const failedJob = {
|
|
558
563
|
...job,
|
|
559
564
|
failedAt: /* @__PURE__ */ new Date(),
|
|
560
|
-
error:
|
|
561
|
-
stack
|
|
565
|
+
error: message,
|
|
566
|
+
stack
|
|
562
567
|
};
|
|
563
568
|
this.failedJobs.set(job.id, failedJob);
|
|
564
569
|
try {
|
|
@@ -723,7 +728,8 @@ var Worker = class {
|
|
|
723
728
|
this.currentJob = null;
|
|
724
729
|
}
|
|
725
730
|
}
|
|
726
|
-
async handleFailedJob(job,
|
|
731
|
+
async handleFailedJob(job, thrown, JobClass) {
|
|
732
|
+
const error = redactQueryParams(thrown);
|
|
727
733
|
const willRetry = job.attempts < job.maxAttempts;
|
|
728
734
|
if (willRetry) {
|
|
729
735
|
const delay = JobClass.calculateRetryDelay(job.attempts);
|
|
@@ -733,9 +739,9 @@ var Worker = class {
|
|
|
733
739
|
await this.driver.fail(job, error);
|
|
734
740
|
try {
|
|
735
741
|
const instance = this.instantiate(JobClass);
|
|
736
|
-
if (instance.failed) await instance.failed(job.payload,
|
|
742
|
+
if (instance.failed) await instance.failed(job.payload, thrown);
|
|
737
743
|
} catch (failedError) {
|
|
738
|
-
console.error(`Error in job.failed() handler:`, failedError);
|
|
744
|
+
console.error(`Error in job.failed() handler:`, redactQueryParams(failedError));
|
|
739
745
|
}
|
|
740
746
|
}
|
|
741
747
|
console.error(JSON.stringify({
|
|
@@ -821,7 +827,7 @@ function defaultLogHandler(info) {
|
|
|
821
827
|
attempt: info.attempt,
|
|
822
828
|
maxAttempts: info.maxAttempts,
|
|
823
829
|
willRetry: info.willRetry,
|
|
824
|
-
error: info.error
|
|
830
|
+
error: redactedMessage(info.error),
|
|
825
831
|
failedAt: info.failedAt.toISOString()
|
|
826
832
|
}));
|
|
827
833
|
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
//#region src/errors/redact-query-params.ts
|
|
2
|
+
/**
|
|
3
|
+
* Strips SQL bound parameters out of an exception before anything prints it:
|
|
4
|
+
* drizzle's `DrizzleQueryError` writes `Failed query: <sql>\nparams: <values>`
|
|
5
|
+
* into its message and stack and keeps the values on `.params`, so a failed
|
|
6
|
+
* INSERT would hand a password hash to the 500 body, the debug page and the log.
|
|
7
|
+
* The shape is detected structurally, since the app may load its own drizzle.
|
|
8
|
+
*/
|
|
9
|
+
const QUERY_PREFIX = "Failed query: ";
|
|
10
|
+
const PARAMS_SEPARATOR = "\nparams: ";
|
|
11
|
+
const REDACTED = "[redacted";
|
|
12
|
+
const PARAM_KEYS = /* @__PURE__ */ new Set([
|
|
13
|
+
"params",
|
|
14
|
+
"parameters",
|
|
15
|
+
"args"
|
|
16
|
+
]);
|
|
17
|
+
function marker(count) {
|
|
18
|
+
return count === void 0 ? `${REDACTED}]` : `${REDACTED} ${count} value${count === 1 ? "" : "s"}]`;
|
|
19
|
+
}
|
|
20
|
+
/** drizzle's own shape, which says where the values start and how many there are. */
|
|
21
|
+
function drizzleShape(error) {
|
|
22
|
+
const { query, params } = error;
|
|
23
|
+
return typeof query === "string" && Array.isArray(params) ? {
|
|
24
|
+
query,
|
|
25
|
+
count: params.length
|
|
26
|
+
} : void 0;
|
|
27
|
+
}
|
|
28
|
+
/** mysql2 formats the values into the statement client-side and keeps it on `err.sql`. */
|
|
29
|
+
function isMysqlDriverError(error) {
|
|
30
|
+
return typeof error.sql === "string" && ("sqlState" in error || "sqlMessage" in error);
|
|
31
|
+
}
|
|
32
|
+
function isSensitive(error, key, value) {
|
|
33
|
+
if (key === "sql") return isMysqlDriverError(error);
|
|
34
|
+
return PARAM_KEYS.has(key) && Array.isArray(value) && typeof error.query === "string";
|
|
35
|
+
}
|
|
36
|
+
/** A message is cut to its end; a stack only up to its first frame. */
|
|
37
|
+
function redactText(text, shape, stack = false) {
|
|
38
|
+
const prefix = shape ? `${QUERY_PREFIX}${shape.query}${PARAMS_SEPARATOR}` : void 0;
|
|
39
|
+
const known = prefix ? text.indexOf(prefix) : -1;
|
|
40
|
+
let start;
|
|
41
|
+
if (known !== -1) start = known + prefix.length;
|
|
42
|
+
else {
|
|
43
|
+
const query = text.indexOf(QUERY_PREFIX);
|
|
44
|
+
const separator = query === -1 ? -1 : text.indexOf(PARAMS_SEPARATOR, query);
|
|
45
|
+
if (separator === -1) return text;
|
|
46
|
+
start = separator + 9;
|
|
47
|
+
}
|
|
48
|
+
if (text.startsWith(REDACTED, start)) return text;
|
|
49
|
+
const frames = stack ? text.indexOf("\n at ", start) : -1;
|
|
50
|
+
return text.slice(0, start) + marker(known !== -1 ? shape.count : void 0) + text.slice(frames === -1 ? text.length : frames);
|
|
51
|
+
}
|
|
52
|
+
function redactStack(error, message) {
|
|
53
|
+
const { stack } = error;
|
|
54
|
+
if (typeof stack !== "string") return stack;
|
|
55
|
+
const at = message === error.message ? -1 : stack.indexOf(error.message);
|
|
56
|
+
if (at !== -1) return stack.slice(0, at) + message + stack.slice(at + error.message.length);
|
|
57
|
+
return redactText(stack, drizzleShape(error), true);
|
|
58
|
+
}
|
|
59
|
+
function needsRedaction(error, seen) {
|
|
60
|
+
if (seen.has(error)) return false;
|
|
61
|
+
seen.add(error);
|
|
62
|
+
if (Reflect.ownKeys(error).some((key) => {
|
|
63
|
+
const descriptor = Object.getOwnPropertyDescriptor(error, key);
|
|
64
|
+
return "value" in descriptor && isSensitive(error, key, descriptor.value);
|
|
65
|
+
})) return true;
|
|
66
|
+
if (redactText(error.message) !== error.message) return true;
|
|
67
|
+
if (typeof error.stack === "string" && redactText(error.stack, void 0, true) !== error.stack) return true;
|
|
68
|
+
const { cause } = error;
|
|
69
|
+
return cause instanceof Error && needsRedaction(cause, seen);
|
|
70
|
+
}
|
|
71
|
+
function redactCopy(error, seen) {
|
|
72
|
+
const existing = seen.get(error);
|
|
73
|
+
if (existing) return existing;
|
|
74
|
+
const copy = /* @__PURE__ */ new Error();
|
|
75
|
+
Object.setPrototypeOf(copy, Object.getPrototypeOf(error));
|
|
76
|
+
seen.set(error, copy);
|
|
77
|
+
const message = redactText(error.message, drizzleShape(error));
|
|
78
|
+
for (const key of Reflect.ownKeys(error)) {
|
|
79
|
+
const descriptor = Object.getOwnPropertyDescriptor(error, key);
|
|
80
|
+
if ("value" in descriptor) {
|
|
81
|
+
const { value } = descriptor;
|
|
82
|
+
if (key === "message") descriptor.value = message;
|
|
83
|
+
else if (key === "stack") descriptor.value = redactStack(error, message);
|
|
84
|
+
else if (key === "cause" && value instanceof Error) descriptor.value = redactCopy(value, seen);
|
|
85
|
+
else if (isSensitive(error, key, value)) descriptor.value = marker(Array.isArray(value) ? value.length : void 0);
|
|
86
|
+
}
|
|
87
|
+
Object.defineProperty(copy, key, descriptor);
|
|
88
|
+
}
|
|
89
|
+
return copy;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The value itself unless it is an error that, or whose cause chain, carries
|
|
93
|
+
* bound parameters; then a copy with the same prototype and own properties
|
|
94
|
+
* whose message, stack, parameter fields and causes are redacted. Being a copy,
|
|
95
|
+
* it carries no `#private` field a custom renderer or `toResponse()` reads.
|
|
96
|
+
*/
|
|
97
|
+
function redactQueryParams(error) {
|
|
98
|
+
if (!(error instanceof Error) || !needsRedaction(error, /* @__PURE__ */ new Set())) return error;
|
|
99
|
+
return redactCopy(error, /* @__PURE__ */ new Map());
|
|
100
|
+
}
|
|
101
|
+
/** `error.message` with bound parameters redacted, for a log line that prints the message alone. */
|
|
102
|
+
function redactedMessage(error) {
|
|
103
|
+
return error instanceof Error ? redactQueryParams(error).message : void 0;
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
export { redactedMessage as n, redactQueryParams as t };
|
package/dist/runtime/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { a as trimTrailingSlashes, n as isRealPathWithin, t as isPathWithin } fr
|
|
|
2
2
|
import { n as parseImportMap } from "../inertia-defaults-BjrcT7za.js";
|
|
3
3
|
import { n as hash } from "../Hash-D2DFd8xX.js";
|
|
4
4
|
import { a as getManifestCss, c as isViteProduction, d as startViteDevServer, i as clientManifestCandidates, l as loadViteManifest, o as getManifestFile, r as PUBLIC_ASSETS_URL_PREFIX, u as normalizeDevServerUrl } from "../vite-manifest-DO0pU1vm.js";
|
|
5
|
-
import { r as logDevServerBanner, t as GUREN_ASCII_ART } from "../dev-banner-
|
|
5
|
+
import { r as logDevServerBanner, t as GUREN_ASCII_ART } from "../dev-banner-BUrHz-LF.js";
|
|
6
6
|
import { createRequire } from "node:module";
|
|
7
7
|
import { dirname, extname, join, resolve } from "node:path";
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as createLoopbackGuard } from "./loopback-guard-CG8xB4v0.js";
|
|
2
1
|
import { r as tryGetRequestContainer } from "./request-container-BbuH0JJy.js";
|
|
2
|
+
import { t as createLoopbackGuard } from "./loopback-guard-CG8xB4v0.js";
|
|
3
3
|
//#region src/mcp/endpoint.ts
|
|
4
4
|
const MCP_ENDPOINT_PATH = "/_guren/mcp";
|
|
5
5
|
/** Where the Dev Center saves a plan review's feedback (RFC 0030 §8), its one write route. */
|
|
@@ -46,7 +46,7 @@ let loading;
|
|
|
46
46
|
* a call no define can settle. `tests/mcp/runtime-errors.test.ts` pins the form.
|
|
47
47
|
*/
|
|
48
48
|
function loadRuntimeErrorsModule() {
|
|
49
|
-
if (typeof process !== "undefined" && process.env.NODE_ENV !== "production" && isMcpEndpointEnabled()) return loading ??= import("./runtime-errors-
|
|
49
|
+
if (typeof process !== "undefined" && process.env.NODE_ENV !== "production" && isMcpEndpointEnabled()) return loading ??= import("./runtime-errors-Dh7nA2-p.js");
|
|
50
50
|
}
|
|
51
51
|
/** Only ExceptionHandler calls this, after applying its dontReport policy. */
|
|
52
52
|
function captureRuntimeError(error, ctx, status) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as RUNTIME_ERRORS_PATH, t as RUNTIME_ERRORS_BINDING } from "./runtime-error-capture-DzllKc0d.js";
|
|
2
1
|
import { r as tryGetRequestContainer } from "./request-container-BbuH0JJy.js";
|
|
2
|
+
import { n as RUNTIME_ERRORS_PATH, t as RUNTIME_ERRORS_BINDING } from "./runtime-error-capture-DLRXwp0d.js";
|
|
3
3
|
import { realpathSync, statSync } from "node:fs";
|
|
4
4
|
import { routePath } from "hono/route";
|
|
5
5
|
//#region src/mcp/runtime-errors.ts
|
package/dist/scheduling/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as ScheduledTask, c as isDue, d as parseCron, f as toTimezone, i as Schedule, l as isDueInTimezone, n as createScheduler, o as getNextOccurrence, p as MemorySchedulerLock, r as PendingSchedule, s as getNextOccurrences, t as Scheduler, u as matchesCron } from "../scheduling-
|
|
1
|
+
import { a as ScheduledTask, c as isDue, d as parseCron, f as toTimezone, i as Schedule, l as isDueInTimezone, n as createScheduler, o as getNextOccurrence, p as MemorySchedulerLock, r as PendingSchedule, s as getNextOccurrences, t as Scheduler, u as matchesCron } from "../scheduling-iLkx4gID.js";
|
|
2
2
|
export { MemorySchedulerLock, PendingSchedule, Schedule, ScheduledTask, Scheduler, createScheduler, getNextOccurrence, getNextOccurrences, isDue, isDueInTimezone, matchesCron, parseCron, toTimezone };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { t as warnOnce } from "./warn-once-p-IlMjra.js";
|
|
2
|
+
import { n as redactedMessage } from "./redact-query-params-Ba-sAfcP.js";
|
|
2
3
|
import { n as isHotReloadRuntime, t as claimHotDisposable } from "./hot-disposables-W2fH-GID.js";
|
|
3
4
|
//#region src/scheduling/MemorySchedulerLock.ts
|
|
4
5
|
/**
|
|
@@ -700,7 +701,7 @@ function createScheduler(options) {
|
|
|
700
701
|
return new Scheduler(options);
|
|
701
702
|
}
|
|
702
703
|
function describe(error) {
|
|
703
|
-
return error
|
|
704
|
+
return redactedMessage(error) ?? String(error);
|
|
704
705
|
}
|
|
705
706
|
//#endregion
|
|
706
707
|
export { ScheduledTask as a, isDue as c, parseCron as d, toTimezone as f, Schedule as i, isDueInTimezone as l, createScheduler as n, getNextOccurrence as o, MemorySchedulerLock as p, PendingSchedule as r, getNextOccurrences as s, Scheduler as t, matchesCron as u };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The caller's headers with each default set only where the caller named none. Header
|
|
3
|
+
* names are case-insensitive, so a caller's `content-type` replaces `Content-Type`
|
|
4
|
+
* rather than joining it; spreading a `Headers` or a pair list would drop it.
|
|
5
|
+
*/
|
|
6
|
+
export declare function withDefaultHeaders(init: HeadersInit | undefined, defaults: Record<string, string>): Headers;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guren/server",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.35.0",
|
|
4
4
|
"description": "HTTP layer of the Guren framework, on Hono: routing, controllers, middleware, auth, sessions, queues and the AWS Lambda adapter. Applications import it through @guren/core.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"guren",
|
|
@@ -148,6 +148,10 @@
|
|
|
148
148
|
"types": "./dist/internal/inertia-page.d.ts",
|
|
149
149
|
"default": "./dist/internal/inertia-page.js"
|
|
150
150
|
},
|
|
151
|
+
"./internal/redact-query-params": {
|
|
152
|
+
"types": "./dist/internal/redact-query-params.d.ts",
|
|
153
|
+
"default": "./dist/internal/redact-query-params.js"
|
|
154
|
+
},
|
|
151
155
|
"./jsx-runtime": {
|
|
152
156
|
"types": "./dist/jsx-runtime.d.ts",
|
|
153
157
|
"default": "./dist/jsx-runtime.js"
|