Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
supertokens-website
Advanced tools
This is a library written in TypeScript that implements the frontend part of user session management for websites. You can use this to make http(s) API calls to your backend that require an authenticated user.
Features:
To get started, you just need to do:
npm i --save supertokens-website
This library is to be used instead of axios in places where the API requires auth tokens.
import * as SuperTokensRequest from "supertokens-website";
// @params refreshTokenURL: this is the path to API endpoint that is responsible for refreshing the session when the access token expires.
// @params sessionExpiredStatusCode: this is the status code that will be sent by any API that detects session expiry.
// @returns void
SuperTokensRequest.init("/api/refreshtoken", 440)
// @params url: endpoint to your GET API
// @params config: this is same as axios config
// @returns Promise
SuperTokensRequest.get("/someAPI", config).then(response => {
// API response.
}).catch(err => {
// err is of type axios error
});
// @params url: endpoint to your POST API
// @params data: post body data - key value object
// @params config: this is same as axios config
// @returns Promise
SuperTokensRequest.post("/someAPI", data, config).then(response => {
// API response.
}).catch(err => {
// err is of type axios error
});
// @params url: endpoint to your DELETE API
// @params config: this is same as axios config
// @returns Promise
SuperTokensRequest.delete("/someAPI", config).then(response => {
// API response.
}).catch(err => {
// err is of type axios error
});
// @params url: endpoint to your PUT API
// @params data: put body data - key value object
// @params config: this is same as axios config
// @returns Promise
SuperTokensRequest.post("/someAPI", data, config).then(response => {
// API response.
}).catch(err => {
// err is of type axios error
});
// @params func: a function that returns a Promise returned by calling the axios function
// @returns Promise
SuperTokensRequest.doRequest(() => axios(...)).then(response => {
// API response.
}).catch(err => {
// err is of type axios error
});
// @params func: a function that returns a Promise returned by calling the axios function
// @returns Promise
SuperTokensRequest.attemptRefreshingSession().then(success => {
if (success) {
// session may have refreshed successfully
} else {
// user has been logged out. Redirect to login page
}
}).catch(err => {
// err is of type axios error
});
You can play around with the demo project that uses this and the supertokens-node-mysql-ref-jwt library. The demo demonstrates how this package behaves when it detects auth token theft (and the best part - you are the hacker here, muahahaha!)
This library is written in TypeScript (TS). When you make any changes to the .ts files in the root folder, run the following command to compile to .js:
tsc -p tsconfig.json
Created with :heart: by the folks at SuperTokens. We are a startup passionate about security and solving software challenges in a way that's helpful for everyone! Please feel free to give us feedback at team@supertokens.io, until our website is ready :grinning:
FAQs
frontend sdk for website to be used for auth solution.
The npm package supertokens-website receives a total of 21,192 weekly downloads. As such, supertokens-website popularity was classified as popular.
We found that supertokens-website demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.