lsh-framework 2.3.2 → 3.1.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.
@@ -155,19 +155,21 @@ export class BillingService {
155
155
  /**
156
156
  * Verify webhook signature
157
157
  */
158
- verifyWebhookSignature(payload, signature) {
158
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Stripe event structure
159
+ verifyWebhookSignature(payload, _signature) {
159
160
  // In production, use Stripe's webhook signature verification
160
161
  // For now, just parse the payload
161
162
  try {
162
163
  return JSON.parse(payload);
163
164
  }
164
- catch (error) {
165
+ catch (_error) {
165
166
  throw new Error('Invalid webhook payload');
166
167
  }
167
168
  }
168
169
  /**
169
170
  * Handle checkout completed
170
171
  */
172
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Stripe checkout session object
171
173
  async handleCheckoutCompleted(session) {
172
174
  const organizationId = session.metadata?.organization_id;
173
175
  if (!organizationId) {
@@ -180,6 +182,7 @@ export class BillingService {
180
182
  /**
181
183
  * Handle subscription updated
182
184
  */
185
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Stripe subscription object
183
186
  async handleSubscriptionUpdated(subscription) {
184
187
  const organizationId = subscription.metadata?.organization_id;
185
188
  if (!organizationId) {
@@ -233,6 +236,7 @@ export class BillingService {
233
236
  /**
234
237
  * Handle subscription deleted
235
238
  */
239
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Stripe subscription object
236
240
  async handleSubscriptionDeleted(subscription) {
237
241
  const organizationId = subscription.metadata?.organization_id;
238
242
  if (!organizationId) {
@@ -265,6 +269,7 @@ export class BillingService {
265
269
  /**
266
270
  * Handle invoice paid
267
271
  */
272
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Stripe invoice object
268
273
  async handleInvoicePaid(invoice) {
269
274
  const organizationId = invoice.subscription_metadata?.organization_id;
270
275
  if (!organizationId) {
@@ -287,6 +292,7 @@ export class BillingService {
287
292
  /**
288
293
  * Handle invoice payment failed
289
294
  */
295
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Stripe invoice object
290
296
  async handleInvoicePaymentFailed(invoice) {
291
297
  const organizationId = invoice.subscription_metadata?.organization_id;
292
298
  if (!organizationId) {
@@ -353,6 +359,7 @@ export class BillingService {
353
359
  /**
354
360
  * Map database subscription to Subscription type
355
361
  */
362
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- DB row type varies by schema
356
363
  mapDbSubscriptionToSubscription(dbSub) {
357
364
  return {
358
365
  id: dbSub.id,
@@ -377,6 +384,7 @@ export class BillingService {
377
384
  /**
378
385
  * Map database invoice to Invoice type
379
386
  */
387
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- DB row type varies by schema
380
388
  mapDbInvoiceToInvoice(dbInvoice) {
381
389
  return {
382
390
  id: dbInvoice.id,
@@ -7,7 +7,7 @@ import { getSupabaseClient } from './supabase-client.js';
7
7
  const ALGORITHM = 'aes-256-cbc';
8
8
  const KEY_LENGTH = 32; // 256 bits
9
9
  const IV_LENGTH = 16; // 128 bits
10
- const SALT_LENGTH = 32;
10
+ const _SALT_LENGTH = 32; // Reserved for future use
11
11
  const PBKDF2_ITERATIONS = 100000;
12
12
  /**
13
13
  * Get master encryption key from environment
@@ -199,6 +199,7 @@ export class EncryptionService {
199
199
  /**
200
200
  * Map database key to EncryptionKey type
201
201
  */
202
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- DB row type varies by schema
202
203
  mapDbKeyToKey(dbKey) {
203
204
  return {
204
205
  id: dbKey.id,
@@ -332,6 +332,7 @@ export class OrganizationService {
332
332
  /**
333
333
  * Map database org to Organization type
334
334
  */
335
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- DB row type varies by schema
335
336
  mapDbOrgToOrg(dbOrg) {
336
337
  return {
337
338
  id: dbOrg.id,
@@ -352,6 +353,7 @@ export class OrganizationService {
352
353
  /**
353
354
  * Map database member to OrganizationMember type
354
355
  */
356
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- DB row type varies by schema
355
357
  mapDbMemberToMember(dbMember) {
356
358
  return {
357
359
  id: dbMember.id,
@@ -368,6 +370,7 @@ export class OrganizationService {
368
370
  /**
369
371
  * Map database member detailed to OrganizationMemberDetailed type
370
372
  */
373
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- DB row with joined user data
371
374
  mapDbMemberDetailedToMemberDetailed(dbMember) {
372
375
  return {
373
376
  id: dbMember.id,
@@ -558,6 +561,7 @@ export class TeamService {
558
561
  /**
559
562
  * Map database team to Team type
560
563
  */
564
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- DB row type varies by schema
561
565
  mapDbTeamToTeam(dbTeam) {
562
566
  return {
563
567
  id: dbTeam.id,
@@ -574,6 +578,7 @@ export class TeamService {
574
578
  /**
575
579
  * Map database team member to TeamMember type
576
580
  */
581
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- DB row type varies by schema
577
582
  mapDbTeamMemberToTeamMember(dbMember) {
578
583
  return {
579
584
  id: dbMember.id,
@@ -2,6 +2,7 @@
2
2
  * LSH SaaS Secrets Management Service
3
3
  * Multi-tenant secrets with per-team encryption
4
4
  */
5
+ import { getErrorMessage, } from './saas-types.js';
5
6
  import { getSupabaseClient } from './supabase-client.js';
6
7
  import { encryptionService } from './saas-encryption.js';
7
8
  import { auditLogger } from './saas-audit.js';
@@ -216,6 +217,7 @@ export class SecretsService {
216
217
  if (error) {
217
218
  throw new Error(`Failed to get secrets summary: ${error.message}`);
218
219
  }
220
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- DB row from view
219
221
  return (data || []).map((row) => ({
220
222
  teamId: row.team_id,
221
223
  teamName: row.team_name,
@@ -313,7 +315,7 @@ export class SecretsService {
313
315
  }
314
316
  }
315
317
  catch (error) {
316
- errors.push(`${secret.key}: ${error.message}`);
318
+ errors.push(`${secret.key}: ${getErrorMessage(error)}`);
317
319
  }
318
320
  }
319
321
  return { created, updated, errors };
@@ -351,6 +353,7 @@ export class SecretsService {
351
353
  /**
352
354
  * Map database secret to Secret type
353
355
  */
356
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- DB row type varies by schema
354
357
  mapDbSecretToSecret(dbSecret) {
355
358
  return {
356
359
  id: dbSecret.id,
@@ -106,3 +106,60 @@ export var ErrorCode;
106
106
  ErrorCode["INTERNAL_ERROR"] = "INTERNAL_ERROR";
107
107
  ErrorCode["SERVICE_UNAVAILABLE"] = "SERVICE_UNAVAILABLE";
108
108
  })(ErrorCode || (ErrorCode = {}));
109
+ /**
110
+ * Helper to safely extract error message
111
+ */
112
+ export function getErrorMessage(error) {
113
+ if (error instanceof Error) {
114
+ return error.message;
115
+ }
116
+ if (typeof error === 'string') {
117
+ return error;
118
+ }
119
+ return 'Unknown error occurred';
120
+ }
121
+ /**
122
+ * Helper to safely extract error for logging
123
+ */
124
+ export function getErrorDetails(error) {
125
+ if (error instanceof Error) {
126
+ return {
127
+ message: error.message,
128
+ stack: error.stack,
129
+ code: error.code,
130
+ };
131
+ }
132
+ return { message: String(error) };
133
+ }
134
+ /**
135
+ * Helper to get authenticated user from request.
136
+ * Use after authenticateUser middleware - throws if user not present.
137
+ */
138
+ export function getAuthenticatedUser(req) {
139
+ if (!req.user) {
140
+ throw new Error('User not authenticated');
141
+ }
142
+ return req.user;
143
+ }
144
+ /**
145
+ * Create a standardized API error response
146
+ */
147
+ export function createErrorResponse(code, message, details) {
148
+ return {
149
+ success: false,
150
+ error: {
151
+ code,
152
+ message,
153
+ details,
154
+ },
155
+ };
156
+ }
157
+ /**
158
+ * Create a standardized API success response
159
+ */
160
+ export function createSuccessResponse(data) {
161
+ return {
162
+ success: true,
163
+ data,
164
+ };
165
+ }
@@ -14,15 +14,53 @@ export class SecretsManager {
14
14
  storage;
15
15
  encryptionKey;
16
16
  gitInfo;
17
- constructor(userId, encryptionKey, detectGit = true) {
17
+ globalMode;
18
+ homeDir;
19
+ constructor(userIdOrOptions, encryptionKey, detectGit) {
18
20
  this.storage = new IPFSSecretsStorage();
21
+ this.homeDir = process.env.HOME || process.env.USERPROFILE || '';
22
+ // Handle both legacy and new constructor signatures
23
+ let options;
24
+ if (typeof userIdOrOptions === 'object') {
25
+ options = userIdOrOptions;
26
+ }
27
+ else {
28
+ options = {
29
+ userId: userIdOrOptions,
30
+ encryptionKey,
31
+ detectGit: detectGit ?? true,
32
+ globalMode: false,
33
+ };
34
+ }
35
+ this.globalMode = options.globalMode ?? false;
19
36
  // Use provided key or generate from machine ID + user
20
- this.encryptionKey = encryptionKey || this.getDefaultEncryptionKey();
21
- // Auto-detect git repo context
22
- if (detectGit) {
37
+ this.encryptionKey = options.encryptionKey || this.getDefaultEncryptionKey();
38
+ // Auto-detect git repo context (skip if in global mode)
39
+ if (!this.globalMode && (options.detectGit ?? true)) {
23
40
  this.gitInfo = getGitRepoInfo();
24
41
  }
25
42
  }
43
+ /**
44
+ * Check if running in global mode
45
+ */
46
+ isGlobalMode() {
47
+ return this.globalMode;
48
+ }
49
+ /**
50
+ * Get the home directory path
51
+ */
52
+ getHomeDir() {
53
+ return this.homeDir;
54
+ }
55
+ /**
56
+ * Resolve file path - in global mode, resolves relative to $HOME
57
+ */
58
+ resolveFilePath(filePath) {
59
+ if (this.globalMode && !path.isAbsolute(filePath)) {
60
+ return path.join(this.homeDir, filePath);
61
+ }
62
+ return filePath;
63
+ }
26
64
  /**
27
65
  * Cleanup resources (stop timers, close connections)
28
66
  * Call this when done to allow process to exit
@@ -430,8 +468,13 @@ export class SecretsManager {
430
468
  /**
431
469
  * Get the default environment name based on context
432
470
  * v2.0: In git repo, default is repo name; otherwise 'dev'
471
+ * Global mode: always returns 'dev' (which resolves to 'global' namespace)
433
472
  */
434
473
  getDefaultEnvironment() {
474
+ // Global mode uses simple 'dev' which maps to 'global' namespace
475
+ if (this.globalMode) {
476
+ return 'dev';
477
+ }
435
478
  // Check for v1 compatibility mode
436
479
  if (process.env.LSH_V1_COMPAT === 'true') {
437
480
  return 'dev'; // v1.x behavior
@@ -447,11 +490,19 @@ export class SecretsManager {
447
490
  * v2.0: Returns environment name with repo context if in a git repo
448
491
  *
449
492
  * Behavior:
493
+ * - Global mode: returns 'global' or 'global_env' (e.g., global_staging)
450
494
  * - Empty env in repo: returns just repo name (v2.0 default)
451
495
  * - Named env in repo: returns repo_env (e.g., repo_staging)
452
496
  * - Any env outside repo: returns env as-is
453
497
  */
454
498
  getRepoAwareEnvironment(environment) {
499
+ // Global mode uses 'global' namespace
500
+ if (this.globalMode) {
501
+ if (environment === '' || environment === 'default' || environment === 'dev') {
502
+ return 'global';
503
+ }
504
+ return `global_${environment}`;
505
+ }
455
506
  if (this.gitInfo?.repoName) {
456
507
  // v2.0: Empty environment means "use repo name only"
457
508
  if (environment === '' || environment === 'default') {
@@ -610,8 +661,14 @@ LSH_SECRETS_KEY=${this.encryptionKey}
610
661
  // In load mode, suppress all output except the final export commands
611
662
  const out = loadMode ? () => { } : console.log;
612
663
  out(`\nšŸ” Smart sync for: ${displayEnv}\n`);
613
- // Show git repo context if detected
614
- if (this.gitInfo?.isGitRepo) {
664
+ // Show workspace context
665
+ if (this.globalMode) {
666
+ out('🌐 Global Workspace:');
667
+ out(` Location: ${this.homeDir}`);
668
+ out(` Namespace: global`);
669
+ out();
670
+ }
671
+ else if (this.gitInfo?.isGitRepo) {
615
672
  out('šŸ“ Git Repository:');
616
673
  out(` Repo: ${this.gitInfo.repoName || 'unknown'}`);
617
674
  if (this.gitInfo.currentBranch) {
@@ -4,7 +4,6 @@
4
4
  */
5
5
  import { createClient } from '@supabase/supabase-js';
6
6
  export class SupabaseClient {
7
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
7
  client;
9
8
  config;
10
9
  constructor(config) {
@@ -32,7 +31,7 @@ export class SupabaseClient {
32
31
  */
33
32
  async testConnection() {
34
33
  try {
35
- const { _data, error } = await this.client
34
+ const { error } = await this.client
36
35
  .from('shell_history')
37
36
  .select('count')
38
37
  .limit(1);
@@ -14,13 +14,16 @@ export async function init_secrets(program) {
14
14
  .description('Push local .env to encrypted cloud storage')
15
15
  .option('-f, --file <path>', 'Path to .env file', '.env')
16
16
  .option('-e, --env <name>', 'Environment name (dev/staging/prod)', 'dev')
17
+ .option('-g, --global', 'Use global workspace ($HOME)')
17
18
  .option('--force', 'Force push even if destructive changes detected')
18
19
  .action(async (options) => {
19
- const manager = new SecretsManager();
20
+ const manager = new SecretsManager({ globalMode: options.global });
20
21
  try {
22
+ // Resolve file path (handles global mode)
23
+ const filePath = manager.resolveFilePath(options.file);
21
24
  // v2.0: Use context-aware default environment
22
25
  const env = options.env === 'dev' ? manager.getDefaultEnvironment() : options.env;
23
- await manager.push(options.file, env, options.force);
26
+ await manager.push(filePath, env, options.force);
24
27
  }
25
28
  catch (error) {
26
29
  const err = error;
@@ -38,13 +41,16 @@ export async function init_secrets(program) {
38
41
  .description('Pull .env from encrypted cloud storage')
39
42
  .option('-f, --file <path>', 'Path to .env file', '.env')
40
43
  .option('-e, --env <name>', 'Environment name (dev/staging/prod)', 'dev')
44
+ .option('-g, --global', 'Use global workspace ($HOME)')
41
45
  .option('--force', 'Overwrite without creating backup')
42
46
  .action(async (options) => {
43
- const manager = new SecretsManager();
47
+ const manager = new SecretsManager({ globalMode: options.global });
44
48
  try {
49
+ // Resolve file path (handles global mode)
50
+ const filePath = manager.resolveFilePath(options.file);
45
51
  // v2.0: Use context-aware default environment
46
52
  const env = options.env === 'dev' ? manager.getDefaultEnvironment() : options.env;
47
- await manager.pull(options.file, env, options.force);
53
+ await manager.pull(filePath, env, options.force);
48
54
  }
49
55
  catch (error) {
50
56
  const err = error;
@@ -62,12 +68,14 @@ export async function init_secrets(program) {
62
68
  .alias('ls')
63
69
  .description('List secrets in the current local .env file')
64
70
  .option('-f, --file <path>', 'Path to .env file', '.env')
71
+ .option('-g, --global', 'Use global workspace ($HOME)')
65
72
  .option('--keys-only', 'Show only keys, not values')
66
73
  .option('--format <type>', 'Output format: env, json, yaml, toml, export', 'env')
67
74
  .option('--no-mask', 'Show full values (default: auto based on format)')
68
75
  .action(async (options) => {
69
76
  try {
70
- const envPath = path.resolve(options.file);
77
+ const manager = new SecretsManager({ globalMode: options.global });
78
+ const envPath = path.resolve(manager.resolveFilePath(options.file));
71
79
  if (!fs.existsSync(envPath)) {
72
80
  console.error(`āŒ File not found: ${envPath}`);
73
81
  console.log('šŸ’” Tip: Pull from cloud with: lsh pull --env <environment>');
@@ -138,11 +146,12 @@ export async function init_secrets(program) {
138
146
  program
139
147
  .command('env [environment]')
140
148
  .description('List all stored environments or show secrets for specific environment')
149
+ .option('-g, --global', 'Use global workspace ($HOME)')
141
150
  .option('--all-files', 'List all tracked .env files across environments')
142
151
  .option('--format <type>', 'Output format: env, json, yaml, toml, export', 'env')
143
152
  .action(async (environment, options) => {
144
153
  try {
145
- const manager = new SecretsManager();
154
+ const manager = new SecretsManager({ globalMode: options.global });
146
155
  // If --all-files flag is set, list all tracked files
147
156
  if (options.allFiles) {
148
157
  const files = await manager.listAllFiles();
@@ -269,23 +278,26 @@ API_KEY=
269
278
  .description('Automatically set up and synchronize secrets (smart mode)')
270
279
  .option('-f, --file <path>', 'Path to .env file', '.env')
271
280
  .option('-e, --env <name>', 'Environment name', 'dev')
281
+ .option('-g, --global', 'Use global workspace ($HOME)')
272
282
  .option('--dry-run', 'Show what would be done without executing')
273
283
  .option('--legacy', 'Use legacy sync mode (suggestions only)')
274
284
  .option('--load', 'Output eval-able export commands for loading secrets')
275
285
  .option('--force', 'Force sync even if destructive changes detected')
276
286
  .option('--force-rekey', 'Re-encrypt cloud secrets with current local key (use when key mismatch)')
277
287
  .action(async (options) => {
278
- const manager = new SecretsManager();
288
+ const manager = new SecretsManager({ globalMode: options.global });
279
289
  try {
290
+ // Resolve file path (handles global mode)
291
+ const filePath = manager.resolveFilePath(options.file);
280
292
  // v2.0: Use context-aware default environment
281
293
  const env = options.env === 'dev' ? manager.getDefaultEnvironment() : options.env;
282
294
  if (options.legacy) {
283
295
  // Use legacy sync (suggestions only)
284
- await manager.sync(options.file, env);
296
+ await manager.sync(filePath, env);
285
297
  }
286
298
  else {
287
299
  // Use new smart sync (auto-execute)
288
- await manager.smartSync(options.file, env, !options.dryRun, options.load, options.force, options.forceRekey);
300
+ await manager.smartSync(filePath, env, !options.dryRun, options.load, options.force, options.forceRekey);
289
301
  }
290
302
  }
291
303
  catch (error) {
@@ -304,10 +316,12 @@ API_KEY=
304
316
  .description('Get detailed secrets status (JSON output)')
305
317
  .option('-f, --file <path>', 'Path to .env file', '.env')
306
318
  .option('-e, --env <name>', 'Environment name', 'dev')
319
+ .option('-g, --global', 'Use global workspace ($HOME)')
307
320
  .action(async (options) => {
308
321
  try {
309
- const manager = new SecretsManager();
310
- const status = await manager.status(options.file, options.env);
322
+ const manager = new SecretsManager({ globalMode: options.global });
323
+ const filePath = manager.resolveFilePath(options.file);
324
+ const status = await manager.status(filePath, options.env);
311
325
  console.log(JSON.stringify(status, null, 2));
312
326
  }
313
327
  catch (error) {
@@ -322,14 +336,20 @@ API_KEY=
322
336
  .description('Show current directory context and tracked environment')
323
337
  .option('-f, --file <path>', 'Path to .env file', '.env')
324
338
  .option('-e, --env <name>', 'Environment name', 'dev')
339
+ .option('-g, --global', 'Use global workspace ($HOME)')
325
340
  .action(async (options) => {
326
341
  try {
327
- const gitInfo = getGitRepoInfo();
328
- const manager = new SecretsManager();
329
- const envPath = path.resolve(options.file);
342
+ const gitInfo = options.global ? null : getGitRepoInfo();
343
+ const manager = new SecretsManager({ globalMode: options.global });
344
+ const envPath = path.resolve(manager.resolveFilePath(options.file));
330
345
  console.log('\nšŸ“ Current Directory Context\n');
331
- // Git Repository Info
332
- if (gitInfo.isGitRepo) {
346
+ // Workspace Info
347
+ if (options.global) {
348
+ console.log('🌐 Global Workspace:');
349
+ console.log(` Location: ${manager.getHomeDir()}`);
350
+ console.log(' Mode: Global (not repo-specific)');
351
+ }
352
+ else if (gitInfo?.isGitRepo) {
333
353
  console.log('šŸ“ Git Repository:');
334
354
  console.log(` Root: ${gitInfo.rootPath || 'unknown'}`);
335
355
  console.log(` Name: ${gitInfo.repoName || 'unknown'}`);
@@ -347,12 +367,22 @@ API_KEY=
347
367
  // Environment Tracking
348
368
  console.log('šŸ” Environment Tracking:');
349
369
  // Show the effective environment name used for cloud storage
350
- const effectiveEnv = gitInfo.repoName
351
- ? `${gitInfo.repoName}_${options.env}`
352
- : options.env;
370
+ let effectiveEnv;
371
+ if (options.global) {
372
+ effectiveEnv = options.env === 'dev' ? 'global' : `global_${options.env}`;
373
+ }
374
+ else {
375
+ effectiveEnv = gitInfo?.repoName
376
+ ? `${gitInfo.repoName}_${options.env}`
377
+ : options.env;
378
+ }
353
379
  console.log(` Base environment: ${options.env}`);
354
380
  console.log(` Cloud storage name: ${effectiveEnv}`);
355
- if (gitInfo.repoName) {
381
+ if (options.global) {
382
+ console.log(' Namespace: global');
383
+ console.log(' ā„¹ļø Global workspace mode enabled');
384
+ }
385
+ else if (gitInfo?.repoName) {
356
386
  console.log(` Namespace: ${gitInfo.repoName}`);
357
387
  console.log(' ā„¹ļø Repo-based isolation enabled');
358
388
  }
@@ -420,13 +450,15 @@ API_KEY=
420
450
  .command('get [key]')
421
451
  .description('Get a specific secret value from .env file, or all secrets with --all')
422
452
  .option('-f, --file <path>', 'Path to .env file', '.env')
453
+ .option('-g, --global', 'Use global workspace ($HOME)')
423
454
  .option('--all', 'Get all secrets from the file')
424
455
  .option('--export', 'Output in export format for shell evaluation (alias for --format export)')
425
456
  .option('--format <type>', 'Output format: env, json, yaml, toml, export', 'env')
426
457
  .option('--exact', 'Require exact key match (disable fuzzy matching)')
427
458
  .action(async (key, options) => {
428
459
  try {
429
- const envPath = path.resolve(options.file);
460
+ const manager = new SecretsManager({ globalMode: options.global });
461
+ const envPath = path.resolve(manager.resolveFilePath(options.file));
430
462
  if (!fs.existsSync(envPath)) {
431
463
  console.error(`āŒ File not found: ${envPath}`);
432
464
  process.exit(1);
@@ -535,10 +567,12 @@ API_KEY=
535
567
  .command('set [key] [value]')
536
568
  .description('Set a specific secret value in .env file, or batch upsert from stdin (KEY=VALUE format)')
537
569
  .option('-f, --file <path>', 'Path to .env file', '.env')
570
+ .option('-g, --global', 'Use global workspace ($HOME)')
538
571
  .option('--stdin', 'Read KEY=VALUE pairs from stdin (one per line)')
539
572
  .action(async (key, value, options) => {
540
573
  try {
541
- const envPath = path.resolve(options.file);
574
+ const manager = new SecretsManager({ globalMode: options.global });
575
+ const envPath = path.resolve(manager.resolveFilePath(options.file));
542
576
  // Check if we should read from stdin
543
577
  const isStdin = options.stdin || (!key && !value);
544
578
  if (isStdin) {
@@ -792,10 +826,12 @@ API_KEY=
792
826
  .command('delete')
793
827
  .description('Delete .env file (requires confirmation)')
794
828
  .option('-f, --file <path>', 'Path to .env file', '.env')
829
+ .option('-g, --global', 'Use global workspace ($HOME)')
795
830
  .option('-y, --yes', 'Skip confirmation prompt')
796
831
  .action(async (options) => {
797
832
  try {
798
- const envPath = path.resolve(options.file);
833
+ const manager = new SecretsManager({ globalMode: options.global });
834
+ const envPath = path.resolve(manager.resolveFilePath(options.file));
799
835
  // Check if file exists
800
836
  if (!fs.existsSync(envPath)) {
801
837
  console.log(`āŒ File not found: ${envPath}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lsh-framework",
3
- "version": "2.3.2",
3
+ "version": "3.1.0",
4
4
  "description": "Simple, cross-platform encrypted secrets manager with automatic sync, IPFS audit logs, and multi-environment support. Just run lsh sync and start managing your secrets.",
5
5
  "main": "dist/app.js",
6
6
  "bin": {
@@ -18,7 +18,8 @@
18
18
  "build": "tsc",
19
19
  "watch": "tsc --watch",
20
20
  "test": "node --experimental-vm-modules ./node_modules/.bin/jest",
21
- "test:coverage": "node --experimental-vm-modules ./node_modules/.bin/jest --coverage",
21
+ "test:ci": "node --experimental-vm-modules ./node_modules/.bin/jest --runInBand",
22
+ "test:coverage": "node --experimental-vm-modules ./node_modules/.bin/jest --coverage --runInBand",
22
23
  "clean": "rm -rf ./build; rm -rf ./bin; rm -rf ./dist",
23
24
  "lint": "eslint src --ext .js,.ts,.tsx",
24
25
  "lint:fix": "eslint src --ext .js,.ts,.tsx --fix",