npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

iflow-local-proxy

v1.0.0

Published

iFlow 本地安全反代 - 仅绑定 127.0.0.1,内置熔断器/限速/签名,最大程度规避封禁风险

Readme

iFlow Local Proxy - 本地安全反代(单账号模式)

仅绑定 127.0.0.1 的 iFlow API 反向代理,内置多层防封保护机制。仅支持单个账号

特性

  • 🔒 仅本地访问 - 绑定 127.0.0.1,外部网络完全不可达
  • 🛡️ 熔断器 - 收到 434 (AK blocked) 立即停止所有请求,避免连续触发封禁
  • ⏱️ 请求节流 - 最小间隔 + 随机抖动,模拟自然使用节奏
  • 📋 模型白名单 - 只允许请求已确认存在的模型,避免无效请求触发风控
  • 🔑 HMAC 签名 - 每个请求携带签名,完全模拟官方 CLI 行为
  • 🔄 自动刷新 - OAuth / Cookie 凭据自动续期
  • 👤 单账号模式 - 仅使用一个账号,设置新账号自动覆盖旧的

安装

方式一: npm 全局安装(推荐)

npm install -g iflow-local-proxy

安装后直接使用:

# 启动代理
iflow-local-proxy

# OAuth 手机号登录
iflow-local-proxy login

# 指定端口
iflow-local-proxy --port 9000

# 指定配置文件
iflow-local-proxy --config /path/to/config.yaml

方式二: npx 免安装运行

npx iflow-local-proxy
npx iflow-local-proxy login

方式三: 源码运行

git clone <repo-url>
cd iflow-local-proxy
npm install
npm start

添加凭据

方式一: 设置 API Key(最简单)

curl -X POST http://127.0.0.1:8318/api/account/set-key ^
  -H "Content-Type: application/json" ^
  -d "{\"apiKey\": \"sk-xxx\", \"name\": \"my-account\"}"

方式二: OAuth 登录

npm run login
# 或通过 API:
# POST http://127.0.0.1:8318/api/login/oauth

方式三: Cookie 登录

curl -X POST http://127.0.0.1:8318/api/account/set-cookie ^
  -H "Content-Type: application/json" ^
  -d "{\"cookie\": \"BXAuth=xxx;\", \"name\": \"cookie-account\"}"

注意: 单账号模式下,设置新账号会自动删除旧账号。

API 端点

代理端点 (兼容 OpenAI / Anthropic)

| 方法 | 路径 | 说明 | |------|------|------| | GET | /v1/models | 模型列表 | | POST | /v1/chat/completions | OpenAI 格式聊天 | | POST | /v1/messages | Anthropic 格式聊天 | | POST | /v1/messages/count_tokens | Token 计数 |

管理端点

| 方法 | 路径 | 说明 | |------|------|------| | GET | / | 服务状态概览 | | GET | /api/status | 详细状态 | | GET | /api/account | 查看当前账号 | | POST | /api/account/set-key | 设置 API Key (覆盖) | | POST | /api/account/set-cookie | Cookie 登录 (覆盖) | | POST | /api/account/refresh | 手动刷新凭据 | | DELETE | /api/account | 删除当前账号 | | GET | /api/circuit-breaker | 熔断器状态 | | POST | /api/circuit-breaker/reset | 重置熔断器 | | POST | /api/login/oauth | 启动 OAuth 登录 (覆盖) |

防封保护机制

1. 熔断器 (Circuit Breaker)

  • 收到 434 (AK blocked) 响应 → 立即暂停所有请求(默认 1 小时)
  • 连续 3 次 434 → 永久熔断(需手动 POST /api/circuit-breaker/reset
  • 暂停期间所有请求返回 503,不会发送到上游

2. 请求节流 (Throttler)

  • 每个请求之间至少间隔 2s + 0~1s 随机抖动
  • 每分钟最多 20 个请求(硬上限)
  • 超出限制时请求排队等待,不会直接拒绝

3. 模型白名单

  • 只允许向白名单中的模型发送请求
  • 请求不存在的模型会被本地拦截,不会发到上游
  • 可在 config.yaml 中配置

4. HMAC 签名

  • 每个请求自动携带 x-iflow-signature / x-iflow-timestamp / session-id
  • 完全模拟官方 iFlow-Cli 行为

配置客户端

Claude Code

claude config set --global apiProvider "openai"
claude config set --global apiBaseUrl "http://127.0.0.1:8318"
claude config set --global apiKey "any-key"
claude config set --global model "deepseek-r1"

Cline (VS Code 插件)

  • API Provider: OpenAI Compatible
  • Base URL: http://127.0.0.1:8318/v1
  • API Key: 任意值
  • Model: 选择白名单中的模型

OpenAI SDK

from openai import OpenAI
client = OpenAI(base_url="http://127.0.0.1:8318/v1", api_key="any")
response = client.chat.completions.create(
    model="deepseek-r1",
    messages=[{"role": "user", "content": "hello"}]
)

配置说明

参见 config.yaml 中的详细注释。