
Research
/Security News
11 Malicious NuGet Tools Pose as Game Cheats to Drop a Windows Host-Surveillance Payload
11 malicious NuGet tools pose as game cheats to deploy Windows payloads, track hosts, and use Google Sheets for telemetry and control.
js-interceptor-es
Advanced tools
推荐使用 es6+的继承方式,包含三部分,before, after, handle
| 模块 | 使用 | 说明 |
|---|---|---|
| handle | 子类中定义 | 具体的业务方法 |
| before | 实例化以后添加 | 执行 handle 的前置操作,通常用来修改和拦截 handle 的参数 |
| after | 实例化以后添加 | 执行 handle 的后置操作,通常用来修改和拦截 handle 的返回值 |
| invoke | 使用 instance.invoke(params)调用 |
import Interceptor from "js-interceptor-es";
class Demo extends Interceptor {
// handle函数是被拦截的业务函数
handle(data) {
return new Promise((resolve) => {
setTimeout(() => {
resolve(100); // 模拟业务返回
}, 1000);
});
}
}
const instance = new Demo();
/**
* instance.interceptors.before 在handle之前执行
* instance.interceptors.after 在handle之后执行
* 拦截请求参数,接受两个函数参数
* 第一个函数参数为前置promise resolve执行
* 第二个函数参数为前置promise reject执行
* 其中resolved的参数,为前置阶段的返回值
* instance.interceptors.before.add(resolved, rejected);
* instance.interceptors.after.add(resolved, rejected);
*/
instance.interceptors.before.add((params) => {
console.log(params);
params++;
return params;
});
// 如果是异步操作,支持返回promise对象
instance.interceptors.before.add((params) => {
return new Promise((resolve) => {
setTimeout(() => {
params++;
resolve(params);
});
});
});
instance.interceptors.after.add((result) => {
console.log(params);
params++;
return params;
});
/**
* 使用invoke执行handle函数
*/
instance.invoke(111);
FAQs
js拦截器
The npm package js-interceptor-es receives a total of 10 weekly downloads. As such, js-interceptor-es popularity was classified as not popular.
We found that js-interceptor-es 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.

Research
/Security News
11 malicious NuGet tools pose as game cheats to deploy Windows payloads, track hosts, and use Google Sheets for telemetry and control.

Research
/Security News
4 compromised asyncapi packages deliver miasma botnet loader on macOS, Linux and Windows.

Research
/Security News
A compromised jscrambler npm release added a malicious preinstall hook that runs hidden native binaries on Linux, macOS, and Windows.