@authsignal/browser 1.12.6 → 1.13.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/dist/api/types/shared.d.ts +7 -3
- package/dist/authsignal.d.ts +2 -1
- package/dist/email-magic-link.d.ts +3 -1
- package/dist/email.d.ts +3 -1
- package/dist/handlers/popup-handler.d.ts +4 -2
- package/dist/helpers.d.ts +18 -4
- package/dist/index.js +139 -70
- package/dist/index.min.js +1 -1
- package/dist/passkey.d.ts +3 -1
- package/dist/push.d.ts +3 -1
- package/dist/qr-code/rest-qr-handler.d.ts +3 -1
- package/dist/qr-code/websocket-qr-handler.d.ts +3 -1
- package/dist/qr-code.d.ts +3 -1
- package/dist/security-key.d.ts +3 -1
- package/dist/sms.d.ts +3 -1
- package/dist/token-cache.d.ts +6 -2
- package/dist/totp.d.ts +3 -1
- package/dist/types.d.ts +16 -6
- package/dist/whatsapp.d.ts +3 -1
- package/package.json +8 -3
package/dist/index.js
CHANGED
|
@@ -764,21 +764,31 @@ function getCookie(name) {
|
|
|
764
764
|
}
|
|
765
765
|
return (decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + encodeURIComponent(name).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null);
|
|
766
766
|
}
|
|
767
|
-
function handleErrorResponse(
|
|
768
|
-
var
|
|
769
|
-
var
|
|
770
|
-
|
|
767
|
+
function handleErrorResponse(_a) {
|
|
768
|
+
var _b;
|
|
769
|
+
var errorResponse = _a.errorResponse, enableLogging = _a.enableLogging;
|
|
770
|
+
if (enableLogging) {
|
|
771
|
+
console.error("[Authsignal] ".concat(errorResponse.errorCode).concat(errorResponse.errorDescription ? ": ".concat(errorResponse.errorDescription) : ""));
|
|
772
|
+
}
|
|
773
|
+
var error = (_b = errorResponse.errorDescription) !== null && _b !== void 0 ? _b : errorResponse.error;
|
|
771
774
|
return {
|
|
772
775
|
error: error,
|
|
776
|
+
errorCode: errorResponse.errorCode,
|
|
777
|
+
errorDescription: errorResponse.errorDescription,
|
|
773
778
|
};
|
|
774
779
|
}
|
|
775
|
-
function handleApiResponse(
|
|
776
|
-
var
|
|
780
|
+
function handleApiResponse(_a) {
|
|
781
|
+
var _b;
|
|
782
|
+
var response = _a.response, enableLogging = _a.enableLogging;
|
|
777
783
|
if (response && typeof response === "object" && "error" in response) {
|
|
778
|
-
var error = (
|
|
779
|
-
|
|
784
|
+
var error = (_b = response.errorDescription) !== null && _b !== void 0 ? _b : response.error;
|
|
785
|
+
if (enableLogging) {
|
|
786
|
+
console.error("[Authsignal] ".concat(response.errorCode).concat(response.errorDescription ? ": ".concat(response.errorDescription) : ""));
|
|
787
|
+
}
|
|
780
788
|
return {
|
|
781
789
|
error: error,
|
|
790
|
+
errorCode: response.errorCode,
|
|
791
|
+
errorDescription: response.errorDescription,
|
|
782
792
|
};
|
|
783
793
|
}
|
|
784
794
|
else if (response &&
|
|
@@ -808,6 +818,14 @@ var AuthsignalWindowMessage;
|
|
|
808
818
|
(function (AuthsignalWindowMessage) {
|
|
809
819
|
AuthsignalWindowMessage["AUTHSIGNAL_CLOSE_POPUP"] = "AUTHSIGNAL_CLOSE_POPUP";
|
|
810
820
|
})(AuthsignalWindowMessage || (AuthsignalWindowMessage = {}));
|
|
821
|
+
var ErrorCode;
|
|
822
|
+
(function (ErrorCode) {
|
|
823
|
+
ErrorCode["token_not_set"] = "token_not_set";
|
|
824
|
+
ErrorCode["expired_token"] = "expired_token";
|
|
825
|
+
ErrorCode["network_error"] = "network_error";
|
|
826
|
+
ErrorCode["too_many_requests"] = "too_many_requests";
|
|
827
|
+
ErrorCode["invalid_credential"] = "invalid_credential";
|
|
828
|
+
})(ErrorCode || (ErrorCode = {}));
|
|
811
829
|
|
|
812
830
|
function buildHeaders(_a) {
|
|
813
831
|
var token = _a.token, tenantId = _a.tenantId;
|
|
@@ -1015,12 +1033,13 @@ var TokenCache = /** @class */ (function () {
|
|
|
1015
1033
|
this.token = null;
|
|
1016
1034
|
}
|
|
1017
1035
|
TokenCache.prototype.handleTokenNotSetError = function () {
|
|
1018
|
-
var
|
|
1019
|
-
var
|
|
1020
|
-
console.error("Error: ".concat(
|
|
1036
|
+
var errorCode = ErrorCode.token_not_set;
|
|
1037
|
+
var errorDescription = "A token has not been set. Call 'setToken' first.";
|
|
1038
|
+
console.error("Error: ".concat(errorDescription));
|
|
1021
1039
|
return {
|
|
1022
1040
|
error: errorCode,
|
|
1023
|
-
|
|
1041
|
+
errorCode: errorCode,
|
|
1042
|
+
errorDescription: errorDescription,
|
|
1024
1043
|
};
|
|
1025
1044
|
};
|
|
1026
1045
|
TokenCache.shared = new TokenCache();
|
|
@@ -1030,11 +1049,13 @@ var TokenCache = /** @class */ (function () {
|
|
|
1030
1049
|
var autofillRequestPending = false;
|
|
1031
1050
|
var Passkey = /** @class */ (function () {
|
|
1032
1051
|
function Passkey(_a) {
|
|
1033
|
-
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, anonymousId = _a.anonymousId, onTokenExpired = _a.onTokenExpired;
|
|
1052
|
+
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, anonymousId = _a.anonymousId, onTokenExpired = _a.onTokenExpired, enableLogging = _a.enableLogging;
|
|
1034
1053
|
this.passkeyLocalStorageKey = "as_user_passkey_map";
|
|
1035
1054
|
this.cache = TokenCache.shared;
|
|
1055
|
+
this.enableLogging = false;
|
|
1036
1056
|
this.api = new PasskeyApiClient({ baseUrl: baseUrl, tenantId: tenantId, onTokenExpired: onTokenExpired });
|
|
1037
1057
|
this.anonymousId = anonymousId;
|
|
1058
|
+
this.enableLogging = enableLogging;
|
|
1038
1059
|
}
|
|
1039
1060
|
Passkey.prototype.signUp = function (_a) {
|
|
1040
1061
|
return __awaiter(this, arguments, void 0, function (_b) {
|
|
@@ -1066,7 +1087,7 @@ var Passkey = /** @class */ (function () {
|
|
|
1066
1087
|
case 3:
|
|
1067
1088
|
optionsResponse = _f.sent();
|
|
1068
1089
|
if ("error" in optionsResponse) {
|
|
1069
|
-
return [2 /*return*/, handleErrorResponse(optionsResponse)];
|
|
1090
|
+
return [2 /*return*/, handleErrorResponse({ errorResponse: optionsResponse, enableLogging: this.enableLogging })];
|
|
1070
1091
|
}
|
|
1071
1092
|
_f.label = 4;
|
|
1072
1093
|
case 4:
|
|
@@ -1084,7 +1105,7 @@ var Passkey = /** @class */ (function () {
|
|
|
1084
1105
|
case 6:
|
|
1085
1106
|
addAuthenticatorResponse = _f.sent();
|
|
1086
1107
|
if ("error" in addAuthenticatorResponse) {
|
|
1087
|
-
return [2 /*return*/, handleErrorResponse(addAuthenticatorResponse)];
|
|
1108
|
+
return [2 /*return*/, handleErrorResponse({ errorResponse: addAuthenticatorResponse, enableLogging: this.enableLogging })];
|
|
1088
1109
|
}
|
|
1089
1110
|
if (addAuthenticatorResponse.isVerified) {
|
|
1090
1111
|
this.storeCredentialAgainstDevice(__assign(__assign({}, registrationResponse), { userId: addAuthenticatorResponse.userId }));
|
|
@@ -1141,7 +1162,7 @@ var Passkey = /** @class */ (function () {
|
|
|
1141
1162
|
challengeResponse = _a;
|
|
1142
1163
|
if (challengeResponse && "error" in challengeResponse) {
|
|
1143
1164
|
autofillRequestPending = false;
|
|
1144
|
-
return [2 /*return*/, handleErrorResponse(challengeResponse)];
|
|
1165
|
+
return [2 /*return*/, handleErrorResponse({ errorResponse: challengeResponse, enableLogging: this.enableLogging })];
|
|
1145
1166
|
}
|
|
1146
1167
|
if (!((params === null || params === void 0 ? void 0 : params.action) || !(params === null || params === void 0 ? void 0 : params.useCookies))) return [3 /*break*/, 5];
|
|
1147
1168
|
return [4 /*yield*/, this.api.authenticationOptions({
|
|
@@ -1160,7 +1181,7 @@ var Passkey = /** @class */ (function () {
|
|
|
1160
1181
|
optionsResponse = _b;
|
|
1161
1182
|
if ("error" in optionsResponse) {
|
|
1162
1183
|
autofillRequestPending = false;
|
|
1163
|
-
return [2 /*return*/, handleErrorResponse(optionsResponse)];
|
|
1184
|
+
return [2 /*return*/, handleErrorResponse({ errorResponse: optionsResponse, enableLogging: this.enableLogging })];
|
|
1164
1185
|
}
|
|
1165
1186
|
_c.label = 8;
|
|
1166
1187
|
case 8:
|
|
@@ -1185,7 +1206,7 @@ var Passkey = /** @class */ (function () {
|
|
|
1185
1206
|
verifyResponse = _c.sent();
|
|
1186
1207
|
if ("error" in verifyResponse) {
|
|
1187
1208
|
autofillRequestPending = false;
|
|
1188
|
-
return [2 /*return*/, handleErrorResponse(verifyResponse)];
|
|
1209
|
+
return [2 /*return*/, handleErrorResponse({ errorResponse: verifyResponse, enableLogging: this.enableLogging })];
|
|
1189
1210
|
}
|
|
1190
1211
|
if (verifyResponse.isVerified) {
|
|
1191
1212
|
this.storeCredentialAgainstDevice(__assign(__assign({}, authenticationResponse), { userId: verifyResponse.userId }));
|
|
@@ -1751,16 +1772,17 @@ var DEFAULT_WIDTH = "385px";
|
|
|
1751
1772
|
var INITIAL_HEIGHT = "384px";
|
|
1752
1773
|
var PopupHandler = /** @class */ (function () {
|
|
1753
1774
|
function PopupHandler(_a) {
|
|
1754
|
-
var width = _a.width, isClosable = _a.isClosable;
|
|
1775
|
+
var width = _a.width, height = _a.height, isClosable = _a.isClosable;
|
|
1755
1776
|
this.popup = null;
|
|
1756
1777
|
if (document.querySelector("#".concat(CONTAINER_ID))) {
|
|
1757
1778
|
throw new Error("Multiple instances of Authsignal popup is not supported.");
|
|
1758
1779
|
}
|
|
1759
|
-
this.
|
|
1780
|
+
this.height = height;
|
|
1781
|
+
this.create({ width: width, height: height, isClosable: isClosable });
|
|
1760
1782
|
}
|
|
1761
1783
|
PopupHandler.prototype.create = function (_a) {
|
|
1762
1784
|
var _this = this;
|
|
1763
|
-
var _b = _a.width, width = _b === void 0 ? DEFAULT_WIDTH : _b, _c = _a.isClosable, isClosable = _c === void 0 ? true : _c;
|
|
1785
|
+
var _b = _a.width, width = _b === void 0 ? DEFAULT_WIDTH : _b, height = _a.height, _c = _a.isClosable, isClosable = _c === void 0 ? true : _c;
|
|
1764
1786
|
var isWidthValidCSSValue = CSS.supports("width", width);
|
|
1765
1787
|
var popupWidth = width;
|
|
1766
1788
|
if (!isWidthValidCSSValue) {
|
|
@@ -1787,7 +1809,7 @@ var PopupHandler = /** @class */ (function () {
|
|
|
1787
1809
|
// Create CSS for dialog
|
|
1788
1810
|
var style = document.createElement("style");
|
|
1789
1811
|
style.setAttribute("id", STYLE_ID);
|
|
1790
|
-
style.textContent = "\n #".concat(CONTAINER_ID, ",\n #").concat(OVERLAY_ID, " {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n }\n\n #").concat(CONTAINER_ID, " {\n z-index: 2147483647;\n display: flex;\n }\n\n #").concat(CONTAINER_ID, "[aria-hidden='true'] {\n display: none;\n }\n\n #").concat(OVERLAY_ID, " {\n background-color: rgba(0, 0, 0, 0.18);\n }\n\n #").concat(CONTENT_ID, " {\n margin: auto;\n z-index: 2147483647;\n position: relative;\n background-color: transparent;\n border-radius: 8px;\n width: ").concat(popupWidth, ";\n }\n\n #").concat(CONTENT_ID, " iframe {\n width: 1px;\n min-width: 100%;\n border-radius: inherit;\n max-height: 95vh;\n height: ").concat(INITIAL_HEIGHT, ";\n }\n ");
|
|
1812
|
+
style.textContent = "\n #".concat(CONTAINER_ID, ",\n #").concat(OVERLAY_ID, " {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n }\n\n #").concat(CONTAINER_ID, " {\n z-index: 2147483647;\n display: flex;\n }\n\n #").concat(CONTAINER_ID, "[aria-hidden='true'] {\n display: none;\n }\n\n #").concat(OVERLAY_ID, " {\n background-color: rgba(0, 0, 0, 0.18);\n }\n\n #").concat(CONTENT_ID, " {\n margin: auto;\n z-index: 2147483647;\n position: relative;\n background-color: transparent;\n border-radius: 8px;\n width: ").concat(popupWidth, ";\n }\n\n #").concat(CONTENT_ID, " iframe {\n width: 1px;\n min-width: 100%;\n border-radius: inherit;\n max-height: ").concat(height ? "100%" : "95vh", ";\n height: ").concat(height !== null && height !== void 0 ? height : INITIAL_HEIGHT, ";\n }\n ");
|
|
1791
1813
|
// Attach the created elements
|
|
1792
1814
|
document.head.insertAdjacentElement("beforeend", style);
|
|
1793
1815
|
container.appendChild(overlay);
|
|
@@ -1828,7 +1850,10 @@ var PopupHandler = /** @class */ (function () {
|
|
|
1828
1850
|
if (dialogContent) {
|
|
1829
1851
|
dialogContent.appendChild(iframe);
|
|
1830
1852
|
}
|
|
1831
|
-
|
|
1853
|
+
// Dynamic resizing if no height is set.
|
|
1854
|
+
if (!this.height) {
|
|
1855
|
+
window.addEventListener("message", resizeIframe);
|
|
1856
|
+
}
|
|
1832
1857
|
(_b = this.popup) === null || _b === void 0 ? void 0 : _b.show();
|
|
1833
1858
|
};
|
|
1834
1859
|
PopupHandler.prototype.close = function () {
|
|
@@ -1845,6 +1870,10 @@ var PopupHandler = /** @class */ (function () {
|
|
|
1845
1870
|
};
|
|
1846
1871
|
return PopupHandler;
|
|
1847
1872
|
}());
|
|
1873
|
+
/**
|
|
1874
|
+
* Resize the iframe to the height of the pre-built UI's (#widget_container)
|
|
1875
|
+
* @param event MessageEvent
|
|
1876
|
+
*/
|
|
1848
1877
|
function resizeIframe(event) {
|
|
1849
1878
|
var iframeEl = document.querySelector("#".concat(IFRAME_ID));
|
|
1850
1879
|
if (iframeEl && event.data.height) {
|
|
@@ -1909,8 +1938,10 @@ var TotpApiClient = /** @class */ (function () {
|
|
|
1909
1938
|
|
|
1910
1939
|
var Totp = /** @class */ (function () {
|
|
1911
1940
|
function Totp(_a) {
|
|
1912
|
-
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, onTokenExpired = _a.onTokenExpired;
|
|
1941
|
+
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, onTokenExpired = _a.onTokenExpired, enableLogging = _a.enableLogging;
|
|
1913
1942
|
this.cache = TokenCache.shared;
|
|
1943
|
+
this.enableLogging = false;
|
|
1944
|
+
this.enableLogging = enableLogging;
|
|
1914
1945
|
this.api = new TotpApiClient({ baseUrl: baseUrl, tenantId: tenantId, onTokenExpired: onTokenExpired });
|
|
1915
1946
|
}
|
|
1916
1947
|
Totp.prototype.enroll = function () {
|
|
@@ -1925,7 +1956,7 @@ var Totp = /** @class */ (function () {
|
|
|
1925
1956
|
return [4 /*yield*/, this.api.enroll({ token: this.cache.token })];
|
|
1926
1957
|
case 1:
|
|
1927
1958
|
response = _a.sent();
|
|
1928
|
-
return [2 /*return*/, handleApiResponse(response)];
|
|
1959
|
+
return [2 /*return*/, handleApiResponse({ response: response, enableLogging: this.enableLogging })];
|
|
1929
1960
|
}
|
|
1930
1961
|
});
|
|
1931
1962
|
});
|
|
@@ -1946,7 +1977,7 @@ var Totp = /** @class */ (function () {
|
|
|
1946
1977
|
if ("accessToken" in response && response.accessToken) {
|
|
1947
1978
|
this.cache.token = response.accessToken;
|
|
1948
1979
|
}
|
|
1949
|
-
return [2 /*return*/, handleApiResponse(response)];
|
|
1980
|
+
return [2 /*return*/, handleApiResponse({ response: response, enableLogging: this.enableLogging })];
|
|
1950
1981
|
}
|
|
1951
1982
|
});
|
|
1952
1983
|
});
|
|
@@ -2035,8 +2066,10 @@ var EmailApiClient = /** @class */ (function () {
|
|
|
2035
2066
|
|
|
2036
2067
|
var Email = /** @class */ (function () {
|
|
2037
2068
|
function Email(_a) {
|
|
2038
|
-
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, onTokenExpired = _a.onTokenExpired;
|
|
2069
|
+
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, onTokenExpired = _a.onTokenExpired, enableLogging = _a.enableLogging;
|
|
2039
2070
|
this.cache = TokenCache.shared;
|
|
2071
|
+
this.enableLogging = false;
|
|
2072
|
+
this.enableLogging = enableLogging;
|
|
2040
2073
|
this.api = new EmailApiClient({ baseUrl: baseUrl, tenantId: tenantId, onTokenExpired: onTokenExpired });
|
|
2041
2074
|
}
|
|
2042
2075
|
Email.prototype.enroll = function (_a) {
|
|
@@ -2052,7 +2085,7 @@ var Email = /** @class */ (function () {
|
|
|
2052
2085
|
return [4 /*yield*/, this.api.enroll({ token: this.cache.token, email: email })];
|
|
2053
2086
|
case 1:
|
|
2054
2087
|
response = _c.sent();
|
|
2055
|
-
return [2 /*return*/, handleApiResponse(response)];
|
|
2088
|
+
return [2 /*return*/, handleApiResponse({ response: response, enableLogging: this.enableLogging })];
|
|
2056
2089
|
}
|
|
2057
2090
|
});
|
|
2058
2091
|
});
|
|
@@ -2069,7 +2102,7 @@ var Email = /** @class */ (function () {
|
|
|
2069
2102
|
return [4 /*yield*/, this.api.challenge({ token: this.cache.token })];
|
|
2070
2103
|
case 1:
|
|
2071
2104
|
response = _a.sent();
|
|
2072
|
-
return [2 /*return*/, handleApiResponse(response)];
|
|
2105
|
+
return [2 /*return*/, handleApiResponse({ response: response, enableLogging: this.enableLogging })];
|
|
2073
2106
|
}
|
|
2074
2107
|
});
|
|
2075
2108
|
});
|
|
@@ -2090,7 +2123,7 @@ var Email = /** @class */ (function () {
|
|
|
2090
2123
|
if ("accessToken" in response && response.accessToken) {
|
|
2091
2124
|
this.cache.token = response.accessToken;
|
|
2092
2125
|
}
|
|
2093
|
-
return [2 /*return*/, handleApiResponse(response)];
|
|
2126
|
+
return [2 /*return*/, handleApiResponse({ response: response, enableLogging: this.enableLogging })];
|
|
2094
2127
|
}
|
|
2095
2128
|
});
|
|
2096
2129
|
});
|
|
@@ -2179,8 +2212,10 @@ var SmsApiClient = /** @class */ (function () {
|
|
|
2179
2212
|
|
|
2180
2213
|
var Sms = /** @class */ (function () {
|
|
2181
2214
|
function Sms(_a) {
|
|
2182
|
-
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, onTokenExpired = _a.onTokenExpired;
|
|
2215
|
+
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, onTokenExpired = _a.onTokenExpired, enableLogging = _a.enableLogging;
|
|
2183
2216
|
this.cache = TokenCache.shared;
|
|
2217
|
+
this.enableLogging = false;
|
|
2218
|
+
this.enableLogging = enableLogging;
|
|
2184
2219
|
this.api = new SmsApiClient({ baseUrl: baseUrl, tenantId: tenantId, onTokenExpired: onTokenExpired });
|
|
2185
2220
|
}
|
|
2186
2221
|
Sms.prototype.enroll = function (_a) {
|
|
@@ -2196,7 +2231,7 @@ var Sms = /** @class */ (function () {
|
|
|
2196
2231
|
return [4 /*yield*/, this.api.enroll({ token: this.cache.token, phoneNumber: phoneNumber })];
|
|
2197
2232
|
case 1:
|
|
2198
2233
|
response = _c.sent();
|
|
2199
|
-
return [2 /*return*/, handleApiResponse(response)];
|
|
2234
|
+
return [2 /*return*/, handleApiResponse({ response: response, enableLogging: this.enableLogging })];
|
|
2200
2235
|
}
|
|
2201
2236
|
});
|
|
2202
2237
|
});
|
|
@@ -2213,7 +2248,7 @@ var Sms = /** @class */ (function () {
|
|
|
2213
2248
|
return [4 /*yield*/, this.api.challenge({ token: this.cache.token })];
|
|
2214
2249
|
case 1:
|
|
2215
2250
|
response = _a.sent();
|
|
2216
|
-
return [2 /*return*/, handleApiResponse(response)];
|
|
2251
|
+
return [2 /*return*/, handleApiResponse({ response: response, enableLogging: this.enableLogging })];
|
|
2217
2252
|
}
|
|
2218
2253
|
});
|
|
2219
2254
|
});
|
|
@@ -2234,7 +2269,7 @@ var Sms = /** @class */ (function () {
|
|
|
2234
2269
|
if ("accessToken" in response && response.accessToken) {
|
|
2235
2270
|
this.cache.token = response.accessToken;
|
|
2236
2271
|
}
|
|
2237
|
-
return [2 /*return*/, handleApiResponse(response)];
|
|
2272
|
+
return [2 /*return*/, handleApiResponse({ response: response, enableLogging: this.enableLogging })];
|
|
2238
2273
|
}
|
|
2239
2274
|
});
|
|
2240
2275
|
});
|
|
@@ -2352,8 +2387,10 @@ var EmailMagicLinkApiClient = /** @class */ (function () {
|
|
|
2352
2387
|
|
|
2353
2388
|
var EmailMagicLink = /** @class */ (function () {
|
|
2354
2389
|
function EmailMagicLink(_a) {
|
|
2355
|
-
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, onTokenExpired = _a.onTokenExpired;
|
|
2390
|
+
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, onTokenExpired = _a.onTokenExpired, enableLogging = _a.enableLogging;
|
|
2356
2391
|
this.cache = TokenCache.shared;
|
|
2392
|
+
this.enableLogging = false;
|
|
2393
|
+
this.enableLogging = enableLogging;
|
|
2357
2394
|
this.api = new EmailMagicLinkApiClient({ baseUrl: baseUrl, tenantId: tenantId, onTokenExpired: onTokenExpired });
|
|
2358
2395
|
}
|
|
2359
2396
|
EmailMagicLink.prototype.enroll = function (_a) {
|
|
@@ -2369,7 +2406,7 @@ var EmailMagicLink = /** @class */ (function () {
|
|
|
2369
2406
|
return [4 /*yield*/, this.api.enroll({ token: this.cache.token, email: email })];
|
|
2370
2407
|
case 1:
|
|
2371
2408
|
response = _c.sent();
|
|
2372
|
-
return [2 /*return*/, handleApiResponse(response)];
|
|
2409
|
+
return [2 /*return*/, handleApiResponse({ response: response, enableLogging: this.enableLogging })];
|
|
2373
2410
|
}
|
|
2374
2411
|
});
|
|
2375
2412
|
});
|
|
@@ -2386,7 +2423,7 @@ var EmailMagicLink = /** @class */ (function () {
|
|
|
2386
2423
|
return [4 /*yield*/, this.api.challenge({ token: this.cache.token })];
|
|
2387
2424
|
case 1:
|
|
2388
2425
|
response = _a.sent();
|
|
2389
|
-
return [2 /*return*/, handleApiResponse(response)];
|
|
2426
|
+
return [2 /*return*/, handleApiResponse({ response: response, enableLogging: this.enableLogging })];
|
|
2390
2427
|
}
|
|
2391
2428
|
});
|
|
2392
2429
|
});
|
|
@@ -2406,7 +2443,7 @@ var EmailMagicLink = /** @class */ (function () {
|
|
|
2406
2443
|
if ("accessToken" in response && response.accessToken) {
|
|
2407
2444
|
this.cache.token = response.accessToken;
|
|
2408
2445
|
}
|
|
2409
|
-
return [2 /*return*/, handleApiResponse(response)];
|
|
2446
|
+
return [2 /*return*/, handleApiResponse({ response: response, enableLogging: this.enableLogging })];
|
|
2410
2447
|
}
|
|
2411
2448
|
});
|
|
2412
2449
|
});
|
|
@@ -2514,9 +2551,11 @@ var SecurityKeyApiClient = /** @class */ (function () {
|
|
|
2514
2551
|
|
|
2515
2552
|
var SecurityKey = /** @class */ (function () {
|
|
2516
2553
|
function SecurityKey(_a) {
|
|
2517
|
-
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, onTokenExpired = _a.onTokenExpired;
|
|
2554
|
+
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, onTokenExpired = _a.onTokenExpired, enableLogging = _a.enableLogging;
|
|
2518
2555
|
this.cache = TokenCache.shared;
|
|
2556
|
+
this.enableLogging = false;
|
|
2519
2557
|
this.api = new SecurityKeyApiClient({ baseUrl: baseUrl, tenantId: tenantId, onTokenExpired: onTokenExpired });
|
|
2558
|
+
this.enableLogging = enableLogging;
|
|
2520
2559
|
}
|
|
2521
2560
|
SecurityKey.prototype.enroll = function () {
|
|
2522
2561
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -2534,7 +2573,7 @@ var SecurityKey = /** @class */ (function () {
|
|
|
2534
2573
|
case 1:
|
|
2535
2574
|
optionsResponse = _a.sent();
|
|
2536
2575
|
if ("error" in optionsResponse) {
|
|
2537
|
-
return [2 /*return*/, handleErrorResponse(optionsResponse)];
|
|
2576
|
+
return [2 /*return*/, handleErrorResponse({ errorResponse: optionsResponse, enableLogging: this.enableLogging })];
|
|
2538
2577
|
}
|
|
2539
2578
|
_a.label = 2;
|
|
2540
2579
|
case 2:
|
|
@@ -2549,7 +2588,7 @@ var SecurityKey = /** @class */ (function () {
|
|
|
2549
2588
|
case 4:
|
|
2550
2589
|
addAuthenticatorResponse = _a.sent();
|
|
2551
2590
|
if ("error" in addAuthenticatorResponse) {
|
|
2552
|
-
return [2 /*return*/, handleErrorResponse(addAuthenticatorResponse)];
|
|
2591
|
+
return [2 /*return*/, handleErrorResponse({ errorResponse: addAuthenticatorResponse, enableLogging: this.enableLogging })];
|
|
2553
2592
|
}
|
|
2554
2593
|
if (addAuthenticatorResponse.accessToken) {
|
|
2555
2594
|
this.cache.token = addAuthenticatorResponse.accessToken;
|
|
@@ -2584,7 +2623,7 @@ var SecurityKey = /** @class */ (function () {
|
|
|
2584
2623
|
case 1:
|
|
2585
2624
|
optionsResponse = _a.sent();
|
|
2586
2625
|
if ("error" in optionsResponse) {
|
|
2587
|
-
return [2 /*return*/, handleErrorResponse(optionsResponse)];
|
|
2626
|
+
return [2 /*return*/, handleErrorResponse({ errorResponse: optionsResponse, enableLogging: this.enableLogging })];
|
|
2588
2627
|
}
|
|
2589
2628
|
_a.label = 2;
|
|
2590
2629
|
case 2:
|
|
@@ -2601,7 +2640,7 @@ var SecurityKey = /** @class */ (function () {
|
|
|
2601
2640
|
case 4:
|
|
2602
2641
|
verifyResponse = _a.sent();
|
|
2603
2642
|
if ("error" in verifyResponse) {
|
|
2604
|
-
return [2 /*return*/, handleErrorResponse(verifyResponse)];
|
|
2643
|
+
return [2 /*return*/, handleErrorResponse({ errorResponse: verifyResponse, enableLogging: this.enableLogging })];
|
|
2605
2644
|
}
|
|
2606
2645
|
if (verifyResponse.accessToken) {
|
|
2607
2646
|
this.cache.token = verifyResponse.accessToken;
|
|
@@ -2692,9 +2731,11 @@ var DEFAULT_POLL_INTERVAL = 3 * 1000;
|
|
|
2692
2731
|
var RestQrHandler = /** @class */ (function (_super) {
|
|
2693
2732
|
__extends(RestQrHandler, _super);
|
|
2694
2733
|
function RestQrHandler(_a) {
|
|
2695
|
-
var baseUrl = _a.baseUrl, tenantId = _a.tenantId;
|
|
2734
|
+
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, enableLogging = _a.enableLogging;
|
|
2696
2735
|
var _this = _super.call(this) || this;
|
|
2697
2736
|
_this.cache = TokenCache.shared;
|
|
2737
|
+
_this.enableLogging = false;
|
|
2738
|
+
_this.enableLogging = enableLogging;
|
|
2698
2739
|
_this.api = new QrCodeApiClient({ baseUrl: baseUrl, tenantId: tenantId });
|
|
2699
2740
|
return _this;
|
|
2700
2741
|
}
|
|
@@ -2711,7 +2752,7 @@ var RestQrHandler = /** @class */ (function (_super) {
|
|
|
2711
2752
|
})];
|
|
2712
2753
|
case 1:
|
|
2713
2754
|
response = _a.sent();
|
|
2714
|
-
result = handleApiResponse(response);
|
|
2755
|
+
result = handleApiResponse({ response: response, enableLogging: this.enableLogging });
|
|
2715
2756
|
if (result.data) {
|
|
2716
2757
|
this.currentChallengeParams = params;
|
|
2717
2758
|
this.clearPolling();
|
|
@@ -2760,7 +2801,7 @@ var RestQrHandler = /** @class */ (function (_super) {
|
|
|
2760
2801
|
})];
|
|
2761
2802
|
case 1:
|
|
2762
2803
|
response = _d.sent();
|
|
2763
|
-
result = handleApiResponse(response);
|
|
2804
|
+
result = handleApiResponse({ response: response, enableLogging: this.enableLogging });
|
|
2764
2805
|
if (result.data) {
|
|
2765
2806
|
this.clearPolling();
|
|
2766
2807
|
if (this.currentChallengeParams.onRefresh) {
|
|
@@ -2828,7 +2869,7 @@ var RestQrHandler = /** @class */ (function (_super) {
|
|
|
2828
2869
|
case 0: return [4 /*yield*/, this.api.challenge({ token: this.cache.token || undefined, action: action, custom: custom })];
|
|
2829
2870
|
case 1:
|
|
2830
2871
|
response = _c.sent();
|
|
2831
|
-
result = handleApiResponse(response);
|
|
2872
|
+
result = handleApiResponse({ response: response, enableLogging: this.enableLogging });
|
|
2832
2873
|
if (result.data) {
|
|
2833
2874
|
this.clearPolling();
|
|
2834
2875
|
onRefresh(result.data.challengeId, result.data.expiresAt);
|
|
@@ -2856,7 +2897,7 @@ var RestQrHandler = /** @class */ (function (_super) {
|
|
|
2856
2897
|
case 0: return [4 /*yield*/, this.api.verify({ challengeId: challengeId, deviceCode: deviceCode })];
|
|
2857
2898
|
case 1:
|
|
2858
2899
|
response = _a.sent();
|
|
2859
|
-
result = handleApiResponse(response);
|
|
2900
|
+
result = handleApiResponse({ response: response, enableLogging: this.enableLogging });
|
|
2860
2901
|
if (result.data) {
|
|
2861
2902
|
if (result.data.isVerified) {
|
|
2862
2903
|
onStateChange("approved", result.data.token);
|
|
@@ -3110,9 +3151,11 @@ var WebSocketClient = /** @class */ (function () {
|
|
|
3110
3151
|
var WebSocketQrHandler = /** @class */ (function (_super) {
|
|
3111
3152
|
__extends(WebSocketQrHandler, _super);
|
|
3112
3153
|
function WebSocketQrHandler(_a) {
|
|
3113
|
-
var baseUrl = _a.baseUrl, tenantId = _a.tenantId;
|
|
3154
|
+
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, enableLogging = _a.enableLogging;
|
|
3114
3155
|
var _this = _super.call(this) || this;
|
|
3115
3156
|
_this.cache = TokenCache.shared;
|
|
3157
|
+
_this.enableLogging = false;
|
|
3158
|
+
_this.enableLogging = enableLogging;
|
|
3116
3159
|
_this.wsClient = new WebSocketClient({ baseUrl: baseUrl, tenantId: tenantId });
|
|
3117
3160
|
return _this;
|
|
3118
3161
|
}
|
|
@@ -3162,10 +3205,12 @@ var WebSocketQrHandler = /** @class */ (function (_super) {
|
|
|
3162
3205
|
|
|
3163
3206
|
var QrCode = /** @class */ (function () {
|
|
3164
3207
|
function QrCode(_a) {
|
|
3165
|
-
var baseUrl = _a.baseUrl, tenantId = _a.tenantId;
|
|
3208
|
+
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, enableLogging = _a.enableLogging;
|
|
3166
3209
|
this.handler = null;
|
|
3210
|
+
this.enableLogging = false;
|
|
3167
3211
|
this.baseUrl = baseUrl;
|
|
3168
3212
|
this.tenantId = tenantId;
|
|
3213
|
+
this.enableLogging = enableLogging;
|
|
3169
3214
|
}
|
|
3170
3215
|
QrCode.prototype.challenge = function (params) {
|
|
3171
3216
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -3176,10 +3221,18 @@ var QrCode = /** @class */ (function () {
|
|
|
3176
3221
|
this.handler.disconnect();
|
|
3177
3222
|
}
|
|
3178
3223
|
if (polling) {
|
|
3179
|
-
this.handler = new RestQrHandler({
|
|
3224
|
+
this.handler = new RestQrHandler({
|
|
3225
|
+
baseUrl: this.baseUrl,
|
|
3226
|
+
tenantId: this.tenantId,
|
|
3227
|
+
enableLogging: this.enableLogging,
|
|
3228
|
+
});
|
|
3180
3229
|
}
|
|
3181
3230
|
else {
|
|
3182
|
-
this.handler = new WebSocketQrHandler({
|
|
3231
|
+
this.handler = new WebSocketQrHandler({
|
|
3232
|
+
baseUrl: this.baseUrl,
|
|
3233
|
+
tenantId: this.tenantId,
|
|
3234
|
+
enableLogging: this.enableLogging,
|
|
3235
|
+
});
|
|
3183
3236
|
}
|
|
3184
3237
|
return [2 /*return*/, this.handler.challenge(challengeParams)];
|
|
3185
3238
|
});
|
|
@@ -3265,8 +3318,10 @@ var PushApiClient = /** @class */ (function () {
|
|
|
3265
3318
|
|
|
3266
3319
|
var Push = /** @class */ (function () {
|
|
3267
3320
|
function Push(_a) {
|
|
3268
|
-
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, onTokenExpired = _a.onTokenExpired;
|
|
3321
|
+
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, onTokenExpired = _a.onTokenExpired, enableLogging = _a.enableLogging;
|
|
3269
3322
|
this.cache = TokenCache.shared;
|
|
3323
|
+
this.enableLogging = false;
|
|
3324
|
+
this.enableLogging = enableLogging;
|
|
3270
3325
|
this.api = new PushApiClient({ baseUrl: baseUrl, tenantId: tenantId, onTokenExpired: onTokenExpired });
|
|
3271
3326
|
}
|
|
3272
3327
|
Push.prototype.challenge = function (_a) {
|
|
@@ -3282,7 +3337,7 @@ var Push = /** @class */ (function () {
|
|
|
3282
3337
|
return [4 /*yield*/, this.api.challenge({ action: action, token: this.cache.token })];
|
|
3283
3338
|
case 1:
|
|
3284
3339
|
response = _c.sent();
|
|
3285
|
-
return [2 /*return*/, handleApiResponse(response)];
|
|
3340
|
+
return [2 /*return*/, handleApiResponse({ response: response, enableLogging: this.enableLogging })];
|
|
3286
3341
|
}
|
|
3287
3342
|
});
|
|
3288
3343
|
});
|
|
@@ -3300,7 +3355,7 @@ var Push = /** @class */ (function () {
|
|
|
3300
3355
|
return [4 /*yield*/, this.api.verify({ challengeId: challengeId, token: this.cache.token })];
|
|
3301
3356
|
case 1:
|
|
3302
3357
|
response = _c.sent();
|
|
3303
|
-
return [2 /*return*/, handleApiResponse(response)];
|
|
3358
|
+
return [2 /*return*/, handleApiResponse({ response: response, enableLogging: this.enableLogging })];
|
|
3304
3359
|
}
|
|
3305
3360
|
});
|
|
3306
3361
|
});
|
|
@@ -3365,8 +3420,10 @@ var WhatsappApiClient = /** @class */ (function () {
|
|
|
3365
3420
|
|
|
3366
3421
|
var Whatsapp = /** @class */ (function () {
|
|
3367
3422
|
function Whatsapp(_a) {
|
|
3368
|
-
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, onTokenExpired = _a.onTokenExpired;
|
|
3423
|
+
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, onTokenExpired = _a.onTokenExpired, enableLogging = _a.enableLogging;
|
|
3369
3424
|
this.cache = TokenCache.shared;
|
|
3425
|
+
this.enableLogging = false;
|
|
3426
|
+
this.enableLogging = enableLogging;
|
|
3370
3427
|
this.api = new WhatsappApiClient({ baseUrl: baseUrl, tenantId: tenantId, onTokenExpired: onTokenExpired });
|
|
3371
3428
|
}
|
|
3372
3429
|
Whatsapp.prototype.challenge = function () {
|
|
@@ -3381,7 +3438,7 @@ var Whatsapp = /** @class */ (function () {
|
|
|
3381
3438
|
return [4 /*yield*/, this.api.challenge({ token: this.cache.token })];
|
|
3382
3439
|
case 1:
|
|
3383
3440
|
response = _a.sent();
|
|
3384
|
-
return [2 /*return*/, handleApiResponse(response)];
|
|
3441
|
+
return [2 /*return*/, handleApiResponse({ response: response, enableLogging: this.enableLogging })];
|
|
3385
3442
|
}
|
|
3386
3443
|
});
|
|
3387
3444
|
});
|
|
@@ -3402,7 +3459,7 @@ var Whatsapp = /** @class */ (function () {
|
|
|
3402
3459
|
if ("accessToken" in response && response.accessToken) {
|
|
3403
3460
|
this.cache.token = response.accessToken;
|
|
3404
3461
|
}
|
|
3405
|
-
return [2 /*return*/, handleApiResponse(response)];
|
|
3462
|
+
return [2 /*return*/, handleApiResponse({ response: response, enableLogging: this.enableLogging })];
|
|
3406
3463
|
}
|
|
3407
3464
|
});
|
|
3408
3465
|
});
|
|
@@ -3416,11 +3473,12 @@ var DEFAULT_BASE_URL = "https://api.authsignal.com/v1";
|
|
|
3416
3473
|
var TMX_ORG_ID = "4a08uqve";
|
|
3417
3474
|
var Authsignal = /** @class */ (function () {
|
|
3418
3475
|
function Authsignal(_a) {
|
|
3419
|
-
var cookieDomain = _a.cookieDomain, _b = _a.cookieName, cookieName = _b === void 0 ? DEFAULT_COOKIE_NAME : _b, _c = _a.baseUrl, baseUrl = _c === void 0 ? DEFAULT_BASE_URL : _c, tenantId = _a.tenantId, onTokenExpired = _a.onTokenExpired;
|
|
3476
|
+
var cookieDomain = _a.cookieDomain, _b = _a.cookieName, cookieName = _b === void 0 ? DEFAULT_COOKIE_NAME : _b, _c = _a.baseUrl, baseUrl = _c === void 0 ? DEFAULT_BASE_URL : _c, tenantId = _a.tenantId, onTokenExpired = _a.onTokenExpired, _d = _a.enableLogging, enableLogging = _d === void 0 ? false : _d;
|
|
3420
3477
|
this.anonymousId = "";
|
|
3421
3478
|
this.profilingId = "";
|
|
3422
3479
|
this.cookieDomain = "";
|
|
3423
3480
|
this.anonymousIdCookieName = "";
|
|
3481
|
+
this.enableLogging = false;
|
|
3424
3482
|
this.cookieDomain = cookieDomain || getCookieDomain();
|
|
3425
3483
|
this.anonymousIdCookieName = cookieName;
|
|
3426
3484
|
if (!tenantId) {
|
|
@@ -3440,15 +3498,22 @@ var Authsignal = /** @class */ (function () {
|
|
|
3440
3498
|
secure: document.location.protocol !== "http:",
|
|
3441
3499
|
});
|
|
3442
3500
|
}
|
|
3443
|
-
this.
|
|
3444
|
-
this.
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
this.
|
|
3501
|
+
this.enableLogging = enableLogging;
|
|
3502
|
+
this.passkey = new Passkey({
|
|
3503
|
+
tenantId: tenantId,
|
|
3504
|
+
baseUrl: baseUrl,
|
|
3505
|
+
anonymousId: this.anonymousId,
|
|
3506
|
+
onTokenExpired: onTokenExpired,
|
|
3507
|
+
enableLogging: this.enableLogging,
|
|
3508
|
+
});
|
|
3509
|
+
this.totp = new Totp({ tenantId: tenantId, baseUrl: baseUrl, onTokenExpired: onTokenExpired, enableLogging: this.enableLogging });
|
|
3510
|
+
this.email = new Email({ tenantId: tenantId, baseUrl: baseUrl, onTokenExpired: onTokenExpired, enableLogging: this.enableLogging });
|
|
3511
|
+
this.emailML = new EmailMagicLink({ tenantId: tenantId, baseUrl: baseUrl, onTokenExpired: onTokenExpired, enableLogging: this.enableLogging });
|
|
3512
|
+
this.sms = new Sms({ tenantId: tenantId, baseUrl: baseUrl, onTokenExpired: onTokenExpired, enableLogging: this.enableLogging });
|
|
3513
|
+
this.securityKey = new SecurityKey({ tenantId: tenantId, baseUrl: baseUrl, onTokenExpired: onTokenExpired, enableLogging: this.enableLogging });
|
|
3514
|
+
this.qrCode = new QrCode({ tenantId: tenantId, baseUrl: baseUrl, enableLogging: this.enableLogging });
|
|
3515
|
+
this.push = new Push({ tenantId: tenantId, baseUrl: baseUrl, onTokenExpired: onTokenExpired, enableLogging: this.enableLogging });
|
|
3516
|
+
this.whatsapp = new Whatsapp({ tenantId: tenantId, baseUrl: baseUrl, onTokenExpired: onTokenExpired, enableLogging: this.enableLogging });
|
|
3452
3517
|
}
|
|
3453
3518
|
Authsignal.prototype.setToken = function (token) {
|
|
3454
3519
|
TokenCache.shared.token = token;
|
|
@@ -3503,7 +3568,11 @@ var Authsignal = /** @class */ (function () {
|
|
|
3503
3568
|
};
|
|
3504
3569
|
Authsignal.prototype.launchWithPopup = function (url, options) {
|
|
3505
3570
|
var popupOptions = options.popupOptions;
|
|
3506
|
-
var popupHandler = new PopupHandler({
|
|
3571
|
+
var popupHandler = new PopupHandler({
|
|
3572
|
+
width: popupOptions === null || popupOptions === void 0 ? void 0 : popupOptions.width,
|
|
3573
|
+
height: popupOptions === null || popupOptions === void 0 ? void 0 : popupOptions.height,
|
|
3574
|
+
isClosable: popupOptions === null || popupOptions === void 0 ? void 0 : popupOptions.isClosable,
|
|
3575
|
+
});
|
|
3507
3576
|
var popupUrl = "".concat(url, "&mode=popup");
|
|
3508
3577
|
popupHandler.show({ url: popupUrl });
|
|
3509
3578
|
return new Promise(function (resolve) {
|
|
@@ -3552,4 +3621,4 @@ var Authsignal = /** @class */ (function () {
|
|
|
3552
3621
|
return Authsignal;
|
|
3553
3622
|
}());
|
|
3554
3623
|
|
|
3555
|
-
export { Authsignal, AuthsignalWindowMessage, WebAuthnError, Whatsapp };
|
|
3624
|
+
export { Authsignal, AuthsignalWindowMessage, ErrorCode, WebAuthnError, Whatsapp };
|