mirror of
https://github.com/gesellix/Bose-SoundTouch.git
synced 2026-08-18 08:36:13 +00:00
Use a constant prefix for our internal token
This commit is contained in:
@@ -139,8 +139,8 @@ func TestSpotifyBridge(t *testing.T) {
|
||||
t.Fatal("Could not find surrogate token in Marge sources")
|
||||
}
|
||||
|
||||
if len(surrogate) != 32 {
|
||||
t.Errorf("Expected surrogate to be 32 hex chars, got %s", surrogate)
|
||||
if !strings.HasPrefix(surrogate, "bs-") || len(surrogate) != 35 {
|
||||
t.Errorf("Expected surrogate to have 'bs-' prefix and be 35 chars, got %s", surrogate)
|
||||
}
|
||||
|
||||
// Request refresh
|
||||
|
||||
@@ -350,13 +350,15 @@ func (s *Service) GetAccountBySecret(secret string) (*Account, bool) {
|
||||
}
|
||||
|
||||
func (s *Service) generateBoseSecret() string {
|
||||
prefix := "bs-"
|
||||
|
||||
b := make([]byte, 16)
|
||||
if _, err := rand.Read(b); err != nil {
|
||||
// Fallback to timestamp-based if RNG fails
|
||||
return fmt.Sprintf("bs-%d", time.Now().UnixNano())
|
||||
return fmt.Sprintf("%s%d", prefix, time.Now().UnixNano())
|
||||
}
|
||||
|
||||
return hex.EncodeToString(b)
|
||||
return prefix + hex.EncodeToString(b)
|
||||
}
|
||||
|
||||
// ResolveEntity resolves a Spotify URI to a name and image URL.
|
||||
|
||||
Reference in New Issue
Block a user