npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

justauthenticateme-node

v1.0.3

Published

Nodejs SDK for https://www.justauthenticate.me

Downloads

3

Readme

Introduction

JustAuthenticateMe offers simple magic link based authentication as a service for web apps. This is a tiny library for your node.js backend to verify ID Tokens from JustAuthenticateMe and otherwise interact with the service. If you're looking for the browser sdk, see justauthenticateme-web.

Getting Started

Installing via npm or yarn

npm install --save justauthenticateme-web
yarn add justauthenticateme-web

Importing

import JustAuthenticateMe from "justauthenticateme-web";

Initializing the library

Pass your App ID from the JustAuthenticateMe dashboard to the constructor.

const appId = "dcd6555e-edff-4f3d-83c9-3af79ea8f895";
const jam = new JustAuthenticateMe(appId);

Use Cases

Verifying an ID Token

const email = await jam.verify(idToken);

On the first call, this will fetch the public key for your app from the JustAuthenticateMe API and cache it for all future uses. It verifies the ID Token with your app's public key and pulls out the email from the JWT payload. If the token is invalid for any reason, an error will be thrown.

There is an optional second boolean argument for forcing a refetch of the public key. jam.verify(idToken, true) will always make the API call to get your public key, even if it was already cached, and cache the results of that call.

Fetching your app's Public Key

const jwks = await jam.getJwks();

This will fetch the JWKS representation of the public key for your app from the JustAuthenticateMe API. Currently, all apps will only have one key in the set.

Authenticating a User

await jam.initAuth("[email protected]");

This will generate a magic link and send it to the email argument. Upon clicking the magic link the user will be redirected to the Redirect URL specified for your app in the JustAuthenticateMe Dashboard with an ID Token and Refresh Token (if enabled) as query string parameters. Successful promise completion means the email was successfully generated and sent.

Getting a new ID Token using a Refresh Token

const newIdToken = await jam.refresh(refreshToken);

Deleting a Refresh Token

await jam.deleteRefreshToken(idToken, refreshToken);

idToken must be a valid ID Token for the user. refreshToken will no longer be valid after calling this function. It's recommended to call this function when logging out in addition to deleting the refreshToken from local memory.

Deleting all Refresh Tokens (Sign Out Everywhere)

await jam.deleteAllRefreshTokens(idToken);

idToken must be a valid ID Token for the user. Calling this function will invalidate all existing refreshTokens for the user, effectively logging the user out from all devices.

License

MIT