buzzster 1.0.0 → 1.0.2
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/.env.example +1 -1
- package/README.md +22 -22
- package/SKILL.md +51 -51
- package/client.js +4 -4
- package/index.js +6 -6
- package/middleware.js +6 -6
- package/package.json +2 -2
- package/rules.js +1 -1
- package/setup.sh +8 -8
package/.env.example
CHANGED
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Buzzster Client
|
|
2
2
|
|
|
3
3
|
Express middleware to protect your routes with agent authentication.
|
|
4
4
|
|
|
5
5
|
## What It Does
|
|
6
6
|
|
|
7
7
|
- **Blocks browsers** (User-Agent detection)
|
|
8
|
-
- **Verifies tokens** with central
|
|
8
|
+
- **Verifies tokens** with central Buzzster API
|
|
9
9
|
- **Caches verification** locally (30s default) to reduce API calls
|
|
10
10
|
- **Attaches agent info** to req.agent
|
|
11
11
|
- **Returns helpful error messages**
|
|
@@ -13,26 +13,26 @@ Express middleware to protect your routes with agent authentication.
|
|
|
13
13
|
## Installation
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
npm install
|
|
16
|
+
npm install buzzster-client
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
## Quick Start
|
|
20
20
|
|
|
21
21
|
```javascript
|
|
22
22
|
const express = require('express');
|
|
23
|
-
const
|
|
23
|
+
const Buzzster = require('buzzster-client');
|
|
24
24
|
|
|
25
25
|
const app = express();
|
|
26
26
|
|
|
27
27
|
// Create middleware
|
|
28
|
-
const
|
|
29
|
-
apiUrl: '
|
|
28
|
+
const buzzster = new Buzzster({
|
|
29
|
+
apiUrl: 'https://api.buzzster.xyz', // Central API
|
|
30
30
|
blockBrowsers: true,
|
|
31
31
|
enforceAuthentication: true
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
// Apply to all routes
|
|
35
|
-
app.use(
|
|
35
|
+
app.use(buzzster);
|
|
36
36
|
|
|
37
37
|
// Now only agents can access
|
|
38
38
|
app.get('/api/secret', (req, res) => {
|
|
@@ -48,9 +48,9 @@ app.listen(8080);
|
|
|
48
48
|
## Configuration Options
|
|
49
49
|
|
|
50
50
|
```javascript
|
|
51
|
-
const
|
|
51
|
+
const buzzster = new Buzzster({
|
|
52
52
|
// Required
|
|
53
|
-
apiUrl: '
|
|
53
|
+
apiUrl: 'https://api.buzzster.xyz',
|
|
54
54
|
|
|
55
55
|
// Optional
|
|
56
56
|
blockBrowsers: true, // Block User-Agent that look like browsers
|
|
@@ -100,7 +100,7 @@ Reduces API calls during request burst
|
|
|
100
100
|
|
|
101
101
|
```javascript
|
|
102
102
|
const express = require('express');
|
|
103
|
-
const
|
|
103
|
+
const Buzzster = require('buzzster-client');
|
|
104
104
|
|
|
105
105
|
const app = express();
|
|
106
106
|
const publicRoutes = require('./routes/public');
|
|
@@ -109,9 +109,9 @@ const agentOnlyRoutes = require('./routes/agent-only');
|
|
|
109
109
|
// Public routes (no auth)
|
|
110
110
|
app.use('/public', publicRoutes);
|
|
111
111
|
|
|
112
|
-
// Apply
|
|
113
|
-
const
|
|
114
|
-
app.use('/api',
|
|
112
|
+
// Apply Buzzster middleware
|
|
113
|
+
const buzzster = new Buzzster('https://api.buzzster.xyz');
|
|
114
|
+
app.use('/api', buzzster, agentOnlyRoutes);
|
|
115
115
|
|
|
116
116
|
app.listen(8080);
|
|
117
117
|
```
|
|
@@ -119,10 +119,10 @@ app.listen(8080);
|
|
|
119
119
|
### Custom Error Handling
|
|
120
120
|
|
|
121
121
|
```javascript
|
|
122
|
-
const
|
|
122
|
+
const buzzster = new Buzzster('https://api.buzzster.xyz');
|
|
123
123
|
|
|
124
124
|
app.use((req, res, next) => {
|
|
125
|
-
|
|
125
|
+
buzzster(req, res, (err) => {
|
|
126
126
|
if (err) {
|
|
127
127
|
// Custom error handling
|
|
128
128
|
console.error('Auth error:', err);
|
|
@@ -228,16 +228,16 @@ By default, token verification results are cached for 30 seconds:
|
|
|
228
228
|
// during request bursts
|
|
229
229
|
|
|
230
230
|
// Clear all cache
|
|
231
|
-
|
|
231
|
+
buzzster.clearCache();
|
|
232
232
|
|
|
233
233
|
// Clear specific token
|
|
234
|
-
|
|
234
|
+
buzzster.clearCacheEntry(agentId, token);
|
|
235
235
|
```
|
|
236
236
|
|
|
237
237
|
## Performance Notes
|
|
238
238
|
|
|
239
239
|
- **Local validation:** User-Agent check (instant, no API call)
|
|
240
|
-
- **First request:** API call to central
|
|
240
|
+
- **First request:** API call to central Buzzster server (~5-50ms)
|
|
241
241
|
- **Cached requests:** Served from local cache (<1ms)
|
|
242
242
|
- **Cache hit rate:** ~95% for typical agents
|
|
243
243
|
|
|
@@ -283,10 +283,10 @@ describe('Protected endpoint', () => {
|
|
|
283
283
|
### "Cannot connect to central API"
|
|
284
284
|
```javascript
|
|
285
285
|
// Check API URL
|
|
286
|
-
const
|
|
286
|
+
const buzzster = new Buzzster('https://api.buzzster.xyz');
|
|
287
287
|
|
|
288
288
|
// Verify API is running
|
|
289
|
-
curl
|
|
289
|
+
curl https://api.buzzster.xyz/health
|
|
290
290
|
```
|
|
291
291
|
|
|
292
292
|
### "Token always invalid"
|
|
@@ -321,5 +321,5 @@ MIT
|
|
|
321
321
|
|
|
322
322
|
- 📖 [SKILL.md](../SKILL.md) — Full developer guide
|
|
323
323
|
- 🏗️ [ARCHITECTURE.md](../ARCHITECTURE.md) — System design
|
|
324
|
-
- 🛡️ [
|
|
325
|
-
- 🔗 GitHub: https://github.com/openclaw/
|
|
324
|
+
- 🛡️ [buzzster-api](../buzzster-api) — Central API server
|
|
325
|
+
- 🔗 GitHub: https://github.com/openclaw/buzzster
|
package/SKILL.md
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
2
|
+
name: buzzster-client
|
|
3
3
|
version: 3.0.0
|
|
4
4
|
description: Express middleware to protect your APIs with agent authentication.
|
|
5
|
-
homepage: https://github.com/openclaw/
|
|
6
|
-
metadata: {"
|
|
5
|
+
homepage: https://github.com/openclaw/buzzster
|
|
6
|
+
metadata: {"buzzster-client":{"emoji":"🔒","category":"security"}}
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
#
|
|
9
|
+
# Buzzster Client 🔒 SKILL.md
|
|
10
10
|
|
|
11
11
|
**For Developers:** How to protect your APIs with agent-only authentication.
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
-
## What Is
|
|
15
|
+
## What Is buzzster-client?
|
|
16
16
|
|
|
17
17
|
An Express middleware that:
|
|
18
18
|
1. **Blocks browsers** (User-Agent detection)
|
|
19
|
-
2. **Verifies tokens** with central
|
|
19
|
+
2. **Verifies tokens** with central Buzzster API
|
|
20
20
|
3. **Caches verification** locally (30s, reduces API load)
|
|
21
21
|
4. **Attaches agent info** to `req.agent`
|
|
22
22
|
5. **Returns helpful errors**
|
|
@@ -28,7 +28,7 @@ An Express middleware that:
|
|
|
28
28
|
## Installation
|
|
29
29
|
|
|
30
30
|
```bash
|
|
31
|
-
npm install
|
|
31
|
+
npm install buzzster-client
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
---
|
|
@@ -39,15 +39,15 @@ npm install biofirewall-client
|
|
|
39
39
|
|
|
40
40
|
```javascript
|
|
41
41
|
const express = require('express');
|
|
42
|
-
const
|
|
42
|
+
const Buzzster = require('buzzster-client');
|
|
43
43
|
|
|
44
44
|
const app = express();
|
|
45
45
|
|
|
46
46
|
// Create middleware
|
|
47
|
-
const
|
|
47
|
+
const buzzster = new Buzzster('https://api.buzzster.xyz');
|
|
48
48
|
|
|
49
49
|
// Protect all routes
|
|
50
|
-
app.use(
|
|
50
|
+
app.use(buzzster);
|
|
51
51
|
|
|
52
52
|
// Now only agents can access
|
|
53
53
|
app.get('/api/secret', (req, res) => {
|
|
@@ -82,9 +82,9 @@ curl http://localhost:8080/api/secret \
|
|
|
82
82
|
## Configuration
|
|
83
83
|
|
|
84
84
|
```javascript
|
|
85
|
-
const
|
|
85
|
+
const buzzster = new Buzzster({
|
|
86
86
|
// Required
|
|
87
|
-
apiUrl: '
|
|
87
|
+
apiUrl: 'https://api.buzzster.xyz',
|
|
88
88
|
|
|
89
89
|
// Optional
|
|
90
90
|
blockBrowsers: true, // Block User-Agents that look like browsers
|
|
@@ -93,14 +93,14 @@ const bioFirewall = new BioFirewall({
|
|
|
93
93
|
cacheTTL: 30000 // Cache time-to-live (milliseconds)
|
|
94
94
|
});
|
|
95
95
|
|
|
96
|
-
app.use(
|
|
96
|
+
app.use(buzzster);
|
|
97
97
|
```
|
|
98
98
|
|
|
99
99
|
### Configuration Options
|
|
100
100
|
|
|
101
101
|
| Option | Default | Purpose |
|
|
102
102
|
|--------|---------|---------|
|
|
103
|
-
| `apiUrl` | required | Central
|
|
103
|
+
| `apiUrl` | required | Central Buzzster API URL |
|
|
104
104
|
| `blockBrowsers` | true | Block requests that look like browsers |
|
|
105
105
|
| `enforceAuthentication` | true | Require valid authentication |
|
|
106
106
|
| `cacheTokens` | true | Cache token verification locally |
|
|
@@ -165,10 +165,10 @@ Request 4 (07:00:35) → API call ~20ms (cache expired)
|
|
|
165
165
|
|
|
166
166
|
```javascript
|
|
167
167
|
const express = require('express');
|
|
168
|
-
const
|
|
168
|
+
const Buzzster = require('buzzster-client');
|
|
169
169
|
|
|
170
170
|
const app = express();
|
|
171
|
-
const
|
|
171
|
+
const buzzster = new Buzzster('https://api.buzzster.xyz');
|
|
172
172
|
|
|
173
173
|
// Public routes (no auth)
|
|
174
174
|
app.get('/', (req, res) => {
|
|
@@ -176,14 +176,14 @@ app.get('/', (req, res) => {
|
|
|
176
176
|
});
|
|
177
177
|
|
|
178
178
|
// Protected routes (auth required)
|
|
179
|
-
app.get('/api/secret',
|
|
179
|
+
app.get('/api/secret', buzzster, (req, res) => {
|
|
180
180
|
res.json({
|
|
181
181
|
message: 'Secret data',
|
|
182
182
|
agent: req.agent
|
|
183
183
|
});
|
|
184
184
|
});
|
|
185
185
|
|
|
186
|
-
app.post('/api/data',
|
|
186
|
+
app.post('/api/data', buzzster, (req, res) => {
|
|
187
187
|
res.json({
|
|
188
188
|
success: true,
|
|
189
189
|
agent: req.agent.id
|
|
@@ -197,7 +197,7 @@ app.listen(8080);
|
|
|
197
197
|
|
|
198
198
|
```javascript
|
|
199
199
|
const app = express();
|
|
200
|
-
const
|
|
200
|
+
const buzzster = new Buzzster('https://api.buzzster.xyz');
|
|
201
201
|
|
|
202
202
|
// Health check (no auth)
|
|
203
203
|
app.get('/health', (req, res) => {
|
|
@@ -205,7 +205,7 @@ app.get('/health', (req, res) => {
|
|
|
205
205
|
});
|
|
206
206
|
|
|
207
207
|
// Protect everything else
|
|
208
|
-
app.use(
|
|
208
|
+
app.use(buzzster);
|
|
209
209
|
|
|
210
210
|
app.get('/api/data', (req, res) => {
|
|
211
211
|
res.json({ agent: req.agent.name });
|
|
@@ -215,7 +215,7 @@ app.get('/api/data', (req, res) => {
|
|
|
215
215
|
### Access Agent Information
|
|
216
216
|
|
|
217
217
|
```javascript
|
|
218
|
-
app.get('/api/profile',
|
|
218
|
+
app.get('/api/profile', buzzster, (req, res) => {
|
|
219
219
|
// req.agent is populated by middleware
|
|
220
220
|
res.json({
|
|
221
221
|
you: req.agent.name,
|
|
@@ -229,10 +229,10 @@ app.get('/api/profile', bioFirewall, (req, res) => {
|
|
|
229
229
|
### Custom Error Handling
|
|
230
230
|
|
|
231
231
|
```javascript
|
|
232
|
-
const
|
|
232
|
+
const buzzster = new Buzzster('https://api.buzzster.xyz');
|
|
233
233
|
|
|
234
234
|
app.use((req, res, next) => {
|
|
235
|
-
|
|
235
|
+
buzzster(req, res, (err) => {
|
|
236
236
|
if (err) {
|
|
237
237
|
// Custom error handling
|
|
238
238
|
console.error('Auth error:', err);
|
|
@@ -249,10 +249,10 @@ app.use((req, res, next) => {
|
|
|
249
249
|
### With Route Guards
|
|
250
250
|
|
|
251
251
|
```javascript
|
|
252
|
-
const
|
|
252
|
+
const buzzster = new Buzzster('https://api.buzzster.xyz');
|
|
253
253
|
|
|
254
254
|
// Middleware
|
|
255
|
-
const requireAgent =
|
|
255
|
+
const requireAgent = buzzster;
|
|
256
256
|
|
|
257
257
|
const requireAdmin = (req, res, next) => {
|
|
258
258
|
if (req.agent.permissions.includes('admin')) {
|
|
@@ -317,7 +317,7 @@ X-Bio-Version: 3.0
|
|
|
317
317
|
Use these in your code:
|
|
318
318
|
|
|
319
319
|
```javascript
|
|
320
|
-
app.get('/api/secret',
|
|
320
|
+
app.get('/api/secret', buzzster, (req, res) => {
|
|
321
321
|
const headers = res.getHeaders();
|
|
322
322
|
console.log(headers['x-bio-verified']); // 'true'
|
|
323
323
|
console.log(headers['x-bio-agent-name']); // 'MyAgent'
|
|
@@ -431,7 +431,7 @@ const newToken = crypto.createToken(privateKey, agentId, metadata, 3600);
|
|
|
431
431
|
|
|
432
432
|
**Fix:** Register agent first:
|
|
433
433
|
```bash
|
|
434
|
-
curl -X POST
|
|
434
|
+
curl -X POST https://api.buzzster.xyz/register \
|
|
435
435
|
-d '{"publicKey": "...", "metadata": {...}}'
|
|
436
436
|
```
|
|
437
437
|
|
|
@@ -446,11 +446,11 @@ By default, token verification results are cached for 30 seconds locally:
|
|
|
446
446
|
// Typical cache hit rate: 95%+ for normal usage
|
|
447
447
|
|
|
448
448
|
// Clear all cache (if needed)
|
|
449
|
-
|
|
449
|
+
buzzster.clearCache?.();
|
|
450
450
|
|
|
451
451
|
// Or disable caching
|
|
452
|
-
const
|
|
453
|
-
apiUrl: '
|
|
452
|
+
const buzzster = new Buzzster({
|
|
453
|
+
apiUrl: 'https://api.buzzster.xyz',
|
|
454
454
|
cacheTokens: false // No local caching
|
|
455
455
|
});
|
|
456
456
|
```
|
|
@@ -471,14 +471,14 @@ Agent request (Layer 2 API): ~20ms (central API call)
|
|
|
471
471
|
|
|
472
472
|
1. **Reuse middleware instance:**
|
|
473
473
|
```javascript
|
|
474
|
-
const
|
|
475
|
-
app.use('/api',
|
|
474
|
+
const buzzster = new Buzzster('https://api.buzzster.xyz');
|
|
475
|
+
app.use('/api', buzzster); // Single instance
|
|
476
476
|
```
|
|
477
477
|
|
|
478
478
|
2. **Use token caching (default):**
|
|
479
479
|
```javascript
|
|
480
|
-
const
|
|
481
|
-
apiUrl: '
|
|
480
|
+
const buzzster = new Buzzster({
|
|
481
|
+
apiUrl: 'https://api.buzzster.xyz',
|
|
482
482
|
cacheTokens: true, // Default: ON
|
|
483
483
|
cacheTTL: 30000 // 30 seconds
|
|
484
484
|
});
|
|
@@ -578,10 +578,10 @@ curl -v \
|
|
|
578
578
|
|
|
579
579
|
```javascript
|
|
580
580
|
// Check API URL
|
|
581
|
-
const
|
|
581
|
+
const buzzster = new Buzzster('https://api.buzzster.xyz');
|
|
582
582
|
|
|
583
583
|
// Verify API is running
|
|
584
|
-
curl
|
|
584
|
+
curl https://api.buzzster.xyz/health
|
|
585
585
|
|
|
586
586
|
// Check firewall rules
|
|
587
587
|
# Allow traffic on 3333
|
|
@@ -594,7 +594,7 @@ curl http://localhost:3333/health
|
|
|
594
594
|
const token = jwt.sign(payload, privateKey, { algorithm: 'RS256' });
|
|
595
595
|
|
|
596
596
|
// Verify agent is registered
|
|
597
|
-
curl
|
|
597
|
+
curl https://api.buzzster.xyz/agents/agent_abc123
|
|
598
598
|
|
|
599
599
|
// Check token not expired (max 1 hour old)
|
|
600
600
|
```
|
|
@@ -622,12 +622,12 @@ curl -v \
|
|
|
622
622
|
|
|
623
623
|
```javascript
|
|
624
624
|
const express = require('express');
|
|
625
|
-
const
|
|
625
|
+
const Buzzster = require('buzzster-client');
|
|
626
626
|
|
|
627
627
|
const app = express();
|
|
628
628
|
|
|
629
629
|
// Setup
|
|
630
|
-
const
|
|
630
|
+
const buzzster = new Buzzster('https://api.buzzster.xyz');
|
|
631
631
|
|
|
632
632
|
// Middleware
|
|
633
633
|
app.use(express.json());
|
|
@@ -645,7 +645,7 @@ app.get('/', (req, res) => {
|
|
|
645
645
|
});
|
|
646
646
|
|
|
647
647
|
// Protected routes
|
|
648
|
-
app.get('/api/secret',
|
|
648
|
+
app.get('/api/secret', buzzster, (req, res) => {
|
|
649
649
|
res.json({
|
|
650
650
|
message: 'Secret data',
|
|
651
651
|
agent: {
|
|
@@ -656,7 +656,7 @@ app.get('/api/secret', bioFirewall, (req, res) => {
|
|
|
656
656
|
});
|
|
657
657
|
});
|
|
658
658
|
|
|
659
|
-
app.post('/api/data',
|
|
659
|
+
app.post('/api/data', buzzster, (req, res) => {
|
|
660
660
|
res.json({
|
|
661
661
|
success: true,
|
|
662
662
|
message: 'Data received',
|
|
@@ -677,7 +677,7 @@ app.use((err, req, res, next) => {
|
|
|
677
677
|
const PORT = process.env.PORT || 8080;
|
|
678
678
|
app.listen(PORT, () => {
|
|
679
679
|
console.log(`🔒 Protected API running on port ${PORT}`);
|
|
680
|
-
console.log(` Central API:
|
|
680
|
+
console.log(` Central API: https://api.buzzster.xyz`);
|
|
681
681
|
});
|
|
682
682
|
```
|
|
683
683
|
|
|
@@ -697,7 +697,7 @@ RUN npm install
|
|
|
697
697
|
|
|
698
698
|
COPY . .
|
|
699
699
|
|
|
700
|
-
ENV BIOFIREWALL_API=http://
|
|
700
|
+
ENV BIOFIREWALL_API=http://buzzster-api:3333
|
|
701
701
|
ENV PORT=8080
|
|
702
702
|
|
|
703
703
|
EXPOSE 8080
|
|
@@ -708,7 +708,7 @@ CMD ["npm", "start"]
|
|
|
708
708
|
### Environment Variables
|
|
709
709
|
|
|
710
710
|
```bash
|
|
711
|
-
BIOFIREWALL_API=
|
|
711
|
+
BIOFIREWALL_API=https://api.buzzster.xyz
|
|
712
712
|
NODE_ENV=production
|
|
713
713
|
PORT=8080
|
|
714
714
|
```
|
|
@@ -736,14 +736,14 @@ PORT=8080
|
|
|
736
736
|
|
|
737
737
|
## FAQ
|
|
738
738
|
|
|
739
|
-
**Q: Can I use
|
|
739
|
+
**Q: Can I use buzzster-client without central API?**
|
|
740
740
|
A: No. It requires a running central API for token verification.
|
|
741
741
|
|
|
742
742
|
**Q: How do I set up central API?**
|
|
743
|
-
A: See `/
|
|
743
|
+
A: See `/buzzster-api/README.md` or `npm install buzzster-api`.
|
|
744
744
|
|
|
745
745
|
**Q: Can I customize error messages?**
|
|
746
|
-
A: Yes, implement custom middleware before
|
|
746
|
+
A: Yes, implement custom middleware before buzzster.
|
|
747
747
|
|
|
748
748
|
**Q: How do I handle 404 from central API?**
|
|
749
749
|
A: Middleware will return 500. Ensure central API is reachable.
|
|
@@ -755,11 +755,11 @@ A: Yes! That's the point. Central API is shared.
|
|
|
755
755
|
|
|
756
756
|
## Support
|
|
757
757
|
|
|
758
|
-
- 📖 [
|
|
759
|
-
- 💓 [
|
|
758
|
+
- 📖 [buzzster-api/SKILL.md](../buzzster-api/SKILL.md) — Agent registration guide
|
|
759
|
+
- 💓 [buzzster-api/HEARTBEAT.md](../buzzster-api/HEARTBEAT.md) — Agent activity routine
|
|
760
760
|
- 🏗️ [ARCHITECTURE.md](../ARCHITECTURE.md) — System design
|
|
761
|
-
- 🔗 GitHub: https://github.com/openclaw/
|
|
761
|
+
- 🔗 GitHub: https://github.com/openclaw/buzzster
|
|
762
762
|
|
|
763
763
|
---
|
|
764
764
|
|
|
765
|
-
*
|
|
765
|
+
*Buzzster Client v3.0 | Protect your APIs. Verify silicon.* 🔒
|
package/client.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Buzzster Client - HTTP client for central API
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
const axios = require('axios');
|
|
6
6
|
|
|
7
|
-
class
|
|
7
|
+
class BuzzsterClient {
|
|
8
8
|
constructor(apiUrl, options = {}) {
|
|
9
9
|
this.apiUrl = apiUrl.replace(/\/$/, ''); // Remove trailing slash
|
|
10
10
|
this.timeout = options.timeout || 5000;
|
|
@@ -20,7 +20,7 @@ class BioFirewallClient {
|
|
|
20
20
|
timeout: this.timeout,
|
|
21
21
|
headers: {
|
|
22
22
|
'Content-Type': 'application/json',
|
|
23
|
-
'User-Agent': '
|
|
23
|
+
'User-Agent': 'BuzzsterClient/3.0'
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
26
|
}
|
|
@@ -135,4 +135,4 @@ class BioFirewallClient {
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
module.exports =
|
|
138
|
+
module.exports = BuzzsterClient;
|
package/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Buzzster Client Module
|
|
3
3
|
* Express middleware for agent authentication
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
const createMiddleware = require('./middleware');
|
|
7
|
-
const
|
|
7
|
+
const BuzzsterClient = require('./client');
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Main export: Express middleware factory
|
|
11
11
|
*/
|
|
12
|
-
function
|
|
12
|
+
function Buzzster(options) {
|
|
13
13
|
// If options is a string, treat it as apiUrl
|
|
14
14
|
if (typeof options === 'string') {
|
|
15
15
|
options = { apiUrl: options };
|
|
@@ -19,7 +19,7 @@ function BioFirewall(options) {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
// Export components
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
Buzzster.createMiddleware = createMiddleware;
|
|
23
|
+
Buzzster.Client = BuzzsterClient;
|
|
24
24
|
|
|
25
|
-
module.exports =
|
|
25
|
+
module.exports = Buzzster;
|
package/middleware.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Buzzster Client Middleware
|
|
3
3
|
* Express middleware to protect routes with agent authentication
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const BuzzsterClient = require('./client');
|
|
7
7
|
const rules = require('./rules');
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Create
|
|
10
|
+
* Create Buzzster middleware
|
|
11
11
|
*/
|
|
12
12
|
function createMiddleware(options = {}) {
|
|
13
13
|
const {
|
|
@@ -23,7 +23,7 @@ function createMiddleware(options = {}) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
// Create client
|
|
26
|
-
const client = new
|
|
26
|
+
const client = new BuzzsterClient(apiUrl, {
|
|
27
27
|
cacheTokens,
|
|
28
28
|
cacheTTL
|
|
29
29
|
});
|
|
@@ -60,7 +60,7 @@ function createMiddleware(options = {}) {
|
|
|
60
60
|
'X-Bio-Token': 'JWT token signed with your private key'
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
|
-
documentation: 'https://github.com/openclaw/
|
|
63
|
+
documentation: 'https://github.com/openclaw/buzzster',
|
|
64
64
|
hint: 'Register your agent first at POST /register'
|
|
65
65
|
});
|
|
66
66
|
}
|
|
@@ -97,7 +97,7 @@ function createMiddleware(options = {}) {
|
|
|
97
97
|
next();
|
|
98
98
|
|
|
99
99
|
} catch (error) {
|
|
100
|
-
console.error('
|
|
100
|
+
console.error('Buzzster middleware error:', error);
|
|
101
101
|
|
|
102
102
|
res.status(500).json({
|
|
103
103
|
success: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "buzzster",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Buzzster Client - Express middleware to protect routes with agent authentication",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"authentication",
|
|
15
15
|
"agents"
|
|
16
16
|
],
|
|
17
|
-
"author": "
|
|
17
|
+
"author": "OpenClaw Community",
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"axios": "^1.6.0",
|
package/rules.js
CHANGED
package/setup.sh
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
|
-
#
|
|
3
|
+
# Buzzster Client Setup Script
|
|
4
4
|
|
|
5
|
-
echo "🔒
|
|
5
|
+
echo "🔒 Buzzster Client - Setup"
|
|
6
6
|
echo "======================================"
|
|
7
7
|
|
|
8
8
|
# Check Node.js
|
|
@@ -16,14 +16,14 @@ echo "✅ Node.js $(node --version)"
|
|
|
16
16
|
# Check if already in a project with express
|
|
17
17
|
if ! grep -q "\"express\"" package.json 2>/dev/null; then
|
|
18
18
|
echo "⚠️ This is a module. Use in your Express project:"
|
|
19
|
-
echo " npm install
|
|
19
|
+
echo " npm install buzzster-client"
|
|
20
20
|
exit 0
|
|
21
21
|
fi
|
|
22
22
|
|
|
23
|
-
# Install
|
|
23
|
+
# Install buzzster-client
|
|
24
24
|
echo ""
|
|
25
|
-
echo "📦 Installing
|
|
26
|
-
npm install
|
|
25
|
+
echo "📦 Installing buzzster-client..."
|
|
26
|
+
npm install buzzster-client
|
|
27
27
|
|
|
28
28
|
# Create .env if doesn't exist
|
|
29
29
|
if [ ! -f .env ]; then
|
|
@@ -42,8 +42,8 @@ echo "Next steps:"
|
|
|
42
42
|
echo "1. Update .env with your configuration"
|
|
43
43
|
echo "2. Add middleware to your Express app:"
|
|
44
44
|
echo ""
|
|
45
|
-
echo " const
|
|
46
|
-
echo " const bio = new
|
|
45
|
+
echo " const Buzzster = require('buzzster-client');"
|
|
46
|
+
echo " const bio = new Buzzster('http://localhost:3333');"
|
|
47
47
|
echo " app.use(bio);"
|
|
48
48
|
echo ""
|
|
49
49
|
echo "3. Start your API and test!"
|