
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
@elasticbottle/trpc-post-message
Advanced tools
⭐ Help this repo out, STAR it! ⭐
1. Install trpc-post-message
.
# npm
npm install @elasticbottle/trpc-post-message
# yarn
yarn add @elasticbottle/trpc-post-message
# pnpm
pnpm add @elasticbottle/trpc-post-message
2. Add createPostMessageHandler
in your background script.
// background.ts
import { initTRPC } from "@trpc/server";
import { createPostMessageHandler } from "@elasticbottle/trpc-post-message/adapter";
const t = initTRPC.create({
isServer: false,
allowOutsideOfServer: true,
});
const appRouter = t.router({
// ...procedures
});
export type AppRouter = typeof appRouter;
createPostMessageHandler({
router: appRouter,
postMessage: ({ message }) => window.postMessage(message, "your_targeted_url"),
addEventListener: (listener) =>
window.addEventListener("message", (e) => {
if (e.origin !== 'your_whitelisted_domain') {
return;
}
listener(e);
}),
}); /* 👈 */,
3. Add a PostMessageLink
to the client in your content script.
// content.ts
import { createTRPCClient } from "@trpc/client";
import { PostMessageLink } from "@elasticbottle/trpc-post-message/link";
import type { AppRouter } from "./background";
export const PostMessageClient = createTRPCClient<AppRouter>({
links: [
PostMessageLink({
postMessage: ({ message }) => window.postMessage(message, "your_targeted_url"),
addEventListener: (listener) => {
const customerListener = (e) => {
if (e.origin !== 'your_whitelisted_domain') {
return;
}
listener(e);
}
window.addEventListener("message", customerListener)
// if you don't return anything it is assumed that the default listener was used
return customerListener;
},
removeEventListener: (listener) =>
window.removeEventListener("message", listener),
}),
], /* 👈 */,
});
Peer dependencies:
Please see full typings here.
Property | Type | Description | Required |
---|---|---|---|
postMessage | Function | Called to send data to the "server". You must send the message param as is | true |
addEventListener | Function | Called to add listener to receive request from the "server". | true |
Please see full typings here.
Property | Type | Description | Required |
---|---|---|---|
router | Router | Your application tRPC router. | true |
postMessage | Function | Called to send data to the "client". You must send the message param as is | true |
addEventListener | Function | Called to add listener to receive request from the "client". | true |
createContext | Function | Passes contextual (ctx ) data to procedure resolvers. | false |
onError | Function | Called if error occurs inside handler. | false |
Distributed under the MIT License. See LICENSE for more information.
Winston Yeo - Follow me on Twitter @winston_yeo 💖
Ths project would not have been possible without @jlalmes and his well-documented trpc-chrome package for which this code base was heavily built upon.
FAQs
tRPC adapter for post messages 📨
The npm package @elasticbottle/trpc-post-message receives a total of 56 weekly downloads. As such, @elasticbottle/trpc-post-message popularity was classified as not popular.
We found that @elasticbottle/trpc-post-message 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
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.