Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function getAvailableBundleIds (udid) {
const service = await services.startInstallationProxyService(udid);
try {
const applications = await service.listApplications({applicationType: 'User'});
const bundleIds = [];
for (const [key, value] of Object.entries(applications)) {
if (!value.UIFileSharingEnabled) {
continue;
}
bundleIds.push(key);
}
return bundleIds;
} finally {
service.close();
}
}
async isAppInstalled (bundleid) {
const service = await services.startInstallationProxyService(this.udid);
try {
const applications = await service.lookupApplications({ bundleIds: bundleid });
return !!applications[bundleid];
} finally {
service.close();
}
}
async remove (bundleid) {
const service = await services.startInstallationProxyService(this.udid);
try {
await service.uninstallApplication(bundleid);
} finally {
service.close();
}
}
async installApplication (bundlePathOnPhone) {
const notificationService = await services.startNotificationProxyService(this.udid);
const installationService = await services.startInstallationProxyService(this.udid);
const appInstalledNotification = new B((resolve) => {
notificationService.observeNotification(APPLICATION_INSTALLED_NOTIFICATION, {notification: resolve});
});
try {
await installationService.installApplication(bundlePathOnPhone, {PackageType: 'Developer'});
try {
await appInstalledNotification.timeout(APPLICATION_NOTIFICATION_TIMEOUT, `Could not get the application installed notification within ${APPLICATION_NOTIFICATION_TIMEOUT}ms but we will continue`);
} catch (e) {
log.warn(`Failed to receive the notification. Error: ${e.message}`);
}
} finally {
installationService.close();
notificationService.close();
}
}
async getUserInstalledBundleIdsByBundleName (bundleName) {
const service = await services.startInstallationProxyService(this.udid);
try {
const applications = await service.listApplications({applicationType: 'User'});
return _.reduce(applications, (acc, {CFBundleName}, key) => {
if (CFBundleName === bundleName) {
acc.push(key);
}
return acc;
}, []);
} finally {
service.close();
}
}