@wix/himalaya-cli 0.1840.0 → 0.1842.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.
@@ -476,8 +476,8 @@ Apply these interpretation rules:
476
476
  - Keep navigation visibility, reachability and data access separate. Reevaluate
477
477
  membership/plan/badge gates at runtime; an operator's successful read is not an
478
478
  end-user access policy. Never expose protected content beneath a visual gate.
479
- Carry a locked page's rule with `himi one-app access` (see "Locked pages" below):
480
- it is a presentation rule, and the data stays protected by its own Wix API.
479
+ `himi one-app generate` carries a locked page's rule itself (see "Locked pages" below), and `himi one-app access` carries
480
+ it for an app that did not go through `generate`: it is a presentation rule, and the data stays protected by its own Wix API.
481
481
  - Exclude `ntt.*` definitions and placements from coverage. Preserve configured
482
482
  header/top-bar intent; do not add unconfigured drawer or header surfaces.
483
483
  - Before publishing, run the migration-only top-bar coverage check:
@@ -1645,7 +1645,21 @@ plan, and choose whether a viewer who may not enter sees a lock screen with the
1645
1645
  tab at all. Those rules are in the AUTHORED structure (`raw-structure.json`, `layoutItems[].permissions`). The
1646
1646
  structure a Visitor reads is already evaluated for that Visitor: every rule becomes "members only" and the badge and
1647
1647
  plan ids are gone, so never read the rules from an enriched view. `himi one-app coverage` lists each rule as an
1648
- `access` row; the rows stay `unresolved` until you carry the rule:
1648
+ `access` row; the rows stay `unresolved` until a device check records them.
1649
+
1650
+ **In a migration, the pages are locked for you.** `himi one-app generate` knows which Himi screen each source page became (its
1651
+ `routes`), so for a new app it carries every locked page itself: it writes the gate table and puts the screens it generates
1652
+ behind their lock, and `himi one-app provision` finishes the starter screens a page opens and `config.ts`. Its output lists the
1653
+ result under `accessGates` (`carried`, `none`, or `skipped` with the reason, and any `unmapped` page). A locked page the
1654
+ generator omits (a retired Wix Forum page) has no screen and no gate: it stays under `unmapped`, and the `--check` mode described
1655
+ below keeps reporting it as having no screen. That is expected, and there is nothing to fix. If `provision` fails with
1656
+ `page_locks_manual`, the app could not take the gates (a custom nav worker, say): fix what its reason names, or merge the gates
1657
+ by hand, then run `himi one-app access` as below.
1658
+
1659
+ `himi one-app access` is still how an app that did not go through `generate` (an existing app, or `accessGates.status:
1660
+ "skipped"`) carries its locks, and it is still the only command that writes the app-wide login requirement (below): run it once
1661
+ for that, with every locked page's screen (each route's `layoutItemId` and `screenId` from generate's output, as `--screens-file`). It changes nothing for a page
1662
+ `generate` already locked:
1649
1663
 
