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

cloudant-user

v2.0.0

Published

Helper module to use standard CouchDB _users db on a Cloudant db

Downloads

3

Readme

cloudant-user

Helper module to use standard CouchDB _users db on a Cloudant db.

Purpose

When _users db is enabled, Cloudant uses an old version of CouchDB auth which requires the salt and sha1-hashed password to be included with user creation.

https://cloudant.com/for-developers/faq/auth/

So, if you'd like to run your own npm registry with the solid hosting of Cloudant, this module is a huge help. I use it to create user accounts for our private npm.

Installation

git clone https://github.com/doublerebel/cloudant-user.git

Usage:

Enable standard CouchDB auth on a Cloudant DB

PUT _security-docs/_security-couchdb.json to youruser.cloudant.com/yourdbname/_security to enable standard CouchDB auth for that database.

curl -X PUT -d @_security-docs/_security-couchdb.json https://youruser.cloudant.com/yourdbname/_security

Example: Set your Cloudant user as CouchDB admin

When switching to CouchDB auth, it's useful to define the admin role as your existing Cloudant user. The admin user will be able to create/read/update/delete all other users in this database.

We can also limit this database to users which have a role "npm".

_security-docs/_security-cloudant.json

{
  "couchdb_auth_only": true,
  "admins": {
    "names": ["your-cloudant-username"],
    "roles": ["_admin"]
  },
  "members": {
    "names": [],
    "roles": ["npm"]
  }
}

Revert to Cloudant auth on a Cloudant DB

PUT _security-docs/_security-cloudant.json to youruser.cloudant.com/yourdbname/_security to reset auth to Cloudant management for that database.

curl -X PUT -d @_security-docs/_security-cloudant.json https://youruser.cloudant.com/yourdbname/_security

Create a user with any set of roles

Example scripts to add a user to Cloudant. Create one of these scripts and run with coffee scriptname.coffee or node scriptname.js.

Server options are passed directly to cradle.

CoffeeScript

CloudantUser = require "cloudant-user"

server =
  host: your-cloudant-user.cloudant.com
  port: 443
  secure: true
  auth:
    username: "your-admin-username"
    password: "your-admin-password"

newuser =
  name: "your-newuser-name"
  password: "your-newuser-pass"
  roles: ["_reader","_writer"]

callback = (err, res) ->
    console.log err if err
    console.log res if res

cloudantUser = new CloudantUser server
cloudantUser.create newuser.name, newuser.password, newuser.roles..., callback

JavaScript

var CloudantUser = require("cloudant-user");

var server = {
  host: your-cloudant-user.cloudant.com,
  port: 443,
  secure: true,
  auth: {
    username: "your-admin-username",
    password: "your-admin-password"
  }
};

var newuser = {
  name: "your-newuser-name",
  password: "your-newuser-pass",
  roles: ["_reader", "_writer"]
};

var callback = function(err, res) {
  if (err) console.log(err);
  if (res) return console.log(res);
};

var cloudantUser = new CloudantUser(server);
cloudantUser.create(newuser.name,
                    newuser.password,
                    newuser.roles[0],
                    newuser.roles[1],
                    callback);

cloudantUser.npmCreate()

Create a user with email (required by npm)

npmCreate(username, password, email, roles..., callback)

cloudantUser.createWithMeta()

Create a user with arbitrary metadata

metadata =
  shrike: true
  timewarp: false

createWithMeta(username, password, email, roles..., metadata, callback)

Extra help

Users need to change their own password

On Cloudant, a user without both roles "_reader" and "_writer" will be unable to change their password. Therefore, all normal users should be created with these roles.

Futon on Cloudant

Futon is available for any Cloudant database at https://cloudant.com/futon . Login there with your Cloudant account username and password.

Contributors

This module is originally based off of a gist by weilu.

License

Copyright 2014-2016 doublerebel. MIT licensed.