@paydock/client-sdk 1.144.0-beta → 1.144.1-beta

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/bundles/index.cjs CHANGED
@@ -956,246 +956,6 @@ var ApiCharge = /*#__PURE__*/function () {
956
956
  }]);
957
957
  }();
958
958
 
959
- var ENV = {
960
- SANDBOX: 'sandbox',
961
- SANDBOX_KOVENA: 'sandbox-kovena',
962
- SANDBOX_DEMO: 'sandbox-demo',
963
- SANDBOX_DEMO_KOVENA: 'sandbox-demo-kovena',
964
- PROD: 'production',
965
- STAGING: 'staging',
966
- STAGING_1: 'staging_1',
967
- STAGING_2: 'staging_2',
968
- STAGING_3: 'staging_3',
969
- STAGING_4: 'staging_4',
970
- STAGING_5: 'staging_5',
971
- STAGING_6: 'staging_6',
972
- STAGING_7: 'staging_7',
973
- STAGING_8: 'staging_8',
974
- STAGING_9: 'staging_9',
975
- STAGING_10: 'staging_10',
976
- STAGING_11: 'staging_11',
977
- STAGING_12: 'staging_12',
978
- STAGING_13: 'staging_13',
979
- STAGING_14: 'staging_14',
980
- STAGING_15: 'staging_15'
981
- };
982
- var WIDGET_URL = [{
983
- env: ENV.SANDBOX,
984
- url: 'https://widget-sandbox.'
985
- }, {
986
- env: ENV.SANDBOX_KOVENA,
987
- url: 'https://widget-sandbox.'
988
- }, {
989
- env: ENV.SANDBOX_DEMO,
990
- url: 'https://widget-sandbox-demo.'
991
- }, {
992
- env: ENV.SANDBOX_DEMO_KOVENA,
993
- url: 'https://widget-sandbox-demo.'
994
- }, {
995
- env: ENV.PROD,
996
- url: 'https://widget.'
997
- }, {
998
- env: ENV.STAGING,
999
- url: 'https://widsta.'
1000
- }, {
1001
- env: ENV.STAGING_1,
1002
- url: 'https://widsta-1.'
1003
- }, {
1004
- env: ENV.STAGING_2,
1005
- url: 'https://widsta-2.'
1006
- }, {
1007
- env: ENV.STAGING_3,
1008
- url: 'https://widsta-3.'
1009
- }, {
1010
- env: ENV.STAGING_4,
1011
- url: 'https://widsta-4.'
1012
- }, {
1013
- env: ENV.STAGING_5,
1014
- url: 'https://widsta-5.'
1015
- }, {
1016
- env: ENV.STAGING_6,
1017
- url: 'https://widsta-6.'
1018
- }, {
1019
- env: ENV.STAGING_7,
1020
- url: 'https://widsta-7.'
1021
- }, {
1022
- env: ENV.STAGING_8,
1023
- url: 'https://widsta-8.'
1024
- }, {
1025
- env: ENV.STAGING_9,
1026
- url: 'https://widsta-9.'
1027
- }, {
1028
- env: ENV.STAGING_10,
1029
- url: 'https://widsta-10.'
1030
- }, {
1031
- env: ENV.STAGING_11,
1032
- url: 'https://widsta-11.'
1033
- }, {
1034
- env: ENV.STAGING_12,
1035
- url: 'https://widsta-12.'
1036
- }, {
1037
- env: ENV.STAGING_13,
1038
- url: 'https://widsta-13.'
1039
- }, {
1040
- env: ENV.STAGING_14,
1041
- url: 'https://widsta-14.'
1042
- }, {
1043
- env: ENV.STAGING_15,
1044
- url: 'https://widsta-15.'
1045
- }];
1046
- var API_URL = [{
1047
- env: ENV.SANDBOX,
1048
- url: 'https://api-sandbox.'
1049
- }, {
1050
- env: ENV.PROD,
1051
- url: 'https://api.'
1052
- }, {
1053
- env: ENV.STAGING,
1054
- url: 'https://apista.'
1055
- }, {
1056
- env: ENV.STAGING_1,
1057
- url: 'https://apista-1.'
1058
- }, {
1059
- env: ENV.STAGING_2,
1060
- url: 'https://apista-2.'
1061
- }, {
1062
- env: ENV.STAGING_3,
1063
- url: 'https://apista-3.'
1064
- }, {
1065
- env: ENV.STAGING_4,
1066
- url: 'https://apista-4.'
1067
- }, {
1068
- env: ENV.STAGING_5,
1069
- url: 'https://apista-5.'
1070
- }, {
1071
- env: ENV.STAGING_6,
1072
- url: 'https://apista-6.'
1073
- }, {
1074
- env: ENV.STAGING_7,
1075
- url: 'https://apista-7.'
1076
- }, {
1077
- env: ENV.STAGING_8,
1078
- url: 'https://apista-8.'
1079
- }, {
1080
- env: ENV.STAGING_9,
1081
- url: 'https://apista-9.'
1082
- }, {
1083
- env: ENV.STAGING_10,
1084
- url: 'https://apista-10.'
1085
- }, {
1086
- env: ENV.STAGING_11,
1087
- url: 'https://apista-11.'
1088
- }, {
1089
- env: ENV.STAGING_12,
1090
- url: 'https://apista-12.'
1091
- }, {
1092
- env: ENV.STAGING_13,
1093
- url: 'https://apista-13.'
1094
- }, {
1095
- env: ENV.STAGING_14,
1096
- url: 'https://apista-14.'
1097
- }, {
1098
- env: ENV.STAGING_15,
1099
- url: 'https://apista-15.'
1100
- }];
1101
- var ADDITIONAL_ENV = [ENV.SANDBOX_KOVENA, ENV.SANDBOX_DEMO_KOVENA];
1102
- var REGEX_ALIAS = '^([a-zA-Z0-9](?:(?:[a-zA-Z0-9-.]*(?!-)\\.(?![-.]))*[a-zA-Z0-9]+)?)$';
1103
- var DEFAULT_ENV = ENV.SANDBOX;
1104
- var DEFAULT_ALIAS = {
1105
- PAYDOCK: 'paydock.com',
1106
- KOVENA: 'kovena.com'
1107
- };
1108
- // TODO @ingeniousraccoons we should take advantage of TypeScript mechanism for static environmentId checking and simplified runtime validation
1109
- // TODO @ingeniousraccoons unify `environment.paydock.ts` and `environment.cba.ts` making them configuration driven
1110
- var Env = /*#__PURE__*/function () {
1111
- function Env(configs) {
1112
- var defaultEnv = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_ENV;
1113
- _classCallCheck(this, Env);
1114
- this.environmentConfigurations = configs;
1115
- this.setEnv(defaultEnv);
1116
- }
1117
- return _createClass(Env, [{
1118
- key: "setEnv",
1119
- value: function setEnv(environmentId, alias) {
1120
- this.validateAlias(alias);
1121
- this.validateEnvironmentId(environmentId);
1122
- this.environmentId = environmentId;
1123
- if (alias) {
1124
- this.alias = alias;
1125
- } else if (ADDITIONAL_ENV.includes(this.environmentId)) {
1126
- this.alias = DEFAULT_ALIAS.KOVENA;
1127
- } else {
1128
- this.alias = DEFAULT_ALIAS.PAYDOCK;
1129
- }
1130
- }
1131
- }, {
1132
- key: "getEnv",
1133
- value: function getEnv() {
1134
- return this.environmentId;
1135
- }
1136
- }, {
1137
- key: "getConf",
1138
- value: function getConf() {
1139
- for (var index in this.environmentConfigurations) {
1140
- if (!Object.hasOwn(this.environmentConfigurations, index)) {
1141
- continue;
1142
- }
1143
- if (this.environmentConfigurations[index].env === this.getEnv()) {
1144
- return {
1145
- url: this.environmentConfigurations[index].url.indexOf('localhost') !== -1 ? this.environmentConfigurations[index].url : this.environmentConfigurations[index].url + this.alias,
1146
- env: this.environmentConfigurations[index].env
1147
- };
1148
- }
1149
- }
1150
- throw new Error('Env could not obtain configuration. Unknown environmentId.');
1151
- }
1152
- }, {
1153
- key: "validateAlias",
1154
- value: function validateAlias(alias) {
1155
- if (typeof alias === 'undefined') {
1156
- return;
1157
- }
1158
- if (typeof alias !== 'string') {
1159
- throw new TypeError("Env expects parameter 'alias' to be of type 'string' or 'undefined'.");
1160
- }
1161
- if (!alias.match(REGEX_ALIAS)) {
1162
- throw new Error("Env received malformed alias: ".concat(alias, ". Ensure it satisfies the regex: '").concat(REGEX_ALIAS, "'."));
1163
- }
1164
- }
1165
- }, {
1166
- key: "validateEnvironmentId",
1167
- value: function validateEnvironmentId(environmentId) {
1168
- for (var index in this.environmentConfigurations) {
1169
- if (!Object.hasOwn(this.environmentConfigurations, index)) {
1170
- continue;
1171
- }
1172
- if (this.environmentConfigurations[index].env === environmentId) {
1173
- return;
1174
- }
1175
- }
1176
- throw new TypeError("Env received unknown environmentId: ".concat(environmentId));
1177
- }
1178
- }]);
1179
- }();
1180
-
1181
- var SDK = /*#__PURE__*/function () {
1182
- function SDK() {
1183
- _classCallCheck(this, SDK);
1184
- }
1185
- return _createClass(SDK, null, [{
1186
- key: "version",
1187
- get: function get() {
1188
- return SDK._version.trim() || null;
1189
- }
1190
- }]);
1191
- }();
1192
- SDK.type = 'client';
1193
- SDK.headerKeys = Object.freeze({
1194
- version: 'x-sdk-version',
1195
- type: 'x-sdk-type'
1196
- });
1197
- SDK._version = 'v1.144.0-beta';
1198
-
1199
959
  function isFunction(value) {
1200
960
  return typeof value === 'function';
1201
961
  }
