{"id":25932758,"url":"https://github.com/cosium/web-native-messaging-host","last_synced_at":"2025-10-05T17:53:28.585Z","repository":{"id":148937109,"uuid":"582702350","full_name":"Cosium/web-native-messaging-host","owner":"Cosium","description":"A java library allowing to turn any JVM application into a Web Native Messaging Host","archived":false,"fork":false,"pushed_at":"2025-09-29T18:24:52.000Z","size":192,"stargazers_count":8,"open_issues_count":2,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-09-29T19:40:03.731Z","etag":null,"topics":["native-messages","native-messaging","native-messaging-host"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cosium.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-12-27T16:17:33.000Z","updated_at":"2025-09-29T17:56:46.000Z","dependencies_parsed_at":"2023-10-03T00:12:33.999Z","dependency_job_id":"656f5fda-e34d-461e-9d98-ccb072804cf9","html_url":"https://github.com/Cosium/web-native-messaging-host","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/Cosium/web-native-messaging-host","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cosium%2Fweb-native-messaging-host","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cosium%2Fweb-native-messaging-host/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cosium%2Fweb-native-messaging-host/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cosium%2Fweb-native-messaging-host/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cosium","download_url":"https://codeload.github.com/Cosium/web-native-messaging-host/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cosium%2Fweb-native-messaging-host/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278493847,"owners_count":25996410,"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","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["native-messages","native-messaging","native-messaging-host"],"created_at":"2025-03-04T00:39:04.870Z","updated_at":"2025-10-05T17:53:28.550Z","avatar_url":"https://github.com/Cosium.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://github.com/Cosium/web-native-messaging-host/actions/workflows/ci.yml/badge.svg)](https://github.com/Cosium/web-native-messaging-host/actions/workflows/ci.yml)\n[![Maven Central](https://img.shields.io/maven-central/v/com.cosium.web_native_messaging_host/web-native-messaging-host.svg)](https://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.cosium.web_native_messaging_host%22%20AND%20a%3A%22web-native-messaging-host%22)\n\n# Web Native Messaging Host\n\nA java library allowing to turn any JVM application into a [Web Native Messaging Host](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_messaging) .\n\n# Gotchas\n\nTo date, [web native messaging protocol](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_messaging) only supports `stdio` communication:\n- messages are sent to the native application's `stdin`  \n- messages are sent to the browser extension via native application's `stdout`\n\nNative application (e.g. your JVM application) instances started by the browser must never use `System.out` for anything else than native messaging. Very often, you will have to make sure your logger never writes to `System.out`.\n\nAs soon as a `Channel` is open, the current library will swap `System.in` and `System.out` for instances throwing exception on any interaction attempt coming from components foreign to the current library. On `Channel` shutdown, the library will swap back the standard `System.in` and `System.out` instances. The current library cannot cover the full application lifecycle, therefore it is only a best effort.\n\nUsing `System.out` (e.g. for logging) before opening a `Channel` will probably trigger a fatal error on the browser side leading to the end of the communication channel and the native application shutdown.\n\n# Quick start\n\n1. Add the following dependency:\n    ```xml\n    \u003cdependency\u003e\n      \u003cgroupId\u003ecom.cosium.web_native_messaging_host\u003c/groupId\u003e\n      \u003cartifactId\u003eweb-native-messaging-host\u003c/artifactId\u003e\n      \u003cversion\u003e${web-native-messaging-host.version}\u003c/version\u003e\n    \u003c/dependency\u003e\n    ```\n2. Open the communication channel:\n    ```java\n    public class App implements MessageHandler {\n   \n      private final ObjectMapper objectMapper = new ObjectMapper();\n\n      public static void main(String[] args) {\n        Host host = Host.builder(new App()).build();\n        // Open the communication channel\n        try (CloseableChannel channel = host.openChannel()) {\n          // Block until channel shutdown\n          channel.waitForShutdown();\n        }\n      }\n    \n      @Override\n      public void onMessage(Channel channel, ContainerNode\u003c?\u003e rawMessage) {\n        Message message = objectMapper.convertValue(rawMessage, Message.class);\n        // Print the received message\n        System.out.printf(\"Received message '%s'%n\", message.body);\n        // Send a message to the other end\n        channel.sendMessage(objectMapper.valueToTree(new Message(\"I got your message\")));\n      }\n   \n      private record Message(String body) {\n      } \n    }\n    ```\n\n# Build\n\n`e2e-tests` can only run on Unix systems.\n\n```shell\n./mvnw clean verify\n```\n\n# Release\n\n```shell\n./release.sh\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcosium%2Fweb-native-messaging-host","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcosium%2Fweb-native-messaging-host","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcosium%2Fweb-native-messaging-host/lists"}