From 096216c15c9093301bc021dbdfb56ff7457e2213 Mon Sep 17 00:00:00 2001 From: Henry Date: Tue, 4 Sep 2018 18:20:54 +0200 Subject: [PATCH] support SHA256 hashes --- lib/sources/NPMRegistrySource.js | 2 ++ lib/sources/Source.js | 3 +++ 2 files changed, 5 insertions(+) diff --git a/lib/sources/NPMRegistrySource.js b/lib/sources/NPMRegistrySource.js index b1647e8..41b90dc 100644 --- a/lib/sources/NPMRegistrySource.js +++ b/lib/sources/NPMRegistrySource.js @@ -171,6 +171,8 @@ NPMRegistrySource.prototype.toNixAST = function() { case "sha1": paramExpr.sha1 = this.sha1; break; + case "sha256": + paramExpr.sha256 = this.sha256; case "sha512": paramExpr.sha512 = this.sha512; break; diff --git a/lib/sources/Source.js b/lib/sources/Source.js index f20ded1..69a7391 100644 --- a/lib/sources/Source.js +++ b/lib/sources/Source.js @@ -108,6 +108,9 @@ Source.prototype.convertIntegrityStringToNixHash = function(integrity) { var hash = base64js.toByteArray(integrity.substring(5)); this.hashType = "sha1"; this.sha1 = new Buffer(hash).toString('hex'); + } else if(integrity.substr(0, 7) === "sha256-") { + this.hashType = "sha256"; + this.sha256 = integrity.substring(7); } else if(integrity.substr(0, 7) === "sha512-") { this.hashType = "sha512"; this.sha512 = integrity.substring(7);