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