@wix/himalaya-cli 0.1886.0 → 0.1888.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/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/app-info/src/index.d.ts +4 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/app-info.mjs +1 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/iap-checkout.mjs +1 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/screens.mjs +1 -0
- package/dist/browser-plane/assets.json +5 -5
- package/dist/browser-plane/preview-deferred/{3c60676d1298b453781d40ec97d5ab59bdc85b33b983653e9c5fd750ac11c8a0.bin → d4250730f37a006c948187a7640453097348fa24695586a3d0014c041511c896.bin} +1 -1
- package/dist/browser-plane/sw.js +8 -8
- package/dist/cli.mjs +58393 -58217
- package/dist/preview-assets.generated.bin +0 -0
- package/guides/himi-json-output.md +23 -0
- package/package.json +2 -2
- package/templates/bare-fashion/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/bare-fashion/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/beauty-salon/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/beauty-salon/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/branded-lite/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/branded-lite/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/brandy/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/brandy/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/community-club/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/community-club/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/conference/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/conference/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/events-meetups/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/events-meetups/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/fitness-gym/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/fitness-gym/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/gym-fitness/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/gym-fitness/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/medical-services/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/medical-services/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/nonprofit-cause/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/nonprofit-cause/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/personal-fitness-trainer/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/podcast-creator/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/podcast-creator/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/portfolio-creative/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/portfolio-creative/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/professional-services/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/professional-services/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/restaurant/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/restaurant/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/retail-store/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/retail-store/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/salon-spa/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/salon-spa/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/wholesale-store/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/wholesale-store/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/yoga-studio/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/yoga-studio/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
|
Binary file
|
|
@@ -385,6 +385,17 @@ signed in without Wix: `federated_not_allowed`, `federated_disabled`, `federated
|
|
|
385
385
|
codes. Their other fields (`status`, the plane's body) are unchanged, and any other refusal keeps the
|
|
386
386
|
command's existing envelope.
|
|
387
387
|
|
|
388
|
+
### One App navigation warnings
|
|
389
|
+
|
|
390
|
+
For a One App migration (its `.himi/one-app/manifest.json` or `ONE-APP-COVERAGE.json` is present), `himi test` lists these in `oneAppWarnings`
|
|
391
|
+
and records them in its attestation, and `himi push` adds them to its `warnings` when the release it publishes has a test run. They are
|
|
392
|
+
warnings only: they never change `ok`, the exit code or `--strict`. Match on `code`, never on `message`.
|
|
393
|
+
|
|
394
|
+
| Code | Meaning |
|
|
395
|
+
|---|---|
|
|
396
|
+
| `one_app_nav_target_missing` | A link opens a screen the app does not have (neither a screen nor a linkable route). The tap opens nothing. |
|
|
397
|
+
| `one_app_screen_unreachable` | A page the migration generated is not reachable from the tabs, the top bar, Profile or any link, and no link the test could not resolve is left to open it. While a reachable screen has link sites the test cannot resolve (list rows bound to a service, computed targets), a page nothing else opens is `unknown`, not unreachable, and nothing is warned: the attestation records it under `nav.unknown`. |
|
|
398
|
+
|
|
388
399
|
The `ux_evidence_*` codes map to the existing typed `uxEvidence.state`; a successful
|
|
389
400
|
`recorded` state has no refusal code. Successful pushes and warnings do not gain
|
|
390
401
|
failure codes. A forced push still follows the existing override rules.
|
|
@@ -396,6 +407,18 @@ then carries a `ring_pinned` entry in `warnings` (also printed to stderr) and
|
|
|
396
407
|
that moves the ring to the new release. When the push passed `--control-url`, `promote` repeats it. It stays `ok: true`. When the rings cannot be read, push
|
|
397
408
|
prints neither.
|
|
398
409
|
|
|
410
|
+
### One App shell warnings
|
|
411
|
+
|
|
412
|
+
For an app that declares `app: { newApp: true }`, `himi push` (an app with One App evidence) adds these entries to its `warnings`,
|
|
413
|
+
and `himi validate` lists them in `oneAppWarnings` and in `warnings` as `<code>: <message>`. They are warnings only: they never change
|
|
414
|
+
`ok`, the exit code, or `--strict`. Match on `code`, never on `message`.
|
|
415
|
+
|
|
416
|
+
| Code | Meaning |
|
|
417
|
+
|---|---|
|
|
418
|
+
| `one_app_side_menu_present` | `navigation.drawer.items` still has rows. A new app has the profile avatar instead of the hamburger and serves an empty drawer. The message says why the migration left it, when `retireSideMenu` reported `kept`. |
|
|
419
|
+
| `one_app_top_bar_hamburger` | The default top bar, or a screen's own bar, has a hamburger / drawer toggle (`leading: "menu"`, or a leading item or action that names the drawer). |
|
|
420
|
+
| `one_app_profile_avatar_missing` | The default top bar has no leading profile avatar that opens `himi_account`. |
|
|
421
|
+
|
|
399
422
|
## `himi notify` owner-login codes
|
|
400
423
|
|
|
401
424
|
`himi notify setup|status` and `himi notify send --provider ping` carry `code` on these refusals
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/himalaya-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1888.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": "
|
|
85
|
+
"falconPackageHash": "f3e605364c0099ac1187a8b1f8fdc1a1be7653bd710dd33a68374151"
|
|
86
86
|
}
|
|
@@ -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
|
-
|
|
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
|
}
|
package/templates/bare-fashion/tier5-src/himi-branded-lite-account-settings/personal-info.ts
CHANGED
|
@@ -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
|
-
|
|
574
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
}
|
package/templates/beauty-salon/tier5-src/himi-branded-lite-account-settings/personal-info.ts
CHANGED
|
@@ -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
|
-
|
|
574
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
}
|
package/templates/branded-lite/tier5-src/himi-branded-lite-account-settings/personal-info.ts
CHANGED
|
@@ -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
|
-
|
|
574
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
}
|