
Security News
Security Community Slams MIT-linked Report Claiming AI Powers 80% of Ransomware
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.
@dr/event-hub
Advanced tools
Broadcast events across frames
event-hub transparently sends scoped events from handlers to the top frame down to handlers in any frame that includes the module.
top frame            frame                            frame
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β                   ββ                               ββ                 β
β   βββββββββββββ   ββ   βββββββββββ   βββββββββββ   ββ   βββββββββββ   β
β   β event hub β   ββ   β handler β   β handler β   ββ   β handler β   β
β   βββββββ¬ββββββ   ββ   ββββββ¬βββββ   ββββββ¬βββββ   ββ   ββββββ¬βββββ   β
β         β         ββ        β             β        ββ        β        β
β         β     subscribe     β             β        ββ        β        β
β         ββ~~~~~~~~~~~~~~~~~~β             β        ββ        β        β
β         β         ββ        β             β        ββ        β        β
β         β         ββ subscribe            β        ββ        β        β
β         ββ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~β        ββ        β        β
β         β         ββ        β             β        ββ        β        β
β         β         ββ        β  subscribe  β        ββ        β        β
β         ββ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~β        β
β         β         ββ        β             β        ββ        β        β
β         β         ββ        β             β        ββ        β        β
β         β    fire event     β             β        ββ        β        β
β         ββββββββββββββββββββO             β        ββ        β        β
β         β         ββ        β             β        ββ        β        β
β         β       event       β             β        ββ        β        β
β         ββββββββββββββββββΊ  X             β        ββ        β        β
β         β         ββ        β             β        ββ        β        β
β         β         ββ   event              β        ββ        β        β
β         ββββββββββββββββββββββββββββββββββΊβ        ββ        β        β
β         β         ββ        β             β        ββ        β        β
β         β         ββ        β    event    β        ββ        β        β
β         βββββββββββββββββββββββββββββββββββββββββββββββββββββΊβ        β
β         β         ββ        β             β        ββ        β        β
β   βββββββ΄ββββββ   ββ   ββββββ΄βββββ   ββββββ΄βββββ   ββ   ββββββ΄βββββ   β
β   β event hub β   ββ   β handler β   β handler β   ββ   β handler β   β
β   βββββββββββββ   ββ   βββββββββββ   βββββββββββ   ββ   βββββββββββ   β
β                   ββ                               ββ                 β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββΊ External event
β~ Internal event
If the top frame has an EventHub instance it will orchestrate delegation of events. All that is required is to include the module in the frame.
Any event sent from a handler (created via createHandler), in any frame, is redelegated by the EventHub instance to any other handlers.
Each handler has its own unique internal id, that is passed on with the event in order to prevent it from firing the on the originating handler.
If the top frame does not have an EventHub instance - handlers in subframes won't be able to broadcast events beoynd their own frame - but still be broadcast within it.
npm install @dr/event-hub
import createHandler, { MEDIA_PAUSE } from '@dr/event-hub';
let state = 'paused';
// Handle incoming events via handler.
const handler = createHandler((type) => {
  if (type === MEDIA_PAUSE) {
    state = 'paused';
  }
});
playButton.onclick = () => {
  if (state === 'paused') {
    state = 'playing';
    // Send events via handler.
    handler.send(MEDIA_PAUSE);
  } else {
    state = 'paused';
  }
}
A function to create a handler for sending and receiving events.
callback (function) - Optional. A callback function to receive events. Has the following arguments:
type (string) - The type of the event, eg. MEDIA_PAUSE.options (object) - Optional.options.id (string|undefined) - Optional. Additional data for the given event.options.data (any) - Optional. Additional data for the given event.An EventHubHandler instance.
A class to listen to and send scoped events. It automatically filters out events sent from itself to avoid confusion.
A method to send events.
type (string) - The type of the event, eg. MEDIA_PAUSE.data (any) - Optional. Additional data for the given event.A method to remove the event listener if the handler is no longer needed.
Predefined event types:
MEDIA_PAUSE (string) - Signals that other playing media elements should pause.To run the demo clone the repo and then run it locally:
npm run demo
The demo runs 4 servers on different ports to simulate cross domain scenarios with regards to framesets. It shows how the state of some "play/pause" widgets react to eachother via events. Go to http://localhost:1234/demo/
The repo is developed as an ESM module (source in esm/) with a minimal build step to support CommonJS (output to cjs/).
FAQs
Broadcast events across frames
We found that @dr/event-hub demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.Β It has 65 open source maintainers 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
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.

Research
/Security News
Socket researchers found 10 typosquatted npm packages that auto-run on install, show fake CAPTCHAs, fingerprint by IP, and deploy a credential stealer.