@guren/server 2.1.1 → 2.3.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-D7RGJPGM.js → DocsViewerServiceProvider-RUYDFBMW.js} +2 -2
- package/dist/McpServiceProvider-FRJ5O7LT.js +8 -0
- package/dist/auth/AuthManager.d.ts +30 -0
- package/dist/auth/AuthenticatableModel.d.ts +25 -0
- package/dist/auth/RequestAuthContext.d.ts +24 -0
- package/dist/auth/SessionGuard.d.ts +31 -0
- package/dist/auth/api-token.d.ts +299 -0
- package/dist/auth/email-verification.d.ts +203 -0
- package/dist/auth/index.d.ts +18 -110
- package/dist/auth/index.js +4 -1
- package/dist/auth/oauth/index.d.ts +239 -0
- package/dist/auth/password/DefaultHasher.d.ts +13 -0
- package/dist/auth/password/NodeHasher.d.ts +22 -0
- package/dist/auth/password/PasswordHasher.d.ts +5 -0
- package/dist/auth/password/ScryptHasher.d.ts +26 -0
- package/dist/auth/password-reset.d.ts +91 -0
- package/dist/auth/providers/ModelUserProvider.d.ts +36 -0
- package/dist/auth/providers/UserProvider.d.ts +9 -0
- package/dist/auth/types.d.ts +102 -0
- package/dist/auth/utils.d.ts +39 -0
- package/dist/{Gate-CynjZCtS.d.ts → authorization/Gate.d.ts} +30 -111
- package/dist/authorization/Policy.d.ts +77 -0
- package/dist/authorization/index.d.ts +5 -129
- package/dist/authorization/index.js +3 -1
- package/dist/authorization/middleware.d.ts +49 -0
- package/dist/authorization/types.d.ts +108 -0
- package/dist/broadcasting/BroadcastManager.d.ts +205 -0
- package/dist/broadcasting/channels/Channel.d.ts +28 -0
- package/dist/broadcasting/channels/PresenceChannel.d.ts +72 -0
- package/dist/broadcasting/channels/PrivateChannel.d.ts +32 -0
- package/dist/broadcasting/channels/index.d.ts +3 -0
- package/dist/broadcasting/drivers/MemoryDriver.d.ts +93 -0
- package/dist/broadcasting/drivers/RedisDriver.d.ts +112 -0
- package/dist/broadcasting/drivers/index.d.ts +2 -0
- package/dist/broadcasting/index.d.ts +6 -233
- package/dist/broadcasting/index.js +1 -1
- package/dist/broadcasting/typed.d.ts +23 -0
- package/dist/broadcasting/types.d.ts +155 -0
- package/dist/cache/CacheManager.d.ts +87 -0
- package/dist/cache/TaggedCache.d.ts +62 -0
- package/dist/cache/index.d.ts +6 -233
- package/dist/cache/index.js +1 -1
- package/dist/cache/stores/FileStore.d.ts +64 -0
- package/dist/cache/stores/MemoryStore.d.ts +52 -0
- package/dist/cache/stores/RedisStore.d.ts +53 -0
- package/dist/{CacheManager-BmDzUKrF.d.ts → cache/types.d.ts} +26 -99
- package/dist/chunk-3KV5X2FL.js +31 -0
- package/dist/{chunk-TVY72CLV.js → chunk-4VE3LYOM.js} +3 -2
- package/dist/{chunk-DSDX3ASM.js → chunk-5WL2FTC4.js} +67 -85
- package/dist/{chunk-5SZTEZ22.js → chunk-6IGN233M.js} +15 -8
- package/dist/{chunk-FZD2AKJI.js → chunk-7OB2YXRE.js} +56 -28
- package/dist/{chunk-WIXGT4TN.js → chunk-A5JJ7XTH.js} +8 -2
- package/dist/{chunk-CWI4AJ47.js → chunk-HPET6XY5.js} +13 -9
- package/dist/{chunk-A3ISJVEV.js → chunk-HR2KZ3WL.js} +23 -5
- package/dist/{chunk-BZMZEFRG.js → chunk-LHR6OHI7.js} +11 -0
- package/dist/{chunk-JBG4AR24.js → chunk-Q2P6YLRR.js} +8 -2
- package/dist/{chunk-J6ETA476.js → chunk-TVV5YNEC.js} +101 -9
- package/dist/console/Command.d.ts +179 -0
- package/dist/{ConsoleKernel-CJg975mp.d.ts → console/ConsoleKernel.d.ts} +4 -6
- package/dist/console/Input.d.ts +140 -0
- package/dist/console/Output.d.ts +161 -0
- package/dist/console/index.d.ts +5 -0
- package/dist/console/types.d.ts +106 -0
- package/dist/container/Container.d.ts +148 -0
- package/dist/container/ServiceProvider.d.ts +103 -0
- package/dist/container/bindings.d.ts +55 -0
- package/dist/container/defineModule.d.ts +88 -0
- package/dist/container/definePlugin.d.ts +62 -0
- package/dist/container/index.d.ts +8 -0
- package/dist/container/types.d.ts +73 -0
- package/dist/database/Factory.d.ts +82 -0
- package/dist/database/Seeder.d.ts +35 -0
- package/dist/database/SeederRunner.d.ts +41 -0
- package/dist/database/index.d.ts +4 -0
- package/dist/database/types.d.ts +49 -0
- package/dist/discovery/AutoDiscovery.d.ts +113 -0
- package/dist/discovery/index.d.ts +2 -0
- package/dist/docs-viewer/DocsViewerServiceProvider.d.ts +12 -0
- package/dist/docs-viewer/endpoint.d.ts +29 -0
- package/dist/encryption/Encrypter.d.ts +96 -0
- package/dist/encryption/Hash.d.ts +69 -0
- package/dist/encryption/MessageSigner.d.ts +21 -0
- package/dist/encryption/Random.d.ts +119 -0
- package/dist/encryption/app-key.d.ts +12 -0
- package/dist/encryption/index.d.ts +10 -222
- package/dist/encryption/signed-url.d.ts +9 -0
- package/dist/encryption/types.d.ts +103 -0
- package/dist/errors/ExceptionHandler.d.ts +118 -0
- package/dist/errors/HttpException.d.ts +106 -0
- package/dist/errors/debug-page.d.ts +22 -0
- package/dist/errors/error-page.d.ts +1 -0
- package/dist/errors/exceptions/AuthenticationException.d.ts +32 -0
- package/dist/errors/exceptions/AuthorizationException.d.ts +32 -0
- package/dist/errors/exceptions/MethodNotAllowedException.d.ts +31 -0
- package/dist/errors/exceptions/NotFoundHttpException.d.ts +36 -0
- package/dist/errors/exceptions/ValidationException.d.ts +60 -0
- package/dist/errors/exceptions/index.d.ts +5 -0
- package/dist/errors/index.d.ts +5 -0
- package/dist/errors/types.d.ts +43 -0
- package/dist/events/Event.d.ts +33 -0
- package/dist/{EventManager-CmIoLt7r.d.ts → events/EventManager.d.ts} +4 -86
- package/dist/events/Listener.d.ts +79 -0
- package/dist/events/builtin.d.ts +73 -0
- package/dist/events/index.d.ts +6 -155
- package/dist/events/types.d.ts +48 -0
- package/dist/facades/index.d.ts +31 -0
- package/dist/health/HealthCheck.d.ts +34 -0
- package/dist/health/HealthManager.d.ts +53 -0
- package/dist/health/checks/CacheCheck.d.ts +35 -0
- package/dist/health/checks/CustomCheck.d.ts +23 -0
- package/dist/health/checks/DatabaseCheck.d.ts +33 -0
- package/dist/health/checks/MemoryCheck.d.ts +32 -0
- package/dist/health/checks/RedisCheck.d.ts +27 -0
- package/dist/health/checks/StorageCheck.d.ts +35 -0
- package/dist/health/checks/index.d.ts +12 -0
- package/dist/health/index.d.ts +5 -185
- package/dist/health/types.d.ts +52 -0
- package/dist/hot-reload/hot-disposables.d.ts +96 -0
- package/dist/hot-reload/testing.d.ts +14 -0
- package/dist/http/Application.d.ts +199 -0
- package/dist/http/FormRequest.d.ts +73 -0
- package/dist/http/dev-assets.d.ts +62 -0
- package/dist/http/dev-banner.d.ts +7 -0
- package/dist/http/inertia-assets.d.ts +31 -0
- package/dist/http/middleware/auth.d.ts +13 -0
- package/dist/http/middleware/capabilities.d.ts +22 -0
- package/dist/http/middleware/cors.d.ts +40 -0
- package/dist/http/middleware/csp.d.ts +59 -0
- package/dist/http/middleware/csrf.d.ts +121 -0
- package/dist/http/middleware/detect-locale.d.ts +65 -0
- package/dist/http/middleware/force-https.d.ts +34 -0
- package/dist/http/middleware/host-authorization.d.ts +24 -0
- package/dist/http/middleware/index.d.ts +19 -0
- package/dist/http/middleware/loopback-guard.d.ts +51 -0
- package/dist/{rate-limit-D9J2b4S1.d.ts → http/middleware/rate-limit.d.ts} +22 -50
- package/dist/http/middleware/redirect-safety.d.ts +29 -0
- package/dist/http/middleware/request-id.d.ts +19 -0
- package/dist/http/middleware/request-logging.d.ts +16 -0
- package/dist/http/middleware/response-headers.d.ts +18 -0
- package/dist/http/middleware/security-headers.d.ts +49 -0
- package/dist/http/middleware/session.d.ts +93 -0
- package/dist/http/middleware/validation.d.ts +94 -0
- package/dist/http/public-assets.d.ts +15 -0
- package/dist/http/request.d.ts +24 -0
- package/dist/http/resources/CursorPaginator.d.ts +106 -0
- package/dist/http/resources/Paginator.d.ts +130 -0
- package/dist/http/resources/Resource.d.ts +67 -0
- package/dist/http/resources/ResourceCollection.d.ts +60 -0
- package/dist/http/resources/index.d.ts +6 -0
- package/dist/http/resources/types.d.ts +91 -0
- package/dist/http/validation/Validator.d.ts +128 -0
- package/dist/http/validation/index.d.ts +3 -0
- package/dist/http/validation/rules.d.ts +196 -0
- package/dist/http/validation/types.d.ts +96 -0
- package/dist/http/vite-dev-server.d.ts +27 -0
- package/dist/i18n/I18nManager.d.ts +114 -0
- package/dist/i18n/Translator.d.ts +80 -0
- package/dist/i18n/index.d.ts +6 -101
- package/dist/i18n/index.js +5 -3
- package/dist/i18n/loaders/JsonLoader.d.ts +47 -0
- package/dist/i18n/loaders/MemoryLoader.d.ts +37 -0
- package/dist/i18n/pluralization.d.ts +19 -0
- package/dist/i18n/types.d.ts +106 -0
- package/dist/index.d.ts +69 -2605
- package/dist/index.js +405 -180
- package/dist/lambda/index.d.ts +17 -37
- package/dist/logging/LogManager.d.ts +83 -0
- package/dist/logging/Logger.d.ts +76 -0
- package/dist/logging/channels/ConsoleChannel.d.ts +11 -0
- package/dist/logging/channels/DailyFileChannel.d.ts +20 -0
- package/dist/logging/channels/FileChannel.d.ts +15 -0
- package/dist/logging/index.d.ts +8 -50
- package/dist/logging/types.d.ts +96 -0
- package/dist/mail/Mail.d.ts +138 -0
- package/dist/mail/MailManager.d.ts +79 -0
- package/dist/mail/address.d.ts +8 -0
- package/dist/mail/index.d.ts +7 -316
- package/dist/mail/transports/LogTransport.d.ts +19 -0
- package/dist/mail/transports/MemoryTransport.d.ts +84 -0
- package/dist/mail/transports/ResendTransport.d.ts +32 -0
- package/dist/mail/transports/SmtpTransport.d.ts +40 -0
- package/dist/{MailManager-DpMvYiP9.d.ts → mail/types.d.ts} +11 -92
- package/dist/mcp/McpServiceProvider.d.ts +17 -0
- package/dist/mcp/create-mcp-server.d.ts +152 -0
- package/dist/mcp/endpoint.d.ts +47 -0
- package/dist/mcp/index.d.ts +3 -185
- package/dist/mcp/index.js +3 -3
- package/dist/mvc/Controller.d.ts +326 -0
- package/dist/mvc/Router.d.ts +239 -0
- package/dist/mvc/ViewEngine.d.ts +11 -0
- package/dist/mvc/inertia/InertiaEngine.d.ts +114 -0
- package/dist/mvc/inertia/shared.d.ts +90 -0
- package/dist/mvc/mount-route.d.ts +10 -0
- package/dist/notifications/Notification.d.ts +99 -0
- package/dist/notifications/NotificationManager.d.ts +150 -0
- package/dist/notifications/channels/DatabaseChannel.d.ts +55 -0
- package/dist/notifications/channels/MailChannel.d.ts +45 -0
- package/dist/notifications/channels/MemoryChannel.d.ts +85 -0
- package/dist/notifications/channels/SlackChannel.d.ts +73 -0
- package/dist/notifications/channels/index.d.ts +4 -0
- package/dist/notifications/index.d.ts +6 -322
- package/dist/notifications/notifiable-type.d.ts +10 -0
- package/dist/notifications/registry.d.ts +39 -0
- package/dist/notifications/types.d.ts +162 -0
- package/dist/providers/AuthServiceProvider.d.ts +7 -0
- package/dist/providers/AuthorizationServiceProvider.d.ts +9 -0
- package/dist/providers/BroadcastServiceProvider.d.ts +7 -0
- package/dist/providers/CacheServiceProvider.d.ts +7 -0
- package/dist/providers/EncryptionServiceProvider.d.ts +7 -0
- package/dist/providers/ErrorServiceProvider.d.ts +9 -0
- package/dist/providers/EventServiceProvider.d.ts +7 -0
- package/dist/providers/HealthServiceProvider.d.ts +7 -0
- package/dist/providers/I18nServiceProvider.d.ts +27 -0
- package/dist/providers/InertiaServiceProvider.d.ts +20 -0
- package/dist/providers/LogServiceProvider.d.ts +7 -0
- package/dist/providers/MailServiceProvider.d.ts +7 -0
- package/dist/providers/NotificationServiceProvider.d.ts +8 -0
- package/dist/providers/OAuthServiceProvider.d.ts +7 -0
- package/dist/providers/QueueServiceProvider.d.ts +7 -0
- package/dist/providers/SchedulingServiceProvider.d.ts +7 -0
- package/dist/providers/StorageServiceProvider.d.ts +7 -0
- package/dist/providers/index.d.ts +17 -0
- package/dist/queue/FailedJobReporter.d.ts +40 -0
- package/dist/queue/Job.d.ts +140 -0
- package/dist/queue/QueueManager.d.ts +79 -0
- package/dist/queue/Worker.d.ts +99 -0
- package/dist/queue/drivers/MemoryDriver.d.ts +60 -0
- package/dist/queue/drivers/RedisDriver.d.ts +96 -0
- package/dist/queue/drivers/SqsDriver.d.ts +108 -0
- package/dist/queue/drivers/SyncDriver.d.ts +28 -0
- package/dist/queue/index.d.ts +9 -453
- package/dist/queue/types.d.ts +171 -0
- package/dist/redis/RedisApiTokenStore.d.ts +78 -0
- package/dist/redis/RedisEmailVerificationStore.d.ts +54 -0
- package/dist/redis/RedisOAuthStateStore.d.ts +26 -0
- package/dist/redis/RedisPasswordResetStore.d.ts +57 -0
- package/dist/redis/RedisRateLimitStore.d.ts +77 -0
- package/dist/redis/RedisSessionStore.d.ts +61 -0
- package/dist/redis/client.d.ts +41 -0
- package/dist/redis/index.d.ts +14 -356
- package/dist/redis/index.js +45 -9
- package/dist/redis/redis-values.d.ts +17 -0
- package/dist/redis/scan-keys.d.ts +6 -0
- package/dist/runtime/index.d.ts +8 -95
- package/dist/runtime/index.js +101 -68
- package/dist/scheduling/CronParser.d.ts +37 -0
- package/dist/scheduling/Schedule.d.ts +229 -0
- package/dist/scheduling/ScheduledTask.d.ts +47 -0
- package/dist/scheduling/Scheduler.d.ts +99 -0
- package/dist/scheduling/index.d.ts +5 -41
- package/dist/scheduling/types.d.ts +97 -0
- package/dist/storage/StorageManager.d.ts +65 -0
- package/dist/storage/drivers/LocalDriver.d.ts +55 -0
- package/dist/storage/drivers/MemoryDriver.d.ts +66 -0
- package/dist/storage/drivers/S3Driver.d.ts +72 -0
- package/dist/storage/index.d.ts +5 -197
- package/dist/{StorageManager-oZTHqaza.d.ts → storage/types.d.ts} +10 -77
- package/dist/support/contained-path.d.ts +26 -0
- package/dist/support/error-polyfill.d.ts +9 -0
- package/dist/support/expiry.d.ts +47 -0
- package/dist/support/expiry.js +12 -0
- package/dist/support/import-map.d.ts +13 -0
- package/dist/support/redirect-target.d.ts +11 -0
- package/dist/support/stack-frames.d.ts +56 -0
- package/dist/support/trim-slashes.d.ts +11 -0
- package/dist/vite/index.d.ts +2 -35
- package/dist/vite/index.js +0 -3
- package/dist/vite/plugin.d.ts +34 -0
- package/package.json +7 -3
- package/dist/AuthManager-DBP4KYsx.d.ts +0 -79
- package/dist/BroadcastManager-D8KoJxiV.d.ts +0 -492
- package/dist/HealthManager-DUyMIzsZ.d.ts +0 -141
- package/dist/I18nManager-BiSoczfV.d.ts +0 -275
- package/dist/LogManager-7mxnkaPM.d.ts +0 -256
- package/dist/McpServiceProvider-7BB5FPF3.js +0 -8
- package/dist/Scheduler-pZiT8i57.d.ts +0 -471
- package/dist/api-token-D24VPr_E.d.ts +0 -663
- package/dist/app-key-CsBfRC_Q.d.ts +0 -214
- package/dist/email-verification-Dx426KLn.d.ts +0 -336
- package/dist/index-9_Jzj5jo.d.ts +0 -7
- package/dist/validation-yAL53e1S.d.ts +0 -2610
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
MCP_ENDPOINT_PATH,
|
|
3
3
|
createMcpAccessGuard,
|
|
4
4
|
isMcpEndpointEnabled
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-Q2P6YLRR.js";
|
|
6
6
|
import {
|
|
7
7
|
ServiceProvider
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-LHR6OHI7.js";
|
|
9
9
|
|
|
10
10
|
// src/mcp/create-mcp-server.ts
|
|
11
11
|
import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
@@ -123,16 +123,10 @@ function createMcpServer(options) {
|
|
|
123
123
|
force: z.boolean().default(false).describe("Overwrite existing files")
|
|
124
124
|
},
|
|
125
125
|
async ({ name, fields, withTest, force }) => {
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
return {
|
|
131
|
-
content: [{ type: "text", text: JSON.stringify({ created: createdFiles }, null, 2) }]
|
|
132
|
-
};
|
|
133
|
-
} finally {
|
|
134
|
-
process.chdir(originalCwd);
|
|
135
|
-
}
|
|
126
|
+
const createdFiles = await cli.makeFeature(name, { fields, withTest, force, cwd });
|
|
127
|
+
return {
|
|
128
|
+
content: [{ type: "text", text: JSON.stringify({ created: createdFiles }, null, 2) }]
|
|
129
|
+
};
|
|
136
130
|
}
|
|
137
131
|
);
|
|
138
132
|
server.tool(
|
|
@@ -162,36 +156,30 @@ function createMcpServer(options) {
|
|
|
162
156
|
force: z.boolean().default(false).describe("Overwrite existing files")
|
|
163
157
|
},
|
|
164
158
|
async ({ type, name, force }) => {
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
};
|
|
175
|
-
const maker = makers[type];
|
|
176
|
-
if (!maker) {
|
|
177
|
-
return {
|
|
178
|
-
content: [
|
|
179
|
-
{
|
|
180
|
-
type: "text",
|
|
181
|
-
text: `Component type "${type}" is not yet supported via MCP. Use the CLI: bunx guren make:${type} ${name}`
|
|
182
|
-
}
|
|
183
|
-
],
|
|
184
|
-
isError: true
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
const result = await maker(name, { force });
|
|
188
|
-
const created = Array.isArray(result) ? result : [result];
|
|
159
|
+
const makers = {
|
|
160
|
+
controller: cli.makeController,
|
|
161
|
+
model: cli.makeModel,
|
|
162
|
+
view: cli.makeView,
|
|
163
|
+
test: cli.makeTest,
|
|
164
|
+
route: cli.makeRoute
|
|
165
|
+
};
|
|
166
|
+
const maker = makers[type];
|
|
167
|
+
if (!maker) {
|
|
189
168
|
return {
|
|
190
|
-
content: [
|
|
169
|
+
content: [
|
|
170
|
+
{
|
|
171
|
+
type: "text",
|
|
172
|
+
text: `Component type "${type}" is not yet supported via MCP. Use the CLI: bunx guren make:${type} ${name}`
|
|
173
|
+
}
|
|
174
|
+
],
|
|
175
|
+
isError: true
|
|
191
176
|
};
|
|
192
|
-
} finally {
|
|
193
|
-
process.chdir(originalCwd);
|
|
194
177
|
}
|
|
178
|
+
const result = await maker(name, { force, cwd });
|
|
179
|
+
const created = Array.isArray(result) ? result : [result];
|
|
180
|
+
return {
|
|
181
|
+
content: [{ type: "text", text: JSON.stringify({ created }, null, 2) }]
|
|
182
|
+
};
|
|
195
183
|
}
|
|
196
184
|
);
|
|
197
185
|
server.tool(
|
|
@@ -199,53 +187,47 @@ function createMcpServer(options) {
|
|
|
199
187
|
"Generate the type-safe route, page, data, and channel manifests plus the API client (.guren/ and types/generated/).",
|
|
200
188
|
{},
|
|
201
189
|
async () => {
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
skipped.push({ artifacts, reason: "nothing to generate" });
|
|
214
|
-
} else {
|
|
215
|
-
generated.push(...artifacts);
|
|
216
|
-
}
|
|
217
|
-
return result;
|
|
218
|
-
} catch (error) {
|
|
219
|
-
failed = true;
|
|
220
|
-
skipped.push({
|
|
221
|
-
artifacts,
|
|
222
|
-
reason: error instanceof Error ? error.message : String(error)
|
|
223
|
-
});
|
|
190
|
+
const options2 = { cwd, force: true };
|
|
191
|
+
const generated = [];
|
|
192
|
+
const skipped = [];
|
|
193
|
+
let failed = false;
|
|
194
|
+
const run = async (artifacts, generate) => {
|
|
195
|
+
try {
|
|
196
|
+
const result = await generate();
|
|
197
|
+
if (result?.outputPath === "") {
|
|
198
|
+
skipped.push({ artifacts, reason: result.skipped?.message ?? "nothing to generate" });
|
|
199
|
+
} else {
|
|
200
|
+
generated.push(...artifacts);
|
|
224
201
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
|
|
202
|
+
return result;
|
|
203
|
+
} catch (error) {
|
|
204
|
+
failed = true;
|
|
205
|
+
skipped.push({
|
|
206
|
+
artifacts,
|
|
207
|
+
reason: error instanceof Error ? error.message : String(error)
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
const routes = await run(
|
|
212
|
+
[".guren/routes.gen.ts", "types/generated/routes.d.ts"],
|
|
213
|
+
() => cli.generateRouteTypes(options2)
|
|
214
|
+
);
|
|
215
|
+
await run([".guren/pages.gen.ts"], () => cli.generatePageTypes(options2));
|
|
216
|
+
await run([".guren/data.gen.ts"], () => cli.generateDataTypes(options2));
|
|
217
|
+
await run([".guren/channels.gen.ts"], () => cli.generateChannelTypes(options2));
|
|
218
|
+
await run([".guren/api-client.gen.ts"], () => {
|
|
219
|
+
if (!routes?.definitions) {
|
|
220
|
+
throw new Error("route generation produced no manifest to build a client from");
|
|
221
|
+
}
|
|
222
|
+
return cli.generateApiClientTypes(routes.definitions, options2);
|
|
223
|
+
});
|
|
224
|
+
return {
|
|
225
|
+
content: [{ type: "text", text: JSON.stringify({ generated, skipped }, null, 2) }],
|
|
226
|
+
// A generator that found nothing to describe is not a failure — an
|
|
227
|
+
// app with no page components is a normal shape — so only a thrown
|
|
228
|
+
// one makes the run an error, even when other artifacts landed.
|
|
229
|
+
isError: failed
|
|
230
|
+
};
|
|
249
231
|
}
|
|
250
232
|
);
|
|
251
233
|
server.resource(
|
|
@@ -6,7 +6,7 @@ import standard from "figlet/importable-fonts/Standard.js";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@guren/server",
|
|
9
|
-
version: "2.
|
|
9
|
+
version: "2.3.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
license: "MIT",
|
|
12
12
|
repository: {
|
|
@@ -106,16 +106,20 @@ var package_default = {
|
|
|
106
106
|
"./redis": {
|
|
107
107
|
types: "./dist/redis/index.d.ts",
|
|
108
108
|
default: "./dist/redis/index.js"
|
|
109
|
+
},
|
|
110
|
+
"./support/expiry": {
|
|
111
|
+
types: "./dist/support/expiry.d.ts",
|
|
112
|
+
default: "./dist/support/expiry.js"
|
|
109
113
|
}
|
|
110
114
|
},
|
|
111
115
|
scripts: {
|
|
112
|
-
build: "
|
|
116
|
+
build: "tsup && tsc -p tsconfig.build.json && bun ../../scripts/fix-dts-extensions.ts dist",
|
|
113
117
|
dev: "bun --watch src/index.ts",
|
|
114
118
|
typecheck: "tsc --noEmit",
|
|
115
119
|
test: "bun test"
|
|
116
120
|
},
|
|
117
121
|
dependencies: {
|
|
118
|
-
"@guren/orm": "^2.1
|
|
122
|
+
"@guren/orm": "^2.2.1",
|
|
119
123
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
120
124
|
chalk: "^5.3.0",
|
|
121
125
|
consola: "^3.4.2",
|
|
@@ -201,10 +205,9 @@ function logDevServerBanner({
|
|
|
201
205
|
}
|
|
202
206
|
|
|
203
207
|
// src/http/vite-dev-server.ts
|
|
204
|
-
|
|
205
|
-
const { root = process.cwd(), config = {}, host
|
|
206
|
-
|
|
207
|
-
const mergedConfig = {
|
|
208
|
+
function resolveViteDevServerConfig(options = {}) {
|
|
209
|
+
const { root = process.cwd(), config = {}, host, port } = options;
|
|
210
|
+
return {
|
|
208
211
|
clearScreen: false,
|
|
209
212
|
...config,
|
|
210
213
|
root: config.root ?? root,
|
|
@@ -214,7 +217,11 @@ async function startViteDevServer(options = {}) {
|
|
|
214
217
|
...config.server ?? {}
|
|
215
218
|
}
|
|
216
219
|
};
|
|
217
|
-
|
|
220
|
+
}
|
|
221
|
+
async function startViteDevServer(options = {}) {
|
|
222
|
+
const { host, port } = options;
|
|
223
|
+
const { createServer } = await import("vite");
|
|
224
|
+
const server = await createServer(resolveViteDevServerConfig(options));
|
|
218
225
|
await server.listen();
|
|
219
226
|
const resolved = server.resolvedUrls;
|
|
220
227
|
const localUrls = resolved?.local?.length ? resolved.local : [`http://${typeof host === "string" ? host : "localhost"}:${server.config.server.port ?? port ?? 5173}`];
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AuthorizationException
|
|
3
3
|
} from "./chunk-63SKW5PS.js";
|
|
4
|
+
import {
|
|
5
|
+
HttpException
|
|
6
|
+
} from "./chunk-DAQKYKLH.js";
|
|
4
7
|
|
|
5
8
|
// src/authorization/Gate.ts
|
|
6
9
|
var Response = {
|
|
@@ -17,6 +20,23 @@ var Response = {
|
|
|
17
20
|
return { allowed: false, message: message ?? "Not found.", status: 404 };
|
|
18
21
|
}
|
|
19
22
|
};
|
|
23
|
+
function isAuthorizationResponse(value) {
|
|
24
|
+
return typeof value === "object" && value !== null && typeof value.allowed === "boolean";
|
|
25
|
+
}
|
|
26
|
+
function toAuthorizationResponse(value) {
|
|
27
|
+
if (isAuthorizationResponse(value)) {
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
return value === true ? Response.allow() : Response.deny();
|
|
31
|
+
}
|
|
32
|
+
function denialToException(response) {
|
|
33
|
+
const message = response.message ?? "This action is unauthorized.";
|
|
34
|
+
const status = response.status;
|
|
35
|
+
if (typeof status === "number" && status !== 403) {
|
|
36
|
+
return new HttpException(status, message);
|
|
37
|
+
}
|
|
38
|
+
return new AuthorizationException(message);
|
|
39
|
+
}
|
|
20
40
|
var Gate = class {
|
|
21
41
|
/**
|
|
22
42
|
* Defined gates.
|
|
@@ -146,45 +166,55 @@ var Gate = class {
|
|
|
146
166
|
* Authorize the ability or throw an exception.
|
|
147
167
|
*/
|
|
148
168
|
async authorize(ability, ...args) {
|
|
149
|
-
const
|
|
150
|
-
if (!allowed) {
|
|
151
|
-
throw
|
|
169
|
+
const response = await this.checkResponse(ability, this.currentUser, ...args);
|
|
170
|
+
if (!response.allowed) {
|
|
171
|
+
throw denialToException(response);
|
|
152
172
|
}
|
|
153
173
|
}
|
|
154
174
|
/**
|
|
155
175
|
* Get the authorization response.
|
|
156
176
|
*/
|
|
157
177
|
async inspect(ability, ...args) {
|
|
158
|
-
|
|
159
|
-
return allowed ? Response.allow() : Response.deny();
|
|
178
|
+
return this.checkResponse(ability, this.currentUser, ...args);
|
|
160
179
|
}
|
|
161
180
|
/**
|
|
162
181
|
* Check the ability with a specific user.
|
|
163
182
|
*/
|
|
164
183
|
async check(ability, user, ...args) {
|
|
184
|
+
const response = await this.checkResponse(ability, user, ...args);
|
|
185
|
+
return response.allowed;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Check the ability with a specific user and keep the full response.
|
|
189
|
+
*
|
|
190
|
+
* Policies may answer with a boolean or with a `Response` object. Both
|
|
191
|
+
* shapes are normalized here so no caller has to truthy-test a
|
|
192
|
+
* `{ allowed: false }` object.
|
|
193
|
+
*/
|
|
194
|
+
async checkResponse(ability, user, ...args) {
|
|
165
195
|
for (const beforeCallback of this.beforeCallbacks) {
|
|
166
196
|
const result = await beforeCallback(user, ability, ...args);
|
|
167
|
-
if (
|
|
168
|
-
|
|
169
|
-
return result;
|
|
197
|
+
if (result !== void 0) {
|
|
198
|
+
return this.settle(user, ability, toAuthorizationResponse(result), args);
|
|
170
199
|
}
|
|
171
200
|
}
|
|
172
201
|
const model = args[0];
|
|
173
202
|
if (model !== void 0 && model !== null) {
|
|
174
203
|
const policyResult = await this.checkPolicy(ability, user, model, args.slice(1));
|
|
175
204
|
if (policyResult !== void 0) {
|
|
176
|
-
|
|
177
|
-
return policyResult;
|
|
205
|
+
return this.settle(user, ability, toAuthorizationResponse(policyResult), args);
|
|
178
206
|
}
|
|
179
207
|
}
|
|
180
208
|
const gate = this.gates.get(ability);
|
|
181
209
|
if (gate) {
|
|
182
210
|
const result = await gate.callback(user, ...args);
|
|
183
|
-
|
|
184
|
-
return result;
|
|
211
|
+
return this.settle(user, ability, toAuthorizationResponse(result), args);
|
|
185
212
|
}
|
|
186
|
-
|
|
187
|
-
|
|
213
|
+
return this.settle(user, ability, Response.deny(), args);
|
|
214
|
+
}
|
|
215
|
+
async settle(user, ability, response, args) {
|
|
216
|
+
await this.runAfterCallbacks(user, ability, response.allowed, args);
|
|
217
|
+
return response;
|
|
188
218
|
}
|
|
189
219
|
/**
|
|
190
220
|
* Check a policy for the given ability.
|
|
@@ -217,7 +247,7 @@ var Gate = class {
|
|
|
217
247
|
const policy = this.getPolicyInstance(policyClass);
|
|
218
248
|
if (policy.before) {
|
|
219
249
|
const beforeResult = await policy.before(user, ability);
|
|
220
|
-
if (
|
|
250
|
+
if (beforeResult !== void 0) {
|
|
221
251
|
return beforeResult;
|
|
222
252
|
}
|
|
223
253
|
}
|
|
@@ -361,16 +391,15 @@ function authorizeMiddleware(ability, modelResolver, options = {}) {
|
|
|
361
391
|
const gateForUser = gate.forUser(user);
|
|
362
392
|
const abilities = Array.isArray(ability) ? ability : [ability];
|
|
363
393
|
const model = modelResolver ? await modelResolver(ctx) : void 0;
|
|
364
|
-
let authorized = false;
|
|
365
394
|
if (Array.isArray(ability)) {
|
|
366
|
-
|
|
395
|
+
if (!await gateForUser.any(abilities, model)) {
|
|
396
|
+
throw new AuthorizationException(options.message ?? "This action is unauthorized.");
|
|
397
|
+
}
|
|
367
398
|
} else {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
options.message ?? "This action is unauthorized."
|
|
373
|
-
);
|
|
399
|
+
const response = await gateForUser.checkResponse(ability, user, model);
|
|
400
|
+
if (!response.allowed) {
|
|
401
|
+
throw denialToException(options.message ? { ...response, message: options.message } : response);
|
|
402
|
+
}
|
|
374
403
|
}
|
|
375
404
|
await next();
|
|
376
405
|
};
|
|
@@ -416,11 +445,9 @@ function authorizeResourceMiddleware(modelResolver, options = {}) {
|
|
|
416
445
|
const user = await gate.resolveUser(ctx);
|
|
417
446
|
const gateForUser = gate.forUser(user);
|
|
418
447
|
const model = await modelResolver(ctx);
|
|
419
|
-
const
|
|
420
|
-
if (!
|
|
421
|
-
throw
|
|
422
|
-
options.message ?? "This action is unauthorized."
|
|
423
|
-
);
|
|
448
|
+
const response = await gateForUser.checkResponse(ability, user, model);
|
|
449
|
+
if (!response.allowed) {
|
|
450
|
+
throw denialToException(options.message ? { ...response, message: options.message } : response);
|
|
424
451
|
}
|
|
425
452
|
await next();
|
|
426
453
|
};
|
|
@@ -445,6 +472,7 @@ function withAuthorization(gate) {
|
|
|
445
472
|
|
|
446
473
|
export {
|
|
447
474
|
Response,
|
|
475
|
+
isAuthorizationResponse,
|
|
448
476
|
Gate,
|
|
449
477
|
createGate,
|
|
450
478
|
setGate,
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createLoopbackGuard
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LHR6OHI7.js";
|
|
4
4
|
|
|
5
5
|
// src/docs-viewer/endpoint.ts
|
|
6
6
|
var DOCS_VIEWER_PATH = "/_guren/docs";
|
|
7
7
|
function isDocsViewerEnabled() {
|
|
8
|
-
|
|
8
|
+
if (typeof process === "undefined") {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
if (process.env.NODE_ENV === "production") {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
return process.env.GUREN_DOCS === "1";
|
|
9
15
|
}
|
|
10
16
|
function createDocsViewerAccessGuard() {
|
|
11
17
|
return createLoopbackGuard("the docs viewer");
|
|
@@ -7,9 +7,11 @@ import {
|
|
|
7
7
|
var MemoryStore = class {
|
|
8
8
|
cache = /* @__PURE__ */ new Map();
|
|
9
9
|
maxSize;
|
|
10
|
+
now;
|
|
10
11
|
checkInterval = null;
|
|
11
12
|
constructor(options = {}) {
|
|
12
13
|
this.maxSize = options.maxSize ?? Infinity;
|
|
14
|
+
this.now = options.now ?? Date.now;
|
|
13
15
|
const checkPeriod = options.checkPeriod ?? 6e4;
|
|
14
16
|
if (checkPeriod > 0) {
|
|
15
17
|
this.checkInterval = setInterval(() => {
|
|
@@ -24,7 +26,7 @@ var MemoryStore = class {
|
|
|
24
26
|
* Remove expired items from the cache.
|
|
25
27
|
*/
|
|
26
28
|
removeExpired() {
|
|
27
|
-
const now =
|
|
29
|
+
const now = this.now();
|
|
28
30
|
for (const [key, item] of this.cache) {
|
|
29
31
|
if (item.expiresAt !== null && item.expiresAt <= now) {
|
|
30
32
|
this.cache.delete(key);
|
|
@@ -35,7 +37,7 @@ var MemoryStore = class {
|
|
|
35
37
|
* Check if an item is expired.
|
|
36
38
|
*/
|
|
37
39
|
isExpired(item) {
|
|
38
|
-
return item.expiresAt !== null && item.expiresAt <=
|
|
40
|
+
return item.expiresAt !== null && item.expiresAt <= this.now();
|
|
39
41
|
}
|
|
40
42
|
/**
|
|
41
43
|
* Evict items if cache is full.
|
|
@@ -61,7 +63,7 @@ var MemoryStore = class {
|
|
|
61
63
|
}
|
|
62
64
|
async set(key, value, ttl) {
|
|
63
65
|
this.evictIfNeeded();
|
|
64
|
-
const expiresAt = ttl ?
|
|
66
|
+
const expiresAt = ttl ? this.now() + ttl * 1e3 : null;
|
|
65
67
|
this.cache.set(key, {
|
|
66
68
|
value,
|
|
67
69
|
expiresAt
|
|
@@ -88,7 +90,7 @@ var MemoryStore = class {
|
|
|
88
90
|
const current = await this.get(key);
|
|
89
91
|
const newValue = (current ?? 0) + value;
|
|
90
92
|
const item = this.cache.get(key);
|
|
91
|
-
const ttl = item?.expiresAt ? Math.max(0, Math.ceil((item.expiresAt -
|
|
93
|
+
const ttl = item?.expiresAt ? Math.max(0, Math.ceil((item.expiresAt - this.now()) / 1e3)) : void 0;
|
|
92
94
|
await this.set(key, newValue, ttl);
|
|
93
95
|
return newValue;
|
|
94
96
|
}
|
|
@@ -146,7 +148,7 @@ var MemoryStore = class {
|
|
|
146
148
|
if (item.expiresAt === null) {
|
|
147
149
|
return -1;
|
|
148
150
|
}
|
|
149
|
-
return Math.max(0, Math.ceil((item.expiresAt -
|
|
151
|
+
return Math.max(0, Math.ceil((item.expiresAt - this.now()) / 1e3));
|
|
150
152
|
}
|
|
151
153
|
/**
|
|
152
154
|
* Get the number of items in the cache.
|
|
@@ -313,9 +315,11 @@ import { createHash } from "crypto";
|
|
|
313
315
|
var FileStore = class {
|
|
314
316
|
basePath;
|
|
315
317
|
extension;
|
|
318
|
+
now;
|
|
316
319
|
constructor(options) {
|
|
317
320
|
this.basePath = options.path;
|
|
318
321
|
this.extension = options.extension ?? ".cache";
|
|
322
|
+
this.now = options.now ?? Date.now;
|
|
319
323
|
}
|
|
320
324
|
/**
|
|
321
325
|
* Generate a hashed filename for a cache key.
|
|
@@ -367,7 +371,7 @@ var FileStore = class {
|
|
|
367
371
|
* Check if a cached item is expired.
|
|
368
372
|
*/
|
|
369
373
|
isExpired(item) {
|
|
370
|
-
return item.expiresAt !== null && item.expiresAt <=
|
|
374
|
+
return item.expiresAt !== null && item.expiresAt <= this.now();
|
|
371
375
|
}
|
|
372
376
|
async get(key) {
|
|
373
377
|
const filePath = this.getFilePath(key);
|
|
@@ -383,7 +387,7 @@ var FileStore = class {
|
|
|
383
387
|
}
|
|
384
388
|
async set(key, value, ttl) {
|
|
385
389
|
const filePath = this.getFilePath(key);
|
|
386
|
-
const expiresAt = ttl ?
|
|
390
|
+
const expiresAt = ttl ? this.now() + ttl * 1e3 : null;
|
|
387
391
|
await this.writeCacheFile(filePath, {
|
|
388
392
|
value,
|
|
389
393
|
expiresAt
|
|
@@ -409,7 +413,7 @@ var FileStore = class {
|
|
|
409
413
|
const newValue = (current ?? 0) + value;
|
|
410
414
|
const filePath = this.getFilePath(key);
|
|
411
415
|
const item = await this.readCacheFile(filePath);
|
|
412
|
-
const ttl = item?.expiresAt ? Math.max(0, Math.ceil((item.expiresAt -
|
|
416
|
+
const ttl = item?.expiresAt ? Math.max(0, Math.ceil((item.expiresAt - this.now()) / 1e3)) : void 0;
|
|
413
417
|
await this.set(key, newValue, ttl);
|
|
414
418
|
return newValue;
|
|
415
419
|
}
|
|
@@ -470,7 +474,7 @@ var FileStore = class {
|
|
|
470
474
|
if (item.expiresAt === null) {
|
|
471
475
|
return -1;
|
|
472
476
|
}
|
|
473
|
-
return Math.max(0, Math.ceil((item.expiresAt -
|
|
477
|
+
return Math.max(0, Math.ceil((item.expiresAt - this.now()) / 1e3));
|
|
474
478
|
}
|
|
475
479
|
/**
|
|
476
480
|
* Clean up expired cache files.
|
|
@@ -99,6 +99,7 @@ function selectPluralForm(translation, count, rule) {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
// src/i18n/Translator.ts
|
|
102
|
+
var REGEXP_SPECIALS = /[.*+?^${}()|[\]\\]/g;
|
|
102
103
|
var Translator = class {
|
|
103
104
|
locale;
|
|
104
105
|
fallbackLocale;
|
|
@@ -231,7 +232,9 @@ var Translator = class {
|
|
|
231
232
|
if (!replacements) return translation;
|
|
232
233
|
let result = translation;
|
|
233
234
|
for (const [key, value] of Object.entries(replacements)) {
|
|
234
|
-
|
|
235
|
+
const escaped = key.replace(REGEXP_SPECIALS, "\\$&");
|
|
236
|
+
const replacement = () => String(value);
|
|
237
|
+
result = result.replace(new RegExp(`:${escaped}`, "g"), replacement).replace(new RegExp(`\\{${escaped}\\}`, "g"), replacement);
|
|
235
238
|
}
|
|
236
239
|
return result;
|
|
237
240
|
}
|
|
@@ -496,12 +499,23 @@ var I18nManager = class {
|
|
|
496
499
|
return new Translator({
|
|
497
500
|
locale,
|
|
498
501
|
fallbackLocale: this.config.fallbackLocale,
|
|
499
|
-
messages:
|
|
500
|
-
[locale]: this.translator.getMessages(locale),
|
|
501
|
-
...this.config.fallbackLocale ? { [this.config.fallbackLocale]: this.translator.getMessages(this.config.fallbackLocale) } : {}
|
|
502
|
-
}
|
|
502
|
+
messages: this.messagesForLocale(locale)
|
|
503
503
|
});
|
|
504
504
|
}
|
|
505
|
+
/**
|
|
506
|
+
* The message catalogs that accompany a locale: the fallback locale's
|
|
507
|
+
* (when it differs) plus the locale's own, in that order — so consumers
|
|
508
|
+
* that flatten the record let the active locale win on key collisions.
|
|
509
|
+
*/
|
|
510
|
+
messagesForLocale(locale) {
|
|
511
|
+
const fallback = this.config.fallbackLocale;
|
|
512
|
+
const messages = {};
|
|
513
|
+
if (fallback && fallback !== locale) {
|
|
514
|
+
messages[fallback] = this.translator.getMessages(fallback);
|
|
515
|
+
}
|
|
516
|
+
messages[locale] = this.translator.getMessages(locale);
|
|
517
|
+
return messages;
|
|
518
|
+
}
|
|
505
519
|
};
|
|
506
520
|
var globalI18n = null;
|
|
507
521
|
function createI18n(config) {
|
|
@@ -516,6 +530,9 @@ function getI18n() {
|
|
|
516
530
|
}
|
|
517
531
|
return globalI18n;
|
|
518
532
|
}
|
|
533
|
+
function tryGetI18n() {
|
|
534
|
+
return globalI18n ?? void 0;
|
|
535
|
+
}
|
|
519
536
|
function t(key, replacements) {
|
|
520
537
|
return getI18n().t(key, replacements);
|
|
521
538
|
}
|
|
@@ -592,6 +609,7 @@ export {
|
|
|
592
609
|
createI18n,
|
|
593
610
|
setI18n,
|
|
594
611
|
getI18n,
|
|
612
|
+
tryGetI18n,
|
|
595
613
|
t,
|
|
596
614
|
tc,
|
|
597
615
|
MemoryLoader
|
|
@@ -157,6 +157,9 @@ function clientAddress(ctx) {
|
|
|
157
157
|
}
|
|
158
158
|
return env.server.requestIP(ctx.req.raw)?.address;
|
|
159
159
|
}
|
|
160
|
+
function allowsUnverifiedPeer() {
|
|
161
|
+
return typeof process !== "undefined" && process.env.GUREN_ALLOW_UNVERIFIED_PEER === "1";
|
|
162
|
+
}
|
|
160
163
|
function createLoopbackGuard(resource) {
|
|
161
164
|
return async (ctx, next) => {
|
|
162
165
|
const origin = ctx.req.header("origin");
|
|
@@ -167,6 +170,14 @@ function createLoopbackGuard(resource) {
|
|
|
167
170
|
if (address !== void 0 && !isLoopbackAddress(address)) {
|
|
168
171
|
return ctx.json({ message: `Forbidden: remote request to ${resource}` }, 403);
|
|
169
172
|
}
|
|
173
|
+
if (address === void 0 && !allowsUnverifiedPeer()) {
|
|
174
|
+
return ctx.json(
|
|
175
|
+
{
|
|
176
|
+
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.`
|
|
177
|
+
},
|
|
178
|
+
403
|
|
179
|
+
);
|
|
180
|
+
}
|
|
170
181
|
await next();
|
|
171
182
|
};
|
|
172
183
|
}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createLoopbackGuard
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LHR6OHI7.js";
|
|
4
4
|
|
|
5
5
|
// src/mcp/endpoint.ts
|
|
6
6
|
var MCP_ENDPOINT_PATH = "/_guren/mcp";
|
|
7
7
|
function isMcpEndpointEnabled() {
|
|
8
|
-
|
|
8
|
+
if (typeof process === "undefined") {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
if (process.env.NODE_ENV === "production") {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
return process.env.GUREN_MCP === "1";
|
|
9
15
|
}
|
|
10
16
|
function createMcpAccessGuard() {
|
|
11
17
|
return createLoopbackGuard("the MCP endpoint");
|