@stratum-hq/hono 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/dist/middleware.js +1 -1
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# @stratum-hq/hono
|
|
2
2
|
|
|
3
|
-
[Hono](https://hono.dev) middleware for [Stratum](https://github.com/stratum-hq/Stratum)
|
|
3
|
+
[Hono](https://hono.dev) middleware for [Stratum](https://github.com/stratum-hq/Stratum). It extracts tenant identity from a request and sets up AsyncLocalStorage context for downstream handlers.
|
|
4
|
+
|
|
5
|
+
Read the documentation at [docs.stratum-hq.org/packages/hono](https://docs.stratum-hq.org/packages/hono/).
|
|
4
6
|
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
@@ -69,13 +71,13 @@ app.use("*", stratumMiddleware({ header: "x-tenant-id", trustTenantHeader: true
|
|
|
69
71
|
| `trustTenantHeader` | Allow header mode. Without it, and without `jwtClaim` or `pathParam`, `stratumMiddleware` throws at construction (default: `false`) |
|
|
70
72
|
| `resolve` | Optional callback `(tenantId) => TenantContext` to populate ancestry, config, and permissions |
|
|
71
73
|
|
|
72
|
-
If no tenant ID is found, the middleware responds with `400 { error: "Missing tenant ID" }`. If `resolve` rejects with a tenant error from `@stratum-hq/core`, for example from `StratumClient.resolveTenant`, the middleware responds with 404 `TENANT_NOT_FOUND`, 403 `TENANT_SUSPENDED`, 410 `TENANT_ARCHIVED`, or 403 `FORBIDDEN`. A control plane timeout gets 504 `CONTROL_PLANE_TIMEOUT`. An `UnauthorizedError` for the SDK's own API key gets 500 `CONTROL_PLANE_AUTH_FAILED` and a `console.error` line. Other errors go to the Hono error handler. Without a `resolve` callback the context is a placeholder (empty config/permissions)
|
|
74
|
+
If no tenant ID is found, the middleware responds with `400 { error: "Missing tenant ID" }`. If `resolve` rejects with a tenant error from `@stratum-hq/core`, for example from `StratumClient.resolveTenant`, the middleware responds with 404 `TENANT_NOT_FOUND`, 403 `TENANT_SUSPENDED`, 410 `TENANT_ARCHIVED`, or 403 `FORBIDDEN`. A control plane timeout gets 504 `CONTROL_PLANE_TIMEOUT`. An `UnauthorizedError` for the SDK's own API key gets 500 `CONTROL_PLANE_AUTH_FAILED` and a `console.error` line. Other errors go to the Hono error handler. Without a `resolve` callback the context is a placeholder (empty config/permissions); provide `resolve` for real tenant data.
|
|
73
75
|
|
|
74
76
|
## Features
|
|
75
77
|
|
|
76
78
|
- Tenant extraction from a verified JWT claim, a path parameter, or a trusted-gateway header
|
|
77
79
|
- Binds tenant context via `runWithTenantContext` so downstream handlers can call `getTenantContext()`
|
|
78
|
-
- Lightweight
|
|
80
|
+
- Lightweight: structural types only, no heavy dependencies
|
|
79
81
|
|
|
80
82
|
## Links
|
|
81
83
|
|
package/dist/middleware.js
CHANGED
|
@@ -49,7 +49,7 @@ export function stratumMiddleware(options = {}) {
|
|
|
49
49
|
ctx = options.resolve
|
|
50
50
|
? await options.resolve(tenantId)
|
|
51
51
|
: /**
|
|
52
|
-
* @warning Placeholder context
|
|
52
|
+
* @warning Placeholder context: ancestry_path, resolved_config, and
|
|
53
53
|
* resolved_permissions are stub values. Provide a `resolve` callback
|
|
54
54
|
* to populate real tenant data.
|
|
55
55
|
*/
|
package/package.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stratum-hq/hono",
|
|
3
|
-
"version": "1.3.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.3.1",
|
|
4
|
+
"description": "Hono multi-tenancy middleware: tenant resolution with AsyncLocalStorage context",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"multi-tenancy",
|
|
7
|
+
"multitenancy",
|
|
7
8
|
"multi-tenant",
|
|
8
9
|
"saas",
|
|
9
10
|
"tenant",
|
|
11
|
+
"tenant-isolation",
|
|
10
12
|
"hono",
|
|
13
|
+
"asynclocalstorage",
|
|
11
14
|
"middleware",
|
|
12
15
|
"typescript",
|
|
13
16
|
"stratum"
|
|
@@ -51,7 +54,7 @@
|
|
|
51
54
|
},
|
|
52
55
|
"license": "MIT",
|
|
53
56
|
"author": "Christian Crank",
|
|
54
|
-
"homepage": "https://
|
|
57
|
+
"homepage": "https://docs.stratum-hq.org/packages/hono/",
|
|
55
58
|
"bugs": "https://github.com/stratum-hq/Stratum/issues",
|
|
56
59
|
"engines": {
|
|
57
60
|
"node": ">=20.0.0"
|