@guren/server 2.10.0 → 2.10.1

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 (90) hide show
  1. package/dist/DocsViewerServiceProvider-qFCaeiUv.js +77 -0
  2. package/dist/Hash-CzrwKeDp.js +133 -0
  3. package/dist/HttpException-BkS3euNG.js +161 -0
  4. package/dist/Job-BVT813DO.js +441 -0
  5. package/dist/McpServiceProvider-BoAN-UcD.js +367 -0
  6. package/dist/MessageSigner-Bd25ZJAV.js +93 -0
  7. package/dist/Random-DbIJ22KQ.js +191 -0
  8. package/dist/address-D0Iq-XIH.js +20 -0
  9. package/dist/auth/index.js +2 -122
  10. package/dist/auth-C7sVmYgc.js +1954 -0
  11. package/dist/authorization/index.js +2 -38
  12. package/dist/authorization-Dbcuc5ZK.js +610 -0
  13. package/dist/broadcasting/index.js +2 -26
  14. package/dist/broadcasting-Dw-FhyjN.js +1055 -0
  15. package/dist/cache/index.js +2 -17
  16. package/dist/cache/types.d.ts +4 -4
  17. package/dist/cache-BYnZf2FR.js +812 -0
  18. package/dist/client-Dd7vLcqp.js +27 -0
  19. package/dist/console/Output.d.ts +18 -18
  20. package/dist/encryption/index.js +5 -96
  21. package/dist/encryption-fOWQaKqX.js +250 -0
  22. package/dist/endpoint-D-20PiHY.js +46 -0
  23. package/dist/endpoint-D6GIqOpe.js +31 -0
  24. package/dist/errors-quJOkkCn.js +81 -0
  25. package/dist/events/index.js +2 -28
  26. package/dist/events-aIH_bWRx.js +410 -0
  27. package/dist/health/index.js +2 -24
  28. package/dist/health-VWdWXRwh.js +345 -0
  29. package/dist/hot-disposables-WsTX2ySN.js +281 -0
  30. package/dist/hot-reload/testing.d.ts +1 -1
  31. package/dist/i18n/index.js +2 -30
  32. package/dist/i18n-mcWi7LCd.js +617 -0
  33. package/dist/index.js +7495 -7276
  34. package/dist/lambda/index.js +114 -71
  35. package/dist/logging/index.js +2 -24
  36. package/dist/logging-CPaRMuPP.js +518 -0
  37. package/dist/loopback-guard-D0Kc7-xc.js +224 -0
  38. package/dist/mail/index.js +2 -27
  39. package/dist/mail-DfEfSQEr.js +699 -0
  40. package/dist/mcp/index.js +2 -10
  41. package/dist/notifications/index.js +2 -33
  42. package/dist/notifications-BGqmUNZ8.js +759 -0
  43. package/dist/queue/index.js +3 -42
  44. package/dist/queue-CXrRK85G.js +948 -0
  45. package/dist/redis/index.js +672 -642
  46. package/dist/rolldown-runtime-8H4AJuhK.js +14 -0
  47. package/dist/runtime/index.js +472 -616
  48. package/dist/scheduling/index.js +2 -29
  49. package/dist/scheduling-CPiEdtQd.js +839 -0
  50. package/dist/storage/index.js +2 -15
  51. package/dist/storage-tWHMv2H_.js +841 -0
  52. package/dist/support/expiry.js +69 -12
  53. package/dist/trim-slashes-ZJ_VsY5s.js +25 -0
  54. package/dist/vite/index.js +118 -181
  55. package/dist/vite/plugin.d.ts +1 -1
  56. package/dist/vite-dev-server-CpCUqmiC.js +131 -0
  57. package/package.json +6 -5
  58. package/dist/DocsViewerServiceProvider-RUYDFBMW.js +0 -75
  59. package/dist/McpServiceProvider-SL7DUZ4G.js +0 -8
  60. package/dist/chunk-2SC566CD.js +0 -376
  61. package/dist/chunk-2V3YID4H.js +0 -20
  62. package/dist/chunk-3KV5X2FL.js +0 -31
  63. package/dist/chunk-63SKW5PS.js +0 -457
  64. package/dist/chunk-6J6B5KOB.js +0 -425
  65. package/dist/chunk-A5JJ7XTH.js +0 -24
  66. package/dist/chunk-AZOYI43J.js +0 -18
  67. package/dist/chunk-B5E5VBDI.js +0 -115
  68. package/dist/chunk-DAQKYKLH.js +0 -182
  69. package/dist/chunk-DRNPVBAA.js +0 -1002
  70. package/dist/chunk-EI5GYMAT.js +0 -853
  71. package/dist/chunk-H3B23O6T.js +0 -271
  72. package/dist/chunk-HPET6XY5.js +0 -853
  73. package/dist/chunk-HR2KZ3WL.js +0 -616
  74. package/dist/chunk-IOTWFHZU.js +0 -558
  75. package/dist/chunk-K6CUBJX6.js +0 -642
  76. package/dist/chunk-KTNJG7R7.js +0 -911
  77. package/dist/chunk-LAJQCSSF.js +0 -355
  78. package/dist/chunk-LHR6OHI7.js +0 -189
  79. package/dist/chunk-N7PLD7MB.js +0 -729
  80. package/dist/chunk-Q2P6YLRR.js +0 -24
  81. package/dist/chunk-QQKTH5KX.js +0 -114
  82. package/dist/chunk-SFQP6O52.js +0 -126
  83. package/dist/chunk-SQR7277M.js +0 -911
  84. package/dist/chunk-T2FFUU6J.js +0 -484
  85. package/dist/chunk-TVV5YNEC.js +0 -1842
  86. package/dist/chunk-UY3AZSYL.js +0 -14
  87. package/dist/chunk-V4DNC2ER.js +0 -114
  88. package/dist/chunk-VSA3QY5Q.js +0 -274
  89. package/dist/chunk-YSOJKAAU.js +0 -427
  90. package/dist/errors-PUNHAFL2.js +0 -34
