@wix/himalaya-cli 0.1255.0 → 0.1256.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.
@@ -55,6 +55,13 @@ export interface WixConsumerAuthConfig {
55
55
  siteUrl: string;
56
56
  /** Custom URL scheme for the member-login redirect. */
57
57
  redirectUri: string;
58
+ /**
59
+ * Where the password-reset email's link lands. Must be an http(s) WEB url:
60
+ * IAM recovery shortens it into the mail body, so `redirectUri` — an app scheme
61
+ * by design — can never serve here (#3891). Omit it to use `siteUrl`; set it only
62
+ * when the reset should land somewhere other than the site root.
63
+ */
64
+ passwordResetUrl?: string;
58
65
  /** Mint a visitor token at boot (no UI). Default: true. */
59
66
  bootAsVisitor?: boolean;
60
67
  /** Preserve visitor token across member signOut so cart/wishlist survive. Default: true. */
@@ -1131,6 +1131,14 @@ function boundCaptchaConfig(config) {
1131
1131
  ...config.captcha?.android ? { android: publicCaptchaKey(config.captcha.android) } : {}
1132
1132
  };
1133
1133
  }
1134
+ function isWebUrl(value) {
1135
+ try {
1136
+ const u = new URL(value);
1137
+ return (u.protocol === "https:" || u.protocol === "http:") && u.hostname.length > 0;
1138
+ } catch {
1139
+ return false;
1140
+ }
1141
+ }
1134
1142
  function WixConsumerAuthProvider(config) {
1135
1143
  if (!config.clientId) {
1136
1144
  throw new Error("WixConsumerAuthProvider: clientId is required.");
@@ -1141,6 +1149,11 @@ function WixConsumerAuthProvider(config) {
1141
1149
  if (!config.redirectUri) {
1142
1150
  throw new Error("WixConsumerAuthProvider: redirectUri is required.");
1143
1151
  }
1152
+ if (config.passwordResetUrl && !isWebUrl(config.passwordResetUrl)) {
1153
+ throw new Error(
1154
+ `WixConsumerAuthProvider: passwordResetUrl must be an http(s) web URL with a host (got "${config.passwordResetUrl}") \u2014 the reset email's link cannot be an app scheme.`
1155
+ );
1156
+ }
1144
1157
  return {
1145
1158
  providerId: "wix-consumer",
1146
1159
  config: {
@@ -1148,6 +1161,7 @@ function WixConsumerAuthProvider(config) {
1148
1161
  siteUrl: config.siteUrl,
1149
1162
  redirectUri: config.redirectUri,
1150
1163
  bootAsVisitor: config.bootAsVisitor ?? true,
1164
+ ...config.passwordResetUrl ? { passwordResetUrl: config.passwordResetUrl } : {},
1151
1165
  preserveVisitorOnSignOut: config.preserveVisitorOnSignOut ?? true,
1152
1166
  ...config.siteId ? { siteId: config.siteId } : {},
1153
1167
  ...config.captcha ? { captcha: boundCaptchaConfig(config) } : {}
@@ -15,11 +15,34 @@ Pick by who signs in (config lives in the app's `config.ts` `auth:` block):
15
15
  |---|---|---|
16
16
  | `wix-native` | native email-first login (owner or consumer) | `mode: "owner"\|"consumer"`, `clientId`, `redirectUri`, `devMode?` |
17
17
  | `wix-owner` | Wix Owner / dashboard apps (two-realm OAuth) | `clientIds: {apps, manage}`, `redirectUri`, `wixApiClientId` |
18
- | `wix-consumer` | customer-facing sites (visitor + member PKCE) | `clientId`, `siteUrl`, `redirectUri`, `bootAsVisitor?` |
18
+ | `wix-consumer` | customer-facing sites (visitor + member PKCE) | `clientId`, `siteUrl`, `redirectUri`, `bootAsVisitor?`, `passwordResetUrl?` |
19
19
  | `wix-api-key` / `wix-app-oauth` | backend/server contexts | secret-bearing — **internal only**, never shipped public |
20
20
 
21
21
  (`@himalaya/wix-auth` is the migrating name of `@himalaya/auth-wix` — RFC 0043 D1; both resolve during migration.)
22
22
 
23
+ ### Password reset needs a WEB url, not `redirectUri`
24
+
25
+ `wix-consumer` password recovery (`himi.wix.resetPassword`) posts to IAM's
26
+ `recovery/v1/send-email`, which **shortens `redirect.url` into the email body** — so that
27
+ url must be `http(s)`. `redirectUri` is the OAuth callback and is a custom app scheme by
28
+ design, so sending it got every reset rejected with
29
+ `400 shortUrl is invalid: url is not a valid Web URL`, and no member ever got a mail.
30
+
31
+ The providers therefore send **`passwordResetUrl ?? siteUrl`**, and reject a non-web
32
+ result on the device before any request goes out. You need `passwordResetUrl` only when
33
+ the reset should land somewhere other than the site root:
34
+
35
+ ```ts
36
+ WixConsumerAuthProvider({
37
+ clientId, siteUrl: "https://example.wix.com/cafe",
38
+ redirectUri: "myapp://oauth/callback", // OAuth callback — app scheme, unchanged
39
+ passwordResetUrl: "https://example.wix.com/cafe/account/reset", // optional
40
+ })
41
+ ```
42
+
43
+ Note the member finishes the reset **on the web**, not in the app: Wix appends its
44
+ recovery token to that url and the site's own page takes the new password.
45
+
23
46
  ## Step 1 — declare the provider (`config.ts`, cross-platform)
24
47
 
25
48
  ```ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/himalaya-cli",
3
- "version": "0.1255.0",
3
+ "version": "0.1256.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": [
@@ -67,5 +67,5 @@
67
67
  "artifactId": "himalaya-cli"
68
68
  }
69
69
  },
70
- "falconPackageHash": "d7beab54860e878a0d330b3368602622b3fdfca3903688c045695634"
70
+ "falconPackageHash": "0a61083a5bb94ca82c70ea46da08d19312ed5cf412c3c19c714238de"
71
71
  }