nitrostack 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/CHANGELOG.md +227 -0
- package/CONTRIBUTING.md +182 -0
- package/LICENSE +201 -0
- package/LICENSE_URLS_UPDATE_COMPLETE.md +388 -0
- package/NOTICE +153 -0
- package/README.md +571 -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 +30 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +43 -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/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 +88 -0
- package/dist/auth/simple-jwt.d.ts.map +1 -0
- package/dist/auth/simple-jwt.js +152 -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 +47 -0
- package/dist/auth/token-validation.d.ts.map +1 -0
- package/dist/auth/token-validation.js +237 -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/cli/commands/build.d.ts +6 -0
- package/dist/cli/commands/build.d.ts.map +1 -0
- package/dist/cli/commands/build.js +104 -0
- package/dist/cli/commands/build.js.map +1 -0
- package/dist/cli/commands/dev.d.ts +7 -0
- package/dist/cli/commands/dev.d.ts.map +1 -0
- package/dist/cli/commands/dev.js +312 -0
- package/dist/cli/commands/dev.js.map +1 -0
- package/dist/cli/commands/generate-types.d.ts +8 -0
- package/dist/cli/commands/generate-types.d.ts.map +1 -0
- package/dist/cli/commands/generate-types.js +220 -0
- package/dist/cli/commands/generate-types.js.map +1 -0
- package/dist/cli/commands/generate.d.ts +5 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/generate.js +365 -0
- package/dist/cli/commands/generate.js.map +1 -0
- package/dist/cli/commands/init.d.ts +7 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +365 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/start.d.ts +6 -0
- package/dist/cli/commands/start.d.ts.map +1 -0
- package/dist/cli/commands/start.js +61 -0
- package/dist/cli/commands/start.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +47 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/mcp-dev-wrapper.d.ts +3 -0
- package/dist/cli/mcp-dev-wrapper.d.ts.map +1 -0
- package/dist/cli/mcp-dev-wrapper.js +116 -0
- package/dist/cli/mcp-dev-wrapper.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 +58 -0
- package/dist/core/app-decorator.d.ts.map +1 -0
- package/dist/core/app-decorator.js +261 -0
- package/dist/core/app-decorator.js.map +1 -0
- package/dist/core/builders.d.ts +38 -0
- package/dist/core/builders.d.ts.map +1 -0
- package/dist/core/builders.js +129 -0
- package/dist/core/builders.js.map +1 -0
- package/dist/core/component.d.ts +105 -0
- package/dist/core/component.d.ts.map +1 -0
- package/dist/core/component.js +182 -0
- package/dist/core/component.js.map +1 -0
- package/dist/core/config-module.d.ts +55 -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 +62 -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 +151 -0
- package/dist/core/decorators.d.ts.map +1 -0
- package/dist/core/decorators.js +142 -0
- package/dist/core/decorators.js.map +1 -0
- package/dist/core/di/container.d.ts +42 -0
- package/dist/core/di/container.d.ts.map +1 -0
- package/dist/core/di/container.js +76 -0
- package/dist/core/di/container.js.map +1 -0
- package/dist/core/di/injectable.decorator.d.ts +35 -0
- package/dist/core/di/injectable.decorator.d.ts.map +1 -0
- package/dist/core/di/injectable.decorator.js +57 -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 +68 -0
- package/dist/core/events/event.decorator.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 +30 -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 +55 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +57 -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 +51 -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 +74 -0
- package/dist/core/module.d.ts.map +1 -0
- package/dist/core/module.js +82 -0
- package/dist/core/module.js.map +1 -0
- package/dist/core/oauth-module.d.ts +144 -0
- package/dist/core/oauth-module.d.ts.map +1 -0
- package/dist/core/oauth-module.js +190 -0
- package/dist/core/oauth-module.js.map +1 -0
- package/dist/core/pipes/pipe.decorator.d.ts +55 -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 +36 -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 +37 -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 +42 -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 +72 -0
- package/dist/core/server.d.ts.map +1 -0
- package/dist/core/server.js +406 -0
- package/dist/core/server.js.map +1 -0
- package/dist/core/tool.d.ts +78 -0
- package/dist/core/tool.d.ts.map +1 -0
- package/dist/core/tool.js +190 -0
- package/dist/core/tool.js.map +1 -0
- package/dist/core/transports/http-server.d.ts +102 -0
- package/dist/core/transports/http-server.d.ts.map +1 -0
- package/dist/core/transports/http-server.js +265 -0
- package/dist/core/transports/http-server.js.map +1 -0
- package/dist/core/types.d.ts +123 -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 +82 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +164 -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/dist/widgets/index.d.ts +9 -0
- package/dist/widgets/index.d.ts.map +1 -0
- package/dist/widgets/index.js +9 -0
- package/dist/widgets/index.js.map +1 -0
- package/dist/widgets/metadata.d.ts +53 -0
- package/dist/widgets/metadata.d.ts.map +1 -0
- package/dist/widgets/metadata.js +29 -0
- package/dist/widgets/metadata.js.map +1 -0
- package/dist/widgets/withToolData.d.ts +19 -0
- package/dist/widgets/withToolData.d.ts.map +1 -0
- package/dist/widgets/withToolData.js +240 -0
- package/dist/widgets/withToolData.js.map +1 -0
- package/jest.config.js +21 -0
- package/package.json +108 -0
- package/templates/typescript-auth/AI_AGENT_CLI_REFERENCE.md +702 -0
- package/templates/typescript-auth/AI_AGENT_SDK_REFERENCE.md +1260 -0
- package/templates/typescript-auth/README.md +400 -0
- package/templates/typescript-auth/package.json +44 -0
- package/templates/typescript-auth-api-key/AI_AGENT_CLI_REFERENCE.md +701 -0
- package/templates/typescript-auth-api-key/AI_AGENT_SDK_REFERENCE.md +1260 -0
- package/templates/typescript-auth-api-key/README.md +483 -0
- package/templates/typescript-auth-api-key/package-lock.json +124 -0
- package/templates/typescript-auth-api-key/package.json +29 -0
- package/templates/typescript-oauth/AI_AGENT_CLI_REFERENCE.md +701 -0
- package/templates/typescript-oauth/AI_AGENT_SDK_REFERENCE.md +1260 -0
- package/templates/typescript-oauth/OAUTH_SETUP.md +406 -0
- package/templates/typescript-oauth/README.md +350 -0
- package/templates/typescript-oauth/package.json +30 -0
- package/templates/typescript-starter/AI_AGENT_CLI_REFERENCE.md +701 -0
- package/templates/typescript-starter/AI_AGENT_SDK_REFERENCE.md +1260 -0
- package/templates/typescript-starter/README.md +312 -0
- package/templates/typescript-starter/package.json +32 -0
package/README.md
ADDED
|
@@ -0,0 +1,571 @@
|
|
|
1
|
+
# NitroStack v3.0 ⚡
|
|
2
|
+
|
|
3
|
+
**A NestJS-inspired framework for building production-ready MCP (Model Context Protocol) servers**
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/nitrostack)
|
|
6
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
7
|
+
[](https://nitrostack.vercel.app/)
|
|
8
|
+
[](https://nitrostack-docs.vercel.app/)
|
|
9
|
+
|
|
10
|
+
NitroStack v3.0 brings a revolutionary decorator-based architecture inspired by NestJS, making MCP server development more intuitive, maintainable, and scalable than ever before.
|
|
11
|
+
|
|
12
|
+
## 🌟 What's New in v3.0
|
|
13
|
+
|
|
14
|
+
### Decorator-Based Architecture
|
|
15
|
+
Write clean, declarative code with TypeScript decorators:
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
@Tool({
|
|
19
|
+
name: 'get_weather',
|
|
20
|
+
description: 'Get current weather',
|
|
21
|
+
inputSchema: z.object({
|
|
22
|
+
city: z.string().describe('City name')
|
|
23
|
+
})
|
|
24
|
+
})
|
|
25
|
+
@Widget('weather-card')
|
|
26
|
+
@UseGuards(JWTGuard)
|
|
27
|
+
async getWeather(input: any, ctx: ExecutionContext) {
|
|
28
|
+
return await this.weatherService.fetch(input.city);
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Modular Architecture
|
|
33
|
+
Organize your code into logical, self-contained modules:
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
@Module({
|
|
37
|
+
name: 'weather',
|
|
38
|
+
controllers: [WeatherTools],
|
|
39
|
+
providers: [WeatherService],
|
|
40
|
+
imports: [HttpModule]
|
|
41
|
+
})
|
|
42
|
+
export class WeatherModule {}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Powerful Features Out of the Box
|
|
46
|
+
|
|
47
|
+
- 🎨 **Decorator-Based Development** - `@Tool`, `@Widget`, `@Resource`, `@Prompt`, `@Module`
|
|
48
|
+
- 🔐 **Guard System** - Declarative authentication with `@UseGuards`
|
|
49
|
+
- 🔄 **Middleware & Interceptors** - Transform requests/responses
|
|
50
|
+
- 🧪 **Pipes for Validation** - NestJS-style input processing
|
|
51
|
+
- 💉 **Dependency Injection** - Built-in DI container for testability
|
|
52
|
+
- ⚡ **Caching** - `@Cache()` decorator for tool responses
|
|
53
|
+
- 🚦 **Rate Limiting** - `@RateLimit()` for API protection
|
|
54
|
+
- 🎯 **Event System** - `@OnEvent()` for event-driven architecture
|
|
55
|
+
- 🔍 **Studio** - Next.js-based visual testing environment
|
|
56
|
+
- 🤖 **AI Integration** - Test with OpenAI GPT-4 or Gemini 2.0 Flash
|
|
57
|
+
- 📦 **Type Generation** - Auto-generate types from tool definitions
|
|
58
|
+
|
|
59
|
+
## 📦 Installation
|
|
60
|
+
|
|
61
|
+
Install NitroStack globally:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
npm install -g nitrostack
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Or use with npx:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
npx nitrostack init my-mcp-server
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## 🚀 Quick Start
|
|
74
|
+
|
|
75
|
+
### 1. Create a New Server
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
nitrostack init my-ecommerce-server --template typescript-auth
|
|
79
|
+
cd my-ecommerce-server
|
|
80
|
+
npm install
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### 2. Define Your Tools
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
// src/modules/products/products.tools.ts
|
|
87
|
+
import { ToolDecorator as Tool, z, ExecutionContext } from 'nitrostack';
|
|
88
|
+
|
|
89
|
+
export class ProductsTools {
|
|
90
|
+
@Tool({
|
|
91
|
+
name: 'browse_products',
|
|
92
|
+
description: 'Browse products by category',
|
|
93
|
+
inputSchema: z.object({
|
|
94
|
+
category: z.string().optional(),
|
|
95
|
+
limit: z.number().default(10)
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
@Widget('products-grid')
|
|
99
|
+
async browseProducts(input: any, ctx: ExecutionContext) {
|
|
100
|
+
const products = await this.db.query('SELECT * FROM products WHERE category = ?', [input.category]);
|
|
101
|
+
return { products, pagination: { total: products.length } };
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### 3. Create a Module
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
// src/modules/products/products.module.ts
|
|
110
|
+
import { Module } from 'nitrostack';
|
|
111
|
+
import { ProductsTools } from './products.tools.js';
|
|
112
|
+
import { ProductsResources } from './products.resources.js';
|
|
113
|
+
import { ProductsPrompts } from './products.prompts.js';
|
|
114
|
+
|
|
115
|
+
@Module({
|
|
116
|
+
name: 'products',
|
|
117
|
+
description: 'Product management module',
|
|
118
|
+
controllers: [ProductsTools, ProductsResources, ProductsPrompts]
|
|
119
|
+
})
|
|
120
|
+
export class ProductsModule {}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### 4. Bootstrap Your Application
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
// src/app.module.ts
|
|
127
|
+
import { McpApp, Module, ConfigModule, JWTModule } from 'nitrostack';
|
|
128
|
+
import { ProductsModule } from './modules/products/products.module.js';
|
|
129
|
+
|
|
130
|
+
@McpApp({
|
|
131
|
+
server: {
|
|
132
|
+
name: 'my-ecommerce-server',
|
|
133
|
+
version: '1.0.0'
|
|
134
|
+
},
|
|
135
|
+
logging: {
|
|
136
|
+
level: 'info'
|
|
137
|
+
}
|
|
138
|
+
})
|
|
139
|
+
@Module({
|
|
140
|
+
imports: [
|
|
141
|
+
ConfigModule.forRoot(),
|
|
142
|
+
JWTModule.forRoot({
|
|
143
|
+
secret: process.env.JWT_SECRET!
|
|
144
|
+
}),
|
|
145
|
+
ProductsModule
|
|
146
|
+
]
|
|
147
|
+
})
|
|
148
|
+
export class AppModule {}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
// src/index.ts
|
|
153
|
+
import { McpApplicationFactory } from 'nitrostack';
|
|
154
|
+
import { AppModule } from './app.module.js';
|
|
155
|
+
|
|
156
|
+
McpApplicationFactory.create(AppModule);
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### 5. Start Development
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
nitrostack dev
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Studio opens at `http://localhost:3000` - test your tools with AI chat! 🎉
|
|
166
|
+
|
|
167
|
+
## 🎯 Core Concepts
|
|
168
|
+
|
|
169
|
+
### Decorators
|
|
170
|
+
|
|
171
|
+
NitroStack v3.0 uses decorators for clean, declarative code:
|
|
172
|
+
|
|
173
|
+
| Decorator | Purpose | Example |
|
|
174
|
+
|-----------|---------|---------|
|
|
175
|
+
| `@Tool` | Define MCP tools | `@Tool({ name: 'get_user' })` |
|
|
176
|
+
| `@Widget` | Attach UI component | `@Widget('user-card')` |
|
|
177
|
+
| `@Resource` | Define data resources | `@Resource({ uri: 'user://{id}' })` |
|
|
178
|
+
| `@Prompt` | Create prompt templates | `@Prompt({ name: 'review-code' })` |
|
|
179
|
+
| `@Module` | Organize code | `@Module({ name: 'users' })` |
|
|
180
|
+
| `@UseGuards` | Add authentication | `@UseGuards(JWTGuard)` |
|
|
181
|
+
| `@UseMiddleware` | Apply middleware | `@UseMiddleware(LoggingMiddleware)` |
|
|
182
|
+
| `@UseInterceptors` | Transform responses | `@UseInterceptors(TransformInterceptor)` |
|
|
183
|
+
| `@UsePipes` | Validate inputs | `@UsePipes(ValidationPipe)` |
|
|
184
|
+
| `@Cache` | Cache responses | `@Cache({ ttl: 300 })` |
|
|
185
|
+
| `@RateLimit` | Limit requests | `@RateLimit({ requests: 10 })` |
|
|
186
|
+
| `@Injectable` | Mark as service | `@Injectable()` |
|
|
187
|
+
| `@OnEvent` | Listen to events | `@OnEvent('user.created')` |
|
|
188
|
+
|
|
189
|
+
### Dependency Injection
|
|
190
|
+
|
|
191
|
+
Use constructor injection for cleaner, testable code:
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
@Injectable()
|
|
195
|
+
export class UserService {
|
|
196
|
+
constructor(private db: DatabaseService) {}
|
|
197
|
+
|
|
198
|
+
async findUser(id: string) {
|
|
199
|
+
return this.db.query('SELECT * FROM users WHERE id = ?', [id]);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export class UserTools {
|
|
204
|
+
constructor(private userService: UserService) {}
|
|
205
|
+
|
|
206
|
+
@Tool({ name: 'get_user' })
|
|
207
|
+
async getUser(input: any) {
|
|
208
|
+
return this.userService.findUser(input.id);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Guards
|
|
214
|
+
|
|
215
|
+
Declarative authentication:
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
export class JWTGuard implements Guard {
|
|
219
|
+
async canActivate(context: ExecutionContext): Promise<boolean> {
|
|
220
|
+
const token = context.auth?.token;
|
|
221
|
+
if (!token) return false;
|
|
222
|
+
|
|
223
|
+
const payload = verifyJWT(token);
|
|
224
|
+
context.auth = { subject: payload.sub };
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
@Tool({ name: 'create_order' })
|
|
230
|
+
@UseGuards(JWTGuard) // ← Auth required!
|
|
231
|
+
async createOrder(input: any, ctx: ExecutionContext) {
|
|
232
|
+
const userId = ctx.auth?.subject;
|
|
233
|
+
// ...
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Middleware
|
|
238
|
+
|
|
239
|
+
Cross-cutting concerns:
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
@Middleware()
|
|
243
|
+
export class LoggingMiddleware implements MiddlewareInterface {
|
|
244
|
+
async use(context: ExecutionContext, next: () => Promise<any>) {
|
|
245
|
+
console.log(`[${context.toolName}] Started`);
|
|
246
|
+
const result = await next();
|
|
247
|
+
console.log(`[${context.toolName}] Completed`);
|
|
248
|
+
return result;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Interceptors
|
|
254
|
+
|
|
255
|
+
Transform requests/responses:
|
|
256
|
+
|
|
257
|
+
```typescript
|
|
258
|
+
@Interceptor()
|
|
259
|
+
export class TransformInterceptor implements InterceptorInterface {
|
|
260
|
+
async intercept(context: ExecutionContext, next: () => Promise<any>) {
|
|
261
|
+
const result = await next();
|
|
262
|
+
return {
|
|
263
|
+
success: true,
|
|
264
|
+
data: result,
|
|
265
|
+
timestamp: new Date().toISOString()
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### Widgets
|
|
272
|
+
|
|
273
|
+
Create beautiful UIs for your tools:
|
|
274
|
+
|
|
275
|
+
```typescript
|
|
276
|
+
@Tool({
|
|
277
|
+
name: 'get_product',
|
|
278
|
+
description: 'Get product details',
|
|
279
|
+
inputSchema: z.object({
|
|
280
|
+
id: z.string()
|
|
281
|
+
}),
|
|
282
|
+
examples: {
|
|
283
|
+
response: {
|
|
284
|
+
id: 'prod-1',
|
|
285
|
+
name: 'Awesome Product',
|
|
286
|
+
price: 99.99
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
})
|
|
290
|
+
@Widget('product-card')
|
|
291
|
+
async getProduct(input: any) {
|
|
292
|
+
return await this.db.getProduct(input.id);
|
|
293
|
+
}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
```tsx
|
|
297
|
+
// src/widgets/app/product-card/page.tsx
|
|
298
|
+
'use client';
|
|
299
|
+
import { withToolData } from 'nitrostack/widgets';
|
|
300
|
+
|
|
301
|
+
function ProductCard({ data }) {
|
|
302
|
+
return (
|
|
303
|
+
<div className="product-card">
|
|
304
|
+
<h2>{data.name}</h2>
|
|
305
|
+
<p className="price">${data.price}</p>
|
|
306
|
+
</div>
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
export default withToolData(ProductCard);
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
## 🛠️ CLI Commands
|
|
314
|
+
|
|
315
|
+
### Initialize Project
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
nitrostack init <project-name> [--template typescript|typescript-auth]
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### Development Mode
|
|
322
|
+
|
|
323
|
+
```bash
|
|
324
|
+
nitrostack dev [--port 3001]
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
Starts Studio + MCP server with hot reload
|
|
328
|
+
|
|
329
|
+
### Build for Production
|
|
330
|
+
|
|
331
|
+
```bash
|
|
332
|
+
nitrostack build
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
### Generate Code
|
|
336
|
+
|
|
337
|
+
```bash
|
|
338
|
+
# Generate types from tools
|
|
339
|
+
nitrostack generate types [--output src/types/tools.ts]
|
|
340
|
+
|
|
341
|
+
# Generate module
|
|
342
|
+
nitrostack generate module payments
|
|
343
|
+
|
|
344
|
+
# Generate tool
|
|
345
|
+
nitrostack generate tool create-payment --module payments
|
|
346
|
+
|
|
347
|
+
# Generate guard
|
|
348
|
+
nitrostack generate guard admin
|
|
349
|
+
|
|
350
|
+
# Generate middleware
|
|
351
|
+
nitrostack generate middleware logging
|
|
352
|
+
|
|
353
|
+
# Generate interceptor
|
|
354
|
+
nitrostack generate interceptor transform
|
|
355
|
+
|
|
356
|
+
# Generate pipe
|
|
357
|
+
nitrostack generate pipe validation
|
|
358
|
+
|
|
359
|
+
# Generate filter
|
|
360
|
+
nitrostack generate filter exception
|
|
361
|
+
|
|
362
|
+
# Generate service
|
|
363
|
+
nitrostack generate service email
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
## 🔍 Studio
|
|
367
|
+
|
|
368
|
+
NitroStack Studio is a Next.js-based testing environment:
|
|
369
|
+
|
|
370
|
+
### Features
|
|
371
|
+
|
|
372
|
+
- 🤖 **AI Chat** - Test with GPT-4 or Gemini 2.0 Flash
|
|
373
|
+
- 🎨 **Widget Preview** - See UI components in action
|
|
374
|
+
- 🔧 **Tool Testing** - Execute tools with dynamic forms
|
|
375
|
+
- 📊 **Resource Browser** - View all resources
|
|
376
|
+
- 🎯 **Prompt Explorer** - Test prompts with arguments
|
|
377
|
+
- 🌓 **Dark/Light Theme** - Beautiful black & gold design
|
|
378
|
+
|
|
379
|
+
### Supported LLMs
|
|
380
|
+
|
|
381
|
+
- **OpenAI GPT-4** - Industry standard, excellent tool calling
|
|
382
|
+
- **Gemini 2.0 Flash** - Free experimental, 1M token context
|
|
383
|
+
|
|
384
|
+
### Usage
|
|
385
|
+
|
|
386
|
+
```bash
|
|
387
|
+
nitrostack dev
|
|
388
|
+
# Opens http://localhost:3000
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
## 🔐 Authentication
|
|
392
|
+
|
|
393
|
+
NitroStack v3.0 supports multiple auth strategies:
|
|
394
|
+
|
|
395
|
+
### JWT (Recommended)
|
|
396
|
+
|
|
397
|
+
```typescript
|
|
398
|
+
@Module({
|
|
399
|
+
imports: [
|
|
400
|
+
JWTModule.forRoot({
|
|
401
|
+
secret: process.env.JWT_SECRET!,
|
|
402
|
+
expiresIn: '1h'
|
|
403
|
+
})
|
|
404
|
+
]
|
|
405
|
+
})
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
### OAuth 2.1
|
|
409
|
+
|
|
410
|
+
Full OAuth 2.1 compliance with PKCE for enterprise apps
|
|
411
|
+
|
|
412
|
+
### API Keys
|
|
413
|
+
|
|
414
|
+
Simple key-based authentication for service-to-service
|
|
415
|
+
|
|
416
|
+
### Guards
|
|
417
|
+
|
|
418
|
+
```typescript
|
|
419
|
+
@Tool({ name: 'admin_tool' })
|
|
420
|
+
@UseGuards(AdminGuard, JWTGuard)
|
|
421
|
+
async adminTool() {
|
|
422
|
+
// Only admins can access
|
|
423
|
+
}
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
## 📦 Type Safety
|
|
427
|
+
|
|
428
|
+
Auto-generate TypeScript types from your tools:
|
|
429
|
+
|
|
430
|
+
```bash
|
|
431
|
+
nitrostack generate types
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
Generated output:
|
|
435
|
+
|
|
436
|
+
```typescript
|
|
437
|
+
// src/types/generated-tools.ts
|
|
438
|
+
export type GetProductInput = {
|
|
439
|
+
id: string;
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
export type GetProductOutput = {
|
|
443
|
+
id: string;
|
|
444
|
+
name: string;
|
|
445
|
+
price: number;
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
export interface ToolInputs {
|
|
449
|
+
'get_product': GetProductInput;
|
|
450
|
+
// ...
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
export interface ToolOutputs {
|
|
454
|
+
'get_product': GetProductOutput;
|
|
455
|
+
// ...
|
|
456
|
+
}
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
Use in widgets:
|
|
460
|
+
|
|
461
|
+
```typescript
|
|
462
|
+
import { GetProductOutput } from '../../types/generated-tools';
|
|
463
|
+
|
|
464
|
+
function ProductCard({ data }: { data: GetProductOutput }) {
|
|
465
|
+
// Fully typed!
|
|
466
|
+
}
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
## 🧪 Testing
|
|
470
|
+
|
|
471
|
+
NitroStack includes testing utilities:
|
|
472
|
+
|
|
473
|
+
```typescript
|
|
474
|
+
import { TestingModule, createMockContext } from 'nitrostack/testing';
|
|
475
|
+
|
|
476
|
+
describe('ProductsTools', () => {
|
|
477
|
+
let module: TestingModule;
|
|
478
|
+
|
|
479
|
+
beforeAll(async () => {
|
|
480
|
+
module = await TestingModule.create({
|
|
481
|
+
controllers: [ProductsTools],
|
|
482
|
+
providers: [DatabaseService]
|
|
483
|
+
}).compile();
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
it('should get product', async () => {
|
|
487
|
+
const tool = module.get(ProductsTools);
|
|
488
|
+
const ctx = createMockContext();
|
|
489
|
+
const result = await tool.getProduct({ id: '1' }, ctx);
|
|
490
|
+
expect(result.name).toBeDefined();
|
|
491
|
+
});
|
|
492
|
+
});
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
## 📚 Documentation
|
|
496
|
+
|
|
497
|
+
**📖 Full documentation available at: [https://nitrostack-docs.vercel.app/](https://nitrostack-docs.vercel.app/)**
|
|
498
|
+
|
|
499
|
+
Quick Links:
|
|
500
|
+
- [Getting Started](https://nitrostack-docs.vercel.app/intro)
|
|
501
|
+
- [Installation](https://nitrostack-docs.vercel.app/installation)
|
|
502
|
+
- [Quick Start](https://nitrostack-docs.vercel.app/quick-start)
|
|
503
|
+
- [Tools Guide](https://nitrostack-docs.vercel.app/sdk/typescript/tools)
|
|
504
|
+
- [Widgets Guide](https://nitrostack-docs.vercel.app/sdk/typescript/ui/widgets)
|
|
505
|
+
- [Authentication (JWT, OAuth, API Keys)](https://nitrostack-docs.vercel.app/sdk/typescript/auth/overview)
|
|
506
|
+
- [CLI Reference](https://nitrostack-docs.vercel.app/cli/overview)
|
|
507
|
+
- [API Reference](https://nitrostack-docs.vercel.app/api/decorators)
|
|
508
|
+
- [Templates](https://nitrostack-docs.vercel.app/templates/starter)
|
|
509
|
+
- [Deployment](https://nitrostack-docs.vercel.app/deployment/checklist)
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
## 🚢 Deployment
|
|
514
|
+
|
|
515
|
+
### Build
|
|
516
|
+
|
|
517
|
+
```bash
|
|
518
|
+
npm run build
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
### Run
|
|
522
|
+
|
|
523
|
+
```bash
|
|
524
|
+
NODE_ENV=production node dist/index.js
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
### Docker
|
|
528
|
+
|
|
529
|
+
```dockerfile
|
|
530
|
+
FROM node:20-alpine
|
|
531
|
+
WORKDIR /app
|
|
532
|
+
COPY package*.json ./
|
|
533
|
+
RUN npm ci --production
|
|
534
|
+
COPY dist ./dist
|
|
535
|
+
CMD ["node", "dist/index.js"]
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
## 🤝 Contributing
|
|
539
|
+
|
|
540
|
+
We welcome contributions! See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.
|
|
541
|
+
|
|
542
|
+
By contributing, you agree that your contributions will be licensed under the Apache License 2.0.
|
|
543
|
+
|
|
544
|
+
## 📝 License
|
|
545
|
+
|
|
546
|
+
This project is licensed under the **Apache License 2.0** - see the [LICENSE](./LICENSE) file for details.
|
|
547
|
+
|
|
548
|
+
Copyright 2025 Abhishek Pandit
|
|
549
|
+
|
|
550
|
+
## 🔗 Links
|
|
551
|
+
|
|
552
|
+
- **Website**: [https://nitrostack.vercel.app/](https://nitrostack.vercel.app/)
|
|
553
|
+
- **Documentation**: [https://nitrostack-docs.vercel.app/](https://nitrostack-docs.vercel.app/)
|
|
554
|
+
- **GitHub**: [https://github.com/abhishekpanditofficial/nitrostack](https://github.com/abhishekpanditofficial/nitrostack)
|
|
555
|
+
- **npm Package**: [https://www.npmjs.com/package/nitrostack](https://www.npmjs.com/package/nitrostack)
|
|
556
|
+
- **Model Context Protocol**: [https://modelcontextprotocol.io](https://modelcontextprotocol.io)
|
|
557
|
+
|
|
558
|
+
## 🙏 Acknowledgments
|
|
559
|
+
|
|
560
|
+
Built with:
|
|
561
|
+
- [Model Context Protocol SDK](https://www.npmjs.com/package/@modelcontextprotocol/sdk)
|
|
562
|
+
- [Zod](https://zod.dev)
|
|
563
|
+
- [Next.js](https://nextjs.org)
|
|
564
|
+
- [React](https://react.dev)
|
|
565
|
+
- [TypeScript](https://www.typescriptlang.org)
|
|
566
|
+
|
|
567
|
+
---
|
|
568
|
+
|
|
569
|
+
**Made with ⚡ by the NitroStack team**
|
|
570
|
+
|
|
571
|
+
*Star us on GitHub!* ⭐
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { RequestHandler } from 'express';
|
|
2
|
+
/**
|
|
3
|
+
* API Key Authentication
|
|
4
|
+
*
|
|
5
|
+
* Simple authentication for basic scenarios.
|
|
6
|
+
* Perfect for service-to-service communication or development.
|
|
7
|
+
*/
|
|
8
|
+
export interface APIKeyConfig {
|
|
9
|
+
/**
|
|
10
|
+
* Array of valid API keys
|
|
11
|
+
* Can be plain strings or hashed values
|
|
12
|
+
*/
|
|
13
|
+
keys: string[];
|
|
14
|
+
/**
|
|
15
|
+
* If true, keys are stored as SHA-256 hashes (recommended)
|
|
16
|
+
*/
|
|
17
|
+
hashed?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Header name to extract API key from
|
|
20
|
+
* Default: 'X-API-Key'
|
|
21
|
+
*/
|
|
22
|
+
headerName?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Also accept API key in query parameter?
|
|
25
|
+
* Default: false (not recommended for production)
|
|
26
|
+
*/
|
|
27
|
+
allowQueryParam?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Query parameter name
|
|
30
|
+
* Default: 'api_key'
|
|
31
|
+
*/
|
|
32
|
+
queryParamName?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Custom key validation
|
|
35
|
+
*/
|
|
36
|
+
customValidation?: (key: string) => Promise<boolean> | boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Create API Key authentication middleware
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const server = createServer({...});
|
|
44
|
+
*
|
|
45
|
+
* // Simple API key auth
|
|
46
|
+
* server.app.use('/mcp', createAPIKeyAuth({
|
|
47
|
+
* keys: [
|
|
48
|
+
* process.env.API_KEY_1!,
|
|
49
|
+
* process.env.API_KEY_2!,
|
|
50
|
+
* ],
|
|
51
|
+
* headerName: 'X-API-Key',
|
|
52
|
+
* }));
|
|
53
|
+
*
|
|
54
|
+
* server.start();
|
|
55
|
+
*
|
|
56
|
+
* // Client usage:
|
|
57
|
+
* // curl -H "X-API-Key: your-api-key" https://mcp.example.com/mcp/tools
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare function createAPIKeyAuth(config: APIKeyConfig): RequestHandler;
|
|
61
|
+
/**
|
|
62
|
+
* Generate a secure API key
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const apiKey = generateAPIKey();
|
|
67
|
+
* console.log('API Key:', apiKey);
|
|
68
|
+
* // Save to .env: API_KEY_1=sk_...
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export declare function generateAPIKey(prefix?: string): string;
|
|
72
|
+
/**
|
|
73
|
+
* Hash an API key (SHA-256)
|
|
74
|
+
* Use this to store hashed keys instead of plain text
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const apiKey = 'sk_abc123...';
|
|
79
|
+
* const hashed = hashAPIKey(apiKey);
|
|
80
|
+
* // Store hashed in database
|
|
81
|
+
*
|
|
82
|
+
* // In config:
|
|
83
|
+
* createAPIKeyAuth({
|
|
84
|
+
* keys: [hashed],
|
|
85
|
+
* hashed: true,
|
|
86
|
+
* });
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export declare function hashAPIKey(key: string): string;
|
|
90
|
+
/**
|
|
91
|
+
* Validate API key format
|
|
92
|
+
*/
|
|
93
|
+
export declare function isValidAPIKeyFormat(key: string, prefix?: string): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Create API key with metadata (advanced)
|
|
96
|
+
*/
|
|
97
|
+
export interface APIKeyWithMetadata {
|
|
98
|
+
key: string;
|
|
99
|
+
hashed: string;
|
|
100
|
+
name: string;
|
|
101
|
+
createdAt: Date;
|
|
102
|
+
expiresAt?: Date;
|
|
103
|
+
scopes?: string[];
|
|
104
|
+
}
|
|
105
|
+
export declare function generateAPIKeyWithMetadata(options: {
|
|
106
|
+
name: string;
|
|
107
|
+
prefix?: string;
|
|
108
|
+
expiresIn?: number;
|
|
109
|
+
scopes?: string[];
|
|
110
|
+
}): APIKeyWithMetadata;
|
|
111
|
+
/**
|
|
112
|
+
* Validate API key with metadata (expiration, scopes)
|
|
113
|
+
*/
|
|
114
|
+
export declare function validateAPIKeyWithMetadata(key: string, metadata: Omit<APIKeyWithMetadata, 'key'>, requiredScopes?: string[]): {
|
|
115
|
+
valid: boolean;
|
|
116
|
+
reason?: string;
|
|
117
|
+
};
|
|
118
|
+
//# sourceMappingURL=api-key.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-key.d.ts","sourceRoot":"","sources":["../../src/auth/api-key.ts"],"names":[],"mappings":"AACA,OAAO,EAAmC,cAAc,EAAE,MAAM,SAAS,CAAC;AAE1E;;;;;GAKG;AAEH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,IAAI,EAAE,MAAM,EAAE,CAAC;IAEf;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,gBAAgB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;CAChE;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,GAAG,cAAc,CA2ErE;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,MAAM,GAAE,MAAa,GAAG,MAAM,CAI5D;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAKzE;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB,GAAG,kBAAkB,CAmBrB;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,IAAI,CAAC,kBAAkB,EAAE,KAAK,CAAC,EACzC,cAAc,CAAC,EAAE,MAAM,EAAE,GACxB;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAiBrC"}
|