@qontinui/ui-bridge-wrapper 0.4.0 → 0.4.2

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/README.md CHANGED
@@ -63,11 +63,19 @@ or a global/dev install:
63
63
  | Bin | What it does |
64
64
  | --- | --- |
65
65
  | `ui-bridge-inject` | Drive the injected transport against a UI-Bridge-free page (exec one-shot actions, or register as a relay tab). |
66
- | `ui-bridge-login-web` | Automated web login via the injected transport — drives the full Cognito OAuth redirect chain in one headless tab. Prints one JSON result line; exit 0 = login confirmed. |
66
+ | `ui-bridge-login-web` | Automated web login via the injected transport — drives the full Cognito OAuth redirect chain in one headless tab. Optionally asserts on-page text (`--expect-text`) and screenshots the authed landing (`--screenshot`/`--scroll-to`). Prints one JSON result line; exit 0 = login confirmed AND all expected text present. |
67
67
  | `ui-bridge-capture-specs` | Log in (same flow) then `goto` + snapshot a set of authed pages, writing one `<slug>.snapshot.json` per page. |
68
68
 
69
69
  Each bin supports `--help`.
70
70
 
71
+ > **Version floor:** the bins exist only at `@qontinui/ui-bridge-wrapper` **>= 0.4.0**
72
+ > (the `scripts/` predecessors were deleted in the same release). A pin or cached
73
+ > npx resolution below that yields `command not found: ui-bridge-login-web` —
74
+ > upgrade rather than hunting for the bin. Also note: since 0.4.1 an explicit but
75
+ > EMPTY `--pages` errors (exit 2) instead of silently capturing the default page
76
+ > set, and (0.4.2) an empty `--success`/`--url` value is rejected rather than
77
+ > matching every landing page.
78
+
71
79
  ### Prerequisites for the browser-driving bins
72
80
 
73
81
  `ui-bridge-login-web` and `ui-bridge-capture-specs` launch Chromium via the
@@ -79,6 +87,26 @@ standalone you must therefore also:
79
87
  2. Run `npx playwright install chromium` once (or point `PLAYWRIGHT_BROWSERS_PATH`
80
88
  at an existing Chromium download).
81
89
 
90
+ > **A bare `npx @qontinui/ui-bridge-wrapper …` does NOT install peers** — it
91
+ > fetches only the wrapper, so the dynamic `import('@qontinui/ui-bridge-headless')`
92
+ > dies with `ERR_MODULE_NOT_FOUND`. For a zero-install one-off, name every package
93
+ > with `-p` so npx stages them together:
94
+ >
95
+ > ```bash
96
+ > npx -y \
97
+ > -p @qontinui/ui-bridge-wrapper \
98
+ > -p @qontinui/ui-bridge \
99
+ > -p @qontinui/ui-bridge-headless \
100
+ > -p playwright \
101
+ > ui-bridge-login-web \
102
+ > --url "https://qontinui.io/login?next=%2Fbuild%2Fworkflows" \
103
+ > --success /build/workflows
104
+ > ```
105
+ >
106
+ > (Still run `npx playwright install chromium` once for the browser binary.) The
107
+ > bare-bin examples below assume a local/global/dev install where the peer is
108
+ > already on the module path.
109
+
82
110
  Credentials for the login/capture bins come from `--email`/`--password` or the
83
111
  env vars `UIB_LOGIN_EMAIL` / `UIB_LOGIN_PASSWORD`. Git Bash callers should
84
112
  prefix `MSYS_NO_PATHCONV=1` so a leading-slash `--success` / path value is not
@@ -90,6 +118,32 @@ ui-bridge-login-web \
90
118
  --url "https://qontinui.io/login?next=%2Fbuild%2Fworkflows" \
91
119
  --success /build/workflows
92
120
 
