Converted the majority of the core and operations to use CommonJS module syntax.

This commit is contained in:
n1474335 2017-03-06 12:45:51 +00:00
parent a4197684e5
commit a21e0e546b
50 changed files with 308 additions and 123 deletions

View file

@ -25,6 +25,9 @@
"type": "git",
"url": "https://github.com/gchq/CyberChef/"
},
"scripts": {
"build": "webpack"
},
"devDependencies": {
"grunt": "~1.0.1",
"grunt-chmod": "~1.1.1",
@ -41,6 +44,25 @@
"grunt-inline-alt": "~0.3.10",
"grunt-jsdoc": "^2.1.0",
"ink-docstrap": "^1.1.4",
"phantomjs-prebuilt": "^2.1.14"
"phantomjs-prebuilt": "^2.1.14",
"webpack": "^2.2.1"
},
"dependencies": {
"crypto-api": "^0.6.2",
"crypto-js": "^3.1.9-1",
"diff": "^3.2.0",
"escodegen": "^1.8.1",
"esmangle": "^1.0.1",
"esprima": "^3.1.3",
"google-code-prettify": "^1.0.5",
"jquery": "^3.1.1",
"jsbn": "^1.1.0",
"jsrsasign": "^7.1.0",
"moment": "^2.17.1",
"moment-timezone": "^0.5.11",
"sladex-blowfish": "^0.8.1",
"uas-parser": "^0.2.2",
"vkbeautify": "^0.99.1",
"zlibjs": "^0.2.0"
}
}

View file

