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

simpleddp-plugin-login

v4.0.2

Published

This is a plugin for simpleDDP js library. Use it to authenticate with any Meteor.Accounts login provider.

Downloads

2,718

Readme

npm version Build Status Dependency Status devDependency Status

simpleddp-plugin-login (SimpleDDP Meteor.Accounts Login Plugin)

This is plugin for simpleDDP js library. Use it to authenticate with any Meteor.Accounts login provider (also custom).

Version 4.0.2

Plugin is for simpleDDP >= 2.2.4 For previous versions see.

Install

npm install simpleddp-plugin-login --save

Usage

Extends simpleDDP instance.

const simpleDDP = require("simpleddp");
const simpleDDPLogin = require("simpleddp-plugin-login").simpleDDPLogin;

let opts = {
    endpoint: "ws://someserver.com/websocket",
    SocketConstructor: WebSocket,
    reconnectInterval: 5000
};
const server = new simpleDDP(opts,[simpleDDPLogin]);

Adds events (login, logout, loginResume, loginSessionLost, loginResumeFailed),methods (login, logout) and userId property which is undefined when user is not logged in or is equal to user._id when user is logged in. Also token property when user is logged in. Plugin automatically resumes authentication if connection with server was lost and then restored back.

simpleDDP.login(auth)

Call this method to login with any Meteor.Accounts login provider.

Returns

A Promise which resolves to the object with userId of the logged in user when the login succeeds, or rejects when it fails.

Example for Accounts Password

server.userId; // undefined, we are not logged in

let password = "somepassword";
let username = "admin";
let email = "admin@admin";

// you must pass password and at least one of username or email
let userAuth = await server.login({
  password,
  user: {
      username,
      email
  }
});

// userAuth will be something like this
// { id: 'd6PqCAKk2QZeqZHWy',
//   token: 'N50Gmknk__geP63YD9pHKdl07b8XXxNGpB_cz5Lte4d',
//   tokenExpires: { '$date': 1548525528846 },
//   type: 'password' }

server.userId; // now equals to 'd6PqCAKk2QZeqZHWy'
server.token; // now equals to 'N50Gmknk__geP63YD9pHKdl07b8XXxNGpB_cz5Lte4d'

simpleDDP.logout()

Call this method to logout.

Returns

A Promise which resolves to undefined when the logout succeeds, or rejects when it fails.

Example

await server.logout();

Events Example

server.on('login',(m)=>{
  console.log('User logged in as', m);
});

server.on('logout',()=>{
  console.log('User logged out');
});

server.on('loginSessionLost',(id=>{
  console.log(`User {id} lost connection to server, will auto resume by default with token`);
});

server.on('loginResume',(m)=>{
  console.log('User resumed (logged in by token)', m);
});

server.on('loginResumeFailed',(m)=>{
  console.log('Failed to resume authorization with token after reconnection ', m);
});