@@ -1853,23 +1613,263 @@ var BehaviorSubject = (function (_super) {
1853
1613
  return BehaviorSubject;
1854
1614
  }(Subject));
1855
1615
 
1856
- var ACCESS_HEADER_NAME = {
1857
- accessToken: 'x-access-token',
1858
- publicKey: 'x-user-public-key'
1859
- };
1860
- var AccessToken = /*#__PURE__*/function () {
1861
- function AccessToken() {
1862
- _classCallCheck(this, AccessToken);
1863
- }
1864
- return _createClass(AccessToken, null, [{
1865
- key: "validateJWT",
1866
- value: function validateJWT(jwt) {
1867
- if (!jwt) return null;
1868
- var _jwt$split = jwt.split("."),
1869
- _jwt$split2 = _slicedToArray(_jwt$split, 3),
1870
- rawHead = _jwt$split2[0],
1871
- rawBody = _jwt$split2[1],
1872
- signature = _jwt$split2[2];
1616
+ var ENV = {
1617
+ SANDBOX: 'sandbox',
1618
+ SANDBOX_KOVENA: 'sandbox-kovena',
1619
+ SANDBOX_DEMO: 'sandbox-demo',
1620
+ SANDBOX_DEMO_KOVENA: 'sandbox-demo-kovena',
1621
+ PROD: 'production',
1622
+ STAGING: 'staging',
1623
+ STAGING_1: 'staging_1',
1624
+ STAGING_2: 'staging_2',
1625
+ STAGING_3: 'staging_3',
1626
+ STAGING_4: 'staging_4',
1627
+ STAGING_5: 'staging_5',
1628
+ STAGING_6: 'staging_6',
1629
+ STAGING_7: 'staging_7',
1630
+ STAGING_8: 'staging_8',
1631
+ STAGING_9: 'staging_9',
1632
+ STAGING_10: 'staging_10',
1633
+ STAGING_11: 'staging_11',
1634
+ STAGING_12: 'staging_12',
1635
+ STAGING_13: 'staging_13',
1636
+ STAGING_14: 'staging_14',
1637
+ STAGING_15: 'staging_15'
1638
+ };
1639
+ var WIDGET_URL = [{
1640
+ env: ENV.SANDBOX,
1641
+ url: 'https://widget-sandbox.'
1642
+ }, {
1643
+ env: ENV.SANDBOX_KOVENA,
1644
+ url: 'https://widget-sandbox.'
1645
+ }, {
1646
+ env: ENV.SANDBOX_DEMO,
1647
+ url: 'https://widget-sandbox-demo.'
1648
+ }, {
1649
+ env: ENV.SANDBOX_DEMO_KOVENA,
1650
+ url: 'https://widget-sandbox-demo.'
1651
+ }, {
1652
+ env: ENV.PROD,
1653
+ url: 'https://widget.'
1654
+ }, {
1655
+ env: ENV.STAGING,
1656
+ url: 'https://widsta.'
1657
+ }, {
1658
+ env: ENV.STAGING_1,
1659
+ url: 'https://widsta-1.'
1660
+ }, {
1661
+ env: ENV.STAGING_2,
1662
+ url: 'https://widsta-2.'
1663
+ }, {
1664
+ env: ENV.STAGING_3,
1665
+ url: 'https://widsta-3.'
1666
+ }, {
1667
+ env: ENV.STAGING_4,
1668
+ url: 'https://widsta-4.'
1669
+ }, {
1670
+ env: ENV.STAGING_5,
1671
+ url: 'https://widsta-5.'
1672
+ }, {
1673
+ env: ENV.STAGING_6,
1674
+ url: 'https://widsta-6.'
1675
+ }, {
1676
+ env: ENV.STAGING_7,
1677
+ url: 'https://widsta-7.'
1678
+ }, {
1679
+ env: ENV.STAGING_8,
1680
+ url: 'https://widsta-8.'
1681
+ }, {
1682
+ env: ENV.STAGING_9,
1683
+ url: 'https://widsta-9.'
1684
+ }, {
1685
+ env: ENV.STAGING_10,
1686
+ url: 'https://widsta-10.'
1687
+ }, {
1688
+ env: ENV.STAGING_11,
1689
+ url: 'https://widsta-11.'
1690
+ }, {
1691
+ env: ENV.STAGING_12,
1692
+ url: 'https://widsta-12.'
1693
+ }, {
1694
+ env: ENV.STAGING_13,
1695
+ url: 'https://widsta-13.'
1696
+ }, {
1697
+ env: ENV.STAGING_14,
1698
+ url: 'https://widsta-14.'
1699
+ }, {
1700
+ env: ENV.STAGING_15,
1701
+ url: 'https://widsta-15.'
1702
+ }];
1703
+ var API_URL = [{
1704
+ env: ENV.SANDBOX,
1705
+ url: 'https://api-sandbox.'
1706
+ }, {
1707
+ env: ENV.PROD,
1708
+ url: 'https://api.'
1709
+ }, {
1710
+ env: ENV.STAGING,
1711
+ url: 'https://apista.'
1712
+ }, {
1713
+ env: ENV.STAGING_1,
1714
+ url: 'https://apista-1.'
1715
+ }, {
1716
+ env: ENV.STAGING_2,
1717
+ url: 'https://apista-2.'
1718
+ }, {
1719
+ env: ENV.STAGING_3,
1720
+ url: 'https://apista-3.'
1721
+ }, {
1722
+ env: ENV.STAGING_4,
1723
+ url: 'https://apista-4.'
1724
+ }, {
1725
+ env: ENV.STAGING_5,
1726
+ url: 'https://apista-5.'
1727
+ }, {
1728
+ env: ENV.STAGING_6,
1729
+ url: 'https://apista-6.'
1730
+ }, {
1731
+ env: ENV.STAGING_7,
1732
+ url: 'https://apista-7.'
1733
+ }, {
1734
+ env: ENV.STAGING_8,
1735
+ url: 'https://apista-8.'
1736
+ }, {
1737
+ env: ENV.STAGING_9,
1738
+ url: 'https://apista-9.'
1739
+ }, {
1740
+ env: ENV.STAGING_10,
1741
+ url: 'https://apista-10.'
1742
+ }, {
1743
+ env: ENV.STAGING_11,
1744
+ url: 'https://apista-11.'
1745
+ }, {
1746
+ env: ENV.STAGING_12,
1747
+ url: 'https://apista-12.'
1748
+ }, {
1749
+ env: ENV.STAGING_13,
1750
+ url: 'https://apista-13.'
1751
+ }, {
1752
+ env: ENV.STAGING_14,
1753
+ url: 'https://apista-14.'
1754
+ }, {
1755
+ env: ENV.STAGING_15,
1756
+ url: 'https://apista-15.'
1757
+ }];
1758
+ var ADDITIONAL_ENV = [ENV.SANDBOX_KOVENA, ENV.SANDBOX_DEMO_KOVENA];
1759
+ var REGEX_ALIAS = '^([a-zA-Z0-9](?:(?:[a-zA-Z0-9-.]*(?!-)\\.(?![-.]))*[a-zA-Z0-9]+)?)$';
1760
+ var DEFAULT_ENV = ENV.SANDBOX;
1761
+ var DEFAULT_ALIAS = {
1762
+ PAYDOCK: 'paydock.com',
1763
+ KOVENA: 'kovena.com'
1764
+ };
1765
+ // TODO @ingeniousraccoons we should take advantage of TypeScript mechanism for static environmentId checking and simplified runtime validation
1766
+ // TODO @ingeniousraccoons unify `environment.paydock.ts` and `environment.cba.ts` making them configuration driven
1767
+ var Env = /*#__PURE__*/function () {
1768
+ function Env(configs) {
1769
+ var defaultEnv = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_ENV;
1770
+ _classCallCheck(this, Env);
1771
+ this.environmentConfigurations = configs;
1772
+ this.setEnv(defaultEnv);
1773
+ }
1774
+ return _createClass(Env, [{
1775
+ key: "setEnv",
1776
+ value: function setEnv(environmentId, alias) {
1777
+ this.validateAlias(alias);
1778
+ this.validateEnvironmentId(environmentId);
1779
+ this.environmentId = environmentId;
1780
+ if (alias) {
1781
+ this.alias = alias;
1782
+ } else if (ADDITIONAL_ENV.includes(this.environmentId)) {
1783
+ this.alias = DEFAULT_ALIAS.KOVENA;
1784
+ } else {
1785
+ this.alias = DEFAULT_ALIAS.PAYDOCK;
1786
+ }
1787
+ }
1788
+ }, {
1789
+ key: "getEnv",
1790
+ value: function getEnv() {
1791
+ return this.environmentId;
1792
+ }
1793
+ }, {
1794
+ key: "getConf",
1795
+ value: function getConf() {
1796
+ for (var index in this.environmentConfigurations) {
1797
+ if (!Object.hasOwn(this.environmentConfigurations, index)) {
1798
+ continue;
1799
+ }
1800
+ if (this.environmentConfigurations[index].env === this.getEnv()) {
1801
+ return {
1802
+ url: this.environmentConfigurations[index].url.indexOf('localhost') !== -1 ? this.environmentConfigurations[index].url : this.environmentConfigurations[index].url + this.alias,
1803
+ env: this.environmentConfigurations[index].env
1804
+ };
1805
+ }
1806
+ }
1807
+ throw new Error('Env could not obtain configuration. Unknown environmentId.');
1808
+ }
1809
+ }, {
1810
+ key: "validateAlias",
1811
+ value: function validateAlias(alias) {
1812
+ if (typeof alias === 'undefined') {
1813
+ return;
1814
+ }
1815
+ if (typeof alias !== 'string') {
1816
+ throw new TypeError("Env expects parameter 'alias' to be of type 'string' or 'undefined'.");
1817
+ }
1818
+ if (!alias.match(REGEX_ALIAS)) {
1819
+ throw new Error("Env received malformed alias: ".concat(alias, ". Ensure it satisfies the regex: '").concat(REGEX_ALIAS, "'."));
1820
+ }
1821
+ }
1822
+ }, {
1823
+ key: "validateEnvironmentId",
1824
+ value: function validateEnvironmentId(environmentId) {
1825
+ for (var index in this.environmentConfigurations) {
1826
+ if (!Object.hasOwn(this.environmentConfigurations, index)) {
1827
+ continue;
1828
+ }
1829
+ if (this.environmentConfigurations[index].env === environmentId) {
1830
+ return;
1831
+ }
1832
+ }
1833
+ throw new TypeError("Env received unknown environmentId: ".concat(environmentId));
1834
+ }
1835
+ }]);
1836
+ }();
1837
+
1838
+ var SDK = /*#__PURE__*/function () {
1839
+ function SDK() {
1840
+ _classCallCheck(this, SDK);
1841
+ }
1842
+ return _createClass(SDK, null, [{
1843
+ key: "version",
1844
+ get: function get() {
1845
+ return SDK._version.trim() || null;
1846
+ }
1847
+ }]);
1848
+ }();
1849
+ SDK.type = 'client';
1850
+ SDK.headerKeys = Object.freeze({
1851
+ version: 'x-sdk-version',
1852
+ type: 'x-sdk-type'
1853
+ });
1854
+ SDK._version = 'v1.144.1-beta';
1855
+
1856
+ var ACCESS_HEADER_NAME = {
1857
+ accessToken: 'x-access-token',
1858
+ publicKey: 'x-user-public-key'
1859
+ };
1860
+ var AccessToken = /*#__PURE__*/function () {
1861
+ function AccessToken() {
1862
+ _classCallCheck(this, AccessToken);
1863
+ }
1864
+ return _createClass(AccessToken, null, [{
1865
+ key: "validateJWT",
1866
+ value: function validateJWT(jwt) {
1867
+ if (!jwt) return null;
1868
+ var _jwt$split = jwt.split("."),
1869
+ _jwt$split2 = _slicedToArray(_jwt$split, 3),
1870
+ rawHead = _jwt$split2[0],
1871
+ rawBody = _jwt$split2[1],
1872
+ signature = _jwt$split2[2];
1873
1873
  if (!rawHead || !rawBody || !signature) return null;
1874
1874
  if (2 + rawHead.length + rawBody.length + signature.length !== jwt.length) return null;
1875
1875
  try {
@@ -1916,32 +1916,165 @@ var AccessToken = /*#__PURE__*/function () {
1916
1916
  }
1917
1917
  }
1918
1918
  }, {
1919
- key: "validateJWTWhitelistedDomains",
1920
- value: function validateJWTWhitelistedDomains(body) {
1921
- var _a;
1922
- try {
1923
- if (!body.meta) return true;
1924
- var meta = this.extractData(body);
1925
- if (!meta) return true;
1926
- if (!((_a = meta.whitelist_domains) === null || _a === void 0 ? void 0 : _a.length)) return true;
1927
- return meta.whitelist_domains.includes(window.location.hostname);
1928
- } catch (err) {
1929
- return true;
1930
- }
1919
+ key: "validateJWTWhitelistedDomains",
1920
+ value: function validateJWTWhitelistedDomains(body) {
1921
+ var _a;
1922
+ try {
1923
+ if (!body.meta) return true;
1924
+ var meta = this.extractData(body);
1925
+ if (!meta) return true;
1926
+ if (!((_a = meta.whitelist_domains) === null || _a === void 0 ? void 0 : _a.length)) return true;
1927
+ return meta.whitelist_domains.includes(window.location.hostname);
1928
+ } catch (err) {
1929
+ return true;
1930
+ }
1931
+ }
1932
+ }, {
1933
+ key: "getAccessHeaderNameByToken",
1934
+ value: function getAccessHeaderNameByToken(token) {
1935
+ return !!AccessToken.validateJWT(token) ? ACCESS_HEADER_NAME.accessToken : ACCESS_HEADER_NAME.publicKey;
1936
+ }
1937
+ }, {
1938
+ key: "isJwt",
1939
+ value: function isJwt(value) {
1940
+ var jwtPattern = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
1941
+ return jwtPattern.test(value);
1942
+ }
1943
+ }]);
1944
+ }();
1945
+
1946
+ /**
1947
+ * Top-level classification of an error. Used by the SDK to route errors to the
1948
+ * right category in instrumentation and to give consumers a coarse-grained
1949
+ * tag for grouping/filtering. See {@link getErrorCategory} for the mapping
1950
+ * between {@link ERROR_CAUSE} and {@link ERROR_CATEGORY}.
1951
+ */
1952
+ var ERROR_CATEGORY = {
1953
+ /** SDK was misconfigured (missing keys, invalid options, etc.). */
1954
+ CONFIGURATION: 'configuration',
1955
+ /** Authentication or authorization failure. */
1956
+ IDENTITY: 'identity_access_management',
1957
+ /** SDK internal failure or upstream service problem. */
1958
+ INTERNAL: 'internal',
1959
+ /** Flow lifecycle event (user cancelled, aborted, etc.) — not a real fault. */
1960
+ PROCESS: 'process',
1961
+ /** Resource lookup failed or was rate-limited. */
1962
+ RESOURCE: 'resource',
1963
+ /** Invalid input or business-rule validation failure. */
1964
+ VALIDATION: 'validation'
1965
+ };
1966
+ /**
1967
+ * Concrete cause of an error. More specific than {@link ERROR_CATEGORY} —
1968
+ * useful for deciding programmatic responses (e.g. show a retry button only
1969
+ * when `cause` is `'service_unreachable'` or `'server_busy'`).
1970
+ */
1971
+ var ERROR_CAUSE = {
1972
+ /** Operation was aborted programmatically. */
1973
+ ABORTED: 'aborted',
1974
+ /** Caller has insufficient permissions for the operation. */
1975
+ ACCESS_FORBIDDEN: 'access_forbidden',
1976
+ /** Resource already exists when create was expected. */
1977
+ ALREADY_EXISTS: 'already_exists',
1978
+ /** User cancelled the flow (e.g. closed the wallet sheet). */
1979
+ CANCELED: 'canceled',
1980
+ /** SDK was instantiated or invoked with invalid configuration. */
1981
+ INVALID_CONFIGURATION: 'invalid_configuration',
1982
+ /** Input failed structural or business-rule validation. */
1983
+ INVALID_INPUT: 'invalid_input',
1984
+ /** Resource was not found by the backend. */
1985
+ NOT_FOUND: 'not_found',
1986
+ /** Operation is not supported in the current context or version. */
1987
+ NOT_IMPLEMENTED: 'not_implemented',
1988
+ /** Caller exceeded the allowed request rate. */
1989
+ RATE_LIMITED: 'rate_limited',
1990
+ /** Backend is healthy but currently overloaded — typically retryable. */
1991
+ SERVER_BUSY: 'server_busy',
1992
+ /** Backend or third-party service could not be reached — typically retryable. */
1993
+ SERVICE_UNREACHABLE: 'service_unreachable',
1994
+ /** Caller is not authenticated. */
1995
+ UNAUTHORIZED: 'unauthorized',
1996
+ /** Catch-all when no other cause applies. */
1997
+ UNKNOWN: 'unknown_error',
1998
+ /** Request was syntactically valid but semantically rejected. */
1999
+ UNPROCESSABLE_ENTITY: 'unprocessable_entity'
2000
+ };
2001
+ var EventError = /*#__PURE__*/function (_Error) {
2002
+ function EventError(cause, category, retryable, details) {
2003
+ var _this;
2004
+ _classCallCheck(this, EventError);
2005
+ _this = _callSuper(this, EventError, [details.message]);
2006
+ _this.cause = cause;
2007
+ _this.category = category;
2008
+ _this.retryable = retryable;
2009
+ _this.details = details;
2010
+ Object.setPrototypeOf(_this, EventError.prototype);
2011
+ _this.name = EventError.name;
2012
+ return _this;
2013
+ }
2014
+ _inherits(EventError, _Error);
2015
+ return _createClass(EventError, [{
2016
+ key: "toJSON",
2017
+ value: function toJSON() {
2018
+ return {
2019
+ error: {
2020
+ category: this.category,
2021
+ cause: this.cause,
2022
+ details: this.details,
2023
+ retryable: this.retryable
2024
+ }
2025
+ };
2026
+ }
2027
+ }, {
2028
+ key: "setContextId",
2029
+ value: function setContextId(contextId) {
2030
+ this.details.contextId = contextId;
1931
2031
  }
1932
2032
  }, {
1933
- key: "getAccessHeaderNameByToken",
1934
- value: function getAccessHeaderNameByToken(token) {
1935
- return !!AccessToken.validateJWT(token) ? ACCESS_HEADER_NAME.accessToken : ACCESS_HEADER_NAME.publicKey;
2033
+ key: "setPurpose",
2034
+ value: function setPurpose(purpose) {
2035
+ this.purpose = purpose;
1936
2036
  }
1937
- }, {
1938
- key: "isJwt",
1939
- value: function isJwt(value) {
1940
- var jwtPattern = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
1941
- return jwtPattern.test(value);
2037
+ }], [{
2038
+ key: "create",
2039
+ value: function create(cause, message) {
2040
+ var contextId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
2041
+ var retryable = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
2042
+ var details = {
2043
+ cause: cause,
2044
+ contextId: contextId,
2045
+ message: message,
2046
+ timestamp: new Date().toISOString()
2047
+ };
2048
+ var category = getErrorCategory(cause);
2049
+ return new EventError(cause, category, retryable, details);
1942
2050
  }
1943
2051
  }]);
1944
- }();
2052
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
2053
+ function getErrorCategory(cause) {
2054
+ switch (cause) {
2055
+ case ERROR_CAUSE.INVALID_CONFIGURATION:
2056
+ return ERROR_CATEGORY.CONFIGURATION;
2057
+ case ERROR_CAUSE.ACCESS_FORBIDDEN:
2058
+ case ERROR_CAUSE.UNAUTHORIZED:
2059
+ return ERROR_CATEGORY.IDENTITY;
2060
+ case ERROR_CAUSE.SERVICE_UNREACHABLE:
2061
+ case ERROR_CAUSE.NOT_IMPLEMENTED:
2062
+ case ERROR_CAUSE.SERVER_BUSY:
2063
+ return ERROR_CATEGORY.INTERNAL;
2064
+ case ERROR_CAUSE.ABORTED:
2065
+ case ERROR_CAUSE.CANCELED:
2066
+ return ERROR_CATEGORY.PROCESS;
2067
+ case ERROR_CAUSE.NOT_FOUND:
2068
+ case ERROR_CAUSE.RATE_LIMITED:
2069
+ return ERROR_CATEGORY.RESOURCE;
2070
+ case ERROR_CAUSE.ALREADY_EXISTS:
2071
+ case ERROR_CAUSE.INVALID_INPUT:
2072
+ case ERROR_CAUSE.UNPROCESSABLE_ENTITY:
2073
+ return ERROR_CATEGORY.VALIDATION;
2074
+ default:
2075
+ return ERROR_CATEGORY.INTERNAL;
2076
+ }
2077
+ }
1945
2078
 
1946
2079
  var HttpRequest = /*#__PURE__*/function () {
1947
2080
  function HttpRequest(request) {
@@ -4637,18 +4770,23 @@ var ApiBase = /*#__PURE__*/function () {
4637
4770
  var errorCb = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function (data) {
4638
4771
  return undefined;
4639
4772
  };
4773
+ var onError = function onError(err) {
4774
+ _this4.reportError(errorRepository, err, _extends(_extends({}, _this4.ctx), {
4775
+ classMethod: 'getClient',
4776
+ description: 'Send unsuccessful.'
4777
+ }));
4778
+ errorCb(err);
4779
+ };
4640
4780
  request.onload = function () {
4641
4781
  return _this4.parser({
4642
4782
  text: request.responseText,
4643
4783
  status: request.status
4644
- }, cb, function (err) {
4645
- _this4.reportError(errorRepository, err, _extends(_extends({}, _this4.ctx), {
4646
- classMethod: 'getClient',
4647
- description: 'Send unsuccessful.'
4648
- }));
4649
- errorCb(err);
4650
- });
4784
+ }, cb, onError);
4651
4785
  };
4786
+ // Transport-level failures (dropped connection, failed CORS
4787
+ // preflight, HTTP/2 protocol error, timeout) never fire `onload`,
4788
+ // so without these handlers the request would fail silently.
4789
+ _this4.attachFailureHandlers(request, onError);
4652
4790
  request.send(JSON.stringify(body));
4653
4791
  }
4654
4792
  };
@@ -4661,13 +4799,18 @@ var ApiBase = /*#__PURE__*/function () {
4661
4799
  return {
4662
4800
  config: request,
4663
4801
  send: function send(body) {
4664
- return new Promise(function (resolve, _reject) {
4802
+ return new Promise(function (resolve, reject) {
4665
4803
  request.onload = function () {
4666
4804
  return resolve({
4667
4805
  text: request.responseText,
4668
4806
  status: request.status
4669
4807
  });
4670
4808
  };
4809
+ // Transport-level failures (dropped connection, failed CORS
4810
+ // preflight, HTTP/2 protocol error, timeout) never fire
4811
+ // `onload`, so without these handlers the promise would never
4812
+ // settle and the caller would hang silently.
4813
+ _this5.attachFailureHandlers(request, reject);
4671
4814
  request.send(JSON.stringify(body));
4672
4815
  }).then(function (value) {
4673
4816
  return _this5.parserPromise(value);
@@ -4719,6 +4862,36 @@ var ApiBase = /*#__PURE__*/function () {
4719
4862
  return Promise.reject(err);
4720
4863
  }
4721
4864
  }
4865
+ /**
4866
+ * Wires the XHR failure events that `onload` does not cover. `onload` only
4867
+ * fires when an HTTP response is received (any status, including 4xx/5xx);
4868
+ * transport-level failures — a dropped connection, a failed CORS preflight,
4869
+ * an HTTP/2 protocol error, or a timeout — fire `onerror`/`ontimeout`/
4870
+ * `onabort` instead. Without these the request never settles and fails
4871
+ * silently (e.g. `onUnavailable` is never invoked for wallet callbacks).
4872
+ */
4873
+ }, {
4874
+ key: "attachFailureHandlers",
4875
+ value: function attachFailureHandlers(request, onFailure) {
4876
+ request.onerror = function () {
4877
+ return onFailure({
4878
+ message: 'Network request failed: the service could not be reached.',
4879
+ code: ERROR_CAUSE.SERVICE_UNREACHABLE
4880
+ });
4881
+ };
4882
+ request.ontimeout = function () {
4883
+ return onFailure({
4884
+ message: 'Network request timed out: the service could not be reached.',
4885
+ code: ERROR_CAUSE.SERVICE_UNREACHABLE
4886
+ });
4887
+ };
4888
+ request.onabort = function () {
4889
+ return onFailure({
4890
+ message: 'Network request was aborted.',
4891
+ code: ERROR_CAUSE.ABORTED
4892
+ });
4893
+ };
4894
+ }
4722
4895
  }, {
4723
4896
  key: "newApiRequest",
4724
4897
  value: function newApiRequest(method, link) {
@@ -12867,139 +13040,6 @@ function getHandleCvv(configuration) {
12867
13040
  }
12868
13041
  }
12869
13042
 
12870
- /**
12871
- * Top-level classification of an error. Used by the SDK to route errors to the
12872
- * right category in instrumentation and to give consumers a coarse-grained
12873
- * tag for grouping/filtering. See {@link getErrorCategory} for the mapping
12874
- * between {@link ERROR_CAUSE} and {@link ERROR_CATEGORY}.
12875
- */
12876
- var ERROR_CATEGORY = {
12877
- /** SDK was misconfigured (missing keys, invalid options, etc.). */
12878
- CONFIGURATION: 'configuration',
12879
- /** Authentication or authorization failure. */
12880
- IDENTITY: 'identity_access_management',
12881
- /** SDK internal failure or upstream service problem. */
12882
- INTERNAL: 'internal',
12883
- /** Flow lifecycle event (user cancelled, aborted, etc.) — not a real fault. */
12884
- PROCESS: 'process',
12885
- /** Resource lookup failed or was rate-limited. */
12886
- RESOURCE: 'resource',
12887
- /** Invalid input or business-rule validation failure. */
12888
- VALIDATION: 'validation'
12889
- };
12890
- /**
12891
- * Concrete cause of an error. More specific than {@link ERROR_CATEGORY} —
12892
- * useful for deciding programmatic responses (e.g. show a retry button only
12893
- * when `cause` is `'service_unreachable'` or `'server_busy'`).
12894
- */
12895
- var ERROR_CAUSE = {
12896
- /** Operation was aborted programmatically. */
12897
- ABORTED: 'aborted',
12898
- /** Caller has insufficient permissions for the operation. */
12899
- ACCESS_FORBIDDEN: 'access_forbidden',
12900
- /** Resource already exists when create was expected. */
12901
- ALREADY_EXISTS: 'already_exists',
12902
- /** User cancelled the flow (e.g. closed the wallet sheet). */
12903
- CANCELED: 'canceled',
12904
- /** SDK was instantiated or invoked with invalid configuration. */
12905
- INVALID_CONFIGURATION: 'invalid_configuration',
12906
- /** Input failed structural or business-rule validation. */
12907
- INVALID_INPUT: 'invalid_input',
12908
- /** Resource was not found by the backend. */
12909
- NOT_FOUND: 'not_found',
12910
- /** Operation is not supported in the current context or version. */
12911
- NOT_IMPLEMENTED: 'not_implemented',
12912
- /** Caller exceeded the allowed request rate. */
12913
- RATE_LIMITED: 'rate_limited',
12914
- /** Backend is healthy but currently overloaded — typically retryable. */
12915
- SERVER_BUSY: 'server_busy',
12916
- /** Backend or third-party service could not be reached — typically retryable. */
12917
- SERVICE_UNREACHABLE: 'service_unreachable',
12918
- /** Caller is not authenticated. */
12919
- UNAUTHORIZED: 'unauthorized',
12920
- /** Catch-all when no other cause applies. */
12921
- UNKNOWN: 'unknown_error',
12922
- /** Request was syntactically valid but semantically rejected. */
12923
- UNPROCESSABLE_ENTITY: 'unprocessable_entity'
12924
- };
12925
- var EventError = /*#__PURE__*/function (_Error) {
12926
- function EventError(cause, category, retryable, details) {
12927
- var _this;
12928
- _classCallCheck(this, EventError);
12929
- _this = _callSuper(this, EventError, [details.message]);
12930
- _this.cause = cause;
12931
- _this.category = category;
12932
- _this.retryable = retryable;
12933
- _this.details = details;
12934
- Object.setPrototypeOf(_this, EventError.prototype);
12935
- _this.name = EventError.name;
12936
- return _this;
12937
- }
12938
- _inherits(EventError, _Error);
12939
- return _createClass(EventError, [{
12940
- key: "toJSON",
12941
- value: function toJSON() {
12942
- return {
12943
- error: {
12944
- category: this.category,
12945
- cause: this.cause,
12946
- details: this.details,
12947
- retryable: this.retryable
12948
- }
12949
- };
12950
- }
12951
- }, {
12952
- key: "setContextId",
12953
- value: function setContextId(contextId) {
12954
- this.details.contextId = contextId;
12955
- }
12956
- }, {
12957
- key: "setPurpose",
12958
- value: function setPurpose(purpose) {
12959
- this.purpose = purpose;
12960
- }
12961
- }], [{
12962
- key: "create",
12963
- value: function create(cause, message) {
12964
- var contextId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
12965
- var retryable = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
12966
- var details = {
12967
- cause: cause,
12968
- contextId: contextId,
12969
- message: message,
12970
- timestamp: new Date().toISOString()
12971
- };
12972
- var category = getErrorCategory(cause);
12973
- return new EventError(cause, category, retryable, details);
12974
- }
12975
- }]);
12976
- }(/*#__PURE__*/_wrapNativeSuper(Error));
12977
- function getErrorCategory(cause) {
12978
- switch (cause) {
12979
- case ERROR_CAUSE.INVALID_CONFIGURATION:
12980
- return ERROR_CATEGORY.CONFIGURATION;
12981
- case ERROR_CAUSE.ACCESS_FORBIDDEN:
12982
- case ERROR_CAUSE.UNAUTHORIZED:
12983
- return ERROR_CATEGORY.IDENTITY;
12984
- case ERROR_CAUSE.SERVICE_UNREACHABLE:
12985
- case ERROR_CAUSE.NOT_IMPLEMENTED:
12986
- case ERROR_CAUSE.SERVER_BUSY:
12987
- return ERROR_CATEGORY.INTERNAL;
12988
- case ERROR_CAUSE.ABORTED:
12989
- case ERROR_CAUSE.CANCELED:
12990
- return ERROR_CATEGORY.PROCESS;
12991
- case ERROR_CAUSE.NOT_FOUND:
12992
- case ERROR_CAUSE.RATE_LIMITED:
12993
- return ERROR_CATEGORY.RESOURCE;
12994
- case ERROR_CAUSE.ALREADY_EXISTS:
12995
- case ERROR_CAUSE.INVALID_INPUT:
12996
- case ERROR_CAUSE.UNPROCESSABLE_ENTITY:
12997
- return ERROR_CATEGORY.VALIDATION;
12998
- default:
12999
- return ERROR_CATEGORY.INTERNAL;
13000
- }
13001
- }
13002
-
13003
13043
  function processEventError(err) {
13004
13044
  var cause;
13005
13045
  var message;
@@ -22897,6 +22937,14 @@ var SRC = /*#__PURE__*/function () {
22897
22937
  if (_this.provider) {
22898
22938
  _this.provider.load();
22899
22939
  }
22940
+ })["catch"](function (error) {
22941
+ var _a;
22942
+ // Surface config-load failures (including transport-level ones now
22943
+ // rejected by ApiBase) instead of leaving the widget hung silently.
22944
+ _this.eventEmitter.emit(EVENT.CHECKOUT_ERROR, {
22945
+ type: EVENT_DATA_TYPE.CRITICAL_ERROR,
22946
+ data: (_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : 'Failed to load Click to Pay configuration.'
22947
+ });
22900
22948
  });
22901
22949
  }
22902
22950
  /**