{"id":18454330,"url":"https://github.com/1password/extension-messaging","last_synced_at":"2025-04-08T03:35:56.572Z","repository":{"id":42383402,"uuid":"454571017","full_name":"1Password/extension-messaging","owner":"1Password","description":null,"archived":false,"fork":false,"pushed_at":"2023-03-18T18:17:15.000Z","size":14,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-07-09T08:26:36.776Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/1Password.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-02-01T22:24:27.000Z","updated_at":"2024-05-17T19:45:36.000Z","dependencies_parsed_at":"2022-09-21T18:00:22.073Z","dependency_job_id":null,"html_url":"https://github.com/1Password/extension-messaging","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1Password%2Fextension-messaging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1Password%2Fextension-messaging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1Password%2Fextension-messaging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1Password%2Fextension-messaging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/1Password","download_url":"https://codeload.github.com/1Password/extension-messaging/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223303757,"owners_count":17123097,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T08:03:47.955Z","updated_at":"2024-11-06T08:03:48.416Z","avatar_url":"https://github.com/1Password.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cross-Extension Save in 1Password\n\nUsing the cross-extension communication provided by [`browser.runtime.sendMessage`](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/sendMessage), you can save data within 1Password.\n\nBelow we outline the messages that 1Password can accept and the response you can expect. Included in `demo-extension/` are types that can be integrated into an extension for communication with 1Password and a sample extension for how this works.\n\nTo use this API and see this demo in action, contact us.\n\n## Messages\n\n1Password supports the following messages from allowed extensions.\n\n### Hello\n\nThis message can be sent by either extension to see if the other extension is installed.\n\nRequest:\n\n```\n{ \"name\": \"hello\" }\n```\n\nResponse:\n\n```\n{ \"name\": \"hello\", \"data\": { \"buildNumber\": 1 } }\n```\n\n### Create Item\n\nSent from your extension to 1Password which opens the 1Password Save Dialog prepopulated with the provided data. The `created` field in the response indicates if the user chose to save the item.\n\n#### Save Request\n\nTo save an item to 1Password, you'll need to build a save request:\n\nA save request needs these values:\n\n\u003ctable\u003e\n\t\u003cthead\u003e\n\t\u003ctr\u003e\n\t\t\u003cth\u003eField\u003c/th\u003e \u003cth\u003eType\u003c/th\u003e \u003cth\u003eDescription\u003c/th\u003e\n\t\u003c/tr\u003e\n\t\u003c/thead\u003e\n\t\u003ctbody\u003e\n\t\u003ctr\u003e\n\t\t\u003ctd\u003e\u003ccode\u003etitle\u003c/code\u003e\u003c/td\u003e \u003ctd\u003estring\u003c/td\u003e\t\u003ctd\u003eThe suggested title for the item to be saved.\u003c/td\u003e\n\t\u003c/tr\u003e\n\t\u003ctr\u003e\n\t\t\u003ctd\u003e\u003ccode\u003efields\u003c/code\u003e\u003c/td\u003e \u003ctd\u003earray\u003c/td\u003e \u003ctd\u003eEach object in the array has these properties:\n\t\t\u003cul\u003e\n\t\t\t\u003cli\u003e\u003ccode\u003eautocomplete\u003c/code\u003e (string): The type of field to fill.\u003c/li\u003e\n\t\t\t\u003cli\u003e\u003ccode\u003evalue\u003c/code\u003e (string or number[]): The value to be filled in the field expressed as the string value or as an array of numbers representing the UTF-8 code points. \u003c/li\u003e\n\t\t\u003c/ul\u003e\n\t\t\u003cp class=\"note\"\u003eUse the autocomplete field name and values defined in the \"Autofill\" section of the \u003ca href=\"https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill\"\u003eHTML Living Standard\u003c/a\u003e.\u003c/p\u003e\n\t\t\u003c/td\u003e\n\t\u003c/tr\u003e\n\t\u003ctr\u003e\n\t\t\u003ctd\u003e\u003ccode\u003enotes\u003c/code\u003e \u003cp class=\"note\"\u003e(optional)\u003c/p\u003e\u003c/td\u003e \u003ctd\u003estring\u003c/td\u003e \u003ctd\u003eNotes to save with the item. These can be formatted with Markdown.\u003c/td\u003e\n\t\u003c/tr\u003e\n\t\u003c/tbody\u003e\n\u003c/table\u003e\n\nFor example:\n\n```ts\n{\n    title: \"Sample Item\",\n    fields: [\n      { autocomplete: \"username\", value: \"wendy.appleseed@1password.com\" },\n      { autocomplete: \"current-password\", value: \"its-a-secret\" },\n    ],\n    notes: \"Item saved while testing the integration.\",\n  });\n```\n\n_Request:_\n\nUse helper function `createOPItem` in this package and pass in:\n\n- the ID of the extension where you want to send the message\n- the \u003ca href=\"#appendix-supported-item-templates\"\u003esupported item template code\u003c/a\u003e for the 1Password item you want to save\n- your \u003ca href=\"#save-request\"\u003e save request\u003c/a\u003e\n\n##### Sample Credit Card Request\n\n```ts\ncreateOPItem(\"dghdojbkjhnklbpkdaibdccddilifddb\", \"credit-card\", {\n  title: \"Virtual Credit Card Item\",\n  fields: [\n    {\n      autocomplete: \"cc-name\",\n      value: \"Wendy Appleseed\",\n    },\n    {\n      autocomplete: \"cc-type\",\n      value: \"visa\",\n    },\n    {\n      autocomplete: \"cc-number\",\n      value: \"4012888888881881\",\n    },\n    {\n      autocomplete: \"cc-exp\",\n      value: \"202401\",\n    },\n    {\n      autocomplete: \"cc-csc\",\n      value: \"714\",\n    },\n    {\n      autocomplete: \"street-address\",\n      value: \"512 Main Street\",\n    },\n    {\n      autocomplete: \"address-level2\",\n      value: \"Cambridge\",\n    },\n    {\n      autocomplete: \"address-level1\",\n      value: \"MA\",\n    },\n    {\n      autocomplete: \"postal-code\",\n      value: \"02114\",\n    },\n    {\n      autocomplete: \"country\",\n      value: \"US\",\n    },\n  ],\n  notes: \"Credit card item saved while testing the integration.\",\n});\n```\n\n_Response:_\n\n```json\n{ \"name\": \"create-item\", \"data\": { \"saved\": true } }\n```\n\n##### Sample Crypto Wallet Request\n\n```ts\ncreateOPItem(\"dghdojbkjhnklbpkdaibdccddilifddb\", \"crypto-wallet\", {\n  title: \"Sample Crypto Wallet\",\n  fields: [\n    {\n      autocomplete: \"crypto-address\",\n      value: \"sample-wallet-address\",\n    },\n    {\n      autocomplete: \"crypto-recovery-seed\",\n      value: Array.from(new TextEncoder().encode(\"sample-recovery-phrase ✨\")),\n    },\n  ],\n  notes: \"Credit card item saved while testing the integration.\",\n});\n```\n\n_Response:_\n\n```json\n{ \"name\": \"create-item\", \"data\": { \"saved\": true } }\n```\n\n## Request to be added to the list of allowed extensions\n\nThe extension-messaging API is only compatible with extensions approved by 1Password. To request that your extension ID be added to the list, to request support for an \u003ca href=\"#appendix-supported-item-templates\"\u003eitem type\u003c/a\u003e not listed below, or for more information about the API, contact the 1Password Partnerships team at [support+partnerships@1password.com](mailto:support+partnerships@1password.com).\n\n## Appendix: Supported item templates\n\n| Template       | Code             |\n| -------------- | ---------------- |\n| API Credential | `api-credential` |\n| Credit Card    | `credit-card`    |\n| Crypto Wallet  | `crypto-wallet`  |\n| Login          | `login`          |\n| Password       | `password`       |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1password%2Fextension-messaging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F1password%2Fextension-messaging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1password%2Fextension-messaging/lists"}