@wix/himalaya-cli 0.1887.0 → 0.1889.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 (60) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/app-config.d.ts +2 -0
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/app-module.d.ts +4 -0
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/builder.d.ts +10 -0
  4. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/bindings.d.ts +5 -1
  5. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +48 -1
  6. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core.mjs +17 -2
  7. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdui.mjs +12 -2
  8. package/dist/browser-plane/assets.json +5 -5
  9. package/dist/browser-plane/preview-deferred/{d4250730f37a006c948187a7640453097348fa24695586a3d0014c041511c896.bin → 0c2266c1d7d6e00c558adf2e3706e5ae360fdb6b5ca7663ed596d683a0f39f34.bin} +1 -1
  10. package/dist/browser-plane/sw.js +7 -7
  11. package/dist/cli.mjs +60571 -59752
  12. package/dist/preview-assets.generated.bin +0 -0
  13. package/guides/component-index.md +5 -1
  14. package/guides/component-reference.json +11 -4
  15. package/guides/component-reference.md +20 -5
  16. package/guides/designing-himi-screens.md +48 -0
  17. package/guides/himi-json-output.md +23 -0
  18. package/guides/index.json +1 -1
  19. package/guides/sdk-reference.json +12 -5
  20. package/package.json +2 -2
  21. package/templates/bare-fashion/tier5-src/_shared/member-account-routes.ts +26 -3
  22. package/templates/bare-fashion/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
  23. package/templates/beauty-salon/tier5-src/_shared/member-account-routes.ts +26 -3
  24. package/templates/beauty-salon/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
  25. package/templates/branded-lite/tier5-src/_shared/member-account-routes.ts +26 -3
  26. package/templates/branded-lite/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
  27. package/templates/brandy/tier5-src/_shared/member-account-routes.ts +26 -3
  28. package/templates/brandy/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
  29. package/templates/community-club/tier5-src/_shared/member-account-routes.ts +26 -3
  30. package/templates/community-club/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
  31. package/templates/conference/tier5-src/_shared/member-account-routes.ts +26 -3
  32. package/templates/conference/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
  33. package/templates/events-meetups/tier5-src/_shared/member-account-routes.ts +26 -3
  34. package/templates/events-meetups/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
  35. package/templates/fitness-gym/tier5-src/_shared/member-account-routes.ts +26 -3
  36. package/templates/fitness-gym/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
  37. package/templates/gym-fitness/tier5-src/_shared/member-account-routes.ts +26 -3
  38. package/templates/gym-fitness/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
  39. package/templates/medical-services/tier5-src/_shared/member-account-routes.ts +26 -3
  40. package/templates/medical-services/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
  41. package/templates/nonprofit-cause/tier5-src/_shared/member-account-routes.ts +26 -3
  42. package/templates/nonprofit-cause/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
  43. package/templates/personal-fitness-trainer/tier5-src/_shared/member-account-routes.ts +26 -3
  44. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
  45. package/templates/podcast-creator/tier5-src/_shared/member-account-routes.ts +26 -3
  46. package/templates/podcast-creator/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
  47. package/templates/portfolio-creative/tier5-src/_shared/member-account-routes.ts +26 -3
  48. package/templates/portfolio-creative/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
  49. package/templates/professional-services/tier5-src/_shared/member-account-routes.ts +26 -3
  50. package/templates/professional-services/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
  51. package/templates/restaurant/tier5-src/_shared/member-account-routes.ts +26 -3
  52. package/templates/restaurant/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
  53. package/templates/retail-store/tier5-src/_shared/member-account-routes.ts +26 -3
  54. package/templates/retail-store/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
  55. package/templates/salon-spa/tier5-src/_shared/member-account-routes.ts +26 -3
  56. package/templates/salon-spa/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
  57. package/templates/wholesale-store/tier5-src/_shared/member-account-routes.ts +26 -3
  58. package/templates/wholesale-store/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
  59. package/templates/yoga-studio/tier5-src/_shared/member-account-routes.ts +26 -3
  60. package/templates/yoga-studio/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
@@ -13,7 +13,7 @@ import { snackbar } from "@himalaya/ui";
13
13
  import { deleteMemberPhones, getMyMember, listCustomFields, updateMember } from "@himalaya/wix-members";
14
14
  import { generateMemberPhotoUploadUrl } from "@himalaya/wix-site-media";
15
15
  import { memberAccess } from "../_shared/member-access.js";
16
- import { memberAccountRoutes } from "../_shared/member-account-routes.js";
16
+ import { MEMBER_PHOTO_UPLOAD_TARGET, isMemberPhotoUploadTarget, memberAccountRoutes } from "../_shared/member-account-routes.js";
17
17
  import { copyParam, stashCopy } from "../_shared/himi-copy.js";
