@guren/server 2.9.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 (92) 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/discovery/AutoDiscovery.d.ts +8 -0
  21. package/dist/encryption/index.js +5 -96
  22. package/dist/encryption-fOWQaKqX.js +250 -0
  23. package/dist/endpoint-D-20PiHY.js +46 -0
  24. package/dist/endpoint-D6GIqOpe.js +31 -0
  25. package/dist/errors-quJOkkCn.js +81 -0
  26. package/dist/events/index.js +2 -28
  27. package/dist/events-aIH_bWRx.js +410 -0
  28. package/dist/health/index.js +2 -24
  29. package/dist/health-VWdWXRwh.js +345 -0
  30. package/dist/hot-disposables-WsTX2ySN.js +281 -0
  31. package/dist/hot-reload/testing.d.ts +1 -1
  32. package/dist/http/Application.d.ts +0 -1
  33. package/dist/i18n/index.js +2 -30
  34. package/dist/i18n-mcWi7LCd.js +617 -0
  35. package/dist/index.js +7496 -7281
  36. package/dist/lambda/index.js +114 -71
  37. package/dist/logging/index.js +2 -24
  38. package/dist/logging-CPaRMuPP.js +518 -0
  39. package/dist/loopback-guard-D0Kc7-xc.js +224 -0
  40. package/dist/mail/index.js +2 -27
  41. package/dist/mail-DfEfSQEr.js +699 -0
  42. package/dist/mcp/index.js +2 -10
  43. package/dist/notifications/index.js +2 -33
  44. package/dist/notifications-BGqmUNZ8.js +759 -0
  45. package/dist/queue/index.js +3 -42
  46. package/dist/queue-CXrRK85G.js +948 -0
  47. package/dist/redis/index.js +672 -642
  48. package/dist/rolldown-runtime-8H4AJuhK.js +14 -0
  49. package/dist/runtime/index.js +474 -604
  50. package/dist/scheduling/index.js +2 -29
  51. package/dist/scheduling-CPiEdtQd.js +839 -0
  52. package/dist/storage/index.js +2 -15
  53. package/dist/storage-tWHMv2H_.js +841 -0
  54. package/dist/support/expiry.js +69 -12
  55. package/dist/trim-slashes-ZJ_VsY5s.js +25 -0
  56. package/dist/vite/index.js +118 -181
  57. package/dist/vite/plugin.d.ts +1 -1
  58. package/dist/vite-dev-server-CpCUqmiC.js +131 -0
  59. package/package.json +6 -5
  60. package/dist/DocsViewerServiceProvider-RUYDFBMW.js +0 -75
  61. package/dist/McpServiceProvider-SL7DUZ4G.js +0 -8
  62. package/dist/chunk-2SC566CD.js +0 -376
  63. package/dist/chunk-2V3YID4H.js +0 -20
  64. package/dist/chunk-3KV5X2FL.js +0 -31
  65. package/dist/chunk-63SKW5PS.js +0 -457
  66. package/dist/chunk-6J6B5KOB.js +0 -425
  67. package/dist/chunk-A5JJ7XTH.js +0 -24
  68. package/dist/chunk-AZOYI43J.js +0 -18
  69. package/dist/chunk-B5E5VBDI.js +0 -115
  70. package/dist/chunk-DAQKYKLH.js +0 -182
  71. package/dist/chunk-DRNPVBAA.js +0 -1002
  72. package/dist/chunk-EI5GYMAT.js +0 -853
  73. package/dist/chunk-H3B23O6T.js +0 -271
  74. package/dist/chunk-HPET6XY5.js +0 -853
  75. package/dist/chunk-HR2KZ3WL.js +0 -616
  76. package/dist/chunk-IOTWFHZU.js +0 -558
  77. package/dist/chunk-K6CUBJX6.js +0 -642
  78. package/dist/chunk-KTNJG7R7.js +0 -911
  79. package/dist/chunk-LAJQCSSF.js +0 -355
  80. package/dist/chunk-LHR6OHI7.js +0 -189
  81. package/dist/chunk-N7PLD7MB.js +0 -729
  82. package/dist/chunk-O5XIXGYM.js +0 -274
  83. package/dist/chunk-Q2P6YLRR.js +0 -24
  84. package/dist/chunk-QQKTH5KX.js +0 -114
  85. package/dist/chunk-SFQP6O52.js +0 -126
  86. package/dist/chunk-SQR7277M.js +0 -911
  87. package/dist/chunk-T2FFUU6J.js +0 -484
  88. package/dist/chunk-TVV5YNEC.js +0 -1842
  89. package/dist/chunk-UY3AZSYL.js +0 -14
  90. package/dist/chunk-V4DNC2ER.js +0 -114
  91. package/dist/chunk-YSOJKAAU.js +0 -427
  92. package/dist/errors-PUNHAFL2.js +0 -34
