@securecode/sdk
The official Node.js SDK for SecureCodeHQ — the secrets vault for developers who build with Claude Code.
Install
npm install @securecode/sdk
Quick Start
Set your API key and start using secrets:
export SECURECODE_API_KEY=sc_your_key_here
import { getSecret } from '@securecode/sdk';
const stripeKey = await getSecret('STRIPE_SECRET_KEY');
const dbUrl = await getSecret('DATABASE_URL');
Load All Secrets at Once
Inject all your secrets into process.env with a single API call:
import { loadEnv } from '@securecode/sdk';
await loadEnv();
Options:
await loadEnv({
tags: { env: 'production', project: 'acme' },
override: true,
});
CLI Tools
Migrate from .env files
Scan and import your .env files into SecureCodeHQ:
npx securecode migrate
npx securecode migrate .env.production
npx securecode migrate --tags "project:acme"
npx securecode migrate --ttl 720 -y
Run with secrets injected
Load secrets into process.env and run your command:
npx securecode-run node server.js
npx securecode-run -- npm start
npx securecode-run --tags "env:production" node app.js
Full Client
For more control, create a client instance:
import { SecureCodeClient } from '@securecode/sdk';
const client = new SecureCodeClient({
apiKey: 'sc_your_key_here',
});
const value = await client.getSecret('OPENAI_API_KEY');
const prodKey = await client.getSecret('DB_URL', { env: 'production' });
const revealed = await client.getSecret('DB_URL', undefined, undefined, { reveal: true });
const secrets = await client.listSecrets();
const prodSecrets = await client.listSecrets({
tags: { env: 'production', project: 'acme' },
});
await client.createSecret({
name: 'NEW_API_KEY',
value: 'sk-...',
description: 'OpenAI production key',
tags: { env: 'production', project: 'acme' },
ttlHours: 720,
});
await client.updateSecret('NEW_API_KEY', {
value: 'sk-new-value...',
tags: { env: 'production', rotated: 'true' },
});
await client.renewSecret('EXPIRED_KEY', 48);
await client.deleteSecret('OLD_KEY');
await client.importEnv('KEY1=val1\nKEY2=val2', {
tags: { env: 'staging' },
filename: '.env.staging',
});
const envContent = await client.exportEnv({ format: 'env' });
Onboarding API
The SDK includes methods for the guided onboarding flow (used by the MCP server):
const session = await client.startOnboarding({ source: 'mcp', agentName: 'claude-code' });
console.log(session.signupUrl);
console.log(session.importUrl);
console.log(session.expiresAt);
const status = await client.getOnboardingStatus(session.token);
console.log(status.step);
console.log(status.signupCompleted);
console.log(status.importCompleted);
console.log(status.migrationInstructions);
MCP Access Rules
When an MCP rule blocks access, the SDK throws McpRuleBlockedError with rule metadata:
import { SecureCodeClient, McpRuleBlockedError } from '@securecode/sdk';
const client = new SecureCodeClient({ apiKey: 'sc_...' });
try {
const value = await client.getSecret('STRIPE_LIVE_KEY');
} catch (err) {
if (err instanceof McpRuleBlockedError) {
console.log(err.ruleAction);
console.log(err.ruleName);
console.log(err.ruleId);
if (err.ruleAction === 'require_confirmation') {
const value = await client.getSecret('STRIPE_LIVE_KEY', undefined, err.ruleId);
}
}
}
const rules = await client.getActiveRules();
Session Lock
Control when Claude Code can access your secrets:
await client.wakeSession({
scope: [{ project: 'acme', env: 'staging' }],
autoSleepMinutes: 60,
});
const status = await client.getSessionStatus();
console.log(status.status);
console.log(status.timeRemainingMinutes);
await client.sleepSession();
API Key
Get your API key from the SecureCodeHQ dashboard under Settings > API Keys.
Requirements
License
MIT