Skip to content

unfallenwill/iflow-auth

Repository files navigation

OpenClaw iFlow Auth Plugin

OpenClaw 插件,提供 iFlow (iflow.cn) 模型的 OAuth 认证和签名代理服务。

功能

  • OAuth 认证:通过手机号登录 iFlow 平台
  • 签名代理:自动为 API 请求生成 HMAC-SHA256 签名
  • 确定性 Session:基于首条消息内容生成确定性 Session ID
  • OpenAI 兼容:使用 OpenAI SDK 实现代理,协议可靠

支持的模型

模型 ID 名称 Context Max Output Reasoning
deepseek-v3.2 DeepSeek V3.2 128K 64K
glm-4.7 GLM-4.7 200K 32K
glm-5 GLM-5 170K 32K
iFlow-ROME-30BA3B iFlow ROME 30B 256K 64K
kimi-k2-0905 Kimi K2 0905 256K 32K
kimi-k2-thinking Kimi K2 Thinking 256K 32K
kimi-k2.5 Kimi K2.5 262K 32K
minimax-m2.5 MiniMax M2.5 128K 64K
qwen3-coder-plus Qwen3 Coder Plus 256K 64K

安装

方式一:本地路径加载(开发推荐)

  1. 安装依赖:
cd /path/to/iflow-auth
npm install
  1. 在 OpenClaw 配置文件 openclaw.json 中添加:
{
  plugins: {
    load: {
      paths: ["/path/to/iflow-auth"],
    },
  },
}

方式二:复制到 extensions 目录

# 复制到 OpenClaw 的 extensions 目录
cp -r /path/to/iflow-auth /path/to/openclaw/extensions/iflow-auth

# 安装依赖
cd /path/to/openclaw/extensions/iflow-auth
npm install

# 启用插件
openclaw plugins enable iflow-auth

方式三:npm 安装

openclaw plugins install @openclaw/iflow-auth

使用

1. 启动 Gateway

openclaw gateway start

2. 登录 iFlow

openclaw models auth login --provider iflow

按提示:

  1. 打开浏览器访问授权页面
  2. 使用手机号登录
  3. 输入获得的授权码

3. 使用模型

# 命令行聊天
openclaw chat --model iflow/glm-5

# 指定其他模型
openclaw chat --model iflow/deepseek-v3.2

# 在配置中使用
# openclaw.json:
{
  agents: {
    list: [{
      id: "main",
      model: "iflow/glm-5"
    }]
  }
}

环境变量

变量名 说明 默认值
OPENCLAW_GATEWAY_PORT OpenClaw Gateway 端口 18789

工作原理

┌─────────────┐     ┌─────────────────┐     ┌─────────────┐
│   OpenClaw  │ ──▶ │  iflow-auth     │ ──▶ │  iFlow API  │
│             │     │  (OpenAI SDK)   │     │             │
└─────────────┘     └─────────────────┘     └─────────────┘
                           │
                    添加签名头:
                    - session-id (确定性)
                    - x-iflow-signature
                    - x-iflow-timestamp
  • OAuth:手机号登录获取 API key
  • 签名:HMAC-SHA256 签名验证请求合法性
  • Session ID:基于首条用户消息内容生成,相同对话保持一致
  • 代理:使用 OpenAI SDK 转发请求,可靠处理 SSE 流式响应

开发

# 安装依赖
npm install

# 类型检查
npm run typecheck

# 格式化
npm run format

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors