@stytch/vanilla-js 0.9.4 → 0.10.0

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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @stytch/vanilla-js
2
2
 
3
+ ## 0.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Launching B2B SDKs
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @stytch/core@0.7.0
13
+
14
+ ## 0.9.5
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies
19
+ - @stytch/core@0.6.1
20
+
3
21
  ## 0.9.4
4
22
 
5
23
  ### Patch Changes
@@ -0,0 +1,28 @@
1
+ import { IHeadlessB2BSessionClient, IHeadlessB2BMagicLinksClient, IHeadlessB2BOrganizationClient, IHeadlessB2BMemberClient, IHeadlessB2BSSOClient, StytchClientOptions } from "@stytch/core/public";
2
+ /**
3
+ * A headless client used for invoking Stytch's B2B APIs.
4
+ * The Stytch Headless Client can be used as a drop-in solution for authentication and session management.
5
+ * Full documentation can be found {@link https://stytch.com/docs/b2b/sdks/javascript-sdk online}.
6
+ *
7
+ * @example
8
+ * const stytch = new StytchB2BHeadlessClient('public-token-<find yours in the stytch dashboard>');
9
+ * stytch.magicLinks.email.loginOrCreate({
10
+ * email: 'sandbox@stytch.com',
11
+ * organization_id: 'organization-test-123',
12
+ * });
13
+ */
14
+ declare class StytchB2BHeadlessClient {
15
+ private readonly _subscriptionService;
16
+ private readonly _sessionManager;
17
+ private readonly _networkClient;
18
+ private readonly _dataLayer;
19
+ // External API Clients
20
+ magicLinks: IHeadlessB2BMagicLinksClient;
21
+ session: IHeadlessB2BSessionClient;
22
+ member: IHeadlessB2BMemberClient;
23
+ organization: IHeadlessB2BOrganizationClient;
24
+ sso: IHeadlessB2BSSOClient;
25
+ constructor(_PUBLIC_TOKEN: string, options?: StytchClientOptions);
26
+ }
27
+ export { StytchB2BHeadlessClient };
28
+ export * from '@stytch/core/public';
@@ -0,0 +1,28 @@
1
+ import { IHeadlessB2BSessionClient, IHeadlessB2BMagicLinksClient, IHeadlessB2BOrganizationClient, IHeadlessB2BMemberClient, IHeadlessB2BSSOClient, StytchClientOptions } from "@stytch/core/public";
2
+ /**
3
+ * A headless client used for invoking Stytch's B2B APIs.
4
+ * The Stytch Headless Client can be used as a drop-in solution for authentication and session management.
5
+ * Full documentation can be found {@link https://stytch.com/docs/b2b/sdks/javascript-sdk online}.
6
+ *
7
+ * @example
8
+ * const stytch = new StytchB2BHeadlessClient('public-token-<find yours in the stytch dashboard>');
9
+ * stytch.magicLinks.email.loginOrCreate({
10
+ * email: 'sandbox@stytch.com',
11
+ * organization_id: 'organization-test-123',
12
+ * });
13
+ */
14
+ declare class StytchB2BHeadlessClient {
15
+ private readonly _subscriptionService;
16
+ private readonly _sessionManager;
17
+ private readonly _networkClient;
18
+ private readonly _dataLayer;
19
+ // External API Clients
20
+ magicLinks: IHeadlessB2BMagicLinksClient;
21
+ session: IHeadlessB2BSessionClient;
22
+ member: IHeadlessB2BMemberClient;
23
+ organization: IHeadlessB2BOrganizationClient;
24
+ sso: IHeadlessB2BSSOClient;
25
+ constructor(_PUBLIC_TOKEN: string, options?: StytchClientOptions);
26
+ }
27
+ export { StytchB2BHeadlessClient };
28
+ export * from '@stytch/core/public';
@@ -0,0 +1,5 @@
1
+ function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t){return function(t){if(Array.isArray(t))return r(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&o(t,e)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}function i(e){var r=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(t){return!1}}();return function(){var n,o=a(e);if(r){var i=a(this).constructor;n=Reflect.construct(o,arguments,i)}else n=o.apply(this,arguments);return function(e,r){if(r&&("object"===t(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(e)}(this,n)}}function a(t){return a=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},a(t)}function s(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */s=function(){return e};var e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=e&&e.prototype instanceof d?e:d,a=Object.create(i.prototype),s=new P(n||[]);return o(a,"_invoke",{value:S(t,r,s)}),a}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var p={};function d(){}function v(){}function y(){}var m={};l(m,a,(function(){return this}));var b=Object.getPrototypeOf,g=b&&b(b(L([])));g&&g!==r&&n.call(g,a)&&(m=g);var _=y.prototype=d.prototype=Object.create(m);function w(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function k(e,r){function i(o,a,s,c){var u=h(e[o],e,a);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==t(f)&&n.call(f,"__await")?r.resolve(f.__await).then((function(t){i("next",t,s,c)}),(function(t){i("throw",t,s,c)})):r.resolve(f).then((function(t){l.value=t,s(l)}),(function(t){return i("throw",t,s,c)}))}c(u.arg)}var a;o(this,"_invoke",{value:function(t,e){function n(){return new r((function(r,n){i(t,e,r,n)}))}return a=a?a.then(n,n):n()}})}function S(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return x()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=E(a,r);if(s){if(s===p)continue;return s}}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=h(t,e,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 E(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),p;var o=h(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,p;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function L(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:x}}function x(){return{value:void 0,done:!0}}return v.prototype=y,o(_,"constructor",{value:y,configurable:!0}),o(y,"constructor",{value:v,configurable:!0}),v.displayName=l(y,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,l(t,u,"GeneratorFunction")),t.prototype=Object.create(_),t},e.awrap=function(t){return{__await:t}},w(k.prototype),l(k.prototype,c,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new k(f(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(_),l(_,u,"Generator"),l(_,a,(function(){return this})),l(_,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=L,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(T),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var s=n.call(i,"catchLoc"),c=n.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;T(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:L(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},e}function c(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function u(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,f(n.key),n)}}function l(t,e,r){return e&&u(t.prototype,e),r&&u(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function f(e){var r=function(e,r){if("object"!==t(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,r||"default");if("object"!==t(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"===t(r)?r:String(r)}function h(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,s=[],c=!0,u=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(s.push(n.value),s.length!==e);c=!0);}catch(t){u=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw o}}return s}}(t,e)||d(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(t){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},p(t)}function d(t,e){if(t){if("string"==typeof t)return v(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?v(t,e):void 0}}function v(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function y(){
2
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
3
+ y=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",s=o.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,o){var i=e&&e.prototype instanceof h?e:h,a=Object.create(i.prototype),s=new P(o||[]);return n(a,"_invoke",{value:S(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var f={};function h(){}function d(){}function v(){}var m={};c(m,i,(function(){return this}));var b=Object.getPrototypeOf,g=b&&b(b(L([])));g&&g!==e&&r.call(g,i)&&(m=g);var _=v.prototype=h.prototype=Object.create(m);function w(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function k(t,e){function o(n,i,a,s){var c=l(t[n],t,i);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==p(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){o("next",t,a,s)}),(function(t){o("throw",t,a,s)})):e.resolve(f).then((function(t){u.value=t,a(u)}),(function(t){return o("throw",t,a,s)}))}s(c.arg)}var i;n(this,"_invoke",{value:function(t,r){function n(){return new e((function(e,n){o(t,r,e,n)}))}return i=i?i.then(n,n):n()}})}function S(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return x()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=E(a,r);if(s){if(s===f)continue;return s}}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(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function E(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),f;var o=l(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,f;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function L(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:x}}function x(){return{value:void 0,done:!0}}return d.prototype=v,n(_,"constructor",{value:v,configurable:!0}),n(v,"constructor",{value:d,configurable:!0}),d.displayName=c(v,s,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,c(t,s,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},w(k.prototype),c(k.prototype,a,(function(){return this})),t.AsyncIterator=k,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new k(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(_),c(_,s,"Generator"),c(_,i,(function(){return this})),c(_,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=L,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(T),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;T(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:L(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function m(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(o=n.key,i=void 0,i=function(t,e){if("object"!==p(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==p(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(o,"string"),"symbol"===p(i)?i:String(i)),n)}var o,i}function b(t,e,r){return e&&m(t.prototype,e),r&&m(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function g(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&T(t,e)}function w(t){var e=O();return function(){var r,n=P(t);if(e){var o=P(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return function(t,e){if(e&&("object"===p(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return k(t)}(this,r)}}function k(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function S(t){var e="function"==typeof Map?new Map:void 0;return S=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return E(t,arguments,P(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),T(n,t)},S(t)}function E(t,e,r){return E=O()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&T(o,r.prototype),o},E.apply(null,arguments)}function O(){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(t){return!1}}function T(t,e){return T=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},T(t,e)}function P(t){return P=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},P(t)}var L,x,C,j,A,R;!function(t){t.emailMagicLinks="emailMagicLinks",t.oauth="oauth",t.otp="otp",t.crypto="crypto",t.passwords="passwords"}(L||(L={})),function(t){t.Google="google",t.Microsoft="microsoft",t.Apple="apple",t.Github="github",t.GitLab="gitlab",t.Facebook="facebook",t.Discord="discord",t.Slack="slack",t.Amazon="amazon",t.Bitbucket="bitbucket",t.LinkedIn="linkedin",t.Coinbase="coinbase",t.Twitch="twitch"}(x||(x={})),function(t){t.Vessel="Vessel",t.Phantom="Phantom",t.Metamask="Metamask",t.Coinbase="Coinbase",t.Binance="Binance",t.GenericEthereumWallet="Other Ethereum Wallet",t.GenericSolanaWallet="Other Solana Wallet"}(C||(C={})),function(t){t.embedded="embedded",t.floating="floating"}(j||(j={})),function(t){t.SMS="sms",t.WhatsApp="whatsapp",t.Email="email"}(A||(A={})),function(t){t.MagicLinkLoginOrCreateEvent="MAGIC_LINK_LOGIN_OR_CREATE",t.OTPsLoginOrCreateEvent="OTP_LOGIN_OR_CREATE",t.OTPsAuthenticate="OTP_AUTHENTICATE",t.CryptoWalletAuthenticateStart="CRYPTO_WALLET_AUTHENTICATE_START",t.CryptoWalletAuthenticate="CRYPTO_WALLET_AUTHENTICATE",t.PasswordCreate="PASSWORD_CREATE",t.PasswordAuthenticate="PASSWORD_AUTHENTICATE",t.PasswordResetByEmailStart="PASSWORD_RESET_BY_EMAIL_START",t.PasswordResetByEmail="PASSWORD_RESET_BY_EMAIL"}(R||(R={}));var I,D,N=function(t){_(r,S(Error));var e=w(r);function r(t,n){var o;return g(this,r),(o=e.call(this,t+"\n"+n)).message=t+"\n"+n,o.name="SDKAPIUnreachableError",o.details=n,Object.setPrototypeOf(k(o),r.prototype),o}return b(r)}(),M=function(t){_(r,S(Error));var e=w(r);function r(t,n){var o;return g(this,r),(o=e.call(this)).name="StytchSDKUsageError",o.message="Invalid call to ".concat(t,"\n")+n,o}return b(r)}(),U=function(t){_(r,S(Error));var e=w(r);function r(t){var n,o;g(this,r),(n=e.call(this)).name="StytchSDKSchemaError";var i=null===(o=t.body)||void 0===o?void 0:o.map((function(t){return"".concat(t.dataPath,": ").concat(t.message)})).join("\n");return n.message="[400] Request does not match expected schema\n".concat(i),n}return b(r)}(),B=function(t){_(r,S(Error));var e=w(r);function r(t){var n;g(this,r),(n=e.call(this)).name="StytchSDKAPIError";var o=t.status_code,i=t.error_type,a=t.error_message,s=t.error_url,c=t.request_id;return n.error_type=i,n.error_message=a,n.error_url=s,n.request_id=c,n.status_code=o,n.message="[".concat(o,"] ").concat(i,"\n")+"".concat(a,"\n")+"See ".concat(s," for more information.\n")+(c?"request_id: ".concat(c,"\n"):""),n}return b(r)}();function K(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))}!function(t){t.BiometricsSensorError="biometrics_sensor_error",t.DeviceCredentialsNotAllowed="device_credentials_not_allowed",t.DeviceHardwareError="device_hardware_error",t.InternalError="internal_error",t.KeyInvalidated="key_invalidated",t.KeystoreUnavailable="keystore_unavailable",t.NoBiometricsEnrolled="no_biometrics_enrolled",t.NoBiometricsRegistration="no_biometrics_registration",t.SessionExpired="session_expired",t.UserCancellation="user_cancellation",t.UserLockedOut="user_locked_out"}(I||(I={}));var F=new Uint8Array(16);function q(){if(!D&&!(D="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 D(F)}var G=/^(?:[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 W=[],H=0;H<256;++H)W.push((H+256).toString(16).substr(1));function z(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(W[t[e+0]]+W[t[e+1]]+W[t[e+2]]+W[t[e+3]]+"-"+W[t[e+4]]+W[t[e+5]]+"-"+W[t[e+6]]+W[t[e+7]]+"-"+W[t[e+8]]+W[t[e+9]]+"-"+W[t[e+10]]+W[t[e+11]]+W[t[e+12]]+W[t[e+13]]+W[t[e+14]]+W[t[e+15]]).toLowerCase();if(!function(t){return"string"==typeof t&&G.test(t)}(r))throw TypeError("Stringified UUID is invalid");return r}function V(t,e,r){var n=(t=t||{}).random||(t.rng||q)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,e){r=r||0;for(var o=0;o<16;++o)e[r+o]=n[o];return e}return z(n)}var Y=["[Stytch]"],J={debug:function(){return false},log:function(){for(var t,e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return(t=console).log.apply(t,Y.concat(r))},warn:function(){for(var t,e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return(t=console).warn.apply(t,Y.concat(r))},error:function(){for(var t,e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return(t=console).error.apply(t,Y.concat(r))}},$="\nYou can find your public token at https://stytch.com/dashboard/api-keys.",X=function(t){var e={isObject:function(r,n){var o="object"===p(n)&&!Array.isArray(n)&&null!==n;if(!o)throw new M(t,r+" must be an object.");return e},isOptionalObject:function(t,r){return void 0===r?e:e.isObject(t,r)},isString:function(r,n){if("string"!=typeof n)throw new M(t,r+" must be a string.");return e},isOptionalString:function(t,r){return void 0===r?e:e.isString(t,r)},isStringArray:function(r,n){if(!Array.isArray(n))throw new M(t,r+" must be an array of strings.");var o,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=d(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}(n);try{for(i.s();!(o=i.n()).done;){if("string"!=typeof o.value)throw new M(t,r+" must be an array of strings.")}}catch(t){i.e(t)}finally{i.f()}return e},isNumber:function(r,n){if("number"!=typeof n)throw new M(t,r+" must be a number.");return e},isOptionalNumber:function(t,r){return void 0===r?e:e.isNumber(t,r)}};return e};function Z(t){var e=t.method,r=t.errorMessage,n=t.finalURL,o=t.basicAuthHeader,i=t.xSDKClientHeader,a=t.xSDKParentHostHeader,s=t.body;return K(this,void 0,void 0,y().mark((function t(){var c,u,l,f,h;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return c={Authorization:o,"Content-Type":"application/json","X-SDK-Client":i},a&&(c["X-SDK-Parent-Host"]=a),u={method:e,headers:c,body:s&&JSON.stringify(s)},t.prev=3,t.next=6,fetch(n,u);case 6:l=t.sent,t.next=14;break;case 9:if(t.prev=9,t.t0=t.catch(3),"Failed to fetch"!==t.t0.message){t.next=13;break}throw new N(r,"Unable to contact the Stytch servers. Are you online?");case 13:throw t.t0;case 14:if(200===l.status){t.next=27;break}return t.prev=15,t.next=18,l.json();case 18:f=t.sent,t.next=24;break;case 21:throw t.prev=21,t.t1=t.catch(15),new N(r,"Invalid or no response from server");case 24:if(!("body"in f||"params"in f||"query"in f)){t.next=26;break}throw new U(f);case 26:throw new B(f);case 27:return t.prev=27,t.next=30,l.json();case 30:return h=t.sent,t.abrupt("return",h.data);case 34:throw t.prev=34,t.t2=t.catch(27),new N(r,"Invalid response from the Stytch servers.");case 37:case"end":return t.stop()}}),t,null,[[3,9],[15,21],[27,34]])})))}var Q=function(){function t(e,r){var n=this;g(this,t),this._subscriptionService=e,this._headlessSessionClient=r,this._onDataChange=function(t){(null==t?void 0:t.session)?n.scheduleBackgroundRefresh():n.cancelBackgroundRefresh()},this._reauthenticateWithBackoff=function(){var e=function(e){return function(r){return t.isUnrecoverableRecoverableError(r)?Promise.reject(r):new Promise((function(r){return setTimeout(r,t.timeoutForAttempt(e))})).then((function(){return n._headlessSessionClient.authenticate()}))}};return n._headlessSessionClient.authenticate().catch(e(0)).catch(e(1)).catch(e(2)).catch(e(3)).catch(e(4))},this.timeout=null,this._subscriptionService.subscribeToState(this._onDataChange)}return b(t,[{key:"performBackgroundRefresh",value:function(){var t=this;this._reauthenticateWithBackoff().then((function(){t.scheduleBackgroundRefresh()})).catch((function(){J.warn("Session background refresh failed. Signalling to app that user is logged out."),t._subscriptionService.destroyState()}))}},{key:"scheduleBackgroundRefresh",value:function(){var e=this;this.cancelBackgroundRefresh(),this.timeout=setTimeout((function(){e.performBackgroundRefresh()}),t.REFRESH_INTERVAL_MS)}},{key:"cancelBackgroundRefresh",value:function(){null!==this.timeout&&(clearTimeout(this.timeout),this.timeout=null)}}],[{key:"timeoutForAttempt",value:function(t){return Math.floor(350*Math.random())-175+2e3*Math.pow(2,t)}},{key:"isUnrecoverableRecoverableError",value:function(t){return"unauthorized_credentials"===t.error_type||"user_unauthenticated"===t.error_type}}]),t}();Q.REFRESH_INTERVAL_MS=18e4;var tt=15,et=800,rt=function(){function t(e){g(this,t),this.maxBatchSize=e.maxBatchSize,this.logEventURL=e.logEventURL,setInterval(this.flush.bind(this),e.intervalDurationMs),this.batch=[]}return b(t,[{key:"logEvent",value:function(t,e){this.batch.push({telemetry:t,event:e}),this.batch.length>=this.maxBatchSize&&this.flush()}},{key:"flush",value:function(){return K(this,void 0,void 0,y().mark((function t(){var e;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.batch.length){t.next=2;break}return t.abrupt("return");case 2:return e=this.batch,this.batch=[],t.prev=4,t.next=7,fetch(this.logEventURL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});case 7:t.next=11;break;case 9:t.prev=9,t.t0=t.catch(4);case 11:case"end":return t.stop()}}),t,this,[[4,9]])})))}}]),t}();Promise.resolve({pkceRequiredForEmailMagicLinks:!1}),Promise.resolve({pkceRequiredForPasswordResets:!1});var nt=Promise.resolve({pkceRequiredForEmailMagicLinks:!1}),ot=function(){function t(e,r,n){var o=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:nt;g(this,t),this._networkClient=e,this._subscriptionService=r,this._pkceManager=n,this._config=i,this.email={loginOrSignup:function(t){return K(o,void 0,void 0,y().mark((function e(){var r,n,o,i;return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return X("stytch.magicLinks.email.loginOrSignup").isString("email",t.email_address).isString("organization_id",t.organization_id).isOptionalString("login_redirect_url",t.login_redirect_url).isOptionalString("login_template_id",t.login_template_id).isOptionalString("signup_redirect_url",t.signup_redirect_url).isOptionalString("signup_template_id",t.signup_template_id),e.next=3,this._config;case 3:if(r=e.sent,n=r.pkceRequiredForEmailMagicLinks,o=void 0,!n){e.next=10;break}return e.next=9,this.getCodeChallenge();case 9:o=e.sent;case 10:return i=Object.assign(Object.assign({},t),{pkce_code_challenge:o}),e.abrupt("return",this._networkClient.fetchSDK({url:"/b2b/magic_links/email/login_or_signup",body:i,errorMessage:"Failed to send magic link",method:"POST"}));case 12:case"end":return e.stop()}}),e,this)})))}},this.authenticate=function(t){return K(o,void 0,void 0,y().mark((function e(){var r,n,o;return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return X("stytch.magicLinks.authenticate").isString("magic_links_token",t.magic_links_token).isNumber("session_duration_minutes",t.session_duration_minutes),n=Object.assign({pkce_code_verifier:null===(r=this._pkceManager.getPKPair())||void 0===r?void 0:r.code_verifier},t),e.next=4,this._networkClient.fetchSDK({url:"/b2b/magic_links/authenticate",body:n,errorMessage:"Failed to authenticate token.",method:"POST"});case 4:return o=e.sent,this._pkceManager.clearPKPair(),this._subscriptionService.updateStateAndTokens({state:{session:o.member_session,member:o.member},session_token:o.session_token,session_jwt:o.session_jwt}),e.abrupt("return",o);case 8:case"end":return e.stop()}}),e,this)})))}}return b(t,[{key:"getCodeChallenge",value:function(){return K(this,void 0,void 0,y().mark((function t(){var e;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e=this._pkceManager.getPKPair())){t.next=3;break}return t.abrupt("return",e.code_challenge);case 3:return t.next=5,this._pkceManager.startPKCETransaction();case 5:return e=t.sent,t.abrupt("return",e.code_challenge);case 7:case"end":return t.stop()}}),t,this)})))}}]),t}(),it=b((function t(e,r){var n=this;g(this,t),this._networkClient=e,this._subscriptionService=r,this.get=function(){return K(n,void 0,void 0,y().mark((function t(){var e;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._networkClient.fetchSDK({url:"/b2b/organizations/members/me",errorMessage:"Failed to retrieve member info.",method:"GET"});case 2:return e=t.sent,this._subscriptionService.updateMember(e.member),t.abrupt("return",e.member);case 5:case"end":return t.stop()}}),t,this)})))},this.getSync=function(){return n._subscriptionService.getMember()},this.onChange=function(t){return n._subscriptionService.subscribeToState((function(e){var r;return t(null!==(r=null==e?void 0:e.member)&&void 0!==r?r:null)}))}})),at=function(){function t(e,r,n,o,i){g(this,t),this._networkClient=e,this._subscriptionService=r,this._pkceManager=n,this._dynamicConfig=o,this._config=i}return b(t,[{key:"authenticate",value:function(t){return K(this,void 0,void 0,y().mark((function e(){var r,n;return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return X("stytch.sso.authenticate").isString("sso_token",t.sso_token).isNumber("session_duration_minutes",t.session_duration_minutes),(r=this._pkceManager.getPKPair())||J.warn("No code verifier found in local storage for SSO flow.\nConsider using stytch.oauth.$provider.start() to add PKCE to your OAuth flows for added security.\nSee https://stytch.com/docs/oauth#guides_pkce for more information."),e.next=5,this._networkClient.fetchSDK({url:"/sso/authenticate",method:"POST",body:Object.assign({pkce_code_verifier:null==r?void 0:r.code_verifier},t),errorMessage:"Failed to authenticate token"});case 5:return n=e.sent,this._pkceManager.clearPKPair(),this._subscriptionService.updateStateAndTokens({state:{session:n.member_session,member:n.member},session_token:n.session_token,session_jwt:n.session_jwt}),e.abrupt("return",n);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"getBaseApiUrl",value:function(){return K(this,void 0,void 0,y().mark((function t(){return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._config.publicToken.includes("public-token-test")){t.next=2;break}return t.abrupt("return",this._config.testAPIURL);case 2:return t.abrupt("return",this._config.liveAPIURL);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"start",value:function(t){var e=t.connection_id,r=t.login_redirect_url,n=t.signup_redirect_url;return K(this,void 0,void 0,y().mark((function t(){var o,i,a,s,c;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._dynamicConfig;case 2:return o=t.sent,i=o.pkceRequiredForSso,t.next=6,this.getBaseApiUrl();case 6:if(a=t.sent,(s=new URL("".concat(a,"/v1/public/sso/start"))).searchParams.set("public_token",this._config.publicToken),s.searchParams.set("connection_id",e),!i){t.next=17;break}return t.next=13,this._pkceManager.startPKCETransaction();case 13:c=t.sent,s.searchParams.set("pkce_code_challenge",c.code_challenge),t.next=18;break;case 17:this._pkceManager.clearPKPair();case 18:r&&s.searchParams.set("login_redirect_url",r),n&&s.searchParams.set("signup_redirect_url",n),window.location.href=s.toString();case 21:case"end":return t.stop()}}),t,this)})))}}]),t}(),st=b((function t(e){var r=this;g(this,t),this._networkClient=e,this.get=function(){return K(r,void 0,void 0,y().mark((function t(){var e;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._networkClient.fetchSDK({url:"/b2b/organizations/me",errorMessage:"Failed to retrieve organization info.",method:"GET"});case 2:return e=t.sent,t.abrupt("return",e.organization);case 4:case"end":return t.stop()}}),t,this)})))}})),ct=function(){function t(e,r){var n=this;g(this,t),this._networkClient=e,this._subscriptionService=r,this.getSync=function(){return n._subscriptionService.getSession()},this.onChange=function(t){return n._subscriptionService.subscribeToState((function(e){var r;return t(null!==(r=null==e?void 0:e.session)&&void 0!==r?r:null)}))},this.revoke=function(){return K(n,void 0,void 0,y().mark((function t(){var e;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._networkClient.fetchSDK({url:"/b2b/sessions/revoke",errorMessage:"Error revoking session",method:"POST"});case 2:e=t.sent;try{this._subscriptionService.destroyState()}catch(t){}return t.abrupt("return",e);case 5:case"end":return t.stop()}}),t,this)})))},this.authenticate=function(t){return K(n,void 0,void 0,y().mark((function e(){var r,n;return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,r={session_duration_minutes:null==t?void 0:t.session_duration_minutes},e.next=4,this._networkClient.fetchSDK({url:"/b2b/sessions/authenticate",body:r,errorMessage:"Error authenticating session",method:"POST"});case 4:return n=e.sent,this._subscriptionService.updateStateAndTokens({state:{session:n.member_session,member:n.member},session_token:n.session_token,session_jwt:n.session_jwt}),e.abrupt("return",n);case 9:throw e.prev=9,e.t0=e.catch(0),this._subscriptionService.destroyState(),e.t0;case 13:case"end":return e.stop()}}),e,this,[[0,9]])})))}}return b(t,[{key:"getTokens",value:function(){return this._subscriptionService.getTokens()}}]),t}(),ut=Symbol.for("stytch__internal"),lt=function(t,e){Object.assign(t,function(t,e,r){return(e=f(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},ut,e))};function ft(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))}var ht=function(){function t(e,r,n,o){c(this,t),this._publicToken=e,this._subscriptionDataLayer=r,this.baseURL=n,this.additionalTelemetryDataFn=o,this.updateSessionToken=function(){return null},this.eventLogger=new rt({maxBatchSize:tt,intervalDurationMs:et,logEventURL:this.buildSDKUrl("/events")})}return l(t,[{key:"logEvent",value:function(t){var e=t.name,r=t.details,n=t.error,o=void 0===n?{}:n;this.eventLogger.logEvent(this.createTelemetryBlob(),{public_token:this._publicToken,event_name:e,details:r,error_code:o.error_code,error_description:o.error_description,http_status_code:o.http_status_code})}},{key:"createTelemetryBlob",value:function(){return Object.assign(Object.assign({event_id:"event-id-".concat(V()),app_session_id:"app-session-id-".concat(V()),persistent_id:"persistent-id-".concat(V()),client_sent_at:(new Date).toISOString(),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone},this.additionalTelemetryDataFn()),{app:{identifier:window.location.hostname},sdk:{identifier:"Stytch.js Javascript SDK",version:"0.10.0"}})}},{key:"fetchSDK",value:function(t){var e=t.url,r=t.body,n=t.errorMessage,o=t.method;return ft(this,void 0,void 0,s().mark((function t(){var i,a,c,u;return s().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=this._subscriptionDataLayer.readSessionCookie().session_token,a="Basic "+window.btoa(this._publicToken+":"+(i||this._publicToken)),c=window.btoa(JSON.stringify(this.createTelemetryBlob())),u=window.location.origin,t.abrupt("return",Z({basicAuthHeader:a,body:r,errorMessage:n,finalURL:this.buildSDKUrl(e),method:o,xSDKClientHeader:c,xSDKParentHostHeader:u}));case 5:case"end":return t.stop()}}),t,this)})))}},{key:"buildSDKUrl",value:function(t){return"".concat(this.baseURL,"/sdk/v1").concat(t)}}]),t}();
4
+ /*! js-cookie v3.0.1 | MIT */
5
+ function pt(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)t[n]=r[n]}return t}var dt=function t(e,r){function n(t,n,o){if("undefined"!=typeof document){"number"==typeof(o=pt({},r,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var i="";for(var a in o)o[a]&&(i+="; "+a,!0!==o[a]&&(i+="="+o[a].split(";")[0]));return document.cookie=t+"="+e.write(n,t)+i}}return Object.create({set:n,get:function(t){if("undefined"!=typeof document&&(!arguments.length||t)){for(var r=document.cookie?document.cookie.split("; "):[],n={},o=0;o<r.length;o++){var i=r[o].split("="),a=i.slice(1).join("=");try{var s=decodeURIComponent(i[0]);if(n[s]=e.read(a,s),t===s)break}catch(t){}}return t?n[t]:n}},remove:function(t,e){n(t,"",pt({},e,{expires:-1}))},withAttributes:function(e){return t(this.converter,pt({},this.attributes,e))},withConverter:function(e){return t(pt({},this.converter,e),this.attributes)}},{attributes:{value:Object.freeze(r)},converter:{value:Object.freeze(e)}})}({read:function(t){return'"'===t[0]&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"}),vt="stytch_sdk_state_",yt=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"".concat(vt).concat(t).concat(e?"::".concat(e):"")},mt=function(){function t(e,r){var n=this;c(this,t),this.browserSessionStorage={getItem:function(t){return sessionStorage.getItem(yt(n.publicToken,t))},setItem:function(t,e){return sessionStorage.setItem(yt(n.publicToken,t),e)},removeItem:function(t){return sessionStorage.removeItem(yt(n.publicToken,t))}},this.publicToken=e,this.state=null,this.subscriptions={},(null==r?void 0:r.cookieOptions)?(X("SubscriptionDataLayer").isOptionalString("cookieOptions.opaqueTokenCookieName",r.cookieOptions.opaqueTokenCookieName).isOptionalString("cookieOptions.jwtCookieName",r.cookieOptions.jwtCookieName).isOptionalString("cookieOptions.path",r.cookieOptions.path),this._jwtCookieName=r.cookieOptions.jwtCookieName||null,this._opaqueTokenCookieName=r.cookieOptions.opaqueTokenCookieName||null,this._cookiePath=r.cookieOptions.path||null,this._cookieAvailableToSubdomains=r.cookieOptions.availableToSubdomains||!1):(this._opaqueTokenCookieName=null,this._jwtCookieName=null,this._cookiePath=null,this._cookieAvailableToSubdomains=!1);var o=localStorage.getItem(yt(this.publicToken));if(o){var i;try{i=JSON.parse(o)}catch(t){return this.syncToLocalStorage(),void this.removeSessionCookie()}this.state=i}else this.removeSessionCookie()}return l(t,[{key:"opaqueTokenCookieName",get:function(){var t;return null!==(t=this._opaqueTokenCookieName)&&void 0!==t?t:"stytch_session"}},{key:"jwtCookieName",get:function(){var t;return null!==(t=this._jwtCookieName)&&void 0!==t?t:"stytch_session_jwt"}},{key:"readSessionCookie",value:function(){return{session_token:dt.get(this.opaqueTokenCookieName),session_jwt:dt.get(this.jwtCookieName)}}},{key:"writeSessionCookie",value:function(e){var r,n,o=e.state,i=e.session_token,a=e.session_jwt,s=t.generateCookieOpts({expiresAt:null!==(n=null===(r=null==o?void 0:o.session)||void 0===r?void 0:r.expires_at)&&void 0!==n?n:"",availableToSubdomains:this._cookieAvailableToSubdomains,path:this._cookiePath});dt.set(this.opaqueTokenCookieName,i,s),dt.set(this.jwtCookieName,a,s)}},{key:"removeSessionCookie",value:function(){var e=this;[!0,!1].forEach((function(r){[e._cookiePath,null].forEach((function(n){var o=t.generateCookieOpts({expiresAt:new Date(0).toString(),availableToSubdomains:r,path:n});dt.remove(e.opaqueTokenCookieName,o),dt.remove(e.jwtCookieName,o)}))}))}},{key:"syncToLocalStorage",value:function(){localStorage.setItem(yt(this.publicToken),JSON.stringify(this.state))}},{key:"getItem",value:function(t){return localStorage.getItem(yt(this.publicToken,t))}},{key:"setItem",value:function(t,e){return localStorage.setItem(yt(this.publicToken,t),e)}},{key:"removeItem",value:function(t){return localStorage.removeItem(yt(this.publicToken,t))}}],[{key:"generateCookieOpts",value:function(t){var e=t.path,r=t.availableToSubdomains,n=t.expiresAt,o={expires:new Date(n),sameSite:"lax"};return e&&(o.path=e),Boolean("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/))?o.secure=!1:(r&&(o.domain=window.location.host),o.secure=!0),o}}]),t}(),bt=function(t){n(r,mt);var e=i(r);function r(){return c(this,r),e.apply(this,arguments)}return l(r)}(),gt=Symbol.for("__stytch_b2b_DataLayer"),_t=function(t,e){var r,n=((r=window)[gt]||(r[gt]={}),r[gt]);return n[t]||(n[t]=new bt(t,e)),n[t]},wt=function(t,e){Object.values(t).forEach((function(t){return t(e)}))},kt=function(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).KEYS_TO_EXCLUDE,e=void 0===t?[]:t;return function t(r,n){return p(r)===p(n)&&(null===r||null===n?r===n:"object"===p(r)?Object.keys(r).length===Object.keys(n).length&&!Object.keys(r).some((function(t){return!(t in n)}))&&Object.entries(r).filter((function(t){var r=h(t,1)[0];return!e.includes(r)})).every((function(e){var r=h(e,2),o=r[0],i=r[1];return t(i,n[o])})):r===n)}}({KEYS_TO_EXCLUDE:["last_accessed_at"]}),St=function(){function t(e,r){var n,o=this;c(this,t),this._publicToken=e,this._datalayer=r,this._listen=function(t){t.key===yt(o._publicToken)&&(null!==t.newValue?o._updateStateAndTokensInternal(JSON.parse(t.newValue)):o.destroyState())},window.addEventListener("storage",this._listen);var i=null===(n=this._datalayer.state)||void 0===n?void 0:n.session;i&&Date.parse(i.expires_at)<Date.now()?this.destroyState():this._datalayer.readSessionCookie().session_token||this.destroyState()}return l(t,[{key:"getTokens",value:function(){var t=this._datalayer.readSessionCookie(),e=t.session_token,r=t.session_jwt;return e&&r?{session_token:e,session_jwt:r}:null}},{key:"destroyState",value:function(){this.updateStateAndTokens({state:null,session_token:null,session_jwt:null})}},{key:"_updateStateAndTokensInternal",value:function(t){var e=t.state,r=this._datalayer.state;this._datalayer.state=e||null,kt(r,t.state)||wt(this._datalayer.subscriptions,t.state)}},{key:"updateStateAndTokens",value:function(t){t.state?this._datalayer.writeSessionCookie(t):this._datalayer.removeSessionCookie(),this._updateStateAndTokensInternal(t),this._datalayer.syncToLocalStorage()}},{key:"updateState",value:function(t){var e=this._datalayer.state,r=Object.assign(Object.assign({},this._datalayer.state),t);this._datalayer.state=r,kt(e,r)||(wt(this._datalayer.subscriptions,r),this._datalayer.syncToLocalStorage())}},{key:"subscribeToState",value:function(t){return e=this._datalayer.subscriptions,r=t,n=Math.random().toString(36).slice(-10),e[n]=r,function(){return delete e[n]};var e,r,n}},{key:"getState",value:function(){return this._datalayer.state}},{key:"destroy",value:function(){window.removeEventListener("storage",this._listen)}},{key:"syncFromDeviceStorage",value:function(){return null}}]),t}(),Et=function(t){n(r,St);var e=i(r);function r(){var t;return c(this,r),(t=e.apply(this,arguments)).updateMember=function(e){return t.updateState({member:e})},t.getMember=function(){var e,r;return null!==(r=null===(e=t.getState())||void 0===e?void 0:e.member)&&void 0!==r?r:null},t.getSession=function(){var e,r;return null!==(r=null===(e=t.getState())||void 0===e?void 0:e.session)&&void 0!==r?r:null},t}return l(r)}();function Ot(t){var e=t.toString(16);return 1===e.length&&(e="0"+e),e}var Tt,Pt,Lt,xt,Ct,jt,At=function(){function t(e,r){c(this,t),this._dataLayer=e,this.namespace=r}return l(t,[{key:"key",value:function(){return"PKCE_VERIFIER:"+this.namespace}},{key:"startPKCETransaction",value:function(){return ft(this,void 0,void 0,s().mark((function e(){var r;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.createProofkeyPair();case 2:return r=e.sent,this._dataLayer.setItem(this.key(),JSON.stringify(r)),e.abrupt("return",r);case 5:case"end":return e.stop()}}),e,this)})))}},{key:"getPKPair",value:function(){var t=this._dataLayer.getItem(this.key());if(null!==t)try{return JSON.parse(t)}catch(t){return void J.warn("Found malformed Proof Key pair in localstorage.")}}},{key:"clearPKPair",value:function(){return this._dataLayer.removeItem(this.key())}}],[{key:"createProofkeyPair",value:function(){return ft(this,void 0,void 0,s().mark((function t(){var r,n,o;return s().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new Uint32Array(16),window.crypto.getRandomValues(r),n=Array.from(r).map(Ot).join(""),t.next=5,window.crypto.subtle.digest("SHA-256",(new TextEncoder).encode(n));case 5:return o=t.sent,t.abrupt("return",{code_challenge:(i=o,a=void 0,btoa((a=String.fromCharCode).call.apply(a,[null].concat(e(new Uint8Array(i))))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")),code_verifier:n});case 7:case"end":return t.stop()}var i,a}),t)})))}}]),t}(),Rt="bootstrap",It=function(){return{displayWatermark:!1,cnameDomain:null,emailDomains:["stytch.com"],captchaSettings:{enabled:!1},pkceRequiredForEmailMagicLinks:!1,pkceRequiredForPasswordResets:!1,pkceRequiredForOAuth:!1,pkceRequiredForSso:!1}},Dt=function(){function t(e,r,n){var o=this;c(this,t),this._publicToken=e,this._networkClient=r,this._dataLayer=n,this._bootstrapDataPromise=this._networkClient.fetchSDK({url:"/projects/bootstrap/".concat(this._publicToken),method:"GET",errorMessage:"Error fetching bootstrap data for SDK for ".concat(this._publicToken)}).then(t.mapBootstrapData).then((function(t){return o._dataLayer.setItem(Rt,JSON.stringify(t)),t})).catch((function(t){return J.error(t),It()}))}return l(t,[{key:"getSync",value:function(){var t=this._dataLayer.getItem(Rt);if(null===t)return It();try{return JSON.parse(t)}catch(t){return It()}}},{key:"getAsync",value:function(){return this._bootstrapDataPromise}}],[{key:"mapBootstrapData",value:function(t){return{displayWatermark:!t.disable_sdk_watermark,captchaSettings:t.captcha_settings,cnameDomain:t.cname_domain,emailDomains:t.email_domains,pkceRequiredForEmailMagicLinks:t.pkce_required_for_email_magic_links,pkceRequiredForPasswordResets:t.pkce_required_for_password_resets,pkceRequiredForOAuth:t.pkce_required_for_oauth,pkceRequiredForSso:t.pkce_required_for_sso}}}]),t}(),Nt=l((function t(e,r){var n,o=this;c(this,t),function(t){if("undefined"==typeof window)throw new Error("The ".concat(t," is not compatible with server-side environments.\nIf using nextjs, use the create").concat(t," method instead.\n```\n").concat("import { createStytchB2BHeadlessClient } from '@stytch/nextjs/b2b';\n \n const stytch = createStytchB2BHeadlessClient('public-token-...');\n ","\n```\n"))}("StytchB2BHeadlessClient"),"string"!=typeof(n=e)?J.warn("Public token is malformed. Expected a string, got ".concat(p(n),".").concat($)):""===n?J.warn('Public token is malformed. Expected "public-token-...", got an empty string.'.concat($)):n.startsWith("public-token-")||J.warn('Public token is malformed. Expected "public-token-...", got '.concat(n,".").concat($));var i,a,s,u,l,f,h,d,v,y=r,m={cookieOptions:null==(i=y)?void 0:i.cookieOptions,endpoints:{sdkBackendURL:null!==(s=null===(a=null==i?void 0:i.endpoints)||void 0===a?void 0:a.sdkBackendURL)&&void 0!==s?s:"https://web.stytch.com",testAPIURL:null!==(l=null===(u=null==i?void 0:i.endpoints)||void 0===u?void 0:u.testAPIURL)&&void 0!==l?l:"https://test.stytch.com",liveAPIURL:null!==(h=null===(f=null==i?void 0:i.endpoints)||void 0===f?void 0:f.liveAPIURL)&&void 0!==h?h:"https://api.stytch.com",clientsideServicesIframeURL:null!==(v=null===(d=null==i?void 0:i.endpoints)||void 0===d?void 0:d.clientsideServicesIframeURL)&&void 0!==v?v:"https://js.stytch.com/clientside-services/index.html"}};this._dataLayer=_t(e,y),this._subscriptionService=new Et(e,this._dataLayer);this._networkClient=new ht(e,this._dataLayer,m.endpoints.sdkBackendURL,(function(){var t,e,r,n;return{stytch_member_id:null===(e=null===(t=o._dataLayer.state)||void 0===t?void 0:t.member)||void 0===e?void 0:e.member_id,stytch_member_session_id:null===(n=null===(r=o._dataLayer.state)||void 0===r?void 0:r.session)||void 0===n?void 0:n.member_session_id}}));var b=new Dt(e,this._networkClient,this._dataLayer);this.organization=new st(this._networkClient),this.member=new it(this._networkClient,this._subscriptionService),this.session=new ct(this._networkClient,this._subscriptionService),this.magicLinks=new ot(this._networkClient,this._subscriptionService,new At(this._dataLayer,"magic_links"),b.getAsync()),this.sso=new at(this._networkClient,this._subscriptionService,new At(this._dataLayer,"sso"),b.getAsync(),{publicToken:e,testAPIURL:m.endpoints.testAPIURL,liveAPIURL:m.endpoints.liveAPIURL}),this._sessionManager=new Q(this._subscriptionService,this.session),this._dataLayer.readSessionCookie().session_token&&this._sessionManager.performBackgroundRefresh(),this._networkClient.logEvent({name:"b2b_sdk_instance_instantiated",details:{event_callback_registered:!1,error_callback_registered:!1,success_callback_registered:!1}}),lt(this,{bootstrap:b,publicToken:e})}));function Mt(t){return Mt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Mt(t)}function Ut(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(o=n.key,i=void 0,i=function(t,e){if("object"!==Mt(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==Mt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(o,"string"),"symbol"===Mt(i)?i:String(i)),n)}var o,i}function Bt(t,e,r){return e&&Ut(t.prototype,e),r&&Ut(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Kt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Ft(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Vt(t,e)}function qt(t){var e=zt();return function(){var r,n=Yt(t);if(e){var o=Yt(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return function(t,e){if(e&&("object"===Mt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return Gt(t)}(this,r)}}function Gt(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Wt(t){var e="function"==typeof Map?new Map:void 0;return Wt=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return Ht(t,arguments,Yt(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),Vt(n,t)},Wt(t)}function Ht(t,e,r){return Ht=zt()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Vt(o,r.prototype),o},Ht.apply(null,arguments)}function zt(){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(t){return!1}}function Vt(t,e){return Vt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Vt(t,e)}function Yt(t){return Yt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Yt(t)}!function(t){t.emailMagicLinks="emailMagicLinks",t.oauth="oauth",t.otp="otp",t.crypto="crypto",t.passwords="passwords"}(Tt||(Tt={})),function(t){t.Google="google",t.Microsoft="microsoft",t.Apple="apple",t.Github="github",t.GitLab="gitlab",t.Facebook="facebook",t.Discord="discord",t.Slack="slack",t.Amazon="amazon",t.Bitbucket="bitbucket",t.LinkedIn="linkedin",t.Coinbase="coinbase",t.Twitch="twitch"}(Pt||(Pt={})),function(t){t.Vessel="Vessel",t.Phantom="Phantom",t.Metamask="Metamask",t.Coinbase="Coinbase",t.Binance="Binance",t.GenericEthereumWallet="Other Ethereum Wallet",t.GenericSolanaWallet="Other Solana Wallet"}(Lt||(Lt={})),function(t){t.embedded="embedded",t.floating="floating"}(xt||(xt={})),function(t){t.SMS="sms",t.WhatsApp="whatsapp",t.Email="email"}(Ct||(Ct={})),function(t){t.MagicLinkLoginOrCreateEvent="MAGIC_LINK_LOGIN_OR_CREATE",t.OTPsLoginOrCreateEvent="OTP_LOGIN_OR_CREATE",t.OTPsAuthenticate="OTP_AUTHENTICATE",t.CryptoWalletAuthenticateStart="CRYPTO_WALLET_AUTHENTICATE_START",t.CryptoWalletAuthenticate="CRYPTO_WALLET_AUTHENTICATE",t.PasswordCreate="PASSWORD_CREATE",t.PasswordAuthenticate="PASSWORD_AUTHENTICATE",t.PasswordResetByEmailStart="PASSWORD_RESET_BY_EMAIL_START",t.PasswordResetByEmail="PASSWORD_RESET_BY_EMAIL"}(jt||(jt={}));var Jt,$t=function(t){Ft(r,Wt(Error));var e=qt(r);function r(t,n){var o;return Kt(this,r),(o=e.call(this,t+"\n"+n)).message=t+"\n"+n,o.name="SDKAPIUnreachableError",o.details=n,Object.setPrototypeOf(Gt(o),r.prototype),o}return Bt(r)}(),Xt=function(t){Ft(r,Wt(Error));var e=qt(r);function r(t,n){var o;return Kt(this,r),(o=e.call(this)).name="StytchSDKUsageError",o.message="Invalid call to ".concat(t,"\n")+n,o}return Bt(r)}(),Zt=function(t){Ft(r,Wt(Error));var e=qt(r);function r(t){var n,o;Kt(this,r),(n=e.call(this)).name="StytchSDKSchemaError";var i=null===(o=t.body)||void 0===o?void 0:o.map((function(t){return"".concat(t.dataPath,": ").concat(t.message)})).join("\n");return n.message="[400] Request does not match expected schema\n".concat(i),n}return Bt(r)}(),Qt=function(t){Ft(r,Wt(Error));var e=qt(r);function r(t){var n;Kt(this,r),(n=e.call(this)).name="StytchSDKAPIError";var o=t.status_code,i=t.error_type,a=t.error_message,s=t.error_url,c=t.request_id;return n.error_type=i,n.error_message=a,n.error_url=s,n.request_id=c,n.status_code=o,n.message="[".concat(o,"] ").concat(i,"\n")+"".concat(a,"\n")+"See ".concat(s," for more information.\n")+(c?"request_id: ".concat(c,"\n"):""),n}return Bt(r)}(),te=function(t){Ft(r,Wt(Error));var e=qt(r);function r(t){var n;return Kt(this,r),(n=e.call(this)).name="StytchSDKNativeError",n.error_type=t,n.message="".concat(t),n}return Bt(r)}();!function(t){t.BiometricsSensorError="biometrics_sensor_error",t.DeviceCredentialsNotAllowed="device_credentials_not_allowed",t.DeviceHardwareError="device_hardware_error",t.InternalError="internal_error",t.KeyInvalidated="key_invalidated",t.KeystoreUnavailable="keystore_unavailable",t.NoBiometricsEnrolled="no_biometrics_enrolled",t.NoBiometricsRegistration="no_biometrics_registration",t.SessionExpired="session_expired",t.UserCancellation="user_cancellation",t.UserLockedOut="user_locked_out"}(Jt||(Jt={}));export{Jt as BiometricsErrors,Pt as OAuthProviders,Ct as OTPMethods,xt as OneTapPositions,Tt as Products,$t as SDKAPIUnreachableError,Nt as StytchB2BHeadlessClient,jt as StytchEventType,Qt as StytchSDKAPIError,te as StytchSDKNativeError,Zt as StytchSDKSchemaError,Xt as StytchSDKUsageError,Lt as Wallets};
@@ -0,0 +1,5 @@
1
+ "use strict";function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t){return function(t){if(Array.isArray(t))return r(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&o(t,e)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}function i(e){var r=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(t){return!1}}();return function(){var n,o=a(e);if(r){var i=a(this).constructor;n=Reflect.construct(o,arguments,i)}else n=o.apply(this,arguments);return function(e,r){if(r&&("object"===t(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(e)}(this,n)}}function a(t){return a=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},a(t)}function s(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */s=function(){return e};var e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=e&&e.prototype instanceof d?e:d,a=Object.create(i.prototype),s=new x(n||[]);return o(a,"_invoke",{value:S(t,r,s)}),a}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var p={};function d(){}function v(){}function y(){}var m={};l(m,a,(function(){return this}));var b=Object.getPrototypeOf,g=b&&b(b(P([])));g&&g!==r&&n.call(g,a)&&(m=g);var _=y.prototype=d.prototype=Object.create(m);function w(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function k(e,r){function i(o,a,s,c){var u=h(e[o],e,a);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==t(f)&&n.call(f,"__await")?r.resolve(f.__await).then((function(t){i("next",t,s,c)}),(function(t){i("throw",t,s,c)})):r.resolve(f).then((function(t){l.value=t,s(l)}),(function(t){return i("throw",t,s,c)}))}c(u.arg)}var a;o(this,"_invoke",{value:function(t,e){function n(){return new r((function(r,n){i(t,e,r,n)}))}return a=a?a.then(n,n):n()}})}function S(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return L()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=E(a,r);if(s){if(s===p)continue;return s}}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=h(t,e,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 E(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),p;var o=h(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,p;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function x(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function P(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:L}}function L(){return{value:void 0,done:!0}}return v.prototype=y,o(_,"constructor",{value:y,configurable:!0}),o(y,"constructor",{value:v,configurable:!0}),v.displayName=l(y,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,l(t,u,"GeneratorFunction")),t.prototype=Object.create(_),t},e.awrap=function(t){return{__await:t}},w(k.prototype),l(k.prototype,c,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new k(f(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(_),l(_,u,"Generator"),l(_,a,(function(){return this})),l(_,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=P,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(T),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var s=n.call(i,"catchLoc"),c=n.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;T(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},e}function c(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function u(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,f(n.key),n)}}function l(t,e,r){return e&&u(t.prototype,e),r&&u(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function f(e){var r=function(e,r){if("object"!==t(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,r||"default");if("object"!==t(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"===t(r)?r:String(r)}function h(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,s=[],c=!0,u=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(s.push(n.value),s.length!==e);c=!0);}catch(t){u=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw o}}return s}}(t,e)||d(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(t){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},p(t)}function d(t,e){if(t){if("string"==typeof t)return v(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?v(t,e):void 0}}function v(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function y(){
2
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
3
+ y=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",s=o.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,o){var i=e&&e.prototype instanceof h?e:h,a=Object.create(i.prototype),s=new x(o||[]);return n(a,"_invoke",{value:S(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var f={};function h(){}function d(){}function v(){}var m={};c(m,i,(function(){return this}));var b=Object.getPrototypeOf,g=b&&b(b(P([])));g&&g!==e&&r.call(g,i)&&(m=g);var _=v.prototype=h.prototype=Object.create(m);function w(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function k(t,e){function o(n,i,a,s){var c=l(t[n],t,i);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==p(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){o("next",t,a,s)}),(function(t){o("throw",t,a,s)})):e.resolve(f).then((function(t){u.value=t,a(u)}),(function(t){return o("throw",t,a,s)}))}s(c.arg)}var i;n(this,"_invoke",{value:function(t,r){function n(){return new e((function(e,n){o(t,r,e,n)}))}return i=i?i.then(n,n):n()}})}function S(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return L()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=E(a,r);if(s){if(s===f)continue;return s}}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(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function E(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),f;var o=l(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,f;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function x(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function P(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:L}}function L(){return{value:void 0,done:!0}}return d.prototype=v,n(_,"constructor",{value:v,configurable:!0}),n(v,"constructor",{value:d,configurable:!0}),d.displayName=c(v,s,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,c(t,s,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},w(k.prototype),c(k.prototype,a,(function(){return this})),t.AsyncIterator=k,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new k(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(_),c(_,s,"Generator"),c(_,i,(function(){return this})),c(_,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=P,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(T),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;T(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function m(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(o=n.key,i=void 0,i=function(t,e){if("object"!==p(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==p(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(o,"string"),"symbol"===p(i)?i:String(i)),n)}var o,i}function b(t,e,r){return e&&m(t.prototype,e),r&&m(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function g(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&T(t,e)}function w(t){var e=O();return function(){var r,n=x(t);if(e){var o=x(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return function(t,e){if(e&&("object"===p(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return k(t)}(this,r)}}function k(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function S(t){var e="function"==typeof Map?new Map:void 0;return S=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return E(t,arguments,x(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),T(n,t)},S(t)}function E(t,e,r){return E=O()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&T(o,r.prototype),o},E.apply(null,arguments)}function O(){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(t){return!1}}function T(t,e){return T=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},T(t,e)}function x(t){return x=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},x(t)}Object.defineProperty(exports,"__esModule",{value:!0});var P,L,C,A,j,R;!function(t){t.emailMagicLinks="emailMagicLinks",t.oauth="oauth",t.otp="otp",t.crypto="crypto",t.passwords="passwords"}(P||(P={})),function(t){t.Google="google",t.Microsoft="microsoft",t.Apple="apple",t.Github="github",t.GitLab="gitlab",t.Facebook="facebook",t.Discord="discord",t.Slack="slack",t.Amazon="amazon",t.Bitbucket="bitbucket",t.LinkedIn="linkedin",t.Coinbase="coinbase",t.Twitch="twitch"}(L||(L={})),function(t){t.Vessel="Vessel",t.Phantom="Phantom",t.Metamask="Metamask",t.Coinbase="Coinbase",t.Binance="Binance",t.GenericEthereumWallet="Other Ethereum Wallet",t.GenericSolanaWallet="Other Solana Wallet"}(C||(C={})),function(t){t.embedded="embedded",t.floating="floating"}(A||(A={})),function(t){t.SMS="sms",t.WhatsApp="whatsapp",t.Email="email"}(j||(j={})),function(t){t.MagicLinkLoginOrCreateEvent="MAGIC_LINK_LOGIN_OR_CREATE",t.OTPsLoginOrCreateEvent="OTP_LOGIN_OR_CREATE",t.OTPsAuthenticate="OTP_AUTHENTICATE",t.CryptoWalletAuthenticateStart="CRYPTO_WALLET_AUTHENTICATE_START",t.CryptoWalletAuthenticate="CRYPTO_WALLET_AUTHENTICATE",t.PasswordCreate="PASSWORD_CREATE",t.PasswordAuthenticate="PASSWORD_AUTHENTICATE",t.PasswordResetByEmailStart="PASSWORD_RESET_BY_EMAIL_START",t.PasswordResetByEmail="PASSWORD_RESET_BY_EMAIL"}(R||(R={}));var I,D,N=function(t){_(r,S(Error));var e=w(r);function r(t,n){var o;return g(this,r),(o=e.call(this,t+"\n"+n)).message=t+"\n"+n,o.name="SDKAPIUnreachableError",o.details=n,Object.setPrototypeOf(k(o),r.prototype),o}return b(r)}(),M=function(t){_(r,S(Error));var e=w(r);function r(t,n){var o;return g(this,r),(o=e.call(this)).name="StytchSDKUsageError",o.message="Invalid call to ".concat(t,"\n")+n,o}return b(r)}(),B=function(t){_(r,S(Error));var e=w(r);function r(t){var n,o;g(this,r),(n=e.call(this)).name="StytchSDKSchemaError";var i=null===(o=t.body)||void 0===o?void 0:o.map((function(t){return"".concat(t.dataPath,": ").concat(t.message)})).join("\n");return n.message="[400] Request does not match expected schema\n".concat(i),n}return b(r)}(),U=function(t){_(r,S(Error));var e=w(r);function r(t){var n;g(this,r),(n=e.call(this)).name="StytchSDKAPIError";var o=t.status_code,i=t.error_type,a=t.error_message,s=t.error_url,c=t.request_id;return n.error_type=i,n.error_message=a,n.error_url=s,n.request_id=c,n.status_code=o,n.message="[".concat(o,"] ").concat(i,"\n")+"".concat(a,"\n")+"See ".concat(s," for more information.\n")+(c?"request_id: ".concat(c,"\n"):""),n}return b(r)}();function K(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))}!function(t){t.BiometricsSensorError="biometrics_sensor_error",t.DeviceCredentialsNotAllowed="device_credentials_not_allowed",t.DeviceHardwareError="device_hardware_error",t.InternalError="internal_error",t.KeyInvalidated="key_invalidated",t.KeystoreUnavailable="keystore_unavailable",t.NoBiometricsEnrolled="no_biometrics_enrolled",t.NoBiometricsRegistration="no_biometrics_registration",t.SessionExpired="session_expired",t.UserCancellation="user_cancellation",t.UserLockedOut="user_locked_out"}(I||(I={}));var F=new Uint8Array(16);function q(){if(!D&&!(D="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 D(F)}var G=/^(?:[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 W=[],H=0;H<256;++H)W.push((H+256).toString(16).substr(1));function z(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(W[t[e+0]]+W[t[e+1]]+W[t[e+2]]+W[t[e+3]]+"-"+W[t[e+4]]+W[t[e+5]]+"-"+W[t[e+6]]+W[t[e+7]]+"-"+W[t[e+8]]+W[t[e+9]]+"-"+W[t[e+10]]+W[t[e+11]]+W[t[e+12]]+W[t[e+13]]+W[t[e+14]]+W[t[e+15]]).toLowerCase();if(!function(t){return"string"==typeof t&&G.test(t)}(r))throw TypeError("Stringified UUID is invalid");return r}function V(t,e,r){var n=(t=t||{}).random||(t.rng||q)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,e){r=r||0;for(var o=0;o<16;++o)e[r+o]=n[o];return e}return z(n)}var Y=["[Stytch]"],J={debug:function(){return false},log:function(){for(var t,e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return(t=console).log.apply(t,Y.concat(r))},warn:function(){for(var t,e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return(t=console).warn.apply(t,Y.concat(r))},error:function(){for(var t,e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return(t=console).error.apply(t,Y.concat(r))}},$="\nYou can find your public token at https://stytch.com/dashboard/api-keys.",X=function(t){var e={isObject:function(r,n){var o="object"===p(n)&&!Array.isArray(n)&&null!==n;if(!o)throw new M(t,r+" must be an object.");return e},isOptionalObject:function(t,r){return void 0===r?e:e.isObject(t,r)},isString:function(r,n){if("string"!=typeof n)throw new M(t,r+" must be a string.");return e},isOptionalString:function(t,r){return void 0===r?e:e.isString(t,r)},isStringArray:function(r,n){if(!Array.isArray(n))throw new M(t,r+" must be an array of strings.");var o,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=d(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}(n);try{for(i.s();!(o=i.n()).done;){if("string"!=typeof o.value)throw new M(t,r+" must be an array of strings.")}}catch(t){i.e(t)}finally{i.f()}return e},isNumber:function(r,n){if("number"!=typeof n)throw new M(t,r+" must be a number.");return e},isOptionalNumber:function(t,r){return void 0===r?e:e.isNumber(t,r)}};return e};function Z(t){var e=t.method,r=t.errorMessage,n=t.finalURL,o=t.basicAuthHeader,i=t.xSDKClientHeader,a=t.xSDKParentHostHeader,s=t.body;return K(this,void 0,void 0,y().mark((function t(){var c,u,l,f,h;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return c={Authorization:o,"Content-Type":"application/json","X-SDK-Client":i},a&&(c["X-SDK-Parent-Host"]=a),u={method:e,headers:c,body:s&&JSON.stringify(s)},t.prev=3,t.next=6,fetch(n,u);case 6:l=t.sent,t.next=14;break;case 9:if(t.prev=9,t.t0=t.catch(3),"Failed to fetch"!==t.t0.message){t.next=13;break}throw new N(r,"Unable to contact the Stytch servers. Are you online?");case 13:throw t.t0;case 14:if(200===l.status){t.next=27;break}return t.prev=15,t.next=18,l.json();case 18:f=t.sent,t.next=24;break;case 21:throw t.prev=21,t.t1=t.catch(15),new N(r,"Invalid or no response from server");case 24:if(!("body"in f||"params"in f||"query"in f)){t.next=26;break}throw new B(f);case 26:throw new U(f);case 27:return t.prev=27,t.next=30,l.json();case 30:return h=t.sent,t.abrupt("return",h.data);case 34:throw t.prev=34,t.t2=t.catch(27),new N(r,"Invalid response from the Stytch servers.");case 37:case"end":return t.stop()}}),t,null,[[3,9],[15,21],[27,34]])})))}var Q=function(){function t(e,r){var n=this;g(this,t),this._subscriptionService=e,this._headlessSessionClient=r,this._onDataChange=function(t){(null==t?void 0:t.session)?n.scheduleBackgroundRefresh():n.cancelBackgroundRefresh()},this._reauthenticateWithBackoff=function(){var e=function(e){return function(r){return t.isUnrecoverableRecoverableError(r)?Promise.reject(r):new Promise((function(r){return setTimeout(r,t.timeoutForAttempt(e))})).then((function(){return n._headlessSessionClient.authenticate()}))}};return n._headlessSessionClient.authenticate().catch(e(0)).catch(e(1)).catch(e(2)).catch(e(3)).catch(e(4))},this.timeout=null,this._subscriptionService.subscribeToState(this._onDataChange)}return b(t,[{key:"performBackgroundRefresh",value:function(){var t=this;this._reauthenticateWithBackoff().then((function(){t.scheduleBackgroundRefresh()})).catch((function(){J.warn("Session background refresh failed. Signalling to app that user is logged out."),t._subscriptionService.destroyState()}))}},{key:"scheduleBackgroundRefresh",value:function(){var e=this;this.cancelBackgroundRefresh(),this.timeout=setTimeout((function(){e.performBackgroundRefresh()}),t.REFRESH_INTERVAL_MS)}},{key:"cancelBackgroundRefresh",value:function(){null!==this.timeout&&(clearTimeout(this.timeout),this.timeout=null)}}],[{key:"timeoutForAttempt",value:function(t){return Math.floor(350*Math.random())-175+2e3*Math.pow(2,t)}},{key:"isUnrecoverableRecoverableError",value:function(t){return"unauthorized_credentials"===t.error_type||"user_unauthenticated"===t.error_type}}]),t}();Q.REFRESH_INTERVAL_MS=18e4;var tt=15,et=800,rt=function(){function t(e){g(this,t),this.maxBatchSize=e.maxBatchSize,this.logEventURL=e.logEventURL,setInterval(this.flush.bind(this),e.intervalDurationMs),this.batch=[]}return b(t,[{key:"logEvent",value:function(t,e){this.batch.push({telemetry:t,event:e}),this.batch.length>=this.maxBatchSize&&this.flush()}},{key:"flush",value:function(){return K(this,void 0,void 0,y().mark((function t(){var e;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.batch.length){t.next=2;break}return t.abrupt("return");case 2:return e=this.batch,this.batch=[],t.prev=4,t.next=7,fetch(this.logEventURL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});case 7:t.next=11;break;case 9:t.prev=9,t.t0=t.catch(4);case 11:case"end":return t.stop()}}),t,this,[[4,9]])})))}}]),t}();Promise.resolve({pkceRequiredForEmailMagicLinks:!1}),Promise.resolve({pkceRequiredForPasswordResets:!1});var nt=Promise.resolve({pkceRequiredForEmailMagicLinks:!1}),ot=function(){function t(e,r,n){var o=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:nt;g(this,t),this._networkClient=e,this._subscriptionService=r,this._pkceManager=n,this._config=i,this.email={loginOrSignup:function(t){return K(o,void 0,void 0,y().mark((function e(){var r,n,o,i;return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return X("stytch.magicLinks.email.loginOrSignup").isString("email",t.email_address).isString("organization_id",t.organization_id).isOptionalString("login_redirect_url",t.login_redirect_url).isOptionalString("login_template_id",t.login_template_id).isOptionalString("signup_redirect_url",t.signup_redirect_url).isOptionalString("signup_template_id",t.signup_template_id),e.next=3,this._config;case 3:if(r=e.sent,n=r.pkceRequiredForEmailMagicLinks,o=void 0,!n){e.next=10;break}return e.next=9,this.getCodeChallenge();case 9:o=e.sent;case 10:return i=Object.assign(Object.assign({},t),{pkce_code_challenge:o}),e.abrupt("return",this._networkClient.fetchSDK({url:"/b2b/magic_links/email/login_or_signup",body:i,errorMessage:"Failed to send magic link",method:"POST"}));case 12:case"end":return e.stop()}}),e,this)})))}},this.authenticate=function(t){return K(o,void 0,void 0,y().mark((function e(){var r,n,o;return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return X("stytch.magicLinks.authenticate").isString("magic_links_token",t.magic_links_token).isNumber("session_duration_minutes",t.session_duration_minutes),n=Object.assign({pkce_code_verifier:null===(r=this._pkceManager.getPKPair())||void 0===r?void 0:r.code_verifier},t),e.next=4,this._networkClient.fetchSDK({url:"/b2b/magic_links/authenticate",body:n,errorMessage:"Failed to authenticate token.",method:"POST"});case 4:return o=e.sent,this._pkceManager.clearPKPair(),this._subscriptionService.updateStateAndTokens({state:{session:o.member_session,member:o.member},session_token:o.session_token,session_jwt:o.session_jwt}),e.abrupt("return",o);case 8:case"end":return e.stop()}}),e,this)})))}}return b(t,[{key:"getCodeChallenge",value:function(){return K(this,void 0,void 0,y().mark((function t(){var e;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e=this._pkceManager.getPKPair())){t.next=3;break}return t.abrupt("return",e.code_challenge);case 3:return t.next=5,this._pkceManager.startPKCETransaction();case 5:return e=t.sent,t.abrupt("return",e.code_challenge);case 7:case"end":return t.stop()}}),t,this)})))}}]),t}(),it=b((function t(e,r){var n=this;g(this,t),this._networkClient=e,this._subscriptionService=r,this.get=function(){return K(n,void 0,void 0,y().mark((function t(){var e;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._networkClient.fetchSDK({url:"/b2b/organizations/members/me",errorMessage:"Failed to retrieve member info.",method:"GET"});case 2:return e=t.sent,this._subscriptionService.updateMember(e.member),t.abrupt("return",e.member);case 5:case"end":return t.stop()}}),t,this)})))},this.getSync=function(){return n._subscriptionService.getMember()},this.onChange=function(t){return n._subscriptionService.subscribeToState((function(e){var r;return t(null!==(r=null==e?void 0:e.member)&&void 0!==r?r:null)}))}})),at=function(){function t(e,r,n,o,i){g(this,t),this._networkClient=e,this._subscriptionService=r,this._pkceManager=n,this._dynamicConfig=o,this._config=i}return b(t,[{key:"authenticate",value:function(t){return K(this,void 0,void 0,y().mark((function e(){var r,n;return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return X("stytch.sso.authenticate").isString("sso_token",t.sso_token).isNumber("session_duration_minutes",t.session_duration_minutes),(r=this._pkceManager.getPKPair())||J.warn("No code verifier found in local storage for SSO flow.\nConsider using stytch.oauth.$provider.start() to add PKCE to your OAuth flows for added security.\nSee https://stytch.com/docs/oauth#guides_pkce for more information."),e.next=5,this._networkClient.fetchSDK({url:"/sso/authenticate",method:"POST",body:Object.assign({pkce_code_verifier:null==r?void 0:r.code_verifier},t),errorMessage:"Failed to authenticate token"});case 5:return n=e.sent,this._pkceManager.clearPKPair(),this._subscriptionService.updateStateAndTokens({state:{session:n.member_session,member:n.member},session_token:n.session_token,session_jwt:n.session_jwt}),e.abrupt("return",n);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"getBaseApiUrl",value:function(){return K(this,void 0,void 0,y().mark((function t(){return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._config.publicToken.includes("public-token-test")){t.next=2;break}return t.abrupt("return",this._config.testAPIURL);case 2:return t.abrupt("return",this._config.liveAPIURL);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"start",value:function(t){var e=t.connection_id,r=t.login_redirect_url,n=t.signup_redirect_url;return K(this,void 0,void 0,y().mark((function t(){var o,i,a,s,c;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._dynamicConfig;case 2:return o=t.sent,i=o.pkceRequiredForSso,t.next=6,this.getBaseApiUrl();case 6:if(a=t.sent,(s=new URL("".concat(a,"/v1/public/sso/start"))).searchParams.set("public_token",this._config.publicToken),s.searchParams.set("connection_id",e),!i){t.next=17;break}return t.next=13,this._pkceManager.startPKCETransaction();case 13:c=t.sent,s.searchParams.set("pkce_code_challenge",c.code_challenge),t.next=18;break;case 17:this._pkceManager.clearPKPair();case 18:r&&s.searchParams.set("login_redirect_url",r),n&&s.searchParams.set("signup_redirect_url",n),window.location.href=s.toString();case 21:case"end":return t.stop()}}),t,this)})))}}]),t}(),st=b((function t(e){var r=this;g(this,t),this._networkClient=e,this.get=function(){return K(r,void 0,void 0,y().mark((function t(){var e;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._networkClient.fetchSDK({url:"/b2b/organizations/me",errorMessage:"Failed to retrieve organization info.",method:"GET"});case 2:return e=t.sent,t.abrupt("return",e.organization);case 4:case"end":return t.stop()}}),t,this)})))}})),ct=function(){function t(e,r){var n=this;g(this,t),this._networkClient=e,this._subscriptionService=r,this.getSync=function(){return n._subscriptionService.getSession()},this.onChange=function(t){return n._subscriptionService.subscribeToState((function(e){var r;return t(null!==(r=null==e?void 0:e.session)&&void 0!==r?r:null)}))},this.revoke=function(){return K(n,void 0,void 0,y().mark((function t(){var e;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._networkClient.fetchSDK({url:"/b2b/sessions/revoke",errorMessage:"Error revoking session",method:"POST"});case 2:e=t.sent;try{this._subscriptionService.destroyState()}catch(t){}return t.abrupt("return",e);case 5:case"end":return t.stop()}}),t,this)})))},this.authenticate=function(t){return K(n,void 0,void 0,y().mark((function e(){var r,n;return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,r={session_duration_minutes:null==t?void 0:t.session_duration_minutes},e.next=4,this._networkClient.fetchSDK({url:"/b2b/sessions/authenticate",body:r,errorMessage:"Error authenticating session",method:"POST"});case 4:return n=e.sent,this._subscriptionService.updateStateAndTokens({state:{session:n.member_session,member:n.member},session_token:n.session_token,session_jwt:n.session_jwt}),e.abrupt("return",n);case 9:throw e.prev=9,e.t0=e.catch(0),this._subscriptionService.destroyState(),e.t0;case 13:case"end":return e.stop()}}),e,this,[[0,9]])})))}}return b(t,[{key:"getTokens",value:function(){return this._subscriptionService.getTokens()}}]),t}(),ut=Symbol.for("stytch__internal"),lt=function(t,e){Object.assign(t,function(t,e,r){return(e=f(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},ut,e))};function ft(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))}var ht=function(){function t(e,r,n,o){c(this,t),this._publicToken=e,this._subscriptionDataLayer=r,this.baseURL=n,this.additionalTelemetryDataFn=o,this.updateSessionToken=function(){return null},this.eventLogger=new rt({maxBatchSize:tt,intervalDurationMs:et,logEventURL:this.buildSDKUrl("/events")})}return l(t,[{key:"logEvent",value:function(t){var e=t.name,r=t.details,n=t.error,o=void 0===n?{}:n;this.eventLogger.logEvent(this.createTelemetryBlob(),{public_token:this._publicToken,event_name:e,details:r,error_code:o.error_code,error_description:o.error_description,http_status_code:o.http_status_code})}},{key:"createTelemetryBlob",value:function(){return Object.assign(Object.assign({event_id:"event-id-".concat(V()),app_session_id:"app-session-id-".concat(V()),persistent_id:"persistent-id-".concat(V()),client_sent_at:(new Date).toISOString(),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone},this.additionalTelemetryDataFn()),{app:{identifier:window.location.hostname},sdk:{identifier:"Stytch.js Javascript SDK",version:"0.10.0"}})}},{key:"fetchSDK",value:function(t){var e=t.url,r=t.body,n=t.errorMessage,o=t.method;return ft(this,void 0,void 0,s().mark((function t(){var i,a,c,u;return s().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=this._subscriptionDataLayer.readSessionCookie().session_token,a="Basic "+window.btoa(this._publicToken+":"+(i||this._publicToken)),c=window.btoa(JSON.stringify(this.createTelemetryBlob())),u=window.location.origin,t.abrupt("return",Z({basicAuthHeader:a,body:r,errorMessage:n,finalURL:this.buildSDKUrl(e),method:o,xSDKClientHeader:c,xSDKParentHostHeader:u}));case 5:case"end":return t.stop()}}),t,this)})))}},{key:"buildSDKUrl",value:function(t){return"".concat(this.baseURL,"/sdk/v1").concat(t)}}]),t}();
4
+ /*! js-cookie v3.0.1 | MIT */
5
+ function pt(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)t[n]=r[n]}return t}var dt=function t(e,r){function n(t,n,o){if("undefined"!=typeof document){"number"==typeof(o=pt({},r,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var i="";for(var a in o)o[a]&&(i+="; "+a,!0!==o[a]&&(i+="="+o[a].split(";")[0]));return document.cookie=t+"="+e.write(n,t)+i}}return Object.create({set:n,get:function(t){if("undefined"!=typeof document&&(!arguments.length||t)){for(var r=document.cookie?document.cookie.split("; "):[],n={},o=0;o<r.length;o++){var i=r[o].split("="),a=i.slice(1).join("=");try{var s=decodeURIComponent(i[0]);if(n[s]=e.read(a,s),t===s)break}catch(t){}}return t?n[t]:n}},remove:function(t,e){n(t,"",pt({},e,{expires:-1}))},withAttributes:function(e){return t(this.converter,pt({},this.attributes,e))},withConverter:function(e){return t(pt({},this.converter,e),this.attributes)}},{attributes:{value:Object.freeze(r)},converter:{value:Object.freeze(e)}})}({read:function(t){return'"'===t[0]&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"}),vt="stytch_sdk_state_",yt=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"".concat(vt).concat(t).concat(e?"::".concat(e):"")},mt=function(){function t(e,r){var n=this;c(this,t),this.browserSessionStorage={getItem:function(t){return sessionStorage.getItem(yt(n.publicToken,t))},setItem:function(t,e){return sessionStorage.setItem(yt(n.publicToken,t),e)},removeItem:function(t){return sessionStorage.removeItem(yt(n.publicToken,t))}},this.publicToken=e,this.state=null,this.subscriptions={},(null==r?void 0:r.cookieOptions)?(X("SubscriptionDataLayer").isOptionalString("cookieOptions.opaqueTokenCookieName",r.cookieOptions.opaqueTokenCookieName).isOptionalString("cookieOptions.jwtCookieName",r.cookieOptions.jwtCookieName).isOptionalString("cookieOptions.path",r.cookieOptions.path),this._jwtCookieName=r.cookieOptions.jwtCookieName||null,this._opaqueTokenCookieName=r.cookieOptions.opaqueTokenCookieName||null,this._cookiePath=r.cookieOptions.path||null,this._cookieAvailableToSubdomains=r.cookieOptions.availableToSubdomains||!1):(this._opaqueTokenCookieName=null,this._jwtCookieName=null,this._cookiePath=null,this._cookieAvailableToSubdomains=!1);var o=localStorage.getItem(yt(this.publicToken));if(o){var i;try{i=JSON.parse(o)}catch(t){return this.syncToLocalStorage(),void this.removeSessionCookie()}this.state=i}else this.removeSessionCookie()}return l(t,[{key:"opaqueTokenCookieName",get:function(){var t;return null!==(t=this._opaqueTokenCookieName)&&void 0!==t?t:"stytch_session"}},{key:"jwtCookieName",get:function(){var t;return null!==(t=this._jwtCookieName)&&void 0!==t?t:"stytch_session_jwt"}},{key:"readSessionCookie",value:function(){return{session_token:dt.get(this.opaqueTokenCookieName),session_jwt:dt.get(this.jwtCookieName)}}},{key:"writeSessionCookie",value:function(e){var r,n,o=e.state,i=e.session_token,a=e.session_jwt,s=t.generateCookieOpts({expiresAt:null!==(n=null===(r=null==o?void 0:o.session)||void 0===r?void 0:r.expires_at)&&void 0!==n?n:"",availableToSubdomains:this._cookieAvailableToSubdomains,path:this._cookiePath});dt.set(this.opaqueTokenCookieName,i,s),dt.set(this.jwtCookieName,a,s)}},{key:"removeSessionCookie",value:function(){var e=this;[!0,!1].forEach((function(r){[e._cookiePath,null].forEach((function(n){var o=t.generateCookieOpts({expiresAt:new Date(0).toString(),availableToSubdomains:r,path:n});dt.remove(e.opaqueTokenCookieName,o),dt.remove(e.jwtCookieName,o)}))}))}},{key:"syncToLocalStorage",value:function(){localStorage.setItem(yt(this.publicToken),JSON.stringify(this.state))}},{key:"getItem",value:function(t){return localStorage.getItem(yt(this.publicToken,t))}},{key:"setItem",value:function(t,e){return localStorage.setItem(yt(this.publicToken,t),e)}},{key:"removeItem",value:function(t){return localStorage.removeItem(yt(this.publicToken,t))}}],[{key:"generateCookieOpts",value:function(t){var e=t.path,r=t.availableToSubdomains,n=t.expiresAt,o={expires:new Date(n),sameSite:"lax"};return e&&(o.path=e),Boolean("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/))?o.secure=!1:(r&&(o.domain=window.location.host),o.secure=!0),o}}]),t}(),bt=function(t){n(r,mt);var e=i(r);function r(){return c(this,r),e.apply(this,arguments)}return l(r)}(),gt=Symbol.for("__stytch_b2b_DataLayer"),_t=function(t,e){var r,n=((r=window)[gt]||(r[gt]={}),r[gt]);return n[t]||(n[t]=new bt(t,e)),n[t]},wt=function(t,e){Object.values(t).forEach((function(t){return t(e)}))},kt=function(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).KEYS_TO_EXCLUDE,e=void 0===t?[]:t;return function t(r,n){return p(r)===p(n)&&(null===r||null===n?r===n:"object"===p(r)?Object.keys(r).length===Object.keys(n).length&&!Object.keys(r).some((function(t){return!(t in n)}))&&Object.entries(r).filter((function(t){var r=h(t,1)[0];return!e.includes(r)})).every((function(e){var r=h(e,2),o=r[0],i=r[1];return t(i,n[o])})):r===n)}}({KEYS_TO_EXCLUDE:["last_accessed_at"]}),St=function(){function t(e,r){var n,o=this;c(this,t),this._publicToken=e,this._datalayer=r,this._listen=function(t){t.key===yt(o._publicToken)&&(null!==t.newValue?o._updateStateAndTokensInternal(JSON.parse(t.newValue)):o.destroyState())},window.addEventListener("storage",this._listen);var i=null===(n=this._datalayer.state)||void 0===n?void 0:n.session;i&&Date.parse(i.expires_at)<Date.now()?this.destroyState():this._datalayer.readSessionCookie().session_token||this.destroyState()}return l(t,[{key:"getTokens",value:function(){var t=this._datalayer.readSessionCookie(),e=t.session_token,r=t.session_jwt;return e&&r?{session_token:e,session_jwt:r}:null}},{key:"destroyState",value:function(){this.updateStateAndTokens({state:null,session_token:null,session_jwt:null})}},{key:"_updateStateAndTokensInternal",value:function(t){var e=t.state,r=this._datalayer.state;this._datalayer.state=e||null,kt(r,t.state)||wt(this._datalayer.subscriptions,t.state)}},{key:"updateStateAndTokens",value:function(t){t.state?this._datalayer.writeSessionCookie(t):this._datalayer.removeSessionCookie(),this._updateStateAndTokensInternal(t),this._datalayer.syncToLocalStorage()}},{key:"updateState",value:function(t){var e=this._datalayer.state,r=Object.assign(Object.assign({},this._datalayer.state),t);this._datalayer.state=r,kt(e,r)||(wt(this._datalayer.subscriptions,r),this._datalayer.syncToLocalStorage())}},{key:"subscribeToState",value:function(t){return e=this._datalayer.subscriptions,r=t,n=Math.random().toString(36).slice(-10),e[n]=r,function(){return delete e[n]};var e,r,n}},{key:"getState",value:function(){return this._datalayer.state}},{key:"destroy",value:function(){window.removeEventListener("storage",this._listen)}},{key:"syncFromDeviceStorage",value:function(){return null}}]),t}(),Et=function(t){n(r,St);var e=i(r);function r(){var t;return c(this,r),(t=e.apply(this,arguments)).updateMember=function(e){return t.updateState({member:e})},t.getMember=function(){var e,r;return null!==(r=null===(e=t.getState())||void 0===e?void 0:e.member)&&void 0!==r?r:null},t.getSession=function(){var e,r;return null!==(r=null===(e=t.getState())||void 0===e?void 0:e.session)&&void 0!==r?r:null},t}return l(r)}();function Ot(t){var e=t.toString(16);return 1===e.length&&(e="0"+e),e}var Tt=function(){function t(e,r){c(this,t),this._dataLayer=e,this.namespace=r}return l(t,[{key:"key",value:function(){return"PKCE_VERIFIER:"+this.namespace}},{key:"startPKCETransaction",value:function(){return ft(this,void 0,void 0,s().mark((function e(){var r;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.createProofkeyPair();case 2:return r=e.sent,this._dataLayer.setItem(this.key(),JSON.stringify(r)),e.abrupt("return",r);case 5:case"end":return e.stop()}}),e,this)})))}},{key:"getPKPair",value:function(){var t=this._dataLayer.getItem(this.key());if(null!==t)try{return JSON.parse(t)}catch(t){return void J.warn("Found malformed Proof Key pair in localstorage.")}}},{key:"clearPKPair",value:function(){return this._dataLayer.removeItem(this.key())}}],[{key:"createProofkeyPair",value:function(){return ft(this,void 0,void 0,s().mark((function t(){var r,n,o;return s().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new Uint32Array(16),window.crypto.getRandomValues(r),n=Array.from(r).map(Ot).join(""),t.next=5,window.crypto.subtle.digest("SHA-256",(new TextEncoder).encode(n));case 5:return o=t.sent,t.abrupt("return",{code_challenge:(i=o,a=void 0,btoa((a=String.fromCharCode).call.apply(a,[null].concat(e(new Uint8Array(i))))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")),code_verifier:n});case 7:case"end":return t.stop()}var i,a}),t)})))}}]),t}(),xt="bootstrap",Pt=function(){return{displayWatermark:!1,cnameDomain:null,emailDomains:["stytch.com"],captchaSettings:{enabled:!1},pkceRequiredForEmailMagicLinks:!1,pkceRequiredForPasswordResets:!1,pkceRequiredForOAuth:!1,pkceRequiredForSso:!1}},Lt=function(){function t(e,r,n){var o=this;c(this,t),this._publicToken=e,this._networkClient=r,this._dataLayer=n,this._bootstrapDataPromise=this._networkClient.fetchSDK({url:"/projects/bootstrap/".concat(this._publicToken),method:"GET",errorMessage:"Error fetching bootstrap data for SDK for ".concat(this._publicToken)}).then(t.mapBootstrapData).then((function(t){return o._dataLayer.setItem(xt,JSON.stringify(t)),t})).catch((function(t){return J.error(t),Pt()}))}return l(t,[{key:"getSync",value:function(){var t=this._dataLayer.getItem(xt);if(null===t)return Pt();try{return JSON.parse(t)}catch(t){return Pt()}}},{key:"getAsync",value:function(){return this._bootstrapDataPromise}}],[{key:"mapBootstrapData",value:function(t){return{displayWatermark:!t.disable_sdk_watermark,captchaSettings:t.captcha_settings,cnameDomain:t.cname_domain,emailDomains:t.email_domains,pkceRequiredForEmailMagicLinks:t.pkce_required_for_email_magic_links,pkceRequiredForPasswordResets:t.pkce_required_for_password_resets,pkceRequiredForOAuth:t.pkce_required_for_oauth,pkceRequiredForSso:t.pkce_required_for_sso}}}]),t}(),Ct=l((function t(e,r){var n,o=this;c(this,t),function(t){if("undefined"==typeof window)throw new Error("The ".concat(t," is not compatible with server-side environments.\nIf using nextjs, use the create").concat(t," method instead.\n```\n").concat("import { createStytchB2BHeadlessClient } from '@stytch/nextjs/b2b';\n \n const stytch = createStytchB2BHeadlessClient('public-token-...');\n ","\n```\n"))}("StytchB2BHeadlessClient"),"string"!=typeof(n=e)?J.warn("Public token is malformed. Expected a string, got ".concat(p(n),".").concat($)):""===n?J.warn('Public token is malformed. Expected "public-token-...", got an empty string.'.concat($)):n.startsWith("public-token-")||J.warn('Public token is malformed. Expected "public-token-...", got '.concat(n,".").concat($));var i,a,s,u,l,f,h,d,v,y=r,m={cookieOptions:null==(i=y)?void 0:i.cookieOptions,endpoints:{sdkBackendURL:null!==(s=null===(a=null==i?void 0:i.endpoints)||void 0===a?void 0:a.sdkBackendURL)&&void 0!==s?s:"https://web.stytch.com",testAPIURL:null!==(l=null===(u=null==i?void 0:i.endpoints)||void 0===u?void 0:u.testAPIURL)&&void 0!==l?l:"https://test.stytch.com",liveAPIURL:null!==(h=null===(f=null==i?void 0:i.endpoints)||void 0===f?void 0:f.liveAPIURL)&&void 0!==h?h:"https://api.stytch.com",clientsideServicesIframeURL:null!==(v=null===(d=null==i?void 0:i.endpoints)||void 0===d?void 0:d.clientsideServicesIframeURL)&&void 0!==v?v:"https://js.stytch.com/clientside-services/index.html"}};this._dataLayer=_t(e,y),this._subscriptionService=new Et(e,this._dataLayer);this._networkClient=new ht(e,this._dataLayer,m.endpoints.sdkBackendURL,(function(){var t,e,r,n;return{stytch_member_id:null===(e=null===(t=o._dataLayer.state)||void 0===t?void 0:t.member)||void 0===e?void 0:e.member_id,stytch_member_session_id:null===(n=null===(r=o._dataLayer.state)||void 0===r?void 0:r.session)||void 0===n?void 0:n.member_session_id}}));var b=new Lt(e,this._networkClient,this._dataLayer);this.organization=new st(this._networkClient),this.member=new it(this._networkClient,this._subscriptionService),this.session=new ct(this._networkClient,this._subscriptionService),this.magicLinks=new ot(this._networkClient,this._subscriptionService,new Tt(this._dataLayer,"magic_links"),b.getAsync()),this.sso=new at(this._networkClient,this._subscriptionService,new Tt(this._dataLayer,"sso"),b.getAsync(),{publicToken:e,testAPIURL:m.endpoints.testAPIURL,liveAPIURL:m.endpoints.liveAPIURL}),this._sessionManager=new Q(this._subscriptionService,this.session),this._dataLayer.readSessionCookie().session_token&&this._sessionManager.performBackgroundRefresh(),this._networkClient.logEvent({name:"b2b_sdk_instance_instantiated",details:{event_callback_registered:!1,error_callback_registered:!1,success_callback_registered:!1}}),lt(this,{bootstrap:b,publicToken:e})}));function At(t){return At="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},At(t)}function jt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(o=n.key,i=void 0,i=function(t,e){if("object"!==At(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==At(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(o,"string"),"symbol"===At(i)?i:String(i)),n)}var o,i}function Rt(t,e,r){return e&&jt(t.prototype,e),r&&jt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function It(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Dt(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Ft(t,e)}function Nt(t){var e=Kt();return function(){var r,n=qt(t);if(e){var o=qt(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return function(t,e){if(e&&("object"===At(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return Mt(t)}(this,r)}}function Mt(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Bt(t){var e="function"==typeof Map?new Map:void 0;return Bt=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return Ut(t,arguments,qt(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),Ft(n,t)},Bt(t)}function Ut(t,e,r){return Ut=Kt()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Ft(o,r.prototype),o},Ut.apply(null,arguments)}function Kt(){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(t){return!1}}function Ft(t,e){return Ft=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Ft(t,e)}function qt(t){return qt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},qt(t)}exports.Products=void 0,function(t){t.emailMagicLinks="emailMagicLinks",t.oauth="oauth",t.otp="otp",t.crypto="crypto",t.passwords="passwords"}(exports.Products||(exports.Products={})),exports.OAuthProviders=void 0,function(t){t.Google="google",t.Microsoft="microsoft",t.Apple="apple",t.Github="github",t.GitLab="gitlab",t.Facebook="facebook",t.Discord="discord",t.Slack="slack",t.Amazon="amazon",t.Bitbucket="bitbucket",t.LinkedIn="linkedin",t.Coinbase="coinbase",t.Twitch="twitch"}(exports.OAuthProviders||(exports.OAuthProviders={})),exports.Wallets=void 0,function(t){t.Vessel="Vessel",t.Phantom="Phantom",t.Metamask="Metamask",t.Coinbase="Coinbase",t.Binance="Binance",t.GenericEthereumWallet="Other Ethereum Wallet",t.GenericSolanaWallet="Other Solana Wallet"}(exports.Wallets||(exports.Wallets={})),exports.OneTapPositions=void 0,function(t){t.embedded="embedded",t.floating="floating"}(exports.OneTapPositions||(exports.OneTapPositions={})),exports.OTPMethods=void 0,function(t){t.SMS="sms",t.WhatsApp="whatsapp",t.Email="email"}(exports.OTPMethods||(exports.OTPMethods={})),exports.StytchEventType=void 0,function(t){t.MagicLinkLoginOrCreateEvent="MAGIC_LINK_LOGIN_OR_CREATE",t.OTPsLoginOrCreateEvent="OTP_LOGIN_OR_CREATE",t.OTPsAuthenticate="OTP_AUTHENTICATE",t.CryptoWalletAuthenticateStart="CRYPTO_WALLET_AUTHENTICATE_START",t.CryptoWalletAuthenticate="CRYPTO_WALLET_AUTHENTICATE",t.PasswordCreate="PASSWORD_CREATE",t.PasswordAuthenticate="PASSWORD_AUTHENTICATE",t.PasswordResetByEmailStart="PASSWORD_RESET_BY_EMAIL_START",t.PasswordResetByEmail="PASSWORD_RESET_BY_EMAIL"}(exports.StytchEventType||(exports.StytchEventType={}));var Gt=function(t){Dt(r,Bt(Error));var e=Nt(r);function r(t,n){var o;return It(this,r),(o=e.call(this,t+"\n"+n)).message=t+"\n"+n,o.name="SDKAPIUnreachableError",o.details=n,Object.setPrototypeOf(Mt(o),r.prototype),o}return Rt(r)}(),Wt=function(t){Dt(r,Bt(Error));var e=Nt(r);function r(t,n){var o;return It(this,r),(o=e.call(this)).name="StytchSDKUsageError",o.message="Invalid call to ".concat(t,"\n")+n,o}return Rt(r)}(),Ht=function(t){Dt(r,Bt(Error));var e=Nt(r);function r(t){var n,o;It(this,r),(n=e.call(this)).name="StytchSDKSchemaError";var i=null===(o=t.body)||void 0===o?void 0:o.map((function(t){return"".concat(t.dataPath,": ").concat(t.message)})).join("\n");return n.message="[400] Request does not match expected schema\n".concat(i),n}return Rt(r)}(),zt=function(t){Dt(r,Bt(Error));var e=Nt(r);function r(t){var n;It(this,r),(n=e.call(this)).name="StytchSDKAPIError";var o=t.status_code,i=t.error_type,a=t.error_message,s=t.error_url,c=t.request_id;return n.error_type=i,n.error_message=a,n.error_url=s,n.request_id=c,n.status_code=o,n.message="[".concat(o,"] ").concat(i,"\n")+"".concat(a,"\n")+"See ".concat(s," for more information.\n")+(c?"request_id: ".concat(c,"\n"):""),n}return Rt(r)}(),Vt=function(t){Dt(r,Bt(Error));var e=Nt(r);function r(t){var n;return It(this,r),(n=e.call(this)).name="StytchSDKNativeError",n.error_type=t,n.message="".concat(t),n}return Rt(r)}();exports.BiometricsErrors=void 0,function(t){t.BiometricsSensorError="biometrics_sensor_error",t.DeviceCredentialsNotAllowed="device_credentials_not_allowed",t.DeviceHardwareError="device_hardware_error",t.InternalError="internal_error",t.KeyInvalidated="key_invalidated",t.KeystoreUnavailable="keystore_unavailable",t.NoBiometricsEnrolled="no_biometrics_enrolled",t.NoBiometricsRegistration="no_biometrics_registration",t.SessionExpired="session_expired",t.UserCancellation="user_cancellation",t.UserLockedOut="user_locked_out"}(exports.BiometricsErrors||(exports.BiometricsErrors={})),exports.SDKAPIUnreachableError=Gt,exports.StytchB2BHeadlessClient=Ct,exports.StytchSDKAPIError=zt,exports.StytchSDKNativeError=Vt,exports.StytchSDKSchemaError=Ht,exports.StytchSDKUsageError=Wt;