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

whoru

v3.0.0

Published

Who are you? Tackle the thorny issue of identity association.

Downloads

13

Readme

whoru

SUPER ALPHA WARNING. Please wait till this message disappears before using.

Who are you? Tackle the thorny issue of identity association.

This module just tries to relate the following nouns.

Nouns:

  • fingerprint: a hash that represents a single device.
  • login. A single login, eg email, social, oauth, that has a bunch of device fingerprints. We will need to associate an login to a fingerprint at login.
  • account. A user account. Might have multiple logins.
  • person. A person has one or more user accounts and fingerprints.
  • app an logical thing a Person uses, like the engine, redforms, or hometribe
  • space like a realtors website. It is the partition of data in an app so data does not bleed between websites.

Relationships of the nouns

Person 1-* Account 1-* Login 1-* LoginFingerprint *-1 Fingerprint

The account object should have a AppSpaceID property on it. Like 'rwp_1232-engine'

The AccountFingerprint ID will be composed fingerprint/loginID/accountID/PersonID as it is the main join.

npm install whoru

Usage

First of all, you need to fingerprint on the client device. Something like

// somewhere on the client
var Fingerprint2 = require('fingerprint2')
new Fingerprint2().get(function (fingerprint, components) {
  console.log('your device fingerpring', fingerprint)
})

Back on the server you will add this fingerprint as soon as you can. Eg, you dont need login info

// whoru is backed by a pouchdb
var db = new PouchDB('whoru')
var whoru = require('whoru')(db)


// ##############################
// Add the fingerprint to the db
// back to where we have whoru
whoru.addFingerprint(fingerprint)
whoru.addFingerprint(fingerprint, deviceInfo)
whoru.addFingerprint(fingerprint, deviceInfo, function(err) {   
  // err if there was a problem adding the fingerprint
})

Now assume the person logins in. At this point we know a lot more about the person. You should inform whoaru with this info The details of all the params

  • fingerprint which was obtained from before
  • userLoginID. Some unique id from your login service. Could be a primary key from a DB or an ID from a OAUTH service.
  • loginType. A string to indentify how the userLoginID is unique. EG, 'db', 'facebook', 'twitter'
  • app. A string to identify the app they logged into, in a multi-app environment, Eg 'wiki', 'forum', 'chat'
  • space. A logical grouping across apps. Useful if you host multiple websites with different branding. Eg 'coke', '7-up'
  • details. Any additional data you want to store about the login

Here is an example of the call:

// ################################
// associate the fingerprint with the login and, eg after they login
whoru.addLogin(fingerprint, userloginID, loginType, app, space, details, function (err, person) {
  
})

Now sometime later, you want to see who an anonymous user is.

// lookup the Person from a fingerprint, given the least info you know
whoru.findPerson(fingerprint, app, space, function (err, person) {
  
})

Or find any related details of a fingerprint

// object stream of all details of a fingerprint, will include login, account, and person details
whoru.findDetails(fingerprint).pipe(through2.obj(function(detail, enc, cb) {
  console.log(detail.doc) //the actual doc one of
  switch(detail.type) {
    case 'login'
    case 'account'
    case 'person'
  }
}))

The end user can decided that two users are actually the same, and decide to merge them

whoaru.mergePerson(from_person_id, to_person_id, function(err)) {

}

## License

MIT