about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--pkgs/build-support/node/fetch-npm-deps/Cargo.lock14
-rw-r--r--pkgs/build-support/node/fetch-npm-deps/Cargo.toml2
-rw-r--r--pkgs/build-support/node/fetch-npm-deps/src/cacache.rs10
-rw-r--r--pkgs/build-support/node/fetch-npm-deps/src/util.rs7
4 files changed, 16 insertions, 17 deletions
diff --git a/pkgs/build-support/node/fetch-npm-deps/Cargo.lock b/pkgs/build-support/node/fetch-npm-deps/Cargo.lock
index 71b9caba13d5..dcabca0aeafd 100644
--- a/pkgs/build-support/node/fetch-npm-deps/Cargo.lock
+++ b/pkgs/build-support/node/fetch-npm-deps/Cargo.lock
@@ -94,12 +94,6 @@ dependencies = [
 ]
 
 [[package]]
-name = "base64"
-version = "0.22.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51"
-
-[[package]]
 name = "bitflags"
 version = "1.3.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -240,6 +234,12 @@ dependencies = [
 ]
 
 [[package]]
+name = "data-encoding"
+version = "2.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5"
+
+[[package]]
 name = "digest"
 version = "0.10.7"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -592,7 +592,7 @@ version = "0.1.0"
 dependencies = [
  "anyhow",
  "backoff",
- "base64",
+ "data-encoding",
  "digest",
  "env_logger",
  "isahc",
diff --git a/pkgs/build-support/node/fetch-npm-deps/Cargo.toml b/pkgs/build-support/node/fetch-npm-deps/Cargo.toml
index bb164bc6a983..dcb7e28a49dd 100644
--- a/pkgs/build-support/node/fetch-npm-deps/Cargo.toml
+++ b/pkgs/build-support/node/fetch-npm-deps/Cargo.toml
@@ -8,7 +8,7 @@ edition = "2021"
 [dependencies]
 anyhow = "1.0.82"
 backoff = "0.4.0"
-base64 = "0.22.0"
+data-encoding = "2.5.0"
 digest = "0.10.7"
 env_logger = "0.11.3"
 isahc = { version = "1.7.2", default_features = false }
diff --git a/pkgs/build-support/node/fetch-npm-deps/src/cacache.rs b/pkgs/build-support/node/fetch-npm-deps/src/cacache.rs
index 8c6845d6ac5a..403c909dee11 100644
--- a/pkgs/build-support/node/fetch-npm-deps/src/cacache.rs
+++ b/pkgs/build-support/node/fetch-npm-deps/src/cacache.rs
@@ -1,4 +1,4 @@
-use base64::prelude::{Engine, BASE64_STANDARD};
+use data_encoding::BASE64;
 use digest::{Digest, Update};
 use serde::{Deserialize, Serialize};
 use sha1::Sha1;
@@ -60,16 +60,18 @@ impl Cache {
         integrity: Option<String>,
     ) -> anyhow::Result<()> {
         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 {
             let hash = Sha512::new().chain(data).finalize();
 
             (
                 String::from("sha512"),
                 hash.to_vec(),
-                format!("sha512-{}", BASE64_STANDARD.encode(hash)),
+                format!("sha512-{}", BASE64.encode(&hash)),
             )
         };
 
diff --git a/pkgs/build-support/node/fetch-npm-deps/src/util.rs b/pkgs/build-support/node/fetch-npm-deps/src/util.rs
index 76f15db03d46..023ba56793b9 100644
--- a/pkgs/build-support/node/fetch-npm-deps/src/util.rs
+++ b/pkgs/build-support/node/fetch-npm-deps/src/util.rs
@@ -1,5 +1,5 @@
 use backoff::{retry, ExponentialBackoff};
-use base64::prelude::{Engine, BASE64_STANDARD};
+use data_encoding::BASE64;
 use digest::Digest;
 use isahc::{
     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)?;
 
-    Ok(format!(
-        "sha256-{}",
-        BASE64_STANDARD.encode(hasher.finalize())
-    ))
+    Ok(format!("sha256-{}", BASE64.encode(&hasher.finalize())))
 }