226 lines
8.2 KiB
Go
226 lines
8.2 KiB
Go
|
|
package models
|
||
|
|
|
||
|
|
import "time"
|
||
|
|
|
||
|
|
type SocialLinks struct {
|
||
|
|
Twitter string
|
||
|
|
GitHub string
|
||
|
|
Discord string
|
||
|
|
}
|
||
|
|
|
||
|
|
type ProfileSettings struct {
|
||
|
|
AvatarURL string
|
||
|
|
Initials string
|
||
|
|
DisplayName string
|
||
|
|
Username string
|
||
|
|
Bio string
|
||
|
|
Website string
|
||
|
|
SocialLinks SocialLinks
|
||
|
|
Visibility string
|
||
|
|
}
|
||
|
|
|
||
|
|
type Device struct {
|
||
|
|
ID string
|
||
|
|
Name string
|
||
|
|
Type string
|
||
|
|
Browser string
|
||
|
|
OS string
|
||
|
|
AuthType string
|
||
|
|
AddedAt time.Time
|
||
|
|
LastUsed time.Time
|
||
|
|
IsCurrent bool
|
||
|
|
}
|
||
|
|
|
||
|
|
type OAuthScope struct {
|
||
|
|
Name string
|
||
|
|
Description string
|
||
|
|
Enabled bool
|
||
|
|
Required bool
|
||
|
|
}
|
||
|
|
|
||
|
|
type AuthorizedClient struct {
|
||
|
|
ID string
|
||
|
|
Name string
|
||
|
|
Domain string
|
||
|
|
Initials string
|
||
|
|
Color string
|
||
|
|
Status string
|
||
|
|
}
|
||
|
|
|
||
|
|
type OAuthSettings struct {
|
||
|
|
DefaultScopes []OAuthScope
|
||
|
|
SessionDuration string
|
||
|
|
ConsentPrompt string
|
||
|
|
Clients []AuthorizedClient
|
||
|
|
}
|
||
|
|
|
||
|
|
type NotificationItem struct {
|
||
|
|
Key string
|
||
|
|
Title string
|
||
|
|
Description string
|
||
|
|
Enabled bool
|
||
|
|
Threshold int
|
||
|
|
}
|
||
|
|
|
||
|
|
type NotificationPrefs struct {
|
||
|
|
SecurityAlerts []NotificationItem
|
||
|
|
Transactions []NotificationItem
|
||
|
|
Apps []NotificationItem
|
||
|
|
Marketing []NotificationItem
|
||
|
|
}
|
||
|
|
|
||
|
|
type Email struct {
|
||
|
|
ID string
|
||
|
|
Address string
|
||
|
|
IsPrimary bool
|
||
|
|
IsVerified bool
|
||
|
|
AddedAt time.Time
|
||
|
|
}
|
||
|
|
|
||
|
|
type Phone struct {
|
||
|
|
ID string
|
||
|
|
Number string
|
||
|
|
IsPrimary bool
|
||
|
|
IsVerified bool
|
||
|
|
AddedAt time.Time
|
||
|
|
Use2FA bool
|
||
|
|
}
|
||
|
|
|
||
|
|
type SMSSettings struct {
|
||
|
|
Enabled bool
|
||
|
|
RecoveryCodes bool
|
||
|
|
}
|
||
|
|
|
||
|
|
type APIKey struct {
|
||
|
|
ID string
|
||
|
|
Name string
|
||
|
|
KeyPreview string
|
||
|
|
KeyFull string
|
||
|
|
Environment string
|
||
|
|
Permissions string
|
||
|
|
Status string
|
||
|
|
CreatedAt time.Time
|
||
|
|
}
|
||
|
|
|
||
|
|
type Webhook struct {
|
||
|
|
ID string
|
||
|
|
URL string
|
||
|
|
Description string
|
||
|
|
Events []string
|
||
|
|
Status string
|
||
|
|
LastTriggered time.Time
|
||
|
|
FailureCount int
|
||
|
|
}
|
||
|
|
|
||
|
|
type OAuthAppConfig struct {
|
||
|
|
ClientID string
|
||
|
|
ClientSecret string
|
||
|
|
RedirectURIs []string
|
||
|
|
}
|
||
|
|
|
||
|
|
type DeveloperSettings struct {
|
||
|
|
APIKeys []APIKey
|
||
|
|
Webhooks []Webhook
|
||
|
|
OAuthApp OAuthAppConfig
|
||
|
|
DebugMode bool
|
||
|
|
TestMode bool
|
||
|
|
ShowRaw bool
|
||
|
|
}
|
||
|
|
|
||
|
|
type SettingsData struct {
|
||
|
|
Profile ProfileSettings
|
||
|
|
Devices []Device
|
||
|
|
OAuth OAuthSettings
|
||
|
|
Notifications NotificationPrefs
|
||
|
|
Emails []Email
|
||
|
|
Phones []Phone
|
||
|
|
SMSSettings SMSSettings
|
||
|
|
Developer DeveloperSettings
|
||
|
|
}
|
||
|
|
|
||
|
|
func DefaultSettingsData() SettingsData {
|
||
|
|
return SettingsData{
|
||
|
|
Profile: ProfileSettings{
|
||
|
|
Initials: "JD",
|
||
|
|
DisplayName: "John Doe",
|
||
|
|
Username: "johndoe",
|
||
|
|
Bio: "Web3 enthusiast and DeFi explorer. Building on Sonr.",
|
||
|
|
Website: "https://johndoe.dev",
|
||
|
|
Visibility: "public",
|
||
|
|
},
|
||
|
|
Devices: []Device{
|
||
|
|
{ID: "dev-1", Name: "MacBook Pro", Type: "laptop", Browser: "Chrome", OS: "macOS", AuthType: "Touch ID", AddedAt: time.Now().AddDate(0, 0, -20), LastUsed: time.Now(), IsCurrent: true},
|
||
|
|
{ID: "dev-2", Name: "iPhone 15 Pro", Type: "mobile", Browser: "Safari", OS: "iOS", AuthType: "Face ID", AddedAt: time.Now().AddDate(0, 0, -25), LastUsed: time.Now().Add(-2 * time.Hour), IsCurrent: false},
|
||
|
|
{ID: "dev-3", Name: "YubiKey 5C", Type: "key", Browser: "", OS: "", AuthType: "FIDO2", AddedAt: time.Now().AddDate(0, -1, -7), LastUsed: time.Now().AddDate(0, 0, -5), IsCurrent: false},
|
||
|
|
{ID: "dev-4", Name: "Windows Desktop", Type: "desktop", Browser: "Firefox", OS: "Windows", AuthType: "Windows Hello", AddedAt: time.Now().AddDate(0, -2, 0), LastUsed: time.Now().AddDate(0, 0, -14), IsCurrent: false},
|
||
|
|
},
|
||
|
|
OAuth: OAuthSettings{
|
||
|
|
DefaultScopes: []OAuthScope{
|
||
|
|
{Name: "openid", Description: "Basic identity information (required)", Enabled: true, Required: true},
|
||
|
|
{Name: "profile", Description: "Display name and avatar", Enabled: true, Required: false},
|
||
|
|
{Name: "email", Description: "Email address access", Enabled: false, Required: false},
|
||
|
|
{Name: "wallet:read", Description: "View wallet balances", Enabled: false, Required: false},
|
||
|
|
},
|
||
|
|
SessionDuration: "7d",
|
||
|
|
ConsentPrompt: "first",
|
||
|
|
Clients: []AuthorizedClient{
|
||
|
|
{ID: "client-1", Name: "Uniswap", Domain: "app.uniswap.org", Initials: "U", Color: "linear-gradient(135deg, #ff007a, #ff5ca0)", Status: "active"},
|
||
|
|
{ID: "client-2", Name: "OpenSea", Domain: "opensea.io", Initials: "O", Color: "linear-gradient(135deg, #627eea, #4c63d2)", Status: "idle"},
|
||
|
|
},
|
||
|
|
},
|
||
|
|
Notifications: NotificationPrefs{
|
||
|
|
SecurityAlerts: []NotificationItem{
|
||
|
|
{Key: "security.new_device", Title: "New device login", Description: "When your account is accessed from a new device", Enabled: true},
|
||
|
|
{Key: "security.suspicious", Title: "Suspicious activity", Description: "Unusual login attempts or access patterns", Enabled: true},
|
||
|
|
{Key: "security.password", Title: "Password changes", Description: "When security credentials are modified", Enabled: true},
|
||
|
|
},
|
||
|
|
Transactions: []NotificationItem{
|
||
|
|
{Key: "tx.incoming", Title: "Incoming transfers", Description: "When you receive tokens or NFTs", Enabled: true},
|
||
|
|
{Key: "tx.outgoing", Title: "Outgoing transfers", Description: "Confirmation of sent transactions", Enabled: true},
|
||
|
|
{Key: "tx.failed", Title: "Failed transactions", Description: "When a transaction fails or is reverted", Enabled: true},
|
||
|
|
{Key: "tx.large", Title: "Large transactions", Description: "Transactions above threshold", Enabled: true, Threshold: 1000},
|
||
|
|
},
|
||
|
|
Apps: []NotificationItem{
|
||
|
|
{Key: "app.connection", Title: "New app connections", Description: "When a new app connects to your wallet", Enabled: true},
|
||
|
|
{Key: "app.signature", Title: "Signature requests", Description: "When an app requests a signature", Enabled: true},
|
||
|
|
{Key: "app.permission", Title: "Permission changes", Description: "When app permissions are modified", Enabled: false},
|
||
|
|
},
|
||
|
|
Marketing: []NotificationItem{
|
||
|
|
{Key: "marketing.updates", Title: "Product updates", Description: "New features and improvements", Enabled: false},
|
||
|
|
{Key: "marketing.newsletter", Title: "Newsletter", Description: "Weekly digest of Sonr ecosystem news", Enabled: false},
|
||
|
|
},
|
||
|
|
},
|
||
|
|
Emails: []Email{
|
||
|
|
{ID: "email-1", Address: "john.doe@example.com", IsPrimary: true, IsVerified: true, AddedAt: time.Now().AddDate(0, 0, -20)},
|
||
|
|
{ID: "email-2", Address: "johndoe.work@company.io", IsPrimary: false, IsVerified: true, AddedAt: time.Now().AddDate(0, -1, -15)},
|
||
|
|
{ID: "email-3", Address: "backup@gmail.com", IsPrimary: false, IsVerified: false, AddedAt: time.Now().AddDate(0, 0, -2)},
|
||
|
|
},
|
||
|
|
Phones: []Phone{
|
||
|
|
{ID: "phone-1", Number: "+1 (555) 123-4567", IsPrimary: true, IsVerified: true, AddedAt: time.Now().AddDate(0, 0, -20), Use2FA: true},
|
||
|
|
{ID: "phone-2", Number: "+44 7700 900123", IsPrimary: false, IsVerified: true, AddedAt: time.Now().AddDate(0, -2, -10), Use2FA: false},
|
||
|
|
},
|
||
|
|
SMSSettings: SMSSettings{
|
||
|
|
Enabled: true,
|
||
|
|
RecoveryCodes: false,
|
||
|
|
},
|
||
|
|
Developer: DeveloperSettings{
|
||
|
|
APIKeys: []APIKey{
|
||
|
|
{ID: "key-1", Name: "Production Key", KeyPreview: "sk_live_••••••••••••••••••••••••3f8b", KeyFull: "sk_live_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d0e1f23f8b", Environment: "live", Permissions: "full", Status: "active", CreatedAt: time.Now().AddDate(0, 0, -35)},
|
||
|
|
{ID: "key-2", Name: "Test Key", KeyPreview: "sk_test_••••••••••••••••••••••••9a2c", KeyFull: "sk_test_z9y8x7w6v5u4t3s2r1q0p9o8n7m6l5k4j3i2h1g0f9e8d7c6b5a4z3y2x1w0v9u89a2c", Environment: "test", Permissions: "full", Status: "active", CreatedAt: time.Now().AddDate(0, 0, -35)},
|
||
|
|
},
|
||
|
|
Webhooks: []Webhook{
|
||
|
|
{ID: "wh-1", URL: "https://api.myapp.com/webhooks/sonr", Description: "Main webhook", Events: []string{"*"}, Status: "active", LastTriggered: time.Now().Add(-2 * time.Hour), FailureCount: 0},
|
||
|
|
{ID: "wh-2", URL: "https://hooks.slack.com/services/...", Description: "Slack notifications", Events: []string{"transaction.*"}, Status: "failing", LastTriggered: time.Now().Add(-1 * time.Hour), FailureCount: 3},
|
||
|
|
},
|
||
|
|
OAuthApp: OAuthAppConfig{
|
||
|
|
ClientID: "sonr_client_a1b2c3d4e5f6",
|
||
|
|
ClientSecret: "sonr_secret_x9y8z7w6v5u4t3s2r1",
|
||
|
|
RedirectURIs: []string{"https://myapp.com/auth/callback", "http://localhost:3000/auth/callback"},
|
||
|
|
},
|
||
|
|
DebugMode: false,
|
||
|
|
TestMode: true,
|
||
|
|
ShowRaw: false,
|
||
|
|
},
|
||
|
|
}
|
||
|
|
}
|