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

Method Refresh

internal/pluginhost/adapters.go:1645–1716  ·  view source on GitHub ↗
(ctx context.Context, auth *coreauth.Auth)

Source from the content-addressed store, hash-verified

1643}
1644
1645func (a *executorAdapter) Refresh(ctx context.Context, auth *coreauth.Auth) (refreshed *coreauth.Auth, err error) {
1646 if a == nil || a.executor == nil || a.host.isPluginFused(a.pluginID) || !a.host.pluginIdentityCurrent(a.pluginID, a.path, a.version) {
1647 return nil, fmt.Errorf("plugin executor %s is unavailable", a.Identifier())
1648 }
1649 record := a.host.authProviderRecord(authProvider(auth))
1650 if record == nil || record.plugin.Capabilities.AuthProvider == nil {
1651 return auth.Clone(), nil
1652 }
1653 defer func() {
1654 if recovered := recover(); recovered != nil {
1655 a.host.fusePlugin(record.id, "AuthProvider.RefreshAuth", recovered)
1656 refreshed = nil
1657 err = fmt.Errorf("plugin executor %s refresh panic: %v", a.Identifier(), recovered)
1658 }
1659 }()
1660
1661 pluginResp, errRefresh := record.plugin.Capabilities.AuthProvider.RefreshAuth(ctx, pluginapi.AuthRefreshRequest{
1662 AuthID: authID(auth),
1663 AuthProvider: authProvider(auth),
1664 StorageJSON: storageJSONFromAuth(auth),
1665 Metadata: cloneAnyMap(authMetadata(auth)),
1666 Attributes: authAttributes(auth),
1667 Host: a.host.hostConfigSummary(),
1668 HTTPClient: a.host.newHTTPClient(auth),
1669 })
1670 if errRefresh != nil {
1671 return nil, errRefresh
1672 }
1673 data := pluginResp.Auth
1674 if strings.TrimSpace(data.Provider) == "" {
1675 data.Provider = authProvider(auth)
1676 }
1677 if strings.TrimSpace(data.ID) == "" {
1678 data.ID = authID(auth)
1679 }
1680 if strings.TrimSpace(data.FileName) == "" && auth != nil {
1681 data.FileName = auth.FileName
1682 }
1683 if strings.TrimSpace(data.Label) == "" && auth != nil {
1684 data.Label = auth.Label
1685 }
1686 if strings.TrimSpace(data.Prefix) == "" && auth != nil {
1687 data.Prefix = auth.Prefix
1688 }
1689 if strings.TrimSpace(data.ProxyURL) == "" && auth != nil {
1690 data.ProxyURL = auth.ProxyURL
1691 }
1692 if len(data.Metadata) == 0 && auth != nil {
1693 data.Metadata = cloneAnyMap(auth.Metadata)
1694 }
1695 if len(data.Attributes) == 0 && auth != nil {
1696 data.Attributes = cloneStringMap(auth.Attributes)
1697 }
1698 if len(data.StorageJSON) == 0 {
1699 data.StorageJSON = storageJSONFromAuth(auth)
1700 }
1701 if pluginResp.NextRefreshAfter.IsZero() && auth != nil {
1702 data.NextRefreshAfter = auth.NextRefreshAfter

Callers

nothing calls this directly

Calls 15

IdentifierMethod · 0.95
authProviderFunction · 0.85
authIDFunction · 0.85
storageJSONFromAuthFunction · 0.85
cloneAnyMapFunction · 0.85
authMetadataFunction · 0.85
cloneStringMapFunction · 0.85
isPluginFusedMethod · 0.80
pluginIdentityCurrentMethod · 0.80
authProviderRecordMethod · 0.80
fusePluginMethod · 0.80
hostConfigSummaryMethod · 0.80

Tested by

no test coverage detected