18
18
  import {
19
19
  clean, currentMemberRecordMatches, fetchMember, isSignedOut, loadErrorVariant, memberInitials, rawText,
@@ -84,6 +84,8 @@ interface S extends ProfileValues {
84
84
  photoUploadAvailable: boolean;
85
85
  noPhotoUploadAvailable: boolean;
86
86
  photoUploadFunctionName: string;
87
+ /** The photo goes to the app's member-photo route as the member (no site function): the host answers the placeholder target. */
88
+ photoUploadViaRoute: boolean;
87
89
  photoDisplayUrl: string;
88
90
  uploadUrl: string;
89
91
  photoDraftUrl: string;
@@ -132,6 +134,7 @@ const EMPTY: S = {
132
134
  photoUploadAvailable: false,
133
135
  noPhotoUploadAvailable: true,
134
136
  photoUploadFunctionName: "",
137
+ photoUploadViaRoute: false,
135
138
  photoDisplayUrl: "",
136
139
  uploadUrl: "",
137
140
  photoDraftUrl: "",
@@ -373,9 +376,12 @@ function photoUploadFunctionName(value: unknown): string {
373
376
  const name = clean(value);
374
377
  return /^[A-Za-z][A-Za-z0-9_]{0,63}$/.test(name) ? name : "";
375
378
  }
376
- function validUploadUrl(value: unknown): string {
379
+ function validUploadUrl(value: unknown, viaRoute: boolean): string {
377
380
  if (typeof value !== "string") return "";
378
381
  // Hand-parsed: JSC (iOS) has no `URL` global. Host is plain letters/digits/dots, so userinfo and ports never match.
382
+ // The member-photo placeholder is the host's to answer with the member's credential; it names no host at all. Only the worker's own
383
+ // route path may publish it: a site function that returns it must not steer the host off the function's Wix Media upload.
384
+ if (isMemberPhotoUploadTarget(value)) return viaRoute && /^[A-Za-z0-9?=&.-]{0,64}$/.test(value.slice(MEMBER_PHOTO_UPLOAD_TARGET.length)) ? value : "";
379
385
  const m = /^https:\/\/([A-Za-z0-9.-]+)(?:[/?][^#\s\\]*)?$/.exec(value);
380
386
  const host = m ? m[1].toLowerCase() : "";
381
387
  return host === "wixmp.com" || host.endsWith(".wixmp.com") ? value : "";
@@ -401,6 +407,8 @@ function canonicalPhotoMediaId(value: unknown): string {
401
407
  let profileMutationInFlight = false;
402
408
  let photoUploadMintInFlight = false;
403
409
  let photoUploadVersion = 0;
410
+ /** Makes each pick's placeholder differ from the last (a retry must not look like the value left from a failed pick). */
411
+ let photoRouteNonce = 0;
404
412
  let loadVersion = 0;
405
413
  // The native picker uploads the file itself and never reports a failed PUT back to the worker, so a minted
406
414
  // upload URL counts as "upload in progress" only for a bounded window. Save waits inside it, then recovers.
@@ -570,8 +578,11 @@ const svc = defineService<S, {
570
578
  if (!(await currentMemberRecordMatches(email, scope, clean(member.id)))) throw signedOutError();
571
579
  if (version !== loadVersion) return svc.getState() as S;
572
580
  const functionName = photoUploadFunctionName((arg as { photoUploadFunctionName?: unknown } | undefined)?.photoUploadFunctionName);
573
- const available = !!functionName && routes.mediaField;
574
- return derive({ ...loaded(member, email, scope, site.fields, site.hasPhone), photoUploadFunctionName: functionName, photoUploadAvailable: available });
581
+ // The site's own upload function wins (it works on every binary that has MediaField). Without one, a host that sends the photo
582
+ // to the app's member-photo route as the member does the upload, with no site code: migrated apps have none.
583
+ const viaRoute = !functionName && routes.memberPhotoRoute;
584
+ const available = (!!functionName && routes.mediaField) || viaRoute;
585
+ return derive({ ...loaded(member, email, scope, site.fields, site.hasPhone), photoUploadFunctionName: functionName, photoUploadViaRoute: viaRoute, photoUploadAvailable: available });
575
586
  } catch (error) {
576
587
  if (version !== loadVersion) return svc.getState() as S;
577
588
  return loadFailed(error);
@@ -607,7 +618,7 @@ const svc = defineService<S, {
607
618
  return derive({ ...s, custom: { ...s.custom, [id]: value }, customErrors: { ...s.customErrors, [id]: "" }, saveError: "" });
608
619
  },
609
620
  genUpload: async (s, arg): Promise<Polled> => {
610
- if (photoUploadMintInFlight || s.phase !== "ready" || !s.memberId || !s.photoUploadAvailable || !s.photoUploadFunctionName) {
621
+ if (photoUploadMintInFlight || s.phase !== "ready" || !s.memberId || !s.photoUploadAvailable || (!s.photoUploadFunctionName && !s.photoUploadViaRoute)) {
611
622
  return derive({ ...s, uploadUrl: "", photoUploadError: copyParam("accountSettings.profilePhotoUnavailable", "Profile photo changes are not available in this session."), photoUploading: false });
612
623
  }
613
624
  photoUploadMintInFlight = true;
@@ -628,7 +639,10 @@ const svc = defineService<S, {
628
639
  if (version !== photoUploadVersion) return latest;
629
640
  return derive(clearPhotoUploadAttempt(latest, copyParam("accountSettings.profilePhotoUploadError", "The photo could not be prepared. Choose another image.")));
630
641
  }
631
- const minted = await generateMemberPhotoUploadUrl(s.photoUploadFunctionName, mimeType, fileName);
642
+ // Through the member-photo route there is nothing to mint: the placeholder says "send it as the member", and the host does.
643
+ const minted = s.photoUploadViaRoute
644
+ ? { uploadUrl: `${MEMBER_PHOTO_UPLOAD_TARGET}?n=${++photoRouteNonce}` }
645
+ : await generateMemberPhotoUploadUrl(s.photoUploadFunctionName, mimeType, fileName);
632
646
  if (version !== photoUploadVersion) return svc.getState() as S;
633
647
  if (!(await currentMemberRecordMatches(s.memberEmail, s.memberScope, s.memberId))) {
634
648
  const latest = svc.getState() as S;
@@ -636,7 +650,7 @@ const svc = defineService<S, {
636
650
  return derive(clearPhotoUploadAttempt(latest, accountChanged()));
637
651
  }
638
652
  if (version !== photoUploadVersion) return svc.getState() as S;
639
- const uploadUrl = validUploadUrl(minted.uploadUrl);
653
+ const uploadUrl = validUploadUrl(minted.uploadUrl, s.photoUploadViaRoute);
640
654
  if (!uploadUrl) return derive(clearPhotoUploadAttempt(svc.getState() as S, copyParam("accountSettings.profilePhotoUploadError", "The photo could not be prepared. Choose another image.")));
641
655
  const latest = svc.getState() as S;
642
656
  if (!sameMember(latest)) return latest;
@@ -17,6 +17,20 @@ import { isHostedWorker } from "./hosted-checkout.js";
17
17
  export const MEMBER_ACCOUNT_ROUTES_MIN_BINARY = "1.4.0";
18
18
  export const MEMBER_MEDIA_FIELD_MIN_BINARY = "1.5.0";
19
19
  export const MEMBER_PASSWORD_ACTIONS_MIN_BINARY = "1.5.0";
20
+ /** The HimalayaCore version whose MediaField answers the member-photo upload target (`MEMBER_PHOTO_UPLOAD_TARGET`). */
21
+ export const MEMBER_PHOTO_ROUTE_MIN_BINARY = "1.11.0";
22
+
23
+ // The upload target a MediaField worker publishes to say "send the picked photo to the app's member-photo route as me".
24
+ // It is a placeholder, not a URL: the HOST answers it with the member credential it already holds (web host, Android, iOS), and the
25
+ // shared presigned-upload policy (`*.wixmp.com`, credential-free) is untouched. A `?n=<nonce>` suffix keeps a retry's value different
26
+ // from the last one (every renderer requires the target to be minted for THIS pick). Held identical to the hosts' constants by
27
+ // the member-photo target parity test.
28
+ export const MEMBER_PHOTO_UPLOAD_TARGET = "himalaya-member-photo://upload";
29
+
30
+ /** Whether [value] is the placeholder: the bare target, or with a `?` suffix. */
31
+ export function isMemberPhotoUploadTarget(value: unknown): value is string {
32
+ return typeof value === "string" && (value === MEMBER_PHOTO_UPLOAD_TARGET || value.startsWith(`${MEMBER_PHOTO_UPLOAD_TARGET}?`));
33
+ }
20
34
 
21
35
  /** `version` (a HimalayaCore binary version, pre-release suffix ignored) is `floor` or later. */
22
36
  export function atLeast(version: string, floor: string): boolean {
@@ -38,6 +52,9 @@ export interface MemberAccountRoutes {
38
52
  mediaField: boolean;
39
53
  /** Password credential actions introduced in HimalayaCore 1.5.0. */
40
54
  passwordCredentials: boolean;
55
+ /** The host sends a picked profile photo to the app's member-photo route as the member (HimalayaCore 1.11.0 and later on native; the web
56
+ * host when that route is mounted; native also needs a server address). No site function is needed. A host without it keeps the "change your photo on the website" line. */
57
+ memberPhotoRoute: boolean;
41
58
  /** The web host: a preview of the app, never a member's real device. Account settings say
42
59
  * "in preview mode" there, and "here" in every other case it cannot change a password. */
43
60
  webPreview: boolean;
@@ -46,11 +63,17 @@ export interface MemberAccountRoutes {
46
63
  export async function memberAccountRoutes(): Promise<MemberAccountRoutes> {
47
64
  const info = await getAppInfo().catch(() => undefined);
48
65
  // A hosted app reaches none of these routes, but a hosted web build is still a preview.
49
- if (isHostedWorker()) return { addresses: false, wallet: false, mediaField: false, passwordCredentials: false, webPreview: info?.platform === "web" };
50
- if (!info) return { addresses: false, wallet: false, mediaField: false, passwordCredentials: false, webPreview: false };
66
+ if (isHostedWorker()) return { addresses: false, wallet: false, mediaField: false, passwordCredentials: false, memberPhotoRoute: false, webPreview: info?.platform === "web" };
67
+ if (!info) return { addresses: false, wallet: false, mediaField: false, passwordCredentials: false, memberPhotoRoute: false, webPreview: false };
51
68
  const native = info.platform === "ios" || info.platform === "android" || info.platform === "macos";
52
69
  const addresses = native && atLeast(info.binaryVersion ?? "", MEMBER_ACCOUNT_ROUTES_MIN_BINARY);
53
70
  const mediaField = native && atLeast(info.binaryVersion ?? "", MEMBER_MEDIA_FIELD_MIN_BINARY);
54
71
  const passwordCredentials = native && atLeast(info.binaryVersion ?? "", MEMBER_PASSWORD_ACTIONS_MIN_BINARY);
55
- return { addresses, wallet: addresses && info.memberSiteBound === true, mediaField, passwordCredentials, webPreview: info.platform === "web" };
72
+ // A host can answer the placeholder only where there is a member-photo route to send the photo to. Web says so itself (`memberPhotoUpload`: the
73
+ // route is mounted; the server address alone is not enough, a standalone build reports its baked address without the same-origin route).
74
+ // Native needs HimalayaCore 1.11.0 and a server address (an empty one means the local preview, where the picker would only fail).
75
+ const memberPhotoRoute = info.platform === "web"
76
+ ? info.memberPhotoUpload === true
77
+ : native && atLeast(info.binaryVersion ?? "", MEMBER_PHOTO_ROUTE_MIN_BINARY) && !!info.serveBaseUrl;
78
+ return { addresses, wallet: addresses && info.memberSiteBound === true, mediaField, passwordCredentials, memberPhotoRoute, webPreview: info.platform === "web" };
56
79
  }
@@ -13,7 +13,7 @@ import { snackbar } from "@himalaya/ui";
13
13
  import { deleteMemberPhones, getMyMember, listCustomFields, updateMember } from "@himalaya/wix-members";
14
14
  import { generateMemberPhotoUploadUrl } from "@himalaya/wix-site-media";
15
15
  import { memberAccess } from "../_shared/member-access.js";
16
- import { memberAccountRoutes } from "../_shared/member-account-routes.js";
16
+ import { MEMBER_PHOTO_UPLOAD_TARGET, isMemberPhotoUploadTarget, memberAccountRoutes } from "../_shared/member-account-routes.js";
17
17
  import { copyParam, stashCopy } from "../_shared/himi-copy.js";
18
18
  import {
19
19
  clean, currentMemberRecordMatches, fetchMember, isSignedOut, loadErrorVariant, memberInitials, rawText,
@@ -84,6 +84,8 @@ interface S extends ProfileValues {
84
84
  photoUploadAvailable: boolean;
85
85
  noPhotoUploadAvailable: boolean;
86
86
  photoUploadFunctionName: string;
87
+ /** The photo goes to the app's member-photo route as the member (no site function): the host answers the placeholder target. */
88
+ photoUploadViaRoute: boolean;
87
89
  photoDisplayUrl: string;
88
90
  uploadUrl: string;
89
91
  photoDraftUrl: string;
@@ -132,6 +134,7 @@ const EMPTY: S = {
132
134
  photoUploadAvailable: false,
133
135
  noPhotoUploadAvailable: true,
134
136
  photoUploadFunctionName: "",
137
+ photoUploadViaRoute: false,
135
138
  photoDisplayUrl: "",
136
139
  uploadUrl: "",
137
140
  photoDraftUrl: "",
@@ -373,9 +376,12 @@ function photoUploadFunctionName(value: unknown): string {
373
376
  const name = clean(value);
374
377
  return /^[A-Za-z][A-Za-z0-9_]{0,63}$/.test(name) ? name : "";
375
378
  }
376
- function validUploadUrl(value: unknown): string {
379
+ function validUploadUrl(value: unknown, viaRoute: boolean): string {
377
380
  if (typeof value !== "string") return "";
378
381
  // Hand-parsed: JSC (iOS) has no `URL` global. Host is plain letters/digits/dots, so userinfo and ports never match.
382
+ // The member-photo placeholder is the host's to answer with the member's credential; it names no host at all. Only the worker's own
383
+ // route path may publish it: a site function that returns it must not steer the host off the function's Wix Media upload.
384
+ if (isMemberPhotoUploadTarget(value)) return viaRoute && /^[A-Za-z0-9?=&.-]{0,64}$/.test(value.slice(MEMBER_PHOTO_UPLOAD_TARGET.length)) ? value : "";
379
385
  const m = /^https:\/\/([A-Za-z0-9.-]+)(?:[/?][^#\s\\]*)?$/.exec(value);
380
386
  const host = m ? m[1].toLowerCase() : "";
381
387
  return host === "wixmp.com" || host.endsWith(".wixmp.com") ? value : "";
@@ -401,6 +407,8 @@ function canonicalPhotoMediaId(value: unknown): string {
401
407
  let profileMutationInFlight = false;
402
408
  let photoUploadMintInFlight = false;
403
409
  let photoUploadVersion = 0;
410
+ /** Makes each pick's placeholder differ from the last (a retry must not look like the value left from a failed pick). */
411
+ let photoRouteNonce = 0;
404
412
  let loadVersion = 0;
405
413
  // The native picker uploads the file itself and never reports a failed PUT back to the worker, so a minted
406
414
  // upload URL counts as "upload in progress" only for a bounded window. Save waits inside it, then recovers.
@@ -570,8 +578,11 @@ const svc = defineService<S, {
570
578
  if (!(await currentMemberRecordMatches(email, scope, clean(member.id)))) throw signedOutError();
571
579
  if (version !== loadVersion) return svc.getState() as S;
572
580
  const functionName = photoUploadFunctionName((arg as { photoUploadFunctionName?: unknown } | undefined)?.photoUploadFunctionName);
573
- const available = !!functionName && routes.mediaField;
574
- return derive({ ...loaded(member, email, scope, site.fields, site.hasPhone), photoUploadFunctionName: functionName, photoUploadAvailable: available });
581
+ // The site's own upload function wins (it works on every binary that has MediaField). Without one, a host that sends the photo
582
+ // to the app's member-photo route as the member does the upload, with no site code: migrated apps have none.
583
+ const viaRoute = !functionName && routes.memberPhotoRoute;
584
+ const available = (!!functionName && routes.mediaField) || viaRoute;
585
+ return derive({ ...loaded(member, email, scope, site.fields, site.hasPhone), photoUploadFunctionName: functionName, photoUploadViaRoute: viaRoute, photoUploadAvailable: available });
575
586
  } catch (error) {
576
587
  if (version !== loadVersion) return svc.getState() as S;
577
588
  return loadFailed(error);
@@ -607,7 +618,7 @@ const svc = defineService<S, {
607
618
  return derive({ ...s, custom: { ...s.custom, [id]: value }, customErrors: { ...s.customErrors, [id]: "" }, saveError: "" });
608
619
  },
609
620
  genUpload: async (s, arg): Promise<Polled> => {
610
- if (photoUploadMintInFlight || s.phase !== "ready" || !s.memberId || !s.photoUploadAvailable || !s.photoUploadFunctionName) {
621
+ if (photoUploadMintInFlight || s.phase !== "ready" || !s.memberId || !s.photoUploadAvailable || (!s.photoUploadFunctionName && !s.photoUploadViaRoute)) {
611
622
  return derive({ ...s, uploadUrl: "", photoUploadError: copyParam("accountSettings.profilePhotoUnavailable", "Profile photo changes are not available in this session."), photoUploading: false });
612
623
  }
613
624
  photoUploadMintInFlight = true;
@@ -628,7 +639,10 @@ const svc = defineService<S, {
628
639
  if (version !== photoUploadVersion) return latest;
629
640
  return derive(clearPhotoUploadAttempt(latest, copyParam("accountSettings.profilePhotoUploadError", "The photo could not be prepared. Choose another image.")));
630
641
  }
631
- const minted = await generateMemberPhotoUploadUrl(s.photoUploadFunctionName, mimeType, fileName);
642
+ // Through the member-photo route there is nothing to mint: the placeholder says "send it as the member", and the host does.
643
+ const minted = s.photoUploadViaRoute
644
+ ? { uploadUrl: `${MEMBER_PHOTO_UPLOAD_TARGET}?n=${++photoRouteNonce}` }
645
+ : await generateMemberPhotoUploadUrl(s.photoUploadFunctionName, mimeType, fileName);
632
646
  if (version !== photoUploadVersion) return svc.getState() as S;
633
647
  if (!(await currentMemberRecordMatches(s.memberEmail, s.memberScope, s.memberId))) {
634
648
  const latest = svc.getState() as S;
@@ -636,7 +650,7 @@ const svc = defineService<S, {
636
650
  return derive(clearPhotoUploadAttempt(latest, accountChanged()));
637
651
  }
638
652
  if (version !== photoUploadVersion) return svc.getState() as S;
639
- const uploadUrl = validUploadUrl(minted.uploadUrl);
653
+ const uploadUrl = validUploadUrl(minted.uploadUrl, s.photoUploadViaRoute);
640
654
  if (!uploadUrl) return derive(clearPhotoUploadAttempt(svc.getState() as S, copyParam("accountSettings.profilePhotoUploadError", "The photo could not be prepared. Choose another image.")));
641
655
  const latest = svc.getState() as S;
642
656
  if (!sameMember(latest)) return latest;
@@ -17,6 +17,20 @@ import { isHostedWorker } from "./hosted-checkout.js";
17
17
  export const MEMBER_ACCOUNT_ROUTES_MIN_BINARY = "1.4.0";
18
18
  export const MEMBER_MEDIA_FIELD_MIN_BINARY = "1.5.0";
19
19
  export const MEMBER_PASSWORD_ACTIONS_MIN_BINARY = "1.5.0";
20
+ /** The HimalayaCore version whose MediaField answers the member-photo upload target (`MEMBER_PHOTO_UPLOAD_TARGET`). */
21
+ export const MEMBER_PHOTO_ROUTE_MIN_BINARY = "1.11.0";
22
+
23
+ // The upload target a MediaField worker publishes to say "send the picked photo to the app's member-photo route as me".
24
+ // It is a placeholder, not a URL: the HOST answers it with the member credential it already holds (web host, Android, iOS), and the
25
+ // shared presigned-upload policy (`*.wixmp.com`, credential-free) is untouched. A `?n=<nonce>` suffix keeps a retry's value different
26
+ // from the last one (every renderer requires the target to be minted for THIS pick). Held identical to the hosts' constants by
27
+ // the member-photo target parity test.
28
+ export const MEMBER_PHOTO_UPLOAD_TARGET = "himalaya-member-photo://upload";
29
+
30
+ /** Whether [value] is the placeholder: the bare target, or with a `?` suffix. */
31
+ export function isMemberPhotoUploadTarget(value: unknown): value is string {
32
+ return typeof value === "string" && (value === MEMBER_PHOTO_UPLOAD_TARGET || value.startsWith(`${MEMBER_PHOTO_UPLOAD_TARGET}?`));
33
+ }
20
34
 
21
35
  /** `version` (a HimalayaCore binary version, pre-release suffix ignored) is `floor` or later. */
22
36
  export function atLeast(version: string, floor: string): boolean {
@@ -38,6 +52,9 @@ export interface MemberAccountRoutes {
38
52
  mediaField: boolean;
39
53
  /** Password credential actions introduced in HimalayaCore 1.5.0. */
40
54
  passwordCredentials: boolean;
55
+ /** The host sends a picked profile photo to the app's member-photo route as the member (HimalayaCore 1.11.0 and later on native; the web
56
+ * host when that route is mounted; native also needs a server address). No site function is needed. A host without it keeps the "change your photo on the website" line. */
57
+ memberPhotoRoute: boolean;
41
58
  /** The web host: a preview of the app, never a member's real device. Account settings say
42
59
  * "in preview mode" there, and "here" in every other case it cannot change a password. */
43
60
  webPreview: boolean;
@@ -46,11 +63,17 @@ export interface MemberAccountRoutes {
46
63
  export async function memberAccountRoutes(): Promise<MemberAccountRoutes> {
47
64
  const info = await getAppInfo().catch(() => undefined);
48
65
  // A hosted app reaches none of these routes, but a hosted web build is still a preview.
49
- if (isHostedWorker()) return { addresses: false, wallet: false, mediaField: false, passwordCredentials: false, webPreview: info?.platform === "web" };
50
- if (!info) return { addresses: false, wallet: false, mediaField: false, passwordCredentials: false, webPreview: false };
66
+ if (isHostedWorker()) return { addresses: false, wallet: false, mediaField: false, passwordCredentials: false, memberPhotoRoute: false, webPreview: info?.platform === "web" };
67
+ if (!info) return { addresses: false, wallet: false, mediaField: false, passwordCredentials: false, memberPhotoRoute: false, webPreview: false };
51
68
  const native = info.platform === "ios" || info.platform === "android" || info.platform === "macos";
52
69
  const addresses = native && atLeast(info.binaryVersion ?? "", MEMBER_ACCOUNT_ROUTES_MIN_BINARY);
53
70
  const mediaField = native && atLeast(info.binaryVersion ?? "", MEMBER_MEDIA_FIELD_MIN_BINARY);
54
71
  const passwordCredentials = native && atLeast(info.binaryVersion ?? "", MEMBER_PASSWORD_ACTIONS_MIN_BINARY);
55
- return { addresses, wallet: addresses && info.memberSiteBound === true, mediaField, passwordCredentials, webPreview: info.platform === "web" };
72
+ // A host can answer the placeholder only where there is a member-photo route to send the photo to. Web says so itself (`memberPhotoUpload`: the
73
+ // route is mounted; the server address alone is not enough, a standalone build reports its baked address without the same-origin route).
74
+ // Native needs HimalayaCore 1.11.0 and a server address (an empty one means the local preview, where the picker would only fail).
75
+ const memberPhotoRoute = info.platform === "web"
76
+ ? info.memberPhotoUpload === true
77
+ : native && atLeast(info.binaryVersion ?? "", MEMBER_PHOTO_ROUTE_MIN_BINARY) && !!info.serveBaseUrl;
78
+ return { addresses, wallet: addresses && info.memberSiteBound === true, mediaField, passwordCredentials, memberPhotoRoute, webPreview: info.platform === "web" };
56
79
  }
@@ -13,7 +13,7 @@ import { snackbar } from "@himalaya/ui";
13
13
  import { deleteMemberPhones, getMyMember, listCustomFields, updateMember } from "@himalaya/wix-members";
14
14
  import { generateMemberPhotoUploadUrl } from "@himalaya/wix-site-media";
15
15
  import { memberAccess } from "../_shared/member-access.js";
16
- import { memberAccountRoutes } from "../_shared/member-account-routes.js";
16
+ import { MEMBER_PHOTO_UPLOAD_TARGET, isMemberPhotoUploadTarget, memberAccountRoutes } from "../_shared/member-account-routes.js";
17
17
  import { copyParam, stashCopy } from "../_shared/himi-copy.js";
18
18
  import {
19
19
  clean, currentMemberRecordMatches, fetchMember, isSignedOut, loadErrorVariant, memberInitials, rawText,
@@ -84,6 +84,8 @@ interface S extends ProfileValues {
84
84
  photoUploadAvailable: boolean;
85
85
  noPhotoUploadAvailable: boolean;
86
86
  photoUploadFunctionName: string;
87
+ /** The photo goes to the app's member-photo route as the member (no site function): the host answers the placeholder target. */
88
+ photoUploadViaRoute: boolean;
87
89
  photoDisplayUrl: string;
88
90
  uploadUrl: string;
89
91
  photoDraftUrl: string;
@@ -132,6 +134,7 @@ const EMPTY: S = {
132
134
  photoUploadAvailable: false,
133
135
  noPhotoUploadAvailable: true,
134
136
  photoUploadFunctionName: "",
137
+ photoUploadViaRoute: false,
135
138
  photoDisplayUrl: "",
136
139
  uploadUrl: "",
137
140
  photoDraftUrl: "",
@@ -373,9 +376,12 @@ function photoUploadFunctionName(value: unknown): string {
373
376
  const name = clean(value);
374
377
  return /^[A-Za-z][A-Za-z0-9_]{0,63}$/.test(name) ? name : "";
375
378
  }
376
- function validUploadUrl(value: unknown): string {
379
+ function validUploadUrl(value: unknown, viaRoute: boolean): string {
377
380
  if (typeof value !== "string") return "";
378
381
  // Hand-parsed: JSC (iOS) has no `URL` global. Host is plain letters/digits/dots, so userinfo and ports never match.
382
+ // The member-photo placeholder is the host's to answer with the member's credential; it names no host at all. Only the worker's own
383
+ // route path may publish it: a site function that returns it must not steer the host off the function's Wix Media upload.
384
+ if (isMemberPhotoUploadTarget(value)) return viaRoute && /^[A-Za-z0-9?=&.-]{0,64}$/.test(value.slice(MEMBER_PHOTO_UPLOAD_TARGET.length)) ? value : "";
379
385
  const m = /^https:\/\/([A-Za-z0-9.-]+)(?:[/?][^#\s\\]*)?$/.exec(value);
380
386
  const host = m ? m[1].toLowerCase() : "";
381
387
  return host === "wixmp.com" || host.endsWith(".wixmp.com") ? value : "";
@@ -401,6 +407,8 @@ function canonicalPhotoMediaId(value: unknown): string {
401
407
  let profileMutationInFlight = false;
402
408
  let photoUploadMintInFlight = false;
403
409
  let photoUploadVersion = 0;
410
+ /** Makes each pick's placeholder differ from the last (a retry must not look like the value left from a failed pick). */
411
+ let photoRouteNonce = 0;
404
412
  let loadVersion = 0;
405
413
  // The native picker uploads the file itself and never reports a failed PUT back to the worker, so a minted
406
414
  // upload URL counts as "upload in progress" only for a bounded window. Save waits inside it, then recovers.
@@ -570,8 +578,11 @@ const svc = defineService<S, {
570
578
  if (!(await currentMemberRecordMatches(email, scope, clean(member.id)))) throw signedOutError();
571
579
  if (version !== loadVersion) return svc.getState() as S;
572
580
  const functionName = photoUploadFunctionName((arg as { photoUploadFunctionName?: unknown } | undefined)?.photoUploadFunctionName);
573
- const available = !!functionName && routes.mediaField;
574
- return derive({ ...loaded(member, email, scope, site.fields, site.hasPhone), photoUploadFunctionName: functionName, photoUploadAvailable: available });
581
+ // The site's own upload function wins (it works on every binary that has MediaField). Without one, a host that sends the photo
582
+ // to the app's member-photo route as the member does the upload, with no site code: migrated apps have none.
583
+ const viaRoute = !functionName && routes.memberPhotoRoute;
584
+ const available = (!!functionName && routes.mediaField) || viaRoute;
585
+ return derive({ ...loaded(member, email, scope, site.fields, site.hasPhone), photoUploadFunctionName: functionName, photoUploadViaRoute: viaRoute, photoUploadAvailable: available });
575
586
  } catch (error) {
576
587
  if (version !== loadVersion) return svc.getState() as S;
577
588
  return loadFailed(error);
@@ -607,7 +618,7 @@ const svc = defineService<S, {
607
618
  return derive({ ...s, custom: { ...s.custom, [id]: value }, customErrors: { ...s.customErrors, [id]: "" }, saveError: "" });
608
619
  },
609
620
  genUpload: async (s, arg): Promise<Polled> => {
610
- if (photoUploadMintInFlight || s.phase !== "ready" || !s.memberId || !s.photoUploadAvailable || !s.photoUploadFunctionName) {
621
+ if (photoUploadMintInFlight || s.phase !== "ready" || !s.memberId || !s.photoUploadAvailable || (!s.photoUploadFunctionName && !s.photoUploadViaRoute)) {
611
622
  return derive({ ...s, uploadUrl: "", photoUploadError: copyParam("accountSettings.profilePhotoUnavailable", "Profile photo changes are not available in this session."), photoUploading: false });
612
623
  }
613
624
  photoUploadMintInFlight = true;
@@ -628,7 +639,10 @@ const svc = defineService<S, {
628
639
  if (version !== photoUploadVersion) return latest;
629
640
  return derive(clearPhotoUploadAttempt(latest, copyParam("accountSettings.profilePhotoUploadError", "The photo could not be prepared. Choose another image.")));
630
641
  }
631
- const minted = await generateMemberPhotoUploadUrl(s.photoUploadFunctionName, mimeType, fileName);
642
+ // Through the member-photo route there is nothing to mint: the placeholder says "send it as the member", and the host does.
643
+ const minted = s.photoUploadViaRoute
644
+ ? { uploadUrl: `${MEMBER_PHOTO_UPLOAD_TARGET}?n=${++photoRouteNonce}` }
645
+ : await generateMemberPhotoUploadUrl(s.photoUploadFunctionName, mimeType, fileName);
632
646
  if (version !== photoUploadVersion) return svc.getState() as S;
633
647
  if (!(await currentMemberRecordMatches(s.memberEmail, s.memberScope, s.memberId))) {
634
648
  const latest = svc.getState() as S;
@@ -636,7 +650,7 @@ const svc = defineService<S, {
636
650
  return derive(clearPhotoUploadAttempt(latest, accountChanged()));
637
651
  }
638
652
  if (version !== photoUploadVersion) return svc.getState() as S;
639
- const uploadUrl = validUploadUrl(minted.uploadUrl);
653
+ const uploadUrl = validUploadUrl(minted.uploadUrl, s.photoUploadViaRoute);
640
654
  if (!uploadUrl) return derive(clearPhotoUploadAttempt(svc.getState() as S, copyParam("accountSettings.profilePhotoUploadError", "The photo could not be prepared. Choose another image.")));
641
655
  const latest = svc.getState() as S;
642
656
  if (!sameMember(latest)) return latest;
@@ -17,6 +17,20 @@ import { isHostedWorker } from "./hosted-checkout.js";
17
17
  export const MEMBER_ACCOUNT_ROUTES_MIN_BINARY = "1.4.0";
18
18
  export const MEMBER_MEDIA_FIELD_MIN_BINARY = "1.5.0";
19
19
  export const MEMBER_PASSWORD_ACTIONS_MIN_BINARY = "1.5.0";
20
+ /** The HimalayaCore version whose MediaField answers the member-photo upload target (`MEMBER_PHOTO_UPLOAD_TARGET`). */
21
+ export const MEMBER_PHOTO_ROUTE_MIN_BINARY = "1.11.0";
22
+
23
+ // The upload target a MediaField worker publishes to say "send the picked photo to the app's member-photo route as me".
24
+ // It is a placeholder, not a URL: the HOST answers it with the member credential it already holds (web host, Android, iOS), and the
25
+ // shared presigned-upload policy (`*.wixmp.com`, credential-free) is untouched. A `?n=<nonce>` suffix keeps a retry's value different
26
+ // from the last one (every renderer requires the target to be minted for THIS pick). Held identical to the hosts' constants by
27
+ // the member-photo target parity test.
28
+ export const MEMBER_PHOTO_UPLOAD_TARGET = "himalaya-member-photo://upload";
29
+
30
+ /** Whether [value] is the placeholder: the bare target, or with a `?` suffix. */
31
+ export function isMemberPhotoUploadTarget(value: unknown): value is string {
32
+ return typeof value === "string" && (value === MEMBER_PHOTO_UPLOAD_TARGET || value.startsWith(`${MEMBER_PHOTO_UPLOAD_TARGET}?`));
33
+ }
20
34
 
21
35
  /** `version` (a HimalayaCore binary version, pre-release suffix ignored) is `floor` or later. */
22
36
  export function atLeast(version: string, floor: string): boolean {
@@ -38,6 +52,9 @@ export interface MemberAccountRoutes {
38
52
  mediaField: boolean;
39
53
  /** Password credential actions introduced in HimalayaCore 1.5.0. */
40
54
  passwordCredentials: boolean;
55
+ /** The host sends a picked profile photo to the app's member-photo route as the member (HimalayaCore 1.11.0 and later on native; the web
56
+ * host when that route is mounted; native also needs a server address). No site function is needed. A host without it keeps the "change your photo on the website" line. */
57
+ memberPhotoRoute: boolean;
41
58
  /** The web host: a preview of the app, never a member's real device. Account settings say
42
59
  * "in preview mode" there, and "here" in every other case it cannot change a password. */
43
60
  webPreview: boolean;
@@ -46,11 +63,17 @@ export interface MemberAccountRoutes {
46
63
  export async function memberAccountRoutes(): Promise<MemberAccountRoutes> {
47
64
  const info = await getAppInfo().catch(() => undefined);
48
65
  // A hosted app reaches none of these routes, but a hosted web build is still a preview.
49
- if (isHostedWorker()) return { addresses: false, wallet: false, mediaField: false, passwordCredentials: false, webPreview: info?.platform === "web" };
50
- if (!info) return { addresses: false, wallet: false, mediaField: false, passwordCredentials: false, webPreview: false };
66
+ if (isHostedWorker()) return { addresses: false, wallet: false, mediaField: false, passwordCredentials: false, memberPhotoRoute: false, webPreview: info?.platform === "web" };
67
+ if (!info) return { addresses: false, wallet: false, mediaField: false, passwordCredentials: false, memberPhotoRoute: false, webPreview: false };
51
68
  const native = info.platform === "ios" || info.platform === "android" || info.platform === "macos";
52
69
  const addresses = native && atLeast(info.binaryVersion ?? "", MEMBER_ACCOUNT_ROUTES_MIN_BINARY);
53
70
  const mediaField = native && atLeast(info.binaryVersion ?? "", MEMBER_MEDIA_FIELD_MIN_BINARY);
54
71
  const passwordCredentials = native && atLeast(info.binaryVersion ?? "", MEMBER_PASSWORD_ACTIONS_MIN_BINARY);
55
- return { addresses, wallet: addresses && info.memberSiteBound === true, mediaField, passwordCredentials, webPreview: info.platform === "web" };
72
+ // A host can answer the placeholder only where there is a member-photo route to send the photo to. Web says so itself (`memberPhotoUpload`: the
73
+ // route is mounted; the server address alone is not enough, a standalone build reports its baked address without the same-origin route).
74
+ // Native needs HimalayaCore 1.11.0 and a server address (an empty one means the local preview, where the picker would only fail).
75
+ const memberPhotoRoute = info.platform === "web"
76
+ ? info.memberPhotoUpload === true
77
+ : native && atLeast(info.binaryVersion ?? "", MEMBER_PHOTO_ROUTE_MIN_BINARY) && !!info.serveBaseUrl;
78
+ return { addresses, wallet: addresses && info.memberSiteBound === true, mediaField, passwordCredentials, memberPhotoRoute, webPreview: info.platform === "web" };
56
79
  }
@@ -13,7 +13,7 @@ import { snackbar } from "@himalaya/ui";
13
13
  import { deleteMemberPhones, getMyMember, listCustomFields, updateMember } from "@himalaya/wix-members";
14
14
  import { generateMemberPhotoUploadUrl } from "@himalaya/wix-site-media";
15
15
  import { memberAccess } from "../_shared/member-access.js";
16
- import { memberAccountRoutes } from "../_shared/member-account-routes.js";
16
+ import { MEMBER_PHOTO_UPLOAD_TARGET, isMemberPhotoUploadTarget, memberAccountRoutes } from "../_shared/member-account-routes.js";
17
17
  import { copyParam, stashCopy } from "../_shared/himi-copy.js";
18
18
  import {
19
19
  clean, currentMemberRecordMatches, fetchMember, isSignedOut, loadErrorVariant, memberInitials, rawText,
@@ -84,6 +84,8 @@ interface S extends ProfileValues {
84
84
  photoUploadAvailable: boolean;
85
85
  noPhotoUploadAvailable: boolean;
86
86
  photoUploadFunctionName: string;
87
+ /** The photo goes to the app's member-photo route as the member (no site function): the host answers the placeholder target. */
88
+ photoUploadViaRoute: boolean;
87
89
  photoDisplayUrl: string;
88
90
  uploadUrl: string;
89
91
  photoDraftUrl: string;
@@ -132,6 +134,7 @@ const EMPTY: S = {
132
134
  photoUploadAvailable: false,
133
135
  noPhotoUploadAvailable: true,
134
136
  photoUploadFunctionName: "",
137
+ photoUploadViaRoute: false,
135
138
  photoDisplayUrl: "",
136
139
  uploadUrl: "",
137
140
  photoDraftUrl: "",
@@ -373,9 +376,12 @@ function photoUploadFunctionName(value: unknown): string {
373
376
  const name = clean(value);
374
377
  return /^[A-Za-z][A-Za-z0-9_]{0,63}$/.test(name) ? name : "";
375
378
  }
376
- function validUploadUrl(value: unknown): string {
379
+ function validUploadUrl(value: unknown, viaRoute: boolean): string {
377
380
  if (typeof value !== "string") return "";
378
381
  // Hand-parsed: JSC (iOS) has no `URL` global. Host is plain letters/digits/dots, so userinfo and ports never match.
382
+ // The member-photo placeholder is the host's to answer with the member's credential; it names no host at all. Only the worker's own
383
+ // route path may publish it: a site function that returns it must not steer the host off the function's Wix Media upload.
384
+ if (isMemberPhotoUploadTarget(value)) return viaRoute && /^[A-Za-z0-9?=&.-]{0,64}$/.test(value.slice(MEMBER_PHOTO_UPLOAD_TARGET.length)) ? value : "";
379
385
  const m = /^https:\/\/([A-Za-z0-9.-]+)(?:[/?][^#\s\\]*)?$/.exec(value);
380
386
  const host = m ? m[1].toLowerCase() : "";
381
387
  return host === "wixmp.com" || host.endsWith(".wixmp.com") ? value : "";
@@ -401,6 +407,8 @@ function canonicalPhotoMediaId(value: unknown): string {
401
407
  let profileMutationInFlight = false;
402
408
  let photoUploadMintInFlight = false;
403
409
  let photoUploadVersion = 0;
410
+ /** Makes each pick's placeholder differ from the last (a retry must not look like the value left from a failed pick). */
411
+ let photoRouteNonce = 0;
404
412
  let loadVersion = 0;
405
413
  // The native picker uploads the file itself and never reports a failed PUT back to the worker, so a minted
406
414
  // upload URL counts as "upload in progress" only for a bounded window. Save waits inside it, then recovers.
@@ -570,8 +578,11 @@ const svc = defineService<S, {
570
578
  if (!(await currentMemberRecordMatches(email, scope, clean(member.id)))) throw signedOutError();
571
579
  if (version !== loadVersion) return svc.getState() as S;
572
580
  const functionName = photoUploadFunctionName((arg as { photoUploadFunctionName?: unknown } | undefined)?.photoUploadFunctionName);
573
- const available = !!functionName && routes.mediaField;
574
- return derive({ ...loaded(member, email, scope, site.fields, site.hasPhone), photoUploadFunctionName: functionName, photoUploadAvailable: available });
581
+ // The site's own upload function wins (it works on every binary that has MediaField). Without one, a host that sends the photo
582
+ // to the app's member-photo route as the member does the upload, with no site code: migrated apps have none.
583
+ const viaRoute = !functionName && routes.memberPhotoRoute;
584
+ const available = (!!functionName && routes.mediaField) || viaRoute;
585
+ return derive({ ...loaded(member, email, scope, site.fields, site.hasPhone), photoUploadFunctionName: functionName, photoUploadViaRoute: viaRoute, photoUploadAvailable: available });
575
586
  } catch (error) {
576
587
  if (version !== loadVersion) return svc.getState() as S;
577
588
  return loadFailed(error);
@@ -607,7 +618,7 @@ const svc = defineService<S, {
607
618
  return derive({ ...s, custom: { ...s.custom, [id]: value }, customErrors: { ...s.customErrors, [id]: "" }, saveError: "" });
608
619
  },
609
620
  genUpload: async (s, arg): Promise<Polled> => {
610
- if (photoUploadMintInFlight || s.phase !== "ready" || !s.memberId || !s.photoUploadAvailable || !s.photoUploadFunctionName) {
621
+ if (photoUploadMintInFlight || s.phase !== "ready" || !s.memberId || !s.photoUploadAvailable || (!s.photoUploadFunctionName && !s.photoUploadViaRoute)) {
611
622
  return derive({ ...s, uploadUrl: "", photoUploadError: copyParam("accountSettings.profilePhotoUnavailable", "Profile photo changes are not available in this session."), photoUploading: false });
612
623
  }
613
624
  photoUploadMintInFlight = true;
@@ -628,7 +639,10 @@ const svc = defineService<S, {
628
639
  if (version !== photoUploadVersion) return latest;
629
640
  return derive(clearPhotoUploadAttempt(latest, copyParam("accountSettings.profilePhotoUploadError", "The photo could not be prepared. Choose another image.")));
630
641
  }
631
- const minted = await generateMemberPhotoUploadUrl(s.photoUploadFunctionName, mimeType, fileName);
642
+ // Through the member-photo route there is nothing to mint: the placeholder says "send it as the member", and the host does.
643
+ const minted = s.photoUploadViaRoute
644
+ ? { uploadUrl: `${MEMBER_PHOTO_UPLOAD_TARGET}?n=${++photoRouteNonce}` }
645
+ : await generateMemberPhotoUploadUrl(s.photoUploadFunctionName, mimeType, fileName);
632
646
  if (version !== photoUploadVersion) return svc.getState() as S;
633
647
  if (!(await currentMemberRecordMatches(s.memberEmail, s.memberScope, s.memberId))) {
634
648
  const latest = svc.getState() as S;
@@ -636,7 +650,7 @@ const svc = defineService<S, {
636
650
  return derive(clearPhotoUploadAttempt(latest, accountChanged()));
637
651
  }
638
652
  if (version !== photoUploadVersion) return svc.getState() as S;
639
- const uploadUrl = validUploadUrl(minted.uploadUrl);
653
+ const uploadUrl = validUploadUrl(minted.uploadUrl, s.photoUploadViaRoute);
640
654
  if (!uploadUrl) return derive(clearPhotoUploadAttempt(svc.getState() as S, copyParam("accountSettings.profilePhotoUploadError", "The photo could not be prepared. Choose another image.")));
641
655
  const latest = svc.getState() as S;
642
656
  if (!sameMember(latest)) return latest;
@@ -17,6 +17,20 @@ import { isHostedWorker } from "./hosted-checkout.js";
17
17
  export const MEMBER_ACCOUNT_ROUTES_MIN_BINARY = "1.4.0";
18
18
  export const MEMBER_MEDIA_FIELD_MIN_BINARY = "1.5.0";
19
19
  export const MEMBER_PASSWORD_ACTIONS_MIN_BINARY = "1.5.0";
20
+ /** The HimalayaCore version whose MediaField answers the member-photo upload target (`MEMBER_PHOTO_UPLOAD_TARGET`). */
21
+ export const MEMBER_PHOTO_ROUTE_MIN_BINARY = "1.11.0";
22
+
23
+ // The upload target a MediaField worker publishes to say "send the picked photo to the app's member-photo route as me".
24
+ // It is a placeholder, not a URL: the HOST answers it with the member credential it already holds (web host, Android, iOS), and the
25
+ // shared presigned-upload policy (`*.wixmp.com`, credential-free) is untouched. A `?n=<nonce>` suffix keeps a retry's value different
26
+ // from the last one (every renderer requires the target to be minted for THIS pick). Held identical to the hosts' constants by
27
+ // the member-photo target parity test.
28
+ export const MEMBER_PHOTO_UPLOAD_TARGET = "himalaya-member-photo://upload";
29
+
30
+ /** Whether [value] is the placeholder: the bare target, or with a `?` suffix. */
31
+ export function isMemberPhotoUploadTarget(value: unknown): value is string {
32
+ return typeof value === "string" && (value === MEMBER_PHOTO_UPLOAD_TARGET || value.startsWith(`${MEMBER_PHOTO_UPLOAD_TARGET}?`));
33
+ }
20
34
 
21
35
  /** `version` (a HimalayaCore binary version, pre-release suffix ignored) is `floor` or later. */
22
36
  export function atLeast(version: string, floor: string): boolean {
@@ -38,6 +52,9 @@ export interface MemberAccountRoutes {
38
52
  mediaField: boolean;
39
53
  /** Password credential actions introduced in HimalayaCore 1.5.0. */
40
54
  passwordCredentials: boolean;
55
+ /** The host sends a picked profile photo to the app's member-photo route as the member (HimalayaCore 1.11.0 and later on native; the web
56
+ * host when that route is mounted; native also needs a server address). No site function is needed. A host without it keeps the "change your photo on the website" line. */
57
+ memberPhotoRoute: boolean;
41
58
  /** The web host: a preview of the app, never a member's real device. Account settings say
42
59
  * "in preview mode" there, and "here" in every other case it cannot change a password. */
43
60
  webPreview: boolean;
@@ -46,11 +63,17 @@ export interface MemberAccountRoutes {
46
63
  export async function memberAccountRoutes(): Promise<MemberAccountRoutes> {
47
64
  const info = await getAppInfo().catch(() => undefined);
48
65
  // A hosted app reaches none of these routes, but a hosted web build is still a preview.
49
- if (isHostedWorker()) return { addresses: false, wallet: false, mediaField: false, passwordCredentials: false, webPreview: info?.platform === "web" };
50
- if (!info) return { addresses: false, wallet: false, mediaField: false, passwordCredentials: false, webPreview: false };
66
+ if (isHostedWorker()) return { addresses: false, wallet: false, mediaField: false, passwordCredentials: false, memberPhotoRoute: false, webPreview: info?.platform === "web" };
67
+ if (!info) return { addresses: false, wallet: false, mediaField: false, passwordCredentials: false, memberPhotoRoute: false, webPreview: false };
51
68
  const native = info.platform === "ios" || info.platform === "android" || info.platform === "macos";
52
69
  const addresses = native && atLeast(info.binaryVersion ?? "", MEMBER_ACCOUNT_ROUTES_MIN_BINARY);
53
70
  const mediaField = native && atLeast(info.binaryVersion ?? "", MEMBER_MEDIA_FIELD_MIN_BINARY);
54
71
  const passwordCredentials = native && atLeast(info.binaryVersion ?? "", MEMBER_PASSWORD_ACTIONS_MIN_BINARY);
55
- return { addresses, wallet: addresses && info.memberSiteBound === true, mediaField, passwordCredentials, webPreview: info.platform === "web" };
72
+ // A host can answer the placeholder only where there is a member-photo route to send the photo to. Web says so itself (`memberPhotoUpload`: the
73
+ // route is mounted; the server address alone is not enough, a standalone build reports its baked address without the same-origin route).
74
+ // Native needs HimalayaCore 1.11.0 and a server address (an empty one means the local preview, where the picker would only fail).
75
+ const memberPhotoRoute = info.platform === "web"
76
+ ? info.memberPhotoUpload === true
77
+ : native && atLeast(info.binaryVersion ?? "", MEMBER_PHOTO_ROUTE_MIN_BINARY) && !!info.serveBaseUrl;
78
+ return { addresses, wallet: addresses && info.memberSiteBound === true, mediaField, passwordCredentials, memberPhotoRoute, webPreview: info.platform === "web" };
56
79
  }