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

Function expirationFromMap

sdk/cliproxy/auth/types.go:613–643  ·  view source on GitHub ↗
(meta map[string]any)

Source from the content-addressed store, hash-verified

611var expireKeys = [...]string{"expired", "expire", "expires_at", "expiresAt", "expiry", "expires"}
612
613func expirationFromMap(meta map[string]any) (time.Time, bool) {
614 if meta == nil {
615 return time.Time{}, false
616 }
617 for _, key := range expireKeys {
618 if v, ok := meta[key]; ok {
619 if ts, ok1 := parseTimeValue(v); ok1 {
620 return ts, true
621 }
622 }
623 }
624 for _, nestedKey := range []string{"token", "Token"} {
625 if nested, ok := meta[nestedKey]; ok {
626 switch val := nested.(type) {
627 case map[string]any:
628 if ts, ok1 := expirationFromMap(val); ok1 {
629 return ts, true
630 }
631 case map[string]string:
632 temp := make(map[string]any, len(val))
633 for k, v := range val {
634 temp[k] = v
635 }
636 if ts, ok1 := expirationFromMap(temp); ok1 {
637 return ts, true
638 }
639 }
640 }
641 }
642 return time.Time{}, false
643}
644
645func ProviderRefreshLead(provider string, runtime any) *time.Duration {
646 provider = strings.ToLower(strings.TrimSpace(provider))

Callers 1

ExpirationTimeMethod · 0.85

Calls 1

parseTimeValueFunction · 0.85

Tested by

no test coverage detected