@guren/server 1.5.0 → 2.1.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.
Files changed (53) hide show
  1. package/dist/{AuthManager-C84xF5ks.d.ts → AuthManager-DBP4KYsx.d.ts} +1 -1
  2. package/dist/{ConsoleKernel-D0dkFt6u.d.ts → ConsoleKernel-CJg975mp.d.ts} +1 -1
  3. package/dist/DocsViewerServiceProvider-D7RGJPGM.js +75 -0
  4. package/dist/{I18nManager-CmUqj6bU.d.ts → I18nManager-BiSoczfV.d.ts} +1 -1
  5. package/dist/McpServiceProvider-7BB5FPF3.js +8 -0
  6. package/dist/auth/index.d.ts +39 -29
  7. package/dist/auth/index.js +2 -2
  8. package/dist/broadcasting/index.js +2 -2
  9. package/dist/cache/index.js +2 -2
  10. package/dist/chunk-2V3YID4H.js +20 -0
  11. package/dist/chunk-AZOYI43J.js +18 -0
  12. package/dist/{chunk-DCYKSYAT.js → chunk-B5E5VBDI.js} +54 -2
  13. package/dist/{chunk-NYQGAWDN.js → chunk-BZMZEFRG.js} +7 -11
  14. package/dist/{chunk-4SBGSJNT.js → chunk-CWI4AJ47.js} +2 -1
  15. package/dist/{chunk-NQCZQAJL.js → chunk-DSDX3ASM.js} +21 -2
  16. package/dist/{chunk-SHYRVOMJ.js → chunk-EARA7JM4.js} +3 -3
  17. package/dist/{chunk-MC752CQT.js → chunk-EI5GYMAT.js} +2 -1
  18. package/dist/{chunk-AUXQISW5.js → chunk-HONCNQXZ.js} +38 -5
  19. package/dist/{chunk-CSRQTEQA.js → chunk-HWEWL6TE.js} +6 -1
  20. package/dist/chunk-JBG4AR24.js +18 -0
  21. package/dist/{chunk-RNXTRWKL.js → chunk-K6CUBJX6.js} +9 -15
  22. package/dist/{chunk-Z3HXKWI6.js → chunk-KTNJG7R7.js} +4 -0
  23. package/dist/{chunk-74HTZG3V.js → chunk-LAJQCSSF.js} +24 -0
  24. package/dist/{chunk-H32L2NE3.js → chunk-LVJCZCAV.js} +20 -13
  25. package/dist/{chunk-5AD7LYWO.js → chunk-N7PLD7MB.js} +9 -8
  26. package/dist/{chunk-ONSDE37A.js → chunk-SFQP6O52.js} +1 -0
  27. package/dist/{chunk-XMQZENBP.js → chunk-TVY72CLV.js} +3 -1
  28. package/dist/chunk-WIXGT4TN.js +18 -0
  29. package/dist/{email-verification-H_WlpsVH.d.ts → email-verification-D60YF2ZO.d.ts} +5 -3
  30. package/dist/encryption/index.js +2 -2
  31. package/dist/events/index.js +1 -1
  32. package/dist/i18n/index.d.ts +2 -2
  33. package/dist/index.d.ts +333 -333
  34. package/dist/index.js +242 -88
  35. package/dist/lambda/index.d.ts +5 -5
  36. package/dist/mail/index.js +3 -2
  37. package/dist/mcp/index.d.ts +14 -4
  38. package/dist/mcp/index.js +3 -2
  39. package/dist/notifications/index.d.ts +5 -5
  40. package/dist/notifications/index.js +3 -2
  41. package/dist/queue/index.d.ts +5 -5
  42. package/dist/queue/index.js +1 -1
  43. package/dist/redis/index.d.ts +4 -4
  44. package/dist/redis/index.js +7 -0
  45. package/dist/runtime/index.d.ts +5 -5
  46. package/dist/runtime/index.js +24 -9
  47. package/dist/scheduling/index.js +2 -2
  48. package/dist/storage/index.js +2 -1
  49. package/dist/{Application-Bi-olFMF.d.ts → validation-yAL53e1S.d.ts} +776 -721
  50. package/package.json +3 -3
  51. package/dist/McpServiceProvider-TZWQWXCT.js +0 -7
  52. package/dist/{api-token-COQHXyM_.d.ts → api-token-D24VPr_E.d.ts} +101 -101
  53. package/dist/{client-BQwF2b9Y.d.ts → rate-limit-D9J2b4S1.d.ts} +36 -36
@@ -1,6 +1,6 @@
1
1
  import { Context } from 'hono';
2
2
  import { Model } from '@guren/orm';
3
- import { A as Authenticatable, U as UserProvider, a as AuthCredentials, b as AuthManagerContract, c as AuthManagerOptions, G as GuardFactory, P as ProviderFactory, d as GuardContext, e as Guard, f as AttachContextOptions, g as AuthContext } from './api-token-COQHXyM_.js';
3
+ import { A as Authenticatable, U as UserProvider, a as AuthCredentials, b as AuthManagerContract, c as AuthManagerOptions, G as GuardFactory, P as ProviderFactory, d as GuardContext, e as Guard, f as AttachContextOptions, g as AuthContext } from './api-token-D24VPr_E.js';
4
4
 
