apigraveyard 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/README.md ADDED
@@ -0,0 +1,501 @@
1
+ # APIgraveyard πŸͺ¦
2
+
3
+ ```
4
+ ___ ____ ____ __
5
+ / | / __ \/ _/___ __________ __ _____ __ ______ __________/ /
6
+ / /| | / /_/ // // __ `/ ___/ __ `/ | / / _ \/ / / / __ `/ ___/ __ /
7
+ / ___ |/ ____// // /_/ / / / /_/ /| |/ / __/ /_/ / /_/ / / / /_/ /
8
+ /_/ |_/_/ /___/\__, /_/ \__,_/ |___/\___/\__, /\__,_/_/ \__,_/
9
+ /____/ /____/
10
+ πŸͺ¦ RIP APIs πŸͺ¦
11
+ ```
12
+
13
+ <p align="center">
14
+ <strong>Never lose track of your scattered API keys</strong>
15
+ </p>
16
+
17
+ <p align="center">
18
+ <a href="https://www.npmjs.com/package/apigraveyard"><img src="https://img.shields.io/npm/v/apigraveyard.svg?style=flat-square" alt="npm version"></a>
19
+ <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square" alt="License: MIT"></a>
20
+ <a href="https://github.com/himanshumudigonda/apigraveyard/actions"><img src="https://img.shields.io/github/actions/workflow/status/himanshumudigonda/apigraveyard/ci.yml?style=flat-square" alt="Build Status"></a>
21
+ <a href="https://github.com/himanshumudigonda/apigraveyard"><img src="https://img.shields.io/github/stars/himanshumudigonda/apigraveyard?style=flat-square" alt="GitHub Stars"></a>
22
+ </p>
23
+
24
+ ---
25
+
26
+ ## 😱 The Problem
27
+
28
+ We've all been there:
29
+
30
+ - πŸ”‘ You have API keys scattered across **10+ different projects**
31
+ - ❓ Some are **expired**, some have **maxed quotas** β€” but which ones?
32
+ - 🀷 You have **no idea** which key is in which project
33
+ - 😰 You've accidentally **committed keys to GitHub** (or almost did)
34
+ - πŸ“ Your `.env.example` says `OPENAI_API_KEY=your-key-here` but you can't remember where the actual key is
35
+
36
+ **APIgraveyard** solves all of this. It's like a cemetery for your API keys β€” but in a good way. πŸͺ¦
37
+
38
+ ---
39
+
40
+ ## ✨ Features
41
+
42
+ | Feature | Description |
43
+ |---------|-------------|
44
+ | πŸ” **Deep Scanning** | Scans entire projects for exposed API keys using regex patterns |
45
+ | βœ… **Key Validation** | Tests if your keys are still valid by calling the actual APIs |
46
+ | πŸ“Š **Quota Tracking** | Shows remaining quota, rate limits, and usage info |
47
+ | 🚫 **Git Protection** | Pre-commit hook blocks commits containing API keys |
48
+ | πŸ’Ύ **Central Database** | Stores all found keys in one local database (`~/.apigraveyard.json`) |
49
+ | 🎨 **Beautiful UI** | Color-coded tables, spinners, and formatted output |
50
+ | πŸ”’ **Privacy First** | Everything stays local β€” no cloud, no telemetry |
51
+
52
+ ---
53
+
54
+ ## πŸ” Supported Services
55
+
56
+ APIgraveyard can detect and validate keys from these services:
57
+
58
+ | Service | Pattern | Validation |
59
+ |---------|---------|------------|
60
+ | **OpenAI** | `sk-...` (48 chars) | βœ… Full validation + models list |
61
+ | **Anthropic** | `sk-ant-...` (95 chars) | βœ… Full validation |
62
+ | **Groq** | `gsk_...` (52 chars) | βœ… Full validation + models list |
63
+ | **GitHub** | `ghp_` / `ghs_...` (36 chars) | βœ… Full validation + rate limits |
64
+ | **Stripe** | `sk_live_` / `sk_test_...` | βœ… Full validation + balance |
65
+ | **Google/Firebase** | `AIza...` (35 chars) | βœ… Token info validation |
66
+ | **AWS** | `AKIA...` (16 chars) | ⚠️ Format validation only |
67
+ | **Hugging Face** | `hf_...` (34 chars) | βœ… Full validation + user info |
68
+
69
+ ---
70
+
71
+ ## πŸ“¦ Installation
72
+
73
+ ### Global Installation (Recommended)
74
+
75
+ ```bash
76
+ npm install -g apigraveyard
77
+ ```
78
+
79
+ ### Local Installation
80
+
81
+ ```bash
82
+ npm install apigraveyard --save-dev
83
+ ```
84
+
85
+ ### Verify Installation
86
+
87
+ ```bash
88
+ apigraveyard --version
89
+ ```
90
+
91
+ ---
92
+
93
+ ## πŸš€ Quick Start
94
+
95
+ ### 1. Scan a Project
96
+
97
+ ```bash
98
+ # Scan your project for API keys
99
+ apigraveyard scan ~/projects/my-app
100
+
101
+ # Scan and test keys immediately
102
+ apigraveyard scan ~/projects/my-app --test
103
+ ```
104
+
105
+ ### 2. Test Your Keys
106
+
107
+ ```bash
108
+ # Test all keys from all projects
109
+ apigraveyard test
110
+
111
+ # Test keys from a specific project
112
+ apigraveyard test ~/projects/my-app
113
+ ```
114
+
115
+ ### 3. List All Projects
116
+
117
+ ```bash
118
+ # See all scanned projects
119
+ apigraveyard list
120
+
121
+ # With database statistics
122
+ apigraveyard list --stats
123
+ ```
124
+
125
+ ---
126
+
127
+ ## πŸ“Έ Usage Examples
128
+
129
+ ### Scanning a Project
130
+
131
+ ```bash
132
+ $ apigraveyard scan ./my-project --test
133
+ ```
134
+
135
+ **Output:**
136
+ ```
137
+ πŸͺ¦ APIgraveyard
138
+
139
+ πŸ“Š Scan Results
140
+ ────────────────────────────────────────────────────────────────
141
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
142
+ β”‚ Service β”‚ Key β”‚ File β”‚ Line β”‚ Status β”‚
143
+ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
144
+ β”‚ OpenAI β”‚ sk-a***...***xyz β”‚ src/config.js β”‚ 23 β”‚ βœ… VALID β”‚
145
+ β”‚ GitHub β”‚ ghp_***...***abc β”‚ .env.local β”‚ 5 β”‚ βœ… VALID β”‚
146
+ β”‚ Stripe β”‚ sk_t***...***def β”‚ lib/payment.js β”‚ 45 β”‚ ❌ INVALID β”‚
147
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
148
+
149
+ πŸ“ˆ Summary
150
+ ────────────────────────────────────────────────────────────────
151
+ Total keys found: 3
152
+ Files scanned: 156
153
+
154
+ By service:
155
+ OpenAI: 1
156
+ GitHub: 1
157
+ Stripe: 1
158
+ ```
159
+
160
+ ### Testing Keys
161
+
162
+ ```bash
163
+ $ apigraveyard test
164
+ ```
165
+
166
+ **Output:**
167
+ ```
168
+ πŸ§ͺ Test Results
169
+ ──────────────────────────────────────────────────────────────────────────
170
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
171
+ β”‚ Service β”‚ Key β”‚ Status β”‚ Details β”‚ Last Tested β”‚
172
+ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
173
+ β”‚ OpenAI β”‚ sk-a***...***xyz β”‚ βœ… VALID β”‚ 15 models β”‚ 1/7/2026, 10:30 AM β”‚
174
+ β”‚ GitHub β”‚ ghp_***...***abc β”‚ βœ… VALID β”‚ @username β”‚ 1/7/2026, 10:30 AM β”‚
175
+ β”‚ Stripe β”‚ sk_t***...***def β”‚ ❌ INVALID β”‚ - β”‚ 1/7/2026, 10:30 AM β”‚
176
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
177
+
178
+ Summary:
179
+ βœ… VALID: 2
180
+ ❌ INVALID: 1
181
+ ```
182
+
183
+ ### Project List
184
+
185
+ ```bash
186
+ $ apigraveyard list
187
+ ```
188
+
189
+ **Output:**
190
+ ```
191
+ πŸ“ Tracked Projects
192
+ ──────────────────────────────────────────────────────────────────────────
193
+
194
+ 1. my-app (/home/user/projects/my-app)
195
+ πŸ”‘ 3 keys (2 valid) β€’ Last scanned: 1/7/2026, 10:30 AM
196
+
197
+ 2. blog-backend (/home/user/projects/blog-backend)
198
+ πŸ”‘ 1 keys (1 valid) β€’ Last scanned: 1/6/2026, 3:45 PM
199
+
200
+ ──────────────────────────────────────────────────────────────────────────
201
+ Total: 2 project(s)
202
+ ```
203
+
204
+ ---
205
+
206
+ ## πŸ“– Commands Reference
207
+
208
+ ### `apigraveyard scan <directory>`
209
+
210
+ Scan a directory for exposed API keys.
211
+
212
+ | Option | Description | Default |
213
+ |--------|-------------|---------|
214
+ | `-r, --recursive` | Scan subdirectories | `true` |
215
+ | `-t, --test` | Test keys after scanning | `false` |
216
+ | `-i, --ignore <patterns...>` | Additional patterns to ignore | `[]` |
217
+
218
+ ```bash
219
+ # Examples
220
+ apigraveyard scan .
221
+ apigraveyard scan ~/projects/my-app --test
222
+ apigraveyard scan . --ignore "*.test.js" "fixtures"
223
+ ```
224
+
225
+ ### `apigraveyard test [project-path]`
226
+
227
+ Test validity of stored API keys.
228
+
229
+ ```bash
230
+ # Test all projects
231
+ apigraveyard test
232
+
233
+ # Test specific project
234
+ apigraveyard test ~/projects/my-app
235
+ ```
236
+
237
+ ### `apigraveyard list`
238
+
239
+ List all scanned projects.
240
+
241
+ | Option | Description |
242
+ |--------|-------------|
243
+ | `-s, --stats` | Show database statistics |
244
+
245
+ ```bash
246
+ apigraveyard list
247
+ apigraveyard list --stats
248
+ ```
249
+
250
+ ### `apigraveyard show <project-path>`
251
+
252
+ Show detailed info for a project.
253
+
254
+ | Option | Description |
255
+ |--------|-------------|
256
+ | `-k, --key <index>` | Show details for specific key |
257
+
258
+ ```bash
259
+ apigraveyard show ~/projects/my-app
260
+ apigraveyard show ~/projects/my-app --key 0
261
+ ```
262
+
263
+ ### `apigraveyard clean`
264
+
265
+ Remove invalid/expired keys from database.
266
+
267
+ | Option | Description |
268
+ |--------|-------------|
269
+ | `-f, --force` | Skip confirmation prompt |
270
+
271
+ ```bash
272
+ apigraveyard clean
273
+ apigraveyard clean --force
274
+ ```
275
+
276
+ ### `apigraveyard export`
277
+
278
+ Export all keys to a file.
279
+
280
+ | Option | Description | Default |
281
+ |--------|-------------|---------|
282
+ | `-f, --format` | Output format (`json` or `csv`) | `json` |
283
+ | `-o, --output` | Output file path | `apigraveyard-export.{format}` |
284
+ | `--include-full-keys` | Include unmasked keys (dangerous!) | `false` |
285
+
286
+ ```bash
287
+ apigraveyard export
288
+ apigraveyard export --format csv --output my-keys.csv
289
+ ```
290
+
291
+ ### `apigraveyard ban <key>`
292
+
293
+ Mark an API key as compromised/banned.
294
+
295
+ | Option | Description |
296
+ |--------|-------------|
297
+ | `-d, --delete` | Offer to delete from files |
298
+
299
+ ```bash
300
+ apigraveyard ban sk-compromised-key-here
301
+ ```
302
+
303
+ ### `apigraveyard delete <project-path>`
304
+
305
+ Remove a project from tracking.
306
+
307
+ | Option | Description |
308
+ |--------|-------------|
309
+ | `-f, --force` | Skip confirmation prompt |
310
+
311
+ ```bash
312
+ apigraveyard delete ~/projects/old-project
313
+ ```
314
+
315
+ ### `apigraveyard stats`
316
+
317
+ Show database statistics.
318
+
319
+ ```bash
320
+ apigraveyard stats
321
+ ```
322
+
323
+ ---
324
+
325
+ ## πŸ”’ Git Hook Setup
326
+
327
+ APIgraveyard includes a pre-commit hook that prevents accidentally committing API keys.
328
+
329
+ ### Automatic Installation
330
+
331
+ The hook is automatically installed when you run `npm install` in a project with APIgraveyard as a dependency.
332
+
333
+ ### Manual Installation
334
+
335
+ ```bash
336
+ # If installed globally
337
+ npm run install-hooks
338
+
339
+ # Or copy manually
340
+ cp node_modules/apigraveyard/hooks/pre-commit .git/hooks/pre-commit
341
+ chmod +x .git/hooks/pre-commit
342
+ ```
343
+
344
+ ### What It Does
345
+
346
+ When you try to commit, the hook:
347
+
348
+ 1. βœ… Scans all staged files for API key patterns
349
+ 2. βœ… Warns about sensitive files (`.env`, `*.pem`, etc.)
350
+ 3. ❌ **Blocks the commit** if keys are found
351
+ 4. πŸ’‘ Shows suggestions for fixing the issue
352
+
353
+ **Example blocked commit:**
354
+ ```
355
+ ❌ COMMIT BLOCKED - API Keys Detected!
356
+
357
+ Found in: src/config.js (line 23)
358
+ OpenAI key: sk-a***...***xyz
359
+
360
+ Suggested fixes:
361
+ 1. Move keys to .env file
362
+ 2. Add .env to .gitignore
363
+ 3. Unstage the file(s):
364
+ git reset HEAD src/config.js
365
+
366
+ To bypass (NOT recommended):
367
+ git commit --no-verify
368
+ ```
369
+
370
+ ### Uninstall Hook
371
+
372
+ ```bash
373
+ node node_modules/apigraveyard/scripts/install-hooks.js --uninstall
374
+ ```
375
+
376
+ ---
377
+
378
+ ## ❓ FAQ
379
+
380
+ ### Where is my data stored?
381
+
382
+ All data is stored locally in `~/.apigraveyard.json`. Nothing is sent to any server.
383
+
384
+ ### Is it secure?
385
+
386
+ - βœ… All data stays on your machine
387
+ - βœ… No network requests except for key validation
388
+ - βœ… Keys are masked in all output
389
+ - βœ… Export with full keys requires explicit flag
390
+ - βœ… No telemetry or analytics
391
+
392
+ ### How do I uninstall?
393
+
394
+ ```bash
395
+ # Remove the package
396
+ npm uninstall -g apigraveyard
397
+
398
+ # Optionally remove the database
399
+ rm ~/.apigraveyard.json
400
+ rm ~/.apigraveyard.backup.json
401
+ rm ~/.apigraveyard.log
402
+ ```
403
+
404
+ ### Can I use it in CI/CD?
405
+
406
+ Yes! You can run scans in CI to detect committed keys:
407
+
408
+ ```bash
409
+ apigraveyard scan . && echo "No keys found" || exit 1
410
+ ```
411
+
412
+ ### What files are ignored?
413
+
414
+ By default, these are ignored:
415
+ - `node_modules/`
416
+ - `.git/`
417
+ - `dist/`, `build/`, `.next/`
418
+ - `venv/`
419
+ - `package-lock.json`, `yarn.lock`
420
+ - `.env.example`, `.env.sample`
421
+
422
+ ---
423
+
424
+ ## πŸ—ΊοΈ Roadmap
425
+
426
+ We're actively working on making APIgraveyard even better:
427
+
428
+ - [ ] πŸ”Œ **More Services** β€” Support for Azure, DigitalOcean, Twilio, SendGrid, etc.
429
+ - [ ] ☁️ **Cloud Sync** β€” Optional encrypted cloud backup
430
+ - [ ] πŸ‘₯ **Team Sharing** β€” Share key inventories with your team
431
+ - [ ] 🌐 **Browser Extension** β€” Detect keys on GitHub, GitLab, etc.
432
+ - [ ] πŸ“± **VS Code Extension** β€” Real-time key detection in your editor
433
+ - [ ] πŸ”” **Expiry Alerts** β€” Get notified before keys expire
434
+ - [ ] πŸ“ˆ **Usage Analytics** β€” Track API usage across projects
435
+
436
+ Have a feature request? [Open an issue](https://github.com/himanshumudigonda/apigraveyard/issues)!
437
+
438
+ ---
439
+
440
+ ## 🀝 Contributing
441
+
442
+ We love contributions! Here's how you can help:
443
+
444
+ ### Reporting Bugs
445
+
446
+ 1. Check if the issue already exists
447
+ 2. Open a new issue with:
448
+ - Clear description
449
+ - Steps to reproduce
450
+ - Expected vs actual behavior
451
+ - Your environment (OS, Node version)
452
+
453
+ ### Submitting Pull Requests
454
+
455
+ 1. Fork the repository
456
+ 2. Create a feature branch: `git checkout -b feature/amazing-feature`
457
+ 3. Make your changes
458
+ 4. Add tests if applicable
459
+ 5. Commit: `git commit -m 'Add amazing feature'`
460
+ 6. Push: `git push origin feature/amazing-feature`
461
+ 7. Open a Pull Request
462
+
463
+ ### Development Setup
464
+
465
+ ```bash
466
+ # Clone the repo
467
+ git clone https://github.com/himanshumudigonda/apigraveyard.git
468
+ cd apigraveyard
469
+
470
+ # Install dependencies
471
+ npm install
472
+
473
+ # Run locally
474
+ node bin/apigraveyard.js --help
475
+
476
+ # Link for global testing
477
+ npm link
478
+ ```
479
+
480
+ ---
481
+
482
+ ## πŸ“„ License
483
+
484
+ MIT License β€” see [LICENSE](LICENSE) for details.
485
+
486
+ ---
487
+
488
+ ## πŸ‘€ Author
489
+
490
+ **Himanshu Mudigonda**
491
+ - GitHub: [@himanshumudigonda](https://github.com/himanshumudigonda)
492
+
493
+ ---
494
+
495
+ <p align="center">
496
+ Made with ❀️ and a healthy fear of exposed API keys
497
+ </p>
498
+
499
+ <p align="center">
500
+ <strong>πŸͺ¦ Rest in peace, scattered API keys. πŸͺ¦</strong>
501
+ </p>