121
+ # log in, land on /operations, assert the gates panel rendered, screenshot it
122
+ ui-bridge-login-web \
123
+ --url "https://qontinui.io/login?next=%2Foperations" \
124
+ --success /operations \
125
+ --expect-text "option2-actions-outage-drill,metric_threshold" \
126
+ --screenshot out.png
127
+
93
128
  # capture the default admin coord pages
94
129
  ui-bridge-capture-specs --out ./spec-capture
95
130
  ```
131
+
132
+ #### Sourcing credentials from SSM (qontinui operators)
133
+
134
+ The bins read credentials from env / flags only — they intentionally do **not**
135
+ embed any SSM lookup, since `@qontinui/ui-bridge-wrapper` is a general-purpose
136
+ package. Operators with access to the operator parameters can populate the env
137
+ vars before invoking a bin. On this fleet `aws` resolves under PowerShell (the
138
+ git-bash profile diverges), so prefer the PowerShell form:
139
+
140
+ ```powershell
141
+ $env:UIB_LOGIN_EMAIL = (aws ssm get-parameter --name /qontinui/operator/email --with-decryption --region eu-central-1 --query Parameter.Value --output text)
142
+ $env:UIB_LOGIN_PASSWORD = (aws ssm get-parameter --name /qontinui/operator/password --with-decryption --region eu-central-1 --query Parameter.Value --output text)
143
+ ```
144
+
145
+ ```bash
146
+ # bash equivalent (only where `aws` is on PATH for this shell)
147
+ export UIB_LOGIN_EMAIL="$(aws ssm get-parameter --name /qontinui/operator/email --with-decryption --region eu-central-1 --query Parameter.Value --output text)"
148
+ export UIB_LOGIN_PASSWORD="$(aws ssm get-parameter --name /qontinui/operator/password --with-decryption --region eu-central-1 --query Parameter.Value --output text)"
149
+ ```
@@ -234,19 +234,53 @@ var HeadlessTransport = class extends BaseTransport {
234
234
  };
235
235
  }
236
236
  async onReady() {
237
- const { launchHeadlessTab } = await import('@qontinui/ui-bridge-headless');
237
+ let launchHeadlessTab;
238
+ try {
239
+ ({ launchHeadlessTab } = await import('@qontinui/ui-bridge-headless'));
240
+ } catch (err) {
241
+ const cause = err instanceof Error ? err.message : String(err);
242
+ const code = err?.code;
243
+ if (code === "ERR_MODULE_NOT_FOUND" || code === "MODULE_NOT_FOUND") {
244
+ throw new WrapperTransportError(
245
+ "INVALID_CONFIG",
246
+ `Transport kind '${this.kind}' needs the optional '@qontinui/ui-bridge-headless' peer, which is not installed. Install it and the Chromium browser:
247
+ npm i @qontinui/ui-bridge-headless && npx playwright install chromium
248
+ (bare \`npx @qontinui/ui-bridge-wrapper \u2026\` does NOT install peers \u2014 pass each peer with \`-p\`, e.g.
249
+ npx -y -p @qontinui/ui-bridge-wrapper -p @qontinui/ui-bridge -p @qontinui/ui-bridge-headless -p playwright ui-bridge-login-web \u2026)
250
+ Underlying import error: ${cause}`
251
+ );
252
+ }
253
+ throw new WrapperTransportError(
254
+ "INVALID_CONFIG",
255
+ `'@qontinui/ui-bridge-headless' is installed but failed to load \u2014 this is a broken install (missing transitive dependency or version skew), not a missing peer. Try reinstalling it. Underlying error: ${cause}`
256
+ );
257
+ }
238
258
  const initScripts = await this.buildInitScripts();
