Package Exports
Readme
Build integrations that programmatically access your secrets in 1Password.
🚀 Get started
To use the 1Password JavaScript SDK in your project:
Create a service account and give it the appropriate permissions in the vaults where the items you want to use with the SDK are saved.
Provision your service account token. We recommend provisioning your token from the environment. For example, to export your token to the
OP_SERVICE_ACCOUNT_TOKENenvironment variable:macOS or Linux
export OP_SERVICE_ACCOUNT_TOKEN=<your-service-account-token>
Windows
$Env:OP_SERVICE_ACCOUNT_TOKEN = "<your-service-account-token>"Install the 1Password JavaScript SDK in your project:
## NPM npm install @1password/sdk
## PNPM pnpm add @1password/sdk
## Yarn yarn add @1password/sdk
Use the JavaScript SDK in your project:
import { createClient } from "@1password/sdk";
// Creates an authenticated client.
const client = await createClient({
auth: process.env.OP_SERVICE_ACCOUNT_TOKEN,
// Set the following to your own integration name and version.
integrationName: "My 1Password Integration",
integrationVersion: "v1.0.0",
});
// Fetches a secret.
const secret = await client.secrets.resolve("op://vault/item/field");Make sure to use secret reference URIs with the syntax op://vault/item/field to securely load secrets from 1Password into your code.
Inside createClient(), set integrationName to the name of your application and integrationVersion to the version of your application.
Supported functionality
1Password SDKs are in active development. We're keen to hear what you'd like to see next. Let us know by upvoting or filing an issue.
Item management
Operations:
- Retrieve secrets
- Retrieve items
- Create items
- Update items
- Delete items
- Archive items
- List items
- Share items (items with files cannot be shared)
- Generate PIN, random and memorable passwords
Field types:
- API Keys
- Passwords
- Concealed fields
- Text fields
- Notes
- SSH private keys, public keys, fingerprint and key type
- One-time passwords
- URLs
- Websites (used to suggest and autofill logins)
- Phone numbers
- Credit card types
- Credit card numbers
- Emails
- References to other items
- Address
- Date
- MM/YY
- Files attachments and Document items
- Menu
Vault management
- Retrieve vaults
- Create vaults (#50)
- Update vaults
- Delete vaults
- List vaults
User & access management
- Provision users
- Retrieve users
- List users
- Suspend users
- Create groups
- Update group membership
- Update vault access & permissions
Compliance & reporting
- Watchtower insights
- Travel mode
- Events. For now, use 1Password Events Reporting API directly.
Authentication
- 1Password Service Accounts
- User authentication
- 1Password Connect. For now, use 1Password/connect-sdk-js.