op-bruno
v0.0.8
Published
CLI tool to sync Bruno secrets with 1Password
Downloads
22
Readme
op-bruno
A CLI tool to sync Bruno API client secrets with 1Password, enabling secure secret management for your API testing workflows.
- op-bruno
- Features
- Installation
- Install the tool globally
- Execute without installation
- Prerequisites
- Usage
- Commands
- How It Works
- Security Considerations
- Development
- Run in development mode
- Build the project
- Run tests
- Lint code
- Troubleshooting
- License
- Contributing
Features
- Extract Secrets: Automatically identifies and extracts secret variables from Bruno environment files
- JSON Export: Exports extracted secrets to a structured JSON file
- 1Password Integration: Creates and manages secrets in 1Password vaults
- Pre-request Scripts: Generates Bruno pre-request scripts to fetch secrets from 1Password
- Filesystem Access: Automatically configures Bruno collections for filesystem access
Installation
# Install the tool globally
npm install -g op-bruno
# Execute without installation
npx op-brunoPrerequisites
- Node.js >= 18.0.0
- 1Password CLI
- Bruno API client
Usage
$ npm install -g op-bruno
$ op-bruno COMMAND
running command...
$ op-bruno (--version)
op-bruno/0.0.8 linux-x64 node-v20.19.6
$ op-bruno --help [COMMAND]
USAGE
$ op-bruno COMMAND
...Commands
op-bruno help [COMMAND]
Display help for op-bruno.
USAGE
$ op-bruno help [COMMAND...] [-n]
ARGUMENTS
COMMAND... Command to show help for.
FLAGS
-n, --nested-commands Include all nested commands in the output.
DESCRIPTION
Display help for op-bruno.See code: @oclif/plugin-help
op-bruno sync COLLECTION
Extract secrets from Bruno environment files and generate pre-request script for fetching from 1Password
USAGE
$ op-bruno sync COLLECTION [--json] [--outName <value>] [--vault <value>] [--title <value>]
[--upsertItem]
ARGUMENTS
COLLECTION Path to Bruno collection directory
FLAGS
--outName=<value> [default: op-secrets.json] JSON output file name
--title=<value> 1Password item title
--upsertItem Create or Update 1Password item
--vault=<value> [default: Employee] 1Password vault name
GLOBAL FLAGS
--json Format output as json.
DESCRIPTION
Extract secrets from Bruno environment files and generate pre-request script for fetching from 1Password
EXAMPLES
$ op-bruno sync ./bruno-collection --outName secrets.json
$ op-bruno sync ./bruno-collection --outName secrets.json --vault Engineering --title "API Secrets" --upsertItemSee code: src/commands/sync.ts
How It Works
Secret Extraction: The tool scans Bruno environment files (
.brufiles) in theenvironmentsdirectory and identifies secret variables.JSON Export: Extracted secrets are exported to a JSON file with the following structure:
{ "development": { "API_KEY": "op://path/to/the/secret", "SECRET_TOKEN": "op://path/to/the/secret" }, "production": { "API_KEY": "op://path/to/the/secret", "SECRET_TOKEN": "op://path/to/the/secret" } }Bruno Configuration: The tool modifies
bruno.jsonto enable filesystem access, allowing pre-request scripts to execute system commandsPre-request Script Generation: A pre-request script is added to
collection.bruthat:- Fetches secrets from 1Password based on the current environment
- Sets Bruno environment variables with the fetched values
1Password Storage: If enabled, creates/updates a structured 1Password item with sections for each environment
Pre-request Script
The generated pre-request script in collection.bru will:
- Detect the current Bruno environment
- Fetch corresponding secrets from 1Password
- Set environment variables for use in requests
Security Considerations
- Ensure 1Password CLI is properly configured and authenticated
- Use appropriate vault permissions in 1Password
- Review generated pre-request scripts before use
Development
# Run in development mode
yarn dev
# Build the project
yarn build
# Run tests
yarn test
# Lint code
yarn lintTroubleshooting
1Password CLI Not Found
Install the 1Password CLI from 1Password Developer
Vault Access Denied
Ensure you're signed in to 1Password CLI:
op signinPre-request Script Already Exists
The tool will preserve existing scripts and add the secret management code. Review the modified collection.bru file to ensure compatibility.
License
MIT
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