239
- const tab = await launchHeadlessTab({
240
- url: this.options.targetUrl,
241
- headless: this.headless,
242
- uiBridgeBase: this.options.uiBridgeBase,
243
- waitForUiBridgeMs: this.options.waitForUiBridgeMs,
244
- viewportWidth: this.options.viewportWidth,
245
- viewportHeight: this.options.viewportHeight,
246
- userAgent: this.options.userAgent,
247
- forwardConsole: this.options.forwardConsole,
248
- initScripts: initScripts.length > 0 ? initScripts : void 0
249
- });
259
+ let tab;
260
+ try {
261
+ tab = await launchHeadlessTab({
262
+ url: this.options.targetUrl,
263
+ headless: this.headless,
264
+ uiBridgeBase: this.options.uiBridgeBase,
265
+ waitForUiBridgeMs: this.options.waitForUiBridgeMs,
266
+ viewportWidth: this.options.viewportWidth,
267
+ viewportHeight: this.options.viewportHeight,
268
+ userAgent: this.options.userAgent,
269
+ forwardConsole: this.options.forwardConsole,
270
+ initScripts: initScripts.length > 0 ? initScripts : void 0
271
+ });
272
+ } catch (err) {
273
+ const cause = err instanceof Error ? err.message : String(err);
274
+ if (/Executable doesn't exist|browserType\.launch/i.test(cause)) {
275
+ throw new WrapperTransportError(
276
+ "INVALID_CONFIG",
277
+ `Playwright's Chromium browser is not installed (the '@qontinui/ui-bridge-headless' peer itself loaded fine). Run:
278
+ npx playwright install chromium
279
+ Underlying launch error: ${cause}`
280
+ );
281
+ }
282
+ throw err;
283
+ }
250
284
  this.tab = {
251
285
  browser: tab.browser,
252
286
  context: tab.context,
@@ -692,6 +726,185 @@ function createTransport(config) {
692
726
  }
693
727
  }
694
728
 
