@stytch/vanilla-js 2.0.1 → 2.0.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 +8 -0
- package/dist/b2b/index.d.ts +10 -2
- package/dist/b2b/index.esm.d.ts +10 -2
- package/dist/b2b/index.esm.js +15078 -1
- package/dist/b2b/index.js +15071 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.headless.esm.js +4024 -4
- package/dist/index.headless.js +4025 -4
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/index.headless.js
CHANGED
|
@@ -1,5 +1,4026 @@
|
|
|
1
|
-
"use strict";function e(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,o,s,a=[],c=!0,u=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(a.push(n.value),a.length!==t);c=!0);}catch(e){u=!0,i=e}finally{try{if(!c&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(u)throw i}}return a}}(e,t)||r(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t(e){return function(e){if(Array.isArray(e))return n(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||r(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&o(e,t)}function o(e,t){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},o(e,t)}function s(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=c(e);if(t){var i=c(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return function(e,t){if(t&&("object"===l(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return a(e)}(this,r)}}function a(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function c(e){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},c(e)}function u(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */u=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",a=i.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function h(e,t,r,i){var o=t&&t.prototype instanceof f?t:f,s=Object.create(o.prototype),a=new x(i||[]);return n(s,"_invoke",{value:S(e,r,a)}),s}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=h;var p={};function f(){}function v(){}function _(){}var m={};c(m,o,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(C([])));g&&g!==t&&r.call(g,o)&&(m=g);var b=_.prototype=f.prototype=Object.create(m);function w(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function k(e,t){function i(n,o,s,a){var c=d(e[n],e,o);if("throw"!==c.type){var u=c.arg,h=u.value;return h&&"object"==l(h)&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){i("next",e,s,a)}),(function(e){i("throw",e,s,a)})):t.resolve(h).then((function(e){u.value=e,s(u)}),(function(e){return i("throw",e,s,a)}))}a(c.arg)}var o;n(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return o=o?o.then(n,n):n()}})}function S(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return A()}for(r.method=i,r.arg=o;;){var s=r.delegate;if(s){var a=O(s,r);if(a){if(a===p)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=d(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===p)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function O(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,O(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),p;var i=d(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,p;var o=i.arg;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,p):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,p)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function C(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:A}}function A(){return{value:void 0,done:!0}}return v.prototype=_,n(b,"constructor",{value:_,configurable:!0}),n(_,"constructor",{value:v,configurable:!0}),v.displayName=c(_,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,_):(e.__proto__=_,c(e,a,"GeneratorFunction")),e.prototype=Object.create(b),e},e.awrap=function(e){return{__await:e}},w(k.prototype),c(k.prototype,s,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var s=new k(h(t,r,n,i),o);return e.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},w(b),c(b,a,"Generator"),c(b,o,(function(){return this})),c(b,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=C,x.prototype={constructor:x,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return s.type="throw",s.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var a=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(a&&c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=e,s.arg=t,o?(this.method="next",this.next=o.finallyLoc,p):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),p},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),E(r),p}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;E(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:C(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},e}function l(e){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},l(e)}function h(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function d(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,f(n.key),n)}}function p(e,t,r){return t&&d(e.prototype,t),r&&d(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function f(e){var t=function(e,t){if("object"!==l(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==l(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===l(t)?t:String(t)}function v(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=m(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}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 o,s=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}function _(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,o,s,a=[],c=!0,u=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(a.push(n.value),a.length!==t);c=!0);}catch(e){u=!0,i=e}finally{try{if(!c&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(u)throw i}}return a}}(e,t)||m(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(e,t){if(e){if("string"==typeof e)return y(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?y(e,t):void 0}}function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function g(e){return g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},g(e)}function b(){
|
|
2
|
-
|
|
3
|
-
b=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",a=i.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function u(e,t,r,i){var o=t&&t.prototype instanceof d?t:d,s=Object.create(o.prototype),a=new x(i||[]);return n(s,"_invoke",{value:S(e,r,a)}),s}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var h={};function d(){}function p(){}function f(){}var v={};c(v,o,(function(){return this}));var _=Object.getPrototypeOf,m=_&&_(_(C([])));m&&m!==t&&r.call(m,o)&&(v=m);var y=f.prototype=d.prototype=Object.create(v);function w(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function k(e,t){function i(n,o,s,a){var c=l(e[n],e,o);if("throw"!==c.type){var u=c.arg,h=u.value;return h&&"object"==g(h)&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){i("next",e,s,a)}),(function(e){i("throw",e,s,a)})):t.resolve(h).then((function(e){u.value=e,s(u)}),(function(e){return i("throw",e,s,a)}))}a(c.arg)}var o;n(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return o=o?o.then(n,n):n()}})}function S(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return A()}for(r.method=i,r.arg=o;;){var s=r.delegate;if(s){var a=O(s,r);if(a){if(a===h)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=l(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function O(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,O(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var i=l(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,h;var o=i.arg;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,h):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function C(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:A}}function A(){return{value:void 0,done:!0}}return p.prototype=f,n(y,"constructor",{value:f,configurable:!0}),n(f,"constructor",{value:p,configurable:!0}),p.displayName=c(f,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,c(e,a,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},w(k.prototype),c(k.prototype,s,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var s=new k(u(t,r,n,i),o);return e.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},w(y),c(y,a,"Generator"),c(y,o,(function(){return this})),c(y,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=C,x.prototype={constructor:x,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return s.type="throw",s.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var a=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(a&&c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=e,s.arg=t,o?(this.method="next",this.next=o.finallyLoc,h):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),E(r),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;E(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:C(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},e}function w(e,t){for(var r=0;r<t.length;r++){var n=t[r];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){if("object"!==g(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==g(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(i,"string"),"symbol"===g(o)?o:String(o)),n)}var i,o}function k(e,t,r){return t&&w(e.prototype,t),r&&w(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function S(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function O(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&P(e,t)}function T(e){var t=A();return function(){var r,n=R(e);if(t){var i=R(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return function(e,t){if(t&&("object"===g(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return E(e)}(this,r)}}function E(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function x(e){var t="function"==typeof Map?new Map:void 0;return x=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return C(e,arguments,R(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),P(n,e)},x(e)}function C(e,t,r){return C=A()?Reflect.construct.bind():function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&P(i,r.prototype),i},C.apply(null,arguments)}function A(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function P(e,t){return P=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},P(e,t)}function R(e){return R=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},R(e)}Object.defineProperty(exports,"__esModule",{value:!0});var B,L="https://accounts.google.com/gsi",I="".concat(L,"/client");function D(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}function j(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{c(n.next(e))}catch(e){o(e)}}function a(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))}var N=new Uint8Array(16);function M(){if(!B&&!(B="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");return B(N)}var F=/^(?:[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;for(var U,K,G,q,W,H,Y=[],z=0;z<256;++z)Y.push((z+256).toString(16).substr(1));function V(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(Y[e[t+0]]+Y[e[t+1]]+Y[e[t+2]]+Y[e[t+3]]+"-"+Y[e[t+4]]+Y[e[t+5]]+"-"+Y[e[t+6]]+Y[e[t+7]]+"-"+Y[e[t+8]]+Y[e[t+9]]+"-"+Y[e[t+10]]+Y[e[t+11]]+Y[e[t+12]]+Y[e[t+13]]+Y[e[t+14]]+Y[e[t+15]]).toLowerCase();if(!function(e){return"string"==typeof e&&F.test(e)}(r))throw TypeError("Stringified UUID is invalid");return r}function J(e,t,r){var n=(e=e||{}).random||(e.rng||M)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(var i=0;i<16;++i)t[r+i]=n[i];return t}return V(n)}!function(e){e.emailMagicLinks="emailMagicLinks",e.oauth="oauth",e.otp="otp",e.crypto="crypto",e.passwords="passwords"}(U||(U={})),function(e){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"}(K||(K={})),function(e){e.Vessel="Vessel",e.Phantom="Phantom",e.Metamask="Metamask",e.Coinbase="Coinbase",e.Binance="Binance",e.GenericEthereumWallet="Other Ethereum Wallet",e.GenericSolanaWallet="Other Solana Wallet"}(G||(G={})),function(e){e.embedded="embedded",e.floating="floating"}(q||(q={})),function(e){e.SMS="sms",e.WhatsApp="whatsapp",e.Email="email"}(W||(W={})),function(e){e.MagicLinkLoginOrCreateEvent="MAGIC_LINK_LOGIN_OR_CREATE",e.OTPsLoginOrCreateEvent="OTP_LOGIN_OR_CREATE",e.OTPsAuthenticate="OTP_AUTHENTICATE",e.CryptoWalletAuthenticateStart="CRYPTO_WALLET_AUTHENTICATE_START",e.CryptoWalletAuthenticate="CRYPTO_WALLET_AUTHENTICATE",e.PasswordCreate="PASSWORD_CREATE",e.PasswordAuthenticate="PASSWORD_AUTHENTICATE",e.PasswordResetByEmailStart="PASSWORD_RESET_BY_EMAIL_START",e.PasswordResetByEmail="PASSWORD_RESET_BY_EMAIL",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"}(H||(H={}));var X,$,Z,Q,ee=function(e){O(r,x(Error));var t=T(r);function r(e,n){var i;return S(this,r),(i=t.call(this,e+"\n"+n)).message=e+"\n"+n,i.name="SDKAPIUnreachableError",i.details=n,Object.setPrototypeOf(E(i),r.prototype),i}return k(r)}(),te=function(e){O(r,x(Error));var t=T(r);function r(e,n){var i;return S(this,r),(i=t.call(this)).name="StytchSDKUsageError",i.message="Invalid call to ".concat(e,"\n")+n,i}return k(r)}(),re=function(e){O(r,x(Error));var t=T(r);function r(e){var n,i;S(this,r),(n=t.call(this)).name="StytchSDKSchemaError";var o=null===(i=e.body)||void 0===i?void 0:i.map((function(e){return"".concat(e.dataPath,": ").concat(e.message)})).join("\n");return n.message="[400] Request does not match expected schema\n".concat(o),n}return k(r)}(),ne=function(e){O(r,x(Error));var t=T(r);function r(e){var n;S(this,r),(n=t.call(this)).name="StytchSDKAPIError";var i=e.status_code,o=e.error_type,s=e.error_message,a=e.error_url,c=e.request_id;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}return k(r)}(),ie=["unauthorized_credentials","user_unauthenticated","invalid_secret_authentication","session_not_found"];!function(e){e.BiometricsSensorError="biometrics_sensor_error",e.DeviceCredentialsNotAllowed="device_credentials_not_allowed",e.DeviceHardwareError="device_hardware_error",e.InternalError="internal_error",e.KeyInvalidated="key_invalidated",e.KeystoreUnavailable="keystore_unavailable",e.NoBiometricsEnrolled="no_biometrics_enrolled",e.NoBiometricsRegistration="no_biometrics_registration",e.SessionExpired="session_expired",e.UserCancellation="user_cancellation",e.UserLockedOut="user_locked_out",e.BiometricsNotAvailable="biometrics_not_available"}(X||(X={})),function(e){e.emailMagicLinks="emailMagicLinks",e.sso="sso",e.passwords="passwords",e.oauth="oauth"}($||($={})),function(e){e.Discovery="Discovery",e.Organization="Organization",e.PasswordReset="PasswordReset"}(Z||(Z={})),function(e){e.Google="google",e.Microsoft="microsoft"}(Q||(Q={}));var oe={};function se(e,t){return j(this,void 0,void 0,b().mark((function r(){return b().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(void 0===oe[e]){r.next=2;break}return r.abrupt("return",oe[e]);case 2:return oe[e]=ae(e,t),r.abrupt("return",oe[e]);case 4:case"end":return r.stop()}}),r)})))}function ae(e,t){return new Promise((function(r,n){var i=function(e){var t=ce(e);if(t[0])return t[0]}(e);if(i&&"true"===i.dataset.loaded)try{r(t())}catch(t){return n(new Error("".concat(e," already loaded, but module was not found in global scope: ").concat(t)))}var o=function(e){var t=document.createElement("script");return t.setAttribute("src",e),t.setAttribute("async","true"),t.setAttribute("defer","true"),document.head.appendChild(t),t}(e);o.addEventListener("load",(function(){o.dataset.loaded="true";try{r(t())}catch(t){n(new Error("".concat(e," was loaded, but module was not found in global scope: ").concat(t)))}})),o.addEventListener("error",(function(t){n(new Error("".concat(e," could not be loaded: ").concat(t)))}))}))}var ce=function(e){return document.querySelectorAll('script[src="'.concat(e,'"]'))};var ue=["[Stytch]"],le=function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return(e=console).warn.apply(e,ue.concat(r))},he=function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return(e=console).error.apply(e,ue.concat(r))},de="\nYou can find your public token at https://stytch.com/dashboard/api-keys.",pe=function(e){var t={isObject:function(r,n){var i="object"===g(n)&&!Array.isArray(n)&&null!==n;if(!i)throw new te(e,r+" must be an object.");return t},isOptionalObject:function(e,r){return void 0===r?t:t.isObject(e,r)},isString:function(r,n){if("string"!=typeof n)throw new te(e,r+" must be a string.");return t},isOptionalString:function(e,r){return void 0===r?t:t.isString(e,r)},isStringArray:function(r,n){if(!Array.isArray(n))throw new te(e,r+" must be an array of strings.");var i,o=v(n);try{for(o.s();!(i=o.n()).done;){if("string"!=typeof i.value)throw new te(e,r+" must be an array of strings.")}}catch(e){o.e(e)}finally{o.f()}return t},isOptionalStringArray:function(e,r){return void 0===r?t:t.isStringArray(e,r)},isNumber:function(r,n){if("number"!=typeof n)throw new te(e,r+" must be a number.");return t},isOptionalNumber:function(e,r){return void 0===r?t:t.isNumber(e,r)},isBoolean:function(r,n){if("boolean"!=typeof n)throw new te(e,r+" must be a boolean.");return t},isOptionalBoolean:function(e,r){return void 0===r?t:t.isBoolean(e,r)}};return t},fe=function(e){return D(e,["request_id","status_code"])},ve=function(e){return D(e,["__user"])},_e=k((function e(t,r,n){var i=this;S(this,e),this.bootstrapPromise=n,this.isEnabled=function(){return j(i,void 0,void 0,b().mark((function e(){return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.state.then((function(e){return e.enabled})));case 1:case"end":return e.stop()}}),e,this)})))},this.getTelemetryID=function(){return j(i,void 0,void 0,b().mark((function e(){var t,r,n,i;return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.state;case 2:if(t=e.sent,r=t.publicToken,n=t.enabled,i=t.dfpBackendURL,n){e.next=8;break}return e.abrupt("return",void 0);case 8:return e.next=10,window.GetTelemetryID(r,"".concat(i,"/submit"));case 10:return e.abrupt("return",e.sent);case 11:case"end":return e.stop()}}),e,this)})))},this.state=n.then((function(e){return j(i,void 0,void 0,b().mark((function n(){return b().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(e.runDFPProtectedAuth){n.next=2;break}return n.abrupt("return",{publicToken:t,dfpBackendURL:r,enabled:!1,loaded:!1});case 2:return n.next=4,void se("".concat("https://elements.stytch.com","/telemetry.js"),(function(){return window}));case 4:return n.abrupt("return",{publicToken:t,dfpBackendURL:r,enabled:!0,loaded:!0});case 5:case"end":return n.stop()}}),n)})))}))})),me=function(){function e(){S(this,e)}return k(e,null,[{key:"marshall",value:function(e){return Object.assign(Object.assign({},e),{name:e.name,message:e.message,stack:e.stack})}},{key:"inflate",value:function(e,t){var r=new e(t);return Object.assign(r,t),Object.setPrototypeOf(r,e.prototype),r}},{key:"unmarshall",value:function(t){if("name"in t)switch(t.name){case"SDKAPIUnreachableError":return e.inflate(ee,t);case"StytchSDKSchemaError":return e.inflate(re,t);case"StytchSDKAPIError":return e.inflate(ne,t);case"TypeError":return e.inflate(TypeError,t);case"SyntaxError":return e.inflate(SyntaxError,t);case"ReferenceError":return e.inflate(ReferenceError,t);case"RangeError":return e.inflate(RangeError,t);case"EvalError":return e.inflate(EvalError,t);case"URIError":return e.inflate(URIError,t)}return e.inflate(Error,t)}}]),e}(),ye=function(){function e(t){S(this,e),this.maxBatchSize=t.maxBatchSize,this.logEventURL=t.logEventURL,setInterval(this.flush.bind(this),t.intervalDurationMs),this.batch=[]}return k(e,[{key:"logEvent",value:function(e,t){this.batch.push({telemetry:e,event:t}),this.batch.length>=this.maxBatchSize&&this.flush()}},{key:"flush",value:function(){return j(this,void 0,void 0,b().mark((function e(){var t;return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.batch.length){e.next=2;break}return e.abrupt("return");case 2:return t=this.batch,this.batch=[],e.prev=4,e.next=7,fetch(this.logEventURL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});case 7:e.next=11;break;case 9:e.prev=9,e.t0=e.catch(4);case 11:case"end":return e.stop()}}),e,this,[[4,9]])})))}}]),e}(),ge=k((function e(t,r){var n=this;S(this,e),this._networkClient=t,this._subscriptionService=r,this.get=function(){return j(n,void 0,void 0,b().mark((function e(){var t,r;return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._networkClient.fetchSDK({url:"/users/me",errorMessage:"Failed to retrieve user info.",method:"GET"});case 2:return t=e.sent,r=fe(t),this._subscriptionService.updateUser(r),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)})))},this.getSync=function(){return n._subscriptionService.getUser()},this.update=function(e){return j(n,void 0,void 0,b().mark((function t(){var r,n;return b().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return pe("stytch.user.update").isOptionalObject("untrusted_metadata",e.untrusted_metadata),t.next=3,this._networkClient.fetchSDK({url:"/users/me",body:e,errorMessage:"Failed to update user.",method:"PUT"});case 3:return r=t.sent,n=fe(r.__user),this._subscriptionService.updateUser(n),t.abrupt("return",ve(r));case 7:case"end":return t.stop()}}),t,this)})))},this.deleteEmail=function(e){return j(n,void 0,void 0,b().mark((function t(){var r,n;return b().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._networkClient.fetchSDK({url:"/users/emails/".concat(e),errorMessage:"Failed to delete email.",method:"DELETE"});case 2:return r=t.sent,n=fe(r.__user),this._subscriptionService.updateUser(n),t.abrupt("return",ve(r));case 6:case"end":return t.stop()}}),t,this)})))},this.deletePhoneNumber=function(e){return j(n,void 0,void 0,b().mark((function t(){var r,n;return b().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._networkClient.fetchSDK({url:"/users/phone_numbers/".concat(e),errorMessage:"Failed to delete phone number.",method:"DELETE"});case 2:return r=t.sent,n=fe(r.__user),this._subscriptionService.updateUser(n),t.abrupt("return",ve(r));case 6:case"end":return t.stop()}}),t,this)})))},this.deleteTOTP=function(e){return j(n,void 0,void 0,b().mark((function t(){var r,n;return b().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._networkClient.fetchSDK({url:"/users/totps/".concat(e),errorMessage:"Failed to delete TOTP.",method:"DELETE"});case 2:return r=t.sent,n=fe(r.__user),this._subscriptionService.updateUser(n),t.abrupt("return",ve(r));case 6:case"end":return t.stop()}}),t,this)})))},this.deleteOAuthRegistration=function(e){return j(n,void 0,void 0,b().mark((function t(){var r,n;return b().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._networkClient.fetchSDK({url:"/users/oauth/".concat(e),errorMessage:"Failed to delete OAuth registration.",method:"DELETE"});case 2:return r=t.sent,n=fe(r.__user),this._subscriptionService.updateUser(n),t.abrupt("return",ve(r));case 6:case"end":return t.stop()}}),t,this)})))},this.deleteWebauthnRegistration=function(e){return j(n,void 0,void 0,b().mark((function t(){var r,n;return b().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._networkClient.fetchSDK({url:"/users/webauthn_registrations/".concat(e),errorMessage:"Failed to delete WebAuthn registration.",method:"DELETE"});case 2:return r=t.sent,n=fe(r.__user),this._subscriptionService.updateUser(n),t.abrupt("return",ve(r));case 6:case"end":return t.stop()}}),t,this)})))},this.deleteBiometricRegistration=function(e){return j(n,void 0,void 0,b().mark((function t(){var r,n;return b().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._networkClient.fetchSDK({url:"/users/biometric_registrations/".concat(e),errorMessage:"Failed to delete Biometric registration.",method:"DELETE"});case 2:return r=t.sent,n=fe(r.__user),this._subscriptionService.updateUser(n),t.abrupt("return",ve(r));case 6:case"end":return t.stop()}}),t,this)})))},this.onChange=function(e){var t=n._subscriptionService.getUser();return n._subscriptionService.subscribeToState((function(r){var n;(null==r?void 0:r.user)!==t&&(t=null!==(n=null==r?void 0:r.user)&&void 0!==n?n:null,e(t))}))}})),be=function(){function e(t,r){var n=this;S(this,e),this._networkClient=t,this._subscriptionService=r,this.getSync=function(){return n._subscriptionService.getSession()},this.onChange=function(e){var t=n._subscriptionService.getSession();return n._subscriptionService.subscribeToState((function(r){var n;(null==r?void 0:r.session)!==t&&(t=null!==(n=null==r?void 0:r.session)&&void 0!==n?n:null,e(t))}))},this.revoke=function(e){return j(n,void 0,void 0,b().mark((function t(){var r;return b().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this._networkClient.fetchSDK({url:"/sessions/revoke",errorMessage:"Error revoking session",method:"POST"});case 3:return r=t.sent,this._subscriptionService.destroyState(),t.abrupt("return",r);case 8:throw t.prev=8,t.t0=t.catch(0),((null==e?void 0:e.forceClear)||ie.includes(t.t0.error_type))&&this._subscriptionService.destroyState(),t.t0;case 12:case"end":return t.stop()}}),t,this,[[0,8]])})))},this.authenticate=function(e){return j(n,void 0,void 0,b().mark((function t(){var r,n;return b().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,r={session_duration_minutes:null==e?void 0:e.session_duration_minutes},t.next=4,this._networkClient.fetchSDK({url:"/sessions/authenticate",body:r,errorMessage:"Error authenticating session",method:"POST"});case 4:return n=t.sent,this._subscriptionService.updateStateAndTokens({state:{session:n.session,user:n.user},session_token:n.session_token,session_jwt:n.session_jwt,intermediate_session_token:null}),t.abrupt("return",ve(n));case 9:throw t.prev=9,t.t0=t.catch(0),ie.includes(t.t0.error_type)&&this._subscriptionService.destroyState(),t.t0;case 13:case"end":return t.stop()}}),t,this,[[0,9]])})))}}return k(e,[{key:"getTokens",value:function(){return this._subscriptionService.getTokens()}},{key:"updateSession",value:function(e){this._subscriptionService.updateTokens(e)}}]),e}(),we=Promise.resolve({pkceRequiredForEmailMagicLinks:!1}),ke=function(){function e(t,r,n){var i=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:we,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:function(){return Promise.resolve(void 0)},a=arguments.length>5?arguments[5]:void 0;S(this,e),this._networkClient=t,this._subscriptionService=r,this._pkceManager=n,this._config=o,this.executeRecaptcha=s,this._dfpProtectedAuth=a,this.email={loginOrCreate:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return j(i,void 0,void 0,b().mark((function r(){var n,i,o,s,a,c,u;return b().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this._config;case 2:if(n=r.sent,i=n.pkceRequiredForEmailMagicLinks,o=void 0,!i){r.next=9;break}return r.next=8,this.getCodeChallenge();case 8:o=r.sent;case 9:return r.next=11,this.getDFPTelemetryIDAndCaptcha();case 11:return s=r.sent,a=s.dfp_telemetry_id,c=s.captcha_token,u=Object.assign(Object.assign({},t),{email:e,code_challenge:o,captcha_token:c,dfp_telemetry_id:a}),r.abrupt("return",this._networkClient.fetchSDK({url:"/magic_links/email/login_or_create",body:u,errorMessage:"Failed to send magic link",method:"POST"}));case 16:case"end":return r.stop()}}),r,this)})))},send:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return j(i,void 0,void 0,b().mark((function r(){var n,i,o,s,a,c,u,l,h;return b().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this._config;case 2:if(n=r.sent,i=n.pkceRequiredForEmailMagicLinks,o=void 0,!i){r.next=9;break}return r.next=8,this.getCodeChallenge();case 8:o=r.sent;case 9:return r.next=11,this.getDFPTelemetryIDAndCaptcha();case 11:return s=r.sent,a=s.dfp_telemetry_id,c=s.captcha_token,u=Object.assign(Object.assign({},t),{email:e,code_challenge:o,captcha_token:c,dfp_telemetry_id:a}),l=!!this._subscriptionService.getSession(),h=l?"/magic_links/email/send/secondary":"/magic_links/email/send/primary",r.abrupt("return",this._networkClient.fetchSDK({url:h,body:u,errorMessage:"Failed to send magic link",method:"POST"}));case 18:case"end":return r.stop()}}),r,this)})))}},this.authenticate=function(e,t){return j(i,void 0,void 0,b().mark((function r(){var n,i,o;return b().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return pe("stytch.magicLinks.authenticate").isString("Token",e).isNumber("session_duration_minutes",t.session_duration_minutes),r.next=3,this._pkceManager.getPKPair();case 3:return n=r.sent,i=Object.assign({token:e,code_verifier:null==n?void 0:n.code_verifier},t),r.next=7,this._networkClient.fetchSDK({url:"/magic_links/authenticate",body:i,errorMessage:"Failed to authenticate token.",method:"POST"});case 7:return o=r.sent,this._pkceManager.clearPKPair(),this._subscriptionService.updateStateAndTokens({state:{session:o.session,user:o.user},session_token:o.session_token,session_jwt:o.session_jwt,intermediate_session_token:null}),r.abrupt("return",ve(o));case 11:case"end":return r.stop()}}),r,this)})))}}return k(e,[{key:"getCodeChallenge",value:function(){return j(this,void 0,void 0,b().mark((function e(){var t;return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._pkceManager.getPKPair();case 2:if(!(t=e.sent)){e.next=5;break}return e.abrupt("return",t.code_challenge);case 5:return e.next=7,this._pkceManager.startPKCETransaction();case 7:return t=e.sent,e.abrupt("return",t.code_challenge);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"getDFPTelemetryIDAndCaptcha",value:function(){return j(this,void 0,void 0,b().mark((function e(){var t,r;return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=void 0,r=void 0,e.t0=this._dfpProtectedAuth,!e.t0){e.next=7;break}return e.next=6,this._dfpProtectedAuth.isEnabled();case 6:e.t0=e.sent;case 7:if(!e.t0){e.next=13;break}return e.next=10,this._dfpProtectedAuth.getTelemetryID();case 10:t=e.sent,e.next=16;break;case 13:return e.next=15,this.executeRecaptcha();case 15:r=e.sent;case 16:return e.abrupt("return",{dfp_telemetry_id:t,captcha_token:r});case 17:case"end":return e.stop()}}),e,this)})))}}]),e}(),Se=k((function e(t,r){var n=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){return Promise.resolve(void 0)};S(this,e),this._networkClient=t,this._subscriptionService=r,this.executeRecaptcha=i,this.sms={loginOrCreate:function(e,t){return j(n,void 0,void 0,b().mark((function r(){var n,i;return b().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this.executeRecaptcha();case 2:return n=r.sent,i=Object.assign(Object.assign({},t),{phone_number:e,captcha_token:n}),r.abrupt("return",this._networkClient.fetchSDK({url:"/otps/sms/login_or_create",body:i,errorMessage:"Failed to send one time passcode",method:"POST"}));case 5:case"end":return r.stop()}}),r,this)})))},send:function(e,t){return j(n,void 0,void 0,b().mark((function r(){var n,i,o,s;return b().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this.executeRecaptcha();case 2:return n=r.sent,i=Object.assign(Object.assign({},t),{phone_number:e,captcha_token:n}),o=!!this._subscriptionService.getSession(),s=o?"/otps/sms/send/secondary":"/otps/sms/send/primary",r.abrupt("return",this._networkClient.fetchSDK({url:s,body:i,errorMessage:"Failed to send one time passcode",method:"POST"}));case 7:case"end":return r.stop()}}),r,this)})))}},this.whatsapp={loginOrCreate:function(e,t){return j(n,void 0,void 0,b().mark((function r(){var n,i;return b().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this.executeRecaptcha();case 2:return n=r.sent,i=Object.assign(Object.assign({},t),{phone_number:e,captcha_token:n}),r.abrupt("return",this._networkClient.fetchSDK({url:"/otps/whatsapp/login_or_create",body:i,errorMessage:"Failed to send one time passcode",method:"POST"}));case 5:case"end":return r.stop()}}),r,this)})))},send:function(e,t){return j(n,void 0,void 0,b().mark((function r(){var n,i,o,s;return b().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this.executeRecaptcha();case 2:return n=r.sent,i=Object.assign(Object.assign({},t),{phone_number:e,captcha_token:n}),o=!!this._subscriptionService.getSession(),s=o?"/otps/whatsapp/send/secondary":"/otps/whatsapp/send/primary",r.abrupt("return",this._networkClient.fetchSDK({url:s,body:i,errorMessage:"Failed to send one time passcode",method:"POST"}));case 7:case"end":return r.stop()}}),r,this)})))}},this.email={loginOrCreate:function(e,t){return j(n,void 0,void 0,b().mark((function r(){var n,i;return b().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this.executeRecaptcha();case 2:return n=r.sent,i=Object.assign(Object.assign({},t),{email:e,captcha_token:n}),r.abrupt("return",this._networkClient.fetchSDK({url:"/otps/email/login_or_create",body:i,errorMessage:"Failed to send one time passcode",method:"POST"}));case 5:case"end":return r.stop()}}),r,this)})))},send:function(e,t){return j(n,void 0,void 0,b().mark((function r(){var n,i,o,s;return b().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this.executeRecaptcha();case 2:return n=r.sent,i=Object.assign(Object.assign({},t),{email:e,captcha_token:n}),o=!!this._subscriptionService.getSession(),s=o?"/otps/email/send/secondary":"/otps/email/send/primary",r.abrupt("return",this._networkClient.fetchSDK({url:s,body:i,errorMessage:"Failed to send one time passcode",method:"POST"}));case 7:case"end":return r.stop()}}),r,this)})))}},this.authenticate=function(e,t,r){return j(n,void 0,void 0,b().mark((function n(){var i,o;return b().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return pe("stytch.otps.authenticate").isString("Code",e).isNumber("session_duration_minutes",r.session_duration_minutes),i=Object.assign({token:e,method_id:t},r),n.next=4,this._networkClient.fetchSDK({url:"/otps/authenticate",body:i,errorMessage:"Failed to authenticate token.",method:"POST"});case 4:return o=n.sent,this._subscriptionService.updateStateAndTokens({state:{session:o.session,user:o.user},session_token:o.session_token,session_jwt:o.session_jwt,intermediate_session_token:null}),n.abrupt("return",ve(o));case 7:case"end":return n.stop()}}),n,this)})))}})),Oe=function(){function e(t,r,n,i,o){S(this,e),this._networkClient=t,this._subscriptionService=r,this._pkceManager=n,this._dynamicConfig=i,this._config=o,this.google={start:this.startOAuthFlow(K.Google)},this.apple={start:this.startOAuthFlow(K.Apple)},this.microsoft={start:this.startOAuthFlow(K.Microsoft)},this.github={start:this.startOAuthFlow(K.Github)},this.gitlab={start:this.startOAuthFlow(K.GitLab)},this.facebook={start:this.startOAuthFlow(K.Facebook)},this.discord={start:this.startOAuthFlow(K.Discord)},this.salesforce={start:this.startOAuthFlow(K.Salesforce)},this.slack={start:this.startOAuthFlow(K.Slack)},this.amazon={start:this.startOAuthFlow(K.Amazon)},this.bitbucket={start:this.startOAuthFlow(K.Bitbucket)},this.linkedin={start:this.startOAuthFlow(K.LinkedIn)},this.coinbase={start:this.startOAuthFlow(K.Coinbase)},this.twitch={start:this.startOAuthFlow(K.Twitch)},this.twitter={start:this.startOAuthFlow(K.Twitter)},this.tiktok={start:this.startOAuthFlow(K.TikTok)},this.snapchat={start:this.startOAuthFlow(K.Snapchat)},this.figma={start:this.startOAuthFlow(K.Figma)},this.yahoo={start:this.startOAuthFlow(K.Yahoo)}}return k(e,[{key:"authenticate",value:function(e,t){return j(this,void 0,void 0,b().mark((function r(){var n,i;return b().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return pe("stytch.oauth.authenticate").isString("Token",e).isNumber("session_duration_minutes",t.session_duration_minutes),r.next=3,this._pkceManager.getPKPair();case 3:return(n=r.sent)||le("No code verifier found in local storage for OAuth flow.\nConsider using stytch.oauth.$provider.start() to add PKCE to your OAuth flows for added security.\nSee https://stytch.com/docs/oauth#guides_pkce for more information."),r.next=7,this._networkClient.fetchSDK({url:"/oauth/authenticate",method:"POST",body:Object.assign({token:e,code_verifier:null==n?void 0:n.code_verifier},t),errorMessage:"Failed to authenticate token"});case 7:return i=r.sent,this._pkceManager.clearPKPair(),this._subscriptionService.updateStateAndTokens({state:{session:i.session,user:fe(i.__user)},session_token:i.session_token,session_jwt:i.session_jwt,intermediate_session_token:null}),r.abrupt("return",ve(i));case 11:case"end":return r.stop()}}),r,this)})))}},{key:"getBaseApiUrl",value:function(){return j(this,void 0,void 0,b().mark((function e(){var t,r;return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._dynamicConfig;case 2:if(t=e.sent,!(r=t.cnameDomain)){e.next=6;break}return e.abrupt("return","https://".concat(r));case 6:if(!this._config.publicToken.includes("public-token-test")){e.next=8;break}return e.abrupt("return",this._config.testAPIURL);case 8:return e.abrupt("return",this._config.liveAPIURL);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"startOAuthFlow",value:function(e){var t=this;return function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=r.login_redirect_url,i=r.signup_redirect_url,o=r.custom_scopes;return j(t,void 0,void 0,b().mark((function t(){var r,s,a,c,u,l;return b().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._dynamicConfig;case 2:return r=t.sent,s=r.cnameDomain,a=r.pkceRequiredForOAuth,t.next=7,this.getBaseApiUrl();case 7:if(c=t.sent,this._networkClient.logEvent({name:"start_oauth_flow",details:{provider_type:e,custom_scopes:o,cname_domain:s,pkce:a}}),(u=new URL("".concat(c,"/v1/public/oauth/").concat(e,"/start"))).searchParams.set("public_token",this._config.publicToken),!a){t.next=18;break}return t.next=14,this._pkceManager.startPKCETransaction();case 14:l=t.sent,u.searchParams.set("code_challenge",l.code_challenge),t.next=19;break;case 18:this._pkceManager.clearPKPair();case 19:o&&(pe("startOAuthFlow").isStringArray("custom_scopes",o),u.searchParams.set("custom_scopes",o.join(" "))),n&&u.searchParams.set("login_redirect_url",n),i&&u.searchParams.set("signup_redirect_url",i),window.location.href=u.toString();case 23:case"end":return t.stop()}}),t,this)})))}}}]),e}(),Te=function(){function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){return Promise.resolve(void 0)};S(this,e),this._networkClient=t,this._subscriptionService=r,this.executeRecaptcha=n}return k(e,[{key:"authenticateStart",value:function(e){return j(this,void 0,void 0,b().mark((function t(){var r,n,i;return b().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return pe("stytch.cryptoWallets.authenticateStart").isString("crypto_wallet_address",e.crypto_wallet_address).isString("crypto_wallet_type",e.crypto_wallet_type),r=!!this._subscriptionService.getSession(),t.next=4,this.executeRecaptcha();case 4:return n=t.sent,i=r?"/crypto_wallets/authenticate/start/secondary":"/crypto_wallets/authenticate/start/primary",t.abrupt("return",this._networkClient.fetchSDK({url:i,method:"POST",errorMessage:"Failed to start wallet authentication.",body:{crypto_wallet_address:e.crypto_wallet_address,crypto_wallet_type:e.crypto_wallet_type,captcha_token:n}}));case 7:case"end":return t.stop()}}),t,this)})))}},{key:"authenticate",value:function(e){return j(this,void 0,void 0,b().mark((function t(){var r;return b().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return pe("stytch.cryptoWallets.authenticate").isString("signature",e.signature).isString("crypto_wallet_address",e.crypto_wallet_address).isString("crypto_wallet_type",e.crypto_wallet_type).isNumber("session_duration_minutes",e.session_duration_minutes),t.next=3,this._networkClient.fetchSDK({url:"/crypto_wallets/authenticate",method:"POST",errorMessage:"Failed to authenticate.",body:{session_duration_minutes:e.session_duration_minutes,crypto_wallet_address:e.crypto_wallet_address,crypto_wallet_type:e.crypto_wallet_type,signature:e.signature}});case 3:return r=t.sent,this._subscriptionService.updateStateAndTokens({state:{session:r.session,user:fe(r.__user)},session_token:r.session_token,session_jwt:r.session_jwt,intermediate_session_token:null}),t.abrupt("return",ve(r));case 6:case"end":return t.stop()}}),t,this)})))}}]),e}(),Ee=function(){function e(t,r){S(this,e),this._networkClient=t,this._subscriptionService=r}return k(e,[{key:"create",value:function(e){return j(this,void 0,void 0,b().mark((function t(){var r;return b().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return pe("stytch.totps.create").isNumber("expiration_minutes",e.expiration_minutes),t.next=3,this._networkClient.fetchSDK({url:"/totps",method:"POST",errorMessage:"Failed to create TOTP",body:{expiration_minutes:e.expiration_minutes}});case 3:return r=t.sent,this._subscriptionService.updateUser(r.__user),t.abrupt("return",ve(r));case 6:case"end":return t.stop()}}),t,this)})))}},{key:"authenticate",value:function(e){return j(this,void 0,void 0,b().mark((function t(){var r;return b().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return pe("stytch.totps.authenticate").isNumber("session_duration_minutes",e.session_duration_minutes).isString("totp_code",e.totp_code),t.next=3,this._networkClient.fetchSDK({url:"/totps/authenticate",method:"POST",errorMessage:"Failed to authenticate TOTP",body:{session_duration_minutes:e.session_duration_minutes,totp_code:e.totp_code}});case 3:return r=t.sent,this._subscriptionService.updateStateAndTokens({state:{session:r.session,user:r.__user},session_token:r.session_token,session_jwt:r.session_jwt,intermediate_session_token:null}),t.abrupt("return",ve(r));case 6:case"end":return t.stop()}}),t,this)})))}},{key:"recoveryCodes",value:function(){return j(this,void 0,void 0,b().mark((function e(){return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._networkClient.fetchSDK({url:"/totps/recovery_codes",method:"POST",errorMessage:"Failed to retrieve recovery codes"}));case 1:case"end":return e.stop()}}),e,this)})))}},{key:"recover",value:function(e){return j(this,void 0,void 0,b().mark((function t(){var r;return b().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return pe("stytch.totps.recover").isNumber("session_duration_minutes",e.session_duration_minutes).isString("recovery_code",e.recovery_code),t.next=3,this._networkClient.fetchSDK({url:"/totps/recover",method:"POST",errorMessage:"Failed to recover TOTP",body:{session_duration_minutes:e.session_duration_minutes,recovery_code:e.recovery_code}});case 3:return r=t.sent,this._subscriptionService.updateStateAndTokens({state:{session:r.session,user:r.__user},session_token:r.session_token,session_jwt:r.session_jwt,intermediate_session_token:null}),t.abrupt("return",ve(r));case 6:case"end":return t.stop()}}),t,this)})))}}]),e}();function xe(e){for(var t="==".slice(0,(4-e.length%4)%4),r=e.replace(/-/g,"+").replace(/_/g,"/")+t,n=atob(r),i=new ArrayBuffer(n.length),o=new Uint8Array(i),s=0;s<n.length;s++)o[s]=n.charCodeAt(s);return i}function Ce(e){var t,r="",n=v(new Uint8Array(e));try{for(n.s();!(t=n.n()).done;){var i=t.value;r+=String.fromCharCode(i)}}catch(e){n.e(e)}finally{n.f()}return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}var Ae="copy",Pe="convert";function Re(e,t,r){if(t===Ae)return r;if(t===Pe)return e(r);if(t instanceof Array)return r.map((function(r){return Re(e,t[0],r)}));if(t instanceof Object){for(var n={},i=0,o=Object.entries(t);i<o.length;i++){var s=_(o[i],2),a=s[0],c=s[1];if(c.derive){var u=c.derive(r);void 0!==u&&(r[a]=u)}if(a in r)null!=r[a]?n[a]=Re(e,c.schema,r[a]):n[a]=null;else if(c.required)throw new Error("Missing key: ".concat(a))}return n}}function Be(e,t){return{required:!0,schema:e,derive:t}}function Le(e){return{required:!0,schema:e}}function Ie(e){return{required:!1,schema:e}}var De={type:Le(Ae),id:Le(Pe),transports:Ie(Ae)},je={appid:Ie(Ae),appidExclude:Ie(Ae),credProps:Ie(Ae)},Ne={appid:Ie(Ae),appidExclude:Ie(Ae),credProps:Ie(Ae)},Me={publicKey:Le({rp:Le(Ae),user:Le({id:Le(Pe),name:Le(Ae),displayName:Le(Ae)}),challenge:Le(Pe),pubKeyCredParams:Le(Ae),timeout:Ie(Ae),excludeCredentials:Ie([De]),authenticatorSelection:Ie(Ae),attestation:Ie(Ae),extensions:Ie(je)}),signal:Ie(Ae)},Fe={type:Le(Ae),id:Le(Ae),rawId:Le(Pe),authenticatorAttachment:Ie(Ae),response:Le({clientDataJSON:Le(Pe),attestationObject:Le(Pe),transports:Be(Ae,(function(e){var t;return(null==(t=e.getTransports)?void 0:t.call(e))||[]}))}),clientExtensionResults:Be(Ne,(function(e){return e.getClientExtensionResults()}))},Ue={mediation:Ie(Ae),publicKey:Le({challenge:Le(Pe),timeout:Ie(Ae),rpId:Ie(Ae),allowCredentials:Ie([De]),userVerification:Ie(Ae),extensions:Ie(je)}),signal:Ie(Ae)},Ke={type:Le(Ae),id:Le(Ae),rawId:Le(Pe),authenticatorAttachment:Ie(Ae),response:Le({clientDataJSON:Le(Pe),authenticatorData:Le(Pe),signature:Le(Pe),userHandle:Le(Pe)}),clientExtensionResults:Be(Ne,(function(e){return e.getClientExtensionResults()}))};function Ge(e){return Re(xe,Me,e)}function qe(e){return Re(Ce,Fe,e)}function We(e){return j(this,void 0,void 0,b().mark((function t(){var r;return b().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,navigator.credentials.create(Ge(e));case 2:return r=t.sent,t.abrupt("return",qe(r));case 4:case"end":return t.stop()}}),t)})))}function He(e){return Re(xe,Ue,e)}function Ye(e){return Re(Ce,Ke,e)}function ze(e){return j(this,void 0,void 0,b().mark((function t(){var r;return b().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,navigator.credentials.get(He(e));case 2:return r=t.sent,t.abrupt("return",Ye(r));case 4:case"end":return t.stop()}}),t)})))}var Ve=function(){function e(t,r){S(this,e),this._networkClient=t,this._subscriptionService=r}return k(e,[{key:"register",value:function(e){var t;return j(this,void 0,void 0,b().mark((function r(){var n,i,o,s;return b().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return pe("stytch.webauthn.register").isOptionalString("domain",null==e?void 0:e.domain).isOptionalString("authenticator_type",null==e?void 0:e.authenticator_type),r.next=3,this._networkClient.fetchSDK({url:"/webauthn/register/start",method:"POST",errorMessage:"Failed to start WebAuthn registration",body:{domain:null!==(t=null==e?void 0:e.domain)&&void 0!==t?t:window.location.hostname,authenticator_type:null==e?void 0:e.authenticator_type}});case 3:return n=r.sent,i=n.public_key_credential_creation_options,r.next=7,We({publicKey:JSON.parse(i)});case 7:return o=r.sent,r.next=10,this._networkClient.fetchSDK({url:"/webauthn/register",method:"POST",errorMessage:"Failed to register WebAuthn device",body:{public_key_credential:JSON.stringify(o)}});case 10:return s=r.sent,this._subscriptionService.updateUser(s.__user),r.abrupt("return",ve(s));case 13:case"end":return r.stop()}}),r,this)})))}},{key:"authenticate",value:function(e){var t;return j(this,void 0,void 0,b().mark((function r(){var n,i,o,s;return b().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return pe("stytch.webauthn.register").isOptionalString("domain",e.domain).isNumber("session_duration_minutes",e.session_duration_minutes),r.next=3,this._networkClient.fetchSDK({url:"/webauthn/authenticate/start",method:"POST",errorMessage:"Failed to start WebAuthn authentication",body:{domain:null!==(t=e.domain)&&void 0!==t?t:window.location.hostname}});case 3:return n=r.sent,i=n.public_key_credential_request_options,r.next=7,ze({publicKey:JSON.parse(i)});case 7:return o=r.sent,r.next=10,this._networkClient.fetchSDK({url:"/webauthn/authenticate",method:"POST",errorMessage:"Failed to authenticate WebAuthn device",body:{public_key_credential:JSON.stringify(o),session_duration_minutes:e.session_duration_minutes}});case 10:return s=r.sent,this._subscriptionService.updateStateAndTokens({state:{session:s.session,user:s.__user},session_token:s.session_token,session_jwt:s.session_jwt,intermediate_session_token:null}),r.abrupt("return",ve(s));case 13:case"end":return r.stop()}}),r,this)})))}}]),e}(),Je=Promise.resolve({pkceRequiredForPasswordResets:!1}),Xe=function(){function e(t,r,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Je,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:function(){return Promise.resolve(void 0)},s=arguments.length>5?arguments[5]:void 0;S(this,e),this._networkClient=t,this._subscriptionService=r,this._pkceManager=n,this._config=i,this.executeRecaptcha=o,this._dfpProtectedAuth=s}return k(e,[{key:"getCodeChallenge",value:function(){return j(this,void 0,void 0,b().mark((function e(){var t,r;return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._config;case 2:if(t=e.sent,t.pkceRequiredForPasswordResets){e.next=6;break}return e.abrupt("return",void 0);case 6:return e.next=8,this._pkceManager.getPKPair();case 8:if(!(r=e.sent)){e.next=11;break}return e.abrupt("return",r.code_challenge);case 11:return e.next=13,this._pkceManager.startPKCETransaction();case 13:return r=e.sent,e.abrupt("return",r.code_challenge);case 15:case"end":return e.stop()}}),e,this)})))}},{key:"getDFPTelemetryIDAndCaptcha",value:function(){return j(this,void 0,void 0,b().mark((function e(){var t,r;return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=void 0,r=void 0,e.t0=this._dfpProtectedAuth,!e.t0){e.next=7;break}return e.next=6,this._dfpProtectedAuth.isEnabled();case 6:e.t0=e.sent;case 7:if(!e.t0){e.next=13;break}return e.next=10,this._dfpProtectedAuth.getTelemetryID();case 10:t=e.sent,e.next=16;break;case 13:return e.next=15,this.executeRecaptcha();case 15:r=e.sent;case 16:return e.abrupt("return",{dfp_telemetry_id:t,captcha_token:r});case 17:case"end":return e.stop()}}),e,this)})))}},{key:"create",value:function(e){return j(this,void 0,void 0,b().mark((function t(){var r,n,i,o;return b().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return pe("stytch.passwords.create").isString("password",e.password).isString("email",e.email).isNumber("session_duration_minutes",e.session_duration_minutes),t.next=3,this.getDFPTelemetryIDAndCaptcha();case 3:return r=t.sent,n=r.dfp_telemetry_id,i=r.captcha_token,t.next=8,this._networkClient.fetchSDK({url:"/passwords",method:"POST",errorMessage:"Failed to create password.",body:{email:e.email,password:e.password,session_duration_minutes:e.session_duration_minutes,captcha_token:i,dfp_telemetry_id:n}});case 8:return o=t.sent,this._subscriptionService.updateStateAndTokens({state:{session:o.session,user:o.user},session_token:o.session_token,session_jwt:o.session_jwt,intermediate_session_token:null}),t.abrupt("return",ve(o));case 11:case"end":return t.stop()}}),t,this)})))}},{key:"authenticate",value:function(e){return j(this,void 0,void 0,b().mark((function t(){var r,n,i,o;return b().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return pe("stytch.passwords.authenticate").isString("password",e.password).isString("email",e.email).isNumber("session_duration_minutes",e.session_duration_minutes),t.next=3,this.getDFPTelemetryIDAndCaptcha();case 3:return r=t.sent,n=r.dfp_telemetry_id,i=r.captcha_token,t.next=8,this._networkClient.fetchSDK({url:"/passwords/authenticate",method:"POST",errorMessage:"Failed to authenticate password.",body:{email:e.email,password:e.password,session_duration_minutes:e.session_duration_minutes,captcha_token:i,dfp_telemetry_id:n}});case 8:return o=t.sent,this._subscriptionService.updateStateAndTokens({state:{session:o.session,user:o.user},session_token:o.session_token,session_jwt:o.session_jwt,intermediate_session_token:null}),t.abrupt("return",ve(o));case 11:case"end":return t.stop()}}),t,this)})))}},{key:"resetByEmailStart",value:function(e){return j(this,void 0,void 0,b().mark((function t(){var r,n,i,o;return b().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return pe("stytch.passwords.resetByEmailStart").isString("email",e.email).isOptionalString("login_redirect_url",e.login_redirect_url).isOptionalString("reset_password_redirect_url",e.reset_password_redirect_url).isOptionalString("reset_password_template_id",e.reset_password_template_id).isOptionalNumber("reset_password_expiration_minutes",e.reset_password_expiration_minutes),t.next=3,this.getCodeChallenge();case 3:return r=t.sent,t.next=6,this.getDFPTelemetryIDAndCaptcha();case 6:return n=t.sent,i=n.dfp_telemetry_id,o=n.captcha_token,t.abrupt("return",this._networkClient.fetchSDK({url:"/passwords/email/reset/start",method:"POST",errorMessage:"Failed to start password reset flow.",body:{email:e.email,login_redirect_url:e.login_redirect_url,reset_password_redirect_url:e.reset_password_redirect_url,reset_password_expiration_minutes:e.reset_password_expiration_minutes,reset_password_template_id:e.reset_password_template_id,code_challenge:r,captcha_token:o,dfp_telemetry_id:i}}));case 10:case"end":return t.stop()}}),t,this)})))}},{key:"resetByEmail",value:function(e){return j(this,void 0,void 0,b().mark((function t(){var r,n,i,o,s,a;return b().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return pe("stytch.passwords.resetByEmail").isString("token",e.token).isString("password",e.password).isNumber("session_duration_minutes",e.session_duration_minutes),t.next=3,this.getDFPTelemetryIDAndCaptcha();case 3:return r=t.sent,n=r.dfp_telemetry_id,i=r.captcha_token,t.next=8,this._pkceManager.getPKPair();case 8:return o=t.sent,s=null==o?void 0:o.code_verifier,t.next=12,this._networkClient.fetchSDK({url:"/passwords/email/reset",method:"POST",errorMessage:"Failed to reset password.",body:{token:e.token,password:e.password,session_duration_minutes:e.session_duration_minutes,captcha_token:i,code_verifier:s,dfp_telemetry_id:n}});case 12:return a=t.sent,this._pkceManager.clearPKPair(),this._subscriptionService.updateStateAndTokens({state:{session:a.session,user:a.user},session_token:a.session_token,session_jwt:a.session_jwt,intermediate_session_token:null}),t.abrupt("return",ve(a));case 16:case"end":return t.stop()}}),t,this)})))}},{key:"resetByExistingPassword",value:function(e){return j(this,void 0,void 0,b().mark((function t(){var r;return b().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return pe("stytch.passwords.resetByExistingPassword").isString("email",e.email).isString("existing_password",e.existing_password).isString("new_password",e.new_password).isNumber("session_duration_minutes",e.session_duration_minutes),t.next=3,this._networkClient.fetchSDK({url:"/passwords/existing_password/reset",method:"POST",errorMessage:"Failed to reset password.",body:{email:e.email,existing_password:e.existing_password,new_password:e.new_password,session_duration_minutes:e.session_duration_minutes}});case 3:return r=t.sent,t.abrupt("return",ve(r));case 5:case"end":return t.stop()}}),t,this)})))}},{key:"resetBySession",value:function(e){return j(this,void 0,void 0,b().mark((function t(){return b().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return pe("stytch.passwords.resetBySession").isString("password",e.password),t.next=3,this._networkClient.fetchSDK({url:"/passwords/session/reset",method:"POST",errorMessage:"Failed to reset session.",body:{password:e.password}});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"strengthCheck",value:function(e){return j(this,void 0,void 0,b().mark((function t(){return b().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return pe("stytch.passwords.strengthCheck").isOptionalString("email",e.email).isString("password",e.password),t.abrupt("return",this._networkClient.fetchSDK({url:"/passwords/strength_check",method:"POST",errorMessage:"Failed to check password strength.",body:{email:e.email,password:e.password}}));case 2:case"end":return t.stop()}}),t,this)})))}}]),e}();function $e(e){var t=e.method,r=e.errorMessage,n=e.finalURL,i=e.basicAuthHeader,o=e.xSDKClientHeader,s=e.xSDKParentHostHeader,a=e.body;return j(this,void 0,void 0,b().mark((function e(){var c,u,l,h,d;return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c={Authorization:i,"Content-Type":"application/json","X-SDK-Client":o},s&&(c["X-SDK-Parent-Host"]=s),u={method:t,headers:c,body:a&&JSON.stringify(a)},e.prev=3,e.next=6,fetch(n,u);case 6:l=e.sent,e.next=14;break;case 9:if(e.prev=9,e.t0=e.catch(3),"Failed to fetch"!==e.t0.message){e.next=13;break}throw new ee(r,"Unable to contact the Stytch servers. Are you online?");case 13:throw e.t0;case 14:if(200===l.status){e.next=27;break}return e.prev=15,e.next=18,l.json();case 18:h=e.sent,e.next=24;break;case 21:throw e.prev=21,e.t1=e.catch(15),new ee(r,"Invalid or no response from server");case 24:if(!("body"in h||"params"in h||"query"in h)){e.next=26;break}throw new re(h);case 26:throw new ne(h);case 27:return e.prev=27,e.next=30,l.json();case 30:return d=e.sent,e.abrupt("return",d.data);case 34:throw e.prev=34,e.t2=e.catch(27),new ee(r,"Invalid response from the Stytch servers.");case 37:case"end":return e.stop()}}),e,null,[[3,9],[15,21],[27,34]])})))}Promise.resolve({pkceRequiredForEmailMagicLinks:!1}),Promise.resolve({pkceRequiredForPasswordResets:!1});var Ze=function(){function e(t){S(this,e),this.iframeURL=t,this.createIframe()}return k(e,[{key:"createIframe",value:function(){var e=document.querySelector('[src~="'.concat(this.iframeURL,'"]'));e?le("It looks like you're creating multiple copies of the Stytch client. This behavior is unsupported, and unintended side effects may occur. Make sure you are creating the Stytch client at the global level, and not inside a component's render function."):((e=document.createElement("iframe")).src=this.iframeURL,e.style.position="absolute",e.style.width="0",e.style.height="0",e.style.border="0",document.body.appendChild(e)),"true"!==e.dataset.loaded?this.frame=new Promise((function(t){e.addEventListener("load",(function(){e.dataset.loaded="true",t(e)}),{once:!0})})):this.frame=Promise.resolve(e)}},{key:"call",value:function(e,t){return j(this,void 0,void 0,b().mark((function r(){var n,i,o=this;return b().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this.frame;case 2:return n=r.sent,i=new MessageChannel,r.abrupt("return",new Promise((function(r,s){var a;i.port1.onmessage=function(e){var t=e.data;i.port1.close(),t.success?r(t.payload):s(me.unmarshall(t.error))};var c={method:e,args:t};null===(a=n.contentWindow)||void 0===a||a.postMessage(c,o.iframeURL,[i.port2])})));case 5:case"end":return r.stop()}}),r,this)})))}}]),e}(),Qe=function(){function e(t,r){var n=this;S(this,e),this._subscriptionService=t,this._headlessSessionClient=r,this._onDataChange=function(e){(null==e?void 0:e.session)?n.scheduleBackgroundRefresh():n.cancelBackgroundRefresh()},this._reauthenticateWithBackoff=function(){return j(n,void 0,void 0,b().mark((function t(){var r;return b().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=0;case 1:return t.prev=2,t.next=5,this._headlessSessionClient.authenticate();case 5:return t.abrupt("return",t.sent);case 8:if(t.prev=8,t.t0=t.catch(2),!e.isUnrecoverableError(t.t0)){t.next=12;break}return t.abrupt("return",Promise.reject(t.t0));case 12:return r++,t.next=15,new Promise((function(t){return setTimeout(t,e.timeoutForAttempt(r))}));case 15:t.next=1;break;case 17:case"end":return t.stop()}}),t,this,[[2,8]])})))},this.timeout=null,this._subscriptionService.subscribeToState(this._onDataChange)}return k(e,[{key:"performBackgroundRefresh",value:function(){var e=this;this._reauthenticateWithBackoff().then((function(){e.scheduleBackgroundRefresh()})).catch((function(t){le("Session background refresh failed. Signalling to app that user is logged out.",{error:t}),e._subscriptionService.destroyState()}))}},{key:"scheduleBackgroundRefresh",value:function(){var t=this;this.cancelBackgroundRefresh(),this.timeout=setTimeout((function(){t.performBackgroundRefresh()}),e.REFRESH_INTERVAL_MS)}},{key:"cancelBackgroundRefresh",value:function(){null!==this.timeout&&(clearTimeout(this.timeout),this.timeout=null)}}],[{key:"timeoutForAttempt",value:function(e){return e=Math.min(e,7),Math.floor(350*Math.random())-175+2e3*Math.pow(2,e)}},{key:"isUnrecoverableError",value:function(e){return ie.includes(e.error_type)}}]),e}();Qe.REFRESH_INTERVAL_MS=18e4;var et="bootstrap",tt=function(){function e(t,r,n){var i=this;h(this,e),this._publicToken=t,this._networkClient=r,this._dataLayer=n,this._bootstrapDataPromise=this._networkClient.fetchSDK({url:"/projects/bootstrap/".concat(this._publicToken),method:"GET",errorMessage:"Error fetching bootstrap data for SDK for ".concat(this._publicToken)}).then(e.mapBootstrapData).then((function(e){return i._dataLayer.setItem(et,JSON.stringify(e)),e})).catch((function(e){return he(e),{displayWatermark:!1,cnameDomain:null,emailDomains:["stytch.com"],captchaSettings:{enabled:!1},pkceRequiredForEmailMagicLinks:!1,pkceRequiredForPasswordResets:!1,pkceRequiredForOAuth:!1,pkceRequiredForSso:!1,slugPattern:null,createOrganizationEnabled:!1,passwordConfig:null,runDFPProtectedAuth:!1}}))}return p(e,[{key:"getSync",value:function(){var e=this._dataLayer.getItem(et);if(null===e)return{displayWatermark:!1,cnameDomain:null,emailDomains:["stytch.com"],captchaSettings:{enabled:!1},pkceRequiredForEmailMagicLinks:!1,pkceRequiredForPasswordResets:!1,pkceRequiredForOAuth:!1,pkceRequiredForSso:!1,slugPattern:null,createOrganizationEnabled:!1,passwordConfig:null,runDFPProtectedAuth:!1};try{return JSON.parse(e)}catch(e){return{displayWatermark:!1,cnameDomain:null,emailDomains:["stytch.com"],captchaSettings:{enabled:!1},pkceRequiredForEmailMagicLinks:!1,pkceRequiredForPasswordResets:!1,pkceRequiredForOAuth:!1,pkceRequiredForSso:!1,slugPattern:null,createOrganizationEnabled:!1,passwordConfig:null,runDFPProtectedAuth:!1}}}},{key:"getAsync",value:function(){return this._bootstrapDataPromise}}],[{key:"mapBootstrapData",value:function(e){var t=null!==e.password_config?{ludsComplexity:e.password_config.luds_complexity,ludsMinimumCount:e.password_config.luds_minimum_count}:null;return{displayWatermark:!e.disable_sdk_watermark,captchaSettings:e.captcha_settings,cnameDomain:e.cname_domain,emailDomains:e.email_domains,pkceRequiredForEmailMagicLinks:e.pkce_required_for_email_magic_links,pkceRequiredForPasswordResets:e.pkce_required_for_password_resets,pkceRequiredForOAuth:e.pkce_required_for_oauth,pkceRequiredForSso:e.pkce_required_for_sso,slugPattern:e.slug_pattern,createOrganizationEnabled:e.create_organization_enabled,passwordConfig:t,runDFPProtectedAuth:"ENABLED"===e.dfp_protected_auth_enabled||"PASSIVE"===e.dfp_protected_auth_enabled}}}]),e}();function rt(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{c(n.next(e))}catch(e){o(e)}}function a(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))}var nt=p((function e(t){var r=this;h(this,e),this.bootstrapPromise=t,this.executeRecaptcha=function(){return rt(r,void 0,void 0,u().mark((function e(){var t,r,n,i;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.state;case 2:if(t=e.sent,r=t.captchaClient,n=t.configured,i=t.siteKey,n){e.next=8;break}return e.abrupt("return",void 0);case 8:return e.next=10,new Promise((function(e){return r.ready(e)}));case 10:return e.abrupt("return",r.execute(i,{action:"LOGIN"}));case 11:case"end":return e.stop()}}),e,this)})))},this.state=t.then((function(e){return rt(r,void 0,void 0,u().mark((function t(){return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.captchaSettings.enabled){t.next=2;break}return t.abrupt("return",{configured:!1});case 2:return t.next=4,r=e.captchaSettings.siteKey,se("https://www.google.com/recaptcha/enterprise.js?render=".concat(r),(function(){return window.grecaptcha.enterprise}));case 4:return t.t0=t.sent,t.t1=e.captchaSettings.siteKey,t.abrupt("return",{configured:!0,captchaClient:t.t0,siteKey:t.t1});case 7:case"end":return t.stop()}var r}),t)})))}))})),it=function(){function e(t){var r=this;h(this,e),this.iframeURL=t,this.oneTapStart=function(e){return r.call("oneTapStart",e)},this.oneTapSubmit=function(e){return r.call("oneTapSubmit",e)}}return p(e,[{key:"frameClient",get:function(){var e;return this._frameClient=null!==(e=this._frameClient)&&void 0!==e?e:new Ze(this.iframeURL),this._frameClient}},{key:"call",value:function(e,t){return this.frameClient.call(e,[t])}}]),e}();function ot(e){return ot="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ot(e)}function st(e,t){for(var r=0;r<t.length;r++){var n=t[r];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){if("object"!==ot(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==ot(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(i,"string"),"symbol"===ot(o)?o:String(o)),n)}var i,o}function at(e,t,r){return t&&st(e.prototype,t),r&&st(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function ct(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ut(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&vt(e,t)}function lt(e){var t=ft();return function(){var r,n=_t(e);if(t){var i=_t(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return function(e,t){if(t&&("object"===ot(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return ht(e)}(this,r)}}function ht(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function dt(e){var t="function"==typeof Map?new Map:void 0;return dt=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return pt(e,arguments,_t(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),vt(n,e)},dt(e)}function pt(e,t,r){return pt=ft()?Reflect.construct.bind():function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&vt(i,r.prototype),i},pt.apply(null,arguments)}function ft(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function vt(e,t){return vt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},vt(e,t)}function _t(e){return _t=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},_t(e)}exports.Products=void 0,function(e){e.emailMagicLinks="emailMagicLinks",e.oauth="oauth",e.otp="otp",e.crypto="crypto",e.passwords="passwords"}(exports.Products||(exports.Products={})),exports.OAuthProviders=void 0,function(e){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"}(exports.OAuthProviders||(exports.OAuthProviders={})),exports.Wallets=void 0,function(e){e.Vessel="Vessel",e.Phantom="Phantom",e.Metamask="Metamask",e.Coinbase="Coinbase",e.Binance="Binance",e.GenericEthereumWallet="Other Ethereum Wallet",e.GenericSolanaWallet="Other Solana Wallet"}(exports.Wallets||(exports.Wallets={})),exports.OneTapPositions=void 0,function(e){e.embedded="embedded",e.floating="floating"}(exports.OneTapPositions||(exports.OneTapPositions={})),exports.OTPMethods=void 0,function(e){e.SMS="sms",e.WhatsApp="whatsapp",e.Email="email"}(exports.OTPMethods||(exports.OTPMethods={})),exports.StytchEventType=void 0,function(e){e.MagicLinkLoginOrCreateEvent="MAGIC_LINK_LOGIN_OR_CREATE",e.OTPsLoginOrCreateEvent="OTP_LOGIN_OR_CREATE",e.OTPsAuthenticate="OTP_AUTHENTICATE",e.CryptoWalletAuthenticateStart="CRYPTO_WALLET_AUTHENTICATE_START",e.CryptoWalletAuthenticate="CRYPTO_WALLET_AUTHENTICATE",e.PasswordCreate="PASSWORD_CREATE",e.PasswordAuthenticate="PASSWORD_AUTHENTICATE",e.PasswordResetByEmailStart="PASSWORD_RESET_BY_EMAIL_START",e.PasswordResetByEmail="PASSWORD_RESET_BY_EMAIL",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"}(exports.StytchEventType||(exports.StytchEventType={}));var mt=function(e){ut(r,dt(Error));var t=lt(r);function r(e,n){var i;return ct(this,r),(i=t.call(this,e+"\n"+n)).message=e+"\n"+n,i.name="SDKAPIUnreachableError",i.details=n,Object.setPrototypeOf(ht(i),r.prototype),i}return at(r)}(),yt=function(e){ut(r,dt(Error));var t=lt(r);function r(e,n){var i;return ct(this,r),(i=t.call(this)).name="StytchSDKUsageError",i.message="Invalid call to ".concat(e,"\n")+n,i}return at(r)}(),gt=function(e){ut(r,dt(Error));var t=lt(r);function r(e){var n,i;ct(this,r),(n=t.call(this)).name="StytchSDKSchemaError";var o=null===(i=e.body)||void 0===i?void 0:i.map((function(e){return"".concat(e.dataPath,": ").concat(e.message)})).join("\n");return n.message="[400] Request does not match expected schema\n".concat(o),n}return at(r)}(),bt=function(e){ut(r,dt(Error));var t=lt(r);function r(e){var n;ct(this,r),(n=t.call(this)).name="StytchSDKAPIError";var i=e.status_code,o=e.error_type,s=e.error_message,a=e.error_url,c=e.request_id;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}return at(r)}(),wt=function(e){ut(r,dt(Error));var t=lt(r);function r(e){var n;return ct(this,r),(n=t.call(this)).name="StytchSDKNativeError",n.error_type=e,n.message="".concat(e),n}return at(r)}();exports.BiometricsErrors=void 0,function(e){e.BiometricsSensorError="biometrics_sensor_error",e.DeviceCredentialsNotAllowed="device_credentials_not_allowed",e.DeviceHardwareError="device_hardware_error",e.InternalError="internal_error",e.KeyInvalidated="key_invalidated",e.KeystoreUnavailable="keystore_unavailable",e.NoBiometricsEnrolled="no_biometrics_enrolled",e.NoBiometricsRegistration="no_biometrics_registration",e.SessionExpired="session_expired",e.UserCancellation="user_cancellation",e.UserLockedOut="user_locked_out",e.BiometricsNotAvailable="biometrics_not_available"}(exports.BiometricsErrors||(exports.BiometricsErrors={})),exports.B2BProducts=void 0,function(e){e.emailMagicLinks="emailMagicLinks",e.sso="sso",e.passwords="passwords",e.oauth="oauth"}(exports.B2BProducts||(exports.B2BProducts={})),exports.AuthFlowType=void 0,function(e){e.Discovery="Discovery",e.Organization="Organization",e.PasswordReset="PasswordReset"}(exports.AuthFlowType||(exports.AuthFlowType={})),exports.B2BOAuthProviders=void 0,function(e){e.Google="google",e.Microsoft="microsoft"}(exports.B2BOAuthProviders||(exports.B2BOAuthProviders={}));var kt=function(e){i(r,Oe);var t=s(r);function r(e,n,i,o,s,c){var l;return h(this,r),(l=t.call(this,e,n,i,o,s))._oneTap=c,l.startOneTap=function(e){return rt(a(l),void 0,void 0,u().mark((function t(){var r,n,i;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._oneTap.createOneTapClient();case 2:if((r=t.sent).success){t.next=5;break}throw new Error("One Tap could not load: ".concat(r.reason));case 5:return n=r.client,i=this._oneTap.createOnSuccessHandler({signupRedirectUrl:e.signup_redirect_url,loginRedirectUrl:e.login_redirect_url,onSuccess:this._oneTap.RedirectOnSuccess}),t.abrupt("return",n.render({style:{position:exports.OneTapPositions.floating},onOneTapCancelled:e.onOneTapCancelled,callback:i}));case 8:case"end":return t.stop()}}),t,this)})))},l.googleOneTap={start:l.startOneTap},l}return p(r)}(),St=function(){function e(t,r,n,i){h(this,e),this._publicToken=t,this._subscriptionDataLayer=r,this.baseURL=n,this.additionalTelemetryDataFn=i,this.updateSessionToken=function(){return null},this.eventLogger=new ye({maxBatchSize:15,intervalDurationMs:800,logEventURL:this.buildSDKUrl("/events")})}return p(e,[{key:"logEvent",value:function(e){var t=e.name,r=e.details,n=e.error,i=void 0===n?{}:n;this.eventLogger.logEvent(this.createTelemetryBlob(),{public_token:this._publicToken,event_name:t,details:r,error_code:i.error_code,error_description:i.error_description,http_status_code:i.http_status_code})}},{key:"createTelemetryBlob",value:function(){return Object.assign(Object.assign({event_id:"event-id-".concat(J()),app_session_id:"app-session-id-".concat(J()),persistent_id:"persistent-id-".concat(J()),client_sent_at:(new Date).toISOString(),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone},this.additionalTelemetryDataFn()),{app:{identifier:window.location.hostname},sdk:{identifier:"Stytch.js Javascript SDK",version:"2.0.1"}})}},{key:"fetchSDK",value:function(e){var t=e.url,r=e.body,n=e.errorMessage,i=e.method;return rt(this,void 0,void 0,u().mark((function e(){var o,s,a,c;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=this._subscriptionDataLayer.readSessionCookie().session_token,s="Basic "+window.btoa(this._publicToken+":"+(o||this._publicToken)),a=window.btoa(JSON.stringify(this.createTelemetryBlob())),c=window.location.origin,e.abrupt("return",$e({basicAuthHeader:s,body:r,errorMessage:n,finalURL:this.buildSDKUrl(t),method:i,xSDKClientHeader:a,xSDKParentHostHeader:c}));case 5:case"end":return e.stop()}}),e,this)})))}},{key:"buildSDKUrl",value:function(e){return"".concat(this.baseURL,"/sdk/v1").concat(e)}}]),e}(),Ot=function(){function e(t,r,n){h(this,e),this._googleClient=t,this._publicToken=r,this._clientId=n}return p(e,[{key:"cancel",value:function(){this._googleClient.cancel()}},{key:"render",value:function(e){var t=e.callback,r=e.onOneTapCancelled,n=e.style;return rt(this,void 0,void 0,u().mark((function e(){var i,o=this;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i={client_id:this._clientId,callback:t,auto_select:!1,context:"use",itp_support:!0},n.position===exports.OneTapPositions.embedded&&(i.prompt_parent_id="google-parent-prompt",i.cancel_on_tap_outside=!1),this._googleClient.initialize(i),e.abrupt("return",new Promise((function(e){o._googleClient.prompt((function(t){return t.isSkippedMoment()?("user_cancel"===t.getSkippedReason()&&(null==r||r()),e({success:!1,reason:t.getSkippedReason()})):t.isNotDisplayed()?e({success:!1,reason:t.getNotDisplayedReason()}):(o.styleFrame(n),e({success:!0}))}))})));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"styleFrame",value:function(e){e.position===exports.OneTapPositions.embedded&&Array.from(document.getElementsByTagName("iframe")).forEach((function(e){e.src.includes(L)&&(e.style.width="100%")}))}}]),e}(),Tt=function(){function e(t,r){var n=this;h(this,e),this._publicToken=t,this.clientsideServices=r,this.createOnSuccessHandler=function(e){var t=e.loginRedirectUrl,r=e.signupRedirectUrl,i=e.onSuccess;return function(e){return rt(n,void 0,void 0,u().mark((function n(){var o,s,a;return u().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=e.credential,n.next=3,this.submitGoogleOneTapToken({credential:o,loginRedirectUrl:t,signupRedirectUrl:r});case 3:s=n.sent,a=s.redirect_url,i(a);case 6:case"end":return n.stop()}}),n,this)})))}},this.RedirectOnSuccess=function(e){window.location.href=e}}return p(e,[{key:"createOneTapClient",value:function(){return rt(this,void 0,void 0,u().mark((function e(){var t,r,n,i;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.fetchGoogleStart();case 3:r=e.sent,t=r.googleClientId,e.next=11;break;case 7:return e.prev=7,e.t0=e.catch(0),n=e.t0,e.abrupt("return",{success:!1,reason:n.error_type});case 11:if(""!==t){e.next=13;break}return e.abrupt("return",{success:!1,reason:"oauth_config_not_found"});case 13:return e.t1=Ot,e.next=16,se(I,(function(){return window.google.accounts.id}));case 16:return e.t2=e.sent,e.t3=this._publicToken,e.t4=t,i=new e.t1(e.t2,e.t3,e.t4),e.abrupt("return",{success:!0,client:i});case 21:case"end":return e.stop()}}),e,this,[[0,7]])})))}},{key:"fetchGoogleStart",value:function(){return this.googleConfig||(this.googleConfig=this.clientsideServices.oneTapStart({publicToken:this._publicToken})),this.googleConfig}},{key:"submitGoogleOneTapToken",value:function(e){var t=e.credential,r=e.loginRedirectUrl,n=e.signupRedirectUrl;return rt(this,void 0,void 0,u().mark((function e(){var i,o;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.fetchGoogleStart();case 2:return i=e.sent,o=i.oauthCallbackId,e.abrupt("return",this.clientsideServices.oneTapSubmit({publicToken:this._publicToken,idToken:t,loginRedirectURL:r,oauthCallbackID:o,signupRedirectURL:n}));case 5:case"end":return e.stop()}}),e,this)})))}}],[{key:"WillGoogleOneTapShowBannerForUA",value:function(e){var t=function(e,t){return-1!==e.indexOf(t)},r=t(e,"iPad")||t(e,"Android")&&!t(e,"Mobile")||t(e,"Silk"),n=t(e,"iPod")||t(e,"iPhone")||t(e,"Android")||t(e,"IEMobile");return!r&&n}},{key:"WillGoogleOneTapShowEmbedded",value:function(){return!e.WillGoogleOneTapShowBannerForUA(navigator.userAgent)}}]),e}();function Et(e){var t=e.toString(16);return 1===t.length&&(t="0"+t),t}var xt=function(){function e(t,r){h(this,e),this._dataLayer=t,this.namespace=r}return p(e,[{key:"key",value:function(){return"PKCE_VERIFIER:"+this.namespace}},{key:"startPKCETransaction",value:function(){return rt(this,void 0,void 0,u().mark((function t(){var r;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.createProofkeyPair();case 2:return r=t.sent,this._dataLayer.setItem(this.key(),JSON.stringify(r)),t.abrupt("return",r);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getPKPair",value:function(){var e=this._dataLayer.getItem(this.key());if(null!==e)try{return JSON.parse(e)}catch(e){return void le("Found malformed Proof Key pair in localstorage.")}}},{key:"clearPKPair",value:function(){return this._dataLayer.removeItem(this.key())}}],[{key:"createProofkeyPair",value:function(){return rt(this,void 0,void 0,u().mark((function e(){var r,n,i;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new Uint32Array(16),window.crypto.getRandomValues(r),n=Array.from(r).map(Et).join(""),e.next=5,window.crypto.subtle.digest("SHA-256",(new TextEncoder).encode(n));case 5:return i=e.sent,e.abrupt("return",{code_challenge:(o=i,s=void 0,btoa((s=String.fromCharCode).call.apply(s,[null].concat(t(new Uint8Array(o))))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")),code_verifier:n});case 7:case"end":return e.stop()}var o,s}),e)})))}}]),e}(),Ct=function(){function e(t){h(this,e),this._networkClient=t}return p(e,[{key:"searchUser",value:function(e){return this._networkClient.fetchSDK({url:"/users/search",method:"POST",body:{email:e},errorMessage:"Error searching for user ".concat(e)})}},{key:"searchOrganization",value:function(e){return this._networkClient.fetchSDK({url:"/b2b/organizations/search",method:"POST",body:{organization_slug:e},errorMessage:"Error searching slug"})}},{key:"searchMember",value:function(e,t){return this._networkClient.fetchSDK({url:"/b2b/organizations/members/search",method:"POST",body:{email_address:e,organization_id:t},errorMessage:"Error searching for member ".concat(e)})}}]),e}(),At=function(t){return(document.cookie?document.cookie.split("; "):[]).filter((function(r){var n=e(r.split("="),1)[0];return t===n})).length>1};
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
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; }
|
|
4
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
5
|
+
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."); }
|
|
6
|
+
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; } }
|
|
7
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
8
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
9
|
+
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."); }
|
|
10
|
+
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); }
|
|
11
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
12
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
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 _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); }
|
|
15
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
16
|
+
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); }; }
|
|
17
|
+
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); }
|
|
18
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
19
|
+
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; } }
|
|
20
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
21
|
+
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; }
|
|
22
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
23
|
+
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); } }
|
|
24
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
25
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
26
|
+
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); }
|
|
27
|
+
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); }
|
|
28
|
+
function e(e, t) {
|
|
29
|
+
var _n = "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
|
|
30
|
+
if (!_n) {
|
|
31
|
+
if (Array.isArray(e) || (_n = r(e)) || t && e && "number" == typeof e.length) {
|
|
32
|
+
_n && (e = _n);
|
|
33
|
+
var i = 0,
|
|
34
|
+
o = function o() {};
|
|
35
|
+
return {
|
|
36
|
+
s: o,
|
|
37
|
+
n: function n() {
|
|
38
|
+
return i >= e.length ? {
|
|
39
|
+
done: !0
|
|
40
|
+
} : {
|
|
41
|
+
done: !1,
|
|
42
|
+
value: e[i++]
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
e: function e(_e2) {
|
|
46
|
+
throw _e2;
|
|
47
|
+
},
|
|
48
|
+
f: o
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
52
|
+
}
|
|
53
|
+
var s,
|
|
54
|
+
a = !0,
|
|
55
|
+
c = !1;
|
|
56
|
+
return {
|
|
57
|
+
s: function s() {
|
|
58
|
+
_n = _n.call(e);
|
|
59
|
+
},
|
|
60
|
+
n: function n() {
|
|
61
|
+
var e = _n.next();
|
|
62
|
+
return a = e.done, e;
|
|
63
|
+
},
|
|
64
|
+
e: function e(_e3) {
|
|
65
|
+
c = !0, s = _e3;
|
|
66
|
+
},
|
|
67
|
+
f: function f() {
|
|
68
|
+
try {
|
|
69
|
+
a || null == _n["return"] || _n["return"]();
|
|
70
|
+
} finally {
|
|
71
|
+
if (c) throw s;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function t(e, t) {
|
|
77
|
+
return function (e) {
|
|
78
|
+
if (Array.isArray(e)) return e;
|
|
79
|
+
}(e) || function (e, t) {
|
|
80
|
+
var r = null == e ? null : "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
|
|
81
|
+
if (null != r) {
|
|
82
|
+
var n,
|
|
83
|
+
i,
|
|
84
|
+
o,
|
|
85
|
+
s,
|
|
86
|
+
a = [],
|
|
87
|
+
c = !0,
|
|
88
|
+
u = !1;
|
|
89
|
+
try {
|
|
90
|
+
if (o = (r = r.call(e)).next, 0 === t) {
|
|
91
|
+
if (Object(r) !== r) return;
|
|
92
|
+
c = !1;
|
|
93
|
+
} else for (; !(c = (n = o.call(r)).done) && (a.push(n.value), a.length !== t); c = !0);
|
|
94
|
+
} catch (e) {
|
|
95
|
+
u = !0, i = e;
|
|
96
|
+
} finally {
|
|
97
|
+
try {
|
|
98
|
+
if (!c && null != r["return"] && (s = r["return"](), Object(s) !== s)) return;
|
|
99
|
+
} finally {
|
|
100
|
+
if (u) throw i;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return a;
|
|
104
|
+
}
|
|
105
|
+
}(e, t) || r(e, t) || function () {
|
|
106
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
107
|
+
}();
|
|
108
|
+
}
|
|
109
|
+
function r(e, t) {
|
|
110
|
+
if (e) {
|
|
111
|
+
if ("string" == typeof e) return n(e, t);
|
|
112
|
+
var r = Object.prototype.toString.call(e).slice(8, -1);
|
|
113
|
+
return "Object" === r && e.constructor && (r = e.constructor.name), "Map" === r || "Set" === r ? Array.from(e) : "Arguments" === r || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? n(e, t) : void 0;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function n(e, t) {
|
|
117
|
+
(null == t || t > e.length) && (t = e.length);
|
|
118
|
+
for (var r = 0, n = new Array(t); r < t; r++) n[r] = e[r];
|
|
119
|
+
return n;
|
|
120
|
+
}
|
|
121
|
+
function i(e) {
|
|
122
|
+
return i = "function" == typeof Symbol && "symbol" == _typeof(Symbol.iterator) ? function (e) {
|
|
123
|
+
return _typeof(e);
|
|
124
|
+
} : function (e) {
|
|
125
|
+
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : _typeof(e);
|
|
126
|
+
}, i(e);
|
|
127
|
+
}
|
|
128
|
+
function o() {
|
|
129
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
130
|
+
o = function o() {
|
|
131
|
+
return e;
|
|
132
|
+
};
|
|
133
|
+
var e = {},
|
|
134
|
+
t = Object.prototype,
|
|
135
|
+
r = t.hasOwnProperty,
|
|
136
|
+
n = Object.defineProperty || function (e, t, r) {
|
|
137
|
+
e[t] = r.value;
|
|
138
|
+
},
|
|
139
|
+
s = "function" == typeof Symbol ? Symbol : {},
|
|
140
|
+
a = s.iterator || "@@iterator",
|
|
141
|
+
c = s.asyncIterator || "@@asyncIterator",
|
|
142
|
+
u = s.toStringTag || "@@toStringTag";
|
|
143
|
+
function l(e, t, r) {
|
|
144
|
+
return Object.defineProperty(e, t, {
|
|
145
|
+
value: r,
|
|
146
|
+
enumerable: !0,
|
|
147
|
+
configurable: !0,
|
|
148
|
+
writable: !0
|
|
149
|
+
}), e[t];
|
|
150
|
+
}
|
|
151
|
+
try {
|
|
152
|
+
l({}, "");
|
|
153
|
+
} catch (e) {
|
|
154
|
+
l = function l(e, t, r) {
|
|
155
|
+
return e[t] = r;
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function d(e, t, r, i) {
|
|
159
|
+
var o = t && t.prototype instanceof f ? t : f,
|
|
160
|
+
s = Object.create(o.prototype),
|
|
161
|
+
a = new C(i || []);
|
|
162
|
+
return n(s, "_invoke", {
|
|
163
|
+
value: S(e, r, a)
|
|
164
|
+
}), s;
|
|
165
|
+
}
|
|
166
|
+
function h(e, t, r) {
|
|
167
|
+
try {
|
|
168
|
+
return {
|
|
169
|
+
type: "normal",
|
|
170
|
+
arg: e.call(t, r)
|
|
171
|
+
};
|
|
172
|
+
} catch (e) {
|
|
173
|
+
return {
|
|
174
|
+
type: "throw",
|
|
175
|
+
arg: e
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
e.wrap = d;
|
|
180
|
+
var p = {};
|
|
181
|
+
function f() {}
|
|
182
|
+
function _() {}
|
|
183
|
+
function v() {}
|
|
184
|
+
var m = {};
|
|
185
|
+
l(m, a, function () {
|
|
186
|
+
return this;
|
|
187
|
+
});
|
|
188
|
+
var y = Object.getPrototypeOf,
|
|
189
|
+
g = y && y(y(x([])));
|
|
190
|
+
g && g !== t && r.call(g, a) && (m = g);
|
|
191
|
+
var b = v.prototype = f.prototype = Object.create(m);
|
|
192
|
+
function w(e) {
|
|
193
|
+
["next", "throw", "return"].forEach(function (t) {
|
|
194
|
+
l(e, t, function (e) {
|
|
195
|
+
return this._invoke(t, e);
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
function k(e, t) {
|
|
200
|
+
function o(n, s, a, c) {
|
|
201
|
+
var u = h(e[n], e, s);
|
|
202
|
+
if ("throw" !== u.type) {
|
|
203
|
+
var l = u.arg,
|
|
204
|
+
d = l.value;
|
|
205
|
+
return d && "object" == i(d) && r.call(d, "__await") ? t.resolve(d.__await).then(function (e) {
|
|
206
|
+
o("next", e, a, c);
|
|
207
|
+
}, function (e) {
|
|
208
|
+
o("throw", e, a, c);
|
|
209
|
+
}) : t.resolve(d).then(function (e) {
|
|
210
|
+
l.value = e, a(l);
|
|
211
|
+
}, function (e) {
|
|
212
|
+
return o("throw", e, a, c);
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
c(u.arg);
|
|
216
|
+
}
|
|
217
|
+
var s;
|
|
218
|
+
n(this, "_invoke", {
|
|
219
|
+
value: function value(e, r) {
|
|
220
|
+
function n() {
|
|
221
|
+
return new t(function (t, n) {
|
|
222
|
+
o(e, r, t, n);
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
return s = s ? s.then(n, n) : n();
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
function S(e, t, r) {
|
|
230
|
+
var n = "suspendedStart";
|
|
231
|
+
return function (i, o) {
|
|
232
|
+
if ("executing" === n) throw new Error("Generator is already running");
|
|
233
|
+
if ("completed" === n) {
|
|
234
|
+
if ("throw" === i) throw o;
|
|
235
|
+
return A();
|
|
236
|
+
}
|
|
237
|
+
for (r.method = i, r.arg = o;;) {
|
|
238
|
+
var s = r.delegate;
|
|
239
|
+
if (s) {
|
|
240
|
+
var a = T(s, r);
|
|
241
|
+
if (a) {
|
|
242
|
+
if (a === p) continue;
|
|
243
|
+
return a;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
if ("next" === r.method) r.sent = r._sent = r.arg;else if ("throw" === r.method) {
|
|
247
|
+
if ("suspendedStart" === n) throw n = "completed", r.arg;
|
|
248
|
+
r.dispatchException(r.arg);
|
|
249
|
+
} else "return" === r.method && r.abrupt("return", r.arg);
|
|
250
|
+
n = "executing";
|
|
251
|
+
var c = h(e, t, r);
|
|
252
|
+
if ("normal" === c.type) {
|
|
253
|
+
if (n = r.done ? "completed" : "suspendedYield", c.arg === p) continue;
|
|
254
|
+
return {
|
|
255
|
+
value: c.arg,
|
|
256
|
+
done: r.done
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
"throw" === c.type && (n = "completed", r.method = "throw", r.arg = c.arg);
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
function T(e, t) {
|
|
264
|
+
var r = t.method,
|
|
265
|
+
n = e.iterator[r];
|
|
266
|
+
if (void 0 === n) return t.delegate = null, "throw" === r && e.iterator["return"] && (t.method = "return", t.arg = void 0, T(e, t), "throw" === t.method) || "return" !== r && (t.method = "throw", t.arg = new TypeError("The iterator does not provide a '" + r + "' method")), p;
|
|
267
|
+
var i = h(n, e.iterator, t.arg);
|
|
268
|
+
if ("throw" === i.type) return t.method = "throw", t.arg = i.arg, t.delegate = null, p;
|
|
269
|
+
var o = i.arg;
|
|
270
|
+
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, p) : o : (t.method = "throw", t.arg = new TypeError("iterator result is not an object"), t.delegate = null, p);
|
|
271
|
+
}
|
|
272
|
+
function O(e) {
|
|
273
|
+
var t = {
|
|
274
|
+
tryLoc: e[0]
|
|
275
|
+
};
|
|
276
|
+
1 in e && (t.catchLoc = e[1]), 2 in e && (t.finallyLoc = e[2], t.afterLoc = e[3]), this.tryEntries.push(t);
|
|
277
|
+
}
|
|
278
|
+
function E(e) {
|
|
279
|
+
var t = e.completion || {};
|
|
280
|
+
t.type = "normal", delete t.arg, e.completion = t;
|
|
281
|
+
}
|
|
282
|
+
function C(e) {
|
|
283
|
+
this.tryEntries = [{
|
|
284
|
+
tryLoc: "root"
|
|
285
|
+
}], e.forEach(O, this), this.reset(!0);
|
|
286
|
+
}
|
|
287
|
+
function x(e) {
|
|
288
|
+
if (e) {
|
|
289
|
+
var t = e[a];
|
|
290
|
+
if (t) return t.call(e);
|
|
291
|
+
if ("function" == typeof e.next) return e;
|
|
292
|
+
if (!isNaN(e.length)) {
|
|
293
|
+
var n = -1,
|
|
294
|
+
i = function t() {
|
|
295
|
+
for (; ++n < e.length;) if (r.call(e, n)) return t.value = e[n], t.done = !1, t;
|
|
296
|
+
return t.value = void 0, t.done = !0, t;
|
|
297
|
+
};
|
|
298
|
+
return i.next = i;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return {
|
|
302
|
+
next: A
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
function A() {
|
|
306
|
+
return {
|
|
307
|
+
value: void 0,
|
|
308
|
+
done: !0
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
return _.prototype = v, n(b, "constructor", {
|
|
312
|
+
value: v,
|
|
313
|
+
configurable: !0
|
|
314
|
+
}), n(v, "constructor", {
|
|
315
|
+
value: _,
|
|
316
|
+
configurable: !0
|
|
317
|
+
}), _.displayName = l(v, u, "GeneratorFunction"), e.isGeneratorFunction = function (e) {
|
|
318
|
+
var t = "function" == typeof e && e.constructor;
|
|
319
|
+
return !!t && (t === _ || "GeneratorFunction" === (t.displayName || t.name));
|
|
320
|
+
}, e.mark = function (e) {
|
|
321
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(e, v) : (e.__proto__ = v, l(e, u, "GeneratorFunction")), e.prototype = Object.create(b), e;
|
|
322
|
+
}, e.awrap = function (e) {
|
|
323
|
+
return {
|
|
324
|
+
__await: e
|
|
325
|
+
};
|
|
326
|
+
}, w(k.prototype), l(k.prototype, c, function () {
|
|
327
|
+
return this;
|
|
328
|
+
}), e.AsyncIterator = k, e.async = function (t, r, n, i, o) {
|
|
329
|
+
void 0 === o && (o = Promise);
|
|
330
|
+
var s = new k(d(t, r, n, i), o);
|
|
331
|
+
return e.isGeneratorFunction(r) ? s : s.next().then(function (e) {
|
|
332
|
+
return e.done ? e.value : s.next();
|
|
333
|
+
});
|
|
334
|
+
}, w(b), l(b, u, "Generator"), l(b, a, function () {
|
|
335
|
+
return this;
|
|
336
|
+
}), l(b, "toString", function () {
|
|
337
|
+
return "[object Generator]";
|
|
338
|
+
}), e.keys = function (e) {
|
|
339
|
+
var t = Object(e),
|
|
340
|
+
r = [];
|
|
341
|
+
for (var n in t) r.push(n);
|
|
342
|
+
return r.reverse(), function e() {
|
|
343
|
+
for (; r.length;) {
|
|
344
|
+
var n = r.pop();
|
|
345
|
+
if (n in t) return e.value = n, e.done = !1, e;
|
|
346
|
+
}
|
|
347
|
+
return e.done = !0, e;
|
|
348
|
+
};
|
|
349
|
+
}, e.values = x, C.prototype = {
|
|
350
|
+
constructor: C,
|
|
351
|
+
reset: function reset(e) {
|
|
352
|
+
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(E), !e) for (var t in this) "t" === t.charAt(0) && r.call(this, t) && !isNaN(+t.slice(1)) && (this[t] = void 0);
|
|
353
|
+
},
|
|
354
|
+
stop: function stop() {
|
|
355
|
+
this.done = !0;
|
|
356
|
+
var e = this.tryEntries[0].completion;
|
|
357
|
+
if ("throw" === e.type) throw e.arg;
|
|
358
|
+
return this.rval;
|
|
359
|
+
},
|
|
360
|
+
dispatchException: function dispatchException(e) {
|
|
361
|
+
if (this.done) throw e;
|
|
362
|
+
var t = this;
|
|
363
|
+
function n(r, n) {
|
|
364
|
+
return s.type = "throw", s.arg = e, t.next = r, n && (t.method = "next", t.arg = void 0), !!n;
|
|
365
|
+
}
|
|
366
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
367
|
+
var o = this.tryEntries[i],
|
|
368
|
+
s = o.completion;
|
|
369
|
+
if ("root" === o.tryLoc) return n("end");
|
|
370
|
+
if (o.tryLoc <= this.prev) {
|
|
371
|
+
var a = r.call(o, "catchLoc"),
|
|
372
|
+
c = r.call(o, "finallyLoc");
|
|
373
|
+
if (a && c) {
|
|
374
|
+
if (this.prev < o.catchLoc) return n(o.catchLoc, !0);
|
|
375
|
+
if (this.prev < o.finallyLoc) return n(o.finallyLoc);
|
|
376
|
+
} else if (a) {
|
|
377
|
+
if (this.prev < o.catchLoc) return n(o.catchLoc, !0);
|
|
378
|
+
} else {
|
|
379
|
+
if (!c) throw new Error("try statement without catch or finally");
|
|
380
|
+
if (this.prev < o.finallyLoc) return n(o.finallyLoc);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
},
|
|
385
|
+
abrupt: function abrupt(e, t) {
|
|
386
|
+
for (var n = this.tryEntries.length - 1; n >= 0; --n) {
|
|
387
|
+
var i = this.tryEntries[n];
|
|
388
|
+
if (i.tryLoc <= this.prev && r.call(i, "finallyLoc") && this.prev < i.finallyLoc) {
|
|
389
|
+
var o = i;
|
|
390
|
+
break;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
o && ("break" === e || "continue" === e) && o.tryLoc <= t && t <= o.finallyLoc && (o = null);
|
|
394
|
+
var s = o ? o.completion : {};
|
|
395
|
+
return s.type = e, s.arg = t, o ? (this.method = "next", this.next = o.finallyLoc, p) : this.complete(s);
|
|
396
|
+
},
|
|
397
|
+
complete: function complete(e, t) {
|
|
398
|
+
if ("throw" === e.type) throw e.arg;
|
|
399
|
+
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), p;
|
|
400
|
+
},
|
|
401
|
+
finish: function finish(e) {
|
|
402
|
+
for (var t = this.tryEntries.length - 1; t >= 0; --t) {
|
|
403
|
+
var r = this.tryEntries[t];
|
|
404
|
+
if (r.finallyLoc === e) return this.complete(r.completion, r.afterLoc), E(r), p;
|
|
405
|
+
}
|
|
406
|
+
},
|
|
407
|
+
"catch": function _catch(e) {
|
|
408
|
+
for (var t = this.tryEntries.length - 1; t >= 0; --t) {
|
|
409
|
+
var r = this.tryEntries[t];
|
|
410
|
+
if (r.tryLoc === e) {
|
|
411
|
+
var n = r.completion;
|
|
412
|
+
if ("throw" === n.type) {
|
|
413
|
+
var i = n.arg;
|
|
414
|
+
E(r);
|
|
415
|
+
}
|
|
416
|
+
return i;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
throw new Error("illegal catch attempt");
|
|
420
|
+
},
|
|
421
|
+
delegateYield: function delegateYield(e, t, r) {
|
|
422
|
+
return this.delegate = {
|
|
423
|
+
iterator: x(e),
|
|
424
|
+
resultName: t,
|
|
425
|
+
nextLoc: r
|
|
426
|
+
}, "next" === this.method && (this.arg = void 0), p;
|
|
427
|
+
}
|
|
428
|
+
}, e;
|
|
429
|
+
}
|
|
430
|
+
function s(e, t) {
|
|
431
|
+
for (var r = 0; r < t.length; r++) {
|
|
432
|
+
var n = t[r];
|
|
433
|
+
n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(e, (o = n.key, s = void 0, s = function (e, t) {
|
|
434
|
+
if ("object" !== i(e) || null === e) return e;
|
|
435
|
+
var r = e[Symbol.toPrimitive];
|
|
436
|
+
if (void 0 !== r) {
|
|
437
|
+
var n = r.call(e, t || "default");
|
|
438
|
+
if ("object" !== i(n)) return n;
|
|
439
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
440
|
+
}
|
|
441
|
+
return ("string" === t ? String : Number)(e);
|
|
442
|
+
}(o, "string"), "symbol" === i(s) ? s : String(s)), n);
|
|
443
|
+
}
|
|
444
|
+
var o, s;
|
|
445
|
+
}
|
|
446
|
+
function a(e, t, r) {
|
|
447
|
+
return t && s(e.prototype, t), r && s(e, r), Object.defineProperty(e, "prototype", {
|
|
448
|
+
writable: !1
|
|
449
|
+
}), e;
|
|
450
|
+
}
|
|
451
|
+
function c(e, t) {
|
|
452
|
+
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
|
|
453
|
+
}
|
|
454
|
+
function u(e, t) {
|
|
455
|
+
if ("function" != typeof t && null !== t) throw new TypeError("Super expression must either be null or a function");
|
|
456
|
+
e.prototype = Object.create(t && t.prototype, {
|
|
457
|
+
constructor: {
|
|
458
|
+
value: e,
|
|
459
|
+
writable: !0,
|
|
460
|
+
configurable: !0
|
|
461
|
+
}
|
|
462
|
+
}), Object.defineProperty(e, "prototype", {
|
|
463
|
+
writable: !1
|
|
464
|
+
}), t && _(e, t);
|
|
465
|
+
}
|
|
466
|
+
function l(e) {
|
|
467
|
+
var t = f();
|
|
468
|
+
return function () {
|
|
469
|
+
var r,
|
|
470
|
+
n = v(e);
|
|
471
|
+
if (t) {
|
|
472
|
+
var o = v(this).constructor;
|
|
473
|
+
r = Reflect.construct(n, arguments, o);
|
|
474
|
+
} else r = n.apply(this, arguments);
|
|
475
|
+
return function (e, t) {
|
|
476
|
+
if (t && ("object" === i(t) || "function" == typeof t)) return t;
|
|
477
|
+
if (void 0 !== t) throw new TypeError("Derived constructors may only return object or undefined");
|
|
478
|
+
return d(e);
|
|
479
|
+
}(this, r);
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
function d(e) {
|
|
483
|
+
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
484
|
+
return e;
|
|
485
|
+
}
|
|
486
|
+
function h(e) {
|
|
487
|
+
var t = "function" == typeof Map ? new Map() : void 0;
|
|
488
|
+
return h = function h(e) {
|
|
489
|
+
if (null === e || (r = e, -1 === Function.toString.call(r).indexOf("[native code]"))) return e;
|
|
490
|
+
var r;
|
|
491
|
+
if ("function" != typeof e) throw new TypeError("Super expression must either be null or a function");
|
|
492
|
+
if (void 0 !== t) {
|
|
493
|
+
if (t.has(e)) return t.get(e);
|
|
494
|
+
t.set(e, n);
|
|
495
|
+
}
|
|
496
|
+
function n() {
|
|
497
|
+
return p(e, arguments, v(this).constructor);
|
|
498
|
+
}
|
|
499
|
+
return n.prototype = Object.create(e.prototype, {
|
|
500
|
+
constructor: {
|
|
501
|
+
value: n,
|
|
502
|
+
enumerable: !1,
|
|
503
|
+
writable: !0,
|
|
504
|
+
configurable: !0
|
|
505
|
+
}
|
|
506
|
+
}), _(n, e);
|
|
507
|
+
}, h(e);
|
|
508
|
+
}
|
|
509
|
+
function p(e, t, r) {
|
|
510
|
+
return p = f() ? Reflect.construct.bind() : function (e, t, r) {
|
|
511
|
+
var n = [null];
|
|
512
|
+
n.push.apply(n, t);
|
|
513
|
+
var i = new (Function.bind.apply(e, n))();
|
|
514
|
+
return r && _(i, r.prototype), i;
|
|
515
|
+
}, p.apply(null, arguments);
|
|
516
|
+
}
|
|
517
|
+
function f() {
|
|
518
|
+
if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
|
|
519
|
+
if (Reflect.construct.sham) return !1;
|
|
520
|
+
if ("function" == typeof Proxy) return !0;
|
|
521
|
+
try {
|
|
522
|
+
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})), !0;
|
|
523
|
+
} catch (e) {
|
|
524
|
+
return !1;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
function _(e, t) {
|
|
528
|
+
return _ = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (e, t) {
|
|
529
|
+
return e.__proto__ = t, e;
|
|
530
|
+
}, _(e, t);
|
|
531
|
+
}
|
|
532
|
+
function v(e) {
|
|
533
|
+
return v = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (e) {
|
|
534
|
+
return e.__proto__ || Object.getPrototypeOf(e);
|
|
535
|
+
}, v(e);
|
|
536
|
+
}
|
|
537
|
+
Object.defineProperty(exports, "__esModule", {
|
|
538
|
+
value: !0
|
|
539
|
+
});
|
|
540
|
+
var m,
|
|
541
|
+
y = "https://accounts.google.com/gsi",
|
|
542
|
+
g = "".concat(y, "/client");
|
|
543
|
+
function b(e, t) {
|
|
544
|
+
var r = {};
|
|
545
|
+
for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && t.indexOf(n) < 0 && (r[n] = e[n]);
|
|
546
|
+
if (null != e && "function" == typeof Object.getOwnPropertySymbols) {
|
|
547
|
+
var i = 0;
|
|
548
|
+
for (n = Object.getOwnPropertySymbols(e); i < n.length; i++) t.indexOf(n[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[i]) && (r[n[i]] = e[n[i]]);
|
|
549
|
+
}
|
|
550
|
+
return r;
|
|
551
|
+
}
|
|
552
|
+
function w(e, t, r, n) {
|
|
553
|
+
return new (r || (r = Promise))(function (i, o) {
|
|
554
|
+
function s(e) {
|
|
555
|
+
try {
|
|
556
|
+
c(n.next(e));
|
|
557
|
+
} catch (e) {
|
|
558
|
+
o(e);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
function a(e) {
|
|
562
|
+
try {
|
|
563
|
+
c(n["throw"](e));
|
|
564
|
+
} catch (e) {
|
|
565
|
+
o(e);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
function c(e) {
|
|
569
|
+
var t;
|
|
570
|
+
e.done ? i(e.value) : (t = e.value, t instanceof r ? t : new r(function (e) {
|
|
571
|
+
e(t);
|
|
572
|
+
})).then(s, a);
|
|
573
|
+
}
|
|
574
|
+
c((n = n.apply(e, t || [])).next());
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
var k = new Uint8Array(16);
|
|
578
|
+
function S() {
|
|
579
|
+
if (!m && !(m = "undefined" != typeof crypto && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || "undefined" != typeof msCrypto && "function" == typeof msCrypto.getRandomValues && msCrypto.getRandomValues.bind(msCrypto))) throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
580
|
+
return m(k);
|
|
581
|
+
}
|
|
582
|
+
var T = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
|
|
583
|
+
for (var O, E, C, x, A, P, R = [], B = 0; B < 256; ++B) R.push((B + 256).toString(16).substr(1));
|
|
584
|
+
function I(e) {
|
|
585
|
+
var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 0,
|
|
586
|
+
r = (R[e[t + 0]] + R[e[t + 1]] + R[e[t + 2]] + R[e[t + 3]] + "-" + R[e[t + 4]] + R[e[t + 5]] + "-" + R[e[t + 6]] + R[e[t + 7]] + "-" + R[e[t + 8]] + R[e[t + 9]] + "-" + R[e[t + 10]] + R[e[t + 11]] + R[e[t + 12]] + R[e[t + 13]] + R[e[t + 14]] + R[e[t + 15]]).toLowerCase();
|
|
587
|
+
if (!function (e) {
|
|
588
|
+
return "string" == typeof e && T.test(e);
|
|
589
|
+
}(r)) throw TypeError("Stringified UUID is invalid");
|
|
590
|
+
return r;
|
|
591
|
+
}
|
|
592
|
+
function D(e, t, r) {
|
|
593
|
+
var n = (e = e || {}).random || (e.rng || S)();
|
|
594
|
+
if (n[6] = 15 & n[6] | 64, n[8] = 63 & n[8] | 128, t) {
|
|
595
|
+
r = r || 0;
|
|
596
|
+
for (var i = 0; i < 16; ++i) t[r + i] = n[i];
|
|
597
|
+
return t;
|
|
598
|
+
}
|
|
599
|
+
return I(n);
|
|
600
|
+
}
|
|
601
|
+
!function (e) {
|
|
602
|
+
e.emailMagicLinks = "emailMagicLinks", e.oauth = "oauth", e.otp = "otp", e.crypto = "crypto", e.passwords = "passwords";
|
|
603
|
+
}(O || (O = {})), function (e) {
|
|
604
|
+
e.Google = "google", e.Microsoft = "microsoft", e.Apple = "apple", e.Github = "github", e.GitLab = "gitlab", e.Facebook = "facebook", e.Discord = "discord", e.Salesforce = "salesforce", e.Slack = "slack", e.Amazon = "amazon", e.Bitbucket = "bitbucket", e.LinkedIn = "linkedin", e.Coinbase = "coinbase", e.Twitch = "twitch", e.Twitter = "twitter", e.TikTok = "tiktok", e.Snapchat = "snapchat", e.Figma = "figma", e.Yahoo = "yahoo";
|
|
605
|
+
}(E || (E = {})), function (e) {
|
|
606
|
+
e.Vessel = "Vessel", e.Phantom = "Phantom", e.Metamask = "Metamask", e.Coinbase = "Coinbase", e.Binance = "Binance", e.GenericEthereumWallet = "Other Ethereum Wallet", e.GenericSolanaWallet = "Other Solana Wallet";
|
|
607
|
+
}(C || (C = {})), function (e) {
|
|
608
|
+
e.embedded = "embedded", e.floating = "floating";
|
|
609
|
+
}(x || (x = {})), function (e) {
|
|
610
|
+
e.SMS = "sms", e.WhatsApp = "whatsapp", e.Email = "email";
|
|
611
|
+
}(A || (A = {})), function (e) {
|
|
612
|
+
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";
|
|
613
|
+
}(P || (P = {}));
|
|
614
|
+
var L,
|
|
615
|
+
j,
|
|
616
|
+
M,
|
|
617
|
+
N,
|
|
618
|
+
U = function (e) {
|
|
619
|
+
u(r, h(Error));
|
|
620
|
+
var t = l(r);
|
|
621
|
+
function r(e, n) {
|
|
622
|
+
var i;
|
|
623
|
+
return c(this, r), (i = t.call(this, e + "\n" + n)).message = e + "\n" + n, i.name = "SDKAPIUnreachableError", i.details = n, Object.setPrototypeOf(d(i), r.prototype), i;
|
|
624
|
+
}
|
|
625
|
+
return a(r);
|
|
626
|
+
}(),
|
|
627
|
+
F = function (e) {
|
|
628
|
+
u(r, h(Error));
|
|
629
|
+
var t = l(r);
|
|
630
|
+
function r(e, n) {
|
|
631
|
+
var i;
|
|
632
|
+
return c(this, r), (i = t.call(this)).name = "StytchSDKUsageError", i.message = "Invalid call to ".concat(e, "\n") + n, i;
|
|
633
|
+
}
|
|
634
|
+
return a(r);
|
|
635
|
+
}(),
|
|
636
|
+
K = function (e) {
|
|
637
|
+
u(r, h(Error));
|
|
638
|
+
var t = l(r);
|
|
639
|
+
function r(e) {
|
|
640
|
+
var n, i;
|
|
641
|
+
c(this, r), (n = t.call(this)).name = "StytchSDKSchemaError";
|
|
642
|
+
var o = null === (i = e.body) || void 0 === i ? void 0 : i.map(function (e) {
|
|
643
|
+
return "".concat(e.dataPath, ": ").concat(e.message);
|
|
644
|
+
}).join("\n");
|
|
645
|
+
return n.message = "[400] Request does not match expected schema\n".concat(o), n;
|
|
646
|
+
}
|
|
647
|
+
return a(r);
|
|
648
|
+
}(),
|
|
649
|
+
q = function (e) {
|
|
650
|
+
u(r, h(Error));
|
|
651
|
+
var t = l(r);
|
|
652
|
+
function r(e) {
|
|
653
|
+
var n;
|
|
654
|
+
c(this, r), (n = t.call(this)).name = "StytchSDKAPIError";
|
|
655
|
+
var i = e.status_code,
|
|
656
|
+
o = e.error_type,
|
|
657
|
+
s = e.error_message,
|
|
658
|
+
a = e.error_url,
|
|
659
|
+
u = e.request_id;
|
|
660
|
+
return n.error_type = o, n.error_message = s, n.error_url = a, n.request_id = u, n.status_code = i, n.message = "[".concat(i, "] ").concat(o, "\n") + "".concat(s, "\n") + "See ".concat(a, " for more information.\n") + (u ? "request_id: ".concat(u, "\n") : ""), n;
|
|
661
|
+
}
|
|
662
|
+
return a(r);
|
|
663
|
+
}(),
|
|
664
|
+
W = ["unauthorized_credentials", "user_unauthenticated", "invalid_secret_authentication", "session_not_found"];
|
|
665
|
+
!function (e) {
|
|
666
|
+
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";
|
|
667
|
+
}(L || (L = {})), function (e) {
|
|
668
|
+
e.emailMagicLinks = "emailMagicLinks", e.sso = "sso", e.passwords = "passwords", e.oauth = "oauth";
|
|
669
|
+
}(j || (j = {})), function (e) {
|
|
670
|
+
e.Discovery = "Discovery", e.Organization = "Organization", e.PasswordReset = "PasswordReset";
|
|
671
|
+
}(M || (M = {})), function (e) {
|
|
672
|
+
e.Google = "google", e.Microsoft = "microsoft";
|
|
673
|
+
}(N || (N = {}));
|
|
674
|
+
var G = {};
|
|
675
|
+
function H(e, t) {
|
|
676
|
+
return w(this, void 0, void 0, o().mark(function r() {
|
|
677
|
+
return o().wrap(function (r) {
|
|
678
|
+
for (;;) switch (r.prev = r.next) {
|
|
679
|
+
case 0:
|
|
680
|
+
if (void 0 === G[e]) {
|
|
681
|
+
r.next = 2;
|
|
682
|
+
break;
|
|
683
|
+
}
|
|
684
|
+
return r.abrupt("return", G[e]);
|
|
685
|
+
case 2:
|
|
686
|
+
return G[e] = z(e, t), r.abrupt("return", G[e]);
|
|
687
|
+
case 4:
|
|
688
|
+
case "end":
|
|
689
|
+
return r.stop();
|
|
690
|
+
}
|
|
691
|
+
}, r);
|
|
692
|
+
}));
|
|
693
|
+
}
|
|
694
|
+
function z(e, t) {
|
|
695
|
+
return new Promise(function (r, n) {
|
|
696
|
+
var i = function (e) {
|
|
697
|
+
var t = Y(e);
|
|
698
|
+
if (t[0]) return t[0];
|
|
699
|
+
}(e);
|
|
700
|
+
if (i && "true" === i.dataset.loaded) try {
|
|
701
|
+
r(t());
|
|
702
|
+
} catch (t) {
|
|
703
|
+
return n(new Error("".concat(e, " already loaded, but module was not found in global scope: ").concat(t)));
|
|
704
|
+
}
|
|
705
|
+
var o = function (e) {
|
|
706
|
+
var t = document.createElement("script");
|
|
707
|
+
return t.setAttribute("src", e), t.setAttribute("async", "true"), t.setAttribute("defer", "true"), document.head.appendChild(t), t;
|
|
708
|
+
}(e);
|
|
709
|
+
o.addEventListener("load", function () {
|
|
710
|
+
o.dataset.loaded = "true";
|
|
711
|
+
try {
|
|
712
|
+
r(t());
|
|
713
|
+
} catch (t) {
|
|
714
|
+
n(new Error("".concat(e, " was loaded, but module was not found in global scope: ").concat(t)));
|
|
715
|
+
}
|
|
716
|
+
}), o.addEventListener("error", function (t) {
|
|
717
|
+
n(new Error("".concat(e, " could not be loaded: ").concat(t)));
|
|
718
|
+
});
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
var Y = function Y(e) {
|
|
722
|
+
return document.querySelectorAll('script[src="'.concat(e, '"]'));
|
|
723
|
+
};
|
|
724
|
+
var V = ["[Stytch]"],
|
|
725
|
+
J = function J() {
|
|
726
|
+
for (var e, t = arguments.length, r = new Array(t), n = 0; n < t; n++) r[n] = arguments[n];
|
|
727
|
+
return (e = console).warn.apply(e, V.concat(r));
|
|
728
|
+
},
|
|
729
|
+
$ = function $() {
|
|
730
|
+
for (var e, t = arguments.length, r = new Array(t), n = 0; n < t; n++) r[n] = arguments[n];
|
|
731
|
+
return (e = console).error.apply(e, V.concat(r));
|
|
732
|
+
},
|
|
733
|
+
X = "\nYou can find your public token at https://stytch.com/dashboard/api-keys.",
|
|
734
|
+
Z = function Z(t) {
|
|
735
|
+
var r = {
|
|
736
|
+
isObject: function isObject(e, n) {
|
|
737
|
+
var o = "object" === i(n) && !Array.isArray(n) && null !== n;
|
|
738
|
+
if (!o) throw new F(t, e + " must be an object.");
|
|
739
|
+
return r;
|
|
740
|
+
},
|
|
741
|
+
isOptionalObject: function isOptionalObject(e, t) {
|
|
742
|
+
return void 0 === t ? r : r.isObject(e, t);
|
|
743
|
+
},
|
|
744
|
+
isString: function isString(e, n) {
|
|
745
|
+
if ("string" != typeof n) throw new F(t, e + " must be a string.");
|
|
746
|
+
return r;
|
|
747
|
+
},
|
|
748
|
+
isOptionalString: function isOptionalString(e, t) {
|
|
749
|
+
return void 0 === t ? r : r.isString(e, t);
|
|
750
|
+
},
|
|
751
|
+
isStringArray: function isStringArray(n, i) {
|
|
752
|
+
if (!Array.isArray(i)) throw new F(t, n + " must be an array of strings.");
|
|
753
|
+
var o,
|
|
754
|
+
s = e(i);
|
|
755
|
+
try {
|
|
756
|
+
for (s.s(); !(o = s.n()).done;) {
|
|
757
|
+
if ("string" != typeof o.value) throw new F(t, n + " must be an array of strings.");
|
|
758
|
+
}
|
|
759
|
+
} catch (e) {
|
|
760
|
+
s.e(e);
|
|
761
|
+
} finally {
|
|
762
|
+
s.f();
|
|
763
|
+
}
|
|
764
|
+
return r;
|
|
765
|
+
},
|
|
766
|
+
isOptionalStringArray: function isOptionalStringArray(e, t) {
|
|
767
|
+
return void 0 === t ? r : r.isStringArray(e, t);
|
|
768
|
+
},
|
|
769
|
+
isNumber: function isNumber(e, n) {
|
|
770
|
+
if ("number" != typeof n) throw new F(t, e + " must be a number.");
|
|
771
|
+
return r;
|
|
772
|
+
},
|
|
773
|
+
isOptionalNumber: function isOptionalNumber(e, t) {
|
|
774
|
+
return void 0 === t ? r : r.isNumber(e, t);
|
|
775
|
+
},
|
|
776
|
+
isBoolean: function isBoolean(e, n) {
|
|
777
|
+
if ("boolean" != typeof n) throw new F(t, e + " must be a boolean.");
|
|
778
|
+
return r;
|
|
779
|
+
},
|
|
780
|
+
isOptionalBoolean: function isOptionalBoolean(e, t) {
|
|
781
|
+
return void 0 === t ? r : r.isBoolean(e, t);
|
|
782
|
+
}
|
|
783
|
+
};
|
|
784
|
+
return r;
|
|
785
|
+
},
|
|
786
|
+
Q = function Q(e) {
|
|
787
|
+
return b(e, ["request_id", "status_code"]);
|
|
788
|
+
},
|
|
789
|
+
ee = function ee(e) {
|
|
790
|
+
return b(e, ["__user"]);
|
|
791
|
+
},
|
|
792
|
+
te = a(function e(t, r, n) {
|
|
793
|
+
var i = this;
|
|
794
|
+
c(this, e), this.bootstrapPromise = n, this.isEnabled = function () {
|
|
795
|
+
return w(i, void 0, void 0, o().mark(function e() {
|
|
796
|
+
return o().wrap(function (e) {
|
|
797
|
+
for (;;) switch (e.prev = e.next) {
|
|
798
|
+
case 0:
|
|
799
|
+
return e.abrupt("return", this.state.then(function (e) {
|
|
800
|
+
return e.enabled;
|
|
801
|
+
}));
|
|
802
|
+
case 1:
|
|
803
|
+
case "end":
|
|
804
|
+
return e.stop();
|
|
805
|
+
}
|
|
806
|
+
}, e, this);
|
|
807
|
+
}));
|
|
808
|
+
}, this.getTelemetryID = function () {
|
|
809
|
+
return w(i, void 0, void 0, o().mark(function e() {
|
|
810
|
+
var t, r, n, i;
|
|
811
|
+
return o().wrap(function (e) {
|
|
812
|
+
for (;;) switch (e.prev = e.next) {
|
|
813
|
+
case 0:
|
|
814
|
+
return e.next = 2, this.state;
|
|
815
|
+
case 2:
|
|
816
|
+
if (t = e.sent, r = t.publicToken, n = t.enabled, i = t.dfpBackendURL, n) {
|
|
817
|
+
e.next = 8;
|
|
818
|
+
break;
|
|
819
|
+
}
|
|
820
|
+
return e.abrupt("return", void 0);
|
|
821
|
+
case 8:
|
|
822
|
+
return e.next = 10, window.GetTelemetryID(r, "".concat(i, "/submit"));
|
|
823
|
+
case 10:
|
|
824
|
+
return e.abrupt("return", e.sent);
|
|
825
|
+
case 11:
|
|
826
|
+
case "end":
|
|
827
|
+
return e.stop();
|
|
828
|
+
}
|
|
829
|
+
}, e, this);
|
|
830
|
+
}));
|
|
831
|
+
}, this.state = n.then(function (e) {
|
|
832
|
+
return w(i, void 0, void 0, o().mark(function n() {
|
|
833
|
+
return o().wrap(function (n) {
|
|
834
|
+
for (;;) switch (n.prev = n.next) {
|
|
835
|
+
case 0:
|
|
836
|
+
if (e.runDFPProtectedAuth) {
|
|
837
|
+
n.next = 2;
|
|
838
|
+
break;
|
|
839
|
+
}
|
|
840
|
+
return n.abrupt("return", {
|
|
841
|
+
publicToken: t,
|
|
842
|
+
dfpBackendURL: r,
|
|
843
|
+
enabled: !1,
|
|
844
|
+
loaded: !1
|
|
845
|
+
});
|
|
846
|
+
case 2:
|
|
847
|
+
return n.next = 4, void H("".concat("https://elements.stytch.com", "/telemetry.js"), function () {
|
|
848
|
+
return window;
|
|
849
|
+
});
|
|
850
|
+
case 4:
|
|
851
|
+
return n.abrupt("return", {
|
|
852
|
+
publicToken: t,
|
|
853
|
+
dfpBackendURL: r,
|
|
854
|
+
enabled: !0,
|
|
855
|
+
loaded: !0
|
|
856
|
+
});
|
|
857
|
+
case 5:
|
|
858
|
+
case "end":
|
|
859
|
+
return n.stop();
|
|
860
|
+
}
|
|
861
|
+
}, n);
|
|
862
|
+
}));
|
|
863
|
+
});
|
|
864
|
+
}),
|
|
865
|
+
re = function () {
|
|
866
|
+
function e() {
|
|
867
|
+
c(this, e);
|
|
868
|
+
}
|
|
869
|
+
return a(e, null, [{
|
|
870
|
+
key: "marshall",
|
|
871
|
+
value: function value(e) {
|
|
872
|
+
return Object.assign(Object.assign({}, e), {
|
|
873
|
+
name: e.name,
|
|
874
|
+
message: e.message,
|
|
875
|
+
stack: e.stack
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
}, {
|
|
879
|
+
key: "inflate",
|
|
880
|
+
value: function value(e, t) {
|
|
881
|
+
var r = new e(t);
|
|
882
|
+
return Object.assign(r, t), Object.setPrototypeOf(r, e.prototype), r;
|
|
883
|
+
}
|
|
884
|
+
}, {
|
|
885
|
+
key: "unmarshall",
|
|
886
|
+
value: function value(t) {
|
|
887
|
+
if ("name" in t) switch (t.name) {
|
|
888
|
+
case "SDKAPIUnreachableError":
|
|
889
|
+
return e.inflate(U, t);
|
|
890
|
+
case "StytchSDKSchemaError":
|
|
891
|
+
return e.inflate(K, t);
|
|
892
|
+
case "StytchSDKAPIError":
|
|
893
|
+
return e.inflate(q, t);
|
|
894
|
+
case "TypeError":
|
|
895
|
+
return e.inflate(TypeError, t);
|
|
896
|
+
case "SyntaxError":
|
|
897
|
+
return e.inflate(SyntaxError, t);
|
|
898
|
+
case "ReferenceError":
|
|
899
|
+
return e.inflate(ReferenceError, t);
|
|
900
|
+
case "RangeError":
|
|
901
|
+
return e.inflate(RangeError, t);
|
|
902
|
+
case "EvalError":
|
|
903
|
+
return e.inflate(EvalError, t);
|
|
904
|
+
case "URIError":
|
|
905
|
+
return e.inflate(URIError, t);
|
|
906
|
+
}
|
|
907
|
+
return e.inflate(Error, t);
|
|
908
|
+
}
|
|
909
|
+
}]), e;
|
|
910
|
+
}(),
|
|
911
|
+
ne = function () {
|
|
912
|
+
function e(t) {
|
|
913
|
+
c(this, e), this.maxBatchSize = t.maxBatchSize, this.logEventURL = t.logEventURL, setInterval(this.flush.bind(this), t.intervalDurationMs), this.batch = [];
|
|
914
|
+
}
|
|
915
|
+
return a(e, [{
|
|
916
|
+
key: "logEvent",
|
|
917
|
+
value: function value(e, t) {
|
|
918
|
+
this.batch.push({
|
|
919
|
+
telemetry: e,
|
|
920
|
+
event: t
|
|
921
|
+
}), this.batch.length >= this.maxBatchSize && this.flush();
|
|
922
|
+
}
|
|
923
|
+
}, {
|
|
924
|
+
key: "flush",
|
|
925
|
+
value: function value() {
|
|
926
|
+
return w(this, void 0, void 0, o().mark(function e() {
|
|
927
|
+
var t;
|
|
928
|
+
return o().wrap(function (e) {
|
|
929
|
+
for (;;) switch (e.prev = e.next) {
|
|
930
|
+
case 0:
|
|
931
|
+
if (this.batch.length) {
|
|
932
|
+
e.next = 2;
|
|
933
|
+
break;
|
|
934
|
+
}
|
|
935
|
+
return e.abrupt("return");
|
|
936
|
+
case 2:
|
|
937
|
+
return t = this.batch, this.batch = [], e.prev = 4, e.next = 7, fetch(this.logEventURL, {
|
|
938
|
+
method: "POST",
|
|
939
|
+
headers: {
|
|
940
|
+
"Content-Type": "application/json"
|
|
941
|
+
},
|
|
942
|
+
body: JSON.stringify(t)
|
|
943
|
+
});
|
|
944
|
+
case 7:
|
|
945
|
+
e.next = 11;
|
|
946
|
+
break;
|
|
947
|
+
case 9:
|
|
948
|
+
e.prev = 9, e.t0 = e["catch"](4);
|
|
949
|
+
case 11:
|
|
950
|
+
case "end":
|
|
951
|
+
return e.stop();
|
|
952
|
+
}
|
|
953
|
+
}, e, this, [[4, 9]]);
|
|
954
|
+
}));
|
|
955
|
+
}
|
|
956
|
+
}]), e;
|
|
957
|
+
}(),
|
|
958
|
+
ie = a(function e(t, r) {
|
|
959
|
+
var n = this;
|
|
960
|
+
c(this, e), this._networkClient = t, this._subscriptionService = r, this.get = function () {
|
|
961
|
+
return w(n, void 0, void 0, o().mark(function e() {
|
|
962
|
+
var t, r;
|
|
963
|
+
return o().wrap(function (e) {
|
|
964
|
+
for (;;) switch (e.prev = e.next) {
|
|
965
|
+
case 0:
|
|
966
|
+
return e.next = 2, this._networkClient.fetchSDK({
|
|
967
|
+
url: "/users/me",
|
|
968
|
+
errorMessage: "Failed to retrieve user info.",
|
|
969
|
+
method: "GET"
|
|
970
|
+
});
|
|
971
|
+
case 2:
|
|
972
|
+
return t = e.sent, r = Q(t), this._subscriptionService.updateUser(r), e.abrupt("return", r);
|
|
973
|
+
case 6:
|
|
974
|
+
case "end":
|
|
975
|
+
return e.stop();
|
|
976
|
+
}
|
|
977
|
+
}, e, this);
|
|
978
|
+
}));
|
|
979
|
+
}, this.getSync = function () {
|
|
980
|
+
return n._subscriptionService.getUser();
|
|
981
|
+
}, this.update = function (e) {
|
|
982
|
+
return w(n, void 0, void 0, o().mark(function t() {
|
|
983
|
+
var r, n;
|
|
984
|
+
return o().wrap(function (t) {
|
|
985
|
+
for (;;) switch (t.prev = t.next) {
|
|
986
|
+
case 0:
|
|
987
|
+
return Z("stytch.user.update").isOptionalObject("untrusted_metadata", e.untrusted_metadata), t.next = 3, this._networkClient.fetchSDK({
|
|
988
|
+
url: "/users/me",
|
|
989
|
+
body: e,
|
|
990
|
+
errorMessage: "Failed to update user.",
|
|
991
|
+
method: "PUT"
|
|
992
|
+
});
|
|
993
|
+
case 3:
|
|
994
|
+
return r = t.sent, n = Q(r.__user), this._subscriptionService.updateUser(n), t.abrupt("return", ee(r));
|
|
995
|
+
case 7:
|
|
996
|
+
case "end":
|
|
997
|
+
return t.stop();
|
|
998
|
+
}
|
|
999
|
+
}, t, this);
|
|
1000
|
+
}));
|
|
1001
|
+
}, this.deleteEmail = function (e) {
|
|
1002
|
+
return w(n, void 0, void 0, o().mark(function t() {
|
|
1003
|
+
var r, n;
|
|
1004
|
+
return o().wrap(function (t) {
|
|
1005
|
+
for (;;) switch (t.prev = t.next) {
|
|
1006
|
+
case 0:
|
|
1007
|
+
return t.next = 2, this._networkClient.fetchSDK({
|
|
1008
|
+
url: "/users/emails/".concat(e),
|
|
1009
|
+
errorMessage: "Failed to delete email.",
|
|
1010
|
+
method: "DELETE"
|
|
1011
|
+
});
|
|
1012
|
+
case 2:
|
|
1013
|
+
return r = t.sent, n = Q(r.__user), this._subscriptionService.updateUser(n), t.abrupt("return", ee(r));
|
|
1014
|
+
case 6:
|
|
1015
|
+
case "end":
|
|
1016
|
+
return t.stop();
|
|
1017
|
+
}
|
|
1018
|
+
}, t, this);
|
|
1019
|
+
}));
|
|
1020
|
+
}, this.deletePhoneNumber = function (e) {
|
|
1021
|
+
return w(n, void 0, void 0, o().mark(function t() {
|
|
1022
|
+
var r, n;
|
|
1023
|
+
return o().wrap(function (t) {
|
|
1024
|
+
for (;;) switch (t.prev = t.next) {
|
|
1025
|
+
case 0:
|
|
1026
|
+
return t.next = 2, this._networkClient.fetchSDK({
|
|
1027
|
+
url: "/users/phone_numbers/".concat(e),
|
|
1028
|
+
errorMessage: "Failed to delete phone number.",
|
|
1029
|
+
method: "DELETE"
|
|
1030
|
+
});
|
|
1031
|
+
case 2:
|
|
1032
|
+
return r = t.sent, n = Q(r.__user), this._subscriptionService.updateUser(n), t.abrupt("return", ee(r));
|
|
1033
|
+
case 6:
|
|
1034
|
+
case "end":
|
|
1035
|
+
return t.stop();
|
|
1036
|
+
}
|
|
1037
|
+
}, t, this);
|
|
1038
|
+
}));
|
|
1039
|
+
}, this.deleteTOTP = function (e) {
|
|
1040
|
+
return w(n, void 0, void 0, o().mark(function t() {
|
|
1041
|
+
var r, n;
|
|
1042
|
+
return o().wrap(function (t) {
|
|
1043
|
+
for (;;) switch (t.prev = t.next) {
|
|
1044
|
+
case 0:
|
|
1045
|
+
return t.next = 2, this._networkClient.fetchSDK({
|
|
1046
|
+
url: "/users/totps/".concat(e),
|
|
1047
|
+
errorMessage: "Failed to delete TOTP.",
|
|
1048
|
+
method: "DELETE"
|
|
1049
|
+
});
|
|
1050
|
+
case 2:
|
|
1051
|
+
return r = t.sent, n = Q(r.__user), this._subscriptionService.updateUser(n), t.abrupt("return", ee(r));
|
|
1052
|
+
case 6:
|
|
1053
|
+
case "end":
|
|
1054
|
+
return t.stop();
|
|
1055
|
+
}
|
|
1056
|
+
}, t, this);
|
|
1057
|
+
}));
|
|
1058
|
+
}, this.deleteOAuthRegistration = function (e) {
|
|
1059
|
+
return w(n, void 0, void 0, o().mark(function t() {
|
|
1060
|
+
var r, n;
|
|
1061
|
+
return o().wrap(function (t) {
|
|
1062
|
+
for (;;) switch (t.prev = t.next) {
|
|
1063
|
+
case 0:
|
|
1064
|
+
return t.next = 2, this._networkClient.fetchSDK({
|
|
1065
|
+
url: "/users/oauth/".concat(e),
|
|
1066
|
+
errorMessage: "Failed to delete OAuth registration.",
|
|
1067
|
+
method: "DELETE"
|
|
1068
|
+
});
|
|
1069
|
+
case 2:
|
|
1070
|
+
return r = t.sent, n = Q(r.__user), this._subscriptionService.updateUser(n), t.abrupt("return", ee(r));
|
|
1071
|
+
case 6:
|
|
1072
|
+
case "end":
|
|
1073
|
+
return t.stop();
|
|
1074
|
+
}
|
|
1075
|
+
}, t, this);
|
|
1076
|
+
}));
|
|
1077
|
+
}, this.deleteWebauthnRegistration = function (e) {
|
|
1078
|
+
return w(n, void 0, void 0, o().mark(function t() {
|
|
1079
|
+
var r, n;
|
|
1080
|
+
return o().wrap(function (t) {
|
|
1081
|
+
for (;;) switch (t.prev = t.next) {
|
|
1082
|
+
case 0:
|
|
1083
|
+
return t.next = 2, this._networkClient.fetchSDK({
|
|
1084
|
+
url: "/users/webauthn_registrations/".concat(e),
|
|
1085
|
+
errorMessage: "Failed to delete WebAuthn registration.",
|
|
1086
|
+
method: "DELETE"
|
|
1087
|
+
});
|
|
1088
|
+
case 2:
|
|
1089
|
+
return r = t.sent, n = Q(r.__user), this._subscriptionService.updateUser(n), t.abrupt("return", ee(r));
|
|
1090
|
+
case 6:
|
|
1091
|
+
case "end":
|
|
1092
|
+
return t.stop();
|
|
1093
|
+
}
|
|
1094
|
+
}, t, this);
|
|
1095
|
+
}));
|
|
1096
|
+
}, this.deleteBiometricRegistration = function (e) {
|
|
1097
|
+
return w(n, void 0, void 0, o().mark(function t() {
|
|
1098
|
+
var r, n;
|
|
1099
|
+
return o().wrap(function (t) {
|
|
1100
|
+
for (;;) switch (t.prev = t.next) {
|
|
1101
|
+
case 0:
|
|
1102
|
+
return t.next = 2, this._networkClient.fetchSDK({
|
|
1103
|
+
url: "/users/biometric_registrations/".concat(e),
|
|
1104
|
+
errorMessage: "Failed to delete Biometric registration.",
|
|
1105
|
+
method: "DELETE"
|
|
1106
|
+
});
|
|
1107
|
+
case 2:
|
|
1108
|
+
return r = t.sent, n = Q(r.__user), this._subscriptionService.updateUser(n), t.abrupt("return", ee(r));
|
|
1109
|
+
case 6:
|
|
1110
|
+
case "end":
|
|
1111
|
+
return t.stop();
|
|
1112
|
+
}
|
|
1113
|
+
}, t, this);
|
|
1114
|
+
}));
|
|
1115
|
+
}, this.onChange = function (e) {
|
|
1116
|
+
var t = n._subscriptionService.getUser();
|
|
1117
|
+
return n._subscriptionService.subscribeToState(function (r) {
|
|
1118
|
+
var n;
|
|
1119
|
+
(null == r ? void 0 : r.user) !== t && (t = null !== (n = null == r ? void 0 : r.user) && void 0 !== n ? n : null, e(t));
|
|
1120
|
+
});
|
|
1121
|
+
};
|
|
1122
|
+
}),
|
|
1123
|
+
oe = function () {
|
|
1124
|
+
function e(t, r) {
|
|
1125
|
+
var n = this;
|
|
1126
|
+
c(this, e), this._networkClient = t, this._subscriptionService = r, this.getSync = function () {
|
|
1127
|
+
return n._subscriptionService.getSession();
|
|
1128
|
+
}, this.onChange = function (e) {
|
|
1129
|
+
var t = n._subscriptionService.getSession();
|
|
1130
|
+
return n._subscriptionService.subscribeToState(function (r) {
|
|
1131
|
+
var n;
|
|
1132
|
+
(null == r ? void 0 : r.session) !== t && (t = null !== (n = null == r ? void 0 : r.session) && void 0 !== n ? n : null, e(t));
|
|
1133
|
+
});
|
|
1134
|
+
}, this.revoke = function (e) {
|
|
1135
|
+
return w(n, void 0, void 0, o().mark(function t() {
|
|
1136
|
+
var r;
|
|
1137
|
+
return o().wrap(function (t) {
|
|
1138
|
+
for (;;) switch (t.prev = t.next) {
|
|
1139
|
+
case 0:
|
|
1140
|
+
return t.prev = 0, t.next = 3, this._networkClient.fetchSDK({
|
|
1141
|
+
url: "/sessions/revoke",
|
|
1142
|
+
errorMessage: "Error revoking session",
|
|
1143
|
+
method: "POST"
|
|
1144
|
+
});
|
|
1145
|
+
case 3:
|
|
1146
|
+
return r = t.sent, this._subscriptionService.destroyState(), t.abrupt("return", r);
|
|
1147
|
+
case 8:
|
|
1148
|
+
throw t.prev = 8, t.t0 = t["catch"](0), ((null == e ? void 0 : e.forceClear) || W.includes(t.t0.error_type)) && this._subscriptionService.destroyState(), t.t0;
|
|
1149
|
+
case 12:
|
|
1150
|
+
case "end":
|
|
1151
|
+
return t.stop();
|
|
1152
|
+
}
|
|
1153
|
+
}, t, this, [[0, 8]]);
|
|
1154
|
+
}));
|
|
1155
|
+
}, this.authenticate = function (e) {
|
|
1156
|
+
return w(n, void 0, void 0, o().mark(function t() {
|
|
1157
|
+
var r, n;
|
|
1158
|
+
return o().wrap(function (t) {
|
|
1159
|
+
for (;;) switch (t.prev = t.next) {
|
|
1160
|
+
case 0:
|
|
1161
|
+
return t.prev = 0, r = {
|
|
1162
|
+
session_duration_minutes: null == e ? void 0 : e.session_duration_minutes
|
|
1163
|
+
}, t.next = 4, this._networkClient.fetchSDK({
|
|
1164
|
+
url: "/sessions/authenticate",
|
|
1165
|
+
body: r,
|
|
1166
|
+
errorMessage: "Error authenticating session",
|
|
1167
|
+
method: "POST"
|
|
1168
|
+
});
|
|
1169
|
+
case 4:
|
|
1170
|
+
return n = t.sent, this._subscriptionService.updateStateAndTokens({
|
|
1171
|
+
state: {
|
|
1172
|
+
session: n.session,
|
|
1173
|
+
user: n.user
|
|
1174
|
+
},
|
|
1175
|
+
session_token: n.session_token,
|
|
1176
|
+
session_jwt: n.session_jwt,
|
|
1177
|
+
intermediate_session_token: null
|
|
1178
|
+
}), t.abrupt("return", ee(n));
|
|
1179
|
+
case 9:
|
|
1180
|
+
throw t.prev = 9, t.t0 = t["catch"](0), W.includes(t.t0.error_type) && this._subscriptionService.destroyState(), t.t0;
|
|
1181
|
+
case 13:
|
|
1182
|
+
case "end":
|
|
1183
|
+
return t.stop();
|
|
1184
|
+
}
|
|
1185
|
+
}, t, this, [[0, 9]]);
|
|
1186
|
+
}));
|
|
1187
|
+
};
|
|
1188
|
+
}
|
|
1189
|
+
return a(e, [{
|
|
1190
|
+
key: "getTokens",
|
|
1191
|
+
value: function value() {
|
|
1192
|
+
return this._subscriptionService.getTokens();
|
|
1193
|
+
}
|
|
1194
|
+
}, {
|
|
1195
|
+
key: "updateSession",
|
|
1196
|
+
value: function value(e) {
|
|
1197
|
+
this._subscriptionService.updateTokens(e);
|
|
1198
|
+
}
|
|
1199
|
+
}]), e;
|
|
1200
|
+
}(),
|
|
1201
|
+
se = Promise.resolve({
|
|
1202
|
+
pkceRequiredForEmailMagicLinks: !1
|
|
1203
|
+
}),
|
|
1204
|
+
ae = function () {
|
|
1205
|
+
function e(t, r, n) {
|
|
1206
|
+
var i = this,
|
|
1207
|
+
s = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : se,
|
|
1208
|
+
a = arguments.length > 4 && void 0 !== arguments[4] ? arguments[4] : function () {
|
|
1209
|
+
return Promise.resolve(void 0);
|
|
1210
|
+
},
|
|
1211
|
+
u = arguments.length > 5 ? arguments[5] : void 0;
|
|
1212
|
+
c(this, e), this._networkClient = t, this._subscriptionService = r, this._pkceManager = n, this._config = s, this.executeRecaptcha = a, this._dfpProtectedAuth = u, this.email = {
|
|
1213
|
+
loginOrCreate: function loginOrCreate(e) {
|
|
1214
|
+
var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
|
|
1215
|
+
return w(i, void 0, void 0, o().mark(function r() {
|
|
1216
|
+
var n, i, s, a, c, u, l;
|
|
1217
|
+
return o().wrap(function (r) {
|
|
1218
|
+
for (;;) switch (r.prev = r.next) {
|
|
1219
|
+
case 0:
|
|
1220
|
+
return r.next = 2, this._config;
|
|
1221
|
+
case 2:
|
|
1222
|
+
if (n = r.sent, i = n.pkceRequiredForEmailMagicLinks, s = void 0, !i) {
|
|
1223
|
+
r.next = 9;
|
|
1224
|
+
break;
|
|
1225
|
+
}
|
|
1226
|
+
return r.next = 8, this.getCodeChallenge();
|
|
1227
|
+
case 8:
|
|
1228
|
+
s = r.sent;
|
|
1229
|
+
case 9:
|
|
1230
|
+
return r.next = 11, this.getDFPTelemetryIDAndCaptcha();
|
|
1231
|
+
case 11:
|
|
1232
|
+
return a = r.sent, c = a.dfp_telemetry_id, u = a.captcha_token, l = Object.assign(Object.assign({}, t), {
|
|
1233
|
+
email: e,
|
|
1234
|
+
code_challenge: s,
|
|
1235
|
+
captcha_token: u,
|
|
1236
|
+
dfp_telemetry_id: c
|
|
1237
|
+
}), r.abrupt("return", this._networkClient.fetchSDK({
|
|
1238
|
+
url: "/magic_links/email/login_or_create",
|
|
1239
|
+
body: l,
|
|
1240
|
+
errorMessage: "Failed to send magic link",
|
|
1241
|
+
method: "POST"
|
|
1242
|
+
}));
|
|
1243
|
+
case 16:
|
|
1244
|
+
case "end":
|
|
1245
|
+
return r.stop();
|
|
1246
|
+
}
|
|
1247
|
+
}, r, this);
|
|
1248
|
+
}));
|
|
1249
|
+
},
|
|
1250
|
+
send: function send(e) {
|
|
1251
|
+
var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
|
|
1252
|
+
return w(i, void 0, void 0, o().mark(function r() {
|
|
1253
|
+
var n, i, s, a, c, u, l, d, h;
|
|
1254
|
+
return o().wrap(function (r) {
|
|
1255
|
+
for (;;) switch (r.prev = r.next) {
|
|
1256
|
+
case 0:
|
|
1257
|
+
return r.next = 2, this._config;
|
|
1258
|
+
case 2:
|
|
1259
|
+
if (n = r.sent, i = n.pkceRequiredForEmailMagicLinks, s = void 0, !i) {
|
|
1260
|
+
r.next = 9;
|
|
1261
|
+
break;
|
|
1262
|
+
}
|
|
1263
|
+
return r.next = 8, this.getCodeChallenge();
|
|
1264
|
+
case 8:
|
|
1265
|
+
s = r.sent;
|
|
1266
|
+
case 9:
|
|
1267
|
+
return r.next = 11, this.getDFPTelemetryIDAndCaptcha();
|
|
1268
|
+
case 11:
|
|
1269
|
+
return a = r.sent, c = a.dfp_telemetry_id, u = a.captcha_token, l = Object.assign(Object.assign({}, t), {
|
|
1270
|
+
email: e,
|
|
1271
|
+
code_challenge: s,
|
|
1272
|
+
captcha_token: u,
|
|
1273
|
+
dfp_telemetry_id: c
|
|
1274
|
+
}), d = !!this._subscriptionService.getSession(), h = d ? "/magic_links/email/send/secondary" : "/magic_links/email/send/primary", r.abrupt("return", this._networkClient.fetchSDK({
|
|
1275
|
+
url: h,
|
|
1276
|
+
body: l,
|
|
1277
|
+
errorMessage: "Failed to send magic link",
|
|
1278
|
+
method: "POST"
|
|
1279
|
+
}));
|
|
1280
|
+
case 18:
|
|
1281
|
+
case "end":
|
|
1282
|
+
return r.stop();
|
|
1283
|
+
}
|
|
1284
|
+
}, r, this);
|
|
1285
|
+
}));
|
|
1286
|
+
}
|
|
1287
|
+
}, this.authenticate = function (e, t) {
|
|
1288
|
+
return w(i, void 0, void 0, o().mark(function r() {
|
|
1289
|
+
var n, i, s;
|
|
1290
|
+
return o().wrap(function (r) {
|
|
1291
|
+
for (;;) switch (r.prev = r.next) {
|
|
1292
|
+
case 0:
|
|
1293
|
+
return Z("stytch.magicLinks.authenticate").isString("Token", e).isNumber("session_duration_minutes", t.session_duration_minutes), r.next = 3, this._pkceManager.getPKPair();
|
|
1294
|
+
case 3:
|
|
1295
|
+
return n = r.sent, i = Object.assign({
|
|
1296
|
+
token: e,
|
|
1297
|
+
code_verifier: null == n ? void 0 : n.code_verifier
|
|
1298
|
+
}, t), r.next = 7, this._networkClient.fetchSDK({
|
|
1299
|
+
url: "/magic_links/authenticate",
|
|
1300
|
+
body: i,
|
|
1301
|
+
errorMessage: "Failed to authenticate token.",
|
|
1302
|
+
method: "POST"
|
|
1303
|
+
});
|
|
1304
|
+
case 7:
|
|
1305
|
+
return s = r.sent, this._pkceManager.clearPKPair(), this._subscriptionService.updateStateAndTokens({
|
|
1306
|
+
state: {
|
|
1307
|
+
session: s.session,
|
|
1308
|
+
user: s.user
|
|
1309
|
+
},
|
|
1310
|
+
session_token: s.session_token,
|
|
1311
|
+
session_jwt: s.session_jwt,
|
|
1312
|
+
intermediate_session_token: null
|
|
1313
|
+
}), r.abrupt("return", ee(s));
|
|
1314
|
+
case 11:
|
|
1315
|
+
case "end":
|
|
1316
|
+
return r.stop();
|
|
1317
|
+
}
|
|
1318
|
+
}, r, this);
|
|
1319
|
+
}));
|
|
1320
|
+
};
|
|
1321
|
+
}
|
|
1322
|
+
return a(e, [{
|
|
1323
|
+
key: "getCodeChallenge",
|
|
1324
|
+
value: function value() {
|
|
1325
|
+
return w(this, void 0, void 0, o().mark(function e() {
|
|
1326
|
+
var t;
|
|
1327
|
+
return o().wrap(function (e) {
|
|
1328
|
+
for (;;) switch (e.prev = e.next) {
|
|
1329
|
+
case 0:
|
|
1330
|
+
return e.next = 2, this._pkceManager.getPKPair();
|
|
1331
|
+
case 2:
|
|
1332
|
+
if (!(t = e.sent)) {
|
|
1333
|
+
e.next = 5;
|
|
1334
|
+
break;
|
|
1335
|
+
}
|
|
1336
|
+
return e.abrupt("return", t.code_challenge);
|
|
1337
|
+
case 5:
|
|
1338
|
+
return e.next = 7, this._pkceManager.startPKCETransaction();
|
|
1339
|
+
case 7:
|
|
1340
|
+
return t = e.sent, e.abrupt("return", t.code_challenge);
|
|
1341
|
+
case 9:
|
|
1342
|
+
case "end":
|
|
1343
|
+
return e.stop();
|
|
1344
|
+
}
|
|
1345
|
+
}, e, this);
|
|
1346
|
+
}));
|
|
1347
|
+
}
|
|
1348
|
+
}, {
|
|
1349
|
+
key: "getDFPTelemetryIDAndCaptcha",
|
|
1350
|
+
value: function value() {
|
|
1351
|
+
return w(this, void 0, void 0, o().mark(function e() {
|
|
1352
|
+
var t, r;
|
|
1353
|
+
return o().wrap(function (e) {
|
|
1354
|
+
for (;;) switch (e.prev = e.next) {
|
|
1355
|
+
case 0:
|
|
1356
|
+
if (t = void 0, r = void 0, e.t0 = this._dfpProtectedAuth, !e.t0) {
|
|
1357
|
+
e.next = 7;
|
|
1358
|
+
break;
|
|
1359
|
+
}
|
|
1360
|
+
return e.next = 6, this._dfpProtectedAuth.isEnabled();
|
|
1361
|
+
case 6:
|
|
1362
|
+
e.t0 = e.sent;
|
|
1363
|
+
case 7:
|
|
1364
|
+
if (!e.t0) {
|
|
1365
|
+
e.next = 13;
|
|
1366
|
+
break;
|
|
1367
|
+
}
|
|
1368
|
+
return e.next = 10, this._dfpProtectedAuth.getTelemetryID();
|
|
1369
|
+
case 10:
|
|
1370
|
+
t = e.sent, e.next = 16;
|
|
1371
|
+
break;
|
|
1372
|
+
case 13:
|
|
1373
|
+
return e.next = 15, this.executeRecaptcha();
|
|
1374
|
+
case 15:
|
|
1375
|
+
r = e.sent;
|
|
1376
|
+
case 16:
|
|
1377
|
+
return e.abrupt("return", {
|
|
1378
|
+
dfp_telemetry_id: t,
|
|
1379
|
+
captcha_token: r
|
|
1380
|
+
});
|
|
1381
|
+
case 17:
|
|
1382
|
+
case "end":
|
|
1383
|
+
return e.stop();
|
|
1384
|
+
}
|
|
1385
|
+
}, e, this);
|
|
1386
|
+
}));
|
|
1387
|
+
}
|
|
1388
|
+
}]), e;
|
|
1389
|
+
}(),
|
|
1390
|
+
ce = a(function e(t, r) {
|
|
1391
|
+
var n = this,
|
|
1392
|
+
i = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : function () {
|
|
1393
|
+
return Promise.resolve(void 0);
|
|
1394
|
+
};
|
|
1395
|
+
c(this, e), this._networkClient = t, this._subscriptionService = r, this.executeRecaptcha = i, this.sms = {
|
|
1396
|
+
loginOrCreate: function loginOrCreate(e, t) {
|
|
1397
|
+
return w(n, void 0, void 0, o().mark(function r() {
|
|
1398
|
+
var n, i;
|
|
1399
|
+
return o().wrap(function (r) {
|
|
1400
|
+
for (;;) switch (r.prev = r.next) {
|
|
1401
|
+
case 0:
|
|
1402
|
+
return r.next = 2, this.executeRecaptcha();
|
|
1403
|
+
case 2:
|
|
1404
|
+
return n = r.sent, i = Object.assign(Object.assign({}, t), {
|
|
1405
|
+
phone_number: e,
|
|
1406
|
+
captcha_token: n
|
|
1407
|
+
}), r.abrupt("return", this._networkClient.fetchSDK({
|
|
1408
|
+
url: "/otps/sms/login_or_create",
|
|
1409
|
+
body: i,
|
|
1410
|
+
errorMessage: "Failed to send one time passcode",
|
|
1411
|
+
method: "POST"
|
|
1412
|
+
}));
|
|
1413
|
+
case 5:
|
|
1414
|
+
case "end":
|
|
1415
|
+
return r.stop();
|
|
1416
|
+
}
|
|
1417
|
+
}, r, this);
|
|
1418
|
+
}));
|
|
1419
|
+
},
|
|
1420
|
+
send: function send(e, t) {
|
|
1421
|
+
return w(n, void 0, void 0, o().mark(function r() {
|
|
1422
|
+
var n, i, s, a;
|
|
1423
|
+
return o().wrap(function (r) {
|
|
1424
|
+
for (;;) switch (r.prev = r.next) {
|
|
1425
|
+
case 0:
|
|
1426
|
+
return r.next = 2, this.executeRecaptcha();
|
|
1427
|
+
case 2:
|
|
1428
|
+
return n = r.sent, i = Object.assign(Object.assign({}, t), {
|
|
1429
|
+
phone_number: e,
|
|
1430
|
+
captcha_token: n
|
|
1431
|
+
}), s = !!this._subscriptionService.getSession(), a = s ? "/otps/sms/send/secondary" : "/otps/sms/send/primary", r.abrupt("return", this._networkClient.fetchSDK({
|
|
1432
|
+
url: a,
|
|
1433
|
+
body: i,
|
|
1434
|
+
errorMessage: "Failed to send one time passcode",
|
|
1435
|
+
method: "POST"
|
|
1436
|
+
}));
|
|
1437
|
+
case 7:
|
|
1438
|
+
case "end":
|
|
1439
|
+
return r.stop();
|
|
1440
|
+
}
|
|
1441
|
+
}, r, this);
|
|
1442
|
+
}));
|
|
1443
|
+
}
|
|
1444
|
+
}, this.whatsapp = {
|
|
1445
|
+
loginOrCreate: function loginOrCreate(e, t) {
|
|
1446
|
+
return w(n, void 0, void 0, o().mark(function r() {
|
|
1447
|
+
var n, i;
|
|
1448
|
+
return o().wrap(function (r) {
|
|
1449
|
+
for (;;) switch (r.prev = r.next) {
|
|
1450
|
+
case 0:
|
|
1451
|
+
return r.next = 2, this.executeRecaptcha();
|
|
1452
|
+
case 2:
|
|
1453
|
+
return n = r.sent, i = Object.assign(Object.assign({}, t), {
|
|
1454
|
+
phone_number: e,
|
|
1455
|
+
captcha_token: n
|
|
1456
|
+
}), r.abrupt("return", this._networkClient.fetchSDK({
|
|
1457
|
+
url: "/otps/whatsapp/login_or_create",
|
|
1458
|
+
body: i,
|
|
1459
|
+
errorMessage: "Failed to send one time passcode",
|
|
1460
|
+
method: "POST"
|
|
1461
|
+
}));
|
|
1462
|
+
case 5:
|
|
1463
|
+
case "end":
|
|
1464
|
+
return r.stop();
|
|
1465
|
+
}
|
|
1466
|
+
}, r, this);
|
|
1467
|
+
}));
|
|
1468
|
+
},
|
|
1469
|
+
send: function send(e, t) {
|
|
1470
|
+
return w(n, void 0, void 0, o().mark(function r() {
|
|
1471
|
+
var n, i, s, a;
|
|
1472
|
+
return o().wrap(function (r) {
|
|
1473
|
+
for (;;) switch (r.prev = r.next) {
|
|
1474
|
+
case 0:
|
|
1475
|
+
return r.next = 2, this.executeRecaptcha();
|
|
1476
|
+
case 2:
|
|
1477
|
+
return n = r.sent, i = Object.assign(Object.assign({}, t), {
|
|
1478
|
+
phone_number: e,
|
|
1479
|
+
captcha_token: n
|
|
1480
|
+
}), s = !!this._subscriptionService.getSession(), a = s ? "/otps/whatsapp/send/secondary" : "/otps/whatsapp/send/primary", r.abrupt("return", this._networkClient.fetchSDK({
|
|
1481
|
+
url: a,
|
|
1482
|
+
body: i,
|
|
1483
|
+
errorMessage: "Failed to send one time passcode",
|
|
1484
|
+
method: "POST"
|
|
1485
|
+
}));
|
|
1486
|
+
case 7:
|
|
1487
|
+
case "end":
|
|
1488
|
+
return r.stop();
|
|
1489
|
+
}
|
|
1490
|
+
}, r, this);
|
|
1491
|
+
}));
|
|
1492
|
+
}
|
|
1493
|
+
}, this.email = {
|
|
1494
|
+
loginOrCreate: function loginOrCreate(e, t) {
|
|
1495
|
+
return w(n, void 0, void 0, o().mark(function r() {
|
|
1496
|
+
var n, i;
|
|
1497
|
+
return o().wrap(function (r) {
|
|
1498
|
+
for (;;) switch (r.prev = r.next) {
|
|
1499
|
+
case 0:
|
|
1500
|
+
return r.next = 2, this.executeRecaptcha();
|
|
1501
|
+
case 2:
|
|
1502
|
+
return n = r.sent, i = Object.assign(Object.assign({}, t), {
|
|
1503
|
+
email: e,
|
|
1504
|
+
captcha_token: n
|
|
1505
|
+
}), r.abrupt("return", this._networkClient.fetchSDK({
|
|
1506
|
+
url: "/otps/email/login_or_create",
|
|
1507
|
+
body: i,
|
|
1508
|
+
errorMessage: "Failed to send one time passcode",
|
|
1509
|
+
method: "POST"
|
|
1510
|
+
}));
|
|
1511
|
+
case 5:
|
|
1512
|
+
case "end":
|
|
1513
|
+
return r.stop();
|
|
1514
|
+
}
|
|
1515
|
+
}, r, this);
|
|
1516
|
+
}));
|
|
1517
|
+
},
|
|
1518
|
+
send: function send(e, t) {
|
|
1519
|
+
return w(n, void 0, void 0, o().mark(function r() {
|
|
1520
|
+
var n, i, s, a;
|
|
1521
|
+
return o().wrap(function (r) {
|
|
1522
|
+
for (;;) switch (r.prev = r.next) {
|
|
1523
|
+
case 0:
|
|
1524
|
+
return r.next = 2, this.executeRecaptcha();
|
|
1525
|
+
case 2:
|
|
1526
|
+
return n = r.sent, i = Object.assign(Object.assign({}, t), {
|
|
1527
|
+
email: e,
|
|
1528
|
+
captcha_token: n
|
|
1529
|
+
}), s = !!this._subscriptionService.getSession(), a = s ? "/otps/email/send/secondary" : "/otps/email/send/primary", r.abrupt("return", this._networkClient.fetchSDK({
|
|
1530
|
+
url: a,
|
|
1531
|
+
body: i,
|
|
1532
|
+
errorMessage: "Failed to send one time passcode",
|
|
1533
|
+
method: "POST"
|
|
1534
|
+
}));
|
|
1535
|
+
case 7:
|
|
1536
|
+
case "end":
|
|
1537
|
+
return r.stop();
|
|
1538
|
+
}
|
|
1539
|
+
}, r, this);
|
|
1540
|
+
}));
|
|
1541
|
+
}
|
|
1542
|
+
}, this.authenticate = function (e, t, r) {
|
|
1543
|
+
return w(n, void 0, void 0, o().mark(function n() {
|
|
1544
|
+
var i, s;
|
|
1545
|
+
return o().wrap(function (n) {
|
|
1546
|
+
for (;;) switch (n.prev = n.next) {
|
|
1547
|
+
case 0:
|
|
1548
|
+
return Z("stytch.otps.authenticate").isString("Code", e).isNumber("session_duration_minutes", r.session_duration_minutes), i = Object.assign({
|
|
1549
|
+
token: e,
|
|
1550
|
+
method_id: t
|
|
1551
|
+
}, r), n.next = 4, this._networkClient.fetchSDK({
|
|
1552
|
+
url: "/otps/authenticate",
|
|
1553
|
+
body: i,
|
|
1554
|
+
errorMessage: "Failed to authenticate token.",
|
|
1555
|
+
method: "POST"
|
|
1556
|
+
});
|
|
1557
|
+
case 4:
|
|
1558
|
+
return s = n.sent, this._subscriptionService.updateStateAndTokens({
|
|
1559
|
+
state: {
|
|
1560
|
+
session: s.session,
|
|
1561
|
+
user: s.user
|
|
1562
|
+
},
|
|
1563
|
+
session_token: s.session_token,
|
|
1564
|
+
session_jwt: s.session_jwt,
|
|
1565
|
+
intermediate_session_token: null
|
|
1566
|
+
}), n.abrupt("return", ee(s));
|
|
1567
|
+
case 7:
|
|
1568
|
+
case "end":
|
|
1569
|
+
return n.stop();
|
|
1570
|
+
}
|
|
1571
|
+
}, n, this);
|
|
1572
|
+
}));
|
|
1573
|
+
};
|
|
1574
|
+
}),
|
|
1575
|
+
ue = function () {
|
|
1576
|
+
function e(t, r, n, i, o) {
|
|
1577
|
+
c(this, e), this._networkClient = t, this._subscriptionService = r, this._pkceManager = n, this._dynamicConfig = i, this._config = o, this.google = {
|
|
1578
|
+
start: this.startOAuthFlow(E.Google)
|
|
1579
|
+
}, this.apple = {
|
|
1580
|
+
start: this.startOAuthFlow(E.Apple)
|
|
1581
|
+
}, this.microsoft = {
|
|
1582
|
+
start: this.startOAuthFlow(E.Microsoft)
|
|
1583
|
+
}, this.github = {
|
|
1584
|
+
start: this.startOAuthFlow(E.Github)
|
|
1585
|
+
}, this.gitlab = {
|
|
1586
|
+
start: this.startOAuthFlow(E.GitLab)
|
|
1587
|
+
}, this.facebook = {
|
|
1588
|
+
start: this.startOAuthFlow(E.Facebook)
|
|
1589
|
+
}, this.discord = {
|
|
1590
|
+
start: this.startOAuthFlow(E.Discord)
|
|
1591
|
+
}, this.salesforce = {
|
|
1592
|
+
start: this.startOAuthFlow(E.Salesforce)
|
|
1593
|
+
}, this.slack = {
|
|
1594
|
+
start: this.startOAuthFlow(E.Slack)
|
|
1595
|
+
}, this.amazon = {
|
|
1596
|
+
start: this.startOAuthFlow(E.Amazon)
|
|
1597
|
+
}, this.bitbucket = {
|
|
1598
|
+
start: this.startOAuthFlow(E.Bitbucket)
|
|
1599
|
+
}, this.linkedin = {
|
|
1600
|
+
start: this.startOAuthFlow(E.LinkedIn)
|
|
1601
|
+
}, this.coinbase = {
|
|
1602
|
+
start: this.startOAuthFlow(E.Coinbase)
|
|
1603
|
+
}, this.twitch = {
|
|
1604
|
+
start: this.startOAuthFlow(E.Twitch)
|
|
1605
|
+
}, this.twitter = {
|
|
1606
|
+
start: this.startOAuthFlow(E.Twitter)
|
|
1607
|
+
}, this.tiktok = {
|
|
1608
|
+
start: this.startOAuthFlow(E.TikTok)
|
|
1609
|
+
}, this.snapchat = {
|
|
1610
|
+
start: this.startOAuthFlow(E.Snapchat)
|
|
1611
|
+
}, this.figma = {
|
|
1612
|
+
start: this.startOAuthFlow(E.Figma)
|
|
1613
|
+
}, this.yahoo = {
|
|
1614
|
+
start: this.startOAuthFlow(E.Yahoo)
|
|
1615
|
+
};
|
|
1616
|
+
}
|
|
1617
|
+
return a(e, [{
|
|
1618
|
+
key: "authenticate",
|
|
1619
|
+
value: function value(e, t) {
|
|
1620
|
+
return w(this, void 0, void 0, o().mark(function r() {
|
|
1621
|
+
var n, i;
|
|
1622
|
+
return o().wrap(function (r) {
|
|
1623
|
+
for (;;) switch (r.prev = r.next) {
|
|
1624
|
+
case 0:
|
|
1625
|
+
return Z("stytch.oauth.authenticate").isString("Token", e).isNumber("session_duration_minutes", t.session_duration_minutes), r.next = 3, this._pkceManager.getPKPair();
|
|
1626
|
+
case 3:
|
|
1627
|
+
return (n = r.sent) || J("No code verifier found in local storage for OAuth flow.\nConsider using stytch.oauth.$provider.start() to add PKCE to your OAuth flows for added security.\nSee https://stytch.com/docs/oauth#guides_pkce for more information."), r.next = 7, this._networkClient.fetchSDK({
|
|
1628
|
+
url: "/oauth/authenticate",
|
|
1629
|
+
method: "POST",
|
|
1630
|
+
body: Object.assign({
|
|
1631
|
+
token: e,
|
|
1632
|
+
code_verifier: null == n ? void 0 : n.code_verifier
|
|
1633
|
+
}, t),
|
|
1634
|
+
errorMessage: "Failed to authenticate token"
|
|
1635
|
+
});
|
|
1636
|
+
case 7:
|
|
1637
|
+
return i = r.sent, this._pkceManager.clearPKPair(), this._subscriptionService.updateStateAndTokens({
|
|
1638
|
+
state: {
|
|
1639
|
+
session: i.session,
|
|
1640
|
+
user: Q(i.__user)
|
|
1641
|
+
},
|
|
1642
|
+
session_token: i.session_token,
|
|
1643
|
+
session_jwt: i.session_jwt,
|
|
1644
|
+
intermediate_session_token: null
|
|
1645
|
+
}), r.abrupt("return", ee(i));
|
|
1646
|
+
case 11:
|
|
1647
|
+
case "end":
|
|
1648
|
+
return r.stop();
|
|
1649
|
+
}
|
|
1650
|
+
}, r, this);
|
|
1651
|
+
}));
|
|
1652
|
+
}
|
|
1653
|
+
}, {
|
|
1654
|
+
key: "getBaseApiUrl",
|
|
1655
|
+
value: function value() {
|
|
1656
|
+
return w(this, void 0, void 0, o().mark(function e() {
|
|
1657
|
+
var t, r;
|
|
1658
|
+
return o().wrap(function (e) {
|
|
1659
|
+
for (;;) switch (e.prev = e.next) {
|
|
1660
|
+
case 0:
|
|
1661
|
+
return e.next = 2, this._dynamicConfig;
|
|
1662
|
+
case 2:
|
|
1663
|
+
if (t = e.sent, !(r = t.cnameDomain)) {
|
|
1664
|
+
e.next = 6;
|
|
1665
|
+
break;
|
|
1666
|
+
}
|
|
1667
|
+
return e.abrupt("return", "https://".concat(r));
|
|
1668
|
+
case 6:
|
|
1669
|
+
if (!this._config.publicToken.includes("public-token-test")) {
|
|
1670
|
+
e.next = 8;
|
|
1671
|
+
break;
|
|
1672
|
+
}
|
|
1673
|
+
return e.abrupt("return", this._config.testAPIURL);
|
|
1674
|
+
case 8:
|
|
1675
|
+
return e.abrupt("return", this._config.liveAPIURL);
|
|
1676
|
+
case 9:
|
|
1677
|
+
case "end":
|
|
1678
|
+
return e.stop();
|
|
1679
|
+
}
|
|
1680
|
+
}, e, this);
|
|
1681
|
+
}));
|
|
1682
|
+
}
|
|
1683
|
+
}, {
|
|
1684
|
+
key: "startOAuthFlow",
|
|
1685
|
+
value: function value(e) {
|
|
1686
|
+
var t = this;
|
|
1687
|
+
return function () {
|
|
1688
|
+
var r = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
|
|
1689
|
+
n = r.login_redirect_url,
|
|
1690
|
+
i = r.signup_redirect_url,
|
|
1691
|
+
s = r.custom_scopes;
|
|
1692
|
+
return w(t, void 0, void 0, o().mark(function t() {
|
|
1693
|
+
var r, a, c, u, l, d;
|
|
1694
|
+
return o().wrap(function (t) {
|
|
1695
|
+
for (;;) switch (t.prev = t.next) {
|
|
1696
|
+
case 0:
|
|
1697
|
+
return t.next = 2, this._dynamicConfig;
|
|
1698
|
+
case 2:
|
|
1699
|
+
return r = t.sent, a = r.cnameDomain, c = r.pkceRequiredForOAuth, t.next = 7, this.getBaseApiUrl();
|
|
1700
|
+
case 7:
|
|
1701
|
+
if (u = t.sent, this._networkClient.logEvent({
|
|
1702
|
+
name: "start_oauth_flow",
|
|
1703
|
+
details: {
|
|
1704
|
+
provider_type: e,
|
|
1705
|
+
custom_scopes: s,
|
|
1706
|
+
cname_domain: a,
|
|
1707
|
+
pkce: c
|
|
1708
|
+
}
|
|
1709
|
+
}), (l = new URL("".concat(u, "/v1/public/oauth/").concat(e, "/start"))).searchParams.set("public_token", this._config.publicToken), !c) {
|
|
1710
|
+
t.next = 18;
|
|
1711
|
+
break;
|
|
1712
|
+
}
|
|
1713
|
+
return t.next = 14, this._pkceManager.startPKCETransaction();
|
|
1714
|
+
case 14:
|
|
1715
|
+
d = t.sent, l.searchParams.set("code_challenge", d.code_challenge), t.next = 19;
|
|
1716
|
+
break;
|
|
1717
|
+
case 18:
|
|
1718
|
+
this._pkceManager.clearPKPair();
|
|
1719
|
+
case 19:
|
|
1720
|
+
s && (Z("startOAuthFlow").isStringArray("custom_scopes", s), l.searchParams.set("custom_scopes", s.join(" "))), n && l.searchParams.set("login_redirect_url", n), i && l.searchParams.set("signup_redirect_url", i), window.location.href = l.toString();
|
|
1721
|
+
case 23:
|
|
1722
|
+
case "end":
|
|
1723
|
+
return t.stop();
|
|
1724
|
+
}
|
|
1725
|
+
}, t, this);
|
|
1726
|
+
}));
|
|
1727
|
+
};
|
|
1728
|
+
}
|
|
1729
|
+
}]), e;
|
|
1730
|
+
}(),
|
|
1731
|
+
le = function () {
|
|
1732
|
+
function e(t, r) {
|
|
1733
|
+
var n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : function () {
|
|
1734
|
+
return Promise.resolve(void 0);
|
|
1735
|
+
};
|
|
1736
|
+
c(this, e), this._networkClient = t, this._subscriptionService = r, this.executeRecaptcha = n;
|
|
1737
|
+
}
|
|
1738
|
+
return a(e, [{
|
|
1739
|
+
key: "authenticateStart",
|
|
1740
|
+
value: function value(e) {
|
|
1741
|
+
return w(this, void 0, void 0, o().mark(function t() {
|
|
1742
|
+
var r, n, i;
|
|
1743
|
+
return o().wrap(function (t) {
|
|
1744
|
+
for (;;) switch (t.prev = t.next) {
|
|
1745
|
+
case 0:
|
|
1746
|
+
return Z("stytch.cryptoWallets.authenticateStart").isString("crypto_wallet_address", e.crypto_wallet_address).isString("crypto_wallet_type", e.crypto_wallet_type), r = !!this._subscriptionService.getSession(), t.next = 4, this.executeRecaptcha();
|
|
1747
|
+
case 4:
|
|
1748
|
+
return n = t.sent, i = r ? "/crypto_wallets/authenticate/start/secondary" : "/crypto_wallets/authenticate/start/primary", t.abrupt("return", this._networkClient.fetchSDK({
|
|
1749
|
+
url: i,
|
|
1750
|
+
method: "POST",
|
|
1751
|
+
errorMessage: "Failed to start wallet authentication.",
|
|
1752
|
+
body: {
|
|
1753
|
+
crypto_wallet_address: e.crypto_wallet_address,
|
|
1754
|
+
crypto_wallet_type: e.crypto_wallet_type,
|
|
1755
|
+
captcha_token: n
|
|
1756
|
+
}
|
|
1757
|
+
}));
|
|
1758
|
+
case 7:
|
|
1759
|
+
case "end":
|
|
1760
|
+
return t.stop();
|
|
1761
|
+
}
|
|
1762
|
+
}, t, this);
|
|
1763
|
+
}));
|
|
1764
|
+
}
|
|
1765
|
+
}, {
|
|
1766
|
+
key: "authenticate",
|
|
1767
|
+
value: function value(e) {
|
|
1768
|
+
return w(this, void 0, void 0, o().mark(function t() {
|
|
1769
|
+
var r;
|
|
1770
|
+
return o().wrap(function (t) {
|
|
1771
|
+
for (;;) switch (t.prev = t.next) {
|
|
1772
|
+
case 0:
|
|
1773
|
+
return Z("stytch.cryptoWallets.authenticate").isString("signature", e.signature).isString("crypto_wallet_address", e.crypto_wallet_address).isString("crypto_wallet_type", e.crypto_wallet_type).isNumber("session_duration_minutes", e.session_duration_minutes), t.next = 3, this._networkClient.fetchSDK({
|
|
1774
|
+
url: "/crypto_wallets/authenticate",
|
|
1775
|
+
method: "POST",
|
|
1776
|
+
errorMessage: "Failed to authenticate.",
|
|
1777
|
+
body: {
|
|
1778
|
+
session_duration_minutes: e.session_duration_minutes,
|
|
1779
|
+
crypto_wallet_address: e.crypto_wallet_address,
|
|
1780
|
+
crypto_wallet_type: e.crypto_wallet_type,
|
|
1781
|
+
signature: e.signature
|
|
1782
|
+
}
|
|
1783
|
+
});
|
|
1784
|
+
case 3:
|
|
1785
|
+
return r = t.sent, this._subscriptionService.updateStateAndTokens({
|
|
1786
|
+
state: {
|
|
1787
|
+
session: r.session,
|
|
1788
|
+
user: Q(r.__user)
|
|
1789
|
+
},
|
|
1790
|
+
session_token: r.session_token,
|
|
1791
|
+
session_jwt: r.session_jwt,
|
|
1792
|
+
intermediate_session_token: null
|
|
1793
|
+
}), t.abrupt("return", ee(r));
|
|
1794
|
+
case 6:
|
|
1795
|
+
case "end":
|
|
1796
|
+
return t.stop();
|
|
1797
|
+
}
|
|
1798
|
+
}, t, this);
|
|
1799
|
+
}));
|
|
1800
|
+
}
|
|
1801
|
+
}]), e;
|
|
1802
|
+
}(),
|
|
1803
|
+
de = function () {
|
|
1804
|
+
function e(t, r) {
|
|
1805
|
+
c(this, e), this._networkClient = t, this._subscriptionService = r;
|
|
1806
|
+
}
|
|
1807
|
+
return a(e, [{
|
|
1808
|
+
key: "create",
|
|
1809
|
+
value: function value(e) {
|
|
1810
|
+
return w(this, void 0, void 0, o().mark(function t() {
|
|
1811
|
+
var r;
|
|
1812
|
+
return o().wrap(function (t) {
|
|
1813
|
+
for (;;) switch (t.prev = t.next) {
|
|
1814
|
+
case 0:
|
|
1815
|
+
return Z("stytch.totps.create").isNumber("expiration_minutes", e.expiration_minutes), t.next = 3, this._networkClient.fetchSDK({
|
|
1816
|
+
url: "/totps",
|
|
1817
|
+
method: "POST",
|
|
1818
|
+
errorMessage: "Failed to create TOTP",
|
|
1819
|
+
body: {
|
|
1820
|
+
expiration_minutes: e.expiration_minutes
|
|
1821
|
+
}
|
|
1822
|
+
});
|
|
1823
|
+
case 3:
|
|
1824
|
+
return r = t.sent, this._subscriptionService.updateUser(r.__user), t.abrupt("return", ee(r));
|
|
1825
|
+
case 6:
|
|
1826
|
+
case "end":
|
|
1827
|
+
return t.stop();
|
|
1828
|
+
}
|
|
1829
|
+
}, t, this);
|
|
1830
|
+
}));
|
|
1831
|
+
}
|
|
1832
|
+
}, {
|
|
1833
|
+
key: "authenticate",
|
|
1834
|
+
value: function value(e) {
|
|
1835
|
+
return w(this, void 0, void 0, o().mark(function t() {
|
|
1836
|
+
var r;
|
|
1837
|
+
return o().wrap(function (t) {
|
|
1838
|
+
for (;;) switch (t.prev = t.next) {
|
|
1839
|
+
case 0:
|
|
1840
|
+
return Z("stytch.totps.authenticate").isNumber("session_duration_minutes", e.session_duration_minutes).isString("totp_code", e.totp_code), t.next = 3, this._networkClient.fetchSDK({
|
|
1841
|
+
url: "/totps/authenticate",
|
|
1842
|
+
method: "POST",
|
|
1843
|
+
errorMessage: "Failed to authenticate TOTP",
|
|
1844
|
+
body: {
|
|
1845
|
+
session_duration_minutes: e.session_duration_minutes,
|
|
1846
|
+
totp_code: e.totp_code
|
|
1847
|
+
}
|
|
1848
|
+
});
|
|
1849
|
+
case 3:
|
|
1850
|
+
return r = t.sent, this._subscriptionService.updateStateAndTokens({
|
|
1851
|
+
state: {
|
|
1852
|
+
session: r.session,
|
|
1853
|
+
user: r.__user
|
|
1854
|
+
},
|
|
1855
|
+
session_token: r.session_token,
|
|
1856
|
+
session_jwt: r.session_jwt,
|
|
1857
|
+
intermediate_session_token: null
|
|
1858
|
+
}), t.abrupt("return", ee(r));
|
|
1859
|
+
case 6:
|
|
1860
|
+
case "end":
|
|
1861
|
+
return t.stop();
|
|
1862
|
+
}
|
|
1863
|
+
}, t, this);
|
|
1864
|
+
}));
|
|
1865
|
+
}
|
|
1866
|
+
}, {
|
|
1867
|
+
key: "recoveryCodes",
|
|
1868
|
+
value: function value() {
|
|
1869
|
+
return w(this, void 0, void 0, o().mark(function e() {
|
|
1870
|
+
return o().wrap(function (e) {
|
|
1871
|
+
for (;;) switch (e.prev = e.next) {
|
|
1872
|
+
case 0:
|
|
1873
|
+
return e.abrupt("return", this._networkClient.fetchSDK({
|
|
1874
|
+
url: "/totps/recovery_codes",
|
|
1875
|
+
method: "POST",
|
|
1876
|
+
errorMessage: "Failed to retrieve recovery codes"
|
|
1877
|
+
}));
|
|
1878
|
+
case 1:
|
|
1879
|
+
case "end":
|
|
1880
|
+
return e.stop();
|
|
1881
|
+
}
|
|
1882
|
+
}, e, this);
|
|
1883
|
+
}));
|
|
1884
|
+
}
|
|
1885
|
+
}, {
|
|
1886
|
+
key: "recover",
|
|
1887
|
+
value: function value(e) {
|
|
1888
|
+
return w(this, void 0, void 0, o().mark(function t() {
|
|
1889
|
+
var r;
|
|
1890
|
+
return o().wrap(function (t) {
|
|
1891
|
+
for (;;) switch (t.prev = t.next) {
|
|
1892
|
+
case 0:
|
|
1893
|
+
return Z("stytch.totps.recover").isNumber("session_duration_minutes", e.session_duration_minutes).isString("recovery_code", e.recovery_code), t.next = 3, this._networkClient.fetchSDK({
|
|
1894
|
+
url: "/totps/recover",
|
|
1895
|
+
method: "POST",
|
|
1896
|
+
errorMessage: "Failed to recover TOTP",
|
|
1897
|
+
body: {
|
|
1898
|
+
session_duration_minutes: e.session_duration_minutes,
|
|
1899
|
+
recovery_code: e.recovery_code
|
|
1900
|
+
}
|
|
1901
|
+
});
|
|
1902
|
+
case 3:
|
|
1903
|
+
return r = t.sent, this._subscriptionService.updateStateAndTokens({
|
|
1904
|
+
state: {
|
|
1905
|
+
session: r.session,
|
|
1906
|
+
user: r.__user
|
|
1907
|
+
},
|
|
1908
|
+
session_token: r.session_token,
|
|
1909
|
+
session_jwt: r.session_jwt,
|
|
1910
|
+
intermediate_session_token: null
|
|
1911
|
+
}), t.abrupt("return", ee(r));
|
|
1912
|
+
case 6:
|
|
1913
|
+
case "end":
|
|
1914
|
+
return t.stop();
|
|
1915
|
+
}
|
|
1916
|
+
}, t, this);
|
|
1917
|
+
}));
|
|
1918
|
+
}
|
|
1919
|
+
}]), e;
|
|
1920
|
+
}();
|
|
1921
|
+
function he(e) {
|
|
1922
|
+
for (var t = "==".slice(0, (4 - e.length % 4) % 4), r = e.replace(/-/g, "+").replace(/_/g, "/") + t, n = atob(r), i = new ArrayBuffer(n.length), o = new Uint8Array(i), s = 0; s < n.length; s++) o[s] = n.charCodeAt(s);
|
|
1923
|
+
return i;
|
|
1924
|
+
}
|
|
1925
|
+
function pe(t) {
|
|
1926
|
+
var r,
|
|
1927
|
+
n = "",
|
|
1928
|
+
i = e(new Uint8Array(t));
|
|
1929
|
+
try {
|
|
1930
|
+
for (i.s(); !(r = i.n()).done;) {
|
|
1931
|
+
var o = r.value;
|
|
1932
|
+
n += String.fromCharCode(o);
|
|
1933
|
+
}
|
|
1934
|
+
} catch (e) {
|
|
1935
|
+
i.e(e);
|
|
1936
|
+
} finally {
|
|
1937
|
+
i.f();
|
|
1938
|
+
}
|
|
1939
|
+
return btoa(n).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
1940
|
+
}
|
|
1941
|
+
var fe = "copy",
|
|
1942
|
+
_e = "convert";
|
|
1943
|
+
function ve(e, r, n) {
|
|
1944
|
+
if (r === fe) return n;
|
|
1945
|
+
if (r === _e) return e(n);
|
|
1946
|
+
if (r instanceof Array) return n.map(function (t) {
|
|
1947
|
+
return ve(e, r[0], t);
|
|
1948
|
+
});
|
|
1949
|
+
if (r instanceof Object) {
|
|
1950
|
+
for (var i = {}, o = 0, s = Object.entries(r); o < s.length; o++) {
|
|
1951
|
+
var a = t(s[o], 2),
|
|
1952
|
+
c = a[0],
|
|
1953
|
+
u = a[1];
|
|
1954
|
+
if (u.derive) {
|
|
1955
|
+
var l = u.derive(n);
|
|
1956
|
+
void 0 !== l && (n[c] = l);
|
|
1957
|
+
}
|
|
1958
|
+
if (c in n) null != n[c] ? i[c] = ve(e, u.schema, n[c]) : i[c] = null;else if (u.required) throw new Error("Missing key: ".concat(c));
|
|
1959
|
+
}
|
|
1960
|
+
return i;
|
|
1961
|
+
}
|
|
1962
|
+
}
|
|
1963
|
+
function me(e, t) {
|
|
1964
|
+
return {
|
|
1965
|
+
required: !0,
|
|
1966
|
+
schema: e,
|
|
1967
|
+
derive: t
|
|
1968
|
+
};
|
|
1969
|
+
}
|
|
1970
|
+
function ye(e) {
|
|
1971
|
+
return {
|
|
1972
|
+
required: !0,
|
|
1973
|
+
schema: e
|
|
1974
|
+
};
|
|
1975
|
+
}
|
|
1976
|
+
function ge(e) {
|
|
1977
|
+
return {
|
|
1978
|
+
required: !1,
|
|
1979
|
+
schema: e
|
|
1980
|
+
};
|
|
1981
|
+
}
|
|
1982
|
+
var be = {
|
|
1983
|
+
type: ye(fe),
|
|
1984
|
+
id: ye(_e),
|
|
1985
|
+
transports: ge(fe)
|
|
1986
|
+
},
|
|
1987
|
+
we = {
|
|
1988
|
+
appid: ge(fe),
|
|
1989
|
+
appidExclude: ge(fe),
|
|
1990
|
+
credProps: ge(fe)
|
|
1991
|
+
},
|
|
1992
|
+
ke = {
|
|
1993
|
+
appid: ge(fe),
|
|
1994
|
+
appidExclude: ge(fe),
|
|
1995
|
+
credProps: ge(fe)
|
|
1996
|
+
},
|
|
1997
|
+
Se = {
|
|
1998
|
+
publicKey: ye({
|
|
1999
|
+
rp: ye(fe),
|
|
2000
|
+
user: ye({
|
|
2001
|
+
id: ye(_e),
|
|
2002
|
+
name: ye(fe),
|
|
2003
|
+
displayName: ye(fe)
|
|
2004
|
+
}),
|
|
2005
|
+
challenge: ye(_e),
|
|
2006
|
+
pubKeyCredParams: ye(fe),
|
|
2007
|
+
timeout: ge(fe),
|
|
2008
|
+
excludeCredentials: ge([be]),
|
|
2009
|
+
authenticatorSelection: ge(fe),
|
|
2010
|
+
attestation: ge(fe),
|
|
2011
|
+
extensions: ge(we)
|
|
2012
|
+
}),
|
|
2013
|
+
signal: ge(fe)
|
|
2014
|
+
},
|
|
2015
|
+
Te = {
|
|
2016
|
+
type: ye(fe),
|
|
2017
|
+
id: ye(fe),
|
|
2018
|
+
rawId: ye(_e),
|
|
2019
|
+
authenticatorAttachment: ge(fe),
|
|
2020
|
+
response: ye({
|
|
2021
|
+
clientDataJSON: ye(_e),
|
|
2022
|
+
attestationObject: ye(_e),
|
|
2023
|
+
transports: me(fe, function (e) {
|
|
2024
|
+
var t;
|
|
2025
|
+
return (null == (t = e.getTransports) ? void 0 : t.call(e)) || [];
|
|
2026
|
+
})
|
|
2027
|
+
}),
|
|
2028
|
+
clientExtensionResults: me(ke, function (e) {
|
|
2029
|
+
return e.getClientExtensionResults();
|
|
2030
|
+
})
|
|
2031
|
+
},
|
|
2032
|
+
Oe = {
|
|
2033
|
+
mediation: ge(fe),
|
|
2034
|
+
publicKey: ye({
|
|
2035
|
+
challenge: ye(_e),
|
|
2036
|
+
timeout: ge(fe),
|
|
2037
|
+
rpId: ge(fe),
|
|
2038
|
+
allowCredentials: ge([be]),
|
|
2039
|
+
userVerification: ge(fe),
|
|
2040
|
+
extensions: ge(we)
|
|
2041
|
+
}),
|
|
2042
|
+
signal: ge(fe)
|
|
2043
|
+
},
|
|
2044
|
+
Ee = {
|
|
2045
|
+
type: ye(fe),
|
|
2046
|
+
id: ye(fe),
|
|
2047
|
+
rawId: ye(_e),
|
|
2048
|
+
authenticatorAttachment: ge(fe),
|
|
2049
|
+
response: ye({
|
|
2050
|
+
clientDataJSON: ye(_e),
|
|
2051
|
+
authenticatorData: ye(_e),
|
|
2052
|
+
signature: ye(_e),
|
|
2053
|
+
userHandle: ye(_e)
|
|
2054
|
+
}),
|
|
2055
|
+
clientExtensionResults: me(ke, function (e) {
|
|
2056
|
+
return e.getClientExtensionResults();
|
|
2057
|
+
})
|
|
2058
|
+
};
|
|
2059
|
+
function Ce(e) {
|
|
2060
|
+
return ve(he, Se, e);
|
|
2061
|
+
}
|
|
2062
|
+
function xe(e) {
|
|
2063
|
+
return ve(pe, Te, e);
|
|
2064
|
+
}
|
|
2065
|
+
function Ae(e) {
|
|
2066
|
+
return w(this, void 0, void 0, o().mark(function t() {
|
|
2067
|
+
var r;
|
|
2068
|
+
return o().wrap(function (t) {
|
|
2069
|
+
for (;;) switch (t.prev = t.next) {
|
|
2070
|
+
case 0:
|
|
2071
|
+
return t.next = 2, navigator.credentials.create(Ce(e));
|
|
2072
|
+
case 2:
|
|
2073
|
+
return r = t.sent, t.abrupt("return", xe(r));
|
|
2074
|
+
case 4:
|
|
2075
|
+
case "end":
|
|
2076
|
+
return t.stop();
|
|
2077
|
+
}
|
|
2078
|
+
}, t);
|
|
2079
|
+
}));
|
|
2080
|
+
}
|
|
2081
|
+
function Pe(e) {
|
|
2082
|
+
return ve(he, Oe, e);
|
|
2083
|
+
}
|
|
2084
|
+
function Re(e) {
|
|
2085
|
+
return ve(pe, Ee, e);
|
|
2086
|
+
}
|
|
2087
|
+
function Be(e) {
|
|
2088
|
+
return w(this, void 0, void 0, o().mark(function t() {
|
|
2089
|
+
var r;
|
|
2090
|
+
return o().wrap(function (t) {
|
|
2091
|
+
for (;;) switch (t.prev = t.next) {
|
|
2092
|
+
case 0:
|
|
2093
|
+
return t.next = 2, navigator.credentials.get(Pe(e));
|
|
2094
|
+
case 2:
|
|
2095
|
+
return r = t.sent, t.abrupt("return", Re(r));
|
|
2096
|
+
case 4:
|
|
2097
|
+
case "end":
|
|
2098
|
+
return t.stop();
|
|
2099
|
+
}
|
|
2100
|
+
}, t);
|
|
2101
|
+
}));
|
|
2102
|
+
}
|
|
2103
|
+
var Ie = function () {
|
|
2104
|
+
function e(t, r) {
|
|
2105
|
+
c(this, e), this._networkClient = t, this._subscriptionService = r;
|
|
2106
|
+
}
|
|
2107
|
+
return a(e, [{
|
|
2108
|
+
key: "register",
|
|
2109
|
+
value: function value(e) {
|
|
2110
|
+
var t;
|
|
2111
|
+
return w(this, void 0, void 0, o().mark(function r() {
|
|
2112
|
+
var n, i, s, a;
|
|
2113
|
+
return o().wrap(function (r) {
|
|
2114
|
+
for (;;) switch (r.prev = r.next) {
|
|
2115
|
+
case 0:
|
|
2116
|
+
return Z("stytch.webauthn.register").isOptionalString("domain", null == e ? void 0 : e.domain).isOptionalString("authenticator_type", null == e ? void 0 : e.authenticator_type), r.next = 3, this._networkClient.fetchSDK({
|
|
2117
|
+
url: "/webauthn/register/start",
|
|
2118
|
+
method: "POST",
|
|
2119
|
+
errorMessage: "Failed to start WebAuthn registration",
|
|
2120
|
+
body: {
|
|
2121
|
+
domain: null !== (t = null == e ? void 0 : e.domain) && void 0 !== t ? t : window.location.hostname,
|
|
2122
|
+
authenticator_type: null == e ? void 0 : e.authenticator_type
|
|
2123
|
+
}
|
|
2124
|
+
});
|
|
2125
|
+
case 3:
|
|
2126
|
+
return n = r.sent, i = n.public_key_credential_creation_options, r.next = 7, Ae({
|
|
2127
|
+
publicKey: JSON.parse(i)
|
|
2128
|
+
});
|
|
2129
|
+
case 7:
|
|
2130
|
+
return s = r.sent, r.next = 10, this._networkClient.fetchSDK({
|
|
2131
|
+
url: "/webauthn/register",
|
|
2132
|
+
method: "POST",
|
|
2133
|
+
errorMessage: "Failed to register WebAuthn device",
|
|
2134
|
+
body: {
|
|
2135
|
+
public_key_credential: JSON.stringify(s)
|
|
2136
|
+
}
|
|
2137
|
+
});
|
|
2138
|
+
case 10:
|
|
2139
|
+
return a = r.sent, this._subscriptionService.updateUser(a.__user), r.abrupt("return", ee(a));
|
|
2140
|
+
case 13:
|
|
2141
|
+
case "end":
|
|
2142
|
+
return r.stop();
|
|
2143
|
+
}
|
|
2144
|
+
}, r, this);
|
|
2145
|
+
}));
|
|
2146
|
+
}
|
|
2147
|
+
}, {
|
|
2148
|
+
key: "authenticate",
|
|
2149
|
+
value: function value(e) {
|
|
2150
|
+
var t;
|
|
2151
|
+
return w(this, void 0, void 0, o().mark(function r() {
|
|
2152
|
+
var n, i, s, a;
|
|
2153
|
+
return o().wrap(function (r) {
|
|
2154
|
+
for (;;) switch (r.prev = r.next) {
|
|
2155
|
+
case 0:
|
|
2156
|
+
return Z("stytch.webauthn.register").isOptionalString("domain", e.domain).isNumber("session_duration_minutes", e.session_duration_minutes), r.next = 3, this._networkClient.fetchSDK({
|
|
2157
|
+
url: "/webauthn/authenticate/start",
|
|
2158
|
+
method: "POST",
|
|
2159
|
+
errorMessage: "Failed to start WebAuthn authentication",
|
|
2160
|
+
body: {
|
|
2161
|
+
domain: null !== (t = e.domain) && void 0 !== t ? t : window.location.hostname
|
|
2162
|
+
}
|
|
2163
|
+
});
|
|
2164
|
+
case 3:
|
|
2165
|
+
return n = r.sent, i = n.public_key_credential_request_options, r.next = 7, Be({
|
|
2166
|
+
publicKey: JSON.parse(i)
|
|
2167
|
+
});
|
|
2168
|
+
case 7:
|
|
2169
|
+
return s = r.sent, r.next = 10, this._networkClient.fetchSDK({
|
|
2170
|
+
url: "/webauthn/authenticate",
|
|
2171
|
+
method: "POST",
|
|
2172
|
+
errorMessage: "Failed to authenticate WebAuthn device",
|
|
2173
|
+
body: {
|
|
2174
|
+
public_key_credential: JSON.stringify(s),
|
|
2175
|
+
session_duration_minutes: e.session_duration_minutes
|
|
2176
|
+
}
|
|
2177
|
+
});
|
|
2178
|
+
case 10:
|
|
2179
|
+
return a = r.sent, this._subscriptionService.updateStateAndTokens({
|
|
2180
|
+
state: {
|
|
2181
|
+
session: a.session,
|
|
2182
|
+
user: a.__user
|
|
2183
|
+
},
|
|
2184
|
+
session_token: a.session_token,
|
|
2185
|
+
session_jwt: a.session_jwt,
|
|
2186
|
+
intermediate_session_token: null
|
|
2187
|
+
}), r.abrupt("return", ee(a));
|
|
2188
|
+
case 13:
|
|
2189
|
+
case "end":
|
|
2190
|
+
return r.stop();
|
|
2191
|
+
}
|
|
2192
|
+
}, r, this);
|
|
2193
|
+
}));
|
|
2194
|
+
}
|
|
2195
|
+
}]), e;
|
|
2196
|
+
}(),
|
|
2197
|
+
De = Promise.resolve({
|
|
2198
|
+
pkceRequiredForPasswordResets: !1
|
|
2199
|
+
}),
|
|
2200
|
+
Le = function () {
|
|
2201
|
+
function e(t, r, n) {
|
|
2202
|
+
var i = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : De,
|
|
2203
|
+
o = arguments.length > 4 && void 0 !== arguments[4] ? arguments[4] : function () {
|
|
2204
|
+
return Promise.resolve(void 0);
|
|
2205
|
+
},
|
|
2206
|
+
s = arguments.length > 5 ? arguments[5] : void 0;
|
|
2207
|
+
c(this, e), this._networkClient = t, this._subscriptionService = r, this._pkceManager = n, this._config = i, this.executeRecaptcha = o, this._dfpProtectedAuth = s;
|
|
2208
|
+
}
|
|
2209
|
+
return a(e, [{
|
|
2210
|
+
key: "getCodeChallenge",
|
|
2211
|
+
value: function value() {
|
|
2212
|
+
return w(this, void 0, void 0, o().mark(function e() {
|
|
2213
|
+
var t, r;
|
|
2214
|
+
return o().wrap(function (e) {
|
|
2215
|
+
for (;;) switch (e.prev = e.next) {
|
|
2216
|
+
case 0:
|
|
2217
|
+
return e.next = 2, this._config;
|
|
2218
|
+
case 2:
|
|
2219
|
+
if (t = e.sent, t.pkceRequiredForPasswordResets) {
|
|
2220
|
+
e.next = 6;
|
|
2221
|
+
break;
|
|
2222
|
+
}
|
|
2223
|
+
return e.abrupt("return", void 0);
|
|
2224
|
+
case 6:
|
|
2225
|
+
return e.next = 8, this._pkceManager.getPKPair();
|
|
2226
|
+
case 8:
|
|
2227
|
+
if (!(r = e.sent)) {
|
|
2228
|
+
e.next = 11;
|
|
2229
|
+
break;
|
|
2230
|
+
}
|
|
2231
|
+
return e.abrupt("return", r.code_challenge);
|
|
2232
|
+
case 11:
|
|
2233
|
+
return e.next = 13, this._pkceManager.startPKCETransaction();
|
|
2234
|
+
case 13:
|
|
2235
|
+
return r = e.sent, e.abrupt("return", r.code_challenge);
|
|
2236
|
+
case 15:
|
|
2237
|
+
case "end":
|
|
2238
|
+
return e.stop();
|
|
2239
|
+
}
|
|
2240
|
+
}, e, this);
|
|
2241
|
+
}));
|
|
2242
|
+
}
|
|
2243
|
+
}, {
|
|
2244
|
+
key: "getDFPTelemetryIDAndCaptcha",
|
|
2245
|
+
value: function value() {
|
|
2246
|
+
return w(this, void 0, void 0, o().mark(function e() {
|
|
2247
|
+
var t, r;
|
|
2248
|
+
return o().wrap(function (e) {
|
|
2249
|
+
for (;;) switch (e.prev = e.next) {
|
|
2250
|
+
case 0:
|
|
2251
|
+
if (t = void 0, r = void 0, e.t0 = this._dfpProtectedAuth, !e.t0) {
|
|
2252
|
+
e.next = 7;
|
|
2253
|
+
break;
|
|
2254
|
+
}
|
|
2255
|
+
return e.next = 6, this._dfpProtectedAuth.isEnabled();
|
|
2256
|
+
case 6:
|
|
2257
|
+
e.t0 = e.sent;
|
|
2258
|
+
case 7:
|
|
2259
|
+
if (!e.t0) {
|
|
2260
|
+
e.next = 13;
|
|
2261
|
+
break;
|
|
2262
|
+
}
|
|
2263
|
+
return e.next = 10, this._dfpProtectedAuth.getTelemetryID();
|
|
2264
|
+
case 10:
|
|
2265
|
+
t = e.sent, e.next = 16;
|
|
2266
|
+
break;
|
|
2267
|
+
case 13:
|
|
2268
|
+
return e.next = 15, this.executeRecaptcha();
|
|
2269
|
+
case 15:
|
|
2270
|
+
r = e.sent;
|
|
2271
|
+
case 16:
|
|
2272
|
+
return e.abrupt("return", {
|
|
2273
|
+
dfp_telemetry_id: t,
|
|
2274
|
+
captcha_token: r
|
|
2275
|
+
});
|
|
2276
|
+
case 17:
|
|
2277
|
+
case "end":
|
|
2278
|
+
return e.stop();
|
|
2279
|
+
}
|
|
2280
|
+
}, e, this);
|
|
2281
|
+
}));
|
|
2282
|
+
}
|
|
2283
|
+
}, {
|
|
2284
|
+
key: "create",
|
|
2285
|
+
value: function value(e) {
|
|
2286
|
+
return w(this, void 0, void 0, o().mark(function t() {
|
|
2287
|
+
var r, n, i, s;
|
|
2288
|
+
return o().wrap(function (t) {
|
|
2289
|
+
for (;;) switch (t.prev = t.next) {
|
|
2290
|
+
case 0:
|
|
2291
|
+
return Z("stytch.passwords.create").isString("password", e.password).isString("email", e.email).isNumber("session_duration_minutes", e.session_duration_minutes), t.next = 3, this.getDFPTelemetryIDAndCaptcha();
|
|
2292
|
+
case 3:
|
|
2293
|
+
return r = t.sent, n = r.dfp_telemetry_id, i = r.captcha_token, t.next = 8, this._networkClient.fetchSDK({
|
|
2294
|
+
url: "/passwords",
|
|
2295
|
+
method: "POST",
|
|
2296
|
+
errorMessage: "Failed to create password.",
|
|
2297
|
+
body: {
|
|
2298
|
+
email: e.email,
|
|
2299
|
+
password: e.password,
|
|
2300
|
+
session_duration_minutes: e.session_duration_minutes,
|
|
2301
|
+
captcha_token: i,
|
|
2302
|
+
dfp_telemetry_id: n
|
|
2303
|
+
}
|
|
2304
|
+
});
|
|
2305
|
+
case 8:
|
|
2306
|
+
return s = t.sent, this._subscriptionService.updateStateAndTokens({
|
|
2307
|
+
state: {
|
|
2308
|
+
session: s.session,
|
|
2309
|
+
user: s.user
|
|
2310
|
+
},
|
|
2311
|
+
session_token: s.session_token,
|
|
2312
|
+
session_jwt: s.session_jwt,
|
|
2313
|
+
intermediate_session_token: null
|
|
2314
|
+
}), t.abrupt("return", ee(s));
|
|
2315
|
+
case 11:
|
|
2316
|
+
case "end":
|
|
2317
|
+
return t.stop();
|
|
2318
|
+
}
|
|
2319
|
+
}, t, this);
|
|
2320
|
+
}));
|
|
2321
|
+
}
|
|
2322
|
+
}, {
|
|
2323
|
+
key: "authenticate",
|
|
2324
|
+
value: function value(e) {
|
|
2325
|
+
return w(this, void 0, void 0, o().mark(function t() {
|
|
2326
|
+
var r, n, i, s;
|
|
2327
|
+
return o().wrap(function (t) {
|
|
2328
|
+
for (;;) switch (t.prev = t.next) {
|
|
2329
|
+
case 0:
|
|
2330
|
+
return Z("stytch.passwords.authenticate").isString("password", e.password).isString("email", e.email).isNumber("session_duration_minutes", e.session_duration_minutes), t.next = 3, this.getDFPTelemetryIDAndCaptcha();
|
|
2331
|
+
case 3:
|
|
2332
|
+
return r = t.sent, n = r.dfp_telemetry_id, i = r.captcha_token, t.next = 8, this._networkClient.fetchSDK({
|
|
2333
|
+
url: "/passwords/authenticate",
|
|
2334
|
+
method: "POST",
|
|
2335
|
+
errorMessage: "Failed to authenticate password.",
|
|
2336
|
+
body: {
|
|
2337
|
+
email: e.email,
|
|
2338
|
+
password: e.password,
|
|
2339
|
+
session_duration_minutes: e.session_duration_minutes,
|
|
2340
|
+
captcha_token: i,
|
|
2341
|
+
dfp_telemetry_id: n
|
|
2342
|
+
}
|
|
2343
|
+
});
|
|
2344
|
+
case 8:
|
|
2345
|
+
return s = t.sent, this._subscriptionService.updateStateAndTokens({
|
|
2346
|
+
state: {
|
|
2347
|
+
session: s.session,
|
|
2348
|
+
user: s.user
|
|
2349
|
+
},
|
|
2350
|
+
session_token: s.session_token,
|
|
2351
|
+
session_jwt: s.session_jwt,
|
|
2352
|
+
intermediate_session_token: null
|
|
2353
|
+
}), t.abrupt("return", ee(s));
|
|
2354
|
+
case 11:
|
|
2355
|
+
case "end":
|
|
2356
|
+
return t.stop();
|
|
2357
|
+
}
|
|
2358
|
+
}, t, this);
|
|
2359
|
+
}));
|
|
2360
|
+
}
|
|
2361
|
+
}, {
|
|
2362
|
+
key: "resetByEmailStart",
|
|
2363
|
+
value: function value(e) {
|
|
2364
|
+
return w(this, void 0, void 0, o().mark(function t() {
|
|
2365
|
+
var r, n, i, s;
|
|
2366
|
+
return o().wrap(function (t) {
|
|
2367
|
+
for (;;) switch (t.prev = t.next) {
|
|
2368
|
+
case 0:
|
|
2369
|
+
return Z("stytch.passwords.resetByEmailStart").isString("email", e.email).isOptionalString("login_redirect_url", e.login_redirect_url).isOptionalString("reset_password_redirect_url", e.reset_password_redirect_url).isOptionalString("reset_password_template_id", e.reset_password_template_id).isOptionalNumber("reset_password_expiration_minutes", e.reset_password_expiration_minutes), t.next = 3, this.getCodeChallenge();
|
|
2370
|
+
case 3:
|
|
2371
|
+
return r = t.sent, t.next = 6, this.getDFPTelemetryIDAndCaptcha();
|
|
2372
|
+
case 6:
|
|
2373
|
+
return n = t.sent, i = n.dfp_telemetry_id, s = n.captcha_token, t.abrupt("return", this._networkClient.fetchSDK({
|
|
2374
|
+
url: "/passwords/email/reset/start",
|
|
2375
|
+
method: "POST",
|
|
2376
|
+
errorMessage: "Failed to start password reset flow.",
|
|
2377
|
+
body: {
|
|
2378
|
+
email: e.email,
|
|
2379
|
+
login_redirect_url: e.login_redirect_url,
|
|
2380
|
+
reset_password_redirect_url: e.reset_password_redirect_url,
|
|
2381
|
+
reset_password_expiration_minutes: e.reset_password_expiration_minutes,
|
|
2382
|
+
reset_password_template_id: e.reset_password_template_id,
|
|
2383
|
+
code_challenge: r,
|
|
2384
|
+
captcha_token: s,
|
|
2385
|
+
dfp_telemetry_id: i
|
|
2386
|
+
}
|
|
2387
|
+
}));
|
|
2388
|
+
case 10:
|
|
2389
|
+
case "end":
|
|
2390
|
+
return t.stop();
|
|
2391
|
+
}
|
|
2392
|
+
}, t, this);
|
|
2393
|
+
}));
|
|
2394
|
+
}
|
|
2395
|
+
}, {
|
|
2396
|
+
key: "resetByEmail",
|
|
2397
|
+
value: function value(e) {
|
|
2398
|
+
return w(this, void 0, void 0, o().mark(function t() {
|
|
2399
|
+
var r, n, i, s, a, c;
|
|
2400
|
+
return o().wrap(function (t) {
|
|
2401
|
+
for (;;) switch (t.prev = t.next) {
|
|
2402
|
+
case 0:
|
|
2403
|
+
return Z("stytch.passwords.resetByEmail").isString("token", e.token).isString("password", e.password).isNumber("session_duration_minutes", e.session_duration_minutes), t.next = 3, this.getDFPTelemetryIDAndCaptcha();
|
|
2404
|
+
case 3:
|
|
2405
|
+
return r = t.sent, n = r.dfp_telemetry_id, i = r.captcha_token, t.next = 8, this._pkceManager.getPKPair();
|
|
2406
|
+
case 8:
|
|
2407
|
+
return s = t.sent, a = null == s ? void 0 : s.code_verifier, t.next = 12, this._networkClient.fetchSDK({
|
|
2408
|
+
url: "/passwords/email/reset",
|
|
2409
|
+
method: "POST",
|
|
2410
|
+
errorMessage: "Failed to reset password.",
|
|
2411
|
+
body: {
|
|
2412
|
+
token: e.token,
|
|
2413
|
+
password: e.password,
|
|
2414
|
+
session_duration_minutes: e.session_duration_minutes,
|
|
2415
|
+
captcha_token: i,
|
|
2416
|
+
code_verifier: a,
|
|
2417
|
+
dfp_telemetry_id: n
|
|
2418
|
+
}
|
|
2419
|
+
});
|
|
2420
|
+
case 12:
|
|
2421
|
+
return c = t.sent, this._pkceManager.clearPKPair(), this._subscriptionService.updateStateAndTokens({
|
|
2422
|
+
state: {
|
|
2423
|
+
session: c.session,
|
|
2424
|
+
user: c.user
|
|
2425
|
+
},
|
|
2426
|
+
session_token: c.session_token,
|
|
2427
|
+
session_jwt: c.session_jwt,
|
|
2428
|
+
intermediate_session_token: null
|
|
2429
|
+
}), t.abrupt("return", ee(c));
|
|
2430
|
+
case 16:
|
|
2431
|
+
case "end":
|
|
2432
|
+
return t.stop();
|
|
2433
|
+
}
|
|
2434
|
+
}, t, this);
|
|
2435
|
+
}));
|
|
2436
|
+
}
|
|
2437
|
+
}, {
|
|
2438
|
+
key: "resetByExistingPassword",
|
|
2439
|
+
value: function value(e) {
|
|
2440
|
+
return w(this, void 0, void 0, o().mark(function t() {
|
|
2441
|
+
var r;
|
|
2442
|
+
return o().wrap(function (t) {
|
|
2443
|
+
for (;;) switch (t.prev = t.next) {
|
|
2444
|
+
case 0:
|
|
2445
|
+
return Z("stytch.passwords.resetByExistingPassword").isString("email", e.email).isString("existing_password", e.existing_password).isString("new_password", e.new_password).isNumber("session_duration_minutes", e.session_duration_minutes), t.next = 3, this._networkClient.fetchSDK({
|
|
2446
|
+
url: "/passwords/existing_password/reset",
|
|
2447
|
+
method: "POST",
|
|
2448
|
+
errorMessage: "Failed to reset password.",
|
|
2449
|
+
body: {
|
|
2450
|
+
email: e.email,
|
|
2451
|
+
existing_password: e.existing_password,
|
|
2452
|
+
new_password: e.new_password,
|
|
2453
|
+
session_duration_minutes: e.session_duration_minutes
|
|
2454
|
+
}
|
|
2455
|
+
});
|
|
2456
|
+
case 3:
|
|
2457
|
+
return r = t.sent, t.abrupt("return", ee(r));
|
|
2458
|
+
case 5:
|
|
2459
|
+
case "end":
|
|
2460
|
+
return t.stop();
|
|
2461
|
+
}
|
|
2462
|
+
}, t, this);
|
|
2463
|
+
}));
|
|
2464
|
+
}
|
|
2465
|
+
}, {
|
|
2466
|
+
key: "resetBySession",
|
|
2467
|
+
value: function value(e) {
|
|
2468
|
+
return w(this, void 0, void 0, o().mark(function t() {
|
|
2469
|
+
return o().wrap(function (t) {
|
|
2470
|
+
for (;;) switch (t.prev = t.next) {
|
|
2471
|
+
case 0:
|
|
2472
|
+
return Z("stytch.passwords.resetBySession").isString("password", e.password), t.next = 3, this._networkClient.fetchSDK({
|
|
2473
|
+
url: "/passwords/session/reset",
|
|
2474
|
+
method: "POST",
|
|
2475
|
+
errorMessage: "Failed to reset session.",
|
|
2476
|
+
body: {
|
|
2477
|
+
password: e.password
|
|
2478
|
+
}
|
|
2479
|
+
});
|
|
2480
|
+
case 3:
|
|
2481
|
+
return t.abrupt("return", t.sent);
|
|
2482
|
+
case 4:
|
|
2483
|
+
case "end":
|
|
2484
|
+
return t.stop();
|
|
2485
|
+
}
|
|
2486
|
+
}, t, this);
|
|
2487
|
+
}));
|
|
2488
|
+
}
|
|
2489
|
+
}, {
|
|
2490
|
+
key: "strengthCheck",
|
|
2491
|
+
value: function value(e) {
|
|
2492
|
+
return w(this, void 0, void 0, o().mark(function t() {
|
|
2493
|
+
return o().wrap(function (t) {
|
|
2494
|
+
for (;;) switch (t.prev = t.next) {
|
|
2495
|
+
case 0:
|
|
2496
|
+
return Z("stytch.passwords.strengthCheck").isOptionalString("email", e.email).isString("password", e.password), t.abrupt("return", this._networkClient.fetchSDK({
|
|
2497
|
+
url: "/passwords/strength_check",
|
|
2498
|
+
method: "POST",
|
|
2499
|
+
errorMessage: "Failed to check password strength.",
|
|
2500
|
+
body: {
|
|
2501
|
+
email: e.email,
|
|
2502
|
+
password: e.password
|
|
2503
|
+
}
|
|
2504
|
+
}));
|
|
2505
|
+
case 2:
|
|
2506
|
+
case "end":
|
|
2507
|
+
return t.stop();
|
|
2508
|
+
}
|
|
2509
|
+
}, t, this);
|
|
2510
|
+
}));
|
|
2511
|
+
}
|
|
2512
|
+
}]), e;
|
|
2513
|
+
}();
|
|
2514
|
+
Promise.resolve({
|
|
2515
|
+
pkceRequiredForEmailMagicLinks: !1
|
|
2516
|
+
}), Promise.resolve({
|
|
2517
|
+
pkceRequiredForPasswordResets: !1
|
|
2518
|
+
});
|
|
2519
|
+
var je = function () {
|
|
2520
|
+
function e(t) {
|
|
2521
|
+
c(this, e), this.iframeURL = t, this.createIframe();
|
|
2522
|
+
}
|
|
2523
|
+
return a(e, [{
|
|
2524
|
+
key: "createIframe",
|
|
2525
|
+
value: function value() {
|
|
2526
|
+
var e = document.querySelector('[src~="'.concat(this.iframeURL, '"]'));
|
|
2527
|
+
e ? J("It looks like you're creating multiple copies of the Stytch client. This behavior is unsupported, and unintended side effects may occur. Make sure you are creating the Stytch client at the global level, and not inside a component's render function.") : ((e = document.createElement("iframe")).src = this.iframeURL, e.style.position = "absolute", e.style.width = "0", e.style.height = "0", e.style.border = "0", document.body.appendChild(e)), "true" !== e.dataset.loaded ? this.frame = new Promise(function (t) {
|
|
2528
|
+
e.addEventListener("load", function () {
|
|
2529
|
+
e.dataset.loaded = "true", t(e);
|
|
2530
|
+
}, {
|
|
2531
|
+
once: !0
|
|
2532
|
+
});
|
|
2533
|
+
}) : this.frame = Promise.resolve(e);
|
|
2534
|
+
}
|
|
2535
|
+
}, {
|
|
2536
|
+
key: "call",
|
|
2537
|
+
value: function value(e, t) {
|
|
2538
|
+
return w(this, void 0, void 0, o().mark(function r() {
|
|
2539
|
+
var n,
|
|
2540
|
+
i,
|
|
2541
|
+
s = this;
|
|
2542
|
+
return o().wrap(function (r) {
|
|
2543
|
+
for (;;) switch (r.prev = r.next) {
|
|
2544
|
+
case 0:
|
|
2545
|
+
return r.next = 2, this.frame;
|
|
2546
|
+
case 2:
|
|
2547
|
+
return n = r.sent, i = new MessageChannel(), r.abrupt("return", new Promise(function (r, o) {
|
|
2548
|
+
var a;
|
|
2549
|
+
i.port1.onmessage = function (e) {
|
|
2550
|
+
var t = e.data;
|
|
2551
|
+
i.port1.close(), t.success ? r(t.payload) : o(re.unmarshall(t.error));
|
|
2552
|
+
};
|
|
2553
|
+
var c = {
|
|
2554
|
+
method: e,
|
|
2555
|
+
args: t
|
|
2556
|
+
};
|
|
2557
|
+
null === (a = n.contentWindow) || void 0 === a || a.postMessage(c, s.iframeURL, [i.port2]);
|
|
2558
|
+
}));
|
|
2559
|
+
case 5:
|
|
2560
|
+
case "end":
|
|
2561
|
+
return r.stop();
|
|
2562
|
+
}
|
|
2563
|
+
}, r, this);
|
|
2564
|
+
}));
|
|
2565
|
+
}
|
|
2566
|
+
}]), e;
|
|
2567
|
+
}(),
|
|
2568
|
+
Me = function () {
|
|
2569
|
+
function e(t, r) {
|
|
2570
|
+
var n = this;
|
|
2571
|
+
c(this, e), this._subscriptionService = t, this._headlessSessionClient = r, this._onDataChange = function (e) {
|
|
2572
|
+
(null == e ? void 0 : e.session) ? n.scheduleBackgroundRefresh() : n.cancelBackgroundRefresh();
|
|
2573
|
+
}, this._reauthenticateWithBackoff = function () {
|
|
2574
|
+
return w(n, void 0, void 0, o().mark(function t() {
|
|
2575
|
+
var r;
|
|
2576
|
+
return o().wrap(function (t) {
|
|
2577
|
+
for (;;) switch (t.prev = t.next) {
|
|
2578
|
+
case 0:
|
|
2579
|
+
r = 0;
|
|
2580
|
+
case 1:
|
|
2581
|
+
return t.prev = 2, t.next = 5, this._headlessSessionClient.authenticate();
|
|
2582
|
+
case 5:
|
|
2583
|
+
return t.abrupt("return", t.sent);
|
|
2584
|
+
case 8:
|
|
2585
|
+
if (t.prev = 8, t.t0 = t["catch"](2), !e.isUnrecoverableError(t.t0)) {
|
|
2586
|
+
t.next = 12;
|
|
2587
|
+
break;
|
|
2588
|
+
}
|
|
2589
|
+
return t.abrupt("return", Promise.reject(t.t0));
|
|
2590
|
+
case 12:
|
|
2591
|
+
return r++, t.next = 15, new Promise(function (t) {
|
|
2592
|
+
return setTimeout(t, e.timeoutForAttempt(r));
|
|
2593
|
+
});
|
|
2594
|
+
case 15:
|
|
2595
|
+
t.next = 1;
|
|
2596
|
+
break;
|
|
2597
|
+
case 17:
|
|
2598
|
+
case "end":
|
|
2599
|
+
return t.stop();
|
|
2600
|
+
}
|
|
2601
|
+
}, t, this, [[2, 8]]);
|
|
2602
|
+
}));
|
|
2603
|
+
}, this.timeout = null, this._subscriptionService.subscribeToState(this._onDataChange);
|
|
2604
|
+
}
|
|
2605
|
+
return a(e, [{
|
|
2606
|
+
key: "performBackgroundRefresh",
|
|
2607
|
+
value: function value() {
|
|
2608
|
+
var e = this;
|
|
2609
|
+
this._reauthenticateWithBackoff().then(function () {
|
|
2610
|
+
e.scheduleBackgroundRefresh();
|
|
2611
|
+
})["catch"](function (t) {
|
|
2612
|
+
J("Session background refresh failed. Signalling to app that user is logged out.", {
|
|
2613
|
+
error: t
|
|
2614
|
+
}), e._subscriptionService.destroyState();
|
|
2615
|
+
});
|
|
2616
|
+
}
|
|
2617
|
+
}, {
|
|
2618
|
+
key: "scheduleBackgroundRefresh",
|
|
2619
|
+
value: function value() {
|
|
2620
|
+
var t = this;
|
|
2621
|
+
this.cancelBackgroundRefresh(), this.timeout = setTimeout(function () {
|
|
2622
|
+
t.performBackgroundRefresh();
|
|
2623
|
+
}, e.REFRESH_INTERVAL_MS);
|
|
2624
|
+
}
|
|
2625
|
+
}, {
|
|
2626
|
+
key: "cancelBackgroundRefresh",
|
|
2627
|
+
value: function value() {
|
|
2628
|
+
null !== this.timeout && (clearTimeout(this.timeout), this.timeout = null);
|
|
2629
|
+
}
|
|
2630
|
+
}], [{
|
|
2631
|
+
key: "timeoutForAttempt",
|
|
2632
|
+
value: function value(e) {
|
|
2633
|
+
return e = Math.min(e, 7), Math.floor(350 * Math.random()) - 175 + 2e3 * Math.pow(2, e);
|
|
2634
|
+
}
|
|
2635
|
+
}, {
|
|
2636
|
+
key: "isUnrecoverableError",
|
|
2637
|
+
value: function value(e) {
|
|
2638
|
+
return W.includes(e.error_type);
|
|
2639
|
+
}
|
|
2640
|
+
}]), e;
|
|
2641
|
+
}();
|
|
2642
|
+
Me.REFRESH_INTERVAL_MS = 18e4;
|
|
2643
|
+
var Ne = "bootstrap";
|
|
2644
|
+
var Ue = /*#__PURE__*/function () {
|
|
2645
|
+
function Ue(e, t, r) {
|
|
2646
|
+
var _this = this;
|
|
2647
|
+
_classCallCheck(this, Ue);
|
|
2648
|
+
this._publicToken = e, this._networkClient = t, this._dataLayer = r, this._bootstrapDataPromise = this._networkClient.fetchSDK({
|
|
2649
|
+
url: "/projects/bootstrap/".concat(this._publicToken),
|
|
2650
|
+
method: "GET",
|
|
2651
|
+
errorMessage: "Error fetching bootstrap data for SDK for ".concat(this._publicToken)
|
|
2652
|
+
}).then(Ue.mapBootstrapData).then(function (e) {
|
|
2653
|
+
return _this._dataLayer.setItem(Ne, JSON.stringify(e)), e;
|
|
2654
|
+
})["catch"](function (e) {
|
|
2655
|
+
return $(e), {
|
|
2656
|
+
displayWatermark: !1,
|
|
2657
|
+
cnameDomain: null,
|
|
2658
|
+
emailDomains: ["stytch.com"],
|
|
2659
|
+
captchaSettings: {
|
|
2660
|
+
enabled: !1
|
|
2661
|
+
},
|
|
2662
|
+
pkceRequiredForEmailMagicLinks: !1,
|
|
2663
|
+
pkceRequiredForPasswordResets: !1,
|
|
2664
|
+
pkceRequiredForOAuth: !1,
|
|
2665
|
+
pkceRequiredForSso: !1,
|
|
2666
|
+
slugPattern: null,
|
|
2667
|
+
createOrganizationEnabled: !1,
|
|
2668
|
+
passwordConfig: null,
|
|
2669
|
+
runDFPProtectedAuth: !1
|
|
2670
|
+
};
|
|
2671
|
+
});
|
|
2672
|
+
}
|
|
2673
|
+
_createClass(Ue, [{
|
|
2674
|
+
key: "getSync",
|
|
2675
|
+
value: function getSync() {
|
|
2676
|
+
var e = this._dataLayer.getItem(Ne);
|
|
2677
|
+
if (null === e) return {
|
|
2678
|
+
displayWatermark: !1,
|
|
2679
|
+
cnameDomain: null,
|
|
2680
|
+
emailDomains: ["stytch.com"],
|
|
2681
|
+
captchaSettings: {
|
|
2682
|
+
enabled: !1
|
|
2683
|
+
},
|
|
2684
|
+
pkceRequiredForEmailMagicLinks: !1,
|
|
2685
|
+
pkceRequiredForPasswordResets: !1,
|
|
2686
|
+
pkceRequiredForOAuth: !1,
|
|
2687
|
+
pkceRequiredForSso: !1,
|
|
2688
|
+
slugPattern: null,
|
|
2689
|
+
createOrganizationEnabled: !1,
|
|
2690
|
+
passwordConfig: null,
|
|
2691
|
+
runDFPProtectedAuth: !1
|
|
2692
|
+
};
|
|
2693
|
+
try {
|
|
2694
|
+
return JSON.parse(e);
|
|
2695
|
+
} catch (e) {
|
|
2696
|
+
return {
|
|
2697
|
+
displayWatermark: !1,
|
|
2698
|
+
cnameDomain: null,
|
|
2699
|
+
emailDomains: ["stytch.com"],
|
|
2700
|
+
captchaSettings: {
|
|
2701
|
+
enabled: !1
|
|
2702
|
+
},
|
|
2703
|
+
pkceRequiredForEmailMagicLinks: !1,
|
|
2704
|
+
pkceRequiredForPasswordResets: !1,
|
|
2705
|
+
pkceRequiredForOAuth: !1,
|
|
2706
|
+
pkceRequiredForSso: !1,
|
|
2707
|
+
slugPattern: null,
|
|
2708
|
+
createOrganizationEnabled: !1,
|
|
2709
|
+
passwordConfig: null,
|
|
2710
|
+
runDFPProtectedAuth: !1
|
|
2711
|
+
};
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
}, {
|
|
2715
|
+
key: "getAsync",
|
|
2716
|
+
value: function getAsync() {
|
|
2717
|
+
return this._bootstrapDataPromise;
|
|
2718
|
+
}
|
|
2719
|
+
}], [{
|
|
2720
|
+
key: "mapBootstrapData",
|
|
2721
|
+
value: function mapBootstrapData(e) {
|
|
2722
|
+
var t = null !== e.password_config ? {
|
|
2723
|
+
ludsComplexity: e.password_config.luds_complexity,
|
|
2724
|
+
ludsMinimumCount: e.password_config.luds_minimum_count
|
|
2725
|
+
} : null;
|
|
2726
|
+
return {
|
|
2727
|
+
displayWatermark: !e.disable_sdk_watermark,
|
|
2728
|
+
captchaSettings: e.captcha_settings,
|
|
2729
|
+
cnameDomain: e.cname_domain,
|
|
2730
|
+
emailDomains: e.email_domains,
|
|
2731
|
+
pkceRequiredForEmailMagicLinks: e.pkce_required_for_email_magic_links,
|
|
2732
|
+
pkceRequiredForPasswordResets: e.pkce_required_for_password_resets,
|
|
2733
|
+
pkceRequiredForOAuth: e.pkce_required_for_oauth,
|
|
2734
|
+
pkceRequiredForSso: e.pkce_required_for_sso,
|
|
2735
|
+
slugPattern: e.slug_pattern,
|
|
2736
|
+
createOrganizationEnabled: e.create_organization_enabled,
|
|
2737
|
+
passwordConfig: t,
|
|
2738
|
+
runDFPProtectedAuth: "ENABLED" === e.dfp_protected_auth_enabled || "PASSIVE" === e.dfp_protected_auth_enabled
|
|
2739
|
+
};
|
|
2740
|
+
}
|
|
2741
|
+
}]);
|
|
2742
|
+
return Ue;
|
|
2743
|
+
}();
|
|
2744
|
+
function Fe(e, t, r, n) {
|
|
2745
|
+
return new (r || (r = Promise))(function (i, o) {
|
|
2746
|
+
function s(e) {
|
|
2747
|
+
try {
|
|
2748
|
+
c(n.next(e));
|
|
2749
|
+
} catch (e) {
|
|
2750
|
+
o(e);
|
|
2751
|
+
}
|
|
2752
|
+
}
|
|
2753
|
+
function a(e) {
|
|
2754
|
+
try {
|
|
2755
|
+
c(n["throw"](e));
|
|
2756
|
+
} catch (e) {
|
|
2757
|
+
o(e);
|
|
2758
|
+
}
|
|
2759
|
+
}
|
|
2760
|
+
function c(e) {
|
|
2761
|
+
var t;
|
|
2762
|
+
e.done ? i(e.value) : (t = e.value, t instanceof r ? t : new r(function (e) {
|
|
2763
|
+
e(t);
|
|
2764
|
+
})).then(s, a);
|
|
2765
|
+
}
|
|
2766
|
+
c((n = n.apply(e, t || [])).next());
|
|
2767
|
+
});
|
|
2768
|
+
}
|
|
2769
|
+
var Ke = /*#__PURE__*/_createClass(function Ke(e) {
|
|
2770
|
+
var _this2 = this;
|
|
2771
|
+
_classCallCheck(this, Ke);
|
|
2772
|
+
this.bootstrapPromise = e, this.executeRecaptcha = function () {
|
|
2773
|
+
return Fe(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
2774
|
+
var _yield$this$state, e, t, r;
|
|
2775
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
2776
|
+
while (1) switch (_context.prev = _context.next) {
|
|
2777
|
+
case 0:
|
|
2778
|
+
_context.next = 2;
|
|
2779
|
+
return this.state;
|
|
2780
|
+
case 2:
|
|
2781
|
+
_yield$this$state = _context.sent;
|
|
2782
|
+
e = _yield$this$state.captchaClient;
|
|
2783
|
+
t = _yield$this$state.configured;
|
|
2784
|
+
r = _yield$this$state.siteKey;
|
|
2785
|
+
if (!t) {
|
|
2786
|
+
_context.next = 10;
|
|
2787
|
+
break;
|
|
2788
|
+
}
|
|
2789
|
+
_context.next = 9;
|
|
2790
|
+
return new Promise(function (t) {
|
|
2791
|
+
return e.ready(t);
|
|
2792
|
+
});
|
|
2793
|
+
case 9:
|
|
2794
|
+
return _context.abrupt("return", e.execute(r, {
|
|
2795
|
+
action: "LOGIN"
|
|
2796
|
+
}));
|
|
2797
|
+
case 10:
|
|
2798
|
+
case "end":
|
|
2799
|
+
return _context.stop();
|
|
2800
|
+
}
|
|
2801
|
+
}, _callee, this);
|
|
2802
|
+
}));
|
|
2803
|
+
}, this.state = e.then(function (e) {
|
|
2804
|
+
return Fe(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
2805
|
+
var t;
|
|
2806
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
2807
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
2808
|
+
case 0:
|
|
2809
|
+
if (!e.captchaSettings.enabled) {
|
|
2810
|
+
_context2.next = 9;
|
|
2811
|
+
break;
|
|
2812
|
+
}
|
|
2813
|
+
_context2.t1 = !0;
|
|
2814
|
+
_context2.next = 4;
|
|
2815
|
+
return t = e.captchaSettings.siteKey, H("https://www.google.com/recaptcha/enterprise.js?render=".concat(t), function () {
|
|
2816
|
+
return window.grecaptcha.enterprise;
|
|
2817
|
+
});
|
|
2818
|
+
case 4:
|
|
2819
|
+
_context2.t2 = _context2.sent;
|
|
2820
|
+
_context2.t3 = e.captchaSettings.siteKey;
|
|
2821
|
+
_context2.t0 = {
|
|
2822
|
+
configured: _context2.t1,
|
|
2823
|
+
captchaClient: _context2.t2,
|
|
2824
|
+
siteKey: _context2.t3
|
|
2825
|
+
};
|
|
2826
|
+
_context2.next = 10;
|
|
2827
|
+
break;
|
|
2828
|
+
case 9:
|
|
2829
|
+
_context2.t0 = {
|
|
2830
|
+
configured: !1
|
|
2831
|
+
};
|
|
2832
|
+
case 10:
|
|
2833
|
+
return _context2.abrupt("return", _context2.t0);
|
|
2834
|
+
case 11:
|
|
2835
|
+
case "end":
|
|
2836
|
+
return _context2.stop();
|
|
2837
|
+
}
|
|
2838
|
+
}, _callee2);
|
|
2839
|
+
}));
|
|
2840
|
+
});
|
|
2841
|
+
});
|
|
2842
|
+
var qe = /*#__PURE__*/function () {
|
|
2843
|
+
function qe(e) {
|
|
2844
|
+
var _this3 = this;
|
|
2845
|
+
_classCallCheck(this, qe);
|
|
2846
|
+
this.iframeURL = e, this.oneTapStart = function (e) {
|
|
2847
|
+
return _this3.call("oneTapStart", e);
|
|
2848
|
+
}, this.oneTapSubmit = function (e) {
|
|
2849
|
+
return _this3.call("oneTapSubmit", e);
|
|
2850
|
+
};
|
|
2851
|
+
}
|
|
2852
|
+
_createClass(qe, [{
|
|
2853
|
+
key: "frameClient",
|
|
2854
|
+
get: function get() {
|
|
2855
|
+
var e;
|
|
2856
|
+
return this._frameClient = null !== (e = this._frameClient) && void 0 !== e ? e : new je(this.iframeURL), this._frameClient;
|
|
2857
|
+
}
|
|
2858
|
+
}, {
|
|
2859
|
+
key: "call",
|
|
2860
|
+
value: function call(e, t) {
|
|
2861
|
+
return this.frameClient.call(e, [t]);
|
|
2862
|
+
}
|
|
2863
|
+
}]);
|
|
2864
|
+
return qe;
|
|
2865
|
+
}();
|
|
2866
|
+
function We(e) {
|
|
2867
|
+
return We = "function" == typeof Symbol && "symbol" == _typeof(Symbol.iterator) ? function (e) {
|
|
2868
|
+
return _typeof(e);
|
|
2869
|
+
} : function (e) {
|
|
2870
|
+
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : _typeof(e);
|
|
2871
|
+
}, We(e);
|
|
2872
|
+
}
|
|
2873
|
+
function Ge(e, t) {
|
|
2874
|
+
for (var r = 0; r < t.length; r++) {
|
|
2875
|
+
var n = t[r];
|
|
2876
|
+
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) {
|
|
2877
|
+
if ("object" !== We(e) || null === e) return e;
|
|
2878
|
+
var r = e[Symbol.toPrimitive];
|
|
2879
|
+
if (void 0 !== r) {
|
|
2880
|
+
var n = r.call(e, t || "default");
|
|
2881
|
+
if ("object" !== We(n)) return n;
|
|
2882
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
2883
|
+
}
|
|
2884
|
+
return ("string" === t ? String : Number)(e);
|
|
2885
|
+
}(i, "string"), "symbol" === We(o) ? o : String(o)), n);
|
|
2886
|
+
}
|
|
2887
|
+
var i, o;
|
|
2888
|
+
}
|
|
2889
|
+
function He(e, t, r) {
|
|
2890
|
+
return t && Ge(e.prototype, t), r && Ge(e, r), Object.defineProperty(e, "prototype", {
|
|
2891
|
+
writable: !1
|
|
2892
|
+
}), e;
|
|
2893
|
+
}
|
|
2894
|
+
function ze(e, t) {
|
|
2895
|
+
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
|
|
2896
|
+
}
|
|
2897
|
+
function Ye(e, t) {
|
|
2898
|
+
if ("function" != typeof t && null !== t) throw new TypeError("Super expression must either be null or a function");
|
|
2899
|
+
e.prototype = Object.create(t && t.prototype, {
|
|
2900
|
+
constructor: {
|
|
2901
|
+
value: e,
|
|
2902
|
+
writable: !0,
|
|
2903
|
+
configurable: !0
|
|
2904
|
+
}
|
|
2905
|
+
}), Object.defineProperty(e, "prototype", {
|
|
2906
|
+
writable: !1
|
|
2907
|
+
}), t && Qe(e, t);
|
|
2908
|
+
}
|
|
2909
|
+
function Ve(e) {
|
|
2910
|
+
var t = Ze();
|
|
2911
|
+
return function () {
|
|
2912
|
+
var r,
|
|
2913
|
+
n = et(e);
|
|
2914
|
+
if (t) {
|
|
2915
|
+
var i = et(this).constructor;
|
|
2916
|
+
r = Reflect.construct(n, arguments, i);
|
|
2917
|
+
} else r = n.apply(this, arguments);
|
|
2918
|
+
return function (e, t) {
|
|
2919
|
+
if (t && ("object" === We(t) || "function" == typeof t)) return t;
|
|
2920
|
+
if (void 0 !== t) throw new TypeError("Derived constructors may only return object or undefined");
|
|
2921
|
+
return Je(e);
|
|
2922
|
+
}(this, r);
|
|
2923
|
+
};
|
|
2924
|
+
}
|
|
2925
|
+
function Je(e) {
|
|
2926
|
+
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
2927
|
+
return e;
|
|
2928
|
+
}
|
|
2929
|
+
function $e(e) {
|
|
2930
|
+
var t = "function" == typeof Map ? new Map() : void 0;
|
|
2931
|
+
return $e = function $e(e) {
|
|
2932
|
+
if (null === e || (r = e, -1 === Function.toString.call(r).indexOf("[native code]"))) return e;
|
|
2933
|
+
var r;
|
|
2934
|
+
if ("function" != typeof e) throw new TypeError("Super expression must either be null or a function");
|
|
2935
|
+
if (void 0 !== t) {
|
|
2936
|
+
if (t.has(e)) return t.get(e);
|
|
2937
|
+
t.set(e, n);
|
|
2938
|
+
}
|
|
2939
|
+
function n() {
|
|
2940
|
+
return Xe(e, arguments, et(this).constructor);
|
|
2941
|
+
}
|
|
2942
|
+
return n.prototype = Object.create(e.prototype, {
|
|
2943
|
+
constructor: {
|
|
2944
|
+
value: n,
|
|
2945
|
+
enumerable: !1,
|
|
2946
|
+
writable: !0,
|
|
2947
|
+
configurable: !0
|
|
2948
|
+
}
|
|
2949
|
+
}), Qe(n, e);
|
|
2950
|
+
}, $e(e);
|
|
2951
|
+
}
|
|
2952
|
+
function Xe(e, t, r) {
|
|
2953
|
+
return Xe = Ze() ? Reflect.construct.bind() : function (e, t, r) {
|
|
2954
|
+
var n = [null];
|
|
2955
|
+
n.push.apply(n, t);
|
|
2956
|
+
var i = new (Function.bind.apply(e, n))();
|
|
2957
|
+
return r && Qe(i, r.prototype), i;
|
|
2958
|
+
}, Xe.apply(null, arguments);
|
|
2959
|
+
}
|
|
2960
|
+
function Ze() {
|
|
2961
|
+
if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
|
|
2962
|
+
if (Reflect.construct.sham) return !1;
|
|
2963
|
+
if ("function" == typeof Proxy) return !0;
|
|
2964
|
+
try {
|
|
2965
|
+
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})), !0;
|
|
2966
|
+
} catch (e) {
|
|
2967
|
+
return !1;
|
|
2968
|
+
}
|
|
2969
|
+
}
|
|
2970
|
+
function Qe(e, t) {
|
|
2971
|
+
return Qe = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (e, t) {
|
|
2972
|
+
return e.__proto__ = t, e;
|
|
2973
|
+
}, Qe(e, t);
|
|
2974
|
+
}
|
|
2975
|
+
function et(e) {
|
|
2976
|
+
return et = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (e) {
|
|
2977
|
+
return e.__proto__ || Object.getPrototypeOf(e);
|
|
2978
|
+
}, et(e);
|
|
2979
|
+
}
|
|
2980
|
+
exports.Products = void 0, function (e) {
|
|
2981
|
+
e.emailMagicLinks = "emailMagicLinks", e.oauth = "oauth", e.otp = "otp", e.crypto = "crypto", e.passwords = "passwords";
|
|
2982
|
+
}(exports.Products || (exports.Products = {})), exports.OAuthProviders = void 0, function (e) {
|
|
2983
|
+
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";
|
|
2984
|
+
}(exports.OAuthProviders || (exports.OAuthProviders = {})), exports.Wallets = void 0, function (e) {
|
|
2985
|
+
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";
|
|
2986
|
+
}(exports.Wallets || (exports.Wallets = {})), exports.OneTapPositions = void 0, function (e) {
|
|
2987
|
+
e.embedded = "embedded", e.floating = "floating";
|
|
2988
|
+
}(exports.OneTapPositions || (exports.OneTapPositions = {})), exports.OTPMethods = void 0, function (e) {
|
|
2989
|
+
e.SMS = "sms", e.WhatsApp = "whatsapp", e.Email = "email";
|
|
2990
|
+
}(exports.OTPMethods || (exports.OTPMethods = {})), exports.StytchEventType = void 0, function (e) {
|
|
2991
|
+
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";
|
|
2992
|
+
}(exports.StytchEventType || (exports.StytchEventType = {}));
|
|
2993
|
+
var tt = function (e) {
|
|
2994
|
+
Ye(r, $e(Error));
|
|
2995
|
+
var t = Ve(r);
|
|
2996
|
+
function r(e, n) {
|
|
2997
|
+
var i;
|
|
2998
|
+
return ze(this, r), (i = t.call(this, e + "\n" + n)).message = e + "\n" + n, i.name = "SDKAPIUnreachableError", i.details = n, Object.setPrototypeOf(Je(i), r.prototype), i;
|
|
2999
|
+
}
|
|
3000
|
+
return He(r);
|
|
3001
|
+
}(),
|
|
3002
|
+
rt = function (e) {
|
|
3003
|
+
Ye(r, $e(Error));
|
|
3004
|
+
var t = Ve(r);
|
|
3005
|
+
function r(e, n) {
|
|
3006
|
+
var i;
|
|
3007
|
+
return ze(this, r), (i = t.call(this)).name = "StytchSDKUsageError", i.message = "Invalid call to ".concat(e, "\n") + n, i;
|
|
3008
|
+
}
|
|
3009
|
+
return He(r);
|
|
3010
|
+
}(),
|
|
3011
|
+
nt = function (e) {
|
|
3012
|
+
Ye(r, $e(Error));
|
|
3013
|
+
var t = Ve(r);
|
|
3014
|
+
function r(e) {
|
|
3015
|
+
var n, i;
|
|
3016
|
+
ze(this, r), (n = t.call(this)).name = "StytchSDKSchemaError";
|
|
3017
|
+
var o = null === (i = e.body) || void 0 === i ? void 0 : i.map(function (e) {
|
|
3018
|
+
return "".concat(e.dataPath, ": ").concat(e.message);
|
|
3019
|
+
}).join("\n");
|
|
3020
|
+
return n.message = "[400] Request does not match expected schema\n".concat(o), n;
|
|
3021
|
+
}
|
|
3022
|
+
return He(r);
|
|
3023
|
+
}(),
|
|
3024
|
+
it = function (e) {
|
|
3025
|
+
Ye(r, $e(Error));
|
|
3026
|
+
var t = Ve(r);
|
|
3027
|
+
function r(e) {
|
|
3028
|
+
var n;
|
|
3029
|
+
ze(this, r), (n = t.call(this)).name = "StytchSDKAPIError";
|
|
3030
|
+
var i = e.status_code,
|
|
3031
|
+
o = e.error_type,
|
|
3032
|
+
s = e.error_message,
|
|
3033
|
+
a = e.error_url,
|
|
3034
|
+
c = e.request_id;
|
|
3035
|
+
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;
|
|
3036
|
+
}
|
|
3037
|
+
return He(r);
|
|
3038
|
+
}(),
|
|
3039
|
+
ot = function (e) {
|
|
3040
|
+
Ye(r, $e(Error));
|
|
3041
|
+
var t = Ve(r);
|
|
3042
|
+
function r(e) {
|
|
3043
|
+
var n;
|
|
3044
|
+
return ze(this, r), (n = t.call(this)).name = "StytchSDKNativeError", n.error_type = e, n.message = "".concat(e), n;
|
|
3045
|
+
}
|
|
3046
|
+
return He(r);
|
|
3047
|
+
}();
|
|
3048
|
+
exports.BiometricsErrors = void 0, function (e) {
|
|
3049
|
+
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";
|
|
3050
|
+
}(exports.BiometricsErrors || (exports.BiometricsErrors = {})), exports.B2BProducts = void 0, function (e) {
|
|
3051
|
+
e.emailMagicLinks = "emailMagicLinks", e.sso = "sso", e.passwords = "passwords", e.oauth = "oauth";
|
|
3052
|
+
}(exports.B2BProducts || (exports.B2BProducts = {})), exports.AuthFlowType = void 0, function (e) {
|
|
3053
|
+
e.Discovery = "Discovery", e.Organization = "Organization", e.PasswordReset = "PasswordReset";
|
|
3054
|
+
}(exports.AuthFlowType || (exports.AuthFlowType = {})), exports.B2BOAuthProviders = void 0, function (e) {
|
|
3055
|
+
e.Google = "google", e.Microsoft = "microsoft";
|
|
3056
|
+
}(exports.B2BOAuthProviders || (exports.B2BOAuthProviders = {}));
|
|
3057
|
+
var st = /*#__PURE__*/function (_ue) {
|
|
3058
|
+
_inherits(st, _ue);
|
|
3059
|
+
var _super = _createSuper(st);
|
|
3060
|
+
function st(e, t, r, n, i, o) {
|
|
3061
|
+
var _this4;
|
|
3062
|
+
_classCallCheck(this, st);
|
|
3063
|
+
_this4 = _super.call(this, e, t, r, n, i), _this4._oneTap = o, _this4.startOneTap = function (e) {
|
|
3064
|
+
return Fe(_assertThisInitialized(_this4), void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
3065
|
+
var t, r, n;
|
|
3066
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
3067
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
3068
|
+
case 0:
|
|
3069
|
+
_context3.next = 2;
|
|
3070
|
+
return this._oneTap.createOneTapClient();
|
|
3071
|
+
case 2:
|
|
3072
|
+
t = _context3.sent;
|
|
3073
|
+
if (t.success) {
|
|
3074
|
+
_context3.next = 5;
|
|
3075
|
+
break;
|
|
3076
|
+
}
|
|
3077
|
+
throw new Error("One Tap could not load: ".concat(t.reason));
|
|
3078
|
+
case 5:
|
|
3079
|
+
r = t.client, n = this._oneTap.createOnSuccessHandler({
|
|
3080
|
+
signupRedirectUrl: e.signup_redirect_url,
|
|
3081
|
+
loginRedirectUrl: e.login_redirect_url,
|
|
3082
|
+
onSuccess: this._oneTap.RedirectOnSuccess
|
|
3083
|
+
});
|
|
3084
|
+
return _context3.abrupt("return", r.render({
|
|
3085
|
+
style: {
|
|
3086
|
+
position: exports.OneTapPositions.floating
|
|
3087
|
+
},
|
|
3088
|
+
onOneTapCancelled: e.onOneTapCancelled,
|
|
3089
|
+
callback: n
|
|
3090
|
+
}));
|
|
3091
|
+
case 7:
|
|
3092
|
+
case "end":
|
|
3093
|
+
return _context3.stop();
|
|
3094
|
+
}
|
|
3095
|
+
}, _callee3, this);
|
|
3096
|
+
}));
|
|
3097
|
+
}, _this4.googleOneTap = {
|
|
3098
|
+
start: _this4.startOneTap
|
|
3099
|
+
};
|
|
3100
|
+
return _this4;
|
|
3101
|
+
}
|
|
3102
|
+
return _createClass(st);
|
|
3103
|
+
}(ue);
|
|
3104
|
+
var at = /*#__PURE__*/function () {
|
|
3105
|
+
function at(e, t, r, n) {
|
|
3106
|
+
_classCallCheck(this, at);
|
|
3107
|
+
this._publicToken = e, this._subscriptionDataLayer = t, this.baseURL = r, this.additionalTelemetryDataFn = n, this.updateSessionToken = function () {
|
|
3108
|
+
return null;
|
|
3109
|
+
}, this.eventLogger = new ne({
|
|
3110
|
+
maxBatchSize: 15,
|
|
3111
|
+
intervalDurationMs: 800,
|
|
3112
|
+
logEventURL: this.buildSDKUrl("/events")
|
|
3113
|
+
});
|
|
3114
|
+
}
|
|
3115
|
+
_createClass(at, [{
|
|
3116
|
+
key: "logEvent",
|
|
3117
|
+
value: function logEvent(_ref) {
|
|
3118
|
+
var e = _ref.name,
|
|
3119
|
+
t = _ref.details,
|
|
3120
|
+
_ref$error = _ref.error,
|
|
3121
|
+
r = _ref$error === void 0 ? {} : _ref$error;
|
|
3122
|
+
this.eventLogger.logEvent(this.createTelemetryBlob(), {
|
|
3123
|
+
public_token: this._publicToken,
|
|
3124
|
+
event_name: e,
|
|
3125
|
+
details: t,
|
|
3126
|
+
error_code: r.error_code,
|
|
3127
|
+
error_description: r.error_description,
|
|
3128
|
+
http_status_code: r.http_status_code
|
|
3129
|
+
});
|
|
3130
|
+
}
|
|
3131
|
+
}, {
|
|
3132
|
+
key: "createTelemetryBlob",
|
|
3133
|
+
value: function createTelemetryBlob() {
|
|
3134
|
+
return Object.assign(Object.assign({
|
|
3135
|
+
event_id: "event-id-".concat(D()),
|
|
3136
|
+
app_session_id: "app-session-id-".concat(D()),
|
|
3137
|
+
persistent_id: "persistent-id-".concat(D()),
|
|
3138
|
+
client_sent_at: new Date().toISOString(),
|
|
3139
|
+
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
3140
|
+
}, this.additionalTelemetryDataFn()), {
|
|
3141
|
+
app: {
|
|
3142
|
+
identifier: window.location.hostname
|
|
3143
|
+
},
|
|
3144
|
+
sdk: {
|
|
3145
|
+
identifier: "Stytch.js Javascript SDK",
|
|
3146
|
+
version: "2.0.2"
|
|
3147
|
+
}
|
|
3148
|
+
});
|
|
3149
|
+
}
|
|
3150
|
+
}, {
|
|
3151
|
+
key: "fetchSDK",
|
|
3152
|
+
value: function fetchSDK(_ref2) {
|
|
3153
|
+
var e = _ref2.url,
|
|
3154
|
+
t = _ref2.body,
|
|
3155
|
+
r = _ref2.errorMessage,
|
|
3156
|
+
n = _ref2.method;
|
|
3157
|
+
return Fe(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
3158
|
+
var i, s, a, c;
|
|
3159
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
3160
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
3161
|
+
case 0:
|
|
3162
|
+
i = this._subscriptionDataLayer.readSessionCookie().session_token, s = "Basic " + window.btoa(this._publicToken + ":" + (i || this._publicToken)), a = window.btoa(JSON.stringify(this.createTelemetryBlob())), c = window.location.origin;
|
|
3163
|
+
return _context4.abrupt("return", function (e) {
|
|
3164
|
+
var t = e.method,
|
|
3165
|
+
r = e.errorMessage,
|
|
3166
|
+
n = e.finalURL,
|
|
3167
|
+
i = e.basicAuthHeader,
|
|
3168
|
+
s = e.xSDKClientHeader,
|
|
3169
|
+
a = e.xSDKParentHostHeader,
|
|
3170
|
+
c = e.body;
|
|
3171
|
+
return w(this, void 0, void 0, o().mark(function e() {
|
|
3172
|
+
var u, l, d, h, p;
|
|
3173
|
+
return o().wrap(function (e) {
|
|
3174
|
+
for (;;) switch (e.prev = e.next) {
|
|
3175
|
+
case 0:
|
|
3176
|
+
return u = {
|
|
3177
|
+
Authorization: i,
|
|
3178
|
+
"Content-Type": "application/json",
|
|
3179
|
+
"X-SDK-Client": s
|
|
3180
|
+
}, a && (u["X-SDK-Parent-Host"] = a), l = {
|
|
3181
|
+
method: t,
|
|
3182
|
+
headers: u,
|
|
3183
|
+
body: c && JSON.stringify(c)
|
|
3184
|
+
}, e.prev = 3, e.next = 6, fetch(n, l);
|
|
3185
|
+
case 6:
|
|
3186
|
+
d = e.sent, e.next = 14;
|
|
3187
|
+
break;
|
|
3188
|
+
case 9:
|
|
3189
|
+
if (e.prev = 9, e.t0 = e["catch"](3), "Failed to fetch" !== e.t0.message) {
|
|
3190
|
+
e.next = 13;
|
|
3191
|
+
break;
|
|
3192
|
+
}
|
|
3193
|
+
throw new U(r, "Unable to contact the Stytch servers. Are you online?");
|
|
3194
|
+
case 13:
|
|
3195
|
+
throw e.t0;
|
|
3196
|
+
case 14:
|
|
3197
|
+
if (200 === d.status) {
|
|
3198
|
+
e.next = 27;
|
|
3199
|
+
break;
|
|
3200
|
+
}
|
|
3201
|
+
return e.prev = 15, e.next = 18, d.json();
|
|
3202
|
+
case 18:
|
|
3203
|
+
h = e.sent, e.next = 24;
|
|
3204
|
+
break;
|
|
3205
|
+
case 21:
|
|
3206
|
+
throw e.prev = 21, e.t1 = e["catch"](15), new U(r, "Invalid or no response from server");
|
|
3207
|
+
case 24:
|
|
3208
|
+
if (!("body" in h || "params" in h || "query" in h)) {
|
|
3209
|
+
e.next = 26;
|
|
3210
|
+
break;
|
|
3211
|
+
}
|
|
3212
|
+
throw new K(h);
|
|
3213
|
+
case 26:
|
|
3214
|
+
throw new q(h);
|
|
3215
|
+
case 27:
|
|
3216
|
+
return e.prev = 27, e.next = 30, d.json();
|
|
3217
|
+
case 30:
|
|
3218
|
+
return p = e.sent, e.abrupt("return", p.data);
|
|
3219
|
+
case 34:
|
|
3220
|
+
throw e.prev = 34, e.t2 = e["catch"](27), new U(r, "Invalid response from the Stytch servers.");
|
|
3221
|
+
case 37:
|
|
3222
|
+
case "end":
|
|
3223
|
+
return e.stop();
|
|
3224
|
+
}
|
|
3225
|
+
}, e, null, [[3, 9], [15, 21], [27, 34]]);
|
|
3226
|
+
}));
|
|
3227
|
+
}({
|
|
3228
|
+
basicAuthHeader: s,
|
|
3229
|
+
body: t,
|
|
3230
|
+
errorMessage: r,
|
|
3231
|
+
finalURL: this.buildSDKUrl(e),
|
|
3232
|
+
method: n,
|
|
3233
|
+
xSDKClientHeader: a,
|
|
3234
|
+
xSDKParentHostHeader: c
|
|
3235
|
+
}));
|
|
3236
|
+
case 2:
|
|
3237
|
+
case "end":
|
|
3238
|
+
return _context4.stop();
|
|
3239
|
+
}
|
|
3240
|
+
}, _callee4, this);
|
|
3241
|
+
}));
|
|
3242
|
+
}
|
|
3243
|
+
}, {
|
|
3244
|
+
key: "buildSDKUrl",
|
|
3245
|
+
value: function buildSDKUrl(e) {
|
|
3246
|
+
return "".concat(this.baseURL, "/sdk/v1").concat(e);
|
|
3247
|
+
}
|
|
3248
|
+
}]);
|
|
3249
|
+
return at;
|
|
3250
|
+
}();
|
|
3251
|
+
var ct = /*#__PURE__*/function () {
|
|
3252
|
+
function ct(e, t, r) {
|
|
3253
|
+
_classCallCheck(this, ct);
|
|
3254
|
+
this._googleClient = e, this._publicToken = t, this._clientId = r;
|
|
3255
|
+
}
|
|
3256
|
+
_createClass(ct, [{
|
|
3257
|
+
key: "cancel",
|
|
3258
|
+
value: function cancel() {
|
|
3259
|
+
this._googleClient.cancel();
|
|
3260
|
+
}
|
|
3261
|
+
}, {
|
|
3262
|
+
key: "render",
|
|
3263
|
+
value: function render(_ref3) {
|
|
3264
|
+
var e = _ref3.callback,
|
|
3265
|
+
t = _ref3.onOneTapCancelled,
|
|
3266
|
+
r = _ref3.style;
|
|
3267
|
+
return Fe(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
3268
|
+
var _this5 = this;
|
|
3269
|
+
var n;
|
|
3270
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
3271
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
3272
|
+
case 0:
|
|
3273
|
+
n = {
|
|
3274
|
+
client_id: this._clientId,
|
|
3275
|
+
callback: e,
|
|
3276
|
+
auto_select: !1,
|
|
3277
|
+
context: "use",
|
|
3278
|
+
itp_support: !0
|
|
3279
|
+
};
|
|
3280
|
+
return _context5.abrupt("return", (r.position === exports.OneTapPositions.embedded && (n.prompt_parent_id = "google-parent-prompt", n.cancel_on_tap_outside = !1), this._googleClient.initialize(n), new Promise(function (e) {
|
|
3281
|
+
_this5._googleClient.prompt(function (n) {
|
|
3282
|
+
return n.isSkippedMoment() ? ("user_cancel" === n.getSkippedReason() && (null == t || t()), e({
|
|
3283
|
+
success: !1,
|
|
3284
|
+
reason: n.getSkippedReason()
|
|
3285
|
+
})) : n.isNotDisplayed() ? e({
|
|
3286
|
+
success: !1,
|
|
3287
|
+
reason: n.getNotDisplayedReason()
|
|
3288
|
+
}) : (_this5.styleFrame(r), e({
|
|
3289
|
+
success: !0
|
|
3290
|
+
}));
|
|
3291
|
+
});
|
|
3292
|
+
})));
|
|
3293
|
+
case 2:
|
|
3294
|
+
case "end":
|
|
3295
|
+
return _context5.stop();
|
|
3296
|
+
}
|
|
3297
|
+
}, _callee5, this);
|
|
3298
|
+
}));
|
|
3299
|
+
}
|
|
3300
|
+
}, {
|
|
3301
|
+
key: "styleFrame",
|
|
3302
|
+
value: function styleFrame(e) {
|
|
3303
|
+
e.position === exports.OneTapPositions.embedded && Array.from(document.getElementsByTagName("iframe")).forEach(function (e) {
|
|
3304
|
+
e.src.includes(y) && (e.style.width = "100%");
|
|
3305
|
+
});
|
|
3306
|
+
}
|
|
3307
|
+
}]);
|
|
3308
|
+
return ct;
|
|
3309
|
+
}();
|
|
3310
|
+
var ut = /*#__PURE__*/function () {
|
|
3311
|
+
function ut(e, t) {
|
|
3312
|
+
var _this6 = this;
|
|
3313
|
+
_classCallCheck(this, ut);
|
|
3314
|
+
this._publicToken = e, this.clientsideServices = t, this.createOnSuccessHandler = function (_ref4) {
|
|
3315
|
+
var e = _ref4.loginRedirectUrl,
|
|
3316
|
+
t = _ref4.signupRedirectUrl,
|
|
3317
|
+
r = _ref4.onSuccess;
|
|
3318
|
+
return function (n) {
|
|
3319
|
+
return Fe(_this6, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
3320
|
+
var i, _yield$this$submitGoo, o;
|
|
3321
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
3322
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
3323
|
+
case 0:
|
|
3324
|
+
i = n.credential;
|
|
3325
|
+
_context6.next = 3;
|
|
3326
|
+
return this.submitGoogleOneTapToken({
|
|
3327
|
+
credential: i,
|
|
3328
|
+
loginRedirectUrl: e,
|
|
3329
|
+
signupRedirectUrl: t
|
|
3330
|
+
});
|
|
3331
|
+
case 3:
|
|
3332
|
+
_yield$this$submitGoo = _context6.sent;
|
|
3333
|
+
o = _yield$this$submitGoo.redirect_url;
|
|
3334
|
+
r(o);
|
|
3335
|
+
case 6:
|
|
3336
|
+
case "end":
|
|
3337
|
+
return _context6.stop();
|
|
3338
|
+
}
|
|
3339
|
+
}, _callee6, this);
|
|
3340
|
+
}));
|
|
3341
|
+
};
|
|
3342
|
+
}, this.RedirectOnSuccess = function (e) {
|
|
3343
|
+
window.location.href = e;
|
|
3344
|
+
};
|
|
3345
|
+
}
|
|
3346
|
+
_createClass(ut, [{
|
|
3347
|
+
key: "createOneTapClient",
|
|
3348
|
+
value: function createOneTapClient() {
|
|
3349
|
+
return Fe(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
3350
|
+
var e, _yield$this$fetchGoog;
|
|
3351
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
3352
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
3353
|
+
case 0:
|
|
3354
|
+
_context7.prev = 0;
|
|
3355
|
+
_context7.next = 3;
|
|
3356
|
+
return this.fetchGoogleStart();
|
|
3357
|
+
case 3:
|
|
3358
|
+
_yield$this$fetchGoog = _context7.sent;
|
|
3359
|
+
e = _yield$this$fetchGoog.googleClientId;
|
|
3360
|
+
_context7.next = 10;
|
|
3361
|
+
break;
|
|
3362
|
+
case 7:
|
|
3363
|
+
_context7.prev = 7;
|
|
3364
|
+
_context7.t0 = _context7["catch"](0);
|
|
3365
|
+
return _context7.abrupt("return", {
|
|
3366
|
+
success: !1,
|
|
3367
|
+
reason: _context7.t0.error_type
|
|
3368
|
+
});
|
|
3369
|
+
case 10:
|
|
3370
|
+
if (!("" === e)) {
|
|
3371
|
+
_context7.next = 12;
|
|
3372
|
+
break;
|
|
3373
|
+
}
|
|
3374
|
+
return _context7.abrupt("return", {
|
|
3375
|
+
success: !1,
|
|
3376
|
+
reason: "oauth_config_not_found"
|
|
3377
|
+
});
|
|
3378
|
+
case 12:
|
|
3379
|
+
_context7.t1 = !0;
|
|
3380
|
+
_context7.t2 = ct;
|
|
3381
|
+
_context7.next = 16;
|
|
3382
|
+
return H(g, function () {
|
|
3383
|
+
return window.google.accounts.id;
|
|
3384
|
+
});
|
|
3385
|
+
case 16:
|
|
3386
|
+
_context7.t3 = _context7.sent;
|
|
3387
|
+
_context7.t4 = this._publicToken;
|
|
3388
|
+
_context7.t5 = e;
|
|
3389
|
+
_context7.t6 = new _context7.t2(_context7.t3, _context7.t4, _context7.t5);
|
|
3390
|
+
return _context7.abrupt("return", {
|
|
3391
|
+
success: _context7.t1,
|
|
3392
|
+
client: _context7.t6
|
|
3393
|
+
});
|
|
3394
|
+
case 21:
|
|
3395
|
+
case "end":
|
|
3396
|
+
return _context7.stop();
|
|
3397
|
+
}
|
|
3398
|
+
}, _callee7, this, [[0, 7]]);
|
|
3399
|
+
}));
|
|
3400
|
+
}
|
|
3401
|
+
}, {
|
|
3402
|
+
key: "fetchGoogleStart",
|
|
3403
|
+
value: function fetchGoogleStart() {
|
|
3404
|
+
return this.googleConfig || (this.googleConfig = this.clientsideServices.oneTapStart({
|
|
3405
|
+
publicToken: this._publicToken
|
|
3406
|
+
})), this.googleConfig;
|
|
3407
|
+
}
|
|
3408
|
+
}, {
|
|
3409
|
+
key: "submitGoogleOneTapToken",
|
|
3410
|
+
value: function submitGoogleOneTapToken(_ref5) {
|
|
3411
|
+
var e = _ref5.credential,
|
|
3412
|
+
t = _ref5.loginRedirectUrl,
|
|
3413
|
+
r = _ref5.signupRedirectUrl;
|
|
3414
|
+
return Fe(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
3415
|
+
var _yield$this$fetchGoog2, n;
|
|
3416
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
3417
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
3418
|
+
case 0:
|
|
3419
|
+
_context8.next = 2;
|
|
3420
|
+
return this.fetchGoogleStart();
|
|
3421
|
+
case 2:
|
|
3422
|
+
_yield$this$fetchGoog2 = _context8.sent;
|
|
3423
|
+
n = _yield$this$fetchGoog2.oauthCallbackId;
|
|
3424
|
+
return _context8.abrupt("return", this.clientsideServices.oneTapSubmit({
|
|
3425
|
+
publicToken: this._publicToken,
|
|
3426
|
+
idToken: e,
|
|
3427
|
+
loginRedirectURL: t,
|
|
3428
|
+
oauthCallbackID: n,
|
|
3429
|
+
signupRedirectURL: r
|
|
3430
|
+
}));
|
|
3431
|
+
case 5:
|
|
3432
|
+
case "end":
|
|
3433
|
+
return _context8.stop();
|
|
3434
|
+
}
|
|
3435
|
+
}, _callee8, this);
|
|
3436
|
+
}));
|
|
3437
|
+
}
|
|
3438
|
+
}], [{
|
|
3439
|
+
key: "WillGoogleOneTapShowBannerForUA",
|
|
3440
|
+
value: function WillGoogleOneTapShowBannerForUA(e) {
|
|
3441
|
+
var t = function t(e, _t2) {
|
|
3442
|
+
return -1 !== e.indexOf(_t2);
|
|
3443
|
+
},
|
|
3444
|
+
r = t(e, "iPad") || t(e, "Android") && !t(e, "Mobile") || t(e, "Silk"),
|
|
3445
|
+
n = t(e, "iPod") || t(e, "iPhone") || t(e, "Android") || t(e, "IEMobile");
|
|
3446
|
+
return !r && n;
|
|
3447
|
+
}
|
|
3448
|
+
}, {
|
|
3449
|
+
key: "WillGoogleOneTapShowEmbedded",
|
|
3450
|
+
value: function WillGoogleOneTapShowEmbedded() {
|
|
3451
|
+
return !ut.WillGoogleOneTapShowBannerForUA(navigator.userAgent);
|
|
3452
|
+
}
|
|
3453
|
+
}]);
|
|
3454
|
+
return ut;
|
|
3455
|
+
}();
|
|
3456
|
+
function lt(e) {
|
|
3457
|
+
var t = e.toString(16);
|
|
3458
|
+
return 1 === t.length && (t = "0" + t), t;
|
|
3459
|
+
}
|
|
3460
|
+
var dt = /*#__PURE__*/function () {
|
|
3461
|
+
function dt(e, t) {
|
|
3462
|
+
_classCallCheck(this, dt);
|
|
3463
|
+
this._dataLayer = e, this.namespace = t;
|
|
3464
|
+
}
|
|
3465
|
+
_createClass(dt, [{
|
|
3466
|
+
key: "key",
|
|
3467
|
+
value: function key() {
|
|
3468
|
+
return "PKCE_VERIFIER:" + this.namespace;
|
|
3469
|
+
}
|
|
3470
|
+
}, {
|
|
3471
|
+
key: "startPKCETransaction",
|
|
3472
|
+
value: function startPKCETransaction() {
|
|
3473
|
+
return Fe(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
3474
|
+
var e;
|
|
3475
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
3476
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
3477
|
+
case 0:
|
|
3478
|
+
_context9.next = 2;
|
|
3479
|
+
return dt.createProofkeyPair();
|
|
3480
|
+
case 2:
|
|
3481
|
+
e = _context9.sent;
|
|
3482
|
+
return _context9.abrupt("return", (this._dataLayer.setItem(this.key(), JSON.stringify(e)), e));
|
|
3483
|
+
case 4:
|
|
3484
|
+
case "end":
|
|
3485
|
+
return _context9.stop();
|
|
3486
|
+
}
|
|
3487
|
+
}, _callee9, this);
|
|
3488
|
+
}));
|
|
3489
|
+
}
|
|
3490
|
+
}, {
|
|
3491
|
+
key: "getPKPair",
|
|
3492
|
+
value: function getPKPair() {
|
|
3493
|
+
var e = this._dataLayer.getItem(this.key());
|
|
3494
|
+
if (null !== e) try {
|
|
3495
|
+
return JSON.parse(e);
|
|
3496
|
+
} catch (e) {
|
|
3497
|
+
return void J("Found malformed Proof Key pair in localstorage.");
|
|
3498
|
+
}
|
|
3499
|
+
}
|
|
3500
|
+
}, {
|
|
3501
|
+
key: "clearPKPair",
|
|
3502
|
+
value: function clearPKPair() {
|
|
3503
|
+
return this._dataLayer.removeItem(this.key());
|
|
3504
|
+
}
|
|
3505
|
+
}], [{
|
|
3506
|
+
key: "createProofkeyPair",
|
|
3507
|
+
value: function createProofkeyPair() {
|
|
3508
|
+
return Fe(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
3509
|
+
var _String$fromCharCode;
|
|
3510
|
+
var e, t, r, n;
|
|
3511
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
3512
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
3513
|
+
case 0:
|
|
3514
|
+
e = new Uint32Array(16);
|
|
3515
|
+
window.crypto.getRandomValues(e);
|
|
3516
|
+
t = Array.from(e).map(lt).join("");
|
|
3517
|
+
_context10.next = 5;
|
|
3518
|
+
return window.crypto.subtle.digest("SHA-256", new TextEncoder().encode(t));
|
|
3519
|
+
case 5:
|
|
3520
|
+
r = _context10.sent;
|
|
3521
|
+
return _context10.abrupt("return", {
|
|
3522
|
+
code_challenge: (n = r, btoa((_String$fromCharCode = String.fromCharCode).call.apply(_String$fromCharCode, [null].concat(_toConsumableArray(new Uint8Array(n))))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "")),
|
|
3523
|
+
code_verifier: t
|
|
3524
|
+
});
|
|
3525
|
+
case 7:
|
|
3526
|
+
case "end":
|
|
3527
|
+
return _context10.stop();
|
|
3528
|
+
}
|
|
3529
|
+
}, _callee10);
|
|
3530
|
+
}));
|
|
3531
|
+
}
|
|
3532
|
+
}]);
|
|
3533
|
+
return dt;
|
|
3534
|
+
}();
|
|
3535
|
+
var ht = /*#__PURE__*/function () {
|
|
3536
|
+
function ht(e) {
|
|
3537
|
+
_classCallCheck(this, ht);
|
|
3538
|
+
this._networkClient = e;
|
|
3539
|
+
}
|
|
3540
|
+
_createClass(ht, [{
|
|
3541
|
+
key: "searchUser",
|
|
3542
|
+
value: function searchUser(e) {
|
|
3543
|
+
return this._networkClient.fetchSDK({
|
|
3544
|
+
url: "/users/search",
|
|
3545
|
+
method: "POST",
|
|
3546
|
+
body: {
|
|
3547
|
+
email: e
|
|
3548
|
+
},
|
|
3549
|
+
errorMessage: "Error searching for user ".concat(e)
|
|
3550
|
+
});
|
|
3551
|
+
}
|
|
3552
|
+
}, {
|
|
3553
|
+
key: "searchOrganization",
|
|
3554
|
+
value: function searchOrganization(e) {
|
|
3555
|
+
return this._networkClient.fetchSDK({
|
|
3556
|
+
url: "/b2b/organizations/search",
|
|
3557
|
+
method: "POST",
|
|
3558
|
+
body: {
|
|
3559
|
+
organization_slug: e
|
|
3560
|
+
},
|
|
3561
|
+
errorMessage: "Error searching slug"
|
|
3562
|
+
});
|
|
3563
|
+
}
|
|
3564
|
+
}, {
|
|
3565
|
+
key: "searchMember",
|
|
3566
|
+
value: function searchMember(e, t) {
|
|
3567
|
+
return this._networkClient.fetchSDK({
|
|
3568
|
+
url: "/b2b/organizations/members/search",
|
|
3569
|
+
method: "POST",
|
|
3570
|
+
body: {
|
|
3571
|
+
email_address: e,
|
|
3572
|
+
organization_id: t
|
|
3573
|
+
},
|
|
3574
|
+
errorMessage: "Error searching for member ".concat(e)
|
|
3575
|
+
});
|
|
3576
|
+
}
|
|
3577
|
+
}]);
|
|
3578
|
+
return ht;
|
|
3579
|
+
}();
|
|
3580
|
+
var pt = function pt(e) {
|
|
3581
|
+
return (document.cookie ? document.cookie.split("; ") : []).filter(function (t) {
|
|
3582
|
+
var _t$split = t.split("="),
|
|
3583
|
+
_t$split2 = _slicedToArray(_t$split, 1),
|
|
3584
|
+
r = _t$split2[0];
|
|
3585
|
+
return e === r;
|
|
3586
|
+
}).length > 1;
|
|
3587
|
+
};
|
|
4
3588
|
/*! js-cookie v3.0.1 | MIT */
|
|
5
|
-
function Pt(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)e[n]=r[n]}return e}var Rt=function e(t,r){function n(e,n,i){if("undefined"!=typeof document){"number"==typeof(i=Pt({},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);var o="";for(var s in i)i[s]&&(o+="; "+s,!0!==i[s]&&(o+="="+i[s].split(";")[0]));return document.cookie=e+"="+t.write(n,e)+o}}return Object.create({set:n,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var r=document.cookie?document.cookie.split("; "):[],n={},i=0;i<r.length;i++){var o=r[i].split("="),s=o.slice(1).join("=");try{var a=decodeURIComponent(o[0]);if(n[a]=t.read(s,a),e===a)break}catch(e){}}return e?n[e]:n}},remove:function(e,t){n(e,"",Pt({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,Pt({},this.attributes,t))},withConverter:function(t){return e(Pt({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(r)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"}),Bt=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"".concat("stytch_sdk_state_").concat(e).concat(t?"::".concat(t):"")},Lt=function(){function e(t,r){var n=this;h(this,e),this.browserSessionStorage={getItem:function(e){return sessionStorage.getItem(Bt(n.publicToken,e))},setItem:function(e,t){return sessionStorage.setItem(Bt(n.publicToken,e),t)},removeItem:function(e){return sessionStorage.removeItem(Bt(n.publicToken,e))}},this.publicToken=t,this.state=null,this.subscriptions={},(null==r?void 0:r.cookieOptions)?(pe("SubscriptionDataLayer").isOptionalString("cookieOptions.opaqueTokenCookieName",r.cookieOptions.opaqueTokenCookieName).isOptionalString("cookieOptions.jwtCookieName",r.cookieOptions.jwtCookieName).isOptionalString("cookieOptions.istCookieName",r.cookieOptions.istCookieName).isOptionalString("cookieOptions.path",r.cookieOptions.path),this._jwtCookieName=r.cookieOptions.jwtCookieName||null,this._opaqueTokenCookieName=r.cookieOptions.opaqueTokenCookieName||null,this._cookiePath=r.cookieOptions.path||null,this._cookieAvailableToSubdomains=r.cookieOptions.availableToSubdomains||!1,this._istCookieName=r.cookieOptions.istCookieName||null):(this._opaqueTokenCookieName=null,this._jwtCookieName=null,this._cookiePath=null,this._cookieAvailableToSubdomains=!1,this._istCookieName=null);var i,o=localStorage.getItem(Bt(this.publicToken));if(!o)return this.removeSessionCookie(),void this.removeISTCookie();try{i=JSON.parse(o)}catch(e){return this.syncToLocalStorage(),this.removeSessionCookie(),void this.removeISTCookie()}this.state=i}return p(e,[{key:"opaqueTokenCookieName",get:function(){var e;return null!==(e=this._opaqueTokenCookieName)&&void 0!==e?e:"stytch_session"}},{key:"jwtCookieName",get:function(){var e;return null!==(e=this._jwtCookieName)&&void 0!==e?e:"stytch_session_jwt"}},{key:"istCookieName",get:function(){var e;return null!==(e=this._istCookieName)&&void 0!==e?e:"stytch_intermediate_session_token"}},{key:"readSessionCookie",value:function(){return{session_token:Rt.get(this.opaqueTokenCookieName),session_jwt:Rt.get(this.jwtCookieName)}}},{key:"readIntermediateSessionTokenCookie",value:function(){return Rt.get(this.istCookieName)}},{key:"writeSessionCookie",value:function(t){var r,n,i,o,s=t.state,a=t.session_token,c=t.session_jwt,u=e.generateCookieOpts({expiresAt:null!==(n=null===(r=null==s?void 0:s.session)||void 0===r?void 0:r.expires_at)&&void 0!==n?n:"",availableToSubdomains:this._cookieAvailableToSubdomains,path:this._cookiePath});Rt.set(this.opaqueTokenCookieName,a,u),Rt.set(this.jwtCookieName,c,u);var l=e.generateCookieOpts({expiresAt:null!==(o=null===(i=null==s?void 0:s.session)||void 0===i?void 0:i.expires_at)&&void 0!==o?o:"",availableToSubdomains:!this._cookieAvailableToSubdomains,path:this._cookiePath});At(this.jwtCookieName)&&Rt.remove(this.jwtCookieName,l),At(this.opaqueTokenCookieName)&&Rt.remove(this.opaqueTokenCookieName,l),At(this.jwtCookieName)&&le("Could not remove extraneous JWT cookie. This might happen if the cookie has been set using multiple `path` settings, and may produce unwanted behavior."),At(this.opaqueTokenCookieName)&&le("Could not remove extraneous opaque token cookie.")}},{key:"writeIntermediateSessionTokenCookie",value:function(t){var r=new Date(Date.now()+6e5),n=e.generateCookieOpts({expiresAt:r.toString(),availableToSubdomains:this._cookieAvailableToSubdomains,path:this._cookiePath});Rt.set(this.istCookieName,t,n)}},{key:"removeSessionCookie",value:function(){this.removeCookies([this.opaqueTokenCookieName,this.jwtCookieName])}},{key:"removeISTCookie",value:function(){this.removeCookies([this.istCookieName])}},{key:"removeCookies",value:function(t){var r=this;[!0,!1].forEach((function(n){[r._cookiePath,null].forEach((function(r){var i=e.generateCookieOpts({expiresAt:new Date(0).toString(),availableToSubdomains:n,path:r});t.forEach((function(e){Rt.remove(e,i)}))}))}))}},{key:"syncToLocalStorage",value:function(){localStorage.setItem(Bt(this.publicToken),JSON.stringify(this.state))}},{key:"getItem",value:function(e){return localStorage.getItem(Bt(this.publicToken,e))}},{key:"setItem",value:function(e,t){return localStorage.setItem(Bt(this.publicToken,e),t)}},{key:"removeItem",value:function(e){return localStorage.removeItem(Bt(this.publicToken,e))}}],[{key:"generateCookieOpts",value:function(e){var t=e.path,r=e.availableToSubdomains,n=e.expiresAt,i={expires:new Date(n),sameSite:"lax"};return t&&(i.path=t),Boolean("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/))?i.secure=!1:(r&&(i.domain=window.location.host),i.secure=!0),i}}]),e}(),It=function(e){i(r,Lt);var t=s(r);function r(){return h(this,r),t.apply(this,arguments)}return p(r)}(),Dt=Symbol.for("__stytch_DataLayer"),jt=function(e,t){var r,n=((r=window)[Dt]||(r[Dt]={}),r[Dt]);return n[e]||(n[e]=new It(e,t)),n[e]},Nt=function(e,t){Object.values(e).forEach((function(e){return e(t)}))},Mt=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).KEYS_TO_EXCLUDE,t=void 0===e?[]:e;return function e(r,n){return g(r)===g(n)&&(null===r||null===n?r===n:"object"===g(r)?Object.keys(r).length===Object.keys(n).length&&!Object.keys(r).some((function(e){return!(e in n)}))&&Object.entries(r).filter((function(e){var r=_(e,1)[0];return!t.includes(r)})).every((function(t){var r=_(t,2),i=r[0],o=r[1];return e(o,n[i])})):r===n)}}({KEYS_TO_EXCLUDE:["last_accessed_at"]}),Ft=function(){function e(t,r){var n,i=this;h(this,e),this._publicToken=t,this._datalayer=r,this._listen=function(e){if(e.key===Bt(i._publicToken))if(null!==e.newValue&&"null"!==e.newValue){var t=JSON.parse(e.newValue);i.updateState(t)}else i.destroyState()},window.addEventListener("storage",this._listen);var o=null===(n=this._datalayer.state)||void 0===n?void 0:n.session;o&&Date.parse(o.expires_at)<Date.now()?this.destroyState():this._datalayer.readSessionCookie().session_token||this.destroyState()}return p(e,[{key:"getTokens",value:function(){var e=this._datalayer.readSessionCookie(),t=e.session_token,r=e.session_jwt;return"string"!=typeof t||"string"!=typeof r?null:{session_token:t,session_jwt:r}}},{key:"getIntermediateSessionToken",value:function(){return this._datalayer.readIntermediateSessionTokenCookie()||null}},{key:"destroyState",value:function(){this.updateStateAndTokens({state:null,session_token:null,session_jwt:null,intermediate_session_token:null})}},{key:"_updateStateAndTokensInternal",value:function(e){var t=this._datalayer.state,r=null===e.state?null:Object.assign(Object.assign({},this._datalayer.state),e.state);this._datalayer.state=r,Mt(t,r)||Nt(this._datalayer.subscriptions,r)}},{key:"updateStateAndTokens",value:function(e){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()}},{key:"updateState",value:function(e){var t=this._datalayer.state,r=null===e?null:Object.assign(Object.assign({},this._datalayer.state),e);this._datalayer.state=r,Mt(t,r)||(Nt(this._datalayer.subscriptions,r),this._datalayer.syncToLocalStorage())}},{key:"updateTokens",value:function(e){var t=e.session_token,r=e.session_jwt,n=this._datalayer.readSessionCookie(),i=Object.assign(Object.assign({},n),{session_token:t,session_jwt:r});t||r?(this._datalayer.writeSessionCookie(i),this._datalayer.removeISTCookie()):this._datalayer.removeSessionCookie()}},{key:"subscribeToState",value:function(e){return t=this._datalayer.subscriptions,r=e,n=Math.random().toString(36).slice(-10),t[n]=r,function(){return delete t[n]};var t,r,n}},{key:"getState",value:function(){return this._datalayer.state}},{key:"destroy",value:function(){window.removeEventListener("storage",this._listen)}},{key:"syncFromDeviceStorage",value:function(){return null}}]),e}(),Ut=function(e){i(r,Ft);var t=s(r);function r(){var e;return h(this,r),(e=t.apply(this,arguments)).updateUser=function(t){return e.updateState({user:t})},e.getUser=function(){var t,r;return null!==(r=null===(t=e.getState())||void 0===t?void 0:t.user)&&void 0!==r?r:null},e.getSession=function(){var t,r;return null!==(r=null===(t=e.getState())||void 0===t?void 0:t.session)&&void 0!==r?r:null},e}return p(r)}(),Kt=Symbol.for("stytch__internal_b2c"),Gt=function(e,t){Object.assign(e,function(e,t,r){return(t=f(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}({},Kt,t))},qt=p((function e(t,r){var n,i=this;h(this,e),function(e){var t="StytchUIClient"===e?"import { createStytchUIClient } from '@stytch/nextjs/ui';\n \nconst stytch = createStytchUIClient('public-token-...');\n":"import { createStytchHeadlessClient } from '@stytch/nextjs/ui';\n \nconst stytch = createStytchHeadlessClient('public-token-...');\n";if("undefined"==typeof window)throw new Error("The ".concat(e," is not compatible with server-side environments.\nIf using nextjs, use the create").concat(e," method instead.\n```\n").concat(t,"\n```\n"))}("StytchHeadlessClient"),"string"!=typeof(n=t)?le("Public token is malformed. Expected a string, got ".concat(g(n),".").concat(de)):""===n?le('Public token is malformed. Expected "public-token-...", got an empty string.'.concat(de)):n.startsWith("public-token-")||le('Public token is malformed. Expected "public-token-...", got '.concat(n,".").concat(de));var o,s,a,c,u,l,d,p,f,v,_,m=r,y={cookieOptions:null==(o=m)?void 0:o.cookieOptions,endpoints:{sdkBackendURL:null!==(a=null===(s=null==o?void 0:o.endpoints)||void 0===s?void 0:s.sdkBackendURL)&&void 0!==a?a:"https://web.stytch.com",testAPIURL:null!==(u=null===(c=null==o?void 0:o.endpoints)||void 0===c?void 0:c.testAPIURL)&&void 0!==u?u:"https://test.stytch.com",liveAPIURL:null!==(d=null===(l=null==o?void 0:o.endpoints)||void 0===l?void 0:l.liveAPIURL)&&void 0!==d?d:"https://api.stytch.com",dfpBackendURL:null!==(f=null===(p=null==o?void 0:o.endpoints)||void 0===p?void 0:p.dfpBackendURL)&&void 0!==f?f:"https://telemetry.stytch.com",clientsideServicesIframeURL:null!==(_=null===(v=null==o?void 0:o.endpoints)||void 0===v?void 0:v.clientsideServicesIframeURL)&&void 0!==_?_:"https://js.stytch.com/clientside-services/index.html"}};this._dataLayer=jt(t,m),this._subscriptionService=new Ut(t,this._dataLayer);this._networkClient=new St(t,this._dataLayer,y.endpoints.sdkBackendURL,(function(){var e,t,r,n;return{stytch_user_id:null===(t=null===(e=i._dataLayer.state)||void 0===e?void 0:e.user)||void 0===t?void 0:t.user_id,stytch_session_id:null===(n=null===(r=i._dataLayer.state)||void 0===r?void 0:r.session)||void 0===n?void 0:n.session_id}}));var b=new tt(t,this._networkClient,this._dataLayer),w=new nt(b.getAsync()),k=new _e(t,y.endpoints.dfpBackendURL,b.getAsync()),S=new it(y.endpoints.clientsideServicesIframeURL),O=new Tt(t,S),T=new Ct(this._networkClient);this.user=new ge(this._networkClient,this._subscriptionService),this.session=new be(this._networkClient,this._subscriptionService),this.magicLinks=new ke(this._networkClient,this._subscriptionService,new xt(this._dataLayer,"magic_links"),b.getAsync(),w.executeRecaptcha,k),this.otps=new Se(this._networkClient,this._subscriptionService,w.executeRecaptcha),this.oauth=new kt(this._networkClient,this._subscriptionService,new xt(this._dataLayer,"oauth"),b.getAsync(),{publicToken:t,testAPIURL:y.endpoints.testAPIURL,liveAPIURL:y.endpoints.liveAPIURL},O),this.cryptoWallets=new Te(this._networkClient,this._subscriptionService,w.executeRecaptcha),this.totps=new Ee(this._networkClient,this._subscriptionService),this.webauthn=new Ve(this._networkClient,this._subscriptionService),this.passwords=new Xe(this._networkClient,this._subscriptionService,new xt(this._dataLayer,"passwords"),b.getAsync(),w.executeRecaptcha,k),this._sessionManager=new Qe(this._subscriptionService,this.session),this._dataLayer.readSessionCookie().session_token&&this._sessionManager.performBackgroundRefresh(),this._networkClient.logEvent({name:"sdk_instance_instantiated",details:{event_callback_registered:!1,error_callback_registered:!1,success_callback_registered:!1}}),Gt(this,{bootstrap:b,clientsideServices:S,captcha:w,oneTap:O,searchManager:T,publicToken:t,dataLayer:this._dataLayer,networkClient:this._networkClient})}));exports.SDKAPIUnreachableError=mt,exports.StytchHeadlessClient=qt,exports.StytchSDKAPIError=bt,exports.StytchSDKNativeError=wt,exports.StytchSDKSchemaError=gt,exports.StytchSDKUsageError=yt,exports.UNRECOVERABLE_ERROR_TYPES=["unauthorized_credentials","user_unauthenticated","invalid_secret_authentication","session_not_found"];
|
|
3589
|
+
function ft(e) {
|
|
3590
|
+
for (var t = 1; t < arguments.length; t++) {
|
|
3591
|
+
var r = arguments[t];
|
|
3592
|
+
for (var n in r) e[n] = r[n];
|
|
3593
|
+
}
|
|
3594
|
+
return e;
|
|
3595
|
+
}
|
|
3596
|
+
var _t = function e(t, r) {
|
|
3597
|
+
function n(e, n, i) {
|
|
3598
|
+
if ("undefined" != typeof document) {
|
|
3599
|
+
"number" == typeof (i = ft({}, 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);
|
|
3600
|
+
var o = "";
|
|
3601
|
+
for (var s in i) i[s] && (o += "; " + s, !0 !== i[s] && (o += "=" + i[s].split(";")[0]));
|
|
3602
|
+
return document.cookie = e + "=" + t.write(n, e) + o;
|
|
3603
|
+
}
|
|
3604
|
+
}
|
|
3605
|
+
return Object.create({
|
|
3606
|
+
set: n,
|
|
3607
|
+
get: function get(e) {
|
|
3608
|
+
if ("undefined" != typeof document && (!arguments.length || e)) {
|
|
3609
|
+
for (var r = document.cookie ? document.cookie.split("; ") : [], n = {}, i = 0; i < r.length; i++) {
|
|
3610
|
+
var o = r[i].split("="),
|
|
3611
|
+
s = o.slice(1).join("=");
|
|
3612
|
+
try {
|
|
3613
|
+
var a = decodeURIComponent(o[0]);
|
|
3614
|
+
if (n[a] = t.read(s, a), e === a) break;
|
|
3615
|
+
} catch (e) {}
|
|
3616
|
+
}
|
|
3617
|
+
return e ? n[e] : n;
|
|
3618
|
+
}
|
|
3619
|
+
},
|
|
3620
|
+
remove: function remove(e, t) {
|
|
3621
|
+
n(e, "", ft({}, t, {
|
|
3622
|
+
expires: -1
|
|
3623
|
+
}));
|
|
3624
|
+
},
|
|
3625
|
+
withAttributes: function withAttributes(t) {
|
|
3626
|
+
return e(this.converter, ft({}, this.attributes, t));
|
|
3627
|
+
},
|
|
3628
|
+
withConverter: function withConverter(t) {
|
|
3629
|
+
return e(ft({}, this.converter, t), this.attributes);
|
|
3630
|
+
}
|
|
3631
|
+
}, {
|
|
3632
|
+
attributes: {
|
|
3633
|
+
value: Object.freeze(r)
|
|
3634
|
+
},
|
|
3635
|
+
converter: {
|
|
3636
|
+
value: Object.freeze(t)
|
|
3637
|
+
}
|
|
3638
|
+
});
|
|
3639
|
+
}({
|
|
3640
|
+
read: function read(e) {
|
|
3641
|
+
return '"' === e[0] && (e = e.slice(1, -1)), e.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
|
|
3642
|
+
},
|
|
3643
|
+
write: function write(e) {
|
|
3644
|
+
return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g, decodeURIComponent);
|
|
3645
|
+
}
|
|
3646
|
+
}, {
|
|
3647
|
+
path: "/"
|
|
3648
|
+
});
|
|
3649
|
+
var vt = function vt(e) {
|
|
3650
|
+
var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
|
|
3651
|
+
return "stytch_sdk_state_".concat(e).concat(t ? "::".concat(t) : "");
|
|
3652
|
+
};
|
|
3653
|
+
var mt = /*#__PURE__*/function () {
|
|
3654
|
+
function mt(e, t) {
|
|
3655
|
+
var _this7 = this;
|
|
3656
|
+
_classCallCheck(this, mt);
|
|
3657
|
+
this.browserSessionStorage = {
|
|
3658
|
+
getItem: function getItem(e) {
|
|
3659
|
+
return sessionStorage.getItem(vt(_this7.publicToken, e));
|
|
3660
|
+
},
|
|
3661
|
+
setItem: function setItem(e, t) {
|
|
3662
|
+
return sessionStorage.setItem(vt(_this7.publicToken, e), t);
|
|
3663
|
+
},
|
|
3664
|
+
removeItem: function removeItem(e) {
|
|
3665
|
+
return sessionStorage.removeItem(vt(_this7.publicToken, e));
|
|
3666
|
+
}
|
|
3667
|
+
}, this.publicToken = e, this.state = null, this.subscriptions = {}, (null == t ? void 0 : t.cookieOptions) ? (Z("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), this._jwtCookieName = t.cookieOptions.jwtCookieName || null, this._opaqueTokenCookieName = t.cookieOptions.opaqueTokenCookieName || null, this._cookiePath = t.cookieOptions.path || null, this._cookieAvailableToSubdomains = t.cookieOptions.availableToSubdomains || !1, this._istCookieName = t.cookieOptions.istCookieName || null) : (this._opaqueTokenCookieName = null, this._jwtCookieName = null, this._cookiePath = null, this._cookieAvailableToSubdomains = !1, this._istCookieName = null);
|
|
3668
|
+
var r = localStorage.getItem(vt(this.publicToken));
|
|
3669
|
+
if (!r) return this.removeSessionCookie(), void this.removeISTCookie();
|
|
3670
|
+
var n;
|
|
3671
|
+
try {
|
|
3672
|
+
n = JSON.parse(r);
|
|
3673
|
+
} catch (e) {
|
|
3674
|
+
return this.syncToLocalStorage(), this.removeSessionCookie(), void this.removeISTCookie();
|
|
3675
|
+
}
|
|
3676
|
+
this.state = n;
|
|
3677
|
+
}
|
|
3678
|
+
_createClass(mt, [{
|
|
3679
|
+
key: "opaqueTokenCookieName",
|
|
3680
|
+
get: function get() {
|
|
3681
|
+
var e;
|
|
3682
|
+
return null !== (e = this._opaqueTokenCookieName) && void 0 !== e ? e : "stytch_session";
|
|
3683
|
+
}
|
|
3684
|
+
}, {
|
|
3685
|
+
key: "jwtCookieName",
|
|
3686
|
+
get: function get() {
|
|
3687
|
+
var e;
|
|
3688
|
+
return null !== (e = this._jwtCookieName) && void 0 !== e ? e : "stytch_session_jwt";
|
|
3689
|
+
}
|
|
3690
|
+
}, {
|
|
3691
|
+
key: "istCookieName",
|
|
3692
|
+
get: function get() {
|
|
3693
|
+
var e;
|
|
3694
|
+
return null !== (e = this._istCookieName) && void 0 !== e ? e : "stytch_intermediate_session_token";
|
|
3695
|
+
}
|
|
3696
|
+
}, {
|
|
3697
|
+
key: "readSessionCookie",
|
|
3698
|
+
value: function readSessionCookie() {
|
|
3699
|
+
return {
|
|
3700
|
+
session_token: _t.get(this.opaqueTokenCookieName),
|
|
3701
|
+
session_jwt: _t.get(this.jwtCookieName)
|
|
3702
|
+
};
|
|
3703
|
+
}
|
|
3704
|
+
}, {
|
|
3705
|
+
key: "readIntermediateSessionTokenCookie",
|
|
3706
|
+
value: function readIntermediateSessionTokenCookie() {
|
|
3707
|
+
return _t.get(this.istCookieName);
|
|
3708
|
+
}
|
|
3709
|
+
}, {
|
|
3710
|
+
key: "writeSessionCookie",
|
|
3711
|
+
value: function writeSessionCookie(e) {
|
|
3712
|
+
var t, r, n, i;
|
|
3713
|
+
var o = e.state,
|
|
3714
|
+
s = e.session_token,
|
|
3715
|
+
a = e.session_jwt,
|
|
3716
|
+
c = mt.generateCookieOpts({
|
|
3717
|
+
expiresAt: null !== (r = null === (t = null == o ? void 0 : o.session) || void 0 === t ? void 0 : t.expires_at) && void 0 !== r ? r : "",
|
|
3718
|
+
availableToSubdomains: this._cookieAvailableToSubdomains,
|
|
3719
|
+
path: this._cookiePath
|
|
3720
|
+
});
|
|
3721
|
+
_t.set(this.opaqueTokenCookieName, s, c), _t.set(this.jwtCookieName, a, c);
|
|
3722
|
+
var u = mt.generateCookieOpts({
|
|
3723
|
+
expiresAt: null !== (i = null === (n = null == o ? void 0 : o.session) || void 0 === n ? void 0 : n.expires_at) && void 0 !== i ? i : "",
|
|
3724
|
+
availableToSubdomains: !this._cookieAvailableToSubdomains,
|
|
3725
|
+
path: this._cookiePath
|
|
3726
|
+
});
|
|
3727
|
+
pt(this.jwtCookieName) && _t.remove(this.jwtCookieName, u), pt(this.opaqueTokenCookieName) && _t.remove(this.opaqueTokenCookieName, u), pt(this.jwtCookieName) && J("Could not remove extraneous JWT cookie. This might happen if the cookie has been set using multiple `path` settings, and may produce unwanted behavior."), pt(this.opaqueTokenCookieName) && J("Could not remove extraneous opaque token cookie.");
|
|
3728
|
+
}
|
|
3729
|
+
}, {
|
|
3730
|
+
key: "writeIntermediateSessionTokenCookie",
|
|
3731
|
+
value: function writeIntermediateSessionTokenCookie(e) {
|
|
3732
|
+
var t = new Date(Date.now() + 6e5),
|
|
3733
|
+
r = mt.generateCookieOpts({
|
|
3734
|
+
expiresAt: t.toString(),
|
|
3735
|
+
availableToSubdomains: this._cookieAvailableToSubdomains,
|
|
3736
|
+
path: this._cookiePath
|
|
3737
|
+
});
|
|
3738
|
+
_t.set(this.istCookieName, e, r);
|
|
3739
|
+
}
|
|
3740
|
+
}, {
|
|
3741
|
+
key: "removeSessionCookie",
|
|
3742
|
+
value: function removeSessionCookie() {
|
|
3743
|
+
this.removeCookies([this.opaqueTokenCookieName, this.jwtCookieName]);
|
|
3744
|
+
}
|
|
3745
|
+
}, {
|
|
3746
|
+
key: "removeISTCookie",
|
|
3747
|
+
value: function removeISTCookie() {
|
|
3748
|
+
this.removeCookies([this.istCookieName]);
|
|
3749
|
+
}
|
|
3750
|
+
}, {
|
|
3751
|
+
key: "removeCookies",
|
|
3752
|
+
value: function removeCookies(e) {
|
|
3753
|
+
var _this8 = this;
|
|
3754
|
+
[!0, !1].forEach(function (t) {
|
|
3755
|
+
[_this8._cookiePath, null].forEach(function (r) {
|
|
3756
|
+
var n = mt.generateCookieOpts({
|
|
3757
|
+
expiresAt: new Date(0).toString(),
|
|
3758
|
+
availableToSubdomains: t,
|
|
3759
|
+
path: r
|
|
3760
|
+
});
|
|
3761
|
+
e.forEach(function (e) {
|
|
3762
|
+
_t.remove(e, n);
|
|
3763
|
+
});
|
|
3764
|
+
});
|
|
3765
|
+
});
|
|
3766
|
+
}
|
|
3767
|
+
}, {
|
|
3768
|
+
key: "syncToLocalStorage",
|
|
3769
|
+
value: function syncToLocalStorage() {
|
|
3770
|
+
localStorage.setItem(vt(this.publicToken), JSON.stringify(this.state));
|
|
3771
|
+
}
|
|
3772
|
+
}, {
|
|
3773
|
+
key: "getItem",
|
|
3774
|
+
value: function getItem(e) {
|
|
3775
|
+
return localStorage.getItem(vt(this.publicToken, e));
|
|
3776
|
+
}
|
|
3777
|
+
}, {
|
|
3778
|
+
key: "setItem",
|
|
3779
|
+
value: function setItem(e, t) {
|
|
3780
|
+
return localStorage.setItem(vt(this.publicToken, e), t);
|
|
3781
|
+
}
|
|
3782
|
+
}, {
|
|
3783
|
+
key: "removeItem",
|
|
3784
|
+
value: function removeItem(e) {
|
|
3785
|
+
return localStorage.removeItem(vt(this.publicToken, e));
|
|
3786
|
+
}
|
|
3787
|
+
}], [{
|
|
3788
|
+
key: "generateCookieOpts",
|
|
3789
|
+
value: function generateCookieOpts(_ref6) {
|
|
3790
|
+
var e = _ref6.path,
|
|
3791
|
+
t = _ref6.availableToSubdomains,
|
|
3792
|
+
r = _ref6.expiresAt;
|
|
3793
|
+
var n = {
|
|
3794
|
+
expires: new Date(r),
|
|
3795
|
+
sameSite: "lax"
|
|
3796
|
+
};
|
|
3797
|
+
return e && (n.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}$/)) ? n.secure = !1 : (t && (n.domain = window.location.host), n.secure = !0), n;
|
|
3798
|
+
}
|
|
3799
|
+
}]);
|
|
3800
|
+
return mt;
|
|
3801
|
+
}();
|
|
3802
|
+
var yt = /*#__PURE__*/function (_mt) {
|
|
3803
|
+
_inherits(yt, _mt);
|
|
3804
|
+
var _super2 = _createSuper(yt);
|
|
3805
|
+
function yt() {
|
|
3806
|
+
_classCallCheck(this, yt);
|
|
3807
|
+
return _super2.apply(this, arguments);
|
|
3808
|
+
}
|
|
3809
|
+
return _createClass(yt);
|
|
3810
|
+
}(mt);
|
|
3811
|
+
var gt = Symbol["for"]("__stytch_DataLayer"),
|
|
3812
|
+
bt = function bt(e, t) {
|
|
3813
|
+
var r = function () {
|
|
3814
|
+
var e = window;
|
|
3815
|
+
return e[gt] || (e[gt] = {}), e[gt];
|
|
3816
|
+
}();
|
|
3817
|
+
return r[e] || (r[e] = new yt(e, t)), r[e];
|
|
3818
|
+
},
|
|
3819
|
+
wt = function wt(e, t) {
|
|
3820
|
+
Object.values(e).forEach(function (e) {
|
|
3821
|
+
return e(t);
|
|
3822
|
+
});
|
|
3823
|
+
},
|
|
3824
|
+
kt = function () {
|
|
3825
|
+
var e = (arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}).KEYS_TO_EXCLUDE,
|
|
3826
|
+
r = void 0 === e ? [] : e;
|
|
3827
|
+
return function e(n, o) {
|
|
3828
|
+
return i(n) === i(o) && (null === n || null === o ? n === o : "object" === i(n) ? Object.keys(n).length === Object.keys(o).length && !Object.keys(n).some(function (e) {
|
|
3829
|
+
return !(e in o);
|
|
3830
|
+
}) && Object.entries(n).filter(function (e) {
|
|
3831
|
+
var n = t(e, 1)[0];
|
|
3832
|
+
return !r.includes(n);
|
|
3833
|
+
}).every(function (r) {
|
|
3834
|
+
var n = t(r, 2),
|
|
3835
|
+
i = n[0],
|
|
3836
|
+
s = n[1];
|
|
3837
|
+
return e(s, o[i]);
|
|
3838
|
+
}) : n === o);
|
|
3839
|
+
};
|
|
3840
|
+
}({
|
|
3841
|
+
KEYS_TO_EXCLUDE: ["last_accessed_at"]
|
|
3842
|
+
});
|
|
3843
|
+
var St = /*#__PURE__*/function () {
|
|
3844
|
+
function St(e, t) {
|
|
3845
|
+
var _this9 = this;
|
|
3846
|
+
_classCallCheck(this, St);
|
|
3847
|
+
var r;
|
|
3848
|
+
this._publicToken = e, this._datalayer = t, this._listen = function (e) {
|
|
3849
|
+
if (e.key !== vt(_this9._publicToken)) return;
|
|
3850
|
+
if (null === e.newValue || "null" === e.newValue) return void _this9.destroyState();
|
|
3851
|
+
var t = JSON.parse(e.newValue);
|
|
3852
|
+
_this9.updateState(t);
|
|
3853
|
+
}, window.addEventListener("storage", this._listen);
|
|
3854
|
+
var n = null === (r = this._datalayer.state) || void 0 === r ? void 0 : r.session;
|
|
3855
|
+
if (n && Date.parse(n.expires_at) < Date.now()) return void this.destroyState();
|
|
3856
|
+
var _this$_datalayer$read = this._datalayer.readSessionCookie(),
|
|
3857
|
+
i = _this$_datalayer$read.session_token;
|
|
3858
|
+
i || this.destroyState();
|
|
3859
|
+
}
|
|
3860
|
+
_createClass(St, [{
|
|
3861
|
+
key: "getTokens",
|
|
3862
|
+
value: function getTokens() {
|
|
3863
|
+
var _this$_datalayer$read2 = this._datalayer.readSessionCookie(),
|
|
3864
|
+
e = _this$_datalayer$read2.session_token,
|
|
3865
|
+
t = _this$_datalayer$read2.session_jwt;
|
|
3866
|
+
return "string" != typeof e || "string" != typeof t ? null : {
|
|
3867
|
+
session_token: e,
|
|
3868
|
+
session_jwt: t
|
|
3869
|
+
};
|
|
3870
|
+
}
|
|
3871
|
+
}, {
|
|
3872
|
+
key: "getIntermediateSessionToken",
|
|
3873
|
+
value: function getIntermediateSessionToken() {
|
|
3874
|
+
return this._datalayer.readIntermediateSessionTokenCookie() || null;
|
|
3875
|
+
}
|
|
3876
|
+
}, {
|
|
3877
|
+
key: "destroyState",
|
|
3878
|
+
value: function destroyState() {
|
|
3879
|
+
this.updateStateAndTokens({
|
|
3880
|
+
state: null,
|
|
3881
|
+
session_token: null,
|
|
3882
|
+
session_jwt: null,
|
|
3883
|
+
intermediate_session_token: null
|
|
3884
|
+
});
|
|
3885
|
+
}
|
|
3886
|
+
}, {
|
|
3887
|
+
key: "_updateStateAndTokensInternal",
|
|
3888
|
+
value: function _updateStateAndTokensInternal(e) {
|
|
3889
|
+
var t = this._datalayer.state,
|
|
3890
|
+
r = null === e.state ? null : Object.assign(Object.assign({}, this._datalayer.state), e.state);
|
|
3891
|
+
this._datalayer.state = r, kt(t, r) || wt(this._datalayer.subscriptions, r);
|
|
3892
|
+
}
|
|
3893
|
+
}, {
|
|
3894
|
+
key: "updateStateAndTokens",
|
|
3895
|
+
value: function updateStateAndTokens(e) {
|
|
3896
|
+
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();
|
|
3897
|
+
}
|
|
3898
|
+
}, {
|
|
3899
|
+
key: "updateState",
|
|
3900
|
+
value: function updateState(e) {
|
|
3901
|
+
var t = this._datalayer.state,
|
|
3902
|
+
r = null === e ? null : Object.assign(Object.assign({}, this._datalayer.state), e);
|
|
3903
|
+
this._datalayer.state = r, kt(t, r) || (wt(this._datalayer.subscriptions, r), this._datalayer.syncToLocalStorage());
|
|
3904
|
+
}
|
|
3905
|
+
}, {
|
|
3906
|
+
key: "updateTokens",
|
|
3907
|
+
value: function updateTokens(e) {
|
|
3908
|
+
var t = e.session_token,
|
|
3909
|
+
r = e.session_jwt,
|
|
3910
|
+
n = this._datalayer.readSessionCookie(),
|
|
3911
|
+
i = Object.assign(Object.assign({}, n), {
|
|
3912
|
+
session_token: t,
|
|
3913
|
+
session_jwt: r
|
|
3914
|
+
});
|
|
3915
|
+
t || r ? (this._datalayer.writeSessionCookie(i), this._datalayer.removeISTCookie()) : this._datalayer.removeSessionCookie();
|
|
3916
|
+
}
|
|
3917
|
+
}, {
|
|
3918
|
+
key: "subscribeToState",
|
|
3919
|
+
value: function subscribeToState(e) {
|
|
3920
|
+
return function (e, t) {
|
|
3921
|
+
var r = Math.random().toString(36).slice(-10);
|
|
3922
|
+
return e[r] = t, function () {
|
|
3923
|
+
return delete e[r];
|
|
3924
|
+
};
|
|
3925
|
+
}(this._datalayer.subscriptions, e);
|
|
3926
|
+
}
|
|
3927
|
+
}, {
|
|
3928
|
+
key: "getState",
|
|
3929
|
+
value: function getState() {
|
|
3930
|
+
return this._datalayer.state;
|
|
3931
|
+
}
|
|
3932
|
+
}, {
|
|
3933
|
+
key: "destroy",
|
|
3934
|
+
value: function destroy() {
|
|
3935
|
+
window.removeEventListener("storage", this._listen);
|
|
3936
|
+
}
|
|
3937
|
+
}, {
|
|
3938
|
+
key: "syncFromDeviceStorage",
|
|
3939
|
+
value: function syncFromDeviceStorage() {
|
|
3940
|
+
return null;
|
|
3941
|
+
}
|
|
3942
|
+
}]);
|
|
3943
|
+
return St;
|
|
3944
|
+
}();
|
|
3945
|
+
var Tt = /*#__PURE__*/function (_St) {
|
|
3946
|
+
_inherits(Tt, _St);
|
|
3947
|
+
var _super3 = _createSuper(Tt);
|
|
3948
|
+
function Tt() {
|
|
3949
|
+
var _this10;
|
|
3950
|
+
_classCallCheck(this, Tt);
|
|
3951
|
+
_this10 = _super3.apply(this, arguments), _this10.updateUser = function (e) {
|
|
3952
|
+
return _this10.updateState({
|
|
3953
|
+
user: e
|
|
3954
|
+
});
|
|
3955
|
+
}, _this10.getUser = function () {
|
|
3956
|
+
var e, t;
|
|
3957
|
+
return null !== (t = null === (e = _this10.getState()) || void 0 === e ? void 0 : e.user) && void 0 !== t ? t : null;
|
|
3958
|
+
}, _this10.getSession = function () {
|
|
3959
|
+
var e, t;
|
|
3960
|
+
return null !== (t = null === (e = _this10.getState()) || void 0 === e ? void 0 : e.session) && void 0 !== t ? t : null;
|
|
3961
|
+
};
|
|
3962
|
+
return _this10;
|
|
3963
|
+
}
|
|
3964
|
+
return _createClass(Tt);
|
|
3965
|
+
}(St);
|
|
3966
|
+
var Ot = Symbol["for"]("stytch__internal_b2c");
|
|
3967
|
+
exports.SDKAPIUnreachableError = tt, exports.StytchHeadlessClient = /*#__PURE__*/function () {
|
|
3968
|
+
function _class(e, t) {
|
|
3969
|
+
var _this11 = this;
|
|
3970
|
+
_classCallCheck(this, _class);
|
|
3971
|
+
var r;
|
|
3972
|
+
!function (e) {
|
|
3973
|
+
var t = "StytchUIClient" === e ? "import { createStytchUIClient } from '@stytch/nextjs/ui';\n \nconst stytch = createStytchUIClient('public-token-...');\n" : "import { createStytchHeadlessClient } from '@stytch/nextjs/ui';\n \nconst stytch = createStytchHeadlessClient('public-token-...');\n";
|
|
3974
|
+
if ("undefined" == typeof window) throw new Error("The ".concat(e, " is not compatible with server-side environments.\nIf using nextjs, use the create").concat(e, " method instead.\n```\n").concat(t, "\n```\n"));
|
|
3975
|
+
}("StytchHeadlessClient"), "string" != typeof (r = e) ? J("Public token is malformed. Expected a string, got ".concat(i(r), ".").concat(X)) : "" === r ? J('Public token is malformed. Expected "public-token-...", got an empty string.'.concat(X)) : r.startsWith("public-token-") || J('Public token is malformed. Expected "public-token-...", got '.concat(r, ".").concat(X));
|
|
3976
|
+
var n = t,
|
|
3977
|
+
o = {
|
|
3978
|
+
cookieOptions: null == (s = n) ? void 0 : s.cookieOptions,
|
|
3979
|
+
endpoints: {
|
|
3980
|
+
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",
|
|
3981
|
+
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",
|
|
3982
|
+
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",
|
|
3983
|
+
dfpBackendURL: null !== (f = null === (p = null == s ? void 0 : s.endpoints) || void 0 === p ? void 0 : p.dfpBackendURL) && void 0 !== f ? f : "https://telemetry.stytch.com",
|
|
3984
|
+
clientsideServicesIframeURL: null !== (v = null === (_ = null == s ? void 0 : s.endpoints) || void 0 === _ ? void 0 : _.clientsideServicesIframeURL) && void 0 !== v ? v : "https://js.stytch.com/clientside-services/index.html"
|
|
3985
|
+
}
|
|
3986
|
+
};
|
|
3987
|
+
var s, a, c, u, l, d, h, p, f, _, v;
|
|
3988
|
+
this._dataLayer = bt(e, n), this._subscriptionService = new Tt(e, this._dataLayer);
|
|
3989
|
+
this._networkClient = new at(e, this._dataLayer, o.endpoints.sdkBackendURL, function () {
|
|
3990
|
+
var e, t, r, n;
|
|
3991
|
+
return {
|
|
3992
|
+
stytch_user_id: null === (t = null === (e = _this11._dataLayer.state) || void 0 === e ? void 0 : e.user) || void 0 === t ? void 0 : t.user_id,
|
|
3993
|
+
stytch_session_id: null === (n = null === (r = _this11._dataLayer.state) || void 0 === r ? void 0 : r.session) || void 0 === n ? void 0 : n.session_id
|
|
3994
|
+
};
|
|
3995
|
+
});
|
|
3996
|
+
var m = new Ue(e, this._networkClient, this._dataLayer),
|
|
3997
|
+
y = new Ke(m.getAsync()),
|
|
3998
|
+
g = new te(e, o.endpoints.dfpBackendURL, m.getAsync()),
|
|
3999
|
+
b = new qe(o.endpoints.clientsideServicesIframeURL),
|
|
4000
|
+
w = new ut(e, b),
|
|
4001
|
+
k = new ht(this._networkClient);
|
|
4002
|
+
var S, T;
|
|
4003
|
+
this.user = new ie(this._networkClient, this._subscriptionService), this.session = new oe(this._networkClient, this._subscriptionService), this.magicLinks = new ae(this._networkClient, this._subscriptionService, new dt(this._dataLayer, "magic_links"), m.getAsync(), y.executeRecaptcha, g), this.otps = new ce(this._networkClient, this._subscriptionService, y.executeRecaptcha), this.oauth = new st(this._networkClient, this._subscriptionService, new dt(this._dataLayer, "oauth"), m.getAsync(), {
|
|
4004
|
+
publicToken: e,
|
|
4005
|
+
testAPIURL: o.endpoints.testAPIURL,
|
|
4006
|
+
liveAPIURL: o.endpoints.liveAPIURL
|
|
4007
|
+
}, w), this.cryptoWallets = new le(this._networkClient, this._subscriptionService, y.executeRecaptcha), this.totps = new de(this._networkClient, this._subscriptionService), this.webauthn = new Ie(this._networkClient, this._subscriptionService), this.passwords = new Le(this._networkClient, this._subscriptionService, new dt(this._dataLayer, "passwords"), m.getAsync(), y.executeRecaptcha, g), this._sessionManager = new Me(this._subscriptionService, this.session), this._dataLayer.readSessionCookie().session_token && this._sessionManager.performBackgroundRefresh(), this._networkClient.logEvent({
|
|
4008
|
+
name: "sdk_instance_instantiated",
|
|
4009
|
+
details: {
|
|
4010
|
+
event_callback_registered: !1,
|
|
4011
|
+
error_callback_registered: !1,
|
|
4012
|
+
success_callback_registered: !1
|
|
4013
|
+
}
|
|
4014
|
+
}), S = this, T = {
|
|
4015
|
+
bootstrap: m,
|
|
4016
|
+
clientsideServices: b,
|
|
4017
|
+
captcha: y,
|
|
4018
|
+
oneTap: w,
|
|
4019
|
+
searchManager: k,
|
|
4020
|
+
publicToken: e,
|
|
4021
|
+
dataLayer: this._dataLayer,
|
|
4022
|
+
networkClient: this._networkClient
|
|
4023
|
+
}, Object.assign(S, _defineProperty({}, Ot, T));
|
|
4024
|
+
}
|
|
4025
|
+
return _createClass(_class);
|
|
4026
|
+
}(), exports.StytchSDKAPIError = it, exports.StytchSDKNativeError = ot, exports.StytchSDKSchemaError = nt, exports.StytchSDKUsageError = rt, exports.UNRECOVERABLE_ERROR_TYPES = ["unauthorized_credentials", "user_unauthenticated", "invalid_secret_authentication", "session_not_found"];
|