@wix/himalaya-cli 0.1883.0 → 0.1885.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/cli.mjs CHANGED
@@ -11972,7 +11972,7 @@ function compileV2(html, profile, options2) {
11972
11972
  return;
11973
11973
  }
11974
11974
  const record6 = value2;
11975
- if (record6.body) {
11975
+ if (record6.body && typeof record6.body === "object" && typeof record6.body.type === "string") {
11976
11976
  const nested = own6(profile.components, record6.body.type);
11977
11977
  if (!nested || nested.package !== record6.body.package) {
11978
11978
  error(el2, "HHP-COMPONENT", "Structured component is unavailable in this app profile.");
@@ -12070,7 +12070,7 @@ function compileV2(html, profile, options2) {
12070
12070
  delete style.font;
12071
12071
  }
12072
12072
  if (style.display && !["main", "div", "header", "footer", "nav", "himi-v-stack", "himi-h-stack", "himi-grid"].includes(tag))
12073
- error(el2, "HHP-CSS-COMPONENT", "display layout rules require a stack or grid container.");
12073
+ error(el2, "HHP-CSS-COMPONENT", `<${tag}> sets display, but display layout rules require a stack or grid container.`, `Remove display/flex rules from <${tag}> and give it plain text; to lay several elements out together, put a <div> stack around them and style that.`);
12074
12074
  type2 = translateStyle(style, profile, type2, props2, mods, (message5, hint, property3) => diagnostics.push({ code: "HHP-CSS-VALUE", severity: "error", ...styleLocations[property3 ?? ""] ?? loc(el2), message: message5, ...hint ? { hint } : {} }));
12075
12075
  const spec = Object.hasOwn(profile.components, type2) ? profile.components[type2] : void 0;
12076
12076
  let id = attrs["data-id"] ?? attrs.id ?? `hhp.${screenId}.${treePath}`;
@@ -41737,6 +41737,7 @@ function resolveIdiom(tokens2, ctx = {}) {
41737
41737
  var IDIOM_CONTEXTS, UNSAFE_KEYS;
41738
41738
  var init_idiom = __esm({
41739
41739
  "../../core/ts/src/idiom.ts"() {
41740
+ "use strict";
41740
41741
  init_define_HHP_CATALOG();
41741
41742
  IDIOM_CONTEXTS = {
41742
41743
  ios: { native: ["ios"] },
@@ -44278,8 +44279,8 @@ function instancePayload(instance) {
44278
44279
  const part7 = instance.split(".")[1];
44279
44280
  if (!part7) return null;
44280
44281
  try {
44281
- const b642 = part7.replace(/-/g, "+").replace(/_/g, "/").padEnd(Math.ceil(part7.length / 4) * 4, "=");
44282
- const parsed = JSON.parse(decodeURIComponent(Array.from(atob(b642), (c2) => `%${c2.charCodeAt(0).toString(16).padStart(2, "0")}`).join("")));
44282
+ const b643 = part7.replace(/-/g, "+").replace(/_/g, "/").padEnd(Math.ceil(part7.length / 4) * 4, "=");
44283
+ const parsed = JSON.parse(decodeURIComponent(Array.from(atob(b643), (c2) => `%${c2.charCodeAt(0).toString(16).padStart(2, "0")}`).join("")));
44283
44284
  return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
44284
44285
  } catch {
44285
44286
  return null;
@@ -94944,7 +94945,7 @@ var init_pdf_worker_min = __esm({
94944
94945
  return e3;
94945
94946
  } });
94946
94947
  }, 3110(e2, t2, n2) {
94947
- var a3 = n2(6518), r3 = n2(7751), s5 = n2(9565), i2 = n2(9504), o2 = n2(9039), l3 = n2(4376), f2 = n2(4901), c2 = n2(34), h2 = n2(2360), u2 = n2(5810), m2 = n2(757), p2 = n2(2195), d2 = n2(1240), g2 = n2(9617).includes, b3 = n2(9297), w2 = n2(655), j2 = n2(8235), k3 = n2(3392), y2 = n2(4495), q4 = n2(7819), v2 = String, S3 = TypeError, x2 = r3("JSON", "stringify"), C2 = r3("BigInt"), T2 = i2("".valueOf), O2 = i2(true.valueOf), R2 = C2 && i2(C2.prototype.valueOf), D2 = i2(/./.exec), H2 = i2("".charAt), M2 = i2("".charCodeAt), N6 = i2("".replace), _2 = i2("".slice), E2 = i2([].push), z8 = i2([].pop), L2 = i2(1.1.toString), U2 = /[\uD800-\uDFFF]/g, W2 = /^[\uD800-\uDBFF]$/, X2 = /^[\uDC00-\uDFFF]$/, K3 = /^\d+$/, G3 = k3(), V2 = k3(), $2 = k3(), Y2 = G3.length, J2 = V2.length, Q2 = !y2 || o2(function() {
94948
+ var a3 = n2(6518), r3 = n2(7751), s5 = n2(9565), i2 = n2(9504), o2 = n2(9039), l3 = n2(4376), f2 = n2(4901), c2 = n2(34), h2 = n2(2360), u2 = n2(5810), m2 = n2(757), p2 = n2(2195), d2 = n2(1240), g2 = n2(9617).includes, b3 = n2(9297), w2 = n2(655), j2 = n2(8235), k3 = n2(3392), y2 = n2(4495), q4 = n2(7819), v2 = String, S3 = TypeError, x2 = r3("JSON", "stringify"), C2 = r3("BigInt"), T2 = i2("".valueOf), O2 = i2(true.valueOf), R2 = C2 && i2(C2.prototype.valueOf), D2 = i2(/./.exec), H2 = i2("".charAt), M2 = i2("".charCodeAt), N6 = i2("".replace), _2 = i2("".slice), E2 = i2([].push), z8 = i2([].pop), L2 = i2(1.1.toString), U2 = /[\uD800-\uDFFF]/g, W2 = /^[\uD800-\uDBFF]$/, X2 = /^[\uDC00-\uDFFF]$/, K3 = /^\d+$/, G3 = k3(), V2 = k3(), $2 = k3(), Y2 = G3.length, J3 = V2.length, Q2 = !y2 || o2(function() {
94948
94949
  var e3 = r3("Symbol")("stringify detection");
94949
94950
  return "[null]" !== x2([e3]) || "{}" !== x2({ a: e3 }) || "{}" !== x2(Object(e3));
94950
94951
  }), Z2 = o2(function() {
@@ -95045,7 +95046,7 @@ var init_pdf_worker_min = __esm({
95045
95046
  var O3 = H2(y3, T3);
95046
95047
  if ('"' === O3) {
95047
95048
  var R3 = j2(y3, ++T3).end - 1, M3 = _2(y3, T3, R3);
95048
- _2(M3, 0, Y2) === G3 ? x3 += c3[_2(M3, Y2)] : _2(M3, 0, J2) === V2 ? x3 += '"' + _2(M3, J2) + '"' : x3 += '"' + M3 + '"';
95049
+ _2(M3, 0, Y2) === G3 ? x3 += c3[_2(M3, Y2)] : _2(M3, 0, J3) === V2 ? x3 += '"' + _2(M3, J3) + '"' : x3 += '"' + M3 + '"';
95049
95050
  T3 = R3;
95050
95051
  } else x3 += O3;
95051
95052
  }
@@ -149877,20 +149878,20 @@ async function pngFontFaceCss(tokens2, opts = {}) {
149877
149878
  if (hit !== void 0) return hit;
149878
149879
  const bytes2 = await faceBytes(face, catalog4, opts);
149879
149880
  if (!bytes2) return null;
149880
- const b642 = bytes2.toString("base64");
149881
- cache4?.set(face.sha256, b642);
149882
- return b642;
149881
+ const b643 = bytes2.toString("base64");
149882
+ cache4?.set(face.sha256, b643);
149883
+ return b643;
149883
149884
  })
149884
149885
  );
149885
149886
  const rules = [];
149886
149887
  wanted.forEach(({ family, face, variable }, i2) => {
149887
- const b642 = data[i2];
149888
- if (b642 == null) return;
149888
+ const b643 = data[i2];
149889
+ if (b643 == null) return;
149889
149890
  const [mime, format] = FORMATS[extname(face.file).toLowerCase()] ?? ["font/ttf", "truetype"];
149890
149891
  const wght = variable?.axes?.["wght"];
149891
149892
  const weight2 = wght ? `${wght.min} ${wght.max}` : String(face.weight);
149892
149893
  rules.push(
149893
- `@font-face{font-family:${cssString(family)};font-weight:${weight2};font-style:${face.style ?? "normal"};font-display:block;src:url(data:${mime};base64,${b642}) format("${format}")}`
149894
+ `@font-face{font-family:${cssString(family)};font-weight:${weight2};font-style:${face.style ?? "normal"};font-display:block;src:url(data:${mime};base64,${b643}) format("${format}")}`
149894
149895
  );
149895
149896
  });
149896
149897
  return rules.join("");
@@ -152403,7 +152404,7 @@ async function handleWebWix(req, res, state) {
152403
152404
  const session = webWixSession(req, res, state);
152404
152405
  const auth = resolveWebWixAuth(state.app);
152405
152406
  const path2 = new URL(req.url ?? "", "http://localhost").pathname;
152406
- const readJson16 = async () => {
152407
+ const readJson17 = async () => {
152407
152408
  const chunks = [];
152408
152409
  for await (const c2 of req) chunks.push(c2);
152409
152410
  const t2 = Buffer.concat(chunks).toString("utf8");
@@ -152420,7 +152421,7 @@ async function handleWebWix(req, res, state) {
152420
152421
  res.end(JSON.stringify(obj30));
152421
152422
  };
152422
152423
  if (path2 === "/v1/__webwix/stream" && req.method === "POST") {
152423
- const b3 = await readJson16();
152424
+ const b3 = await readJson17();
152424
152425
  const method = String(b3.method ?? "GET").toUpperCase();
152425
152426
  const requestedUrl = String(b3.url ?? "");
152426
152427
  const body = b3.body === void 0 ? void 0 : typeof b3.body === "string" ? b3.body : JSON.stringify(b3.body);
@@ -152574,7 +152575,7 @@ async function handleWebWix(req, res, state) {
152574
152575
  if (oneAppMetaSiteIdOf(state.app?.meta.auth) && !resolveWixClientId(state.app)) {
152575
152576
  return reply(200, { ok: false, code: "unavailable", error: "member_login_unavailable" });
152576
152577
  }
152577
- const b3 = await readJson16();
152578
+ const b3 = await readJson17();
152578
152579
  try {
152579
152580
  const { memberToken, visitorToken } = await memberDirectLogin(
152580
152581
  auth.clientId,
@@ -152667,7 +152668,7 @@ async function handleWebWix(req, res, state) {
152667
152668
  res.setHeader("cache-control", "no-store");
152668
152669
  const account2 = session.account;
152669
152670
  if (!account2) return reply(401, { error: "webwix_account_signed_out" });
152670
- const metaSiteId = String((await readJson16()).metaSiteId ?? "").trim();
152671
+ const metaSiteId = String((await readJson17()).metaSiteId ?? "").trim();
152671
152672
  if (!isSafeMsid(metaSiteId)) return reply(400, { error: "webwix_account_bad_site_id" });
152672
152673
  if (sealedAccountRoute) return sealedRefusal(MEMBER_SESSION_URL, "POST");
152673
152674
  try {
@@ -152688,7 +152689,7 @@ async function handleWebWix(req, res, state) {
152688
152689
  if (!accountApp) return reply(404, { error: "webwix_account_unsupported" });
152689
152690
  if (req.method !== "POST") return reply(405, { error: "method_not_allowed" });
152690
152691
  res.setHeader("cache-control", "no-store");
152691
- const shortId = String((await readJson16()).shortId ?? "").trim();
152692
+ const shortId = String((await readJson17()).shortId ?? "").trim();
152692
152693
  const start2 = inviteShortLinkUrl(shortId);
152693
152694
  if (!start2) return reply(400, { error: "webwix_short_link_bad_id" });
152694
152695
  if (sealedAccountRoute) return sealedRefusal(start2, "GET");
@@ -152697,7 +152698,7 @@ async function handleWebWix(req, res, state) {
152697
152698
  return url ? reply(200, { url }) : reply(404, { error: "webwix_short_link_unresolved" });
152698
152699
  }
152699
152700
  if (path2 === "/v1/__webwix/call" && req.method === "POST") {
152700
- const b3 = await readJson16();
152701
+ const b3 = await readJson17();
152701
152702
  const ownerRung = b3.ownerMsid !== void 0 || b3.checkOwnerSession === true;
152702
152703
  const accountRung = !ownerRung && accountApp && !!session.account;
152703
152704
  const msid = String(b3.ownerMsid ?? "");
@@ -152895,7 +152896,7 @@ async function handleWebWix(req, res, state) {
152895
152896
  if (oneAppMetaSiteIdOf(state.app?.meta.auth) && !resolveWixClientId(state.app)) {
152896
152897
  return reply(200, { ok: false, code: "unavailable", error: "member_login_unavailable" });
152897
152898
  }
152898
- const b3 = await readJson16();
152899
+ const b3 = await readJson17();
152899
152900
  try {
152900
152901
  const { memberToken, visitorToken } = await memberDirectRegister(
152901
152902
  auth.clientId,
@@ -183495,8 +183496,8 @@ var init_milestones = __esm({
183495
183496
  });
183496
183497
 
183497
183498
  // ../../core/serve-storage/src/base64.ts
183498
- function fromBase64(b642) {
183499
- const bin = atob(b642);
183499
+ function fromBase64(b643) {
183500
+ const bin = atob(b643);
183500
183501
  const out2 = new Uint8Array(bin.length);
183501
183502
  for (let i2 = 0; i2 < bin.length; i2++) out2[i2] = bin.charCodeAt(i2) & 255;
183502
183503
  return out2;
@@ -195329,10 +195330,10 @@ async function runShotsPass(opts) {
195329
195330
  const files = {};
195330
195331
  const states = {};
195331
195332
  for (let i2 = 0; i2 < shots.length; i2++) {
195332
- const b642 = pngs[i2];
195333
- if (!b642) continue;
195333
+ const b643 = pngs[i2];
195334
+ if (!b643) continue;
195334
195335
  const file2 = `${opts.outDir}/${shots[i2].screenId}.png`;
195335
- const own6 = opts.deps.writePng(file2, b642, shots[i2].screenId);
195336
+ const own6 = opts.deps.writePng(file2, b643, shots[i2].screenId);
195336
195337
  if (own6 === null) {
195337
195338
  refused2.push(shots[i2].screenId);
195338
195339
  continue;
@@ -215790,9 +215791,9 @@ var init_local = __esm({
215790
215791
  return lease(account2, this.privateKey(), this.now());
215791
215792
  }
215792
215793
  privateKey() {
215793
- const b642 = this.env.ASC_PRIVATE_KEY_B64?.trim();
215794
- if (b642)
215795
- return Buffer.from(b642, "base64").toString("utf8");
215794
+ const b643 = this.env.ASC_PRIVATE_KEY_B64?.trim();
215795
+ if (b643)
215796
+ return Buffer.from(b643, "base64").toString("utf8");
215796
215797
  const inline = this.env.ASC_PRIVATE_KEY;
215797
215798
  if (inline?.trim())
215798
215799
  return inline.replace(/\\n/g, "\n");
@@ -258192,7 +258193,7 @@ async function renderCommand(ctx) {
258192
258193
  pngFile = explicitPng ? writePngFile(explicitPng, r3.pngBase64) : attestationPngFile;
258193
258194
  }
258194
258195
  const beside = (suffix) => pngFile ? pngFile.replace(/\.png$/i, "") + suffix + ".png" : void 0;
258195
- const frameFiles = r3.entranceFramesBase64 && pngFile ? r3.entranceFramesBase64.map((b642, i2) => writePngFile(beside(`-enter-${i2}`), b642)) : void 0;
258196
+ const frameFiles = r3.entranceFramesBase64 && pngFile ? r3.entranceFramesBase64.map((b643, i2) => writePngFile(beside(`-enter-${i2}`), b643)) : void 0;
258196
258197
  const pressedFile = r3.pressedBase64 && pngFile ? writePngFile(beside("-pressed"), r3.pressedBase64) : void 0;
258197
258198
  if (renderWidth !== void 0 && r3.renderable) {
258198
258199
  recordRenderWidth(dir, {
@@ -259612,11 +259613,11 @@ function planFromPayload(payload, base2, selectors) {
259612
259613
  patch.bundles = {};
259613
259614
  for (const name of wantBundles) {
259614
259615
  const sha7 = local.bundles?.[name]?.sha256;
259615
- const b642 = sha7 ? payload.bundles?.[sha7] : void 0;
259616
- if (!sha7 || !b642) {
259616
+ const b643 = sha7 ? payload.bundles?.[sha7] : void 0;
259617
+ if (!sha7 || !b643) {
259617
259618
  return { ok: false, error: { error: "selector_matched_nothing", selector: `bundle:${name}`, message: `bundle "${name}" has no built bytes in this release \u2014 run \`himi build\` first.`, bundles: localBundles } };
259618
259619
  }
259619
- patch.bundles[sha7] = b642;
259620
+ patch.bundles[sha7] = b643;
259620
259621
  touched.push(`bundle:${name}`);
259621
259622
  }
259622
259623
  }
@@ -260655,6 +260656,164 @@ var init_member_exchange = __esm({
260655
260656
  }
260656
260657
  });
260657
260658
 
260659
+ // ../../core/serve-runtime/src/member-photo.ts
260660
+ function sniffImageMime(bytes2) {
260661
+ const at2 = (i2) => bytes2[i2];
260662
+ if (bytes2.length >= 8 && at2(0) === 137 && at2(1) === 80 && at2(2) === 78 && at2(3) === 71 && at2(4) === 13 && at2(5) === 10 && at2(6) === 26 && at2(7) === 10) return "image/png";
260663
+ if (bytes2.length >= 3 && at2(0) === 255 && at2(1) === 216 && at2(2) === 255) return "image/jpeg";
260664
+ if (bytes2.length >= 12 && at2(0) === 82 && at2(1) === 73 && at2(2) === 70 && at2(3) === 70 && at2(8) === 87 && at2(9) === 69 && at2(10) === 66 && at2(11) === 80) return "image/webp";
260665
+ return null;
260666
+ }
260667
+ async function readBodyCapped(request2, max = MEMBER_PHOTO_MAX_BYTES) {
260668
+ const declared = Number(request2.headers.get("content-length"));
260669
+ if (Number.isFinite(declared) && declared > max) {
260670
+ await request2.body?.cancel().catch(() => {
260671
+ });
260672
+ return null;
260673
+ }
260674
+ if (!request2.body) return new Uint8Array(0);
260675
+ const reader = request2.body.getReader();
260676
+ const chunks = [];
260677
+ let total = 0;
260678
+ for (; ; ) {
260679
+ const { done, value: value2 } = await reader.read();
260680
+ if (done) break;
260681
+ total += value2.byteLength;
260682
+ if (total > max) {
260683
+ await reader.cancel().catch(() => {
260684
+ });
260685
+ return null;
260686
+ }
260687
+ chunks.push(value2);
260688
+ }
260689
+ const out2 = new Uint8Array(total);
260690
+ let offset = 0;
260691
+ for (const chunk2 of chunks) {
260692
+ out2.set(chunk2, offset);
260693
+ offset += chunk2.byteLength;
260694
+ }
260695
+ return out2;
260696
+ }
260697
+ function isMediaHost(raw) {
260698
+ let url;
260699
+ try {
260700
+ url = new URL(raw);
260701
+ } catch {
260702
+ return false;
260703
+ }
260704
+ if (url.protocol !== "https:" || url.port !== "" || url.username || url.password) return false;
260705
+ const host = url.hostname.toLowerCase();
260706
+ return host === "wixmp.com" || host.endsWith(".wixmp.com");
260707
+ }
260708
+ function isStaticMediaUrl(raw) {
260709
+ if (typeof raw !== "string" || raw.length > 2048) return false;
260710
+ let url;
260711
+ try {
260712
+ url = new URL(raw);
260713
+ } catch {
260714
+ return false;
260715
+ }
260716
+ if (url.protocol !== "https:" || url.hostname.toLowerCase() !== "static.wixstatic.com" || url.port !== "" || url.username || url.password || url.hash) return false;
260717
+ const rawPath = raw.replace(/^https:\/\/[^/?#]*/i, "").split(/[?#]/, 1)[0];
260718
+ return rawPath === url.pathname && url.pathname.startsWith("/media/") && url.pathname.length > "/media/".length && !/[\\]|%2f|%5c|\/\.\.?(\/|$)/i.test(url.pathname);
260719
+ }
260720
+ async function lookupMemberId(memberToken, fetchImpl = fetch) {
260721
+ const res = await makeCall(fetchImpl)(`${MEMBERS_API}/my`, { method: "GET", headers: { Accept: "application/json", Authorization: memberToken } });
260722
+ if (!res) return { ok: false, code: "unreachable" };
260723
+ if (res.status === 401 || res.status === 403) return { ok: false, code: "member_token_refused", status: res.status };
260724
+ const id = (await readJson13(res)).member?.id;
260725
+ if (!res.ok || typeof id !== "string" || !MEMBER_ID.test(id)) return { ok: false, code: "member_lookup_failed", status: res.status };
260726
+ return { ok: true, memberId: id };
260727
+ }
260728
+ async function uploadMemberPhoto(input, fetchImpl = fetch) {
260729
+ const { memberToken, memberId, bytes: bytes2, mimeType } = input;
260730
+ const call = makeCall(fetchImpl);
260731
+ const fail16 = (code3, res) => res === null ? { ok: false, code: "unreachable" } : { ok: false, code: code3, ...res ? { status: res.status } : {} };
260732
+ const fileName = `member-photo.${EXTENSION[mimeType]}`;
260733
+ const mint = await call(MINT_URL, {
260734
+ method: "POST",
260735
+ headers: { ...J2, Authorization: memberToken },
260736
+ body: JSON.stringify({ mimeType, fileName, parentFolderId: MEMBER_PHOTO_FOLDER, sizeInBytes: bytes2.length, isVisitor: false })
260737
+ });
260738
+ if (!mint) return fail16("mint_failed", null);
260739
+ const minted = await readJson13(mint);
260740
+ const { uploadUrl, uploadToken } = minted;
260741
+ if (!mint.ok || typeof uploadUrl !== "string" || !isMediaHost(uploadUrl) || typeof uploadToken !== "string" || !UPLOAD_TOKEN.test(uploadToken)) return fail16("mint_failed", mint);
260742
+ const base2 = uploadUrl.replace(/\/+$/, "");
260743
+ const create = await call(base2, {
260744
+ method: "POST",
260745
+ headers: {
260746
+ "Tus-Resumable": "1.0.0",
260747
+ "Upload-Length": String(bytes2.length),
260748
+ "Content-Type": "application/offset+octet-stream",
260749
+ "Upload-Metadata": `filename ${b642(fileName)},acl ${b642("public")},token ${b642(uploadToken)},parent_folder_id ${b642(MEMBER_PHOTO_FOLDER)}`
260750
+ }
260751
+ });
260752
+ if (!create) return fail16("upload_session_failed", null);
260753
+ const location = create.headers.get("location");
260754
+ if (create.status !== 201 || !location) return fail16("upload_session_failed", create);
260755
+ let session;
260756
+ try {
260757
+ session = new URL(location, base2).toString();
260758
+ } catch {
260759
+ return fail16("upload_session_failed", create);
260760
+ }
260761
+ if (!isMediaHost(session)) return fail16("upload_session_failed", create);
260762
+ const patch = await call(session, {
260763
+ method: "PATCH",
260764
+ headers: { "Tus-Resumable": "1.0.0", "Upload-Offset": "0", "Content-Type": "application/offset+octet-stream" },
260765
+ body: bytes2
260766
+ });
260767
+ if (!patch) return fail16("upload_failed", null);
260768
+ if (patch.status !== 204 || patch.headers.get("upload-offset") !== String(bytes2.length)) return fail16("upload_failed", patch);
260769
+ const query = new URLSearchParams({ filename: fileName, acl: "public", token: uploadToken, parent_folder_id: MEMBER_PHOTO_FOLDER });
260770
+ const finish3 = await call(`${base2}/${uploadToken}?${query}`, { method: "PUT", headers: J2 });
260771
+ if (!finish3) return fail16("finish_failed", null);
260772
+ const file2 = (await readJson13(finish3)).file;
260773
+ if (!finish3.ok) return fail16("finish_failed", finish3);
260774
+ if (!isStaticMediaUrl(file2?.url)) return fail16("bad_file_url", finish3);
260775
+ const url = file2.url;
260776
+ const save = await call(`${MEMBERS_API}/${encodeURIComponent(memberId)}`, {
260777
+ method: "PATCH",
260778
+ headers: { ...J2, Authorization: memberToken },
260779
+ body: JSON.stringify({ member: { id: memberId, profile: { photo: { url } } } })
260780
+ });
260781
+ if (!save) return fail16("save_failed", null);
260782
+ if (!save.ok) return fail16("save_failed", save);
260783
+ return { ok: true, url };
260784
+ }
260785
+ var MEMBER_PHOTO_MAX_BYTES, MEMBER_PHOTO_FOLDER, MINT_URL, MEMBERS_API, STEP_TIMEOUT_MS2, MEMBER_ID, UPLOAD_TOKEN, EXTENSION, J2, b642, makeCall, readJson13;
260786
+ var init_member_photo = __esm({
260787
+ "../../core/serve-runtime/src/member-photo.ts"() {
260788
+ init_define_HHP_CATALOG();
260789
+ MEMBER_PHOTO_MAX_BYTES = 5 * 1024 * 1024;
260790
+ MEMBER_PHOTO_FOLDER = "mobile-uploads";
260791
+ MINT_URL = "https://www.wix.com/_serverless/mobile_pixwix/v1/tus_upload_url";
260792
+ MEMBERS_API = "https://www.wixapis.com/members/v1/members";
260793
+ STEP_TIMEOUT_MS2 = 2e4;
260794
+ MEMBER_ID = /^[^\u0000-\u001f\u007f]{1,128}$/;
260795
+ UPLOAD_TOKEN = /^[A-Za-z0-9._-]{16,4096}$/;
260796
+ EXTENSION = { "image/png": "png", "image/jpeg": "jpg", "image/webp": "webp" };
260797
+ J2 = { "Content-Type": "application/json" };
260798
+ b642 = (s5) => btoa(s5);
260799
+ makeCall = (fetchImpl) => async (url, init) => {
260800
+ try {
260801
+ return await fetchImpl(url, { ...init, redirect: "manual", credentials: "omit", signal: AbortSignal.timeout(STEP_TIMEOUT_MS2) });
260802
+ } catch {
260803
+ return null;
260804
+ }
260805
+ };
260806
+ readJson13 = async (res) => {
260807
+ try {
260808
+ const v2 = await res.json();
260809
+ return v2 && typeof v2 === "object" ? v2 : {};
260810
+ } catch {
260811
+ return {};
260812
+ }
260813
+ };
260814
+ }
260815
+ });
260816
+
260658
260817
  // ../../core/serve-runtime/src/member-forward.ts
260659
260818
  function matchMemberForward(method, raw, rules = MEMBER_FORWARD_ALLOWLIST) {
260660
260819
  if (typeof method !== "string" || typeof raw !== "string" || raw.length === 0 || raw.length > 8192) return null;
@@ -261397,6 +261556,10 @@ function makeServeHandler(opts) {
261397
261556
  const webwixFetch = opts.webwixFetch ?? fetch;
261398
261557
  const webwixOwnerInstances = new OwnerInstanceCache(webwixFetch);
261399
261558
  const visitorMintLimiter = new FixedWindowRateLimiter({ max: opts.visitorMintRatePerMin ?? 30, windowMs: 6e4 });
261559
+ const memberPhotoLimiter = new FixedWindowRateLimiter({ max: opts.memberPhotoRatePerMin ?? 5, windowMs: 6e4 });
261560
+ const memberPhotoCallerLimiter = new FixedWindowRateLimiter({ max: opts.memberPhotoCallerRatePerMin ?? 30, windowMs: 6e4 });
261561
+ const memberPhotoSlots = new QueuedConcurrencyLimiter(opts.memberPhotoMaxInFlight ?? 8, 0);
261562
+ const memberPhotoCallerSlots = new KeyedQueuedConcurrencyLimiter(2, 0);
261400
261563
  const largeAssetReads = new QueuedConcurrencyLimiter(LARGE_ASSET_STORE_READS_PER_POD, LARGE_ASSET_STORE_READS_QUEUED);
261401
261564
  const largeAssetCallerReads = new KeyedQueuedConcurrencyLimiter(LARGE_ASSET_STORE_READS_PER_CALLER, LARGE_ASSET_STORE_READS_QUEUED_PER_CALLER);
261402
261565
  const forwardVisitors = /* @__PURE__ */ new Map();
@@ -261994,6 +262157,43 @@ ${releaseId}`;
261994
262157
  if (!forwarded.ok) return json6(502, { error: forwarded.code }, noStore);
261995
262158
  return json6(200, { status: forwarded.status, body: forwarded.body }, noStore);
261996
262159
  }
262160
+ if (request2.method === "POST" && path2 === "/v1/__webwix/member-photo") {
262161
+ const noStore = { "cache-control": "no-store" };
262162
+ if (opts.webwixBridge === false) return json6(503, { error: "webwix_bridge_disabled" }, noStore);
262163
+ const app3 = resolveApp2(request2, url);
262164
+ if (!app3) return json6(400, { error: "app_required" }, noStore);
262165
+ const cfg = await appConfigFor(request2, url, app3);
262166
+ if (!cfg.ok) return cfg.response;
262167
+ const memberToken = request2.headers.get("x-himalaya-member-token") ?? "";
262168
+ if (!/^[\x21-\x7e]{1,4096}$/.test(memberToken)) return json6(400, { error: "member_token_required" }, noStore);
262169
+ const caller = visitorMintCaller(request2);
262170
+ const callerRate = memberPhotoCallerLimiter.check(caller);
262171
+ if (!callerRate.ok) return json6(429, { error: "member_photo_rate_limited" }, { ...noStore, "retry-after": String(callerRate.retryAfterSec) });
262172
+ const callerSlot = await memberPhotoCallerSlots.acquire(caller, request2.signal);
262173
+ if (!callerSlot) return json6(429, { error: "member_photo_busy" }, { ...noStore, "retry-after": "1" });
262174
+ const podSlot = await memberPhotoSlots.acquire(request2.signal);
262175
+ if (!podSlot) {
262176
+ callerSlot();
262177
+ return json6(503, { error: "member_photo_busy" }, { ...noStore, "retry-after": "1" });
262178
+ }
262179
+ try {
262180
+ const bytes2 = await readBodyCapped(request2);
262181
+ if (!bytes2) return json6(413, { error: "photo_too_large", maxBytes: MEMBER_PHOTO_MAX_BYTES }, noStore);
262182
+ if (bytes2.length === 0) return json6(400, { error: "empty_body" }, noStore);
262183
+ const mimeType = sniffImageMime(bytes2);
262184
+ if (!mimeType) return json6(415, { error: "unsupported_image_type" }, noStore);
262185
+ const member = await lookupMemberId(memberToken, webwixFetch);
262186
+ if (!member.ok) return json6(member.code === "member_token_refused" ? 401 : 502, { error: member.code }, noStore);
262187
+ const rate = memberPhotoLimiter.check(member.memberId);
262188
+ if (!rate.ok) return json6(429, { error: "member_photo_rate_limited" }, { ...noStore, "retry-after": String(rate.retryAfterSec) });
262189
+ const uploaded = await uploadMemberPhoto({ memberToken, memberId: member.memberId, bytes: bytes2, mimeType }, webwixFetch);
262190
+ if (!uploaded.ok) return json6(502, { error: uploaded.code }, noStore);
262191
+ return json6(200, { url: uploaded.url }, noStore);
262192
+ } finally {
262193
+ podSlot();
262194
+ callerSlot();
262195
+ }
262196
+ }
261997
262197
  if (request2.method === "POST" && path2 === "/v1/__webwix/call") {
261998
262198
  const served = { rung: "none" };
261999
262199
  let status2 = 500;
@@ -262697,6 +262897,7 @@ var init_server3 = __esm({
262697
262897
  init_preview_token();
262698
262898
  init_pinned_read();
262699
262899
  init_member_exchange();
262900
+ init_member_photo();
262700
262901
  init_member_forward();
262701
262902
  init_package_share();
262702
262903
  init_rate_limit();
@@ -263629,7 +263830,7 @@ async function releasePayloadFromDir(root, app2, header2) {
263629
263830
  const store = new FileReleaseStore(root);
263630
263831
  const manifest2 = await store.getManifest(app2);
263631
263832
  if (!manifest2) throw new Error(`no release manifest for ${app2} under ${root}`);
263632
- const b642 = (b3) => b3 ? Buffer.from(b3).toString("base64") : void 0;
263833
+ const b643 = (b3) => b3 ? Buffer.from(b3).toString("base64") : void 0;
263633
263834
  const text32 = (b3) => b3 ? new TextDecoder().decode(b3) : void 0;
263634
263835
  const screens = {};
263635
263836
  const docs = {};
@@ -263650,12 +263851,12 @@ async function releasePayloadFromDir(root, app2, header2) {
263650
263851
  await addDoc(manifest2.sourceHash);
263651
263852
  const bundles = {};
263652
263853
  for (const b3 of Object.values(manifest2.bundles ?? {})) {
263653
- const bytes2 = b642(await store.getBundle(app2, b3.sha256));
263854
+ const bytes2 = b643(await store.getBundle(app2, b3.sha256));
263654
263855
  if (bytes2 !== void 0) bundles[b3.sha256] = bytes2;
263655
263856
  }
263656
263857
  const assets = {};
263657
263858
  for (const rec of Object.values(manifest2.assets ?? {})) {
263658
- const bytes2 = b642(await store.getAsset?.(app2, rec.sha256) ?? null);
263859
+ const bytes2 = b643(await store.getAsset?.(app2, rec.sha256) ?? null);
263659
263860
  if (bytes2 !== void 0) assets[rec.sha256] = { base64: bytes2, contentType: rec.contentType };
263660
263861
  }
263661
263862
  const widgets = {};
@@ -263675,7 +263876,7 @@ async function releasePayloadFromDir(root, app2, header2) {
263675
263876
  widgets,
263676
263877
  tokens: text32(await store.getTokens(app2)),
263677
263878
  appConfig,
263678
- icon: b642(await store.getIcon?.(app2) ?? null),
263879
+ icon: b643(await store.getIcon?.(app2) ?? null),
263679
263880
  header: header2,
263680
263881
  ...wixClientId ? { wixClientId } : {}
263681
263882
  };
@@ -266742,7 +266943,7 @@ function assetUploadUrl(operation, size) {
266742
266943
  function backoffMs2(attempt2) {
266743
266944
  return Math.min(BASE_BACKOFF_MS * 2 ** (attempt2 - 1), MAX_RETRY_WAIT_MS);
266744
266945
  }
266745
- async function readJson13(response) {
266946
+ async function readJson14(response) {
266746
266947
  try {
266747
266948
  return await response.json();
266748
266949
  } catch {
@@ -266883,7 +267084,7 @@ var init_iap_client = __esm({
266883
267084
  }
266884
267085
  async send(method, url, body) {
266885
267086
  const response = await this.fetchOrNetworkError(method, url, body);
266886
- const payload = await readJson13(response);
267087
+ const payload = await readJson14(response);
266887
267088
  if (!response.ok) throw this.httpError(method, url, response, payload);
266888
267089
  if (payload === void 0 && response.status !== 204) {
266889
267090
  throw new AscError2("server", `${method} ${url.pathname} \u2192 ${response.status} with an unreadable body`, response.status);
@@ -276407,7 +276608,7 @@ function dropTrailingCommas(text32) {
276407
276608
  }
276408
276609
  return out2;
276409
276610
  }
276410
- function readJson14(files, path2) {
276611
+ function readJson15(files, path2) {
276411
276612
  const text32 = files.get(path2);
276412
276613
  if (text32 === void 0) return void 0;
276413
276614
  try {
@@ -276422,7 +276623,7 @@ function filesIn(files, dir, re2) {
276422
276623
  return [...files.keys()].filter((p2) => p2.startsWith(prefix) && !p2.slice(prefix.length).includes("/") && re2.test(p2)).sort();
276423
276624
  }
276424
276625
  function projectDirs(files) {
276425
- const cfg = readJson14(files, "base44/config.jsonc") ?? readJson14(files, "base44/config.json") ?? {};
276626
+ const cfg = readJson15(files, "base44/config.jsonc") ?? readJson15(files, "base44/config.json") ?? {};
276426
276627
  const dir = (k3, d2) => {
276427
276628
  const v2 = cfg[k3];
276428
276629
  return `base44/${typeof v2 === "string" && v2 && !v2.includes("..") ? v2.replace(/^\.\/|\/+$/g, "") : d2}`;
@@ -276453,7 +276654,7 @@ function fieldsOf(schema2) {
276453
276654
  function readEntities(files, dirs) {
276454
276655
  const out2 = [];
276455
276656
  for (const path2 of [...filesIn(files, dirs.entities, JSON_FILE), ...filesIn(files, "entities", JSON_FILE)]) {
276456
- const schema2 = readJson14(files, path2);
276657
+ const schema2 = readJson15(files, path2);
276457
276658
  if (!schema2) continue;
276458
276659
  const base2 = path2.split("/").pop().replace(JSON_FILE, "");
276459
276660
  const name = typeof schema2.name === "string" && schema2.name ? schema2.name : base2;
@@ -276497,7 +276698,7 @@ function readFunctions(files, dirs) {
276497
276698
  const prefix = `${dirs.functions}/`;
276498
276699
  const under = [...files.keys()].filter((p2) => p2.startsWith(prefix)).sort();
276499
276700
  for (const cfgPath of under.filter((p2) => /\/function\.jsonc?$/i.test(p2))) {
276500
- const cfg = readJson14(files, cfgPath);
276701
+ const cfg = readJson15(files, cfgPath);
276501
276702
  if (!cfg || typeof cfg.name !== "string") continue;
276502
276703
  const folder = cfgPath.slice(0, cfgPath.lastIndexOf("/"));
276503
276704
  const entry = typeof cfg.entry === "string" ? `${folder}/${cfg.entry.replace(/^\.\//, "")}` : void 0;
@@ -276524,12 +276725,12 @@ function agentFromConfig(cfg, source2) {
276524
276725
  return { name: cfg.name, ...typeof cfg.description === "string" ? { description: cfg.description } : {}, tools, source: source2 };
276525
276726
  }
276526
276727
  function readAgents(files, dirs) {
276527
- return filesIn(files, dirs.agents, JSON_FILE).map((p2) => readJson14(files, p2)).map((cfg) => cfg ? agentFromConfig(cfg, "project-files") : void 0).filter((a3) => !!a3);
276728
+ return filesIn(files, dirs.agents, JSON_FILE).map((p2) => readJson15(files, p2)).map((cfg) => cfg ? agentFromConfig(cfg, "project-files") : void 0).filter((a3) => !!a3);
276528
276729
  }
276529
276730
  function readConnectors(files, dirs) {
276530
276731
  const out2 = [];
276531
276732
  for (const p2 of filesIn(files, dirs.connectors, JSON_FILE)) {
276532
- const cfg = readJson14(files, p2);
276733
+ const cfg = readJson15(files, p2);
276533
276734
  if (!cfg || typeof cfg.type !== "string") continue;
276534
276735
  out2.push({ type: cfg.type, scopes: Array.isArray(cfg.scopes) ? cfg.scopes.map(String) : [], source: "project-files" });
276535
276736
  }
@@ -276548,7 +276749,7 @@ function providersOf(cfg) {
276548
276749
  }
276549
276750
  function readAuthConfig(files, dirs) {
276550
276751
  for (const p2 of filesIn(files, dirs.auth, JSON_FILE)) {
276551
- const cfg = readJson14(files, p2);
276752
+ const cfg = readJson15(files, p2);
276552
276753
  if (cfg && Object.keys(cfg).some((k3) => /^enable/.test(k3))) return { providers: providersOf(cfg), source: "project-files" };
276553
276754
  }
276554
276755
  return void 0;
@@ -285090,7 +285291,7 @@ var init_widgets_cli = __esm({
285090
285291
  });
285091
285292
 
285092
285293
  // src/one-app/access-policy.ts
285093
- async function readJson15(fetchImpl, url, headers2) {
285294
+ async function readJson16(fetchImpl, url, headers2) {
285094
285295
  const response = await fetchImpl(url, { method: "GET", headers: headers2, redirect: "error", signal: AbortSignal.timeout(TIMEOUT_MS6) });
285095
285296
  if (!response.ok) throw new Error(`HTTP ${response.status}`);
285096
285297
  const text32 = await response.text();
@@ -285106,10 +285307,10 @@ async function readAccessPolicy(metaSiteId, deps = {}) {
285106
285307
  });
285107
285308
  if (!SITE_ID2.test(metaSiteId)) return unknown("the site id is not a UUID");
285108
285309
  try {
285109
- const session = await readJson15(fetchImpl, `${VISITOR_SESSION2}${metaSiteId}/signed-instance?signed_instance_type=Visitor`, { Accept: "application/json" });
285310
+ const session = await readJson16(fetchImpl, `${VISITOR_SESSION2}${metaSiteId}/signed-instance?signed_instance_type=Visitor`, { Accept: "application/json" });
285110
285311
  const instance = isObject4(session) && session.signedInstanceType === "Visitor" && typeof session.signedInstance === "string" ? session.signedInstance.trim() : "";
285111
285312
  if (!instance || /[\r\n]/.test(instance)) return unknown("no Visitor session");
285112
- const config = await readJson15(fetchImpl, `${GATEWAY}${metaSiteId}/hybrid-app-config`, { Authorization: instance, "wix-site-id": metaSiteId, Accept: "application/json" });
285313
+ const config = await readJson16(fetchImpl, `${GATEWAY}${metaSiteId}/hybrid-app-config`, { Authorization: instance, "wix-site-id": metaSiteId, Accept: "application/json" });
285113
285314
  const value2 = isObject4(config) ? config.visitorModeEnabled : void 0;
285114
285315
  if (typeof value2 !== "boolean") return unknown("the gateway did not report it");
285115
285316
  return { policy: { schemaVersion: 1, visitorModeEnabled: value2, source: "mobile-hybrid-gateway:hybrid-app-config", fetchedAt } };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/himalaya-cli",
3
- "version": "0.1883.0",
3
+ "version": "0.1885.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": "fcfc88f9ba55f05e1aed17c7ea6c788e6de57e7721b2f2b439d7c3cd"
85
+ "falconPackageHash": "db6d78dbfb0d75be08bec93fe553f30af6c1886f6e8002abd911be9f"
86
86
  }