diff --git a/.babelrc b/.babelrc index ae8447ec..33deb636 100644 --- a/.babelrc +++ b/.babelrc @@ -5,7 +5,8 @@ "chrome": 40, "firefox": 35, "edge": 14 - } + }, + "modules": false }] ] } \ No newline at end of file diff --git a/src/.eslintrc.json b/src/.eslintrc.json index 1e91ad34..677146b5 100755 --- a/src/.eslintrc.json +++ b/src/.eslintrc.json @@ -3,12 +3,12 @@ "ecmaVersion": 6, "ecmaFeatures": { "impliedStrict": true - } + }, + "sourceType": "module" }, "env": { "browser": true, "es6": true, - "commonjs": true, "node": true }, "extends": "eslint:recommended", diff --git a/src/core/Chef.js b/src/core/Chef.js index bb7fea54..8192640f 100755 --- a/src/core/Chef.js +++ b/src/core/Chef.js @@ -1,5 +1,5 @@ -var Dish = require("./Dish.js"), - Recipe = require("./Recipe.js"); +import Dish from "./Dish.js"; +import Recipe from "./Recipe.js"; /** @@ -11,7 +11,7 @@ var Dish = require("./Dish.js"), * * @class */ -var Chef = module.exports = function() { +var Chef = function() { this.dish = new Dish(); }; @@ -122,3 +122,5 @@ Chef.prototype.silentBake = function(recipeConfig) { } return new Date().getTime() - startTime; }; + +export default Chef; diff --git a/src/core/Dish.js b/src/core/Dish.js index db2c8e72..fe880571 100755 --- a/src/core/Dish.js +++ b/src/core/Dish.js @@ -1,4 +1,4 @@ -var Utils = require("./Utils.js"); +import Utils from "./Utils.js"; /** @@ -12,7 +12,7 @@ var Utils = require("./Utils.js"); * @param {byteArray|string|number} value - The value of the input data. * @param {number} type - The data type of value, see Dish enums. */ -var Dish = module.exports = function(value, type) { +var Dish = function(value, type) { this.value = value || typeof value == "string" ? value : null; this.type = type || Dish.BYTE_ARRAY; }; @@ -203,3 +203,5 @@ Dish.prototype.valid = function() { return false; } }; + +export default Dish; diff --git a/src/core/FlowControl.js b/src/core/FlowControl.js index 9f81680a..ff54794d 100755 --- a/src/core/FlowControl.js +++ b/src/core/FlowControl.js @@ -1,5 +1,5 @@ -var Recipe = require("./Recipe.js"), - Dish = require("./Dish.js"); +import Recipe from "./Recipe.js"; +import Dish from "./Dish.js"; /** @@ -11,7 +11,7 @@ var Recipe = require("./Recipe.js"), * * @namespace */ -var FlowControl = module.exports = { +const FlowControl = { /** * @constant @@ -186,3 +186,5 @@ var FlowControl = module.exports = { }, }; + +export default FlowControl; diff --git a/src/core/Ingredient.js b/src/core/Ingredient.js index eacd56b9..2a3c36a9 100755 --- a/src/core/Ingredient.js +++ b/src/core/Ingredient.js @@ -1,4 +1,4 @@ -var Utils = require("./Utils.js"); +import Utils from "./Utils.js"; /** @@ -11,7 +11,7 @@ var Utils = require("./Utils.js"); * @class * @param {Object} ingredientConfig */ -var Ingredient = module.exports = function(ingredientConfig) { +var Ingredient = function(ingredientConfig) { this.name = ""; this.type = ""; this.value = null; @@ -86,3 +86,5 @@ Ingredient.prepare = function(data, type) { return data; } }; + +export default Ingredient; diff --git a/src/core/Operation.js b/src/core/Operation.js index a92dd1b8..cf8932e2 100755 --- a/src/core/Operation.js +++ b/src/core/Operation.js @@ -1,5 +1,5 @@ -var Dish = require("./Dish.js"), - Ingredient = require("./Ingredient.js"); +import Dish from "./Dish.js"; +import Ingredient from "./Ingredient.js"; /** @@ -13,7 +13,7 @@ var Dish = require("./Dish.js"), * @param {string} operationName * @param {Object} operationConfig */ -var Operation = module.exports = function(operationName, operationConfig) { +var Operation = function(operationName, operationConfig) { this.name = operationName; this.description = ""; this.inputType = -1; @@ -159,3 +159,5 @@ Operation.prototype.isDisabled = function() { Operation.prototype.isFlowControl = function() { return this.flowControl; }; + +export default Operation; diff --git a/src/core/Recipe.js b/src/core/Recipe.js index af64158e..b0a39673 100755 --- a/src/core/Recipe.js +++ b/src/core/Recipe.js @@ -1,5 +1,5 @@ -var Operation = require("./Operation.js"); -// OperationConfig required at the bottom of this file to prevent circular dependency errors +import Operation from "./Operation.js"; +import OperationConfig from "./config/OperationConfig.js"; /** @@ -12,7 +12,7 @@ var Operation = require("./Operation.js"); * @class * @param {Object} recipeConfig */ -var Recipe = module.exports = function(recipeConfig) { +var Recipe = function(recipeConfig) { this.opList = []; if (recipeConfig) { @@ -217,7 +217,4 @@ Recipe.prototype.fromString = function(recipeStr) { this._parseConfig(recipeConfig); }; - -// Required here to prevent circular dependency where Recipe returns an empty object -// See http://stackoverflow.com/a/30390378 -var OperationConfig = require("./config/OperationConfig.js"); +export default Recipe; diff --git a/src/core/Utils.js b/src/core/Utils.js index 56efe9c3..e12f015b 100755 --- a/src/core/Utils.js +++ b/src/core/Utils.js @@ -1,4 +1,4 @@ -var CryptoJS = require("crypto-js"); +import CryptoJS from "crypto-js"; /** @@ -10,7 +10,7 @@ var CryptoJS = require("crypto-js"); * * @namespace */ -var Utils = module.exports = { +const Utils = { /** * Translates an ordinal into a character. @@ -1169,6 +1169,8 @@ var Utils = module.exports = { }; +export default Utils; + /** * Removes all duplicates from an array. diff --git a/src/core/config/Categories.js b/src/core/config/Categories.js index 2eb93fd3..dd0c4e17 100755 --- a/src/core/config/Categories.js +++ b/src/core/config/Categories.js @@ -17,7 +17,7 @@ * @constant * @type {CatConf[]} */ -var Categories = module.exports = [ +const Categories = [ { name: "Favourites", ops: [] @@ -291,3 +291,5 @@ var Categories = module.exports = [ ] }, ]; + +export default Categories; diff --git a/src/core/config/OperationConfig.js b/src/core/config/OperationConfig.js index 4e8917d4..66846352 100755 --- a/src/core/config/OperationConfig.js +++ b/src/core/config/OperationConfig.js @@ -1,41 +1,41 @@ -var FlowControl = require("../FlowControl.js"), - Base = require("../operations/Base.js"), - Base58 = require("../operations/Base58.js"), - Base64 = require("../operations/Base64.js"), - BitwiseOp = require("../operations/BitwiseOp.js"), - ByteRepr = require("../operations/ByteRepr.js"), - CharEnc = require("../operations/CharEnc.js"), - Checksum = require("../operations/Checksum.js"), - Cipher = require("../operations/Cipher.js"), - Code = require("../operations/Code.js"), - Compress = require("../operations/Compress.js"), - Convert = require("../operations/Convert.js"), - DateTime = require("../operations/DateTime.js"), - Endian = require("../operations/Endian.js"), - Entropy = require("../operations/Entropy.js"), - Extract = require("../operations/Extract.js"), - FileType = require("../operations/FileType.js"), - Hash = require("../operations/Hash.js"), - Hexdump = require("../operations/Hexdump.js"), - HTML = require("../operations/HTML.js"), - HTTP = require("../operations/HTTP.js"), - IP = require("../operations/IP.js"), - JS = require("../operations/JS.js"), - MAC = require("../operations/MAC.js"), - MorseCode = require("../operations/MorseCode.js"), - NetBIOS = require("../operations/NetBIOS.js"), - Numberwang = require("../operations/Numberwang.js"), - OS = require("../operations/OS.js"), - PublicKey = require("../operations/PublicKey.js"), - Punycode = require("../operations/Punycode.js"), - QuotedPrintable = require("../operations/QuotedPrintable.js"), - Rotate = require("../operations/Rotate.js"), - SeqUtils = require("../operations/SeqUtils.js"), - StrUtils = require("../operations/StrUtils.js"), - Tidy = require("../operations/Tidy.js"), - Unicode = require("../operations/Unicode.js"), - URL_ = require("../operations/URL.js"), - UUID = require("../operations/UUID.js"); +import FlowControl from "../FlowControl.js"; +import Base from "../operations/Base.js"; +import Base58 from "../operations/Base58.js"; +import Base64 from "../operations/Base64.js"; +import BitwiseOp from "../operations/BitwiseOp.js"; +import ByteRepr from "../operations/ByteRepr.js"; +import CharEnc from "../operations/CharEnc.js"; +import Checksum from "../operations/Checksum.js"; +import Cipher from "../operations/Cipher.js"; +import Code from "../operations/Code.js"; +import Compress from "../operations/Compress.js"; +import Convert from "../operations/Convert.js"; +import DateTime from "../operations/DateTime.js"; +import Endian from "../operations/Endian.js"; +import Entropy from "../operations/Entropy.js"; +import Extract from "../operations/Extract.js"; +import FileType from "../operations/FileType.js"; +import Hash from "../operations/Hash.js"; +import Hexdump from "../operations/Hexdump.js"; +import HTML from "../operations/HTML.js"; +import HTTP from "../operations/HTTP.js"; +import IP from "../operations/IP.js"; +import JS from "../operations/JS.js"; +import MAC from "../operations/MAC.js"; +import MorseCode from "../operations/MorseCode.js"; +import NetBIOS from "../operations/NetBIOS.js"; +import Numberwang from "../operations/Numberwang.js"; +import OS from "../operations/OS.js"; +import PublicKey from "../operations/PublicKey.js"; +import Punycode from "../operations/Punycode.js"; +import QuotedPrintable from "../operations/QuotedPrintable.js"; +import Rotate from "../operations/Rotate.js"; +import SeqUtils from "../operations/SeqUtils.js"; +import StrUtils from "../operations/StrUtils.js"; +import Tidy from "../operations/Tidy.js"; +import Unicode from "../operations/Unicode.js"; +import URL_ from "../operations/URL.js"; +import UUID from "../operations/UUID.js"; /** @@ -78,7 +78,7 @@ var FlowControl = require("../FlowControl.js"), * @constant * @type {Object.} */ -var OperationConfig = module.exports = { +const OperationConfig = { "Fork": { description: "Split the input data up based on the specified delimiter and run all subsequent operations on each branch separately.

For example, to decode multiple Base64 strings, enter them all on separate lines then add the 'Fork' and 'From Base64' operations to the recipe. Each string will be decoded separately.", run: FlowControl.runFork, @@ -3168,3 +3168,5 @@ var OperationConfig = module.exports = { ] } }; + +export default OperationConfig; diff --git a/src/core/lib/canvascomponents.js b/src/core/lib/canvascomponents.js index a8db9b6e..f6ea0538 100755 --- a/src/core/lib/canvascomponents.js +++ b/src/core/lib/canvascomponents.js @@ -10,7 +10,7 @@ * @constant * @namespace */ -var CanvasComponents = module.exports = { +const CanvasComponents = { drawLine: function(ctx, startX, startY, endX, endY) { ctx.beginPath(); @@ -182,3 +182,5 @@ var CanvasComponents = module.exports = { }, }; + +export default CanvasComponents; diff --git a/src/core/lib/uas_parser.js b/src/core/lib/uas_parser.js index 3d86d533..8f29da26 100755 --- a/src/core/lib/uas_parser.js +++ b/src/core/lib/uas_parser.js @@ -24,11 +24,10 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -"use strict"; -var Utils = require("../Utils.js"); +import Utils from "../Utils.js"; -var UAS_parser = { +const UAS_parser = { parse: function (userAgent) { var result = { @@ -135,7 +134,7 @@ var UAS_parser = { } }; -var UAS_cache = { +const UAS_cache = { version: '20131025-01', robots: { '3': { @@ -25816,4 +25815,7 @@ var UAS_cache = { '35' ] } -}; \ No newline at end of file +}; + +export {UAS_parser, UAS_cache}; +export default UAS_parser; \ No newline at end of file diff --git a/src/core/operations/Base.js b/src/core/operations/Base.js index c25c0eeb..39e0b741 100755 --- a/src/core/operations/Base.js +++ b/src/core/operations/Base.js @@ -7,7 +7,7 @@ * * @namespace */ -var Base = module.exports = { +const Base = { /** * @constant @@ -50,3 +50,5 @@ var Base = module.exports = { }, }; + +export default Base; diff --git a/src/core/operations/Base58.js b/src/core/operations/Base58.js index 6a4430ef..b2541b67 100755 --- a/src/core/operations/Base58.js +++ b/src/core/operations/Base58.js @@ -1,4 +1,4 @@ -var Utils = require("../Utils.js"); +import Utils from "../Utils.js"; /** @@ -10,7 +10,7 @@ var Utils = require("../Utils.js"); * * @namespace */ -var Base58 = module.exports = { +const Base58 = { /** * @constant @@ -133,3 +133,5 @@ var Base58 = module.exports = { }, }; + +export default Base58; diff --git a/src/core/operations/Base64.js b/src/core/operations/Base64.js index e8ea1296..ab2450e8 100755 --- a/src/core/operations/Base64.js +++ b/src/core/operations/Base64.js @@ -1,4 +1,4 @@ -var Utils = require("../Utils.js"); +import Utils from "../Utils.js"; /** @@ -10,7 +10,7 @@ var Utils = require("../Utils.js"); * * @namespace */ -var Base64 = module.exports = { +const Base64 = { /** * @constant @@ -342,3 +342,5 @@ var Base64 = module.exports = { }, }; + +export default Base64; diff --git a/src/core/operations/BitwiseOp.js b/src/core/operations/BitwiseOp.js index 665556ca..36d4373e 100755 --- a/src/core/operations/BitwiseOp.js +++ b/src/core/operations/BitwiseOp.js @@ -1,5 +1,5 @@ -var Utils = require("../Utils.js"), - CryptoJS = require("crypto-js"); +import Utils from "../Utils.js"; +import CryptoJS from "crypto-js"; /** @@ -11,7 +11,7 @@ var Utils = require("../Utils.js"), * * @namespace */ -var BitwiseOp = module.exports = { +const BitwiseOp = { /** * Runs bitwise operations across the input data. @@ -306,3 +306,5 @@ var BitwiseOp = module.exports = { }, }; + +export default BitwiseOp; diff --git a/src/core/operations/ByteRepr.js b/src/core/operations/ByteRepr.js index 4208c2c9..a439d1e1 100755 --- a/src/core/operations/ByteRepr.js +++ b/src/core/operations/ByteRepr.js @@ -1,5 +1,5 @@ /* globals app */ -var Utils = require("../Utils.js"); +import Utils from "../Utils.js"; /** @@ -11,7 +11,7 @@ var Utils = require("../Utils.js"); * * @namespace */ -var ByteRepr = module.exports = { +const ByteRepr = { /** * @constant @@ -394,3 +394,5 @@ var ByteRepr = module.exports = { }, }; + +export default ByteRepr; diff --git a/src/core/operations/CharEnc.js b/src/core/operations/CharEnc.js index e3cc6855..96659272 100755 --- a/src/core/operations/CharEnc.js +++ b/src/core/operations/CharEnc.js @@ -1,5 +1,5 @@ -var Utils = require("../Utils.js"), - CryptoJS = require("crypto-js"); +import Utils from "../Utils.js"; +import CryptoJS from "crypto-js"; /** @@ -11,7 +11,7 @@ var Utils = require("../Utils.js"), * * @namespace */ -var CharEnc = module.exports = { +const CharEnc = { /** * @constant @@ -46,3 +46,5 @@ var CharEnc = module.exports = { }, }; + +export default CharEnc; diff --git a/src/core/operations/Checksum.js b/src/core/operations/Checksum.js index 70c7d2a9..4a20c0ad 100755 --- a/src/core/operations/Checksum.js +++ b/src/core/operations/Checksum.js @@ -1,4 +1,4 @@ -var Utils = require("../Utils.js"); +import Utils from "../Utils.js"; /** @@ -10,7 +10,7 @@ var Utils = require("../Utils.js"); * * @namespace */ -var Checksum = module.exports = { +const Checksum = { /** * Fletcher-8 Checksum operation. @@ -191,3 +191,5 @@ var Checksum = module.exports = { }, }; + +export default Checksum; diff --git a/src/core/operations/Cipher.js b/src/core/operations/Cipher.js index fd4f657d..934dbe18 100755 --- a/src/core/operations/Cipher.js +++ b/src/core/operations/Cipher.js @@ -1,6 +1,6 @@ -var Utils = require("../Utils.js"), - CryptoJS = require("crypto-js"), - Blowfish = require("sladex-blowfish"); +import Utils from "../Utils.js"; +import CryptoJS from "crypto-js"; +import {blowfish as Blowfish} from "sladex-blowfish"; /** @@ -12,7 +12,7 @@ var Utils = require("../Utils.js"), * * @namespace */ -var Cipher = module.exports = { +const Cipher = { /** * @constant @@ -617,6 +617,8 @@ var Cipher = module.exports = { }; +export default Cipher; + /** * Overwriting the CryptoJS OpenSSL key derivation function so that it is possible to not pass a diff --git a/src/core/operations/Code.js b/src/core/operations/Code.js index 4a442d54..91d2bf0b 100755 --- a/src/core/operations/Code.js +++ b/src/core/operations/Code.js @@ -1,8 +1,8 @@ -var Utils = require("../Utils.js"), - VKbeautify = require("vkbeautify"), - dom = require("xmldom").DOMParser, - xpath = require("xpath"), - prettyPrintOne = require("exports-loader?prettyPrintOne!google-code-prettify/bin/prettify.min.js"); +import Utils from "../Utils.js"; +import vkbeautify from "vkbeautify"; +import {DOMParser as dom} from "xmldom"; +import xpath from "xpath"; +import prettyPrintOne from "exports-loader?prettyPrintOne!google-code-prettify/bin/prettify.min.js"; /** @@ -14,7 +14,7 @@ var Utils = require("../Utils.js"), * * @namespace */ -var Code = module.exports = { +const Code = { /** * @constant @@ -56,7 +56,7 @@ var Code = module.exports = { */ runXmlBeautify: function(input, args) { var indentStr = args[0]; - return VKbeautify.xml(input, indentStr); + return vkbeautify.xml(input, indentStr); }, @@ -70,7 +70,7 @@ var Code = module.exports = { runJsonBeautify: function(input, args) { var indentStr = args[0]; if (!input) return ""; - return VKbeautify.json(input, indentStr); + return vkbeautify.json(input, indentStr); }, @@ -83,7 +83,7 @@ var Code = module.exports = { */ runCssBeautify: function(input, args) { var indentStr = args[0]; - return VKbeautify.css(input, indentStr); + return vkbeautify.css(input, indentStr); }, @@ -96,7 +96,7 @@ var Code = module.exports = { */ runSqlBeautify: function(input, args) { var indentStr = args[0]; - return VKbeautify.sql(input, indentStr); + return vkbeautify.sql(input, indentStr); }, @@ -115,7 +115,7 @@ var Code = module.exports = { */ runXmlMinify: function(input, args) { var preserveComments = args[0]; - return VKbeautify.xmlmin(input, preserveComments); + return vkbeautify.xmlmin(input, preserveComments); }, @@ -128,7 +128,7 @@ var Code = module.exports = { */ runJsonMinify: function(input, args) { if (!input) return ""; - return VKbeautify.jsonmin(input); + return vkbeautify.jsonmin(input); }, @@ -141,7 +141,7 @@ var Code = module.exports = { */ runCssMinify: function(input, args) { var preserveComments = args[0]; - return VKbeautify.cssmin(input, preserveComments); + return vkbeautify.cssmin(input, preserveComments); }, @@ -153,7 +153,7 @@ var Code = module.exports = { * @returns {string} */ runSqlMinify: function(input, args) { - return VKbeautify.sqlmin(input); + return vkbeautify.sqlmin(input); }, @@ -423,3 +423,5 @@ var Code = module.exports = { }, }; + +export default Code; diff --git a/src/core/operations/Compress.js b/src/core/operations/Compress.js index be1ebc47..f37be114 100755 --- a/src/core/operations/Compress.js +++ b/src/core/operations/Compress.js @@ -1,10 +1,10 @@ -var Utils = require("../Utils.js"), - rawdeflate = require("zlibjs/bin/rawdeflate.min"), - rawinflate = require("zlibjs/bin/rawinflate.min"), - zlibAndGzip = require("zlibjs/bin/zlib_and_gzip.min"), - zip = require("zlibjs/bin/zip.min"), - unzip = require("zlibjs/bin/unzip.min"), - bzip2 = require("exports-loader?bzip2!../lib/bzip2.js"); +import Utils from "../Utils.js"; +import rawdeflate from "zlibjs/bin/rawdeflate.min"; +import rawinflate from "zlibjs/bin/rawinflate.min"; +import zlibAndGzip from "zlibjs/bin/zlib_and_gzip.min"; +import zip from "zlibjs/bin/zip.min"; +import unzip from "zlibjs/bin/unzip.min"; +import bzip2 from "exports-loader?bzip2!../lib/bzip2.js"; var Zlib = { RawDeflate: rawdeflate.Zlib.RawDeflate, @@ -27,7 +27,7 @@ var Zlib = { * * @namespace */ -var Compress = module.exports = { +const Compress = { /** * @constant @@ -569,3 +569,5 @@ var Compress = module.exports = { return Utils.displayFilesAsHTML(files); }, }; + +export default Compress; diff --git a/src/core/operations/Convert.js b/src/core/operations/Convert.js index 9586f522..972b319f 100755 --- a/src/core/operations/Convert.js +++ b/src/core/operations/Convert.js @@ -7,7 +7,7 @@ * * @namespace */ -var Convert = module.exports = { +const Convert = { /** * @constant @@ -410,3 +410,5 @@ var Convert = module.exports = { }, }; + +export default Convert; diff --git a/src/core/operations/DateTime.js b/src/core/operations/DateTime.js index 1b42368d..78f1c0b4 100755 --- a/src/core/operations/DateTime.js +++ b/src/core/operations/DateTime.js @@ -7,7 +7,7 @@ * * @namespace */ -var DateTime = module.exports = { +const DateTime = { /** * @constant @@ -448,5 +448,6 @@ var DateTime = module.exports = { \ ", - }; + +export default DateTime; diff --git a/src/core/operations/Endian.js b/src/core/operations/Endian.js index 9bfdd84e..219ef347 100755 --- a/src/core/operations/Endian.js +++ b/src/core/operations/Endian.js @@ -1,4 +1,4 @@ -var Utils = require("../Utils.js"); +import Utils from "../Utils.js"; /** @@ -10,7 +10,7 @@ var Utils = require("../Utils.js"); * * @namespace */ -var Endian = module.exports = { +const Endian = { /** * @constant @@ -95,3 +95,5 @@ var Endian = module.exports = { }, }; + +export default Endian; diff --git a/src/core/operations/Entropy.js b/src/core/operations/Entropy.js index 6b76d9bc..e3237c25 100755 --- a/src/core/operations/Entropy.js +++ b/src/core/operations/Entropy.js @@ -1,4 +1,4 @@ -var Utils = require("../Utils.js"); +import Utils from "../Utils.js"; /** @@ -10,7 +10,7 @@ var Utils = require("../Utils.js"); * * @namespace */ -var Entropy = module.exports = { +const Entropy = { /** * @constant @@ -167,3 +167,5 @@ var Entropy = module.exports = { }, }; + +export default Entropy; diff --git a/src/core/operations/Extract.js b/src/core/operations/Extract.js index 799eb531..52bfaf7d 100755 --- a/src/core/operations/Extract.js +++ b/src/core/operations/Extract.js @@ -7,7 +7,7 @@ * * @namespace */ -var Extract = module.exports = { +const Extract = { /** * Runs search operations across the input data using regular expressions. @@ -295,3 +295,5 @@ var Extract = module.exports = { }, }; + +export default Extract; diff --git a/src/core/operations/FileType.js b/src/core/operations/FileType.js index c6020b35..43bc622b 100755 --- a/src/core/operations/FileType.js +++ b/src/core/operations/FileType.js @@ -1,4 +1,4 @@ -var Utils = require("../Utils.js"); +import Utils from "../Utils.js"; /** @@ -10,7 +10,7 @@ var Utils = require("../Utils.js"); * * @namespace */ -var FileType = module.exports = { +const FileType = { /** * Detect File Type operation. @@ -527,3 +527,5 @@ var FileType = module.exports = { }, }; + +export default FileType; diff --git a/src/core/operations/HTML.js b/src/core/operations/HTML.js index ffe890cb..13f94d92 100755 --- a/src/core/operations/HTML.js +++ b/src/core/operations/HTML.js @@ -1,4 +1,4 @@ -var Utils = require("../Utils.js"); +import Utils from "../Utils.js"; /** @@ -10,7 +10,7 @@ var Utils = require("../Utils.js"); * * @namespace */ -var HTML = module.exports = { +const HTML = { /** * @constant @@ -851,3 +851,5 @@ var HTML = module.exports = { }, }; + +export default HTML; diff --git a/src/core/operations/HTTP.js b/src/core/operations/HTTP.js index a30ce234..10708544 100755 --- a/src/core/operations/HTTP.js +++ b/src/core/operations/HTTP.js @@ -1,4 +1,4 @@ -var UAParser = require("exports-loader?UAS_parser!../lib/uas_parser.js"); +import {UAS_parser as UAParser} from "../lib/uas_parser.js"; /** @@ -10,7 +10,7 @@ var UAParser = require("exports-loader?UAS_parser!../lib/uas_parser.js"); * * @namespace */ -var HTTP = module.exports = { +const HTTP = { /** * Strip HTTP headers operation. @@ -52,3 +52,5 @@ var HTTP = module.exports = { }, }; + +export default HTTP; diff --git a/src/core/operations/Hash.js b/src/core/operations/Hash.js index c0c7d7fe..7605e7a2 100755 --- a/src/core/operations/Hash.js +++ b/src/core/operations/Hash.js @@ -1,7 +1,7 @@ -var Utils = require("../Utils.js"), - CryptoJS = require("crypto-js"), - CryptoApi = require("crypto-api"), - Checksum = require("./Checksum.js"); +import Utils from "../Utils.js"; +import CryptoJS from "crypto-js"; +import CryptoApi from "crypto-api"; +import Checksum from "./Checksum.js"; /** @@ -13,7 +13,7 @@ var Utils = require("../Utils.js"), * * @namespace */ -var Hash = module.exports = { +const Hash = { /** * MD2 operation. @@ -385,3 +385,5 @@ var Hash = module.exports = { }, }; + +export default Hash; diff --git a/src/core/operations/Hexdump.js b/src/core/operations/Hexdump.js index c29e02dc..9bb16df9 100755 --- a/src/core/operations/Hexdump.js +++ b/src/core/operations/Hexdump.js @@ -1,5 +1,5 @@ /* globals app */ -var Utils = require("../Utils.js"); +import Utils from "../Utils.js"; /** @@ -11,7 +11,7 @@ var Utils = require("../Utils.js"); * * @namespace */ -var Hexdump = module.exports = { +const Hexdump = { /** * @constant @@ -198,3 +198,5 @@ var Hexdump = module.exports = { }, }; + +export default Hexdump; diff --git a/src/core/operations/IP.js b/src/core/operations/IP.js index e807f560..c5e6a4fe 100755 --- a/src/core/operations/IP.js +++ b/src/core/operations/IP.js @@ -1,6 +1,6 @@ -var Utils = require("../Utils.js"), - Checksum = require("./Checksum.js"), - BigInteger = require("jsbn").BigInteger; +import Utils from "../Utils.js"; +import Checksum from "./Checksum.js"; +import {BigInteger} from "jsbn"; /** @@ -12,7 +12,7 @@ var Utils = require("../Utils.js"), * * @namespace */ -var IP = module.exports = { +const IP = { /** * @constant @@ -1060,5 +1060,6 @@ var IP = module.exports = { 255: {keyword: "Reserved", protocol: ""} }, - }; + +export default IP; diff --git a/src/core/operations/JS.js b/src/core/operations/JS.js index 906717e3..93f22a3c 100755 --- a/src/core/operations/JS.js +++ b/src/core/operations/JS.js @@ -1,6 +1,6 @@ -var esprima = require("esprima"), - escodegen = require("escodegen"), - esmangle = require("esmangle"); +import esprima from "esprima"; +import escodegen from "escodegen"; +import esmangle from "esmangle"; /** @@ -12,7 +12,7 @@ var esprima = require("esprima"), * * @namespace */ -var JS = module.exports = { +const JS = { /** * @constant @@ -160,3 +160,5 @@ var JS = module.exports = { }, }; + +export default JS; diff --git a/src/core/operations/MAC.js b/src/core/operations/MAC.js index a890b1c0..7affbfc4 100755 --- a/src/core/operations/MAC.js +++ b/src/core/operations/MAC.js @@ -7,7 +7,7 @@ * * @namespace */ -var MAC = module.exports = { +const MAC = { /** * @constant @@ -86,3 +86,5 @@ var MAC = module.exports = { }, }; + +export default MAC; diff --git a/src/core/operations/MorseCode.js b/src/core/operations/MorseCode.js index 614ee8b6..3d00c56d 100644 --- a/src/core/operations/MorseCode.js +++ b/src/core/operations/MorseCode.js @@ -1,4 +1,4 @@ -var Utils = require("../Utils.js"); +import Utils from "../Utils.js"; /** @@ -10,7 +10,7 @@ var Utils = require("../Utils.js"); * * @namespace */ -var MorseCode = module.exports = { +const MorseCode = { /** * @constant @@ -186,3 +186,5 @@ var MorseCode = module.exports = { })(), }; + +export default MorseCode; diff --git a/src/core/operations/NetBIOS.js b/src/core/operations/NetBIOS.js index b71704ae..7791c840 100644 --- a/src/core/operations/NetBIOS.js +++ b/src/core/operations/NetBIOS.js @@ -7,7 +7,7 @@ * * @namespace */ -var NetBIOS = module.exports = { +const NetBIOS = { /** * @constant @@ -55,3 +55,5 @@ var NetBIOS = module.exports = { }, }; + +export default NetBIOS; diff --git a/src/core/operations/Numberwang.js b/src/core/operations/Numberwang.js index f5d06d11..4fff3184 100755 --- a/src/core/operations/Numberwang.js +++ b/src/core/operations/Numberwang.js @@ -4,7 +4,7 @@ * @author Unknown Male 282 * @namespace */ -var Numberwang = module.exports = { +const Numberwang = { /** * Numberwang operation. Remain indoors. @@ -25,3 +25,5 @@ var Numberwang = module.exports = { }, }; + +export default Numberwang; diff --git a/src/core/operations/OS.js b/src/core/operations/OS.js index e517152c..ae842b8f 100755 --- a/src/core/operations/OS.js +++ b/src/core/operations/OS.js @@ -7,7 +7,7 @@ * * @namespace */ -var OS = module.exports = { +const OS = { /** * Parse UNIX file permissions operation. @@ -307,3 +307,5 @@ var OS = module.exports = { }, }; + +export default OS; diff --git a/src/core/operations/PublicKey.js b/src/core/operations/PublicKey.js index 3643585e..199c06f2 100755 --- a/src/core/operations/PublicKey.js +++ b/src/core/operations/PublicKey.js @@ -1,5 +1,5 @@ -var Utils = require("../Utils.js"), - r = require("jsrsasign"); +import Utils from "../Utils.js"; +import * as r from "jsrsasign"; /** @@ -11,7 +11,7 @@ var Utils = require("../Utils.js"), * * @namespace */ -var PublicKey = module.exports = { +const PublicKey = { /** * @constant @@ -336,6 +336,8 @@ var PublicKey = module.exports = { }; +export default PublicKey; + /** * Overwrite X509.hex2dn function so as to join RDNs with a string which can be split on without diff --git a/src/core/operations/Punycode.js b/src/core/operations/Punycode.js index a53f176f..b03758e3 100755 --- a/src/core/operations/Punycode.js +++ b/src/core/operations/Punycode.js @@ -1,4 +1,4 @@ -var punycode = require("punycode"); +import punycode from "punycode"; /** @@ -10,7 +10,7 @@ var punycode = require("punycode"); * * @namespace */ -var Punycode = module.exports = { +const Punycode = { /** * @constant @@ -54,3 +54,5 @@ var Punycode = module.exports = { }, }; + +export default Punycode; diff --git a/src/core/operations/QuotedPrintable.js b/src/core/operations/QuotedPrintable.js index a07135be..4a41e3ad 100755 --- a/src/core/operations/QuotedPrintable.js +++ b/src/core/operations/QuotedPrintable.js @@ -30,7 +30,7 @@ * * @namespace */ -var QuotedPrintable = module.exports = { +const QuotedPrintable = { /** * To Quoted Printable operation. @@ -268,3 +268,5 @@ var QuotedPrintable = module.exports = { }, }; + +export default QuotedPrintable; diff --git a/src/core/operations/Rotate.js b/src/core/operations/Rotate.js index b3856099..2ea02308 100755 --- a/src/core/operations/Rotate.js +++ b/src/core/operations/Rotate.js @@ -9,7 +9,7 @@ * * @todo Support for UTF16 */ -var Rotate = module.exports = { +const Rotate = { /** * @constant @@ -240,3 +240,5 @@ var Rotate = module.exports = { }, }; + +export default Rotate; diff --git a/src/core/operations/SeqUtils.js b/src/core/operations/SeqUtils.js index 32788af4..68a0d4c2 100755 --- a/src/core/operations/SeqUtils.js +++ b/src/core/operations/SeqUtils.js @@ -1,4 +1,4 @@ -var Utils = require("../Utils.js"); +import Utils from "../Utils.js"; /** @@ -10,7 +10,7 @@ var Utils = require("../Utils.js"); * * @namespace */ -var SeqUtils = module.exports = { +const SeqUtils = { /** * @constant @@ -221,3 +221,5 @@ var SeqUtils = module.exports = { }, }; + +export default SeqUtils; diff --git a/src/core/operations/StrUtils.js b/src/core/operations/StrUtils.js index 96ebdad7..e2e28c19 100755 --- a/src/core/operations/StrUtils.js +++ b/src/core/operations/StrUtils.js @@ -1,5 +1,5 @@ -var Utils = require("../Utils.js"), - JsDiff = require("diff"); +import Utils from "../Utils.js"; +import JsDiff from "diff"; /** @@ -11,7 +11,7 @@ var Utils = require("../Utils.js"), * * @namespace */ -var StrUtils = module.exports = { +const StrUtils = { /** * @constant @@ -538,3 +538,5 @@ var StrUtils = module.exports = { }, }; + +export default StrUtils; diff --git a/src/core/operations/Tidy.js b/src/core/operations/Tidy.js index 5e4babd8..7e18d56c 100755 --- a/src/core/operations/Tidy.js +++ b/src/core/operations/Tidy.js @@ -1,4 +1,4 @@ -var Utils = require("../Utils.js"); +import Utils from "../Utils.js"; /** @@ -10,7 +10,7 @@ var Utils = require("../Utils.js"); * * @namespace */ -var Tidy = module.exports = { +const Tidy = { /** * @constant @@ -239,3 +239,5 @@ var Tidy = module.exports = { }, }; + +export default Tidy; diff --git a/src/core/operations/URL.js b/src/core/operations/URL.js index cf84d3b1..9dde1798 100755 --- a/src/core/operations/URL.js +++ b/src/core/operations/URL.js @@ -1,5 +1,5 @@ /* globals unescape */ -var Utils = require("../Utils.js"); +import Utils from "../Utils.js"; /** @@ -12,7 +12,7 @@ var Utils = require("../Utils.js"); * * @namespace */ -var URL_ = module.exports = { +const URL_ = { /** * @constant @@ -130,3 +130,5 @@ var URL_ = module.exports = { }, }; + +export default URL_; diff --git a/src/core/operations/UUID.js b/src/core/operations/UUID.js index 1e0dc22c..3ea0d36d 100755 --- a/src/core/operations/UUID.js +++ b/src/core/operations/UUID.js @@ -7,7 +7,7 @@ * * @namespace */ -var UUID = module.exports = { +const UUID = { /** * Generate UUID operation. @@ -37,3 +37,5 @@ var UUID = module.exports = { }, }; + +export default UUID; diff --git a/src/core/operations/Unicode.js b/src/core/operations/Unicode.js index 147b410a..4b67f4ef 100755 --- a/src/core/operations/Unicode.js +++ b/src/core/operations/Unicode.js @@ -1,4 +1,4 @@ -var Utils = require("../Utils.js"); +import Utils from "../Utils.js"; /** @@ -10,7 +10,7 @@ var Utils = require("../Utils.js"); * * @namespace */ -var Unicode = module.exports = { +const Unicode = { /** * @constant @@ -63,3 +63,5 @@ var Unicode = module.exports = { }, }; + +export default Unicode; diff --git a/src/node/index.js b/src/node/index.js index 348b9f59..61b2f549 100644 --- a/src/node/index.js +++ b/src/node/index.js @@ -6,9 +6,9 @@ * @license Apache-2.0 */ -var Chef = require("../core/Chef.js"); +var Chef = require("../core/Chef.js").default; -module.exports = { +const CyberChef = module.exports = { bake: function(input, recipeConfig) { this.chef = new Chef(); diff --git a/src/web/HTMLApp.js b/src/web/App.js similarity index 91% rename from src/web/HTMLApp.js rename to src/web/App.js index 9b3fc3d4..59121bd9 100755 --- a/src/web/HTMLApp.js +++ b/src/web/App.js @@ -1,9 +1,9 @@ -var Utils = require("../core/Utils.js"), - Chef = require("../core/Chef.js"), - Manager = require("./Manager.js"), - HTMLCategory = require("./HTMLCategory.js"), - HTMLOperation = require("./HTMLOperation.js"), - Split = require("split.js"); +import Utils from "../core/Utils.js"; +import Chef from "../core/Chef.js"; +import Manager from "./Manager.js"; +import HTMLCategory from "./HTMLCategory.js"; +import HTMLOperation from "./HTMLOperation.js"; +import Split from "split.js"; /** @@ -20,7 +20,7 @@ var Utils = require("../core/Utils.js"), * @param {String[]} defaultFavourites - A list of default favourite operations. * @param {Object} options - Default setting for app options. */ -var HTMLApp = module.exports = function(categories, operations, defaultFavourites, defaultOptions) { +var App = function(categories, operations, defaultFavourites, defaultOptions) { this.categories = categories; this.operations = operations; this.dfavourites = defaultFavourites; @@ -43,7 +43,7 @@ var HTMLApp = module.exports = function(categories, operations, defaultFavourite * * @fires Manager#appstart */ -HTMLApp.prototype.setup = function() { +App.prototype.setup = function() { document.dispatchEvent(this.manager.appstart); this.initialiseSplitter(); this.loadLocalStorage(); @@ -60,7 +60,7 @@ HTMLApp.prototype.setup = function() { * * @param {Error} err */ -HTMLApp.prototype.handleError = function(err) { +App.prototype.handleError = function(err) { console.error(err); var msg = err.displayStr || err.toString(); this.alert(msg, "danger", this.options.errorTimeout, !this.options.showErrors); @@ -73,7 +73,7 @@ HTMLApp.prototype.handleError = function(err) { * @param {boolean} [step] - Set to true if we should only execute one operation instead of the * whole recipe. */ -HTMLApp.prototype.bake = function(step) { +App.prototype.bake = function(step) { var response; try { @@ -112,7 +112,7 @@ HTMLApp.prototype.bake = function(step) { /** * Runs Auto Bake if it is set. */ -HTMLApp.prototype.autoBake = function() { +App.prototype.autoBake = function() { if (this.autoBake_) { this.bake(); } @@ -128,7 +128,7 @@ HTMLApp.prototype.autoBake = function() { * * @returns {number} - The number of miliseconds it took to run the silent bake. */ -HTMLApp.prototype.silentBake = function() { +App.prototype.silentBake = function() { var startTime = new Date().getTime(), recipeConfig = this.getRecipeConfig(); @@ -145,7 +145,7 @@ HTMLApp.prototype.silentBake = function() { * * @returns {string} */ -HTMLApp.prototype.getInput = function() { +App.prototype.getInput = function() { var input = this.manager.input.get(); // Save to session storage in case we need to restore it later @@ -161,7 +161,7 @@ HTMLApp.prototype.getInput = function() { * * @param {string} input - The string to set the input to */ -HTMLApp.prototype.setInput = function(input) { +App.prototype.setInput = function(input) { sessionStorage.setItem("inputLength", input.length); sessionStorage.setItem("input", input); this.manager.input.set(input); @@ -174,7 +174,7 @@ HTMLApp.prototype.setInput = function(input) { * * @fires Manager#oplistcreate */ -HTMLApp.prototype.populateOperationsList = function() { +App.prototype.populateOperationsList = function() { // Move edit button away before we overwrite it document.body.appendChild(document.getElementById("edit-favourites")); @@ -210,7 +210,7 @@ HTMLApp.prototype.populateOperationsList = function() { /** * Sets up the adjustable splitter to allow the user to resize areas of the page. */ -HTMLApp.prototype.initialiseSplitter = function() { +App.prototype.initialiseSplitter = function() { this.columnSplitter = Split(["#operations", "#recipe", "#IO"], { sizes: [20, 30, 50], minSize: [240, 325, 440], @@ -234,7 +234,7 @@ HTMLApp.prototype.initialiseSplitter = function() { * Loads the information previously saved to the HTML5 local storage object so that user options * and favourites can be restored. */ -HTMLApp.prototype.loadLocalStorage = function() { +App.prototype.loadLocalStorage = function() { // Load options var lOptions; if (localStorage.options !== undefined) { @@ -252,7 +252,7 @@ HTMLApp.prototype.loadLocalStorage = function() { * Favourites category with them. * If the user currently has no saved favourites, the defaults from the view constructor are used. */ -HTMLApp.prototype.loadFavourites = function() { +App.prototype.loadFavourites = function() { var favourites = localStorage.favourites && localStorage.favourites.length > 2 ? JSON.parse(localStorage.favourites) : @@ -283,7 +283,7 @@ HTMLApp.prototype.loadFavourites = function() { * @param {string[]} favourites - A list of the user's favourite operations * @returns {string[]} A list of the valid favourites */ -HTMLApp.prototype.validFavourites = function(favourites) { +App.prototype.validFavourites = function(favourites) { var validFavs = []; for (var i = 0; i < favourites.length; i++) { if (this.operations.hasOwnProperty(favourites[i])) { @@ -302,7 +302,7 @@ HTMLApp.prototype.validFavourites = function(favourites) { * * @param {string[]} favourites - A list of the user's favourite operations */ -HTMLApp.prototype.saveFavourites = function(favourites) { +App.prototype.saveFavourites = function(favourites) { localStorage.setItem("favourites", JSON.stringify(this.validFavourites(favourites))); }; @@ -311,7 +311,7 @@ HTMLApp.prototype.saveFavourites = function(favourites) { * Resets favourite operations back to the default as specified in the view constructor and * refreshes the operation list. */ -HTMLApp.prototype.resetFavourites = function() { +App.prototype.resetFavourites = function() { this.saveFavourites(this.dfavourites); this.loadFavourites(); this.populateOperationsList(); @@ -324,7 +324,7 @@ HTMLApp.prototype.resetFavourites = function() { * * @param {string} name - The name of the operation */ -HTMLApp.prototype.addFavourite = function(name) { +App.prototype.addFavourite = function(name) { var favourites = JSON.parse(localStorage.favourites); if (favourites.indexOf(name) >= 0) { @@ -343,7 +343,7 @@ HTMLApp.prototype.addFavourite = function(name) { /** * Checks for input and recipe in the URI parameters and loads them if present. */ -HTMLApp.prototype.loadURIParams = function() { +App.prototype.loadURIParams = function() { // Load query string from URI this.queryString = (function(a) { if (a === "") return {}; @@ -408,7 +408,7 @@ HTMLApp.prototype.loadURIParams = function() { * * @returns {number} */ -HTMLApp.prototype.nextIngId = function() { +App.prototype.nextIngId = function() { return this.ingId++; }; @@ -418,7 +418,7 @@ HTMLApp.prototype.nextIngId = function() { * * @returns {Object[]} */ -HTMLApp.prototype.getRecipeConfig = function() { +App.prototype.getRecipeConfig = function() { var recipeConfig = this.manager.recipe.getConfig(); sessionStorage.setItem("recipeConfig", JSON.stringify(recipeConfig)); return recipeConfig; @@ -430,7 +430,7 @@ HTMLApp.prototype.getRecipeConfig = function() { * * @param {Object[]} recipeConfig - The recipe configuration */ -HTMLApp.prototype.setRecipeConfig = function(recipeConfig) { +App.prototype.setRecipeConfig = function(recipeConfig) { sessionStorage.setItem("recipeConfig", JSON.stringify(recipeConfig)); document.getElementById("rec-list").innerHTML = null; @@ -471,7 +471,7 @@ HTMLApp.prototype.setRecipeConfig = function(recipeConfig) { /** * Resets the splitter positions to default. */ -HTMLApp.prototype.resetLayout = function() { +App.prototype.resetLayout = function() { this.columnSplitter.setSizes([20, 30, 50]); this.ioSplitter.setSizes([50, 50]); @@ -483,7 +483,7 @@ HTMLApp.prototype.resetLayout = function() { /** * Sets the compile message. */ -HTMLApp.prototype.setCompileMessage = function() { +App.prototype.setCompileMessage = function() { // Display time since last build and compile message var now = new Date(), timeSinceCompile = Utils.fuzzyTime(now.getTime() - window.compileTime), @@ -522,7 +522,7 @@ HTMLApp.prototype.setCompileMessage = function() { * // that will disappear after 5 seconds. * this.alert("Happy Christmas!", "info", 5000); */ -HTMLApp.prototype.alert = function(str, style, timeout, silent) { +App.prototype.alert = function(str, style, timeout, silent) { var time = new Date(); console.log("[" + time.toLocaleString() + "] " + str); @@ -576,7 +576,7 @@ HTMLApp.prototype.alert = function(str, style, timeout, silent) { * // Pops up a box asking if the user would like a cookie. Prints the answer to the console. * this.confirm("Question", "Would you like a cookie?", function(answer) {console.log(answer);}); */ -HTMLApp.prototype.confirm = function(title, body, callback, scope) { +App.prototype.confirm = function(title, body, callback, scope) { scope = scope || this; document.getElementById("confirm-title").innerHTML = title; document.getElementById("confirm-body").innerHTML = body; @@ -604,7 +604,7 @@ HTMLApp.prototype.confirm = function(title, body, callback, scope) { * Handler for the alert close button click event. * Closes the alert box. */ -HTMLApp.prototype.alertCloseClick = function() { +App.prototype.alertCloseClick = function() { document.getElementById("alert").style.display = "none"; }; @@ -616,7 +616,7 @@ HTMLApp.prototype.alertCloseClick = function() { * @listens Manager#statechange * @param {event} e */ -HTMLApp.prototype.stateChange = function(e) { +App.prototype.stateChange = function(e) { this.autoBake(); // Update the current history state (not creating a new one) @@ -633,7 +633,7 @@ HTMLApp.prototype.stateChange = function(e) { * * @param {event} e */ -HTMLApp.prototype.popState = function(e) { +App.prototype.popState = function(e) { if (window.location.href.split("#")[0] !== this.lastStateUrl) { this.loadURIParams(); } @@ -643,7 +643,7 @@ HTMLApp.prototype.popState = function(e) { /** * Function to call an external API from this view. */ -HTMLApp.prototype.callApi = function(url, type, data, dataType, contentType) { +App.prototype.callApi = function(url, type, data, dataType, contentType) { type = type || "POST"; data = data || {}; dataType = dataType || undefined; @@ -674,3 +674,5 @@ HTMLApp.prototype.callApi = function(url, type, data, dataType, contentType) { response: response }; }; + +export default App; diff --git a/src/web/ControlsWaiter.js b/src/web/ControlsWaiter.js index aeac07f0..9896ed9e 100755 --- a/src/web/ControlsWaiter.js +++ b/src/web/ControlsWaiter.js @@ -1,4 +1,4 @@ -var Utils = require("../core/Utils.js"); +import Utils from "../core/Utils.js"; /** @@ -9,10 +9,10 @@ var Utils = require("../core/Utils.js"); * @license Apache-2.0 * * @constructor - * @param {HTMLApp} app - The main view object for CyberChef. + * @param {App} app - The main view object for CyberChef. * @param {Manager} manager - The CyberChef event manager. */ -var ControlsWaiter = module.exports = function(app, manager) { +var ControlsWaiter = function(app, manager) { this.app = app; this.manager = manager; }; @@ -358,3 +358,5 @@ ControlsWaiter.prototype.supportButtonClick = function() { "* User-Agent: \n" + navigator.userAgent + "\n" + "* [Link to reproduce](" + saveLink + ")\n\n"; }; + +export default ControlsWaiter; diff --git a/src/web/HTMLCategory.js b/src/web/HTMLCategory.js index d0b1b61b..d1120c20 100755 --- a/src/web/HTMLCategory.js +++ b/src/web/HTMLCategory.js @@ -9,7 +9,7 @@ * @param {string} name - The name of the category. * @param {boolean} selected - Whether this category is pre-selected or not. */ -var HTMLCategory = module.exports = function(name, selected) { +var HTMLCategory = function(name, selected) { this.name = name; this.selected = selected; this.opList = []; @@ -48,3 +48,5 @@ HTMLCategory.prototype.toHtml = function() { html += ""; return html; }; + +export default HTMLCategory; diff --git a/src/web/HTMLIngredient.js b/src/web/HTMLIngredient.js index b1e3f471..05e98b9c 100755 --- a/src/web/HTMLIngredient.js +++ b/src/web/HTMLIngredient.js @@ -7,10 +7,10 @@ * * @constructor * @param {Object} config - The configuration object for this ingredient. - * @param {HTMLApp} app - The main view object for CyberChef. + * @param {App} app - The main view object for CyberChef. * @param {Manager} manager - The CyberChef event manager. */ -var HTMLIngredient = module.exports = function(config, app, manager) { +var HTMLIngredient = function(config, app, manager) { this.app = app; this.manager = manager; @@ -210,3 +210,5 @@ HTMLIngredient.prototype.editableOptionChange = function(e) { this.manager.recipe.ingChange(); }; + +export default HTMLIngredient; diff --git a/src/web/HTMLOperation.js b/src/web/HTMLOperation.js index 92a081ad..dd9a8ee1 100755 --- a/src/web/HTMLOperation.js +++ b/src/web/HTMLOperation.js @@ -1,4 +1,4 @@ -var HTMLIngredient = require("./HTMLIngredient.js"); +import HTMLIngredient from "./HTMLIngredient.js"; /** @@ -11,10 +11,10 @@ var HTMLIngredient = require("./HTMLIngredient.js"); * @constructor * @param {string} name - The name of the operation. * @param {Object} config - The configuration object for this operation. - * @param {HTMLApp} app - The main view object for CyberChef. + * @param {App} app - The main view object for CyberChef. * @param {Manager} manager - The CyberChef event manager. */ -var HTMLOperation = module.exports = function(name, config, app, manager) { +var HTMLOperation = function(name, config, app, manager) { this.app = app; this.manager = manager; @@ -115,3 +115,5 @@ HTMLOperation.prototype.highlightSearchString = function(searchStr, namePos, des this.description.slice(descPos + searchStr.length); } }; + +export default HTMLOperation; diff --git a/src/web/HighlighterWaiter.js b/src/web/HighlighterWaiter.js index e848c2bb..56e4ae81 100755 --- a/src/web/HighlighterWaiter.js +++ b/src/web/HighlighterWaiter.js @@ -1,4 +1,4 @@ -var Utils = require("../core/Utils.js"); +import Utils from "../core/Utils.js"; /** @@ -9,9 +9,9 @@ var Utils = require("../core/Utils.js"); * @license Apache-2.0 * * @constructor - * @param {HTMLApp} app - The main view object for CyberChef. + * @param {App} app - The main view object for CyberChef. */ -var HighlighterWaiter = module.exports = function(app) { +var HighlighterWaiter = function(app) { this.app = app; this.mouseButtonDown = false; @@ -507,3 +507,5 @@ HighlighterWaiter.prototype.highlight = function(textarea, highlighter, pos) { highlighter.scrollTop = textarea.scrollTop; highlighter.scrollLeft = textarea.scrollLeft; }; + +export default HighlighterWaiter; diff --git a/src/web/InputWaiter.js b/src/web/InputWaiter.js index 8b85c1e4..158d2b70 100755 --- a/src/web/InputWaiter.js +++ b/src/web/InputWaiter.js @@ -1,4 +1,4 @@ -var Utils = require("../core/Utils.js"); +import Utils from "../core/Utils.js"; /** @@ -9,10 +9,10 @@ var Utils = require("../core/Utils.js"); * @license Apache-2.0 * * @constructor - * @param {HTMLApp} app - The main view object for CyberChef. + * @param {App} app - The main view object for CyberChef. * @param {Manager} manager - The CyberChef event manager. */ -var InputWaiter = module.exports = function(app, manager) { +var InputWaiter = function(app, manager) { this.app = app; this.manager = manager; @@ -218,3 +218,5 @@ InputWaiter.prototype.clearIoClick = function() { document.getElementById("output-selection-info").innerHTML = ""; window.dispatchEvent(this.manager.statechange); }; + +export default InputWaiter; diff --git a/src/web/Manager.js b/src/web/Manager.js index ed71cd4a..28b9f93a 100755 --- a/src/web/Manager.js +++ b/src/web/Manager.js @@ -1,12 +1,12 @@ -var WindowWaiter = require("./WindowWaiter.js"), - ControlsWaiter = require("./ControlsWaiter.js"), - RecipeWaiter = require("./RecipeWaiter.js"), - OperationsWaiter = require("./OperationsWaiter.js"), - InputWaiter = require("./InputWaiter.js"), - OutputWaiter = require("./OutputWaiter.js"), - OptionsWaiter = require("./OptionsWaiter.js"), - HighlighterWaiter = require("./HighlighterWaiter.js"), - SeasonalWaiter = require("./SeasonalWaiter.js"); +import WindowWaiter from "./WindowWaiter.js"; +import ControlsWaiter from "./ControlsWaiter.js"; +import RecipeWaiter from "./RecipeWaiter.js"; +import OperationsWaiter from "./OperationsWaiter.js"; +import InputWaiter from "./InputWaiter.js"; +import OutputWaiter from "./OutputWaiter.js"; +import OptionsWaiter from "./OptionsWaiter.js"; +import HighlighterWaiter from "./HighlighterWaiter.js"; +import SeasonalWaiter from "./SeasonalWaiter.js"; /** @@ -17,9 +17,9 @@ var WindowWaiter = require("./WindowWaiter.js"), * @license Apache-2.0 * * @constructor - * @param {HTMLApp} app - The main view object for CyberChef. + * @param {App} app - The main view object for CyberChef. */ -var Manager = module.exports = function(app) { +var Manager = function(app) { this.app = app; // Define custom events @@ -274,3 +274,5 @@ Manager.prototype.dynamicListenerHandler = function(e) { } } }; + +export default Manager; diff --git a/src/web/OperationsWaiter.js b/src/web/OperationsWaiter.js index f47e5b55..997c4ff8 100755 --- a/src/web/OperationsWaiter.js +++ b/src/web/OperationsWaiter.js @@ -1,5 +1,5 @@ -var HTMLOperation = require("./HTMLOperation.js"), - Sortable = require("sortablejs"); +import HTMLOperation from "./HTMLOperation.js"; +import Sortable from "sortablejs"; /** @@ -10,10 +10,10 @@ var HTMLOperation = require("./HTMLOperation.js"), * @license Apache-2.0 * * @constructor - * @param {HTMLApp} app - The main view object for CyberChef. + * @param {App} app - The main view object for CyberChef. * @param {Manager} manager - The CyberChef event manager. */ -var OperationsWaiter = module.exports = function(app, manager) { +var OperationsWaiter = function(app, manager) { this.app = app; this.manager = manager; @@ -283,3 +283,5 @@ OperationsWaiter.prototype.opIconMouseleave = function(e) { $(opEl).popover("show"); } }; + +export default OperationsWaiter; diff --git a/src/web/OptionsWaiter.js b/src/web/OptionsWaiter.js index 6afc6945..d7c89eb6 100755 --- a/src/web/OptionsWaiter.js +++ b/src/web/OptionsWaiter.js @@ -6,9 +6,9 @@ * @license Apache-2.0 * * @constructor - * @param {HTMLApp} app - The main view object for CyberChef. + * @param {App} app - The main view object for CyberChef. */ -var OptionsWaiter = module.exports = function(app) { +var OptionsWaiter = function(app) { this.app = app; }; @@ -130,3 +130,5 @@ OptionsWaiter.prototype.setWordWrap = function() { document.getElementById("output-highlighter").classList.add("word-wrap"); } }; + +export default OptionsWaiter; diff --git a/src/web/OutputWaiter.js b/src/web/OutputWaiter.js index 663d17fe..90f297d3 100755 --- a/src/web/OutputWaiter.js +++ b/src/web/OutputWaiter.js @@ -1,4 +1,4 @@ -var Utils = require("../core/Utils.js"); +import Utils from "../core/Utils.js"; /** @@ -9,10 +9,10 @@ var Utils = require("../core/Utils.js"); * @license Apache-2.0 * * @constructor - * @param {HTMLApp} app - The main view object for CyberChef. + * @param {App} app - The main view object for CyberChef. * @param {Manager} manager - The CyberChef event manager. */ -var OutputWaiter = module.exports = function(app, manager) { +var OutputWaiter = function(app, manager) { this.app = app; this.manager = manager; }; @@ -189,3 +189,5 @@ OutputWaiter.prototype.maximiseOutputClick = function(e) { this.app.resetLayout(); } }; + +export default OutputWaiter; diff --git a/src/web/RecipeWaiter.js b/src/web/RecipeWaiter.js index e6e98dfa..2829ccdc 100755 --- a/src/web/RecipeWaiter.js +++ b/src/web/RecipeWaiter.js @@ -1,5 +1,5 @@ -var HTMLOperation = require("./HTMLOperation.js"), - Sortable = require("sortablejs"); +import HTMLOperation from "./HTMLOperation.js"; +import Sortable from "sortablejs"; /** @@ -10,10 +10,10 @@ var HTMLOperation = require("./HTMLOperation.js"), * @license Apache-2.0 * * @constructor - * @param {HTMLApp} app - The main view object for CyberChef. + * @param {App} app - The main view object for CyberChef. * @param {Manager} manager - The CyberChef event manager. */ -var RecipeWaiter = module.exports = function(app, manager) { +var RecipeWaiter = function(app, manager) { this.app = app; this.manager = manager; this.removeIntent = false; @@ -424,3 +424,5 @@ RecipeWaiter.prototype.opAdd = function(e) { RecipeWaiter.prototype.opRemove = function(e) { window.dispatchEvent(this.manager.statechange); }; + +export default RecipeWaiter; diff --git a/src/web/SeasonalWaiter.js b/src/web/SeasonalWaiter.js index 3de85a19..ad897b63 100755 --- a/src/web/SeasonalWaiter.js +++ b/src/web/SeasonalWaiter.js @@ -6,10 +6,10 @@ * @license Apache-2.0 * * @constructor - * @param {HTMLApp} app - The main view object for CyberChef. + * @param {App} app - The main view object for CyberChef. * @param {Manager} manager - The CyberChef event manager. */ -var SeasonalWaiter = module.exports = function(app, manager) { +var SeasonalWaiter = function(app, manager) { this.app = app; this.manager = manager; }; @@ -150,3 +150,5 @@ SeasonalWaiter.treeWalk = (function() { } }; })(); + +export default SeasonalWaiter; diff --git a/src/web/WindowWaiter.js b/src/web/WindowWaiter.js index 378f0550..d85ee6b6 100755 --- a/src/web/WindowWaiter.js +++ b/src/web/WindowWaiter.js @@ -6,9 +6,9 @@ * @license Apache-2.0 * * @constructor - * @param {HTMLApp} app - The main view object for CyberChef. + * @param {App} app - The main view object for CyberChef. */ -var WindowWaiter = module.exports = function(app) { +var WindowWaiter = function(app) { this.app = app; }; @@ -50,3 +50,5 @@ WindowWaiter.prototype.windowFocus = function() { this.app.silentBake(); } }; + +export default WindowWaiter; diff --git a/src/web/css/index.js b/src/web/css/index.js index 75f0d126..6c76009a 100644 --- a/src/web/css/index.js +++ b/src/web/css/index.js @@ -6,13 +6,13 @@ * @license Apache-2.0 */ -require("google-code-prettify/src/prettify.css"); +import "google-code-prettify/src/prettify.css"; -require("./lib/bootstrap.less"); -require("bootstrap-switch/src/less/bootstrap3/build.less"); -require("bootstrap-colorpicker/dist/css/bootstrap-colorpicker.css"); +import "./lib/bootstrap.less"; +import "bootstrap-switch/src/less/bootstrap3/build.less"; +import "bootstrap-colorpicker/dist/css/bootstrap-colorpicker.css"; -require("./structure/overrides.css"); -require("./structure/layout.css"); -require("./structure/utils.css"); -require("./themes/classic.css"); +import "./structure/overrides.css"; +import "./structure/layout.css"; +import "./structure/utils.css"; +import "./themes/classic.css"; diff --git a/src/web/css/lib/bootstrap.less b/src/web/css/lib/bootstrap.less index f71b6ee7..12637095 100644 --- a/src/web/css/lib/bootstrap.less +++ b/src/web/css/lib/bootstrap.less @@ -45,7 +45,7 @@ @import "~bootstrap/less/panels.less"; // @import "~bootstrap/less/responsive-embed.less"; // @import "~bootstrap/less/wells.less"; -// @import "~bootstrap/less/close.less"; +@import "~bootstrap/less/close.less"; // Components w/ JavaScript @import "~bootstrap/less/modals.less"; diff --git a/src/web/index.js b/src/web/index.js index 8b65958e..e86baf4c 100755 --- a/src/web/index.js +++ b/src/web/index.js @@ -4,10 +4,10 @@ * @license Apache-2.0 */ -var HTMLApp = require("./HTMLApp.js"), - Categories = require("../core/config/Categories.js"), - OperationConfig = require("../core/config/OperationConfig.js"), - CanvasComponents = require("../core/lib/canvascomponents.js"); +import App from "./App.js"; +import Categories from "../core/config/Categories.js"; +import OperationConfig from "../core/config/OperationConfig.js"; +import CanvasComponents from "../core/lib/canvascomponents.js"; /** * Main function used to build the CyberChef web app. @@ -38,7 +38,7 @@ var main = function() { }; document.removeEventListener("DOMContentLoaded", main, false); - window.app = new HTMLApp(Categories, OperationConfig, defaultFavourites, defaultOptions); + window.app = new App(Categories, OperationConfig, defaultFavourites, defaultOptions); window.app.setup(); }; diff --git a/test/TestRegister.js b/test/TestRegister.js index 5a00eca8..fdd3431b 100644 --- a/test/TestRegister.js +++ b/test/TestRegister.js @@ -8,7 +8,7 @@ * @copyright Crown Copyright 2017 * @license Apache-2.0 */ -var Chef = require("../src/core/Chef.js"); +import Chef from "../src/core/Chef.js"; (function() { /** @@ -87,5 +87,7 @@ var Chef = require("../src/core/Chef.js"); // Singleton TestRegister, keeping things simple and obvious. global.TestRegister = global.TestRegister || new TestRegister(); - module.exports = global.TestRegister; })(); + +export default global.TestRegister; + diff --git a/test/TestRunner.js b/test/TestRunner.js index 22961b62..e0d735fb 100644 --- a/test/TestRunner.js +++ b/test/TestRunner.js @@ -8,25 +8,18 @@ * @copyright Crown Copyright 2017 * @license Apache-2.0 */ -var TestRegister = require("./TestRegister.js"), - allTestsPassing = true, +import TestRegister from "./TestRegister.js"; +import "./tests/operations/Base58.js"; +import "./tests/operations/Compress.js"; +import "./tests/operations/FlowControl.js"; +import "./tests/operations/MorseCode.js"; +import "./tests/operations/StrUtils.js"; + +var allTestsPassing = true, testStatusCounts = { total: 0, }; -/** - * Requires and returns all modules that match. - * - * @param {Object} requireContext - * @returns {Object[]} - */ -function requireAll(requireContext) { - return requireContext.keys().map(requireContext); -} - -// Import all tests -requireAll(require.context("./tests", true, /.+\.js$/)); - /** * Helper function to convert a status to an icon. diff --git a/test/tests/operations/Base58.js b/test/tests/operations/Base58.js index c3b3eaf7..d09a3fc4 100644 --- a/test/tests/operations/Base58.js +++ b/test/tests/operations/Base58.js @@ -6,7 +6,7 @@ * @copyright Crown Copyright 2017 * @license Apache-2.0 */ -var TestRegister = require("../../TestRegister.js"); +import TestRegister from "../../TestRegister.js"; TestRegister.addTests([ { diff --git a/test/tests/operations/Compress.js b/test/tests/operations/Compress.js index 815ecf94..41046b40 100644 --- a/test/tests/operations/Compress.js +++ b/test/tests/operations/Compress.js @@ -5,7 +5,7 @@ * @copyright Crown Copyright 2017 * @license Apache-2.0 */ -var TestRegister = require("../../TestRegister.js"); +import TestRegister from "../../TestRegister.js"; TestRegister.addTests([ { diff --git a/test/tests/operations/FlowControl.js b/test/tests/operations/FlowControl.js index 8d986c6b..96ae2e80 100644 --- a/test/tests/operations/FlowControl.js +++ b/test/tests/operations/FlowControl.js @@ -6,7 +6,7 @@ * @copyright Crown Copyright 2017 * @license Apache-2.0 */ -var TestRegister = require("../../TestRegister.js"); +import TestRegister from "../../TestRegister.js"; TestRegister.addTests([ { diff --git a/test/tests/operations/MorseCode.js b/test/tests/operations/MorseCode.js index 9fe68b02..4f4d59fa 100644 --- a/test/tests/operations/MorseCode.js +++ b/test/tests/operations/MorseCode.js @@ -6,7 +6,7 @@ * @copyright Crown Copyright 2017 * @license Apache-2.0 */ -var TestRegister = require("../../TestRegister.js"); +import TestRegister from "../../TestRegister.js"; TestRegister.addTests([ { diff --git a/test/tests/operations/StrUtils.js b/test/tests/operations/StrUtils.js index 15d4bc4b..de0140aa 100644 --- a/test/tests/operations/StrUtils.js +++ b/test/tests/operations/StrUtils.js @@ -5,7 +5,7 @@ * @copyright Crown Copyright 2017 * @license Apache-2.0 */ -var TestRegister = require("../../TestRegister.js"); +import TestRegister from "../../TestRegister.js"; TestRegister.addTests([ {