alepha 0.7.7 → 0.8.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 (55) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +7 -34
  3. package/batch.cjs +8 -0
  4. package/batch.d.ts +147 -0
  5. package/batch.js +1 -0
  6. package/cache/redis.d.ts +13 -18
  7. package/cache.d.ts +183 -119
  8. package/command.cjs +8 -0
  9. package/command.d.ts +152 -0
  10. package/command.js +1 -0
  11. package/core.d.ts +846 -838
  12. package/datetime.d.ts +78 -78
  13. package/file.cjs +8 -0
  14. package/file.d.ts +46 -0
  15. package/file.js +1 -0
  16. package/lock/redis.d.ts +10 -12
  17. package/lock.d.ts +73 -80
  18. package/package.json +86 -34
  19. package/postgres.d.ts +348 -170
  20. package/queue/redis.d.ts +13 -13
  21. package/queue.d.ts +107 -18
  22. package/react/auth.d.ts +22 -16
  23. package/react/head.d.ts +10 -4
  24. package/react.d.ts +206 -49
  25. package/redis.d.ts +23 -27
  26. package/retry.d.ts +75 -54
  27. package/router.cjs +8 -0
  28. package/router.d.ts +45 -0
  29. package/router.js +1 -0
  30. package/scheduler.d.ts +15 -16
  31. package/security.d.ts +229 -40
  32. package/server/cache.d.ts +7 -8
  33. package/server/compress.cjs +8 -0
  34. package/server/compress.d.ts +26 -0
  35. package/server/compress.js +1 -0
  36. package/server/cookies.d.ts +249 -18
  37. package/server/cors.d.ts +7 -3
  38. package/server/health.d.ts +21 -24
  39. package/server/helmet.cjs +8 -0
  40. package/server/helmet.d.ts +70 -0
  41. package/server/helmet.js +1 -0
  42. package/server/links.d.ts +87 -93
  43. package/server/metrics.cjs +8 -0
  44. package/server/metrics.d.ts +35 -0
  45. package/server/metrics.js +1 -0
  46. package/server/multipart.cjs +8 -0
  47. package/server/multipart.d.ts +46 -0
  48. package/server/multipart.js +1 -0
  49. package/server/proxy.d.ts +11 -11
  50. package/server/static.d.ts +70 -55
  51. package/server/swagger.d.ts +55 -54
  52. package/server.d.ts +273 -123
  53. package/topic/redis.d.ts +22 -23
  54. package/topic.d.ts +26 -19
  55. package/vite.d.ts +59 -36
package/server/cache.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { Cache, CacheDescriptorOptions, CacheDescriptorProvider } from "@alepha/cache";
2
- import { ServerHandler, ServerRequestConfig } from "@alepha/server";
3
- import * as _alepha_core1 from "@alepha/core";
4
- import { Alepha, Module, OPTIONS } from "@alepha/core";
5
- import { DateTimeProvider, DurationLike } from "@alepha/datetime";
1
+ import { Cache, CacheDescriptorOptions, CacheDescriptorProvider } from "alepha/cache";
2
+ import { ServerHandler, ServerRequestConfig } from "alepha/server";
3
+ import * as _alepha_core1 from "alepha";
4
+ import { Alepha, Module, OPTIONS } from "alepha";
5
+ import { DateTimeProvider, DurationLike } from "alepha/datetime";
6
6
 
7
7
  //#region src/providers/ServerCacheProvider.d.ts
