将 main 分支的 Claude/Anthropic 相关逆向工作迁移到 codex 分支: - claude/constants.go: 添加 4 个新 Beta 常量 + 版本升级至 2.1.84/0.74.0 - config.go: 添加 InstanceSalt 和 FingerprintDefaultsConfig 配置 - identity_service: 版本升级 + instanceSalt 支持 + ApplyDefaultFingerprintOverrides - wire_gen.go: 初始化指纹覆盖 + 使用 NewIdentityServiceWithSalt Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
40 lines
1.5 KiB
Go
40 lines
1.5 KiB
Go
package service
|
|
|
|
// ==============================================================
|
|
// antigravity — identity_service 扩展
|
|
//
|
|
// 此文件包含 Antigravity fork 对 IdentityService 的扩展,
|
|
// 新增了实例级隔离盐值和指纹默认值覆盖功能。
|
|
//
|
|
// 对上游文件 identity_service.go 的最小化改动:
|
|
// - defaultFingerprint 版本号更新
|
|
// - IdentityService struct 新增 instanceSalt 字段
|
|
// ==============================================================
|
|
|
|
// ApplyDefaultFingerprintOverrides 用配置覆盖 identity_service 的默认指纹
|
|
// 允许不同部署实例设置不同的 CLI/SDK 版本号,避免所有实例指纹相同
|
|
func ApplyDefaultFingerprintOverrides(cliVersion, pkgVersion, runtimeVersion, os_, arch string) {
|
|
if cliVersion != "" {
|
|
defaultFingerprint.UserAgent = "claude-cli/" + cliVersion + " (external, cli)"
|
|
}
|
|
if pkgVersion != "" {
|
|
defaultFingerprint.StainlessPackageVersion = pkgVersion
|
|
}
|
|
if runtimeVersion != "" {
|
|
defaultFingerprint.StainlessRuntimeVersion = runtimeVersion
|
|
}
|
|
if os_ != "" {
|
|
defaultFingerprint.StainlessOS = os_
|
|
}
|
|
if arch != "" {
|
|
defaultFingerprint.StainlessArch = arch
|
|
}
|
|
}
|
|
|
|
// NewIdentityServiceWithSalt 创建带实例盐值的 IdentityService
|
|
// 实例盐值用于 user_id 重写时的 session hash 混淆,
|
|
// 使不同 sub2api 实例对相同输入产生不同的 hash 输出,增加隔离性
|
|
func NewIdentityServiceWithSalt(cache IdentityCache, salt string) *IdentityService {
|
|
return &IdentityService{cache: cache, instanceSalt: salt}
|
|
}
|