@devicecloud.dev/dcd 5.14.0-beta.1 → 5.14.1
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/cloud.d.ts +1 -1
- package/dist/commands/cloud.js +2 -2
- package/dist/commands/device.js +91 -2
- package/dist/commands/live.js +1 -1
- package/dist/config/flags/device.flags.d.ts +1 -1
- package/dist/config/flags/device.flags.js +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/gateways/cli-auth-gateway.d.ts +16 -5
- package/dist/gateways/cli-auth-gateway.js +53 -52
- package/dist/gateways/device-gateway.d.ts +1 -1
- package/dist/gateways/device-gateway.js +1 -1
- package/dist/services/telemetry.service.d.ts +17 -0
- package/dist/services/telemetry.service.js +35 -4
- package/dist/types/domain/device-session.types.d.ts +10 -0
- package/dist/utils/auth.js +1 -1
- package/package.json +7 -37
package/dist/commands/cloud.d.ts
CHANGED
|
@@ -176,7 +176,7 @@ export declare const cloudCommand: import("citty").CommandDef<{
|
|
|
176
176
|
};
|
|
177
177
|
readonly 'device-locale': {
|
|
178
178
|
readonly type: "string";
|
|
179
|
-
readonly description: "Locale that will be set to a device
|
|
179
|
+
readonly description: "Locale that will be set to a device: a 2-3 letter lowercase language code (ISO 639) and an uppercase ISO-3166-1 country code, e.g. \"de_DE\" for Germany";
|
|
180
180
|
};
|
|
181
181
|
readonly 'google-play': {
|
|
182
182
|
readonly type: "boolean";
|
package/dist/commands/cloud.js
CHANGED
|
@@ -280,10 +280,10 @@ export const cloudCommand = defineCommand({
|
|
|
280
280
|
retry = 2;
|
|
281
281
|
}
|
|
282
282
|
if (runnerType === 'm4') {
|
|
283
|
-
out(ui.info('runnerType m4 is experimental and currently supports iOS only
|
|
283
|
+
out(ui.info('runnerType m4 is experimental and currently supports iOS only. Android runs with m4 are rejected: use default or cpu1 for Android.'));
|
|
284
284
|
}
|
|
285
285
|
if (runnerType === 'm1') {
|
|
286
|
-
out(ui.info('runnerType m1 is experimental and currently
|
|
286
|
+
out(ui.info('runnerType m1 is experimental and currently applies to Android only (API level 34-37, every device except generic-tablet). iOS runs on M1 by default.'));
|
|
287
287
|
}
|
|
288
288
|
const firstFile = args.firstFile;
|
|
289
289
|
const secondFile = args.secondFile;
|
package/dist/commands/device.js
CHANGED
|
@@ -598,6 +598,33 @@ function percentArg(value, flag) {
|
|
|
598
598
|
}
|
|
599
599
|
return n;
|
|
600
600
|
}
|
|
601
|
+
/** The longest a tap may wait for its target, as the API allows. */
|
|
602
|
+
const MAX_TAP_TIMEOUT_SECONDS = 60;
|
|
603
|
+
/** Seconds from a flag value, from 0 to `max`, or a usage error. Undefined when the flag was not given. */
|
|
604
|
+
function secondsArg(value, flag, max) {
|
|
605
|
+
if (value === undefined)
|
|
606
|
+
return undefined;
|
|
607
|
+
const n = typeof value === 'number' ? value : Number(value);
|
|
608
|
+
if (typeof value === 'boolean' || value === '' || !Number.isFinite(n) || n < 0 || n > max) {
|
|
609
|
+
throw new CliError(`--${flag} must be a number of seconds from 0 to ${max}.`, 1);
|
|
610
|
+
}
|
|
611
|
+
return n;
|
|
612
|
+
}
|
|
613
|
+
/** Decimal degrees from a flag value, within `limit` either way, or a usage error. */
|
|
614
|
+
function degreesArg(value, flag, limit) {
|
|
615
|
+
const n = typeof value === 'number' ? value : Number(value);
|
|
616
|
+
if (value === undefined ||
|
|
617
|
+
typeof value === 'boolean' ||
|
|
618
|
+
(typeof value === 'string' && value.trim() === '') ||
|
|
619
|
+
!Number.isFinite(n) ||
|
|
620
|
+
n < -limit ||
|
|
621
|
+
n > limit) {
|
|
622
|
+
throw new CliError(`--${flag} must be a number from -${limit} to ${limit} (decimal degrees).`, 1);
|
|
623
|
+
}
|
|
624
|
+
return n;
|
|
625
|
+
}
|
|
626
|
+
/** A link with a scheme and nothing a shell or a URL would split on. A session id has no colon. */
|
|
627
|
+
const LINK = /^[A-Za-z][A-Za-z0-9+.-]*:\S+$/;
|
|
601
628
|
/** "x,y" (percentages) from a flag value, or a usage error. */
|
|
602
629
|
function pointArg(value, flag) {
|
|
603
630
|
const parts = typeof value === 'string' ? value.split(',') : [];
|
|
@@ -636,6 +663,10 @@ const tapSub = defineCommand({
|
|
|
636
663
|
rid: { type: 'string', description: 'The element\'s resource id (rid in `dcd device inspect`)' },
|
|
637
664
|
x: { type: 'string', description: 'With --y: a point, as percentages of the screen (0-100)' },
|
|
638
665
|
y: { type: 'string', description: 'See --x' },
|
|
666
|
+
timeout: {
|
|
667
|
+
type: 'string',
|
|
668
|
+
description: `With --text or --rid: seconds to wait for it to appear before failing (0-${MAX_TAP_TIMEOUT_SECONDS}, default 17; 0 looks once)`,
|
|
669
|
+
},
|
|
639
670
|
maestro: maestroArg,
|
|
640
671
|
},
|
|
641
672
|
async run({ args }) {
|
|
@@ -649,10 +680,15 @@ const tapSub = defineCommand({
|
|
|
649
680
|
if (targets !== 1) {
|
|
650
681
|
throw new CliError('tap takes exactly one target: --text, --rid, or --x and --y.', 1);
|
|
651
682
|
}
|
|
683
|
+
const timeoutSeconds = secondsArg(args.timeout, 'timeout', MAX_TAP_TIMEOUT_SECONDS);
|
|
684
|
+
if (timeoutSeconds !== undefined && args.text === undefined && args.rid === undefined) {
|
|
685
|
+
throw new CliError('tap --timeout goes with --text or --rid: a point has nothing to wait for.', 1);
|
|
686
|
+
}
|
|
687
|
+
const wait = timeoutSeconds === undefined ? {} : { timeoutSeconds };
|
|
652
688
|
const body = args.text !== undefined
|
|
653
|
-
? { type: 'tap', text: String(args.text) }
|
|
689
|
+
? { type: 'tap', text: String(args.text), ...wait }
|
|
654
690
|
: args.rid !== undefined
|
|
655
|
-
? { type: 'tap', id: String(args.rid) }
|
|
691
|
+
? { type: 'tap', id: String(args.rid), ...wait }
|
|
656
692
|
: { type: 'tap', x: percentArg(args.x, 'x'), y: percentArg(args.y, 'y') };
|
|
657
693
|
const what = args.text !== undefined
|
|
658
694
|
? `"${String(args.text)}"`
|
|
@@ -759,6 +795,57 @@ const pressKeySub = defineCommand({
|
|
|
759
795
|
});
|
|
760
796
|
},
|
|
761
797
|
});
|
|
798
|
+
const openLinkSub = defineCommand({
|
|
799
|
+
meta: { name: 'open-link', description: 'Open a link on the device: a deep link into an app, or a web link' },
|
|
800
|
+
args: {
|
|
801
|
+
...commonArgs,
|
|
802
|
+
id: idArg,
|
|
803
|
+
// Not `required`, as with `type --text`: a missing link fails inside the envelope.
|
|
804
|
+
url: {
|
|
805
|
+
type: 'positional',
|
|
806
|
+
required: false,
|
|
807
|
+
description: 'The link with its scheme, e.g. myapp://path or https://example.com',
|
|
808
|
+
},
|
|
809
|
+
sensitive: {
|
|
810
|
+
type: 'boolean',
|
|
811
|
+
default: false,
|
|
812
|
+
description: 'The link is a secret (it carries a token): stored encrypted, never shown',
|
|
813
|
+
},
|
|
814
|
+
},
|
|
815
|
+
async run({ args }) {
|
|
816
|
+
const json = Boolean(args.json);
|
|
817
|
+
await runDeviceCommand(json, async () => {
|
|
818
|
+
let id = args.id;
|
|
819
|
+
let url = args.url;
|
|
820
|
+
// `dcd device open-link myapp://path`: the one positional is the link, not a session.
|
|
821
|
+
if (id && !url && id.includes(':'))
|
|
822
|
+
[id, url] = [undefined, id];
|
|
823
|
+
if (!url || !LINK.test(url)) {
|
|
824
|
+
throw new CliError('open-link takes a link with its scheme and no spaces, e.g. myapp://path or https://example.com.', 1);
|
|
825
|
+
}
|
|
826
|
+
const shown = args.sensitive ? 'a link' : url;
|
|
827
|
+
return performAction(args, id, { type: 'open_link', url, ...(args.sensitive ? { sensitive: true } : {}) }, { done: `Opened ${shown}`, failed: `Opening ${shown} failed` });
|
|
828
|
+
});
|
|
829
|
+
},
|
|
830
|
+
});
|
|
831
|
+
const setLocationSub = defineCommand({
|
|
832
|
+
meta: { name: 'set-location', description: "Set the device's GPS position, in decimal degrees" },
|
|
833
|
+
args: {
|
|
834
|
+
...commonArgs,
|
|
835
|
+
id: idArg,
|
|
836
|
+
latitude: { type: 'string', description: 'Decimal degrees, north positive (-90 to 90)' },
|
|
837
|
+
longitude: { type: 'string', description: 'Decimal degrees, east positive (-180 to 180)' },
|
|
838
|
+
},
|
|
839
|
+
async run({ args }) {
|
|
840
|
+
const json = Boolean(args.json);
|
|
841
|
+
await runDeviceCommand(json, async () => {
|
|
842
|
+
// South and west are negative. citty keeps a value that is a number, minus sign and all.
|
|
843
|
+
const latitude = degreesArg(args.latitude, 'latitude', 90);
|
|
844
|
+
const longitude = degreesArg(args.longitude, 'longitude', 180);
|
|
845
|
+
return performAction(args, args.id, { type: 'set_location', latitude, longitude }, { done: `Location set to ${latitude}, ${longitude}`, failed: 'Setting the location failed' });
|
|
846
|
+
});
|
|
847
|
+
},
|
|
848
|
+
});
|
|
762
849
|
const modelsSub = defineCommand({
|
|
763
850
|
meta: { name: 'models', description: 'The devices a session can ask for' },
|
|
764
851
|
args: {
|
|
@@ -1358,6 +1445,8 @@ export const deviceCommand = defineCommand({
|
|
|
1358
1445
|
type: typeSub,
|
|
1359
1446
|
swipe: swipeSub,
|
|
1360
1447
|
'press-key': pressKeySub,
|
|
1448
|
+
'open-link': openLinkSub,
|
|
1449
|
+
'set-location': setLocationSub,
|
|
1361
1450
|
models: modelsSub,
|
|
1362
1451
|
inspect: inspectSub,
|
|
1363
1452
|
screenshot: screenshotSub,
|
package/dist/commands/live.js
CHANGED
|
@@ -129,7 +129,7 @@ const startSub = defineCommand({
|
|
|
129
129
|
},
|
|
130
130
|
'device-locale': {
|
|
131
131
|
type: 'string',
|
|
132
|
-
description: 'Device locale
|
|
132
|
+
description: 'Device locale: a 2-3 letter lowercase language code (ISO 639) and an uppercase ISO-3166-1 country code, e.g. "de_DE"',
|
|
133
133
|
},
|
|
134
134
|
'android-device': {
|
|
135
135
|
type: 'string',
|
|
@@ -16,7 +16,7 @@ export declare const deviceFlags: {
|
|
|
16
16
|
};
|
|
17
17
|
readonly 'device-locale': {
|
|
18
18
|
readonly type: "string";
|
|
19
|
-
readonly description: "Locale that will be set to a device
|
|
19
|
+
readonly description: "Locale that will be set to a device: a 2-3 letter lowercase language code (ISO 639) and an uppercase ISO-3166-1 country code, e.g. \"de_DE\" for Germany";
|
|
20
20
|
};
|
|
21
21
|
readonly 'google-play': {
|
|
22
22
|
readonly type: "boolean";
|
|
@@ -21,7 +21,7 @@ export const deviceFlags = {
|
|
|
21
21
|
},
|
|
22
22
|
'device-locale': {
|
|
23
23
|
type: 'string',
|
|
24
|
-
description: 'Locale that will be set to a device
|
|
24
|
+
description: 'Locale that will be set to a device: a 2-3 letter lowercase language code (ISO 639) and an uppercase ISO-3166-1 country code, e.g. "de_DE" for Germany',
|
|
25
25
|
},
|
|
26
26
|
'google-play': {
|
|
27
27
|
type: 'boolean',
|
package/dist/constants.d.ts
CHANGED
|
@@ -162,7 +162,7 @@ export declare const flags: {
|
|
|
162
162
|
};
|
|
163
163
|
readonly 'device-locale': {
|
|
164
164
|
readonly type: "string";
|
|
165
|
-
readonly description: "Locale that will be set to a device
|
|
165
|
+
readonly description: "Locale that will be set to a device: a 2-3 letter lowercase language code (ISO 639) and an uppercase ISO-3166-1 country code, e.g. \"de_DE\" for Germany";
|
|
166
166
|
};
|
|
167
167
|
readonly 'google-play': {
|
|
168
168
|
readonly type: "boolean";
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Refreshes a `dcd login` session through the dcd API's
|
|
3
|
+
* `POST /cli-login/refresh`, which calls Supabase Auth on the CLI's behalf.
|
|
4
|
+
* The CLI holds no Supabase key for this.
|
|
5
|
+
*
|
|
6
|
+
* The login itself is the PKCE rendezvous in src/commands/login.ts.
|
|
7
|
+
*/
|
|
2
8
|
import type { StoredSession } from '../utils/config-store.js';
|
|
3
9
|
/**
|
|
4
|
-
* Thrown when a session refresh fails. `definitive` distinguishes "
|
|
5
|
-
*
|
|
6
|
-
*
|
|
10
|
+
* Thrown when a session refresh fails. `definitive` distinguishes "this
|
|
11
|
+
* refresh token was rejected" (revoked, already used, expired — re-login is
|
|
12
|
+
* the only fix) from transient failures (network, 5xx, rate limit) where the
|
|
7
13
|
* stored session may still be good on the next attempt.
|
|
8
14
|
*/
|
|
9
15
|
export declare class SessionRefreshError extends Error {
|
|
@@ -23,5 +29,10 @@ export interface RefreshedSession {
|
|
|
23
29
|
user_id: string;
|
|
24
30
|
}
|
|
25
31
|
export declare const CliAuthGateway: {
|
|
26
|
-
|
|
32
|
+
/**
|
|
33
|
+
* @param apiUrl The API the session was minted by (the stored `api_url`)
|
|
34
|
+
* @param session The stored session, whose refresh token is spent on success
|
|
35
|
+
* @param headers Extra headers, such as the CLI's identity headers
|
|
36
|
+
*/
|
|
37
|
+
refresh(apiUrl: string, session: StoredSession, headers?: Record<string, string>): Promise<RefreshedSession>;
|
|
27
38
|
};
|
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* Does not talk to the dcd API — the dcd-side session exchange lives in the
|
|
6
|
-
* login command's PKCE rendezvous flow (see src/commands/login.ts).
|
|
7
|
-
*/
|
|
8
|
-
import { createClient, isAuthApiError, isAuthSessionMissingError } from '@supabase/supabase-js';
|
|
9
|
-
import { getSupabaseKey } from '../config/supabase-key.js';
|
|
10
|
-
/**
|
|
11
|
-
* Thrown when a session refresh fails. `definitive` distinguishes "Supabase
|
|
12
|
-
* rejected this refresh token" (revoked, already used, malformed — re-login
|
|
13
|
-
* is the only fix) from transient failures (network, GoTrue 5xx) where the
|
|
2
|
+
* Thrown when a session refresh fails. `definitive` distinguishes "this
|
|
3
|
+
* refresh token was rejected" (revoked, already used, expired — re-login is
|
|
4
|
+
* the only fix) from transient failures (network, 5xx, rate limit) where the
|
|
14
5
|
* stored session may still be good on the next attempt.
|
|
15
6
|
*/
|
|
16
7
|
export class SessionRefreshError extends Error {
|
|
@@ -39,52 +30,62 @@ const REFRESH_REFUSAL_MESSAGES = new Map([
|
|
|
39
30
|
['session_not_found', SIGNED_OUT],
|
|
40
31
|
['refresh_token_not_found', SIGNED_OUT],
|
|
41
32
|
]);
|
|
42
|
-
function client(supabaseUrl, supabaseKey) {
|
|
43
|
-
return createClient(supabaseUrl, supabaseKey, {
|
|
44
|
-
auth: { persistSession: false, autoRefreshToken: false, detectSessionInUrl: false },
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
33
|
export const CliAuthGateway = {
|
|
48
|
-
|
|
49
|
-
|
|
34
|
+
/**
|
|
35
|
+
* @param apiUrl The API the session was minted by (the stored `api_url`)
|
|
36
|
+
* @param session The stored session, whose refresh token is spent on success
|
|
37
|
+
* @param headers Extra headers, such as the CLI's identity headers
|
|
38
|
+
*/
|
|
39
|
+
async refresh(apiUrl, session, headers = {}) {
|
|
40
|
+
let res;
|
|
50
41
|
try {
|
|
51
|
-
|
|
42
|
+
res = await fetch(`${apiUrl.replace(/\/$/, '')}/cli-login/refresh`, {
|
|
43
|
+
body: JSON.stringify({ refresh_token: session.refresh_token }),
|
|
44
|
+
headers: { ...headers, 'content-type': 'application/json' },
|
|
45
|
+
method: 'POST',
|
|
46
|
+
});
|
|
52
47
|
}
|
|
53
48
|
catch (error) {
|
|
54
|
-
// Never definitive: the
|
|
55
|
-
// session must survive for the next attempt.
|
|
49
|
+
// Never definitive: the token was not even tried.
|
|
56
50
|
throw new SessionRefreshError(`Failed to refresh session: ${error.message}`, false);
|
|
57
51
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
52
|
+
if (res.ok) {
|
|
53
|
+
let s;
|
|
54
|
+
try {
|
|
55
|
+
s = (await res.json());
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
// A 200 that is not JSON (a proxy page, say). The token may not have
|
|
59
|
+
// been spent, so keep the session and try again next time.
|
|
60
|
+
throw new SessionRefreshError('Failed to refresh session: response was not JSON', false);
|
|
61
|
+
}
|
|
62
|
+
if (!s.access_token || !s.refresh_token || !s.expires_at || !s.user_id) {
|
|
63
|
+
throw new SessionRefreshError('Failed to refresh session: incomplete response', false);
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
access_token: s.access_token,
|
|
67
|
+
refresh_token: s.refresh_token,
|
|
68
|
+
expires_at: s.expires_at,
|
|
69
|
+
user_email: s.user_email || session.user_email,
|
|
70
|
+
user_id: s.user_id,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
let body = {};
|
|
74
|
+
try {
|
|
75
|
+
body = (await res.json());
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
// Not JSON (a proxy page, say). The status alone decides.
|
|
77
79
|
}
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
};
|
|
80
|
+
const code = typeof body.error === 'string' ? body.error : undefined;
|
|
81
|
+
const reason = typeof body.message === 'string' && body.message ? body.message : `HTTP ${res.status}`;
|
|
82
|
+
// 401: Supabase Auth refused the token, and `error` is its code. 400: the
|
|
83
|
+
// API refused the request itself (an empty token). Only `dcd login` fixes
|
|
84
|
+
// either. Anything else (404 from an API without this route, 429, 5xx)
|
|
85
|
+
// may work later with the same token, so it must survive.
|
|
86
|
+
const definitive = res.status === 401 || res.status === 400;
|
|
87
|
+
const known = definitive && code ? REFRESH_REFUSAL_MESSAGES.get(code) : undefined;
|
|
88
|
+
throw new SessionRefreshError(known ??
|
|
89
|
+
`Failed to refresh session: ${reason}.` + (definitive ? ' Run `dcd login` again.' : ''), definitive, definitive ? code : undefined);
|
|
89
90
|
},
|
|
90
91
|
};
|
|
@@ -83,7 +83,7 @@ export declare const DeviceGateway: {
|
|
|
83
83
|
human: DeviceHumanStatus;
|
|
84
84
|
session: DeviceSession;
|
|
85
85
|
}>;
|
|
86
|
-
/** One typed action: tap, type, swipe or
|
|
86
|
+
/** One typed action: tap, type, swipe, press_key, open_link or set_location. Synchronous: answers with the outcome. */
|
|
87
87
|
action(baseUrl: string, auth: AuthContext, id: string, body: DeviceActionRequest): Promise<{
|
|
88
88
|
result: DeviceCommandResult;
|
|
89
89
|
session: DeviceSession;
|
|
@@ -157,7 +157,7 @@ export const DeviceGateway = {
|
|
|
157
157
|
requestHuman(baseUrl, auth, id, reason) {
|
|
158
158
|
return request(baseUrl, auth, 'POST', `${sessionPath(id)}/request-human`, { reason });
|
|
159
159
|
},
|
|
160
|
-
/** One typed action: tap, type, swipe or
|
|
160
|
+
/** One typed action: tap, type, swipe, press_key, open_link or set_location. Synchronous: answers with the outcome. */
|
|
161
161
|
action(baseUrl, auth, id, body) {
|
|
162
162
|
return request(baseUrl, auth, 'POST', `${sessionPath(id)}/actions`, body);
|
|
163
163
|
},
|
|
@@ -99,5 +99,22 @@ declare class Telemetry {
|
|
|
99
99
|
flushSync(): void;
|
|
100
100
|
private buildMeta;
|
|
101
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* The argv a command was run with, as telemetry may keep it: without the
|
|
104
|
+
* values of the flags above, and without what two `dcd device` subcommands
|
|
105
|
+
* are given that no flag name marks as a secret.
|
|
106
|
+
*
|
|
107
|
+
* - `device open-link` takes its link as a positional. A sign-in link is a
|
|
108
|
+
* credential, and `--sensitive` promises it is never shown, so everything
|
|
109
|
+
* after `open-link` that is not a flag is taken for the link, and the value
|
|
110
|
+
* of any flag but the API URL goes too. That costs the session id, and
|
|
111
|
+
* keeps a link too malformed to send from being kept either.
|
|
112
|
+
* - `device type` takes `--text`, which is a password or a code as often as
|
|
113
|
+
* not. `device tap` has a `--text` as well, an element's label, and keeps it.
|
|
114
|
+
*
|
|
115
|
+
* The subcommand is found by its name anywhere after `device`, not as the
|
|
116
|
+
* first positional: a flag's value in between must not hide it.
|
|
117
|
+
*/
|
|
118
|
+
export declare function scrubArgv(args: string[]): string[];
|
|
102
119
|
export declare const telemetry: Telemetry;
|
|
103
120
|
export {};
|
|
@@ -245,24 +245,55 @@ const SENSITIVE_FLAG_NAMES = new Set([
|
|
|
245
245
|
'-e',
|
|
246
246
|
'--env',
|
|
247
247
|
]);
|
|
248
|
-
|
|
248
|
+
const REDACTED = '<redacted>';
|
|
249
|
+
/**
|
|
250
|
+
* The argv a command was run with, as telemetry may keep it: without the
|
|
251
|
+
* values of the flags above, and without what two `dcd device` subcommands
|
|
252
|
+
* are given that no flag name marks as a secret.
|
|
253
|
+
*
|
|
254
|
+
* - `device open-link` takes its link as a positional. A sign-in link is a
|
|
255
|
+
* credential, and `--sensitive` promises it is never shown, so everything
|
|
256
|
+
* after `open-link` that is not a flag is taken for the link, and the value
|
|
257
|
+
* of any flag but the API URL goes too. That costs the session id, and
|
|
258
|
+
* keeps a link too malformed to send from being kept either.
|
|
259
|
+
* - `device type` takes `--text`, which is a password or a code as often as
|
|
260
|
+
* not. `device tap` has a `--text` as well, an element's label, and keeps it.
|
|
261
|
+
*
|
|
262
|
+
* The subcommand is found by its name anywhere after `device`, not as the
|
|
263
|
+
* first positional: a flag's value in between must not hide it.
|
|
264
|
+
*/
|
|
265
|
+
export function scrubArgv(args) {
|
|
266
|
+
const device = args.indexOf('device');
|
|
267
|
+
const subcommand = (name) => (device === -1 ? -1 : args.indexOf(name, device + 1));
|
|
268
|
+
const openLink = subcommand('open-link');
|
|
269
|
+
const type = subcommand('type');
|
|
270
|
+
const keeps = (flag) => API_URL_FLAGS.includes(flag);
|
|
249
271
|
const scrubbed = [];
|
|
250
272
|
for (let i = 0; i < args.length; i++) {
|
|
251
273
|
const arg = args[i];
|
|
274
|
+
const isFlag = arg.startsWith('-');
|
|
252
275
|
const eqIndex = arg.indexOf('=');
|
|
253
276
|
const flagName = eqIndex === -1 ? arg : arg.slice(0, eqIndex);
|
|
254
|
-
|
|
277
|
+
const afterOpenLink = openLink !== -1 && i > openLink;
|
|
278
|
+
const secretFlag = SENSITIVE_FLAG_NAMES.has(flagName) ||
|
|
279
|
+
(type !== -1 && i > type && flagName === '--text') ||
|
|
280
|
+
// `--anything=value` after open-link: no flag of the command needs its value kept.
|
|
281
|
+
(afterOpenLink && eqIndex !== -1 && !keeps(flagName));
|
|
282
|
+
if (isFlag && secretFlag) {
|
|
255
283
|
if (eqIndex === -1) {
|
|
256
284
|
scrubbed.push(arg);
|
|
257
285
|
if (i + 1 < args.length) {
|
|
258
|
-
scrubbed.push(
|
|
286
|
+
scrubbed.push(REDACTED);
|
|
259
287
|
i++;
|
|
260
288
|
}
|
|
261
289
|
}
|
|
262
290
|
else {
|
|
263
|
-
scrubbed.push(`${flagName}
|
|
291
|
+
scrubbed.push(`${flagName}=${REDACTED}`);
|
|
264
292
|
}
|
|
265
293
|
}
|
|
294
|
+
else if (afterOpenLink && !isFlag) {
|
|
295
|
+
scrubbed.push(keeps(args[i - 1]) ? arg : REDACTED);
|
|
296
|
+
}
|
|
266
297
|
else {
|
|
267
298
|
scrubbed.push(arg);
|
|
268
299
|
}
|
|
@@ -114,6 +114,8 @@ export type DeviceActionRequest = {
|
|
|
114
114
|
id?: string;
|
|
115
115
|
mode?: 'maestro';
|
|
116
116
|
text?: string;
|
|
117
|
+
/** With `text` or `id`: seconds to wait for it to appear (0 to 60; 0 looks once). */
|
|
118
|
+
timeoutSeconds?: number;
|
|
117
119
|
type: 'tap';
|
|
118
120
|
x?: number;
|
|
119
121
|
y?: number;
|
|
@@ -132,6 +134,14 @@ export type DeviceActionRequest = {
|
|
|
132
134
|
mode?: 'maestro';
|
|
133
135
|
to?: DevicePoint;
|
|
134
136
|
type: 'swipe';
|
|
137
|
+
} | {
|
|
138
|
+
sensitive?: boolean;
|
|
139
|
+
type: 'open_link';
|
|
140
|
+
url: string;
|
|
141
|
+
} | {
|
|
142
|
+
latitude: number;
|
|
143
|
+
longitude: number;
|
|
144
|
+
type: 'set_location';
|
|
135
145
|
};
|
|
136
146
|
/** The keys press_key takes, as the API names them. */
|
|
137
147
|
export declare const DEVICE_KEYS: readonly ["back", "home", "enter", "backspace", "tab", "volume_up", "volume_down", "lock", "power"];
|
package/dist/utils/auth.js
CHANGED
|
@@ -170,7 +170,7 @@ async function refreshSessionWithLock(initial) {
|
|
|
170
170
|
// forced a fresh login when an upgrade alone would have fixed it. The
|
|
171
171
|
// error tells the user to log in again; only `dcd logout` (or the next
|
|
172
172
|
// `dcd login`) replaces the stored session.
|
|
173
|
-
const refreshed = await CliAuthGateway.refresh(current.
|
|
173
|
+
const refreshed = await CliAuthGateway.refresh(current.api_url, session, clientHeaders());
|
|
174
174
|
// Re-read again and merge only `session` so a concurrent `switch-org`
|
|
175
175
|
// write (org fields) isn't reverted by our pre-refresh snapshot.
|
|
176
176
|
const merged = { ...(readConfig() ?? current), session: refreshed };
|
package/package.json
CHANGED
|
@@ -23,21 +23,19 @@
|
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@eslint/js": "^10.0.1",
|
|
25
25
|
"@types/chai": "^5.2.3",
|
|
26
|
-
"@types/js-yaml": "^4.0.9",
|
|
27
26
|
"@types/mocha": "^10.0.10",
|
|
28
27
|
"@types/node": "^26.0.0",
|
|
29
28
|
"@types/yazl": "^3.3.1",
|
|
30
29
|
"chai": "^6.2.2",
|
|
31
|
-
"eslint": "^10.
|
|
30
|
+
"eslint": "^10.15.0",
|
|
32
31
|
"eslint-config-prettier": "^10.1.8",
|
|
33
32
|
"eslint-plugin-unicorn": "^79.0.0",
|
|
34
33
|
"husky": "^9.1.7",
|
|
35
34
|
"mocha": "^12.0.0",
|
|
36
35
|
"prettier": "^3.8.4",
|
|
37
|
-
"shx": "^0.4.0",
|
|
38
36
|
"tsx": "^4.22.4",
|
|
39
37
|
"typescript": "^6.0.3",
|
|
40
|
-
"typescript-eslint": "^8.
|
|
38
|
+
"typescript-eslint": "^8.73.0"
|
|
41
39
|
},
|
|
42
40
|
"engines": {
|
|
43
41
|
"node": ">=22.0.0"
|
|
@@ -60,7 +58,7 @@
|
|
|
60
58
|
},
|
|
61
59
|
"scripts": {
|
|
62
60
|
"dcd": "tsx src/index.ts",
|
|
63
|
-
"build": "
|
|
61
|
+
"build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc -b && node -e \"for (const f of ['dist/index.js','dist/mcp/index.js']) require('node:fs').chmodSync(f,0o755)\"",
|
|
64
62
|
"build:binaries": "node scripts/build-binaries.mjs",
|
|
65
63
|
"lint": "eslint src test --ext .ts",
|
|
66
64
|
"prepare": "pnpm build && husky",
|
|
@@ -68,7 +66,7 @@
|
|
|
68
66
|
"test:unit": "node scripts/test-runner.mjs --unit",
|
|
69
67
|
"typecheck": "tsc --noEmit -p tsconfig.test.json"
|
|
70
68
|
},
|
|
71
|
-
"version": "5.14.
|
|
69
|
+
"version": "5.14.1",
|
|
72
70
|
"bugs": {
|
|
73
71
|
"url": "https://discord.gg/gm3mJwcNw8"
|
|
74
72
|
},
|
|
@@ -84,42 +82,14 @@
|
|
|
84
82
|
"packageManager": "pnpm@10.17.1",
|
|
85
83
|
"pnpm": {
|
|
86
84
|
"overrides": {
|
|
87
|
-
"js-yaml@<3.14.2": ">=3.14.2",
|
|
88
|
-
"js-yaml@>=4.0.0 <4.2.0": ">=4.2.0",
|
|
89
|
-
"js-yaml@>=5.0.0 <5.2.2": ">=5.2.2",
|
|
90
|
-
"tar@<7.5.16": ">=7.5.16",
|
|
91
|
-
"@isaacs/brace-expansion": ">=5.0.1",
|
|
92
|
-
"fast-xml-parser": ">=5.5.7",
|
|
93
|
-
"flatted": ">=3.4.2",
|
|
94
|
-
"lodash": ">=4.18.0",
|
|
95
|
-
"@xmldom/xmldom": ">=0.9.12",
|
|
96
|
-
"minimatch@<3.1.4": "3.1.4",
|
|
97
|
-
"minimatch@>=5.0.0 <5.1.8": "5.1.8",
|
|
98
|
-
"minimatch@>=9.0.0 <9.0.7": "9.0.7",
|
|
99
85
|
"minimatch@>=10.0.0 <11.0.1": "11.0.1",
|
|
100
|
-
"glob@>=9.0.0 <14.0.2": "14.0.2"
|
|
101
|
-
"picomatch@<2.3.2": "2.3.2",
|
|
102
|
-
"picomatch@>=4.0.0 <4.0.4": "4.0.4",
|
|
103
|
-
"serialize-javascript": ">=7.0.5",
|
|
104
|
-
"ajv@<7.0.0": "6.14.0",
|
|
105
|
-
"diff@>=4.0.0 <6.0.0": "4.0.4",
|
|
106
|
-
"diff@>=6.0.0": "8.0.3",
|
|
107
|
-
"brace-expansion@<1.1.16": "1.1.16",
|
|
108
|
-
"brace-expansion@>=2.0.0 <2.0.3": "2.0.3",
|
|
109
|
-
"brace-expansion@>=3.0.0 <5.0.12": "5.0.12",
|
|
110
|
-
"ws@>=8.0.0 <8.21.0": "8.21.0",
|
|
111
|
-
"esbuild@<0.28.1": ">=0.28.1",
|
|
112
|
-
"qs@<6.16.1": "6.16.1",
|
|
113
|
-
"fast-uri@>=3.0.0 <3.1.9": "3.1.9",
|
|
114
|
-
"hono@>=4.0.0 <4.13.16": "4.13.16",
|
|
115
|
-
"source-map-js@<1.2.2": "1.2.2",
|
|
116
|
-
"micromatch>picomatch": "^2.3.2",
|
|
117
|
-
"tinyglobby>picomatch": "^4.0.4"
|
|
86
|
+
"glob@>=9.0.0 <14.0.2": "14.0.2"
|
|
118
87
|
},
|
|
119
88
|
"auditConfig": {
|
|
120
89
|
"ignoreGhsas": [
|
|
121
90
|
"GHSA-frvp-7c67-39w9",
|
|
122
|
-
"GHSA-vfj7-8cjw-p6xm"
|
|
91
|
+
"GHSA-vfj7-8cjw-p6xm",
|
|
92
|
+
"GHSA-fc5q-39xc-vjpf"
|
|
123
93
|
]
|
|
124
94
|
}
|
|
125
95
|
}
|