diff --git a/bundle/bundle.js b/bundle/bundle.js index 690421cf..59c80718 100644 --- a/bundle/bundle.js +++ b/bundle/bundle.js @@ -1 +1 @@ -var supertokens;(()=>{"use strict";var e={759:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]o?[2,{isValid:!1,reason:{message:"expired",ageInSeconds:n,maxAgeInSeconds:o}}]:t.includes(e)?[2,{isValid:!0}]:[2,{isValid:!1,reason:{message:"wrong value",expectedToInclude:e,actualValue:t}}])}))}))}}},excludes:function(e,o,s){return void 0===o&&(o=t.defaultMaxAgeInSeconds),{id:void 0!==s?s:t.id,refresh:function(e){return t.refresh(e)},shouldRefresh:function(e,n){return void 0===t.getValueFromPayload(e,n)||void 0!==o&&e[t.id].to?[2,{isValid:!1,reason:{message:"expired",ageInSeconds:n,maxAgeInSeconds:o}}]:t.includes(e)?[2,{isValid:!1,reason:{message:"wrong value",expectedToNotInclude:e,actualValue:t}}]:[2,{isValid:!0}])}))}))}}},includesAll:function(e,o,s){return void 0===o&&(o=t.defaultMaxAgeInSeconds),{id:void 0!==s?s:t.id,refresh:function(e){return t.refresh(e)},shouldRefresh:function(e,n){return void 0===t.getValueFromPayload(e,n)||void 0!==o&&e[t.id].to?[2,{isValid:!1,reason:{message:"expired",ageInSeconds:n,maxAgeInSeconds:o}}]:(a=new Set(t),[2,(u=e.every((function(e){return a.has(e)})))?{isValid:u}:{isValid:u,reason:{message:"wrong value",expectedToInclude:e,actualValue:t}}]))}))}))}}},includesAny:function(e,o,s){return void 0===o&&(o=t.defaultMaxAgeInSeconds),{id:void 0!==s?s:t.id,refresh:function(e){return t.refresh(e)},shouldRefresh:function(e,n){return void 0===t.getValueFromPayload(e,n)||void 0!==o&&e[t.id].to?[2,{isValid:!1,reason:{message:"expired",ageInSeconds:n,maxAgeInSeconds:o}}]:(a=new Set(t),[2,(u=e.some((function(e){return a.has(e)})))?{isValid:u}:{isValid:u,reason:{message:"wrong value",expectedToIncludeAtLeastOneOf:e,actualValue:t}}]))}))}))}}},excludesAll:function(e,o,s){return void 0===o&&(o=t.defaultMaxAgeInSeconds),{id:void 0!==s?s:t.id,refresh:function(e){return t.refresh(e)},shouldRefresh:function(e,n){return void 0===t.getValueFromPayload(e,n)||void 0!==o&&e[t.id].to?[2,{isValid:!1,reason:{message:"expired",ageInSeconds:n,maxAgeInSeconds:o}}]:(a=new Set(t),[2,(u=e.every((function(e){return!a.has(e)})))?{isValid:u}:{isValid:u,reason:{message:"wrong value",expectedToNotInclude:e,actualValue:t}}]))}))}))}}}},this.id=e.id,this.refresh=e.refresh,this.defaultMaxAgeInSeconds=e.defaultMaxAgeInSeconds}return e.prototype.getValueFromPayload=function(e,t){return void 0!==e[this.id]?e[this.id].v:void 0},e.prototype.getLastFetchedTime=function(e,t){return void 0!==e[this.id]?e[this.id].t:void 0},e}();t.PrimitiveArrayClaim=o},911:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PrimitiveClaim=void 0;var n=function(){function e(e){var t=this;this.validators={hasValue:function(e,n,r){return void 0===n&&(n=t.defaultMaxAgeInSeconds),{id:void 0!==r?r:t.id,refresh:function(e){return t.refresh(e)},shouldRefresh:function(e,r){return void 0===t.getValueFromPayload(e,r)||void 0!==n&&e[t.id].tn?{isValid:!1,reason:{message:"expired",ageInSeconds:i,maxAgeInSeconds:n}}:s!==e?{isValid:!1,reason:{message:"wrong value",expectedValue:e,actualValue:s}}:{isValid:!0}}}}},this.id=e.id,this.refresh=e.refresh,this.defaultMaxAgeInSeconds=e.defaultMaxAgeInSeconds}return e.prototype.getValueFromPayload=function(e,t){return void 0!==e[this.id]?e[this.id].v:void 0},e.prototype.getLastFetchedTime=function(e,t){return void 0!==e[this.id]?e[this.id].t:void 0},e}();t.PrimitiveClaim=n},173:function(e,t){var n,r=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.STGeneralError=void 0;var o=function(e){function t(t){var n=e.call(this,t)||this;return n.isSuperTokensGeneralError=!0,n}return r(t,e),t.isThisError=function(e){return!0===e.isSuperTokensGeneralError},t}(Error);t.STGeneralError=o},379:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]=300)throw c;return[4,h.config.postAPIHook({action:"REFRESH_SESSION",fetchResponse:c.clone(),requestInit:u.requestInit,url:u.url,userContext:{}})];case 12:return s.sent(),[4,k(!1)];case 13:return"NOT_EXISTS"===s.sent().status?((0,d.logDebugMessage)("onUnauthorisedResponse: local session doesn't exist, so returning session expired"),[2,{result:"SESSION_EXPIRED"}]):(h.config.onHandleEvent({action:"REFRESH_SESSION",userContext:{}}),(0,d.logDebugMessage)("onUnauthorisedResponse: Sending RETRY signal"),[2,{result:"RETRY"}]);case 14:return v=s.sent(),[4,k(!1)];case 15:return"NOT_EXISTS"===s.sent().status?((0,d.logDebugMessage)("onUnauthorisedResponse: local session doesn't exist, so returning session expired"),[2,{result:"SESSION_EXPIRED",error:v}]):((0,d.logDebugMessage)("onUnauthorisedResponse: sending API_ERROR"),[2,{result:"API_ERROR",error:v}]);case 16:return[4,t.releaseLock("REFRESH_TOKEN_USE")];case 17:return s.sent(),(0,d.logDebugMessage)("onUnauthorisedResponse: Released lock"),[4,k(!1)];case 18:return"NOT_EXISTS"!==s.sent().status?[3,21]:((0,d.logDebugMessage)("onUnauthorisedResponse: local session doesn't exist, so removing anti-csrf and sFrontToken"),[4,f.removeToken()]);case 19:return s.sent(),[4,g.removeToken()];case 20:s.sent(),s.label=21;case 21:return[7];case 22:return[4,k(!1)];case 23:return"NOT_EXISTS"===(b=s.sent()).status?((0,d.logDebugMessage)("onUnauthorisedResponse: lock acquired failed and local session doesn't exist, so sending SESSION_EXPIRED"),[2,{result:"SESSION_EXPIRED"}]):b.status!==e.status||"EXISTS"===b.status&&"EXISTS"===e.status&&b.lastAccessTokenUpdate!==e.lastAccessTokenUpdate?((0,d.logDebugMessage)("onUnauthorisedResponse: lock acquired failed and retrying early because pre and post lastAccessTokenUpdate don't match"),[2,{result:"RETRY"}]):[3,2];case 24:return[2]}}))}))}function y(){(0,d.logDebugMessage)("onTokenUpdate: firing ACCESS_TOKEN_PAYLOAD_UPDATED event"),h.config.onHandleEvent({action:"ACCESS_TOKEN_PAYLOAD_UPDATED",userContext:{}})}function w(e){return o(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,h.recipeImpl.getInvalidClaimsFromResponse({response:e,userContext:{}})];case 1:return(t=n.sent())&&h.config.onHandleEvent({action:"API_INVALID_CLAIM",claimValidationErrors:t,userContext:{}}),[3,3];case 2:return n.sent(),[3,3];case 3:return[2]}}))}))}function k(e){return o(this,void 0,void 0,(function(){var t,n,r;return s(this,(function(o){switch(o.label){case 0:return(0,d.logDebugMessage)("getLocalSessionState: called"),[4,D(p)];case 1:return t=o.sent(),[4,g.doesTokenExists()];case 2:return o.sent()&&void 0!==t?((0,d.logDebugMessage)("getLocalSessionState: returning EXISTS since both frontToken and lastAccessTokenUpdate exists"),[2,{status:"EXISTS",lastAccessTokenUpdate:t}]):[3,3];case 3:return t?((0,d.logDebugMessage)("getLocalSessionState: returning NOT_EXISTS since frontToken was cleared but lastAccessTokenUpdate exists"),[2,{status:"NOT_EXISTS"}]):[3,4];case 4:return n={status:"MAY_EXIST"},e?((0,d.logDebugMessage)("getLocalSessionState: trying to refresh"),[4,m(n)]):[3,7];case 5:return"RETRY"!==(r=o.sent()).result?((0,d.logDebugMessage)("getLocalSessionState: return NOT_EXISTS in case error from backend"+r.result),[2,{status:"NOT_EXISTS"}]):((0,d.logDebugMessage)("getLocalSessionState: Retrying post refresh"),[4,k(e)]);case 6:return[2,o.sent()];case 7:return(0,d.logDebugMessage)("getLocalSessionState: returning: "+n.status),[2,n]}}))}))}function S(e){switch(e){case"access":return"st-access-token";case"refresh":return"st-refresh-token"}}function I(e,t){var n=S(e);return""!==t?((0,d.logDebugMessage)("setToken: saved ".concat(e," token into cookies")),T(n,t,Date.now()+31536e5)):((0,d.logDebugMessage)("setToken: cleared ".concat(e," token from cookies")),T(n,t,0))}function T(e,t,n){var r="Fri, 31 Dec 9999 23:59:59 GMT";n!==Number.MAX_SAFE_INTEGER&&(r=new Date(n).toUTCString());var o=h.config.sessionTokenFrontendDomain;return"localhost"===o||o===c.default.getReferenceOrThrow().windowHandler.location.getHostName()?u.default.getReferenceOrThrow().cookieHandler.setCookie("".concat(e,"=").concat(t,";expires=").concat(r,";path=/;samesite=").concat(h.config.isInIframe?"none;secure":"lax")):u.default.getReferenceOrThrow().cookieHandler.setCookie("".concat(e,"=").concat(t,";expires=").concat(r,";domain=").concat(o,";path=/;samesite=").concat(h.config.isInIframe?"none;secure":"lax"))}function R(e){return o(this,void 0,void 0,(function(){return s(this,(function(t){return[2,D(S(e))]}))}))}function D(e){return o(this,void 0,void 0,(function(){var t,n,r,o;return s(this,(function(s){switch(s.label){case 0:return n="; ",[4,u.default.getReferenceOrThrow().cookieHandler.getCookie()];case 1:return t=n+s.sent(),(r=t.split("; "+e+"=")).length>=2&&void 0!==(o=r.pop())?[2,o.split(";").shift()]:[2,void 0]}}))}))}function E(e,t){return void 0===t&&(t=!1),o(this,void 0,void 0,(function(){var n,r;return s(this,(function(o){switch(o.label){case 0:return(0,d.logDebugMessage)("setTokenHeaders: adding existing tokens as header"),[4,R("access")];case 1:return n=o.sent(),[4,R("refresh")];case 2:return r=o.sent(),!t&&void 0===n||void 0===r?(0,d.logDebugMessage)("setAuthorizationHeaderIfRequired: token for header based auth not found"):e.has("Authorization")?(0,d.logDebugMessage)("setAuthorizationHeaderIfRequired: Authorization header defined by the user, not adding"):((0,d.logDebugMessage)("setAuthorizationHeaderIfRequired: added authorization header"),e.set("Authorization","Bearer ".concat(t?r:n))),[2]}}))}))}function x(e){return o(this,void 0,void 0,(function(){var t,n,r,o,i;return s(this,(function(s){switch(s.label){case 0:return(0,d.logDebugMessage)("saveTokensFromHeaders: Saving updated tokens from the response headers"),null===(t=e.headers.get("st-refresh-token"))?[3,2]:((0,d.logDebugMessage)("saveTokensFromHeaders: saving new refresh token"),[4,I("refresh",t)]);case 1:s.sent(),s.label=2;case 2:return null===(n=e.headers.get("st-access-token"))?[3,4]:((0,d.logDebugMessage)("saveTokensFromHeaders: saving new access token"),[4,I("access",n)]);case 3:s.sent(),s.label=4;case 4:return null===(r=e.headers.get("front-token"))?[3,6]:((0,d.logDebugMessage)("saveTokensFromHeaders: Setting sFrontToken: "+r),[4,g.setItem(r)]);case 5:s.sent(),s.label=6;case 6:return null===(o=e.headers.get("anti-csrf"))?[3,9]:[4,k(!0)];case 7:return"EXISTS"!==(i=s.sent()).status?[3,9]:((0,d.logDebugMessage)("saveTokensFromHeaders: Setting anti-csrf token"),[4,f.setItem(i.lastAccessTokenUpdate,o)]);case 8:s.sent(),s.label=9;case 9:return[2]}}))}))}function M(){return o(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return(0,d.logDebugMessage)("saveLastAccessTokenUpdate: called"),e=Date.now().toString(),(0,d.logDebugMessage)("saveLastAccessTokenUpdate: setting "+e),[4,T(p,e,Number.MAX_SAFE_INTEGER)];case 1:return t.sent(),[4,T("sIRTFrontend","",0)];case 2:return t.sent(),[2]}}))}))}function A(){return o(this,void 0,void 0,(function(){function e(){return o(this,void 0,void 0,(function(){var e,t,n,r,o;return s(this,(function(s){switch(s.label){case 0:return t="; ",[4,u.default.getReferenceOrThrow().cookieHandler.getCookie()];case 1:return e=t+s.sent(),(n=e.split("; sAntiCsrf=")).length>=2&&void 0!==(r=n.pop())?void 0===(o=r.split(";").shift())?[2,null]:[2,o]:[2,null]}}))}))}var t;return s(this,(function(n){switch(n.label){case 0:return(0,d.logDebugMessage)("getAntiCSRFToken: called"),[4,k(!0)];case 1:return"EXISTS"!==n.sent().status?((0,d.logDebugMessage)("getAntiCSRFToken: Returning because local session state != EXISTS"),[2,null]):[4,e()];case 2:return t=n.sent(),(0,d.logDebugMessage)("getAntiCSRFToken: returning: "+t),[2,t]}}))}))}function _(e){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return(0,d.logDebugMessage)("setAntiCSRF: called: "+e),void 0===e?[3,2]:[4,T(v,e,Number.MAX_SAFE_INTEGER)];case 1:return t.sent(),[3,4];case 2:return[4,T(v,"",0)];case 3:t.sent(),t.label=4;case 4:return[2]}}))}))}function C(){return o(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return(0,d.logDebugMessage)("getFrontTokenFromCookie: called"),[4,D(b)];case 1:return[2,void 0===(e=t.sent())?null:e]}}))}))}function O(e){return JSON.parse(decodeURIComponent(escape(atob(e))))}function P(){return o(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return(0,d.logDebugMessage)("getFrontToken: called"),[4,k(!0)];case 1:return"EXISTS"!==t.sent().status?((0,d.logDebugMessage)("getFrontToken: Returning because sIRTFrontend != EXISTS"),[2,null]):[4,C()];case 2:return e=t.sent(),(0,d.logDebugMessage)("getFrontToken: returning: "+e),[2,e]}}))}))}function H(e){return o(this,void 0,void 0,(function(){var t,n,r;return s(this,(function(o){switch(o.label){case 0:return(0,d.logDebugMessage)("setFrontToken: called"),[4,C()];case 1:return null!==(t=o.sent())&&void 0!==e&&(n=O(t).up,r=O(e).up,JSON.stringify(n)!==JSON.stringify(r)&&y()),void 0!==e?[3,3]:[4,T(b,"",0)];case 2:return o.sent(),[3,5];case 3:return[4,T(b,e,Number.MAX_SAFE_INTEGER)];case 4:o.sent(),o.label=5;case 5:return[2]}}))}))}function F(e,t,n){if(null!=n){var r="remove"!==n;(0,d.logDebugMessage)("fireSessionUpdateEventsIfNecessary wasLoggedIn: ".concat(e," frontTokenExistsAfter: ").concat(r," status: ").concat(t)),e?r||(t===h.config.sessionExpiredStatusCode?((0,d.logDebugMessage)("onUnauthorisedResponse: firing UNAUTHORISED event"),h.config.onHandleEvent({action:"UNAUTHORISED",sessionExpiredOrRevoked:!0,userContext:{}})):((0,d.logDebugMessage)("onUnauthorisedResponse: firing SIGN_OUT event"),h.config.onHandleEvent({action:"SIGN_OUT",userContext:{}}))):r&&((0,d.logDebugMessage)("onUnauthorisedResponse: firing SESSION_CREATED event"),h.config.onHandleEvent({action:"SESSION_CREATED",userContext:{}}))}else(0,d.logDebugMessage)("fireSessionUpdateEventsIfNecessary returning early because the front token was not updated")}t.onUnauthorisedResponse=m,t.onTokenUpdate=y,t.onInvalidClaimResponse=w,t.getLocalSessionState=k,t.getStorageNameForToken=S,t.setToken=I,t.getTokenForHeaderAuth=R,t.saveLastAccessTokenUpdate=M,t.setAntiCSRF=_,t.getFrontToken=P,t.setFrontToken=H,t.fireSessionUpdateEventsIfNecessary=F},569:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{u(r.next(e))}catch(e){s(e)}}function a(e){try{u(r.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}u((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]{Object.defineProperty(t,"__esModule",{value:!0}),t.logDebugMessage=t.disableLogging=t.enableLogging=void 0;var r=n(255),o=!1;t.enableLogging=function(){o=!0},t.disableLogging=function(){o=!1},t.logDebugMessage=function(e){o&&console.log("".concat("com.supertokens",' {t: "').concat((new Date).toISOString(),'", message: "').concat(e,'", supertokens-website-ver: "').concat(r.package_version,'"}'))}},992:(e,t)=>{function n(e){return/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.isAnIpAddress=void 0,t.isAnIpAddress=n;function r(e,t){void 0===t&&(t=!1),e=e.trim();try{if(!e.startsWith("http://")&&!e.startsWith("https://"))throw new Error("converting to proper URL");var o=new URL(e);return t?o.hostname.startsWith("localhost")||n(o.hostname)?"http://"+o.host:"https://"+o.host:o.protocol+"//"+o.host}catch(e){}if(e.startsWith("/"))throw new Error("Please provide a valid domain name");if(0===e.indexOf(".")&&(e=e.substr(1)),(-1!==e.indexOf(".")||e.startsWith("localhost"))&&!e.startsWith("http://")&&!e.startsWith("https://")){e="https://"+e;try{return new URL(e),r(e,!0)}catch(e){}}throw new Error("Please provide a valid domain name")}t.default=function(e){var t=this;this.getAsStringDangerous=function(){return t.value},this.value=r(e)}},260:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});function n(e){e=e.trim();try{if(!e.startsWith("http://")&&!e.startsWith("https://"))throw new Error("converting to proper URL");return"/"===(e=new URL(e).pathname).charAt(e.length-1)?e.substr(0,e.length-1):e}catch(e){}if((function(e){if(-1===e.indexOf(".")||e.startsWith("/"))return!1;try{return-1!==new URL(e).hostname.indexOf(".")}catch(e){}try{return-1!==new URL("http://"+e).hostname.indexOf(".")}catch(e){}return!1}(e)||e.startsWith("localhost"))&&!e.startsWith("http://")&&!e.startsWith("https://"))return n(e="http://"+e);"/"!==e.charAt(0)&&(e="/"+e);try{return new URL("http://example.com"+e),n("http://example.com"+e)}catch(e){throw new Error("Please provide a valid URL path")}}t.default=function e(t){var r=this;this.startsWith=function(e){return r.value.startsWith(e.value)},this.appendPath=function(t){return new e(r.value+t.value)},this.getAsStringDangerous=function(){return r.value},this.value=n(t)}},743:function(e,t){var n,r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{u(r.next(e))}catch(e){s(e)}}function a(e){try{u(r.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}u((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]=0;n--)if(e.history[n]==t)return e.history[n]},this.reset=function(){e.history=[]},this.waitForEvent=function(t,n){return void 0===n&&(n=7e3),r(e,void 0,void 0,(function(){var e,r=this;return o(this,(function(o){return e=Date.now(),[2,new Promise((function(o){var s=r;!function r(){var i=s.getEventByLastEventByName(t);void 0===i?Date.now()-e>n?o(void 0):setTimeout(r,1e3):o(i)}()}))]}))}))}}return e.getInstance=function(){return null==e.instance&&(e.instance=new e),e.instance},e}();t.ProcessState=s},994:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]=300)throw r;return[4,e.postAPIHook({action:"SIGN_OUT",requestInit:n.requestInit,url:n.url,fetchResponse:r.clone(),userContext:t.userContext})];case 4:return s.sent(),[4,r.clone().json()];case 5:if("GENERAL_ERROR"===(o=s.sent()).status)throw(0,c.logDebugMessage)("doRequest: Throwing general error"),a=void 0===o.message?"No Error Message Provided":o.message,new l.STGeneralError(a);return[2]}}))}))},getInvalidClaimsFromResponse:function(e){return o(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return"body"in e.response?[4,e.response.clone().json()]:[3,2];case 1:return t=n.sent(),[3,3];case 2:t="string"==typeof e.response.data?JSON.parse(e.response.data):e.response.data,n.label=3;case 3:return[2,t.claimValidationErrors]}}))}))},getGlobalClaimValidators:function(e){return e.claimValidatorsAddedByOtherRecipes},validateClaims:function(e){return o(this,void 0,void 0,(function(){var t,n,r,o,i,a,u,c,l;return s(this,(function(s){switch(s.label){case 0:return[4,this.getAccessTokenPayloadSecurely({userContext:e.userContext})];case 1:t=s.sent(),n=0,r=e.claimValidators,s.label=2;case 2:return n1){var u=n.split(":")[n.split(":").length-1];"string"!=typeof(i=u)||isNaN(i)||isNaN(parseFloat(i))||(a+=":"+u,o=""===r.port?o:o+":"+r.port)}return n.startsWith(".")?("."+o).endsWith(a):o===a}}}},272:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{u(r.next(e))}catch(e){s(e)}}function a(e){try{u(r.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}u((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]{Object.defineProperty(t,"__esModule",{value:!0}),t.CookieHandlerReference=void 0;var r=n(272),o=function(){function e(e){var t=function(e){return e};void 0!==e&&(t=e),this.cookieHandler=t(r.defaultCookieHandlerImplementation)}return e.init=function(t){void 0===e.instance&&(e.instance=new e(t))},e.getReferenceOrThrow=function(){if(void 0===e.instance)throw new Error("SuperTokensCookieHandler must be initialized before calling this method.");return e.instance},e}();t.CookieHandlerReference=o,t.default=o},318:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]{Object.defineProperty(t,"__esModule",{value:!0}),t.LockFactoryReference=void 0;var r=n(895),o=function(){function e(e){this.lockFactory=e}return e.init=function(t,n){void 0===this.instance&&(this.instance=new e(null!=t?t:function(e){return function(){return Promise.resolve(new r.default(e))}}(n)))},e.getReferenceOrThrow=function(){if(void 0===e.instance)throw new Error("SuperTokensLockReference must be initialized before calling this method.");return e.instance},e}();t.LockFactoryReference=o,t.default=o},153:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SessionClaimValidatorStore=void 0;var n=function(){function e(){}return e.claimValidatorsAddedByOtherRecipes=[],e.addClaimValidatorFromOtherRecipe=function(t){e.claimValidatorsAddedByOtherRecipes.push(t)},e.getClaimValidatorsAddedByOtherRecipes=function(){return e.claimValidatorsAddedByOtherRecipes},e}();t.SessionClaimValidatorStore=n,t.default=n},586:function(e,t){var n=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{u(r.next(e))}catch(e){s(e)}}function a(e){try{u(r.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}u((r=r.apply(e,t||[])).next())}))},r=this&&this.__generator||function(e,t){var n,r,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]{Object.defineProperty(t,"__esModule",{value:!0}),t.WindowHandlerReference=void 0;var r=n(586),o=function(){function e(e){var t=function(e){return e};void 0!==e&&(t=e),this.windowHandler=t(r.defaultWindowHandlerImplementation)}return e.init=function(t){void 0===e.instance&&(e.instance=new e(t))},e.getReferenceOrThrow=function(){if(void 0===e.instance)throw new Error("SuperTokensWindowHandler must be initialized before calling this method.");return e.instance},e}();t.WindowHandlerReference=o,t.default=o},255:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.supported_fdi=t.package_version=void 0,t.package_version="17.0.5",t.supported_fdi=["1.16","1.17","1.18"]},648:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{u(r.next(e))}catch(e){s(e)}}function a(e){try{u(r.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}u((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]0?setTimeout(n,t):n(null)}}window.addEventListener("storage",i),e.addToWaiting(i);var a=setTimeout(i,Math.max(0,t-Date.now()))}))];case 1:return n.sent(),[2]}}))}))},e.addToWaiting=function(t){this.removeFromWaiting(t),void 0!==e.waiters&&e.waiters.push(t)},e.removeFromWaiting=function(t){void 0!==e.waiters&&(e.waiters=e.waiters.filter((function(e){return e!==t})))},e.notifyWaiters=function(){void 0!==e.waiters&&e.waiters.slice().forEach((function(e){return e()}))},e.prototype.releaseLock=function(e){return r(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,this.releaseLock__private__(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.releaseLock__private__=function(t){return r(this,void 0,void 0,(function(){var n,r,s,c;return o(this,(function(o){switch(o.label){case 0:return n=void 0===this.storageHandler?u:this.storageHandler,r=a+"-"+t,null===(s=n.getItemSync(r))?[2]:(c=JSON.parse(s)).id!==this.id?[3,2]:[4,i.default().lock(c.iat)];case 1:o.sent(),this.acquiredIatSet.delete(c.iat),n.removeItemSync(r),i.default().unlock(c.iat),e.notifyWaiters(),o.label=2;case 2:return[2]}}))}))},e.lockCorrector=function(t){for(var n=Date.now()-5e3,r=t,o=[],s=0;;){var i=r.keySync(s);if(null===i)break;o.push(i),s++}for(var u=!1,c=0;c{Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(){var e=this;this.locked=new Map,this.addToLocked=function(t,n){var r=e.locked.get(t);void 0===r?void 0===n?e.locked.set(t,[]):e.locked.set(t,[n]):void 0!==n&&(r.unshift(n),e.locked.set(t,r))},this.isLocked=function(t){return e.locked.has(t)},this.lock=function(t){return new Promise((function(n,r){e.isLocked(t)?e.addToLocked(t,n):(e.addToLocked(t),n())}))},this.unlock=function(t){var n=e.locked.get(t);if(void 0!==n&&0!==n.length){var r=n.pop();e.locked.set(t,n),void 0!==r&&setTimeout(r,0)}else e.locked.delete(t)}}return e.getInstance=function(){return void 0===e.instance&&(e.instance=new e),e.instance},e}();t.default=function(){return n.getInstance()}},225:function(e,t){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n{Object.defineProperty(t,"__esModule",{value:!0}),t.OverrideableBuilder=void 0;var r=n(225),o=function(){function e(e){this.layers=[e],this.proxies=[]}return e.prototype.override=function(e){for(var t=(0,r.getProxyObject)(this.layers[0]),n=e(t,this),o=0,s=Object.keys(this.layers[0]);o=0;--o){var s=e.layers[o][n];if(null!=s)return s.bind(e.result).apply(void 0,r)}}},c=this,l=0;l{"use strict";var e={759:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]n?[2,{isValid:!1,reason:{message:"expired",ageInSeconds:r,maxAgeInSeconds:n}}]:t.includes(e)?[2,{isValid:!0}]:[2,{isValid:!1,reason:{message:"wrong value",expectedToInclude:e,actualValue:t}}])}))}))}}},excludes:function(e,n,i){void 0===n&&(n=t.defaultMaxAgeInSeconds);var a=s.default.getReferenceOrThrow().dateProvider;return{id:void 0!==i?i:t.id,refresh:function(e){return t.refresh(e)},shouldRefresh:function(e,r){return void 0===t.getValueFromPayload(e,r)||void 0!==n&&e[t.id].tn?[2,{isValid:!1,reason:{message:"expired",ageInSeconds:r,maxAgeInSeconds:n}}]:t.includes(e)?[2,{isValid:!1,reason:{message:"wrong value",expectedToNotInclude:e,actualValue:t}}]:[2,{isValid:!0}])}))}))}}},includesAll:function(e,n,i){void 0===n&&(n=t.defaultMaxAgeInSeconds);var a=s.default.getReferenceOrThrow().dateProvider;return{id:void 0!==i?i:t.id,refresh:function(e){return t.refresh(e)},shouldRefresh:function(e,r){return void 0===t.getValueFromPayload(e,r)||void 0!==n&&e[t.id].tn?[2,{isValid:!1,reason:{message:"expired",ageInSeconds:r,maxAgeInSeconds:n}}]:(u=new Set(t),[2,(c=e.every((function(e){return u.has(e)})))?{isValid:c}:{isValid:c,reason:{message:"wrong value",expectedToInclude:e,actualValue:t}}]))}))}))}}},includesAny:function(e,n,i){void 0===n&&(n=t.defaultMaxAgeInSeconds);var a=s.default.getReferenceOrThrow().dateProvider;return{id:void 0!==i?i:t.id,refresh:function(e){return t.refresh(e)},shouldRefresh:function(e,r){return void 0===t.getValueFromPayload(e,r)||void 0!==n&&e[t.id].tn?[2,{isValid:!1,reason:{message:"expired",ageInSeconds:r,maxAgeInSeconds:n}}]:(u=new Set(t),[2,(c=e.some((function(e){return u.has(e)})))?{isValid:c}:{isValid:c,reason:{message:"wrong value",expectedToIncludeAtLeastOneOf:e,actualValue:t}}]))}))}))}}},excludesAll:function(e,n,i){void 0===n&&(n=t.defaultMaxAgeInSeconds);var a=s.default.getReferenceOrThrow().dateProvider;return{id:void 0!==i?i:t.id,refresh:function(e){return t.refresh(e)},shouldRefresh:function(e,r){return void 0===t.getValueFromPayload(e,r)||void 0!==n&&e[t.id].tn?[2,{isValid:!1,reason:{message:"expired",ageInSeconds:r,maxAgeInSeconds:n}}]:(u=new Set(t),[2,(c=e.every((function(e){return!u.has(e)})))?{isValid:c}:{isValid:c,reason:{message:"wrong value",expectedToNotInclude:e,actualValue:t}}]))}))}))}}}},this.id=e.id,this.refresh=e.refresh,this.defaultMaxAgeInSeconds=e.defaultMaxAgeInSeconds}return e.prototype.getValueFromPayload=function(e,t){return void 0!==e[this.id]?e[this.id].v:void 0},e.prototype.getLastFetchedTime=function(e,t){return void 0!==e[this.id]?e[this.id].t:void 0},e}();t.PrimitiveArrayClaim=i},911:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PrimitiveClaim=void 0;var r=n(671),o=function(){function e(e){var t=this;this.validators={hasValue:function(e,n,o){void 0===n&&(n=t.defaultMaxAgeInSeconds);var s=r.default.getReferenceOrThrow().dateProvider;return{id:void 0!==o?o:t.id,refresh:function(e){return t.refresh(e)},shouldRefresh:function(e,r){return void 0===t.getValueFromPayload(e,r)||void 0!==n&&e[t.id].tn?{isValid:!1,reason:{message:"expired",ageInSeconds:a,maxAgeInSeconds:n}}:i!==e?{isValid:!1,reason:{message:"wrong value",expectedValue:e,actualValue:i}}:{isValid:!0}}}}},this.id=e.id,this.refresh=e.refresh,this.defaultMaxAgeInSeconds=e.defaultMaxAgeInSeconds}return e.prototype.getValueFromPayload=function(e,t){return void 0!==e[this.id]?e[this.id].v:void 0},e.prototype.getLastFetchedTime=function(e,t){return void 0!==e[this.id]?e[this.id].t:void 0},e}();t.PrimitiveClaim=o},173:function(e,t){var n,r=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.STGeneralError=void 0;var o=function(e){function t(t){var n=e.call(this,t)||this;return n.isSuperTokensGeneralError=!0,n}return r(t,e),t.isThisError=function(e){return!0===e.isSuperTokensGeneralError},t}(Error);t.STGeneralError=o},379:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]=300)throw c;return[4,h.config.postAPIHook({action:"REFRESH_SESSION",fetchResponse:c.clone(),requestInit:u.requestInit,url:u.url,userContext:{}})];case 12:return s.sent(),[4,w(!1)];case 13:return"NOT_EXISTS"===s.sent().status?((0,d.logDebugMessage)("onUnauthorisedResponse: local session doesn't exist, so returning session expired"),[2,{result:"SESSION_EXPIRED"}]):(h.config.onHandleEvent({action:"REFRESH_SESSION",userContext:{}}),(0,d.logDebugMessage)("onUnauthorisedResponse: Sending RETRY signal"),[2,{result:"RETRY"}]);case 14:return v=s.sent(),[4,w(!1)];case 15:return"NOT_EXISTS"===s.sent().status?((0,d.logDebugMessage)("onUnauthorisedResponse: local session doesn't exist, so returning session expired"),[2,{result:"SESSION_EXPIRED",error:v}]):((0,d.logDebugMessage)("onUnauthorisedResponse: sending API_ERROR"),[2,{result:"API_ERROR",error:v}]);case 16:return[4,t.releaseLock("REFRESH_TOKEN_USE")];case 17:return s.sent(),(0,d.logDebugMessage)("onUnauthorisedResponse: Released lock"),[4,w(!1)];case 18:return"NOT_EXISTS"!==s.sent().status?[3,21]:((0,d.logDebugMessage)("onUnauthorisedResponse: local session doesn't exist, so removing anti-csrf and sFrontToken"),[4,f.removeToken()]);case 19:return s.sent(),[4,g.removeToken()];case 20:s.sent(),s.label=21;case 21:return[7];case 22:return[4,w(!1)];case 23:return"NOT_EXISTS"===(b=s.sent()).status?((0,d.logDebugMessage)("onUnauthorisedResponse: lock acquired failed and local session doesn't exist, so sending SESSION_EXPIRED"),[2,{result:"SESSION_EXPIRED"}]):b.status!==e.status||"EXISTS"===b.status&&"EXISTS"===e.status&&b.lastAccessTokenUpdate!==e.lastAccessTokenUpdate?((0,d.logDebugMessage)("onUnauthorisedResponse: lock acquired failed and retrying early because pre and post lastAccessTokenUpdate don't match"),[2,{result:"RETRY"}]):[3,2];case 24:return[2]}}))}))}function k(){(0,d.logDebugMessage)("onTokenUpdate: firing ACCESS_TOKEN_PAYLOAD_UPDATED event"),h.config.onHandleEvent({action:"ACCESS_TOKEN_PAYLOAD_UPDATED",userContext:{}})}function y(e){return o(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,h.recipeImpl.getInvalidClaimsFromResponse({response:e,userContext:{}})];case 1:return(t=n.sent())&&h.config.onHandleEvent({action:"API_INVALID_CLAIM",claimValidationErrors:t,userContext:{}}),[3,3];case 2:return n.sent(),[3,3];case 3:return[2]}}))}))}function w(e){return o(this,void 0,void 0,(function(){var t,n,r;return s(this,(function(o){switch(o.label){case 0:return(0,d.logDebugMessage)("getLocalSessionState: called"),[4,D(p)];case 1:return t=o.sent(),[4,g.doesTokenExists()];case 2:return o.sent()&&void 0!==t?((0,d.logDebugMessage)("getLocalSessionState: returning EXISTS since both frontToken and lastAccessTokenUpdate exists"),[2,{status:"EXISTS",lastAccessTokenUpdate:t}]):[3,3];case 3:return t?((0,d.logDebugMessage)("getLocalSessionState: returning NOT_EXISTS since frontToken was cleared but lastAccessTokenUpdate exists"),[2,{status:"NOT_EXISTS"}]):[3,4];case 4:return n={status:"MAY_EXIST"},e?((0,d.logDebugMessage)("getLocalSessionState: trying to refresh"),[4,m(n)]):[3,7];case 5:return"RETRY"!==(r=o.sent()).result?((0,d.logDebugMessage)("getLocalSessionState: return NOT_EXISTS in case error from backend"+r.result),[2,{status:"NOT_EXISTS"}]):((0,d.logDebugMessage)("getLocalSessionState: Retrying post refresh"),[4,w(e)]);case 6:return[2,o.sent()];case 7:return(0,d.logDebugMessage)("getLocalSessionState: returning: "+n.status),[2,n]}}))}))}function S(e){switch(e){case"access":return"st-access-token";case"refresh":return"st-refresh-token"}}function T(e,t){var n=S(e);return""!==t?((0,d.logDebugMessage)("setToken: saved ".concat(e," token into cookies")),I(n,t,Date.now()+31536e5)):((0,d.logDebugMessage)("setToken: cleared ".concat(e," token from cookies")),I(n,t,0))}function I(e,t,n){var r="Fri, 31 Dec 9999 23:59:59 GMT";n!==Number.MAX_SAFE_INTEGER&&(r=new Date(n).toUTCString());var o=h.config.sessionTokenFrontendDomain;return"localhost"===o||o===c.default.getReferenceOrThrow().windowHandler.location.getHostName()?u.default.getReferenceOrThrow().cookieHandler.setCookie("".concat(e,"=").concat(t,";expires=").concat(r,";path=/;samesite=").concat(h.config.isInIframe?"none;secure":"lax")):u.default.getReferenceOrThrow().cookieHandler.setCookie("".concat(e,"=").concat(t,";expires=").concat(r,";domain=").concat(o,";path=/;samesite=").concat(h.config.isInIframe?"none;secure":"lax"))}function R(e){return o(this,void 0,void 0,(function(){return s(this,(function(t){return[2,D(S(e))]}))}))}function D(e){return o(this,void 0,void 0,(function(){var t,n,r,o;return s(this,(function(s){switch(s.label){case 0:return n="; ",[4,u.default.getReferenceOrThrow().cookieHandler.getCookie()];case 1:return t=n+s.sent(),(r=t.split("; "+e+"=")).length>=2&&void 0!==(o=r.pop())?[2,o.split(";").shift()]:[2,void 0]}}))}))}function E(e,t){return void 0===t&&(t=!1),o(this,void 0,void 0,(function(){var n,r;return s(this,(function(o){switch(o.label){case 0:return(0,d.logDebugMessage)("setTokenHeaders: adding existing tokens as header"),[4,R("access")];case 1:return n=o.sent(),[4,R("refresh")];case 2:return r=o.sent(),!t&&void 0===n||void 0===r?(0,d.logDebugMessage)("setAuthorizationHeaderIfRequired: token for header based auth not found"):e.has("Authorization")?(0,d.logDebugMessage)("setAuthorizationHeaderIfRequired: Authorization header defined by the user, not adding"):((0,d.logDebugMessage)("setAuthorizationHeaderIfRequired: added authorization header"),e.set("Authorization","Bearer ".concat(t?r:n))),[2]}}))}))}function x(e){return o(this,void 0,void 0,(function(){var t,n,r,o,i;return s(this,(function(s){switch(s.label){case 0:return(0,d.logDebugMessage)("saveTokensFromHeaders: Saving updated tokens from the response headers"),null===(t=e.headers.get("st-refresh-token"))?[3,2]:((0,d.logDebugMessage)("saveTokensFromHeaders: saving new refresh token"),[4,T("refresh",t)]);case 1:s.sent(),s.label=2;case 2:return null===(n=e.headers.get("st-access-token"))?[3,4]:((0,d.logDebugMessage)("saveTokensFromHeaders: saving new access token"),[4,T("access",n)]);case 3:s.sent(),s.label=4;case 4:return null===(r=e.headers.get("front-token"))?[3,6]:((0,d.logDebugMessage)("saveTokensFromHeaders: Setting sFrontToken: "+r),[4,g.setItem(r)]);case 5:s.sent(),s.label=6;case 6:return null===(o=e.headers.get("anti-csrf"))?[3,9]:[4,w(!0)];case 7:return"EXISTS"!==(i=s.sent()).status?[3,9]:((0,d.logDebugMessage)("saveTokensFromHeaders: Setting anti-csrf token"),[4,f.setItem(i.lastAccessTokenUpdate,o)]);case 8:s.sent(),s.label=9;case 9:return[2]}}))}))}function M(){return o(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return(0,d.logDebugMessage)("saveLastAccessTokenUpdate: called"),e=Date.now().toString(),(0,d.logDebugMessage)("saveLastAccessTokenUpdate: setting "+e),[4,I(p,e,Number.MAX_SAFE_INTEGER)];case 1:return t.sent(),[4,I("sIRTFrontend","",0)];case 2:return t.sent(),[2]}}))}))}function A(){return o(this,void 0,void 0,(function(){function e(){return o(this,void 0,void 0,(function(){var e,t,n,r,o;return s(this,(function(s){switch(s.label){case 0:return t="; ",[4,u.default.getReferenceOrThrow().cookieHandler.getCookie()];case 1:return e=t+s.sent(),(n=e.split("; sAntiCsrf=")).length>=2&&void 0!==(r=n.pop())?void 0===(o=r.split(";").shift())?[2,null]:[2,o]:[2,null]}}))}))}var t;return s(this,(function(n){switch(n.label){case 0:return(0,d.logDebugMessage)("getAntiCSRFToken: called"),[4,w(!0)];case 1:return"EXISTS"!==n.sent().status?((0,d.logDebugMessage)("getAntiCSRFToken: Returning because local session state != EXISTS"),[2,null]):[4,e()];case 2:return t=n.sent(),(0,d.logDebugMessage)("getAntiCSRFToken: returning: "+t),[2,t]}}))}))}function C(e){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return(0,d.logDebugMessage)("setAntiCSRF: called: "+e),void 0===e?[3,2]:[4,I(v,e,Number.MAX_SAFE_INTEGER)];case 1:return t.sent(),[3,4];case 2:return[4,I(v,"",0)];case 3:t.sent(),t.label=4;case 4:return[2]}}))}))}function _(){return o(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return(0,d.logDebugMessage)("getFrontTokenFromCookie: called"),[4,D(b)];case 1:return[2,void 0===(e=t.sent())?null:e]}}))}))}function O(e){return JSON.parse(decodeURIComponent(escape(atob(e))))}function P(){return o(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return(0,d.logDebugMessage)("getFrontToken: called"),[4,w(!0)];case 1:return"EXISTS"!==t.sent().status?((0,d.logDebugMessage)("getFrontToken: Returning because sIRTFrontend != EXISTS"),[2,null]):[4,_()];case 2:return e=t.sent(),(0,d.logDebugMessage)("getFrontToken: returning: "+e),[2,e]}}))}))}function F(e){return o(this,void 0,void 0,(function(){var t,n,r;return s(this,(function(o){switch(o.label){case 0:return(0,d.logDebugMessage)("setFrontToken: called"),[4,_()];case 1:return null!==(t=o.sent())&&void 0!==e&&(n=O(t).up,r=O(e).up,JSON.stringify(n)!==JSON.stringify(r)&&k()),void 0!==e?[3,3]:[4,I(b,"",0)];case 2:return o.sent(),[3,5];case 3:return[4,I(b,e,Number.MAX_SAFE_INTEGER)];case 4:o.sent(),o.label=5;case 5:return[2]}}))}))}function H(e,t,n){if(null!=n){var r="remove"!==n;(0,d.logDebugMessage)("fireSessionUpdateEventsIfNecessary wasLoggedIn: ".concat(e," frontTokenExistsAfter: ").concat(r," status: ").concat(t)),e?r||(t===h.config.sessionExpiredStatusCode?((0,d.logDebugMessage)("onUnauthorisedResponse: firing UNAUTHORISED event"),h.config.onHandleEvent({action:"UNAUTHORISED",sessionExpiredOrRevoked:!0,userContext:{}})):((0,d.logDebugMessage)("onUnauthorisedResponse: firing SIGN_OUT event"),h.config.onHandleEvent({action:"SIGN_OUT",userContext:{}}))):r&&((0,d.logDebugMessage)("onUnauthorisedResponse: firing SESSION_CREATED event"),h.config.onHandleEvent({action:"SESSION_CREATED",userContext:{}}))}else(0,d.logDebugMessage)("fireSessionUpdateEventsIfNecessary returning early because the front token was not updated")}t.onUnauthorisedResponse=m,t.onTokenUpdate=k,t.onInvalidClaimResponse=y,t.getLocalSessionState=w,t.getStorageNameForToken=S,t.setToken=T,t.getTokenForHeaderAuth=R,t.saveLastAccessTokenUpdate=M,t.setAntiCSRF=C,t.getFrontToken=P,t.setFrontToken=F,t.fireSessionUpdateEventsIfNecessary=H,t.updateClientClockUsingFrontToken=function(e){var t,n=e.frontToken,r=e.roundTripTime;if((0,d.logDebugMessage)("updateClientClockUsingFrontToken: frontToken: "+n+" roundTripTime: "+r),null!==n&&"remove"!==n){var o=null===(t=O(n).up)||void 0===t?void 0:t.iat;if(void 0!==o&&"number"==typeof o){var s=1e3*o+Math.floor(r/2)-Date.now();h.recipeImpl.updateClientClockDeviation(s),(0,d.logDebugMessage)("updateClientClockUsingFrontToken: Client clock synchronized successfully")}else(0,d.logDebugMessage)("updateClientClockUsingFrontToken: FrontToken iat is undefined or not a number, skipping update")}else(0,d.logDebugMessage)("updateClientClockUsingFrontToken: frontToken is either null or is being removed, skipping update")}},569:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{u(r.next(e))}catch(e){s(e)}}function a(e){try{u(r.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}u((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]{Object.defineProperty(t,"__esModule",{value:!0}),t.logDebugMessage=t.disableLogging=t.enableLogging=void 0;var r=n(255),o=!1;t.enableLogging=function(){o=!0},t.disableLogging=function(){o=!1},t.logDebugMessage=function(e){o&&console.log("".concat("com.supertokens",' {t: "').concat((new Date).toISOString(),'", message: "').concat(e,'", supertokens-website-ver: "').concat(r.package_version,'"}'))}},992:(e,t)=>{function n(e){return/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.isAnIpAddress=void 0,t.isAnIpAddress=n;function r(e,t){void 0===t&&(t=!1),e=e.trim();try{if(!e.startsWith("http://")&&!e.startsWith("https://"))throw new Error("converting to proper URL");var o=new URL(e);return t?o.hostname.startsWith("localhost")||n(o.hostname)?"http://"+o.host:"https://"+o.host:o.protocol+"//"+o.host}catch(e){}if(e.startsWith("/"))throw new Error("Please provide a valid domain name");if(0===e.indexOf(".")&&(e=e.substr(1)),(-1!==e.indexOf(".")||e.startsWith("localhost"))&&!e.startsWith("http://")&&!e.startsWith("https://")){e="https://"+e;try{return new URL(e),r(e,!0)}catch(e){}}throw new Error("Please provide a valid domain name")}t.default=function(e){var t=this;this.getAsStringDangerous=function(){return t.value},this.value=r(e)}},260:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});function n(e){e=e.trim();try{if(!e.startsWith("http://")&&!e.startsWith("https://"))throw new Error("converting to proper URL");return"/"===(e=new URL(e).pathname).charAt(e.length-1)?e.substr(0,e.length-1):e}catch(e){}if((function(e){if(-1===e.indexOf(".")||e.startsWith("/"))return!1;try{return-1!==new URL(e).hostname.indexOf(".")}catch(e){}try{return-1!==new URL("http://"+e).hostname.indexOf(".")}catch(e){}return!1}(e)||e.startsWith("localhost"))&&!e.startsWith("http://")&&!e.startsWith("https://"))return n(e="http://"+e);"/"!==e.charAt(0)&&(e="/"+e);try{return new URL("http://example.com"+e),n("http://example.com"+e)}catch(e){throw new Error("Please provide a valid URL path")}}t.default=function e(t){var r=this;this.startsWith=function(e){return r.value.startsWith(e.value)},this.appendPath=function(t){return new e(r.value+t.value)},this.getAsStringDangerous=function(){return r.value},this.value=n(t)}},743:function(e,t){var n,r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{u(r.next(e))}catch(e){s(e)}}function a(e){try{u(r.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}u((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]=0;n--)if(e.history[n]==t)return e.history[n]},this.reset=function(){e.history=[]},this.waitForEvent=function(t,n){return void 0===n&&(n=7e3),r(e,void 0,void 0,(function(){var e,r=this;return o(this,(function(o){return e=Date.now(),[2,new Promise((function(o){var s=r;!function r(){var i=s.getEventByLastEventByName(t);void 0===i?Date.now()-e>n?o(void 0):setTimeout(r,1e3):o(i)}()}))]}))}))}}return e.getInstance=function(){return null==e.instance&&(e.instance=new e),e.instance},e}();t.ProcessState=s},994:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]=300)throw r;return[4,e.postAPIHook({action:"SIGN_OUT",requestInit:n.requestInit,url:n.url,fetchResponse:r.clone(),userContext:t.userContext})];case 4:return s.sent(),[4,r.clone().json()];case 5:if("GENERAL_ERROR"===(o=s.sent()).status)throw(0,c.logDebugMessage)("doRequest: Throwing general error"),a=void 0===o.message?"No Error Message Provided":o.message,new l.STGeneralError(a);return[2]}}))}))},getInvalidClaimsFromResponse:function(e){return o(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return"body"in e.response?[4,e.response.clone().json()]:[3,2];case 1:return t=n.sent(),[3,3];case 2:t="string"==typeof e.response.data?JSON.parse(e.response.data):e.response.data,n.label=3;case 3:return[2,t.claimValidationErrors]}}))}))},getGlobalClaimValidators:function(e){return e.claimValidatorsAddedByOtherRecipes},validateClaims:function(e){return o(this,void 0,void 0,(function(){var t,n,r,o,i,a,u,c,l;return s(this,(function(s){switch(s.label){case 0:return[4,this.getAccessTokenPayloadSecurely({userContext:e.userContext})];case 1:t=s.sent(),n=0,r=e.claimValidators,s.label=2;case 2:return n1){var u=n.split(":")[n.split(":").length-1];"string"!=typeof(i=u)||isNaN(i)||isNaN(parseFloat(i))||(a+=":"+u,o=""===r.port?o:o+":"+r.port)}return n.startsWith(".")?("."+o).endsWith(a):o===a},updateClientClockDeviation:function(e){(0,c.logDebugMessage)("updateClientClockDeviation: clientClockDeviationInMillis: "+e),g.default.getReferenceOrThrow().dateProvider.setClientClockDeviationInMillis(e)}}}},272:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{u(r.next(e))}catch(e){s(e)}}function a(e){try{u(r.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}u((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]{Object.defineProperty(t,"__esModule",{value:!0}),t.CookieHandlerReference=void 0;var r=n(272),o=function(){function e(e){var t=function(e){return e};void 0!==e&&(t=e),this.cookieHandler=t(r.defaultCookieHandlerImplementation)}return e.init=function(t){void 0===e.instance&&(e.instance=new e(t))},e.getReferenceOrThrow=function(){if(void 0===e.instance)throw new Error("SuperTokensCookieHandler must be initialized before calling this method.");return e.instance},e}();t.CookieHandlerReference=o,t.default=o},812:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultDateProviderImplementation=void 0;var n=function(){function e(){this.clientClockDeviationInMillis=0}return e.prototype.setClientClockDeviationInMillis=function(e){this.clientClockDeviationInMillis=e},e.prototype.getClientClockDeviationInMills=function(){return this.clientClockDeviationInMillis},e.prototype.now=function(){return Date.now()+this.clientClockDeviationInMillis},e}();t.defaultDateProviderImplementation=new n},671:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DateProviderReference=void 0;var r=n(812),o=function(){function e(e){var t=function(e){return e};void 0!==e&&(t=e),this.dateProvider=t(r.defaultDateProviderImplementation)}return e.init=function(t){void 0===e.instance&&(e.instance=new e(t))},e.getReferenceOrThrow=function(){if(void 0===e.instance)throw new Error("SuperTokensDateProvider must be initialized before calling this method.");return e.instance},e}();t.DateProviderReference=o,t.default=o},318:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]{Object.defineProperty(t,"__esModule",{value:!0}),t.LockFactoryReference=void 0;var r=n(895),o=function(){function e(e){this.lockFactory=e}return e.init=function(t,n){void 0===this.instance&&(this.instance=new e(null!=t?t:function(e){return function(){return Promise.resolve(new r.default(e))}}(n)))},e.getReferenceOrThrow=function(){if(void 0===e.instance)throw new Error("SuperTokensLockReference must be initialized before calling this method.");return e.instance},e}();t.LockFactoryReference=o,t.default=o},153:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SessionClaimValidatorStore=void 0;var n=function(){function e(){}return e.claimValidatorsAddedByOtherRecipes=[],e.addClaimValidatorFromOtherRecipe=function(t){e.claimValidatorsAddedByOtherRecipes.push(t)},e.getClaimValidatorsAddedByOtherRecipes=function(){return e.claimValidatorsAddedByOtherRecipes},e}();t.SessionClaimValidatorStore=n,t.default=n},586:function(e,t){var n=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{u(r.next(e))}catch(e){s(e)}}function a(e){try{u(r.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}u((r=r.apply(e,t||[])).next())}))},r=this&&this.__generator||function(e,t){var n,r,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]{Object.defineProperty(t,"__esModule",{value:!0}),t.WindowHandlerReference=void 0;var r=n(586),o=function(){function e(e){var t=function(e){return e};void 0!==e&&(t=e),this.windowHandler=t(r.defaultWindowHandlerImplementation)}return e.init=function(t){void 0===e.instance&&(e.instance=new e(t))},e.getReferenceOrThrow=function(){if(void 0===e.instance)throw new Error("SuperTokensWindowHandler must be initialized before calling this method.");return e.instance},e}();t.WindowHandlerReference=o,t.default=o},255:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.supported_fdi=t.package_version=void 0,t.package_version="17.0.5",t.supported_fdi=["1.16","1.17","1.18"]},648:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{u(r.next(e))}catch(e){s(e)}}function a(e){try{u(r.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}u((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]0?setTimeout(n,t):n(null)}}window.addEventListener("storage",i),e.addToWaiting(i);var a=setTimeout(i,Math.max(0,t-Date.now()))}))];case 1:return n.sent(),[2]}}))}))},e.addToWaiting=function(t){this.removeFromWaiting(t),void 0!==e.waiters&&e.waiters.push(t)},e.removeFromWaiting=function(t){void 0!==e.waiters&&(e.waiters=e.waiters.filter((function(e){return e!==t})))},e.notifyWaiters=function(){void 0!==e.waiters&&e.waiters.slice().forEach((function(e){return e()}))},e.prototype.releaseLock=function(e){return r(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,this.releaseLock__private__(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.releaseLock__private__=function(t){return r(this,void 0,void 0,(function(){var n,r,s,c;return o(this,(function(o){switch(o.label){case 0:return n=void 0===this.storageHandler?u:this.storageHandler,r=a+"-"+t,null===(s=n.getItemSync(r))?[2]:(c=JSON.parse(s)).id!==this.id?[3,2]:[4,i.default().lock(c.iat)];case 1:o.sent(),this.acquiredIatSet.delete(c.iat),n.removeItemSync(r),i.default().unlock(c.iat),e.notifyWaiters(),o.label=2;case 2:return[2]}}))}))},e.lockCorrector=function(t){for(var n=Date.now()-5e3,r=t,o=[],s=0;;){var i=r.keySync(s);if(null===i)break;o.push(i),s++}for(var u=!1,c=0;c{Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(){var e=this;this.locked=new Map,this.addToLocked=function(t,n){var r=e.locked.get(t);void 0===r?void 0===n?e.locked.set(t,[]):e.locked.set(t,[n]):void 0!==n&&(r.unshift(n),e.locked.set(t,r))},this.isLocked=function(t){return e.locked.has(t)},this.lock=function(t){return new Promise((function(n,r){e.isLocked(t)?e.addToLocked(t,n):(e.addToLocked(t),n())}))},this.unlock=function(t){var n=e.locked.get(t);if(void 0!==n&&0!==n.length){var r=n.pop();e.locked.set(t,n),void 0!==r&&setTimeout(r,0)}else e.locked.delete(t)}}return e.getInstance=function(){return void 0===e.instance&&(e.instance=new e),e.instance},e}();t.default=function(){return n.getInstance()}},225:function(e,t){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n{Object.defineProperty(t,"__esModule",{value:!0}),t.OverrideableBuilder=void 0;var r=n(225),o=function(){function e(e){this.layers=[e],this.proxies=[]}return e.prototype.override=function(e){for(var t=(0,r.getProxyObject)(this.layers[0]),n=e(t,this),o=0,s=Object.keys(this.layers[0]);o=0;--o){var s=e.layers[o][n];if(null!=s)return s.bind(e.result).apply(void 0,r)}}},c=this,l=0;l maxAgeInSeconds) { return [ 2 /*return*/, @@ -207,6 +210,7 @@ var PrimitiveArrayClaim = /** @class */ (function () { if (maxAgeInSeconds === void 0) { maxAgeInSeconds = _this.defaultMaxAgeInSeconds; } + var DateProvider = dateProvider_1.default.getReferenceOrThrow().dateProvider; return { id: id !== undefined ? id : _this.id, refresh: function (ctx) { @@ -216,7 +220,8 @@ var PrimitiveArrayClaim = /** @class */ (function () { return ( _this.getValueFromPayload(payload, ctx) === undefined || // We know payload[this.id] is defined since the value is not undefined in this branch - (maxAgeInSeconds !== undefined && payload[_this.id].t < Date.now() - maxAgeInSeconds * 1000) + (maxAgeInSeconds !== undefined && + payload[_this.id].t < DateProvider.now() - maxAgeInSeconds * 1000) ); }, validate: function (payload, ctx) { @@ -237,7 +242,7 @@ var PrimitiveArrayClaim = /** @class */ (function () { } ]; } - ageInSeconds = (Date.now() - this.getLastFetchedTime(payload, ctx)) / 1000; + ageInSeconds = (DateProvider.now() - this.getLastFetchedTime(payload, ctx)) / 1000; if (maxAgeInSeconds !== undefined && ageInSeconds > maxAgeInSeconds) { return [ 2 /*return*/, @@ -274,6 +279,7 @@ var PrimitiveArrayClaim = /** @class */ (function () { if (maxAgeInSeconds === void 0) { maxAgeInSeconds = _this.defaultMaxAgeInSeconds; } + var DateProvider = dateProvider_1.default.getReferenceOrThrow().dateProvider; return { id: id !== undefined ? id : _this.id, refresh: function (ctx) { @@ -283,7 +289,8 @@ var PrimitiveArrayClaim = /** @class */ (function () { return ( _this.getValueFromPayload(payload, ctx) === undefined || // We know payload[this.id] is defined since the value is not undefined in this branch - (maxAgeInSeconds !== undefined && payload[_this.id].t < Date.now() - maxAgeInSeconds * 1000) + (maxAgeInSeconds !== undefined && + payload[_this.id].t < DateProvider.now() - maxAgeInSeconds * 1000) ); }, validate: function (payload, ctx) { @@ -304,7 +311,7 @@ var PrimitiveArrayClaim = /** @class */ (function () { } ]; } - ageInSeconds = (Date.now() - this.getLastFetchedTime(payload, ctx)) / 1000; + ageInSeconds = (DateProvider.now() - this.getLastFetchedTime(payload, ctx)) / 1000; if (maxAgeInSeconds !== undefined && ageInSeconds > maxAgeInSeconds) { return [ 2 /*return*/, @@ -344,6 +351,7 @@ var PrimitiveArrayClaim = /** @class */ (function () { if (maxAgeInSeconds === void 0) { maxAgeInSeconds = _this.defaultMaxAgeInSeconds; } + var DateProvider = dateProvider_1.default.getReferenceOrThrow().dateProvider; return { id: id !== undefined ? id : _this.id, refresh: function (ctx) { @@ -353,7 +361,8 @@ var PrimitiveArrayClaim = /** @class */ (function () { return ( _this.getValueFromPayload(payload, ctx) === undefined || // We know payload[this.id] is defined since the value is not undefined in this branch - (maxAgeInSeconds !== undefined && payload[_this.id].t < Date.now() - maxAgeInSeconds * 1000) + (maxAgeInSeconds !== undefined && + payload[_this.id].t < DateProvider.now() - maxAgeInSeconds * 1000) ); }, validate: function (payload, ctx) { @@ -374,7 +383,7 @@ var PrimitiveArrayClaim = /** @class */ (function () { } ]; } - ageInSeconds = (Date.now() - this.getLastFetchedTime(payload, ctx)) / 1000; + ageInSeconds = (DateProvider.now() - this.getLastFetchedTime(payload, ctx)) / 1000; if (maxAgeInSeconds !== undefined && ageInSeconds > maxAgeInSeconds) { return [ 2 /*return*/, @@ -414,6 +423,7 @@ var PrimitiveArrayClaim = /** @class */ (function () { if (maxAgeInSeconds === void 0) { maxAgeInSeconds = _this.defaultMaxAgeInSeconds; } + var DateProvider = dateProvider_1.default.getReferenceOrThrow().dateProvider; return { id: id !== undefined ? id : _this.id, refresh: function (ctx) { @@ -423,7 +433,8 @@ var PrimitiveArrayClaim = /** @class */ (function () { return ( _this.getValueFromPayload(payload, ctx) === undefined || // We know payload[this.id] is defined since the value is not undefined in this branch - (maxAgeInSeconds !== undefined && payload[_this.id].t < Date.now() - maxAgeInSeconds * 1000) + (maxAgeInSeconds !== undefined && + payload[_this.id].t < DateProvider.now() - maxAgeInSeconds * 1000) ); }, validate: function (payload, ctx) { @@ -444,7 +455,7 @@ var PrimitiveArrayClaim = /** @class */ (function () { } ]; } - ageInSeconds = (Date.now() - this.getLastFetchedTime(payload, ctx)) / 1000; + ageInSeconds = (DateProvider.now() - this.getLastFetchedTime(payload, ctx)) / 1000; if (maxAgeInSeconds !== undefined && ageInSeconds > maxAgeInSeconds) { return [ 2 /*return*/, diff --git a/lib/build/claims/primitiveClaim.js b/lib/build/claims/primitiveClaim.js index 1c87679c..c84d9f2b 100644 --- a/lib/build/claims/primitiveClaim.js +++ b/lib/build/claims/primitiveClaim.js @@ -1,6 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PrimitiveClaim = void 0; +var dateProvider_1 = require("../utils/dateProvider"); var PrimitiveClaim = /** @class */ (function () { function PrimitiveClaim(config) { var _this = this; @@ -9,6 +10,7 @@ var PrimitiveClaim = /** @class */ (function () { if (maxAgeInSeconds === void 0) { maxAgeInSeconds = _this.defaultMaxAgeInSeconds; } + var DateProvider = dateProvider_1.default.getReferenceOrThrow().dateProvider; return { id: id !== undefined ? id : _this.id, refresh: function (ctx) { @@ -18,7 +20,8 @@ var PrimitiveClaim = /** @class */ (function () { return ( _this.getValueFromPayload(payload, ctx) === undefined || // We know payload[this.id] is defined since the value is not undefined in this branch - (maxAgeInSeconds !== undefined && payload[_this.id].t < Date.now() - maxAgeInSeconds * 1000) + (maxAgeInSeconds !== undefined && + payload[_this.id].t < DateProvider.now() - maxAgeInSeconds * 1000) ); }, validate: function (payload, ctx) { @@ -29,7 +32,7 @@ var PrimitiveClaim = /** @class */ (function () { reason: { message: "value does not exist", expectedValue: val, actualValue: claimVal } }; } - var ageInSeconds = (Date.now() - _this.getLastFetchedTime(payload, ctx)) / 1000; + var ageInSeconds = (DateProvider.now() - _this.getLastFetchedTime(payload, ctx)) / 1000; if (maxAgeInSeconds !== undefined && ageInSeconds > maxAgeInSeconds) { return { isValid: false, diff --git a/lib/build/fetch.d.ts b/lib/build/fetch.d.ts index 713a2a24..207fe36c 100644 --- a/lib/build/fetch.d.ts +++ b/lib/build/fetch.d.ts @@ -64,3 +64,14 @@ export declare function setAntiCSRF(antiCSRFToken: string | undefined): Promise< export declare function getFrontToken(): Promise; export declare function setFrontToken(frontToken: string | undefined): Promise; export declare function fireSessionUpdateEventsIfNecessary(wasLoggedIn: boolean, status: number, frontTokenHeaderFromResponse: string | null | undefined): void; +/** + * Updates the client clock deviation based on the provided frontToken and round-trip time. + * + * @param {Object} params - The parameters for updating the client clock deviation. + * @param {string | null} params.frontToken - The frontToken containing issued timestamp. + * @param {number} params.roundTripTime - The round-trip time between the client and server. + */ +export declare const updateClientClockUsingFrontToken: ({ frontToken, roundTripTime }: { + frontToken: string | null; + roundTripTime: number; +}) => void; diff --git a/lib/build/fetch.js b/lib/build/fetch.js index 542fef50..895b6458 100644 --- a/lib/build/fetch.js +++ b/lib/build/fetch.js @@ -145,7 +145,8 @@ var __generator = } }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.fireSessionUpdateEventsIfNecessary = +exports.updateClientClockUsingFrontToken = + exports.fireSessionUpdateEventsIfNecessary = exports.setFrontToken = exports.getFrontToken = exports.setAntiCSRF = @@ -452,7 +453,10 @@ var AuthHttpRequest = /** @class */ (function () { configWithAntiCsrf, antiCsrfToken, transferMethod, + clientTimeBeforeRequest, response, + clientTimeAfterRequest, + frontToken, retry, postRequestIdToken; return __generator(_a, function (_b) { @@ -579,17 +583,24 @@ var AuthHttpRequest = /** @class */ (function () { case 11: _b.sent(); (0, logger_1.logDebugMessage)("doRequest: Making user's http call"); + clientTimeBeforeRequest = Date.now(); return [4 /*yield*/, httpCall(configWithAntiCsrf)]; case 12: response = _b.sent(); + clientTimeAfterRequest = Date.now(); (0, logger_1.logDebugMessage)("doRequest: User's http call ended"); return [4 /*yield*/, saveTokensFromHeaders(response)]; case 13: _b.sent(); + frontToken = response.headers.get("front-token"); + (0, exports.updateClientClockUsingFrontToken)({ + frontToken: frontToken, + roundTripTime: clientTimeAfterRequest - clientTimeBeforeRequest + }); fireSessionUpdateEventsIfNecessary( preRequestLSS.status === "EXISTS", response.status, - response.headers.get("front-token") + frontToken ); if (!(response.status === AuthHttpRequest.config.sessionExpiredStatusCode)) return [3 /*break*/, 15]; @@ -1413,3 +1424,36 @@ function fireSessionUpdateEventsIfNecessary(wasLoggedIn, status, frontTokenHeade } } exports.fireSessionUpdateEventsIfNecessary = fireSessionUpdateEventsIfNecessary; +/** + * Updates the client clock deviation based on the provided frontToken and round-trip time. + * + * @param {Object} params - The parameters for updating the client clock deviation. + * @param {string | null} params.frontToken - The frontToken containing issued timestamp. + * @param {number} params.roundTripTime - The round-trip time between the client and server. + */ +var updateClientClockUsingFrontToken = function (_b) { + var _c; + var frontToken = _b.frontToken, + roundTripTime = _b.roundTripTime; + (0, logger_1.logDebugMessage)( + "updateClientClockUsingFrontToken: frontToken: " + frontToken + " roundTripTime: " + roundTripTime + ); + if (frontToken === null || frontToken === "remove") { + (0, logger_1.logDebugMessage)( + "updateClientClockUsingFrontToken: frontToken is either null or is being removed, skipping update" + ); + return; + } + var tokenIssuedAt = (_c = parseFrontToken(frontToken).up) === null || _c === void 0 ? void 0 : _c.iat; + if (tokenIssuedAt === undefined || typeof tokenIssuedAt !== "number") { + (0, logger_1.logDebugMessage)( + "updateClientClockUsingFrontToken: FrontToken iat is undefined or not a number, skipping update" + ); + return; + } + var estimatedServerTimeNow = tokenIssuedAt * 1000 + Math.floor(roundTripTime / 2); + var clientClockDeviationInMillis = estimatedServerTimeNow - Date.now(); + AuthHttpRequest.recipeImpl.updateClientClockDeviation(clientClockDeviationInMillis); + (0, logger_1.logDebugMessage)("updateClientClockUsingFrontToken: Client clock synchronized successfully"); +}; +exports.updateClientClockUsingFrontToken = updateClientClockUsingFrontToken; diff --git a/lib/build/recipeImplementation.js b/lib/build/recipeImplementation.js index 49f8bcd7..a0e04708 100644 --- a/lib/build/recipeImplementation.js +++ b/lib/build/recipeImplementation.js @@ -152,6 +152,7 @@ var logger_1 = require("./logger"); var error_1 = require("./error"); var xmlhttprequest_1 = require("./xmlhttprequest"); var utils_1 = require("./utils"); +var dateProvider_1 = require("./utils/dateProvider"); function RecipeImplementation(recipeImplInput) { return { addXMLHttpRequestInterceptor: function (_) { @@ -535,6 +536,14 @@ function RecipeImplementation(recipeImplInput) { return domain === normalisedsessionDomain; } } + }, + updateClientClockDeviation: function (clientClockDeviationInMillis) { + (0, logger_1.logDebugMessage)( + "updateClientClockDeviation: clientClockDeviationInMillis: " + clientClockDeviationInMillis + ); + dateProvider_1.default + .getReferenceOrThrow() + .dateProvider.setClientClockDeviationInMillis(clientClockDeviationInMillis); } }; } diff --git a/lib/build/types.d.ts b/lib/build/types.d.ts index 1ef7c721..3e4e5e7c 100644 --- a/lib/build/types.d.ts +++ b/lib/build/types.d.ts @@ -123,6 +123,7 @@ export declare type RecipeInterface = { userContext: any; }): SessionClaimValidator[]; shouldDoInterceptionBasedOnUrl(toCheckUrl: string, apiDomain: string, sessionTokenBackendDomain: string | undefined): boolean; + updateClientClockDeviation(clientClockDeviationInMillis: number): void; }; export declare type ClaimValidationResult = { isValid: true; diff --git a/lib/build/utils/dateProvider/defaultImplementation.d.ts b/lib/build/utils/dateProvider/defaultImplementation.d.ts new file mode 100644 index 00000000..7437f1ef --- /dev/null +++ b/lib/build/utils/dateProvider/defaultImplementation.d.ts @@ -0,0 +1,8 @@ +declare class DateProvider { + private clientClockDeviationInMillis; + setClientClockDeviationInMillis(deviation: number): void; + getClientClockDeviationInMills(): number; + now(): number; +} +export declare const defaultDateProviderImplementation: DateProvider; +export {}; diff --git a/lib/build/utils/dateProvider/defaultImplementation.js b/lib/build/utils/dateProvider/defaultImplementation.js new file mode 100644 index 00000000..a49f9a50 --- /dev/null +++ b/lib/build/utils/dateProvider/defaultImplementation.js @@ -0,0 +1,33 @@ +"use strict"; +/* Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.defaultDateProviderImplementation = void 0; +var DateProvider = /** @class */ (function () { + function DateProvider() { + this.clientClockDeviationInMillis = 0; + } + DateProvider.prototype.setClientClockDeviationInMillis = function (deviation) { + this.clientClockDeviationInMillis = deviation; + }; + DateProvider.prototype.getClientClockDeviationInMills = function () { + return this.clientClockDeviationInMillis; + }; + DateProvider.prototype.now = function () { + return Date.now() + this.clientClockDeviationInMillis; + }; + return DateProvider; +})(); +exports.defaultDateProviderImplementation = new DateProvider(); diff --git a/lib/build/utils/dateProvider/index.d.ts b/lib/build/utils/dateProvider/index.d.ts new file mode 100644 index 00000000..b6b4a456 --- /dev/null +++ b/lib/build/utils/dateProvider/index.d.ts @@ -0,0 +1,16 @@ +import { DateProviderInterface, DateProviderInput } from "./types"; +/** + * A utility class for managing a reference to a DateProviderInterface, allowing customization of time-related operations. + * This class is designed to address clock skew issues between the server and client by providing a consistent mechanism + * for obtaining current time with the serverClockDeviation. + * + * @class DateProviderReference + */ +export default class DateProviderReference { + private static instance?; + dateProvider: DateProviderInterface; + constructor(dateProviderInput?: DateProviderInput); + static init(dateProviderInput?: DateProviderInput): void; + static getReferenceOrThrow(): DateProviderReference; +} +export { DateProviderReference }; diff --git a/lib/build/utils/dateProvider/index.js b/lib/build/utils/dateProvider/index.js new file mode 100644 index 00000000..e3f9e863 --- /dev/null +++ b/lib/build/utils/dateProvider/index.js @@ -0,0 +1,51 @@ +"use strict"; +/* Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DateProviderReference = void 0; +var defaultImplementation_1 = require("./defaultImplementation"); +/** + * A utility class for managing a reference to a DateProviderInterface, allowing customization of time-related operations. + * This class is designed to address clock skew issues between the server and client by providing a consistent mechanism + * for obtaining current time with the serverClockDeviation. + * + * @class DateProviderReference + */ +var DateProviderReference = /** @class */ (function () { + function DateProviderReference(dateProviderInput) { + var dateProviderFunc = function (original) { + return original; + }; + if (dateProviderInput !== undefined) { + dateProviderFunc = dateProviderInput; + } + this.dateProvider = dateProviderFunc(defaultImplementation_1.defaultDateProviderImplementation); + } + DateProviderReference.init = function (dateProviderInput) { + if (DateProviderReference.instance !== undefined) { + return; + } + DateProviderReference.instance = new DateProviderReference(dateProviderInput); + }; + DateProviderReference.getReferenceOrThrow = function () { + if (DateProviderReference.instance === undefined) { + throw new Error("SuperTokensDateProvider must be initialized before calling this method."); + } + return DateProviderReference.instance; + }; + return DateProviderReference; +})(); +exports.DateProviderReference = DateProviderReference; +exports.default = DateProviderReference; diff --git a/lib/build/utils/dateProvider/types.d.ts b/lib/build/utils/dateProvider/types.d.ts new file mode 100644 index 00000000..0dfc8c82 --- /dev/null +++ b/lib/build/utils/dateProvider/types.d.ts @@ -0,0 +1,6 @@ +export interface DateProviderInterface { + now(): number; + setClientClockDeviationInMillis(deviation: number): void; + getClientClockDeviationInMills(): number; +} +export declare type DateProviderInput = (original: DateProviderInterface) => DateProviderInterface; diff --git a/lib/build/utils/dateProvider/types.js b/lib/build/utils/dateProvider/types.js new file mode 100644 index 00000000..9f123731 --- /dev/null +++ b/lib/build/utils/dateProvider/types.js @@ -0,0 +1,16 @@ +"use strict"; +/* Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/lib/ts/claims/primitiveArrayClaim.ts b/lib/ts/claims/primitiveArrayClaim.ts index a6f53d4e..f245a331 100644 --- a/lib/ts/claims/primitiveArrayClaim.ts +++ b/lib/ts/claims/primitiveArrayClaim.ts @@ -1,4 +1,5 @@ import { SessionClaimValidator } from "../types"; +import DateProviderReference from "../utils/dateProvider"; export type PrimitiveArrayClaimConfig = { id: string; @@ -31,13 +32,14 @@ export class PrimitiveArrayClaim { maxAgeInSeconds: number | undefined = this.defaultMaxAgeInSeconds, id?: string ): SessionClaimValidator => { + const DateProvider = DateProviderReference.getReferenceOrThrow().dateProvider; return { id: id !== undefined ? id : this.id, refresh: ctx => this.refresh(ctx), shouldRefresh: (payload, ctx) => this.getValueFromPayload(payload, ctx) === undefined || // We know payload[this.id] is defined since the value is not undefined in this branch - (maxAgeInSeconds !== undefined && payload[this.id].t < Date.now() - maxAgeInSeconds * 1000), + (maxAgeInSeconds !== undefined && payload[this.id].t < DateProvider.now() - maxAgeInSeconds * 1000), validate: async (payload, ctx) => { const claimVal = this.getValueFromPayload(payload, ctx); if (claimVal === undefined) { @@ -46,7 +48,7 @@ export class PrimitiveArrayClaim { reason: { message: "value does not exist", expectedToInclude: val, actualValue: claimVal } }; } - const ageInSeconds = (Date.now() - this.getLastFetchedTime(payload, ctx)!) / 1000; + const ageInSeconds = (DateProvider.now() - this.getLastFetchedTime(payload, ctx)!) / 1000; if (maxAgeInSeconds !== undefined && ageInSeconds > maxAgeInSeconds) { return { isValid: false, @@ -72,13 +74,14 @@ export class PrimitiveArrayClaim { maxAgeInSeconds: number | undefined = this.defaultMaxAgeInSeconds, id?: string ): SessionClaimValidator => { + const DateProvider = DateProviderReference.getReferenceOrThrow().dateProvider; return { id: id !== undefined ? id : this.id, refresh: ctx => this.refresh(ctx), shouldRefresh: (payload, ctx) => this.getValueFromPayload(payload, ctx) === undefined || // We know payload[this.id] is defined since the value is not undefined in this branch - (maxAgeInSeconds !== undefined && payload[this.id].t < Date.now() - maxAgeInSeconds * 1000), + (maxAgeInSeconds !== undefined && payload[this.id].t < DateProvider.now() - maxAgeInSeconds * 1000), validate: async (payload, ctx) => { const claimVal = this.getValueFromPayload(payload, ctx); if (claimVal === undefined) { @@ -91,7 +94,7 @@ export class PrimitiveArrayClaim { } }; } - const ageInSeconds = (Date.now() - this.getLastFetchedTime(payload, ctx)!) / 1000; + const ageInSeconds = (DateProvider.now() - this.getLastFetchedTime(payload, ctx)!) / 1000; if (maxAgeInSeconds !== undefined && ageInSeconds > maxAgeInSeconds) { return { isValid: false, @@ -117,13 +120,14 @@ export class PrimitiveArrayClaim { maxAgeInSeconds: number | undefined = this.defaultMaxAgeInSeconds, id?: string ): SessionClaimValidator => { + const DateProvider = DateProviderReference.getReferenceOrThrow().dateProvider; return { id: id !== undefined ? id : this.id, refresh: ctx => this.refresh(ctx), shouldRefresh: (payload, ctx) => this.getValueFromPayload(payload, ctx) === undefined || // We know payload[this.id] is defined since the value is not undefined in this branch - (maxAgeInSeconds !== undefined && payload[this.id].t < Date.now() - maxAgeInSeconds * 1000), + (maxAgeInSeconds !== undefined && payload[this.id].t < DateProvider.now() - maxAgeInSeconds * 1000), validate: async (payload, ctx) => { const claimVal = this.getValueFromPayload(payload, ctx); if (claimVal === undefined) { @@ -132,7 +136,7 @@ export class PrimitiveArrayClaim { reason: { message: "value does not exist", expectedToInclude: val, actualValue: claimVal } }; } - const ageInSeconds = (Date.now() - this.getLastFetchedTime(payload, ctx)!) / 1000; + const ageInSeconds = (DateProvider.now() - this.getLastFetchedTime(payload, ctx)!) / 1000; if (maxAgeInSeconds !== undefined && ageInSeconds > maxAgeInSeconds) { return { isValid: false, @@ -159,13 +163,14 @@ export class PrimitiveArrayClaim { maxAgeInSeconds: number | undefined = this.defaultMaxAgeInSeconds, id?: string ): SessionClaimValidator => { + const DateProvider = DateProviderReference.getReferenceOrThrow().dateProvider; return { id: id !== undefined ? id : this.id, refresh: ctx => this.refresh(ctx), shouldRefresh: (payload, ctx) => this.getValueFromPayload(payload, ctx) === undefined || // We know payload[this.id] is defined since the value is not undefined in this branch - (maxAgeInSeconds !== undefined && payload[this.id].t < Date.now() - maxAgeInSeconds * 1000), + (maxAgeInSeconds !== undefined && payload[this.id].t < DateProvider.now() - maxAgeInSeconds * 1000), validate: async (payload, ctx) => { const claimVal = this.getValueFromPayload(payload, ctx); if (claimVal === undefined) { @@ -174,7 +179,7 @@ export class PrimitiveArrayClaim { reason: { message: "value does not exist", expectedToInclude: val, actualValue: claimVal } }; } - const ageInSeconds = (Date.now() - this.getLastFetchedTime(payload, ctx)!) / 1000; + const ageInSeconds = (DateProvider.now() - this.getLastFetchedTime(payload, ctx)!) / 1000; if (maxAgeInSeconds !== undefined && ageInSeconds > maxAgeInSeconds) { return { isValid: false, @@ -205,13 +210,14 @@ export class PrimitiveArrayClaim { maxAgeInSeconds: number | undefined = this.defaultMaxAgeInSeconds, id?: string ): SessionClaimValidator => { + const DateProvider = DateProviderReference.getReferenceOrThrow().dateProvider; return { id: id !== undefined ? id : this.id, refresh: ctx => this.refresh(ctx), shouldRefresh: (payload, ctx) => this.getValueFromPayload(payload, ctx) === undefined || // We know payload[this.id] is defined since the value is not undefined in this branch - (maxAgeInSeconds !== undefined && payload[this.id].t < Date.now() - maxAgeInSeconds * 1000), + (maxAgeInSeconds !== undefined && payload[this.id].t < DateProvider.now() - maxAgeInSeconds * 1000), validate: async (payload, ctx) => { const claimVal = this.getValueFromPayload(payload, ctx); if (claimVal === undefined) { @@ -225,7 +231,7 @@ export class PrimitiveArrayClaim { }; } - const ageInSeconds = (Date.now() - this.getLastFetchedTime(payload, ctx)!) / 1000; + const ageInSeconds = (DateProvider.now() - this.getLastFetchedTime(payload, ctx)!) / 1000; if (maxAgeInSeconds !== undefined && ageInSeconds > maxAgeInSeconds) { return { isValid: false, diff --git a/lib/ts/claims/primitiveClaim.ts b/lib/ts/claims/primitiveClaim.ts index 4a444114..02b32e12 100644 --- a/lib/ts/claims/primitiveClaim.ts +++ b/lib/ts/claims/primitiveClaim.ts @@ -1,4 +1,5 @@ import { SessionClaimValidator } from "../types"; +import DateProviderReference from "../utils/dateProvider"; export type PrimitiveClaimConfig = { id: string; @@ -31,13 +32,14 @@ export class PrimitiveClaim { maxAgeInSeconds: number | undefined = this.defaultMaxAgeInSeconds, id?: string ): SessionClaimValidator => { + const DateProvider = DateProviderReference.getReferenceOrThrow().dateProvider; return { id: id !== undefined ? id : this.id, refresh: ctx => this.refresh(ctx), shouldRefresh: (payload, ctx) => this.getValueFromPayload(payload, ctx) === undefined || // We know payload[this.id] is defined since the value is not undefined in this branch - (maxAgeInSeconds !== undefined && payload[this.id].t < Date.now() - maxAgeInSeconds * 1000), + (maxAgeInSeconds !== undefined && payload[this.id].t < DateProvider.now() - maxAgeInSeconds * 1000), validate: (payload, ctx) => { const claimVal = this.getValueFromPayload(payload, ctx); if (claimVal === undefined) { @@ -47,7 +49,7 @@ export class PrimitiveClaim { }; } - const ageInSeconds = (Date.now() - this.getLastFetchedTime(payload, ctx)!) / 1000; + const ageInSeconds = (DateProvider.now() - this.getLastFetchedTime(payload, ctx)!) / 1000; if (maxAgeInSeconds !== undefined && ageInSeconds > maxAgeInSeconds) { return { isValid: false, diff --git a/lib/ts/fetch.ts b/lib/ts/fetch.ts index b3472cc1..a103c9d2 100644 --- a/lib/ts/fetch.ts +++ b/lib/ts/fetch.ts @@ -327,16 +327,21 @@ export default class AuthHttpRequest { await setAuthorizationHeaderIfRequired(clonedHeaders); logDebugMessage("doRequest: Making user's http call"); + const clientTimeBeforeRequest = Date.now(); let response = await httpCall(configWithAntiCsrf); + const clientTimeAfterRequest = Date.now(); logDebugMessage("doRequest: User's http call ended"); await saveTokensFromHeaders(response); - fireSessionUpdateEventsIfNecessary( - preRequestLSS.status === "EXISTS", - response.status, - response.headers.get("front-token") - ); + const frontToken = response.headers.get("front-token"); + + updateClientClockUsingFrontToken({ + frontToken, + roundTripTime: clientTimeAfterRequest - clientTimeBeforeRequest + }); + + fireSessionUpdateEventsIfNecessary(preRequestLSS.status === "EXISTS", response.status, frontToken); if (response.status === AuthHttpRequest.config.sessionExpiredStatusCode) { logDebugMessage("doRequest: Status code is: " + response.status); @@ -926,3 +931,43 @@ export function fireSessionUpdateEventsIfNecessary( }); } } + +/** + * Updates the client clock deviation based on the provided frontToken and round-trip time. + * + * @param {Object} params - The parameters for updating the client clock deviation. + * @param {string | null} params.frontToken - The frontToken containing issued timestamp. + * @param {number} params.roundTripTime - The round-trip time between the client and server. + */ +export const updateClientClockUsingFrontToken = ({ + frontToken, + roundTripTime +}: { + frontToken: string | null; + roundTripTime: number; +}): void => { + logDebugMessage("updateClientClockUsingFrontToken: frontToken: " + frontToken + " roundTripTime: " + roundTripTime); + + if (frontToken === null || frontToken === "remove") { + logDebugMessage( + "updateClientClockUsingFrontToken: frontToken is either null or is being removed, skipping update" + ); + return; + } + + const tokenIssuedAt = parseFrontToken(frontToken).up?.iat; + + if (tokenIssuedAt === undefined || typeof tokenIssuedAt !== "number") { + logDebugMessage( + "updateClientClockUsingFrontToken: FrontToken iat is undefined or not a number, skipping update" + ); + return; + } + + const estimatedServerTimeNow = tokenIssuedAt * 1000 + Math.floor(roundTripTime / 2); + const clientClockDeviationInMillis = estimatedServerTimeNow - Date.now(); + + AuthHttpRequest.recipeImpl.updateClientClockDeviation(clientClockDeviationInMillis); + + logDebugMessage("updateClientClockUsingFrontToken: Client clock synchronized successfully"); +}; diff --git a/lib/ts/recipeImplementation.ts b/lib/ts/recipeImplementation.ts index 76625ad0..42281ba3 100644 --- a/lib/ts/recipeImplementation.ts +++ b/lib/ts/recipeImplementation.ts @@ -14,6 +14,7 @@ import { logDebugMessage } from "./logger"; import { STGeneralError } from "./error"; import { addInterceptorsToXMLHttpRequest } from "./xmlhttprequest"; import { normaliseSessionScopeOrThrowError, normaliseURLDomainOrThrowError } from "./utils"; +import DateProviderReference from "./utils/dateProvider"; export default function RecipeImplementation(recipeImplInput: { preAPIHook: RecipePreAPIHookFunction; @@ -308,6 +309,16 @@ export default function RecipeImplementation(recipeImplInput: { return domain === normalisedsessionDomain; } } + }, + + updateClientClockDeviation: function (clientClockDeviationInMillis: number): void { + logDebugMessage( + "updateClientClockDeviation: clientClockDeviationInMillis: " + clientClockDeviationInMillis + ); + + DateProviderReference.getReferenceOrThrow().dateProvider.setClientClockDeviationInMillis( + clientClockDeviationInMillis + ); } }; } diff --git a/lib/ts/types.ts b/lib/ts/types.ts index 9c6cea43..4fe18b11 100644 --- a/lib/ts/types.ts +++ b/lib/ts/types.ts @@ -150,6 +150,8 @@ export type RecipeInterface = { apiDomain: string, sessionTokenBackendDomain: string | undefined ): boolean; + + updateClientClockDeviation(clientClockDeviationInMillis: number): void; }; export type ClaimValidationResult = { isValid: true } | { isValid: false; reason?: any }; diff --git a/lib/ts/utils/dateProvider/defaultImplementation.ts b/lib/ts/utils/dateProvider/defaultImplementation.ts new file mode 100644 index 00000000..97a309c9 --- /dev/null +++ b/lib/ts/utils/dateProvider/defaultImplementation.ts @@ -0,0 +1,32 @@ +/* Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +class DateProvider { + private clientClockDeviationInMillis: number = 0; + + setClientClockDeviationInMillis(deviation: number): void { + this.clientClockDeviationInMillis = deviation; + } + + getClientClockDeviationInMills(): number { + return this.clientClockDeviationInMillis; + } + + now(): number { + return Date.now() + this.clientClockDeviationInMillis; + } +} + +export const defaultDateProviderImplementation = new DateProvider(); diff --git a/lib/ts/utils/dateProvider/index.ts b/lib/ts/utils/dateProvider/index.ts new file mode 100644 index 00000000..9402716a --- /dev/null +++ b/lib/ts/utils/dateProvider/index.ts @@ -0,0 +1,57 @@ +/* Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +import { defaultDateProviderImplementation } from "./defaultImplementation"; +import { DateProviderInterface, DateProviderInput } from "./types"; + +/** + * A utility class for managing a reference to a DateProviderInterface, allowing customization of time-related operations. + * This class is designed to address clock skew issues between the server and client by providing a consistent mechanism + * for obtaining current time with the serverClockDeviation. + * + * @class DateProviderReference + */ +export default class DateProviderReference { + private static instance?: DateProviderReference; + + dateProvider: DateProviderInterface; + + constructor(dateProviderInput?: DateProviderInput) { + let dateProviderFunc: DateProviderInput = original => original; + if (dateProviderInput !== undefined) { + dateProviderFunc = dateProviderInput; + } + + this.dateProvider = dateProviderFunc(defaultDateProviderImplementation); + } + + static init(dateProviderInput?: DateProviderInput): void { + if (DateProviderReference.instance !== undefined) { + return; + } + + DateProviderReference.instance = new DateProviderReference(dateProviderInput); + } + + static getReferenceOrThrow(): DateProviderReference { + if (DateProviderReference.instance === undefined) { + throw new Error("SuperTokensDateProvider must be initialized before calling this method."); + } + + return DateProviderReference.instance; + } +} + +export { DateProviderReference }; diff --git a/lib/ts/utils/dateProvider/types.ts b/lib/ts/utils/dateProvider/types.ts new file mode 100644 index 00000000..2661d9f5 --- /dev/null +++ b/lib/ts/utils/dateProvider/types.ts @@ -0,0 +1,22 @@ +/* Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +export interface DateProviderInterface { + now(): number; + setClientClockDeviationInMillis(deviation: number): void; + getClientClockDeviationInMills(): number; +} + +export type DateProviderInput = (original: DateProviderInterface) => DateProviderInterface; diff --git a/test/sessionClaimValidatorRefresh.test.js b/test/sessionClaimValidatorRefresh.test.js new file mode 100644 index 00000000..26a2fe2a --- /dev/null +++ b/test/sessionClaimValidatorRefresh.test.js @@ -0,0 +1,129 @@ +/* Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +const assert = require("assert"); +const sinon = require("sinon"); +const { BooleanClaim } = require("../lib/build"); +const { DateProviderReference } = require("../lib/build/utils/dateProvider"); + +const ONE_HOUR_IN_MS = 3600000; + +function withFakeClock(now, cb) { + const clock = sinon.useFakeTimers({ now, shouldAdvanceTime: false }); + + try { + return cb(); + } finally { + clock.restore(); + } +} + +describe("SessionClaimValidator Refresh", () => { + describe("Client and Server clock are in sync", () => { + before(function () { + DateProviderReference.init(); + }); + + it("SessionClaimValidator.shouldRefresh should return false after refreshing", function () { + const tokenPayload = { + "st-test": { + v: false, + t: Date.now() - 20000 // setting claim fetched time to 20 seconds ago + } + }; + + const testClaim = new BooleanClaim({ + id: "st-test", + refresh: () => { + tokenPayload["st-test"].t = Date.now(); + }, + defaultMaxAgeInSeconds: 10 /* 10 seconds */ + }); + + const testClaimValidator = testClaim.validators.isTrue(); + + assert(testClaimValidator.shouldRefresh(tokenPayload) === true); + testClaimValidator.refresh(); + assert(testClaimValidator.shouldRefresh(tokenPayload) === false); + }); + }); + + describe("Client Clock is ahead 1 hour of server time", () => { + before(function () { + DateProviderReference.init(); + }); + + it("SessionClaimValidator.shouldRefresh should return true even after refreshing", function () { + const tokenPayload = { + "st-test": { + v: false, + t: Date.now() + } + }; + + const testClaim = new BooleanClaim({ + id: "st-test", + refresh: () => { + tokenPayload["st-test"].t = Date.now(); + }, + defaultMaxAgeInSeconds: 10 /* 10 seconds */ + }); + + const testClaimValidator = testClaim.validators.isTrue(); + + withFakeClock(Date.now() + ONE_HOUR_IN_MS, () => { + assert(testClaimValidator.shouldRefresh(tokenPayload) === true); + }); + + testClaimValidator.refresh(); + + withFakeClock(Date.now() + ONE_HOUR_IN_MS, () => { + assert(testClaimValidator.shouldRefresh(tokenPayload) === true); + }); + }); + + it("SessionClaimValidator.shouldRefresh should return false after refreshing", function () { + const tokenPayload = { + "st-test": { + v: false, + t: Date.now() - 20000 // setting claim fetched time to 20 seconds ago + } + }; + + const testClaim = new BooleanClaim({ + id: "st-test", + refresh: () => { + tokenPayload["st-test"].t = Date.now(); + }, + defaultMaxAgeInSeconds: 10 /* 10 seconds */ + }); + + const testClaimValidator = testClaim.validators.isTrue(); + + // Adjust DateProvider clientClockDeviation + DateProviderReference.getReferenceOrThrow().dateProvider.setClientClockDeviationInMillis(-ONE_HOUR_IN_MS); + + withFakeClock(Date.now() + ONE_HOUR_IN_MS, () => { + assert(testClaimValidator.shouldRefresh(tokenPayload) === true); + }); + + testClaimValidator.refresh(); + + withFakeClock(Date.now() + ONE_HOUR_IN_MS, () => { + assert(testClaimValidator.shouldRefresh(tokenPayload) === false); + }); + }); + }); +}); diff --git a/utils/dateProvider/index.d.ts b/utils/dateProvider/index.d.ts new file mode 100644 index 00000000..11ea6c22 --- /dev/null +++ b/utils/dateProvider/index.d.ts @@ -0,0 +1,25 @@ +/* Copyright (c) 2022, VRAI Labs and/or its affiliates. All rights reserved. +* +* This software is licensed under the Apache License, Version 2.0 (the +* "License") as published by the Apache Software Foundation. +* +* You may not use this file except in compliance with the License. You may +* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +* License for the specific language governing permissions and limitations +* under the License. +*/ +export * from "../../lib/build/utils/dateProvider"; +/** + * 'export *' does not re-export a default. + * import SuperTokens from "supertokens-website"; + * the above import statement won't be possible unless either + * - user add "esModuleInterop": true in their tsconfig.json file + * - we do the following change: + */ + import * as _default from "../../lib/build/utils/dateProvider"; + export default _default; + \ No newline at end of file diff --git a/utils/dateProvider/index.js b/utils/dateProvider/index.js new file mode 100644 index 00000000..8ac536eb --- /dev/null +++ b/utils/dateProvider/index.js @@ -0,0 +1,20 @@ +/* Copyright (c) 2020, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. +*/ +"use strict"; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +exports.__esModule = true; +__export(require("../../lib/build/utils/dateProvider")); diff --git a/utils/dateProvider/types.d.ts b/utils/dateProvider/types.d.ts new file mode 100644 index 00000000..2d0f2e91 --- /dev/null +++ b/utils/dateProvider/types.d.ts @@ -0,0 +1,25 @@ +/* Copyright (c) 2022, VRAI Labs and/or its affiliates. All rights reserved. +* +* This software is licensed under the Apache License, Version 2.0 (the +* "License") as published by the Apache Software Foundation. +* +* You may not use this file except in compliance with the License. You may +* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +* License for the specific language governing permissions and limitations +* under the License. +*/ +export * from "../../lib/build/utils/dateProvider/types"; +/** + * 'export *' does not re-export a default. + * import SuperTokens from "supertokens-website"; + * the above import statement won't be possible unless either + * - user add "esModuleInterop": true in their tsconfig.json file + * - we do the following change: + */ + import * as _default from "../../lib/build/utils/dateProvider/types"; + export default _default; + \ No newline at end of file diff --git a/utils/dateProvider/types.js b/utils/dateProvider/types.js new file mode 100644 index 00000000..d0c4cb58 --- /dev/null +++ b/utils/dateProvider/types.js @@ -0,0 +1,20 @@ +/* Copyright (c) 2020, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. +*/ +"use strict"; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +exports.__esModule = true; +__export(require("../../lib/build/utils/dateProvider/types"));