@saasquatch/squatch-js 2.8.0-6 → 2.8.1-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/squatch.js CHANGED
@@ -1117,7 +1117,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1117
1117
  async load() {
1118
1118
  var _a2, _b, _c, _d, _e;
1119
1119
  const brandingConfig = (_b = (_a2 = this.context.widgetConfig) == null ? void 0 : _a2.values) == null ? void 0 : _b.brandingConfig;
1120
- console.log({ brandingConfig });
1121
1120
  const sizes = (_c = brandingConfig == null ? void 0 : brandingConfig.widgetSize) == null ? void 0 : _c.embeddedWidgets;
1122
1121
  const maxWidth = (sizes == null ? void 0 : sizes.maxWidth) ? formatWidth(sizes.maxWidth) : "";
1123
1122
  const minWidth = (sizes == null ? void 0 : sizes.minWidth) ? formatWidth(sizes.minWidth) : "";
@@ -1792,7 +1791,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1792
1791
  }
1793
1792
  }
1794
1793
  const _log$3 = browserExports.debug("squatch-js");
1795
- function _getAutoConfig(configIn) {
1794
+ function _getAutoConfig() {
1795
+ var _a2;
1796
1796
  const queryString = window.location.search;
1797
1797
  const urlParams = new URLSearchParams(queryString);
1798
1798
  const refParam = urlParams.get("_saasquatchExtra") || "";
@@ -1800,6 +1800,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1800
1800
  _log$3("No _saasquatchExtra param");
1801
1801
  return;
1802
1802
  }
1803
+ const config = validateConfig();
1804
+ if (!config.domain || !config.tenantAlias) {
1805
+ _log$3(
1806
+ "domain and tenantAlias must be provided in config to use _saasquatchExtra"
1807
+ );
1808
+ return;
1809
+ }
1803
1810
  let raw;
1804
1811
  try {
1805
1812
  raw = JSON.parse(b64decode(refParam));
@@ -1807,8 +1814,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1807
1814
  _log$3("Unable to decode _saasquatchExtra config");
1808
1815
  return;
1809
1816
  }
1810
- const { domain, tenantAlias, widgetConfig } = convertExtraToConfig(raw);
1811
- if (!domain || !tenantAlias || !widgetConfig) {
1817
+ function normalizeDomain(domain) {
1818
+ return domain.replace(/^https?:\/\//, "");
1819
+ }
1820
+ const normalizedDomain = normalizeDomain(config.domain);
1821
+ const widgetConfig = (_a2 = raw == null ? void 0 : raw[normalizedDomain]) == null ? void 0 : _a2[config.tenantAlias];
1822
+ if (!widgetConfig) {
1812
1823
  _log$3("_saasquatchExtra did not have an expected structure");
1813
1824
  return void 0;
1814
1825
  }
@@ -1820,20 +1831,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1820
1831
  ...rest
1821
1832
  },
1822
1833
  squatchConfig: {
1823
- ...configIn ? { configIn } : {},
1824
- domain,
1825
- tenantAlias
1834
+ ...config,
1835
+ domain: config.domain,
1836
+ tenantAlias: config.tenantAlias
1826
1837
  }
1827
1838
  };
1828
1839
  }
1829
- function convertExtraToConfig(obj) {
1830
- var _a2;
1831
- const _domain = Object.keys(obj || {})[0];
1832
- const tenantAlias = Object.keys((obj == null ? void 0 : obj[_domain]) || {})[0];
1833
- const widgetConfig = (_a2 = obj == null ? void 0 : obj[_domain]) == null ? void 0 : _a2[tenantAlias];
1834
- const domain = _domain ? `https://${_domain}` : void 0;
1835
- return { domain, tenantAlias, widgetConfig };
1836
- }
1837
1840
  const _log$2 = browserExports.debug("squatch-js:decodeUserJwt");
1838
1841
  function decodeUserJwt(tokenStr) {
1839
1842
  var _a2;
@@ -2146,9 +2149,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2146
2149
  var _a2;
2147
2150
  return (_a2 = widgets()) == null ? void 0 : _a2.render(widgetConfig);
2148
2151
  }
2149
- function _auto(configIn) {
2152
+ function _auto() {
2150
2153
  var _a2;
2151
- const configs = _getAutoConfig(configIn);
2154
+ const configs = _getAutoConfig();
2152
2155
  if (configs) {
2153
2156
  const { squatchConfig, widgetConfig } = configs;
2154
2157
  init(squatchConfig);