
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
protoframe
Advanced tools
A small (dependency-free) library for 2-way iframe communication.
You are embedding an iframe where you would like to communicate with the following facilities:
iframe.contentWindow.postMessagewindow.addEventListener('message', (ev) => ...)This library allows you to define a protocol for this type of communication
supporting both fire-and-forget (tell) semantics, as well as request/response
(ask) semantics. It provides connector constructors that will facilitate the
sending and receiving of these messages across parent and iframe windows.
npm install protoframe --save
import { ProtoframeDescriptor } from 'protoframe';
const cacheProtocol: ProtoframeDescriptor<{
getFoo: {
body: { key: string };
response: { value: string };
};
setBar: {
body: { key: string; value: string };
};
}> = { type: 'cache' };
The ProtoframeDescriptor defines 2 elements of your protocol:
body type of the payload (for ask and tell requests), and an optional
response types (for ask requests). An ask message must define a
response key, a tell message must not{type: 'cache'}) defines a type key for the
protocol, which is used to key on specific types of messages to listen to
between the pagesThe connector allows 2-way communication between a page and its iframe. For example, we have a page that wishes to use an iframe as a "cache" server:
Iframe:
import { ProtoframePubsub } from 'protoframe';
// Will hold our cache state
const data: { [key: string]: string } = {};
// The connector. This function creates a connector that listens for messages
// on `window` and sends messages and responses over `window.parent`
const cache = ProtoframePubsub.iframe(cacheProtocol);
// Implement our handlers for the ask and tell requests defined in the protocol
cache.handleTell('setBar', ({ key, value }) => (data[key] = value));
cache.handleAsk('getFoo', async ({ key }) => {
const value = key in data ? data[key] : null;
return { value };
});
Parent:
import { ProtoframePubsub } from 'protoframe';
const iframe = document.getElementById('myCacheServerIframe');
const client = ProtoframePubsub.parent(cacheProtocol, iframe);
// Wait for the iframe page to load and for the connector to be instantiated
ProtoframePubsub.connect(client).then(() => {
client.tell('setBar', { key: 'my key', value: 'my value' });
// value = { value: 'my value' }
const value = await client.ask('getFoo', { key: 'my key' });
});
FAQs
A small (dependency-free) library for 2-way iframe communication.
The npm package protoframe receives a total of 143 weekly downloads. As such, protoframe popularity was classified as not popular.
We found that protoframe 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.