1650
1664
  ```bash
1651
1665
  himi one-app access --evidence-dir .himi/one-app --content . --new-app \
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/himalaya-cli",
3
- "version": "0.1840.0",
3
+ "version": "0.1842.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": [
@@ -82,5 +82,5 @@
82
82
  "artifactId": "himalaya-cli"
83
83
  }
84
84
  },
85
- "falconPackageHash": "bebd483ba027e636f2cf9c50fbbb218fc7b7ebfe6789d52f57a47a36"
85
+ "falconPackageHash": "e158f89edd8f102bb50001ac406ba3c2b38f20a5f2be36f25c5903e5"
86
86
  }
@@ -565,6 +565,7 @@ const BASE44_ACCOUNT = {
565
565
  "placeholder": "Email",
566
566
  "keyboard": "email",
567
567
  "autoCapitalization": "none",
568
+ "valuePath": "$service:himiBase44Account.email",
568
569
  "onChange": {
569
570
  "actionId": "tier5.himiBase44Account.setEmail"
570
571
  }
@@ -583,6 +584,7 @@ const BASE44_ACCOUNT = {
583
584
  "placeholder": "Password",
584
585
  "secure": true,
585
586
  "autoCapitalization": "none",
587
+ "valuePath": "$service:himiBase44Account.password",
586
588
  "onChange": {
587
589
  "actionId": "tier5.himiBase44Account.setPassword"
588
590
  }
@@ -601,6 +603,7 @@ const BASE44_ACCOUNT = {
601
603
  "placeholder": "Code from your email",
602
604
  "keyboard": "number",
603
605
  "autoCapitalization": "none",
606
+ "valuePath": "$service:himiBase44Account.code",
604
607
  "onChange": {
605
608
  "actionId": "tier5.himiBase44Account.setCode"
606
609
  }
@@ -60,6 +60,57 @@ interface AccountState {
60
60
  hideConfirmDelete: boolean;
61
61
  }
62
62
 
63
+ /** What the user is typing as a secret. The screen's fields show these keys (`valuePath`), so a saved
64
+ * value would come back on the next launch, filled in and ready to submit again: never written to the
65
+ * device (`notPersisted`), never restored from an older build's snapshot (`notHydrated`). */
66
+ const SECRET_KEYS = ["password", "code"] as const;
67
+ type SecretKey = typeof SECRET_KEYS[number];
68
+
69
+ /** A host saves worker state through `__snapshotForPersistence`, which honours `notPersisted`. A
70
+ * binary built before it (Brandy and Himi Player shipped the Base44 capability first) saves the
71
+ * whole state, so there the secrets never enter state: they are held here, the fields stay at ""
72
+ * (a field takes the worker's value only when it changes, so typing is untouched), and those
73
+ * binaries keep the old uncleared fields rather than writing a password to the device. */
74
+ const FILTERS_PERSISTENCE =
75
+ typeof (globalThis as { himalaya?: { __snapshotForPersistence?: unknown } }).himalaya?.__snapshotForPersistence === "function";
76
+ const held: Record<SecretKey, string> = { password: "", code: "" };
77
+ /** Bumped on every edit and every send of a secret, so a clear that waited for a call can tell
78
+ * whether the user typed again in the meantime. */
79
+ const generation: Record<SecretKey, number> = { password: 0, code: 0 };
80
+
81
+ /** The typed secret, wherever this host keeps it. */
82
+ const secret = (s: AccountState, key: SecretKey): string => (FILTERS_PERSISTENCE ? s[key] : held[key]);
83
+
84
+ /** Record a typed secret: in state where the host filters it from the snapshot, else held here. */
85
+ function typed(s: AccountState, key: SecretKey, value: string): AccountState {
86
+ generation[key] += 1;
87
+ if (FILTERS_PERSISTENCE) return { ...s, [key]: value };
88
+ held[key] = value;
89
+ return s;
90
+ }
91
+
92
+ /** Forget a secret once it is sent, and empty its field. Where the secret was held outside state the
93
+ * field's value is already "", so writing "" again would not reach the field and the typed dots would
94
+ * stay: there it steps through a non-secret " " now and back to "" once the call settles
95
+ * (`clearAfter`), so the field sees a change and ends empty. */
96
+ function spent(s: AccountState, key: SecretKey): AccountState {
97
+ held[key] = "";
98
+ generation[key] += 1;
99
+ return { ...s, [key]: FILTERS_PERSISTENCE ? "" : " " };
100
+ }
101
+
102
+ /** Chain after a call that spent `key` (take it right after `spent`): empties the field `spent` left
103
+ * at " ". Run when the call settles, like `_signedIn` / `_failed`, never as the reducer returns: a
104
+ * host may not have stored that reducer's state yet, and a follow-up action then would act on the
105
+ * state before it. Skipped when the user typed again meanwhile: the field shows that new text and
106
+ * `held` has it, and the " " left in state is not secret and reaches no field (it did not change). */
107
+ function clearAfter(key: SecretKey): () => void {
108
+ const sent = generation[key];
109
+ return () => {
110
+ if (!FILTERS_PERSISTENCE && generation[key] === sent) acct._clearField(key);
111
+ };
112
+ }
113
+
63
114
  const describe = (e: unknown): string =>
64
115
  isBase44Error(e) ? (e.message || e.code) : e instanceof Error ? e.message : String(e);
65
116
 
@@ -110,6 +161,7 @@ const acct = defineService<AccountState, {
110
161
  _failed: (s: AccountState, error?: string) => AccountState;
111
162
  _failedRegister: (s: AccountState, message?: string) => AccountState;
112
163
  _methods: (s: AccountState, password?: boolean, providers?: string[]) => AccountState;
164
+ _clearField: (s: AccountState, key?: string) => AccountState;
113
165
  }>("himiBase44Account", {
114
166
  state: derive({
115
167
  signedIn: false,
@@ -138,6 +190,8 @@ const acct = defineService<AccountState, {
138
190
  hideDelete: true,
139
191
  hideConfirmDelete: true,
140
192
  }),
193
+ notPersisted: [...SECRET_KEYS],
194
+ notHydrated: [...SECRET_KEYS],
141
195
  actions: {
142
196
  open: (s, p) => {
143
197
  auth.status()
@@ -152,16 +206,19 @@ const acct = defineService<AccountState, {
152
206
  },
153
207
 
154
208
  setEmail: (s, p) => ({ ...s, email: String(p?.value ?? "") }),
155
- setPassword: (s, p) => ({ ...s, password: String(p?.value ?? "") }),
156
- setCode: (s, p) => ({ ...s, code: String(p?.value ?? "") }),
209
+ setPassword: (s, p) => typed(s, "password", String(p?.value ?? "")),
210
+ setCode: (s, p) => typed(s, "code", String(p?.value ?? "")),
157
211
  usePassword: (s) => derive({ ...s, mode: "signIn", message: "" }),
158
212
 
159
213
  signIn: (s) => {
160
- if (!s.email || !s.password) return { ...s, error: "", message: "Enter your email and password." };
161
- auth.loginViaEmailPassword(s.email, s.password)
214
+ const password = secret(s, "password");
215
+ if (!s.email || !password) return { ...s, error: "", message: "Enter your email and password." };
216
+ const next = spent(s, "password");
217
+ auth.loginViaEmailPassword(s.email, password)
162
218
  .then(({ user }) => acct._signedIn(String(user?.email ?? s.email), "Signed in."))
163
- .catch((e) => acct._failed(describe(e)));
164
- return { ...s, password: "", busy: true, error: "", message: "Signing in…" };
219
+ .catch((e) => acct._failed(describe(e)))
220
+ .then(clearAfter("password"));
221
+ return { ...next, busy: true, error: "", message: "Signing in…" };
165
222
  },
166
223
 
167
224
  signInWith: (s, p) => {
@@ -177,20 +234,26 @@ const acct = defineService<AccountState, {
177
234
  },
178
235
 
179
236
  register: (s) => {
180
- if (!s.email || !s.password) return { ...s, error: "", message: "Enter an email and a password to create an account." };
181
- auth.register(s.email, s.password)
237
+ const password = secret(s, "password");
238
+ if (!s.email || !password) return { ...s, error: "", message: "Enter an email and a password to create an account." };
239
+ const next = spent(s, "password");
240
+ auth.register(s.email, password)
182
241
  .then(() => acct._done("Check your email for a code to finish creating your account."))
183
242
  // Back to the password form: the code form hides the fields a retry needs.
184
- .catch((e) => acct._failedRegister(describe(e)));
185
- return derive({ ...s, password: "", mode: "code", busy: true, error: "", message: "Creating your account…" });
243
+ .catch((e) => acct._failedRegister(describe(e)))
244
+ .then(clearAfter("password"));
245
+ return derive({ ...next, mode: "code", busy: true, error: "", message: "Creating your account…" });
186
246
  },
187
247
 
188
248
  verifyCode: (s) => {
189
- if (!s.email || !s.code) return { ...s, error: "", message: "Enter your email and the code." };
190
- auth.verifyOtp(s.email, s.code)
249
+ const code = secret(s, "code");
250
+ if (!s.email || !code) return { ...s, error: "", message: "Enter your email and the code." };
251
+ const next = spent(s, "code");
252
+ auth.verifyOtp(s.email, code)
191
253
  .then(({ user }) => acct._signedIn(String(user?.email ?? s.email), "Signed in."))
192
- .catch((e) => acct._failed(describe(e)));
193
- return { ...s, code: "", busy: true, error: "", message: "Checking the code…" };
254
+ .catch((e) => acct._failed(describe(e)))
255
+ .then(clearAfter("code"));
256
+ return { ...next, busy: true, error: "", message: "Checking the code…" };
194
257
  },
195
258
 
196
259
  resetPassword: (s) => {
@@ -235,8 +298,16 @@ const acct = defineService<AccountState, {
235
298
  // (Base44 still accepts it for users who set one) rather than an empty card.
236
299
  return derive({ ...s, passwordEnabled: password !== false || list.length === 0, providers: list });
237
300
  },
301
+ _clearField: (s, key) => ((SECRET_KEYS as readonly string[]).includes(String(key)) ? { ...s, [String(key)]: "" } : s),
238
302
  _failedRegister: (s, error) => derive({ ...s, busy: false, mode: "signIn", message: "", error: String(error ?? "") }),
239
303
  },
240
304
  });
241
305
 
306
+ // A runtime that predates `notHydrated` has already laid the snapshot over the state: clear the
307
+ // secrets in place before any action runs (on those runtimes getState() IS the stored state).
308
+ if ((globalThis as { himalaya?: { hydrationOptOut?: unknown } }).himalaya?.hydrationOptOut !== true) {
309
+ const live = (acct as { getState?: () => AccountState | undefined }).getState?.();
310
+ if (live && typeof live === "object") for (const key of SECRET_KEYS) live[key] = "";
311
+ }
312
+
242
313
  export default acct;