node-provenance-hash
Advanced tools
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" | ||
] | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8871
0
116
4
4
- Removedts-node@^10.4.0
- Removedtypescript@^4.5.2
- Removed@cspotcode/source-map-support@0.8.1(transitive)
- Removed@jridgewell/resolve-uri@3.1.2(transitive)
- Removed@jridgewell/sourcemap-codec@1.5.0(transitive)
- Removed@jridgewell/trace-mapping@0.3.9(transitive)
- Removed@tsconfig/node10@1.0.11(transitive)
- Removed@tsconfig/node12@1.0.11(transitive)
- Removed@tsconfig/node14@1.0.3(transitive)
- Removed@tsconfig/node16@1.0.4(transitive)
- Removed@types/node@22.9.1(transitive)
- Removedacorn@8.14.0(transitive)
- Removedacorn-walk@8.3.4(transitive)
- Removedarg@4.1.3(transitive)
- Removedcreate-require@1.1.1(transitive)
- Removeddiff@4.0.2(transitive)
- Removedmake-error@1.3.6(transitive)
- Removedts-node@10.9.2(transitive)
- Removedtypescript@4.9.5(transitive)
- Removedundici-types@6.19.8(transitive)
- Removedv8-compile-cache-lib@3.0.1(transitive)
- Removedyn@3.1.1(transitive)