New:Microsoft Teams Notifications Are Now Available in Socket.Learn more
Get Started

interception-crack

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

interception-crack

拦截 WebSocket、Fetch、XHR 请求的 TypeScript 库

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
4
-20%
Maintainers
1
Weekly downloads
 
Created
Source

InterceptionRequest

拦截 WebSocket、Fetch、XHR 请求的 TypeScript 库。

A TypeScript library for intercepting WebSocket, Fetch, and XHR requests.

Installation

npm install interception-crack
# or
yarn add interception-crack
# or
pnpm add interception-crack

Usage

基本使用

导入库后,拦截器会自动初始化。你可以通过回调函数来接收拦截到的响应数据:

import {
  onFetchResponse,
  onXHRResponse,
  onWebSocketMessage,
  onWebSocketSend,
} from 'interception-crack';

// 注册 Fetch 响应拦截回调
onFetchResponse((url, method, status, statusText, data) => {
  console.log('Fetch 响应:', { url, method, status, statusText, data });
});

// 注册 XHR 响应拦截回调
onXHRResponse((url, method, status, statusText, responseType, data) => {
  console.log('XHR 响应:', { url, method, status, statusText, responseType, data });
});

// 注册 WebSocket 消息接收拦截回调
onWebSocketMessage(data => {
  console.log('WebSocket 接收消息:', data);
});

// 注册 WebSocket 消息发送拦截回调
onWebSocketSend(data => {
  console.log('WebSocket 发送消息:', data);
});

使用 InterceptorManager 实例

你也可以创建自己的拦截器管理器实例:

import { InterceptorManager } from 'interception-crack';

const manager = new InterceptorManager();

manager.onFetchResponse((url, method, status, statusText, data) => {
  // 处理 Fetch 响应
});

manager.onXHRResponse((url, method, status, statusText, responseType, data) => {
  // 处理 XHR 响应
});

manager.onWebSocketMessage(data => {
  // 处理 WebSocket 接收消息
});

manager.onWebSocketSend(data => {
  // 处理 WebSocket 发送消息
});

回调函数类型

所有回调函数类型都已导出,方便 TypeScript 类型检查:

import type {
  FetchResponseCallback,
  XHRResponseCallback,
  WebSocketMessageCallback,
  WebSocketSendCallback,
} from 'interception-crack';

Development

# Install dependencies
yarn install

# Development mode (watch)
yarn dev

# Build
yarn build

# Lint
yarn lint

# Format code
yarn format

# Generate documentation
yarn build:docs

License

MIT

Keywords

fetch

FAQs

Package last updated on 28 Nov 2025

Related posts