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

rfc2253

v0.2.0

Published

LDAPv3 Distinguished Name parser and formatter.

Downloads

9,386

Readme

rfc2253 is a parser and formatter for X.500/X.501 distinguished names based on RFC 2253 as used in LDAPv3 and SSL certificates.

license - MIT Dependencies

NPM status

Install

This module requires an ES2015 (formerly known as ES6) compatible Map implementation to be globally available. For older versions of Node.js you may have to use an appropriate shim, e.g. core-js.

With NPM

npm install rfc2253

From source

git clone https://github.com/foss-haas/rfc2253.git
cd rfc2253
npm install
npm run dist

API

parse

Parses an RFC 2253 string representation of a distinguished name and returns a DistinguishedName object.

Arguments

  • str: string

    A UTF-8 encoded distinguished name.

Examples

const str = 'CN=Wayne\\, Bruce,DC=Wayne Enterprises';
let dn = rfc2253.parse(str);
dn.get('DC'); // 'Wayne Enterprises'
str === dn.format(); // true

format

Formats a DistinguishedName or RelativeDistinguishedName instance according to RFC 2253 and returns a UTF-8 encoded string.

Arguments

  • dn: DistinguishedName or RelativeDistinguishedName

    The distinguished name or relative distinguished name to format as a string.

Examples

TODO

escape

Escapes an attribute key or value and returns the escaped string.

Arguments

  • value: any

    The value to escape. If the value is a Buffer it will be formatted as an octothorpe (#) followed by the hexadecimal representation of each byte in the buffer. Otherwise the value will be converted to a string and escaped according to RFC 2253.

Examples

rfc2253.escape(' "hello", <world> '); // '\\ \\"hello\\"\\, \\<world\\>\\ '
rfc2253.escape(new Buffer([1,2,3,16,255])); // '#01020310ff'

class DistinguishedName

Represents a distinguished name consisting of zero or more relative distinguished names.

match

Determines whether the given DistinguishedName is identical with this DN. Returns true if both DNs contain the same number of RDNs in the same order and each pair of RDNs shares exactly the same keys and values (regardless of order). Returns false otherwise.

Arguments

  • dn: DistinguishedName

    Another DistinguishedName to compare to.

Example

let dn1 = rfc2253.parse(str);
let dn2 = rfc2253.parse(str);
dn1.match(dn2); // true
dn2.match(dn1); // true

format

Formats this DN according to RFC 2253. Equivalent to passing the DN to the format function.

Examples

TODO

toString

Converts the DN to a human-readable string representation. Note that RDNs will appear in reverse order.

Examples

TODO

has

Checks whether a RelativeDistinguishedName exists for the given offset or whether any of the RDNs has the given key.

Arguments

  • key: any

    If key is a number, it is the offset of a RelativeDistinguishedName. Otherwise it is a key in at least one RDN.

Examples

TODO

get

Returns the RelativeDistinguishedName at the given offset or looks up the given key and returns the first value.

Arguments

  • key: any

    If key is a number, it is the offset of a RelativeDistinguishedName. Otherwise it is a key in at least one RDN.

Examples

let dn = rfc2253.parse('CN=Wayne\\, Bruce,DC=Wayne Enterprises');
dn.get('DC'); // 'Wayne Enterprises'
let rdn = dn.get(0); // <RelativeDistinguishedName>
rdn.get('CN'); // 'Wayne, Bruce'

getAll

Looks up the given key and returns all values.

Arguments

  • key: string

    The key in at least one RDN.

Examples

let dn = rfc2253.parse('CN=Wayne\\, Bruce,DC=Wayne Enterprises,DC=com,OU=Research and Development,OU=Gadget Services');
dn.getAll('OU'); // ['Research and Development', 'Gadget Services']
dn.getAll('DC'); // ['Wayne Enterprises', 'com']

set

Sets the given offset to the given RelativeDistinguishedName or sets the given key to the given value.

If the key does not yet exist on any of the RDNs, a new RelativeDistinguishedName will be created for the given key and value and appended to the DN.

Arguments

  • key: any

    If key is a number, it is the offset of the RelativeDistinguishedName. Otherwise it is the key in a RelativeDistinguishedName.

  • value: any

    If key is a number, this is the RelativeDistinguishedName the given offset will be set to. Otherwise this is the value the key will be set to.

Examples

TODO

delete

TODO

push

TODO

pop

TODO

unshift

TODO

shift

TODO

count

Returns the number of RDNs that are part of this DN. Also available as the size property.

RelativeDistinguishedName

TODO

match

TODO

format

TODO

toString

TODO

has

TODO

get

TODO

set

TODO

delete

TODO

count

Returns the number of attributes of this RDN. Also available as the size property.

License

The MIT/Expat license. For more information, see http://foss-haas.mit-license.org/ or the accompanying LICENSE file.