@wix/himalaya-cli 0.1285.0 → 0.1286.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
@@ -3758,7 +3758,9 @@ __export(wix_owner_exports, {
3758
3758
  ownerTransport: () => ownerTransport,
3759
3759
  redactForError: () => redactForError,
3760
3760
  resolveSiteId: () => resolveSiteId,
3761
+ siteApiKey: () => siteApiKey,
3761
3762
  siteToken: () => siteToken,
3763
+ userSiteToken: () => userSiteToken,
3762
3764
  withRetry: () => withRetry
3763
3765
  });
3764
3766
  import { spawn as spawn2 } from "node:child_process";
@@ -3772,9 +3774,23 @@ function resolveSiteId(flag) {
3772
3774
  return id;
3773
3775
  }
3774
3776
  async function siteToken(msid, spawnImpl = spawn2) {
3777
+ if (!process.env.WIX_TEST_TOKEN?.trim()) {
3778
+ const key2 = siteApiKey();
3779
+ if (key2) return key2;
3780
+ }
3775
3781
  return await mintToken(["token", "--site", msid], `wix token --site ${msid}`, msid, spawnImpl);
3776
3782
  }
3783
+ async function userSiteToken(msid, spawnImpl = spawn2) {
3784
+ return await mintToken(["token", "--site", msid], `wix token --site ${msid}`, `user:${msid}`, spawnImpl);
3785
+ }
3786
+ function siteApiKey(env = process.env) {
3787
+ return env.WIX_API_KEY?.trim() || void 0;
3788
+ }
3777
3789
  async function accountToken(spawnImpl = spawn2) {
3790
+ if (!process.env.WIX_TEST_TOKEN?.trim()) {
3791
+ const key2 = siteApiKey();
3792
+ if (key2) return key2;
3793
+ }
3778
3794
  return await mintToken(["token"], "wix token", ACCOUNT_TOKEN_KEY, spawnImpl);
3779
3795
  }
