mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-28 06:53:42 +08:00
crypto.createECDH returns a native ECDH handle backed by mbedTLS for prime192v1, secp224r1, prime256v1, secp384r1, secp521r1, secp192k1, secp224k1, secp256k1, brainpoolP256r1, brainpoolP384r1 and brainpoolP512r1. generateKeys, computeSecret, getPublicKey, getPrivateKey, setPrivateKey, setPublicKey and ECDH.convertKey follow Node 24: compressed, uncompressed and hybrid points, input and output encodings, the private key range, key pair validation, and Node's error codes and messages. Curve names follow OpenSSL's short-name lookup: names of other curves from crypto.getCurves() are refused at compile time when literal and throw a coded SC2020 error when computed, other OpenSSL short names throw ERR_CRYPTO_OPERATION_FAILED, and unknown names throw ERR_CRYPTO_INVALID_CURVE. Calls whose arguments no @types/node overload accepts, and computeSecret(view, encoding), are refused at compile time. The runtime unit scr_ecdh.c links, with the mbedTLS archive, only into programs that use ECDH. wasm32-wasi builds refuse it.
51 lines
2.0 KiB
JavaScript
51 lines
2.0 KiB
JavaScript
import { withWorkerRuntimeVariants } from "../runtime-pack-common/worker-matrix.mjs";
|
|
import { withLibraryRuntimeFlavors } from "../runtime-pack-common/library-matrix.mjs";
|
|
import {
|
|
BASE_RUNTIME_SOURCES,
|
|
OPTIONAL_RUNTIME_SOURCES,
|
|
variantsFor,
|
|
} from "../runtime-pack-common/runtime-pack-matrix.mjs";
|
|
|
|
/**
|
|
* The executable runtime-pack matrix. This is the single source of truth for
|
|
* both release compilation and the generated feature predicates consumed by
|
|
* the compiler. A predicate is intentionally data, not JavaScript, so the
|
|
* installed compiler can validate and evaluate it deterministically.
|
|
*/
|
|
|
|
const any = (...features) => ({ any: features });
|
|
|
|
// ld64 dead-strips Mach-O symbol subsections without an ELF-style compile
|
|
// flag. Keep this checked-in metadata alongside the matrix so pack build and
|
|
// source/external linking share one documented executable recipe.
|
|
export const EXECUTABLE_SECTION_ELIMINATION = {
|
|
compile_flags: [],
|
|
link_flags: ["-Wl,-dead_strip"],
|
|
};
|
|
|
|
export const RUNTIME_PACK_MATRIX = withLibraryRuntimeFlavors(
|
|
withWorkerRuntimeVariants({
|
|
schema: "scriptc.runtime-pack-matrix.v1",
|
|
target: {
|
|
name: "macos-arm64",
|
|
llvm_triple: "arm64-apple-macosx14.0.0",
|
|
architecture: "arm64",
|
|
object_format: "macho",
|
|
minimum_os: "14.0",
|
|
},
|
|
flavors: { release: { optimization: "-O2" }, dev: { optimization: "-O0" } },
|
|
executable_section_elimination: EXECUTABLE_SECTION_ELIMINATION,
|
|
runtime_units: [
|
|
...BASE_RUNTIME_SOURCES.map((source) => ({ source, predicate: true })),
|
|
...OPTIONAL_RUNTIME_SOURCES.map(([source, predicate]) => ({ source, predicate })),
|
|
].map((unit) => ({ ...unit, variants: variantsFor(unit.source) })),
|
|
archives: [
|
|
{ id: "quickjs", predicate: false },
|
|
{ id: "libregexp", predicate: "regex" },
|
|
{ id: "zlib", predicate: "zlibEffective" },
|
|
{ id: "mbedtls", predicate: any("tlsEffective", "cipher", "ecdh") },
|
|
],
|
|
system_libraries: [{ name: "System", predicate: true }],
|
|
}),
|
|
);
|