mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 15:03:28 +00:00
prefetch-npm-deps: switch to data-encoding
This commit is contained in:
parent
c588edaf25
commit
ddb94deafa
14
pkgs/build-support/node/fetch-npm-deps/Cargo.lock
generated
14
pkgs/build-support/node/fetch-npm-deps/Cargo.lock
generated
@ -93,12 +93,6 @@ dependencies = [
|
|||||||
"rand",
|
"rand",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "base64"
|
|
||||||
version = "0.22.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "1.3.2"
|
version = "1.3.2"
|
||||||
@ -239,6 +233,12 @@ dependencies = [
|
|||||||
"windows-sys 0.52.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "data-encoding"
|
||||||
|
version = "2.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "digest"
|
name = "digest"
|
||||||
version = "0.10.7"
|
version = "0.10.7"
|
||||||
@ -592,7 +592,7 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"backoff",
|
"backoff",
|
||||||
"base64",
|
"data-encoding",
|
||||||
"digest",
|
"digest",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"isahc",
|
"isahc",
|
||||||
|
@ -8,7 +8,7 @@ edition = "2021"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.82"
|
anyhow = "1.0.82"
|
||||||
backoff = "0.4.0"
|
backoff = "0.4.0"
|
||||||
base64 = "0.22.0"
|
data-encoding = "2.5.0"
|
||||||
digest = "0.10.7"
|
digest = "0.10.7"
|
||||||
env_logger = "0.11.3"
|
env_logger = "0.11.3"
|
||||||
isahc = { version = "1.7.2", default_features = false }
|
isahc = { version = "1.7.2", default_features = false }
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use base64::prelude::{Engine, BASE64_STANDARD};
|
use data_encoding::BASE64;
|
||||||
use digest::{Digest, Update};
|
use digest::{Digest, Update};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sha1::Sha1;
|
use sha1::Sha1;
|
||||||
@ -60,16 +60,18 @@ impl Cache {
|
|||||||
integrity: Option<String>,
|
integrity: Option<String>,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
let (algo, hash, integrity) = if let Some(integrity) = integrity {
|
let (algo, hash, integrity) = if let Some(integrity) = integrity {
|
||||||
let (algo, hash) = integrity.split_once('-').unwrap();
|
let (algo, hash) = integrity
|
||||||
|
.split_once('-')
|
||||||
|
.expect("hash should be SRI format");
|
||||||
|
|
||||||
(algo.to_string(), BASE64_STANDARD.decode(hash)?, integrity)
|
(algo.to_string(), BASE64.decode(hash.as_bytes())?, integrity)
|
||||||
} else {
|
} else {
|
||||||
let hash = Sha512::new().chain(data).finalize();
|
let hash = Sha512::new().chain(data).finalize();
|
||||||
|
|
||||||
(
|
(
|
||||||
String::from("sha512"),
|
String::from("sha512"),
|
||||||
hash.to_vec(),
|
hash.to_vec(),
|
||||||
format!("sha512-{}", BASE64_STANDARD.encode(hash)),
|
format!("sha512-{}", BASE64.encode(&hash)),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use backoff::{retry, ExponentialBackoff};
|
use backoff::{retry, ExponentialBackoff};
|
||||||
use base64::prelude::{Engine, BASE64_STANDARD};
|
use data_encoding::BASE64;
|
||||||
use digest::Digest;
|
use digest::Digest;
|
||||||
use isahc::{
|
use isahc::{
|
||||||
config::{CaCertificate, Configurable, RedirectPolicy, SslOption},
|
config::{CaCertificate, Configurable, RedirectPolicy, SslOption},
|
||||||
@ -79,8 +79,5 @@ pub fn make_sri_hash(path: &Path) -> Result<String, NarError> {
|
|||||||
|
|
||||||
io::copy(&mut encoder, &mut hasher)?;
|
io::copy(&mut encoder, &mut hasher)?;
|
||||||
|
|
||||||
Ok(format!(
|
Ok(format!("sha256-{}", BASE64.encode(&hasher.finalize())))
|
||||||
"sha256-{}",
|
|
||||||
BASE64_STANDARD.encode(hasher.finalize())
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user