8
8
  declare module "alepha/server" {
@@ -46,9 +46,6 @@ type RouteLike = {
46
46
  //#endregion
47
47
  //#region src/index.d.ts
48
48
  /**
49
- * # Alepha Server Cache Module
50
- *
51
- * @description
52
49
  * Plugin for Alepha Server that provides server-side caching capabilities.
53
50
  * It uses the Alepha Cache module to cache responses from server actions ($action).
54
51
  * It also provides a ETag-based cache invalidation mechanism.
@@ -80,6 +77,8 @@ declare class AlephaServerCache implements Module {
80
77
  readonly name = "alepha.server.cache";
81
78
  readonly $services: (alepha: Alepha) => Alepha;
82
79
  }
80
+ //# sourceMappingURL=index.d.ts.map
81
+
83
82
  //#endregion
84
83
  export { AlephaServerCache, ServerCacheProvider, ServerRouteCache };
85
84
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+ var m = require('@alepha/server-compress');
3
+ Object.keys(m).forEach(function (k) {
4
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
5
+ enumerable: true,
6
+ get: function () { return m[k]; }
7
+ });
8
+ });
@@ -0,0 +1,26 @@
1
+ import { ServerResponse } from "alepha/server";
2
+ import { Transform } from "node:stream";
3
+ import { Alepha, HookDescriptor, Module } from "alepha";
4
+
5
+ //#region src/providers/ServerCompressProvider.d.ts
6
+ declare class ServerCompressProvider {
7
+ compressors: Record<string, {
8
+ compress: (...args: any[]) => Promise<Buffer>;
9
+ stream: (options?: any) => Transform;
10
+ } | undefined>;
11
+ readonly onResponse: HookDescriptor<"server:onResponse">;
12
+ protected isAllowedContentType(contentType: string | undefined): boolean;
13
+ protected compress(encoding: keyof typeof (void 0).compressors, response: ServerResponse): Promise<void>;
14
+ protected getParams(encoding: keyof typeof (void 0).compressors): Record<number, any>;
15
+ protected setHeaders(response: ServerResponse, encoding: keyof typeof (void 0).compressors): void;
16
+ }
17
+ //#endregion
18
+ //#region src/index.d.ts
19
+ // ---------------------------------------------------------------------------------------------------------------------
20
+ declare class AlephaServerCompress implements Module {
21
+ readonly name = "alepha.server.compress";
22
+ readonly $services: (alepha: Alepha) => void;
23
+ }
24
+ //#endregion
25
+ export { AlephaServerCompress, ServerCompressProvider };
26
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ export * from '@alepha/server-compress'
@@ -1,32 +1,59 @@
1
- import * as _alepha_core1 from "@alepha/core";
2
- import { KIND, OPTIONS, Static, TSchema } from "@alepha/core";
3
- import { DurationLike } from "@alepha/datetime";
1
+ import { Alepha, HookDescriptor, KIND, Logger, Module, OPTIONS, Static, TObject, TOptional, TSchema, TString } from "alepha";
2
+ import { DateTimeProvider, DurationLike } from "alepha/datetime";
4
3
 
5
4
  //#region src/descriptors/$cookie.d.ts
5
+ declare const KEY = "COOKIE";
6
+ /**
7
+ * Declares a type-safe, configurable HTTP cookie.
8
+ * This descriptor provides methods to get, set, and delete the cookie
9
+ * within the server request/response cycle.
10
+ */
11
+ declare const $cookie: {
12
+ <T extends TSchema>(options: CookieDescriptorOptions<T>): CookieDescriptor<T>;
13
+ [KIND]: string;
14
+ };
15
+ // ---------------------------------------------------------------------------------------------------------------------
6
16
  interface CookieDescriptorOptions<T extends TSchema> {
17
+ /** The schema for the cookie's value, used for validation and type safety. */
7
18
  schema: T;
8
- name: string;
19
+ /** The name of the cookie. */
20
+ name?: string;
21
+ /** The cookie's path. Defaults to "/". */
9
22
  path?: string;
23
+ /** Time-to-live for the cookie. Maps to `Max-Age`. */
10
24
  ttl?: DurationLike;
25
+ /** If true, the cookie is only sent over HTTPS. Defaults to true in production. */
11
26
  secure?: boolean;
27
+ /** If true, the cookie cannot be accessed by client-side scripts. */
12
28
  httpOnly?: boolean;
29
+ /** SameSite policy for the cookie. Defaults to "lax". */
13
30
  sameSite?: "strict" | "lax" | "none";
31
+ /** The domain for the cookie. */
14
32
  domain?: string;
33
+ /** If true, the cookie value will be compressed using zlib. */
15
34
  compress?: boolean;
35
+ /** If true, the cookie value will be encrypted. Requires `COOKIE_SECRET` env var. */
16
36
  encrypt?: boolean;
37
+ /** If true, the cookie will be signed to prevent tampering. Requires `COOKIE_SECRET` env var. */
17
38
  sign?: boolean;
18
39
  }
19
40
  interface CookieDescriptor<T extends TSchema> {
20
- [KIND]: "COOKIE";
41
+ [KIND]: typeof KEY;
21
42
  [OPTIONS]: CookieDescriptorOptions<T>;
22
- set: (cookies: Cookies, value: Static<T>) => void;
23
- get: (cookies: Cookies) => Static<T> | undefined;
24
- del: (cookies: Cookies) => void;
43
+ schema: T;
44
+ /** Sets the cookie with the given value in the current request's response. */
45
+ set: (value: Static<T>, options?: {
46
+ cookies?: Cookies;
47
+ }) => void;
48
+ /** Gets the cookie value from the current request. Returns undefined if not found or invalid. */
49
+ get: (options?: {
50
+ cookies?: Cookies;
51
+ }) => Static<T> | undefined;
52
+ /** Deletes the cookie in the current request's response. */
53
+ del: (options?: {
54
+ cookies?: Cookies;
55
+ }) => void;
25
56
  }
26
- declare const $cookie: {
27
- <T extends TSchema>(options: CookieDescriptorOptions<T>): CookieDescriptor<T>;
28
- [KIND]: string;
29
- };
30
57
  interface Cookies {
31
58
  req: Record<string, string>;
32
59
  res: Record<string, Cookie | null>;
@@ -42,22 +69,226 @@ interface Cookie {
42
69
  }
43
70
  //#endregion
44
71
  //#region src/providers/ServerCookiesProvider.d.ts
72
+ declare const envSchema: TObject<{
73
+ COOKIE_SECRET: TOptional<TString>;
74
+ }>;
75
+ declare module "alepha" {
76
+ interface Env extends Partial<Static<typeof envSchema>> {}
77
+ }
45
78
  declare class ServerCookiesProvider {
46
- readonly onRequest: _alepha_core1.HookDescriptor<"server:onRequest">;
47
- readonly onSend: _alepha_core1.HookDescriptor<"server:onSend">;
48
- fromHeader(header: string): Record<string, string>;
49
- toHeader(cookies: Record<string, Cookie | null>, isHttps?: boolean): string[];
79
+ protected readonly alepha: Alepha;
80
+ protected readonly log: Logger;
81
+ protected readonly env: Static<typeof envSchema>;
82
+ protected readonly dateTimeProvider: DateTimeProvider;
83
+ // Crypto constants
84
+ protected readonly ALGORITHM = "aes-256-gcm";
85
+ protected readonly IV_LENGTH = 16;
86
+ protected readonly AUTH_TAG_LENGTH = 16;
87
+ protected readonly SIGNATURE_LENGTH = 32;
88
+ protected readonly configure: HookDescriptor<"configure">;
89
+ protected createApi<T extends TSchema>(name: string, options: CookieDescriptorOptions<T>): CookieDescriptor<T>;
90
+ readonly onRequest: HookDescriptor<"server:onRequest">;
91
+ readonly onSend: HookDescriptor<"server:onSend">;
92
+ protected getCookiesFromContext(cookies?: Cookies): Cookies;
93
+ protected getCookie<T extends TSchema>(name: string, options: CookieDescriptorOptions<T>, contextCookies?: Cookies): Static<T> | undefined;
94
+ protected setCookie<T extends TSchema>(name: string, options: CookieDescriptorOptions<T>, data: Static<T>, contextCookies?: Cookies): void;
95
+ protected deleteCookie<T extends TSchema>(name: string, contextCookies?: Cookies): void;
96
+ // --- Crypto & Parsing ---
97
+ protected encrypt(text: string): string;
98
+ protected decrypt(encryptedText: string): string;
99
+ secretKey(): string;
100
+ protected sign(data: string): string;
101
+ protected parseRequestCookies(header: string): Record<string, string>;
102
+ protected serializeResponseCookies(cookies: Record<string, Cookie | null>, isHttps: boolean): string[];
50
103
  }
51
104
  //#endregion
52
105
  //#region src/index.d.ts
106
+ // ---------------------------------------------------------------------------------------------------------------------
53
107
  declare module "alepha/server" {
54
108
  interface ServerRequest {
55
109
  cookies: Cookies;
56
110
  }
57
111
  }
58
- declare class AlephaServerCookies {
112
+ /**
113
+ * Provides HTTP cookie management capabilities for server requests and responses with type-safe cookie descriptors.
114
+ *
115
+ * The server-cookies module enables declarative cookie handling using the `$cookie` descriptor on class properties.
116
+ * It offers automatic cookie parsing, secure cookie configuration, and seamless integration with server routes
117
+ * for managing user sessions, preferences, and authentication tokens.
118
+ *
119
+ * **Key Features:**
120
+ * - Declarative cookie definition with `$cookie` descriptor
121
+ * - Automatic cookie parsing from requests
122
+ * - Secure cookie configuration (httpOnly, secure, sameSite)
123
+ * - Type-safe cookie values with schema validation
124
+ * - Automatic cookie serialization and deserialization
125
+ * - Integration with server request/response lifecycle
126
+ *
127
+ * **Basic Usage:**
128
+ * ```ts
129
+ * import { Alepha, run, t } from "alepha";
130
+ * import { AlephaServer, $route } from "alepha/server";
131
+ * import { AlephaServerCookies, $cookie } from "alepha/server/cookies";
132
+ *
133
+ * class AuthRoutes {
134
+ * // Define authentication cookie
135
+ * authToken = $cookie({
136
+ * name: "auth_token",
137
+ * httpOnly: true,
138
+ * secure: true,
139
+ * sameSite: "strict",
140
+ * maxAge: "7d",
141
+ * });
142
+ *
143
+ * // Define user preferences cookie
144
+ * userPrefs = $cookie({
145
+ * name: "user_prefs",
146
+ * schema: t.object({
147
+ * theme: t.union([t.literal("light"), t.literal("dark")]),
148
+ * language: t.string(),
149
+ * }),
150
+ * maxAge: "30d",
151
+ * });
152
+ *
153
+ * login = $route({
154
+ * path: "/login",
155
+ * method: "POST",
156
+ * schema: {
157
+ * body: t.object({
158
+ * email: t.string(),
159
+ * password: t.string(),
160
+ * }),
161
+ * },
162
+ * handler: async ({ body, reply }) => {
163
+ * const user = await authenticateUser(body.email, body.password);
164
+ * if (!user) {
165
+ * return new Response("Invalid credentials", { status: 401 });
166
+ * }
167
+ *
168
+ * const token = await generateJWT(user.id);
169
+ *
170
+ * // Set authentication cookie
171
+ * this.authToken.set(reply, token);
172
+ *
173
+ * return Response.json({ success: true, user });
174
+ * },
175
+ * });
176
+ *
177
+ * profile = $route({
178
+ * path: "/profile",
179
+ * method: "GET",
180
+ * handler: async ({ cookies }) => {
181
+ * // Get authentication token from cookie
182
+ * const token = this.authToken.get(cookies);
183
+ * if (!token) {
184
+ * return new Response("Unauthorized", { status: 401 });
185
+ * }
186
+ *
187
+ * const user = await validateJWT(token);
188
+ * const preferences = this.userPrefs.get(cookies) || {
189
+ * theme: "light",
190
+ * language: "en",
191
+ * };
192
+ *
193
+ * return Response.json({ user, preferences });
194
+ * },
195
+ * });
196
+ *
197
+ * logout = $route({
198
+ * path: "/logout",
199
+ * method: "POST",
200
+ * handler: async ({ reply }) => {
201
+ * // Clear authentication cookie
202
+ * this.authToken.clear(reply);
203
+ * return Response.json({ success: true });
204
+ * },
205
+ * });
206
+ * }
207
+ *
208
+ * const alepha = Alepha.create()
209
+ * .with(AlephaServer)
210
+ * .with(AlephaServerCookies)
211
+ * .with(AuthRoutes);
212
+ *
213
+ * run(alepha);
214
+ * ```
215
+ *
216
+ * **Advanced Cookie Management:**
217
+ * ```ts
218
+ * class SessionRoutes {
219
+ * // Session cookie with custom configuration
220
+ * sessionId = $cookie({
221
+ * name: "session_id",
222
+ * httpOnly: true,
223
+ * secure: process.env.NODE_ENV === "production",
224
+ * sameSite: "lax",
225
+ * path: "/",
226
+ * maxAge: "2h",
227
+ * encrypt: true, // Optional encryption
228
+ * });
229
+ *
230
+ * // Shopping cart cookie
231
+ * cart = $cookie({
232
+ * name: "shopping_cart",
233
+ * schema: t.object({
234
+ * items: t.array(t.object({
235
+ * id: t.string(),
236
+ * quantity: t.number(),
237
+ * })),
238
+ * total: t.number(),
239
+ * }),
240
+ * maxAge: "30d",
241
+ * });
242
+ *
243
+ * // Tracking consent cookie
244
+ * consent = $cookie({
245
+ * name: "tracking_consent",
246
+ * schema: t.object({
247
+ * analytics: t.boolean(),
248
+ * marketing: t.boolean(),
249
+ * functional: t.boolean(),
250
+ * }),
251
+ * maxAge: "1y",
252
+ * });
253
+ *
254
+ * updateCart = $route({
255
+ * path: "/cart",
256
+ * method: "POST",
257
+ * schema: {
258
+ * body: t.object({
259
+ * productId: t.string(),
260
+ * quantity: t.number(),
261
+ * }),
262
+ * },
263
+ * handler: async ({ body, cookies, reply }) => {
264
+ * const currentCart = this.cart.get(cookies) || { items: [], total: 0 };
265
+ *
266
+ * // Update cart logic
267
+ * const existingItem = currentCart.items.find(item => item.id === body.productId);
268
+ * if (existingItem) {
269
+ * existingItem.quantity = body.quantity;
270
+ * } else {
271
+ * currentCart.items.push({ id: body.productId, quantity: body.quantity });
272
+ * }
273
+ *
274
+ * // Recalculate total
275
+ * currentCart.total = await calculateCartTotal(currentCart.items);
276
+ *
277
+ * // Update cookie
278
+ * this.cart.set(reply, currentCart);
279
+ *
280
+ * return Response.json(currentCart);
281
+ * },
282
+ * });
283
+ * }
284
+ * ```
285
+ *
286
+ * @see {@link $cookie}
287
+ * @module alepha.server.cookies
288
+ */
289
+ declare class AlephaServerCookies implements Module {
59
290
  readonly name = "alepha.server.cookies";
60
- readonly $services: (alepha: any) => void;
291
+ readonly $services: (alepha: Alepha) => void;
61
292
  }
62
293
  //#endregion
63
294
  export { $cookie, AlephaServerCookies, Cookie, CookieDescriptor, CookieDescriptorOptions, Cookies, ServerCookiesProvider };
package/server/cors.d.ts CHANGED
@@ -1,12 +1,15 @@
1
- import * as _alepha_core0 from "@alepha/core";
2
- import { Alepha, Module } from "@alepha/core";
1
+ import { ServerRouterProvider } from "alepha/server";
2
+ import { Alepha, HookDescriptor, Module } from "alepha";
3
3
 
4
4
  //#region src/providers/ServerCorsProvider.d.ts
5
5
  declare class ServerCorsProvider {
6
+ protected readonly serverRouterProvider: ServerRouterProvider;
6
7
  options: CorsOptions;
7
- protected readonly onRequest: _alepha_core0.HookDescriptor<"server:onRequest">;
8
+ protected readonly onRoute: HookDescriptor<"server:onRoute">;
9
+ protected readonly onRequest: HookDescriptor<"server:onRequest">;
8
10
  isOriginAllowed(origin: string | undefined, allowed: CorsOptions["origin"]): boolean;
9
11
  }
12
+ // ---------------------------------------------------------------------------------------------------------------------
10
13
  interface CorsOptions {
11
14
  origin?: string | string[] | ((origin: string | undefined) => boolean);
12
15
  methods: string[];
@@ -16,6 +19,7 @@ interface CorsOptions {
16
19
  }
17
20
  //#endregion
18
21
  //#region src/index.d.ts
22
+ // ---------------------------------------------------------------------------------------------------------------------
19
23
  declare class AlephaServerCors implements Module {
20
24
  readonly name = "alepha.server.cors";
21
25
  readonly $services: (alepha: Alepha) => void;
@@ -1,41 +1,38 @@
1
- import * as _alepha_server5 from "@alepha/server";
2
- import { Alepha } from "@alepha/core";
3
- import { DateTimeProvider } from "@alepha/datetime";
4
- import * as _sinclair_typebox0 from "@sinclair/typebox";
1
+ import { RouteDescriptor } from "alepha/server";
2
+ import { Alepha, TBoolean, TNumber, TObject, TString } from "alepha";
3
+ import { DateTimeProvider } from "alepha/datetime";
5
4
 
6
5
  //#region src/providers/ServerHealthProvider.d.ts
7
6
 
8
7
  /**
9
- * Register `/health` endpoint.
10
- *
11
- * - Provides basic health information about the server.
12
- */
8
+ * Register `/health` endpoint.
9
+ *
10
+ * - Provides basic health information about the server.
11
+ */
13
12
  declare class ServerHealthProvider {
14
- protected readonly dateTimeProvider: DateTimeProvider;
13
+ protected readonly time: DateTimeProvider;
15
14
  protected readonly alepha: Alepha;
16
- readonly health: _alepha_server5.RouteDescriptor<{
17
- response: _sinclair_typebox0.TObject<{
18
- message: _sinclair_typebox0.TString;
19
- uptime: _sinclair_typebox0.TNumber;
20
- date: _sinclair_typebox0.TString;
21
- ready: _sinclair_typebox0.TBoolean;
15
+ readonly health: RouteDescriptor<{
16
+ response: TObject<{
17
+ message: TString;
18
+ uptime: TNumber;
19
+ date: TString;
20
+ ready: TBoolean;
22
21
  }>;
23
22
  }>;
24
23
  }
25
24
  //#endregion
26
25
  //#region src/index.d.ts
26
+ // ---------------------------------------------------------------------------------------------------------------------
27
27
  /**
28
- * Alepha Server Health Module
29
- *
30
- * @description
31
- * Plugin for Alepha Server that provides health-check endpoints.
32
- *
33
- * @see {@link ServerHealthProvider}
34
- * @module alepha.server.health
35
- */
28
+ * Plugin for Alepha Server that provides health-check endpoints.
29
+ *
30
+ * @see {@link ServerHealthProvider}
31
+ * @module alepha.server.health
32
+ */
36
33
  declare class AlephaServerHealth {
37
34
  readonly name = "alepha.server.health";
38
- readonly $services: (alepha: any) => void;
35
+ readonly $services: (alepha: Alepha) => void;
39
36
  }
40
37
  //#endregion
41
38
  export { AlephaServerHealth, ServerHealthProvider };
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+ var m = require('@alepha/server-helmet');
3
+ Object.keys(m).forEach(function (k) {
4
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
5
+ enumerable: true,
6
+ get: function () { return m[k]; }
7
+ });
8
+ });
@@ -0,0 +1,70 @@
1
+ import { Alepha, HookDescriptor, Module } from "alepha";
2
+
3
+ //#region src/providers/ServerHelmetProvider.d.ts
4
+ type CspDirective = string | string[];
5
+ interface CspOptions {
6
+ directives: {
7
+ "default-src"?: CspDirective;
8
+ "script-src"?: CspDirective;
9
+ "style-src"?: CspDirective;
10
+ "img-src"?: CspDirective;
11
+ "connect-src"?: CspDirective;
12
+ "font-src"?: CspDirective;
13
+ "object-src"?: CspDirective;
14
+ "media-src"?: CspDirective;
15
+ "frame-src"?: CspDirective;
16
+ sandbox?: CspDirective | boolean;
17
+ "report-uri"?: string;
18
+ "child-src"?: CspDirective;
19
+ "form-action"?: CspDirective;
20
+ "frame-ancestors"?: CspDirective;
21
+ "plugin-types"?: CspDirective;
22
+ "base-uri"?: CspDirective;
23
+ [key: string]: CspDirective | undefined | boolean;
24
+ };
25
+ }
26
+ interface HstsOptions {
27
+ maxAge?: number;
28
+ includeSubDomains?: boolean;
29
+ preload?: boolean;
30
+ }
31
+ interface HelmetOptions {
32
+ isSecure?: boolean;
33
+ strictTransportSecurity?: HstsOptions | false;
34
+ xContentTypeOptions?: false;
35
+ xFrameOptions?: "DENY" | "SAMEORIGIN" | false;
36
+ xXssProtection?: false;
37
+ contentSecurityPolicy?: CspOptions | false;
38
+ referrerPolicy?: "no-referrer" | "no-referrer-when-downgrade" | "origin" | "origin-when-cross-origin" | "same-origin" | "strict-origin" | "strict-origin-when-cross-origin" | "unsafe-url" | false;
39
+ }
40
+ /**
41
+ * Provides a configurable way to apply essential HTTP security headers
42
+ * to every server response, without external dependencies.
43
+ */
44
+ declare class ServerHelmetProvider {
45
+ protected readonly alepha: Alepha;
46
+ /**
47
+ * The configuration options. These can be overridden during
48
+ * the application's configuration phase using `alepha.configure()`.
49
+ */
50
+ options: HelmetOptions;
51
+ private buildHeaders;
52
+ protected readonly onResponse: HookDescriptor<"server:onResponse">;
53
+ }
54
+ //#endregion
55
+ //#region src/index.d.ts
56
+ // ---------------------------------------------------------------------------------------------------------------------
57
+ /**
58
+ * Automatically adds important HTTP security headers to every response
59
+ * to help protect your application from common web vulnerabilities.
60
+ *
61
+ * @see {@link ServerHelmetProvider}
62
+ * @module alepha.server.helmet
63
+ */
64
+ declare class AlephaServerHelmet implements Module {
65
+ readonly name = "alepha.server.helmet";
66
+ readonly $services: (alepha: Alepha) => void;
67
+ }
68
+ //#endregion
69
+ export { AlephaServerHelmet, CspOptions, HelmetOptions, HstsOptions, ServerHelmetProvider };
70
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ export * from '@alepha/server-helmet'