@stytch/vanilla-js 2.2.2 → 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/CHANGELOG.md +22 -0
- package/README.md +55 -3
- package/b2b/headless/package.json +6 -0
- package/dist/b2b/index.d.ts +1 -1
- package/dist/b2b/index.esm.d.ts +1 -1
- package/dist/b2b/index.esm.js +4 -7
- package/dist/b2b/index.headless.d.ts +634 -0
- package/dist/b2b/index.headless.esm.d.ts +634 -0
- package/dist/b2b/index.headless.esm.js +3811 -0
- package/dist/b2b/index.headless.js +3811 -0
- package/dist/b2b/index.js +4 -7
- package/dist/index.esm.js +1 -1
- package/dist/index.headless.esm.js +36 -39
- package/dist/index.headless.js +18 -21
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,3811 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
5
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
6
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
7
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
8
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
9
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
10
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
11
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e4) { throw _e4; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e5) { didErr = true; err = _e5; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
12
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
13
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
14
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
15
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
16
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
17
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
18
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
19
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
20
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
21
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
22
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
23
|
+
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
24
|
+
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
25
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
26
|
+
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
|
27
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
28
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
29
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
30
|
+
function e(e, r) {
|
|
31
|
+
return function (e) {
|
|
32
|
+
if (Array.isArray(e)) return e;
|
|
33
|
+
}(e) || function (e, t) {
|
|
34
|
+
var r = null == e ? null : "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
|
|
35
|
+
if (null != r) {
|
|
36
|
+
var n,
|
|
37
|
+
i,
|
|
38
|
+
o,
|
|
39
|
+
s,
|
|
40
|
+
a = [],
|
|
41
|
+
c = !0,
|
|
42
|
+
u = !1;
|
|
43
|
+
try {
|
|
44
|
+
if (o = (r = r.call(e)).next, 0 === t) {
|
|
45
|
+
if (Object(r) !== r) return;
|
|
46
|
+
c = !1;
|
|
47
|
+
} else for (; !(c = (n = o.call(r)).done) && (a.push(n.value), a.length !== t); c = !0);
|
|
48
|
+
} catch (e) {
|
|
49
|
+
u = !0, i = e;
|
|
50
|
+
} finally {
|
|
51
|
+
try {
|
|
52
|
+
if (!c && null != r["return"] && (s = r["return"](), Object(s) !== s)) return;
|
|
53
|
+
} finally {
|
|
54
|
+
if (u) throw i;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return a;
|
|
58
|
+
}
|
|
59
|
+
}(e, r) || t(e, r) || function () {
|
|
60
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
61
|
+
}();
|
|
62
|
+
}
|
|
63
|
+
function t(e, t) {
|
|
64
|
+
if (e) {
|
|
65
|
+
if ("string" == typeof e) return r(e, t);
|
|
66
|
+
var n = Object.prototype.toString.call(e).slice(8, -1);
|
|
67
|
+
return "Object" === n && e.constructor && (n = e.constructor.name), "Map" === n || "Set" === n ? Array.from(e) : "Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? r(e, t) : void 0;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function r(e, t) {
|
|
71
|
+
(null == t || t > e.length) && (t = e.length);
|
|
72
|
+
for (var r = 0, n = new Array(t); r < t; r++) n[r] = e[r];
|
|
73
|
+
return n;
|
|
74
|
+
}
|
|
75
|
+
function n(e) {
|
|
76
|
+
return n = "function" == typeof Symbol && "symbol" == _typeof(Symbol.iterator) ? function (e) {
|
|
77
|
+
return _typeof(e);
|
|
78
|
+
} : function (e) {
|
|
79
|
+
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : _typeof(e);
|
|
80
|
+
}, n(e);
|
|
81
|
+
}
|
|
82
|
+
function i() {
|
|
83
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
84
|
+
i = function i() {
|
|
85
|
+
return e;
|
|
86
|
+
};
|
|
87
|
+
var e = {},
|
|
88
|
+
t = Object.prototype,
|
|
89
|
+
r = t.hasOwnProperty,
|
|
90
|
+
o = Object.defineProperty || function (e, t, r) {
|
|
91
|
+
e[t] = r.value;
|
|
92
|
+
},
|
|
93
|
+
s = "function" == typeof Symbol ? Symbol : {},
|
|
94
|
+
a = s.iterator || "@@iterator",
|
|
95
|
+
c = s.asyncIterator || "@@asyncIterator",
|
|
96
|
+
u = s.toStringTag || "@@toStringTag";
|
|
97
|
+
function l(e, t, r) {
|
|
98
|
+
return Object.defineProperty(e, t, {
|
|
99
|
+
value: r,
|
|
100
|
+
enumerable: !0,
|
|
101
|
+
configurable: !0,
|
|
102
|
+
writable: !0
|
|
103
|
+
}), e[t];
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
l({}, "");
|
|
107
|
+
} catch (e) {
|
|
108
|
+
l = function l(e, t, r) {
|
|
109
|
+
return e[t] = r;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function d(e, t, r, n) {
|
|
113
|
+
var i = t && t.prototype instanceof p ? t : p,
|
|
114
|
+
s = Object.create(i.prototype),
|
|
115
|
+
a = new E(n || []);
|
|
116
|
+
return o(s, "_invoke", {
|
|
117
|
+
value: w(e, r, a)
|
|
118
|
+
}), s;
|
|
119
|
+
}
|
|
120
|
+
function h(e, t, r) {
|
|
121
|
+
try {
|
|
122
|
+
return {
|
|
123
|
+
type: "normal",
|
|
124
|
+
arg: e.call(t, r)
|
|
125
|
+
};
|
|
126
|
+
} catch (e) {
|
|
127
|
+
return {
|
|
128
|
+
type: "throw",
|
|
129
|
+
arg: e
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
e.wrap = d;
|
|
134
|
+
var _ = {};
|
|
135
|
+
function p() {}
|
|
136
|
+
function m() {}
|
|
137
|
+
function f() {}
|
|
138
|
+
var v = {};
|
|
139
|
+
l(v, a, function () {
|
|
140
|
+
return this;
|
|
141
|
+
});
|
|
142
|
+
var b = Object.getPrototypeOf,
|
|
143
|
+
g = b && b(b(C([])));
|
|
144
|
+
g && g !== t && r.call(g, a) && (v = g);
|
|
145
|
+
var y = f.prototype = p.prototype = Object.create(v);
|
|
146
|
+
function k(e) {
|
|
147
|
+
["next", "throw", "return"].forEach(function (t) {
|
|
148
|
+
l(e, t, function (e) {
|
|
149
|
+
return this._invoke(t, e);
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
function S(e, t) {
|
|
154
|
+
function i(o, s, a, c) {
|
|
155
|
+
var u = h(e[o], e, s);
|
|
156
|
+
if ("throw" !== u.type) {
|
|
157
|
+
var l = u.arg,
|
|
158
|
+
d = l.value;
|
|
159
|
+
return d && "object" == n(d) && r.call(d, "__await") ? t.resolve(d.__await).then(function (e) {
|
|
160
|
+
i("next", e, a, c);
|
|
161
|
+
}, function (e) {
|
|
162
|
+
i("throw", e, a, c);
|
|
163
|
+
}) : t.resolve(d).then(function (e) {
|
|
164
|
+
l.value = e, a(l);
|
|
165
|
+
}, function (e) {
|
|
166
|
+
return i("throw", e, a, c);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
c(u.arg);
|
|
170
|
+
}
|
|
171
|
+
var s;
|
|
172
|
+
o(this, "_invoke", {
|
|
173
|
+
value: function value(e, r) {
|
|
174
|
+
function n() {
|
|
175
|
+
return new t(function (t, n) {
|
|
176
|
+
i(e, r, t, n);
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
return s = s ? s.then(n, n) : n();
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
function w(e, t, r) {
|
|
184
|
+
var n = "suspendedStart";
|
|
185
|
+
return function (i, o) {
|
|
186
|
+
if ("executing" === n) throw new Error("Generator is already running");
|
|
187
|
+
if ("completed" === n) {
|
|
188
|
+
if ("throw" === i) throw o;
|
|
189
|
+
return P();
|
|
190
|
+
}
|
|
191
|
+
for (r.method = i, r.arg = o;;) {
|
|
192
|
+
var s = r.delegate;
|
|
193
|
+
if (s) {
|
|
194
|
+
var a = A(s, r);
|
|
195
|
+
if (a) {
|
|
196
|
+
if (a === _) continue;
|
|
197
|
+
return a;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if ("next" === r.method) r.sent = r._sent = r.arg;else if ("throw" === r.method) {
|
|
201
|
+
if ("suspendedStart" === n) throw n = "completed", r.arg;
|
|
202
|
+
r.dispatchException(r.arg);
|
|
203
|
+
} else "return" === r.method && r.abrupt("return", r.arg);
|
|
204
|
+
n = "executing";
|
|
205
|
+
var c = h(e, t, r);
|
|
206
|
+
if ("normal" === c.type) {
|
|
207
|
+
if (n = r.done ? "completed" : "suspendedYield", c.arg === _) continue;
|
|
208
|
+
return {
|
|
209
|
+
value: c.arg,
|
|
210
|
+
done: r.done
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
"throw" === c.type && (n = "completed", r.method = "throw", r.arg = c.arg);
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
function A(e, t) {
|
|
218
|
+
var r = t.method,
|
|
219
|
+
n = e.iterator[r];
|
|
220
|
+
if (void 0 === n) return t.delegate = null, "throw" === r && e.iterator["return"] && (t.method = "return", t.arg = void 0, A(e, t), "throw" === t.method) || "return" !== r && (t.method = "throw", t.arg = new TypeError("The iterator does not provide a '" + r + "' method")), _;
|
|
221
|
+
var i = h(n, e.iterator, t.arg);
|
|
222
|
+
if ("throw" === i.type) return t.method = "throw", t.arg = i.arg, t.delegate = null, _;
|
|
223
|
+
var o = i.arg;
|
|
224
|
+
return o ? o.done ? (t[e.resultName] = o.value, t.next = e.nextLoc, "return" !== t.method && (t.method = "next", t.arg = void 0), t.delegate = null, _) : o : (t.method = "throw", t.arg = new TypeError("iterator result is not an object"), t.delegate = null, _);
|
|
225
|
+
}
|
|
226
|
+
function T(e) {
|
|
227
|
+
var t = {
|
|
228
|
+
tryLoc: e[0]
|
|
229
|
+
};
|
|
230
|
+
1 in e && (t.catchLoc = e[1]), 2 in e && (t.finallyLoc = e[2], t.afterLoc = e[3]), this.tryEntries.push(t);
|
|
231
|
+
}
|
|
232
|
+
function O(e) {
|
|
233
|
+
var t = e.completion || {};
|
|
234
|
+
t.type = "normal", delete t.arg, e.completion = t;
|
|
235
|
+
}
|
|
236
|
+
function E(e) {
|
|
237
|
+
this.tryEntries = [{
|
|
238
|
+
tryLoc: "root"
|
|
239
|
+
}], e.forEach(T, this), this.reset(!0);
|
|
240
|
+
}
|
|
241
|
+
function C(e) {
|
|
242
|
+
if (e) {
|
|
243
|
+
var t = e[a];
|
|
244
|
+
if (t) return t.call(e);
|
|
245
|
+
if ("function" == typeof e.next) return e;
|
|
246
|
+
if (!isNaN(e.length)) {
|
|
247
|
+
var n = -1,
|
|
248
|
+
i = function t() {
|
|
249
|
+
for (; ++n < e.length;) if (r.call(e, n)) return t.value = e[n], t.done = !1, t;
|
|
250
|
+
return t.value = void 0, t.done = !0, t;
|
|
251
|
+
};
|
|
252
|
+
return i.next = i;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return {
|
|
256
|
+
next: P
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
function P() {
|
|
260
|
+
return {
|
|
261
|
+
value: void 0,
|
|
262
|
+
done: !0
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
return m.prototype = f, o(y, "constructor", {
|
|
266
|
+
value: f,
|
|
267
|
+
configurable: !0
|
|
268
|
+
}), o(f, "constructor", {
|
|
269
|
+
value: m,
|
|
270
|
+
configurable: !0
|
|
271
|
+
}), m.displayName = l(f, u, "GeneratorFunction"), e.isGeneratorFunction = function (e) {
|
|
272
|
+
var t = "function" == typeof e && e.constructor;
|
|
273
|
+
return !!t && (t === m || "GeneratorFunction" === (t.displayName || t.name));
|
|
274
|
+
}, e.mark = function (e) {
|
|
275
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(e, f) : (e.__proto__ = f, l(e, u, "GeneratorFunction")), e.prototype = Object.create(y), e;
|
|
276
|
+
}, e.awrap = function (e) {
|
|
277
|
+
return {
|
|
278
|
+
__await: e
|
|
279
|
+
};
|
|
280
|
+
}, k(S.prototype), l(S.prototype, c, function () {
|
|
281
|
+
return this;
|
|
282
|
+
}), e.AsyncIterator = S, e.async = function (t, r, n, i, o) {
|
|
283
|
+
void 0 === o && (o = Promise);
|
|
284
|
+
var s = new S(d(t, r, n, i), o);
|
|
285
|
+
return e.isGeneratorFunction(r) ? s : s.next().then(function (e) {
|
|
286
|
+
return e.done ? e.value : s.next();
|
|
287
|
+
});
|
|
288
|
+
}, k(y), l(y, u, "Generator"), l(y, a, function () {
|
|
289
|
+
return this;
|
|
290
|
+
}), l(y, "toString", function () {
|
|
291
|
+
return "[object Generator]";
|
|
292
|
+
}), e.keys = function (e) {
|
|
293
|
+
var t = Object(e),
|
|
294
|
+
r = [];
|
|
295
|
+
for (var n in t) r.push(n);
|
|
296
|
+
return r.reverse(), function e() {
|
|
297
|
+
for (; r.length;) {
|
|
298
|
+
var n = r.pop();
|
|
299
|
+
if (n in t) return e.value = n, e.done = !1, e;
|
|
300
|
+
}
|
|
301
|
+
return e.done = !0, e;
|
|
302
|
+
};
|
|
303
|
+
}, e.values = C, E.prototype = {
|
|
304
|
+
constructor: E,
|
|
305
|
+
reset: function reset(e) {
|
|
306
|
+
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(O), !e) for (var t in this) "t" === t.charAt(0) && r.call(this, t) && !isNaN(+t.slice(1)) && (this[t] = void 0);
|
|
307
|
+
},
|
|
308
|
+
stop: function stop() {
|
|
309
|
+
this.done = !0;
|
|
310
|
+
var e = this.tryEntries[0].completion;
|
|
311
|
+
if ("throw" === e.type) throw e.arg;
|
|
312
|
+
return this.rval;
|
|
313
|
+
},
|
|
314
|
+
dispatchException: function dispatchException(e) {
|
|
315
|
+
if (this.done) throw e;
|
|
316
|
+
var t = this;
|
|
317
|
+
function n(r, n) {
|
|
318
|
+
return s.type = "throw", s.arg = e, t.next = r, n && (t.method = "next", t.arg = void 0), !!n;
|
|
319
|
+
}
|
|
320
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
321
|
+
var o = this.tryEntries[i],
|
|
322
|
+
s = o.completion;
|
|
323
|
+
if ("root" === o.tryLoc) return n("end");
|
|
324
|
+
if (o.tryLoc <= this.prev) {
|
|
325
|
+
var a = r.call(o, "catchLoc"),
|
|
326
|
+
c = r.call(o, "finallyLoc");
|
|
327
|
+
if (a && c) {
|
|
328
|
+
if (this.prev < o.catchLoc) return n(o.catchLoc, !0);
|
|
329
|
+
if (this.prev < o.finallyLoc) return n(o.finallyLoc);
|
|
330
|
+
} else if (a) {
|
|
331
|
+
if (this.prev < o.catchLoc) return n(o.catchLoc, !0);
|
|
332
|
+
} else {
|
|
333
|
+
if (!c) throw new Error("try statement without catch or finally");
|
|
334
|
+
if (this.prev < o.finallyLoc) return n(o.finallyLoc);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
abrupt: function abrupt(e, t) {
|
|
340
|
+
for (var n = this.tryEntries.length - 1; n >= 0; --n) {
|
|
341
|
+
var i = this.tryEntries[n];
|
|
342
|
+
if (i.tryLoc <= this.prev && r.call(i, "finallyLoc") && this.prev < i.finallyLoc) {
|
|
343
|
+
var o = i;
|
|
344
|
+
break;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
o && ("break" === e || "continue" === e) && o.tryLoc <= t && t <= o.finallyLoc && (o = null);
|
|
348
|
+
var s = o ? o.completion : {};
|
|
349
|
+
return s.type = e, s.arg = t, o ? (this.method = "next", this.next = o.finallyLoc, _) : this.complete(s);
|
|
350
|
+
},
|
|
351
|
+
complete: function complete(e, t) {
|
|
352
|
+
if ("throw" === e.type) throw e.arg;
|
|
353
|
+
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), _;
|
|
354
|
+
},
|
|
355
|
+
finish: function finish(e) {
|
|
356
|
+
for (var t = this.tryEntries.length - 1; t >= 0; --t) {
|
|
357
|
+
var r = this.tryEntries[t];
|
|
358
|
+
if (r.finallyLoc === e) return this.complete(r.completion, r.afterLoc), O(r), _;
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
"catch": function _catch(e) {
|
|
362
|
+
for (var t = this.tryEntries.length - 1; t >= 0; --t) {
|
|
363
|
+
var r = this.tryEntries[t];
|
|
364
|
+
if (r.tryLoc === e) {
|
|
365
|
+
var n = r.completion;
|
|
366
|
+
if ("throw" === n.type) {
|
|
367
|
+
var i = n.arg;
|
|
368
|
+
O(r);
|
|
369
|
+
}
|
|
370
|
+
return i;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
throw new Error("illegal catch attempt");
|
|
374
|
+
},
|
|
375
|
+
delegateYield: function delegateYield(e, t, r) {
|
|
376
|
+
return this.delegate = {
|
|
377
|
+
iterator: C(e),
|
|
378
|
+
resultName: t,
|
|
379
|
+
nextLoc: r
|
|
380
|
+
}, "next" === this.method && (this.arg = void 0), _;
|
|
381
|
+
}
|
|
382
|
+
}, e;
|
|
383
|
+
}
|
|
384
|
+
function o(e, t) {
|
|
385
|
+
for (var r = 0; r < t.length; r++) {
|
|
386
|
+
var i = t[r];
|
|
387
|
+
i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, (o = i.key, s = void 0, s = function (e, t) {
|
|
388
|
+
if ("object" !== n(e) || null === e) return e;
|
|
389
|
+
var r = e[Symbol.toPrimitive];
|
|
390
|
+
if (void 0 !== r) {
|
|
391
|
+
var i = r.call(e, t || "default");
|
|
392
|
+
if ("object" !== n(i)) return i;
|
|
393
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
394
|
+
}
|
|
395
|
+
return ("string" === t ? String : Number)(e);
|
|
396
|
+
}(o, "string"), "symbol" === n(s) ? s : String(s)), i);
|
|
397
|
+
}
|
|
398
|
+
var o, s;
|
|
399
|
+
}
|
|
400
|
+
function s(e, t, r) {
|
|
401
|
+
return t && o(e.prototype, t), r && o(e, r), Object.defineProperty(e, "prototype", {
|
|
402
|
+
writable: !1
|
|
403
|
+
}), e;
|
|
404
|
+
}
|
|
405
|
+
function a(e, t) {
|
|
406
|
+
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
|
|
407
|
+
}
|
|
408
|
+
function c(e, t) {
|
|
409
|
+
if ("function" != typeof t && null !== t) throw new TypeError("Super expression must either be null or a function");
|
|
410
|
+
e.prototype = Object.create(t && t.prototype, {
|
|
411
|
+
constructor: {
|
|
412
|
+
value: e,
|
|
413
|
+
writable: !0,
|
|
414
|
+
configurable: !0
|
|
415
|
+
}
|
|
416
|
+
}), Object.defineProperty(e, "prototype", {
|
|
417
|
+
writable: !1
|
|
418
|
+
}), t && p(e, t);
|
|
419
|
+
}
|
|
420
|
+
function u(e) {
|
|
421
|
+
var t = _();
|
|
422
|
+
return function () {
|
|
423
|
+
var r,
|
|
424
|
+
i = m(e);
|
|
425
|
+
if (t) {
|
|
426
|
+
var o = m(this).constructor;
|
|
427
|
+
r = Reflect.construct(i, arguments, o);
|
|
428
|
+
} else r = i.apply(this, arguments);
|
|
429
|
+
return function (e, t) {
|
|
430
|
+
if (t && ("object" === n(t) || "function" == typeof t)) return t;
|
|
431
|
+
if (void 0 !== t) throw new TypeError("Derived constructors may only return object or undefined");
|
|
432
|
+
return l(e);
|
|
433
|
+
}(this, r);
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
function l(e) {
|
|
437
|
+
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
438
|
+
return e;
|
|
439
|
+
}
|
|
440
|
+
function d(e) {
|
|
441
|
+
var t = "function" == typeof Map ? new Map() : void 0;
|
|
442
|
+
return d = function d(e) {
|
|
443
|
+
if (null === e || (r = e, -1 === Function.toString.call(r).indexOf("[native code]"))) return e;
|
|
444
|
+
var r;
|
|
445
|
+
if ("function" != typeof e) throw new TypeError("Super expression must either be null or a function");
|
|
446
|
+
if (void 0 !== t) {
|
|
447
|
+
if (t.has(e)) return t.get(e);
|
|
448
|
+
t.set(e, n);
|
|
449
|
+
}
|
|
450
|
+
function n() {
|
|
451
|
+
return h(e, arguments, m(this).constructor);
|
|
452
|
+
}
|
|
453
|
+
return n.prototype = Object.create(e.prototype, {
|
|
454
|
+
constructor: {
|
|
455
|
+
value: n,
|
|
456
|
+
enumerable: !1,
|
|
457
|
+
writable: !0,
|
|
458
|
+
configurable: !0
|
|
459
|
+
}
|
|
460
|
+
}), p(n, e);
|
|
461
|
+
}, d(e);
|
|
462
|
+
}
|
|
463
|
+
function h(e, t, r) {
|
|
464
|
+
return h = _() ? Reflect.construct.bind() : function (e, t, r) {
|
|
465
|
+
var n = [null];
|
|
466
|
+
n.push.apply(n, t);
|
|
467
|
+
var i = new (Function.bind.apply(e, n))();
|
|
468
|
+
return r && p(i, r.prototype), i;
|
|
469
|
+
}, h.apply(null, arguments);
|
|
470
|
+
}
|
|
471
|
+
function _() {
|
|
472
|
+
if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
|
|
473
|
+
if (Reflect.construct.sham) return !1;
|
|
474
|
+
if ("function" == typeof Proxy) return !0;
|
|
475
|
+
try {
|
|
476
|
+
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})), !0;
|
|
477
|
+
} catch (e) {
|
|
478
|
+
return !1;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
function p(e, t) {
|
|
482
|
+
return p = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (e, t) {
|
|
483
|
+
return e.__proto__ = t, e;
|
|
484
|
+
}, p(e, t);
|
|
485
|
+
}
|
|
486
|
+
function m(e) {
|
|
487
|
+
return m = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (e) {
|
|
488
|
+
return e.__proto__ || Object.getPrototypeOf(e);
|
|
489
|
+
}, m(e);
|
|
490
|
+
}
|
|
491
|
+
var f, v, b, g, y, k;
|
|
492
|
+
function S(e, t, r, n) {
|
|
493
|
+
return new (r || (r = Promise))(function (i, o) {
|
|
494
|
+
function s(e) {
|
|
495
|
+
try {
|
|
496
|
+
c(n.next(e));
|
|
497
|
+
} catch (e) {
|
|
498
|
+
o(e);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
function a(e) {
|
|
502
|
+
try {
|
|
503
|
+
c(n["throw"](e));
|
|
504
|
+
} catch (e) {
|
|
505
|
+
o(e);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
function c(e) {
|
|
509
|
+
var t;
|
|
510
|
+
e.done ? i(e.value) : (t = e.value, t instanceof r ? t : new r(function (e) {
|
|
511
|
+
e(t);
|
|
512
|
+
})).then(s, a);
|
|
513
|
+
}
|
|
514
|
+
c((n = n.apply(e, t || [])).next());
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
!function (e) {
|
|
518
|
+
e.emailMagicLinks = "emailMagicLinks", e.oauth = "oauth", e.otp = "otp", e.crypto = "crypto", e.passwords = "passwords";
|
|
519
|
+
}(f || (f = {})), function (e) {
|
|
520
|
+
e.Google = "google", e.Microsoft = "microsoft", e.Apple = "apple", e.Github = "github", e.GitLab = "gitlab", e.Facebook = "facebook", e.Discord = "discord", e.Salesforce = "salesforce", e.Slack = "slack", e.Amazon = "amazon", e.Bitbucket = "bitbucket", e.LinkedIn = "linkedin", e.Coinbase = "coinbase", e.Twitch = "twitch", e.Twitter = "twitter", e.TikTok = "tiktok", e.Snapchat = "snapchat", e.Figma = "figma", e.Yahoo = "yahoo";
|
|
521
|
+
}(v || (v = {})), function (e) {
|
|
522
|
+
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";
|
|
523
|
+
}(b || (b = {})), function (e) {
|
|
524
|
+
e.embedded = "embedded", e.floating = "floating";
|
|
525
|
+
}(g || (g = {})), function (e) {
|
|
526
|
+
e.SMS = "sms", e.WhatsApp = "whatsapp", e.Email = "email";
|
|
527
|
+
}(y || (y = {})), function (e) {
|
|
528
|
+
e.MagicLinkLoginOrCreateEvent = "MAGIC_LINK_LOGIN_OR_CREATE", e.OTPsLoginOrCreateEvent = "OTP_LOGIN_OR_CREATE", e.OTPsAuthenticate = "OTP_AUTHENTICATE", e.CryptoWalletAuthenticateStart = "CRYPTO_WALLET_AUTHENTICATE_START", e.CryptoWalletAuthenticate = "CRYPTO_WALLET_AUTHENTICATE", e.PasswordCreate = "PASSWORD_CREATE", e.PasswordAuthenticate = "PASSWORD_AUTHENTICATE", e.PasswordResetByEmailStart = "PASSWORD_RESET_BY_EMAIL_START", e.PasswordResetByEmail = "PASSWORD_RESET_BY_EMAIL", e.B2BMagicLinkEmailLoginOrSignup = "B2B_MAGIC_LINK_EMAIL_LOGIN_OR_SIGNUP", e.B2BMagicLinkAuthenticate = "B2B_MAGIC_LINK_AUTHENTICATE", e.B2BMagicLinkEmailDiscoverySend = "B2B_MAGIC_LINK_EMAIL_DISCOVERY_SEND", e.B2BMagicLinkDiscoveryAuthenticate = "B2B_MAGIC_LINK_DISCOVERY_AUTHENTICATE", e.B2BSSOStart = "B2B_SSO_START", e.B2BSSOAuthenticate = "B2B_SSO_AUTHENTICATE", e.B2BOAuthAuthenticate = "B2B_SSO_AUTHENTICATE", e.B2BOAuthDiscoveryAuthenticate = "B2B_OAUTH_DISCOVERY_AUTHENTICATE", e.B2BDiscoveryOrganizationsCreate = "B2B_DISCOVERY_ORGANIZATIONS_CREATE", e.B2BDiscoveryIntermediateSessionExchange = "B2B_DISCOVERY_INTERMEDIATE_SESSION_EXCHANGE", e.B2BPasswordAuthenticate = "B2B_PASSWORD_AUTHENTICATE", e.B2BPasswordResetByEmailStart = "B2B_PASSWORD_RESET_BY_EMAIL_START", e.B2BPasswordResetByEmail = "B2B_PASSWORD_RESET_BY_EMAIL", e.B2BPasswordResetBySession = "B2B_PASSWORD_RESET_BY_SESSION";
|
|
529
|
+
}(k || (k = {}));
|
|
530
|
+
var w,
|
|
531
|
+
A,
|
|
532
|
+
T,
|
|
533
|
+
O,
|
|
534
|
+
E,
|
|
535
|
+
C = function (e) {
|
|
536
|
+
c(r, d(Error));
|
|
537
|
+
var t = u(r);
|
|
538
|
+
function r(e, n) {
|
|
539
|
+
var i;
|
|
540
|
+
return a(this, r), (i = t.call(this, e + "\n" + n)).message = e + "\n" + n, i.name = "SDKAPIUnreachableError", i.details = n, Object.setPrototypeOf(l(i), r.prototype), i;
|
|
541
|
+
}
|
|
542
|
+
return s(r);
|
|
543
|
+
}(),
|
|
544
|
+
P = function (e) {
|
|
545
|
+
c(r, d(Error));
|
|
546
|
+
var t = u(r);
|
|
547
|
+
function r(e, n) {
|
|
548
|
+
var i;
|
|
549
|
+
return a(this, r), (i = t.call(this)).name = "StytchSDKUsageError", i.message = "Invalid call to ".concat(e, "\n") + n, i;
|
|
550
|
+
}
|
|
551
|
+
return s(r);
|
|
552
|
+
}(),
|
|
553
|
+
B = function (e) {
|
|
554
|
+
c(r, d(Error));
|
|
555
|
+
var t = u(r);
|
|
556
|
+
function r(e) {
|
|
557
|
+
var n, i;
|
|
558
|
+
a(this, r), (n = t.call(this)).name = "StytchSDKSchemaError";
|
|
559
|
+
var o = null === (i = e.body) || void 0 === i ? void 0 : i.map(function (e) {
|
|
560
|
+
return "".concat(e.dataPath, ": ").concat(e.message);
|
|
561
|
+
}).join("\n");
|
|
562
|
+
return n.message = "[400] Request does not match expected schema\n".concat(o), n;
|
|
563
|
+
}
|
|
564
|
+
return s(r);
|
|
565
|
+
}(),
|
|
566
|
+
x = function (e) {
|
|
567
|
+
c(r, d(Error));
|
|
568
|
+
var t = u(r);
|
|
569
|
+
function r(e) {
|
|
570
|
+
var n;
|
|
571
|
+
a(this, r), (n = t.call(this)).name = "StytchSDKAPIError";
|
|
572
|
+
var i = e.status_code,
|
|
573
|
+
o = e.error_type,
|
|
574
|
+
s = e.error_message,
|
|
575
|
+
c = e.error_url,
|
|
576
|
+
u = e.request_id;
|
|
577
|
+
return n.error_type = o, n.error_message = s, n.error_url = c, n.request_id = u, n.status_code = i, n.message = "[".concat(i, "] ").concat(o, "\n") + "".concat(s, "\n") + "See ".concat(c, " for more information.\n") + (u ? "request_id: ".concat(u, "\n") : ""), n;
|
|
578
|
+
}
|
|
579
|
+
return s(r);
|
|
580
|
+
}(),
|
|
581
|
+
R = ["unauthorized_credentials", "user_unauthenticated", "invalid_secret_authentication", "session_not_found"];
|
|
582
|
+
!function (e) {
|
|
583
|
+
e.BiometricsSensorError = "biometrics_sensor_error", e.DeviceCredentialsNotAllowed = "device_credentials_not_allowed", e.DeviceHardwareError = "device_hardware_error", e.InternalError = "internal_error", e.KeyInvalidated = "key_invalidated", e.KeystoreUnavailable = "keystore_unavailable", e.NoBiometricsEnrolled = "no_biometrics_enrolled", e.NoBiometricsRegistration = "no_biometrics_registration", e.SessionExpired = "session_expired", e.UserCancellation = "user_cancellation", e.UserLockedOut = "user_locked_out", e.BiometricsNotAvailable = "biometrics_not_available";
|
|
584
|
+
}(w || (w = {})), function (e) {
|
|
585
|
+
e.emailMagicLinks = "emailMagicLinks", e.sso = "sso", e.passwords = "passwords", e.oauth = "oauth";
|
|
586
|
+
}(A || (A = {})), function (e) {
|
|
587
|
+
e.Discovery = "Discovery", e.Organization = "Organization", e.PasswordReset = "PasswordReset";
|
|
588
|
+
}(T || (T = {})), function (e) {
|
|
589
|
+
e.Google = "google", e.Microsoft = "microsoft";
|
|
590
|
+
}(O || (O = {})), (E || (E = {})).RequiredCatcha = "Catcha Required";
|
|
591
|
+
var I,
|
|
592
|
+
D = function (e) {
|
|
593
|
+
c(r, d(Error));
|
|
594
|
+
var t = u(r);
|
|
595
|
+
function r(e) {
|
|
596
|
+
var n;
|
|
597
|
+
return a(this, r), (n = t.call(this, e)).type = e, n;
|
|
598
|
+
}
|
|
599
|
+
return s(r);
|
|
600
|
+
}();
|
|
601
|
+
function L(e) {
|
|
602
|
+
var t = e.method,
|
|
603
|
+
r = e.errorMessage,
|
|
604
|
+
n = e.finalURL,
|
|
605
|
+
o = e.basicAuthHeader,
|
|
606
|
+
s = e.xSDKClientHeader,
|
|
607
|
+
a = e.xSDKParentHostHeader,
|
|
608
|
+
c = e.body;
|
|
609
|
+
return S(this, void 0, void 0, i().mark(function e() {
|
|
610
|
+
var u, l, d, h, _, p;
|
|
611
|
+
return i().wrap(function (e) {
|
|
612
|
+
for (;;) switch (e.prev = e.next) {
|
|
613
|
+
case 0:
|
|
614
|
+
return u = {
|
|
615
|
+
Authorization: o,
|
|
616
|
+
"Content-Type": "application/json",
|
|
617
|
+
"X-SDK-Client": s
|
|
618
|
+
}, a && (u["X-SDK-Parent-Host"] = a), l = {
|
|
619
|
+
method: t,
|
|
620
|
+
headers: u,
|
|
621
|
+
body: c && JSON.stringify(c)
|
|
622
|
+
}, e.prev = 3, e.next = 6, fetch(n, l);
|
|
623
|
+
case 6:
|
|
624
|
+
d = e.sent, e.next = 14;
|
|
625
|
+
break;
|
|
626
|
+
case 9:
|
|
627
|
+
if (e.prev = 9, e.t0 = e["catch"](3), "Failed to fetch" !== e.t0.message) {
|
|
628
|
+
e.next = 13;
|
|
629
|
+
break;
|
|
630
|
+
}
|
|
631
|
+
throw new C(r, "Unable to contact the Stytch servers. Are you online?");
|
|
632
|
+
case 13:
|
|
633
|
+
throw e.t0;
|
|
634
|
+
case 14:
|
|
635
|
+
if (403 !== d.status) {
|
|
636
|
+
e.next = 27;
|
|
637
|
+
break;
|
|
638
|
+
}
|
|
639
|
+
return e.prev = 15, e.next = 18, d.text();
|
|
640
|
+
case 18:
|
|
641
|
+
h = e.sent, e.next = 24;
|
|
642
|
+
break;
|
|
643
|
+
case 21:
|
|
644
|
+
throw e.prev = 21, e.t1 = e["catch"](15), new C(r, "Invalid response from the Stytch servers.");
|
|
645
|
+
case 24:
|
|
646
|
+
if (!h.includes("Captcha required")) {
|
|
647
|
+
e.next = 26;
|
|
648
|
+
break;
|
|
649
|
+
}
|
|
650
|
+
throw new D(E.RequiredCatcha);
|
|
651
|
+
case 26:
|
|
652
|
+
throw new C(r, "Invalid response from the Stytch servers.");
|
|
653
|
+
case 27:
|
|
654
|
+
if (200 === d.status) {
|
|
655
|
+
e.next = 40;
|
|
656
|
+
break;
|
|
657
|
+
}
|
|
658
|
+
return e.prev = 28, e.next = 31, d.json();
|
|
659
|
+
case 31:
|
|
660
|
+
_ = e.sent, e.next = 37;
|
|
661
|
+
break;
|
|
662
|
+
case 34:
|
|
663
|
+
throw e.prev = 34, e.t2 = e["catch"](28), new C(r, "Invalid or no response from server");
|
|
664
|
+
case 37:
|
|
665
|
+
if (!("body" in _ || "params" in _ || "query" in _)) {
|
|
666
|
+
e.next = 39;
|
|
667
|
+
break;
|
|
668
|
+
}
|
|
669
|
+
throw new B(_);
|
|
670
|
+
case 39:
|
|
671
|
+
throw new x(_);
|
|
672
|
+
case 40:
|
|
673
|
+
return e.prev = 40, e.next = 43, d.json();
|
|
674
|
+
case 43:
|
|
675
|
+
return p = e.sent, e.abrupt("return", p.data);
|
|
676
|
+
case 47:
|
|
677
|
+
throw e.prev = 47, e.t3 = e["catch"](40), new C(r, "Invalid response from the Stytch servers.");
|
|
678
|
+
case 50:
|
|
679
|
+
case "end":
|
|
680
|
+
return e.stop();
|
|
681
|
+
}
|
|
682
|
+
}, e, null, [[3, 9], [15, 21], [28, 34], [40, 47]]);
|
|
683
|
+
}));
|
|
684
|
+
}
|
|
685
|
+
var M = new Uint8Array(16);
|
|
686
|
+
function N() {
|
|
687
|
+
if (!I && !(I = "undefined" != typeof crypto && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || "undefined" != typeof msCrypto && "function" == typeof msCrypto.getRandomValues && msCrypto.getRandomValues.bind(msCrypto))) throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
688
|
+
return I(M);
|
|
689
|
+
}
|
|
690
|
+
var j = /^(?:[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;
|
|
691
|
+
for (var F = [], K = 0; K < 256; ++K) F.push((K + 256).toString(16).substr(1));
|
|
692
|
+
function U(e) {
|
|
693
|
+
var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 0,
|
|
694
|
+
r = (F[e[t + 0]] + F[e[t + 1]] + F[e[t + 2]] + F[e[t + 3]] + "-" + F[e[t + 4]] + F[e[t + 5]] + "-" + F[e[t + 6]] + F[e[t + 7]] + "-" + F[e[t + 8]] + F[e[t + 9]] + "-" + F[e[t + 10]] + F[e[t + 11]] + F[e[t + 12]] + F[e[t + 13]] + F[e[t + 14]] + F[e[t + 15]]).toLowerCase();
|
|
695
|
+
if (!function (e) {
|
|
696
|
+
return "string" == typeof e && j.test(e);
|
|
697
|
+
}(r)) throw TypeError("Stringified UUID is invalid");
|
|
698
|
+
return r;
|
|
699
|
+
}
|
|
700
|
+
function z(e, t, r) {
|
|
701
|
+
var n = (e = e || {}).random || (e.rng || N)();
|
|
702
|
+
if (n[6] = 15 & n[6] | 64, n[8] = 63 & n[8] | 128, t) {
|
|
703
|
+
r = r || 0;
|
|
704
|
+
for (var i = 0; i < 16; ++i) t[r + i] = n[i];
|
|
705
|
+
return t;
|
|
706
|
+
}
|
|
707
|
+
return U(n);
|
|
708
|
+
}
|
|
709
|
+
var W = {};
|
|
710
|
+
function G(e, t) {
|
|
711
|
+
return S(this, void 0, void 0, i().mark(function r() {
|
|
712
|
+
return i().wrap(function (r) {
|
|
713
|
+
for (;;) switch (r.prev = r.next) {
|
|
714
|
+
case 0:
|
|
715
|
+
if (void 0 === W[e]) {
|
|
716
|
+
r.next = 2;
|
|
717
|
+
break;
|
|
718
|
+
}
|
|
719
|
+
return r.abrupt("return", W[e]);
|
|
720
|
+
case 2:
|
|
721
|
+
return W[e] = H(e, t), r.abrupt("return", W[e]);
|
|
722
|
+
case 4:
|
|
723
|
+
case "end":
|
|
724
|
+
return r.stop();
|
|
725
|
+
}
|
|
726
|
+
}, r);
|
|
727
|
+
}));
|
|
728
|
+
}
|
|
729
|
+
function H(e, t) {
|
|
730
|
+
return new Promise(function (r, n) {
|
|
731
|
+
var i = function (e) {
|
|
732
|
+
var t = q(e);
|
|
733
|
+
if (t[0]) return t[0];
|
|
734
|
+
}(e);
|
|
735
|
+
if (i && "true" === i.dataset.loaded) try {
|
|
736
|
+
r(t());
|
|
737
|
+
} catch (t) {
|
|
738
|
+
return n(new Error("".concat(e, " already loaded, but module was not found in global scope: ").concat(t)));
|
|
739
|
+
}
|
|
740
|
+
var o = function (e) {
|
|
741
|
+
var t = document.createElement("script");
|
|
742
|
+
return t.setAttribute("src", e), t.setAttribute("async", "true"), t.setAttribute("defer", "true"), document.head.appendChild(t), t;
|
|
743
|
+
}(e);
|
|
744
|
+
o.addEventListener("load", function () {
|
|
745
|
+
o.dataset.loaded = "true";
|
|
746
|
+
try {
|
|
747
|
+
r(t());
|
|
748
|
+
} catch (t) {
|
|
749
|
+
n(new Error("".concat(e, " was loaded, but module was not found in global scope: ").concat(t)));
|
|
750
|
+
}
|
|
751
|
+
}), o.addEventListener("error", function (t) {
|
|
752
|
+
n(new Error("".concat(e, " could not be loaded: ").concat(t)));
|
|
753
|
+
});
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
var q = function q(e) {
|
|
757
|
+
return document.querySelectorAll('script[src="'.concat(e, '"]'));
|
|
758
|
+
};
|
|
759
|
+
var Y,
|
|
760
|
+
V = ["[Stytch]"],
|
|
761
|
+
$ = function $() {
|
|
762
|
+
for (var e, t = arguments.length, r = new Array(t), n = 0; n < t; n++) r[n] = arguments[n];
|
|
763
|
+
return (e = console).warn.apply(e, V.concat(r));
|
|
764
|
+
},
|
|
765
|
+
J = function J() {
|
|
766
|
+
for (var e, t = arguments.length, r = new Array(t), n = 0; n < t; n++) r[n] = arguments[n];
|
|
767
|
+
return (e = console).error.apply(e, V.concat(r));
|
|
768
|
+
},
|
|
769
|
+
X = "\nYou can find your public token at https://stytch.com/dashboard/api-keys.",
|
|
770
|
+
Z = function Z(e) {
|
|
771
|
+
return e.includes("public-token-test");
|
|
772
|
+
},
|
|
773
|
+
Q = function Q(e) {
|
|
774
|
+
var r = {
|
|
775
|
+
isObject: function isObject(t, i) {
|
|
776
|
+
var o = "object" === n(i) && !Array.isArray(i) && null !== i;
|
|
777
|
+
if (!o) throw new P(e, t + " must be an object.");
|
|
778
|
+
return r;
|
|
779
|
+
},
|
|
780
|
+
isOptionalObject: function isOptionalObject(e, t) {
|
|
781
|
+
return void 0 === t ? r : r.isObject(e, t);
|
|
782
|
+
},
|
|
783
|
+
isString: function isString(t, n) {
|
|
784
|
+
if ("string" != typeof n) throw new P(e, t + " must be a string.");
|
|
785
|
+
return r;
|
|
786
|
+
},
|
|
787
|
+
isOptionalString: function isOptionalString(e, t) {
|
|
788
|
+
return void 0 === t ? r : r.isString(e, t);
|
|
789
|
+
},
|
|
790
|
+
isStringArray: function isStringArray(n, i) {
|
|
791
|
+
if (!Array.isArray(i)) throw new P(e, n + " must be an array of strings.");
|
|
792
|
+
var o,
|
|
793
|
+
s = function (e, r) {
|
|
794
|
+
var _n = "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
|
|
795
|
+
if (!_n) {
|
|
796
|
+
if (Array.isArray(e) || (_n = t(e)) || r && e && "number" == typeof e.length) {
|
|
797
|
+
_n && (e = _n);
|
|
798
|
+
var i = 0,
|
|
799
|
+
o = function o() {};
|
|
800
|
+
return {
|
|
801
|
+
s: o,
|
|
802
|
+
n: function n() {
|
|
803
|
+
return i >= e.length ? {
|
|
804
|
+
done: !0
|
|
805
|
+
} : {
|
|
806
|
+
done: !1,
|
|
807
|
+
value: e[i++]
|
|
808
|
+
};
|
|
809
|
+
},
|
|
810
|
+
e: function e(_e2) {
|
|
811
|
+
throw _e2;
|
|
812
|
+
},
|
|
813
|
+
f: o
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
817
|
+
}
|
|
818
|
+
var s,
|
|
819
|
+
a = !0,
|
|
820
|
+
c = !1;
|
|
821
|
+
return {
|
|
822
|
+
s: function s() {
|
|
823
|
+
_n = _n.call(e);
|
|
824
|
+
},
|
|
825
|
+
n: function n() {
|
|
826
|
+
var e = _n.next();
|
|
827
|
+
return a = e.done, e;
|
|
828
|
+
},
|
|
829
|
+
e: function e(_e3) {
|
|
830
|
+
c = !0, s = _e3;
|
|
831
|
+
},
|
|
832
|
+
f: function f() {
|
|
833
|
+
try {
|
|
834
|
+
a || null == _n["return"] || _n["return"]();
|
|
835
|
+
} finally {
|
|
836
|
+
if (c) throw s;
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
};
|
|
840
|
+
}(i);
|
|
841
|
+
try {
|
|
842
|
+
for (s.s(); !(o = s.n()).done;) {
|
|
843
|
+
if ("string" != typeof o.value) throw new P(e, n + " must be an array of strings.");
|
|
844
|
+
}
|
|
845
|
+
} catch (e) {
|
|
846
|
+
s.e(e);
|
|
847
|
+
} finally {
|
|
848
|
+
s.f();
|
|
849
|
+
}
|
|
850
|
+
return r;
|
|
851
|
+
},
|
|
852
|
+
isOptionalStringArray: function isOptionalStringArray(e, t) {
|
|
853
|
+
return void 0 === t ? r : r.isStringArray(e, t);
|
|
854
|
+
},
|
|
855
|
+
isNumber: function isNumber(t, n) {
|
|
856
|
+
if ("number" != typeof n) throw new P(e, t + " must be a number.");
|
|
857
|
+
return r;
|
|
858
|
+
},
|
|
859
|
+
isOptionalNumber: function isOptionalNumber(e, t) {
|
|
860
|
+
return void 0 === t ? r : r.isNumber(e, t);
|
|
861
|
+
},
|
|
862
|
+
isBoolean: function isBoolean(t, n) {
|
|
863
|
+
if ("boolean" != typeof n) throw new P(e, t + " must be a boolean.");
|
|
864
|
+
return r;
|
|
865
|
+
},
|
|
866
|
+
isOptionalBoolean: function isOptionalBoolean(e, t) {
|
|
867
|
+
return void 0 === t ? r : r.isBoolean(e, t);
|
|
868
|
+
}
|
|
869
|
+
};
|
|
870
|
+
return r;
|
|
871
|
+
},
|
|
872
|
+
ee = s(function e(t, r, n) {
|
|
873
|
+
var o = this,
|
|
874
|
+
s = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : function () {
|
|
875
|
+
return Promise.resolve(void 0);
|
|
876
|
+
};
|
|
877
|
+
a(this, e), this.bootstrapPromise = n, this.isEnabled = function () {
|
|
878
|
+
return S(o, void 0, void 0, i().mark(function e() {
|
|
879
|
+
return i().wrap(function (e) {
|
|
880
|
+
for (;;) switch (e.prev = e.next) {
|
|
881
|
+
case 0:
|
|
882
|
+
return e.abrupt("return", this.state.then(function (e) {
|
|
883
|
+
return e.enabled;
|
|
884
|
+
}));
|
|
885
|
+
case 1:
|
|
886
|
+
case "end":
|
|
887
|
+
return e.stop();
|
|
888
|
+
}
|
|
889
|
+
}, e, this);
|
|
890
|
+
}));
|
|
891
|
+
}, this.getTelemetryID = function () {
|
|
892
|
+
return S(o, void 0, void 0, i().mark(function e() {
|
|
893
|
+
var t, r, n, o;
|
|
894
|
+
return i().wrap(function (e) {
|
|
895
|
+
for (;;) switch (e.prev = e.next) {
|
|
896
|
+
case 0:
|
|
897
|
+
return e.next = 2, this.state;
|
|
898
|
+
case 2:
|
|
899
|
+
if (t = e.sent, r = t.publicToken, n = t.enabled, o = t.dfpBackendURL, n) {
|
|
900
|
+
e.next = 8;
|
|
901
|
+
break;
|
|
902
|
+
}
|
|
903
|
+
return e.abrupt("return", void 0);
|
|
904
|
+
case 8:
|
|
905
|
+
return e.next = 10, window.GetTelemetryID(r, "".concat(o, "/submit"));
|
|
906
|
+
case 10:
|
|
907
|
+
return e.abrupt("return", e.sent);
|
|
908
|
+
case 11:
|
|
909
|
+
case "end":
|
|
910
|
+
return e.stop();
|
|
911
|
+
}
|
|
912
|
+
}, e, this);
|
|
913
|
+
}));
|
|
914
|
+
}, this.getDFPTelemetryIDAndCaptcha = function () {
|
|
915
|
+
return S(o, void 0, void 0, i().mark(function e() {
|
|
916
|
+
var t, r, n, o, s, a;
|
|
917
|
+
return i().wrap(function (e) {
|
|
918
|
+
for (;;) switch (e.prev = e.next) {
|
|
919
|
+
case 0:
|
|
920
|
+
return e.next = 2, this.state;
|
|
921
|
+
case 2:
|
|
922
|
+
if (t = e.sent, r = t.enabled, n = t.executeRecaptcha, o = t.mode, s = void 0, a = void 0, r) {
|
|
923
|
+
e.next = 12;
|
|
924
|
+
break;
|
|
925
|
+
}
|
|
926
|
+
return e.next = 11, n();
|
|
927
|
+
case 11:
|
|
928
|
+
a = e.sent;
|
|
929
|
+
case 12:
|
|
930
|
+
if ("DECISIONING" !== o) {
|
|
931
|
+
e.next = 18;
|
|
932
|
+
break;
|
|
933
|
+
}
|
|
934
|
+
return e.next = 15, this.getTelemetryID();
|
|
935
|
+
case 15:
|
|
936
|
+
s = e.sent, e.next = 25;
|
|
937
|
+
break;
|
|
938
|
+
case 18:
|
|
939
|
+
if ("OBSERVATION" !== o) {
|
|
940
|
+
e.next = 25;
|
|
941
|
+
break;
|
|
942
|
+
}
|
|
943
|
+
return e.next = 21, this.getTelemetryID();
|
|
944
|
+
case 21:
|
|
945
|
+
return s = e.sent, e.next = 24, n();
|
|
946
|
+
case 24:
|
|
947
|
+
a = e.sent;
|
|
948
|
+
case 25:
|
|
949
|
+
return e.abrupt("return", {
|
|
950
|
+
dfp_telemetry_id: s,
|
|
951
|
+
captcha_token: a
|
|
952
|
+
});
|
|
953
|
+
case 26:
|
|
954
|
+
case "end":
|
|
955
|
+
return e.stop();
|
|
956
|
+
}
|
|
957
|
+
}, e, this);
|
|
958
|
+
}));
|
|
959
|
+
}, this.retryWithCaptchaAndDFP = function (e, t) {
|
|
960
|
+
return S(o, void 0, void 0, i().mark(function r() {
|
|
961
|
+
var n, o, s;
|
|
962
|
+
return i().wrap(function (r) {
|
|
963
|
+
for (;;) switch (r.prev = r.next) {
|
|
964
|
+
case 0:
|
|
965
|
+
return r.next = 2, this.state;
|
|
966
|
+
case 2:
|
|
967
|
+
if (n = r.sent, o = n.enabled, s = n.executeRecaptcha, e.type !== E.RequiredCatcha || !o) {
|
|
968
|
+
r.next = 14;
|
|
969
|
+
break;
|
|
970
|
+
}
|
|
971
|
+
if (!t.body) {
|
|
972
|
+
r.next = 13;
|
|
973
|
+
break;
|
|
974
|
+
}
|
|
975
|
+
return r.next = 9, this.getTelemetryID();
|
|
976
|
+
case 9:
|
|
977
|
+
return t.body.dfp_telemetry_id = r.sent, r.next = 12, s();
|
|
978
|
+
case 12:
|
|
979
|
+
t.body.captcha_token = r.sent;
|
|
980
|
+
case 13:
|
|
981
|
+
return r.abrupt("return", t);
|
|
982
|
+
case 14:
|
|
983
|
+
throw new Error("Unable to query captcha and/or dfp telemetry ID");
|
|
984
|
+
case 15:
|
|
985
|
+
case "end":
|
|
986
|
+
return r.stop();
|
|
987
|
+
}
|
|
988
|
+
}, r, this);
|
|
989
|
+
}));
|
|
990
|
+
}, this.state = n.then(function (e) {
|
|
991
|
+
return S(o, void 0, void 0, i().mark(function n() {
|
|
992
|
+
return i().wrap(function (n) {
|
|
993
|
+
for (;;) switch (n.prev = n.next) {
|
|
994
|
+
case 0:
|
|
995
|
+
if (e.runDFPProtectedAuth) {
|
|
996
|
+
n.next = 2;
|
|
997
|
+
break;
|
|
998
|
+
}
|
|
999
|
+
return n.abrupt("return", {
|
|
1000
|
+
publicToken: t,
|
|
1001
|
+
dfpBackendURL: r,
|
|
1002
|
+
enabled: !1,
|
|
1003
|
+
loaded: !1,
|
|
1004
|
+
executeRecaptcha: s
|
|
1005
|
+
});
|
|
1006
|
+
case 2:
|
|
1007
|
+
return n.next = 4, void G("".concat("https://elements.stytch.com", "/telemetry.js"), function () {
|
|
1008
|
+
return window;
|
|
1009
|
+
});
|
|
1010
|
+
case 4:
|
|
1011
|
+
return n.abrupt("return", {
|
|
1012
|
+
publicToken: t,
|
|
1013
|
+
dfpBackendURL: r,
|
|
1014
|
+
enabled: !0,
|
|
1015
|
+
mode: e.dfpProtectedAuthMode || "OBSERVATION",
|
|
1016
|
+
loaded: !0,
|
|
1017
|
+
executeRecaptcha: s
|
|
1018
|
+
});
|
|
1019
|
+
case 5:
|
|
1020
|
+
case "end":
|
|
1021
|
+
return n.stop();
|
|
1022
|
+
}
|
|
1023
|
+
}, n);
|
|
1024
|
+
}));
|
|
1025
|
+
});
|
|
1026
|
+
}),
|
|
1027
|
+
te = function te() {
|
|
1028
|
+
return {
|
|
1029
|
+
isEnabled: function isEnabled() {
|
|
1030
|
+
return S(void 0, void 0, void 0, i().mark(function e() {
|
|
1031
|
+
return i().wrap(function (e) {
|
|
1032
|
+
for (;;) switch (e.prev = e.next) {
|
|
1033
|
+
case 0:
|
|
1034
|
+
return e.abrupt("return", !1);
|
|
1035
|
+
case 1:
|
|
1036
|
+
case "end":
|
|
1037
|
+
return e.stop();
|
|
1038
|
+
}
|
|
1039
|
+
}, e);
|
|
1040
|
+
}));
|
|
1041
|
+
},
|
|
1042
|
+
getTelemetryID: function getTelemetryID() {
|
|
1043
|
+
return S(void 0, void 0, void 0, i().mark(function e() {
|
|
1044
|
+
return i().wrap(function (e) {
|
|
1045
|
+
for (;;) switch (e.prev = e.next) {
|
|
1046
|
+
case 0:
|
|
1047
|
+
return e.abrupt("return", void 0);
|
|
1048
|
+
case 1:
|
|
1049
|
+
case "end":
|
|
1050
|
+
return e.stop();
|
|
1051
|
+
}
|
|
1052
|
+
}, e);
|
|
1053
|
+
}));
|
|
1054
|
+
},
|
|
1055
|
+
getDFPTelemetryIDAndCaptcha: function getDFPTelemetryIDAndCaptcha() {
|
|
1056
|
+
return S(void 0, void 0, void 0, i().mark(function e() {
|
|
1057
|
+
return i().wrap(function (e) {
|
|
1058
|
+
for (;;) switch (e.prev = e.next) {
|
|
1059
|
+
case 0:
|
|
1060
|
+
return e.abrupt("return", {
|
|
1061
|
+
dfp_telemetry_id: void 0,
|
|
1062
|
+
captcha_token: void 0
|
|
1063
|
+
});
|
|
1064
|
+
case 1:
|
|
1065
|
+
case "end":
|
|
1066
|
+
return e.stop();
|
|
1067
|
+
}
|
|
1068
|
+
}, e);
|
|
1069
|
+
}));
|
|
1070
|
+
},
|
|
1071
|
+
retryWithCaptchaAndDFP: function retryWithCaptchaAndDFP() {
|
|
1072
|
+
return S(void 0, void 0, void 0, i().mark(function e() {
|
|
1073
|
+
return i().wrap(function (e) {
|
|
1074
|
+
for (;;) switch (e.prev = e.next) {
|
|
1075
|
+
case 0:
|
|
1076
|
+
throw new Error("DFP protected auth is disabled");
|
|
1077
|
+
case 1:
|
|
1078
|
+
case "end":
|
|
1079
|
+
return e.stop();
|
|
1080
|
+
}
|
|
1081
|
+
}, e);
|
|
1082
|
+
}));
|
|
1083
|
+
}
|
|
1084
|
+
};
|
|
1085
|
+
},
|
|
1086
|
+
re = function () {
|
|
1087
|
+
function e(t) {
|
|
1088
|
+
a(this, e), this.maxBatchSize = t.maxBatchSize, this.logEventURL = t.logEventURL, setInterval(this.flush.bind(this), t.intervalDurationMs), this.batch = [];
|
|
1089
|
+
}
|
|
1090
|
+
return s(e, [{
|
|
1091
|
+
key: "logEvent",
|
|
1092
|
+
value: function value(e, t) {
|
|
1093
|
+
this.batch.push({
|
|
1094
|
+
telemetry: e,
|
|
1095
|
+
event: t
|
|
1096
|
+
}), this.batch.length >= this.maxBatchSize && this.flush();
|
|
1097
|
+
}
|
|
1098
|
+
}, {
|
|
1099
|
+
key: "flush",
|
|
1100
|
+
value: function value() {
|
|
1101
|
+
return S(this, void 0, void 0, i().mark(function e() {
|
|
1102
|
+
var t;
|
|
1103
|
+
return i().wrap(function (e) {
|
|
1104
|
+
for (;;) switch (e.prev = e.next) {
|
|
1105
|
+
case 0:
|
|
1106
|
+
if (this.batch.length) {
|
|
1107
|
+
e.next = 2;
|
|
1108
|
+
break;
|
|
1109
|
+
}
|
|
1110
|
+
return e.abrupt("return");
|
|
1111
|
+
case 2:
|
|
1112
|
+
return t = this.batch, this.batch = [], e.prev = 4, e.next = 7, fetch(this.logEventURL, {
|
|
1113
|
+
method: "POST",
|
|
1114
|
+
headers: {
|
|
1115
|
+
"Content-Type": "application/json"
|
|
1116
|
+
},
|
|
1117
|
+
body: JSON.stringify(t)
|
|
1118
|
+
});
|
|
1119
|
+
case 7:
|
|
1120
|
+
e.next = 11;
|
|
1121
|
+
break;
|
|
1122
|
+
case 9:
|
|
1123
|
+
e.prev = 9, e.t0 = e["catch"](4);
|
|
1124
|
+
case 11:
|
|
1125
|
+
case "end":
|
|
1126
|
+
return e.stop();
|
|
1127
|
+
}
|
|
1128
|
+
}, e, this, [[4, 9]]);
|
|
1129
|
+
}));
|
|
1130
|
+
}
|
|
1131
|
+
}]), e;
|
|
1132
|
+
}();
|
|
1133
|
+
!function (e) {
|
|
1134
|
+
e.LoginOrCreateEML = "login_or_create_eml", e.LoginOrCreateOTP = "login_or_create_otp", e.ResetPassword = "reset_password";
|
|
1135
|
+
}(Y || (Y = {})), Promise.resolve({
|
|
1136
|
+
pkceRequiredForEmailMagicLinks: !1
|
|
1137
|
+
}), Promise.resolve({
|
|
1138
|
+
pkceRequiredForPasswordResets: !1
|
|
1139
|
+
});
|
|
1140
|
+
var ne = Promise.resolve({
|
|
1141
|
+
pkceRequiredForEmailMagicLinks: !1
|
|
1142
|
+
}),
|
|
1143
|
+
ie = function () {
|
|
1144
|
+
function e(t, r, n, o) {
|
|
1145
|
+
var s = this,
|
|
1146
|
+
c = arguments.length > 4 && void 0 !== arguments[4] ? arguments[4] : ne,
|
|
1147
|
+
u = arguments.length > 5 && void 0 !== arguments[5] ? arguments[5] : te();
|
|
1148
|
+
a(this, e), this._networkClient = t, this._subscriptionService = r, this._pkceManager = n, this._passwordResetPKCEManager = o, this._config = c, this.dfpProtectedAuth = u, this.email = {
|
|
1149
|
+
loginOrSignup: function loginOrSignup(e) {
|
|
1150
|
+
return S(s, void 0, void 0, i().mark(function t() {
|
|
1151
|
+
var r, n;
|
|
1152
|
+
return i().wrap(function (t) {
|
|
1153
|
+
for (;;) switch (t.prev = t.next) {
|
|
1154
|
+
case 0:
|
|
1155
|
+
return Q("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).isOptionalString("locale", e.locale), t.next = 3, this.getCodeChallenge();
|
|
1156
|
+
case 3:
|
|
1157
|
+
return r = t.sent, n = Object.assign(Object.assign({}, e), {
|
|
1158
|
+
pkce_code_challenge: r
|
|
1159
|
+
}), t.abrupt("return", this._networkClient.fetchSDK({
|
|
1160
|
+
url: "/b2b/magic_links/email/login_or_signup",
|
|
1161
|
+
body: n,
|
|
1162
|
+
errorMessage: "Failed to send magic link",
|
|
1163
|
+
method: "POST"
|
|
1164
|
+
}));
|
|
1165
|
+
case 6:
|
|
1166
|
+
case "end":
|
|
1167
|
+
return t.stop();
|
|
1168
|
+
}
|
|
1169
|
+
}, t, this);
|
|
1170
|
+
}));
|
|
1171
|
+
},
|
|
1172
|
+
discovery: {
|
|
1173
|
+
send: function send(e) {
|
|
1174
|
+
return S(s, void 0, void 0, i().mark(function t() {
|
|
1175
|
+
var r, n;
|
|
1176
|
+
return i().wrap(function (t) {
|
|
1177
|
+
for (;;) switch (t.prev = t.next) {
|
|
1178
|
+
case 0:
|
|
1179
|
+
return Q("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).isOptionalString("locale", e.locale), t.next = 3, this.getCodeChallenge();
|
|
1180
|
+
case 3:
|
|
1181
|
+
return r = t.sent, n = Object.assign(Object.assign({}, e), {
|
|
1182
|
+
pkce_code_challenge: r
|
|
1183
|
+
}), t.abrupt("return", this._networkClient.fetchSDK({
|
|
1184
|
+
url: "/b2b/magic_links/email/discovery/send",
|
|
1185
|
+
body: n,
|
|
1186
|
+
errorMessage: "Failed to send discovery magic link",
|
|
1187
|
+
method: "POST"
|
|
1188
|
+
}));
|
|
1189
|
+
case 6:
|
|
1190
|
+
case "end":
|
|
1191
|
+
return t.stop();
|
|
1192
|
+
}
|
|
1193
|
+
}, t, this);
|
|
1194
|
+
}));
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
}, this.authenticate = function (e) {
|
|
1198
|
+
return S(s, void 0, void 0, i().mark(function t() {
|
|
1199
|
+
var r, n;
|
|
1200
|
+
return i().wrap(function (t) {
|
|
1201
|
+
for (;;) switch (t.prev = t.next) {
|
|
1202
|
+
case 0:
|
|
1203
|
+
return Q("stytch.magicLinks.authenticate").isString("magic_links_token", e.magic_links_token).isNumber("session_duration_minutes", e.session_duration_minutes).isOptionalString("locale", e.locale), t.next = 3, this._passwordResetPKCEManager.getPKPair();
|
|
1204
|
+
case 3:
|
|
1205
|
+
if (r = t.sent, n = null, !(null == r ? void 0 : r.code_verifier)) {
|
|
1206
|
+
t.next = 19;
|
|
1207
|
+
break;
|
|
1208
|
+
}
|
|
1209
|
+
return t.prev = 6, t.next = 9, this.handlePKCEForAuthenticate(this._passwordResetPKCEManager, e);
|
|
1210
|
+
case 9:
|
|
1211
|
+
n = t.sent, t.next = 19;
|
|
1212
|
+
break;
|
|
1213
|
+
case 12:
|
|
1214
|
+
if (t.prev = 12, t.t0 = t["catch"](6), !t.t0.message.includes("pkce")) {
|
|
1215
|
+
t.next = 18;
|
|
1216
|
+
break;
|
|
1217
|
+
}
|
|
1218
|
+
console.log("Authenticate with passwords pkce namespace failed. Falling back to authenticate with magic_links namespace."), t.next = 19;
|
|
1219
|
+
break;
|
|
1220
|
+
case 18:
|
|
1221
|
+
throw t.t0;
|
|
1222
|
+
case 19:
|
|
1223
|
+
if (n) {
|
|
1224
|
+
t.next = 23;
|
|
1225
|
+
break;
|
|
1226
|
+
}
|
|
1227
|
+
return t.next = 22, this.handlePKCEForAuthenticate(this._pkceManager, e);
|
|
1228
|
+
case 22:
|
|
1229
|
+
n = t.sent;
|
|
1230
|
+
case 23:
|
|
1231
|
+
return n.member_session ? this._subscriptionService.updateStateAndTokens({
|
|
1232
|
+
state: {
|
|
1233
|
+
session: n.member_session,
|
|
1234
|
+
member: n.member
|
|
1235
|
+
},
|
|
1236
|
+
session_token: n.session_token,
|
|
1237
|
+
session_jwt: n.session_jwt,
|
|
1238
|
+
intermediate_session_token: null
|
|
1239
|
+
}) : this._subscriptionService.updateStateAndTokens({
|
|
1240
|
+
state: null,
|
|
1241
|
+
session_token: null,
|
|
1242
|
+
session_jwt: null,
|
|
1243
|
+
intermediate_session_token: n.intermediate_session_token
|
|
1244
|
+
}), t.abrupt("return", n);
|
|
1245
|
+
case 25:
|
|
1246
|
+
case "end":
|
|
1247
|
+
return t.stop();
|
|
1248
|
+
}
|
|
1249
|
+
}, t, this, [[6, 12]]);
|
|
1250
|
+
}));
|
|
1251
|
+
}, this.discovery = {
|
|
1252
|
+
authenticate: function authenticate(e) {
|
|
1253
|
+
return S(s, void 0, void 0, i().mark(function t() {
|
|
1254
|
+
var r, n, o, s, a, c;
|
|
1255
|
+
return i().wrap(function (t) {
|
|
1256
|
+
for (;;) switch (t.prev = t.next) {
|
|
1257
|
+
case 0:
|
|
1258
|
+
return Q("stytch.magicLinks.discovery.authenticate").isString("discovery_magic_links_token", e.discovery_magic_links_token), t.next = 3, this._pkceManager.getPKPair();
|
|
1259
|
+
case 3:
|
|
1260
|
+
return r = t.sent, t.next = 6, this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
|
|
1261
|
+
case 6:
|
|
1262
|
+
return n = t.sent, o = n.dfp_telemetry_id, s = n.captcha_token, a = Object.assign({
|
|
1263
|
+
pkce_code_verifier: null == r ? void 0 : r.code_verifier,
|
|
1264
|
+
dfp_telemetry_id: o,
|
|
1265
|
+
captcha_token: s
|
|
1266
|
+
}, e), t.next = 12, this._networkClient.retriableFetchSDK({
|
|
1267
|
+
url: "/b2b/magic_links/discovery/authenticate",
|
|
1268
|
+
body: a,
|
|
1269
|
+
errorMessage: "Failed to authenticate intermediate magic link token",
|
|
1270
|
+
method: "POST",
|
|
1271
|
+
retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
|
|
1272
|
+
});
|
|
1273
|
+
case 12:
|
|
1274
|
+
return c = t.sent, this._pkceManager.clearPKPair(), this._subscriptionService.updateStateAndTokens({
|
|
1275
|
+
state: null,
|
|
1276
|
+
session_token: null,
|
|
1277
|
+
session_jwt: null,
|
|
1278
|
+
intermediate_session_token: c.intermediate_session_token
|
|
1279
|
+
}), t.abrupt("return", c);
|
|
1280
|
+
case 16:
|
|
1281
|
+
case "end":
|
|
1282
|
+
return t.stop();
|
|
1283
|
+
}
|
|
1284
|
+
}, t, this);
|
|
1285
|
+
}));
|
|
1286
|
+
}
|
|
1287
|
+
};
|
|
1288
|
+
}
|
|
1289
|
+
return s(e, [{
|
|
1290
|
+
key: "getCodeChallenge",
|
|
1291
|
+
value: function value() {
|
|
1292
|
+
return S(this, void 0, void 0, i().mark(function e() {
|
|
1293
|
+
var t, r;
|
|
1294
|
+
return i().wrap(function (e) {
|
|
1295
|
+
for (;;) switch (e.prev = e.next) {
|
|
1296
|
+
case 0:
|
|
1297
|
+
return e.next = 2, this._config;
|
|
1298
|
+
case 2:
|
|
1299
|
+
if (t = e.sent, t.pkceRequiredForEmailMagicLinks) {
|
|
1300
|
+
e.next = 6;
|
|
1301
|
+
break;
|
|
1302
|
+
}
|
|
1303
|
+
return e.abrupt("return", void 0);
|
|
1304
|
+
case 6:
|
|
1305
|
+
return e.next = 8, this._pkceManager.getPKPair();
|
|
1306
|
+
case 8:
|
|
1307
|
+
if (!(r = e.sent)) {
|
|
1308
|
+
e.next = 11;
|
|
1309
|
+
break;
|
|
1310
|
+
}
|
|
1311
|
+
return e.abrupt("return", r.code_challenge);
|
|
1312
|
+
case 11:
|
|
1313
|
+
return e.next = 13, this._pkceManager.startPKCETransaction();
|
|
1314
|
+
case 13:
|
|
1315
|
+
return r = e.sent, e.abrupt("return", r.code_challenge);
|
|
1316
|
+
case 15:
|
|
1317
|
+
case "end":
|
|
1318
|
+
return e.stop();
|
|
1319
|
+
}
|
|
1320
|
+
}, e, this);
|
|
1321
|
+
}));
|
|
1322
|
+
}
|
|
1323
|
+
}, {
|
|
1324
|
+
key: "handlePKCEForAuthenticate",
|
|
1325
|
+
value: function value(e, t) {
|
|
1326
|
+
return S(this, void 0, void 0, i().mark(function r() {
|
|
1327
|
+
var n, o, s, a, c, u;
|
|
1328
|
+
return i().wrap(function (r) {
|
|
1329
|
+
for (;;) switch (r.prev = r.next) {
|
|
1330
|
+
case 0:
|
|
1331
|
+
return r.next = 2, e.getPKPair();
|
|
1332
|
+
case 2:
|
|
1333
|
+
return n = r.sent, r.next = 5, this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
|
|
1334
|
+
case 5:
|
|
1335
|
+
return o = r.sent, s = o.dfp_telemetry_id, a = o.captcha_token, c = Object.assign({
|
|
1336
|
+
pkce_code_verifier: null == n ? void 0 : n.code_verifier,
|
|
1337
|
+
dfp_telemetry_id: s,
|
|
1338
|
+
captcha_token: a
|
|
1339
|
+
}, t), r.next = 11, this._networkClient.retriableFetchSDK({
|
|
1340
|
+
url: "/b2b/magic_links/authenticate",
|
|
1341
|
+
body: c,
|
|
1342
|
+
errorMessage: "Failed to authenticate token",
|
|
1343
|
+
method: "POST",
|
|
1344
|
+
retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
|
|
1345
|
+
});
|
|
1346
|
+
case 11:
|
|
1347
|
+
return u = r.sent, e.clearPKPair(), r.abrupt("return", u);
|
|
1348
|
+
case 14:
|
|
1349
|
+
case "end":
|
|
1350
|
+
return r.stop();
|
|
1351
|
+
}
|
|
1352
|
+
}, r, this);
|
|
1353
|
+
}));
|
|
1354
|
+
}
|
|
1355
|
+
}]), e;
|
|
1356
|
+
}(),
|
|
1357
|
+
oe = s(function e(t, r) {
|
|
1358
|
+
var n = this;
|
|
1359
|
+
a(this, e), this._networkClient = t, this._subscriptionService = r, this.get = function () {
|
|
1360
|
+
return S(n, void 0, void 0, i().mark(function e() {
|
|
1361
|
+
var t;
|
|
1362
|
+
return i().wrap(function (e) {
|
|
1363
|
+
for (;;) switch (e.prev = e.next) {
|
|
1364
|
+
case 0:
|
|
1365
|
+
return e.next = 2, this._networkClient.fetchSDK({
|
|
1366
|
+
url: "/b2b/organizations/members/me",
|
|
1367
|
+
errorMessage: "Failed to retrieve member info.",
|
|
1368
|
+
method: "GET"
|
|
1369
|
+
});
|
|
1370
|
+
case 2:
|
|
1371
|
+
return t = e.sent, this._subscriptionService.updateMember(t.member), e.abrupt("return", t.member);
|
|
1372
|
+
case 5:
|
|
1373
|
+
case "end":
|
|
1374
|
+
return e.stop();
|
|
1375
|
+
}
|
|
1376
|
+
}, e, this);
|
|
1377
|
+
}));
|
|
1378
|
+
}, this.getSync = function () {
|
|
1379
|
+
return n._subscriptionService.getMember();
|
|
1380
|
+
}, this.onChange = function (e) {
|
|
1381
|
+
return n._subscriptionService.subscribeToState(function (t) {
|
|
1382
|
+
var r;
|
|
1383
|
+
return e(null !== (r = null == t ? void 0 : t.member) && void 0 !== r ? r : null);
|
|
1384
|
+
});
|
|
1385
|
+
}, this.update = function (e) {
|
|
1386
|
+
return S(n, void 0, void 0, i().mark(function t() {
|
|
1387
|
+
var r;
|
|
1388
|
+
return i().wrap(function (t) {
|
|
1389
|
+
for (;;) switch (t.prev = t.next) {
|
|
1390
|
+
case 0:
|
|
1391
|
+
return Q("stytch.member.update").isOptionalString("name", e.name).isOptionalObject("untrusted_metadata", e.untrusted_metadata).isOptionalBoolean("mfa_enrolled", e.mfa_enrolled).isOptionalString("mfa_phone_number", e.mfa_phone_number), t.next = 3, this._networkClient.fetchSDK({
|
|
1392
|
+
url: "/b2b/organizations/members/update",
|
|
1393
|
+
body: e,
|
|
1394
|
+
errorMessage: "Failed to update member.",
|
|
1395
|
+
method: "PUT"
|
|
1396
|
+
});
|
|
1397
|
+
case 3:
|
|
1398
|
+
return r = t.sent, this._subscriptionService.updateMember(r.member), t.abrupt("return", r);
|
|
1399
|
+
case 6:
|
|
1400
|
+
case "end":
|
|
1401
|
+
return t.stop();
|
|
1402
|
+
}
|
|
1403
|
+
}, t, this);
|
|
1404
|
+
}));
|
|
1405
|
+
}, this.deleteMFAPhoneNumber = function () {
|
|
1406
|
+
return S(n, void 0, void 0, i().mark(function e() {
|
|
1407
|
+
var t;
|
|
1408
|
+
return i().wrap(function (e) {
|
|
1409
|
+
for (;;) switch (e.prev = e.next) {
|
|
1410
|
+
case 0:
|
|
1411
|
+
return e.next = 2, this._networkClient.fetchSDK({
|
|
1412
|
+
url: "/b2b/organizations/members/deletePhoneNumber",
|
|
1413
|
+
errorMessage: "Failed to delete member phone number.",
|
|
1414
|
+
method: "DELETE"
|
|
1415
|
+
});
|
|
1416
|
+
case 2:
|
|
1417
|
+
return t = e.sent, this._subscriptionService.updateMember(t.member), e.abrupt("return", t);
|
|
1418
|
+
case 5:
|
|
1419
|
+
case "end":
|
|
1420
|
+
return e.stop();
|
|
1421
|
+
}
|
|
1422
|
+
}, e, this);
|
|
1423
|
+
}));
|
|
1424
|
+
};
|
|
1425
|
+
}),
|
|
1426
|
+
se = function () {
|
|
1427
|
+
function e(t, r, n, i, o) {
|
|
1428
|
+
var s = arguments.length > 5 && void 0 !== arguments[5] ? arguments[5] : te();
|
|
1429
|
+
a(this, e), this._networkClient = t, this._subscriptionService = r, this._pkceManager = n, this._dynamicConfig = i, this._config = o, this.dfpProtectedAuth = s;
|
|
1430
|
+
}
|
|
1431
|
+
return s(e, [{
|
|
1432
|
+
key: "authenticate",
|
|
1433
|
+
value: function value(e) {
|
|
1434
|
+
return S(this, void 0, void 0, i().mark(function t() {
|
|
1435
|
+
var r, n, o, s, a;
|
|
1436
|
+
return i().wrap(function (t) {
|
|
1437
|
+
for (;;) switch (t.prev = t.next) {
|
|
1438
|
+
case 0:
|
|
1439
|
+
return Q("stytch.sso.authenticate").isString("sso_token", e.sso_token).isNumber("session_duration_minutes", e.session_duration_minutes).isOptionalString("locale", e.locale), t.next = 3, this._pkceManager.getPKPair();
|
|
1440
|
+
case 3:
|
|
1441
|
+
return (r = t.sent) || $("No code verifier found in local storage for SSO flow.\nConsider using stytch.sso.start() to add PKCE to your SSO flows for added security.\nSee https://stytch.com/docs/oauth#guides_pkce for more information."), t.next = 7, this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
|
|
1442
|
+
case 7:
|
|
1443
|
+
return n = t.sent, o = n.dfp_telemetry_id, s = n.captcha_token, t.next = 12, this._networkClient.retriableFetchSDK({
|
|
1444
|
+
url: "/b2b/sso/authenticate",
|
|
1445
|
+
method: "POST",
|
|
1446
|
+
body: Object.assign(Object.assign({
|
|
1447
|
+
pkce_code_verifier: null == r ? void 0 : r.code_verifier
|
|
1448
|
+
}, e), {
|
|
1449
|
+
dfp_telemetry_id: o,
|
|
1450
|
+
captcha_token: s
|
|
1451
|
+
}),
|
|
1452
|
+
errorMessage: "Failed to authenticate token",
|
|
1453
|
+
retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
|
|
1454
|
+
});
|
|
1455
|
+
case 12:
|
|
1456
|
+
return a = t.sent, this._pkceManager.clearPKPair(), a.member_session ? this._subscriptionService.updateStateAndTokens({
|
|
1457
|
+
state: {
|
|
1458
|
+
session: a.member_session,
|
|
1459
|
+
member: a.member
|
|
1460
|
+
},
|
|
1461
|
+
session_token: a.session_token,
|
|
1462
|
+
session_jwt: a.session_jwt,
|
|
1463
|
+
intermediate_session_token: null
|
|
1464
|
+
}) : this._subscriptionService.updateStateAndTokens({
|
|
1465
|
+
state: null,
|
|
1466
|
+
session_token: null,
|
|
1467
|
+
session_jwt: null,
|
|
1468
|
+
intermediate_session_token: a.intermediate_session_token
|
|
1469
|
+
}), t.abrupt("return", a);
|
|
1470
|
+
case 16:
|
|
1471
|
+
case "end":
|
|
1472
|
+
return t.stop();
|
|
1473
|
+
}
|
|
1474
|
+
}, t, this);
|
|
1475
|
+
}));
|
|
1476
|
+
}
|
|
1477
|
+
}, {
|
|
1478
|
+
key: "getBaseApiUrl",
|
|
1479
|
+
value: function value() {
|
|
1480
|
+
return S(this, void 0, void 0, i().mark(function e() {
|
|
1481
|
+
return i().wrap(function (e) {
|
|
1482
|
+
for (;;) switch (e.prev = e.next) {
|
|
1483
|
+
case 0:
|
|
1484
|
+
if (!Z(this._config.publicToken)) {
|
|
1485
|
+
e.next = 2;
|
|
1486
|
+
break;
|
|
1487
|
+
}
|
|
1488
|
+
return e.abrupt("return", this._config.testAPIURL);
|
|
1489
|
+
case 2:
|
|
1490
|
+
return e.abrupt("return", this._config.liveAPIURL);
|
|
1491
|
+
case 3:
|
|
1492
|
+
case "end":
|
|
1493
|
+
return e.stop();
|
|
1494
|
+
}
|
|
1495
|
+
}, e, this);
|
|
1496
|
+
}));
|
|
1497
|
+
}
|
|
1498
|
+
}, {
|
|
1499
|
+
key: "start",
|
|
1500
|
+
value: function value(e) {
|
|
1501
|
+
var t = e.connection_id,
|
|
1502
|
+
r = e.login_redirect_url,
|
|
1503
|
+
n = e.signup_redirect_url;
|
|
1504
|
+
return S(this, void 0, void 0, i().mark(function e() {
|
|
1505
|
+
var o, s, a, c, u;
|
|
1506
|
+
return i().wrap(function (e) {
|
|
1507
|
+
for (;;) switch (e.prev = e.next) {
|
|
1508
|
+
case 0:
|
|
1509
|
+
return e.next = 2, this._dynamicConfig;
|
|
1510
|
+
case 2:
|
|
1511
|
+
return o = e.sent, s = o.pkceRequiredForSso, e.next = 6, this.getBaseApiUrl();
|
|
1512
|
+
case 6:
|
|
1513
|
+
if (a = e.sent, (c = new URL("".concat(a, "/v1/public/sso/start"))).searchParams.set("public_token", this._config.publicToken), c.searchParams.set("connection_id", t), !s) {
|
|
1514
|
+
e.next = 17;
|
|
1515
|
+
break;
|
|
1516
|
+
}
|
|
1517
|
+
return e.next = 13, this._pkceManager.startPKCETransaction();
|
|
1518
|
+
case 13:
|
|
1519
|
+
u = e.sent, c.searchParams.set("pkce_code_challenge", u.code_challenge), e.next = 18;
|
|
1520
|
+
break;
|
|
1521
|
+
case 17:
|
|
1522
|
+
this._pkceManager.clearPKPair();
|
|
1523
|
+
case 18:
|
|
1524
|
+
r && c.searchParams.set("login_redirect_url", r), n && c.searchParams.set("signup_redirect_url", n), window.location.href = c.toString();
|
|
1525
|
+
case 21:
|
|
1526
|
+
case "end":
|
|
1527
|
+
return e.stop();
|
|
1528
|
+
}
|
|
1529
|
+
}, e, this);
|
|
1530
|
+
}));
|
|
1531
|
+
}
|
|
1532
|
+
}]), e;
|
|
1533
|
+
}(),
|
|
1534
|
+
ae = s(function e(t) {
|
|
1535
|
+
var r = this;
|
|
1536
|
+
a(this, e), this._networkClient = t, this.get = function () {
|
|
1537
|
+
return S(r, void 0, void 0, i().mark(function e() {
|
|
1538
|
+
var t;
|
|
1539
|
+
return i().wrap(function (e) {
|
|
1540
|
+
for (;;) switch (e.prev = e.next) {
|
|
1541
|
+
case 0:
|
|
1542
|
+
return e.next = 2, this._networkClient.fetchSDK({
|
|
1543
|
+
url: "/b2b/organizations/me",
|
|
1544
|
+
errorMessage: "Failed to retrieve organization info.",
|
|
1545
|
+
method: "GET"
|
|
1546
|
+
});
|
|
1547
|
+
case 2:
|
|
1548
|
+
return t = e.sent, e.abrupt("return", t.organization);
|
|
1549
|
+
case 4:
|
|
1550
|
+
case "end":
|
|
1551
|
+
return e.stop();
|
|
1552
|
+
}
|
|
1553
|
+
}, e, this);
|
|
1554
|
+
}));
|
|
1555
|
+
};
|
|
1556
|
+
}),
|
|
1557
|
+
ce = function () {
|
|
1558
|
+
function e(t, r, n, o, s) {
|
|
1559
|
+
var c = this,
|
|
1560
|
+
u = arguments.length > 5 && void 0 !== arguments[5] ? arguments[5] : te();
|
|
1561
|
+
a(this, e), this._networkClient = t, this._subscriptionService = r, this._pkceManager = n, this._dynamicConfig = o, this._config = s, this.dfpProtectedAuth = u, this.discovery = {
|
|
1562
|
+
authenticate: function authenticate(e) {
|
|
1563
|
+
return S(c, void 0, void 0, i().mark(function t() {
|
|
1564
|
+
var r, n, o, s, a, c;
|
|
1565
|
+
return i().wrap(function (t) {
|
|
1566
|
+
for (;;) switch (t.prev = t.next) {
|
|
1567
|
+
case 0:
|
|
1568
|
+
return Q("stytch.oauth.discovery.authenticate").isString("discovery_oauth_token", e.discovery_oauth_token), t.next = 3, this._pkceManager.getPKPair();
|
|
1569
|
+
case 3:
|
|
1570
|
+
return r = t.sent, t.next = 6, this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
|
|
1571
|
+
case 6:
|
|
1572
|
+
return n = t.sent, o = n.dfp_telemetry_id, s = n.captcha_token, a = Object.assign({
|
|
1573
|
+
pkce_code_verifier: null == r ? void 0 : r.code_verifier,
|
|
1574
|
+
dfp_telemetry_id: o,
|
|
1575
|
+
captcha_token: s
|
|
1576
|
+
}, e), t.next = 12, this._networkClient.retriableFetchSDK({
|
|
1577
|
+
url: "/b2b/oauth/discovery/authenticate",
|
|
1578
|
+
body: a,
|
|
1579
|
+
errorMessage: "Failed to authenticate discovery oauth token",
|
|
1580
|
+
method: "POST",
|
|
1581
|
+
retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
|
|
1582
|
+
});
|
|
1583
|
+
case 12:
|
|
1584
|
+
return c = t.sent, this._pkceManager.clearPKPair(), this._subscriptionService.updateStateAndTokens({
|
|
1585
|
+
state: null,
|
|
1586
|
+
session_token: null,
|
|
1587
|
+
session_jwt: null,
|
|
1588
|
+
intermediate_session_token: c.intermediate_session_token
|
|
1589
|
+
}), t.abrupt("return", c);
|
|
1590
|
+
case 16:
|
|
1591
|
+
case "end":
|
|
1592
|
+
return t.stop();
|
|
1593
|
+
}
|
|
1594
|
+
}, t, this);
|
|
1595
|
+
}));
|
|
1596
|
+
}
|
|
1597
|
+
}, this.google = {
|
|
1598
|
+
start: this.startOAuthFlow(O.Google),
|
|
1599
|
+
discovery: {
|
|
1600
|
+
start: this.startDiscoveryOAuthFlow(O.Google)
|
|
1601
|
+
}
|
|
1602
|
+
}, this.microsoft = {
|
|
1603
|
+
start: this.startOAuthFlow(O.Microsoft),
|
|
1604
|
+
discovery: {
|
|
1605
|
+
start: this.startDiscoveryOAuthFlow(O.Microsoft)
|
|
1606
|
+
}
|
|
1607
|
+
};
|
|
1608
|
+
}
|
|
1609
|
+
return s(e, [{
|
|
1610
|
+
key: "authenticate",
|
|
1611
|
+
value: function value(e) {
|
|
1612
|
+
return S(this, void 0, void 0, i().mark(function t() {
|
|
1613
|
+
var r, n, o, s, a;
|
|
1614
|
+
return i().wrap(function (t) {
|
|
1615
|
+
for (;;) switch (t.prev = t.next) {
|
|
1616
|
+
case 0:
|
|
1617
|
+
return Q("stytch.oauth.authenticate").isString("oauth_token", e.oauth_token).isNumber("session_duration_minutes", e.session_duration_minutes).isOptionalString("locale", e.locale), t.next = 3, this._pkceManager.getPKPair();
|
|
1618
|
+
case 3:
|
|
1619
|
+
return (r = t.sent) || $("No code verifier found in local storage for OAuth flow.\nConsider using stytch.oauth.$provider.start() to add PKCE to your OAuth flows for added security.\nSee https://stytch.com/docs/oauth#guides_pkce for more information."), t.next = 7, this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
|
|
1620
|
+
case 7:
|
|
1621
|
+
return n = t.sent, o = n.dfp_telemetry_id, s = n.captcha_token, t.next = 12, this._networkClient.retriableFetchSDK({
|
|
1622
|
+
url: "/b2b/oauth/authenticate",
|
|
1623
|
+
method: "POST",
|
|
1624
|
+
body: Object.assign({
|
|
1625
|
+
pkce_code_verifier: null == r ? void 0 : r.code_verifier,
|
|
1626
|
+
dfp_telemetry_id: o,
|
|
1627
|
+
captcha_token: s
|
|
1628
|
+
}, e),
|
|
1629
|
+
errorMessage: "Failed to authenticate token",
|
|
1630
|
+
retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
|
|
1631
|
+
});
|
|
1632
|
+
case 12:
|
|
1633
|
+
return a = t.sent, this._pkceManager.clearPKPair(), a.member_session ? this._subscriptionService.updateStateAndTokens({
|
|
1634
|
+
state: {
|
|
1635
|
+
session: a.member_session,
|
|
1636
|
+
member: a.member
|
|
1637
|
+
},
|
|
1638
|
+
session_token: a.session_token,
|
|
1639
|
+
session_jwt: a.session_jwt,
|
|
1640
|
+
intermediate_session_token: null
|
|
1641
|
+
}) : this._subscriptionService.updateStateAndTokens({
|
|
1642
|
+
state: null,
|
|
1643
|
+
session_token: null,
|
|
1644
|
+
session_jwt: null,
|
|
1645
|
+
intermediate_session_token: a.intermediate_session_token
|
|
1646
|
+
}), t.abrupt("return", a);
|
|
1647
|
+
case 16:
|
|
1648
|
+
case "end":
|
|
1649
|
+
return t.stop();
|
|
1650
|
+
}
|
|
1651
|
+
}, t, this);
|
|
1652
|
+
}));
|
|
1653
|
+
}
|
|
1654
|
+
}, {
|
|
1655
|
+
key: "getBaseApiUrl",
|
|
1656
|
+
value: function value() {
|
|
1657
|
+
return S(this, void 0, void 0, i().mark(function e() {
|
|
1658
|
+
var t, r;
|
|
1659
|
+
return i().wrap(function (e) {
|
|
1660
|
+
for (;;) switch (e.prev = e.next) {
|
|
1661
|
+
case 0:
|
|
1662
|
+
return e.next = 2, this._dynamicConfig;
|
|
1663
|
+
case 2:
|
|
1664
|
+
if (t = e.sent, !(r = t.cnameDomain)) {
|
|
1665
|
+
e.next = 6;
|
|
1666
|
+
break;
|
|
1667
|
+
}
|
|
1668
|
+
return e.abrupt("return", "https://".concat(r));
|
|
1669
|
+
case 6:
|
|
1670
|
+
if (!Z(this._config.publicToken)) {
|
|
1671
|
+
e.next = 8;
|
|
1672
|
+
break;
|
|
1673
|
+
}
|
|
1674
|
+
return e.abrupt("return", this._config.testAPIURL);
|
|
1675
|
+
case 8:
|
|
1676
|
+
return e.abrupt("return", this._config.liveAPIURL);
|
|
1677
|
+
case 9:
|
|
1678
|
+
case "end":
|
|
1679
|
+
return e.stop();
|
|
1680
|
+
}
|
|
1681
|
+
}, e, this);
|
|
1682
|
+
}));
|
|
1683
|
+
}
|
|
1684
|
+
}, {
|
|
1685
|
+
key: "startOAuthFlow",
|
|
1686
|
+
value: function value(e) {
|
|
1687
|
+
var t = this;
|
|
1688
|
+
return function (r) {
|
|
1689
|
+
var n = r.organization_id,
|
|
1690
|
+
o = r.organization_slug,
|
|
1691
|
+
s = r.login_redirect_url,
|
|
1692
|
+
a = r.signup_redirect_url,
|
|
1693
|
+
c = r.custom_scopes;
|
|
1694
|
+
return S(t, void 0, void 0, i().mark(function t() {
|
|
1695
|
+
var r, u, l, d, h;
|
|
1696
|
+
return i().wrap(function (t) {
|
|
1697
|
+
for (;;) switch (t.prev = t.next) {
|
|
1698
|
+
case 0:
|
|
1699
|
+
return t.next = 2, this._dynamicConfig;
|
|
1700
|
+
case 2:
|
|
1701
|
+
return r = t.sent, u = r.pkceRequiredForOAuth, t.next = 6, this.getBaseApiUrl();
|
|
1702
|
+
case 6:
|
|
1703
|
+
if (l = t.sent, (d = new URL("".concat(l, "/v1/b2b/public/oauth/").concat(e, "/start"))).searchParams.set("public_token", this._config.publicToken), n && "" != n && d.searchParams.set("organization_id", n), o && "" != o && d.searchParams.set("slug", o), c && (Q("startOAuthFlow").isStringArray("custom_scopes", c), d.searchParams.set("custom_scopes", c.join(" "))), !u) {
|
|
1704
|
+
t.next = 19;
|
|
1705
|
+
break;
|
|
1706
|
+
}
|
|
1707
|
+
return t.next = 15, this._pkceManager.startPKCETransaction();
|
|
1708
|
+
case 15:
|
|
1709
|
+
h = t.sent, d.searchParams.set("pkce_code_challenge", h.code_challenge), t.next = 20;
|
|
1710
|
+
break;
|
|
1711
|
+
case 19:
|
|
1712
|
+
this._pkceManager.clearPKPair();
|
|
1713
|
+
case 20:
|
|
1714
|
+
s && d.searchParams.set("login_redirect_url", s), a && d.searchParams.set("signup_redirect_url", a), window.location.href = d.toString();
|
|
1715
|
+
case 23:
|
|
1716
|
+
case "end":
|
|
1717
|
+
return t.stop();
|
|
1718
|
+
}
|
|
1719
|
+
}, t, this);
|
|
1720
|
+
}));
|
|
1721
|
+
};
|
|
1722
|
+
}
|
|
1723
|
+
}, {
|
|
1724
|
+
key: "startDiscoveryOAuthFlow",
|
|
1725
|
+
value: function value(e) {
|
|
1726
|
+
var t = this;
|
|
1727
|
+
return function (r) {
|
|
1728
|
+
var n = r.discovery_redirect_url,
|
|
1729
|
+
o = r.custom_scopes;
|
|
1730
|
+
return S(t, void 0, void 0, i().mark(function t() {
|
|
1731
|
+
var r, s, a, c, u;
|
|
1732
|
+
return i().wrap(function (t) {
|
|
1733
|
+
for (;;) switch (t.prev = t.next) {
|
|
1734
|
+
case 0:
|
|
1735
|
+
return t.next = 2, this._dynamicConfig;
|
|
1736
|
+
case 2:
|
|
1737
|
+
return r = t.sent, s = r.pkceRequiredForOAuth, t.next = 6, this.getBaseApiUrl();
|
|
1738
|
+
case 6:
|
|
1739
|
+
if (a = t.sent, (c = new URL("".concat(a, "/v1/b2b/public/oauth/").concat(e, "/discovery/start"))).searchParams.set("public_token", this._config.publicToken), o && (Q("startOAuthFlow").isStringArray("custom_scopes", o), c.searchParams.set("custom_scopes", o.join(" "))), !s) {
|
|
1740
|
+
t.next = 17;
|
|
1741
|
+
break;
|
|
1742
|
+
}
|
|
1743
|
+
return t.next = 13, this._pkceManager.startPKCETransaction();
|
|
1744
|
+
case 13:
|
|
1745
|
+
u = t.sent, c.searchParams.set("pkce_code_challenge", u.code_challenge), t.next = 18;
|
|
1746
|
+
break;
|
|
1747
|
+
case 17:
|
|
1748
|
+
this._pkceManager.clearPKPair();
|
|
1749
|
+
case 18:
|
|
1750
|
+
n && c.searchParams.set("discovery_redirect_url", n), window.location.href = c.toString();
|
|
1751
|
+
case 20:
|
|
1752
|
+
case "end":
|
|
1753
|
+
return t.stop();
|
|
1754
|
+
}
|
|
1755
|
+
}, t, this);
|
|
1756
|
+
}));
|
|
1757
|
+
};
|
|
1758
|
+
}
|
|
1759
|
+
}]), e;
|
|
1760
|
+
}(),
|
|
1761
|
+
ue = function () {
|
|
1762
|
+
function e(t, r) {
|
|
1763
|
+
var n = this;
|
|
1764
|
+
a(this, e), this._networkClient = t, this._subscriptionService = r, this.getSync = function () {
|
|
1765
|
+
return n._subscriptionService.getSession();
|
|
1766
|
+
}, this.onChange = function (e) {
|
|
1767
|
+
return n._subscriptionService.subscribeToState(function (t) {
|
|
1768
|
+
var r;
|
|
1769
|
+
return e(null !== (r = null == t ? void 0 : t.session) && void 0 !== r ? r : null);
|
|
1770
|
+
});
|
|
1771
|
+
}, this.revoke = function (e) {
|
|
1772
|
+
return S(n, void 0, void 0, i().mark(function t() {
|
|
1773
|
+
var r;
|
|
1774
|
+
return i().wrap(function (t) {
|
|
1775
|
+
for (;;) switch (t.prev = t.next) {
|
|
1776
|
+
case 0:
|
|
1777
|
+
return t.prev = 0, t.next = 3, this._networkClient.fetchSDK({
|
|
1778
|
+
url: "/b2b/sessions/revoke",
|
|
1779
|
+
errorMessage: "Error revoking session",
|
|
1780
|
+
method: "POST"
|
|
1781
|
+
});
|
|
1782
|
+
case 3:
|
|
1783
|
+
return r = t.sent, this._subscriptionService.destroyState(), t.abrupt("return", r);
|
|
1784
|
+
case 8:
|
|
1785
|
+
throw t.prev = 8, t.t0 = t["catch"](0), ((null == e ? void 0 : e.forceClear) || R.includes(t.t0.error_type)) && this._subscriptionService.destroyState(), t.t0;
|
|
1786
|
+
case 12:
|
|
1787
|
+
case "end":
|
|
1788
|
+
return t.stop();
|
|
1789
|
+
}
|
|
1790
|
+
}, t, this, [[0, 8]]);
|
|
1791
|
+
}));
|
|
1792
|
+
}, this.authenticate = function (e) {
|
|
1793
|
+
return S(n, void 0, void 0, i().mark(function t() {
|
|
1794
|
+
var r, n;
|
|
1795
|
+
return i().wrap(function (t) {
|
|
1796
|
+
for (;;) switch (t.prev = t.next) {
|
|
1797
|
+
case 0:
|
|
1798
|
+
return t.prev = 0, r = {
|
|
1799
|
+
session_duration_minutes: null == e ? void 0 : e.session_duration_minutes
|
|
1800
|
+
}, t.next = 4, this._networkClient.fetchSDK({
|
|
1801
|
+
url: "/b2b/sessions/authenticate",
|
|
1802
|
+
body: r,
|
|
1803
|
+
errorMessage: "Error authenticating session",
|
|
1804
|
+
method: "POST"
|
|
1805
|
+
});
|
|
1806
|
+
case 4:
|
|
1807
|
+
return n = t.sent, this._subscriptionService.updateStateAndTokens({
|
|
1808
|
+
state: {
|
|
1809
|
+
session: n.member_session,
|
|
1810
|
+
member: n.member
|
|
1811
|
+
},
|
|
1812
|
+
session_token: n.session_token,
|
|
1813
|
+
session_jwt: n.session_jwt,
|
|
1814
|
+
intermediate_session_token: null
|
|
1815
|
+
}), t.abrupt("return", n);
|
|
1816
|
+
case 9:
|
|
1817
|
+
throw t.prev = 9, t.t0 = t["catch"](0), R.includes(t.t0.error_type) && this._subscriptionService.destroyState(), t.t0;
|
|
1818
|
+
case 13:
|
|
1819
|
+
case "end":
|
|
1820
|
+
return t.stop();
|
|
1821
|
+
}
|
|
1822
|
+
}, t, this, [[0, 9]]);
|
|
1823
|
+
}));
|
|
1824
|
+
}, this.exchange = function (e) {
|
|
1825
|
+
return S(n, void 0, void 0, i().mark(function t() {
|
|
1826
|
+
var r;
|
|
1827
|
+
return i().wrap(function (t) {
|
|
1828
|
+
for (;;) switch (t.prev = t.next) {
|
|
1829
|
+
case 0:
|
|
1830
|
+
return Q("stytch.sessions.exchange").isString("organization_id", e.organization_id).isNumber("session_duration_minutes", e.session_duration_minutes).isOptionalString("locale", e.locale), t.prev = 1, t.next = 4, this._networkClient.fetchSDK({
|
|
1831
|
+
url: "/b2b/sessions/exchange",
|
|
1832
|
+
body: e,
|
|
1833
|
+
errorMessage: "Failed to exchange session",
|
|
1834
|
+
method: "POST"
|
|
1835
|
+
});
|
|
1836
|
+
case 4:
|
|
1837
|
+
return (r = t.sent).member_session ? this._subscriptionService.updateStateAndTokens({
|
|
1838
|
+
state: {
|
|
1839
|
+
session: r.member_session,
|
|
1840
|
+
member: r.member
|
|
1841
|
+
},
|
|
1842
|
+
session_token: r.session_token,
|
|
1843
|
+
session_jwt: r.session_jwt,
|
|
1844
|
+
intermediate_session_token: null
|
|
1845
|
+
}) : this._subscriptionService.updateStateAndTokens({
|
|
1846
|
+
state: null,
|
|
1847
|
+
session_token: null,
|
|
1848
|
+
session_jwt: null,
|
|
1849
|
+
intermediate_session_token: r.intermediate_session_token
|
|
1850
|
+
}), t.abrupt("return", r);
|
|
1851
|
+
case 9:
|
|
1852
|
+
throw t.prev = 9, t.t0 = t["catch"](1), t.t0;
|
|
1853
|
+
case 12:
|
|
1854
|
+
case "end":
|
|
1855
|
+
return t.stop();
|
|
1856
|
+
}
|
|
1857
|
+
}, t, this, [[1, 9]]);
|
|
1858
|
+
}));
|
|
1859
|
+
};
|
|
1860
|
+
}
|
|
1861
|
+
return s(e, [{
|
|
1862
|
+
key: "getTokens",
|
|
1863
|
+
value: function value() {
|
|
1864
|
+
return this._subscriptionService.getTokens();
|
|
1865
|
+
}
|
|
1866
|
+
}]), e;
|
|
1867
|
+
}(),
|
|
1868
|
+
le = s(function e(t, r) {
|
|
1869
|
+
var n = this;
|
|
1870
|
+
a(this, e), this._networkClient = t, this._subscriptionService = r, this.organizations = {
|
|
1871
|
+
list: function list() {
|
|
1872
|
+
return S(n, void 0, void 0, i().mark(function e() {
|
|
1873
|
+
return i().wrap(function (e) {
|
|
1874
|
+
for (;;) switch (e.prev = e.next) {
|
|
1875
|
+
case 0:
|
|
1876
|
+
return e.t0 = this._networkClient, e.next = 3, this._subscriptionService.getIntermediateSessionToken();
|
|
1877
|
+
case 3:
|
|
1878
|
+
if (e.t1 = e.sent, e.t1) {
|
|
1879
|
+
e.next = 6;
|
|
1880
|
+
break;
|
|
1881
|
+
}
|
|
1882
|
+
e.t1 = void 0;
|
|
1883
|
+
case 6:
|
|
1884
|
+
return e.t2 = e.t1, e.t3 = {
|
|
1885
|
+
intermediate_session_token: e.t2
|
|
1886
|
+
}, e.t4 = {
|
|
1887
|
+
url: "/b2b/discovery/organizations",
|
|
1888
|
+
body: e.t3,
|
|
1889
|
+
errorMessage: "Failed to retrieve discovered organizations",
|
|
1890
|
+
method: "POST"
|
|
1891
|
+
}, e.abrupt("return", e.t0.fetchSDK.call(e.t0, e.t4));
|
|
1892
|
+
case 10:
|
|
1893
|
+
case "end":
|
|
1894
|
+
return e.stop();
|
|
1895
|
+
}
|
|
1896
|
+
}, e, this);
|
|
1897
|
+
}));
|
|
1898
|
+
},
|
|
1899
|
+
create: function create(e) {
|
|
1900
|
+
return S(n, void 0, void 0, i().mark(function t() {
|
|
1901
|
+
var r, n;
|
|
1902
|
+
return i().wrap(function (t) {
|
|
1903
|
+
for (;;) switch (t.prev = t.next) {
|
|
1904
|
+
case 0:
|
|
1905
|
+
return Q("stytch.discovery.organizations.create").isNumber("session_duration_minutes", e.session_duration_minutes).isOptionalString("organization_name", e.organization_name).isOptionalString("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).isOptionalString("mfa_policy", e.mfa_policy), t.t0 = Object, t.t1 = Object.assign({}, e), t.next = 5, this._subscriptionService.getIntermediateSessionToken();
|
|
1906
|
+
case 5:
|
|
1907
|
+
if (t.t2 = t.sent, t.t2) {
|
|
1908
|
+
t.next = 8;
|
|
1909
|
+
break;
|
|
1910
|
+
}
|
|
1911
|
+
t.t2 = void 0;
|
|
1912
|
+
case 8:
|
|
1913
|
+
return t.t3 = t.t2, t.t4 = {
|
|
1914
|
+
intermediate_session_token: t.t3
|
|
1915
|
+
}, r = t.t0.assign.call(t.t0, t.t1, t.t4), t.next = 13, this._networkClient.fetchSDK({
|
|
1916
|
+
url: "/b2b/discovery/organizations/create",
|
|
1917
|
+
body: r,
|
|
1918
|
+
errorMessage: "Failed to create organization and member",
|
|
1919
|
+
method: "POST"
|
|
1920
|
+
});
|
|
1921
|
+
case 13:
|
|
1922
|
+
return (n = t.sent).member_session ? this._subscriptionService.updateStateAndTokens({
|
|
1923
|
+
state: {
|
|
1924
|
+
session: n.member_session,
|
|
1925
|
+
member: n.member
|
|
1926
|
+
},
|
|
1927
|
+
session_token: n.session_token,
|
|
1928
|
+
session_jwt: n.session_jwt,
|
|
1929
|
+
intermediate_session_token: null
|
|
1930
|
+
}) : this._subscriptionService.updateStateAndTokens({
|
|
1931
|
+
state: null,
|
|
1932
|
+
session_token: null,
|
|
1933
|
+
session_jwt: null,
|
|
1934
|
+
intermediate_session_token: n.intermediate_session_token
|
|
1935
|
+
}), t.abrupt("return", n);
|
|
1936
|
+
case 16:
|
|
1937
|
+
case "end":
|
|
1938
|
+
return t.stop();
|
|
1939
|
+
}
|
|
1940
|
+
}, t, this);
|
|
1941
|
+
}));
|
|
1942
|
+
}
|
|
1943
|
+
}, this.intermediateSessions = {
|
|
1944
|
+
exchange: function exchange(e) {
|
|
1945
|
+
return S(n, void 0, void 0, i().mark(function t() {
|
|
1946
|
+
var r, n;
|
|
1947
|
+
return i().wrap(function (t) {
|
|
1948
|
+
for (;;) switch (t.prev = t.next) {
|
|
1949
|
+
case 0:
|
|
1950
|
+
return Q("stytch.discovery.intermediateSessions.exchange").isString("organization_id", e.organization_id).isNumber("session_duration_minutes", e.session_duration_minutes).isOptionalString("locale", e.locale), t.t0 = Object, t.t1 = Object.assign({}, e), t.next = 5, this._subscriptionService.getIntermediateSessionToken();
|
|
1951
|
+
case 5:
|
|
1952
|
+
if (t.t2 = t.sent, t.t2) {
|
|
1953
|
+
t.next = 8;
|
|
1954
|
+
break;
|
|
1955
|
+
}
|
|
1956
|
+
t.t2 = void 0;
|
|
1957
|
+
case 8:
|
|
1958
|
+
return t.t3 = t.t2, t.t4 = {
|
|
1959
|
+
intermediate_session_token: t.t3
|
|
1960
|
+
}, r = t.t0.assign.call(t.t0, t.t1, t.t4), t.next = 13, this._networkClient.fetchSDK({
|
|
1961
|
+
url: "/b2b/discovery/intermediate_sessions/exchange",
|
|
1962
|
+
body: r,
|
|
1963
|
+
errorMessage: "Failed to exchange intermediate session",
|
|
1964
|
+
method: "POST"
|
|
1965
|
+
});
|
|
1966
|
+
case 13:
|
|
1967
|
+
return (n = t.sent).member_session ? this._subscriptionService.updateStateAndTokens({
|
|
1968
|
+
state: {
|
|
1969
|
+
session: n.member_session,
|
|
1970
|
+
member: n.member
|
|
1971
|
+
},
|
|
1972
|
+
session_token: n.session_token,
|
|
1973
|
+
session_jwt: n.session_jwt,
|
|
1974
|
+
intermediate_session_token: null
|
|
1975
|
+
}) : this._subscriptionService.updateStateAndTokens({
|
|
1976
|
+
state: null,
|
|
1977
|
+
session_token: null,
|
|
1978
|
+
session_jwt: null,
|
|
1979
|
+
intermediate_session_token: n.intermediate_session_token
|
|
1980
|
+
}), t.abrupt("return", n);
|
|
1981
|
+
case 16:
|
|
1982
|
+
case "end":
|
|
1983
|
+
return t.stop();
|
|
1984
|
+
}
|
|
1985
|
+
}, t, this);
|
|
1986
|
+
}));
|
|
1987
|
+
}
|
|
1988
|
+
};
|
|
1989
|
+
});
|
|
1990
|
+
Promise.resolve({
|
|
1991
|
+
pkceRequiredForPasswordResets: !1
|
|
1992
|
+
});
|
|
1993
|
+
var de,
|
|
1994
|
+
he,
|
|
1995
|
+
_e,
|
|
1996
|
+
pe,
|
|
1997
|
+
me,
|
|
1998
|
+
fe,
|
|
1999
|
+
ve,
|
|
2000
|
+
be,
|
|
2001
|
+
ge,
|
|
2002
|
+
ye,
|
|
2003
|
+
ke,
|
|
2004
|
+
Se = s(function e(t, r) {
|
|
2005
|
+
var n = this,
|
|
2006
|
+
o = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : te();
|
|
2007
|
+
a(this, e), this._networkClient = t, this._subscriptionService = r, this.dfpProtectedAuth = o, this.sms = {
|
|
2008
|
+
send: function send(e) {
|
|
2009
|
+
return S(n, void 0, void 0, i().mark(function t() {
|
|
2010
|
+
var r, n, o;
|
|
2011
|
+
return i().wrap(function (t) {
|
|
2012
|
+
for (;;) switch (t.prev = t.next) {
|
|
2013
|
+
case 0:
|
|
2014
|
+
return Q("stytch.otps.sms.send").isString("organization_id", e.organization_id).isString("member_id", e.member_id).isOptionalString("mfa_phone_number", e.mfa_phone_number).isOptionalString("locale", e.locale), t.next = 3, this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
|
|
2015
|
+
case 3:
|
|
2016
|
+
return r = t.sent, n = r.dfp_telemetry_id, o = r.captcha_token, t.abrupt("return", this._networkClient.retriableFetchSDK({
|
|
2017
|
+
url: "/b2b/otps/sms/send",
|
|
2018
|
+
body: Object.assign(Object.assign({}, e), {
|
|
2019
|
+
dfp_telemetry_id: n,
|
|
2020
|
+
captcha_token: o
|
|
2021
|
+
}),
|
|
2022
|
+
errorMessage: "Failed to send one time passcode",
|
|
2023
|
+
method: "POST",
|
|
2024
|
+
retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
|
|
2025
|
+
}));
|
|
2026
|
+
case 7:
|
|
2027
|
+
case "end":
|
|
2028
|
+
return t.stop();
|
|
2029
|
+
}
|
|
2030
|
+
}, t, this);
|
|
2031
|
+
}));
|
|
2032
|
+
},
|
|
2033
|
+
authenticate: function authenticate(e) {
|
|
2034
|
+
return S(n, void 0, void 0, i().mark(function t() {
|
|
2035
|
+
var r, n, o, s, a;
|
|
2036
|
+
return i().wrap(function (t) {
|
|
2037
|
+
for (;;) switch (t.prev = t.next) {
|
|
2038
|
+
case 0:
|
|
2039
|
+
return Q("stytch.otps.sms.authenticate").isString("organization_id", e.organization_id).isString("member_id", e.member_id).isString("code", e.code).isOptionalString("set_mfa_enrollment", e.set_mfa_enrollment), t.next = 3, this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
|
|
2040
|
+
case 3:
|
|
2041
|
+
return r = t.sent, n = r.dfp_telemetry_id, o = r.captcha_token, t.t0 = Object, t.t1 = Object.assign({}, e), t.t2 = n, t.t3 = o, t.next = 12, this._subscriptionService.getIntermediateSessionToken();
|
|
2042
|
+
case 12:
|
|
2043
|
+
if (t.t4 = t.sent, t.t4) {
|
|
2044
|
+
t.next = 15;
|
|
2045
|
+
break;
|
|
2046
|
+
}
|
|
2047
|
+
t.t4 = void 0;
|
|
2048
|
+
case 15:
|
|
2049
|
+
return t.t5 = t.t4, t.t6 = {
|
|
2050
|
+
dfp_telemetry_id: t.t2,
|
|
2051
|
+
captcha_token: t.t3,
|
|
2052
|
+
intermediate_session_token: t.t5
|
|
2053
|
+
}, s = t.t0.assign.call(t.t0, t.t1, t.t6), t.next = 20, this._networkClient.retriableFetchSDK({
|
|
2054
|
+
url: "/b2b/otps/sms/authenticate",
|
|
2055
|
+
body: s,
|
|
2056
|
+
errorMessage: "Failed to authenticate one time passcode",
|
|
2057
|
+
method: "POST",
|
|
2058
|
+
retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
|
|
2059
|
+
});
|
|
2060
|
+
case 20:
|
|
2061
|
+
return a = t.sent, this._subscriptionService.updateStateAndTokens({
|
|
2062
|
+
state: {
|
|
2063
|
+
session: a.member_session,
|
|
2064
|
+
member: a.member
|
|
2065
|
+
},
|
|
2066
|
+
session_token: a.session_token,
|
|
2067
|
+
session_jwt: a.session_jwt,
|
|
2068
|
+
intermediate_session_token: null
|
|
2069
|
+
}), t.abrupt("return", a);
|
|
2070
|
+
case 23:
|
|
2071
|
+
case "end":
|
|
2072
|
+
return t.stop();
|
|
2073
|
+
}
|
|
2074
|
+
}, t, this);
|
|
2075
|
+
}));
|
|
2076
|
+
}
|
|
2077
|
+
};
|
|
2078
|
+
}),
|
|
2079
|
+
we = function () {
|
|
2080
|
+
function e(t, r) {
|
|
2081
|
+
var n = this;
|
|
2082
|
+
a(this, e), this._subscriptionService = t, this._headlessSessionClient = r, this._onDataChange = function (e) {
|
|
2083
|
+
(null == e ? void 0 : e.session) ? n.scheduleBackgroundRefresh() : n.cancelBackgroundRefresh();
|
|
2084
|
+
}, this._reauthenticateWithBackoff = function () {
|
|
2085
|
+
return S(n, void 0, void 0, i().mark(function t() {
|
|
2086
|
+
var r;
|
|
2087
|
+
return i().wrap(function (t) {
|
|
2088
|
+
for (;;) switch (t.prev = t.next) {
|
|
2089
|
+
case 0:
|
|
2090
|
+
r = 0;
|
|
2091
|
+
case 1:
|
|
2092
|
+
return t.prev = 2, t.next = 5, this._headlessSessionClient.authenticate();
|
|
2093
|
+
case 5:
|
|
2094
|
+
return t.abrupt("return", t.sent);
|
|
2095
|
+
case 8:
|
|
2096
|
+
if (t.prev = 8, t.t0 = t["catch"](2), !e.isUnrecoverableError(t.t0)) {
|
|
2097
|
+
t.next = 12;
|
|
2098
|
+
break;
|
|
2099
|
+
}
|
|
2100
|
+
return t.abrupt("return", Promise.reject(t.t0));
|
|
2101
|
+
case 12:
|
|
2102
|
+
return r++, t.next = 15, new Promise(function (t) {
|
|
2103
|
+
return setTimeout(t, e.timeoutForAttempt(r));
|
|
2104
|
+
});
|
|
2105
|
+
case 15:
|
|
2106
|
+
t.next = 1;
|
|
2107
|
+
break;
|
|
2108
|
+
case 17:
|
|
2109
|
+
case "end":
|
|
2110
|
+
return t.stop();
|
|
2111
|
+
}
|
|
2112
|
+
}, t, this, [[2, 8]]);
|
|
2113
|
+
}));
|
|
2114
|
+
}, this.timeout = null, this._subscriptionService.subscribeToState(this._onDataChange);
|
|
2115
|
+
}
|
|
2116
|
+
return s(e, [{
|
|
2117
|
+
key: "performBackgroundRefresh",
|
|
2118
|
+
value: function value() {
|
|
2119
|
+
var e = this;
|
|
2120
|
+
this._reauthenticateWithBackoff().then(function () {
|
|
2121
|
+
e.scheduleBackgroundRefresh();
|
|
2122
|
+
})["catch"](function (t) {
|
|
2123
|
+
$("Session background refresh failed. Signalling to app that user is logged out.", {
|
|
2124
|
+
error: t
|
|
2125
|
+
}), e._subscriptionService.destroyState();
|
|
2126
|
+
});
|
|
2127
|
+
}
|
|
2128
|
+
}, {
|
|
2129
|
+
key: "scheduleBackgroundRefresh",
|
|
2130
|
+
value: function value() {
|
|
2131
|
+
var t = this;
|
|
2132
|
+
this.cancelBackgroundRefresh(), this.timeout = setTimeout(function () {
|
|
2133
|
+
t.performBackgroundRefresh();
|
|
2134
|
+
}, e.REFRESH_INTERVAL_MS);
|
|
2135
|
+
}
|
|
2136
|
+
}, {
|
|
2137
|
+
key: "cancelBackgroundRefresh",
|
|
2138
|
+
value: function value() {
|
|
2139
|
+
null !== this.timeout && (clearTimeout(this.timeout), this.timeout = null);
|
|
2140
|
+
}
|
|
2141
|
+
}], [{
|
|
2142
|
+
key: "timeoutForAttempt",
|
|
2143
|
+
value: function value(e) {
|
|
2144
|
+
return e = Math.min(e, 7), Math.floor(350 * Math.random()) - 175 + 2e3 * Math.pow(2, e);
|
|
2145
|
+
}
|
|
2146
|
+
}, {
|
|
2147
|
+
key: "isUnrecoverableError",
|
|
2148
|
+
value: function value(e) {
|
|
2149
|
+
return R.includes(e.error_type);
|
|
2150
|
+
}
|
|
2151
|
+
}]), e;
|
|
2152
|
+
}();
|
|
2153
|
+
function Ae(e, t, r, n) {
|
|
2154
|
+
return new (r || (r = Promise))(function (i, o) {
|
|
2155
|
+
function s(e) {
|
|
2156
|
+
try {
|
|
2157
|
+
c(n.next(e));
|
|
2158
|
+
} catch (e) {
|
|
2159
|
+
o(e);
|
|
2160
|
+
}
|
|
2161
|
+
}
|
|
2162
|
+
function a(e) {
|
|
2163
|
+
try {
|
|
2164
|
+
c(n["throw"](e));
|
|
2165
|
+
} catch (e) {
|
|
2166
|
+
o(e);
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
function c(e) {
|
|
2170
|
+
var t;
|
|
2171
|
+
e.done ? i(e.value) : (t = e.value, t instanceof r ? t : new r(function (e) {
|
|
2172
|
+
e(t);
|
|
2173
|
+
})).then(s, a);
|
|
2174
|
+
}
|
|
2175
|
+
c((n = n.apply(e, t || [])).next());
|
|
2176
|
+
});
|
|
2177
|
+
}
|
|
2178
|
+
we.REFRESH_INTERVAL_MS = 18e4, function (e) {
|
|
2179
|
+
e.emailMagicLinks = "emailMagicLinks", e.oauth = "oauth", e.otp = "otp", e.crypto = "crypto", e.passwords = "passwords";
|
|
2180
|
+
}(de || (de = {})), function (e) {
|
|
2181
|
+
e.Google = "google", e.Microsoft = "microsoft", e.Apple = "apple", e.Github = "github", e.GitLab = "gitlab", e.Facebook = "facebook", e.Discord = "discord", e.Salesforce = "salesforce", e.Slack = "slack", e.Amazon = "amazon", e.Bitbucket = "bitbucket", e.LinkedIn = "linkedin", e.Coinbase = "coinbase", e.Twitch = "twitch", e.Twitter = "twitter", e.TikTok = "tiktok", e.Snapchat = "snapchat", e.Figma = "figma", e.Yahoo = "yahoo";
|
|
2182
|
+
}(he || (he = {})), function (e) {
|
|
2183
|
+
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";
|
|
2184
|
+
}(_e || (_e = {})), function (e) {
|
|
2185
|
+
e.embedded = "embedded", e.floating = "floating";
|
|
2186
|
+
}(pe || (pe = {})), function (e) {
|
|
2187
|
+
e.SMS = "sms", e.WhatsApp = "whatsapp", e.Email = "email";
|
|
2188
|
+
}(me || (me = {})), function (e) {
|
|
2189
|
+
e.MagicLinkLoginOrCreateEvent = "MAGIC_LINK_LOGIN_OR_CREATE", e.OTPsLoginOrCreateEvent = "OTP_LOGIN_OR_CREATE", e.OTPsAuthenticate = "OTP_AUTHENTICATE", e.CryptoWalletAuthenticateStart = "CRYPTO_WALLET_AUTHENTICATE_START", e.CryptoWalletAuthenticate = "CRYPTO_WALLET_AUTHENTICATE", e.PasswordCreate = "PASSWORD_CREATE", e.PasswordAuthenticate = "PASSWORD_AUTHENTICATE", e.PasswordResetByEmailStart = "PASSWORD_RESET_BY_EMAIL_START", e.PasswordResetByEmail = "PASSWORD_RESET_BY_EMAIL", e.B2BMagicLinkEmailLoginOrSignup = "B2B_MAGIC_LINK_EMAIL_LOGIN_OR_SIGNUP", e.B2BMagicLinkAuthenticate = "B2B_MAGIC_LINK_AUTHENTICATE", e.B2BMagicLinkEmailDiscoverySend = "B2B_MAGIC_LINK_EMAIL_DISCOVERY_SEND", e.B2BMagicLinkDiscoveryAuthenticate = "B2B_MAGIC_LINK_DISCOVERY_AUTHENTICATE", e.B2BSSOStart = "B2B_SSO_START", e.B2BSSOAuthenticate = "B2B_SSO_AUTHENTICATE", e.B2BOAuthAuthenticate = "B2B_SSO_AUTHENTICATE", e.B2BOAuthDiscoveryAuthenticate = "B2B_OAUTH_DISCOVERY_AUTHENTICATE", e.B2BDiscoveryOrganizationsCreate = "B2B_DISCOVERY_ORGANIZATIONS_CREATE", e.B2BDiscoveryIntermediateSessionExchange = "B2B_DISCOVERY_INTERMEDIATE_SESSION_EXCHANGE", e.B2BPasswordAuthenticate = "B2B_PASSWORD_AUTHENTICATE", e.B2BPasswordResetByEmailStart = "B2B_PASSWORD_RESET_BY_EMAIL_START", e.B2BPasswordResetByEmail = "B2B_PASSWORD_RESET_BY_EMAIL", e.B2BPasswordResetBySession = "B2B_PASSWORD_RESET_BY_SESSION";
|
|
2190
|
+
}(fe || (fe = {}));
|
|
2191
|
+
var Te = /*#__PURE__*/function (_Error) {
|
|
2192
|
+
_inherits(Te, _Error);
|
|
2193
|
+
var _super = _createSuper(Te);
|
|
2194
|
+
function Te(e, t) {
|
|
2195
|
+
var _this;
|
|
2196
|
+
_classCallCheck(this, Te);
|
|
2197
|
+
_this = _super.call(this), _this.name = "StytchSDKUsageError", _this.message = "Invalid call to ".concat(e, "\n") + t;
|
|
2198
|
+
return _this;
|
|
2199
|
+
}
|
|
2200
|
+
return _createClass(Te);
|
|
2201
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
2202
|
+
!function (e) {
|
|
2203
|
+
e.BiometricsSensorError = "biometrics_sensor_error", e.DeviceCredentialsNotAllowed = "device_credentials_not_allowed", e.DeviceHardwareError = "device_hardware_error", e.InternalError = "internal_error", e.KeyInvalidated = "key_invalidated", e.KeystoreUnavailable = "keystore_unavailable", e.NoBiometricsEnrolled = "no_biometrics_enrolled", e.NoBiometricsRegistration = "no_biometrics_registration", e.SessionExpired = "session_expired", e.UserCancellation = "user_cancellation", e.UserLockedOut = "user_locked_out", e.BiometricsNotAvailable = "biometrics_not_available";
|
|
2204
|
+
}(ve || (ve = {})), function (e) {
|
|
2205
|
+
e.emailMagicLinks = "emailMagicLinks", e.sso = "sso", e.passwords = "passwords", e.oauth = "oauth";
|
|
2206
|
+
}(be || (be = {})), function (e) {
|
|
2207
|
+
e.Discovery = "Discovery", e.Organization = "Organization", e.PasswordReset = "PasswordReset";
|
|
2208
|
+
}(ge || (ge = {})), function (e) {
|
|
2209
|
+
e.Google = "google", e.Microsoft = "microsoft";
|
|
2210
|
+
}(ye || (ye = {})), function (e) {
|
|
2211
|
+
e.RequiredCatcha = "Catcha Required";
|
|
2212
|
+
}(ke || (ke = {}));
|
|
2213
|
+
var Oe = function Oe(e) {
|
|
2214
|
+
var t = {
|
|
2215
|
+
isObject: function isObject(r, n) {
|
|
2216
|
+
if (!("object" == _typeof(n) && !Array.isArray(n) && null !== n)) throw new Te(e, r + " must be an object.");
|
|
2217
|
+
return t;
|
|
2218
|
+
},
|
|
2219
|
+
isOptionalObject: function isOptionalObject(e, r) {
|
|
2220
|
+
return void 0 === r ? t : t.isObject(e, r);
|
|
2221
|
+
},
|
|
2222
|
+
isString: function isString(r, n) {
|
|
2223
|
+
if ("string" != typeof n) throw new Te(e, r + " must be a string.");
|
|
2224
|
+
return t;
|
|
2225
|
+
},
|
|
2226
|
+
isOptionalString: function isOptionalString(e, r) {
|
|
2227
|
+
return void 0 === r ? t : t.isString(e, r);
|
|
2228
|
+
},
|
|
2229
|
+
isStringArray: function isStringArray(r, n) {
|
|
2230
|
+
if (!Array.isArray(n)) throw new Te(e, r + " must be an array of strings.");
|
|
2231
|
+
var _iterator = _createForOfIteratorHelper(n),
|
|
2232
|
+
_step;
|
|
2233
|
+
try {
|
|
2234
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2235
|
+
var _t2 = _step.value;
|
|
2236
|
+
if ("string" != typeof _t2) throw new Te(e, r + " must be an array of strings.");
|
|
2237
|
+
}
|
|
2238
|
+
} catch (err) {
|
|
2239
|
+
_iterator.e(err);
|
|
2240
|
+
} finally {
|
|
2241
|
+
_iterator.f();
|
|
2242
|
+
}
|
|
2243
|
+
return t;
|
|
2244
|
+
},
|
|
2245
|
+
isOptionalStringArray: function isOptionalStringArray(e, r) {
|
|
2246
|
+
return void 0 === r ? t : t.isStringArray(e, r);
|
|
2247
|
+
},
|
|
2248
|
+
isNumber: function isNumber(r, n) {
|
|
2249
|
+
if ("number" != typeof n) throw new Te(e, r + " must be a number.");
|
|
2250
|
+
return t;
|
|
2251
|
+
},
|
|
2252
|
+
isOptionalNumber: function isOptionalNumber(e, r) {
|
|
2253
|
+
return void 0 === r ? t : t.isNumber(e, r);
|
|
2254
|
+
},
|
|
2255
|
+
isBoolean: function isBoolean(r, n) {
|
|
2256
|
+
if ("boolean" != typeof n) throw new Te(e, r + " must be a boolean.");
|
|
2257
|
+
return t;
|
|
2258
|
+
},
|
|
2259
|
+
isOptionalBoolean: function isOptionalBoolean(e, r) {
|
|
2260
|
+
return void 0 === r ? t : t.isBoolean(e, r);
|
|
2261
|
+
}
|
|
2262
|
+
};
|
|
2263
|
+
return t;
|
|
2264
|
+
};
|
|
2265
|
+
var Ee;
|
|
2266
|
+
!function (e) {
|
|
2267
|
+
e.LoginOrCreateEML = "login_or_create_eml", e.LoginOrCreateOTP = "login_or_create_otp", e.ResetPassword = "reset_password";
|
|
2268
|
+
}(Ee || (Ee = {})), Promise.resolve({
|
|
2269
|
+
pkceRequiredForEmailMagicLinks: !1
|
|
2270
|
+
}), Promise.resolve({
|
|
2271
|
+
pkceRequiredForPasswordResets: !1
|
|
2272
|
+
}), Promise.resolve({
|
|
2273
|
+
pkceRequiredForEmailMagicLinks: !1
|
|
2274
|
+
});
|
|
2275
|
+
var Ce = Promise.resolve({
|
|
2276
|
+
pkceRequiredForPasswordResets: !1
|
|
2277
|
+
});
|
|
2278
|
+
var Pe = /*#__PURE__*/function () {
|
|
2279
|
+
function Pe(e, t, r) {
|
|
2280
|
+
var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : Ce;
|
|
2281
|
+
var i = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : function () {
|
|
2282
|
+
return {
|
|
2283
|
+
isEnabled: function isEnabled() {
|
|
2284
|
+
return Ae(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
2285
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
2286
|
+
while (1) switch (_context.prev = _context.next) {
|
|
2287
|
+
case 0:
|
|
2288
|
+
return _context.abrupt("return", !1);
|
|
2289
|
+
case 1:
|
|
2290
|
+
case "end":
|
|
2291
|
+
return _context.stop();
|
|
2292
|
+
}
|
|
2293
|
+
}, _callee);
|
|
2294
|
+
}));
|
|
2295
|
+
},
|
|
2296
|
+
getTelemetryID: function getTelemetryID() {
|
|
2297
|
+
return Ae(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
2298
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
2299
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
2300
|
+
case 0:
|
|
2301
|
+
case "end":
|
|
2302
|
+
return _context2.stop();
|
|
2303
|
+
}
|
|
2304
|
+
}, _callee2);
|
|
2305
|
+
}));
|
|
2306
|
+
},
|
|
2307
|
+
getDFPTelemetryIDAndCaptcha: function getDFPTelemetryIDAndCaptcha() {
|
|
2308
|
+
return Ae(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
2309
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
2310
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
2311
|
+
case 0:
|
|
2312
|
+
return _context3.abrupt("return", {
|
|
2313
|
+
dfp_telemetry_id: void 0,
|
|
2314
|
+
captcha_token: void 0
|
|
2315
|
+
});
|
|
2316
|
+
case 1:
|
|
2317
|
+
case "end":
|
|
2318
|
+
return _context3.stop();
|
|
2319
|
+
}
|
|
2320
|
+
}, _callee3);
|
|
2321
|
+
}));
|
|
2322
|
+
},
|
|
2323
|
+
retryWithCaptchaAndDFP: function retryWithCaptchaAndDFP() {
|
|
2324
|
+
return Ae(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
2325
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
2326
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
2327
|
+
case 0:
|
|
2328
|
+
throw new Error("DFP protected auth is disabled");
|
|
2329
|
+
case 1:
|
|
2330
|
+
case "end":
|
|
2331
|
+
return _context4.stop();
|
|
2332
|
+
}
|
|
2333
|
+
}, _callee4);
|
|
2334
|
+
}));
|
|
2335
|
+
}
|
|
2336
|
+
};
|
|
2337
|
+
}();
|
|
2338
|
+
_classCallCheck(this, Pe);
|
|
2339
|
+
this._networkClient = e, this._subscriptionService = t, this._pkceManager = r, this._config = n, this.dfpProtectedAuth = i;
|
|
2340
|
+
}
|
|
2341
|
+
_createClass(Pe, [{
|
|
2342
|
+
key: "getCodeChallenge",
|
|
2343
|
+
value: function getCodeChallenge() {
|
|
2344
|
+
return Ae(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
2345
|
+
var _yield$this$_config, e, t;
|
|
2346
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
2347
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
2348
|
+
case 0:
|
|
2349
|
+
_context5.next = 2;
|
|
2350
|
+
return this._config;
|
|
2351
|
+
case 2:
|
|
2352
|
+
_yield$this$_config = _context5.sent;
|
|
2353
|
+
e = _yield$this$_config.pkceRequiredForPasswordResets;
|
|
2354
|
+
if (e) {
|
|
2355
|
+
_context5.next = 6;
|
|
2356
|
+
break;
|
|
2357
|
+
}
|
|
2358
|
+
return _context5.abrupt("return");
|
|
2359
|
+
case 6:
|
|
2360
|
+
_context5.next = 8;
|
|
2361
|
+
return this._pkceManager.getPKPair();
|
|
2362
|
+
case 8:
|
|
2363
|
+
t = _context5.sent;
|
|
2364
|
+
_context5.t0 = t;
|
|
2365
|
+
if (_context5.t0) {
|
|
2366
|
+
_context5.next = 14;
|
|
2367
|
+
break;
|
|
2368
|
+
}
|
|
2369
|
+
_context5.next = 13;
|
|
2370
|
+
return this._pkceManager.startPKCETransaction();
|
|
2371
|
+
case 13:
|
|
2372
|
+
t = _context5.sent;
|
|
2373
|
+
case 14:
|
|
2374
|
+
return _context5.abrupt("return", t.code_challenge);
|
|
2375
|
+
case 15:
|
|
2376
|
+
case "end":
|
|
2377
|
+
return _context5.stop();
|
|
2378
|
+
}
|
|
2379
|
+
}, _callee5, this);
|
|
2380
|
+
}));
|
|
2381
|
+
}
|
|
2382
|
+
}, {
|
|
2383
|
+
key: "authenticate",
|
|
2384
|
+
value: function authenticate(e) {
|
|
2385
|
+
return Ae(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
2386
|
+
var t, r, _yield$this$dfpProtec, n, i, o;
|
|
2387
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
2388
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
2389
|
+
case 0:
|
|
2390
|
+
Oe("stytch.passwords.authenticate").isString("org_id", e.organization_id).isString("password", e.password).isString("email_address", e.email_address).isNumber("session_duration_minutes", e.session_duration_minutes).isOptionalString("locale", e.locale);
|
|
2391
|
+
_context6.next = 3;
|
|
2392
|
+
return this._pkceManager.getPKPair();
|
|
2393
|
+
case 3:
|
|
2394
|
+
t = _context6.sent;
|
|
2395
|
+
r = null == t ? void 0 : t.code_verifier;
|
|
2396
|
+
_context6.next = 7;
|
|
2397
|
+
return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
|
|
2398
|
+
case 7:
|
|
2399
|
+
_yield$this$dfpProtec = _context6.sent;
|
|
2400
|
+
n = _yield$this$dfpProtec.dfp_telemetry_id;
|
|
2401
|
+
i = _yield$this$dfpProtec.captcha_token;
|
|
2402
|
+
_context6.next = 12;
|
|
2403
|
+
return this._networkClient.retriableFetchSDK({
|
|
2404
|
+
url: "/b2b/passwords/authenticate",
|
|
2405
|
+
method: "POST",
|
|
2406
|
+
errorMessage: "Failed to authenticate password.",
|
|
2407
|
+
body: {
|
|
2408
|
+
organization_id: e.organization_id,
|
|
2409
|
+
email_address: e.email_address,
|
|
2410
|
+
password: e.password,
|
|
2411
|
+
session_duration_minutes: e.session_duration_minutes,
|
|
2412
|
+
locale: e.locale,
|
|
2413
|
+
captcha_token: i,
|
|
2414
|
+
dfp_telemetry_id: n,
|
|
2415
|
+
code_verifier: r
|
|
2416
|
+
},
|
|
2417
|
+
retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
|
|
2418
|
+
});
|
|
2419
|
+
case 12:
|
|
2420
|
+
o = _context6.sent;
|
|
2421
|
+
return _context6.abrupt("return", (o.member_session ? this._subscriptionService.updateStateAndTokens({
|
|
2422
|
+
state: {
|
|
2423
|
+
session: o.member_session,
|
|
2424
|
+
member: o.member
|
|
2425
|
+
},
|
|
2426
|
+
session_token: o.session_token,
|
|
2427
|
+
session_jwt: o.session_jwt,
|
|
2428
|
+
intermediate_session_token: null
|
|
2429
|
+
}) : this._subscriptionService.updateStateAndTokens({
|
|
2430
|
+
state: null,
|
|
2431
|
+
session_token: null,
|
|
2432
|
+
session_jwt: null,
|
|
2433
|
+
intermediate_session_token: o.intermediate_session_token
|
|
2434
|
+
}), o));
|
|
2435
|
+
case 14:
|
|
2436
|
+
case "end":
|
|
2437
|
+
return _context6.stop();
|
|
2438
|
+
}
|
|
2439
|
+
}, _callee6, this);
|
|
2440
|
+
}));
|
|
2441
|
+
}
|
|
2442
|
+
}, {
|
|
2443
|
+
key: "resetByEmailStart",
|
|
2444
|
+
value: function resetByEmailStart(e) {
|
|
2445
|
+
return Ae(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
2446
|
+
var t, _yield$this$dfpProtec2, r, n;
|
|
2447
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
2448
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
2449
|
+
case 0:
|
|
2450
|
+
Oe("stytch.passwords.resetByEmailStart").isString("email", e.email_address).isOptionalString("login_redirect_url", e.login_redirect_url).isOptionalString("reset_password_redirect_url", e.reset_password_redirect_url).isOptionalString("reset_password_template_id", e.reset_password_template_id).isOptionalNumber("reset_password_expiration_minutes", e.reset_password_expiration_minutes);
|
|
2451
|
+
_context7.next = 3;
|
|
2452
|
+
return this.getCodeChallenge();
|
|
2453
|
+
case 3:
|
|
2454
|
+
t = _context7.sent;
|
|
2455
|
+
_context7.next = 6;
|
|
2456
|
+
return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
|
|
2457
|
+
case 6:
|
|
2458
|
+
_yield$this$dfpProtec2 = _context7.sent;
|
|
2459
|
+
r = _yield$this$dfpProtec2.dfp_telemetry_id;
|
|
2460
|
+
n = _yield$this$dfpProtec2.captcha_token;
|
|
2461
|
+
return _context7.abrupt("return", this._networkClient.retriableFetchSDK({
|
|
2462
|
+
url: "/b2b/passwords/email/reset/start",
|
|
2463
|
+
method: "POST",
|
|
2464
|
+
errorMessage: "Failed to start password reset flow.",
|
|
2465
|
+
body: {
|
|
2466
|
+
organization_id: e.organization_id,
|
|
2467
|
+
email_address: e.email_address,
|
|
2468
|
+
login_redirect_url: e.login_redirect_url,
|
|
2469
|
+
reset_password_redirect_url: e.reset_password_redirect_url,
|
|
2470
|
+
reset_password_expiration_minutes: e.reset_password_expiration_minutes,
|
|
2471
|
+
reset_password_template_id: e.reset_password_template_id,
|
|
2472
|
+
code_challenge: t,
|
|
2473
|
+
captcha_token: n,
|
|
2474
|
+
dfp_telemetry_id: r
|
|
2475
|
+
},
|
|
2476
|
+
retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
|
|
2477
|
+
}));
|
|
2478
|
+
case 10:
|
|
2479
|
+
case "end":
|
|
2480
|
+
return _context7.stop();
|
|
2481
|
+
}
|
|
2482
|
+
}, _callee7, this);
|
|
2483
|
+
}));
|
|
2484
|
+
}
|
|
2485
|
+
}, {
|
|
2486
|
+
key: "resetByEmail",
|
|
2487
|
+
value: function resetByEmail(e) {
|
|
2488
|
+
return Ae(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
2489
|
+
var _yield$this$dfpProtec3, t, r, n, i, o;
|
|
2490
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
2491
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
2492
|
+
case 0:
|
|
2493
|
+
Oe("stytch.passwords.resetByEmail").isString("password_reset_token", e.password_reset_token).isString("password", e.password).isNumber("session_duration_minutes", e.session_duration_minutes).isOptionalString("locale", e.locale);
|
|
2494
|
+
_context8.next = 3;
|
|
2495
|
+
return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
|
|
2496
|
+
case 3:
|
|
2497
|
+
_yield$this$dfpProtec3 = _context8.sent;
|
|
2498
|
+
t = _yield$this$dfpProtec3.dfp_telemetry_id;
|
|
2499
|
+
r = _yield$this$dfpProtec3.captcha_token;
|
|
2500
|
+
_context8.next = 8;
|
|
2501
|
+
return this._pkceManager.getPKPair();
|
|
2502
|
+
case 8:
|
|
2503
|
+
n = _context8.sent;
|
|
2504
|
+
i = null == n ? void 0 : n.code_verifier;
|
|
2505
|
+
_context8.next = 12;
|
|
2506
|
+
return this._networkClient.retriableFetchSDK({
|
|
2507
|
+
url: "/b2b/passwords/email/reset",
|
|
2508
|
+
method: "POST",
|
|
2509
|
+
errorMessage: "Failed to reset password.",
|
|
2510
|
+
body: {
|
|
2511
|
+
password_reset_token: e.password_reset_token,
|
|
2512
|
+
password: e.password,
|
|
2513
|
+
session_duration_minutes: e.session_duration_minutes,
|
|
2514
|
+
locale: e.locale,
|
|
2515
|
+
captcha_token: r,
|
|
2516
|
+
dfp_telemetry_id: t,
|
|
2517
|
+
code_verifier: i
|
|
2518
|
+
},
|
|
2519
|
+
retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
|
|
2520
|
+
});
|
|
2521
|
+
case 12:
|
|
2522
|
+
o = _context8.sent;
|
|
2523
|
+
return _context8.abrupt("return", (this._pkceManager.clearPKPair(), o.member_session ? this._subscriptionService.updateStateAndTokens({
|
|
2524
|
+
state: {
|
|
2525
|
+
session: o.member_session,
|
|
2526
|
+
member: o.member
|
|
2527
|
+
},
|
|
2528
|
+
session_token: o.session_token,
|
|
2529
|
+
session_jwt: o.session_jwt,
|
|
2530
|
+
intermediate_session_token: null
|
|
2531
|
+
}) : this._subscriptionService.updateStateAndTokens({
|
|
2532
|
+
state: null,
|
|
2533
|
+
session_token: null,
|
|
2534
|
+
session_jwt: null,
|
|
2535
|
+
intermediate_session_token: o.intermediate_session_token
|
|
2536
|
+
}), o));
|
|
2537
|
+
case 14:
|
|
2538
|
+
case "end":
|
|
2539
|
+
return _context8.stop();
|
|
2540
|
+
}
|
|
2541
|
+
}, _callee8, this);
|
|
2542
|
+
}));
|
|
2543
|
+
}
|
|
2544
|
+
}, {
|
|
2545
|
+
key: "resetByExistingPassword",
|
|
2546
|
+
value: function resetByExistingPassword(e) {
|
|
2547
|
+
return Ae(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
2548
|
+
var _yield$this$dfpProtec4, t, r, n;
|
|
2549
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
2550
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
2551
|
+
case 0:
|
|
2552
|
+
Oe("stytch.passwords.resetByExistingPassword").isString("email", e.email_address).isString("existing_password", e.existing_password).isString("new_password", e.new_password).isOptionalString("locale", e.locale);
|
|
2553
|
+
_context9.next = 3;
|
|
2554
|
+
return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
|
|
2555
|
+
case 3:
|
|
2556
|
+
_yield$this$dfpProtec4 = _context9.sent;
|
|
2557
|
+
t = _yield$this$dfpProtec4.dfp_telemetry_id;
|
|
2558
|
+
r = _yield$this$dfpProtec4.captcha_token;
|
|
2559
|
+
_context9.next = 8;
|
|
2560
|
+
return this._networkClient.retriableFetchSDK({
|
|
2561
|
+
url: "/b2b/passwords/existing_password/reset",
|
|
2562
|
+
method: "POST",
|
|
2563
|
+
errorMessage: "Failed to reset password.",
|
|
2564
|
+
body: {
|
|
2565
|
+
organization_id: e.organization_id,
|
|
2566
|
+
email_address: e.email_address,
|
|
2567
|
+
existing_password: e.existing_password,
|
|
2568
|
+
new_password: e.new_password,
|
|
2569
|
+
locale: e.locale,
|
|
2570
|
+
captcha_token: r,
|
|
2571
|
+
dfp_telemetry_id: t
|
|
2572
|
+
},
|
|
2573
|
+
retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
|
|
2574
|
+
});
|
|
2575
|
+
case 8:
|
|
2576
|
+
n = _context9.sent;
|
|
2577
|
+
return _context9.abrupt("return", (n.member_session ? this._subscriptionService.updateStateAndTokens({
|
|
2578
|
+
state: {
|
|
2579
|
+
session: n.member_session,
|
|
2580
|
+
member: n.member
|
|
2581
|
+
},
|
|
2582
|
+
session_token: n.session_token,
|
|
2583
|
+
session_jwt: n.session_jwt,
|
|
2584
|
+
intermediate_session_token: null
|
|
2585
|
+
}) : this._subscriptionService.updateStateAndTokens({
|
|
2586
|
+
state: null,
|
|
2587
|
+
session_token: null,
|
|
2588
|
+
session_jwt: null,
|
|
2589
|
+
intermediate_session_token: n.intermediate_session_token
|
|
2590
|
+
}), n));
|
|
2591
|
+
case 10:
|
|
2592
|
+
case "end":
|
|
2593
|
+
return _context9.stop();
|
|
2594
|
+
}
|
|
2595
|
+
}, _callee9, this);
|
|
2596
|
+
}));
|
|
2597
|
+
}
|
|
2598
|
+
}, {
|
|
2599
|
+
key: "resetBySession",
|
|
2600
|
+
value: function resetBySession(e) {
|
|
2601
|
+
return Ae(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
2602
|
+
var _yield$this$dfpProtec5, t, r, n;
|
|
2603
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
2604
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
2605
|
+
case 0:
|
|
2606
|
+
Oe("stytch.passwords.resetBySession").isString("password", e.password);
|
|
2607
|
+
_context10.next = 3;
|
|
2608
|
+
return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
|
|
2609
|
+
case 3:
|
|
2610
|
+
_yield$this$dfpProtec5 = _context10.sent;
|
|
2611
|
+
t = _yield$this$dfpProtec5.dfp_telemetry_id;
|
|
2612
|
+
r = _yield$this$dfpProtec5.captcha_token;
|
|
2613
|
+
_context10.next = 8;
|
|
2614
|
+
return this._networkClient.retriableFetchSDK({
|
|
2615
|
+
url: "/b2b/passwords/session/reset",
|
|
2616
|
+
method: "POST",
|
|
2617
|
+
errorMessage: "Failed to reset session.",
|
|
2618
|
+
body: {
|
|
2619
|
+
organization_id: e.organization_id,
|
|
2620
|
+
password: e.password,
|
|
2621
|
+
captcha_token: r,
|
|
2622
|
+
dfp_telemetry_id: t
|
|
2623
|
+
},
|
|
2624
|
+
retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
|
|
2625
|
+
});
|
|
2626
|
+
case 8:
|
|
2627
|
+
n = _context10.sent;
|
|
2628
|
+
return _context10.abrupt("return", (this._subscriptionService.updateStateAndTokens({
|
|
2629
|
+
state: {
|
|
2630
|
+
session: n.member_session,
|
|
2631
|
+
member: n.member
|
|
2632
|
+
},
|
|
2633
|
+
session_token: n.session_token,
|
|
2634
|
+
session_jwt: n.session_jwt,
|
|
2635
|
+
intermediate_session_token: null
|
|
2636
|
+
}), n));
|
|
2637
|
+
case 10:
|
|
2638
|
+
case "end":
|
|
2639
|
+
return _context10.stop();
|
|
2640
|
+
}
|
|
2641
|
+
}, _callee10, this);
|
|
2642
|
+
}));
|
|
2643
|
+
}
|
|
2644
|
+
}, {
|
|
2645
|
+
key: "strengthCheck",
|
|
2646
|
+
value: function strengthCheck(e) {
|
|
2647
|
+
return Ae(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
2648
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
2649
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
2650
|
+
case 0:
|
|
2651
|
+
return _context11.abrupt("return", (Oe("stytch.passwords.strengthCheck").isOptionalString("email", e.email_address).isString("password", e.password), this._networkClient.fetchSDK({
|
|
2652
|
+
url: "/b2b/passwords/strength_check",
|
|
2653
|
+
method: "POST",
|
|
2654
|
+
errorMessage: "Failed to check password strength.",
|
|
2655
|
+
body: {
|
|
2656
|
+
email_address: e.email_address,
|
|
2657
|
+
password: e.password
|
|
2658
|
+
}
|
|
2659
|
+
})));
|
|
2660
|
+
case 1:
|
|
2661
|
+
case "end":
|
|
2662
|
+
return _context11.stop();
|
|
2663
|
+
}
|
|
2664
|
+
}, _callee11, this);
|
|
2665
|
+
}));
|
|
2666
|
+
}
|
|
2667
|
+
}]);
|
|
2668
|
+
return Pe;
|
|
2669
|
+
}();
|
|
2670
|
+
var Be = "bootstrap";
|
|
2671
|
+
var xe = /*#__PURE__*/function () {
|
|
2672
|
+
function xe(e, t, r) {
|
|
2673
|
+
var _this2 = this;
|
|
2674
|
+
_classCallCheck(this, xe);
|
|
2675
|
+
this._publicToken = e, this._networkClient = t, this._dataLayer = r, this._bootstrapDataPromise = this._networkClient.fetchSDK({
|
|
2676
|
+
url: "/projects/bootstrap/".concat(this._publicToken),
|
|
2677
|
+
method: "GET",
|
|
2678
|
+
errorMessage: "Error fetching bootstrap data for SDK for ".concat(this._publicToken)
|
|
2679
|
+
}).then(xe.mapBootstrapData).then(function (e) {
|
|
2680
|
+
return _this2._dataLayer.setItem(Be, JSON.stringify(e)), e;
|
|
2681
|
+
})["catch"](function (e) {
|
|
2682
|
+
return J(e), {
|
|
2683
|
+
displayWatermark: !1,
|
|
2684
|
+
cnameDomain: null,
|
|
2685
|
+
emailDomains: ["stytch.com"],
|
|
2686
|
+
captchaSettings: {
|
|
2687
|
+
enabled: !1
|
|
2688
|
+
},
|
|
2689
|
+
pkceRequiredForEmailMagicLinks: !1,
|
|
2690
|
+
pkceRequiredForPasswordResets: !1,
|
|
2691
|
+
pkceRequiredForOAuth: !1,
|
|
2692
|
+
pkceRequiredForSso: !1,
|
|
2693
|
+
slugPattern: null,
|
|
2694
|
+
createOrganizationEnabled: !1,
|
|
2695
|
+
passwordConfig: null,
|
|
2696
|
+
runDFPProtectedAuth: !1
|
|
2697
|
+
};
|
|
2698
|
+
});
|
|
2699
|
+
}
|
|
2700
|
+
_createClass(xe, [{
|
|
2701
|
+
key: "getSync",
|
|
2702
|
+
value: function getSync() {
|
|
2703
|
+
var e = this._dataLayer.getItem(Be);
|
|
2704
|
+
if (null === e) return {
|
|
2705
|
+
displayWatermark: !1,
|
|
2706
|
+
cnameDomain: null,
|
|
2707
|
+
emailDomains: ["stytch.com"],
|
|
2708
|
+
captchaSettings: {
|
|
2709
|
+
enabled: !1
|
|
2710
|
+
},
|
|
2711
|
+
pkceRequiredForEmailMagicLinks: !1,
|
|
2712
|
+
pkceRequiredForPasswordResets: !1,
|
|
2713
|
+
pkceRequiredForOAuth: !1,
|
|
2714
|
+
pkceRequiredForSso: !1,
|
|
2715
|
+
slugPattern: null,
|
|
2716
|
+
createOrganizationEnabled: !1,
|
|
2717
|
+
passwordConfig: null,
|
|
2718
|
+
runDFPProtectedAuth: !1
|
|
2719
|
+
};
|
|
2720
|
+
try {
|
|
2721
|
+
return JSON.parse(e);
|
|
2722
|
+
} catch (e) {
|
|
2723
|
+
return {
|
|
2724
|
+
displayWatermark: !1,
|
|
2725
|
+
cnameDomain: null,
|
|
2726
|
+
emailDomains: ["stytch.com"],
|
|
2727
|
+
captchaSettings: {
|
|
2728
|
+
enabled: !1
|
|
2729
|
+
},
|
|
2730
|
+
pkceRequiredForEmailMagicLinks: !1,
|
|
2731
|
+
pkceRequiredForPasswordResets: !1,
|
|
2732
|
+
pkceRequiredForOAuth: !1,
|
|
2733
|
+
pkceRequiredForSso: !1,
|
|
2734
|
+
slugPattern: null,
|
|
2735
|
+
createOrganizationEnabled: !1,
|
|
2736
|
+
passwordConfig: null,
|
|
2737
|
+
runDFPProtectedAuth: !1
|
|
2738
|
+
};
|
|
2739
|
+
}
|
|
2740
|
+
}
|
|
2741
|
+
}, {
|
|
2742
|
+
key: "getAsync",
|
|
2743
|
+
value: function getAsync() {
|
|
2744
|
+
return this._bootstrapDataPromise;
|
|
2745
|
+
}
|
|
2746
|
+
}], [{
|
|
2747
|
+
key: "mapBootstrapData",
|
|
2748
|
+
value: function mapBootstrapData(e) {
|
|
2749
|
+
var t;
|
|
2750
|
+
var r = null !== e.password_config ? {
|
|
2751
|
+
ludsComplexity: e.password_config.luds_complexity,
|
|
2752
|
+
ludsMinimumCount: e.password_config.luds_minimum_count
|
|
2753
|
+
} : null;
|
|
2754
|
+
return {
|
|
2755
|
+
displayWatermark: !e.disable_sdk_watermark,
|
|
2756
|
+
captchaSettings: e.captcha_settings,
|
|
2757
|
+
cnameDomain: e.cname_domain,
|
|
2758
|
+
emailDomains: e.email_domains,
|
|
2759
|
+
pkceRequiredForEmailMagicLinks: e.pkce_required_for_email_magic_links,
|
|
2760
|
+
pkceRequiredForPasswordResets: e.pkce_required_for_password_resets,
|
|
2761
|
+
pkceRequiredForOAuth: e.pkce_required_for_oauth,
|
|
2762
|
+
pkceRequiredForSso: e.pkce_required_for_sso,
|
|
2763
|
+
slugPattern: e.slug_pattern,
|
|
2764
|
+
createOrganizationEnabled: e.create_organization_enabled,
|
|
2765
|
+
passwordConfig: r,
|
|
2766
|
+
runDFPProtectedAuth: null !== (t = e.dfp_protected_auth_enabled) && void 0 !== t && t,
|
|
2767
|
+
dfpProtectedAuthMode: e.dfp_protected_auth_mode
|
|
2768
|
+
};
|
|
2769
|
+
}
|
|
2770
|
+
}]);
|
|
2771
|
+
return xe;
|
|
2772
|
+
}();
|
|
2773
|
+
var Re = /*#__PURE__*/_createClass(function Re(e) {
|
|
2774
|
+
var _this3 = this;
|
|
2775
|
+
_classCallCheck(this, Re);
|
|
2776
|
+
this.bootstrapPromise = e, this.executeRecaptcha = function () {
|
|
2777
|
+
return Ae(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
2778
|
+
var _yield$this$state, e, t, r;
|
|
2779
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
2780
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
2781
|
+
case 0:
|
|
2782
|
+
_context12.next = 2;
|
|
2783
|
+
return this.state;
|
|
2784
|
+
case 2:
|
|
2785
|
+
_yield$this$state = _context12.sent;
|
|
2786
|
+
e = _yield$this$state.captchaClient;
|
|
2787
|
+
t = _yield$this$state.configured;
|
|
2788
|
+
r = _yield$this$state.siteKey;
|
|
2789
|
+
if (!t) {
|
|
2790
|
+
_context12.next = 10;
|
|
2791
|
+
break;
|
|
2792
|
+
}
|
|
2793
|
+
_context12.next = 9;
|
|
2794
|
+
return new Promise(function (t) {
|
|
2795
|
+
return e.ready(t);
|
|
2796
|
+
});
|
|
2797
|
+
case 9:
|
|
2798
|
+
return _context12.abrupt("return", e.execute(r, {
|
|
2799
|
+
action: "LOGIN"
|
|
2800
|
+
}));
|
|
2801
|
+
case 10:
|
|
2802
|
+
case "end":
|
|
2803
|
+
return _context12.stop();
|
|
2804
|
+
}
|
|
2805
|
+
}, _callee12, this);
|
|
2806
|
+
}));
|
|
2807
|
+
}, this.state = e.then(function (e) {
|
|
2808
|
+
return Ae(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
2809
|
+
var t;
|
|
2810
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
2811
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
2812
|
+
case 0:
|
|
2813
|
+
if (!e.captchaSettings.enabled) {
|
|
2814
|
+
_context13.next = 9;
|
|
2815
|
+
break;
|
|
2816
|
+
}
|
|
2817
|
+
_context13.t1 = !0;
|
|
2818
|
+
_context13.next = 4;
|
|
2819
|
+
return t = e.captchaSettings.siteKey, G("https://www.google.com/recaptcha/enterprise.js?render=".concat(t), function () {
|
|
2820
|
+
return window.grecaptcha.enterprise;
|
|
2821
|
+
});
|
|
2822
|
+
case 4:
|
|
2823
|
+
_context13.t2 = _context13.sent;
|
|
2824
|
+
_context13.t3 = e.captchaSettings.siteKey;
|
|
2825
|
+
_context13.t0 = {
|
|
2826
|
+
configured: _context13.t1,
|
|
2827
|
+
captchaClient: _context13.t2,
|
|
2828
|
+
siteKey: _context13.t3
|
|
2829
|
+
};
|
|
2830
|
+
_context13.next = 10;
|
|
2831
|
+
break;
|
|
2832
|
+
case 9:
|
|
2833
|
+
_context13.t0 = {
|
|
2834
|
+
configured: !1
|
|
2835
|
+
};
|
|
2836
|
+
case 10:
|
|
2837
|
+
return _context13.abrupt("return", _context13.t0);
|
|
2838
|
+
case 11:
|
|
2839
|
+
case "end":
|
|
2840
|
+
return _context13.stop();
|
|
2841
|
+
}
|
|
2842
|
+
}, _callee13);
|
|
2843
|
+
}));
|
|
2844
|
+
});
|
|
2845
|
+
});
|
|
2846
|
+
var Ie = /*#__PURE__*/function () {
|
|
2847
|
+
function Ie(e, t, r, n) {
|
|
2848
|
+
_classCallCheck(this, Ie);
|
|
2849
|
+
this._publicToken = e, this._subscriptionDataLayer = t, this.baseURL = r, this.additionalTelemetryDataFn = n, this.updateSessionToken = function () {
|
|
2850
|
+
return null;
|
|
2851
|
+
}, this.eventLogger = new re({
|
|
2852
|
+
maxBatchSize: 15,
|
|
2853
|
+
intervalDurationMs: 800,
|
|
2854
|
+
logEventURL: this.buildSDKUrl("/events")
|
|
2855
|
+
});
|
|
2856
|
+
}
|
|
2857
|
+
_createClass(Ie, [{
|
|
2858
|
+
key: "logEvent",
|
|
2859
|
+
value: function logEvent(_ref) {
|
|
2860
|
+
var e = _ref.name,
|
|
2861
|
+
t = _ref.details,
|
|
2862
|
+
_ref$error = _ref.error,
|
|
2863
|
+
r = _ref$error === void 0 ? {} : _ref$error;
|
|
2864
|
+
this.eventLogger.logEvent(this.createTelemetryBlob(), {
|
|
2865
|
+
public_token: this._publicToken,
|
|
2866
|
+
event_name: e,
|
|
2867
|
+
details: t,
|
|
2868
|
+
error_code: r.error_code,
|
|
2869
|
+
error_description: r.error_description,
|
|
2870
|
+
http_status_code: r.http_status_code
|
|
2871
|
+
});
|
|
2872
|
+
}
|
|
2873
|
+
}, {
|
|
2874
|
+
key: "createTelemetryBlob",
|
|
2875
|
+
value: function createTelemetryBlob() {
|
|
2876
|
+
return Object.assign(Object.assign({
|
|
2877
|
+
event_id: "event-id-".concat(z()),
|
|
2878
|
+
app_session_id: "app-session-id-".concat(z()),
|
|
2879
|
+
persistent_id: "persistent-id-".concat(z()),
|
|
2880
|
+
client_sent_at: new Date().toISOString(),
|
|
2881
|
+
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
2882
|
+
}, this.additionalTelemetryDataFn()), {
|
|
2883
|
+
app: {
|
|
2884
|
+
identifier: window.location.hostname
|
|
2885
|
+
},
|
|
2886
|
+
sdk: {
|
|
2887
|
+
identifier: "Stytch.js Javascript SDK",
|
|
2888
|
+
version: "3.0.1"
|
|
2889
|
+
}
|
|
2890
|
+
});
|
|
2891
|
+
}
|
|
2892
|
+
}, {
|
|
2893
|
+
key: "fetchSDK",
|
|
2894
|
+
value: function fetchSDK(_ref2) {
|
|
2895
|
+
var e = _ref2.url,
|
|
2896
|
+
t = _ref2.body,
|
|
2897
|
+
r = _ref2.errorMessage,
|
|
2898
|
+
n = _ref2.method;
|
|
2899
|
+
return Ae(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
2900
|
+
var i, o, s, a;
|
|
2901
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
2902
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
2903
|
+
case 0:
|
|
2904
|
+
i = this._subscriptionDataLayer.readSessionCookie().session_token, o = "Basic " + window.btoa(this._publicToken + ":" + (i || this._publicToken)), s = window.btoa(JSON.stringify(this.createTelemetryBlob())), a = window.location.origin;
|
|
2905
|
+
return _context14.abrupt("return", L({
|
|
2906
|
+
basicAuthHeader: o,
|
|
2907
|
+
body: t,
|
|
2908
|
+
errorMessage: r,
|
|
2909
|
+
finalURL: this.buildSDKUrl(e),
|
|
2910
|
+
method: n,
|
|
2911
|
+
xSDKClientHeader: s,
|
|
2912
|
+
xSDKParentHostHeader: a
|
|
2913
|
+
}));
|
|
2914
|
+
case 2:
|
|
2915
|
+
case "end":
|
|
2916
|
+
return _context14.stop();
|
|
2917
|
+
}
|
|
2918
|
+
}, _callee14, this);
|
|
2919
|
+
}));
|
|
2920
|
+
}
|
|
2921
|
+
}, {
|
|
2922
|
+
key: "retriableFetchSDK",
|
|
2923
|
+
value: function retriableFetchSDK(_ref3) {
|
|
2924
|
+
var e = _ref3.url,
|
|
2925
|
+
t = _ref3.body,
|
|
2926
|
+
r = _ref3.errorMessage,
|
|
2927
|
+
n = _ref3.method,
|
|
2928
|
+
o = _ref3.retryCallback;
|
|
2929
|
+
return Ae(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
2930
|
+
var s, a, c, u;
|
|
2931
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
2932
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
2933
|
+
case 0:
|
|
2934
|
+
s = this._subscriptionDataLayer.readSessionCookie().session_token, a = "Basic " + window.btoa(this._publicToken + ":" + (s || this._publicToken)), c = window.btoa(JSON.stringify(this.createTelemetryBlob())), u = window.location.origin;
|
|
2935
|
+
return _context15.abrupt("return", function (e) {
|
|
2936
|
+
var t = e.method,
|
|
2937
|
+
r = e.errorMessage,
|
|
2938
|
+
n = e.finalURL,
|
|
2939
|
+
o = e.basicAuthHeader,
|
|
2940
|
+
s = e.xSDKClientHeader,
|
|
2941
|
+
a = e.xSDKParentHostHeader,
|
|
2942
|
+
c = e.body,
|
|
2943
|
+
u = e.retryCallback;
|
|
2944
|
+
return S(this, void 0, void 0, i().mark(function e() {
|
|
2945
|
+
var l;
|
|
2946
|
+
return i().wrap(function (e) {
|
|
2947
|
+
for (;;) switch (e.prev = e.next) {
|
|
2948
|
+
case 0:
|
|
2949
|
+
return l = {
|
|
2950
|
+
method: t,
|
|
2951
|
+
errorMessage: r,
|
|
2952
|
+
finalURL: n,
|
|
2953
|
+
basicAuthHeader: o,
|
|
2954
|
+
xSDKClientHeader: s,
|
|
2955
|
+
xSDKParentHostHeader: a,
|
|
2956
|
+
body: c
|
|
2957
|
+
}, e.prev = 1, e.next = 4, L(l);
|
|
2958
|
+
case 4:
|
|
2959
|
+
case 15:
|
|
2960
|
+
return e.abrupt("return", e.sent);
|
|
2961
|
+
case 7:
|
|
2962
|
+
if (e.prev = 7, e.t0 = e["catch"](1), !(e.t0 instanceof D)) {
|
|
2963
|
+
e.next = 16;
|
|
2964
|
+
break;
|
|
2965
|
+
}
|
|
2966
|
+
return e.next = 12, u(e.t0, l);
|
|
2967
|
+
case 12:
|
|
2968
|
+
return l = e.sent, e.next = 15, L(l);
|
|
2969
|
+
case 16:
|
|
2970
|
+
throw e.t0;
|
|
2971
|
+
case 17:
|
|
2972
|
+
case "end":
|
|
2973
|
+
return e.stop();
|
|
2974
|
+
}
|
|
2975
|
+
}, e, null, [[1, 7]]);
|
|
2976
|
+
}));
|
|
2977
|
+
}({
|
|
2978
|
+
basicAuthHeader: a,
|
|
2979
|
+
body: t,
|
|
2980
|
+
errorMessage: r,
|
|
2981
|
+
finalURL: this.buildSDKUrl(e),
|
|
2982
|
+
method: n,
|
|
2983
|
+
xSDKClientHeader: c,
|
|
2984
|
+
xSDKParentHostHeader: u,
|
|
2985
|
+
retryCallback: o
|
|
2986
|
+
}));
|
|
2987
|
+
case 2:
|
|
2988
|
+
case "end":
|
|
2989
|
+
return _context15.stop();
|
|
2990
|
+
}
|
|
2991
|
+
}, _callee15, this);
|
|
2992
|
+
}));
|
|
2993
|
+
}
|
|
2994
|
+
}, {
|
|
2995
|
+
key: "buildSDKUrl",
|
|
2996
|
+
value: function buildSDKUrl(e) {
|
|
2997
|
+
return "".concat(this.baseURL, "/sdk/v1").concat(e);
|
|
2998
|
+
}
|
|
2999
|
+
}]);
|
|
3000
|
+
return Ie;
|
|
3001
|
+
}();
|
|
3002
|
+
var De = /*#__PURE__*/function () {
|
|
3003
|
+
function De(e, t) {
|
|
3004
|
+
_classCallCheck(this, De);
|
|
3005
|
+
this._networkClient = e, this._subscriptionService = t;
|
|
3006
|
+
}
|
|
3007
|
+
_createClass(De, [{
|
|
3008
|
+
key: "resetBySession",
|
|
3009
|
+
value: function resetBySession(e) {
|
|
3010
|
+
return Ae(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
3011
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
3012
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
3013
|
+
case 0:
|
|
3014
|
+
Oe("stytch.passwords.resetBySession").isString("password", e.password);
|
|
3015
|
+
_context16.next = 3;
|
|
3016
|
+
return this._networkClient.fetchSDK({
|
|
3017
|
+
url: "/b2b/passwords/session/reset",
|
|
3018
|
+
method: "POST",
|
|
3019
|
+
errorMessage: "Failed to reset session.",
|
|
3020
|
+
body: {
|
|
3021
|
+
organization_id: e.organization_id,
|
|
3022
|
+
password: e.password,
|
|
3023
|
+
session_token: e.session_token
|
|
3024
|
+
}
|
|
3025
|
+
});
|
|
3026
|
+
case 3:
|
|
3027
|
+
return _context16.abrupt("return", _context16.sent);
|
|
3028
|
+
case 4:
|
|
3029
|
+
case "end":
|
|
3030
|
+
return _context16.stop();
|
|
3031
|
+
}
|
|
3032
|
+
}, _callee16, this);
|
|
3033
|
+
}));
|
|
3034
|
+
}
|
|
3035
|
+
}]);
|
|
3036
|
+
return De;
|
|
3037
|
+
}();
|
|
3038
|
+
function Le(e) {
|
|
3039
|
+
var t = e.toString(16);
|
|
3040
|
+
return 1 === t.length && (t = "0" + t), t;
|
|
3041
|
+
}
|
|
3042
|
+
var Me = /*#__PURE__*/function () {
|
|
3043
|
+
function Me(e, t) {
|
|
3044
|
+
_classCallCheck(this, Me);
|
|
3045
|
+
this._dataLayer = e, this.namespace = t;
|
|
3046
|
+
}
|
|
3047
|
+
_createClass(Me, [{
|
|
3048
|
+
key: "key",
|
|
3049
|
+
value: function key() {
|
|
3050
|
+
return "PKCE_VERIFIER:" + this.namespace;
|
|
3051
|
+
}
|
|
3052
|
+
}, {
|
|
3053
|
+
key: "startPKCETransaction",
|
|
3054
|
+
value: function startPKCETransaction() {
|
|
3055
|
+
return Ae(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
3056
|
+
var e;
|
|
3057
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
3058
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
3059
|
+
case 0:
|
|
3060
|
+
_context17.next = 2;
|
|
3061
|
+
return Me.createProofkeyPair();
|
|
3062
|
+
case 2:
|
|
3063
|
+
e = _context17.sent;
|
|
3064
|
+
return _context17.abrupt("return", (this._dataLayer.setItem(this.key(), JSON.stringify(e)), e));
|
|
3065
|
+
case 4:
|
|
3066
|
+
case "end":
|
|
3067
|
+
return _context17.stop();
|
|
3068
|
+
}
|
|
3069
|
+
}, _callee17, this);
|
|
3070
|
+
}));
|
|
3071
|
+
}
|
|
3072
|
+
}, {
|
|
3073
|
+
key: "getPKPair",
|
|
3074
|
+
value: function getPKPair() {
|
|
3075
|
+
var e = this._dataLayer.getItem(this.key());
|
|
3076
|
+
if (null !== e) try {
|
|
3077
|
+
return JSON.parse(e);
|
|
3078
|
+
} catch (e) {
|
|
3079
|
+
return void $("Found malformed Proof Key pair in localstorage.");
|
|
3080
|
+
}
|
|
3081
|
+
}
|
|
3082
|
+
}, {
|
|
3083
|
+
key: "clearPKPair",
|
|
3084
|
+
value: function clearPKPair() {
|
|
3085
|
+
return this._dataLayer.removeItem(this.key());
|
|
3086
|
+
}
|
|
3087
|
+
}], [{
|
|
3088
|
+
key: "createProofkeyPair",
|
|
3089
|
+
value: function createProofkeyPair() {
|
|
3090
|
+
return Ae(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
3091
|
+
var _String$fromCharCode;
|
|
3092
|
+
var e, t, r, n;
|
|
3093
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
3094
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
3095
|
+
case 0:
|
|
3096
|
+
e = new Uint32Array(16);
|
|
3097
|
+
window.crypto.getRandomValues(e);
|
|
3098
|
+
t = Array.from(e).map(Le).join("");
|
|
3099
|
+
_context18.next = 5;
|
|
3100
|
+
return window.crypto.subtle.digest("SHA-256", new TextEncoder().encode(t));
|
|
3101
|
+
case 5:
|
|
3102
|
+
r = _context18.sent;
|
|
3103
|
+
return _context18.abrupt("return", {
|
|
3104
|
+
code_challenge: (n = r, btoa((_String$fromCharCode = String.fromCharCode).call.apply(_String$fromCharCode, [null].concat(_toConsumableArray(new Uint8Array(n))))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "")),
|
|
3105
|
+
code_verifier: t
|
|
3106
|
+
});
|
|
3107
|
+
case 7:
|
|
3108
|
+
case "end":
|
|
3109
|
+
return _context18.stop();
|
|
3110
|
+
}
|
|
3111
|
+
}, _callee18);
|
|
3112
|
+
}));
|
|
3113
|
+
}
|
|
3114
|
+
}]);
|
|
3115
|
+
return Me;
|
|
3116
|
+
}();
|
|
3117
|
+
var Ne = /*#__PURE__*/function () {
|
|
3118
|
+
function Ne(e) {
|
|
3119
|
+
_classCallCheck(this, Ne);
|
|
3120
|
+
this._networkClient = e;
|
|
3121
|
+
}
|
|
3122
|
+
_createClass(Ne, [{
|
|
3123
|
+
key: "searchUser",
|
|
3124
|
+
value: function searchUser(e) {
|
|
3125
|
+
return this._networkClient.fetchSDK({
|
|
3126
|
+
url: "/users/search",
|
|
3127
|
+
method: "POST",
|
|
3128
|
+
body: {
|
|
3129
|
+
email: e
|
|
3130
|
+
},
|
|
3131
|
+
errorMessage: "Error searching for user ".concat(e)
|
|
3132
|
+
});
|
|
3133
|
+
}
|
|
3134
|
+
}, {
|
|
3135
|
+
key: "searchOrganization",
|
|
3136
|
+
value: function searchOrganization(e) {
|
|
3137
|
+
return this._networkClient.fetchSDK({
|
|
3138
|
+
url: "/b2b/organizations/search",
|
|
3139
|
+
method: "POST",
|
|
3140
|
+
body: {
|
|
3141
|
+
organization_slug: e
|
|
3142
|
+
},
|
|
3143
|
+
errorMessage: "Error searching slug"
|
|
3144
|
+
});
|
|
3145
|
+
}
|
|
3146
|
+
}, {
|
|
3147
|
+
key: "searchMember",
|
|
3148
|
+
value: function searchMember(e, t) {
|
|
3149
|
+
return this._networkClient.fetchSDK({
|
|
3150
|
+
url: "/b2b/organizations/members/search",
|
|
3151
|
+
method: "POST",
|
|
3152
|
+
body: {
|
|
3153
|
+
email_address: e,
|
|
3154
|
+
organization_id: t
|
|
3155
|
+
},
|
|
3156
|
+
errorMessage: "Error searching for member ".concat(e)
|
|
3157
|
+
});
|
|
3158
|
+
}
|
|
3159
|
+
}]);
|
|
3160
|
+
return Ne;
|
|
3161
|
+
}();
|
|
3162
|
+
var je = function je(e) {
|
|
3163
|
+
return (document.cookie ? document.cookie.split("; ") : []).filter(function (t) {
|
|
3164
|
+
var _t$split = t.split("="),
|
|
3165
|
+
_t$split2 = _slicedToArray(_t$split, 1),
|
|
3166
|
+
r = _t$split2[0];
|
|
3167
|
+
return e === r;
|
|
3168
|
+
}).length > 1;
|
|
3169
|
+
};
|
|
3170
|
+
/*! js-cookie v3.0.1 | MIT */
|
|
3171
|
+
function Fe(e) {
|
|
3172
|
+
for (var t = 1; t < arguments.length; t++) {
|
|
3173
|
+
var r = arguments[t];
|
|
3174
|
+
for (var n in r) e[n] = r[n];
|
|
3175
|
+
}
|
|
3176
|
+
return e;
|
|
3177
|
+
}
|
|
3178
|
+
var Ke = function e(t, r) {
|
|
3179
|
+
function n(e, n, i) {
|
|
3180
|
+
if ("undefined" != typeof document) {
|
|
3181
|
+
"number" == typeof (i = Fe({}, r, i)).expires && (i.expires = new Date(Date.now() + 864e5 * i.expires)), i.expires && (i.expires = i.expires.toUTCString()), e = encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
|
|
3182
|
+
var o = "";
|
|
3183
|
+
for (var s in i) i[s] && (o += "; " + s, !0 !== i[s] && (o += "=" + i[s].split(";")[0]));
|
|
3184
|
+
return document.cookie = e + "=" + t.write(n, e) + o;
|
|
3185
|
+
}
|
|
3186
|
+
}
|
|
3187
|
+
return Object.create({
|
|
3188
|
+
set: n,
|
|
3189
|
+
get: function get(e) {
|
|
3190
|
+
if ("undefined" != typeof document && (!arguments.length || e)) {
|
|
3191
|
+
for (var r = document.cookie ? document.cookie.split("; ") : [], n = {}, i = 0; i < r.length; i++) {
|
|
3192
|
+
var o = r[i].split("="),
|
|
3193
|
+
s = o.slice(1).join("=");
|
|
3194
|
+
try {
|
|
3195
|
+
var a = decodeURIComponent(o[0]);
|
|
3196
|
+
if (n[a] = t.read(s, a), e === a) break;
|
|
3197
|
+
} catch (e) {}
|
|
3198
|
+
}
|
|
3199
|
+
return e ? n[e] : n;
|
|
3200
|
+
}
|
|
3201
|
+
},
|
|
3202
|
+
remove: function remove(e, t) {
|
|
3203
|
+
n(e, "", Fe({}, t, {
|
|
3204
|
+
expires: -1
|
|
3205
|
+
}));
|
|
3206
|
+
},
|
|
3207
|
+
withAttributes: function withAttributes(t) {
|
|
3208
|
+
return e(this.converter, Fe({}, this.attributes, t));
|
|
3209
|
+
},
|
|
3210
|
+
withConverter: function withConverter(t) {
|
|
3211
|
+
return e(Fe({}, this.converter, t), this.attributes);
|
|
3212
|
+
}
|
|
3213
|
+
}, {
|
|
3214
|
+
attributes: {
|
|
3215
|
+
value: Object.freeze(r)
|
|
3216
|
+
},
|
|
3217
|
+
converter: {
|
|
3218
|
+
value: Object.freeze(t)
|
|
3219
|
+
}
|
|
3220
|
+
});
|
|
3221
|
+
}({
|
|
3222
|
+
read: function read(e) {
|
|
3223
|
+
return '"' === e[0] && (e = e.slice(1, -1)), e.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
|
|
3224
|
+
},
|
|
3225
|
+
write: function write(e) {
|
|
3226
|
+
return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g, decodeURIComponent);
|
|
3227
|
+
}
|
|
3228
|
+
}, {
|
|
3229
|
+
path: "/"
|
|
3230
|
+
});
|
|
3231
|
+
var Ue = function Ue(e) {
|
|
3232
|
+
var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
|
|
3233
|
+
return "stytch_sdk_state_".concat(e).concat(t ? "::".concat(t) : "");
|
|
3234
|
+
};
|
|
3235
|
+
var ze = /*#__PURE__*/function () {
|
|
3236
|
+
function ze(e, t) {
|
|
3237
|
+
var _this4 = this;
|
|
3238
|
+
_classCallCheck(this, ze);
|
|
3239
|
+
this.browserSessionStorage = {
|
|
3240
|
+
getItem: function getItem(e) {
|
|
3241
|
+
return sessionStorage.getItem(Ue(_this4.publicToken, e));
|
|
3242
|
+
},
|
|
3243
|
+
setItem: function setItem(e, t) {
|
|
3244
|
+
return sessionStorage.setItem(Ue(_this4.publicToken, e), t);
|
|
3245
|
+
},
|
|
3246
|
+
removeItem: function removeItem(e) {
|
|
3247
|
+
return sessionStorage.removeItem(Ue(_this4.publicToken, e));
|
|
3248
|
+
}
|
|
3249
|
+
}, this.publicToken = e, this.state = null, this.subscriptions = {}, (null == t ? void 0 : t.cookieOptions) ? (Q("SubscriptionDataLayer").isOptionalString("cookieOptions.opaqueTokenCookieName", t.cookieOptions.opaqueTokenCookieName).isOptionalString("cookieOptions.jwtCookieName", t.cookieOptions.jwtCookieName).isOptionalString("cookieOptions.istCookieName", t.cookieOptions.istCookieName).isOptionalString("cookieOptions.path", t.cookieOptions.path).isOptionalString("cookieOptions.domain", t.cookieOptions.domain), this._jwtCookieName = t.cookieOptions.jwtCookieName || null, this._opaqueTokenCookieName = t.cookieOptions.opaqueTokenCookieName || null, this._cookiePath = t.cookieOptions.path || null, this._domain = t.cookieOptions.domain || null, this._cookieAvailableToSubdomains = t.cookieOptions.availableToSubdomains || !1, this._istCookieName = t.cookieOptions.istCookieName || null) : (this._opaqueTokenCookieName = null, this._jwtCookieName = null, this._cookiePath = null, this._domain = null, this._cookieAvailableToSubdomains = !1, this._istCookieName = null);
|
|
3250
|
+
var r = localStorage.getItem(Ue(this.publicToken));
|
|
3251
|
+
if (!r) return;
|
|
3252
|
+
var n;
|
|
3253
|
+
try {
|
|
3254
|
+
n = JSON.parse(r);
|
|
3255
|
+
} catch (e) {
|
|
3256
|
+
return void this.syncToLocalStorage();
|
|
3257
|
+
}
|
|
3258
|
+
this.state = n;
|
|
3259
|
+
}
|
|
3260
|
+
_createClass(ze, [{
|
|
3261
|
+
key: "opaqueTokenCookieName",
|
|
3262
|
+
get: function get() {
|
|
3263
|
+
var e;
|
|
3264
|
+
return null !== (e = this._opaqueTokenCookieName) && void 0 !== e ? e : "stytch_session";
|
|
3265
|
+
}
|
|
3266
|
+
}, {
|
|
3267
|
+
key: "jwtCookieName",
|
|
3268
|
+
get: function get() {
|
|
3269
|
+
var e;
|
|
3270
|
+
return null !== (e = this._jwtCookieName) && void 0 !== e ? e : "stytch_session_jwt";
|
|
3271
|
+
}
|
|
3272
|
+
}, {
|
|
3273
|
+
key: "istCookieName",
|
|
3274
|
+
get: function get() {
|
|
3275
|
+
var e;
|
|
3276
|
+
return null !== (e = this._istCookieName) && void 0 !== e ? e : "stytch_intermediate_session_token";
|
|
3277
|
+
}
|
|
3278
|
+
}, {
|
|
3279
|
+
key: "readSessionCookie",
|
|
3280
|
+
value: function readSessionCookie() {
|
|
3281
|
+
return {
|
|
3282
|
+
session_token: Ke.get(this.opaqueTokenCookieName),
|
|
3283
|
+
session_jwt: Ke.get(this.jwtCookieName)
|
|
3284
|
+
};
|
|
3285
|
+
}
|
|
3286
|
+
}, {
|
|
3287
|
+
key: "readIntermediateSessionTokenCookie",
|
|
3288
|
+
value: function readIntermediateSessionTokenCookie() {
|
|
3289
|
+
return Ke.get(this.istCookieName);
|
|
3290
|
+
}
|
|
3291
|
+
}, {
|
|
3292
|
+
key: "writeSessionCookie",
|
|
3293
|
+
value: function writeSessionCookie(e) {
|
|
3294
|
+
var t, r, n, i;
|
|
3295
|
+
var o = e.state,
|
|
3296
|
+
s = e.session_token,
|
|
3297
|
+
a = e.session_jwt,
|
|
3298
|
+
c = ze.generateCookieOpts({
|
|
3299
|
+
expiresAt: null !== (r = null === (t = null == o ? void 0 : o.session) || void 0 === t ? void 0 : t.expires_at) && void 0 !== r ? r : "",
|
|
3300
|
+
availableToSubdomains: this._cookieAvailableToSubdomains,
|
|
3301
|
+
path: this._cookiePath,
|
|
3302
|
+
domain: this._domain
|
|
3303
|
+
});
|
|
3304
|
+
Ke.set(this.opaqueTokenCookieName, s, c), Ke.set(this.jwtCookieName, a, c);
|
|
3305
|
+
var u = ze.generateCookieOpts({
|
|
3306
|
+
expiresAt: null !== (i = null === (n = null == o ? void 0 : o.session) || void 0 === n ? void 0 : n.expires_at) && void 0 !== i ? i : "",
|
|
3307
|
+
availableToSubdomains: !this._cookieAvailableToSubdomains,
|
|
3308
|
+
path: this._cookiePath,
|
|
3309
|
+
domain: this._domain
|
|
3310
|
+
});
|
|
3311
|
+
je(this.jwtCookieName) && Ke.remove(this.jwtCookieName, u), je(this.opaqueTokenCookieName) && Ke.remove(this.opaqueTokenCookieName, u), je(this.jwtCookieName) && $("Could not remove extraneous JWT cookie. This might happen if the cookie has been set using multiple `path` settings, and may produce unwanted behavior."), je(this.opaqueTokenCookieName) && $("Could not remove extraneous opaque token cookie.");
|
|
3312
|
+
}
|
|
3313
|
+
}, {
|
|
3314
|
+
key: "writeIntermediateSessionTokenCookie",
|
|
3315
|
+
value: function writeIntermediateSessionTokenCookie(e) {
|
|
3316
|
+
var t = new Date(Date.now() + 6e5),
|
|
3317
|
+
r = ze.generateCookieOpts({
|
|
3318
|
+
expiresAt: t.toString(),
|
|
3319
|
+
availableToSubdomains: this._cookieAvailableToSubdomains,
|
|
3320
|
+
path: this._cookiePath,
|
|
3321
|
+
domain: this._domain
|
|
3322
|
+
});
|
|
3323
|
+
Ke.set(this.istCookieName, e, r);
|
|
3324
|
+
}
|
|
3325
|
+
}, {
|
|
3326
|
+
key: "removeSessionCookie",
|
|
3327
|
+
value: function removeSessionCookie() {
|
|
3328
|
+
this.removeCookies([this.opaqueTokenCookieName, this.jwtCookieName]);
|
|
3329
|
+
}
|
|
3330
|
+
}, {
|
|
3331
|
+
key: "removeISTCookie",
|
|
3332
|
+
value: function removeISTCookie() {
|
|
3333
|
+
this.removeCookies([this.istCookieName]);
|
|
3334
|
+
}
|
|
3335
|
+
}, {
|
|
3336
|
+
key: "removeCookies",
|
|
3337
|
+
value: function removeCookies(e) {
|
|
3338
|
+
var _this5 = this;
|
|
3339
|
+
[!0, !1].forEach(function (t) {
|
|
3340
|
+
[_this5._cookiePath, null].forEach(function (r) {
|
|
3341
|
+
[_this5._domain, null].forEach(function (n) {
|
|
3342
|
+
var i = ze.generateCookieOpts({
|
|
3343
|
+
expiresAt: new Date(0).toString(),
|
|
3344
|
+
availableToSubdomains: t,
|
|
3345
|
+
path: r,
|
|
3346
|
+
domain: n
|
|
3347
|
+
});
|
|
3348
|
+
e.forEach(function (e) {
|
|
3349
|
+
Ke.remove(e, i);
|
|
3350
|
+
});
|
|
3351
|
+
});
|
|
3352
|
+
});
|
|
3353
|
+
});
|
|
3354
|
+
}
|
|
3355
|
+
}, {
|
|
3356
|
+
key: "syncToLocalStorage",
|
|
3357
|
+
value: function syncToLocalStorage() {
|
|
3358
|
+
localStorage.setItem(Ue(this.publicToken), JSON.stringify(this.state));
|
|
3359
|
+
}
|
|
3360
|
+
}, {
|
|
3361
|
+
key: "getItem",
|
|
3362
|
+
value: function getItem(e) {
|
|
3363
|
+
return localStorage.getItem(Ue(this.publicToken, e));
|
|
3364
|
+
}
|
|
3365
|
+
}, {
|
|
3366
|
+
key: "setItem",
|
|
3367
|
+
value: function setItem(e, t) {
|
|
3368
|
+
return localStorage.setItem(Ue(this.publicToken, e), t);
|
|
3369
|
+
}
|
|
3370
|
+
}, {
|
|
3371
|
+
key: "removeItem",
|
|
3372
|
+
value: function removeItem(e) {
|
|
3373
|
+
return localStorage.removeItem(Ue(this.publicToken, e));
|
|
3374
|
+
}
|
|
3375
|
+
}], [{
|
|
3376
|
+
key: "generateCookieOpts",
|
|
3377
|
+
value: function generateCookieOpts(_ref4) {
|
|
3378
|
+
var e = _ref4.path,
|
|
3379
|
+
t = _ref4.domain,
|
|
3380
|
+
r = _ref4.availableToSubdomains,
|
|
3381
|
+
n = _ref4.expiresAt;
|
|
3382
|
+
var i = {
|
|
3383
|
+
expires: new Date(n),
|
|
3384
|
+
sameSite: "lax"
|
|
3385
|
+
};
|
|
3386
|
+
return e && (i.path = e), Boolean("localhost" === window.location.hostname || "[::1]" === window.location.hostname || window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/)) ? i.secure = !1 : (r && (i.domain = t || window.location.host), i.secure = !0), i;
|
|
3387
|
+
}
|
|
3388
|
+
}]);
|
|
3389
|
+
return ze;
|
|
3390
|
+
}();
|
|
3391
|
+
var We = /*#__PURE__*/function (_ze) {
|
|
3392
|
+
_inherits(We, _ze);
|
|
3393
|
+
var _super2 = _createSuper(We);
|
|
3394
|
+
function We() {
|
|
3395
|
+
_classCallCheck(this, We);
|
|
3396
|
+
return _super2.apply(this, arguments);
|
|
3397
|
+
}
|
|
3398
|
+
return _createClass(We);
|
|
3399
|
+
}(ze);
|
|
3400
|
+
var Ge = Symbol["for"]("__stytch_b2b_DataLayer"),
|
|
3401
|
+
He = function He(e, t) {
|
|
3402
|
+
var r = function () {
|
|
3403
|
+
var e = window;
|
|
3404
|
+
return e[Ge] || (e[Ge] = {}), e[Ge];
|
|
3405
|
+
}();
|
|
3406
|
+
return r[e] || (r[e] = new We(e, t)), r[e];
|
|
3407
|
+
},
|
|
3408
|
+
qe = function qe(e, t) {
|
|
3409
|
+
Object.values(e).forEach(function (e) {
|
|
3410
|
+
return e(t);
|
|
3411
|
+
});
|
|
3412
|
+
},
|
|
3413
|
+
Ye = function () {
|
|
3414
|
+
var t = (arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}).KEYS_TO_EXCLUDE,
|
|
3415
|
+
r = void 0 === t ? [] : t;
|
|
3416
|
+
return function t(i, o) {
|
|
3417
|
+
return n(i) === n(o) && (null === i || null === o ? i === o : "object" === n(i) ? Object.keys(i).length === Object.keys(o).length && !Object.keys(i).some(function (e) {
|
|
3418
|
+
return !(e in o);
|
|
3419
|
+
}) && Object.entries(i).filter(function (t) {
|
|
3420
|
+
var n = e(t, 1)[0];
|
|
3421
|
+
return !r.includes(n);
|
|
3422
|
+
}).every(function (r) {
|
|
3423
|
+
var n = e(r, 2),
|
|
3424
|
+
i = n[0],
|
|
3425
|
+
s = n[1];
|
|
3426
|
+
return t(s, o[i]);
|
|
3427
|
+
}) : i === o);
|
|
3428
|
+
};
|
|
3429
|
+
}({
|
|
3430
|
+
KEYS_TO_EXCLUDE: ["last_accessed_at"]
|
|
3431
|
+
});
|
|
3432
|
+
var Ve = /*#__PURE__*/function () {
|
|
3433
|
+
function Ve(e, t) {
|
|
3434
|
+
var _this6 = this;
|
|
3435
|
+
_classCallCheck(this, Ve);
|
|
3436
|
+
this._publicToken = e, this._datalayer = t, this._listen = function (e) {
|
|
3437
|
+
if (e.key !== Ue(_this6._publicToken)) return;
|
|
3438
|
+
if (null === e.newValue || "null" === e.newValue) return void _this6.destroyState();
|
|
3439
|
+
var t = JSON.parse(e.newValue);
|
|
3440
|
+
_this6.updateState(t);
|
|
3441
|
+
}, window.addEventListener("storage", this._listen);
|
|
3442
|
+
var _this$_datalayer$read = this._datalayer.readSessionCookie(),
|
|
3443
|
+
r = _this$_datalayer$read.session_token;
|
|
3444
|
+
r || this.destroyState();
|
|
3445
|
+
}
|
|
3446
|
+
_createClass(Ve, [{
|
|
3447
|
+
key: "getTokens",
|
|
3448
|
+
value: function getTokens() {
|
|
3449
|
+
var _this$_datalayer$read2 = this._datalayer.readSessionCookie(),
|
|
3450
|
+
e = _this$_datalayer$read2.session_token,
|
|
3451
|
+
t = _this$_datalayer$read2.session_jwt;
|
|
3452
|
+
return "string" != typeof e || "string" != typeof t ? null : {
|
|
3453
|
+
session_token: e,
|
|
3454
|
+
session_jwt: t
|
|
3455
|
+
};
|
|
3456
|
+
}
|
|
3457
|
+
}, {
|
|
3458
|
+
key: "getIntermediateSessionToken",
|
|
3459
|
+
value: function getIntermediateSessionToken() {
|
|
3460
|
+
return this._datalayer.readIntermediateSessionTokenCookie() || null;
|
|
3461
|
+
}
|
|
3462
|
+
}, {
|
|
3463
|
+
key: "destroyState",
|
|
3464
|
+
value: function destroyState() {
|
|
3465
|
+
this.updateStateAndTokens({
|
|
3466
|
+
state: null,
|
|
3467
|
+
session_token: null,
|
|
3468
|
+
session_jwt: null,
|
|
3469
|
+
intermediate_session_token: null
|
|
3470
|
+
});
|
|
3471
|
+
}
|
|
3472
|
+
}, {
|
|
3473
|
+
key: "_updateStateAndTokensInternal",
|
|
3474
|
+
value: function _updateStateAndTokensInternal(e) {
|
|
3475
|
+
var t = this._datalayer.state,
|
|
3476
|
+
r = null === e.state ? null : Object.assign(Object.assign({}, this._datalayer.state), e.state);
|
|
3477
|
+
this._datalayer.state = r, Ye(t, r) || qe(this._datalayer.subscriptions, r);
|
|
3478
|
+
}
|
|
3479
|
+
}, {
|
|
3480
|
+
key: "updateStateAndTokens",
|
|
3481
|
+
value: function updateStateAndTokens(e) {
|
|
3482
|
+
e.state ? (this._datalayer.writeSessionCookie(e), this._datalayer.removeISTCookie()) : e.intermediate_session_token ? (this._datalayer.writeIntermediateSessionTokenCookie(e.intermediate_session_token), this._datalayer.removeSessionCookie()) : (this._datalayer.removeSessionCookie(), this._datalayer.removeISTCookie()), this._updateStateAndTokensInternal(e), this._datalayer.syncToLocalStorage();
|
|
3483
|
+
}
|
|
3484
|
+
}, {
|
|
3485
|
+
key: "updateState",
|
|
3486
|
+
value: function updateState(e) {
|
|
3487
|
+
var t = this._datalayer.state,
|
|
3488
|
+
r = null === e ? null : Object.assign(Object.assign({}, this._datalayer.state), e);
|
|
3489
|
+
this._datalayer.state = r, Ye(t, r) || (qe(this._datalayer.subscriptions, r), this._datalayer.syncToLocalStorage());
|
|
3490
|
+
}
|
|
3491
|
+
}, {
|
|
3492
|
+
key: "updateTokens",
|
|
3493
|
+
value: function updateTokens(e) {
|
|
3494
|
+
var t = e.session_token,
|
|
3495
|
+
r = e.session_jwt,
|
|
3496
|
+
n = this._datalayer.readSessionCookie(),
|
|
3497
|
+
i = Object.assign(Object.assign({}, n), {
|
|
3498
|
+
session_token: t,
|
|
3499
|
+
session_jwt: r
|
|
3500
|
+
});
|
|
3501
|
+
t || r ? (this._datalayer.writeSessionCookie(i), this._datalayer.removeISTCookie()) : this._datalayer.removeSessionCookie();
|
|
3502
|
+
}
|
|
3503
|
+
}, {
|
|
3504
|
+
key: "subscribeToState",
|
|
3505
|
+
value: function subscribeToState(e) {
|
|
3506
|
+
return function (e, t) {
|
|
3507
|
+
var r = Math.random().toString(36).slice(-10);
|
|
3508
|
+
return e[r] = t, function () {
|
|
3509
|
+
return delete e[r];
|
|
3510
|
+
};
|
|
3511
|
+
}(this._datalayer.subscriptions, e);
|
|
3512
|
+
}
|
|
3513
|
+
}, {
|
|
3514
|
+
key: "getState",
|
|
3515
|
+
value: function getState() {
|
|
3516
|
+
return this._datalayer.state;
|
|
3517
|
+
}
|
|
3518
|
+
}, {
|
|
3519
|
+
key: "destroy",
|
|
3520
|
+
value: function destroy() {
|
|
3521
|
+
window.removeEventListener("storage", this._listen);
|
|
3522
|
+
}
|
|
3523
|
+
}, {
|
|
3524
|
+
key: "syncFromDeviceStorage",
|
|
3525
|
+
value: function syncFromDeviceStorage() {
|
|
3526
|
+
return null;
|
|
3527
|
+
}
|
|
3528
|
+
}]);
|
|
3529
|
+
return Ve;
|
|
3530
|
+
}();
|
|
3531
|
+
var $e = /*#__PURE__*/function (_Ve) {
|
|
3532
|
+
_inherits($e, _Ve);
|
|
3533
|
+
var _super3 = _createSuper($e);
|
|
3534
|
+
function $e() {
|
|
3535
|
+
var _this7;
|
|
3536
|
+
_classCallCheck(this, $e);
|
|
3537
|
+
_this7 = _super3.apply(this, arguments), _this7.updateMember = function (e) {
|
|
3538
|
+
return _this7.updateState({
|
|
3539
|
+
member: e
|
|
3540
|
+
});
|
|
3541
|
+
}, _this7.getMember = function () {
|
|
3542
|
+
var e, t;
|
|
3543
|
+
return null !== (t = null === (e = _this7.getState()) || void 0 === e ? void 0 : e.member) && void 0 !== t ? t : null;
|
|
3544
|
+
}, _this7.getSession = function () {
|
|
3545
|
+
var e, t;
|
|
3546
|
+
return null !== (t = null === (e = _this7.getState()) || void 0 === e ? void 0 : e.session) && void 0 !== t ? t : null;
|
|
3547
|
+
};
|
|
3548
|
+
return _this7;
|
|
3549
|
+
}
|
|
3550
|
+
return _createClass($e);
|
|
3551
|
+
}(Ve);
|
|
3552
|
+
var Je = Symbol["for"]("stytch__internal_b2b");
|
|
3553
|
+
var Xe = /*#__PURE__*/_createClass(function Xe(e, t) {
|
|
3554
|
+
var _this8 = this;
|
|
3555
|
+
_classCallCheck(this, Xe);
|
|
3556
|
+
var r;
|
|
3557
|
+
!function (e) {
|
|
3558
|
+
if ("undefined" == typeof window) throw new Error("The ".concat(e, " is not compatible with server-side environments.\nIf using nextjs, use the create").concat(e, " method instead.\n```\n").concat("import { createStytchB2BHeadlessClient } from '@stytch/nextjs/b2b';\n \n const stytch = createStytchB2BHeadlessClient('public-token-...');\n ", "\n```\n"));
|
|
3559
|
+
}("StytchB2BHeadlessClient"), "string" != typeof (r = e) ? $("Public token is malformed. Expected a string, got ".concat(n(r), ".").concat(X)) : "" === r ? $('Public token is malformed. Expected "public-token-...", got an empty string.'.concat(X)) : r.startsWith("public-token-") || $('Public token is malformed. Expected "public-token-...", got '.concat(r, ".").concat(X));
|
|
3560
|
+
var i = t,
|
|
3561
|
+
o = {
|
|
3562
|
+
cookieOptions: null == (s = i) ? void 0 : s.cookieOptions,
|
|
3563
|
+
endpoints: {
|
|
3564
|
+
sdkBackendURL: null !== (c = null === (a = null == s ? void 0 : s.endpoints) || void 0 === a ? void 0 : a.sdkBackendURL) && void 0 !== c ? c : "https://web.stytch.com",
|
|
3565
|
+
testAPIURL: null !== (l = null === (u = null == s ? void 0 : s.endpoints) || void 0 === u ? void 0 : u.testAPIURL) && void 0 !== l ? l : "https://test.stytch.com",
|
|
3566
|
+
liveAPIURL: null !== (h = null === (d = null == s ? void 0 : s.endpoints) || void 0 === d ? void 0 : d.liveAPIURL) && void 0 !== h ? h : "https://api.stytch.com",
|
|
3567
|
+
dfpBackendURL: null !== (p = null === (_ = null == s ? void 0 : s.endpoints) || void 0 === _ ? void 0 : _.dfpBackendURL) && void 0 !== p ? p : "https://telemetry.stytch.com",
|
|
3568
|
+
clientsideServicesIframeURL: null !== (f = null === (m = null == s ? void 0 : s.endpoints) || void 0 === m ? void 0 : m.clientsideServicesIframeURL) && void 0 !== f ? f : "https://js.stytch.com/clientside-services/index.html"
|
|
3569
|
+
}
|
|
3570
|
+
};
|
|
3571
|
+
var s, a, c, u, l, d, h, _, p, m, f;
|
|
3572
|
+
this._dataLayer = He(e, i), this._subscriptionService = new $e(e, this._dataLayer);
|
|
3573
|
+
var v = new Me(this._dataLayer, "passwords");
|
|
3574
|
+
this._networkClient = new Ie(e, this._dataLayer, o.endpoints.sdkBackendURL, function () {
|
|
3575
|
+
var e, t, r, n;
|
|
3576
|
+
return {
|
|
3577
|
+
stytch_member_id: null === (t = null === (e = _this8._dataLayer.state) || void 0 === e ? void 0 : e.member) || void 0 === t ? void 0 : t.member_id,
|
|
3578
|
+
stytch_member_session_id: null === (n = null === (r = _this8._dataLayer.state) || void 0 === r ? void 0 : r.session) || void 0 === n ? void 0 : n.member_session_id
|
|
3579
|
+
};
|
|
3580
|
+
});
|
|
3581
|
+
var b = new xe(e, this._networkClient, this._dataLayer),
|
|
3582
|
+
g = new Re(b.getAsync()),
|
|
3583
|
+
y = new ee(e, o.endpoints.dfpBackendURL, b.getAsync(), g.executeRecaptcha),
|
|
3584
|
+
k = new De(this._networkClient, this._subscriptionService);
|
|
3585
|
+
this.organization = new ae(this._networkClient), this.member = new oe(this._networkClient, this._subscriptionService), this.session = new ue(this._networkClient, this._subscriptionService), this.magicLinks = new ie(this._networkClient, this._subscriptionService, new Me(this._dataLayer, "magic_links"), v, b.getAsync(), y), this.oauth = new ce(this._networkClient, this._subscriptionService, new Me(this._dataLayer, "oauth"), b.getAsync(), {
|
|
3586
|
+
publicToken: e,
|
|
3587
|
+
testAPIURL: o.endpoints.testAPIURL,
|
|
3588
|
+
liveAPIURL: o.endpoints.liveAPIURL
|
|
3589
|
+
}, y), this.sso = new se(this._networkClient, this._subscriptionService, new Me(this._dataLayer, "sso"), b.getAsync(), {
|
|
3590
|
+
publicToken: e,
|
|
3591
|
+
testAPIURL: o.endpoints.testAPIURL,
|
|
3592
|
+
liveAPIURL: o.endpoints.liveAPIURL
|
|
3593
|
+
}), this.discovery = new le(this._networkClient, this._subscriptionService), this.passwords = new Pe(this._networkClient, this._subscriptionService, v, b.getAsync(), y), this.otps = new Se(this._networkClient, this._subscriptionService, y), this._sessionManager = new we(this._subscriptionService, this.session);
|
|
3594
|
+
var S = new Ne(this._networkClient);
|
|
3595
|
+
this._dataLayer.readSessionCookie().session_token && this._sessionManager.performBackgroundRefresh(), this._networkClient.logEvent({
|
|
3596
|
+
name: "b2b_sdk_instance_instantiated",
|
|
3597
|
+
details: {
|
|
3598
|
+
event_callback_registered: !1,
|
|
3599
|
+
error_callback_registered: !1,
|
|
3600
|
+
success_callback_registered: !1
|
|
3601
|
+
}
|
|
3602
|
+
});
|
|
3603
|
+
(function (e, t) {
|
|
3604
|
+
Object.assign(e, _defineProperty({}, Je, t));
|
|
3605
|
+
})(this, {
|
|
3606
|
+
bootstrap: b,
|
|
3607
|
+
publicToken: e,
|
|
3608
|
+
searchManager: S,
|
|
3609
|
+
passwordResetClient: k,
|
|
3610
|
+
dataLayer: this._dataLayer,
|
|
3611
|
+
networkClient: this._networkClient
|
|
3612
|
+
});
|
|
3613
|
+
});
|
|
3614
|
+
function Ze(e) {
|
|
3615
|
+
return Ze = "function" == typeof Symbol && "symbol" == _typeof(Symbol.iterator) ? function (e) {
|
|
3616
|
+
return _typeof(e);
|
|
3617
|
+
} : function (e) {
|
|
3618
|
+
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : _typeof(e);
|
|
3619
|
+
}, Ze(e);
|
|
3620
|
+
}
|
|
3621
|
+
function Qe(e, t) {
|
|
3622
|
+
for (var r = 0; r < t.length; r++) {
|
|
3623
|
+
var n = t[r];
|
|
3624
|
+
n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(e, (i = n.key, o = void 0, o = function (e, t) {
|
|
3625
|
+
if ("object" !== Ze(e) || null === e) return e;
|
|
3626
|
+
var r = e[Symbol.toPrimitive];
|
|
3627
|
+
if (void 0 !== r) {
|
|
3628
|
+
var n = r.call(e, t || "default");
|
|
3629
|
+
if ("object" !== Ze(n)) return n;
|
|
3630
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
3631
|
+
}
|
|
3632
|
+
return ("string" === t ? String : Number)(e);
|
|
3633
|
+
}(i, "string"), "symbol" === Ze(o) ? o : String(o)), n);
|
|
3634
|
+
}
|
|
3635
|
+
var i, o;
|
|
3636
|
+
}
|
|
3637
|
+
function et(e, t, r) {
|
|
3638
|
+
return t && Qe(e.prototype, t), r && Qe(e, r), Object.defineProperty(e, "prototype", {
|
|
3639
|
+
writable: !1
|
|
3640
|
+
}), e;
|
|
3641
|
+
}
|
|
3642
|
+
function tt(e, t) {
|
|
3643
|
+
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
|
|
3644
|
+
}
|
|
3645
|
+
function rt(e, t) {
|
|
3646
|
+
if ("function" != typeof t && null !== t) throw new TypeError("Super expression must either be null or a function");
|
|
3647
|
+
e.prototype = Object.create(t && t.prototype, {
|
|
3648
|
+
constructor: {
|
|
3649
|
+
value: e,
|
|
3650
|
+
writable: !0,
|
|
3651
|
+
configurable: !0
|
|
3652
|
+
}
|
|
3653
|
+
}), Object.defineProperty(e, "prototype", {
|
|
3654
|
+
writable: !1
|
|
3655
|
+
}), t && ct(e, t);
|
|
3656
|
+
}
|
|
3657
|
+
function nt(e) {
|
|
3658
|
+
var t = at();
|
|
3659
|
+
return function () {
|
|
3660
|
+
var r,
|
|
3661
|
+
n = ut(e);
|
|
3662
|
+
if (t) {
|
|
3663
|
+
var i = ut(this).constructor;
|
|
3664
|
+
r = Reflect.construct(n, arguments, i);
|
|
3665
|
+
} else r = n.apply(this, arguments);
|
|
3666
|
+
return function (e, t) {
|
|
3667
|
+
if (t && ("object" === Ze(t) || "function" == typeof t)) return t;
|
|
3668
|
+
if (void 0 !== t) throw new TypeError("Derived constructors may only return object or undefined");
|
|
3669
|
+
return it(e);
|
|
3670
|
+
}(this, r);
|
|
3671
|
+
};
|
|
3672
|
+
}
|
|
3673
|
+
function it(e) {
|
|
3674
|
+
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
3675
|
+
return e;
|
|
3676
|
+
}
|
|
3677
|
+
function ot(e) {
|
|
3678
|
+
var t = "function" == typeof Map ? new Map() : void 0;
|
|
3679
|
+
return ot = function ot(e) {
|
|
3680
|
+
if (null === e || (r = e, -1 === Function.toString.call(r).indexOf("[native code]"))) return e;
|
|
3681
|
+
var r;
|
|
3682
|
+
if ("function" != typeof e) throw new TypeError("Super expression must either be null or a function");
|
|
3683
|
+
if (void 0 !== t) {
|
|
3684
|
+
if (t.has(e)) return t.get(e);
|
|
3685
|
+
t.set(e, n);
|
|
3686
|
+
}
|
|
3687
|
+
function n() {
|
|
3688
|
+
return st(e, arguments, ut(this).constructor);
|
|
3689
|
+
}
|
|
3690
|
+
return n.prototype = Object.create(e.prototype, {
|
|
3691
|
+
constructor: {
|
|
3692
|
+
value: n,
|
|
3693
|
+
enumerable: !1,
|
|
3694
|
+
writable: !0,
|
|
3695
|
+
configurable: !0
|
|
3696
|
+
}
|
|
3697
|
+
}), ct(n, e);
|
|
3698
|
+
}, ot(e);
|
|
3699
|
+
}
|
|
3700
|
+
function st(e, t, r) {
|
|
3701
|
+
return st = at() ? Reflect.construct.bind() : function (e, t, r) {
|
|
3702
|
+
var n = [null];
|
|
3703
|
+
n.push.apply(n, t);
|
|
3704
|
+
var i = new (Function.bind.apply(e, n))();
|
|
3705
|
+
return r && ct(i, r.prototype), i;
|
|
3706
|
+
}, st.apply(null, arguments);
|
|
3707
|
+
}
|
|
3708
|
+
function at() {
|
|
3709
|
+
if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
|
|
3710
|
+
if (Reflect.construct.sham) return !1;
|
|
3711
|
+
if ("function" == typeof Proxy) return !0;
|
|
3712
|
+
try {
|
|
3713
|
+
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})), !0;
|
|
3714
|
+
} catch (e) {
|
|
3715
|
+
return !1;
|
|
3716
|
+
}
|
|
3717
|
+
}
|
|
3718
|
+
function ct(e, t) {
|
|
3719
|
+
return ct = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (e, t) {
|
|
3720
|
+
return e.__proto__ = t, e;
|
|
3721
|
+
}, ct(e, t);
|
|
3722
|
+
}
|
|
3723
|
+
function ut(e) {
|
|
3724
|
+
return ut = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (e) {
|
|
3725
|
+
return e.__proto__ || Object.getPrototypeOf(e);
|
|
3726
|
+
}, ut(e);
|
|
3727
|
+
}
|
|
3728
|
+
var lt, dt, ht, _t, pt, mt;
|
|
3729
|
+
!function (e) {
|
|
3730
|
+
e.emailMagicLinks = "emailMagicLinks", e.oauth = "oauth", e.otp = "otp", e.crypto = "crypto", e.passwords = "passwords";
|
|
3731
|
+
}(lt || (lt = {})), function (e) {
|
|
3732
|
+
e.Google = "google", e.Microsoft = "microsoft", e.Apple = "apple", e.Github = "github", e.GitLab = "gitlab", e.Facebook = "facebook", e.Discord = "discord", e.Salesforce = "salesforce", e.Slack = "slack", e.Amazon = "amazon", e.Bitbucket = "bitbucket", e.LinkedIn = "linkedin", e.Coinbase = "coinbase", e.Twitch = "twitch", e.Twitter = "twitter", e.TikTok = "tiktok", e.Snapchat = "snapchat", e.Figma = "figma", e.Yahoo = "yahoo";
|
|
3733
|
+
}(dt || (dt = {})), function (e) {
|
|
3734
|
+
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";
|
|
3735
|
+
}(ht || (ht = {})), function (e) {
|
|
3736
|
+
e.embedded = "embedded", e.floating = "floating";
|
|
3737
|
+
}(_t || (_t = {})), function (e) {
|
|
3738
|
+
e.SMS = "sms", e.WhatsApp = "whatsapp", e.Email = "email";
|
|
3739
|
+
}(pt || (pt = {})), function (e) {
|
|
3740
|
+
e.MagicLinkLoginOrCreateEvent = "MAGIC_LINK_LOGIN_OR_CREATE", e.OTPsLoginOrCreateEvent = "OTP_LOGIN_OR_CREATE", e.OTPsAuthenticate = "OTP_AUTHENTICATE", e.CryptoWalletAuthenticateStart = "CRYPTO_WALLET_AUTHENTICATE_START", e.CryptoWalletAuthenticate = "CRYPTO_WALLET_AUTHENTICATE", e.PasswordCreate = "PASSWORD_CREATE", e.PasswordAuthenticate = "PASSWORD_AUTHENTICATE", e.PasswordResetByEmailStart = "PASSWORD_RESET_BY_EMAIL_START", e.PasswordResetByEmail = "PASSWORD_RESET_BY_EMAIL", e.B2BMagicLinkEmailLoginOrSignup = "B2B_MAGIC_LINK_EMAIL_LOGIN_OR_SIGNUP", e.B2BMagicLinkAuthenticate = "B2B_MAGIC_LINK_AUTHENTICATE", e.B2BMagicLinkEmailDiscoverySend = "B2B_MAGIC_LINK_EMAIL_DISCOVERY_SEND", e.B2BMagicLinkDiscoveryAuthenticate = "B2B_MAGIC_LINK_DISCOVERY_AUTHENTICATE", e.B2BSSOStart = "B2B_SSO_START", e.B2BSSOAuthenticate = "B2B_SSO_AUTHENTICATE", e.B2BOAuthAuthenticate = "B2B_SSO_AUTHENTICATE", e.B2BOAuthDiscoveryAuthenticate = "B2B_OAUTH_DISCOVERY_AUTHENTICATE", e.B2BDiscoveryOrganizationsCreate = "B2B_DISCOVERY_ORGANIZATIONS_CREATE", e.B2BDiscoveryIntermediateSessionExchange = "B2B_DISCOVERY_INTERMEDIATE_SESSION_EXCHANGE", e.B2BPasswordAuthenticate = "B2B_PASSWORD_AUTHENTICATE", e.B2BPasswordResetByEmailStart = "B2B_PASSWORD_RESET_BY_EMAIL_START", e.B2BPasswordResetByEmail = "B2B_PASSWORD_RESET_BY_EMAIL", e.B2BPasswordResetBySession = "B2B_PASSWORD_RESET_BY_SESSION";
|
|
3741
|
+
}(mt || (mt = {}));
|
|
3742
|
+
var ft,
|
|
3743
|
+
vt,
|
|
3744
|
+
bt,
|
|
3745
|
+
gt,
|
|
3746
|
+
yt = function (e) {
|
|
3747
|
+
rt(r, ot(Error));
|
|
3748
|
+
var t = nt(r);
|
|
3749
|
+
function r(e, n) {
|
|
3750
|
+
var i;
|
|
3751
|
+
return tt(this, r), (i = t.call(this, e + "\n" + n)).message = e + "\n" + n, i.name = "SDKAPIUnreachableError", i.details = n, Object.setPrototypeOf(it(i), r.prototype), i;
|
|
3752
|
+
}
|
|
3753
|
+
return et(r);
|
|
3754
|
+
}(),
|
|
3755
|
+
kt = function (e) {
|
|
3756
|
+
rt(r, ot(Error));
|
|
3757
|
+
var t = nt(r);
|
|
3758
|
+
function r(e, n) {
|
|
3759
|
+
var i;
|
|
3760
|
+
return tt(this, r), (i = t.call(this)).name = "StytchSDKUsageError", i.message = "Invalid call to ".concat(e, "\n") + n, i;
|
|
3761
|
+
}
|
|
3762
|
+
return et(r);
|
|
3763
|
+
}(),
|
|
3764
|
+
St = function (e) {
|
|
3765
|
+
rt(r, ot(Error));
|
|
3766
|
+
var t = nt(r);
|
|
3767
|
+
function r(e) {
|
|
3768
|
+
var n, i;
|
|
3769
|
+
tt(this, r), (n = t.call(this)).name = "StytchSDKSchemaError";
|
|
3770
|
+
var o = null === (i = e.body) || void 0 === i ? void 0 : i.map(function (e) {
|
|
3771
|
+
return "".concat(e.dataPath, ": ").concat(e.message);
|
|
3772
|
+
}).join("\n");
|
|
3773
|
+
return n.message = "[400] Request does not match expected schema\n".concat(o), n;
|
|
3774
|
+
}
|
|
3775
|
+
return et(r);
|
|
3776
|
+
}(),
|
|
3777
|
+
wt = function (e) {
|
|
3778
|
+
rt(r, ot(Error));
|
|
3779
|
+
var t = nt(r);
|
|
3780
|
+
function r(e) {
|
|
3781
|
+
var n;
|
|
3782
|
+
tt(this, r), (n = t.call(this)).name = "StytchSDKAPIError";
|
|
3783
|
+
var i = e.status_code,
|
|
3784
|
+
o = e.error_type,
|
|
3785
|
+
s = e.error_message,
|
|
3786
|
+
a = e.error_url,
|
|
3787
|
+
c = e.request_id;
|
|
3788
|
+
return n.error_type = o, n.error_message = s, n.error_url = a, n.request_id = c, n.status_code = i, n.message = "[".concat(i, "] ").concat(o, "\n") + "".concat(s, "\n") + "See ".concat(a, " for more information.\n") + (c ? "request_id: ".concat(c, "\n") : ""), n;
|
|
3789
|
+
}
|
|
3790
|
+
return et(r);
|
|
3791
|
+
}(),
|
|
3792
|
+
At = function (e) {
|
|
3793
|
+
rt(r, ot(Error));
|
|
3794
|
+
var t = nt(r);
|
|
3795
|
+
function r(e) {
|
|
3796
|
+
var n;
|
|
3797
|
+
return tt(this, r), (n = t.call(this)).name = "StytchSDKNativeError", n.error_type = e, n.message = "".concat(e), n;
|
|
3798
|
+
}
|
|
3799
|
+
return et(r);
|
|
3800
|
+
}(),
|
|
3801
|
+
Tt = ["unauthorized_credentials", "user_unauthenticated", "invalid_secret_authentication", "session_not_found"];
|
|
3802
|
+
!function (e) {
|
|
3803
|
+
e.BiometricsSensorError = "biometrics_sensor_error", e.DeviceCredentialsNotAllowed = "device_credentials_not_allowed", e.DeviceHardwareError = "device_hardware_error", e.InternalError = "internal_error", e.KeyInvalidated = "key_invalidated", e.KeystoreUnavailable = "keystore_unavailable", e.NoBiometricsEnrolled = "no_biometrics_enrolled", e.NoBiometricsRegistration = "no_biometrics_registration", e.SessionExpired = "session_expired", e.UserCancellation = "user_cancellation", e.UserLockedOut = "user_locked_out", e.BiometricsNotAvailable = "biometrics_not_available";
|
|
3804
|
+
}(ft || (ft = {})), function (e) {
|
|
3805
|
+
e.emailMagicLinks = "emailMagicLinks", e.sso = "sso", e.passwords = "passwords", e.oauth = "oauth";
|
|
3806
|
+
}(vt || (vt = {})), function (e) {
|
|
3807
|
+
e.Discovery = "Discovery", e.Organization = "Organization", e.PasswordReset = "PasswordReset";
|
|
3808
|
+
}(bt || (bt = {})), function (e) {
|
|
3809
|
+
e.Google = "google", e.Microsoft = "microsoft";
|
|
3810
|
+
}(gt || (gt = {}));
|
|
3811
|
+
export { bt as AuthFlowType, gt as B2BOAuthProviders, vt as B2BProducts, ft as BiometricsErrors, dt as OAuthProviders, pt as OTPMethods, _t as OneTapPositions, lt as Products, yt as SDKAPIUnreachableError, Xe as StytchB2BHeadlessClient, mt as StytchEventType, wt as StytchSDKAPIError, At as StytchSDKNativeError, St as StytchSDKSchemaError, kt as StytchSDKUsageError, Tt as UNRECOVERABLE_ERROR_TYPES, ht as Wallets };
|