@guren/server 2.23.3 → 2.24.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/DailyFileChannel-CTTPA0EF.js +114 -0
- package/dist/{DocsViewerServiceProvider-DWnlXx_y.js → DocsViewerServiceProvider-CIRNHQ2I.js} +2 -2
- package/dist/{authorization-0mCGUFoI.js → Gate-Cn1E6JnO.js} +3 -217
- package/dist/{Job-BVvaY-7p.js → Job-BVRCYuVY.js} +4 -10
- package/dist/McpServiceProvider-B-LioPSz.js +43 -0
- package/dist/Resource-BJhY4aF8.js +1035 -0
- package/dist/{loopback-guard-DT9gHF0F.js → ServiceProvider-DDW3MqQJ.js} +10 -68
- package/dist/agent/audit-file.d.ts +3 -0
- package/dist/agent/audit-sink.d.ts +16 -0
- package/dist/agent/call-budget.d.ts +22 -0
- package/dist/agent/events.d.ts +6 -6
- package/dist/api-token-BbgDEd6j.js +298 -0
- package/dist/audit-file-DocumbCr.js +29 -0
- package/dist/auth/index.js +2 -1
- package/dist/auth/oauth/index.d.ts +7 -0
- package/dist/{auth-Jp_MB8Il.js → auth-vFeem6uM.js} +8 -298
- package/dist/authorization/index.js +2 -1
- package/dist/authorization-BsMTG8P1.js +217 -0
- package/dist/broadcasting/index.js +1 -1
- package/dist/{broadcasting-DVfG2vgN.js → broadcasting-6o_CCfF0.js} +2 -1
- package/dist/config/define.d.ts +50 -0
- package/dist/config/env-reads.d.ts +12 -0
- package/dist/config/env.d.ts +122 -0
- package/dist/container/Container.d.ts +13 -2
- package/dist/container/ServiceProvider.d.ts +7 -0
- package/dist/container/bindings.d.ts +8 -0
- package/dist/{default-application-Chbrul_m.js → default-application-CMuAAsdf.js} +20 -31
- package/dist/deprecate-rL8jNpKX.js +31 -0
- package/dist/encryption/index.js +1 -1
- package/dist/{encryption-BRjZnshr.js → encryption-_GiNb0Ol.js} +2 -1
- package/dist/{endpoint-BXipU2Jj.js → endpoint-CTIzcagh.js} +1 -1
- package/dist/{endpoint-Dsw3Acvq.js → endpoint-Coq0K_6I.js} +1 -1
- package/dist/events/index.js +1 -1
- package/dist/{events-CaJKZ2qk.js → events-swsyfCzt.js} +1 -1
- package/dist/http/Application.d.ts +22 -0
- package/dist/http/vite-manifest.d.ts +5 -1
- package/dist/i18n/index.js +1 -1
- package/dist/i18n/injected-translations.d.ts +8 -0
- package/dist/i18n/loaders/JsonLoader.d.ts +3 -2
- package/dist/{i18n-DRo1g0AN.js → i18n-0bOJqFpX.js} +5 -3
- package/dist/index.d.ts +11 -0
- package/dist/index.js +526 -1075
- package/dist/inertia-defaults-BjrcT7za.js +30 -0
- package/dist/internal/request.d.ts +4 -3
- package/dist/internal/request.js +2 -1
- package/dist/internal/testing.d.ts +17 -0
- package/dist/internal/testing.js +6 -0
- package/dist/lambda/index.js +1 -1
- package/dist/logging/index.js +2 -1
- package/dist/{logging-CXotojgW.js → logging-DshkpIkj.js} +4 -113
- package/dist/loopback-guard-CG8xB4v0.js +68 -0
- package/dist/mail/index.js +1 -1
- package/dist/{mail-zMjQimaJ.js → mail-CQlxrjYp.js} +4 -2
- package/dist/mcp/McpServiceProvider.d.ts +21 -4
- package/dist/mcp/create-mcp-server.d.ts +6 -0
- package/dist/mcp/index.js +434 -1
- package/dist/mvc/Controller.d.ts +11 -1
- package/dist/mvc/Router.d.ts +6 -0
- package/dist/mvc/inertia/InertiaEngine.d.ts +2 -0
- package/dist/mvc/validated-input.d.ts +55 -0
- package/dist/notifications/index.js +1 -1
- package/dist/{notifications-BLid0Y6M.js → notifications-DmyJZGM2.js} +3 -2
- package/dist/providers/ConfigServiceProvider.d.ts +19 -0
- package/dist/queue/index.js +2 -2
- package/dist/{queue-IdJjqbyJ.js → queue-CdwHlFXE.js} +1 -1
- package/dist/resolve-optional-ax6gPWTp.js +9 -0
- package/dist/runtime/index.js +2 -1
- package/dist/validated-input-D84J8wcC.js +25 -0
- package/dist/{vite-manifest-DeWRFXTm.js → vite-manifest-DAqhhZZ9.js} +7 -32
- package/package.json +6 -2
- package/dist/McpServiceProvider-BvJRcDOm.js +0 -458
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region src/support/import-map.ts
|
|
2
|
+
/**
|
|
3
|
+
* Empty, null and undefined entries are dropped, so callers can merge optional
|
|
4
|
+
* overrides without filtering first.
|
|
5
|
+
*/
|
|
6
|
+
function parseImportMap(value, options = {}) {
|
|
7
|
+
if (!value) return {};
|
|
8
|
+
try {
|
|
9
|
+
const parsed = JSON.parse(value);
|
|
10
|
+
const result = {};
|
|
11
|
+
for (const [key, entry] of Object.entries(parsed)) if (typeof entry === "string" && entry.length > 0) result[key] = entry;
|
|
12
|
+
return result;
|
|
13
|
+
} catch (error) {
|
|
14
|
+
const label = options.context ?? "import map";
|
|
15
|
+
console.warn(`Failed to parse ${label}. Expected JSON object.`, error);
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/support/inertia-defaults.ts
|
|
21
|
+
/**
|
|
22
|
+
* The stylesheet *source* path the dev asset configuration falls back to. A
|
|
23
|
+
* leaf module because two sides must agree on it: `http/inertia-assets.ts`
|
|
24
|
+
* publishes it into `GUREN_INERTIA_STYLES` and `mvc/inertia/InertiaEngine.ts`
|
|
25
|
+
* drops exactly this path when a dev server owns the script entry. Importing
|
|
26
|
+
* either from the other would cross the Workers/Lambda boundary or cycle.
|
|
27
|
+
*/
|
|
28
|
+
const DEFAULT_DEV_STYLES_ENTRY = "/resources/css/app.css";
|
|
29
|
+
//#endregion
|
|
30
|
+
export { parseImportMap as n, DEFAULT_DEV_STYLES_ENTRY as t };
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
* The one set of request-reading rules: which content types are read, how a
|
|
3
3
|
* repeated form field collapses, what an unreadable body falls back to, how a
|
|
4
4
|
* multipart upload is read, and how repeated query parameters flatten.
|
|
5
|
-
* `@guren/testing`
|
|
6
|
-
*
|
|
7
|
-
* came to disagree on an uppercase media type and on a repeated `field[]`.
|
|
5
|
+
* `@guren/testing` imports these instead of restating them. Keep every name: published
|
|
6
|
+
* `@guren/testing` releases import some that its current source does not.
|
|
8
7
|
* Internal per `contributing/api-stability.md`: reachable only through this
|
|
9
8
|
* deep import. `parseRequestPayload` beside them is public.
|
|
10
9
|
*/
|
|
11
10
|
export { parseRequestBody, parseRequestUploads, asRecord, flattenRequestQueries, } from '../http/request.js';
|
|
12
11
|
export type { RequestBodyContext, RequestQueryContext, RequestUploads, RequestUploadsContext, } from '../http/request.js';
|
|
12
|
+
export { VALIDATED_INPUT_CONTEXT_KEY, readValidatedInput } from '../mvc/validated-input.js';
|
|
13
|
+
export type { UntypedValidatedInput, ValidatedInputRecord } from '../mvc/validated-input.js';
|
package/dist/internal/request.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { i as parseRequestBody, n as flattenRequestQueries, o as parseRequestUploads, t as asRecord } from "../request-CLOYytGP.js";
|
|
2
|
-
|
|
2
|
+
import { r as readValidatedInput, t as VALIDATED_INPUT_CONTEXT_KEY } from "../validated-input-D84J8wcC.js";
|
|
3
|
+
export { VALIDATED_INPUT_CONTEXT_KEY, asRecord, flattenRequestQueries, parseRequestBody, parseRequestUploads, readValidatedInput };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The framework classes and helpers `@guren/testing`'s controller mock installs as its own
|
|
3
|
+
* exports. A mock that suites install as `@guren/server` itself cannot import
|
|
4
|
+
* that specifier (the factory would be mocking what it imports), so it reaches
|
|
5
|
+
* the same modules through this deep import; `instanceof` then agrees with the runtime.
|
|
6
|
+
* Internal per `contributing/api-stability.md`: reachable only through this path.
|
|
7
|
+
*/
|
|
8
|
+
export { Controller } from '../mvc/Controller.js';
|
|
9
|
+
export type { InertiaPageContractLike, InertiaResponseOptions } from '../mvc/Controller.js';
|
|
10
|
+
export { acceptsJson, serializePage } from '../mvc/inertia/InertiaEngine.js';
|
|
11
|
+
export { Resource, JsonResource, collect } from '../http/resources/Resource.js';
|
|
12
|
+
export { ValidationException } from '../errors/exceptions/ValidationException.js';
|
|
13
|
+
export { AuthenticationException } from '../errors/exceptions/AuthenticationException.js';
|
|
14
|
+
export { ServiceProvider } from '../container/ServiceProvider.js';
|
|
15
|
+
export { defineModule } from '../container/defineModule.js';
|
|
16
|
+
export { definePlugin } from '../container/definePlugin.js';
|
|
17
|
+
export { formatValidationErrors } from '../http/request.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { _ as acceptsJson, f as definePlugin, i as Controller, n as Resource, r as collect, t as JsonResource, u as defineModule, y as serializePage } from "../Resource-BJhY4aF8.js";
|
|
2
|
+
import { r as formatValidationErrors } from "../request-CLOYytGP.js";
|
|
3
|
+
import { n as ValidationException } from "../errors-JpkcCjjn.js";
|
|
4
|
+
import { n as ServiceProvider } from "../ServiceProvider-DDW3MqQJ.js";
|
|
5
|
+
import { o as AuthenticationException } from "../context-af2n5abO.js";
|
|
6
|
+
export { AuthenticationException, Controller, JsonResource, Resource, ServiceProvider, ValidationException, acceptsJson, collect, defineModule, definePlugin, formatValidationErrors, serializePage };
|
package/dist/lambda/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as detectServerlessRuntime } from "../serverless-D96rJb6x.js";
|
|
2
|
-
import { a as getJob } from "../Job-
|
|
2
|
+
import { a as getJob } from "../Job-BVRCYuVY.js";
|
|
3
3
|
import { handle } from "hono/aws-lambda";
|
|
4
4
|
//#region src/lambda/index.ts
|
|
5
5
|
/** Create an AWS Lambda handler from an already booted Guren application. */
|
package/dist/logging/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { n as filterSensitiveData, t as Logger } from "../Logger-DWXdtLSJ.js";
|
|
2
|
-
import { a as
|
|
2
|
+
import { a as LOG_LEVEL_PRIORITY, i as matchDailyFileDate, n as dailyFileDateStamp, r as dailyFilePath, t as DailyFileChannel } from "../DailyFileChannel-CTTPA0EF.js";
|
|
3
|
+
import { a as FileChannel, i as setLogManager, n as createLogManager, o as ConsoleChannel, r as getLogManager, t as LogManager } from "../logging-DshkpIkj.js";
|
|
3
4
|
export { ConsoleChannel, DailyFileChannel, FileChannel, LOG_LEVEL_PRIORITY, LogManager, Logger, createLogManager, dailyFileDateStamp, dailyFilePath, filterSensitiveData, getLogManager, matchDailyFileDate, setLogManager };
|
|
@@ -1,20 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as warnDeprecatedGetter, r as warnDeprecatedSetter } from "./deprecate-rL8jNpKX.js";
|
|
2
|
+
import { i as bindAmbient, n as ambientBinding } from "./default-application-CMuAAsdf.js";
|
|
2
3
|
import { r as isPromiseLike, t as Logger } from "./Logger-DWXdtLSJ.js";
|
|
4
|
+
import { a as LOG_LEVEL_PRIORITY, t as DailyFileChannel } from "./DailyFileChannel-CTTPA0EF.js";
|
|
3
5
|
import * as path$1 from "node:path";
|
|
4
6
|
import * as fs from "node:fs";
|
|
5
|
-
//#region src/logging/types.ts
|
|
6
|
-
/** Log level priority (lower = more severe). */
|
|
7
|
-
const LOG_LEVEL_PRIORITY = {
|
|
8
|
-
emergency: 0,
|
|
9
|
-
alert: 1,
|
|
10
|
-
critical: 2,
|
|
11
|
-
error: 3,
|
|
12
|
-
warning: 4,
|
|
13
|
-
notice: 5,
|
|
14
|
-
info: 6,
|
|
15
|
-
debug: 7
|
|
16
|
-
};
|
|
17
|
-
//#endregion
|
|
18
7
|
//#region src/logging/channels/ConsoleChannel.ts
|
|
19
8
|
const LEVEL_COLORS = {
|
|
20
9
|
emergency: "\x1B[41m\x1B[37m",
|
|
@@ -118,104 +107,6 @@ var FileChannel = class {
|
|
|
118
107
|
close() {}
|
|
119
108
|
};
|
|
120
109
|
//#endregion
|
|
121
|
-
//#region src/logging/daily-file-path.ts
|
|
122
|
-
/**
|
|
123
|
-
* The one rule for what a daily-rotated log file is called:
|
|
124
|
-
* `dir/name-YYYY-MM-DD.ext`. {@link DailyFileChannel} names what it appends to
|
|
125
|
-
* through this module, and the audit reader behind `guren tool:log` decides
|
|
126
|
-
* what to read through the same one; a second copy drifts silently, leaving an
|
|
127
|
-
* empty audit trail rather than an error. Naming only — nothing here touches
|
|
128
|
-
* the filesystem, so a caller keeps "missing" and "unreadable" apart itself.
|
|
129
|
-
*/
|
|
130
|
-
/**
|
|
131
|
-
* The `YYYY-MM-DD` stamp a file rotated at `date` carries. UTC, because the
|
|
132
|
-
* rotation boundary must be the same instant for every process appending to one
|
|
133
|
-
* directory — a fleet across time zones would write two files for one day.
|
|
134
|
-
*/
|
|
135
|
-
function dailyFileDateStamp(date) {
|
|
136
|
-
return date.toISOString().slice(0, 10);
|
|
137
|
-
}
|
|
138
|
-
/** The dated file a base path rotates to on `date`. */
|
|
139
|
-
function dailyFilePath(basePath, date) {
|
|
140
|
-
const { dir, name, ext } = path$1.parse(basePath);
|
|
141
|
-
return path$1.join(dir, `${name}-${dailyFileDateStamp(date)}${ext}`);
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* The date stamp of `fileName` if it is one of `basePath`'s dated files, else
|
|
145
|
-
* `null` — the inverse of {@link dailyFilePath}. The base name and extension
|
|
146
|
-
* are escaped first: `app.v1.log` would otherwise match another app's files
|
|
147
|
-
* into this rotation set, which for the cleanup consuming it means deleting them.
|
|
148
|
-
*/
|
|
149
|
-
function matchDailyFileDate(basePath, fileName) {
|
|
150
|
-
const { name, ext } = path$1.parse(basePath);
|
|
151
|
-
return new RegExp(`^${escapeRegExp(name)}-(\\d{4}-\\d{2}-\\d{2})${escapeRegExp(ext)}$`, "u").exec(fileName)?.[1] ?? null;
|
|
152
|
-
}
|
|
153
|
-
/** Every character with meaning inside a regular expression, made literal. */
|
|
154
|
-
function escapeRegExp(text) {
|
|
155
|
-
return text.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
156
|
-
}
|
|
157
|
-
//#endregion
|
|
158
|
-
//#region src/logging/channels/DailyFileChannel.ts
|
|
159
|
-
/** Daily rotating file log channel. */
|
|
160
|
-
var DailyFileChannel = class {
|
|
161
|
-
config;
|
|
162
|
-
minLevel;
|
|
163
|
-
currentDate = null;
|
|
164
|
-
currentFilePath = null;
|
|
165
|
-
constructor(config) {
|
|
166
|
-
this.config = {
|
|
167
|
-
days: 14,
|
|
168
|
-
format: "text",
|
|
169
|
-
...config
|
|
170
|
-
};
|
|
171
|
-
this.minLevel = LOG_LEVEL_PRIORITY[this.config.level ?? "debug"];
|
|
172
|
-
}
|
|
173
|
-
log(entry) {
|
|
174
|
-
if (LOG_LEVEL_PRIORITY[entry.level] > this.minLevel) return;
|
|
175
|
-
const dateStr = dailyFileDateStamp(entry.timestamp);
|
|
176
|
-
if (this.currentDate !== dateStr) this.rotate(entry.timestamp, dateStr);
|
|
177
|
-
const line = this.format(entry) + "\n";
|
|
178
|
-
this.write(line);
|
|
179
|
-
}
|
|
180
|
-
write(data) {
|
|
181
|
-
if (this.currentFilePath) fs.appendFileSync(this.currentFilePath, data);
|
|
182
|
-
}
|
|
183
|
-
rotate(date, dateStr) {
|
|
184
|
-
this.currentDate = dateStr;
|
|
185
|
-
this.currentFilePath = dailyFilePath(this.config.path, date);
|
|
186
|
-
this.ensureDirectory(this.currentFilePath);
|
|
187
|
-
this.cleanup();
|
|
188
|
-
}
|
|
189
|
-
ensureDirectory(filePath) {
|
|
190
|
-
const dir = path$1.dirname(filePath);
|
|
191
|
-
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
192
|
-
}
|
|
193
|
-
cleanup() {
|
|
194
|
-
const dir = path$1.dirname(this.config.path);
|
|
195
|
-
if (!fs.existsSync(dir)) return;
|
|
196
|
-
const files = fs.readdirSync(dir);
|
|
197
|
-
const cutoff = /* @__PURE__ */ new Date();
|
|
198
|
-
cutoff.setDate(cutoff.getDate() - (this.config.days ?? 14));
|
|
199
|
-
for (const file of files) {
|
|
200
|
-
const stamp = matchDailyFileDate(this.config.path, file);
|
|
201
|
-
if (stamp !== null && new Date(stamp) < cutoff) fs.unlinkSync(path$1.join(dir, file));
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
format(entry) {
|
|
205
|
-
if (this.config.format === "json") return JSON.stringify({
|
|
206
|
-
timestamp: entry.timestamp.toISOString(),
|
|
207
|
-
level: entry.level,
|
|
208
|
-
message: entry.message,
|
|
209
|
-
...entry.context
|
|
210
|
-
});
|
|
211
|
-
const timestamp = entry.timestamp.toISOString();
|
|
212
|
-
const level = entry.level.toUpperCase().padEnd(9);
|
|
213
|
-
const context = Object.keys(entry.context).length > 0 ? " " + JSON.stringify(entry.context) : "";
|
|
214
|
-
return `[${timestamp}] ${level} ${entry.message}${context}`;
|
|
215
|
-
}
|
|
216
|
-
close() {}
|
|
217
|
-
};
|
|
218
|
-
//#endregion
|
|
219
110
|
//#region src/logging/LogManager.ts
|
|
220
111
|
/** Log manager for managing multiple logging channels. */
|
|
221
112
|
var LogManager = class {
|
|
@@ -370,4 +261,4 @@ function getLogManager() {
|
|
|
370
261
|
return manager;
|
|
371
262
|
}
|
|
372
263
|
//#endregion
|
|
373
|
-
export {
|
|
264
|
+
export { FileChannel as a, setLogManager as i, createLogManager as n, ConsoleChannel as o, getLogManager as r, LogManager as t };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
//#region src/http/middleware/loopback-guard.ts
|
|
2
|
+
const LOOPBACK_HOSTNAMES = /* @__PURE__ */ new Set(["localhost", "[::1]"]);
|
|
3
|
+
const LOOPBACK_IPV4 = /^127\.\d+\.\d+\.\d+$/;
|
|
4
|
+
/**
|
|
5
|
+
* Whether an `Origin` header value belongs to the developer's own machine.
|
|
6
|
+
* Only a web page's request carries one; restricting it to loopback blocks
|
|
7
|
+
* cross-site requests and DNS rebinding (an attacker's domain resolving to
|
|
8
|
+
* 127.0.0.1 so the browser skips preflight). A *negative* filter only: any
|
|
9
|
+
* non-browser client sets the header with one flag, so never use it to satisfy the peer check.
|
|
10
|
+
*/
|
|
11
|
+
function isLoopbackOrigin(origin) {
|
|
12
|
+
try {
|
|
13
|
+
const { hostname } = new URL(origin);
|
|
14
|
+
return LOOPBACK_HOSTNAMES.has(hostname) || LOOPBACK_IPV4.test(hostname);
|
|
15
|
+
} catch {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Whether a socket peer address belongs to this machine.
|
|
21
|
+
*
|
|
22
|
+
* Bun reports IPv4-mapped peers as `::ffff:127.0.0.1`, so unwrap that prefix
|
|
23
|
+
* before matching.
|
|
24
|
+
*/
|
|
25
|
+
function isLoopbackAddress(address) {
|
|
26
|
+
const normalized = address.startsWith("::ffff:") ? address.slice(7) : address;
|
|
27
|
+
return normalized === "::1" || LOOPBACK_IPV4.test(normalized);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The peer address of the current request, when the runtime exposes one.
|
|
31
|
+
* `Bun.serve` passes `{ server }` through Hono's env, wired by
|
|
32
|
+
* `Application.listen()`; proxy headers are attacker-controlled and ignored.
|
|
33
|
+
* `undefined` means "the runtime did not say", not "remote": no `server` in env
|
|
34
|
+
* (Node, Vercel's `app.fetch(request)`, in-process tests), or `requestIP()` null (closed or non-TCP socket).
|
|
35
|
+
*/
|
|
36
|
+
function clientAddress(ctx) {
|
|
37
|
+
const env = ctx.env;
|
|
38
|
+
if (typeof env?.server?.requestIP !== "function") return;
|
|
39
|
+
return env.server.requestIP(ctx.req.raw)?.address;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Whether the operator accepted serving these endpoints on a runtime that
|
|
43
|
+
* cannot report the socket peer.
|
|
44
|
+
*
|
|
45
|
+
* Read per request, and written in the plain `process.env.X` form for the
|
|
46
|
+
* same bundler reason as the endpoint gates (see `mcp/endpoint.ts`).
|
|
47
|
+
*/
|
|
48
|
+
function allowsUnverifiedPeer() {
|
|
49
|
+
return typeof process !== "undefined" && process.env.GUREN_ALLOW_UNVERIFIED_PEER === "1";
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Restricts an endpoint to the developer's own machine. `resource` names the
|
|
53
|
+
* endpoint in the 403 body (e.g. "the MCP endpoint"). The two denials say
|
|
54
|
+
* different things on purpose: a present non-loopback peer is a remote caller,
|
|
55
|
+
* a peer the runtime never reported is a deployment the guard cannot vouch for.
|
|
56
|
+
*/
|
|
57
|
+
function createLoopbackGuard(resource) {
|
|
58
|
+
return async (ctx, next) => {
|
|
59
|
+
const origin = ctx.req.header("origin");
|
|
60
|
+
if (origin !== void 0 && !isLoopbackOrigin(origin)) return ctx.json({ message: `Forbidden: cross-origin request to ${resource}` }, 403);
|
|
61
|
+
const address = clientAddress(ctx);
|
|
62
|
+
if (address !== void 0 && !isLoopbackAddress(address)) return ctx.json({ message: `Forbidden: remote request to ${resource}` }, 403);
|
|
63
|
+
if (address === void 0 && !allowsUnverifiedPeer()) return ctx.json({ message: `Forbidden: this runtime does not report the peer address, so ${resource} cannot confirm the request came from this machine. Serve the app with Application.listen() on Bun, or set GUREN_ALLOW_UNVERIFIED_PEER=1 to accept requests from anywhere the process is reachable.` }, 403);
|
|
64
|
+
await next();
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
export { createLoopbackGuard as t };
|
package/dist/mail/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as MailManager, c as MemoryTransport, i as setMailManager, l as ResendTransport, n as getMailManager, o as createMailManager, r as mail, s as LogTransport, t as Mail, u as SmtpTransport } from "../mail-
|
|
1
|
+
import { a as MailManager, c as MemoryTransport, i as setMailManager, l as ResendTransport, n as getMailManager, o as createMailManager, r as mail, s as LogTransport, t as Mail, u as SmtpTransport } from "../mail-CQlxrjYp.js";
|
|
2
2
|
export { LogTransport, Mail, MailManager, MemoryTransport, ResendTransport, SmtpTransport, createMailManager, getMailManager, mail, setMailManager };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { t as resolveOptional } from "./resolve-optional-ax6gPWTp.js";
|
|
2
|
+
import { n as warnDeprecatedGetter, r as warnDeprecatedSetter } from "./deprecate-rL8jNpKX.js";
|
|
3
|
+
import { i as bindAmbient, n as ambientBinding } from "./default-application-CMuAAsdf.js";
|
|
4
|
+
import { c as pinnedQueueDriver, d as resolveQueueDriver, i as enqueueJob, l as registerJob, t as Job } from "./Job-BVRCYuVY.js";
|
|
3
5
|
import { t as parseMailAddress } from "./address-D0Iq-XIH.js";
|
|
4
6
|
import nodemailer from "nodemailer";
|
|
5
7
|
//#region src/mail/transports/SmtpTransport.ts
|
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
import { ServiceProvider } from '../container/ServiceProvider.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* `
|
|
6
|
-
|
|
3
|
+
* What this provider calls on `@guren/cli`, spelled here: the package cannot be
|
|
4
|
+
* declared as a dependency (it depends on this one), so an imported type would
|
|
5
|
+
* build as `any`. Same seam as `DocsViewerServiceProvider`'s.
|
|
6
|
+
*/
|
|
7
|
+
export interface DevMcpCliApi {
|
|
8
|
+
createDevMcpHandler?(options: {
|
|
9
|
+
cwd: string;
|
|
10
|
+
}): {
|
|
11
|
+
fetch(request: Request): Promise<Response>;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare const DEV_MCP_CLI_TOO_OLD: string;
|
|
15
|
+
/** Whether this CLI ships the Dev MCP factory; `DEV_MCP_CLI_TOO_OLD` says what to do when it does not. */
|
|
16
|
+
export declare function canServeDevMcp(cli: DevMcpCliApi): cli is DevMcpCliApi & {
|
|
17
|
+
createDevMcpHandler: NonNullable<DevMcpCliApi['createDevMcpHandler']>;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Mounts the Dev MCP endpoint at /_guren/mcp while `isMcpEndpointEnabled()` holds.
|
|
21
|
+
* The server lives in @guren/cli (RFC 0028 §1), which every deploy target stubs, so
|
|
22
|
+
* this package imports no MCP SDK code.
|
|
23
|
+
* @experimental
|
|
7
24
|
*/
|
|
8
25
|
export declare class McpServiceProvider extends ServiceProvider {
|
|
9
26
|
register(): void;
|
|
@@ -177,4 +177,10 @@ export interface CreateMcpServerOptions {
|
|
|
177
177
|
cli: GurenCliApi;
|
|
178
178
|
version?: string;
|
|
179
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* @deprecated Serves only the 2025-era MCP protocol. The Dev MCP endpoint is now
|
|
182
|
+
* built by `createDevMcpHandler` from `@guren/cli` (RFC 0028); this is removed in
|
|
183
|
+
* the next minor.
|
|
184
|
+
* @experimental
|
|
185
|
+
*/
|
|
180
186
|
export declare function createMcpServer(options: CreateMcpServerOptions): McpServer;
|