@asenajs/ergenecore 2.0.0 → 3.1.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/README.md +18 -6
- package/dist/lib/Ergenecore.d.ts +5 -0
- package/dist/lib/Ergenecore.js +66 -32
- package/dist/lib/Ergenecore.js.map +1 -1
- package/dist/lib/ErgenecoreContextWrapper.d.ts +28 -0
- package/dist/lib/ErgenecoreContextWrapper.js +41 -0
- package/dist/lib/ErgenecoreContextWrapper.js.map +1 -1
- package/dist/lib/ErgenecoreWebsocketAdapter.d.ts +10 -0
- package/dist/lib/ErgenecoreWebsocketAdapter.js +34 -4
- package/dist/lib/ErgenecoreWebsocketAdapter.js.map +1 -1
- package/dist/lib/errors.d.ts +13 -89
- package/dist/lib/errors.js +13 -100
- package/dist/lib/errors.js.map +1 -1
- package/dist/lib/middlewares/CorsMiddleware.d.ts +22 -6
- package/dist/lib/middlewares/CorsMiddleware.js +56 -27
- package/dist/lib/middlewares/CorsMiddleware.js.map +1 -1
- package/dist/lib/middlewares/RateLimiterMiddleware.d.ts +11 -2
- package/dist/lib/middlewares/RateLimiterMiddleware.js +29 -2
- package/dist/lib/middlewares/RateLimiterMiddleware.js.map +1 -1
- package/package.json +11 -8
|
@@ -68,6 +68,16 @@ export class ErgenecoreWebsocketAdapter extends AsenaWebsocketAdapter {
|
|
|
68
68
|
this.clearAllHeartbeats();
|
|
69
69
|
// Clear connection tracking
|
|
70
70
|
this.activeConnections.clear();
|
|
71
|
+
// Release the transport. Both hooks are optional on the contract - BunLocalTransport declares
|
|
72
|
+
// neither, because server.publish() owns nothing that has to be given back - but a remote
|
|
73
|
+
// transport holds a subscriber connection with a live channel subscription plus a publisher
|
|
74
|
+
// connection, and destroy() had no call site anywhere in the framework. A pod that restarts
|
|
75
|
+
// in-process (a test suite, a watch-mode reload) therefore leaked two broker connections per
|
|
76
|
+
// cycle until the broker refused new ones.
|
|
77
|
+
//
|
|
78
|
+
// Last, after the HTTP surface is already down: a close handler running during the drain may
|
|
79
|
+
// still broadcast, and publish() on a destroyed transport is a null dereference.
|
|
80
|
+
await this.transport?.destroy?.();
|
|
71
81
|
this.logger.info('WebSocket shutdown complete');
|
|
72
82
|
}
|
|
73
83
|
/**
|
|
@@ -141,16 +151,36 @@ export class ErgenecoreWebsocketAdapter extends AsenaWebsocketAdapter {
|
|
|
141
151
|
if (!this.websockets || this.websockets.size < 1) {
|
|
142
152
|
return;
|
|
143
153
|
}
|
|
144
|
-
//
|
|
145
|
-
|
|
146
|
-
|
|
154
|
+
// Assigned back to the field, not a local: sockets and the shutdown path read `_transport`,
|
|
155
|
+
// so a default that reached only a local left the two broadcast paths disagreeing.
|
|
156
|
+
this._transport ??= new BunLocalTransport();
|
|
157
|
+
await this._transport.init?.(server);
|
|
158
|
+
this.warnIfTransportLacksPublishRemote();
|
|
147
159
|
// Create a single shared wrapper for all WebSocket services
|
|
148
|
-
const sharedServer = new AsenaWebSocketServer(
|
|
160
|
+
const sharedServer = new AsenaWebSocketServer(this._transport);
|
|
149
161
|
// Assign the shared wrapper to all services
|
|
150
162
|
for (const websocket of this.websockets.values()) {
|
|
151
163
|
websocket.server = sharedServer;
|
|
152
164
|
}
|
|
153
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* Warns once, at startup, when the configured transport predates `publishRemote()`.
|
|
168
|
+
*
|
|
169
|
+
* Such a transport still works: `socket.publish()` falls back to its `publish()`, which does
|
|
170
|
+
* local delivery as well - so the sender receives its own message, unlike every other
|
|
171
|
+
* configuration. Warning here rather than per message keeps a hot path clean, and warning at
|
|
172
|
+
* all is the point: the alternative reading, treating the missing method as "no cross-pod
|
|
173
|
+
* delivery wanted", would drop messages between pods in silence.
|
|
174
|
+
*/
|
|
175
|
+
warnIfTransportLacksPublishRemote() {
|
|
176
|
+
if (typeof this._transport?.publishRemote === 'function') {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
this.logger.warn('WebSocket transport does not implement publishRemote(). socket.publish() will fall back to ' +
|
|
180
|
+
'transport.publish(), which delivers to the publishing socket as well. Implement ' +
|
|
181
|
+
'publishRemote() (broker publish only, no local delivery) to keep the sender excluded. ' +
|
|
182
|
+
'The fallback is removed in the next major version.');
|
|
183
|
+
}
|
|
154
184
|
/**
|
|
155
185
|
* Creates a handler wrapper for WebSocket lifecycle events
|
|
156
186
|
* @param type - Event type (onOpenInternal, onMessage, etc.)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErgenecoreWebsocketAdapter.js","sourceRoot":"","sources":["../../lib/ErgenecoreWebsocketAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAI/D,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,iBAAiB,GAIlB,MAAM,2BAA2B,CAAC;AAEnC;;;;GAIG;AACH,MAAM,OAAO,0BAA2B,SAAQ,qBAAqB;IAC5D,IAAI,GAAG,4BAA4B,CAAC;IAEnC,iBAAiB,GAA6B,IAAI,GAAG,EAAE,CAAC,CAAC,qCAAqC;IAE9F,gBAAgB,GAAwB,IAAI,GAAG,EAAE,CAAC,CAAC,+BAA+B;IAE1F,YAAmB,MAAoB;QACrC,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IAED;;;OAGG;IACI,iBAAiB,CAAC,gBAA4C;QACnE,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;QACnD,CAAC;QAED,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACrD,CAAC;QAED,qFAAqF;QACrF,MAAM,cAAc,GAAG,mBAAmB,CAAC;QAE3C,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAAE,CAAC;YACrD,MAAM,IAAI,KAAK,CACb,wCAAwC,g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BACnB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,yCAAyC,EAAE,SAAS,CAAC,CAAC;oBAC1E,CAAC;gBACH,CAAC;gBAED,mDAAmD;gBACnD,IAAI,IAAI,KAAK,gBAAgB,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;oBACtD,IAAI,EAAE,CAAC,UAAU,KAAK,SAAS,CAAC,IAAI,EAAE,CAAC;wBACrC,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;oBAClC,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC,CAAC;IACJ,CAAC;CACF"}
|
package/dist/lib/errors.d.ts
CHANGED
|
@@ -1,101 +1,25 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { HTTP_EXCEPTION, type HttpExceptionLike, VALIDATION_ERROR, type ValidationErrorLike, type ValidationIssue } from '@asenajs/asena/adapter';
|
|
1
|
+
import { HttpException, VALIDATION_ERROR, type ValidationErrorLike, type ValidationIssue } from '@asenajs/asena/adapter';
|
|
3
2
|
import { type ZodError } from 'zod';
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
export interface HttpExceptionInit extends ResponseInit {
|
|
8
|
-
/** The original error that caused this exception */
|
|
9
|
-
cause?: Error;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* HTTP Exception for Ergenecore
|
|
4
|
+
* The exception applications throw, re-exported so `@asenajs/ergenecore` keeps offering it under
|
|
5
|
+
* the name it always had.
|
|
13
6
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* ```typescript
|
|
19
|
-
* // In middleware
|
|
20
|
-
* if (!user) {
|
|
21
|
-
* throw new HttpException(401, 'Unauthorized', {
|
|
22
|
-
* headers: { 'WWW-Authenticate': 'Bearer' }
|
|
23
|
-
* });
|
|
24
|
-
* }
|
|
25
|
-
*
|
|
26
|
-
* // In handler
|
|
27
|
-
* if (!isValid) {
|
|
28
|
-
* throw new HttpException(400, { error: 'Invalid data' });
|
|
29
|
-
* }
|
|
30
|
-
*
|
|
31
|
-
* // With cause
|
|
32
|
-
* try { await db.query(...) } catch (err) {
|
|
33
|
-
* throw new HttpException(500, 'Database Error', { cause: err });
|
|
34
|
-
* }
|
|
35
|
-
* ```
|
|
7
|
+
* It used to be defined here. It now lives in `@asenajs/asena/adapter` so the hono adapter can
|
|
8
|
+
* offer the *same class* rather than a look-alike - one `throw new HttpException(...)` that
|
|
9
|
+
* compiles and behaves identically on both. This is a re-export, not a subclass: the class object
|
|
10
|
+
* is the one core exports, so `instanceof` holds across the two import paths.
|
|
36
11
|
*/
|
|
37
|
-
export
|
|
38
|
-
/**
|
|
39
|
-
* Registered-symbol brand so `isHttpException()` works even when a project resolves two
|
|
40
|
-
* copies of this package - `instanceof` answers false across copies, silently.
|
|
41
|
-
*/
|
|
42
|
-
readonly [HTTP_EXCEPTION]: true;
|
|
43
|
-
/**
|
|
44
|
-
* HTTP status code
|
|
45
|
-
*/
|
|
46
|
-
readonly status: number;
|
|
47
|
-
/**
|
|
48
|
-
* Response body (can be string or object)
|
|
49
|
-
*/
|
|
50
|
-
readonly body: string | object;
|
|
51
|
-
/**
|
|
52
|
-
* Optional response init options (headers, statusText, cause, etc.)
|
|
53
|
-
*/
|
|
54
|
-
readonly options?: HttpExceptionInit;
|
|
55
|
-
/**
|
|
56
|
-
* Creates a new HttpException
|
|
57
|
-
*
|
|
58
|
-
* @param status - HTTP status code (e.g., 401, 403, 404) or HttpStatusCode enum value
|
|
59
|
-
* @param body - Response body (string or object to be JSON stringified)
|
|
60
|
-
* @param options - Optional HttpExceptionInit options (headers, statusText, cause, etc.)
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* ```typescript
|
|
64
|
-
* // Simple message
|
|
65
|
-
* throw new HttpException(404, 'Not Found');
|
|
66
|
-
*
|
|
67
|
-
* // With HttpStatusCode enum
|
|
68
|
-
* throw new HttpException(ClientErrorStatusCode.NotFound, 'Not Found');
|
|
69
|
-
*
|
|
70
|
-
* // JSON object
|
|
71
|
-
* throw new HttpException(400, { error: 'Invalid input', field: 'email' });
|
|
72
|
-
*
|
|
73
|
-
* // With headers
|
|
74
|
-
* throw new HttpException(429, 'Too Many Requests', {
|
|
75
|
-
* headers: { 'Retry-After': '60' }
|
|
76
|
-
* });
|
|
77
|
-
*
|
|
78
|
-
* // With cause
|
|
79
|
-
* throw new HttpException(500, 'Internal Error', { cause: originalError });
|
|
80
|
-
* ```
|
|
81
|
-
*/
|
|
82
|
-
constructor(status: HttpStatusCode | number, body?: string | object, options?: HttpExceptionInit);
|
|
83
|
-
/**
|
|
84
|
-
* Converts the exception to a Response object
|
|
85
|
-
*
|
|
86
|
-
* @returns Bun Response object ready to be returned
|
|
87
|
-
*/
|
|
88
|
-
getResponse(): Response;
|
|
89
|
-
}
|
|
12
|
+
export { HttpException, type HttpExceptionInit } from '@asenajs/asena/adapter';
|
|
90
13
|
/**
|
|
91
14
|
* Thrown when request validation fails, so the failure reaches the application's
|
|
92
15
|
* `ConfigService.onError` like every other error instead of being answered inside
|
|
93
16
|
* the validation step.
|
|
94
17
|
*
|
|
95
|
-
* Extends `HttpException` with status 400 deliberately:
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
18
|
+
* Extends `HttpException` with status 400 deliberately: a handler that matches with
|
|
19
|
+
* `isHttpException()` and replies with `error.status` keeps answering 400, so adopting
|
|
20
|
+
* this does not silently turn validation failures into 500s. Check `isValidationError()`
|
|
21
|
+
* first if you want validation failures to get their own envelope - this is an
|
|
22
|
+
* `HttpException`, so the generic branch would otherwise swallow it.
|
|
99
23
|
*
|
|
100
24
|
* @example
|
|
101
25
|
* ```typescript
|
package/dist/lib/errors.js
CHANGED
|
@@ -1,112 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HttpException, VALIDATION_ERROR, } from '@asenajs/asena/adapter';
|
|
2
2
|
import { flattenError } from 'zod';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* The exception applications throw, re-exported so `@asenajs/ergenecore` keeps offering it under
|
|
5
|
+
* the name it always had.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* ```typescript
|
|
11
|
-
* // In middleware
|
|
12
|
-
* if (!user) {
|
|
13
|
-
* throw new HttpException(401, 'Unauthorized', {
|
|
14
|
-
* headers: { 'WWW-Authenticate': 'Bearer' }
|
|
15
|
-
* });
|
|
16
|
-
* }
|
|
17
|
-
*
|
|
18
|
-
* // In handler
|
|
19
|
-
* if (!isValid) {
|
|
20
|
-
* throw new HttpException(400, { error: 'Invalid data' });
|
|
21
|
-
* }
|
|
22
|
-
*
|
|
23
|
-
* // With cause
|
|
24
|
-
* try { await db.query(...) } catch (err) {
|
|
25
|
-
* throw new HttpException(500, 'Database Error', { cause: err });
|
|
26
|
-
* }
|
|
27
|
-
* ```
|
|
7
|
+
* It used to be defined here. It now lives in `@asenajs/asena/adapter` so the hono adapter can
|
|
8
|
+
* offer the *same class* rather than a look-alike - one `throw new HttpException(...)` that
|
|
9
|
+
* compiles and behaves identically on both. This is a re-export, not a subclass: the class object
|
|
10
|
+
* is the one core exports, so `instanceof` holds across the two import paths.
|
|
28
11
|
*/
|
|
29
|
-
export
|
|
30
|
-
/**
|
|
31
|
-
* Registered-symbol brand so `isHttpException()` works even when a project resolves two
|
|
32
|
-
* copies of this package - `instanceof` answers false across copies, silently.
|
|
33
|
-
*/
|
|
34
|
-
[HTTP_EXCEPTION] = true;
|
|
35
|
-
/**
|
|
36
|
-
* HTTP status code
|
|
37
|
-
*/
|
|
38
|
-
status;
|
|
39
|
-
/**
|
|
40
|
-
* Response body (can be string or object)
|
|
41
|
-
*/
|
|
42
|
-
body;
|
|
43
|
-
/**
|
|
44
|
-
* Optional response init options (headers, statusText, cause, etc.)
|
|
45
|
-
*/
|
|
46
|
-
options;
|
|
47
|
-
/**
|
|
48
|
-
* Creates a new HttpException
|
|
49
|
-
*
|
|
50
|
-
* @param status - HTTP status code (e.g., 401, 403, 404) or HttpStatusCode enum value
|
|
51
|
-
* @param body - Response body (string or object to be JSON stringified)
|
|
52
|
-
* @param options - Optional HttpExceptionInit options (headers, statusText, cause, etc.)
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```typescript
|
|
56
|
-
* // Simple message
|
|
57
|
-
* throw new HttpException(404, 'Not Found');
|
|
58
|
-
*
|
|
59
|
-
* // With HttpStatusCode enum
|
|
60
|
-
* throw new HttpException(ClientErrorStatusCode.NotFound, 'Not Found');
|
|
61
|
-
*
|
|
62
|
-
* // JSON object
|
|
63
|
-
* throw new HttpException(400, { error: 'Invalid input', field: 'email' });
|
|
64
|
-
*
|
|
65
|
-
* // With headers
|
|
66
|
-
* throw new HttpException(429, 'Too Many Requests', {
|
|
67
|
-
* headers: { 'Retry-After': '60' }
|
|
68
|
-
* });
|
|
69
|
-
*
|
|
70
|
-
* // With cause
|
|
71
|
-
* throw new HttpException(500, 'Internal Error', { cause: originalError });
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
constructor(status, body = '', options) {
|
|
75
|
-
const message = typeof body === 'string' ? body : JSON.stringify(body);
|
|
76
|
-
super(message, options?.cause ? { cause: options.cause } : undefined);
|
|
77
|
-
this.name = 'HttpException';
|
|
78
|
-
this.status = status;
|
|
79
|
-
this.body = body;
|
|
80
|
-
this.options = options;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Converts the exception to a Response object
|
|
84
|
-
*
|
|
85
|
-
* @returns Bun Response object ready to be returned
|
|
86
|
-
*/
|
|
87
|
-
getResponse() {
|
|
88
|
-
const body = typeof this.body === 'string' ? this.body : JSON.stringify(this.body);
|
|
89
|
-
const headers = new Headers(this.options?.headers);
|
|
90
|
-
// Set Content-Type to application/json if body is an object and not already set
|
|
91
|
-
if (typeof this.body === 'object' && !headers.has('Content-Type')) {
|
|
92
|
-
headers.set('Content-Type', 'application/json');
|
|
93
|
-
}
|
|
94
|
-
return new Response(body, {
|
|
95
|
-
status: this.status,
|
|
96
|
-
statusText: this.options?.statusText,
|
|
97
|
-
headers,
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
}
|
|
12
|
+
export { HttpException } from '@asenajs/asena/adapter';
|
|
101
13
|
/**
|
|
102
14
|
* Thrown when request validation fails, so the failure reaches the application's
|
|
103
15
|
* `ConfigService.onError` like every other error instead of being answered inside
|
|
104
16
|
* the validation step.
|
|
105
17
|
*
|
|
106
|
-
* Extends `HttpException` with status 400 deliberately:
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
18
|
+
* Extends `HttpException` with status 400 deliberately: a handler that matches with
|
|
19
|
+
* `isHttpException()` and replies with `error.status` keeps answering 400, so adopting
|
|
20
|
+
* this does not silently turn validation failures into 500s. Check `isValidationError()`
|
|
21
|
+
* first if you want validation failures to get their own envelope - this is an
|
|
22
|
+
* `HttpException`, so the generic branch would otherwise swallow it.
|
|
110
23
|
*
|
|
111
24
|
* @example
|
|
112
25
|
* ```typescript
|
package/dist/lib/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../lib/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../lib/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,gBAAgB,GAGjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,YAAY,EAAiB,MAAM,KAAK,CAAC;AAElD;;;;;;;;GAQG;AACH,OAAO,EAAE,aAAa,EAA0B,MAAM,wBAAwB,CAAC;AAE/E;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,eAAgB,SAAQ,aAAa;IAChC,CAAC,gBAAgB,CAAC,GAAG,IAAa,CAAC;IAEnD,qFAAqF;IACrE,MAAM,CAAS;IA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;QACtC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF"}
|
|
@@ -86,9 +86,10 @@ export interface CorsOptions {
|
|
|
86
86
|
*
|
|
87
87
|
* **CORS Flow:**
|
|
88
88
|
* 1. Check if request has Origin header (if not, skip CORS)
|
|
89
|
-
* 2.
|
|
90
|
-
* 3.
|
|
91
|
-
* 4.
|
|
89
|
+
* 2. Advertise that the response varies by Origin (unless the config is the literal '*')
|
|
90
|
+
* 3. Validate origin - when it is not allowed, emit no CORS headers and carry on
|
|
91
|
+
* 4. Handle preflight OPTIONS request → return 204 immediately
|
|
92
|
+
* 5. For other requests → set CORS headers and call next()
|
|
92
93
|
*/
|
|
93
94
|
export declare class CorsMiddleware extends MiddlewareService {
|
|
94
95
|
private readonly origin;
|
|
@@ -123,15 +124,30 @@ export declare class CorsMiddleware extends MiddlewareService {
|
|
|
123
124
|
*
|
|
124
125
|
* Execution flow:
|
|
125
126
|
* 1. Check if Origin header present (if not, skip CORS)
|
|
126
|
-
* 2.
|
|
127
|
-
* 3.
|
|
128
|
-
* 4.
|
|
127
|
+
* 2. Advertise that the response varies by Origin (unless the config is the literal '*')
|
|
128
|
+
* 3. Validate origin - when it is not allowed, emit no CORS headers and carry on
|
|
129
|
+
* 4. Handle preflight OPTIONS → return 204 No Content
|
|
130
|
+
* 5. Set CORS headers for actual request → call next()
|
|
131
|
+
*
|
|
132
|
+
* A disallowed origin is *not* answered with 403. CORS is a policy the browser enforces on
|
|
133
|
+
* behalf of the user, not an access-control decision the server makes: the correct denial is a
|
|
134
|
+
* normal response with no `Access-Control-Allow-Origin`, which the browser then refuses to
|
|
135
|
+
* expose. Rejecting outright also turned away every non-browser caller that happens to send an
|
|
136
|
+
* Origin header - server-to-server clients, proxies, webviews - and forced applications to
|
|
137
|
+
* register this middleware conditionally when CORS was already terminated at the ingress.
|
|
129
138
|
*
|
|
130
139
|
* @param context - Ergenecore context wrapper
|
|
131
140
|
* @param next - Function to call next middleware or handler
|
|
132
141
|
* @returns Response for preflight, or result of next() for actual requests
|
|
133
142
|
*/
|
|
134
143
|
handle(context: Context, next: () => Promise<void>): Promise<any>;
|
|
144
|
+
/**
|
|
145
|
+
* Adds `Origin` to the response's `Vary` header, keeping whatever is already listed.
|
|
146
|
+
*
|
|
147
|
+
* Unlike the Hono adapter, `setResponseHeader` here writes into a Map and therefore overwrites.
|
|
148
|
+
* A plain set would drop an upstream `Vary: Accept-Encoding`, which is a caching bug of its own.
|
|
149
|
+
*/
|
|
150
|
+
private appendVaryOrigin;
|
|
135
151
|
/**
|
|
136
152
|
* Determines the allowed origin value for the response
|
|
137
153
|
*
|
|
@@ -41,9 +41,10 @@ import { MiddlewareService } from '../defaults';
|
|
|
41
41
|
*
|
|
42
42
|
* **CORS Flow:**
|
|
43
43
|
* 1. Check if request has Origin header (if not, skip CORS)
|
|
44
|
-
* 2.
|
|
45
|
-
* 3.
|
|
46
|
-
* 4.
|
|
44
|
+
* 2. Advertise that the response varies by Origin (unless the config is the literal '*')
|
|
45
|
+
* 3. Validate origin - when it is not allowed, emit no CORS headers and carry on
|
|
46
|
+
* 4. Handle preflight OPTIONS request → return 204 immediately
|
|
47
|
+
* 5. For other requests → set CORS headers and call next()
|
|
47
48
|
*/
|
|
48
49
|
export class CorsMiddleware extends MiddlewareService {
|
|
49
50
|
origin;
|
|
@@ -87,9 +88,17 @@ export class CorsMiddleware extends MiddlewareService {
|
|
|
87
88
|
*
|
|
88
89
|
* Execution flow:
|
|
89
90
|
* 1. Check if Origin header present (if not, skip CORS)
|
|
90
|
-
* 2.
|
|
91
|
-
* 3.
|
|
92
|
-
* 4.
|
|
91
|
+
* 2. Advertise that the response varies by Origin (unless the config is the literal '*')
|
|
92
|
+
* 3. Validate origin - when it is not allowed, emit no CORS headers and carry on
|
|
93
|
+
* 4. Handle preflight OPTIONS → return 204 No Content
|
|
94
|
+
* 5. Set CORS headers for actual request → call next()
|
|
95
|
+
*
|
|
96
|
+
* A disallowed origin is *not* answered with 403. CORS is a policy the browser enforces on
|
|
97
|
+
* behalf of the user, not an access-control decision the server makes: the correct denial is a
|
|
98
|
+
* normal response with no `Access-Control-Allow-Origin`, which the browser then refuses to
|
|
99
|
+
* expose. Rejecting outright also turned away every non-browser caller that happens to send an
|
|
100
|
+
* Origin header - server-to-server clients, proxies, webviews - and forced applications to
|
|
101
|
+
* register this middleware conditionally when CORS was already terminated at the ingress.
|
|
93
102
|
*
|
|
94
103
|
* @param context - Ergenecore context wrapper
|
|
95
104
|
* @param next - Function to call next middleware or handler
|
|
@@ -101,38 +110,58 @@ export class CorsMiddleware extends MiddlewareService {
|
|
|
101
110
|
if (!origin) {
|
|
102
111
|
return await next();
|
|
103
112
|
}
|
|
104
|
-
// Validate origin
|
|
105
113
|
const allowedOrigin = this.getAllowedOrigin(origin);
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
// Set CORS headers using context.setResponseHeader (lazy initialization)
|
|
111
|
-
context.setResponseHeader('Access-Control-Allow-Origin', allowedOrigin);
|
|
112
|
-
if (this.credentials) {
|
|
113
|
-
context.setResponseHeader('Access-Control-Allow-Credentials', 'true');
|
|
114
|
+
// Any config but the literal '*' makes the response depend on the request's Origin, so a
|
|
115
|
+
// shared cache must key on it or it hands one origin's response to another. Refusals too.
|
|
116
|
+
if (this.origin !== '*') {
|
|
117
|
+
this.appendVaryOrigin(context);
|
|
114
118
|
}
|
|
115
|
-
if (
|
|
116
|
-
context.setResponseHeader('Access-Control-
|
|
119
|
+
if (allowedOrigin) {
|
|
120
|
+
context.setResponseHeader('Access-Control-Allow-Origin', allowedOrigin);
|
|
121
|
+
if (this.credentials) {
|
|
122
|
+
context.setResponseHeader('Access-Control-Allow-Credentials', 'true');
|
|
123
|
+
}
|
|
124
|
+
if (this.exposedHeaders) {
|
|
125
|
+
context.setResponseHeader('Access-Control-Expose-Headers', this.exposedHeaders);
|
|
126
|
+
}
|
|
117
127
|
}
|
|
118
128
|
// Handle preflight OPTIONS request
|
|
119
129
|
if (context.req.method === 'OPTIONS') {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
'Access-Control-Allow-
|
|
123
|
-
'Access-Control-
|
|
124
|
-
'Access-Control-Allow-Headers': this.allowedHeaders,
|
|
125
|
-
'Access-Control-Max-Age': this.maxAge,
|
|
126
|
-
};
|
|
127
|
-
if (this.credentials) {
|
|
128
|
-
headers['Access-Control-Allow-Credentials'] = 'true';
|
|
130
|
+
if (allowedOrigin) {
|
|
131
|
+
context.setResponseHeader('Access-Control-Allow-Methods', this.methods);
|
|
132
|
+
context.setResponseHeader('Access-Control-Allow-Headers', this.allowedHeaders);
|
|
133
|
+
context.setResponseHeader('Access-Control-Max-Age', this.maxAge);
|
|
129
134
|
}
|
|
130
|
-
//
|
|
135
|
+
// Accumulated headers, not a fresh object, so what an earlier middleware set survives the 204.
|
|
136
|
+
const headers = {};
|
|
137
|
+
context.res.headers.forEach((value, key) => {
|
|
138
|
+
headers[key] = value;
|
|
139
|
+
});
|
|
131
140
|
return new Response(null, { status: 204, headers });
|
|
132
141
|
}
|
|
133
142
|
// For actual requests, continue to handler
|
|
134
143
|
return await next();
|
|
135
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Adds `Origin` to the response's `Vary` header, keeping whatever is already listed.
|
|
147
|
+
*
|
|
148
|
+
* Unlike the Hono adapter, `setResponseHeader` here writes into a Map and therefore overwrites.
|
|
149
|
+
* A plain set would drop an upstream `Vary: Accept-Encoding`, which is a caching bug of its own.
|
|
150
|
+
*/
|
|
151
|
+
appendVaryOrigin(context) {
|
|
152
|
+
const existing = context.res.headers.get('Vary');
|
|
153
|
+
if (!existing) {
|
|
154
|
+
context.setResponseHeader('Vary', 'Origin');
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const alreadyListed = existing
|
|
158
|
+
.split(',')
|
|
159
|
+
.map((value) => value.trim().toLowerCase())
|
|
160
|
+
.includes('origin');
|
|
161
|
+
if (!alreadyListed) {
|
|
162
|
+
context.setResponseHeader('Vary', `${existing}, Origin`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
136
165
|
/**
|
|
137
166
|
* Determines the allowed origin value for the response
|
|
138
167
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CorsMiddleware.js","sourceRoot":"","sources":["../../../lib/middlewares/CorsMiddleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAoDhD
|
|
1
|
+
{"version":3,"file":"CorsMiddleware.js","sourceRoot":"","sources":["../../../lib/middlewares/CorsMiddleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAoDhD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAO,cAAe,SAAQ,iBAAiB;IAClC,MAAM,CAAiD;IAEvD,OAAO,CAAS;IAEhB,cAAc,CAAS;IAEvB,cAAc,CAAS;IAEvB,WAAW,CAAU;IAErB,MAAM,CAAS;IAEhC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,YAAmB,UAAuB,EAAE;QAC1C,KAAK,EAAE,CAAC;QAER,iEAAiE;QACjE,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,GAAG,CAAC;QACpC,IAAI,CAAC,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpG,IAAI,CAAC,cAAc,GAAG,CAAC,OAAO,CAAC,cAAc,IAAI,CAAC,cAAc,EAAE,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/F,IAAI,CAAC,cAAc,GAA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UG;IACK,gBAAgB,CAAC,aAAqB;QAC5C,+BAA+B;QAC/B,IAAI,IAAI,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YACxB,OAAO,GAAG,CAAC;QACb,CAAC;QAED,4BAA4B;QAC5B,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YAC/B,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC;QACpE,CAAC;QAED,4BAA4B;QAC5B,IAAI,OAAO,IAAI,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;YACtC,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC;QAC3D,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -295,9 +295,18 @@ export declare class RateLimiterMiddleware extends MiddlewareService {
|
|
|
295
295
|
*/
|
|
296
296
|
handle(context: Context, next: () => Promise<void>): Promise<any>;
|
|
297
297
|
/**
|
|
298
|
-
* Cleanup resources (stop cleanup timer)
|
|
298
|
+
* Cleanup resources (stop cleanup timer, drop every bucket)
|
|
299
299
|
*
|
|
300
|
-
*
|
|
300
|
+
* Wired to `@OnStop`, so `server.stop()` releases it without the application having to
|
|
301
|
+
* remember. The timer is `unref()`'d and will not hold the process open, but nothing about
|
|
302
|
+
* unref makes it *stop*: across an in-process restart - the twenty stop/start cycles a test
|
|
303
|
+
* suite performs, a watch-mode reload - each generation of the middleware left behind a live
|
|
304
|
+
* interval and a bucket Map still holding one entry per client that ever called.
|
|
305
|
+
*
|
|
306
|
+
* Inherited by subclasses: the hook is collected across the prototype chain, so a
|
|
307
|
+
* `class ApiRateLimiter extends RateLimiterMiddleware` is released without redeclaring it.
|
|
308
|
+
*
|
|
309
|
+
* Idempotent - the handle is dropped, so a second stop() finds nothing to clear.
|
|
301
310
|
*/
|
|
302
311
|
destroy(): void;
|
|
303
312
|
/**
|
|
@@ -46,7 +46,17 @@
|
|
|
46
46
|
* public login() { ... }
|
|
47
47
|
* ```
|
|
48
48
|
*/
|
|
49
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
50
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
51
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
52
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
53
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
54
|
+
};
|
|
55
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
56
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
57
|
+
};
|
|
49
58
|
import { MiddlewareService } from '../defaults';
|
|
59
|
+
import { OnStop } from '@asenajs/asena/decorators/ioc';
|
|
50
60
|
/**
|
|
51
61
|
* Rate Limiter Middleware
|
|
52
62
|
*
|
|
@@ -238,14 +248,25 @@ export class RateLimiterMiddleware extends MiddlewareService {
|
|
|
238
248
|
return await next();
|
|
239
249
|
}
|
|
240
250
|
/**
|
|
241
|
-
* Cleanup resources (stop cleanup timer)
|
|
251
|
+
* Cleanup resources (stop cleanup timer, drop every bucket)
|
|
242
252
|
*
|
|
243
|
-
*
|
|
253
|
+
* Wired to `@OnStop`, so `server.stop()` releases it without the application having to
|
|
254
|
+
* remember. The timer is `unref()`'d and will not hold the process open, but nothing about
|
|
255
|
+
* unref makes it *stop*: across an in-process restart - the twenty stop/start cycles a test
|
|
256
|
+
* suite performs, a watch-mode reload - each generation of the middleware left behind a live
|
|
257
|
+
* interval and a bucket Map still holding one entry per client that ever called.
|
|
258
|
+
*
|
|
259
|
+
* Inherited by subclasses: the hook is collected across the prototype chain, so a
|
|
260
|
+
* `class ApiRateLimiter extends RateLimiterMiddleware` is released without redeclaring it.
|
|
261
|
+
*
|
|
262
|
+
* Idempotent - the handle is dropped, so a second stop() finds nothing to clear.
|
|
244
263
|
*/
|
|
245
264
|
destroy() {
|
|
246
265
|
if (this.cleanupTimer) {
|
|
247
266
|
clearInterval(this.cleanupTimer);
|
|
267
|
+
this.cleanupTimer = undefined;
|
|
248
268
|
}
|
|
269
|
+
this.buckets.clear();
|
|
249
270
|
}
|
|
250
271
|
/**
|
|
251
272
|
* Get current bucket state for a client (for testing/debugging)
|
|
@@ -300,4 +321,10 @@ export class RateLimiterMiddleware extends MiddlewareService {
|
|
|
300
321
|
this.cleanupTimer.unref();
|
|
301
322
|
}
|
|
302
323
|
}
|
|
324
|
+
__decorate([
|
|
325
|
+
OnStop(),
|
|
326
|
+
__metadata("design:type", Function),
|
|
327
|
+
__metadata("design:paramtypes", []),
|
|
328
|
+
__metadata("design:returntype", void 0)
|
|
329
|
+
], RateLimiterMiddleware.prototype, "destroy", null);
|
|
303
330
|
//# sourceMappingURL=RateLimiterMiddleware.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RateLimiterMiddleware.js","sourceRoot":"","sources":["../../../lib/middlewares/RateLimiterMiddleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG
|
|
1
|
+
{"version":3,"file":"RateLimiterMiddleware.js","sourceRoot":"","sources":["../../../lib/middlewares/RateLimiterMiddleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;;;;;;;;;;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAoIvD;;;;;;;;;;;;;;;;;;;;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