@vurb/api-key 3.14.5 → 3.14.7

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.
Files changed (2) hide show
  1. package/README.md +90 -90
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,90 +1,90 @@
1
- <p align="center">
2
- <h1 align="center">@vurb/api-key</h1>
3
- <p align="center">
4
- <strong>MCP API Key Authentication for Vurb.ts</strong> — A framework for creating secure MCP servers<br/>
5
- Timing-safe API key validation · SHA-256 hashing · Async validators · Self-healing error responses
6
- </p>
7
- </p>
8
-
9
- <p align="center">
10
- <a href="https://www.npmjs.com/package/@vurb/api-key"><img src="https://img.shields.io/npm/v/@vurb/api-key?color=blue" alt="npm" /></a>
11
- <a href="https://github.com/vinkius-labs/vurb.ts/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-green" alt="License" /></a>
12
- <img src="https://img.shields.io/badge/node-%3E%3D18-brightgreen" alt="Node" />
13
- <a href="https://modelcontextprotocol.io/"><img src="https://img.shields.io/badge/MCP-compatible-purple" alt="MCP" /></a>
14
- <a href="https://vurb.vinkius.com/"><img src="https://img.shields.io/badge/Vurb.ts-framework-0ea5e9" alt="Vurb.ts" /></a>
15
- </p>
16
-
17
- ---
18
-
19
- > **MCP API Key Authentication for Vurb.ts** — the Model Context Protocol framework for building production MCP servers. Timing-safe key comparison, SHA-256 hashing, async validators, and self-healing error responses.
20
-
21
- ## Quick Start
22
-
23
- ```typescript
24
- import { initVurb } from '@vurb/core';
25
- import { apiKeyGuard } from '@vurb/api-key';
26
-
27
- const f = initVurb<AppContext>();
28
-
29
- const withApiKey = apiKeyGuard({
30
- keys: [process.env.API_KEY!],
31
- header: 'x-api-key',
32
- });
33
-
34
- export default f.query('data.export')
35
- .use(withApiKey)
36
- .handle(async (input, ctx) => {
37
- return db.records.findMany();
38
- });
39
- ```
40
-
41
- ## Features
42
-
43
- | Feature | Description |
44
- |---------|-------------|
45
- | **Timing-Safe** | Constant-time key comparison prevents timing attacks |
46
- | **SHA-256 Hashing** | Store hashed keys instead of plaintext |
47
- | **Async Validators** | Validate keys against a database or external service |
48
- | **Self-Healing** | Missing/invalid keys return actionable hints to the LLM agent |
49
- | **Key Rotation** | Support multiple keys for seamless rotation |
50
-
51
- ## SHA-256 Hashed Keys
52
-
53
- ```typescript
54
- const withApiKey = apiKeyGuard({
55
- hashedKeys: ['a1b2c3...'], // SHA-256 hash of the actual key
56
- algorithm: 'sha256',
57
- });
58
- ```
59
-
60
- ## Async Validator
61
-
62
- ```typescript
63
- const withApiKey = apiKeyGuard({
64
- validate: async (key) => {
65
- const record = await db.apiKeys.findUnique({ where: { key } });
66
- return record !== null && record.revokedAt === null;
67
- },
68
- });
69
- ```
70
-
71
- ## Installation
72
-
73
- ```bash
74
- npm install @vurb/api-key
75
- ```
76
-
77
- ### Peer Dependencies
78
-
79
- | Package | Version |
80
- |---------|---------|
81
- | `vurb` | `^2.0.0` |
82
-
83
- ## Requirements
84
-
85
- - **Node.js** ≥ 18.0.0
86
- - **Vurb.ts** ≥ 2.0.0 (peer dependency)
87
-
88
- ## License
89
-
90
- [Apache-2.0](https://github.com/vinkius-labs/vurb.ts/blob/main/LICENSE)
1
+ <p align="center">
2
+ <h1 align="center">@vurb/api-key</h1>
3
+ <p align="center">
4
+ <strong>MCP API Key Authentication for Vurb.ts</strong> — A framework for creating secure MCP servers<br/>
5
+ Timing-safe API key validation · SHA-256 hashing · Async validators · Self-healing error responses
6
+ </p>
7
+ </p>
8
+
9
+ <p align="center">
10
+ <a href="https://www.npmjs.com/package/@vurb/api-key"><img src="https://img.shields.io/npm/v/@vurb/api-key?color=blue" alt="npm" /></a>
11
+ <a href="https://github.com/vinkius-labs/vurb.ts/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-green" alt="License" /></a>
12
+ <img src="https://img.shields.io/badge/node-%3E%3D18-brightgreen" alt="Node" />
13
+ <a href="https://modelcontextprotocol.io/"><img src="https://img.shields.io/badge/MCP-compatible-purple" alt="MCP" /></a>
14
+ <a href="https://vurb.vinkius.com/"><img src="https://img.shields.io/badge/Vurb.ts-framework-0ea5e9" alt="Vurb.ts" /></a>
15
+ </p>
16
+
17
+ ---
18
+
19
+ > **MCP API Key Authentication for Vurb.ts** — the Model Context Protocol framework for building production MCP servers. Timing-safe key comparison, SHA-256 hashing, async validators, and self-healing error responses.
20
+
21
+ ## Quick Start
22
+
23
+ ```typescript
24
+ import { initVurb } from '@vurb/core';
25
+ import { apiKeyGuard } from '@vurb/api-key';
26
+
27
+ const f = initVurb<AppContext>();
28
+
29
+ const withApiKey = apiKeyGuard({
30
+ keys: [process.env.API_KEY!],
31
+ header: 'x-api-key',
32
+ });
33
+
34
+ export default f.query('data.export')
35
+ .use(withApiKey)
36
+ .handle(async (input, ctx) => {
37
+ return db.records.findMany();
38
+ });
39
+ ```
40
+
41
+ ## Features
42
+
43
+ | Feature | Description |
44
+ |---------|-------------|
45
+ | **Timing-Safe** | Constant-time key comparison prevents timing attacks |
46
+ | **SHA-256 Hashing** | Store hashed keys instead of plaintext |
47
+ | **Async Validators** | Validate keys against a database or external service |
48
+ | **Self-Healing** | Missing/invalid keys return actionable hints to the LLM agent |
49
+ | **Key Rotation** | Support multiple keys for seamless rotation |
50
+
51
+ ## SHA-256 Hashed Keys
52
+
53
+ ```typescript
54
+ const withApiKey = apiKeyGuard({
55
+ hashedKeys: ['a1b2c3...'], // SHA-256 hash of the actual key
56
+ algorithm: 'sha256',
57
+ });
58
+ ```
59
+
60
+ ## Async Validator
61
+
62
+ ```typescript
63
+ const withApiKey = apiKeyGuard({
64
+ validate: async (key) => {
65
+ const record = await db.apiKeys.findUnique({ where: { key } });
66
+ return record !== null && record.revokedAt === null;
67
+ },
68
+ });
69
+ ```
70
+
71
+ ## Installation
72
+
73
+ ```bash
74
+ npm install @vurb/api-key
75
+ ```
76
+
77
+ ### Peer Dependencies
78
+
79
+ | Package | Version |
80
+ |---------|---------|
81
+ | `vurb` | `^2.0.0` |
82
+
83
+ ## Requirements
84
+
85
+ - **Node.js** ≥ 18.0.0
86
+ - **Vurb.ts** ≥ 2.0.0 (peer dependency)
87
+
88
+ ## License
89
+
90
+ [Apache-2.0](https://github.com/vinkius-labs/vurb.ts/blob/main/LICENSE)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vurb/api-key",
3
- "version": "3.14.5",
3
+ "version": "3.14.7",
4
4
  "description": "API key validation middleware for MCP servers built with vurb. Timing-safe comparison, SHA-256 hashing, async validators, and self-healing error responses.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",