opensecureconf-client 2.3.1 → 2.3.3
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 +355 -41
- package/dist/index.d.mts +123 -2
- package/dist/index.d.ts +123 -2
- package/dist/index.js +270 -1
- package/dist/index.mjs +270 -1
- package/package.json +2 -5
package/README.md
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
# OpenSecureConf TypeScript/JavaScript Client
|
|
2
3
|
|
|
3
4
|
[](https://www.npmjs.com/package/opensecureconf-client)
|
|
@@ -11,6 +12,7 @@ A comprehensive TypeScript/JavaScript client library for OpenSecureConf - Encryp
|
|
|
11
12
|
- ✅ **Full TypeScript Support** - Complete type definitions
|
|
12
13
|
- 🔒 **HTTPS/SSL Support** - Production-ready with TLS
|
|
13
14
|
- 🔐 **Self-Signed Certificates** - Option for development environments
|
|
15
|
+
- 💾 **Backup & Restore** - Encrypted backup and import operations
|
|
14
16
|
- 📦 **Batch Operations** - Bulk create, read, delete
|
|
15
17
|
- 🌐 **Cluster Support** - Status and health check methods
|
|
16
18
|
- ⚡ **Async/Await** - Modern promise-based API
|
|
@@ -18,6 +20,7 @@ A comprehensive TypeScript/JavaScript client library for OpenSecureConf - Encryp
|
|
|
18
20
|
- 🌍 **Universal** - Works in Node.js and browsers
|
|
19
21
|
- 🔄 **Auto-Retry** - Built-in timeout and error handling
|
|
20
22
|
- 📊 **Metrics** - Prometheus metrics support
|
|
23
|
+
- 🎯 **Environment & Category Filtering** - Organize configurations by environment and category
|
|
21
24
|
|
|
22
25
|
## 📦 Installation
|
|
23
26
|
|
|
@@ -49,21 +52,27 @@ const client = new OpenSecureConfClient({
|
|
|
49
52
|
apiKey: 'optional-api-key', // Optional
|
|
50
53
|
});
|
|
51
54
|
|
|
52
|
-
// Create configuration
|
|
55
|
+
// Create configuration with environment and category
|
|
53
56
|
const config = await client.create('database', {
|
|
54
57
|
host: 'localhost',
|
|
55
58
|
port: 5432,
|
|
56
59
|
username: 'admin',
|
|
60
|
+
}, {
|
|
61
|
+
category: 'config',
|
|
62
|
+
environment: 'production'
|
|
57
63
|
});
|
|
58
64
|
|
|
59
65
|
// Read configuration
|
|
60
66
|
const retrieved = await client.read('database');
|
|
61
67
|
console.log(retrieved.value); // { host: 'localhost', port: 5432, ... }
|
|
68
|
+
console.log(retrieved.environment); // 'production'
|
|
62
69
|
|
|
63
70
|
// Update configuration
|
|
64
71
|
await client.update('database', {
|
|
65
72
|
host: 'db.example.com',
|
|
66
73
|
port: 5432,
|
|
74
|
+
}, {
|
|
75
|
+
environment: 'production'
|
|
67
76
|
});
|
|
68
77
|
|
|
69
78
|
// Delete configuration
|
|
@@ -84,6 +93,9 @@ const client = new OpenSecureConfClient({
|
|
|
84
93
|
const config = await client.create('api_keys', {
|
|
85
94
|
stripe: 'sk_live_xxx',
|
|
86
95
|
aws: 'AKIA_xxx',
|
|
96
|
+
}, {
|
|
97
|
+
category: 'secrets',
|
|
98
|
+
environment: 'production'
|
|
87
99
|
});
|
|
88
100
|
```
|
|
89
101
|
|
|
@@ -101,6 +113,80 @@ const info = await client.getInfo();
|
|
|
101
113
|
console.log(info.service); // OpenSecureConf API
|
|
102
114
|
```
|
|
103
115
|
|
|
116
|
+
## 💾 Backup & Restore
|
|
117
|
+
|
|
118
|
+
### Create Backup
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
// Backup all configurations
|
|
122
|
+
const backup = await client.createBackup('my-backup-password-123');
|
|
123
|
+
console.log(`Backup ID: ${backup.backup_id}`);
|
|
124
|
+
console.log(`Total configs: ${backup.total_configs}`);
|
|
125
|
+
console.log(`Timestamp: ${backup.backup_timestamp}`);
|
|
126
|
+
|
|
127
|
+
// Backup specific environment
|
|
128
|
+
const prodBackup = await client.createBackup('password123', {
|
|
129
|
+
environment: 'production'
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// Backup specific category
|
|
133
|
+
const dbBackup = await client.createBackup('password123', {
|
|
134
|
+
category: 'database'
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
// Backup specific category and environment
|
|
138
|
+
const backup = await client.createBackup('password123', {
|
|
139
|
+
category: 'database',
|
|
140
|
+
environment: 'production'
|
|
141
|
+
});
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Import Backup
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
// Import without overwriting existing configs
|
|
148
|
+
const result = await client.importBackup(
|
|
149
|
+
backup.backup_data,
|
|
150
|
+
'my-backup-password-123',
|
|
151
|
+
false // don't overwrite
|
|
152
|
+
);
|
|
153
|
+
console.log(`Imported: ${result.imported_count}`);
|
|
154
|
+
console.log(`Skipped: ${result.skipped_count}`);
|
|
155
|
+
|
|
156
|
+
// Import with overwrite
|
|
157
|
+
const resultOverwrite = await client.importBackup(
|
|
158
|
+
backup.backup_data,
|
|
159
|
+
'my-backup-password-123',
|
|
160
|
+
true // overwrite existing
|
|
161
|
+
);
|
|
162
|
+
console.log(`Imported: ${resultOverwrite.imported_count}`);
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Backup to File (Node.js only)
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
// Save backup to file
|
|
169
|
+
await client.backupToFile(
|
|
170
|
+
'my-backup-password-123',
|
|
171
|
+
'./backups/full-backup-2026-02-05.json'
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
// Backup production environment to file
|
|
175
|
+
await client.backupToFile(
|
|
176
|
+
'password123',
|
|
177
|
+
'./backups/prod-backup.json',
|
|
178
|
+
{ environment: 'production' }
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
// Import from file
|
|
182
|
+
const importResult = await client.importFromFile(
|
|
183
|
+
'my-backup-password-123',
|
|
184
|
+
'./backups/full-backup-2026-02-05.json',
|
|
185
|
+
false // don't overwrite
|
|
186
|
+
);
|
|
187
|
+
console.log(`Restored ${importResult.imported_count} configurations`);
|
|
188
|
+
```
|
|
189
|
+
|
|
104
190
|
## 📖 API Reference
|
|
105
191
|
|
|
106
192
|
### Constructor Options
|
|
@@ -120,34 +206,75 @@ interface OpenSecureConfOptions {
|
|
|
120
206
|
#### Configuration Operations
|
|
121
207
|
|
|
122
208
|
```typescript
|
|
123
|
-
// Create
|
|
209
|
+
// Create with environment and category
|
|
124
210
|
await client.create(
|
|
125
211
|
key: string,
|
|
126
|
-
value:
|
|
127
|
-
category?: string
|
|
212
|
+
value: ConfigValue,
|
|
213
|
+
options?: { category?: string; environment?: string }
|
|
128
214
|
): Promise<ConfigEntry>
|
|
129
215
|
|
|
130
216
|
// Read
|
|
131
217
|
await client.read(key: string): Promise<ConfigEntry>
|
|
132
218
|
|
|
133
|
-
// Update
|
|
219
|
+
// Update with environment and category
|
|
134
220
|
await client.update(
|
|
135
221
|
key: string,
|
|
136
|
-
value:
|
|
137
|
-
category?: string
|
|
222
|
+
value: ConfigValue,
|
|
223
|
+
options?: { category?: string; environment?: string }
|
|
138
224
|
): Promise<ConfigEntry>
|
|
139
225
|
|
|
140
226
|
// Delete
|
|
141
227
|
await client.delete(key: string): Promise<{ message: string }>
|
|
142
228
|
|
|
143
|
-
// List
|
|
144
|
-
await client.list(
|
|
229
|
+
// List with filters
|
|
230
|
+
await client.list(
|
|
231
|
+
options?: { category?: string; environment?: string }
|
|
232
|
+
): Promise<ConfigEntry[]>
|
|
145
233
|
|
|
146
234
|
// Check existence
|
|
147
235
|
await client.exists(key: string): Promise<boolean>
|
|
148
236
|
|
|
149
|
-
// Count
|
|
150
|
-
await client.count(
|
|
237
|
+
// Count with filters
|
|
238
|
+
await client.count(
|
|
239
|
+
options?: { category?: string; environment?: string }
|
|
240
|
+
): Promise<number>
|
|
241
|
+
|
|
242
|
+
// List all categories
|
|
243
|
+
await client.listCategories(): Promise<string[]>
|
|
244
|
+
|
|
245
|
+
// List all environments
|
|
246
|
+
await client.listEnvironments(): Promise<string[]>
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
#### Backup & Import Operations
|
|
250
|
+
|
|
251
|
+
```typescript
|
|
252
|
+
// Create encrypted backup
|
|
253
|
+
await client.createBackup(
|
|
254
|
+
backupPassword: string,
|
|
255
|
+
options?: { category?: string; environment?: string }
|
|
256
|
+
): Promise<BackupResponse>
|
|
257
|
+
|
|
258
|
+
// Import encrypted backup
|
|
259
|
+
await client.importBackup(
|
|
260
|
+
backupData: string,
|
|
261
|
+
backupPassword: string,
|
|
262
|
+
overwrite?: boolean
|
|
263
|
+
): Promise<ImportResponse>
|
|
264
|
+
|
|
265
|
+
// Backup to file (Node.js only)
|
|
266
|
+
await client.backupToFile(
|
|
267
|
+
backupPassword: string,
|
|
268
|
+
filePath: string,
|
|
269
|
+
options?: { category?: string; environment?: string }
|
|
270
|
+
): Promise<BackupResponse>
|
|
271
|
+
|
|
272
|
+
// Import from file (Node.js only)
|
|
273
|
+
await client.importFromFile(
|
|
274
|
+
backupPassword: string,
|
|
275
|
+
filePath: string,
|
|
276
|
+
overwrite?: boolean
|
|
277
|
+
): Promise<ImportResponse>
|
|
151
278
|
```
|
|
152
279
|
|
|
153
280
|
#### Batch Operations
|
|
@@ -155,7 +282,12 @@ await client.count(category?: string): Promise<number>
|
|
|
155
282
|
```typescript
|
|
156
283
|
// Bulk create
|
|
157
284
|
await client.bulkCreate(
|
|
158
|
-
configs: Array<{
|
|
285
|
+
configs: Array<{
|
|
286
|
+
key: string;
|
|
287
|
+
value: ConfigValue;
|
|
288
|
+
category?: string;
|
|
289
|
+
environment?: string;
|
|
290
|
+
}>,
|
|
159
291
|
ignoreErrors?: boolean
|
|
160
292
|
): Promise<ConfigEntry[]>
|
|
161
293
|
|
|
@@ -247,7 +379,7 @@ const client = new OpenSecureConfClient({
|
|
|
247
379
|
|
|
248
380
|
## 📚 Usage Examples
|
|
249
381
|
|
|
250
|
-
### Complete Workflow
|
|
382
|
+
### Complete Workflow with Backup
|
|
251
383
|
|
|
252
384
|
```typescript
|
|
253
385
|
import OpenSecureConfClient, { OpenSecureConfError } from 'opensecureconf-client';
|
|
@@ -269,27 +401,62 @@ async function workflow() {
|
|
|
269
401
|
await client.create('database', {
|
|
270
402
|
host: 'postgres.local',
|
|
271
403
|
port: 5432,
|
|
404
|
+
}, {
|
|
405
|
+
category: 'config',
|
|
406
|
+
environment: 'production'
|
|
272
407
|
});
|
|
273
408
|
|
|
274
409
|
// 3. Batch create
|
|
275
410
|
await client.bulkCreate([
|
|
276
|
-
{
|
|
277
|
-
|
|
411
|
+
{
|
|
412
|
+
key: 'redis',
|
|
413
|
+
value: { host: 'redis.local', port: 6379 },
|
|
414
|
+
category: 'cache',
|
|
415
|
+
environment: 'production'
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
key: 'cache_ttl',
|
|
419
|
+
value: 3600,
|
|
420
|
+
category: 'settings',
|
|
421
|
+
environment: 'production'
|
|
422
|
+
},
|
|
278
423
|
], true);
|
|
279
424
|
|
|
280
|
-
// 4. List all
|
|
281
|
-
const
|
|
282
|
-
console.log(`
|
|
425
|
+
// 4. List all production configs
|
|
426
|
+
const prodConfigs = await client.list({ environment: 'production' });
|
|
427
|
+
console.log(`Production configs: ${prodConfigs.length}`);
|
|
283
428
|
|
|
284
|
-
// 5.
|
|
429
|
+
// 5. Create backup before updates
|
|
430
|
+
const backup = await client.createBackup('backup-password-123', {
|
|
431
|
+
environment: 'production'
|
|
432
|
+
});
|
|
433
|
+
console.log(`Backed up ${backup.total_configs} configurations`);
|
|
434
|
+
|
|
435
|
+
// 6. Update configuration
|
|
285
436
|
await client.update('database', {
|
|
286
437
|
host: 'postgres.local',
|
|
287
438
|
port: 5432,
|
|
288
439
|
ssl: true,
|
|
440
|
+
}, {
|
|
441
|
+
environment: 'production'
|
|
289
442
|
});
|
|
290
443
|
|
|
291
|
-
//
|
|
292
|
-
await client.
|
|
444
|
+
// 7. Save backup to file (Node.js)
|
|
445
|
+
await client.backupToFile(
|
|
446
|
+
'backup-password-123',
|
|
447
|
+
'./backups/prod-backup.json',
|
|
448
|
+
{ environment: 'production' }
|
|
449
|
+
);
|
|
450
|
+
|
|
451
|
+
// 8. Restore from backup if needed
|
|
452
|
+
// const restored = await client.importFromFile(
|
|
453
|
+
// 'backup-password-123',
|
|
454
|
+
// './backups/prod-backup.json',
|
|
455
|
+
// true
|
|
456
|
+
// );
|
|
457
|
+
|
|
458
|
+
// 9. Cleanup
|
|
459
|
+
await client.bulkDelete(['database', 'redis', 'cache_ttl'], true);
|
|
293
460
|
|
|
294
461
|
} catch (error) {
|
|
295
462
|
if (error instanceof OpenSecureConfError) {
|
|
@@ -299,6 +466,97 @@ async function workflow() {
|
|
|
299
466
|
}
|
|
300
467
|
```
|
|
301
468
|
|
|
469
|
+
### Environment & Category Management
|
|
470
|
+
|
|
471
|
+
```typescript
|
|
472
|
+
// Create configs with different environments
|
|
473
|
+
await client.create('api_url', 'https://api.dev.example.com', {
|
|
474
|
+
category: 'config',
|
|
475
|
+
environment: 'development'
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
await client.create('api_url', 'https://api.staging.example.com', {
|
|
479
|
+
category: 'config',
|
|
480
|
+
environment: 'staging'
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
await client.create('api_url', 'https://api.example.com', {
|
|
484
|
+
category: 'config',
|
|
485
|
+
environment: 'production'
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
// List all environments
|
|
489
|
+
const environments = await client.listEnvironments();
|
|
490
|
+
console.log(environments); // ['development', 'production', 'staging']
|
|
491
|
+
|
|
492
|
+
// List all categories
|
|
493
|
+
const categories = await client.listCategories();
|
|
494
|
+
console.log(categories); // ['cache', 'config', 'settings']
|
|
495
|
+
|
|
496
|
+
// List configs by environment
|
|
497
|
+
const prodConfigs = await client.list({ environment: 'production' });
|
|
498
|
+
|
|
499
|
+
// List configs by category
|
|
500
|
+
const cacheConfigs = await client.list({ category: 'cache' });
|
|
501
|
+
|
|
502
|
+
// List configs by both
|
|
503
|
+
const prodCacheConfigs = await client.list({
|
|
504
|
+
category: 'cache',
|
|
505
|
+
environment: 'production'
|
|
506
|
+
});
|
|
507
|
+
|
|
508
|
+
// Count configs by filters
|
|
509
|
+
const prodCount = await client.count({ environment: 'production' });
|
|
510
|
+
console.log(`Production configs: ${prodCount}`);
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
### Disaster Recovery Workflow
|
|
514
|
+
|
|
515
|
+
```typescript
|
|
516
|
+
// Daily backup routine
|
|
517
|
+
async function dailyBackup() {
|
|
518
|
+
const timestamp = new Date().toISOString().split('T');
|
|
519
|
+
|
|
520
|
+
// Backup production
|
|
521
|
+
await client.backupToFile(
|
|
522
|
+
process.env.BACKUP_PASSWORD!,
|
|
523
|
+
`./backups/prod-${timestamp}.json`,
|
|
524
|
+
{ environment: 'production' }
|
|
525
|
+
);
|
|
526
|
+
|
|
527
|
+
// Backup staging
|
|
528
|
+
await client.backupToFile(
|
|
529
|
+
process.env.BACKUP_PASSWORD!,
|
|
530
|
+
`./backups/staging-${timestamp}.json`,
|
|
531
|
+
{ environment: 'staging' }
|
|
532
|
+
);
|
|
533
|
+
|
|
534
|
+
console.log(`Backups created for ${timestamp}`);
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
// Restore from backup
|
|
538
|
+
async function restoreFromBackup(backupFile: string, overwrite = false) {
|
|
539
|
+
const result = await client.importFromFile(
|
|
540
|
+
process.env.BACKUP_PASSWORD!,
|
|
541
|
+
backupFile,
|
|
542
|
+
overwrite
|
|
543
|
+
);
|
|
544
|
+
|
|
545
|
+
console.log(`Restored ${result.imported_count} configurations`);
|
|
546
|
+
|
|
547
|
+
if (result.skipped_count) {
|
|
548
|
+
console.log(`Skipped ${result.skipped_count} existing configurations`);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
if (result.errors && result.errors.length > 0) {
|
|
552
|
+
console.error('Import errors:');
|
|
553
|
+
result.errors.forEach(err => {
|
|
554
|
+
console.error(` - ${err.key}: ${err.error}`);
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
```
|
|
559
|
+
|
|
302
560
|
### Error Handling
|
|
303
561
|
|
|
304
562
|
```typescript
|
|
@@ -308,7 +566,7 @@ try {
|
|
|
308
566
|
if (error instanceof OpenSecureConfError) {
|
|
309
567
|
switch (error.statusCode) {
|
|
310
568
|
case 401:
|
|
311
|
-
console.error('Authentication failed');
|
|
569
|
+
console.error('Authentication failed - check user key');
|
|
312
570
|
break;
|
|
313
571
|
case 404:
|
|
314
572
|
console.error('Configuration not found');
|
|
@@ -316,6 +574,9 @@ try {
|
|
|
316
574
|
case 408:
|
|
317
575
|
console.error('Request timeout');
|
|
318
576
|
break;
|
|
577
|
+
case 422:
|
|
578
|
+
console.error('Validation error:', error.detail);
|
|
579
|
+
break;
|
|
319
580
|
default:
|
|
320
581
|
console.error(`API error: ${error.message}`);
|
|
321
582
|
}
|
|
@@ -329,7 +590,8 @@ try {
|
|
|
329
590
|
// Check cluster status
|
|
330
591
|
const status = await client.getClusterStatus();
|
|
331
592
|
if (status.enabled) {
|
|
332
|
-
console.log(`
|
|
593
|
+
console.log(`Cluster mode: ${status.mode}`);
|
|
594
|
+
console.log(`Node ID: ${status.node_id}`);
|
|
333
595
|
console.log(`Nodes: ${status.healthy_nodes}/${status.total_nodes}`);
|
|
334
596
|
}
|
|
335
597
|
|
|
@@ -350,22 +612,6 @@ const client = new OpenSecureConfClient({
|
|
|
350
612
|
});
|
|
351
613
|
```
|
|
352
614
|
|
|
353
|
-
### Category Filtering
|
|
354
|
-
|
|
355
|
-
```typescript
|
|
356
|
-
// Create with category
|
|
357
|
-
await client.create('db', { host: 'localhost' }, 'production');
|
|
358
|
-
await client.create('cache', { ttl: 3600 }, 'production');
|
|
359
|
-
|
|
360
|
-
// List by category
|
|
361
|
-
const prodConfigs = await client.list('production');
|
|
362
|
-
console.log(prodConfigs); // Only production configs
|
|
363
|
-
|
|
364
|
-
// Count by category
|
|
365
|
-
const count = await client.count('production');
|
|
366
|
-
console.log(`Production configs: ${count}`);
|
|
367
|
-
```
|
|
368
|
-
|
|
369
615
|
### Batch Operations with Error Handling
|
|
370
616
|
|
|
371
617
|
```typescript
|
|
@@ -382,6 +628,35 @@ for (const failure of result.failed) {
|
|
|
382
628
|
}
|
|
383
629
|
```
|
|
384
630
|
|
|
631
|
+
### Type-Safe Value Types
|
|
632
|
+
|
|
633
|
+
```typescript
|
|
634
|
+
// Object value
|
|
635
|
+
await client.create('database', {
|
|
636
|
+
host: 'localhost',
|
|
637
|
+
port: 5432
|
|
638
|
+
});
|
|
639
|
+
|
|
640
|
+
// String value
|
|
641
|
+
await client.create('api_token', 'secret-token-123');
|
|
642
|
+
|
|
643
|
+
// Number value
|
|
644
|
+
await client.create('max_retries', 3);
|
|
645
|
+
|
|
646
|
+
// Boolean value
|
|
647
|
+
await client.create('debug_enabled', false);
|
|
648
|
+
|
|
649
|
+
// Array value
|
|
650
|
+
await client.create('allowed_ips', ['192.168.1.1', '10.0.0.1']);
|
|
651
|
+
|
|
652
|
+
// Read preserves types
|
|
653
|
+
const dbConfig = await client.read('database');
|
|
654
|
+
console.log(dbConfig.value.port); // number: 5432
|
|
655
|
+
|
|
656
|
+
const token = await client.read('api_token');
|
|
657
|
+
console.log(token.value); // string: 'secret-token-123'
|
|
658
|
+
```
|
|
659
|
+
|
|
385
660
|
## 🔍 TypeScript Support
|
|
386
661
|
|
|
387
662
|
Full TypeScript definitions included:
|
|
@@ -390,7 +665,10 @@ Full TypeScript definitions included:
|
|
|
390
665
|
import OpenSecureConfClient, {
|
|
391
666
|
OpenSecureConfOptions,
|
|
392
667
|
ConfigEntry,
|
|
668
|
+
ConfigValue,
|
|
393
669
|
ClusterStatus,
|
|
670
|
+
BackupResponse,
|
|
671
|
+
ImportResponse,
|
|
394
672
|
OpenSecureConfError,
|
|
395
673
|
} from 'opensecureconf-client';
|
|
396
674
|
|
|
@@ -406,6 +684,11 @@ const client = new OpenSecureConfClient(options);
|
|
|
406
684
|
// Return types are inferred
|
|
407
685
|
const config: ConfigEntry = await client.read('key');
|
|
408
686
|
const status: ClusterStatus = await client.getClusterStatus();
|
|
687
|
+
const backup: BackupResponse = await client.createBackup('password123');
|
|
688
|
+
const importResult: ImportResponse = await client.importBackup(
|
|
689
|
+
backup.backup_data,
|
|
690
|
+
'password123'
|
|
691
|
+
);
|
|
409
692
|
```
|
|
410
693
|
|
|
411
694
|
## 🔐 Security Best Practices
|
|
@@ -415,9 +698,13 @@ const status: ClusterStatus = await client.getClusterStatus();
|
|
|
415
698
|
- Use HTTPS in production (`https://`)
|
|
416
699
|
- Use valid SSL certificates (Let's Encrypt, trusted CA)
|
|
417
700
|
- Set strong user keys (16+ characters)
|
|
701
|
+
- Use strong backup passwords (16+ characters)
|
|
418
702
|
- Enable API key authentication
|
|
419
703
|
- Use environment variables for secrets
|
|
420
704
|
- Set appropriate timeouts
|
|
705
|
+
- Store backups securely and encrypted
|
|
706
|
+
- Rotate backup passwords regularly
|
|
707
|
+
- Test backup/restore procedures periodically
|
|
421
708
|
|
|
422
709
|
### ❌ Don'ts
|
|
423
710
|
|
|
@@ -426,6 +713,9 @@ const status: ClusterStatus = await client.getClusterStatus();
|
|
|
426
713
|
- **Never** commit secrets to version control
|
|
427
714
|
- **Never** use short encryption keys (<8 chars)
|
|
428
715
|
- **Never** expose API endpoints without authentication
|
|
716
|
+
- **Never** store backups in plaintext
|
|
717
|
+
- **Never** use weak backup passwords
|
|
718
|
+
- **Never** share backup passwords insecurely
|
|
429
719
|
|
|
430
720
|
### Environment Variables
|
|
431
721
|
|
|
@@ -436,6 +726,11 @@ const client = new OpenSecureConfClient({
|
|
|
436
726
|
apiKey: process.env.OSC_API_KEY,
|
|
437
727
|
rejectUnauthorized: process.env.NODE_ENV === 'production',
|
|
438
728
|
});
|
|
729
|
+
|
|
730
|
+
// Backup with environment variable password
|
|
731
|
+
const backup = await client.createBackup(
|
|
732
|
+
process.env.OSC_BACKUP_PASSWORD!
|
|
733
|
+
);
|
|
439
734
|
```
|
|
440
735
|
|
|
441
736
|
## 🌍 Browser vs Node.js
|
|
@@ -446,6 +741,7 @@ const client = new OpenSecureConfClient({
|
|
|
446
741
|
// Automatic HTTPS agent setup
|
|
447
742
|
// Supports rejectUnauthorized option
|
|
448
743
|
// Full control over SSL/TLS
|
|
744
|
+
// File-based backup operations (backupToFile, importFromFile)
|
|
449
745
|
```
|
|
450
746
|
|
|
451
747
|
### Browser
|
|
@@ -455,6 +751,7 @@ const client = new OpenSecureConfClient({
|
|
|
455
751
|
// SSL validation by browser
|
|
456
752
|
// rejectUnauthorized ignored (browser controls SSL)
|
|
457
753
|
// Works with CORS-enabled servers
|
|
754
|
+
// No file-based operations (use createBackup/importBackup with manual file handling)
|
|
458
755
|
```
|
|
459
756
|
|
|
460
757
|
## 📊 Error Codes
|
|
@@ -467,12 +764,14 @@ const client = new OpenSecureConfClient({
|
|
|
467
764
|
| 403 | Forbidden | Invalid API key |
|
|
468
765
|
| 404 | Not Found | Configuration not found |
|
|
469
766
|
| 408 | Timeout | Request timeout |
|
|
767
|
+
| 422 | Validation Error | Invalid backup data or password |
|
|
470
768
|
| 429 | Rate Limit | Too many requests |
|
|
471
769
|
| 500+ | Server Error | Internal server error |
|
|
472
770
|
|
|
473
771
|
## 🔗 Links
|
|
474
772
|
|
|
475
773
|
- **GitHub**: [OpenSecureConf](https://github.com/lordraw77/OpenSecureConf)
|
|
774
|
+
- **NPM**: [opensecureconf-client](https://www.npmjs.com/package/opensecureconf-client)
|
|
476
775
|
- **Docker Hub**: [lordraw/open-secureconfiguration](https://hub.docker.com/r/lordraw/open-secureconfiguration)
|
|
477
776
|
- **PyPI Client**: [opensecureconf-client](https://pypi.org/project/opensecureconf-client/)
|
|
478
777
|
- **Documentation**: [GitHub README](https://github.com/lordraw77/OpenSecureConf/blob/main/README.md)
|
|
@@ -487,6 +786,20 @@ Contributions are welcome! Please open an issue or submit a pull request.
|
|
|
487
786
|
|
|
488
787
|
## 📝 Changelog
|
|
489
788
|
|
|
789
|
+
### v2.3.3
|
|
790
|
+
- ✨ Added encrypted backup operations (`createBackup`, `importBackup`)
|
|
791
|
+
- ✨ Added file-based backup for Node.js (`backupToFile`, `importFromFile`)
|
|
792
|
+
- ✨ Added environment and category filtering to all operations
|
|
793
|
+
- ✨ Added `listCategories()` and `listEnvironments()` methods
|
|
794
|
+
- ✨ Support for multiple value types (object, string, number, boolean, array)
|
|
795
|
+
- 📚 Enhanced documentation with backup/restore examples
|
|
796
|
+
- 🔒 Improved security practices for backup passwords
|
|
797
|
+
|
|
798
|
+
### v2.0.0
|
|
799
|
+
- ✨ Added environment and category support
|
|
800
|
+
- ✨ Enhanced filtering capabilities
|
|
801
|
+
- 🔄 Breaking: Updated create/update signatures to support options object
|
|
802
|
+
|
|
490
803
|
### v1.1.0
|
|
491
804
|
- ✨ Added HTTPS/SSL support
|
|
492
805
|
- ✨ Added `rejectUnauthorized` option
|
|
@@ -506,6 +819,7 @@ Contributions are welcome! Please open an issue or submit a pull request.
|
|
|
506
819
|
|
|
507
820
|
**OpenSecureConf TypeScript Client** - Secure configuration management made simple.
|
|
508
821
|
|
|
509
|
-
**Version**: 2.3.
|
|
510
|
-
**Author**:
|
|
822
|
+
**Version**: 2.3.3
|
|
823
|
+
**Author**: Apioli <alessandro.pioli+apioli-npm@gmail.com>
|
|
824
|
+
**Repository**: [GitHub](https://github.com/lordraw77/OpenSecureConf/tree/main/client-js)
|
|
511
825
|
**Support**: [GitHub Issues](https://github.com/lordraw77/OpenSecureConf/issues)
|