@nitrostack/core 1.0.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/LICENSE +201 -0
- package/README.md +80 -0
- package/dist/auth/api-key.d.ts +118 -0
- package/dist/auth/api-key.d.ts.map +1 -0
- package/dist/auth/api-key.js +168 -0
- package/dist/auth/api-key.js.map +1 -0
- package/dist/auth/client.d.ts +151 -0
- package/dist/auth/client.d.ts.map +1 -0
- package/dist/auth/client.js +330 -0
- package/dist/auth/client.js.map +1 -0
- package/dist/auth/index.d.ts +31 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +46 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/middleware.d.ts +95 -0
- package/dist/auth/middleware.d.ts.map +1 -0
- package/dist/auth/middleware.js +260 -0
- package/dist/auth/middleware.js.map +1 -0
- package/dist/auth/pkce.d.ts +53 -0
- package/dist/auth/pkce.d.ts.map +1 -0
- package/dist/auth/pkce.js +105 -0
- package/dist/auth/pkce.js.map +1 -0
- package/dist/auth/quick-setup.d.ts +94 -0
- package/dist/auth/quick-setup.d.ts.map +1 -0
- package/dist/auth/quick-setup.js +210 -0
- package/dist/auth/quick-setup.js.map +1 -0
- package/dist/auth/secure-secret.d.ts +136 -0
- package/dist/auth/secure-secret.d.ts.map +1 -0
- package/dist/auth/secure-secret.js +182 -0
- package/dist/auth/secure-secret.js.map +1 -0
- package/dist/auth/server-integration.d.ts +97 -0
- package/dist/auth/server-integration.d.ts.map +1 -0
- package/dist/auth/server-integration.js +182 -0
- package/dist/auth/server-integration.js.map +1 -0
- package/dist/auth/server-metadata.d.ts +51 -0
- package/dist/auth/server-metadata.d.ts.map +1 -0
- package/dist/auth/server-metadata.js +106 -0
- package/dist/auth/server-metadata.js.map +1 -0
- package/dist/auth/simple-jwt.d.ts +174 -0
- package/dist/auth/simple-jwt.d.ts.map +1 -0
- package/dist/auth/simple-jwt.js +162 -0
- package/dist/auth/simple-jwt.js.map +1 -0
- package/dist/auth/token-store.d.ts +104 -0
- package/dist/auth/token-store.d.ts.map +1 -0
- package/dist/auth/token-store.js +205 -0
- package/dist/auth/token-store.js.map +1 -0
- package/dist/auth/token-validation.d.ts +59 -0
- package/dist/auth/token-validation.d.ts.map +1 -0
- package/dist/auth/token-validation.js +241 -0
- package/dist/auth/token-validation.js.map +1 -0
- package/dist/auth/types.d.ts +215 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +6 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/core/apikey-module.d.ts +69 -0
- package/dist/core/apikey-module.d.ts.map +1 -0
- package/dist/core/apikey-module.js +114 -0
- package/dist/core/apikey-module.js.map +1 -0
- package/dist/core/app-decorator.d.ts +59 -0
- package/dist/core/app-decorator.d.ts.map +1 -0
- package/dist/core/app-decorator.js +322 -0
- package/dist/core/app-decorator.js.map +1 -0
- package/dist/core/builders.d.ts +50 -0
- package/dist/core/builders.d.ts.map +1 -0
- package/dist/core/builders.js +139 -0
- package/dist/core/builders.js.map +1 -0
- package/dist/core/component.d.ts +111 -0
- package/dist/core/component.d.ts.map +1 -0
- package/dist/core/component.js +228 -0
- package/dist/core/component.js.map +1 -0
- package/dist/core/config-module.d.ts +62 -0
- package/dist/core/config-module.d.ts.map +1 -0
- package/dist/core/config-module.js +94 -0
- package/dist/core/config-module.js.map +1 -0
- package/dist/core/decorators/cache.decorator.d.ts +61 -0
- package/dist/core/decorators/cache.decorator.d.ts.map +1 -0
- package/dist/core/decorators/cache.decorator.js +115 -0
- package/dist/core/decorators/cache.decorator.js.map +1 -0
- package/dist/core/decorators/health-check.decorator.d.ts +80 -0
- package/dist/core/decorators/health-check.decorator.d.ts.map +1 -0
- package/dist/core/decorators/health-check.decorator.js +153 -0
- package/dist/core/decorators/health-check.decorator.js.map +1 -0
- package/dist/core/decorators/rate-limit.decorator.d.ts +63 -0
- package/dist/core/decorators/rate-limit.decorator.d.ts.map +1 -0
- package/dist/core/decorators/rate-limit.decorator.js +129 -0
- package/dist/core/decorators/rate-limit.decorator.js.map +1 -0
- package/dist/core/decorators.d.ts +190 -0
- package/dist/core/decorators.d.ts.map +1 -0
- package/dist/core/decorators.js +170 -0
- package/dist/core/decorators.js.map +1 -0
- package/dist/core/di/container.d.ts +64 -0
- package/dist/core/di/container.d.ts.map +1 -0
- package/dist/core/di/container.js +105 -0
- package/dist/core/di/container.js.map +1 -0
- package/dist/core/di/injectable.decorator.d.ts +62 -0
- package/dist/core/di/injectable.decorator.d.ts.map +1 -0
- package/dist/core/di/injectable.decorator.js +66 -0
- package/dist/core/di/injectable.decorator.js.map +1 -0
- package/dist/core/errors.d.ts +54 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +87 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/events/event-emitter.d.ts +50 -0
- package/dist/core/events/event-emitter.d.ts.map +1 -0
- package/dist/core/events/event-emitter.js +94 -0
- package/dist/core/events/event-emitter.js.map +1 -0
- package/dist/core/events/event.decorator.d.ts +48 -0
- package/dist/core/events/event.decorator.d.ts.map +1 -0
- package/dist/core/events/event.decorator.js +72 -0
- package/dist/core/events/event.decorator.js.map +1 -0
- package/dist/core/events/log-emitter.d.ts +14 -0
- package/dist/core/events/log-emitter.d.ts.map +1 -0
- package/dist/core/events/log-emitter.js +20 -0
- package/dist/core/events/log-emitter.js.map +1 -0
- package/dist/core/filters/exception-filter.decorator.d.ts +40 -0
- package/dist/core/filters/exception-filter.decorator.d.ts.map +1 -0
- package/dist/core/filters/exception-filter.decorator.js +54 -0
- package/dist/core/filters/exception-filter.decorator.js.map +1 -0
- package/dist/core/filters/exception-filter.interface.d.ts +39 -0
- package/dist/core/filters/exception-filter.interface.d.ts.map +1 -0
- package/dist/core/filters/exception-filter.interface.js +2 -0
- package/dist/core/filters/exception-filter.interface.js.map +1 -0
- package/dist/core/guards/apikey.guard.d.ts +22 -0
- package/dist/core/guards/apikey.guard.d.ts.map +1 -0
- package/dist/core/guards/apikey.guard.js +11 -0
- package/dist/core/guards/apikey.guard.js.map +1 -0
- package/dist/core/guards/guard.interface.d.ts +18 -0
- package/dist/core/guards/guard.interface.d.ts.map +1 -0
- package/dist/core/guards/guard.interface.js +2 -0
- package/dist/core/guards/guard.interface.js.map +1 -0
- package/dist/core/guards/jwt.guard.d.ts +18 -0
- package/dist/core/guards/jwt.guard.d.ts.map +1 -0
- package/dist/core/guards/jwt.guard.js +2 -0
- package/dist/core/guards/jwt.guard.js.map +1 -0
- package/dist/core/guards/oauth.guard.d.ts +35 -0
- package/dist/core/guards/oauth.guard.d.ts.map +1 -0
- package/dist/core/guards/oauth.guard.js +2 -0
- package/dist/core/guards/oauth.guard.js.map +1 -0
- package/dist/core/guards/use-guards.decorator.d.ts +25 -0
- package/dist/core/guards/use-guards.decorator.d.ts.map +1 -0
- package/dist/core/guards/use-guards.decorator.js +32 -0
- package/dist/core/guards/use-guards.decorator.js.map +1 -0
- package/dist/core/health/health-checks.resource.d.ts +14 -0
- package/dist/core/health/health-checks.resource.d.ts.map +1 -0
- package/dist/core/health/health-checks.resource.js +29 -0
- package/dist/core/health/health-checks.resource.js.map +1 -0
- package/dist/core/index.d.ts +57 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +59 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/interceptors/interceptor.decorator.d.ts +37 -0
- package/dist/core/interceptors/interceptor.decorator.d.ts.map +1 -0
- package/dist/core/interceptors/interceptor.decorator.js +51 -0
- package/dist/core/interceptors/interceptor.decorator.js.map +1 -0
- package/dist/core/interceptors/interceptor.interface.d.ts +31 -0
- package/dist/core/interceptors/interceptor.interface.d.ts.map +1 -0
- package/dist/core/interceptors/interceptor.interface.js +2 -0
- package/dist/core/interceptors/interceptor.interface.js.map +1 -0
- package/dist/core/jwt-module.d.ts +51 -0
- package/dist/core/jwt-module.d.ts.map +1 -0
- package/dist/core/jwt-module.js +52 -0
- package/dist/core/jwt-module.js.map +1 -0
- package/dist/core/logger.d.ts +18 -0
- package/dist/core/logger.d.ts.map +1 -0
- package/dist/core/logger.js +53 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/middleware/middleware.decorator.d.ts +39 -0
- package/dist/core/middleware/middleware.decorator.d.ts.map +1 -0
- package/dist/core/middleware/middleware.decorator.js +53 -0
- package/dist/core/middleware/middleware.decorator.js.map +1 -0
- package/dist/core/middleware/middleware.interface.d.ts +29 -0
- package/dist/core/middleware/middleware.interface.d.ts.map +1 -0
- package/dist/core/middleware/middleware.interface.js +2 -0
- package/dist/core/middleware/middleware.interface.js.map +1 -0
- package/dist/core/module.d.ts +93 -0
- package/dist/core/module.d.ts.map +1 -0
- package/dist/core/module.js +87 -0
- package/dist/core/module.js.map +1 -0
- package/dist/core/oauth-module.d.ts +123 -0
- package/dist/core/oauth-module.d.ts.map +1 -0
- package/dist/core/oauth-module.js +324 -0
- package/dist/core/oauth-module.js.map +1 -0
- package/dist/core/pipes/pipe.decorator.d.ts +64 -0
- package/dist/core/pipes/pipe.decorator.d.ts.map +1 -0
- package/dist/core/pipes/pipe.decorator.js +85 -0
- package/dist/core/pipes/pipe.decorator.js.map +1 -0
- package/dist/core/pipes/pipe.interface.d.ts +41 -0
- package/dist/core/pipes/pipe.interface.d.ts.map +1 -0
- package/dist/core/pipes/pipe.interface.js +2 -0
- package/dist/core/pipes/pipe.interface.js.map +1 -0
- package/dist/core/prompt.d.ts +46 -0
- package/dist/core/prompt.d.ts.map +1 -0
- package/dist/core/prompt.js +76 -0
- package/dist/core/prompt.js.map +1 -0
- package/dist/core/resource.d.ts +47 -0
- package/dist/core/resource.d.ts.map +1 -0
- package/dist/core/resource.js +90 -0
- package/dist/core/resource.js.map +1 -0
- package/dist/core/server.d.ts +129 -0
- package/dist/core/server.d.ts.map +1 -0
- package/dist/core/server.js +617 -0
- package/dist/core/server.js.map +1 -0
- package/dist/core/tool.d.ts +108 -0
- package/dist/core/tool.d.ts.map +1 -0
- package/dist/core/tool.js +241 -0
- package/dist/core/tool.js.map +1 -0
- package/dist/core/transports/discovery-http-server.d.ts +19 -0
- package/dist/core/transports/discovery-http-server.d.ts.map +1 -0
- package/dist/core/transports/discovery-http-server.js +54 -0
- package/dist/core/transports/discovery-http-server.js.map +1 -0
- package/dist/core/transports/http-server.d.ts +108 -0
- package/dist/core/transports/http-server.d.ts.map +1 -0
- package/dist/core/transports/http-server.js +293 -0
- package/dist/core/transports/http-server.js.map +1 -0
- package/dist/core/transports/streamable-http.d.ts +177 -0
- package/dist/core/transports/streamable-http.d.ts.map +1 -0
- package/dist/core/transports/streamable-http.js +1287 -0
- package/dist/core/transports/streamable-http.js.map +1 -0
- package/dist/core/types.d.ts +195 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +2 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/widgets/widget-examples.resource.d.ts +17 -0
- package/dist/core/widgets/widget-examples.resource.d.ts.map +1 -0
- package/dist/core/widgets/widget-examples.resource.js +28 -0
- package/dist/core/widgets/widget-examples.resource.js.map +1 -0
- package/dist/core/widgets/widget-registry.d.ts +56 -0
- package/dist/core/widgets/widget-registry.d.ts.map +1 -0
- package/dist/core/widgets/widget-registry.js +75 -0
- package/dist/core/widgets/widget-registry.js.map +1 -0
- package/dist/testing/index.d.ts +103 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +161 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/ui-next/index.d.ts +31 -0
- package/dist/ui-next/index.d.ts.map +1 -0
- package/dist/ui-next/index.js +687 -0
- package/dist/ui-next/index.js.map +1 -0
- package/package.json +89 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apikey.guard.d.ts","sourceRoot":"","sources":["../../../src/core/guards/apikey.guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,WAAW,cAAc;IAC7B,8BAA8B;IAC9B,GAAG,EAAE,MAAM,CAAC;IAEZ,wCAAwC;IACxC,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,4EAA4E;IAC5E,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,mCAAmC;IACnC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAElB,oCAAoC;IACpC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Key Guard Interface
|
|
3
|
+
*
|
|
4
|
+
* This is exported from the SDK for type definitions.
|
|
5
|
+
* The actual ApiKeyGuard implementation should be in your project's guards folder.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* See templates/typescript-auth-api-key/src/guards/apikey.guard.ts for implementation
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=apikey.guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apikey.guard.js","sourceRoot":"","sources":["../../../src/core/guards/apikey.guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ExecutionContext } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Guard interface for protecting tool execution
|
|
4
|
+
* Guards can perform authentication, authorization, validation, etc.
|
|
5
|
+
*/
|
|
6
|
+
export interface Guard {
|
|
7
|
+
/**
|
|
8
|
+
* Determines if the current execution context is allowed to proceed
|
|
9
|
+
* @param context Execution context with request metadata
|
|
10
|
+
* @returns true if allowed, false if denied, or throws an error
|
|
11
|
+
*/
|
|
12
|
+
canActivate(context: ExecutionContext): boolean | Promise<boolean>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Type for guard constructor
|
|
16
|
+
*/
|
|
17
|
+
export type GuardConstructor = new (...args: unknown[]) => Guard;
|
|
18
|
+
//# sourceMappingURL=guard.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guard.interface.d.ts","sourceRoot":"","sources":["../../../src/core/guards/guard.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C;;;GAGG;AACH,MAAM,WAAW,KAAK;IACpB;;;;OAIG;IACH,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACpE;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,KAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guard.interface.js","sourceRoot":"","sources":["../../../src/core/guards/guard.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JWT payload interface
|
|
3
|
+
*
|
|
4
|
+
* This is exported from the SDK for type definitions.
|
|
5
|
+
* The actual JWTGuard implementation should be in your project's guards folder.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* See templates/typescript-auth/src/guards/jwt.guard.ts for implementation
|
|
9
|
+
*/
|
|
10
|
+
export interface JWTPayload {
|
|
11
|
+
sub: string;
|
|
12
|
+
email?: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
iat?: number;
|
|
15
|
+
exp?: number;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=jwt.guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwt.guard.d.ts","sourceRoot":"","sources":["../../../src/core/guards/jwt.guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwt.guard.js","sourceRoot":"","sources":["../../../src/core/guards/jwt.guard.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth Token Payload Interface
|
|
3
|
+
*
|
|
4
|
+
* Standard OAuth 2.1 / JWT claims (RFC 9068)
|
|
5
|
+
*
|
|
6
|
+
* This is exported from the SDK for type definitions.
|
|
7
|
+
* The actual OAuthGuard implementation should be in your project's guards folder.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* See templates/typescript-oauth/src/guards/oauth.guard.ts for implementation
|
|
11
|
+
*/
|
|
12
|
+
export interface OAuthTokenPayload {
|
|
13
|
+
/** Subject - typically the user ID */
|
|
14
|
+
sub: string;
|
|
15
|
+
/** Issuer - the authorization server that issued the token */
|
|
16
|
+
iss?: string;
|
|
17
|
+
/** Audience - who the token is intended for (RFC 8707) */
|
|
18
|
+
aud?: string | string[];
|
|
19
|
+
/** Expiration time (Unix timestamp) */
|
|
20
|
+
exp?: number;
|
|
21
|
+
/** Issued at time (Unix timestamp) */
|
|
22
|
+
iat?: number;
|
|
23
|
+
/** Not before time (Unix timestamp) */
|
|
24
|
+
nbf?: number;
|
|
25
|
+
/** JWT ID - unique identifier for the token */
|
|
26
|
+
jti?: string;
|
|
27
|
+
/** Scopes - permissions granted to the token */
|
|
28
|
+
scope?: string;
|
|
29
|
+
scopes?: string[];
|
|
30
|
+
/** Client ID that requested the token */
|
|
31
|
+
client_id?: string;
|
|
32
|
+
/** Custom claims */
|
|
33
|
+
[key: string]: unknown;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=oauth.guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth.guard.d.ts","sourceRoot":"","sources":["../../../src/core/guards/oauth.guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,WAAW,iBAAiB;IAChC,sCAAsC;IACtC,GAAG,EAAE,MAAM,CAAC;IAEZ,8DAA8D;IAC9D,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,0DAA0D;IAC1D,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAExB,uCAAuC;IACvC,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,sCAAsC;IACtC,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,uCAAuC;IACvC,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,+CAA+C;IAC/C,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAElB,yCAAyC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,oBAAoB;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth.guard.js","sourceRoot":"","sources":["../../../src/core/guards/oauth.guard.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { GuardConstructor } from './guard.interface.js';
|
|
3
|
+
/**
|
|
4
|
+
* Metadata key for guards
|
|
5
|
+
*/
|
|
6
|
+
export declare const GUARDS_METADATA: unique symbol;
|
|
7
|
+
/**
|
|
8
|
+
* UseGuards decorator - Applies guards to a tool method
|
|
9
|
+
* Guards are executed before the tool handler
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* @Tool({ name: 'whoami', ... })
|
|
14
|
+
* @UseGuards(JWTGuard)
|
|
15
|
+
* async whoami(input: Record<string, unknown>, context: ExecutionContext) {
|
|
16
|
+
* // This only executes if JWTGuard.canActivate returns true
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function UseGuards(...guards: GuardConstructor[]): (target: object, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
21
|
+
/**
|
|
22
|
+
* Get guards metadata for a specific method
|
|
23
|
+
*/
|
|
24
|
+
export declare function getGuardsMetadata(target: object, methodName: string): GuardConstructor[];
|
|
25
|
+
//# sourceMappingURL=use-guards.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-guards.decorator.d.ts","sourceRoot":"","sources":["../../../src/core/guards/use-guards.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD;;GAEG;AACH,eAAO,MAAM,eAAe,eAA4B,CAAC;AAEzD;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,GAAG,MAAM,EAAE,gBAAgB,EAAE,IACpC,QAAQ,MAAM,EAAE,aAAa,MAAM,EAAE,YAAY,kBAAkB,wBAKrF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAExF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
/**
|
|
3
|
+
* Metadata key for guards
|
|
4
|
+
*/
|
|
5
|
+
export const GUARDS_METADATA = Symbol('guards:metadata');
|
|
6
|
+
/**
|
|
7
|
+
* UseGuards decorator - Applies guards to a tool method
|
|
8
|
+
* Guards are executed before the tool handler
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* @Tool({ name: 'whoami', ... })
|
|
13
|
+
* @UseGuards(JWTGuard)
|
|
14
|
+
* async whoami(input: Record<string, unknown>, context: ExecutionContext) {
|
|
15
|
+
* // This only executes if JWTGuard.canActivate returns true
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export function UseGuards(...guards) {
|
|
20
|
+
return function (target, propertyKey, descriptor) {
|
|
21
|
+
// Store guards metadata for this method
|
|
22
|
+
Reflect.defineMetadata(GUARDS_METADATA, guards, target, propertyKey);
|
|
23
|
+
return descriptor;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Get guards metadata for a specific method
|
|
28
|
+
*/
|
|
29
|
+
export function getGuardsMetadata(target, methodName) {
|
|
30
|
+
return Reflect.getMetadata(GUARDS_METADATA, target, methodName) || [];
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=use-guards.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-guards.decorator.js","sourceRoot":"","sources":["../../../src/core/guards/use-guards.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAG1B;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAEzD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,SAAS,CAAC,GAAG,MAA0B;IACrD,OAAO,UAAU,MAAc,EAAE,WAAmB,EAAE,UAA8B;QAClF,wCAAwC;QACxC,OAAO,CAAC,cAAc,CAAC,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;QACrE,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAc,EAAE,UAAkB;IAClE,OAAO,OAAO,CAAC,WAAW,CAAC,eAAe,EAAE,MAAM,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Health Checks Resource
|
|
3
|
+
*
|
|
4
|
+
* Exposes all registered health checks as an MCP resource
|
|
5
|
+
* so clients can query health status
|
|
6
|
+
*/
|
|
7
|
+
export declare function buildHealthChecksResource(): Promise<{
|
|
8
|
+
uri: string;
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
mimeType: string;
|
|
12
|
+
read(): Promise<string>;
|
|
13
|
+
}>;
|
|
14
|
+
//# sourceMappingURL=health-checks.resource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health-checks.resource.d.ts","sourceRoot":"","sources":["../../../src/core/health/health-checks.resource.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAsB,yBAAyB;;;;;;GAsB9C"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { getAllHealthChecks } from '../decorators/health-check.decorator.js';
|
|
2
|
+
/**
|
|
3
|
+
* Health Checks Resource
|
|
4
|
+
*
|
|
5
|
+
* Exposes all registered health checks as an MCP resource
|
|
6
|
+
* so clients can query health status
|
|
7
|
+
*/
|
|
8
|
+
export async function buildHealthChecksResource() {
|
|
9
|
+
return {
|
|
10
|
+
uri: 'health://checks',
|
|
11
|
+
name: 'Health Checks',
|
|
12
|
+
description: 'Current health status of all registered health checks',
|
|
13
|
+
mimeType: 'application/json',
|
|
14
|
+
async read() {
|
|
15
|
+
const checks = await getAllHealthChecks();
|
|
16
|
+
// Transform to array format
|
|
17
|
+
const checksArray = Object.entries(checks).map(([name, result]) => ({
|
|
18
|
+
name,
|
|
19
|
+
...result,
|
|
20
|
+
}));
|
|
21
|
+
return JSON.stringify({
|
|
22
|
+
checks: checksArray,
|
|
23
|
+
count: checksArray.length,
|
|
24
|
+
timestamp: new Date().toISOString(),
|
|
25
|
+
}, null, 2);
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=health-checks.resource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health-checks.resource.js","sourceRoot":"","sources":["../../../src/core/health/health-checks.resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAE7E;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB;IAC7C,OAAO;QACL,GAAG,EAAE,iBAAiB;QACtB,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE,uDAAuD;QACpE,QAAQ,EAAE,kBAAkB;QAC5B,KAAK,CAAC,IAAI;YACR,MAAM,MAAM,GAAG,MAAM,kBAAkB,EAAE,CAAC;YAE1C,4BAA4B;YAC5B,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC;gBAClE,IAAI;gBACJ,GAAG,MAAM;aACV,CAAC,CAAC,CAAC;YAEJ,OAAO,IAAI,CAAC,SAAS,CAAC;gBACpB,MAAM,EAAE,WAAW;gBACnB,KAAK,EAAE,WAAW,CAAC,MAAM;gBACzB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;aACpC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NitroStack Core Exports
|
|
3
|
+
*/
|
|
4
|
+
import 'reflect-metadata';
|
|
5
|
+
export { createServer, NitroStackServer } from './server.js';
|
|
6
|
+
export { HttpServerTransport } from './transports/http-server.js';
|
|
7
|
+
export type { HttpServerTransportOptions } from './transports/http-server.js';
|
|
8
|
+
export { Tool } from './tool.js';
|
|
9
|
+
export { createResource, Resource } from './resource.js';
|
|
10
|
+
export { createPrompt, Prompt } from './prompt.js';
|
|
11
|
+
export { createComponent, Component } from './component.js';
|
|
12
|
+
export { createLogger, defaultLogger } from './logger.js';
|
|
13
|
+
export * from './errors.js';
|
|
14
|
+
export type { McpServerConfig, ToolDefinition, ResourceDefinition, PromptDefinition, ExecutionContext, Logger, AuthContext, JsonValue, JsonValueOrUndefined, JsonObject, JsonArray, JsonPrimitive, Constructor, ClassConstructor, } from './types.js';
|
|
15
|
+
export { Tool as ToolDecorator, Widget, Resource as ResourceDecorator, Prompt as PromptDecorator, extractTools, extractResources, extractPrompts, getWidgetMetadata, getGuardsMetadata, InitialTool, } from './decorators.js';
|
|
16
|
+
export type { ToolOptions, ResourceOptions, PromptOptions, } from './decorators.js';
|
|
17
|
+
export { Module, createModule, isModule, getModuleMetadata, } from './module.js';
|
|
18
|
+
export type { ModuleMetadata, ModuleImport, DynamicModule, Provider, } from './module.js';
|
|
19
|
+
export type { Guard, GuardConstructor } from './guards/guard.interface.js';
|
|
20
|
+
export { UseGuards, getGuardsMetadata as getGuardsMetadataFromDecorator } from './guards/use-guards.decorator.js';
|
|
21
|
+
export type { JWTPayload } from './guards/jwt.guard.js';
|
|
22
|
+
export type { ApiKeyMetadata } from './guards/apikey.guard.js';
|
|
23
|
+
export type { OAuthTokenPayload } from './guards/oauth.guard.js';
|
|
24
|
+
export { JWTModule } from './jwt-module.js';
|
|
25
|
+
export type { JWTModuleConfig } from './jwt-module.js';
|
|
26
|
+
export { ApiKeyModule } from './apikey-module.js';
|
|
27
|
+
export type { ApiKeyModuleConfig } from './apikey-module.js';
|
|
28
|
+
export { OAuthModule } from './oauth-module.js';
|
|
29
|
+
export type { OAuthModuleConfig } from './oauth-module.js';
|
|
30
|
+
export { buildTool, buildTools, buildResource, buildResources, buildPrompt, buildPrompts, buildController, } from './builders.js';
|
|
31
|
+
export type { MiddlewareInterface, MiddlewareConstructor } from './middleware/middleware.interface.js';
|
|
32
|
+
export { Middleware, UseMiddleware, getMiddlewareMetadata, isMiddleware } from './middleware/middleware.decorator.js';
|
|
33
|
+
export type { InterceptorInterface, InterceptorConstructor } from './interceptors/interceptor.interface.js';
|
|
34
|
+
export { Interceptor, UseInterceptors, getInterceptorMetadata, isInterceptor } from './interceptors/interceptor.decorator.js';
|
|
35
|
+
export type { PipeInterface, PipeConstructor, ArgumentMetadata } from './pipes/pipe.interface.js';
|
|
36
|
+
export { Pipe, UsePipes, Body, Validated, getPipeMetadata, getParamPipesMetadata, isPipe } from './pipes/pipe.decorator.js';
|
|
37
|
+
export type { ExceptionFilterInterface, ExceptionFilterConstructor } from './filters/exception-filter.interface.js';
|
|
38
|
+
export { ExceptionFilter, UseFilters, getExceptionFilterMetadata, isExceptionFilter } from './filters/exception-filter.decorator.js';
|
|
39
|
+
export { DIContainer } from './di/container.js';
|
|
40
|
+
export { Injectable, Inject, isInjectable, getInjectTokens } from './di/injectable.decorator.js';
|
|
41
|
+
export type { InjectableOptions } from './di/injectable.decorator.js';
|
|
42
|
+
export { Cache, clearCache, getCacheMetadata } from './decorators/cache.decorator.js';
|
|
43
|
+
export type { CacheOptions, CacheStorage } from './decorators/cache.decorator.js';
|
|
44
|
+
export { RateLimit, resetRateLimit, getRateLimitMetadata } from './decorators/rate-limit.decorator.js';
|
|
45
|
+
export type { RateLimitOptions, RateLimitStorage } from './decorators/rate-limit.decorator.js';
|
|
46
|
+
export { HealthCheck, registerHealthCheck, getAllHealthChecks, getHealthCheck, getOverallHealth, isHealthCheck, getHealthCheckMetadata } from './decorators/health-check.decorator.js';
|
|
47
|
+
export type { HealthCheckOptions, HealthCheckResult, HealthCheckInterface } from './decorators/health-check.decorator.js';
|
|
48
|
+
export { EventEmitter } from './events/event-emitter.js';
|
|
49
|
+
export { OnEvent, getEventHandlers, registerEventHandlers, emitEvent } from './events/event.decorator.js';
|
|
50
|
+
export { ConfigModule, ConfigService } from './config-module.js';
|
|
51
|
+
export type { ConfigModuleOptions } from './config-module.js';
|
|
52
|
+
export { McpApp, McpApplicationFactory, getMcpAppMetadata } from './app-decorator.js';
|
|
53
|
+
export type { McpAppOptions } from './app-decorator.js';
|
|
54
|
+
export { z } from 'zod';
|
|
55
|
+
export * from '../auth/index.js';
|
|
56
|
+
export { createComponentFromNext, createComponentFromNextRoute } from '../ui-next/index.js';
|
|
57
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NitroStack Core Exports
|
|
3
|
+
*/
|
|
4
|
+
// Import reflect-metadata for decorator support
|
|
5
|
+
import 'reflect-metadata';
|
|
6
|
+
// Server
|
|
7
|
+
export { createServer, NitroStackServer } from './server.js';
|
|
8
|
+
// Transports
|
|
9
|
+
export { HttpServerTransport } from './transports/http-server.js';
|
|
10
|
+
// Tool
|
|
11
|
+
export { Tool } from './tool.js';
|
|
12
|
+
// Resource
|
|
13
|
+
export { createResource, Resource } from './resource.js';
|
|
14
|
+
// Prompt
|
|
15
|
+
export { createPrompt, Prompt } from './prompt.js';
|
|
16
|
+
// Component (UI/UX)
|
|
17
|
+
export { createComponent, Component } from './component.js';
|
|
18
|
+
// Logger
|
|
19
|
+
export { createLogger, defaultLogger } from './logger.js';
|
|
20
|
+
// Errors
|
|
21
|
+
export * from './errors.js';
|
|
22
|
+
// ========== V3 Decorators ==========
|
|
23
|
+
export { Tool as ToolDecorator, Widget, Resource as ResourceDecorator, Prompt as PromptDecorator, extractTools, extractResources, extractPrompts, getWidgetMetadata, getGuardsMetadata, InitialTool, } from './decorators.js';
|
|
24
|
+
// ========== V3 Modules ==========
|
|
25
|
+
export { Module, createModule, isModule, getModuleMetadata, } from './module.js';
|
|
26
|
+
export { UseGuards, getGuardsMetadata as getGuardsMetadataFromDecorator } from './guards/use-guards.decorator.js';
|
|
27
|
+
// ========== V3 JWT Module ==========
|
|
28
|
+
export { JWTModule } from './jwt-module.js';
|
|
29
|
+
// ========== V3 API Key Module ==========
|
|
30
|
+
export { ApiKeyModule } from './apikey-module.js';
|
|
31
|
+
// ========== V3 OAuth Module ==========
|
|
32
|
+
export { OAuthModule } from './oauth-module.js';
|
|
33
|
+
// ========== V3 Builders ==========
|
|
34
|
+
export { buildTool, buildTools, buildResource, buildResources, buildPrompt, buildPrompts, buildController, } from './builders.js';
|
|
35
|
+
export { Middleware, UseMiddleware, getMiddlewareMetadata, isMiddleware } from './middleware/middleware.decorator.js';
|
|
36
|
+
export { Interceptor, UseInterceptors, getInterceptorMetadata, isInterceptor } from './interceptors/interceptor.decorator.js';
|
|
37
|
+
export { Pipe, UsePipes, Body, Validated, getPipeMetadata, getParamPipesMetadata, isPipe } from './pipes/pipe.decorator.js';
|
|
38
|
+
export { ExceptionFilter, UseFilters, getExceptionFilterMetadata, isExceptionFilter } from './filters/exception-filter.decorator.js';
|
|
39
|
+
// ========== V3 Dependency Injection ==========
|
|
40
|
+
export { DIContainer } from './di/container.js';
|
|
41
|
+
export { Injectable, Inject, isInjectable, getInjectTokens } from './di/injectable.decorator.js';
|
|
42
|
+
// ========== V3 Utility Decorators ==========
|
|
43
|
+
export { Cache, clearCache, getCacheMetadata } from './decorators/cache.decorator.js';
|
|
44
|
+
export { RateLimit, resetRateLimit, getRateLimitMetadata } from './decorators/rate-limit.decorator.js';
|
|
45
|
+
export { HealthCheck, registerHealthCheck, getAllHealthChecks, getHealthCheck, getOverallHealth, isHealthCheck, getHealthCheckMetadata } from './decorators/health-check.decorator.js';
|
|
46
|
+
// ========== V3 Event System ==========
|
|
47
|
+
export { EventEmitter } from './events/event-emitter.js';
|
|
48
|
+
export { OnEvent, getEventHandlers, registerEventHandlers, emitEvent } from './events/event.decorator.js';
|
|
49
|
+
// ========== V3 Configuration Module ==========
|
|
50
|
+
export { ConfigModule, ConfigService } from './config-module.js';
|
|
51
|
+
// ========== V3 Application Bootstrap ==========
|
|
52
|
+
export { McpApp, McpApplicationFactory, getMcpAppMetadata } from './app-decorator.js';
|
|
53
|
+
// Zod re-export for convenience
|
|
54
|
+
export { z } from 'zod';
|
|
55
|
+
// Auth module
|
|
56
|
+
export * from '../auth/index.js';
|
|
57
|
+
// UI Next adapter (optional)
|
|
58
|
+
export { createComponentFromNext, createComponentFromNextRoute } from '../ui-next/index.js';
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { InterceptorConstructor } from './interceptor.interface.js';
|
|
3
|
+
/**
|
|
4
|
+
* Marks a class as an interceptor
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* @Interceptor()
|
|
9
|
+
* export class TransformInterceptor implements InterceptorInterface {
|
|
10
|
+
* async intercept(context: ExecutionContext, next: () => Promise<unknown>) {
|
|
11
|
+
* const result = await next();
|
|
12
|
+
* return { success: true, data: result, timestamp: Date.now() };
|
|
13
|
+
* }
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare function Interceptor(): ClassDecorator;
|
|
18
|
+
/**
|
|
19
|
+
* Apply interceptors to a tool method
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* @Tool({ name: 'get_user', ... })
|
|
24
|
+
* @UseInterceptors(TransformInterceptor, CacheInterceptor)
|
|
25
|
+
* async getUser(input: Record<string, unknown>) { }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function UseInterceptors(...interceptors: InterceptorConstructor[]): MethodDecorator;
|
|
29
|
+
/**
|
|
30
|
+
* Get interceptors for a method
|
|
31
|
+
*/
|
|
32
|
+
export declare function getInterceptorMetadata(target: object, propertyKey: string | symbol): InterceptorConstructor[];
|
|
33
|
+
/**
|
|
34
|
+
* Check if a class is marked as an interceptor
|
|
35
|
+
*/
|
|
36
|
+
export declare function isInterceptor(target: object): boolean;
|
|
37
|
+
//# sourceMappingURL=interceptor.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interceptor.decorator.d.ts","sourceRoot":"","sources":["../../../src/core/interceptors/interceptor.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAKpE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,IAAI,cAAc,CAI5C;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,GAAG,YAAY,EAAE,sBAAsB,EAAE,GAAG,eAAe,CAU1F;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,sBAAsB,EAAE,CAE7G;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAErD"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
const INTERCEPTOR_KEY = 'nitrostack:interceptor';
|
|
3
|
+
const IS_INTERCEPTOR_KEY = 'nitrostack:is_interceptor';
|
|
4
|
+
/**
|
|
5
|
+
* Marks a class as an interceptor
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* @Interceptor()
|
|
10
|
+
* export class TransformInterceptor implements InterceptorInterface {
|
|
11
|
+
* async intercept(context: ExecutionContext, next: () => Promise<unknown>) {
|
|
12
|
+
* const result = await next();
|
|
13
|
+
* return { success: true, data: result, timestamp: Date.now() };
|
|
14
|
+
* }
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export function Interceptor() {
|
|
19
|
+
return (target) => {
|
|
20
|
+
Reflect.defineMetadata(IS_INTERCEPTOR_KEY, true, target);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Apply interceptors to a tool method
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* @Tool({ name: 'get_user', ... })
|
|
29
|
+
* @UseInterceptors(TransformInterceptor, CacheInterceptor)
|
|
30
|
+
* async getUser(input: Record<string, unknown>) { }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export function UseInterceptors(...interceptors) {
|
|
34
|
+
return (target, propertyKey, descriptor) => {
|
|
35
|
+
const existingInterceptors = Reflect.getMetadata(INTERCEPTOR_KEY, target, propertyKey) || [];
|
|
36
|
+
Reflect.defineMetadata(INTERCEPTOR_KEY, [...existingInterceptors, ...interceptors], target, propertyKey);
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get interceptors for a method
|
|
41
|
+
*/
|
|
42
|
+
export function getInterceptorMetadata(target, propertyKey) {
|
|
43
|
+
return Reflect.getMetadata(INTERCEPTOR_KEY, target, propertyKey) || [];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Check if a class is marked as an interceptor
|
|
47
|
+
*/
|
|
48
|
+
export function isInterceptor(target) {
|
|
49
|
+
return Reflect.getMetadata(IS_INTERCEPTOR_KEY, target) === true;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=interceptor.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interceptor.decorator.js","sourceRoot":"","sources":["../../../src/core/interceptors/interceptor.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAG1B,MAAM,eAAe,GAAG,wBAAwB,CAAC;AACjD,MAAM,kBAAkB,GAAG,2BAA2B,CAAC;AAEvD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,CAAC,MAAc,EAAE,EAAE;QACxB,OAAO,CAAC,cAAc,CAAC,kBAAkB,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IAC3D,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAAC,GAAG,YAAsC;IACvE,OAAO,CAAC,MAAc,EAAE,WAA4B,EAAE,UAA8B,EAAE,EAAE;QACtF,MAAM,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC,eAAe,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;QAC7F,OAAO,CAAC,cAAc,CACpB,eAAe,EACf,CAAC,GAAG,oBAAoB,EAAE,GAAG,YAAY,CAAC,EAC1C,MAAM,EACN,WAAW,CACZ,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAc,EAAE,WAA4B;IACjF,OAAO,OAAO,CAAC,WAAW,CAAC,eAAe,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;AACzE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,MAAc;IAC1C,OAAO,OAAO,CAAC,WAAW,CAAC,kBAAkB,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { ExecutionContext } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Interceptor Interface
|
|
5
|
+
*
|
|
6
|
+
* Interceptors can transform the input or output of a tool execution.
|
|
7
|
+
* They're executed after guards but before the actual tool handler.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* @Interceptor()
|
|
12
|
+
* export class TransformInterceptor implements InterceptorInterface {
|
|
13
|
+
* async intercept(context: ExecutionContext, next: () => Promise<unknown>) {
|
|
14
|
+
* const result = await next();
|
|
15
|
+
* return {
|
|
16
|
+
* success: true,
|
|
17
|
+
* data: result,
|
|
18
|
+
* timestamp: new Date().toISOString()
|
|
19
|
+
* };
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export interface InterceptorInterface {
|
|
25
|
+
intercept(context: ExecutionContext, next: () => Promise<unknown>): Promise<unknown>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Interceptor constructor type
|
|
29
|
+
*/
|
|
30
|
+
export type InterceptorConstructor = new (...args: unknown[]) => InterceptorInterface;
|
|
31
|
+
//# sourceMappingURL=interceptor.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interceptor.interface.d.ts","sourceRoot":"","sources":["../../../src/core/interceptors/interceptor.interface.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,oBAAoB;IACnC,SAAS,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACtF;AAED;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interceptor.interface.js","sourceRoot":"","sources":["../../../src/core/interceptors/interceptor.interface.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
/**
|
|
3
|
+
* JWT Module Configuration
|
|
4
|
+
*/
|
|
5
|
+
export interface JWTModuleConfig {
|
|
6
|
+
/** JWT secret (or env var name to read from) */
|
|
7
|
+
secret?: string;
|
|
8
|
+
/** Environment variable to read secret from */
|
|
9
|
+
secretEnvVar?: string;
|
|
10
|
+
/** Token expiration time (e.g., '24h', '7d') */
|
|
11
|
+
expiresIn?: string;
|
|
12
|
+
/** JWT audience */
|
|
13
|
+
audience?: string;
|
|
14
|
+
/** JWT issuer */
|
|
15
|
+
issuer?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* JWT Module - Enable JWT authentication in your MCP server
|
|
19
|
+
*
|
|
20
|
+
* Import this module to indicate your server uses JWT authentication.
|
|
21
|
+
* Then use @UseGuards(JWTGuard) on your tools to protect them.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* import { createServer, JWTModule } from 'nitrostack';
|
|
26
|
+
*
|
|
27
|
+
* const server = createServer({ ... });
|
|
28
|
+
*
|
|
29
|
+
* // Enable JWT authentication
|
|
30
|
+
* server.use(JWTModule.forRoot({
|
|
31
|
+
* secretEnvVar: 'JWT_SECRET',
|
|
32
|
+
* expiresIn: '24h',
|
|
33
|
+
* }));
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare class JWTModule {
|
|
37
|
+
private static config;
|
|
38
|
+
/**
|
|
39
|
+
* Configure JWT module for the application
|
|
40
|
+
*/
|
|
41
|
+
static forRoot(config: JWTModuleConfig): JWTModuleConfig;
|
|
42
|
+
/**
|
|
43
|
+
* Get current JWT configuration
|
|
44
|
+
*/
|
|
45
|
+
static getConfig(): JWTModuleConfig;
|
|
46
|
+
/**
|
|
47
|
+
* Get JWT secret from config or environment
|
|
48
|
+
*/
|
|
49
|
+
static getSecret(): string | null;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=jwt-module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwt-module.d.ts","sourceRoot":"","sources":["../../src/core/jwt-module.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,mBAAmB;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,iBAAiB;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAC,MAAM,CAGnB;IAEF;;OAEG;IACH,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,eAAe,GAAG,eAAe;IAKxD;;OAEG;IACH,MAAM,CAAC,SAAS,IAAI,eAAe;IAInC;;OAEG;IACH,MAAM,CAAC,SAAS,IAAI,MAAM,GAAG,IAAI;CAWlC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
/**
|
|
3
|
+
* JWT Module - Enable JWT authentication in your MCP server
|
|
4
|
+
*
|
|
5
|
+
* Import this module to indicate your server uses JWT authentication.
|
|
6
|
+
* Then use @UseGuards(JWTGuard) on your tools to protect them.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { createServer, JWTModule } from 'nitrostack';
|
|
11
|
+
*
|
|
12
|
+
* const server = createServer({ ... });
|
|
13
|
+
*
|
|
14
|
+
* // Enable JWT authentication
|
|
15
|
+
* server.use(JWTModule.forRoot({
|
|
16
|
+
* secretEnvVar: 'JWT_SECRET',
|
|
17
|
+
* expiresIn: '24h',
|
|
18
|
+
* }));
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export class JWTModule {
|
|
22
|
+
static config = {
|
|
23
|
+
secretEnvVar: 'JWT_SECRET',
|
|
24
|
+
expiresIn: '24h',
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Configure JWT module for the application
|
|
28
|
+
*/
|
|
29
|
+
static forRoot(config) {
|
|
30
|
+
this.config = { ...this.config, ...config };
|
|
31
|
+
return this.config;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get current JWT configuration
|
|
35
|
+
*/
|
|
36
|
+
static getConfig() {
|
|
37
|
+
return this.config;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get JWT secret from config or environment
|
|
41
|
+
*/
|
|
42
|
+
static getSecret() {
|
|
43
|
+
if (this.config.secret) {
|
|
44
|
+
return this.config.secret;
|
|
45
|
+
}
|
|
46
|
+
if (this.config.secretEnvVar) {
|
|
47
|
+
return process.env[this.config.secretEnvVar] || null;
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=jwt-module.js.map
|