@wix/himalaya-cli 0.1081.0 → 0.1083.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.
Files changed (2) hide show
  1. package/dist/cli.mjs +19 -5
  2. package/package.json +2 -2
package/dist/cli.mjs CHANGED
@@ -50205,7 +50205,12 @@ async function signature(body, secret) {
50205
50205
  function isClaims(value) {
50206
50206
  if (!value || typeof value !== "object") return false;
50207
50207
  const c = value;
50208
- return c.v === PREVIEW_TOKEN_VERSION && typeof c.sub === "string" && !!c.sub && typeof c.app === "string" && !!c.app && typeof c.releaseId === "string" && !!c.releaseId && (c.screenId === void 0 || typeof c.screenId === "string") && typeof c.source === "string" && typeof c.iat === "number" && Number.isInteger(c.iat) && typeof c.exp === "number" && Number.isInteger(c.exp);
50208
+ return c.v === PREVIEW_TOKEN_VERSION && typeof c.sub === "string" && !!c.sub && typeof c.app === "string" && !!c.app && typeof c.releaseId === "string" && !!c.releaseId && (c.screenId === void 0 || typeof c.screenId === "string") && typeof c.source === "string" && typeof c.iat === "number" && Number.isInteger(c.iat) && typeof c.exp === "number" && Number.isInteger(c.exp) && // A follow token carries BOTH claims or neither. Half of one is malformed — never a plain
50209
+ // preview token, which is what dropping the unrecognised half would turn it into.
50210
+ (c.grant === void 0 && c.gen === void 0 || isFollowClaimPair(c.grant, c.gen));
50211
+ }
50212
+ function isFollowClaimPair(grant, gen) {
50213
+ return typeof grant === "string" && FOLLOW_GRANT_ID_RE.test(grant) && typeof gen === "number" && Number.isInteger(gen) && gen >= 1;
50209
50214
  }
50210
50215
  async function verifyPreviewToken(input) {
50211
50216
  const [body, sig, extra] = input.token.split(".");
@@ -50225,7 +50230,7 @@ async function verifyPreviewToken(input) {
50225
50230
  }
50226
50231
  return { ok: true, claims };
50227
50232
  }
50228
- var SUBTLE_ALGO, PREVIEW_TOKEN_VERSION, DEFAULT_PREVIEW_TOKEN_TTL_SECONDS, WEB_PREVIEW_TOKEN_TTL_SECONDS;
50233
+ var SUBTLE_ALGO, PREVIEW_TOKEN_VERSION, DEFAULT_PREVIEW_TOKEN_TTL_SECONDS, WEB_PREVIEW_TOKEN_TTL_SECONDS, FOLLOW_GRANT_ID_RE;
50229
50234
  var init_preview_token = __esm({
50230
50235
  "../../core/serve-runtime/src/preview-token.ts"() {
50231
50236
  init_site_lease();
@@ -50234,6 +50239,7 @@ var init_preview_token = __esm({
50234
50239
  PREVIEW_TOKEN_VERSION = 1;
50235
50240
  DEFAULT_PREVIEW_TOKEN_TTL_SECONDS = 5 * 60;
50236
50241
  WEB_PREVIEW_TOKEN_TTL_SECONDS = 45 * 60;
50242
+ FOLLOW_GRANT_ID_RE = /^[A-Za-z0-9_-]{22}$/;
50237
50243
  }
50238
50244
  });
50239
50245
 
@@ -53664,14 +53670,21 @@ var init_assets = __esm({
53664
53670
 
53665
53671
  // ../../core/serve-runtime/src/pinned-read.ts
53666
53672
  async function checkPinnedRead(input) {
53667
- const { secret, token, app, releaseId, screenId, authorizePreview } = input;
53673
+ const { secret, token, app, releaseId, screenId, authorizePreview, authorizeFollow } = input;
53668
53674
  if (!secret) return authorizePreview ? { status: 503, body: { error: "preview_token_unavailable" } } : null;
53669
53675
  if (!token) return await input.isPublic() ? null : { status: 401, body: { error: "preview_token_required", app, releaseId } };
53670
- const verified = await verifyPreviewToken({ token, secret, app, releaseId, screenId });
53676
+ const verified = await verifyPreviewToken({ token, secret, app, releaseId, screenId, nowSeconds: input.nowSeconds });
53671
53677
  if (verified.ok) {
53672
53678
  if (authorizePreview ? !await authorizePreview(verified.claims) : !!verified.claims.siteLease) {
53673
53679
  return { status: 403, body: { error: "site_preview_forbidden" } };
53674
53680
  }
53681
+ if (verified.claims.grant !== void 0) {
53682
+ if (!authorizeFollow) return { status: 503, body: { error: "follow_token_unverifiable", app, releaseId } };
53683
+ const decision = await authorizeFollow(verified.claims);
53684
+ if (!decision.ok) {
53685
+ return { status: decision.status, body: { error: decision.error, ...decision.reason ? { reason: decision.reason } : {}, app, releaseId } };
53686
+ }
53687
+ }
53675
53688
  return null;
53676
53689
  }
53677
53690
  return {
@@ -54056,7 +54069,8 @@ ${releaseId}`;
54056
54069
  releaseId,
54057
54070
  screenId,
54058
54071
  isPublic: async () => (await manifest(app))?.releaseId === releaseId || await isRingRelease(app, releaseId),
54059
- authorizePreview: opts.authorizePreview
54072
+ authorizePreview: opts.authorizePreview,
54073
+ authorizeFollow: opts.authorizeFollow
54060
54074
  });
54061
54075
  return denied && json4(denied.status, denied.body);
54062
54076
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/himalaya-cli",
3
- "version": "0.1081.0",
3
+ "version": "0.1083.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": [
@@ -67,5 +67,5 @@
67
67
  "artifactId": "himalaya-cli"
68
68
  }
69
69
  },
70
- "falconPackageHash": "fabad058e08298bebcb3bacb89f82255ed6b92c6ee395d7b444c7fd3"
70
+ "falconPackageHash": "b9cfb5bf9ce91e18a8e397fefd9657af6a1089dbcd95913b0cd47a28"
71
71
  }