Files
next.js/turbopack/crates/turbo-tasks-fs/Cargo.toml
Niklas MischkulnigandGitHub 9404b901ab Turbopack: add Rope.content_hash and SHA hashing (#90235)
We want `FileContent.content_hash()` to only hash the content bytes. This is also needed to produce the correct hashes [for SRI](https://developer.mozilla.org/en-US/docs/Web/Security/Defenses/Subresource_Integrity)

However, the default `DeterministicHash` and `Hash` impls are ill-suited for that because they're a generic hashing infrastructure.
Hashing only the content bytes isn't what you want actually, otherwise `hash(("a", "b", "c"))`  would be the same as `hash("abc")`
https://doc.rust-lang.org/std/hash/trait.Hasher.html#method.write_str describes this problem as well

This is exactly what we want for Rope though, so this adds a `Rope.content_hash() -> impl DeterministicHash`.

Additionally, this changes `content_hash` to accept a HashAlgorithm to prepare for sha SRI hashes. This required changing the return type to `RcStr`, because of the variable hash lengths. But the return value was always `encode_hex`d everywhere anyway.
2026-02-20 22:25:22 +01:00

66 lines
1.7 KiB
TOML

[package]
name = "turbo-tasks-fs"
version = "0.1.0"
description = "TBD"
license = "MIT"
edition = "2024"
[lib]
bench = false
[[bench]]
name = "mod"
harness = false
[features]
default = []
# Enables dynamic linking (and hot reloading) of embedded files/dirs.
# A binary built with this option **is not portable**, the directory
# path will be embedded into the binary.
dynamic_embed_contents = []
[lints]
workspace = true
[dependencies]
anyhow = { workspace = true }
auto-hash-map = { workspace = true }
bincode = { workspace = true }
bitflags = "1.3.2"
bytes = { workspace = true }
concurrent-queue = { workspace = true }
dashmap = { workspace = true }
dunce = { workspace = true }
futures = { workspace = true }
include_dir = { version = "0.7.3", features = ["nightly"] }
indexmap = { workspace = true }
jsonc-parser = { version = "0.26.3", features = ["serde"] }
mime = { workspace = true }
notify = { workspace = true }
parking_lot = { workspace = true }
regex = { workspace = true }
rustc-hash = { workspace = true }
serde = { workspace = true, features = ["rc"] }
serde_json = { workspace = true }
serde_path_to_error = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }
triomphe = { workspace = true }
turbo-bincode = { workspace = true }
turbo-rcstr = { workspace = true }
turbo-tasks = { workspace = true }
turbo-tasks-hash = { workspace = true }
turbo-unix-path = { workspace = true }
urlencoding = { workspace = true }
[dev-dependencies]
criterion = { workspace = true, features = ["async_tokio"] }
rand = { workspace = true }
rstest = { workspace = true }
sha2 = { workspace = true }
tempfile = { workspace = true }
turbo-tasks-testing = { workspace = true }
turbo-tasks-backend = { workspace = true }