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

protectedlib

v1.0.1

Published

Add ssh keys to your project, and set it in your environment before install

Downloads

8

Readme

protectedlib

Environments

  • node.js (>=8)
  • all unix-like operating systems

Usage

Add your private packages to package.json

"dependencies": {
  "myprotectedlib1": "[email protected]:r-berto811/myprotectedlib1.git#0.0.1"
}

Create keys folder

Create a folder in the root of your project, that will contain all your ssh keys:

  $ mkdir ssh

Generate new ssh key

  $ ssh-keygen -t rsa -b 4096 -C "[email protected]"
  • Replace the email address with your real email address.
  • When prompted with a location to save the generated keys, don’t overwrite your existing SSH key!!! Save your key to folder, created in prev step.
  • It is best practice to call your generated key file as name of the package, for which it is generated
  • Don’t add a passphrase to the key.

GitHub/GitLab/Bitbucked

Set up your newly generated public key in your GitHub/GitLab/Bitbucked profile or in repository settings.

It is recommended to grant "read only" rights, in order to protect your data

Install library

  $ npm install --save privalelib

Set up your packages data

There are two ways to set you packages configuration data

  1. Just create protected.json file in the root of your project:
  {
    "keys_dir": "./ssh",
    "packages": {
      "myprotectedlib1": {
        "host": "github.com",
        "key_file": "myprotectedlib1"
      },
      "myprotectedlib2": {
        "host": "gitlab.com",
        "key_file": "myprotectedlib2"
      }
    }
  }
  1. Set as options in init method:
const protectedlib = require('protectedlib').init({
  keys_dir: './ssh',
  packages: {
    myprotectedlib1: {
      host: 'github.com',
      key_file: 'myprotectedlib1'
    },
    myprotectedlib2: {
      host: 'gitlab.com',
      key_file: 'myprotectedlib2'
    }
  }
})
// or you can load from your custom file
const fs = require('fs')
const protectedlib = require('protectedlib').init(JSON.parse(fs.readFileSync('your/custom/file', 'utf-8')))

Create preinstall and postinstall bin files

To make the keys automatically added and removed during installation, create preinstall and postinstall scripts

  • preinstall
  #!/usr/bin/env node

  // config will be loaded from protected.json
  const protectedlib = require('protectedlib').init()
  protectedlib.addKeys()
  • postinstall
  #!/usr/bin/env node

  // config will be loaded from protected.json
  const protectedlib = require('protectedlib').init()
  protectedlib.removeKeys()

Add preinstall and postinstall commands to package.json

  "scripts": {
    "preinstall": "npm i protectedlib && node ./preinstal",
    "postinstall": "node ./postinstall"
  }

Custom location of your system .ssh folder

By default you .ssh folder location is ~/.ssh If you want to add your custom location of .ssh folder, just create .sshlocation file in the root of your project with full path to your custom folder.

Don't forget to add your .sshlocation to gitignore