@@ -1,24 +0,0 @@
1
- import {
2
- createLoopbackGuard
3
- } from "./chunk-LHR6OHI7.js";
4
-
5
- // src/mcp/endpoint.ts
6
- var MCP_ENDPOINT_PATH = "/_guren/mcp";
7
- function isMcpEndpointEnabled() {
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";
15
- }
16
- function createMcpAccessGuard() {
17
- return createLoopbackGuard("the MCP endpoint");
18
- }
19
-
20
- export {
21
- MCP_ENDPOINT_PATH,
22
- isMcpEndpointEnabled,
23
- createMcpAccessGuard
24
- };
@@ -1,114 +0,0 @@
1
- // src/encryption/Hash.ts
2
- import {
3
- createHash,
4
- createHmac,
5
- randomBytes,
6
- scrypt,
7
- timingSafeEqual
8
- } from "crypto";
9
- import { promisify } from "util";
10
- var scryptAsync = promisify(scrypt);
11
- function hash(value, algorithm = "sha256", encoding = "hex") {
12
- return createHash(algorithm).update(value).digest(encoding);
13
- }
14
- function hmac(value, key, options = {}) {
15
- const { algorithm = "sha256", encoding = "hex" } = options;
16
- return createHmac(algorithm, key).update(value).digest(encoding);
17
- }
18
- function verifyHmac(value, signature, key, options = {}) {
19
- const expected = hmac(value, key, options);
20
- return secureCompare(signature, expected);
21
- }
22
- function sha256(value) {
23
- return hash(value, "sha256");
24
- }
25
- function sha512(value) {
26
- return hash(value, "sha512");
27
- }
28
- function md5(value) {
29
- return hash(value, "md5");
30
- }
31
- async function hashPassword(password, options = {}) {
32
- const {
33
- cost = 16384,
34
- // N
35
- memory = 8,
36
- // r (block size)
37
- saltLength = 16,
38
- keyLength = 64
39
- } = options;
40
- const salt = randomBytes(saltLength);
41
- const derived = await scryptAsync(password, salt, keyLength, {
42
- N: cost,
43
- r: memory,
44
- p: 1
45
- });
46
- const params = `N=${cost},r=${memory},p=1`;
47
- return `$scrypt$${params}$${salt.toString("base64")}$${derived.toString("base64")}`;
48
- }
49
- async function verifyPassword(password, hash2) {
50
- if (!hash2.startsWith("$scrypt$")) {
51
- throw new Error("Invalid password hash format.");
52
- }
53
- const parts = hash2.split("$");
54
- if (parts.length !== 5) {
55
- throw new Error("Invalid password hash format.");
56
- }
57
- const [, , paramsStr, saltB64, hashB64] = parts;
58
- const params = {};
59
- for (const param of paramsStr.split(",")) {
60
- const [key, value] = param.split("=");
61
- params[key] = parseInt(value, 10);
62
- }
63
- const salt = Buffer.from(saltB64, "base64");
64
- const expectedHash = Buffer.from(hashB64, "base64");
65
- const derived = await scryptAsync(password, salt, expectedHash.length, {
66
- N: params.N,
67
- r: params.r,
68
- p: params.p ?? 1
69
- });
70
- return timingSafeEqual(derived, expectedHash);
71
- }
72
- function needsRehash(hash2, options = {}) {
73
- const { cost = 16384, memory = 8 } = options;
74
- if (!hash2.startsWith("$scrypt$")) {
75
- return true;
76
- }
77
- const parts = hash2.split("$");
78
- if (parts.length !== 5) {
79
- return true;
80
- }
81
- const paramsStr = parts[2];
82
- const params = {};
83
- for (const param of paramsStr.split(",")) {
84
- const [key, value] = param.split("=");
85
- params[key] = parseInt(value, 10);
86
- }
87
- return params.N !== cost || params.r !== memory;
88
- }
89
- function secureCompare(a, b) {
90
- if (a.length !== b.length) {
91
- return false;
92
- }
93
- const bufA = Buffer.from(a);
94
- const bufB = Buffer.from(b);
95
- return timingSafeEqual(bufA, bufB);
96
- }
97
- function check(value, hash2, algorithm = "sha256") {
98
- const computed = createHash(algorithm).update(value).digest("hex");
99
- return secureCompare(computed, hash2);
100
- }
101
-
102
- export {
103
- hash,
104
- hmac,
105
- verifyHmac,
106
- sha256,
107
- sha512,
108
- md5,
109
- hashPassword,
110
- verifyPassword,
111
- needsRehash,
112
- secureCompare,
113
- check
114
- };
@@ -1,126 +0,0 @@
1
- // src/encryption/app-key.ts
2
- import { hkdfSync, randomBytes } from "crypto";
3
- var APP_KEY_PREFIX = "base64:";
4
- var APP_KEY_BYTES = 32;
5
- function decodeAppKey(rawKey, envName) {
6
- const trimmed = rawKey.trim();
7
- if (!trimmed) {
8
- throw new Error(`${envName} is required and must be a base64-encoded 32-byte key.`);
9
- }
10
- const encoded = trimmed.startsWith(APP_KEY_PREFIX) ? trimmed.slice(APP_KEY_PREFIX.length) : trimmed;
11
- const decoded = Buffer.from(encoded, "base64");
12
- if (decoded.length !== APP_KEY_BYTES || decoded.toString("base64") !== encoded.replace(/\s+/gu, "")) {
13
- throw new Error(`${envName} must be a base64-encoded 32-byte key.`);
14
- }
15
- return decoded;
16
- }
17
- function normalizeAppKey(rawKey, envName = "APP_KEY") {
18
- return `${APP_KEY_PREFIX}${decodeAppKey(rawKey, envName).toString("base64")}`;
19
- }
20
- function parseAppKey(rawKey, envName = "APP_KEY") {
21
- return decodeAppKey(rawKey, envName);
22
- }
23
- function parsePreviousAppKeys(rawKeys, envName = "APP_PREVIOUS_KEYS") {
24
- if (!rawKeys) {
25
- return [];
26
- }
27
- return rawKeys.split(",").map((value) => value.trim()).filter(Boolean).map((value, index) => decodeAppKey(value, `${envName}[${index}]`));
28
- }
29
- function getAppKeyringFromEnv(env = process.env) {
30
- return {
31
- current: parseAppKey(env.APP_KEY ?? "", "APP_KEY"),
32
- previous: parsePreviousAppKeys(env.APP_PREVIOUS_KEYS)
33
- };
34
- }
35
- function deriveAppKey(rootKey, purpose) {
36
- return Buffer.from(
37
- hkdfSync("sha256", rootKey, Buffer.alloc(0), Buffer.from(`guren:${purpose}`, "utf8"), APP_KEY_BYTES)
38
- );
39
- }
40
- function deriveAppKeyring(keyring, purpose) {
41
- return {
42
- current: deriveAppKey(keyring.current, purpose),
43
- previous: keyring.previous.map((key) => deriveAppKey(key, purpose))
44
- };
45
- }
46
- function encodeDerivedKey(key) {
47
- return `${APP_KEY_PREFIX}${key.toString("base64")}`;
48
- }
49
- function generateAppKey() {
50
- return `${APP_KEY_PREFIX}${randomBytes(APP_KEY_BYTES).toString("base64")}`;
51
- }
52
-
53
- // src/encryption/MessageSigner.ts
54
- import { createHmac, timingSafeEqual } from "crypto";
55
- function encodeBase64Url(value) {
56
- return Buffer.from(value).toString("base64url");
57
- }
58
- function decodeBase64Url(value) {
59
- return Buffer.from(value, "base64url").toString("utf8");
60
- }
61
- function createSignature(input, key) {
62
- return encodeBase64Url(createHmac("sha256", key).update(input).digest());
63
- }
64
- function signaturesMatch(actual, expected) {
65
- const actualBuffer = Buffer.from(actual, "utf8");
66
- const expectedBuffer = Buffer.from(expected, "utf8");
67
- if (actualBuffer.length !== expectedBuffer.length) {
68
- return false;
69
- }
70
- return timingSafeEqual(actualBuffer, expectedBuffer);
71
- }
72
- var MessageSigner = class {
73
- constructor(keyring) {
74
- this.keyring = keyring;
75
- }
76
- keyring;
77
- sign(payload, options = {}) {
78
- const now = Date.now();
79
- const claims = {
80
- ...payload,
81
- iat: Math.floor(now / 1e3),
82
- ...options.purpose ? { purpose: options.purpose } : {},
83
- ...typeof options.expiresIn === "number" ? { exp: Math.floor((now + options.expiresIn) / 1e3) } : {}
84
- };
85
- const encodedPayload = encodeBase64Url(JSON.stringify(claims));
86
- const signature = createSignature(encodedPayload, this.keyring.current);
87
- return `${encodedPayload}.${signature}`;
88
- }
89
- verify(token, options = {}) {
90
- const [encodedPayload, signature, extra] = token.split(".");
91
- if (!encodedPayload || !signature || extra) {
92
- return null;
93
- }
94
- const verified = [this.keyring.current, ...this.keyring.previous].some(
95
- (key) => signaturesMatch(signature, createSignature(encodedPayload, key))
96
- );
97
- if (!verified) {
98
- return null;
99
- }
100
- let payload;
101
- try {
102
- payload = JSON.parse(decodeBase64Url(encodedPayload));
103
- } catch {
104
- return null;
105
- }
106
- if (options.purpose && payload.purpose !== options.purpose) {
107
- return null;
108
- }
109
- if (typeof payload.exp === "number" && Math.floor(Date.now() / 1e3) > payload.exp && options.allowExpired !== true) {
110
- return null;
111
- }
112
- return payload;
113
- }
114
- };
115
-
116
- export {
117
- normalizeAppKey,
118
- parseAppKey,
119
- parsePreviousAppKeys,
120
- getAppKeyringFromEnv,
121
- deriveAppKey,
122
- deriveAppKeyring,
123
- encodeDerivedKey,
124
- generateAppKey,
125
- MessageSigner
126
- };