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

@1password/password-rules-parser

v1.0.0

Published

Parser for Apple's password rules format: https://developer.apple.com/password-rules/

Downloads

12,287

Readme

Password Rules Parser

Context Free Grammar and PEGs

A context-free grammar (CFG) is a set of "production rules" that describe all the possible strings that can be formed in a given formal language. Production rules are simple replacements, and they can produce more than one result.

A Parsing Expression Grammar (PEG) is a CFG that will choose the first match and therefore is not ambiguous. The nitty-gritty about PEGs can be read in this paper.

Note that a PEG is not a parser, but it can be converted into one.

How to get a parser from a PEG

The grammar itself is the set of substitution rules. Depending on the target language for the parser, it is possible to add functions in that language to clean up and improve the output. These functions should not alter what the grammar produces (don't add if statements!) just the way it presents the answer.

PEG.js is the best and most user friendly option. It outputs a JavaScript parser. To obtain a JavaScript parser, install and configure PEG.js in your computer, or generate it with the online tool by pasting the code here. The online tool makes it easy to test different inputs, but these inputs are not part of the generated or downloaded parser.

If you need a parser in Go instead of JS, the answer is Pigeon. There's no online version so it needs to be configured in your computer.

Apple's Password Rule Validation Tool

Apple has implemented a standard syntax for addressing password rules.

The grammar ParserNoCharacterClass defines a subset of the above specs, in PEG.js. It does not allow custom character classes (for now). It allows 0 or more spaces between the different parts of the rule so, minlength: 15;required: upper, lower; will output the same content result as minlength:15;required:upper, lower;. It does not allow line breaks.

And the custom character classes?

A grammar that parses the full specs will be added soon. Later on, a Go version for it.