@wix/himalaya-cli 0.1012.0 → 0.1014.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 +41 -22
- package/package.json +2 -2
package/dist/cli.mjs
CHANGED
|
@@ -45887,6 +45887,29 @@ var init_assets = __esm({
|
|
|
45887
45887
|
}
|
|
45888
45888
|
});
|
|
45889
45889
|
|
|
45890
|
+
// ../../core/serve-runtime/src/pinned-read.ts
|
|
45891
|
+
async function checkPinnedRead(input) {
|
|
45892
|
+
const { secret, token, app, releaseId, screenId, authorizePreview } = input;
|
|
45893
|
+
if (!secret) return authorizePreview ? { status: 503, body: { error: "preview_token_unavailable" } } : null;
|
|
45894
|
+
if (!token) return await input.isLive() ? null : { status: 401, body: { error: "preview_token_required", app, releaseId } };
|
|
45895
|
+
const verified = await verifyPreviewToken({ token, secret, app, releaseId, screenId });
|
|
45896
|
+
if (verified.ok) {
|
|
45897
|
+
if (authorizePreview ? !await authorizePreview(verified.claims) : !!verified.claims.siteLease) {
|
|
45898
|
+
return { status: 403, body: { error: "site_preview_forbidden" } };
|
|
45899
|
+
}
|
|
45900
|
+
return null;
|
|
45901
|
+
}
|
|
45902
|
+
return {
|
|
45903
|
+
status: verified.error === "scope_mismatch" ? 403 : 401,
|
|
45904
|
+
body: { error: `preview_token_${verified.error}`, app, releaseId, ...screenId ? { screenId } : {} }
|
|
45905
|
+
};
|
|
45906
|
+
}
|
|
45907
|
+
var init_pinned_read = __esm({
|
|
45908
|
+
"../../core/serve-runtime/src/pinned-read.ts"() {
|
|
45909
|
+
init_preview_token();
|
|
45910
|
+
}
|
|
45911
|
+
});
|
|
45912
|
+
|
|
45890
45913
|
// ../../core/serve-runtime/package-share.ts
|
|
45891
45914
|
function parseStored(bytes2, id) {
|
|
45892
45915
|
if (!bytes2) return null;
|
|
@@ -46193,10 +46216,13 @@ ${releaseId}`;
|
|
|
46193
46216
|
}
|
|
46194
46217
|
);
|
|
46195
46218
|
}
|
|
46196
|
-
async function appConfigFor(
|
|
46219
|
+
async function appConfigFor(request, url, app) {
|
|
46197
46220
|
const store = await getStore();
|
|
46221
|
+
const pin = resolvePin(request, url);
|
|
46198
46222
|
let bytes2 = null;
|
|
46199
46223
|
if (pin) {
|
|
46224
|
+
const denied = await authorizePinnedRead(request, url, app, pin);
|
|
46225
|
+
if (denied) return { ok: false, response: denied };
|
|
46200
46226
|
const m = await pinnedManifest(app, pin);
|
|
46201
46227
|
if (!m) return { ok: false, response: json3(404, { error: "release_not_found", app, releaseId: pin }) };
|
|
46202
46228
|
bytes2 = m.appConfigHash ? await pinnedBody(app, m.appConfigHash, () => store.getAppConfig(app)) : null;
|
|
@@ -46219,23 +46245,16 @@ ${releaseId}`;
|
|
|
46219
46245
|
return new Response(body, { status: 200, headers: { "content-type": JSON_CT, etag, "cache-control": cache, ...vary } });
|
|
46220
46246
|
}
|
|
46221
46247
|
async function authorizePinnedRead(request, url, app, releaseId, screenId) {
|
|
46222
|
-
const
|
|
46223
|
-
|
|
46224
|
-
|
|
46225
|
-
const live2 = await manifest(app);
|
|
46226
|
-
const isLive = live2?.releaseId === releaseId;
|
|
46227
|
-
if (!token) return isLive ? null : json3(401, { error: "preview_token_required", app, releaseId });
|
|
46228
|
-
const verified = await verifyPreviewToken({ token, secret, app, releaseId, screenId });
|
|
46229
|
-
if (verified.ok) {
|
|
46230
|
-
if (opts.authorizePreview ? !await opts.authorizePreview(verified.claims) : !!verified.claims.siteLease) return json3(403, { error: "site_preview_forbidden" });
|
|
46231
|
-
return null;
|
|
46232
|
-
}
|
|
46233
|
-
return json3(verified.error === "scope_mismatch" ? 403 : 401, {
|
|
46234
|
-
error: `preview_token_${verified.error}`,
|
|
46248
|
+
const denied = await checkPinnedRead({
|
|
46249
|
+
secret: opts.previewTokenSecret,
|
|
46250
|
+
token: resolvePreviewToken(request, url),
|
|
46235
46251
|
app,
|
|
46236
46252
|
releaseId,
|
|
46237
|
-
|
|
46253
|
+
screenId,
|
|
46254
|
+
isLive: async () => (await manifest(app))?.releaseId === releaseId,
|
|
46255
|
+
authorizePreview: opts.authorizePreview
|
|
46238
46256
|
});
|
|
46257
|
+
return denied && json3(denied.status, denied.body);
|
|
46239
46258
|
}
|
|
46240
46259
|
const corsHeaders = (request) => {
|
|
46241
46260
|
const origin = request.headers.get("origin");
|
|
@@ -46350,7 +46369,7 @@ ${releaseId}`;
|
|
|
46350
46369
|
});
|
|
46351
46370
|
}
|
|
46352
46371
|
if (request.method !== "GET") return json3(405, { error: "method_not_allowed" });
|
|
46353
|
-
const cfg = await appConfigFor(
|
|
46372
|
+
const cfg = await appConfigFor(request, url, app2);
|
|
46354
46373
|
if (!cfg.ok) return cfg.response;
|
|
46355
46374
|
const resolved2 = wixMemberAuthOf(utf8Decode(cfg.bytes), callbackUrlFor(url));
|
|
46356
46375
|
if (!resolved2.ok) return json3(501, { error: `member_auth_${resolved2.error}`, app: app2 });
|
|
@@ -46408,7 +46427,7 @@ ${releaseId}`;
|
|
|
46408
46427
|
}
|
|
46409
46428
|
const app2 = resolveApp(request, url);
|
|
46410
46429
|
if (!app2) return json3(400, { error: "app_required" });
|
|
46411
|
-
const resolvedCfg = await appConfigFor(
|
|
46430
|
+
const resolvedCfg = await appConfigFor(request, url, app2);
|
|
46412
46431
|
if (!resolvedCfg.ok) return resolvedCfg.response;
|
|
46413
46432
|
const cfgBytes = resolvedCfg.bytes;
|
|
46414
46433
|
let call;
|
|
@@ -46666,6 +46685,10 @@ ${releaseId}`;
|
|
|
46666
46685
|
const cfgMatch = /^\/v1\/app-config\/([^/]+)$/.exec(path2);
|
|
46667
46686
|
const app = cfgMatch?.[1] ?? resolveApp(request, url);
|
|
46668
46687
|
const pin = resolvePin(request, url);
|
|
46688
|
+
if (app && pin) {
|
|
46689
|
+
const denied = await authorizePinnedRead(request, url, app, pin);
|
|
46690
|
+
if (denied) return denied;
|
|
46691
|
+
}
|
|
46669
46692
|
if (path2 === "/v1/template-source") {
|
|
46670
46693
|
if (!app) return json3(400, { error: "missing_app" });
|
|
46671
46694
|
if (!store.getSource) return json3(501, { error: "templates_unsupported" });
|
|
@@ -46682,10 +46705,6 @@ ${releaseId}`;
|
|
|
46682
46705
|
headers: { "content-type": JSON_CT, etag, "cache-control": DOC_CACHE_CONTROL, "x-himalaya-app": app }
|
|
46683
46706
|
});
|
|
46684
46707
|
}
|
|
46685
|
-
if (app && pin) {
|
|
46686
|
-
const denied = await authorizePinnedRead(request, url, app, pin);
|
|
46687
|
-
if (denied) return denied;
|
|
46688
|
-
}
|
|
46689
46708
|
if (path2 === "/v1/authoring-docs" || /^\/v1\/authoring-docs\/(spec|mobile-ux)$/.test(path2)) {
|
|
46690
46709
|
if (!app) return json3(400, { error: "missing_app" });
|
|
46691
46710
|
const m = pin ? await pinnedManifest(app, pin) : await manifest(app);
|
|
@@ -47005,7 +47024,7 @@ var init_server = __esm({
|
|
|
47005
47024
|
init_store();
|
|
47006
47025
|
init_base64();
|
|
47007
47026
|
init_contract();
|
|
47008
|
-
|
|
47027
|
+
init_pinned_read();
|
|
47009
47028
|
init_package_share();
|
|
47010
47029
|
init_wix_bridge();
|
|
47011
47030
|
init_wix_member_auth();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/himalaya-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1014.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": "18405dc60f540308524da075bbb12c054da8e06b44e0fcdabaf2e2b0"
|
|
69
69
|
}
|