{ "info": { "author": "Rayquaza01", "author_email": "rayquaza01@outlook.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# nativemessaging\nA Python package for interfacing with Native Messaging in WebExtensions\n\n[See Native Messaging on MDN](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_messaging)\n\nBased on [Native Messaging on MDN](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_messaging#App_side) and [native-messaging on mdn/webextension-examples](https://github.com/mdn/webextensions-examples/tree/master/native-messaging) (MPL 2.0 License)\n\n`pip3 install nativemessaging`\n\n## `get_message()`\n`nativemessaging.get_message()` will poll for a message from the browser. \nIf [`runtime.connectNative`](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/connectNative) is used, `get_message()` must be called repeatedly in a loop to poll for messages. \nIf [`runtime.sendNativeMessage`](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/sendNativeMessage) is used, `get_message()` only needs to be called once.\n\n## `encode_message( message_content )`\n`nativemessaging.encode_message()` takes one argument, a message to be encoded. \nReturns an encoded version of a message to be returned to the browser. Use with `send_message()`.\n\n## `send_message( encoded_message )`\n`nativemessaging.send_message()` takes one argument, an encoded message from `encode_message()`. Returns a message to the browser.\n\n## Sample\nBrowser side:\n```javascript\nfunction onReceived(response) {\n console.log(response);\n}\n\n// runtime.connectNative\nvar port = browser.runtime.connectNative(\"application_name\");\nport.onMessage.addListener(onReceived);\nport.postMessage(\"hello\");\n\n// runtime.sendNativeMessage\nbrowser.runtime.sendNativeMessage(\"application_name\", \"hello\").then(onReceived);\n```\n\nApp side:\n```python\nimport nativemessaging\n\nwhile True:\n message = nativemessaging.get_message()\n if message == \"hello\":\n nativemessaging.send_message(nativemessaging.encode_message(\"world\"))\n```\n\n## nativemessaging-install\n`nativemessaging-install` is a command line script provided with the package.\n\n### Arguments\n`nativemessaging-install browser [--manifest manifest]`\n * `browser` - positional argument, 1 or more parameters. Must be `chrome` or `firefox`.\n * `--manifest` - a path to a manifest file to use for installing.\n\n### manifest-install.json\nA `native-manifest.json` file is expected in the current working directory when running the script, unless `--manifest` is passsed.\nThe format must be similar to the native manifest format for Chrome or Firefox, with two main differences:\n * `path` must be a relative path to the native app in relation to your current working directory.\n * Both `allowed_extensions` and `allowed_origins` must be in the manifest to work with both Chrome and Firefox.\n```json\n{\n \"name\": \"application_name\",\n \"description\": \"description\",\n \"path\": \"application_name.py\",\n \"type\": \"stdio\",\n \"allowed_extensions\": [\"extension@id\"],\n \"allowed_origins\": [\"chrome-extension://extension-id\"]\n}\n```\n\n### Created files\nOn Windows, it will create `_firefox.json` and `_chrome.json` in the same directory as ``. \nA batch file will also be created for python apps on Windows. \nA registry key is created at `HKEY_CURRENT_USER\\Software\\Google\\Chrome\\NativeMessagingHosts\\` or `HKEY_CURRENT_USER\\Software\\Mozilla\\NativeMessagingHosts\\`\n\nOn linux, it will create `~/.config/google-chrome/NativeMessagingHosts/.json` or `~/.mozilla/native-messaging-hosts/.json`\n\nOn mac, it will create `~/Library/Application Support/Google/Chrome/NativeMessagingHosts/.json` or `~/Library/Application Support/Mozilla/NativeMessagingHosts/.json`\n\n#### See also:\n * [Native Messaging on Chrome Docs](https://developer.chrome.com/extensions/nativeMessaging)\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Rayquaza01/nativemessaging", "keywords": "", "license": "MPL 2.0", "maintainer": "", "maintainer_email": "", "name": "nativemessaging", "package_url": "https://pypi.org/project/nativemessaging/", "platform": "", "project_url": "https://pypi.org/project/nativemessaging/", "project_urls": { "Homepage": "https://github.com/Rayquaza01/nativemessaging" }, "release_url": "https://pypi.org/project/nativemessaging/1.0.1/", "requires_dist": null, "requires_python": "", "summary": "A package with basic native messaging apis for webextensions", "version": "1.0.1" }, "last_serial": 4657210, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "f7db0d13906ac6f249bddae330b22206", "sha256": "21f0d1d301dbea5d80b7c6c64b2d8b6771e155ef3e30bc8962bd94aa2fde2c19" }, "downloads": -1, "filename": "nativemessaging-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "f7db0d13906ac6f249bddae330b22206", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10219, "upload_time": "2018-10-12T13:15:51", "url": "https://files.pythonhosted.org/packages/00/c9/994c76668cf1bafcc9f3e3c6ca7807edb82844f30a0ed490a071b7b4e0ac/nativemessaging-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "83bda8f3656ed48bb2e573153f1f9515", "sha256": "1c6ab268448ed5ba1149ce8f91e1aad1012ac00760dcabf0acfb4a5526cf3cd0" }, "downloads": -1, "filename": "nativemessaging-1.0.0.tar.gz", "has_sig": false, "md5_digest": "83bda8f3656ed48bb2e573153f1f9515", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4171, "upload_time": "2018-10-12T13:15:52", "url": "https://files.pythonhosted.org/packages/22/d8/fbea6f97e03f9c557bdbe1be537c5b825b11fc42f2175353cc6e2ba60c72/nativemessaging-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "012710e379914de94d1514d06eaedba1", "sha256": "596196460fc1d23933c8daed7022f6e54a8f551a985a87fa74c6d0aed06c6bb8" }, "downloads": -1, "filename": "nativemessaging-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "012710e379914de94d1514d06eaedba1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6956, "upload_time": "2019-01-03T17:52:54", "url": "https://files.pythonhosted.org/packages/24/c6/156c213b38d96a07906faf435e7cef025273a262a1bf2a4480923faa98c6/nativemessaging-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "115c14221162afe99e4ae6dea5ac4bf5", "sha256": "9e52dad970e91e7fb9571951ea610a461d0e01324ab1f0dc08e127dc2ec5bd78" }, "downloads": -1, "filename": "nativemessaging-1.0.1.tar.gz", "has_sig": false, "md5_digest": "115c14221162afe99e4ae6dea5ac4bf5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4135, "upload_time": "2019-01-03T17:52:55", "url": "https://files.pythonhosted.org/packages/fe/c1/1271a54bfa7dda4675248b5e81b77dd801182309ebabde8f7dd7a27562e7/nativemessaging-1.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "012710e379914de94d1514d06eaedba1", "sha256": "596196460fc1d23933c8daed7022f6e54a8f551a985a87fa74c6d0aed06c6bb8" }, "downloads": -1, "filename": "nativemessaging-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "012710e379914de94d1514d06eaedba1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6956, "upload_time": "2019-01-03T17:52:54", "url": "https://files.pythonhosted.org/packages/24/c6/156c213b38d96a07906faf435e7cef025273a262a1bf2a4480923faa98c6/nativemessaging-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "115c14221162afe99e4ae6dea5ac4bf5", "sha256": "9e52dad970e91e7fb9571951ea610a461d0e01324ab1f0dc08e127dc2ec5bd78" }, "downloads": -1, "filename": "nativemessaging-1.0.1.tar.gz", "has_sig": false, "md5_digest": "115c14221162afe99e4ae6dea5ac4bf5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4135, "upload_time": "2019-01-03T17:52:55", "url": "https://files.pythonhosted.org/packages/fe/c1/1271a54bfa7dda4675248b5e81b77dd801182309ebabde8f7dd7a27562e7/nativemessaging-1.0.1.tar.gz" } ] }