
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
supertokens-website
Advanced tools
SuperTokens adds secure login and session management to your apps. This is the Javascript Frontend SDK for SuperTokens. More SDKs are available for frontend and backend e.g. Node.js, Go, Python, React.js, React Native, Vanilla JS, etc.
SuperTokens architecture is optimized to add secure authentication for your users without compromising on user and developer experience
Learn more at supertokens.com
Using npm
npm i -s supertokens-website
OR simply add the following script tag to your HTML pages
<script src="https://cdn.jsdelivr.net/gh/supertokens/supertokens-website/bundle/bundle.js"></script>
supertokens.init({
apiDomain: "<URL to your auth backend>"
});
// To be called at least once before any http request is made to any of your APIs that require authentication.
// Now your app will maintain secure SuperTokens sessions for your users
You can use one of the SuperTokens backend SDKs for this. Backend SDKs are available for
Now that's the basic setup. But you might want to do some of the following things
await supertokens.doesSessionExist();
let userId = await supertokens.getUserId();
let payload = await supertokens.getAccessTokenPayloadSecurely();
The signOut method simply revokes the session on the frontend and backend.
await supertokens.signOut();
fetch
The init
function call automatically adds interceptors to fetch. So there is nothing else that needs to be done.
supertokens.init({
apiDomain: "https://api.example.com"
});
async function doAPICalls() {
try {
// make API call as usual
let fetchConfig = { ... };
let response = await fetch("/someAPI", fetchConfig);
// handle response
if (response.status !== 200) {
throw response;
}
let data = await response.json();
let someField = data.someField;
// ...
} catch (err) {
if (err.status === 401) {
// redirect user to login
} else {
// handle error
}
}
}
supertokens.addAxiosInterceptors(axios); // To be called on each axios instances being imported
supertokens.init({
apiDomain: "https://api.example.com"
});
async function doAPICalls() {
try {
let postData = { ... };
let response = await axios({url: "someAPI", method: "post", data: postData });
let data = await response.data;
let someField = data.someField;
} catch (err) {
if (err.response !== undefined && err.response.status === 401) {
// redirect user to login
} else {
// handle error
}
}
}
To see documentation, please click here.
Please refer to the CONTRIBUTING.md file in this repo.
For any queries, or support requests, please email us at team@supertokens.com, or join our Discord server.
Created with :heart: by the folks at SuperTokens.com
[12.2.0] - 2022-06-25
FAQs
frontend sdk for website to be used for auth solution.
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
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.