Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-provenance-hash

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-provenance-hash - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

107

dist/main.js

@@ -39,58 +39,59 @@ "use strict";

exports.__esModule = true;
exports.makeHash = void 0;
var crypto_1 = require("crypto");
var fs_1 = require("fs");
var makeHash = function (sourceDirImages, sourceDirMetadata, sortingFunction) { return __awaiter(void 0, void 0, void 0, function () {
var jsonFiles, imageFiles, fullImgHash, _i, imageFiles_1, file, h, fullMetadataHash, _a, jsonFiles_1, file, h;
var _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
jsonFiles = sortingFunction
? (0, fs_1.readdirSync)(sourceDirMetadata)
: (0, fs_1.readdirSync)(sourceDirMetadata).sort(sortingFunction);
imageFiles = sortingFunction
? (0, fs_1.readdirSync)(sourceDirImages)
: (0, fs_1.readdirSync)(sourceDirImages).sort(sortingFunction);
fullImgHash = "";
_i = 0, imageFiles_1 = imageFiles;
_c.label = 1;
case 1:
if (!(_i < imageFiles_1.length)) return [3 /*break*/, 4];
file = imageFiles_1[_i];
return [4 /*yield*/, hash(sourceDirImages + "/" + file, true)];
case 2:
h = _c.sent();
fullImgHash += h;
_c.label = 3;
case 3:
_i++;
return [3 /*break*/, 1];
case 4:
fullMetadataHash = "";
_a = 0, jsonFiles_1 = jsonFiles;
_c.label = 5;
case 5:
if (!(_a < jsonFiles_1.length)) return [3 /*break*/, 8];
file = jsonFiles_1[_a];
return [4 /*yield*/, hash(sourceDirMetadata + "/" + file, true)];
case 6:
h = _c.sent();
fullMetadataHash += h;
_c.label = 7;
case 7:
_a++;
return [3 /*break*/, 5];
case 8:
_b = {};
return [4 /*yield*/, hash(fullImgHash, false)];
case 9:
_b.imagesProvenanceHash = _c.sent();
return [4 /*yield*/, hash(fullMetadataHash, false)];
case 10: return [2 /*return*/, (_b.metadataProvenanceHash = _c.sent(),
_b)];
}
function makeHash(sourceDirImages, sourceDirMetadata, sortingFunction) {
return __awaiter(this, void 0, void 0, function () {
var jsonFiles, imageFiles, fullImgHash, _i, imageFiles_1, file, h, fullMetadataHash, _a, jsonFiles_1, file, h;
var _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
jsonFiles = sortingFunction
? (0, fs_1.readdirSync)(sourceDirMetadata)
: (0, fs_1.readdirSync)(sourceDirMetadata).sort(sortingFunction);
imageFiles = sortingFunction
? (0, fs_1.readdirSync)(sourceDirImages)
: (0, fs_1.readdirSync)(sourceDirImages).sort(sortingFunction);
fullImgHash = "";
_i = 0, imageFiles_1 = imageFiles;
_c.label = 1;
case 1:
if (!(_i < imageFiles_1.length)) return [3 /*break*/, 4];
file = imageFiles_1[_i];
return [4 /*yield*/, hash(sourceDirImages + "/" + file, true)];
case 2:
h = _c.sent();
fullImgHash += h;
_c.label = 3;
case 3:
_i++;
return [3 /*break*/, 1];
case 4:
fullMetadataHash = "";
_a = 0, jsonFiles_1 = jsonFiles;
_c.label = 5;
case 5:
if (!(_a < jsonFiles_1.length)) return [3 /*break*/, 8];
file = jsonFiles_1[_a];
return [4 /*yield*/, hash(sourceDirMetadata + "/" + file, true)];
case 6:
h = _c.sent();
fullMetadataHash += h;
_c.label = 7;
case 7:
_a++;
return [3 /*break*/, 5];
case 8:
_b = {};
return [4 /*yield*/, hash(fullImgHash, false)];
case 9:
_b.imagesProvenanceHash = _c.sent();
return [4 /*yield*/, hash(fullMetadataHash, false)];
case 10: return [2 /*return*/, (_b.metadataProvenanceHash = _c.sent(),
_b)];
}
});
});
}); };
exports.makeHash = makeHash;
}
exports["default"] = makeHash;
var hash = function (data, isFile) { return __awaiter(void 0, void 0, void 0, function () {

@@ -97,0 +98,0 @@ var hash;

@@ -5,3 +5,3 @@ {

"license": "MIT",
"version": "0.0.1",
"version": "0.0.2",
"author": {

@@ -11,6 +11,3 @@ "email": "ttokic1985@gmail.com",

},
"dependencies": {
"ts-node": "^10.4.0",
"typescript": "^4.5.2"
},
"scripts": {

@@ -23,7 +20,12 @@ "build": "yarn tsc src/main.ts --outDir dist",

"@types/node": "^16.11.7",
"prettier": "^2.4.1"
"prettier": "^2.4.1",
"ts-node": "^10.4.0",
"typescript": "^4.5.2"
},
"main": "dist/main",
"typings": "dist/main",
"files": ["dist/main.js", "dist/main.d.ts"]
"files": [
"dist/main.js",
"dist/main.d.ts"
]
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc