@wix/himalaya-cli 0.1751.0 → 0.1752.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.
Files changed (25) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/app-config.d.ts +1 -0
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/app-module.d.ts +3 -0
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/define-app.d.ts +16 -1
  4. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/auth-providers/wix/src/index.d.ts +1 -1
  5. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/auth-providers/wix/src/native-engine.d.ts +49 -3
  6. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/auth/src/copy.generated.d.ts +16 -1
  7. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/auth/src/feedback.d.ts +1 -1
  8. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/auth.mjs +27 -2
  9. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/screens.mjs +27 -2
  10. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdui.mjs +1 -0
  11. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-auth/worker.mjs +133 -13
  12. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-auth.mjs +139 -13
  13. package/dist/browser-plane/assets.json +5 -5
  14. package/dist/browser-plane/preview-deferred/{21f35a12bd94f4ab97a9a75453c4adcadc438daf024a4b1950d5c356c123bd01.bin → 2671d1cadb15daa5e59440f4c924e30c221ab3d405e8a56a0ab1cdbe4764af3d.bin} +1 -1
  15. package/dist/browser-plane/sw.js +1 -1
  16. package/dist/cli.mjs +3876 -3340
  17. package/dist/preview-assets.generated.bin +0 -0
  18. package/guides/app-config.md +1 -1
  19. package/guides/himi-json-output.md +25 -3
  20. package/guides/push-cli-onboarding.md +13 -0
  21. package/guides/qa-builds.md +3 -1
  22. package/guides/releasing-with-himi-serve.md +51 -0
  23. package/guides/store-submission.md +46 -1
  24. package/package.json +2 -2
  25. package/templates/fitness-gym/tier5-src/himi-fitcoach-goal/index.ts +3 -4
