@lenne.tech/nest-server 11.41.2 → 11.41.4
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/.claude/rules/architecture.md +1 -0
- package/.claude/rules/configurable-features.md +1 -0
- package/.claude/rules/role-system.md +15 -1
- package/.claude/rules/testing.md +16 -4
- package/CLAUDE.md +2 -1
- package/FRAMEWORK-API.md +4 -1
- package/dist/core/common/helpers/graceful-shutdown.helper.js.map +1 -1
- package/dist/core/common/helpers/logging.helper.js +2 -0
- package/dist/core/common/helpers/logging.helper.js.map +1 -1
- package/dist/core/common/helpers/process-diagnostics.helper.js.map +1 -1
- package/dist/core/common/interfaces/server-options.interface.d.ts +20 -0
- package/dist/core/modules/ai/helpers/ai-mcp-oauth.helper.d.ts +2 -2
- package/dist/core/modules/ai/helpers/ai-mcp-oauth.helper.js +46 -6
- package/dist/core/modules/ai/helpers/ai-mcp-oauth.helper.js.map +1 -1
- package/dist/core/modules/ai/services/core-ai-mcp-oauth.service.js +7 -1
- package/dist/core/modules/ai/services/core-ai-mcp-oauth.service.js.map +1 -1
- package/dist/core/modules/api-token/core-api-token.constants.d.ts +6 -0
- package/dist/core/modules/api-token/core-api-token.constants.js +11 -0
- package/dist/core/modules/api-token/core-api-token.constants.js.map +1 -0
- package/dist/core/modules/api-token/core-api-token.decorators.d.ts +1 -0
- package/dist/core/modules/api-token/core-api-token.decorators.js +8 -0
- package/dist/core/modules/api-token/core-api-token.decorators.js.map +1 -0
- package/dist/core/modules/api-token/core-api-token.helpers.d.ts +127 -0
- package/dist/core/modules/api-token/core-api-token.helpers.js +398 -0
- package/dist/core/modules/api-token/core-api-token.helpers.js.map +1 -0
- package/dist/core/modules/api-token/core-api-token.middleware.d.ts +10 -0
- package/dist/core/modules/api-token/core-api-token.middleware.js +58 -0
- package/dist/core/modules/api-token/core-api-token.middleware.js.map +1 -0
- package/dist/core/modules/api-token/core-api-token.model.d.ts +20 -0
- package/dist/core/modules/api-token/core-api-token.model.js +199 -0
- package/dist/core/modules/api-token/core-api-token.model.js.map +1 -0
- package/dist/core/modules/api-token/core-api-token.module.d.ts +11 -0
- package/dist/core/modules/api-token/core-api-token.module.js +39 -0
- package/dist/core/modules/api-token/core-api-token.module.js.map +1 -0
- package/dist/core/modules/api-token/core-api-token.registry.d.ts +9 -0
- package/dist/core/modules/api-token/core-api-token.registry.js +17 -0
- package/dist/core/modules/api-token/core-api-token.registry.js.map +1 -0
- package/dist/core/modules/api-token/core-api-token.service.d.ts +104 -0
- package/dist/core/modules/api-token/core-api-token.service.js +550 -0
- package/dist/core/modules/api-token/core-api-token.service.js.map +1 -0
- package/dist/core/modules/auth/guards/roles.guard.js +17 -1
- package/dist/core/modules/auth/guards/roles.guard.js.map +1 -1
- package/dist/core/modules/better-auth/better-auth-roles.guard.js +12 -2
- package/dist/core/modules/better-auth/better-auth-roles.guard.js.map +1 -1
- package/dist/core/modules/better-auth/core-better-auth.middleware.js +4 -0
- package/dist/core/modules/better-auth/core-better-auth.middleware.js.map +1 -1
- package/dist/core/modules/better-auth/core-better-auth.module.d.ts +4 -0
- package/dist/core/modules/better-auth/core-better-auth.module.js +18 -0
- package/dist/core/modules/better-auth/core-better-auth.module.js.map +1 -1
- package/dist/core/modules/tenant/core-tenant-guard.registry.d.ts +2 -0
- package/dist/core/modules/tenant/core-tenant-guard.registry.js +19 -0
- package/dist/core/modules/tenant/core-tenant-guard.registry.js.map +1 -0
- package/dist/core/modules/tenant/core-tenant.guard.d.ts +1 -0
- package/dist/core/modules/tenant/core-tenant.guard.js +28 -12
- package/dist/core/modules/tenant/core-tenant.guard.js.map +1 -1
- package/dist/core/modules/tenant/core-tenant.helpers.d.ts +1 -0
- package/dist/core/modules/tenant/core-tenant.helpers.js +19 -0
- package/dist/core/modules/tenant/core-tenant.helpers.js.map +1 -1
- package/dist/core/modules/tenant/core-tenant.module.d.ts +5 -2
- package/dist/core/modules/tenant/core-tenant.module.js +8 -0
- package/dist/core/modules/tenant/core-tenant.module.js.map +1 -1
- package/dist/core/modules/user/core-user.service.js +7 -0
- package/dist/core/modules/user/core-user.service.js.map +1 -1
- package/dist/core.module.js +6 -0
- package/dist/core.module.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/docs/REQUEST-LIFECYCLE.md +49 -1
- package/docs/security-overrides.md +16 -10
- package/migration-guides/11.41.3-to-11.41.4.md +172 -0
- package/package.json +38 -37
- package/src/core/common/helpers/graceful-shutdown.helper.ts +9 -0
- package/src/core/common/helpers/logging.helper.ts +7 -0
- package/src/core/common/helpers/process-diagnostics.helper.ts +4 -0
- package/src/core/common/interfaces/server-options.interface.ts +110 -0
- package/src/core/modules/ai/INTEGRATION-CHECKLIST.md +17 -10
- package/src/core/modules/ai/README.md +9 -1
- package/src/core/modules/ai/helpers/ai-mcp-oauth.helper.ts +74 -7
- package/src/core/modules/ai/services/core-ai-mcp-oauth.service.ts +13 -1
- package/src/core/modules/api-token/INTEGRATION-CHECKLIST.md +121 -0
- package/src/core/modules/api-token/README.md +212 -0
- package/src/core/modules/api-token/core-api-token.constants.ts +27 -0
- package/src/core/modules/api-token/core-api-token.decorators.ts +29 -0
- package/src/core/modules/api-token/core-api-token.helpers.ts +711 -0
- package/src/core/modules/api-token/core-api-token.middleware.ts +57 -0
- package/src/core/modules/api-token/core-api-token.model.ts +193 -0
- package/src/core/modules/api-token/core-api-token.module.ts +48 -0
- package/src/core/modules/api-token/core-api-token.registry.ts +53 -0
- package/src/core/modules/api-token/core-api-token.service.ts +822 -0
- package/src/core/modules/auth/guards/roles.guard.ts +23 -2
- package/src/core/modules/better-auth/better-auth-roles.guard.ts +18 -4
- package/src/core/modules/better-auth/core-better-auth.middleware.ts +8 -0
- package/src/core/modules/better-auth/core-better-auth.module.ts +33 -0
- package/src/core/modules/tenant/README.md +17 -0
- package/src/core/modules/tenant/core-tenant-guard.registry.ts +36 -0
- package/src/core/modules/tenant/core-tenant.guard.ts +52 -12
- package/src/core/modules/tenant/core-tenant.helpers.ts +30 -0
- package/src/core/modules/tenant/core-tenant.module.ts +19 -2
- package/src/core/modules/user/core-user.service.ts +14 -0
- package/src/core.module.ts +12 -0
- package/src/index.ts +12 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Import-free leaf on purpose: guards of three modules (auth, better-auth, tenant) read these values,
|
|
2
|
+
// and a leaf can never be mid-evaluation when one of them imports it (see .claude/rules/architecture.md
|
|
3
|
+
// → "DI Token Placement (SWC-Safe)").
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Injection token / Mongoose model name for API tokens.
|
|
7
|
+
*/
|
|
8
|
+
export const API_TOKEN_MODEL_TOKEN = 'ApiToken';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Metadata key for the `@ApiTokenScopes()` decorator.
|
|
12
|
+
*/
|
|
13
|
+
export const API_TOKEN_SCOPES_KEY = 'apiTokenScopes';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Who an API token belongs to.
|
|
17
|
+
*
|
|
18
|
+
* - `USER`: owned by a user; acts with that user's CURRENT rights (never global roles such as ADMIN),
|
|
19
|
+
* optionally narrowed to scopes, one tenant and a maximum tenant role. Works with and without
|
|
20
|
+
* multi-tenancy.
|
|
21
|
+
* - `TENANT`: owned by a tenant, independent of any person; managed by the tenant's administrators,
|
|
22
|
+
* acts with the lowest tenant role and only inside its own tenant. Requires multi-tenancy.
|
|
23
|
+
*/
|
|
24
|
+
export enum ApiTokenKind {
|
|
25
|
+
TENANT = 'tenant',
|
|
26
|
+
USER = 'user',
|
|
27
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SetMetadata } from '@nestjs/common';
|
|
2
|
+
|
|
3
|
+
import { API_TOKEN_SCOPES_KEY } from './core-api-token.constants';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Method/class decorator that opens an endpoint to API tokens (`apiTokens` config).
|
|
7
|
+
*
|
|
8
|
+
* Tokens are DENIED on every route by default — user tokens and tenant tokens alike. A route accepts
|
|
9
|
+
* one only when it names the scopes that may call it; a token holding ANY one of them passes. A
|
|
10
|
+
* method-level declaration replaces the class-level one rather than adding to it, so a class can open
|
|
11
|
+
* itself for `'read'` while a single method narrows to `'export'`.
|
|
12
|
+
*
|
|
13
|
+
* Opening a route does not widen what a token may do there, it only stops the blanket refusal:
|
|
14
|
+
* - a USER token then acts as its user (without global roles), bounded by the token's own limits;
|
|
15
|
+
* - a TENANT token acts as a member of its tenant with the LOWEST role of the hierarchy, and
|
|
16
|
+
* `S_EVERYONE` / `S_USER` / `S_VERIFIED` count as satisfied for it.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* @ApiTokenScopes('upload')
|
|
21
|
+
* @Roles(RoleEnum.S_USER)
|
|
22
|
+
* @Post('documents')
|
|
23
|
+
* async upload(@CurrentUser() caller: any) {
|
|
24
|
+
* const token = getApiTokenContext(caller); // undefined for a session, set for a token
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export const ApiTokenScopes = (scope: string, ...moreScopes: string[]) =>
|
|
29
|
+
SetMetadata(API_TOKEN_SCOPES_KEY, [scope, ...moreScopes]);
|