package service import "github.com/Wei-Shaw/sub2api/internal/pkg/claude" // ============================================================== // 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.BuildCLIUserAgent(cliVersion, "", "") } 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} }