5
5
  interface PasswordHasher {
6
6
  hash(plain: string): Promise<string>;
@@ -1,4 +1,4 @@
1
- import { C as CommandClass, a as Container, O as OutputInterface, b as ConsoleKernelOptions } from './Application-Bi-olFMF.js';
1
+ import { C as CommandClass, a as Container, O as OutputInterface, b as ConsoleKernelOptions } from './validation-yAL53e1S.js';
2
2
 
3
3
  /**
4
4
  * Console kernel for managing and executing commands.
@@ -0,0 +1,75 @@
1
+ import {
2
+ DOCS_VIEWER_PATH,
3
+ createDocsViewerAccessGuard,
4
+ isDocsViewerEnabled
5
+ } from "./chunk-WIXGT4TN.js";
6
+ import {
7
+ ServiceProvider
8
+ } from "./chunk-BZMZEFRG.js";
9
+
10
+ // src/docs-viewer/DocsViewerServiceProvider.ts
11
+ import { createRequire } from "module";
12
+ import { readFile } from "fs/promises";
13
+ import { createHash } from "crypto";
14
+ import { join } from "path";
15
+ var DATA_CACHE_TTL_MS = 15e3;
16
+ var DocsViewerServiceProvider = class extends ServiceProvider {
17
+ register() {
18
+ }
19
+ async boot() {
20
+ if (!isDocsViewerEnabled()) {
21
+ return;
22
+ }
23
+ const app = this.container.make("app");
24
+ const hono = app.hono;
25
+ const cwd = process.cwd();
26
+ const cli = await import("@guren/cli");
27
+ const guard = createDocsViewerAccessGuard();
28
+ hono.use(DOCS_VIEWER_PATH, guard);
29
+ hono.use(`${DOCS_VIEWER_PATH}/*`, guard);
30
+ let shell = null;
31
+ hono.get(DOCS_VIEWER_PATH, async (ctx) => {
32
+ shell ??= readFile(cli.docsViewerAssetPath(), "utf-8");
33
+ return ctx.html(await shell);
34
+ });
35
+ let cached = null;
36
+ const payload = () => {
37
+ if (!cached || Date.now() - cached.at > DATA_CACHE_TTL_MS) {
38
+ cached = {
39
+ at: Date.now(),
40
+ payload: cli.buildDocsViewerData(cwd).then((data) => {
41
+ const body = JSON.stringify(data);
42
+ return { body, etag: `"${createHash("sha1").update(body).digest("hex")}"` };
43
+ })
44
+ };
45
+ }
46
+ return cached.payload;
47
+ };
48
+ hono.get(`${DOCS_VIEWER_PATH}/data.json`, async (ctx) => {
49
+ const { body, etag } = await payload();
50
+ if (ctx.req.header("if-none-match") === etag) {
51
+ return ctx.body(null, 304, { ETag: etag });
52
+ }
53
+ return ctx.body(body, 200, { "Content-Type": "application/json", ETag: etag });
54
+ });
55
+ let mermaid = null;
56
+ hono.get(`${DOCS_VIEWER_PATH}/assets/mermaid.js`, async (ctx) => {
57
+ try {
58
+ mermaid ??= readFile(
59
+ createRequire(join(cwd, "package.json")).resolve("mermaid/dist/mermaid.min.js")
60
+ );
61
+ const source = await mermaid;
62
+ return ctx.body(new Uint8Array(source), 200, {
63
+ "Content-Type": "text/javascript",
64
+ "Cache-Control": "max-age=3600"
65
+ });
66
+ } catch {
67
+ mermaid = null;
68
+ return ctx.json({ message: "mermaid is not installed (bun add -d mermaid)" }, 404);
69
+ }
70
+ });
71
+ }
72
+ };
73
+ export {
74
+ DocsViewerServiceProvider
75
+ };
@@ -272,4 +272,4 @@ declare function t(key: string, replacements?: ReplacementValues): string;
272
272
  */
273
273
  declare function tc(key: string, count: number, replacements?: ReplacementValues): string;
274
274
 
275
- export { I18nManager as I, type PluralizationRule as P, type ReplacementValues as R, Translator as T, type I18nConfig as a, type TranslationLoader as b, type TranslationLoaderFactory as c, type TranslationMessages as d, type TranslatorOptions as e, createI18n as f, getI18n as g, tc as h, setI18n as s, t };
275
+ export { I18nManager as I, type PluralizationRule as P, type ReplacementValues as R, type TranslationLoader as T, type I18nConfig as a, type TranslationLoaderFactory as b, type TranslationMessages as c, Translator as d, type TranslatorOptions as e, createI18n as f, getI18n as g, tc as h, setI18n as s, t };
@@ -0,0 +1,8 @@
1
+ import {
2
+ McpServiceProvider
3
+ } from "./chunk-DSDX3ASM.js";
4
+ import "./chunk-JBG4AR24.js";
5
+ import "./chunk-BZMZEFRG.js";
6
+ export {
7
+ McpServiceProvider
8
+ };
@@ -1,11 +1,33 @@
1
- import { P as PasswordHasher } from '../AuthManager-C84xF5ks.js';
2
- export { A as AuthManager, B as BaseUserProvider, M as ModelUserProvider } from '../AuthManager-C84xF5ks.js';
3
- import { A as Authenticatable, e as Guard, U as UserProvider, F as Session, a as AuthCredentials } from '../api-token-COQHXyM_.js';
4
- export { m as API_TOKEN_KEY, j as ApiToken, i as ApiTokenStore, f as AttachContextOptions, g as AuthContext, b as AuthManagerContract, c as AuthManagerOptions, B as BearerTokenMiddlewareOptions, n as CreateApiTokenOptions, o as CreateApiTokenResult, D as DefaultSanitizedKeys, d as GuardContext, G as GuardFactory, M as MemoryApiTokenStore, p as MemoryOAuthStateStore, r as OAuthAuthorizeOptions, s as OAuthCallbackPayload, t as OAuthFallbackEmail, l as OAuthManager, u as OAuthManagerOptions, v as OAuthProviderConfig, w as OAuthProviderFactoryInput, x as OAuthStateConfig, k as OAuthStatePayload, O as OAuthStateStore, y as OAuthTokenResult, z as OAuthUserProfile, P as ProviderFactory, E as Sanitized, H as buildOAuthAuthorizeUrl, I as buildOAuthRedirectUrl, J as createApiToken, K as createBearerTokenMiddleware, L as createDiscordOAuthProviderConfig, N as createGitHubOAuthProviderConfig, Q as createGoogleOAuthProviderConfig, R as createOAuthManager, T as createOAuthState, W as exchangeOAuthCode, X as fetchOAuthUserProfile, Y as getApiToken, Z as getApiTokenOrFail, $ as getUserApiTokens, a0 as parseApiToken, a1 as parseOAuthRedirectUrl, a2 as revokeAllApiTokens, a3 as revokeApiToken, a4 as sanitizeOAuthRedirect, a5 as tokenCan, a6 as tokenCanAll, a7 as tokenCanAny, a8 as verifyApiToken, a9 as verifyOAuthState } from '../api-token-COQHXyM_.js';
1
+ import { P as PasswordHasher } from '../AuthManager-DBP4KYsx.js';
2
+ export { A as AuthManager, B as BaseUserProvider, M as ModelUserProvider } from '../AuthManager-DBP4KYsx.js';
3
+ import { A as Authenticatable, e as Guard, U as UserProvider, F as Session, a as AuthCredentials } from '../api-token-D24VPr_E.js';
4
+ export { m as API_TOKEN_KEY, j as ApiToken, i as ApiTokenStore, f as AttachContextOptions, g as AuthContext, b as AuthManagerContract, c as AuthManagerOptions, B as BearerTokenMiddlewareOptions, n as CreateApiTokenOptions, o as CreateApiTokenResult, D as DefaultSanitizedKeys, d as GuardContext, G as GuardFactory, M as MemoryApiTokenStore, p as MemoryOAuthStateStore, r as OAuthAuthorizeOptions, s as OAuthCallbackPayload, t as OAuthFallbackEmail, l as OAuthManager, u as OAuthManagerOptions, v as OAuthProviderConfig, w as OAuthProviderFactoryInput, x as OAuthStateConfig, k as OAuthStatePayload, O as OAuthStateStore, y as OAuthTokenResult, z as OAuthUserProfile, P as ProviderFactory, E as Sanitized, H as buildOAuthAuthorizeUrl, I as buildOAuthRedirectUrl, J as createApiToken, K as createBearerTokenMiddleware, L as createDiscordOAuthProviderConfig, N as createGitHubOAuthProviderConfig, Q as createGoogleOAuthProviderConfig, R as createOAuthManager, T as createOAuthState, W as exchangeOAuthCode, X as fetchOAuthUserProfile, Y as getApiToken, Z as getApiTokenOrFail, $ as getUserApiTokens, a0 as parseApiToken, a1 as parseOAuthRedirectUrl, a2 as revokeAllApiTokens, a3 as revokeApiToken, a4 as sanitizeOAuthRedirect, a5 as tokenCan, a6 as tokenCanAll, a7 as tokenCanAny, a8 as verifyApiToken, a9 as verifyOAuthState } from '../api-token-D24VPr_E.js';
5
5
  import { PlainObject, Model } from '@guren/orm';
6
- export { b as EmailVerificationConfig, a as EmailVerificationToken, c as EmailVerificationTokenResult, E as EmailVerificationTokenStore, M as MemoryEmailVerificationStore, d as MemoryPasswordResetStore, e as PasswordResetConfig, f as PasswordResetTokenResult, P as PasswordResetTokenStore, g as buildPasswordResetUrl, q as buildTokenUrl, h as buildVerificationUrl, i as completeEmailVerification, j as completePasswordReset, k as createEmailVerificationToken, l as createPasswordResetToken, s as generateId, t as generateToken, u as hashToken, m as isEmailVerified, p as parsePasswordResetUrl, w as parseTokenUrl, n as parseVerificationUrl, r as requireVerifiedEmail, x as secureCompare, y as secureStringCompare, v as verifyEmailToken, o as verifyPasswordResetToken } from '../email-verification-H_WlpsVH.js';
6
+ export { b as EmailVerificationConfig, a as EmailVerificationToken, c as EmailVerificationTokenResult, E as EmailVerificationTokenStore, M as MemoryEmailVerificationStore, d as MemoryPasswordResetStore, e as PasswordResetConfig, f as PasswordResetTokenResult, P as PasswordResetTokenStore, g as buildPasswordResetUrl, q as buildTokenUrl, h as buildVerificationUrl, i as completeEmailVerification, j as completePasswordReset, k as createEmailVerificationToken, l as createPasswordResetToken, s as generateId, t as generateToken, u as hashToken, m as isEmailVerified, p as parsePasswordResetUrl, w as parseTokenUrl, n as parseVerificationUrl, r as requireVerifiedEmail, x as secureCompare, y as secureStringCompare, v as verifyEmailToken, o as verifyPasswordResetToken } from '../email-verification-D60YF2ZO.js';
7
7
  import 'hono';
8
8
 
9
+ interface NodeHasherOptions {
10
+ /** scrypt cost parameter (N). Defaults to 16384. */
11
+ cost?: number;
12
+ /** scrypt block size (r). Defaults to 8. */
13
+ memory?: number;
14
+ /** Salt length in bytes. Defaults to 16. */
15
+ saltLength?: number;
16
+ /** Derived key length in bytes. Defaults to 64. */
17
+ keyLength?: number;
18
+ }
19
+ /**
20
+ * Node.js-compatible password hasher using crypto.scrypt.
21
+ * Use this instead of ScryptHasher when deploying to non-Bun runtimes (e.g. AWS Lambda).
22
+ */
23
+ declare class NodeHasher implements PasswordHasher {
24
+ private readonly options;
25
+ constructor(options?: NodeHasherOptions);
26
+ hash(plain: string): Promise<string>;
27
+ verify(hashed: string, plain: string): Promise<boolean>;
28
+ needsRehash(hashed: string): boolean;
29
+ }
30
+
9
31
  interface SessionGuardOptions {
10
32
  provider: UserProvider;
11
33
  sessionKey?: string;
@@ -61,38 +83,26 @@ declare class ScryptHasher implements PasswordHasher {
61
83
  needsRehash(hashed: string): boolean;
62
84
  }
63
85
 
64
- interface NodeHasherOptions {
65
- /** scrypt cost parameter (N). Defaults to 16384. */
66
- cost?: number;
67
- /** scrypt block size (r). Defaults to 8. */
68
- memory?: number;
69
- /** Salt length in bytes. Defaults to 16. */
70
- saltLength?: number;
71
- /** Derived key length in bytes. Defaults to 64. */
72
- keyLength?: number;
73
- }
74
- /**
75
- * Node.js-compatible password hasher using crypto.scrypt.
76
- * Use this instead of ScryptHasher when deploying to non-Bun runtimes (e.g. AWS Lambda).
77
- */
78
- declare class NodeHasher implements PasswordHasher {
79
- private readonly options;
80
- constructor(options?: NodeHasherOptions);
81
- hash(plain: string): Promise<string>;
82
- verify(hashed: string, plain: string): Promise<boolean>;
83
- needsRehash(hashed: string): boolean;
84
- }
85
-
86
86
  declare abstract class AuthenticatableModel<TRecord extends PlainObject = PlainObject> extends Model<TRecord> {
87
- static readonly createType: PlainObject & {
87
+ static readonly createType: {
88
88
  password?: string;
89
89
  plainPassword?: string;
90
90
  };
91
91
  protected static passwordField: string;
92
92
  protected static passwordHashField: string;
93
+ protected static rememberTokenField: string;
93
94
  protected static passwordHasher: PasswordHasher | null;
94
95
  protected static resolvePasswordField(): string;
95
- protected static resolvePasswordHashField(): string;
96
+ static resolvePasswordHashField(): string;
97
+ static resolveRememberTokenField(): string;
98
+ /**
99
+ * Credential columns can never be mass-assigned: the resolved password-hash
100
+ * column (unless the model hashes in place into the password field itself)
101
+ * and the remember-token column. Resolved at call time so a renamed column
102
+ * stays covered. Use `forceCreate()`/`forceUpdate()` for trusted
103
+ * server-side values such as `passwordHash: 'oauth:...'`.
104
+ */
105
+ protected static deniedFields(): string[];
96
106
  protected static resolvePasswordHasher(): PasswordHasher;
97
107
  protected static preparePersistencePayload(data: PlainObject): Promise<PlainObject>;
98
108
  }
@@ -55,9 +55,9 @@ import {
55
55
  verifyEmailToken,
56
56
  verifyOAuthState,
57
57
  verifyPasswordResetToken
58
- } from "../chunk-AUXQISW5.js";
58
+ } from "../chunk-HONCNQXZ.js";
59
59
  import "../chunk-DAQKYKLH.js";
60
- import "../chunk-ONSDE37A.js";
60
+ import "../chunk-SFQP6O52.js";
61
61
  import "../chunk-QQKTH5KX.js";
62
62
  export {
63
63
  API_TOKEN_KEY,
@@ -9,8 +9,8 @@ import {
9
9
  createTypedBroadcaster,
10
10
  getBroadcastManager,
11
11
  setBroadcastManager
12
- } from "../chunk-XMQZENBP.js";
13
- import "../chunk-DCYKSYAT.js";
12
+ } from "../chunk-TVY72CLV.js";
13
+ import "../chunk-B5E5VBDI.js";
14
14
  export {
15
15
  BroadcastManager,
16
16
  Channel,
@@ -5,8 +5,8 @@ import {
5
5
  RedisStore,
6
6
  TaggedCache,
7
7
  createCacheManager
8
- } from "../chunk-4SBGSJNT.js";
9
- import "../chunk-DCYKSYAT.js";
8
+ } from "../chunk-CWI4AJ47.js";
9
+ import "../chunk-B5E5VBDI.js";
10
10
  export {
11
11
  CacheManager,
12
12
  FileStore,
@@ -0,0 +1,20 @@
1
+ // src/mail/address.ts
2
+ function parseMailAddress(input) {
3
+ if (typeof input !== "string") {
4
+ return input;
5
+ }
6
+ if (input.endsWith(">") && !/[\r\n\u2028\u2029]/u.test(input)) {
7
+ const open = input.lastIndexOf("<");
8
+ if (open > 0 && open < input.length - 2) {
9
+ return {
10
+ name: input.slice(0, open).trim(),
11
+ email: input.slice(open + 1, -1).trim()
12
+ };
13
+ }
14
+ }
15
+ return { email: input };
16
+ }
17
+
18
+ export {
19
+ parseMailAddress
20
+ };
@@ -0,0 +1,18 @@
1
+ // src/support/trim-slashes.ts
2
+ function trimTrailingSlashes(value) {
3
+ let end = value.length;
4
+ while (end > 0 && value[end - 1] === "/") end--;
5
+ return value.slice(0, end);
6
+ }
7
+ function trimSlashes(value) {
8
+ let start = 0;
9
+ let end = value.length;
10
+ while (start < end && value[start] === "/") start++;
11
+ while (end > start && value[end - 1] === "/") end--;
12
+ return value.slice(start, end);
13
+ }
14
+
15
+ export {
16
+ trimTrailingSlashes,
17
+ trimSlashes
18
+ };
@@ -1,3 +1,32 @@
1
+ // src/support/stack-frames.ts
2
+ var OPEN_PAREN = 40;
3
+ var CLOSE_PAREN = 41;
4
+ function isLineTerminator(code) {
5
+ return code === 10 || code === 13 || code === 8232 || code === 8233;
6
+ }
7
+ function matchingOpenParen(frame, closeIndex) {
8
+ if (frame.charCodeAt(closeIndex) !== CLOSE_PAREN) {
9
+ return void 0;
10
+ }
11
+ let depth = 0;
12
+ let leftmostOpen;
13
+ for (let index = closeIndex; index >= 0; index--) {
14
+ const code = frame.charCodeAt(index);
15
+ if (isLineTerminator(code)) {
16
+ break;
17
+ }
18
+ if (code === CLOSE_PAREN) {
19
+ depth++;
20
+ } else if (code === OPEN_PAREN) {
21
+ if (--depth === 0) {
22
+ return index;
23
+ }
24
+ leftmostOpen = index;
25
+ }
26
+ }
27
+ return leftmostOpen;
28
+ }
29
+
1
30
  // src/hot-reload/hot-disposables.ts
2
31
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("guren.server.hotDisposables");
3
32
  function getRegistry() {
@@ -9,9 +38,31 @@ function isHotReloadRuntime() {
9
38
  }
10
39
  var SYNTHETIC_FRAME_PATHS = /* @__PURE__ */ new Set(["unknown", "native", "<anonymous>"]);
11
40
  var LOCATION_SUFFIX = /:\d+(?::\d+)?$/;
41
+ var WHITESPACE = /\s/;
42
+ var LINE_TERMINATOR = /[\n\r\u2028\u2029]/;
43
+ function parseBareFrame(frame) {
44
+ const end = frame.trimEnd().length;
45
+ let cursor = 0;
46
+ while (cursor < end && WHITESPACE.test(frame[cursor])) cursor += 1;
47
+ if (!frame.startsWith("at", cursor)) return void 0;
48
+ const afterAt = cursor + 2;
49
+ let start = afterAt;
50
+ while (start < end && WHITESPACE.test(frame[start])) start += 1;
51
+ if (start === afterAt) return void 0;
52
+ const body = frame.slice(start, end);
53
+ return LINE_TERMINATOR.test(body) ? void 0 : body;
54
+ }
55
+ function parenthesizedLocation(frame) {
56
+ const trimmed = frame.trimEnd();
57
+ if (!trimmed.endsWith(")")) {
58
+ return void 0;
59
+ }
60
+ const open = matchingOpenParen(trimmed, trimmed.length - 1);
61
+ return open === void 0 ? void 0 : trimmed.slice(open + 1, -1);
62
+ }
12
63
  function parseFrameLocation(frame) {
13
- const location = frame.match(/\(([^()]*)\)\s*$/)?.[1] ?? frame.match(/^\s*at\s+(.+?)\s*$/)?.[1];
14
- if (!location || !LOCATION_SUFFIX.test(location)) {
64
+ const location = parenthesizedLocation(frame) ?? parseBareFrame(frame);
65
+ if (!location || location.startsWith("eval at ") || !LOCATION_SUFFIX.test(location)) {
15
66
  return void 0;
16
67
  }
17
68
  return location.replace(LOCATION_SUFFIX, "");
@@ -58,6 +109,7 @@ function claimHotDisposable(scope, stack, target, dispose) {
58
109
  }
59
110
 
60
111
  export {
112
+ matchingOpenParen,
61
113
  isHotReloadRuntime,
62
114
  claimHotDisposable
63
115
  };
@@ -3,6 +3,7 @@ var ServiceProvider = class {
3
3
  constructor(container) {
4
4
  this.container = container;
5
5
  }
6
+ container;
6
7
  /**
7
8
  * Whether this provider should be deferred.
8
9
  * Deferred providers are only loaded when one of their provided services is requested.
@@ -29,6 +30,7 @@ var ProviderManager = class {
29
30
  constructor(container) {
30
31
  this.container = container;
31
32
  }
33
+ container;
32
34
  providers = [];
33
35
  registered = /* @__PURE__ */ new Set();
34
36
  booted = /* @__PURE__ */ new Set();
@@ -133,11 +135,7 @@ var ProviderManager = class {
133
135
  }
134
136
  };
135
137
 
136
- // src/mcp/endpoint.ts
137
- var MCP_ENDPOINT_PATH = "/_guren/mcp";
138
- function isMcpEndpointEnabled() {
139
- return typeof process !== "undefined" && process.env?.NODE_ENV !== "production" && process.env?.GUREN_MCP === "1";
140
- }
138
+ // src/http/middleware/loopback-guard.ts
141
139
  var LOOPBACK_HOSTNAMES = /* @__PURE__ */ new Set(["localhost", "[::1]"]);
142
140
  var LOOPBACK_IPV4 = /^127\.\d+\.\d+\.\d+$/;
143
141
  function isLoopbackOrigin(origin) {
@@ -159,15 +157,15 @@ function clientAddress(ctx) {
159
157
  }
160
158
  return env.server.requestIP(ctx.req.raw)?.address;
161
159
  }
162
- function createMcpAccessGuard() {
160
+ function createLoopbackGuard(resource) {
163
161
  return async (ctx, next) => {
164
162
  const origin = ctx.req.header("origin");
165
163
  if (origin !== void 0 && !isLoopbackOrigin(origin)) {
166
- return ctx.json({ message: "Forbidden: cross-origin request to the MCP endpoint" }, 403);
164
+ return ctx.json({ message: `Forbidden: cross-origin request to ${resource}` }, 403);
167
165
  }
168
166
  const address = clientAddress(ctx);
169
167
  if (address !== void 0 && !isLoopbackAddress(address)) {
170
- return ctx.json({ message: "Forbidden: remote request to the MCP endpoint" }, 403);
168
+ return ctx.json({ message: `Forbidden: remote request to ${resource}` }, 403);
171
169
  }
172
170
  await next();
173
171
  };
@@ -176,7 +174,5 @@ function createMcpAccessGuard() {
176
174
  export {
177
175
  ServiceProvider,
178
176
  ProviderManager,
179
- MCP_ENDPOINT_PATH,
180
- isMcpEndpointEnabled,
181
- createMcpAccessGuard
177
+ createLoopbackGuard
182
178
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  claimHotDisposable,
3
3
  isHotReloadRuntime
4
- } from "./chunk-DCYKSYAT.js";
4
+ } from "./chunk-B5E5VBDI.js";
5
5
 
6
6
  // src/cache/stores/MemoryStore.ts
7
7
  var MemoryStore = class {
@@ -674,6 +674,7 @@ var TaggableCacheStoreWrapper = class {
674
674
  constructor(store) {
675
675
  this.store = store;
676
676
  }
677
+ store;
677
678
  get(key) {
678
679
  return this.store.get(key);
679
680
  }
@@ -1,9 +1,11 @@
1
1
  import {
2
2
  MCP_ENDPOINT_PATH,
3
- ServiceProvider,
4
3
  createMcpAccessGuard,
5
4
  isMcpEndpointEnabled
6
- } from "./chunk-NYQGAWDN.js";
5
+ } from "./chunk-JBG4AR24.js";
6
+ import {
7
+ ServiceProvider
8
+ } from "./chunk-BZMZEFRG.js";
7
9
 
8
10
  // src/mcp/create-mcp-server.ts
9
11
  import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
@@ -49,6 +51,23 @@ function createMcpServer(options) {
49
51
  }
50
52
  }
51
53
  );
54
+ if (cli.buildDocsGraphReport && cli.renderDocsGraphMarkdown) {
55
+ const { buildDocsGraphReport, renderDocsGraphMarkdown } = cli;
56
+ server.tool(
57
+ "guren_docs_graph",
58
+ 'The OKF docs relation graph: documents, entities, and code paths as nodes, verified relations (governs, body links, spec-view derivation) as edges. Narrow with entity or path to answer "which docs govern this, and which spec views regenerate from it?" BEFORE renaming or editing a file \u2014 guren_check only reports the breakage afterwards.',
59
+ {
60
+ entity: z.string().optional().describe("Narrow to the neighborhood of one model entity (case-insensitive)."),
61
+ path: z.string().optional().describe('Narrow to the neighborhood of one app-root-relative path (e.g. "app/Http/Controllers/PostController.ts").'),
62
+ format: z.enum(["json", "markdown"]).default("markdown").describe("Output format")
63
+ },
64
+ async ({ entity, path, format }) => {
65
+ const report = await buildDocsGraphReport({ cwd, entity, path });
66
+ const text = format === "markdown" ? renderDocsGraphMarkdown(report) : JSON.stringify(report, null, 2);
67
+ return { content: [{ type: "text", text }] };
68
+ }
69
+ );
70
+ }
52
71
  server.tool(
53
72
  "guren_check",
54
73
  "Validate route-to-controller-to-page consistency, check for empty controller methods, missing test files, and missing generated manifests.",
@@ -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: "1.5.0",
9
+ version: "2.1.0",
10
10
  type: "module",
11
11
  license: "MIT",
12
12
  repository: {
@@ -115,8 +115,8 @@ var package_default = {
115
115
  test: "bun test"
116
116
  },
117
117
  dependencies: {
118
- "@guren/orm": "^1.3.0",
119
- "@modelcontextprotocol/sdk": "^1.27.1",
118
+ "@guren/orm": "^2.1.0",
119
+ "@modelcontextprotocol/sdk": "^1.30.0",
120
120
  chalk: "^5.3.0",
121
121
  consola: "^3.4.2",
122
122
  figlet: "^1.7.0",
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  claimHotDisposable,
3
3
  isHotReloadRuntime
4
- } from "./chunk-DCYKSYAT.js";
4
+ } from "./chunk-B5E5VBDI.js";
5
5
 
6
6
  // src/scheduling/CronParser.ts
7
7
  function parseField(field, min, max) {
@@ -244,6 +244,7 @@ var PendingSchedule = class {
244
244
  constructor(callback) {
245
245
  this.callback = callback;
246
246
  }
247
+ callback;
247
248
  expression = "* * * * *";
248
249
  timezone;
249
250
  taskName;
@@ -5,7 +5,7 @@ import {
5
5
  MessageSigner,
6
6
  deriveAppKeyring,
7
7
  getAppKeyringFromEnv
8
- } from "./chunk-ONSDE37A.js";
8
+ } from "./chunk-SFQP6O52.js";
9
9
  import {
10
10
  hashPassword,
11
11
  needsRehash,
@@ -19,6 +19,7 @@ var MemorySessionStore = class {
19
19
  constructor(now = () => Date.now()) {
20
20
  this.now = now;
21
21
  }
22
+ now;
22
23
  store = /* @__PURE__ */ new Map();
23
24
  async read(id) {
24
25
  const entry = this.store.get(id);
@@ -65,6 +66,7 @@ var SessionImpl = class {
65
66
  };
66
67
  }
67
68
  }
69
+ isNew;
68
70
  currentId;
69
71
  originalId;
70
72
  data;
@@ -319,6 +321,10 @@ var RequestAuthContext = class {
319
321
  this.resolveSession = resolveSession;
320
322
  this.resolveGuard = resolveGuard;
321
323
  }
324
+ manager;
325
+ ctx;
326
+ resolveSession;
327
+ resolveGuard;
322
328
  guardCache = /* @__PURE__ */ new Map();
323
329
  guard(name) {
324
330
  const key = name ?? this.manager.getDefaultGuard();
@@ -443,17 +449,23 @@ var BaseUserProvider = class {
443
449
  };
444
450
 
445
451
  // src/auth/providers/ModelUserProvider.ts
452
+ function credentialColumnSource(model) {
453
+ const candidate = model;
454
+ return typeof candidate.resolvePasswordHashField === "function" && typeof candidate.resolveRememberTokenField === "function" ? candidate : null;
455
+ }
446
456
  var ModelUserProvider = class extends BaseUserProvider {
447
457
  constructor(model, options = {}) {
448
458
  super();
449
459
  this.model = model;
460
+ const authModel = credentialColumnSource(model);
450
461
  this.idColumn = options.idColumn ?? "id";
451
462
  this.usernameColumn = options.usernameColumn ?? "email";
452
- this.passwordColumn = options.passwordColumn ?? "password";
453
- this.rememberTokenColumn = options.rememberTokenColumn ?? "remember_token";
463
+ this.passwordColumn = options.passwordColumn ?? authModel?.resolvePasswordHashField() ?? "passwordHash";
464
+ this.rememberTokenColumn = options.rememberTokenColumn ?? authModel?.resolveRememberTokenField() ?? "rememberToken";
454
465
  this.hasher = options.hasher ?? new ScryptHasher();
455
466
  this.credentialsPasswordField = options.credentialsPasswordField ?? "password";
456
467
  }
468
+ model;
457
469
  idColumn;
458
470
  usernameColumn;
459
471
  passwordColumn;
@@ -505,9 +517,11 @@ var ModelUserProvider = class extends BaseUserProvider {
505
517
  * never affects login — only what `auth.user()` exposes.
506
518
  */
507
519
  sanitize(user) {
520
+ const authModel = credentialColumnSource(this.model);
508
521
  const blocked = /* @__PURE__ */ new Set([
509
522
  this.passwordColumn,
510
523
  this.rememberTokenColumn,
524
+ ...authModel ? [authModel.resolvePasswordHashField(), authModel.resolveRememberTokenField()] : [],
511
525
  ...this.model.hidden ?? []
512
526
  ]);
513
527
  const clean = {};
@@ -586,6 +600,7 @@ var SessionGuard = class {
586
600
  constructor(options) {
587
601
  this.options = options;
588
602
  }
603
+ options;
589
604
  cachedUser;
590
605
  get currentSession() {
591
606
  return this.options.session;
@@ -801,8 +816,6 @@ var AuthManager = class {
801
816
  useModel(model, options = {}, providerName = "users", guardName = "web") {
802
817
  const defaultOptions = {
803
818
  usernameColumn: "email",
804
- passwordColumn: "passwordHash",
805
- rememberTokenColumn: "rememberToken",
806
819
  credentialsPasswordField: "password",
807
820
  hasher: new ScryptHasher(),
808
821
  ...options
@@ -844,6 +857,7 @@ var AuthenticatableModel = class extends Model {
844
857
  static createType = void 0;
845
858
  static passwordField = "password";
846
859
  static passwordHashField = "passwordHash";
860
+ static rememberTokenField = "rememberToken";
847
861
  static passwordHasher = null;
848
862
  static resolvePasswordField() {
849
863
  return this.passwordField ?? "password";
@@ -851,6 +865,25 @@ var AuthenticatableModel = class extends Model {
851
865
  static resolvePasswordHashField() {
852
866
  return this.passwordHashField ?? "passwordHash";
853
867
  }
868
+ static resolveRememberTokenField() {
869
+ return this.rememberTokenField ?? "rememberToken";
870
+ }
871
+ /**
872
+ * Credential columns can never be mass-assigned: the resolved password-hash
873
+ * column (unless the model hashes in place into the password field itself)
874
+ * and the remember-token column. Resolved at call time so a renamed column
875
+ * stays covered. Use `forceCreate()`/`forceUpdate()` for trusted
876
+ * server-side values such as `passwordHash: 'oauth:...'`.
877
+ */
878
+ static deniedFields() {
879
+ const denied = [...super.deniedFields()];
880
+ const hashField = this.resolvePasswordHashField();
881
+ if (hashField !== this.resolvePasswordField()) {
882
+ denied.push(hashField);
883
+ }
884
+ denied.push(this.resolveRememberTokenField());
885
+ return denied;
886
+ }
854
887
  static resolvePasswordHasher() {
855
888
  if (this.passwordHasher) {
856
889
  return this.passwordHasher;
@@ -1,3 +1,7 @@
1
+ import {
2
+ trimSlashes
3
+ } from "./chunk-AZOYI43J.js";
4
+
1
5
  // src/storage/drivers/LocalDriver.ts
2
6
  import {
3
7
  readFile,
@@ -203,6 +207,7 @@ var S3Driver = class {
203
207
  this.baseUrl = options.url ?? `https://${this.bucket}.s3.${this.region}.amazonaws.com`;
204
208
  this.defaultVisibility = options.visibility ?? "private";
205
209
  }
210
+ options;
206
211
  client = null;
207
212
  bucket;
208
213
  region;
@@ -520,7 +525,7 @@ var MemoryDriver = class {
520
525
  * Normalize path (remove leading/trailing slashes).
521
526
  */
522
527
  normalizePath(path) {
523
- return path.replace(/^\/+|\/+$/g, "");
528
+ return trimSlashes(path);
524
529
  }
525
530
  /**
526
531
  * Get directory from path.