729
+ // src/cli-args.ts
730
+ var COMMON_FLAGS = /* @__PURE__ */ new Set(["--help", "-h", "--quiet"]);
731
+ function isFlagShaped(value) {
732
+ return value.startsWith("--");
733
+ }
734
+ function consumeValue(flag, raw, error) {
735
+ if (raw === void 0) return null;
736
+ if (isFlagShaped(raw)) {
737
+ throw error(`${flag} expects a value but got the flag '${raw}' \u2014 did you omit ${flag}'s argument?`);
738
+ }
739
+ return raw;
740
+ }
741
+ var ArgReader = class {
742
+ argv;
743
+ error;
744
+ /**
745
+ * @param argv Already sliced past `node script`.
746
+ * @param known All flags the bin recognizes (union the bin's set with {@link COMMON_FLAGS}).
747
+ * @param error Factory producing the bin's domain error type.
748
+ */
749
+ constructor(argv, known, error) {
750
+ this.argv = argv;
751
+ this.error = error;
752
+ for (const arg of argv) {
753
+ if (isFlagShaped(arg) && !known.has(arg)) {
754
+ throw error(`Unknown flag: ${arg}`);
755
+ }
756
+ }
757
+ }
758
+ /** True if `name` appears as a bare boolean flag. */
759
+ has(name) {
760
+ return this.argv.includes(name);
761
+ }
762
+ /**
763
+ * Value following the value-flag `name`, or `null` when the flag is absent OR
764
+ * has no following token (the caller defaults it). Throws when the following
765
+ * token is flag-shaped — the swallow this kit exists to kill. Delegates to
766
+ * {@link consumeValue} so the guard (and its message) live in exactly one
767
+ * place for both the indexOf-style and switch-style parsers.
768
+ */
769
+ value(name) {
770
+ const i = this.argv.indexOf(name);
771
+ if (i < 0 || i + 1 >= this.argv.length) return null;
772
+ return consumeValue(name, this.argv[i + 1], this.error);
773
+ }
774
+ };
775
+ function makeLogger(prefix, quiet) {
776
+ if (quiet) return () => {
777
+ };
778
+ return (m) => process.stderr.write(`${prefix} ${m}
779
+ `) ;
780
+ }
781
+
782
+ // src/login-drive.ts
783
+ var isCognito = (u) => /auth\.qontinui\.io|amazoncognito\.com|\/oauth2\//i.test(u);
784
+ var pathOf = (u) => {
785
+ try {
786
+ return new URL(u).pathname;
787
+ } catch {
788
+ return "";
789
+ }
790
+ };
791
+ var isAppLoginPath = (u) => /\/login(\b|\/|$)/.test(pathOf(u)) && !isCognito(u);
792
+ async function scrapeErrorCard(page) {
793
+ try {
794
+ const alerts = page.locator(
795
+ '[role="alert"], #loginErrorMessage, .error-message, [class*="error" i], [data-testid*="error" i]'
796
+ );
797
+ const an = await alerts.count();
798
+ for (let i = 0; i < an; i++) {
799
+ const el = alerts.nth(i);
800
+ if (await el.isVisible().catch(() => false)) {
801
+ const t = (await el.innerText().catch(() => "")).trim();
802
+ if (t) return t.slice(0, 500);
803
+ }
804
+ }
805
+ } catch {
806
+ }
807
+ return null;
808
+ }
809
+ async function loginDrive(page, { email, password, timeoutMs, log = () => {
810
+ } }) {
811
+ log(`landed ${page.url()}`);
812
+ const emailBtn = page.getByRole("button", { name: /continue with email/i }).or(page.getByText(/continue with email/i));
813
+ await emailBtn.first().waitFor({ state: "visible", timeout: 15e3 });
814
+ await emailBtn.first().click();
815
+ await page.waitForURL(
816
+ (u) => {
817
+ const s = u.toString();
818
+ return isCognito(s) || !isAppLoginPath(s) && !/\/auth\/callback/.test(pathOf(s));
819
+ },
820
+ { timeout: timeoutMs }
821
+ );
822
+ if (isCognito(page.url())) {
823
+ await page.waitForLoadState("domcontentloaded");
824
+ log(`cognito ${page.url()}`);
825
+ const fillFirst = async (sels, val, what) => {
826
+ for (const s of sels) {
827
+ const loc = page.locator(s);
828
+ const n = await loc.count().catch(() => 0);
829
+ for (let i = 0; i < n; i++) {
830
+ const el = loc.nth(i);
831
+ if (await el.isVisible().catch(() => false)) {
832
+ await el.fill(val, { timeout: 1e4 });
833
+ log(`filled ${what} via ${s} [visible #${i}]`);
834
+ return;
835
+ }
836
+ }
837
+ }
838
+ throw new Error(`Cognito ${what} field (visible) not found (selectors: ${sels.join(", ")})`);
839
+ };
840
+ await fillFirst(
841
+ [
842
+ "#signInFormUsername",
843
+ 'input[name="username"]',
844
+ 'input[type="email"]',
845
+ 'input[autocomplete="username"]'
846
+ ],
847
+ email,
848
+ "email"
849
+ );
850
+ await fillFirst(
851
+ [
852
+ "#signInFormPassword",
853
+ 'input[name="password"]',
854
+ 'input[type="password"]',
855
+ 'input[autocomplete="current-password"]'
856
+ ],
857
+ password,
858
+ "password"
859
+ );
860
+ const submitLoc = page.locator(
861
+ 'input[name="signInSubmitButton"], button[type="submit"], input[type="submit"], [name="signInSubmitButton"]'
862
+ );
863
+ let clicked = false;
864
+ const sn = await submitLoc.count().catch(() => 0);
865
+ for (let i = 0; i < sn; i++) {
866
+ const el = submitLoc.nth(i);
867
+ if (await el.isVisible().catch(() => false)) {
868
+ await el.click();
869
+ clicked = true;
870
+ log(`clicked submit [visible #${i}]`);
871
+ break;
872
+ }
873
+ }
874
+ if (!clicked) {
875
+ await page.getByRole("button", { name: /sign in|log in|continue|submit/i }).first().click();
876
+ log("clicked submit [role fallback]");
877
+ }
878
+ try {
879
+ await page.waitForURL(
880
+ (u) => {
881
+ const s = u.toString();
882
+ return !isCognito(s) && !/\/auth\/callback/.test(pathOf(s));
883
+ },
884
+ { timeout: timeoutMs }
885
+ );
886
+ } catch {
887
+ const errorText2 = await scrapeErrorCard(page);
888
+ const finalUrl2 = page.url();
889
+ log(`stalled ${finalUrl2}`);
890
+ return { ok: false, finalUrl: finalUrl2, landingPath: pathOf(finalUrl2), errorText: errorText2 };
891
+ }
892
+ }
893
+ await page.waitForLoadState("networkidle").catch(() => {
894
+ });
895
+ await page.waitForFunction(
896
+ () => window.__uiBridgeInjected?.ready === true,
897
+ { timeout: 15e3 }
898
+ ).catch(() => {
899
+ });
900
+ const finalUrl = page.url();
901
+ const landingPath = await page.evaluate(() => location.pathname).catch(() => pathOf(finalUrl));
902
+ const ok = !isAppLoginPath(finalUrl) && !isCognito(finalUrl) && !/\/auth\/callback/.test(pathOf(finalUrl));
903
+ log(ok ? `authed ${finalUrl}` : `stalled ${finalUrl}`);
904
+ const errorText = ok ? null : await scrapeErrorCard(page);
905
+ return { ok, finalUrl, landingPath, errorText };
906
+ }
907
+
695
908
  // src/capture-specs-cli.ts
