CodeSampleX

Exemple

bcryptjs 3.0.3: Handle the bcryptjs 3 major revision switch where genSalt and hash default silently to 2b revisions, clamp out-of-range rounds, and restrict package subpath exports

Échantillon vérifié pour npm bcryptjs 3.0.3: Handle the bcryptjs 3 major revision switch where genSalt and hash default silently to 2b revisions, clamp…

sha256:70583a22fda0b9a43aca2419197c61191453261a59934ff49df46aea0832ca04

Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré. Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes. MIT-0

Preuves d'exécution

L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.

Base de preuve
Contrat signé réussi
Reçus de vérification
2
Clés de signature qui l’ont compilé
2
Environnement déclaré node linux x64 node node npm

Environnements des exécutions de vérification

Environnement Contrat Étapes Exécution
node 22 · linux alpine/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-16
node 22 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-18

Cas

HOW
Objectif
Handle the bcryptjs 3 major revision switch where genSalt and hash default silently to 2b revisions, clamp out-of-range rounds, and restrict package subpath exports
Paquets
Symboles
  • bcrypt.genSaltSync
  • bcrypt.hashSync
  • bcrypt.compareSync
  • bcrypt.truncates
  • bcrypt.getRounds
  • bcrypt.getSalt
Environnement
node
Créé
2026-08-16T06:23:36Z

Contrat

  1. assert bcryptjs 3 defaults to generating "$2b$" salt and hash prefixes rather than the legacy "$2a$" prefix from bcryptjs 2, causing regex validators expecting "$2a$" to silently reject new hashes
  2. assert passing a minor revision argument to genSaltSync or hashSync is ignored because bcryptjs 3 hardcodes "$2b$" in genSaltSync, so generating "$2a$" requires providing an explicit custom "$2a$" salt string
  3. assert compareSync remains backward compatible with historical "$2a$" and "$2y$" hash strings by parsing the revision directly from the stored hash prefix
  4. assert genSaltSync silently clamps rounds below 4 up to 4 and rounds above 31 down to 31 while defaulting 0 to 10, whereas passing an explicit salt with rounds outside 4-31 to hashSync throws an Error
  5. assert bcryptjs 3 exports truncates() which reports truncation strictly at 72 UTF-8 bytes rather than string character length, causing multibyte strings beyond 72 bytes to collide under compareSync
  6. assert bcryptjs 3 declares an exports map restricting subpaths so require("bcryptjs/package.json") throws ERR_PACKAGE_PATH_NOT_EXPORTED

Fichiers

  • NOTES.md
  • csx.json
  • package-lock.json
  • package.json
  • src/index.mjs
  • test/contract.mjs

Télécharger l’artefact source (tar.gz)

Seeder d'origine

csx-seed