A minimal example showing how varlock pulls secrets from 1Password at runtime using the @varlock/1password-plugin.
Instead of a .env file with hardcoded secrets, this project uses a .env.schema file that declares:
VARLOCK_EXAMPLE— a plain string value, defined inlineVARLOCK_EXAMPLE_SECRET— a sensitive value fetched from 1Password at runtime viaop("op://...")
When you run npm run example, varlock resolves the schema, fetches any secrets from 1Password, and injects them as environment variables into the Node.js process.
- Node.js (v18+)
- 1Password desktop app with CLI integration enabled:
- Open 1Password > Settings > Developer
- Enable "Integrate with 1Password CLI"
- 1Password CLI (
op) installed — see 1Password CLI docs- Verify with:
op account list
- Verify with:
-
Clone this repo and install dependencies:
git clone <repo-url> cd varlock-node-example npm install
-
Create a secret in your 1Password vault for the example to read. The default
.env.schemaexpects an item at:op://Demos/varlock_example_secret/passwordTo use a different item, edit
.env.schemaand replace theop("op://...")reference with your own. You can find the secret reference for any field in 1Password by clicking the field's dropdown and selecting Copy Secret Reference. It will look something like this:"op://Demos/varlock_example_secret/password" -
Run the example:
npm run example
1Password will prompt you to authorize access (via biometrics or password), then the script prints the resolved secret.
For CI/CD or deployed environments where the desktop app isn't available, set an OP_TOKEN environment variable with a 1Password service account token and update the plugin config in .env.schema:
# @plugin(@varlock/1password-plugin, token=$OP_TOKEN)