secretcarousel 1.0.3 → 2.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.
- package/LICENSE +74 -14
- package/README.md +85 -37
- package/bin/cli.js +7 -83
- package/dist/api.js +1 -0
- package/dist/commands/audit.js +1 -0
- package/dist/commands/auth.js +1 -0
- package/dist/commands/backup.js +1 -0
- package/dist/commands/claim.js +1 -0
- package/dist/commands/env.js +1 -0
- package/dist/commands/partner.js +1 -0
- package/dist/commands/rotate.js +1 -0
- package/dist/commands/secret.js +1 -0
- package/dist/commands/secrets.js +1 -0
- package/dist/commands/share.js +1 -0
- package/dist/commands/signup.js +1 -0
- package/dist/commands/status.js +1 -0
- package/dist/config.js +1 -0
- package/dist/format.js +1 -0
- package/dist/main.js +1 -0
- package/package.json +7 -3
- package/commands/audit-export.js +0 -12
- package/commands/backup-create.js +0 -13
- package/commands/config.js +0 -20
- package/commands/env-export.js +0 -27
- package/commands/env-promote.js +0 -36
- package/commands/rotate.js +0 -7
- package/commands/secrets-create.js +0 -16
- package/commands/secrets-delete.js +0 -7
- package/commands/secrets-get.js +0 -7
- package/commands/secrets-list.js +0 -12
- package/commands/signup.js +0 -32
- package/lib/api.js +0 -53
- package/lib/config.js +0 -49
package/commands/signup.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
const { signup } = require('../lib/api');
|
|
2
|
-
const config = require('../lib/config');
|
|
3
|
-
|
|
4
|
-
module.exports = async function (args) {
|
|
5
|
-
const data = {};
|
|
6
|
-
for (let i = 0; i < args.length; i += 2) {
|
|
7
|
-
if (args[i] && args[i + 1]) data[args[i].replace(/^--/, '')] = args[i + 1];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
if (!data.tenant) {
|
|
11
|
-
console.error('Usage: sc signup --tenant <project-name>\n');
|
|
12
|
-
console.error('Example: sc signup --tenant my-backend');
|
|
13
|
-
process.exit(1);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const result = await signup(data.tenant);
|
|
17
|
-
|
|
18
|
-
if (result.error) {
|
|
19
|
-
console.error(`Error: ${result.message || result.error}`);
|
|
20
|
-
process.exit(1);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// Auto-save the API key to config
|
|
24
|
-
config.set('apiKey', result.apiKey);
|
|
25
|
-
|
|
26
|
-
console.log(`\nTenant "${result.tenantId}" created!\n`);
|
|
27
|
-
console.log(`API Key: ${result.apiKey}`);
|
|
28
|
-
console.log(`Plan: ${result.plan}`);
|
|
29
|
-
console.log(`Limits: ${JSON.stringify(result.limits)}\n`);
|
|
30
|
-
console.log(`Key saved to ${config.CONFIG_FILE}`);
|
|
31
|
-
console.log(`\nNext: sc secrets:create --name DB_PASSWORD --value s3cur3!`);
|
|
32
|
-
};
|
package/lib/api.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Self-contained HTTP client for SecretCarousel API
|
|
3
|
-
* Zero dependencies — uses Node.js built-in fetch (18+)
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
const config = require('./config');
|
|
7
|
-
|
|
8
|
-
async function request(method, path, body) {
|
|
9
|
-
const cfg = config.load();
|
|
10
|
-
if (!cfg.apiKey) {
|
|
11
|
-
console.error('No API key configured.\n');
|
|
12
|
-
console.error('Set via environment variable:');
|
|
13
|
-
console.error(' export SC_API_KEY=sc_free_...\n');
|
|
14
|
-
console.error('Or configure permanently:');
|
|
15
|
-
console.error(' sc config apiKey sc_free_...\n');
|
|
16
|
-
console.error('Or self-signup for a new key:');
|
|
17
|
-
console.error(' sc signup --tenant my-project');
|
|
18
|
-
process.exit(1);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const url = cfg.baseUrl.replace(/\/+$/, '') + path;
|
|
22
|
-
const opts = {
|
|
23
|
-
method,
|
|
24
|
-
headers: {
|
|
25
|
-
'X-API-Key': cfg.apiKey,
|
|
26
|
-
'Content-Type': 'application/json',
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
if (body) opts.body = JSON.stringify(body);
|
|
30
|
-
|
|
31
|
-
const resp = await fetch(url, opts);
|
|
32
|
-
const data = await resp.json().catch(() => ({}));
|
|
33
|
-
|
|
34
|
-
if (!resp.ok) {
|
|
35
|
-
const msg = data.error || data.message || `HTTP ${resp.status}`;
|
|
36
|
-
throw new Error(msg);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return data;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
async function signup(tenantId) {
|
|
43
|
-
const cfg = config.load();
|
|
44
|
-
const url = cfg.baseUrl.replace(/\/+$/, '') + '/api/signup';
|
|
45
|
-
const resp = await fetch(url, {
|
|
46
|
-
method: 'POST',
|
|
47
|
-
headers: { 'Content-Type': 'application/json' },
|
|
48
|
-
body: JSON.stringify({ tenantId, agent: 'sc-cli' }),
|
|
49
|
-
});
|
|
50
|
-
return resp.json();
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
module.exports = { request, signup };
|
package/lib/config.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const os = require('os');
|
|
4
|
-
|
|
5
|
-
const CONFIG_DIR = path.join(os.homedir(), '.secretcarousel');
|
|
6
|
-
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
|
|
7
|
-
|
|
8
|
-
const DEFAULTS = {
|
|
9
|
-
apiKey: '',
|
|
10
|
-
baseUrl: 'https://secretcarousel.com',
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
function load() {
|
|
14
|
-
// Environment variables take priority (agent-first: agents pass env vars, not config files)
|
|
15
|
-
const env = {
|
|
16
|
-
apiKey: process.env.SC_API_KEY || process.env.SECRETCAROUSEL_API_KEY || '',
|
|
17
|
-
baseUrl: process.env.SC_BASE_URL || process.env.SECRETCAROUSEL_BASE_URL || '',
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
let file = {};
|
|
21
|
-
try {
|
|
22
|
-
if (fs.existsSync(CONFIG_FILE)) {
|
|
23
|
-
file = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
|
|
24
|
-
}
|
|
25
|
-
} catch { /* ignore corrupt config */ }
|
|
26
|
-
|
|
27
|
-
return {
|
|
28
|
-
...DEFAULTS,
|
|
29
|
-
...file,
|
|
30
|
-
// Env vars override file config (non-empty only)
|
|
31
|
-
...(env.apiKey ? { apiKey: env.apiKey } : {}),
|
|
32
|
-
...(env.baseUrl ? { baseUrl: env.baseUrl } : {}),
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function save(config) {
|
|
37
|
-
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
38
|
-
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2) + '\n');
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function get(key) { return load()[key]; }
|
|
42
|
-
|
|
43
|
-
function set(key, value) {
|
|
44
|
-
const config = load();
|
|
45
|
-
config[key] = value;
|
|
46
|
-
save(config);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
module.exports = { load, save, get, set, CONFIG_FILE, CONFIG_DIR };
|