feat: add customer session refresh functionality and improve session management
- Introduced RealtimeCustomerSessionRefreshPayload and RealtimeCustomerSessionRefreshEvent types for handling session refresh events. - Updated ws_service to verify customer session and handle session refresh notifications. - Enhanced API client to manage customer session tokens and expiration. - Implemented customer session validation and storage in session storage. - Added functions to exchange and ensure customer sessions. - Updated IM real-time connection to include customer session tokens in WebSocket requests. - Modified SDK and widget configurations to support external IDs and user tokens.
This commit is contained in:
@@ -9,14 +9,15 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Server ServerConfig `yaml:"server"`
|
||||
DB DBConfig `yaml:"db"`
|
||||
Logger LoggerConfig `yaml:"logger"`
|
||||
Auth AuthConfig `yaml:"auth"`
|
||||
Storage StorageConfig `yaml:"storage"`
|
||||
VectorDB VectorDBConfig `yaml:"vectorDB"`
|
||||
MCP MCPConfig `yaml:"mcp"`
|
||||
WxWork WxWorkConfig `yaml:"wxWork"`
|
||||
Server ServerConfig `yaml:"server"`
|
||||
DB DBConfig `yaml:"db"`
|
||||
Logger LoggerConfig `yaml:"logger"`
|
||||
Auth AuthConfig `yaml:"auth"`
|
||||
Storage StorageConfig `yaml:"storage"`
|
||||
VectorDB VectorDBConfig `yaml:"vectorDB"`
|
||||
MCP MCPConfig `yaml:"mcp"`
|
||||
WxWork WxWorkConfig `yaml:"wxWork"`
|
||||
CustomerSession CustomerSessionConfig `yaml:"customerSession"`
|
||||
}
|
||||
|
||||
type WxWorkNotifyConfig struct {
|
||||
@@ -60,6 +61,26 @@ type AuthConfig struct {
|
||||
CredentialLockMinute int `yaml:"credentialLockMinute"`
|
||||
}
|
||||
|
||||
type CustomerSessionConfig struct {
|
||||
Secret string `yaml:"secret"`
|
||||
TTLMinutes int `yaml:"ttlMinutes"`
|
||||
RefreshThresholdMinutes int `yaml:"refreshThresholdMinutes"`
|
||||
}
|
||||
|
||||
func (c CustomerSessionConfig) TTL() int {
|
||||
if c.TTLMinutes <= 0 {
|
||||
return 120
|
||||
}
|
||||
return c.TTLMinutes
|
||||
}
|
||||
|
||||
func (c CustomerSessionConfig) RefreshThreshold() int {
|
||||
if c.RefreshThresholdMinutes <= 0 {
|
||||
return 30
|
||||
}
|
||||
return c.RefreshThresholdMinutes
|
||||
}
|
||||
|
||||
type StorageConfig struct {
|
||||
Default enums.AssetProvider `yaml:"default"`
|
||||
MaxUploadSizeMB int64 `yaml:"maxUploadSizeMB"`
|
||||
|
||||
Reference in New Issue
Block a user