@adonisjs/http-server 8.0.0-next.0 → 8.0.0-next.10

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 (74) hide show
  1. package/build/chunk-2QM3D5BN.js +87 -0
  2. package/build/chunk-5PWHBE2E.js +128 -0
  3. package/build/chunk-QDK57QGB.js +1176 -0
  4. package/build/{chunk-VYBTM3NC.js → chunk-YBLFT4O6.js} +1161 -1719
  5. package/build/factories/http_context.d.ts +5 -4
  6. package/build/factories/http_server.d.ts +7 -0
  7. package/build/factories/main.d.ts +6 -6
  8. package/build/factories/main.js +33 -5
  9. package/build/factories/qs_parser_factory.d.ts +5 -4
  10. package/build/factories/request.d.ts +3 -2
  11. package/build/factories/response.d.ts +4 -3
  12. package/build/factories/router.d.ts +2 -1
  13. package/build/factories/server_factory.d.ts +3 -2
  14. package/build/factories/url_builder_factory.d.ts +3 -2
  15. package/build/index.d.ts +19 -16
  16. package/build/index.js +97 -42
  17. package/build/src/client/helpers.d.ts +37 -0
  18. package/build/src/client/types.d.ts +88 -66
  19. package/build/src/client/url_builder.d.ts +12 -10
  20. package/build/src/client/url_builder.js +12 -0
  21. package/build/src/cookies/client.d.ts +61 -3
  22. package/build/src/cookies/drivers/encrypted.d.ts +13 -0
  23. package/build/src/cookies/drivers/plain.d.ts +9 -0
  24. package/build/src/cookies/drivers/signed.d.ts +13 -0
  25. package/build/src/cookies/parser.d.ts +18 -0
  26. package/build/src/cookies/serializer.d.ts +22 -3
  27. package/build/src/debug.d.ts +13 -0
  28. package/build/src/define_config.d.ts +21 -5
  29. package/build/src/define_middleware.d.ts +20 -4
  30. package/build/src/errors.d.ts +67 -10
  31. package/build/src/exception_handler.d.ts +95 -41
  32. package/build/src/helpers.d.ts +60 -4
  33. package/build/src/helpers.js +9 -1
  34. package/build/src/http_context/local_storage.d.ts +18 -1
  35. package/build/src/http_context/main.d.ts +71 -13
  36. package/build/src/qs.d.ts +31 -3
  37. package/build/src/redirect.d.ts +87 -16
  38. package/build/src/request.d.ts +121 -15
  39. package/build/src/response.d.ts +421 -208
  40. package/build/src/response_status.d.ts +14 -0
  41. package/build/src/router/brisk.d.ts +18 -7
  42. package/build/src/router/executor.d.ts +7 -3
  43. package/build/src/router/factories/use_return_value.d.ts +6 -1
  44. package/build/src/router/group.d.ts +23 -6
  45. package/build/src/router/legacy/url_builder.d.ts +15 -15
  46. package/build/src/router/main.d.ts +133 -20
  47. package/build/src/router/matchers.d.ts +3 -0
  48. package/build/src/router/resource.d.ts +37 -5
  49. package/build/src/router/route.d.ts +30 -6
  50. package/build/src/router/signed_url_builder.d.ts +7 -10
  51. package/build/src/router/store.d.ts +10 -2
  52. package/build/src/server/factories/middleware_handler.d.ts +12 -3
  53. package/build/src/server/factories/route_finder.d.ts +16 -6
  54. package/build/src/server/factories/write_response.d.ts +10 -3
  55. package/build/src/server/main.d.ts +83 -29
  56. package/build/src/tracing_channels.d.ts +4 -4
  57. package/build/src/types/main.d.ts +1 -1
  58. package/build/src/types/middleware.d.ts +35 -10
  59. package/build/src/types/qs.d.ts +5 -0
  60. package/build/src/types/request.d.ts +1 -1
  61. package/build/src/types/response.d.ts +14 -6
  62. package/build/src/types/route.d.ts +53 -51
  63. package/build/src/types/server.d.ts +30 -15
  64. package/build/src/types/tracing_channels.d.ts +24 -6
  65. package/build/src/types/url_builder.d.ts +22 -0
  66. package/build/src/utils.d.ts +76 -11
  67. package/package.json +29 -30
  68. package/build/chunk-ASX56VAK.js +0 -76
  69. package/build/client.cjs +0 -232
  70. package/build/client.d.cts +0 -258
  71. package/build/client.d.ts +0 -258
  72. package/build/client.js +0 -229
  73. package/build/src/client/main.d.ts +0 -3
  74. package/build/src/client/router.d.ts +0 -68
