MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / buildAuthRecord

Method buildAuthRecord

sdk/auth/codex_device.go:254–294  ·  view source on GitHub ↗
(authSvc *codex.CodexAuth, authBundle *codex.CodexAuthBundle)

Source from the content-addressed store, hash-verified

252}
253
254func (a *CodexAuthenticator) buildAuthRecord(authSvc *codex.CodexAuth, authBundle *codex.CodexAuthBundle) (*coreauth.Auth, error) {
255 tokenStorage := authSvc.CreateTokenStorage(authBundle)
256
257 if tokenStorage == nil || tokenStorage.Email == "" {
258 return nil, fmt.Errorf("codex token storage missing account information")
259 }
260
261 planType := ""
262 hashAccountID := ""
263 if tokenStorage.IDToken != "" {
264 if claims, errParse := codex.ParseJWTToken(tokenStorage.IDToken); errParse == nil && claims != nil {
265 planType = strings.TrimSpace(claims.CodexAuthInfo.ChatgptPlanType)
266 accountID := strings.TrimSpace(claims.CodexAuthInfo.ChatgptAccountID)
267 if accountID != "" {
268 digest := sha256.Sum256([]byte(accountID))
269 hashAccountID = hex.EncodeToString(digest[:])[:8]
270 }
271 }
272 }
273
274 fileName := codex.CredentialFileName(tokenStorage.Email, planType, hashAccountID, true)
275 metadata := map[string]any{
276 "email": tokenStorage.Email,
277 }
278
279 fmt.Println("Codex authentication successful")
280 if authBundle.APIKey != "" {
281 fmt.Println("Codex API key obtained and stored")
282 }
283
284 return &coreauth.Auth{
285 ID: fileName,
286 Provider: a.Provider(),
287 FileName: fileName,
288 Storage: tokenStorage,
289 Metadata: metadata,
290 Attributes: map[string]string{
291 "plan_type": planType,
292 },
293 }, nil
294}

Callers 2

loginWithDeviceFlowMethod · 0.95
LoginMethod · 0.95

Calls 4

ProviderMethod · 0.95
ParseJWTTokenFunction · 0.92
CredentialFileNameFunction · 0.92
CreateTokenStorageMethod · 0.65

Tested by

no test coverage detected