forge

A native, pure-JavaScript implementation of TLS and PKI cryptography for building crypto-based Node.js and browser apps.

Library
npm
v1.4.0
5,342 stars
(BSD-3-Clause OR GPL-2.0)

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
60 /100 Good
Development Activity 44
Maintenance 8
Community 88
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
63 /100 Good
Architecture 68
Code Quality 58
Innovation 55
Learning Curve 70

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 forge module 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 17 apps in this directory

TypeScript
99%
Apache 2.0

Mastra Code

AI Code Assistants

29,041

"A coding agent that never compacts" — a terminal-based AI coding agent built on the Mastra framework, with Observational Memory instead of context compaction, multi-model support, and OAuth login for Claude Max or ChatGPT Plus.

View details
90
Repo Health
73
Technical
65
Dependency
Built with
TypeScript 99%
Updated 5 days ago
TypeScript
95%
MIT

melty

AI Code Assistants · Code Editors · Developer Tools

5,462

The AI code editor where every chat message is a git commit you can revert, branch, or squash

View details
35
Repo Health
75
Technical
67
Dependency
Built with
TypeScript 95%
Updated 1 years ago
JavaScript
90%
Other

OpenSign

Digital Signiture

7,163

Self-host a full-featured DocuSign alternative with unlimited e-signatures, multi-signer workflows, and cryptographic PDF signing.

View details
83
Repo Health
61
Technical
69
Dependency
Built with
JavaScript 90%
Updated 6 days ago
TypeScript
92%
Other

Suna

AI Agents

20,306

Turn your company into a git repo — one config, one command center, a workforce of AI agents that runs the real work around the clock.

View details
90
Repo Health
79
Technical
65
Dependency
Built with
TypeScript 92%
Updated 5 days ago
Go
75%
AGPL 3.0

Teleport

Authentication · Security

21,016

Zero-trust infrastructure access platform that replaces credentials and VPNs with short-lived certificates, SSO, and identity-aware proxies for SSH, Kubernetes, databases, RDP, and AI agents.

View details
94
Repo Health
81
Technical
68
Dependency
Built with
Go 75%
TypeScript 16%
Updated 1 weeks ago
Python
73%
Apache 2.0

Unsloth

AI Assistants · AI Development

78,493

Run and fine-tune LLMs, diffusion, audio and embedding models on your own hardware, from a native desktop app, a browser UI, or a Python library.

View details
89
Repo Health
83
Technical
70
Dependency
Built with
Python 73%
TypeScript 22%
Updated 5 days ago
TypeScript
95%
Apache 2.0

Void

AI Code Assistants · Automation · Code Editors

28,733

Open-source AI code editor with direct LLM integration and data privacy

View details
44
Repo Health
84
Technical
68
Dependency
Built with
TypeScript 95%
Updated 4 months ago
Go
74%
AGPL 3.0

ZITADEL

Authentication

15,418

Open-source, API-first identity platform delivering multi-tenancy, Passkeys, OIDC, SAML, and SCIM without vendor lock-in.

View details
92
Repo Health
81
Technical
65
Dependency
Built with
Go 74%
TypeScript 12%
Updated 6 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers