diff --git a/package-lock.json b/package-lock.json index 903b67e..0dcbe4f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,9 +13,9 @@ "axios-cookiejar-support": "^1.0.1", "cheerio": "^1.0.0-rc.3", "class-validator": "^0.13.1", + "js-sha256": "^0.9.0", "log4js": "^6.3.0", "luxon": "^1.25.0", - "md5": "^2.3.0", "tough-cookie": "^4.0.0" }, "devDependencies": { @@ -24,7 +24,6 @@ "@types/expect": "^24.3.0", "@types/lodash": "^4.14.168", "@types/luxon": "^1.25.2", - "@types/md5": "^2.3.0", "@types/mocha": "^8.2.0", "@types/node": "^14.14.27", "@types/source-map-support": "^0.5.3", @@ -535,15 +534,6 @@ "integrity": "sha512-lMc5+7ynC4+Pu3RR/FvKGx7WHakrPPTtFEZUy1cMXTbH5fQbso+LZjM/G1moOBpCR9XGNa39gXOQu89lpXTeiw==", "dev": true }, - "node_modules/@types/md5": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/@types/md5/-/md5-2.3.0.tgz", - "integrity": "sha512-556YJ7ejzxIqSSxzyGGpctuZOarNZJt/zlEkhmmDc1f/slOEANHuwu2ZX7YaZ40rMiWoxt8GvAhoDpW1cmSy6A==", - "dev": true, - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/mocha": { "version": "8.2.0", "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-8.2.0.tgz", @@ -1039,14 +1029,6 @@ "node": ">=4" } }, - "node_modules/charenc": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz", - "integrity": "sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc=", - "engines": { - "node": "*" - } - }, "node_modules/check-error": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", @@ -1192,14 +1174,6 @@ "node": ">= 8" } }, - "node_modules/crypt": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz", - "integrity": "sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs=", - "engines": { - "node": "*" - } - }, "node_modules/css-select": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/css-select/-/css-select-3.1.2.tgz", @@ -2194,11 +2168,6 @@ "node": ">=8" } }, - "node_modules/is-buffer": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" - }, "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -2670,6 +2639,11 @@ "node": ">= 10.14.2" } }, + "node_modules/js-sha256": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/js-sha256/-/js-sha256-0.9.0.tgz", + "integrity": "sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA==" + }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -2907,16 +2881,6 @@ "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", "dev": true }, - "node_modules/md5": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz", - "integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==", - "dependencies": { - "charenc": "0.0.2", - "crypt": "0.0.2", - "is-buffer": "~1.1.6" - } - }, "node_modules/merge2": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", @@ -4999,15 +4963,6 @@ "integrity": "sha512-lMc5+7ynC4+Pu3RR/FvKGx7WHakrPPTtFEZUy1cMXTbH5fQbso+LZjM/G1moOBpCR9XGNa39gXOQu89lpXTeiw==", "dev": true }, - "@types/md5": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/@types/md5/-/md5-2.3.0.tgz", - "integrity": "sha512-556YJ7ejzxIqSSxzyGGpctuZOarNZJt/zlEkhmmDc1f/slOEANHuwu2ZX7YaZ40rMiWoxt8GvAhoDpW1cmSy6A==", - "dev": true, - "requires": { - "@types/node": "*" - } - }, "@types/mocha": { "version": "8.2.0", "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-8.2.0.tgz", @@ -5413,11 +5368,6 @@ "supports-color": "^5.3.0" } }, - "charenc": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz", - "integrity": "sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc=" - }, "check-error": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", @@ -5546,11 +5496,6 @@ "which": "^2.0.1" } }, - "crypt": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz", - "integrity": "sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs=" - }, "css-select": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/css-select/-/css-select-3.1.2.tgz", @@ -6340,11 +6285,6 @@ "binary-extensions": "^2.0.0" } }, - "is-buffer": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" - }, "is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -6712,6 +6652,11 @@ "integrity": "sha512-Gv3ZIs/nA48/Zvjrl34bf+oD76JHiGDUxNOVgUjh3j890sblXryjY4rss71fPtD/njchl6PSE2hIhvyWa1eT0A==", "dev": true }, + "js-sha256": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/js-sha256/-/js-sha256-0.9.0.tgz", + "integrity": "sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA==" + }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -6900,16 +6845,6 @@ "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", "dev": true }, - "md5": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz", - "integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==", - "requires": { - "charenc": "0.0.2", - "crypt": "0.0.2", - "is-buffer": "~1.1.6" - } - }, "merge2": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", diff --git a/package.json b/package.json index 62eaff3..32d9e17 100644 --- a/package.json +++ b/package.json @@ -38,9 +38,9 @@ "axios-cookiejar-support": "^1.0.1", "cheerio": "^1.0.0-rc.3", "class-validator": "^0.13.1", + "js-sha256": "^0.9.0", "log4js": "^6.3.0", "luxon": "^1.25.0", - "md5": "^2.3.0", "tough-cookie": "^4.0.0" }, "devDependencies": { @@ -49,7 +49,6 @@ "@types/expect": "^24.3.0", "@types/lodash": "^4.14.168", "@types/luxon": "^1.25.2", - "@types/md5": "^2.3.0", "@types/mocha": "^8.2.0", "@types/node": "^14.14.27", "@types/source-map-support": "^0.5.3", diff --git a/src/scripts/classes/session.ts b/src/scripts/classes/session.ts index 564f8ea..fbf25e7 100644 --- a/src/scripts/classes/session.ts +++ b/src/scripts/classes/session.ts @@ -6,7 +6,7 @@ import { promisify } from "util"; import path from "path"; // Public modules from npm -import md5 from "md5"; +import { sha256 } from "js-sha256"; import tough, { CookieJar } from "tough-cookie"; // Promisifed functions @@ -114,7 +114,7 @@ export default class Session { create(username: string, password: string, token: string): void { // First, create the _hash of the credentials const value = `${username}%%%${password}`; - this._hash = md5(value); + this._hash = sha256(value); // Set the token this._token = token; @@ -187,7 +187,7 @@ export default class Session { // Check the hash const value = `${username}%%%${password}`; - const hashValid = md5(value) === this._hash; + const hashValid = sha256(value) === this._hash; // Search for expired cookies const jarValid = this._cookieJar