@wix/himalaya-cli 0.1008.0 → 0.1009.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 +61 -22
- package/package.json +2 -2
package/dist/cli.mjs
CHANGED
|
@@ -16874,7 +16874,7 @@ function wixClientIdOf(appConfigJson) {
|
|
|
16874
16874
|
if (typeof clientId !== "string" || !clientId) return { error: "no_client_id" };
|
|
16875
16875
|
return { clientId };
|
|
16876
16876
|
}
|
|
16877
|
-
var WIX_API, ONE_APP_SESSION, OWNER_SCOPED_WIX_HOST, VisitorTokenCache, OWNER_REFRESH_MARGIN_MS, OwnerInstanceCache, OWNER_SITES_QUERY_PATH, OWNER_SITES_COUNT_PATH, OwnerSitesCache;
|
|
16877
|
+
var WIX_API, ONE_APP_SESSION, OWNER_SCOPED_WIX_HOST, VisitorTokenCache, OWNER_REFRESH_MARGIN_MS, OWNER_RENEW_MIN_AGE_MS, OWNER_MINT_TIMEOUT_MS, OwnerInstanceCache, OWNER_SITES_QUERY_PATH, OWNER_SITES_COUNT_PATH, OwnerSitesCache;
|
|
16878
16878
|
var init_wix_bridge = __esm({
|
|
16879
16879
|
"../../core/serve-runtime/src/wix-bridge.ts"() {
|
|
16880
16880
|
init_sha256();
|
|
@@ -16912,12 +16912,19 @@ var init_wix_bridge = __esm({
|
|
|
16912
16912
|
}
|
|
16913
16913
|
};
|
|
16914
16914
|
OWNER_REFRESH_MARGIN_MS = 6e4;
|
|
16915
|
+
OWNER_RENEW_MIN_AGE_MS = 5e3;
|
|
16916
|
+
OWNER_MINT_TIMEOUT_MS = 8e3;
|
|
16915
16917
|
OwnerInstanceCache = class {
|
|
16916
|
-
constructor(fetchImpl = fetch, ttlMs = 5 * 6e4) {
|
|
16918
|
+
constructor(fetchImpl = fetch, ttlMs = 5 * 6e4, mintTimeoutMs = OWNER_MINT_TIMEOUT_MS, elapsedClock = () => performance.now()) {
|
|
16917
16919
|
this.fetchImpl = fetchImpl;
|
|
16918
16920
|
this.ttlMs = ttlMs;
|
|
16921
|
+
this.mintTimeoutMs = mintTimeoutMs;
|
|
16922
|
+
this.elapsedClock = elapsedClock;
|
|
16919
16923
|
}
|
|
16920
16924
|
cache = /* @__PURE__ */ new Map();
|
|
16925
|
+
/** The one mint on its way per (business, session). Every caller, plain or renewing, joins it:
|
|
16926
|
+
* it started after whatever is cached was minted, so it is the fresh instance. */
|
|
16927
|
+
inflight = /* @__PURE__ */ new Map();
|
|
16921
16928
|
/** Keyed on the SESSION (`wixSession2`), not the whole cookie header: manage.wix.com's jar churns
|
|
16922
16929
|
* (analytics, experiments), and keying on all of it re-minted on nearly every call (#3044). A
|
|
16923
16930
|
* header with no session cookie falls back to itself — callers refuse that case before here. */
|
|
@@ -16929,28 +16936,62 @@ ${session}`);
|
|
|
16929
16936
|
async instance(msid, cookieHeader, now = Date.now()) {
|
|
16930
16937
|
return (await this.entry(msid, cookieHeader, now)).instance;
|
|
16931
16938
|
}
|
|
16932
|
-
/** The instance and the time this cache stops trusting it (#3044: the web host caches until then).
|
|
16933
|
-
|
|
16939
|
+
/** The instance and the time this cache stops trusting it (#3044: the web host caches until then).
|
|
16940
|
+
* `renew`: Wix refused the instance this cache handed out (the route's `renew=1`, #3140) — mint a
|
|
16941
|
+
* new one, unless the cached one is younger than OWNER_RENEW_MIN_AGE_MS or a mint is already on
|
|
16942
|
+
* its way, in which case that IS the new one. */
|
|
16943
|
+
async entry(msid, cookieHeader, now = Date.now(), opts = {}) {
|
|
16934
16944
|
const key2 = this.key(msid, cookieHeader);
|
|
16935
|
-
const
|
|
16945
|
+
const pending = this.inflight.get(key2);
|
|
16946
|
+
if (pending) return { ...await pending };
|
|
16947
|
+
let hit = this.cache.get(key2);
|
|
16948
|
+
if (opts.renew && hit && now - hit.mintedAt >= OWNER_RENEW_MIN_AGE_MS) hit = void 0;
|
|
16936
16949
|
if (hit && hit.expiresAt - OWNER_REFRESH_MARGIN_MS > now) return { instance: hit.instance, expiresAt: hit.expiresAt };
|
|
16937
|
-
const
|
|
16938
|
-
|
|
16939
|
-
|
|
16950
|
+
const mint = this.mint(key2, msid, cookieHeader, now).finally(() => this.inflight.delete(key2));
|
|
16951
|
+
this.inflight.set(key2, mint);
|
|
16952
|
+
return { ...await mint };
|
|
16953
|
+
}
|
|
16954
|
+
async mint(key2, msid, cookieHeader, now) {
|
|
16955
|
+
const startedAt = this.elapsedClock();
|
|
16956
|
+
const abort = new AbortController();
|
|
16957
|
+
let timer;
|
|
16958
|
+
const timedOut = new Promise((_, reject) => {
|
|
16959
|
+
timer = setTimeout(() => {
|
|
16960
|
+
abort.abort();
|
|
16961
|
+
reject(new Error(`owner mint timed out after ${this.mintTimeoutMs}ms`));
|
|
16962
|
+
}, this.mintTimeoutMs);
|
|
16940
16963
|
});
|
|
16941
|
-
const text4 = await res.text();
|
|
16942
|
-
let j = {};
|
|
16943
16964
|
try {
|
|
16944
|
-
|
|
16945
|
-
|
|
16965
|
+
const res = await Promise.race([
|
|
16966
|
+
this.fetchImpl(`${ONE_APP_SESSION}/${msid}/signed-instance?signed_instance_type=User`, {
|
|
16967
|
+
method: "GET",
|
|
16968
|
+
headers: { Cookie: cookieHeader },
|
|
16969
|
+
signal: abort.signal
|
|
16970
|
+
}),
|
|
16971
|
+
timedOut
|
|
16972
|
+
]);
|
|
16973
|
+
const text4 = await Promise.race([res.text(), timedOut]);
|
|
16974
|
+
let j = {};
|
|
16975
|
+
try {
|
|
16976
|
+
j = text4 ? JSON.parse(text4) : {};
|
|
16977
|
+
} catch {
|
|
16978
|
+
}
|
|
16979
|
+
if (res.status < 200 || res.status >= 300 || !j.signedInstance)
|
|
16980
|
+
throw new Error(`owner mint failed (${res.status})`);
|
|
16981
|
+
const elapsed = Math.max(0, this.elapsedClock() - startedAt);
|
|
16982
|
+
const mintedAt = now + elapsed;
|
|
16983
|
+
const entry = { instance: j.signedInstance, expiresAt: now + Math.floor(elapsed / 1e3) * 1e3 + this.ttlMs };
|
|
16984
|
+
this.cache.set(key2, { ...entry, mintedAt });
|
|
16985
|
+
return entry;
|
|
16986
|
+
} catch (e) {
|
|
16987
|
+
this.cache.delete(key2);
|
|
16988
|
+
throw e;
|
|
16989
|
+
} finally {
|
|
16990
|
+
clearTimeout(timer);
|
|
16946
16991
|
}
|
|
16947
|
-
if (res.status < 200 || res.status >= 300 || !j.signedInstance)
|
|
16948
|
-
throw new Error(`owner mint failed (${res.status})`);
|
|
16949
|
-
const entry = { instance: j.signedInstance, expiresAt: now + this.ttlMs };
|
|
16950
|
-
this.cache.set(key2, entry);
|
|
16951
|
-
return { ...entry };
|
|
16952
16992
|
}
|
|
16953
|
-
/** Drop a cached instance
|
|
16993
|
+
/** Drop a cached instance so the next call re-mints. The envelope owner branch's own 401 retry;
|
|
16994
|
+
* the route's `renew=1` goes through `entry(…, { renew: true })` instead. */
|
|
16954
16995
|
invalidate(msid, cookieHeader) {
|
|
16955
16996
|
this.cache.delete(this.key(msid, cookieHeader));
|
|
16956
16997
|
}
|
|
@@ -19468,7 +19509,6 @@ function shouldRevealError(args) {
|
|
|
19468
19509
|
var EMAIL_RE, URL_HOST_RE, INTEGER_RE, NUMBER_RE;
|
|
19469
19510
|
var init_validation = __esm({
|
|
19470
19511
|
"../../core/ts/src/validation.ts"() {
|
|
19471
|
-
"use strict";
|
|
19472
19512
|
EMAIL_RE = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}$/;
|
|
19473
19513
|
URL_HOST_RE = /^[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*(:[0-9]+)?$/;
|
|
19474
19514
|
INTEGER_RE = /^[+-]?[0-9]+$/;
|
|
@@ -22893,7 +22933,6 @@ function validateWorkerSubtree(raw, slotId, policy, actionCatalog) {
|
|
|
22893
22933
|
var WORKER_SUBTREE_CEILINGS, ID_PART, ACTION_ID;
|
|
22894
22934
|
var init_worker_subtree = __esm({
|
|
22895
22935
|
"../../core/ts/src/worker-subtree.ts"() {
|
|
22896
|
-
"use strict";
|
|
22897
22936
|
init_worker_subtree_safe_types_generated();
|
|
22898
22937
|
WORKER_SUBTREE_CEILINGS = Object.freeze({
|
|
22899
22938
|
maxEncodedBytes: 65536,
|
|
@@ -45863,9 +45902,9 @@ ${releaseId}`;
|
|
|
45863
45902
|
if (!isSafeMsid(msid)) return json3(400, { error: "webwix_owner_bad_msid" });
|
|
45864
45903
|
const cookie = request.headers.get("cookie") ?? "";
|
|
45865
45904
|
if (!/wixSession2=/.test(cookie)) return json3(401, { error: "webwix_owner_no_session" });
|
|
45866
|
-
|
|
45905
|
+
const renew = url.searchParams.get("renew") === "1";
|
|
45867
45906
|
try {
|
|
45868
|
-
const entry = await webwixOwnerInstances.entry(msid, cookie);
|
|
45907
|
+
const entry = await webwixOwnerInstances.entry(msid, cookie, Date.now(), { renew });
|
|
45869
45908
|
return json3(200, { ...entry, expiresInMs: Math.max(0, entry.expiresAt - Date.now()) }, { "cache-control": "no-store" });
|
|
45870
45909
|
} catch (e) {
|
|
45871
45910
|
const msg = String(e?.message ?? e);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/himalaya-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1009.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": [
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"artifactId": "himalaya-cli"
|
|
66
66
|
}
|
|
67
67
|
},
|
|
68
|
-
"falconPackageHash": "
|
|
68
|
+
"falconPackageHash": "91d6d29413a928844d1207a733cba17640e15e3263898ac967ba4b95"
|
|
69
69
|
}
|