@expo/cli 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bin/cli +89 -4
- package/build/bin/cli.map +1 -1
- package/build/src/api/rest/wrapFetchWithOffline.js +2 -23
- package/build/src/api/rest/wrapFetchWithOffline.js.map +1 -1
- package/build/src/customize/customizeAsync.js +40 -0
- package/build/src/customize/customizeAsync.js.map +1 -0
- package/build/src/customize/generate.js +77 -0
- package/build/src/customize/generate.js.map +1 -0
- package/build/src/customize/index.js +41 -0
- package/build/src/customize/index.js.map +1 -0
- package/build/src/customize/resolveOptions.js +18 -0
- package/build/src/customize/resolveOptions.js.map +1 -0
- package/build/src/customize/templates.js +118 -0
- package/build/src/customize/templates.js.map +1 -0
- package/build/src/export/createMetadataJson.js +10 -7
- package/build/src/export/createMetadataJson.js.map +1 -1
- package/build/src/export/exportApp.js +32 -0
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportAssets.js +2 -3
- package/build/src/export/exportAssets.js.map +1 -1
- package/build/src/export/fork-bundleAsync.js +51 -34
- package/build/src/export/fork-bundleAsync.js.map +1 -1
- package/build/src/export/index.js +15 -10
- package/build/src/export/index.js.map +1 -1
- package/build/src/export/printBundleSizes.js +27 -48
- package/build/src/export/printBundleSizes.js.map +1 -1
- package/build/src/export/resolveOptions.js +44 -5
- package/build/src/export/resolveOptions.js.map +1 -1
- package/build/src/export/saveAssets.js +2 -1
- package/build/src/export/saveAssets.js.map +1 -1
- package/build/src/export/web/exportWebAsync.js +37 -0
- package/build/src/export/web/exportWebAsync.js.map +1 -0
- package/build/src/export/web/index.js +66 -0
- package/build/src/export/web/index.js.map +1 -0
- package/build/src/export/web/resolveOptions.js +13 -0
- package/build/src/export/web/resolveOptions.js.map +1 -0
- package/build/src/export/writeContents.js.map +1 -1
- package/build/src/install/checkPackages.js +2 -1
- package/build/src/install/checkPackages.js.map +1 -1
- package/build/src/install/index.js +1 -0
- package/build/src/install/index.js.map +1 -1
- package/build/src/install/installAsync.js +13 -5
- package/build/src/install/installAsync.js.map +1 -1
- package/build/src/install/resolveOptions.js +12 -65
- package/build/src/install/resolveOptions.js.map +1 -1
- package/build/src/install/utils/autoAddConfigPlugins.js +5 -26
- package/build/src/install/utils/autoAddConfigPlugins.js.map +1 -1
- package/build/src/log.js.map +1 -1
- package/build/src/prebuild/copyTemplateFiles.js +5 -23
- package/build/src/prebuild/copyTemplateFiles.js.map +1 -1
- package/build/src/prebuild/index.js +18 -12
- package/build/src/prebuild/index.js.map +1 -1
- package/build/src/prebuild/prebuildAsync.js +11 -12
- package/build/src/prebuild/prebuildAsync.js.map +1 -1
- package/build/src/prebuild/resolveOptions.js +17 -0
- package/build/src/prebuild/resolveOptions.js.map +1 -1
- package/build/src/prebuild/resolveTemplate.js +2 -1
- package/build/src/prebuild/resolveTemplate.js.map +1 -1
- package/build/src/prebuild/updatePackageJson.js +5 -5
- package/build/src/prebuild/updatePackageJson.js.map +1 -1
- package/build/src/run/android/resolveInstallApkName.js +5 -26
- package/build/src/run/android/resolveInstallApkName.js.map +1 -1
- package/build/src/run/android/runAndroidAsync.js +3 -3
- package/build/src/run/android/runAndroidAsync.js.map +1 -1
- package/build/src/run/ensureNativeProject.js +3 -0
- package/build/src/run/ensureNativeProject.js.map +1 -1
- package/build/src/run/hints.js +1 -1
- package/build/src/run/hints.js.map +1 -1
- package/build/src/run/ios/XcodeBuild.js +275 -0
- package/build/src/run/ios/XcodeBuild.js.map +1 -0
- package/build/src/run/ios/XcodeBuild.types.js +6 -0
- package/build/src/run/ios/XcodeBuild.types.js.map +1 -0
- package/build/src/run/ios/appleDevice/AppleDevice.js +161 -0
- package/build/src/run/ios/appleDevice/AppleDevice.js.map +1 -0
- package/build/src/run/ios/appleDevice/ClientManager.js +161 -0
- package/build/src/run/ios/appleDevice/ClientManager.js.map +1 -0
- package/build/src/run/ios/appleDevice/client/AFCClient.js +195 -0
- package/build/src/run/ios/appleDevice/client/AFCClient.js.map +1 -0
- package/build/src/run/ios/appleDevice/client/DebugserverClient.js +107 -0
- package/build/src/run/ios/appleDevice/client/DebugserverClient.js.map +1 -0
- package/build/src/run/ios/appleDevice/client/InstallationProxyClient.js +97 -0
- package/build/src/run/ios/appleDevice/client/InstallationProxyClient.js.map +1 -0
- package/build/src/run/ios/appleDevice/client/LockdowndClient.js +140 -0
- package/build/src/run/ios/appleDevice/client/LockdowndClient.js.map +1 -0
- package/build/src/run/ios/appleDevice/client/MobileImageMounterClient.js +91 -0
- package/build/src/run/ios/appleDevice/client/MobileImageMounterClient.js.map +1 -0
- package/build/src/run/ios/appleDevice/client/ServiceClient.js +21 -0
- package/build/src/run/ios/appleDevice/client/ServiceClient.js.map +1 -0
- package/build/src/run/ios/appleDevice/client/UsbmuxdClient.js +117 -0
- package/build/src/run/ios/appleDevice/client/UsbmuxdClient.js.map +1 -0
- package/build/src/run/ios/appleDevice/installOnDeviceAsync.js +90 -0
- package/build/src/run/ios/appleDevice/installOnDeviceAsync.js.map +1 -0
- package/build/src/run/ios/appleDevice/protocol/AFCProtocol.js +332 -0
- package/build/src/run/ios/appleDevice/protocol/AFCProtocol.js.map +1 -0
- package/build/src/run/ios/appleDevice/protocol/AbstractProtocol.js +115 -0
- package/build/src/run/ios/appleDevice/protocol/AbstractProtocol.js.map +1 -0
- package/build/src/run/ios/appleDevice/protocol/GDBProtocol.js +126 -0
- package/build/src/run/ios/appleDevice/protocol/GDBProtocol.js.map +1 -0
- package/build/src/run/ios/appleDevice/protocol/LockdownProtocol.js +74 -0
- package/build/src/run/ios/appleDevice/protocol/LockdownProtocol.js.map +1 -0
- package/build/src/run/ios/appleDevice/protocol/UsbmuxProtocol.js +65 -0
- package/build/src/run/ios/appleDevice/protocol/UsbmuxProtocol.js.map +1 -0
- package/build/src/run/ios/codeSigning/Security.js +85 -0
- package/build/src/run/ios/codeSigning/Security.js.map +1 -0
- package/build/src/run/ios/codeSigning/configureCodeSigning.js +77 -0
- package/build/src/run/ios/codeSigning/configureCodeSigning.js.map +1 -0
- package/build/src/run/ios/codeSigning/resolveCertificateSigningIdentity.js +102 -0
- package/build/src/run/ios/codeSigning/resolveCertificateSigningIdentity.js.map +1 -0
- package/build/src/run/ios/codeSigning/settings.js +21 -0
- package/build/src/run/ios/codeSigning/settings.js.map +1 -0
- package/build/src/run/ios/codeSigning/xcodeCodeSigning.js +76 -0
- package/build/src/run/ios/codeSigning/xcodeCodeSigning.js.map +1 -0
- package/build/src/run/ios/index.js +98 -0
- package/build/src/run/ios/index.js.map +1 -0
- package/build/src/run/ios/launchApp.js +75 -0
- package/build/src/run/ios/launchApp.js.map +1 -0
- package/build/src/run/ios/options/promptDevice.js +50 -0
- package/build/src/run/ios/options/promptDevice.js.map +1 -0
- package/build/src/run/ios/options/resolveDevice.js +92 -0
- package/build/src/run/ios/options/resolveDevice.js.map +1 -0
- package/build/src/run/ios/options/resolveNativeScheme.js +92 -0
- package/build/src/run/ios/options/resolveNativeScheme.js.map +1 -0
- package/build/src/run/ios/options/resolveOptions.js +44 -0
- package/build/src/run/ios/options/resolveOptions.js.map +1 -0
- package/build/src/run/ios/options/resolveXcodeProject.js +39 -0
- package/build/src/run/ios/options/resolveXcodeProject.js.map +1 -0
- package/build/src/run/ios/runIosAsync.js +85 -0
- package/build/src/run/ios/runIosAsync.js.map +1 -0
- package/build/src/run/resolveBundlerProps.js +9 -6
- package/build/src/run/resolveBundlerProps.js.map +1 -1
- package/build/src/run/startBundler.js +4 -2
- package/build/src/run/startBundler.js.map +1 -1
- package/build/src/start/doctor/Prerequisite.js +4 -4
- package/build/src/start/doctor/Prerequisite.js.map +1 -1
- package/build/src/start/doctor/SecurityBinPrerequisite.js +27 -0
- package/build/src/start/doctor/SecurityBinPrerequisite.js.map +1 -0
- package/build/src/start/doctor/apple/SimulatorAppPrerequisite.js +2 -0
- package/build/src/start/doctor/apple/SimulatorAppPrerequisite.js.map +1 -1
- package/build/src/start/doctor/apple/XcodeDeveloperDiskImagePrerequisite.js +69 -0
- package/build/src/start/doctor/apple/XcodeDeveloperDiskImagePrerequisite.js.map +1 -0
- package/build/src/start/doctor/apple/XcodePrerequisite.js +2 -0
- package/build/src/start/doctor/apple/XcodePrerequisite.js.map +1 -1
- package/build/src/start/doctor/dependencies/bundledNativeModules.js +3 -2
- package/build/src/start/doctor/dependencies/bundledNativeModules.js.map +1 -1
- package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js +7 -13
- package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js.map +1 -1
- package/build/src/start/doctor/dependencies/getMissingPackages.js +3 -24
- package/build/src/start/doctor/dependencies/getMissingPackages.js.map +1 -1
- package/build/src/start/doctor/dependencies/getVersionedPackages.js +2 -23
- package/build/src/start/doctor/dependencies/getVersionedPackages.js.map +1 -1
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +17 -9
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
- package/build/src/start/doctor/ngrok/ExternalModule.js +2 -1
- package/build/src/start/doctor/ngrok/ExternalModule.js.map +1 -1
- package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js +4 -3
- package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js.map +1 -1
- package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js +32 -31
- package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js.map +1 -1
- package/build/src/start/interface/KeyPressHandler.js +2 -0
- package/build/src/start/interface/KeyPressHandler.js.map +1 -1
- package/build/src/start/interface/interactiveActions.js +5 -5
- package/build/src/start/interface/interactiveActions.js.map +1 -1
- package/build/src/start/interface/startInterface.js +3 -2
- package/build/src/start/interface/startInterface.js.map +1 -1
- package/build/src/start/platforms/ExpoGoInstaller.js +2 -1
- package/build/src/start/platforms/ExpoGoInstaller.js.map +1 -1
- package/build/src/start/platforms/PlatformManager.js +4 -24
- package/build/src/start/platforms/PlatformManager.js.map +1 -1
- package/build/src/start/platforms/android/ADBServer.js +17 -32
- package/build/src/start/platforms/android/ADBServer.js.map +1 -1
- package/build/src/start/platforms/android/AndroidSdk.js +41 -0
- package/build/src/start/platforms/android/AndroidSdk.js.map +1 -0
- package/build/src/start/platforms/android/activateWindow.js +4 -4
- package/build/src/start/platforms/android/activateWindow.js.map +1 -1
- package/build/src/start/platforms/android/adb.js +8 -3
- package/build/src/start/platforms/android/adb.js.map +1 -1
- package/build/src/start/platforms/android/adbReverse.js +3 -2
- package/build/src/start/platforms/android/adbReverse.js.map +1 -1
- package/build/src/start/platforms/android/emulator.js +8 -0
- package/build/src/start/platforms/android/emulator.js.map +1 -1
- package/build/src/start/platforms/android/gradle.js +2 -2
- package/build/src/start/platforms/android/gradle.js.map +1 -1
- package/build/src/start/platforms/android/promptAndroidDevice.js +1 -5
- package/build/src/start/platforms/android/promptAndroidDevice.js.map +1 -1
- package/build/src/start/platforms/ios/AppleDeviceManager.js +5 -1
- package/build/src/start/platforms/ios/AppleDeviceManager.js.map +1 -1
- package/build/src/start/platforms/ios/getBestSimulator.js +4 -4
- package/build/src/start/platforms/ios/getBestSimulator.js.map +1 -1
- package/build/src/start/platforms/ios/promptAppleDevice.js +1 -5
- package/build/src/start/platforms/ios/promptAppleDevice.js.map +1 -1
- package/build/src/start/platforms/ios/simctl.js +14 -0
- package/build/src/start/platforms/ios/simctl.js.map +1 -1
- package/build/src/start/platforms/ios/simctlLogging.js +220 -0
- package/build/src/start/platforms/ios/simctlLogging.js.map +1 -0
- package/build/src/start/platforms/ios/xcrun.js +2 -23
- package/build/src/start/platforms/ios/xcrun.js.map +1 -1
- package/build/src/start/project/devices.js +2 -0
- package/build/src/start/project/devices.js.map +1 -1
- package/build/src/start/server/AsyncNgrok.js +6 -5
- package/build/src/start/server/AsyncNgrok.js.map +1 -1
- package/build/src/start/server/BundlerDevServer.js +15 -8
- package/build/src/start/server/BundlerDevServer.js.map +1 -1
- package/build/src/start/server/DevServerManager.js +15 -5
- package/build/src/start/server/DevServerManager.js.map +1 -1
- package/build/src/start/server/DevelopmentSession.js +4 -0
- package/build/src/start/server/DevelopmentSession.js.map +1 -1
- package/build/src/start/server/UrlCreator.js +10 -3
- package/build/src/start/server/UrlCreator.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +9 -0
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/TerminalReporter.js +5 -0
- package/build/src/start/server/metro/TerminalReporter.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +11 -1
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/resolveFromProject.js +8 -0
- package/build/src/start/server/metro/resolveFromProject.js.map +1 -1
- package/build/src/start/server/metro/withMetroMultiPlatform.js +115 -0
- package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -0
- package/build/src/start/server/middleware/ClassicManifestMiddleware.js +1 -1
- package/build/src/start/server/middleware/ExpoMiddleware.js +9 -4
- package/build/src/start/server/middleware/ExpoMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/HistoryFallbackMiddleware.js +24 -0
- package/build/src/start/server/middleware/HistoryFallbackMiddleware.js.map +1 -0
- package/build/src/start/server/middleware/InterstitialPageMiddleware.js +2 -0
- package/build/src/start/server/middleware/InterstitialPageMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ManifestMiddleware.js +57 -6
- package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js +6 -1
- package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ServeStaticMiddleware.js +62 -0
- package/build/src/start/server/middleware/ServeStaticMiddleware.js.map +1 -0
- package/build/src/start/server/platformBundlers.js +18 -0
- package/build/src/start/server/platformBundlers.js.map +1 -0
- package/build/src/start/server/webTemplate.js +68 -0
- package/build/src/start/server/webTemplate.js.map +1 -0
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js +59 -19
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js.map +1 -1
- package/build/src/start/server/webpack/compile.js +64 -0
- package/build/src/start/server/webpack/compile.js.map +1 -0
- package/build/src/start/startAsync.js +21 -17
- package/build/src/start/startAsync.js.map +1 -1
- package/build/src/utils/FileNotifier.js +5 -2
- package/build/src/utils/FileNotifier.js.map +1 -1
- package/build/src/utils/analytics/rudderstackClient.js +30 -3
- package/build/src/utils/analytics/rudderstackClient.js.map +1 -1
- package/build/src/utils/cocoapods.js +47 -0
- package/build/src/utils/cocoapods.js.map +1 -1
- package/build/src/utils/dir.js +6 -1
- package/build/src/utils/dir.js.map +1 -1
- package/build/src/utils/downloadAppAsync.js +3 -2
- package/build/src/utils/downloadAppAsync.js.map +1 -1
- package/build/src/utils/downloadExpoGoAsync.js +7 -32
- package/build/src/utils/downloadExpoGoAsync.js.map +1 -1
- package/build/src/utils/editor.js +3 -2
- package/build/src/utils/editor.js.map +1 -1
- package/build/src/utils/env.js +3 -0
- package/build/src/utils/env.js.map +1 -1
- package/build/src/utils/exit.js +4 -25
- package/build/src/utils/exit.js.map +1 -1
- package/build/src/utils/getRunningProcess.js +6 -2
- package/build/src/utils/getRunningProcess.js.map +1 -1
- package/build/src/utils/nodeModules.js +13 -102
- package/build/src/utils/nodeModules.js.map +1 -1
- package/build/src/utils/npm.js +3 -24
- package/build/src/utils/npm.js.map +1 -1
- package/build/src/utils/ora.js +1 -13
- package/build/src/utils/ora.js.map +1 -1
- package/build/src/utils/plist.js +59 -0
- package/build/src/utils/plist.js.map +1 -0
- package/build/src/utils/progress.js +46 -0
- package/build/src/utils/progress.js.map +1 -1
- package/build/src/utils/prompts.js +19 -3
- package/build/src/utils/prompts.js.map +1 -1
- package/build/src/utils/resolveArgs.js +4 -1
- package/build/src/utils/resolveArgs.js.map +1 -1
- package/build/src/utils/tar.js +3 -0
- package/build/src/utils/tar.js.map +1 -1
- package/build/src/utils/terminal.js +10 -0
- package/build/src/utils/terminal.js.map +1 -0
- package/build/src/utils/validateApplicationId.js +9 -2
- package/build/src/utils/validateApplicationId.js.map +1 -1
- package/build/src/utils/variadic.js +47 -0
- package/build/src/utils/variadic.js.map +1 -0
- package/package.json +14 -10
- package/static/template/babel.config.js +6 -0
- package/static/template/index.html +117 -0
- package/static/template/metro.config.js +4 -0
- package/static/template/serve.json +13 -0
- package/static/template/webpack.config.js +7 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
var _stream = require("stream");
|
|
6
|
+
var tls = _interopRequireWildcard(require("tls"));
|
|
7
|
+
var _errors = require("../../../utils/errors");
|
|
8
|
+
var _afcclient = require("./client/AFCClient");
|
|
9
|
+
var _debugserverClient = require("./client/DebugserverClient");
|
|
10
|
+
var _installationProxyClient = require("./client/InstallationProxyClient");
|
|
11
|
+
var _lockdowndClient = require("./client/LockdowndClient");
|
|
12
|
+
var _mobileImageMounterClient = require("./client/MobileImageMounterClient");
|
|
13
|
+
var _usbmuxdClient = require("./client/UsbmuxdClient");
|
|
14
|
+
function _interopRequireWildcard(obj) {
|
|
15
|
+
if (obj && obj.__esModule) {
|
|
16
|
+
return obj;
|
|
17
|
+
} else {
|
|
18
|
+
var newObj = {};
|
|
19
|
+
if (obj != null) {
|
|
20
|
+
for(var key in obj){
|
|
21
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
22
|
+
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
|
|
23
|
+
if (desc.get || desc.set) {
|
|
24
|
+
Object.defineProperty(newObj, key, desc);
|
|
25
|
+
} else {
|
|
26
|
+
newObj[key] = obj[key];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
newObj.default = obj;
|
|
32
|
+
return newObj;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
class ClientManager {
|
|
36
|
+
constructor(pairRecord, device, lockdowndClient){
|
|
37
|
+
this.pairRecord = pairRecord;
|
|
38
|
+
this.device = device;
|
|
39
|
+
this.lockdowndClient = lockdowndClient;
|
|
40
|
+
this.connections = [
|
|
41
|
+
lockdowndClient.socket
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
static async create(udid) {
|
|
45
|
+
const usbmuxClient = new _usbmuxdClient.UsbmuxdClient(_usbmuxdClient.UsbmuxdClient.connectUsbmuxdSocket());
|
|
46
|
+
const device = await usbmuxClient.getDevice(udid);
|
|
47
|
+
const pairRecord = await usbmuxClient.readPairRecord(device.Properties.SerialNumber);
|
|
48
|
+
const lockdownSocket = await usbmuxClient.connect(device, 62078);
|
|
49
|
+
const lockdownClient = new _lockdowndClient.LockdowndClient(lockdownSocket);
|
|
50
|
+
await lockdownClient.doHandshake(pairRecord);
|
|
51
|
+
return new ClientManager(pairRecord, device, lockdownClient);
|
|
52
|
+
}
|
|
53
|
+
async getUsbmuxdClient() {
|
|
54
|
+
const usbmuxClient = new _usbmuxdClient.UsbmuxdClient(_usbmuxdClient.UsbmuxdClient.connectUsbmuxdSocket());
|
|
55
|
+
this.connections.push(usbmuxClient.socket);
|
|
56
|
+
return usbmuxClient;
|
|
57
|
+
}
|
|
58
|
+
async getLockdowndClient() {
|
|
59
|
+
const usbmuxClient = new _usbmuxdClient.UsbmuxdClient(_usbmuxdClient.UsbmuxdClient.connectUsbmuxdSocket());
|
|
60
|
+
const lockdownSocket = await usbmuxClient.connect(this.device, 62078);
|
|
61
|
+
const lockdownClient = new _lockdowndClient.LockdowndClient(lockdownSocket);
|
|
62
|
+
this.connections.push(lockdownClient.socket);
|
|
63
|
+
return lockdownClient;
|
|
64
|
+
}
|
|
65
|
+
async getLockdowndClientWithHandshake() {
|
|
66
|
+
const lockdownClient = await this.getLockdowndClient();
|
|
67
|
+
await lockdownClient.doHandshake(this.pairRecord);
|
|
68
|
+
return lockdownClient;
|
|
69
|
+
}
|
|
70
|
+
async getAFCClient() {
|
|
71
|
+
return this.getServiceClient("com.apple.afc", _afcclient.AFCClient);
|
|
72
|
+
}
|
|
73
|
+
async getInstallationProxyClient() {
|
|
74
|
+
return this.getServiceClient("com.apple.mobile.installation_proxy", _installationProxyClient.InstallationProxyClient);
|
|
75
|
+
}
|
|
76
|
+
async getMobileImageMounterClient() {
|
|
77
|
+
return this.getServiceClient("com.apple.mobile.mobile_image_mounter", _mobileImageMounterClient.MobileImageMounterClient);
|
|
78
|
+
}
|
|
79
|
+
async getDebugserverClient() {
|
|
80
|
+
try {
|
|
81
|
+
// iOS 14 added support for a secure debug service so try to connect to that first
|
|
82
|
+
return await this.getServiceClient("com.apple.debugserver.DVTSecureSocketProxy", _debugserverClient.DebugserverClient);
|
|
83
|
+
} catch {
|
|
84
|
+
// otherwise, fall back to the previous implementation
|
|
85
|
+
return this.getServiceClient("com.apple.debugserver", _debugserverClient.DebugserverClient, true);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
async getServiceClient(name, ServiceType, disableSSL = false) {
|
|
89
|
+
const { port: servicePort , enableServiceSSL } = await this.lockdowndClient.startService(name);
|
|
90
|
+
const usbmuxClient = new _usbmuxdClient.UsbmuxdClient(_usbmuxdClient.UsbmuxdClient.connectUsbmuxdSocket());
|
|
91
|
+
let usbmuxdSocket = await usbmuxClient.connect(this.device, servicePort);
|
|
92
|
+
if (enableServiceSSL) {
|
|
93
|
+
const tlsOptions = {
|
|
94
|
+
rejectUnauthorized: false,
|
|
95
|
+
secureContext: tls.createSecureContext({
|
|
96
|
+
secureProtocol: "TLSv1_method",
|
|
97
|
+
cert: this.pairRecord.RootCertificate,
|
|
98
|
+
key: this.pairRecord.RootPrivateKey
|
|
99
|
+
})
|
|
100
|
+
};
|
|
101
|
+
// Some services seem to not support TLS/SSL after the initial handshake
|
|
102
|
+
// More info: https://github.com/libimobiledevice/libimobiledevice/issues/793
|
|
103
|
+
if (disableSSL) {
|
|
104
|
+
// According to https://nodejs.org/api/tls.html#tls_tls_connect_options_callback we can
|
|
105
|
+
// pass any Duplex in to tls.connect instead of a Socket. So we'll use our proxy to keep
|
|
106
|
+
// the TLS wrapper and underlying usbmuxd socket separate.
|
|
107
|
+
const proxy = new UsbmuxdProxy(usbmuxdSocket);
|
|
108
|
+
tlsOptions.socket = proxy;
|
|
109
|
+
await new Promise((resolve, reject)=>{
|
|
110
|
+
const timeoutId = setTimeout(()=>{
|
|
111
|
+
reject(new _errors.CommandError("APPLE_DEVICE", "The TLS handshake failed to complete after 5s."));
|
|
112
|
+
}, 5000);
|
|
113
|
+
tls.connect(tlsOptions, function() {
|
|
114
|
+
clearTimeout(timeoutId);
|
|
115
|
+
// After the handshake, we don't need TLS or the proxy anymore,
|
|
116
|
+
// since we'll just pass in the naked usbmuxd socket to the service client
|
|
117
|
+
this.destroy();
|
|
118
|
+
resolve();
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
} else {
|
|
122
|
+
tlsOptions.socket = usbmuxdSocket;
|
|
123
|
+
usbmuxdSocket = tls.connect(tlsOptions);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
const client = new ServiceType(usbmuxdSocket);
|
|
127
|
+
this.connections.push(client.socket);
|
|
128
|
+
return client;
|
|
129
|
+
}
|
|
130
|
+
end() {
|
|
131
|
+
for (const socket of this.connections){
|
|
132
|
+
// may already be closed
|
|
133
|
+
try {
|
|
134
|
+
socket.end();
|
|
135
|
+
} catch {}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.ClientManager = ClientManager;
|
|
140
|
+
class UsbmuxdProxy extends _stream.Duplex {
|
|
141
|
+
constructor(usbmuxdSock){
|
|
142
|
+
super();
|
|
143
|
+
this.usbmuxdSock = usbmuxdSock;
|
|
144
|
+
this.usbmuxdSock.on("data", (data)=>{
|
|
145
|
+
this.push(data);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
_write(chunk, encoding, callback) {
|
|
149
|
+
this.usbmuxdSock.write(chunk);
|
|
150
|
+
callback();
|
|
151
|
+
}
|
|
152
|
+
_read(size) {
|
|
153
|
+
// Stub so we don't error, since we push everything we get from usbmuxd as it comes in.
|
|
154
|
+
// TODO: better way to do this?
|
|
155
|
+
}
|
|
156
|
+
_destroy() {
|
|
157
|
+
this.usbmuxdSock.removeAllListeners();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
//# sourceMappingURL=ClientManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/run/ios/appleDevice/ClientManager.ts"],"sourcesContent":["/**\n * Copyright (c) 2021 Expo, Inc.\n * Copyright (c) 2018 Drifty Co.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { Socket } from 'net';\nimport { Duplex } from 'stream';\nimport * as tls from 'tls';\n\nimport { CommandError } from '../../../utils/errors';\nimport { AFCClient } from './client/AFCClient';\nimport { DebugserverClient } from './client/DebugserverClient';\nimport { InstallationProxyClient } from './client/InstallationProxyClient';\nimport { LockdowndClient } from './client/LockdowndClient';\nimport { MobileImageMounterClient } from './client/MobileImageMounterClient';\nimport { ServiceClient } from './client/ServiceClient';\nimport { UsbmuxdClient, UsbmuxdDevice, UsbmuxdPairRecord } from './client/UsbmuxdClient';\n\nexport class ClientManager {\n private connections: Socket[];\n constructor(\n public pairRecord: UsbmuxdPairRecord,\n public device: UsbmuxdDevice,\n private lockdowndClient: LockdowndClient\n ) {\n this.connections = [lockdowndClient.socket];\n }\n\n static async create(udid?: string) {\n const usbmuxClient = new UsbmuxdClient(UsbmuxdClient.connectUsbmuxdSocket());\n const device = await usbmuxClient.getDevice(udid);\n const pairRecord = await usbmuxClient.readPairRecord(device.Properties.SerialNumber);\n const lockdownSocket = await usbmuxClient.connect(device, 62078);\n const lockdownClient = new LockdowndClient(lockdownSocket);\n await lockdownClient.doHandshake(pairRecord);\n return new ClientManager(pairRecord, device, lockdownClient);\n }\n\n async getUsbmuxdClient() {\n const usbmuxClient = new UsbmuxdClient(UsbmuxdClient.connectUsbmuxdSocket());\n this.connections.push(usbmuxClient.socket);\n return usbmuxClient;\n }\n\n async getLockdowndClient() {\n const usbmuxClient = new UsbmuxdClient(UsbmuxdClient.connectUsbmuxdSocket());\n const lockdownSocket = await usbmuxClient.connect(this.device, 62078);\n const lockdownClient = new LockdowndClient(lockdownSocket);\n this.connections.push(lockdownClient.socket);\n return lockdownClient;\n }\n\n async getLockdowndClientWithHandshake() {\n const lockdownClient = await this.getLockdowndClient();\n await lockdownClient.doHandshake(this.pairRecord);\n return lockdownClient;\n }\n\n async getAFCClient() {\n return this.getServiceClient('com.apple.afc', AFCClient);\n }\n\n async getInstallationProxyClient() {\n return this.getServiceClient('com.apple.mobile.installation_proxy', InstallationProxyClient);\n }\n\n async getMobileImageMounterClient() {\n return this.getServiceClient('com.apple.mobile.mobile_image_mounter', MobileImageMounterClient);\n }\n\n async getDebugserverClient() {\n try {\n // iOS 14 added support for a secure debug service so try to connect to that first\n return await this.getServiceClient(\n 'com.apple.debugserver.DVTSecureSocketProxy',\n DebugserverClient\n );\n } catch {\n // otherwise, fall back to the previous implementation\n return this.getServiceClient('com.apple.debugserver', DebugserverClient, true);\n }\n }\n\n private async getServiceClient<T extends ServiceClient<any>>(\n name: string,\n ServiceType: new (...args: any[]) => T,\n disableSSL = false\n ) {\n const { port: servicePort, enableServiceSSL } = await this.lockdowndClient.startService(name);\n const usbmuxClient = new UsbmuxdClient(UsbmuxdClient.connectUsbmuxdSocket());\n let usbmuxdSocket = await usbmuxClient.connect(this.device, servicePort);\n\n if (enableServiceSSL) {\n const tlsOptions: tls.ConnectionOptions = {\n rejectUnauthorized: false,\n secureContext: tls.createSecureContext({\n secureProtocol: 'TLSv1_method',\n cert: this.pairRecord.RootCertificate,\n key: this.pairRecord.RootPrivateKey,\n }),\n };\n\n // Some services seem to not support TLS/SSL after the initial handshake\n // More info: https://github.com/libimobiledevice/libimobiledevice/issues/793\n if (disableSSL) {\n // According to https://nodejs.org/api/tls.html#tls_tls_connect_options_callback we can\n // pass any Duplex in to tls.connect instead of a Socket. So we'll use our proxy to keep\n // the TLS wrapper and underlying usbmuxd socket separate.\n const proxy: any = new UsbmuxdProxy(usbmuxdSocket);\n tlsOptions.socket = proxy;\n\n await new Promise<void>((resolve, reject) => {\n const timeoutId = setTimeout(() => {\n reject(\n new CommandError('APPLE_DEVICE', 'The TLS handshake failed to complete after 5s.')\n );\n }, 5000);\n tls.connect(tlsOptions, function (this: tls.TLSSocket) {\n clearTimeout(timeoutId);\n // After the handshake, we don't need TLS or the proxy anymore,\n // since we'll just pass in the naked usbmuxd socket to the service client\n this.destroy();\n resolve();\n });\n });\n } else {\n tlsOptions.socket = usbmuxdSocket;\n usbmuxdSocket = tls.connect(tlsOptions);\n }\n }\n const client = new ServiceType(usbmuxdSocket);\n this.connections.push(client.socket);\n return client;\n }\n\n end() {\n for (const socket of this.connections) {\n // may already be closed\n try {\n socket.end();\n } catch {}\n }\n }\n}\n\nclass UsbmuxdProxy extends Duplex {\n constructor(private usbmuxdSock: Socket) {\n super();\n\n this.usbmuxdSock.on('data', (data) => {\n this.push(data);\n });\n }\n\n _write(chunk: any, encoding: string, callback: (err?: Error) => void) {\n this.usbmuxdSock.write(chunk);\n callback();\n }\n\n _read(size: number) {\n // Stub so we don't error, since we push everything we get from usbmuxd as it comes in.\n // TODO: better way to do this?\n }\n\n _destroy() {\n this.usbmuxdSock.removeAllListeners();\n }\n}\n"],"names":["tls","ClientManager","constructor","pairRecord","device","lockdowndClient","connections","socket","create","udid","usbmuxClient","UsbmuxdClient","connectUsbmuxdSocket","getDevice","readPairRecord","Properties","SerialNumber","lockdownSocket","connect","lockdownClient","LockdowndClient","doHandshake","getUsbmuxdClient","push","getLockdowndClient","getLockdowndClientWithHandshake","getAFCClient","getServiceClient","AFCClient","getInstallationProxyClient","InstallationProxyClient","getMobileImageMounterClient","MobileImageMounterClient","getDebugserverClient","DebugserverClient","name","ServiceType","disableSSL","port","servicePort","enableServiceSSL","startService","usbmuxdSocket","tlsOptions","rejectUnauthorized","secureContext","createSecureContext","secureProtocol","cert","RootCertificate","key","RootPrivateKey","proxy","UsbmuxdProxy","Promise","resolve","reject","timeoutId","setTimeout","CommandError","clearTimeout","destroy","client","end","Duplex","usbmuxdSock","on","data","_write","chunk","encoding","callback","write","_read","size","_destroy","removeAllListeners"],"mappings":"AAOA;;;;AACuB,IAAA,OAAQ,WAAR,QAAQ,CAAA;AACnBA,IAAAA,GAAG,mCAAM,KAAK,EAAX;AAEc,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AAC1B,IAAA,UAAoB,WAApB,oBAAoB,CAAA;AACZ,IAAA,kBAA4B,WAA5B,4BAA4B,CAAA;AACtB,IAAA,wBAAkC,WAAlC,kCAAkC,CAAA;AAC1C,IAAA,gBAA0B,WAA1B,0BAA0B,CAAA;AACjB,IAAA,yBAAmC,WAAnC,mCAAmC,CAAA;AAEZ,IAAA,cAAwB,WAAxB,wBAAwB,CAAA;;;;;;;;;;;;;;;;;;;;;;AAEjF,MAAMC,aAAa;IAExBC,YACSC,UAA6B,EAC7BC,MAAqB,EACpBC,eAAgC,CACxC;aAHOF,UAA6B,GAA7BA,UAA6B;aAC7BC,MAAqB,GAArBA,MAAqB;aACpBC,eAAgC,GAAhCA,eAAgC;QAExC,IAAI,CAACC,WAAW,GAAG;YAACD,eAAe,CAACE,MAAM;SAAC,CAAC;KAC7C;IAED,aAAaC,MAAM,CAACC,IAAa,EAAE;QACjC,MAAMC,YAAY,GAAG,IAAIC,cAAa,cAAA,CAACA,cAAa,cAAA,CAACC,oBAAoB,EAAE,CAAC,AAAC;QAC7E,MAAMR,MAAM,GAAG,MAAMM,YAAY,CAACG,SAAS,CAACJ,IAAI,CAAC,AAAC;QAClD,MAAMN,UAAU,GAAG,MAAMO,YAAY,CAACI,cAAc,CAACV,MAAM,CAACW,UAAU,CAACC,YAAY,CAAC,AAAC;QACrF,MAAMC,cAAc,GAAG,MAAMP,Y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EAAE,CAAC;aADUA,WAAmB,GAAnBA,WAAmB;QAGrC,IAAI,CAACA,WAAW,CAACC,EAAE,CAAC,MAAM,EAAE,CAACC,IAAI,GAAK;YACpC,IAAI,CAAC5C,IAAI,CAAC4C,IAAI,CAAC,CAAC;SACjB,CAAC,CAAC;KACJ;IAEDC,MAAM,CAACC,KAAU,EAAEC,QAAgB,EAAEC,QAA+B,EAAE;QACpE,IAAI,CAACN,WAAW,CAACO,KAAK,CAACH,KAAK,CAAC,CAAC;QAC9BE,QAAQ,EAAE,CAAC;KACZ;IAEDE,KAAK,CAACC,IAAY,EAAE;IAClB,uFAAuF;IACvF,+BAA+B;KAChC;IAEDC,QAAQ,GAAG;QACT,IAAI,CAACV,WAAW,CAACW,kBAAkB,EAAE,CAAC;KACvC;CACF"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
6
|
+
var fs = _interopRequireWildcard(require("fs"));
|
|
7
|
+
var path = _interopRequireWildcard(require("path"));
|
|
8
|
+
var _util = require("util");
|
|
9
|
+
var _errors = require("../../../../utils/errors");
|
|
10
|
+
var _afcprotocol = require("../protocol/AFCProtocol");
|
|
11
|
+
var _serviceClient = require("./ServiceClient");
|
|
12
|
+
function _interopRequireDefault(obj) {
|
|
13
|
+
return obj && obj.__esModule ? obj : {
|
|
14
|
+
default: obj
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function _interopRequireWildcard(obj) {
|
|
18
|
+
if (obj && obj.__esModule) {
|
|
19
|
+
return obj;
|
|
20
|
+
} else {
|
|
21
|
+
var newObj = {};
|
|
22
|
+
if (obj != null) {
|
|
23
|
+
for(var key in obj){
|
|
24
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
25
|
+
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
|
|
26
|
+
if (desc.get || desc.set) {
|
|
27
|
+
Object.defineProperty(newObj, key, desc);
|
|
28
|
+
} else {
|
|
29
|
+
newObj[key] = obj[key];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
newObj.default = obj;
|
|
35
|
+
return newObj;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const debug = (0, _debug).default("expo:apple-device:client:afc");
|
|
39
|
+
const MAX_OPEN_FILES = 240;
|
|
40
|
+
class AFCClient extends _serviceClient.ServiceClient {
|
|
41
|
+
constructor(socket){
|
|
42
|
+
super(socket, new _afcprotocol.AFCProtocolClient(socket));
|
|
43
|
+
this.socket = socket;
|
|
44
|
+
}
|
|
45
|
+
async getFileInfo(path1) {
|
|
46
|
+
debug(`getFileInfo: ${path1}`);
|
|
47
|
+
const response = await this.protocolClient.sendMessage({
|
|
48
|
+
operation: _afcprotocol.AFC_OPS.GET_FILE_INFO,
|
|
49
|
+
data: toCString(path1)
|
|
50
|
+
});
|
|
51
|
+
debug(`getFileInfo:response: %O`, response);
|
|
52
|
+
const strings = [];
|
|
53
|
+
let currentString = "";
|
|
54
|
+
const tokens = response.data;
|
|
55
|
+
tokens.forEach((token)=>{
|
|
56
|
+
if (token === 0) {
|
|
57
|
+
strings.push(currentString);
|
|
58
|
+
currentString = "";
|
|
59
|
+
} else {
|
|
60
|
+
currentString += String.fromCharCode(token);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
return strings;
|
|
64
|
+
}
|
|
65
|
+
async writeFile(fd, data) {
|
|
66
|
+
debug(`writeFile: ${Array.prototype.toString.call(fd)} data size: ${data.length}`);
|
|
67
|
+
const response = await this.protocolClient.sendMessage({
|
|
68
|
+
operation: _afcprotocol.AFC_OPS.FILE_WRITE,
|
|
69
|
+
data: fd,
|
|
70
|
+
payload: data
|
|
71
|
+
});
|
|
72
|
+
debug(`writeFile:response:`, response);
|
|
73
|
+
return response;
|
|
74
|
+
}
|
|
75
|
+
async openFile(path2) {
|
|
76
|
+
debug(`openFile: ${path2}`);
|
|
77
|
+
// mode + path + null terminator
|
|
78
|
+
const data = Buffer.alloc(8 + path2.length + 1);
|
|
79
|
+
// write mode
|
|
80
|
+
data.writeUInt32LE(_afcprotocol.AFC_FILE_OPEN_FLAGS.WRONLY, 0);
|
|
81
|
+
// then path to file
|
|
82
|
+
toCString(path2).copy(data, 8);
|
|
83
|
+
const response = await this.protocolClient.sendMessage({
|
|
84
|
+
operation: _afcprotocol.AFC_OPS.FILE_OPEN,
|
|
85
|
+
data
|
|
86
|
+
});
|
|
87
|
+
// debug(`openFile:response:`, response);
|
|
88
|
+
if (response.operation === _afcprotocol.AFC_OPS.FILE_OPEN_RES) {
|
|
89
|
+
return response.data;
|
|
90
|
+
}
|
|
91
|
+
throw new _errors.CommandError("APPLE_DEVICE_AFC", `There was an unknown error opening file ${path2}, response: ${Array.prototype.toString.call(response.data)}`);
|
|
92
|
+
}
|
|
93
|
+
async closeFile(fd) {
|
|
94
|
+
debug(`closeFile fd: ${Array.prototype.toString.call(fd)}`);
|
|
95
|
+
const response = await this.protocolClient.sendMessage({
|
|
96
|
+
operation: _afcprotocol.AFC_OPS.FILE_CLOSE,
|
|
97
|
+
data: fd
|
|
98
|
+
});
|
|
99
|
+
debug(`closeFile:response:`, response);
|
|
100
|
+
return response;
|
|
101
|
+
}
|
|
102
|
+
async uploadFile(srcPath, destPath) {
|
|
103
|
+
debug(`uploadFile: ${srcPath}, ${destPath}`);
|
|
104
|
+
// read local file and get fd of destination
|
|
105
|
+
const [srcFile, destFile] = await Promise.all([
|
|
106
|
+
await (0, _util).promisify(fs.readFile)(srcPath),
|
|
107
|
+
await this.openFile(destPath),
|
|
108
|
+
]);
|
|
109
|
+
try {
|
|
110
|
+
await this.writeFile(destFile, srcFile);
|
|
111
|
+
await this.closeFile(destFile);
|
|
112
|
+
} catch (err) {
|
|
113
|
+
await this.closeFile(destFile);
|
|
114
|
+
throw err;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
async makeDirectory(path3) {
|
|
118
|
+
debug(`makeDirectory: ${path3}`);
|
|
119
|
+
const response = await this.protocolClient.sendMessage({
|
|
120
|
+
operation: _afcprotocol.AFC_OPS.MAKE_DIR,
|
|
121
|
+
data: toCString(path3)
|
|
122
|
+
});
|
|
123
|
+
debug(`makeDirectory:response:`, response);
|
|
124
|
+
return response;
|
|
125
|
+
}
|
|
126
|
+
async uploadDirectory(srcPath, destPath) {
|
|
127
|
+
debug(`uploadDirectory: ${srcPath}`);
|
|
128
|
+
await this.makeDirectory(destPath);
|
|
129
|
+
// AFC doesn't seem to give out more than 240 file handles,
|
|
130
|
+
// so we delay any requests that would push us over until more open up
|
|
131
|
+
let numOpenFiles = 0;
|
|
132
|
+
const pendingFileUploads = [];
|
|
133
|
+
const _this = this;
|
|
134
|
+
return uploadDir(srcPath);
|
|
135
|
+
async function uploadDir(dirPath) {
|
|
136
|
+
const promises = [];
|
|
137
|
+
for (const file of fs.readdirSync(dirPath)){
|
|
138
|
+
const filePath = path.join(dirPath, file);
|
|
139
|
+
const remotePath = path.join(destPath, path.relative(srcPath, filePath));
|
|
140
|
+
if (fs.lstatSync(filePath).isDirectory()) {
|
|
141
|
+
promises.push(_this.makeDirectory(remotePath).then(()=>uploadDir(filePath)
|
|
142
|
+
));
|
|
143
|
+
} else {
|
|
144
|
+
// Create promise to add to promises array
|
|
145
|
+
// this way it can be resolved once a pending upload has finished
|
|
146
|
+
let resolve;
|
|
147
|
+
let reject;
|
|
148
|
+
const promise = new Promise((res, rej)=>{
|
|
149
|
+
resolve = res;
|
|
150
|
+
reject = rej;
|
|
151
|
+
});
|
|
152
|
+
promises.push(promise);
|
|
153
|
+
// wrap upload in a function in case we need to save it for later
|
|
154
|
+
const uploadFile = (tries = 0)=>{
|
|
155
|
+
numOpenFiles++;
|
|
156
|
+
_this.uploadFile(filePath, remotePath).then(()=>{
|
|
157
|
+
resolve();
|
|
158
|
+
numOpenFiles--;
|
|
159
|
+
const fn = pendingFileUploads.pop();
|
|
160
|
+
if (fn) {
|
|
161
|
+
fn();
|
|
162
|
+
}
|
|
163
|
+
}).catch((err)=>{
|
|
164
|
+
// Couldn't get fd for whatever reason, try again
|
|
165
|
+
// # of retries is arbitrary and can be adjusted
|
|
166
|
+
if (err.status === _afcprotocol.AFC_STATUS.NO_RESOURCES && tries < 10) {
|
|
167
|
+
debug(`Received NO_RESOURCES from AFC, retrying ${filePath} upload. ${tries}`);
|
|
168
|
+
uploadFile(tries++);
|
|
169
|
+
} else {
|
|
170
|
+
numOpenFiles--;
|
|
171
|
+
reject(err);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
if (numOpenFiles < MAX_OPEN_FILES) {
|
|
176
|
+
uploadFile();
|
|
177
|
+
} else {
|
|
178
|
+
debug(`numOpenFiles >= ${MAX_OPEN_FILES}, adding to pending queue. Length: ${pendingFileUploads.length}`);
|
|
179
|
+
pendingFileUploads.push(uploadFile);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
await Promise.all(promises);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
exports.AFCClient = AFCClient;
|
|
188
|
+
function toCString(s) {
|
|
189
|
+
const buf = Buffer.alloc(s.length + 1);
|
|
190
|
+
const len = buf.write(s);
|
|
191
|
+
buf.writeUInt8(0, len);
|
|
192
|
+
return buf;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
//# sourceMappingURL=AFCClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/run/ios/appleDevice/client/AFCClient.ts"],"sourcesContent":["/**\n * Copyright (c) 2021 Expo, Inc.\n * Copyright (c) 2018 Drifty Co.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport Debug from 'debug';\nimport * as fs from 'fs';\nimport { Socket } from 'net';\nimport * as path from 'path';\nimport { promisify } from 'util';\n\nimport { CommandError } from '../../../../utils/errors';\nimport {\n AFC_FILE_OPEN_FLAGS,\n AFC_OPS,\n AFC_STATUS,\n AFCError,\n AFCProtocolClient,\n AFCResponse,\n} from '../protocol/AFCProtocol';\nimport { ServiceClient } from './ServiceClient';\n\nconst debug = Debug('expo:apple-device:client:afc');\nconst MAX_OPEN_FILES = 240;\n\nexport class AFCClient extends ServiceClient<AFCProtocolClient> {\n constructor(public socket: Socket) {\n super(socket, new AFCProtocolClient(socket));\n }\n\n async getFileInfo(path: string): Promise<string[]> {\n debug(`getFileInfo: ${path}`);\n\n const response = await this.protocolClient.sendMessage({\n operation: AFC_OPS.GET_FILE_INFO,\n data: toCString(path),\n });\n debug(`getFileInfo:response: %O`, response);\n\n const strings: string[] = [];\n let currentString = '';\n const tokens = response.data;\n tokens.forEach((token) => {\n if (token === 0) {\n strings.push(currentString);\n currentString = '';\n } else {\n currentString += String.fromCharCode(token);\n }\n });\n return strings;\n }\n\n async writeFile(fd: Buffer, data: Buffer): Promise<AFCResponse> {\n debug(`writeFile: ${Array.prototype.toString.call(fd)} data size: ${data.length}`);\n\n const response = await this.protocolClient.sendMessage({\n operation: AFC_OPS.FILE_WRITE,\n data: fd,\n payload: data,\n });\n\n debug(`writeFile:response:`, response);\n return response;\n }\n\n protected async openFile(path: string): Promise<Buffer> {\n debug(`openFile: ${path}`);\n // mode + path + null terminator\n const data = Buffer.alloc(8 + path.length + 1);\n // write mode\n data.writeUInt32LE(AFC_FILE_OPEN_FLAGS.WRONLY, 0);\n // then path to file\n toCString(path).copy(data, 8);\n\n const response = await this.protocolClient.sendMessage({\n operation: AFC_OPS.FILE_OPEN,\n data,\n });\n\n // debug(`openFile:response:`, response);\n\n if (response.operation === AFC_OPS.FILE_OPEN_RES) {\n return response.data;\n }\n\n throw new CommandError(\n 'APPLE_DEVICE_AFC',\n `There was an unknown error opening file ${path}, response: ${Array.prototype.toString.call(\n response.data\n )}`\n );\n }\n\n protected async closeFile(fd: Buffer): Promise<AFCResponse> {\n debug(`closeFile fd: ${Array.prototype.toString.call(fd)}`);\n const response = await this.protocolClient.sendMessage({\n operation: AFC_OPS.FILE_CLOSE,\n data: fd,\n });\n\n debug(`closeFile:response:`, response);\n return response;\n }\n\n protected async uploadFile(srcPath: string, destPath: string): Promise<void> {\n debug(`uploadFile: ${srcPath}, ${destPath}`);\n\n // read local file and get fd of destination\n const [srcFile, destFile] = await Promise.all([\n await promisify(fs.readFile)(srcPath),\n await this.openFile(destPath),\n ]);\n\n try {\n await this.writeFile(destFile, srcFile);\n await this.closeFile(destFile);\n } catch (err) {\n await this.closeFile(destFile);\n throw err;\n }\n }\n\n async makeDirectory(path: string): Promise<AFCResponse> {\n debug(`makeDirectory: ${path}`);\n\n const response = await this.protocolClient.sendMessage({\n operation: AFC_OPS.MAKE_DIR,\n data: toCString(path),\n });\n\n debug(`makeDirectory:response:`, response);\n return response;\n }\n\n async uploadDirectory(srcPath: string, destPath: string): Promise<void> {\n debug(`uploadDirectory: ${srcPath}`);\n await this.makeDirectory(destPath);\n\n // AFC doesn't seem to give out more than 240 file handles,\n // so we delay any requests that would push us over until more open up\n let numOpenFiles = 0;\n const pendingFileUploads: (() => void)[] = [];\n const _this = this;\n return uploadDir(srcPath);\n\n async function uploadDir(dirPath: string): Promise<void> {\n const promises: Promise<void>[] = [];\n for (const file of fs.readdirSync(dirPath)) {\n const filePath = path.join(dirPath, file);\n const remotePath = path.join(destPath, path.relative(srcPath, filePath));\n if (fs.lstatSync(filePath).isDirectory()) {\n promises.push(_this.makeDirectory(remotePath).then(() => uploadDir(filePath)));\n } else {\n // Create promise to add to promises array\n // this way it can be resolved once a pending upload has finished\n let resolve: (val?: any) => void;\n let reject: (err: AFCError) => void;\n const promise = new Promise<void>((res, rej) => {\n resolve = res;\n reject = rej;\n });\n promises.push(promise);\n\n // wrap upload in a function in case we need to save it for later\n const uploadFile = (tries = 0) => {\n numOpenFiles++;\n _this\n .uploadFile(filePath, remotePath)\n .then(() => {\n resolve();\n numOpenFiles--;\n const fn = pendingFileUploads.pop();\n if (fn) {\n fn();\n }\n })\n .catch((err: AFCError) => {\n // Couldn't get fd for whatever reason, try again\n // # of retries is arbitrary and can be adjusted\n if (err.status === AFC_STATUS.NO_RESOURCES && tries < 10) {\n debug(`Received NO_RESOURCES from AFC, retrying ${filePath} upload. ${tries}`);\n uploadFile(tries++);\n } else {\n numOpenFiles--;\n reject(err);\n }\n });\n };\n\n if (numOpenFiles < MAX_OPEN_FILES) {\n uploadFile();\n } else {\n debug(\n `numOpenFiles >= ${MAX_OPEN_FILES}, adding to pending queue. Length: ${pendingFileUploads.length}`\n );\n pendingFileUploads.push(uploadFile);\n }\n }\n }\n await Promise.all(promises);\n }\n }\n}\n\nfunction toCString(s: string) {\n const buf = Buffer.alloc(s.length + 1);\n const len = buf.write(s);\n buf.writeUInt8(0, len);\n return buf;\n}\n"],"names":["fs","path","debug","Debug","MAX_OPEN_FILES","AFCClient","ServiceClient","constructor","socket","AFCProtocolClient","getFileInfo","response","protocolClient","sendMessage","operation","AFC_OPS","GET_FILE_INFO","data","toCString","strings","currentString","tokens","forEach","token","push","String","fromCharCode","writeFile","fd","Array","prototype","toString","call","length","FILE_WRITE","payload","openFile","Buffer","alloc","writeUInt32LE","AFC_FILE_OPEN_FLAGS","WRONLY","copy","FILE_OPEN","FILE_OPEN_RES","CommandError","closeFile","FILE_CLOSE","uploadFile","srcPath","destPath","srcFile","destFile","Promise","all","promisify","readFile","err","makeDirectory","MAKE_DIR","uploadDirectory","numOpenFiles","pendingFileUploads","_this","uploadDir","dirPath","promises","file","readdirSync","filePath","join","remotePath","relative","lstatSync","isDirectory","then","resolve","reject","promise","res","rej","tries","fn","pop","catch","status","AFC_STATUS","NO_RESOURCES","s","buf","len","write","writeUInt8"],"mappings":"AAOA;;;;AAAkB,IAAA,MAAO,kCAAP,OAAO,EAAA;AACbA,IAAAA,EAAE,mCAAM,IAAI,EAAV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,SAAS,EAAEY,KAAK,CAAC,CAAC,CAAC,CAAC;gCAC/EjC,UAAU,CAACiC,KAAK,EAAE,CAAC,CAAC;6BACrB,MAAM;gCACLpB,YAAY,EAAE,CAAC;gCACfgB,MAAM,CAACpB,GAAG,CAAC,CAAC;6BACb;yBACF,CAAC,CAAC;qBACN,AAAC;oBAEF,IAAII,YAAY,GAAGzD,cAAc,EAAE;wBACjC4C,UAAU,EAAE,CAAC;qBACd,MAAM;wBACL9C,KAAK,CACH,CAAC,gBAAgB,EAAEE,cAAc,CAAC,mCAAmC,EAAE0D,kBAAkB,CAAC7B,MAAM,CAAC,CAAC,CACnG,CAAC;wBACF6B,kBAAkB,CAACtC,IAAI,CAACwB,UAAU,CAAC,CAAC;qBACrC;iBACF;aACF;YACD,MAAMK,OAAO,CAACC,GAAG,CAACY,QAAQ,CAAC,CAAC;SAC7B;KACF;CACF;QAlLY7D,SAAS,GAATA,SAAS;AAoLtB,SAASa,SAAS,CAACsE,CAAS,EAAE;IAC5B,MAAMC,GAAG,GAAGpD,MAAM,CAACC,KAAK,CAACkD,CAAC,CAACvD,MAAM,GAAG,CAAC,CAAC,AAAC;IACvC,MAAMyD,GAAG,GAAGD,GAAG,CAACE,KAAK,CAACH,CAAC,CAAC,AAAC;IACzBC,GAAG,CAACG,UAAU,CAAC,CAAC,EAAEF,GAAG,CAAC,CAAC;IACvB,OAAOD,GAAG,CAAC;CACZ"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
6
|
+
var path = _interopRequireWildcard(require("path"));
|
|
7
|
+
var _gdbprotocol = require("../protocol/GDBProtocol");
|
|
8
|
+
var _serviceClient = require("./ServiceClient");
|
|
9
|
+
function _interopRequireDefault(obj) {
|
|
10
|
+
return obj && obj.__esModule ? obj : {
|
|
11
|
+
default: obj
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function _interopRequireWildcard(obj) {
|
|
15
|
+
if (obj && obj.__esModule) {
|
|
16
|
+
return obj;
|
|
17
|
+
} else {
|
|
18
|
+
var newObj = {};
|
|
19
|
+
if (obj != null) {
|
|
20
|
+
for(var key in obj){
|
|
21
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
22
|
+
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
|
|
23
|
+
if (desc.get || desc.set) {
|
|
24
|
+
Object.defineProperty(newObj, key, desc);
|
|
25
|
+
} else {
|
|
26
|
+
newObj[key] = obj[key];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
newObj.default = obj;
|
|
32
|
+
return newObj;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const debug = (0, _debug).default("expo:apple-device:client:debugserver");
|
|
36
|
+
class DebugserverClient extends _serviceClient.ServiceClient {
|
|
37
|
+
constructor(socket){
|
|
38
|
+
super(socket, new _gdbprotocol.GDBProtocolClient(socket));
|
|
39
|
+
this.socket = socket;
|
|
40
|
+
}
|
|
41
|
+
async setMaxPacketSize(size) {
|
|
42
|
+
return this.sendCommand("QSetMaxPacketSize:", [
|
|
43
|
+
size.toString()
|
|
44
|
+
]);
|
|
45
|
+
}
|
|
46
|
+
async setWorkingDir(workingDir) {
|
|
47
|
+
return this.sendCommand("QSetWorkingDir:", [
|
|
48
|
+
workingDir
|
|
49
|
+
]);
|
|
50
|
+
}
|
|
51
|
+
async checkLaunchSuccess() {
|
|
52
|
+
return this.sendCommand("qLaunchSuccess", []);
|
|
53
|
+
}
|
|
54
|
+
async attachByName(name) {
|
|
55
|
+
const hexName = Buffer.from(name).toString("hex");
|
|
56
|
+
return this.sendCommand(`vAttachName;${hexName}`, []);
|
|
57
|
+
}
|
|
58
|
+
async continue() {
|
|
59
|
+
return this.sendCommand("c", []);
|
|
60
|
+
}
|
|
61
|
+
halt() {
|
|
62
|
+
// ^C
|
|
63
|
+
debug("Sending ^C to debugserver");
|
|
64
|
+
return this.protocolClient.socket.write("\x03");
|
|
65
|
+
}
|
|
66
|
+
async kill() {
|
|
67
|
+
debug(`kill`);
|
|
68
|
+
const msg = {
|
|
69
|
+
cmd: "k",
|
|
70
|
+
args: []
|
|
71
|
+
};
|
|
72
|
+
return this.protocolClient.sendMessage(msg, (resp, resolve)=>{
|
|
73
|
+
debug(`kill:response: ${resp}`);
|
|
74
|
+
this.protocolClient.socket.write("+");
|
|
75
|
+
const parts = resp.split(";");
|
|
76
|
+
for (const part of parts){
|
|
77
|
+
if (part.includes("description")) {
|
|
78
|
+
// description:{hex encoded message like: "Terminated with signal 9"}
|
|
79
|
+
resolve(Buffer.from(part.split(":")[1], "hex").toString("ascii"));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
// TODO support app args
|
|
85
|
+
// https://sourceware.org/gdb/onlinedocs/gdb/Packets.html#Packets
|
|
86
|
+
// A arglen,argnum,arg,
|
|
87
|
+
async launchApp(appPath, executableName) {
|
|
88
|
+
const fullPath = path.join(appPath, executableName);
|
|
89
|
+
const hexAppPath = Buffer.from(fullPath).toString("hex");
|
|
90
|
+
const appCommand = `A${hexAppPath.length},0,${hexAppPath}`;
|
|
91
|
+
return this.sendCommand(appCommand, []);
|
|
92
|
+
}
|
|
93
|
+
async sendCommand(cmd, args) {
|
|
94
|
+
const msg = {
|
|
95
|
+
cmd,
|
|
96
|
+
args
|
|
97
|
+
};
|
|
98
|
+
debug(`Sending command: ${cmd}, args: ${args}`);
|
|
99
|
+
const resp = await this.protocolClient.sendMessage(msg);
|
|
100
|
+
// we need to ACK as well
|
|
101
|
+
this.protocolClient.socket.write("+");
|
|
102
|
+
return resp;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.DebugserverClient = DebugserverClient;
|
|
106
|
+
|
|
107
|
+
//# sourceMappingURL=DebugserverClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/run/ios/appleDevice/client/DebugserverClient.ts"],"sourcesContent":["/**\n * Copyright (c) 2021 Expo, Inc.\n * Copyright (c) 2018 Drifty Co.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport Debug from 'debug';\nimport { Socket } from 'net';\nimport * as path from 'path';\n\nimport { GDBProtocolClient } from '../protocol/GDBProtocol';\nimport { ServiceClient } from './ServiceClient';\n\nconst debug = Debug('expo:apple-device:client:debugserver');\n\nexport class DebugserverClient extends ServiceClient<GDBProtocolClient> {\n constructor(public socket: Socket) {\n super(socket, new GDBProtocolClient(socket));\n }\n\n async setMaxPacketSize(size: number) {\n return this.sendCommand('QSetMaxPacketSize:', [size.toString()]);\n }\n\n async setWorkingDir(workingDir: string) {\n return this.sendCommand('QSetWorkingDir:', [workingDir]);\n }\n\n async checkLaunchSuccess() {\n return this.sendCommand('qLaunchSuccess', []);\n }\n\n async attachByName(name: string) {\n const hexName = Buffer.from(name).toString('hex');\n return this.sendCommand(`vAttachName;${hexName}`, []);\n }\n\n async continue() {\n return this.sendCommand('c', []);\n }\n\n halt() {\n // ^C\n debug('Sending ^C to debugserver');\n return this.protocolClient.socket.write('\\u0003');\n }\n\n async kill() {\n debug(`kill`);\n const msg: any = { cmd: 'k', args: [] };\n return this.protocolClient.sendMessage(msg, (resp: string, resolve: any) => {\n debug(`kill:response: ${resp}`);\n this.protocolClient.socket.write('+');\n const parts = resp.split(';');\n for (const part of parts) {\n if (part.includes('description')) {\n // description:{hex encoded message like: \"Terminated with signal 9\"}\n resolve(Buffer.from(part.split(':')[1], 'hex').toString('ascii'));\n }\n }\n });\n }\n\n // TODO support app args\n // https://sourceware.org/gdb/onlinedocs/gdb/Packets.html#Packets\n // A arglen,argnum,arg,\n async launchApp(appPath: string, executableName: string) {\n const fullPath = path.join(appPath, executableName);\n const hexAppPath = Buffer.from(fullPath).toString('hex');\n const appCommand = `A${hexAppPath.length},0,${hexAppPath}`;\n return this.sendCommand(appCommand, []);\n }\n\n async sendCommand(cmd: string, args: string[]) {\n const msg = { cmd, args };\n debug(`Sending command: ${cmd}, args: ${args}`);\n const resp = await this.protocolClient.sendMessage(msg);\n // we need to ACK as well\n this.protocolClient.socket.write('+');\n return resp;\n }\n}\n"],"names":["path","debug","Debug","DebugserverClient","ServiceClient","constructor","socket","GDBProtocolClient","setMaxPacketSize","size","sendCommand","toString","setWorkingDir","workingDir","checkLaunchSuccess","attachByName","name","hexName","Buffer","from","continue","halt","protocolClient","write","kill","msg","cmd","args","sendMessage","resp","resolve","parts","split","part","includes","launchApp","appPath","executableName","fullPath","join","hexAppPath","appCommand","length"],"mappings":"AAOA;;;;AAAkB,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEbA,IAAAA,IAAI,mCAAM,MAAM,EAAZ;AAEkB,IAAA,YAAyB,WAAzB,yBAAyB,CAAA;AAC7B,IAAA,cAAiB,WAAjB,iBAAiB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE/C,MAAMC,KAAK,GAAGC,CAAAA,GAAAA,MAAK,AAAwC,CAAA,QAAxC,CAAC,sCAAsC,CAAC,AAAC;AAErD,MAAMC,iBAAiB,SAASC,cAAa,cAAA;IAClDC,YAAmBC,MAAc,CAAE;QACjC,KAAK,CAACA,MAAM,EAAE,IAAIC,YAAiB,kBAAA,CAACD,MAAM,CAAC,CAAC,CAAC;aAD5BA,MAAc,GAAdA,MAAc;KAEhC;IAED,MAAME,gBAAgB,CAACC,IAAY,EAAE;QACnC,OAAO,IAAI,CAACC,WAAW,CAAC,oBAAoB,EAAE;YAACD,IAAI,CAACE,QAAQ,EAAE;SAAC,CAAC,CAAC;KAClE;IAED,MAAMC,aAAa,CAACC,UAAkB,EAAE;QACtC,OAAO,IAAI,CAACH,WAAW,CAAC,iBAAiB,EAAE;YAACG,UAAU;SAAC,CAAC,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= _interopRequireDefault(require("debug"));
|
|
6
|
+
var _lockdownProtocol = require("../protocol/LockdownProtocol");
|
|
7
|
+
var _serviceClient = require("./ServiceClient");
|
|
8
|
+
function _interopRequireDefault(obj) {
|
|
9
|
+
return obj && obj.__esModule ? obj : {
|
|
10
|
+
default: obj
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
const debug = (0, _debug).default("expo:apple-device:client:installation_proxy");
|
|
14
|
+
function isIPLookupResponse(resp) {
|
|
15
|
+
return resp.length && resp[0].LookupResult !== undefined;
|
|
16
|
+
}
|
|
17
|
+
function isIPInstallPercentCompleteResponse(resp) {
|
|
18
|
+
return resp.length && resp[0].PercentComplete !== undefined;
|
|
19
|
+
}
|
|
20
|
+
function isIPInstallCFBundleIdentifierResponse(resp) {
|
|
21
|
+
return resp.length && resp[0].CFBundleIdentifier !== undefined;
|
|
22
|
+
}
|
|
23
|
+
function isIPInstallCompleteResponse(resp) {
|
|
24
|
+
return resp.length && resp[0].Status === "Complete";
|
|
25
|
+
}
|
|
26
|
+
class InstallationProxyClient extends _serviceClient.ServiceClient {
|
|
27
|
+
constructor(socket){
|
|
28
|
+
super(socket, new _lockdownProtocol.LockdownProtocolClient(socket));
|
|
29
|
+
this.socket = socket;
|
|
30
|
+
}
|
|
31
|
+
async lookupApp(bundleIds, options = {
|
|
32
|
+
ReturnAttributes: [
|
|
33
|
+
"Path",
|
|
34
|
+
"Container",
|
|
35
|
+
"CFBundleExecutable",
|
|
36
|
+
"CFBundleIdentifier"
|
|
37
|
+
],
|
|
38
|
+
ApplicationsType: "Any"
|
|
39
|
+
}) {
|
|
40
|
+
debug(`lookupApp, options: ${JSON.stringify(options)}`);
|
|
41
|
+
let resp = await this.protocolClient.sendMessage({
|
|
42
|
+
Command: "Lookup",
|
|
43
|
+
ClientOptions: {
|
|
44
|
+
BundleIDs: bundleIds,
|
|
45
|
+
...options
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
if (resp && !Array.isArray(resp)) resp = [
|
|
49
|
+
resp
|
|
50
|
+
];
|
|
51
|
+
if (isIPLookupResponse(resp)) {
|
|
52
|
+
return resp[0].LookupResult;
|
|
53
|
+
} else {
|
|
54
|
+
throw new _serviceClient.ResponseError(`There was an error looking up app`, resp);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async installApp(packagePath, bundleId, options = {
|
|
58
|
+
ApplicationsType: "Any",
|
|
59
|
+
PackageType: "Developer"
|
|
60
|
+
}, onProgress) {
|
|
61
|
+
debug(`installApp, packagePath: ${packagePath}, bundleId: ${bundleId}`);
|
|
62
|
+
return this.protocolClient.sendMessage({
|
|
63
|
+
Command: "Install",
|
|
64
|
+
PackagePath: packagePath,
|
|
65
|
+
ClientOptions: {
|
|
66
|
+
CFBundleIdentifier: bundleId,
|
|
67
|
+
...options
|
|
68
|
+
}
|
|
69
|
+
}, (resp, resolve, reject)=>{
|
|
70
|
+
if (resp && !Array.isArray(resp)) resp = [
|
|
71
|
+
resp
|
|
72
|
+
];
|
|
73
|
+
if (isIPInstallCompleteResponse(resp)) {
|
|
74
|
+
onProgress({
|
|
75
|
+
isComplete: true,
|
|
76
|
+
progress: 100,
|
|
77
|
+
status: resp[0].Status
|
|
78
|
+
});
|
|
79
|
+
resolve();
|
|
80
|
+
} else if (isIPInstallPercentCompleteResponse(resp)) {
|
|
81
|
+
onProgress({
|
|
82
|
+
isComplete: false,
|
|
83
|
+
progress: resp[0].PercentComplete,
|
|
84
|
+
status: resp[0].Status
|
|
85
|
+
});
|
|
86
|
+
debug(`Installation status: ${resp[0].Status}, %${resp[0].PercentComplete}`);
|
|
87
|
+
} else if (isIPInstallCFBundleIdentifierResponse(resp)) {
|
|
88
|
+
debug(`Installed app: ${resp[0].CFBundleIdentifier}`);
|
|
89
|
+
} else {
|
|
90
|
+
reject(new _serviceClient.ResponseError("There was an error installing app: " + require("util").inspect(resp), resp));
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.InstallationProxyClient = InstallationProxyClient;
|
|
96
|
+
|
|
97
|
+
//# sourceMappingURL=InstallationProxyClient.js.map
|