@expo/cli 0.1.3 → 0.1.6

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.
Files changed (108) hide show
  1. package/build/bin/cli +8 -2
  2. package/build/bin/cli.map +1 -1
  3. package/build/src/export/index.js +1 -0
  4. package/build/src/export/index.js.map +1 -1
  5. package/build/src/run/android/runAndroidAsync.js +3 -3
  6. package/build/src/run/android/runAndroidAsync.js.map +1 -1
  7. package/build/src/run/ensureNativeProject.js +3 -0
  8. package/build/src/run/ensureNativeProject.js.map +1 -1
  9. package/build/src/run/hints.js +1 -1
  10. package/build/src/run/hints.js.map +1 -1
  11. package/build/src/run/ios/XcodeBuild.js +275 -0
  12. package/build/src/run/ios/XcodeBuild.js.map +1 -0
  13. package/build/src/run/ios/XcodeBuild.types.js +6 -0
  14. package/build/src/run/ios/XcodeBuild.types.js.map +1 -0
  15. package/build/src/run/ios/appleDevice/AppleDevice.js +161 -0
  16. package/build/src/run/ios/appleDevice/AppleDevice.js.map +1 -0
  17. package/build/src/run/ios/appleDevice/ClientManager.js +161 -0
  18. package/build/src/run/ios/appleDevice/ClientManager.js.map +1 -0
  19. package/build/src/run/ios/appleDevice/client/AFCClient.js +195 -0
  20. package/build/src/run/ios/appleDevice/client/AFCClient.js.map +1 -0
  21. package/build/src/run/ios/appleDevice/client/DebugserverClient.js +107 -0
  22. package/build/src/run/ios/appleDevice/client/DebugserverClient.js.map +1 -0
  23. package/build/src/run/ios/appleDevice/client/InstallationProxyClient.js +97 -0
  24. package/build/src/run/ios/appleDevice/client/InstallationProxyClient.js.map +1 -0
  25. package/build/src/run/ios/appleDevice/client/LockdowndClient.js +140 -0
  26. package/build/src/run/ios/appleDevice/client/LockdowndClient.js.map +1 -0
  27. package/build/src/run/ios/appleDevice/client/MobileImageMounterClient.js +91 -0
  28. package/build/src/run/ios/appleDevice/client/MobileImageMounterClient.js.map +1 -0
  29. package/build/src/run/ios/appleDevice/client/ServiceClient.js +21 -0
  30. package/build/src/run/ios/appleDevice/client/ServiceClient.js.map +1 -0
  31. package/build/src/run/ios/appleDevice/client/UsbmuxdClient.js +117 -0
  32. package/build/src/run/ios/appleDevice/client/UsbmuxdClient.js.map +1 -0
  33. package/build/src/run/ios/appleDevice/installOnDeviceAsync.js +90 -0
  34. package/build/src/run/ios/appleDevice/installOnDeviceAsync.js.map +1 -0
  35. package/build/src/run/ios/appleDevice/protocol/AFCProtocol.js +332 -0
  36. package/build/src/run/ios/appleDevice/protocol/AFCProtocol.js.map +1 -0
  37. package/build/src/run/ios/appleDevice/protocol/AbstractProtocol.js +115 -0
  38. package/build/src/run/ios/appleDevice/protocol/AbstractProtocol.js.map +1 -0
  39. package/build/src/run/ios/appleDevice/protocol/GDBProtocol.js +126 -0
  40. package/build/src/run/ios/appleDevice/protocol/GDBProtocol.js.map +1 -0
  41. package/build/src/run/ios/appleDevice/protocol/LockdownProtocol.js +74 -0
  42. package/build/src/run/ios/appleDevice/protocol/LockdownProtocol.js.map +1 -0
  43. package/build/src/run/ios/appleDevice/protocol/UsbmuxProtocol.js +65 -0
  44. package/build/src/run/ios/appleDevice/protocol/UsbmuxProtocol.js.map +1 -0
  45. package/build/src/run/ios/codeSigning/Security.js +85 -0
  46. package/build/src/run/ios/codeSigning/Security.js.map +1 -0
  47. package/build/src/run/ios/codeSigning/configureCodeSigning.js +77 -0
  48. package/build/src/run/ios/codeSigning/configureCodeSigning.js.map +1 -0
  49. package/build/src/run/ios/codeSigning/resolveCertificateSigningIdentity.js +102 -0
  50. package/build/src/run/ios/codeSigning/resolveCertificateSigningIdentity.js.map +1 -0
  51. package/build/src/run/ios/codeSigning/settings.js +21 -0
  52. package/build/src/run/ios/codeSigning/settings.js.map +1 -0
  53. package/build/src/run/ios/codeSigning/xcodeCodeSigning.js +76 -0
  54. package/build/src/run/ios/codeSigning/xcodeCodeSigning.js.map +1 -0
  55. package/build/src/run/ios/index.js +98 -0
  56. package/build/src/run/ios/index.js.map +1 -0
  57. package/build/src/run/ios/launchApp.js +75 -0
  58. package/build/src/run/ios/launchApp.js.map +1 -0
  59. package/build/src/run/ios/options/promptDevice.js +50 -0
  60. package/build/src/run/ios/options/promptDevice.js.map +1 -0
  61. package/build/src/run/ios/options/resolveDevice.js +92 -0
  62. package/build/src/run/ios/options/resolveDevice.js.map +1 -0
  63. package/build/src/run/ios/options/resolveNativeScheme.js +92 -0
  64. package/build/src/run/ios/options/resolveNativeScheme.js.map +1 -0
  65. package/build/src/run/ios/options/resolveOptions.js +44 -0
  66. package/build/src/run/ios/options/resolveOptions.js.map +1 -0
  67. package/build/src/run/ios/options/resolveXcodeProject.js +39 -0
  68. package/build/src/run/ios/options/resolveXcodeProject.js.map +1 -0
  69. package/build/src/run/ios/runIosAsync.js +85 -0
  70. package/build/src/run/ios/runIosAsync.js.map +1 -0
  71. package/build/src/run/resolveBundlerProps.js +9 -6
  72. package/build/src/run/resolveBundlerProps.js.map +1 -1
  73. package/build/src/run/startBundler.js +4 -2
  74. package/build/src/run/startBundler.js.map +1 -1
  75. package/build/src/start/doctor/Prerequisite.js +4 -4
  76. package/build/src/start/doctor/Prerequisite.js.map +1 -1
  77. package/build/src/start/doctor/SecurityBinPrerequisite.js +27 -0
  78. package/build/src/start/doctor/SecurityBinPrerequisite.js.map +1 -0
  79. package/build/src/start/doctor/apple/XcodeDeveloperDiskImagePrerequisite.js +69 -0
  80. package/build/src/start/doctor/apple/XcodeDeveloperDiskImagePrerequisite.js.map +1 -0
  81. package/build/src/start/platforms/android/emulator.js +8 -0
  82. package/build/src/start/platforms/android/emulator.js.map +1 -1
  83. package/build/src/start/platforms/android/promptAndroidDevice.js +1 -5
  84. package/build/src/start/platforms/android/promptAndroidDevice.js.map +1 -1
  85. package/build/src/start/platforms/ios/AppleDeviceManager.js +5 -1
  86. package/build/src/start/platforms/ios/AppleDeviceManager.js.map +1 -1
  87. package/build/src/start/platforms/ios/promptAppleDevice.js +1 -5
  88. package/build/src/start/platforms/ios/promptAppleDevice.js.map +1 -1
  89. package/build/src/start/platforms/ios/simctl.js +14 -0
  90. package/build/src/start/platforms/ios/simctl.js.map +1 -1
  91. package/build/src/start/platforms/ios/simctlLogging.js +220 -0
  92. package/build/src/start/platforms/ios/simctlLogging.js.map +1 -0
  93. package/build/src/start/server/middleware/ClassicManifestMiddleware.js +1 -1
  94. package/build/src/utils/analytics/rudderstackClient.js +30 -3
  95. package/build/src/utils/analytics/rudderstackClient.js.map +1 -1
  96. package/build/src/utils/cocoapods.js +47 -0
  97. package/build/src/utils/cocoapods.js.map +1 -1
  98. package/build/src/utils/dir.js +6 -1
  99. package/build/src/utils/dir.js.map +1 -1
  100. package/build/src/utils/plist.js +59 -0
  101. package/build/src/utils/plist.js.map +1 -0
  102. package/build/src/utils/prompts.js +16 -0
  103. package/build/src/utils/prompts.js.map +1 -1
  104. package/build/src/utils/resolveArgs.js +4 -1
  105. package/build/src/utils/resolveArgs.js.map +1 -1
  106. package/build/src/utils/terminal.js +10 -0
  107. package/build/src/utils/terminal.js.map +1 -0
  108. package/package.json +7 -7
