@wix/himalaya-cli 0.811.0 → 0.813.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 +21 -3
  2. package/package.json +2 -2
package/dist/cli.mjs CHANGED
@@ -7890,6 +7890,25 @@ async function mintVisitor(clientId) {
7890
7890
  if (r.status !== 200 || !r.json.access_token) throw new Error(`visitor mint failed (${r.status})`);
7891
7891
  return r.json.access_token;
7892
7892
  }
7893
+ function isRedirectCallback(url, redirectUri) {
7894
+ if (url.startsWith(redirectUri)) return true;
7895
+ const path = (u) => u.pathname.replace(/\/+$/, "") || "/";
7896
+ try {
7897
+ const got = new URL(url);
7898
+ const want = new URL(redirectUri);
7899
+ return got.protocol === want.protocol && got.host === want.host && path(got) === path(want);
7900
+ } catch {
7901
+ return false;
7902
+ }
7903
+ }
7904
+ function authCodeFrom(url) {
7905
+ try {
7906
+ const u = new URL(url);
7907
+ return new URLSearchParams(u.hash.slice(1)).get("code") ?? u.searchParams.get("code") ?? void 0;
7908
+ } catch {
7909
+ return void 0;
7910
+ }
7911
+ }
7893
7912
  async function exchangeSessionToken(clientId, redirectUri, visitorToken, sessionToken) {
7894
7913
  const verifier = b64url(randomBytes4(32));
7895
7914
  const challenge = b64url(createHash9("sha256").update(verifier).digest());
@@ -7915,9 +7934,8 @@ async function exchangeSessionToken(clientId, redirectUri, visitorToken, session
7915
7934
  let url = fullUrl;
7916
7935
  let code;
7917
7936
  for (let hop = 0; hop < 8 && url; hop++) {
7918
- if (url.startsWith(redirectUri.split("://")[0] + "://")) {
7919
- const frag = new URL(url.replace("#", "?")).searchParams;
7920
- code = frag.get("code") ?? void 0;
7937
+ if (isRedirectCallback(url, redirectUri)) {
7938
+ code = authCodeFrom(url);
7921
7939
  break;
7922
7940
  }
7923
7941
  const res = await fetch(url, { redirect: "manual", headers: { "User-Agent": "Mozilla/5.0" } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/himalaya-cli",
3
- "version": "0.811.0",
3
+ "version": "0.813.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": [
@@ -63,5 +63,5 @@
63
63
  "artifactId": "himalaya-cli"
64
64
  }
65
65
  },
66
- "falconPackageHash": "9898157ace92c5158f9a90e9131d208af5056b4251605dd477d9d65a"
66
+ "falconPackageHash": "da45e40ee81ea04e359c160e78f384cdb9e89688d8059747162fc2b6"
67
67
  }