@wix/himalaya-cli 0.812.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 -5
  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" } });
@@ -11459,7 +11477,6 @@ function shouldRevealError(args) {
11459
11477
  var EMAIL_RE, URL_HOST_RE, INTEGER_RE, NUMBER_RE;
11460
11478
  var init_validation = __esm({
11461
11479
  "../../core/ts/src/validation.ts"() {
11462
- "use strict";
11463
11480
  EMAIL_RE = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}$/;
11464
11481
  URL_HOST_RE = /^[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*(:[0-9]+)?$/;
11465
11482
  INTEGER_RE = /^[+-]?[0-9]+$/;
@@ -14805,7 +14822,6 @@ function validateWorkerSubtree(raw, slotId, policy, actionCatalog) {
14805
14822
  var WORKER_SUBTREE_CEILINGS, ID_PART, ACTION_ID;
14806
14823
  var init_worker_subtree = __esm({
14807
14824
  "../../core/ts/src/worker-subtree.ts"() {
14808
- "use strict";
14809
14825
  init_worker_subtree_safe_types_generated();
14810
14826
  WORKER_SUBTREE_CEILINGS = Object.freeze({
14811
14827
  maxEncodedBytes: 65536,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/himalaya-cli",
3
- "version": "0.812.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": "65ec344515508714eab1eee898f49b670f2ad738a0690a7a4dde7ed1"
66
+ "falconPackageHash": "da45e40ee81ea04e359c160e78f384cdb9e89688d8059747162fc2b6"
67
67
  }