11# Suggested Additional Features
22
3- ## Currently Implemented
4- - ✅ Custom alphabet for key generation
5- - ✅ Salt for hashing
6- - ✅ Update last used timestamp
7- - ✅ Key tags/labels
8- - ✅ Audit logging (opt-in)
9-
103## Recommended Additions
114
125### 1. Rate Limiting Helper
@@ -25,15 +18,7 @@ const rateLimiter = keys.createRateLimiter({
2518await rateLimiter .check (apiKeyRecord )
2619```
2720
28- ### 2. Key Rotation
29- ``` typescript
30- // Rotate a key (create new, mark old as rotating)
31- const { newKey, oldRecord } = await keys .rotate (oldKeyId , {
32- gracePeriodMs: 86400000 , // 24 hours
33- })
34- ```
35-
36- ### 3. Usage Analytics
21+ ### 2. Usage Analytics
3722``` typescript
3823// Track key usage
3924await keys .trackUsage (keyId , {
@@ -46,22 +31,7 @@ await keys.trackUsage(keyId, {
4631const stats = await keys .getUsageStats (keyId )
4732```
4833
49- ### 4. Webhook Events
50- ``` typescript
51- keys .on (' key.created' , async (event ) => {
52- await sendWebhook (event .ownerId , ' key_created' , event .data )
53- })
54-
55- keys .on (' key.used' , async (event ) => {
56- // Log to analytics
57- })
58-
59- keys .on (' key.expired' , async (event ) => {
60- // Notify owner
61- })
62- ```
63-
64- ### 5. IP Whitelisting
34+ ### 2. IP Whitelisting
6535``` typescript
6636await keys .create ({
6737 ownerId: ' user_123' ,
@@ -71,7 +41,7 @@ await keys.create({
7141await keys .verify (key , { ipAddress: req .ip })
7242```
7343
74- ### 6 . Request Signing
44+ ### 3 . Request Signing
7545``` typescript
7646// HMAC-based request signing
7747const signature = keys .sign (request , apiKey )
@@ -80,7 +50,7 @@ const signature = keys.sign(request, apiKey)
8050const isValid = await keys .verifySignature (request , signature , keyId )
8151```
8252
83- ### 7 . Bulk Operations
53+ ### 4 . Bulk Operations
8454``` typescript
8555// Bulk create
8656const results = await keys .createBulk ([
@@ -92,7 +62,7 @@ const results = await keys.createBulk([
9262await keys .revokeBulk ([' key_1' , ' key_2' , ' key_3' ])
9363```
9464
95- ### 8 . Key Templates
65+ ### 5 . Key Templates
9666``` typescript
9767// Define reusable templates
9868keys .defineTemplate (' readonly' , {
@@ -105,40 +75,27 @@ const { key } = await keys.createFromTemplate('readonly', {
10575})
10676```
10777
108- ### 9. Audit Logging
109- ``` typescript
110- interface AuditLog {
111- action: ' created' | ' verified' | ' revoked' | ' updated'
112- keyId: string
113- ownerId: string
114- timestamp: string
115- metadata: Record <string , any >
116- }
117-
118- const logs = await keys .getAuditLogs ({
119- keyId: ' key_123' ,
120- startDate: ' 2025-01-01' ,
121- endDate: ' 2025-12-31' ,
122- })
123- ```
124-
12578## Priority Recommendations
12679
12780** High Priority:**
128811 . Rate limiting (security)
129- 2 . ~~ Update last used timestamp~~ ✅ (already added)
130- 3 . ~~ Audit logging~~ ✅ (already added)
13182
13283** Medium Priority:**
133- 4 . Key rotation (security best practice)
134- 5 . IP whitelisting (additional security layer)
135- 6 . Usage analytics (insights)
84+ 2 . IP whitelisting (additional security layer)
85+ 3 . Usage analytics (insights)
13686
13787** Low Priority:**
138- 7 . Webhook events (automation)
139- 8 . Request signing (advanced security)
140- 9 . Key templates (convenience)
141- 10 . Bulk operations (efficiency)
88+ 4 . Request signing (advanced security)
89+ 5 . Key templates (convenience)
90+ 6 . Bulk operations (efficiency)
91+
92+ ## Completed Features ✅
93+ - Custom alphabet for key generation
94+ - Salt for hashing
95+ - Update last used timestamp
96+ - Key tags/labels
97+ - Audit logging (opt-in)
98+ - Key rotation
14299
143100## Implementation Notes
144101
0 commit comments