@@ -0,0 +1,37 @@
1
+ import { type ClientRouteMatchItTokens, type ClientRouteJSON, type URLOptions } from './types.ts';
2
+ /**
3
+ * Finds a route by its identifier across domains.
4
+ *
5
+ * Searches for routes by name, pattern, or controller reference. When no domain
6
+ * is specified, searches across all domains. Supports legacy lookup strategies
7
+ * for backwards compatibility.
8
+ *
9
+ * @param domainsRoutes - Object mapping domain names to route arrays
10
+ * @param routeIdentifier - Route name, pattern, or controller reference to find
11
+ * @param domain - Optional domain to limit search scope
12
+ * @param method - Optional HTTP method to filter routes
13
+ * @param disableLegacyLookup - Whether to disable pattern and controller lookup
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const route = findRoute(routes, 'users.show', 'api', 'GET')
18
+ * const route2 = findRoute(routes, '/users/:id', undefined, 'GET')
19
+ * ```
20
+ */
21
+ export declare function findRoute<Route extends ClientRouteJSON>(domainsRoutes: {
22
+ [domain: string]: Route[];
23
+ }, routeIdentifier: string, domain?: string, method?: string, disableLegacyLookup?: boolean): null | Route;
24
+ /**
25
+ * Makes URL for a given route pattern using its parsed tokens. The
26
+ * tokens could be generated using the "parseRoute" method.
27
+ *
28
+ * @param pattern - The route pattern
29
+ * @param tokens - Array of parsed route tokens
30
+ * @param searchParamsStringifier - Function to stringify query parameters
31
+ * @param params - Route parameters as array or object
32
+ * @param options - URL options
33
+ * @returns {string} The generated URL
34
+ */
35
+ export declare function createURL(pattern: string, tokens: Pick<ClientRouteMatchItTokens, 'val' | 'type' | 'end'>[], searchParamsStringifier: (qs: Record<string, any>) => string, params?: any[] | {
36
+ [param: string]: any;
37
+ }, options?: URLOptions): string;
@@ -2,50 +2,18 @@
2
2
  * Types shared with the client. These should never import other types
3
3
  */
4
4
  import { type Prettify } from '@poppinss/utils/types';
