
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
A tiny, flexible, fast, promise-based library for messaging in Firefox and Chrome extensions.
npm install --save msgx
Try this example yourself with cd test_extension && npm run build
import client from 'msgx/client'
const actions = { zoom: (zoom) => console.log(`zoom ${zoom}`) }
function onDisconnect () { console.log('disconnected') }
const debug = true
const msg = client(actions, onDisconnect, debug)
msg('zoom').then(zoom => console.log(`init zoom ${zoom})`))
msg('sum', 7).then(sum => console.log(`new sum ${sum}`)) // 7
msg('sum', 3).then(sum => console.log(`new sum ${sum}`)) // 10
import server from 'msgx/server'
import browser from 'webextension-polyfill'
const actions = {
sum: (n, _, data) => data.sum += n,
zoom: (_, sender) => browser.tabs.getZoom(sender.tab.id)
}
function onConnect (sender, msg, data) {
function onZoomChange ({ tabId, newZoomFactor }) {
if (sender.tab.id === tabId) msg('zoom', newZoomFactor)
}
browser.tabs.onZoomChange.addListener(onZoomChange)
data.onZoomChange = onZoomChange
data.sum = 0
}
function onDisconnect (sender, data) {
console.log(`final sum ${data.sum}`)
browser.tabs.onZoomChange.removeListener(data.onZoomChange)
}
const debug = true
server(actions, onConnect, onDisconnect, debug)
(actions, onConnect, onDisconnect, debug) => void
(arg, sender, data) => result
(sender, msg, data) => void
(action, arg) => void
(sender, data) => void
(actions, onDisconnect, debug) => msg
(arg) => any
(sender) => void
(action, arg) => Promise<result>
msgx is tiny! Read its source code below.
export default function (actions = {}, onDisconnect, debug = true) {
const port = chrome.runtime.connect()
let t = 0
const transactions = {}
port.onMessage.addListener(([t, actionOrResult, arg]) => {
if (t > 0) {
if (debug) console.log(`rx:${t}`, actionOrResult)
transactions[t](actionOrResult)
} else {
if (debug) console.log(`rx:${t}:${actionOrResult}`, arg)
actions[actionOrResult](arg)
}
})
onDisconnect && port.onDisconnect.addListener(onDisconnect)
return (action, arg) => new Promise(resolve => {
t++
if (debug) console.log(`tx:${t}:${action}`, arg)
port.postMessage([t, action, arg])
transactions[t] = resolve
})
}
export default function (actions = {}, onConnect, onDisconnect, debug = true) {
chrome.runtime.onConnect.addListener(port => {
if (debug) console.log('connect', port.sender)
const data = {}
port.onMessage.addListener(async ([t, action, arg]) => {
if (debug) console.log(`rx:${t}:${action}`, arg)
const reply = await actions[action](arg, port.sender, data)
port.postMessage([ t, reply ])
if (debug) console.log(`tx:${t}`, reply)
})
const msg = (action, arg) => {
if (debug) console.log(`tx:${0}:${action}`, arg)
port.postMessage([0, action, arg])
}
onConnect && onConnect(port.sender, msg, data)
onDisconnect && port.onDisconnect.addListener(() => onDisconnect(port.sender, data))
})
}
FAQs
tiny, flexible, fast, promise-based, webextension messaging
The npm package msgx receives a total of 0 weekly downloads. As such, msgx popularity was classified as not popular.
We found that msgx 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.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.