@wix/himalaya-cli 0.1783.0 → 0.1784.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/cli.mjs CHANGED
@@ -40211,7 +40211,6 @@ function resolveIdiom(tokens2, ctx = {}) {
40211
40211
  var IDIOM_CONTEXTS, UNSAFE_KEYS;
40212
40212
  var init_idiom = __esm({
40213
40213
  "../../core/ts/src/idiom.ts"() {
40214
- "use strict";
40215
40214
  init_define_HHP_CATALOG();
40216
40215
  IDIOM_CONTEXTS = {
40217
40216
  ios: { native: ["ios"] },
@@ -41947,7 +41946,6 @@ function shouldRevealError(args) {
41947
41946
  var EMAIL_RE, URL_HOST_RE, INTEGER_RE, NUMBER_RE, AUTHORED_PATTERN_LIMIT, authoredPatterns;
41948
41947
  var init_validation = __esm({
41949
41948
  "../../core/ts/src/validation.ts"() {
41950
- "use strict";
41951
41949
  init_define_HHP_CATALOG();
41952
41950
  EMAIL_RE = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}$/;
41953
41951
  URL_HOST_RE = /^[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*(:[0-9]+)?$/;
@@ -198433,32 +198431,112 @@ async function attachConsole(port, io2 = {}) {
198433
198431
  return;
198434
198432
  Object.assign(auth, learnConsoleAuth(m2.params?.request?.url ?? "", m2.params?.request?.headers ?? {}));
198435
198433
  });
198434
+ const href = async () => (await cdp.send("Runtime.evaluate", { expression: "location.href", returnByValue: true }).catch(() => void 0))?.result?.value ?? "";
198435
+ const wantDev = io2.wantUrl ? developerIdFromUrl(io2.wantUrl) : void 0;
198436
+ const learn = async (timeoutMs) => {
198437
+ const deadline = Date.now() + timeoutMs;
198438
+ while (!(auth.apiKey && auth.authUser) && Date.now() < deadline) {
198439
+ await sleep4(250);
198440
+ await new Promise((r3) => setTimeout(r3, 0));
198441
+ }
198442
+ return !!(auth.apiKey && auth.authUser) && (!wantDev || developerIdFromUrl(await href()) === wantDev);
198443
+ };
198436
198444
  await cdp.send("Network.enable");
198437
198445
  await cdp.send("Page.reload", { ignoreCache: false });
198438
- const deadline = Date.now() + (io2.timeoutMs ?? 2e4);
198439
- while (!(auth.apiKey && auth.authUser) && Date.now() < deadline)
198440
- await sleep4(250);
198446
+ let ok5 = await learn(io2.timeoutMs ?? 2e4);
198447
+ let seen = ok5 ? "" : await href();
198448
+ if (!ok5 && wantDev && io2.wantUrl && !isSignInUrl(seen)) {
198449
+ const first = slotFromUrl(io2.wantUrl);
198450
+ for (let slot2 = 0; slot2 < MAX_SLOTS && !ok5; slot2++) {
198451
+ if (slot2 === first)
198452
+ continue;
198453
+ delete auth.apiKey;
198454
+ delete auth.authUser;
198455
+ await cdp.send("Page.navigate", { url: withSlot(io2.wantUrl, slot2) });
198456
+ ok5 = await learn(Math.min(io2.timeoutMs ?? 2e4, 1e4));
198457
+ }
198458
+ if (!ok5)
198459
+ seen = await href();
198460
+ }
198441
198461
  await cdp.send("Network.disable").catch(() => void 0);
198442
- if (!auth.apiKey || !auth.authUser) {
198462
+ if (!ok5) {
198443
198463
  cdp.close();
198444
- throw new ConsoleError("auth", "The Console page made no authorised call, so its key and account slot are unknown", { remediation: "Check the profile is signed in: gplay-node console login --show" });
198464
+ const where = seen ? ` (it showed ${seen})` : "";
198465
+ throw new ConsoleError("auth", wantDev && !isSignInUrl(seen) ? `No Google account signed in to this Chrome profile opened developer account ${wantDev}${where}` : `The Console page made no authorised call, so its key and account slot are unknown${where}`, { remediation: "Check the profile is signed in to the account that owns it: gplay-node console login --show" });
198445
198466
  }
198446
- const { result } = await cdp.send("Runtime.evaluate", { expression: "location.href", returnByValue: true });
198467
+ const slot = auth.authUser;
198468
+ const moveSlot = (text32) => slot === "0" ? text32 : text32.split(CONSOLE_HOME).join(withSlot(CONSOLE_HOME, slot));
198469
+ const result = { value: await href() };
198447
198470
  const page = {
198448
198471
  async evaluate(expression) {
198449
- const out2 = await cdp.send("Runtime.evaluate", { expression, awaitPromise: true, returnByValue: true });
198472
+ const out2 = await cdp.send("Runtime.evaluate", { expression: moveSlot(expression), awaitPromise: true, returnByValue: true });
198450
198473
  if (out2.exceptionDetails)
198451
198474
  throw new ConsoleError("server", `In-page call failed: ${out2.exceptionDetails.exception?.description ?? out2.exceptionDetails.text}`);
198452
198475
  return out2.result.value;
198453
198476
  },
198454
- send: (method, params = {}) => devtoolsSend(cdp, method, params)
198477
+ send: (method, params = {}) => devtoolsSend(cdp, method, method === "Page.navigate" && typeof params.url === "string" ? { ...params, url: moveSlot(params.url) } : params)
198455
198478
  };
198456
198479
  return { session: new ConsoleSession(page, auth), page, developerId: developerIdFromUrl(result.value), close: () => cdp.close() };
198457
198480
  }
198458
198481
  async function openConsole(launch, opts = {}, io2 = {}) {
198482
+ const opened = await openConsoleOnce(launch, opts, io2);
198483
+ return opts.reauth ? withPageSignIn(launch, opened, opts, io2) : opened;
198484
+ }
198485
+ function withPageSignIn(launch, opened, opts, io2 = {}) {
198486
+ let current = opened;
198487
+ let headless = launch.headless && !opened.reauthed;
198488
+ let told = false;
198489
+ const waitMs = opts.waitMs ?? 10 * 6e4;
198490
+ const sleep4 = sleepFor(io2);
198491
+ const tell = (what, how) => {
198492
+ if (told)
198493
+ return;
198494
+ told = true;
198495
+ opts.notify?.(`Google asked for a sign-in before ${what}. ${how}
198496
+ `);
198497
+ };
198498
+ const timedOut = (what) => new ConsoleError("auth", `The sign-in for ${what} didn't finish within ${Math.max(1, Math.round(waitMs / 6e4))} min`, { remediation: "Run it again with --reauth and a longer --wait-min, or sign in with gplay-node console login" });
198499
+ const page = {
198500
+ evaluate: (expression) => current.attached.page.evaluate(expression),
198501
+ send: (method, params) => current.attached.page.send(method, params),
198502
+ async signIn(what) {
198503
+ if (headless) {
198504
+ current.attached.close();
198505
+ current.chrome.close();
198506
+ await sleep4(1500);
198507
+ const chrome = await launchChrome({ ...launch, headless: false }, io2);
198508
+ headless = false;
198509
+ tell(what, "A Chrome window opened: sign in there yourself and the command carries on.");
198510
+ try {
198511
+ await waitForConsole(launch.port, waitMs, io2);
198512
+ current = { chrome, attached: await attachConsole(launch.port, { ...io2, wantUrl: launch.url }), reauthed: true };
198513
+ } catch (e2) {
198514
+ chrome.close();
198515
+ throw e2 instanceof ConsoleError && e2.kind === "auth" ? timedOut(what) : e2;
198516
+ }
198517
+ return;
198518
+ }
198519
+ tell(what, "Sign in in the Chrome window yourself and the command carries on.");
198520
+ const polls = Math.max(1, Math.ceil(waitMs / 2e3));
198521
+ for (let i2 = 0; i2 < polls; i2++) {
198522
+ const href = await current.attached.page.evaluate("location.href").catch(() => "");
198523
+ if (isConsoleUrl(href))
198524
+ return;
198525
+ await sleep4(2e3);
198526
+ }
198527
+ throw timedOut(what);
198528
+ }
198529
+ };
198530
+ return {
198531
+ chrome: { port: launch.port, close: () => current.chrome.close() },
198532
+ attached: { session: new ConsoleSession(page, opened.attached.session.auth), page, developerId: opened.attached.developerId, close: () => current.attached.close() },
198533
+ reauthed: opened.reauthed
198534
+ };
198535
+ }
198536
+ async function openConsoleOnce(launch, opts, io2) {
198459
198537
  let chrome = await launchChrome(launch, io2);
198460
198538
  try {
198461
- return { chrome, attached: await attachConsole(launch.port, io2), reauthed: false };
198539
+ return { chrome, attached: await attachConsole(launch.port, { ...io2, wantUrl: launch.url }), reauthed: false };
198462
198540
  } catch (e2) {
198463
198541
  chrome.close();
198464
198542
  if (!(e2 instanceof ConsoleError && e2.kind === "auth" && opts.reauth))
@@ -198469,14 +198547,14 @@ async function openConsole(launch, opts = {}, io2 = {}) {
198469
198547
  `);
198470
198548
  try {
198471
198549
  await waitForConsole(launch.port, opts.waitMs ?? 10 * 6e4, io2);
198472
- return { chrome, attached: await attachConsole(launch.port, io2), reauthed: true };
198550
+ return { chrome, attached: await attachConsole(launch.port, { ...io2, wantUrl: launch.url }), reauthed: true };
198473
198551
  } catch (again) {
198474
198552
  chrome.close();
198475
198553
  throw again;
198476
198554
  }
198477
198555
  }
198478
198556
  }
198479
- var nodeSpawn3, mkdir6, CONSOLE_HOME, CONSOLE_SIGN_IN, sleepFor, developerIdFromUrl, isSignInUrl, isReauthUrl, isConsoleUrl, Cdp, PAGE_DEVTOOLS_METHODS;
198557
+ var nodeSpawn3, mkdir6, CONSOLE_HOME, CONSOLE_SIGN_IN, sleepFor, slotFromUrl, withSlot, MAX_SLOTS, developerIdFromUrl, isSignInUrl, isReauthUrl, isConsoleUrl, Cdp, PAGE_DEVTOOLS_METHODS;
198480
198558
  var init_console_cdp = __esm({
198481
198559
  "../../node_modules/@wix/gplay-api/dist/console-cdp.js"() {
198482
198560
  init_define_HHP_CATALOG();
@@ -198486,6 +198564,9 @@ var init_console_cdp = __esm({
198486
198564
  CONSOLE_HOME = "https://play.google.com/console/u/0/developers";
198487
198565
  CONSOLE_SIGN_IN = `https://accounts.google.com/ServiceLogin?continue=${encodeURIComponent("https://play.google.com/console/")}`;
198488
198566
  sleepFor = (io2) => io2.sleep ?? ((ms2) => new Promise((r3) => setTimeout(r3, ms2)));
198567
+ slotFromUrl = (url) => Number(url.match(/play\.google\.com\/console\/u\/(\d+)\//)?.[1] ?? 0);
198568
+ withSlot = (url, slot) => url.replace(/(play\.google\.com\/console\/)(?:u\/\d+\/)?/, `$1u/${slot}/`);
198569
+ MAX_SLOTS = 5;
198489
198570
  developerIdFromUrl = (url) => url.match(/play\.google\.com\/console\/(?:u\/\d+\/)?developers\/(\d{6,25})(?:[/?#]|$)/)?.[1];
198490
198571
  isSignInUrl = (url) => /^https:\/\/accounts\.google\.com\//.test(url);
198491
198572
  isReauthUrl = (url) => /^https:\/\/accounts\.google\.com\/(?:v3\/)?signin\/(?:confirmidentifier|challenge)/.test(url);
@@ -198535,266 +198616,44 @@ var init_console_cdp = __esm({
198535
198616
  }
198536
198617
  });
198537
198618
 
198538
- // ../../node_modules/@wix/gplay-api/dist/console-app.js
198539
- function checkCreateApp(opts) {
198540
- if (!opts.name.trim() || opts.name.length > 30)
198541
- throw new ConsoleError("invalid", `The app name must be 1 to 30 characters (got ${opts.name.length})`);
198542
- if (!PACKAGE_NAME.test(opts.packageName) || opts.packageName.length > 150)
198543
- throw new ConsoleError("invalid", `"${opts.packageName}" isn't an Android package name`);
198544
- if (!opts.dryRun && !opts.acceptDeclarations) {
198545
- throw new ConsoleError("invalid", "Creating an app needs the owner to accept Google's declarations", {
198546
- remediation: `Show the owner these and pass --accept-declarations once they agree: ${CREATE_APP_DECLARATIONS.map((d2) => `"${d2.title}" (${d2.url})`).join("; ")}. Or use --dry-run`
198547
- });
198548
- }
198549
- }
198550
- async function createConsoleApp(page, developerId, opts) {
198551
- checkDeveloperId(developerId);
198552
- checkCreateApp(opts);
198553
- const full = { name: opts.name, packageName: opts.packageName, type: opts.type ?? "app", pricing: opts.pricing ?? "free" };
198554
- await page.evaluate(createAppScripts.open(developerId)).catch(() => void 0);
198555
- let ready = false;
198556
- for (let attempt2 = 0; attempt2 < 4 && ready !== true; attempt2++) {
198557
- await new Promise((r3) => setTimeout(r3, attempt2 === 0 ? 1500 : 1e3));
198558
- ready = await page.evaluate(createAppScripts.ready()).catch(() => false);
198559
- if (ready === "signin")
198560
- throw new ConsoleError("auth", "Google asked for a sign-in instead of opening Create app", { remediation: "Add --reauth to sign in again in a window, or run gplay-node console login" });
198561
- }
198562
- if (!ready)
198563
- throw new ConsoleError("server", "The Create app form didn't load", { remediation: "Check the account can create apps: gplay-node console status" });
198564
- const filled2 = await page.evaluate(createAppScripts.fill(full));
198565
- if (filled2.error)
198566
- throw new ConsoleError("server", `Create app form: ${filled2.error}`);
198567
- if (filled2.name !== full.name || filled2.packageName !== full.packageName)
198568
- throw new ConsoleError("server", "The Create app form didn't take the name or package name");
198569
- const wanted = [full.type === "game" ? "Game" : "App", full.pricing === "paid" ? "Paid" : "Free"];
198570
- if (!wanted.every((w2) => filled2.radios?.[w2]))
198571
- throw new ConsoleError("server", `The Create app form didn't take ${wanted.join(" and ")}`);
198572
- if (filled2.verdict !== "available") {
198573
- throw new ConsoleError(filled2.verdict === "unknown" ? "server" : "conflict", filled2.verdict === "unknown" ? "Play Console gave no answer on the package name" : `Package name ${full.packageName}: ${filled2.verdict}`);
198574
- }
198575
- const known2 = new Set(CREATE_APP_DECLARATIONS.map((d2) => d2.title));
198576
- const unknown = (filled2.declarations ?? []).filter((t2) => !known2.has(t2));
198577
- if (unknown.length)
198578
- throw new ConsoleError("invalid", `The form asks for declarations the owner wasn't shown: ${unknown.join("; ")}`, { remediation: "Update CREATE_APP_DECLARATIONS after the owner reads them" });
198579
- if (opts.dryRun)
198580
- return { name: full.name, packageName: full.packageName, created: false, dryRun: true };
198581
- const accepted = await page.evaluate(createAppScripts.accept(filled2.declarations ?? []));
198582
- if (accepted.error || accepted.ticked !== accepted.total)
198583
- throw new ConsoleError("server", `Declarations: ${accepted.error ?? `${accepted.ticked} of ${accepted.total} ticked`}`);
198584
- const submitted = await page.evaluate(createAppScripts.submit());
198585
- if (submitted.error || !submitted.clicked)
198586
- throw new ConsoleError("server", `Create app: ${submitted.error ?? "the button wasn't pressed"}`);
198587
- let errors = [];
198588
- for (let waited = 0; waited < (opts.landTimeoutMs ?? 3e4); waited += 1e3) {
198589
- await pause(1e3);
198590
- const landed = await page.evaluate(createAppScripts.landed()).catch(() => null);
198591
- if (landed?.appId)
198592
- return { name: full.name, packageName: full.packageName, created: true, appId: landed.appId };
198593
- if (landed)
198594
- errors = landed.errors;
198595
- }
198596
- throw new ConsoleError("uncertain", `Create app was pressed but the new app didn't open${errors.length ? `: ${errors.join(" | ")}` : ""}`, { remediation: "Check the app list in Play Console before trying again" });
198597
- }
198598
- var CREATE_APP_DECLARATIONS, PACKAGE_NAME, IN_PAGE, createAppScripts, pause;
198599
- var init_console_app = __esm({
198600
- "../../node_modules/@wix/gplay-api/dist/console-app.js"() {
198601
- init_define_HHP_CATALOG();
198602
- init_console();
198603
- init_console_cdp();
198604
- CREATE_APP_DECLARATIONS = [
198605
- { id: "policies", title: "Confirm app meets the Developer Program Policies", url: "https://play.google.com/about/developer-content-policy/" },
198606
- { id: "app-signing", title: "Accept the Play App Signing Terms of Service", url: "https://play.google.com/about/play-app-signing-terms/" },
198607
- { id: "export-laws", title: "Accept US export laws", url: "https://support.google.com/googleplay/android-developer/answer/113770" }
198608
- ];
198609
- PACKAGE_NAME = /^[a-zA-Z][a-zA-Z0-9_]*(\.[a-zA-Z][a-zA-Z0-9_]*)+$/;
198610
- IN_PAGE = String.raw`
198611
- const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
198612
- const input = (label) => [...document.querySelectorAll('input')].find((x) => x.getAttribute('aria-label') === label);
198613
- const button = (label) => [...document.querySelectorAll('button')].find((b) => b.offsetParent && b.innerText.replace(/\s+/g, ' ').trim() === label);
198614
- const radio = (label) => [...document.querySelectorAll('material-radio')].find((r) => r.innerText.trim() === label);
198615
- const setText = (el, value) => {
198616
- el.focus();
198617
- Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value').set.call(el, value);
198618
- el.dispatchEvent(new Event('input', { bubbles: true }));
198619
- el.dispatchEvent(new Event('change', { bubbles: true }));
198620
- el.dispatchEvent(new Event('blur', { bubbles: true }));
198621
- };
198622
- const until = async (test, ms) => { for (let t = 0; t < ms; t += 250) { const v = test(); if (v) return v; await sleep(250); } return null; };
198623
- `;
198624
- createAppScripts = {
198625
- open: (developerId) => `/*step:open*/(() => { location.href = ${JSON.stringify(`${CONSOLE_HOME}/${developerId}/create-new-app`)}; return true; })()`,
198626
- // Google's sign-in page instead of the form (its "Verify it's you") answers "signin", as openForm's does.
198627
- ready: () => `/*step:ready*/(async () => { ${IN_PAGE} const r = await until(() => location.host === 'accounts.google.com' ? 'signin' : input('App name') && input('App package name'), 20000); return r === 'signin' ? 'signin' : !!r; })()`,
198628
- fill: (o2) => String.raw`/*step:fill*/(async () => { ${IN_PAGE}
198629
- setText(input('App name'), ${JSON.stringify(o2.name)});
198630
- setText(input('App package name'), ${JSON.stringify(o2.packageName)});
198631
- for (const label of [${JSON.stringify(o2.type === "game" ? "Game" : "App")}, ${JSON.stringify(o2.pricing === "paid" ? "Paid" : "Free")}]) { const r = radio(label); if (!r) return { error: 'no "' + label + '" choice on the form' }; r.click(); await sleep(200); }
198632
- const check = button('Check availability'); if (!check) return { error: 'no Check availability button' };
198633
- check.click();
198634
- const main = () => (document.querySelector('main, [role=main]') || document.body).innerText;
198635
- const verdict = await until(() => /Package name available/.test(main()) ? 'available' : (/(not available|already (in use|exists|been used)|isn't available|invalid)/i.exec(main()) || [])[0], 15000);
198636
- const radios = Object.fromEntries([...document.querySelectorAll('material-radio')].map((r) => [r.innerText.trim(), !!r.querySelector('input')?.checked]));
198637
- return { verdict: verdict || 'unknown', name: input('App name').value, packageName: input('App package name').value, radios,
198638
- declarations: [...document.querySelectorAll('material-checkbox')].map((c) => c.innerText.split(String.fromCharCode(10))[0].trim()) };
198639
- })()`,
198640
- accept: (titles) => String.raw`/*step:accept*/(async () => { ${IN_PAGE}
198641
- const boxes = [...document.querySelectorAll('material-checkbox')];
198642
- for (const title of ${JSON.stringify(titles)}) {
198643
- const box = boxes.find((c) => c.innerText.split(String.fromCharCode(10))[0].trim() === title);
198644
- if (!box) return { error: 'declaration not found: ' + title };
198645
- if (!box.querySelector('input')?.checked) box.click();
198646
- await sleep(150);
198647
- }
198648
- return { ticked: boxes.filter((c) => c.querySelector('input')?.checked).length, total: boxes.length };
198649
- })()`,
198650
- // Create app navigates the page, which kills any script still running in it (OBSERVED 2026-11-10: "Inspected target
198651
- // navigated or closed", with the app created). So the click is scheduled after this script returns, and `landed` is
198652
- // polled with fresh calls.
198653
- submit: () => String.raw`/*step:submit*/(() => { ${IN_PAGE}
198654
- const b = button('Create app'); if (!b) return { error: 'no Create app button' };
198655
- if (b.disabled || b.getAttribute('aria-disabled') === 'true') return { error: 'Create app is disabled' };
198656
- setTimeout(() => b.click(), 50);
198657
- return { clicked: true };
198658
- })()`,
198659
- landed: () => String.raw`/*step:landed*/(() => ({
198660
- appId: (location.pathname.match(/\/app\/(\d{6,25})(?:\/|$)/) || [])[1] ?? null,
198661
- errors: [...document.querySelectorAll('[role=alert], .error-text, material-input .error')].map((e) => e.innerText.trim()).filter(Boolean),
198662
- }))()`
198663
- };
198664
- pause = (ms2) => new Promise((r3) => setTimeout(r3, ms2));
198665
- }
198666
- });
198667
-
198668
- // ../../node_modules/@wix/gplay-api/dist/connect.js
198669
- import * as __ascBuiltin09 from "node:fs/promises";
198670
- import * as __ascBuiltin18 from "node:path";
198671
- function defaultClientFile(env, stateDir2) {
198672
- return env[OAUTH_CLIENT_ENV] || join104(stateDir2, "oauth-client.json");
198673
- }
198674
- function missingClientFileMessage(path2) {
198675
- return `No OAuth client file at ${path2}. Put the Desktop client's JSON there, or set ${OAUTH_CLIENT_ENV} (or pass --client-file) to its path. A Wix Cloud admin creates the Internal client; it is never committed.`;
198676
- }
198677
- async function requireClientFile(path2) {
198678
- try {
198679
- await access(path2);
198680
- } catch {
198681
- throw new AuthError(missingClientFileMessage(path2), { remediation: `Put the file at ${path2} or set ${OAUTH_CLIENT_ENV}` });
198682
- }
198683
- }
198684
- async function signedInEmail(user, o2 = {}) {
198685
- const fetchImpl = o2.fetch ?? ((input, init) => globalThis.fetch(input, init));
198686
- try {
198687
- const grant = await new RefreshTokenAuth(user, { fetch: o2.fetch, ...o2.tokenUri ? { tokenUri: o2.tokenUri } : o2.baseUrl ? { tokenUri: `${o2.baseUrl}/${HOSTS.oauth}/token` } : {} }).token();
198688
- const url = o2.baseUrl ? `${o2.baseUrl}/${new URL(USERINFO).host}${new URL(USERINFO).pathname}` : USERINFO;
198689
- const res = await fetchImpl(url, { headers: { authorization: `Bearer ${grant.token}` } });
198690
- if (!res.ok)
198691
- return void 0;
198692
- const info4 = await res.json();
198693
- return typeof info4.email === "string" && info4.email ? info4.email : void 0;
198694
- } catch {
198695
- return void 0;
198696
- }
198697
- }
198698
- async function connectGoogle(opts) {
198699
- await requireClientFile(opts.clientFile);
198700
- const read2 = await readOAuthClientFile(opts.clientFile);
198701
- const client4 = opts.client ? opts.client(read2) : read2;
198702
- const scopes = [.../* @__PURE__ */ new Set([...opts.scopes, ...OPENID])];
198703
- if (opts.signal?.aborted)
198704
- return { connected: false, code: "aborted", message: "The sign-in was aborted before it started." };
198705
- let user;
198706
- try {
198707
- user = await loginWithOAuthClient({ client: client4, openBrowser: opts.openBrowser, scopes, fetch: opts.fetch, timeoutMs: opts.timeoutMs, signal: opts.signal });
198708
- } catch (e2) {
198709
- const message5 = e2.message;
198710
- if (/access_denied/.test(message5))
198711
- return { connected: false, code: "consent_denied", message: "Google sign-in was declined, so nothing was connected." };
198712
- if (opts.signal?.aborted)
198713
- return { connected: false, code: "aborted", message: "The sign-in was aborted, so nothing was connected." };
198714
- if (e2 instanceof AuthError)
198715
- return { connected: false, code: "sign_in_failed", message: message5 };
198716
- throw e2;
198717
- }
198718
- const email = await signedInEmail(user, { fetch: opts.fetch });
198719
- if (opts.signal?.aborted)
198720
- return { connected: false, code: "aborted", message: "The sign-in was aborted, so nothing was connected." };
198721
- await opts.store.save({ ...user, ...email ? { account: email } : {} });
198722
- const account2 = email ?? "unknown";
198723
- let developerId;
198724
- let consoleReady = false;
198725
- let consoleNote;
198726
- const pending2 = openConsole(opts.console.launch, { reauth: opts.console.reauth, waitMs: opts.waitMs, notify: opts.notify }, opts.consoleIo);
198727
- let abort;
198728
- const aborted = new Promise((resolve130) => {
198729
- abort = () => resolve130("aborted");
198730
- if (opts.signal?.aborted)
198731
- resolve130("aborted");
198732
- else
198733
- opts.signal?.addEventListener("abort", abort, { once: true });
198734
- });
198735
- try {
198736
- const opened = await Promise.race([pending2, aborted]);
198737
- if (opened === "aborted") {
198738
- void pending2.then((o2) => {
198739
- o2.attached.close();
198740
- o2.chrome.close();
198741
- }, () => void 0);
198742
- return { connected: false, code: "aborted", message: "Aborted during the Play Console step. The Google sign-in was saved; run the connect again to ready the Console." };
198743
- }
198744
- try {
198745
- developerId = opened.attached.developerId;
198746
- consoleReady = true;
198747
- } finally {
198748
- opened.attached.close();
198749
- opened.chrome.close();
198750
- }
198751
- } catch (e2) {
198752
- consoleNote = `Signed in to Google, but the Play Console profile isn't ready: ${e2.message}`;
198753
- } finally {
198754
- if (abort)
198755
- opts.signal?.removeEventListener("abort", abort);
198756
- }
198757
- return { connected: true, account: account2, ...developerId ? { developerId } : {}, consoleReady, ...consoleNote ? { consoleNote } : {} };
198758
- }
198759
- var access, join104, OAUTH_CLIENT_ENV, USERINFO, OPENID;
198760
- var init_connect = __esm({
198761
- "../../node_modules/@wix/gplay-api/dist/connect.js"() {
198762
- init_define_HHP_CATALOG();
198763
- init_errors3();
198764
- init_auth2();
198765
- init_transport();
198766
- init_console_cdp();
198767
- ({ access } = __ascBuiltin09);
198768
- ({ join: join104 } = __ascBuiltin18);
198769
- OAUTH_CLIENT_ENV = "GPLAY_OAUTH_CLIENT_FILE";
198770
- USERINFO = "https://openidconnect.googleapis.com/v1/userinfo";
198771
- OPENID = ["openid", "email"];
198772
- }
198773
- });
198774
-
198775
198619
  // ../../node_modules/@wix/gplay-api/dist/console-forms.js
198776
198620
  function checkAppId(id) {
198777
198621
  if (!APP_ID2.test(id))
198778
198622
  throw new ConsoleError("invalid", `"${id}" isn't a Play Console app id (the number after /app/ in the app's Console URL)`);
198779
198623
  return id;
198780
198624
  }
198625
+ async function awaitSignIn(page, what) {
198626
+ if (!page.signIn)
198627
+ throw new ConsoleError("auth", `Google asked for a sign-in instead of opening ${what}`, { remediation: "Add --reauth to sign in again in a window, or run gplay-node console login" });
198628
+ await page.signIn(what);
198629
+ }
198781
198630
  async function openForm(page, url, readyTest, what, opts = {}, settleMs = SETTLE_MS) {
198782
- const reply = await page.send("Page.navigate", { url });
198783
- if (reply?.errorText)
198784
- throw new ConsoleError("network", `Couldn't open ${what}: ${reply.errorText}`);
198785
198631
  const sleep4 = sleeperOf(opts);
198786
198632
  const tries = Math.max(1, Math.ceil((opts.readyTimeoutMs ?? 3e4) / 500));
198787
- for (let i2 = 0; i2 < tries; i2++) {
198788
- await sleep4(500);
198789
- const state = await page.evaluate(formScript("ready", `if (location.host === 'accounts.google.com') return 'signin'; return !!(${readyTest});`)).catch(() => false);
198790
- if (state === "signin")
198791
- throw new ConsoleError("auth", `Google asked for a sign-in instead of opening ${what}`, { remediation: "Add --reauth to sign in again in a window, or run gplay-node console login" });
198792
- if (state === true) {
198793
- await sleep4(settleMs);
198794
- return;
198633
+ for (let signIns = 0; ; signIns++) {
198634
+ const reply = await page.send("Page.navigate", { url });
198635
+ if (reply?.errorText)
198636
+ throw new ConsoleError("network", `Couldn't open ${what}: ${reply.errorText}`);
198637
+ let signin = false;
198638
+ for (let i2 = 0; i2 < tries && !signin; i2++) {
198639
+ await sleep4(500);
198640
+ const state = await page.evaluate(formScript("ready", `if (${SIGN_IN_TEST}) return 'signin'; return !!(${readyTest});`)).catch(() => false);
198641
+ if (state === "signin")
198642
+ signin = true;
198643
+ else if (state === true) {
198644
+ await sleep4(settleMs);
198645
+ return;
198646
+ }
198795
198647
  }
198648
+ if (!signin)
198649
+ break;
198650
+ if (signIns >= MAX_SIGN_INS)
198651
+ throw new ConsoleError("auth", `Google kept asking for a sign-in instead of opening ${what}`, { remediation: "Sign in with gplay-node console login --show, then run it again" });
198652
+ await awaitSignIn(page, what);
198796
198653
  }
198797
- throw new ConsoleError("server", `${what} didn't load in Play Console`, { remediation: "Check the app id and that this Google account can see the app; --show opens the window to watch" });
198654
+ const seen = await page.evaluate("({ href: location.href, title: document.title })").catch(() => null);
198655
+ const at2 = seen?.href ? ` (it showed ${seen.href}${seen.title ? `, "${seen.title}"` : ""})` : "";
198656
+ throw new ConsoleError("server", `${what} didn't load in Play Console${at2}`, { remediation: "Check the app id and that this Google account can see the app; --show opens the window to watch" });
198798
198657
  }
198799
198658
  async function pressSave(page, what, twoStep, opts = {}) {
198800
198659
  const sleep4 = sleeperOf(opts);
@@ -199090,7 +198949,7 @@ async function checkConsoleAppPackage(page, developerId, appId3, packageArg, opt
199090
198949
  if (lines2.length !== 1 || lines2[0] !== packageName)
199091
198950
  throw new ConsoleAppMismatchError(appId3, packageName, lines2);
199092
198951
  }
199093
- var APP_ID2, appPageUrl, sleeperOf, SETTLE_MS, SAVE_WAIT_MS, FORM_IN_PAGE, PRESS_IN, formScript, READBACK_TRIES, READBACK_GAP_MS, notStuck, DECLARATION_TITLES, tabScript, declarationScripts, CHOICE_FORMS, TARGET_AGE_GROUPS, PROVEN_AGE_GROUPS, DECLARE_FORMS, FORM_READY, declareScripts, ticked, sameGroups, PACKAGE_LINE, ConsoleAppMismatchError, appPackageScript, APP_LIST_READY, appListPackageScript;
198952
+ var APP_ID2, appPageUrl, sleeperOf, SETTLE_MS, SAVE_WAIT_MS, FORM_IN_PAGE, PRESS_IN, formScript, SIGN_IN_TEST, MAX_SIGN_INS, READBACK_TRIES, READBACK_GAP_MS, notStuck, DECLARATION_TITLES, tabScript, declarationScripts, CHOICE_FORMS, TARGET_AGE_GROUPS, PROVEN_AGE_GROUPS, DECLARE_FORMS, FORM_READY, declareScripts, ticked, sameGroups, PACKAGE_LINE, ConsoleAppMismatchError, appPackageScript, APP_LIST_READY, appListPackageScript;
199094
198953
  var init_console_forms = __esm({
199095
198954
  "../../node_modules/@wix/gplay-api/dist/console-forms.js"() {
199096
198955
  init_define_HHP_CATALOG();
@@ -199119,6 +198978,8 @@ var init_console_forms = __esm({
199119
198978
  `;
199120
198979
  PRESS_IN = String.raw`const pressIn = (scope, label) => { const b = [...scope.querySelectorAll('button, material-button, [role=button], a')].find((e) => visible(e) && norm(e.innerText) === label); if (!b) return 'missing'; if (b.disabled || b.getAttribute('aria-disabled') === 'true') return 'disabled'; b.click(); return 'pressed'; };`;
199121
198980
  formScript = (step, body) => `/*step:${step}*/(async () => { ${FORM_IN_PAGE} ${body} })()`;
198981
+ SIGN_IN_TEST = "location.host === 'accounts.google.com'";
198982
+ MAX_SIGN_INS = 2;
199122
198983
  READBACK_TRIES = 3;
199123
198984
  READBACK_GAP_MS = 4e3;
199124
198985
  notStuck = (what, saw) => new ConsoleError("server", `${what}: Save was pressed, but after a reload the form shows ${saw}`, { remediation: "Open the form in Play Console to see what it holds; nothing else was changed" });
@@ -199241,6 +199102,250 @@ var init_console_forms = __esm({
199241
199102
  }
199242
199103
  });
199243
199104
 
199105
+ // ../../node_modules/@wix/gplay-api/dist/console-app.js
199106
+ function checkCreateApp(opts) {
199107
+ if (!opts.name.trim() || opts.name.length > 30)
199108
+ throw new ConsoleError("invalid", `The app name must be 1 to 30 characters (got ${opts.name.length})`);
199109
+ if (!PACKAGE_NAME.test(opts.packageName) || opts.packageName.length > 150)
199110
+ throw new ConsoleError("invalid", `"${opts.packageName}" isn't an Android package name`);
199111
+ if (!opts.dryRun && !opts.acceptDeclarations) {
199112
+ throw new ConsoleError("invalid", "Creating an app needs the owner to accept Google's declarations", {
199113
+ remediation: `Show the owner these and pass --accept-declarations once they agree: ${CREATE_APP_DECLARATIONS.map((d2) => `"${d2.title}" (${d2.url})`).join("; ")}. Or use --dry-run`
199114
+ });
199115
+ }
199116
+ }
199117
+ async function createConsoleApp(page, developerId, opts) {
199118
+ checkDeveloperId(developerId);
199119
+ checkCreateApp(opts);
199120
+ const full = { name: opts.name, packageName: opts.packageName, type: opts.type ?? "app", pricing: opts.pricing ?? "free" };
199121
+ let ready = false;
199122
+ for (let signIns = 0; ; signIns++) {
199123
+ await page.evaluate(createAppScripts.open(developerId)).catch(() => void 0);
199124
+ ready = false;
199125
+ for (let attempt2 = 0; attempt2 < 4 && ready === false; attempt2++) {
199126
+ await new Promise((r3) => setTimeout(r3, attempt2 === 0 ? 1500 : 1e3));
199127
+ ready = await page.evaluate(createAppScripts.ready()).catch(() => false);
199128
+ }
199129
+ if (ready !== "signin")
199130
+ break;
199131
+ if (signIns >= 2)
199132
+ throw new ConsoleError("auth", "Google kept asking for a sign-in instead of opening Create app", { remediation: "Sign in with gplay-node console login --show, then run it again" });
199133
+ await awaitSignIn(page, "Create app");
199134
+ }
199135
+ if (!ready)
199136
+ throw new ConsoleError("server", "The Create app form didn't load", { remediation: "Check the account can create apps: gplay-node console status" });
199137
+ const filled2 = await page.evaluate(createAppScripts.fill(full));
199138
+ if (filled2.error)
199139
+ throw new ConsoleError("server", `Create app form: ${filled2.error}`);
199140
+ if (filled2.name !== full.name || filled2.packageName !== full.packageName)
199141
+ throw new ConsoleError("server", "The Create app form didn't take the name or package name");
199142
+ const wanted = [full.type === "game" ? "Game" : "App", full.pricing === "paid" ? "Paid" : "Free"];
199143
+ if (!wanted.every((w2) => filled2.radios?.[w2]))
199144
+ throw new ConsoleError("server", `The Create app form didn't take ${wanted.join(" and ")}`);
199145
+ if (filled2.verdict !== "available") {
199146
+ throw new ConsoleError(filled2.verdict === "unknown" ? "server" : "conflict", filled2.verdict === "unknown" ? "Play Console gave no answer on the package name" : `Package name ${full.packageName}: ${filled2.verdict}`);
199147
+ }
199148
+ const known2 = new Set(CREATE_APP_DECLARATIONS.map((d2) => d2.title));
199149
+ const unknown = (filled2.declarations ?? []).filter((t2) => !known2.has(t2));
199150
+ if (unknown.length)
199151
+ throw new ConsoleError("invalid", `The form asks for declarations the owner wasn't shown: ${unknown.join("; ")}`, { remediation: "Update CREATE_APP_DECLARATIONS after the owner reads them" });
199152
+ if (opts.dryRun)
199153
+ return { name: full.name, packageName: full.packageName, created: false, dryRun: true };
199154
+ const accepted = await page.evaluate(createAppScripts.accept(filled2.declarations ?? []));
199155
+ if (accepted.error || accepted.ticked !== accepted.total)
199156
+ throw new ConsoleError("server", `Declarations: ${accepted.error ?? `${accepted.ticked} of ${accepted.total} ticked`}`);
199157
+ const submitted = await page.evaluate(createAppScripts.submit());
199158
+ if (submitted.error || !submitted.clicked)
199159
+ throw new ConsoleError("server", `Create app: ${submitted.error ?? "the button wasn't pressed"}`);
199160
+ let errors = [];
199161
+ for (let waited = 0; waited < (opts.landTimeoutMs ?? 3e4); waited += 1e3) {
199162
+ await pause(1e3);
199163
+ const landed = await page.evaluate(createAppScripts.landed()).catch(() => null);
199164
+ if (landed?.appId)
199165
+ return { name: full.name, packageName: full.packageName, created: true, appId: landed.appId };
199166
+ if (landed)
199167
+ errors = landed.errors;
199168
+ }
199169
+ throw new ConsoleError("uncertain", `Create app was pressed but the new app didn't open${errors.length ? `: ${errors.join(" | ")}` : ""}`, { remediation: "Check the app list in Play Console before trying again" });
199170
+ }
199171
+ var CREATE_APP_DECLARATIONS, PACKAGE_NAME, IN_PAGE, createAppScripts, pause;
199172
+ var init_console_app = __esm({
199173
+ "../../node_modules/@wix/gplay-api/dist/console-app.js"() {
199174
+ init_define_HHP_CATALOG();
199175
+ init_console();
199176
+ init_console_cdp();
199177
+ init_console_forms();
199178
+ CREATE_APP_DECLARATIONS = [
199179
+ { id: "policies", title: "Confirm app meets the Developer Program Policies", url: "https://play.google.com/about/developer-content-policy/" },
199180
+ { id: "app-signing", title: "Accept the Play App Signing Terms of Service", url: "https://play.google.com/about/play-app-signing-terms/" },
199181
+ { id: "export-laws", title: "Accept US export laws", url: "https://support.google.com/googleplay/android-developer/answer/113770" }
199182
+ ];
199183
+ PACKAGE_NAME = /^[a-zA-Z][a-zA-Z0-9_]*(\.[a-zA-Z][a-zA-Z0-9_]*)+$/;
199184
+ IN_PAGE = String.raw`
199185
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
199186
+ const input = (label) => [...document.querySelectorAll('input')].find((x) => x.getAttribute('aria-label') === label);
199187
+ const button = (label) => [...document.querySelectorAll('button')].find((b) => b.offsetParent && b.innerText.replace(/\s+/g, ' ').trim() === label);
199188
+ const radio = (label) => [...document.querySelectorAll('material-radio')].find((r) => r.innerText.trim() === label);
199189
+ const setText = (el, value) => {
199190
+ el.focus();
199191
+ Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value').set.call(el, value);
199192
+ el.dispatchEvent(new Event('input', { bubbles: true }));
199193
+ el.dispatchEvent(new Event('change', { bubbles: true }));
199194
+ el.dispatchEvent(new Event('blur', { bubbles: true }));
199195
+ };
199196
+ const until = async (test, ms) => { for (let t = 0; t < ms; t += 250) { const v = test(); if (v) return v; await sleep(250); } return null; };
199197
+ `;
199198
+ createAppScripts = {
199199
+ open: (developerId) => `/*step:open*/(() => { location.href = ${JSON.stringify(`${CONSOLE_HOME}/${developerId}/create-new-app`)}; return true; })()`,
199200
+ // Google's sign-in page instead of the form (its "Verify it's you") answers "signin", as openForm's does.
199201
+ ready: () => `/*step:ready*/(async () => { ${IN_PAGE} const r = await until(() => ${SIGN_IN_TEST} ? 'signin' : input('App name') && input('App package name'), 20000); return r === 'signin' ? 'signin' : !!r; })()`,
199202
+ fill: (o2) => String.raw`/*step:fill*/(async () => { ${IN_PAGE}
199203
+ setText(input('App name'), ${JSON.stringify(o2.name)});
199204
+ setText(input('App package name'), ${JSON.stringify(o2.packageName)});
199205
+ for (const label of [${JSON.stringify(o2.type === "game" ? "Game" : "App")}, ${JSON.stringify(o2.pricing === "paid" ? "Paid" : "Free")}]) { const r = radio(label); if (!r) return { error: 'no "' + label + '" choice on the form' }; r.click(); await sleep(200); }
199206
+ const check = button('Check availability'); if (!check) return { error: 'no Check availability button' };
199207
+ check.click();
199208
+ const main = () => (document.querySelector('main, [role=main]') || document.body).innerText;
199209
+ const verdict = await until(() => /Package name available/.test(main()) ? 'available' : (/(not available|already (in use|exists|been used)|isn't available|invalid)/i.exec(main()) || [])[0], 15000);
199210
+ const radios = Object.fromEntries([...document.querySelectorAll('material-radio')].map((r) => [r.innerText.trim(), !!r.querySelector('input')?.checked]));
199211
+ return { verdict: verdict || 'unknown', name: input('App name').value, packageName: input('App package name').value, radios,
199212
+ declarations: [...document.querySelectorAll('material-checkbox')].map((c) => c.innerText.split(String.fromCharCode(10))[0].trim()) };
199213
+ })()`,
199214
+ accept: (titles) => String.raw`/*step:accept*/(async () => { ${IN_PAGE}
199215
+ const boxes = [...document.querySelectorAll('material-checkbox')];
199216
+ for (const title of ${JSON.stringify(titles)}) {
199217
+ const box = boxes.find((c) => c.innerText.split(String.fromCharCode(10))[0].trim() === title);
199218
+ if (!box) return { error: 'declaration not found: ' + title };
199219
+ if (!box.querySelector('input')?.checked) box.click();
199220
+ await sleep(150);
199221
+ }
199222
+ return { ticked: boxes.filter((c) => c.querySelector('input')?.checked).length, total: boxes.length };
199223
+ })()`,
199224
+ // Create app navigates the page, which kills any script still running in it (OBSERVED 2026-11-10: "Inspected target
199225
+ // navigated or closed", with the app created). So the click is scheduled after this script returns, and `landed` is
199226
+ // polled with fresh calls.
199227
+ submit: () => String.raw`/*step:submit*/(() => { ${IN_PAGE}
199228
+ const b = button('Create app'); if (!b) return { error: 'no Create app button' };
199229
+ if (b.disabled || b.getAttribute('aria-disabled') === 'true') return { error: 'Create app is disabled' };
199230
+ setTimeout(() => b.click(), 50);
199231
+ return { clicked: true };
199232
+ })()`,
199233
+ landed: () => String.raw`/*step:landed*/(() => ({
199234
+ appId: (location.pathname.match(/\/app\/(\d{6,25})(?:\/|$)/) || [])[1] ?? null,
199235
+ errors: [...document.querySelectorAll('[role=alert], .error-text, material-input .error')].map((e) => e.innerText.trim()).filter(Boolean),
199236
+ }))()`
199237
+ };
199238
+ pause = (ms2) => new Promise((r3) => setTimeout(r3, ms2));
199239
+ }
199240
+ });
199241
+
199242
+ // ../../node_modules/@wix/gplay-api/dist/connect.js
199243
+ import * as __ascBuiltin09 from "node:fs/promises";
199244
+ import * as __ascBuiltin18 from "node:path";
199245
+ function defaultClientFile(env, stateDir2) {
199246
+ return env[OAUTH_CLIENT_ENV] || join104(stateDir2, "oauth-client.json");
199247
+ }
199248
+ function missingClientFileMessage(path2) {
199249
+ return `No OAuth client file at ${path2}. Put the Desktop client's JSON there, or set ${OAUTH_CLIENT_ENV} (or pass --client-file) to its path. A Wix Cloud admin creates the Internal client; it is never committed.`;
199250
+ }
199251
+ async function requireClientFile(path2) {
199252
+ try {
199253
+ await access(path2);
199254
+ } catch {
199255
+ throw new AuthError(missingClientFileMessage(path2), { remediation: `Put the file at ${path2} or set ${OAUTH_CLIENT_ENV}` });
199256
+ }
199257
+ }
199258
+ async function signedInEmail(user, o2 = {}) {
199259
+ const fetchImpl = o2.fetch ?? ((input, init) => globalThis.fetch(input, init));
199260
+ try {
199261
+ const grant = await new RefreshTokenAuth(user, { fetch: o2.fetch, ...o2.tokenUri ? { tokenUri: o2.tokenUri } : o2.baseUrl ? { tokenUri: `${o2.baseUrl}/${HOSTS.oauth}/token` } : {} }).token();
199262
+ const url = o2.baseUrl ? `${o2.baseUrl}/${new URL(USERINFO).host}${new URL(USERINFO).pathname}` : USERINFO;
199263
+ const res = await fetchImpl(url, { headers: { authorization: `Bearer ${grant.token}` } });
199264
+ if (!res.ok)
199265
+ return void 0;
199266
+ const info4 = await res.json();
199267
+ return typeof info4.email === "string" && info4.email ? info4.email : void 0;
199268
+ } catch {
199269
+ return void 0;
199270
+ }
199271
+ }
199272
+ async function connectGoogle(opts) {
199273
+ await requireClientFile(opts.clientFile);
199274
+ const read2 = await readOAuthClientFile(opts.clientFile);
199275
+ const client4 = opts.client ? opts.client(read2) : read2;
199276
+ const scopes = [.../* @__PURE__ */ new Set([...opts.scopes, ...OPENID])];
199277
+ if (opts.signal?.aborted)
199278
+ return { connected: false, code: "aborted", message: "The sign-in was aborted before it started." };
199279
+ let user;
199280
+ try {
199281
+ user = await loginWithOAuthClient({ client: client4, openBrowser: opts.openBrowser, scopes, fetch: opts.fetch, timeoutMs: opts.timeoutMs, signal: opts.signal });
199282
+ } catch (e2) {
199283
+ const message5 = e2.message;
199284
+ if (/access_denied/.test(message5))
199285
+ return { connected: false, code: "consent_denied", message: "Google sign-in was declined, so nothing was connected." };
199286
+ if (opts.signal?.aborted)
199287
+ return { connected: false, code: "aborted", message: "The sign-in was aborted, so nothing was connected." };
199288
+ if (e2 instanceof AuthError)
199289
+ return { connected: false, code: "sign_in_failed", message: message5 };
199290
+ throw e2;
199291
+ }
199292
+ const email = await signedInEmail(user, { fetch: opts.fetch });
199293
+ if (opts.signal?.aborted)
199294
+ return { connected: false, code: "aborted", message: "The sign-in was aborted, so nothing was connected." };
199295
+ await opts.store.save({ ...user, ...email ? { account: email } : {} });
199296
+ const account2 = email ?? "unknown";
199297
+ let developerId;
199298
+ let consoleReady = false;
199299
+ let consoleNote;
199300
+ const pending2 = openConsole(opts.console.launch, { reauth: opts.console.reauth, waitMs: opts.waitMs, notify: opts.notify }, opts.consoleIo);
199301
+ let abort;
199302
+ const aborted = new Promise((resolve130) => {
199303
+ abort = () => resolve130("aborted");
199304
+ if (opts.signal?.aborted)
199305
+ resolve130("aborted");
199306
+ else
199307
+ opts.signal?.addEventListener("abort", abort, { once: true });
199308
+ });
199309
+ try {
199310
+ const opened = await Promise.race([pending2, aborted]);
199311
+ if (opened === "aborted") {
199312
+ void pending2.then((o2) => {
199313
+ o2.attached.close();
199314
+ o2.chrome.close();
199315
+ }, () => void 0);
199316
+ return { connected: false, code: "aborted", message: "Aborted during the Play Console step. The Google sign-in was saved; run the connect again to ready the Console." };
199317
+ }
199318
+ try {
199319
+ developerId = opened.attached.developerId;
199320
+ consoleReady = true;
199321
+ } finally {
199322
+ opened.attached.close();
199323
+ opened.chrome.close();
199324
+ }
199325
+ } catch (e2) {
199326
+ consoleNote = `Signed in to Google, but the Play Console profile isn't ready: ${e2.message}`;
199327
+ } finally {
199328
+ if (abort)
199329
+ opts.signal?.removeEventListener("abort", abort);
199330
+ }
199331
+ return { connected: true, account: account2, ...developerId ? { developerId } : {}, consoleReady, ...consoleNote ? { consoleNote } : {} };
199332
+ }
199333
+ var access, join104, OAUTH_CLIENT_ENV, USERINFO, OPENID;
199334
+ var init_connect = __esm({
199335
+ "../../node_modules/@wix/gplay-api/dist/connect.js"() {
199336
+ init_define_HHP_CATALOG();
199337
+ init_errors3();
199338
+ init_auth2();
199339
+ init_transport();
199340
+ init_console_cdp();
199341
+ ({ access } = __ascBuiltin09);
199342
+ ({ join: join104 } = __ascBuiltin18);
199343
+ OAUTH_CLIENT_ENV = "GPLAY_OAUTH_CLIENT_FILE";
199344
+ USERINFO = "https://openidconnect.googleapis.com/v1/userinfo";
199345
+ OPENID = ["openid", "email"];
199346
+ }
199347
+ });
199348
+
199244
199349
  // ../../node_modules/@wix/gplay-api/dist/console-data-safety.js
199245
199350
  import * as __ascBuiltin010 from "node:fs/promises";
199246
199351
  import * as __ascBuiltin19 from "node:path";
@@ -204164,6 +204269,7 @@ __export(dist_exports, {
204164
204269
  REQUIRED_DAYS: () => REQUIRED_DAYS,
204165
204270
  REQUIRED_TESTERS: () => REQUIRED_TESTERS,
204166
204271
  RefreshTokenAuth: () => RefreshTokenAuth,
204272
+ SIGN_IN_TEST: () => SIGN_IN_TEST,
204167
204273
  SINGLE_IMAGE_TYPES: () => SINGLE_IMAGE_TYPES,
204168
204274
  TARGET_AGE_GROUPS: () => TARGET_AGE_GROUPS,
204169
204275
  TOKEN_URI: () => TOKEN_URI,
@@ -204183,6 +204289,7 @@ __export(dist_exports, {
204183
204289
  applyForProduction: () => applyForProduction,
204184
204290
  applyListing: () => applyListing,
204185
204291
  attachConsole: () => attachConsole,
204292
+ awaitSignIn: () => awaitSignIn,
204186
204293
  buildPlan: () => buildPlan,
204187
204294
  buildStoreImages: () => buildStoreImages,
204188
204295
  bundlePackage: () => bundlePackage,
@@ -204329,6 +204436,7 @@ __export(dist_exports, {
204329
204436
  sha256OfFile: () => sha256OfFile,
204330
204437
  signedInEmail: () => signedInEmail,
204331
204438
  sleeperOf: () => sleeperOf,
204439
+ slotFromUrl: () => slotFromUrl,
204332
204440
  startClock: () => startClock,
204333
204441
  stopAt: () => stopAt,
204334
204442
  submitForReview: () => submitForReview,
@@ -204342,6 +204450,8 @@ __export(dist_exports, {
204342
204450
  waitForReview: () => waitForReview,
204343
204451
  withEdit: () => withEdit,
204344
204452
  withNotes: () => withNotes,
204453
+ withPageSignIn: () => withPageSignIn,
204454
+ withSlot: () => withSlot,
204345
204455
  writeClosedTestRecord: () => writeClosedTestRecord,
204346
204456
  writeListingDir: () => writeListingDir,
204347
204457
  writePlanRecord: () => writePlanRecord,
@@ -204964,7 +205074,9 @@ function readOnlyConsolePage(page) {
204964
205074
  if (!READ_DEVTOOLS.includes(method))
204965
205075
  throw refuse10(`DevTools ${method}`);
204966
205076
  return page.send(method, params);
204967
- }
205077
+ },
205078
+ // Waiting for the owner's own sign-in changes nothing in the Console; present only when the opener allowed it.
205079
+ ...page.signIn ? { signIn: (what) => page.signIn(what) } : {}
204968
205080
  };
204969
205081
  }
204970
205082
  function readOnlyConsole(opener) {
@@ -209203,9 +209315,10 @@ function fileOf(title) {
209203
209315
  const form = step ? STEP_FORM[step] ?? step : title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
209204
209316
  return { path: `google/app-content/${form}.json`, schema: "google.app-content@1" };
209205
209317
  }
209206
- async function appContentPart(deps, consoles) {
209318
+ async function appContentPart(deps, consoles, packageName) {
209207
209319
  const { developerId, appId: appId3 } = await need(deps.appOf, "the app's developer account and Play Console app id");
209208
209320
  const { page } = await consoles.open(developerId, appId3);
209321
+ await consoles.verify(page, developerId, appId3, packageName);
209209
209322
  const status2 = await readDeclarations(page, developerId, appId3, sleepOf(deps));
209210
209323
  const notes = [...status2.notes];
209211
209324
  if (!status2.complete)
@@ -209252,9 +209365,10 @@ async function accountPart(deps, consoles) {
209252
209365
  }
209253
209366
  return { writes: [{ path: "google/account.json", schema: "google.account@1", data: { developerId, ...status2, traderStatus } }], notes };
209254
209367
  }
209255
- async function policyPart(deps, consoles) {
209368
+ async function policyPart(deps, consoles, packageName) {
209256
209369
  const { developerId, appId: appId3 } = await need(deps.appOf, "the app's developer account and Play Console app id");
209257
209370
  const { page } = await consoles.open(developerId, appId3);
209371
+ await consoles.verify(page, developerId, appId3, packageName);
209258
209372
  const policy = await readPolicyStatus(page, developerId, appId3, sleepOf(deps));
209259
209373
  const access3 = await readProductionAccess(page, developerId, appId3, sleepOf(deps));
209260
209374
  return {
@@ -209274,7 +209388,7 @@ async function refreshRecord(record5, app2, packageName, parts, deps) {
209274
209388
  const at2 = new Date(now()).toISOString();
209275
209389
  let result;
209276
209390
  try {
209277
- result = await (part5 === "status" ? statusPart(deps, record5, app2, packageName) : part5 === "tracks" ? tracksPart(deps, record5, app2, packageName) : part5 === "listing" ? listingPart(deps, packageName) : part5 === "app-content" ? appContentPart(deps, consoles) : part5 === "account" ? accountPart(deps, consoles) : policyPart(deps, consoles));
209391
+ result = await (part5 === "status" ? statusPart(deps, record5, app2, packageName) : part5 === "tracks" ? tracksPart(deps, record5, app2, packageName) : part5 === "listing" ? listingPart(deps, packageName) : part5 === "app-content" ? appContentPart(deps, consoles, packageName) : part5 === "account" ? accountPart(deps, consoles) : policyPart(deps, consoles, packageName));
209278
209392
  for (const w2 of result.writes) {
209279
209393
  const hit = findSecret(w2.data);
209280
209394
  if (hit)
@@ -209323,6 +209437,27 @@ var init_record_refresh = __esm({
209323
209437
  const opened = await this.deps.openConsole({ developerId, ...appId3 ? { appId: appId3 } : {} });
209324
209438
  return { page: readOnlyConsolePage(opened.page), ...opened.session ? { session: opened.session } : {}, close: () => opened.close() };
209325
209439
  }
209440
+ checked = /* @__PURE__ */ new Map();
209441
+ /** The app id is the package's app: checkConsoleAppPackage on the read-only page, once per id for the whole refresh. A
209442
+ * mismatch is a usage error naming both packages, so the part fails and writes nothing. */
209443
+ verify(page, developerId, appId3, packageName) {
209444
+ const key4 = `${developerId}/${appId3}`;
209445
+ let done = this.checked.get(key4);
209446
+ if (!done) {
209447
+ done = (async () => {
209448
+ try {
209449
+ await checkConsoleAppPackage(page, developerId, appId3, packageName, sleepOf(this.deps));
209450
+ } catch (e2) {
209451
+ if (e2 instanceof ConsoleAppMismatchError)
209452
+ throw new UsageError(`Play Console app ${appId3} is ${e2.seen.length ? e2.seen.join(", ") : "an app with no package name shown"}, not ${packageName}: nothing was refreshed from it. Pass the app id of ${packageName}: --app-id N (the number after /app/ in its Console URL)`);
209453
+ throw e2;
209454
+ }
209455
+ await this.deps.rememberApp?.({ developerId, appId: appId3 }).catch(() => void 0);
209456
+ })();
209457
+ this.checked.set(key4, done);
209458
+ }
209459
+ return done;
209460
+ }
209326
209461
  async close() {
209327
209462
  const handle = await this.opened?.catch(() => void 0);
209328
209463
  handle?.close();
@@ -254176,7 +254311,8 @@ async function runStoreGoogleTesters(pos, flags, io2, deps = {}) {
254176
254311
  try {
254177
254312
  const google = await googleOf({ google: deps.google, ...deps.now ? { now: deps.now } : {} }, env, io2);
254178
254313
  if (p2.op === "consent") return await consentCommand(p2, io2, ask4, google.host.stateDir, now);
254179
- const consent = p2.op === "pool-check" ? void 0 : await validConsent(google.host.stateDir, p2, now);
254314
+ const recorded = p2.op === "pool-check" ? void 0 : await validConsent(google.host.stateDir, p2, now);
254315
+ const consent = recorded && ask4 && p2.ready && !(recorded.covers ?? []).includes("ready") ? void 0 : recorded;
254180
254316
  if (p2.op !== "pool-check" && !ask4 && !consent) {
254181
254317
  return fail13(io2, "confirmation_required", "this changes your own app's testers on Google Play, so it needs your typed yes at a terminal, or your recorded consent: run it in your own terminal, or once run himi store google testers consent grant there (90 days)");
254182
254318
  }
@@ -400,6 +400,8 @@ himi store google testers consent grant|revoke|status [--dir <app>]
400
400
  state dir. While it holds and matches the package and pool group, `pool-add` and `pool-remove` apply without asking
401
401
  (the job is still planned, checked, approved as you and logged) and print `consent: <when you granted it>`.
402
402
  `consent revoke` deletes it and `consent status` shows it. Expired or not matching: the prompt as before.
403
+ A consent recorded before pool-add set countries, release and review covers only the group: at a terminal,
404
+ `pool-add` asks once for everything; with no terminal it adds the group and skips the rest, saying why.
403
405
 
404
406
  - `pool-add` reads the track's Google Groups, plans a `gplay.closedTest.setup` job with the same groups plus the pool's,
405
407
  shows you the change and applies it only after your typed `yes` (there is no `--yes`). Then it reads the track back.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/himalaya-cli",
3
- "version": "0.1783.0",
3
+ "version": "0.1784.0",
4
4
  "type": "module",
5
5
  "description": "himi — the Himalaya authoring CLI. Build a Tier-5 content package on your own machine, push it to the production serve as a draft, preview it on web + Himi Player, and read worker logs back — the remote dev loop. Wraps @himalaya/serve-cli for transport.",
6
6
  "keywords": [
@@ -62,14 +62,14 @@
62
62
  "@anthropic-ai/mcpb": "2.1.2",
63
63
  "@himalaya/data-resources": "0.0.0",
64
64
  "@types/wawoff2": "^1.0.2",
65
- "@wix/asc": "0.4.16",
66
- "@wix/asc-api": "0.4.16",
67
- "@wix/asc-core": "0.4.16",
68
- "@wix/asc-jobs": "0.4.16",
69
- "@wix/asc-mcp": "0.4.16",
70
- "@wix/asc-web": "0.4.16",
71
- "@wix/gplay-api": "0.4.16",
72
- "@wix/gplay-jobs": "0.4.16",
65
+ "@wix/asc": "0.4.17",
66
+ "@wix/asc-api": "0.4.17",
67
+ "@wix/asc-core": "0.4.17",
68
+ "@wix/asc-jobs": "0.4.17",
69
+ "@wix/asc-mcp": "0.4.17",
70
+ "@wix/asc-web": "0.4.17",
71
+ "@wix/gplay-api": "0.4.17",
72
+ "@wix/gplay-jobs": "0.4.17",
73
73
  "@wix/himalaya": "0.1.0"
74
74
  },
75
75
  "publishConfig": {
@@ -82,5 +82,5 @@
82
82
  "artifactId": "himalaya-cli"
83
83
  }
84
84
  },
85
- "falconPackageHash": "2aff14b7075f78dd5d06c2bb652328245859a38666ddb40f8af6810f"
85
+ "falconPackageHash": "d05563b3a38e6c40e5a8adfbf4f3798f6434af56104a83032dcd214f"
86
86
  }