Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function getEMSClient() {
if (!emsClient) {
const isEmsEnabled = chrome.getInjected('isEmsEnabled', true);
if (isEmsEnabled) {
const proxyElasticMapsServiceInMaps = chrome.getInjected('proxyElasticMapsServiceInMaps', false);
const proxyPath = proxyElasticMapsServiceInMaps ? relativeToAbsolute('..') : '';
const manifestServiceUrl = proxyElasticMapsServiceInMaps ? relativeToAbsolute(`${GIS_API_RELATIVE}/${EMS_CATALOGUE_PATH}`) : chrome.getInjected('emsManifestServiceUrl');
emsClient = new EMSClient({
language: i18n.getLocale(),
kbnVersion: chrome.getInjected('kbnPkgVersion'),
manifestServiceUrl: manifestServiceUrl,
landingPageUrl: chrome.getInjected('emsLandingPageUrl'),
fetchFunction: fetchFunction, //import this from client-side, so the right instance is returned (bootstrapped from common/* would not work
proxyPath: proxyPath
});
} else {
//EMS is turned off. Mock API.
emsClient = {
async getFileLayers() {
return [];
},
async getTMSServices() {
return [];
},