@stytch/vanilla-js 2.0.3 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/b2b/index.esm.js +4241 -4185
- package/dist/b2b/index.js +4130 -4074
- package/dist/index.esm.js +1 -1
- package/dist/index.headless.esm.js +617 -557
- package/dist/index.headless.js +587 -527
- package/dist/index.js +1 -1
- package/package.json +4 -2
package/dist/index.headless.js
CHANGED
|
@@ -237,7 +237,7 @@ function s() {
|
|
|
237
237
|
for (r.method = i, r.arg = s;;) {
|
|
238
238
|
var o = r.delegate;
|
|
239
239
|
if (o) {
|
|
240
|
-
var a =
|
|
240
|
+
var a = O(o, r);
|
|
241
241
|
if (a) {
|
|
242
242
|
if (a === p) continue;
|
|
243
243
|
return a;
|
|
@@ -260,16 +260,16 @@ function s() {
|
|
|
260
260
|
}
|
|
261
261
|
};
|
|
262
262
|
}
|
|
263
|
-
function
|
|
263
|
+
function O(e, t) {
|
|
264
264
|
var r = t.method,
|
|
265
265
|
n = e.iterator[r];
|
|
266
|
-
if (void 0 === n) return t.delegate = null, "throw" === r && e.iterator["return"] && (t.method = "return", t.arg = void 0,
|
|
266
|
+
if (void 0 === n) return t.delegate = null, "throw" === r && e.iterator["return"] && (t.method = "return", t.arg = void 0, O(e, t), "throw" === t.method) || "return" !== r && (t.method = "throw", t.arg = new TypeError("The iterator does not provide a '" + r + "' method")), p;
|
|
267
267
|
var i = h(n, e.iterator, t.arg);
|
|
268
268
|
if ("throw" === i.type) return t.method = "throw", t.arg = i.arg, t.delegate = null, p;
|
|
269
269
|
var s = i.arg;
|
|
270
270
|
return s ? s.done ? (t[e.resultName] = s.value, t.next = e.nextLoc, "return" !== t.method && (t.method = "next", t.arg = void 0), t.delegate = null, p) : s : (t.method = "throw", t.arg = new TypeError("iterator result is not an object"), t.delegate = null, p);
|
|
271
271
|
}
|
|
272
|
-
function
|
|
272
|
+
function T(e) {
|
|
273
273
|
var t = {
|
|
274
274
|
tryLoc: e[0]
|
|
275
275
|
};
|
|
@@ -282,7 +282,7 @@ function s() {
|
|
|
282
282
|
function C(e) {
|
|
283
283
|
this.tryEntries = [{
|
|
284
284
|
tryLoc: "root"
|
|
285
|
-
}], e.forEach(
|
|
285
|
+
}], e.forEach(T, this), this.reset(!0);
|
|
286
286
|
}
|
|
287
287
|
function E(e) {
|
|
288
288
|
if (e) {
|
|
@@ -579,13 +579,13 @@ function S() {
|
|
|
579
579
|
if (!m && !(m = "undefined" != typeof crypto && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || "undefined" != typeof msCrypto && "function" == typeof msCrypto.getRandomValues && msCrypto.getRandomValues.bind(msCrypto))) throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
580
580
|
return m(w);
|
|
581
581
|
}
|
|
582
|
-
var
|
|
583
|
-
for (var
|
|
582
|
+
var O = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
|
|
583
|
+
for (var T, x, C, E, A, P, R = [], B = 0; B < 256; ++B) R.push((B + 256).toString(16).substr(1));
|
|
584
584
|
function D(e) {
|
|
585
585
|
var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 0,
|
|
586
586
|
r = (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();
|
|
587
587
|
if (!function (e) {
|
|
588
|
-
return "string" == typeof e &&
|
|
588
|
+
return "string" == typeof e && O.test(e);
|
|
589
589
|
}(r)) throw TypeError("Stringified UUID is invalid");
|
|
590
590
|
return r;
|
|
591
591
|
}
|
|
@@ -600,7 +600,7 @@ function I(e, t, r) {
|
|
|
600
600
|
}
|
|
601
601
|
!function (e) {
|
|
602
602
|
e.emailMagicLinks = "emailMagicLinks", e.oauth = "oauth", e.otp = "otp", e.crypto = "crypto", e.passwords = "passwords";
|
|
603
|
-
}(
|
|
603
|
+
}(T || (T = {})), function (e) {
|
|
604
604
|
e.Google = "google", e.Microsoft = "microsoft", e.Apple = "apple", e.Github = "github", e.GitLab = "gitlab", e.Facebook = "facebook", e.Discord = "discord", e.Salesforce = "salesforce", e.Slack = "slack", e.Amazon = "amazon", e.Bitbucket = "bitbucket", e.LinkedIn = "linkedin", e.Coinbase = "coinbase", e.Twitch = "twitch", e.Twitter = "twitter", e.TikTok = "tiktok", e.Snapchat = "snapchat", e.Figma = "figma", e.Yahoo = "yahoo";
|
|
605
605
|
}(x || (x = {})), function (e) {
|
|
606
606
|
e.Vessel = "Vessel", e.Phantom = "Phantom", e.Metamask = "Metamask", e.Coinbase = "Coinbase", e.Binance = "Binance", e.GenericEthereumWallet = "Other Ethereum Wallet", e.GenericSolanaWallet = "Other Solana Wallet";
|
|
@@ -721,17 +721,18 @@ function z(e, t) {
|
|
|
721
721
|
var Y = function Y(e) {
|
|
722
722
|
return document.querySelectorAll('script[src="'.concat(e, '"]'));
|
|
723
723
|
};
|
|
724
|
-
var V
|
|
725
|
-
J =
|
|
724
|
+
var V,
|
|
725
|
+
J = ["[Stytch]"],
|
|
726
|
+
$ = function $() {
|
|
726
727
|
for (var e, t = arguments.length, r = new Array(t), n = 0; n < t; n++) r[n] = arguments[n];
|
|
727
|
-
return (e = console).warn.apply(e,
|
|
728
|
+
return (e = console).warn.apply(e, J.concat(r));
|
|
728
729
|
},
|
|
729
|
-
|
|
730
|
+
X = function X() {
|
|
730
731
|
for (var e, t = arguments.length, r = new Array(t), n = 0; n < t; n++) r[n] = arguments[n];
|
|
731
|
-
return (e = console).error.apply(e,
|
|
732
|
+
return (e = console).error.apply(e, J.concat(r));
|
|
732
733
|
},
|
|
733
|
-
|
|
734
|
-
|
|
734
|
+
Z = "\nYou can find your public token at https://stytch.com/dashboard/api-keys.",
|
|
735
|
+
Q = function Q(t) {
|
|
735
736
|
var r = {
|
|
736
737
|
isObject: function isObject(e, n) {
|
|
737
738
|
var s = "object" === i(n) && !Array.isArray(n) && null !== n;
|
|
@@ -783,13 +784,13 @@ var V = ["[Stytch]"],
|
|
|
783
784
|
};
|
|
784
785
|
return r;
|
|
785
786
|
},
|
|
786
|
-
|
|
787
|
+
ee = function ee(e) {
|
|
787
788
|
return b(e, ["request_id", "status_code"]);
|
|
788
789
|
},
|
|
789
|
-
|
|
790
|
+
te = function te(e) {
|
|
790
791
|
return b(e, ["__user"]);
|
|
791
792
|
},
|
|
792
|
-
|
|
793
|
+
re = a(function e(t, r, n) {
|
|
793
794
|
var i = this;
|
|
794
795
|
c(this, e), this.bootstrapPromise = n, this.isEnabled = function () {
|
|
795
796
|
return k(i, void 0, void 0, s().mark(function e() {
|
|
@@ -862,7 +863,7 @@ var V = ["[Stytch]"],
|
|
|
862
863
|
}));
|
|
863
864
|
});
|
|
864
865
|
}),
|
|
865
|
-
|
|
866
|
+
ne = function () {
|
|
866
867
|
function e() {
|
|
867
868
|
c(this, e);
|
|
868
869
|
}
|
|
@@ -908,7 +909,7 @@ var V = ["[Stytch]"],
|
|
|
908
909
|
}
|
|
909
910
|
}]), e;
|
|
910
911
|
}(),
|
|
911
|
-
|
|
912
|
+
ie = function () {
|
|
912
913
|
function e(t) {
|
|
913
914
|
c(this, e), this.maxBatchSize = t.maxBatchSize, this.logEventURL = t.logEventURL, setInterval(this.flush.bind(this), t.intervalDurationMs), this.batch = [];
|
|
914
915
|
}
|
|
@@ -954,8 +955,12 @@ var V = ["[Stytch]"],
|
|
|
954
955
|
}));
|
|
955
956
|
}
|
|
956
957
|
}]), e;
|
|
957
|
-
}()
|
|
958
|
-
|
|
958
|
+
}();
|
|
959
|
+
!function (e) {
|
|
960
|
+
e.LoginOrCreateEML = "login_or_create_eml", e.LoginOrCreateOTP = "login_or_create_otp", e.ResetPassword = "reset_password";
|
|
961
|
+
}(V || (V = {}));
|
|
962
|
+
var se,
|
|
963
|
+
oe = a(function e(t, r) {
|
|
959
964
|
var n = this;
|
|
960
965
|
c(this, e), this._networkClient = t, this._subscriptionService = r, this.get = function () {
|
|
961
966
|
return k(n, void 0, void 0, s().mark(function e() {
|
|
@@ -969,7 +974,7 @@ var V = ["[Stytch]"],
|
|
|
969
974
|
method: "GET"
|
|
970
975
|
});
|
|
971
976
|
case 2:
|
|
972
|
-
return t = e.sent, r =
|
|
977
|
+
return t = e.sent, r = ee(t), this._subscriptionService.updateUser(r), e.abrupt("return", r);
|
|
973
978
|
case 6:
|
|
974
979
|
case "end":
|
|
975
980
|
return e.stop();
|
|
@@ -984,14 +989,14 @@ var V = ["[Stytch]"],
|
|
|
984
989
|
return s().wrap(function (t) {
|
|
985
990
|
for (;;) switch (t.prev = t.next) {
|
|
986
991
|
case 0:
|
|
987
|
-
return
|
|
992
|
+
return Q("stytch.user.update").isOptionalObject("untrusted_metadata", e.untrusted_metadata), t.next = 3, this._networkClient.fetchSDK({
|
|
988
993
|
url: "/users/me",
|
|
989
994
|
body: e,
|
|
990
995
|
errorMessage: "Failed to update user.",
|
|
991
996
|
method: "PUT"
|
|
992
997
|
});
|
|
993
998
|
case 3:
|
|
994
|
-
return r = t.sent, n =
|
|
999
|
+
return r = t.sent, n = ee(r.__user), this._subscriptionService.updateUser(n), t.abrupt("return", te(r));
|
|
995
1000
|
case 7:
|
|
996
1001
|
case "end":
|
|
997
1002
|
return t.stop();
|
|
@@ -1010,7 +1015,7 @@ var V = ["[Stytch]"],
|
|
|
1010
1015
|
method: "DELETE"
|
|
1011
1016
|
});
|
|
1012
1017
|
case 2:
|
|
1013
|
-
return r = t.sent, n =
|
|
1018
|
+
return r = t.sent, n = ee(r.__user), this._subscriptionService.updateUser(n), t.abrupt("return", te(r));
|
|
1014
1019
|
case 6:
|
|
1015
1020
|
case "end":
|
|
1016
1021
|
return t.stop();
|
|
@@ -1029,7 +1034,7 @@ var V = ["[Stytch]"],
|
|
|
1029
1034
|
method: "DELETE"
|
|
1030
1035
|
});
|
|
1031
1036
|
case 2:
|
|
1032
|
-
return r = t.sent, n =
|
|
1037
|
+
return r = t.sent, n = ee(r.__user), this._subscriptionService.updateUser(n), t.abrupt("return", te(r));
|
|
1033
1038
|
case 6:
|
|
1034
1039
|
case "end":
|
|
1035
1040
|
return t.stop();
|
|
@@ -1048,7 +1053,7 @@ var V = ["[Stytch]"],
|
|
|
1048
1053
|
method: "DELETE"
|
|
1049
1054
|
});
|
|
1050
1055
|
case 2:
|
|
1051
|
-
return r = t.sent, n =
|
|
1056
|
+
return r = t.sent, n = ee(r.__user), this._subscriptionService.updateUser(n), t.abrupt("return", te(r));
|
|
1052
1057
|
case 6:
|
|
1053
1058
|
case "end":
|
|
1054
1059
|
return t.stop();
|
|
@@ -1067,7 +1072,7 @@ var V = ["[Stytch]"],
|
|
|
1067
1072
|
method: "DELETE"
|
|
1068
1073
|
});
|
|
1069
1074
|
case 2:
|
|
1070
|
-
return r = t.sent, n =
|
|
1075
|
+
return r = t.sent, n = ee(r.__user), this._subscriptionService.updateUser(n), t.abrupt("return", te(r));
|
|
1071
1076
|
case 6:
|
|
1072
1077
|
case "end":
|
|
1073
1078
|
return t.stop();
|
|
@@ -1086,7 +1091,7 @@ var V = ["[Stytch]"],
|
|
|
1086
1091
|
method: "DELETE"
|
|
1087
1092
|
});
|
|
1088
1093
|
case 2:
|
|
1089
|
-
return r = t.sent, n =
|
|
1094
|
+
return r = t.sent, n = ee(r.__user), this._subscriptionService.updateUser(n), t.abrupt("return", te(r));
|
|
1090
1095
|
case 6:
|
|
1091
1096
|
case "end":
|
|
1092
1097
|
return t.stop();
|
|
@@ -1105,7 +1110,7 @@ var V = ["[Stytch]"],
|
|
|
1105
1110
|
method: "DELETE"
|
|
1106
1111
|
});
|
|
1107
1112
|
case 2:
|
|
1108
|
-
return r = t.sent, n =
|
|
1113
|
+
return r = t.sent, n = ee(r.__user), this._subscriptionService.updateUser(n), t.abrupt("return", te(r));
|
|
1109
1114
|
case 6:
|
|
1110
1115
|
case "end":
|
|
1111
1116
|
return t.stop();
|
|
@@ -1120,7 +1125,7 @@ var V = ["[Stytch]"],
|
|
|
1120
1125
|
});
|
|
1121
1126
|
};
|
|
1122
1127
|
}),
|
|
1123
|
-
|
|
1128
|
+
ae = function () {
|
|
1124
1129
|
function e(t, r) {
|
|
1125
1130
|
var n = this;
|
|
1126
1131
|
c(this, e), this._networkClient = t, this._subscriptionService = r, this.getSync = function () {
|
|
@@ -1175,7 +1180,7 @@ var V = ["[Stytch]"],
|
|
|
1175
1180
|
session_token: n.session_token,
|
|
1176
1181
|
session_jwt: n.session_jwt,
|
|
1177
1182
|
intermediate_session_token: null
|
|
1178
|
-
}), t.abrupt("return",
|
|
1183
|
+
}), t.abrupt("return", te(n));
|
|
1179
1184
|
case 9:
|
|
1180
1185
|
throw t.prev = 9, t.t0 = t["catch"](0), W.includes(t.t0.error_type) && this._subscriptionService.destroyState(), t.t0;
|
|
1181
1186
|
case 13:
|
|
@@ -1197,20 +1202,116 @@ var V = ["[Stytch]"],
|
|
|
1197
1202
|
this._subscriptionService.updateTokens(e);
|
|
1198
1203
|
}
|
|
1199
1204
|
}]), e;
|
|
1200
|
-
}()
|
|
1201
|
-
|
|
1205
|
+
}();
|
|
1206
|
+
!function (e) {
|
|
1207
|
+
e.RequiredCatcha = "Catcha Required";
|
|
1208
|
+
}(se || (se = {}));
|
|
1209
|
+
var ce = function (e) {
|
|
1210
|
+
u(r, h(Error));
|
|
1211
|
+
var t = l(r);
|
|
1212
|
+
function r(e) {
|
|
1213
|
+
var n;
|
|
1214
|
+
return c(this, r), (n = t.call(this, e)).type = e, n;
|
|
1215
|
+
}
|
|
1216
|
+
return a(r);
|
|
1217
|
+
}();
|
|
1218
|
+
function ue(e) {
|
|
1219
|
+
var t = e.method,
|
|
1220
|
+
r = e.errorMessage,
|
|
1221
|
+
n = e.finalURL,
|
|
1222
|
+
i = e.basicAuthHeader,
|
|
1223
|
+
o = e.xSDKClientHeader,
|
|
1224
|
+
a = e.xSDKParentHostHeader,
|
|
1225
|
+
c = e.body;
|
|
1226
|
+
return k(this, void 0, void 0, s().mark(function e() {
|
|
1227
|
+
var u, l, d, h, p, f;
|
|
1228
|
+
return s().wrap(function (e) {
|
|
1229
|
+
for (;;) switch (e.prev = e.next) {
|
|
1230
|
+
case 0:
|
|
1231
|
+
return u = {
|
|
1232
|
+
Authorization: i,
|
|
1233
|
+
"Content-Type": "application/json",
|
|
1234
|
+
"X-SDK-Client": o
|
|
1235
|
+
}, a && (u["X-SDK-Parent-Host"] = a), l = {
|
|
1236
|
+
method: t,
|
|
1237
|
+
headers: u,
|
|
1238
|
+
body: c && JSON.stringify(c)
|
|
1239
|
+
}, e.prev = 3, e.next = 6, fetch(n, l);
|
|
1240
|
+
case 6:
|
|
1241
|
+
d = e.sent, e.next = 14;
|
|
1242
|
+
break;
|
|
1243
|
+
case 9:
|
|
1244
|
+
if (e.prev = 9, e.t0 = e["catch"](3), "Failed to fetch" !== e.t0.message) {
|
|
1245
|
+
e.next = 13;
|
|
1246
|
+
break;
|
|
1247
|
+
}
|
|
1248
|
+
throw new F(r, "Unable to contact the Stytch servers. Are you online?");
|
|
1249
|
+
case 13:
|
|
1250
|
+
throw e.t0;
|
|
1251
|
+
case 14:
|
|
1252
|
+
if (403 !== d.status) {
|
|
1253
|
+
e.next = 27;
|
|
1254
|
+
break;
|
|
1255
|
+
}
|
|
1256
|
+
return e.prev = 15, e.next = 18, d.text();
|
|
1257
|
+
case 18:
|
|
1258
|
+
h = e.sent, e.next = 24;
|
|
1259
|
+
break;
|
|
1260
|
+
case 21:
|
|
1261
|
+
throw e.prev = 21, e.t1 = e["catch"](15), new F(r, "Invalid response from the Stytch servers.");
|
|
1262
|
+
case 24:
|
|
1263
|
+
if (!h.includes("Captcha required")) {
|
|
1264
|
+
e.next = 26;
|
|
1265
|
+
break;
|
|
1266
|
+
}
|
|
1267
|
+
throw new ce(se.RequiredCatcha);
|
|
1268
|
+
case 26:
|
|
1269
|
+
throw new F(r, "Invalid response from the Stytch servers.");
|
|
1270
|
+
case 27:
|
|
1271
|
+
if (200 === d.status) {
|
|
1272
|
+
e.next = 40;
|
|
1273
|
+
break;
|
|
1274
|
+
}
|
|
1275
|
+
return e.prev = 28, e.next = 31, d.json();
|
|
1276
|
+
case 31:
|
|
1277
|
+
p = e.sent, e.next = 37;
|
|
1278
|
+
break;
|
|
1279
|
+
case 34:
|
|
1280
|
+
throw e.prev = 34, e.t2 = e["catch"](28), new F(r, "Invalid or no response from server");
|
|
1281
|
+
case 37:
|
|
1282
|
+
if (!("body" in p || "params" in p || "query" in p)) {
|
|
1283
|
+
e.next = 39;
|
|
1284
|
+
break;
|
|
1285
|
+
}
|
|
1286
|
+
throw new K(p);
|
|
1287
|
+
case 39:
|
|
1288
|
+
throw new q(p);
|
|
1289
|
+
case 40:
|
|
1290
|
+
return e.prev = 40, e.next = 43, d.json();
|
|
1291
|
+
case 43:
|
|
1292
|
+
return f = e.sent, e.abrupt("return", f.data);
|
|
1293
|
+
case 47:
|
|
1294
|
+
throw e.prev = 47, e.t3 = e["catch"](40), new F(r, "Invalid response from the Stytch servers.");
|
|
1295
|
+
case 50:
|
|
1296
|
+
case "end":
|
|
1297
|
+
return e.stop();
|
|
1298
|
+
}
|
|
1299
|
+
}, e, null, [[3, 9], [15, 21], [28, 34], [40, 47]]);
|
|
1300
|
+
}));
|
|
1301
|
+
}
|
|
1302
|
+
var le = Promise.resolve({
|
|
1202
1303
|
pkceRequiredForEmailMagicLinks: !1
|
|
1203
1304
|
}),
|
|
1204
|
-
|
|
1205
|
-
function e(t, r, n) {
|
|
1206
|
-
var
|
|
1207
|
-
|
|
1208
|
-
|
|
1305
|
+
de = function () {
|
|
1306
|
+
function e(t, r, n, i) {
|
|
1307
|
+
var o = this,
|
|
1308
|
+
a = arguments.length > 4 && void 0 !== arguments[4] ? arguments[4] : le,
|
|
1309
|
+
u = arguments.length > 5 && void 0 !== arguments[5] ? arguments[5] : function () {
|
|
1209
1310
|
return Promise.resolve(void 0);
|
|
1210
1311
|
},
|
|
1211
|
-
|
|
1212
|
-
c(this, e), this._networkClient = t, this._subscriptionService = r, this._pkceManager = n, this._config =
|
|
1213
|
-
return k(
|
|
1312
|
+
l = arguments.length > 6 ? arguments[6] : void 0;
|
|
1313
|
+
c(this, e), this._networkClient = t, this._subscriptionService = r, this._pkceManager = n, this._passwordResetPKCEManager = i, this._config = a, this.executeRecaptcha = u, this._dfpProtectedAuth = l, this.retryWithCaptchaAndDFP = function (e, t) {
|
|
1314
|
+
return k(o, void 0, void 0, s().mark(function r() {
|
|
1214
1315
|
var n, i;
|
|
1215
1316
|
return s().wrap(function (r) {
|
|
1216
1317
|
for (;;) switch (r.prev = r.next) {
|
|
@@ -1223,7 +1324,7 @@ var V = ["[Stytch]"],
|
|
|
1223
1324
|
case 5:
|
|
1224
1325
|
r.t0 = r.sent;
|
|
1225
1326
|
case 6:
|
|
1226
|
-
if (i = r.t0, e.type !==
|
|
1327
|
+
if (i = r.t0, e.type !== se.RequiredCatcha || !i) {
|
|
1227
1328
|
r.next = 16;
|
|
1228
1329
|
break;
|
|
1229
1330
|
}
|
|
@@ -1249,7 +1350,7 @@ var V = ["[Stytch]"],
|
|
|
1249
1350
|
}, this.email = {
|
|
1250
1351
|
loginOrCreate: function loginOrCreate(e) {
|
|
1251
1352
|
var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
|
|
1252
|
-
return k(
|
|
1353
|
+
return k(o, void 0, void 0, s().mark(function r() {
|
|
1253
1354
|
var n, i, o, a, c, u, l;
|
|
1254
1355
|
return s().wrap(function (r) {
|
|
1255
1356
|
for (;;) switch (r.prev = r.next) {
|
|
@@ -1287,7 +1388,7 @@ var V = ["[Stytch]"],
|
|
|
1287
1388
|
},
|
|
1288
1389
|
send: function send(e) {
|
|
1289
1390
|
var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
|
|
1290
|
-
return k(
|
|
1391
|
+
return k(o, void 0, void 0, s().mark(function r() {
|
|
1291
1392
|
var n, i, o, a, c, u, l, d, h;
|
|
1292
1393
|
return s().wrap(function (r) {
|
|
1293
1394
|
for (;;) switch (r.prev = r.next) {
|
|
@@ -1324,37 +1425,57 @@ var V = ["[Stytch]"],
|
|
|
1324
1425
|
}));
|
|
1325
1426
|
}
|
|
1326
1427
|
}, this.authenticate = function (e, t) {
|
|
1327
|
-
return k(
|
|
1328
|
-
var n, i
|
|
1428
|
+
return k(o, void 0, void 0, s().mark(function r() {
|
|
1429
|
+
var n, i;
|
|
1329
1430
|
return s().wrap(function (r) {
|
|
1330
1431
|
for (;;) switch (r.prev = r.next) {
|
|
1331
1432
|
case 0:
|
|
1332
|
-
return
|
|
1433
|
+
return Q("stytch.magicLinks.authenticate").isString("Token", e).isNumber("session_duration_minutes", t.session_duration_minutes), r.next = 3, this._passwordResetPKCEManager.getPKPair();
|
|
1333
1434
|
case 3:
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
}
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1435
|
+
if (n = r.sent, i = null, !(null == n ? void 0 : n.code_verifier)) {
|
|
1436
|
+
r.next = 19;
|
|
1437
|
+
break;
|
|
1438
|
+
}
|
|
1439
|
+
return r.prev = 6, r.next = 9, this.handlePKCEForAuthenticate(this._passwordResetPKCEManager, Object.assign(Object.assign({}, t), {
|
|
1440
|
+
token: e
|
|
1441
|
+
}));
|
|
1442
|
+
case 9:
|
|
1443
|
+
i = r.sent, r.next = 19;
|
|
1444
|
+
break;
|
|
1445
|
+
case 12:
|
|
1446
|
+
if (r.prev = 12, r.t0 = r["catch"](6), !r.t0.message.includes("pkce")) {
|
|
1447
|
+
r.next = 18;
|
|
1448
|
+
break;
|
|
1449
|
+
}
|
|
1450
|
+
console.log("Authenticate with passwords pkce namespace failed. Falling back to authenticate with magic_links namespace."), r.next = 19;
|
|
1451
|
+
break;
|
|
1452
|
+
case 18:
|
|
1453
|
+
throw r.t0;
|
|
1454
|
+
case 19:
|
|
1455
|
+
if (i) {
|
|
1456
|
+
r.next = 23;
|
|
1457
|
+
break;
|
|
1458
|
+
}
|
|
1459
|
+
return r.next = 22, this.handlePKCEForAuthenticate(this._pkceManager, Object.assign(Object.assign({}, t), {
|
|
1460
|
+
token: e
|
|
1461
|
+
}));
|
|
1462
|
+
case 22:
|
|
1463
|
+
i = r.sent;
|
|
1464
|
+
case 23:
|
|
1465
|
+
return this._subscriptionService.updateStateAndTokens({
|
|
1345
1466
|
state: {
|
|
1346
|
-
session:
|
|
1347
|
-
user:
|
|
1467
|
+
session: i.session,
|
|
1468
|
+
user: i.user
|
|
1348
1469
|
},
|
|
1349
|
-
session_token:
|
|
1350
|
-
session_jwt:
|
|
1470
|
+
session_token: i.session_token,
|
|
1471
|
+
session_jwt: i.session_jwt,
|
|
1351
1472
|
intermediate_session_token: null
|
|
1352
|
-
}), r.abrupt("return",
|
|
1353
|
-
case
|
|
1473
|
+
}), r.abrupt("return", te(i));
|
|
1474
|
+
case 25:
|
|
1354
1475
|
case "end":
|
|
1355
1476
|
return r.stop();
|
|
1356
1477
|
}
|
|
1357
|
-
}, r, this);
|
|
1478
|
+
}, r, this, [[6, 12]]);
|
|
1358
1479
|
}));
|
|
1359
1480
|
};
|
|
1360
1481
|
}
|
|
@@ -1424,9 +1545,36 @@ var V = ["[Stytch]"],
|
|
|
1424
1545
|
}, e, this);
|
|
1425
1546
|
}));
|
|
1426
1547
|
}
|
|
1548
|
+
}, {
|
|
1549
|
+
key: "handlePKCEForAuthenticate",
|
|
1550
|
+
value: function value(e, t) {
|
|
1551
|
+
return k(this, void 0, void 0, s().mark(function r() {
|
|
1552
|
+
var n, i, o;
|
|
1553
|
+
return s().wrap(function (r) {
|
|
1554
|
+
for (;;) switch (r.prev = r.next) {
|
|
1555
|
+
case 0:
|
|
1556
|
+
return r.next = 2, e.getPKPair();
|
|
1557
|
+
case 2:
|
|
1558
|
+
return n = r.sent, i = Object.assign({
|
|
1559
|
+
code_verifier: null == n ? void 0 : n.code_verifier
|
|
1560
|
+
}, t), r.next = 6, this._networkClient.fetchSDK({
|
|
1561
|
+
url: "/magic_links/authenticate",
|
|
1562
|
+
body: i,
|
|
1563
|
+
errorMessage: "Failed to authenticate token.",
|
|
1564
|
+
method: "POST"
|
|
1565
|
+
});
|
|
1566
|
+
case 6:
|
|
1567
|
+
return o = r.sent, e.clearPKPair(), r.abrupt("return", o);
|
|
1568
|
+
case 9:
|
|
1569
|
+
case "end":
|
|
1570
|
+
return r.stop();
|
|
1571
|
+
}
|
|
1572
|
+
}, r, this);
|
|
1573
|
+
}));
|
|
1574
|
+
}
|
|
1427
1575
|
}]), e;
|
|
1428
1576
|
}(),
|
|
1429
|
-
|
|
1577
|
+
he = a(function e(t, r) {
|
|
1430
1578
|
var n = this,
|
|
1431
1579
|
i = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : function () {
|
|
1432
1580
|
return Promise.resolve(void 0);
|
|
@@ -1584,7 +1732,7 @@ var V = ["[Stytch]"],
|
|
|
1584
1732
|
return s().wrap(function (n) {
|
|
1585
1733
|
for (;;) switch (n.prev = n.next) {
|
|
1586
1734
|
case 0:
|
|
1587
|
-
return
|
|
1735
|
+
return Q("stytch.otps.authenticate").isString("Code", e).isNumber("session_duration_minutes", r.session_duration_minutes), i = Object.assign({
|
|
1588
1736
|
token: e,
|
|
1589
1737
|
method_id: t
|
|
1590
1738
|
}, r), n.next = 4, this._networkClient.fetchSDK({
|
|
@@ -1602,7 +1750,7 @@ var V = ["[Stytch]"],
|
|
|
1602
1750
|
session_token: o.session_token,
|
|
1603
1751
|
session_jwt: o.session_jwt,
|
|
1604
1752
|
intermediate_session_token: null
|
|
1605
|
-
}), n.abrupt("return",
|
|
1753
|
+
}), n.abrupt("return", te(o));
|
|
1606
1754
|
case 7:
|
|
1607
1755
|
case "end":
|
|
1608
1756
|
return n.stop();
|
|
@@ -1611,7 +1759,7 @@ var V = ["[Stytch]"],
|
|
|
1611
1759
|
}));
|
|
1612
1760
|
};
|
|
1613
1761
|
}),
|
|
1614
|
-
|
|
1762
|
+
pe = function () {
|
|
1615
1763
|
function e(t, r, n, i, s) {
|
|
1616
1764
|
c(this, e), this._networkClient = t, this._subscriptionService = r, this._pkceManager = n, this._dynamicConfig = i, this._config = s, this.google = {
|
|
1617
1765
|
start: this.startOAuthFlow(x.Google)
|
|
@@ -1661,9 +1809,9 @@ var V = ["[Stytch]"],
|
|
|
1661
1809
|
return s().wrap(function (r) {
|
|
1662
1810
|
for (;;) switch (r.prev = r.next) {
|
|
1663
1811
|
case 0:
|
|
1664
|
-
return
|
|
1812
|
+
return Q("stytch.oauth.authenticate").isString("Token", e).isNumber("session_duration_minutes", t.session_duration_minutes), r.next = 3, this._pkceManager.getPKPair();
|
|
1665
1813
|
case 3:
|
|
1666
|
-
return (n = r.sent) ||
|
|
1814
|
+
return (n = r.sent) || $("No code verifier found in local storage for OAuth flow.\nConsider using stytch.oauth.$provider.start() to add PKCE to your OAuth flows for added security.\nSee https://stytch.com/docs/oauth#guides_pkce for more information."), r.next = 7, this._networkClient.fetchSDK({
|
|
1667
1815
|
url: "/oauth/authenticate",
|
|
1668
1816
|
method: "POST",
|
|
1669
1817
|
body: Object.assign({
|
|
@@ -1676,12 +1824,12 @@ var V = ["[Stytch]"],
|
|
|
1676
1824
|
return i = r.sent, this._pkceManager.clearPKPair(), this._subscriptionService.updateStateAndTokens({
|
|
1677
1825
|
state: {
|
|
1678
1826
|
session: i.session,
|
|
1679
|
-
user:
|
|
1827
|
+
user: ee(i.__user)
|
|
1680
1828
|
},
|
|
1681
1829
|
session_token: i.session_token,
|
|
1682
1830
|
session_jwt: i.session_jwt,
|
|
1683
1831
|
intermediate_session_token: null
|
|
1684
|
-
}), r.abrupt("return",
|
|
1832
|
+
}), r.abrupt("return", te(i));
|
|
1685
1833
|
case 11:
|
|
1686
1834
|
case "end":
|
|
1687
1835
|
return r.stop();
|
|
@@ -1756,7 +1904,7 @@ var V = ["[Stytch]"],
|
|
|
1756
1904
|
case 18:
|
|
1757
1905
|
this._pkceManager.clearPKPair();
|
|
1758
1906
|
case 19:
|
|
1759
|
-
o && (
|
|
1907
|
+
o && (Q("startOAuthFlow").isStringArray("custom_scopes", o), l.searchParams.set("custom_scopes", o.join(" "))), n && l.searchParams.set("login_redirect_url", n), i && l.searchParams.set("signup_redirect_url", i), window.location.href = l.toString();
|
|
1760
1908
|
case 23:
|
|
1761
1909
|
case "end":
|
|
1762
1910
|
return t.stop();
|
|
@@ -1767,7 +1915,7 @@ var V = ["[Stytch]"],
|
|
|
1767
1915
|
}
|
|
1768
1916
|
}]), e;
|
|
1769
1917
|
}(),
|
|
1770
|
-
|
|
1918
|
+
fe = function () {
|
|
1771
1919
|
function e(t, r) {
|
|
1772
1920
|
var n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : function () {
|
|
1773
1921
|
return Promise.resolve(void 0);
|
|
@@ -1782,7 +1930,7 @@ var V = ["[Stytch]"],
|
|
|
1782
1930
|
return s().wrap(function (t) {
|
|
1783
1931
|
for (;;) switch (t.prev = t.next) {
|
|
1784
1932
|
case 0:
|
|
1785
|
-
return
|
|
1933
|
+
return Q("stytch.cryptoWallets.authenticateStart").isString("crypto_wallet_address", e.crypto_wallet_address).isString("crypto_wallet_type", e.crypto_wallet_type), r = !!this._subscriptionService.getSession(), t.next = 4, this.executeRecaptcha();
|
|
1786
1934
|
case 4:
|
|
1787
1935
|
return n = t.sent, i = r ? "/crypto_wallets/authenticate/start/secondary" : "/crypto_wallets/authenticate/start/primary", t.abrupt("return", this._networkClient.fetchSDK({
|
|
1788
1936
|
url: i,
|
|
@@ -1809,7 +1957,7 @@ var V = ["[Stytch]"],
|
|
|
1809
1957
|
return s().wrap(function (t) {
|
|
1810
1958
|
for (;;) switch (t.prev = t.next) {
|
|
1811
1959
|
case 0:
|
|
1812
|
-
return
|
|
1960
|
+
return Q("stytch.cryptoWallets.authenticate").isString("signature", e.signature).isString("crypto_wallet_address", e.crypto_wallet_address).isString("crypto_wallet_type", e.crypto_wallet_type).isNumber("session_duration_minutes", e.session_duration_minutes), t.next = 3, this._networkClient.fetchSDK({
|
|
1813
1961
|
url: "/crypto_wallets/authenticate",
|
|
1814
1962
|
method: "POST",
|
|
1815
1963
|
errorMessage: "Failed to authenticate.",
|
|
@@ -1824,12 +1972,12 @@ var V = ["[Stytch]"],
|
|
|
1824
1972
|
return r = t.sent, this._subscriptionService.updateStateAndTokens({
|
|
1825
1973
|
state: {
|
|
1826
1974
|
session: r.session,
|
|
1827
|
-
user:
|
|
1975
|
+
user: ee(r.__user)
|
|
1828
1976
|
},
|
|
1829
1977
|
session_token: r.session_token,
|
|
1830
1978
|
session_jwt: r.session_jwt,
|
|
1831
1979
|
intermediate_session_token: null
|
|
1832
|
-
}), t.abrupt("return",
|
|
1980
|
+
}), t.abrupt("return", te(r));
|
|
1833
1981
|
case 6:
|
|
1834
1982
|
case "end":
|
|
1835
1983
|
return t.stop();
|
|
@@ -1839,7 +1987,7 @@ var V = ["[Stytch]"],
|
|
|
1839
1987
|
}
|
|
1840
1988
|
}]), e;
|
|
1841
1989
|
}(),
|
|
1842
|
-
|
|
1990
|
+
_e = function () {
|
|
1843
1991
|
function e(t, r) {
|
|
1844
1992
|
c(this, e), this._networkClient = t, this._subscriptionService = r;
|
|
1845
1993
|
}
|
|
@@ -1851,7 +1999,7 @@ var V = ["[Stytch]"],
|
|
|
1851
1999
|
return s().wrap(function (t) {
|
|
1852
2000
|
for (;;) switch (t.prev = t.next) {
|
|
1853
2001
|
case 0:
|
|
1854
|
-
return
|
|
2002
|
+
return Q("stytch.totps.create").isNumber("expiration_minutes", e.expiration_minutes), t.next = 3, this._networkClient.fetchSDK({
|
|
1855
2003
|
url: "/totps",
|
|
1856
2004
|
method: "POST",
|
|
1857
2005
|
errorMessage: "Failed to create TOTP",
|
|
@@ -1860,7 +2008,7 @@ var V = ["[Stytch]"],
|
|
|
1860
2008
|
}
|
|
1861
2009
|
});
|
|
1862
2010
|
case 3:
|
|
1863
|
-
return r = t.sent, this._subscriptionService.updateUser(r.__user), t.abrupt("return",
|
|
2011
|
+
return r = t.sent, this._subscriptionService.updateUser(r.__user), t.abrupt("return", te(r));
|
|
1864
2012
|
case 6:
|
|
1865
2013
|
case "end":
|
|
1866
2014
|
return t.stop();
|
|
@@ -1876,7 +2024,7 @@ var V = ["[Stytch]"],
|
|
|
1876
2024
|
return s().wrap(function (t) {
|
|
1877
2025
|
for (;;) switch (t.prev = t.next) {
|
|
1878
2026
|
case 0:
|
|
1879
|
-
return
|
|
2027
|
+
return Q("stytch.totps.authenticate").isNumber("session_duration_minutes", e.session_duration_minutes).isString("totp_code", e.totp_code), t.next = 3, this._networkClient.fetchSDK({
|
|
1880
2028
|
url: "/totps/authenticate",
|
|
1881
2029
|
method: "POST",
|
|
1882
2030
|
errorMessage: "Failed to authenticate TOTP",
|
|
@@ -1894,7 +2042,7 @@ var V = ["[Stytch]"],
|
|
|
1894
2042
|
session_token: r.session_token,
|
|
1895
2043
|
session_jwt: r.session_jwt,
|
|
1896
2044
|
intermediate_session_token: null
|
|
1897
|
-
}), t.abrupt("return",
|
|
2045
|
+
}), t.abrupt("return", te(r));
|
|
1898
2046
|
case 6:
|
|
1899
2047
|
case "end":
|
|
1900
2048
|
return t.stop();
|
|
@@ -1929,7 +2077,7 @@ var V = ["[Stytch]"],
|
|
|
1929
2077
|
return s().wrap(function (t) {
|
|
1930
2078
|
for (;;) switch (t.prev = t.next) {
|
|
1931
2079
|
case 0:
|
|
1932
|
-
return
|
|
2080
|
+
return Q("stytch.totps.recover").isNumber("session_duration_minutes", e.session_duration_minutes).isString("recovery_code", e.recovery_code), t.next = 3, this._networkClient.fetchSDK({
|
|
1933
2081
|
url: "/totps/recover",
|
|
1934
2082
|
method: "POST",
|
|
1935
2083
|
errorMessage: "Failed to recover TOTP",
|
|
@@ -1947,7 +2095,7 @@ var V = ["[Stytch]"],
|
|
|
1947
2095
|
session_token: r.session_token,
|
|
1948
2096
|
session_jwt: r.session_jwt,
|
|
1949
2097
|
intermediate_session_token: null
|
|
1950
|
-
}), t.abrupt("return",
|
|
2098
|
+
}), t.abrupt("return", te(r));
|
|
1951
2099
|
case 6:
|
|
1952
2100
|
case "end":
|
|
1953
2101
|
return t.stop();
|
|
@@ -1957,11 +2105,11 @@ var V = ["[Stytch]"],
|
|
|
1957
2105
|
}
|
|
1958
2106
|
}]), e;
|
|
1959
2107
|
}();
|
|
1960
|
-
function
|
|
2108
|
+
function ve(e) {
|
|
1961
2109
|
for (var t = "==".slice(0, (4 - e.length % 4) % 4), r = e.replace(/-/g, "+").replace(/_/g, "/") + t, n = atob(r), i = new ArrayBuffer(n.length), s = new Uint8Array(i), o = 0; o < n.length; o++) s[o] = n.charCodeAt(o);
|
|
1962
2110
|
return i;
|
|
1963
2111
|
}
|
|
1964
|
-
function
|
|
2112
|
+
function me(t) {
|
|
1965
2113
|
var r,
|
|
1966
2114
|
n = "",
|
|
1967
2115
|
i = e(new Uint8Array(t));
|
|
@@ -1977,13 +2125,13 @@ function pe(t) {
|
|
|
1977
2125
|
}
|
|
1978
2126
|
return btoa(n).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
1979
2127
|
}
|
|
1980
|
-
var
|
|
1981
|
-
|
|
1982
|
-
function
|
|
1983
|
-
if (r ===
|
|
1984
|
-
if (r ===
|
|
2128
|
+
var ye = "copy",
|
|
2129
|
+
ge = "convert";
|
|
2130
|
+
function be(e, r, n) {
|
|
2131
|
+
if (r === ye) return n;
|
|
2132
|
+
if (r === ge) return e(n);
|
|
1985
2133
|
if (r instanceof Array) return n.map(function (t) {
|
|
1986
|
-
return
|
|
2134
|
+
return be(e, r[0], t);
|
|
1987
2135
|
});
|
|
1988
2136
|
if (r instanceof Object) {
|
|
1989
2137
|
for (var i = {}, s = 0, o = Object.entries(r); s < o.length; s++) {
|
|
@@ -1994,122 +2142,122 @@ function ve(e, r, n) {
|
|
|
1994
2142
|
var l = u.derive(n);
|
|
1995
2143
|
void 0 !== l && (n[c] = l);
|
|
1996
2144
|
}
|
|
1997
|
-
if (c in n) null != n[c] ? i[c] =
|
|
2145
|
+
if (c in n) null != n[c] ? i[c] = be(e, u.schema, n[c]) : i[c] = null;else if (u.required) throw new Error("Missing key: ".concat(c));
|
|
1998
2146
|
}
|
|
1999
2147
|
return i;
|
|
2000
2148
|
}
|
|
2001
2149
|
}
|
|
2002
|
-
function
|
|
2150
|
+
function ke(e, t) {
|
|
2003
2151
|
return {
|
|
2004
2152
|
required: !0,
|
|
2005
2153
|
schema: e,
|
|
2006
2154
|
derive: t
|
|
2007
2155
|
};
|
|
2008
2156
|
}
|
|
2009
|
-
function
|
|
2157
|
+
function we(e) {
|
|
2010
2158
|
return {
|
|
2011
2159
|
required: !0,
|
|
2012
2160
|
schema: e
|
|
2013
2161
|
};
|
|
2014
2162
|
}
|
|
2015
|
-
function
|
|
2163
|
+
function Se(e) {
|
|
2016
2164
|
return {
|
|
2017
2165
|
required: !1,
|
|
2018
2166
|
schema: e
|
|
2019
2167
|
};
|
|
2020
2168
|
}
|
|
2021
|
-
var
|
|
2022
|
-
type: ye
|
|
2023
|
-
id:
|
|
2024
|
-
transports:
|
|
2169
|
+
var Oe = {
|
|
2170
|
+
type: we(ye),
|
|
2171
|
+
id: we(ge),
|
|
2172
|
+
transports: Se(ye)
|
|
2025
2173
|
},
|
|
2026
|
-
|
|
2027
|
-
appid:
|
|
2028
|
-
appidExclude:
|
|
2029
|
-
credProps:
|
|
2174
|
+
Te = {
|
|
2175
|
+
appid: Se(ye),
|
|
2176
|
+
appidExclude: Se(ye),
|
|
2177
|
+
credProps: Se(ye)
|
|
2030
2178
|
},
|
|
2031
|
-
|
|
2032
|
-
appid:
|
|
2033
|
-
appidExclude:
|
|
2034
|
-
credProps:
|
|
2179
|
+
xe = {
|
|
2180
|
+
appid: Se(ye),
|
|
2181
|
+
appidExclude: Se(ye),
|
|
2182
|
+
credProps: Se(ye)
|
|
2035
2183
|
},
|
|
2036
|
-
|
|
2037
|
-
publicKey:
|
|
2038
|
-
rp: ye
|
|
2039
|
-
user:
|
|
2040
|
-
id:
|
|
2041
|
-
name: ye
|
|
2042
|
-
displayName: ye
|
|
2184
|
+
Ce = {
|
|
2185
|
+
publicKey: we({
|
|
2186
|
+
rp: we(ye),
|
|
2187
|
+
user: we({
|
|
2188
|
+
id: we(ge),
|
|
2189
|
+
name: we(ye),
|
|
2190
|
+
displayName: we(ye)
|
|
2043
2191
|
}),
|
|
2044
|
-
challenge:
|
|
2045
|
-
pubKeyCredParams: ye
|
|
2046
|
-
timeout:
|
|
2047
|
-
excludeCredentials:
|
|
2048
|
-
authenticatorSelection:
|
|
2049
|
-
attestation:
|
|
2050
|
-
extensions:
|
|
2192
|
+
challenge: we(ge),
|
|
2193
|
+
pubKeyCredParams: we(ye),
|
|
2194
|
+
timeout: Se(ye),
|
|
2195
|
+
excludeCredentials: Se([Oe]),
|
|
2196
|
+
authenticatorSelection: Se(ye),
|
|
2197
|
+
attestation: Se(ye),
|
|
2198
|
+
extensions: Se(Te)
|
|
2051
2199
|
}),
|
|
2052
|
-
signal:
|
|
2200
|
+
signal: Se(ye)
|
|
2053
2201
|
},
|
|
2054
|
-
|
|
2055
|
-
type: ye
|
|
2056
|
-
id: ye
|
|
2057
|
-
rawId:
|
|
2058
|
-
authenticatorAttachment:
|
|
2059
|
-
response:
|
|
2060
|
-
clientDataJSON:
|
|
2061
|
-
attestationObject:
|
|
2062
|
-
transports:
|
|
2202
|
+
Ee = {
|
|
2203
|
+
type: we(ye),
|
|
2204
|
+
id: we(ye),
|
|
2205
|
+
rawId: we(ge),
|
|
2206
|
+
authenticatorAttachment: Se(ye),
|
|
2207
|
+
response: we({
|
|
2208
|
+
clientDataJSON: we(ge),
|
|
2209
|
+
attestationObject: we(ge),
|
|
2210
|
+
transports: ke(ye, function (e) {
|
|
2063
2211
|
var t;
|
|
2064
2212
|
return (null == (t = e.getTransports) ? void 0 : t.call(e)) || [];
|
|
2065
2213
|
})
|
|
2066
2214
|
}),
|
|
2067
|
-
clientExtensionResults:
|
|
2215
|
+
clientExtensionResults: ke(xe, function (e) {
|
|
2068
2216
|
return e.getClientExtensionResults();
|
|
2069
2217
|
})
|
|
2070
2218
|
},
|
|
2071
|
-
|
|
2072
|
-
mediation:
|
|
2073
|
-
publicKey:
|
|
2074
|
-
challenge:
|
|
2075
|
-
timeout:
|
|
2076
|
-
rpId:
|
|
2077
|
-
allowCredentials:
|
|
2078
|
-
userVerification:
|
|
2079
|
-
extensions:
|
|
2219
|
+
Ae = {
|
|
2220
|
+
mediation: Se(ye),
|
|
2221
|
+
publicKey: we({
|
|
2222
|
+
challenge: we(ge),
|
|
2223
|
+
timeout: Se(ye),
|
|
2224
|
+
rpId: Se(ye),
|
|
2225
|
+
allowCredentials: Se([Oe]),
|
|
2226
|
+
userVerification: Se(ye),
|
|
2227
|
+
extensions: Se(Te)
|
|
2080
2228
|
}),
|
|
2081
|
-
signal:
|
|
2229
|
+
signal: Se(ye)
|
|
2082
2230
|
},
|
|
2083
|
-
|
|
2084
|
-
type: ye
|
|
2085
|
-
id: ye
|
|
2086
|
-
rawId:
|
|
2087
|
-
authenticatorAttachment:
|
|
2088
|
-
response:
|
|
2089
|
-
clientDataJSON:
|
|
2090
|
-
authenticatorData:
|
|
2091
|
-
signature:
|
|
2092
|
-
userHandle:
|
|
2231
|
+
Pe = {
|
|
2232
|
+
type: we(ye),
|
|
2233
|
+
id: we(ye),
|
|
2234
|
+
rawId: we(ge),
|
|
2235
|
+
authenticatorAttachment: Se(ye),
|
|
2236
|
+
response: we({
|
|
2237
|
+
clientDataJSON: we(ge),
|
|
2238
|
+
authenticatorData: we(ge),
|
|
2239
|
+
signature: we(ge),
|
|
2240
|
+
userHandle: we(ge)
|
|
2093
2241
|
}),
|
|
2094
|
-
clientExtensionResults:
|
|
2242
|
+
clientExtensionResults: ke(xe, function (e) {
|
|
2095
2243
|
return e.getClientExtensionResults();
|
|
2096
2244
|
})
|
|
2097
2245
|
};
|
|
2098
|
-
function
|
|
2099
|
-
return ve
|
|
2246
|
+
function Re(e) {
|
|
2247
|
+
return be(ve, Ce, e);
|
|
2100
2248
|
}
|
|
2101
|
-
function
|
|
2102
|
-
return
|
|
2249
|
+
function Be(e) {
|
|
2250
|
+
return be(me, Ee, e);
|
|
2103
2251
|
}
|
|
2104
|
-
function
|
|
2252
|
+
function De(e) {
|
|
2105
2253
|
return k(this, void 0, void 0, s().mark(function t() {
|
|
2106
2254
|
var r;
|
|
2107
2255
|
return s().wrap(function (t) {
|
|
2108
2256
|
for (;;) switch (t.prev = t.next) {
|
|
2109
2257
|
case 0:
|
|
2110
|
-
return t.next = 2, navigator.credentials.create(
|
|
2258
|
+
return t.next = 2, navigator.credentials.create(Re(e));
|
|
2111
2259
|
case 2:
|
|
2112
|
-
return r = t.sent, t.abrupt("return",
|
|
2260
|
+
return r = t.sent, t.abrupt("return", Be(r));
|
|
2113
2261
|
case 4:
|
|
2114
2262
|
case "end":
|
|
2115
2263
|
return t.stop();
|
|
@@ -2117,21 +2265,21 @@ function Ae(e) {
|
|
|
2117
2265
|
}, t);
|
|
2118
2266
|
}));
|
|
2119
2267
|
}
|
|
2120
|
-
function
|
|
2121
|
-
return ve
|
|
2268
|
+
function Ie(e) {
|
|
2269
|
+
return be(ve, Ae, e);
|
|
2122
2270
|
}
|
|
2123
|
-
function
|
|
2124
|
-
return
|
|
2271
|
+
function Le(e) {
|
|
2272
|
+
return be(me, Pe, e);
|
|
2125
2273
|
}
|
|
2126
|
-
function
|
|
2274
|
+
function je(e) {
|
|
2127
2275
|
return k(this, void 0, void 0, s().mark(function t() {
|
|
2128
2276
|
var r;
|
|
2129
2277
|
return s().wrap(function (t) {
|
|
2130
2278
|
for (;;) switch (t.prev = t.next) {
|
|
2131
2279
|
case 0:
|
|
2132
|
-
return t.next = 2, navigator.credentials.get(
|
|
2280
|
+
return t.next = 2, navigator.credentials.get(Ie(e));
|
|
2133
2281
|
case 2:
|
|
2134
|
-
return r = t.sent, t.abrupt("return",
|
|
2282
|
+
return r = t.sent, t.abrupt("return", Le(r));
|
|
2135
2283
|
case 4:
|
|
2136
2284
|
case "end":
|
|
2137
2285
|
return t.stop();
|
|
@@ -2139,8 +2287,7 @@ function Be(e) {
|
|
|
2139
2287
|
}, t);
|
|
2140
2288
|
}));
|
|
2141
2289
|
}
|
|
2142
|
-
var
|
|
2143
|
-
Ie = function () {
|
|
2290
|
+
var Me = function () {
|
|
2144
2291
|
function e(t, r) {
|
|
2145
2292
|
c(this, e), this._networkClient = t, this._subscriptionService = r;
|
|
2146
2293
|
}
|
|
@@ -2153,7 +2300,7 @@ var De,
|
|
|
2153
2300
|
return s().wrap(function (r) {
|
|
2154
2301
|
for (;;) switch (r.prev = r.next) {
|
|
2155
2302
|
case 0:
|
|
2156
|
-
return
|
|
2303
|
+
return Q("stytch.webauthn.register").isOptionalString("domain", null == e ? void 0 : e.domain).isOptionalString("authenticator_type", null == e ? void 0 : e.authenticator_type), r.next = 3, this._networkClient.fetchSDK({
|
|
2157
2304
|
url: "/webauthn/register/start",
|
|
2158
2305
|
method: "POST",
|
|
2159
2306
|
errorMessage: "Failed to start WebAuthn registration",
|
|
@@ -2163,7 +2310,7 @@ var De,
|
|
|
2163
2310
|
}
|
|
2164
2311
|
});
|
|
2165
2312
|
case 3:
|
|
2166
|
-
return n = r.sent, i = n.public_key_credential_creation_options, r.next = 7,
|
|
2313
|
+
return n = r.sent, i = n.public_key_credential_creation_options, r.next = 7, De({
|
|
2167
2314
|
publicKey: JSON.parse(i)
|
|
2168
2315
|
});
|
|
2169
2316
|
case 7:
|
|
@@ -2176,7 +2323,7 @@ var De,
|
|
|
2176
2323
|
}
|
|
2177
2324
|
});
|
|
2178
2325
|
case 10:
|
|
2179
|
-
return a = r.sent, this._subscriptionService.updateUser(a.__user), r.abrupt("return",
|
|
2326
|
+
return a = r.sent, this._subscriptionService.updateUser(a.__user), r.abrupt("return", te(a));
|
|
2180
2327
|
case 13:
|
|
2181
2328
|
case "end":
|
|
2182
2329
|
return r.stop();
|
|
@@ -2193,7 +2340,7 @@ var De,
|
|
|
2193
2340
|
return s().wrap(function (r) {
|
|
2194
2341
|
for (;;) switch (r.prev = r.next) {
|
|
2195
2342
|
case 0:
|
|
2196
|
-
return
|
|
2343
|
+
return Q("stytch.webauthn.register").isOptionalString("domain", e.domain).isNumber("session_duration_minutes", e.session_duration_minutes), r.next = 3, this._networkClient.fetchSDK({
|
|
2197
2344
|
url: "/webauthn/authenticate/start",
|
|
2198
2345
|
method: "POST",
|
|
2199
2346
|
errorMessage: "Failed to start WebAuthn authentication",
|
|
@@ -2202,7 +2349,7 @@ var De,
|
|
|
2202
2349
|
}
|
|
2203
2350
|
});
|
|
2204
2351
|
case 3:
|
|
2205
|
-
return n = r.sent, i = n.public_key_credential_request_options, r.next = 7,
|
|
2352
|
+
return n = r.sent, i = n.public_key_credential_request_options, r.next = 7, je({
|
|
2206
2353
|
publicKey: JSON.parse(i)
|
|
2207
2354
|
});
|
|
2208
2355
|
case 7:
|
|
@@ -2224,7 +2371,7 @@ var De,
|
|
|
2224
2371
|
session_token: a.session_token,
|
|
2225
2372
|
session_jwt: a.session_jwt,
|
|
2226
2373
|
intermediate_session_token: null
|
|
2227
|
-
}), r.abrupt("return",
|
|
2374
|
+
}), r.abrupt("return", te(a));
|
|
2228
2375
|
case 13:
|
|
2229
2376
|
case "end":
|
|
2230
2377
|
return r.stop();
|
|
@@ -2234,13 +2381,13 @@ var De,
|
|
|
2234
2381
|
}
|
|
2235
2382
|
}]), e;
|
|
2236
2383
|
}(),
|
|
2237
|
-
|
|
2384
|
+
Ne = Promise.resolve({
|
|
2238
2385
|
pkceRequiredForPasswordResets: !1
|
|
2239
2386
|
}),
|
|
2240
|
-
|
|
2387
|
+
Fe = function () {
|
|
2241
2388
|
function e(t, r, n) {
|
|
2242
2389
|
var i = this,
|
|
2243
|
-
o = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] :
|
|
2390
|
+
o = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : Ne,
|
|
2244
2391
|
a = arguments.length > 4 && void 0 !== arguments[4] ? arguments[4] : function () {
|
|
2245
2392
|
return Promise.resolve(void 0);
|
|
2246
2393
|
},
|
|
@@ -2259,7 +2406,7 @@ var De,
|
|
|
2259
2406
|
case 5:
|
|
2260
2407
|
r.t0 = r.sent;
|
|
2261
2408
|
case 6:
|
|
2262
|
-
if (i = r.t0, e.type !==
|
|
2409
|
+
if (i = r.t0, e.type !== se.RequiredCatcha || !i) {
|
|
2263
2410
|
r.next = 16;
|
|
2264
2411
|
break;
|
|
2265
2412
|
}
|
|
@@ -2366,7 +2513,7 @@ var De,
|
|
|
2366
2513
|
return s().wrap(function (t) {
|
|
2367
2514
|
for (;;) switch (t.prev = t.next) {
|
|
2368
2515
|
case 0:
|
|
2369
|
-
return
|
|
2516
|
+
return Q("stytch.passwords.create").isString("password", e.password).isString("email", e.email).isNumber("session_duration_minutes", e.session_duration_minutes), t.next = 3, this.getDFPTelemetryIDAndCaptcha();
|
|
2370
2517
|
case 3:
|
|
2371
2518
|
return r = t.sent, n = r.dfp_telemetry_id, i = r.captcha_token, t.next = 8, this._networkClient.retriableFetchSDK({
|
|
2372
2519
|
url: "/passwords",
|
|
@@ -2390,7 +2537,7 @@ var De,
|
|
|
2390
2537
|
session_token: o.session_token,
|
|
2391
2538
|
session_jwt: o.session_jwt,
|
|
2392
2539
|
intermediate_session_token: null
|
|
2393
|
-
}), t.abrupt("return",
|
|
2540
|
+
}), t.abrupt("return", te(o));
|
|
2394
2541
|
case 11:
|
|
2395
2542
|
case "end":
|
|
2396
2543
|
return t.stop();
|
|
@@ -2406,7 +2553,7 @@ var De,
|
|
|
2406
2553
|
return s().wrap(function (t) {
|
|
2407
2554
|
for (;;) switch (t.prev = t.next) {
|
|
2408
2555
|
case 0:
|
|
2409
|
-
return
|
|
2556
|
+
return Q("stytch.passwords.authenticate").isString("password", e.password).isString("email", e.email).isNumber("session_duration_minutes", e.session_duration_minutes), t.next = 3, this.getDFPTelemetryIDAndCaptcha();
|
|
2410
2557
|
case 3:
|
|
2411
2558
|
return r = t.sent, n = r.dfp_telemetry_id, i = r.captcha_token, t.next = 8, this._networkClient.retriableFetchSDK({
|
|
2412
2559
|
url: "/passwords/authenticate",
|
|
@@ -2430,7 +2577,7 @@ var De,
|
|
|
2430
2577
|
session_token: o.session_token,
|
|
2431
2578
|
session_jwt: o.session_jwt,
|
|
2432
2579
|
intermediate_session_token: null
|
|
2433
|
-
}), t.abrupt("return",
|
|
2580
|
+
}), t.abrupt("return", te(o));
|
|
2434
2581
|
case 11:
|
|
2435
2582
|
case "end":
|
|
2436
2583
|
return t.stop();
|
|
@@ -2446,7 +2593,7 @@ var De,
|
|
|
2446
2593
|
return s().wrap(function (t) {
|
|
2447
2594
|
for (;;) switch (t.prev = t.next) {
|
|
2448
2595
|
case 0:
|
|
2449
|
-
return
|
|
2596
|
+
return Q("stytch.passwords.resetByEmailStart").isString("email", e.email).isOptionalString("login_redirect_url", e.login_redirect_url).isOptionalString("reset_password_redirect_url", e.reset_password_redirect_url).isOptionalString("reset_password_template_id", e.reset_password_template_id).isOptionalNumber("reset_password_expiration_minutes", e.reset_password_expiration_minutes), t.next = 3, this.getCodeChallenge();
|
|
2450
2597
|
case 3:
|
|
2451
2598
|
return r = t.sent, t.next = 6, this.getDFPTelemetryIDAndCaptcha();
|
|
2452
2599
|
case 6:
|
|
@@ -2481,7 +2628,7 @@ var De,
|
|
|
2481
2628
|
return s().wrap(function (t) {
|
|
2482
2629
|
for (;;) switch (t.prev = t.next) {
|
|
2483
2630
|
case 0:
|
|
2484
|
-
return
|
|
2631
|
+
return Q("stytch.passwords.resetByEmail").isString("token", e.token).isString("password", e.password).isNumber("session_duration_minutes", e.session_duration_minutes), t.next = 3, this.getDFPTelemetryIDAndCaptcha();
|
|
2485
2632
|
case 3:
|
|
2486
2633
|
return r = t.sent, n = r.dfp_telemetry_id, i = r.captcha_token, t.next = 8, this._pkceManager.getPKPair();
|
|
2487
2634
|
case 8:
|
|
@@ -2508,7 +2655,7 @@ var De,
|
|
|
2508
2655
|
session_token: c.session_token,
|
|
2509
2656
|
session_jwt: c.session_jwt,
|
|
2510
2657
|
intermediate_session_token: null
|
|
2511
|
-
}), t.abrupt("return",
|
|
2658
|
+
}), t.abrupt("return", te(c));
|
|
2512
2659
|
case 16:
|
|
2513
2660
|
case "end":
|
|
2514
2661
|
return t.stop();
|
|
@@ -2524,7 +2671,7 @@ var De,
|
|
|
2524
2671
|
return s().wrap(function (t) {
|
|
2525
2672
|
for (;;) switch (t.prev = t.next) {
|
|
2526
2673
|
case 0:
|
|
2527
|
-
return
|
|
2674
|
+
return Q("stytch.passwords.resetByExistingPassword").isString("email", e.email).isString("existing_password", e.existing_password).isString("new_password", e.new_password).isNumber("session_duration_minutes", e.session_duration_minutes), t.next = 3, this._networkClient.fetchSDK({
|
|
2528
2675
|
url: "/passwords/existing_password/reset",
|
|
2529
2676
|
method: "POST",
|
|
2530
2677
|
errorMessage: "Failed to reset password.",
|
|
@@ -2544,7 +2691,7 @@ var De,
|
|
|
2544
2691
|
session_token: r.session_token,
|
|
2545
2692
|
session_jwt: r.session_jwt,
|
|
2546
2693
|
intermediate_session_token: null
|
|
2547
|
-
}), t.abrupt("return",
|
|
2694
|
+
}), t.abrupt("return", te(r));
|
|
2548
2695
|
case 6:
|
|
2549
2696
|
case "end":
|
|
2550
2697
|
return t.stop();
|
|
@@ -2560,7 +2707,7 @@ var De,
|
|
|
2560
2707
|
return s().wrap(function (t) {
|
|
2561
2708
|
for (;;) switch (t.prev = t.next) {
|
|
2562
2709
|
case 0:
|
|
2563
|
-
return
|
|
2710
|
+
return Q("stytch.passwords.resetBySession").isString("password", e.password), t.next = 3, this._networkClient.fetchSDK({
|
|
2564
2711
|
url: "/passwords/session/reset",
|
|
2565
2712
|
method: "POST",
|
|
2566
2713
|
errorMessage: "Failed to reset session.",
|
|
@@ -2592,7 +2739,7 @@ var De,
|
|
|
2592
2739
|
return s().wrap(function (t) {
|
|
2593
2740
|
for (;;) switch (t.prev = t.next) {
|
|
2594
2741
|
case 0:
|
|
2595
|
-
return
|
|
2742
|
+
return Q("stytch.passwords.strengthCheck").isOptionalString("email", e.email).isString("password", e.password), t.abrupt("return", this._networkClient.fetchSDK({
|
|
2596
2743
|
url: "/passwords/strength_check",
|
|
2597
2744
|
method: "POST",
|
|
2598
2745
|
errorMessage: "Failed to check password strength.",
|
|
@@ -2614,103 +2761,8 @@ Promise.resolve({
|
|
|
2614
2761
|
pkceRequiredForEmailMagicLinks: !1
|
|
2615
2762
|
}), Promise.resolve({
|
|
2616
2763
|
pkceRequiredForPasswordResets: !1
|
|
2617
|
-
})
|
|
2618
|
-
|
|
2619
|
-
}(De || (De = {}));
|
|
2620
|
-
var Me = function (e) {
|
|
2621
|
-
u(r, h(Error));
|
|
2622
|
-
var t = l(r);
|
|
2623
|
-
function r(e) {
|
|
2624
|
-
var n;
|
|
2625
|
-
return c(this, r), (n = t.call(this, e)).type = e, n;
|
|
2626
|
-
}
|
|
2627
|
-
return a(r);
|
|
2628
|
-
}();
|
|
2629
|
-
function Ne(e) {
|
|
2630
|
-
var t = e.method,
|
|
2631
|
-
r = e.errorMessage,
|
|
2632
|
-
n = e.finalURL,
|
|
2633
|
-
i = e.basicAuthHeader,
|
|
2634
|
-
o = e.xSDKClientHeader,
|
|
2635
|
-
a = e.xSDKParentHostHeader,
|
|
2636
|
-
c = e.body;
|
|
2637
|
-
return k(this, void 0, void 0, s().mark(function e() {
|
|
2638
|
-
var u, l, d, h, p, f;
|
|
2639
|
-
return s().wrap(function (e) {
|
|
2640
|
-
for (;;) switch (e.prev = e.next) {
|
|
2641
|
-
case 0:
|
|
2642
|
-
return u = {
|
|
2643
|
-
Authorization: i,
|
|
2644
|
-
"Content-Type": "application/json",
|
|
2645
|
-
"X-SDK-Client": o
|
|
2646
|
-
}, a && (u["X-SDK-Parent-Host"] = a), l = {
|
|
2647
|
-
method: t,
|
|
2648
|
-
headers: u,
|
|
2649
|
-
body: c && JSON.stringify(c)
|
|
2650
|
-
}, e.prev = 3, e.next = 6, fetch(n, l);
|
|
2651
|
-
case 6:
|
|
2652
|
-
d = e.sent, e.next = 14;
|
|
2653
|
-
break;
|
|
2654
|
-
case 9:
|
|
2655
|
-
if (e.prev = 9, e.t0 = e["catch"](3), "Failed to fetch" !== e.t0.message) {
|
|
2656
|
-
e.next = 13;
|
|
2657
|
-
break;
|
|
2658
|
-
}
|
|
2659
|
-
throw new F(r, "Unable to contact the Stytch servers. Are you online?");
|
|
2660
|
-
case 13:
|
|
2661
|
-
throw e.t0;
|
|
2662
|
-
case 14:
|
|
2663
|
-
if (403 !== d.status) {
|
|
2664
|
-
e.next = 27;
|
|
2665
|
-
break;
|
|
2666
|
-
}
|
|
2667
|
-
return e.prev = 15, e.next = 18, d.text();
|
|
2668
|
-
case 18:
|
|
2669
|
-
h = e.sent, e.next = 24;
|
|
2670
|
-
break;
|
|
2671
|
-
case 21:
|
|
2672
|
-
throw e.prev = 21, e.t1 = e["catch"](15), new F(r, "Invalid response from the Stytch servers.");
|
|
2673
|
-
case 24:
|
|
2674
|
-
if (!h.includes("Captcha required")) {
|
|
2675
|
-
e.next = 26;
|
|
2676
|
-
break;
|
|
2677
|
-
}
|
|
2678
|
-
throw new Me(De.RequiredCatcha);
|
|
2679
|
-
case 26:
|
|
2680
|
-
throw new F(r, "Invalid response from the Stytch servers.");
|
|
2681
|
-
case 27:
|
|
2682
|
-
if (200 === d.status) {
|
|
2683
|
-
e.next = 40;
|
|
2684
|
-
break;
|
|
2685
|
-
}
|
|
2686
|
-
return e.prev = 28, e.next = 31, d.json();
|
|
2687
|
-
case 31:
|
|
2688
|
-
p = e.sent, e.next = 37;
|
|
2689
|
-
break;
|
|
2690
|
-
case 34:
|
|
2691
|
-
throw e.prev = 34, e.t2 = e["catch"](28), new F(r, "Invalid or no response from server");
|
|
2692
|
-
case 37:
|
|
2693
|
-
if (!("body" in p || "params" in p || "query" in p)) {
|
|
2694
|
-
e.next = 39;
|
|
2695
|
-
break;
|
|
2696
|
-
}
|
|
2697
|
-
throw new K(p);
|
|
2698
|
-
case 39:
|
|
2699
|
-
throw new q(p);
|
|
2700
|
-
case 40:
|
|
2701
|
-
return e.prev = 40, e.next = 43, d.json();
|
|
2702
|
-
case 43:
|
|
2703
|
-
return f = e.sent, e.abrupt("return", f.data);
|
|
2704
|
-
case 47:
|
|
2705
|
-
throw e.prev = 47, e.t3 = e["catch"](40), new F(r, "Invalid response from the Stytch servers.");
|
|
2706
|
-
case 50:
|
|
2707
|
-
case "end":
|
|
2708
|
-
return e.stop();
|
|
2709
|
-
}
|
|
2710
|
-
}, e, null, [[3, 9], [15, 21], [28, 34], [40, 47]]);
|
|
2711
|
-
}));
|
|
2712
|
-
}
|
|
2713
|
-
var Fe = function () {
|
|
2764
|
+
});
|
|
2765
|
+
var Ue = function () {
|
|
2714
2766
|
function e(t) {
|
|
2715
2767
|
c(this, e), this.iframeURL = t, this.createIframe();
|
|
2716
2768
|
}
|
|
@@ -2718,7 +2770,7 @@ var Fe = function () {
|
|
|
2718
2770
|
key: "createIframe",
|
|
2719
2771
|
value: function value() {
|
|
2720
2772
|
var e = document.querySelector('[src~="'.concat(this.iframeURL, '"]'));
|
|
2721
|
-
e ?
|
|
2773
|
+
e ? $("It looks like you're creating multiple copies of the Stytch client. This behavior is unsupported, and unintended side effects may occur. Make sure you are creating the Stytch client at the global level, and not inside a component's render function.") : ((e = document.createElement("iframe")).src = this.iframeURL, e.style.position = "absolute", e.style.width = "0", e.style.height = "0", e.style.border = "0", document.body.appendChild(e)), "true" !== e.dataset.loaded ? this.frame = new Promise(function (t) {
|
|
2722
2774
|
e.addEventListener("load", function () {
|
|
2723
2775
|
e.dataset.loaded = "true", t(e);
|
|
2724
2776
|
}, {
|
|
@@ -2742,7 +2794,7 @@ var Fe = function () {
|
|
|
2742
2794
|
var a;
|
|
2743
2795
|
i.port1.onmessage = function (e) {
|
|
2744
2796
|
var t = e.data;
|
|
2745
|
-
i.port1.close(), t.success ? r(t.payload) : s(
|
|
2797
|
+
i.port1.close(), t.success ? r(t.payload) : s(ne.unmarshall(t.error));
|
|
2746
2798
|
};
|
|
2747
2799
|
var c = {
|
|
2748
2800
|
method: e,
|
|
@@ -2759,7 +2811,7 @@ var Fe = function () {
|
|
|
2759
2811
|
}
|
|
2760
2812
|
}]), e;
|
|
2761
2813
|
}(),
|
|
2762
|
-
|
|
2814
|
+
Ke = function () {
|
|
2763
2815
|
function e(t, r) {
|
|
2764
2816
|
var n = this;
|
|
2765
2817
|
c(this, e), this._subscriptionService = t, this._headlessSessionClient = r, this._onDataChange = function (e) {
|
|
@@ -2803,7 +2855,7 @@ var Fe = function () {
|
|
|
2803
2855
|
this._reauthenticateWithBackoff().then(function () {
|
|
2804
2856
|
e.scheduleBackgroundRefresh();
|
|
2805
2857
|
})["catch"](function (t) {
|
|
2806
|
-
|
|
2858
|
+
$("Session background refresh failed. Signalling to app that user is logged out.", {
|
|
2807
2859
|
error: t
|
|
2808
2860
|
}), e._subscriptionService.destroyState();
|
|
2809
2861
|
});
|
|
@@ -2833,20 +2885,20 @@ var Fe = function () {
|
|
|
2833
2885
|
}
|
|
2834
2886
|
}]), e;
|
|
2835
2887
|
}();
|
|
2836
|
-
|
|
2837
|
-
var
|
|
2838
|
-
var
|
|
2839
|
-
function
|
|
2888
|
+
Ke.REFRESH_INTERVAL_MS = 18e4;
|
|
2889
|
+
var qe = "bootstrap";
|
|
2890
|
+
var We = /*#__PURE__*/function () {
|
|
2891
|
+
function We(e, t, r) {
|
|
2840
2892
|
var _this = this;
|
|
2841
|
-
_classCallCheck(this,
|
|
2893
|
+
_classCallCheck(this, We);
|
|
2842
2894
|
this._publicToken = e, this._networkClient = t, this._dataLayer = r, this._bootstrapDataPromise = this._networkClient.fetchSDK({
|
|
2843
2895
|
url: "/projects/bootstrap/".concat(this._publicToken),
|
|
2844
2896
|
method: "GET",
|
|
2845
2897
|
errorMessage: "Error fetching bootstrap data for SDK for ".concat(this._publicToken)
|
|
2846
|
-
}).then(
|
|
2847
|
-
return _this._dataLayer.setItem(
|
|
2898
|
+
}).then(We.mapBootstrapData).then(function (e) {
|
|
2899
|
+
return _this._dataLayer.setItem(qe, JSON.stringify(e)), e;
|
|
2848
2900
|
})["catch"](function (e) {
|
|
2849
|
-
return
|
|
2901
|
+
return X(e), {
|
|
2850
2902
|
displayWatermark: !1,
|
|
2851
2903
|
cnameDomain: null,
|
|
2852
2904
|
emailDomains: ["stytch.com"],
|
|
@@ -2864,10 +2916,10 @@ var qe = /*#__PURE__*/function () {
|
|
|
2864
2916
|
};
|
|
2865
2917
|
});
|
|
2866
2918
|
}
|
|
2867
|
-
_createClass(
|
|
2919
|
+
_createClass(We, [{
|
|
2868
2920
|
key: "getSync",
|
|
2869
2921
|
value: function getSync() {
|
|
2870
|
-
var e = this._dataLayer.getItem(
|
|
2922
|
+
var e = this._dataLayer.getItem(qe);
|
|
2871
2923
|
if (null === e) return {
|
|
2872
2924
|
displayWatermark: !1,
|
|
2873
2925
|
cnameDomain: null,
|
|
@@ -2934,9 +2986,9 @@ var qe = /*#__PURE__*/function () {
|
|
|
2934
2986
|
};
|
|
2935
2987
|
}
|
|
2936
2988
|
}]);
|
|
2937
|
-
return
|
|
2989
|
+
return We;
|
|
2938
2990
|
}();
|
|
2939
|
-
function
|
|
2991
|
+
function Ge(e, t, r, n) {
|
|
2940
2992
|
return new (r || (r = Promise))(function (i, s) {
|
|
2941
2993
|
function o(e) {
|
|
2942
2994
|
try {
|
|
@@ -2961,11 +3013,11 @@ function We(e, t, r, n) {
|
|
|
2961
3013
|
c((n = n.apply(e, t || [])).next());
|
|
2962
3014
|
});
|
|
2963
3015
|
}
|
|
2964
|
-
var
|
|
3016
|
+
var He = /*#__PURE__*/_createClass(function He(e) {
|
|
2965
3017
|
var _this2 = this;
|
|
2966
|
-
_classCallCheck(this,
|
|
3018
|
+
_classCallCheck(this, He);
|
|
2967
3019
|
this.bootstrapPromise = e, this.executeRecaptcha = function () {
|
|
2968
|
-
return
|
|
3020
|
+
return Ge(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
2969
3021
|
var _yield$this$state, e, t, r;
|
|
2970
3022
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
2971
3023
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -2996,7 +3048,7 @@ var Ge = /*#__PURE__*/_createClass(function Ge(e) {
|
|
|
2996
3048
|
}, _callee, this);
|
|
2997
3049
|
}));
|
|
2998
3050
|
}, this.state = e.then(function (e) {
|
|
2999
|
-
return
|
|
3051
|
+
return Ge(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
3000
3052
|
var t;
|
|
3001
3053
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
3002
3054
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -3034,21 +3086,21 @@ var Ge = /*#__PURE__*/_createClass(function Ge(e) {
|
|
|
3034
3086
|
}));
|
|
3035
3087
|
});
|
|
3036
3088
|
});
|
|
3037
|
-
var
|
|
3038
|
-
function
|
|
3089
|
+
var ze = /*#__PURE__*/function () {
|
|
3090
|
+
function ze(e) {
|
|
3039
3091
|
var _this3 = this;
|
|
3040
|
-
_classCallCheck(this,
|
|
3092
|
+
_classCallCheck(this, ze);
|
|
3041
3093
|
this.iframeURL = e, this.oneTapStart = function (e) {
|
|
3042
3094
|
return _this3.call("oneTapStart", e);
|
|
3043
3095
|
}, this.oneTapSubmit = function (e) {
|
|
3044
3096
|
return _this3.call("oneTapSubmit", e);
|
|
3045
3097
|
};
|
|
3046
3098
|
}
|
|
3047
|
-
_createClass(
|
|
3099
|
+
_createClass(ze, [{
|
|
3048
3100
|
key: "frameClient",
|
|
3049
3101
|
get: function get() {
|
|
3050
3102
|
var e;
|
|
3051
|
-
return this._frameClient = null !== (e = this._frameClient) && void 0 !== e ? e : new
|
|
3103
|
+
return this._frameClient = null !== (e = this._frameClient) && void 0 !== e ? e : new Ue(this.iframeURL), this._frameClient;
|
|
3052
3104
|
}
|
|
3053
3105
|
}, {
|
|
3054
3106
|
key: "call",
|
|
@@ -3056,40 +3108,40 @@ var He = /*#__PURE__*/function () {
|
|
|
3056
3108
|
return this.frameClient.call(e, [t]);
|
|
3057
3109
|
}
|
|
3058
3110
|
}]);
|
|
3059
|
-
return
|
|
3111
|
+
return ze;
|
|
3060
3112
|
}();
|
|
3061
|
-
function
|
|
3062
|
-
return
|
|
3113
|
+
function Ye(e) {
|
|
3114
|
+
return Ye = "function" == typeof Symbol && "symbol" == _typeof(Symbol.iterator) ? function (e) {
|
|
3063
3115
|
return _typeof(e);
|
|
3064
3116
|
} : function (e) {
|
|
3065
3117
|
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : _typeof(e);
|
|
3066
|
-
},
|
|
3118
|
+
}, Ye(e);
|
|
3067
3119
|
}
|
|
3068
|
-
function
|
|
3120
|
+
function Ve(e, t) {
|
|
3069
3121
|
for (var r = 0; r < t.length; r++) {
|
|
3070
3122
|
var n = t[r];
|
|
3071
3123
|
n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(e, (i = n.key, s = void 0, s = function (e, t) {
|
|
3072
|
-
if ("object" !==
|
|
3124
|
+
if ("object" !== Ye(e) || null === e) return e;
|
|
3073
3125
|
var r = e[Symbol.toPrimitive];
|
|
3074
3126
|
if (void 0 !== r) {
|
|
3075
3127
|
var n = r.call(e, t || "default");
|
|
3076
|
-
if ("object" !==
|
|
3128
|
+
if ("object" !== Ye(n)) return n;
|
|
3077
3129
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
3078
3130
|
}
|
|
3079
3131
|
return ("string" === t ? String : Number)(e);
|
|
3080
|
-
}(i, "string"), "symbol" ===
|
|
3132
|
+
}(i, "string"), "symbol" === Ye(s) ? s : String(s)), n);
|
|
3081
3133
|
}
|
|
3082
3134
|
var i, s;
|
|
3083
3135
|
}
|
|
3084
|
-
function
|
|
3085
|
-
return t &&
|
|
3136
|
+
function Je(e, t, r) {
|
|
3137
|
+
return t && Ve(e.prototype, t), r && Ve(e, r), Object.defineProperty(e, "prototype", {
|
|
3086
3138
|
writable: !1
|
|
3087
3139
|
}), e;
|
|
3088
3140
|
}
|
|
3089
|
-
function
|
|
3141
|
+
function $e(e, t) {
|
|
3090
3142
|
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
|
|
3091
3143
|
}
|
|
3092
|
-
function
|
|
3144
|
+
function Xe(e, t) {
|
|
3093
3145
|
if ("function" != typeof t && null !== t) throw new TypeError("Super expression must either be null or a function");
|
|
3094
3146
|
e.prototype = Object.create(t && t.prototype, {
|
|
3095
3147
|
constructor: {
|
|
@@ -3099,31 +3151,31 @@ function $e(e, t) {
|
|
|
3099
3151
|
}
|
|
3100
3152
|
}), Object.defineProperty(e, "prototype", {
|
|
3101
3153
|
writable: !1
|
|
3102
|
-
}), t &&
|
|
3154
|
+
}), t && nt(e, t);
|
|
3103
3155
|
}
|
|
3104
|
-
function
|
|
3105
|
-
var t =
|
|
3156
|
+
function Ze(e) {
|
|
3157
|
+
var t = rt();
|
|
3106
3158
|
return function () {
|
|
3107
3159
|
var r,
|
|
3108
|
-
n =
|
|
3160
|
+
n = it(e);
|
|
3109
3161
|
if (t) {
|
|
3110
|
-
var i =
|
|
3162
|
+
var i = it(this).constructor;
|
|
3111
3163
|
r = Reflect.construct(n, arguments, i);
|
|
3112
3164
|
} else r = n.apply(this, arguments);
|
|
3113
3165
|
return function (e, t) {
|
|
3114
|
-
if (t && ("object" ===
|
|
3166
|
+
if (t && ("object" === Ye(t) || "function" == typeof t)) return t;
|
|
3115
3167
|
if (void 0 !== t) throw new TypeError("Derived constructors may only return object or undefined");
|
|
3116
|
-
return
|
|
3168
|
+
return Qe(e);
|
|
3117
3169
|
}(this, r);
|
|
3118
3170
|
};
|
|
3119
3171
|
}
|
|
3120
|
-
function
|
|
3172
|
+
function Qe(e) {
|
|
3121
3173
|
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
3122
3174
|
return e;
|
|
3123
3175
|
}
|
|
3124
|
-
function
|
|
3176
|
+
function et(e) {
|
|
3125
3177
|
var t = "function" == typeof Map ? new Map() : void 0;
|
|
3126
|
-
return
|
|
3178
|
+
return et = function et(e) {
|
|
3127
3179
|
if (null === e || (r = e, -1 === Function.toString.call(r).indexOf("[native code]"))) return e;
|
|
3128
3180
|
var r;
|
|
3129
3181
|
if ("function" != typeof e) throw new TypeError("Super expression must either be null or a function");
|
|
@@ -3132,7 +3184,7 @@ function Qe(e) {
|
|
|
3132
3184
|
t.set(e, n);
|
|
3133
3185
|
}
|
|
3134
3186
|
function n() {
|
|
3135
|
-
return
|
|
3187
|
+
return tt(e, arguments, it(this).constructor);
|
|
3136
3188
|
}
|
|
3137
3189
|
return n.prototype = Object.create(e.prototype, {
|
|
3138
3190
|
constructor: {
|
|
@@ -3141,18 +3193,18 @@ function Qe(e) {
|
|
|
3141
3193
|
writable: !0,
|
|
3142
3194
|
configurable: !0
|
|
3143
3195
|
}
|
|
3144
|
-
}),
|
|
3145
|
-
},
|
|
3196
|
+
}), nt(n, e);
|
|
3197
|
+
}, et(e);
|
|
3146
3198
|
}
|
|
3147
|
-
function
|
|
3148
|
-
return
|
|
3199
|
+
function tt(e, t, r) {
|
|
3200
|
+
return tt = rt() ? Reflect.construct.bind() : function (e, t, r) {
|
|
3149
3201
|
var n = [null];
|
|
3150
3202
|
n.push.apply(n, t);
|
|
3151
3203
|
var i = new (Function.bind.apply(e, n))();
|
|
3152
|
-
return r &&
|
|
3153
|
-
},
|
|
3204
|
+
return r && nt(i, r.prototype), i;
|
|
3205
|
+
}, tt.apply(null, arguments);
|
|
3154
3206
|
}
|
|
3155
|
-
function
|
|
3207
|
+
function rt() {
|
|
3156
3208
|
if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
|
|
3157
3209
|
if (Reflect.construct.sham) return !1;
|
|
3158
3210
|
if ("function" == typeof Proxy) return !0;
|
|
@@ -3162,15 +3214,15 @@ function tt() {
|
|
|
3162
3214
|
return !1;
|
|
3163
3215
|
}
|
|
3164
3216
|
}
|
|
3165
|
-
function
|
|
3166
|
-
return
|
|
3217
|
+
function nt(e, t) {
|
|
3218
|
+
return nt = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (e, t) {
|
|
3167
3219
|
return e.__proto__ = t, e;
|
|
3168
|
-
},
|
|
3220
|
+
}, nt(e, t);
|
|
3169
3221
|
}
|
|
3170
|
-
function
|
|
3171
|
-
return
|
|
3222
|
+
function it(e) {
|
|
3223
|
+
return it = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (e) {
|
|
3172
3224
|
return e.__proto__ || Object.getPrototypeOf(e);
|
|
3173
|
-
},
|
|
3225
|
+
}, it(e);
|
|
3174
3226
|
}
|
|
3175
3227
|
exports.Products = void 0, function (e) {
|
|
3176
3228
|
e.emailMagicLinks = "emailMagicLinks", e.oauth = "oauth", e.otp = "otp", e.crypto = "crypto", e.passwords = "passwords";
|
|
@@ -3185,43 +3237,43 @@ exports.Products = void 0, function (e) {
|
|
|
3185
3237
|
}(exports.OTPMethods || (exports.OTPMethods = {})), exports.StytchEventType = void 0, function (e) {
|
|
3186
3238
|
e.MagicLinkLoginOrCreateEvent = "MAGIC_LINK_LOGIN_OR_CREATE", e.OTPsLoginOrCreateEvent = "OTP_LOGIN_OR_CREATE", e.OTPsAuthenticate = "OTP_AUTHENTICATE", e.CryptoWalletAuthenticateStart = "CRYPTO_WALLET_AUTHENTICATE_START", e.CryptoWalletAuthenticate = "CRYPTO_WALLET_AUTHENTICATE", e.PasswordCreate = "PASSWORD_CREATE", e.PasswordAuthenticate = "PASSWORD_AUTHENTICATE", e.PasswordResetByEmailStart = "PASSWORD_RESET_BY_EMAIL_START", e.PasswordResetByEmail = "PASSWORD_RESET_BY_EMAIL", e.B2BMagicLinkEmailLoginOrSignup = "B2B_MAGIC_LINK_EMAIL_LOGIN_OR_SIGNUP", e.B2BMagicLinkAuthenticate = "B2B_MAGIC_LINK_AUTHENTICATE", e.B2BMagicLinkEmailDiscoverySend = "B2B_MAGIC_LINK_EMAIL_DISCOVERY_SEND", e.B2BMagicLinkDiscoveryAuthenticate = "B2B_MAGIC_LINK_DISCOVERY_AUTHENTICATE", e.B2BSSOStart = "B2B_SSO_START", e.B2BSSOAuthenticate = "B2B_SSO_AUTHENTICATE", e.B2BOAuthAuthenticate = "B2B_SSO_AUTHENTICATE", e.B2BOAuthDiscoveryAuthenticate = "B2B_OAUTH_DISCOVERY_AUTHENTICATE", e.B2BDiscoveryOrganizationsCreate = "B2B_DISCOVERY_ORGANIZATIONS_CREATE", e.B2BDiscoveryIntermediateSessionExchange = "B2B_DISCOVERY_INTERMEDIATE_SESSION_EXCHANGE", e.B2BPasswordAuthenticate = "B2B_PASSWORD_AUTHENTICATE", e.B2BPasswordResetByEmailStart = "B2B_PASSWORD_RESET_BY_EMAIL_START", e.B2BPasswordResetByEmail = "B2B_PASSWORD_RESET_BY_EMAIL", e.B2BPasswordResetBySession = "B2B_PASSWORD_RESET_BY_SESSION";
|
|
3187
3239
|
}(exports.StytchEventType || (exports.StytchEventType = {}));
|
|
3188
|
-
var
|
|
3189
|
-
|
|
3190
|
-
var t =
|
|
3240
|
+
var st = function (e) {
|
|
3241
|
+
Xe(r, et(Error));
|
|
3242
|
+
var t = Ze(r);
|
|
3191
3243
|
function r(e, n) {
|
|
3192
3244
|
var i;
|
|
3193
|
-
return
|
|
3245
|
+
return $e(this, r), (i = t.call(this, e + "\n" + n)).message = e + "\n" + n, i.name = "SDKAPIUnreachableError", i.details = n, Object.setPrototypeOf(Qe(i), r.prototype), i;
|
|
3194
3246
|
}
|
|
3195
|
-
return
|
|
3247
|
+
return Je(r);
|
|
3196
3248
|
}(),
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
var t =
|
|
3249
|
+
ot = function (e) {
|
|
3250
|
+
Xe(r, et(Error));
|
|
3251
|
+
var t = Ze(r);
|
|
3200
3252
|
function r(e, n) {
|
|
3201
3253
|
var i;
|
|
3202
|
-
return
|
|
3254
|
+
return $e(this, r), (i = t.call(this)).name = "StytchSDKUsageError", i.message = "Invalid call to ".concat(e, "\n") + n, i;
|
|
3203
3255
|
}
|
|
3204
|
-
return
|
|
3256
|
+
return Je(r);
|
|
3205
3257
|
}(),
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
var t =
|
|
3258
|
+
at = function (e) {
|
|
3259
|
+
Xe(r, et(Error));
|
|
3260
|
+
var t = Ze(r);
|
|
3209
3261
|
function r(e) {
|
|
3210
3262
|
var n, i;
|
|
3211
|
-
|
|
3263
|
+
$e(this, r), (n = t.call(this)).name = "StytchSDKSchemaError";
|
|
3212
3264
|
var s = null === (i = e.body) || void 0 === i ? void 0 : i.map(function (e) {
|
|
3213
3265
|
return "".concat(e.dataPath, ": ").concat(e.message);
|
|
3214
3266
|
}).join("\n");
|
|
3215
3267
|
return n.message = "[400] Request does not match expected schema\n".concat(s), n;
|
|
3216
3268
|
}
|
|
3217
|
-
return
|
|
3269
|
+
return Je(r);
|
|
3218
3270
|
}(),
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
var t =
|
|
3271
|
+
ct = function (e) {
|
|
3272
|
+
Xe(r, et(Error));
|
|
3273
|
+
var t = Ze(r);
|
|
3222
3274
|
function r(e) {
|
|
3223
3275
|
var n;
|
|
3224
|
-
|
|
3276
|
+
$e(this, r), (n = t.call(this)).name = "StytchSDKAPIError";
|
|
3225
3277
|
var i = e.status_code,
|
|
3226
3278
|
s = e.error_type,
|
|
3227
3279
|
o = e.error_message,
|
|
@@ -3229,16 +3281,16 @@ var it = function (e) {
|
|
|
3229
3281
|
c = e.request_id;
|
|
3230
3282
|
return n.error_type = s, n.error_message = o, n.error_url = a, n.request_id = c, n.status_code = i, n.message = "[".concat(i, "] ").concat(s, "\n") + "".concat(o, "\n") + "See ".concat(a, " for more information.\n") + (c ? "request_id: ".concat(c, "\n") : ""), n;
|
|
3231
3283
|
}
|
|
3232
|
-
return
|
|
3284
|
+
return Je(r);
|
|
3233
3285
|
}(),
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
var t =
|
|
3286
|
+
ut = function (e) {
|
|
3287
|
+
Xe(r, et(Error));
|
|
3288
|
+
var t = Ze(r);
|
|
3237
3289
|
function r(e) {
|
|
3238
3290
|
var n;
|
|
3239
|
-
return
|
|
3291
|
+
return $e(this, r), (n = t.call(this)).name = "StytchSDKNativeError", n.error_type = e, n.message = "".concat(e), n;
|
|
3240
3292
|
}
|
|
3241
|
-
return
|
|
3293
|
+
return Je(r);
|
|
3242
3294
|
}();
|
|
3243
3295
|
exports.BiometricsErrors = void 0, function (e) {
|
|
3244
3296
|
e.BiometricsSensorError = "biometrics_sensor_error", e.DeviceCredentialsNotAllowed = "device_credentials_not_allowed", e.DeviceHardwareError = "device_hardware_error", e.InternalError = "internal_error", e.KeyInvalidated = "key_invalidated", e.KeystoreUnavailable = "keystore_unavailable", e.NoBiometricsEnrolled = "no_biometrics_enrolled", e.NoBiometricsRegistration = "no_biometrics_registration", e.SessionExpired = "session_expired", e.UserCancellation = "user_cancellation", e.UserLockedOut = "user_locked_out", e.BiometricsNotAvailable = "biometrics_not_available";
|
|
@@ -3249,14 +3301,14 @@ exports.BiometricsErrors = void 0, function (e) {
|
|
|
3249
3301
|
}(exports.AuthFlowType || (exports.AuthFlowType = {})), exports.B2BOAuthProviders = void 0, function (e) {
|
|
3250
3302
|
e.Google = "google", e.Microsoft = "microsoft";
|
|
3251
3303
|
}(exports.B2BOAuthProviders || (exports.B2BOAuthProviders = {}));
|
|
3252
|
-
var
|
|
3253
|
-
_inherits(
|
|
3254
|
-
var _super = _createSuper(
|
|
3255
|
-
function
|
|
3304
|
+
var lt = /*#__PURE__*/function (_pe) {
|
|
3305
|
+
_inherits(lt, _pe);
|
|
3306
|
+
var _super = _createSuper(lt);
|
|
3307
|
+
function lt(e, t, r, n, i, s) {
|
|
3256
3308
|
var _this4;
|
|
3257
|
-
_classCallCheck(this,
|
|
3309
|
+
_classCallCheck(this, lt);
|
|
3258
3310
|
_this4 = _super.call(this, e, t, r, n, i), _this4._oneTap = s, _this4.startOneTap = function (e) {
|
|
3259
|
-
return
|
|
3311
|
+
return Ge(_assertThisInitialized(_this4), void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
3260
3312
|
var t, r, n;
|
|
3261
3313
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
3262
3314
|
while (1) switch (_context3.prev = _context3.next) {
|
|
@@ -3294,20 +3346,20 @@ var ut = /*#__PURE__*/function (_ue) {
|
|
|
3294
3346
|
};
|
|
3295
3347
|
return _this4;
|
|
3296
3348
|
}
|
|
3297
|
-
return _createClass(
|
|
3298
|
-
}(
|
|
3299
|
-
var
|
|
3300
|
-
function
|
|
3301
|
-
_classCallCheck(this,
|
|
3349
|
+
return _createClass(lt);
|
|
3350
|
+
}(pe);
|
|
3351
|
+
var dt = /*#__PURE__*/function () {
|
|
3352
|
+
function dt(e, t, r, n) {
|
|
3353
|
+
_classCallCheck(this, dt);
|
|
3302
3354
|
this._publicToken = e, this._subscriptionDataLayer = t, this.baseURL = r, this.additionalTelemetryDataFn = n, this.updateSessionToken = function () {
|
|
3303
3355
|
return null;
|
|
3304
|
-
}, this.eventLogger = new
|
|
3356
|
+
}, this.eventLogger = new ie({
|
|
3305
3357
|
maxBatchSize: 15,
|
|
3306
3358
|
intervalDurationMs: 800,
|
|
3307
3359
|
logEventURL: this.buildSDKUrl("/events")
|
|
3308
3360
|
});
|
|
3309
3361
|
}
|
|
3310
|
-
_createClass(
|
|
3362
|
+
_createClass(dt, [{
|
|
3311
3363
|
key: "logEvent",
|
|
3312
3364
|
value: function logEvent(_ref) {
|
|
3313
3365
|
var e = _ref.name,
|
|
@@ -3338,7 +3390,7 @@ var lt = /*#__PURE__*/function () {
|
|
|
3338
3390
|
},
|
|
3339
3391
|
sdk: {
|
|
3340
3392
|
identifier: "Stytch.js Javascript SDK",
|
|
3341
|
-
version: "2.0.
|
|
3393
|
+
version: "2.0.5"
|
|
3342
3394
|
}
|
|
3343
3395
|
});
|
|
3344
3396
|
}
|
|
@@ -3349,13 +3401,13 @@ var lt = /*#__PURE__*/function () {
|
|
|
3349
3401
|
t = _ref2.body,
|
|
3350
3402
|
r = _ref2.errorMessage,
|
|
3351
3403
|
n = _ref2.method;
|
|
3352
|
-
return
|
|
3404
|
+
return Ge(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
3353
3405
|
var i, s, o, a;
|
|
3354
3406
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
3355
3407
|
while (1) switch (_context4.prev = _context4.next) {
|
|
3356
3408
|
case 0:
|
|
3357
3409
|
i = this._subscriptionDataLayer.readSessionCookie().session_token, s = "Basic " + window.btoa(this._publicToken + ":" + (i || this._publicToken)), o = window.btoa(JSON.stringify(this.createTelemetryBlob())), a = window.location.origin;
|
|
3358
|
-
return _context4.abrupt("return",
|
|
3410
|
+
return _context4.abrupt("return", ue({
|
|
3359
3411
|
basicAuthHeader: s,
|
|
3360
3412
|
body: t,
|
|
3361
3413
|
errorMessage: r,
|
|
@@ -3379,7 +3431,7 @@ var lt = /*#__PURE__*/function () {
|
|
|
3379
3431
|
r = _ref3.errorMessage,
|
|
3380
3432
|
n = _ref3.method,
|
|
3381
3433
|
i = _ref3.retryCallback;
|
|
3382
|
-
return
|
|
3434
|
+
return Ge(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
3383
3435
|
var o, a, c, u;
|
|
3384
3436
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
3385
3437
|
while (1) switch (_context5.prev = _context5.next) {
|
|
@@ -3407,18 +3459,18 @@ var lt = /*#__PURE__*/function () {
|
|
|
3407
3459
|
xSDKClientHeader: o,
|
|
3408
3460
|
xSDKParentHostHeader: a,
|
|
3409
3461
|
body: c
|
|
3410
|
-
}, e.prev = 1, e.next = 4,
|
|
3462
|
+
}, e.prev = 1, e.next = 4, ue(l);
|
|
3411
3463
|
case 4:
|
|
3412
3464
|
case 15:
|
|
3413
3465
|
return e.abrupt("return", e.sent);
|
|
3414
3466
|
case 7:
|
|
3415
|
-
if (e.prev = 7, e.t0 = e["catch"](1), !(e.t0 instanceof
|
|
3467
|
+
if (e.prev = 7, e.t0 = e["catch"](1), !(e.t0 instanceof ce)) {
|
|
3416
3468
|
e.next = 16;
|
|
3417
3469
|
break;
|
|
3418
3470
|
}
|
|
3419
3471
|
return e.next = 12, u(e.t0, l);
|
|
3420
3472
|
case 12:
|
|
3421
|
-
return l = e.sent, e.next = 15,
|
|
3473
|
+
return l = e.sent, e.next = 15, ue(l);
|
|
3422
3474
|
case 16:
|
|
3423
3475
|
throw e.t0;
|
|
3424
3476
|
case 17:
|
|
@@ -3450,14 +3502,14 @@ var lt = /*#__PURE__*/function () {
|
|
|
3450
3502
|
return "".concat(this.baseURL, "/sdk/v1").concat(e);
|
|
3451
3503
|
}
|
|
3452
3504
|
}]);
|
|
3453
|
-
return
|
|
3505
|
+
return dt;
|
|
3454
3506
|
}();
|
|
3455
|
-
var
|
|
3456
|
-
function
|
|
3457
|
-
_classCallCheck(this,
|
|
3507
|
+
var ht = /*#__PURE__*/function () {
|
|
3508
|
+
function ht(e, t, r) {
|
|
3509
|
+
_classCallCheck(this, ht);
|
|
3458
3510
|
this._googleClient = e, this._publicToken = t, this._clientId = r;
|
|
3459
3511
|
}
|
|
3460
|
-
_createClass(
|
|
3512
|
+
_createClass(ht, [{
|
|
3461
3513
|
key: "cancel",
|
|
3462
3514
|
value: function cancel() {
|
|
3463
3515
|
this._googleClient.cancel();
|
|
@@ -3468,7 +3520,7 @@ var dt = /*#__PURE__*/function () {
|
|
|
3468
3520
|
var e = _ref4.callback,
|
|
3469
3521
|
t = _ref4.onOneTapCancelled,
|
|
3470
3522
|
r = _ref4.style;
|
|
3471
|
-
return
|
|
3523
|
+
return Ge(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
3472
3524
|
var _this5 = this;
|
|
3473
3525
|
var n;
|
|
3474
3526
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
@@ -3509,18 +3561,18 @@ var dt = /*#__PURE__*/function () {
|
|
|
3509
3561
|
});
|
|
3510
3562
|
}
|
|
3511
3563
|
}]);
|
|
3512
|
-
return
|
|
3564
|
+
return ht;
|
|
3513
3565
|
}();
|
|
3514
|
-
var
|
|
3515
|
-
function
|
|
3566
|
+
var pt = /*#__PURE__*/function () {
|
|
3567
|
+
function pt(e, t) {
|
|
3516
3568
|
var _this6 = this;
|
|
3517
|
-
_classCallCheck(this,
|
|
3569
|
+
_classCallCheck(this, pt);
|
|
3518
3570
|
this._publicToken = e, this.clientsideServices = t, this.createOnSuccessHandler = function (_ref5) {
|
|
3519
3571
|
var e = _ref5.loginRedirectUrl,
|
|
3520
3572
|
t = _ref5.signupRedirectUrl,
|
|
3521
3573
|
r = _ref5.onSuccess;
|
|
3522
3574
|
return function (n) {
|
|
3523
|
-
return
|
|
3575
|
+
return Ge(_this6, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
3524
3576
|
var i, _yield$this$submitGoo, s;
|
|
3525
3577
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
3526
3578
|
while (1) switch (_context7.prev = _context7.next) {
|
|
@@ -3547,10 +3599,10 @@ var ht = /*#__PURE__*/function () {
|
|
|
3547
3599
|
window.location.href = e;
|
|
3548
3600
|
};
|
|
3549
3601
|
}
|
|
3550
|
-
_createClass(
|
|
3602
|
+
_createClass(pt, [{
|
|
3551
3603
|
key: "createOneTapClient",
|
|
3552
3604
|
value: function createOneTapClient() {
|
|
3553
|
-
return
|
|
3605
|
+
return Ge(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
3554
3606
|
var e, _yield$this$fetchGoog;
|
|
3555
3607
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
3556
3608
|
while (1) switch (_context8.prev = _context8.next) {
|
|
@@ -3581,7 +3633,7 @@ var ht = /*#__PURE__*/function () {
|
|
|
3581
3633
|
});
|
|
3582
3634
|
case 12:
|
|
3583
3635
|
_context8.t1 = !0;
|
|
3584
|
-
_context8.t2 =
|
|
3636
|
+
_context8.t2 = ht;
|
|
3585
3637
|
_context8.next = 16;
|
|
3586
3638
|
return H(g, function () {
|
|
3587
3639
|
return window.google.accounts.id;
|
|
@@ -3615,7 +3667,7 @@ var ht = /*#__PURE__*/function () {
|
|
|
3615
3667
|
var e = _ref6.credential,
|
|
3616
3668
|
t = _ref6.loginRedirectUrl,
|
|
3617
3669
|
r = _ref6.signupRedirectUrl;
|
|
3618
|
-
return
|
|
3670
|
+
return Ge(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
3619
3671
|
var _yield$this$fetchGoog2, n;
|
|
3620
3672
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
3621
3673
|
while (1) switch (_context9.prev = _context9.next) {
|
|
@@ -3652,21 +3704,21 @@ var ht = /*#__PURE__*/function () {
|
|
|
3652
3704
|
}, {
|
|
3653
3705
|
key: "WillGoogleOneTapShowEmbedded",
|
|
3654
3706
|
value: function WillGoogleOneTapShowEmbedded() {
|
|
3655
|
-
return !
|
|
3707
|
+
return !pt.WillGoogleOneTapShowBannerForUA(navigator.userAgent);
|
|
3656
3708
|
}
|
|
3657
3709
|
}]);
|
|
3658
|
-
return
|
|
3710
|
+
return pt;
|
|
3659
3711
|
}();
|
|
3660
|
-
function
|
|
3712
|
+
function ft(e) {
|
|
3661
3713
|
var t = e.toString(16);
|
|
3662
3714
|
return 1 === t.length && (t = "0" + t), t;
|
|
3663
3715
|
}
|
|
3664
|
-
var
|
|
3665
|
-
function
|
|
3666
|
-
_classCallCheck(this,
|
|
3716
|
+
var _t = /*#__PURE__*/function () {
|
|
3717
|
+
function _t(e, t) {
|
|
3718
|
+
_classCallCheck(this, _t);
|
|
3667
3719
|
this._dataLayer = e, this.namespace = t;
|
|
3668
3720
|
}
|
|
3669
|
-
_createClass(
|
|
3721
|
+
_createClass(_t, [{
|
|
3670
3722
|
key: "key",
|
|
3671
3723
|
value: function key() {
|
|
3672
3724
|
return "PKCE_VERIFIER:" + this.namespace;
|
|
@@ -3674,13 +3726,13 @@ var ft = /*#__PURE__*/function () {
|
|
|
3674
3726
|
}, {
|
|
3675
3727
|
key: "startPKCETransaction",
|
|
3676
3728
|
value: function startPKCETransaction() {
|
|
3677
|
-
return
|
|
3729
|
+
return Ge(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
3678
3730
|
var e;
|
|
3679
3731
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
3680
3732
|
while (1) switch (_context10.prev = _context10.next) {
|
|
3681
3733
|
case 0:
|
|
3682
3734
|
_context10.next = 2;
|
|
3683
|
-
return
|
|
3735
|
+
return _t.createProofkeyPair();
|
|
3684
3736
|
case 2:
|
|
3685
3737
|
e = _context10.sent;
|
|
3686
3738
|
return _context10.abrupt("return", (this._dataLayer.setItem(this.key(), JSON.stringify(e)), e));
|
|
@@ -3698,7 +3750,7 @@ var ft = /*#__PURE__*/function () {
|
|
|
3698
3750
|
if (null !== e) try {
|
|
3699
3751
|
return JSON.parse(e);
|
|
3700
3752
|
} catch (e) {
|
|
3701
|
-
return void
|
|
3753
|
+
return void $("Found malformed Proof Key pair in localstorage.");
|
|
3702
3754
|
}
|
|
3703
3755
|
}
|
|
3704
3756
|
}, {
|
|
@@ -3709,7 +3761,7 @@ var ft = /*#__PURE__*/function () {
|
|
|
3709
3761
|
}], [{
|
|
3710
3762
|
key: "createProofkeyPair",
|
|
3711
3763
|
value: function createProofkeyPair() {
|
|
3712
|
-
return
|
|
3764
|
+
return Ge(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
3713
3765
|
var _String$fromCharCode;
|
|
3714
3766
|
var e, t, r, n;
|
|
3715
3767
|
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
@@ -3717,7 +3769,7 @@ var ft = /*#__PURE__*/function () {
|
|
|
3717
3769
|
case 0:
|
|
3718
3770
|
e = new Uint32Array(16);
|
|
3719
3771
|
window.crypto.getRandomValues(e);
|
|
3720
|
-
t = Array.from(e).map(
|
|
3772
|
+
t = Array.from(e).map(ft).join("");
|
|
3721
3773
|
_context11.next = 5;
|
|
3722
3774
|
return window.crypto.subtle.digest("SHA-256", new TextEncoder().encode(t));
|
|
3723
3775
|
case 5:
|
|
@@ -3734,14 +3786,14 @@ var ft = /*#__PURE__*/function () {
|
|
|
3734
3786
|
}));
|
|
3735
3787
|
}
|
|
3736
3788
|
}]);
|
|
3737
|
-
return
|
|
3789
|
+
return _t;
|
|
3738
3790
|
}();
|
|
3739
|
-
var
|
|
3740
|
-
function
|
|
3741
|
-
_classCallCheck(this,
|
|
3791
|
+
var vt = /*#__PURE__*/function () {
|
|
3792
|
+
function vt(e) {
|
|
3793
|
+
_classCallCheck(this, vt);
|
|
3742
3794
|
this._networkClient = e;
|
|
3743
3795
|
}
|
|
3744
|
-
_createClass(
|
|
3796
|
+
_createClass(vt, [{
|
|
3745
3797
|
key: "searchUser",
|
|
3746
3798
|
value: function searchUser(e) {
|
|
3747
3799
|
return this._networkClient.fetchSDK({
|
|
@@ -3779,9 +3831,9 @@ var _t = /*#__PURE__*/function () {
|
|
|
3779
3831
|
});
|
|
3780
3832
|
}
|
|
3781
3833
|
}]);
|
|
3782
|
-
return
|
|
3834
|
+
return vt;
|
|
3783
3835
|
}();
|
|
3784
|
-
var
|
|
3836
|
+
var mt = function mt(e) {
|
|
3785
3837
|
return (document.cookie ? document.cookie.split("; ") : []).filter(function (t) {
|
|
3786
3838
|
var _t$split = t.split("="),
|
|
3787
3839
|
_t$split2 = _slicedToArray(_t$split, 1),
|
|
@@ -3790,17 +3842,17 @@ var vt = function vt(e) {
|
|
|
3790
3842
|
}).length > 1;
|
|
3791
3843
|
};
|
|
3792
3844
|
/*! js-cookie v3.0.1 | MIT */
|
|
3793
|
-
function
|
|
3845
|
+
function yt(e) {
|
|
3794
3846
|
for (var t = 1; t < arguments.length; t++) {
|
|
3795
3847
|
var r = arguments[t];
|
|
3796
3848
|
for (var n in r) e[n] = r[n];
|
|
3797
3849
|
}
|
|
3798
3850
|
return e;
|
|
3799
3851
|
}
|
|
3800
|
-
var
|
|
3852
|
+
var gt = function e(t, r) {
|
|
3801
3853
|
function n(e, n, i) {
|
|
3802
3854
|
if ("undefined" != typeof document) {
|
|
3803
|
-
"number" == typeof (i =
|
|
3855
|
+
"number" == typeof (i = yt({}, r, i)).expires && (i.expires = new Date(Date.now() + 864e5 * i.expires)), i.expires && (i.expires = i.expires.toUTCString()), e = encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
|
|
3804
3856
|
var s = "";
|
|
3805
3857
|
for (var o in i) i[o] && (s += "; " + o, !0 !== i[o] && (s += "=" + i[o].split(";")[0]));
|
|
3806
3858
|
return document.cookie = e + "=" + t.write(n, e) + s;
|
|
@@ -3822,15 +3874,15 @@ var yt = function e(t, r) {
|
|
|
3822
3874
|
}
|
|
3823
3875
|
},
|
|
3824
3876
|
remove: function remove(e, t) {
|
|
3825
|
-
n(e, "",
|
|
3877
|
+
n(e, "", yt({}, t, {
|
|
3826
3878
|
expires: -1
|
|
3827
3879
|
}));
|
|
3828
3880
|
},
|
|
3829
3881
|
withAttributes: function withAttributes(t) {
|
|
3830
|
-
return e(this.converter,
|
|
3882
|
+
return e(this.converter, yt({}, this.attributes, t));
|
|
3831
3883
|
},
|
|
3832
3884
|
withConverter: function withConverter(t) {
|
|
3833
|
-
return e(
|
|
3885
|
+
return e(yt({}, this.converter, t), this.attributes);
|
|
3834
3886
|
}
|
|
3835
3887
|
}, {
|
|
3836
3888
|
attributes: {
|
|
@@ -3850,26 +3902,26 @@ var yt = function e(t, r) {
|
|
|
3850
3902
|
}, {
|
|
3851
3903
|
path: "/"
|
|
3852
3904
|
});
|
|
3853
|
-
var
|
|
3905
|
+
var bt = function bt(e) {
|
|
3854
3906
|
var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
|
|
3855
3907
|
return "stytch_sdk_state_".concat(e).concat(t ? "::".concat(t) : "");
|
|
3856
3908
|
};
|
|
3857
|
-
var
|
|
3858
|
-
function
|
|
3909
|
+
var kt = /*#__PURE__*/function () {
|
|
3910
|
+
function kt(e, t) {
|
|
3859
3911
|
var _this7 = this;
|
|
3860
|
-
_classCallCheck(this,
|
|
3912
|
+
_classCallCheck(this, kt);
|
|
3861
3913
|
this.browserSessionStorage = {
|
|
3862
3914
|
getItem: function getItem(e) {
|
|
3863
|
-
return sessionStorage.getItem(
|
|
3915
|
+
return sessionStorage.getItem(bt(_this7.publicToken, e));
|
|
3864
3916
|
},
|
|
3865
3917
|
setItem: function setItem(e, t) {
|
|
3866
|
-
return sessionStorage.setItem(
|
|
3918
|
+
return sessionStorage.setItem(bt(_this7.publicToken, e), t);
|
|
3867
3919
|
},
|
|
3868
3920
|
removeItem: function removeItem(e) {
|
|
3869
|
-
return sessionStorage.removeItem(
|
|
3921
|
+
return sessionStorage.removeItem(bt(_this7.publicToken, e));
|
|
3870
3922
|
}
|
|
3871
|
-
}, this.publicToken = e, this.state = null, this.subscriptions = {}, (null == t ? void 0 : t.cookieOptions) ? (
|
|
3872
|
-
var r = localStorage.getItem(
|
|
3923
|
+
}, this.publicToken = e, this.state = null, this.subscriptions = {}, (null == t ? void 0 : t.cookieOptions) ? (Q("SubscriptionDataLayer").isOptionalString("cookieOptions.opaqueTokenCookieName", t.cookieOptions.opaqueTokenCookieName).isOptionalString("cookieOptions.jwtCookieName", t.cookieOptions.jwtCookieName).isOptionalString("cookieOptions.istCookieName", t.cookieOptions.istCookieName).isOptionalString("cookieOptions.path", t.cookieOptions.path).isOptionalString("cookieOptions.domain", t.cookieOptions.domain), this._jwtCookieName = t.cookieOptions.jwtCookieName || null, this._opaqueTokenCookieName = t.cookieOptions.opaqueTokenCookieName || null, this._cookiePath = t.cookieOptions.path || null, this._domain = t.cookieOptions.domain || null, this._cookieAvailableToSubdomains = t.cookieOptions.availableToSubdomains || !1, this._istCookieName = t.cookieOptions.istCookieName || null) : (this._opaqueTokenCookieName = null, this._jwtCookieName = null, this._cookiePath = null, this._domain = null, this._cookieAvailableToSubdomains = !1, this._istCookieName = null);
|
|
3924
|
+
var r = localStorage.getItem(bt(this.publicToken));
|
|
3873
3925
|
if (!r) return this.removeSessionCookie(), void this.removeISTCookie();
|
|
3874
3926
|
var n;
|
|
3875
3927
|
try {
|
|
@@ -3879,7 +3931,7 @@ var bt = /*#__PURE__*/function () {
|
|
|
3879
3931
|
}
|
|
3880
3932
|
this.state = n;
|
|
3881
3933
|
}
|
|
3882
|
-
_createClass(
|
|
3934
|
+
_createClass(kt, [{
|
|
3883
3935
|
key: "opaqueTokenCookieName",
|
|
3884
3936
|
get: function get() {
|
|
3885
3937
|
var e;
|
|
@@ -3901,14 +3953,14 @@ var bt = /*#__PURE__*/function () {
|
|
|
3901
3953
|
key: "readSessionCookie",
|
|
3902
3954
|
value: function readSessionCookie() {
|
|
3903
3955
|
return {
|
|
3904
|
-
session_token:
|
|
3905
|
-
session_jwt:
|
|
3956
|
+
session_token: gt.get(this.opaqueTokenCookieName),
|
|
3957
|
+
session_jwt: gt.get(this.jwtCookieName)
|
|
3906
3958
|
};
|
|
3907
3959
|
}
|
|
3908
3960
|
}, {
|
|
3909
3961
|
key: "readIntermediateSessionTokenCookie",
|
|
3910
3962
|
value: function readIntermediateSessionTokenCookie() {
|
|
3911
|
-
return
|
|
3963
|
+
return gt.get(this.istCookieName);
|
|
3912
3964
|
}
|
|
3913
3965
|
}, {
|
|
3914
3966
|
key: "writeSessionCookie",
|
|
@@ -3917,29 +3969,32 @@ var bt = /*#__PURE__*/function () {
|
|
|
3917
3969
|
var s = e.state,
|
|
3918
3970
|
o = e.session_token,
|
|
3919
3971
|
a = e.session_jwt,
|
|
3920
|
-
c =
|
|
3972
|
+
c = kt.generateCookieOpts({
|
|
3921
3973
|
expiresAt: null !== (r = null === (t = null == s ? void 0 : s.session) || void 0 === t ? void 0 : t.expires_at) && void 0 !== r ? r : "",
|
|
3922
3974
|
availableToSubdomains: this._cookieAvailableToSubdomains,
|
|
3923
|
-
path: this._cookiePath
|
|
3975
|
+
path: this._cookiePath,
|
|
3976
|
+
domain: this._domain
|
|
3924
3977
|
});
|
|
3925
|
-
|
|
3926
|
-
var u =
|
|
3978
|
+
gt.set(this.opaqueTokenCookieName, o, c), gt.set(this.jwtCookieName, a, c);
|
|
3979
|
+
var u = kt.generateCookieOpts({
|
|
3927
3980
|
expiresAt: null !== (i = null === (n = null == s ? void 0 : s.session) || void 0 === n ? void 0 : n.expires_at) && void 0 !== i ? i : "",
|
|
3928
3981
|
availableToSubdomains: !this._cookieAvailableToSubdomains,
|
|
3929
|
-
path: this._cookiePath
|
|
3982
|
+
path: this._cookiePath,
|
|
3983
|
+
domain: this._domain
|
|
3930
3984
|
});
|
|
3931
|
-
|
|
3985
|
+
mt(this.jwtCookieName) && gt.remove(this.jwtCookieName, u), mt(this.opaqueTokenCookieName) && gt.remove(this.opaqueTokenCookieName, u), mt(this.jwtCookieName) && $("Could not remove extraneous JWT cookie. This might happen if the cookie has been set using multiple `path` settings, and may produce unwanted behavior."), mt(this.opaqueTokenCookieName) && $("Could not remove extraneous opaque token cookie.");
|
|
3932
3986
|
}
|
|
3933
3987
|
}, {
|
|
3934
3988
|
key: "writeIntermediateSessionTokenCookie",
|
|
3935
3989
|
value: function writeIntermediateSessionTokenCookie(e) {
|
|
3936
3990
|
var t = new Date(Date.now() + 6e5),
|
|
3937
|
-
r =
|
|
3991
|
+
r = kt.generateCookieOpts({
|
|
3938
3992
|
expiresAt: t.toString(),
|
|
3939
3993
|
availableToSubdomains: this._cookieAvailableToSubdomains,
|
|
3940
|
-
path: this._cookiePath
|
|
3994
|
+
path: this._cookiePath,
|
|
3995
|
+
domain: this._domain
|
|
3941
3996
|
});
|
|
3942
|
-
|
|
3997
|
+
gt.set(this.istCookieName, e, r);
|
|
3943
3998
|
}
|
|
3944
3999
|
}, {
|
|
3945
4000
|
key: "removeSessionCookie",
|
|
@@ -3957,13 +4012,16 @@ var bt = /*#__PURE__*/function () {
|
|
|
3957
4012
|
var _this8 = this;
|
|
3958
4013
|
[!0, !1].forEach(function (t) {
|
|
3959
4014
|
[_this8._cookiePath, null].forEach(function (r) {
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
4015
|
+
[_this8._domain, null].forEach(function (n) {
|
|
4016
|
+
var i = kt.generateCookieOpts({
|
|
4017
|
+
expiresAt: new Date(0).toString(),
|
|
4018
|
+
availableToSubdomains: t,
|
|
4019
|
+
path: r,
|
|
4020
|
+
domain: n
|
|
4021
|
+
});
|
|
4022
|
+
e.forEach(function (e) {
|
|
4023
|
+
gt.remove(e, i);
|
|
4024
|
+
});
|
|
3967
4025
|
});
|
|
3968
4026
|
});
|
|
3969
4027
|
});
|
|
@@ -3971,61 +4029,62 @@ var bt = /*#__PURE__*/function () {
|
|
|
3971
4029
|
}, {
|
|
3972
4030
|
key: "syncToLocalStorage",
|
|
3973
4031
|
value: function syncToLocalStorage() {
|
|
3974
|
-
localStorage.setItem(
|
|
4032
|
+
localStorage.setItem(bt(this.publicToken), JSON.stringify(this.state));
|
|
3975
4033
|
}
|
|
3976
4034
|
}, {
|
|
3977
4035
|
key: "getItem",
|
|
3978
4036
|
value: function getItem(e) {
|
|
3979
|
-
return localStorage.getItem(
|
|
4037
|
+
return localStorage.getItem(bt(this.publicToken, e));
|
|
3980
4038
|
}
|
|
3981
4039
|
}, {
|
|
3982
4040
|
key: "setItem",
|
|
3983
4041
|
value: function setItem(e, t) {
|
|
3984
|
-
return localStorage.setItem(
|
|
4042
|
+
return localStorage.setItem(bt(this.publicToken, e), t);
|
|
3985
4043
|
}
|
|
3986
4044
|
}, {
|
|
3987
4045
|
key: "removeItem",
|
|
3988
4046
|
value: function removeItem(e) {
|
|
3989
|
-
return localStorage.removeItem(
|
|
4047
|
+
return localStorage.removeItem(bt(this.publicToken, e));
|
|
3990
4048
|
}
|
|
3991
4049
|
}], [{
|
|
3992
4050
|
key: "generateCookieOpts",
|
|
3993
4051
|
value: function generateCookieOpts(_ref7) {
|
|
3994
4052
|
var e = _ref7.path,
|
|
3995
|
-
t = _ref7.
|
|
3996
|
-
r = _ref7.
|
|
3997
|
-
|
|
3998
|
-
|
|
4053
|
+
t = _ref7.domain,
|
|
4054
|
+
r = _ref7.availableToSubdomains,
|
|
4055
|
+
n = _ref7.expiresAt;
|
|
4056
|
+
var i = {
|
|
4057
|
+
expires: new Date(n),
|
|
3999
4058
|
sameSite: "lax"
|
|
4000
4059
|
};
|
|
4001
|
-
return e && (
|
|
4060
|
+
return e && (i.path = e), Boolean("localhost" === window.location.hostname || "[::1]" === window.location.hostname || window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/)) ? i.secure = !1 : (r && (i.domain = t || window.location.host), i.secure = !0), i;
|
|
4002
4061
|
}
|
|
4003
4062
|
}]);
|
|
4004
|
-
return
|
|
4063
|
+
return kt;
|
|
4005
4064
|
}();
|
|
4006
|
-
var
|
|
4007
|
-
_inherits(
|
|
4008
|
-
var _super2 = _createSuper(
|
|
4009
|
-
function
|
|
4010
|
-
_classCallCheck(this,
|
|
4065
|
+
var wt = /*#__PURE__*/function (_kt) {
|
|
4066
|
+
_inherits(wt, _kt);
|
|
4067
|
+
var _super2 = _createSuper(wt);
|
|
4068
|
+
function wt() {
|
|
4069
|
+
_classCallCheck(this, wt);
|
|
4011
4070
|
return _super2.apply(this, arguments);
|
|
4012
4071
|
}
|
|
4013
|
-
return _createClass(
|
|
4014
|
-
}(
|
|
4015
|
-
var
|
|
4016
|
-
|
|
4072
|
+
return _createClass(wt);
|
|
4073
|
+
}(kt);
|
|
4074
|
+
var St = Symbol["for"]("__stytch_DataLayer"),
|
|
4075
|
+
Ot = function Ot(e, t) {
|
|
4017
4076
|
var r = function () {
|
|
4018
4077
|
var e = window;
|
|
4019
|
-
return e[
|
|
4078
|
+
return e[St] || (e[St] = {}), e[St];
|
|
4020
4079
|
}();
|
|
4021
|
-
return r[e] || (r[e] = new
|
|
4080
|
+
return r[e] || (r[e] = new wt(e, t)), r[e];
|
|
4022
4081
|
},
|
|
4023
4082
|
Tt = function Tt(e, t) {
|
|
4024
4083
|
Object.values(e).forEach(function (e) {
|
|
4025
4084
|
return e(t);
|
|
4026
4085
|
});
|
|
4027
4086
|
},
|
|
4028
|
-
|
|
4087
|
+
xt = function () {
|
|
4029
4088
|
var e = (arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}).KEYS_TO_EXCLUDE,
|
|
4030
4089
|
r = void 0 === e ? [] : e;
|
|
4031
4090
|
return function e(n, s) {
|
|
@@ -4044,13 +4103,13 @@ var wt = Symbol["for"]("__stytch_DataLayer"),
|
|
|
4044
4103
|
}({
|
|
4045
4104
|
KEYS_TO_EXCLUDE: ["last_accessed_at"]
|
|
4046
4105
|
});
|
|
4047
|
-
var
|
|
4048
|
-
function
|
|
4106
|
+
var Ct = /*#__PURE__*/function () {
|
|
4107
|
+
function Ct(e, t) {
|
|
4049
4108
|
var _this9 = this;
|
|
4050
|
-
_classCallCheck(this,
|
|
4109
|
+
_classCallCheck(this, Ct);
|
|
4051
4110
|
var r;
|
|
4052
4111
|
this._publicToken = e, this._datalayer = t, this._listen = function (e) {
|
|
4053
|
-
if (e.key !==
|
|
4112
|
+
if (e.key !== bt(_this9._publicToken)) return;
|
|
4054
4113
|
if (null === e.newValue || "null" === e.newValue) return void _this9.destroyState();
|
|
4055
4114
|
var t = JSON.parse(e.newValue);
|
|
4056
4115
|
_this9.updateState(t);
|
|
@@ -4061,7 +4120,7 @@ var xt = /*#__PURE__*/function () {
|
|
|
4061
4120
|
i = _this$_datalayer$read.session_token;
|
|
4062
4121
|
i || this.destroyState();
|
|
4063
4122
|
}
|
|
4064
|
-
_createClass(
|
|
4123
|
+
_createClass(Ct, [{
|
|
4065
4124
|
key: "getTokens",
|
|
4066
4125
|
value: function getTokens() {
|
|
4067
4126
|
var _this$_datalayer$read2 = this._datalayer.readSessionCookie(),
|
|
@@ -4092,7 +4151,7 @@ var xt = /*#__PURE__*/function () {
|
|
|
4092
4151
|
value: function _updateStateAndTokensInternal(e) {
|
|
4093
4152
|
var t = this._datalayer.state,
|
|
4094
4153
|
r = null === e.state ? null : Object.assign(Object.assign({}, this._datalayer.state), e.state);
|
|
4095
|
-
this._datalayer.state = r,
|
|
4154
|
+
this._datalayer.state = r, xt(t, r) || Tt(this._datalayer.subscriptions, r);
|
|
4096
4155
|
}
|
|
4097
4156
|
}, {
|
|
4098
4157
|
key: "updateStateAndTokens",
|
|
@@ -4104,7 +4163,7 @@ var xt = /*#__PURE__*/function () {
|
|
|
4104
4163
|
value: function updateState(e) {
|
|
4105
4164
|
var t = this._datalayer.state,
|
|
4106
4165
|
r = null === e ? null : Object.assign(Object.assign({}, this._datalayer.state), e);
|
|
4107
|
-
this._datalayer.state = r,
|
|
4166
|
+
this._datalayer.state = r, xt(t, r) || (Tt(this._datalayer.subscriptions, r), this._datalayer.syncToLocalStorage());
|
|
4108
4167
|
}
|
|
4109
4168
|
}, {
|
|
4110
4169
|
key: "updateTokens",
|
|
@@ -4144,14 +4203,14 @@ var xt = /*#__PURE__*/function () {
|
|
|
4144
4203
|
return null;
|
|
4145
4204
|
}
|
|
4146
4205
|
}]);
|
|
4147
|
-
return
|
|
4206
|
+
return Ct;
|
|
4148
4207
|
}();
|
|
4149
|
-
var
|
|
4150
|
-
_inherits(
|
|
4151
|
-
var _super3 = _createSuper(
|
|
4152
|
-
function
|
|
4208
|
+
var Et = /*#__PURE__*/function (_Ct) {
|
|
4209
|
+
_inherits(Et, _Ct);
|
|
4210
|
+
var _super3 = _createSuper(Et);
|
|
4211
|
+
function Et() {
|
|
4153
4212
|
var _this10;
|
|
4154
|
-
_classCallCheck(this,
|
|
4213
|
+
_classCallCheck(this, Et);
|
|
4155
4214
|
_this10 = _super3.apply(this, arguments), _this10.updateUser = function (e) {
|
|
4156
4215
|
return _this10.updateState({
|
|
4157
4216
|
user: e
|
|
@@ -4165,10 +4224,10 @@ var Ct = /*#__PURE__*/function (_xt) {
|
|
|
4165
4224
|
};
|
|
4166
4225
|
return _this10;
|
|
4167
4226
|
}
|
|
4168
|
-
return _createClass(
|
|
4169
|
-
}(
|
|
4170
|
-
var
|
|
4171
|
-
exports.SDKAPIUnreachableError =
|
|
4227
|
+
return _createClass(Et);
|
|
4228
|
+
}(Ct);
|
|
4229
|
+
var At = Symbol["for"]("stytch__internal_b2c");
|
|
4230
|
+
exports.SDKAPIUnreachableError = st, exports.StytchHeadlessClient = /*#__PURE__*/function () {
|
|
4172
4231
|
function _class(e, t) {
|
|
4173
4232
|
var _this11 = this;
|
|
4174
4233
|
_classCallCheck(this, _class);
|
|
@@ -4176,7 +4235,7 @@ exports.SDKAPIUnreachableError = it, exports.StytchHeadlessClient = /*#__PURE__*
|
|
|
4176
4235
|
!function (e) {
|
|
4177
4236
|
var t = "StytchUIClient" === e ? "import { createStytchUIClient } from '@stytch/nextjs/ui';\n \nconst stytch = createStytchUIClient('public-token-...');\n" : "import { createStytchHeadlessClient } from '@stytch/nextjs/ui';\n \nconst stytch = createStytchHeadlessClient('public-token-...');\n";
|
|
4178
4237
|
if ("undefined" == typeof window) throw new Error("The ".concat(e, " is not compatible with server-side environments.\nIf using nextjs, use the create").concat(e, " method instead.\n```\n").concat(t, "\n```\n"));
|
|
4179
|
-
}("StytchHeadlessClient"), "string" != typeof (r = e) ?
|
|
4238
|
+
}("StytchHeadlessClient"), "string" != typeof (r = e) ? $("Public token is malformed. Expected a string, got ".concat(i(r), ".").concat(Z)) : "" === r ? $('Public token is malformed. Expected "public-token-...", got an empty string.'.concat(Z)) : r.startsWith("public-token-") || $('Public token is malformed. Expected "public-token-...", got '.concat(r, ".").concat(Z));
|
|
4180
4239
|
var n = t,
|
|
4181
4240
|
s = {
|
|
4182
4241
|
cookieOptions: null == (o = n) ? void 0 : o.cookieOptions,
|
|
@@ -4189,42 +4248,43 @@ exports.SDKAPIUnreachableError = it, exports.StytchHeadlessClient = /*#__PURE__*
|
|
|
4189
4248
|
}
|
|
4190
4249
|
};
|
|
4191
4250
|
var o, a, c, u, l, d, h, p, f, _, v;
|
|
4192
|
-
this._dataLayer =
|
|
4193
|
-
|
|
4251
|
+
this._dataLayer = Ot(e, n), this._subscriptionService = new Et(e, this._dataLayer);
|
|
4252
|
+
var m = new _t(this._dataLayer, "passwords");
|
|
4253
|
+
this._networkClient = new dt(e, this._dataLayer, s.endpoints.sdkBackendURL, function () {
|
|
4194
4254
|
var e, t, r, n;
|
|
4195
4255
|
return {
|
|
4196
4256
|
stytch_user_id: null === (t = null === (e = _this11._dataLayer.state) || void 0 === e ? void 0 : e.user) || void 0 === t ? void 0 : t.user_id,
|
|
4197
4257
|
stytch_session_id: null === (n = null === (r = _this11._dataLayer.state) || void 0 === r ? void 0 : r.session) || void 0 === n ? void 0 : n.session_id
|
|
4198
4258
|
};
|
|
4199
4259
|
});
|
|
4200
|
-
var
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
var
|
|
4207
|
-
this.user = new
|
|
4260
|
+
var y = new We(e, this._networkClient, this._dataLayer),
|
|
4261
|
+
g = new He(y.getAsync()),
|
|
4262
|
+
b = new re(e, s.endpoints.dfpBackendURL, y.getAsync()),
|
|
4263
|
+
k = new ze(s.endpoints.clientsideServicesIframeURL),
|
|
4264
|
+
w = new pt(e, k),
|
|
4265
|
+
S = new vt(this._networkClient);
|
|
4266
|
+
var O, T;
|
|
4267
|
+
this.user = new oe(this._networkClient, this._subscriptionService), this.session = new ae(this._networkClient, this._subscriptionService), this.magicLinks = new de(this._networkClient, this._subscriptionService, new _t(this._dataLayer, "magic_links"), m, y.getAsync(), g.executeRecaptcha, b), this.otps = new he(this._networkClient, this._subscriptionService, g.executeRecaptcha), this.oauth = new lt(this._networkClient, this._subscriptionService, new _t(this._dataLayer, "oauth"), y.getAsync(), {
|
|
4208
4268
|
publicToken: e,
|
|
4209
4269
|
testAPIURL: s.endpoints.testAPIURL,
|
|
4210
4270
|
liveAPIURL: s.endpoints.liveAPIURL
|
|
4211
|
-
},
|
|
4271
|
+
}, w), this.cryptoWallets = new fe(this._networkClient, this._subscriptionService, g.executeRecaptcha), this.totps = new _e(this._networkClient, this._subscriptionService), this.webauthn = new Me(this._networkClient, this._subscriptionService), this.passwords = new Fe(this._networkClient, this._subscriptionService, m, y.getAsync(), g.executeRecaptcha, b), this._sessionManager = new Ke(this._subscriptionService, this.session), this._dataLayer.readSessionCookie().session_token && this._sessionManager.performBackgroundRefresh(), this._networkClient.logEvent({
|
|
4212
4272
|
name: "sdk_instance_instantiated",
|
|
4213
4273
|
details: {
|
|
4214
4274
|
event_callback_registered: !1,
|
|
4215
4275
|
error_callback_registered: !1,
|
|
4216
4276
|
success_callback_registered: !1
|
|
4217
4277
|
}
|
|
4218
|
-
}),
|
|
4219
|
-
bootstrap:
|
|
4220
|
-
clientsideServices:
|
|
4221
|
-
captcha:
|
|
4222
|
-
oneTap:
|
|
4223
|
-
searchManager:
|
|
4278
|
+
}), O = this, T = {
|
|
4279
|
+
bootstrap: y,
|
|
4280
|
+
clientsideServices: k,
|
|
4281
|
+
captcha: g,
|
|
4282
|
+
oneTap: w,
|
|
4283
|
+
searchManager: S,
|
|
4224
4284
|
publicToken: e,
|
|
4225
4285
|
dataLayer: this._dataLayer,
|
|
4226
4286
|
networkClient: this._networkClient
|
|
4227
|
-
}, Object.assign(
|
|
4287
|
+
}, Object.assign(O, _defineProperty({}, At, T));
|
|
4228
4288
|
}
|
|
4229
4289
|
return _createClass(_class);
|
|
4230
|
-
}(), exports.StytchSDKAPIError =
|
|
4290
|
+
}(), exports.StytchSDKAPIError = ct, exports.StytchSDKNativeError = ut, exports.StytchSDKSchemaError = at, exports.StytchSDKUsageError = ot, exports.UNRECOVERABLE_ERROR_TYPES = ["unauthorized_credentials", "user_unauthenticated", "invalid_secret_authentication", "session_not_found"];
|