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

octopusidentity

v0.2.3

Published

Passport + mongoose middle ware to manage multiple identity users and non-user contacts without redundancy and conflicts.

Downloads

8

Readme

octopusidentity

npm install octopusidentity

Passport + mongoose middle ware to manage multiple identity users and non-user contacts without redundancy and conflicts.

It may be usefull as long you try to solve ALL listed challanges:

  • you use Passport
  • your users can use multiple emails
  • your users can authorise with oauth strategies
  • your users can have contacts who can be identified either by email and social accounts
  • contacts may be users in your system, but doesn't have to be

Usage with MeanJS

Main reason to use with MeanJS

MeanJS saves various identities in few fields:

  • user.email
  • user.username
  • user.providerData.id
  • user.additionalProviderData[providerName].id

As we know Mongo is quite rubbish, if you want to create multiple indexes on collection (very space consuming). For that case we gather all data in "shadow" collection called aliases witch such schema:

var AliasSchema = new Schema( {
    id       : { type : String },
    provider : { type : String },
    user     : { type : String, default : null },
    contacts : [ { type : String } ]
} );

Thanks to that you can simplify queries to maximum 3 indexes: * id+provider * user * contact

Installation

For MeanJS simply plugin MeanJS User Plugin into your user model

var octopus = require('octopusidentity' ).meanPlugin;
(...)
UserSchema.plugin(octopus);

All happens behind the scenes and OctopusIdentity shadows native MeanJS authentification. It also works asynchronous so won't affect user experience.

Usage with Passport

For Passport please use User Plugin.

var UserPlugin = require( 'octopusidentity' ).plugin;
var mongoose = require('mongoose');
var Schema = mongoose.Schema;

var UserSchema = new Schema( {
    name     : { type : String, default : '' },
    accounts : [ UserPlugin ]
} );
OctopusUserSchema.plugin( UserPlugin, {} );
mongoose.model( 'User', UserSchema );

This user plugin has slightly different internface to mongoose-user User Plugin, as it base more on the callbacks.

To fetch user:

/**
  * @param {String} provider - email, facebook or other strategy name
  * @param {String} id - oauth id or email
  */
UserModel.load( provider, id , function ( err, user ) {
	(...)
});

To verify credentials

/**
  * @param {Boolean} successOrFail
  */
user.validateCredentials( provider, id, tokenOrPassword, function(err, successOfFail) {
   (...)
});

To assign credentials

user.setAlias(provider, id, tokenOrPassword, function(err, user) {
});

Planned features

  • Collect graph data from providers (useful for contacts). Use Gmail Contacts use case. If you have [email protected] in you contacts Gmail will fill info about him (including avatar) with G+ data. You can override it, but your changes appear only for you. If johndoe changes his data on G+ all non-overriden data should be updated. It has sense to store data in such structure:

{ provider : "google", id : "[email protected]", user : null // he is not yet a user contacts : [ 'someMongoID', 'someMongoID2' ], data : { thumb : 'http://example.com/my_smiley_avatar.png', displayName : 'John Doe' } }


## Test status

Tested with strategies:

* google
* github
* linkedin
* facebook
* twitter
* vk

Tested with MEANJS.Org

Project that is decoupted part of code I work at in my free time.

## Credits

* Lukasz Sielski [email address](mailto:[email protected]) [web site](http://www.lukaszsielski.pl) [github](https://github.com/sielay)

Licenced under MIT, of course.