
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
@avinlab/postmessage-rpc
Advanced tools
This is a library for making RPC calls (asynchronous method calls) between browser windows or iframes. It builds upon the browser postMessage
API, which lacks some features that complex applications may depend upon:
postMessage
events are global on the window, so multiple postMessage targets must be disambiguated.postMessage
does not guarantee ordering, which can lead to surprising and difficult to diagnose bugs.This RPC layer resolves those issues.
The RPC class is symmetrical and should be created on both windows you want to talk between. Say you want to embed iframe.html
inside the parent.html
, and have the parent provide a function that adds things the child gives it. That might look like:
parent.js
import { RPC } from '@avinlab/postmessage-rpc';
const rpc = new RPC({
// The window you want to talk to:
target: myIframe.contentWindow,
// This should be unique for each of your producer<->consumer pairs:
serviceId: 'my-awesome-service',
// Optionally, allowlist the origin you want to talk to:
// origin: 'example.com',
});
rpc.expose('add', (data) => data.a + data.b);
iframe.js
import { RPC } from '@avinlab/postmessage-rpc';
const rpc = new RPC({
target: window.parent,
serviceId: 'my-awesome-service',
});
rpc.call('add', { a: 3, b: 5 }).then(result => console.log('3 + 5 is', result));
FAQs
Remote procedure call layer between browser contexts
We found that @avinlab/postmessage-rpc 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
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.