@guren/server 1.4.0 → 2.0.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/{AuthManager-C84xF5ks.d.ts → AuthManager-DBP4KYsx.d.ts} +1 -1
- package/dist/ConsoleKernel-DlK9j2Lu.d.ts +101 -0
- package/dist/DocsViewerServiceProvider-D7RGJPGM.js +75 -0
- package/dist/{I18nManager-CmUqj6bU.d.ts → I18nManager-BiSoczfV.d.ts} +1 -1
- package/dist/McpServiceProvider-7BB5FPF3.js +8 -0
- package/dist/auth/index.d.ts +39 -29
- package/dist/auth/index.js +2 -2
- package/dist/broadcasting/index.js +2 -2
- package/dist/cache/index.js +2 -2
- package/dist/chunk-2V3YID4H.js +20 -0
- package/dist/{chunk-JIT7QVMJ.js → chunk-4DW4GRWF.js} +3 -3
- package/dist/{chunk-R2TCP7D7.js → chunk-6J6B5KOB.js} +18 -2
- package/dist/chunk-AZOYI43J.js +18 -0
- package/dist/{chunk-DCYKSYAT.js → chunk-B5E5VBDI.js} +54 -2
- package/dist/{chunk-NYQGAWDN.js → chunk-BZMZEFRG.js} +7 -11
- package/dist/{chunk-4SBGSJNT.js → chunk-CWI4AJ47.js} +2 -1
- package/dist/{chunk-NQCZQAJL.js → chunk-DSDX3ASM.js} +21 -2
- package/dist/{chunk-MC752CQT.js → chunk-EI5GYMAT.js} +2 -1
- package/dist/{chunk-AUXQISW5.js → chunk-HONCNQXZ.js} +38 -5
- package/dist/{chunk-CSRQTEQA.js → chunk-HWEWL6TE.js} +6 -1
- package/dist/chunk-JBG4AR24.js +18 -0
- package/dist/{chunk-EDRGAM6G.js → chunk-K6CUBJX6.js} +11 -16
- package/dist/{chunk-WJJ5CTNI.js → chunk-KTNJG7R7.js} +6 -2
- package/dist/{chunk-74HTZG3V.js → chunk-LAJQCSSF.js} +24 -0
- package/dist/{chunk-H32L2NE3.js → chunk-LVJCZCAV.js} +20 -13
- package/dist/{chunk-CSDKWLFD.js → chunk-N7PLD7MB.js} +120 -43
- package/dist/{chunk-ONSDE37A.js → chunk-SFQP6O52.js} +1 -0
- package/dist/{chunk-XMQZENBP.js → chunk-TVY72CLV.js} +3 -1
- package/dist/chunk-WIXGT4TN.js +18 -0
- package/dist/{email-verification-H_WlpsVH.d.ts → email-verification-D8N7P6Pu.d.ts} +1 -1
- package/dist/encryption/index.js +2 -2
- package/dist/events/index.js +1 -1
- package/dist/i18n/index.d.ts +2 -2
- package/dist/index.d.ts +348 -330
- package/dist/index.js +332 -110
- package/dist/lambda/index.d.ts +5 -5
- package/dist/lambda/index.js +1 -1
- package/dist/mail/index.js +4 -3
- package/dist/mcp/index.d.ts +14 -4
- package/dist/mcp/index.js +3 -2
- package/dist/notifications/index.d.ts +55 -6
- package/dist/notifications/index.js +12 -3
- package/dist/queue/index.d.ts +5 -5
- package/dist/queue/index.js +4 -2
- package/dist/redis/index.d.ts +4 -4
- package/dist/redis/index.js +7 -0
- package/dist/runtime/index.d.ts +5 -5
- package/dist/runtime/index.js +24 -9
- package/dist/scheduling/index.js +2 -2
- package/dist/storage/index.js +2 -1
- package/dist/{Application-BvBqgc2k.d.ts → validation-CDR7lRE8.d.ts} +873 -654
- package/package.json +3 -3
- package/dist/ConsoleKernel-Dw9X9qZY.d.ts +0 -207
- package/dist/McpServiceProvider-TZWQWXCT.js +0 -7
- package/dist/{api-token-COQHXyM_.d.ts → api-token-D24VPr_E.d.ts} +101 -101
- 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-
|
|
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>;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { C as CommandClass, a as Container, O as OutputInterface, b as ConsoleKernelOptions } from './validation-CDR7lRE8.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Console kernel for managing and executing commands.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* const kernel = new ConsoleKernel()
|
|
9
|
+
*
|
|
10
|
+
* kernel.register(CreateUserCommand)
|
|
11
|
+
* kernel.register(SendNotificationsCommand)
|
|
12
|
+
*
|
|
13
|
+
* // Execute command
|
|
14
|
+
* const exitCode = await kernel.handle(['users:create', 'john@example.com', '--admin'])
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
declare class ConsoleKernel {
|
|
18
|
+
/**
|
|
19
|
+
* Registered commands.
|
|
20
|
+
*/
|
|
21
|
+
protected commands: Map<string, CommandClass>;
|
|
22
|
+
/**
|
|
23
|
+
* Service container.
|
|
24
|
+
*/
|
|
25
|
+
protected container?: Container;
|
|
26
|
+
/**
|
|
27
|
+
* Output instance.
|
|
28
|
+
*/
|
|
29
|
+
protected output: OutputInterface;
|
|
30
|
+
constructor(options?: ConsoleKernelOptions);
|
|
31
|
+
/**
|
|
32
|
+
* Register a command.
|
|
33
|
+
*/
|
|
34
|
+
register(command: CommandClass): this;
|
|
35
|
+
/**
|
|
36
|
+
* Register multiple commands.
|
|
37
|
+
*/
|
|
38
|
+
registerMany(commands: CommandClass[]): this;
|
|
39
|
+
/**
|
|
40
|
+
* Get all registered commands.
|
|
41
|
+
*/
|
|
42
|
+
getCommands(): Map<string, CommandClass>;
|
|
43
|
+
/**
|
|
44
|
+
* Get a command by name.
|
|
45
|
+
*/
|
|
46
|
+
getCommand(name: string): CommandClass | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Check if a command is registered.
|
|
49
|
+
*/
|
|
50
|
+
hasCommand(name: string): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Set the output instance.
|
|
53
|
+
*/
|
|
54
|
+
setOutput(output: OutputInterface): this;
|
|
55
|
+
/**
|
|
56
|
+
* Get the output instance.
|
|
57
|
+
*/
|
|
58
|
+
getOutput(): OutputInterface;
|
|
59
|
+
/**
|
|
60
|
+
* Handle command execution.
|
|
61
|
+
*/
|
|
62
|
+
handle(argv?: string[]): Promise<number>;
|
|
63
|
+
/**
|
|
64
|
+
* Run a command.
|
|
65
|
+
*/
|
|
66
|
+
protected runCommand(CommandClass: CommandClass, args: string[]): Promise<number>;
|
|
67
|
+
/**
|
|
68
|
+
* Show help.
|
|
69
|
+
*/
|
|
70
|
+
protected showHelp(): void;
|
|
71
|
+
/**
|
|
72
|
+
* Show help for a specific command.
|
|
73
|
+
*/
|
|
74
|
+
protected showCommandHelp(commandName: string): void;
|
|
75
|
+
/**
|
|
76
|
+
* List all commands.
|
|
77
|
+
*/
|
|
78
|
+
protected listCommands(): void;
|
|
79
|
+
/**
|
|
80
|
+
* Group commands by namespace.
|
|
81
|
+
*/
|
|
82
|
+
protected groupCommands(): Map<string, Map<string, CommandClass>>;
|
|
83
|
+
/**
|
|
84
|
+
* Suggest similar commands.
|
|
85
|
+
*/
|
|
86
|
+
protected suggestCommands(input: string): void;
|
|
87
|
+
/**
|
|
88
|
+
* Calculate string similarity (simple Dice coefficient).
|
|
89
|
+
*/
|
|
90
|
+
protected similarity(a: string, b: string): number;
|
|
91
|
+
/**
|
|
92
|
+
* Call a command programmatically.
|
|
93
|
+
*/
|
|
94
|
+
call(commandName: string, args?: string[], silent?: boolean): Promise<number>;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Create a console kernel.
|
|
98
|
+
*/
|
|
99
|
+
declare function createConsoleKernel(options?: ConsoleKernelOptions): ConsoleKernel;
|
|
100
|
+
|
|
101
|
+
export { ConsoleKernel as C, createConsoleKernel as c };
|
|
@@ -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,
|
|
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 };
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,11 +1,33 @@
|
|
|
1
|
-
import { P as PasswordHasher } from '../AuthManager-
|
|
2
|
-
export { A as AuthManager, B as BaseUserProvider, M as ModelUserProvider } from '../AuthManager-
|
|
3
|
-
import { A as Authenticatable, e as Guard, U as UserProvider, F as Session, a as AuthCredentials } from '../api-token-
|
|
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-
|
|
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-
|
|
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-D8N7P6Pu.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:
|
|
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
|
-
|
|
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
|
}
|
package/dist/auth/index.js
CHANGED
|
@@ -55,9 +55,9 @@ import {
|
|
|
55
55
|
verifyEmailToken,
|
|
56
56
|
verifyOAuthState,
|
|
57
57
|
verifyPasswordResetToken
|
|
58
|
-
} from "../chunk-
|
|
58
|
+
} from "../chunk-HONCNQXZ.js";
|
|
59
59
|
import "../chunk-DAQKYKLH.js";
|
|
60
|
-
import "../chunk-
|
|
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-
|
|
13
|
-
import "../chunk-
|
|
12
|
+
} from "../chunk-TVY72CLV.js";
|
|
13
|
+
import "../chunk-B5E5VBDI.js";
|
|
14
14
|
export {
|
|
15
15
|
BroadcastManager,
|
|
16
16
|
Channel,
|
package/dist/cache/index.js
CHANGED
|
@@ -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
|
+
};
|
|
@@ -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: "
|
|
9
|
+
version: "2.0.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": "^
|
|
119
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
118
|
+
"@guren/orm": "^2.0.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",
|
|
@@ -307,6 +307,17 @@ function generateJobId() {
|
|
|
307
307
|
return randomBytes(16).toString("hex");
|
|
308
308
|
}
|
|
309
309
|
var Job = class {
|
|
310
|
+
/**
|
|
311
|
+
* Stable wire name for this job.
|
|
312
|
+
*
|
|
313
|
+
* Queued messages record this name, and the worker resolves the class back
|
|
314
|
+
* from it. When omitted the class name is used, which breaks if a bundler
|
|
315
|
+
* mangles identifiers or if the class is later renamed while messages are
|
|
316
|
+
* still in flight. Set it to pin the name across both.
|
|
317
|
+
*
|
|
318
|
+
* @default the class name
|
|
319
|
+
*/
|
|
320
|
+
static jobName;
|
|
310
321
|
/**
|
|
311
322
|
* The queue this job should be dispatched to.
|
|
312
323
|
* @default 'default'
|
|
@@ -344,7 +355,7 @@ var Job = class {
|
|
|
344
355
|
const delay = options.delay ?? 0;
|
|
345
356
|
const job = {
|
|
346
357
|
id: jobId,
|
|
347
|
-
name: this
|
|
358
|
+
name: resolveJobName(this),
|
|
348
359
|
payload,
|
|
349
360
|
queue: options.queue ?? this.queue,
|
|
350
361
|
attempts: 0,
|
|
@@ -379,9 +390,13 @@ var Job = class {
|
|
|
379
390
|
return Math.pow(2, attempts) * 1e3;
|
|
380
391
|
}
|
|
381
392
|
};
|
|
393
|
+
function resolveJobName(jobClass) {
|
|
394
|
+
const own = Object.prototype.hasOwnProperty.call(jobClass, "jobName") ? jobClass.jobName : void 0;
|
|
395
|
+
return own ?? jobClass.name;
|
|
396
|
+
}
|
|
382
397
|
var jobRegistry = /* @__PURE__ */ new Map();
|
|
383
398
|
function registerJob(jobClass) {
|
|
384
|
-
jobRegistry.set(jobClass
|
|
399
|
+
jobRegistry.set(resolveJobName(jobClass), jobClass);
|
|
385
400
|
}
|
|
386
401
|
function getJob(name) {
|
|
387
402
|
return jobRegistry.get(name);
|
|
@@ -402,6 +417,7 @@ export {
|
|
|
402
417
|
setQueueDriver,
|
|
403
418
|
getQueueDriver,
|
|
404
419
|
Job,
|
|
420
|
+
resolveJobName,
|
|
405
421
|
registerJob,
|
|
406
422
|
getJob,
|
|
407
423
|
getRegisteredJobs,
|
|
@@ -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
|
|
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/
|
|
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
|
|
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:
|
|
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:
|
|
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
|
-
|
|
180
|
-
isMcpEndpointEnabled,
|
|
181
|
-
createMcpAccessGuard
|
|
177
|
+
createLoopbackGuard
|
|
182
178
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
claimHotDisposable,
|
|
3
3
|
isHotReloadRuntime
|
|
4
|
-
} from "./chunk-
|
|
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-
|
|
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.",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
claimHotDisposable,
|
|
3
3
|
isHotReloadRuntime
|
|
4
|
-
} from "./chunk-
|
|
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;
|