
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
@webext-pegasus/rpc
Advanced tools
RPC Messaging in Web Extensions made easy and type safe. Out of the box.

RPC Messaging in Web Extensions made easy and type safe. Out of the box. It provides a simple type-safe wrapper around the web extension messaging APIs that lets you call a function/class from anywhere, but execute it in the target runtime context.
npm install -S @webext-pegasus/transport @webext-pegasus/rpc
IPegasusRPCService<YourService>registerRPCService('serviceName', yourService) in the target runtime context (ex: background)getRPCService<YourServiceType>('serviceName', 'background')
MathService.ts
import {IPegasusRPCService, PegasusRPCMessage} from '@webext-pegasus/rpc';
export type IMathService = InstanceType<
typeof MathService
>;
export class MathService
implements IPegasusRPCService<MathService>
{
fibonacci(num: number): number {
return (num <= 1) ? 1 : this.fibonacci(num - 1) + this.fibonacci(num - 2);
}
}
background.ts
import {registerRPCService} from '@webext-pegasus/rpc';
import {initPegasusTransport} from '@webext-pegasus/transport/background';
import {MathService} from './MathService.ts';
// Done once in every runtime context to init transport layer
initPegasusTransport();
registerRPCService(
'MathService',
new MathService(),
);
injected.ts
// Important to import type only as we don't want to cause any errors by injecting
// code that expects web extension runtime to be loaded on target webpag
import type {IMathService} from './MathService.ts';
import {getRPCService} from '@webext-pegasus/rpc';
import {initPegasusTransport} from '@webext-pegasus/transport/window';
// Done once in every runtime context to init transport layer
initPegasusTransport();
const mathService = getRPCService<IMathService>(
// Same ID that was used for registration
// We may have multiple instances of the same service executed independently
'MathService',
// Where sevice was registered
'background',
);
// Note that now mathService.fibonacci() returns Promise
mathService.fibonacci(10).then(console.log);
// Output: 89
FAQs
RPC Messaging in Web Extensions made easy and type safe. Out of the box.
The npm package @webext-pegasus/rpc receives a total of 4,053 weekly downloads. As such, @webext-pegasus/rpc popularity was classified as popular.
We found that @webext-pegasus/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.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.