Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@microbitsclub/microbits-client
Advanced tools
Wrapper around the Microbits HTTP API.
npm install @microbitsclub/microbits-client
Get your merchant ID and API key.
Create a MicrobitsClient
instance.
const microbits = new MicrobitsClient({
merchantId: '<your_merchant_id>',
apiKey: '<your_api_key>',
});
Create a RequestHandlerConfig
object.
interface Ctx {
request: FastifyRequest;
reply: FastifyReply;
}
const microbitsConfig: RequestHandlerConfig<Ctx> = {
microbits,
getUserSessionIdCookie(ctx, name) {
return ctx.request.cookies[name];
},
setUserSessionIdCookie(ctx, name, userSessionId) {
ctx.reply.setCookie(name, userSessionId, {
path: '/',
maxAge: 60 * 60 * 24 * 7,
secure: true,
httpOnly: false,
});
},
};
getUserSessionIdCookie
must return the value of the named cookie.
setUserSessionIdCookie
must set the value of the named cookie to userSessionId
. The cookie must not be HttpOnly in order for the client paywall to be able to access it.
Create configured request handlers.
const clientRequestHandler = getClientRequestHandler<Ctx>(microbitsConfig);
const paywallRequestHandler = getContentRequestHandler<Ctx>(microbitsConfig);
Forward GET requests to the client and paywall request handlers.
fastify.route({
method: 'GET',
url: `${DEFAULTS.MERCHANT_ROUTE_PREFIX}/*`,
async handler(request, reply) {
const result = await microbitsClientRequestHandler({ request, reply }, request.url);
reply.send(result);
},
});
fastify.route({
method: 'GET',
url: '/story/:storyId',
async handler(request, reply) {
const result = await microbitsPaywallRequestHandler({ request, reply }, request.url);
if (result.type === 'error') {
reply.status(result.error.statusCode);
reply.send(result.error.message);
return;
}
if (result.ok.type === 'serve-content') {
const { storyId } = request.params as { storyId: string };
const story = stories.find(x => x.id === storyId);
if (story === undefined) {
reply.status(404);
} else {
reply.status(200);
reply.send(story);
}
} else {
reply.status(204);
reply.send(result.ok.contentUrl);
}
},
});
Here we assume that there is a single group URL paywall for the path /story
.
TODO hard paywall
FAQs
Microbits API client
The npm package @microbitsclub/microbits-client receives a total of 1 weekly downloads. As such, @microbitsclub/microbits-client popularity was classified as not popular.
We found that @microbitsclub/microbits-client 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
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.