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

hipstapas.core

v1.1.2

Published

Easy and unobtrusive generation of secure strings, uuids, passphrases (using EFF wordlists) and random numbers.

Downloads

4

Readme

hipstapas.core

Node.js CI

Easy and unobtrusive generation of secure strings, uuids, passphrases using EFF wordlists and random numbers.

This package is the core behind hipstapas.dev - the Hipster Password Helper As A Service, that lets you generate passphrases from anywhere in a second.

Table of content

Installation

This is a Node.js module.

Installation is done using the npm install command:

npm install hipstapas.core

Features

Quick Start

Import the module and call the generator (the default configuration values are documented in the Configuration Properties section):

  1. password
  2. uuid
  3. wordlist
  4. random
const hipstapasCore = require('hipstapas.core')

const password = hipstapasCore.password() 
// sample output: C7j|do]t!aj5r]#Od)&R+1UHC

const uuid = hipstapasCore.uuid()
// sample output: 43bf1afd-f9f5-4546-85ea-481b064d6d56

const wordlist =  hipstapasCore.wordlist()
// sample output: companion cope undermine tipoff calamari eternity

const random = hipstapasCore.random()
// sample output: 618554

Basic concepts

Input

Every method accepts an object as an input parameter, that has different configuration properties described in # Configuration options.

Validation

Every configuration property is of specific type and has a range of acceptable values. On each generation call, the passed values are validated regarding type and value range. If either of the two checks fails, the entire validation fails.

Output

The generation result is an object, that has three properties:

  • success: set to true if validation and generation were successful; false otherwise
  • result: an array with generated values when success = true
  • error: validation error description when success = false

Example of a successful uuid generation:

{
  success: true,
  result: [ '72e2aecd-3f5b-45c6-abe6-a438428822b3' ],
  error: ''
}

Examples of a failed uuid generation:

// wrong parameter type
{
  success: false,
  result: [],
  error: "Only numbers between 1 and 100 are allowed as values for the query parameter 'resultsCount'."
}
// wrong value range
{
  success: false,
  result: [],
  error: "The value of the query parameter 'resultsCount' must be between 1 and 100."
}

Configuration properties

One configuration property is supported by every generator:

|Parameter name|Type|Allowed values|Default value| |----|----|----|----| |resultsCount|Number|1..100|1| |Defines how many results should be generated at once|

password

|Parameter name|Type|Allowed values|Default value| |----|----|----|----| |alphabetSmall|Boolean|true..false|true| |If set to true the generation alphabet contains small characters: abcdefghijklmnopqrstuvwxyz| |alphabetCapital|Boolean|true..false|true| |If set to true the generation alphabet contains capital characters: ABCDEFGHIJKLMNOPQRSTUVWXYZ| |alphabetNumber|Boolean|true..false|true| |If set to true the generation alphabet contains numbers: 0123456789| |alphabetSpecial|Boolean|true..false|true| |If set to true the generation alphabet contains special characters: .,+-*/!?;:{}()[]%$&~#@|| |lengthMin|Number|1..2048|16 |Defines the minimal length of the generated phrase| |lengthMax|Number|1..2048|32 |Defines the maximal length of the generated phrase| |resultsCount|Number|1..100|1| |Defines how many results should be generated at once|

uuid

|Parameter name|Type|Allowed values|Default value| |----|----|----|----| |resultsCount|Number|1..100|1| |Defines how many results should be generated at once|

wordlist

|Parameter name|Type|Allowed values|Default value| |----|----|----|----| |words|Number|1..50|6| |Defines how many results should be generated at once| |resultsCount|Number|1..100|1| |Defines how many results should be generated at once|

random

|Parameter name|Type|Allowed values|Default value| |----|----|----|----| |min|Number|1..1048576|1| |Defines the lower bound of the number generator| |max|Number|1..1048576|1048576| |Defines the upper bound of the number generator| |sort|Boolean|true..false|false| |Sorts the generated number sequence| |noDuplicates|Boolean|true..false|false| |The generated number sequence should contain only unique numbers| |resultsCount|Number|1..100|1| |Defines how many results should be generated at once|

Examples

const fiftyPasswords = hipstapasCore.password({ resultsCount: 50 })
const fiftyUuids = hipstapasCore.uuid({ resultsCount: 50 })
const fiftyPassphrases = hipstapasCore.wordlist({ resultsCount: 50 })
const fiftyRandomNumbers = hipstapasCore.random({ resultsCount: 50 })

/*
- generate 10 passphrases at once
- where each phrase is exactly 5 characters long
- excluding special and capital characters = using only small characters and numbers
*/
const options = {
  resultsCount: 10,
  lengthMin: 5,
  lengthMax: 5,
  alphabetSpecial: false,
  alphabetCapital: false
}
const passwords = hipstapasCore.password(options)
/* sample output:
{
  success: true,
  result: [
    '1p9d7', 'h88a2',
    'j6yzp', 'fftkg',
    '8d40c', 'uqp3q',
    'yj9wc', 'qjsch',
    'qnlrk', 'men3u'
  ],
  error: ''
}
*/

/*
- generate 5 random numbers at once
- every number should be >= 10 and <= 100
- sort the result sequence
- there should be no duplicates in the result sequence
*/
const optionsRandom = {
  resultsCount: 5,
  min: 10,
  max: 100,
  sort: true,
  noDuplicates: true
}
const randomNumbers = hipstapasCore.random(optionsRandom)
/* sample output: 
{ 
  success: true, 
  result: [ 30, 35, 52, 86, 88 ], 
  error: '' 
}
*/

License

MIT License