mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-28 06:53:42 +08:00
X25519 KeyObjects come from generateKeyPair(Sync)("x25519"), which keeps
the private key clamped as OpenSSL does, and from createPrivateKey and
createPublicKey of PKCS#8, SubjectPublicKeyInfo, JWK (OKP, X25519) and
raw keys. They export in the same forms. sign, verify, createSign and
createVerify throw OpenSSL's "operation not supported for this keytype",
with its library, reason and code properties. X25519 uses mbedTLS's
Curve25519 group.
crypto.diffieHellman({ privateKey, publicKey }[, callback]) computes the
X25519 and ECDH secrets of two keys of one type, given as KeyObjects or
in any form createPrivateKey and createPublicKey read. The checks run in
Node's order: the options, the callback, both keys present, the key types
when both are KeyObjects ("Incompatible key types for Diffie-Hellman"),
then the public and private key inputs. Mismatched curves, a small-order
X25519 point and key types other than EC and X25519 throw OpenSSL's
errors. The callback form passes the secret, or the error without the
OpenSSL properties, in a later macrotask, as Node's DHBitsJob does.
createPublicKey also reads a private key's DER encodings (pkcs8 and
sec1), which Node accepts there.
node-types fixture
A project whose node_modules contains @types/node — the adoption path for real-world Node/TypeScript projects. The vendored node_modules are COMMITTED TEST DATA, pinned so the type surface (and therefore the pinned diagnostics) never drifts with the registry:
@types/node24.13.3undici-types7.18.2 (its dependency — declares the web-platform globals: fetch/Response/AbortSignal/ReadableStream/...)
What the fixture pins (see tests/harness/project-config.test.ts):
argv-env.ts— the SUPPORTED process surface (argv, env) typed by @types/node lowers statically and the binary runs: with @types/node present, the shipped fallback declarations forprocess/node:fs/consolestand down (their types come from @types/node), but the same members lower to the same libCalls, recognized by name + @types/node provenance.fenced.ts— surface @types/node DECLARES but scriptc does not lower (process.uptime, Buffer.from, setInterval) reports the SC2020-family fence naming @types/node, instead of typechecking its way into a broken binary — and never a raw "Cannot find name" error.event-loop-metrics.tsandtimeout-type.ts— performance.eventLoopUtilization, monitorEventLoopDelay's IntervalHistogram and NodeJS.Timeout as declared types lower under @types/node exactly as under the fallback declarations.source-import/— an imported TypeScript source may use theRequestInfoglobal supplied by TypeScript's default DOM lib while scriptc adopts the project's @types/node declarations.
Projects WITHOUT @types/node (every other fixture and the whole corpus) keep the shipped fallback declarations and behave exactly as before.