@limrun/api 0.55.0 → 0.57.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.
Files changed (43) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/instance-client.d.mts +8 -0
  3. package/instance-client.d.mts.map +1 -1
  4. package/instance-client.d.ts +8 -0
  5. package/instance-client.d.ts.map +1 -1
  6. package/instance-client.js +5 -2
  7. package/instance-client.js.map +1 -1
  8. package/instance-client.mjs +5 -2
  9. package/instance-client.mjs.map +1 -1
  10. package/internal/destination-tunnel-url.d.mts +2 -0
  11. package/internal/destination-tunnel-url.d.mts.map +1 -1
  12. package/internal/destination-tunnel-url.d.ts +2 -0
  13. package/internal/destination-tunnel-url.d.ts.map +1 -1
  14. package/internal/destination-tunnel-url.js +17 -17
  15. package/internal/destination-tunnel-url.js.map +1 -1
  16. package/internal/destination-tunnel-url.mjs +16 -17
  17. package/internal/destination-tunnel-url.mjs.map +1 -1
  18. package/internal/trusted-ca.d.mts +13 -0
  19. package/internal/trusted-ca.d.mts.map +1 -0
  20. package/internal/trusted-ca.d.ts +13 -0
  21. package/internal/trusted-ca.d.ts.map +1 -0
  22. package/internal/trusted-ca.js +22 -0
  23. package/internal/trusted-ca.js.map +1 -0
  24. package/internal/trusted-ca.mjs +19 -0
  25. package/internal/trusted-ca.mjs.map +1 -0
  26. package/ios-client.d.mts +11 -3
  27. package/ios-client.d.mts.map +1 -1
  28. package/ios-client.d.ts +11 -3
  29. package/ios-client.d.ts.map +1 -1
  30. package/ios-client.js +3 -1
  31. package/ios-client.js.map +1 -1
  32. package/ios-client.mjs +3 -1
  33. package/ios-client.mjs.map +1 -1
  34. package/package.json +1 -1
  35. package/src/instance-client.ts +16 -2
  36. package/src/internal/destination-tunnel-url.ts +17 -17
  37. package/src/internal/trusted-ca.ts +31 -0
  38. package/src/ios-client.ts +18 -3
  39. package/src/version.ts +1 -1
  40. package/version.d.mts +1 -1
  41. package/version.d.ts +1 -1
  42. package/version.js +1 -1
  43. package/version.mjs +1 -1
@@ -0,0 +1,31 @@
1
+ import { deriveAdbHttpURL } from './destination-tunnel-url';
2
+ import { nodeProxyTransport } from './proxy-transport';
3
+
4
+ /** A CA certificate the device now trusts. */
5
+ export interface TrustedCaCertificate {
6
+ /** File name in Android's system store: the subject hash plus a suffix. */
7
+ filename: string;
8
+ /** SHA-256 of the certificate's DER encoding, in hex. */
9
+ sha256: string;
10
+ }
11
+
12
+ /**
13
+ * Adds a PEM CA certificate to an Android instance's trust stores
14
+ * through websocket-proxy, which answers on the instance's ADB URL.
15
+ */
16
+ export async function addTrustedCaCertificate(
17
+ adbUrl: string,
18
+ token: string,
19
+ pem: string,
20
+ ): Promise<TrustedCaCertificate> {
21
+ const response = await nodeProxyTransport.fetch(deriveAdbHttpURL(adbUrl, 'trusted-cas').toString(), {
22
+ method: 'POST',
23
+ headers: { 'Content-Type': 'application/x-pem-file', Authorization: `Bearer ${token}` },
24
+ body: pem,
25
+ });
26
+ if (!response.ok) {
27
+ const reason = (await response.text()).trim();
28
+ throw new Error(`Adding the CA certificate failed (${response.status}): ${reason}`);
29
+ }
30
+ return (await response.json()) as TrustedCaCertificate;
31
+ }
package/src/ios-client.ts CHANGED
@@ -1024,6 +1024,7 @@ export type InstanceClient = {
1024
1024
  * @param args Arguments to pass to simctl
1025
1025
  * @param opts Options for the simctl execution
1026
1026
  * @param opts.disconnectOnExit If true, disconnect from the instance when the command completes
1027
+ * @param opts.stdin Data written to the command's standard input, which is then closed
1027
1028
  * @returns A SimctlExecution handle for listening to command output
1028
1029
  *
1029
1030
  * @example
@@ -1057,7 +1058,7 @@ export type InstanceClient = {
1057
1058
  * const execution2 = client.simctl(['status'], { disconnectOnExit: true });
1058
1059
  * ```
1059
1060
  */
1060
- simctl: (args: string[], opts?: { disconnectOnExit?: boolean }) => SimctlExecution;
1061
+ simctl: (args: string[], opts?: SimctlOptions) => SimctlExecution;
1061
1062
 
1062
1063
  /**
1063
1064
  * Push a local file to the simulator. Returns the path of the file on the simulator host
@@ -1268,11 +1269,23 @@ type PendingRequest<T> = {
1268
1269
  transform?: (message: ServerResponse) => T;
1269
1270
  };
1270
1271
 
1272
+ /**
1273
+ * Options for a simctl execution
1274
+ */
1275
+ export type SimctlOptions = {
1276
+ /** Disconnect from the instance when the command completes */
1277
+ disconnectOnExit?: boolean;
1278
+ /** Data written to the command's standard input, which is then closed */
1279
+ stdin?: string | Buffer;
1280
+ };
1281
+
1271
1282
  // Simctl uses streaming, so it's handled separately
1272
1283
  type SimctlRequest = {
1273
1284
  type: 'simctl';
1274
1285
  id: string;
1275
1286
  args: string[];
1287
+ /** Base64 of the command's standard input */
1288
+ stdin?: string;
1276
1289
  };
1277
1290
 
1278
1291
  /**
@@ -2609,7 +2622,7 @@ export async function createInstanceClient(options: InstanceClientOptions): Prom
2609
2622
  // Cached device info, populated during connection
2610
2623
  let cachedDeviceInfo: DeviceInfo;
2611
2624
 
2612
- const simctl = (args: string[], opts: { disconnectOnExit?: boolean } = {}): SimctlExecution => {
2625
+ const simctl = (args: string[], opts: SimctlOptions = {}): SimctlExecution => {
2613
2626
  const id = generateId();
2614
2627
 
2615
2628
  const cancelCallback = () => {
@@ -2651,9 +2664,11 @@ export async function createInstanceClient(options: InstanceClientOptions): Prom
2651
2664
  type: 'simctl',
2652
2665
  id,
2653
2666
  args,
2667
+ ...(opts.stdin !== undefined && { stdin: Buffer.from(opts.stdin).toString('base64') }),
2654
2668
  };
2655
2669
 
2656
- logger.debug('Sending simctl request:', simctlRequest);
2670
+ // stdin can carry secrets such as one-time codes, so it stays out of the log.
2671
+ logger.debug('Sending simctl request:', { ...simctlRequest, stdin: undefined });
2657
2672
  ws.send(JSON.stringify(simctlRequest), (err?: Error) => {
2658
2673
  if (err) {
2659
2674
  logger.error('Failed to send simctl request:', err);
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.55.0'; // x-release-please-version
1
+ export const VERSION = '0.57.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.55.0";
1
+ export declare const VERSION = "0.57.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.55.0";
1
+ export declare const VERSION = "0.57.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '0.55.0'; // x-release-please-version
4
+ exports.VERSION = '0.57.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.55.0'; // x-release-please-version
1
+ export const VERSION = '0.57.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map