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