@@ -1,271 +0,0 @@
1
- import {
2
- MessageSigner,
3
- generateAppKey,
4
- normalizeAppKey
5
- } from "./chunk-SFQP6O52.js";
6
-
7
- // src/encryption/Encrypter.ts
8
- import { createCipheriv, createDecipheriv, randomBytes, createHmac } from "crypto";
9
- var GCM_TAG_BYTES = 16;
10
- var Encrypter = class {
11
- /**
12
- * Encryption key.
13
- */
14
- key;
15
- previousKeys;
16
- /**
17
- * Cipher algorithm.
18
- */
19
- cipher;
20
- constructor(config) {
21
- this.key = Buffer.from(normalizeAppKey(config.key).slice("base64:".length), "base64");
22
- this.previousKeys = (config.previousKeys ?? []).map(
23
- (key) => Buffer.from(normalizeAppKey(key).slice("base64:".length), "base64")
24
- );
25
- this.cipher = config.cipher ?? "aes-256-gcm";
26
- }
27
- /**
28
- * Encrypt a value.
29
- */
30
- encrypt(value, options = {}) {
31
- const serialize = options.serialize !== false;
32
- const data = serialize ? JSON.stringify(value) : String(value);
33
- if (this.cipher === "aes-256-gcm") {
34
- return this.encryptGcm(data);
35
- }
36
- return this.encryptCbc(data);
37
- }
38
- /**
39
- * Decrypt a value.
40
- */
41
- decrypt(payload, options = {}) {
42
- const deserialize = options.deserialize !== false;
43
- let parsed;
44
- try {
45
- parsed = JSON.parse(Buffer.from(payload, "base64").toString("utf8"));
46
- } catch {
47
- throw new Error("Invalid encrypted payload.");
48
- }
49
- let decrypted;
50
- if (parsed.tag) {
51
- decrypted = this.decryptGcm(parsed);
52
- } else if (parsed.mac) {
53
- decrypted = this.decryptCbc(parsed);
54
- } else {
55
- throw new Error("Invalid encrypted payload format.");
56
- }
57
- if (deserialize) {
58
- try {
59
- return JSON.parse(decrypted);
60
- } catch {
61
- return decrypted;
62
- }
63
- }
64
- return decrypted;
65
- }
66
- /**
67
- * Encrypt a string (no serialization).
68
- */
69
- encryptString(value) {
70
- return this.encrypt(value, { serialize: false });
71
- }
72
- /**
73
- * Decrypt a string (no deserialization).
74
- */
75
- decryptString(payload) {
76
- return this.decrypt(payload, { deserialize: false });
77
- }
78
- /**
79
- * Encrypt using AES-256-GCM.
80
- */
81
- encryptGcm(data) {
82
- const iv = randomBytes(12);
83
- const cipher = createCipheriv("aes-256-gcm", this.key, iv, { authTagLength: GCM_TAG_BYTES });
84
- const encrypted = Buffer.concat([
85
- cipher.update(data, "utf8"),
86
- cipher.final()
87
- ]);
88
- const tag = cipher.getAuthTag();
89
- const payload = {
90
- iv: iv.toString("base64"),
91
- value: encrypted.toString("base64"),
92
- tag: tag.toString("base64")
93
- };
94
- return Buffer.from(JSON.stringify(payload)).toString("base64");
95
- }
96
- /**
97
- * Decrypt using AES-256-GCM.
98
- */
99
- decryptGcm(payload) {
100
- const iv = Buffer.from(payload.iv, "base64");
101
- const encrypted = Buffer.from(payload.value, "base64");
102
- const tag = Buffer.from(payload.tag, "base64");
103
- if (tag.length !== GCM_TAG_BYTES) {
104
- throw new Error("Invalid authentication tag length.");
105
- }
106
- return this.tryDecryptWithKeys((key) => {
107
- const decipher = createDecipheriv("aes-256-gcm", key, iv, { authTagLength: GCM_TAG_BYTES });
108
- decipher.setAuthTag(tag);
109
- const decrypted = Buffer.concat([
110
- decipher.update(encrypted),
111
- decipher.final()
112
- ]);
113
- return decrypted.toString("utf8");
114
- });
115
- }
116
- /**
117
- * Encrypt using AES-256-CBC with HMAC.
118
- */
119
- encryptCbc(data) {
120
- const iv = randomBytes(16);
121
- const cipher = createCipheriv("aes-256-cbc", this.key, iv);
122
- const encrypted = Buffer.concat([
123
- cipher.update(data, "utf8"),
124
- cipher.final()
125
- ]);
126
- const mac = this.createMac(iv, encrypted);
127
- const payload = {
128
- iv: iv.toString("base64"),
129
- value: encrypted.toString("base64"),
130
- mac
131
- };
132
- return Buffer.from(JSON.stringify(payload)).toString("base64");
133
- }
134
- /**
135
- * Decrypt using AES-256-CBC with HMAC verification.
136
- */
137
- decryptCbc(payload) {
138
- return this.tryDecryptWithKeys((key) => {
139
- const iv = Buffer.from(payload.iv, "base64");
140
- const encrypted = Buffer.from(payload.value, "base64");
141
- const expectedMac = this.createMac(iv, encrypted, key);
142
- if (!this.secureCompare(payload.mac, expectedMac)) {
143
- throw new Error("MAC verification failed.");
144
- }
145
- const decipher = createDecipheriv("aes-256-cbc", key, iv);
146
- const decrypted = Buffer.concat([
147
- decipher.update(encrypted),
148
- decipher.final()
149
- ]);
150
- return decrypted.toString("utf8");
151
- });
152
- }
153
- /**
154
- * Create HMAC for CBC mode.
155
- */
156
- createMac(iv, encrypted, key = this.key) {
157
- const hmac2 = createHmac("sha256", key);
158
- hmac2.update(iv);
159
- hmac2.update(encrypted);
160
- return hmac2.digest("hex");
161
- }
162
- /**
163
- * Constant-time string comparison.
164
- */
165
- secureCompare(a, b) {
166
- if (a.length !== b.length) {
167
- return false;
168
- }
169
- let result = 0;
170
- for (let i = 0; i < a.length; i++) {
171
- result |= a.charCodeAt(i) ^ b.charCodeAt(i);
172
- }
173
- return result === 0;
174
- }
175
- /**
176
- * Get the encryption key (base64).
177
- */
178
- getKey() {
179
- return this.key.toString("base64");
180
- }
181
- tryDecryptWithKeys(run) {
182
- const keys = [this.key, ...this.previousKeys];
183
- let lastError;
184
- for (const key of keys) {
185
- try {
186
- return run(key);
187
- } catch (error) {
188
- lastError = error;
189
- }
190
- }
191
- throw lastError ?? new Error("Failed to decrypt payload.");
192
- }
193
- };
194
- function generateKey() {
195
- return generateAppKey();
196
- }
197
- var globalEncrypter = null;
198
- function createEncrypter(config) {
199
- return new Encrypter(config);
200
- }
201
- function setEncrypter(encrypter) {
202
- globalEncrypter = encrypter;
203
- }
204
- function getEncrypter() {
205
- if (!globalEncrypter) {
206
- throw new Error("Encrypter not initialized. Call setEncrypter() first.");
207
- }
208
- return globalEncrypter;
209
- }
210
- function encrypt(value, options) {
211
- return getEncrypter().encrypt(value, options);
212
- }
213
- function decrypt(payload, options) {
214
- return getEncrypter().decrypt(payload, options);
215
- }
216
-
217
- // src/encryption/signed-url.ts
218
- var PURPOSE = "signed-url";
219
- var SIGNATURE_PARAM = "signature";
220
- var EXPIRES_PARAM = "expires";
221
- function canonicalizeUrl(value) {
222
- const url = new URL(value);
223
- url.searchParams.delete(SIGNATURE_PARAM);
224
- const params = Array.from(url.searchParams.entries()).sort(([left], [right]) => left.localeCompare(right));
225
- url.search = "";
226
- for (const [key, paramValue] of params) {
227
- url.searchParams.append(key, paramValue);
228
- }
229
- return { canonical: `${url.pathname}${url.search}`, url };
230
- }
231
- function signUrl(value, keyring, options = {}) {
232
- const url = new URL(value);
233
- if (typeof options.expiresIn === "number") {
234
- url.searchParams.set(EXPIRES_PARAM, String(Math.floor((Date.now() + options.expiresIn) / 1e3)));
235
- }
236
- const { canonical } = canonicalizeUrl(url.toString());
237
- const signer = new MessageSigner(keyring);
238
- const signature = signer.sign({ url: canonical }, { purpose: PURPOSE });
239
- url.searchParams.set(SIGNATURE_PARAM, signature);
240
- return url.toString();
241
- }
242
- function verifySignedUrl(value, keyring, options = {}) {
243
- const url = new URL(value);
244
- const signature = url.searchParams.get(SIGNATURE_PARAM);
245
- if (!signature) {
246
- return false;
247
- }
248
- const expires = url.searchParams.get(EXPIRES_PARAM);
249
- if (options.requireExpiration && !expires) {
250
- return false;
251
- }
252
- if (expires && Number(expires) < Math.floor(Date.now() / 1e3)) {
253
- return false;
254
- }
255
- const { canonical } = canonicalizeUrl(value);
256
- const signer = new MessageSigner(keyring);
257
- const payload = signer.verify(signature, { purpose: PURPOSE });
258
- return payload?.url === canonical;
259
- }
260
-
261
- export {
262
- Encrypter,
263
- generateKey,
264
- createEncrypter,
265
- setEncrypter,
266
- getEncrypter,
267
- encrypt,
268
- decrypt,
269
- signUrl,
270
- verifySignedUrl
271
- };