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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ndiinginc/cert

v3.0.0

Published

Utility ringan untuk generate Root CA dan sertifikat SSL/TLS per-hostname secara dinamis, dibangun di atas [`node-forge`](https://github.com/digitalbazaar/forge). Cocok untuk kebutuhan MITM proxy, dev server HTTPS lokal, atau tooling yang butuh generate s

Readme

@ndiinginc/cert

Utility ringan untuk generate Root CA dan sertifikat SSL/TLS per-hostname secara dinamis, dibangun di atas node-forge. Cocok untuk kebutuhan MITM proxy, dev server HTTPS lokal, atau tooling yang butuh generate sertifikat on-the-fly.

Instalasi

npm install @ndiinginc/cert

Fitur

  • Generate Root CA (self-signed) lengkap dengan private key, public key, dan sertifikat dalam format PEM.
  • Generate sertifikat leaf untuk suatu hostname/domain, ditandatangani oleh Root CA.
  • Deteksi otomatis apakah target berupa IP address atau domain name, lalu set subjectAltName (SAN) yang sesuai (type: 7 untuk IP, type: 2 untuk DNS name).
  • Serial number sertifikat leaf dihasilkan secara deterministik dari MD5 hash domain, sehingga sertifikat untuk domain yang sama konsisten.
  • Masa berlaku sertifikat: notBefore mundur 1 hari dari sekarang, notAfter maju 824 hari (sesuai batas maksimum umum browser modern).

Penggunaan

1. Generate Root CA

const { generateRootCA } = require("@ndiinginc/cert");

const rootCA = generateRootCA("My Root CA");
// rootCA.privateKey  -> PEM string
// rootCA.publicKey   -> PEM string
// rootCA.certificate -> PEM string

Root CA ini perlu di-install/trust di sistem/browser client agar sertifikat leaf yang ditandatangani olehnya dianggap valid.

2. Generate sertifikat untuk hostname

const { generateCertsForHostname } = require("@ndiinginc/cert");

const rootCA = generateRootCA("My Root CA");

const leafCert = generateCertsForHostname("example.com", {
    cert: rootCA.certificate,
    key: rootCA.privateKey,
});

// leafCert.privateKey  -> PEM string
// leafCert.publicKey   -> PEM string
// leafCert.certificate -> PEM string

Fungsi ini juga menerima IP address sebagai target:

const leafCert = generateCertsForHostname("192.168.1.10", {
    cert: rootCA.certificate,
    key: rootCA.privateKey,
});

3. Contoh pemakaian dengan HTTPS server

const https = require("https");
const { generateRootCA, generateCertsForHostname } = require("@ndiinginc/cert");

const rootCA = generateRootCA();
const { privateKey, certificate } = generateCertsForHostname("localhost", {
    cert: rootCA.certificate,
    key: rootCA.privateKey,
});

https.createServer({ key: privateKey, cert: certificate }, (req, res) => {
    res.end("Hello over HTTPS");
}).listen(443);

API

generateRootCA(commonName?: string)

Membuat sertifikat Root CA self-signed.

| Parameter | Tipe | Default | Keterangan | |---------------|--------|----------------|---------------------------------| | commonName | string | "CertManager"| Common Name (CN) untuk Root CA |

Return { privateKey, publicKey, certificate } — semua dalam format PEM string.

generateCertsForHostname(domain: string, rootCAConfig: { cert: string, key: string })

Membuat sertifikat leaf untuk sebuah domain atau IP, ditandatangani oleh Root CA yang diberikan.

| Parameter | Tipe | Keterangan | |---------------------|--------|----------------------------------------------| | domain | string | Hostname atau IP address | | rootCAConfig.cert | string | Sertifikat Root CA (PEM) | | rootCAConfig.key | string | Private key Root CA (PEM) |

Return { privateKey, publicKey, certificate } — semua dalam format PEM string.

Detail Subject

Sertifikat yang dihasilkan (baik Root CA maupun leaf) menggunakan atribut subject default berikut, ditambah commonName sesuai parameter:

[
  { name: "countryName", value: "US" },
  { shortName: "ST", value: "California" },
  { name: "organizationName", value: "My Company Inc" },
  { shortName: "OU", value: "Engineering" },
]

Sesuaikan nilai-nilai ini di source jika dibutuhkan branding/identitas organisasi yang berbeda.

Dependencies

Lisensi

MIT