Repository navigation
Project Overhaul - #47
Merged
Merged
Conversation
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Port jsbn to TypeScript and ship it as a dual CJS + ESM package (plus an IIFE browser bundle) with bundled
.d.tsfiles, so consumers can drop@types/jsbn. The public and protected APIs stay compatible with existing callers (including node-forge).Fix long-standing runtime bugs along the way: always use the 28-bit
am3multiply kernel (no user-agent sniffing — this was breaking Node 21+navigatorand React Native), use a platform CSPRNG inSecureRandom.nextByteswhen one exists, and reduce negative values inmodInverseinstead of hanging.Add a GitHub Pages demo/benchmark (jsbn vs bn.js, big-integer, and bignumber.js) with a native-
BigIntfast path, plus CI, npm publish, and Pages deploy workflows.What’s in this branch
Four commits on top of
origin/master:src/, Vitest tests, tsup dual/IIFE builds, rewritten README + CHANGELOG,SECURITY.md, CI and release workflows. Version bump to 1.3.0.engines.nodeis>=18.docs/playground and in-browser benchmark; nativeBigIntpath for arithmetic; Pages deploy workflow.github-pagesenvironment block from the Pages workflow so deploy can run without that environment being configured.Compatibility notes
import { BigInteger, SecureRandom } from 'jsbn'import BigInteger from 'jsbn'require('jsbn').BigIntegercopyTo,fromString,am,Barrett, limb fields, etc.) remain for dependentsdist/+ changelog/security docs (no rawindex.jsat the package root)Test plan
npm ci && npm run typecheck && npm test && npm run buildrequire('./dist/index.cjs').BigIntegeradd10 + 32 === 42import { BigInteger } from './dist/index.js'same checkmodInverseon a negative value (-3mod2) returns1and does not hangSecureRandom.nextBytesfills a buffer without throwing in Nodedocs/index.htmlafternpm run pages:build) — run a few arithmetic ops and the benchmark suitev1.3.0to exercise the npm publish + GitHub Release workflow (needsNPM_TOKEN)