@stytch/nextjs 2.0.3 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/b2b/index.js CHANGED
@@ -210,61 +210,55 @@ const StytchB2BProvider = ({ stytch, children }) => {
210
210
  React__default['default'].createElement(StytchMemberSessionContext.Provider, { value: finalMemberSession }, children))));
211
211
  };
212
212
 
213
- function t(e) { return t = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (t) { return typeof t; } : function (t) { return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t; }, t(e); }
214
- function e(t) { return function (t) { if (Array.isArray(t))
215
- return r(t); }(t) || function (t) { if ("undefined" != typeof Symbol && null != t[Symbol.iterator] || null != t["@@iterator"])
216
- return Array.from(t); }(t) || function (t, e) { if (!t)
217
- return; if ("string" == typeof t)
218
- return r(t, e); var n = Object.prototype.toString.call(t).slice(8, -1); "Object" === n && t.constructor && (n = t.constructor.name); if ("Map" === n || "Set" === n)
219
- return Array.from(t); if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
220
- return r(t, e); }(t) || function () { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }(); }
221
- function r(t, e) { (null == e || e > t.length) && (e = t.length); for (var r = 0, n = new Array(e); r < e; r++)
222
- n[r] = t[r]; return n; }
223
- function n(t, e) { if ("function" != typeof e && null !== e)
224
- throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && o(t, e); }
225
- function o(t, e) { return o = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, o(t, e); }
226
- function i(e) { var r = function () { if ("undefined" == typeof Reflect || !Reflect.construct)
213
+ function e(t) { return e = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (e) { return typeof e; } : function (e) { return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e; }, e(t); }
214
+ function t(e) { return function (e) { if (Array.isArray(e))
215
+ return f(e); }(e) || function (e) { if ("undefined" != typeof Symbol && null != e[Symbol.iterator] || null != e["@@iterator"])
216
+ return Array.from(e); }(e) || h(e) || function () { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }(); }
217
+ function r(e, t) { if ("function" != typeof t && null !== t)
218
+ throw new TypeError("Super expression must either be null or a function"); e.prototype = Object.create(t && t.prototype, { constructor: { value: e, writable: !0, configurable: !0 } }), Object.defineProperty(e, "prototype", { writable: !1 }), t && n(e, t); }
219
+ function n(e, t) { return n = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (e, t) { return e.__proto__ = t, e; }, n(e, t); }
220
+ function o(t) { var r = function () { if ("undefined" == typeof Reflect || !Reflect.construct)
227
221
  return !1; if (Reflect.construct.sham)
228
222
  return !1; if ("function" == typeof Proxy)
229
223
  return !0; try {
230
224
  return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], (function () { }))), !0;
231
225
  }
232
- catch (t) {
226
+ catch (e) {
233
227
  return !1;
234
- } }(); return function () { var n, o = a(e); if (r) {
235
- var i = a(this).constructor;
236
- n = Reflect.construct(o, arguments, i);
228
+ } }(); return function () { var n, o = i(t); if (r) {
229
+ var a = i(this).constructor;
230
+ n = Reflect.construct(o, arguments, a);
237
231
  }
238
232
  else
239
- n = o.apply(this, arguments); return function (e, r) { if (r && ("object" === t(r) || "function" == typeof r))
233
+ n = o.apply(this, arguments); return function (t, r) { if (r && ("object" === e(r) || "function" == typeof r))
240
234
  return r; if (void 0 !== r)
241
- throw new TypeError("Derived constructors may only return object or undefined"); return function (t) { if (void 0 === t)
242
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return t; }(e); }(this, n); }; }
243
- function a(t) { return a = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, a(t); }
244
- function s() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ s = function () { return e; }; var e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function l(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try {
235
+ throw new TypeError("Derived constructors may only return object or undefined"); return function (e) { if (void 0 === e)
236
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }(t); }(this, n); }; }
237
+ function i(e) { return i = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (e) { return e.__proto__ || Object.getPrototypeOf(e); }, i(e); }
238
+ function a() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ a = function () { return t; }; var t = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (e, t, r) { e[t] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, s = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function l(e, t, r) { return Object.defineProperty(e, t, { value: r, enumerable: !0, configurable: !0, writable: !0 }), e[t]; } try {
245
239
  l({}, "");
246
240
  }
247
- catch (t) {
248
- l = function (t, e, r) { return t[e] = r; };
249
- } function f(t, e, r, n) { var i = e && e.prototype instanceof d ? e : d, a = Object.create(i.prototype), s = new P(n || []); return o(a, "_invoke", { value: S(t, r, s) }), a; } function h(t, e, r) { try {
250
- return { type: "normal", arg: t.call(e, r) };
241
+ catch (e) {
242
+ l = function (e, t, r) { return e[t] = r; };
243
+ } function h(e, t, r, n) { var i = t && t.prototype instanceof p ? t : p, a = Object.create(i.prototype), s = new x(n || []); return o(a, "_invoke", { value: S(e, r, s) }), a; } function f(e, t, r) { try {
244
+ return { type: "normal", arg: e.call(t, r) };
251
245
  }
252
- catch (t) {
253
- return { type: "throw", arg: t };
254
- } } e.wrap = f; var p = {}; function d() { } function v() { } function y() { } var m = {}; l(m, a, (function () { return this; })); var b = Object.getPrototypeOf, g = b && b(b(L([]))); g && g !== r && n.call(g, a) && (m = g); var _ = y.prototype = d.prototype = Object.create(m); function w(t) { ["next", "throw", "return"].forEach((function (e) { l(t, e, (function (t) { return this._invoke(e, t); })); })); } function k(e, r) { function i(o, a, s, c) { var u = h(e[o], e, a); if ("throw" !== u.type) {
255
- var l = u.arg, f = l.value;
256
- return f && "object" == t(f) && n.call(f, "__await") ? r.resolve(f.__await).then((function (t) { i("next", t, s, c); }), (function (t) { i("throw", t, s, c); })) : r.resolve(f).then((function (t) { l.value = t, s(l); }), (function (t) { return i("throw", t, s, c); }));
257
- } c(u.arg); } var a; o(this, "_invoke", { value: function (t, e) { function n() { return new r((function (r, n) { i(t, e, r, n); })); } return a = a ? a.then(n, n) : n(); } }); } function S(t, e, r) { var n = "suspendedStart"; return function (o, i) { if ("executing" === n)
246
+ catch (e) {
247
+ return { type: "throw", arg: e };
248
+ } } t.wrap = h; var d = {}; function p() { } function v() { } function m() { } var y = {}; l(y, s, (function () { return this; })); var _ = Object.getPrototypeOf, b = _ && _(_(C([]))); b && b !== r && n.call(b, s) && (y = b); var g = m.prototype = p.prototype = Object.create(y); function k(e) { ["next", "throw", "return"].forEach((function (t) { l(e, t, (function (e) { return this._invoke(t, e); })); })); } function w(t, r) { function i(o, a, s, c) { var u = f(t[o], t, a); if ("throw" !== u.type) {
249
+ var l = u.arg, h = l.value;
250
+ return h && "object" == e(h) && n.call(h, "__await") ? r.resolve(h.__await).then((function (e) { i("next", e, s, c); }), (function (e) { i("throw", e, s, c); })) : r.resolve(h).then((function (e) { l.value = e, s(l); }), (function (e) { return i("throw", e, s, c); }));
251
+ } c(u.arg); } var a; o(this, "_invoke", { value: function (e, t) { function n() { return new r((function (r, n) { i(e, t, r, n); })); } return a = a ? a.then(n, n) : n(); } }); } function S(e, t, r) { var n = "suspendedStart"; return function (o, i) { if ("executing" === n)
258
252
  throw new Error("Generator is already running"); if ("completed" === n) {
259
253
  if ("throw" === o)
260
254
  throw i;
261
- return x();
255
+ return P();
262
256
  } for (r.method = o, r.arg = i;;) {
263
257
  var a = r.delegate;
264
258
  if (a) {
265
- var s = E(a, r);
259
+ var s = O(a, r);
266
260
  if (s) {
267
- if (s === p)
261
+ if (s === d)
268
262
  continue;
269
263
  return s;
270
264
  }
@@ -279,37 +273,37 @@ catch (t) {
279
273
  else
280
274
  "return" === r.method && r.abrupt("return", r.arg);
281
275
  n = "executing";
282
- var c = h(t, e, r);
276
+ var c = f(e, t, r);
283
277
  if ("normal" === c.type) {
284
- if (n = r.done ? "completed" : "suspendedYield", c.arg === p)
278
+ if (n = r.done ? "completed" : "suspendedYield", c.arg === d)
285
279
  continue;
286
280
  return { value: c.arg, done: r.done };
287
281
  }
288
282
  "throw" === c.type && (n = "completed", r.method = "throw", r.arg = c.arg);
289
- } }; } function E(t, e) { var r = e.method, n = t.iterator[r]; if (void 0 === n)
290
- return e.delegate = null, "throw" === r && t.iterator.return && (e.method = "return", e.arg = void 0, E(t, e), "throw" === e.method) || "return" !== r && (e.method = "throw", e.arg = new TypeError("The iterator does not provide a '" + r + "' method")), p; var o = h(n, t.iterator, e.arg); if ("throw" === o.type)
291
- return e.method = "throw", e.arg = o.arg, e.delegate = null, p; var i = o.arg; return i ? i.done ? (e[t.resultName] = i.value, e.next = t.nextLoc, "return" !== e.method && (e.method = "next", e.arg = void 0), e.delegate = null, p) : i : (e.method = "throw", e.arg = new TypeError("iterator result is not an object"), e.delegate = null, p); } function O(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function T(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function P(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(O, this), this.reset(!0); } function L(t) { if (t) {
292
- var e = t[a];
293
- if (e)
294
- return e.call(t);
295
- if ("function" == typeof t.next)
296
- return t;
297
- if (!isNaN(t.length)) {
298
- var r = -1, o = function e() { for (; ++r < t.length;)
299
- if (n.call(t, r))
300
- return e.value = t[r], e.done = !1, e; return e.value = void 0, e.done = !0, e; };
283
+ } }; } function O(e, t) { var r = t.method, n = e.iterator[r]; if (void 0 === n)
284
+ 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")), d; var o = f(n, e.iterator, t.arg); if ("throw" === o.type)
285
+ return t.method = "throw", t.arg = o.arg, t.delegate = null, d; var i = o.arg; return i ? i.done ? (t[e.resultName] = i.value, t.next = e.nextLoc, "return" !== t.method && (t.method = "next", t.arg = void 0), t.delegate = null, d) : i : (t.method = "throw", t.arg = new TypeError("iterator result is not an object"), t.delegate = null, d); } function E(e) { var t = { tryLoc: e[0] }; 1 in e && (t.catchLoc = e[1]), 2 in e && (t.finallyLoc = e[2], t.afterLoc = e[3]), this.tryEntries.push(t); } function T(e) { var t = e.completion || {}; t.type = "normal", delete t.arg, e.completion = t; } function x(e) { this.tryEntries = [{ tryLoc: "root" }], e.forEach(E, this), this.reset(!0); } function C(e) { if (e) {
286
+ var t = e[s];
287
+ if (t)
288
+ return t.call(e);
289
+ if ("function" == typeof e.next)
290
+ return e;
291
+ if (!isNaN(e.length)) {
292
+ var r = -1, o = function t() { for (; ++r < e.length;)
293
+ if (n.call(e, r))
294
+ return t.value = e[r], t.done = !1, t; return t.value = void 0, t.done = !0, t; };
301
295
  return o.next = o;
302
296
  }
303
- } return { next: x }; } function x() { return { value: void 0, done: !0 }; } return v.prototype = y, o(_, "constructor", { value: y, configurable: !0 }), o(y, "constructor", { value: v, configurable: !0 }), v.displayName = l(y, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === v || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, y) : (t.__proto__ = y, l(t, u, "GeneratorFunction")), t.prototype = Object.create(_), t; }, e.awrap = function (t) { return { __await: t }; }, w(k.prototype), l(k.prototype, c, (function () { return this; })), e.AsyncIterator = k, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new k(f(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then((function (t) { return t.done ? t.value : a.next(); })); }, w(_), l(_, u, "Generator"), l(_, a, (function () { return this; })), l(_, "toString", (function () { return "[object Generator]"; })), e.keys = function (t) { var e = Object(t), r = []; for (var n in e)
304
- r.push(n); return r.reverse(), function t() { for (; r.length;) {
297
+ } return { next: P }; } function P() { return { value: void 0, done: !0 }; } return v.prototype = m, o(g, "constructor", { value: m, configurable: !0 }), o(m, "constructor", { value: v, configurable: !0 }), v.displayName = l(m, u, "GeneratorFunction"), t.isGeneratorFunction = function (e) { var t = "function" == typeof e && e.constructor; return !!t && (t === v || "GeneratorFunction" === (t.displayName || t.name)); }, t.mark = function (e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, m) : (e.__proto__ = m, l(e, u, "GeneratorFunction")), e.prototype = Object.create(g), e; }, t.awrap = function (e) { return { __await: e }; }, k(w.prototype), l(w.prototype, c, (function () { return this; })), t.AsyncIterator = w, t.async = function (e, r, n, o, i) { void 0 === i && (i = Promise); var a = new w(h(e, r, n, o), i); return t.isGeneratorFunction(r) ? a : a.next().then((function (e) { return e.done ? e.value : a.next(); })); }, k(g), l(g, u, "Generator"), l(g, s, (function () { return this; })), l(g, "toString", (function () { return "[object Generator]"; })), t.keys = function (e) { var t = Object(e), r = []; for (var n in t)
298
+ r.push(n); return r.reverse(), function e() { for (; r.length;) {
305
299
  var n = r.pop();
306
- if (n in e)
307
- return t.value = n, t.done = !1, t;
308
- } return t.done = !0, t; }; }, e.values = L, P.prototype = { constructor: P, reset: function (t) { if (this.prev = 0, this.next = 0, this.sent = this._sent = void 0, this.done = !1, this.delegate = null, this.method = "next", this.arg = void 0, this.tryEntries.forEach(T), !t)
309
- for (var e in this)
310
- "t" === e.charAt(0) && n.call(this, e) && !isNaN(+e.slice(1)) && (this[e] = void 0); }, stop: function () { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type)
311
- throw t.arg; return this.rval; }, dispatchException: function (t) { if (this.done)
312
- throw t; var e = this; function r(r, n) { return a.type = "throw", a.arg = t, e.next = r, n && (e.method = "next", e.arg = void 0), !!n; } for (var o = this.tryEntries.length - 1; o >= 0; --o) {
300
+ if (n in t)
301
+ return e.value = n, e.done = !1, e;
302
+ } return e.done = !0, e; }; }, t.values = C, x.prototype = { constructor: x, reset: function (e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = void 0, this.done = !1, this.delegate = null, this.method = "next", this.arg = void 0, this.tryEntries.forEach(T), !e)
303
+ for (var t in this)
304
+ "t" === t.charAt(0) && n.call(this, t) && !isNaN(+t.slice(1)) && (this[t] = void 0); }, stop: function () { this.done = !0; var e = this.tryEntries[0].completion; if ("throw" === e.type)
305
+ throw e.arg; return this.rval; }, dispatchException: function (e) { if (this.done)
306
+ throw e; var t = this; function r(r, n) { return a.type = "throw", a.arg = e, t.next = r, n && (t.method = "next", t.arg = void 0), !!n; } for (var o = this.tryEntries.length - 1; o >= 0; --o) {
313
307
  var i = this.tryEntries[o], a = i.completion;
314
308
  if ("root" === i.tryLoc)
315
309
  return r("end");
@@ -332,20 +326,20 @@ catch (t) {
332
326
  return r(i.finallyLoc);
333
327
  }
334
328
  }
335
- } }, abrupt: function (t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) {
329
+ } }, abrupt: function (e, t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) {
336
330
  var o = this.tryEntries[r];
337
331
  if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
338
332
  var i = o;
339
333
  break;
340
334
  }
341
- } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, p) : this.complete(a); }, complete: function (t, e) { if ("throw" === t.type)
342
- throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), p; }, finish: function (t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) {
343
- var r = this.tryEntries[e];
344
- if (r.finallyLoc === t)
345
- return this.complete(r.completion, r.afterLoc), T(r), p;
346
- } }, catch: function (t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) {
347
- var r = this.tryEntries[e];
348
- if (r.tryLoc === t) {
335
+ } i && ("break" === e || "continue" === e) && i.tryLoc <= t && t <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = e, a.arg = t, i ? (this.method = "next", this.next = i.finallyLoc, d) : this.complete(a); }, complete: function (e, t) { if ("throw" === e.type)
336
+ throw e.arg; return "break" === e.type || "continue" === e.type ? this.next = e.arg : "return" === e.type ? (this.rval = this.arg = e.arg, this.method = "return", this.next = "end") : "normal" === e.type && t && (this.next = t), d; }, finish: function (e) { for (var t = this.tryEntries.length - 1; t >= 0; --t) {
337
+ var r = this.tryEntries[t];
338
+ if (r.finallyLoc === e)
339
+ return this.complete(r.completion, r.afterLoc), T(r), d;
340
+ } }, catch: function (e) { for (var t = this.tryEntries.length - 1; t >= 0; --t) {
341
+ var r = this.tryEntries[t];
342
+ if (r.tryLoc === e) {
349
343
  var n = r.completion;
350
344
  if ("throw" === n.type) {
351
345
  var o = n.arg;
@@ -353,36 +347,72 @@ catch (t) {
353
347
  }
354
348
  return o;
355
349
  }
356
- } throw new Error("illegal catch attempt"); }, delegateYield: function (t, e, r) { return this.delegate = { iterator: L(t), resultName: e, nextLoc: r }, "next" === this.method && (this.arg = void 0), p; } }, e; }
357
- function c(t, e) { if (!(t instanceof e))
350
+ } throw new Error("illegal catch attempt"); }, delegateYield: function (e, t, r) { return this.delegate = { iterator: C(e), resultName: t, nextLoc: r }, "next" === this.method && (this.arg = void 0), d; } }, t; }
351
+ function s(e, t) { if (!(e instanceof t))
358
352
  throw new TypeError("Cannot call a class as a function"); }
