@rexezuge/http 1.9.4 → 1.10.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 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/dist/testing.d.ts +8 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +1 -0
- package/dist/testing.js.map +7 -0
- package/package.json +21 -6
package/README.md
CHANGED
|
@@ -11,10 +11,16 @@ framework. The pieces in here cannot be framework-free — they are Hono- and
|
|
|
11
11
|
chanfana-shaped — and the zero-dependency rule silently prevented the fix while
|
|
12
12
|
four repos each shipped four copies.
|
|
13
13
|
|
|
14
|
-
So this is the one package that
|
|
14
|
+
So this is the one package that is framework-shaped, deliberately. Nothing in the
|
|
15
15
|
other eight imports it, so a repo that wants the framework-free core can keep
|
|
16
16
|
taking only that.
|
|
17
17
|
|
|
18
|
+
It is shaped for Hono and chanfana, but it does not import either: every entry
|
|
19
|
+
point takes a structural context type (see below). `hono` and `chanfana` are
|
|
20
|
+
therefore **optional peer dependencies** — the app brings its own copy, and this
|
|
21
|
+
package never pins or duplicates it. The only third-party runtime dependency is
|
|
22
|
+
`jose` (Cloudflare Access JWT verification).
|
|
23
|
+
|
|
18
24
|
## What converged here
|
|
19
25
|
|
|
20
26
|
| Module | From |
|
|
@@ -66,6 +72,17 @@ A surface with its own wire envelope (Subsonic, CalDAV) supplies `onThrottled`
|
|
|
66
72
|
and `toResponse`; everything else gets the canonical `{Exception:{Type,Message}}`
|
|
67
73
|
dialect every SPA in the family decodes.
|
|
68
74
|
|
|
75
|
+
## Test seams
|
|
76
|
+
|
|
77
|
+
The limiter's buckets are module-global. Suites reset and inspect them through the
|
|
78
|
+
`/testing` subpath, kept off the production barrel:
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import { getRateLimitBucketCountForTests, resetRateLimitForTests } from '@rexezuge/http/testing';
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The same names on the root barrel are deprecated and removed in 2.0.
|
|
85
|
+
|
|
69
86
|
## Context types are structural
|
|
70
87
|
|
|
71
88
|
Every entry point takes a context _shape_ (`RateLimitContext`, `HeaderContext`,
|
package/dist/index.d.ts
CHANGED
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
* Hono's `Context<…>`, which keeps a `Request`-dispatching surface and a test
|
|
31
31
|
* double usable without a framework import.
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
import { getRateLimitBucketCountForTests as getRateLimitBucketCountForTestsSeam, resetRateLimitForTests as resetRateLimitForTestsSeam } from './testing.ts';
|
|
34
|
+
export { clientIp, MAX_BUCKETS, rateLimit } from './rateLimit.ts';
|
|
34
35
|
export type { RateLimitContext, RateLimitHandler, RateLimitOptions } from './rateLimit.ts';
|
|
35
36
|
export { applySecurityHeaders, securityHeaders, sensitivePaths, CONTENT_SECURITY_POLICY, SECURITY_HEADERS, STRICT_TRANSPORT_SECURITY, } from './securityHeaders.ts';
|
|
36
37
|
export type { HeaderContext } from './securityHeaders.ts';
|
|
@@ -40,4 +41,12 @@ export { errorBody, toErrorResponse, toServiceError, INTERNAL_SERVER_MESSAGE } f
|
|
|
40
41
|
export type { ErrorMapperOptions } from './ErrorMapper.ts';
|
|
41
42
|
export { BaseRoute, createRouteHandler } from './routeBase.ts';
|
|
42
43
|
export type { RouteContext, RouteHandler, RouteHandlerOptions } from './routeBase.ts';
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated Import from '@rexezuge/http/testing'. Removed in 2.0.
|
|
46
|
+
*/
|
|
47
|
+
export declare const resetRateLimitForTests: typeof resetRateLimitForTestsSeam;
|
|
48
|
+
/**
|
|
49
|
+
* @deprecated Import from '@rexezuge/http/testing'. Removed in 2.0.
|
|
50
|
+
*/
|
|
51
|
+
export declare const getRateLimitBucketCountForTests: typeof getRateLimitBucketCountForTestsSeam;
|
|
43
52
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EACL,+BAA+B,IAAI,mCAAmC,EACtE,sBAAsB,IAAI,0BAA0B,EACrD,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAClE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAE3F,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,gBAAgB,EAChB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC5G,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAE3G,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AACvG,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAC/D,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAKtF;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,OAAO,0BAAuD,CAAC;AACpG;;GAEG;AACH,eAAO,MAAM,+BAA+B,EAAE,OAAO,mCAAyE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{getRateLimitBucketCountForTests as e,resetRateLimitForTests as t}from"./testing.js";import{clientIp as R,MAX_BUCKETS as c,rateLimit as m}from"./rateLimit.js";import{applySecurityHeaders as E,securityHeaders as S,sensitivePaths as n,CONTENT_SECURITY_POLICY as p,SECURITY_HEADERS as u,STRICT_TRANSPORT_SECURITY as C}from"./securityHeaders.js";import{AccessAuthError as L,authenticateAccess as _,identityFromBinding as f,verifyAccessJwt as x}from"./accessAuth.js";import{errorBody as F,toErrorResponse as I,toServiceError as d,INTERNAL_SERVER_MESSAGE as y}from"./ErrorMapper.js";import{BaseRoute as g,createRouteHandler as H}from"./routeBase.js";const o=t,s=e;export{L as AccessAuthError,g as BaseRoute,p as CONTENT_SECURITY_POLICY,y as INTERNAL_SERVER_MESSAGE,c as MAX_BUCKETS,u as SECURITY_HEADERS,C as STRICT_TRANSPORT_SECURITY,E as applySecurityHeaders,_ as authenticateAccess,R as clientIp,H as createRouteHandler,F as errorBody,s as getRateLimitBucketCountForTests,f as identityFromBinding,m as rateLimit,o as resetRateLimitForTests,S as securityHeaders,n as sensitivePaths,I as toErrorResponse,d as toServiceError,x as verifyAccessJwt};
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * `@rexezuge/http` — the family's HTTP layer.\n *\n * ## Why this package exists\n *\n * Eight other packages in the kit are framework-free on purpose, and that is\n * what lets a repo adopt `shared` / `errors` / `runtime` without adopting a web\n * framework. The rate limiter, the security headers, the route bases and the\n * Access auth service cannot be framework-free: they are Hono- and\n * chanfana-shaped, and four repos shipped four copies of each while the kit's\n * zero-dependency rule silently prevented the fix.\n *\n * So this is the one package that breaks the rule, deliberately. It is also the\n * only one a repo can choose to skip — nothing in the other eight imports it.\n *\n * ## What converged here\n *\n * | Module | From |\n * | ----------------- | --------------------------------------------------------------------- |\n * | `rateLimit` | Edge-Sonic's — the copy that fixed the per-request sweep, the resolver `max`, and the `Retry-After` header |\n * | `securityHeaders` | Four byte-identical copies, with the `no-store` predicate made a **required** argument |\n * | `accessAuth` | Edge-Sonic's — the copy that replaced a `ctx.access` branch that could never execute |\n * | `ErrorMapper` | Edge-Sonic's — split by surface, not by convenience |\n * | `routeBase` | All three incompatible shapes, with their shared parts converged |\n *\n * ## The null rule\n *\n * `null` means absent, `undefined` means not supplied — see the kit's `AGENTS.md`.\n * The middleware in this package takes *structural* context types rather than\n * Hono's `Context<…>`, which keeps a `Request`-dispatching surface and a test\n * double usable without a framework import.\n */\n\nexport { clientIp,
|
|
5
|
-
"mappings": "AAiCA,OAAS,
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["/**\n * `@rexezuge/http` — the family's HTTP layer.\n *\n * ## Why this package exists\n *\n * Eight other packages in the kit are framework-free on purpose, and that is\n * what lets a repo adopt `shared` / `errors` / `runtime` without adopting a web\n * framework. The rate limiter, the security headers, the route bases and the\n * Access auth service cannot be framework-free: they are Hono- and\n * chanfana-shaped, and four repos shipped four copies of each while the kit's\n * zero-dependency rule silently prevented the fix.\n *\n * So this is the one package that breaks the rule, deliberately. It is also the\n * only one a repo can choose to skip — nothing in the other eight imports it.\n *\n * ## What converged here\n *\n * | Module | From |\n * | ----------------- | --------------------------------------------------------------------- |\n * | `rateLimit` | Edge-Sonic's — the copy that fixed the per-request sweep, the resolver `max`, and the `Retry-After` header |\n * | `securityHeaders` | Four byte-identical copies, with the `no-store` predicate made a **required** argument |\n * | `accessAuth` | Edge-Sonic's — the copy that replaced a `ctx.access` branch that could never execute |\n * | `ErrorMapper` | Edge-Sonic's — split by surface, not by convenience |\n * | `routeBase` | All three incompatible shapes, with their shared parts converged |\n *\n * ## The null rule\n *\n * `null` means absent, `undefined` means not supplied — see the kit's `AGENTS.md`.\n * The middleware in this package takes *structural* context types rather than\n * Hono's `Context<…>`, which keeps a `Request`-dispatching surface and a test\n * double usable without a framework import.\n */\n\nimport {\n getRateLimitBucketCountForTests as getRateLimitBucketCountForTestsSeam,\n resetRateLimitForTests as resetRateLimitForTestsSeam,\n} from './testing.ts';\n\nexport { clientIp, MAX_BUCKETS, rateLimit } from './rateLimit.ts';\nexport type { RateLimitContext, RateLimitHandler, RateLimitOptions } from './rateLimit.ts';\n\nexport {\n applySecurityHeaders,\n securityHeaders,\n sensitivePaths,\n CONTENT_SECURITY_POLICY,\n SECURITY_HEADERS,\n STRICT_TRANSPORT_SECURITY,\n} from './securityHeaders.ts';\nexport type { HeaderContext } from './securityHeaders.ts';\n\nexport { AccessAuthError, authenticateAccess, identityFromBinding, verifyAccessJwt } from './accessAuth.ts';\nexport type { AccessAuthOptions, AccessBinding, AccessIdentity, AccessJwtVerifier } from './accessAuth.ts';\n\nexport { errorBody, toErrorResponse, toServiceError, INTERNAL_SERVER_MESSAGE } from './ErrorMapper.ts';\nexport type { ErrorMapperOptions } from './ErrorMapper.ts';\n\nexport { BaseRoute, createRouteHandler } from './routeBase.ts';\nexport type { RouteContext, RouteHandler, RouteHandlerOptions } from './routeBase.ts';\n\n// Test seams, re-exported from the root barrel only for compatibility. Bound as\n// consts rather than re-export specifiers so the @deprecated tag reaches callers.\n\n/**\n * @deprecated Import from '@rexezuge/http/testing'. Removed in 2.0.\n */\nexport const resetRateLimitForTests: typeof resetRateLimitForTestsSeam = resetRateLimitForTestsSeam;\n/**\n * @deprecated Import from '@rexezuge/http/testing'. Removed in 2.0.\n */\nexport const getRateLimitBucketCountForTests: typeof getRateLimitBucketCountForTestsSeam = getRateLimitBucketCountForTestsSeam;\n"],
|
|
5
|
+
"mappings": "AAiCA,OACE,mCAAmCA,EACnC,0BAA0BC,MACrB,eAEP,OAAS,YAAAC,EAAU,eAAAC,EAAa,aAAAC,MAAiB,iBAGjD,OACE,wBAAAC,EACA,mBAAAC,EACA,kBAAAC,EACA,2BAAAC,EACA,oBAAAC,EACA,6BAAAC,MACK,uBAGP,OAAS,mBAAAC,EAAiB,sBAAAC,EAAoB,uBAAAC,EAAqB,mBAAAC,MAAuB,kBAG1F,OAAS,aAAAC,EAAW,mBAAAC,EAAiB,kBAAAC,EAAgB,2BAAAC,MAA+B,mBAGpF,OAAS,aAAAC,EAAW,sBAAAC,MAA0B,iBASvC,MAAMC,EAA4DpB,EAI5DqB,EAA8EtB",
|
|
6
|
+
"names": ["getRateLimitBucketCountForTestsSeam", "resetRateLimitForTestsSeam", "clientIp", "MAX_BUCKETS", "rateLimit", "applySecurityHeaders", "securityHeaders", "sensitivePaths", "CONTENT_SECURITY_POLICY", "SECURITY_HEADERS", "STRICT_TRANSPORT_SECURITY", "AccessAuthError", "authenticateAccess", "identityFromBinding", "verifyAccessJwt", "errorBody", "toErrorResponse", "toServiceError", "INTERNAL_SERVER_MESSAGE", "BaseRoute", "createRouteHandler", "resetRateLimitForTests", "getRateLimitBucketCountForTests"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@rexezuge/http/testing` — test seams, kept off the production barrel.
|
|
3
|
+
*
|
|
4
|
+
* The limiter state these reach is module-global, so a suite that exercises
|
|
5
|
+
* `rateLimit` resets it between cases. Nothing here belongs in a request path.
|
|
6
|
+
*/
|
|
7
|
+
export { getRateLimitBucketCountForTests, resetRateLimitForTests } from './rateLimit.ts';
|
|
8
|
+
//# sourceMappingURL=testing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,+BAA+B,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/testing.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getRateLimitBucketCountForTests as o,resetRateLimitForTests as r}from"./rateLimit.js";export{o as getRateLimitBucketCountForTests,r as resetRateLimitForTests};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/testing.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * `@rexezuge/http/testing` — test seams, kept off the production barrel.\n *\n * The limiter state these reach is module-global, so a suite that exercises\n * `rateLimit` resets it between cases. Nothing here belongs in a request path.\n */\n\nexport { getRateLimitBucketCountForTests, resetRateLimitForTests } from './rateLimit.ts';\n"],
|
|
5
|
+
"mappings": "AAOA,OAAS,mCAAAA,EAAiC,0BAAAC,MAA8B",
|
|
6
|
+
"names": ["getRateLimitBucketCountForTests", "resetRateLimitForTests"]
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rexezuge/http",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
"types": "./dist/index.d.ts",
|
|
17
17
|
"default": "./dist/index.js"
|
|
18
18
|
},
|
|
19
|
+
"./testing": {
|
|
20
|
+
"types": "./dist/testing.d.ts",
|
|
21
|
+
"default": "./dist/testing.js"
|
|
22
|
+
},
|
|
19
23
|
"./*": {
|
|
20
24
|
"types": "./dist/*.d.ts",
|
|
21
25
|
"default": "./dist/*.js"
|
|
@@ -25,11 +29,21 @@
|
|
|
25
29
|
"dist"
|
|
26
30
|
],
|
|
27
31
|
"dependencies": {
|
|
28
|
-
"chanfana": "^3.4.0",
|
|
29
|
-
"hono": "^4.13.13",
|
|
30
32
|
"jose": "^6.2.12",
|
|
31
|
-
"@rexezuge/errors": "1.
|
|
32
|
-
"@rexezuge/shared": "1.
|
|
33
|
+
"@rexezuge/errors": "1.10.0",
|
|
34
|
+
"@rexezuge/shared": "1.10.0"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"chanfana": "^3.4.0",
|
|
38
|
+
"hono": "^4.13.13"
|
|
39
|
+
},
|
|
40
|
+
"peerDependenciesMeta": {
|
|
41
|
+
"chanfana": {
|
|
42
|
+
"optional": true
|
|
43
|
+
},
|
|
44
|
+
"hono": {
|
|
45
|
+
"optional": true
|
|
46
|
+
}
|
|
33
47
|
},
|
|
34
48
|
"devDependencies": {
|
|
35
49
|
"@types/node": "26.6.4",
|
|
@@ -40,6 +54,7 @@
|
|
|
40
54
|
"scripts": {
|
|
41
55
|
"build": "tsc -p tsconfig.json && node ../../scripts/minify-dist.mjs",
|
|
42
56
|
"typecheck": "tsc -p tsconfig.test.json --noEmit",
|
|
43
|
-
"test": "vitest run"
|
|
57
|
+
"test": "vitest run",
|
|
58
|
+
"test:coverage": "vitest run --coverage"
|
|
44
59
|
}
|
|
45
60
|
}
|