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

@uraikus/sso

v1.0.0

Published

uraik.us anonymous Single Sign-On (SSO) is a secure, fast, and simple login tool that doesn't track its users. With bot-stopping mechanisms and pre-generated passcodes, its never been easier to make an account or to implement SSO.

Downloads

2

Readme

uraik.us SSO

uraik.us anonymous Single Sign-On (SSO) is a secure, fast, and simple login tool that doesn't track its users. With bot-stopping mechanisms and pre-generated passcodes, its never been easier to make an account or to implement SSO.

Client implementation is extremely easy (no dependency required):

var sso = {origin: 'https://sso.uraik.us'}
addEventListener('message', ev => {
  if (ev.origin === sso.origin) {
    if (ev.data === 'ready') sso.window.postMessage('credentials', sso.origin)
    else if (ev.data && ev.data.type === 'credentials') {
      sso.credentials = ev.data // {publicKey: 'abcdf...', userId: 3, type: 'credentials'}
      shareWithServer(ev.data)
    }
  }
})
sso.window = open(sso.origin, 'sso')

To prevent user spoofing, you can validate the key with the server:

Client:

function shareWithServer(theCreds) {
  fetch('/validate-sso', {
    method: 'POST',
    headers: {
      'content-type': 'application/json'
    },
    body: JSON.stringify(theCreds)
  })
}

To validate the credential on your server, make an http request with the public key to the address below:

POST https://sso.uraik.us/apiv1/validate BODY: {publicKey: 'abbDKsdlfk...'}
RESPONSE: {userId: 3}

Example (ExpressJS):

router.post('/validate-sso', (req, res, next) => {
  let fetch = require('node-fetch')
  fetch('https://sso.uraik.us/apiv1/validate', {
    method: 'POST',
    headers: {
      'content-type': 'application/json'
    },
    body: JSON.stringify(req.body)
  })
    .then(r => {
      if (r.ok) {
        res.cookie('public_key', body.publicKey, { expires: new Date(Date.now() + 900000), httpOnly: true })
        res.send()
      } else res.status(401).send('Unauthorized')
    })
})

You can also use the SSO middleware for the ExpressJS validation:

app.use(require('@uraikus/sso'))
app.use((req, res) => {
  req.userId // will be null if validation failed
})

This middleware will validate the authorization http header and put the userId into the request object. So when sending requests from the client after logging in, include the publicKey in the authorization header.

Client:

fetch(url, {
  headers: {
    authorization: 'Bearer ' + sso.publicKey
  }
})