All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Added
3.1
and4.0
to the list of supported FDIs - Now we throw and log an error if a successful refresh response doesn't have the
front-token
header. This used to break the session state.
- Removed redundant
removeToken
calls - Improves test stability
- Adds new test
- Fixed a session refresh loop caused by blocked cookie writes. The SDK would throw/log a helpful error message when this happens.
- Added a warning if the SDK can't save to cookies to help people notice/debug these issues faster.
- Fixed an issue in the Axios interceptor that caused it to throw when encountering a network error
- Fixed the session refresh loop in all the request interceptors that occurred when an API returned a 401 response despite a valid session. Interceptors now attempt to refresh the session a maximum of ten times before throwing an error. The retry limit is configurable via the
maxRetryAttemptsForSessionRefresh
option.
- Added 2.0 and 3.0 to supported FDIs
- Now we use the locking to make sure that refreshing claims happens only once even for concurrent validateClaims calls
- The locking mechanism is configurable through by providing a
lockFactory
function in the configuration
- The locking mechanism is configurable through by providing a
The shouldDoInterceptionBasedOnUrl
function now returns true:
- If
sessionTokenBackendDomain
is a valid subdomain of the URL's domain. This aligns with the behavior of browsers when sending cookies to subdomains. - Even if the ports of the URL you are querying are different compared to the
apiDomain
's port ot thesessionTokenBackendDomain
port (as long as the hostname is the same, or a subdomain of thesessionTokenBackendDomain
): #217
Before:
shouldDoInterceptionBasedOnUrl("https://sub.api.example.com", "", "api.example.com") // false
shouldDoInterceptionBasedOnUrl("https://sub.api.example.com", "", ".api.example.com") // true
shouldDoInterceptionBasedOnUrl("https://sub.api.example.com", "", "example.com") // false
shouldDoInterceptionBasedOnUrl("https://sub.api.example.com", "", ".example.com") // true
shouldDoInterceptionBasedOnUrl("https://api.example.com", "", ".example.com:8080") // false
shouldDoInterceptionBasedOnUrl("https://api.example.com", "https://example.com:8080") // false
After:
shouldDoInterceptionBasedOnUrl("https://sub.api.example.com", "", "api.example.com") // true
shouldDoInterceptionBasedOnUrl("https://sub.api.example.com", "", ".api.example.com") // true
shouldDoInterceptionBasedOnUrl("https://sub.api.example.com", "", "example.com") // true
shouldDoInterceptionBasedOnUrl("https://sub.api.example.com", "", ".example.com") // true
shouldDoInterceptionBasedOnUrl("https://api.example.com", "", ".example.com:8080") // true
shouldDoInterceptionBasedOnUrl("https://api.example.com", "https://example.com:8080") // true
- Fixes test server
- Rename
validatorId
in claim validation errors toid
to match the backend SDKs
- Added
1.19
to the list of supported FDIs
- Fix the type of the
builder
object the function override callback gets. It is not longer optional.
- Fix an issue that caused
attemptRefreshingSession
to throw in some cases when getting a 401 response from the refresh endpoint
- The default
DateProvider
implementation relies onlocalStorage
. If your environment lacks support forlocalStorage
, you must provide custom implementations for either theDateProvider
orlocalStorage
.
- Added a
DateProvider
, that both built-in and custom validators can use instead ofDate.now
to get an estimate of the server clock. - Added the
dateProvider
prop to the configuration that can be used to customize the built-inDateProvider
. - Added
getClockSkewInMillis
as an overrideable function that estimates the time difference between the backend and the client. - Added a test to check that relative URLs get intercepted correctly
- Fix typo in debug logging
- Split some test suites into multiple files to help with test parallelization
- Added
1.18
to supported FDI versions
- Added
1.17
to supported FDI versions
- Added
shouldDoInterceptionBasedOnUrl
as an overrideable function to the recipe interface
- Fixed an issue where the Authorization header was getting removed unnecessarily
- Made SessionClaimValidator a type instead of an abstract class
- Always clearing locally stored access and refresh tokens if the front-token is removed to handle proxies omitting empty headers
- Updated tests/test server to match new backend version supporting v3 access tokens
- Fixes fetch interceptor calling clone on URL instances
- Passes windowHandler's localstorage to browser-tabs-lock as well.
- Relaxes test constraint related to legacy axios interceptor.
- Refactored XMLHttpRequest interceptor to fix a possible issue timing issue: #208
- Fixed an issue that could cause an infinite refresh loop in the legacy axios interceptor (explicitly disabling the XHR interceptor) if the access token changed during the request
- Switched dependency away from the removed/unpublished
mocha-split-tests
package
- Adding refresh tokens to refresh calls even if access token isn't present to make manual testing easier.
- Exposed getGlobalClaimValidators function via utils.
- Fixed a rare case where the XHR interceptor didn't handle empty response headers correctly
- Only supporting FDI 1.16
- The backend SDK should be updated to a version supporting the header-based sessions!
- supertokens-node: >= 13.0.0
- supertokens-python: >= 0.12.0
- supertokens-golang: >= 0.10.0
- Renamed configuration options:
sessionScope
renamed tosessionTokenFrontendDomain
cookieDomain
renamed tosessionTokenBackendDomain
- Added
getHost
function to theWindowHandlerInterface
.
- Added support for authorizing requests using the
Authorization
header instead of cookies- Added
tokenTransferMethod
config option - Check out https://supertokens.com/docs/thirdpartyemailpassword/common-customizations/sessions/token-transfer-method for more information
- Added
- Added
includesAny
validator to Primitive Array claims.
- Add ability to specify a lockFactory to override the default browser-tabs-lock
- Added
getWindowUnsafe
to the WindowHandlerInterface. This function should return the raw window object.
- doesSessionExist now refreshes the session if it detects an expired access token
- XMLHttpRequest event dispatching should now work in Safari.
- A race-condition blocking XMLHttpRequests in Chrome is now fixed.
- Retrying request post refreshing now remembers the original input body.
- Adding an interceptor for XMLHttpRequest by default upon initializing SuperTokens
- Marked
addAxiosInterceptors
as deprecated - Request interception can now be disabled by adding
superTokensDoNotDoInterception
to the hash of the request (works as a queryparam as well)
- Removed default max age from claims
- Support for new FDI (1.15)
- Added the
API_INVALID_CLAIM
event and the relatedinvalidClaimStatusCode
config prop. - Adds base classes, types for session claims, and the
getInvalidClaimsFromResponse
,validateClaims
,getClaimValue
functions.
- Updates README
- Updates dependencies to fix building in node 17 + match typescript version of auth-react
- Refactors the way the SDK exports the error class
- Fixes node dependency for integration tests
- Removes
setCookieSync
andgetCookieSync
from the interface forcookieHandler
when callingSuperTokens.init
- Adds new FDI support (1.14)
- Calling
SuperTokens.signOut
now throwsSTGeneralError
if the API responds with a general error status
- Adds tests for custom cookie and window handlers
- You can now configure a
postAPIHook
when callingSuperTokens.init
to subscribe to and handle to network responses
- Adds user context to all functions exposed to the user, and to API and Recipe interface functions. This is a non breaking change for User exposed function calls, but a breaking change if you are using the recipe override feature.
- All recipe functions now accept an object (instead of inidividual parameters), this is a breaking change only if you are using the override feature.
- Recipe functions no longer accept the
config
parameter, this is a breaking change if you are using the override feature - Renames properties for
windowHandler
- getLocalStorage -> RENAMED to localStorage
- getSessionStorage -> RENAMED to sessionStorage
windowHandler
uses a new interface type for localStorage and sessionStorage
- Updates debug log message
- Adds debug logs
- Add the
ACCESS_TOKEN_PAYLOAD_UPDATED
event
- A new config property
cookieHandler
that allows for custom handling when the SDK reads/writes cookies - A new config property
windowHandler
that allows for custom handling when the SDK uses any functions from the Window API.
- For electron apps, prod build, we now handle
window.location.hostname
being an empty string.
- Setting headers in first param of fetch (#116)
- New FDI support (v1.13)
- Workflow to verify if pr title follows conventional commits
- Issue #99
- FDI 1.12 compatibility
- Compatibility with FDI 1.11
- Add tests for using session with jwt enabled
- Fixes #98
- Re-organises code to remove circular dependencies: supertokens/supertokens-auth-react#334
- Uses supertokens-js-override from npm
- When calling a user's API, uses rid "anti-csrf" instead of session to solve supertokens/supertokens-node#202
- FDI 1.10 support (just changing the frontendDriverInterfaceSupported.json)
- Uses non arrow functions in api and recipe interface impl to allow for "true" inheritance in override: supertokens/supertokens-node#199
- Uses
bind(this)
when calling original implementation - Added bundle size checking for PRs
- Renames
getJWTPayloadSecurely
togetAccessTokenPayloadSecurely
- Fixed how we transform fetch responses with an empty body into axios responses
- Not calling refresh after API calls if the refresh API returned an error
- Not calling refresh after an 401 response has removed the session
- Moved axios to dev dependency
- Fixed axios refresh error test
- Using fetch instead of axios to call the refresh API
- Adds axios as a dependency
- Rejecting with axios response object if a call through axios gets an unexpected error during session refresh. This is a breaking change since it changes the API (even if it's an error).
- Disabled source map generation
- New FDI 1.9
- Updated test behavior for cores after 3.6
- A sessionExpiredOrRevoked propety on the "UNAUTHORIZED" event.
- Fixes typescript issue with default imports. (Related to supertokens/supertokens-auth-react#297)
- Handles
Uncaught ReferenceError: process is not defined
during getting if testing or not.
SESSION_CREATED
event, which can be consumed byonHandleEvent
- If a new session is created, and we try and fetch userId or jwtPayload before the frontToken is set, then it would throw an error. However, now we wait for the frontend token to be set / removed and then return the requested information.
- Fires
UNAUTHORISED
event before attempting to refresh if we know that a session does not exist. - Fires
SIGN_OUT
event whensignOut
is called and a session doesn't exist.
- Removes use of
addedFetchInterceptor
infetch.ts
- Recipe interface that can be overrided
preAPIHook
andonHandleEvent
functions
sessionScope
is a now a string
- Backward compatibility with cross domain localstorage
- Removes
setAuth0API
,getAuth0API
andgetRefreshURLDomain
functions. - Removed
refreshAPICustomHeaders
andsignoutAPICustomHeaders
from config. UsepreAPIHook
instead.
- Pushes new version to show this version as latest in npm
- Fixes issue supertokens/supertokens-node#134
- Allow specifying of
cookieDomain
in config to add interceptors to multiple API subdomain: #58
- Fixes .d.ts file to allow all styles of imports
- Adds a ts testing file in test folder.
- Support for sessions if used within an iframe: #53
- #50: originalFetch was being assigned twice such that the the refresh call was calling it too, resulting in a refresh inside a refresh -> deadlock
- When fetching the idRefreshToken from the frontend, if the backend is not working, we assume that the session doesn't exist.
- Uses frontend set cookies instead of localstorage so that sub domain session works on Safari
- Sends
rid
on each request - acts as a CSRF protection measure (see https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html#use-of-custom-request-headers) - Refreshes session if the frontend set cookies are deleted (due to privacy features in Safari).
- New FDI 1.8
- Uses localstorage and iframes (for cross domain communication of localstorage) for session storage instead of cookies
getUserId
anddoesSessionExist
now returnPromises
- Sign out support
- Support for FDI 1.7
- Sets the cookies set by the frontend to never expire. Previously they were being set as Session cookies which cause them to be removed on browser restart, resulting in an inconsistent state.
- Fixes normalisation of URL and path in case the path has a dot in it
- Compatibility with new FDI version
- Adds ability to use relative path for fetch and axios
- Compatibility with new FDI version
- Correctly handles fetch interception if the type of url is not a string
- Applies dependabot dependency changes
- Adds package-lock as per #28
- Better error messages for SSR.
- Added compatibility with new FDI. No change needed for this SDK, but added this since it's still compatible
- If the sessionScope is the same as the current domain, then we do not use it when setting cookies. This is because we do not want the browser to automatically add a leading dot. See #25
- Enforce interception for fetch and axios for easier use - issue #19
- Renames
websiteRootDomain
tosessionScope
- Removes
refreshTokenUrl
from input and replaces it withapiDomain
andapiBasePath
. - The refresh API will alway be
apiDomain + apiBasePath + "/session/refresh"
- Normalizing of user input
- Updates supported FDI to be
1.3
- Changes to tests to use the new config
- Does not send frontend SDK version anymore
- Changed success refresh call status code to >= 200 && < 300
- Stores Anti CSRF token in cookie that can be shared across sub domains. This value is then read and added to the request header separately.
- Compatible with FDI 1.2 and not with previous versions
- Adds ability to get userID and JWT payload (securely) from the frontend
- Adds 1.1 as supported FDI
- Changed the default session expiry status code to 401
- Changed function signature of
init
foraxios
andfetch
- Enables
fetch
interception by default - Automatically adds credentials to
axios
andfetch
- which can be disabled
- If current hostname is
localhost
, we do not add that as an explicit domain when setting theIRTFrontend
cookie.
- Function to get Refresh URL's domain
- Function to set and get Auth0's API path
- New tests added for testing JWT payload update
- For testing, cookie domain changed from localhost to localhost.org
- In testing, GET "/" API will return userId of the logged in user
- In axios interception, when handling error, we no longer create a new axios instance
- Update license in package.json to match github's license.
- Updated dependency browser-tabs-lock's version
- Makes frontend id refresh token's cookie path =
/
So that it is accessible throughout a website and not just the page that was used to login the user (in case tha page was not/
).
- Relaxes constraint for checking if session is alive
- Handles id refresh token via frontend cookies so that non sub domain cross domain requests can be made.
- Added ability to check if a session exists or not.
- Minor changes.
- Adds support for api on a different domain (as long as there is a shared sub domain between currently loaded page and API) - via setting withCredentials to true.
- makeSuper is now a part of the default import
- creates fetch interceptor so that users do not need to change their existing fetch calls
- added support for axios calls
- handling of anti-csrf token
- package testing