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

@roudanio/awesome-auth

v0.1.0

Published

Awesome Auth ========

Downloads

918

Readme

Awesome Auth

Awesome Auth is mainly used by static sites to give users functionalities like comment, like, validation, etc. It could be used with Awesome Comment, or alternative with Auth0.

We assume that you, as a static site owner, don't need a complex user system. The only thing you need is to know who is this current user, and allow them or disallow them to do something. You don't need to store sensitive data, just some useful information like game scores to make user more engaged.

So, here are something we will provide:

  • Only SSO via Google Identity (other providers will be added soon)
  • Serverless / Worker based backend API, only for validation
  • No user data stored

Usage

  1. Deploy the backend API
    1. Fork this repo
    2. Deploy /auth-admin on Serverless / Self-hosted servers
    3. Set up the environment variables
  2. Integrate Awesome Auth into your site
    import { getInstance } from '@roudanio/awesome-auth';
      
    const auth = getInstance({
      googleId: 'YOUR-GOOGLE-CLIENT-ID',
      root: 'https://your-backend-api.com',
    });
    // register events to handle user state
    awesomeAuth.on(AwesomeAuthEvent.VERIFIED, handleVerified);
    awesomeAuth.on(AwesomeAuthEvent.VERIFYING, handleUnverified);
  3. Add your own code for your own features
    // in your frontend code, attach access token to requests
    const token = auth.accessToken;
    fetch('https://your-backend-api.com/your-endpoint', {
      headers: {
        Authorization: `Bearer ${token}`,
      },
    });
      
    // in your backend API, validate the token by JWT.verify or with http request   
    const token = getHeader('Authorization');
    const user = jwt.verify(token, process.env.JWT_SECRET);
    if (!user) {
      // not valid user, return 401 or something else
      return;
    }

Store or retrieve user data

After all setup, you can store or retrieve user data like this:

// store
auth.store(key, value);

// retrieve
auth.retrieve(key);

with Awesome Comment

Of course it's very simple to use Awesome Auth with Awesome Comment:

import { getInstance } from '@roudanio/awesome-auth';
   
const auth = getInstance({
  googleId: 'YOUR-GOOGLE-CLIENT-ID',
  root: 'https://your-backend-api.com',
});

AwesomeComment.init({
  awesomeAuth: auth,
  // other options
});

Support SSO

  • [x] Google Identity
  • [ ] GitHub SSO
  • [ ] Sign in with Apple

LICENSE

MIT