3780
3796
  async function mintToken(args, label2, cacheKey, spawnImpl) {
@@ -3836,7 +3852,7 @@ function redactForError(buf) {
3836
3852
  ${trimmed.slice(0, 300)}` : "It printed nothing.";
3837
3853
  }
3838
3854
  function mintHelp(label2, detail) {
3839
- return `could not run \`${label2}\` (${detail}). Install the Wix CLI and log in (\`npm i -g @wix/cli && wix login\`), or set WIX_TEST_TOKEN.`;
3855
+ return `could not run \`${label2}\` (${detail}). Install the Wix CLI and log in (\`npm i -g @wix/cli && wix login\`), or, with no browser, export WIX_API_KEY (manage.wix.com/account/api-keys).`;
3840
3856
  }
3841
3857
  function ownerTransport(msid, fetchImpl = fetch, timeoutMs = DEFAULT_TIMEOUT_MS2) {
3842
3858
  return async (method, path2, body) => {
@@ -7512,7 +7528,6 @@ function buttonVariant(style) {
7512
7528
  var SYSTEM_FONT_FAMILY, TONAL_ELEVATION_ALPHA, BUTTON_MIN_HIT_TARGET, nonNegative, nonEmpty, own, COLOR_TOKEN_PROPS, TYPOGRAPHY_TOKEN_PROPS, BUTTON_VARIANTS;
7513
7529
  var init_tokens = __esm({
7514
7530
  "../../core/ts/src/tokens.ts"() {
7515
- "use strict";
7516
7531
  SYSTEM_FONT_FAMILY = "$system";
7517
7532
  TONAL_ELEVATION_ALPHA = [0, 0.05, 0.08, 0.11, 0.12, 0.14];
7518
7533
  BUTTON_MIN_HIT_TARGET = 44;
@@ -152179,9 +152194,9 @@ async function runNotifyPing(flags, io2, deps = {}) {
152179
152194
  if (ownership.state !== "owned") return refuse5(io2, `app_ownership_${ownership.state}`, "Sending requires the app owner.", 1);
152180
152195
  let siteToken2;
152181
152196
  try {
152182
- siteToken2 = await (deps.siteToken ?? siteToken)(input.site);
152197
+ siteToken2 = await (deps.siteToken ?? userSiteToken)(input.site);
152183
152198
  } catch {
152184
- return refuse5(io2, "wix_site_token_required", "Run wix login as the site owner; the site token reads this site's members.", 1);
152199
+ return refuse5(io2, "wix_site_token_required", "Run wix login as the site owner; the site token reads this site's members. A WIX_API_KEY cannot stand in: sending needs a Wix USER, and a key is an app.", 1);
152185
152200
  }
152186
152201
  if (allMembers) return runAllMembers({ input: { app: ownership.slug, site: input.site }, siteToken: siteToken2, session, requestId: requestId2, flags, io: io2, deps });
152187
152202
  const body = {
@@ -162978,6 +162993,9 @@ __export(site_oauth_client_exports, {
162978
162993
  function explainOwnerFailure(err, msid) {
162979
162994
  if (!(err instanceof WixApiError)) return void 0;
162980
162995
  if (err.status === 401 || err.status === 403) {
162996
+ if (siteApiKey() && !process.env.WIX_TEST_TOKEN?.trim()) {
162997
+ return `Wix refused OAuth-client access to site ${msid} (${err.status}) for WIX_API_KEY. The key lacks a permission this call needs (OAuth apps / Headless), or no access to that site. Widen it at https://manage.wix.com/account/api-keys, or create the client in the dashboard: ${DASHBOARD_BASE}/${msid}/oauth-apps-settings`;
162998
+ }
162981
162999
  return `Wix refused OAuth-client access to site ${msid} (${err.status}). This is an OWNER-scoped operation: the account behind \`wix token --site ${msid}\` must own (or be a collaborator with permissions on) that site. Check \`wix whoami\`, or create the client in the dashboard: ${DASHBOARD_BASE}/${msid}/oauth-apps-settings`;
162982
163000
  }
162983
163001
  return void 0;
@@ -165921,9 +165939,10 @@ var USAGE = `himi \u2014 the Himalaya authoring CLI (remote dev loop)
165921
165939
  get + store a scoped control token for push/promote
165922
165940
  --browser: sign in with your own Wix account in a browser
165923
165941
  (NO VPN, no BO) -> use with --target wix
165924
- --wix: HEADLESS \u2014 reads the machine's own Wix CLI
165942
+ --wix: HEADLESS \u2014 presents WIX_API_KEY (a Wix account
165943
+ API key) or, without one, the machine's own Wix CLI
165925
165944
  credential (\`wix login\`). No browser, no VPN, no BO.
165926
- The mode for a CI pod or an agent container.
165945
+ The mode for a server, a CI pod or an agent container.
165927
165946
  --dpx: Wix employee path via an existing BO session
165928
165947
  (internal; --target bo)
165929
165948
  himi apps [list] | claim <slug> [--display-name <n>] [--account-id <id>] [--cookie <c>]
@@ -166272,9 +166291,9 @@ var USAGE = `himi \u2014 the Himalaya authoring CLI (remote dev loop)
166272
166291
  which is what lets a provisioned manifest stand alone
166273
166292
  instead of depending on an exported env var.
166274
166293
  MUTATES your Wix account: without --yes it prints the
166275
- payload and sends nothing. Auth: account-scoped
166276
- 'wix token' (no --site), falling back to
166277
- WIX_API_KEY + WIX_ACCOUNT_ID.
166294
+ payload and sends nothing. Auth: WIX_API_KEY +
166295
+ WIX_ACCOUNT_ID when both are set (no wix CLI needed),
166296
+ else account-scoped 'wix token' (no --site).
166278
166297
  himi site list every site the account identity can reach, with its
166279
166298
  premium flag (read-only)
166280
166299
  himi site client ensure --site <msid> [--name <name>] [--redirect-uri <uri>] [--new]
@@ -166301,8 +166320,8 @@ var USAGE = `himi \u2014 the Himalaya authoring CLI (remote dev loop)
166301
166320
  later complete read, moving the resolved clientId between
166302
166321
  runs. --name cannot narrow it (the name is applied after
166303
166322
  the rows arrive), so the recovery is the dashboard. Auth
166304
- is SITE-scoped ('wix token --site <msid>'): minting is
166305
- owner-of-that-site.
166323
+ is SITE-scoped (WIX_API_KEY, else 'wix token --site
166324
+ <msid>'): minting is owner-of-that-site.
166306
166325
  himi site client list --site <msid> every Headless OAuth client on the site (read-only). Act
166307
166326
  on the 'shippable' column, not 'hasRedirect': shippable
166308
166327
  also requires a MOBILE applicationType, because ensure
@@ -166321,7 +166340,7 @@ var USAGE = `himi \u2014 the Himalaya authoring CLI (remote dev loop)
166321
166340
  names 'himi dist --shell' does; default branded-lite.
166322
166341
  A SITE shell (brandy) also derives the site's page map
166323
166342
  (tabs/drawer from its menu) into the overlay's \`site\`
166324
- block \u2014 edit it, then --apply. Owner token: WIX_TEST_TOKEN
166343
+ block \u2014 edit it, then --apply. Owner token: WIX_API_KEY
166325
166344
  or 'wix token --site'. Look/screenshots need Chromium:
166326
166345
  npx playwright install chromium.
166327
166346
  himi site function list|get|put|publish|invoke [--site <msid>] [--url <https>] [--method GET]
@@ -166329,7 +166348,7 @@ var USAGE = `himi \u2014 the Himalaya authoring CLI (remote dev loop)
166329
166348
  create/update/get/publish/invoke Velo HTTP functions on the
166330
166349
  Wix site (backend/http-functions.js). Draft writes are not
166331
166350
  live until publish. Not \`himi functions\` (serve-plane jobs).
166332
- Owner token: WIX_TEST_TOKEN or 'wix token --site'.
166351
+ Owner token: WIX_API_KEY or 'wix token --site'.
166333
166352
  himi base44 analyze (--url <https://\u2026> | --app-id <id>) [--out <dir>] [--sample <n>] [--json]
166334
166353
  read a Base44 app into an app book (book.json + BOOK.md,
166335
166354
  default .himi/base44-book/). READ-ONLY. --url alone is the
@@ -166387,9 +166406,9 @@ MODES \u2014 pick by who is at the keyboard
166387
166406
  has no BO issuer, which is the \`wix\` target \u2014 and \`wix\` is the default target
166388
166407
  off-repo, so a bare \`himi login\` there is this mode. --no-open prints the URL
166389
166408
  instead of opening it (a headless shell).
166390
- --wix HEADLESS. Uses the machine's EXISTING Wix CLI credential (\`wix login\`, or
166391
- \`wix login --api-key\` in a pod) \u2014 the mode a CI job or an agent container can
166392
- satisfy. It does not create a credential; log the Wix CLI in first.
166409
+ --wix HEADLESS. Presents WIX_API_KEY (a Wix account API key) when set, else the
166410
+ machine's EXISTING Wix CLI credential (\`wix login\`) \u2014 the mode a server, a CI
166411
+ job or an agent container can satisfy. It does not create a credential.
166393
166412
  --dpx Wix EMPLOYEE. Reads the BO session at ~/.dpx/session/token (dpx 2.x:
166394
166413
  \`dpx auth login\` then \`dpx auth token > ~/.dpx/session/token\`). Internal
166395
166414
  targets only (--target bo); VPN-gated.
@@ -167463,9 +167482,9 @@ function loginModeReport(input) {
167463
167482
  const noIssuer = 'the diagnosed target resolves no `ownerIssue`, so this login refuses with `no owner issuer for target "\u2026"` \u2014 use --target wix, pass --owner-issue-url, or set target.ownerIssue in serve-targets.json';
167464
167483
  return {
167465
167484
  wix: {
167466
- available: input.hasOwnerIssuer && (input.wixTestToken || input.wixOnPath),
167485
+ available: input.hasOwnerIssuer && (input.wixTestToken || !!input.wixApiKey || input.wixOnPath),
167467
167486
  interactive: false,
167468
- detail: !input.hasOwnerIssuer ? noIssuer : input.wixTestToken ? "WIX_TEST_TOKEN is set, and is used before the `wix` CLI would be spawned at all" : input.wixOnPath ? "the `wix` CLI is on PATH \u2014 NOT checked: whether it is logged in (`wix login`)" : "`wix` is not on PATH \u2014 `npm i -g @wix/cli && wix login`, set WIX_TEST_TOKEN, or use --dpx"
167487
+ detail: !input.hasOwnerIssuer ? noIssuer : input.wixTestToken ? "WIX_TEST_TOKEN is set, and is used before the `wix` CLI would be spawned at all" : input.wixApiKey ? "WIX_API_KEY is set, and is presented as the account credential \u2014 no `wix` CLI needed" : input.wixOnPath ? "the `wix` CLI is on PATH \u2014 NOT checked: whether it is logged in (`wix login`)" : "`wix` is not on PATH \u2014 export WIX_API_KEY, `npm i -g @wix/cli && wix login`, or use --dpx"
167469
167488
  },
167470
167489
  dpx: {
167471
167490
  // Gated on the EMPLOYEE issuer, and on the session file being there. Presence is all the
@@ -173409,7 +173428,7 @@ ${label2}`);
173409
173428
  } catch (e2) {
173410
173429
  io2.error(JSON.stringify({
173411
173430
  error: `could not mint a Wix account token: ${e2.message}`,
173412
- hint: "`himi login --wix` reads an EXISTING Wix CLI credential (it does not create one). Log the machine in with `wix login` (or `wix login --api-key` for a pod), then retry."
173431
+ hint: "`himi login --wix` presents WIX_API_KEY, or else an EXISTING Wix CLI credential (it does not create one). On a server, export WIX_API_KEY (manage.wix.com/account/api-keys); otherwise log the machine in with `wix login`, then retry."
173413
173432
  }));
173414
173433
  return 1;
173415
173434
  }
@@ -173873,6 +173892,7 @@ ${label2}`);
173873
173892
  const loginModes = loginModeReport({
173874
173893
  wixOnPath: executableOnPath("wix"),
173875
173894
  wixTestToken: (process.env.WIX_TEST_TOKEN ?? "").trim().length > 0,
173895
+ wixApiKey: !!siteApiKey(),
173876
173896
  dpxOnPath: executableOnPath("dpx"),
173877
173897
  dpxSession: auth.dpxSession,
173878
173898
  dpxPath,
@@ -39,6 +39,10 @@ Verified: the plain account token is accepted on both `/funnel/projects/v1/creat
39
39
  `WIX_API_KEY` + `WIX_ACCOUNT_ID` stay supported as a fallback for identities whose token
40
40
  lacks the permission — both halves must be present or the key path is ignored.
41
41
 
42
+ On a server with no `wix login`, set both halves for step 1. Step 2 then reuses
43
+ `WIX_API_KEY` alone with `wix-site-id`, so the whole command runs without a browser. See
44
+ [wix-authentication.md → Headless](wix-authentication.md#headless--himi-on-a-server-or-in-ci-no-browser).
45
+
42
46
  Note the base path oddity on step 2: it is `oauth-app/v1` (**singular**), then the
43
47
  `oauth-apps` collection. `/headless/v1/…`, `/oauth-apps/v1/…` and a bare `/v1/…` all 404,
44
48
  and so does `GET` on the collection — only `POST` create and `POST /query` route.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/himalaya-cli",
3
- "version": "0.1285.0",
3
+ "version": "0.1286.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": [
@@ -70,5 +70,5 @@
70
70
  "artifactId": "himalaya-cli"
71
71
  }
72
72
  },
73
- "falconPackageHash": "a501a3b7c132cc5db9247bdc0cd15570da2891e5eedd6df2ff42004b"
73
+ "falconPackageHash": "9bef92b32e5ba74fc5d57743ad239e87468d3bc9069c8a1f37ac0fe1"
74
74
  }