@stratum-hq/nestjs 1.2.0 → 1.3.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
CHANGED
|
@@ -55,7 +55,7 @@ export class DataController {
|
|
|
55
55
|
## API
|
|
56
56
|
|
|
57
57
|
- **`StratumModule.forRoot(options)` / `forRootAsync(options)`** — register the SDK client for DI. `forRootAsync` supports `useFactory` + `inject` for config that depends on other providers (e.g. `ConfigService`).
|
|
58
|
-
- **`StratumGuard`** — resolves the tenant from a verified JWT claim, then the `X-Tenant-ID` header, then custom `resolvers`. When `jwtSecret` or `jwtVerify` is set, the guard reads the header only with `trustTenantHeader: true`, and it rejects a Bearer token that fails verification with 401. Sets `req.tenant` (full `TenantContext`), plus `req.impersonating` / `req.originalTenantId` when impersonation is enabled. Throws `UnauthorizedException` (401) if the request has no tenant ID, `NotFoundException` (404) if the tenant does not exist, `ForbiddenException` (403) if the tenant is suspended or access is denied, and `GoneException` (410) if the tenant is archived. A control plane timeout throws `GatewayTimeoutException` (504). A rejected SDK API key throws `InternalServerErrorException` (500) and writes the cause to `console.error`.
|
|
58
|
+
- **`StratumGuard`** — resolves the tenant from a verified JWT claim, then the `X-Tenant-ID` header, then custom `resolvers`. When `jwtSecret` or `jwtVerify` is set, the guard reads the header only with `trustTenantHeader: true`, and it rejects a Bearer token that fails verification with 401. Set `jwtAudience` / `jwtIssuer` to also reject tokens whose `aud` / `iss` claim does not match. Sets `req.tenant` (full `TenantContext`), plus `req.impersonating` / `req.originalTenantId` when impersonation is enabled. Throws `UnauthorizedException` (401) if the request has no tenant ID, `NotFoundException` (404) if the tenant does not exist, `ForbiddenException` (403) if the tenant is suspended or access is denied, and `GoneException` (410) if the tenant is archived. A control plane timeout throws `GatewayTimeoutException` (504). A rejected SDK API key throws `InternalServerErrorException` (500) and writes the cause to `console.error`.
|
|
59
59
|
- **`@Tenant()`** — parameter decorator that extracts `req.tenant`.
|
|
60
60
|
- **`StratumContextInterceptor`** — binds the resolved context to AsyncLocalStorage so services can call `getTenantContext()` from `@stratum-hq/sdk` without the request object.
|
|
61
61
|
|
package/dist/stratum.module.d.ts
CHANGED
|
@@ -9,6 +9,10 @@ export interface StratumModuleOptions {
|
|
|
9
9
|
jwtSecret?: string;
|
|
10
10
|
/** Custom JWT verify function — takes priority over jwtSecret. */
|
|
11
11
|
jwtVerify?: (token: string) => Record<string, unknown> | null;
|
|
12
|
+
/** When set, a verified token is accepted only if its `aud` claim equals (or, for an array, includes) this value. */
|
|
13
|
+
jwtAudience?: string;
|
|
14
|
+
/** When set, a verified token is accepted only if its `iss` claim equals this value. */
|
|
15
|
+
jwtIssuer?: string;
|
|
12
16
|
/** Header to read the tenant ID from. When set, only this header is read (default: X-Tenant-ID). */
|
|
13
17
|
headerName?: string;
|
|
14
18
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stratum.module.d.ts","sourceRoot":"","sources":["../src/stratum.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,aAAa,EAAU,MAAM,gBAAgB,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAOtE,MAAM,WAAW,oBAAoB;IACnC,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,uHAAuH;IACvH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iFAAiF;IACjF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kEAAkE;IAClE,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC9D,oGAAoG;IACpG,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,yEAAyE;IACzE,SAAS,CAAC,EAAE,OAAO,iBAAiB,EAAE,cAAc,EAAE,C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description": "Stratum NestJS integration — StratumGuard, @Tenant() decorator, and StratumModule",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"multi-tenancy",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@nestjs/common": ">=10.0.0",
|
|
45
45
|
"@nestjs/core": ">=10.0.0",
|
|
46
46
|
"@stratum-hq/core": "^1.0.0",
|
|
47
|
-
"@stratum-hq/sdk": "^1.
|
|
47
|
+
"@stratum-hq/sdk": "^1.3.0",
|
|
48
48
|
"reflect-metadata": ">=0.1.13"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|