lsh-framework 2.3.1 → 2.3.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.
@@ -108,8 +108,43 @@ export class IPFSSecretsStorage {
108
108
  try {
109
109
  const metadataKey = this.getMetadataKey(gitRepo, environment);
110
110
  let metadata = this.metadata[metadataKey];
111
+ // Construct display name for error messages
112
+ const displayEnv = gitRepo
113
+ ? (environment ? `${gitRepo}_${environment}` : gitRepo)
114
+ : (environment || 'default');
115
+ // If no local metadata, try to fetch from Storacha registry first (for git repos)
116
+ if (!metadata && gitRepo) {
117
+ try {
118
+ const storacha = getStorachaClient();
119
+ if (storacha.isEnabled() && await storacha.isAuthenticated()) {
120
+ logger.info(` 🔍 No local metadata found, checking Storacha registry...`);
121
+ const latestCid = await storacha.getLatestCID(gitRepo);
122
+ if (latestCid) {
123
+ logger.info(` ✅ Found secrets in registry (CID: ${latestCid})`);
124
+ // Create metadata from registry
125
+ metadata = {
126
+ environment,
127
+ git_repo: gitRepo,
128
+ cid: latestCid,
129
+ timestamp: new Date().toISOString(),
130
+ keys_count: 0, // Unknown until decrypted
131
+ encrypted: true,
132
+ };
133
+ this.metadata[metadataKey] = metadata;
134
+ this.saveMetadata();
135
+ }
136
+ }
137
+ }
138
+ catch (error) {
139
+ // Registry check failed, continue to error
140
+ const err = error;
141
+ logger.debug(` Registry check failed: ${err.message}`);
142
+ }
143
+ }
111
144
  if (!metadata) {
112
- throw new Error(`No secrets found for environment: ${environment}`);
145
+ throw new Error(`No secrets found for environment: ${displayEnv}\n\n` +
146
+ `💡 Tip: Check available environments with: lsh env\n` +
147
+ ` Or push secrets first with: lsh push`);
113
148
  }
114
149
  // Check if there's a newer version in the registry (for git repos)
115
150
  if (gitRepo) {
@@ -253,7 +288,7 @@ export class IPFSSecretsStorage {
253
288
  /**
254
289
  * Store encrypted data locally
255
290
  */
256
- async storeLocally(cid, encryptedData, environment) {
291
+ async storeLocally(cid, encryptedData, _environment) {
257
292
  const cachePath = path.join(this.cacheDir, `${cid}.encrypted`);
258
293
  fs.writeFileSync(cachePath, encryptedData, 'utf8');
259
294
  logger.debug(`Cached secrets locally: ${cachePath}`);
@@ -18,53 +18,6 @@ export async function loadCommands() {
18
18
  const cmdMap = await parseCommands(files);
19
19
  return cmdMap;
20
20
  }
21
- async function _makeCommand(commander) {
22
- const _commands = await loadCommands();
23
- commander.command("jug").action(() => {
24
- console.log("heat jug");
25
- });
26
- commander.command("pot").action(() => {
27
- console.log("heat pot");
28
- });
29
- return commander;
30
- }
31
- // export async function init_lib_cmd(program: Command) {
32
- // const brew = program.command("lib");
33
- // // const commands = await loadCommands();
34
- // // await set(lsh.commands, commands);
35
- // brew.command("tea").action(() => {
36
- // console.log("brew tea");
37
- // });
38
- // brew.command("coffee").action(() => {
39
- // console.log("brew coffee");
40
- // });
41
- // await makeCommand(brew);
42
- // // for (let c in commands) {
43
- // // brew.command(c).action(() => console.log(c));
44
- // // }
45
- // // .command("lib").description("lsh lib commands");
46
- // // lib
47
- // // .showHelpAfterError(true)
48
- // // .showSuggestionAfterError(true);
49
- // // const commands = await loadCommands();
50
- // // set(lsh.commands, commands);
51
- // // for (const [key, value] of Object.entries(get(lsh.commands))) {
52
- // // // console.log(`${key} : ${value}`);
53
- // // lib.command(key).action(() => {console.log(value)});
54
- // // };
55
- // // .action(async (type: String, action: String, spec: Spec) => {
56
- // // const commands = await loadCommands();
57
- // // set(lsh.commands, commands);
58
- // // switch (type) {
59
- // // case "ls":
60
- // // // console.log("lsh called");
61
- // // // console.log(get(lsh.commands)['rand']());
62
- // // break;
63
- // // default:
64
- // // console.log("default");
65
- // // }
66
- // // });
67
- // }
68
21
  export async function init_lib(program) {
69
22
  const lib = program
70
23
  .command("lib")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lsh-framework",
3
- "version": "2.3.1",
3
+ "version": "2.3.2",
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": {