@@ -35,17 +35,74 @@ function dualDomainAuthorizeUrls(clientIds, redirectUri, opts = {}, endpoint = O
35
35
 
36
36
  // ../../stdlib/auth-providers/wix/src/native-engine.ts
37
37
  var NativeAuthError = class extends Error {
38
- constructor(kind, message, twoFAToken, twoFAMethod, twoFAMethods, verificationId) {
38
+ constructor(kind, message, twoFAToken, twoFAMethod, twoFAMethods, verificationId, twoFAHint) {
39
39
  super(message);
40
40
  this.kind = kind;
41
41
  this.twoFAToken = twoFAToken;
42
42
  this.twoFAMethod = twoFAMethod;
43
43
  this.twoFAMethods = twoFAMethods;
44
44
  this.verificationId = verificationId;
45
+ this.twoFAHint = twoFAHint;
45
46
  this.name = "NativeAuthError";
46
47
  }
47
48
  };
48
49
  var DEV_PASSWORD = "Passw0rd!";
50
+ var VOICE_CALL_METHOD = "VoiceCall";
51
+ var isPhoneMethod = (m) => ["phone", "sms"].includes(m.toLowerCase());
52
+ var isVoiceCallMethod = (m) => m.toLowerCase() === VOICE_CALL_METHOD.toLowerCase();
53
+ var twoFactorWireMethod = (m) => isVoiceCallMethod(m) ? "Phone" : m;
54
+ var nonBlank = (v) => typeof v === "string" && v.trim() ? v.trim() : void 0;
55
+ function twoFactorGateMethods(current, enabled) {
56
+ const out = [];
57
+ for (const m of [...enabled, current]) {
58
+ if (out.includes(m)) continue;
59
+ out.push(m);
60
+ if (isPhoneMethod(m) && !out.some(isVoiceCallMethod)) out.push(VOICE_CALL_METHOD);
61
+ }
62
+ return out;
63
+ }
64
+ function shapeTwoFactorChallenge(payload, requested, previous) {
65
+ const server = nonBlank(payload.currentTwoFAMethod) ?? twoFactorWireMethod(requested);
66
+ const method = isVoiceCallMethod(requested) && isPhoneMethod(server) ? VOICE_CALL_METHOD : server;
67
+ const enabled = Array.isArray(payload.enabledTwoFAMethods) ? payload.enabledTwoFAMethods.filter((m) => typeof m === "string" && m !== "") : void 0;
68
+ const inherited = previous && previous.emailUnlisted && server !== "Email" ? previous.methods.filter((m) => m.toLowerCase() !== "email") : previous?.methods;
69
+ const methods = enabled ? twoFactorGateMethods(server, enabled) : inherited ?? twoFactorGateMethods(server, []);
70
+ const raw = isPhoneMethod(server) ? nonBlank(payload.phoneHint) ?? nonBlank(payload.twoFAHint) : nonBlank(payload.twoFAHint);
71
+ const id = payload.verificationId;
72
+ const verificationId = (typeof id === "string" || typeof id === "number") && /^\d+$/.test(String(id)) ? String(id) : void 0;
73
+ return {
74
+ verificationId,
75
+ token: String(payload.twoFAToken ?? previous?.token ?? ""),
76
+ method,
77
+ methods: methods.includes(method) ? methods : [...methods, method],
78
+ hint: raw && !raw.startsWith("{") ? raw : void 0,
79
+ // With no list in the reply, Email is unlisted unless the previous challenge listed it — a send
80
+ // that fell back to Email (e.g. from SMS) is still a channel the server never offered.
81
+ emailUnlisted: server === "Email" && (enabled ? !enabled.includes("Email") : previous ? previous.emailUnlisted || !previous.methods.some((m) => m.toLowerCase() === "email") : true)
82
+ };
83
+ }
84
+ function twoFactorResendForm(token, method, challenge) {
85
+ const form = { twoFAToken: token };
86
+ const wire = twoFactorWireMethod(method);
87
+ if (!(challenge?.emailUnlisted && wire.toLowerCase() === "email")) form.twoFAMethod = wire;
88
+ if (isVoiceCallMethod(method)) form.phoneDeliveryMethod = "VOICE_CALL";
89
+ else if (isPhoneMethod(method)) form.phoneDeliveryMethod = "SMS";
90
+ return form;
91
+ }
92
+ function legacyTwoFactorFailure(errorCode) {
93
+ switch (Number(errorCode)) {
94
+ case 8002:
95
+ return new NativeAuthError("verificationExpired", "This verification has expired. Go back and sign in again.");
96
+ case 8004:
97
+ return new NativeAuthError("rateLimited", "Too many attempts. Wait a few minutes and try again.");
98
+ case 8034:
99
+ return new NativeAuthError("deliveryFailed", "We couldn't send the code. Try again, or try another way.");
100
+ case 8056:
101
+ return new NativeAuthError("smsRegionUnsupported", "SMS codes aren't available in your region. Try another way.");
102
+ default:
103
+ return void 0;
104
+ }
105
+ }
49
106
  var WixNativeAuthEngine = class {
50
107
  constructor(config = {}) {
51
108
  __publicField(this, "baseURL");
@@ -53,6 +110,7 @@ var WixNativeAuthEngine = class {
53
110
  __publicField(this, "pxToken");
54
111
  __publicField(this, "petriOverrides");
55
112
  __publicField(this, "fetchImpl");
113
+ __publicField(this, "challenges", /* @__PURE__ */ new Map());
56
114
  this.baseURL = config.baseURL ?? "https://users.wix.com";
57
115
  this.devMode = config.devMode ?? false;
58
116
  this.pxToken = config.pxToken;
@@ -102,13 +160,44 @@ var WixNativeAuthEngine = class {
102
160
  return this.postSignIn("/auth/m/verifycodeandlogin", {
103
161
  twoFAToken: token,
104
162
  code,
105
- twoFAMethod: method,
163
+ twoFAMethod: twoFactorWireMethod(method),
106
164
  rememberMe: "true"
107
165
  });
108
166
  }
109
- async resendTwoFactor(token) {
110
- if (this.devMode) return;
111
- await this.rawPost("/auth/m/resend2facode", { twoFAToken: token });
167
+ /** The challenge `token` stands for, as the gate shows it. */
168
+ twoFactorChallenge(token) {
169
+ return this.challenges.get(token);
170
+ }
171
+ /** Re-sends the 2FA code via `method` (default: the challenge's current one) — the same call
172
+ * switches to another method; `VoiceCall` asks for the Phone code by a call. Resolves to the
173
+ * new challenge (every send issues a new token), or undefined when the server named none.
174
+ * Rejects when the server refused to send: a failed resend must not read as "a new code was sent". */
175
+ async resendTwoFactor(token, method) {
176
+ const previous = this.challenges.get(token);
177
+ const requested = method ?? previous?.method ?? "";
178
+ if (this.devMode) {
179
+ const requested2 = method ?? previous?.method ?? "sms";
180
+ const phone = isPhoneMethod(twoFactorWireMethod(requested2));
181
+ const next2 = shapeTwoFactorChallenge({
182
+ twoFAToken: token,
183
+ currentTwoFAMethod: twoFactorWireMethod(requested2),
184
+ ...phone ? { phoneHint: "\u2022\u2022\u2022-\u2022\u2022\u2022-\u2022\u202234" } : requested2.toLowerCase() === "email" ? { twoFAHint: "2f\u2022\u2022\u2022@himalaya.dev" } : {}
185
+ }, requested2, previous);
186
+ this.challenges.set(token, next2);
187
+ return next2;
188
+ }
189
+ const json = await this.rawPost(
190
+ "/auth/m/resend2facode",
191
+ requested ? twoFactorResendForm(token, requested, previous) : { twoFAToken: token }
192
+ );
193
+ if (json.success !== true) {
194
+ throw legacyTwoFactorFailure(json.errorCode) ?? new NativeAuthError("unknown", "Something went wrong. Please try again.");
195
+ }
196
+ const payload = json.payload ?? json;
197
+ if (typeof payload.twoFAToken !== "string" || !payload.twoFAToken) return void 0;
198
+ const next = shapeTwoFactorChallenge(payload, requested, previous);
199
+ this.challenges.set(next.token, next);
200
+ return next;
112
201
  }
113
202
  async sendPasswordReset(email) {
114
203
  if (this.devMode) return;
@@ -127,7 +216,21 @@ var WixNativeAuthEngine = class {
127
216
  * the account session (uaToken) + sets wixSession2/XSRF cookies. 2FA via the
128
217
  * payload.twoFAToken handshake. Register is captcha-gated (errorCode 9981). */
129
218
  async ownerSignIn(email, password) {
130
- if (this.devMode) return devSignIn(email, password);
219
+ if (this.devMode) {
220
+ try {
221
+ return devSignIn(email, password);
222
+ } catch (e) {
223
+ if (!(e instanceof NativeAuthError) || e.kind !== "needsTwoFactor" || !e.twoFAToken) throw e;
224
+ const c = shapeTwoFactorChallenge({
225
+ twoFAToken: e.twoFAToken,
226
+ currentTwoFAMethod: e.twoFAMethod,
227
+ enabledTwoFAMethods: e.twoFAMethods,
228
+ phoneHint: "\u2022\u2022\u2022-\u2022\u2022\u2022-\u2022\u202234"
229
+ }, e.twoFAMethod ?? "sms");
230
+ this.challenges.set(c.token, c);
231
+ throw new NativeAuthError("needsTwoFactor", e.message, c.token, c.method, c.methods, void 0, c.hint);
232
+ }
233
+ }
131
234
  const form = `email=${encodeURIComponent(email)}&password=${encodeURIComponent(password)}&accept=json` + (this.petriOverrides ? `&petri_ovr=${encodeURIComponent(this.petriOverrides)}` : "");
132
235
  const res = await this.fetchImpl("https://users.wix.com/wix-users/auth/m/login", {
133
236
  method: "POST",
@@ -137,21 +240,25 @@ var WixNativeAuthEngine = class {
137
240
  const json = await res.json();
138
241
  const payload = json.payload ?? {};
139
242
  if (payload.twoFAToken && json.success !== true) {
140
- const current = payload.currentTwoFAMethod ?? "sms";
141
- const methods = payload.enabledTwoFAMethods ?? [current];
243
+ const current = nonBlank(payload.currentTwoFAMethod) ?? "sms";
244
+ const c = shapeTwoFactorChallenge(payload, current);
245
+ this.challenges.set(c.token, c);
142
246
  const id = payload.verificationId;
143
247
  const verificationId = (typeof id === "string" || typeof id === "number") && /^\d+$/.test(String(id)) ? String(id) : void 0;
144
248
  throw new NativeAuthError(
145
249
  "needsTwoFactor",
146
250
  "Two-factor verification required.",
147
251
  payload.twoFAToken,
148
- current,
149
- methods,
150
- verificationId
252
+ c.method,
253
+ c.methods,
254
+ verificationId,
255
+ c.hint
151
256
  );
152
257
  }
153
258
  if (json.success !== true || !payload.guid) {
154
259
  if (json.errorCode === 9981) throw new NativeAuthError("recaptchaRequired", "Additional verification is required.");
260
+ const twoFactor = legacyTwoFactorFailure(json.errorCode);
261
+ if (twoFactor) throw twoFactor;
155
262
  throw new NativeAuthError("invalidCredentials", "Wrong email or password.");
156
263
  }
157
264
  return {
@@ -222,15 +329,21 @@ var WixNativeAuthEngine = class {
222
329
  async postSignIn(path, body) {
223
330
  const json = await this.rawPost(path, body);
224
331
  if (typeof json.twoFAToken === "string" && json.twoFAToken) {
332
+ const method = json.twoFAMethod ?? "sms";
333
+ const c = shapeTwoFactorChallenge({ ...json, currentTwoFAMethod: json.currentTwoFAMethod ?? method }, method);
334
+ this.challenges.set(c.token, c);
225
335
  throw new NativeAuthError(
226
336
  "needsTwoFactor",
227
337
  "Two-factor verification required.",
228
338
  json.twoFAToken,
229
- json.twoFAMethod ?? "sms"
339
+ c.method,
340
+ c.methods,
341
+ c.verificationId,
342
+ c.hint
230
343
  );
231
344
  }
232
345
  if (typeof json.errorCode === "number" && json.errorCode !== 0) {
233
- throw mapErrorCode(json.errorCode, json.errorDescription);
346
+ throw legacyTwoFactorFailure(json.errorCode) ?? mapErrorCode(json.errorCode, json.errorDescription);
234
347
  }
235
348
  const payload = json.payload ?? json;
236
349
  const access = payload.accessToken ?? payload.wixAT;
@@ -275,6 +388,13 @@ function mapErrorCode(code, description) {
275
388
  case -15007:
276
389
  case 1:
277
390
  return new NativeAuthError("invalidCredentials", description || "Wrong email or password.");
391
+ // A wrong 2FA code (legacyTwoFactorFailure leaves these to the credential path): the gate
392
+ // words invalidCredentials on a verify as a bad code. Mirrors the Swift/Kotlin engines.
393
+ case 8001:
394
+ case 8005:
395
+ case 8006:
396
+ case 8008:
397
+ return new NativeAuthError("invalidCredentials", description || "That code isn't right.");
278
398
  case 8051:
279
399
  return new NativeAuthError("unknown", description || "This domain is blocked.");
280
400
  default:
@@ -1299,6 +1419,7 @@ export {
1299
1419
  SessionIDService,
1300
1420
  SignedInstanceError,
1301
1421
  SignedInstanceResolver,
1422
+ VOICE_CALL_METHOD,
1302
1423
  WIX_SENSITIVE_KEYS,
1303
1424
  WIX_SESSION3_SOFT_INIT_SPEC,
1304
1425
  WixAuthModalities,
@@ -1329,6 +1450,7 @@ export {
1329
1450
  isSensitiveKey,
1330
1451
  isSignedInstanceExpired,
1331
1452
  isSignedUploadTarget,
1453
+ legacyTwoFactorFailure,
1332
1454
  localDayIndex,
1333
1455
  normalizeKey,
1334
1456
  parseDeviceQr,
@@ -1338,7 +1460,11 @@ export {
1338
1460
  redactCookieString,
1339
1461
  redactJson,
1340
1462
  redactHeaders as redactWixHeaders,
1463
+ shapeTwoFactorChallenge,
1341
1464
  shouldEscalateCaptcha,
1465
+ twoFactorGateMethods,
1466
+ twoFactorResendForm,
1467
+ twoFactorWireMethod,
1342
1468
  policyFor as wixRequestPolicy
1343
1469
  };
1344
1470
  //# sourceMappingURL=wix-auth.mjs.map
@@ -2,7 +2,7 @@
2
2
  "files": [
3
3
  {
4
4
  "name": "sw.js",
5
- "bytes": 2568796
5
+ "bytes": 2570584
6
6
  },
7
7
  {
8
8
  "name": "host.html",
@@ -21,7 +21,7 @@
21
21
  "bytes": 24320
22
22
  },
23
23
  {
24
- "name": "preview-deferred/21f35a12bd94f4ab97a9a75453c4adcadc438daf024a4b1950d5c356c123bd01.bin",
24
+ "name": "preview-deferred/2671d1cadb15daa5e59440f4c924e30c221ab3d405e8a56a0ab1cdbe4764af3d.bin",
25
25
  "bytes": 488215
26
26
  },
27
27
  {
@@ -79,10 +79,10 @@
79
79
  ],
80
80
  "deferred": [
81
81
  {
82
- "key": "assets/pdf-CPQgsn9E.js",
82
+ "key": "assets/pdf-C6dm8ZFK.js",
83
83
  "contentType": "application/javascript; charset=utf-8",
84
- "sha256": "21f35a12bd94f4ab97a9a75453c4adcadc438daf024a4b1950d5c356c123bd01",
85
- "file": "preview-deferred/21f35a12bd94f4ab97a9a75453c4adcadc438daf024a4b1950d5c356c123bd01.bin"
84
+ "sha256": "2671d1cadb15daa5e59440f4c924e30c221ab3d405e8a56a0ab1cdbe4764af3d",
85
+ "file": "preview-deferred/2671d1cadb15daa5e59440f4c924e30c221ab3d405e8a56a0ab1cdbe4764af3d.bin"
86
86
  },
87
87
  {
88
88
  "key": "assets/pdf.worker.min-BGnVRhRG.js",