@ -9,7 +9,8 @@
"browser": true,
"jquery": true,
"es6": true,
"node": false
"commonjs": true,
"node": true
},
"extends": "eslint:recommended",
"rules": {

View file

@ -17,7 +17,7 @@
* @constant
* @type {CatConf[]}
*/
var Categories = [
var Categories = module.exports = [
{
name: "Favourites",
ops: []

View file

@ -1,8 +1,41 @@
/*
* Tell eslint to ignore "'Object' is not defined" errors in this file, as it references every
* single operation object by definition.
*/
/* eslint no-undef: "off" */
var FlowControl = require("../core/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");
/**
@ -45,7 +78,7 @@
* @constant
* @type {Object.<string, OpConf>}
*/
var OperationConfig = {
var OperationConfig = module.exports = {
"Fork": {
description: "Split the input data up based on the specified delimiter and run all subsequent operations on each branch separately.<br><br>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,

View file

@ -1,3 +1,7 @@
var Dish = require("./Dish.js"),
Recipe = require("./Recipe.js");
/**
* The main controller for CyberChef.
*
@ -7,7 +11,7 @@
*
* @class
*/
var Chef = function() {
var Chef = module.exports = function() {
this.dish = new Dish();
};

View file

@ -1,3 +1,6 @@
var Utils = require("./Utils.js");
/**
* The data being operated on by each operation.
*
@ -9,7 +12,7 @@
* @param {byteArray|string|number} value - The value of the input data.
* @param {number} type - The data type of value, see Dish enums.
*/
var Dish = function(value, type) {
var Dish = module.exports = function(value, type) {
this.value = value || typeof value == "string" ? value : null;
this.type = type || Dish.BYTE_ARRAY;
};

View file

@ -7,7 +7,7 @@
*
* @namespace
*/
var FlowControl = {
var FlowControl = module.exports = {
/**
* @constant

View file

@ -1,3 +1,6 @@
var Utils = require("./Utils.js");
/**
* The arguments to operations.
*
@ -8,7 +11,7 @@
* @class
* @param {Object} ingredientConfig
*/
var Ingredient = function(ingredientConfig) {
var Ingredient = module.exports = function(ingredientConfig) {
this.name = "";
this.type = "";
this.value = null;

View file

@ -1,3 +1,7 @@
var Dish = require("./Dish.js"),
Ingredient = require("./Ingredient.js");
/**
* The Operation specified by the user to be run.
*
@ -9,7 +13,7 @@
* @param {string} operationName
* @param {Object} operationConfig
*/
var Operation = function(operationName, operationConfig) {
var Operation = module.exports = function(operationName, operationConfig) {
this.name = operationName;
this.description = "";
this.inputType = -1;

View file

@ -1,3 +1,7 @@
var OperationConfig = require("../config/OperationConfig.js"),
Operation = require("./Operation.js");
/**
* The Recipe controls a list of Operations and the Dish they operate on.
*
@ -8,7 +12,7 @@
* @class
* @param {Object} recipeConfig
*/
var Recipe = function(recipeConfig) {
var Recipe = module.exports = function(recipeConfig) {
this.opList = [];
if (recipeConfig) {

View file

@ -1,4 +1,7 @@
/* globals CryptoJS, moment */
var CryptoJS = require("crypto-js"),
moment = require("moment"),
$ = require("jquery");
/**
* Utility functions for use in operations, the core framework and the stage.
@ -9,7 +12,7 @@
*
* @namespace
*/
var Utils = {
var Utils = module.exports = {
/**
* Translates an ordinal into a character.
@ -1182,21 +1185,21 @@ var Utils = {
* // Places the cursor at the beginning of the element #input-text.
* $("#input-text").selectRange(0);
*/
$.fn.selectRange = function(start, end) {
if (!end) end = start;
return this.each(function() {
if (this.setSelectionRange) {
this.focus();
this.setSelectionRange(start, end);
} else if (this.createTextRange) {
var range = this.createTextRange();
range.collapse(true);
range.moveEnd("character", end);
range.moveStart("character", start);
range.select();
}
});
};
// $.fn.selectRange = function(start, end) {
// if (!end) end = start;
// return this.each(function() {
// if (this.setSelectionRange) {
// this.focus();
// this.setSelectionRange(start, end);
// } else if (this.createTextRange) {
// var range = this.createTextRange();
// range.collapse(true);
// range.moveEnd("character", end);
// range.moveStart("character", start);
// range.select();
// }
// });
// };
/**

View file

@ -7,7 +7,7 @@
*
* @namespace
*/
var Base = {
var Base = module.exports = {
/**
* @constant

View file

@ -1,3 +1,6 @@
var Utils = require("../core/Utils.js");
/**
* Base58 operations.
*
@ -7,7 +10,7 @@
*
* @namespace
*/
var Base58 = {
var Base58 = module.exports = {
/**
* @constant

View file

@ -1,3 +1,6 @@
var Utils = require("../core/Utils.js");
/**
* Base64 operations.
*
@ -7,7 +10,7 @@
*
* @namespace
*/
var Base64 = {
var Base64 = module.exports = {
/**
* @constant

View file

@ -1,4 +1,6 @@
/* globals CryptoJS */
var Utils = require("../core/Utils.js"),
CryptoJS = require("crypto-js");
/**
* Bitwise operations.
@ -9,7 +11,7 @@
*
* @namespace
*/
var BitwiseOp = {
var BitwiseOp = module.exports = {
/**
* Runs bitwise operations across the input data.

View file

@ -1,4 +1,6 @@
/* globals app */
var Utils = require("../core/Utils.js");
/**
* Byte representation operations.
@ -9,7 +11,7 @@
*
* @namespace
*/
var ByteRepr = {
var ByteRepr = module.exports = {
/**
* @constant

View file

@ -1,4 +1,6 @@
/* globals CryptoJS */
var Utils = require("../core/Utils.js"),
CryptoJS = require("crypto-js");
/**
* Character encoding operations.
@ -9,7 +11,7 @@
*
* @namespace
*/
var CharEnc = {
var CharEnc = module.exports = {
/**
* @constant

View file

@ -1,3 +1,6 @@
var Utils = require("../core/Utils.js");
/**
* Checksum operations.
*
@ -7,7 +10,7 @@
*
* @namespace
*/
var Checksum = {
var Checksum = module.exports = {
/**
* Fletcher-8 Checksum operation.

View file

@ -1,4 +1,7 @@
/* globals CryptoJS, blowfish */
var Utils = require("../core/Utils.js"),
CryptoJS = require("crypto-js"),
Blowfish = require("sladex-blowfish");
/**
* Cipher operations.
@ -9,7 +12,7 @@
*
* @namespace
*/
var Cipher = {
var Cipher = module.exports = {
/**
* @constant
@ -263,7 +266,7 @@ var Cipher = {
if (key.length === 0) return "Enter a key";
var encHex = blowfish.encrypt(input, key, {
var encHex = Blowfish.encrypt(input, key, {
outputType: 1,
cipherMode: Cipher.BLOWFISH_MODES.indexOf(mode)
}),
@ -289,7 +292,7 @@ var Cipher = {
input = Utils.format[inputFormat].parse(input);
return blowfish.decrypt(input.toString(CryptoJS.enc.Base64), key, {
return Blowfish.decrypt(input.toString(CryptoJS.enc.Base64), key, {
outputType: 0, // This actually means inputType. The library is weird.
cipherMode: Cipher.BLOWFISH_MODES.indexOf(mode)
});

View file

@ -1,4 +1,8 @@
/* globals prettyPrintOne, vkbeautify, xpath */
/* globals xpath */
var Utils = require("../core/Utils.js"),
VKbeautify = require("vkbeautify");
//Prettify = require("google-code-prettify");
/**
* Code operations.
@ -9,7 +13,7 @@
*
* @namespace
*/
var Code = {
var Code = module.exports = {
/**
* @constant
@ -32,7 +36,7 @@ var Code = {
runSyntaxHighlight: function(input, args) {
var language = args[0],
lineNums = args[1];
return "<code class='prettyprint'>" + prettyPrintOne(Utils.escapeHtml(input), language, lineNums) + "</code>";
return "<code class='prettyprint'>" + Prettify.prettyPrintOne(Utils.escapeHtml(input), language, lineNums) + "</code>";
},
@ -51,7 +55,7 @@ var Code = {
*/
runXmlBeautify: function(input, args) {
var indentStr = args[0];
return vkbeautify.xml(input, indentStr);
return VKbeautify.xml(input, indentStr);
},
@ -65,7 +69,7 @@ var Code = {
runJsonBeautify: function(input, args) {
var indentStr = args[0];
if (!input) return "";
return vkbeautify.json(input, indentStr);
return VKbeautify.json(input, indentStr);
},
@ -78,7 +82,7 @@ var Code = {
*/
runCssBeautify: function(input, args) {
var indentStr = args[0];
return vkbeautify.css(input, indentStr);
return VKbeautify.css(input, indentStr);
},
@ -91,7 +95,7 @@ var Code = {
*/
runSqlBeautify: function(input, args) {
var indentStr = args[0];
return vkbeautify.sql(input, indentStr);
return VKbeautify.sql(input, indentStr);
},
@ -110,7 +114,7 @@ var Code = {
*/
runXmlMinify: function(input, args) {
var preserveComments = args[0];
return vkbeautify.xmlmin(input, preserveComments);
return VKbeautify.xmlmin(input, preserveComments);
},
@ -123,7 +127,7 @@ var Code = {
*/
runJsonMinify: function(input, args) {
if (!input) return "";
return vkbeautify.jsonmin(input);
return VKbeautify.jsonmin(input);
},
@ -136,7 +140,7 @@ var Code = {
*/
runCssMinify: function(input, args) {
var preserveComments = args[0];
return vkbeautify.cssmin(input, preserveComments);
return VKbeautify.cssmin(input, preserveComments);
},
@ -148,7 +152,7 @@ var Code = {
* @returns {string}
*/
runSqlMinify: function(input, args) {
return vkbeautify.sqlmin(input);
return VKbeautify.sqlmin(input);
},

View file

@ -1,4 +1,21 @@
/* globals Zlib, bzip2 */
/* globals bzip2 */
var 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");
var Zlib = {
RawDeflate: rawdeflate.Zlib.RawDeflate,
RawInflate: rawinflate.Zlib.RawInflate,
Deflate: zlibAndGzip.Zlib.Deflate,
Inflate: zlibAndGzip.Zlib.Inflate,
Gzip: zlibAndGzip.Zlib.Gzip,
Gunzip: zlibAndGzip.Zlib.Gunzip,
Zip: zip.Zlib.Zip,
Unzip: unzip.Zlib.Unzip,
};
/**
* Compression operations.
@ -9,7 +26,7 @@
*
* @namespace
*/
var Compress = {
var Compress = module.exports = {
/**
* @constant

View file

@ -7,7 +7,7 @@
*
* @namespace
*/
var Convert = {
var Convert = module.exports = {
/**
* @constant

View file

@ -1,4 +1,5 @@
/* globals moment */
var moment = require("moment-timezone");
/**
* Date and time operations.
@ -9,7 +10,7 @@
*
* @namespace
*/
var DateTime = {
var DateTime = module.exports = {
/**
* @constant

View file

@ -1,3 +1,6 @@
var Utils = require("../core/Utils.js");
/**
* Endian operations.
*
@ -7,7 +10,7 @@
*
* @namespace
*/
var Endian = {
var Endian = module.exports = {
/**
* @constant

View file

@ -1,3 +1,6 @@
var Utils = require("../core/Utils.js");
/**
* Entropy operations.
*
@ -7,7 +10,7 @@
*
* @namespace
*/
var Entropy = {
var Entropy = module.exports = {
/**
* @constant

View file

@ -7,7 +7,7 @@
*
* @namespace
*/
var Extract = {
var Extract = module.exports = {
/**
* Runs search operations across the input data using regular expressions.

View file

@ -1,3 +1,6 @@
var Utils = require("../core/Utils.js");
/**
* File type operations.
*
@ -7,7 +10,7 @@
*
* @namespace
*/
var FileType = {
var FileType = module.exports = {
/**
* Detect File Type operation.

View file

@ -1,3 +1,6 @@
var Utils = require("../core/Utils.js");
/**
* HTML operations.
*
@ -7,7 +10,7 @@
*
* @namespace
*/
var HTML = {
var HTML = module.exports = {
/**
* @constant

View file

@ -1,4 +1,5 @@
/* globals UAS_parser */
var UAParser = require("uas-parser");
/**
* HTTP operations.
@ -9,7 +10,7 @@
*
* @namespace
*/
var HTTP = {
var HTTP = module.exports = {
/**
* Strip HTTP headers operation.
@ -34,7 +35,7 @@ var HTTP = {
* @returns {string}
*/
runParseUserAgent: function(input, args) {
var ua = UAS_parser.parse(input); // eslint-disable-line camelcase
var ua = UAParser.parse(input);
return "Type: " + ua.type + "\n" +
"Family: " + ua.uaFamily + "\n" +

View file

@ -1,4 +1,8 @@
/* globals CryptoApi, CryptoJS, Checksum */
var Utils = require("../core/Utils.js"),
CryptoJS = require("crypto-js"),
CryptoApi = require("crypto-api"),
Checksum = require("./Checksum.js");
/**
* Hashing operations.
@ -9,7 +13,7 @@
*
* @namespace
*/
var Hash = {
var Hash = module.exports = {
/**
* MD2 operation.

View file

@ -1,4 +1,6 @@
/* globals app */
var Utils = require("../core/Utils.js");
/**
* Hexdump operations.
@ -9,7 +11,7 @@
*
* @namespace
*/
var Hexdump = {
var Hexdump = module.exports = {
/**
* @constant

View file

@ -1,4 +1,7 @@
/* globals BigInteger, Checksum */
var Utils = require("../core/Utils.js"),
Checksum = require("./Checksum.js"),
BigInteger = require("jsbn").BigInteger;
/**
* Internet Protocol address operations.
@ -9,7 +12,7 @@
*
* @namespace
*/
var IP = {
var IP = module.exports = {
/**
* @constant

View file

@ -1,4 +1,7 @@
/* globals esprima, escodegen, esmangle */
var esprima = require("esprima"),
escodegen = require("escodegen"),
esmangle = require("esmangle");
/**
* JavaScript operations.
@ -9,7 +12,7 @@
*
* @namespace
*/
var JS = {
var JS = module.exports = {
/**
* @constant

View file

@ -7,7 +7,7 @@
*
* @namespace
*/
var MAC = {
var MAC = module.exports = {
/**
* @constant

View file

@ -1,3 +1,6 @@
var Utils = require("../core/Utils.js");
/**
* Morse Code translation operations.
*
@ -7,7 +10,7 @@
*
* @namespace
*/
var MorseCode = {
var MorseCode = module.exports = {
/**
* @constant

View file

@ -7,7 +7,7 @@
*
* @namespace
*/
var NetBIOS = {
var NetBIOS = module.exports = {
/**
* @constant

View file

@ -4,7 +4,7 @@
* @author Unknown Male 282
* @namespace
*/
var Numberwang = {
var Numberwang = module.exports = {
/**
* Numberwang operation. Remain indoors.

View file

@ -7,7 +7,7 @@
*
* @namespace
*/
var OS = {
var OS = module.exports = {
/**
* Parse UNIX file permissions operation.

View file

@ -1,4 +1,6 @@
/* globals X509, KJUR, ASN1HEX, KEYUTIL, BigInteger */
var Utils = require("../core/Utils.js"),
r = require("jsrsasign");
/**
* Public Key operations.
@ -9,7 +11,7 @@
*
* @namespace
*/
var PublicKey = {
var PublicKey = module.exports = {
/**
* @constant
@ -25,7 +27,7 @@ var PublicKey = {
* @returns {string}
*/
runParseX509: function (input, args) {
var cert = new X509(),
var cert = new r.X509(),
inputFormat = args[0];
if (!input.length) {
@ -36,39 +38,39 @@ var PublicKey = {
case "DER Hex":
input = input.replace(/\s/g, "");
cert.hex = input;
cert.pem = KJUR.asn1.ASN1Util.getPEMStringFromHex(input, "CERTIFICATE");
cert.pem = r.KJUR.asn1.ASN1Util.getPEMStringFromHex(input, "CERTIFICATE");
break;
case "PEM":
cert.hex = X509.pemToHex(input);
cert.hex = r.X509.pemToHex(input);
cert.pem = input;
break;
case "Base64":
cert.hex = Utils.toHex(Utils.fromBase64(input, null, "byteArray"), "");
cert.pem = KJUR.asn1.ASN1Util.getPEMStringFromHex(cert.hex, "CERTIFICATE");
cert.pem = r.KJUR.asn1.ASN1Util.getPEMStringFromHex(cert.hex, "CERTIFICATE");
break;
case "Raw":
cert.hex = Utils.toHex(Utils.strToByteArray(input), "");
cert.pem = KJUR.asn1.ASN1Util.getPEMStringFromHex(cert.hex, "CERTIFICATE");
cert.pem = r.KJUR.asn1.ASN1Util.getPEMStringFromHex(cert.hex, "CERTIFICATE");
break;
default:
throw "Undefined input format";
}
var version = ASN1HEX.getDecendantHexVByNthList(cert.hex, 0, [0, 0, 0]),
var version = r.ASN1HEX.getDecendantHexVByNthList(cert.hex, 0, [0, 0, 0]),
sn = cert.getSerialNumberHex(),
algorithm = KJUR.asn1.x509.OID.oid2name(KJUR.asn1.ASN1Util.oidHexToInt(ASN1HEX.getDecendantHexVByNthList(cert.hex, 0, [0, 2, 0]))),
algorithm = r.KJUR.asn1.x509.OID.oid2name(r.KJUR.asn1.ASN1Util.oidHexToInt(r.ASN1HEX.getDecendantHexVByNthList(cert.hex, 0, [0, 2, 0]))),
issuer = cert.getIssuerString(),
notBefore = cert.getNotBefore(),
notAfter = cert.getNotAfter(),
subject = cert.getSubjectString(),
pkAlgorithm = KJUR.asn1.x509.OID.oid2name(KJUR.asn1.ASN1Util.oidHexToInt(ASN1HEX.getDecendantHexVByNthList(cert.hex, 0, [0, 6, 0, 0]))),
pk = X509.getPublicKeyFromCertPEM(cert.pem),
pkAlgorithm = r.KJUR.asn1.x509.OID.oid2name(r.KJUR.asn1.ASN1Util.oidHexToInt(r.ASN1HEX.getDecendantHexVByNthList(cert.hex, 0, [0, 6, 0, 0]))),
pk = r.X509.getPublicKeyFromCertPEM(cert.pem),
pkFields = [],
pkStr = "",
certSigAlg = KJUR.asn1.x509.OID.oid2name(KJUR.asn1.ASN1Util.oidHexToInt(ASN1HEX.getDecendantHexVByNthList(cert.hex, 0, [1, 0]))),
certSig = ASN1HEX.getDecendantHexVByNthList(cert.hex, 0, [2]).substr(2),
certSigAlg = r.KJUR.asn1.x509.OID.oid2name(r.KJUR.asn1.ASN1Util.oidHexToInt(r.ASN1HEX.getDecendantHexVByNthList(cert.hex, 0, [1, 0]))),
certSig = r.ASN1HEX.getDecendantHexVByNthList(cert.hex, 0, [2]).substr(2),
sigStr = "",
extensions = ASN1HEX.dump(ASN1HEX.getDecendantHexVByNthList(cert.hex, 0, [0, 7]));
extensions = r.ASN1HEX.dump(r.ASN1HEX.getDecendantHexVByNthList(cert.hex, 0, [0, 7]));
// Public Key fields
if (pk.type === "EC") { // ECDSA
@ -78,7 +80,7 @@ var PublicKey = {
});
pkFields.push({
key: "Length",
value: (((new BigInteger(pk.pubKeyHex, 16)).bitLength()-3) /2) + " bits"
value: (((new r.BigInteger(pk.pubKeyHex, 16)).bitLength()-3) /2) + " bits"
});
pkFields.push({
key: "pub",
@ -122,9 +124,9 @@ var PublicKey = {
}
// Signature fields
if (ASN1HEX.dump(certSig).indexOf("SEQUENCE") === 0) { // DSA or ECDSA
sigStr = " r: " + PublicKey._formatByteStr(ASN1HEX.getDecendantHexVByNthList(certSig, 0, [0]), 16, 18) + "\n" +
" s: " + PublicKey._formatByteStr(ASN1HEX.getDecendantHexVByNthList(certSig, 0, [1]), 16, 18) + "\n";
if (r.ASN1HEX.dump(certSig).indexOf("SEQUENCE") === 0) { // DSA or ECDSA
sigStr = " r: " + PublicKey._formatByteStr(r.ASN1HEX.getDecendantHexVByNthList(certSig, 0, [0]), 16, 18) + "\n" +
" s: " + PublicKey._formatByteStr(r.ASN1HEX.getDecendantHexVByNthList(certSig, 0, [1]), 16, 18) + "\n";
} else { // RSA
sigStr = " Signature: " + PublicKey._formatByteStr(certSig, 16, 18) + "\n";
}
@ -145,7 +147,7 @@ var PublicKey = {
subjectStr = PublicKey._formatDnStr(subject, 2);
var output = "Version: " + (parseInt(version, 16) + 1) + " (0x" + version + ")\n" +
"Serial number: " + new BigInteger(sn, 16).toString() + " (0x" + sn + ")\n" +
"Serial number: " + new r.BigInteger(sn, 16).toString() + " (0x" + sn + ")\n" +
"Algorithm ID: " + algorithm + "\n" +
"Validity\n" +
" Not Before: " + nbDate + " (dd-mm-yy hh:mm:ss) (" + notBefore + ")\n" +
@ -183,7 +185,7 @@ var PublicKey = {
// Add footer so that the KEYUTIL function works
input = input + "-----END CERTIFICATE-----";
}
return KEYUTIL.getHexFromPEM(input);
return r.KEYUTIL.getHexFromPEM(input);
},
@ -201,7 +203,7 @@ var PublicKey = {
* @returns {string}
*/
runHexToPem: function(input, args) {
return KJUR.asn1.ASN1Util.getPEMStringFromHex(input.replace(/\s/g, ""), args[0]);
return r.KJUR.asn1.ASN1Util.getPEMStringFromHex(input.replace(/\s/g, ""), args[0]);
},
@ -213,7 +215,7 @@ var PublicKey = {
* @returns {string}
*/
runHexToObjectIdentifier: function(input, args) {
return KJUR.asn1.ASN1Util.oidHexToInt(input.replace(/\s/g, ""));
return r.KJUR.asn1.ASN1Util.oidHexToInt(input.replace(/\s/g, ""));
},
@ -225,7 +227,7 @@ var PublicKey = {
* @returns {string}
*/
runObjectIdentifierToHex: function(input, args) {
return KJUR.asn1.ASN1Util.oidIntToHex(input);
return r.KJUR.asn1.ASN1Util.oidIntToHex(input);
},
@ -245,7 +247,7 @@ var PublicKey = {
runParseAsn1HexString: function(input, args) {
var truncateLen = args[1],
index = args[0];
return ASN1HEX.dump(input.replace(/\s/g, ""), {
return r.ASN1HEX.dump(input.replace(/\s/g, ""), {
"ommitLongOctet": truncateLen
}, index);
},
@ -342,12 +344,12 @@ var PublicKey = {
* @param {string} hDN - Hex DN string
* @returns {string}
*/
X509.hex2dn = function(hDN) {
r.X509.hex2dn = function(hDN) {
var s = "";
var a = ASN1HEX.getPosArrayOfChildren_AtObj(hDN, 0);
var a = r.ASN1HEX.getPosArrayOfChildren_AtObj(hDN, 0);
for (var i = 0; i < a.length; i++) {
var hRDN = ASN1HEX.getHexOfTLV_AtObj(hDN, a[i]);
s = s + ",/|" + X509.hex2rdn(hRDN);
var hRDN = r.ASN1HEX.getHexOfTLV_AtObj(hDN, a[i]);
s = s + ",/|" + r.X509.hex2rdn(hRDN);
}
return s;
};
@ -361,7 +363,7 @@ X509.hex2dn = function(hDN) {
*
* @constant
*/
X509.DN_ATTRHEX = {
r.X509.DN_ATTRHEX = {
"0603550403" : "commonName",
"0603550404" : "surname",
"0603550406" : "countryName",

View file

@ -1,4 +1,5 @@
/* globals punycode */
var punycode = require("punycode");
/**
* Punycode operations.
@ -9,7 +10,7 @@
*
* @namespace
*/
var Punycode = {
var Punycode = module.exports = {
/**
* @constant
@ -28,7 +29,7 @@ var Punycode = {
var idn = args[0];
if (idn) {
return punycode.ToASCII(input);
return punycode.toASCII(input);
} else {
return punycode.encode(input);
}
@ -46,7 +47,7 @@ var Punycode = {
var idn = args[0];
if (idn) {
return punycode.ToUnicode(input);
return punycode.toUnicode(input);
} else {
return punycode.decode(input);
}

View file

@ -30,7 +30,7 @@
*
* @namespace
*/
var QuotedPrintable = {
var QuotedPrintable = module.exports = {
/**
* To Quoted Printable operation.

View file

@ -9,7 +9,7 @@
*
* @todo Support for UTF16
*/
var Rotate = {
var Rotate = module.exports = {
/**
* @constant

View file

@ -1,3 +1,6 @@
var Utils = require("../core/Utils.js");
/**
* Sequence utility operations.
*
@ -7,7 +10,7 @@
*
* @namespace
*/
var SeqUtils = {
var SeqUtils = module.exports = {
/**
* @constant

View file

@ -1,4 +1,6 @@
/* globals JsDiff */
var Utils = require("../core/Utils.js"),
JsDiff = require("diff");
/**
* String utility operations.
@ -9,7 +11,7 @@
*
* @namespace
*/
var StrUtils = {
var StrUtils = module.exports = {
/**
* @constant

View file

@ -1,3 +1,6 @@
var Utils = require("../core/Utils.js");
/**
* Tidy operations.
*
@ -7,7 +10,7 @@
*
* @namespace
*/
var Tidy = {
var Tidy = module.exports = {
/**
* @constant

View file

@ -1,5 +1,8 @@
/* globals unescape */
var Utils = require("../core/Utils.js");
/**
* URL operations.
* Namespace is appended with an underscore to prevent overwriting the global URL object.
@ -10,7 +13,7 @@
*
* @namespace
*/
var URL_ = {
var URL_ = module.exports = {
/**
* @constant

View file

@ -7,7 +7,7 @@
*
* @namespace
*/
var UUID = {
var UUID = module.exports = {
/**
* Generate UUID operation.

View file

@ -1,3 +1,6 @@
var Utils = require("../core/Utils.js");
/**
* Unicode operations.
*
@ -7,7 +10,7 @@
*
* @namespace
*/
var Unicode = {
var Unicode = module.exports = {
/**
* @constant

View file

@ -0,0 +1,12 @@
var Chef = require("../../core/Chef.js");
/**
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2017
* @license Apache-2.0
*/
var chef = new Chef();
console.log(chef.bake("test", [{"op":"To Hex","args":["Space"]}], {}, 0, false));

11
webpack.config.js Normal file
View file

@ -0,0 +1,11 @@
/* eslint-env node */
var path = require("path");
module.exports = {
entry: "./src/js/views/html/index.js",
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "build/dev")
}
};