359
- function u(t, e) { for (var r = 0; r < e.length; r++) {
360
- var n = e[r];
361
- n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(t, f(n.key), n);
353
+ function c(e, t) { for (var r = 0; r < t.length; r++) {
354
+ var n = t[r];
355
+ n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(e, d(n.key), n);
362
356
  } }
363
- function l(t, e, r) { return e && u(t.prototype, e), r && u(t, r), Object.defineProperty(t, "prototype", { writable: !1 }), t; }
364
- function f(e) { var r = function (e, r) { if ("object" !== t(e) || null === e)
365
- return e; var n = e[Symbol.toPrimitive]; if (void 0 !== n) {
366
- var o = n.call(e, r || "default");
367
- if ("object" !== t(o))
357
+ function u(e, t, r) { return t && c(e.prototype, t), r && c(e, r), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
358
+ function l(e, t) { return function (e) { if (Array.isArray(e))
359
+ return e; }(e) || function (e, t) { var r = null == e ? null : "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"]; if (null != r) {
360
+ var n, o, i, a, s = [], c = !0, u = !1;
361
+ try {
362
+ if (i = (r = r.call(e)).next, 0 === t) {
363
+ if (Object(r) !== r)
364
+ return;
365
+ c = !1;
366
+ }
367
+ else
368
+ for (; !(c = (n = i.call(r)).done) && (s.push(n.value), s.length !== t); c = !0)
369
+ ;
370
+ }
371
+ catch (e) {
372
+ u = !0, o = e;
373
+ }
374
+ finally {
375
+ try {
376
+ if (!c && null != r.return && (a = r.return(), Object(a) !== a))
377
+ return;
378
+ }
379
+ finally {
380
+ if (u)
381
+ throw o;
382
+ }
383
+ }
384
+ return s;
385
+ } }(e, t) || h(e, t) || function () { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }(); }
386
+ function h(e, t) { if (e) {
387
+ if ("string" == typeof e)
388
+ return f(e, t);
389
+ var r = Object.prototype.toString.call(e).slice(8, -1);
390
+ return "Object" === r && e.constructor && (r = e.constructor.name), "Map" === r || "Set" === r ? Array.from(e) : "Arguments" === r || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? f(e, t) : void 0;
391
+ } }
392
+ function f(e, t) { (null == t || t > e.length) && (t = e.length); for (var r = 0, n = new Array(t); r < t; r++)
393
+ n[r] = e[r]; return n; }
394
+ function d(t) { var r = function (t, r) { if ("object" !== e(t) || null === t)
395
+ return t; var n = t[Symbol.toPrimitive]; if (void 0 !== n) {
396
+ var o = n.call(t, r || "default");
397
+ if ("object" !== e(o))
368
398
  return o;
369
399
  throw new TypeError("@@toPrimitive must return a primitive value.");
370
- } return ("string" === r ? String : Number)(e); }(e, "string"); return "symbol" === t(r) ? r : String(r); }
371
- function h(t, e) { return function (t) { if (Array.isArray(t))
372
- return t; }(t) || function (t, e) { var r = null == t ? null : "undefined" != typeof Symbol && t[Symbol.iterator] || t["@@iterator"]; if (null != r) {
400
+ } return ("string" === r ? String : Number)(t); }(t, "string"); return "symbol" === e(r) ? r : String(r); }
401
+ function p(e, t) { return function (e) { if (Array.isArray(e))
402
+ return e; }(e) || function (e, t) { var r = null == e ? null : "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"]; if (null != r) {
373
403
  var n, o, i, a, s = [], c = !0, u = !1;
374
404
  try {
375
- if (i = (r = r.call(t)).next, 0 === e) {
405
+ if (i = (r = r.call(e)).next, 0 === t) {
376
406
  if (Object(r) !== r)
377
407
  return;
378
408
  c = !1;
379
409
  }
380
410
  else
381
- for (; !(c = (n = i.call(r)).done) && (s.push(n.value), s.length !== e); c = !0)
411
+ for (; !(c = (n = i.call(r)).done) && (s.push(n.value), s.length !== t); c = !0)
382
412
  ;
383
413
  }
384
- catch (t) {
385
- u = !0, o = t;
414
+ catch (e) {
415
+ u = !0, o = e;
386
416
  }
387
417
  finally {
388
418
  try {
@@ -395,60 +425,60 @@ function h(t, e) { return function (t) { if (Array.isArray(t))
395
425
  }
396
426
  }
397
427
  return s;
398
- } }(t, e) || d(t, e) || function () { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }(); }
399
- function p(t) { return p = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (t) { return typeof t; } : function (t) { return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t; }, p(t); }
400
- function d(t, e) { if (t) {
401
- if ("string" == typeof t)
402
- return v(t, e);
403
- var r = Object.prototype.toString.call(t).slice(8, -1);
404
- return "Object" === r && t.constructor && (r = t.constructor.name), "Map" === r || "Set" === r ? Array.from(t) : "Arguments" === r || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? v(t, e) : void 0;
428
+ } }(e, t) || m(e, t) || function () { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }(); }
429
+ function v(e) { return v = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (e) { return typeof e; } : function (e) { return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e; }, v(e); }
430
+ function m(e, t) { if (e) {
431
+ if ("string" == typeof e)
432
+ return y(e, t);
433
+ var r = Object.prototype.toString.call(e).slice(8, -1);
434
+ return "Object" === r && e.constructor && (r = e.constructor.name), "Map" === r || "Set" === r ? Array.from(e) : "Arguments" === r || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? y(e, t) : void 0;
405
435
  } }
406
- function v(t, e) { (null == e || e > t.length) && (e = t.length); for (var r = 0, n = new Array(e); r < e; r++)
407
- n[r] = t[r]; return n; }
408
- function y() {
436
+ function y(e, t) { (null == t || t > e.length) && (t = e.length); for (var r = 0, n = new Array(t); r < t; r++)
437
+ n[r] = e[r]; return n; }
438
+ function _() {
409
439
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
410
- y = function () { return t; };
411
- var t = {}, e = Object.prototype, r = e.hasOwnProperty, n = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, o = "function" == typeof Symbol ? Symbol : {}, i = o.iterator || "@@iterator", a = o.asyncIterator || "@@asyncIterator", s = o.toStringTag || "@@toStringTag";
412
- function c(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; }
440
+ _ = function () { return e; };
441
+ var e = {}, t = Object.prototype, r = t.hasOwnProperty, n = Object.defineProperty || function (e, t, r) { e[t] = r.value; }, o = "function" == typeof Symbol ? Symbol : {}, i = o.iterator || "@@iterator", a = o.asyncIterator || "@@asyncIterator", s = o.toStringTag || "@@toStringTag";
442
+ function c(e, t, r) { return Object.defineProperty(e, t, { value: r, enumerable: !0, configurable: !0, writable: !0 }), e[t]; }
413
443
  try {
414
444
  c({}, "");
415
445
  }
416
- catch (t) {
417
- c = function (t, e, r) { return t[e] = r; };
446
+ catch (e) {
447
+ c = function (e, t, r) { return e[t] = r; };
418
448
  }
419
- function u(t, e, r, o) { var i = e && e.prototype instanceof h ? e : h, a = Object.create(i.prototype), s = new P(o || []); return n(a, "_invoke", { value: S(t, r, s) }), a; }
420
- function l(t, e, r) { try {
421
- return { type: "normal", arg: t.call(e, r) };
449
+ function u(e, t, r, o) { var i = t && t.prototype instanceof f ? t : f, a = Object.create(i.prototype), s = new x(o || []); return n(a, "_invoke", { value: S(e, r, s) }), a; }
450
+ function l(e, t, r) { try {
451
+ return { type: "normal", arg: e.call(t, r) };
422
452
  }
423
- catch (t) {
424
- return { type: "throw", arg: t };
453
+ catch (e) {
454
+ return { type: "throw", arg: e };
425
455
  } }
426
- t.wrap = u;
427
- var f = {};
428
- function h() { }
456
+ e.wrap = u;
457
+ var h = {};
458
+ function f() { }
429
459
  function d() { }
430
- function v() { }
460
+ function p() { }
431
461
  var m = {};
432
462
  c(m, i, (function () { return this; }));
433
- var b = Object.getPrototypeOf, g = b && b(b(L([])));
434
- g && g !== e && r.call(g, i) && (m = g);
435
- var _ = v.prototype = h.prototype = Object.create(m);
436
- function w(t) { ["next", "throw", "return"].forEach((function (e) { c(t, e, (function (t) { return this._invoke(e, t); })); })); }
437
- function k(t, e) { function o(n, i, a, s) { var c = l(t[n], t, i); if ("throw" !== c.type) {
438
- var u = c.arg, f = u.value;
439
- return f && "object" == p(f) && r.call(f, "__await") ? e.resolve(f.__await).then((function (t) { o("next", t, a, s); }), (function (t) { o("throw", t, a, s); })) : e.resolve(f).then((function (t) { u.value = t, a(u); }), (function (t) { return o("throw", t, a, s); }));
440
- } s(c.arg); } var i; n(this, "_invoke", { value: function (t, r) { function n() { return new e((function (e, n) { o(t, r, e, n); })); } return i = i ? i.then(n, n) : n(); } }); }
441
- function S(t, e, r) { var n = "suspendedStart"; return function (o, i) { if ("executing" === n)
463
+ var y = Object.getPrototypeOf, b = y && y(y(C([])));
464
+ b && b !== t && r.call(b, i) && (m = b);
465
+ var g = p.prototype = f.prototype = Object.create(m);
466
+ function k(e) { ["next", "throw", "return"].forEach((function (t) { c(e, t, (function (e) { return this._invoke(t, e); })); })); }
467
+ function w(e, t) { function o(n, i, a, s) { var c = l(e[n], e, i); if ("throw" !== c.type) {
468
+ var u = c.arg, h = u.value;
469
+ return h && "object" == v(h) && r.call(h, "__await") ? t.resolve(h.__await).then((function (e) { o("next", e, a, s); }), (function (e) { o("throw", e, a, s); })) : t.resolve(h).then((function (e) { u.value = e, a(u); }), (function (e) { return o("throw", e, a, s); }));
470
+ } s(c.arg); } var i; n(this, "_invoke", { value: function (e, r) { function n() { return new t((function (t, n) { o(e, r, t, n); })); } return i = i ? i.then(n, n) : n(); } }); }
471
+ function S(e, t, r) { var n = "suspendedStart"; return function (o, i) { if ("executing" === n)
442
472
  throw new Error("Generator is already running"); if ("completed" === n) {
443
473
  if ("throw" === o)
444
474
  throw i;
445
- return x();
475
+ return P();
446
476
  } for (r.method = o, r.arg = i;;) {
447
477
  var a = r.delegate;
448
478
  if (a) {
449
- var s = E(a, r);
479
+ var s = O(a, r);
450
480
  if (s) {
451
- if (s === f)
481
+ if (s === h)
452
482
  continue;
453
483
  return s;
454
484
  }
@@ -463,44 +493,44 @@ function y() {
463
493
  else
464
494
  "return" === r.method && r.abrupt("return", r.arg);
465
495
  n = "executing";
466
- var c = l(t, e, r);
496
+ var c = l(e, t, r);
467
497
  if ("normal" === c.type) {
468
- if (n = r.done ? "completed" : "suspendedYield", c.arg === f)
498
+ if (n = r.done ? "completed" : "suspendedYield", c.arg === h)
469
499
  continue;
470
500
  return { value: c.arg, done: r.done };
471
501
  }
472
502
  "throw" === c.type && (n = "completed", r.method = "throw", r.arg = c.arg);
473
503
  } }; }
474
- function E(t, e) { var r = e.method, n = t.iterator[r]; if (void 0 === n)
475
- return e.delegate = null, "throw" === r && t.iterator.return && (e.method = "return", e.arg = void 0, E(t, e), "throw" === e.method) || "return" !== r && (e.method = "throw", e.arg = new TypeError("The iterator does not provide a '" + r + "' method")), f; var o = l(n, t.iterator, e.arg); if ("throw" === o.type)
476
- return e.method = "throw", e.arg = o.arg, e.delegate = null, f; var i = o.arg; return i ? i.done ? (e[t.resultName] = i.value, e.next = t.nextLoc, "return" !== e.method && (e.method = "next", e.arg = void 0), e.delegate = null, f) : i : (e.method = "throw", e.arg = new TypeError("iterator result is not an object"), e.delegate = null, f); }
477
- function O(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); }
478
- function T(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; }
479
- function P(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(O, this), this.reset(!0); }
480
- function L(t) { if (t) {
481
- var e = t[i];
482
- if (e)
483
- return e.call(t);
484
- if ("function" == typeof t.next)
485
- return t;
486
- if (!isNaN(t.length)) {
487
- var n = -1, o = function e() { for (; ++n < t.length;)
488
- if (r.call(t, n))
489
- return e.value = t[n], e.done = !1, e; return e.value = void 0, e.done = !0, e; };
504
+ function O(e, t) { var r = t.method, n = e.iterator[r]; if (void 0 === n)
505
+ 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")), h; var o = l(n, e.iterator, t.arg); if ("throw" === o.type)
506
+ return t.method = "throw", t.arg = o.arg, t.delegate = null, h; var i = o.arg; return i ? i.done ? (t[e.resultName] = i.value, t.next = e.nextLoc, "return" !== t.method && (t.method = "next", t.arg = void 0), t.delegate = null, h) : i : (t.method = "throw", t.arg = new TypeError("iterator result is not an object"), t.delegate = null, h); }
507
+ function E(e) { var t = { tryLoc: e[0] }; 1 in e && (t.catchLoc = e[1]), 2 in e && (t.finallyLoc = e[2], t.afterLoc = e[3]), this.tryEntries.push(t); }
508
+ function T(e) { var t = e.completion || {}; t.type = "normal", delete t.arg, e.completion = t; }
509
+ function x(e) { this.tryEntries = [{ tryLoc: "root" }], e.forEach(E, this), this.reset(!0); }
510
+ function C(e) { if (e) {
511
+ var t = e[i];
512
+ if (t)
513
+ return t.call(e);
514
+ if ("function" == typeof e.next)
515
+ return e;
516
+ if (!isNaN(e.length)) {
517
+ var n = -1, o = function t() { for (; ++n < e.length;)
518
+ if (r.call(e, n))
519
+ return t.value = e[n], t.done = !1, t; return t.value = void 0, t.done = !0, t; };
490
520
  return o.next = o;
491
521
  }
492
- } return { next: x }; }
493
- function x() { return { value: void 0, done: !0 }; }
494
- return d.prototype = v, n(_, "constructor", { value: v, configurable: !0 }), n(v, "constructor", { value: d, configurable: !0 }), d.displayName = c(v, s, "GeneratorFunction"), t.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === d || "GeneratorFunction" === (e.displayName || e.name)); }, t.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, v) : (t.__proto__ = v, c(t, s, "GeneratorFunction")), t.prototype = Object.create(_), t; }, t.awrap = function (t) { return { __await: t }; }, w(k.prototype), c(k.prototype, a, (function () { return this; })), t.AsyncIterator = k, t.async = function (e, r, n, o, i) { void 0 === i && (i = Promise); var a = new k(u(e, r, n, o), i); return t.isGeneratorFunction(r) ? a : a.next().then((function (t) { return t.done ? t.value : a.next(); })); }, w(_), c(_, s, "Generator"), c(_, i, (function () { return this; })), c(_, "toString", (function () { return "[object Generator]"; })), t.keys = function (t) { var e = Object(t), r = []; for (var n in e)
495
- r.push(n); return r.reverse(), function t() { for (; r.length;) {
522
+ } return { next: P }; }
523
+ function P() { return { value: void 0, done: !0 }; }
524
+ return d.prototype = p, n(g, "constructor", { value: p, configurable: !0 }), n(p, "constructor", { value: d, configurable: !0 }), d.displayName = c(p, s, "GeneratorFunction"), e.isGeneratorFunction = function (e) { var t = "function" == typeof e && e.constructor; return !!t && (t === d || "GeneratorFunction" === (t.displayName || t.name)); }, e.mark = function (e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, p) : (e.__proto__ = p, c(e, s, "GeneratorFunction")), e.prototype = Object.create(g), e; }, e.awrap = function (e) { return { __await: e }; }, k(w.prototype), c(w.prototype, a, (function () { return this; })), e.AsyncIterator = w, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new w(u(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then((function (e) { return e.done ? e.value : a.next(); })); }, k(g), c(g, s, "Generator"), c(g, i, (function () { return this; })), c(g, "toString", (function () { return "[object Generator]"; })), e.keys = function (e) { var t = Object(e), r = []; for (var n in t)
525
+ r.push(n); return r.reverse(), function e() { for (; r.length;) {
496
526
  var n = r.pop();
497
- if (n in e)
498
- return t.value = n, t.done = !1, t;
499
- } return t.done = !0, t; }; }, t.values = L, P.prototype = { constructor: P, reset: function (t) { if (this.prev = 0, this.next = 0, this.sent = this._sent = void 0, this.done = !1, this.delegate = null, this.method = "next", this.arg = void 0, this.tryEntries.forEach(T), !t)
500
- for (var e in this)
501
- "t" === e.charAt(0) && r.call(this, e) && !isNaN(+e.slice(1)) && (this[e] = void 0); }, stop: function () { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type)
502
- throw t.arg; return this.rval; }, dispatchException: function (t) { if (this.done)
503
- throw t; var e = this; function n(r, n) { return a.type = "throw", a.arg = t, e.next = r, n && (e.method = "next", e.arg = void 0), !!n; } for (var o = this.tryEntries.length - 1; o >= 0; --o) {
527
+ if (n in t)
528
+ return e.value = n, e.done = !1, e;
529
+ } return e.done = !0, e; }; }, e.values = C, x.prototype = { constructor: x, reset: function (e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = void 0, this.done = !1, this.delegate = null, this.method = "next", this.arg = void 0, this.tryEntries.forEach(T), !e)
530
+ for (var t in this)
531
+ "t" === t.charAt(0) && r.call(this, t) && !isNaN(+t.slice(1)) && (this[t] = void 0); }, stop: function () { this.done = !0; var e = this.tryEntries[0].completion; if ("throw" === e.type)
532
+ throw e.arg; return this.rval; }, dispatchException: function (e) { if (this.done)
533
+ throw e; var t = this; function n(r, n) { return a.type = "throw", a.arg = e, t.next = r, n && (t.method = "next", t.arg = void 0), !!n; } for (var o = this.tryEntries.length - 1; o >= 0; --o) {
504
534
  var i = this.tryEntries[o], a = i.completion;
505
535
  if ("root" === i.tryLoc)
506
536
  return n("end");
@@ -523,20 +553,20 @@ function y() {
523
553
  return n(i.finallyLoc);
524
554
  }
525
555
  }
526
- } }, abrupt: function (t, e) { for (var n = this.tryEntries.length - 1; n >= 0; --n) {
556
+ } }, abrupt: function (e, t) { for (var n = this.tryEntries.length - 1; n >= 0; --n) {
527
557
  var o = this.tryEntries[n];
528
558
  if (o.tryLoc <= this.prev && r.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
529
559
  var i = o;
530
560
  break;
531
561
  }
532
- } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, f) : this.complete(a); }, complete: function (t, e) { if ("throw" === t.type)
533
- throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), f; }, finish: function (t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) {
534
- var r = this.tryEntries[e];
535
- if (r.finallyLoc === t)
536
- return this.complete(r.completion, r.afterLoc), T(r), f;
537
- } }, catch: function (t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) {
538
- var r = this.tryEntries[e];
539
- if (r.tryLoc === t) {
562
+ } i && ("break" === e || "continue" === e) && i.tryLoc <= t && t <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = e, a.arg = t, i ? (this.method = "next", this.next = i.finallyLoc, h) : this.complete(a); }, complete: function (e, t) { if ("throw" === e.type)
563
+ throw e.arg; return "break" === e.type || "continue" === e.type ? this.next = e.arg : "return" === e.type ? (this.rval = this.arg = e.arg, this.method = "return", this.next = "end") : "normal" === e.type && t && (this.next = t), h; }, finish: function (e) { for (var t = this.tryEntries.length - 1; t >= 0; --t) {
564
+ var r = this.tryEntries[t];
565
+ if (r.finallyLoc === e)
566
+ return this.complete(r.completion, r.afterLoc), T(r), h;
567
+ } }, catch: function (e) { for (var t = this.tryEntries.length - 1; t >= 0; --t) {
568
+ var r = this.tryEntries[t];
569
+ if (r.tryLoc === e) {
540
570
  var n = r.completion;
541
571
  if ("throw" === n.type) {
542
572
  var o = n.arg;
@@ -544,95 +574,95 @@ function y() {
544
574
  }
545
575
  return o;
546
576
  }
547
- } throw new Error("illegal catch attempt"); }, delegateYield: function (t, e, r) { return this.delegate = { iterator: L(t), resultName: e, nextLoc: r }, "next" === this.method && (this.arg = void 0), f; } }, t;
577
+ } throw new Error("illegal catch attempt"); }, delegateYield: function (e, t, r) { return this.delegate = { iterator: C(e), resultName: t, nextLoc: r }, "next" === this.method && (this.arg = void 0), h; } }, e;
548
578
  }
549
- function m(t, e) { for (var r = 0; r < e.length; r++) {
550
- var n = e[r];
551
- n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(t, (o = n.key, i = void 0, i = function (t, e) { if ("object" !== p(t) || null === t)
552
- return t; var r = t[Symbol.toPrimitive]; if (void 0 !== r) {
553
- var n = r.call(t, e || "default");
554
- if ("object" !== p(n))
579
+ function b(e, t) { for (var r = 0; r < t.length; r++) {
580
+ var n = t[r];
581
+ n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(e, (o = n.key, i = void 0, i = function (e, t) { if ("object" !== v(e) || null === e)
582
+ return e; var r = e[Symbol.toPrimitive]; if (void 0 !== r) {
583
+ var n = r.call(e, t || "default");
584
+ if ("object" !== v(n))
555
585
  return n;
556
586
  throw new TypeError("@@toPrimitive must return a primitive value.");
557
- } return ("string" === e ? String : Number)(t); }(o, "string"), "symbol" === p(i) ? i : String(i)), n);
587
+ } return ("string" === t ? String : Number)(e); }(o, "string"), "symbol" === v(i) ? i : String(i)), n);
558
588
  } var o, i; }
559
- function b(t, e, r) { return e && m(t.prototype, e), r && m(t, r), Object.defineProperty(t, "prototype", { writable: !1 }), t; }
560
- function g(t, e) { if (!(t instanceof e))
589
+ function g(e, t, r) { return t && b(e.prototype, t), r && b(e, r), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
590
+ function k(e, t) { if (!(e instanceof t))
561
591
  throw new TypeError("Cannot call a class as a function"); }
562
- function _(t, e) { if ("function" != typeof e && null !== e)
563
- throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && T(t, e); }
564
- function w(t) { var e = O(); return function () { var r, n = P(t); if (e) {
592
+ function w(e, t) { if ("function" != typeof t && null !== t)
593
+ throw new TypeError("Super expression must either be null or a function"); e.prototype = Object.create(t && t.prototype, { constructor: { value: e, writable: !0, configurable: !0 } }), Object.defineProperty(e, "prototype", { writable: !1 }), t && C(e, t); }
594
+ function S(e) { var t = x(); return function () { var r, n = P(e); if (t) {
565
595
  var o = P(this).constructor;
566
596
  r = Reflect.construct(n, arguments, o);
567
597
  }
568
598
  else
569
- r = n.apply(this, arguments); return function (t, e) { if (e && ("object" === p(e) || "function" == typeof e))
570
- return e; if (void 0 !== e)
571
- throw new TypeError("Derived constructors may only return object or undefined"); return k(t); }(this, r); }; }
572
- function k(t) { if (void 0 === t)
573
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return t; }
574
- function S(t) { var e = "function" == typeof Map ? new Map : void 0; return S = function (t) { if (null === t || (r = t, -1 === Function.toString.call(r).indexOf("[native code]")))
575
- return t; var r; if ("function" != typeof t)
576
- throw new TypeError("Super expression must either be null or a function"); if (void 0 !== e) {
577
- if (e.has(t))
578
- return e.get(t);
579
- e.set(t, n);
580
- } function n() { return E(t, arguments, P(this).constructor); } return n.prototype = Object.create(t.prototype, { constructor: { value: n, enumerable: !1, writable: !0, configurable: !0 } }), T(n, t); }, S(t); }
581
- function E(t, e, r) { return E = O() ? Reflect.construct.bind() : function (t, e, r) { var n = [null]; n.push.apply(n, e); var o = new (Function.bind.apply(t, n)); return r && T(o, r.prototype), o; }, E.apply(null, arguments); }
582
- function O() { if ("undefined" == typeof Reflect || !Reflect.construct)
599
+ r = n.apply(this, arguments); return function (e, t) { if (t && ("object" === v(t) || "function" == typeof t))
600
+ return t; if (void 0 !== t)
601
+ throw new TypeError("Derived constructors may only return object or undefined"); return O(e); }(this, r); }; }
602
+ function O(e) { if (void 0 === e)
603
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
604
+ function E(e) { var t = "function" == typeof Map ? new Map : void 0; return E = function (e) { if (null === e || (r = e, -1 === Function.toString.call(r).indexOf("[native code]")))
605
+ return e; var r; if ("function" != typeof e)
606
+ throw new TypeError("Super expression must either be null or a function"); if (void 0 !== t) {
607
+ if (t.has(e))
608
+ return t.get(e);
609
+ t.set(e, n);
610
+ } function n() { return T(e, arguments, P(this).constructor); } return n.prototype = Object.create(e.prototype, { constructor: { value: n, enumerable: !1, writable: !0, configurable: !0 } }), C(n, e); }, E(e); }
611
+ function T(e, t, r) { return T = x() ? Reflect.construct.bind() : function (e, t, r) { var n = [null]; n.push.apply(n, t); var o = new (Function.bind.apply(e, n)); return r && C(o, r.prototype), o; }, T.apply(null, arguments); }
612
+ function x() { if ("undefined" == typeof Reflect || !Reflect.construct)
583
613
  return !1; if (Reflect.construct.sham)
584
614
  return !1; if ("function" == typeof Proxy)
585
615
  return !0; try {
586
616
  return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], (function () { }))), !0;
587
617
  }
588
- catch (t) {
618
+ catch (e) {
589
619
  return !1;
590
620
  } }
591
- function T(t, e) { return T = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, T(t, e); }
592
- function P(t) { return P = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, P(t); }
593
- var L, x, C, j, A, R;
594
- !function (t) { t.emailMagicLinks = "emailMagicLinks", t.oauth = "oauth", t.otp = "otp", t.crypto = "crypto", t.passwords = "passwords"; }(L || (L = {})), function (t) { t.Google = "google", t.Microsoft = "microsoft", t.Apple = "apple", t.Github = "github", t.GitLab = "gitlab", t.Facebook = "facebook", t.Discord = "discord", t.Slack = "slack", t.Amazon = "amazon", t.Bitbucket = "bitbucket", t.LinkedIn = "linkedin", t.Coinbase = "coinbase", t.Twitch = "twitch"; }(x || (x = {})), function (t) { t.Vessel = "Vessel", t.Phantom = "Phantom", t.Metamask = "Metamask", t.Coinbase = "Coinbase", t.Binance = "Binance", t.GenericEthereumWallet = "Other Ethereum Wallet", t.GenericSolanaWallet = "Other Solana Wallet"; }(C || (C = {})), function (t) { t.embedded = "embedded", t.floating = "floating"; }(j || (j = {})), function (t) { t.SMS = "sms", t.WhatsApp = "whatsapp", t.Email = "email"; }(A || (A = {})), function (t) { t.MagicLinkLoginOrCreateEvent = "MAGIC_LINK_LOGIN_OR_CREATE", t.OTPsLoginOrCreateEvent = "OTP_LOGIN_OR_CREATE", t.OTPsAuthenticate = "OTP_AUTHENTICATE", t.CryptoWalletAuthenticateStart = "CRYPTO_WALLET_AUTHENTICATE_START", t.CryptoWalletAuthenticate = "CRYPTO_WALLET_AUTHENTICATE", t.PasswordCreate = "PASSWORD_CREATE", t.PasswordAuthenticate = "PASSWORD_AUTHENTICATE", t.PasswordResetByEmailStart = "PASSWORD_RESET_BY_EMAIL_START", t.PasswordResetByEmail = "PASSWORD_RESET_BY_EMAIL"; }(R || (R = {}));
595
- var I, D, N = function (t) { _(r, S(Error)); var e = w(r); function r(t, n) { var o; return g(this, r), (o = e.call(this, t + "\n" + n)).message = t + "\n" + n, o.name = "SDKAPIUnreachableError", o.details = n, Object.setPrototypeOf(k(o), r.prototype), o; } return b(r); }(), M = function (t) { _(r, S(Error)); var e = w(r); function r(t, n) { var o; return g(this, r), (o = e.call(this)).name = "StytchSDKUsageError", o.message = "Invalid call to ".concat(t, "\n") + n, o; } return b(r); }(), U = function (t) { _(r, S(Error)); var e = w(r); function r(t) { var n, o; g(this, r), (n = e.call(this)).name = "StytchSDKSchemaError"; var i = null === (o = t.body) || void 0 === o ? void 0 : o.map((function (t) { return "".concat(t.dataPath, ": ").concat(t.message); })).join("\n"); return n.message = "[400] Request does not match expected schema\n".concat(i), n; } return b(r); }(), B = function (t) { _(r, S(Error)); var e = w(r); function r(t) { var n; g(this, r), (n = e.call(this)).name = "StytchSDKAPIError"; var o = t.status_code, i = t.error_type, a = t.error_message, s = t.error_url, c = t.request_id; return n.error_type = i, n.error_message = a, n.error_url = s, n.request_id = c, n.status_code = o, n.message = "[".concat(o, "] ").concat(i, "\n") + "".concat(a, "\n") + "See ".concat(s, " for more information.\n") + (c ? "request_id: ".concat(c, "\n") : ""), n; } return b(r); }(), K = ["unauthorized_credentials", "user_unauthenticated", "invalid_secret_authentication"];
596
- function F(t, e, r, n) { return new (r || (r = Promise))((function (o, i) { function a(t) { try {
597
- c(n.next(t));
621
+ function C(e, t) { return C = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (e, t) { return e.__proto__ = t, e; }, C(e, t); }
622
+ function P(e) { return P = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (e) { return e.__proto__ || Object.getPrototypeOf(e); }, P(e); }
623
+ var j, L, A, R, I, N;
624
+ !function (e) { e.emailMagicLinks = "emailMagicLinks", e.oauth = "oauth", e.otp = "otp", e.crypto = "crypto", e.passwords = "passwords"; }(j || (j = {})), function (e) { e.Google = "google", e.Microsoft = "microsoft", e.Apple = "apple", e.Github = "github", e.GitLab = "gitlab", e.Facebook = "facebook", e.Discord = "discord", e.Slack = "slack", e.Amazon = "amazon", e.Bitbucket = "bitbucket", e.LinkedIn = "linkedin", e.Coinbase = "coinbase", e.Twitch = "twitch"; }(L || (L = {})), function (e) { 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"; }(A || (A = {})), function (e) { e.embedded = "embedded", e.floating = "floating"; }(R || (R = {})), function (e) { e.SMS = "sms", e.WhatsApp = "whatsapp", e.Email = "email"; }(I || (I = {})), function (e) { 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"; }(N || (N = {}));
625
+ var D, M, U = function (e) { w(r, E(Error)); var t = S(r); function r(e, n) { var o; return k(this, r), (o = t.call(this, e + "\n" + n)).message = e + "\n" + n, o.name = "SDKAPIUnreachableError", o.details = n, Object.setPrototypeOf(O(o), r.prototype), o; } return g(r); }(), B = function (e) { w(r, E(Error)); var t = S(r); function r(e, n) { var o; return k(this, r), (o = t.call(this)).name = "StytchSDKUsageError", o.message = "Invalid call to ".concat(e, "\n") + n, o; } return g(r); }(), K = function (e) { w(r, E(Error)); var t = S(r); function r(e) { var n, o; k(this, r), (n = t.call(this)).name = "StytchSDKSchemaError"; var i = null === (o = e.body) || void 0 === o ? void 0 : o.map((function (e) { return "".concat(e.dataPath, ": ").concat(e.message); })).join("\n"); return n.message = "[400] Request does not match expected schema\n".concat(i), n; } return g(r); }(), F = function (e) { w(r, E(Error)); var t = S(r); function r(e) { var n; k(this, r), (n = t.call(this)).name = "StytchSDKAPIError"; var o = e.status_code, i = e.error_type, a = e.error_message, s = e.error_url, c = e.request_id; return n.error_type = i, n.error_message = a, n.error_url = s, n.request_id = c, n.status_code = o, n.message = "[".concat(o, "] ").concat(i, "\n") + "".concat(a, "\n") + "See ".concat(s, " for more information.\n") + (c ? "request_id: ".concat(c, "\n") : ""), n; } return g(r); }(), q = ["unauthorized_credentials", "user_unauthenticated", "invalid_secret_authentication", "session_not_found"];
626
+ function z(e, t, r, n) { return new (r || (r = Promise))((function (o, i) { function a(e) { try {
627
+ c(n.next(e));
598
628
  }
599
- catch (t) {
600
- i(t);
601
- } } function s(t) { try {
602
- c(n.throw(t));
629
+ catch (e) {
630
+ i(e);
631
+ } } function s(e) { try {
632
+ c(n.throw(e));
603
633
  }
604
- catch (t) {
605
- i(t);
606
- } } function c(t) { var e; t.done ? o(t.value) : (e = t.value, e instanceof r ? e : new r((function (t) { t(e); }))).then(a, s); } c((n = n.apply(t, e || [])).next()); })); }
607
- !function (t) { t.BiometricsSensorError = "biometrics_sensor_error", t.DeviceCredentialsNotAllowed = "device_credentials_not_allowed", t.DeviceHardwareError = "device_hardware_error", t.InternalError = "internal_error", t.KeyInvalidated = "key_invalidated", t.KeystoreUnavailable = "keystore_unavailable", t.NoBiometricsEnrolled = "no_biometrics_enrolled", t.NoBiometricsRegistration = "no_biometrics_registration", t.SessionExpired = "session_expired", t.UserCancellation = "user_cancellation", t.UserLockedOut = "user_locked_out"; }(I || (I = {}));
608
- var q = new Uint8Array(16);
609
- function G() { if (!D && !(D = "undefined" != typeof crypto && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || "undefined" != typeof msCrypto && "function" == typeof msCrypto.getRandomValues && msCrypto.getRandomValues.bind(msCrypto)))
610
- throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported"); return D(q); }
611
- var W = /^(?:[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;
612
- for (var H = [], z = 0; z < 256; ++z)
613
- H.push((z + 256).toString(16).substr(1));
614
- function V(t) { var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 0, r = (H[t[e + 0]] + H[t[e + 1]] + H[t[e + 2]] + H[t[e + 3]] + "-" + H[t[e + 4]] + H[t[e + 5]] + "-" + H[t[e + 6]] + H[t[e + 7]] + "-" + H[t[e + 8]] + H[t[e + 9]] + "-" + H[t[e + 10]] + H[t[e + 11]] + H[t[e + 12]] + H[t[e + 13]] + H[t[e + 14]] + H[t[e + 15]]).toLowerCase(); if (!function (t) { return "string" == typeof t && W.test(t); }(r))
634
+ catch (e) {
635
+ i(e);
636
+ } } function c(e) { var t; e.done ? o(e.value) : (t = e.value, t instanceof r ? t : new r((function (e) { e(t); }))).then(a, s); } c((n = n.apply(e, t || [])).next()); })); }
637
+ !function (e) { 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"; }(D || (D = {}));
638
+ var G = new Uint8Array(16);
639
+ function W() { if (!M && !(M = "undefined" != typeof crypto && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || "undefined" != typeof msCrypto && "function" == typeof msCrypto.getRandomValues && msCrypto.getRandomValues.bind(msCrypto)))
640
+ throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported"); return M(G); }
641
+ var H = /^(?:[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;
642
+ for (var V = [], Y = 0; Y < 256; ++Y)
643
+ V.push((Y + 256).toString(16).substr(1));
644
+ function J(e) { var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 0, r = (V[e[t + 0]] + V[e[t + 1]] + V[e[t + 2]] + V[e[t + 3]] + "-" + V[e[t + 4]] + V[e[t + 5]] + "-" + V[e[t + 6]] + V[e[t + 7]] + "-" + V[e[t + 8]] + V[e[t + 9]] + "-" + V[e[t + 10]] + V[e[t + 11]] + V[e[t + 12]] + V[e[t + 13]] + V[e[t + 14]] + V[e[t + 15]]).toLowerCase(); if (!function (e) { return "string" == typeof e && H.test(e); }(r))
615
645
  throw TypeError("Stringified UUID is invalid"); return r; }
616
- function Y(t, e, r) { var n = (t = t || {}).random || (t.rng || G)(); if (n[6] = 15 & n[6] | 64, n[8] = 63 & n[8] | 128, e) {
646
+ function $(e, t, r) { var n = (e = e || {}).random || (e.rng || W)(); if (n[6] = 15 & n[6] | 64, n[8] = 63 & n[8] | 128, t) {
617
647
  r = r || 0;
618
648
  for (var o = 0; o < 16; ++o)
619
- e[r + o] = n[o];
620
- return e;
621
- } return V(n); }
622
- var J = ["[Stytch]"], $ = { debug: function () { return false; }, log: function () { for (var t, e = arguments.length, r = new Array(e), n = 0; n < e; n++)
623
- r[n] = arguments[n]; return (t = console).log.apply(t, J.concat(r)); }, warn: function () { for (var t, e = arguments.length, r = new Array(e), n = 0; n < e; n++)
624
- r[n] = arguments[n]; return (t = console).warn.apply(t, J.concat(r)); }, error: function () { for (var t, e = arguments.length, r = new Array(e), n = 0; n < e; n++)
625
- r[n] = arguments[n]; return (t = console).error.apply(t, J.concat(r)); } }, X = "\nYou can find your public token at https://stytch.com/dashboard/api-keys.", Z = function (t) { var e = { isObject: function (r, n) { var o = "object" === p(n) && !Array.isArray(n) && null !== n; if (!o)
626
- throw new M(t, r + " must be an object."); return e; }, isOptionalObject: function (t, r) { return void 0 === r ? e : e.isObject(t, r); }, isString: function (r, n) { if ("string" != typeof n)
627
- throw new M(t, r + " must be a string."); return e; }, isOptionalString: function (t, r) { return void 0 === r ? e : e.isString(t, r); }, isStringArray: function (r, n) { if (!Array.isArray(n))
628
- throw new M(t, r + " must be an array of strings."); var o, i = function (t, e) { var r = "undefined" != typeof Symbol && t[Symbol.iterator] || t["@@iterator"]; if (!r) {
629
- if (Array.isArray(t) || (r = d(t)) || e && t && "number" == typeof t.length) {
630
- r && (t = r);
649
+ t[r + o] = n[o];
650
+ return t;
651
+ } return J(n); }
652
+ var X = ["[Stytch]"], Z = { debug: function () { return false; }, log: function () { for (var e, t = arguments.length, r = new Array(t), n = 0; n < t; n++)
653
+ r[n] = arguments[n]; return (e = console).log.apply(e, X.concat(r)); }, warn: function () { for (var e, t = arguments.length, r = new Array(t), n = 0; n < t; n++)
654
+ r[n] = arguments[n]; return (e = console).warn.apply(e, X.concat(r)); }, error: function () { for (var e, t = arguments.length, r = new Array(t), n = 0; n < t; n++)
655
+ r[n] = arguments[n]; return (e = console).error.apply(e, X.concat(r)); } }, Q = "\nYou can find your public token at https://stytch.com/dashboard/api-keys.", ee = function (e) { var t = { isObject: function (r, n) { var o = "object" === v(n) && !Array.isArray(n) && null !== n; if (!o)
656
+ throw new B(e, r + " must be an object."); return t; }, isOptionalObject: function (e, r) { return void 0 === r ? t : t.isObject(e, r); }, isString: function (r, n) { if ("string" != typeof n)
657
+ throw new B(e, r + " must be a string."); return t; }, isOptionalString: function (e, r) { return void 0 === r ? t : t.isString(e, r); }, isStringArray: function (r, n) { if (!Array.isArray(n))
658
+ throw new B(e, r + " must be an array of strings."); var o, i = function (e, t) { var r = "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"]; if (!r) {
659
+ if (Array.isArray(e) || (r = m(e)) || t && e && "number" == typeof e.length) {
660
+ r && (e = r);
631
661
  var n = 0, o = function () { };
632
- return { s: o, n: function () { return n >= t.length ? { done: !0 } : { done: !1, value: t[n++] }; }, e: function (t) { throw t; }, f: o };
662
+ return { s: o, n: function () { return n >= e.length ? { done: !0 } : { done: !1, value: e[n++] }; }, e: function (e) { throw e; }, f: o };
633
663
  }
634
664
  throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
635
- } var i, a = !0, s = !1; return { s: function () { r = r.call(t); }, n: function () { var t = r.next(); return a = t.done, t; }, e: function (t) { s = !0, i = t; }, f: function () { try {
665
+ } var i, a = !0, s = !1; return { s: function () { r = r.call(e); }, n: function () { var e = r.next(); return a = e.done, e; }, e: function (e) { s = !0, i = e; }, f: function () { try {
636
666
  a || null == r.return || r.return();
637
667
  }
638
668
  finally {
@@ -641,298 +671,336 @@ var J = ["[Stytch]"], $ = { debug: function () { return false; }, log: function
641
671
  } } }; }(n); try {
642
672
  for (i.s(); !(o = i.n()).done;) {
643
673
  if ("string" != typeof o.value)
644
- throw new M(t, r + " must be an array of strings.");
674
+ throw new B(e, r + " must be an array of strings.");
645
675
  }
646
676
  }
647
- catch (t) {
648
- i.e(t);
677
+ catch (e) {
678
+ i.e(e);
649
679
  }
650
680
  finally {
651
681
  i.f();
652
- } return e; }, isNumber: function (r, n) { if ("number" != typeof n)
653
- throw new M(t, r + " must be a number."); return e; }, isOptionalNumber: function (t, r) { return void 0 === r ? e : e.isNumber(t, r); } }; return e; };
654
- function Q(t) { var e = t.method, r = t.errorMessage, n = t.finalURL, o = t.basicAuthHeader, i = t.xSDKClientHeader, a = t.xSDKParentHostHeader, s = t.body; return F(this, void 0, void 0, y().mark((function t() { var c, u, l, f, h; return y().wrap((function (t) { for (;;)
655
- switch (t.prev = t.next) {
656
- case 0: return c = { Authorization: o, "Content-Type": "application/json", "X-SDK-Client": i }, a && (c["X-SDK-Parent-Host"] = a), u = { method: e, headers: c, body: s && JSON.stringify(s) }, t.prev = 3, t.next = 6, fetch(n, u);
682
+ } return t; }, isOptionalStringArray: function (e, r) { return void 0 === r ? t : t.isStringArray(e, r); }, isNumber: function (r, n) { if ("number" != typeof n)
683
+ throw new B(e, r + " must be a number."); return t; }, isOptionalNumber: function (e, r) { return void 0 === r ? t : t.isNumber(e, r); } }; return t; };
684
+ function te(e) { var t = e.method, r = e.errorMessage, n = e.finalURL, o = e.basicAuthHeader, i = e.xSDKClientHeader, a = e.xSDKParentHostHeader, s = e.body; return z(this, void 0, void 0, _().mark((function e() { var c, u, l, h, f; return _().wrap((function (e) { for (;;)
685
+ switch (e.prev = e.next) {
686
+ case 0: return c = { Authorization: o, "Content-Type": "application/json", "X-SDK-Client": i }, a && (c["X-SDK-Parent-Host"] = a), u = { method: t, headers: c, body: s && JSON.stringify(s) }, e.prev = 3, e.next = 6, fetch(n, u);
657
687
  case 6:
658
- l = t.sent, t.next = 14;
688
+ l = e.sent, e.next = 14;
659
689
  break;
660
690
  case 9:
661
- if (t.prev = 9, t.t0 = t.catch(3), "Failed to fetch" !== t.t0.message) {
662
- t.next = 13;
691
+ if (e.prev = 9, e.t0 = e.catch(3), "Failed to fetch" !== e.t0.message) {
692
+ e.next = 13;
663
693
  break;
664
694
  }
665
- throw new N(r, "Unable to contact the Stytch servers. Are you online?");
666
- case 13: throw t.t0;
695
+ throw new U(r, "Unable to contact the Stytch servers. Are you online?");
696
+ case 13: throw e.t0;
667
697
  case 14:
668
698
  if (200 === l.status) {
669
- t.next = 27;
699
+ e.next = 27;
670
700
  break;
671
701
  }
672
- return t.prev = 15, t.next = 18, l.json();
702
+ return e.prev = 15, e.next = 18, l.json();
673
703
  case 18:
674
- f = t.sent, t.next = 24;
704
+ h = e.sent, e.next = 24;
675
705
  break;
676
- case 21: throw t.prev = 21, t.t1 = t.catch(15), new N(r, "Invalid or no response from server");
706
+ case 21: throw e.prev = 21, e.t1 = e.catch(15), new U(r, "Invalid or no response from server");
677
707
  case 24:
678
- if (!("body" in f || "params" in f || "query" in f)) {
679
- t.next = 26;
708
+ if (!("body" in h || "params" in h || "query" in h)) {
709
+ e.next = 26;
680
710
  break;
681
711
  }
682
- throw new U(f);
683
- case 26: throw new B(f);
684
- case 27: return t.prev = 27, t.next = 30, l.json();
685
- case 30: return h = t.sent, t.abrupt("return", h.data);
686
- case 34: throw t.prev = 34, t.t2 = t.catch(27), new N(r, "Invalid response from the Stytch servers.");
712
+ throw new K(h);
713
+ case 26: throw new F(h);
714
+ case 27: return e.prev = 27, e.next = 30, l.json();
715
+ case 30: return f = e.sent, e.abrupt("return", f.data);
716
+ case 34: throw e.prev = 34, e.t2 = e.catch(27), new U(r, "Invalid response from the Stytch servers.");
687
717
  case 37:
688
- case "end": return t.stop();
689
- } }), t, null, [[3, 9], [15, 21], [27, 34]]); }))); }
690
- var tt = function () { function t(e, r) { var n = this; g(this, t), this._subscriptionService = e, this._headlessSessionClient = r, this._onDataChange = function (t) { (null == t ? void 0 : t.session) ? n.scheduleBackgroundRefresh() : n.cancelBackgroundRefresh(); }, this._reauthenticateWithBackoff = function () { var e = function (e) { return function (r) { return t.isUnrecoverableError(r) ? Promise.reject(r) : new Promise((function (r) { return setTimeout(r, t.timeoutForAttempt(e)); })).then((function () { return n._headlessSessionClient.authenticate(); })); }; }; return n._headlessSessionClient.authenticate().catch(e(0)).catch(e(1)).catch(e(2)).catch(e(3)).catch(e(4)); }, this.timeout = null, this._subscriptionService.subscribeToState(this._onDataChange); } return b(t, [{ key: "performBackgroundRefresh", value: function () { var t = this; this._reauthenticateWithBackoff().then((function () { t.scheduleBackgroundRefresh(); })).catch((function () { $.warn("Session background refresh failed. Signalling to app that user is logged out."), t._subscriptionService.destroyState(); })); } }, { key: "scheduleBackgroundRefresh", value: function () { var e = this; this.cancelBackgroundRefresh(), this.timeout = setTimeout((function () { e.performBackgroundRefresh(); }), t.REFRESH_INTERVAL_MS); } }, { key: "cancelBackgroundRefresh", value: function () { null !== this.timeout && (clearTimeout(this.timeout), this.timeout = null); } }], [{ key: "timeoutForAttempt", value: function (t) { return Math.floor(350 * Math.random()) - 175 + 2e3 * Math.pow(2, t); } }, { key: "isUnrecoverableError", value: function (t) { return K.includes(t.error_type); } }]), t; }();
691
- tt.REFRESH_INTERVAL_MS = 18e4;
692
- var et = 15, rt = 800, nt = function () { function t(e) { g(this, t), this.maxBatchSize = e.maxBatchSize, this.logEventURL = e.logEventURL, setInterval(this.flush.bind(this), e.intervalDurationMs), this.batch = []; } return b(t, [{ key: "logEvent", value: function (t, e) { this.batch.push({ telemetry: t, event: e }), this.batch.length >= this.maxBatchSize && this.flush(); } }, { key: "flush", value: function () { return F(this, void 0, void 0, y().mark((function t() { var e; return y().wrap((function (t) { for (;;)
693
- switch (t.prev = t.next) {
718
+ case "end": return e.stop();
719
+ } }), e, null, [[3, 9], [15, 21], [27, 34]]); }))); }
720
+ var re = function () { function e(t, r) { var n = this; k(this, e), this._subscriptionService = t, this._headlessSessionClient = r, this._onDataChange = function (e) { (null == e ? void 0 : e.session) ? n.scheduleBackgroundRefresh() : n.cancelBackgroundRefresh(); }, this._reauthenticateWithBackoff = function () { var t = function (t) { return function (r) { return e.isUnrecoverableError(r) ? Promise.reject(r) : new Promise((function (r) { return setTimeout(r, e.timeoutForAttempt(t)); })).then((function () { return n._headlessSessionClient.authenticate(); })); }; }; return n._headlessSessionClient.authenticate().catch(t(0)).catch(t(1)).catch(t(2)).catch(t(3)).catch(t(4)); }, this.timeout = null, this._subscriptionService.subscribeToState(this._onDataChange); } return g(e, [{ key: "performBackgroundRefresh", value: function () { var e = this; this._reauthenticateWithBackoff().then((function () { e.scheduleBackgroundRefresh(); })).catch((function () { Z.warn("Session background refresh failed. Signalling to app that user is logged out."), e._subscriptionService.destroyState(); })); } }, { key: "scheduleBackgroundRefresh", value: function () { var t = this; this.cancelBackgroundRefresh(), this.timeout = setTimeout((function () { t.performBackgroundRefresh(); }), e.REFRESH_INTERVAL_MS); } }, { key: "cancelBackgroundRefresh", value: function () { null !== this.timeout && (clearTimeout(this.timeout), this.timeout = null); } }], [{ key: "timeoutForAttempt", value: function (e) { return Math.floor(350 * Math.random()) - 175 + 2e3 * Math.pow(2, e); } }, { key: "isUnrecoverableError", value: function (e) { return q.includes(e.error_type); } }]), e; }();
721
+ re.REFRESH_INTERVAL_MS = 18e4;
722
+ var ne = 15, oe = 800, ie = function () { function e(t) { k(this, e), this.maxBatchSize = t.maxBatchSize, this.logEventURL = t.logEventURL, setInterval(this.flush.bind(this), t.intervalDurationMs), this.batch = []; } return g(e, [{ key: "logEvent", value: function (e, t) { this.batch.push({ telemetry: e, event: t }), this.batch.length >= this.maxBatchSize && this.flush(); } }, { key: "flush", value: function () { return z(this, void 0, void 0, _().mark((function e() { var t; return _().wrap((function (e) { for (;;)
723
+ switch (e.prev = e.next) {
694
724
  case 0:
695
725
  if (this.batch.length) {
696
- t.next = 2;
726
+ e.next = 2;
697
727
  break;
698
728
  }
699
- return t.abrupt("return");
700
- case 2: return e = this.batch, this.batch = [], t.prev = 4, t.next = 7, fetch(this.logEventURL, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(e) });
729
+ return e.abrupt("return");
730
+ case 2: return t = this.batch, this.batch = [], e.prev = 4, e.next = 7, fetch(this.logEventURL, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(t) });
701
731
  case 7:
702
- t.next = 11;
732
+ e.next = 11;
703
733
  break;
704
- case 9: t.prev = 9, t.t0 = t.catch(4);
734
+ case 9: e.prev = 9, e.t0 = e.catch(4);
705
735
  case 11:
706
- case "end": return t.stop();
707
- } }), t, this, [[4, 9]]); }))); } }]), t; }();
736
+ case "end": return e.stop();
737
+ } }), e, this, [[4, 9]]); }))); } }]), e; }();
708
738
  Promise.resolve({ pkceRequiredForEmailMagicLinks: !1 }), Promise.resolve({ pkceRequiredForPasswordResets: !1 });
709
- var ot = Promise.resolve({ pkceRequiredForEmailMagicLinks: !1 }), it = function () { function t(e, r, n) { var o = this, i = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : ot; g(this, t), this._networkClient = e, this._subscriptionService = r, this._pkceManager = n, this._config = i, this.email = { loginOrSignup: function (t) { return F(o, void 0, void 0, y().mark((function e() { var r, n, o, i; return y().wrap((function (e) { for (;;)
710
- switch (e.prev = e.next) {
711
- case 0: return Z("stytch.magicLinks.email.loginOrSignup").isString("email", t.email_address).isString("organization_id", t.organization_id).isOptionalString("login_redirect_url", t.login_redirect_url).isOptionalString("login_template_id", t.login_template_id).isOptionalString("signup_redirect_url", t.signup_redirect_url).isOptionalString("signup_template_id", t.signup_template_id), e.next = 3, this._config;
712
- case 3:
713
- if (r = e.sent, n = r.pkceRequiredForEmailMagicLinks, o = void 0, !n) {
714
- e.next = 10;
715
- break;
716
- }
717
- return e.next = 9, this.getCodeChallenge();
718
- case 9: o = e.sent;
719
- case 10: return i = Object.assign(Object.assign({}, t), { pkce_code_challenge: o }), e.abrupt("return", this._networkClient.fetchSDK({ url: "/b2b/magic_links/email/login_or_signup", body: i, errorMessage: "Failed to send magic link", method: "POST" }));
720
- case 12:
721
- case "end": return e.stop();
722
- } }), e, this); }))); } }, this.authenticate = function (t) { return F(o, void 0, void 0, y().mark((function e() { var r, n, o; return y().wrap((function (e) { for (;;)
723
- switch (e.prev = e.next) {
724
- case 0: return Z("stytch.magicLinks.authenticate").isString("magic_links_token", t.magic_links_token).isNumber("session_duration_minutes", t.session_duration_minutes), e.next = 3, this._pkceManager.getPKPair();
725
- case 3: return r = e.sent, n = Object.assign({ pkce_code_verifier: null == r ? void 0 : r.code_verifier }, t), e.next = 7, this._networkClient.fetchSDK({ url: "/b2b/magic_links/authenticate", body: n, errorMessage: "Failed to authenticate token.", method: "POST" });
726
- case 7: return o = e.sent, this._pkceManager.clearPKPair(), this._subscriptionService.updateStateAndTokens({ state: { session: o.member_session, member: o.member }, session_token: o.session_token, session_jwt: o.session_jwt }), e.abrupt("return", o);
727
- case 11:
728
- case "end": return e.stop();
729
- } }), e, this); }))); }; } return b(t, [{ key: "getCodeChallenge", value: function () { return F(this, void 0, void 0, y().mark((function t() { var e; return y().wrap((function (t) { for (;;)
739
+ var ae = Promise.resolve({ pkceRequiredForEmailMagicLinks: !1 }), se = function () { function e(t, r, n) { var o = this, i = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : ae; k(this, e), this._networkClient = t, this._subscriptionService = r, this._pkceManager = n, this._config = i, this.email = { loginOrSignup: function (e) { return z(o, void 0, void 0, _().mark((function t() { var r, n; return _().wrap((function (t) { for (;;)
740
+ switch (t.prev = t.next) {
741
+ case 0: return ee("stytch.magicLinks.email.loginOrSignup").isString("email", e.email_address).isString("organization_id", e.organization_id).isOptionalString("login_redirect_url", e.login_redirect_url).isOptionalString("login_template_id", e.login_template_id).isOptionalString("signup_redirect_url", e.signup_redirect_url).isOptionalString("signup_template_id", e.signup_template_id), t.next = 3, this.getCodeChallenge();
742
+ case 3: return r = t.sent, n = Object.assign(Object.assign({}, e), { pkce_code_challenge: r }), t.abrupt("return", this._networkClient.fetchSDK({ url: "/b2b/magic_links/email/login_or_signup", body: n, errorMessage: "Failed to send magic link", method: "POST" }));
743
+ case 6:
744
+ case "end": return t.stop();
745
+ } }), t, this); }))); }, discovery: { send: function (e) { return z(o, void 0, void 0, _().mark((function t() { var r, n; return _().wrap((function (t) { for (;;)
730
746
  switch (t.prev = t.next) {
731
- case 0: return t.next = 2, this._pkceManager.getPKPair();
732
- case 2:
733
- if (!(e = t.sent)) {
734
- t.next = 5;
735
- break;
736
- }
737
- return t.abrupt("return", e.code_challenge);
738
- case 5: return t.next = 7, this._pkceManager.startPKCETransaction();
739
- case 7: return e = t.sent, t.abrupt("return", e.code_challenge);
740
- case 9:
747
+ case 0: return ee("stytch.magicLinks.email.discovery.send").isString("email_address", e.email_address).isOptionalString("discovery_redirect_url", e.discovery_redirect_url).isOptionalString("login_template_id", e.login_template_id), t.next = 3, this.getCodeChallenge();
748
+ case 3: return r = t.sent, n = Object.assign(Object.assign({}, e), { pkce_code_challenge: r }), t.abrupt("return", this._networkClient.fetchSDK({ url: "/b2b/magic_links/email/discovery/send", body: n, errorMessage: "Failed to send discovery magic link", method: "POST" }));
749
+ case 6:
741
750
  case "end": return t.stop();
742
- } }), t, this); }))); } }]), t; }(), at = b((function t(e, r) { var n = this; g(this, t), this._networkClient = e, this._subscriptionService = r, this.get = function () { return F(n, void 0, void 0, y().mark((function t() { var e; return y().wrap((function (t) { for (;;)
751
+ } }), t, this); }))); } } }, this.authenticate = function (e) { return z(o, void 0, void 0, _().mark((function t() { var r, n, o; return _().wrap((function (t) { for (;;)
743
752
  switch (t.prev = t.next) {
744
- case 0: return t.next = 2, this._networkClient.fetchSDK({ url: "/b2b/organizations/members/me", errorMessage: "Failed to retrieve member info.", method: "GET" });
745
- case 2: return e = t.sent, this._subscriptionService.updateMember(e.member), t.abrupt("return", e.member);
746
- case 5:
753
+ case 0: return ee("stytch.magicLinks.authenticate").isString("magic_links_token", e.magic_links_token).isNumber("session_duration_minutes", e.session_duration_minutes), t.next = 3, this._pkceManager.getPKPair();
754
+ case 3: return r = t.sent, n = Object.assign({ pkce_code_verifier: null == r ? void 0 : r.code_verifier }, e), t.next = 7, this._networkClient.fetchSDK({ url: "/b2b/magic_links/authenticate", body: n, errorMessage: "Failed to authenticate token", method: "POST" });
755
+ case 7: return o = t.sent, this._pkceManager.clearPKPair(), this._subscriptionService.updateStateAndTokens({ state: { session: o.member_session, member: o.member }, session_token: o.session_token, session_jwt: o.session_jwt }), t.abrupt("return", o);
756
+ case 11:
747
757
  case "end": return t.stop();
748
- } }), t, this); }))); }, this.getSync = function () { return n._subscriptionService.getMember(); }, this.onChange = function (t) { return n._subscriptionService.subscribeToState((function (e) { var r; return t(null !== (r = null == e ? void 0 : e.member) && void 0 !== r ? r : null); })); }; })), st = function () { function t(e, r, n, o, i) { g(this, t), this._networkClient = e, this._subscriptionService = r, this._pkceManager = n, this._dynamicConfig = o, this._config = i; } return b(t, [{ key: "authenticate", value: function (t) { return F(this, void 0, void 0, y().mark((function e() { var r, n; return y().wrap((function (e) { for (;;)
758
+ } }), t, this); }))); }, this.discovery = { authenticate: function (e) { return z(o, void 0, void 0, _().mark((function t() { var r, n, o; return _().wrap((function (t) { for (;;)
759
+ switch (t.prev = t.next) {
760
+ case 0: return ee("stytch.magicLinks.discovery.authenticate").isString("discovery_magic_links_token", e.discovery_magic_links_token), t.next = 3, this._pkceManager.getPKPair();
761
+ case 3: return r = t.sent, n = Object.assign({ pkce_code_verifier: null == r ? void 0 : r.code_verifier }, e), t.next = 7, this._networkClient.fetchSDK({ url: "/b2b/magic_links/discovery/authenticate", body: n, errorMessage: "Failed to authenticate intermediate magic link token", method: "POST" });
762
+ case 7: return o = t.sent, this._pkceManager.clearPKPair(), t.abrupt("return", o);
763
+ case 10:
764
+ case "end": return t.stop();
765
+ } }), t, this); }))); } }; } return g(e, [{ key: "getCodeChallenge", value: function () { return z(this, void 0, void 0, _().mark((function e() { var t, r; return _().wrap((function (e) { for (;;)
749
766
  switch (e.prev = e.next) {
750
- case 0: return Z("stytch.sso.authenticate").isString("sso_token", t.sso_token).isNumber("session_duration_minutes", t.session_duration_minutes), e.next = 3, this._pkceManager.getPKPair();
751
- case 3: return (r = e.sent) || $.warn("No code verifier found in local storage for SSO 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."), e.next = 7, this._networkClient.fetchSDK({ url: "/sso/authenticate", method: "POST", body: Object.assign({ pkce_code_verifier: null == r ? void 0 : r.code_verifier }, t), errorMessage: "Failed to authenticate token" });
752
- case 7: return n = e.sent, this._pkceManager.clearPKPair(), this._subscriptionService.updateStateAndTokens({ state: { session: n.member_session, member: n.member }, session_token: n.session_token, session_jwt: n.session_jwt }), e.abrupt("return", n);
753
- case 11:
767
+ case 0: return e.next = 2, this._config;
768
+ case 2:
769
+ if (t = e.sent, t.pkceRequiredForEmailMagicLinks) {
770
+ e.next = 6;
771
+ break;
772
+ }
773
+ return e.abrupt("return", void 0);
774
+ case 6: return e.next = 8, this._pkceManager.getPKPair();
775
+ case 8:
776
+ if (!(r = e.sent)) {
777
+ e.next = 11;
778
+ break;
779
+ }
780
+ return e.abrupt("return", r.code_challenge);
781
+ case 11: return e.next = 13, this._pkceManager.startPKCETransaction();
782
+ case 13: return r = e.sent, e.abrupt("return", r.code_challenge);
783
+ case 15:
754
784
  case "end": return e.stop();
755
- } }), e, this); }))); } }, { key: "getBaseApiUrl", value: function () { return F(this, void 0, void 0, y().mark((function t() { return y().wrap((function (t) { for (;;)
785
+ } }), e, this); }))); } }]), e; }(), ce = g((function e(t, r) { var n = this; k(this, e), this._networkClient = t, this._subscriptionService = r, this.get = function () { return z(n, void 0, void 0, _().mark((function e() { var t; return _().wrap((function (e) { for (;;)
786
+ switch (e.prev = e.next) {
787
+ case 0: return e.next = 2, this._networkClient.fetchSDK({ url: "/b2b/organizations/members/me", errorMessage: "Failed to retrieve member info.", method: "GET" });
788
+ case 2: return t = e.sent, this._subscriptionService.updateMember(t.member), e.abrupt("return", t.member);
789
+ case 5:
790
+ case "end": return e.stop();
791
+ } }), e, this); }))); }, this.getSync = function () { return n._subscriptionService.getMember(); }, this.onChange = function (e) { return n._subscriptionService.subscribeToState((function (t) { var r; return e(null !== (r = null == t ? void 0 : t.member) && void 0 !== r ? r : null); })); }; })), ue = function () { function e(t, r, n, o, i) { k(this, e), this._networkClient = t, this._subscriptionService = r, this._pkceManager = n, this._dynamicConfig = o, this._config = i; } return g(e, [{ key: "authenticate", value: function (e) { return z(this, void 0, void 0, _().mark((function t() { var r, n; return _().wrap((function (t) { for (;;)
756
792
  switch (t.prev = t.next) {
793
+ case 0: return ee("stytch.sso.authenticate").isString("sso_token", e.sso_token).isNumber("session_duration_minutes", e.session_duration_minutes), t.next = 3, this._pkceManager.getPKPair();
794
+ case 3: return (r = t.sent) || Z.warn("No code verifier found in local storage for SSO 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."), t.next = 7, this._networkClient.fetchSDK({ url: "/sso/authenticate", method: "POST", body: Object.assign({ pkce_code_verifier: null == r ? void 0 : r.code_verifier }, e), errorMessage: "Failed to authenticate token" });
795
+ case 7: return n = t.sent, this._pkceManager.clearPKPair(), this._subscriptionService.updateStateAndTokens({ state: { session: n.member_session, member: n.member }, session_token: n.session_token, session_jwt: n.session_jwt }), t.abrupt("return", n);
796
+ case 11:
797
+ case "end": return t.stop();
798
+ } }), t, this); }))); } }, { key: "getBaseApiUrl", value: function () { return z(this, void 0, void 0, _().mark((function e() { return _().wrap((function (e) { for (;;)
799
+ switch (e.prev = e.next) {
757
800
  case 0:
758
801
  if (!this._config.publicToken.includes("public-token-test")) {
759
- t.next = 2;
802
+ e.next = 2;
760
803
  break;
761
804
  }
762
- return t.abrupt("return", this._config.testAPIURL);
763
- case 2: return t.abrupt("return", this._config.liveAPIURL);
805
+ return e.abrupt("return", this._config.testAPIURL);
806
+ case 2: return e.abrupt("return", this._config.liveAPIURL);
764
807
  case 3:
765
- case "end": return t.stop();
766
- } }), t, this); }))); } }, { key: "start", value: function (t) { var e = t.connection_id, r = t.login_redirect_url, n = t.signup_redirect_url; return F(this, void 0, void 0, y().mark((function t() { var o, i, a, s, c; return y().wrap((function (t) { for (;;)
767
- switch (t.prev = t.next) {
768
- case 0: return t.next = 2, this._dynamicConfig;
769
- case 2: return o = t.sent, i = o.pkceRequiredForSso, t.next = 6, this.getBaseApiUrl();
808
+ case "end": return e.stop();
809
+ } }), e, this); }))); } }, { key: "start", value: function (e) { var t = e.connection_id, r = e.login_redirect_url, n = e.signup_redirect_url; return z(this, void 0, void 0, _().mark((function e() { var o, i, a, s, c; return _().wrap((function (e) { for (;;)
810
+ switch (e.prev = e.next) {
811
+ case 0: return e.next = 2, this._dynamicConfig;
812
+ case 2: return o = e.sent, i = o.pkceRequiredForSso, e.next = 6, this.getBaseApiUrl();
770
813
  case 6:
771
- if (a = t.sent, (s = new URL("".concat(a, "/v1/public/sso/start"))).searchParams.set("public_token", this._config.publicToken), s.searchParams.set("connection_id", e), !i) {
772
- t.next = 17;
814
+ if (a = e.sent, (s = new URL("".concat(a, "/v1/public/sso/start"))).searchParams.set("public_token", this._config.publicToken), s.searchParams.set("connection_id", t), !i) {
815
+ e.next = 17;
773
816
  break;
774
817
  }
775
- return t.next = 13, this._pkceManager.startPKCETransaction();
818
+ return e.next = 13, this._pkceManager.startPKCETransaction();
776
819
  case 13:
777
- c = t.sent, s.searchParams.set("pkce_code_challenge", c.code_challenge), t.next = 18;
820
+ c = e.sent, s.searchParams.set("pkce_code_challenge", c.code_challenge), e.next = 18;
778
821
  break;
779
822
  case 17: this._pkceManager.clearPKPair();
780
823
  case 18: r && s.searchParams.set("login_redirect_url", r), n && s.searchParams.set("signup_redirect_url", n), window.location.href = s.toString();
781
824
  case 21:
782
- case "end": return t.stop();
783
- } }), t, this); }))); } }]), t; }(), ct = b((function t(e) { var r = this; g(this, t), this._networkClient = e, this.get = function () { return F(r, void 0, void 0, y().mark((function t() { var e; return y().wrap((function (t) { for (;;)
784
- switch (t.prev = t.next) {
785
- case 0: return t.next = 2, this._networkClient.fetchSDK({ url: "/b2b/organizations/me", errorMessage: "Failed to retrieve organization info.", method: "GET" });
786
- case 2: return e = t.sent, t.abrupt("return", e.organization);
825
+ case "end": return e.stop();
826
+ } }), e, this); }))); } }]), e; }(), le = g((function e(t) { var r = this; k(this, e), this._networkClient = t, this.get = function () { return z(r, void 0, void 0, _().mark((function e() { var t; return _().wrap((function (e) { for (;;)
827
+ switch (e.prev = e.next) {
828
+ case 0: return e.next = 2, this._networkClient.fetchSDK({ url: "/b2b/organizations/me", errorMessage: "Failed to retrieve organization info.", method: "GET" });
829
+ case 2: return t = e.sent, e.abrupt("return", t.organization);
787
830
  case 4:
788
- case "end": return t.stop();
789
- } }), t, this); }))); }; })), ut = function () { function t(e, r) { var n = this; g(this, t), this._networkClient = e, this._subscriptionService = r, this.getSync = function () { return n._subscriptionService.getSession(); }, this.onChange = function (t) { return n._subscriptionService.subscribeToState((function (e) { var r; return t(null !== (r = null == e ? void 0 : e.session) && void 0 !== r ? r : null); })); }, this.revoke = function () { return F(n, void 0, void 0, y().mark((function t() { var e; return y().wrap((function (t) { for (;;)
831
+ case "end": return e.stop();
832
+ } }), e, this); }))); }; })), he = function () { function e(t, r) { var n = this; k(this, e), this._networkClient = t, this._subscriptionService = r, this.getSync = function () { return n._subscriptionService.getSession(); }, this.onChange = function (e) { return n._subscriptionService.subscribeToState((function (t) { var r; return e(null !== (r = null == t ? void 0 : t.session) && void 0 !== r ? r : null); })); }, this.revoke = function (e) { return z(n, void 0, void 0, _().mark((function t() { var r; return _().wrap((function (t) { for (;;)
790
833
  switch (t.prev = t.next) {
791
- case 0: return t.next = 2, this._networkClient.fetchSDK({ url: "/b2b/sessions/revoke", errorMessage: "Error revoking session", method: "POST" });
792
- case 2:
793
- e = t.sent;
794
- try {
795
- this._subscriptionService.destroyState();
796
- }
797
- catch (t) { }
798
- return t.abrupt("return", e);
799
- case 5:
834
+ case 0: return t.prev = 0, t.next = 3, this._networkClient.fetchSDK({ url: "/b2b/sessions/revoke", errorMessage: "Error revoking session", method: "POST" });
835
+ case 3: return r = t.sent, this._subscriptionService.destroyState(), t.abrupt("return", r);
836
+ case 8: throw t.prev = 8, t.t0 = t.catch(0), ((null == e ? void 0 : e.forceClear) || q.includes(t.t0.error_type)) && this._subscriptionService.destroyState(), t.t0;
837
+ case 12:
800
838
  case "end": return t.stop();
801
- } }), t, this); }))); }, this.authenticate = function (t) { return F(n, void 0, void 0, y().mark((function e() { var r, n; return y().wrap((function (e) { for (;;)
802
- switch (e.prev = e.next) {
803
- case 0: return e.prev = 0, r = { session_duration_minutes: null == t ? void 0 : t.session_duration_minutes }, e.next = 4, this._networkClient.fetchSDK({ url: "/b2b/sessions/authenticate", body: r, errorMessage: "Error authenticating session", method: "POST" });
804
- case 4: return n = e.sent, this._subscriptionService.updateStateAndTokens({ state: { session: n.member_session, member: n.member }, session_token: n.session_token, session_jwt: n.session_jwt }), e.abrupt("return", n);
805
- case 9: throw e.prev = 9, e.t0 = e.catch(0), K.includes(e.t0.error_type) && this._subscriptionService.destroyState(), e.t0;
839
+ } }), t, this, [[0, 8]]); }))); }, this.authenticate = function (e) { return z(n, void 0, void 0, _().mark((function t() { var r, n; return _().wrap((function (t) { for (;;)
840
+ switch (t.prev = t.next) {
841
+ case 0: return t.prev = 0, r = { session_duration_minutes: null == e ? void 0 : e.session_duration_minutes }, t.next = 4, this._networkClient.fetchSDK({ url: "/b2b/sessions/authenticate", body: r, errorMessage: "Error authenticating session", method: "POST" });
842
+ case 4: return n = t.sent, this._subscriptionService.updateStateAndTokens({ state: { session: n.member_session, member: n.member }, session_token: n.session_token, session_jwt: n.session_jwt }), t.abrupt("return", n);
843
+ case 9: throw t.prev = 9, t.t0 = t.catch(0), q.includes(t.t0.error_type) && this._subscriptionService.destroyState(), t.t0;
806
844
  case 13:
807
- case "end": return e.stop();
808
- } }), e, this, [[0, 9]]); }))); }; } return b(t, [{ key: "getTokens", value: function () { return this._subscriptionService.getTokens(); } }]), t; }(), lt = Symbol.for("stytch__internal"), ft = function (t, e) { Object.assign(t, function (t, e, r) { return (e = f(e)) in t ? Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }) : t[e] = r, t; }({}, lt, e)); };
809
- function ht(t, e, r, n) { return new (r || (r = Promise))((function (o, i) { function a(t) { try {
810
- c(n.next(t));
845
+ case "end": return t.stop();
846
+ } }), t, this, [[0, 9]]); }))); }, this.exchange = function (e) { return z(n, void 0, void 0, _().mark((function t() { var r; return _().wrap((function (t) { for (;;)
847
+ switch (t.prev = t.next) {
848
+ case 0: return ee("stytch.sessions.exchange").isString("organization_id", e.organization_id).isNumber("session_duration_minutes", e.session_duration_minutes), t.prev = 1, t.next = 4, this._networkClient.fetchSDK({ url: "/b2b/sessions/exchange", body: e, errorMessage: "Failed to exchange session", method: "POST" });
849
+ case 4: return r = t.sent, this._subscriptionService.updateStateAndTokens({ state: { session: r.member_session, member: r.member }, session_token: r.session_token, session_jwt: r.session_jwt }), t.abrupt("return", r);
850
+ case 9: throw t.prev = 9, t.t0 = t.catch(1), t.t0;
851
+ case 12:
852
+ case "end": return t.stop();
853
+ } }), t, this, [[1, 9]]); }))); }; } return g(e, [{ key: "getTokens", value: function () { return this._subscriptionService.getTokens(); } }]), e; }(), fe = g((function e(t, r) { var n = this; k(this, e), this._networkClient = t, this._subscriptionService = r, this.organizations = { list: function (e) { return z(n, void 0, void 0, _().mark((function t() { return _().wrap((function (t) { for (;;)
854
+ switch (t.prev = t.next) {
855
+ case 0: return ee("stytch.discovery.organizations.list").isOptionalString("intermediate_session_token", e.intermediate_session_token), t.abrupt("return", this._networkClient.fetchSDK({ url: "/b2b/discovery/organizations", body: e, errorMessage: "Failed to retrieve discovered organizations", method: "POST" }));
856
+ case 2:
857
+ case "end": return t.stop();
858
+ } }), t, this); }))); }, create: function (e) { return z(n, void 0, void 0, _().mark((function t() { var r; return _().wrap((function (t) { for (;;)
859
+ switch (t.prev = t.next) {
860
+ case 0: return ee("stytch.discovery.organizations.create").isString("intermediate_session_token", e.intermediate_session_token).isNumber("session_duration_minutes", e.session_duration_minutes).isString("organization_name", e.organization_name).isString("organization_slug", e.organization_slug).isOptionalString("organization_logo_url", e.organization_logo_url).isOptionalString("sso_jit_provisioning", e.sso_jit_provisioning).isOptionalStringArray("email_allowed_domains", e.email_allowed_domains).isOptionalString("email_invites", e.email_invites).isOptionalString("auth_methods", e.auth_methods).isOptionalStringArray("allowed_auth_methods", e.allowed_auth_methods), t.next = 3, this._networkClient.fetchSDK({ url: "/b2b/discovery/organizations/create", body: e, errorMessage: "Failed to create organization and member", method: "POST" });
861
+ case 3: return r = t.sent, this._subscriptionService.updateStateAndTokens({ state: { session: r.member_session, member: r.member }, session_token: r.session_token, session_jwt: r.session_jwt }), t.abrupt("return", r);
862
+ case 6:
863
+ case "end": return t.stop();
864
+ } }), t, this); }))); } }, this.intermediateSessions = { exchange: function (e) { return z(n, void 0, void 0, _().mark((function t() { var r; return _().wrap((function (t) { for (;;)
865
+ switch (t.prev = t.next) {
866
+ case 0: return ee("stytch.discovery.intermediateSessions.exchange").isString("intermediate_session_token", e.intermediate_session_token).isString("organization_id", e.organization_id).isNumber("session_duration_minutes", e.session_duration_minutes), t.next = 3, this._networkClient.fetchSDK({ url: "/b2b/discovery/intermediate_sessions/exchange", body: e, errorMessage: "Failed to exchange intermediate session", method: "POST" });
867
+ case 3: return r = t.sent, this._subscriptionService.updateStateAndTokens({ state: { session: r.member_session, member: r.member }, session_token: r.session_token, session_jwt: r.session_jwt }), t.abrupt("return", r);
868
+ case 6:
869
+ case "end": return t.stop();
870
+ } }), t, this); }))); } }; })), de = Symbol.for("stytch__internal"), pe = function (e, t) { Object.assign(e, function (e, t, r) { return (t = d(t)) in e ? Object.defineProperty(e, t, { value: r, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = r, e; }({}, de, t)); }, ve = function (e) { return (document.cookie ? document.cookie.split("; ") : []).filter((function (t) { var r = l(t.split("="), 1)[0]; return e === r; })).length > 1; };
871
+ function me(e, t, r, n) { return new (r || (r = Promise))((function (o, i) { function a(e) { try {
872
+ c(n.next(e));
811
873
  }
812
- catch (t) {
813
- i(t);
814
- } } function s(t) { try {
815
- c(n.throw(t));
874
+ catch (e) {
875
+ i(e);
876
+ } } function s(e) { try {
877
+ c(n.throw(e));
816
878
  }
817
- catch (t) {
818
- i(t);
819
- } } function c(t) { var e; t.done ? o(t.value) : (e = t.value, e instanceof r ? e : new r((function (t) { t(e); }))).then(a, s); } c((n = n.apply(t, e || [])).next()); })); }
820
- var pt = function () { function t(e, r, n, o) { c(this, t), this._publicToken = e, this._subscriptionDataLayer = r, this.baseURL = n, this.additionalTelemetryDataFn = o, this.updateSessionToken = function () { return null; }, this.eventLogger = new nt({ maxBatchSize: et, intervalDurationMs: rt, logEventURL: this.buildSDKUrl("/events") }); } return l(t, [{ key: "logEvent", value: function (t) { var e = t.name, r = t.details, n = t.error, o = void 0 === n ? {} : n; this.eventLogger.logEvent(this.createTelemetryBlob(), { public_token: this._publicToken, event_name: e, details: r, error_code: o.error_code, error_description: o.error_description, http_status_code: o.http_status_code }); } }, { key: "createTelemetryBlob", value: function () { return Object.assign(Object.assign({ event_id: "event-id-".concat(Y()), app_session_id: "app-session-id-".concat(Y()), persistent_id: "persistent-id-".concat(Y()), client_sent_at: (new Date).toISOString(), timezone: Intl.DateTimeFormat().resolvedOptions().timeZone }, this.additionalTelemetryDataFn()), { app: { identifier: window.location.hostname }, sdk: { identifier: "Stytch.js Javascript SDK", version: "0.10.7" } }); } }, { key: "fetchSDK", value: function (t) { var e = t.url, r = t.body, n = t.errorMessage, o = t.method; return ht(this, void 0, void 0, s().mark((function t() { var i, a, c, u; return s().wrap((function (t) { for (;;)
821
- switch (t.prev = t.next) {
822
- case 0: return i = this._subscriptionDataLayer.readSessionCookie().session_token, a = "Basic " + window.btoa(this._publicToken + ":" + (i || this._publicToken)), c = window.btoa(JSON.stringify(this.createTelemetryBlob())), u = window.location.origin, t.abrupt("return", Q({ basicAuthHeader: a, body: r, errorMessage: n, finalURL: this.buildSDKUrl(e), method: o, xSDKClientHeader: c, xSDKParentHostHeader: u }));
879
+ catch (e) {
880
+ i(e);
881
+ } } function c(e) { var t; e.done ? o(e.value) : (t = e.value, t instanceof r ? t : new r((function (e) { e(t); }))).then(a, s); } c((n = n.apply(e, t || [])).next()); })); }
882
+ var ye = function () { function e(t, r, n, o) { s(this, e), this._publicToken = t, this._subscriptionDataLayer = r, this.baseURL = n, this.additionalTelemetryDataFn = o, this.updateSessionToken = function () { return null; }, this.eventLogger = new ie({ maxBatchSize: ne, intervalDurationMs: oe, logEventURL: this.buildSDKUrl("/events") }); } return u(e, [{ key: "logEvent", value: function (e) { var t = e.name, r = e.details, n = e.error, o = void 0 === n ? {} : n; this.eventLogger.logEvent(this.createTelemetryBlob(), { public_token: this._publicToken, event_name: t, details: r, error_code: o.error_code, error_description: o.error_description, http_status_code: o.http_status_code }); } }, { key: "createTelemetryBlob", value: function () { return Object.assign(Object.assign({ event_id: "event-id-".concat($()), app_session_id: "app-session-id-".concat($()), persistent_id: "persistent-id-".concat($()), client_sent_at: (new Date).toISOString(), timezone: Intl.DateTimeFormat().resolvedOptions().timeZone }, this.additionalTelemetryDataFn()), { app: { identifier: window.location.hostname }, sdk: { identifier: "Stytch.js Javascript SDK", version: "0.11.2" } }); } }, { key: "fetchSDK", value: function (e) { var t = e.url, r = e.body, n = e.errorMessage, o = e.method; return me(this, void 0, void 0, a().mark((function e() { var i, s, c, u; return a().wrap((function (e) { for (;;)
883
+ switch (e.prev = e.next) {
884
+ case 0: return i = this._subscriptionDataLayer.readSessionCookie().session_token, s = "Basic " + window.btoa(this._publicToken + ":" + (i || this._publicToken)), c = window.btoa(JSON.stringify(this.createTelemetryBlob())), u = window.location.origin, e.abrupt("return", te({ basicAuthHeader: s, body: r, errorMessage: n, finalURL: this.buildSDKUrl(t), method: o, xSDKClientHeader: c, xSDKParentHostHeader: u }));
823
885
  case 5:
824
- case "end": return t.stop();
825
- } }), t, this); }))); } }, { key: "buildSDKUrl", value: function (t) { return "".concat(this.baseURL, "/sdk/v1").concat(t); } }]), t; }();
886
+ case "end": return e.stop();
887
+ } }), e, this); }))); } }, { key: "buildSDKUrl", value: function (e) { return "".concat(this.baseURL, "/sdk/v1").concat(e); } }]), e; }();
826
888
  /*! js-cookie v3.0.1 | MIT */
827
- function dt(t) { for (var e = 1; e < arguments.length; e++) {
828
- var r = arguments[e];
889
+ function _e(e) { for (var t = 1; t < arguments.length; t++) {
890
+ var r = arguments[t];
829
891
  for (var n in r)
830
- t[n] = r[n];
831
- } return t; }
832
- var vt = function t(e, r) { function n(t, n, o) { if ("undefined" != typeof document) {
833
- "number" == typeof (o = dt({}, r, o)).expires && (o.expires = new Date(Date.now() + 864e5 * o.expires)), o.expires && (o.expires = o.expires.toUTCString()), t = encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
892
+ e[n] = r[n];
893
+ } return e; }
894
+ var be = function e(t, r) { function n(e, n, o) { if ("undefined" != typeof document) {
895
+ "number" == typeof (o = _e({}, r, o)).expires && (o.expires = new Date(Date.now() + 864e5 * o.expires)), o.expires && (o.expires = o.expires.toUTCString()), e = encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
834
896
  var i = "";
835
897
  for (var a in o)
836
898
  o[a] && (i += "; " + a, !0 !== o[a] && (i += "=" + o[a].split(";")[0]));
837
- return document.cookie = t + "=" + e.write(n, t) + i;
838
- } } return Object.create({ set: n, get: function (t) { if ("undefined" != typeof document && (!arguments.length || t)) {
899
+ return document.cookie = e + "=" + t.write(n, e) + i;
900
+ } } return Object.create({ set: n, get: function (e) { if ("undefined" != typeof document && (!arguments.length || e)) {
839
901
  for (var r = document.cookie ? document.cookie.split("; ") : [], n = {}, o = 0; o < r.length; o++) {
840
902
  var i = r[o].split("="), a = i.slice(1).join("=");
841
903
  try {
842
904
  var s = decodeURIComponent(i[0]);
843
- if (n[s] = e.read(a, s), t === s)
905
+ if (n[s] = t.read(a, s), e === s)
844
906
  break;
845
907
  }
846
- catch (t) { }
908
+ catch (e) { }
847
909
  }
848
- return t ? n[t] : n;
849
- } }, remove: function (t, e) { n(t, "", dt({}, e, { expires: -1 })); }, withAttributes: function (e) { return t(this.converter, dt({}, this.attributes, e)); }, withConverter: function (e) { return t(dt({}, this.converter, e), this.attributes); } }, { attributes: { value: Object.freeze(r) }, converter: { value: Object.freeze(e) } }); }({ read: function (t) { return '"' === t[0] && (t = t.slice(1, -1)), t.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent); }, write: function (t) { return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g, decodeURIComponent); } }, { path: "/" }), yt = "stytch_sdk_state_", mt = function (t) { var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : ""; return "".concat(yt).concat(t).concat(e ? "::".concat(e) : ""); }, bt = function () { function t(e, r) { var n = this; c(this, t), this.browserSessionStorage = { getItem: function (t) { return sessionStorage.getItem(mt(n.publicToken, t)); }, setItem: function (t, e) { return sessionStorage.setItem(mt(n.publicToken, t), e); }, removeItem: function (t) { return sessionStorage.removeItem(mt(n.publicToken, t)); } }, this.publicToken = e, this.state = null, this.subscriptions = {}, (null == r ? void 0 : r.cookieOptions) ? (Z("SubscriptionDataLayer").isOptionalString("cookieOptions.opaqueTokenCookieName", r.cookieOptions.opaqueTokenCookieName).isOptionalString("cookieOptions.jwtCookieName", r.cookieOptions.jwtCookieName).isOptionalString("cookieOptions.path", r.cookieOptions.path), this._jwtCookieName = r.cookieOptions.jwtCookieName || null, this._opaqueTokenCookieName = r.cookieOptions.opaqueTokenCookieName || null, this._cookiePath = r.cookieOptions.path || null, this._cookieAvailableToSubdomains = r.cookieOptions.availableToSubdomains || !1) : (this._opaqueTokenCookieName = null, this._jwtCookieName = null, this._cookiePath = null, this._cookieAvailableToSubdomains = !1); var o = localStorage.getItem(mt(this.publicToken)); if (o) {
910
+ return e ? n[e] : n;
911
+ } }, remove: function (e, t) { n(e, "", _e({}, t, { expires: -1 })); }, withAttributes: function (t) { return e(this.converter, _e({}, this.attributes, t)); }, withConverter: function (t) { return e(_e({}, this.converter, t), this.attributes); } }, { attributes: { value: Object.freeze(r) }, converter: { value: Object.freeze(t) } }); }({ read: function (e) { return '"' === e[0] && (e = e.slice(1, -1)), e.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent); }, write: function (e) { return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g, decodeURIComponent); } }, { path: "/" }), ge = "stytch_sdk_state_", ke = function (e) { var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : ""; return "".concat(ge).concat(e).concat(t ? "::".concat(t) : ""); }, we = function () { function e(t, r) { var n = this; s(this, e), this.browserSessionStorage = { getItem: function (e) { return sessionStorage.getItem(ke(n.publicToken, e)); }, setItem: function (e, t) { return sessionStorage.setItem(ke(n.publicToken, e), t); }, removeItem: function (e) { return sessionStorage.removeItem(ke(n.publicToken, e)); } }, this.publicToken = t, this.state = null, this.subscriptions = {}, (null == r ? void 0 : r.cookieOptions) ? (ee("SubscriptionDataLayer").isOptionalString("cookieOptions.opaqueTokenCookieName", r.cookieOptions.opaqueTokenCookieName).isOptionalString("cookieOptions.jwtCookieName", r.cookieOptions.jwtCookieName).isOptionalString("cookieOptions.path", r.cookieOptions.path), this._jwtCookieName = r.cookieOptions.jwtCookieName || null, this._opaqueTokenCookieName = r.cookieOptions.opaqueTokenCookieName || null, this._cookiePath = r.cookieOptions.path || null, this._cookieAvailableToSubdomains = r.cookieOptions.availableToSubdomains || !1) : (this._opaqueTokenCookieName = null, this._jwtCookieName = null, this._cookiePath = null, this._cookieAvailableToSubdomains = !1); var o = localStorage.getItem(ke(this.publicToken)); if (o) {
850
912
  var i;
851
913
  try {
852
914
  i = JSON.parse(o);
853
915
  }
854
- catch (t) {
916
+ catch (e) {
855
917
  return this.syncToLocalStorage(), void this.removeSessionCookie();
856
918
  }
857
919
  this.state = i;
858
920
  }
859
921
  else
860
- this.removeSessionCookie(); } return l(t, [{ key: "opaqueTokenCookieName", get: function () { var t; return null !== (t = this._opaqueTokenCookieName) && void 0 !== t ? t : "stytch_session"; } }, { key: "jwtCookieName", get: function () { var t; return null !== (t = this._jwtCookieName) && void 0 !== t ? t : "stytch_session_jwt"; } }, { key: "readSessionCookie", value: function () { return { session_token: vt.get(this.opaqueTokenCookieName), session_jwt: vt.get(this.jwtCookieName) }; } }, { key: "writeSessionCookie", value: function (e) { var r, n, o = e.state, i = e.session_token, a = e.session_jwt, s = t.generateCookieOpts({ expiresAt: null !== (n = null === (r = null == o ? void 0 : o.session) || void 0 === r ? void 0 : r.expires_at) && void 0 !== n ? n : "", availableToSubdomains: this._cookieAvailableToSubdomains, path: this._cookiePath }); vt.set(this.opaqueTokenCookieName, i, s), vt.set(this.jwtCookieName, a, s); } }, { key: "removeSessionCookie", value: function () { var e = this; [!0, !1].forEach((function (r) { [e._cookiePath, null].forEach((function (n) { var o = t.generateCookieOpts({ expiresAt: new Date(0).toString(), availableToSubdomains: r, path: n }); vt.remove(e.opaqueTokenCookieName, o), vt.remove(e.jwtCookieName, o); })); })); } }, { key: "syncToLocalStorage", value: function () { localStorage.setItem(mt(this.publicToken), JSON.stringify(this.state)); } }, { key: "getItem", value: function (t) { return localStorage.getItem(mt(this.publicToken, t)); } }, { key: "setItem", value: function (t, e) { return localStorage.setItem(mt(this.publicToken, t), e); } }, { key: "removeItem", value: function (t) { return localStorage.removeItem(mt(this.publicToken, t)); } }], [{ key: "generateCookieOpts", value: function (t) { var e = t.path, r = t.availableToSubdomains, n = t.expiresAt, o = { expires: new Date(n), sameSite: "lax" }; return e && (o.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}$/)) ? o.secure = !1 : (r && (o.domain = window.location.host), o.secure = !0), o; } }]), t; }(), gt = function (t) { n(r, bt); var e = i(r); function r() { return c(this, r), e.apply(this, arguments); } return l(r); }(), _t = Symbol.for("__stytch_b2b_DataLayer"), wt = function (t, e) { var r, n = ((r = window)[_t] || (r[_t] = {}), r[_t]); return n[t] || (n[t] = new gt(t, e)), n[t]; }, kt = function (t, e) { Object.values(t).forEach((function (t) { return t(e); })); }, St = function () { var t = (arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}).KEYS_TO_EXCLUDE, e = void 0 === t ? [] : t; return function t(r, n) { return p(r) === p(n) && (null === r || null === n ? r === n : "object" === p(r) ? Object.keys(r).length === Object.keys(n).length && !Object.keys(r).some((function (t) { return !(t in n); })) && Object.entries(r).filter((function (t) { var r = h(t, 1)[0]; return !e.includes(r); })).every((function (e) { var r = h(e, 2), o = r[0], i = r[1]; return t(i, n[o]); })) : r === n); }; }({ KEYS_TO_EXCLUDE: ["last_accessed_at"] }), Et = function () { function t(e, r) { var n, o = this; c(this, t), this._publicToken = e, this._datalayer = r, this._listen = function (t) { t.key === mt(o._publicToken) && (null !== t.newValue ? o._updateStateAndTokensInternal(JSON.parse(t.newValue)) : o.destroyState()); }, window.addEventListener("storage", this._listen); var i = null === (n = this._datalayer.state) || void 0 === n ? void 0 : n.session; i && Date.parse(i.expires_at) < Date.now() ? this.destroyState() : this._datalayer.readSessionCookie().session_token || this.destroyState(); } return l(t, [{ key: "getTokens", value: function () { var t = this._datalayer.readSessionCookie(), e = t.session_token, r = t.session_jwt; return e && r ? { session_token: e, session_jwt: r } : null; } }, { key: "destroyState", value: function () { this.updateStateAndTokens({ state: null, session_token: null, session_jwt: null }); } }, { key: "_updateStateAndTokensInternal", value: function (t) { var e = t.state, r = this._datalayer.state; this._datalayer.state = e || null, St(r, t.state) || kt(this._datalayer.subscriptions, t.state); } }, { key: "updateStateAndTokens", value: function (t) { t.state ? this._datalayer.writeSessionCookie(t) : this._datalayer.removeSessionCookie(), this._updateStateAndTokensInternal(t), this._datalayer.syncToLocalStorage(); } }, { key: "updateState", value: function (t) { var e = this._datalayer.state, r = Object.assign(Object.assign({}, this._datalayer.state), t); this._datalayer.state = r, St(e, r) || (kt(this._datalayer.subscriptions, r), this._datalayer.syncToLocalStorage()); } }, { key: "subscribeToState", value: function (t) { return e = this._datalayer.subscriptions, r = t, n = Math.random().toString(36).slice(-10), e[n] = r, function () { return delete e[n]; }; var e, r, n; } }, { key: "getState", value: function () { return this._datalayer.state; } }, { key: "destroy", value: function () { window.removeEventListener("storage", this._listen); } }, { key: "syncFromDeviceStorage", value: function () { return null; } }]), t; }(), Ot = function (t) { n(r, Et); var e = i(r); function r() { var t; return c(this, r), (t = e.apply(this, arguments)).updateMember = function (e) { return t.updateState({ member: e }); }, t.getMember = function () { var e, r; return null !== (r = null === (e = t.getState()) || void 0 === e ? void 0 : e.member) && void 0 !== r ? r : null; }, t.getSession = function () { var e, r; return null !== (r = null === (e = t.getState()) || void 0 === e ? void 0 : e.session) && void 0 !== r ? r : null; }, t; } return l(r); }();
861
- function Tt(t) { var e = t.toString(16); return 1 === e.length && (e = "0" + e), e; }
862
- var Pt, Lt, xt, Ct, jt, At, Rt = function () { function t(e, r) { c(this, t), this._dataLayer = e, this.namespace = r; } return l(t, [{ key: "key", value: function () { return "PKCE_VERIFIER:" + this.namespace; } }, { key: "startPKCETransaction", value: function () { return ht(this, void 0, void 0, s().mark((function e() { var r; return s().wrap((function (e) { for (;;)
863
- switch (e.prev = e.next) {
864
- case 0: return e.next = 2, t.createProofkeyPair();
865
- case 2: return r = e.sent, this._dataLayer.setItem(this.key(), JSON.stringify(r)), e.abrupt("return", r);
922
+ this.removeSessionCookie(); } return u(e, [{ key: "opaqueTokenCookieName", get: function () { var e; return null !== (e = this._opaqueTokenCookieName) && void 0 !== e ? e : "stytch_session"; } }, { key: "jwtCookieName", get: function () { var e; return null !== (e = this._jwtCookieName) && void 0 !== e ? e : "stytch_session_jwt"; } }, { key: "readSessionCookie", value: function () { return { session_token: be.get(this.opaqueTokenCookieName), session_jwt: be.get(this.jwtCookieName) }; } }, { key: "writeSessionCookie", value: function (t) { var r, n, o, i, a = t.state, s = t.session_token, c = t.session_jwt, u = e.generateCookieOpts({ expiresAt: null !== (n = null === (r = null == a ? void 0 : a.session) || void 0 === r ? void 0 : r.expires_at) && void 0 !== n ? n : "", availableToSubdomains: this._cookieAvailableToSubdomains, path: this._cookiePath }); be.set(this.opaqueTokenCookieName, s, u), be.set(this.jwtCookieName, c, u); var l = e.generateCookieOpts({ expiresAt: null !== (i = null === (o = null == a ? void 0 : a.session) || void 0 === o ? void 0 : o.expires_at) && void 0 !== i ? i : "", availableToSubdomains: !this._cookieAvailableToSubdomains, path: this._cookiePath }); ve(this.jwtCookieName) && be.remove(this.jwtCookieName, l), ve(this.opaqueTokenCookieName) && be.remove(this.opaqueTokenCookieName, l), ve(this.jwtCookieName) && Z.warn("Could not remove extraneous JWT cookie. This might happen if the cookie has been set using multiple `path` settings, and may produce unwanted behavior."), ve(this.opaqueTokenCookieName) && Z.warn("Could not remove extraneous opaque token cookie."); } }, { key: "removeSessionCookie", value: function () { var t = this; [!0, !1].forEach((function (r) { [t._cookiePath, null].forEach((function (n) { var o = e.generateCookieOpts({ expiresAt: new Date(0).toString(), availableToSubdomains: r, path: n }); be.remove(t.opaqueTokenCookieName, o), be.remove(t.jwtCookieName, o); })); })); } }, { key: "syncToLocalStorage", value: function () { localStorage.setItem(ke(this.publicToken), JSON.stringify(this.state)); } }, { key: "getItem", value: function (e) { return localStorage.getItem(ke(this.publicToken, e)); } }, { key: "setItem", value: function (e, t) { return localStorage.setItem(ke(this.publicToken, e), t); } }, { key: "removeItem", value: function (e) { return localStorage.removeItem(ke(this.publicToken, e)); } }], [{ key: "generateCookieOpts", value: function (e) { var t = e.path, r = e.availableToSubdomains, n = e.expiresAt, o = { expires: new Date(n), sameSite: "lax" }; return t && (o.path = t), 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}$/)) ? o.secure = !1 : (r && (o.domain = window.location.host), o.secure = !0), o; } }]), e; }(), Se = function (e) { r(n, we); var t = o(n); function n() { return s(this, n), t.apply(this, arguments); } return u(n); }(), Oe = Symbol.for("__stytch_b2b_DataLayer"), Ee = function (e, t) { var r, n = ((r = window)[Oe] || (r[Oe] = {}), r[Oe]); return n[e] || (n[e] = new Se(e, t)), n[e]; }, Te = function (e, t) { Object.values(e).forEach((function (e) { return e(t); })); }, xe = function () { var e = (arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}).KEYS_TO_EXCLUDE, t = void 0 === e ? [] : e; return function e(r, n) { return v(r) === v(n) && (null === r || null === n ? r === n : "object" === v(r) ? Object.keys(r).length === Object.keys(n).length && !Object.keys(r).some((function (e) { return !(e in n); })) && Object.entries(r).filter((function (e) { var r = p(e, 1)[0]; return !t.includes(r); })).every((function (t) { var r = p(t, 2), o = r[0], i = r[1]; return e(i, n[o]); })) : r === n); }; }({ KEYS_TO_EXCLUDE: ["last_accessed_at"] }), Ce = function () { function e(t, r) { var n, o = this; s(this, e), this._publicToken = t, this._datalayer = r, this._listen = function (e) { if (e.key === ke(o._publicToken))
923
+ if (null !== e.newValue && "null" !== e.newValue) {
924
+ var t = JSON.parse(e.newValue);
925
+ o.updateState(t);
926
+ }
927
+ else
928
+ o.destroyState(); }, window.addEventListener("storage", this._listen); var i = null === (n = this._datalayer.state) || void 0 === n ? void 0 : n.session; i && Date.parse(i.expires_at) < Date.now() ? this.destroyState() : this._datalayer.readSessionCookie().session_token || this.destroyState(); } return u(e, [{ key: "getTokens", value: function () { var e = this._datalayer.readSessionCookie(), t = e.session_token, r = e.session_jwt; return t && r ? { session_token: t, session_jwt: r } : null; } }, { key: "destroyState", value: function () { this.updateStateAndTokens({ state: null, session_token: null, session_jwt: null }); } }, { key: "_updateStateAndTokensInternal", value: function (e) { var t = this._datalayer.state, r = null === e.state ? null : Object.assign(Object.assign({}, this._datalayer.state), e.state); this._datalayer.state = r, xe(t, r) || Te(this._datalayer.subscriptions, r); } }, { key: "updateStateAndTokens", value: function (e) { e.state ? this._datalayer.writeSessionCookie(e) : this._datalayer.removeSessionCookie(), this._updateStateAndTokensInternal(e), this._datalayer.syncToLocalStorage(); } }, { key: "updateState", value: function (e) { var t = this._datalayer.state, r = null === e ? null : Object.assign(Object.assign({}, this._datalayer.state), e); this._datalayer.state = r, xe(t, r) || (Te(this._datalayer.subscriptions, r), this._datalayer.syncToLocalStorage()); } }, { key: "updateTokens", value: function (e) { var t = e.session_token, r = e.session_jwt, n = this._datalayer.readSessionCookie(), o = Object.assign(Object.assign({}, n), { session_token: t, session_jwt: r }); t && r ? this._datalayer.writeSessionCookie(o) : this._datalayer.removeSessionCookie(); } }, { key: "subscribeToState", value: function (e) { return t = this._datalayer.subscriptions, r = e, n = Math.random().toString(36).slice(-10), t[n] = r, function () { return delete t[n]; }; var t, r, n; } }, { key: "getState", value: function () { return this._datalayer.state; } }, { key: "destroy", value: function () { window.removeEventListener("storage", this._listen); } }, { key: "syncFromDeviceStorage", value: function () { return null; } }]), e; }(), Pe = function (e) { r(n, Ce); var t = o(n); function n() { var e; return s(this, n), (e = t.apply(this, arguments)).updateMember = function (t) { return e.updateState({ member: t }); }, e.getMember = function () { var t, r; return null !== (r = null === (t = e.getState()) || void 0 === t ? void 0 : t.member) && void 0 !== r ? r : null; }, e.getSession = function () { var t, r; return null !== (r = null === (t = e.getState()) || void 0 === t ? void 0 : t.session) && void 0 !== r ? r : null; }, e; } return u(n); }();
929
+ function je(e) { var t = e.toString(16); return 1 === t.length && (t = "0" + t), t; }
930
+ var Le, Ae, Re, Ie, Ne, De, Me = function () { function e(t, r) { s(this, e), this._dataLayer = t, this.namespace = r; } return u(e, [{ key: "key", value: function () { return "PKCE_VERIFIER:" + this.namespace; } }, { key: "startPKCETransaction", value: function () { return me(this, void 0, void 0, a().mark((function t() { var r; return a().wrap((function (t) { for (;;)
931
+ switch (t.prev = t.next) {
932
+ case 0: return t.next = 2, e.createProofkeyPair();
933
+ case 2: return r = t.sent, this._dataLayer.setItem(this.key(), JSON.stringify(r)), t.abrupt("return", r);
866
934
  case 5:
867
- case "end": return e.stop();
868
- } }), e, this); }))); } }, { key: "getPKPair", value: function () { var t = this._dataLayer.getItem(this.key()); if (null !== t)
935
+ case "end": return t.stop();
936
+ } }), t, this); }))); } }, { key: "getPKPair", value: function () { var e = this._dataLayer.getItem(this.key()); if (null !== e)
869
937
  try {
870
- return JSON.parse(t);
938
+ return JSON.parse(e);
871
939
  }
872
- catch (t) {
873
- return void $.warn("Found malformed Proof Key pair in localstorage.");
874
- } } }, { key: "clearPKPair", value: function () { return this._dataLayer.removeItem(this.key()); } }], [{ key: "createProofkeyPair", value: function () { return ht(this, void 0, void 0, s().mark((function t() { var r, n, o; return s().wrap((function (t) { for (;;)
875
- switch (t.prev = t.next) {
876
- case 0: return r = new Uint32Array(16), window.crypto.getRandomValues(r), n = Array.from(r).map(Tt).join(""), t.next = 5, window.crypto.subtle.digest("SHA-256", (new TextEncoder).encode(n));
877
- case 5: return o = t.sent, t.abrupt("return", { code_challenge: (i = o, a = void 0, btoa((a = String.fromCharCode).call.apply(a, [null].concat(e(new Uint8Array(i))))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "")), code_verifier: n });
940
+ catch (e) {
941
+ return void Z.warn("Found malformed Proof Key pair in localstorage.");
942
+ } } }, { key: "clearPKPair", value: function () { return this._dataLayer.removeItem(this.key()); } }], [{ key: "createProofkeyPair", value: function () { return me(this, void 0, void 0, a().mark((function e() { var r, n, o; return a().wrap((function (e) { for (;;)
943
+ switch (e.prev = e.next) {
944
+ case 0: return r = new Uint32Array(16), window.crypto.getRandomValues(r), n = Array.from(r).map(je).join(""), e.next = 5, window.crypto.subtle.digest("SHA-256", (new TextEncoder).encode(n));
945
+ case 5: return o = e.sent, e.abrupt("return", { code_challenge: (i = o, a = void 0, btoa((a = String.fromCharCode).call.apply(a, [null].concat(t(new Uint8Array(i))))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "")), code_verifier: n });
878
946
  case 7:
879
- case "end": return t.stop();
880
- } var i, a; }), t); }))); } }]), t; }(), It = "bootstrap", Dt = function () { return { displayWatermark: !1, cnameDomain: null, emailDomains: ["stytch.com"], captchaSettings: { enabled: !1 }, pkceRequiredForEmailMagicLinks: !1, pkceRequiredForPasswordResets: !1, pkceRequiredForOAuth: !1, pkceRequiredForSso: !1 }; }, Nt = function () { function t(e, r, n) { var o = this; c(this, t), this._publicToken = e, this._networkClient = r, this._dataLayer = n, this._bootstrapDataPromise = this._networkClient.fetchSDK({ url: "/projects/bootstrap/".concat(this._publicToken), method: "GET", errorMessage: "Error fetching bootstrap data for SDK for ".concat(this._publicToken) }).then(t.mapBootstrapData).then((function (t) { return o._dataLayer.setItem(It, JSON.stringify(t)), t; })).catch((function (t) { return $.error(t), Dt(); })); } return l(t, [{ key: "getSync", value: function () { var t = this._dataLayer.getItem(It); if (null === t)
881
- return Dt(); try {
882
- return JSON.parse(t);
947
+ case "end": return e.stop();
948
+ } var i, a; }), e); }))); } }]), e; }(), Ue = "bootstrap", Be = function () { return { displayWatermark: !1, cnameDomain: null, emailDomains: ["stytch.com"], captchaSettings: { enabled: !1 }, pkceRequiredForEmailMagicLinks: !1, pkceRequiredForPasswordResets: !1, pkceRequiredForOAuth: !1, pkceRequiredForSso: !1 }; }, Ke = function () { function e(t, r, n) { var o = this; s(this, e), this._publicToken = t, this._networkClient = r, this._dataLayer = n, this._bootstrapDataPromise = this._networkClient.fetchSDK({ url: "/projects/bootstrap/".concat(this._publicToken), method: "GET", errorMessage: "Error fetching bootstrap data for SDK for ".concat(this._publicToken) }).then(e.mapBootstrapData).then((function (e) { return o._dataLayer.setItem(Ue, JSON.stringify(e)), e; })).catch((function (e) { return Z.error(e), Be(); })); } return u(e, [{ key: "getSync", value: function () { var e = this._dataLayer.getItem(Ue); if (null === e)
949
+ return Be(); try {
950
+ return JSON.parse(e);
883
951
  }
884
- catch (t) {
885
- return Dt();
886
- } } }, { key: "getAsync", value: function () { return this._bootstrapDataPromise; } }], [{ key: "mapBootstrapData", value: function (t) { return { displayWatermark: !t.disable_sdk_watermark, captchaSettings: t.captcha_settings, cnameDomain: t.cname_domain, emailDomains: t.email_domains, pkceRequiredForEmailMagicLinks: t.pkce_required_for_email_magic_links, pkceRequiredForPasswordResets: t.pkce_required_for_password_resets, pkceRequiredForOAuth: t.pkce_required_for_oauth, pkceRequiredForSso: t.pkce_required_for_sso }; } }]), t; }(), Mt = l((function t(e, r) { var n, o = this; c(this, t), function (t) { if ("undefined" == typeof window)
887
- throw new Error("The ".concat(t, " is not compatible with server-side environments.\nIf using nextjs, use the create").concat(t, " method instead.\n```\n").concat("import { createStytchB2BHeadlessClient } from '@stytch/nextjs/b2b';\n \n const stytch = createStytchB2BHeadlessClient('public-token-...');\n ", "\n```\n")); }("StytchB2BHeadlessClient"), "string" != typeof (n = e) ? $.warn("Public token is malformed. Expected a string, got ".concat(p(n), ".").concat(X)) : "" === n ? $.warn('Public token is malformed. Expected "public-token-...", got an empty string.'.concat(X)) : n.startsWith("public-token-") || $.warn('Public token is malformed. Expected "public-token-...", got '.concat(n, ".").concat(X)); var i, a, s, u, l, f, h, d, v, y = r, m = { cookieOptions: null == (i = y) ? void 0 : i.cookieOptions, endpoints: { sdkBackendURL: null !== (s = null === (a = null == i ? void 0 : i.endpoints) || void 0 === a ? void 0 : a.sdkBackendURL) && void 0 !== s ? s : "https://web.stytch.com", testAPIURL: null !== (l = null === (u = null == i ? void 0 : i.endpoints) || void 0 === u ? void 0 : u.testAPIURL) && void 0 !== l ? l : "https://test.stytch.com", liveAPIURL: null !== (h = null === (f = null == i ? void 0 : i.endpoints) || void 0 === f ? void 0 : f.liveAPIURL) && void 0 !== h ? h : "https://api.stytch.com", clientsideServicesIframeURL: null !== (v = null === (d = null == i ? void 0 : i.endpoints) || void 0 === d ? void 0 : d.clientsideServicesIframeURL) && void 0 !== v ? v : "https://js.stytch.com/clientside-services/index.html" } }; this._dataLayer = wt(e, y), this._subscriptionService = new Ot(e, this._dataLayer); this._networkClient = new pt(e, this._dataLayer, m.endpoints.sdkBackendURL, (function () { var t, e, r, n; return { stytch_member_id: null === (e = null === (t = o._dataLayer.state) || void 0 === t ? void 0 : t.member) || void 0 === e ? void 0 : e.member_id, stytch_member_session_id: null === (n = null === (r = o._dataLayer.state) || void 0 === r ? void 0 : r.session) || void 0 === n ? void 0 : n.member_session_id }; })); var b = new Nt(e, this._networkClient, this._dataLayer); this.organization = new ct(this._networkClient), this.member = new at(this._networkClient, this._subscriptionService), this.session = new ut(this._networkClient, this._subscriptionService), this.magicLinks = new it(this._networkClient, this._subscriptionService, new Rt(this._dataLayer, "magic_links"), b.getAsync()), this.sso = new st(this._networkClient, this._subscriptionService, new Rt(this._dataLayer, "sso"), b.getAsync(), { publicToken: e, testAPIURL: m.endpoints.testAPIURL, liveAPIURL: m.endpoints.liveAPIURL }), this._sessionManager = new tt(this._subscriptionService, this.session), this._dataLayer.readSessionCookie().session_token && this._sessionManager.performBackgroundRefresh(), this._networkClient.logEvent({ name: "b2b_sdk_instance_instantiated", details: { event_callback_registered: !1, error_callback_registered: !1, success_callback_registered: !1 } }), ft(this, { bootstrap: b, publicToken: e }); }));
888
- function Ut(t) { return Ut = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (t) { return typeof t; } : function (t) { return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t; }, Ut(t); }
889
- function Bt(t, e) { for (var r = 0; r < e.length; r++) {
890
- var n = e[r];
891
- n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(t, (o = n.key, i = void 0, i = function (t, e) { if ("object" !== Ut(t) || null === t)
892
- return t; var r = t[Symbol.toPrimitive]; if (void 0 !== r) {
893
- var n = r.call(t, e || "default");
894
- if ("object" !== Ut(n))
952
+ catch (e) {
953
+ return Be();
954
+ } } }, { key: "getAsync", value: function () { return this._bootstrapDataPromise; } }], [{ key: "mapBootstrapData", value: function (e) { return { displayWatermark: !e.disable_sdk_watermark, captchaSettings: e.captcha_settings, cnameDomain: e.cname_domain, emailDomains: e.email_domains, pkceRequiredForEmailMagicLinks: e.pkce_required_for_email_magic_links, pkceRequiredForPasswordResets: e.pkce_required_for_password_resets, pkceRequiredForOAuth: e.pkce_required_for_oauth, pkceRequiredForSso: e.pkce_required_for_sso }; } }]), e; }(), Fe = u((function e(t, r) { var n, o = this; s(this, e), function (e) { if ("undefined" == typeof window)
955
+ 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("import { createStytchB2BHeadlessClient } from '@stytch/nextjs/b2b';\n \n const stytch = createStytchB2BHeadlessClient('public-token-...');\n ", "\n```\n")); }("StytchB2BHeadlessClient"), "string" != typeof (n = t) ? Z.warn("Public token is malformed. Expected a string, got ".concat(v(n), ".").concat(Q)) : "" === n ? Z.warn('Public token is malformed. Expected "public-token-...", got an empty string.'.concat(Q)) : n.startsWith("public-token-") || Z.warn('Public token is malformed. Expected "public-token-...", got '.concat(n, ".").concat(Q)); var i, a, c, u, l, h, f, d, p, m = r, y = { cookieOptions: null == (i = m) ? void 0 : i.cookieOptions, endpoints: { sdkBackendURL: null !== (c = null === (a = null == i ? void 0 : i.endpoints) || void 0 === a ? void 0 : a.sdkBackendURL) && void 0 !== c ? c : "https://web.stytch.com", testAPIURL: null !== (l = null === (u = null == i ? void 0 : i.endpoints) || void 0 === u ? void 0 : u.testAPIURL) && void 0 !== l ? l : "https://test.stytch.com", liveAPIURL: null !== (f = null === (h = null == i ? void 0 : i.endpoints) || void 0 === h ? void 0 : h.liveAPIURL) && void 0 !== f ? f : "https://api.stytch.com", clientsideServicesIframeURL: null !== (p = null === (d = null == i ? void 0 : i.endpoints) || void 0 === d ? void 0 : d.clientsideServicesIframeURL) && void 0 !== p ? p : "https://js.stytch.com/clientside-services/index.html" } }; this._dataLayer = Ee(t, m), this._subscriptionService = new Pe(t, this._dataLayer); this._networkClient = new ye(t, this._dataLayer, y.endpoints.sdkBackendURL, (function () { var e, t, r, n; return { stytch_member_id: null === (t = null === (e = o._dataLayer.state) || void 0 === e ? void 0 : e.member) || void 0 === t ? void 0 : t.member_id, stytch_member_session_id: null === (n = null === (r = o._dataLayer.state) || void 0 === r ? void 0 : r.session) || void 0 === n ? void 0 : n.member_session_id }; })); var _ = new Ke(t, this._networkClient, this._dataLayer); this.organization = new le(this._networkClient), this.member = new ce(this._networkClient, this._subscriptionService), this.session = new he(this._networkClient, this._subscriptionService), this.magicLinks = new se(this._networkClient, this._subscriptionService, new Me(this._dataLayer, "magic_links"), _.getAsync()), this.sso = new ue(this._networkClient, this._subscriptionService, new Me(this._dataLayer, "sso"), _.getAsync(), { publicToken: t, testAPIURL: y.endpoints.testAPIURL, liveAPIURL: y.endpoints.liveAPIURL }), this.discovery = new fe(this._networkClient, this._subscriptionService), this._sessionManager = new re(this._subscriptionService, this.session), this._dataLayer.readSessionCookie().session_token && this._sessionManager.performBackgroundRefresh(), this._networkClient.logEvent({ name: "b2b_sdk_instance_instantiated", details: { event_callback_registered: !1, error_callback_registered: !1, success_callback_registered: !1 } }), pe(this, { bootstrap: _, publicToken: t }); }));
956
+ function qe(e) { return qe = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (e) { return typeof e; } : function (e) { return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e; }, qe(e); }
957
+ function ze(e, t) { for (var r = 0; r < t.length; r++) {
958
+ var n = t[r];
959
+ n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(e, (o = n.key, i = void 0, i = function (e, t) { if ("object" !== qe(e) || null === e)
960
+ return e; var r = e[Symbol.toPrimitive]; if (void 0 !== r) {
961
+ var n = r.call(e, t || "default");
962
+ if ("object" !== qe(n))
895
963
  return n;
896
964
  throw new TypeError("@@toPrimitive must return a primitive value.");
897
- } return ("string" === e ? String : Number)(t); }(o, "string"), "symbol" === Ut(i) ? i : String(i)), n);
965
+ } return ("string" === t ? String : Number)(e); }(o, "string"), "symbol" === qe(i) ? i : String(i)), n);
898
966
  } var o, i; }
899
- function Kt(t, e, r) { return e && Bt(t.prototype, e), r && Bt(t, r), Object.defineProperty(t, "prototype", { writable: !1 }), t; }
900
- function Ft(t, e) { if (!(t instanceof e))
967
+ function Ge(e, t, r) { return t && ze(e.prototype, t), r && ze(e, r), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
968
+ function We(e, t) { if (!(e instanceof t))
901
969
  throw new TypeError("Cannot call a class as a function"); }
902
- function qt(t, e) { if ("function" != typeof e && null !== e)
903
- throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && Yt(t, e); }
904
- function Gt(t) { var e = Vt(); return function () { var r, n = Jt(t); if (e) {
905
- var o = Jt(this).constructor;
970
+ function He(e, t) { if ("function" != typeof t && null !== t)
971
+ throw new TypeError("Super expression must either be null or a function"); e.prototype = Object.create(t && t.prototype, { constructor: { value: e, writable: !0, configurable: !0 } }), Object.defineProperty(e, "prototype", { writable: !1 }), t && Ze(e, t); }
972
+ function Ve(e) { var t = Xe(); return function () { var r, n = Qe(e); if (t) {
973
+ var o = Qe(this).constructor;
906
974
  r = Reflect.construct(n, arguments, o);
907
975
  }
908
976
  else
909
- r = n.apply(this, arguments); return function (t, e) { if (e && ("object" === Ut(e) || "function" == typeof e))
910
- return e; if (void 0 !== e)
911
- throw new TypeError("Derived constructors may only return object or undefined"); return Wt(t); }(this, r); }; }
912
- function Wt(t) { if (void 0 === t)
913
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return t; }
914
- function Ht(t) { var e = "function" == typeof Map ? new Map : void 0; return Ht = function (t) { if (null === t || (r = t, -1 === Function.toString.call(r).indexOf("[native code]")))
915
- return t; var r; if ("function" != typeof t)
916
- throw new TypeError("Super expression must either be null or a function"); if (void 0 !== e) {
917
- if (e.has(t))
918
- return e.get(t);
919
- e.set(t, n);
920
- } function n() { return zt(t, arguments, Jt(this).constructor); } return n.prototype = Object.create(t.prototype, { constructor: { value: n, enumerable: !1, writable: !0, configurable: !0 } }), Yt(n, t); }, Ht(t); }
921
- function zt(t, e, r) { return zt = Vt() ? Reflect.construct.bind() : function (t, e, r) { var n = [null]; n.push.apply(n, e); var o = new (Function.bind.apply(t, n)); return r && Yt(o, r.prototype), o; }, zt.apply(null, arguments); }
922
- function Vt() { if ("undefined" == typeof Reflect || !Reflect.construct)
977
+ r = n.apply(this, arguments); return function (e, t) { if (t && ("object" === qe(t) || "function" == typeof t))
978
+ return t; if (void 0 !== t)
979
+ throw new TypeError("Derived constructors may only return object or undefined"); return Ye(e); }(this, r); }; }
980
+ function Ye(e) { if (void 0 === e)
981
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
982
+ function Je(e) { var t = "function" == typeof Map ? new Map : void 0; return Je = function (e) { if (null === e || (r = e, -1 === Function.toString.call(r).indexOf("[native code]")))
983
+ return e; var r; if ("function" != typeof e)
984
+ throw new TypeError("Super expression must either be null or a function"); if (void 0 !== t) {
985
+ if (t.has(e))
986
+ return t.get(e);
987
+ t.set(e, n);
988
+ } function n() { return $e(e, arguments, Qe(this).constructor); } return n.prototype = Object.create(e.prototype, { constructor: { value: n, enumerable: !1, writable: !0, configurable: !0 } }), Ze(n, e); }, Je(e); }
989
+ function $e(e, t, r) { return $e = Xe() ? Reflect.construct.bind() : function (e, t, r) { var n = [null]; n.push.apply(n, t); var o = new (Function.bind.apply(e, n)); return r && Ze(o, r.prototype), o; }, $e.apply(null, arguments); }
990
+ function Xe() { if ("undefined" == typeof Reflect || !Reflect.construct)
923
991
  return !1; if (Reflect.construct.sham)
924
992
  return !1; if ("function" == typeof Proxy)
925
993
  return !0; try {
926
994
  return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], (function () { }))), !0;
927
995
  }
928
- catch (t) {
996
+ catch (e) {
929
997
  return !1;
930
998
  } }
931
- function Yt(t, e) { return Yt = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, Yt(t, e); }
932
- function Jt(t) { return Jt = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, Jt(t); }
933
- !function (t) { t.emailMagicLinks = "emailMagicLinks", t.oauth = "oauth", t.otp = "otp", t.crypto = "crypto", t.passwords = "passwords"; }(Pt || (Pt = {})), function (t) { t.Google = "google", t.Microsoft = "microsoft", t.Apple = "apple", t.Github = "github", t.GitLab = "gitlab", t.Facebook = "facebook", t.Discord = "discord", t.Slack = "slack", t.Amazon = "amazon", t.Bitbucket = "bitbucket", t.LinkedIn = "linkedin", t.Coinbase = "coinbase", t.Twitch = "twitch"; }(Lt || (Lt = {})), function (t) { t.Vessel = "Vessel", t.Phantom = "Phantom", t.Metamask = "Metamask", t.Coinbase = "Coinbase", t.Binance = "Binance", t.GenericEthereumWallet = "Other Ethereum Wallet", t.GenericSolanaWallet = "Other Solana Wallet"; }(xt || (xt = {})), function (t) { t.embedded = "embedded", t.floating = "floating"; }(Ct || (Ct = {})), function (t) { t.SMS = "sms", t.WhatsApp = "whatsapp", t.Email = "email"; }(jt || (jt = {})), function (t) { t.MagicLinkLoginOrCreateEvent = "MAGIC_LINK_LOGIN_OR_CREATE", t.OTPsLoginOrCreateEvent = "OTP_LOGIN_OR_CREATE", t.OTPsAuthenticate = "OTP_AUTHENTICATE", t.CryptoWalletAuthenticateStart = "CRYPTO_WALLET_AUTHENTICATE_START", t.CryptoWalletAuthenticate = "CRYPTO_WALLET_AUTHENTICATE", t.PasswordCreate = "PASSWORD_CREATE", t.PasswordAuthenticate = "PASSWORD_AUTHENTICATE", t.PasswordResetByEmailStart = "PASSWORD_RESET_BY_EMAIL_START", t.PasswordResetByEmail = "PASSWORD_RESET_BY_EMAIL"; }(At || (At = {}));
934
- var $t; (function (t) { qt(r, Ht(Error)); var e = Gt(r); function r(t, n) { var o; return Ft(this, r), (o = e.call(this, t + "\n" + n)).message = t + "\n" + n, o.name = "SDKAPIUnreachableError", o.details = n, Object.setPrototypeOf(Wt(o), r.prototype), o; } return Kt(r); })(); (function (t) { qt(r, Ht(Error)); var e = Gt(r); function r(t, n) { var o; return Ft(this, r), (o = e.call(this)).name = "StytchSDKUsageError", o.message = "Invalid call to ".concat(t, "\n") + n, o; } return Kt(r); })(); (function (t) { qt(r, Ht(Error)); var e = Gt(r); function r(t) { var n, o; Ft(this, r), (n = e.call(this)).name = "StytchSDKSchemaError"; var i = null === (o = t.body) || void 0 === o ? void 0 : o.map((function (t) { return "".concat(t.dataPath, ": ").concat(t.message); })).join("\n"); return n.message = "[400] Request does not match expected schema\n".concat(i), n; } return Kt(r); })(); (function (t) { qt(r, Ht(Error)); var e = Gt(r); function r(t) { var n; Ft(this, r), (n = e.call(this)).name = "StytchSDKAPIError"; var o = t.status_code, i = t.error_type, a = t.error_message, s = t.error_url, c = t.request_id; return n.error_type = i, n.error_message = a, n.error_url = s, n.request_id = c, n.status_code = o, n.message = "[".concat(o, "] ").concat(i, "\n") + "".concat(a, "\n") + "See ".concat(s, " for more information.\n") + (c ? "request_id: ".concat(c, "\n") : ""), n; } return Kt(r); })(); (function (t) { qt(r, Ht(Error)); var e = Gt(r); function r(t) { var n; return Ft(this, r), (n = e.call(this)).name = "StytchSDKNativeError", n.error_type = t, n.message = "".concat(t), n; } return Kt(r); })();
935
- !function (t) { t.BiometricsSensorError = "biometrics_sensor_error", t.DeviceCredentialsNotAllowed = "device_credentials_not_allowed", t.DeviceHardwareError = "device_hardware_error", t.InternalError = "internal_error", t.KeyInvalidated = "key_invalidated", t.KeystoreUnavailable = "keystore_unavailable", t.NoBiometricsEnrolled = "no_biometrics_enrolled", t.NoBiometricsRegistration = "no_biometrics_registration", t.SessionExpired = "session_expired", t.UserCancellation = "user_cancellation", t.UserLockedOut = "user_locked_out"; }($t || ($t = {}));
999
+ function Ze(e, t) { return Ze = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (e, t) { return e.__proto__ = t, e; }, Ze(e, t); }
1000
+ function Qe(e) { return Qe = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (e) { return e.__proto__ || Object.getPrototypeOf(e); }, Qe(e); }
1001
+ !function (e) { e.emailMagicLinks = "emailMagicLinks", e.oauth = "oauth", e.otp = "otp", e.crypto = "crypto", e.passwords = "passwords"; }(Le || (Le = {})), function (e) { e.Google = "google", e.Microsoft = "microsoft", e.Apple = "apple", e.Github = "github", e.GitLab = "gitlab", e.Facebook = "facebook", e.Discord = "discord", e.Slack = "slack", e.Amazon = "amazon", e.Bitbucket = "bitbucket", e.LinkedIn = "linkedin", e.Coinbase = "coinbase", e.Twitch = "twitch"; }(Ae || (Ae = {})), function (e) { 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"; }(Re || (Re = {})), function (e) { e.embedded = "embedded", e.floating = "floating"; }(Ie || (Ie = {})), function (e) { e.SMS = "sms", e.WhatsApp = "whatsapp", e.Email = "email"; }(Ne || (Ne = {})), function (e) { 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"; }(De || (De = {}));
1002
+ var et; (function (e) { He(r, Je(Error)); var t = Ve(r); function r(e, n) { var o; return We(this, r), (o = t.call(this, e + "\n" + n)).message = e + "\n" + n, o.name = "SDKAPIUnreachableError", o.details = n, Object.setPrototypeOf(Ye(o), r.prototype), o; } return Ge(r); })(); (function (e) { He(r, Je(Error)); var t = Ve(r); function r(e, n) { var o; return We(this, r), (o = t.call(this)).name = "StytchSDKUsageError", o.message = "Invalid call to ".concat(e, "\n") + n, o; } return Ge(r); })(); (function (e) { He(r, Je(Error)); var t = Ve(r); function r(e) { var n, o; We(this, r), (n = t.call(this)).name = "StytchSDKSchemaError"; var i = null === (o = e.body) || void 0 === o ? void 0 : o.map((function (e) { return "".concat(e.dataPath, ": ").concat(e.message); })).join("\n"); return n.message = "[400] Request does not match expected schema\n".concat(i), n; } return Ge(r); })(); (function (e) { He(r, Je(Error)); var t = Ve(r); function r(e) { var n; We(this, r), (n = t.call(this)).name = "StytchSDKAPIError"; var o = e.status_code, i = e.error_type, a = e.error_message, s = e.error_url, c = e.request_id; return n.error_type = i, n.error_message = a, n.error_url = s, n.request_id = c, n.status_code = o, n.message = "[".concat(o, "] ").concat(i, "\n") + "".concat(a, "\n") + "See ".concat(s, " for more information.\n") + (c ? "request_id: ".concat(c, "\n") : ""), n; } return Ge(r); })(); (function (e) { He(r, Je(Error)); var t = Ve(r); function r(e) { var n; return We(this, r), (n = t.call(this)).name = "StytchSDKNativeError", n.error_type = e, n.message = "".concat(e), n; } return Ge(r); })();
1003
+ !function (e) { 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"; }(et || (et = {}));
936
1004
 
937
1005
  /**
938
1006
  * Creates a Headless Stytch client object to call the stytch B2B APIs.
@@ -951,7 +1019,7 @@ const createStytchB2BHeadlessClient = (...args) => {
951
1019
  if (typeof window === 'undefined') {
952
1020
  return createStytchSSRProxy();
953
1021
  }
954
- return new Mt(...args);
1022
+ return new Fe(...args);
955
1023
  };
956
1024
 
957
1025
  exports.StytchB2BProvider = StytchB2BProvider;