5
- /**
6
- * Options accepted by "url" and "route" helper methods
7
- */
8
- export type URLOptions = {
9
- qs?: Record<string, any>;
10
- prefixUrl?: string;
11
- };
12
- /**
13
- * Options accepted by "signedUrl" and "signedRoute" helper methods
14
- */
15
- export type SignedURLOptions = URLOptions & {
16
- expiresIn?: string | number;
17
- purpose?: string;
18
- };
19
- /**
20
- * Returns params for a route identifier
21
- */
22
- export type RouteBuilderArguments<Routes, Method extends keyof Routes, Identifier extends keyof Routes[Method], Options extends any = URLOptions> = Routes extends LookupList ? Prettify<undefined extends Routes[Method][Identifier]['params'] ? [identifier: Identifier, params?: undefined, options?: Options] : [undefined] extends [Routes[Method][Identifier]['params']] ? [
23
- identifier: Identifier,
24
- params?: Routes[Method][Identifier]['params'] | Routes[Method][Identifier]['paramsTuple'],
25
- options?: Options
26
- ] : [
27
- identifier: Identifier,
28
- params: Routes[Method][Identifier]['params'] | Routes[Method][Identifier]['paramsTuple'],
29
- options?: Options
30
- ]> : never;
31
- /**
32
- * Shape of a route param matcher
33
- */
34
- export type RouteMatcher = {
35
- match?: RegExp;
36
- cast?: (value: string) => any;
37
- };
38
- /**
39
- * Route token stored by matchit library
40
- */
41
- export type MatchItRouteToken = RouteMatcher & {
5
+ export type ClientRouteMatchItTokens = {
6
+ /** Original token string */
42
7
  old: string;
8
+ /** Token type identifier (0=static, 1=param, 2=wildcard, 3=optional) */
43
9
  type: 0 | 1 | 2 | 3;
10
+ /** Token value */
44
11
  val: string;
12
+ /** Token end delimiter */
45
13
  end: string;
46
14
  };
47
15
  /**
48
- * Representation of route shared with the client
16
+ * Complete route definition with all metadata, handlers, and execution context
49
17
  */
50
18
  export type ClientRouteJSON = {
51
19
  /**
@@ -57,23 +25,30 @@ export type ClientRouteJSON = {
57
25
  */
58
26
  pattern: string;
59
27
  /**
60
- * HTTP methods, the route responds to.
28
+ * Route handler
61
29
  */
62
- methods: string[];
30
+ handler?: unknown;
63
31
  /**
64
- * Route domain
32
+ * Tokens to be used to construct the route URL
65
33
  */
66
- domain: string;
34
+ tokens: ClientRouteMatchItTokens[];
67
35
  /**
68
- * Reference to the route handler
36
+ * HTTP methods, the route responds to.
69
37
  */
70
- handler: {
71
- reference?: any;
72
- } | Function;
38
+ methods: string[];
73
39
  /**
74
- * Tokens to be used to construct the route URL
40
+ * The domain for which the route is registered.
75
41
  */
76
- tokens: MatchItRouteToken[];
42
+ domain: string;
43
+ };
44
+ /**
45
+ * Configuration options for URL generation helpers
46
+ */
47
+ export type URLOptions = {
48
+ /** Query string parameters to append to the URL */
49
+ qs?: Record<string, any>;
50
+ /** URL prefix to prepend to the generated URL */
51
+ prefixUrl?: string;
77
52
  };
78
53
  /**
79
54
  * LookupList type is used by the URLBuilder to provide
@@ -82,16 +57,39 @@ export type ClientRouteJSON = {
82
57
  * There is no runtime property that matches this type. Its
83
58
  * purely for type-inference.
84
59
  */
60
+ /**
61
+ * Route definition structure for type-safe URL building
62
+ */
63
+ export type LookupListRoute = {
64
+ /** Parameters as a tuple for positional arguments */
65
+ paramsTuple?: [...any[]];
66
+ /** Parameters as a named object */
67
+ params?: {
68
+ [name: string]: any;
69
+ };
70
+ };
71
+ /**
72
+ * Complete route lookup structure organized by HTTP methods and route identifiers
73
+ */
85
74
  export type LookupList = {
75
+ /** HTTP method to route mapping */
86
76
  [method: string]: {
87
- [identifier: string]: {
88
- paramsTuple?: [...any[]];
89
- params?: {
90
- [name: string]: any;
91
- };
92
- };
77
+ /** Route identifier to route definition mapping */
78
+ [identifier: string]: LookupListRoute;
93
79
  };
94
80
  };
81
+ /**
82
+ * Utility type that constructs function arguments for route URL builders based on route parameters
83
+ */
84
+ export type RouteBuilderArguments<Identifier, Route, Options extends any = URLOptions> = Route extends LookupListRoute ? Prettify<Route['params'] extends undefined ? [identifier: Identifier, params?: undefined, options?: Options] : [undefined] extends [Route['params']] ? [
85
+ identifier: Identifier,
86
+ params?: Route['params'] | Route['paramsTuple'],
87
+ options?: Options
88
+ ] : [
89
+ identifier: Identifier,
90
+ params: Route['params'] | Route['paramsTuple'],
91
+ options?: Options
92
+ ]> : never;
95
93
  /**
96
94
  * The urlFor helper is used to make URLs for pre-existing known routes. You can
97
95
  * make a URL using the route name, route pattern, or the route controller
@@ -104,7 +102,7 @@ export type LookupList = {
104
102
  * urlFor('blog.adonisjs.com@posts.show', [1]) // /posts/1
105
103
  * ```
106
104
  */
107
- export type UrlFor<Routes extends LookupList, Options extends any = URLOptions> = (<Identifier extends keyof Routes['ALL'] & string>(...[identifier, params, options]: RouteBuilderArguments<Routes, 'ALL', Identifier, Options>) => string) & {
105
+ export type UrlFor<Routes extends LookupList, Options extends any = URLOptions> = (<Identifier extends keyof Routes['ALL'] & string>(...[identifier, params, options]: RouteBuilderArguments<Identifier, Routes['ALL'][Identifier], Options>) => string) & {
108
106
  /**
109
107
  * Make URL for a GET route. An error will be raised if the route doesn't
110
108
  * exist.
@@ -114,9 +112,13 @@ export type UrlFor<Routes extends LookupList, Options extends any = URLOptions>
114
112
  * urlFor.get('users.store', [1]) // Error: Route not found GET@users/store
115
113
  * ```
116
114
  */
117
- get<RouteIdentifier extends keyof Routes['GET'] & string>(...[identifier, params, options]: RouteBuilderArguments<Routes, 'GET', RouteIdentifier, Options>): {
118
- method: 'get';
115
+ get<RouteIdentifier extends keyof Routes['GET'] & string>(...[identifier, params, options]: RouteBuilderArguments<RouteIdentifier, Routes['GET'][RouteIdentifier], Options>): {
116
+ method: 'GET';
119
117
  url: string;
118
+ form: {
119
+ action: string;
120
+ method: 'GET';
121
+ };
120
122
  };
121
123
  /**
122
124
  * Make URL for a POST route. An error will be raised if the route doesn't
@@ -127,9 +129,13 @@ export type UrlFor<Routes extends LookupList, Options extends any = URLOptions>
127
129
  * urlFor.post('users.show', [1]) // Error: Route not found POST@users.show
128
130
  * ```
129
131
  */
130
- post<RouteIdentifier extends keyof Routes['POST'] & string>(...[identifier, params, options]: RouteBuilderArguments<Routes, 'POST', RouteIdentifier, Options>): {
131
- method: 'post';
132
+ post<RouteIdentifier extends keyof Routes['POST'] & string>(...[identifier, params, options]: RouteBuilderArguments<RouteIdentifier, Routes['POST'][RouteIdentifier], Options>): {
133
+ method: 'POST';
132
134
  url: string;
135
+ form: {
136
+ action: string;
137
+ method: 'POST';
138
+ };
133
139
  };
134
140
  /**
135
141
  * Make URL for a PUT route. An error will be raised if the route doesn't
@@ -140,9 +146,13 @@ export type UrlFor<Routes extends LookupList, Options extends any = URLOptions>
140
146
  * urlFor.put('users.show', [1]) // Error: Route not found PUT@users.show
141
147
  * ```
142
148
  */
143
- put<RouteIdentifier extends keyof Routes['PUT'] & string>(...[identifier, params, options]: RouteBuilderArguments<Routes, 'PUT', RouteIdentifier, Options>): {
144
- method: 'put';
149
+ put<RouteIdentifier extends keyof Routes['PUT'] & string>(...[identifier, params, options]: RouteBuilderArguments<RouteIdentifier, Routes['PUT'][RouteIdentifier], Options>): {
150
+ method: 'PUT';
145
151
  url: string;
152
+ form: {
153
+ action: string;
154
+ method: 'PUT';
155
+ };
146
156
  };
147
157
  /**
148
158
  * Make URL for a PATCH route. An error will be raised if the route doesn't
@@ -153,9 +163,13 @@ export type UrlFor<Routes extends LookupList, Options extends any = URLOptions>
153
163
  * urlFor.put('users.show', [1]) // Error: Route not found PATCH@users.show
154
164
  * ```
155
165
  */
156
- patch<RouteIdentifier extends keyof Routes['PATCH'] & string>(...[identifier, params, options]: RouteBuilderArguments<Routes, 'PATCH', RouteIdentifier, Options>): {
157
- method: 'patch';
166
+ patch<RouteIdentifier extends keyof Routes['PATCH'] & string>(...[identifier, params, options]: RouteBuilderArguments<RouteIdentifier, Routes['PATCH'][RouteIdentifier], Options>): {
167
+ method: 'PATCH';
158
168
  url: string;
169
+ form: {
170
+ action: string;
171
+ method: 'PATCH';
172
+ };
159
173
  };
160
174
  /**
161
175
  * Make URL for a DELETE route. An error will be raised if the route doesn't
@@ -166,16 +180,24 @@ export type UrlFor<Routes extends LookupList, Options extends any = URLOptions>
166
180
  * urlFor.delete('users.show', [1]) // Error: Route not found DELETE@users.show
167
181
  * ```
168
182
  */
169
- delete<RouteIdentifier extends keyof Routes['DELETE'] & string>(...[identifier, params, options]: RouteBuilderArguments<Routes, 'DELETE', RouteIdentifier, Options>): {
170
- method: 'delete';
183
+ delete<RouteIdentifier extends keyof Routes['DELETE'] & string>(...[identifier, params, options]: RouteBuilderArguments<RouteIdentifier, Routes['DELETE'][RouteIdentifier], Options>): {
184
+ method: 'DELETE';
171
185
  url: string;
186
+ form: {
187
+ action: string;
188
+ method: 'DELETE';
189
+ };
172
190
  };
173
191
  /**
174
192
  * Make URL for a custom route method. An error will be raised if the route doesn't
175
193
  * exist for the same method.
176
194
  */
177
- method<Method extends keyof Routes & string, RouteIdentifier extends keyof Routes[Method] & string>(method: Method, ...[identifier, params, options]: RouteBuilderArguments<Routes, Method, RouteIdentifier, Options>): {
195
+ method<Method extends keyof Routes & string, RouteIdentifier extends keyof Routes[Method] & string>(method: Method, ...[identifier, params, options]: RouteBuilderArguments<RouteIdentifier, Routes[Method][RouteIdentifier], Options>): {
178
196
  method: Method;
179
197
  url: string;
198
+ form: {
199
+ action: string;
200
+ method: Method;
201
+ };
180
202
  };
181
203
  };
@@ -1,13 +1,15 @@
1
- import { type RouterClient } from './router.ts';
2
- import { type UrlFor, type LookupList, type URLOptions, type ClientRouteJSON, type MatchItRouteToken } from './types.ts';
3
- /**
4
- * Makes URL for a given route pattern. The route pattern could be an
5
- * identifier or an array of tokens.
6
- */
7
- export declare function createURL(identifier: string, tokens: Pick<MatchItRouteToken, 'val' | 'type' | 'end'>[], searchParamsStringifier: (qs: Record<string, any>) => string, params?: any[] | {
8
- [param: string]: any;
9
- }, options?: URLOptions): string;
1
+ import { createURL, findRoute } from './helpers.ts';
2
+ import { type UrlFor, type LookupList, type ClientRouteJSON } from './types.ts';
3
+ export * from './types.ts';
4
+ export { createURL, findRoute };
10
5
  /**
11
6
  * Creates the URLBuilder helper
7
+ * @param router - The router instance
8
+ * @param searchParamsStringifier - Function to stringify query string parameters
9
+ * @returns URL builder function for creating URLs
12
10
  */
13
- export declare function createUrlBuilder<Routes extends LookupList>(router: RouterClient<ClientRouteJSON>, searchParamsStringifier: (qs: Record<string, any>) => string): UrlFor<Routes>;
11
+ export declare function createUrlBuilder<Routes extends LookupList>(routesLoader: {
12
+ [domain: string]: ClientRouteJSON[];
13
+ } | (() => {
14
+ [domain: string]: ClientRouteJSON[];
15
+ }), searchParamsStringifier: (qs: Record<string, any>) => string): UrlFor<Routes>;
@@ -0,0 +1,12 @@
1
+ import {
2
+ createUrlBuilder
3
+ } from "../../chunk-5PWHBE2E.js";
4
+ import {
5
+ createURL,
6
+ findRoute
7
+ } from "../../chunk-2QM3D5BN.js";
8
+ export {
9
+ createURL,
10
+ createUrlBuilder,
11
+ findRoute
12
+ };
@@ -1,37 +1,95 @@
1
1
  import type { Encryption } from '@adonisjs/encryption';
2
2
  /**
3
- * Cookie client exposes the API to parse/set AdonisJS cookies
4
- * as a client.
3
+ * Cookie client provides a unified API for parsing and setting AdonisJS cookies on the client side.
4
+ *
5
+ * This class handles different types of cookies including plain, signed, and encrypted cookies.
6
+ * It provides methods to encode/decode cookies for client-side operations and parse server responses.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const client = new CookieClient(encryption)
11
+ *
12
+ * // Encrypt a cookie value
13
+ * const encrypted = client.encrypt('sessionId', 'abc123')
14
+ *
15
+ * // Parse a cookie from server response
16
+ * const value = client.parse('sessionId', cookieValue)
17
+ * ```
5
18
  */
6
19
  export declare class CookieClient {
7
20
  #private;
21
+ /**
22
+ * Create a new instance of CookieClient
23
+ *
24
+ * @param encryption - The encryption instance for cookie operations
25
+ */
8
26
  constructor(encryption: Encryption);
9
27
  /**
10
28
  * Encrypt a key value pair to be sent in the cookie header
29
+ *
30
+ * @param key - The cookie key
31
+ * @param value - The value to encrypt
32
+ * @returns The encrypted cookie string or null if encryption fails
11
33
  */
12
34
  encrypt(key: string, value: any): string | null;
13
35
  /**
14
36
  * Sign a key value pair to be sent in the cookie header
37
+ *
38
+ * @param key - The cookie key
39
+ * @param value - The value to sign
40
+ * @returns The signed cookie string or null if signing fails
15
41
  */
16
42
  sign(key: string, value: any): string | null;
17
43
  /**
18
44
  * Encode a key value pair to be sent in the cookie header
45
+ *
46
+ * @param _ - Unused key parameter
47
+ * @param value - The value to encode
48
+ * @param stringify - Whether to stringify the value before encoding
49
+ * @returns The encoded cookie string or null if encoding fails
19
50
  */
20
51
  encode(_: string, value: any, stringify?: boolean): string | null;
21
52
  /**
22
53
  * Unsign a signed cookie value
54
+ *
55
+ * @param key - The cookie key
56
+ * @param value - The signed cookie value to unsign
57
+ * @returns The original value if valid signature, null otherwise
23
58
  */
24
59
  unsign(key: string, value: string): any;
25
60
  /**
26
61
  * Decrypt an encrypted cookie value
62
+ *
63
+ * @param key - The cookie key
64
+ * @param value - The encrypted cookie value to decrypt
65
+ * @returns The decrypted value or null if decryption fails
27
66
  */
28
67
  decrypt(key: string, value: string): any;
29
68
  /**
30
69
  * Decode an encoded cookie value
70
+ *
71
+ * @param _ - Unused key parameter
72
+ * @param value - The encoded cookie value to decode
73
+ * @param stringified - Whether the value was stringified during encoding
74
+ * @returns The decoded value or null if decoding fails
31
75
  */
32
76
  decode(_: string, value: string, stringified?: boolean): any;
33
77
  /**
34
- * Parse response cookie
78
+ * Parse a cookie value by attempting to decrypt, unsign, or decode it.
79
+ *
80
+ * This method tries different unpacking strategies in order:
81
+ * 1. Unsign if it's a signed cookie
82
+ * 2. Decrypt if it's an encrypted cookie
83
+ * 3. Decode if it's a plain encoded cookie
84
+ *
85
+ * @param key - The cookie key
86
+ * @param value - The cookie value to parse
87
+ *
88
+ * @example
89
+ * ```ts
90
+ * const parsed = client.parse('session', 'e30.abc123def')
91
+ * // Returns the original value if successfully parsed
92
+ * ```
35
93
  */
36
94
  parse(key: string, value: any): any;
37
95
  }
@@ -1,16 +1,29 @@
1
1
  import type { Encryption } from '@adonisjs/encryption';
2
2
  /**
3
3
  * Encrypt a value to be set as cookie
4
+ *
5
+ * @param key - The cookie key used for encryption
6
+ * @param value - The value to encrypt
7
+ * @param encryption - The encryption instance
8
+ * @returns The encrypted cookie string or null if value is null/undefined
4
9
  */
5
10
  export declare function pack(key: string, value: any, encryption: Encryption): null | string;
6
11
  /**
7
12
  * Returns a boolean, if the unpack method from this module can attempt
8
13
  * to unpack encrypted value.
14
+ *
15
+ * @param encryptedValue - The encrypted value to check
16
+ * @returns True if the value can be unpacked by this module
9
17
  */
10
18
  export declare function canUnpack(encryptedValue: string): boolean;
11
19
  /**
12
20
  * Attempts to unpack the encrypted cookie value. Returns null, when fails to do so.
13
21
  * Only call this method, when `canUnpack` returns true, otherwise runtime
14
22
  * exceptions can be raised.
23
+ *
24
+ * @param key - The cookie key used for decryption
25
+ * @param encryptedValue - The encrypted value to decrypt
26
+ * @param encryption - The encryption instance
27
+ * @returns The decrypted value or null if decryption fails
15
28
  */
16
29
  export declare function unpack(key: string, encryptedValue: string, encryption: Encryption): null | any;
@@ -1,15 +1,24 @@
1
1
  /**
2
2
  * Encodes a value into a base64 url encoded string to
3
3
  * be set as cookie
4
+ *
5
+ * @param value - The value to encode
6
+ * @returns The encoded cookie string or null if value is null/undefined
4
7
  */
5
8
  export declare function pack(value: any): null | string;
6
9
  /**
7
10
  * Returns true when this `unpack` method of this module can attempt
8
11
  * to unpack the encode value.
12
+ *
13
+ * @param encodedValue - The encoded value to check
14
+ * @returns True if the value can be unpacked by this module
9
15
  */
10
16
  export declare function canUnpack(encodedValue: string): boolean;
11
17
  /**
12
18
  * Attempts to unpack the value by decoding it. Make sure to call, `canUnpack`
13
19
  * before calling this method
20
+ *
21
+ * @param encodedValue - The encoded value to decode
22
+ * @returns The decoded value or null if decoding fails
14
23
  */
15
24
  export declare function unpack(encodedValue: string): null | any;
@@ -2,15 +2,28 @@ import type { Encryption } from '@adonisjs/encryption';
2
2
  /**
3
3
  * Signs a value to be shared as a cookie. The signed output has a
4
4
  * hash to verify tampering with the original value
5
+ *
6
+ * @param key - The cookie key used for signing
7
+ * @param value - The value to sign
8
+ * @param encryption - The encryption instance
9
+ * @returns The signed cookie string or null if value is null/undefined
5
10
  */
6
11
  export declare function pack(key: string, value: any, encryption: Encryption): null | string;
7
12
  /**
8
13
  * Returns a boolean, if the unpack method from this module can attempt
9
14
  * to unpack the signed value.
15
+ *
16
+ * @param signedValue - The signed value to check
17
+ * @returns True if the value can be unpacked by this module
10
18
  */
11
19
  export declare function canUnpack(signedValue: string): boolean;
12
20
  /**
13
21
  * Attempts to unpack the signed value. Make sure to call `canUnpack` before
14
22
  * calling this method.
23
+ *
24
+ * @param key - The cookie key used for verification
25
+ * @param signedValue - The signed value to verify and unpack
26
+ * @param encryption - The encryption instance
27
+ * @returns The original value or null if verification fails
15
28
  */
16
29
  export declare function unpack(key: string, signedValue: string, encryption: Encryption): null | any;
@@ -11,27 +11,45 @@ import type { Encryption } from '@adonisjs/encryption';
11
11
  */
12
12
  export declare class CookieParser {
13
13
  #private;
14
+ /**
15
+ * Create a new instance of CookieParser
16
+ *
17
+ * @param cookieHeader - The raw cookie header string from the request
18
+ * @param encryption - The encryption instance for cookie operations
19
+ */
14
20
  constructor(cookieHeader: string, encryption: Encryption);
15
21
  /**
16
22
  * Attempts to decode a cookie by the name. When calling this method,
17
23
  * you are assuming that the cookie was just stringified in the first
18
24
  * place and not signed or encrypted.
25
+ *
26
+ * @param key - The cookie key to decode
27
+ * @param stringified - Whether the cookie value was stringified
28
+ * @returns The decoded cookie value or null if decoding fails
19
29
  */
20
30
  decode(key: string, stringified?: boolean): any | null;
21
31
  /**
22
32
  * Attempts to unsign a cookie by the name. When calling this method,
23
33
  * you are assuming that the cookie was signed in the first place.
34
+ *
35
+ * @param key - The cookie key to unsign
36
+ * @returns The original cookie value or null if unsigning fails
24
37
  */
25
38
  unsign(key: string): null | any;
26
39
  /**
27
40
  * Attempts to decrypt a cookie by the name. When calling this method,
28
41
  * you are assuming that the cookie was encrypted in the first place.
42
+ *
43
+ * @param key - The cookie key to decrypt
44
+ * @returns The decrypted cookie value or null if decryption fails
29
45
  */
30
46
  decrypt(key: string): null | any;
31
47
  /**
32
48
  * Returns an object of cookies key-value pair. Do note, the
33
49
  * cookies are not decoded, unsigned or decrypted inside this
34
50
  * list.
51
+ *
52
+ * @returns Raw cookies as key-value pairs
35
53
  */
36
54
  list(): Record<string, any>;
37
55
  }
@@ -1,5 +1,5 @@
1
1
  import type { Encryption } from '@adonisjs/encryption';
2
- import type { CookieOptions } from '../types/response.js';
2
+ import type { CookieOptions } from '../types/response.ts';
3
3
  /**
4
4
  * Cookies serializer is used to serialize a value to be set on the `Set-Cookie`
5
5
  * header. You can `encode`, `sign` on `encrypt` cookies using the serializer
@@ -7,6 +7,11 @@ import type { CookieOptions } from '../types/response.js';
7
7
  */
8
8
  export declare class CookieSerializer {
9
9
  #private;
10
+ /**
11
+ * Create a new instance of CookieSerializer
12
+ *
13
+ * @param encryption - The encryption instance for cookie operations
14
+ */
10
15
  constructor(encryption: Encryption);
11
16
  /**
12
17
  * Encodes value as a plain cookie. By default, the plain value will be converted
@@ -18,11 +23,15 @@ export declare class CookieSerializer {
18
23
  * serializer.encode('name', 'virk')
19
24
  * serializer.encode('name', 'virk', { stringify: false })
20
25
  * ```
26
+ *
27
+ * @param key - The cookie key
28
+ * @param value - The value to encode
29
+ * @param options - Cookie encoding options
30
+ * @returns The serialized cookie string or null if encoding fails
21
31
  */
22
32
  encode(key: string, value: any, options?: Partial<CookieOptions & {
23
33
  /**
24
- * @depreacted
25
- * Instead use stringify option
34
+ * @depreacted Instead use stringify option
26
35
  */
27
36
  encode: boolean;
28
37
  stringify: boolean;
@@ -30,10 +39,20 @@ export declare class CookieSerializer {
30
39
  /**
31
40
  * Sign a key-value pair to a signed cookie. The signed value has a
32
41
  * verification hash attached to it to detect data tampering.
42
+ *
43
+ * @param key - The cookie key
44
+ * @param value - The value to sign
45
+ * @param options - Cookie options
46
+ * @returns The serialized signed cookie string or null if signing fails
33
47
  */
34
48
  sign(key: string, value: any, options?: Partial<CookieOptions>): string | null;
35
49
  /**
36
50
  * Encrypts a key-value pair to an encrypted cookie.
51
+ *
52
+ * @param key - The cookie key
53
+ * @param value - The value to encrypt
54
+ * @param options - Cookie options
55
+ * @returns The serialized encrypted cookie string or null if encryption fails
37
56
  */
38
57
  encrypt(key: string, value: any, options?: Partial<CookieOptions>): string | null;
39
58
  }
@@ -1,2 +1,15 @@
1
+ /**
2
+ * Debug logger instance for the AdonisJS HTTP server package.
3
+ *
4
+ * This debug logger can be enabled by setting the NODE_DEBUG environment variable
5
+ * to include 'adonisjs:http'. When enabled, it will output detailed debugging
6
+ * information about HTTP server operations including route matching, middleware
7
+ * execution, and response generation.
8
+ *
9
+ * @example
10
+ * ```bash
11
+ * NODE_DEBUG=adonisjs:http node ace serve
12
+ * ```
13
+ */
1
14
  declare const _default: import("util").DebugLogger;
2
15
  export default _default;
@@ -1,12 +1,28 @@
1
- import type { ServerConfig } from './types/server.js';
2
- type DeepPartial<T> = {
3
- [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
4
- };
1
+ import { type DeepPartial } from '@poppinss/utils/types';
2
+ import type { ServerConfig } from './types/server.ts';
5
3
  type UserDefinedServerConfig = DeepPartial<Omit<ServerConfig, 'trustProxy'> & {
6
4
  trustProxy: ((address: string, distance: number) => boolean) | boolean | string;
7
5
  }>;
8
6
  /**
9
- * Define configuration for the HTTP server
7
+ * Define configuration for the HTTP server with sensible defaults.
8
+ *
9
+ * This function merges user-provided configuration with default values,
10
+ * normalizes certain properties (like cookie maxAge and trustProxy settings),
11
+ * and returns a complete ServerConfig object.
12
+ *
13
+ * @param config - User-defined server configuration options
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const config = defineConfig({
18
+ * trustProxy: true,
19
+ * cookie: {
20
+ * maxAge: '7d',
21
+ * secure: false
22
+ * },
23
+ * etag: true
24
+ * })
25
+ * ```
10
26
  */
11
27
  export declare function defineConfig(config: UserDefinedServerConfig): ServerConfig;
12
28
  export {};