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

validate-direct-address

v2.0.2

Published

This package validates that "email" addresses are in fact DirectTrust addresses.

Downloads

59

Readme

validate-direct-address

Validates a Direct Trust email address. The main purpose in developing this library is to prevent users from entering email addresses in as direct addresses.

To be clear, validation with this library checks that an email address is a DirectTrust address. It does not guarantee that messages sent to that address will be delivered or that the receiving system will process it correctly. More importantly, while it confirms that the certificate appears to be signed by a CA in the trust bundle, it does not guarantee it. It's for validating input, not security.

It has not been tested (and probably won't work) in the browser environment.

USAGE

const {Validator} = require('validate-direct-address');

async main() {
   // use the default trust bundle, 1000ms timeout, 2 retries.  All options are optional
  const validator = new Validator(undefined, 1000, 2);

  await validator.isValid('[email protected]'); // Returns 'false' because the domain certificate does not exist
  await validator.isValid('[email protected]'); // Returns 'true' because the domain certificate exists.
  await validator.assertValid('[email protected]'); // Throws an error.  Use this or isValid based on what fits your code
}

TESTS

We strive for 100% test coverage. To run them, run yarn test or npm run test.

METHOD

Assuming a direct address of "[email protected]":

  1. do a DNS lookup for a cert record for jsmith.direct.hospital.org. (Note that you must replace the '@' with a '.'. If this succeeds, go to step 4.
  2. do a DNS lookup for a cert record for direct.hospital.org. (Not the removal of the RHS of the address.) If this succeds, go to step 4.
  3. If you haven't yet gotten the certificate, exit.
  4. Using node crypto tools, decode the content of the cert record. You may need to play around with it to get it to work, but it is in X.509 format.
  5. The issuer "cn" of the certificate must be one of the organizations listed in the directTrust trust bundle, which can be downloaded from https://directtrust.org/trust-bundles/accredited-trust-bundle