@authsignal/browser 1.12.7 → 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/helpers.d.ts +18 -4
- package/dist/index.js +121 -64
- 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 +15 -5
- package/dist/whatsapp.d.ts +3 -1
- package/package.json +8 -3
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CredentialDeviceType } from "@simplewebauthn/browser";
|
|
2
|
+
import { ErrorCode } from "../../types";
|
|
2
3
|
export type ApiClientOptions = {
|
|
3
4
|
baseUrl: string;
|
|
4
5
|
tenantId: string;
|
|
@@ -21,9 +22,12 @@ export type VerifyResponse = {
|
|
|
21
22
|
userAuthenticator?: Authenticator;
|
|
22
23
|
};
|
|
23
24
|
export type ErrorResponse = {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated Use errorCode and errorDescription instead
|
|
27
|
+
*/
|
|
28
|
+
error?: string;
|
|
29
|
+
errorCode?: ErrorCode;
|
|
30
|
+
errorDescription?: string | undefined;
|
|
27
31
|
};
|
|
28
32
|
export declare enum VerificationMethod {
|
|
29
33
|
SMS = "SMS",
|
package/dist/authsignal.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare class Authsignal {
|
|
|
13
13
|
profilingId: string;
|
|
14
14
|
cookieDomain: string;
|
|
15
15
|
anonymousIdCookieName: string;
|
|
16
|
+
enableLogging: boolean;
|
|
16
17
|
passkey: Passkey;
|
|
17
18
|
totp: Totp;
|
|
18
19
|
email: Email;
|
|
@@ -22,7 +23,7 @@ export declare class Authsignal {
|
|
|
22
23
|
qrCode: QrCode;
|
|
23
24
|
push: Push;
|
|
24
25
|
whatsapp: Whatsapp;
|
|
25
|
-
constructor({ cookieDomain, cookieName, baseUrl, tenantId, onTokenExpired, }: AuthsignalOptions);
|
|
26
|
+
constructor({ cookieDomain, cookieName, baseUrl, tenantId, onTokenExpired, enableLogging, }: AuthsignalOptions);
|
|
26
27
|
setToken(token: string): void;
|
|
27
28
|
launch(url: string, options?: {
|
|
28
29
|
mode?: "redirect";
|
|
@@ -4,6 +4,7 @@ type EmailMagicLinkOptions = {
|
|
|
4
4
|
baseUrl: string;
|
|
5
5
|
tenantId: string;
|
|
6
6
|
onTokenExpired?: () => void;
|
|
7
|
+
enableLogging: boolean;
|
|
7
8
|
};
|
|
8
9
|
type EnrollParams = {
|
|
9
10
|
email: string;
|
|
@@ -11,7 +12,8 @@ type EnrollParams = {
|
|
|
11
12
|
export declare class EmailMagicLink {
|
|
12
13
|
private api;
|
|
13
14
|
private cache;
|
|
14
|
-
|
|
15
|
+
private enableLogging;
|
|
16
|
+
constructor({ baseUrl, tenantId, onTokenExpired, enableLogging }: EmailMagicLinkOptions);
|
|
15
17
|
enroll({ email }: EnrollParams): Promise<AuthsignalResponse<EnrollResponse>>;
|
|
16
18
|
challenge(): Promise<AuthsignalResponse<ChallengeResponse>>;
|
|
17
19
|
checkVerificationStatus(): Promise<AuthsignalResponse<VerifyResponse>>;
|
package/dist/email.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ type EmailOptions = {
|
|
|
4
4
|
baseUrl: string;
|
|
5
5
|
tenantId: string;
|
|
6
6
|
onTokenExpired?: () => void;
|
|
7
|
+
enableLogging: boolean;
|
|
7
8
|
};
|
|
8
9
|
type EnrollParams = {
|
|
9
10
|
email: string;
|
|
@@ -14,7 +15,8 @@ type VerifyParams = {
|
|
|
14
15
|
export declare class Email {
|
|
15
16
|
private api;
|
|
16
17
|
private cache;
|
|
17
|
-
|
|
18
|
+
private enableLogging;
|
|
19
|
+
constructor({ baseUrl, tenantId, onTokenExpired, enableLogging }: EmailOptions);
|
|
18
20
|
enroll({ email }: EnrollParams): Promise<AuthsignalResponse<EnrollResponse>>;
|
|
19
21
|
challenge(): Promise<AuthsignalResponse<ChallengeResponse>>;
|
|
20
22
|
verify({ code }: VerifyParams): Promise<AuthsignalResponse<VerifyResponse>>;
|
package/dist/helpers.d.ts
CHANGED
|
@@ -9,15 +9,29 @@ type CookieOptions = {
|
|
|
9
9
|
export declare function setCookie({ name, value, expire, domain, secure }: CookieOptions): void;
|
|
10
10
|
export declare function getCookieDomain(): string;
|
|
11
11
|
export declare function getCookie(name: string): string | null;
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
type HandleErrorResponseParams = {
|
|
13
|
+
errorResponse: ErrorResponse;
|
|
14
|
+
enableLogging: boolean;
|
|
14
15
|
};
|
|
15
|
-
export declare function
|
|
16
|
-
error: string;
|
|
16
|
+
export declare function handleErrorResponse({ errorResponse, enableLogging }: HandleErrorResponseParams): {
|
|
17
|
+
error: string | undefined;
|
|
18
|
+
errorCode: import("./types").ErrorCode | undefined;
|
|
19
|
+
errorDescription: string | undefined;
|
|
20
|
+
};
|
|
21
|
+
type HandleApiResponseParams<T> = {
|
|
22
|
+
response: ErrorResponse | T;
|
|
23
|
+
enableLogging: boolean;
|
|
24
|
+
};
|
|
25
|
+
export declare function handleApiResponse<T>({ response, enableLogging }: HandleApiResponseParams<T>): {
|
|
26
|
+
error: string | undefined;
|
|
27
|
+
errorCode: import("./types").ErrorCode | undefined;
|
|
28
|
+
errorDescription: string | undefined;
|
|
17
29
|
data?: undefined;
|
|
18
30
|
} | {
|
|
19
31
|
data: T;
|
|
20
32
|
error?: undefined;
|
|
33
|
+
errorCode?: undefined;
|
|
34
|
+
errorDescription?: undefined;
|
|
21
35
|
};
|
|
22
36
|
export declare function handleWebAuthnError(error: unknown): void;
|
|
23
37
|
export {};
|
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 }));
|
|
@@ -1917,8 +1938,10 @@ var TotpApiClient = /** @class */ (function () {
|
|
|
1917
1938
|
|
|
1918
1939
|
var Totp = /** @class */ (function () {
|
|
1919
1940
|
function Totp(_a) {
|
|
1920
|
-
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, onTokenExpired = _a.onTokenExpired;
|
|
1941
|
+
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, onTokenExpired = _a.onTokenExpired, enableLogging = _a.enableLogging;
|
|
1921
1942
|
this.cache = TokenCache.shared;
|
|
1943
|
+
this.enableLogging = false;
|
|
1944
|
+
this.enableLogging = enableLogging;
|
|
1922
1945
|
this.api = new TotpApiClient({ baseUrl: baseUrl, tenantId: tenantId, onTokenExpired: onTokenExpired });
|
|
1923
1946
|
}
|
|
1924
1947
|
Totp.prototype.enroll = function () {
|
|
@@ -1933,7 +1956,7 @@ var Totp = /** @class */ (function () {
|
|
|
1933
1956
|
return [4 /*yield*/, this.api.enroll({ token: this.cache.token })];
|
|
1934
1957
|
case 1:
|
|
1935
1958
|
response = _a.sent();
|
|
1936
|
-
return [2 /*return*/, handleApiResponse(response)];
|
|
1959
|
+
return [2 /*return*/, handleApiResponse({ response: response, enableLogging: this.enableLogging })];
|
|
1937
1960
|
}
|
|
1938
1961
|
});
|
|
1939
1962
|
});
|
|
@@ -1954,7 +1977,7 @@ var Totp = /** @class */ (function () {
|
|
|
1954
1977
|
if ("accessToken" in response && response.accessToken) {
|
|
1955
1978
|
this.cache.token = response.accessToken;
|
|
1956
1979
|
}
|
|
1957
|
-
return [2 /*return*/, handleApiResponse(response)];
|
|
1980
|
+
return [2 /*return*/, handleApiResponse({ response: response, enableLogging: this.enableLogging })];
|
|
1958
1981
|
}
|
|
1959
1982
|
});
|
|
1960
1983
|
});
|
|
@@ -2043,8 +2066,10 @@ var EmailApiClient = /** @class */ (function () {
|
|
|
2043
2066
|
|
|
2044
2067
|
var Email = /** @class */ (function () {
|
|
2045
2068
|
function Email(_a) {
|
|
2046
|
-
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, onTokenExpired = _a.onTokenExpired;
|
|
2069
|
+
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, onTokenExpired = _a.onTokenExpired, enableLogging = _a.enableLogging;
|
|
2047
2070
|
this.cache = TokenCache.shared;
|
|
2071
|
+
this.enableLogging = false;
|
|
2072
|
+
this.enableLogging = enableLogging;
|
|
2048
2073
|
this.api = new EmailApiClient({ baseUrl: baseUrl, tenantId: tenantId, onTokenExpired: onTokenExpired });
|
|
2049
2074
|
}
|
|
2050
2075
|
Email.prototype.enroll = function (_a) {
|
|
@@ -2060,7 +2085,7 @@ var Email = /** @class */ (function () {
|
|
|
2060
2085
|
return [4 /*yield*/, this.api.enroll({ token: this.cache.token, email: email })];
|
|
2061
2086
|
case 1:
|
|
2062
2087
|
response = _c.sent();
|
|
2063
|
-
return [2 /*return*/, handleApiResponse(response)];
|
|
2088
|
+
return [2 /*return*/, handleApiResponse({ response: response, enableLogging: this.enableLogging })];
|
|
2064
2089
|
}
|
|
2065
2090
|
});
|
|
2066
2091
|
});
|
|
@@ -2077,7 +2102,7 @@ var Email = /** @class */ (function () {
|
|
|
2077
2102
|
return [4 /*yield*/, this.api.challenge({ token: this.cache.token })];
|
|
2078
2103
|
case 1:
|
|
2079
2104
|
response = _a.sent();
|
|
2080
|
-
return [2 /*return*/, handleApiResponse(response)];
|
|
2105
|
+
return [2 /*return*/, handleApiResponse({ response: response, enableLogging: this.enableLogging })];
|
|
2081
2106
|
}
|
|
2082
2107
|
});
|
|
2083
2108
|
});
|
|
@@ -2098,7 +2123,7 @@ var Email = /** @class */ (function () {
|
|
|
2098
2123
|
if ("accessToken" in response && response.accessToken) {
|
|
2099
2124
|
this.cache.token = response.accessToken;
|
|
2100
2125
|
}
|
|
2101
|
-
return [2 /*return*/, handleApiResponse(response)];
|
|
2126
|
+
return [2 /*return*/, handleApiResponse({ response: response, enableLogging: this.enableLogging })];
|
|
2102
2127
|
}
|
|
2103
2128
|
});
|
|
2104
2129
|
});
|
|
@@ -2187,8 +2212,10 @@ var SmsApiClient = /** @class */ (function () {
|
|
|
2187
2212
|
|
|
2188
2213
|
var Sms = /** @class */ (function () {
|
|
2189
2214
|
function Sms(_a) {
|
|
2190
|
-
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, onTokenExpired = _a.onTokenExpired;
|
|
2215
|
+
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, onTokenExpired = _a.onTokenExpired, enableLogging = _a.enableLogging;
|
|
2191
2216
|
this.cache = TokenCache.shared;
|
|
2217
|
+
this.enableLogging = false;
|
|
2218
|
+
this.enableLogging = enableLogging;
|
|
2192
2219
|
this.api = new SmsApiClient({ baseUrl: baseUrl, tenantId: tenantId, onTokenExpired: onTokenExpired });
|
|
2193
2220
|
}
|
|
2194
2221
|
Sms.prototype.enroll = function (_a) {
|
|
@@ -2204,7 +2231,7 @@ var Sms = /** @class */ (function () {
|
|
|
2204
2231
|
return [4 /*yield*/, this.api.enroll({ token: this.cache.token, phoneNumber: phoneNumber })];
|
|
2205
2232
|
case 1:
|
|
2206
2233
|
response = _c.sent();
|
|
2207
|
-
return [2 /*return*/, handleApiResponse(response)];
|
|
2234
|
+
return [2 /*return*/, handleApiResponse({ response: response, enableLogging: this.enableLogging })];
|
|
2208
2235
|
}
|
|
2209
2236
|
});
|
|
2210
2237
|
});
|
|
@@ -2221,7 +2248,7 @@ var Sms = /** @class */ (function () {
|
|
|
2221
2248
|
return [4 /*yield*/, this.api.challenge({ token: this.cache.token })];
|
|
2222
2249
|
case 1:
|
|
2223
2250
|
response = _a.sent();
|
|
2224
|
-
return [2 /*return*/, handleApiResponse(response)];
|
|
2251
|
+
return [2 /*return*/, handleApiResponse({ response: response, enableLogging: this.enableLogging })];
|
|
2225
2252
|
}
|
|
2226
2253
|
});
|
|
2227
2254
|
});
|
|
@@ -2242,7 +2269,7 @@ var Sms = /** @class */ (function () {
|
|
|
2242
2269
|
if ("accessToken" in response && response.accessToken) {
|
|
2243
2270
|
this.cache.token = response.accessToken;
|
|
2244
2271
|
}
|
|
2245
|
-
return [2 /*return*/, handleApiResponse(response)];
|
|
2272
|
+
return [2 /*return*/, handleApiResponse({ response: response, enableLogging: this.enableLogging })];
|
|
2246
2273
|
}
|
|
2247
2274
|
});
|
|
2248
2275
|
});
|
|
@@ -2360,8 +2387,10 @@ var EmailMagicLinkApiClient = /** @class */ (function () {
|
|
|
2360
2387
|
|
|
2361
2388
|
var EmailMagicLink = /** @class */ (function () {
|
|
2362
2389
|
function EmailMagicLink(_a) {
|
|
2363
|
-
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, onTokenExpired = _a.onTokenExpired;
|
|
2390
|
+
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, onTokenExpired = _a.onTokenExpired, enableLogging = _a.enableLogging;
|
|
2364
2391
|
this.cache = TokenCache.shared;
|
|
2392
|
+
this.enableLogging = false;
|
|
2393
|
+
this.enableLogging = enableLogging;
|
|
2365
2394
|
this.api = new EmailMagicLinkApiClient({ baseUrl: baseUrl, tenantId: tenantId, onTokenExpired: onTokenExpired });
|
|
2366
2395
|
}
|
|
2367
2396
|
EmailMagicLink.prototype.enroll = function (_a) {
|
|
@@ -2377,7 +2406,7 @@ var EmailMagicLink = /** @class */ (function () {
|
|
|
2377
2406
|
return [4 /*yield*/, this.api.enroll({ token: this.cache.token, email: email })];
|
|
2378
2407
|
case 1:
|
|
2379
2408
|
response = _c.sent();
|
|
2380
|
-
return [2 /*return*/, handleApiResponse(response)];
|
|
2409
|
+
return [2 /*return*/, handleApiResponse({ response: response, enableLogging: this.enableLogging })];
|
|
2381
2410
|
}
|
|
2382
2411
|
});
|
|
2383
2412
|
});
|
|
@@ -2394,7 +2423,7 @@ var EmailMagicLink = /** @class */ (function () {
|
|
|
2394
2423
|
return [4 /*yield*/, this.api.challenge({ token: this.cache.token })];
|
|
2395
2424
|
case 1:
|
|
2396
2425
|
response = _a.sent();
|
|
2397
|
-
return [2 /*return*/, handleApiResponse(response)];
|
|
2426
|
+
return [2 /*return*/, handleApiResponse({ response: response, enableLogging: this.enableLogging })];
|
|
2398
2427
|
}
|
|
2399
2428
|
});
|
|
2400
2429
|
});
|
|
@@ -2414,7 +2443,7 @@ var EmailMagicLink = /** @class */ (function () {
|
|
|
2414
2443
|
if ("accessToken" in response && response.accessToken) {
|
|
2415
2444
|
this.cache.token = response.accessToken;
|
|
2416
2445
|
}
|
|
2417
|
-
return [2 /*return*/, handleApiResponse(response)];
|
|
2446
|
+
return [2 /*return*/, handleApiResponse({ response: response, enableLogging: this.enableLogging })];
|
|
2418
2447
|
}
|
|
2419
2448
|
});
|
|
2420
2449
|
});
|
|
@@ -2522,9 +2551,11 @@ var SecurityKeyApiClient = /** @class */ (function () {
|
|
|
2522
2551
|
|
|
2523
2552
|
var SecurityKey = /** @class */ (function () {
|
|
2524
2553
|
function SecurityKey(_a) {
|
|
2525
|
-
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, onTokenExpired = _a.onTokenExpired;
|
|
2554
|
+
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, onTokenExpired = _a.onTokenExpired, enableLogging = _a.enableLogging;
|
|
2526
2555
|
this.cache = TokenCache.shared;
|
|
2556
|
+
this.enableLogging = false;
|
|
2527
2557
|
this.api = new SecurityKeyApiClient({ baseUrl: baseUrl, tenantId: tenantId, onTokenExpired: onTokenExpired });
|
|
2558
|
+
this.enableLogging = enableLogging;
|
|
2528
2559
|
}
|
|
2529
2560
|
SecurityKey.prototype.enroll = function () {
|
|
2530
2561
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -2542,7 +2573,7 @@ var SecurityKey = /** @class */ (function () {
|
|
|
2542
2573
|
case 1:
|
|
2543
2574
|
optionsResponse = _a.sent();
|
|
2544
2575
|
if ("error" in optionsResponse) {
|
|
2545
|
-
return [2 /*return*/, handleErrorResponse(optionsResponse)];
|
|
2576
|
+
return [2 /*return*/, handleErrorResponse({ errorResponse: optionsResponse, enableLogging: this.enableLogging })];
|
|
2546
2577
|
}
|
|
2547
2578
|
_a.label = 2;
|
|
2548
2579
|
case 2:
|
|
@@ -2557,7 +2588,7 @@ var SecurityKey = /** @class */ (function () {
|
|
|
2557
2588
|
case 4:
|
|
2558
2589
|
addAuthenticatorResponse = _a.sent();
|
|
2559
2590
|
if ("error" in addAuthenticatorResponse) {
|
|
2560
|
-
return [2 /*return*/, handleErrorResponse(addAuthenticatorResponse)];
|
|
2591
|
+
return [2 /*return*/, handleErrorResponse({ errorResponse: addAuthenticatorResponse, enableLogging: this.enableLogging })];
|
|
2561
2592
|
}
|
|
2562
2593
|
if (addAuthenticatorResponse.accessToken) {
|
|
2563
2594
|
this.cache.token = addAuthenticatorResponse.accessToken;
|
|
@@ -2592,7 +2623,7 @@ var SecurityKey = /** @class */ (function () {
|
|
|
2592
2623
|
case 1:
|
|
2593
2624
|
optionsResponse = _a.sent();
|
|
2594
2625
|
if ("error" in optionsResponse) {
|
|
2595
|
-
return [2 /*return*/, handleErrorResponse(optionsResponse)];
|
|
2626
|
+
return [2 /*return*/, handleErrorResponse({ errorResponse: optionsResponse, enableLogging: this.enableLogging })];
|
|
2596
2627
|
}
|
|
2597
2628
|
_a.label = 2;
|
|
2598
2629
|
case 2:
|
|
@@ -2609,7 +2640,7 @@ var SecurityKey = /** @class */ (function () {
|
|
|
2609
2640
|
case 4:
|
|
2610
2641
|
verifyResponse = _a.sent();
|
|
2611
2642
|
if ("error" in verifyResponse) {
|
|
2612
|
-
return [2 /*return*/, handleErrorResponse(verifyResponse)];
|
|
2643
|
+
return [2 /*return*/, handleErrorResponse({ errorResponse: verifyResponse, enableLogging: this.enableLogging })];
|
|
2613
2644
|
}
|
|
2614
2645
|
if (verifyResponse.accessToken) {
|
|
2615
2646
|
this.cache.token = verifyResponse.accessToken;
|
|
@@ -2700,9 +2731,11 @@ var DEFAULT_POLL_INTERVAL = 3 * 1000;
|
|
|
2700
2731
|
var RestQrHandler = /** @class */ (function (_super) {
|
|
2701
2732
|
__extends(RestQrHandler, _super);
|
|
2702
2733
|
function RestQrHandler(_a) {
|
|
2703
|
-
var baseUrl = _a.baseUrl, tenantId = _a.tenantId;
|
|
2734
|
+
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, enableLogging = _a.enableLogging;
|
|
2704
2735
|
var _this = _super.call(this) || this;
|
|
2705
2736
|
_this.cache = TokenCache.shared;
|
|
2737
|
+
_this.enableLogging = false;
|
|
2738
|
+
_this.enableLogging = enableLogging;
|
|
2706
2739
|
_this.api = new QrCodeApiClient({ baseUrl: baseUrl, tenantId: tenantId });
|
|
2707
2740
|
return _this;
|
|
2708
2741
|
}
|
|
@@ -2719,7 +2752,7 @@ var RestQrHandler = /** @class */ (function (_super) {
|
|
|
2719
2752
|
})];
|
|
2720
2753
|
case 1:
|
|
2721
2754
|
response = _a.sent();
|
|
2722
|
-
result = handleApiResponse(response);
|
|
2755
|
+
result = handleApiResponse({ response: response, enableLogging: this.enableLogging });
|
|
2723
2756
|
if (result.data) {
|
|
2724
2757
|
this.currentChallengeParams = params;
|
|
2725
2758
|
this.clearPolling();
|
|
@@ -2768,7 +2801,7 @@ var RestQrHandler = /** @class */ (function (_super) {
|
|
|
2768
2801
|
})];
|
|
2769
2802
|
case 1:
|
|
2770
2803
|
response = _d.sent();
|
|
2771
|
-
result = handleApiResponse(response);
|
|
2804
|
+
result = handleApiResponse({ response: response, enableLogging: this.enableLogging });
|
|
2772
2805
|
if (result.data) {
|
|
2773
2806
|
this.clearPolling();
|
|
2774
2807
|
if (this.currentChallengeParams.onRefresh) {
|
|
@@ -2836,7 +2869,7 @@ var RestQrHandler = /** @class */ (function (_super) {
|
|
|
2836
2869
|
case 0: return [4 /*yield*/, this.api.challenge({ token: this.cache.token || undefined, action: action, custom: custom })];
|
|
2837
2870
|
case 1:
|
|
2838
2871
|
response = _c.sent();
|
|
2839
|
-
result = handleApiResponse(response);
|
|
2872
|
+
result = handleApiResponse({ response: response, enableLogging: this.enableLogging });
|
|
2840
2873
|
if (result.data) {
|
|
2841
2874
|
this.clearPolling();
|
|
2842
2875
|
onRefresh(result.data.challengeId, result.data.expiresAt);
|
|
@@ -2864,7 +2897,7 @@ var RestQrHandler = /** @class */ (function (_super) {
|
|
|
2864
2897
|
case 0: return [4 /*yield*/, this.api.verify({ challengeId: challengeId, deviceCode: deviceCode })];
|
|
2865
2898
|
case 1:
|
|
2866
2899
|
response = _a.sent();
|
|
2867
|
-
result = handleApiResponse(response);
|
|
2900
|
+
result = handleApiResponse({ response: response, enableLogging: this.enableLogging });
|
|
2868
2901
|
if (result.data) {
|
|
2869
2902
|
if (result.data.isVerified) {
|
|
2870
2903
|
onStateChange("approved", result.data.token);
|
|
@@ -3118,9 +3151,11 @@ var WebSocketClient = /** @class */ (function () {
|
|
|
3118
3151
|
var WebSocketQrHandler = /** @class */ (function (_super) {
|
|
3119
3152
|
__extends(WebSocketQrHandler, _super);
|
|
3120
3153
|
function WebSocketQrHandler(_a) {
|
|
3121
|
-
var baseUrl = _a.baseUrl, tenantId = _a.tenantId;
|
|
3154
|
+
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, enableLogging = _a.enableLogging;
|
|
3122
3155
|
var _this = _super.call(this) || this;
|
|
3123
3156
|
_this.cache = TokenCache.shared;
|
|
3157
|
+
_this.enableLogging = false;
|
|
3158
|
+
_this.enableLogging = enableLogging;
|
|
3124
3159
|
_this.wsClient = new WebSocketClient({ baseUrl: baseUrl, tenantId: tenantId });
|
|
3125
3160
|
return _this;
|
|
3126
3161
|
}
|
|
@@ -3170,10 +3205,12 @@ var WebSocketQrHandler = /** @class */ (function (_super) {
|
|
|
3170
3205
|
|
|
3171
3206
|
var QrCode = /** @class */ (function () {
|
|
3172
3207
|
function QrCode(_a) {
|
|
3173
|
-
var baseUrl = _a.baseUrl, tenantId = _a.tenantId;
|
|
3208
|
+
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, enableLogging = _a.enableLogging;
|
|
3174
3209
|
this.handler = null;
|
|
3210
|
+
this.enableLogging = false;
|
|
3175
3211
|
this.baseUrl = baseUrl;
|
|
3176
3212
|
this.tenantId = tenantId;
|
|
3213
|
+
this.enableLogging = enableLogging;
|
|
3177
3214
|
}
|
|
3178
3215
|
QrCode.prototype.challenge = function (params) {
|
|
3179
3216
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -3184,10 +3221,18 @@ var QrCode = /** @class */ (function () {
|
|
|
3184
3221
|
this.handler.disconnect();
|
|
3185
3222
|
}
|
|
3186
3223
|
if (polling) {
|
|
3187
|
-
this.handler = new RestQrHandler({
|
|
3224
|
+
this.handler = new RestQrHandler({
|
|
3225
|
+
baseUrl: this.baseUrl,
|
|
3226
|
+
tenantId: this.tenantId,
|
|
3227
|
+
enableLogging: this.enableLogging,
|
|
3228
|
+
});
|
|
3188
3229
|
}
|
|
3189
3230
|
else {
|
|
3190
|
-
this.handler = new WebSocketQrHandler({
|
|
3231
|
+
this.handler = new WebSocketQrHandler({
|
|
3232
|
+
baseUrl: this.baseUrl,
|
|
3233
|
+
tenantId: this.tenantId,
|
|
3234
|
+
enableLogging: this.enableLogging,
|
|
3235
|
+
});
|
|
3191
3236
|
}
|
|
3192
3237
|
return [2 /*return*/, this.handler.challenge(challengeParams)];
|
|
3193
3238
|
});
|
|
@@ -3273,8 +3318,10 @@ var PushApiClient = /** @class */ (function () {
|
|
|
3273
3318
|
|
|
3274
3319
|
var Push = /** @class */ (function () {
|
|
3275
3320
|
function Push(_a) {
|
|
3276
|
-
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, onTokenExpired = _a.onTokenExpired;
|
|
3321
|
+
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, onTokenExpired = _a.onTokenExpired, enableLogging = _a.enableLogging;
|
|
3277
3322
|
this.cache = TokenCache.shared;
|
|
3323
|
+
this.enableLogging = false;
|
|
3324
|
+
this.enableLogging = enableLogging;
|
|
3278
3325
|
this.api = new PushApiClient({ baseUrl: baseUrl, tenantId: tenantId, onTokenExpired: onTokenExpired });
|
|
3279
3326
|
}
|
|
3280
3327
|
Push.prototype.challenge = function (_a) {
|
|
@@ -3290,7 +3337,7 @@ var Push = /** @class */ (function () {
|
|
|
3290
3337
|
return [4 /*yield*/, this.api.challenge({ action: action, token: this.cache.token })];
|
|
3291
3338
|
case 1:
|
|
3292
3339
|
response = _c.sent();
|
|
3293
|
-
return [2 /*return*/, handleApiResponse(response)];
|
|
3340
|
+
return [2 /*return*/, handleApiResponse({ response: response, enableLogging: this.enableLogging })];
|
|
3294
3341
|
}
|
|
3295
3342
|
});
|
|
3296
3343
|
});
|
|
@@ -3308,7 +3355,7 @@ var Push = /** @class */ (function () {
|
|
|
3308
3355
|
return [4 /*yield*/, this.api.verify({ challengeId: challengeId, token: this.cache.token })];
|
|
3309
3356
|
case 1:
|
|
3310
3357
|
response = _c.sent();
|
|
3311
|
-
return [2 /*return*/, handleApiResponse(response)];
|
|
3358
|
+
return [2 /*return*/, handleApiResponse({ response: response, enableLogging: this.enableLogging })];
|
|
3312
3359
|
}
|
|
3313
3360
|
});
|
|
3314
3361
|
});
|
|
@@ -3373,8 +3420,10 @@ var WhatsappApiClient = /** @class */ (function () {
|
|
|
3373
3420
|
|
|
3374
3421
|
var Whatsapp = /** @class */ (function () {
|
|
3375
3422
|
function Whatsapp(_a) {
|
|
3376
|
-
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, onTokenExpired = _a.onTokenExpired;
|
|
3423
|
+
var baseUrl = _a.baseUrl, tenantId = _a.tenantId, onTokenExpired = _a.onTokenExpired, enableLogging = _a.enableLogging;
|
|
3377
3424
|
this.cache = TokenCache.shared;
|
|
3425
|
+
this.enableLogging = false;
|
|
3426
|
+
this.enableLogging = enableLogging;
|
|
3378
3427
|
this.api = new WhatsappApiClient({ baseUrl: baseUrl, tenantId: tenantId, onTokenExpired: onTokenExpired });
|
|
3379
3428
|
}
|
|
3380
3429
|
Whatsapp.prototype.challenge = function () {
|
|
@@ -3389,7 +3438,7 @@ var Whatsapp = /** @class */ (function () {
|
|
|
3389
3438
|
return [4 /*yield*/, this.api.challenge({ token: this.cache.token })];
|
|
3390
3439
|
case 1:
|
|
3391
3440
|
response = _a.sent();
|
|
3392
|
-
return [2 /*return*/, handleApiResponse(response)];
|
|
3441
|
+
return [2 /*return*/, handleApiResponse({ response: response, enableLogging: this.enableLogging })];
|
|
3393
3442
|
}
|
|
3394
3443
|
});
|
|
3395
3444
|
});
|
|
@@ -3410,7 +3459,7 @@ var Whatsapp = /** @class */ (function () {
|
|
|
3410
3459
|
if ("accessToken" in response && response.accessToken) {
|
|
3411
3460
|
this.cache.token = response.accessToken;
|
|
3412
3461
|
}
|
|
3413
|
-
return [2 /*return*/, handleApiResponse(response)];
|
|
3462
|
+
return [2 /*return*/, handleApiResponse({ response: response, enableLogging: this.enableLogging })];
|
|
3414
3463
|
}
|
|
3415
3464
|
});
|
|
3416
3465
|
});
|
|
@@ -3424,11 +3473,12 @@ var DEFAULT_BASE_URL = "https://api.authsignal.com/v1";
|
|
|
3424
3473
|
var TMX_ORG_ID = "4a08uqve";
|
|
3425
3474
|
var Authsignal = /** @class */ (function () {
|
|
3426
3475
|
function Authsignal(_a) {
|
|
3427
|
-
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;
|
|
3428
3477
|
this.anonymousId = "";
|
|
3429
3478
|
this.profilingId = "";
|
|
3430
3479
|
this.cookieDomain = "";
|
|
3431
3480
|
this.anonymousIdCookieName = "";
|
|
3481
|
+
this.enableLogging = false;
|
|
3432
3482
|
this.cookieDomain = cookieDomain || getCookieDomain();
|
|
3433
3483
|
this.anonymousIdCookieName = cookieName;
|
|
3434
3484
|
if (!tenantId) {
|
|
@@ -3448,15 +3498,22 @@ var Authsignal = /** @class */ (function () {
|
|
|
3448
3498
|
secure: document.location.protocol !== "http:",
|
|
3449
3499
|
});
|
|
3450
3500
|
}
|
|
3451
|
-
this.
|
|
3452
|
-
this.
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
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 });
|
|
3460
3517
|
}
|
|
3461
3518
|
Authsignal.prototype.setToken = function (token) {
|
|
3462
3519
|
TokenCache.shared.token = token;
|
|
@@ -3564,4 +3621,4 @@ var Authsignal = /** @class */ (function () {
|
|
|
3564
3621
|
return Authsignal;
|
|
3565
3622
|
}());
|
|
3566
3623
|
|
|
3567
|
-
export { Authsignal, AuthsignalWindowMessage, WebAuthnError, Whatsapp };
|
|
3624
|
+
export { Authsignal, AuthsignalWindowMessage, ErrorCode, WebAuthnError, Whatsapp };
|
package/dist/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var authsignal=function(e){"use strict";let t;const n=new Uint8Array(16);function r(){if(!t&&(t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!t))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return t(n)}const o=[];for(let e=0;e<256;++e)o.push((e+256).toString(16).slice(1));var i={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function s(e,t,n){if(i.randomUUID&&!t&&!e)return i.randomUUID();const s=(e=e||{}).random||(e.rng||r)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=s[e];return t}return function(e,t=0){return(o[e[t+0]]+o[e[t+1]]+o[e[t+2]]+o[e[t+3]]+"-"+o[e[t+4]]+o[e[t+5]]+"-"+o[e[t+6]]+o[e[t+7]]+"-"+o[e[t+8]]+o[e[t+9]]+"-"+o[e[t+10]]+o[e[t+11]]+o[e[t+12]]+o[e[t+13]]+o[e[t+14]]+o[e[t+15]]).toLowerCase()}(s)}var a=function(e,t){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},a(e,t)};function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var h=function(){return h=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},h.apply(this,arguments)};function l(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function u(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))}function d(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function p(e){const t=new Uint8Array(e);let n="";for(const e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function f(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,"="),o=atob(r),i=new ArrayBuffer(o.length),s=new Uint8Array(i);for(let e=0;e<o.length;e++)s[e]=o.charCodeAt(e);return i}function v(){return g.stubThis(void 0!==globalThis?.PublicKeyCredential&&"function"==typeof globalThis.PublicKeyCredential)}const g={stubThis:e=>e};function y(e){const{id:t}=e;return{...e,id:f(t),transports:e.transports}}function b(e){return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}class m extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=r??n.name,this.code=t}}const k=new class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){const e=new Error("Cancelling existing WebAuthn API call for new one");e.name="AbortError",this.controller.abort(e)}const e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){const e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}},w=["cross-platform","platform"];function E(e){if(e&&!(w.indexOf(e)<0))return e}async function I(e){!e.optionsJSON&&e.challenge&&(console.warn("startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information."),e={optionsJSON:e});const{optionsJSON:t,useAutoRegister:n=!1}=e;if(!v())throw new Error("WebAuthn is not supported in this browser");const r={...t,challenge:f(t.challenge),user:{...t.user,id:f(t.user.id)},excludeCredentials:t.excludeCredentials?.map(y)},o={};let i;n&&(o.mediation="conditional"),o.publicKey=r,o.signal=k.createNewAbortSignal();try{i=await navigator.credentials.create(o)}catch(e){throw function({error:e,options:t}){const{publicKey:n}=t;if(!n)throw Error("options was missing required publicKey property");if("AbortError"===e.name){if(t.signal instanceof AbortSignal)return new m({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else if("ConstraintError"===e.name){if(!0===n.authenticatorSelection?.requireResidentKey)return new m({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:e});if("conditional"===t.mediation&&"required"===n.authenticatorSelection?.userVerification)return new m({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:e});if("required"===n.authenticatorSelection?.userVerification)return new m({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:e})}else{if("InvalidStateError"===e.name)return new m({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:e});if("NotAllowedError"===e.name)return new m({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});if("NotSupportedError"===e.name)return 0===n.pubKeyCredParams.filter((e=>"public-key"===e.type)).length?new m({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:e}):new m({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:e});if("SecurityError"===e.name){const t=globalThis.location.hostname;if(!b(t))return new m({message:`${globalThis.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e});if(n.rp.id!==t)return new m({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else if("TypeError"===e.name){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new m({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:e})}else if("UnknownError"===e.name)return new m({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e})}return e}({error:e,options:o})}if(!i)throw new Error("Registration was not completed");const{id:s,rawId:a,response:c,type:h}=i;let l,u,d,g;if("function"==typeof c.getTransports&&(l=c.getTransports()),"function"==typeof c.getPublicKeyAlgorithm)try{u=c.getPublicKeyAlgorithm()}catch(e){T("getPublicKeyAlgorithm()",e)}if("function"==typeof c.getPublicKey)try{const e=c.getPublicKey();null!==e&&(d=p(e))}catch(e){T("getPublicKey()",e)}if("function"==typeof c.getAuthenticatorData)try{g=p(c.getAuthenticatorData())}catch(e){T("getAuthenticatorData()",e)}return{id:s,rawId:p(a),response:{attestationObject:p(c.attestationObject),clientDataJSON:p(c.clientDataJSON),transports:l,publicKeyAlgorithm:u,publicKey:d,authenticatorData:g},type:h,clientExtensionResults:i.getClientExtensionResults(),authenticatorAttachment:E(i.authenticatorAttachment)}}function T(e,t){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.\n`,t)}const C={stubThis:e=>e};async function S(e){!e.optionsJSON&&e.challenge&&(console.warn("startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information."),e={optionsJSON:e});const{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:r=!0}=e;if(!v())throw new Error("WebAuthn is not supported in this browser");let o;0!==t.allowCredentials?.length&&(o=t.allowCredentials?.map(y));const i={...t,challenge:f(t.challenge),allowCredentials:o},s={};if(n){if(!await function(){if(!v())return C.stubThis(new Promise((e=>e(!1))));const e=globalThis.PublicKeyCredential;return void 0===e?.isConditionalMediationAvailable?C.stubThis(new Promise((e=>e(!1)))):C.stubThis(e.isConditionalMediationAvailable())}())throw Error("Browser does not support WebAuthn autofill");if(document.querySelectorAll("input[autocomplete$='webauthn']").length<1&&r)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');s.mediation="conditional",i.allowCredentials=[]}let a;s.publicKey=i,s.signal=k.createNewAbortSignal();try{a=await navigator.credentials.get(s)}catch(e){throw function({error:e,options:t}){const{publicKey:n}=t;if(!n)throw Error("options was missing required publicKey property");if("AbortError"===e.name){if(t.signal instanceof AbortSignal)return new m({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else{if("NotAllowedError"===e.name)return new m({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});if("SecurityError"===e.name){const t=globalThis.location.hostname;if(!b(t))return new m({message:`${globalThis.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e});if(n.rpId!==t)return new m({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else if("UnknownError"===e.name)return new m({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e})}return e}({error:e,options:s})}if(!a)throw new Error("Authentication was not completed");const{id:c,rawId:h,response:l,type:u}=a;let d;return l.userHandle&&(d=p(l.userHandle)),{id:c,rawId:p(h),response:{authenticatorData:p(l.authenticatorData),clientDataJSON:p(l.clientDataJSON),signature:p(l.signature),userHandle:d},type:u,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:E(a.authenticatorAttachment)}}function A(e){var t=e.name,n=e.value,r=e.expire,o=e.domain,i=e.secure,s=r===1/0?" expires=Fri, 31 Dec 9999 23:59:59 GMT":"; max-age="+r;document.cookie=encodeURIComponent(t)+"="+n+"; path=/;"+s+(o?"; domain="+o:"")+(i?"; secure":"")}function R(e){var t,n=null!==(t=e.errorDescription)&&void 0!==t?t:e.error;return console.error(n),{error:n}}function O(e){var t;if(e&&"object"==typeof e&&"error"in e){var n=null!==(t=e.errorDescription)&&void 0!==t?t:e.error;return console.error(n),{error:n}}if(e&&"object"==typeof e&&"accessToken"in e&&"string"==typeof e.accessToken){var r=e.accessToken,o=l(e,["accessToken"]);return{data:h(h({},o),{token:r})}}return{data:e}}function x(e){var t,n;if(e instanceof m&&"ERROR_INVALID_RP_ID"===e.code){var r=(null===(n=null===(t=e.message)||void 0===t?void 0:t.match(/"([^"]*)"/))||void 0===n?void 0:n[1])||"";console.error('[Authsignal] The Relying Party ID "'.concat(r,'" is invalid for this domain.\n To learn more, visit https://docs.authsignal.com/scenarios/passkeys-prebuilt-ui#defining-the-relying-party'))}}function U(e){var t=e.token,n=e.tenantId;return{"Content-Type":"application/json",Authorization:t?"Bearer ".concat(t):"Basic ".concat(window.btoa(encodeURIComponent(n)))}}function P(e){var t=e.response,n=e.onTokenExpired;"error"in t&&"expired_token"===t.errorCode&&n&&n()}e.AuthsignalWindowMessage=void 0,(e.AuthsignalWindowMessage||(e.AuthsignalWindowMessage={})).AUTHSIGNAL_CLOSE_POPUP="AUTHSIGNAL_CLOSE_POPUP";var N=function(){function e(e){var t=e.baseUrl,n=e.tenantId,r=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=r}return e.prototype.registrationOptions=function(e){return u(this,arguments,void 0,(function(e){var t,n,r,o,i=e.token,s=e.username,a=e.authenticatorAttachment,c=e.useCookies;return d(this,(function(e){switch(e.label){case 0:return t=Boolean(a)?{username:s,authenticatorAttachment:a}:{username:s},n="".concat(this.baseUrl,c?"/client/user-authenticators/passkey/registration-options/web":"/client/user-authenticators/passkey/registration-options"),r=c?"include":"same-origin",[4,fetch(n,{method:"POST",headers:U({token:i,tenantId:this.tenantId}),body:JSON.stringify(t),credentials:r})];case 1:return[4,e.sent().json()];case 2:return P({response:o=e.sent(),onTokenExpired:this.onTokenExpired}),[2,o]}}))}))},e.prototype.authenticationOptions=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token,r=e.challengeId,o=e.useCookies;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/passkey/authentication-options"),{method:"POST",headers:U({token:n,tenantId:this.tenantId}),body:JSON.stringify({challengeId:r}),credentials:o?"include":"same-origin"})];case 1:return[4,e.sent().json()];case 2:return P({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.authenticationOptionsWeb=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/passkey/authentication-options/web"),{method:"POST",headers:U({token:n,tenantId:this.tenantId}),body:JSON.stringify({}),credentials:"include"})];case 1:return[4,e.sent().json()];case 2:return P({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.addAuthenticator=function(e){return u(this,arguments,void 0,(function(e){var t,n,r=e.token,o=e.registrationCredential,i=e.conditionalCreate,s=e.challengeId,a=e.useCookies;return d(this,(function(e){switch(e.label){case 0:return t={registrationCredential:o,conditionalCreate:i,challengeId:s},[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/passkey"),{method:"POST",headers:U({token:r,tenantId:this.tenantId}),body:JSON.stringify(t),credentials:a?"include":"same-origin"})];case 1:return[4,e.sent().json()];case 2:return P({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n,r=e.authenticationCredential,o=e.token,i=e.deviceId,s=e.challengeId,a=e.useCookies;return d(this,(function(e){switch(e.label){case 0:return t={authenticationCredential:r,deviceId:i,challengeId:s},[4,fetch("".concat(this.baseUrl,"/client/verify/passkey"),{method:"POST",headers:U({token:o,tenantId:this.tenantId}),body:JSON.stringify(t),credentials:a?"include":"same-origin"})];case 1:return[4,e.sent().json()];case 2:return P({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e.prototype.getPasskeyAuthenticator=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.credentialIds;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/passkey?credentialIds=").concat(n),{method:"GET",headers:U({tenantId:this.tenantId})})];case 1:if(!(t=e.sent()).ok)throw new Error(t.statusText);return[2,t.json()]}}))}))},e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t,n,r=e.action,o=e.useCookies;return d(this,(function(e){switch(e.label){case 0:return t="".concat(this.baseUrl,o?"/client/challenge/web":"/client/challenge"),[4,fetch(t,{method:"POST",headers:U({tenantId:this.tenantId}),body:JSON.stringify({action:r}),credentials:o?"include":"same-origin"})];case 1:return[4,e.sent().json()];case 2:return P({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e}(),_=function(){function e(){this.token=null}return e.prototype.handleTokenNotSetError=function(){var e="A token has not been set. Call 'setToken' first.";return console.error("Error: ".concat(e)),{error:"TOKEN_NOT_SET",errorDescription:e}},e.shared=new e,e}(),$=!1,D=function(){function e(e){var t=e.baseUrl,n=e.tenantId,r=e.anonymousId,o=e.onTokenExpired;this.passkeyLocalStorageKey="as_user_passkey_map",this.cache=_.shared,this.api=new N({baseUrl:t,tenantId:n,onTokenExpired:o}),this.anonymousId=r}return e.prototype.signUp=function(e){return u(this,arguments,void 0,(function(e){var t,n,r,o,i,s,a=e.username,c=e.displayName,l=e.token,u=e.authenticatorAttachment,p=void 0===u?"platform":u,f=e.useAutoRegister,v=void 0!==f&&f,g=e.useCookies,y=void 0!==g&&g;return d(this,(function(e){switch(e.label){case 0:return(t=null!=l?l:this.cache.token)?v?[4,this.doesBrowserSupportConditionalCreate()]:[3,2]:[2,this.cache.handleTokenNotSetError()];case 1:if(!e.sent())throw new Error("CONDITIONAL_CREATE_NOT_SUPPORTED");e.label=2;case 2:return n={username:a,displayName:c,token:t,authenticatorAttachment:p,useCookies:y},[4,this.api.registrationOptions(n)];case 3:if("error"in(r=e.sent()))return[2,R(r)];e.label=4;case 4:return e.trys.push([4,7,,8]),[4,I({optionsJSON:r.options,useAutoRegister:v})];case 5:return o=e.sent(),[4,this.api.addAuthenticator({registrationCredential:o,token:t,conditionalCreate:v,challengeId:r.challengeId,useCookies:y})];case 6:return"error"in(i=e.sent())?[2,R(i)]:(i.isVerified&&this.storeCredentialAgainstDevice(h(h({},o),{userId:i.userId})),i.accessToken&&(this.cache.token=i.accessToken),[2,{data:{token:i.accessToken,userAuthenticator:i.userAuthenticator,registrationResponse:o}}]);case 7:throw s=e.sent(),$=!1,x(s),s;case 8:return[2]}}))}))},e.prototype.signIn=function(e){return u(this,void 0,void 0,(function(){var t,n,r,o,i,s,a,c,l,u,p,f,v;return d(this,(function(d){switch(d.label){case 0:if((null==e?void 0:e.token)&&e.autofill)throw new Error("autofill is not supported when providing a token");if((null==e?void 0:e.action)&&e.token)throw new Error("action is not supported when providing a token");if(null==e?void 0:e.autofill){if($)return[2,{}];$=!0}return(null==e?void 0:e.action)?[4,this.api.challenge({action:null==e?void 0:e.action,useCookies:null==e?void 0:e.useCookies})]:[3,2];case 1:return n=d.sent(),[3,3];case 2:n=null,d.label=3;case 3:return(t=n)&&"error"in t?($=!1,[2,R(t)]):!(null==e?void 0:e.action)&&(null==e?void 0:e.useCookies)?[3,5]:[4,this.api.authenticationOptions({token:null==e?void 0:e.token,challengeId:null==t?void 0:t.challengeId,useCookies:null==e?void 0:e.useCookies})];case 4:return o=d.sent(),[3,7];case 5:return[4,this.api.authenticationOptionsWeb({token:null==e?void 0:e.token})];case 6:o=d.sent(),d.label=7;case 7:if("error"in(r=o))return $=!1,[2,R(r)];d.label=8;case 8:return d.trys.push([8,11,,12]),[4,S({optionsJSON:r.options,useBrowserAutofill:null==e?void 0:e.autofill})];case 9:return i=d.sent(),(null==e?void 0:e.onVerificationStarted)&&e.onVerificationStarted(),[4,this.api.verify({authenticationCredential:i,token:null==e?void 0:e.token,deviceId:this.anonymousId,challengeId:r.challengeId,useCookies:null==e?void 0:e.useCookies})];case 10:return"error"in(s=d.sent())?($=!1,[2,R(s)]):(s.isVerified&&this.storeCredentialAgainstDevice(h(h({},i),{userId:s.userId})),s.accessToken&&(this.cache.token=s.accessToken),a=s.accessToken,c=s.userId,l=s.userAuthenticatorId,u=s.username,p=s.userDisplayName,f=s.isVerified,$=!1,[2,{data:{isVerified:f,token:a,userId:c,userAuthenticatorId:l,username:u,displayName:p,authenticationResponse:i}}]);case 11:throw v=d.sent(),$=!1,x(v),v;case 12:return[2]}}))}))},e.prototype.isAvailableOnDevice=function(e){return u(this,arguments,void 0,(function(e){var t,n,r,o,i=e.userId;return d(this,(function(e){switch(e.label){case 0:if(!i)throw new Error("userId is required");if(!(t=localStorage.getItem(this.passkeyLocalStorageKey)))return[2,!1];if(n=JSON.parse(t),0===(r=null!==(o=n[i])&&void 0!==o?o:[]).length)return[2,!1];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.api.getPasskeyAuthenticator({credentialIds:r})];case 2:return e.sent(),[2,!0];case 3:return e.sent(),[2,!1];case 4:return[2]}}))}))},e.prototype.storeCredentialAgainstDevice=function(e){var t=e.id,n=e.authenticatorAttachment,r=e.userId,o=void 0===r?"":r;if("cross-platform"!==n){var i=localStorage.getItem(this.passkeyLocalStorageKey),s=i?JSON.parse(i):{};s[o]?s[o].includes(t)||s[o].push(t):s[o]=[t],localStorage.setItem(this.passkeyLocalStorageKey,JSON.stringify(s))}},e.prototype.doesBrowserSupportConditionalCreate=function(){return u(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return window.PublicKeyCredential&&PublicKeyCredential.getClientCapabilities?[4,PublicKeyCredential.getClientCapabilities()]:[3,2];case 1:if(e.sent().conditionalCreate)return[2,!0];e.label=2;case 2:return[2,!1]}}))}))},e}(),L=function(){function e(){this.windowRef=null}return e.prototype.show=function(e){var t=e.url,n=e.width,r=void 0===n?400:n,o=e.height,i=function(e){var t=e.url,n=e.width,r=e.height,o=e.win;if(!o.top)return null;var i=o.top.outerHeight/2+o.top.screenY-r/2,s=o.top.outerWidth/2+o.top.screenX-n/2;return window.open(t,"","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=".concat(n,", height=").concat(r,", top=").concat(i,", left=").concat(s))}({url:t,width:r,height:void 0===o?500:o,win:window});if(!i)throw new Error("Window is not initialized");return this.windowRef=i,i},e.prototype.close=function(){if(!this.windowRef)throw new Error("Window is not initialized");this.windowRef.close()},e}();const j=":not([inert]):not([inert] *)",J=':not([tabindex^="-"])',K=":not(:disabled)";var W=[`a[href]${j}${J}`,`area[href]${j}${J}`,`input:not([type="hidden"]):not([type="radio"])${j}${J}${K}`,`input[type="radio"]${j}${J}${K}`,`select${j}${J}${K}`,`textarea${j}${J}${K}`,`button${j}${J}${K}`,`details${j} > summary:first-of-type${J}`,`iframe${j}${J}`,`audio[controls]${j}${J}`,`video[controls]${j}${J}`,`[contenteditable]${j}${J}`,`[tabindex]${j}${J}`];function H(e){(e.querySelector("[autofocus]")||e).focus()}function M(e,t){if(t&&G(e))return e;if(!((n=e).shadowRoot&&"-1"===n.getAttribute("tabindex")||n.matches(":disabled,[hidden],[inert]")))if(e.shadowRoot){let n=V(e.shadowRoot,t);for(;n;){const e=M(n,t);if(e)return e;n=q(n,t)}}else if("slot"===e.localName){const n=e.assignedElements({flatten:!0});t||n.reverse();for(const e of n){const n=M(e,t);if(n)return n}}else{let n=V(e,t);for(;n;){const e=M(n,t);if(e)return e;n=q(n,t)}}var n;return!t&&G(e)?e:null}function V(e,t){return t?e.firstElementChild:e.lastElementChild}function q(e,t){return t?e.nextElementSibling:e.previousElementSibling}const G=e=>!e.shadowRoot?.delegatesFocus&&(e.matches(W.join(","))&&!(e=>!(!e.matches("details:not([open]) *")||e.matches("details>summary:first-of-type"))||!(e.offsetWidth||e.offsetHeight||e.getClientRects().length))(e));function F(e=document){const t=e.activeElement;return t?t.shadowRoot?F(t.shadowRoot)||document.activeElement:t:null}function B(e,t){const[n,r]=function(e){const t=M(e,!0);return[t,t?M(e,!1)||t:null]}(e);if(!n)return t.preventDefault();const o=F();t.shiftKey&&o===n?(r.focus(),t.preventDefault()):t.shiftKey||o!==r||(n.focus(),t.preventDefault())}class z{$el;id;previouslyFocused;shown;constructor(e){this.$el=e,this.id=this.$el.getAttribute("data-a11y-dialog")||this.$el.id,this.previouslyFocused=null,this.shown=!1,this.maintainFocus=this.maintainFocus.bind(this),this.bindKeypress=this.bindKeypress.bind(this),this.handleTriggerClicks=this.handleTriggerClicks.bind(this),this.show=this.show.bind(this),this.hide=this.hide.bind(this),this.$el.setAttribute("aria-hidden","true"),this.$el.setAttribute("aria-modal","true"),this.$el.setAttribute("tabindex","-1"),this.$el.hasAttribute("role")||this.$el.setAttribute("role","dialog"),document.addEventListener("click",this.handleTriggerClicks,!0)}destroy(){return this.hide(),document.removeEventListener("click",this.handleTriggerClicks,!0),this.$el.replaceWith(this.$el.cloneNode(!0)),this.fire("destroy"),this}show(e){return this.shown||(this.shown=!0,this.$el.removeAttribute("aria-hidden"),this.previouslyFocused=F(),"BODY"===this.previouslyFocused?.tagName&&e?.target&&(this.previouslyFocused=e.target),"focus"===e?.type?this.maintainFocus(e):H(this.$el),document.body.addEventListener("focus",this.maintainFocus,!0),this.$el.addEventListener("keydown",this.bindKeypress,!0),this.fire("show",e)),this}hide(e){return this.shown?(this.shown=!1,this.$el.setAttribute("aria-hidden","true"),this.previouslyFocused?.focus?.(),document.body.removeEventListener("focus",this.maintainFocus,!0),this.$el.removeEventListener("keydown",this.bindKeypress,!0),this.fire("hide",e),this):this}on(e,t,n){return this.$el.addEventListener(e,t,n),this}off(e,t,n){return this.$el.removeEventListener(e,t,n),this}fire(e,t){this.$el.dispatchEvent(new CustomEvent(e,{detail:t,cancelable:!0}))}handleTriggerClicks(e){const t=e.target;t.closest(`[data-a11y-dialog-show="${this.id}"]`)&&this.show(e),(t.closest(`[data-a11y-dialog-hide="${this.id}"]`)||t.closest("[data-a11y-dialog-hide]")&&t.closest('[aria-modal="true"]')===this.$el)&&this.hide(e)}bindKeypress(e){if(document.activeElement?.closest('[aria-modal="true"]')!==this.$el)return;let t=!1;try{t=!!this.$el.querySelector('[popover]:not([popover="manual"]):popover-open')}catch{}"Escape"!==e.key||"alertdialog"===this.$el.getAttribute("role")||t||(e.preventDefault(),this.hide(e)),"Tab"===e.key&&B(this.$el,e)}maintainFocus(e){e.target.closest('[aria-modal="true"], [data-a11y-dialog-ignore-focus-trap]')||H(this.$el)}}function Y(){for(const e of document.querySelectorAll("[data-a11y-dialog]"))new z(e)}"undefined"!=typeof document&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",Y):Y());var Q="__authsignal-popup-container",X="__authsignal-popup-content",Z="__authsignal-popup-overlay",ee="__authsignal-popup-style",te="__authsignal-popup-iframe",ne="385px",re=function(){function e(e){var t=e.width,n=e.height,r=e.isClosable;if(this.popup=null,document.querySelector("#".concat(Q)))throw new Error("Multiple instances of Authsignal popup is not supported.");this.height=n,this.create({width:t,height:n,isClosable:r})}return e.prototype.create=function(e){var t=this,n=e.width,r=void 0===n?ne:n,o=e.height,i=e.isClosable,s=void 0===i||i,a=r;CSS.supports("width",r)||(console.warn("Invalid CSS value for `popupOptions.width`. Using default value instead."),a=ne);var c=document.createElement("div");c.setAttribute("id",Q),c.setAttribute("aria-hidden","true"),s||c.setAttribute("role","alertdialog");var h=document.createElement("div");h.setAttribute("id",Z),s&&h.setAttribute("data-a11y-dialog-hide","true");var l=document.createElement("div");l.setAttribute("id",X),document.body.appendChild(c);var u=document.createElement("style");u.setAttribute("id",ee),u.textContent="\n #".concat(Q,",\n #").concat(Z," {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n }\n\n #").concat(Q," {\n z-index: 2147483647;\n display: flex;\n }\n\n #").concat(Q,"[aria-hidden='true'] {\n display: none;\n }\n\n #").concat(Z," {\n background-color: rgba(0, 0, 0, 0.18);\n }\n\n #").concat(X," {\n margin: auto;\n z-index: 2147483647;\n position: relative;\n background-color: transparent;\n border-radius: 8px;\n width: ").concat(a,";\n }\n\n #").concat(X," iframe {\n width: 1px;\n min-width: 100%;\n border-radius: inherit;\n max-height: ").concat(o?"100%":"95vh",";\n height: ").concat(null!=o?o:"384px",";\n }\n "),document.head.insertAdjacentElement("beforeend",u),c.appendChild(h),c.appendChild(l),this.popup=new z(c),c.focus(),this.popup.on("hide",(function(){t.destroy()}))},e.prototype.destroy=function(){var e=document.querySelector("#".concat(Q)),t=document.querySelector("#".concat(ee));e&&t&&(document.body.removeChild(e),document.head.removeChild(t)),window.removeEventListener("message",oe)},e.prototype.show=function(e){var t,n=e.url;if(!this.popup)throw new Error("Popup is not initialized");var r=document.createElement("iframe");r.setAttribute("id",te),r.setAttribute("name","authsignal"),r.setAttribute("title","Authsignal multi-factor authentication"),r.setAttribute("src",n),r.setAttribute("frameborder","0"),r.setAttribute("allow","publickey-credentials-get *; publickey-credentials-create *; clipboard-write");var o=document.querySelector("#".concat(X));o&&o.appendChild(r),this.height||window.addEventListener("message",oe),null===(t=this.popup)||void 0===t||t.show()},e.prototype.close=function(){if(!this.popup)throw new Error("Popup is not initialized");this.popup.hide()},e.prototype.on=function(e,t){if(!this.popup)throw new Error("Popup is not initialized");this.popup.on(e,t)},e}();function oe(e){var t=document.querySelector("#".concat(te));t&&e.data.height&&(t.style.height=e.data.height+"px")}var ie=function(){function e(e){var t=e.baseUrl,n=e.tenantId,r=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=r}return e.prototype.enroll=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/totp"),{method:"POST",headers:U({token:n,tenantId:this.tenantId})})];case 1:return[4,e.sent().json()];case 2:return P({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n,r=e.token,o=e.code;return d(this,(function(e){switch(e.label){case 0:return t={verificationCode:o},[4,fetch("".concat(this.baseUrl,"/client/verify/totp"),{method:"POST",headers:U({token:r,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return P({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e}(),se=function(){function e(e){var t=e.baseUrl,n=e.tenantId,r=e.onTokenExpired;this.cache=_.shared,this.api=new ie({baseUrl:t,tenantId:n,onTokenExpired:r})}return e.prototype.enroll=function(){return u(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.enroll({token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O(e.sent())]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.code;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.verify({token:this.cache.token,code:n})]:[2,this.cache.handleTokenNotSetError()];case 1:return"accessToken"in(t=e.sent())&&t.accessToken&&(this.cache.token=t.accessToken),[2,O(t)]}}))}))},e}(),ae=function(){function e(e){var t=e.baseUrl,n=e.tenantId,r=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=r}return e.prototype.enroll=function(e){return u(this,arguments,void 0,(function(e){var t,n,r=e.token,o=e.email;return d(this,(function(e){switch(e.label){case 0:return t={email:o},[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/email-otp"),{method:"POST",headers:U({token:r,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return P({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/challenge/email-otp"),{method:"POST",headers:U({token:n,tenantId:this.tenantId})})];case 1:return[4,e.sent().json()];case 2:return P({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n,r=e.token,o=e.code;return d(this,(function(e){switch(e.label){case 0:return t={verificationCode:o},[4,fetch("".concat(this.baseUrl,"/client/verify/email-otp"),{method:"POST",headers:U({token:r,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return P({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e}(),ce=function(){function e(e){var t=e.baseUrl,n=e.tenantId,r=e.onTokenExpired;this.cache=_.shared,this.api=new ae({baseUrl:t,tenantId:n,onTokenExpired:r})}return e.prototype.enroll=function(e){return u(this,arguments,void 0,(function(e){var t=e.email;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.enroll({token:this.cache.token,email:t})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O(e.sent())]}}))}))},e.prototype.challenge=function(){return u(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.challenge({token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O(e.sent())]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.code;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.verify({token:this.cache.token,code:n})]:[2,this.cache.handleTokenNotSetError()];case 1:return"accessToken"in(t=e.sent())&&t.accessToken&&(this.cache.token=t.accessToken),[2,O(t)]}}))}))},e}(),he=function(){function e(e){var t=e.baseUrl,n=e.tenantId,r=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=r}return e.prototype.enroll=function(e){return u(this,arguments,void 0,(function(e){var t,n,r=e.token,o=e.phoneNumber;return d(this,(function(e){switch(e.label){case 0:return t={phoneNumber:o},[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/sms"),{method:"POST",headers:U({token:r,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return P({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/challenge/sms"),{method:"POST",headers:U({token:n,tenantId:this.tenantId})})];case 1:return[4,e.sent().json()];case 2:return P({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n,r=e.token,o=e.code;return d(this,(function(e){switch(e.label){case 0:return t={verificationCode:o},[4,fetch("".concat(this.baseUrl,"/client/verify/sms"),{method:"POST",headers:U({token:r,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return P({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e}(),le=function(){function e(e){var t=e.baseUrl,n=e.tenantId,r=e.onTokenExpired;this.cache=_.shared,this.api=new he({baseUrl:t,tenantId:n,onTokenExpired:r})}return e.prototype.enroll=function(e){return u(this,arguments,void 0,(function(e){var t=e.phoneNumber;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.enroll({token:this.cache.token,phoneNumber:t})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O(e.sent())]}}))}))},e.prototype.challenge=function(){return u(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.challenge({token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O(e.sent())]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.code;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.verify({token:this.cache.token,code:n})]:[2,this.cache.handleTokenNotSetError()];case 1:return"accessToken"in(t=e.sent())&&t.accessToken&&(this.cache.token=t.accessToken),[2,O(t)]}}))}))},e}(),ue=function(){function e(e){var t=e.baseUrl,n=e.tenantId,r=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=r}return e.prototype.enroll=function(e){return u(this,arguments,void 0,(function(e){var t,n,r=e.token,o=e.email;return d(this,(function(e){switch(e.label){case 0:return t={email:o},[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/email-magic-link"),{method:"POST",headers:U({token:r,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return P({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/challenge/email-magic-link"),{method:"POST",headers:U({token:n,tenantId:this.tenantId})})];case 1:return[4,e.sent().json()];case 2:return P({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.checkVerificationStatus=function(e){return u(this,arguments,void 0,(function(e){var t,n=this,r=e.token;return d(this,(function(e){switch(e.label){case 0:return t=function(){return u(n,void 0,void 0,(function(){var e,n=this;return d(this,(function(o){switch(o.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/verify/email-magic-link/finalize"),{method:"POST",headers:U({token:r,tenantId:this.tenantId}),body:JSON.stringify({})})];case 1:return[4,o.sent().json()];case 2:return P({response:e=o.sent(),onTokenExpired:this.onTokenExpired}),e.isVerified?[2,e]:[2,new Promise((function(e){setTimeout((function(){return u(n,void 0,void 0,(function(){var n;return d(this,(function(r){switch(r.label){case 0:return n=e,[4,t()];case 1:return n.apply(void 0,[r.sent()]),[2]}}))}))}),1e3)}))]}}))}))},[4,t()];case 1:return[2,e.sent()]}}))}))},e}(),de=function(){function e(e){var t=e.baseUrl,n=e.tenantId,r=e.onTokenExpired;this.cache=_.shared,this.api=new ue({baseUrl:t,tenantId:n,onTokenExpired:r})}return e.prototype.enroll=function(e){return u(this,arguments,void 0,(function(e){var t=e.email;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.enroll({token:this.cache.token,email:t})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O(e.sent())]}}))}))},e.prototype.challenge=function(){return u(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.challenge({token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O(e.sent())]}}))}))},e.prototype.checkVerificationStatus=function(){return u(this,void 0,void 0,(function(){var e;return d(this,(function(t){switch(t.label){case 0:return this.cache.token?[4,this.api.checkVerificationStatus({token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return"accessToken"in(e=t.sent())&&e.accessToken&&(this.cache.token=e.accessToken),[2,O(e)]}}))}))},e}(),pe=function(){function e(e){var t=e.baseUrl,n=e.tenantId,r=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=r}return e.prototype.registrationOptions=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/security-key/registration-options"),{method:"POST",headers:U({token:n,tenantId:this.tenantId}),body:JSON.stringify({})})];case 1:return[4,e.sent().json()];case 2:return P({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.authenticationOptions=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/security-key/authentication-options"),{method:"POST",headers:U({token:n,tenantId:this.tenantId}),body:JSON.stringify({})})];case 1:return[4,e.sent().json()];case 2:return P({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.addAuthenticator=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token,r=e.registrationCredential;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/security-key"),{method:"POST",headers:U({token:n,tenantId:this.tenantId}),body:JSON.stringify(r)})];case 1:return[4,e.sent().json()];case 2:return P({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token,r=e.authenticationCredential;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/verify/security-key"),{method:"POST",headers:U({token:n,tenantId:this.tenantId}),body:JSON.stringify(r)})];case 1:return[4,e.sent().json()];case 2:return P({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e}(),fe=function(){function e(e){var t=e.baseUrl,n=e.tenantId,r=e.onTokenExpired;this.cache=_.shared,this.api=new pe({baseUrl:t,tenantId:n,onTokenExpired:r})}return e.prototype.enroll=function(){return u(this,void 0,void 0,(function(){var e,t,n,r,o;return d(this,(function(i){switch(i.label){case 0:return this.cache.token?(e={token:this.cache.token},[4,this.api.registrationOptions(e)]):[2,this.cache.handleTokenNotSetError()];case 1:if("error"in(t=i.sent()))return[2,R(t)];i.label=2;case 2:return i.trys.push([2,5,,6]),[4,I({optionsJSON:t})];case 3:return n=i.sent(),[4,this.api.addAuthenticator({registrationCredential:n,token:this.cache.token})];case 4:return"error"in(r=i.sent())?[2,R(r)]:(r.accessToken&&(this.cache.token=r.accessToken),[2,{data:{token:r.accessToken,registrationResponse:n}}]);case 5:throw x(o=i.sent()),o;case 6:return[2]}}))}))},e.prototype.verify=function(){return u(this,void 0,void 0,(function(){var e,t,n,r,o;return d(this,(function(i){switch(i.label){case 0:return this.cache.token?[4,this.api.authenticationOptions({token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:if("error"in(e=i.sent()))return[2,R(e)];i.label=2;case 2:return i.trys.push([2,5,,6]),[4,S({optionsJSON:e})];case 3:return t=i.sent(),[4,this.api.verify({authenticationCredential:t,token:this.cache.token})];case 4:return"error"in(n=i.sent())?[2,R(n)]:(n.accessToken&&(this.cache.token=n.accessToken),r=n.accessToken,[2,{data:{isVerified:n.isVerified,token:r,authenticationResponse:t}}]);case 5:throw x(o=i.sent()),o;case 6:return[2]}}))}))},e}(),ve=function(){function e(e){var t=e.baseUrl,n=e.tenantId;this.tenantId=n,this.baseUrl=t}return e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.action,r=e.token,o=e.custom;return d(this,(function(e){switch(e.label){case 0:return t={action:n,custom:o},[4,fetch("".concat(this.baseUrl,"/client/challenge/qr-code"),{method:"POST",headers:U({tenantId:this.tenantId,token:r}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return[2,e.sent()]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.challengeId,r=e.deviceCode;return d(this,(function(e){switch(e.label){case 0:return t={challengeId:n,deviceCode:r},[4,fetch("".concat(this.baseUrl,"/client/verify/qr-code"),{method:"POST",headers:U({tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return[2,e.sent()]}}))}))},e}(),ge=function(){},ye=54e4,be=3e3,me=function(e){function t(t){var n=t.baseUrl,r=t.tenantId,o=e.call(this)||this;return o.cache=_.shared,o.api=new ve({baseUrl:n,tenantId:r}),o}return c(t,e),t.prototype.challenge=function(e){return u(this,void 0,void 0,(function(){var t,n,r,o,i,s=this;return d(this,(function(a){switch(a.label){case 0:return[4,this.api.challenge({token:this.cache.token||void 0,action:e.action,custom:e.custom})];case 1:return t=a.sent(),(n=O(t)).data&&(this.currentChallengeParams=e,this.clearPolling(),r=e.pollInterval||be,o=e.refreshInterval||ye,n.data.deviceCode&&this.startPolling({challengeId:n.data.challengeId,deviceCode:n.data.deviceCode,onStateChange:e.onStateChange,pollInterval:r}),e.onRefresh&&(i=e.onRefresh,this.startRefreshTimer((function(){return s.performRefresh({action:e.action,custom:e.custom,onRefresh:i,onStateChange:e.onStateChange,pollInterval:r})}),o))),[2,n]}}))}))},t.prototype.refresh=function(){return u(this,arguments,void 0,(function(e){var t,n,r,o,i,s,a,c,h,l=this,u=(void 0===e?{}:e).custom;return d(this,(function(e){switch(e.label){case 0:return this.currentChallengeParams?[4,this.api.challenge({token:this.cache.token||void 0,action:this.currentChallengeParams.action,custom:u||this.currentChallengeParams.custom})]:[2];case 1:return t=e.sent(),(n=O(t)).data&&(this.clearPolling(),this.currentChallengeParams.onRefresh&&this.currentChallengeParams.onRefresh(n.data.challengeId,n.data.expiresAt),n.data.deviceCode&&this.startPolling({challengeId:n.data.challengeId,deviceCode:n.data.deviceCode,onStateChange:this.currentChallengeParams.onStateChange,pollInterval:this.currentChallengeParams.pollInterval||be}),this.currentChallengeParams.onRefresh&&(r=this.currentChallengeParams.refreshInterval||ye,o=this.currentChallengeParams,i=o.action,s=o.custom,a=o.onRefresh,c=o.onStateChange,h=o.pollInterval,this.startRefreshTimer((function(){return l.performRefresh({action:i,custom:s,onRefresh:a,onStateChange:c,pollInterval:h||be})}),r))),[2]}}))}))},t.prototype.disconnect=function(){this.clearPolling(),this.clearRefreshTimer(),this.currentChallengeParams=void 0},t.prototype.startRefreshTimer=function(e,t){var n=this;this.clearRefreshTimer(),this.refreshTimeout=setTimeout((function(){return u(n,void 0,void 0,(function(){return d(this,(function(n){switch(n.label){case 0:return[4,e()];case 1:return n.sent(),this.startRefreshTimer(e,t),[2]}}))}))}),t)},t.prototype.clearRefreshTimer=function(){this.refreshTimeout&&(clearTimeout(this.refreshTimeout),this.refreshTimeout=void 0)},t.prototype.performRefresh=function(e){return u(this,arguments,void 0,(function(e){var t,n,r=e.action,o=e.custom,i=e.onRefresh,s=e.onStateChange,a=e.pollInterval;return d(this,(function(e){switch(e.label){case 0:return[4,this.api.challenge({token:this.cache.token||void 0,action:r,custom:o})];case 1:return t=e.sent(),(n=O(t)).data&&(this.clearPolling(),i(n.data.challengeId,n.data.expiresAt),n.data.deviceCode&&this.startPolling({challengeId:n.data.challengeId,deviceCode:n.data.deviceCode,onStateChange:s,pollInterval:a})),[2]}}))}))},t.prototype.startPolling=function(e){var t=this,n=e.challengeId,r=e.deviceCode,o=e.onStateChange,i=e.pollInterval;this.pollingInterval=setInterval((function(){return u(t,void 0,void 0,(function(){var e,t;return d(this,(function(i){switch(i.label){case 0:return[4,this.api.verify({challengeId:n,deviceCode:r})];case 1:return e=i.sent(),(t=O(e)).data&&(t.data.isVerified?(o("approved",t.data.token),this.clearPolling()):t.data.isClaimed&&!t.data.isConsumed?o("claimed"):t.data.isClaimed&&t.data.isConsumed&&(o("rejected"),this.clearPolling())),[2]}}))}))}),i)},t.prototype.clearPolling=function(){this.pollingInterval&&(clearInterval(this.pollingInterval),this.pollingInterval=void 0)},t}(ge),ke="CHALLENGE_CREATED_HANDLER",we=function(){function e(e){var t=e.baseUrl,n=e.tenantId;this.ws=null,this.messageHandlers=new Map,this.options=null,this.refreshInterval=null,this.tokenCache=_.shared;var r=t.replace("https://","wss://").replace("http://","ws://").replace("v1","ws-v1-challenge").replace("api","api-ws");this.baseUrl=r,this.tenantId=n}return e.prototype.connect=function(){return u(this,void 0,void 0,(function(){var e=this;return d(this,(function(t){return[2,new Promise((function(t,n){try{var r=["authsignal-ws"];e.tokenCache.token?r.push("x.authsignal.token.".concat(e.tokenCache.token)):r.push("x.authsignal.tenant.".concat(e.tenantId)),e.ws=new WebSocket(e.baseUrl,r),e.ws.onopen=function(){t()},e.ws.onerror=function(e){n(new Error("WebSocket connection error: ".concat(e)))},e.ws.onclose=function(){e.refreshInterval&&(clearInterval(e.refreshInterval),e.refreshInterval=null),e.messageHandlers.clear(),e.ws=null},e.ws.onmessage=function(t){try{var n=JSON.parse(t.data);e.handleMessage(n)}catch(e){console.error("Failed to parse WebSocket message:",e)}}}catch(e){n(e)}}))]}))}))},e.prototype.handleMessage=function(e){if("CHALLENGE_CREATED"===e.type){if(!(t=this.messageHandlers.get(ke)))throw new Error("Challenge created handler not found");t(e)}else if("STATE_CHANGE"===e.type){var t;(t=this.messageHandlers.get(e.data.challengeId))&&t(e)}},e.prototype.createQrCodeChallenge=function(e){return u(this,void 0,void 0,(function(){var t=this;return d(this,(function(n){switch(n.label){case 0:return this.ws&&this.ws.readyState===WebSocket.OPEN?[3,2]:[4,this.connect()];case 1:n.sent(),n.label=2;case 2:return this.refreshInterval&&clearInterval(this.refreshInterval),this.options=e,[2,new Promise((function(n,r){t.messageHandlers.set(ke,(function(r){if("CHALLENGE_CREATED"===r.type){var o=r;t.messageHandlers.delete(ke),t.monitorChallengeState(o.data.challengeId,e),t.startRefreshCycle(o.data.challengeId,e),n({challengeId:o.data.challengeId,expiresAt:o.data.expiresAt,state:o.data.state})}})),t.sendChallengeRequest(e).catch(r)}))]}}))}))},e.prototype.monitorChallengeState=function(e,t){var n=this;this.messageHandlers.set(e,(function(r){var o;if("STATE_CHANGE"===r.type){var i=r;null===(o=t.onStateChange)||void 0===o||o.call(t,i.data.state,i.data.accessToken),"approved"!==i.data.state&&"rejected"!==i.data.state||n.messageHandlers.delete(e)}}))},e.prototype.startRefreshCycle=function(e,t){var n=this,r=t.refreshInterval||54e4,o=e;this.refreshInterval=setInterval((function(){return u(n,void 0,void 0,(function(){var e,n,r;return d(this,(function(i){switch(i.label){case 0:this.messageHandlers.delete(o),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.createQrCodeChallenge(t)];case 2:return e=i.sent(),o=e.challengeId,null===(r=t.onRefresh)||void 0===r||r.call(t,e.challengeId,e.expiresAt),[3,4];case 3:return n=i.sent(),console.error("Failed to refresh QR code challenge:",n),this.refreshInterval&&(clearInterval(this.refreshInterval),this.refreshInterval=null),[3,4];case 4:return[2]}}))}))}),r)},e.prototype.sendChallengeRequest=function(e){return u(this,void 0,void 0,(function(){return d(this,(function(t){switch(t.label){case 0:return this.ws&&this.ws.readyState===WebSocket.OPEN?[3,2]:[4,this.connect()];case 1:t.sent(),t.label=2;case 2:if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket connection could not be established");return this.sendMessage({type:"CREATE_CHALLENGE",data:{challengeType:"QR_CODE",actionCode:e.action,custom:e.custom}}),[2]}}))}))},e.prototype.sendMessage=function(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");this.ws.send(JSON.stringify(e))},e.prototype.refreshQrCodeChallenge=function(e){return u(this,arguments,void 0,(function(e){var t,n,r,o=e.custom;return d(this,(function(e){switch(e.label){case 0:if(!this.options)throw new Error("Call createQrCodeChallenge first");return[4,this.createQrCodeChallenge(h(h({},this.options),void 0!==o&&{custom:o}))];case 1:return t=e.sent(),null===(r=(n=this.options).onRefresh)||void 0===r||r.call(n,t.challengeId,t.expiresAt),[2,t]}}))}))},e.prototype.disconnect=function(){this.ws&&this.ws.close()},e}(),Ee=function(e){function t(t){var n=t.baseUrl,r=t.tenantId,o=e.call(this)||this;return o.cache=_.shared,o.wsClient=new we({baseUrl:n,tenantId:r}),o}return c(t,e),t.prototype.challenge=function(e){return u(this,void 0,void 0,(function(){var t;return d(this,(function(n){switch(n.label){case 0:return[4,this.wsClient.createQrCodeChallenge({token:this.cache.token||void 0,action:e.action,custom:e.custom,refreshInterval:e.refreshInterval,onRefresh:e.onRefresh,onStateChange:e.onStateChange})];case 1:return[2,{data:{challengeId:(t=n.sent()).challengeId,expiresAt:t.expiresAt}}]}}))}))},t.prototype.refresh=function(){return u(this,arguments,void 0,(function(e){var t=(void 0===e?{}:e).custom;return d(this,(function(e){switch(e.label){case 0:return[4,this.wsClient.refreshQrCodeChallenge({custom:t})];case 1:return e.sent(),[2]}}))}))},t.prototype.disconnect=function(){this.wsClient.disconnect()},t}(ge),Ie=function(){function e(e){var t=e.baseUrl,n=e.tenantId;this.handler=null,this.baseUrl=t,this.tenantId=n}return e.prototype.challenge=function(e){return u(this,void 0,void 0,(function(){var t,n,r;return d(this,(function(o){return t=e.polling,n=void 0!==t&&t,r=l(e,["polling"]),this.handler&&this.handler.disconnect(),this.handler=n?new me({baseUrl:this.baseUrl,tenantId:this.tenantId}):new Ee({baseUrl:this.baseUrl,tenantId:this.tenantId}),[2,this.handler.challenge(r)]}))}))},e.prototype.refresh=function(){return u(this,arguments,void 0,(function(e){var t=(void 0===e?{}:e).custom;return d(this,(function(e){if(!this.handler)throw new Error("challenge() must be called before refresh()");return[2,this.handler.refresh({custom:t})]}))}))},e.prototype.disconnect=function(){this.handler&&(this.handler.disconnect(),this.handler=null)},e}(),Te=function(){function e(e){var t=e.baseUrl,n=e.tenantId,r=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=r}return e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t,n,r=e.action,o=e.token;return d(this,(function(e){switch(e.label){case 0:return t={action:r},[4,fetch("".concat(this.baseUrl,"/client/challenge/push"),{method:"POST",headers:U({token:o,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return P({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n,r=e.challengeId,o=e.token;return d(this,(function(e){switch(e.label){case 0:return t={challengeId:r},[4,fetch("".concat(this.baseUrl,"/client/verify/push"),{method:"POST",headers:U({token:o,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return P({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e}(),Ce=function(){function e(e){var t=e.baseUrl,n=e.tenantId,r=e.onTokenExpired;this.cache=_.shared,this.api=new Te({baseUrl:t,tenantId:n,onTokenExpired:r})}return e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t=e.action;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.challenge({action:t,token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O(e.sent())]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t=e.challengeId;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.verify({challengeId:t,token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O(e.sent())]}}))}))},e}(),Se=function(){function e(e){var t=e.baseUrl,n=e.tenantId,r=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=r}return e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/challenge/whatsapp"),{method:"POST",headers:U({token:n,tenantId:this.tenantId})})];case 1:return[4,e.sent().json()];case 2:return P({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n,r=e.token,o=e.code;return d(this,(function(e){switch(e.label){case 0:return t={verificationCode:o},[4,fetch("".concat(this.baseUrl,"/client/verify/whatsapp"),{method:"POST",headers:U({token:r,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return P({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e}(),Ae=function(){function e(e){var t=e.baseUrl,n=e.tenantId,r=e.onTokenExpired;this.cache=_.shared,this.api=new Se({baseUrl:t,tenantId:n,onTokenExpired:r})}return e.prototype.challenge=function(){return u(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.challenge({token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O(e.sent())]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.code;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.verify({token:this.cache.token,code:n})]:[2,this.cache.handleTokenNotSetError()];case 1:return"accessToken"in(t=e.sent())&&t.accessToken&&(this.cache.token=t.accessToken),[2,O(t)]}}))}))},e}(),Re="4a08uqve",Oe=function(){function t(e){var t=e.cookieDomain,n=e.cookieName,r=void 0===n?"__as_aid":n,o=e.baseUrl,i=void 0===o?"https://api.authsignal.com/v1":o,a=e.tenantId,c=e.onTokenExpired;if(this.anonymousId="",this.profilingId="",this.cookieDomain="",this.anonymousIdCookieName="",this.cookieDomain=t||document.location.hostname.replace("www.",""),this.anonymousIdCookieName=r,!a)throw new Error("tenantId is required");var h,l=(h=this.anonymousIdCookieName)&&decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*"+encodeURIComponent(h).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*([^;]*).*$)|^.*$"),"$1"))||null;l?this.anonymousId=l:(this.anonymousId=s(),A({name:this.anonymousIdCookieName,value:this.anonymousId,expire:1/0,domain:this.cookieDomain,secure:"http:"!==document.location.protocol})),this.passkey=new D({tenantId:a,baseUrl:i,anonymousId:this.anonymousId,onTokenExpired:c}),this.totp=new se({tenantId:a,baseUrl:i,onTokenExpired:c}),this.email=new ce({tenantId:a,baseUrl:i,onTokenExpired:c}),this.emailML=new de({tenantId:a,baseUrl:i,onTokenExpired:c}),this.sms=new le({tenantId:a,baseUrl:i,onTokenExpired:c}),this.securityKey=new fe({tenantId:a,baseUrl:i,onTokenExpired:c}),this.qrCode=new Ie({tenantId:a,baseUrl:i}),this.push=new Ce({tenantId:a,baseUrl:i,onTokenExpired:c}),this.whatsapp=new Ae({tenantId:a,baseUrl:i,onTokenExpired:c})}return t.prototype.setToken=function(e){_.shared.token=e},t.prototype.launch=function(e,t){switch(null==t?void 0:t.mode){case"window":return this.launchWithWindow(e,t);case"popup":return this.launchWithPopup(e,t);default:this.launchWithRedirect(e)}},t.prototype.initAdvancedProfiling=function(e){var t=s();this.profilingId=t,A({name:"__as_pid",value:t,expire:1/0,domain:this.cookieDomain,secure:"http:"!==document.location.protocol});var n=e?"".concat(e,"/fp/tags.js?org_id=").concat(Re,"&session_id=").concat(t):"https://h.online-metrix.net/fp/tags.js?org_id=".concat(Re,"&session_id=").concat(t),r=document.createElement("script");r.src=n,r.async=!1,r.id="as_adv_profile",document.head.appendChild(r);var o=document.createElement("noscript");o.setAttribute("id","as_adv_profile_pixel"),o.setAttribute("aria-hidden","true");var i=document.createElement("iframe"),a=e?"".concat(e,"/fp/tags?org_id=").concat(Re,"&session_id=").concat(t):"https://h.online-metrix.net/fp/tags?org_id=".concat(Re,"&session_id=").concat(t);i.setAttribute("id","as_adv_profile_pixel"),i.setAttribute("src",a),i.setAttribute("style","width: 100px; height: 100px; border: 0; position: absolute; top: -5000px;"),o&&(o.appendChild(i),document.body.prepend(o))},t.prototype.launchWithRedirect=function(e){window.location.href=e},t.prototype.launchWithPopup=function(t,n){var r=n.popupOptions,o=new re({width:null==r?void 0:r.width,height:null==r?void 0:r.height,isClosable:null==r?void 0:r.isClosable}),i="".concat(t,"&mode=popup");return o.show({url:i}),new Promise((function(t){var n=void 0;o.on("hide",(function(){t({token:n})})),window.addEventListener("message",(function(t){var r=null;try{r=JSON.parse(t.data)}catch(e){}(null==r?void 0:r.event)===e.AuthsignalWindowMessage.AUTHSIGNAL_CLOSE_POPUP&&(n=r.token,o.close())}),!1)}))},t.prototype.launchWithWindow=function(t,n){var r=n.windowOptions,o=new L,i="".concat(t,"&mode=popup");return o.show({url:i,width:null==r?void 0:r.width,height:null==r?void 0:r.height}),new Promise((function(t){window.addEventListener("message",(function(n){var r=null;try{r=JSON.parse(n.data)}catch(e){}(null==r?void 0:r.event)===e.AuthsignalWindowMessage.AUTHSIGNAL_CLOSE_POPUP&&(o.close(),t({token:r.token}))}),!1)}))},t}();return e.Authsignal=Oe,e.WebAuthnError=m,e.Whatsapp=Ae,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
|
|
1
|
+
var authsignal=function(e){"use strict";let t;const n=new Uint8Array(16);function o(){if(!t&&(t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!t))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return t(n)}const r=[];for(let e=0;e<256;++e)r.push((e+256).toString(16).slice(1));var i={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function s(e,t,n){if(i.randomUUID&&!t&&!e)return i.randomUUID();const s=(e=e||{}).random||(e.rng||o)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=s[e];return t}return function(e,t=0){return(r[e[t+0]]+r[e[t+1]]+r[e[t+2]]+r[e[t+3]]+"-"+r[e[t+4]]+r[e[t+5]]+"-"+r[e[t+6]]+r[e[t+7]]+"-"+r[e[t+8]]+r[e[t+9]]+"-"+r[e[t+10]]+r[e[t+11]]+r[e[t+12]]+r[e[t+13]]+r[e[t+14]]+r[e[t+15]]).toLowerCase()}(s)}var a=function(e,t){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},a(e,t)};function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var l=function(){return l=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},l.apply(this,arguments)};function h(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}function u(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{c(o.next(e))}catch(e){i(e)}}function a(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))}function d(e,t){var n,o,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,o=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function p(e){const t=new Uint8Array(e);let n="";for(const e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function g(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=(4-t.length%4)%4,o=t.padEnd(t.length+n,"="),r=atob(o),i=new ArrayBuffer(r.length),s=new Uint8Array(i);for(let e=0;e<r.length;e++)s[e]=r.charCodeAt(e);return i}function f(){return b.stubThis(void 0!==globalThis?.PublicKeyCredential&&"function"==typeof globalThis.PublicKeyCredential)}const b={stubThis:e=>e};function v(e){const{id:t}=e;return{...e,id:g(t),transports:e.transports}}function y(e){return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}class m extends Error{constructor({message:e,code:t,cause:n,name:o}){super(e,{cause:n}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=o??n.name,this.code=t}}const k=new class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){const e=new Error("Cancelling existing WebAuthn API call for new one");e.name="AbortError",this.controller.abort(e)}const e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){const e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}},w=["cross-platform","platform"];function E(e){if(e&&!(w.indexOf(e)<0))return e}async function I(e){!e.optionsJSON&&e.challenge&&(console.warn("startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information."),e={optionsJSON:e});const{optionsJSON:t,useAutoRegister:n=!1}=e;if(!f())throw new Error("WebAuthn is not supported in this browser");const o={...t,challenge:g(t.challenge),user:{...t.user,id:g(t.user.id)},excludeCredentials:t.excludeCredentials?.map(v)},r={};let i;n&&(r.mediation="conditional"),r.publicKey=o,r.signal=k.createNewAbortSignal();try{i=await navigator.credentials.create(r)}catch(e){throw function({error:e,options:t}){const{publicKey:n}=t;if(!n)throw Error("options was missing required publicKey property");if("AbortError"===e.name){if(t.signal instanceof AbortSignal)return new m({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else if("ConstraintError"===e.name){if(!0===n.authenticatorSelection?.requireResidentKey)return new m({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:e});if("conditional"===t.mediation&&"required"===n.authenticatorSelection?.userVerification)return new m({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:e});if("required"===n.authenticatorSelection?.userVerification)return new m({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:e})}else{if("InvalidStateError"===e.name)return new m({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:e});if("NotAllowedError"===e.name)return new m({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});if("NotSupportedError"===e.name)return 0===n.pubKeyCredParams.filter((e=>"public-key"===e.type)).length?new m({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:e}):new m({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:e});if("SecurityError"===e.name){const t=globalThis.location.hostname;if(!y(t))return new m({message:`${globalThis.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e});if(n.rp.id!==t)return new m({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else if("TypeError"===e.name){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new m({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:e})}else if("UnknownError"===e.name)return new m({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e})}return e}({error:e,options:r})}if(!i)throw new Error("Registration was not completed");const{id:s,rawId:a,response:c,type:l}=i;let h,u,d,b;if("function"==typeof c.getTransports&&(h=c.getTransports()),"function"==typeof c.getPublicKeyAlgorithm)try{u=c.getPublicKeyAlgorithm()}catch(e){T("getPublicKeyAlgorithm()",e)}if("function"==typeof c.getPublicKey)try{const e=c.getPublicKey();null!==e&&(d=p(e))}catch(e){T("getPublicKey()",e)}if("function"==typeof c.getAuthenticatorData)try{b=p(c.getAuthenticatorData())}catch(e){T("getAuthenticatorData()",e)}return{id:s,rawId:p(a),response:{attestationObject:p(c.attestationObject),clientDataJSON:p(c.clientDataJSON),transports:h,publicKeyAlgorithm:u,publicKey:d,authenticatorData:b},type:l,clientExtensionResults:i.getClientExtensionResults(),authenticatorAttachment:E(i.authenticatorAttachment)}}function T(e,t){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.\n`,t)}const C={stubThis:e=>e};async function S(e){!e.optionsJSON&&e.challenge&&(console.warn("startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information."),e={optionsJSON:e});const{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:o=!0}=e;if(!f())throw new Error("WebAuthn is not supported in this browser");let r;0!==t.allowCredentials?.length&&(r=t.allowCredentials?.map(v));const i={...t,challenge:g(t.challenge),allowCredentials:r},s={};if(n){if(!await function(){if(!f())return C.stubThis(new Promise((e=>e(!1))));const e=globalThis.PublicKeyCredential;return void 0===e?.isConditionalMediationAvailable?C.stubThis(new Promise((e=>e(!1)))):C.stubThis(e.isConditionalMediationAvailable())}())throw Error("Browser does not support WebAuthn autofill");if(document.querySelectorAll("input[autocomplete$='webauthn']").length<1&&o)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');s.mediation="conditional",i.allowCredentials=[]}let a;s.publicKey=i,s.signal=k.createNewAbortSignal();try{a=await navigator.credentials.get(s)}catch(e){throw function({error:e,options:t}){const{publicKey:n}=t;if(!n)throw Error("options was missing required publicKey property");if("AbortError"===e.name){if(t.signal instanceof AbortSignal)return new m({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else{if("NotAllowedError"===e.name)return new m({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});if("SecurityError"===e.name){const t=globalThis.location.hostname;if(!y(t))return new m({message:`${globalThis.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e});if(n.rpId!==t)return new m({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else if("UnknownError"===e.name)return new m({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e})}return e}({error:e,options:s})}if(!a)throw new Error("Authentication was not completed");const{id:c,rawId:l,response:h,type:u}=a;let d;return h.userHandle&&(d=p(h.userHandle)),{id:c,rawId:p(l),response:{authenticatorData:p(h.authenticatorData),clientDataJSON:p(h.clientDataJSON),signature:p(h.signature),userHandle:d},type:u,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:E(a.authenticatorAttachment)}}function R(e){var t=e.name,n=e.value,o=e.expire,r=e.domain,i=e.secure,s=o===1/0?" expires=Fri, 31 Dec 9999 23:59:59 GMT":"; max-age="+o;document.cookie=encodeURIComponent(t)+"="+n+"; path=/;"+s+(r?"; domain="+r:"")+(i?"; secure":"")}function A(e){var t,n=e.errorResponse;return e.enableLogging&&console.error("[Authsignal] ".concat(n.errorCode).concat(n.errorDescription?": ".concat(n.errorDescription):"")),{error:null!==(t=n.errorDescription)&&void 0!==t?t:n.error,errorCode:n.errorCode,errorDescription:n.errorDescription}}function O(e){var t,n=e.response,o=e.enableLogging;if(n&&"object"==typeof n&&"error"in n){var r=null!==(t=n.errorDescription)&&void 0!==t?t:n.error;return o&&console.error("[Authsignal] ".concat(n.errorCode).concat(n.errorDescription?": ".concat(n.errorDescription):"")),{error:r,errorCode:n.errorCode,errorDescription:n.errorDescription}}if(n&&"object"==typeof n&&"accessToken"in n&&"string"==typeof n.accessToken){var i=n.accessToken,s=h(n,["accessToken"]);return{data:l(l({},s),{token:i})}}return{data:n}}function L(e){var t,n;if(e instanceof m&&"ERROR_INVALID_RP_ID"===e.code){var o=(null===(n=null===(t=e.message)||void 0===t?void 0:t.match(/"([^"]*)"/))||void 0===n?void 0:n[1])||"";console.error('[Authsignal] The Relying Party ID "'.concat(o,'" is invalid for this domain.\n To learn more, visit https://docs.authsignal.com/scenarios/passkeys-prebuilt-ui#defining-the-relying-party'))}}var x;function _(e){var t=e.token,n=e.tenantId;return{"Content-Type":"application/json",Authorization:t?"Bearer ".concat(t):"Basic ".concat(window.btoa(encodeURIComponent(n)))}}function U(e){var t=e.response,n=e.onTokenExpired;"error"in t&&"expired_token"===t.errorCode&&n&&n()}e.AuthsignalWindowMessage=void 0,(e.AuthsignalWindowMessage||(e.AuthsignalWindowMessage={})).AUTHSIGNAL_CLOSE_POPUP="AUTHSIGNAL_CLOSE_POPUP",e.ErrorCode=void 0,(x=e.ErrorCode||(e.ErrorCode={})).token_not_set="token_not_set",x.expired_token="expired_token",x.network_error="network_error",x.too_many_requests="too_many_requests",x.invalid_credential="invalid_credential";var P=function(){function e(e){var t=e.baseUrl,n=e.tenantId,o=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=o}return e.prototype.registrationOptions=function(e){return u(this,arguments,void 0,(function(e){var t,n,o,r,i=e.token,s=e.username,a=e.authenticatorAttachment,c=e.useCookies;return d(this,(function(e){switch(e.label){case 0:return t=Boolean(a)?{username:s,authenticatorAttachment:a}:{username:s},n="".concat(this.baseUrl,c?"/client/user-authenticators/passkey/registration-options/web":"/client/user-authenticators/passkey/registration-options"),o=c?"include":"same-origin",[4,fetch(n,{method:"POST",headers:_({token:i,tenantId:this.tenantId}),body:JSON.stringify(t),credentials:o})];case 1:return[4,e.sent().json()];case 2:return U({response:r=e.sent(),onTokenExpired:this.onTokenExpired}),[2,r]}}))}))},e.prototype.authenticationOptions=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token,o=e.challengeId,r=e.useCookies;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/passkey/authentication-options"),{method:"POST",headers:_({token:n,tenantId:this.tenantId}),body:JSON.stringify({challengeId:o}),credentials:r?"include":"same-origin"})];case 1:return[4,e.sent().json()];case 2:return U({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.authenticationOptionsWeb=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/passkey/authentication-options/web"),{method:"POST",headers:_({token:n,tenantId:this.tenantId}),body:JSON.stringify({}),credentials:"include"})];case 1:return[4,e.sent().json()];case 2:return U({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.addAuthenticator=function(e){return u(this,arguments,void 0,(function(e){var t,n,o=e.token,r=e.registrationCredential,i=e.conditionalCreate,s=e.challengeId,a=e.useCookies;return d(this,(function(e){switch(e.label){case 0:return t={registrationCredential:r,conditionalCreate:i,challengeId:s},[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/passkey"),{method:"POST",headers:_({token:o,tenantId:this.tenantId}),body:JSON.stringify(t),credentials:a?"include":"same-origin"})];case 1:return[4,e.sent().json()];case 2:return U({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n,o=e.authenticationCredential,r=e.token,i=e.deviceId,s=e.challengeId,a=e.useCookies;return d(this,(function(e){switch(e.label){case 0:return t={authenticationCredential:o,deviceId:i,challengeId:s},[4,fetch("".concat(this.baseUrl,"/client/verify/passkey"),{method:"POST",headers:_({token:r,tenantId:this.tenantId}),body:JSON.stringify(t),credentials:a?"include":"same-origin"})];case 1:return[4,e.sent().json()];case 2:return U({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e.prototype.getPasskeyAuthenticator=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.credentialIds;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/passkey?credentialIds=").concat(n),{method:"GET",headers:_({tenantId:this.tenantId})})];case 1:if(!(t=e.sent()).ok)throw new Error(t.statusText);return[2,t.json()]}}))}))},e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t,n,o=e.action,r=e.useCookies;return d(this,(function(e){switch(e.label){case 0:return t="".concat(this.baseUrl,r?"/client/challenge/web":"/client/challenge"),[4,fetch(t,{method:"POST",headers:_({tenantId:this.tenantId}),body:JSON.stringify({action:o}),credentials:r?"include":"same-origin"})];case 1:return[4,e.sent().json()];case 2:return U({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e}(),N=function(){function t(){this.token=null}return t.prototype.handleTokenNotSetError=function(){var t=e.ErrorCode.token_not_set,n="A token has not been set. Call 'setToken' first.";return console.error("Error: ".concat(n)),{error:t,errorCode:t,errorDescription:n}},t.shared=new t,t}(),D=!1,$=function(){function e(e){var t=e.baseUrl,n=e.tenantId,o=e.anonymousId,r=e.onTokenExpired,i=e.enableLogging;this.passkeyLocalStorageKey="as_user_passkey_map",this.cache=N.shared,this.enableLogging=!1,this.api=new P({baseUrl:t,tenantId:n,onTokenExpired:r}),this.anonymousId=o,this.enableLogging=i}return e.prototype.signUp=function(e){return u(this,arguments,void 0,(function(e){var t,n,o,r,i,s,a=e.username,c=e.displayName,h=e.token,u=e.authenticatorAttachment,p=void 0===u?"platform":u,g=e.useAutoRegister,f=void 0!==g&&g,b=e.useCookies,v=void 0!==b&&b;return d(this,(function(e){switch(e.label){case 0:return(t=null!=h?h:this.cache.token)?f?[4,this.doesBrowserSupportConditionalCreate()]:[3,2]:[2,this.cache.handleTokenNotSetError()];case 1:if(!e.sent())throw new Error("CONDITIONAL_CREATE_NOT_SUPPORTED");e.label=2;case 2:return n={username:a,displayName:c,token:t,authenticatorAttachment:p,useCookies:v},[4,this.api.registrationOptions(n)];case 3:if("error"in(o=e.sent()))return[2,A({errorResponse:o,enableLogging:this.enableLogging})];e.label=4;case 4:return e.trys.push([4,7,,8]),[4,I({optionsJSON:o.options,useAutoRegister:f})];case 5:return r=e.sent(),[4,this.api.addAuthenticator({registrationCredential:r,token:t,conditionalCreate:f,challengeId:o.challengeId,useCookies:v})];case 6:return"error"in(i=e.sent())?[2,A({errorResponse:i,enableLogging:this.enableLogging})]:(i.isVerified&&this.storeCredentialAgainstDevice(l(l({},r),{userId:i.userId})),i.accessToken&&(this.cache.token=i.accessToken),[2,{data:{token:i.accessToken,userAuthenticator:i.userAuthenticator,registrationResponse:r}}]);case 7:throw s=e.sent(),D=!1,L(s),s;case 8:return[2]}}))}))},e.prototype.signIn=function(e){return u(this,void 0,void 0,(function(){var t,n,o,r,i,s,a,c,h,u,p,g,f;return d(this,(function(d){switch(d.label){case 0:if((null==e?void 0:e.token)&&e.autofill)throw new Error("autofill is not supported when providing a token");if((null==e?void 0:e.action)&&e.token)throw new Error("action is not supported when providing a token");if(null==e?void 0:e.autofill){if(D)return[2,{}];D=!0}return(null==e?void 0:e.action)?[4,this.api.challenge({action:null==e?void 0:e.action,useCookies:null==e?void 0:e.useCookies})]:[3,2];case 1:return n=d.sent(),[3,3];case 2:n=null,d.label=3;case 3:return(t=n)&&"error"in t?(D=!1,[2,A({errorResponse:t,enableLogging:this.enableLogging})]):!(null==e?void 0:e.action)&&(null==e?void 0:e.useCookies)?[3,5]:[4,this.api.authenticationOptions({token:null==e?void 0:e.token,challengeId:null==t?void 0:t.challengeId,useCookies:null==e?void 0:e.useCookies})];case 4:return r=d.sent(),[3,7];case 5:return[4,this.api.authenticationOptionsWeb({token:null==e?void 0:e.token})];case 6:r=d.sent(),d.label=7;case 7:if("error"in(o=r))return D=!1,[2,A({errorResponse:o,enableLogging:this.enableLogging})];d.label=8;case 8:return d.trys.push([8,11,,12]),[4,S({optionsJSON:o.options,useBrowserAutofill:null==e?void 0:e.autofill})];case 9:return i=d.sent(),(null==e?void 0:e.onVerificationStarted)&&e.onVerificationStarted(),[4,this.api.verify({authenticationCredential:i,token:null==e?void 0:e.token,deviceId:this.anonymousId,challengeId:o.challengeId,useCookies:null==e?void 0:e.useCookies})];case 10:return"error"in(s=d.sent())?(D=!1,[2,A({errorResponse:s,enableLogging:this.enableLogging})]):(s.isVerified&&this.storeCredentialAgainstDevice(l(l({},i),{userId:s.userId})),s.accessToken&&(this.cache.token=s.accessToken),a=s.accessToken,c=s.userId,h=s.userAuthenticatorId,u=s.username,p=s.userDisplayName,g=s.isVerified,D=!1,[2,{data:{isVerified:g,token:a,userId:c,userAuthenticatorId:h,username:u,displayName:p,authenticationResponse:i}}]);case 11:throw f=d.sent(),D=!1,L(f),f;case 12:return[2]}}))}))},e.prototype.isAvailableOnDevice=function(e){return u(this,arguments,void 0,(function(e){var t,n,o,r,i=e.userId;return d(this,(function(e){switch(e.label){case 0:if(!i)throw new Error("userId is required");if(!(t=localStorage.getItem(this.passkeyLocalStorageKey)))return[2,!1];if(n=JSON.parse(t),0===(o=null!==(r=n[i])&&void 0!==r?r:[]).length)return[2,!1];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.api.getPasskeyAuthenticator({credentialIds:o})];case 2:return e.sent(),[2,!0];case 3:return e.sent(),[2,!1];case 4:return[2]}}))}))},e.prototype.storeCredentialAgainstDevice=function(e){var t=e.id,n=e.authenticatorAttachment,o=e.userId,r=void 0===o?"":o;if("cross-platform"!==n){var i=localStorage.getItem(this.passkeyLocalStorageKey),s=i?JSON.parse(i):{};s[r]?s[r].includes(t)||s[r].push(t):s[r]=[t],localStorage.setItem(this.passkeyLocalStorageKey,JSON.stringify(s))}},e.prototype.doesBrowserSupportConditionalCreate=function(){return u(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return window.PublicKeyCredential&&PublicKeyCredential.getClientCapabilities?[4,PublicKeyCredential.getClientCapabilities()]:[3,2];case 1:if(e.sent().conditionalCreate)return[2,!0];e.label=2;case 2:return[2,!1]}}))}))},e}(),j=function(){function e(){this.windowRef=null}return e.prototype.show=function(e){var t=e.url,n=e.width,o=void 0===n?400:n,r=e.height,i=function(e){var t=e.url,n=e.width,o=e.height,r=e.win;if(!r.top)return null;var i=r.top.outerHeight/2+r.top.screenY-o/2,s=r.top.outerWidth/2+r.top.screenX-n/2;return window.open(t,"","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=".concat(n,", height=").concat(o,", top=").concat(i,", left=").concat(s))}({url:t,width:o,height:void 0===r?500:r,win:window});if(!i)throw new Error("Window is not initialized");return this.windowRef=i,i},e.prototype.close=function(){if(!this.windowRef)throw new Error("Window is not initialized");this.windowRef.close()},e}();const J=":not([inert]):not([inert] *)",K=':not([tabindex^="-"])',W=":not(:disabled)";var H=[`a[href]${J}${K}`,`area[href]${J}${K}`,`input:not([type="hidden"]):not([type="radio"])${J}${K}${W}`,`input[type="radio"]${J}${K}${W}`,`select${J}${K}${W}`,`textarea${J}${K}${W}`,`button${J}${K}${W}`,`details${J} > summary:first-of-type${K}`,`iframe${J}${K}`,`audio[controls]${J}${K}`,`video[controls]${J}${K}`,`[contenteditable]${J}${K}`,`[tabindex]${J}${K}`];function M(e){(e.querySelector("[autofocus]")||e).focus()}function V(e,t){if(t&&F(e))return e;if(!((n=e).shadowRoot&&"-1"===n.getAttribute("tabindex")||n.matches(":disabled,[hidden],[inert]")))if(e.shadowRoot){let n=q(e.shadowRoot,t);for(;n;){const e=V(n,t);if(e)return e;n=G(n,t)}}else if("slot"===e.localName){const n=e.assignedElements({flatten:!0});t||n.reverse();for(const e of n){const n=V(e,t);if(n)return n}}else{let n=q(e,t);for(;n;){const e=V(n,t);if(e)return e;n=G(n,t)}}var n;return!t&&F(e)?e:null}function q(e,t){return t?e.firstElementChild:e.lastElementChild}function G(e,t){return t?e.nextElementSibling:e.previousElementSibling}const F=e=>!e.shadowRoot?.delegatesFocus&&(e.matches(H.join(","))&&!(e=>!(!e.matches("details:not([open]) *")||e.matches("details>summary:first-of-type"))||!(e.offsetWidth||e.offsetHeight||e.getClientRects().length))(e));function B(e=document){const t=e.activeElement;return t?t.shadowRoot?B(t.shadowRoot)||document.activeElement:t:null}function z(e,t){const[n,o]=function(e){const t=V(e,!0);return[t,t?V(e,!1)||t:null]}(e);if(!n)return t.preventDefault();const r=B();t.shiftKey&&r===n?(o.focus(),t.preventDefault()):t.shiftKey||r!==o||(n.focus(),t.preventDefault())}class Y{$el;id;previouslyFocused;shown;constructor(e){this.$el=e,this.id=this.$el.getAttribute("data-a11y-dialog")||this.$el.id,this.previouslyFocused=null,this.shown=!1,this.maintainFocus=this.maintainFocus.bind(this),this.bindKeypress=this.bindKeypress.bind(this),this.handleTriggerClicks=this.handleTriggerClicks.bind(this),this.show=this.show.bind(this),this.hide=this.hide.bind(this),this.$el.setAttribute("aria-hidden","true"),this.$el.setAttribute("aria-modal","true"),this.$el.setAttribute("tabindex","-1"),this.$el.hasAttribute("role")||this.$el.setAttribute("role","dialog"),document.addEventListener("click",this.handleTriggerClicks,!0)}destroy(){return this.hide(),document.removeEventListener("click",this.handleTriggerClicks,!0),this.$el.replaceWith(this.$el.cloneNode(!0)),this.fire("destroy"),this}show(e){return this.shown||(this.shown=!0,this.$el.removeAttribute("aria-hidden"),this.previouslyFocused=B(),"BODY"===this.previouslyFocused?.tagName&&e?.target&&(this.previouslyFocused=e.target),"focus"===e?.type?this.maintainFocus(e):M(this.$el),document.body.addEventListener("focus",this.maintainFocus,!0),this.$el.addEventListener("keydown",this.bindKeypress,!0),this.fire("show",e)),this}hide(e){return this.shown?(this.shown=!1,this.$el.setAttribute("aria-hidden","true"),this.previouslyFocused?.focus?.(),document.body.removeEventListener("focus",this.maintainFocus,!0),this.$el.removeEventListener("keydown",this.bindKeypress,!0),this.fire("hide",e),this):this}on(e,t,n){return this.$el.addEventListener(e,t,n),this}off(e,t,n){return this.$el.removeEventListener(e,t,n),this}fire(e,t){this.$el.dispatchEvent(new CustomEvent(e,{detail:t,cancelable:!0}))}handleTriggerClicks(e){const t=e.target;t.closest(`[data-a11y-dialog-show="${this.id}"]`)&&this.show(e),(t.closest(`[data-a11y-dialog-hide="${this.id}"]`)||t.closest("[data-a11y-dialog-hide]")&&t.closest('[aria-modal="true"]')===this.$el)&&this.hide(e)}bindKeypress(e){if(document.activeElement?.closest('[aria-modal="true"]')!==this.$el)return;let t=!1;try{t=!!this.$el.querySelector('[popover]:not([popover="manual"]):popover-open')}catch{}"Escape"!==e.key||"alertdialog"===this.$el.getAttribute("role")||t||(e.preventDefault(),this.hide(e)),"Tab"===e.key&&z(this.$el,e)}maintainFocus(e){e.target.closest('[aria-modal="true"], [data-a11y-dialog-ignore-focus-trap]')||M(this.$el)}}function Q(){for(const e of document.querySelectorAll("[data-a11y-dialog]"))new Y(e)}"undefined"!=typeof document&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",Q):Q());var X="__authsignal-popup-container",Z="__authsignal-popup-content",ee="__authsignal-popup-overlay",te="__authsignal-popup-style",ne="__authsignal-popup-iframe",oe="385px",re=function(){function e(e){var t=e.width,n=e.height,o=e.isClosable;if(this.popup=null,document.querySelector("#".concat(X)))throw new Error("Multiple instances of Authsignal popup is not supported.");this.height=n,this.create({width:t,height:n,isClosable:o})}return e.prototype.create=function(e){var t=this,n=e.width,o=void 0===n?oe:n,r=e.height,i=e.isClosable,s=void 0===i||i,a=o;CSS.supports("width",o)||(console.warn("Invalid CSS value for `popupOptions.width`. Using default value instead."),a=oe);var c=document.createElement("div");c.setAttribute("id",X),c.setAttribute("aria-hidden","true"),s||c.setAttribute("role","alertdialog");var l=document.createElement("div");l.setAttribute("id",ee),s&&l.setAttribute("data-a11y-dialog-hide","true");var h=document.createElement("div");h.setAttribute("id",Z),document.body.appendChild(c);var u=document.createElement("style");u.setAttribute("id",te),u.textContent="\n #".concat(X,",\n #").concat(ee," {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n }\n\n #").concat(X," {\n z-index: 2147483647;\n display: flex;\n }\n\n #").concat(X,"[aria-hidden='true'] {\n display: none;\n }\n\n #").concat(ee," {\n background-color: rgba(0, 0, 0, 0.18);\n }\n\n #").concat(Z," {\n margin: auto;\n z-index: 2147483647;\n position: relative;\n background-color: transparent;\n border-radius: 8px;\n width: ").concat(a,";\n }\n\n #").concat(Z," iframe {\n width: 1px;\n min-width: 100%;\n border-radius: inherit;\n max-height: ").concat(r?"100%":"95vh",";\n height: ").concat(null!=r?r:"384px",";\n }\n "),document.head.insertAdjacentElement("beforeend",u),c.appendChild(l),c.appendChild(h),this.popup=new Y(c),c.focus(),this.popup.on("hide",(function(){t.destroy()}))},e.prototype.destroy=function(){var e=document.querySelector("#".concat(X)),t=document.querySelector("#".concat(te));e&&t&&(document.body.removeChild(e),document.head.removeChild(t)),window.removeEventListener("message",ie)},e.prototype.show=function(e){var t,n=e.url;if(!this.popup)throw new Error("Popup is not initialized");var o=document.createElement("iframe");o.setAttribute("id",ne),o.setAttribute("name","authsignal"),o.setAttribute("title","Authsignal multi-factor authentication"),o.setAttribute("src",n),o.setAttribute("frameborder","0"),o.setAttribute("allow","publickey-credentials-get *; publickey-credentials-create *; clipboard-write");var r=document.querySelector("#".concat(Z));r&&r.appendChild(o),this.height||window.addEventListener("message",ie),null===(t=this.popup)||void 0===t||t.show()},e.prototype.close=function(){if(!this.popup)throw new Error("Popup is not initialized");this.popup.hide()},e.prototype.on=function(e,t){if(!this.popup)throw new Error("Popup is not initialized");this.popup.on(e,t)},e}();function ie(e){var t=document.querySelector("#".concat(ne));t&&e.data.height&&(t.style.height=e.data.height+"px")}var se=function(){function e(e){var t=e.baseUrl,n=e.tenantId,o=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=o}return e.prototype.enroll=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/totp"),{method:"POST",headers:_({token:n,tenantId:this.tenantId})})];case 1:return[4,e.sent().json()];case 2:return U({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n,o=e.token,r=e.code;return d(this,(function(e){switch(e.label){case 0:return t={verificationCode:r},[4,fetch("".concat(this.baseUrl,"/client/verify/totp"),{method:"POST",headers:_({token:o,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return U({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e}(),ae=function(){function e(e){var t=e.baseUrl,n=e.tenantId,o=e.onTokenExpired,r=e.enableLogging;this.cache=N.shared,this.enableLogging=!1,this.enableLogging=r,this.api=new se({baseUrl:t,tenantId:n,onTokenExpired:o})}return e.prototype.enroll=function(){return u(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.enroll({token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O({response:e.sent(),enableLogging:this.enableLogging})]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.code;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.verify({token:this.cache.token,code:n})]:[2,this.cache.handleTokenNotSetError()];case 1:return"accessToken"in(t=e.sent())&&t.accessToken&&(this.cache.token=t.accessToken),[2,O({response:t,enableLogging:this.enableLogging})]}}))}))},e}(),ce=function(){function e(e){var t=e.baseUrl,n=e.tenantId,o=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=o}return e.prototype.enroll=function(e){return u(this,arguments,void 0,(function(e){var t,n,o=e.token,r=e.email;return d(this,(function(e){switch(e.label){case 0:return t={email:r},[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/email-otp"),{method:"POST",headers:_({token:o,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return U({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/challenge/email-otp"),{method:"POST",headers:_({token:n,tenantId:this.tenantId})})];case 1:return[4,e.sent().json()];case 2:return U({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n,o=e.token,r=e.code;return d(this,(function(e){switch(e.label){case 0:return t={verificationCode:r},[4,fetch("".concat(this.baseUrl,"/client/verify/email-otp"),{method:"POST",headers:_({token:o,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return U({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e}(),le=function(){function e(e){var t=e.baseUrl,n=e.tenantId,o=e.onTokenExpired,r=e.enableLogging;this.cache=N.shared,this.enableLogging=!1,this.enableLogging=r,this.api=new ce({baseUrl:t,tenantId:n,onTokenExpired:o})}return e.prototype.enroll=function(e){return u(this,arguments,void 0,(function(e){var t=e.email;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.enroll({token:this.cache.token,email:t})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O({response:e.sent(),enableLogging:this.enableLogging})]}}))}))},e.prototype.challenge=function(){return u(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.challenge({token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O({response:e.sent(),enableLogging:this.enableLogging})]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.code;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.verify({token:this.cache.token,code:n})]:[2,this.cache.handleTokenNotSetError()];case 1:return"accessToken"in(t=e.sent())&&t.accessToken&&(this.cache.token=t.accessToken),[2,O({response:t,enableLogging:this.enableLogging})]}}))}))},e}(),he=function(){function e(e){var t=e.baseUrl,n=e.tenantId,o=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=o}return e.prototype.enroll=function(e){return u(this,arguments,void 0,(function(e){var t,n,o=e.token,r=e.phoneNumber;return d(this,(function(e){switch(e.label){case 0:return t={phoneNumber:r},[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/sms"),{method:"POST",headers:_({token:o,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return U({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/challenge/sms"),{method:"POST",headers:_({token:n,tenantId:this.tenantId})})];case 1:return[4,e.sent().json()];case 2:return U({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n,o=e.token,r=e.code;return d(this,(function(e){switch(e.label){case 0:return t={verificationCode:r},[4,fetch("".concat(this.baseUrl,"/client/verify/sms"),{method:"POST",headers:_({token:o,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return U({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e}(),ue=function(){function e(e){var t=e.baseUrl,n=e.tenantId,o=e.onTokenExpired,r=e.enableLogging;this.cache=N.shared,this.enableLogging=!1,this.enableLogging=r,this.api=new he({baseUrl:t,tenantId:n,onTokenExpired:o})}return e.prototype.enroll=function(e){return u(this,arguments,void 0,(function(e){var t=e.phoneNumber;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.enroll({token:this.cache.token,phoneNumber:t})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O({response:e.sent(),enableLogging:this.enableLogging})]}}))}))},e.prototype.challenge=function(){return u(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.challenge({token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O({response:e.sent(),enableLogging:this.enableLogging})]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.code;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.verify({token:this.cache.token,code:n})]:[2,this.cache.handleTokenNotSetError()];case 1:return"accessToken"in(t=e.sent())&&t.accessToken&&(this.cache.token=t.accessToken),[2,O({response:t,enableLogging:this.enableLogging})]}}))}))},e}(),de=function(){function e(e){var t=e.baseUrl,n=e.tenantId,o=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=o}return e.prototype.enroll=function(e){return u(this,arguments,void 0,(function(e){var t,n,o=e.token,r=e.email;return d(this,(function(e){switch(e.label){case 0:return t={email:r},[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/email-magic-link"),{method:"POST",headers:_({token:o,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return U({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/challenge/email-magic-link"),{method:"POST",headers:_({token:n,tenantId:this.tenantId})})];case 1:return[4,e.sent().json()];case 2:return U({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.checkVerificationStatus=function(e){return u(this,arguments,void 0,(function(e){var t,n=this,o=e.token;return d(this,(function(e){switch(e.label){case 0:return t=function(){return u(n,void 0,void 0,(function(){var e,n=this;return d(this,(function(r){switch(r.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/verify/email-magic-link/finalize"),{method:"POST",headers:_({token:o,tenantId:this.tenantId}),body:JSON.stringify({})})];case 1:return[4,r.sent().json()];case 2:return U({response:e=r.sent(),onTokenExpired:this.onTokenExpired}),e.isVerified?[2,e]:[2,new Promise((function(e){setTimeout((function(){return u(n,void 0,void 0,(function(){var n;return d(this,(function(o){switch(o.label){case 0:return n=e,[4,t()];case 1:return n.apply(void 0,[o.sent()]),[2]}}))}))}),1e3)}))]}}))}))},[4,t()];case 1:return[2,e.sent()]}}))}))},e}(),pe=function(){function e(e){var t=e.baseUrl,n=e.tenantId,o=e.onTokenExpired,r=e.enableLogging;this.cache=N.shared,this.enableLogging=!1,this.enableLogging=r,this.api=new de({baseUrl:t,tenantId:n,onTokenExpired:o})}return e.prototype.enroll=function(e){return u(this,arguments,void 0,(function(e){var t=e.email;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.enroll({token:this.cache.token,email:t})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O({response:e.sent(),enableLogging:this.enableLogging})]}}))}))},e.prototype.challenge=function(){return u(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.challenge({token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O({response:e.sent(),enableLogging:this.enableLogging})]}}))}))},e.prototype.checkVerificationStatus=function(){return u(this,void 0,void 0,(function(){var e;return d(this,(function(t){switch(t.label){case 0:return this.cache.token?[4,this.api.checkVerificationStatus({token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return"accessToken"in(e=t.sent())&&e.accessToken&&(this.cache.token=e.accessToken),[2,O({response:e,enableLogging:this.enableLogging})]}}))}))},e}(),ge=function(){function e(e){var t=e.baseUrl,n=e.tenantId,o=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=o}return e.prototype.registrationOptions=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/security-key/registration-options"),{method:"POST",headers:_({token:n,tenantId:this.tenantId}),body:JSON.stringify({})})];case 1:return[4,e.sent().json()];case 2:return U({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.authenticationOptions=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/security-key/authentication-options"),{method:"POST",headers:_({token:n,tenantId:this.tenantId}),body:JSON.stringify({})})];case 1:return[4,e.sent().json()];case 2:return U({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.addAuthenticator=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token,o=e.registrationCredential;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/security-key"),{method:"POST",headers:_({token:n,tenantId:this.tenantId}),body:JSON.stringify(o)})];case 1:return[4,e.sent().json()];case 2:return U({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token,o=e.authenticationCredential;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/verify/security-key"),{method:"POST",headers:_({token:n,tenantId:this.tenantId}),body:JSON.stringify(o)})];case 1:return[4,e.sent().json()];case 2:return U({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e}(),fe=function(){function e(e){var t=e.baseUrl,n=e.tenantId,o=e.onTokenExpired,r=e.enableLogging;this.cache=N.shared,this.enableLogging=!1,this.api=new ge({baseUrl:t,tenantId:n,onTokenExpired:o}),this.enableLogging=r}return e.prototype.enroll=function(){return u(this,void 0,void 0,(function(){var e,t,n,o,r;return d(this,(function(i){switch(i.label){case 0:return this.cache.token?(e={token:this.cache.token},[4,this.api.registrationOptions(e)]):[2,this.cache.handleTokenNotSetError()];case 1:if("error"in(t=i.sent()))return[2,A({errorResponse:t,enableLogging:this.enableLogging})];i.label=2;case 2:return i.trys.push([2,5,,6]),[4,I({optionsJSON:t})];case 3:return n=i.sent(),[4,this.api.addAuthenticator({registrationCredential:n,token:this.cache.token})];case 4:return"error"in(o=i.sent())?[2,A({errorResponse:o,enableLogging:this.enableLogging})]:(o.accessToken&&(this.cache.token=o.accessToken),[2,{data:{token:o.accessToken,registrationResponse:n}}]);case 5:throw L(r=i.sent()),r;case 6:return[2]}}))}))},e.prototype.verify=function(){return u(this,void 0,void 0,(function(){var e,t,n,o,r;return d(this,(function(i){switch(i.label){case 0:return this.cache.token?[4,this.api.authenticationOptions({token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:if("error"in(e=i.sent()))return[2,A({errorResponse:e,enableLogging:this.enableLogging})];i.label=2;case 2:return i.trys.push([2,5,,6]),[4,S({optionsJSON:e})];case 3:return t=i.sent(),[4,this.api.verify({authenticationCredential:t,token:this.cache.token})];case 4:return"error"in(n=i.sent())?[2,A({errorResponse:n,enableLogging:this.enableLogging})]:(n.accessToken&&(this.cache.token=n.accessToken),o=n.accessToken,[2,{data:{isVerified:n.isVerified,token:o,authenticationResponse:t}}]);case 5:throw L(r=i.sent()),r;case 6:return[2]}}))}))},e}(),be=function(){function e(e){var t=e.baseUrl,n=e.tenantId;this.tenantId=n,this.baseUrl=t}return e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.action,o=e.token,r=e.custom;return d(this,(function(e){switch(e.label){case 0:return t={action:n,custom:r},[4,fetch("".concat(this.baseUrl,"/client/challenge/qr-code"),{method:"POST",headers:_({tenantId:this.tenantId,token:o}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return[2,e.sent()]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.challengeId,o=e.deviceCode;return d(this,(function(e){switch(e.label){case 0:return t={challengeId:n,deviceCode:o},[4,fetch("".concat(this.baseUrl,"/client/verify/qr-code"),{method:"POST",headers:_({tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return[2,e.sent()]}}))}))},e}(),ve=function(){},ye=54e4,me=3e3,ke=function(e){function t(t){var n=t.baseUrl,o=t.tenantId,r=t.enableLogging,i=e.call(this)||this;return i.cache=N.shared,i.enableLogging=!1,i.enableLogging=r,i.api=new be({baseUrl:n,tenantId:o}),i}return c(t,e),t.prototype.challenge=function(e){return u(this,void 0,void 0,(function(){var t,n,o,r,i,s=this;return d(this,(function(a){switch(a.label){case 0:return[4,this.api.challenge({token:this.cache.token||void 0,action:e.action,custom:e.custom})];case 1:return t=a.sent(),(n=O({response:t,enableLogging:this.enableLogging})).data&&(this.currentChallengeParams=e,this.clearPolling(),o=e.pollInterval||me,r=e.refreshInterval||ye,n.data.deviceCode&&this.startPolling({challengeId:n.data.challengeId,deviceCode:n.data.deviceCode,onStateChange:e.onStateChange,pollInterval:o}),e.onRefresh&&(i=e.onRefresh,this.startRefreshTimer((function(){return s.performRefresh({action:e.action,custom:e.custom,onRefresh:i,onStateChange:e.onStateChange,pollInterval:o})}),r))),[2,n]}}))}))},t.prototype.refresh=function(){return u(this,arguments,void 0,(function(e){var t,n,o,r,i,s,a,c,l,h=this,u=(void 0===e?{}:e).custom;return d(this,(function(e){switch(e.label){case 0:return this.currentChallengeParams?[4,this.api.challenge({token:this.cache.token||void 0,action:this.currentChallengeParams.action,custom:u||this.currentChallengeParams.custom})]:[2];case 1:return t=e.sent(),(n=O({response:t,enableLogging:this.enableLogging})).data&&(this.clearPolling(),this.currentChallengeParams.onRefresh&&this.currentChallengeParams.onRefresh(n.data.challengeId,n.data.expiresAt),n.data.deviceCode&&this.startPolling({challengeId:n.data.challengeId,deviceCode:n.data.deviceCode,onStateChange:this.currentChallengeParams.onStateChange,pollInterval:this.currentChallengeParams.pollInterval||me}),this.currentChallengeParams.onRefresh&&(o=this.currentChallengeParams.refreshInterval||ye,r=this.currentChallengeParams,i=r.action,s=r.custom,a=r.onRefresh,c=r.onStateChange,l=r.pollInterval,this.startRefreshTimer((function(){return h.performRefresh({action:i,custom:s,onRefresh:a,onStateChange:c,pollInterval:l||me})}),o))),[2]}}))}))},t.prototype.disconnect=function(){this.clearPolling(),this.clearRefreshTimer(),this.currentChallengeParams=void 0},t.prototype.startRefreshTimer=function(e,t){var n=this;this.clearRefreshTimer(),this.refreshTimeout=setTimeout((function(){return u(n,void 0,void 0,(function(){return d(this,(function(n){switch(n.label){case 0:return[4,e()];case 1:return n.sent(),this.startRefreshTimer(e,t),[2]}}))}))}),t)},t.prototype.clearRefreshTimer=function(){this.refreshTimeout&&(clearTimeout(this.refreshTimeout),this.refreshTimeout=void 0)},t.prototype.performRefresh=function(e){return u(this,arguments,void 0,(function(e){var t,n,o=e.action,r=e.custom,i=e.onRefresh,s=e.onStateChange,a=e.pollInterval;return d(this,(function(e){switch(e.label){case 0:return[4,this.api.challenge({token:this.cache.token||void 0,action:o,custom:r})];case 1:return t=e.sent(),(n=O({response:t,enableLogging:this.enableLogging})).data&&(this.clearPolling(),i(n.data.challengeId,n.data.expiresAt),n.data.deviceCode&&this.startPolling({challengeId:n.data.challengeId,deviceCode:n.data.deviceCode,onStateChange:s,pollInterval:a})),[2]}}))}))},t.prototype.startPolling=function(e){var t=this,n=e.challengeId,o=e.deviceCode,r=e.onStateChange,i=e.pollInterval;this.pollingInterval=setInterval((function(){return u(t,void 0,void 0,(function(){var e,t;return d(this,(function(i){switch(i.label){case 0:return[4,this.api.verify({challengeId:n,deviceCode:o})];case 1:return e=i.sent(),(t=O({response:e,enableLogging:this.enableLogging})).data&&(t.data.isVerified?(r("approved",t.data.token),this.clearPolling()):t.data.isClaimed&&!t.data.isConsumed?r("claimed"):t.data.isClaimed&&t.data.isConsumed&&(r("rejected"),this.clearPolling())),[2]}}))}))}),i)},t.prototype.clearPolling=function(){this.pollingInterval&&(clearInterval(this.pollingInterval),this.pollingInterval=void 0)},t}(ve),we="CHALLENGE_CREATED_HANDLER",Ee=function(){function e(e){var t=e.baseUrl,n=e.tenantId;this.ws=null,this.messageHandlers=new Map,this.options=null,this.refreshInterval=null,this.tokenCache=N.shared;var o=t.replace("https://","wss://").replace("http://","ws://").replace("v1","ws-v1-challenge").replace("api","api-ws");this.baseUrl=o,this.tenantId=n}return e.prototype.connect=function(){return u(this,void 0,void 0,(function(){var e=this;return d(this,(function(t){return[2,new Promise((function(t,n){try{var o=["authsignal-ws"];e.tokenCache.token?o.push("x.authsignal.token.".concat(e.tokenCache.token)):o.push("x.authsignal.tenant.".concat(e.tenantId)),e.ws=new WebSocket(e.baseUrl,o),e.ws.onopen=function(){t()},e.ws.onerror=function(e){n(new Error("WebSocket connection error: ".concat(e)))},e.ws.onclose=function(){e.refreshInterval&&(clearInterval(e.refreshInterval),e.refreshInterval=null),e.messageHandlers.clear(),e.ws=null},e.ws.onmessage=function(t){try{var n=JSON.parse(t.data);e.handleMessage(n)}catch(e){console.error("Failed to parse WebSocket message:",e)}}}catch(e){n(e)}}))]}))}))},e.prototype.handleMessage=function(e){if("CHALLENGE_CREATED"===e.type){if(!(t=this.messageHandlers.get(we)))throw new Error("Challenge created handler not found");t(e)}else if("STATE_CHANGE"===e.type){var t;(t=this.messageHandlers.get(e.data.challengeId))&&t(e)}},e.prototype.createQrCodeChallenge=function(e){return u(this,void 0,void 0,(function(){var t=this;return d(this,(function(n){switch(n.label){case 0:return this.ws&&this.ws.readyState===WebSocket.OPEN?[3,2]:[4,this.connect()];case 1:n.sent(),n.label=2;case 2:return this.refreshInterval&&clearInterval(this.refreshInterval),this.options=e,[2,new Promise((function(n,o){t.messageHandlers.set(we,(function(o){if("CHALLENGE_CREATED"===o.type){var r=o;t.messageHandlers.delete(we),t.monitorChallengeState(r.data.challengeId,e),t.startRefreshCycle(r.data.challengeId,e),n({challengeId:r.data.challengeId,expiresAt:r.data.expiresAt,state:r.data.state})}})),t.sendChallengeRequest(e).catch(o)}))]}}))}))},e.prototype.monitorChallengeState=function(e,t){var n=this;this.messageHandlers.set(e,(function(o){var r;if("STATE_CHANGE"===o.type){var i=o;null===(r=t.onStateChange)||void 0===r||r.call(t,i.data.state,i.data.accessToken),"approved"!==i.data.state&&"rejected"!==i.data.state||n.messageHandlers.delete(e)}}))},e.prototype.startRefreshCycle=function(e,t){var n=this,o=t.refreshInterval||54e4,r=e;this.refreshInterval=setInterval((function(){return u(n,void 0,void 0,(function(){var e,n,o;return d(this,(function(i){switch(i.label){case 0:this.messageHandlers.delete(r),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.createQrCodeChallenge(t)];case 2:return e=i.sent(),r=e.challengeId,null===(o=t.onRefresh)||void 0===o||o.call(t,e.challengeId,e.expiresAt),[3,4];case 3:return n=i.sent(),console.error("Failed to refresh QR code challenge:",n),this.refreshInterval&&(clearInterval(this.refreshInterval),this.refreshInterval=null),[3,4];case 4:return[2]}}))}))}),o)},e.prototype.sendChallengeRequest=function(e){return u(this,void 0,void 0,(function(){return d(this,(function(t){switch(t.label){case 0:return this.ws&&this.ws.readyState===WebSocket.OPEN?[3,2]:[4,this.connect()];case 1:t.sent(),t.label=2;case 2:if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket connection could not be established");return this.sendMessage({type:"CREATE_CHALLENGE",data:{challengeType:"QR_CODE",actionCode:e.action,custom:e.custom}}),[2]}}))}))},e.prototype.sendMessage=function(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");this.ws.send(JSON.stringify(e))},e.prototype.refreshQrCodeChallenge=function(e){return u(this,arguments,void 0,(function(e){var t,n,o,r=e.custom;return d(this,(function(e){switch(e.label){case 0:if(!this.options)throw new Error("Call createQrCodeChallenge first");return[4,this.createQrCodeChallenge(l(l({},this.options),void 0!==r&&{custom:r}))];case 1:return t=e.sent(),null===(o=(n=this.options).onRefresh)||void 0===o||o.call(n,t.challengeId,t.expiresAt),[2,t]}}))}))},e.prototype.disconnect=function(){this.ws&&this.ws.close()},e}(),Ie=function(e){function t(t){var n=t.baseUrl,o=t.tenantId,r=t.enableLogging,i=e.call(this)||this;return i.cache=N.shared,i.enableLogging=!1,i.enableLogging=r,i.wsClient=new Ee({baseUrl:n,tenantId:o}),i}return c(t,e),t.prototype.challenge=function(e){return u(this,void 0,void 0,(function(){var t;return d(this,(function(n){switch(n.label){case 0:return[4,this.wsClient.createQrCodeChallenge({token:this.cache.token||void 0,action:e.action,custom:e.custom,refreshInterval:e.refreshInterval,onRefresh:e.onRefresh,onStateChange:e.onStateChange})];case 1:return[2,{data:{challengeId:(t=n.sent()).challengeId,expiresAt:t.expiresAt}}]}}))}))},t.prototype.refresh=function(){return u(this,arguments,void 0,(function(e){var t=(void 0===e?{}:e).custom;return d(this,(function(e){switch(e.label){case 0:return[4,this.wsClient.refreshQrCodeChallenge({custom:t})];case 1:return e.sent(),[2]}}))}))},t.prototype.disconnect=function(){this.wsClient.disconnect()},t}(ve),Te=function(){function e(e){var t=e.baseUrl,n=e.tenantId,o=e.enableLogging;this.handler=null,this.enableLogging=!1,this.baseUrl=t,this.tenantId=n,this.enableLogging=o}return e.prototype.challenge=function(e){return u(this,void 0,void 0,(function(){var t,n,o;return d(this,(function(r){return t=e.polling,n=void 0!==t&&t,o=h(e,["polling"]),this.handler&&this.handler.disconnect(),this.handler=n?new ke({baseUrl:this.baseUrl,tenantId:this.tenantId,enableLogging:this.enableLogging}):new Ie({baseUrl:this.baseUrl,tenantId:this.tenantId,enableLogging:this.enableLogging}),[2,this.handler.challenge(o)]}))}))},e.prototype.refresh=function(){return u(this,arguments,void 0,(function(e){var t=(void 0===e?{}:e).custom;return d(this,(function(e){if(!this.handler)throw new Error("challenge() must be called before refresh()");return[2,this.handler.refresh({custom:t})]}))}))},e.prototype.disconnect=function(){this.handler&&(this.handler.disconnect(),this.handler=null)},e}(),Ce=function(){function e(e){var t=e.baseUrl,n=e.tenantId,o=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=o}return e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t,n,o=e.action,r=e.token;return d(this,(function(e){switch(e.label){case 0:return t={action:o},[4,fetch("".concat(this.baseUrl,"/client/challenge/push"),{method:"POST",headers:_({token:r,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return U({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n,o=e.challengeId,r=e.token;return d(this,(function(e){switch(e.label){case 0:return t={challengeId:o},[4,fetch("".concat(this.baseUrl,"/client/verify/push"),{method:"POST",headers:_({token:r,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return U({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e}(),Se=function(){function e(e){var t=e.baseUrl,n=e.tenantId,o=e.onTokenExpired,r=e.enableLogging;this.cache=N.shared,this.enableLogging=!1,this.enableLogging=r,this.api=new Ce({baseUrl:t,tenantId:n,onTokenExpired:o})}return e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t=e.action;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.challenge({action:t,token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O({response:e.sent(),enableLogging:this.enableLogging})]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t=e.challengeId;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.verify({challengeId:t,token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O({response:e.sent(),enableLogging:this.enableLogging})]}}))}))},e}(),Re=function(){function e(e){var t=e.baseUrl,n=e.tenantId,o=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=o}return e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/challenge/whatsapp"),{method:"POST",headers:_({token:n,tenantId:this.tenantId})})];case 1:return[4,e.sent().json()];case 2:return U({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n,o=e.token,r=e.code;return d(this,(function(e){switch(e.label){case 0:return t={verificationCode:r},[4,fetch("".concat(this.baseUrl,"/client/verify/whatsapp"),{method:"POST",headers:_({token:o,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return U({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e}(),Ae=function(){function e(e){var t=e.baseUrl,n=e.tenantId,o=e.onTokenExpired,r=e.enableLogging;this.cache=N.shared,this.enableLogging=!1,this.enableLogging=r,this.api=new Re({baseUrl:t,tenantId:n,onTokenExpired:o})}return e.prototype.challenge=function(){return u(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.challenge({token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O({response:e.sent(),enableLogging:this.enableLogging})]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.code;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.verify({token:this.cache.token,code:n})]:[2,this.cache.handleTokenNotSetError()];case 1:return"accessToken"in(t=e.sent())&&t.accessToken&&(this.cache.token=t.accessToken),[2,O({response:t,enableLogging:this.enableLogging})]}}))}))},e}(),Oe="4a08uqve",Le=function(){function t(e){var t=e.cookieDomain,n=e.cookieName,o=void 0===n?"__as_aid":n,r=e.baseUrl,i=void 0===r?"https://api.authsignal.com/v1":r,a=e.tenantId,c=e.onTokenExpired,l=e.enableLogging,h=void 0!==l&&l;if(this.anonymousId="",this.profilingId="",this.cookieDomain="",this.anonymousIdCookieName="",this.enableLogging=!1,this.cookieDomain=t||document.location.hostname.replace("www.",""),this.anonymousIdCookieName=o,!a)throw new Error("tenantId is required");var u,d=(u=this.anonymousIdCookieName)&&decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*"+encodeURIComponent(u).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*([^;]*).*$)|^.*$"),"$1"))||null;d?this.anonymousId=d:(this.anonymousId=s(),R({name:this.anonymousIdCookieName,value:this.anonymousId,expire:1/0,domain:this.cookieDomain,secure:"http:"!==document.location.protocol})),this.enableLogging=h,this.passkey=new $({tenantId:a,baseUrl:i,anonymousId:this.anonymousId,onTokenExpired:c,enableLogging:this.enableLogging}),this.totp=new ae({tenantId:a,baseUrl:i,onTokenExpired:c,enableLogging:this.enableLogging}),this.email=new le({tenantId:a,baseUrl:i,onTokenExpired:c,enableLogging:this.enableLogging}),this.emailML=new pe({tenantId:a,baseUrl:i,onTokenExpired:c,enableLogging:this.enableLogging}),this.sms=new ue({tenantId:a,baseUrl:i,onTokenExpired:c,enableLogging:this.enableLogging}),this.securityKey=new fe({tenantId:a,baseUrl:i,onTokenExpired:c,enableLogging:this.enableLogging}),this.qrCode=new Te({tenantId:a,baseUrl:i,enableLogging:this.enableLogging}),this.push=new Se({tenantId:a,baseUrl:i,onTokenExpired:c,enableLogging:this.enableLogging}),this.whatsapp=new Ae({tenantId:a,baseUrl:i,onTokenExpired:c,enableLogging:this.enableLogging})}return t.prototype.setToken=function(e){N.shared.token=e},t.prototype.launch=function(e,t){switch(null==t?void 0:t.mode){case"window":return this.launchWithWindow(e,t);case"popup":return this.launchWithPopup(e,t);default:this.launchWithRedirect(e)}},t.prototype.initAdvancedProfiling=function(e){var t=s();this.profilingId=t,R({name:"__as_pid",value:t,expire:1/0,domain:this.cookieDomain,secure:"http:"!==document.location.protocol});var n=e?"".concat(e,"/fp/tags.js?org_id=").concat(Oe,"&session_id=").concat(t):"https://h.online-metrix.net/fp/tags.js?org_id=".concat(Oe,"&session_id=").concat(t),o=document.createElement("script");o.src=n,o.async=!1,o.id="as_adv_profile",document.head.appendChild(o);var r=document.createElement("noscript");r.setAttribute("id","as_adv_profile_pixel"),r.setAttribute("aria-hidden","true");var i=document.createElement("iframe"),a=e?"".concat(e,"/fp/tags?org_id=").concat(Oe,"&session_id=").concat(t):"https://h.online-metrix.net/fp/tags?org_id=".concat(Oe,"&session_id=").concat(t);i.setAttribute("id","as_adv_profile_pixel"),i.setAttribute("src",a),i.setAttribute("style","width: 100px; height: 100px; border: 0; position: absolute; top: -5000px;"),r&&(r.appendChild(i),document.body.prepend(r))},t.prototype.launchWithRedirect=function(e){window.location.href=e},t.prototype.launchWithPopup=function(t,n){var o=n.popupOptions,r=new re({width:null==o?void 0:o.width,height:null==o?void 0:o.height,isClosable:null==o?void 0:o.isClosable}),i="".concat(t,"&mode=popup");return r.show({url:i}),new Promise((function(t){var n=void 0;r.on("hide",(function(){t({token:n})})),window.addEventListener("message",(function(t){var o=null;try{o=JSON.parse(t.data)}catch(e){}(null==o?void 0:o.event)===e.AuthsignalWindowMessage.AUTHSIGNAL_CLOSE_POPUP&&(n=o.token,r.close())}),!1)}))},t.prototype.launchWithWindow=function(t,n){var o=n.windowOptions,r=new j,i="".concat(t,"&mode=popup");return r.show({url:i,width:null==o?void 0:o.width,height:null==o?void 0:o.height}),new Promise((function(t){window.addEventListener("message",(function(n){var o=null;try{o=JSON.parse(n.data)}catch(e){}(null==o?void 0:o.event)===e.AuthsignalWindowMessage.AUTHSIGNAL_CLOSE_POPUP&&(r.close(),t({token:o.token}))}),!1)}))},t}();return e.Authsignal=Le,e.WebAuthnError=m,e.Whatsapp=Ae,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
|
package/dist/passkey.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ type PasskeyOptions = {
|
|
|
7
7
|
tenantId: string;
|
|
8
8
|
anonymousId: string;
|
|
9
9
|
onTokenExpired?: () => void;
|
|
10
|
+
enableLogging: boolean;
|
|
10
11
|
};
|
|
11
12
|
type SignUpParams = {
|
|
12
13
|
token?: string;
|
|
@@ -42,7 +43,8 @@ export declare class Passkey {
|
|
|
42
43
|
private passkeyLocalStorageKey;
|
|
43
44
|
private anonymousId;
|
|
44
45
|
private cache;
|
|
45
|
-
|
|
46
|
+
private enableLogging;
|
|
47
|
+
constructor({ baseUrl, tenantId, anonymousId, onTokenExpired, enableLogging }: PasskeyOptions);
|
|
46
48
|
signUp({ username, displayName, token, authenticatorAttachment, useAutoRegister, useCookies, }: SignUpParams): Promise<AuthsignalResponse<SignUpResponse>>;
|
|
47
49
|
signIn(params?: SignInParams): Promise<AuthsignalResponse<SignInResponse>>;
|
|
48
50
|
isAvailableOnDevice({ userId }: {
|
package/dist/push.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ type PushOptions = {
|
|
|
4
4
|
baseUrl: string;
|
|
5
5
|
tenantId: string;
|
|
6
6
|
onTokenExpired?: () => void;
|
|
7
|
+
enableLogging: boolean;
|
|
7
8
|
};
|
|
8
9
|
type ChallengeParams = {
|
|
9
10
|
action: string;
|
|
@@ -14,7 +15,8 @@ type VerifyParams = {
|
|
|
14
15
|
export declare class Push {
|
|
15
16
|
private api;
|
|
16
17
|
private cache;
|
|
17
|
-
|
|
18
|
+
private enableLogging;
|
|
19
|
+
constructor({ baseUrl, tenantId, onTokenExpired, enableLogging }: PushOptions);
|
|
18
20
|
challenge({ action }: ChallengeParams): Promise<AuthsignalResponse<PushChallengeResponse>>;
|
|
19
21
|
verify({ challengeId }: VerifyParams): Promise<AuthsignalResponse<PushVerifyResponse>>;
|
|
20
22
|
}
|
|
@@ -8,9 +8,11 @@ export declare class RestQrHandler extends BaseQrHandler {
|
|
|
8
8
|
private refreshTimeout?;
|
|
9
9
|
private currentChallengeParams?;
|
|
10
10
|
private cache;
|
|
11
|
-
|
|
11
|
+
private enableLogging;
|
|
12
|
+
constructor({ baseUrl, tenantId, enableLogging }: {
|
|
12
13
|
baseUrl: string;
|
|
13
14
|
tenantId: string;
|
|
15
|
+
enableLogging: boolean;
|
|
14
16
|
});
|
|
15
17
|
challenge(params: ChallengeParams): Promise<AuthsignalResponse<QrCodeChallengeResponse>>;
|
|
16
18
|
refresh({ custom }?: {
|
|
@@ -5,9 +5,11 @@ import { BaseQrHandler } from "./base-qr-handler";
|
|
|
5
5
|
export declare class WebSocketQrHandler extends BaseQrHandler {
|
|
6
6
|
private wsClient;
|
|
7
7
|
private cache;
|
|
8
|
-
|
|
8
|
+
private enableLogging;
|
|
9
|
+
constructor({ baseUrl, tenantId, enableLogging }: {
|
|
9
10
|
baseUrl: string;
|
|
10
11
|
tenantId: string;
|
|
12
|
+
enableLogging: boolean;
|
|
11
13
|
});
|
|
12
14
|
challenge(params: ChallengeParams): Promise<AuthsignalResponse<QrCodeChallengeResponse>>;
|
|
13
15
|
refresh({ custom }?: {
|
package/dist/qr-code.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { AuthsignalResponse } from "./types";
|
|
|
4
4
|
type QrCodeOptions = {
|
|
5
5
|
baseUrl: string;
|
|
6
6
|
tenantId: string;
|
|
7
|
+
enableLogging: boolean;
|
|
7
8
|
};
|
|
8
9
|
export type ChallengeParams = {
|
|
9
10
|
/** The action to be performed when the QR code is scanned. If track action is called, this must match the action passed to track. */
|
|
@@ -25,7 +26,8 @@ export declare class QrCode {
|
|
|
25
26
|
private handler;
|
|
26
27
|
private baseUrl;
|
|
27
28
|
private tenantId;
|
|
28
|
-
|
|
29
|
+
private enableLogging;
|
|
30
|
+
constructor({ baseUrl, tenantId, enableLogging }: QrCodeOptions);
|
|
29
31
|
challenge(params: ChallengeParams): Promise<AuthsignalResponse<QrCodeChallengeResponse>>;
|
|
30
32
|
refresh({ custom }?: {
|
|
31
33
|
custom?: Record<string, unknown>;
|
package/dist/security-key.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ type SecurityKeyOptions = {
|
|
|
5
5
|
baseUrl: string;
|
|
6
6
|
tenantId: string;
|
|
7
7
|
onTokenExpired?: () => void;
|
|
8
|
+
enableLogging: boolean;
|
|
8
9
|
};
|
|
9
10
|
type EnrollResponse = {
|
|
10
11
|
token?: string;
|
|
@@ -18,7 +19,8 @@ type VerifyResponse = {
|
|
|
18
19
|
export declare class SecurityKey {
|
|
19
20
|
api: SecurityKeyApiClient;
|
|
20
21
|
private cache;
|
|
21
|
-
|
|
22
|
+
private enableLogging;
|
|
23
|
+
constructor({ baseUrl, tenantId, onTokenExpired, enableLogging }: SecurityKeyOptions);
|
|
22
24
|
enroll(): Promise<AuthsignalResponse<EnrollResponse>>;
|
|
23
25
|
verify(): Promise<AuthsignalResponse<VerifyResponse>>;
|
|
24
26
|
}
|
package/dist/sms.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ type SmsOptions = {
|
|
|
4
4
|
baseUrl: string;
|
|
5
5
|
tenantId: string;
|
|
6
6
|
onTokenExpired?: () => void;
|
|
7
|
+
enableLogging: boolean;
|
|
7
8
|
};
|
|
8
9
|
type EnrollParams = {
|
|
9
10
|
phoneNumber: string;
|
|
@@ -14,7 +15,8 @@ type VerifyParams = {
|
|
|
14
15
|
export declare class Sms {
|
|
15
16
|
private api;
|
|
16
17
|
private cache;
|
|
17
|
-
|
|
18
|
+
private enableLogging;
|
|
19
|
+
constructor({ baseUrl, tenantId, onTokenExpired, enableLogging }: SmsOptions);
|
|
18
20
|
enroll({ phoneNumber }: EnrollParams): Promise<AuthsignalResponse<EnrollResponse>>;
|
|
19
21
|
challenge(): Promise<AuthsignalResponse<ChallengeResponse>>;
|
|
20
22
|
verify({ code }: VerifyParams): Promise<AuthsignalResponse<VerifyResponse>>;
|
package/dist/token-cache.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ErrorCode } from "./types";
|
|
2
2
|
export declare class TokenCache {
|
|
3
3
|
token: string | null;
|
|
4
4
|
static shared: TokenCache;
|
|
5
|
-
handleTokenNotSetError():
|
|
5
|
+
handleTokenNotSetError(): {
|
|
6
|
+
error: ErrorCode;
|
|
7
|
+
errorCode: ErrorCode;
|
|
8
|
+
errorDescription: string;
|
|
9
|
+
};
|
|
6
10
|
}
|
package/dist/totp.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ type TotpOptions = {
|
|
|
4
4
|
baseUrl: string;
|
|
5
5
|
tenantId: string;
|
|
6
6
|
onTokenExpired?: () => void;
|
|
7
|
+
enableLogging: boolean;
|
|
7
8
|
};
|
|
8
9
|
type VerifyParams = {
|
|
9
10
|
code: string;
|
|
@@ -11,7 +12,8 @@ type VerifyParams = {
|
|
|
11
12
|
export declare class Totp {
|
|
12
13
|
private api;
|
|
13
14
|
private cache;
|
|
14
|
-
|
|
15
|
+
private enableLogging;
|
|
16
|
+
constructor({ baseUrl, tenantId, onTokenExpired, enableLogging }: TotpOptions);
|
|
15
17
|
enroll(): Promise<AuthsignalResponse<EnrollTotpResponse>>;
|
|
16
18
|
verify({ code }: VerifyParams): Promise<AuthsignalResponse<VerifyResponse>>;
|
|
17
19
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -42,10 +42,7 @@ export type AuthsignalOptions = {
|
|
|
42
42
|
*/
|
|
43
43
|
cookieDomain?: string;
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
46
|
-
* we'd try to do the best to "guess" it. Last resort is t.authsignal.com.
|
|
47
|
-
*
|
|
48
|
-
* Though this parameter is not required, it's highly recommended to set is explicitly
|
|
45
|
+
* @deprecated - This parameter is no longer used.
|
|
49
46
|
*/
|
|
50
47
|
trackingHost?: string;
|
|
51
48
|
/**
|
|
@@ -55,6 +52,7 @@ export type AuthsignalOptions = {
|
|
|
55
52
|
baseUrl?: string;
|
|
56
53
|
tenantId: string;
|
|
57
54
|
onTokenExpired?: () => void;
|
|
55
|
+
enableLogging?: boolean;
|
|
58
56
|
};
|
|
59
57
|
export declare enum AuthsignalWindowMessage {
|
|
60
58
|
AUTHSIGNAL_CLOSE_POPUP = "AUTHSIGNAL_CLOSE_POPUP"
|
|
@@ -66,9 +64,21 @@ export type AuthsignalWindowMessageData = {
|
|
|
66
64
|
export type TokenPayload = {
|
|
67
65
|
token?: string;
|
|
68
66
|
};
|
|
67
|
+
export declare enum ErrorCode {
|
|
68
|
+
token_not_set = "token_not_set",
|
|
69
|
+
expired_token = "expired_token",
|
|
70
|
+
network_error = "network_error",
|
|
71
|
+
too_many_requests = "too_many_requests",
|
|
72
|
+
invalid_credential = "invalid_credential"
|
|
73
|
+
}
|
|
69
74
|
export type AuthsignalResponse<T> = {
|
|
70
|
-
error?: string;
|
|
71
75
|
data?: T;
|
|
76
|
+
errorCode?: ErrorCode;
|
|
77
|
+
errorDescription?: string;
|
|
78
|
+
/**
|
|
79
|
+
* @deprecated Use errorCode and errorDescription instead
|
|
80
|
+
*/
|
|
81
|
+
error?: string;
|
|
72
82
|
};
|
|
73
83
|
export type VerifyResponse = Omit<ApiVerifyResponse, "accessToken"> & {
|
|
74
84
|
token?: string;
|
package/dist/whatsapp.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ type WhatsappOptions = {
|
|
|
4
4
|
baseUrl: string;
|
|
5
5
|
tenantId: string;
|
|
6
6
|
onTokenExpired?: () => void;
|
|
7
|
+
enableLogging: boolean;
|
|
7
8
|
};
|
|
8
9
|
type VerifyParams = {
|
|
9
10
|
code: string;
|
|
@@ -11,7 +12,8 @@ type VerifyParams = {
|
|
|
11
12
|
export declare class Whatsapp {
|
|
12
13
|
private api;
|
|
13
14
|
private cache;
|
|
14
|
-
|
|
15
|
+
private enableLogging;
|
|
16
|
+
constructor({ baseUrl, tenantId, onTokenExpired, enableLogging }: WhatsappOptions);
|
|
15
17
|
challenge(): Promise<AuthsignalResponse<ChallengeResponse>>;
|
|
16
18
|
verify({ code }: VerifyParams): Promise<AuthsignalResponse<VerifyResponse>>;
|
|
17
19
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@authsignal/browser",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -19,7 +19,11 @@
|
|
|
19
19
|
"typescript"
|
|
20
20
|
],
|
|
21
21
|
"license": "MIT",
|
|
22
|
-
"repository": "
|
|
22
|
+
"repository": "https://github.com/authsignal/authsignal-browser",
|
|
23
|
+
"homepage": "https://github.com/authsignal/authsignal-browser#readme",
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/authsignal/authsignal-browser/issues"
|
|
26
|
+
},
|
|
23
27
|
"sideEffects": false,
|
|
24
28
|
"scripts": {
|
|
25
29
|
"typecheck": "tsc",
|
|
@@ -51,5 +55,6 @@
|
|
|
51
55
|
},
|
|
52
56
|
"files": [
|
|
53
57
|
"dist"
|
|
54
|
-
]
|
|
58
|
+
],
|
|
59
|
+
"packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
|
|
55
60
|
}
|