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

justlogin.xyz-client

v2.0.2

Published

An example client for the just-login-core

Downloads

5

Readme

justlogin.xyz-client

Build Status

Example

Create a server:

var db = require('level')('./databases/core')
var core = require('just-login-core')(db)
var sessionState = require('just-login-session-state')(core, db)
var server = require('http').createServer()
var sock = require('justlogin.xyz-client')(core, sessionState)

sock.install(server, '/dnode-example')

Create a client:

var justLoginClient = require('justlogin.xyz-client')

var client = justLoginClient('/dnode-example', function (err, newApi, sessionId) {
	if (!err) {
		//do stuff with the api
	}
})

client.on('session', function (session) {
	if (session.continued) {
		console.log('Reusing my session:', session.sessionId)
	} else {
		console.log('New session:', session.sessionId)
	}
})
client.on('authenticated', function (email) {
	console.log(email + ' just got logged in!')
})

API

var client = require('justlogin.xyz-client')

Server Side

var sock = client(core, sessionState)

var sock = client(core, sessionState)
sock.install(http.createServer(), '/dnode')

Client Side

var emitter = client(dnodeEndpoint, cb)

This function handles remembering the session id in the browser's local storage.

  • dnodeEndpoint is a string for the endpoint that dnode uses for communication. The string must start with a forward slash /.
  • cb is a function that has the following arguments:
    • err is either null or an Error object.
    • newApi is an object with methods from just-login-core and just-login-session-state, but with the sessionId pre-bound:
      • beginAuthentication(contactAddress, [cb]) from just-login-core
      • isAuthenticated(cb) from just-login-session-state
      • unauthenticate([cb]) from just-login-session-state
      • sessionExists(cb) from just-login-session-state
    • sessionId is the new (or previous, when applicable) session id.
  • Returns emitter which can emit the following events:
    • session is emitted when a session is initiated. An object is emitted with the following properties:
      • sessionId The id for the current session. E.g. 3879533a-1f34-11e4-a8de-c92c3319c4e0
      • continued Whether or not the session was continued from a previous session. E.g. true, false
    • authenticated is emitted when the user gets authenticated.
emitter.on('session', function (data) {
	console.log(data.continued) //boolean for if the session was continued or newly created
	console.log(data.sessionId) //string for the session id
})

emitter.on('authenticated', function (whom) {
	t.ok(whom, 'got authenticated')
	t.equal(whom, fakeEmailAddress, 'correct email (new)')
})

Install

Install with npm

npm install justlogin.xyz-client

License

VOL