@stonyx/rest-server 0.2.1-alpha.17 → 0.2.1-alpha.19
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/config/environment.js +17 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +7 -15
- package/dist/main.js.map +1 -1
- package/dist/request.d.ts.map +1 -1
- package/dist/request.js +5 -6
- package/dist/request.js.map +1 -1
- package/dist/route-matching.d.ts +35 -0
- package/dist/route-matching.d.ts.map +1 -0
- package/dist/route-matching.js +38 -0
- package/dist/route-matching.js.map +1 -0
- package/package.json +1 -1
package/config/environment.js
CHANGED
|
@@ -13,6 +13,23 @@ const config = {
|
|
|
13
13
|
// URL-based authorization cannot be walked past by changing case
|
|
14
14
|
// (abofs/stonyx-rest-server#47). Opt out with REST_CASE_SENSITIVE_ROUTES=false
|
|
15
15
|
// only as a temporary remediation for a client that relies on loose casing.
|
|
16
|
+
//
|
|
17
|
+
// DELIBERATELY NOT PINNED in test/config/environment.ts -- do not "fix" this
|
|
18
|
+
// as part of abofs/stonyx-rest-server#43. This line is the only thing the
|
|
19
|
+
// suite still checks about the SHIPPED default. Inverting it to
|
|
20
|
+
// `=== 'true'` turns AC3, AC4 and AC5 red; AC6 stays GREEN, because AC6
|
|
21
|
+
// stubs `caseSensitiveRoutes` to `undefined` and src/route-matching.ts reads
|
|
22
|
+
// `!== false`, so AC6 guards the source's read and not this default.
|
|
23
|
+
// Measured: pin `caseSensitiveRoutes: true` in test/config/environment.ts AND
|
|
24
|
+
// invert this line, and the suite reports 28 pass / 0 fail. A naive pin makes
|
|
25
|
+
// an insecure published default completely invisible to a green suite --
|
|
26
|
+
// quieter and weaker, which is the outcome pinning was supposed to prevent.
|
|
27
|
+
//
|
|
28
|
+
// The cost of leaving it unpinned is that the suite is ambient-sensitive here
|
|
29
|
+
// (`REST_CASE_SENSITIVE_ROUTES=false pnpm test` => 25 pass / 3 fail), but it
|
|
30
|
+
// fails LOUDLY, so there is no false green. Closing #43 for this key needs
|
|
31
|
+
// the subprocess-based env isolation this repo does not yet have; any fix
|
|
32
|
+
// must keep a live assertion on this default.
|
|
16
33
|
caseSensitiveRoutes: REST_CASE_SENSITIVE_ROUTES !== 'false',
|
|
17
34
|
enableHealthCheck: REST_HEALTH_CHECK_DISABLE !== 'true',
|
|
18
35
|
origin: REST_CORS_ORIGIN ?? '*',
|
package/dist/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAiBA,OAAgB,EAAE,KAAK,OAAO,EAAoE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAiBA,OAAgB,EAAE,KAAK,OAAO,EAAoE,MAAM,SAAS,CAAC;AAKlH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC;AAElD,MAAM,CAAC,OAAO,OAAO,UAAU;IAC7B,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC;IAE5B,GAAG,EAAG,OAAO,CAAC;IACd,MAAM,EAAG,MAAM,CAAC;;IAgBhB,MAAM,CAAC,KAAK,IAAI,IAAI;IAQd,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAerB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAelC,qBAAqB,IAAI,IAAI;IAW7B,UAAU,CAAC,iBAAiB,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI;CAarG"}
|
package/dist/main.js
CHANGED
|
@@ -18,6 +18,7 @@ import express from 'express';
|
|
|
18
18
|
import config from 'stonyx/config';
|
|
19
19
|
import log from 'stonyx/log';
|
|
20
20
|
import { forEachFileImport } from '@stonyx/utils/file';
|
|
21
|
+
import applyRouteMatching from './route-matching.js';
|
|
21
22
|
export { default as Request } from './request.js';
|
|
22
23
|
export default class RestServer {
|
|
23
24
|
static instance;
|
|
@@ -28,21 +29,12 @@ export default class RestServer {
|
|
|
28
29
|
return RestServer.instance;
|
|
29
30
|
RestServer.instance = this;
|
|
30
31
|
this.api = express();
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
// `express({ caseSensitive: true })` is a no-op; the app setting is the
|
|
38
|
-
// only mechanism that works.
|
|
39
|
-
//
|
|
40
|
-
// This closes the mount segment (/PUBLIC/... ). It does NOT propagate to
|
|
41
|
-
// the sub-apps: settings are inherited on mount, but mountRoute() calls
|
|
42
|
-
// registerCalls() before api.use(), so each child router is already built.
|
|
43
|
-
// The matching set in Request's constructor is what closes sub-paths.
|
|
44
|
-
if (config.restServer?.caseSensitiveRoutes !== false)
|
|
45
|
-
this.api.set('case sensitive routing', true);
|
|
32
|
+
// Closes the mount segment (/PUBLIC/...) for abofs/stonyx-rest-server#47.
|
|
33
|
+
// Must stay in the constructor: the router is materialised lazily on first
|
|
34
|
+
// route registration, so applying this after setupRouter() is silently
|
|
35
|
+
// ineffective. The matching call in Request's constructor is what closes
|
|
36
|
+
// sub-paths -- see src/route-matching.ts for why both are required.
|
|
37
|
+
applyRouteMatching(this.api);
|
|
46
38
|
}
|
|
47
39
|
static close() {
|
|
48
40
|
if (!RestServer.instance)
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAA2F,MAAM,SAAS,CAAC;AAClH,OAAO,MAAM,MAAM,eAAe,CAAC;AAC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,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC,UAAU,CAAC;QAE1D,IAAI,UAAU;YAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;QAElD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;YACX,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;YACzB,OAAO,CAAC,IAAI,EAAE;SACf,CAAC,CAAC;IACL,CAAC;IAED,UAAU,CAAC,iBAA0B,EAAE,EAAE,IAAI,EAAE,OAAO,EAAuC;QAC3F,MAAM,UAAU,GAAG,iBAAmG,CAAC;QACvH,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;QACrB,MAAM,aAAa,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC;QAC9C,MAAM,KAAK,GAAG,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;QAClD,MAAM,EAAE,eAAe,EAAE,GAAG,aAAa,CAAC;QAE1C,aAAa,CAAC,aAAa,EAAE,CAAC;QAC9B,eAAe,CAAC,SAAS,GAAG,KAAK,CAAC;QAElC,qCAAqC;QACrC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;IAClC,CAAC;CACF"}
|
package/dist/request.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,KAAK,OAAO,IAAI,cAAc,EAAE,KAAK,QAAQ,IAAI,eAAe,EAAE,KAAK,OAAO,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,KAAK,OAAO,IAAI,cAAc,EAAE,KAAK,QAAQ,IAAI,eAAe,EAAE,KAAK,OAAO,EAAE,MAAM,SAAS,CAAC;AAOlH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACnD,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,YAAY,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AACtG,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,YAAY,KAAK,MAAM,GAAG,SAAS,CAAC;AAC3F,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,EAAE,CAAC,CAAC,CAAC;AAE9F,MAAM,CAAC,OAAO,OAAO,OAAO;IAC1B,MAAM,CAAC,SAAS,SAAmB;IAEnC,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,cAAc,GAAG,YAAY;IASlD,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAWrE,eAAe,EAAE,OAAO,CAAC;IACzB,QAAQ,EAAG,aAAa,CAAC;IACjB,IAAI,CAAC,EAAE,WAAW,CAAC;;IAe3B,aAAa,IAAI,IAAI;CAqDtB"}
|
package/dist/request.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
import config from 'stonyx/config';
|
|
3
3
|
import { makeArray } from '@stonyx/utils/object';
|
|
4
|
+
import applyRouteMatching from './route-matching.js';
|
|
4
5
|
const METHODS = new Set(['get', 'post', 'put', 'delete', 'patch']);
|
|
5
6
|
export default class Request {
|
|
6
7
|
static stateProp = '__stonyxState';
|
|
@@ -27,13 +28,11 @@ export default class Request {
|
|
|
27
28
|
constructor() {
|
|
28
29
|
const api = express();
|
|
29
30
|
api.disable('x-powered-by');
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
// must stay in the constructor: registerCalls() materialises this router,
|
|
31
|
+
// Closes sub-paths (/public/SUCCESS) for abofs/stonyx-rest-server#47.
|
|
32
|
+
// Must stay in the constructor: registerCalls() materialises this router,
|
|
33
33
|
// and a set applied afterwards has no effect. The parent app's setting
|
|
34
|
-
// does not reach here -- see
|
|
35
|
-
|
|
36
|
-
api.set('case sensitive routing', true);
|
|
34
|
+
// does not reach here -- see src/route-matching.ts.
|
|
35
|
+
applyRouteMatching(api);
|
|
37
36
|
this.expressInstance = api;
|
|
38
37
|
}
|
|
39
38
|
registerCalls() {
|
package/dist/request.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAAA,OAAO,OAA2F,MAAM,SAAS,CAAC;AAClH,OAAO,MAAM,MAAM,eAAe,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAAA,OAAO,OAA2F,MAAM,SAAS,CAAC;AAClH,OAAO,MAAM,MAAM,eAAe,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,kBAAkB,MAAM,qBAAqB,CAAC;AAErD,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;AAOnE,MAAM,CAAC,OAAO,OAAO,OAAO;IAC1B,MAAM,CAAC,SAAS,GAAG,eAAe,CAAC;IAEnC,MAAM,CAAC,QAAQ,CAAC,GAAmB;QACjC,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;QAC9B,MAAM,MAAM,GAAG,GAAyC,CAAC;QACzD,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,SAAS;YAAE,OAAO,MAAM,CAAC,SAAS,CAAiB,C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AAkB,CAAC,CAAC;oBAEtD,2CAA2C;oBAC3C,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;oBACvB,IAAI,IAAI,EAAE,CAAC;wBACT,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAA0F,CAAC;wBAEvH,IAAI,OAAO;4BAAE,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;gCAAE,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;wBACrF,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;oBAC1B,CAAC;oBAED,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;wBAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;wBAAC,OAAO;oBAAC,CAAC;oBAC5D,IAAI,OAAO,QAAQ,KAAK,QAAQ;wBAAE,OAAO,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;oBAEtE,GAAG,CAAC,IAAI,CAAC,QAAmC,CAAC,CAAC;gBAChD,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Express } from 'express';
|
|
2
|
+
/**
|
|
3
|
+
* Applies this module's route-matching settings to an express app.
|
|
4
|
+
*
|
|
5
|
+
* Called from BOTH express construction sites (abofs/stonyx-rest-server#47):
|
|
6
|
+
* `RestServer`'s constructor closes the mount segment (`/PUBLIC/...`), and
|
|
7
|
+
* `Request`'s constructor closes sub-paths (`/public/SUCCESS`). Neither alone
|
|
8
|
+
* is sufficient -- settings are inherited on mount, but `mountRoute()` calls
|
|
9
|
+
* `registerCalls()` before `api.use()`, so each child router is already built
|
|
10
|
+
* by the time the parent's setting could reach it.
|
|
11
|
+
*
|
|
12
|
+
* Both callers invoke this from a constructor, and must keep doing so: express
|
|
13
|
+
* materialises a router lazily on first route registration, and a setting
|
|
14
|
+
* applied afterwards is silently ineffective -- no throw, no warning.
|
|
15
|
+
*
|
|
16
|
+
* The guard is `!== false`, not a plain truthy check, and that polarity is
|
|
17
|
+
* load-bearing. `trustProxy` and `enableHealthCheck` default to the falsy
|
|
18
|
+
* direction, so a missing key fails safe for them. This flag defaults to the
|
|
19
|
+
* truthy direction, so `if (config.restServer?.caseSensitiveRoutes)` would
|
|
20
|
+
* silently fail OPEN for a consumer whose shipped config predates the key.
|
|
21
|
+
*
|
|
22
|
+
* It lives here, in one place, rather than being written out at each call
|
|
23
|
+
* site, so that a single test can anchor it. The invariant is duplicated the
|
|
24
|
+
* moment the expression is: `test/unit/request-test.ts` AC6 reaches this
|
|
25
|
+
* function through `Request`, which means the same assertion now also covers
|
|
26
|
+
* the `RestServer` half. Two copies of the predicate left the parent's copy
|
|
27
|
+
* free to drift -- inverting it, or dropping the condition entirely, kept the
|
|
28
|
+
* suite green.
|
|
29
|
+
*
|
|
30
|
+
* Note `express({ caseSensitive: true })` does NOT work: express 5's
|
|
31
|
+
* `createApplication()` takes zero arguments and forwards nothing. The app
|
|
32
|
+
* setting is the only mechanism.
|
|
33
|
+
*/
|
|
34
|
+
export default function applyRouteMatching(api: Express): void;
|
|
35
|
+
//# sourceMappingURL=route-matching.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-matching.d.ts","sourceRoot":"","sources":["../src/route-matching.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAE7D"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import config from 'stonyx/config';
|
|
2
|
+
/**
|
|
3
|
+
* Applies this module's route-matching settings to an express app.
|
|
4
|
+
*
|
|
5
|
+
* Called from BOTH express construction sites (abofs/stonyx-rest-server#47):
|
|
6
|
+
* `RestServer`'s constructor closes the mount segment (`/PUBLIC/...`), and
|
|
7
|
+
* `Request`'s constructor closes sub-paths (`/public/SUCCESS`). Neither alone
|
|
8
|
+
* is sufficient -- settings are inherited on mount, but `mountRoute()` calls
|
|
9
|
+
* `registerCalls()` before `api.use()`, so each child router is already built
|
|
10
|
+
* by the time the parent's setting could reach it.
|
|
11
|
+
*
|
|
12
|
+
* Both callers invoke this from a constructor, and must keep doing so: express
|
|
13
|
+
* materialises a router lazily on first route registration, and a setting
|
|
14
|
+
* applied afterwards is silently ineffective -- no throw, no warning.
|
|
15
|
+
*
|
|
16
|
+
* The guard is `!== false`, not a plain truthy check, and that polarity is
|
|
17
|
+
* load-bearing. `trustProxy` and `enableHealthCheck` default to the falsy
|
|
18
|
+
* direction, so a missing key fails safe for them. This flag defaults to the
|
|
19
|
+
* truthy direction, so `if (config.restServer?.caseSensitiveRoutes)` would
|
|
20
|
+
* silently fail OPEN for a consumer whose shipped config predates the key.
|
|
21
|
+
*
|
|
22
|
+
* It lives here, in one place, rather than being written out at each call
|
|
23
|
+
* site, so that a single test can anchor it. The invariant is duplicated the
|
|
24
|
+
* moment the expression is: `test/unit/request-test.ts` AC6 reaches this
|
|
25
|
+
* function through `Request`, which means the same assertion now also covers
|
|
26
|
+
* the `RestServer` half. Two copies of the predicate left the parent's copy
|
|
27
|
+
* free to drift -- inverting it, or dropping the condition entirely, kept the
|
|
28
|
+
* suite green.
|
|
29
|
+
*
|
|
30
|
+
* Note `express({ caseSensitive: true })` does NOT work: express 5's
|
|
31
|
+
* `createApplication()` takes zero arguments and forwards nothing. The app
|
|
32
|
+
* setting is the only mechanism.
|
|
33
|
+
*/
|
|
34
|
+
export default function applyRouteMatching(api) {
|
|
35
|
+
if (config.restServer?.caseSensitiveRoutes !== false)
|
|
36
|
+
api.set('case sensitive routing', true);
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=route-matching.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-matching.js","sourceRoot":"","sources":["../src/route-matching.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,eAAe,CAAC;AAEnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,GAAY;IACrD,IAAI,MAAM,CAAC,UAAU,EAAE,mBAAmB,KAAK,KAAK;QAAE,GAAG,CAAC,GAAG,CAAC,wBAAwB,EAAE,IAAI,CAAC,CAAC;AAChG,CAAC"}
|