696
909
  var USAGE = `ui-bridge-capture-specs \u2014 log in and snapshot authed pages via the injected transport
697
910
 
@@ -708,6 +921,8 @@ Options:
708
921
  the two admin coord pages.
709
922
  --device <id> device_id query for the default trees page.
710
923
  --timeout <ms> Per-hop wait budget (default 70000).
924
+ --quiet Suppress human-readable stderr logs (the per-page
925
+ JSON lines still print).
711
926
  --help, -h Print this help and exit.
712
927
 
713
928
  Prerequisites (packaged bin): the optional @qontinui/ui-bridge-headless peer must
@@ -746,15 +961,6 @@ function defaultTargets(origin, device) {
746
961
  { slug: "admin-coord-pull-decisions", url: `${origin}/admin/coord/pull-decisions` }
747
962
  ];
748
963
  }
749
- var isCognito = (u) => /auth\.qontinui\.io|amazoncognito\.com|\/oauth2\//i.test(u);
750
- var pathOf = (u) => {
751
- try {
752
- return new URL(u).pathname;
753
- } catch {
754
- return "";
755
- }
756
- };
757
- var isLoginPath = (u) => /\/login(\b|\/|$)/.test(pathOf(u)) && !isCognito(u);
758
964
  function computeLoginUrl(targets, origin) {
759
965
  let firstNext = null;
760
966
  try {
@@ -766,16 +972,10 @@ function computeLoginUrl(targets, origin) {
766
972
  return { loginUrl, firstNext };
767
973
  }
768
974
  function parseArgs(argv) {
769
- const valueOf = (name) => {
770
- const i = argv.indexOf(name);
771
- return i >= 0 && i + 1 < argv.length ? argv[i + 1] ?? null : null;
772
- };
773
- const has = (name) => argv.includes(name);
774
- for (const arg of argv) {
775
- if (arg.startsWith("--") && !KNOWN_FLAGS.has(arg)) {
776
- throw new CaptureCliArgError(`Unknown flag: ${arg}`);
777
- }
778
- }
975
+ const mkError = (m) => new CaptureCliArgError(m);
976
+ const reader = new ArgReader(argv, KNOWN_FLAGS, mkError);
977
+ const valueOf = (name) => reader.value(name);
978
+ const has = (name) => reader.has(name);
779
979
  const help = has("--help") || has("-h");
780
980
  const origin = valueOf("--origin") ?? DEFAULT_ORIGIN;
781
981
  const device = valueOf("--device") ?? DEFAULT_DEVICE;
@@ -785,6 +985,15 @@ function parseArgs(argv) {
785
985
  throw new CaptureCliArgError(`--timeout expects a positive integer (got ${timeoutRaw})`);
786
986
  }
787
987
  const pagesSpec = valueOf("--pages");
988
+ let pages = null;
989
+ if (pagesSpec !== null) {
990
+ pages = parsePages(pagesSpec, origin);
991
+ if (pages.length === 0) {
992
+ throw new CaptureCliArgError(
993
+ `--pages was given but parsed to zero targets (got '${pagesSpec}'); omit --pages for the default pages, or pass 'slug=path[,slug=path]'`
994
+ );
995
+ }
996
+ }
788
997
  const args = {
789
998
  email: valueOf("--email") ?? process.env.UIB_LOGIN_EMAIL ?? "",
790
999
  password: valueOf("--password") ?? process.env.UIB_LOGIN_PASSWORD ?? "",
@@ -792,7 +1001,8 @@ function parseArgs(argv) {
792
1001
  origin,
793
1002
  device,
794
1003
  timeoutMs,
795
- pages: pagesSpec ? parsePages(pagesSpec, origin) : null,
1004
+ pages,
1005
+ quiet: has("--quiet"),
796
1006
  help
797
1007
  };
798
1008
  validateArgs(args);
@@ -806,8 +1016,7 @@ var KNOWN_FLAGS = /* @__PURE__ */ new Set([
806
1016
  "--pages",
807
1017
  "--device",
808
1018
  "--timeout",
809
- "--help",
810
- "-h"
1019
+ ...COMMON_FLAGS
811
1020
  ]);
812
1021
  function validateArgs(args) {
813
1022
  if (args.help) return;
@@ -815,24 +1024,6 @@ function validateArgs(args) {
815
1024
  throw new CaptureCliArgError("need creds (UIB_LOGIN_EMAIL/PASSWORD or --email/--password)");
816
1025
  }
817
1026
  }
818
- function log(m) {
819
- process.stderr.write(`[capture] ${m}
820
- `);
821
- }
822
- async function fillVisible(page, sels, val, what) {
823
- for (const s of sels) {
824
- const loc = page.locator(s);
825
- const n = await loc.count().catch(() => 0);
826
- for (let i = 0; i < n; i++) {
827
- const el = loc.nth(i);
828
- if (await el.isVisible().catch(() => false)) {
829
- await el.fill(val, { timeout: 1e4 });
830
- return;
831
- }
832
- }
833
- }
834
- throw new Error(`Cognito ${what} field not found`);
835
- }
836
1027
  async function main() {
837
1028
  let args;
838
1029
  try {
@@ -851,9 +1042,9 @@ ${USAGE}`);
851
1042
  process.exit(0);
