(path, baseDir string)
| 222 | } |
| 223 | |
| 224 | func (s *FileTokenStore) readAuthFiles(path, baseDir string) ([]*cliproxyauth.Auth, error) { |
| 225 | data, err := os.ReadFile(path) |
| 226 | if err != nil { |
| 227 | return nil, fmt.Errorf("read file: %w", err) |
| 228 | } |
| 229 | if len(data) == 0 { |
| 230 | return nil, nil |
| 231 | } |
| 232 | metadata := make(map[string]any) |
| 233 | if err = json.Unmarshal(data, &metadata); err != nil { |
| 234 | return nil, fmt.Errorf("unmarshal auth json: %w", err) |
| 235 | } |
| 236 | provider, _ := metadata["type"].(string) |
| 237 | provider = strings.TrimSpace(provider) |
| 238 | if strings.EqualFold(provider, "gemini") { |
| 239 | return nil, nil |
| 240 | } |
| 241 | info, errStat := os.Stat(path) |
| 242 | if errStat != nil { |
| 243 | return nil, fmt.Errorf("stat file: %w", errStat) |
| 244 | } |
| 245 | if parser := currentPluginAuthParser(); parser != nil { |
| 246 | auths, handled, errParse := parsePluginAuthFile(parser, pluginapi.AuthParseRequest{ |
| 247 | Provider: provider, |
| 248 | Path: path, |
| 249 | FileName: s.idFor(path, baseDir), |
| 250 | RawJSON: data, |
| 251 | }) |
| 252 | if errParse == nil && handled { |
| 253 | auths = compactPluginAuths(auths) |
| 254 | if len(auths) == 0 { |
| 255 | return nil, nil |
| 256 | } |
| 257 | for index, auth := range auths { |
| 258 | if auth == nil { |
| 259 | continue |
| 260 | } |
| 261 | if len(auths) > 1 { |
| 262 | cliproxyauth.MarkPluginVirtualAuth(auth, path, index) |
| 263 | } |
| 264 | auth.CreatedAt = info.ModTime() |
| 265 | auth.UpdatedAt = info.ModTime() |
| 266 | if auth.Attributes == nil { |
| 267 | auth.Attributes = make(map[string]string) |
| 268 | } |
| 269 | auth.Attributes[cliproxyauth.AttributePath] = path |
| 270 | auth.Attributes[cliproxyauth.AttributeSource] = path |
| 271 | auth.Attributes[cliproxyauth.AttributeSourceBackend] = cliproxyauth.AuthSourceFile |
| 272 | cliproxyauth.ApplyCustomHeadersFromMetadata(auth) |
| 273 | } |
| 274 | return auths, nil |
| 275 | } |
| 276 | } |
| 277 | if provider == "" { |
| 278 | provider = "unknown" |
| 279 | } |
| 280 | if provider == "antigravity" { |
| 281 | projectID := "" |
no test coverage detected