
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.
@hadeeb/trpc-worker
Advanced tools
Run tRPC in a web worker / electron main thread
Thin wrapper(<1kb min+gzip) around tRPC's websocket link & adapter
import { applyWSSHandler } from "@trpc/server/adapters/ws";
import { createWorkerServer } from "@hadeeb/trpc-worker/adapter";
import { appRouter } from "../path/to/router";
import { createContext } from "../path/to/context";
applyWSSHandler({
router: appRouter,
createContext,
wss: createWorkerServer({ worker: self }),
});
import { createTRPCProxyClient, wsLink } from "@trpc/client";
import { createWorkerClient } from "@hadeeb/trpc-worker/link";
import type { AppRouter } from "../path/to/server/trpc";
const worker = new Worker("../path/to/trpc/worker");
const client = createTRPCProxyClient<AppRouter>({
links: [
wsLink({
client: createWorkerClient({ worker }),
}),
],
});
import { ipcMain } from "electron";
import { createElectronServer } from "@hadeeb/trpc-worker/adapter";
applyWSSHandler({
router: appRouter,
createContext,
wss: createElectronServer({ ipcMain }),
});
import { ipcRenderer } from "electron";
import { trpcElectronPreload } from "@hadeeb/trpc-worker/adapter";
trpcElectronPreload({ ipcRenderer });
const client = createTRPCProxyClient<AppRouter>({
links: [
wsLink({
client: createWorkerClient({ worker: window }),
}),
],
});
While running in browser, you may have to disable server-side checks in tRPC.
const t = initTRPC.create({
isServer: false,
allowOutsideOfServer: true,
});
This depends on the internals of default tRPC Websocket link & ws adapter.
It helps keep the implementation very light.
However, it may break with tRPC patch updates.
Please check before updating tRPC.
FAQs
Run tRPC in a web worker
The npm package @hadeeb/trpc-worker receives a total of 7 weekly downloads. As such, @hadeeb/trpc-worker popularity was classified as not popular.
We found that @hadeeb/trpc-worker 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.