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

pronto-auth-service

v0.0.6

Published

User sessions for web and mobile. Pluggable authentication from Zamba, Facebook, Twitter, Google, Linkedin, Salesforce and custom providers. Permit users amongst apps with configurable roles. You can (configured) make Users belong to Accounts. You can inv

Downloads

5

Readme

Auth Service

User sessions for web and mobile. Pluggable authentication from Zamba, Facebook, Twitter, Google, Linkedin, Salesforce and custom providers. Permit users amongst apps with configurable roles. You can (configured) make Users belong to Accounts. You can invite a user to (a composable set of [App, Account, other config in tokens]), with customized handlers based on the nature of the token.

Usage

Clone https://github.com/prontotype-us/auth-service into your node_modules, or include the repo in your package.

# ...
# Set up your DataService here

config = require '../config'
{jwt_secret, auth_callback_base_url} = config

auth_config = {
    id_key: '_id'
    jwt_secret: jwt_secret
    # Oauth2
    auth_callback_base_url
    providers: {
        (facebook):
            client_id: ''
            client_key: ''
        (twitter):
            consumer_key: ''
            consumer_secret: ''
            ...
    }
}

AuthService = require('auth-service')(auth_config,
    create: (type, item, cb) ->
        DataService 'create', type, item, cb
    get: (type, query, cb) ->
        DataService 'get', type, query, cb
    find: (type, query, cb) ->
        DataService 'find', type, query, cb
    update: (type, id, item_update, cb) ->
        DataService 'update', type, id, item_update, cb
)

service = new somata.Service 'platform_slug:auth', AuthService

Methods

Incoming users

signupUser(app_id_or_slug, new_user, cb)

Sign up a new user with an email and password. app_id_or_slug is optional and will build a Role for the newly created User for the given app if included. Include any configuration for this Role on new_user.role. Things like account_id, organization_id, [app-specific-id-configuration], and any god, admin, or superadmin privileges are good things to put into the role config.

Authenticating as a user

getUserForApp(app_id_or_slug, query, cb)

Exchange an email and password for access to an app.

getUserByToken(jwt_token, cb)

Exchange a jwt token for a user record and session.

Auth Providers

You can configure social network login by passing in an array of strings to config.provider. Permitted provider slugs are twitter and facebook. google and linkedin need to be ported in.

getAuthUrl(provider, query, cb)

Get a url to redirect to for kicking off OAuth2 with this provider.

handleAuthCallback(provider, query, cb)

Handle the end of OAuth2 flow from a provider. Route here from your auth API.

getUserFromMetadata(user_data, cb)

Return a user for metadata including at least source and source_id or email. Useful for social authentication or providing users keyed off other external platforms. Each external account will map to exactly one user. Pass config.use_metadata = true to use a separate table for metadata like this. Otherwise the source and source_id will be kept directly on the user model.

getContextWithApiKey(api_key, cb)

Considering configuring this on a per-platform basis so there is slightly more flexibility how API keys are set up within the schema.

Helpers

getOrCreateUser getOrCreateUserForApp getOrCreateRole createUserForApp getApp getAppId