36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
package synthesizer
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/router-for-me/CLIProxyAPI/v7/internal/config"
|
|
coreauth "github.com/router-for-me/CLIProxyAPI/v7/sdk/cliproxy/auth"
|
|
"github.com/router-for-me/CLIProxyAPI/v7/sdk/pluginapi"
|
|
)
|
|
|
|
// PluginAuthParser parses auth JSON owned by plugin providers.
|
|
type PluginAuthParser interface {
|
|
ParseAuth(context.Context, pluginapi.AuthParseRequest) (*coreauth.Auth, bool, error)
|
|
}
|
|
|
|
// PluginMultiAuthParser expands one auth JSON payload into multiple plugin auth records.
|
|
// Returning handled=true with an empty slice means the plugin intentionally suppresses built-in parsing.
|
|
type PluginMultiAuthParser interface {
|
|
ParseAuths(context.Context, pluginapi.AuthParseRequest) ([]*coreauth.Auth, bool, error)
|
|
}
|
|
|
|
// SynthesisContext provides the context needed for auth synthesis.
|
|
type SynthesisContext struct {
|
|
// Config is the current configuration
|
|
Config *config.Config
|
|
// AuthDir is the directory containing auth files
|
|
AuthDir string
|
|
// Now is the current time for timestamps
|
|
Now time.Time
|
|
// IDGenerator generates stable IDs for auth entries
|
|
IDGenerator *StableIDGenerator
|
|
// PluginAuthParser parses plugin-owned auth files
|
|
PluginAuthParser PluginAuthParser
|
|
}
|