import type {SupportedBrowser} from './SupportedBrowser'; // Source: https://github.com/browserstack/api export class BrowserstackApi { private readonly _baseUrl: string = 'https://api.browserstack.com/5'; private readonly _authorizationHeader: string; constructor(username: string, accessKey: string) { this._authorizationHeader = `Basic ${Buffer.from(`${username}:${accessKey}`).toString('base64')}`; } public async getListOfSupportedBrowsers(): Promise { const requestPath = `${this._baseUrl}/browsers?flat=true`; const headers = { Authorization: this._authorizationHeader, 'Content-Type': 'application/json', Accept: 'application/json' }; const response = await fetch(requestPath, {headers}); if (!response.ok) { throw new Error(`Failed to fetch BrowserStack supported browsers due to [${response.statusText}]`); } return response.json() as Promise; } }