@@ -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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AAC;QACtC,OAAOM,IAAI,CAAC;KACb;CACF;QAlEY1B,iBAAiB,GAAjBA,iBAAiB"}
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ var _debug = _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
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/run/ios/appleDevice/client/InstallationProxyClient.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';\n\nimport { LockdownProtocolClient } from '../protocol/LockdownProtocol';\nimport type { LockdownCommand, LockdownResponse } from '../protocol/LockdownProtocol';\nimport { ResponseError, ServiceClient } from './ServiceClient';\n\nconst debug = Debug('expo:apple-device:client:installation_proxy');\n\nexport type OnInstallProgressCallback = (props: {\n status: string;\n isComplete: boolean;\n // copiedFiles: number;\n progress: number;\n}) => void;\n\ninterface IPOptions {\n ApplicationsType?: 'Any';\n PackageType?: 'Developer';\n CFBundleIdentifier?: string;\n ReturnAttributes?: ('CFBundleIdentifier' | 'CFBundleExecutable' | 'Container' | 'Path')[];\n BundleIDs?: string[];\n [key: string]: undefined | string | string[];\n}\n\ninterface IPInstallPercentCompleteResponseItem extends LockdownResponse {\n PercentComplete: number;\n}\n\ninterface IPInstallCFBundleIdentifierResponseItem {\n CFBundleIdentifier: string;\n}\n\ninterface IPInstallCompleteResponseItem extends LockdownResponse {\n Status: 'Complete';\n}\n/*\n * [{ \"PercentComplete\": 5, \"Status\": \"CreatingStagingDirectory\" }]\n * ...\n * [{ \"PercentComplete\": 90, \"Status\": \"GeneratingApplicationMap\" }]\n * [{ \"CFBundleIdentifier\": \"my.company.app\" }]\n * [{ \"Status\": \"Complete\" }]\n */\ntype IPInstallPercentCompleteResponse = IPInstallPercentCompleteResponseItem[];\ntype IPInstallCFBundleIdentifierResponse = IPInstallCFBundleIdentifierResponseItem[];\ntype IPInstallCompleteResponse = IPInstallCompleteResponseItem[];\n\ninterface IPMessage extends LockdownCommand {\n Command: string;\n ClientOptions: IPOptions;\n}\n\ninterface IPLookupResponseItem extends LockdownResponse {\n LookupResult: IPLookupResult;\n}\n/*\n * [{\n * LookupResult: IPLookupResult,\n * Status: \"Complete\"\n * }]\n */\ntype IPLookupResponse = IPLookupResponseItem[];\n\nexport interface IPLookupResult {\n // BundleId\n [key: string]: {\n Container: string;\n CFBundleIdentifier: string;\n CFBundleExecutable: string;\n Path: string;\n };\n}\n\nfunction isIPLookupResponse(resp: any): resp is IPLookupResponse {\n return resp.length && resp[0].LookupResult !== undefined;\n}\n\nfunction isIPInstallPercentCompleteResponse(resp: any): resp is IPInstallPercentCompleteResponse {\n return resp.length && resp[0].PercentComplete !== undefined;\n}\n\nfunction isIPInstallCFBundleIdentifierResponse(\n resp: any\n): resp is IPInstallCFBundleIdentifierResponse {\n return resp.length && resp[0].CFBundleIdentifier !== undefined;\n}\n\nfunction isIPInstallCompleteResponse(resp: any): resp is IPInstallCompleteResponse {\n return resp.length && resp[0].Status === 'Complete';\n}\n\nexport class InstallationProxyClient extends ServiceClient<LockdownProtocolClient<IPMessage>> {\n constructor(public socket: Socket) {\n super(socket, new LockdownProtocolClient(socket));\n }\n\n async lookupApp(\n bundleIds: string[],\n options: IPOptions = {\n ReturnAttributes: ['Path', 'Container', 'CFBundleExecutable', 'CFBundleIdentifier'],\n ApplicationsType: 'Any',\n }\n ) {\n debug(`lookupApp, options: ${JSON.stringify(options)}`);\n\n let resp = await this.protocolClient.sendMessage({\n Command: 'Lookup',\n ClientOptions: {\n BundleIDs: bundleIds,\n ...options,\n },\n });\n if (resp && !Array.isArray(resp)) resp = [resp];\n if (isIPLookupResponse(resp)) {\n return resp[0].LookupResult;\n } else {\n throw new ResponseError(`There was an error looking up app`, resp);\n }\n }\n\n async installApp(\n packagePath: string,\n bundleId: string,\n options: IPOptions = {\n ApplicationsType: 'Any',\n PackageType: 'Developer',\n },\n onProgress: OnInstallProgressCallback\n ) {\n debug(`installApp, packagePath: ${packagePath}, bundleId: ${bundleId}`);\n\n return this.protocolClient.sendMessage(\n {\n Command: 'Install',\n PackagePath: packagePath,\n ClientOptions: {\n CFBundleIdentifier: bundleId,\n ...options,\n },\n },\n (resp, resolve, reject) => {\n if (resp && !Array.isArray(resp)) resp = [resp];\n\n if (isIPInstallCompleteResponse(resp)) {\n onProgress({\n isComplete: true,\n progress: 100,\n status: resp[0].Status,\n });\n resolve();\n } else if (isIPInstallPercentCompleteResponse(resp)) {\n onProgress({\n isComplete: false,\n progress: resp[0].PercentComplete,\n status: resp[0].Status,\n });\n debug(`Installation status: ${resp[0].Status}, %${resp[0].PercentComplete}`);\n } else if (isIPInstallCFBundleIdentifierResponse(resp)) {\n debug(`Installed app: ${resp[0].CFBundleIdentifier}`);\n } else {\n reject(\n new ResponseError(\n 'There was an error installing app: ' + require('util').inspect(resp),\n resp\n )\n );\n }\n }\n );\n }\n}\n"],"names":["debug","Debug","isIPLookupResponse","resp","length","LookupResult","undefined","isIPInstallPercentCompleteResponse","PercentComplete","isIPInstallCFBundleIdentifierResponse","CFBundleIdentifier","isIPInstallCompleteResponse","Status","InstallationProxyClient","ServiceClient","constructor","socket","LockdownProtocolClient","lookupApp","bundleIds","options","ReturnAttributes","ApplicationsType","JSON","stringify","protocolClient","sendMessage","Command","ClientOptions","BundleIDs","Array","isArray","ResponseError","installApp","packagePath","bundleId","PackageType","onProgress","PackagePath","resolve","reject","isComplete","progress","status","require","inspect"],"mappings":"AAOA;;;;AAAkB,IAAA,MAAO,kCAAP,OAAO,EAAA;AAGc,IAAA,iBAA8B,WAA9B,8BAA8B,CAAA;AAExB,IAAA,cAAiB,WAAjB,iBAAiB,CAAA;;;;;;AAE9D,MAAMA,KAAK,GAAGC,CAAAA,GAAAA,MAAK,AAA+C,CAAA,QAA/C,CAAC,6CAA6C,CAAC,AAAC;AAkEnE,SAASC,kBAAkB,CAACC,IAAS,EAA4B;IAC/D,OAAOA,IAAI,CAACC,MAAM,IAAID,IAAI,CAAC,CAAC,CAAC,CAACE,YAAY,KAAKC,SAAS,CAAC;CAC1D;AAED,SAASC,kCAAkC,CAACJ,IAAS,EAA4C;IAC/F,OAAOA,IAAI,CAACC,MAAM,IAAID,IAAI,CAAC,CAAC,CAAC,CAACK,eAAe,KAAKF,SAAS,CAAC;CAC7D;AAED,SAASG,qCAAqC,CAC5CN,IAAS,EACoC;IAC7C,OAAOA,IAAI,CAACC,MAAM,IAAID,IAAI,CAAC,CAAC,CAAC,CAACO,kBAAkB,KAAKJ,SAAS,CAAC;CAChE;AAED,SAASK,2BAA2B,CAACR,IAAS,EAAqC;IACjF,OAAOA,IAAI,CAACC,MAAM,IAAID,IAAI,CAAC,CAAC,CAAC,CAACS,MAAM,KAAK,UAAU,CAAC;CACrD;AAEM,MAAMC,uBAAuB,SAASC,cAAa,cAAA;IACx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,CAAC;KACH;CACF;QA/EYU,uBAAuB,GAAvBA,uBAAuB"}
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ var _debug = _interopRequireDefault(require("debug"));
6
+ var tls = _interopRequireWildcard(require("tls"));
7
+ var _lockdownProtocol = require("../protocol/LockdownProtocol");
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:lockdownd");
36
+ function isLockdowndServiceResponse(resp) {
37
+ return resp.Request === "StartService" && resp.Service !== undefined && resp.Port !== undefined;
38
+ }
39
+ function isLockdowndSessionResponse(resp) {
40
+ return resp.Request === "StartSession";
41
+ }
42
+ function isLockdowndAllValuesResponse(resp) {
43
+ return resp.Request === "GetValue" && resp.Value !== undefined;
44
+ }
45
+ function isLockdowndValueResponse(resp) {
46
+ return resp.Request === "GetValue" && resp.Key !== undefined && typeof resp.Value === "string";
47
+ }
48
+ function isLockdowndQueryTypeResponse(resp) {
49
+ return resp.Request === "QueryType" && resp.Type !== undefined;
50
+ }
51
+ class LockdowndClient extends _serviceClient.ServiceClient {
52
+ constructor(socket){
53
+ super(socket, new _lockdownProtocol.LockdownProtocolClient(socket));
54
+ this.socket = socket;
55
+ }
56
+ async startService(name) {
57
+ debug(`startService: ${name}`);
58
+ const resp = await this.protocolClient.sendMessage({
59
+ Request: "StartService",
60
+ Service: name
61
+ });
62
+ if (isLockdowndServiceResponse(resp)) {
63
+ return {
64
+ port: resp.Port,
65
+ enableServiceSSL: !!resp.EnableServiceSSL
66
+ };
67
+ } else {
68
+ throw new _serviceClient.ResponseError(`Error starting service ${name}`, resp);
69
+ }
70
+ }
71
+ async startSession(pairRecord) {
72
+ debug(`startSession: ${pairRecord}`);
73
+ const resp = await this.protocolClient.sendMessage({
74
+ Request: "StartSession",
75
+ HostID: pairRecord.HostID,
76
+ SystemBUID: pairRecord.SystemBUID
77
+ });
78
+ if (isLockdowndSessionResponse(resp)) {
79
+ if (resp.EnableSessionSSL) {
80
+ this.protocolClient.socket = new tls.TLSSocket(this.protocolClient.socket, {
81
+ secureContext: tls.createSecureContext({
82
+ secureProtocol: "TLSv1_method",
83
+ cert: pairRecord.RootCertificate,
84
+ key: pairRecord.RootPrivateKey
85
+ })
86
+ });
87
+ debug(`Socket upgraded to TLS connection`);
88
+ }
89
+ // TODO: save sessionID for StopSession?
90
+ } else {
91
+ throw new _serviceClient.ResponseError("Error starting session", resp);
92
+ }
93
+ }
94
+ async getAllValues() {
95
+ debug(`getAllValues`);
96
+ const resp = await this.protocolClient.sendMessage({
97
+ Request: "GetValue"
98
+ });
99
+ if (isLockdowndAllValuesResponse(resp)) {
100
+ return resp.Value;
101
+ } else {
102
+ throw new _serviceClient.ResponseError("Error getting lockdown value", resp);
103
+ }
104
+ }
105
+ async getValue(val) {
106
+ debug(`getValue: ${val}`);
107
+ const resp = await this.protocolClient.sendMessage({
108
+ Request: "GetValue",
109
+ Key: val
110
+ });
111
+ if (isLockdowndValueResponse(resp)) {
112
+ return resp.Value;
113
+ } else {
114
+ throw new _serviceClient.ResponseError("Error getting lockdown value", resp);
115
+ }
116
+ }
117
+ async queryType() {
118
+ debug("queryType");
119
+ const resp = await this.protocolClient.sendMessage({
120
+ Request: "QueryType"
121
+ });
122
+ if (isLockdowndQueryTypeResponse(resp)) {
123
+ return resp.Type;
124
+ } else {
125
+ throw new _serviceClient.ResponseError("Error getting lockdown query type", resp);
126
+ }
127
+ }
128
+ async doHandshake(pairRecord) {
129
+ debug("doHandshake");
130
+ // if (await this.lockdownQueryType() !== 'com.apple.mobile.lockdown') {
131
+ // throw new CommandError('Invalid type received from lockdown handshake');
132
+ // }
133
+ // await this.getLockdownValue('ProductVersion');
134
+ // TODO: validate pair and pair
135
+ await this.startSession(pairRecord);
136
+ }
137
+ }
138
+ exports.LockdowndClient = LockdowndClient;
139
+
140
+ //# sourceMappingURL=LockdowndClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/run/ios/appleDevice/client/LockdowndClient.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 tls from 'tls';\n\nimport { LockdownProtocolClient } from '../protocol/LockdownProtocol';\nimport { ResponseError, ServiceClient } from './ServiceClient';\nimport { UsbmuxdPairRecord } from './UsbmuxdClient';\n\nconst debug = Debug('expo:apple-device:client:lockdownd');\n\nexport interface DeviceValues {\n BasebandCertId: number;\n BasebandKeyHashInformation: {\n AKeyStatus: number;\n SKeyHash: Buffer;\n SKeyStatus: number;\n };\n BasebandSerialNumber: Buffer;\n BasebandVersion: string;\n BoardId: number;\n BuildVersion: string;\n ChipID: number;\n DeviceClass: string;\n DeviceColor: string;\n DeviceName: string;\n DieID: number;\n HardwareModel: string;\n HasSiDP: boolean;\n PartitionType: string;\n ProductName: string;\n ProductType: string;\n ProductVersion: string;\n ProductionSOC: boolean;\n ProtocolVersion: string;\n TelephonyCapability: boolean;\n UniqueChipID: number;\n UniqueDeviceID: string;\n WiFiAddress: string;\n [key: string]: any;\n}\n\ninterface LockdowndServiceResponse {\n Request: 'StartService';\n Service: string;\n Port: number;\n EnableServiceSSL?: boolean; // Only on iOS 13+\n}\n\ninterface LockdowndSessionResponse {\n Request: 'StartSession';\n EnableSessionSSL: boolean;\n}\n\ninterface LockdowndAllValuesResponse {\n Request: 'GetValue';\n Value: DeviceValues;\n}\n\ninterface LockdowndValueResponse {\n Request: 'GetValue';\n Key: string;\n Value: string;\n}\n\ninterface LockdowndQueryTypeResponse {\n Request: 'QueryType';\n Type: string;\n}\n\nfunction isLockdowndServiceResponse(resp: any): resp is LockdowndServiceResponse {\n return resp.Request === 'StartService' && resp.Service !== undefined && resp.Port !== undefined;\n}\n\nfunction isLockdowndSessionResponse(resp: any): resp is LockdowndSessionResponse {\n return resp.Request === 'StartSession';\n}\n\nfunction isLockdowndAllValuesResponse(resp: any): resp is LockdowndAllValuesResponse {\n return resp.Request === 'GetValue' && resp.Value !== undefined;\n}\n\nfunction isLockdowndValueResponse(resp: any): resp is LockdowndValueResponse {\n return resp.Request === 'GetValue' && resp.Key !== undefined && typeof resp.Value === 'string';\n}\n\nfunction isLockdowndQueryTypeResponse(resp: any): resp is LockdowndQueryTypeResponse {\n return resp.Request === 'QueryType' && resp.Type !== undefined;\n}\n\nexport class LockdowndClient extends ServiceClient<LockdownProtocolClient> {\n constructor(public socket: Socket) {\n super(socket, new LockdownProtocolClient(socket));\n }\n\n async startService(name: string) {\n debug(`startService: ${name}`);\n\n const resp = await this.protocolClient.sendMessage({\n Request: 'StartService',\n Service: name,\n });\n\n if (isLockdowndServiceResponse(resp)) {\n return { port: resp.Port, enableServiceSSL: !!resp.EnableServiceSSL };\n } else {\n throw new ResponseError(`Error starting service ${name}`, resp);\n }\n }\n\n async startSession(pairRecord: UsbmuxdPairRecord) {\n debug(`startSession: ${pairRecord}`);\n\n const resp = await this.protocolClient.sendMessage({\n Request: 'StartSession',\n HostID: pairRecord.HostID,\n SystemBUID: pairRecord.SystemBUID,\n });\n\n if (isLockdowndSessionResponse(resp)) {\n if (resp.EnableSessionSSL) {\n this.protocolClient.socket = new tls.TLSSocket(this.protocolClient.socket, {\n secureContext: tls.createSecureContext({\n secureProtocol: 'TLSv1_method',\n cert: pairRecord.RootCertificate,\n key: pairRecord.RootPrivateKey,\n }),\n });\n debug(`Socket upgraded to TLS connection`);\n }\n // TODO: save sessionID for StopSession?\n } else {\n throw new ResponseError('Error starting session', resp);\n }\n }\n\n async getAllValues() {\n debug(`getAllValues`);\n\n const resp = await this.protocolClient.sendMessage({ Request: 'GetValue' });\n\n if (isLockdowndAllValuesResponse(resp)) {\n return resp.Value;\n } else {\n throw new ResponseError('Error getting lockdown value', resp);\n }\n }\n\n async getValue(val: string) {\n debug(`getValue: ${val}`);\n\n const resp = await this.protocolClient.sendMessage({\n Request: 'GetValue',\n Key: val,\n });\n\n if (isLockdowndValueResponse(resp)) {\n return resp.Value;\n } else {\n throw new ResponseError('Error getting lockdown value', resp);\n }\n }\n\n async queryType() {\n debug('queryType');\n\n const resp = await this.protocolClient.sendMessage({\n Request: 'QueryType',\n });\n\n if (isLockdowndQueryTypeResponse(resp)) {\n return resp.Type;\n } else {\n throw new ResponseError('Error getting lockdown query type', resp);\n }\n }\n\n async doHandshake(pairRecord: UsbmuxdPairRecord) {\n debug('doHandshake');\n\n // if (await this.lockdownQueryType() !== 'com.apple.mobile.lockdown') {\n // throw new CommandError('Invalid type received from lockdown handshake');\n // }\n // await this.getLockdownValue('ProductVersion');\n // TODO: validate pair and pair\n await this.startSession(pairRecord);\n }\n}\n"],"names":["tls","debug","Debug","isLockdowndServiceResponse","resp","Request","Service","undefined","Port","isLockdowndSessionResponse","isLockdowndAllValuesResponse","Value","isLockdowndValueResponse","Key","isLockdowndQueryTypeResponse","Type","LockdowndClient","ServiceClient","constructor","socket","LockdownProtocolClient","startService","name","protocolClient","sendMessage","port","enableServiceSSL","EnableServiceSSL","ResponseError","startSession","pairRecord","HostID","SystemBUID","EnableSessionSSL","TLSSocket","secureContext","createSecureContext","secureProtocol","cert","RootCertificate","key","RootPriv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;SAClB,MAAM;YACL,MAAM,IAAIa,cAAa,cAAA,CAAC,mCAAmC,EAAExB,IAAI,CAAC,CAAC;SACpE;KACF;IAED,MAAM0C,WAAW,CAAChB,UAA6B,EAAE;QAC/C7B,KAAK,CAAC,aAAa,CAAC,CAAC;QAErB,wEAAwE;QACxE,6EAA6E;QAC7E,IAAI;QACJ,iDAAiD;QACjD,+BAA+B;QAC/B,MAAM,IAAI,CAAC4B,YAAY,CAACC,UAAU,CAAC,CAAC;KACrC;CACF;QAjGYd,eAAe,GAAfA,eAAe"}
@@ -0,0 +1,91 @@
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 _lockdownProtocol = require("../protocol/LockdownProtocol");
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:mobile_image_mounter");
36
+ function isMIMUploadCompleteResponse(resp) {
37
+ return resp.Status === "Complete";
38
+ }
39
+ function isMIMUploadReceiveBytesResponse(resp) {
40
+ return resp.Status === "ReceiveBytesAck";
41
+ }
42
+ class MobileImageMounterClient extends _serviceClient.ServiceClient {
43
+ constructor(socket){
44
+ super(socket, new _lockdownProtocol.LockdownProtocolClient(socket));
45
+ }
46
+ async mountImage(imagePath, imageSig) {
47
+ debug(`mountImage: ${imagePath}`);
48
+ const resp = await this.protocolClient.sendMessage({
49
+ Command: "MountImage",
50
+ ImagePath: imagePath,
51
+ ImageSignature: imageSig,
52
+ ImageType: "Developer"
53
+ });
54
+ if (!(0, _lockdownProtocol).isLockdownResponse(resp) || resp.Status !== "Complete") {
55
+ throw new _serviceClient.ResponseError(`There was an error mounting ${imagePath} on device`, resp);
56
+ }
57
+ }
58
+ async uploadImage(imagePath, imageSig) {
59
+ debug(`uploadImage: ${imagePath}`);
60
+ const imageSize = fs.statSync(imagePath).size;
61
+ return this.protocolClient.sendMessage({
62
+ Command: "ReceiveBytes",
63
+ ImageSize: imageSize,
64
+ ImageSignature: imageSig,
65
+ ImageType: "Developer"
66
+ }, (resp, resolve, reject)=>{
67
+ if (isMIMUploadReceiveBytesResponse(resp)) {
68
+ const imageStream = fs.createReadStream(imagePath);
69
+ imageStream.pipe(this.protocolClient.socket, {
70
+ end: false
71
+ });
72
+ imageStream.on("error", (err)=>reject(err)
73
+ );
74
+ } else if (isMIMUploadCompleteResponse(resp)) {
75
+ resolve();
76
+ } else {
77
+ reject(new _serviceClient.ResponseError(`There was an error uploading image ${imagePath} to the device`, resp));
78
+ }
79
+ });
80
+ }
81
+ async lookupImage() {
82
+ debug("lookupImage");
83
+ return this.protocolClient.sendMessage({
84
+ Command: "LookupImage",
85
+ ImageType: "Developer"
86
+ });
87
+ }
88
+ }
89
+ exports.MobileImageMounterClient = MobileImageMounterClient;
90
+
91
+ //# sourceMappingURL=MobileImageMounterClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/run/ios/appleDevice/client/MobileImageMounterClient.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';\n\nimport type { LockdownCommand, LockdownResponse } from '../protocol/LockdownProtocol';\nimport { isLockdownResponse, LockdownProtocolClient } from '../protocol/LockdownProtocol';\nimport { ResponseError, ServiceClient } from './ServiceClient';\n\nconst debug = Debug('expo:apple-device:client:mobile_image_mounter');\n\nexport type MIMMountResponse = LockdownResponse;\n\nexport interface MIMMessage extends LockdownCommand {\n ImageType: string;\n}\n\nexport interface MIMLookupResponse extends LockdownResponse {\n ImageSignature?: string;\n}\n\nexport interface MIMUploadCompleteResponse extends LockdownResponse {\n Status: 'Complete';\n}\n\nexport interface MIMUploadReceiveBytesResponse extends LockdownResponse {\n Status: 'ReceiveBytesAck';\n}\n\nfunction isMIMUploadCompleteResponse(resp: any): resp is MIMUploadCompleteResponse {\n return resp.Status === 'Complete';\n}\n\nfunction isMIMUploadReceiveBytesResponse(resp: any): resp is MIMUploadReceiveBytesResponse {\n return resp.Status === 'ReceiveBytesAck';\n}\n\nexport class MobileImageMounterClient extends ServiceClient<LockdownProtocolClient<MIMMessage>> {\n constructor(socket: Socket) {\n super(socket, new LockdownProtocolClient(socket));\n }\n\n async mountImage(imagePath: string, imageSig: Buffer) {\n debug(`mountImage: ${imagePath}`);\n\n const resp = await this.protocolClient.sendMessage({\n Command: 'MountImage',\n ImagePath: imagePath,\n ImageSignature: imageSig,\n ImageType: 'Developer',\n });\n\n if (!isLockdownResponse(resp) || resp.Status !== 'Complete') {\n throw new ResponseError(`There was an error mounting ${imagePath} on device`, resp);\n }\n }\n\n async uploadImage(imagePath: string, imageSig: Buffer) {\n debug(`uploadImage: ${imagePath}`);\n\n const imageSize = fs.statSync(imagePath).size;\n return this.protocolClient.sendMessage(\n {\n Command: 'ReceiveBytes',\n ImageSize: imageSize,\n ImageSignature: imageSig,\n ImageType: 'Developer',\n },\n (resp: any, resolve, reject) => {\n if (isMIMUploadReceiveBytesResponse(resp)) {\n const imageStream = fs.createReadStream(imagePath);\n imageStream.pipe(this.protocolClient.socket, { end: false });\n imageStream.on('error', (err) => reject(err));\n } else if (isMIMUploadCompleteResponse(resp)) {\n resolve();\n } else {\n reject(\n new ResponseError(`There was an error uploading image ${imagePath} to the device`, resp)\n );\n }\n }\n );\n }\n\n async lookupImage() {\n debug('lookupImage');\n\n return this.protocolClient.sendMessage<MIMLookupResponse>({\n Command: 'LookupImage',\n ImageType: 'Developer',\n });\n }\n}\n"],"names":["fs","debug","Debug","isMIMUploadCompleteResponse","resp","Status","isMIMUploadReceiveBytesResponse","MobileImageMounterClient","ServiceClient","constructor","socket","LockdownProtocolClient","mountImage","imagePath","imageSig","protocolClient","sendMessage","Command","ImagePath","ImageSignature","ImageType","isLockdownResponse","ResponseError","uploadImage","imageSize","statSync","size","ImageSize","resolve","reject","imageStream","createReadStream","pipe","end","on","err","lookupImage"],"mappings":"AAOA;;;;AAAkB,IAAA,MAAO,kCAAP,OAAO,EAAA;AACbA,IAAAA,EAAE,mCAAM,IAAI,EAAV;AAI6C,IAAA,iBAA8B,WAA9B,8BAA8B,CAAA;AAC5C,IAAA,cAAiB,WAAjB,iBAAiB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE9D,MAAMC,KAAK,GAAGC,CAAAA,GAAAA,MAAK,AAAiD,CAAA,QAAjD,CAAC,+CAA+C,CAAC,AAAC;AAoBrE,SAASC,2BAA2B,CAACC,IAAS,EAAqC;IACjF,OAAOA,IAAI,CAACC,MAAM,KAAK,UAAU,CAAC;CACnC;AAED,SAASC,+BAA+B,CAACF,IAAS,EAAyC;IACzF,OAAOA,IAAI,CAACC,MAAM,KAAK,iBAAiB,CAAC;CAC1C;AAEM,MAAME,wBAAwB,SAASC,cAAa,cAAA;IACzDC,YAAYC,MAAc,CAAE;QAC1B,KAAK,CAACA,MAAM,EAAE,IAAIC,iBAAsB,uBAAA,CAACD,MAAM,CAAC,CAAC,CAAC;KACnD;IAED,MAAME,UAAU,CAACC,SAAiB,EAAEC,QAAgB,EAAE;QACpDb,KA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AAG,CAAC;gBAAA,CAAC,CAAC;aAC/C,MAAM,IAAIhC,2BAA2B,CAACC,IAAI,CAAC,EAAE;gBAC5CwB,OAAO,EAAE,CAAC;aACX,MAAM;gBACLC,MAAM,CACJ,IAAIP,cAAa,cAAA,CAAC,CAAC,mCAAmC,EAAET,SAAS,CAAC,cAAc,CAAC,EAAET,IAAI,CAAC,CACzF,CAAC;aACH;SACF,CACF,CAAC;KACH;IAED,MAAMgC,WAAW,GAAG;QAClBnC,KAAK,CAAC,aAAa,CAAC,CAAC;QAErB,OAAO,IAAI,CAACc,cAAc,CAACC,WAAW,CAAoB;YACxDC,OAAO,EAAE,aAAa;YACtBG,SAAS,EAAE,WAAW;SACvB,CAAC,CAAC;KACJ;CACF;QAvDYb,wBAAwB,GAAxBA,wBAAwB"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ var _errors = require("../../../../utils/errors");
6
+ class ServiceClient {
7
+ constructor(socket, protocolClient){
8
+ this.socket = socket;
9
+ this.protocolClient = protocolClient;
10
+ }
11
+ }
12
+ exports.ServiceClient = ServiceClient;
13
+ class ResponseError extends _errors.CommandError {
14
+ constructor(msg, response){
15
+ super(msg);
16
+ this.response = response;
17
+ }
18
+ }
19
+ exports.ResponseError = ResponseError;
20
+
21
+ //# sourceMappingURL=ServiceClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/run/ios/appleDevice/client/ServiceClient.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';\n\nimport { CommandError } from '../../../../utils/errors';\nimport { ProtocolClient } from '../protocol/AbstractProtocol';\n\nexport abstract class ServiceClient<T extends ProtocolClient> {\n constructor(public socket: Socket, protected protocolClient: T) {}\n}\n\nexport class ResponseError extends CommandError {\n constructor(msg: string, public response: any) {\n super(msg);\n }\n}\n"],"names":["ServiceClient","constructor","socket","protocolClient","ResponseError","CommandError","msg","response"],"mappings":"AAOA;;;;AAE6B,IAAA,OAA0B,WAA1B,0BAA0B,CAAA;AAGhD,MAAeA,aAAa;IACjCC,YAAmBC,MAAc,EAAYC,cAAiB,CAAE;aAA7CD,MAAc,GAAdA,MAAc;aAAYC,cAAiB,GAAjBA,cAAiB;KAAI;CACnE;QAFqBH,aAAa,GAAbA,aAAa;AAI5B,MAAMI,aAAa,SAASC,OAAY,aAAA;IAC7CJ,YAAYK,GAAW,EAASC,QAAa,CAAE;QAC7C,KAAK,CAACD,GAAG,CAAC,CAAC;aADmBC,QAAa,GAAbA,QAAa;KAE5C;CACF;QAJYH,aAAa,GAAbA,aAAa"}
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ var _plist = _interopRequireDefault(require("@expo/plist"));
6
+ var _debug = _interopRequireDefault(require("debug"));
7
+ var _net = require("net");
8
+ var _errors = require("../../../../utils/errors");
9
+ var _plist1 = require("../../../../utils/plist");
10
+ var _usbmuxProtocol = require("../protocol/UsbmuxProtocol");
11
+ var _serviceClient = require("./ServiceClient");
12
+ function _interopRequireDefault(obj) {
13
+ return obj && obj.__esModule ? obj : {
14
+ default: obj
15
+ };
16
+ }
17
+ const debug = (0, _debug).default("expo:apple-device:client:usbmuxd");
18
+ function isUsbmuxdConnectResponse(resp) {
19
+ return resp.MessageType === "Result" && resp.Number !== undefined;
20
+ }
21
+ function isUsbmuxdDeviceResponse(resp) {
22
+ return resp.DeviceList !== undefined;
23
+ }
24
+ function isUsbmuxdPairRecordResponse(resp) {
25
+ return resp.PairRecordData !== undefined;
26
+ }
27
+ class UsbmuxdClient extends _serviceClient.ServiceClient {
28
+ constructor(socket){
29
+ super(socket, new _usbmuxProtocol.UsbmuxProtocolClient(socket));
30
+ this.socket = socket;
31
+ }
32
+ static connectUsbmuxdSocket() {
33
+ debug("connectUsbmuxdSocket");
34
+ if (process.platform === "win32") {
35
+ return (0, _net).connect({
36
+ port: 27015,
37
+ host: "localhost"
38
+ });
39
+ } else {
40
+ return (0, _net).connect({
41
+ path: "/var/run/usbmuxd"
42
+ });
43
+ }
44
+ }
45
+ async connect(device, port) {
46
+ debug(`connect: ${device.DeviceID} on port ${port}`);
47
+ debug(`connect:device: %O`, device);
48
+ const response = await this.protocolClient.sendMessage({
49
+ messageType: "Connect",
50
+ extraFields: {
51
+ DeviceID: device.DeviceID,
52
+ PortNumber: htons(port)
53
+ }
54
+ });
55
+ debug(`connect:device:response: %O`, response);
56
+ if (isUsbmuxdConnectResponse(response) && response.Number === 0) {
57
+ return this.protocolClient.socket;
58
+ } else {
59
+ throw new _serviceClient.ResponseError(`There was an error connecting to the USB connected device (id: ${device.DeviceID}, port: ${port})`, response);
60
+ }
61
+ }
62
+ async getDevices() {
63
+ debug("getDevices");
64
+ const resp = await this.protocolClient.sendMessage({
65
+ messageType: "ListDevices"
66
+ });
67
+ if (isUsbmuxdDeviceResponse(resp)) {
68
+ return resp.DeviceList;
69
+ } else {
70
+ throw new _serviceClient.ResponseError("Invalid response from getDevices", resp);
71
+ }
72
+ }
73
+ async getDevice(udid) {
74
+ debug(`getDevice ${udid ? "udid: " + udid : ""}`);
75
+ const devices = await this.getDevices();
76
+ if (!devices.length) {
77
+ throw new _errors.CommandError("APPLE_DEVICE_USBMUXD", "No devices found");
78
+ }
79
+ if (!udid) {
80
+ return devices[0];
81
+ }
82
+ for (const device of devices){
83
+ if (device.Properties && device.Properties.SerialNumber === udid) {
84
+ return device;
85
+ }
86
+ }
87
+ throw new _errors.CommandError("APPLE_DEVICE_USBMUXD", `No device found (udid: ${udid})`);
88
+ }
89
+ async readPairRecord(udid) {
90
+ debug(`readPairRecord: ${udid}`);
91
+ const resp = await this.protocolClient.sendMessage({
92
+ messageType: "ReadPairRecord",
93
+ extraFields: {
94
+ PairRecordID: udid
95
+ }
96
+ });
97
+ if (isUsbmuxdPairRecordResponse(resp)) {
98
+ // the pair record can be created as a binary plist
99
+ const BPLIST_MAGIC = Buffer.from("bplist00");
100
+ if (BPLIST_MAGIC.compare(resp.PairRecordData, 0, 8) === 0) {
101
+ debug("Binary plist pair record detected.");
102
+ return (0, _plist1).parsePlistBuffer(resp.PairRecordData)[0];
103
+ } else {
104
+ // TODO: use parsePlistBuffer
105
+ return _plist.default.parse(resp.PairRecordData.toString()); // TODO: type guard
106
+ }
107
+ } else {
108
+ throw new _serviceClient.ResponseError(`There was an error reading pair record for device (udid: ${udid})`, resp);
109
+ }
110
+ }
111
+ }
112
+ exports.UsbmuxdClient = UsbmuxdClient;
113
+ function htons(n) {
114
+ return (n & 255) << 8 | n >> 8 & 255;
115
+ }
116
+
117
+ //# sourceMappingURL=UsbmuxdClient.js.map