852
1043
  }
853
1044
  const { email, password, out, origin, device, timeoutMs } = args;
1045
+ const log = makeLogger("[capture]", args.quiet);
854
1046
  const targets = args.pages ?? defaultTargets(origin, device);
855
- const { loginUrl, firstNext } = computeLoginUrl(targets, origin);
856
- const landedAuthed = (u) => firstNext ? pathOf(u) === pathOf(`${origin}${firstNext}`) : pathOf(u).includes("/dashboard") || pathOf(u).includes("/build");
1047
+ const { loginUrl } = computeLoginUrl(targets, origin);
857
1048
  const transport = createTransport({
858
1049
  kind: "injected",
859
1050
  options: { targetUrl: loginUrl, waitForSettle: false, readyTimeoutMs: 45e3 }
@@ -861,67 +1052,9 @@ ${USAGE}`);
861
1052
  transport.register("run", async (_p, ctx) => {
862
1053
  const page = ctx.page;
863
1054
  log(`login: ${page.url()}`);
864
- await page.getByRole("button", { name: /continue with email/i }).or(page.getByText(/continue with email/i)).first().click({ timeout: 2e4 });
865
- await page.waitForURL((u) => isCognito(u.toString()) || landedAuthed(u.toString()), {
866
- timeout: timeoutMs
867
- });
868
- if (isCognito(page.url())) {
869
- await page.waitForLoadState("domcontentloaded");
870
- await fillVisible(
871
- page,
872
- ["#signInFormUsername", 'input[name="username"]', 'input[type="email"]'],
873
- email,
874
- "email"
875
- );
876
- await fillVisible(
877
- page,
878
- ["#signInFormPassword", 'input[name="password"]', 'input[type="password"]'],
879
- password,
880
- "password"
881
- );
882
- const sub = page.locator(
883
- 'input[name="signInSubmitButton"], button[type="submit"], input[type="submit"]'
884
- );
885
- const sn = await sub.count();
886
- let done = false;
887
- for (let i = 0; i < sn; i++) {
888
- if (await sub.nth(i).isVisible().catch(() => false)) {
889
- await sub.nth(i).click();
890
- done = true;
891
- break;
892
- }
893
- }
894
- if (!done) await page.getByRole("button", { name: /sign in|continue/i }).first().click();
895
- try {
896
- await page.waitForURL(
897
- (u) => !isCognito(u.toString()) && !/^\/auth\/callback/.test(pathOf(u.toString())),
898
- { timeout: timeoutMs }
899
- );
900
- } catch {
901
- let errorText = null;
902
- try {
903
- const alerts = page.locator(
904
- '[role="alert"], #loginErrorMessage, .error-message, [class*="error" i], [data-testid*="error" i]'
905
- );
906
- const an = await alerts.count();
907
- for (let i = 0; i < an && !errorText; i++) {
908
- const el = alerts.nth(i);
909
- if (await el.isVisible().catch(() => false)) {
910
- const t = (await el.innerText().catch(() => "")).trim();
911
- if (t) errorText = t.slice(0, 500);
912
- }
913
- }
914
- } catch {
915
- }
916
- throw new Error(
917
- `login stalled on ${pathOf(page.url())}${errorText ? ` \u2014 ${errorText}` : ""}`
918
- );
919
- }
920
- }
921
- await page.waitForLoadState("networkidle").catch(() => {
922
- });
923
- if (isLoginPath(page.url())) {
924
- throw new Error(`login failed \u2014 bounced back to ${pathOf(page.url())}`);
1055
+ const r = await loginDrive(page, { email, password, timeoutMs, log });
1056
+ if (!r.ok) {
1057
+ throw new Error(`login stalled on ${r.landingPath}${r.errorText ? ` \u2014 ${r.errorText}` : ""}`);
925
1058
  }
926
1059
  log(`authed: ${page.url()}`);
927
1060
  const out2 = [];
@@ -944,7 +1077,7 @@ ${USAGE}`);
944
1077
  err = e instanceof Error ? e.message : String(e);
945
1078
  }
946
1079
  const finalUrl = page.url();
947
- const onLogin = isLoginPath(finalUrl);
1080
+ const onLogin = isAppLoginPath(finalUrl);
948
1081
  out2.push({
949
1082
  slug: t.slug,
950
1083
  requestedUrl: t.url,
@@ -1013,11 +1146,8 @@ exports.CaptureCliArgError = CaptureCliArgError;
1013
1146
  exports.USAGE = USAGE;
1014
1147
  exports.computeLoginUrl = computeLoginUrl;
1015
1148
  exports.defaultTargets = defaultTargets;
1016
- exports.isCognito = isCognito;
1017
- exports.isLoginPath = isLoginPath;
1018
1149
  exports.parseArgs = parseArgs;
1019
1150
  exports.parsePages = parsePages;
1020
- exports.pathOf = pathOf;
1021
1151
  exports.validateArgs = validateArgs;
1022
1152
  //# sourceMappingURL=capture-specs-cli.cjs.map
1023
1153
  //# sourceMappingURL=capture-specs-cli.cjs.map