@stytch/vanilla-js 5.6.0 → 5.6.2
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 +16 -0
- package/dist/adminPortal/index.esm.js +1 -1
- package/dist/adminPortal/index.js +1 -1
- package/dist/b2b/index.esm.js +40 -45
- package/dist/b2b/index.headless.esm.js +108 -71
- package/dist/b2b/index.headless.js +107 -70
- package/dist/b2b/index.js +39 -44
- package/dist/{extractErrorMessage-LV5bs3zG.js → extractErrorMessage-Ddemk2Gq.js} +1 -1
- package/dist/{extractErrorMessage-C2EAqH1L.js → extractErrorMessage-DqI8LnhU.js} +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.headless.esm.js +107 -70
- package/dist/index.headless.js +107 -70
- package/dist/index.js +1 -1
- package/dist/{internal-B_-Y0eVO.js → internal-8PFEtDRF.js} +296 -127
- package/dist/{internal-BwQxoPJh.js → internal-B_3PRrIX.js} +296 -127
- package/dist/ui/b2b/GlobalContextProvider.d.ts +2 -1
- package/package.json +2 -2
|
@@ -26,7 +26,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
26
26
|
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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
27
27
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
28
28
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
29
|
-
var internal = require('../internal-
|
|
29
|
+
var internal = require('../internal-8PFEtDRF.js');
|
|
30
30
|
var DisabledDFPProtectedAuthProvider = function DisabledDFPProtectedAuthProvider() {
|
|
31
31
|
return {
|
|
32
32
|
isEnabled: function () {
|
|
@@ -612,37 +612,58 @@ function init(converter, defaultAttributes) {
|
|
|
612
612
|
var api = init(defaultConverter, {
|
|
613
613
|
path: '/'
|
|
614
614
|
});
|
|
615
|
-
var cookieVerificationTimeouts = new Map();
|
|
616
|
-
var cancelCookieRestoration = function cancelCookieRestoration(name) {
|
|
617
|
-
clearTimeout(cookieVerificationTimeouts.get(name));
|
|
618
|
-
};
|
|
619
|
-
var setCookiePersistently = function setCookiePersistently(name, value, options) {
|
|
620
|
-
var COOKIE_VERIFY_DELAY_MS = 10;
|
|
621
|
-
cancelCookieRestoration(name);
|
|
622
|
-
var timeoutId = setTimeout(function () {
|
|
623
|
-
if (api.get(name) === undefined) {
|
|
624
|
-
api.set(name, value, options);
|
|
625
|
-
}
|
|
626
|
-
}, COOKIE_VERIFY_DELAY_MS);
|
|
627
|
-
cookieVerificationTimeouts.set(name, timeoutId);
|
|
628
|
-
return api.set(name, value, options);
|
|
629
|
-
};
|
|
630
615
|
var STYTCH_SESSION_COOKIE = 'stytch_session';
|
|
631
616
|
var STYTCH_SESSION_JWT_COOKIE = 'stytch_session_jwt';
|
|
632
617
|
var STYTCH_INTERMEDIATE_SESSION_TOKEN_COOKIE = 'stytch_intermediate_session_token';
|
|
618
|
+
var isStorageAvailable = function isStorageAvailable(storage) {
|
|
619
|
+
return typeof storage !== 'undefined' && storage !== null;
|
|
620
|
+
};
|
|
621
|
+
var safeStorageOperation = function safeStorageOperation(storage) {
|
|
622
|
+
return function (_ref6) {
|
|
623
|
+
var operation = _ref6.operation,
|
|
624
|
+
key = _ref6.key,
|
|
625
|
+
value = _ref6.value;
|
|
626
|
+
if (!storage || !isStorageAvailable(storage)) return null;
|
|
627
|
+
try {
|
|
628
|
+
switch (operation) {
|
|
629
|
+
case 'get':
|
|
630
|
+
return storage.getItem(key);
|
|
631
|
+
case 'set':
|
|
632
|
+
if (value) storage.setItem(key, value);
|
|
633
|
+
break;
|
|
634
|
+
case 'remove':
|
|
635
|
+
storage.removeItem(key);
|
|
636
|
+
break;
|
|
637
|
+
}
|
|
638
|
+
} catch (err) {}
|
|
639
|
+
return null;
|
|
640
|
+
};
|
|
641
|
+
};
|
|
642
|
+
var safeLocalStorageOperation = safeStorageOperation(typeof window !== 'undefined' ? window.localStorage : undefined);
|
|
643
|
+
var safeSessionStorageOperation = safeStorageOperation(typeof window !== 'undefined' ? window.sessionStorage : undefined);
|
|
633
644
|
var SubscriptionDataLayer = /*#__PURE__*/function () {
|
|
634
645
|
function SubscriptionDataLayer(publicToken, options) {
|
|
635
646
|
var _this5 = this;
|
|
636
647
|
_classCallCheck(this, SubscriptionDataLayer);
|
|
637
648
|
this.browserSessionStorage = {
|
|
638
649
|
getItem: function getItem(key) {
|
|
639
|
-
return
|
|
650
|
+
return safeSessionStorageOperation({
|
|
651
|
+
operation: 'get',
|
|
652
|
+
key: internal.getPersistentStorageKey(_this5.publicToken, key)
|
|
653
|
+
});
|
|
640
654
|
},
|
|
641
655
|
setItem: function setItem(key, value) {
|
|
642
|
-
|
|
656
|
+
safeSessionStorageOperation({
|
|
657
|
+
operation: 'set',
|
|
658
|
+
key: internal.getPersistentStorageKey(_this5.publicToken, key),
|
|
659
|
+
value: value
|
|
660
|
+
});
|
|
643
661
|
},
|
|
644
662
|
removeItem: function removeItem(key) {
|
|
645
|
-
|
|
663
|
+
safeSessionStorageOperation({
|
|
664
|
+
operation: 'remove',
|
|
665
|
+
key: internal.getPersistentStorageKey(_this5.publicToken, key)
|
|
666
|
+
});
|
|
646
667
|
}
|
|
647
668
|
};
|
|
648
669
|
this.publicToken = publicToken;
|
|
@@ -665,7 +686,10 @@ var SubscriptionDataLayer = /*#__PURE__*/function () {
|
|
|
665
686
|
this._cookieAvailableToSubdomains = false;
|
|
666
687
|
this._istCookieName = null;
|
|
667
688
|
}
|
|
668
|
-
var localStorageState =
|
|
689
|
+
var localStorageState = safeLocalStorageOperation({
|
|
690
|
+
operation: 'get',
|
|
691
|
+
key: internal.getPersistentStorageKey(this.publicToken)
|
|
692
|
+
});
|
|
669
693
|
if (!localStorageState) {
|
|
670
694
|
return;
|
|
671
695
|
}
|
|
@@ -722,8 +746,8 @@ var SubscriptionDataLayer = /*#__PURE__*/function () {
|
|
|
722
746
|
path: this._cookiePath,
|
|
723
747
|
domain: this._domain
|
|
724
748
|
});
|
|
725
|
-
|
|
726
|
-
|
|
749
|
+
api.set(this.opaqueTokenCookieName, session_token, cookieOpts);
|
|
750
|
+
api.set(this.jwtCookieName, session_jwt, cookieOpts);
|
|
727
751
|
var alternateCookieOptions = SubscriptionDataLayer.generateCookieOpts({
|
|
728
752
|
expiresAt: (_d = (_c = state === null || state === void 0 ? void 0 : state.session) === null || _c === void 0 ? void 0 : _c.expires_at) !== null && _d !== void 0 ? _d : '',
|
|
729
753
|
availableToSubdomains: !this._cookieAvailableToSubdomains,
|
|
@@ -753,7 +777,7 @@ var SubscriptionDataLayer = /*#__PURE__*/function () {
|
|
|
753
777
|
path: this._cookiePath,
|
|
754
778
|
domain: this._domain
|
|
755
779
|
});
|
|
756
|
-
|
|
780
|
+
api.set(this.istCookieName, IST, cookieOpts);
|
|
757
781
|
}
|
|
758
782
|
}, {
|
|
759
783
|
key: "removeSessionCookie",
|
|
@@ -784,35 +808,48 @@ var SubscriptionDataLayer = /*#__PURE__*/function () {
|
|
|
784
808
|
});
|
|
785
809
|
});
|
|
786
810
|
});
|
|
787
|
-
cookiesToRemove.forEach(cancelCookieRestoration);
|
|
788
811
|
}
|
|
789
812
|
}, {
|
|
790
813
|
key: "syncToLocalStorage",
|
|
791
814
|
value: function syncToLocalStorage() {
|
|
792
|
-
|
|
815
|
+
safeLocalStorageOperation({
|
|
816
|
+
operation: 'set',
|
|
817
|
+
key: internal.getPersistentStorageKey(this.publicToken),
|
|
818
|
+
value: JSON.stringify(this.state)
|
|
819
|
+
});
|
|
793
820
|
}
|
|
794
821
|
}, {
|
|
795
822
|
key: "getItem",
|
|
796
823
|
value: function getItem(key) {
|
|
797
|
-
return
|
|
824
|
+
return safeLocalStorageOperation({
|
|
825
|
+
operation: 'get',
|
|
826
|
+
key: internal.getPersistentStorageKey(this.publicToken, key)
|
|
827
|
+
});
|
|
798
828
|
}
|
|
799
829
|
}, {
|
|
800
830
|
key: "setItem",
|
|
801
831
|
value: function setItem(key, value) {
|
|
802
|
-
|
|
832
|
+
safeLocalStorageOperation({
|
|
833
|
+
operation: 'set',
|
|
834
|
+
key: internal.getPersistentStorageKey(this.publicToken, key),
|
|
835
|
+
value: value
|
|
836
|
+
});
|
|
803
837
|
}
|
|
804
838
|
}, {
|
|
805
839
|
key: "removeItem",
|
|
806
840
|
value: function removeItem(key) {
|
|
807
|
-
|
|
841
|
+
safeLocalStorageOperation({
|
|
842
|
+
operation: 'remove',
|
|
843
|
+
key: internal.getPersistentStorageKey(this.publicToken, key)
|
|
844
|
+
});
|
|
808
845
|
}
|
|
809
846
|
}], [{
|
|
810
847
|
key: "generateCookieOpts",
|
|
811
|
-
value: function generateCookieOpts(
|
|
812
|
-
var path =
|
|
813
|
-
domain =
|
|
814
|
-
availableToSubdomains =
|
|
815
|
-
expiresAt =
|
|
848
|
+
value: function generateCookieOpts(_ref7) {
|
|
849
|
+
var path = _ref7.path,
|
|
850
|
+
domain = _ref7.domain,
|
|
851
|
+
availableToSubdomains = _ref7.availableToSubdomains,
|
|
852
|
+
expiresAt = _ref7.expiresAt;
|
|
816
853
|
var cookieOpts = {
|
|
817
854
|
expires: new Date(expiresAt),
|
|
818
855
|
sameSite: 'lax'
|
|
@@ -1082,10 +1119,10 @@ var GoogleOneTapClient = /*#__PURE__*/function () {
|
|
|
1082
1119
|
}
|
|
1083
1120
|
}, {
|
|
1084
1121
|
key: "render",
|
|
1085
|
-
value: function render(
|
|
1086
|
-
var callback =
|
|
1087
|
-
onOneTapCancelled =
|
|
1088
|
-
style =
|
|
1122
|
+
value: function render(_ref8) {
|
|
1123
|
+
var callback = _ref8.callback,
|
|
1124
|
+
onOneTapCancelled = _ref8.onOneTapCancelled,
|
|
1125
|
+
style = _ref8.style;
|
|
1089
1126
|
return internal.__awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
1090
1127
|
var _this9 = this;
|
|
1091
1128
|
var embeddedMode, shouldRenderEmbeddedOneTap, config;
|
|
@@ -1172,10 +1209,10 @@ var B2BOneTapProvider = /*#__PURE__*/function () {
|
|
|
1172
1209
|
this._networkClient = _networkClient;
|
|
1173
1210
|
this._pkceManager = _pkceManager;
|
|
1174
1211
|
this._config = _config;
|
|
1175
|
-
this.createOnDiscoverySuccessHandler = function (
|
|
1176
|
-
var discoveryRedirectUrl =
|
|
1177
|
-
onSuccess =
|
|
1178
|
-
onError =
|
|
1212
|
+
this.createOnDiscoverySuccessHandler = function (_ref9) {
|
|
1213
|
+
var discoveryRedirectUrl = _ref9.discoveryRedirectUrl,
|
|
1214
|
+
onSuccess = _ref9.onSuccess,
|
|
1215
|
+
onError = _ref9.onError;
|
|
1179
1216
|
return function (response) {
|
|
1180
1217
|
return internal.__awaiter(_this10, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
1181
1218
|
var credential, submitPromise;
|
|
@@ -1204,12 +1241,12 @@ var B2BOneTapProvider = /*#__PURE__*/function () {
|
|
|
1204
1241
|
}));
|
|
1205
1242
|
};
|
|
1206
1243
|
};
|
|
1207
|
-
this.createOnSuccessHandler = function (
|
|
1208
|
-
var organizationId =
|
|
1209
|
-
signupRedirectUrl =
|
|
1210
|
-
loginRedirectUrl =
|
|
1211
|
-
onSuccess =
|
|
1212
|
-
onError =
|
|
1244
|
+
this.createOnSuccessHandler = function (_ref10) {
|
|
1245
|
+
var organizationId = _ref10.organizationId,
|
|
1246
|
+
signupRedirectUrl = _ref10.signupRedirectUrl,
|
|
1247
|
+
loginRedirectUrl = _ref10.loginRedirectUrl,
|
|
1248
|
+
onSuccess = _ref10.onSuccess,
|
|
1249
|
+
onError = _ref10.onError;
|
|
1213
1250
|
return function (response) {
|
|
1214
1251
|
return internal.__awaiter(_this10, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
1215
1252
|
var credential, submitPromise;
|
|
@@ -1276,9 +1313,9 @@ var B2BOneTapProvider = /*#__PURE__*/function () {
|
|
|
1276
1313
|
}
|
|
1277
1314
|
}, {
|
|
1278
1315
|
key: "submitGoogleOneTapTokenDiscovery",
|
|
1279
|
-
value: function submitGoogleOneTapTokenDiscovery(
|
|
1280
|
-
var credential =
|
|
1281
|
-
discoveryRedirectUrl =
|
|
1316
|
+
value: function submitGoogleOneTapTokenDiscovery(_ref11) {
|
|
1317
|
+
var credential = _ref11.credential,
|
|
1318
|
+
discoveryRedirectUrl = _ref11.discoveryRedirectUrl;
|
|
1282
1319
|
return internal.__awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
1283
1320
|
var codeChallenge, _yield$this$_config, pkceRequiredForOAuth, keyPair;
|
|
1284
1321
|
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
@@ -1325,11 +1362,11 @@ var B2BOneTapProvider = /*#__PURE__*/function () {
|
|
|
1325
1362
|
}
|
|
1326
1363
|
}, {
|
|
1327
1364
|
key: "submitGoogleOneTapToken",
|
|
1328
|
-
value: function submitGoogleOneTapToken(
|
|
1329
|
-
var credential =
|
|
1330
|
-
organizationId =
|
|
1331
|
-
signupRedirectUrl =
|
|
1332
|
-
loginRedirectUrl =
|
|
1365
|
+
value: function submitGoogleOneTapToken(_ref12) {
|
|
1366
|
+
var credential = _ref12.credential,
|
|
1367
|
+
organizationId = _ref12.organizationId,
|
|
1368
|
+
signupRedirectUrl = _ref12.signupRedirectUrl,
|
|
1369
|
+
loginRedirectUrl = _ref12.loginRedirectUrl;
|
|
1333
1370
|
return internal.__awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
1334
1371
|
var codeChallenge, _yield$this$_config2, pkceRequiredForOAuth, keyPair;
|
|
1335
1372
|
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
@@ -1430,7 +1467,7 @@ var B2BOneTapProvider = /*#__PURE__*/function () {
|
|
|
1430
1467
|
}]);
|
|
1431
1468
|
return B2BOneTapProvider;
|
|
1432
1469
|
}();
|
|
1433
|
-
var version = "5.6.
|
|
1470
|
+
var version = "5.6.2";
|
|
1434
1471
|
var NetworkClient = /*#__PURE__*/function () {
|
|
1435
1472
|
function NetworkClient(_publicToken, _subscriptionDataLayer, _liveAPIURL, _testAPIURL, additionalTelemetryDataFn) {
|
|
1436
1473
|
_classCallCheck(this, NetworkClient);
|
|
@@ -1452,11 +1489,11 @@ var NetworkClient = /*#__PURE__*/function () {
|
|
|
1452
1489
|
}
|
|
1453
1490
|
_createClass(NetworkClient, [{
|
|
1454
1491
|
key: "logEvent",
|
|
1455
|
-
value: function logEvent(
|
|
1456
|
-
var name =
|
|
1457
|
-
details =
|
|
1458
|
-
|
|
1459
|
-
error =
|
|
1492
|
+
value: function logEvent(_ref13) {
|
|
1493
|
+
var name = _ref13.name,
|
|
1494
|
+
details = _ref13.details,
|
|
1495
|
+
_ref13$error = _ref13.error,
|
|
1496
|
+
error = _ref13$error === void 0 ? {} : _ref13$error;
|
|
1460
1497
|
this.eventLogger.logEvent(this.createTelemetryBlob(), {
|
|
1461
1498
|
public_token: this._publicToken,
|
|
1462
1499
|
event_name: name,
|
|
@@ -1487,10 +1524,10 @@ var NetworkClient = /*#__PURE__*/function () {
|
|
|
1487
1524
|
}
|
|
1488
1525
|
}, {
|
|
1489
1526
|
key: "fetchSDK",
|
|
1490
|
-
value: function fetchSDK(
|
|
1491
|
-
var url =
|
|
1492
|
-
body =
|
|
1493
|
-
method =
|
|
1527
|
+
value: function fetchSDK(_ref14) {
|
|
1528
|
+
var url = _ref14.url,
|
|
1529
|
+
body = _ref14.body,
|
|
1530
|
+
method = _ref14.method;
|
|
1494
1531
|
return internal.__awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
1495
1532
|
var sessionToken, basicAuthHeader, xSDKClientHeader, xSDKParentHostHeader;
|
|
1496
1533
|
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
@@ -1517,11 +1554,11 @@ var NetworkClient = /*#__PURE__*/function () {
|
|
|
1517
1554
|
}
|
|
1518
1555
|
}, {
|
|
1519
1556
|
key: "retriableFetchSDK",
|
|
1520
|
-
value: function retriableFetchSDK(
|
|
1521
|
-
var url =
|
|
1522
|
-
body =
|
|
1523
|
-
method =
|
|
1524
|
-
retryCallback =
|
|
1557
|
+
value: function retriableFetchSDK(_ref15) {
|
|
1558
|
+
var url = _ref15.url,
|
|
1559
|
+
body = _ref15.body,
|
|
1560
|
+
method = _ref15.method,
|
|
1561
|
+
retryCallback = _ref15.retryCallback;
|
|
1525
1562
|
return internal.__awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
1526
1563
|
var sessionToken, basicAuthHeader, xSDKClientHeader, xSDKParentHostHeader;
|
|
1527
1564
|
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
package/dist/b2b/index.js
CHANGED
|
@@ -32,8 +32,8 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
32
32
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
33
33
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
34
34
|
var b2b_index_headless = require('./index.headless.js');
|
|
35
|
-
var extractErrorMessage = require('../extractErrorMessage-
|
|
36
|
-
var internal = require('../internal-
|
|
35
|
+
var extractErrorMessage = require('../extractErrorMessage-DqI8LnhU.js');
|
|
36
|
+
var internal = require('../internal-8PFEtDRF.js');
|
|
37
37
|
var DEFAULT_MFA_STATE = {
|
|
38
38
|
primaryInfo: null,
|
|
39
39
|
isEnrolling: false,
|
|
@@ -459,6 +459,7 @@ var ErrorType;
|
|
|
459
459
|
ErrorType[ErrorType["EmailMagicLink"] = 1] = "EmailMagicLink";
|
|
460
460
|
ErrorType[ErrorType["Organization"] = 2] = "Organization";
|
|
461
461
|
ErrorType[ErrorType["CannotJoinOrgDueToAuthPolicy"] = 3] = "CannotJoinOrgDueToAuthPolicy";
|
|
462
|
+
ErrorType[ErrorType["AdBlockerDetected"] = 4] = "AdBlockerDetected";
|
|
462
463
|
})(ErrorType || (ErrorType = {}));
|
|
463
464
|
var DEFAULT_STATE = {
|
|
464
465
|
screen: AppScreens$1.Main,
|
|
@@ -1501,7 +1502,7 @@ var ErrorScreen = function ErrorScreen() {
|
|
|
1501
1502
|
_useGlobalReducer2 = _slicedToArray(_useGlobalReducer, 1),
|
|
1502
1503
|
state = _useGlobalReducer2[0];
|
|
1503
1504
|
var currentErrorType = state.errorType;
|
|
1504
|
-
var ErrorTypeMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ErrorType.Default, 'Something went wrong. Try again later or contact your admin for help.'), ErrorType.EmailMagicLink, 'Something went wrong. Your login link may have expired, been revoked, or been used more than once. Request a new login link to try again, or contact your admin for help.'), ErrorType.Organization, 'The organization you are looking for could not be found. If you think this is a mistake, contact your admin.'), ErrorType.CannotJoinOrgDueToAuthPolicy, "Unable to join due to ".concat((_b = (_a = state.flowState.organization) === null || _a === void 0 ? void 0 : _a.organization_name) !== null && _b !== void 0 ? _b : 'the organization', "'s authentication policy. Please contact your admin for more information."));
|
|
1505
|
+
var ErrorTypeMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ErrorType.Default, 'Something went wrong. Try again later or contact your admin for help.'), ErrorType.EmailMagicLink, 'Something went wrong. Your login link may have expired, been revoked, or been used more than once. Request a new login link to try again, or contact your admin for help.'), ErrorType.Organization, 'The organization you are looking for could not be found. If you think this is a mistake, contact your admin.'), ErrorType.CannotJoinOrgDueToAuthPolicy, "Unable to join due to ".concat((_b = (_a = state.flowState.organization) === null || _a === void 0 ? void 0 : _a.organization_name) !== null && _b !== void 0 ? _b : 'the organization', "'s authentication policy. Please contact your admin for more information.")), ErrorType.AdBlockerDetected, 'The request was blocked by an Ad Blocker. Please disable your ad blocker, refresh the page, and try again.');
|
|
1505
1506
|
return /*#__PURE__*/extractErrorMessage.wn.createElement(Flex, {
|
|
1506
1507
|
direction: "column",
|
|
1507
1508
|
gap: 24,
|
|
@@ -5828,81 +5829,75 @@ var AppContainer$1 = function AppContainer$1() {
|
|
|
5828
5829
|
intermediateSessionToken: data.intermediate_session_token
|
|
5829
5830
|
});
|
|
5830
5831
|
};
|
|
5831
|
-
var
|
|
5832
|
-
|
|
5833
|
-
|
|
5832
|
+
var handleStytchAPIError = function handleStytchAPIError(defaultErrorType) {
|
|
5833
|
+
return function (error) {
|
|
5834
|
+
var error_type = extractErrorType(error);
|
|
5835
|
+
var errorTypeMap = {
|
|
5836
|
+
ad_blocker_detected: ErrorType.AdBlockerDetected
|
|
5837
|
+
};
|
|
5838
|
+
var errorType = error_type && errorTypeMap[error_type] ? errorTypeMap[error_type] : defaultErrorType !== null && defaultErrorType !== void 0 ? defaultErrorType : ErrorType.Default;
|
|
5834
5839
|
clearStytchSearchParams();
|
|
5835
5840
|
dispatch({
|
|
5836
5841
|
type: 'set_error_message_and_transition',
|
|
5837
|
-
errorType: errorType
|
|
5842
|
+
errorType: errorType
|
|
5838
5843
|
});
|
|
5839
5844
|
};
|
|
5840
5845
|
};
|
|
5841
|
-
var _useMutate13 = useMutate("stytch.magicLinks.authenticate", function (_,
|
|
5842
|
-
var token =
|
|
5846
|
+
var _useMutate13 = useMutate("stytch.magicLinks.authenticate", function (_, _ref123) {
|
|
5847
|
+
var token = _ref123.arg.token;
|
|
5843
5848
|
return stytchClient.magicLinks.authenticate({
|
|
5844
5849
|
magic_links_token: token,
|
|
5845
5850
|
session_duration_minutes: config.sessionOptions.sessionDurationMinutes
|
|
5846
5851
|
});
|
|
5847
5852
|
}, {
|
|
5848
5853
|
onSuccess: onSuccess,
|
|
5849
|
-
onError:
|
|
5850
|
-
errorType: ErrorType.EmailMagicLink
|
|
5851
|
-
})
|
|
5854
|
+
onError: handleStytchAPIError(ErrorType.EmailMagicLink)
|
|
5852
5855
|
}),
|
|
5853
5856
|
stytchMagicLinkAuthenticate = _useMutate13.trigger,
|
|
5854
5857
|
isMagicLinkLoading = _useMutate13.isMutating;
|
|
5855
|
-
var _useMutate14 = useMutate("stytch.oauth.authenticate", function (_,
|
|
5856
|
-
var token =
|
|
5858
|
+
var _useMutate14 = useMutate("stytch.oauth.authenticate", function (_, _ref124) {
|
|
5859
|
+
var token = _ref124.arg.token;
|
|
5857
5860
|
return stytchClient.oauth.authenticate({
|
|
5858
5861
|
oauth_token: token,
|
|
5859
5862
|
session_duration_minutes: config.sessionOptions.sessionDurationMinutes
|
|
5860
5863
|
});
|
|
5861
5864
|
}, {
|
|
5862
5865
|
onSuccess: onSuccess,
|
|
5863
|
-
onError:
|
|
5864
|
-
errorType: null
|
|
5865
|
-
})
|
|
5866
|
+
onError: handleStytchAPIError()
|
|
5866
5867
|
}),
|
|
5867
5868
|
stytchOAuthAuthenticate = _useMutate14.trigger,
|
|
5868
5869
|
isOAuthLoading = _useMutate14.isMutating;
|
|
5869
|
-
var _useMutate15 = useMutate("stytch.oauth.discovery.authenticate", function (_,
|
|
5870
|
-
var token =
|
|
5870
|
+
var _useMutate15 = useMutate("stytch.oauth.discovery.authenticate", function (_, _ref125) {
|
|
5871
|
+
var token = _ref125.arg.token;
|
|
5871
5872
|
return stytchClient.oauth.discovery.authenticate({
|
|
5872
5873
|
discovery_oauth_token: token
|
|
5873
5874
|
});
|
|
5874
5875
|
}, {
|
|
5875
5876
|
onSuccess: onDiscoverySuccess,
|
|
5876
|
-
onError:
|
|
5877
|
-
errorType: null
|
|
5878
|
-
})
|
|
5877
|
+
onError: handleStytchAPIError()
|
|
5879
5878
|
}),
|
|
5880
5879
|
stytchOAuthDiscoveryAuthenticate = _useMutate15.trigger,
|
|
5881
5880
|
isDiscoveryOAuthLoading = _useMutate15.isMutating;
|
|
5882
|
-
var _useMutate16 = useMutate("stytch.sso.authenticate", function (_,
|
|
5883
|
-
var token =
|
|
5881
|
+
var _useMutate16 = useMutate("stytch.sso.authenticate", function (_, _ref126) {
|
|
5882
|
+
var token = _ref126.arg.token;
|
|
5884
5883
|
return stytchClient.sso.authenticate({
|
|
5885
5884
|
sso_token: token,
|
|
5886
5885
|
session_duration_minutes: config.sessionOptions.sessionDurationMinutes
|
|
5887
5886
|
});
|
|
5888
5887
|
}, {
|
|
5889
5888
|
onSuccess: onSuccess,
|
|
5890
|
-
onError:
|
|
5891
|
-
errorType: null
|
|
5892
|
-
})
|
|
5889
|
+
onError: handleStytchAPIError()
|
|
5893
5890
|
}),
|
|
5894
5891
|
stytchSSOAuthenticate = _useMutate16.trigger,
|
|
5895
5892
|
isSSOLoading = _useMutate16.isMutating;
|
|
5896
|
-
var _useMutate17 = useMutate("stytch.magicLinks.discovery.authenticate", function (_,
|
|
5897
|
-
var token =
|
|
5893
|
+
var _useMutate17 = useMutate("stytch.magicLinks.discovery.authenticate", function (_, _ref127) {
|
|
5894
|
+
var token = _ref127.arg.token;
|
|
5898
5895
|
return stytchClient.magicLinks.discovery.authenticate({
|
|
5899
5896
|
discovery_magic_links_token: token
|
|
5900
5897
|
});
|
|
5901
5898
|
}, {
|
|
5902
5899
|
onSuccess: onDiscoverySuccess,
|
|
5903
|
-
onError:
|
|
5904
|
-
errorType: ErrorType.Default
|
|
5905
|
-
})
|
|
5900
|
+
onError: handleStytchAPIError()
|
|
5906
5901
|
}),
|
|
5907
5902
|
stytchDiscoveryAuthenticate = _useMutate17.trigger,
|
|
5908
5903
|
isDiscoveryLoading = _useMutate17.isMutating;
|
|
@@ -6005,11 +6000,11 @@ var AppContainer$1 = function AppContainer$1() {
|
|
|
6005
6000
|
src: POWERED_BY_STYTCH_IMG_URL
|
|
6006
6001
|
}))))));
|
|
6007
6002
|
};
|
|
6008
|
-
var AppContainer = function AppContainer(
|
|
6009
|
-
var client =
|
|
6010
|
-
styles =
|
|
6011
|
-
callbacks =
|
|
6012
|
-
config =
|
|
6003
|
+
var AppContainer = function AppContainer(_ref128) {
|
|
6004
|
+
var client = _ref128.client,
|
|
6005
|
+
styles = _ref128.styles,
|
|
6006
|
+
callbacks = _ref128.callbacks,
|
|
6007
|
+
config = _ref128.config;
|
|
6013
6008
|
var _extractErrorMessage$70 = extractErrorMessage.h(function () {
|
|
6014
6009
|
var _internal$readB2BInte5 = internal.readB2BInternals(client).bootstrap.getSync(),
|
|
6015
6010
|
displayWatermark = _internal$readB2BInte5.displayWatermark;
|
|
@@ -6025,8 +6020,8 @@ var AppContainer = function AppContainer(_ref129) {
|
|
|
6025
6020
|
options: config
|
|
6026
6021
|
}
|
|
6027
6022
|
});
|
|
6028
|
-
internal.readB2BInternals(client).bootstrap.getAsync().then(function (
|
|
6029
|
-
var displayWatermark =
|
|
6023
|
+
internal.readB2BInternals(client).bootstrap.getAsync().then(function (_ref129) {
|
|
6024
|
+
var displayWatermark = _ref129.displayWatermark;
|
|
6030
6025
|
setDisplayWatermark(displayWatermark);
|
|
6031
6026
|
});
|
|
6032
6027
|
}, [client]);
|
|
@@ -6063,11 +6058,11 @@ var StytchB2BUIClient = /*#__PURE__*/function (_b2b_index_headless$S) {
|
|
|
6063
6058
|
}
|
|
6064
6059
|
_createClass(StytchB2BUIClient, [{
|
|
6065
6060
|
key: "mount",
|
|
6066
|
-
value: function mount(
|
|
6067
|
-
var elementId =
|
|
6068
|
-
styles =
|
|
6069
|
-
callbacks =
|
|
6070
|
-
config =
|
|
6061
|
+
value: function mount(_ref130) {
|
|
6062
|
+
var elementId = _ref130.elementId,
|
|
6063
|
+
styles = _ref130.styles,
|
|
6064
|
+
callbacks = _ref130.callbacks,
|
|
6065
|
+
config = _ref130.config;
|
|
6071
6066
|
var _a;
|
|
6072
6067
|
var targetParentDomNode = document.querySelector(elementId);
|
|
6073
6068
|
if (!targetParentDomNode) {
|
|
@@ -27,7 +27,7 @@ function _isNativeFunction(fn) { try { return Function.toString.call(fn).indexOf
|
|
|
27
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
28
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
29
29
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
30
|
-
import { O as OAuthProviders } from './internal-
|
|
30
|
+
import { O as OAuthProviders } from './internal-B_3PRrIX.js';
|
|
31
31
|
var n$3,
|
|
32
32
|
l$4,
|
|
33
33
|
u$3,
|
|
@@ -29,7 +29,7 @@ function _isNativeFunction(fn) { try { return Function.toString.call(fn).indexOf
|
|
|
29
29
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
30
30
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
31
31
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
32
|
-
var internal = require('./internal-
|
|
32
|
+
var internal = require('./internal-8PFEtDRF.js');
|
|
33
33
|
var n$3,
|
|
34
34
|
l$4,
|
|
35
35
|
u$3,
|