forge
A native, pure-JavaScript implementation of TLS and PKI cryptography for building crypto-based Node.js and browser apps.
Repository Health
Technical Analysis
node-forge is a native JavaScript implementation of the TLS protocol along with a broad set of cryptographic primitives and PKI tooling, distributed as the node-forge npm package. It runs equally in Node.js and the browser, providing ciphers (AES, DES, RC2), message digests (MD5, SHA-1, SHA-256, SHA-384, SHA-512, HMAC), asymmetric cryptography (RSA, Ed25519, RSA-KEM), and a full ASN.1/X.509 stack for generating certificates, certificate signing requests, and PKCS#5/7/8/10/12 structures.
Beyond cryptography, forge includes higher-level networking tools — an HTTP client, SSH key handling, XHR and raw TCP/TLS socket wrappers, and a Flash-based networking fallback for pre-WebSocket browsers — reflecting its origin as a toolkit for building network-heavy web apps before native browser crypto and WebSocket APIs were universally available. It remains widely used today (tens of millions of weekly npm downloads) primarily for its X.509/PKI utilities: generating self-signed certificates, parsing CSRs, and working with PKCS#12 keystores in pure JavaScript without native bindings.
What You Get
- A single
forgemodule exposing ciphers, digests, PKI, and networking utilities under one namespace (forge.pki,forge.tls,forge.util, etc.) - Full X.509/ASN.1 support for generating and parsing certificates, CSRs, and PKCS#5/7/8/10/12 structures in pure JavaScript
- A complete set of symmetric ciphers (AES, DES, RC2) and message digests (MD5, SHA-1/256/384/512, HMAC) with no native dependencies
- Pre-built UMD browser bundles (forge.min.js, forge.all.min.js) via jsDelivr/webpack for drop-in use without a build step
- A Fortuna-based PRNG with Node
crypto-backed seeding when available, falling back to pure JavaScript in restricted environments
Common Use Cases
- Generating self-signed TLS certificates and CSRs entirely client-side or in a Node script
- Parsing and validating X.509 certificates and PKCS#12 keystores without shelling out to OpenSSL
- Implementing custom TLS clients/servers in environments without native TLS support
- Hashing and HMAC-signing payloads (SHA-256, SHA-512) in browser code where Web Crypto coverage is inconsistent
Under The Hood
Architecture
Each module attaches itself onto a single shared forge singleton (lib/forge.js) via forge.<name> = forge.<name> || {}, and lib/index.js requires every module file to populate it — a flat plugin-registration pattern rather than classes or dependency injection. Environment detection is pushed into leaf modules instead of centralized: prng.js checks forge.util.isNodejs and forge.options.usePureJavaScript to decide whether to seed from Node’s native crypto module or fall back to a pure-JS Fortuna implementation. Layering runs bottom-up from bignum/PRNG/util primitives, through ciphers and digests, up to the ASN.1/PKI/TLS stack (pki.js, x509.js, pkcs7.js, pkcs12.js, tls.js), but modules require concrete siblings directly rather than accepting injected implementations, so swapping a backend means monkey-patching forge.random rather than passing an alternative in.
Tech Stack
Pure JavaScript targeting ES5 (.eslintrc.js sets ecmaVersion: 5, sourceType: script), dual-published for Node (CommonJS) and the browser via a browser field that remaps buffer/crypto/process, with UMD bundles (forge.min.js, forge.all.min.js, prime.worker.min.js) built by webpack and also supporting Browserify. Tests run through Mocha on Node and Karma in-browser across both bundlers, exercised in CI across a wide Node matrix (6.x through 24.x). Build tooling (webpack ^4, karma ^1-4, mocha ^5) is pinned to older majors, favoring broad runtime compatibility over a modern toolchain.
Code Quality
The test suite (tests/unit/*.js) covers each primitive individually — digests, ciphers, RSA, X.509, CSR, PKCS#7/12, TLS, SSH, Ed25519, ASN.1, PEM, KEM — run under both Mocha and Karma, giving genuinely broad functional coverage. ESLint extends eslint-config-digitalbazaar, but the repository’s own lint CI job is commented out, and rules like no-unused-vars, no-var, and prefer-const are relaxed or disabled because the code intentionally targets ES5. There is no static typing and no TypeScript definitions bundled in the package itself; error handling is plain synchronous throw with descriptive messages rather than typed error classes.
API Design
A single forge namespace (forge.pki, forge.tls, forge.util, forge.random, …) avoids per-algorithm imports and gives every primitive a consistent .create()-style factory. The tradeoff is an API that predates modern JS idioms: it exposes its own ByteBuffer/binary-string abstractions (forge.util.createBuffer) rather than native Buffer/Uint8Array, and options are passed as plain objects rather than typed configs. A long, example-heavy README (2000+ lines) offsets some of the ramp-up cost this creates for newcomers.
Used by 16 apps in this directory
Appsmith
Developer Tools · Automation · No Code Platforms
Open-source low-code platform to build admin panels, dashboards, and internal tools connected to any database or API.
Countly
Analytics · Marketing
Privacy-first, self-hosted analytics and customer engagement platform with full data ownership, GDPR compliance, and AI-powered insights across mobile, web, desktop, and IoT.
Grafana
Monitoring · Analytics
The open-source observability platform that unifies metrics, logs, and traces from any data source into dynamic, queryable dashboards.
Huly Platform
Project Management · Team Chat · Collaboration
Open-source all-in-one workspace that replaces Linear, Jira, Slack, and Notion for product and engineering teams.
Infisical
Security · Devops
The open-source platform for secrets, certificates, privileged access, and AI agent security — all in one self-hostable system.
IT-Tools
Developer Tools
A unified collection of 88 web-based developer utilities — from JSON formatting to subnet calculation — all self-hostable, keyboard-searchable, and offline-ready.
Jitsu
Data Engineering
Open-source, fully-scriptable data ingestion engine that streams events from web, apps, and APIs to any data warehouse in real time.
Kibana
Analytics · Monitoring
Your open source window into the Elastic Stack — query, visualize, and act on data stored in Elasticsearch with real-time dashboards, AI-assisted search, and automated alerting.
Logto
Authentication
Open-source auth infrastructure for SaaS and AI apps with OIDC, SAML, and RBAC