Research
Recent Trends in Malicious Packages Targeting Discord
The Socket research team breaks down a sampling of malicious packages that download and execute files, among other suspicious behaviors, targeting the popular Discord platform.
@travetto/context
Advanced tools
Readme
Install: @travetto/context
npm install @travetto/context
# or
yarn add @travetto/context
This module provides a wrapper around node's async_hooks to maintain context across async calls. This is generally used for retaining contextual user information at various levels of async flow.
The most common way of utilizing the context, is via the WithAsyncContext decorator. The decorator requires the class it's being used in, to have a AsyncContext member, as it is the source of the contextual information.
The decorator will load the context on invocation, and will keep the context active during the entire asynchronous call chain.
Code: Usage of context within a service
import { AsyncContext, WithAsyncContext } from '@travetto/context';
export class ContextAwareService {
constructor(public context: AsyncContext) { }
@WithAsyncContext()
async complexOperator(name: string) {
this.context.set({ name });
await this.additionalOp('extra');
await this.finalOp();
}
async additionalOp(additional: string) {
const { name } = this.context.get();
this.context.set({ name: `${name} ${additional}` });
}
async finalOp() {
const { name } = this.context.get();
// Use name
return name;
}
}
The decorator also allows for a priming of the contextual information. This is generally useful for system generated operations that are not initiated by a user.
Code: Usage of context within a service
import { AsyncContext, WithAsyncContext } from '@travetto/context';
export class SystemInitiatedContext {
constructor(public context: AsyncContext) { }
@WithAsyncContext({
user: 'system',
uid: 20
})
async runJob(name: string) {
console.log('Running', { user: this.context.get().user, jobName: name });
}
}
FAQs
Async-aware state management, maintaining context across asynchronous calls.
The npm package @travetto/context receives a total of 109 weekly downloads. As such, @travetto/context popularity was classified as not popular.
We found that @travetto/context demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Research
The Socket research team breaks down a sampling of malicious packages that download and execute files, among other suspicious behaviors, targeting the popular Discord platform.
Security News
Socket CEO Feross Aboukhadijeh joins a16z partners to discuss how modern, sophisticated supply chain attacks require AI-driven defenses and explore the challenges and solutions in leveraging AI for threat detection early in the development life cycle.
Security News
NIST's new AI Risk Management Framework aims to enhance the security and reliability of generative AI systems and address the unique challenges of malicious AI exploits.