Commit Graph
663 Commits
Author SHA1 Message Date
LongYinan d907346d1d chore(deps): update dependency @napi-rs/cli to ^3.10.8 2026-10-06 17:56:26 +08:00
renovate[bot] 22926d9e3e chore(deps): update dependency oxfmt to ^0.72.0 (#1221)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-10-06 17:55:56 +08:00
LongYinanandDevin fe73c75332 feat!: redesign bcrypt API while preserving stored hash verification (#1207)
* feat!: redesign bcrypt creation API and narrow Argon2 verification options

* chore: keep major API changes scoped to bcrypt

* fix(bcrypt): preserve Node 10 and 12 runtime compatibility

* fix(bcrypt): support cancellation without global AbortController

* fix(bcrypt): polish the 2.0 API and packaging before release

- Settle the public Promise before removing the abort listener, and remove
  it with the same options, so throwing or capture-flag EventTargets cannot
  hang a call or leak the listener.
- Keep signal.reason as a non-enumerable AbortError cause, so callers can
  tell a TimeoutError or custom reason apart.
- Throw TypeError for option values of the wrong type and keep RangeError
  for out-of-range or malformed values.
- Copy only the 72 password bytes bcrypt reads for async work, and wipe
  those copies on drop; replace the unreachable!() salt branch.
- Declare package exports so internal files cannot be deep-imported.
- Stop declaring the WASI package as an optional dependency, so installs do
  not pull it and a missing native binary fails loudly.
- Leave the version bump to the release step, add the 2.0.0 changelog, and
  preapprove this repo's own @node-rs/* packages.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(bcrypt): keep the event loop alive while waiting for AbortSignal.timeout

AbortSignal.timeout() uses a timer that does not keep the event loop
alive, and the controlled backend has no native work that would. The
test passed only when other tests kept the worker busy, and failed with
"Promise returned by test never resolved" on the Linux and WASI jobs.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* chore: resolve bcrypt-previous from the registry

With the bcrypt workspace back at 1.10.9, yarn's transparent workspaces
link bcrypt-previous (npm:@node-rs/bcrypt@1.10.9) to the workspace
itself whenever the lockfile is regenerated, so the previous-release
tests would compare the new code with itself. No workspace depends on
another, so only the workspace: protocol needs to link workspaces.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* chore(bcrypt): regenerate bindings with @napi-rs/cli 3.10.5

main moved @napi-rs/cli from 3.9.0 to 3.10.5. Regenerate the bcrypt
loaders and type declarations from native and wasm32-wasip1-threads
builds so the committed files match what the release build produces.
binding.js still parses as ES2019 for Node 10 and 12.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(bcrypt): keep custom signal errors from breaking settled or aborted calls

A signal whose removeEventListener throws made a successful call raise an
unhandled rejection, which exits modern Node, and on abort it skipped the
native cancellation. A signal whose reason getter throws stopped the abort
listener before it settled, so the call stayed pending or resolved after
the abort. Ignore cleanup failures once the call has settled, and read the
optional reason defensively.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* feat(bcrypt): add parseOptions and Node-style error codes for 2.0

Bundle two more contract changes into the 2.0 break so the error and
rehash-on-login story is complete at release:

- Thrown errors carry Node-style codes: TypeError ERR_INVALID_ARG_TYPE,
  RangeError ERR_OUT_OF_RANGE (including native InvalidArg translations),
  and AbortError ABORT_ERR, matching Node's own AbortError.
- parseOptions(hash) returns { version, cost } through the verifier's
  parser (bcrypt::HashParts), so every hash verify accepts is parseable,
  including +4 costs and imported 2x labels; hashes verify always rejects
  throw RangeError. Mirrors argon2's parseOptions in this repo.
- AbortSignalLike.removeEventListener declares the options argument the
  adapter actually passes.
- Drop unused blowfish and quickcheck dependencies from the bcrypt crate
  and the workspace.

Native and wasm32-wasip1-threads bindings are regenerated. api.cjs still
parses as ES2019 for Node 10 and 12.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(bcrypt): tidy parseOptions review nits

- Use one options type for add/removeEventListener on AbortSignalLike,
  matching the comment that the same object is passed to both.
- Give parseOptions its own arity message; it never had positional
  options to drop.
- Cover the 60-byte non-ASCII parser branch in the test, which the
  previous 61-byte input missed.
- Mention in the README that parseOptions throws for hashes verify
  always rejects.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* feat(bcrypt): give the backend contract error a code

A stale platform package now fails at import time with
code ERR_BCRYPT_INCOMPATIBLE_BINARY, so every error the package throws
sits inside the documented ErrorCode contract.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* feat(bcrypt): switch hashing backend to bcrypt-rust

Replace the bcrypt 0.19 dependency with bcrypt-rust 1.0, keeping the crate
name so imports stay valid. The new crate is a drop-in for every API used
here except one deliberate difference: its HashParts parser is strict and
rejects the noncanonical '+4' cost spelling the old backend accepted.

Verify and parseOptions now use a lenient parser that mirrors the old
backend byte-for-byte (60 ASCII bytes, 2a/2b/2x/2y markers, u32::parse for
cost), then hand the canonicalized hash to bcrypt::verify so the cost gate
and constant-time compare stay in the library.

~20% faster than the C++ backend on hash and verify.

* bench: make benchmark comparisons 1:1 and migrate argon2 to tinybench

bcrypt: uniform call signatures via per-impl adapters, a fixed salt so the
hash suite measures hashing only, a real sync compare for verify (it
previously timed an unawaited async call with a hash inside the loop), one
cost across suites, all five implementations in every suite, and a compact
sorted table with latency, rme, ops/s, and a ratio to the baseline.

argon2: replace the hand-rolled performance.now() harness with tinybench
fixed-iteration runs, keep the per-iteration tag assertion and the
native-sync / native-async / js-wasm grouping, and adopt the same report
format.

* bench: narrow tinybench TaskResult before reading stats

TaskResult is a discriminated union; latency/throughput exist only on
completed and aborted-with-statistics. CI type-checks benchmark files
through packages/argon2/tsconfig.json, unlike oxnode which strips types.

* perf(bcrypt): fast-path genSaltSync options; note wasm salt overhead in bench comment

genSaltSync previously ran every call through options() + creation(),
allocating a fresh Object.create(null) copy even for {} and {cost}. Now
undefined uses a frozen empty options object and reusable options shapes
validate in place — identical error paths preserved for non-plain or
extra-key objects. Saves ~200ns of JS wrapper overhead per call.

* deps: bump bcrypt-rust to 1.0.1

Picks up the crypt_blowfish fused-round kernel shape
(Brooooooklyn/bcrypt-rust@f65cd90): bcrypt() at cost 10 on x86_64
drops ~19% (138.2ms -> 112.6ms vs vendored C at 108.7ms); arm64
unchanged.

* perf(bcrypt): cut genSaltSync overhead; pool OS entropy per thread

genSaltSync now serves 16-byte salts from a 256-byte thread-local pool
refilled by SysRng (direct getrandom), amortizing one syscall over 16
salts without any userspace PRNG in between. The salt string is built
without format! machinery and the bcrypt base64 engine is constructed
once in a LazyLock instead of per call.

api.cjs gains a specialized fast path for the {cost,version} shapes:
getOwnPropertyNames/getOwnPropertySymbols cover the same key space as
Reflect.ownKeys at half the cost, the sync() closure is inlined, and
anything the fast path cannot prove valid funnels into a shared full-
validation path so error types, codes, and messages stay identical.

x86_64 sandbox (30k-iteration amortized loop, best of reps):
  @node-rs/bcrypt ~380-560ns vs wasm OpenBSD ~550-730ns
  per-call min: 210-250ns vs 320-370ns; bench.js min 290ns vs 860ns.

* deps: bump bcrypt-rust to 1.0.2

Picks up the xor_late asm boundary (Brooooooklyn/bcrypt-rust#8): LLVM no
longer reassociates the fused round into two serial xors after the S-box
loads. On x86_64 EPYC the raw kernel now beats crypt_blowfish C
(~54.6ms vs ~54.9ms at cost 10) and JS hashSync/verifySync beat node
bcrypt (C++); arm64/wasm32 untouched via cfg fallback. CodSpeed: -4% on
all single-hash benches.

---------

Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-05 23:33:58 +08:00
renovate[bot] 9814527d02 chore(deps): lock file maintenance (#1220)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-10-05 15:27:38 +08:00
renovate[bot] c1d8de470c chore(deps): lock file maintenance (#1215) 2026-09-30 12:09:43 +00:00
renovate[bot] c118471ee5 chore(deps): update dependency oxfmt to ^0.71.0 (#1218)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-09-28 23:11:32 +00:00
renovate[bot] 84d621a480 chore(deps): update dependency oxfmt to ^0.70.0 (#1216)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-09-21 20:14:31 +00:00
renovate[bot] 20cce721bb chore(deps): update dependency oxfmt to ^0.68.0 (#1211)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-09-14 14:06:58 +00:00
renovate[bot] 9b4a4a06df chore(deps): lock file maintenance (#1210)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-09-14 13:21:00 +08:00
renovate[bot] bb467e8512 chore(deps): lock file maintenance (#1202)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-09-09 23:09:16 +08:00
renovate[bot] e692dfad3f chore(deps): update dependency oxfmt to ^0.67.0 (#1203)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-09-07 22:23:26 +00:00
renovate[bot] 1f53bf3ffb chore(deps): update dependency oxfmt to ^0.66.0 (#1198)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-09-01 16:44:17 +00:00
renovate[bot] cb6b2b2482 chore(deps): lock file maintenance (#1197) 2026-08-31 21:16:30 +08:00
renovate[bot] fa77f2849e chore(deps): update dependency oxfmt to ^0.65.0 (#1194)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-08-25 04:34:43 +00:00
renovate[bot] 15632e42f3 chore(deps): lock file maintenance (#1193)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-08-25 12:25:11 +08:00
renovate[bot] 635e750eb0 chore(deps): update dependency oxfmt to ^0.64.0 (#1191)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-08-18 16:20:03 +00:00
renovate[bot] af63ac2992 chore(deps): lock file maintenance (#1190) 2026-08-17 15:30:28 +08:00
renovate[bot] 64b9227bc4 chore(deps): lock file maintenance (#1182)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-08-13 17:13:29 +08:00
LongYinan 2b8b617be0 feat(argon2): switch backend to argon2-rust (#1188)
* feat(argon2): switch backend to argon2-rust

Replace RustCrypto argon2 with argon2-rust 1.0.0 from crates.io.
Keep the public JS API. Verify accepts node-argon2 PHC param order
and associatedData. The bench pins the same raw params, salt, and
tag across implementations.

* fix(argon2): keep Node 22 tests and bound verify threads

Skip the node:crypto.argon2Sync comparison on runtimes that lack it.
Cap worker threads at available parallelism so a PHC p= value cannot
spawn one OS thread per lane. Allocate tag buffers with try_reserve
instead of vec! so a huge outputLen is a JS error, not a process abort.

* fix(argon2): skip node-argon2 interop when its native addon is missing

node-argon2 0.45 has no darwin-x64 prebuild. Intel macOS CI runs x64
Node on an ARM host, so a static import crashed the whole spec file.

* test(argon2): compare against node:crypto argon2

Drop the node-argon2 native addon from tests. Interop uses the
builtin KDF, which is available on every CI host that has it.
2026-08-13 11:01:01 +08:00
LongYinan 1933745e96 chore: upgrade all npm deps (#1187)
* chore: upgrade all npm deps

* fix: update tsconfig for TypeScript 7

Remove deprecated downlevelIteration and importsNotUsedAsValues options,
and explicitly include node types required by TypeScript 7.

* fix: download test artifacts into package dirs

@napi-rs/cli 3.8 requires all configured targets when running
napi artifacts. Test jobs only have one platform, so download
bindings directly into the workspace like the package template.

* fix: download bindings into packages/ for tests

upload-artifact uses packages/ as the common root, so the artifact
contains argon2/*.node not packages/argon2/*.node. Download into
packages/ so binaries land where the loaders expect them.

* fix: add WASI .d.cts files required by @napi-rs/cli 3.8

napi artifacts now requires a complete WASI loader set including
*.wasi.d.cts. Also upload the full WASI support files from the wasm
build job for the publish path.

* fix: upload only wasm artifacts from WASI builds

WASI loaders and types stay committed in the repo and updated with
the codegen; CI only needs the built .wasm binaries.
2026-08-12 23:51:31 +08:00
renovate[bot] 284ee7075c chore(deps): update dependency oxfmt to ^0.63.0 (#1186)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-08-10 15:44:44 +00:00
renovate[bot] 54d5564d81 chore(deps): update dependency oxfmt to ^0.62.0 (#1183)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-08-03 13:20:02 +00:00
renovate[bot] 626c853e56 chore(deps): lock file maintenance (#1178) 2026-07-28 16:55:47 +08:00
renovate[bot] bf48de0466 chore(deps): update dependency oxfmt to ^0.61.0 (#1179)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-07-27 19:11:14 +00:00
renovate[bot] d13e2cd20d chore(deps): lock file maintenance (#1173) 2026-07-25 10:43:41 +08:00
renovate[bot] 07c7d14dd3 chore(deps): update dependency oxfmt to ^0.60.0 (#1174)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-07-21 23:56:06 +00:00
renovate[bot] 3ac4a59eaa chore(deps): lock file maintenance (#1168)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-07-16 10:33:25 +08:00
renovate[bot] 3c9ac9a5d4 chore(deps): update dependency oxfmt to ^0.59.0 (#1170)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-07-14 08:52:08 +00:00
renovate[bot] be829c4f6e chore(deps): update yarn to v4.17.1 (#1164)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-07-08 20:21:34 +00:00
renovate[bot] 84a2950255 chore(deps): update dependency oxfmt to ^0.58.0 (#1163)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-07-07 03:59:29 +00:00
renovate[bot] c51bb75564 chore(deps): lock file maintenance (#1162)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-07-06 11:37:06 +08:00
LongYinan d469a181e1 fix: yarn npmPreapprovedPackages 2026-06-30 12:11:53 +08:00
renovate[bot] 595e0d34e6 chore(deps): lock file maintenance (#1156)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-06-30 12:08:48 +08:00
renovate[bot] ac62938458 chore(deps): update dependency oxfmt to ^0.55.0 (#1154)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-06-16 14:47:12 +00:00
renovate[bot] 618ee1b41d chore(deps): update dependency @emnapi/wasi-threads to v2 (#1149)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-06-16 22:30:32 +08:00
renovate[bot] d1f42811fe chore(deps): update dependency npm-run-all2 to v9 (#1137)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-06-15 22:00:18 +08:00
renovate[bot] 7912277c70 chore(deps): lock file maintenance (#1142)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-06-15 18:38:05 +08:00
dependabot[bot] 4b0b14b68d chore(deps): bump shell-quote from 1.8.3 to 1.8.4 (#1151)
Bumps [shell-quote](https://github.com/ljharb/shell-quote) from 1.8.3 to 1.8.4.
- [Changelog](https://github.com/ljharb/shell-quote/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ljharb/shell-quote/compare/v1.8.3...v1.8.4)

---
updated-dependencies:
- dependency-name: shell-quote
  dependency-version: 1.8.4
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-06-15 14:54:12 +08:00
Copilot 20873f3352 fix(jieba): compile error: adapt to jieba-rs 0.10.1 Token API (#1152)
* fix: adapt jieba bindings to jieba-rs 0.10.1 Token API changes

* chore: update yarn.lock

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2026-06-15 12:20:58 +08:00
renovate[bot] b40d786973 chore(deps): update yarn monorepo to v4.16.0 (#1148)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-06-06 11:35:54 +00:00
renovate[bot] 9f17b637c7 chore(deps): update yarn to v4.15.0 (#1139)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-05-20 02:25:32 +00:00
renovate[bot] c023a0a3ad chore(deps): update dependency oxfmt to ^0.51.0 (#1138)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-05-19 11:50:41 +00:00
renovate[bot] 1f0389924d chore(deps): lock file maintenance (#1136)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-05-18 12:32:40 +08:00
renovate[bot] 03e4842db0 chore(deps): update dependency oxfmt to ^0.50.0 (#1134)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-05-15 17:09:25 +00:00
renovate[bot] 4234029812 chore(deps): update dependency oxfmt to ^0.49.0 (#1133)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-05-11 21:52:29 +00:00
renovate[bot] 1c19b6bdad chore(deps): lock file maintenance (#1131)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-05-11 10:45:29 +08:00
renovate[bot] 7b2b3e8fee chore(deps): update dependency lint-staged to v17 (#1129)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-05-11 10:45:02 +08:00
dependabot[bot] cfa712a065 chore(deps): bump fast-uri from 3.1.0 to 3.1.2 (#1130)
Bumps [fast-uri](https://github.com/fastify/fast-uri) from 3.1.0 to 3.1.2.
- [Release notes](https://github.com/fastify/fast-uri/releases)
- [Commits](https://github.com/fastify/fast-uri/compare/v3.1.0...v3.1.2)

---
updated-dependencies:
- dependency-name: fast-uri
  dependency-version: 3.1.2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-09 21:48:27 +08:00
renovate[bot] 4160ef5818 chore(deps): update dependency oxfmt to ^0.48.0 (#1128)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-05-05 16:22:49 +00:00
renovate[bot]andanthropic-code-agent[bot] c364489587 chore(deps): lock file maintenance (#1127)
* chore(deps): lock file maintenance

* chore(deps): update emnapi packages to latest (1.10.0)

Agent-Logs-Url: https://github.com/napi-rs/node-rs/sessions/eec16a0a-460d-4520-bf79-83494a584b1a

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: anthropic-code-agent[bot] <242468646+Claude@users.noreply.github.com>
2026-05-04 11:47:54 +08:00