lim 0.36.0 → 0.37.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/dist/commands/android/ca/add.d.ts +20 -0
- package/dist/commands/android/ca/add.d.ts.map +1 -0
- package/dist/commands/android/ca/add.js +59 -0
- package/dist/commands/android/ca/add.js.map +1 -0
- package/dist/commands/android/ca/add.test.d.ts +2 -0
- package/dist/commands/android/ca/add.test.d.ts.map +1 -0
- package/dist/commands/android/ca/add.test.js +44 -0
- package/dist/commands/android/ca/add.test.js.map +1 -0
- package/package.json +6 -3
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base-command';
|
|
2
|
+
export default class AndroidCaAdd extends BaseCommand {
|
|
3
|
+
static summary: string;
|
|
4
|
+
static description: string;
|
|
5
|
+
static examples: string[];
|
|
6
|
+
static args: {
|
|
7
|
+
path: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
8
|
+
};
|
|
9
|
+
static flags: {
|
|
10
|
+
id: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
|
+
'api-key': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
12
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
quiet: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
14
|
+
create: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
15
|
+
workspace: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
16
|
+
daemon: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
17
|
+
};
|
|
18
|
+
run(): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=add.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../../src/commands/android/ca/add.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGpD,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,WAAW;IACnD,MAAM,CAAC,OAAO,SAA0D;IACxE,MAAM,CAAC,WAAW,SAG0E;IAE5F,MAAM,CAAC,QAAQ,WAGb;IAEF,MAAM,CAAC,IAAI;;MAKT;IAEF,MAAM,CAAC,KAAK;;;;;;;;MAKV;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAwB3B"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const fs_1 = __importDefault(require("fs"));
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const core_1 = require("@oclif/core");
|
|
9
|
+
const base_command_1 = require("../../../base-command");
|
|
10
|
+
const instance_client_factory_1 = require("../../../lib/instance-client-factory");
|
|
11
|
+
class AndroidCaAdd extends base_command_1.BaseCommand {
|
|
12
|
+
async run() {
|
|
13
|
+
const { args, flags } = await this.parse(AndroidCaAdd);
|
|
14
|
+
this.setParsedFlags(flags);
|
|
15
|
+
const localPath = path_1.default.resolve(args.path);
|
|
16
|
+
if (!fs_1.default.existsSync(localPath)) {
|
|
17
|
+
this.error(`File not found: ${localPath}`);
|
|
18
|
+
}
|
|
19
|
+
const pem = fs_1.default.readFileSync(localPath, 'utf8');
|
|
20
|
+
await this.withAuth(async () => {
|
|
21
|
+
const resolvedInstance = this.resolveAndroidInstance(flags.id);
|
|
22
|
+
const { client, disconnect } = await (0, instance_client_factory_1.getAndroidInstanceClient)(this.client, resolvedInstance);
|
|
23
|
+
try {
|
|
24
|
+
const trusted = await client.addCaCertificate(pem);
|
|
25
|
+
if (flags.json) {
|
|
26
|
+
this.outputJson(trusted);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
this.output(`Trusted ${trusted.filename} (SHA-256 ${trusted.sha256})`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
disconnect();
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
AndroidCaAdd.summary = 'Trust a CA certificate on a running Android instance';
|
|
39
|
+
AndroidCaAdd.description = "Add a PEM-encoded CA certificate to the device's trust stores, for example the CA of an " +
|
|
40
|
+
'intercepting proxy you record traffic with. Apps, WebViews and the Chrome browser trust it on their ' +
|
|
41
|
+
'next connection, without a restart. The certificate lasts for the life of the instance.';
|
|
42
|
+
AndroidCaAdd.examples = [
|
|
43
|
+
'<%= config.bin %> android ca add ./proxy-ca.pem',
|
|
44
|
+
'<%= config.bin %> android ca add ./proxy-ca.pem --id <instance-ID>',
|
|
45
|
+
];
|
|
46
|
+
AndroidCaAdd.args = {
|
|
47
|
+
path: core_1.Args.string({
|
|
48
|
+
description: 'Local PEM file holding one CA certificate.',
|
|
49
|
+
required: true,
|
|
50
|
+
}),
|
|
51
|
+
};
|
|
52
|
+
AndroidCaAdd.flags = {
|
|
53
|
+
...base_command_1.BaseCommand.baseFlags,
|
|
54
|
+
id: core_1.Flags.string({
|
|
55
|
+
description: 'Android instance ID to target. Defaults to the last created Android instance.',
|
|
56
|
+
}),
|
|
57
|
+
};
|
|
58
|
+
exports.default = AndroidCaAdd;
|
|
59
|
+
//# sourceMappingURL=add.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.js","sourceRoot":"","sources":["../../../../src/commands/android/ca/add.ts"],"names":[],"mappings":";;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,sCAA0C;AAC1C,wDAAoD;AACpD,kFAAgF;AAEhF,MAAqB,YAA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1F,sGAAsG;IACtG,yFAAyF,CAAC;AAErF,qBAAQ,GAAG;IAChB,iDAAiD;IACjD,oEAAoE;CACrE,CAAC;AAEK,iBAAI,GAAG;IACZ,IAAI,EAAE,WAAI,CAAC,MAAM,CAAC;QAChB,WAAW,EAAE,4CAA4C;QACzD,QAAQ,EAAE,IAAI;KACf,CAAC;CACH,CAAC;AAEK,kBAAK,GAAG;IACb,GAAG,0BAAW,CAAC,SAAS;IACxB,EAAE,EAAE,YAAK,CAAC,MAAM,CAAC;QACf,WAAW,EAAE,+EAA+E;KAC7F,CAAC;CACH,CAAC;kBAxBiB,YAAY"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.test.d.ts","sourceRoot":"","sources":["../../../../src/commands/android/ca/add.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const fs_1 = __importDefault(require("fs"));
|
|
7
|
+
const os_1 = __importDefault(require("os"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const add_1 = __importDefault(require("./add"));
|
|
10
|
+
const instance_client_factory_1 = require("../../../lib/instance-client-factory");
|
|
11
|
+
jest.mock('../../../lib/instance-client-factory', () => ({ getAndroidInstanceClient: jest.fn() }));
|
|
12
|
+
function setup(pemPath) {
|
|
13
|
+
const client = { addCaCertificate: jest.fn().mockResolvedValue({ filename: '8c1d60e6.0', sha256: 'ab' }) };
|
|
14
|
+
const disconnect = jest.fn();
|
|
15
|
+
jest.mocked(instance_client_factory_1.getAndroidInstanceClient).mockResolvedValue({ client, disconnect });
|
|
16
|
+
const command = Object.assign(Object.create(add_1.default.prototype), {
|
|
17
|
+
parse: async () => ({ args: { path: pemPath }, flags: { json: true, id: 'android_test' } }),
|
|
18
|
+
setParsedFlags: jest.fn(),
|
|
19
|
+
withAuth: async (run) => run(),
|
|
20
|
+
resolveAndroidInstance: () => 'android_test',
|
|
21
|
+
outputJson: jest.fn(),
|
|
22
|
+
error: (message) => {
|
|
23
|
+
throw new Error(message);
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(command, 'client', { value: {} });
|
|
27
|
+
return { command, client, disconnect };
|
|
28
|
+
}
|
|
29
|
+
beforeEach(() => jest.clearAllMocks());
|
|
30
|
+
test('sends the PEM file to the instance and reports the stored certificate', async () => {
|
|
31
|
+
const pemPath = path_1.default.join(fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'lim-ca-')), 'ca.pem');
|
|
32
|
+
fs_1.default.writeFileSync(pemPath, '-----BEGIN CERTIFICATE-----\nMIIB\n-----END CERTIFICATE-----\n');
|
|
33
|
+
const { command, client, disconnect } = setup(pemPath);
|
|
34
|
+
await command.run();
|
|
35
|
+
expect(client.addCaCertificate).toHaveBeenCalledWith(fs_1.default.readFileSync(pemPath, 'utf8'));
|
|
36
|
+
expect(command.outputJson).toHaveBeenCalledWith({ filename: '8c1d60e6.0', sha256: 'ab' });
|
|
37
|
+
expect(disconnect).toHaveBeenCalledTimes(1);
|
|
38
|
+
});
|
|
39
|
+
test('refuses a missing file before connecting', async () => {
|
|
40
|
+
const { command } = setup('/does/not/exist.pem');
|
|
41
|
+
await expect(command.run()).rejects.toThrow('File not found: /does/not/exist.pem');
|
|
42
|
+
expect(instance_client_factory_1.getAndroidInstanceClient).not.toHaveBeenCalled();
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=add.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.test.js","sourceRoot":"","sources":["../../../../src/commands/android/ca/add.test.ts"],"names":[],"mappings":";;;;;AAAA,4CAAoB;AACpB,4CAAoB;AACpB,gDAAwB;AACxB,gDAAiC;AACjC,kFAAg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,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lim",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"description": "Use remote XCode, Gradle, iOS Simulator, Android Emulator and more to build and test apps from Linux, Windows or macOS.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"lim": "./bin/run.js"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"test": "jest"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@limrun/api": "0.
|
|
28
|
+
"@limrun/api": "0.57.0",
|
|
29
29
|
"@oclif/core": "^4",
|
|
30
30
|
"cli-progress": "^3.12.0",
|
|
31
31
|
"cli-table3": "^0.6.5",
|
|
@@ -54,7 +54,10 @@
|
|
|
54
54
|
"topicSeparator": " ",
|
|
55
55
|
"topics": {
|
|
56
56
|
"android": {
|
|
57
|
-
"description": "Execute any task on remote Android Emulators: create, list, get, delete, connect, sync, screenshot, tap, tap-element, find-element, element-tree, type, press-key, scroll, open-url, install-app, launch-app, terminate-app, app-log, logcat, record, play-on-microphone, set-wifi-bandwidth, adb-shell"
|
|
57
|
+
"description": "Execute any task on remote Android Emulators: create, list, get, delete, connect, sync, screenshot, tap, tap-element, find-element, element-tree, type, press-key, scroll, open-url, install-app, launch-app, terminate-app, app-log, logcat, record, play-on-microphone, set-wifi-bandwidth, adb-shell, ca"
|
|
58
|
+
},
|
|
59
|
+
"android:ca": {
|
|
60
|
+
"description": "Trust CA certificates on a running Android instance: add"
|
|
58
61
|
},
|
|
59
62
|
"asset": {
|
|
60
63
|
"description": "Upload, download, list, inspect, and delete files that can be used by iOS & Android as pre-installed apps: push, pull, list, delete"
|