@captainsafia/burrow 1.0.0-preview.aac83a8 → 1.0.0-preview.bc1a66f

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # burrow
2
2
 
3
- A platform-agnostic, directory-scoped secrets manager. Store secrets outside your repos, inherit them through directory ancestry.
3
+ Burrow is a platform-agnostic, directory-scoped secrets manager. Secrets are stored outside your repos in a local SQLite store and exportable to various formats via the CLI. For a nicer dev experience, Burrow currently stores secrets in a plain-text format outside the target repo, which means that secrets can still be leaked to other users on your machine or people who gain access to your device. But, for your day-to-day dev use, this beats keeping secrets in gitignored files in your repo.
4
4
 
5
5
  ```
6
6
  ~/projects/ # DATABASE_URL, API_KEY defined here
@@ -32,6 +32,8 @@ burrow set DATABASE_URL=postgres://localhost/mydb --path ~/projects
32
32
  ```bash
33
33
  burrow get API_KEY
34
34
  burrow get API_KEY --format json
35
+ # Redact the secret value in output
36
+ burrow get API_KEY --redact
35
37
  ```
36
38
 
37
39
  ### List all secrets
@@ -39,13 +41,21 @@ burrow get API_KEY --format json
39
41
  ```bash
40
42
  burrow list
41
43
  burrow list --format json
44
+ # Redact secret values in output
45
+ burrow list --redact
42
46
  ```
43
47
 
44
48
  ### Export to your shell
45
49
 
46
50
  ```bash
51
+ # Auto-detects your shell (bash, fish, powershell, cmd)
47
52
  eval "$(burrow export)"
48
- eval "$(burrow export --format shell)" && npm start
53
+
54
+ # Or specify a format explicitly
55
+ burrow export --format fish
56
+ burrow export --format powershell
57
+ burrow export --format dotenv
58
+ burrow export --format json
49
59
  ```
50
60
 
51
61
  ### Block inheritance
package/dist/api.d.ts CHANGED
@@ -5,7 +5,7 @@ export interface ResolvedSecret {
5
5
  value: string;
6
6
  sourcePath: string;
7
7
  }
8
- export type ExportFormat = "shell" | "dotenv" | "json";
8
+ export type ExportFormat = "shell" | "bash" | "fish" | "powershell" | "cmd" | "dotenv" | "json";
9
9
  /**
10
10
  * Configuration options for creating a BurrowClient instance.
11
11
  */
package/dist/api.js CHANGED
@@ -66,10 +66,10 @@ class Storage {
66
66
  await chmod(this.configDir, 448);
67
67
  }
68
68
  this.db = new Database(this.storePath);
69
- this.db.run("PRAGMA journal_mode = WAL");
70
69
  if (!isWindows()) {
71
70
  await chmod(this.storePath, 384);
72
71
  }
72
+ this.db.run("PRAGMA journal_mode = WAL");
73
73
  this.db.run(`
74
74
  CREATE TABLE IF NOT EXISTS secrets (
75
75
  path TEXT NOT NULL,
@@ -122,7 +122,12 @@ class Storage {
122
122
  }
123
123
  async getAncestorPaths(canonicalPath) {
124
124
  const db = await this.ensureDb();
125
- const rows = db.query("SELECT DISTINCT path FROM secrets WHERE ? = path OR ? LIKE path || '/' || '%' OR path = '/'").all(canonicalPath, canonicalPath);
125
+ let rows;
126
+ if (isWindows()) {
127
+ rows = db.query("SELECT DISTINCT path FROM secrets WHERE ? = path OR ? LIKE path || '\\' || '%' OR (length(path) = 3 AND path LIKE '_:\\' AND ? LIKE path || '%')").all(canonicalPath, canonicalPath, canonicalPath);
128
+ } else {
129
+ rows = db.query("SELECT DISTINCT path FROM secrets WHERE ? = path OR ? LIKE path || '/' || '%' OR path = '/'").all(canonicalPath, canonicalPath);
130
+ }
126
131
  return rows.map((row) => row.path);
127
132
  }
128
133
  async removeKey(canonicalPath, key) {
@@ -246,6 +251,9 @@ function escapeShellValue(value) {
246
251
  function escapeDoubleQuotes(value) {
247
252
  return value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
248
253
  }
254
+ function escapePowerShellValue(value) {
255
+ return value.replace(/'/g, "''");
256
+ }
249
257
  function formatShell(secrets) {
250
258
  const lines = [];
251
259
  const sortedKeys = Array.from(secrets.keys()).sort();
@@ -258,6 +266,42 @@ function formatShell(secrets) {
258
266
  return lines.join(`
259
267
  `);
260
268
  }
269
+ function formatFish(secrets) {
270
+ const lines = [];
271
+ const sortedKeys = Array.from(secrets.keys()).sort();
272
+ for (const key of sortedKeys) {
273
+ const secret = secrets.get(key);
274
+ assertValidEnvKey(key);
275
+ const escapedValue = escapeShellValue(secret.value);
276
+ lines.push(`set -gx ${key} '${escapedValue}'`);
277
+ }
278
+ return lines.join(`
279
+ `);
280
+ }
281
+ function formatPowerShell(secrets) {
282
+ const lines = [];
283
+ const sortedKeys = Array.from(secrets.keys()).sort();
284
+ for (const key of sortedKeys) {
285
+ const secret = secrets.get(key);
286
+ assertValidEnvKey(key);
287
+ const escapedValue = escapePowerShellValue(secret.value);
288
+ lines.push(`$env:${key} = '${escapedValue}'`);
289
+ }
290
+ return lines.join(`
291
+ `);
292
+ }
293
+ function formatCmd(secrets) {
294
+ const lines = [];
295
+ const sortedKeys = Array.from(secrets.keys()).sort();
296
+ for (const key of sortedKeys) {
297
+ const secret = secrets.get(key);
298
+ assertValidEnvKey(key);
299
+ const escapedValue = secret.value.replace(/([&|<>^])/g, "^$1");
300
+ lines.push(`set ${key}=${escapedValue}`);
301
+ }
302
+ return lines.join(`
303
+ `);
304
+ }
261
305
  function formatDotenv(secrets) {
262
306
  const lines = [];
263
307
  const sortedKeys = Array.from(secrets.keys()).sort();
@@ -295,7 +339,14 @@ function formatJson(secrets, includeSources = false) {
295
339
  function format(secrets, fmt, options = {}) {
296
340
  switch (fmt) {
297
341
  case "shell":
342
+ case "bash":
298
343
  return formatShell(secrets);
344
+ case "fish":
345
+ return formatFish(secrets);
346
+ case "powershell":
347
+ return formatPowerShell(secrets);
348
+ case "cmd":
349
+ return formatCmd(secrets);
299
350
  case "dotenv":
300
351
  return formatDotenv(secrets);
301
352
  case "json":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@captainsafia/burrow",
3
- "version": "1.0.0-preview.aac83a8",
3
+ "version": "1.0.0-preview.bc1a66f",
4
4
  "description": "Platform-agnostic, directory-scoped secrets manager",
5
5
  "type": "module",
6
6
  "main": "dist/api.js",