secrettnl
v1.1.0
Published
SecretTunnel CLI to push and pull secrets
Readme
SecretTunnel CLI
CLI for creating and reading one-time encrypted secrets.
Setup
Install dependencies from the monorepo root:
bun installRun commands from this folder:
cd apps/cliThe CLI talks to the web API at:
http://localhost:3000/api/secretsYou can override this with environment variables:
SECRETTUNNEL_API_URL=http://localhost:3000Fallback behavior:
SECRETTUNNEL_API_URL(preferred)API_URLNODE_ENV=production->https://secrettunnel.vercel.app/api/secrets- Otherwise ->
http://localhost:3000/api/secrets
Make sure the web app is running before using CLI commands.
Command Summary
bun src/index.ts push <content> [--ttl <duration>] [--file <path>] [--password <value>]
bun src/index.ts pull <share-url> [--password <value>] [--output <path|->]
bun src/index.ts pull <token> --key <base64Key> [--password <value>] [--output <path|->]--ttl accepts either:
- Raw seconds (example:
3600) - Human-readable values using
s|m|h|d(examples:30m,1h,7d)
Default TTL is 24h.
Important: Command is required. Running bun src/index.ts "message" will fail. Use push or pull explicitly.
Push Command
Create a secret and print a share URL.
Push with direct content
bun src/index.ts push "my secret message"If you press Enter at the password prompt, the secret is created without password protection.
Push with file content
bun src/index.ts push --file .envPush with custom TTL
bun src/index.ts push "temporary secret" --ttl 1hPush with explicit password
bun src/index.ts push "top secret" --password mypass123On success, CLI prints:
- Tokenized URL path (
/s/<token>) - Decryption key in hash fragment (
#key=...)
Example:
http://localhost:3000/s/abc123#key=base64EncodedKeyPull Command
Read and decrypt a secret.
Pull using full share URL
bun src/index.ts pull "http://localhost:3000/s/abc123#key=base64EncodedKey"The CLI extracts both:
tokenfrom pathkeyfrom URL hash
Pull using token + key
bun src/index.ts pull abc123 --key "base64EncodedKey"Pull password-protected secret
If the secret is password-protected, CLI prompts:
Enter secret password:You can also provide it directly:
bun src/index.ts pull "http://localhost:3000/s/abc123#key=base64EncodedKey" --password mypass123Pull secret directly to file
bun src/index.ts pull "http://localhost:3000/s/abc123#key=base64EncodedKey" --output .envIf the output file already exists, CLI asks for confirmation before overwriting it.
Explicit stdout output
Use --output - to force plaintext output to stdout.
bun src/index.ts pull "http://localhost:3000/s/abc123#key=base64EncodedKey" --output -Behavior Notes
- Secrets are one-time read (burn after read).
- After a successful pull, running pull again with the same token returns not found.
pullrequires both token and key (either inside URL or key passed with--key).
Common Errors
Missing key
Missing key. Provide a full URL containing #key=... or pass --key <base64Key>Secret already viewed or expired
Secret not found. It may have expired or already been viewed.Wrong password or corrupted key
Failed to decrypt secret. Incorrect password or corrupted key.Invalid flags
Examples:
Missing value for --ttl
Unknown option for pull command: --ttl