@saasquatch/squatch-js 2.6.2-0 → 2.6.3-1

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/CHANGELOG.md CHANGED
@@ -7,8 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.6.2] - 2024-02-06
11
+
12
+ ### Added
13
+ - `sq:user-registration` event listener for Instant Access widgets to fire a Load Analytics API event on successful user registration within the widget.
14
+
10
15
  ## [2.6.1] - 2023-09-01
11
16
 
17
+ ### Fixed
18
+
12
19
  - Fix customElementRegistry error that occurs when multiple instances of squatchjs are loaded on the same page.
13
20
 
14
21
  ## [2.6.0] - 2023-08-23
@@ -832,7 +832,7 @@ class EmbedWidget extends Widget {
832
832
  this._loadEvent(_sqh);
833
833
 
834
834
  _log$7("loaded");
835
- } else {
835
+ } else if (frameDoc) {
836
836
  this._attachLoadEventListener(frameDoc, _sqh);
837
837
  }
838
838
  });
@@ -1553,6 +1553,379 @@ function asyncLoad() {
1553
1553
  }, 0);
1554
1554
  }
1555
1555
 
1556
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
1557
+
1558
+ function createCommonjsModule(fn) {
1559
+ var module = { exports: {} };
1560
+ return fn(module, module.exports), module.exports;
1561
+ }
1562
+
1563
+ /*! https://mths.be/utf8js v3.0.0 by @mathias */
1564
+
1565
+ var utf8 = createCommonjsModule(function (module, exports) {
1566
+ (function(root) {
1567
+
1568
+ var stringFromCharCode = String.fromCharCode;
1569
+
1570
+ // Taken from https://mths.be/punycode
1571
+ function ucs2decode(string) {
1572
+ var output = [];
1573
+ var counter = 0;
1574
+ var length = string.length;
1575
+ var value;
1576
+ var extra;
1577
+ while (counter < length) {
1578
+ value = string.charCodeAt(counter++);
1579
+ if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
1580
+ // high surrogate, and there is a next character
1581
+ extra = string.charCodeAt(counter++);
1582
+ if ((extra & 0xFC00) == 0xDC00) { // low surrogate
1583
+ output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
1584
+ } else {
1585
+ // unmatched surrogate; only append this code unit, in case the next
1586
+ // code unit is the high surrogate of a surrogate pair
1587
+ output.push(value);
1588
+ counter--;
1589
+ }
1590
+ } else {
1591
+ output.push(value);
1592
+ }
1593
+ }
1594
+ return output;
1595
+ }
1596
+
1597
+ // Taken from https://mths.be/punycode
1598
+ function ucs2encode(array) {
1599
+ var length = array.length;
1600
+ var index = -1;
1601
+ var value;
1602
+ var output = '';
1603
+ while (++index < length) {
1604
+ value = array[index];
1605
+ if (value > 0xFFFF) {
1606
+ value -= 0x10000;
1607
+ output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
1608
+ value = 0xDC00 | value & 0x3FF;
1609
+ }
1610
+ output += stringFromCharCode(value);
1611
+ }
1612
+ return output;
1613
+ }
1614
+
1615
+ function checkScalarValue(codePoint) {
1616
+ if (codePoint >= 0xD800 && codePoint <= 0xDFFF) {
1617
+ throw Error(
1618
+ 'Lone surrogate U+' + codePoint.toString(16).toUpperCase() +
1619
+ ' is not a scalar value'
1620
+ );
1621
+ }
1622
+ }
1623
+ /*--------------------------------------------------------------------------*/
1624
+
1625
+ function createByte(codePoint, shift) {
1626
+ return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80);
1627
+ }
1628
+
1629
+ function encodeCodePoint(codePoint) {
1630
+ if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence
1631
+ return stringFromCharCode(codePoint);
1632
+ }
1633
+ var symbol = '';
1634
+ if ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence
1635
+ symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0);
1636
+ }
1637
+ else if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence
1638
+ checkScalarValue(codePoint);
1639
+ symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0);
1640
+ symbol += createByte(codePoint, 6);
1641
+ }
1642
+ else if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence
1643
+ symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0);
1644
+ symbol += createByte(codePoint, 12);
1645
+ symbol += createByte(codePoint, 6);
1646
+ }
1647
+ symbol += stringFromCharCode((codePoint & 0x3F) | 0x80);
1648
+ return symbol;
1649
+ }
1650
+
1651
+ function utf8encode(string) {
1652
+ var codePoints = ucs2decode(string);
1653
+ var length = codePoints.length;
1654
+ var index = -1;
1655
+ var codePoint;
1656
+ var byteString = '';
1657
+ while (++index < length) {
1658
+ codePoint = codePoints[index];
1659
+ byteString += encodeCodePoint(codePoint);
1660
+ }
1661
+ return byteString;
1662
+ }
1663
+
1664
+ /*--------------------------------------------------------------------------*/
1665
+
1666
+ function readContinuationByte() {
1667
+ if (byteIndex >= byteCount) {
1668
+ throw Error('Invalid byte index');
1669
+ }
1670
+
1671
+ var continuationByte = byteArray[byteIndex] & 0xFF;
1672
+ byteIndex++;
1673
+
1674
+ if ((continuationByte & 0xC0) == 0x80) {
1675
+ return continuationByte & 0x3F;
1676
+ }
1677
+
1678
+ // If we end up here, it’s not a continuation byte
1679
+ throw Error('Invalid continuation byte');
1680
+ }
1681
+
1682
+ function decodeSymbol() {
1683
+ var byte1;
1684
+ var byte2;
1685
+ var byte3;
1686
+ var byte4;
1687
+ var codePoint;
1688
+
1689
+ if (byteIndex > byteCount) {
1690
+ throw Error('Invalid byte index');
1691
+ }
1692
+
1693
+ if (byteIndex == byteCount) {
1694
+ return false;
1695
+ }
1696
+
1697
+ // Read first byte
1698
+ byte1 = byteArray[byteIndex] & 0xFF;
1699
+ byteIndex++;
1700
+
1701
+ // 1-byte sequence (no continuation bytes)
1702
+ if ((byte1 & 0x80) == 0) {
1703
+ return byte1;
1704
+ }
1705
+
1706
+ // 2-byte sequence
1707
+ if ((byte1 & 0xE0) == 0xC0) {
1708
+ byte2 = readContinuationByte();
1709
+ codePoint = ((byte1 & 0x1F) << 6) | byte2;
1710
+ if (codePoint >= 0x80) {
1711
+ return codePoint;
1712
+ } else {
1713
+ throw Error('Invalid continuation byte');
1714
+ }
1715
+ }
1716
+
1717
+ // 3-byte sequence (may include unpaired surrogates)
1718
+ if ((byte1 & 0xF0) == 0xE0) {
1719
+ byte2 = readContinuationByte();
1720
+ byte3 = readContinuationByte();
1721
+ codePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3;
1722
+ if (codePoint >= 0x0800) {
1723
+ checkScalarValue(codePoint);
1724
+ return codePoint;
1725
+ } else {
1726
+ throw Error('Invalid continuation byte');
1727
+ }
1728
+ }
1729
+
1730
+ // 4-byte sequence
1731
+ if ((byte1 & 0xF8) == 0xF0) {
1732
+ byte2 = readContinuationByte();
1733
+ byte3 = readContinuationByte();
1734
+ byte4 = readContinuationByte();
1735
+ codePoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0C) |
1736
+ (byte3 << 0x06) | byte4;
1737
+ if (codePoint >= 0x010000 && codePoint <= 0x10FFFF) {
1738
+ return codePoint;
1739
+ }
1740
+ }
1741
+
1742
+ throw Error('Invalid UTF-8 detected');
1743
+ }
1744
+
1745
+ var byteArray;
1746
+ var byteCount;
1747
+ var byteIndex;
1748
+ function utf8decode(byteString) {
1749
+ byteArray = ucs2decode(byteString);
1750
+ byteCount = byteArray.length;
1751
+ byteIndex = 0;
1752
+ var codePoints = [];
1753
+ var tmp;
1754
+ while ((tmp = decodeSymbol()) !== false) {
1755
+ codePoints.push(tmp);
1756
+ }
1757
+ return ucs2encode(codePoints);
1758
+ }
1759
+
1760
+ /*--------------------------------------------------------------------------*/
1761
+
1762
+ root.version = '3.0.0';
1763
+ root.encode = utf8encode;
1764
+ root.decode = utf8decode;
1765
+
1766
+ }(exports));
1767
+ });
1768
+
1769
+ /*! https://mths.be/base64 v1.0.0 by @mathias | MIT license */
1770
+
1771
+ var base64 = createCommonjsModule(function (module, exports) {
1772
+ (function(root) {
1773
+
1774
+ // Detect free variables `exports`.
1775
+ var freeExports = exports;
1776
+
1777
+ // Detect free variable `module`.
1778
+ var freeModule = module &&
1779
+ module.exports == freeExports && module;
1780
+
1781
+ // Detect free variable `global`, from Node.js or Browserified code, and use
1782
+ // it as `root`.
1783
+ var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal;
1784
+ if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
1785
+ root = freeGlobal;
1786
+ }
1787
+
1788
+ /*--------------------------------------------------------------------------*/
1789
+
1790
+ var InvalidCharacterError = function(message) {
1791
+ this.message = message;
1792
+ };
1793
+ InvalidCharacterError.prototype = new Error;
1794
+ InvalidCharacterError.prototype.name = 'InvalidCharacterError';
1795
+
1796
+ var error = function(message) {
1797
+ // Note: the error messages used throughout this file match those used by
1798
+ // the native `atob`/`btoa` implementation in Chromium.
1799
+ throw new InvalidCharacterError(message);
1800
+ };
1801
+
1802
+ var TABLE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
1803
+ // http://whatwg.org/html/common-microsyntaxes.html#space-character
1804
+ var REGEX_SPACE_CHARACTERS = /[\t\n\f\r ]/g;
1805
+
1806
+ // `decode` is designed to be fully compatible with `atob` as described in the
1807
+ // HTML Standard. http://whatwg.org/html/webappapis.html#dom-windowbase64-atob
1808
+ // The optimized base64-decoding algorithm used is based on @atk’s excellent
1809
+ // implementation. https://gist.github.com/atk/1020396
1810
+ var decode = function(input) {
1811
+ input = String(input)
1812
+ .replace(REGEX_SPACE_CHARACTERS, '');
1813
+ var length = input.length;
1814
+ if (length % 4 == 0) {
1815
+ input = input.replace(/==?$/, '');
1816
+ length = input.length;
1817
+ }
1818
+ if (
1819
+ length % 4 == 1 ||
1820
+ // http://whatwg.org/C#alphanumeric-ascii-characters
1821
+ /[^+a-zA-Z0-9/]/.test(input)
1822
+ ) {
1823
+ error(
1824
+ 'Invalid character: the string to be decoded is not correctly encoded.'
1825
+ );
1826
+ }
1827
+ var bitCounter = 0;
1828
+ var bitStorage;
1829
+ var buffer;
1830
+ var output = '';
1831
+ var position = -1;
1832
+ while (++position < length) {
1833
+ buffer = TABLE.indexOf(input.charAt(position));
1834
+ bitStorage = bitCounter % 4 ? bitStorage * 64 + buffer : buffer;
1835
+ // Unless this is the first of a group of 4 characters…
1836
+ if (bitCounter++ % 4) {
1837
+ // …convert the first 8 bits to a single ASCII character.
1838
+ output += String.fromCharCode(
1839
+ 0xFF & bitStorage >> (-2 * bitCounter & 6)
1840
+ );
1841
+ }
1842
+ }
1843
+ return output;
1844
+ };
1845
+
1846
+ // `encode` is designed to be fully compatible with `btoa` as described in the
1847
+ // HTML Standard: http://whatwg.org/html/webappapis.html#dom-windowbase64-btoa
1848
+ var encode = function(input) {
1849
+ input = String(input);
1850
+ if (/[^\0-\xFF]/.test(input)) {
1851
+ // Note: no need to special-case astral symbols here, as surrogates are
1852
+ // matched, and the input is supposed to only contain ASCII anyway.
1853
+ error(
1854
+ 'The string to be encoded contains characters outside of the ' +
1855
+ 'Latin1 range.'
1856
+ );
1857
+ }
1858
+ var padding = input.length % 3;
1859
+ var output = '';
1860
+ var position = -1;
1861
+ var a;
1862
+ var b;
1863
+ var c;
1864
+ var buffer;
1865
+ // Make sure any padding is handled outside of the loop.
1866
+ var length = input.length - padding;
1867
+
1868
+ while (++position < length) {
1869
+ // Read three bytes, i.e. 24 bits.
1870
+ a = input.charCodeAt(position) << 16;
1871
+ b = input.charCodeAt(++position) << 8;
1872
+ c = input.charCodeAt(++position);
1873
+ buffer = a + b + c;
1874
+ // Turn the 24 bits into four chunks of 6 bits each, and append the
1875
+ // matching character for each of them to the output.
1876
+ output += (
1877
+ TABLE.charAt(buffer >> 18 & 0x3F) +
1878
+ TABLE.charAt(buffer >> 12 & 0x3F) +
1879
+ TABLE.charAt(buffer >> 6 & 0x3F) +
1880
+ TABLE.charAt(buffer & 0x3F)
1881
+ );
1882
+ }
1883
+
1884
+ if (padding == 2) {
1885
+ a = input.charCodeAt(position) << 8;
1886
+ b = input.charCodeAt(++position);
1887
+ buffer = a + b;
1888
+ output += (
1889
+ TABLE.charAt(buffer >> 10) +
1890
+ TABLE.charAt((buffer >> 4) & 0x3F) +
1891
+ TABLE.charAt((buffer << 2) & 0x3F) +
1892
+ '='
1893
+ );
1894
+ } else if (padding == 1) {
1895
+ buffer = input.charCodeAt(position);
1896
+ output += (
1897
+ TABLE.charAt(buffer >> 2) +
1898
+ TABLE.charAt((buffer << 4) & 0x3F) +
1899
+ '=='
1900
+ );
1901
+ }
1902
+
1903
+ return output;
1904
+ };
1905
+
1906
+ var base64 = {
1907
+ 'encode': encode,
1908
+ 'decode': decode,
1909
+ 'version': '1.0.0'
1910
+ };
1911
+
1912
+ // Some AMD build optimizers, like r.js, check for specific condition patterns
1913
+ // like the following:
1914
+ if (freeExports && !freeExports.nodeType) {
1915
+ if (freeModule) { // in Node.js or RingoJS v0.8.0+
1916
+ freeModule.exports = base64;
1917
+ } else { // in Narwhal or RingoJS v0.7.0-
1918
+ for (var key in base64) {
1919
+ base64.hasOwnProperty(key) && (freeExports[key] = base64[key]);
1920
+ }
1921
+ }
1922
+ } else { // in Rhino or a web browser
1923
+ root.base64 = base64;
1924
+ }
1925
+
1926
+ }(commonjsGlobal));
1927
+ });
1928
+
1556
1929
  /** @hidden */
1557
1930
 
1558
1931
  var _log$4 = debug("squatch-js");
@@ -1569,7 +1942,7 @@ var deepMerge = (target, source) => {
1569
1942
  };
1570
1943
 
1571
1944
  function b64decode(input) {
1572
- return atob(input.replace(/_/g, "/").replace(/-/g, "+"));
1945
+ return utf8.decode(base64.decode(input));
1573
1946
  }
1574
1947
 
1575
1948
  function b64encode(input) {