{"id":28425206,"url":"https://github.com/metamask/extension-port-stream","last_synced_at":"2026-02-13T18:14:19.599Z","repository":{"id":32841780,"uuid":"144187202","full_name":"MetaMask/extension-port-stream","owner":"MetaMask","description":"A module for creating a node style stream over a WebExtension port object.","archived":false,"fork":false,"pushed_at":"2025-03-28T16:15:05.000Z","size":126,"stargazers_count":25,"open_issues_count":6,"forks_count":11,"subscribers_count":33,"default_branch":"main","last_synced_at":"2025-05-29T16:34:24.834Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MetaMask.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":null,"open_collective":"metamask","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2018-08-09T18:04:10.000Z","updated_at":"2025-05-28T13:43:54.000Z","dependencies_parsed_at":"2024-02-27T19:28:54.378Z","dependency_job_id":"e65e573b-939b-4daf-b00d-eb9d8f4886bc","html_url":"https://github.com/MetaMask/extension-port-stream","commit_stats":{"total_commits":28,"total_committers":9,"mean_commits":3.111111111111111,"dds":0.6785714285714286,"last_synced_commit":"395bd0e419dcb8e749df48c6842f910e2cdcbeab"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/MetaMask/extension-port-stream","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MetaMask%2Fextension-port-stream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MetaMask%2Fextension-port-stream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MetaMask%2Fextension-port-stream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MetaMask%2Fextension-port-stream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MetaMask","download_url":"https://codeload.github.com/MetaMask/extension-port-stream/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MetaMask%2Fextension-port-stream/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262335203,"owners_count":23295594,"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":"2025-06-05T10:36:36.047Z","updated_at":"2026-02-13T18:14:19.591Z","avatar_url":"https://github.com/MetaMask.png","language":"TypeScript","funding_links":["https://opencollective.com/metamask"],"categories":[],"sub_categories":[],"readme":"# Extension Port Stream\n\nA module for creating a Node-style stream over a WebExtension [Runtime.Port](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/Port) object.\n\n## Breaking changes from v4 to v5\n\n1. Chunking mode is enabled by default (see the [Usage](#usage) section below).\n2. Node.js-style `Buffer` messages are no longer supported.\n\nAdditionally, the timing of logging, errors, and callbacks may be handled differently.\n\n## Usage\n\nBy default, `ExtensionPortStream` will send messages in 64MB chunks on Chromium-based browsers.\nWhen this mode is used the receiving end must also use `ExtensionPortStream` in its default mode.\n\n```javascript\nimport { ExtensionPortStream } from \"extension-port-stream\";\n\nextension.runtime.onConnect.addListener(connectRemote);\nconst portStream = new ExtensionPortStream(remotePort, {\n  chunkSize: 0, // disable chunking\n});\n\n// Enjoy!\n```\n\nTo disable chunking set the `chunkSize` option to `0`. This will make the transport\nmostly backwards compatible with v4.\n\n```javascript\nimport { ExtensionPortStream } from \"extension-port-stream\";\n\nextension.runtime.onConnect.addListener(connectRemote);\nconst portStream = new ExtensionPortStream(remotePort, {\n  chunkSize: 0, // disable chunking\n});\n\n// Enjoy!\n```\n\n### Events\n\n`ExtensionPortStream` extends Node.js `Duplex` stream, so it inherits all EventEmitter capabilities. Additionally, it emits the following custom events:\n\n#### `message-too-large`\n\nEmitted when a message is too large to send in a single `postMessage` call and needs to be chunked. This event is only emitted when chunking is enabled (default).\n\n```javascript\nimport {\n  ExtensionPortStream,\n  MessageTooLargeEventData,\n} from \"extension-port-stream\";\n\nconst portStream = new ExtensionPortStream(remotePort);\n\nportStream.on(\"message-too-large\", (data: MessageTooLargeEventData) =\u003e {\n  console.log(\n    `Message too large (${\n      JSON.stringify(data.message).length\n    } bytes), chunking into ${data.chunkSize}-byte pieces`\n  );\n  console.log(\"Original error:\", data.originalError.message);\n});\n```\n\n## Running tests\n\n```bash\nyarn test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetamask%2Fextension-port-stream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmetamask%2Fextension-port-stream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetamask%2Fextension-port-stream/lists"}