Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@devtools-ds/port-controller
Advanced tools
`PortController` is a simple class for managing browser `Runtime.Port` objects in the `background` script of your extension.
PortController
is a simple class for managing browser Runtime.Port
objects in the background
script of your extension.
Some background:
If you are developing an extension with a popup dialog or a devtools panel, they'll need to send messages to your background
script. Only the background script has permissions to communicate with the content
script (the page). Managing these connections can be a little confusing, because there is only one instance of your background script running but multiple tabs, popups, and panels can exist and try to talk to each other.
npm i @devtools-ds/port-controller
# or with yarn
yarn add @devtools-ds/port-controller
Here is an example background
script using the port controller.
import { PortController } from "@devtools-ds/port-controller";
const controller = new PortController<Message>();
browser.runtime.onConnect.addListener((port) => {
if (port.name === PORT_NAME) {
// Attach listener to the Panel
port.onMessage.addListener((message: Message) => {
if (message.type === "connect" && message.tabId) {
controller.connect(message.tabId, port);
}
// Pass message to content script
controller.toContent(message.tabId, message);
});
// Handle Panel disconnect
port.onDisconnect.addListener(function (p) {
const message: DisconnectMessage = {
type: "disconnect",
source: PANEL_SOURCE,
tabId: 0,
};
controller.disconnect(p, message);
});
}
});
// Attach listener to content
browser.runtime.onMessage.addListener(function (
message: Message,
sender: Runtime.MessageSender
) {
// Messages from content scripts should have sender.tab set
if (sender.tab) {
const tabId = sender.tab.id;
if (tabId) controller.toPanel(tabId, message);
} else {
logger.log("Could not pass message, sender.tab not defined.", message);
}
});
FAQs
`PortController` is a simple class for managing browser `Runtime.Port` objects in the `background` script of your extension.
The npm package @devtools-ds/port-controller receives a total of 0 weekly downloads. As such, @devtools-ds/port-controller popularity was classified as not popular.
We found that @devtools-ds/port-controller demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.