
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
@1password/save-button
Advanced tools
When you add the Save in 1Password button to your website, visitors can easily save their sign-in details, credit cards, or addresses to their 1Password account with a click. If you set up an integration with 1Password, the button can also be used to save API keys.
The Save in 1Password button on your site communicates directly with 1Password in the browser, so no unencrypted information leaves the customer's browser.
To add the button to your site, you'll need to install the Save in 1Password button, build a save request, and import the button into your file with the required attributes and values. The button is disabled by default. When the page loads, 1Password will check for the button and make it available to the user. Item URLs, if applicable, are determined by 1Password, so a login item can only be filled for the domain on which it was saved.
The button element specifies the type of item to create and the information it'll contain. The information is a Base64-encoded save request in JSON format.
To get started, install the Save in 1Password button using your preferred package manager:
npm install @1password/save-button --save-dev
yarn add @1password/save-button -D
Then import the package into your HTML file. For example:
<script type="module">
import "@1password/save-button/index.js";
</script>
The save request needs these values:
Field | Type | Description |
---|---|---|
title | string | The suggested title for the item to be saved. |
fields | array | Each object in the array has these properties:
Use the autocomplete field name and values defined in the "Autofill" section of the HTML Living Standard. |
notes (optional) | string | Notes to save with the item. These can be formatted with Markdown. |
For example:
const saveRequest = {
title: "ACME Credit Card",
fields: [
{
autocomplete: "cc-name",
value: "Wendy J. Appleseed",
},
{
autocomplete: "cc-number",
value: "4111111111111111",
},
{
autocomplete: "cc-exp",
value: "202512",
},
{
autocomplete: "cc-csc",
value: "123",
},
{
autocomplete: "cc-type",
value: "visa",
},
{
autocomplete: "street-address",
value: "512 Main Street",
},
{
autocomplete: "address-level2",
value: "Cambridge",
},
{
autocomplete: "address-level1",
value: "MA",
},
{
autocomplete: "postal-code",
value: "12345",
},
{
autocomplete: "country",
value: "US",
},
],
notes:
"Plain text. You can use [Markdown](https://support.1password.com/markdown/) too.",
};
To encode the example above to a Base64 string in JSON format, use the built-in encodeOPSaveRequest
function:
const encodedSaveRequest = encodeOPSaveRequest(saveRequest);
Then copy and paste the resulting Base64-encoded string as the value
attribute of the Save in 1Password button. For example:
"eyJ0aXRsZSI6IkFDTUUgQ3JlZGl0IENhcmQiLCJmaWVsZHMiOlt7ImF1dG9jb21wbGV0ZSI6ImNjLW5hbWUiLCJ2YWx1ZSI6IldlbmR5IEouIEFwcGxlc2VlZCJ9LHsiYXV0b2NvbXBsZXRlIjoiY2MtbnVtYmVyIiwidmFsdWUiOiI0MTExMTExMTExMTExMTExIn0seyJhdXRvY29tcGxldGUiOiJjYy1leHAiLCJ2YWx1ZSI6IjIwMjUxMiJ9LHsiYXV0b2NvbXBsZXRlIjoiY2MtY3NjIiwidmFsdWUiOiIxMjMifSx7ImF1dG9jb21wbGV0ZSI6ImNjLXR5cGUiLCJ2YWx1ZSI6InZpc2EifSx7ImF1dG9jb21wbGV0ZSI6InN0cmVldC1hZGRyZXNzIiwidmFsdWUiOiI1MTIgTWFpbiBTdHJlZXQifSx7ImF1dG9jb21wbGV0ZSI6ImFkZHJlc3MtbGV2ZWwyIiwidmFsdWUiOiJDYW1icmlkZ2UifSx7ImF1dG9jb21wbGV0ZSI6ImFkZHJlc3MtbGV2ZWwxIiwidmFsdWUiOiJNQSJ9LHsiYXV0b2NvbXBsZXRlIjoicG9zdGFsLWNvZGUiLCJ2YWx1ZSI6IjEyMzQ1In0seyJhdXRvY29tcGxldGUiOiJjb3VudHJ5IiwidmFsdWUiOiJVUyJ9XSwibm90ZXMiOiJQbGFpbiB0ZXh0LiBZb3UgY2FuIHVzZSBbTWFya2Rvd25dKGh0dHBzOi8vc3VwcG9ydC4xcGFzc3dvcmQuY29tL21hcmtkb3duLykgdG9vLiJ9";
Or update the Base64-encoded value of the button:
document
.querySelector("onepassword-save-button")
.shadowRoot.querySelector("button[data-onepassword-save-button]")
.setAttribute("value", encodedSaveRequest);
Add the Save in 1Password button to your page with the two required attributes: data-onepassword-type
and value
.
You can also add optional attributes to change the button language, color, theme, or padding: lang
, class
, data-theme
, or padding
.
Attribute | Value |
---|---|
data-onepassword-type | The type of item the button will create:credit-card , api-key , or login |
value | The Base64-encoded save request. |
lang (optional) | The language code for one of the supported languages.
If no language attribute is provided, the package will determine the browser language using the NavigatorLanguage Web API. If the browser language isn’t supported, the package will default to English. |
class (optional) | The color of the button:black or white
If no class attribute is provided, the button color will default to blue. |
data-theme (optional) | The optimized button theme for a website with a light or dark background:light or dark
If no theme is provided the package will default to the light theme. |
padding (optional) | Controls the padding of the button:normal or compact or none
If no value is provided or a value of |
For example:
<onepassword-save-button
data-onepassword-type="credit-card"
value="ewoJInRpdGxlIjogIkFDTUUgQ3JlZGl0IE...=="
lang="en"
class="black"
data-theme="dark"
padding="normal"
>
</onepassword-save-button>
If you're building a single-page app, you may need to call the activateOPButton()
function to activate the button. This will dispatch a custom event on the page to tell 1Password to enable the Save in 1Password button.
The Save in 1Password button only works on sites approved by 1Password. To request that your site be added to the list or for more information about the Save in 1Password button, contact the 1Password Partnerships team at support+partnerships@1password.com.
Language | Code | Language | Code | Language | Code |
---|---|---|---|---|---|
English | en | Japanese | ja | Spanish | es |
French | fr | Korean | ko | Chinese, simplified | zh-CN |
German | de | Portuguese | pt | Chinese, traditional | zh-TW |
Italian | it | Russian | ru |
FAQs
Save to 1Password button
The npm package @1password/save-button receives a total of 14,184 weekly downloads. As such, @1password/save-button popularity was classified as popular.
We found that @1password/save-button demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.