export interface IAuthConfig { client_id : string ; response_type : 'token' | string ; redirect_uri : string ; state : string ; show_dialog : boolean ; scope : SpotifyScope [ ] | string ; } export type SpotifyScope = 'ugc-image-upload' | 'user-read-playback-state' | 'user-modify-playback-state' | 'user-read-currently-playing' | 'streaming' | 'app-remote-control' | 'user-read-email' | 'user-read-private' | 'playlist-read-collaborative' | 'playlist-modify-public' | 'playlist-read-private' | 'playlist-modify-private' | 'user-library-modify' | 'user-library-read' | 'user-top-read' | 'user-read-recently-played' | 'user-follow-read' | 'user-follow-modify' ; const requestAuthUrl = 'https://accounts.spotify.com/authorize' ; export function buildAuthUrl ( config ) { let params = [ ] ; for ( const [ key , value ] of Object . entries ( config ) ) { let param ; if ( typeof value === 'object' ) { param = `${ key }=${ ( < string [ ] > value ) . join ( ' ' ) }` ; } else { param = `${ key }=${ value }` ; } params = [ ... params , param ] ; } return `${ requestAuthUrl }?${ params . join ( '&' ) }` ; }