From a85e0219ae28915bb81e5cca1180188a6267f709 Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Sat, 17 Mar 2018 23:02:23 +0100 Subject: [PATCH 01/68] Exports for random module --- lib/random/mersennetwister.js | 2 ++ lib/random/random.js | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/random/mersennetwister.js b/lib/random/mersennetwister.js index 56dd7df..ddf8e20 100644 --- a/lib/random/mersennetwister.js +++ b/lib/random/mersennetwister.js @@ -84,3 +84,5 @@ function MersenneTwister () { // eslint-disable-line no-unused-vars return ((this.int32() >>> 5) * 67108864.0 + (this.int32() >>> 6)) / 9007199254740992.0 } } + +module.exports = { MersenneTwister } \ No newline at end of file diff --git a/lib/random/random.js b/lib/random/random.js index 3811eef..247a3c4 100644 --- a/lib/random/random.js +++ b/lib/random/random.js @@ -2,6 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +const MersenneTwister = require('./mersennetwister') + var random = { // eslint-disable-line no-unused-vars seed: null, twister: null, @@ -14,7 +16,7 @@ var random = { // eslint-disable-line no-unused-vars if (seed === null || seed === undefined) { this.seed = new Date().getTime() } - this.twister = new MersenneTwister() + this.twister = new MersenneTwister.MersenneTwister() this.twister.seed(this.seed) }, number: function (limit) { @@ -166,3 +168,8 @@ var random = { // eslint-disable-line no-unused-vars return this.number(Math.pow(2, len * 4)).toString(16) } } + +module.exports = { + random, + MersenneTwister +} From 142576ed49d5260960671b35d03cf88419bdf4f9 Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Mon, 19 Mar 2018 04:23:05 +0100 Subject: [PATCH 02/68] Add module based architecture * Build with Webpack * Let Octo.js run in Node --- .gitignore | 388 +--- build.py | 64 - deploy/octo.js | 3163 --------------------------------- lib/index.js | 11 + lib/logging/console.js | 99 +- lib/logging/index.js | 15 + lib/make/alignment.js | 30 +- lib/make/arrays.js | 9 +- lib/make/colors.js | 31 +- lib/make/command.js | 117 +- lib/make/crypto.js | 1719 +++++++++--------- lib/make/datetime.js | 29 +- lib/make/files.js | 35 +- lib/make/fonts.js | 73 +- lib/make/html.js | 23 +- lib/make/index.js | 91 + lib/make/init.js | 1 - lib/make/mime.js | 43 +- lib/make/network.js | 105 +- lib/make/numbers.js | 59 +- lib/make/shaders.js | 263 +-- lib/make/style.js | 13 +- lib/make/text.js | 113 +- lib/make/time.js | 16 +- lib/make/typed.js | 84 +- lib/make/types.js | 9 +- lib/make/units.js | 19 +- lib/make/uri.js | 21 +- lib/make/webgl.js | 265 +-- lib/random/index.js | 5 + lib/random/mersennetwister.js | 81 +- lib/random/random.js | 150 +- lib/utils/block.js | 8 +- lib/utils/common.js | 49 +- lib/utils/index.js | 27 + lib/utils/init.js | 1 - lib/utils/mutate.js | 26 +- lib/utils/objects.js | 181 +- lib/utils/platform.js | 197 +- lib/utils/script.js | 88 +- package.json | 16 +- webpack.config.js | 14 + 42 files changed, 2339 insertions(+), 5412 deletions(-) delete mode 100755 build.py delete mode 100644 deploy/octo.js create mode 100644 lib/index.js create mode 100644 lib/logging/index.js create mode 100644 lib/make/index.js delete mode 100644 lib/make/init.js create mode 100644 lib/random/index.js create mode 100644 lib/utils/index.js delete mode 100644 lib/utils/init.js create mode 100644 webpack.config.js diff --git a/.gitignore b/.gitignore index bcfb949..ec70e51 100644 --- a/.gitignore +++ b/.gitignore @@ -1,386 +1,4 @@ -### SublimeText template - -# cache files for sublime text -*.tmlanguage.cache -*.tmPreferences.cache -*.stTheme.cache - -# workspace files are user-specific -*.sublime-workspace - -# project files should be checked into the repository, unless a significant -# proportion of contributors will probably not be using SublimeText -# *.sublime-project - -# sftp configuration file -sftp-config.json - -# Package control specific files -Package Control.last-run -Package Control.ca-list -Package Control.ca-bundle -Package Control.system-ca-bundle -Package Control.cache/ -Package Control.ca-certs/ -Package Control.merged-ca-bundle -Package Control.user-ca-bundle -oscrypto-ca-bundle.crt -bh_unicode_properties.cache - -# Sublime-github package stores a github token in this file -# https://packagecontrol.io/packages/sublime-github -GitHub.sublime-settings - -### macOS template - -*.DS_Store -.AppleDouble -.LSOverride - -# Icon must end with two \r -Icon - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns -.com.apple.timemachine.donotpresent - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk - -### Linux template - -*~ - -# temporary files which can be created if a process still has a handle open of a deleted file -.fuse_hidden* - -# KDE directory preferences -.directory - -# Linux trash folder which might appear on any partition or disk -.Trash-* - -# .nfs files are created when an open file is removed but is still being accessed -.nfs* - -### Windows template - -# Windows thumbnail cache files -Thumbs.db -ehthumbs.db -ehthumbs_vista.db - -# Folder config file -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msm -*.msp - -# Windows shortcuts -*.lnk - -### CVS template - -/CVS/* -**/CVS/* -.cvsignore -*/.cvsignore - -### Emacs template - -# -*- mode: gitignore; -*- -*~ -\#*\# -/.emacs.desktop -/.emacs.desktop.lock -*.elc -auto-save-list -tramp -.\#* - -# Org-mode -.org-id-locations -*_archive - -# flymake-mode -*_flymake.* - -# eshell files -/eshell/history -/eshell/lastdir - -# elpa packages -/elpa/ - -# reftex files -*.rel - -# AUCTeX auto folder -/auto/ - -# cask packages -.cask/ -dist/ - -# Flycheck -flycheck_*.el - -# server auth directory -/server/ - -# projectiles files -.projectile - -# directory configuration -.dir-locals.el - -### NetBeans template - -nbproject/private/ -build/ -nbbuild/ -dist/ -nbdist/ -.nb-gradle/ - -### Eclipse template - -.metadata -bin/ -tmp/ -*.tmp -*.bak -*.swp -*~.nib -local.properties -.settings/ -.loadpath -.recommenders - -# Eclipse Core -.project - -# External tool builders -.externalToolBuilders/ - -# Locally stored "Eclipse launch configurations" -*.launch - -# PyDev specific (Python IDE for Eclipse) -*.pydevproject - -# CDT-specific (C/C++ Development Tooling) -.cproject - -# JDT-specific (Eclipse Java Development Tools) -.classpath - -# Java annotation processor (APT) -.factorypath - -# PDT-specific (PHP Development Tools) -.buildpath - -# sbteclipse plugin -.target - -# Tern plugin -.tern-project - -# TeXlipse plugin -.texlipse - -# STS (Spring Tool Suite) -.springBeans - -# Code Recommenders -.recommenders/ - -# Scala IDE specific (Scala & Java development for Eclipse) -.cache-main -.scala_dependencies -.worksheet - -### JetBrains template - -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff: -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/dictionaries - -# Sensitive or high-churn files: -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.xml -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml - -# Gradle: -.idea/**/gradle.xml -.idea/**/libraries - -# Mongo Explorer plugin: -.idea/**/mongoSettings.xml - -## File-based project format: -*.iws - -## Plugin-specific files: - -# IntelliJ -/out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - -### Xcode template - -# Xcode -# -# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore - -## Build generated -build/ -DerivedData/ - -## Various settings -*.pbxuser -!default.pbxuser -*.mode1v3 -!default.mode1v3 -*.mode2v3 -!default.mode2v3 -*.perspectivev3 -!default.perspectivev3 -xcuserdata/ - -## Other -*.moved-aside -*.xccheckout -*.xcscmblueprint - -### Vim template - -# swap -[._]*.s[a-v][a-z] -[._]*.sw[a-p] -[._]s[a-v][a-z] -[._]sw[a-p] -# session -Session.vim -# temporary -.netrwhist -*~ -# auto-generated tag files -tags - -### Mercurial template - -.hg/ -.hgignore -.hgsigs -.hgsub -.hgsubstate -.hgtags - -### Node template - -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage +.DS_Store +node_modules +package-lock.json tests/coverage - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (http://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# Typescript v1 declaration files -typings/ - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variables file -.env - -### Notepad++ template - -# Notepad++ backups # -*.bak - -# WebBrains project files -.idea/ diff --git a/build.py b/build.py deleted file mode 100755 index 3e00af9..0000000 --- a/build.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env python -# coding=utf-8 -from __future__ import print_function - -import argparse -import os - -# List of files which must be loaded first -PRELOAD = ( - 'random/random.js', - 'random/mersennetwister.js', - 'utils/init.js', - 'utils/platform.js', - 'logging/console.js', - 'make/init.js' -) - - -def argparser(): - parser = argparse.ArgumentParser() - parser.add_argument('-l', '--libs', required=True, - help='Directory containing the octo libraries.') - parser.add_argument('-d', '--deploy', required=True, - help='Directory where the combined octo library will be built.') - args = parser.parse_args() - - if not os.path.isdir(args.libs): - parser.error("Lib directory doesn't exist!") - if not os.path.isdir(args.deploy): - parser.error("Deploy directory doesn't exist!") - - return args - - -def main(): - args = argparser() - - data = [] - loaded = set() - - for filename in PRELOAD: - path = os.path.join(args.libs, filename) - if not os.path.isfile(path): - raise Exception("Unable to find file in preload: {0}".format(path)) - print("Adding path: {0}".format(path)) - with open(path, 'rb') as f: - data.append(f.read()) - loaded.add(path) - - for root, _, files in os.walk(args.libs): - for filename in files: - path = os.path.join(root, filename) - if path.endswith('.js') and path not in loaded: - print("Adding path: {0}".format(path)) - with open(path, 'rb') as f: - data.append(f.read()) - - octo_path = os.path.join(args.deploy, 'octo.js') - with open(octo_path, 'wb') as f: - f.write(b'\n\n'.join(data)) - - -if __name__ == "__main__": - main() diff --git a/deploy/octo.js b/deploy/octo.js deleted file mode 100644 index ab1893d..0000000 --- a/deploy/octo.js +++ /dev/null @@ -1,3163 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -var random = { // eslint-disable-line no-unused-vars - seed: null, - twister: null, - - /** - * Must be called before any other methods can be called to initialize MersenneTwister. - * @param {number|null|undefined} seed Value to initialize MersenneTwister. - */ - init: function (seed) { - if (seed === null || seed === undefined) { - this.seed = new Date().getTime() - } - this.twister = new MersenneTwister() - this.twister.seed(this.seed) - }, - number: function (limit) { - // Returns an integer in [0, limit). Uniform distribution. - if (limit === 0) { - return limit - } - if (limit === null || limit === undefined) { - limit = 0xffffffff - } - let x = (0x100000000 / limit) >>> 0 - let y = (x * limit) >>> 0 - let r - do { - r = this.twister.int32() - } while (y && r >= y) // eslint-disable-line no-unmodified-loop-condition - return (r / x) >>> 0 - }, - float: function () { - // Returns a float in [0, 1). Uniform distribution. - return this.twister.real2() - }, - range: function (start, limit) { - // Returns an integer in [start, limit]. Uniform distribution. - if (isNaN(start) || isNaN(limit)) { - logger.traceback() - throw new TypeError('random.range() received a non number type: \'' + start + '\', \'' + limit + '\')') - } - return this.number(limit - start + 1) + start - }, - ludOneTo: function (limit) { - // Returns a float in [1, limit]. The logarithm has uniform distribution. - return Math.exp(this.float() * Math.log(limit)) - }, - item: function (list) { - if (list === undefined || typeof list === 'string' || list.length === undefined) { - logger.traceback() - throw new TypeError('random.item() received an invalid object: \'' + list + '\'') - } - /* - if (typeof list === 'object') { - logger.info('You are passing an object to random.item!\n>>>' + list) - } - */ - // if (typeof list === 'object') { // Todo: remove random.key() - // return list[random.item(Object.keys(list))] - // } - - return list[this.number(list.length)] - }, - key: function (obj) { - let list = [] - for (let i in obj) { - list.push(i) - } - return this.item(list) - }, - bool: function () { - return this.item([true, false]) - }, - pick: function (obj) { - if (typeof obj === 'function') { - return obj() - } - if (Array.isArray(obj)) { - return this.pick(this.item(obj)) - } - return obj - }, - chance: function (limit) { - if (limit === null || limit === undefined) { - limit = 2 - } - if (isNaN(limit)) { - logger.traceback() - throw new TypeError('random.chance() received a non number type: \'' + limit + '\'') - } - return this.number(limit) === 1 - }, - choose: function (list, flat) { - if (!(Array.isArray(list))) { - logger.traceback() - throw new TypeError('random.choose() received a non-array type: \'' + list + '\'') - } - let total = 0 - for (let i = 0; i < list.length; i++) { - total += list[i][0] - } - let n = this.number(total) - for (let i = 0; i < list.length; i++) { - if (n < list[i][0]) { - if (flat === true) { - return list[i][1] - } else { - return this.pick([list[i][1]]) - } - } - n = n - list[i][0] - } - if (flat === true) { - return list[0][1] - } - return this.pick([list[0][1]]) - }, - weighted: function (wa) { - // More memory-hungry but hopefully faster than random.choose$flat - let a = [] - for (let i = 0; i < wa.length; ++i) { - for (let j = 0; j < wa[i].w; ++j) { - a.push(wa[i].v) - } - } - return a - }, - use: function (obj) { - return this.bool() ? obj : '' - }, - shuffle: function (arr) { - let i = arr.length - while (i--) { - let p = this.number(i + 1) - let t = arr[i] - arr[i] = arr[p] - arr[p] = t - } - }, - shuffled: function (arr) { - let newArray = arr.slice() - this.shuffle(newArray) - return newArray - }, - subset: function (list, limit) { - if (!(Array.isArray(list))) { - logger.traceback() - throw new TypeError('random.subset() received a non-array type: \'' + list + '\'') - } - if (typeof limit !== 'number') { - limit = this.number(list.length + 1) - } - let result = [] - for (let i = 0; i < limit; i++) { - result.push(this.pick(list)) - } - return result - }, - pop: function (arr) { - // Removes and returns a random item from an array - let i, obj - - i = this.number(arr.length) - obj = arr[i] - arr.splice(i, 1) - - return obj - }, - hex: function (len) { - return this.number(Math.pow(2, len * 4)).toString(16) - } -} - - -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * JavaScript version of Mersenne Twister - * - * @author Yasuharu Okada - * - */ - -function MersenneTwister () { // eslint-disable-line no-unused-vars - const N = 624 - const M = 397 - const UPPER_MASK = 0x80000000 - const LOWER_MASK = 0x7fffffff - const MAG01 = new Int32Array([0, 0x9908b0df]) - - let mt = new Int32Array(N) - /* the array for the state vector */ - let mti = 625 - - this.seed = function (s) { - mt[0] = s | 0 - for (mti = 1; mti < N; mti++) { - mt[mti] = Math.imul(1812433253, mt[mti - 1] ^ (mt[mti - 1] >>> 30)) + mti - } - } - - this.export_state = function () { - return [mt, mti] - } - - this.import_state = function (s) { - mt = s[0] - mti = s[1] - } - - this.export_mta = function () { - return mt - } - - this.import_mta = function (_mta) { - mt = _mta - } - - this.export_mti = function () { - return mti - } - - this.import_mti = function (_mti) { - mti = _mti - } - - this.int32 = function () { - let y, kk - - if (mti >= N) { /* generate N words at one time */ - for (kk = 0; kk < N - M; kk++) { - y = ((mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK)) - mt[kk] = (mt[kk + M] ^ (y >>> 1) ^ MAG01[y & 0x1]) - } - for (; kk < N - 1; kk++) { - y = ((mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK)) - mt[kk] = (mt[kk + (M - N)] ^ (y >>> 1) ^ MAG01[y & 0x1]) - } - y = ((mt[N - 1] & UPPER_MASK) | (mt[0] & LOWER_MASK)) - mt[N - 1] = (mt[M - 1] ^ (y >>> 1) ^ MAG01[y & 0x1]) - mti = 0 - } - - y = mt[mti++] - - /* Tempering */ - y = y ^ (y >>> 11) - y = y ^ ((y << 7) & 0x9d2c5680) - y = y ^ ((y << 15) & 0xefc60000) - y = y ^ (y >>> 18) - - return y >>> 0 - } - - this.real2 = function () { - return ((this.int32() >>> 5) * 67108864.0 + (this.int32() >>> 6)) / 9007199254740992.0 - } -} - - -var utils = {} // eslint-disable-line no-unused-vars -module.exports = utils - - -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -utils.platform = (function () { - let platform = {} - - const userAgent = (navigator.userAgent).toLowerCase() - const language = navigator.language || navigator.browserLanguage - - const version = platform.version = (userAgent.match(/.*(?:rv|chrome|webkit|opera|ie)[/: ](.+?)([ );]|$)/) || [])[1] - const webkitVersion = (userAgent.match(/webkit\/(.+?) /) || [])[1] - - platform.windows = platform.isWindows = !!/windows/.test(userAgent) - platform.mac = platform.isMac = !!/macintosh/.test(userAgent) || (/mac os x/.test(userAgent) && !/like mac os x/.test(userAgent)) - platform.lion = platform.isLion = !!(/mac os x 10_7/.test(userAgent) && !/like mac os x 10_7/.test(userAgent)) - platform.iPhone = platform.isiPhone = !!/iphone/.test(userAgent) - platform.iPod = platform.isiPod = !!/ipod/.test(userAgent) - platform.iPad = platform.isiPad = !!/ipad/.test(userAgent) - platform.iOS = platform.isiOS = platform.iPhone || platform.iPod || platform.iPad - platform.android = platform.isAndroid = !!/android/.test(userAgent) - platform.opera = /opera/.test(userAgent) ? version : 0 - platform.isOpera = !!platform.opera - platform.msie = /msie/.test(userAgent) && !platform.opera ? version : 0 - platform.isIE = !!platform.msie - platform.isIE8OrLower = !!(platform.msie && parseInt(platform.msie, 10) <= 8) - platform.mozilla = /mozilla/.test(userAgent) && !/(compatible|webkit|msie)/.test(userAgent) ? version : 0 - platform.isMozilla = !!platform.mozilla - platform.webkit = /webkit/.test(userAgent) ? webkitVersion : 0 - platform.isWebkit = !!platform.webkit - platform.chrome = /chrome/.test(userAgent) ? version : 0 - platform.isChrome = !!platform.chrome - platform.mobileSafari = /apple.*mobile/.test(userAgent) && platform.iOS ? webkitVersion : 0 - platform.isMobileSafari = !!platform.mobileSafari - platform.iPadSafari = platform.iPad && platform.isMobileSafari ? webkitVersion : 0 - platform.isiPadSafari = !!platform.iPadSafari - platform.iPhoneSafari = platform.iPhone && platform.isMobileSafari ? webkitVersion : 0 - platform.isiPhoneSafari = !!platform.iphoneSafari - platform.iPodSafari = platform.iPod && platform.isMobileSafari ? webkitVersion : 0 - platform.isiPodSafari = !!platform.iPodSafari - platform.isiOSHomeScreen = platform.isMobileSafari && !/apple.*mobile.*safari/.test(userAgent) - platform.safari = platform.webkit && !platform.chrome && !platform.iOS && !platform.android ? webkitVersion : 0 - platform.isSafari = !!platform.safari - platform.language = language.split('-', 1)[0] - platform.current = - platform.msie ? 'msie' : platform.mozilla ? 'mozilla' : platform.chrome ? 'chrome' : platform.safari ? 'safari' : platform.opera ? 'opera' : platform.mobileSafari ? 'mobile-safari' : platform.android ? 'android' : 'unknown' - - function platformName (candidates) { - for (let i = 0; i < candidates.length; i++) { - if (candidates[i] in window) { - return 'window.' + candidates[i] - } - if (candidates[i] in navigator) { - return 'navigator.' + candidates[i] - } - } - return undefined - } - - platform.GUM = platformName(['getUserMedia', 'webkitGetUserMedia', 'mozGetUserMedia', 'msGetUserMedia', 'getGUM']) - platform.PeerConnection = platformName(['webkitRTCPeerConnection', 'mozRTCPeerConnection', 'msPeerConnection']) - platform.IceCandidate = platformName(['mozRTCIceCandidate', 'RTCIceCandidate']) - platform.SessionDescription = platformName(['mozRTCSessionDescription', 'RTCSessionDescription']) - platform.URL = platformName(['URL', 'webkitURL']) - platform.AudioContext = platformName(['AudioContext', 'webkitAudioContext']) - platform.OfflineAudioContext = platformName(['OfflineAudioContext', 'webkitOfflineAudioContext']) - platform.MediaSource = platformName(['MediaSource', 'WebKitMediaSource']) - - platform.SpeechRecognition = platformName(['SpeechRecognition', 'webkitSpeechRecognition']) - platform.SpeechGrammarList = platformName(['SpeechGrammarList', 'webkitSpeechGrammarList']) - platform.SpeechGrammar = platformName(['SpeechGrammar']) - - /* - function findWebGLContextName (candidates) { - var canvas = document.createElement('canvas') - for (var i = 0; i < candidates.length; i++) { - var name = candidates[i] - try { - if (canvas.getContext(name)) { - return name - } - } catch (e) {} - } - return null - } - */ - - platform.WebGL = 'webgl' // findWebGLContextName(["webgl", "experimental-webgl", "webkit-3d"]); - platform.WebGL2 = 'webgl2' // findWebGLContextName(["webgl2", "experimental-webgl2"]); - - platform.captureStreamUntilEnded = 'captureStreamUntilEnded' - if (platform.isMozilla) { - platform.captureStreamUntilEnded = 'mozCaptureStreamUntilEnded' - } - - platform.srcObject = 'srcObject' - if (platform.isMozilla) { - platform.srcObject = 'mozSrcObject' - } - - return platform -})() - - -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -var websocket = null - -var logger = (function () { // eslint-disable-line no-unused-vars - const sep = '\n/* ### NEXT TESTCASE ############################## */' - const color = { - red: '\u{1b}[1;31m', - green: '\u{1b}[1;32m', - clear: '\u{1b}[0m' - } - if (utils.platform.isWindows) { - color.red = '' - color.green = '' - color.clear = '' - } - - function console (msg) { - if (websocket) { - websocket.send(msg) - } - if (typeof window === 'undefined') { - print(msg) // eslint-disable-line no-undef - } else if (window.dump) { - window.dump(msg) - } else if (window.console && window.console.log) { - window.console.log(msg) - } else { - throw new Error('Unable to run console logger.') - } - } - - function dump (msg) { - console(msg) - } - - function dumpln (msg) { - dump(msg + '\n') - } - - function log (msg) { - dumpln('/*L*/ ' + utils.script.safely(msg)) - } - - function info (msg) { - dumpln('/*L*/ /* ' + msg + ' */') - } - - function error (msg) { - dumpln(color.red + msg + color.clear) - } - - function ok (msg) { // eslint-disable-line no-unused-vars - dumpln(color.green + msg + color.green) - } - - function JSError (msg) { - error('/* ERROR: ' + msg + ' */') - } - - function comment (msg) { - dumpln('/*L*/ // ' + msg) - } - - function separator () { - dumpln(color.green + sep + color.clear) - } - - function traceback () { - error('===[ Traceback ]') - try { - throw new Error() - } catch (e) { - dump(e.stack || e.stacktrace || '') - } - error('================') - } - - return { - console: console, - dump: dump, - log: log, - info: info, - error: error, - JSError: JSError, - dumpln: dumpln, - comment: comment, - separator: separator, - traceback: traceback - } -})() - - -var make = {} // eslint-disable-line no-unused-vars - - -/* eslint no-extend-native: ["error", { "exceptions": ["String", "Array"] }] */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -Object.defineProperty(String.prototype, 'fromCodePoint', function () { - let chars = [] - let point, offset, units, i - for (i = 0; i < arguments.length; ++i) { - point = arguments[i] - offset = point - 0x10000 - units = point > 0xFFFF - ? [ - 0xD800 + (offset >> 10), - 0xDC00 + (offset & 0x3FF)] - : [point] - chars.push(String.fromCharCode.apply(null, units)) - } - return chars.join('') -}) - -Object.defineProperty(String.prototype, 'endsWith', function (str) { - return this.match(str + '$') === str -}) - -Object.defineProperty(String.prototype, 'startsWith', function (str) { - return this.match('^' + str) === str -}) - -Object.defineProperty(String.prototype, 'trim', function () { - return this.replace(/^[\s\xA0]+/, '').replace(/[\s\xA0]+$/, '') -}) - -Object.defineProperty(String.prototype, 'insert', function (data, idx) { - return this.slice(0, idx) + data + this.slice(idx, this.length) -}) - -Object.defineProperty(Array.prototype, 'has', function (v) { - return this.indexOf(v) !== -1 -}) - -Object.defineProperty(Array.prototype, 'forEach', function (array, fn) { - for (let i = 0; i < array.length; i++) { - fn(array[i]) - } -}) - -Object.defineProperty(Array.prototype, 'map', function (fn, array) { - let result = [] - Array.forEach(array, function (element) { - result.push(fn(element)) - }) - return result -}) - -Object.defineProperty(Array.prototype, 'extend', { - value: function (obj) { - if (Array.isArray(obj)) { - obj.forEach(function (v) { - if (typeof v !== 'undefined') { - this.push(v) - } - }, this) - } else { - this.push(obj) - } - } -}) - -Object.defineProperty(Object, 'isObject', { - value: function (obj) { - return (obj !== null && typeof obj === 'object' && - Object.prototype.toString.call(obj) === '[object Object]') - } -}) - - -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -utils.script = { - methodHead: function (list, numOptional) { - if (isNaN(numOptional)) { - numOptional = 0 - } - let arity = list.length - random.number(numOptional) - let params = [] - for (let i = 0; i < arity; i++) { - params.push(random.pick([list[i]])) - } - return '(' + params.join(', ') + ')' - }, - methodCall: function (objectName, methodHash) { - if (!utils.common.getKeysFromHash(methodHash).length || !objectName) { - return '' - } - let methodName = random.key(methodHash) - let methodArgs = methodHash[methodName] - if (typeof (methodArgs) === 'function') { // Todo: Hmmmm.. - return methodArgs() - } - return objectName + '.' + methodName + utils.script.methodHead(methodArgs) - }, - setAttribute: function (objectName, attributeHash) { - if (!utils.common.getKeysFromHash(attributeHash).length || !objectName) { - return '' - } - let attributeName = random.key(attributeHash) - let attributeValue = random.pick(attributeHash[attributeName]) - let operator = ' = ' - /* - if (typeof(attributeValue) == "number" && Random.chance(8)) { - operator = " " + Make.randomAssignmentOperator() + " "; - } - if (typeof(attributeValue) == "string") { - attributeValue = "'" + attributeValue + "'"; - } - */ - return objectName + '.' + attributeName + operator + attributeValue + ';' - }, - makeConstraint: function (keys, values) { - let o = {} - let n = random.range(0, keys.length) - while (n--) { - o[random.pick(keys)] = random.pick(values) - } - return o - }, - makeRandomOptions: function (baseObject) { - let o = {} - let unique = random.subset(Object.keys(baseObject)) - for (let i = 0; i < unique.length; i++) { - o[unique[i]] = random.pick(baseObject[unique[i]]) - } - return JSON.stringify(o) - }, - safely: function (s) { - return 'try { ' + s + ' } catch(e) { }' - }, - makeLoop: function (s, max) { - return 'for (let i = 0; i < ' + (max || make.number.range()) + '; i++) {' + s + '}' - }, - makeArray: function (type, arrayLength, cb) { - if (type === null || type === undefined) { - type = random.item(['Uint8', 'Float32']) - } - switch (random.number(8)) { - case 0: - let src = 'function() { let buffer = new ' + type + 'Array(' + arrayLength + ');' - src += utils.script.makeLoop('buffer[i] = ' + cb() + ';', arrayLength) - src += 'return buffer;}()' - return src - case 1: - return 'new ' + type + 'Array([' + make.arrays.filledArray(cb, arrayLength) + '])' - default: - return 'new ' + type + 'Array(' + arrayLength + ')' - } - }, - randListIndex: function (objName) { - return random.number() + ' % ' + o.pick(objName) + '.length' - }, - addElementToBody: function (name) { - return '(document.body || document.documentElement).appendChild' + utils.script.methodHead([name]) - }, - forceGC: function () { - if (utils.platform.isMozilla) { - } - if (utils.platform.isChrome) { - if (window.GCController) { - return GCController.collect() // eslint-disable-line no-undef - } - } - if (utils.platform.isSafari) { - } - if (utils.platform.isIE) { - } - }, - getRandomElement: function () { - return 'document.getElementsByTagName(\'*\')[' + random.number(document.getElementsByTagName('*').length) + ']' - } -} - - -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -var o = null // eslint-disable-line no-unused-vars - -function Objects () { - this.counter = 0 - this.container = {} -} - -Objects.prototype.add = function (category, member) { - if (!member) { - member = 'o' + this.counter - } - if (!this.has(category)) { - this.container[category] = [] - } - this.container[category].push({type: category, name: member}) - ++this.counter - return this.container[category].slice(-1)[0].name -} - -Objects.prototype.get = function (category, last) { - if (!(category in this.container)) { - // return {type:null, name:null}; - logger.traceback() - throw new Error(category + ' is not available.') - } - if (last) { - return this.container[category].slice(-1)[0] - } - return random.pick(this.container[category]) -} - -Objects.prototype.pick = function (category, last) { - try { - return this.get(category, last).name - } catch (e) { - logger.traceback() - throw logger.JSError('Error: pick(\'' + category + '\') is undefined.') - } -} - -Objects.prototype.pop = function (objectName) { - let self = this - utils.common.getKeysFromHash(this.container).forEach(function (category) { - self.container[category].forEach(function (obj) { - if (obj.name === objectName) { - self.container[category].splice(self.container[category].indexOf(obj), 1) - } - }) - }) -} - -Objects.prototype.contains = function (categoryNames) { - let categories = [] - let self = this - categoryNames.forEach(function (name) { - if (self.has(name)) { - categories.push(name) - } - }) - return (categories.length === 0) ? null : categories -} - -Objects.prototype.show = function (category) { - return (category in this.container) ? this.container[category] : this.container -} - -Objects.prototype.count = function (category) { - return (category in this.container) ? this.container[category].length : 0 -} - -Objects.prototype.has = function (category) { - if (category in this.container) { - this.check(category) - return this.container[category].length > 0 - } - return false -} - -Objects.prototype.valid = function () { - let items = [] - let self = this - utils.common.getKeysFromHash(self.container).forEach(function (category) { - self.check(category) - }) - utils.common.getKeysFromHash(self.container).forEach(function (category) { - for (let i = 0; i < self.container[category].length; i++) { - items.push(self.container[category][i].name) - } - }) - return items -} - -Objects.prototype.check = function (category) { - let self = this - self.container[category].forEach(function (object) { - try { - let x = /* frame.contentWindow. */ eval(object.name) // eslint-disable-line no-eval - if (x === undefined || x === null) { - self.pop(object.name) - } - } catch (e) { - self.pop(object.name) - } - }) -} - - -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -utils.block = { - block: function (list, optional) { - if (optional === true) { - if (random.chance(6)) { - return '' - } - } - - function deeper (item) { - if (item === null || item === undefined) { - return '' - } - if (typeof (item) === 'function') { - return item() - } - if (typeof (item) === 'string') { - return item - } - if (Array.isArray(item)) { - let s = '' - for (let i = 0; i < item.length; i++) { - s += deeper(item[i]) - } - return s - } - return item - } - - let asString = '' - for (let i = 0; i < list.length; i++) { - asString += deeper(list[i]) - } - - return asString - } -} - - -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -utils.common = { - objToString: function (obj) { - try { - return '' + obj - } catch (e) { - return '[' + e + ']' - } - }, - getAllProperties: function (obj) { - let list = [] - while (obj) { - list = list.concat(Object.getOwnPropertyNames(obj)) - obj = Object.getPrototypeOf(obj) - } - return list - }, - getKeysFromHash: function (obj) { - let list = [] - for (let p in obj) { - list.push(p) - } - return list - }, - quote: function (s) { - // Taken from DOMfuzz - function escapeString (s) { - return ('\"' + // eslint-disable-line no-useless-escape - s.replace(/\\/g, '\\\\') - .replace(/\"/g, '\\\"') // eslint-disable-line no-useless-escape - .replace(/\0/g, '\\0') - .replace(/\n/g, '\\n') + - '\"') // eslint-disable-line no-useless-escape - } - - if (typeof s === 'string') { - if (/^[\n\x20-\x7f]*$/.exec(s) || !self.uneval) { // eslint-disable-line no-undef - // Printable ASCII characters and line breaks: try to make it pretty. - return escapeString(s) - } else { - // Non-ASCII: use uneval to get \u escapes. - return uneval(s) // eslint-disable-line no-undef - } - } else { - // For other things (such as numbers, |null|, and |undefined|), just coerce to string. - return JSON.stringify(s) - } - }, - b64encode: function (str) { - // Unicode safe b64 encoding - // https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#The_Unicode_Problem - return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, - function toSolidBytes (match, p1) { - // noinspection JSCheckFunctionSignatures - return String.fromCharCode('0x' + p1) - })) - }, - b64decode: function (str) { - // Unicode safe b64 decoding - // https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#The_Unicode_Problem - return decodeURIComponent(atob(str).split('').map(function (c) { - return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2) - }).join('')) - }, - uniqueList: function (list) { - let tmp = {} - let r = [] - for (let i = 0; i < list.length; i++) { - tmp[list[i]] = list[i] - } - for (let i in tmp) { - r.push(tmp[i]) - } - return r - }, - mergeHash: function (obj1, obj2) { - for (let p in obj2) { - try { - if (obj2[p].constructor === Object) { - obj1[p] = utils.common.mergeHash(obj1[p], obj2[p]) - } else { - obj1[p] = obj2[p] - } - } catch (e) { - obj1[p] = obj2[p] - } - } - return obj1 - }, - mockup: (obj) => obj.split('\n').map((ln) => ln.trim()).join('') -} - - -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -utils.mutate = { - text: function (str) { - let mutator = function (m) { - return random.chance(4) ? m : make.text.any() - } - return str.replace(/[a-zA-Z]+?/g, mutator) - }, - - numbers: function (str) { - let mutator = function (m) { - return random.chance(4) ? m : make.number.any() - } - return str.replace(/-?\d+(\.\d+)?/g, mutator) - }, - - units: function (str) { - let mutator = function (m, p1) { - if (random.chance(4)) { - return m - } else { - return p1 + make.unit.unit() - } - } - return str.replace(/(\d+)(px|em|ex|ch|rem|mm|cm|in|pt|pc|%')/g, mutator) - }, - - random: function (str) { - let mutator = function (m) { - if (random.chance(20)) { - if (str.match(/[0-9]/g)) { - return make.number.any() - } else { - return make.text.any() - } - } else { - return m - } - } - return str.replace(/./g, mutator) - }, - - any: function (str) { - switch (random.number(4)) { - case 0: - return utils.mutate.text(str) - case 1: - return utils.mutate.numbers(str) - case 2: - return utils.mutate.units(str) - case 3: - return utils.mutate.random(str) - } - } -} - - -make.html = { - tag: function () { - return random.item(['a', 'abbr', 'acronym', 'address', 'applet', 'area', 'article', 'aside', 'audio', 'b', 'base', 'basefont', 'bdi', 'bdo', 'bgsound', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'command', 'content', 'data', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'font', 'foo', 'footer', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'iframe', 'image', 'img', 'input', 'ins', 'isindex', 'kbd', 'keygen', 'label', 'legend', 'li', 'link', 'listing', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meta', 'meter', 'multicol', 'nav', 'nobr', 'noembed', 'noframes', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'picture', 'plaintext', 'pre', 'progress', 'q', 'rb', 'rp', 'rt', 'rtc', 'ruby', 's', 'samp', 'script', 'section', 'select', 'shadow', 'slot', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr', 'xmp']) - }, - attribute: function () { // eslint-disable-line no-unused-vars - return random.item(['accept', 'accept-charset', 'accesskey', 'action', 'align', 'alt', 'async', 'autocomplete', 'autofocus', 'autoplay', 'autosave', 'bgcolor', 'border', 'buffered', 'challenge', 'charset', 'checked', 'cite', 'class', 'code', 'codebase', 'color', 'cols', 'colspan', 'content', 'contenteditable', 'contextmenu', 'controls', 'coords', 'crossorigin', 'data', 'data-*', 'datetime', 'default', 'defer', 'dir', 'dirname', 'disabled', 'download', 'draggable', 'dropzone', 'enctype', 'for', 'form', 'formaction', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'http-equiv', 'icon', 'id', 'integrity', 'ismap', 'itemprop', 'keytype', 'kind', 'label', 'lang', 'language', 'list', 'loop', 'low', 'manifest', 'max', 'maxlength', 'minlength', 'media', 'method', 'min', 'multiple', 'muted', 'name', 'novalidate', 'open', 'optimum', 'pattern', 'ping', 'placeholder', 'poster', 'preload', 'radiogroup', 'readonly', 'rel', 'required', 'reversed', 'rows', 'rowspan', 'sandbox', 'scope', 'scoped', 'seamless', 'selected', 'shape', 'size', 'sizes', 'slot', 'span', 'spellcheck', 'src', 'srcdoc', 'srclang', 'srcset', 'start', 'step', 'style', 'summary', 'tabindex', 'target', 'title', 'type', 'usemap', 'value', 'width']) - }, - interfaceName: function () { // eslint-disable-line no-unused-vars - return random.pick(['HTMLBRElement', 'HTMLTableSectionElement', 'HTMLDataListElement', 'HTMLTableElement', 'HTMLOListElement', 'HTMLFontElement', 'HTMLMapElement', 'HTMLButtonElement', 'HTMLFrameSetElement', 'HTMLDataElement', 'HTMLOptGroupElement', 'HTMLAnchorElement', 'HTMLLinkElement', 'HTMLObjectElement', 'HTMLHeadElement', 'HTMLProgressElement', 'HTMLFrameElement', 'HTMLTimeElement', 'HTMLTableCaptionElement', 'HTMLDivElement', 'HTMLDListElement', 'HTMLBodyElement', 'HTMLImageElement', 'HTMLTableRowElement', 'HTMLScriptElement', 'HTMLInputElement', 'HTMLMeterElement', 'HTMLFieldSetElement', 'HTMLHtmlElement', 'HTMLStyleElement', 'HTMLDetailsElement', 'HTMLTrackElement', 'HTMLBaseElement', 'HTMLTableColElement', 'HTMLSourceElement', 'HTMLPictureElement', 'HTMLSelectElement', 'HTMLLegendElement', 'HTMLHRElement', 'HTMLModElement', 'HTMLTemplateElement', 'HTMLAreaElement', 'HTMLFormElement', 'HTMLEmbedElement', 'HTMLSpanElement', 'HTMLParagraphElement', 'HTMLIFrameElement', 'HTMLTableCellElement', 'HTMLElement', 'HTMLMenuElement', 'HTMLTextAreaElement', 'HTMLHeadingElement', 'HTMLCanvasElement', 'HTMLOutputElement', 'HTMLQuoteElement', 'HTMLOptionElement', 'HTMLLIElement', 'HTMLAudioElement', 'HTMLMenuItemElement', 'HTMLParamElement', 'HTMLUListElement', 'HTMLLabelElement', 'HTMLDirectoryElement', 'HTMLTitleElement', 'HTMLPreElement', 'HTMLMetaElement', 'HTMLVideoElement']) - } -} - - -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -make.types = { - random: function () { - return random.item([ - 'true', - 'null', - '(new Object())', - 'undefined', - '{}', - '[]', - '\'\'', - 'function() {}' - ]) - } -} - - -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -make.number = { - bool: function () { - return random.bool() - }, - float: function () { - let n - if (random.chance(32)) { - switch (random.number(4)) { - case 0: - n = random.range(Number.MIN_VALUE, Number.MAX_VALUE) - break - case 1: - n = Math.pow(10, 1) / Math.pow(10, random.number(307)) - break - case 2: - n = Math.pow(2, random.float() * random.float() * 64) - break - case 3: - n = Math.pow(10, random.range(1, 9)) / Math.pow(10, random.range(1, 9)) - break - } - return n - } - switch (random.number(6)) { - default: - n = random.float() - } - return n - }, - range: function () { - return random.pick([1, 2, 3, 4, 6, 8, 16, 32, 64, make.number.tiny]) - }, - frange: function (min, max, precision) { - let x = Math.random() * (min - max) + max - if (precision) { - let power = Math.pow(10, precision || 0) - x = Math.round(x * power) / power - } - return x - }, - tiny: function () { - return Math.pow(2, random.number(12)) - }, - unsigned: function () { - if (random.chance(2)) { - return Math.abs(make.number.any()) - } - return Math.pow(2, random.number(random.number(65))) + random.number(3) - 1 - }, - even: function (number) { - return number % 2 === 1 ? ++number : number - }, - any: function () { - let value = random.choose([ - [10, make.number.float], - [10, [make.number.range, make.number.tiny]], - [1, make.number.unsigned] - ]) - return random.chance(10) ? -value : value - } -} - - -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -make.typed = { - byte: function (limit = null) { - // [-128, 127] - let value = (limit !== null) ? random.number(limit) : random.number(129) - value = random.chance(10) ? -value : value - return 'new Uint8Array([' + value + '])[0]' - }, - octet: function (limit = null) { - // [0, 255] - let value = (limit !== null) ? random.number(limit) : random.number(256) - return 'new Int8Array([' + value + '])[0]' - }, - short: function (limit = null) { - // [-32768, 32767] - let value = (limit !== null) ? random.number(limit) : random.number(32769) - value = random.chance(10) ? -value : value - return 'new Int16Array([' + value + '])[0]' - }, - unsignedShort: function (limit = null) { - // [0, 65535] - let value = (limit !== null) ? random.number(limit) : random.number(65535) - return 'new Uint16Array([' + value + '])[0]' - }, - long: function (limit = null) { - // [-2147483648, 2147483647] - let value = (limit !== null) ? random.number(limit) : random.number(2147483649) - value = random.chance(10) ? -value : value - return 'new Int32Array([' + value + '])[0]' - }, - unsignedLong: function (limit = null) { - // [0, 4294967295] - let value = (limit !== null) ? random.number(limit) : random.number(4294967296) - return 'new Uint32Array([' + value + '])[0]' - }, - // ToDo: Add support for longlong and ulonglong - /* - longLong: function () {}, - unsignedLongLong: function () {}, - */ - float: function (limit = null) { - let base = (limit !== null) ? random.number(limit) : random.number() - let value = random.chance(10) ? -(base + random.float()) : (base + random.float()) - return 'new Float32Array([' + value + '])[0]' - }, - unrestrictedFloat: function (limit = null) { - if (random.chance(100)) { - return random.pick([NaN, +Infinity, -Infinity]) - } else { - let base = (limit !== null) ? random.number(limit) : random.number() - return 'new Float32Array([' + (base + random.float()) + '])[0]' - } - }, - double: function (limit = null) { - let base = (limit !== null) ? random.number(limit) : random.number() - let value = random.chance(10) ? -(base + random.float()) : (base + random.float()) - return 'new Float64Array([' + value + '])[0]' - }, - unrestrictedDouble: function (limit = null) { - if (random.chance(100)) { - return random.pick([NaN, +Infinity, -Infinity]) - } else { - let base = (limit !== null) ? random.number(limit) : random.number() - let value = random.chance(10) ? -(base + random.float()) : (base + random.float()) - return 'new Float64Array([' + value + '])[0]' - } - }, - any: function () { - return random.choose([ - [1, [this.byte, this.octet]], - [1, [this.short, this.unsignedShort]], - [1, [this.long, this.unsignedLong]], - [1, [this.float, this.unrestrictedFloat]], - [1, [this.double, this.unrestrictedDouble]], - [1, [make.number.range, make.number.tiny]] - ]) - }, - arrayBuffer: function (byteLength = null) { - let length = (byteLength !== null) ? byteLength : this.unsignedShort() - return 'new ArrayBuffer(' + length + ')' - }, - dataView: function (byteLength = null) { - let length = (byteLength !== null) ? byteLength : this.unsignedShort() - return 'new DataView(' + this.arrayBuffer(length) + ')' - }, - typedArray: function (byteLength = null) { - let length = (byteLength !== null) ? byteLength : this.unsignedShort() - let arrType = random.item([ - 'Int8', 'Uint8', 'Uint8Clamped', - 'Int16', 'Uint16', - 'Int32', 'Uint32', - 'Float32', 'Float64' - ]) - let method = 'new ' + arrType + 'Array' - switch (random.number(16)) { - case 0: - return method + '()' - case 1: - return method + '(' + this.typedArray() + ')' - default: - return method + '(' + length + ')' - } - }, - bufferSource: function () { - switch (random.number(4)) { - case 0: - return this.arrayBuffer() - case 1: - return this.dataView() - default: - return this.typedArray() - } - } -} - - -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -make.mime = { - any: function () { - return random.pick([ - make.mime.standard, - make.mime.xml, - make.mime.image, - make.mime.media, - make.mime.form - ]) - }, - - standard: function () { - return random.pick([ - 'text/html', - 'text/html; charset=utf-8', - 'text/plain', - 'text/css', - 'text/javascript', - 'foo/bar', - 'application/octet-stream', - 'application/x-shockwave-flash', - 'application/x-test' - ]) - }, - - xml: function () { - return random.pick([ - 'application/xml', - 'text/xml', - 'application/xhtml+xml', - 'image/svg+xml', - 'application/vnd.mozilla.xul+xml', - 'application/rss+xml', - 'application/rdf+xml', - 'application/xslt+xml' - ]) - }, - - image: function () { - return random.pick([ - 'image/jpeg', - 'image/gif', - 'image/png', - 'image/mng', - 'image/*' - ]) - }, - - media: function () { - return random.pick([ - 'audio/mpeg', - 'audio/ogg', - 'audio/ogg; codecs=vorbis', - 'video/ogg', - 'video/ogg; codecs="theora, vorbis"', - 'video/mp4', - 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"' - ]) - }, - - form: function () { - return random.pick([ - 'application/x-www-form-urlencoded', - 'multipart/form-data', - 'text/plain' - ]) - } -} - - -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -make.files = { - image: function () { - return random.pick([ - 'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=', - 'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==', - 'data:image/gif;base64,R0lGODlhAQABAAAAACwAAAAAAQABAAA=', - 'data:image/gif;base64,R0lGODlhAQABAAAAACw=', - 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAACklEQVQYV2P4DwABAQEAWk1v8QAAAABJRU5ErkJggg==', - 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=' - ]) - }, - video: function () { - return random.pick([ - 'data:video/webm;base64,GkXfowEAAAAAAAAfQoaBAUL3gQFC8oEEQvOBCEKChHdlYm1Ch4EEQoWBAhhTgGcBAAAAAAAVkhFNm3RALE27i1OrhBVJqWZTrIHfTbuMU6uEFlSua1OsggEwTbuMU6uEHFO7a1OsghV17AEAAAAAAACkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmAQAAAAAAAEUq17GDD0JATYCNTGF2ZjU1LjMzLjEwMFdBjUxhdmY1NS4zMy4xMDBzpJBlrrXf3DCDVB8KcgbMpcr+RImIQJBgAAAAAAAWVK5rAQAAAAAAD++uAQAAAAAAADLXgQFzxYEBnIEAIrWcg3VuZIaFVl9WUDiDgQEj44OEAmJaAOABAAAAAAAABrCBsLqBkK4BAAAAAAAPq9eBAnPFgQKcgQAitZyDdW5khohBX1ZPUkJJU4OBAuEBAAAAAAAAEZ+BArWIQOdwAAAAAABiZIEgY6JPbwIeVgF2b3JiaXMAAAAAAoC7AAAAAAAAgLUBAAAAAAC4AQN2b3JiaXMtAAAAWGlwaC5Pcmcgb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UY845JxFSijHnnJNKMeacc85JKRlzzDnnpJTOOeecc1JK5pxzzjkppXPOOeeclFJK55xzTkopJYTOQSellNI555wTAABU4AAAEGCjyOYEI0GFhqwEAFIBAAyOY1ma5nmiaJqWJGma53meKJqmJkma5nmeJ4qqyfM8TxRF0TRVled5niiKommqKtcVRdM0TVVVXbIsiqZpmqrqujBN01RV13VdmKZpqqrrui5sW1VV1XVlGbatqqrqurIMXNd1ZdmWgSy7ruzasgAA8AQHAKACG1ZHOCkaCyw0ZCUAkAEAQBiDkEIIIWUQQgohhJRSCAkAABhwAAAIMKEMFBqyEgBIBQAAjLHWWmuttdZAZ6211lprrYDMWmuttdZaa6211lprrbXWUmuttdZaa6211lprrbXWWmuttdZaa6211lprrbXWWmuttdZaa6211lprrbXWWmuttdZaay2llFJKKaWUUkoppZRSSimllFJKBQD6VTgA+D/YsDrCSdFYYKEhKwGAcAAAwBilGHMMQimlVAgx5px0VFqLsUKIMeckpNRabMVzzkEoIZXWYiyecw5CKSnFVmNRKYRSUkottliLSqGjklJKrdVYjDGppNZai63GYoxJKbTUWosxFiNsTam12GqrsRhjayottBhjjMUIX2RsLabaag3GCCNbLC3VWmswxhjdW4ultpqLMT742lIsMdZcAAB3gwMARIKNM6wknRWOBhcashIACAkAIBBSijHGGHPOOeekUow55pxzDkIIoVSKMcaccw5CCCGUjDHmnHMQQgghhFJKxpxzEEIIIYSQUuqccxBCCCGEEEopnXMOQgghhBBCKaWDEEIIIYQQSiilpBRCCCGEEEIIqaSUQgghhFJCKCGVlFIIIYQQQiklpJRSCiGEUkIIoYSUUkophRBCCKWUklJKKaUSSgklhBJSKSmlFEoIIZRSSkoppVRKCaGEEkopJaWUUkohhBBKKQUAABw4AAAEGEEnGVUWYaMJFx6AQkNWAgBkAACQopRSKS1FgiKlGKQYS0YVc1BaiqhyDFLNqVLOIOYklogxhJSTVDLmFEIMQuocdUwpBi2VGELGGKTYckuhcw4AAABBAICAkAAAAwQFMwDA4ADhcxB0AgRHGwCAI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q6pqq6rqeqtmy6qi6brmrbruz6tmu7vu6pqmybqivrpurKuurKtu66tu1Lnqeqoqq6rmeqrqu6rm6rrmvbmmrKrqm6sm26ri27smzrrizrumaqrmy6qi2brizrruzatirLui+6rm6rsqz7qiz7vmzruu7auvCLrmvrqizrvirLvjHbtvDLui4ckyeqqqeqruuZquuqrmvbquvauqaarmy6ri2bqivbqizrtivLtq6ZqiybrivbpuvKsirLvu/Ksm6LruvrpizruirLwu7qujHMtq37ouvquirLuq/Ksq67uu77sm4Lu6aqum7Ksq+bsqz7tq4Ly6zbujG6ru+rsi38qiwLv677wjLrPmN0XV9XbVkYVtn2fd33lWPWdWFZbVv5XVtnvL5uDLtu/MqtC8uy2raxzLqtLK+vG8Mu7Hxb+JWaqtq26bq6bsqyr8u6LrR13VdG1/V91bZ9X5Vl37eFX2kbw7CMrqv7qizrwmvLyi/rurDswi8sq20rv6vryjDburDcvrAsv+4Ly6rbvu/qutK1dWW5fZ+xK7fxCwAAGHAAAAgwoQwUGrIiAIgTAEAQcg4pBqFiCkIIoaQQQioVY1Iy5qRkzkkppZQUSkmtYkxK5pyUzDEpoZSWSimphFJaKqXEFEppLaXWYkqpxVBKa6Wk1kpJraWUYkytxRgxJiVzTkrmnJSSUmslldYy5yhlDkrqIKSUSiqtpNRi5pykDjorHYTUSioxlZRiC6nEVkpqraQUYysx1dRajiGlGEtKsZWUWm0x1dZaqzViTErmnJTMOSolpdZKKq1lzknqILTUOSippNRiKinFyjlJHYSUMsiolJRaK6nEElKJrbQUYympxdRirinFFkNJLZaUWiypxNZijLW1VFMnpcWSUowllRhbrLm21moMpcRWSouxpJRbazHXFmOOoaQWSyuxlZRabLXl2FrLNbVUY0qt1hZjjTHllGutPafWYk0x1dparLnVllvMtedOSmullBZLSjG21mKNMeYcSmmtpBRbKSnG1lqtrcVcQymxldJaLKnE2GKstcVWY2qtxhZbraW1WmutvcZWWy6t1dxirD21lGusteZYU20FAAAMOAAABJhQBgoNWQkARAEAAMYwxhiERinH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dYDwWFg=' - ]) - }, - webvtt: function () { - return random.pick([ - // 'data:text/vtt,' + encodeURIComponent('WEBVTT\n\n00:00:00.000 --> 00:00:00.001\ntest');, - 'media/video/sample.vtt' - // Todo: load from filesystem randomly: 'media/videos/*.{vtt}' - ]) - }, - any: function () { - return random.pick([ - make.files.image, - make.files.video, - make.files.audio - ]) - } -} - - -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -make.arrays = { - filledArray: function (fn, limit) { - let array = [] - let size = limit || random.number(make.number.tiny()) + 1 - - for (let i = 0; i < size; i++) { - let value = random.pick(fn) - if (value !== undefined) { - array.push(value) - } - } - - return array - } -} - - -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -make.time = { - unit: function () { - return random.pick([ - 's', 'ms' - ]) - }, - any: function () { - return make.number.any() + make.time.unit() - } -} - - -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -make.alignment = { - horizontal: function () { - return random.item(['left', 'right', 'justify', 'center']) - }, - vertical: function () { - return random.item(['top', 'bottom', 'middle', 'baseline']) - }, - any: function () { - return random.pick([ - this.horizontal, - this.vertical - ]) - } -} - - -make.style = { - pseudoElement: function () { - return random.item([ - '::after', - '::before', - '::cue', - '::first-letter', - '::first-line', - '::selection', - '::backdrop', - '::placeholder', - '::marker', - '::spelling-error', - '::grammar-error']) - } -} - - -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -make.unit = { - unit: function () { - return random.pick([ - 'px', 'em', 'ex', 'ch', 'rem', 'mm', 'cm', 'in', 'pt', 'pc', '%' - ]) - }, - length: function () { - return make.number.any() + make.unit.unit() - }, - percent: function () { - return make.number.any() + '%' - } -} - - -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -make.command = { - _data: { - 'backcolor': function () { return make.colors.any() }, - 'bold': null, - 'contentReadOnly': function () { return random.bool() }, - 'copy': null, - 'createlink': function () { return make.uri.any() }, - 'cut': null, - 'decreasefontsize': null, - 'delete': null, - 'enableInlineTableEditing': function () { return random.bool() }, - 'enableObjectResizing': function () { return random.bool() }, - 'fontname': function () { return make.font.family() }, - 'fontsize': function () { return make.font.relativeSize() }, - 'formatblock': ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ol', 'ul', 'pre', 'address', 'blockquote', 'dl', 'div'], - 'forwarddelete': null, - 'forecolor': function () { return make.colors.any() }, - 'gethtml': null, - 'heading': null, - 'hilitecolor': function () { return make.colors.any() }, - 'increasefontsize': null, - 'indent': null, - 'insertBrOnReturn': function () { return random.bool() }, - 'inserthorizontalrule': null, - // 'inserthtml': function () { }, - 'insertlinebreak': null, - 'insertimage': function () { return make.uri.any() }, - 'insertorderedlist': null, - 'insertparagraph': null, - 'inserttext': function () { return make.text.any() }, - 'insertunorderedlist': null, - 'italic': null, - 'justifycenter': null, - 'justifyfull': null, - 'justifyleft': null, - 'justifyright': null, - 'outdent': null, - 'paste': null, - 'redo': null, - 'removeformat': null, - 'selectall': null, - 'strikethrough': null, - 'styleWithCSS': function () { return random.bool() }, - 'subscript': null, - 'superscript': null, - 'underline': null, - 'undo': null, - 'unlink': null - }, - name: function () { - return random.item(Object.keys(this._data)) - }, - value: function (name) { - return random.pick(this._data[name]) - } -} - - -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -make.font = { - globalValue: function () { - return random.pick(['inherit', 'initial', 'unset']) - }, - style: function () { - return random.pick(['italic', 'normal', 'oblique', 'inherit']) - }, - variant: function () { - return random.pick(['normal', 'small-caps', 'inherit']) - }, - weight: function () { - return random.pick([ - /* standard */ - ['normal', 'bold'], - /* Relative to the parent */ - ['bolder', 'lighter'], - /* numeric values */ - [100, 200, 300, 400, 500, 600, 700, 800, 900] - ]) - }, - size: function () { - return random.pick([ - /* values */ - ['xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'], - /* values */ - ['larger', 'smaller'], - /* values */ - make.number.unsigned() + make.unit.unit(), - /* values */ - make.unit.percent() - ]) - }, - relativeSize: function () { - let value = random.number(8) - return random.item(['', '+', '-']) + value - }, - genericFamily: function () { - return random.pick(['serif', 'sans-serif', 'cursive', 'fantasy', 'monospace']) - }, - familyName: function () { - return random.pick(['Times New Roman', 'Arial', 'Courier', 'Helvetica']) - }, - family: function () { - let s = random.pick(make.font.familyName) - if (random.chance(8)) { - s += ', ' + random.pick(make.font.genericFamily) - } - return s - }, - registeredFontFeatures: function () { - return random.pick([ - 'aalt', 'abvf', 'abvm', 'abvs', 'afrc', 'akhn', 'blwf', 'blwm', 'blws', - 'calt', 'case', 'ccmp', 'cfar', 'cjct', 'clig', 'cpct', 'cpsp', 'cswh', - 'curs', 'cv01-cv99', 'c2pc', 'c2sc', 'dist', 'dlig', 'dnom', 'expt', - 'falt', 'fin2', 'fin3', 'fina', 'frac', 'fwid', 'half', 'haln', 'halt', - 'hist', 'hkna', 'hlig', 'hngl', 'hojo', 'hwid', 'init', 'isol', 'ital', - 'jalt', 'jp78', 'jp83', 'jp90', 'jp04', 'kern', 'lfbd', 'liga', 'ljmo', - 'lnum', 'locl', 'ltra', 'ltrm', 'mark', 'med2', 'medi', 'mgrk', 'mkmk', - 'mset', 'nalt', 'nlck', 'nukt', 'numr', 'onum', 'opbd', 'ordn', 'ornm', - 'palt', 'pcap', 'pkna', 'pnum', 'pref', 'pres', 'pstf', 'psts', 'pwid', - 'qwid', 'rand', 'rkrf', 'rlig', 'rphf', 'rtbd', 'rtla', 'rtlm', 'ruby', - 'salt', 'sinf', 'size', 'smcp', 'smpl', 'ss01', 'ss02', 'ss03', 'ss04', - 'ss05', 'ss06', 'ss07', 'ss08', 'ss09', 'ss10', 'ss11', 'ss12', 'ss13', - 'ss14', 'ss15', 'ss16', 'ss17', 'ss18', 'ss19', 'ss20', 'subs', 'sups', - 'swsh', 'titl', 'tjmo', 'tnam', 'tnum', 'trad', 'twid', 'unic', 'valt', - 'vatu', 'vert', 'vhal', 'vjmo', 'vkna', 'vkrn', 'vpal', 'vrt2', 'zero' - ]) - }, - font: function () { - let s = '' - if (random.chance(4)) { - s += random.pick(make.font.style) + ' ' - } - if (random.chance(4)) { - s += random.pick(make.font.variant) + ' ' - } - if (random.chance(4)) { - s += random.pick(make.font.weight) + ' ' - } - if (random.chance(4)) { - s += make.number.any() + '/' - } - s += make.font.size() - s += ' ' - s += make.font.family() - return s - } -} - - -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -make.datetime = { - object: function () { - switch (random.number(2)) { - case 0: - return new Date(new Date().getTime() + random.number()) - case 1: - return new Date(new Date().getTime() - random.number()) - } - }, - date: function () { // eslint-disable-line no-unused-vars - return this.object().toDateString() - }, - time: function () { // eslint-disable-line no-unused-vars - return this.object().toTimeString() - }, - iso: function () { // eslint-disable-line no-unused-vars - return this.object().toISOString() - }, - epoch: function () { // eslint-disable-line no-unused-vars - return Math.floor(this.object() / 1000) - } -} - - -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -make.colors = { - any: function () { - return random.pick([ - make.colors.rgb, - make.colors.hsl, - make.colors.keyword - ]) - }, - - rgb: function () { - let values - - switch (random.number(4)) { - case 0: - // Rgb functional notation - if (random.bool()) { - // Ints - values = [random.number(255), random.number(255), random.number(255)] - } else { - // Percents - values = ['%' + random.number(255), '%' + random.number(255), '%' + random.number(255)] - } - return 'rgba(' + values.join(',') + ')' - case 1: - // Rgba functional notation - values = [random.number(255), random.number(255), random.number(255), random.float()] - return 'rgba(' + values.join(',') + ')' - case 2: - // 4 char hex - return '#' + random.hex(4) - default: - // 8 char hex - return '#' + random.hex(8) - } - }, - - hsl: function () { - let values, opt - - switch (random.number(4)) { - case 0: - values = [random.number(255), '%' + random.number(255), '%' + random.number(255)] - return 'hsl(' + values.join(',') + ')' - case 1: - values = [random.number(255), '%' + random.number(255), '%' + random.number(255), '%' + random.number(255)] - return 'hsl(' + values.join(',') + ')' - case 2: - opt = random.pick(['deg', 'rad', 'grad', 'turn']) - values = [random.number(255) + opt, '%' + random.number(255), '%' + random.number(255), '%' + random.number(255)] - return 'hsl(' + values.join(',') + ')' - default: - values = [random.number(255), '%' + random.number(255), '%' + random.number(255), random.float()] - return 'hsl(' + values.join(',') + ')' - } - }, - - keyword: function () { - return random.pick([ - 'lime', 'red', 'blue', 'invert', 'currentColor', 'ActiveBorder', 'ActiveCaption', - 'AppWorkspace', 'Background', 'ButtonFace', 'ButtonHighlight', 'ButtonShadow', - 'ButtonText', 'CaptionText', 'GrayText', 'Highlight', 'HighlightText', - 'InactiveBorder', 'InactiveCaption', 'InactiveCaptionText', 'InfoBackground', - 'InfoText', 'Menu', 'MenuText', 'Scrollbar', 'ThreeDDarkShadow', 'ThreeDFace', - 'ThreeDHighlight', 'ThreeDLightShadow', 'ThreeDShadow', 'Window', 'WindowFrame', - 'WindowText', '-moz-ButtonDefault', '-moz-ButtonHoverFace', '-moz-ButtonHoverText', - '-moz-CellHighlight', '-moz-CellHighlightText', '-moz-Combobox', '-moz-ComboboxText', - '-moz-Dialog', '-moz-DialogText', '-moz-dragtargetzone', '-moz-EvenTreeRow', - '-moz-Field', '-moz-FieldText', '-moz-html-CellHighlight', - '-moz-html-CellHighlightText', '-moz-mac-accentdarkestshadow', - '-moz-mac-accentdarkshadow', '-moz-mac-accentface', - '-moz-mac-accentlightesthighlight', '-moz-mac-accentlightshadow', - '-moz-mac-accentregularhighlight', '-moz-mac-accentregularshadow', - '-moz-mac-chrome-active', '-moz-mac-chrome-inactive', '-moz-mac-focusring', - '-moz-mac-menuselect', '-moz-mac-menushadow', '-moz-mac-menutextselect', - '-moz-MenuHover', '-moz-MenuHoverText', '-moz-MenuBarText', '-moz-MenuBarHoverText', - '-moz-nativehyperlinktext', '-moz-OddTreeRow', '-moz-win-communicationstext', - '-moz-win-mediatext', '-moz-activehyperlinktext', '-moz-default-background-color', - '-moz-default-color', '-moz-hyperlinktext', '-moz-visitedhyperlinktext' - ]) - } -} - - -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -make.shaders = { - fragment1: [ - [ - '#ifdef GL_ES', - 'precision mediump float;', - '#endif', - 'varying vec4 vColor;', - 'void main() {', - 'gl_FragColor=vColor;', - '}' - ], - [ - 'varying highp vec2 vTextureCoord;', - 'varying highp vec3 vLighting;', - 'uniform sampler2D uSampler;', - 'void main(void) {', - 'highp vec4 texelColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t));', - 'gl_FragColor = vec4(texelColor.rgb * vLighting, texelColor.a);', - '}' - ] - ], - vertex1: [ - [ - 'attribute vec4 aVertex;', - 'attribute vec4 aColor;', - 'varying vec4 vColor;', - 'void main(){', - 'vColor=aColor;', - 'gl_Position=aVertex;', - '}' - ], - [ - 'attribute highp vec3 aVertexNormal;', - 'attribute highp vec3 aVertexPosition;', - 'attribute highp vec2 aTextureCoord;', - 'uniform highp mat4 uNormalMatrix;', - 'uniform highp mat4 uMVMatrix;', - 'uniform highp mat4 uPMatrix;', - 'varying highp vec2 vTextureCoord;', - 'varying highp vec3 vLighting;', - 'void main(void) {', - 'gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);', - 'vTextureCoord = aTextureCoord;', - 'highp vec3 ambientLight = vec3(0.6, 0.6, 0.6);', - 'highp vec3 directionalLightColor = vec3(0.5, 0.5, 0.75);', - 'highp vec3 directionalVector = vec3(0.85, 0.8, 0.75);', - 'highp vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0);', - 'highp float directional = max(dot(transformedNormal.xyz, directionalVector), 0.0);', - 'vLighting = ambientLight + (directionalLightColor * directional);', - '}' - ] - ], - fragment2: [ - [ - 'varying highp vec2 vTextureCoord;', - 'varying highp vec3 vLighting;', - 'uniform sampler2D uSampler;', - 'void main(void) {', - 'highp vec4 texelColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t));', - 'gl_FragColor = vec4(texelColor.rgb * vLighting, texelColor.a);', - '}' - ], - [ - '#version proto-200', - 'uniform sampler2D albedoMap;', - 'uniform sampler2D normalMap;', - 'varying vec3 varyingTangent;', - 'varying vec3 varyingBitangent;', - 'varying vec3 varyingNormal;', - 'varying vec2 varyingUV;', - 'void main(void) {', - 'vec3 albedo=texture2D(albedoMap,varyingUV).rgb;', - 'vec3 normal=texture2D(normalMap,varyingUV).rgb*2.0-1.0;', - 'float specularFactor=pow((albedo.r+albedo.g+albedo.b)*0.33,2.0);', - 'float specularHardness=2.0;', - 'vec3 spaceNormal=varyingTangent*normal.x+varyingBitangent*normal.y+varyingNormal*normal.z;', - 'gl_FragData[0]=vec4(albedo,1.0);', - 'gl_FragData[1]=vec4(spaceNormal*0.5 +0.5,1.0);', - 'gl_FragData[2]=vec4(specularFactor,specularHardness*0.1,0.0,1.0);', - '}' - ] - ], - vertex2: [ - [ - 'attribute highp vec3 aVertexNormal;', - 'attribute highp vec3 aVertexPosition;', - 'attribute highp vec2 aTextureCoord;', - 'uniform highp mat4 uNormalMatrix;', - 'uniform highp mat4 uMVMatrix;', - 'uniform highp mat4 uPMatrix;', - 'varying highp vec2 vTextureCoord;', - 'varying highp vec3 vLighting;', - 'void main(void) {', - 'gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);', - 'vTextureCoord = aTextureCoord;', - 'highp vec3 ambientLight = vec3(0.6, 0.6, 0.6);', - 'highp vec3 directionalLightColor = vec3(0.5, 0.5, 0.75);', - 'highp vec3 directionalVector = vec3(0.85, 0.8, 0.75);', - 'highp vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0);', - 'highp float directional = max(dot(transformedNormal.xyz, directionalVector), 0.0);', - 'vLighting = ambientLight + (directionalLightColor * directional);', - '}' - ], - [ - '#version proto-200', - 'attribute vec3 vertexPosition;', - 'attribute vec3 vertexTangent;', - 'attribute vec3 vertexBitangent;', - 'attribute vec3 vertexNormal;', - 'attribute vec2 vertexUV;', - 'uniform mat4 modelMatrix;', - 'uniform mat4 viewMatrix;', - 'varying vec3 varyingTangent;', - 'varying vec3 varyingBitangent;', - 'varying vec3 varyingNormal;', - 'varying vec2 varyingUV;', - 'void main(void){', - 'gl_Position=viewMatrix*(modelMatrix*vec4(vertexPosition,1.0));', - 'gl_Position.xy=gl_Position.xy*0.5+(float(gl_InstanceID)-0.5);', - 'varyingTangent=(modelMatrix*vec4(vertexTangent,0.0)).xyz;', - 'varyingBitangent=(modelMatrix*vec4(vertexBitangent,0.0)).xyz;', - 'varyingNormal=(modelMatrix*vec4(vertexNormal,0.0)).xyz;', - 'varyingUV = vertexUV;', - '}' - ] - ], - shaderPair: function (v, f) { - let i = random.number(v.length) - return { - vertex: utils.common.quote(v[i].join('\n')), - fragment: utils.common.quote(f[i].join('\n')) - } - } -} - - -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -make.crypto = { - keyFormats: [ - 'raw', - 'spki', - 'pkcs8', - 'jwk' - ], - randomKeyFormat: () => random.item(make.crypto.keyFormats), - keyTypes: [ - 'public', - 'private', - 'secret' - ], - randomKeyType: () => random.item(make.crypto.keyTypes), - keyUsages: [ - 'encrypt', - 'decrypt', - 'sign', - 'verify', - 'deriveKey', - 'deriveBits', - 'wrapKey', - 'unwrapKey' - ], - randomKeyUsage: () => random.subset(make.crypto.keyUsages), - curves: [ - 'P-256', - 'P-384', - 'P-521' - ], - randomCurve: () => random.item(make.crypto.curves), - jwkUsages: [ - 'enc', - 'sig' - ], - randomJwkUsage: () => random.subset(make.crypto.jwkUsages), - jwkKeyTypes: [ - 'oct', - 'RSA', - 'EC' - ], - randomJwkKeyType: () => random.subset(make.crypto.jwkKeyTypes), - algorithmNames: { - // https://www.w3.org/TR/WebCryptoAPI/#algorithm-overview - sign: [ - 'RSASSA-PKCS1-v1_5', - 'RSA-PSS', - 'ECDSA', - 'HMAC' - ], - verify: [ - 'RSASSA-PKCS1-v1_5', - 'RSA-PSS', - 'ECDSA', - 'HMAC' - ], - generateKey: [ - 'RSASSA-PKCS1-v1_5', - 'RSA-PSS', - 'RSA-OAEP', - 'ECDSA', - 'ECDH', - 'AES-CTR', - 'AES-CBC', - 'AES-GCM', - 'AES-KW', - 'HMAC' - ], - importKey: [ - 'RSASSA-PKCS1-v1_5', - 'RSA-PSS', - 'RSA-OAEP', - 'ECDSA', - 'ECDH', - 'AES-CTR', - 'AES-CBC', - 'AES-GCM', - 'AES-KW', - 'HMAC', - 'HKDF', - 'PBKDF2' - ], - exportKey: [ - 'RSASSA-PKCS1-v1_5', - 'RSA-PSS', - 'RSA-OAEP', - 'ECDSA', - 'ECDH', - 'AES-CTR', - 'AES-CBC', - 'AES-GCM', - 'AES-KW', - 'HMAC' - ], - encrypt: [ - 'RSA-OAEP', - 'AES-CTR', - 'AES-CBC', - 'AES-GCM' - ], - decrypt: [ - 'RSA-OAEP', - 'AES-CTR', - 'AES-CBC', - 'AES-GCM' - ], - deriveBits: [ - 'ECDH', - 'HKDF', - 'PBKDF2' - ], - deriveKey: [ - 'ECDH', - 'HKDF', - 'PBKDF2' - ], - wrapKey: [ - 'RSA-OAEP', - 'AES-CTR', - 'AES-CBC', - 'AES-GCM', - 'AES-KW' - ], - unwrapKey: [ - 'RSA-OAEP', - 'AES-CTR', - 'AES-CBC', - 'AES-GCM', - 'AES-KW' - ], - digest: [ - 'SHA-1', - 'SHA-256', - 'SHA-384', - 'SHA-512' - ] - }, - randomAlgorithmName: (method) => random.item(make.crypto.algorithmNames[method]), - randomDigestName: () => random.item(make.crypto.algorithmNames.digest), - algorithms: { - /* (Unsupported as of 30/01/2017) - ------------------------------- - | | Firefox | Chrome | - ----------------------------- | - | AES-CMAC | x | x | - | AES-CFB | x | x | - | CONCAT | x | x | - | HKDF-CTR | x | x | - | DH | | x | - ------------------------------- - */ - 'RSASSA-PKCS1-v1_5': { - // RSASA-PKCS1_v1_5 algorithm, using a SHA hash function. - keyUsages: ['sign', 'verify'], - length: function (len) { - return len || random.item([1, 256, 384, 512]) - }, - alg: function (len) { - return utils.common.mockup(`{ - name: 'RSASSA-PKCS1-v1_5', - hash: { - name: 'SHA-${this.length(len)}' - }, - modulusLength: ${random.item([1024, 2048, 4096])}, - publicExponent: new Uint8Array([0x01, 0x00, 0x01]) - }`) - }, - jwk: function (len) { - return utils.common.mockup(`{ - kty: 'RSA', - alg: 'RS${this.length(len)}' - }`) - }, - generateKey: function () { - return this.alg() - }, - importKey: function () { - return this.alg() - }, - sign: function () { - return this.alg() - }, - verify: function () { - return this.alg() - }, - presets: { - raw: {}, - jwk: [ - { - kty: 'RSA', - e: 'AQAB', - n: 'vGO3eU16ag9zRkJ4AK8ZUZrjbtp5xWK0LyFMNT8933evJoHeczexMUzSiXaLrEFSyQZortk81zJH3y41MBO_UFDO_X0crAquNrkjZDrf9Scc5-MdxlWU2Jl7Gc4Z18AC9aNibWVmXhgvHYkEoFdLCFG-2Sq-qIyW4KFkjan05IE', - alg: 'RS256', - ext: true - }, - { - kty: 'RSA', - e: 'AQAB', - d: 'n_dIVw9MD_04lANi5KnKJPoRfxKy7cGHYLG0hU5DGpsFNfx2yH0Uz9j8uU7ZARai1iHECBxcxhpi3wbckQtjmbkCUKvs4G0gKLT9UuNHcCbh0WfvadfPPec52n4z6s4zwisbgWCNbT2L-SyHt1yuFmLAYXkg0swk3y5Bt_ilA8E', - dp: '2RNM_uiYEQMcATQaUu3AwdeJpenCPykbQHkwAylvXqlHB6W7m5XX0k-SutkbXAijmGTC-Oh8NexsLGHxOACb8Q', - dq: 'rHabkI3_XVGieLqHujpWaWe9YD03fJY0KbbQX0fIoNdNU4GcmUftzIWLSajPKKsiyfR6Xk2AEtBmBPE5qaoV6Q', - n: 'vGO3eU16ag9zRkJ4AK8ZUZrjbtp5xWK0LyFMNT8933evJoHeczexMUzSiXaLrEFSyQZortk81zJH3y41MBO_UFDO_X0crAquNrkjZDrf9Scc5-MdxlWU2Jl7Gc4Z18AC9aNibWVmXhgvHYkEoFdLCFG-2Sq-qIyW4KFkjan05IE', - p: '5Y4ynodegqC9kgGmfZeSrojGmLyYR8HIvKVEAIjjMUQjyvKWpWsXfPg67mTdqVpjSpQLQlRfES2nUvZ27KrU6Q', - q: '0hd_U9PcNpMe77nhsTgoVNgMB34cqfrfu4fPuJ-7NvvMkKIELDLy-m8qg1MBbgf2i5546A9B5Exsuj4D2Vwz2Q', - qi: 'R3CkCGVAESy_hChmDvUaLMT-R1xk6kK7RLIUQKXATPQbnDqWBMgm-vcawFVhKJ-ICJsPfmRUsv7Wt1bJ01wLGQ', - alg: 'RS256', - ext: true - } - ], - spki: 'new Uint8Array([48, 129, 159, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 3, 129, 141, 0, 48, 129, 137, 2, 129, 129, 0, 182, 93, 35, 213, 252, 204, 20, 103, 91, 238, 105, 199, 53, 114, 24, 221, 114, 210, 137, 173, 88, 76, 205, 113, 148, 148, 79, 80, 59, 208, 60, 75, 231, 248, 78, 125, 12, 30, 237, 226, 63, 146, 157, 203, 239, 60, 138, 123, 234, 50, 23, 174, 216, 33, 122, 16, 53, 246, 140, 254, 75, 246, 205, 204, 117, 204, 115, 29, 178, 102, 139, 201, 74, 177, 45, 131, 183, 166, 234, 61, 124, 75, 110, 3, 70, 202, 148, 95, 45, 228, 94, 95, 148, 2, 162, 79, 146, 137, 29, 189, 102, 75, 207, 214, 116, 58, 63, 171, 219, 27, 5, 9, 108, 16, 218, 23, 169, 43, 181, 119, 31, 172, 95, 205, 180, 18, 255, 203, 2, 3, 1, 0, 1])', - pkcs8: 'new Uint8Array([48, 130, 2, 118, 2, 1, 0, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 4, 130, 2, 96, 48, 130, 2, 92, 2, 1, 0, 2, 129, 129, 0, 217, 78, 147, 218, 221, 152, 10, 66, 75, 127, 242, 108, 182, 142, 157, 44, 93, 58, 176, 193, 135, 103, 216, 179, 69, 72, 38, 115, 144, 244, 12, 139, 0, 245, 48, 115, 204, 234, 158, 193, 231, 127, 178, 240, 244, 203, 35, 229, 203, 245, 110, 215, 199, 19, 98, 183, 164, 223, 159, 203, 128, 123, 173, 26, 12, 172, 250, 99, 254, 35, 225, 221, 39, 51, 62, 3, 139, 35, 38, 164, 71, 238, 240, 73, 139, 214, 68, 172, 204, 253, 171, 244, 14, 186, 152, 159, 225, 133, 229, 140, 99, 50, 183, 242, 217, 248, 86, 233, 20, 117, 42, 136, 55, 8, 65, 124, 244, 65, 29, 15, 194, 255, 78, 31, 189, 146, 105, 161, 2, 3, 1, 0, 1, 2, 129, 128, 26, 88, 13, 82, 166, 52, 141, 97, 214, 23, 79, 195, 96, 42, 79, 225, 149, 247, 204, 127, 217, 179, 124, 48, 215, 128, 84, 177, 3, 236, 162, 44, 163, 212, 21, 168, 164, 57, 249, 63, 22, 154, 131, 141, 244, 143, 63, 237, 214, 217, 13, 51, 249, 125, 95, 37, 86, 70, 137, 239, 184, 198, 197, 136, 62, 183, 41, 78, 118, 234, 57, 195, 161, 219, 173, 234, 61, 11, 165, 109, 209, 9, 3, 22, 186, 114, 32, 135, 147, 74, 6, 106, 190, 214, 36, 208, 32, 220, 61, 12, 41, 105, 251, 247, 18, 159, 3, 198, 28, 228, 36, 44, 189, 125, 45, 72, 233, 199, 12, 72, 91, 106, 165, 246, 217, 58, 168, 53, 2, 65, 0, 241, 112, 53, 166, 98, 11, 38, 73, 58, 156, 84, 190, 118, 74, 247, 229, 85, 178, 83, 231, 53, 137, 237, 228, 246, 12, 32, 206, 157, 198, 152, 70, 11, 185, 234, 30, 112, 23, 115, 249, 68, 176, 159, 108, 247, 249, 207, 152, 145, 166, 246, 79, 176, 219, 163, 111, 243, 4, 49, 3, 239, 242, 63, 147, 2, 65, 0, 230, 105, 200, 1, 208, 201, 237, 225, 85, 27, 39, 216, 193, 1, 253, 168, 88, 15, 242, 166, 70, 106, 235, 2, 92, 24, 130, 66, 176, 176, 220, 238, 66, 12, 159, 26, 24, 40, 19, 213, 138, 98, 238, 98, 220, 65, 148, 116, 146, 21, 0, 25, 6, 177, 57, 216, 70, 51, 149, 244, 157, 153, 106, 123, 2, 64, 127, 92, 254, 48, 67, 80, 54, 102, 50, 240, 253, 19, 108, 59, 168, 1, 230, 239, 39, 171, 180, 102, 138, 132, 89, 247, 147, 230, 234, 252, 52, 159, 222, 215, 184, 85, 78, 52, 81, 13, 145, 218, 202, 127, 37, 97, 54, 205, 249, 39, 230, 143, 171, 112, 114, 11, 64, 91, 89, 176, 6, 7, 248, 217, 2, 65, 0, 220, 94, 95, 132, 29, 4, 132, 22, 247, 38, 185, 189, 125, 27, 66, 87, 55, 162, 73, 24, 238, 80, 99, 228, 37, 224, 234, 244, 141, 185, 26, 20, 101, 231, 92, 99, 192, 166, 212, 17, 112, 1, 158, 173, 190, 170, 154, 41, 195, 109, 130, 98, 109, 28, 35, 142, 205, 213, 152, 158, 19, 253, 30, 241, 2, 64, 15, 148, 8, 16, 189, 122, 55, 109, 203, 175, 173, 24, 222, 36, 130, 130, 179, 87, 189, 32, 141, 149, 30, 115, 211, 227, 79, 234, 78, 202, 253, 48, 173, 95, 167, 203, 20, 193, 160, 30, 146, 33, 109, 4, 221, 25, 212, 216, 183, 100, 18, 46, 184, 52, 65, 146, 249, 68, 225, 10, 84, 38, 98, 133])' - } - }, - 'RSA-PSS': { - keyUsages: ['sign', 'verify'], - length: function (len) { - return len || random.item([1, 256, 384, 512]) - }, - alg: function (len) { - return utils.common.mockup(`{ - name: 'RSA-PSS', - hash: { - name: 'SHA-${this.length(len)}' - }, - modulusLength: ${random.item([1024, 2048, 4096])}, - publicExponent: new Uint8Array([0x01, 0x00, 0x01]), - saltLength: 8 - }`) - }, - jwk: function (len) { - return utils.common.mockup(`{ - kty: 'RSA', - alg: 'PS${this.length(len)}' - }`) - }, - generateKey: function () { - return this.alg() - }, - importKey: function () { - return this.alg() - }, - sign: function () { - return this.alg() - }, - verify: function () { - return this.alg() - }, - presets: { - raw: {}, - jwk: [ - { - kty: 'RSA', - e: 'AQAB', - n: 'vGO3eU16ag9zRkJ4AK8ZUZrjbtp5xWK0LyFMNT8933evJoHeczexMUzSiXaLrEFSyQZortk81zJH3y41MBO_UFDO_X0crAquNrkjZDrf9Scc5-MdxlWU2Jl7Gc4Z18AC9aNibWVmXhgvHYkEoFdLCFG-2Sq-qIyW4KFkjan05IE', - alg: 'RS256', - ext: true - }, - { - kty: 'RSA', - e: 'AQAB', - d: 'n_dIVw9MD_04lANi5KnKJPoRfxKy7cGHYLG0hU5DGpsFNfx2yH0Uz9j8uU7ZARai1iHECBxcxhpi3wbckQtjmbkCUKvs4G0gKLT9UuNHcCbh0WfvadfPPec52n4z6s4zwisbgWCNbT2L-SyHt1yuFmLAYXkg0swk3y5Bt_ilA8E', - dp: '2RNM_uiYEQMcATQaUu3AwdeJpenCPykbQHkwAylvXqlHB6W7m5XX0k-SutkbXAijmGTC-Oh8NexsLGHxOACb8Q', - dq: 'rHabkI3_XVGieLqHujpWaWe9YD03fJY0KbbQX0fIoNdNU4GcmUftzIWLSajPKKsiyfR6Xk2AEtBmBPE5qaoV6Q', - n: 'vGO3eU16ag9zRkJ4AK8ZUZrjbtp5xWK0LyFMNT8933evJoHeczexMUzSiXaLrEFSyQZortk81zJH3y41MBO_UFDO_X0crAquNrkjZDrf9Scc5-MdxlWU2Jl7Gc4Z18AC9aNibWVmXhgvHYkEoFdLCFG-2Sq-qIyW4KFkjan05IE', - p: '5Y4ynodegqC9kgGmfZeSrojGmLyYR8HIvKVEAIjjMUQjyvKWpWsXfPg67mTdqVpjSpQLQlRfES2nUvZ27KrU6Q', - q: '0hd_U9PcNpMe77nhsTgoVNgMB34cqfrfu4fPuJ-7NvvMkKIELDLy-m8qg1MBbgf2i5546A9B5Exsuj4D2Vwz2Q', - qi: 'R3CkCGVAESy_hChmDvUaLMT-R1xk6kK7RLIUQKXATPQbnDqWBMgm-vcawFVhKJ-ICJsPfmRUsv7Wt1bJ01wLGQ', - alg: 'PS256', - ext: true - } - ], - spki: 'new Uint8Array([48, 129, 159, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 3, 129, 141, 0, 48, 129, 137, 2, 129, 129, 0, 180, 31, 227, 200, 37, 227, 65, 238, 23, 91, 226, 130, 51, 32, 165, 245, 1, 24, 244, 5, 184, 42, 181, 155, 23, 142, 249, 220, 222, 131, 175, 54, 117, 135, 64, 232, 120, 90, 160, 221, 18, 31, 200, 41, 23, 174, 18, 172, 247, 166, 90, 37, 156, 229, 2, 70, 169, 165, 93, 246, 120, 117, 59, 202, 3, 102, 44, 119, 154, 54, 28, 198, 111, 39, 144, 73, 69, 251, 179, 74, 41, 215, 115, 186, 124, 200, 105, 75, 104, 158, 156, 158, 238, 214, 14, 81, 95, 130, 155, 146, 114, 125, 88, 158, 212, 44, 65, 236, 228, 194, 105, 96, 211, 155, 60, 71, 134, 90, 151, 202, 68, 20, 228, 105, 249, 202, 170, 155, 2, 3, 1, 0, 1])', - plcs8: 'new Uint8Array([48, 130, 2, 119, 2, 1, 0, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 4, 130, 2, 97, 48, 130, 2, 93, 2, 1, 0, 2, 129, 129, 0, 180, 31, 227, 200, 37, 227, 65, 238, 23, 91, 226, 130, 51, 32, 165, 245, 1, 24, 244, 5, 184, 42, 181, 155, 23, 142, 249, 220, 222, 131, 175, 54, 117, 135, 64, 232, 120, 90, 160, 221, 18, 31, 200, 41, 23, 174, 18, 172, 247, 166, 90, 37, 156, 229, 2, 70, 169, 165, 93, 246, 120, 117, 59, 202, 3, 102, 44, 119, 154, 54, 28, 198, 111, 39, 144, 73, 69, 251, 179, 74, 41, 215, 115, 186, 124, 200, 105, 75, 104, 158, 156, 158, 238, 214, 14, 81, 95, 130, 155, 146, 114, 125, 88, 158, 212, 44, 65, 236, 228, 194, 105, 96, 211, 155, 60, 71, 134, 90, 151, 202, 68, 20, 228, 105, 249, 202, 170, 155, 2, 3, 1, 0, 1, 2, 129, 128, 102, 251, 236, 161, 220, 119, 168, 148, 86, 42, 164, 192, 200, 54, 156, 108, 14, 42, 148, 42, 72, 247, 178, 73, 112, 24, 192, 230, 245, 25, 217, 45, 139, 216, 190, 213, 171, 42, 53, 218, 239, 167, 216, 43, 22, 108, 226, 36, 158, 155, 47, 227, 93, 102, 217, 252, 72, 182, 81, 152, 191, 154, 87, 137, 219, 194, 236, 53, 200, 123, 61, 10, 59, 231, 41, 18, 116, 77, 148, 50, 170, 116, 221, 110, 170, 190, 158, 108, 217, 38, 73, 84, 183, 51, 122, 179, 217, 143, 255, 87, 82, 80, 223, 188, 84, 134, 146, 150, 169, 64, 30, 168, 104, 8, 123, 162, 46, 59, 47, 232, 0, 35, 202, 42, 195, 141, 6, 1, 2, 65, 0, 237, 171, 148, 110, 241, 19, 152, 216, 206, 77, 109, 215, 21, 144, 110, 96, 34, 61, 46, 214, 148, 70, 238, 119, 206, 128, 32, 24, 136, 197, 185, 254, 209, 35, 235, 231, 122, 246, 167, 183, 117, 176, 51, 133, 169, 47, 130, 178, 40, 225, 145, 219, 48, 56, 21, 46, 198, 18, 85, 218, 194, 150, 141, 27, 2, 65, 0, 194, 4, 41, 152, 43, 246, 147, 7, 229, 244, 215, 110, 143, 7, 184, 187, 22, 166, 113, 217, 81, 52, 205, 54, 73, 202, 244, 24, 24, 219, 254, 243, 230, 230, 212, 172, 225, 218, 112, 95, 118, 103, 144, 223, 248, 164, 19, 228, 204, 204, 64, 91, 76, 77, 4, 206, 89, 173, 154, 162, 134, 113, 176, 129, 2, 64, 58, 4, 78, 97, 158, 155, 200, 13, 244, 158, 86, 23, 208, 253, 198, 211, 212, 199, 214, 173, 46, 216, 249, 209, 105, 41, 65, 172, 123, 134, 184, 214, 137, 59, 25, 149, 18, 33, 47, 227, 202, 232, 206, 74, 236, 119, 218, 145, 159, 5, 33, 83, 190, 59, 146, 128, 46, 125, 191, 83, 125, 120, 190, 205, 2, 65, 0, 134, 6, 204, 25, 20, 29, 180, 250, 90, 207, 229, 214, 185, 53, 211, 86, 98, 210, 62, 137, 170, 128, 120, 86, 205, 105, 71, 112, 50, 20, 31, 174, 171, 206, 192, 18, 97, 191, 61, 171, 164, 166, 236, 188, 220, 13, 180, 180, 117, 9, 144, 87, 193, 128, 223, 22, 17, 123, 76, 252, 131, 53, 156, 129, 2, 65, 0, 178, 29, 141, 176, 179, 203, 180, 190, 224, 34, 134, 226, 151, 73, 139, 163, 47, 17, 179, 117, 167, 200, 255, 174, 67, 114, 158, 96, 195, 176, 163, 241, 96, 24, 72, 35, 38, 18, 132, 176, 76, 235, 8, 29, 225, 138, 155, 191, 97, 158, 3, 22, 114, 133, 176, 213, 207, 120, 33, 55, 52, 135, 79, 161])' - } - }, - 'RSA-OAEP': { - // RSAES-OAEP algorithm using a SHA hash functions and a MGF1 mask generating function. - keyUsages: ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey'], - length: function (len) { - return len || random.item([1, 256, 384, 512]) - }, - alg: function (len) { - return utils.common.mockup(`{ - name: 'RSA-OAEP', - hash: { - name: 'SHA-${this.length(len)}' - }, - modulusLength: ${random.item([1024, 2048, 4096])}, - publicExponent: new Uint8Array([0x01, 0x00, 0x01]) - }`) - }, - jwk: function (len) { - return utils.common.mockup(`{ - kty: 'RSA', - alg: 'RSA-OAEP-${this.length(len)}' - }`) - }, - generateKey: function () { - return this.alg() - }, - importKey: function () { - return this.alg() - }, - encrypt: function () { - utils.common.mockup(`{ - name: 'RSA-OAEP', - hash: { - name: 'SHA-${this.length()}' - }, - modulusLength: ${random.item([1024, 2048, 4096])}, - publicExponent: new Uint8Array([0x01, 0x00, 0x01]), - label: crypto.getRandomValues(new Uint8Array(16)) - }`) - }, - decrypt: function () { - return this.alg() - }, - unwrapKey: function () { - return this.alg() - }, - wrapKey: function () { - return this.alg() - }, - presets: { - raw: {}, - jkw: [ - { - kty: 'RSA', - e: 'AQAB', - n: 'vGO3eU16ag9zRkJ4AK8ZUZrjbtp5xWK0LyFMNT8933evJoHeczexMUzSiXaLrEFSyQZortk81zJH3y41MBO_UFDO_X0crAquNrkjZDrf9Scc5-MdxlWU2Jl7Gc4Z18AC9aNibWVmXhgvHYkEoFdLCFG-2Sq-qIyW4KFkjan05IE', - alg: 'RSA-OAEP-256', - ext: true - }, - { - kty: 'RSA', - e: 'AQAB', - d: 'e-Nm1CB_F7j0p4Cb-T4WmFTh7RbxUthC3j8xnlXwHgWYwaPs9ZRkicgNCfmjEb-qJ-m0ho1Cz4WzlL1CtTKEdr2w0P6L_IQPvWkFYwUm0rpY9doxnOKkzq53dhP5zdc6N8aOLk4cmAcVjw4o_csc85H-0fxzQxsTP0_jhJn7SNE', - dp: 'JuZmXNBY9uGGfx3w3ysmFumGBLooNjMwwgMduVS6T8S-0tZkBU-iwJPzXAkKhwINEv1EnygjwmJLBdoHROeEeQ', - dq: 'KaKOFHxm9104WNwqTth04O9ogaDz_W0wkeHnxOxbWgdtFxsarnImiMlI3Hphv9JuHD5awzNAkaj9P7wDVew-5Q', - n: 'x-Do39ky8RVFrFplFfAuOQGLr-rqY3h9OiNHVMe34LoVG4Aofps11ycyw5ka3Ls_yA-oRouGmaMjaiPUoaU_Lm5-CMSoVwyeANLZ4b2S7V-srXFS-Qpe6aD7NpzoUL9knwTnZFIGZlxSXB-NXL5kq18UuO1LQGe1To16ijXKNxc', - p: '4ss3ZAQMdmOk1BRQXwM9YHAoxVDkHDnSV9u89tUb3RbPXlV3fLlhRYtZ7u3FYaTzy08s8Ty2hV1KZ7xXhKEtuQ', - q: '4Z5ejmIJTwsgxN5pI6mLxwXqQwFDERYDnwU9_vyToWXMEPAphWpS9ET00YrdHsgIGao1Slc0jp4OUxaLfhtzTw', - qi: 'R1aKNnhUiTjoCHfOVHZ6Qv5R7So-F5mtjDKCBvCi8190U3E25DiKRvDqHZ0bHMRbdQPLLknxHVnuETw6gddHUg', - alg: 'RSA-OAEP-256', - ext: true - } - ], - spki: 'new Uint8Array([48, 129, 159, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 3, 129, 141, 0, 48, 129, 137, 2, 129, 129, 0, 182, 93, 35, 213, 252, 204, 20, 103, 91, 238, 105, 199, 53, 114, 24, 221, 114, 210, 137, 173, 88, 76, 205, 113, 148, 148, 79, 80, 59, 208, 60, 75, 231, 248, 78, 125, 12, 30, 237, 226, 63, 146, 157, 203, 239, 60, 138, 123, 234, 50, 23, 174, 216, 33, 122, 16, 53, 246, 140, 254, 75, 246, 205, 204, 117, 204, 115, 29, 178, 102, 139, 201, 74, 177, 45, 131, 183, 166, 234, 61, 124, 75, 110, 3, 70, 202, 148, 95, 45, 228, 94, 95, 148, 2, 162, 79, 146, 137, 29, 189, 102, 75, 207, 214, 116, 58, 63, 171, 219, 27, 5, 9, 108, 16, 218, 23, 169, 43, 181, 119, 31, 172, 95, 205, 180, 18, 255, 203, 2, 3, 1, 0, 1])', - pkcs8: 'new Uint8Array([48, 130, 2, 118, 2, 1, 0, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 4, 130, 2, 96, 48, 130, 2, 92, 2, 1, 0, 2, 129, 129, 0, 217, 78, 147, 218, 221, 152, 10, 66, 75, 127, 242, 108, 182, 142, 157, 44, 93, 58, 176, 193, 135, 103, 216, 179, 69, 72, 38, 115, 144, 244, 12, 139, 0, 245, 48, 115, 204, 234, 158, 193, 231, 127, 178, 240, 244, 203, 35, 229, 203, 245, 110, 215, 199, 19, 98, 183, 164, 223, 159, 203, 128, 123, 173, 26, 12, 172, 250, 99, 254, 35, 225, 221, 39, 51, 62, 3, 139, 35, 38, 164, 71, 238, 240, 73, 139, 214, 68, 172, 204, 253, 171, 244, 14, 186, 152, 159, 225, 133, 229, 140, 99, 50, 183, 242, 217, 248, 86, 233, 20, 117, 42, 136, 55, 8, 65, 124, 244, 65, 29, 15, 194, 255, 78, 31, 189, 146, 105, 161, 2, 3, 1, 0, 1, 2, 129, 128, 26, 88, 13, 82, 166, 52, 141, 97, 214, 23, 79, 195, 96, 42, 79, 225, 149, 247, 204, 127, 217, 179, 124, 48, 215, 128, 84, 177, 3, 236, 162, 44, 163, 212, 21, 168, 164, 57, 249, 63, 22, 154, 131, 141, 244, 143, 63, 237, 214, 217, 13, 51, 249, 125, 95, 37, 86, 70, 137, 239, 184, 198, 197, 136, 62, 183, 41, 78, 118, 234, 57, 195, 161, 219, 173, 234, 61, 11, 165, 109, 209, 9, 3, 22, 186, 114, 32, 135, 147, 74, 6, 106, 190, 214, 36, 208, 32, 220, 61, 12, 41, 105, 251, 247, 18, 159, 3, 198, 28, 228, 36, 44, 189, 125, 45, 72, 233, 199, 12, 72, 91, 106, 165, 246, 217, 58, 168, 53, 2, 65, 0, 241, 112, 53, 166, 98, 11, 38, 73, 58, 156, 84, 190, 118, 74, 247, 229, 85, 178, 83, 231, 53, 137, 237, 228, 246, 12, 32, 206, 157, 198, 152, 70, 11, 185, 234, 30, 112, 23, 115, 249, 68, 176, 159, 108, 247, 249, 207, 152, 145, 166, 246, 79, 176, 219, 163, 111, 243, 4, 49, 3, 239, 242, 63, 147, 2, 65, 0, 230, 105, 200, 1, 208, 201, 237, 225, 85, 27, 39, 216, 193, 1, 253, 168, 88, 15, 242, 166, 70, 106, 235, 2, 92, 24, 130, 66, 176, 176, 220, 238, 66, 12, 159, 26, 24, 40, 19, 213, 138, 98, 238, 98, 220, 65, 148, 116, 146, 21, 0, 25, 6, 177, 57, 216, 70, 51, 149, 244, 157, 153, 106, 123, 2, 64, 127, 92, 254, 48, 67, 80, 54, 102, 50, 240, 253, 19, 108, 59, 168, 1, 230, 239, 39, 171, 180, 102, 138, 132, 89, 247, 147, 230, 234, 252, 52, 159, 222, 215, 184, 85, 78, 52, 81, 13, 145, 218, 202, 127, 37, 97, 54, 205, 249, 39, 230, 143, 171, 112, 114, 11, 64, 91, 89, 176, 6, 7, 248, 217, 2, 65, 0, 220, 94, 95, 132, 29, 4, 132, 22, 247, 38, 185, 189, 125, 27, 66, 87, 55, 162, 73, 24, 238, 80, 99, 228, 37, 224, 234, 244, 141, 185, 26, 20, 101, 231, 92, 99, 192, 166, 212, 17, 112, 1, 158, 173, 190, 170, 154, 41, 195, 109, 130, 98, 109, 28, 35, 142, 205, 213, 152, 158, 19, 253, 30, 241, 2, 64, 15, 148, 8, 16, 189, 122, 55, 109, 203, 175, 173, 24, 222, 36, 130, 130, 179, 87, 189, 32, 141, 149, 30, 115, 211, 227, 79, 234, 78, 202, 253, 48, 173, 95, 167, 203, 20, 193, 160, 30, 146, 33, 109, 4, 221, 25, 212, 216, 183, 100, 18, 46, 184, 52, 65, 146, 249, 68, 225, 10, 84, 38, 98, 133])' - } - }, - 'ECDSA': { - keyUsages: ['sign', 'verify'], - length: function (len) { - return len || random.item([256, 384, 512]) - }, - alg: function (len) { - len = this.length(len) - return utils.common.mockup(`{ - name: 'ECDSA', - namedCurve: 'P-${len}', - hash: { - name: 'SHA-${len}' - } - }`) - }, - jwk: function (len) { - return utils.common.mockup(`{ - kty: 'EC', - alg: 'ES${this.length(len)}' - }`) - }, - generateKey: function () { - return this.alg() - }, - importKey: function () { - return this.alg() - }, - sign: function () { - return this.alg() - }, - verify: function () { - return this.alg() - }, - presets: { - raw: {}, - jwk: [ - { - kty: 'EC', - crv: 'P-256', - x: 'A5fQnBdBSgBhTjMr1Atpzvh5SKYQ4aQRJ9WTCG5U4m4', - y: '8YF98byzMljHX3T5ORLYTDbcwG-_eq3f23JtTE6lOe0', - ext: true - }, - { - kty: 'EC', - crv: 'P-256', - x: 'A5fQnBdBSgBhTjMr1Atpzvh5SKYQ4aQRJ9WTCG5U4m4', - y: '8YF98byzMljHX3T5ORLYTDbcwG-_eq3f23JtTE6lOe0', - d: '4DvC-hxpv8myZLNeMY-8nq55MhdfA4obM1lGG3hF_yo', - ext: true - } - ], - spki: 'new Uint8Array([48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7, 3, 66, 0, 4, 3, 151, 208, 156, 23, 65, 74, 0, 97, 78, 51, 43, 212, 11, 105, 206, 248, 121, 72, 166, 16, 225, 164, 17, 39, 213, 147, 8, 110, 84, 226, 110, 241, 129, 125, 241, 188, 179, 50, 88, 199, 95, 116, 249, 57, 18, 216, 76, 54, 220, 192, 111, 191, 122, 173, 223, 219, 114, 109, 76, 78, 165, 57, 237])', - pkcs8: 'new Uint8Array([48, 129, 135, 2, 1, 0, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7, 4, 109, 48, 107, 2, 1, 1, 4, 32, 224, 59, 194, 250, 28, 105, 191, 201, 178, 100, 179, 94, 49, 143, 188, 158, 174, 121, 50, 23, 95, 3, 138, 27, 51, 89, 70, 27, 120, 69, 255, 42, 161, 68, 3, 66, 0, 4, 3, 151, 208, 156, 23, 65, 74, 0, 97, 78, 51, 43, 212, 11, 105, 206, 248, 121, 72, 166, 16, 225, 164, 17, 39, 213, 147, 8, 110, 84, 226, 110, 241, 129, 125, 241, 188, 179, 50, 88, 199, 95, 116, 249, 57, 18, 216, 76, 54, 220, 192, 111, 191, 122, 173, 223, 219, 114, 109, 76, 78, 165, 57, 237])' - } - }, - 'ECDH': { - keyUsages: ['deriveKey', 'deriveBits'], - length: function (len) { - return len || random.item([256, 384, 512]) - }, - alg: function (len) { - return utils.common.mockup(`{ - name: 'ECDSA', - namedCurve: 'P-${this.length(len)}' - }`) - }, - jwk: function () { - return {} - }, - generateKey: function () { - return this.alg() - }, - importKey: function () { - return this.alg() - }, - deriveKey: function (key) { - return utils.common.mockup(`{ - name: 'ECDSA', - namedCurve: 'P-${this.length()}', - ${key} - }`) - }, - deriveBits: function (key) { - return utils.common.mockup(`{ - name: 'ECDSA', - namedCurve: 'P-${this.length()}', - ${key} - }`) - }, - presets: { - raw: {}, - jwk: [ - { - kty: 'EC', - crv: 'P-256', - x: 'kgR_PqO07L8sZOBbw6rvv7O_f7clqDeiE3WnMkb5EoI', - y: 'djI-XqCqSyO9GFk_QT_stROMCAROIvU8KOORBgQUemE', - ext: true - }, - { - kty: 'EC', - crv: 'P-256', - x: 'kgR_PqO07L8sZOBbw6rvv7O_f7clqDeiE3WnMkb5EoI', - y: 'djI-XqCqSyO9GFk_QT_stROMCAROIvU8KOORBgQUemE', - d: '5aPFSt0UFVXYGu-ZKyC9FQIUOAMmnjzdIwkxCMe3Iok', - ext: true - } - ], - spki: 'new Uint8Array([48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7, 3, 66, 0, 4, 146, 4, 127, 62, 163, 180, 236, 191, 44, 100, 224, 91, 195, 170, 239, 191, 179, 191, 127, 183, 37, 168, 55, 162, 19, 117, 167, 50, 70, 249, 18, 130, 118, 50, 62, 94, 160, 170, 75, 35, 189, 24, 89, 63, 65, 63, 236, 181, 19, 140, 8, 4, 78, 34, 245, 60, 40, 227, 145, 6, 4, 20, 122, 97])', - pkcs8: 'new Uint8Array([48, 129, 135, 2, 1, 0, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7, 4, 109, 48, 107, 2, 1, 1, 4, 32, 229, 163, 197, 74, 221, 20, 21, 85, 216, 26, 239, 153, 43, 32, 189, 21, 2, 20, 56, 3, 38, 158, 60, 221, 35, 9, 49, 8, 199, 183, 34, 137, 161, 68, 3, 66, 0, 4, 146, 4, 127, 62, 163, 180, 236, 191, 44, 100, 224, 91, 195, 170, 239, 191, 179, 191, 127, 183, 37, 168, 55, 162, 19, 117, 167, 50, 70, 249, 18, 130, 118, 50, 62, 94, 160, 170, 75, 35, 189, 24, 89, 63, 65, 63, 236, 181, 19, 140, 8, 4, 78, 34, 245, 60, 40, 227, 145, 6, 4, 20, 122, 97])' - } - }, - 'AES-CTR': { - // AES in Counter Mode. - keyUsages: ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey'], - length: function (len) { - return len || random.item([128, 192, 256]) - }, - alg: function (len) { - return utils.common.mockup(`{ - name: 'AES-CTR', - length: '${this.length(len)}' - }`) - }, - jwk: function (len) { - return utils.common.mockup(`{ - kty: 'oct', - alg: 'A${this.length(len)}CTR' - }`) - }, - generateKey: function () { - return this.alg() - }, - importKey: function () { - return this.alg() - }, - encrypt: function () { - return utils.common.mockup(`{ - name: 'AES-CTR', - length: ${this.length()}, - counter: new Uint8Array(16) - }`) - }, - decrypt: function () { - return this.encrypt() - }, - wrapKey: function () { - return this.encrypt() - }, - unwrapKey: function () { - return this.encrypt() - }, - presets: { - raw: 'new Uint8Array([122, 94, 39, 230, 46, 23, 151, 80, 131, 230, 3, 101, 80, 234, 143, 9, 251, 152, 229, 228, 89, 222, 31, 135, 214, 104, 55, 68, 67, 59, 5, 51])', - jwk: [ - { - kty: 'oct', - k: 'Y0zt37HgOx-BY7SQjYVmrqhPkO44Ii2Jcb9yydUDPfE', - alg: 'A256CTR', - ext: true - } - ], - spki: {}, - pkcs8: {} - } - }, - 'AES-CBC': { - // AES in Cipher Block Chaining mode. - keyUsages: ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey'], - length: function (len) { - return len || random.item([128, 192, 256]) - }, - alg: function (len) { - return utils.common.mockup(`{ - name: 'AES-CBC', - length: ${this.length(len)} - }`) - }, - jwk: function (len) { - return utils.common.mockup(`{ - kty: 'oct', - alg: 'A${this.length(len)}CBC' - }`) - }, - generateKey: function () { - return this.alg() - }, - importKey: function () { - return this.alg() - }, - encrypt: function () { - return utils.common.mockup(`{ - name: 'AES-CBC', - length: ${this.length()}, - iv: crypto.getRandomValues(new Uint8Array(16)) - }`) - }, - decrypt: function () { - return this.encrypt() - }, - wrapKey: function () { - return this.encrypt() - }, - unwrapKey: function () { - return this.encrypt() - }, - presets: { - raw: 'new Uint8Array([122, 94, 39, 230, 46, 23, 151, 80, 131, 230, 3, 101, 80, 234, 143, 9, 251, 152, 229, 228, 89, 222, 31, 135, 214, 104, 55, 68, 67, 59, 5, 51])', - jwk: [ - { - kty: 'oct', - k: 'KfKY5nueRX7eBrOddn9IerHLv1r-T7qpggaCF3MfSR4', - alg: 'A256CBC', - ext: true - } - ], - spki: {}, - pkcs8: {} - } - }, - 'AES-GCM': { - // AES in Galois/Counter Mode. - keyUsages: ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey'], - length: function (len) { - return len || random.item([128, 192, 256]) - }, - alg: function (len) { - return utils.common.mockup(`{ - name: 'AES-GCM', - length: ${this.length(len)} - }`) - }, - jwk: function (len) { - if (random.chance(4)) { - return utils.common.mockup(`{ - kty: 'oct', - alg: 'A${this.length(len)}GCMKW' - }`) - } else { - return utils.common.mockup(`{ - kty: 'oct', - alg: 'A${this.length(len)}GCM' - }`) - } - }, - generateKey: function () { - return this.alg() - }, - importKey: function () { - return this.alg() - }, - encrypt: function () { - return utils.common.mockup(`{ - name: 'AES-GCM', - iv: crypto.getRandomValues(new Uint8Array(12)), - additionalData: crypto.getRandomValues(new Uint8Array(256)), - tagLength: ${random.item([32, 64, 96, 104, 112, 120, 128])} - }`) - }, - decrypt: function () { - return this.encrypt() - }, - wrapKey: function () { - return utils.common.mockup(`{ - name: 'AES-GCM', - iv: crypto.getRandomValues(new Uint8Array(16)) - }`) - }, - unwrapKey: function () { - return this.wrapKey() - }, - presets: { - raw: 'new Uint8Array([122, 94, 39, 230, 46, 23, 151, 80, 131, 230, 3, 101, 80, 234, 143, 9, 251, 152, 229, 228, 89, 222, 31, 135, 214, 104, 55, 68, 67, 59, 5, 51])', - jwk: [ - { - kty: 'oct', - k: 'KfKY5nueRX7eBrOddn9IerHLv1r-T7qpggaCF3MfSR4', - alg: 'A256GCM', - ext: true - } - ], - spki: {}, - pkcs8: {} - } - }, - 'AES-KW': { - // Key wrapping in AES algorithm. - keyUsages: ['wrapKey', 'unwrapKey'], - length: function (len) { - return len || random.item([128, 192, 256]) - }, - alg: function (len) { - return utils.common.mockup(`{ - name: 'AES-KW', - length: ${this.length(len)} - }`) - }, - jwk: function (len) { - return utils.common.mockup(`{ - kty: 'oct', - alg: 'A${this.length(len)}KW' - }`) - }, - generateKey: function () { - return this.alg() - }, - importKey: function () { - return this.alg() - }, - wrapKey: function () { - return utils.common.mockup(`{ - name: 'AES-KW' - }`) - }, - unwrapKey: function () { - return this.wrapKey() - }, - presets: { - raw: 'new Uint8Array([122, 94, 39, 230, 46, 23, 151, 80, 131, 230, 3, 101, 80, 234, 143, 9, 251, 152, 229, 228, 89, 222, 31, 135, 214, 104, 55, 68, 67, 59, 5, 51])', - jwk: [ - { - kty: 'oct', - k: 'KfKY5nueRX7eBrOddn9IerHLv1r-T7qpggaCF3MfSR4', - alg: 'A256KW', - ext: true - } - ], - spki: {}, - pkcs8: {} - } - }, - 'HMAC': { - // Hash-based message authentication method using SHA hash functions. - keyUsages: ['sign', 'verify'], - length: function (len) { - return len || random.item([1, 256, 384, 512]) - }, - alg: function (len) { - return utils.common.mockup(`{ - name: 'HMAC', - hash: { - name: 'SHA-${this.length(len)}' - } - }`) - }, - jwk: function (len) { - return utils.common.mockup(`{ - kty: 'oct', - alg: 'HS${this.length(len)}' - }`) - }, - generateKey: function () { - return this.alg() - }, - importKey: function () { - return this.alg() - }, - sign: function () { - return this.alg() - }, - verify: function () { - return this.alg() - }, - presets: { - raw: 'new Uint8Array([122, 94, 39, 230, 46, 23, 151, 80, 131, 230, 3, 101, 80, 234, 143, 9, 251, 152, 229, 228, 89, 222, 31, 135, 214, 104, 55, 68, 67, 59, 5, 51])', - jwk: { - kty: 'oct', - k: 'KfKY5nueRX7eBrOddn9IerHLv1r-T7qpggaCF3MfSR4', - alg: 'HS256', - ext: true - }, - spki: {}, - pkcs8: {} - } - }, - 'HKDF': { - // Key derivation using the extraction-then-expansion approach and using the SHA hash functions. - keyUsages: ['deriveKey', 'deriveBits'], - alg: function () { - return utils.common.mockup(`{ - name: 'HKDF' - }`) - }, - jwk: function () { - return utils.common.mockup(`{}`) - }, - generateKey: function () { - return this.alg() - }, - importKey: function () { - return this.alg() - }, - deriveBits: function () { - return utils.common.mockup(`{ - name: 'HKDF', - hash: { - name: '${make.crypto.randomDigestName()}' - }, - salt: crypto.getRandomValues(new Uint8Array(16)), - info: crypto.getRandomValues(new Uint8Array(16)) - }`) - }, - deriveKey: function () { - return this.deriveBits() - }, - presets: { - raw: 'crypto.getRandomValues(new Uint8Array(16))', - jwk: {}, - spki: {}, - pkcs8: {} - } - }, - 'PBKDF2': { - // Key derivation using the PKCS#5 password-based key derivation function v2.0. - keyUsages: ['deriveKey', 'deriveBits'], - alg: function () { - return utils.common.mockup(`{ - name: 'PBKDF2' - }`) - }, - jwk: function () { - return utils.common.mockup(`{}`) - }, - generateKey: function () { - return this.alg() - }, - importKey: function () { - return this.alg() - }, - deriveBits: function () { - return utils.common.mockup(`{ - name: 'PBKDF2', - hash: { - name: '${make.crypto.randomDigestName()}' - }, - salt: crypto.getRandomValues(new Uint8Array(16)), - iterations: ${random.number(1000)} - }`) - }, - deriveKey: function () { - return this.deriveBits() - }, - presets: { - raw: 'crypto.getRandomValues(new Uint8Array(16))', - jwk: {}, - spki: {}, - pkcs8: {} - } - }, - 'DH': { - keyUsages: ['deriveKey', 'deriveBits'], - alg: function () { - return utils.common.mockup(`{ - name: 'DH' - }`) - }, - jwk: function () { - return utils.common.mockup(`{}`) - }, - generateKey: function () { - return utils.common.mockup(`{ - name: 'DH', - prime: new Uint8Array([255, 255, 255, 255, 255, 255, 255, 255, 201, 15, 218, 162, 33, 104, 194, 52, 196, 198, 98, 139, 128, 220, 28, 209, 41, 2, 78, 8, 138, 103, 204, 116, 2, 11, 190, 166, 59, 19, 155, 34, 81, 74, 8, 121, 142, 52, 4, 221, 239, 149, 25, 179, 205, 58, 67, 27, 48, 43, 10, 109, 242, 95, 20, 55, 79, 225, 53, 109, 109, 81, 194, 69, 228, 133, 181, 118, 98, 94, 126, 198, 244, 76, 66, 233, 166, 55, 237, 107, 11, 255, 92, 182, 244, 6, 183, 237, 238, 56, 107, 251, 90, 137, 159, 165, 174, 159, 36, 17, 124, 75, 31, 230, 73, 40, 102, 81, 236, 228, 91, 61, 194, 0, 124, 184, 161, 99, 191, 5, 152, 218, 72, 54, 28, 85, 211, 154, 105, 22, 63, 168, 253, 36, 207, 95, 131, 101, 93, 35, 220, 163, 173, 150, 28, 98, 243, 86, 32, 133, 82, 187, 158, 213, 41, 7, 112, 150, 150, 109, 103, 12, 53, 78, 74, 188, 152, 4, 241, 116, 108, 8, 202, 35, 115, 39, 255, 255, 255, 255, 255, 255, 255, 255]), - generator: new Uint8Array([2]) - }`) - }, - importKey: function () { - return this.generateKey() - }, - deriveKey: function (key) { - // return Object.assign(this.generateKey(),key) - return utils.common.mockup(` - name: 'DH', - prime: new Uint8Array([255, 255, 255, 255, 255, 255, 255, 255, 201, 15, 218, 162, 33, 104, 194, 52, 196, 198, 98, 139, 128, 220, 28, 209, 41, 2, 78, 8, 138, 103, 204, 116, 2, 11, 190, 166, 59, 19, 155, 34, 81, 74, 8, 121, 142, 52, 4, 221, 239, 149, 25, 179, 205, 58, 67, 27, 48, 43, 10, 109, 242, 95, 20, 55, 79, 225, 53, 109, 109, 81, 194, 69, 228, 133, 181, 118, 98, 94, 126, 198, 244, 76, 66, 233, 166, 55, 237, 107, 11, 255, 92, 182, 244, 6, 183, 237, 238, 56, 107, 251, 90, 137, 159, 165, 174, 159, 36, 17, 124, 75, 31, 230, 73, 40, 102, 81, 236, 228, 91, 61, 194, 0, 124, 184, 161, 99, 191, 5, 152, 218, 72, 54, 28, 85, 211, 154, 105, 22, 63, 168, 253, 36, 207, 95, 131, 101, 93, 35, 220, 163, 173, 150, 28, 98, 243, 86, 32, 133, 82, 187, 158, 213, 41, 7, 112, 150, 150, 109, 103, 12, 53, 78, 74, 188, 152, 4, 241, 116, 108, 8, 202, 35, 115, 39, 255, 255, 255, 255, 255, 255, 255, 255]), - generator: new Uint8Array([2]), - ${key} - `) - }, - deriveBits: function (key) { - return utils.common.mockup(` - name: 'DH', - prime: new Uint8Array([255, 255, 255, 255, 255, 255, 255, 255, 201, 15, 218, 162, 33, 104, 194, 52, 196, 198, 98, 139, 128, 220, 28, 209, 41, 2, 78, 8, 138, 103, 204, 116, 2, 11, 190, 166, 59, 19, 155, 34, 81, 74, 8, 121, 142, 52, 4, 221, 239, 149, 25, 179, 205, 58, 67, 27, 48, 43, 10, 109, 242, 95, 20, 55, 79, 225, 53, 109, 109, 81, 194, 69, 228, 133, 181, 118, 98, 94, 126, 198, 244, 76, 66, 233, 166, 55, 237, 107, 11, 255, 92, 182, 244, 6, 183, 237, 238, 56, 107, 251, 90, 137, 159, 165, 174, 159, 36, 17, 124, 75, 31, 230, 73, 40, 102, 81, 236, 228, 91, 61, 194, 0, 124, 184, 161, 99, 191, 5, 152, 218, 72, 54, 28, 85, 211, 154, 105, 22, 63, 168, 253, 36, 207, 95, 131, 101, 93, 35, 220, 163, 173, 150, 28, 98, 243, 86, 32, 133, 82, 187, 158, 213, 41, 7, 112, 150, 150, 109, 103, 12, 53, 78, 74, 188, 152, 4, 241, 116, 108, 8, 202, 35, 115, 39, 255, 255, 255, 255, 255, 255, 255, 255]), - generator: new Uint8Array([2]), - ${key} - `) - }, - presets: { - raw: {}, - jwk: {}, - spki: {}, - pkcs8: {} - } - } - }, - supportedAlgorithms: () => Object.keys(make.crypto.algorithms), - randomAlgorithm: () => { - return make.crypto.algorithms[random.item(Object.keys(make.crypto.algorithms))] - }, - randomCandidate: (operation) => { - // Find and return a random algorithm suitable for a given operation. - return make.crypto.algorithms[make.crypto.randomAlgorithmName(operation)] - } -} - - -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -make.network = { - sdp () { - // session description protocol template - return [ - 'v=0', - 'o=Mozilla-SIPUA 23597 0 IN IP4 0.0.0.0', - 's=SIP Call', - 't=0 0', - 'a=ice-ufrag:f5fda439', - 'a=ice-pwd:d0df8e2904bdbd29587966e797655970', - 'a=fingerprint:sha-256 DF:69:78:20:8D:2E:08:CE:49:82:A3:11:79:1D:BF:B5:49:49:2D:32:82:2F:0D:88:84:A7:C6:63:23:63:A9:0F', - 'm=audio 52757 RTP/SAVPF 109 0 8 101', - 'c=IN IP4 192.168.129.33', - 'a=rtpmap:109 opus/48000/2', - 'a=ptime:20', - 'a=rtpmap:0 PCMU/8000', - 'a=rtpmap:8 PCMA/8000', - 'a=rtpmap:101 telephone-event/8000', - 'a=fmtp:101 0-15', - 'a=sendrecv', - 'a=candidate:0 1 UDP 2113601791 192.168.129.33 52757 typ host', - 'a=candidate:0 2 UDP 2113601790 192.168.129.33 59738 typ host', - 'm=video 63901 RTP/SAVPF 120', - 'c=IN IP4 192.168.129.33', - 'a=rtpmap:120 VP8/90000', - 'a=sendrecv', - 'a=candidate:0 1 UDP 2113601791 192.168.129.33 63901 typ host', - 'a=candidate:0 2 UDP 2113601790 192.168.129.33 54165 typ host', - 'm=application 65080 SCTP/DTLS 5000', - 'c=IN IP4 192.168.129.33', - 'a=fmtp:5000 protocol=webrtc-datachannel;streams=16', - 'a=sendrecv', - 'a=candidate:0 1 UDP 2113601791 192.168.129.33 65080 typ host', - 'a=candidate:0 2 UDP 2113601790 192.168.129.33 62658 typ host' - ].join('\n') - }, - IceCandidate () { - // https://tools.ietf.org/html/rfc5245#section-15 - // candidate= - return utils.block.block([ - random.pick([0, 1, make.number.any]), - ' ', - random.pick([0, 1, make.number.any]), - ' ', - random.pick(['UDP', 'TCP', 'SCTP']), - random.pick(['', '/' + random.pick(['DTLS', 'DTLS-SRTP'])]), - ' ', - random.pick([make.number.any]), - ' ', - random.pick([make.network.goodHostnames]), - ' ', - random.pick([56187, make.number.any]), - ' ', - 'type', - ' ', - random.pick([ - 'host', - utils.block.block([ - random.pick(['srflx', 'prflx', 'relay']), - ' ', - random.pick(['raddr']), - ' ', - random.pick([make.network.goodHostnames]), - ' ', - random.pick(['rport']), - random.use([utils.block.block([' ', make.number.any])]) - ]) - ]) - ]) - }, - SdpMid () { - // m= - return utils.block.block([ - random.pick(['application', 'video', 'audio']), - ' ', - make.number.any, - ' ', - random.pick(['RTP/AVP', 'RTP/SAVPF', 'RTP/SAVP', 'SCTP/DTLS']), - ' ', - make.number.any - ]) - }, - Turn () { - // https://tools.ietf.org/html/rfc7065#section-3.1 - return utils.block.block([ - // scheme - random.pick(make.network.PeerConnectionProtocols), - ':', - // turn-host - random.pick([ - make.text.any, - make.network.hostname - ]), - // turn-port - random.use([utils.block.block([':', make.number.any])]), - random.use([utils.block.block(['/', make.text.any])]), - '?', - random.pick(['transport']), - '=', - random.pick(['udp', 'tcp', make.text.any]) - ]) - }, - PeerConnectionProtocols () { - return ['turn', 'turns', 'stun', 'stuns'] - }, - randomIPv4 () { - return random.pick([random.number(255), make.number.any]) + '.' + - random.pick([random.number(255), make.number.any]) + '.' + - random.pick([random.number(255), make.number.any]) + '.' + - random.pick([random.number(255), make.number.any]) - }, - randomIPv6 () { - let parts = [] - - for (let i = 0; i < 8; i++) { - parts.push(random.hex(4)) - } - - return parts.join(':') - }, - iceServer () { - return random.pick([ - 'stun:23.21.150.121' - ]) - }, - dtmf () { - return random.subset([ - '*', '#', - 'A', 'B', 'C', 'D', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' - ], make.number.range()).join('') - }, - goodHostnames () { - return [ - '0.0.0.0', - '127.0.0.1:8080' - ] - }, - badHostnames () { - return [ - 'google.org:8080', - '::1', - '[::192.9.5.5]:42', - '2001:db8:85a3::8a2e:370:3478', - '2001:db8:85a3:0:0:8a2e:370:3478', - '::ffff:192.0.2.1', - '0000:0000:0000:0000:0000:0000:0000:0001', - '::192.0.2.128', - '::ffff:192.0.2.128', - '2001:db8::1:2', - '2001:db8::1:1:1:1:1' - ] - }, - hostname () { - return random.pick([ - this.randomIPv4, - this.randomIPv6, - this.goodHostnames, - this.badHostnames - ]) - }, - port () { - return random.pick([80, 443, 21, 23, 9310]) - }, - hash () { - return random.pick([ - '', - '#', - '#main-content', - () => '#' + make.text.any() - ]) - }, - path () { - return random.pick([ - '', - '/', - '/index.html', - () => '/' + make.text.any() - ]) - }, - protocol () { - return random.pick([ - 'http', - 'https', - 'ftp', - 'telnet', - 'chrome', - 'resource' - ]) + ':' - }, - search () { - return random.pick([ - '', - '?', - '?foo=bar', - () => '?' + make.text.any() - ]) - }, - randomBitmask (list) { - if (list.length <= 1) { - return list.join('') - } - let max = random.range(2, list.length) - let mask = random.pick(list) - for (let i = 1; i < max; i++) { - mask += '|' + random.pick(list) - } - return mask - } -} - - -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -make.text = { - lineEnd: function () { - return random.pick([ - '\n', '\r', '\r\n', '\n\r' - ]) - }, - controlChar: function () { - return random.pick([ - '\b', '\t', '\n', '\v', '\f', '\r', '\0', '\c', '\a', '\e' // eslint-disable-line no-useless-escape - ]) - }, - token: function () { - return random.pick([ - '*', '+', '%', '-', '!', '^', ':', '|', '&', '<', '>', '.', '"', - '#', ' ', ';', ',', '{', '}', '(', ')', '[', ']', '/', '\\', '/*', '*/' - ]) - }, - charset: function () { - return random.pick([ - 'UTF-8', 'ISO-8859-1' - ]) - }, - language: function () { - return random.pick([ - // special casing for i, I, dotted/dotless variants - ['tr', 'az'], - // special casing rules: https://developer.mozilla.org/en/CSS/text-transform - ['nl', 'gr'], - // special justification rules - ['ja', 'zh'], - // tend to be RTL - ['ar', 'he'], - // http://mxr.mozilla.org/mozilla-central/source/gfx/thebes/gfxAtomList.h - ['en', 'x-unicode', 'x-western', 'ja', 'ko', 'zh-cn', 'zh-hk', 'zh-tw', 'x-cyrillic', 'el', 'tr', 'he', 'ar', 'x-baltic', 'th', 'x-devanagari', 'x-tamil', 'x-armn', 'x-beng', 'x-cans', 'x-ethi', 'x-geor', 'x-gujr', 'x-guru', 'x-khmr', 'x-knda', 'x-mlym', 'x-orya', 'x-sinh', 'x-telu', 'x-tibt', 'ko-xxx', 'x-central-euro', 'x-symbol', 'x-user-def', 'az', 'ba', 'crh', 'tt'], - // Seen in mxr - ['en-US', 'fr', 'fra', 'de', 'ru', 'en-us', 'is-IS', 'xyzzy'] - ]) - }, - layoutCharCodes: function () { - return random.pick([ - 0, // null - 160, // non-breaking space - 0x005C, // backslash, but in some countries, represents local currency symbol (e.g. yen) - 0x00AD, // soft hyphen - 0x0BCC, // a Tamil character that is displayed as three glyphs - // http://unicode.org/charts/PDF/U2000.pdf - 0x200B, // zero-width space - 0x200C, // zero-width non-joiner - 0x200D, // zero-width joiner - 0x200E, // left-to-right mark - 0x200F, // right-to-left mark - 0x2011, // non-breaking hyphen - 0x2027, // hyphenation point - 0x2028, // line separator - 0x2029, // paragraph separator - 0x202A, // left-to-right embedding - 0x202B, // right-to-left embedding - 0x202C, // pop directional formatting - 0x202D, // left-to-right override - 0x202E, // right-to-left override - 0x202F, // narrow no-break space - 0x2060, // word joiner - 0x2061, // function application (one of several invisible mathematical operators) - // http://unicode.org/charts/PDF/U3000.pdf - 0x3000, // ideographic space (CJK) - // http://unicode.org/charts/PDF/U0300.pdf - 0x0301, // combining acute accent (if it appears after "a", it turns into "a" with an accent) - // Arabic has the interesting property that most letters connect to the next letter. - // Some code calls this "shaping". - 0x0643, // arabic letter kaf - 0x0645, // arabic letter meem - 0x06CD, // arabic letter yeh with tail - 0xFDDE, // invalid unicode? but somehow associated with arabic. - // http://unicode.org/reports/tr36/tr36-7.html#Buffer_Overflows - // Characters with especially high expansion factors when they go through various unicode "normalizations" - 0x1F82, - 0xFDFA, - 0xFB2C, - 0x0390, - // 0x1D160, // hmm, need surrogates - // Characters with especially high expansion factors when lowercased or uppercased - 0x023A, - 0x0041, - 0xDC1D, // a low surrogate - 0xDB00, // a high surrogate - // UFFF0.pdf - 0xFFF9, // interlinear annotation anchor - 0xFFFA, // interlinear annotation seperator - 0xFFFB, // interlinear annotation terminator - 0xFFFC, // object replacement character - 0xFFFD, // replacement character - 0xFEFF, // zero width no-break space - 0xFFFF, // not a character - 0x00A0, // no-break space - 0x2426, - 0x003F, - 0x00BF, - 0xDC80, - 0xDCFF, - // http://en.wikipedia.org/wiki/Mapping_of_Unicode_characters - 0x205F, // mathematical space - 0x2061, // mathematical function application - 0x2064, // mathematical invisible separator - 0x2044 // fraction slash character - ]) - }, - bidiCharCodes: function () { - return random.pick([ - 0x0660, // START_HINDI_DIGITS - 0x0669, // END_HINDI_DIGITS - 0x066A, // START_ARABIC_SEPARATOR - 0x066B, // END_ARABIC_SEPARATOR - 0x0030, // START_ARABIC_DIGITS - 0x0039, // END_ARABIC_DIGITS - 0x06f0, // START_FARSI_DIGITS - 0x06f9 // END_FARSI_DIGITS - ]) - }, - // http://www.unicode.org/Public/6.0.0/ucd/UnicodeData.txt - unicodeCombiningCharacters: function () { - return random.item([ - [0x0300, 0x036F], // Combining Diacritical Marks - [0x0483, 0x0489], - [0x07EB, 0x07F3], - [0x135D, 0x135F], - [0x1A7F, 0x1A7F], - [0x1B6B, 0x1B73], - [0x1DC0, 0x1DFF], // Combining Diacritical Marks Supplement - [0x20D0, 0x2DFF], - [0x3099, 0x309A], - [0xA66F, 0xA6F1], - [0xA8E0, 0xA8F1], - [0xFE20, 0xFE26], // Combining Half Marks - [0x101FD, 0x101FD], - [0x1D165, 0x1D169], - [0x1D16D, 0x1D172], - [0x1D17B, 0x1D18B], - [0x1D1AA, 0x1D1AD], - [0x1D242, 0x1D244] - ]) - }, - unicodeBMP: function () { - return random.item([ - // BMP = Basic Multilingual Plane - [0x0000, 0xFFFF] - ]) - }, - unicodeSMP: function () { - return random.item([ - // SMP = Supplementary Multilingual Plane - [0x10000, 0x13FFF], - [0x16000, 0x16FFF], - [0x1B000, 0x1BFFF], - [0x1D000, 0x1DFFF], - [0x1F000, 0x1FFFF] - ]) - }, - unicodeSIP: function () { - return random.item([ - // SIP = Supplementary Ideographic Plane - [0x20000, 0x2BFFF], - [0x2F000, 0x2FFFF] - ]) - }, - unicodeSSP: function () { - return random.item([ - // SSP = Supplementary Special-purpose Plane - [0xE0000, 0xE0FFF] - ]) - }, - assignmentOperator: function () { - return random.pick([ - '=', '+=', '-=', '*=', '/=', '%=', '**=', '<<=', '>>=', '>>>=', '&=', '^=', '|=' - ]) - }, - arithmeticOperator: function () { - return random.pick([ - '%', '-', '+', '*', '/' - ]) - }, - currency: function () { - return random.pick([ - // https://en.wikipedia.org/wiki/ISO_4217 - 'USD', 'USS', 'USN', 'EUR', 'CHF', 'GBP', 'XAG', 'XBA', 'XBB', 'XBC', - 'XBD', 'XSU', 'XTS', 'XXX' - ]) - }, - fromBlocks: function (set, maxlen) { - let s = '' - - for (let i = 0; i < random.number(maxlen || 255); i++) { - s += random.pick(set) - } - - return s - }, - quotedString: function () { - return utils.common.quote(make.text.any()) - }, - chars: function () { - return random.pick([ - make.text.controlChar, - make.text.token, - make.text.assignmentOperator, - make.text.arithmeticOperator, - String.fromCharCode(make.text.layoutCharCodes()), - String.fromCharCode(make.text.bidiCharCodes()) - ]) - }, - any: function () { - // Generate a string compromised of random individual characters - // This might be too slow to used for all 'texts' uses - let s = '' - // TODO: Len calculation take from DOMFuzz - maybe we should revise this? - let len = random.pick([make.number.tiny, make.number.range]) - for (let i = 0; i < len; i++) { - s += make.text.chars() - } - return s - } -} - - -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -make.uri = { - problematic: function () { - return random.item([ - 'aim:yaz', // Often triggers an 'external protocol request' dialog - 'foop:yaz', // Often triggers an unknown protocol - 'about:memory', // Content is not allowed to link or load - 'ws://localhost/' // WebSocket protocol - ]) - }, - - standard: function () { - return random.item([ - 'about:blank', - 'about:srcdoc', - 'about:mozilla', - 'about:rights', - 'data:text/html,', - 'data:image/png,', - 'data:', - 'javascript:5555', - 'javascript:"QQQQ' + String.fromCharCode(0) + 'UUUU"', - 'http://a.invalid/', - 'http://localhost:6/', - 'https://localhost:6/', - 'ftp://localhost:6/', - 'http://localhost:25/' - ]) - }, - - namespace: function () { - return random.item([ - 'http://www.w3.org/1999/xhtml', - 'http://www.w3.org/2000/svg', - 'http://www.w3.org/1998/Math/MathML' - ]) - }, - - any: function () { - return random.choose([ - [1, this.problematic], - [10, this.standard], - [10, this.namespace], - [10, make.files.any] - ]) - } -} diff --git a/lib/index.js b/lib/index.js new file mode 100644 index 0000000..477e633 --- /dev/null +++ b/lib/index.js @@ -0,0 +1,11 @@ +const logger = require('./logging') +const make = require('./make') +const random = require('./random') +const utils = require('./utils') + +module.exports = { + logger, + random, + make, + utils +} diff --git a/lib/logging/console.js b/lib/logging/console.js index 7888977..a8f56fe 100644 --- a/lib/logging/console.js +++ b/lib/logging/console.js @@ -2,92 +2,87 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -var websocket = null +const utils = require('../utils') -var logger = (function () { // eslint-disable-line no-unused-vars - const sep = '\n/* ### NEXT TESTCASE ############################## */' - const color = { - red: '\u{1b}[1;31m', - green: '\u{1b}[1;32m', - clear: '\u{1b}[0m' - } - if (utils.platform.isWindows) { - color.red = '' - color.green = '' - color.clear = '' - } +let websocket = null - function console (msg) { +const sep = '\n/* ### NEXT TESTCASE ############################## */' +const color = { + red: '\u{1b}[1;31m', + green: '\u{1b}[1;32m', + clear: '\u{1b}[0m' +} +if (utils.platform.name.isWindows) { + color.red = '' + color.green = '' + color.clear = '' +} + +class logger { + + static console (msg) { if (websocket) { websocket.send(msg) } if (typeof window === 'undefined') { - print(msg) // eslint-disable-line no-undef + try { + print(msg) // eslint-disable-line no-undef + } catch (e) { + console.log(msg) + } } else if (window.dump) { - window.dump(msg) + dump(msg) } else if (window.console && window.console.log) { - window.console.log(msg) + console.log(msg) } else { throw new Error('Unable to run console logger.') } } - function dump (msg) { - console(msg) + static dump (msg) { + this.console(msg) } - function dumpln (msg) { - dump(msg + '\n') + static dumpln (msg) { + this.dump(`${msg}\n`) } - function log (msg) { - dumpln('/*L*/ ' + utils.script.safely(msg)) + static log (msg) { + this.dumpln(`/*L*/ ${utils.script.safely(msg)}`) } - function info (msg) { - dumpln('/*L*/ /* ' + msg + ' */') + static info (msg) { + this.dumpln(`/*L*/ /* ${msg} */`) } - function error (msg) { - dumpln(color.red + msg + color.clear) + static error (msg) { + this.dumpln(color.red + msg + color.clear) } - function ok (msg) { // eslint-disable-line no-unused-vars - dumpln(color.green + msg + color.green) + static ok (msg) { // eslint-disable-line no-unused-vars + this.dumpln(color.green + msg + color.green) } - function JSError (msg) { - error('/* ERROR: ' + msg + ' */') + static JSError (msg) { + this.error(`/* ERROR: ${msg} */`) } - function comment (msg) { - dumpln('/*L*/ // ' + msg) + static comment (msg) { + this.dumpln(`/*L*/ // ${msg}`) } - function separator () { - dumpln(color.green + sep + color.clear) + static separator () { + this.dumpln(color.green + sep + color.clear) } - function traceback () { - error('===[ Traceback ]') + static traceback () { + this.error('===[ Traceback ] ===') try { throw new Error() } catch (e) { - dump(e.stack || e.stacktrace || '') + this.dump(e.stack || e.stacktrace || '') } - error('================') } +} - return { - console: console, - dump: dump, - log: log, - info: info, - error: error, - JSError: JSError, - dumpln: dumpln, - comment: comment, - separator: separator, - traceback: traceback - } -})() +module.exports = logger \ No newline at end of file diff --git a/lib/logging/index.js b/lib/logging/index.js new file mode 100644 index 0000000..05ab01b --- /dev/null +++ b/lib/logging/index.js @@ -0,0 +1,15 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +class logging { + constructor () { + } + + static get logger () { + // Or: const {logger} = require('./logging') + return require('./console') + } +} + +module.exports = logging diff --git a/lib/make/alignment.js b/lib/make/alignment.js index d5668f1..cd7ce20 100644 --- a/lib/make/alignment.js +++ b/lib/make/alignment.js @@ -2,17 +2,21 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -make.alignment = { - horizontal: function () { - return random.item(['left', 'right', 'justify', 'center']) - }, - vertical: function () { - return random.item(['top', 'bottom', 'middle', 'baseline']) - }, - any: function () { - return random.pick([ - this.horizontal, - this.vertical - ]) - } +const make = require('../make') +const random = require('../random') + +class alignment extends make { + static horizontal () { + return random.item(['left', 'right', 'justify', 'center']) + } + + static vertical () { + return random.item(['top', 'bottom', 'middle', 'baseline']) + } + + static any () { + return random.pick([this.horizontal, this.vertical]) + } } + +module.exports = alignment diff --git a/lib/make/arrays.js b/lib/make/arrays.js index 50a25a6..639461e 100644 --- a/lib/make/arrays.js +++ b/lib/make/arrays.js @@ -2,8 +2,11 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -make.arrays = { - filledArray: function (fn, limit) { +const make = require('../make') +const random = require('../random') + +class arrays extends make { + static filledArray (fn, limit) { let array = [] let size = limit || random.number(make.number.tiny()) + 1 @@ -17,3 +20,5 @@ make.arrays = { return array } } + +module.exports = arrays diff --git a/lib/make/colors.js b/lib/make/colors.js index 56cc05e..959b575 100644 --- a/lib/make/colors.js +++ b/lib/make/colors.js @@ -2,16 +2,19 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -make.colors = { - any: function () { - return random.pick([ - make.colors.rgb, - make.colors.hsl, - make.colors.keyword - ]) - }, +const make = require('../make') +const random = require('../random') - rgb: function () { +class colors extends make { + static any () { + return random.pick([ + this.rgb, + this.hsl, + this.keyword + ]) + } + + static rgb () { let values switch (random.number(4)) { @@ -36,9 +39,9 @@ make.colors = { // 8 char hex return '#' + random.hex(8) } - }, + } - hsl: function () { + static hsl () { let values, opt switch (random.number(4)) { @@ -56,9 +59,9 @@ make.colors = { values = [random.number(255), '%' + random.number(255), '%' + random.number(255), random.float()] return 'hsl(' + values.join(',') + ')' } - }, + } - keyword: function () { + static keyword () { return random.pick([ 'lime', 'red', 'blue', 'invert', 'currentColor', 'ActiveBorder', 'ActiveCaption', 'AppWorkspace', 'Background', 'ButtonFace', 'ButtonHighlight', 'ButtonShadow', @@ -83,3 +86,5 @@ make.colors = { ]) } } + +module.exports = colors diff --git a/lib/make/command.js b/lib/make/command.js index c75cda6..2648747 100644 --- a/lib/make/command.js +++ b/lib/make/command.js @@ -2,59 +2,68 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -make.command = { - _data: { - 'backcolor': function () { return make.colors.any() }, - 'bold': null, - 'contentReadOnly': function () { return random.bool() }, - 'copy': null, - 'createlink': function () { return make.uri.any() }, - 'cut': null, - 'decreasefontsize': null, - 'delete': null, - 'enableInlineTableEditing': function () { return random.bool() }, - 'enableObjectResizing': function () { return random.bool() }, - 'fontname': function () { return make.font.family() }, - 'fontsize': function () { return make.font.relativeSize() }, - 'formatblock': ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ol', 'ul', 'pre', 'address', 'blockquote', 'dl', 'div'], - 'forwarddelete': null, - 'forecolor': function () { return make.colors.any() }, - 'gethtml': null, - 'heading': null, - 'hilitecolor': function () { return make.colors.any() }, - 'increasefontsize': null, - 'indent': null, - 'insertBrOnReturn': function () { return random.bool() }, - 'inserthorizontalrule': null, - // 'inserthtml': function () { }, - 'insertlinebreak': null, - 'insertimage': function () { return make.uri.any() }, - 'insertorderedlist': null, - 'insertparagraph': null, - 'inserttext': function () { return make.text.any() }, - 'insertunorderedlist': null, - 'italic': null, - 'justifycenter': null, - 'justifyfull': null, - 'justifyleft': null, - 'justifyright': null, - 'outdent': null, - 'paste': null, - 'redo': null, - 'removeformat': null, - 'selectall': null, - 'strikethrough': null, - 'styleWithCSS': function () { return random.bool() }, - 'subscript': null, - 'superscript': null, - 'underline': null, - 'undo': null, - 'unlink': null - }, - name: function () { - return random.item(Object.keys(this._data)) - }, - value: function (name) { - return random.pick(this._data[name]) +const make = require('../make') +const random = require('../random') + +class command extends make { + static data () { + return { + 'backcolor': () => make.colors.any(), + 'bold': null, + 'contentReadOnly': () => random.bool(), + 'copy': null, + 'createlink': () => make.uri.any(), + 'cut': null, + 'decreasefontsize': null, + 'delete': null, + 'enableInlineTableEditing': () => random.bool(), + 'enableObjectResizing': () => random.bool(), + 'fontname': () => make.font.family(), + 'fontsize': () => make.font.relativeSize(), + 'formatblock': ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ol', 'ul', 'pre', 'address', 'blockquote', 'dl', 'div'], + 'forwarddelete': null, + 'forecolor': () => make.colors.any(), + 'gethtml': null, + 'heading': null, + 'hilitecolor': () => make.colors.any(), + 'increasefontsize': null, + 'indent': null, + 'insertBrOnReturn': () => random.bool(), + 'inserthorizontalrule': null, + // 'inserthtml': function () { }, + 'insertlinebreak': null, + 'insertimage': () => make.uri.any(), + 'insertorderedlist': null, + 'insertparagraph': null, + 'inserttext': () => make.text.any(), + 'insertunorderedlist': null, + 'italic': null, + 'justifycenter': null, + 'justifyfull': null, + 'justifyleft': null, + 'justifyright': null, + 'outdent': null, + 'paste': null, + 'redo': null, + 'removeformat': null, + 'selectall': null, + 'strikethrough': null, + 'styleWithCSS': () => random.bool(), + 'subscript': null, + 'superscript': null, + 'underline': null, + 'undo': null, + 'unlink': null + } + } + + static name () { + return random.item(Object.keys(this.data())) + } + + static value (value) { + return random.pick(this.data()[name]) } } + +module.exports = command diff --git a/lib/make/crypto.js b/lib/make/crypto.js index d254c60..3199e2d 100644 --- a/lib/make/crypto.js +++ b/lib/make/crypto.js @@ -2,858 +2,913 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -make.crypto = { - keyFormats: [ - 'raw', - 'spki', - 'pkcs8', - 'jwk' - ], - randomKeyFormat: () => random.item(make.crypto.keyFormats), - keyTypes: [ - 'public', - 'private', - 'secret' - ], - randomKeyType: () => random.item(make.crypto.keyTypes), - keyUsages: [ - 'encrypt', - 'decrypt', - 'sign', - 'verify', - 'deriveKey', - 'deriveBits', - 'wrapKey', - 'unwrapKey' - ], - randomKeyUsage: () => random.subset(make.crypto.keyUsages), - curves: [ - 'P-256', - 'P-384', - 'P-521' - ], - randomCurve: () => random.item(make.crypto.curves), - jwkUsages: [ - 'enc', - 'sig' - ], - randomJwkUsage: () => random.subset(make.crypto.jwkUsages), - jwkKeyTypes: [ - 'oct', - 'RSA', - 'EC' - ], - randomJwkKeyType: () => random.subset(make.crypto.jwkKeyTypes), - algorithmNames: { - // https://www.w3.org/TR/WebCryptoAPI/#algorithm-overview - sign: [ - 'RSASSA-PKCS1-v1_5', - 'RSA-PSS', - 'ECDSA', - 'HMAC' - ], - verify: [ - 'RSASSA-PKCS1-v1_5', - 'RSA-PSS', - 'ECDSA', - 'HMAC' - ], - generateKey: [ - 'RSASSA-PKCS1-v1_5', - 'RSA-PSS', - 'RSA-OAEP', - 'ECDSA', - 'ECDH', - 'AES-CTR', - 'AES-CBC', - 'AES-GCM', - 'AES-KW', - 'HMAC' - ], - importKey: [ - 'RSASSA-PKCS1-v1_5', - 'RSA-PSS', - 'RSA-OAEP', - 'ECDSA', - 'ECDH', - 'AES-CTR', - 'AES-CBC', - 'AES-GCM', - 'AES-KW', - 'HMAC', - 'HKDF', - 'PBKDF2' - ], - exportKey: [ - 'RSASSA-PKCS1-v1_5', - 'RSA-PSS', - 'RSA-OAEP', - 'ECDSA', - 'ECDH', - 'AES-CTR', - 'AES-CBC', - 'AES-GCM', - 'AES-KW', - 'HMAC' - ], - encrypt: [ - 'RSA-OAEP', - 'AES-CTR', - 'AES-CBC', - 'AES-GCM' - ], - decrypt: [ - 'RSA-OAEP', - 'AES-CTR', - 'AES-CBC', - 'AES-GCM' - ], - deriveBits: [ - 'ECDH', - 'HKDF', - 'PBKDF2' - ], - deriveKey: [ - 'ECDH', - 'HKDF', - 'PBKDF2' - ], - wrapKey: [ - 'RSA-OAEP', - 'AES-CTR', - 'AES-CBC', - 'AES-GCM', - 'AES-KW' - ], - unwrapKey: [ - 'RSA-OAEP', - 'AES-CTR', - 'AES-CBC', - 'AES-GCM', - 'AES-KW' - ], - digest: [ - 'SHA-1', - 'SHA-256', - 'SHA-384', - 'SHA-512' +const make = require('../make') +const random = require('../random') + +class crypto extends make { + static get keyFormats () { + return [ + 'raw', + 'spki', + 'pkcs8', + 'jwk' ] - }, - randomAlgorithmName: (method) => random.item(make.crypto.algorithmNames[method]), - randomDigestName: () => random.item(make.crypto.algorithmNames.digest), - algorithms: { - /* (Unsupported as of 30/01/2017) - ------------------------------- - | | Firefox | Chrome | - ----------------------------- | - | AES-CMAC | x | x | - | AES-CFB | x | x | - | CONCAT | x | x | - | HKDF-CTR | x | x | - | DH | | x | - ------------------------------- - */ - 'RSASSA-PKCS1-v1_5': { - // RSASA-PKCS1_v1_5 algorithm, using a SHA hash function. - keyUsages: ['sign', 'verify'], - length: function (len) { - return len || random.item([1, 256, 384, 512]) - }, - alg: function (len) { - return utils.common.mockup(`{ - name: 'RSASSA-PKCS1-v1_5', - hash: { - name: 'SHA-${this.length(len)}' - }, - modulusLength: ${random.item([1024, 2048, 4096])}, - publicExponent: new Uint8Array([0x01, 0x00, 0x01]) - }`) - }, - jwk: function (len) { - return utils.common.mockup(`{ - kty: 'RSA', - alg: 'RS${this.length(len)}' - }`) - }, - generateKey: function () { - return this.alg() - }, - importKey: function () { - return this.alg() - }, - sign: function () { - return this.alg() - }, - verify: function () { - return this.alg() - }, - presets: { - raw: {}, - jwk: [ - { - kty: 'RSA', - e: 'AQAB', - n: 'vGO3eU16ag9zRkJ4AK8ZUZrjbtp5xWK0LyFMNT8933evJoHeczexMUzSiXaLrEFSyQZortk81zJH3y41MBO_UFDO_X0crAquNrkjZDrf9Scc5-MdxlWU2Jl7Gc4Z18AC9aNibWVmXhgvHYkEoFdLCFG-2Sq-qIyW4KFkjan05IE', - alg: 'RS256', - ext: true - }, - { - kty: 'RSA', - e: 'AQAB', - d: 'n_dIVw9MD_04lANi5KnKJPoRfxKy7cGHYLG0hU5DGpsFNfx2yH0Uz9j8uU7ZARai1iHECBxcxhpi3wbckQtjmbkCUKvs4G0gKLT9UuNHcCbh0WfvadfPPec52n4z6s4zwisbgWCNbT2L-SyHt1yuFmLAYXkg0swk3y5Bt_ilA8E', - dp: '2RNM_uiYEQMcATQaUu3AwdeJpenCPykbQHkwAylvXqlHB6W7m5XX0k-SutkbXAijmGTC-Oh8NexsLGHxOACb8Q', - dq: 'rHabkI3_XVGieLqHujpWaWe9YD03fJY0KbbQX0fIoNdNU4GcmUftzIWLSajPKKsiyfR6Xk2AEtBmBPE5qaoV6Q', - n: 'vGO3eU16ag9zRkJ4AK8ZUZrjbtp5xWK0LyFMNT8933evJoHeczexMUzSiXaLrEFSyQZortk81zJH3y41MBO_UFDO_X0crAquNrkjZDrf9Scc5-MdxlWU2Jl7Gc4Z18AC9aNibWVmXhgvHYkEoFdLCFG-2Sq-qIyW4KFkjan05IE', - p: '5Y4ynodegqC9kgGmfZeSrojGmLyYR8HIvKVEAIjjMUQjyvKWpWsXfPg67mTdqVpjSpQLQlRfES2nUvZ27KrU6Q', - q: '0hd_U9PcNpMe77nhsTgoVNgMB34cqfrfu4fPuJ-7NvvMkKIELDLy-m8qg1MBbgf2i5546A9B5Exsuj4D2Vwz2Q', - qi: 'R3CkCGVAESy_hChmDvUaLMT-R1xk6kK7RLIUQKXATPQbnDqWBMgm-vcawFVhKJ-ICJsPfmRUsv7Wt1bJ01wLGQ', - alg: 'RS256', - ext: true - } - ], - spki: 'new Uint8Array([48, 129, 159, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 3, 129, 141, 0, 48, 129, 137, 2, 129, 129, 0, 182, 93, 35, 213, 252, 204, 20, 103, 91, 238, 105, 199, 53, 114, 24, 221, 114, 210, 137, 173, 88, 76, 205, 113, 148, 148, 79, 80, 59, 208, 60, 75, 231, 248, 78, 125, 12, 30, 237, 226, 63, 146, 157, 203, 239, 60, 138, 123, 234, 50, 23, 174, 216, 33, 122, 16, 53, 246, 140, 254, 75, 246, 205, 204, 117, 204, 115, 29, 178, 102, 139, 201, 74, 177, 45, 131, 183, 166, 234, 61, 124, 75, 110, 3, 70, 202, 148, 95, 45, 228, 94, 95, 148, 2, 162, 79, 146, 137, 29, 189, 102, 75, 207, 214, 116, 58, 63, 171, 219, 27, 5, 9, 108, 16, 218, 23, 169, 43, 181, 119, 31, 172, 95, 205, 180, 18, 255, 203, 2, 3, 1, 0, 1])', - pkcs8: 'new Uint8Array([48, 130, 2, 118, 2, 1, 0, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 4, 130, 2, 96, 48, 130, 2, 92, 2, 1, 0, 2, 129, 129, 0, 217, 78, 147, 218, 221, 152, 10, 66, 75, 127, 242, 108, 182, 142, 157, 44, 93, 58, 176, 193, 135, 103, 216, 179, 69, 72, 38, 115, 144, 244, 12, 139, 0, 245, 48, 115, 204, 234, 158, 193, 231, 127, 178, 240, 244, 203, 35, 229, 203, 245, 110, 215, 199, 19, 98, 183, 164, 223, 159, 203, 128, 123, 173, 26, 12, 172, 250, 99, 254, 35, 225, 221, 39, 51, 62, 3, 139, 35, 38, 164, 71, 238, 240, 73, 139, 214, 68, 172, 204, 253, 171, 244, 14, 186, 152, 159, 225, 133, 229, 140, 99, 50, 183, 242, 217, 248, 86, 233, 20, 117, 42, 136, 55, 8, 65, 124, 244, 65, 29, 15, 194, 255, 78, 31, 189, 146, 105, 161, 2, 3, 1, 0, 1, 2, 129, 128, 26, 88, 13, 82, 166, 52, 141, 97, 214, 23, 79, 195, 96, 42, 79, 225, 149, 247, 204, 127, 217, 179, 124, 48, 215, 128, 84, 177, 3, 236, 162, 44, 163, 212, 21, 168, 164, 57, 249, 63, 22, 154, 131, 141, 244, 143, 63, 237, 214, 217, 13, 51, 249, 125, 95, 37, 86, 70, 137, 239, 184, 198, 197, 136, 62, 183, 41, 78, 118, 234, 57, 195, 161, 219, 173, 234, 61, 11, 165, 109, 209, 9, 3, 22, 186, 114, 32, 135, 147, 74, 6, 106, 190, 214, 36, 208, 32, 220, 61, 12, 41, 105, 251, 247, 18, 159, 3, 198, 28, 228, 36, 44, 189, 125, 45, 72, 233, 199, 12, 72, 91, 106, 165, 246, 217, 58, 168, 53, 2, 65, 0, 241, 112, 53, 166, 98, 11, 38, 73, 58, 156, 84, 190, 118, 74, 247, 229, 85, 178, 83, 231, 53, 137, 237, 228, 246, 12, 32, 206, 157, 198, 152, 70, 11, 185, 234, 30, 112, 23, 115, 249, 68, 176, 159, 108, 247, 249, 207, 152, 145, 166, 246, 79, 176, 219, 163, 111, 243, 4, 49, 3, 239, 242, 63, 147, 2, 65, 0, 230, 105, 200, 1, 208, 201, 237, 225, 85, 27, 39, 216, 193, 1, 253, 168, 88, 15, 242, 166, 70, 106, 235, 2, 92, 24, 130, 66, 176, 176, 220, 238, 66, 12, 159, 26, 24, 40, 19, 213, 138, 98, 238, 98, 220, 65, 148, 116, 146, 21, 0, 25, 6, 177, 57, 216, 70, 51, 149, 244, 157, 153, 106, 123, 2, 64, 127, 92, 254, 48, 67, 80, 54, 102, 50, 240, 253, 19, 108, 59, 168, 1, 230, 239, 39, 171, 180, 102, 138, 132, 89, 247, 147, 230, 234, 252, 52, 159, 222, 215, 184, 85, 78, 52, 81, 13, 145, 218, 202, 127, 37, 97, 54, 205, 249, 39, 230, 143, 171, 112, 114, 11, 64, 91, 89, 176, 6, 7, 248, 217, 2, 65, 0, 220, 94, 95, 132, 29, 4, 132, 22, 247, 38, 185, 189, 125, 27, 66, 87, 55, 162, 73, 24, 238, 80, 99, 228, 37, 224, 234, 244, 141, 185, 26, 20, 101, 231, 92, 99, 192, 166, 212, 17, 112, 1, 158, 173, 190, 170, 154, 41, 195, 109, 130, 98, 109, 28, 35, 142, 205, 213, 152, 158, 19, 253, 30, 241, 2, 64, 15, 148, 8, 16, 189, 122, 55, 109, 203, 175, 173, 24, 222, 36, 130, 130, 179, 87, 189, 32, 141, 149, 30, 115, 211, 227, 79, 234, 78, 202, 253, 48, 173, 95, 167, 203, 20, 193, 160, 30, 146, 33, 109, 4, 221, 25, 212, 216, 183, 100, 18, 46, 184, 52, 65, 146, 249, 68, 225, 10, 84, 38, 98, 133])' - } - }, - 'RSA-PSS': { - keyUsages: ['sign', 'verify'], - length: function (len) { - return len || random.item([1, 256, 384, 512]) - }, - alg: function (len) { - return utils.common.mockup(`{ - name: 'RSA-PSS', - hash: { - name: 'SHA-${this.length(len)}' - }, - modulusLength: ${random.item([1024, 2048, 4096])}, - publicExponent: new Uint8Array([0x01, 0x00, 0x01]), - saltLength: 8 - }`) - }, - jwk: function (len) { - return utils.common.mockup(`{ - kty: 'RSA', - alg: 'PS${this.length(len)}' - }`) - }, - generateKey: function () { - return this.alg() - }, - importKey: function () { - return this.alg() - }, - sign: function () { - return this.alg() - }, - verify: function () { - return this.alg() - }, - presets: { - raw: {}, - jwk: [ - { - kty: 'RSA', - e: 'AQAB', - n: 'vGO3eU16ag9zRkJ4AK8ZUZrjbtp5xWK0LyFMNT8933evJoHeczexMUzSiXaLrEFSyQZortk81zJH3y41MBO_UFDO_X0crAquNrkjZDrf9Scc5-MdxlWU2Jl7Gc4Z18AC9aNibWVmXhgvHYkEoFdLCFG-2Sq-qIyW4KFkjan05IE', - alg: 'RS256', - ext: true - }, - { - kty: 'RSA', - e: 'AQAB', - d: 'n_dIVw9MD_04lANi5KnKJPoRfxKy7cGHYLG0hU5DGpsFNfx2yH0Uz9j8uU7ZARai1iHECBxcxhpi3wbckQtjmbkCUKvs4G0gKLT9UuNHcCbh0WfvadfPPec52n4z6s4zwisbgWCNbT2L-SyHt1yuFmLAYXkg0swk3y5Bt_ilA8E', - dp: '2RNM_uiYEQMcATQaUu3AwdeJpenCPykbQHkwAylvXqlHB6W7m5XX0k-SutkbXAijmGTC-Oh8NexsLGHxOACb8Q', - dq: 'rHabkI3_XVGieLqHujpWaWe9YD03fJY0KbbQX0fIoNdNU4GcmUftzIWLSajPKKsiyfR6Xk2AEtBmBPE5qaoV6Q', - n: 'vGO3eU16ag9zRkJ4AK8ZUZrjbtp5xWK0LyFMNT8933evJoHeczexMUzSiXaLrEFSyQZortk81zJH3y41MBO_UFDO_X0crAquNrkjZDrf9Scc5-MdxlWU2Jl7Gc4Z18AC9aNibWVmXhgvHYkEoFdLCFG-2Sq-qIyW4KFkjan05IE', - p: '5Y4ynodegqC9kgGmfZeSrojGmLyYR8HIvKVEAIjjMUQjyvKWpWsXfPg67mTdqVpjSpQLQlRfES2nUvZ27KrU6Q', - q: '0hd_U9PcNpMe77nhsTgoVNgMB34cqfrfu4fPuJ-7NvvMkKIELDLy-m8qg1MBbgf2i5546A9B5Exsuj4D2Vwz2Q', - qi: 'R3CkCGVAESy_hChmDvUaLMT-R1xk6kK7RLIUQKXATPQbnDqWBMgm-vcawFVhKJ-ICJsPfmRUsv7Wt1bJ01wLGQ', - alg: 'PS256', - ext: true - } - ], - spki: 'new Uint8Array([48, 129, 159, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 3, 129, 141, 0, 48, 129, 137, 2, 129, 129, 0, 180, 31, 227, 200, 37, 227, 65, 238, 23, 91, 226, 130, 51, 32, 165, 245, 1, 24, 244, 5, 184, 42, 181, 155, 23, 142, 249, 220, 222, 131, 175, 54, 117, 135, 64, 232, 120, 90, 160, 221, 18, 31, 200, 41, 23, 174, 18, 172, 247, 166, 90, 37, 156, 229, 2, 70, 169, 165, 93, 246, 120, 117, 59, 202, 3, 102, 44, 119, 154, 54, 28, 198, 111, 39, 144, 73, 69, 251, 179, 74, 41, 215, 115, 186, 124, 200, 105, 75, 104, 158, 156, 158, 238, 214, 14, 81, 95, 130, 155, 146, 114, 125, 88, 158, 212, 44, 65, 236, 228, 194, 105, 96, 211, 155, 60, 71, 134, 90, 151, 202, 68, 20, 228, 105, 249, 202, 170, 155, 2, 3, 1, 0, 1])', - plcs8: 'new Uint8Array([48, 130, 2, 119, 2, 1, 0, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 4, 130, 2, 97, 48, 130, 2, 93, 2, 1, 0, 2, 129, 129, 0, 180, 31, 227, 200, 37, 227, 65, 238, 23, 91, 226, 130, 51, 32, 165, 245, 1, 24, 244, 5, 184, 42, 181, 155, 23, 142, 249, 220, 222, 131, 175, 54, 117, 135, 64, 232, 120, 90, 160, 221, 18, 31, 200, 41, 23, 174, 18, 172, 247, 166, 90, 37, 156, 229, 2, 70, 169, 165, 93, 246, 120, 117, 59, 202, 3, 102, 44, 119, 154, 54, 28, 198, 111, 39, 144, 73, 69, 251, 179, 74, 41, 215, 115, 186, 124, 200, 105, 75, 104, 158, 156, 158, 238, 214, 14, 81, 95, 130, 155, 146, 114, 125, 88, 158, 212, 44, 65, 236, 228, 194, 105, 96, 211, 155, 60, 71, 134, 90, 151, 202, 68, 20, 228, 105, 249, 202, 170, 155, 2, 3, 1, 0, 1, 2, 129, 128, 102, 251, 236, 161, 220, 119, 168, 148, 86, 42, 164, 192, 200, 54, 156, 108, 14, 42, 148, 42, 72, 247, 178, 73, 112, 24, 192, 230, 245, 25, 217, 45, 139, 216, 190, 213, 171, 42, 53, 218, 239, 167, 216, 43, 22, 108, 226, 36, 158, 155, 47, 227, 93, 102, 217, 252, 72, 182, 81, 152, 191, 154, 87, 137, 219, 194, 236, 53, 200, 123, 61, 10, 59, 231, 41, 18, 116, 77, 148, 50, 170, 116, 221, 110, 170, 190, 158, 108, 217, 38, 73, 84, 183, 51, 122, 179, 217, 143, 255, 87, 82, 80, 223, 188, 84, 134, 146, 150, 169, 64, 30, 168, 104, 8, 123, 162, 46, 59, 47, 232, 0, 35, 202, 42, 195, 141, 6, 1, 2, 65, 0, 237, 171, 148, 110, 241, 19, 152, 216, 206, 77, 109, 215, 21, 144, 110, 96, 34, 61, 46, 214, 148, 70, 238, 119, 206, 128, 32, 24, 136, 197, 185, 254, 209, 35, 235, 231, 122, 246, 167, 183, 117, 176, 51, 133, 169, 47, 130, 178, 40, 225, 145, 219, 48, 56, 21, 46, 198, 18, 85, 218, 194, 150, 141, 27, 2, 65, 0, 194, 4, 41, 152, 43, 246, 147, 7, 229, 244, 215, 110, 143, 7, 184, 187, 22, 166, 113, 217, 81, 52, 205, 54, 73, 202, 244, 24, 24, 219, 254, 243, 230, 230, 212, 172, 225, 218, 112, 95, 118, 103, 144, 223, 248, 164, 19, 228, 204, 204, 64, 91, 76, 77, 4, 206, 89, 173, 154, 162, 134, 113, 176, 129, 2, 64, 58, 4, 78, 97, 158, 155, 200, 13, 244, 158, 86, 23, 208, 253, 198, 211, 212, 199, 214, 173, 46, 216, 249, 209, 105, 41, 65, 172, 123, 134, 184, 214, 137, 59, 25, 149, 18, 33, 47, 227, 202, 232, 206, 74, 236, 119, 218, 145, 159, 5, 33, 83, 190, 59, 146, 128, 46, 125, 191, 83, 125, 120, 190, 205, 2, 65, 0, 134, 6, 204, 25, 20, 29, 180, 250, 90, 207, 229, 214, 185, 53, 211, 86, 98, 210, 62, 137, 170, 128, 120, 86, 205, 105, 71, 112, 50, 20, 31, 174, 171, 206, 192, 18, 97, 191, 61, 171, 164, 166, 236, 188, 220, 13, 180, 180, 117, 9, 144, 87, 193, 128, 223, 22, 17, 123, 76, 252, 131, 53, 156, 129, 2, 65, 0, 178, 29, 141, 176, 179, 203, 180, 190, 224, 34, 134, 226, 151, 73, 139, 163, 47, 17, 179, 117, 167, 200, 255, 174, 67, 114, 158, 96, 195, 176, 163, 241, 96, 24, 72, 35, 38, 18, 132, 176, 76, 235, 8, 29, 225, 138, 155, 191, 97, 158, 3, 22, 114, 133, 176, 213, 207, 120, 33, 55, 52, 135, 79, 161])' - } - }, - 'RSA-OAEP': { - // RSAES-OAEP algorithm using a SHA hash functions and a MGF1 mask generating function. - keyUsages: ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey'], - length: function (len) { - return len || random.item([1, 256, 384, 512]) - }, - alg: function (len) { - return utils.common.mockup(`{ - name: 'RSA-OAEP', - hash: { - name: 'SHA-${this.length(len)}' - }, - modulusLength: ${random.item([1024, 2048, 4096])}, - publicExponent: new Uint8Array([0x01, 0x00, 0x01]) - }`) - }, - jwk: function (len) { - return utils.common.mockup(`{ - kty: 'RSA', - alg: 'RSA-OAEP-${this.length(len)}' - }`) - }, - generateKey: function () { - return this.alg() - }, - importKey: function () { - return this.alg() - }, - encrypt: function () { - utils.common.mockup(`{ - name: 'RSA-OAEP', - hash: { - name: 'SHA-${this.length()}' - }, - modulusLength: ${random.item([1024, 2048, 4096])}, - publicExponent: new Uint8Array([0x01, 0x00, 0x01]), - label: crypto.getRandomValues(new Uint8Array(16)) - }`) - }, - decrypt: function () { - return this.alg() - }, - unwrapKey: function () { - return this.alg() - }, - wrapKey: function () { - return this.alg() - }, - presets: { - raw: {}, - jkw: [ - { - kty: 'RSA', - e: 'AQAB', - n: 'vGO3eU16ag9zRkJ4AK8ZUZrjbtp5xWK0LyFMNT8933evJoHeczexMUzSiXaLrEFSyQZortk81zJH3y41MBO_UFDO_X0crAquNrkjZDrf9Scc5-MdxlWU2Jl7Gc4Z18AC9aNibWVmXhgvHYkEoFdLCFG-2Sq-qIyW4KFkjan05IE', - alg: 'RSA-OAEP-256', - ext: true - }, - { - kty: 'RSA', - e: 'AQAB', - d: 'e-Nm1CB_F7j0p4Cb-T4WmFTh7RbxUthC3j8xnlXwHgWYwaPs9ZRkicgNCfmjEb-qJ-m0ho1Cz4WzlL1CtTKEdr2w0P6L_IQPvWkFYwUm0rpY9doxnOKkzq53dhP5zdc6N8aOLk4cmAcVjw4o_csc85H-0fxzQxsTP0_jhJn7SNE', - dp: 'JuZmXNBY9uGGfx3w3ysmFumGBLooNjMwwgMduVS6T8S-0tZkBU-iwJPzXAkKhwINEv1EnygjwmJLBdoHROeEeQ', - dq: 'KaKOFHxm9104WNwqTth04O9ogaDz_W0wkeHnxOxbWgdtFxsarnImiMlI3Hphv9JuHD5awzNAkaj9P7wDVew-5Q', - n: 'x-Do39ky8RVFrFplFfAuOQGLr-rqY3h9OiNHVMe34LoVG4Aofps11ycyw5ka3Ls_yA-oRouGmaMjaiPUoaU_Lm5-CMSoVwyeANLZ4b2S7V-srXFS-Qpe6aD7NpzoUL9knwTnZFIGZlxSXB-NXL5kq18UuO1LQGe1To16ijXKNxc', - p: '4ss3ZAQMdmOk1BRQXwM9YHAoxVDkHDnSV9u89tUb3RbPXlV3fLlhRYtZ7u3FYaTzy08s8Ty2hV1KZ7xXhKEtuQ', - q: '4Z5ejmIJTwsgxN5pI6mLxwXqQwFDERYDnwU9_vyToWXMEPAphWpS9ET00YrdHsgIGao1Slc0jp4OUxaLfhtzTw', - qi: 'R1aKNnhUiTjoCHfOVHZ6Qv5R7So-F5mtjDKCBvCi8190U3E25DiKRvDqHZ0bHMRbdQPLLknxHVnuETw6gddHUg', - alg: 'RSA-OAEP-256', - ext: true - } - ], - spki: 'new Uint8Array([48, 129, 159, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 3, 129, 141, 0, 48, 129, 137, 2, 129, 129, 0, 182, 93, 35, 213, 252, 204, 20, 103, 91, 238, 105, 199, 53, 114, 24, 221, 114, 210, 137, 173, 88, 76, 205, 113, 148, 148, 79, 80, 59, 208, 60, 75, 231, 248, 78, 125, 12, 30, 237, 226, 63, 146, 157, 203, 239, 60, 138, 123, 234, 50, 23, 174, 216, 33, 122, 16, 53, 246, 140, 254, 75, 246, 205, 204, 117, 204, 115, 29, 178, 102, 139, 201, 74, 177, 45, 131, 183, 166, 234, 61, 124, 75, 110, 3, 70, 202, 148, 95, 45, 228, 94, 95, 148, 2, 162, 79, 146, 137, 29, 189, 102, 75, 207, 214, 116, 58, 63, 171, 219, 27, 5, 9, 108, 16, 218, 23, 169, 43, 181, 119, 31, 172, 95, 205, 180, 18, 255, 203, 2, 3, 1, 0, 1])', - pkcs8: 'new Uint8Array([48, 130, 2, 118, 2, 1, 0, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 4, 130, 2, 96, 48, 130, 2, 92, 2, 1, 0, 2, 129, 129, 0, 217, 78, 147, 218, 221, 152, 10, 66, 75, 127, 242, 108, 182, 142, 157, 44, 93, 58, 176, 193, 135, 103, 216, 179, 69, 72, 38, 115, 144, 244, 12, 139, 0, 245, 48, 115, 204, 234, 158, 193, 231, 127, 178, 240, 244, 203, 35, 229, 203, 245, 110, 215, 199, 19, 98, 183, 164, 223, 159, 203, 128, 123, 173, 26, 12, 172, 250, 99, 254, 35, 225, 221, 39, 51, 62, 3, 139, 35, 38, 164, 71, 238, 240, 73, 139, 214, 68, 172, 204, 253, 171, 244, 14, 186, 152, 159, 225, 133, 229, 140, 99, 50, 183, 242, 217, 248, 86, 233, 20, 117, 42, 136, 55, 8, 65, 124, 244, 65, 29, 15, 194, 255, 78, 31, 189, 146, 105, 161, 2, 3, 1, 0, 1, 2, 129, 128, 26, 88, 13, 82, 166, 52, 141, 97, 214, 23, 79, 195, 96, 42, 79, 225, 149, 247, 204, 127, 217, 179, 124, 48, 215, 128, 84, 177, 3, 236, 162, 44, 163, 212, 21, 168, 164, 57, 249, 63, 22, 154, 131, 141, 244, 143, 63, 237, 214, 217, 13, 51, 249, 125, 95, 37, 86, 70, 137, 239, 184, 198, 197, 136, 62, 183, 41, 78, 118, 234, 57, 195, 161, 219, 173, 234, 61, 11, 165, 109, 209, 9, 3, 22, 186, 114, 32, 135, 147, 74, 6, 106, 190, 214, 36, 208, 32, 220, 61, 12, 41, 105, 251, 247, 18, 159, 3, 198, 28, 228, 36, 44, 189, 125, 45, 72, 233, 199, 12, 72, 91, 106, 165, 246, 217, 58, 168, 53, 2, 65, 0, 241, 112, 53, 166, 98, 11, 38, 73, 58, 156, 84, 190, 118, 74, 247, 229, 85, 178, 83, 231, 53, 137, 237, 228, 246, 12, 32, 206, 157, 198, 152, 70, 11, 185, 234, 30, 112, 23, 115, 249, 68, 176, 159, 108, 247, 249, 207, 152, 145, 166, 246, 79, 176, 219, 163, 111, 243, 4, 49, 3, 239, 242, 63, 147, 2, 65, 0, 230, 105, 200, 1, 208, 201, 237, 225, 85, 27, 39, 216, 193, 1, 253, 168, 88, 15, 242, 166, 70, 106, 235, 2, 92, 24, 130, 66, 176, 176, 220, 238, 66, 12, 159, 26, 24, 40, 19, 213, 138, 98, 238, 98, 220, 65, 148, 116, 146, 21, 0, 25, 6, 177, 57, 216, 70, 51, 149, 244, 157, 153, 106, 123, 2, 64, 127, 92, 254, 48, 67, 80, 54, 102, 50, 240, 253, 19, 108, 59, 168, 1, 230, 239, 39, 171, 180, 102, 138, 132, 89, 247, 147, 230, 234, 252, 52, 159, 222, 215, 184, 85, 78, 52, 81, 13, 145, 218, 202, 127, 37, 97, 54, 205, 249, 39, 230, 143, 171, 112, 114, 11, 64, 91, 89, 176, 6, 7, 248, 217, 2, 65, 0, 220, 94, 95, 132, 29, 4, 132, 22, 247, 38, 185, 189, 125, 27, 66, 87, 55, 162, 73, 24, 238, 80, 99, 228, 37, 224, 234, 244, 141, 185, 26, 20, 101, 231, 92, 99, 192, 166, 212, 17, 112, 1, 158, 173, 190, 170, 154, 41, 195, 109, 130, 98, 109, 28, 35, 142, 205, 213, 152, 158, 19, 253, 30, 241, 2, 64, 15, 148, 8, 16, 189, 122, 55, 109, 203, 175, 173, 24, 222, 36, 130, 130, 179, 87, 189, 32, 141, 149, 30, 115, 211, 227, 79, 234, 78, 202, 253, 48, 173, 95, 167, 203, 20, 193, 160, 30, 146, 33, 109, 4, 221, 25, 212, 216, 183, 100, 18, 46, 184, 52, 65, 146, 249, 68, 225, 10, 84, 38, 98, 133])' - } - }, - 'ECDSA': { - keyUsages: ['sign', 'verify'], - length: function (len) { - return len || random.item([256, 384, 512]) - }, - alg: function (len) { - len = this.length(len) - return utils.common.mockup(`{ - name: 'ECDSA', - namedCurve: 'P-${len}', - hash: { - name: 'SHA-${len}' - } - }`) - }, - jwk: function (len) { - return utils.common.mockup(`{ - kty: 'EC', - alg: 'ES${this.length(len)}' - }`) - }, - generateKey: function () { - return this.alg() - }, - importKey: function () { - return this.alg() - }, - sign: function () { - return this.alg() - }, - verify: function () { - return this.alg() - }, - presets: { - raw: {}, - jwk: [ - { - kty: 'EC', - crv: 'P-256', - x: 'A5fQnBdBSgBhTjMr1Atpzvh5SKYQ4aQRJ9WTCG5U4m4', - y: '8YF98byzMljHX3T5ORLYTDbcwG-_eq3f23JtTE6lOe0', - ext: true - }, - { - kty: 'EC', - crv: 'P-256', - x: 'A5fQnBdBSgBhTjMr1Atpzvh5SKYQ4aQRJ9WTCG5U4m4', - y: '8YF98byzMljHX3T5ORLYTDbcwG-_eq3f23JtTE6lOe0', - d: '4DvC-hxpv8myZLNeMY-8nq55MhdfA4obM1lGG3hF_yo', - ext: true - } - ], - spki: 'new Uint8Array([48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7, 3, 66, 0, 4, 3, 151, 208, 156, 23, 65, 74, 0, 97, 78, 51, 43, 212, 11, 105, 206, 248, 121, 72, 166, 16, 225, 164, 17, 39, 213, 147, 8, 110, 84, 226, 110, 241, 129, 125, 241, 188, 179, 50, 88, 199, 95, 116, 249, 57, 18, 216, 76, 54, 220, 192, 111, 191, 122, 173, 223, 219, 114, 109, 76, 78, 165, 57, 237])', - pkcs8: 'new Uint8Array([48, 129, 135, 2, 1, 0, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7, 4, 109, 48, 107, 2, 1, 1, 4, 32, 224, 59, 194, 250, 28, 105, 191, 201, 178, 100, 179, 94, 49, 143, 188, 158, 174, 121, 50, 23, 95, 3, 138, 27, 51, 89, 70, 27, 120, 69, 255, 42, 161, 68, 3, 66, 0, 4, 3, 151, 208, 156, 23, 65, 74, 0, 97, 78, 51, 43, 212, 11, 105, 206, 248, 121, 72, 166, 16, 225, 164, 17, 39, 213, 147, 8, 110, 84, 226, 110, 241, 129, 125, 241, 188, 179, 50, 88, 199, 95, 116, 249, 57, 18, 216, 76, 54, 220, 192, 111, 191, 122, 173, 223, 219, 114, 109, 76, 78, 165, 57, 237])' - } - }, - 'ECDH': { - keyUsages: ['deriveKey', 'deriveBits'], - length: function (len) { - return len || random.item([256, 384, 512]) - }, - alg: function (len) { - return utils.common.mockup(`{ - name: 'ECDSA', - namedCurve: 'P-${this.length(len)}' - }`) - }, - jwk: function () { - return {} - }, - generateKey: function () { - return this.alg() - }, - importKey: function () { - return this.alg() - }, - deriveKey: function (key) { - return utils.common.mockup(`{ - name: 'ECDSA', - namedCurve: 'P-${this.length()}', - ${key} - }`) - }, - deriveBits: function (key) { - return utils.common.mockup(`{ - name: 'ECDSA', - namedCurve: 'P-${this.length()}', - ${key} - }`) - }, - presets: { - raw: {}, - jwk: [ - { - kty: 'EC', - crv: 'P-256', - x: 'kgR_PqO07L8sZOBbw6rvv7O_f7clqDeiE3WnMkb5EoI', - y: 'djI-XqCqSyO9GFk_QT_stROMCAROIvU8KOORBgQUemE', - ext: true - }, - { - kty: 'EC', - crv: 'P-256', - x: 'kgR_PqO07L8sZOBbw6rvv7O_f7clqDeiE3WnMkb5EoI', - y: 'djI-XqCqSyO9GFk_QT_stROMCAROIvU8KOORBgQUemE', - d: '5aPFSt0UFVXYGu-ZKyC9FQIUOAMmnjzdIwkxCMe3Iok', - ext: true - } - ], - spki: 'new Uint8Array([48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7, 3, 66, 0, 4, 146, 4, 127, 62, 163, 180, 236, 191, 44, 100, 224, 91, 195, 170, 239, 191, 179, 191, 127, 183, 37, 168, 55, 162, 19, 117, 167, 50, 70, 249, 18, 130, 118, 50, 62, 94, 160, 170, 75, 35, 189, 24, 89, 63, 65, 63, 236, 181, 19, 140, 8, 4, 78, 34, 245, 60, 40, 227, 145, 6, 4, 20, 122, 97])', - pkcs8: 'new Uint8Array([48, 129, 135, 2, 1, 0, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7, 4, 109, 48, 107, 2, 1, 1, 4, 32, 229, 163, 197, 74, 221, 20, 21, 85, 216, 26, 239, 153, 43, 32, 189, 21, 2, 20, 56, 3, 38, 158, 60, 221, 35, 9, 49, 8, 199, 183, 34, 137, 161, 68, 3, 66, 0, 4, 146, 4, 127, 62, 163, 180, 236, 191, 44, 100, 224, 91, 195, 170, 239, 191, 179, 191, 127, 183, 37, 168, 55, 162, 19, 117, 167, 50, 70, 249, 18, 130, 118, 50, 62, 94, 160, 170, 75, 35, 189, 24, 89, 63, 65, 63, 236, 181, 19, 140, 8, 4, 78, 34, 245, 60, 40, 227, 145, 6, 4, 20, 122, 97])' - } - }, - 'AES-CTR': { - // AES in Counter Mode. - keyUsages: ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey'], - length: function (len) { - return len || random.item([128, 192, 256]) - }, - alg: function (len) { - return utils.common.mockup(`{ - name: 'AES-CTR', - length: '${this.length(len)}' - }`) - }, - jwk: function (len) { - return utils.common.mockup(`{ - kty: 'oct', - alg: 'A${this.length(len)}CTR' - }`) - }, - generateKey: function () { - return this.alg() - }, - importKey: function () { - return this.alg() - }, - encrypt: function () { - return utils.common.mockup(`{ - name: 'AES-CTR', - length: ${this.length()}, - counter: new Uint8Array(16) - }`) - }, - decrypt: function () { - return this.encrypt() - }, - wrapKey: function () { - return this.encrypt() - }, - unwrapKey: function () { - return this.encrypt() - }, - presets: { - raw: 'new Uint8Array([122, 94, 39, 230, 46, 23, 151, 80, 131, 230, 3, 101, 80, 234, 143, 9, 251, 152, 229, 228, 89, 222, 31, 135, 214, 104, 55, 68, 67, 59, 5, 51])', - jwk: [ - { - kty: 'oct', - k: 'Y0zt37HgOx-BY7SQjYVmrqhPkO44Ii2Jcb9yydUDPfE', - alg: 'A256CTR', - ext: true - } - ], - spki: {}, - pkcs8: {} - } - }, - 'AES-CBC': { - // AES in Cipher Block Chaining mode. - keyUsages: ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey'], - length: function (len) { - return len || random.item([128, 192, 256]) - }, - alg: function (len) { - return utils.common.mockup(`{ - name: 'AES-CBC', - length: ${this.length(len)} - }`) - }, - jwk: function (len) { - return utils.common.mockup(`{ - kty: 'oct', - alg: 'A${this.length(len)}CBC' - }`) - }, - generateKey: function () { - return this.alg() - }, - importKey: function () { - return this.alg() - }, - encrypt: function () { - return utils.common.mockup(`{ - name: 'AES-CBC', - length: ${this.length()}, - iv: crypto.getRandomValues(new Uint8Array(16)) - }`) - }, - decrypt: function () { - return this.encrypt() - }, - wrapKey: function () { - return this.encrypt() - }, - unwrapKey: function () { - return this.encrypt() - }, - presets: { - raw: 'new Uint8Array([122, 94, 39, 230, 46, 23, 151, 80, 131, 230, 3, 101, 80, 234, 143, 9, 251, 152, 229, 228, 89, 222, 31, 135, 214, 104, 55, 68, 67, 59, 5, 51])', - jwk: [ - { - kty: 'oct', - k: 'KfKY5nueRX7eBrOddn9IerHLv1r-T7qpggaCF3MfSR4', - alg: 'A256CBC', - ext: true - } - ], - spki: {}, - pkcs8: {} - } - }, - 'AES-GCM': { - // AES in Galois/Counter Mode. - keyUsages: ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey'], - length: function (len) { - return len || random.item([128, 192, 256]) - }, - alg: function (len) { - return utils.common.mockup(`{ - name: 'AES-GCM', - length: ${this.length(len)} - }`) - }, - jwk: function (len) { - if (random.chance(4)) { + } + static randomKeyFormat () { + return random.item(this.keyFormats) + } + + static get keyTypes () { + return [ + 'public', + 'private', + 'secret' + ] + } + static randomKeyType () { + return random.item(this.keyTypes) + } + + static get keyUsages () { + return [ + 'encrypt', + 'decrypt', + 'sign', + 'verify', + 'deriveKey', + 'deriveBits', + 'wrapKey', + 'unwrapKey' + ] + } + + static randomKeyUsage () { + return random.subset(this.keyUsages) + } + + static get curves () { + return [ + 'P-256', + 'P-384', + 'P-521' + ] + } + + static randomCurve (){ + return random.item(this.curves) + } + + static get jwkUsages () { + return [ + 'enc', + 'sig' + ] + } + + static randomJwkUsage () { + return random.subset(this.keyUsages) + } + + static get jwkKeyTypes () { + return [ + 'oct', + 'RSA', + 'EC' + ] + } + + static randomJwkKeyType () { + return random.subset(this.jwkKeyTypes) + } + + static get algorithmNames () { + // https://www.w3.org/TR/WebCryptoAPI/#algorithm-overview + return { + sign: [ + 'RSASSA-PKCS1-v1_5', + 'RSA-PSS', + 'ECDSA', + 'HMAC' + ], + verify: [ + 'RSASSA-PKCS1-v1_5', + 'RSA-PSS', + 'ECDSA', + 'HMAC' + ], + generateKey: [ + 'RSASSA-PKCS1-v1_5', + 'RSA-PSS', + 'RSA-OAEP', + 'ECDSA', + 'ECDH', + 'AES-CTR', + 'AES-CBC', + 'AES-GCM', + 'AES-KW', + 'HMAC' + ], + importKey: [ + 'RSASSA-PKCS1-v1_5', + 'RSA-PSS', + 'RSA-OAEP', + 'ECDSA', + 'ECDH', + 'AES-CTR', + 'AES-CBC', + 'AES-GCM', + 'AES-KW', + 'HMAC', + 'HKDF', + 'PBKDF2' + ], + exportKey: [ + 'RSASSA-PKCS1-v1_5', + 'RSA-PSS', + 'RSA-OAEP', + 'ECDSA', + 'ECDH', + 'AES-CTR', + 'AES-CBC', + 'AES-GCM', + 'AES-KW', + 'HMAC' + ], + encrypt: [ + 'RSA-OAEP', + 'AES-CTR', + 'AES-CBC', + 'AES-GCM' + ], + decrypt: [ + 'RSA-OAEP', + 'AES-CTR', + 'AES-CBC', + 'AES-GCM' + ], + deriveBits: [ + 'ECDH', + 'HKDF', + 'PBKDF2' + ], + deriveKey: [ + 'ECDH', + 'HKDF', + 'PBKDF2' + ], + wrapKey: [ + 'RSA-OAEP', + 'AES-CTR', + 'AES-CBC', + 'AES-GCM', + 'AES-KW' + ], + unwrapKey: [ + 'RSA-OAEP', + 'AES-CTR', + 'AES-CBC', + 'AES-GCM', + 'AES-KW' + ], + digest: [ + 'SHA-1', + 'SHA-256', + 'SHA-384', + 'SHA-512' + ] + } + } + + static randomAlgorithmName (method) { + return random.item(this.algorithmNames[method]) + } + + static randomDigestName () { + return random.item(this.algorithmNames.digest) + } + + static get algorithms () { + return { + /* (Unsupported as of 30/01/2017) + ------------------------------- + | | Firefox | Chrome | + ----------------------------- | + | AES-CMAC | x | x | + | AES-CFB | x | x | + | CONCAT | x | x | + | HKDF-CTR | x | x | + | DH | | x | + ------------------------------- + */ + 'RSASSA-PKCS1-v1_5': { + // RSASA-PKCS1_v1_5 algorithm, using a SHA hash function. + keyUsages: ['sign', 'verify'], + length: function (len) { + return len || random.item([1, 256, 384, 512]) + }, + alg: function (len) { return utils.common.mockup(`{ - kty: 'oct', - alg: 'A${this.length(len)}GCMKW' + name: 'RSASSA-PKCS1-v1_5', + hash: { + name: 'SHA-${this.length(len)}' + }, + modulusLength: ${random.item([1024, 2048, 4096])}, + publicExponent: new Uint8Array([0x01, 0x00, 0x01]) }`) - } else { + }, + jwk: function (len) { return utils.common.mockup(`{ - kty: 'oct', - alg: 'A${this.length(len)}GCM' + kty: 'RSA', + alg: 'RS${this.length(len)}' }`) + }, + generateKey: function () { + return this.alg() + }, + importKey: function () { + return this.alg() + }, + sign: function () { + return this.alg() + }, + verify: function () { + return this.alg() + }, + presets: { + raw: {}, + jwk: [ + { + kty: 'RSA', + e: 'AQAB', + n: 'vGO3eU16ag9zRkJ4AK8ZUZrjbtp5xWK0LyFMNT8933evJoHeczexMUzSiXaLrEFSyQZortk81zJH3y41MBO_UFDO_X0crAquNrkjZDrf9Scc5-MdxlWU2Jl7Gc4Z18AC9aNibWVmXhgvHYkEoFdLCFG-2Sq-qIyW4KFkjan05IE', + alg: 'RS256', + ext: true + }, + { + kty: 'RSA', + e: 'AQAB', + d: 'n_dIVw9MD_04lANi5KnKJPoRfxKy7cGHYLG0hU5DGpsFNfx2yH0Uz9j8uU7ZARai1iHECBxcxhpi3wbckQtjmbkCUKvs4G0gKLT9UuNHcCbh0WfvadfPPec52n4z6s4zwisbgWCNbT2L-SyHt1yuFmLAYXkg0swk3y5Bt_ilA8E', + dp: '2RNM_uiYEQMcATQaUu3AwdeJpenCPykbQHkwAylvXqlHB6W7m5XX0k-SutkbXAijmGTC-Oh8NexsLGHxOACb8Q', + dq: 'rHabkI3_XVGieLqHujpWaWe9YD03fJY0KbbQX0fIoNdNU4GcmUftzIWLSajPKKsiyfR6Xk2AEtBmBPE5qaoV6Q', + n: 'vGO3eU16ag9zRkJ4AK8ZUZrjbtp5xWK0LyFMNT8933evJoHeczexMUzSiXaLrEFSyQZortk81zJH3y41MBO_UFDO_X0crAquNrkjZDrf9Scc5-MdxlWU2Jl7Gc4Z18AC9aNibWVmXhgvHYkEoFdLCFG-2Sq-qIyW4KFkjan05IE', + p: '5Y4ynodegqC9kgGmfZeSrojGmLyYR8HIvKVEAIjjMUQjyvKWpWsXfPg67mTdqVpjSpQLQlRfES2nUvZ27KrU6Q', + q: '0hd_U9PcNpMe77nhsTgoVNgMB34cqfrfu4fPuJ-7NvvMkKIELDLy-m8qg1MBbgf2i5546A9B5Exsuj4D2Vwz2Q', + qi: 'R3CkCGVAESy_hChmDvUaLMT-R1xk6kK7RLIUQKXATPQbnDqWBMgm-vcawFVhKJ-ICJsPfmRUsv7Wt1bJ01wLGQ', + alg: 'RS256', + ext: true + } + ], + spki: 'new Uint8Array([48, 129, 159, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 3, 129, 141, 0, 48, 129, 137, 2, 129, 129, 0, 182, 93, 35, 213, 252, 204, 20, 103, 91, 238, 105, 199, 53, 114, 24, 221, 114, 210, 137, 173, 88, 76, 205, 113, 148, 148, 79, 80, 59, 208, 60, 75, 231, 248, 78, 125, 12, 30, 237, 226, 63, 146, 157, 203, 239, 60, 138, 123, 234, 50, 23, 174, 216, 33, 122, 16, 53, 246, 140, 254, 75, 246, 205, 204, 117, 204, 115, 29, 178, 102, 139, 201, 74, 177, 45, 131, 183, 166, 234, 61, 124, 75, 110, 3, 70, 202, 148, 95, 45, 228, 94, 95, 148, 2, 162, 79, 146, 137, 29, 189, 102, 75, 207, 214, 116, 58, 63, 171, 219, 27, 5, 9, 108, 16, 218, 23, 169, 43, 181, 119, 31, 172, 95, 205, 180, 18, 255, 203, 2, 3, 1, 0, 1])', + pkcs8: 'new Uint8Array([48, 130, 2, 118, 2, 1, 0, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 4, 130, 2, 96, 48, 130, 2, 92, 2, 1, 0, 2, 129, 129, 0, 217, 78, 147, 218, 221, 152, 10, 66, 75, 127, 242, 108, 182, 142, 157, 44, 93, 58, 176, 193, 135, 103, 216, 179, 69, 72, 38, 115, 144, 244, 12, 139, 0, 245, 48, 115, 204, 234, 158, 193, 231, 127, 178, 240, 244, 203, 35, 229, 203, 245, 110, 215, 199, 19, 98, 183, 164, 223, 159, 203, 128, 123, 173, 26, 12, 172, 250, 99, 254, 35, 225, 221, 39, 51, 62, 3, 139, 35, 38, 164, 71, 238, 240, 73, 139, 214, 68, 172, 204, 253, 171, 244, 14, 186, 152, 159, 225, 133, 229, 140, 99, 50, 183, 242, 217, 248, 86, 233, 20, 117, 42, 136, 55, 8, 65, 124, 244, 65, 29, 15, 194, 255, 78, 31, 189, 146, 105, 161, 2, 3, 1, 0, 1, 2, 129, 128, 26, 88, 13, 82, 166, 52, 141, 97, 214, 23, 79, 195, 96, 42, 79, 225, 149, 247, 204, 127, 217, 179, 124, 48, 215, 128, 84, 177, 3, 236, 162, 44, 163, 212, 21, 168, 164, 57, 249, 63, 22, 154, 131, 141, 244, 143, 63, 237, 214, 217, 13, 51, 249, 125, 95, 37, 86, 70, 137, 239, 184, 198, 197, 136, 62, 183, 41, 78, 118, 234, 57, 195, 161, 219, 173, 234, 61, 11, 165, 109, 209, 9, 3, 22, 186, 114, 32, 135, 147, 74, 6, 106, 190, 214, 36, 208, 32, 220, 61, 12, 41, 105, 251, 247, 18, 159, 3, 198, 28, 228, 36, 44, 189, 125, 45, 72, 233, 199, 12, 72, 91, 106, 165, 246, 217, 58, 168, 53, 2, 65, 0, 241, 112, 53, 166, 98, 11, 38, 73, 58, 156, 84, 190, 118, 74, 247, 229, 85, 178, 83, 231, 53, 137, 237, 228, 246, 12, 32, 206, 157, 198, 152, 70, 11, 185, 234, 30, 112, 23, 115, 249, 68, 176, 159, 108, 247, 249, 207, 152, 145, 166, 246, 79, 176, 219, 163, 111, 243, 4, 49, 3, 239, 242, 63, 147, 2, 65, 0, 230, 105, 200, 1, 208, 201, 237, 225, 85, 27, 39, 216, 193, 1, 253, 168, 88, 15, 242, 166, 70, 106, 235, 2, 92, 24, 130, 66, 176, 176, 220, 238, 66, 12, 159, 26, 24, 40, 19, 213, 138, 98, 238, 98, 220, 65, 148, 116, 146, 21, 0, 25, 6, 177, 57, 216, 70, 51, 149, 244, 157, 153, 106, 123, 2, 64, 127, 92, 254, 48, 67, 80, 54, 102, 50, 240, 253, 19, 108, 59, 168, 1, 230, 239, 39, 171, 180, 102, 138, 132, 89, 247, 147, 230, 234, 252, 52, 159, 222, 215, 184, 85, 78, 52, 81, 13, 145, 218, 202, 127, 37, 97, 54, 205, 249, 39, 230, 143, 171, 112, 114, 11, 64, 91, 89, 176, 6, 7, 248, 217, 2, 65, 0, 220, 94, 95, 132, 29, 4, 132, 22, 247, 38, 185, 189, 125, 27, 66, 87, 55, 162, 73, 24, 238, 80, 99, 228, 37, 224, 234, 244, 141, 185, 26, 20, 101, 231, 92, 99, 192, 166, 212, 17, 112, 1, 158, 173, 190, 170, 154, 41, 195, 109, 130, 98, 109, 28, 35, 142, 205, 213, 152, 158, 19, 253, 30, 241, 2, 64, 15, 148, 8, 16, 189, 122, 55, 109, 203, 175, 173, 24, 222, 36, 130, 130, 179, 87, 189, 32, 141, 149, 30, 115, 211, 227, 79, 234, 78, 202, 253, 48, 173, 95, 167, 203, 20, 193, 160, 30, 146, 33, 109, 4, 221, 25, 212, 216, 183, 100, 18, 46, 184, 52, 65, 146, 249, 68, 225, 10, 84, 38, 98, 133])' } }, - generateKey: function () { - return this.alg() - }, - importKey: function () { - return this.alg() - }, - encrypt: function () { - return utils.common.mockup(`{ - name: 'AES-GCM', - iv: crypto.getRandomValues(new Uint8Array(12)), - additionalData: crypto.getRandomValues(new Uint8Array(256)), - tagLength: ${random.item([32, 64, 96, 104, 112, 120, 128])} - }`) - }, - decrypt: function () { - return this.encrypt() - }, - wrapKey: function () { - return utils.common.mockup(`{ - name: 'AES-GCM', - iv: crypto.getRandomValues(new Uint8Array(16)) - }`) - }, - unwrapKey: function () { - return this.wrapKey() - }, - presets: { - raw: 'new Uint8Array([122, 94, 39, 230, 46, 23, 151, 80, 131, 230, 3, 101, 80, 234, 143, 9, 251, 152, 229, 228, 89, 222, 31, 135, 214, 104, 55, 68, 67, 59, 5, 51])', - jwk: [ - { - kty: 'oct', - k: 'KfKY5nueRX7eBrOddn9IerHLv1r-T7qpggaCF3MfSR4', - alg: 'A256GCM', - ext: true - } - ], - spki: {}, - pkcs8: {} - } - }, - 'AES-KW': { - // Key wrapping in AES algorithm. - keyUsages: ['wrapKey', 'unwrapKey'], - length: function (len) { - return len || random.item([128, 192, 256]) - }, - alg: function (len) { - return utils.common.mockup(`{ - name: 'AES-KW', - length: ${this.length(len)} - }`) - }, - jwk: function (len) { - return utils.common.mockup(`{ - kty: 'oct', - alg: 'A${this.length(len)}KW' - }`) - }, - generateKey: function () { - return this.alg() - }, - importKey: function () { - return this.alg() - }, - wrapKey: function () { - return utils.common.mockup(`{ - name: 'AES-KW' - }`) - }, - unwrapKey: function () { - return this.wrapKey() - }, - presets: { - raw: 'new Uint8Array([122, 94, 39, 230, 46, 23, 151, 80, 131, 230, 3, 101, 80, 234, 143, 9, 251, 152, 229, 228, 89, 222, 31, 135, 214, 104, 55, 68, 67, 59, 5, 51])', - jwk: [ - { - kty: 'oct', - k: 'KfKY5nueRX7eBrOddn9IerHLv1r-T7qpggaCF3MfSR4', - alg: 'A256KW', - ext: true - } - ], - spki: {}, - pkcs8: {} - } - }, - 'HMAC': { - // Hash-based message authentication method using SHA hash functions. - keyUsages: ['sign', 'verify'], - length: function (len) { - return len || random.item([1, 256, 384, 512]) - }, - alg: function (len) { - return utils.common.mockup(`{ - name: 'HMAC', - hash: { - name: 'SHA-${this.length(len)}' - } - }`) - }, - jwk: function (len) { - return utils.common.mockup(`{ - kty: 'oct', - alg: 'HS${this.length(len)}' - }`) - }, - generateKey: function () { - return this.alg() - }, - importKey: function () { - return this.alg() - }, - sign: function () { - return this.alg() - }, - verify: function () { - return this.alg() - }, - presets: { - raw: 'new Uint8Array([122, 94, 39, 230, 46, 23, 151, 80, 131, 230, 3, 101, 80, 234, 143, 9, 251, 152, 229, 228, 89, 222, 31, 135, 214, 104, 55, 68, 67, 59, 5, 51])', - jwk: { - kty: 'oct', - k: 'KfKY5nueRX7eBrOddn9IerHLv1r-T7qpggaCF3MfSR4', - alg: 'HS256', - ext: true + 'RSA-PSS': { + keyUsages: ['sign', 'verify'], + length: function (len) { + return len || random.item([1, 256, 384, 512]) }, - spki: {}, - pkcs8: {} - } - }, - 'HKDF': { - // Key derivation using the extraction-then-expansion approach and using the SHA hash functions. - keyUsages: ['deriveKey', 'deriveBits'], - alg: function () { - return utils.common.mockup(`{ - name: 'HKDF' - }`) + alg: function (len) { + return utils.common.mockup(`{ + name: 'RSA-PSS', + hash: { + name: 'SHA-${this.length(len)}' + }, + modulusLength: ${random.item([1024, 2048, 4096])}, + publicExponent: new Uint8Array([0x01, 0x00, 0x01]), + saltLength: 8 + }`) + }, + jwk: function (len) { + return utils.common.mockup(`{ + kty: 'RSA', + alg: 'PS${this.length(len)}' + }`) + }, + generateKey: function () { + return this.alg() + }, + importKey: function () { + return this.alg() + }, + sign: function () { + return this.alg() + }, + verify: function () { + return this.alg() + }, + presets: { + raw: {}, + jwk: [ + { + kty: 'RSA', + e: 'AQAB', + n: 'vGO3eU16ag9zRkJ4AK8ZUZrjbtp5xWK0LyFMNT8933evJoHeczexMUzSiXaLrEFSyQZortk81zJH3y41MBO_UFDO_X0crAquNrkjZDrf9Scc5-MdxlWU2Jl7Gc4Z18AC9aNibWVmXhgvHYkEoFdLCFG-2Sq-qIyW4KFkjan05IE', + alg: 'RS256', + ext: true + }, + { + kty: 'RSA', + e: 'AQAB', + d: 'n_dIVw9MD_04lANi5KnKJPoRfxKy7cGHYLG0hU5DGpsFNfx2yH0Uz9j8uU7ZARai1iHECBxcxhpi3wbckQtjmbkCUKvs4G0gKLT9UuNHcCbh0WfvadfPPec52n4z6s4zwisbgWCNbT2L-SyHt1yuFmLAYXkg0swk3y5Bt_ilA8E', + dp: '2RNM_uiYEQMcATQaUu3AwdeJpenCPykbQHkwAylvXqlHB6W7m5XX0k-SutkbXAijmGTC-Oh8NexsLGHxOACb8Q', + dq: 'rHabkI3_XVGieLqHujpWaWe9YD03fJY0KbbQX0fIoNdNU4GcmUftzIWLSajPKKsiyfR6Xk2AEtBmBPE5qaoV6Q', + n: 'vGO3eU16ag9zRkJ4AK8ZUZrjbtp5xWK0LyFMNT8933evJoHeczexMUzSiXaLrEFSyQZortk81zJH3y41MBO_UFDO_X0crAquNrkjZDrf9Scc5-MdxlWU2Jl7Gc4Z18AC9aNibWVmXhgvHYkEoFdLCFG-2Sq-qIyW4KFkjan05IE', + p: '5Y4ynodegqC9kgGmfZeSrojGmLyYR8HIvKVEAIjjMUQjyvKWpWsXfPg67mTdqVpjSpQLQlRfES2nUvZ27KrU6Q', + q: '0hd_U9PcNpMe77nhsTgoVNgMB34cqfrfu4fPuJ-7NvvMkKIELDLy-m8qg1MBbgf2i5546A9B5Exsuj4D2Vwz2Q', + qi: 'R3CkCGVAESy_hChmDvUaLMT-R1xk6kK7RLIUQKXATPQbnDqWBMgm-vcawFVhKJ-ICJsPfmRUsv7Wt1bJ01wLGQ', + alg: 'PS256', + ext: true + } + ], + spki: 'new Uint8Array([48, 129, 159, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 3, 129, 141, 0, 48, 129, 137, 2, 129, 129, 0, 180, 31, 227, 200, 37, 227, 65, 238, 23, 91, 226, 130, 51, 32, 165, 245, 1, 24, 244, 5, 184, 42, 181, 155, 23, 142, 249, 220, 222, 131, 175, 54, 117, 135, 64, 232, 120, 90, 160, 221, 18, 31, 200, 41, 23, 174, 18, 172, 247, 166, 90, 37, 156, 229, 2, 70, 169, 165, 93, 246, 120, 117, 59, 202, 3, 102, 44, 119, 154, 54, 28, 198, 111, 39, 144, 73, 69, 251, 179, 74, 41, 215, 115, 186, 124, 200, 105, 75, 104, 158, 156, 158, 238, 214, 14, 81, 95, 130, 155, 146, 114, 125, 88, 158, 212, 44, 65, 236, 228, 194, 105, 96, 211, 155, 60, 71, 134, 90, 151, 202, 68, 20, 228, 105, 249, 202, 170, 155, 2, 3, 1, 0, 1])', + plcs8: 'new Uint8Array([48, 130, 2, 119, 2, 1, 0, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 4, 130, 2, 97, 48, 130, 2, 93, 2, 1, 0, 2, 129, 129, 0, 180, 31, 227, 200, 37, 227, 65, 238, 23, 91, 226, 130, 51, 32, 165, 245, 1, 24, 244, 5, 184, 42, 181, 155, 23, 142, 249, 220, 222, 131, 175, 54, 117, 135, 64, 232, 120, 90, 160, 221, 18, 31, 200, 41, 23, 174, 18, 172, 247, 166, 90, 37, 156, 229, 2, 70, 169, 165, 93, 246, 120, 117, 59, 202, 3, 102, 44, 119, 154, 54, 28, 198, 111, 39, 144, 73, 69, 251, 179, 74, 41, 215, 115, 186, 124, 200, 105, 75, 104, 158, 156, 158, 238, 214, 14, 81, 95, 130, 155, 146, 114, 125, 88, 158, 212, 44, 65, 236, 228, 194, 105, 96, 211, 155, 60, 71, 134, 90, 151, 202, 68, 20, 228, 105, 249, 202, 170, 155, 2, 3, 1, 0, 1, 2, 129, 128, 102, 251, 236, 161, 220, 119, 168, 148, 86, 42, 164, 192, 200, 54, 156, 108, 14, 42, 148, 42, 72, 247, 178, 73, 112, 24, 192, 230, 245, 25, 217, 45, 139, 216, 190, 213, 171, 42, 53, 218, 239, 167, 216, 43, 22, 108, 226, 36, 158, 155, 47, 227, 93, 102, 217, 252, 72, 182, 81, 152, 191, 154, 87, 137, 219, 194, 236, 53, 200, 123, 61, 10, 59, 231, 41, 18, 116, 77, 148, 50, 170, 116, 221, 110, 170, 190, 158, 108, 217, 38, 73, 84, 183, 51, 122, 179, 217, 143, 255, 87, 82, 80, 223, 188, 84, 134, 146, 150, 169, 64, 30, 168, 104, 8, 123, 162, 46, 59, 47, 232, 0, 35, 202, 42, 195, 141, 6, 1, 2, 65, 0, 237, 171, 148, 110, 241, 19, 152, 216, 206, 77, 109, 215, 21, 144, 110, 96, 34, 61, 46, 214, 148, 70, 238, 119, 206, 128, 32, 24, 136, 197, 185, 254, 209, 35, 235, 231, 122, 246, 167, 183, 117, 176, 51, 133, 169, 47, 130, 178, 40, 225, 145, 219, 48, 56, 21, 46, 198, 18, 85, 218, 194, 150, 141, 27, 2, 65, 0, 194, 4, 41, 152, 43, 246, 147, 7, 229, 244, 215, 110, 143, 7, 184, 187, 22, 166, 113, 217, 81, 52, 205, 54, 73, 202, 244, 24, 24, 219, 254, 243, 230, 230, 212, 172, 225, 218, 112, 95, 118, 103, 144, 223, 248, 164, 19, 228, 204, 204, 64, 91, 76, 77, 4, 206, 89, 173, 154, 162, 134, 113, 176, 129, 2, 64, 58, 4, 78, 97, 158, 155, 200, 13, 244, 158, 86, 23, 208, 253, 198, 211, 212, 199, 214, 173, 46, 216, 249, 209, 105, 41, 65, 172, 123, 134, 184, 214, 137, 59, 25, 149, 18, 33, 47, 227, 202, 232, 206, 74, 236, 119, 218, 145, 159, 5, 33, 83, 190, 59, 146, 128, 46, 125, 191, 83, 125, 120, 190, 205, 2, 65, 0, 134, 6, 204, 25, 20, 29, 180, 250, 90, 207, 229, 214, 185, 53, 211, 86, 98, 210, 62, 137, 170, 128, 120, 86, 205, 105, 71, 112, 50, 20, 31, 174, 171, 206, 192, 18, 97, 191, 61, 171, 164, 166, 236, 188, 220, 13, 180, 180, 117, 9, 144, 87, 193, 128, 223, 22, 17, 123, 76, 252, 131, 53, 156, 129, 2, 65, 0, 178, 29, 141, 176, 179, 203, 180, 190, 224, 34, 134, 226, 151, 73, 139, 163, 47, 17, 179, 117, 167, 200, 255, 174, 67, 114, 158, 96, 195, 176, 163, 241, 96, 24, 72, 35, 38, 18, 132, 176, 76, 235, 8, 29, 225, 138, 155, 191, 97, 158, 3, 22, 114, 133, 176, 213, 207, 120, 33, 55, 52, 135, 79, 161])' + } }, - jwk: function () { - return utils.common.mockup(`{}`) + 'RSA-OAEP': { + // RSAES-OAEP algorithm using a SHA hash functions and a MGF1 mask generating function. + keyUsages: ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey'], + length: function (len) { + return len || random.item([1, 256, 384, 512]) + }, + alg: function (len) { + return utils.common.mockup(`{ + name: 'RSA-OAEP', + hash: { + name: 'SHA-${this.length(len)}' + }, + modulusLength: ${random.item([1024, 2048, 4096])}, + publicExponent: new Uint8Array([0x01, 0x00, 0x01]) + }`) + }, + jwk: function (len) { + return utils.common.mockup(`{ + kty: 'RSA', + alg: 'RSA-OAEP-${this.length(len)}' + }`) + }, + generateKey: function () { + return this.alg() + }, + importKey: function () { + return this.alg() + }, + encrypt: function () { + utils.common.mockup(`{ + name: 'RSA-OAEP', + hash: { + name: 'SHA-${this.length()}' + }, + modulusLength: ${random.item([1024, 2048, 4096])}, + publicExponent: new Uint8Array([0x01, 0x00, 0x01]), + label: crypto.getRandomValues(new Uint8Array(16)) + }`) + }, + decrypt: function () { + return this.alg() + }, + unwrapKey: function () { + return this.alg() + }, + wrapKey: function () { + return this.alg() + }, + presets: { + raw: {}, + jkw: [ + { + kty: 'RSA', + e: 'AQAB', + n: 'vGO3eU16ag9zRkJ4AK8ZUZrjbtp5xWK0LyFMNT8933evJoHeczexMUzSiXaLrEFSyQZortk81zJH3y41MBO_UFDO_X0crAquNrkjZDrf9Scc5-MdxlWU2Jl7Gc4Z18AC9aNibWVmXhgvHYkEoFdLCFG-2Sq-qIyW4KFkjan05IE', + alg: 'RSA-OAEP-256', + ext: true + }, + { + kty: 'RSA', + e: 'AQAB', + d: 'e-Nm1CB_F7j0p4Cb-T4WmFTh7RbxUthC3j8xnlXwHgWYwaPs9ZRkicgNCfmjEb-qJ-m0ho1Cz4WzlL1CtTKEdr2w0P6L_IQPvWkFYwUm0rpY9doxnOKkzq53dhP5zdc6N8aOLk4cmAcVjw4o_csc85H-0fxzQxsTP0_jhJn7SNE', + dp: 'JuZmXNBY9uGGfx3w3ysmFumGBLooNjMwwgMduVS6T8S-0tZkBU-iwJPzXAkKhwINEv1EnygjwmJLBdoHROeEeQ', + dq: 'KaKOFHxm9104WNwqTth04O9ogaDz_W0wkeHnxOxbWgdtFxsarnImiMlI3Hphv9JuHD5awzNAkaj9P7wDVew-5Q', + n: 'x-Do39ky8RVFrFplFfAuOQGLr-rqY3h9OiNHVMe34LoVG4Aofps11ycyw5ka3Ls_yA-oRouGmaMjaiPUoaU_Lm5-CMSoVwyeANLZ4b2S7V-srXFS-Qpe6aD7NpzoUL9knwTnZFIGZlxSXB-NXL5kq18UuO1LQGe1To16ijXKNxc', + p: '4ss3ZAQMdmOk1BRQXwM9YHAoxVDkHDnSV9u89tUb3RbPXlV3fLlhRYtZ7u3FYaTzy08s8Ty2hV1KZ7xXhKEtuQ', + q: '4Z5ejmIJTwsgxN5pI6mLxwXqQwFDERYDnwU9_vyToWXMEPAphWpS9ET00YrdHsgIGao1Slc0jp4OUxaLfhtzTw', + qi: 'R1aKNnhUiTjoCHfOVHZ6Qv5R7So-F5mtjDKCBvCi8190U3E25DiKRvDqHZ0bHMRbdQPLLknxHVnuETw6gddHUg', + alg: 'RSA-OAEP-256', + ext: true + } + ], + spki: 'new Uint8Array([48, 129, 159, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 3, 129, 141, 0, 48, 129, 137, 2, 129, 129, 0, 182, 93, 35, 213, 252, 204, 20, 103, 91, 238, 105, 199, 53, 114, 24, 221, 114, 210, 137, 173, 88, 76, 205, 113, 148, 148, 79, 80, 59, 208, 60, 75, 231, 248, 78, 125, 12, 30, 237, 226, 63, 146, 157, 203, 239, 60, 138, 123, 234, 50, 23, 174, 216, 33, 122, 16, 53, 246, 140, 254, 75, 246, 205, 204, 117, 204, 115, 29, 178, 102, 139, 201, 74, 177, 45, 131, 183, 166, 234, 61, 124, 75, 110, 3, 70, 202, 148, 95, 45, 228, 94, 95, 148, 2, 162, 79, 146, 137, 29, 189, 102, 75, 207, 214, 116, 58, 63, 171, 219, 27, 5, 9, 108, 16, 218, 23, 169, 43, 181, 119, 31, 172, 95, 205, 180, 18, 255, 203, 2, 3, 1, 0, 1])', + pkcs8: 'new Uint8Array([48, 130, 2, 118, 2, 1, 0, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 4, 130, 2, 96, 48, 130, 2, 92, 2, 1, 0, 2, 129, 129, 0, 217, 78, 147, 218, 221, 152, 10, 66, 75, 127, 242, 108, 182, 142, 157, 44, 93, 58, 176, 193, 135, 103, 216, 179, 69, 72, 38, 115, 144, 244, 12, 139, 0, 245, 48, 115, 204, 234, 158, 193, 231, 127, 178, 240, 244, 203, 35, 229, 203, 245, 110, 215, 199, 19, 98, 183, 164, 223, 159, 203, 128, 123, 173, 26, 12, 172, 250, 99, 254, 35, 225, 221, 39, 51, 62, 3, 139, 35, 38, 164, 71, 238, 240, 73, 139, 214, 68, 172, 204, 253, 171, 244, 14, 186, 152, 159, 225, 133, 229, 140, 99, 50, 183, 242, 217, 248, 86, 233, 20, 117, 42, 136, 55, 8, 65, 124, 244, 65, 29, 15, 194, 255, 78, 31, 189, 146, 105, 161, 2, 3, 1, 0, 1, 2, 129, 128, 26, 88, 13, 82, 166, 52, 141, 97, 214, 23, 79, 195, 96, 42, 79, 225, 149, 247, 204, 127, 217, 179, 124, 48, 215, 128, 84, 177, 3, 236, 162, 44, 163, 212, 21, 168, 164, 57, 249, 63, 22, 154, 131, 141, 244, 143, 63, 237, 214, 217, 13, 51, 249, 125, 95, 37, 86, 70, 137, 239, 184, 198, 197, 136, 62, 183, 41, 78, 118, 234, 57, 195, 161, 219, 173, 234, 61, 11, 165, 109, 209, 9, 3, 22, 186, 114, 32, 135, 147, 74, 6, 106, 190, 214, 36, 208, 32, 220, 61, 12, 41, 105, 251, 247, 18, 159, 3, 198, 28, 228, 36, 44, 189, 125, 45, 72, 233, 199, 12, 72, 91, 106, 165, 246, 217, 58, 168, 53, 2, 65, 0, 241, 112, 53, 166, 98, 11, 38, 73, 58, 156, 84, 190, 118, 74, 247, 229, 85, 178, 83, 231, 53, 137, 237, 228, 246, 12, 32, 206, 157, 198, 152, 70, 11, 185, 234, 30, 112, 23, 115, 249, 68, 176, 159, 108, 247, 249, 207, 152, 145, 166, 246, 79, 176, 219, 163, 111, 243, 4, 49, 3, 239, 242, 63, 147, 2, 65, 0, 230, 105, 200, 1, 208, 201, 237, 225, 85, 27, 39, 216, 193, 1, 253, 168, 88, 15, 242, 166, 70, 106, 235, 2, 92, 24, 130, 66, 176, 176, 220, 238, 66, 12, 159, 26, 24, 40, 19, 213, 138, 98, 238, 98, 220, 65, 148, 116, 146, 21, 0, 25, 6, 177, 57, 216, 70, 51, 149, 244, 157, 153, 106, 123, 2, 64, 127, 92, 254, 48, 67, 80, 54, 102, 50, 240, 253, 19, 108, 59, 168, 1, 230, 239, 39, 171, 180, 102, 138, 132, 89, 247, 147, 230, 234, 252, 52, 159, 222, 215, 184, 85, 78, 52, 81, 13, 145, 218, 202, 127, 37, 97, 54, 205, 249, 39, 230, 143, 171, 112, 114, 11, 64, 91, 89, 176, 6, 7, 248, 217, 2, 65, 0, 220, 94, 95, 132, 29, 4, 132, 22, 247, 38, 185, 189, 125, 27, 66, 87, 55, 162, 73, 24, 238, 80, 99, 228, 37, 224, 234, 244, 141, 185, 26, 20, 101, 231, 92, 99, 192, 166, 212, 17, 112, 1, 158, 173, 190, 170, 154, 41, 195, 109, 130, 98, 109, 28, 35, 142, 205, 213, 152, 158, 19, 253, 30, 241, 2, 64, 15, 148, 8, 16, 189, 122, 55, 109, 203, 175, 173, 24, 222, 36, 130, 130, 179, 87, 189, 32, 141, 149, 30, 115, 211, 227, 79, 234, 78, 202, 253, 48, 173, 95, 167, 203, 20, 193, 160, 30, 146, 33, 109, 4, 221, 25, 212, 216, 183, 100, 18, 46, 184, 52, 65, 146, 249, 68, 225, 10, 84, 38, 98, 133])' + } }, - generateKey: function () { - return this.alg() + 'ECDSA': { + keyUsages: ['sign', 'verify'], + length: function (len) { + return len || random.item([256, 384, 512]) + }, + alg: function (len) { + len = this.length(len) + return utils.common.mockup(`{ + name: 'ECDSA', + namedCurve: 'P-${len}', + hash: { + name: 'SHA-${len}' + } + }`) + }, + jwk: function (len) { + return utils.common.mockup(`{ + kty: 'EC', + alg: 'ES${this.length(len)}' + }`) + }, + generateKey: function () { + return this.alg() + }, + importKey: function () { + return this.alg() + }, + sign: function () { + return this.alg() + }, + verify: function () { + return this.alg() + }, + presets: { + raw: {}, + jwk: [ + { + kty: 'EC', + crv: 'P-256', + x: 'A5fQnBdBSgBhTjMr1Atpzvh5SKYQ4aQRJ9WTCG5U4m4', + y: '8YF98byzMljHX3T5ORLYTDbcwG-_eq3f23JtTE6lOe0', + ext: true + }, + { + kty: 'EC', + crv: 'P-256', + x: 'A5fQnBdBSgBhTjMr1Atpzvh5SKYQ4aQRJ9WTCG5U4m4', + y: '8YF98byzMljHX3T5ORLYTDbcwG-_eq3f23JtTE6lOe0', + d: '4DvC-hxpv8myZLNeMY-8nq55MhdfA4obM1lGG3hF_yo', + ext: true + } + ], + spki: 'new Uint8Array([48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7, 3, 66, 0, 4, 3, 151, 208, 156, 23, 65, 74, 0, 97, 78, 51, 43, 212, 11, 105, 206, 248, 121, 72, 166, 16, 225, 164, 17, 39, 213, 147, 8, 110, 84, 226, 110, 241, 129, 125, 241, 188, 179, 50, 88, 199, 95, 116, 249, 57, 18, 216, 76, 54, 220, 192, 111, 191, 122, 173, 223, 219, 114, 109, 76, 78, 165, 57, 237])', + pkcs8: 'new Uint8Array([48, 129, 135, 2, 1, 0, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7, 4, 109, 48, 107, 2, 1, 1, 4, 32, 224, 59, 194, 250, 28, 105, 191, 201, 178, 100, 179, 94, 49, 143, 188, 158, 174, 121, 50, 23, 95, 3, 138, 27, 51, 89, 70, 27, 120, 69, 255, 42, 161, 68, 3, 66, 0, 4, 3, 151, 208, 156, 23, 65, 74, 0, 97, 78, 51, 43, 212, 11, 105, 206, 248, 121, 72, 166, 16, 225, 164, 17, 39, 213, 147, 8, 110, 84, 226, 110, 241, 129, 125, 241, 188, 179, 50, 88, 199, 95, 116, 249, 57, 18, 216, 76, 54, 220, 192, 111, 191, 122, 173, 223, 219, 114, 109, 76, 78, 165, 57, 237])' + } }, - importKey: function () { - return this.alg() + 'ECDH': { + keyUsages: ['deriveKey', 'deriveBits'], + length: function (len) { + return len || random.item([256, 384, 512]) + }, + alg: function (len) { + return utils.common.mockup(`{ + name: 'ECDSA', + namedCurve: 'P-${this.length(len)}' + }`) + }, + jwk: function () { + return {} + }, + generateKey: function () { + return this.alg() + }, + importKey: function () { + return this.alg() + }, + deriveKey: function (key) { + return utils.common.mockup(`{ + name: 'ECDSA', + namedCurve: 'P-${this.length()}', + ${key} + }`) + }, + deriveBits: function (key) { + return utils.common.mockup(`{ + name: 'ECDSA', + namedCurve: 'P-${this.length()}', + ${key} + }`) + }, + presets: { + raw: {}, + jwk: [ + { + kty: 'EC', + crv: 'P-256', + x: 'kgR_PqO07L8sZOBbw6rvv7O_f7clqDeiE3WnMkb5EoI', + y: 'djI-XqCqSyO9GFk_QT_stROMCAROIvU8KOORBgQUemE', + ext: true + }, + { + kty: 'EC', + crv: 'P-256', + x: 'kgR_PqO07L8sZOBbw6rvv7O_f7clqDeiE3WnMkb5EoI', + y: 'djI-XqCqSyO9GFk_QT_stROMCAROIvU8KOORBgQUemE', + d: '5aPFSt0UFVXYGu-ZKyC9FQIUOAMmnjzdIwkxCMe3Iok', + ext: true + } + ], + spki: 'new Uint8Array([48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7, 3, 66, 0, 4, 146, 4, 127, 62, 163, 180, 236, 191, 44, 100, 224, 91, 195, 170, 239, 191, 179, 191, 127, 183, 37, 168, 55, 162, 19, 117, 167, 50, 70, 249, 18, 130, 118, 50, 62, 94, 160, 170, 75, 35, 189, 24, 89, 63, 65, 63, 236, 181, 19, 140, 8, 4, 78, 34, 245, 60, 40, 227, 145, 6, 4, 20, 122, 97])', + pkcs8: 'new Uint8Array([48, 129, 135, 2, 1, 0, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7, 4, 109, 48, 107, 2, 1, 1, 4, 32, 229, 163, 197, 74, 221, 20, 21, 85, 216, 26, 239, 153, 43, 32, 189, 21, 2, 20, 56, 3, 38, 158, 60, 221, 35, 9, 49, 8, 199, 183, 34, 137, 161, 68, 3, 66, 0, 4, 146, 4, 127, 62, 163, 180, 236, 191, 44, 100, 224, 91, 195, 170, 239, 191, 179, 191, 127, 183, 37, 168, 55, 162, 19, 117, 167, 50, 70, 249, 18, 130, 118, 50, 62, 94, 160, 170, 75, 35, 189, 24, 89, 63, 65, 63, 236, 181, 19, 140, 8, 4, 78, 34, 245, 60, 40, 227, 145, 6, 4, 20, 122, 97])' + } }, - deriveBits: function () { - return utils.common.mockup(`{ - name: 'HKDF', - hash: { - name: '${make.crypto.randomDigestName()}' + 'AES-CTR': { + // AES in Counter Mode. + keyUsages: ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey'], + length: function (len) { + return len || random.item([128, 192, 256]) + }, + alg: function (len) { + return utils.common.mockup(`{ + name: 'AES-CTR', + length: '${this.length(len)}' + }`) + }, + jwk: function (len) { + return utils.common.mockup(`{ + kty: 'oct', + alg: 'A${this.length(len)}CTR' + }`) + }, + generateKey: function () { + return this.alg() + }, + importKey: function () { + return this.alg() + }, + encrypt: function () { + return utils.common.mockup(`{ + name: 'AES-CTR', + length: ${this.length()}, + counter: new Uint8Array(16) + }`) + }, + decrypt: function () { + return this.encrypt() + }, + wrapKey: function () { + return this.encrypt() + }, + unwrapKey: function () { + return this.encrypt() + }, + presets: { + raw: 'new Uint8Array([122, 94, 39, 230, 46, 23, 151, 80, 131, 230, 3, 101, 80, 234, 143, 9, 251, 152, 229, 228, 89, 222, 31, 135, 214, 104, 55, 68, 67, 59, 5, 51])', + jwk: [ + { + kty: 'oct', + k: 'Y0zt37HgOx-BY7SQjYVmrqhPkO44Ii2Jcb9yydUDPfE', + alg: 'A256CTR', + ext: true + } + ], + spki: {}, + pkcs8: {} + } + }, + 'AES-CBC': { + // AES in Cipher Block Chaining mode. + keyUsages: ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey'], + length: function (len) { + return len || random.item([128, 192, 256]) + }, + alg: function (len) { + return utils.common.mockup(`{ + name: 'AES-CBC', + length: ${this.length(len)} + }`) + }, + jwk: function (len) { + return utils.common.mockup(`{ + kty: 'oct', + alg: 'A${this.length(len)}CBC' + }`) + }, + generateKey: function () { + return this.alg() + }, + importKey: function () { + return this.alg() + }, + encrypt: function () { + return utils.common.mockup(`{ + name: 'AES-CBC', + length: ${this.length()}, + iv: crypto.getRandomValues(new Uint8Array(16)) + }`) + }, + decrypt: function () { + return this.encrypt() + }, + wrapKey: function () { + return this.encrypt() + }, + unwrapKey: function () { + return this.encrypt() + }, + presets: { + raw: 'new Uint8Array([122, 94, 39, 230, 46, 23, 151, 80, 131, 230, 3, 101, 80, 234, 143, 9, 251, 152, 229, 228, 89, 222, 31, 135, 214, 104, 55, 68, 67, 59, 5, 51])', + jwk: [ + { + kty: 'oct', + k: 'KfKY5nueRX7eBrOddn9IerHLv1r-T7qpggaCF3MfSR4', + alg: 'A256CBC', + ext: true + } + ], + spki: {}, + pkcs8: {} + } + }, + 'AES-GCM': { + // AES in Galois/Counter Mode. + keyUsages: ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey'], + length: function (len) { + return len || random.item([128, 192, 256]) + }, + alg: function (len) { + return utils.common.mockup(`{ + name: 'AES-GCM', + length: ${this.length(len)} + }`) + }, + jwk: function (len) { + if (random.chance(4)) { + return utils.common.mockup(`{ + kty: 'oct', + alg: 'A${this.length(len)}GCMKW' + }`) + } else { + return utils.common.mockup(`{ + kty: 'oct', + alg: 'A${this.length(len)}GCM' + }`) + } + }, + generateKey: function () { + return this.alg() + }, + importKey: function () { + return this.alg() + }, + encrypt: function () { + return utils.common.mockup(`{ + name: 'AES-GCM', + iv: crypto.getRandomValues(new Uint8Array(12)), + additionalData: crypto.getRandomValues(new Uint8Array(256)), + tagLength: ${random.item([32, 64, 96, 104, 112, 120, 128])} + }`) + }, + decrypt: function () { + return this.encrypt() + }, + wrapKey: function () { + return utils.common.mockup(`{ + name: 'AES-GCM', + iv: crypto.getRandomValues(new Uint8Array(16)) + }`) + }, + unwrapKey: function () { + return this.wrapKey() + }, + presets: { + raw: 'new Uint8Array([122, 94, 39, 230, 46, 23, 151, 80, 131, 230, 3, 101, 80, 234, 143, 9, 251, 152, 229, 228, 89, 222, 31, 135, 214, 104, 55, 68, 67, 59, 5, 51])', + jwk: [ + { + kty: 'oct', + k: 'KfKY5nueRX7eBrOddn9IerHLv1r-T7qpggaCF3MfSR4', + alg: 'A256GCM', + ext: true + } + ], + spki: {}, + pkcs8: {} + } + }, + 'AES-KW': { + // Key wrapping in AES algorithm. + keyUsages: ['wrapKey', 'unwrapKey'], + length: function (len) { + return len || random.item([128, 192, 256]) + }, + alg: function (len) { + return utils.common.mockup(`{ + name: 'AES-KW', + length: ${this.length(len)} + }`) + }, + jwk: function (len) { + return utils.common.mockup(`{ + kty: 'oct', + alg: 'A${this.length(len)}KW' + }`) + }, + generateKey: function () { + return this.alg() + }, + importKey: function () { + return this.alg() + }, + wrapKey: function () { + return utils.common.mockup(`{ + name: 'AES-KW' + }`) + }, + unwrapKey: function () { + return this.wrapKey() + }, + presets: { + raw: 'new Uint8Array([122, 94, 39, 230, 46, 23, 151, 80, 131, 230, 3, 101, 80, 234, 143, 9, 251, 152, 229, 228, 89, 222, 31, 135, 214, 104, 55, 68, 67, 59, 5, 51])', + jwk: [ + { + kty: 'oct', + k: 'KfKY5nueRX7eBrOddn9IerHLv1r-T7qpggaCF3MfSR4', + alg: 'A256KW', + ext: true + } + ], + spki: {}, + pkcs8: {} + } + }, + 'HMAC': { + // Hash-based message authentication method using SHA hash functions. + keyUsages: ['sign', 'verify'], + length: function (len) { + return len || random.item([1, 256, 384, 512]) + }, + alg: function (len) { + return utils.common.mockup(`{ + name: 'HMAC', + hash: { + name: 'SHA-${this.length(len)}' + } + }`) + }, + jwk: function (len) { + return utils.common.mockup(`{ + kty: 'oct', + alg: 'HS${this.length(len)}' + }`) + }, + generateKey: function () { + return this.alg() + }, + importKey: function () { + return this.alg() + }, + sign: function () { + return this.alg() + }, + verify: function () { + return this.alg() + }, + presets: { + raw: 'new Uint8Array([122, 94, 39, 230, 46, 23, 151, 80, 131, 230, 3, 101, 80, 234, 143, 9, 251, 152, 229, 228, 89, 222, 31, 135, 214, 104, 55, 68, 67, 59, 5, 51])', + jwk: { + kty: 'oct', + k: 'KfKY5nueRX7eBrOddn9IerHLv1r-T7qpggaCF3MfSR4', + alg: 'HS256', + ext: true }, - salt: crypto.getRandomValues(new Uint8Array(16)), - info: crypto.getRandomValues(new Uint8Array(16)) - }`) + spki: {}, + pkcs8: {} + } }, - deriveKey: function () { - return this.deriveBits() + 'HKDF': { + // Key derivation using the extraction-then-expansion approach and using the SHA hash functions. + keyUsages: ['deriveKey', 'deriveBits'], + alg: function () { + return utils.common.mockup(`{ + name: 'HKDF' + }`) + }, + jwk: function () { + return utils.common.mockup(`{}`) + }, + generateKey: function () { + return this.alg() + }, + importKey: function () { + return this.alg() + }, + deriveBits: function () { + return utils.common.mockup(`{ + name: 'HKDF', + hash: { + name: '${make.crypto.randomDigestName()}' + }, + salt: crypto.getRandomValues(new Uint8Array(16)), + info: crypto.getRandomValues(new Uint8Array(16)) + }`) + }, + deriveKey: function () { + return this.deriveBits() + }, + presets: { + raw: 'crypto.getRandomValues(new Uint8Array(16))', + jwk: {}, + spki: {}, + pkcs8: {} + } }, - presets: { - raw: 'crypto.getRandomValues(new Uint8Array(16))', - jwk: {}, - spki: {}, - pkcs8: {} - } - }, - 'PBKDF2': { - // Key derivation using the PKCS#5 password-based key derivation function v2.0. - keyUsages: ['deriveKey', 'deriveBits'], - alg: function () { - return utils.common.mockup(`{ - name: 'PBKDF2' - }`) + 'PBKDF2': { + // Key derivation using the PKCS#5 password-based key derivation function v2.0. + keyUsages: ['deriveKey', 'deriveBits'], + alg: function () { + return utils.common.mockup(`{ + name: 'PBKDF2' + }`) + }, + jwk: function () { + return utils.common.mockup(`{}`) + }, + generateKey: function () { + return this.alg() + }, + importKey: function () { + return this.alg() + }, + deriveBits: function () { + return utils.common.mockup(`{ + name: 'PBKDF2', + hash: { + name: '${make.crypto.randomDigestName()}' + }, + salt: crypto.getRandomValues(new Uint8Array(16)), + iterations: ${random.number(1000)} + }`) + }, + deriveKey: function () { + return this.deriveBits() + }, + presets: { + raw: 'crypto.getRandomValues(new Uint8Array(16))', + jwk: {}, + spki: {}, + pkcs8: {} + } }, - jwk: function () { - return utils.common.mockup(`{}`) - }, - generateKey: function () { - return this.alg() - }, - importKey: function () { - return this.alg() - }, - deriveBits: function () { - return utils.common.mockup(`{ - name: 'PBKDF2', - hash: { - name: '${make.crypto.randomDigestName()}' - }, - salt: crypto.getRandomValues(new Uint8Array(16)), - iterations: ${random.number(1000)} - }`) - }, - deriveKey: function () { - return this.deriveBits() - }, - presets: { - raw: 'crypto.getRandomValues(new Uint8Array(16))', - jwk: {}, - spki: {}, - pkcs8: {} - } - }, - 'DH': { - keyUsages: ['deriveKey', 'deriveBits'], - alg: function () { - return utils.common.mockup(`{ - name: 'DH' - }`) - }, - jwk: function () { - return utils.common.mockup(`{}`) - }, - generateKey: function () { - return utils.common.mockup(`{ - name: 'DH', - prime: new Uint8Array([255, 255, 255, 255, 255, 255, 255, 255, 201, 15, 218, 162, 33, 104, 194, 52, 196, 198, 98, 139, 128, 220, 28, 209, 41, 2, 78, 8, 138, 103, 204, 116, 2, 11, 190, 166, 59, 19, 155, 34, 81, 74, 8, 121, 142, 52, 4, 221, 239, 149, 25, 179, 205, 58, 67, 27, 48, 43, 10, 109, 242, 95, 20, 55, 79, 225, 53, 109, 109, 81, 194, 69, 228, 133, 181, 118, 98, 94, 126, 198, 244, 76, 66, 233, 166, 55, 237, 107, 11, 255, 92, 182, 244, 6, 183, 237, 238, 56, 107, 251, 90, 137, 159, 165, 174, 159, 36, 17, 124, 75, 31, 230, 73, 40, 102, 81, 236, 228, 91, 61, 194, 0, 124, 184, 161, 99, 191, 5, 152, 218, 72, 54, 28, 85, 211, 154, 105, 22, 63, 168, 253, 36, 207, 95, 131, 101, 93, 35, 220, 163, 173, 150, 28, 98, 243, 86, 32, 133, 82, 187, 158, 213, 41, 7, 112, 150, 150, 109, 103, 12, 53, 78, 74, 188, 152, 4, 241, 116, 108, 8, 202, 35, 115, 39, 255, 255, 255, 255, 255, 255, 255, 255]), - generator: new Uint8Array([2]) - }`) - }, - importKey: function () { - return this.generateKey() - }, - deriveKey: function (key) { - // return Object.assign(this.generateKey(),key) - return utils.common.mockup(` - name: 'DH', - prime: new Uint8Array([255, 255, 255, 255, 255, 255, 255, 255, 201, 15, 218, 162, 33, 104, 194, 52, 196, 198, 98, 139, 128, 220, 28, 209, 41, 2, 78, 8, 138, 103, 204, 116, 2, 11, 190, 166, 59, 19, 155, 34, 81, 74, 8, 121, 142, 52, 4, 221, 239, 149, 25, 179, 205, 58, 67, 27, 48, 43, 10, 109, 242, 95, 20, 55, 79, 225, 53, 109, 109, 81, 194, 69, 228, 133, 181, 118, 98, 94, 126, 198, 244, 76, 66, 233, 166, 55, 237, 107, 11, 255, 92, 182, 244, 6, 183, 237, 238, 56, 107, 251, 90, 137, 159, 165, 174, 159, 36, 17, 124, 75, 31, 230, 73, 40, 102, 81, 236, 228, 91, 61, 194, 0, 124, 184, 161, 99, 191, 5, 152, 218, 72, 54, 28, 85, 211, 154, 105, 22, 63, 168, 253, 36, 207, 95, 131, 101, 93, 35, 220, 163, 173, 150, 28, 98, 243, 86, 32, 133, 82, 187, 158, 213, 41, 7, 112, 150, 150, 109, 103, 12, 53, 78, 74, 188, 152, 4, 241, 116, 108, 8, 202, 35, 115, 39, 255, 255, 255, 255, 255, 255, 255, 255]), - generator: new Uint8Array([2]), - ${key} - `) - }, - deriveBits: function (key) { - return utils.common.mockup(` - name: 'DH', - prime: new Uint8Array([255, 255, 255, 255, 255, 255, 255, 255, 201, 15, 218, 162, 33, 104, 194, 52, 196, 198, 98, 139, 128, 220, 28, 209, 41, 2, 78, 8, 138, 103, 204, 116, 2, 11, 190, 166, 59, 19, 155, 34, 81, 74, 8, 121, 142, 52, 4, 221, 239, 149, 25, 179, 205, 58, 67, 27, 48, 43, 10, 109, 242, 95, 20, 55, 79, 225, 53, 109, 109, 81, 194, 69, 228, 133, 181, 118, 98, 94, 126, 198, 244, 76, 66, 233, 166, 55, 237, 107, 11, 255, 92, 182, 244, 6, 183, 237, 238, 56, 107, 251, 90, 137, 159, 165, 174, 159, 36, 17, 124, 75, 31, 230, 73, 40, 102, 81, 236, 228, 91, 61, 194, 0, 124, 184, 161, 99, 191, 5, 152, 218, 72, 54, 28, 85, 211, 154, 105, 22, 63, 168, 253, 36, 207, 95, 131, 101, 93, 35, 220, 163, 173, 150, 28, 98, 243, 86, 32, 133, 82, 187, 158, 213, 41, 7, 112, 150, 150, 109, 103, 12, 53, 78, 74, 188, 152, 4, 241, 116, 108, 8, 202, 35, 115, 39, 255, 255, 255, 255, 255, 255, 255, 255]), - generator: new Uint8Array([2]), - ${key} - `) - }, - presets: { - raw: {}, - jwk: {}, - spki: {}, - pkcs8: {} + 'DH': { + keyUsages: ['deriveKey', 'deriveBits'], + alg: function () { + return utils.common.mockup(`{ + name: 'DH' + }`) + }, + jwk: function () { + return utils.common.mockup(`{}`) + }, + generateKey: function () { + return utils.common.mockup(`{ + name: 'DH', + prime: new Uint8Array([255, 255, 255, 255, 255, 255, 255, 255, 201, 15, 218, 162, 33, 104, 194, 52, 196, 198, 98, 139, 128, 220, 28, 209, 41, 2, 78, 8, 138, 103, 204, 116, 2, 11, 190, 166, 59, 19, 155, 34, 81, 74, 8, 121, 142, 52, 4, 221, 239, 149, 25, 179, 205, 58, 67, 27, 48, 43, 10, 109, 242, 95, 20, 55, 79, 225, 53, 109, 109, 81, 194, 69, 228, 133, 181, 118, 98, 94, 126, 198, 244, 76, 66, 233, 166, 55, 237, 107, 11, 255, 92, 182, 244, 6, 183, 237, 238, 56, 107, 251, 90, 137, 159, 165, 174, 159, 36, 17, 124, 75, 31, 230, 73, 40, 102, 81, 236, 228, 91, 61, 194, 0, 124, 184, 161, 99, 191, 5, 152, 218, 72, 54, 28, 85, 211, 154, 105, 22, 63, 168, 253, 36, 207, 95, 131, 101, 93, 35, 220, 163, 173, 150, 28, 98, 243, 86, 32, 133, 82, 187, 158, 213, 41, 7, 112, 150, 150, 109, 103, 12, 53, 78, 74, 188, 152, 4, 241, 116, 108, 8, 202, 35, 115, 39, 255, 255, 255, 255, 255, 255, 255, 255]), + generator: new Uint8Array([2]) + }`) + }, + importKey: function () { + return this.generateKey() + }, + deriveKey: function (key) { + // return Object.assign(this.generateKey(),key) + return utils.common.mockup(` + name: 'DH', + prime: new Uint8Array([255, 255, 255, 255, 255, 255, 255, 255, 201, 15, 218, 162, 33, 104, 194, 52, 196, 198, 98, 139, 128, 220, 28, 209, 41, 2, 78, 8, 138, 103, 204, 116, 2, 11, 190, 166, 59, 19, 155, 34, 81, 74, 8, 121, 142, 52, 4, 221, 239, 149, 25, 179, 205, 58, 67, 27, 48, 43, 10, 109, 242, 95, 20, 55, 79, 225, 53, 109, 109, 81, 194, 69, 228, 133, 181, 118, 98, 94, 126, 198, 244, 76, 66, 233, 166, 55, 237, 107, 11, 255, 92, 182, 244, 6, 183, 237, 238, 56, 107, 251, 90, 137, 159, 165, 174, 159, 36, 17, 124, 75, 31, 230, 73, 40, 102, 81, 236, 228, 91, 61, 194, 0, 124, 184, 161, 99, 191, 5, 152, 218, 72, 54, 28, 85, 211, 154, 105, 22, 63, 168, 253, 36, 207, 95, 131, 101, 93, 35, 220, 163, 173, 150, 28, 98, 243, 86, 32, 133, 82, 187, 158, 213, 41, 7, 112, 150, 150, 109, 103, 12, 53, 78, 74, 188, 152, 4, 241, 116, 108, 8, 202, 35, 115, 39, 255, 255, 255, 255, 255, 255, 255, 255]), + generator: new Uint8Array([2]), + ${key} + `) + }, + deriveBits: function (key) { + return utils.common.mockup(` + name: 'DH', + prime: new Uint8Array([255, 255, 255, 255, 255, 255, 255, 255, 201, 15, 218, 162, 33, 104, 194, 52, 196, 198, 98, 139, 128, 220, 28, 209, 41, 2, 78, 8, 138, 103, 204, 116, 2, 11, 190, 166, 59, 19, 155, 34, 81, 74, 8, 121, 142, 52, 4, 221, 239, 149, 25, 179, 205, 58, 67, 27, 48, 43, 10, 109, 242, 95, 20, 55, 79, 225, 53, 109, 109, 81, 194, 69, 228, 133, 181, 118, 98, 94, 126, 198, 244, 76, 66, 233, 166, 55, 237, 107, 11, 255, 92, 182, 244, 6, 183, 237, 238, 56, 107, 251, 90, 137, 159, 165, 174, 159, 36, 17, 124, 75, 31, 230, 73, 40, 102, 81, 236, 228, 91, 61, 194, 0, 124, 184, 161, 99, 191, 5, 152, 218, 72, 54, 28, 85, 211, 154, 105, 22, 63, 168, 253, 36, 207, 95, 131, 101, 93, 35, 220, 163, 173, 150, 28, 98, 243, 86, 32, 133, 82, 187, 158, 213, 41, 7, 112, 150, 150, 109, 103, 12, 53, 78, 74, 188, 152, 4, 241, 116, 108, 8, 202, 35, 115, 39, 255, 255, 255, 255, 255, 255, 255, 255]), + generator: new Uint8Array([2]), + ${key} + `) + }, + presets: { + raw: {}, + jwk: {}, + spki: {}, + pkcs8: {} + } } } - }, - supportedAlgorithms: () => Object.keys(make.crypto.algorithms), - randomAlgorithm: () => { + } + + static supportedAlgorithms () { + Object.keys(make.crypto.algorithms) + } + + static randomAlgorithm () { return make.crypto.algorithms[random.item(Object.keys(make.crypto.algorithms))] - }, - randomCandidate: (operation) => { + } + + static randomCandidate (operation) { // Find and return a random algorithm suitable for a given operation. return make.crypto.algorithms[make.crypto.randomAlgorithmName(operation)] } } + +module.exports = crypto diff --git a/lib/make/datetime.js b/lib/make/datetime.js index 602a6d1..4e81c99 100644 --- a/lib/make/datetime.js +++ b/lib/make/datetime.js @@ -2,25 +2,34 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -make.datetime = { - object: function () { +const make = require('../make') +const random = require('../random') + +class datetime extends make { + static object () { switch (random.number(2)) { case 0: return new Date(new Date().getTime() + random.number()) case 1: return new Date(new Date().getTime() - random.number()) } - }, - date: function () { // eslint-disable-line no-unused-vars + } + + static date () { return this.object().toDateString() - }, - time: function () { // eslint-disable-line no-unused-vars + } + + static time () { return this.object().toTimeString() - }, - iso: function () { // eslint-disable-line no-unused-vars + } + + static iso () { return this.object().toISOString() - }, - epoch: function () { // eslint-disable-line no-unused-vars + } + + static epoch () { return Math.floor(this.object() / 1000) } } + +module.exports = datetime diff --git a/lib/make/files.js b/lib/make/files.js index 3eb94d5..76aac78 100644 --- a/lib/make/files.js +++ b/lib/make/files.js @@ -2,8 +2,11 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -make.files = { - image: function () { +const make = require('../make') +const random = require('../random') + +class files extends make { + static image () { return random.pick([ 'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=', 'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==', @@ -12,33 +15,39 @@ make.files = { 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAACklEQVQYV2P4DwABAQEAWk1v8QAAAABJRU5ErkJggg==', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=' ]) - }, - video: function () { + } + + static video () { return random.pick([ 'data:video/webm;base64,GkXfowEAAAAAAAAfQoaBAUL3gQFC8oEEQvOBCEKChHdlYm1Ch4EEQoWBAhhTgGcBAAAAAAAVkhFNm3RALE27i1OrhBVJqWZTrIHfTbuMU6uEFlSua1OsggEwTbuMU6uEHFO7a1OsghV17AEAAAAAAACkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSal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EnpZTSOeecEwAAVOAAABBgo8jmBCNBhYasBABSAQAMjmNZmuZ5omialiRpmud5niiapiZJmuZ5nieKqsnzPE8URdE0VZXneZ4oiqJpqirXFUXTNE1VVV2yLIqmaZqq6rowTdNUVdd1XZimaaqq67oubFtVVdV1ZRm2raqq6rqyDFzXdWXZloEsu67s2rIAAPAEBwCgAhtWRzgpGgssNGQlAJABAEAYg5BCCCFlEEIKIYSUUggJAAAYcAAACDChDBQashIASAUAAIyx1lprrbXWQGettdZaa62AzFprrbXWWmuttdZaa6211lJrrbXWWmuttdZaa6211lprrbXWWmuttdZaa6211lprrbXWWmuttdZaa6211lprrbXWWmstpZRSSimllFJKKaWUUkoppZRSSgUA+lU4APg/2LA6wknRWGChISsBgHAAAMAYpRhzDEIppVQIMeacdFRai7FCiDHnJKTUWmzFc85BKCGV1mIsnnMOQikpxVZjUSmEUlJKLbZYi0qho5JSSq3VWIwxqaTWWoutxmKMSSm01FqLMRYjbE2ptdhqq7EYY2sqLbQYY4zFCF9kbC2m2moNxggjWywt1VprMMYY3VuLpbaaizE++NpSLDHWXAAAd4MDAESCjTOsJJ0VjgYXGrISAAgJACAQUooxxhhzzjnnpFKMOeaccw5CCKFUijHGnHMOQgghlIwx5pxzEEIIIYRSSsaccxBCCCGEkFLqnHMQQgghhBBKKZ1zDkIIIYQQQimlgxBCCCGEEEoopaQUQgghhBBCCKmklEIIIYRSQighlZRSCCGEEEIpJaSUUgohhFJCCKGElFJKKYUQQgillJJSSimlEkoJJYQSUikppRRKCCGUUkpKKaVUSgmhhBJKKSWllFJKIYQQSikFAAAcOAAABBhBJxlVFmGjCRcegEJDVgIAZAAAkKKUUiktRYIipRikGEtGFXNQWoqocgxSzalSziDmJJaIMYSUk1Qy5hRCDELqHHVMKQYtlRhCxhik2HJLoXMOAAAAQQCAgJAAAAMEBTMAwOAA4XMQdAIERxsAgCBEZohEw0JweFAJEBFTAUBigkIuAFRYXKRdXECXAS7o4q4DIQQhCEEsDqCABByccMMTb3jC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QAQgIAHIpiWZrmeZ4niqapmiRJ0zxPFEXRNE1TVUmSpnmeKIqiaZqmqrIsTfM8URRF01RVVYWmeZ4oiqJpqqrqwvM8TxRF0TRV1XXheZ4niqJomqrquhBFUTRN01RNVXVdIIqmaZqqqqquC0RPFE1TVV3XdYHniaJpqqqrui4QTdNUVVV1XVkGmKZpqqrryjJAVVXVdV1XlgGqqqqu67qyDFBV13VdWZZlAK7rurIsywIAAA4cAAACjKCTjCqLsNGECw9AoSErAoAoAADAGKYUU8owJiGkEBrGJIQUQiYlpdJSqiCkUlIpFYRUSiolo5RSailVEFIpqZQKQiollVIAANiBAwDYgYVQaMhKACAPAIAwRinGGHNOIqQUY845JxFSijHnnJNKMeacc85JKRlzzDnnpJTOOeecc1JK5pxzzjkppXPOOeeclFJK55xzTkopJYTOQSellNI555wTAABU4AAAEGCjyOYEI0GFhqwEAFIBAAyOY1ma5nmiaJqWJGma53meKJqmJkma5nmeJ4qqyfM8TxRF0TRVled5niiKommqKtcVRdM0TVVVXbIsiqZpmqrqujBN01RV13VdmKZpqqrrui5sW1VV1XVlGbatqqrqurIMXNd1ZdmWgSy7ruzasgAA8AQHAKACG1ZHOCkaCyw0ZCUAkAEAQBiDkEIIIWUQQgohhJRSCAkAABhwAAAIMKEMFBqyEgBIBQAAjLHWWmuttdZAZ6211lprrYDMWmuttdZaa6211lprrbXWUmuttdZaa6211lprrbXWWmuttdZaa6211lprrbXWWmuttdZaa6211lprrbXWWmuttdZaay2llFJKKaWUUkoppZRSSimllFJKBQD6VTgA+D/YsDrCSdFYYKEhKwGAcAAAwBilGHMMQimlVAgx5px0VFqLsUKIMeckpNRabMVzzkEoIZXWYiyecw5CKSnFVmNRKYRSUkottliLSqGjklJKrdVYjDGppNZai63GYoxJKbTUWosxFiNsTam12GqrsRhjayottBhjjMUIX2RsLabaag3GCCNbLC3VWmswxhjdW4ultpqLMT742lIsMdZcAAB3gwMARIKNM6wknRWOBhcashIACAkAIBBSijHGGHPOOeekUow55pxzD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AAAAIAAAABAAAAEQAAAAEAAAABAAAAEgAAAAIAAAABAAAAFAAAAAEAAAABAAAAFQAAAAIAAAABAAAAFgAAAAEAAAABAAAAFwAAAAIAAAABAAAAGAAAAAEAAAABAAAAGQAAAAIAAAABAAAAGgAAAAEAAAABAAAAGwAAAAIAAAABAAAAHQAAAAEAAAABAAAAHgAAAAIAAAABAAAAHwAAAAQAAAABAAAA4HN0c3oAAAAAAAAAAAAAADMAAAAaAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAACMc3RjbwAAAAAAAAAfAAAALAAAA1UAAANyAAADhgAAA6IAAAO+AAAD0QAAA+0AAAQAAAAEHAAABC8AAARLAAAEZwAABHoAAASWAAAEqQAABMUAAATYAAAE9AAABRAAAAUjAAAFPwAABVIAAAVuAAAFgQAABZ0AAAWwAAAFzAAABegAAAX7AAAGFwAAAGJ1ZHRhAAAAWm1ldGEAAAAAAAAAIWhkbHIAAAAAAAAAAG1kaXJhcHBsAAAAAAAAAAAAAAAALWlsc3QAAAAlqXRvbwAAAB1kYXRhAAAAAQAAAABMYXZmNTUuMzMuMTAw' ]) - }, - audio: function () { + } + + static audio () { return random.pick([ 'data:audio/wav;base64,UklGRkYCAABXQVZFZm10IBIAAAABAAEA6AMAANAHAAACABAAAABMSVNUAgAAAElORk9JU0ZUDAAAAExhdmY1NC4yMC40AGRhdGEAAgAA2/ct9q79DwTC/oD64wKYBZ/6dPz1/z78OgKSBC4DQP7J/WwCNgG/Ac0A8v11/6kFgwRU+1oAGf3q+MP+1vnI+usAfQIY/yIBNwPt+af5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jorHYTUSioxlZRiC6nEVkpqraQUYysx1dRajiGlGEtKsZWUWm0x1dZaqzViTErmnJTMOSolpdZKKq1lzknqILTUOSippNRiKinFyjlJHYSUMsiolJRaK6nEElKJrbQUYympxdRirinFFkNJLZaUWiypxNZijLW1VFMnpcWSUowllRhbrLm21moMpcRWSouxpJRbazHXFmOOoaQWSyuxlZRabLXl2FrLNbVUY0qt1hZjjTHllGutPafWYk0x1dparLnVllvMtedOSmullBZLSjG21mKNMeYcSmmtpBRbKSnG1lqtrcVcQymxldJaLKnE2GKstcVWY2qtxhZbraW1WmutvcZWWy6t1dxirD21lGusteZYU20FAAAMOAAABJhQBgoNWQkARAEAAMYwxhiERinHnJPSKOWcc1Iq5yCEkFLmHIQQUsqcg1BKS5lzEEpJKZSSUmqthVJSaq21AgAAChwAAAJs0JRYHKDQkJUAQCoAgMFxNE0UVdV1fV+xLFFUVdeVbeNXLE0UVVV2bVv4NVFUVde1bdsWfk0UVVV2Zdm2haKqurJt27JuC8Ooqq5r27Jt66iuq9u6rdu6L1RdWZZtW7d1Hde2dd32dV34GbNt67Zu677wIwxH3/gh5OP7dEIIAABPcAAAKrBhdYSTorHAQkNWAgAZAACAMUoZhRgzSDGmGGNMMcaYAACAAQcAgAATykChISsCgCgAAMA555xzzjnnnHPOOeecc84555xzjjHGGGOMMcYYY4wxxhhjjDHGGGOMMcYYY4wxxhhjTADAToQDwE6EhVBoyEoAIBwAAEAIISkppZRSShFTzkFJKaWUUqoUg4xKSimllFKkFHWUUkoppZQipaCkklJKKaWUSUkppZRSSimljDpKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppVRKKaWUUkoppZRSSimlFABg8uAAAJVg4wwrSWeFo8GFhqwEAHIDAACFGIMQQmmtpFRSSiVVzkEoJZSUSkoplZRSqpiDEEoqqaWSUkoptdJBKKGUUEopJZRSSiglhBBKCaGUVEIrqYRSSgehhBJCKaGEVEop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DAADLlmjIxWKxWTyIABgmGydGjRox4f8Tg+D4OAgc/BwEDn+UBD+qwH/+8Tny7///KO4IYDgcDgcDgcDgcCgQAAAKKBUFc/nnP30a5O0zyYzMNMkzKlPva2GXgMIBbwDQEAYDQNXGLT2EIgEhoFnQNDb4BAPD9wTFYGJBWJw/8AUWgMBQgIEg4KmAKGP/wRG0csCIWDaQxcFhYvv/8WYMUpEIkXhvnRef//kmsuLPH5OvSoAFKxrJIm26DP/7UsQEgAuBCYu8tQAxeSiuPNKO5Z3/4Vs8526Brv0OF5/Q4Vg2Gn4UQ8M9HJG84QRGX9TBu/0X9S5A3nK31Y8znHCqUHj6HOZ+ahiZxx5Y8PyzdYDwWFg=' ]) - }, - webvtt: function () { + } + + static webvtt () { return random.pick([ // 'data:text/vtt,' + encodeURIComponent('WEBVTT\n\n00:00:00.000 --> 00:00:00.001\ntest');, 'media/video/sample.vtt' // Todo: load from filesystem randomly: 'media/videos/*.{vtt}' ]) - }, - any: function () { + } + + static any () { return random.pick([ - make.files.image, - make.files.video, - make.files.audio + this.image, + this.video, + this.audio ]) } } + +module.exports = files diff --git a/lib/make/fonts.js b/lib/make/fonts.js index edd9cd8..0f26c13 100644 --- a/lib/make/fonts.js +++ b/lib/make/fonts.js @@ -2,17 +2,23 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -make.font = { - globalValue: function () { +const make = require('../make') +const random = require('../random') + +class font extends make { + static globalValue () { return random.pick(['inherit', 'initial', 'unset']) - }, - style: function () { + } + + static style () { return random.pick(['italic', 'normal', 'oblique', 'inherit']) - }, - variant: function () { + } + + static variant () { return random.pick(['normal', 'small-caps', 'inherit']) - }, - weight: function () { + } + + static weight () { return random.pick([ /* standard */ ['normal', 'bold'], @@ -21,8 +27,9 @@ make.font = { /* numeric values */ [100, 200, 300, 400, 500, 600, 700, 800, 900] ]) - }, - size: function () { + } + + static size () { return random.pick([ /* values */ ['xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'], @@ -33,25 +40,30 @@ make.font = { /* values */ make.unit.percent() ]) - }, - relativeSize: function () { + } + + static relativeSize () { let value = random.number(8) return random.item(['', '+', '-']) + value - }, - genericFamily: function () { + } + + static genericFamily () { return random.pick(['serif', 'sans-serif', 'cursive', 'fantasy', 'monospace']) - }, - familyName: function () { + } + + static familyName () { return random.pick(['Times New Roman', 'Arial', 'Courier', 'Helvetica']) - }, - family: function () { - let s = random.pick(make.font.familyName) + } + + static family () { + let s = random.pick(this.familyName) if (random.chance(8)) { - s += ', ' + random.pick(make.font.genericFamily) + s += ', ' + random.pick(this.genericFamily) } return s - }, - registeredFontFeatures: function () { + } + + static registeredFontFeatures () { return random.pick([ 'aalt', 'abvf', 'abvm', 'abvs', 'afrc', 'akhn', 'blwf', 'blwm', 'blws', 'calt', 'case', 'ccmp', 'cfar', 'cjct', 'clig', 'cpct', 'cpsp', 'cswh', @@ -69,24 +81,27 @@ make.font = { 'swsh', 'titl', 'tjmo', 'tnam', 'tnum', 'trad', 'twid', 'unic', 'valt', 'vatu', 'vert', 'vhal', 'vjmo', 'vkna', 'vkrn', 'vpal', 'vrt2', 'zero' ]) - }, - font: function () { + } + + static font() { let s = '' if (random.chance(4)) { - s += random.pick(make.font.style) + ' ' + s += random.pick(this.style) + ' ' } if (random.chance(4)) { - s += random.pick(make.font.variant) + ' ' + s += random.pick(this.variant) + ' ' } if (random.chance(4)) { - s += random.pick(make.font.weight) + ' ' + s += random.pick(this.weight) + ' ' } if (random.chance(4)) { s += make.number.any() + '/' } - s += make.font.size() + s += this.size() s += ' ' - s += make.font.family() + s += this.family() return s } } + +module.exports = font \ No newline at end of file diff --git a/lib/make/html.js b/lib/make/html.js index 2ed5bd9..c2de5b3 100644 --- a/lib/make/html.js +++ b/lib/make/html.js @@ -1,11 +1,22 @@ -make.html = { - tag: function () { +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +const make = require('../make') +const random = require('../random') + +class html extends make { + static tag () { return random.item(['a', 'abbr', 'acronym', 'address', 'applet', 'area', 'article', 'aside', 'audio', 'b', 'base', 'basefont', 'bdi', 'bdo', 'bgsound', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'command', 'content', 'data', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'font', 'foo', 'footer', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'iframe', 'image', 'img', 'input', 'ins', 'isindex', 'kbd', 'keygen', 'label', 'legend', 'li', 'link', 'listing', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meta', 'meter', 'multicol', 'nav', 'nobr', 'noembed', 'noframes', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'picture', 'plaintext', 'pre', 'progress', 'q', 'rb', 'rp', 'rt', 'rtc', 'ruby', 's', 'samp', 'script', 'section', 'select', 'shadow', 'slot', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr', 'xmp']) - }, - attribute: function () { // eslint-disable-line no-unused-vars + } + + static attribute () { return random.item(['accept', 'accept-charset', 'accesskey', 'action', 'align', 'alt', 'async', 'autocomplete', 'autofocus', 'autoplay', 'autosave', 'bgcolor', 'border', 'buffered', 'challenge', 'charset', 'checked', 'cite', 'class', 'code', 'codebase', 'color', 'cols', 'colspan', 'content', 'contenteditable', 'contextmenu', 'controls', 'coords', 'crossorigin', 'data', 'data-*', 'datetime', 'default', 'defer', 'dir', 'dirname', 'disabled', 'download', 'draggable', 'dropzone', 'enctype', 'for', 'form', 'formaction', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'http-equiv', 'icon', 'id', 'integrity', 'ismap', 'itemprop', 'keytype', 'kind', 'label', 'lang', 'language', 'list', 'loop', 'low', 'manifest', 'max', 'maxlength', 'minlength', 'media', 'method', 'min', 'multiple', 'muted', 'name', 'novalidate', 'open', 'optimum', 'pattern', 'ping', 'placeholder', 'poster', 'preload', 'radiogroup', 'readonly', 'rel', 'required', 'reversed', 'rows', 'rowspan', 'sandbox', 'scope', 'scoped', 'seamless', 'selected', 'shape', 'size', 'sizes', 'slot', 'span', 'spellcheck', 'src', 'srcdoc', 'srclang', 'srcset', 'start', 'step', 'style', 'summary', 'tabindex', 'target', 'title', 'type', 'usemap', 'value', 'width']) - }, - interfaceName: function () { // eslint-disable-line no-unused-vars + } + + static interfaceName () { return random.pick(['HTMLBRElement', 'HTMLTableSectionElement', 'HTMLDataListElement', 'HTMLTableElement', 'HTMLOListElement', 'HTMLFontElement', 'HTMLMapElement', 'HTMLButtonElement', 'HTMLFrameSetElement', 'HTMLDataElement', 'HTMLOptGroupElement', 'HTMLAnchorElement', 'HTMLLinkElement', 'HTMLObjectElement', 'HTMLHeadElement', 'HTMLProgressElement', 'HTMLFrameElement', 'HTMLTimeElement', 'HTMLTableCaptionElement', 'HTMLDivElement', 'HTMLDListElement', 'HTMLBodyElement', 'HTMLImageElement', 'HTMLTableRowElement', 'HTMLScriptElement', 'HTMLInputElement', 'HTMLMeterElement', 'HTMLFieldSetElement', 'HTMLHtmlElement', 'HTMLStyleElement', 'HTMLDetailsElement', 'HTMLTrackElement', 'HTMLBaseElement', 'HTMLTableColElement', 'HTMLSourceElement', 'HTMLPictureElement', 'HTMLSelectElement', 'HTMLLegendElement', 'HTMLHRElement', 'HTMLModElement', 'HTMLTemplateElement', 'HTMLAreaElement', 'HTMLFormElement', 'HTMLEmbedElement', 'HTMLSpanElement', 'HTMLParagraphElement', 'HTMLIFrameElement', 'HTMLTableCellElement', 'HTMLElement', 'HTMLMenuElement', 'HTMLTextAreaElement', 'HTMLHeadingElement', 'HTMLCanvasElement', 'HTMLOutputElement', 'HTMLQuoteElement', 'HTMLOptionElement', 'HTMLLIElement', 'HTMLAudioElement', 'HTMLMenuItemElement', 'HTMLParamElement', 'HTMLUListElement', 'HTMLLabelElement', 'HTMLDirectoryElement', 'HTMLTitleElement', 'HTMLPreElement', 'HTMLMetaElement', 'HTMLVideoElement']) } } + +module.exports = html diff --git a/lib/make/index.js b/lib/make/index.js new file mode 100644 index 0000000..e138f6d --- /dev/null +++ b/lib/make/index.js @@ -0,0 +1,91 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +class make { + static get number () { + return require('./numbers') + } + + static get alignment () { + return require('./alignment') + } + + static get arrays () { + return require('./arrays') + } + + static get colors () { + return require('./colors') + } + + static get command () { + return require('./command') + } + + static get crypto () { + return require('./crypto') + } + + static get datetime () { + return require('./datetime') + } + + static get files () { + return require('./files') + } + + static get font () { + return require('./fonts') + } + + static get html () { + return require('./html') + } + + static get mime () { + return require('./mime') + } + + static get network () { + return require('./network') + } + + static get shaders () { + return require('./shaders') + } + + static get style () { + return require('./style') + } + + static get text () { + return require('./text') + } + + static get time () { + return require('./time') + } + + static get typed () { + return require('./typed') + } + + static get types () { + return require('./types') + } + + static get unit () { + return require('./units') + } + + static get uri () { + return require('./uri') + } + + static get webgl () { + return require('./webgl') + } +} + +module.exports = make diff --git a/lib/make/init.js b/lib/make/init.js deleted file mode 100644 index 3d96dd0..0000000 --- a/lib/make/init.js +++ /dev/null @@ -1 +0,0 @@ -var make = {} // eslint-disable-line no-unused-vars diff --git a/lib/make/mime.js b/lib/make/mime.js index 1aa062b..1a7b28a 100644 --- a/lib/make/mime.js +++ b/lib/make/mime.js @@ -2,18 +2,21 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -make.mime = { - any: function () { - return random.pick([ - make.mime.standard, - make.mime.xml, - make.mime.image, - make.mime.media, - make.mime.form - ]) - }, +const make = require('../make') +const random = require('../random') - standard: function () { +class mime extends make { + static any () { + return random.pick([ + this.standard, + this.xml, + this.image, + this.media, + this.form + ]) + } + + static standard () { return random.pick([ 'text/html', 'text/html; charset=utf-8', @@ -25,9 +28,9 @@ make.mime = { 'application/x-shockwave-flash', 'application/x-test' ]) - }, + } - xml: function () { + static xml () { return random.pick([ 'application/xml', 'text/xml', @@ -38,9 +41,9 @@ make.mime = { 'application/rdf+xml', 'application/xslt+xml' ]) - }, + } - image: function () { + static image () { return random.pick([ 'image/jpeg', 'image/gif', @@ -48,9 +51,9 @@ make.mime = { 'image/mng', 'image/*' ]) - }, + } - media: function () { + static media () { return random.pick([ 'audio/mpeg', 'audio/ogg', @@ -60,9 +63,9 @@ make.mime = { 'video/mp4', 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"' ]) - }, + } - form: function () { + static form () { return random.pick([ 'application/x-www-form-urlencoded', 'multipart/form-data', @@ -70,3 +73,5 @@ make.mime = { ]) } } + +module.exports = mime diff --git a/lib/make/network.js b/lib/make/network.js index 4ce10b5..c7ebe02 100644 --- a/lib/make/network.js +++ b/lib/make/network.js @@ -2,8 +2,12 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -make.network = { - sdp () { +const make = require('../make') +const random = require('../random') +const utils = require('../utils') + +class network extends make { + static sdp () { // session description protocol template return [ 'v=0', @@ -37,8 +41,9 @@ make.network = { 'a=candidate:0 1 UDP 2113601791 192.168.129.33 65080 typ host', 'a=candidate:0 2 UDP 2113601790 192.168.129.33 62658 typ host' ].join('\n') - }, - IceCandidate () { + } + + static IceCandidate () { // https://tools.ietf.org/html/rfc5245#section-15 // candidate= return utils.block.block([ @@ -51,7 +56,7 @@ make.network = { ' ', random.pick([make.number.any]), ' ', - random.pick([make.network.goodHostnames]), + random.pick([this.goodHostnames]), ' ', random.pick([56187, make.number.any]), ' ', @@ -64,15 +69,16 @@ make.network = { ' ', random.pick(['raddr']), ' ', - random.pick([make.network.goodHostnames]), + random.pick([this.goodHostnames]), ' ', random.pick(['rport']), random.use([utils.block.block([' ', make.number.any])]) ]) ]) ]) - }, - SdpMid () { + } + + static SdpMid () { // m= return utils.block.block([ random.pick(['application', 'video', 'audio']), @@ -83,17 +89,18 @@ make.network = { ' ', make.number.any ]) - }, - Turn () { + } + + static Turn () { // https://tools.ietf.org/html/rfc7065#section-3.1 return utils.block.block([ // scheme - random.pick(make.network.PeerConnectionProtocols), + random.pick(this.PeerConnectionProtocols), ':', // turn-host random.pick([ - make.text.any, - make.network.hostname + this.any, + this.hostname ]), // turn-port random.use([utils.block.block([':', make.number.any])]), @@ -103,17 +110,20 @@ make.network = { '=', random.pick(['udp', 'tcp', make.text.any]) ]) - }, - PeerConnectionProtocols () { + } + + static PeerConnectionProtocols () { return ['turn', 'turns', 'stun', 'stuns'] - }, - randomIPv4 () { + } + + static randomIPv4 () { return random.pick([random.number(255), make.number.any]) + '.' + random.pick([random.number(255), make.number.any]) + '.' + random.pick([random.number(255), make.number.any]) + '.' + random.pick([random.number(255), make.number.any]) - }, - randomIPv6 () { + } + + static randomIPv6 () { let parts = [] for (let i = 0; i < 8; i++) { @@ -121,26 +131,30 @@ make.network = { } return parts.join(':') - }, - iceServer () { + } + + static iceServer () { return random.pick([ 'stun:23.21.150.121' ]) - }, - dtmf () { + } + + static dtmf () { return random.subset([ '*', '#', 'A', 'B', 'C', 'D', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' ], make.number.range()).join('') - }, - goodHostnames () { + } + + static goodHostnames () { return [ '0.0.0.0', '127.0.0.1:8080' ] - }, - badHostnames () { + } + + static badHostnames () { return [ 'google.org:8080', '::1', @@ -154,35 +168,40 @@ make.network = { '2001:db8::1:2', '2001:db8::1:1:1:1:1' ] - }, - hostname () { + } + + static hostname () { return random.pick([ this.randomIPv4, this.randomIPv6, this.goodHostnames, this.badHostnames ]) - }, - port () { + } + + static port () { return random.pick([80, 443, 21, 23, 9310]) - }, - hash () { + } + + static hash () { return random.pick([ '', '#', '#main-content', () => '#' + make.text.any() ]) - }, - path () { + } + + static path () { return random.pick([ '', '/', '/index.html', () => '/' + make.text.any() ]) - }, - protocol () { + } + + static protocol () { return random.pick([ 'http', 'https', @@ -191,16 +210,18 @@ make.network = { 'chrome', 'resource' ]) + ':' - }, - search () { + } + + static search () { return random.pick([ '', '?', '?foo=bar', () => '?' + make.text.any() ]) - }, - randomBitmask (list) { + } + + static randomBitmask (list) { if (list.length <= 1) { return list.join('') } @@ -212,3 +233,5 @@ make.network = { return mask } } + +module.exports = network diff --git a/lib/make/numbers.js b/lib/make/numbers.js index 3a06721..bbc6ee7 100644 --- a/lib/make/numbers.js +++ b/lib/make/numbers.js @@ -2,11 +2,15 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -make.number = { - bool: function () { +const make = require('../make') +const random = require('../random') + +class number extends make { + static bool () { return random.bool() - }, - float: function () { + } + + static float () { let n if (random.chance(32)) { switch (random.number(4)) { @@ -30,43 +34,52 @@ make.number = { n = random.float() } return n - }, - range: function () { - return random.pick([1, 2, 3, 4, 6, 8, 16, 32, 64, make.number.tiny]) - }, - frange: function (min, max, precision) { + } + + static range () { + return random.pick([1, 2, 3, 4, 6, 8, 16, 32, 64, number.tiny]) + } + + static frange (min, max, precision) { let x = Math.random() * (min - max) + max if (precision) { let power = Math.pow(10, precision || 0) x = Math.round(x * power) / power } return x - }, - tiny: function () { + } + + static tiny () { return Math.pow(2, random.number(12)) - }, - unsigned: function () { + } + + static unsigned () { if (random.chance(2)) { - return Math.abs(make.number.any()) + return Math.abs(number.any()) } return Math.pow(2, random.number(random.number(65))) + random.number(3) - 1 - }, - even: function (number) { + } + + static even(number) { return number % 2 === 1 ? ++number : number - }, - interesting: function () { + } + + static interesting () { return random.choose([ [10, [-128, -1, 0, 1, 16, 32, 64, 100, 127]], [7, [-32768, -129, 128, 255, 256, 512, 1000, 1024, 4096, 32767]], [1, [-2147483648, -100663046, -32769, 32768, 65535, 65536, 100663045, 2147483647]] ]) - }, - any: function () { + } + + static any () { let value = random.choose([ - [10, make.number.float], - [10, [make.number.range, make.number.tiny]], - [1, make.number.unsigned] + [10, number.float], + [10, [number.range, number.tiny]], + [1, number.unsigned] ]) return random.chance(10) ? -value : value } } + +module.exports = number diff --git a/lib/make/shaders.js b/lib/make/shaders.js index d2bb85d..7b332cc 100644 --- a/lib/make/shaders.js +++ b/lib/make/shaders.js @@ -2,133 +2,148 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -make.shaders = { - fragment1: [ - [ - '#ifdef GL_ES', - 'precision mediump float;', - '#endif', - 'varying vec4 vColor;', - 'void main() {', - 'gl_FragColor=vColor;', - '}' - ], - [ - 'varying highp vec2 vTextureCoord;', - 'varying highp vec3 vLighting;', - 'uniform sampler2D uSampler;', - 'void main(void) {', - 'highp vec4 texelColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t));', - 'gl_FragColor = vec4(texelColor.rgb * vLighting, texelColor.a);', - '}' +const make = require('../make') +const random = require('../random') + +class shaders extends make { + static get fragment1 () { + return [ + [ + '#ifdef GL_ES', + 'precision mediump float;', + '#endif', + 'varying vec4 vColor;', + 'void main() {', + 'gl_FragColor=vColor;', + '}' + ], + [ + 'varying highp vec2 vTextureCoord;', + 'varying highp vec3 vLighting;', + 'uniform sampler2D uSampler;', + 'void main(void) {', + 'highp vec4 texelColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t));', + 'gl_FragColor = vec4(texelColor.rgb * vLighting, texelColor.a);', + '}' + ] ] - ], - vertex1: [ - [ - 'attribute vec4 aVertex;', - 'attribute vec4 aColor;', - 'varying vec4 vColor;', - 'void main(){', - 'vColor=aColor;', - 'gl_Position=aVertex;', - '}' - ], - [ - 'attribute highp vec3 aVertexNormal;', - 'attribute highp vec3 aVertexPosition;', - 'attribute highp vec2 aTextureCoord;', - 'uniform highp mat4 uNormalMatrix;', - 'uniform highp mat4 uMVMatrix;', - 'uniform highp mat4 uPMatrix;', - 'varying highp vec2 vTextureCoord;', - 'varying highp vec3 vLighting;', - 'void main(void) {', - 'gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);', - 'vTextureCoord = aTextureCoord;', - 'highp vec3 ambientLight = vec3(0.6, 0.6, 0.6);', - 'highp vec3 directionalLightColor = vec3(0.5, 0.5, 0.75);', - 'highp vec3 directionalVector = vec3(0.85, 0.8, 0.75);', - 'highp vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0);', - 'highp float directional = max(dot(transformedNormal.xyz, directionalVector), 0.0);', - 'vLighting = ambientLight + (directionalLightColor * directional);', - '}' + } + + static get vertex1() { + return [ + [ + 'attribute vec4 aVertex;', + 'attribute vec4 aColor;', + 'varying vec4 vColor;', + 'void main(){', + 'vColor=aColor;', + 'gl_Position=aVertex;', + '}' + ], + [ + 'attribute highp vec3 aVertexNormal;', + 'attribute highp vec3 aVertexPosition;', + 'attribute highp vec2 aTextureCoord;', + 'uniform highp mat4 uNormalMatrix;', + 'uniform highp mat4 uMVMatrix;', + 'uniform highp mat4 uPMatrix;', + 'varying highp vec2 vTextureCoord;', + 'varying highp vec3 vLighting;', + 'void main(void) {', + 'gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);', + 'vTextureCoord = aTextureCoord;', + 'highp vec3 ambientLight = vec3(0.6, 0.6, 0.6);', + 'highp vec3 directionalLightColor = vec3(0.5, 0.5, 0.75);', + 'highp vec3 directionalVector = vec3(0.85, 0.8, 0.75);', + 'highp vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0);', + 'highp float directional = max(dot(transformedNormal.xyz, directionalVector), 0.0);', + 'vLighting = ambientLight + (directionalLightColor * directional);', + '}' + ] ] - ], - fragment2: [ - [ - 'varying highp vec2 vTextureCoord;', - 'varying highp vec3 vLighting;', - 'uniform sampler2D uSampler;', - 'void main(void) {', - 'highp vec4 texelColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t));', - 'gl_FragColor = vec4(texelColor.rgb * vLighting, texelColor.a);', - '}' - ], - [ - '#version proto-200', - 'uniform sampler2D albedoMap;', - 'uniform sampler2D normalMap;', - 'varying vec3 varyingTangent;', - 'varying vec3 varyingBitangent;', - 'varying vec3 varyingNormal;', - 'varying vec2 varyingUV;', - 'void main(void) {', - 'vec3 albedo=texture2D(albedoMap,varyingUV).rgb;', - 'vec3 normal=texture2D(normalMap,varyingUV).rgb*2.0-1.0;', - 'float specularFactor=pow((albedo.r+albedo.g+albedo.b)*0.33,2.0);', - 'float specularHardness=2.0;', - 'vec3 spaceNormal=varyingTangent*normal.x+varyingBitangent*normal.y+varyingNormal*normal.z;', - 'gl_FragData[0]=vec4(albedo,1.0);', - 'gl_FragData[1]=vec4(spaceNormal*0.5 +0.5,1.0);', - 'gl_FragData[2]=vec4(specularFactor,specularHardness*0.1,0.0,1.0);', - '}' + } + + static get fragment2() { + return [ + [ + 'varying highp vec2 vTextureCoord;', + 'varying highp vec3 vLighting;', + 'uniform sampler2D uSampler;', + 'void main(void) {', + 'highp vec4 texelColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t));', + 'gl_FragColor = vec4(texelColor.rgb * vLighting, texelColor.a);', + '}' + ], + [ + '#version proto-200', + 'uniform sampler2D albedoMap;', + 'uniform sampler2D normalMap;', + 'varying vec3 varyingTangent;', + 'varying vec3 varyingBitangent;', + 'varying vec3 varyingNormal;', + 'varying vec2 varyingUV;', + 'void main(void) {', + 'vec3 albedo=texture2D(albedoMap,varyingUV).rgb;', + 'vec3 normal=texture2D(normalMap,varyingUV).rgb*2.0-1.0;', + 'float specularFactor=pow((albedo.r+albedo.g+albedo.b)*0.33,2.0);', + 'float specularHardness=2.0;', + 'vec3 spaceNormal=varyingTangent*normal.x+varyingBitangent*normal.y+varyingNormal*normal.z;', + 'gl_FragData[0]=vec4(albedo,1.0);', + 'gl_FragData[1]=vec4(spaceNormal*0.5 +0.5,1.0);', + 'gl_FragData[2]=vec4(specularFactor,specularHardness*0.1,0.0,1.0);', + '}' + ] ] - ], - vertex2: [ - [ - 'attribute highp vec3 aVertexNormal;', - 'attribute highp vec3 aVertexPosition;', - 'attribute highp vec2 aTextureCoord;', - 'uniform highp mat4 uNormalMatrix;', - 'uniform highp mat4 uMVMatrix;', - 'uniform highp mat4 uPMatrix;', - 'varying highp vec2 vTextureCoord;', - 'varying highp vec3 vLighting;', - 'void main(void) {', - 'gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);', - 'vTextureCoord = aTextureCoord;', - 'highp vec3 ambientLight = vec3(0.6, 0.6, 0.6);', - 'highp vec3 directionalLightColor = vec3(0.5, 0.5, 0.75);', - 'highp vec3 directionalVector = vec3(0.85, 0.8, 0.75);', - 'highp vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0);', - 'highp float directional = max(dot(transformedNormal.xyz, directionalVector), 0.0);', - 'vLighting = ambientLight + (directionalLightColor * directional);', - '}' - ], - [ - '#version proto-200', - 'attribute vec3 vertexPosition;', - 'attribute vec3 vertexTangent;', - 'attribute vec3 vertexBitangent;', - 'attribute vec3 vertexNormal;', - 'attribute vec2 vertexUV;', - 'uniform mat4 modelMatrix;', - 'uniform mat4 viewMatrix;', - 'varying vec3 varyingTangent;', - 'varying vec3 varyingBitangent;', - 'varying vec3 varyingNormal;', - 'varying vec2 varyingUV;', - 'void main(void){', - 'gl_Position=viewMatrix*(modelMatrix*vec4(vertexPosition,1.0));', - 'gl_Position.xy=gl_Position.xy*0.5+(float(gl_InstanceID)-0.5);', - 'varyingTangent=(modelMatrix*vec4(vertexTangent,0.0)).xyz;', - 'varyingBitangent=(modelMatrix*vec4(vertexBitangent,0.0)).xyz;', - 'varyingNormal=(modelMatrix*vec4(vertexNormal,0.0)).xyz;', - 'varyingUV = vertexUV;', - '}' + } + + static get vertex2() { + return [ + [ + 'attribute highp vec3 aVertexNormal;', + 'attribute highp vec3 aVertexPosition;', + 'attribute highp vec2 aTextureCoord;', + 'uniform highp mat4 uNormalMatrix;', + 'uniform highp mat4 uMVMatrix;', + 'uniform highp mat4 uPMatrix;', + 'varying highp vec2 vTextureCoord;', + 'varying highp vec3 vLighting;', + 'void main(void) {', + 'gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);', + 'vTextureCoord = aTextureCoord;', + 'highp vec3 ambientLight = vec3(0.6, 0.6, 0.6);', + 'highp vec3 directionalLightColor = vec3(0.5, 0.5, 0.75);', + 'highp vec3 directionalVector = vec3(0.85, 0.8, 0.75);', + 'highp vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0);', + 'highp float directional = max(dot(transformedNormal.xyz, directionalVector), 0.0);', + 'vLighting = ambientLight + (directionalLightColor * directional);', + '}' + ], + [ + '#version proto-200', + 'attribute vec3 vertexPosition;', + 'attribute vec3 vertexTangent;', + 'attribute vec3 vertexBitangent;', + 'attribute vec3 vertexNormal;', + 'attribute vec2 vertexUV;', + 'uniform mat4 modelMatrix;', + 'uniform mat4 viewMatrix;', + 'varying vec3 varyingTangent;', + 'varying vec3 varyingBitangent;', + 'varying vec3 varyingNormal;', + 'varying vec2 varyingUV;', + 'void main(void){', + 'gl_Position=viewMatrix*(modelMatrix*vec4(vertexPosition,1.0));', + 'gl_Position.xy=gl_Position.xy*0.5+(float(gl_InstanceID)-0.5);', + 'varyingTangent=(modelMatrix*vec4(vertexTangent,0.0)).xyz;', + 'varyingBitangent=(modelMatrix*vec4(vertexBitangent,0.0)).xyz;', + 'varyingNormal=(modelMatrix*vec4(vertexNormal,0.0)).xyz;', + 'varyingUV = vertexUV;', + '}' + ] ] - ], - shaderPair: function (v, f) { + } + + static shaderPair (v, f) { let i = random.number(v.length) return { vertex: utils.common.quote(v[i].join(' ')), @@ -136,3 +151,5 @@ make.shaders = { } } } + +module.exports = shaders diff --git a/lib/make/style.js b/lib/make/style.js index ad24b1c..11920b5 100644 --- a/lib/make/style.js +++ b/lib/make/style.js @@ -1,5 +1,12 @@ -make.style = { - pseudoElement: function () { +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +const make = require('../make') +const random = require('../random') + +class style extends make { + static pseudoElement () { return random.item([ '::after', '::before', @@ -14,3 +21,5 @@ make.style = { '::grammar-error']) } } + +module.exports = style diff --git a/lib/make/text.js b/lib/make/text.js index 3acf2c7..da1aec8 100644 --- a/lib/make/text.js +++ b/lib/make/text.js @@ -2,29 +2,36 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -make.text = { - lineEnd: function () { +const make = require('../make') +const random = require('../random') + +class text extends make { + static lineEnd () { return random.pick([ '\n', '\r', '\r\n', '\n\r' ]) - }, - controlChar: function () { + } + + static controlChar () { return random.pick([ '\b', '\t', '\n', '\v', '\f', '\r', '\0', '\c', '\a', '\e' // eslint-disable-line no-useless-escape ]) - }, - token: function () { + } + + static token () { return random.pick([ '*', '+', '%', '-', '!', '^', ':', '|', '&', '<', '>', '.', '"', '#', ' ', ';', ',', '{', '}', '(', ')', '[', ']', '/', '\\', '/*', '*/' ]) - }, - charset: function () { + } + + static charset () { return random.pick([ 'UTF-8', 'ISO-8859-1' ]) - }, - language: function () { + } + + static language () { return random.pick([ // special casing for i, I, dotted/dotless variants ['tr', 'az'], @@ -39,8 +46,9 @@ make.text = { // Seen in mxr ['en-US', 'fr', 'fra', 'de', 'ru', 'en-us', 'is-IS', 'xyzzy'] ]) - }, - layoutCharCodes: function () { + } + + static layoutCharCodes () { return random.pick([ 0, // null 160, // non-breaking space @@ -107,8 +115,9 @@ make.text = { 0x2064, // mathematical invisible separator 0x2044 // fraction slash character ]) - }, - bidiCharCodes: function () { + } + + static bidiCharCodes () { return random.pick([ 0x0660, // START_HINDI_DIGITS 0x0669, // END_HINDI_DIGITS @@ -119,9 +128,10 @@ make.text = { 0x06f0, // START_FARSI_DIGITS 0x06f9 // END_FARSI_DIGITS ]) - }, + } + // http://www.unicode.org/Public/6.0.0/ucd/UnicodeData.txt - unicodeCombiningCharacters: function () { + static unicodeCombiningCharacters () { return random.item([ [0x0300, 0x036F], // Combining Diacritical Marks [0x0483, 0x0489], @@ -142,14 +152,16 @@ make.text = { [0x1D1AA, 0x1D1AD], [0x1D242, 0x1D244] ]) - }, - unicodeBMP: function () { + } + + static unicodeBMP () { return random.item([ // BMP = Basic Multilingual Plane [0x0000, 0xFFFF] ]) - }, - unicodeSMP: function () { + } + + static unicodeSMP () { return random.item([ // SMP = Supplementary Multilingual Plane [0x10000, 0x13FFF], @@ -158,38 +170,44 @@ make.text = { [0x1D000, 0x1DFFF], [0x1F000, 0x1FFFF] ]) - }, - unicodeSIP: function () { + } + + static unicodeSIP () { return random.item([ // SIP = Supplementary Ideographic Plane [0x20000, 0x2BFFF], [0x2F000, 0x2FFFF] ]) - }, - unicodeSSP: function () { + } + + static unicodeSSP () { return random.item([ // SSP = Supplementary Special-purpose Plane [0xE0000, 0xE0FFF] ]) - }, - assignmentOperator: function () { + } + + static assignmentOperator () { return random.pick([ '=', '+=', '-=', '*=', '/=', '%=', '**=', '<<=', '>>=', '>>>=', '&=', '^=', '|=' ]) - }, - arithmeticOperator: function () { + } + + static arithmeticOperator () { return random.pick([ '%', '-', '+', '*', '/' ]) - }, - currency: function () { + } + + static currency () { return random.pick([ // https://en.wikipedia.org/wiki/ISO_4217 'USD', 'USS', 'USN', 'EUR', 'CHF', 'GBP', 'XAG', 'XBA', 'XBB', 'XBC', 'XBD', 'XSU', 'XTS', 'XXX' ]) - }, - fromBlocks: function (set, maxlen) { + } + + static fromBlocks (set, maxlen) { let s = '' for (let i = 0; i < random.number(maxlen || 255); i++) { @@ -197,21 +215,24 @@ make.text = { } return s - }, - quotedString: function () { - return utils.common.quote(make.text.any()) - }, - chars: function () { + } + + static quotedString () { + return utils.common.quote(this.any()) + } + + static chars () { return random.pick([ - make.text.controlChar, - make.text.token, - make.text.assignmentOperator, - make.text.arithmeticOperator, - String.fromCharCode(make.text.layoutCharCodes()), - String.fromCharCode(make.text.bidiCharCodes()) + this.controlChar, + this.token, + this.assignmentOperator, + this.arithmeticOperator, + String.fromCharCode(this.layoutCharCodes()), + String.fromCharCode(this.bidiCharCodes()) ]) - }, - any: function () { + } + + static any () { // Generate a string compromised of random individual characters // This might be too slow to used for all 'texts' uses let s = '' @@ -223,3 +244,5 @@ make.text = { return s } } + +module.exports = text diff --git a/lib/make/time.js b/lib/make/time.js index bf553e8..aad6c08 100644 --- a/lib/make/time.js +++ b/lib/make/time.js @@ -2,13 +2,19 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -make.time = { - unit: function () { +const make = require('../make') +const random = require('../random') + +class time extends make { + static unit () { return random.pick([ 's', 'ms' ]) - }, - any: function () { - return make.number.any() + make.time.unit() + } + + static any () { + return make.number.any() + this.unit() } } + +module.exports = time diff --git a/lib/make/typed.js b/lib/make/typed.js index 36d7a25..3b8fdb1 100644 --- a/lib/make/typed.js +++ b/lib/make/typed.js @@ -2,64 +2,71 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -make.typed = { - byte: function (limit = null) { +const make = require('../make') +const random = require('../random') + +class typed extends make { + static byte (limit = null) { // [-128, 127] let value = (limit !== null) ? random.number(limit) : random.number(129) value = random.chance(10) ? -value : value return 'new Uint8Array([' + value + '])[0]' - }, - octet: function (limit = null) { + } + + static octet (limit = null) { // [0, 255] let value = (limit !== null) ? random.number(limit) : random.number(256) return 'new Int8Array([' + value + '])[0]' - }, - short: function (limit = null) { + } + + static short (limit = null) { // [-32768, 32767] let value = (limit !== null) ? random.number(limit) : random.number(32769) value = random.chance(10) ? -value : value return 'new Int16Array([' + value + '])[0]' - }, - unsignedShort: function (limit = null) { + } + + static unsignedShort (limit = null) { // [0, 65535] let value = (limit !== null) ? random.number(limit) : random.number(65535) return 'new Uint16Array([' + value + '])[0]' - }, - long: function (limit = null) { + } + + static long (limit = null) { // [-2147483648, 2147483647] let value = (limit !== null) ? random.number(limit) : random.number(2147483649) value = random.chance(10) ? -value : value return 'new Int32Array([' + value + '])[0]' - }, - unsignedLong: function (limit = null) { + } + + static unsignedLong (limit = null) { // [0, 4294967295] let value = (limit !== null) ? random.number(limit) : random.number(4294967296) return 'new Uint32Array([' + value + '])[0]' - }, - // ToDo: Add support for longlong and ulonglong - /* - longLong: function () {}, - unsignedLongLong: function () {}, - */ - float: function (limit = null) { + } + + static float (limit = null) { let base = (limit !== null) ? random.number(limit) : random.number() let value = random.chance(10) ? -(base + random.float()) : (base + random.float()) return 'new Float32Array([' + value + '])[0]' - }, - unrestrictedFloat: function (limit = null) { + } + + static unrestrictedFloat (limit = null) { if (random.chance(100)) { return random.pick([NaN, +Infinity, -Infinity]) } else { let base = (limit !== null) ? random.number(limit) : random.number() return 'new Float32Array([' + (base + random.float()) + '])[0]' } - }, - double: function (limit = null) { + } + + static double (limit = null) { let base = (limit !== null) ? random.number(limit) : random.number() let value = random.chance(10) ? -(base + random.float()) : (base + random.float()) return 'new Float64Array([' + value + '])[0]' - }, - unrestrictedDouble: function (limit = null) { + } + + static unrestrictedDouble (limit = null) { if (random.chance(100)) { return random.pick([NaN, +Infinity, -Infinity]) } else { @@ -67,8 +74,9 @@ make.typed = { let value = random.chance(10) ? -(base + random.float()) : (base + random.float()) return 'new Float64Array([' + value + '])[0]' } - }, - any: function () { + } + + static any () { return random.choose([ [1, [this.byte, this.octet]], [1, [this.short, this.unsignedShort]], @@ -77,16 +85,19 @@ make.typed = { [1, [this.double, this.unrestrictedDouble]], [1, [make.number.range, make.number.tiny]] ]) - }, - arrayBuffer: function (byteLength = null) { + } + + static arrayBuffer (byteLength = null) { let length = (byteLength !== null) ? byteLength : this.unsignedShort() return 'new ArrayBuffer(' + length + ')' - }, - dataView: function (byteLength = null) { + } + + static dataView (byteLength = null) { let length = (byteLength !== null) ? byteLength : this.unsignedShort() return 'new DataView(' + this.arrayBuffer(length) + ')' - }, - typedArray: function (byteLength = null) { + } + + static typedArray (byteLength = null) { let length = (byteLength !== null) ? byteLength : this.unsignedShort() let arrType = random.item([ 'Int8', 'Uint8', 'Uint8Clamped', @@ -103,8 +114,9 @@ make.typed = { default: return method + '(' + length + ')' } - }, - bufferSource: function () { + } + + static bufferSource () { switch (random.number(4)) { case 0: return this.arrayBuffer() @@ -115,3 +127,5 @@ make.typed = { } } } + +module.exports = typed diff --git a/lib/make/types.js b/lib/make/types.js index 65a7897..4039826 100644 --- a/lib/make/types.js +++ b/lib/make/types.js @@ -2,8 +2,11 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -make.types = { - random: function () { +const make = require('../make') +const random = require('../random') + +class types extends make { + static random () { return random.item([ 'true', 'null', @@ -16,3 +19,5 @@ make.types = { ]) } } + +module.exports = types diff --git a/lib/make/units.js b/lib/make/units.js index 9217931..c27151a 100644 --- a/lib/make/units.js +++ b/lib/make/units.js @@ -2,16 +2,23 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -make.unit = { - unit: function () { +const make = require('../make') +const random = require('../random') + +class unit extends make { + static unit () { return random.pick([ 'px', 'em', 'ex', 'ch', 'rem', 'mm', 'cm', 'in', 'pt', 'pc', '%' ]) - }, - length: function () { + } + + static length () { return make.number.any() + make.unit.unit() - }, - percent: function () { + } + + static percent () { return make.number.any() + '%' } } + +module.exports = unit diff --git a/lib/make/uri.js b/lib/make/uri.js index bcb0a19..d65f2d9 100644 --- a/lib/make/uri.js +++ b/lib/make/uri.js @@ -2,17 +2,20 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -make.uri = { - problematic: function () { +const make = require('../make') +const random = require('../random') + +class uri extends make { + static problematic () { return random.item([ 'aim:yaz', // Often triggers an 'external protocol request' dialog 'foop:yaz', // Often triggers an unknown protocol 'about:memory', // Content is not allowed to link or load 'ws://localhost/' // WebSocket protocol ]) - }, + } - standard: function () { + static standard () { return random.item([ 'about:blank', 'about:srcdoc', @@ -29,17 +32,17 @@ make.uri = { 'ftp://localhost:6/', 'http://localhost:25/' ]) - }, + } - namespace: function () { + static namespace () { return random.item([ 'http://www.w3.org/1999/xhtml', 'http://www.w3.org/2000/svg', 'http://www.w3.org/1998/Math/MathML' ]) - }, + } - any: function () { + static any () { return random.choose([ [1, this.problematic], [10, this.standard], @@ -48,3 +51,5 @@ make.uri = { ]) } } + +module.exports = uri diff --git a/lib/make/webgl.js b/lib/make/webgl.js index db6f384..568a080 100644 --- a/lib/make/webgl.js +++ b/lib/make/webgl.js @@ -2,45 +2,52 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -make.webgl = { - internalFormat: { - 'RGB': {format: 'RGB', type: ['UNSIGNED_BYTE', 'UNSIGNED_SHORT_5_6_5']}, - 'RGBA': {format: 'RGBA', type: ['UNSIGNED_BYTE', 'UNSIGNED_SHORT_4_4_4_4', 'UNSIGNED_SHORT_5_5_5_1']}, - 'LUMINANCE_ALPHA': {format: 'LUMINANCE_ALPHA', type: ['UNSIGNED_BYTE']}, - 'LUMINANCE': {format: 'LUMINANCE', type: ['UNSIGNED_BYTE']}, - 'ALPHA': {format: 'ALPHA', type: ['UNSIGNED_BYTE']}, - 'R8': {format: 'RED', type: ['UNSIGNED_BYTE']}, - 'R16F': {format: 'RED', type: ['HALF_FLOAT', 'FLOAT']}, - 'R32F': {format: 'RED', type: ['FLOAT']}, - 'R8UI': {format: 'RED_INTEGER', type: ['UNSIGNED_BYTE']}, - 'RG8': {format: 'RG', type: ['UNSIGNED_BYTE']}, - 'RG16F': {format: 'RG', type: ['HALF_FLOAT', 'FLOAT']}, - 'RG32F': {format: 'RG', type: ['FLOAT']}, - 'RG8UI': {format: 'RG_INTEGER', type: ['UNSIGNED_BYTE']}, - 'RGB8': {format: 'RGB', type: ['UNSIGNED_BYTE']}, - 'SRGB8': {format: 'RGB', type: ['UNSIGNED_BYTE']}, - 'RGB565': {format: 'RGB', type: ['RGB', 'UNSIGNED_BYTE', 'UNSIGNED_SHORT_5_6_5']}, - 'R11F_G11F_B10F': {format: 'RGB', type: ['UNSIGNED_INT_10F_11F_11F_REV', 'HALF_FLOAT', 'FLOAT']}, - 'RGB9_E5': {format: 'RGB', type: ['HALF_FLOAT', 'FLOAT']}, - 'RGB16F': {format: 'RGB', type: ['HALF_FLOAT', 'FLOAT']}, - 'RGB32F': {format: 'RGB', type: ['FLOAT']}, - 'RGB8UI': {format: 'RGB_INTEGER', type: ['UNSIGNED_BYTE']}, - 'RGBA8': {format: 'RGBA', type: ['UNSIGNED_BYTE']}, - 'SRGB8_ALPHA8': {format: 'RGBA', type: ['UNSIGNED_BYTE']}, - 'RGB5_A1': {format: 'RGBA', type: ['UNSIGNED_BYTE', 'UNSIGNED_SHORT_5_5_5_1']}, - 'RGB10_A2': {format: 'RGBA', type: ['UNSIGNED_INT_2_10_10_10_REV']}, - 'RGBA4': {format: 'RGBA', type: ['UNSIGNED_BYTE', 'UNSIGNED_SHORT_4_4_4_4']}, - 'RGBA16F': {format: 'RGBA', type: ['HALF_FLOAT', 'FLOAT']}, - 'RGBA32F': {format: 'RGBA', type: ['FLOAT']}, - 'RGBA8UI': {format: 'RGBA_INTEGER', type: ['UNSIGNED_BYTE']} - }, - WebGLFormat: () => { - let internalformat = random.item(Object.keys(make.webgl.internalFormat)) - let format = make.webgl.internalFormat[internalformat].format - let type = random.item(make.webgl.internalFormat[internalformat].type) +const make = require('../make') +const random = require('../random') + +class webgl extends make { + static get internalFormat () { + return { + 'RGB': {format: 'RGB', type: ['UNSIGNED_BYTE', 'UNSIGNED_SHORT_5_6_5']}, + 'RGBA': {format: 'RGBA', type: ['UNSIGNED_BYTE', 'UNSIGNED_SHORT_4_4_4_4', 'UNSIGNED_SHORT_5_5_5_1']}, + 'LUMINANCE_ALPHA': {format: 'LUMINANCE_ALPHA', type: ['UNSIGNED_BYTE']}, + 'LUMINANCE': {format: 'LUMINANCE', type: ['UNSIGNED_BYTE']}, + 'ALPHA': {format: 'ALPHA', type: ['UNSIGNED_BYTE']}, + 'R8': {format: 'RED', type: ['UNSIGNED_BYTE']}, + 'R16F': {format: 'RED', type: ['HALF_FLOAT', 'FLOAT']}, + 'R32F': {format: 'RED', type: ['FLOAT']}, + 'R8UI': {format: 'RED_INTEGER', type: ['UNSIGNED_BYTE']}, + 'RG8': {format: 'RG', type: ['UNSIGNED_BYTE']}, + 'RG16F': {format: 'RG', type: ['HALF_FLOAT', 'FLOAT']}, + 'RG32F': {format: 'RG', type: ['FLOAT']}, + 'RG8UI': {format: 'RG_INTEGER', type: ['UNSIGNED_BYTE']}, + 'RGB8': {format: 'RGB', type: ['UNSIGNED_BYTE']}, + 'SRGB8': {format: 'RGB', type: ['UNSIGNED_BYTE']}, + 'RGB565': {format: 'RGB', type: ['RGB', 'UNSIGNED_BYTE', 'UNSIGNED_SHORT_5_6_5']}, + 'R11F_G11F_B10F': {format: 'RGB', type: ['UNSIGNED_INT_10F_11F_11F_REV', 'HALF_FLOAT', 'FLOAT']}, + 'RGB9_E5': {format: 'RGB', type: ['HALF_FLOAT', 'FLOAT']}, + 'RGB16F': {format: 'RGB', type: ['HALF_FLOAT', 'FLOAT']}, + 'RGB32F': {format: 'RGB', type: ['FLOAT']}, + 'RGB8UI': {format: 'RGB_INTEGER', type: ['UNSIGNED_BYTE']}, + 'RGBA8': {format: 'RGBA', type: ['UNSIGNED_BYTE']}, + 'SRGB8_ALPHA8': {format: 'RGBA', type: ['UNSIGNED_BYTE']}, + 'RGB5_A1': {format: 'RGBA', type: ['UNSIGNED_BYTE', 'UNSIGNED_SHORT_5_5_5_1']}, + 'RGB10_A2': {format: 'RGBA', type: ['UNSIGNED_INT_2_10_10_10_REV']}, + 'RGBA4': {format: 'RGBA', type: ['UNSIGNED_BYTE', 'UNSIGNED_SHORT_4_4_4_4']}, + 'RGBA16F': {format: 'RGBA', type: ['HALF_FLOAT', 'FLOAT']}, + 'RGBA32F': {format: 'RGBA', type: ['FLOAT']}, + 'RGBA8UI': {format: 'RGBA_INTEGER', type: ['UNSIGNED_BYTE']} + } + } + + static WebGLFormat () { + let internalformat = random.item(Object.keys(this.internalFormat)) + let format = this.internalFormat[internalformat].format + let type = random.item(this.internalFormat[internalformat].type) return [internalformat, format, type] - }, - textureSources: () => { + } + + static textureSources () { let sources = [ 'HTMLCanvasElement', 'HTMLImageElement', @@ -48,30 +55,35 @@ make.webgl = { 'ImageData' ] return random.item(sources) - }, - parseUniforms: (shader) => { + } + + static parseUniforms (shader) { let names = [] let result = shader.match(/uniform .* (\w+)(?=;)/gm) if (result) { result.forEach((v) => names.push(v.split(' ').pop())) } return names - }, - parseAttributes: (shader) => { + } + + static parseAttributes (shader) { let names = [] let result = shader.match(/attribute .* (\w+)(?=;)/gm) if (result) { result.forEach((v) => names.push(v.split(' ').pop())) } return names - }, - parseFrag: (shader) => { + } + + static parseFrag (shader) { return shader.match(/(gl_Frag[^[ =]+)/gm) - }, - randomBitmask: () => { + } + + static randomBitmask () { return parseInt((random.subset([1, 0], 8).join(''))) - }, - randomBufferTarget: (isWebGL2) => { + } + + static randomBufferTarget (isWebGL2) { let target = [ 'ARRAY_BUFFER', 'ELEMENT_ARRAY_BUFFER' @@ -87,8 +99,9 @@ make.webgl = { ]) } return random.item(target) - }, - randomTexParameter: (isWebGL2) => { + } + + static randomTexParameter (isWebGL2) { let pname = [ 'TEXTURE_MAG_FILTER', 'TEXTURE_MIN_FILTER', @@ -107,8 +120,9 @@ make.webgl = { ]) } return random.item(pname) - }, - randomTexParameterValue: (isWebGL2) => { + } + + static randomTexParameterValue (isWebGL2) { let pnameparam = { 'TEXTURE_MAG_FILTER': [ 'LINEAR', @@ -174,8 +188,9 @@ make.webgl = { let pname = random.item(Object.keys(pnameparam)) let param = random.item(pnameparam[pname]) return [pname, param] - }, - randomBlendMode: (isWebGL2) => { + } + + static randomBlendMode (isWebGL2) { let mode = [ 'FUNC_ADD', 'FUNC_SUBTRACT', @@ -188,8 +203,9 @@ make.webgl = { ]) } return random.item(mode) - }, - randomBlendFactor: (isWebGL2) => { + } + + static randomBlendFactor (isWebGL2) { let factor = [ 'ZERO', 'ONE', @@ -208,16 +224,18 @@ make.webgl = { 'SRC_ALPHA_SATURATE' ] return random.item(factor) - }, - randomFace: (isWebGL2) => { + } + + static randomFace (isWebGL2) { let mode = [ 'FRONT', 'BACK', 'FRONT_AND_BACK' ] return random.item(mode) - }, - randomTexImage2DTarget: (isWebGL2) => { + } + + static randomTexImage2DTarget (isWebGL2) { let target = [ 'TEXTURE_2D', 'TEXTURE_CUBE_MAP_POSITIVE_X', @@ -228,8 +246,9 @@ make.webgl = { 'TEXTURE_CUBE_MAP_NEGATIVE_Z' ] return random.item(target) - }, - randomTextureTarget: (isWebGL2) => { + } + + static randomTextureTarget (isWebGL2) { let target = [ 'TEXTURE_2D', 'TEXTURE_CUBE_MAP' @@ -241,8 +260,9 @@ make.webgl = { ]) } return random.item(target) - }, - randomFunc: (isWebGL2) => { + } + + static randomFunc (isWebGL2) { let func = [ 'NEVER', 'LESS', @@ -254,8 +274,9 @@ make.webgl = { 'ALWAYS' ] return random.item(func) - }, - randomCap: (isWebGL2) => { + } + + static randomCap (isWebGL2) { let cap = [ 'BLEND', 'CULL_FACE', @@ -273,8 +294,9 @@ make.webgl = { ]) } return random.item(cap) - }, - randomPrimitive: (isWebGL2) => { + } + + static randomPrimitive (isWebGL2) { let mode = [ 'POINTS', 'LINE_STRIP', @@ -285,8 +307,9 @@ make.webgl = { 'TRIANGLES' ] return random.item(mode) - }, - randomTextureAttachment: (isWebGL2) => { + } + + static randomTextureAttachment (isWebGL2) { let attachment = [ 'COLOR_ATTACHMENT0', 'DEPTH_ATTACHMENT', @@ -299,8 +322,9 @@ make.webgl = { ]) } return random.item(attachment) - }, - randomAttachmentQuery: (isWebGL2) => { + } + + static randomAttachmentQuery (isWebGL2) { let pname = [ 'FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE', 'FRAMEBUFFER_ATTACHMENT_OBJECT_NAME', @@ -321,8 +345,9 @@ make.webgl = { ]) } return random.item(pname) - }, - randomShaderPrecision: (isWebGL2) => { + } + + static randomShaderPrecision (isWebGL2) { let precisiontype = [ 'LOW_FLOAT', 'MEDIUM_FLOAT', @@ -332,8 +357,9 @@ make.webgl = { 'HIGH_INT' ] return random.item(precisiontype) - }, - randomStencilRefParameter: (isWebGL2) => { + } + + static randomStencilRefParameter (isWebGL2) { let param = [ 'STENCIL_FUNC', 'STENCIL_VALUE_MASK', @@ -344,16 +370,18 @@ make.webgl = { 'STENCIL_BITS' ] return random.item(param) - }, - randomStencilMaskParameter: (isWebGL2) => { + } + + static randomStencilMaskParameter (isWebGL2) { let param = [ 'STENCIL_WRITEMASK', 'STENCIL_BACK_WRITEMASK', 'STENCIL_BITS' ] return random.item(param) - }, - randomVertexAttribParameter: (isWebGL2) => { + } + + static randomVertexAttribParameter (isWebGL2) { let pname = [ 'VERTEX_ATTRIB_ARRAY_BUFFER_BINDING', 'VERTEX_ATTRIB_ARRAY_ENABLED', @@ -371,8 +399,9 @@ make.webgl = { ]) } return random.item(pname) - }, - randomHint: (isWebGL2) => { + } + + static randomHint (isWebGL2) { let target = [ 'GENERATE_MIPMAP_HINT' ] @@ -382,16 +411,18 @@ make.webgl = { ]) } return random.item(target) - }, - randomHintMode: (isWebGL2) => { + } + + static randomHintMode (isWebGL2) { let mode = [ 'FASTEST', 'NICEST', 'DONT_CARE' ] return random.item(mode) - }, - randomPixelStorage: (isWebGL2) => { + } + + static randomPixelStorage (isWebGL2) { let pname = { 'PACK_ALIGNMENT': random.item([1, 2, 4, 8]), 'UNPACK_ALIGNMENT': random.item([1, 2, 4, 8]), @@ -416,8 +447,9 @@ make.webgl = { } let name = random.item(Object.keys(pname)) return [name, pname[name]] - }, - randomStencilAction: (isWebGL2) => { + } + + static randomStencilAction (isWebGL2) { let action = [ 'KEEP', 'ZERO', @@ -429,24 +461,27 @@ make.webgl = { 'INVERT' ] return random.item(action) - }, - randomQueryTarget: (isWebGL2) => { + } + + static randomQueryTarget (isWebGL2) { let target = [ 'ANY_SAMPLES_PASSED', 'ANY_SAMPLES_PASSED_CONSERVATIVE', 'TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN' ] return random.item(target) - }, - randomQueryPname: (isWebGL2) => { + } + + static randomQueryPname (isWebGL2) { let pname = [ 'CURRENT_QUERY', 'QUERY_RESULT', 'QUERY_RESULT_AVAILABLE' ] return random.item(pname) - }, - randomSamplerParameter: (isWebGL2) => { + } + + static randomSamplerParameter (isWebGL2) { let pname = [ 'TEXTURE_MAG_FILTER', 'TEXTURE_MIN_FILTER', @@ -462,8 +497,9 @@ make.webgl = { 'TEXTURE_MAX_ANISOTROPY_EXT' ] return random.item(pname) - }, - randomSyncParameter: (isWebGL2) => { + } + + static randomSyncParameter (isWebGL2) { let pname = [ 'OBJECT_TYPE', 'SYNC_STATUS', @@ -471,8 +507,9 @@ make.webgl = { 'SYNC_FLAGS' ] return random.item(pname) - }, - randomClearBuffer: (isWebGL2) => { + } + + static randomClearBuffer (isWebGL2) { let buffer = [ 'COLOR', 'DEPTH', @@ -480,15 +517,17 @@ make.webgl = { 'DEPTH_STENCIL' ] return random.item(buffer) - }, - randomBindBufferTarget: (isWebGL2) => { + } + + static randomBindBufferTarget (isWebGL2) { let target = [ 'TRANSFORM_FEEDBACK_BUFFER', 'UNIFORM_BUFFER' ] return random.item(target) - }, - randomIndexedParameterTarget: (isWebGL2) => { + } + + static randomIndexedParameterTarget (isWebGL2) { let target = [ 'TRANSFORM_FEEDBACK_BUFFER_BINDING', 'TRANSFORM_FEEDBACK_BUFFER_SIZE', @@ -498,8 +537,9 @@ make.webgl = { 'UNIFORM_BUFFER_START' ] return random.item(target) - }, - randomUniformParameter: (isWebGL2) => { + } + + static randomUniformParameter (isWebGL2) { let pname = [ 'UNIFORM_TYPE', 'UNIFORM_SIZE', @@ -510,8 +550,9 @@ make.webgl = { 'UNIFORM_IS_ROW_MAJOR' ] return random.item(pname) - }, - randomUniformBlockParameter: (isWebGL2) => { + } + + static randomUniformBlockParameter (isWebGL2) { let pname = [ 'UNIFORM_BLOCK_BINDING', 'UNIFORM_BLOCK_DATA_SIZE', @@ -521,8 +562,9 @@ make.webgl = { 'UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER' ] return random.item(pname) - }, - randomPixelDatatype: (isWebGL2) => { + } + + static randomPixelDatatype (isWebGL2) { let type = [ 'UNSIGNED_BYTE', 'UNSIGNED_SHORT', @@ -533,8 +575,9 @@ make.webgl = { 'FLOAT' ] return random.item(type) - }, - randomBufferUsage: (isWebGL2) => { + } + + static randomBufferUsage (isWebGL2) { let usage = [ 'STATIC_DRAW', 'DYNAMIC_DRAW', @@ -553,3 +596,5 @@ make.webgl = { return random.item(usage) } } + +module.exports = webgl diff --git a/lib/random/index.js b/lib/random/index.js new file mode 100644 index 0000000..574274c --- /dev/null +++ b/lib/random/index.js @@ -0,0 +1,5 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +module.exports = require('./random') diff --git a/lib/random/mersennetwister.js b/lib/random/mersennetwister.js index ddf8e20..18b298f 100644 --- a/lib/random/mersennetwister.js +++ b/lib/random/mersennetwister.js @@ -9,67 +9,68 @@ * */ -function MersenneTwister () { // eslint-disable-line no-unused-vars - const N = 624 - const M = 397 - const UPPER_MASK = 0x80000000 - const LOWER_MASK = 0x7fffffff - const MAG01 = new Int32Array([0, 0x9908b0df]) +class MersenneTwister { + constructor () { + this.N = 624 + this.M = 397 + this.UPPER_MASK = 0x80000000 + this.LOWER_MASK = 0x7fffffff + this.MAG01 = new Int32Array([0, 0x9908b0df]) - let mt = new Int32Array(N) - /* the array for the state vector */ - let mti = 625 + this.mt = new Int32Array(this.N) + this.mti = 625 // The array for the state vector. + } - this.seed = function (s) { - mt[0] = s | 0 - for (mti = 1; mti < N; mti++) { - mt[mti] = Math.imul(1812433253, mt[mti - 1] ^ (mt[mti - 1] >>> 30)) + mti + seed (s) { + this.mt[0] = s | 0 + for (this.mti = 1; this.mti < this.N; this.mti++) { + this.mt[this.mti] = Math.imul(1812433253, this.mt[this.mti - 1] ^ (this.mt[this.mti - 1] >>> 30)) + this.mti } } - this.export_state = function () { - return [mt, mti] + export_state () { + return [this.mt, this.mti] } - this.import_state = function (s) { - mt = s[0] - mti = s[1] + import_state (s) { + this.mt = s[0] + this.mti = s[1] } - this.export_mta = function () { - return mt + export_mta () { + return this.mt } - this.import_mta = function (_mta) { - mt = _mta + import_mta (_mta) { + this.mt = _mta } - this.export_mti = function () { - return mti + export_mti () { + return this.mti } - this.import_mti = function (_mti) { - mti = _mti + import_mti (_mti) { + this.mti = _mti } - this.int32 = function () { + int32 () { let y, kk - if (mti >= N) { /* generate N words at one time */ - for (kk = 0; kk < N - M; kk++) { - y = ((mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK)) - mt[kk] = (mt[kk + M] ^ (y >>> 1) ^ MAG01[y & 0x1]) + if (this.mti >= this.N) { /* generate N words at one time */ + for (kk = 0; kk < this.N - this.M; kk++) { + y = ((this.mt[kk] & this.UPPER_MASK) | (this.mt[kk + 1] & this.LOWER_MASK)) + this.mt[kk] = (this.mt[kk + this.M] ^ (y >>> 1) ^ this.MAG01[y & 0x1]) } - for (; kk < N - 1; kk++) { - y = ((mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK)) - mt[kk] = (mt[kk + (M - N)] ^ (y >>> 1) ^ MAG01[y & 0x1]) + for (; kk < this.N - 1; kk++) { + y = ((this.mt[kk] & this.UPPER_MASK) | (this.mt[kk + 1] & this.LOWER_MASK)) + this.mt[kk] = (this.mt[kk + (this.M - this.N)] ^ (y >>> 1) ^ this.MAG01[y & 0x1]) } - y = ((mt[N - 1] & UPPER_MASK) | (mt[0] & LOWER_MASK)) - mt[N - 1] = (mt[M - 1] ^ (y >>> 1) ^ MAG01[y & 0x1]) - mti = 0 + y = ((this.mt[this.N - 1] & this.UPPER_MASK) | (this.mt[0] & this.LOWER_MASK)) + this.mt[this.N - 1] = (this.mt[this.M - 1] ^ (y >>> 1) ^ this.MAG01[y & 0x1]) + this.mti = 0 } - y = mt[mti++] + y = this.mt[this.mti++] /* Tempering */ y = y ^ (y >>> 11) @@ -80,9 +81,9 @@ function MersenneTwister () { // eslint-disable-line no-unused-vars return y >>> 0 } - this.real2 = function () { + real2 () { return ((this.int32() >>> 5) * 67108864.0 + (this.int32() >>> 6)) / 9007199254740992.0 } } -module.exports = { MersenneTwister } \ No newline at end of file +module.exports = MersenneTwister diff --git a/lib/random/random.js b/lib/random/random.js index 247a3c4..e98f91b 100644 --- a/lib/random/random.js +++ b/lib/random/random.js @@ -3,27 +3,27 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ const MersenneTwister = require('./mersennetwister') +const {logger} = require('../logging') -var random = { // eslint-disable-line no-unused-vars - seed: null, - twister: null, +class random { /** * Must be called before any other methods can be called to initialize MersenneTwister. * @param {number|null|undefined} seed Value to initialize MersenneTwister. */ - init: function (seed) { + static init (seed) { if (seed === null || seed === undefined) { this.seed = new Date().getTime() } - this.twister = new MersenneTwister.MersenneTwister() + this.twister = new MersenneTwister() this.twister.seed(this.seed) - }, - number: function (limit) { - // Returns an integer in [0, limit). Uniform distribution. - if (limit === 0) { - return limit - } + } + + /** + * Returns an integer in [0, limit). Uniform distribution. + * @param limit + */ + static number (limit) { if (limit === null || limit === undefined) { limit = 0xffffffff } @@ -34,42 +34,64 @@ var random = { // eslint-disable-line no-unused-vars r = this.twister.int32() } while (y && r >= y) // eslint-disable-line no-unmodified-loop-condition return (r / x) >>> 0 - }, - float: function () { - // Returns a float in [0, 1). Uniform distribution. + } + + /** + * Returns a float in [0, 1). Uniform distribution. + */ + static float () { return this.twister.real2() - }, - range: function (start, limit) { - // Returns an integer in [start, limit]. Uniform distribution. + } + + /** + * Returns an integer in [start, limit]. Uniform distribution. + * @param start + * @param limit + */ + static range (start, limit) { if (isNaN(start) || isNaN(limit)) { logger.traceback() - throw new TypeError('random.range() received a non number type: \'' + start + '\', \'' + limit + '\')') + throw new TypeError(`random.range() received non-number type: (${start}, ${limit})`) } return this.number(limit - start + 1) + start - }, - ludOneTo: function (limit) { - // Returns a float in [1, limit]. The logarithm has uniform distribution. + } + + /** + * Returns a float in [1, limit]. The logarithm has uniform distribution. + * @param {*} limit + */ + static ludOneTo (limit) { return Math.exp(this.float() * Math.log(limit)) - }, - item: function (list) { + } + + static item (list) { if (list === undefined || typeof list === 'string' || list.length === undefined) { logger.traceback() - throw new TypeError('random.item() received an invalid object: \'' + list + '\'') + throw new TypeError(`random.item() received invalid object: (${list})`) } - return list[this.number(list.length)] - }, - key: function (obj) { + } + + /** + * Returns a random key of a provided object. + * @param {*} obj + */ + static key (obj) { let list = [] for (let i in obj) { list.push(i) } return this.item(list) - }, - bool: function () { + } + + /** + * Return a random Boolean value. + */ + static bool () { return this.item([true, false]) - }, - pick: function (obj) { + } + + static pick (obj) { if (typeof obj === 'function') { return obj() } @@ -77,21 +99,23 @@ var random = { // eslint-disable-line no-unused-vars return this.pick(this.item(obj)) } return obj - }, - chance: function (limit) { + } + + static chance (limit) { if (limit === null || limit === undefined) { limit = 2 } if (isNaN(limit)) { logger.traceback() - throw new TypeError('random.chance() received a non number type: \'' + limit + '\'') + throw new TypeError(`random.chance() received non-number type: (${limit})`) } return this.number(limit) === 1 - }, - choose: function (list, flat) { + } + + static choose (list, flat) { if (!(Array.isArray(list))) { logger.traceback() - throw new TypeError('random.choose() received a non-array type: \'' + list + '\'') + throw new TypeError(`random.choose() received non-array type: (${list})`) } let total = 0 for (let i = 0; i < list.length; i++) { @@ -112,9 +136,13 @@ var random = { // eslint-disable-line no-unused-vars return list[0][1] } return this.pick([list[0][1]]) - }, - weighted: function (wa) { - // More memory-hungry but hopefully faster than random.choose$flat + } + + /** + * More memory-hungry but hopefully faster than random.choose$flat. + * @param {*} wa + */ + static weighted (wa) { let a = [] for (let i = 0; i < wa.length; ++i) { for (let j = 0; j < wa[i].w; ++j) { @@ -122,11 +150,13 @@ var random = { // eslint-disable-line no-unused-vars } } return a - }, - use: function (obj) { + } + + static use (obj) { return this.bool() ? obj : '' - }, - shuffle: function (arr) { + } + + static shuffle (arr) { let i = arr.length while (i--) { let p = this.number(i + 1) @@ -134,16 +164,18 @@ var random = { // eslint-disable-line no-unused-vars arr[i] = arr[p] arr[p] = t } - }, - shuffled: function (arr) { + } + + static shuffled (arr) { let newArray = arr.slice() this.shuffle(newArray) return newArray - }, - subset: function (list, limit) { + } + + static subset (list, limit) { if (!(Array.isArray(list))) { logger.traceback() - throw new TypeError('random.subset() received a non-array type: \'' + list + '\'') + throw new TypeError(`random.subset() received non-array type: (${list})`) } if (typeof limit !== 'number') { limit = this.number(list.length + 1) @@ -153,9 +185,13 @@ var random = { // eslint-disable-line no-unused-vars result.push(this.pick(list)) } return result - }, - pop: function (arr) { - // Removes and returns a random item from an array + } + + /** + * Removes and returns a random item from an array. + * @param {*} arr + */ + static pop (arr) { let i, obj i = this.number(arr.length) @@ -163,13 +199,11 @@ var random = { // eslint-disable-line no-unused-vars arr.splice(i, 1) return obj - }, - hex: function (len) { + } + + static hex (len) { return this.number(Math.pow(2, len * 4)).toString(16) } } -module.exports = { - random, - MersenneTwister -} +module.exports = random diff --git a/lib/utils/block.js b/lib/utils/block.js index 20ce3aa..b5d9f79 100644 --- a/lib/utils/block.js +++ b/lib/utils/block.js @@ -2,8 +2,10 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -utils.block = { - block: function (list, optional) { +const utils = require('../utils') + +class block extends utils { + static block (list, optional) { if (optional === true) { if (random.chance(6)) { return '' @@ -38,3 +40,5 @@ utils.block = { return asString } } + +module.exports = block diff --git a/lib/utils/common.js b/lib/utils/common.js index 77c1649..cbb30fe 100644 --- a/lib/utils/common.js +++ b/lib/utils/common.js @@ -2,30 +2,34 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -utils.common = { - objToString: function (obj) { + +class common extends utils { + static objToString (obj) { try { return '' + obj } catch (e) { return '[' + e + ']' } - }, - getAllProperties: function (obj) { + } + + static getAllProperties (obj) { let list = [] while (obj) { list = list.concat(Object.getOwnPropertyNames(obj)) obj = Object.getPrototypeOf(obj) } return list - }, - getKeysFromHash: function (obj) { + } + + static getKeysFromHash (obj) { let list = [] for (let p in obj) { list.push(p) } return list - }, - quote: function (s) { + } + + static quote (s) { // Taken from DOMfuzz function escapeString (s) { return ('\"' + // eslint-disable-line no-useless-escape @@ -48,8 +52,9 @@ utils.common = { // For other things (such as numbers, |null|, and |undefined|), just coerce to string. return JSON.stringify(s) } - }, - b64encode: function (str) { + } + + static b64encode (str) { // Unicode safe b64 encoding // https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#The_Unicode_Problem return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, @@ -57,15 +62,17 @@ utils.common = { // noinspection JSCheckFunctionSignatures return String.fromCharCode('0x' + p1) })) - }, - b64decode: function (str) { + } + + static b64decode (str) { // Unicode safe b64 decoding // https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#The_Unicode_Problem return decodeURIComponent(atob(str).split('').map(function (c) { return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2) }).join('')) - }, - uniqueList: function (list) { + } + + static uniqueList (list) { let tmp = {} let r = [] for (let i = 0; i < list.length; i++) { @@ -75,8 +82,9 @@ utils.common = { r.push(tmp[i]) } return r - }, - mergeHash: function (obj1, obj2) { + } + + static mergeHash (obj1, obj2) { for (let p in obj2) { try { if (obj2[p].constructor === Object) { @@ -89,6 +97,11 @@ utils.common = { } } return obj1 - }, - mockup: (obj) => obj.split('\n').map((ln) => ln.trim()).join('') + } + + static mockup (obj) { + return obj.split('\n').map((ln) => ln.trim()).join('') + } } + +module.exports = common diff --git a/lib/utils/index.js b/lib/utils/index.js new file mode 100644 index 0000000..fe6f14c --- /dev/null +++ b/lib/utils/index.js @@ -0,0 +1,27 @@ +class utils { + static get common () { + return require('./common') + } + + static get block () { + return require('./block') + } + + static get mutate () { + return require('./mutate') + } + + static Objects () { + return require('./objects') + } + + static get platform () { + return require('./platform') + } + + static get script () { + return require('./script') + } +} + +module.exports = utils diff --git a/lib/utils/init.js b/lib/utils/init.js deleted file mode 100644 index 0db5220..0000000 --- a/lib/utils/init.js +++ /dev/null @@ -1 +0,0 @@ -var utils = {} // eslint-disable-line no-unused-vars diff --git a/lib/utils/mutate.js b/lib/utils/mutate.js index 3d4b78d..25730e6 100644 --- a/lib/utils/mutate.js +++ b/lib/utils/mutate.js @@ -2,22 +2,26 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -utils.mutate = { - text: function (str) { +const make = require('../make') +const utils = require('../utils') +const random = require('../random') + +class mutate extends utils { + static text (str) { let mutator = function (m) { return random.chance(4) ? m : make.text.any() } return str.replace(/[a-zA-Z]+?/g, mutator) - }, + } - numbers: function (str) { + static numbers (str) { let mutator = function (m) { return random.chance(4) ? m : make.number.any() } return str.replace(/-?\d+(\.\d+)?/g, mutator) - }, + } - units: function (str) { + static units (str) { let mutator = function (m, p1) { if (random.chance(4)) { return m @@ -26,9 +30,9 @@ utils.mutate = { } } return str.replace(/(\d+)(px|em|ex|ch|rem|mm|cm|in|pt|pc|%')/g, mutator) - }, + } - random: function (str) { + static random (str) { let mutator = function (m) { if (random.chance(20)) { if (str.match(/[0-9]/g)) { @@ -41,9 +45,9 @@ utils.mutate = { } } return str.replace(/./g, mutator) - }, + } - any: function (str) { + static any (str) { switch (random.number(4)) { case 0: return utils.mutate.text(str) @@ -56,3 +60,5 @@ utils.mutate = { } } } + +module.exports = mutate \ No newline at end of file diff --git a/lib/utils/objects.js b/lib/utils/objects.js index 98170ce..4c5df16 100644 --- a/lib/utils/objects.js +++ b/lib/utils/objects.js @@ -2,108 +2,115 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +const utils = require('../utils') +const {logger} = require('../logging') + var o = null // eslint-disable-line no-unused-vars -function Objects () { - this.counter = 0 - this.container = {} -} +class Objects { + constructor () { + this.counter = 0 + this.container = {} + } -Objects.prototype.add = function (category, member) { - if (!member) { - member = 'o' + this.counter + add (category, member) { + if (!member) { + member = 'o' + this.counter + } + if (!this.has(category)) { + this.container[category] = [] + } + this.container[category].push({type: category, name: member}) + ++this.counter + return this.container[category].slice(-1)[0].name } - if (!this.has(category)) { - this.container[category] = [] - } - this.container[category].push({type: category, name: member}) - ++this.counter - return this.container[category].slice(-1)[0].name -} -Objects.prototype.get = function (category, last) { - if (!(category in this.container)) { - // return {type:null, name:null}; - logger.traceback() - throw new Error(category + ' is not available.') + get (category, last) { + if (!(category in this.container)) { + // return {type:null, name:null}; + logger.traceback() + throw new Error(category + ' is not available.') + } + if (last) { + return this.container[category].slice(-1)[0] + } + return random.pick(this.container[category]) } - if (last) { - return this.container[category].slice(-1)[0] - } - return random.pick(this.container[category]) -} -Objects.prototype.pick = function (category, last) { - try { - return this.get(category, last).name - } catch (e) { - logger.traceback() - throw logger.JSError('Error: pick(\'' + category + '\') is undefined.') + pick (category, last) { + try { + return this.get(category, last).name + } catch (e) { + logger.traceback() + throw logger.JSError('Error: pick(\'' + category + '\') is undefined.') + } } -} -Objects.prototype.pop = function (objectName) { - let self = this - utils.common.getKeysFromHash(this.container).forEach(function (category) { - self.container[category].forEach(function (obj) { - if (obj.name === objectName) { - self.container[category].splice(self.container[category].indexOf(obj), 1) + pop (objectName) { + let self = this + utils.common.getKeysFromHash(this.container).forEach(function (category) { + self.container[category].forEach(function (obj) { + if (obj.name === objectName) { + self.container[category].splice(self.container[category].indexOf(obj), 1) + } + }) + }) + } + + contains (categoryNames) { + let categories = [] + let self = this + categoryNames.forEach(function (name) { + if (self.has(name)) { + categories.push(name) } }) - }) -} - -Objects.prototype.contains = function (categoryNames) { - let categories = [] - let self = this - categoryNames.forEach(function (name) { - if (self.has(name)) { - categories.push(name) - } - }) - return (categories.length === 0) ? null : categories -} - -Objects.prototype.show = function (category) { - return (category in this.container) ? this.container[category] : this.container -} - -Objects.prototype.count = function (category) { - return (category in this.container) ? this.container[category].length : 0 -} - -Objects.prototype.has = function (category) { - if (category in this.container) { - this.check(category) - return this.container[category].length > 0 + return (categories.length === 0) ? null : categories } - return false -} -Objects.prototype.valid = function () { - let items = [] - let self = this - utils.common.getKeysFromHash(self.container).forEach(function (category) { - self.check(category) - }) - utils.common.getKeysFromHash(self.container).forEach(function (category) { - for (let i = 0; i < self.container[category].length; i++) { - items.push(self.container[category][i].name) + show (category) { + return (category in this.container) ? this.container[category] : this.container + } + + count (category) { + return (category in this.container) ? this.container[category].length : 0 + } + + has (category) { + if (category in this.container) { + this.check(category) + return this.container[category].length > 0 } - }) - return items -} + return false + } -Objects.prototype.check = function (category) { - let self = this - self.container[category].forEach(function (object) { - try { - let x = /* frame.contentWindow. */ eval(object.name) // eslint-disable-line no-eval - if (x === undefined || x === null) { + valid () { + let items = [] + let self = this + utils.common.getKeysFromHash(self.container).forEach(function (category) { + self.check(category) + }) + utils.common.getKeysFromHash(self.container).forEach(function (category) { + for (let i = 0; i < self.container[category].length; i++) { + items.push(self.container[category][i].name) + } + }) + return items + } + + check (category) { + let self = this + self.container[category].forEach(function (object) { + try { + let x = /* frame.contentWindow. */ eval(object.name) // eslint-disable-line no-eval + if (x === undefined || x === null) { + self.pop(object.name) + } + } catch (e) { self.pop(object.name) } - } catch (e) { - self.pop(object.name) - } - }) + }) + } } + +module.exports = Object diff --git a/lib/utils/platform.js b/lib/utils/platform.js index 5481ab1..2905ff4 100644 --- a/lib/utils/platform.js +++ b/lib/utils/platform.js @@ -2,101 +2,112 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -utils.platform = (function () { - let platform = {} +const utils = require('../utils') - const userAgent = (navigator.userAgent).toLowerCase() - const language = navigator.language || navigator.browserLanguage +class platform extends utils { + static get name () { + let platform = {} - const version = platform.version = (userAgent.match(/.*(?:rv|chrome|webkit|opera|ie)[/: ](.+?)([ );]|$)/) || [])[1] - const webkitVersion = (userAgent.match(/webkit\/(.+?) /) || [])[1] - - platform.windows = platform.isWindows = !!/windows/.test(userAgent) - platform.mac = platform.isMac = !!/macintosh/.test(userAgent) || (/mac os x/.test(userAgent) && !/like mac os x/.test(userAgent)) - platform.lion = platform.isLion = !!(/mac os x 10_7/.test(userAgent) && !/like mac os x 10_7/.test(userAgent)) - platform.iPhone = platform.isiPhone = !!/iphone/.test(userAgent) - platform.iPod = platform.isiPod = !!/ipod/.test(userAgent) - platform.iPad = platform.isiPad = !!/ipad/.test(userAgent) - platform.iOS = platform.isiOS = platform.iPhone || platform.iPod || platform.iPad - platform.android = platform.isAndroid = !!/android/.test(userAgent) - platform.opera = /opera/.test(userAgent) ? version : 0 - platform.isOpera = !!platform.opera - platform.msie = /msie/.test(userAgent) && !platform.opera ? version : 0 - platform.isIE = !!platform.msie - platform.isIE8OrLower = !!(platform.msie && parseInt(platform.msie, 10) <= 8) - platform.mozilla = /mozilla/.test(userAgent) && !/(compatible|webkit|msie)/.test(userAgent) ? version : 0 - platform.isMozilla = !!platform.mozilla - platform.webkit = /webkit/.test(userAgent) ? webkitVersion : 0 - platform.isWebkit = !!platform.webkit - platform.chrome = /chrome/.test(userAgent) ? version : 0 - platform.isChrome = !!platform.chrome - platform.mobileSafari = /apple.*mobile/.test(userAgent) && platform.iOS ? webkitVersion : 0 - platform.isMobileSafari = !!platform.mobileSafari - platform.iPadSafari = platform.iPad && platform.isMobileSafari ? webkitVersion : 0 - platform.isiPadSafari = !!platform.iPadSafari - platform.iPhoneSafari = platform.iPhone && platform.isMobileSafari ? webkitVersion : 0 - platform.isiPhoneSafari = !!platform.iphoneSafari - platform.iPodSafari = platform.iPod && platform.isMobileSafari ? webkitVersion : 0 - platform.isiPodSafari = !!platform.iPodSafari - platform.isiOSHomeScreen = platform.isMobileSafari && !/apple.*mobile.*safari/.test(userAgent) - platform.safari = platform.webkit && !platform.chrome && !platform.iOS && !platform.android ? webkitVersion : 0 - platform.isSafari = !!platform.safari - platform.language = language.split('-', 1)[0] - platform.current = - platform.msie ? 'msie' : platform.mozilla ? 'mozilla' : platform.chrome ? 'chrome' : platform.safari ? 'safari' : platform.opera ? 'opera' : platform.mobileSafari ? 'mobile-safari' : platform.android ? 'android' : 'unknown' - - function platformName (candidates) { - for (let i = 0; i < candidates.length; i++) { - if (candidates[i] in window) { - return 'window.' + candidates[i] - } - if (candidates[i] in navigator) { - return 'navigator.' + candidates[i] - } + /* In case we are running in Node. */ + if (typeof window === 'undefined') { + return platform } - return undefined + + const userAgent = (navigator.userAgent).toLowerCase() + const language = navigator.language || navigator.browserLanguage + + const version = platform.version = (userAgent.match(/.*(?:rv|chrome|webkit|opera|ie)[/: ](.+?)([ );]|$)/) || [])[1] + const webkitVersion = (userAgent.match(/webkit\/(.+?) /) || [])[1] + + platform.windows = platform.isWindows = !!/windows/.test(userAgent) + platform.mac = platform.isMac = !!/macintosh/.test(userAgent) || (/mac os x/.test(userAgent) && !/like mac os x/.test(userAgent)) + platform.lion = platform.isLion = !!(/mac os x 10_7/.test(userAgent) && !/like mac os x 10_7/.test(userAgent)) + platform.iPhone = platform.isiPhone = !!/iphone/.test(userAgent) + platform.iPod = platform.isiPod = !!/ipod/.test(userAgent) + platform.iPad = platform.isiPad = !!/ipad/.test(userAgent) + platform.iOS = platform.isiOS = platform.iPhone || platform.iPod || platform.iPad + platform.android = platform.isAndroid = !!/android/.test(userAgent) + platform.opera = /opera/.test(userAgent) ? version : 0 + platform.isOpera = !!platform.opera + platform.msie = /msie/.test(userAgent) && !platform.opera ? version : 0 + platform.isIE = !!platform.msie + platform.isIE8OrLower = !!(platform.msie && parseInt(platform.msie, 10) <= 8) + platform.mozilla = /mozilla/.test(userAgent) && !/(compatible|webkit|msie)/.test(userAgent) ? version : 0 + platform.isMozilla = !!platform.mozilla + platform.webkit = /webkit/.test(userAgent) ? webkitVersion : 0 + platform.isWebkit = !!platform.webkit + platform.chrome = /chrome/.test(userAgent) ? version : 0 + platform.isChrome = !!platform.chrome + platform.mobileSafari = /apple.*mobile/.test(userAgent) && platform.iOS ? webkitVersion : 0 + platform.isMobileSafari = !!platform.mobileSafari + platform.iPadSafari = platform.iPad && platform.isMobileSafari ? webkitVersion : 0 + platform.isiPadSafari = !!platform.iPadSafari + platform.iPhoneSafari = platform.iPhone && platform.isMobileSafari ? webkitVersion : 0 + platform.isiPhoneSafari = !!platform.iphoneSafari + platform.iPodSafari = platform.iPod && platform.isMobileSafari ? webkitVersion : 0 + platform.isiPodSafari = !!platform.iPodSafari + platform.isiOSHomeScreen = platform.isMobileSafari && !/apple.*mobile.*safari/.test(userAgent) + platform.safari = platform.webkit && !platform.chrome && !platform.iOS && !platform.android ? webkitVersion : 0 + platform.isSafari = !!platform.safari + platform.language = language.split('-', 1)[0] + platform.current = + platform.msie ? 'msie' : platform.mozilla ? 'mozilla' : platform.chrome ? 'chrome' : platform.safari ? 'safari' : platform.opera ? 'opera' : platform.mobileSafari ? 'mobile-safari' : platform.android ? 'android' : 'unknown' + + function platformName (candidates) { + for (let i = 0; i < candidates.length; i++) { + if (candidates[i] in window) { + return 'window.' + candidates[i] + } + if (candidates[i] in navigator) { + return 'navigator.' + candidates[i] + } + } + return undefined + } + + platform.GUM = platformName(['getUserMedia', 'webkitGetUserMedia', 'mozGetUserMedia', 'msGetUserMedia', 'getGUM']) + platform.PeerConnection = platformName(['webkitRTCPeerConnection', 'mozRTCPeerConnection', 'msPeerConnection']) + platform.IceCandidate = platformName(['mozRTCIceCandidate', 'RTCIceCandidate']) + platform.SessionDescription = platformName(['mozRTCSessionDescription', 'RTCSessionDescription']) + platform.URL = platformName(['URL', 'webkitURL']) + platform.AudioContext = platformName(['AudioContext', 'webkitAudioContext']) + platform.OfflineAudioContext = platformName(['OfflineAudioContext', 'webkitOfflineAudioContext']) + platform.MediaSource = platformName(['MediaSource', 'WebKitMediaSource']) + + platform.SpeechRecognition = platformName(['SpeechRecognition', 'webkitSpeechRecognition']) + platform.SpeechGrammarList = platformName(['SpeechGrammarList', 'webkitSpeechGrammarList']) + platform.SpeechGrammar = platformName(['SpeechGrammar']) + + /* + function findWebGLContextName (candidates) { + var canvas = document.createElement('canvas') + for (var i = 0; i < candidates.length; i++) { + var name = candidates[i] + try { + if (canvas.getContext(name)) { + return name + } + } catch (e) {} + } + return null + } + */ + + platform.WebGL = 'webgl' // findWebGLContextName(["webgl", "experimental-webgl", "webkit-3d"]); + platform.WebGL2 = 'webgl2' // findWebGLContextName(["webgl2", "experimental-webgl2"]); + + platform.captureStreamUntilEnded = 'captureStreamUntilEnded' + if (platform.isMozilla) { + platform.captureStreamUntilEnded = 'mozCaptureStreamUntilEnded' + } + + platform.srcObject = 'srcObject' + if (platform.isMozilla) { + platform.srcObject = 'mozSrcObject' + } + + return platform } +} - platform.GUM = platformName(['getUserMedia', 'webkitGetUserMedia', 'mozGetUserMedia', 'msGetUserMedia', 'getGUM']) - platform.PeerConnection = platformName(['webkitRTCPeerConnection', 'mozRTCPeerConnection', 'msPeerConnection']) - platform.IceCandidate = platformName(['mozRTCIceCandidate', 'RTCIceCandidate']) - platform.SessionDescription = platformName(['mozRTCSessionDescription', 'RTCSessionDescription']) - platform.URL = platformName(['URL', 'webkitURL']) - platform.AudioContext = platformName(['AudioContext', 'webkitAudioContext']) - platform.OfflineAudioContext = platformName(['OfflineAudioContext', 'webkitOfflineAudioContext']) - platform.MediaSource = platformName(['MediaSource', 'WebKitMediaSource']) - - platform.SpeechRecognition = platformName(['SpeechRecognition', 'webkitSpeechRecognition']) - platform.SpeechGrammarList = platformName(['SpeechGrammarList', 'webkitSpeechGrammarList']) - platform.SpeechGrammar = platformName(['SpeechGrammar']) - - /* - function findWebGLContextName (candidates) { - var canvas = document.createElement('canvas') - for (var i = 0; i < candidates.length; i++) { - var name = candidates[i] - try { - if (canvas.getContext(name)) { - return name - } - } catch (e) {} - } - return null - } - */ - - platform.WebGL = 'webgl' // findWebGLContextName(["webgl", "experimental-webgl", "webkit-3d"]); - platform.WebGL2 = 'webgl2' // findWebGLContextName(["webgl2", "experimental-webgl2"]); - - platform.captureStreamUntilEnded = 'captureStreamUntilEnded' - if (platform.isMozilla) { - platform.captureStreamUntilEnded = 'mozCaptureStreamUntilEnded' - } - - platform.srcObject = 'srcObject' - if (platform.isMozilla) { - platform.srcObject = 'mozSrcObject' - } - - return platform -})() +module.exports = platform diff --git a/lib/utils/script.js b/lib/utils/script.js index f245d5d..1f632c0 100644 --- a/lib/utils/script.js +++ b/lib/utils/script.js @@ -2,8 +2,11 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -utils.script = { - methodHead: function (list, numOptional) { +const utils = require('../utils') +const random = require('../random') + +class script extends utils { + static methodHead (list, numOptional) { if (isNaN(numOptional)) { numOptional = 0 } @@ -12,9 +15,10 @@ utils.script = { for (let i = 0; i < arity; i++) { params.push(random.pick([list[i]])) } - return '(' + params.join(', ') + ')' - }, - methodCall: function (objectName, methodHash) { + return `(${params.join(', ')})` + } + + static methodCall (objectName, methodHash) { if (!utils.common.getKeysFromHash(methodHash).length || !objectName) { return '' } @@ -23,9 +27,10 @@ utils.script = { if (typeof (methodArgs) === 'function') { // Todo: Hmmmm.. return methodArgs() } - return objectName + '.' + methodName + utils.script.methodHead(methodArgs) - }, - setAttribute: function (objectName, attributeHash) { + return objectName + '.' + methodName + script.methodHead(methodArgs) + } + + static setAttribute (objectName, attributeHash) { if (!utils.common.getKeysFromHash(attributeHash).length || !objectName) { return '' } @@ -41,65 +46,62 @@ utils.script = { } */ return objectName + '.' + attributeName + operator + attributeValue + ';' - }, - makeConstraint: function (keys, values) { + } + + static makeConstraint (keys, values) { let o = {} let n = random.range(0, keys.length) while (n--) { o[random.pick(keys)] = random.pick(values) } return o - }, - makeRandomOptions: function (baseObject) { + } + + static makeRandomOptions (baseObject) { let o = {} let unique = random.subset(Object.keys(baseObject)) for (let i = 0; i < unique.length; i++) { o[unique[i]] = random.pick(baseObject[unique[i]]) } return JSON.stringify(o) - }, - safely: function (s) { - return 'try { ' + s + ' } catch(e) { }' - }, - makeLoop: function (s, max) { + } + + static safely (s) { + return `try { ${s} } catch(e) { }` + } + + static makeLoop (s, max) { return 'for (let i = 0; i < ' + (max || make.number.range()) + '; i++) {' + s + '}' - }, - makeArray: function (type, arrayLength, cb) { + } + + static makeArray (type, arrayLength, cb) { if (type === null || type === undefined) { type = random.item(['Uint8', 'Float32']) } switch (random.number(8)) { case 0: let src = 'function() { let buffer = new ' + type + 'Array(' + arrayLength + ');' - src += utils.script.makeLoop('buffer[i] = ' + cb() + ';', arrayLength) + src += script.makeLoop('buffer[i] = ' + cb() + ';', arrayLength) src += 'return buffer;}()' return src case 1: - return 'new ' + type + 'Array([' + make.arrays.filledArray(cb, arrayLength) + '])' + return `new ${type}Array([${make.arrays.filledArray(cb, arrayLength)}])` default: - return 'new ' + type + 'Array(' + arrayLength + ')' + return `new ${type}Array(${arrayLength})` } - }, - randListIndex: function (objName) { + } + + static randListIndex (objName) { return random.number() + ' % ' + o.pick(objName) + '.length' - }, - addElementToBody: function (name) { - return '(document.body || document.documentElement).appendChild' + utils.script.methodHead([name]) - }, - forceGC: function () { - if (utils.platform.isMozilla) { - } - if (utils.platform.isChrome) { - if (window.GCController) { - return GCController.collect() // eslint-disable-line no-undef - } - } - if (utils.platform.isSafari) { - } - if (utils.platform.isIE) { - } - }, - getRandomElement: function () { - return 'document.getElementsByTagName(\'*\')[' + random.number(document.getElementsByTagName('*').length) + ']' + } + + static addElementToBody (name) { + return `(document.body || document.documentElement).appendChild${script.methodHead([name])}` + } + + static getRandomElement () { + return `document.getElementsByTagName('*')[${random.number(document.getElementsByTagName('*').length)}]` } } + +module.exports = script diff --git a/package.json b/package.json index 3b1e67d..ccde6a9 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,13 @@ { "name": "octo", - "version": "0.0.3", + "version": "1.0.0", "description": "", "keywords": [ "fuzzing", - "browsers" + "browsers", + "javascript", + "node", + "library" ], "homepage": "https://github.com/mozillasecurity/octo", "repository": { @@ -21,7 +24,8 @@ "test": "grunt test --verbose", "test:lint": "cross-env NODE_ENV=test standard --verbose", "test:lint:fix": "cross-env NODE_ENV=test standard --fix --verbose", - "build": "./build.py -l lib/ -d deploy/", + "build": "webpack -p", + "watch": "webpack --watch", "postinstall": "npm run build", "precommit": "npm run test:lint" }, @@ -51,12 +55,16 @@ "grunt-karma-coveralls": "*", "grunt-standard": "*", "husky": "^0.14.3", + "jshint": "^2.9.5", + "jshint-loader": "^0.8.4", "karma": "*", "karma-chrome-launcher": "*", "karma-coverage": "*", "karma-firefox-launcher": "*", "karma-qunit": "*", "qunitjs": "*", - "standard": "*" + "standard": "*", + "webpack": "^4.1.1", + "webpack-cli": "^2.0.12" } } diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..2e384a8 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,14 @@ +const path = require('path') +const webpack = require("webpack") + +let config = { + entry: './lib/index.js', + output: { + filename: 'octo.js', + library: 'octo', + path: path.resolve(__dirname, 'dist'), + libraryTarget: 'var' + } +} + +module.exports = config \ No newline at end of file From ee570a8136252524eadf44a52c2e502c1d5e24f1 Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Mon, 19 Mar 2018 04:37:40 +0100 Subject: [PATCH 03/68] Add entry point for node package --- index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 index.js diff --git a/index.js b/index.js new file mode 100644 index 0000000..df8fe0e --- /dev/null +++ b/index.js @@ -0,0 +1,11 @@ +const logger = require('./lib/logging') +const make = require('./lib/make') +const random = require('./lib/random') +const utils = require('./lib/utils') + +module.exports = { + logger, + random, + make, + utils +} From 360f7abb1ea584b6400bf705be6e94dee0ddda57 Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Mon, 19 Mar 2018 04:54:15 +0100 Subject: [PATCH 04/68] Add entry point for node package --- index.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/index.js b/index.js index df8fe0e..ba74d55 100644 --- a/index.js +++ b/index.js @@ -1,11 +1 @@ -const logger = require('./lib/logging') -const make = require('./lib/make') -const random = require('./lib/random') -const utils = require('./lib/utils') - -module.exports = { - logger, - random, - make, - utils -} +module.exports = require('./lib/') \ No newline at end of file From 43b69880b1212599e531599d28eac9dc5432cd17 Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Mon, 19 Mar 2018 05:54:40 +0100 Subject: [PATCH 05/68] Add linter fixes --- index.js | 2 +- lib/index.js | 8 +-- lib/logging/console.js | 5 +- lib/logging/index.js | 11 ++- lib/make/alignment.js | 18 ++--- lib/make/crypto.js | 7 +- lib/make/fonts.js | 4 +- lib/make/index.js | 126 +++++++++++++++++----------------- lib/make/numbers.js | 2 +- lib/make/shaders.js | 9 +-- lib/make/text.js | 3 +- lib/random/mersennetwister.js | 16 ++--- lib/random/random.js | 1 - lib/utils/block.js | 1 + lib/utils/common.js | 2 +- lib/utils/index.js | 36 +++++----- lib/utils/mutate.js | 2 +- lib/utils/objects.js | 3 +- lib/utils/script.js | 4 +- package.json | 20 +----- webpack.config.js | 17 +++-- 21 files changed, 141 insertions(+), 156 deletions(-) diff --git a/index.js b/index.js index ba74d55..9615572 100644 --- a/index.js +++ b/index.js @@ -1 +1 @@ -module.exports = require('./lib/') \ No newline at end of file +module.exports = require('./lib/') diff --git a/lib/index.js b/lib/index.js index 477e633..3df1d31 100644 --- a/lib/index.js +++ b/lib/index.js @@ -4,8 +4,8 @@ const random = require('./random') const utils = require('./utils') module.exports = { - logger, - random, - make, - utils + logger, + random, + make, + utils } diff --git a/lib/logging/console.js b/lib/logging/console.js index a8f56fe..cda8e0e 100644 --- a/lib/logging/console.js +++ b/lib/logging/console.js @@ -19,7 +19,6 @@ if (utils.platform.name.isWindows) { } class logger { - static console (msg) { if (websocket) { websocket.send(msg) @@ -31,7 +30,7 @@ class logger { console.log(msg) } } else if (window.dump) { - dump(msg) + dump(msg) // eslint-disable-line no-undef } else if (window.console && window.console.log) { console.log(msg) } else { @@ -85,4 +84,4 @@ class logger { } } -module.exports = logger \ No newline at end of file +module.exports = logger diff --git a/lib/logging/index.js b/lib/logging/index.js index 05ab01b..3468436 100644 --- a/lib/logging/index.js +++ b/lib/logging/index.js @@ -3,13 +3,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ class logging { - constructor () { - } - - static get logger () { - // Or: const {logger} = require('./logging') - return require('./console') - } + static get logger () { + // Or: const {logger} = require('./logging') + return require('./console') + } } module.exports = logging diff --git a/lib/make/alignment.js b/lib/make/alignment.js index cd7ce20..e819c62 100644 --- a/lib/make/alignment.js +++ b/lib/make/alignment.js @@ -6,17 +6,17 @@ const make = require('../make') const random = require('../random') class alignment extends make { - static horizontal () { - return random.item(['left', 'right', 'justify', 'center']) - } + static horizontal () { + return random.item(['left', 'right', 'justify', 'center']) + } - static vertical () { - return random.item(['top', 'bottom', 'middle', 'baseline']) - } + static vertical () { + return random.item(['top', 'bottom', 'middle', 'baseline']) + } - static any () { - return random.pick([this.horizontal, this.vertical]) - } + static any () { + return random.pick([this.horizontal, this.vertical]) + } } module.exports = alignment diff --git a/lib/make/crypto.js b/lib/make/crypto.js index 3199e2d..4e0ab5b 100644 --- a/lib/make/crypto.js +++ b/lib/make/crypto.js @@ -2,8 +2,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -const make = require('../make') const random = require('../random') +const make = require('../make') +const utils = require('../utils') class crypto extends make { static get keyFormats () { @@ -54,8 +55,8 @@ class crypto extends make { ] } - static randomCurve (){ - return random.item(this.curves) + static randomCurve () { + return random.item(this.curves) } static get jwkUsages () { diff --git a/lib/make/fonts.js b/lib/make/fonts.js index 0f26c13..402812d 100644 --- a/lib/make/fonts.js +++ b/lib/make/fonts.js @@ -83,7 +83,7 @@ class font extends make { ]) } - static font() { + static font () { let s = '' if (random.chance(4)) { s += random.pick(this.style) + ' ' @@ -104,4 +104,4 @@ class font extends make { } } -module.exports = font \ No newline at end of file +module.exports = font diff --git a/lib/make/index.js b/lib/make/index.js index e138f6d..99d31b9 100644 --- a/lib/make/index.js +++ b/lib/make/index.js @@ -3,89 +3,89 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ class make { - static get number () { - return require('./numbers') - } + static get number () { + return require('./numbers') + } - static get alignment () { - return require('./alignment') - } + static get alignment () { + return require('./alignment') + } - static get arrays () { - return require('./arrays') - } + static get arrays () { + return require('./arrays') + } - static get colors () { - return require('./colors') - } + static get colors () { + return require('./colors') + } - static get command () { - return require('./command') - } + static get command () { + return require('./command') + } - static get crypto () { - return require('./crypto') - } + static get crypto () { + return require('./crypto') + } - static get datetime () { - return require('./datetime') - } + static get datetime () { + return require('./datetime') + } - static get files () { - return require('./files') - } + static get files () { + return require('./files') + } - static get font () { - return require('./fonts') - } + static get font () { + return require('./fonts') + } - static get html () { - return require('./html') - } + static get html () { + return require('./html') + } - static get mime () { - return require('./mime') - } + static get mime () { + return require('./mime') + } - static get network () { - return require('./network') - } + static get network () { + return require('./network') + } - static get shaders () { - return require('./shaders') - } + static get shaders () { + return require('./shaders') + } - static get style () { - return require('./style') - } + static get style () { + return require('./style') + } - static get text () { - return require('./text') - } + static get text () { + return require('./text') + } - static get time () { - return require('./time') - } + static get time () { + return require('./time') + } - static get typed () { - return require('./typed') - } + static get typed () { + return require('./typed') + } - static get types () { - return require('./types') - } + static get types () { + return require('./types') + } - static get unit () { - return require('./units') - } + static get unit () { + return require('./units') + } - static get uri () { - return require('./uri') - } + static get uri () { + return require('./uri') + } - static get webgl () { - return require('./webgl') - } + static get webgl () { + return require('./webgl') + } } module.exports = make diff --git a/lib/make/numbers.js b/lib/make/numbers.js index bbc6ee7..52b4f69 100644 --- a/lib/make/numbers.js +++ b/lib/make/numbers.js @@ -60,7 +60,7 @@ class number extends make { return Math.pow(2, random.number(random.number(65))) + random.number(3) - 1 } - static even(number) { + static even (number) { return number % 2 === 1 ? ++number : number } diff --git a/lib/make/shaders.js b/lib/make/shaders.js index 7b332cc..7cd7065 100644 --- a/lib/make/shaders.js +++ b/lib/make/shaders.js @@ -2,8 +2,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -const make = require('../make') const random = require('../random') +const make = require('../make') +const utils = require('../utils') class shaders extends make { static get fragment1 () { @@ -29,7 +30,7 @@ class shaders extends make { ] } - static get vertex1() { + static get vertex1 () { return [ [ 'attribute vec4 aVertex;', @@ -63,7 +64,7 @@ class shaders extends make { ] } - static get fragment2() { + static get fragment2 () { return [ [ 'varying highp vec2 vTextureCoord;', @@ -96,7 +97,7 @@ class shaders extends make { ] } - static get vertex2() { + static get vertex2 () { return [ [ 'attribute highp vec3 aVertexNormal;', diff --git a/lib/make/text.js b/lib/make/text.js index da1aec8..9e0737a 100644 --- a/lib/make/text.js +++ b/lib/make/text.js @@ -2,8 +2,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -const make = require('../make') const random = require('../random') +const make = require('../make') +const utils = require('../utils') class text extends make { static lineEnd () { diff --git a/lib/random/mersennetwister.js b/lib/random/mersennetwister.js index 18b298f..45f246e 100644 --- a/lib/random/mersennetwister.js +++ b/lib/random/mersennetwister.js @@ -28,28 +28,28 @@ class MersenneTwister { } } - export_state () { + export_state () { // eslint-disable-line camelcase return [this.mt, this.mti] } - import_state (s) { + import_state (s) { // eslint-disable-line camelcase this.mt = s[0] this.mti = s[1] } - export_mta () { + export_mta () { // eslint-disable-line camelcase return this.mt } - import_mta (_mta) { + import_mta (_mta) { // eslint-disable-line camelcase this.mt = _mta } - export_mti () { + export_mti () { // eslint-disable-line camelcase return this.mti } - import_mti (_mti) { + import_mti (_mti) { // eslint-disable-line camelcase this.mti = _mti } @@ -58,8 +58,8 @@ class MersenneTwister { if (this.mti >= this.N) { /* generate N words at one time */ for (kk = 0; kk < this.N - this.M; kk++) { - y = ((this.mt[kk] & this.UPPER_MASK) | (this.mt[kk + 1] & this.LOWER_MASK)) - this.mt[kk] = (this.mt[kk + this.M] ^ (y >>> 1) ^ this.MAG01[y & 0x1]) + y = ((this.mt[kk] & this.UPPER_MASK) | (this.mt[kk + 1] & this.LOWER_MASK)) + this.mt[kk] = (this.mt[kk + this.M] ^ (y >>> 1) ^ this.MAG01[y & 0x1]) } for (; kk < this.N - 1; kk++) { y = ((this.mt[kk] & this.UPPER_MASK) | (this.mt[kk + 1] & this.LOWER_MASK)) diff --git a/lib/random/random.js b/lib/random/random.js index e98f91b..541891f 100644 --- a/lib/random/random.js +++ b/lib/random/random.js @@ -6,7 +6,6 @@ const MersenneTwister = require('./mersennetwister') const {logger} = require('../logging') class random { - /** * Must be called before any other methods can be called to initialize MersenneTwister. * @param {number|null|undefined} seed Value to initialize MersenneTwister. diff --git a/lib/utils/block.js b/lib/utils/block.js index b5d9f79..08c9d70 100644 --- a/lib/utils/block.js +++ b/lib/utils/block.js @@ -2,6 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +const random = require('../random') const utils = require('../utils') class block extends utils { diff --git a/lib/utils/common.js b/lib/utils/common.js index cbb30fe..89be16e 100644 --- a/lib/utils/common.js +++ b/lib/utils/common.js @@ -1,7 +1,7 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - +const utils = require('../utils') class common extends utils { static objToString (obj) { diff --git a/lib/utils/index.js b/lib/utils/index.js index fe6f14c..77dd756 100644 --- a/lib/utils/index.js +++ b/lib/utils/index.js @@ -1,27 +1,27 @@ class utils { - static get common () { - return require('./common') - } + static get common () { + return require('./common') + } - static get block () { - return require('./block') - } + static get block () { + return require('./block') + } - static get mutate () { - return require('./mutate') - } + static get mutate () { + return require('./mutate') + } - static Objects () { - return require('./objects') - } + static Objects () { + return require('./objects') + } - static get platform () { - return require('./platform') - } + static get platform () { + return require('./platform') + } - static get script () { - return require('./script') - } + static get script () { + return require('./script') + } } module.exports = utils diff --git a/lib/utils/mutate.js b/lib/utils/mutate.js index 25730e6..f3739cd 100644 --- a/lib/utils/mutate.js +++ b/lib/utils/mutate.js @@ -61,4 +61,4 @@ class mutate extends utils { } } -module.exports = mutate \ No newline at end of file +module.exports = mutate diff --git a/lib/utils/objects.js b/lib/utils/objects.js index 4c5df16..d2f6e5c 100644 --- a/lib/utils/objects.js +++ b/lib/utils/objects.js @@ -2,6 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +const random = require('../random') const utils = require('../utils') const {logger} = require('../logging') @@ -113,4 +114,4 @@ class Objects { } } -module.exports = Object +module.exports = {Objects, o} diff --git a/lib/utils/script.js b/lib/utils/script.js index 1f632c0..a0733fe 100644 --- a/lib/utils/script.js +++ b/lib/utils/script.js @@ -2,8 +2,10 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -const utils = require('../utils') const random = require('../random') +const make = require('../make') +const utils = require('../utils') +const {o} = require('../objects') class script extends utils { static methodHead (list, numOptional) { diff --git a/package.json b/package.json index ccde6a9..b443dd4 100644 --- a/package.json +++ b/package.json @@ -2,13 +2,7 @@ "name": "octo", "version": "1.0.0", "description": "", - "keywords": [ - "fuzzing", - "browsers", - "javascript", - "node", - "library" - ], + "keywords": ["fuzzing", "browser", "javascript", "node", "library"], "homepage": "https://github.com/mozillasecurity/octo", "repository": { "type": "git", @@ -32,17 +26,7 @@ "standard": { "ignore": [ "tests/**", - "deploy/" - ], - "globals": [ - "random", - "make", - "utils", - "logger", - "MersenneTwister", - "o", - "btoa", - "atob" + "dist/" ], "envs": [ "browser" diff --git a/webpack.config.js b/webpack.config.js index 2e384a8..64dda53 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,14 +1,13 @@ const path = require('path') -const webpack = require("webpack") let config = { - entry: './lib/index.js', - output: { - filename: 'octo.js', - library: 'octo', - path: path.resolve(__dirname, 'dist'), - libraryTarget: 'var' - } + entry: './lib/index.js', + output: { + filename: 'octo.js', + library: 'octo', + path: path.resolve(__dirname, 'dist'), + libraryTarget: 'var' + } } -module.exports = config \ No newline at end of file +module.exports = config From 7c2273e26c7542a750cb47e3c7eeecb14ccf0e5f Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Mon, 19 Mar 2018 06:34:18 +0100 Subject: [PATCH 06/68] Fix static method for objects --- lib/utils/index.js | 2 +- lib/utils/objects.js | 5 ++++- lib/utils/script.js | 2 +- package.json | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/utils/index.js b/lib/utils/index.js index 77dd756..be0f16c 100644 --- a/lib/utils/index.js +++ b/lib/utils/index.js @@ -11,7 +11,7 @@ class utils { return require('./mutate') } - static Objects () { + static get objects () { return require('./objects') } diff --git a/lib/utils/objects.js b/lib/utils/objects.js index d2f6e5c..5460110 100644 --- a/lib/utils/objects.js +++ b/lib/utils/objects.js @@ -114,4 +114,7 @@ class Objects { } } -module.exports = {Objects, o} +module.exports = { + o, + Objects +} diff --git a/lib/utils/script.js b/lib/utils/script.js index a0733fe..f6105d2 100644 --- a/lib/utils/script.js +++ b/lib/utils/script.js @@ -5,7 +5,7 @@ const random = require('../random') const make = require('../make') const utils = require('../utils') -const {o} = require('../objects') +const {o} = require('./objects') class script extends utils { static methodHead (list, numOptional) { diff --git a/package.json b/package.json index b443dd4..5984cc5 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "octo", + "name": "@mozillasecurity/octo", "version": "1.0.0", "description": "", "keywords": ["fuzzing", "browser", "javascript", "node", "library"], From 014bc759304ddcf62b04d36db9930beda69accb9 Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Mon, 19 Mar 2018 06:38:07 +0100 Subject: [PATCH 07/68] Increase minor version number for NPM --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5984cc5..4f48d40 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mozillasecurity/octo", - "version": "1.0.0", + "version": "1.0.1", "description": "", "keywords": ["fuzzing", "browser", "javascript", "node", "library"], "homepage": "https://github.com/mozillasecurity/octo", From e902b1b4c2f2c7abe4e9f92bbb909aca3a72cc1f Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Mon, 19 Mar 2018 07:05:35 +0100 Subject: [PATCH 08/68] Update README.md --- README.md | 18 +++++++++++++++++- package.json | 8 +++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2093525..b8bdbbe 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,23 @@ Octo.js bundles core functions and generic boilerplate code commonly used in mos Octo's future aims to be a stable, well-tested and well-documented standard library for fuzzing in a JavaScript environment. -## Usage +## Node + +``` +npm i @mozillasecurity/octo --save-dev +``` + +``` +const {random} = require('@mozillasecurity/octo') +``` + + +## Browser + +``` +npm run build +``` + ```html diff --git a/package.json b/package.json index 4f48d40..417a783 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,13 @@ "name": "@mozillasecurity/octo", "version": "1.0.1", "description": "", - "keywords": ["fuzzing", "browser", "javascript", "node", "library"], + "keywords": [ + "fuzzing", + "browser", + "javascript", + "node", + "library" + ], "homepage": "https://github.com/mozillasecurity/octo", "repository": { "type": "git", From 79c8ad48987ffce25cd3631c47cc1ac90d319045 Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Mon, 19 Mar 2018 07:08:40 +0100 Subject: [PATCH 09/68] Change 'homepage' URL to update to ES6 branch README.md --- README.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b8bdbbe..a4c1623 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,8 @@ https://cdn.jsdelivr.net/gh/MozillaSecurity/octo@0.0.3/deploy/octo.js ```bash npm install npm run build +npm run watch +npm run test:lint ``` ## Testing diff --git a/package.json b/package.json index 417a783..31bcbc7 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "node", "library" ], - "homepage": "https://github.com/mozillasecurity/octo", + "homepage": "https://github.com/mozillasecurity/octo/tree/es6", "repository": { "type": "git", "url": "https://github.com/mozillasecurity/octo.git" From e8471d8edcb71320a7584d34ebb77f2ef9c71d7d Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Mon, 19 Mar 2018 07:09:11 +0100 Subject: [PATCH 10/68] Change 'homepage' URL to update to ES6 branch README.md --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 31bcbc7..c6d5a04 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mozillasecurity/octo", - "version": "1.0.1", + "version": "1.0.2", "description": "", "keywords": [ "fuzzing", From 94f85030e4b36e404ed9ebef08199f0aec96df25 Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Tue, 20 Mar 2018 00:03:55 +0100 Subject: [PATCH 11/68] Use global namespace for overwriting String|Array prototypes --- lib/utils/prototypes.js | 20 ++++++++++---------- package.json | 11 ++++++----- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/utils/prototypes.js b/lib/utils/prototypes.js index e50d95c..62e6aec 100644 --- a/lib/utils/prototypes.js +++ b/lib/utils/prototypes.js @@ -3,7 +3,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -Object.defineProperty(String.prototype, 'fromCodePoint', function () { +Object.defineProperty(global.String.prototype, 'fromCodePoint', function () { let chars = [] let point, offset, units, i for (i = 0; i < arguments.length; ++i) { @@ -19,33 +19,33 @@ Object.defineProperty(String.prototype, 'fromCodePoint', function () { return chars.join('') }) -Object.defineProperty(String.prototype, 'endsWith', function (str) { +Object.defineProperty(global.String.prototype, 'endsWith', function (str) { return this.match(str + '$') === str }) -Object.defineProperty(String.prototype, 'startsWith', function (str) { +Object.defineProperty(global.String.prototype, 'startsWith', function (str) { return this.match('^' + str) === str }) -Object.defineProperty(String.prototype, 'trim', function () { +Object.defineProperty(global.String.prototype, 'trim', function () { return this.replace(/^[\s\xA0]+/, '').replace(/[\s\xA0]+$/, '') }) -Object.defineProperty(String.prototype, 'insert', function (data, idx) { +Object.defineProperty(global.String.prototype, 'insert', function (data, idx) { return this.slice(0, idx) + data + this.slice(idx, this.length) }) -Object.defineProperty(Array.prototype, 'has', function (v) { +Object.defineProperty(global.Array.prototype, 'has', function (v) { return this.indexOf(v) !== -1 }) -Object.defineProperty(Array.prototype, 'forEach', function (array, fn) { +Object.defineProperty(global.Array.prototype, 'forEach', function (array, fn) { for (let i = 0; i < array.length; i++) { fn(array[i]) } }) -Object.defineProperty(Array.prototype, 'map', function (fn, array) { +Object.defineProperty(global.Array.prototype, 'map', function (fn, array) { let result = [] Array.forEach(array, function (element) { result.push(fn(element)) @@ -53,7 +53,7 @@ Object.defineProperty(Array.prototype, 'map', function (fn, array) { return result }) -Object.defineProperty(Array.prototype, 'extend', { +Object.defineProperty(global.Array.prototype, 'extend', { value: function (obj) { if (Array.isArray(obj)) { obj.forEach(function (v) { @@ -67,7 +67,7 @@ Object.defineProperty(Array.prototype, 'extend', { } }) -Object.defineProperty(Object, 'isObject', { +Object.defineProperty(global.Object, 'isObject', { value: function (obj) { return (obj !== null && typeof obj === 'object' && Object.prototype.toString.call(obj) === '[object Object]') diff --git a/package.json b/package.json index c6d5a04..eeca90f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mozillasecurity/octo", - "version": "1.0.2", + "version": "1.0.3", "description": "", "keywords": [ "fuzzing", @@ -34,9 +34,11 @@ "tests/**", "dist/" ], - "envs": [ - "browser" - ] + "envs": { + "browser": true, + "node": true, + "es6": true + } }, "devDependencies": { "cross-env": "^5.1.3", @@ -46,7 +48,6 @@ "grunt-standard": "*", "husky": "^0.14.3", "jshint": "^2.9.5", - "jshint-loader": "^0.8.4", "karma": "*", "karma-chrome-launcher": "*", "karma-coverage": "*", From 3c297bdea23d26eebe3c8db8946ca146af43221f Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Tue, 20 Mar 2018 00:55:16 +0100 Subject: [PATCH 12/68] Stick with require for overwriting String|Array prototypes --- lib/utils/index.js | 4 ++++ lib/utils/prototypes.js | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/utils/index.js b/lib/utils/index.js index be0f16c..c579338 100644 --- a/lib/utils/index.js +++ b/lib/utils/index.js @@ -22,6 +22,10 @@ class utils { static get script () { return require('./script') } + + static get prototypes () { + return require('./prototypes') + } } module.exports = utils diff --git a/lib/utils/prototypes.js b/lib/utils/prototypes.js index 62e6aec..e50d95c 100644 --- a/lib/utils/prototypes.js +++ b/lib/utils/prototypes.js @@ -3,7 +3,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -Object.defineProperty(global.String.prototype, 'fromCodePoint', function () { +Object.defineProperty(String.prototype, 'fromCodePoint', function () { let chars = [] let point, offset, units, i for (i = 0; i < arguments.length; ++i) { @@ -19,33 +19,33 @@ Object.defineProperty(global.String.prototype, 'fromCodePoint', function () { return chars.join('') }) -Object.defineProperty(global.String.prototype, 'endsWith', function (str) { +Object.defineProperty(String.prototype, 'endsWith', function (str) { return this.match(str + '$') === str }) -Object.defineProperty(global.String.prototype, 'startsWith', function (str) { +Object.defineProperty(String.prototype, 'startsWith', function (str) { return this.match('^' + str) === str }) -Object.defineProperty(global.String.prototype, 'trim', function () { +Object.defineProperty(String.prototype, 'trim', function () { return this.replace(/^[\s\xA0]+/, '').replace(/[\s\xA0]+$/, '') }) -Object.defineProperty(global.String.prototype, 'insert', function (data, idx) { +Object.defineProperty(String.prototype, 'insert', function (data, idx) { return this.slice(0, idx) + data + this.slice(idx, this.length) }) -Object.defineProperty(global.Array.prototype, 'has', function (v) { +Object.defineProperty(Array.prototype, 'has', function (v) { return this.indexOf(v) !== -1 }) -Object.defineProperty(global.Array.prototype, 'forEach', function (array, fn) { +Object.defineProperty(Array.prototype, 'forEach', function (array, fn) { for (let i = 0; i < array.length; i++) { fn(array[i]) } }) -Object.defineProperty(global.Array.prototype, 'map', function (fn, array) { +Object.defineProperty(Array.prototype, 'map', function (fn, array) { let result = [] Array.forEach(array, function (element) { result.push(fn(element)) @@ -53,7 +53,7 @@ Object.defineProperty(global.Array.prototype, 'map', function (fn, array) { return result }) -Object.defineProperty(global.Array.prototype, 'extend', { +Object.defineProperty(Array.prototype, 'extend', { value: function (obj) { if (Array.isArray(obj)) { obj.forEach(function (v) { @@ -67,7 +67,7 @@ Object.defineProperty(global.Array.prototype, 'extend', { } }) -Object.defineProperty(global.Object, 'isObject', { +Object.defineProperty(Object, 'isObject', { value: function (obj) { return (obj !== null && typeof obj === 'object' && Object.prototype.toString.call(obj) === '[object Object]') From 08b59b356ab9c8758572448fe2422d72da38c72f Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Tue, 20 Mar 2018 00:55:58 +0100 Subject: [PATCH 13/68] Stick with require for overwriting String|Array prototypes --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index eeca90f..7126e46 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mozillasecurity/octo", - "version": "1.0.3", + "version": "1.0.4", "description": "", "keywords": [ "fuzzing", From 1a7c08c16c6519312c87c802ac1ea13c73e27cf9 Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Tue, 20 Mar 2018 02:33:18 +0100 Subject: [PATCH 14/68] Remove unnecessary build step --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 7126e46..843b93e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mozillasecurity/octo", - "version": "1.0.4", + "version": "1.0.5", "description": "", "keywords": [ "fuzzing", @@ -26,7 +26,6 @@ "test:lint:fix": "cross-env NODE_ENV=test standard --fix --verbose", "build": "webpack -p", "watch": "webpack --watch", - "postinstall": "npm run build", "precommit": "npm run test:lint" }, "standard": { From 53d9167682d8f3437d83073e5e5c3fa855825b1e Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Wed, 21 Mar 2018 22:04:57 +0100 Subject: [PATCH 15/68] Prefer jsesc for quoting --- lib/utils/common.js | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/lib/utils/common.js b/lib/utils/common.js index 89be16e..fe6770f 100644 --- a/lib/utils/common.js +++ b/lib/utils/common.js @@ -1,6 +1,7 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +const jsesc = require('jsesc') const utils = require('../utils') class common extends utils { @@ -30,28 +31,7 @@ class common extends utils { } static quote (s) { - // Taken from DOMfuzz - function escapeString (s) { - return ('\"' + // eslint-disable-line no-useless-escape - s.replace(/\\/g, '\\\\') - .replace(/\"/g, '\\\"') // eslint-disable-line no-useless-escape - .replace(/\0/g, '\\0') - .replace(/\n/g, '\\n') + - '\"') // eslint-disable-line no-useless-escape - } - - if (typeof s === 'string') { - if (/^[\n\x20-\x7f]*$/.exec(s) || !self.uneval) { // eslint-disable-line no-undef - // Printable ASCII characters and line breaks: try to make it pretty. - return escapeString(s) - } else { - // Non-ASCII: use uneval to get \u escapes. - return uneval(s) // eslint-disable-line no-undef - } - } else { - // For other things (such as numbers, |null|, and |undefined|), just coerce to string. - return JSON.stringify(s) - } + return jsesc(s) } static b64encode (str) { From 0ec0980e8dae5d66befa1441b8688b6282312b02 Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Wed, 21 Mar 2018 22:26:35 +0100 Subject: [PATCH 16/68] Ensure proper quoting of jsesc --- lib/utils/common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utils/common.js b/lib/utils/common.js index fe6770f..cfcaea6 100644 --- a/lib/utils/common.js +++ b/lib/utils/common.js @@ -31,7 +31,7 @@ class common extends utils { } static quote (s) { - return jsesc(s) + return `'${jsesc(s)}'` } static b64encode (str) { From 9e97d0d59f5343f4cdb9482c4806b1b898e727f6 Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Wed, 21 Mar 2018 22:36:13 +0100 Subject: [PATCH 17/68] Fix calling logger --- lib/logging/console.js | 87 ------------------------------------------ lib/logging/index.js | 85 ++++++++++++++++++++++++++++++++++++++--- package.json | 17 +++++---- 3 files changed, 90 insertions(+), 99 deletions(-) delete mode 100644 lib/logging/console.js diff --git a/lib/logging/console.js b/lib/logging/console.js deleted file mode 100644 index cda8e0e..0000000 --- a/lib/logging/console.js +++ /dev/null @@ -1,87 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -const utils = require('../utils') - -let websocket = null - -const sep = '\n/* ### NEXT TESTCASE ############################## */' -const color = { - red: '\u{1b}[1;31m', - green: '\u{1b}[1;32m', - clear: '\u{1b}[0m' -} -if (utils.platform.name.isWindows) { - color.red = '' - color.green = '' - color.clear = '' -} - -class logger { - static console (msg) { - if (websocket) { - websocket.send(msg) - } - if (typeof window === 'undefined') { - try { - print(msg) // eslint-disable-line no-undef - } catch (e) { - console.log(msg) - } - } else if (window.dump) { - dump(msg) // eslint-disable-line no-undef - } else if (window.console && window.console.log) { - console.log(msg) - } else { - throw new Error('Unable to run console logger.') - } - } - - static dump (msg) { - this.console(msg) - } - - static dumpln (msg) { - this.dump(`${msg}\n`) - } - - static log (msg) { - this.dumpln(`/*L*/ ${utils.script.safely(msg)}`) - } - - static info (msg) { - this.dumpln(`/*L*/ /* ${msg} */`) - } - - static error (msg) { - this.dumpln(color.red + msg + color.clear) - } - - static ok (msg) { // eslint-disable-line no-unused-vars - this.dumpln(color.green + msg + color.green) - } - - static JSError (msg) { - this.error(`/* ERROR: ${msg} */`) - } - - static comment (msg) { - this.dumpln(`/*L*/ // ${msg}`) - } - - static separator () { - this.dumpln(color.green + sep + color.clear) - } - - static traceback () { - this.error('===[ Traceback ] ===') - try { - throw new Error() - } catch (e) { - this.dump(e.stack || e.stacktrace || '') - } - } -} - -module.exports = logger diff --git a/lib/logging/index.js b/lib/logging/index.js index 3468436..cda8e0e 100644 --- a/lib/logging/index.js +++ b/lib/logging/index.js @@ -2,11 +2,86 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -class logging { - static get logger () { - // Or: const {logger} = require('./logging') - return require('./console') +const utils = require('../utils') + +let websocket = null + +const sep = '\n/* ### NEXT TESTCASE ############################## */' +const color = { + red: '\u{1b}[1;31m', + green: '\u{1b}[1;32m', + clear: '\u{1b}[0m' +} +if (utils.platform.name.isWindows) { + color.red = '' + color.green = '' + color.clear = '' +} + +class logger { + static console (msg) { + if (websocket) { + websocket.send(msg) + } + if (typeof window === 'undefined') { + try { + print(msg) // eslint-disable-line no-undef + } catch (e) { + console.log(msg) + } + } else if (window.dump) { + dump(msg) // eslint-disable-line no-undef + } else if (window.console && window.console.log) { + console.log(msg) + } else { + throw new Error('Unable to run console logger.') + } + } + + static dump (msg) { + this.console(msg) + } + + static dumpln (msg) { + this.dump(`${msg}\n`) + } + + static log (msg) { + this.dumpln(`/*L*/ ${utils.script.safely(msg)}`) + } + + static info (msg) { + this.dumpln(`/*L*/ /* ${msg} */`) + } + + static error (msg) { + this.dumpln(color.red + msg + color.clear) + } + + static ok (msg) { // eslint-disable-line no-unused-vars + this.dumpln(color.green + msg + color.green) + } + + static JSError (msg) { + this.error(`/* ERROR: ${msg} */`) + } + + static comment (msg) { + this.dumpln(`/*L*/ // ${msg}`) + } + + static separator () { + this.dumpln(color.green + sep + color.clear) + } + + static traceback () { + this.error('===[ Traceback ] ===') + try { + throw new Error() + } catch (e) { + this.dump(e.stack || e.stacktrace || '') + } } } -module.exports = logging +module.exports = logger diff --git a/package.json b/package.json index 843b93e..2f167c0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mozillasecurity/octo", - "version": "1.0.5", + "version": "1.0.8", "description": "", "keywords": [ "fuzzing", @@ -40,21 +40,24 @@ } }, "devDependencies": { - "cross-env": "^5.1.3", + "cross-env": "^5.1.4", "grunt": "*", "grunt-karma": "*", "grunt-karma-coveralls": "*", "grunt-standard": "*", "husky": "^0.14.3", - "jshint": "^2.9.5", "karma": "*", "karma-chrome-launcher": "*", "karma-coverage": "*", - "karma-firefox-launcher": "*", - "karma-qunit": "*", - "qunitjs": "*", - "standard": "*", + "karma-firefox-launcher": "^1.1.0", + "karma-qunit": "^2.0.1", + "qunit": "^2.5.1", + "qunitjs": "^2.4.1", + "standard": "^11.0.1", "webpack": "^4.1.1", "webpack-cli": "^2.0.12" + }, + "dependencies": { + "jsesc": "^2.5.1" } } From a869409853d8a06f92dd864aa6732a80f1bbbdc9 Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Thu, 22 Mar 2018 00:08:55 +0100 Subject: [PATCH 18/68] Fix prototypes and explicitly enable them --- lib/utils/prototypes.js | 108 ++++++++++++++++------------------------ package.json | 2 +- 2 files changed, 44 insertions(+), 66 deletions(-) diff --git a/lib/utils/prototypes.js b/lib/utils/prototypes.js index e50d95c..5fa890a 100644 --- a/lib/utils/prototypes.js +++ b/lib/utils/prototypes.js @@ -3,73 +3,51 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -Object.defineProperty(String.prototype, 'fromCodePoint', function () { - let chars = [] - let point, offset, units, i - for (i = 0; i < arguments.length; ++i) { - point = arguments[i] - offset = point - 0x10000 - units = point > 0xFFFF - ? [ - 0xD800 + (offset >> 10), - 0xDC00 + (offset & 0x3FF)] - : [point] - chars.push(String.fromCharCode.apply(null, units)) - } - return chars.join('') -}) +const utils = require('../utils') -Object.defineProperty(String.prototype, 'endsWith', function (str) { - return this.match(str + '$') === str -}) - -Object.defineProperty(String.prototype, 'startsWith', function (str) { - return this.match('^' + str) === str -}) - -Object.defineProperty(String.prototype, 'trim', function () { - return this.replace(/^[\s\xA0]+/, '').replace(/[\s\xA0]+$/, '') -}) - -Object.defineProperty(String.prototype, 'insert', function (data, idx) { - return this.slice(0, idx) + data + this.slice(idx, this.length) -}) - -Object.defineProperty(Array.prototype, 'has', function (v) { - return this.indexOf(v) !== -1 -}) - -Object.defineProperty(Array.prototype, 'forEach', function (array, fn) { - for (let i = 0; i < array.length; i++) { - fn(array[i]) - } -}) - -Object.defineProperty(Array.prototype, 'map', function (fn, array) { - let result = [] - Array.forEach(array, function (element) { - result.push(fn(element)) - }) - return result -}) - -Object.defineProperty(Array.prototype, 'extend', { - value: function (obj) { - if (Array.isArray(obj)) { - obj.forEach(function (v) { - if (typeof v !== 'undefined') { - this.push(v) +class prototypes extends utils { + static enable () { + if (!String.prototype.hasOwnProperty('insert')) { + Object.defineProperty(String.prototype, 'insert', { + value: function (data, i) { + return this.slice(0, i) + data + this.slice(i, this.length) } - }, this) - } else { - this.push(obj) + }) + } + + if (!Array.prototype.hasOwnProperty('has')) { + Object.defineProperty(Array.prototype, 'has', { + value: function (v) { + return this.indexOf(v) !== -1 + } + }) + } + + if (!Array.prototype.hasOwnProperty('extend')) { + Object.defineProperty(Array.prototype, 'extend', { + value: function (obj) { + if (Array.isArray(obj)) { + obj.forEach(function (v) { + if (typeof v !== 'undefined') { + this.push(v) + } + }, this) + } else { + this.push(obj) + } + } + }) + } + + if (!Object.hasOwnProperty('isObject')) { + Object.defineProperty(Object, 'isObject', { + value: function (obj) { + return (obj !== null && typeof obj === 'object' && + Object.prototype.toString.call(obj) === '[object Object]') + } + }) } } -}) +} -Object.defineProperty(Object, 'isObject', { - value: function (obj) { - return (obj !== null && typeof obj === 'object' && - Object.prototype.toString.call(obj) === '[object Object]') - } -}) +module.exports = prototypes diff --git a/package.json b/package.json index 2f167c0..6411f15 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mozillasecurity/octo", - "version": "1.0.8", + "version": "1.0.9", "description": "", "keywords": [ "fuzzing", From 19a2f212592fd08c53681bf86cf76767741ff977 Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Thu, 22 Mar 2018 00:17:33 +0100 Subject: [PATCH 19/68] Merge datetime with time class --- lib/make/datetime.js | 35 ----------------------------------- lib/make/index.js | 4 ---- lib/make/time.js | 27 ++++++++++++++++++++++++++- package.json | 2 +- 4 files changed, 27 insertions(+), 41 deletions(-) delete mode 100644 lib/make/datetime.js diff --git a/lib/make/datetime.js b/lib/make/datetime.js deleted file mode 100644 index 4e81c99..0000000 --- a/lib/make/datetime.js +++ /dev/null @@ -1,35 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -const make = require('../make') -const random = require('../random') - -class datetime extends make { - static object () { - switch (random.number(2)) { - case 0: - return new Date(new Date().getTime() + random.number()) - case 1: - return new Date(new Date().getTime() - random.number()) - } - } - - static date () { - return this.object().toDateString() - } - - static time () { - return this.object().toTimeString() - } - - static iso () { - return this.object().toISOString() - } - - static epoch () { - return Math.floor(this.object() / 1000) - } -} - -module.exports = datetime diff --git a/lib/make/index.js b/lib/make/index.js index 99d31b9..b78f984 100644 --- a/lib/make/index.js +++ b/lib/make/index.js @@ -27,10 +27,6 @@ class make { return require('./crypto') } - static get datetime () { - return require('./datetime') - } - static get files () { return require('./files') } diff --git a/lib/make/time.js b/lib/make/time.js index aad6c08..4105dd6 100644 --- a/lib/make/time.js +++ b/lib/make/time.js @@ -12,8 +12,33 @@ class time extends make { ]) } + static datetime () { + switch (random.number(2)) { + case 0: + return new Date(new Date().getTime() + random.number()) + case 1: + return new Date(new Date().getTime() - random.number()) + } + } + + static date () { + return time.datetime().toDateString() + } + + static time () { + return time.datetime().toTimeString() + } + + static iso () { + return time.datetime().toISOString() + } + + static epoch () { + return Math.floor(time.object() / 1000) + } + static any () { - return make.number.any() + this.unit() + return make.number.any() + time.unit() } } diff --git a/package.json b/package.json index 6411f15..2551879 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mozillasecurity/octo", - "version": "1.0.9", + "version": "1.0.10", "description": "", "keywords": [ "fuzzing", From a5a68d53aff572780ef1e3545344b65ff9316805 Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Thu, 22 Mar 2018 18:32:29 +0100 Subject: [PATCH 20/68] Update README.md --- README.md | 40 +++++++++++++++++----------------------- package.json | 2 +- 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index a4c1623..4aaf101 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,9 @@ A unified shared library which aids in building fuzzers for browsers or as compl

JavaScript Style Guide -Build Status -Current Release -Coverage Status + + + IRC

@@ -18,41 +18,37 @@ Octo.js bundles core functions and generic boilerplate code commonly used in mos Octo's future aims to be a stable, well-tested and well-documented standard library for fuzzing in a JavaScript environment. +## Note +The ES6 branch is under active development while we are incorporating it with our existing fuzzers. + + +## Playbook + +https://runkit.com/posidron/octo-js-playbook + ## Node ``` -npm i @mozillasecurity/octo --save-dev +npm i @mozillasecurity/octo ``` ``` const {random} = require('@mozillasecurity/octo') +random.init() ``` ## Browser +We have not yet merged ES6 to master, hence the browser version which was released on master is not up-to-date. +Use the `dist/octo.js` version of this branch by running the following command. + ``` npm run build ``` -```html - -https://mozillasecurity.github.io/octo/octo.js - -``` - -```html - -https://github.com/mozillasecurity/octo/releases/download/0.0.3/octo.js -``` - -```html - -https://cdn.jsdelivr.net/gh/MozillaSecurity/octo@0.0.3/deploy/octo.js -``` - ## Development ```bash @@ -70,7 +66,5 @@ The automated tests are run in Firefox or Chrome using [Karma](https://karma-run To run the automated tests: ```bash -npm install -CHROME_BIN=chromium npm test +npm test ``` -When adding new files, add them in `index.html` and `karma.conf.js` so they can be tested and included in coverage reports. diff --git a/package.json b/package.json index 2551879..50cefb4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mozillasecurity/octo", - "version": "1.0.10", + "version": "1.0.11", "description": "", "keywords": [ "fuzzing", From f394b75f3819c2815b1e6c09976baa8da51733bb Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Fri, 6 Apr 2018 12:13:05 +0200 Subject: [PATCH 21/68] Add constants for WebGL getParameter functions --- lib/make/webgl.js | 190 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 191 insertions(+), 1 deletion(-) diff --git a/lib/make/webgl.js b/lib/make/webgl.js index 568a080..828bbe7 100644 --- a/lib/make/webgl.js +++ b/lib/make/webgl.js @@ -595,6 +595,196 @@ class webgl extends make { } return random.item(usage) } + + static randomParameter (isWebGL2) { + let pname = [ + 'ACTIVE_TEXTURE', + 'ALIASED_LINE_WIDTH_RANGE', + 'ALIASED_POINT_SIZE_RANGE', + 'ALPHA_BITS', + 'ARRAY_BUFFER_BINDING', + 'BLEND', + 'BLEND_COLOR', + 'BLEND_DST_ALPHA', + 'BLEND_DST_RGB', + 'BLEND_EQUATION_ALPHA', + 'BLEND_EQUATION_RGB', + 'BLEND_SRC_ALPHA', + 'BLEND_SRC_RGB', + 'BLUE_BITS', + 'COLOR_CLEAR_VALUE', + 'COLOR_WRITEMASK', + 'COMPRESSED_TEXTURE_FORMATS', + 'CULL_FACE', + 'CULL_FACE_MODE', + 'CURRENT_PROGRAM', + 'DEPTH_BITS', + 'DEPTH_CLEAR_VALUE', + 'DEPTH_FUNC', + 'DEPTH_RANGE', + 'DEPTH_TEST', + 'DEPTH_WRITEMASK', + 'DITHER', + 'ELEMENT_ARRAY_BUFFER_BINDING', + 'FRAMEBUFFER_BINDING', + 'FRONT_FACE', + 'GENERATE_MIPMAP_HINT', + 'GREEN_BITS', + 'IMPLEMENTATION_COLOR_READ_FORMAT', + 'IMPLEMENTATION_COLOR_READ_TYPE', + 'LINE_WIDTH', + 'MAX_COMBINED_TEXTURE_IMAGE_UNITS', + 'MAX_CUBE_MAP_TEXTURE_SIZE', + 'MAX_FRAGMENT_UNIFORM_VECTORS', + 'MAX_RENDERBUFFER_SIZE', + 'MAX_TEXTURE_IMAGE_UNITS', + 'MAX_TEXTURE_SIZE', + 'MAX_VARYING_VECTORS', + 'MAX_VERTEX_ATTRIBS', + 'MAX_VERTEX_TEXTURE_IMAGE_UNITS', + 'MAX_VERTEX_UNIFORM_VECTORS', + 'MAX_VIEWPORT_DIMS', + 'PACK_ALIGNMENT', + 'POLYGON_OFFSET_FACTOR', + 'POLYGON_OFFSET_FILL', + 'POLYGON_OFFSET_UNITS', + 'RED_BITS', + 'RENDERBUFFER_BINDING', + 'RENDERER', + 'SAMPLE_ALPHA_TO_COVERAGE', + 'SAMPLE_BUFFERS', + 'SAMPLE_COVERAGE', + 'SAMPLE_COVERAGE_INVERT', + 'SAMPLE_COVERAGE_VALUE', + 'SAMPLES', + 'SCISSOR_BOX', + 'SCISSOR_TEST', + 'SHADING_LANGUAGE_VERSION', + 'STENCIL_BACK_FAIL', + 'STENCIL_BACK_FUNC', + 'STENCIL_BACK_PASS_DEPTH_FAIL', + 'STENCIL_BACK_PASS_DEPTH_PASS', + 'STENCIL_BACK_REF', + 'STENCIL_BACK_VALUE_MASK', + 'STENCIL_BACK_WRITEMASK', + 'STENCIL_BITS', + 'STENCIL_CLEAR_VALUE', + 'STENCIL_FAIL', + 'STENCIL_FUNC', + 'STENCIL_PASS_DEPTH_FAIL', + 'STENCIL_PASS_DEPTH_PASS', + 'STENCIL_REF', + 'STENCIL_TEST', + 'STENCIL_VALUE_MASK', + 'STENCIL_WRITEMASK', + 'SUBPIXEL_BITS', + 'TEXTURE_BINDING_2D', + 'TEXTURE_BINDING_CUBE_MAP', + 'UNPACK_ALIGNMENT', + 'UNPACK_COLORSPACE_CONVERSION_WEBGL', + 'UNPACK_FLIP_Y_WEBGL', + 'UNPACK_PREMULTIPLY_ALPHA_WEBGL', + 'VENDOR', + 'VERSION', + 'VIEWPORT', + 'VERSION', + 'SHADING_LANGUAGE_VERSION', + 'VENDOR', + 'RENDERER' + ] + + if (isWebGL2) { + pname.extends([ + 'COPY_READ_BUFFER_BINDING', + 'COPY_WRITE_BUFFER_BINDING', + 'DRAW_BUFFERi', + 'DRAW_FRAMEBUFFER_BINDING', + 'FRAGMENT_SHADER_DERIVATIVE_HINT', + 'MAX_3D_TEXTURE_SIZE', + 'MAX_ARRAY_TEXTURE_LAYERS', + 'MAX_CLIENT_WAIT_TIMEOUT_WEBGL', + 'MAX_COLOR_ATTACHMENTS', + 'MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS', + 'MAX_COMBINED_UNIFORM_BLOCKS', + 'MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS', + 'MAX_DRAW_BUFFERS', + 'MAX_ELEMENT_INDEX', + 'MAX_ELEMENTS_INDICE', + 'MAX_ELEMENTS_VERTICES', + 'MAX_FRAGMENT_INPUT_COMPONENTS', + 'MAX_FRAGMENT_UNIFORM_BLOCKS', + 'MAX_FRAGMENT_UNIFORM_COMPONENTS', + 'MAX_PROGRAM_TEXEL_OFFSET', + 'MAX_SAMPLES', + 'MAX_SERVER_WAIT_TIMEOUT', + 'MAX_TEXTURE_LOD_BIAS', + 'MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS', + 'MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS', + 'MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS', + 'MAX_UNIFORM_BLOCK_SIZE', + 'MAX_UNIFORM_BUFFER_BINDINGS', + 'MAX_VARYING_COMPONENTS', + 'MAX_VERTEX_OUTPUT_COMPONENTS', + 'MAX_VERTEX_UNIFORM_BLOCKS', + 'MAX_VERTEX_UNIFORM_COMPONENTS', + 'MIN_PROGRAM_TEXEL_OFFSET', + 'PACK_ROW_LENGTH', + 'PACK_SKIP_PIXELS', + 'PACK_SKIP_ROWS', + 'PIXEL_PACK_BUFFER_BINDING', + 'PIXEL_UNPACK_BUFFER_BINDING', + 'RASTERIZER_DISCARD', + 'READ_BUFFER', + 'READ_FRAMEBUFFER_BINDING', + 'SAMPLER_BINDING', + 'TEXTURE_BINDING_2D_ARRAY', + 'TEXTURE_BINDING_3D', + 'TRANSFORM_FEEDBACK_ACTIVE', + 'TRANSFORM_FEEDBACK_BINDING', + 'TRANSFORM_FEEDBACK_BUFFER_BINDING', + 'TRANSFORM_FEEDBACK_PAUSED', + 'UNIFORM_BUFFER_BINDING', + 'UNIFORM_BUFFER_OFFSET_ALIGNMENT', + 'UNPACK_IMAGE_HEIGHT', + 'UNPACK_ROW_LENGTH', + 'UNPACK_SKIP_IMAGES', + 'UNPACK_SKIP_PIXELS', + 'UNPACK_SKIP_ROWS', + 'VERTEX_ARRAY_BINDING' + ]) + } + return random.item(pname) + } + + static randomProgramParameter () { + let pname = [ + 'DELETE_STATUS', + 'LINK_STATUS', + 'VALIDATE_STATUS', + 'ATTACHED_SHADERS', + 'ACTIVE_ATTRIBUTES', + 'ACTIVE_UNIFORMS', + 'TRANSFORM_FEEDBACK_BUFFER_MODE', + 'TRANSFORM_FEEDBACK_VARYINGS', + 'ACTIVE_UNIFORM_BLOCKS' + ] + return random.item(pname) + } + + static randomRenderBufferParameter () { + let pname = [ + 'RENDERBUFFER_WIDTH', + 'RENDERBUFFER_HEIGHT', + 'RENDERBUFFER_INTERNAL_FORMAT', + 'RENDERBUFFER_RED_SIZE', + 'RENDERBUFFER_GREEN_SIZE', + 'RENDERBUFFER_BLUE_SIZE', + 'RENDERBUFFER_ALPHA_SIZE', + 'RENDERBUFFER_DEPTH_SIZE', + 'RENDERBUFFER_STENCIL_SIZE' + ] + return random.item(pname) + } } module.exports = webgl diff --git a/package.json b/package.json index 50cefb4..e110765 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mozillasecurity/octo", - "version": "1.0.11", + "version": "1.0.12", "description": "", "keywords": [ "fuzzing", From 297002fec486efc29a3754a6703eeff12dc8dbc1 Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Fri, 6 Apr 2018 19:45:19 +0200 Subject: [PATCH 22/68] Let safely() support Arrays --- lib/utils/script.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/utils/script.js b/lib/utils/script.js index f6105d2..bf09ca0 100644 --- a/lib/utils/script.js +++ b/lib/utils/script.js @@ -68,8 +68,12 @@ class script extends utils { return JSON.stringify(o) } - static safely (s) { - return `try { ${s} } catch(e) { }` + static safely (obj) { + if (Array.isArray(obj)) { + return obj.map(s => utils.script.safely(s)).join(' ') + } else { + return `try { ${obj} } catch(e) { }` + } } static makeLoop (s, max) { From 42cadc6db0696c8b3c646bc9e105d2121d2bc2f2 Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Fri, 6 Apr 2018 21:57:37 +0200 Subject: [PATCH 23/68] Add postinstal step to build octo --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e110765..87aa4a1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mozillasecurity/octo", - "version": "1.0.12", + "version": "1.0.13", "description": "", "keywords": [ "fuzzing", @@ -26,7 +26,8 @@ "test:lint:fix": "cross-env NODE_ENV=test standard --fix --verbose", "build": "webpack -p", "watch": "webpack --watch", - "precommit": "npm run test:lint" + "precommit": "npm run test:lint", + "postinstall": "npm run build" }, "standard": { "ignore": [ From d2c84b56a866fedef81d05262dc192e2045a639d Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Fri, 6 Apr 2018 22:02:56 +0200 Subject: [PATCH 24/68] Add webpack to normal dependencies --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 87aa4a1..01a38bc 100644 --- a/package.json +++ b/package.json @@ -55,10 +55,10 @@ "qunit": "^2.5.1", "qunitjs": "^2.4.1", "standard": "^11.0.1", - "webpack": "^4.1.1", - "webpack-cli": "^2.0.12" }, "dependencies": { - "jsesc": "^2.5.1" + "jsesc": "^2.5.1", + "webpack": "^4.1.1", + "webpack-cli": "^2.0.12" } } From 58a6a1ce7882182f59ff5df178faeca5fe70f300 Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Fri, 6 Apr 2018 22:05:51 +0200 Subject: [PATCH 25/68] Add webpack to normal dependencies --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 01a38bc..ccf9b1b 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "karma-qunit": "^2.0.1", "qunit": "^2.5.1", "qunitjs": "^2.4.1", - "standard": "^11.0.1", + "standard": "^11.0.1" }, "dependencies": { "jsesc": "^2.5.1", From c9e1987eb16c46d879b443c461bf9b5a44e2d000 Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Fri, 6 Apr 2018 22:50:48 +0200 Subject: [PATCH 26/68] Fix mime module --- lib/make/mime.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/make/mime.js b/lib/make/mime.js index 1a7b28a..2d8e909 100644 --- a/lib/make/mime.js +++ b/lib/make/mime.js @@ -8,11 +8,11 @@ const random = require('../random') class mime extends make { static any () { return random.pick([ - this.standard, - this.xml, - this.image, - this.media, - this.form + mime.standard, + mime.xml, + mime.image, + mime.media, + mime.form ]) } From fc53bca173670d6a023d19d1c97bfc092ff2a0cf Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Sat, 7 Apr 2018 00:15:55 +0200 Subject: [PATCH 27/68] Fix various modules using this --- lib/make/colors.js | 6 ++--- lib/make/command.js | 4 ++-- lib/make/files.js | 6 ++--- lib/make/fonts.js | 14 ++++++------ lib/make/network.js | 18 +++++++-------- lib/make/text.js | 14 ++++++------ lib/make/typed.js | 24 ++++++++++---------- lib/make/uri.js | 6 ++--- lib/make/webgl.js | 6 ++--- lib/random/random.js | 53 ++++++++++++++++++++++++++------------------ 10 files changed, 80 insertions(+), 71 deletions(-) diff --git a/lib/make/colors.js b/lib/make/colors.js index 959b575..929a992 100644 --- a/lib/make/colors.js +++ b/lib/make/colors.js @@ -8,9 +8,9 @@ const random = require('../random') class colors extends make { static any () { return random.pick([ - this.rgb, - this.hsl, - this.keyword + colors.rgb, + colors.hsl, + colors.keyword ]) } diff --git a/lib/make/command.js b/lib/make/command.js index 2648747..d6827be 100644 --- a/lib/make/command.js +++ b/lib/make/command.js @@ -58,11 +58,11 @@ class command extends make { } static name () { - return random.item(Object.keys(this.data())) + return random.item(Object.keys(command.data())) } static value (value) { - return random.pick(this.data()[name]) + return random.pick(command.data()[name]) } } diff --git a/lib/make/files.js b/lib/make/files.js index 76aac78..8b80d35 100644 --- a/lib/make/files.js +++ b/lib/make/files.js @@ -43,9 +43,9 @@ class files extends make { static any () { return random.pick([ - this.image, - this.video, - this.audio + files.image, + files.video, + files.audio ]) } } diff --git a/lib/make/fonts.js b/lib/make/fonts.js index 402812d..16ec092 100644 --- a/lib/make/fonts.js +++ b/lib/make/fonts.js @@ -56,9 +56,9 @@ class font extends make { } static family () { - let s = random.pick(this.familyName) + let s = random.pick(font.familyName) if (random.chance(8)) { - s += ', ' + random.pick(this.genericFamily) + s += ', ' + random.pick(font.genericFamily) } return s } @@ -86,20 +86,20 @@ class font extends make { static font () { let s = '' if (random.chance(4)) { - s += random.pick(this.style) + ' ' + s += random.pick(font.style) + ' ' } if (random.chance(4)) { - s += random.pick(this.variant) + ' ' + s += random.pick(font.variant) + ' ' } if (random.chance(4)) { - s += random.pick(this.weight) + ' ' + s += random.pick(font.weight) + ' ' } if (random.chance(4)) { s += make.number.any() + '/' } - s += this.size() + s += font.size() s += ' ' - s += this.family() + s += font.family() return s } } diff --git a/lib/make/network.js b/lib/make/network.js index c7ebe02..a1a16aa 100644 --- a/lib/make/network.js +++ b/lib/make/network.js @@ -56,7 +56,7 @@ class network extends make { ' ', random.pick([make.number.any]), ' ', - random.pick([this.goodHostnames]), + random.pick([network.goodHostnames]), ' ', random.pick([56187, make.number.any]), ' ', @@ -69,7 +69,7 @@ class network extends make { ' ', random.pick(['raddr']), ' ', - random.pick([this.goodHostnames]), + random.pick([network.goodHostnames]), ' ', random.pick(['rport']), random.use([utils.block.block([' ', make.number.any])]) @@ -95,12 +95,12 @@ class network extends make { // https://tools.ietf.org/html/rfc7065#section-3.1 return utils.block.block([ // scheme - random.pick(this.PeerConnectionProtocols), + random.pick(network.PeerConnectionProtocols), ':', // turn-host random.pick([ - this.any, - this.hostname + network.any, + network.hostname ]), // turn-port random.use([utils.block.block([':', make.number.any])]), @@ -172,10 +172,10 @@ class network extends make { static hostname () { return random.pick([ - this.randomIPv4, - this.randomIPv6, - this.goodHostnames, - this.badHostnames + network.randomIPv4, + network.randomIPv6, + network.goodHostnames, + network.badHostnames ]) } diff --git a/lib/make/text.js b/lib/make/text.js index 9e0737a..e1ee21b 100644 --- a/lib/make/text.js +++ b/lib/make/text.js @@ -219,17 +219,17 @@ class text extends make { } static quotedString () { - return utils.common.quote(this.any()) + return utils.common.quote(text.any()) } static chars () { return random.pick([ - this.controlChar, - this.token, - this.assignmentOperator, - this.arithmeticOperator, - String.fromCharCode(this.layoutCharCodes()), - String.fromCharCode(this.bidiCharCodes()) + text.controlChar, + text.token, + text.assignmentOperator, + text.arithmeticOperator, + String.fromCharCode(text.layoutCharCodes()), + String.fromCharCode(text.bidiCharCodes()) ]) } diff --git a/lib/make/typed.js b/lib/make/typed.js index 3b8fdb1..5f957a6 100644 --- a/lib/make/typed.js +++ b/lib/make/typed.js @@ -78,27 +78,27 @@ class typed extends make { static any () { return random.choose([ - [1, [this.byte, this.octet]], - [1, [this.short, this.unsignedShort]], - [1, [this.long, this.unsignedLong]], - [1, [this.float, this.unrestrictedFloat]], - [1, [this.double, this.unrestrictedDouble]], + [1, [typed.byte, typed.octet]], + [1, [typed.short, typed.unsignedShort]], + [1, [typed.long, typed.unsignedLong]], + [1, [typed.float, typed.unrestrictedFloat]], + [1, [typed.double, typed.unrestrictedDouble]], [1, [make.number.range, make.number.tiny]] ]) } static arrayBuffer (byteLength = null) { - let length = (byteLength !== null) ? byteLength : this.unsignedShort() + let length = (byteLength !== null) ? byteLength : typed.unsignedShort() return 'new ArrayBuffer(' + length + ')' } static dataView (byteLength = null) { - let length = (byteLength !== null) ? byteLength : this.unsignedShort() - return 'new DataView(' + this.arrayBuffer(length) + ')' + let length = (byteLength !== null) ? byteLength : typed.unsignedShort() + return 'new DataView(' + typed.arrayBuffer(length) + ')' } static typedArray (byteLength = null) { - let length = (byteLength !== null) ? byteLength : this.unsignedShort() + let length = (byteLength !== null) ? byteLength : typed.unsignedShort() let arrType = random.item([ 'Int8', 'Uint8', 'Uint8Clamped', 'Int16', 'Uint16', @@ -119,11 +119,11 @@ class typed extends make { static bufferSource () { switch (random.number(4)) { case 0: - return this.arrayBuffer() + return typed.arrayBuffer() case 1: - return this.dataView() + return typed.dataView() default: - return this.typedArray() + return typed.typedArray() } } } diff --git a/lib/make/uri.js b/lib/make/uri.js index d65f2d9..cfa9fa3 100644 --- a/lib/make/uri.js +++ b/lib/make/uri.js @@ -44,9 +44,9 @@ class uri extends make { static any () { return random.choose([ - [1, this.problematic], - [10, this.standard], - [10, this.namespace], + [1, uri.problematic], + [10, uri.standard], + [10, uri.namespace], [10, make.files.any] ]) } diff --git a/lib/make/webgl.js b/lib/make/webgl.js index 828bbe7..bab4599 100644 --- a/lib/make/webgl.js +++ b/lib/make/webgl.js @@ -41,9 +41,9 @@ class webgl extends make { } static WebGLFormat () { - let internalformat = random.item(Object.keys(this.internalFormat)) - let format = this.internalFormat[internalformat].format - let type = random.item(this.internalFormat[internalformat].type) + let internalformat = random.item(Object.keys(webgl.internalFormat)) + let format = webgl.internalFormat[internalformat].format + let type = random.item(webgl.internalFormat[internalformat].type) return [internalformat, format, type] } diff --git a/lib/random/random.js b/lib/random/random.js index 541891f..63a1f61 100644 --- a/lib/random/random.js +++ b/lib/random/random.js @@ -12,10 +12,10 @@ class random { */ static init (seed) { if (seed === null || seed === undefined) { - this.seed = new Date().getTime() + random.seed = new Date().getTime() } - this.twister = new MersenneTwister() - this.twister.seed(this.seed) + random.twister = new MersenneTwister() + random.twister.seed(random.seed) } /** @@ -23,6 +23,9 @@ class random { * @param limit */ static number (limit) { + if (!random.twister) { + throw new Error('random.init must be called first.') + } if (limit === null || limit === undefined) { limit = 0xffffffff } @@ -30,7 +33,7 @@ class random { let y = (x * limit) >>> 0 let r do { - r = this.twister.int32() + r = random.twister.int32() } while (y && r >= y) // eslint-disable-line no-unmodified-loop-condition return (r / x) >>> 0 } @@ -39,7 +42,10 @@ class random { * Returns a float in [0, 1). Uniform distribution. */ static float () { - return this.twister.real2() + if (!random.twister) { + throw new Error('random.init must be called first.') + } + return random.twister.real2() } /** @@ -48,11 +54,14 @@ class random { * @param limit */ static range (start, limit) { + if (!random.twister) { + throw new Error('random.init must be called first.') + } if (isNaN(start) || isNaN(limit)) { logger.traceback() throw new TypeError(`random.range() received non-number type: (${start}, ${limit})`) } - return this.number(limit - start + 1) + start + return random.number(limit - start + 1) + start } /** @@ -60,7 +69,7 @@ class random { * @param {*} limit */ static ludOneTo (limit) { - return Math.exp(this.float() * Math.log(limit)) + return Math.exp(random.float() * Math.log(limit)) } static item (list) { @@ -68,7 +77,7 @@ class random { logger.traceback() throw new TypeError(`random.item() received invalid object: (${list})`) } - return list[this.number(list.length)] + return list[random.number(list.length)] } /** @@ -80,14 +89,14 @@ class random { for (let i in obj) { list.push(i) } - return this.item(list) + return random.item(list) } /** * Return a random Boolean value. */ static bool () { - return this.item([true, false]) + return random.item([true, false]) } static pick (obj) { @@ -95,7 +104,7 @@ class random { return obj() } if (Array.isArray(obj)) { - return this.pick(this.item(obj)) + return random.pick(random.item(obj)) } return obj } @@ -108,7 +117,7 @@ class random { logger.traceback() throw new TypeError(`random.chance() received non-number type: (${limit})`) } - return this.number(limit) === 1 + return random.number(limit) === 1 } static choose (list, flat) { @@ -120,13 +129,13 @@ class random { for (let i = 0; i < list.length; i++) { total += list[i][0] } - let n = this.number(total) + let n = random.number(total) for (let i = 0; i < list.length; i++) { if (n < list[i][0]) { if (flat === true) { return list[i][1] } else { - return this.pick([list[i][1]]) + return random.pick([list[i][1]]) } } n = n - list[i][0] @@ -134,7 +143,7 @@ class random { if (flat === true) { return list[0][1] } - return this.pick([list[0][1]]) + return random.pick([list[0][1]]) } /** @@ -152,13 +161,13 @@ class random { } static use (obj) { - return this.bool() ? obj : '' + return random.bool() ? obj : '' } static shuffle (arr) { let i = arr.length while (i--) { - let p = this.number(i + 1) + let p = random.number(i + 1) let t = arr[i] arr[i] = arr[p] arr[p] = t @@ -167,7 +176,7 @@ class random { static shuffled (arr) { let newArray = arr.slice() - this.shuffle(newArray) + random.shuffle(newArray) return newArray } @@ -177,11 +186,11 @@ class random { throw new TypeError(`random.subset() received non-array type: (${list})`) } if (typeof limit !== 'number') { - limit = this.number(list.length + 1) + limit = random.number(list.length + 1) } let result = [] for (let i = 0; i < limit; i++) { - result.push(this.pick(list)) + result.push(random.pick(list)) } return result } @@ -193,7 +202,7 @@ class random { static pop (arr) { let i, obj - i = this.number(arr.length) + i = random.number(arr.length) obj = arr[i] arr.splice(i, 1) @@ -201,7 +210,7 @@ class random { } static hex (len) { - return this.number(Math.pow(2, len * 4)).toString(16) + return random.number(Math.pow(2, len * 4)).toString(16) } } From b80448b2b2ec643ace543293a4684a25ce8630a9 Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Sat, 7 Apr 2018 02:11:14 +0200 Subject: [PATCH 28/68] Fix crypto module using this --- lib/make/crypto.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/make/crypto.js b/lib/make/crypto.js index 4e0ab5b..3696afe 100644 --- a/lib/make/crypto.js +++ b/lib/make/crypto.js @@ -16,7 +16,7 @@ class crypto extends make { ] } static randomKeyFormat () { - return random.item(this.keyFormats) + return random.item(crypto.keyFormats) } static get keyTypes () { @@ -27,7 +27,7 @@ class crypto extends make { ] } static randomKeyType () { - return random.item(this.keyTypes) + return random.item(crypto.keyTypes) } static get keyUsages () { @@ -44,7 +44,7 @@ class crypto extends make { } static randomKeyUsage () { - return random.subset(this.keyUsages) + return random.subset(crypto.keyUsages) } static get curves () { @@ -56,7 +56,7 @@ class crypto extends make { } static randomCurve () { - return random.item(this.curves) + return random.item(crypto.curves) } static get jwkUsages () { @@ -67,7 +67,7 @@ class crypto extends make { } static randomJwkUsage () { - return random.subset(this.keyUsages) + return random.subset(crypto.keyUsages) } static get jwkKeyTypes () { @@ -79,7 +79,7 @@ class crypto extends make { } static randomJwkKeyType () { - return random.subset(this.jwkKeyTypes) + return random.subset(crypto.jwkKeyTypes) } static get algorithmNames () { @@ -181,11 +181,11 @@ class crypto extends make { } static randomAlgorithmName (method) { - return random.item(this.algorithmNames[method]) + return random.item(crypto.algorithmNames[method]) } static randomDigestName () { - return random.item(this.algorithmNames.digest) + return random.item(crypto.algorithmNames.digest) } static get algorithms () { From 49915cb7a2ad9b0a59cd60626219802a1aab28e8 Mon Sep 17 00:00:00 2001 From: pyoor Date: Sat, 7 Apr 2018 11:14:40 -0400 Subject: [PATCH 29/68] Only wrap strings in quotes --- lib/utils/common.js | 6 +++++- package.json | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/utils/common.js b/lib/utils/common.js index cfcaea6..5df4992 100644 --- a/lib/utils/common.js +++ b/lib/utils/common.js @@ -31,7 +31,11 @@ class common extends utils { } static quote (s) { - return `'${jsesc(s)}'` + if (typeof s === 'string') { + return `'${jsesc(s)}'` + } else { + return jsesc(s) + } } static b64encode (str) { diff --git a/package.json b/package.json index ccf9b1b..00efd83 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mozillasecurity/octo", - "version": "1.0.13", + "version": "1.0.14", "description": "", "keywords": [ "fuzzing", From a53231e5edf5740a1472eeb23270ca962d09bb42 Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Mon, 9 Apr 2018 19:38:54 +0200 Subject: [PATCH 30/68] Fix make.command.value --- lib/make/command.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/make/command.js b/lib/make/command.js index d6827be..0009e5a 100644 --- a/lib/make/command.js +++ b/lib/make/command.js @@ -61,7 +61,7 @@ class command extends make { return random.item(Object.keys(command.data())) } - static value (value) { + static value (name) { return random.pick(command.data()[name]) } } From e11c0eca0a70083339cdfaf630bdb2fc7fd2e02c Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Wed, 25 Apr 2018 13:48:31 -0700 Subject: [PATCH 31/68] Add WebGL extensions names --- lib/make/webgl.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib/make/webgl.js b/lib/make/webgl.js index bab4599..c1a557d 100644 --- a/lib/make/webgl.js +++ b/lib/make/webgl.js @@ -785,6 +785,36 @@ class webgl extends make { ] return random.item(pname) } + + static randomExtension () { + let extension = [ + 'ANGLE_instanced_arrays', + 'EXT_blend_minmax', + 'EXT_color_buffer_half_float', + 'EXT_frag_depth', + 'EXT_sRGB', + 'EXT_shader_texture_lod', + 'EXT_texture_filter_anisotropic', + 'EXT_disjoint_timer_query', + 'OES_element_index_uint', + 'OES_standard_derivatives', + 'OES_texture_float', + 'OES_texture_float_linear', + 'OES_texture_half_float', + 'OES_texture_half_float_linear', + 'OES_vertex_array_object', + 'WEBGL_color_buffer_float', + 'WEBGL_compressed_texture_s3tc', + 'WEBGL_compressed_texture_s3tc_srgb', + 'WEBGL_debug_renderer_info', + 'WEBGL_debug_shaders', + 'WEBGL_depth_texture', + 'WEBGL_draw_buffers', + 'WEBGL_lose_context' + ] + + return random.item(extension) + } } module.exports = webgl From e245d40e384f929e4c6d5f0145fecbdebaab5dc5 Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Wed, 25 Apr 2018 14:19:03 -0700 Subject: [PATCH 32/68] Add WebGL extensions names --- lib/make/webgl.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/make/webgl.js b/lib/make/webgl.js index c1a557d..b3dc18f 100644 --- a/lib/make/webgl.js +++ b/lib/make/webgl.js @@ -786,8 +786,8 @@ class webgl extends make { return random.item(pname) } - static randomExtension () { - let extension = [ + static randomExtension (pattern) { + let extensions = [ 'ANGLE_instanced_arrays', 'EXT_blend_minmax', 'EXT_color_buffer_half_float', @@ -813,7 +813,13 @@ class webgl extends make { 'WEBGL_lose_context' ] - return random.item(extension) + if (pattern) { + let candidates = [] + extensions.forEach((ext) => ext.includes(pattern) ? candidates.push(ext) : '') + return random.item(candidates) + } + + return random.item(extensions) } } From 15579c705c5a7c04749d01c27c6921fdad82e9f2 Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Wed, 25 Apr 2018 14:22:20 -0700 Subject: [PATCH 33/68] Add WebGL extensions names --- lib/make/webgl.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/make/webgl.js b/lib/make/webgl.js index b3dc18f..c84f6ef 100644 --- a/lib/make/webgl.js +++ b/lib/make/webgl.js @@ -816,7 +816,9 @@ class webgl extends make { if (pattern) { let candidates = [] extensions.forEach((ext) => ext.includes(pattern) ? candidates.push(ext) : '') - return random.item(candidates) + if (candidates.length >= 0) { + return random.item(candidates) + } } return random.item(extensions) From 2c5fd23f493b9aba02d32c08bcea5754a5e45e65 Mon Sep 17 00:00:00 2001 From: pyoor Date: Thu, 26 Apr 2018 13:04:04 -0400 Subject: [PATCH 34/68] Fix bad reference in make.time.epoch --- lib/make/time.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/make/time.js b/lib/make/time.js index 4105dd6..bb85cbb 100644 --- a/lib/make/time.js +++ b/lib/make/time.js @@ -34,7 +34,7 @@ class time extends make { } static epoch () { - return Math.floor(time.object() / 1000) + return Math.floor(time.datetime() / 1000) } static any () { From 6059659c05d79d1403d6297f6d4c0fab185ff61f Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Fri, 27 Apr 2018 15:50:51 -0700 Subject: [PATCH 35/68] [WebGL] Fix .extend --- lib/make/webgl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/make/webgl.js b/lib/make/webgl.js index c84f6ef..3de3c61 100644 --- a/lib/make/webgl.js +++ b/lib/make/webgl.js @@ -694,7 +694,7 @@ class webgl extends make { ] if (isWebGL2) { - pname.extends([ + pname.extend([ 'COPY_READ_BUFFER_BINDING', 'COPY_WRITE_BUFFER_BINDING', 'DRAW_BUFFERi', From a7ac3bc258c196a6b6be768fcb56d10795becd2b Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Wed, 9 May 2018 17:46:20 +0200 Subject: [PATCH 36/68] Evenly distribute make.numbers.any() --- lib/make/numbers.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/make/numbers.js b/lib/make/numbers.js index 52b4f69..d96b7f2 100644 --- a/lib/make/numbers.js +++ b/lib/make/numbers.js @@ -74,9 +74,9 @@ class number extends make { static any () { let value = random.choose([ - [10, number.float], - [10, [number.range, number.tiny]], - [1, number.unsigned] + [1, number.float], + [1, number.unsigned], + [1, [number.range, number.tiny]] ]) return random.chance(10) ? -value : value } From 6079e9b428a4e47fd58831b9d946e6c2cf2fefbc Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Wed, 9 May 2018 17:48:44 +0200 Subject: [PATCH 37/68] Fix regex for parsing uniforms and attributes --- lib/make/webgl.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/make/webgl.js b/lib/make/webgl.js index 3de3c61..9154731 100644 --- a/lib/make/webgl.js +++ b/lib/make/webgl.js @@ -59,7 +59,7 @@ class webgl extends make { static parseUniforms (shader) { let names = [] - let result = shader.match(/uniform .* (\w+)(?=;)/gm) + let result = shader.match(/uniform \w+ \w+(?=;)/gm) if (result) { result.forEach((v) => names.push(v.split(' ').pop())) } @@ -68,7 +68,7 @@ class webgl extends make { static parseAttributes (shader) { let names = [] - let result = shader.match(/attribute .* (\w+)(?=;)/gm) + let result = shader.match(/attribute \w+ \w+(?=;)/gm) if (result) { result.forEach((v) => names.push(v.split(' ').pop())) } From 60a7b65cdf8fd9824d99ec78cbdfbcf603f5deff Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Thu, 10 May 2018 08:56:29 +0200 Subject: [PATCH 38/68] Fix regex for parsing uniforms, attributes, varyings --- lib/make/webgl.js | 48 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/lib/make/webgl.js b/lib/make/webgl.js index 9154731..5941cb9 100644 --- a/lib/make/webgl.js +++ b/lib/make/webgl.js @@ -57,26 +57,44 @@ class webgl extends make { return random.item(sources) } - static parseUniforms (shader) { - let names = [] - let result = shader.match(/uniform \w+ \w+(?=;)/gm) - if (result) { - result.forEach((v) => names.push(v.split(' ').pop())) + match (shader, regex, group = 1) { + let matches = [] + let match + while (match = regex.exec(shader)) { + matches.push(match[group]) } - return names + return matches } - static parseAttributes (shader) { - let names = [] - let result = shader.match(/attribute \w+ \w+(?=;)/gm) - if (result) { - result.forEach((v) => names.push(v.split(' ').pop())) - } - return names + static parseUniforms (shader, group = 1) { + /* Todo: Parse their individual data types into categories. */ + return match(shader, /uniform .+? (\w+)(?=[\[;])/gm, group) } - static parseFrag (shader) { - return shader.match(/(gl_Frag[^[ =]+)/gm) + static parseAttributes (shader, group = 1) { + return match(shader, /attribute .+? (\w+)(?=;)/gm, group) + } + + static parseVaryings (shader, group = 1) { + return match(shader, /varying .+? (\w+)(?=;)/gm, group) + } + + static parseFragDatav2 (shader, group = 1) { + // #version 200 + return match(shader, /(gl_Frag[^[ =]+)/gm, group) + } + + static parseFragDatav3 (shader, group = 1) { + // #version 300 + return match(shader, /out .+? (\w+)(?=[\[;])/gm, group) + } + + static parseFrag (shader, group = 1) { + let matches = parseFragDatav2(shader) + if (matches.length) { + return matches + } + return parseFragDatav3(shader) } static randomBitmask () { From 3c7d14349a8862b13387c88fa7e0d3e3589d0bab Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Thu, 10 May 2018 09:16:18 +0200 Subject: [PATCH 39/68] Let webgl.match() be accessible --- lib/make/webgl.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/make/webgl.js b/lib/make/webgl.js index 5941cb9..3a54814 100644 --- a/lib/make/webgl.js +++ b/lib/make/webgl.js @@ -57,7 +57,7 @@ class webgl extends make { return random.item(sources) } - match (shader, regex, group = 1) { + static match (shader, regex, group = 1) { let matches = [] let match while (match = regex.exec(shader)) { @@ -68,33 +68,33 @@ class webgl extends make { static parseUniforms (shader, group = 1) { /* Todo: Parse their individual data types into categories. */ - return match(shader, /uniform .+? (\w+)(?=[\[;])/gm, group) + return webgl.match(shader, /uniform .+? (\w+)(?=[\[;])/gm, group) } static parseAttributes (shader, group = 1) { - return match(shader, /attribute .+? (\w+)(?=;)/gm, group) + return webgl.match(shader, /attribute .+? (\w+)(?=;)/gm, group) } static parseVaryings (shader, group = 1) { - return match(shader, /varying .+? (\w+)(?=;)/gm, group) + return webgl.match(shader, /varying .+? (\w+)(?=;)/gm, group) } static parseFragDatav2 (shader, group = 1) { // #version 200 - return match(shader, /(gl_Frag[^[ =]+)/gm, group) + return webgl.match(shader, /(gl_Frag[^[ =]+)/gm, group) } static parseFragDatav3 (shader, group = 1) { // #version 300 - return match(shader, /out .+? (\w+)(?=[\[;])/gm, group) + return webgl.match(shader, /out .+? (\w+)(?=[\[;])/gm, group) } static parseFrag (shader, group = 1) { - let matches = parseFragDatav2(shader) + let matches = webgl.parseFragDatav2(shader) if (matches.length) { return matches } - return parseFragDatav3(shader) + return webgl.parseFragDatav3(shader) } static randomBitmask () { From b1908915d53eaabf47c5837b68dce863d150c7f8 Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Mon, 14 May 2018 19:25:38 +0200 Subject: [PATCH 40/68] [crypto.js] Add missing return statement --- lib/make/crypto.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/make/crypto.js b/lib/make/crypto.js index 3696afe..fe59a57 100644 --- a/lib/make/crypto.js +++ b/lib/make/crypto.js @@ -354,7 +354,7 @@ class crypto extends make { return this.alg() }, encrypt: function () { - utils.common.mockup(`{ + return utils.common.mockup(`{ name: 'RSA-OAEP', hash: { name: 'SHA-${this.length()}' From 090daa68b52a19e1a64212918f274b67875bebc8 Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Mon, 14 May 2018 19:49:08 +0200 Subject: [PATCH 41/68] Add support for Base64 in NodeJS --- lib/utils/common.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/utils/common.js b/lib/utils/common.js index 5df4992..3877221 100644 --- a/lib/utils/common.js +++ b/lib/utils/common.js @@ -41,19 +41,28 @@ class common extends utils { static b64encode (str) { // Unicode safe b64 encoding // https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#The_Unicode_Problem - return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, - function toSolidBytes (match, p1) { - // noinspection JSCheckFunctionSignatures - return String.fromCharCode('0x' + p1) - })) + if (process.browser) { + return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, + function toSolidBytes (match, p1) { + // noinspection JSCheckFunctionSignatures + return String.fromCharCode('0x' + p1) + }) + ) + } else { + return Buffer.from(str).toString('base64') + } } static b64decode (str) { // Unicode safe b64 decoding // https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#The_Unicode_Problem - return decodeURIComponent(atob(str).split('').map(function (c) { - return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2) - }).join('')) + if (process.browser) { + return decodeURIComponent(atob(str).split('').map(function (c) { + return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2) + }).join('')) + } else { + return Buffer.from(str, 'base64').toString('ascii') + } } static uniqueList (list) { From 0e292b817c8ff846b539e7c1b3cc4241a8ba2bed Mon Sep 17 00:00:00 2001 From: pyoor Date: Mon, 21 May 2018 11:03:38 -0400 Subject: [PATCH 42/68] Remove JSHint in favor of standard --- .jshintrc | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 .jshintrc diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 6eba332..0000000 --- a/.jshintrc +++ /dev/null @@ -1,22 +0,0 @@ -{ - "curly": true, - "eqeqeq": true, - "immed": true, - "latedef": "nofunc", - "newcap": true, - "noarg": true, - "sub": true, - "undef": true, - "unused": true, - "boss": true, - "eqnull": true, - "node": true, - "maxerr": 2000, - "esversion": 6, - "undef": true, - "unused": true, - "globals": { - "random": true, - "make": true - } -} \ No newline at end of file From cf910de0f665e2c3454426c678e92e607115e409 Mon Sep 17 00:00:00 2001 From: pyoor Date: Mon, 21 May 2018 11:34:53 -0400 Subject: [PATCH 43/68] Minor linter fixes --- lib/logging/index.js | 2 +- lib/make/text.js | 6 +++--- lib/make/webgl.js | 14 +++++++++----- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/logging/index.js b/lib/logging/index.js index cda8e0e..41a6897 100644 --- a/lib/logging/index.js +++ b/lib/logging/index.js @@ -25,7 +25,7 @@ class logger { } if (typeof window === 'undefined') { try { - print(msg) // eslint-disable-line no-undef + print(msg) // eslint-disable-line no-undef } catch (e) { console.log(msg) } diff --git a/lib/make/text.js b/lib/make/text.js index e1ee21b..2d4bbcc 100644 --- a/lib/make/text.js +++ b/lib/make/text.js @@ -51,8 +51,8 @@ class text extends make { static layoutCharCodes () { return random.pick([ - 0, // null - 160, // non-breaking space + 0, // null + 160, // non-breaking space 0x005C, // backslash, but in some countries, represents local currency symbol (e.g. yen) 0x00AD, // soft hyphen 0x0BCC, // a Tamil character that is displayed as three glyphs @@ -114,7 +114,7 @@ class text extends make { 0x205F, // mathematical space 0x2061, // mathematical function application 0x2064, // mathematical invisible separator - 0x2044 // fraction slash character + 0x2044 // fraction slash character ]) } diff --git a/lib/make/webgl.js b/lib/make/webgl.js index 3a54814..79b11ea 100644 --- a/lib/make/webgl.js +++ b/lib/make/webgl.js @@ -59,16 +59,20 @@ class webgl extends make { static match (shader, regex, group = 1) { let matches = [] - let match - while (match = regex.exec(shader)) { + while (true) { + let match = regex.exec(shader) + if (match) { matches.push(match[group]) + } else { + break + } } return matches } static parseUniforms (shader, group = 1) { /* Todo: Parse their individual data types into categories. */ - return webgl.match(shader, /uniform .+? (\w+)(?=[\[;])/gm, group) + return webgl.match(shader, /uniform .+? (\w+)(?=[\[;])/gm, group) /* eslint-disable-line no-useless-escape */ } static parseAttributes (shader, group = 1) { @@ -86,13 +90,13 @@ class webgl extends make { static parseFragDatav3 (shader, group = 1) { // #version 300 - return webgl.match(shader, /out .+? (\w+)(?=[\[;])/gm, group) + return webgl.match(shader, /out .+? (\w+)(?=[\[;])/gm, group) /* eslint-disable-line no-useless-escape */ } static parseFrag (shader, group = 1) { let matches = webgl.parseFragDatav2(shader) if (matches.length) { - return matches + return matches } return webgl.parseFragDatav3(shader) } From 600bb045be6e9bdc041e8a7fefd764cfbcfce701 Mon Sep 17 00:00:00 2001 From: pyoor Date: Mon, 21 May 2018 11:50:44 -0400 Subject: [PATCH 44/68] Use template literals throughout --- lib/make/colors.js | 26 +++++++++++++------------- lib/make/fonts.js | 10 +++++----- lib/make/network.js | 23 ++++++++++++----------- lib/make/typed.js | 32 ++++++++++++++++---------------- lib/make/units.js | 2 +- lib/make/uri.js | 2 +- lib/make/webgl.js | 2 +- lib/utils/common.js | 6 +++--- lib/utils/objects.js | 4 ++-- lib/utils/platform.js | 4 ++-- lib/utils/script.js | 12 ++++++------ 11 files changed, 62 insertions(+), 61 deletions(-) diff --git a/lib/make/colors.js b/lib/make/colors.js index 929a992..52d8e22 100644 --- a/lib/make/colors.js +++ b/lib/make/colors.js @@ -25,19 +25,19 @@ class colors extends make { values = [random.number(255), random.number(255), random.number(255)] } else { // Percents - values = ['%' + random.number(255), '%' + random.number(255), '%' + random.number(255)] + values = [`%${random.number(255)}`, `%${random.number(255)}`, `%${random.number(255)}`] } - return 'rgba(' + values.join(',') + ')' + return `rgba(${values.join(',')})` case 1: // Rgba functional notation values = [random.number(255), random.number(255), random.number(255), random.float()] - return 'rgba(' + values.join(',') + ')' + return `rgba(${values.join(',')})` case 2: // 4 char hex - return '#' + random.hex(4) + return `#${random.hex(4)}` default: // 8 char hex - return '#' + random.hex(8) + return `#${random.hex(8)}` } } @@ -46,18 +46,18 @@ class colors extends make { switch (random.number(4)) { case 0: - values = [random.number(255), '%' + random.number(255), '%' + random.number(255)] - return 'hsl(' + values.join(',') + ')' + values = [random.number(255), `%${random.number(255)}`, `%${random.number(255)}`] + return `hsl(${values.join(',')})` case 1: - values = [random.number(255), '%' + random.number(255), '%' + random.number(255), '%' + random.number(255)] - return 'hsl(' + values.join(',') + ')' + values = [random.number(255), `%${random.number(255)}`, `%${random.number(255)}`, `%${random.number(255)}`] + return `hsl(${values.join(',')})` case 2: opt = random.pick(['deg', 'rad', 'grad', 'turn']) - values = [random.number(255) + opt, '%' + random.number(255), '%' + random.number(255), '%' + random.number(255)] - return 'hsl(' + values.join(',') + ')' + values = [random.number(255) + opt, `%${random.number(255)}`, `%${random.number(255)}`, `%${random.number(255)}`] + return `hsl(${values.join(',')})` default: - values = [random.number(255), '%' + random.number(255), '%' + random.number(255), random.float()] - return 'hsl(' + values.join(',') + ')' + values = [random.number(255), `%${random.number(255)}`, `%${random.number(255)}`, random.float()] + return `hsl(${values.join(',')})` } } diff --git a/lib/make/fonts.js b/lib/make/fonts.js index 16ec092..84f8570 100644 --- a/lib/make/fonts.js +++ b/lib/make/fonts.js @@ -58,7 +58,7 @@ class font extends make { static family () { let s = random.pick(font.familyName) if (random.chance(8)) { - s += ', ' + random.pick(font.genericFamily) + s += `, ${random.pick(font.genericFamily)}` } return s } @@ -86,16 +86,16 @@ class font extends make { static font () { let s = '' if (random.chance(4)) { - s += random.pick(font.style) + ' ' + s += `${random.pick(font.style)} ` } if (random.chance(4)) { - s += random.pick(font.variant) + ' ' + s += `${random.pick(font.variant)} ` } if (random.chance(4)) { - s += random.pick(font.weight) + ' ' + s += `${random.pick(font.weight)} ` } if (random.chance(4)) { - s += make.number.any() + '/' + s += `${make.number.any()}/` } s += font.size() s += ' ' diff --git a/lib/make/network.js b/lib/make/network.js index a1a16aa..505d6c8 100644 --- a/lib/make/network.js +++ b/lib/make/network.js @@ -52,7 +52,7 @@ class network extends make { random.pick([0, 1, make.number.any]), ' ', random.pick(['UDP', 'TCP', 'SCTP']), - random.pick(['', '/' + random.pick(['DTLS', 'DTLS-SRTP'])]), + random.pick(['', `/${random.pick(['DTLS', 'DTLS-SRTP'])}`]), ' ', random.pick([make.number.any]), ' ', @@ -117,10 +117,11 @@ class network extends make { } static randomIPv4 () { - return random.pick([random.number(255), make.number.any]) + '.' + - random.pick([random.number(255), make.number.any]) + '.' + - random.pick([random.number(255), make.number.any]) + '.' + - random.pick([random.number(255), make.number.any]) + function octet () { + return random.pick([random.number(255), make.number.any]) + } + + return `${octet()}.${octet()}.${octet()}.${octet()}.` } static randomIPv6 () { @@ -188,7 +189,7 @@ class network extends make { '', '#', '#main-content', - () => '#' + make.text.any() + () => `#${make.text.any()}` ]) } @@ -197,19 +198,19 @@ class network extends make { '', '/', '/index.html', - () => '/' + make.text.any() + () => `/${make.text.any()}` ]) } static protocol () { - return random.pick([ + return `${random.pick([ 'http', 'https', 'ftp', 'telnet', 'chrome', 'resource' - ]) + ':' + ])}:` } static search () { @@ -217,7 +218,7 @@ class network extends make { '', '?', '?foo=bar', - () => '?' + make.text.any() + () => `?${make.text.any()}` ]) } @@ -228,7 +229,7 @@ class network extends make { let max = random.range(2, list.length) let mask = random.pick(list) for (let i = 1; i < max; i++) { - mask += '|' + random.pick(list) + mask += `|${random.pick(list)}` } return mask } diff --git a/lib/make/typed.js b/lib/make/typed.js index 5f957a6..53bc4e1 100644 --- a/lib/make/typed.js +++ b/lib/make/typed.js @@ -10,45 +10,45 @@ class typed extends make { // [-128, 127] let value = (limit !== null) ? random.number(limit) : random.number(129) value = random.chance(10) ? -value : value - return 'new Uint8Array([' + value + '])[0]' + return `new Uint8Array([${value}])[0]` } static octet (limit = null) { // [0, 255] let value = (limit !== null) ? random.number(limit) : random.number(256) - return 'new Int8Array([' + value + '])[0]' + return `new Int8Array([${value}])[0]` } static short (limit = null) { // [-32768, 32767] let value = (limit !== null) ? random.number(limit) : random.number(32769) value = random.chance(10) ? -value : value - return 'new Int16Array([' + value + '])[0]' + return `new Int16Array([${value}])[0]` } static unsignedShort (limit = null) { // [0, 65535] let value = (limit !== null) ? random.number(limit) : random.number(65535) - return 'new Uint16Array([' + value + '])[0]' + return `new Uint16Array([${value}])[0]` } static long (limit = null) { // [-2147483648, 2147483647] let value = (limit !== null) ? random.number(limit) : random.number(2147483649) value = random.chance(10) ? -value : value - return 'new Int32Array([' + value + '])[0]' + return `new Int32Array([${value}])[0]` } static unsignedLong (limit = null) { // [0, 4294967295] let value = (limit !== null) ? random.number(limit) : random.number(4294967296) - return 'new Uint32Array([' + value + '])[0]' + return `new Uint32Array([${value}])[0]` } static float (limit = null) { let base = (limit !== null) ? random.number(limit) : random.number() let value = random.chance(10) ? -(base + random.float()) : (base + random.float()) - return 'new Float32Array([' + value + '])[0]' + return `new Float32Array([${value}])[0]` } static unrestrictedFloat (limit = null) { @@ -56,14 +56,14 @@ class typed extends make { return random.pick([NaN, +Infinity, -Infinity]) } else { let base = (limit !== null) ? random.number(limit) : random.number() - return 'new Float32Array([' + (base + random.float()) + '])[0]' + return `new Float32Array([${base + random.float()}])[0]` } } static double (limit = null) { let base = (limit !== null) ? random.number(limit) : random.number() let value = random.chance(10) ? -(base + random.float()) : (base + random.float()) - return 'new Float64Array([' + value + '])[0]' + return `new Float64Array([${value}])[0]` } static unrestrictedDouble (limit = null) { @@ -72,7 +72,7 @@ class typed extends make { } else { let base = (limit !== null) ? random.number(limit) : random.number() let value = random.chance(10) ? -(base + random.float()) : (base + random.float()) - return 'new Float64Array([' + value + '])[0]' + return `new Float64Array([${value}])[0]` } } @@ -89,12 +89,12 @@ class typed extends make { static arrayBuffer (byteLength = null) { let length = (byteLength !== null) ? byteLength : typed.unsignedShort() - return 'new ArrayBuffer(' + length + ')' + return `new ArrayBuffer(${length})` } static dataView (byteLength = null) { let length = (byteLength !== null) ? byteLength : typed.unsignedShort() - return 'new DataView(' + typed.arrayBuffer(length) + ')' + return `new DataView(${typed.arrayBuffer(length)})` } static typedArray (byteLength = null) { @@ -105,14 +105,14 @@ class typed extends make { 'Int32', 'Uint32', 'Float32', 'Float64' ]) - let method = 'new ' + arrType + 'Array' + let method = `new ${arrType}Array` switch (random.number(16)) { case 0: - return method + '()' + return `${method}()` case 1: - return method + '(' + this.typedArray() + ')' + return `${method}(${this.typedArray()})` default: - return method + '(' + length + ')' + return `${method}(${length})` } } diff --git a/lib/make/units.js b/lib/make/units.js index c27151a..f9f8c3b 100644 --- a/lib/make/units.js +++ b/lib/make/units.js @@ -17,7 +17,7 @@ class unit extends make { } static percent () { - return make.number.any() + '%' + return `${make.number.any()}%` } } diff --git a/lib/make/uri.js b/lib/make/uri.js index cfa9fa3..67a1fc5 100644 --- a/lib/make/uri.js +++ b/lib/make/uri.js @@ -25,7 +25,7 @@ class uri extends make { 'data:image/png,', 'data:', 'javascript:5555', - 'javascript:"QQQQ' + String.fromCharCode(0) + 'UUUU"', + `javascript:"QQQQ${String.fromCharCode(0)}UUUU"`, 'http://a.invalid/', 'http://localhost:6/', 'https://localhost:6/', diff --git a/lib/make/webgl.js b/lib/make/webgl.js index 79b11ea..14e2400 100644 --- a/lib/make/webgl.js +++ b/lib/make/webgl.js @@ -340,7 +340,7 @@ class webgl extends make { ] if (isWebGL2) { attachment.extend([ - 'COLOR_ATTACHMENT' + random.range(0, 15) + `COLOR_ATTACHMENT${random.range(0, 15)}` ]) } return random.item(attachment) diff --git a/lib/utils/common.js b/lib/utils/common.js index 3877221..f9b3101 100644 --- a/lib/utils/common.js +++ b/lib/utils/common.js @@ -7,9 +7,9 @@ const utils = require('../utils') class common extends utils { static objToString (obj) { try { - return '' + obj + return `${obj}` } catch (e) { - return '[' + e + ']' + return `[${e}]` } } @@ -58,7 +58,7 @@ class common extends utils { // https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#The_Unicode_Problem if (process.browser) { return decodeURIComponent(atob(str).split('').map(function (c) { - return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2) + return `%${('00' + c.charCodeAt(0).toString(16)).slice(-2)}` }).join('')) } else { return Buffer.from(str, 'base64').toString('ascii') diff --git a/lib/utils/objects.js b/lib/utils/objects.js index 5460110..ee7ef0e 100644 --- a/lib/utils/objects.js +++ b/lib/utils/objects.js @@ -30,7 +30,7 @@ class Objects { if (!(category in this.container)) { // return {type:null, name:null}; logger.traceback() - throw new Error(category + ' is not available.') + throw new Error(`${category} is not available.`) } if (last) { return this.container[category].slice(-1)[0] @@ -43,7 +43,7 @@ class Objects { return this.get(category, last).name } catch (e) { logger.traceback() - throw logger.JSError('Error: pick(\'' + category + '\') is undefined.') + throw logger.JSError(`Error: pick('${category}') is undefined.`) } } diff --git a/lib/utils/platform.js b/lib/utils/platform.js index 2905ff4..6dbca47 100644 --- a/lib/utils/platform.js +++ b/lib/utils/platform.js @@ -56,10 +56,10 @@ class platform extends utils { function platformName (candidates) { for (let i = 0; i < candidates.length; i++) { if (candidates[i] in window) { - return 'window.' + candidates[i] + return `window.${candidates[i]}` } if (candidates[i] in navigator) { - return 'navigator.' + candidates[i] + return `navigator.${candidates[i]}` } } return undefined diff --git a/lib/utils/script.js b/lib/utils/script.js index bf09ca0..6c730a1 100644 --- a/lib/utils/script.js +++ b/lib/utils/script.js @@ -29,7 +29,7 @@ class script extends utils { if (typeof (methodArgs) === 'function') { // Todo: Hmmmm.. return methodArgs() } - return objectName + '.' + methodName + script.methodHead(methodArgs) + return `${objectName}.${methodName}${script.methodHead(methodArgs)}` } static setAttribute (objectName, attributeHash) { @@ -47,7 +47,7 @@ class script extends utils { attributeValue = "'" + attributeValue + "'"; } */ - return objectName + '.' + attributeName + operator + attributeValue + ';' + return `${objectName}.${attributeName}${operator}${attributeValue};` } static makeConstraint (keys, values) { @@ -77,7 +77,7 @@ class script extends utils { } static makeLoop (s, max) { - return 'for (let i = 0; i < ' + (max || make.number.range()) + '; i++) {' + s + '}' + return `for (let i = 0; i < ${max || make.number.range()}; i++) {${s}}` } static makeArray (type, arrayLength, cb) { @@ -86,8 +86,8 @@ class script extends utils { } switch (random.number(8)) { case 0: - let src = 'function() { let buffer = new ' + type + 'Array(' + arrayLength + ');' - src += script.makeLoop('buffer[i] = ' + cb() + ';', arrayLength) + let src = `function() { let buffer = new ${type}Array(${arrayLength});` + src += script.makeLoop(`buffer[i] = ${cb()};`, arrayLength) src += 'return buffer;}()' return src case 1: @@ -98,7 +98,7 @@ class script extends utils { } static randListIndex (objName) { - return random.number() + ' % ' + o.pick(objName) + '.length' + return `${random.number()} % ${o.pick(objName)}.length` } static addElementToBody (name) { From 3f23299430b07e955255d2aeb505c0a6dfb7859b Mon Sep 17 00:00:00 2001 From: pyoor Date: Mon, 21 May 2018 12:04:34 -0400 Subject: [PATCH 45/68] Sort functions alphabetically --- lib/utils/script.js | 144 ++++++++++++++++++++++---------------------- 1 file changed, 72 insertions(+), 72 deletions(-) diff --git a/lib/utils/script.js b/lib/utils/script.js index 6c730a1..fa988f6 100644 --- a/lib/utils/script.js +++ b/lib/utils/script.js @@ -8,76 +8,12 @@ const utils = require('../utils') const {o} = require('./objects') class script extends utils { - static methodHead (list, numOptional) { - if (isNaN(numOptional)) { - numOptional = 0 - } - let arity = list.length - random.number(numOptional) - let params = [] - for (let i = 0; i < arity; i++) { - params.push(random.pick([list[i]])) - } - return `(${params.join(', ')})` + static addElementToBody (name) { + return `(document.body || document.documentElement).appendChild${script.methodHead([name])}` } - static methodCall (objectName, methodHash) { - if (!utils.common.getKeysFromHash(methodHash).length || !objectName) { - return '' - } - let methodName = random.key(methodHash) - let methodArgs = methodHash[methodName] - if (typeof (methodArgs) === 'function') { // Todo: Hmmmm.. - return methodArgs() - } - return `${objectName}.${methodName}${script.methodHead(methodArgs)}` - } - - static setAttribute (objectName, attributeHash) { - if (!utils.common.getKeysFromHash(attributeHash).length || !objectName) { - return '' - } - let attributeName = random.key(attributeHash) - let attributeValue = random.pick(attributeHash[attributeName]) - let operator = ' = ' - /* - if (typeof(attributeValue) == "number" && Random.chance(8)) { - operator = " " + Make.randomAssignmentOperator() + " "; - } - if (typeof(attributeValue) == "string") { - attributeValue = "'" + attributeValue + "'"; - } - */ - return `${objectName}.${attributeName}${operator}${attributeValue};` - } - - static makeConstraint (keys, values) { - let o = {} - let n = random.range(0, keys.length) - while (n--) { - o[random.pick(keys)] = random.pick(values) - } - return o - } - - static makeRandomOptions (baseObject) { - let o = {} - let unique = random.subset(Object.keys(baseObject)) - for (let i = 0; i < unique.length; i++) { - o[unique[i]] = random.pick(baseObject[unique[i]]) - } - return JSON.stringify(o) - } - - static safely (obj) { - if (Array.isArray(obj)) { - return obj.map(s => utils.script.safely(s)).join(' ') - } else { - return `try { ${obj} } catch(e) { }` - } - } - - static makeLoop (s, max) { - return `for (let i = 0; i < ${max || make.number.range()}; i++) {${s}}` + static getRandomElement () { + return `document.getElementsByTagName('*')[${random.number(document.getElementsByTagName('*').length)}]` } static makeArray (type, arrayLength, cb) { @@ -97,16 +33,80 @@ class script extends utils { } } + static makeConstraint (keys, values) { + let o = {} + let n = random.range(0, keys.length) + while (n--) { + o[random.pick(keys)] = random.pick(values) + } + return o + } + + static makeLoop (s, max) { + return `for (let i = 0; i < ${max || make.number.range()}; i++) {${s}}` + } + + static makeRandomOptions (baseObject) { + let o = {} + let unique = random.subset(Object.keys(baseObject)) + for (let i = 0; i < unique.length; i++) { + o[unique[i]] = random.pick(baseObject[unique[i]]) + } + return JSON.stringify(o) + } + + static methodCall (objectName, methodHash) { + if (!utils.common.getKeysFromHash(methodHash).length || !objectName) { + return '' + } + let methodName = random.key(methodHash) + let methodArgs = methodHash[methodName] + if (typeof (methodArgs) === 'function') { // Todo: Hmmmm.. + return methodArgs() + } + return `${objectName}.${methodName}${script.methodHead(methodArgs)}` + } + + static methodHead (list, numOptional) { + if (isNaN(numOptional)) { + numOptional = 0 + } + let arity = list.length - random.number(numOptional) + let params = [] + for (let i = 0; i < arity; i++) { + params.push(random.pick([list[i]])) + } + return `(${params.join(', ')})` + } + static randListIndex (objName) { return `${random.number()} % ${o.pick(objName)}.length` } - static addElementToBody (name) { - return `(document.body || document.documentElement).appendChild${script.methodHead([name])}` + static safely (obj) { + if (Array.isArray(obj)) { + return obj.map(s => utils.script.safely(s)).join(' ') + } else { + return `try { ${obj} } catch(e) { }` + } } - static getRandomElement () { - return `document.getElementsByTagName('*')[${random.number(document.getElementsByTagName('*').length)}]` + static setAttribute (objectName, attributeHash) { + if (!utils.common.getKeysFromHash(attributeHash).length || !objectName) { + return '' + } + let attributeName = random.key(attributeHash) + let attributeValue = random.pick(attributeHash[attributeName]) + let operator = ' = ' + /* + if (typeof(attributeValue) == "number" && Random.chance(8)) { + operator = " " + Make.randomAssignmentOperator() + " "; + } + if (typeof(attributeValue) == "string") { + attributeValue = "'" + attributeValue + "'"; + } + */ + return `${objectName}.${attributeName}${operator}${attributeValue};` } } From 6455376a976b26d34c0583594d88dd0bcb7263ed Mon Sep 17 00:00:00 2001 From: pyoor Date: Mon, 21 May 2018 12:17:48 -0400 Subject: [PATCH 46/68] Add utils.script.offset --- lib/utils/script.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/utils/script.js b/lib/utils/script.js index fa988f6..af7f874 100644 --- a/lib/utils/script.js +++ b/lib/utils/script.js @@ -79,6 +79,10 @@ class script extends utils { return `(${params.join(', ')})` } + static offset (s) { + return `(${s} % ${random.range(1, 3)})` + } + static randListIndex (objName) { return `${random.number()} % ${o.pick(objName)}.length` } From 40eee0a442fd7a47c50a076c9783e504d20c0555 Mon Sep 17 00:00:00 2001 From: pyoor Date: Mon, 21 May 2018 12:18:09 -0400 Subject: [PATCH 47/68] Add utils.script.runner --- lib/utils/script.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/utils/script.js b/lib/utils/script.js index af7f874..81ef852 100644 --- a/lib/utils/script.js +++ b/lib/utils/script.js @@ -87,6 +87,31 @@ class script extends utils { return `${random.number()} % ${o.pick(objName)}.length` } + static runner (cmds) { + /** + * Wrap command(s) in setInterval, setTimeout, loop or run directly + * @param {Object|String} cmds - Command(s) to be executed + */ + cmds = (Array.isArray(cmds)) ? cmds : [cmds] + cmds = cmds.filter(function (i) { return i !== undefined }) + if (cmds.length) { + if (random.chance(50)) { + // Wrap each command in try/catch for use in setInterval, setTimeout, repeater + switch (random.number(3)) { + case 0: + return `setInterval(function () { ${utils.script.safely(cmds)} }, ${random.range(100, 400)} )` + case 1: + return `setTimeout(function () { ${utils.script.safely(cmds)} }, ${random.range(100, 400)} )` + case 2: + let n = random.number(random.number(30)) + return `for (let i = 0; i < ${n}; i++) { ${utils.script.safely(cmds)} }` + } + } else { + return cmds + } + } + } + static safely (obj) { if (Array.isArray(obj)) { return obj.map(s => utils.script.safely(s)).join(' ') From 075fe8930927b47ef0738be3327f86ac8d27205c Mon Sep 17 00:00:00 2001 From: pyoor Date: Thu, 26 Jul 2018 19:26:27 -0400 Subject: [PATCH 48/68] Refactor random.subset to pop items from cloned array --- lib/random/random.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/random/random.js b/lib/random/random.js index 63a1f61..eb4b901 100644 --- a/lib/random/random.js +++ b/lib/random/random.js @@ -180,18 +180,29 @@ class random { return newArray } + /** + * Select an array containing a subset of 'list' + * @param list + * @param limit + * @returns {Array} + */ static subset (list, limit) { if (!(Array.isArray(list))) { logger.traceback() throw new TypeError(`random.subset() received non-array type: (${list})`) } + if (typeof limit !== 'number') { limit = random.number(list.length + 1) } - let result = [] - for (let i = 0; i < limit; i++) { - result.push(random.pick(list)) + + // Deepclone list + const temp = JSON.parse(JSON.stringify(list)) + const result = [] + while (limit--) { + result.push(random.pop(temp)) } + return result } From 625adebc67d96ef9c07add00cd75dd09d8679b39 Mon Sep 17 00:00:00 2001 From: pyoor Date: Thu, 26 Jul 2018 19:26:57 -0400 Subject: [PATCH 49/68] Fix uses of random.subset --- lib/make/network.js | 12 +++++++----- lib/make/webgl.js | 11 ++++++++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/make/network.js b/lib/make/network.js index 505d6c8..ce4e233 100644 --- a/lib/make/network.js +++ b/lib/make/network.js @@ -141,11 +141,13 @@ class network extends make { } static dtmf () { - return random.subset([ - '*', '#', - 'A', 'B', 'C', 'D', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' - ], make.number.range()).join('') + let count = make.number.range() + const values = [] + while (count--) { + values.push(random.item(['*', '#', 'A', 'B', 'C', 'D', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'])) + } + + return values.join('') } static goodHostnames () { diff --git a/lib/make/webgl.js b/lib/make/webgl.js index 14e2400..6a4cce0 100644 --- a/lib/make/webgl.js +++ b/lib/make/webgl.js @@ -72,7 +72,7 @@ class webgl extends make { static parseUniforms (shader, group = 1) { /* Todo: Parse their individual data types into categories. */ - return webgl.match(shader, /uniform .+? (\w+)(?=[\[;])/gm, group) /* eslint-disable-line no-useless-escape */ + return webgl.match(shader, /uniform .+? (\w+)(?=[\[;])/gm, group) // eslint-disable-line no-useless-escape } static parseAttributes (shader, group = 1) { @@ -90,7 +90,7 @@ class webgl extends make { static parseFragDatav3 (shader, group = 1) { // #version 300 - return webgl.match(shader, /out .+? (\w+)(?=[\[;])/gm, group) /* eslint-disable-line no-useless-escape */ + return webgl.match(shader, /out .+? (\w+)(?=[\[;])/gm, group) // eslint-disable-line no-useless-escape } static parseFrag (shader, group = 1) { @@ -102,7 +102,12 @@ class webgl extends make { } static randomBitmask () { - return parseInt((random.subset([1, 0], 8).join(''))) + const values = [] + for (let i = 0; i < 8; i++) { + values.push(random.item([1, 0])) + } + + return parseInt(values.join('')) } static randomBufferTarget (isWebGL2) { From 2786f886fceca50af7a99d8b9c1e732a57e84249 Mon Sep 17 00:00:00 2001 From: pyoor Date: Thu, 26 Jul 2018 19:27:25 -0400 Subject: [PATCH 50/68] Added JSDoc throughout and minor refactoring --- lib/random/random.js | 92 +++++++++++++++++++++++++++++++------------- 1 file changed, 66 insertions(+), 26 deletions(-) diff --git a/lib/random/random.js b/lib/random/random.js index eb4b901..38e1034 100644 --- a/lib/random/random.js +++ b/lib/random/random.js @@ -7,28 +7,31 @@ const {logger} = require('../logging') class random { /** - * Must be called before any other methods can be called to initialize MersenneTwister. - * @param {number|null|undefined} seed Value to initialize MersenneTwister. + * Must be called before any other methods can be called to initialize MersenneTwister + * @param {number|null|undefined} seed - Value to initialize MersenneTwister */ static init (seed) { if (seed === null || seed === undefined) { random.seed = new Date().getTime() } + random.twister = new MersenneTwister() random.twister.seed(random.seed) } /** - * Returns an integer in [0, limit). Uniform distribution. - * @param limit + * Returns an integer in [0, limit] (uniform distribution) + * @param {number} limit */ static number (limit) { if (!random.twister) { throw new Error('random.init must be called first.') } + if (limit === null || limit === undefined) { limit = 0xffffffff } + let x = (0x100000000 / limit) >>> 0 let y = (x * limit) >>> 0 let r @@ -39,19 +42,20 @@ class random { } /** - * Returns a float in [0, 1). Uniform distribution. + * Returns a float in [0, 1] (uniform distribution) */ static float () { if (!random.twister) { throw new Error('random.init must be called first.') } + return random.twister.real2() } /** - * Returns an integer in [start, limit]. Uniform distribution. - * @param start - * @param limit + * Returns an integer in [start, limit] (uniform distribution) + * @param {number} start + * @param {number} limit */ static range (start, limit) { if (!random.twister) { @@ -66,69 +70,93 @@ class random { /** * Returns a float in [1, limit]. The logarithm has uniform distribution. - * @param {*} limit + * @param {number} limit */ static ludOneTo (limit) { return Math.exp(random.float() * Math.log(limit)) } + /** + * Returns a random index from a list + * @param {Array} list + * @returns list[n] + */ static item (list) { - if (list === undefined || typeof list === 'string' || list.length === undefined) { + if (!Array.isArray(list)) { logger.traceback() throw new TypeError(`random.item() received invalid object: (${list})`) } + return list[random.number(list.length)] } /** - * Returns a random key of a provided object. - * @param {*} obj + * Returns a random key of a provided object + * @param {Object} obj */ static key (obj) { - let list = [] - for (let i in obj) { - list.push(i) - } - return random.item(list) + return random.item(Object.keys(obj)) } /** - * Return a random Boolean value. + * Return a random Boolean value */ static bool () { return random.item([true, false]) } + /** + * Recursively iterate over array until non-array item identified + * If item is a function, evaluate it with no args + * @param {*} obj + * @returns {*} + */ static pick (obj) { + if (!(Array.isArray(obj) || typeof obj === 'function')) { + logger.traceback() + throw new TypeError(`random.pick() received invalid object: (${obj})`) + } + if (typeof obj === 'function') { return obj() - } - if (Array.isArray(obj)) { + } else if (Array.isArray(obj)) { return random.pick(random.item(obj)) } + return obj } - static chance (limit) { - if (limit === null || limit === undefined) { - limit = 2 - } + /** + * Returns a boolean result based on limit + * @param limit + * @returns {boolean} + */ + static chance (limit = 2) { if (isNaN(limit)) { logger.traceback() throw new TypeError(`random.chance() received non-number type: (${limit})`) } + return random.number(limit) === 1 } - static choose (list, flat) { + /** + * Return an item from an array of arrays where the first index in each sub-array denotes the weight + * @param {Array} list - Array of arrays + * @param {Boolean} flat - Indicates whether we should iterate over the arrays recursively + * @returns {*} + */ + static choose (list, flat = false) { if (!(Array.isArray(list))) { logger.traceback() throw new TypeError(`random.choose() received non-array type: (${list})`) } + let total = 0 for (let i = 0; i < list.length; i++) { total += list[i][0] } + let n = random.number(total) for (let i = 0; i < list.length; i++) { if (n < list[i][0]) { @@ -140,9 +168,11 @@ class random { } n = n - list[i][0] } - if (flat === true) { + + if (flat) { return list[0][1] } + return random.pick([list[0][1]]) } @@ -157,6 +187,7 @@ class random { a.push(wa[i].v) } } + return a } @@ -164,6 +195,10 @@ class random { return random.bool() ? obj : '' } + /** + * Returns arr shuffled + * @param arr + */ static shuffle (arr) { let i = arr.length while (i--) { @@ -174,6 +209,11 @@ class random { } } + /** + * Returns a shuffled copy of arr + * @param arr + * @returns {*} + */ static shuffled (arr) { let newArray = arr.slice() random.shuffle(newArray) From e87962069a22a6b2ea6e4ae758297d7677439f7c Mon Sep 17 00:00:00 2001 From: pyoor Date: Thu, 26 Jul 2018 19:44:34 -0400 Subject: [PATCH 51/68] Minor fixes --- lib/random/random.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/random/random.js b/lib/random/random.js index 38e1034..403a59a 100644 --- a/lib/random/random.js +++ b/lib/random/random.js @@ -20,7 +20,7 @@ class random { } /** - * Returns an integer in [0, limit] (uniform distribution) + * Returns an integer in [0, limit) (uniform distribution) * @param {number} limit */ static number (limit) { @@ -42,7 +42,7 @@ class random { } /** - * Returns a float in [0, 1] (uniform distribution) + * Returns a float in [0, 1) (uniform distribution) */ static float () { if (!random.twister) { @@ -53,7 +53,7 @@ class random { } /** - * Returns an integer in [start, limit] (uniform distribution) + * Returns an integer in [start, limit) (uniform distribution) * @param {number} start * @param {number} limit */ @@ -61,15 +61,17 @@ class random { if (!random.twister) { throw new Error('random.init must be called first.') } + if (isNaN(start) || isNaN(limit)) { logger.traceback() throw new TypeError(`random.range() received non-number type: (${start}, ${limit})`) } + return random.number(limit - start + 1) + start } /** - * Returns a float in [1, limit]. The logarithm has uniform distribution. + * Returns a float in [1, limit). The logarithm has uniform distribution. * @param {number} limit */ static ludOneTo (limit) { From 385894b5ac69da0bfa41b1601e7082ffdeff0961 Mon Sep 17 00:00:00 2001 From: pyoor Date: Mon, 30 Jul 2018 10:36:46 -0400 Subject: [PATCH 52/68] Remove incorrect check in random.pick --- lib/random/random.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/random/random.js b/lib/random/random.js index 403a59a..3a86f64 100644 --- a/lib/random/random.js +++ b/lib/random/random.js @@ -114,11 +114,6 @@ class random { * @returns {*} */ static pick (obj) { - if (!(Array.isArray(obj) || typeof obj === 'function')) { - logger.traceback() - throw new TypeError(`random.pick() received invalid object: (${obj})`) - } - if (typeof obj === 'function') { return obj() } else if (Array.isArray(obj)) { From 879af3cacf7db310ee56dcf24ff2749cbc0b8a40 Mon Sep 17 00:00:00 2001 From: pyoor Date: Mon, 30 Jul 2018 19:25:37 -0400 Subject: [PATCH 53/68] Add simple generator for return random class names --- lib/make/html.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/make/html.js b/lib/make/html.js index c2de5b3..16019b8 100644 --- a/lib/make/html.js +++ b/lib/make/html.js @@ -17,6 +17,10 @@ class html extends make { static interfaceName () { return random.pick(['HTMLBRElement', 'HTMLTableSectionElement', 'HTMLDataListElement', 'HTMLTableElement', 'HTMLOListElement', 'HTMLFontElement', 'HTMLMapElement', 'HTMLButtonElement', 'HTMLFrameSetElement', 'HTMLDataElement', 'HTMLOptGroupElement', 'HTMLAnchorElement', 'HTMLLinkElement', 'HTMLObjectElement', 'HTMLHeadElement', 'HTMLProgressElement', 'HTMLFrameElement', 'HTMLTimeElement', 'HTMLTableCaptionElement', 'HTMLDivElement', 'HTMLDListElement', 'HTMLBodyElement', 'HTMLImageElement', 'HTMLTableRowElement', 'HTMLScriptElement', 'HTMLInputElement', 'HTMLMeterElement', 'HTMLFieldSetElement', 'HTMLHtmlElement', 'HTMLStyleElement', 'HTMLDetailsElement', 'HTMLTrackElement', 'HTMLBaseElement', 'HTMLTableColElement', 'HTMLSourceElement', 'HTMLPictureElement', 'HTMLSelectElement', 'HTMLLegendElement', 'HTMLHRElement', 'HTMLModElement', 'HTMLTemplateElement', 'HTMLAreaElement', 'HTMLFormElement', 'HTMLEmbedElement', 'HTMLSpanElement', 'HTMLParagraphElement', 'HTMLIFrameElement', 'HTMLTableCellElement', 'HTMLElement', 'HTMLMenuElement', 'HTMLTextAreaElement', 'HTMLHeadingElement', 'HTMLCanvasElement', 'HTMLOutputElement', 'HTMLQuoteElement', 'HTMLOptionElement', 'HTMLLIElement', 'HTMLAudioElement', 'HTMLMenuItemElement', 'HTMLParamElement', 'HTMLUListElement', 'HTMLLabelElement', 'HTMLDirectoryElement', 'HTMLTitleElement', 'HTMLPreElement', 'HTMLMetaElement', 'HTMLVideoElement']) } + + static className () { + return random.item(['class_1', 'class_2', 'class_3', 'class_4']) + } } module.exports = html From be27c5057c0b0e4546b07adac07434f50f3bf3c6 Mon Sep 17 00:00:00 2001 From: pyoor Date: Wed, 1 Aug 2018 10:57:28 -0400 Subject: [PATCH 54/68] Only escape required characters (non-ASCII safe) --- lib/utils/common.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/utils/common.js b/lib/utils/common.js index f9b3101..7e1f278 100644 --- a/lib/utils/common.js +++ b/lib/utils/common.js @@ -32,9 +32,9 @@ class common extends utils { static quote (s) { if (typeof s === 'string') { - return `'${jsesc(s)}'` + return `'${jsesc(s, {minimal: true})}'` } else { - return jsesc(s) + return jsesc(s, {minimal: true}) } } From b2206ba0b2535d7e5e054c41a6df3925f63f783a Mon Sep 17 00:00:00 2001 From: pyoor Date: Wed, 1 Aug 2018 12:01:42 -0400 Subject: [PATCH 55/68] Revert "Only escape required characters (non-ASCII safe)" This reverts commit be27c5057c0b0e4546b07adac07434f50f3bf3c6. --- lib/utils/common.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/utils/common.js b/lib/utils/common.js index 7e1f278..f9b3101 100644 --- a/lib/utils/common.js +++ b/lib/utils/common.js @@ -32,9 +32,9 @@ class common extends utils { static quote (s) { if (typeof s === 'string') { - return `'${jsesc(s, {minimal: true})}'` + return `'${jsesc(s)}'` } else { - return jsesc(s, {minimal: true}) + return jsesc(s) } } From 21a6025481a3cda143c922a672847bf0afb42d54 Mon Sep 17 00:00:00 2001 From: pyoor Date: Thu, 2 Aug 2018 11:26:21 -0400 Subject: [PATCH 56/68] Refactor text generator --- lib/make/text.js | 389 +++++++++++++++++++++++++++++------------------ 1 file changed, 240 insertions(+), 149 deletions(-) diff --git a/lib/make/text.js b/lib/make/text.js index 2d4bbcc..bcdaf25 100644 --- a/lib/make/text.js +++ b/lib/make/text.js @@ -7,18 +7,66 @@ const make = require('../make') const utils = require('../utils') class text extends make { - static lineEnd () { + /** + * Generate a random alphabetic character + */ + static alpha () { + return String.fromCharCode(random.range('A'.charCodeAt(0), 'z'.charCodeAt(0))) + } + + /** + * Generate a random alphanumeric character + */ + static alphanum () { + return String.fromCharCode(random.range('0'.charCodeAt(0), 'z'.charCodeAt(0))) + } + + /** + * Generate a random assignment operator + */ + static assignmentOperator () { return random.pick([ - '\n', '\r', '\r\n', '\n\r' + '=', '+=', '-=', '*=', '/=', '%=', '**=', '<<=', '>>=', '>>>=', '&=', '^=', '|=' ]) } + /** + * Generate a random arithmetic operator + */ + static arithmeticOperator () { + return random.pick([ + '%', '-', '+', '*', '/' + ]) + } + + /** + * Generate a random control character + */ static controlChar () { return random.pick([ '\b', '\t', '\n', '\v', '\f', '\r', '\0', '\c', '\a', '\e' // eslint-disable-line no-useless-escape ]) } + /** + * Generate a random digit + */ + static digit () { + return String.fromCharCode(random.range('0'.charCodeAt(0), '9'.charCodeAt(0))) + } + + /** + * Generate a random line ending + */ + static lineEnd () { + return random.pick([ + '\n', '\r', '\r\n', '\n\r' + ]) + } + + /** + * Generate a random token + */ static token () { return random.pick([ '*', '+', '%', '-', '!', '^', ':', '|', '&', '<', '>', '.', '"', @@ -35,9 +83,9 @@ class text extends make { static language () { return random.pick([ // special casing for i, I, dotted/dotless variants - ['tr', 'az'], + ['tr', 'az', 'crh', 'tt', 'ba'], // special casing rules: https://developer.mozilla.org/en/CSS/text-transform - ['nl', 'gr'], + ['nl', 'el', 'ga'], // special justification rules ['ja', 'zh'], // tend to be RTL @@ -49,155 +97,176 @@ class text extends make { ]) } + /** + * Generate a random character that may affect layout + */ static layoutCharCodes () { - return random.pick([ - 0, // null - 160, // non-breaking space - 0x005C, // backslash, but in some countries, represents local currency symbol (e.g. yen) - 0x00AD, // soft hyphen - 0x0BCC, // a Tamil character that is displayed as three glyphs - // http://unicode.org/charts/PDF/U2000.pdf - 0x200B, // zero-width space - 0x200C, // zero-width non-joiner - 0x200D, // zero-width joiner - 0x200E, // left-to-right mark - 0x200F, // right-to-left mark - 0x2011, // non-breaking hyphen - 0x2027, // hyphenation point - 0x2028, // line separator - 0x2029, // paragraph separator - 0x202A, // left-to-right embedding - 0x202B, // right-to-left embedding - 0x202C, // pop directional formatting - 0x202D, // left-to-right override - 0x202E, // right-to-left override - 0x202F, // narrow no-break space - 0x2060, // word joiner - 0x2061, // function application (one of several invisible mathematical operators) - // http://unicode.org/charts/PDF/U3000.pdf - 0x3000, // ideographic space (CJK) - // http://unicode.org/charts/PDF/U0300.pdf - 0x0301, // combining acute accent (if it appears after "a", it turns into "a" with an accent) - // Arabic has the interesting property that most letters connect to the next letter. - // Some code calls this "shaping". - 0x0643, // arabic letter kaf - 0x0645, // arabic letter meem - 0x06CD, // arabic letter yeh with tail - 0xFDDE, // invalid unicode? but somehow associated with arabic. - // http://unicode.org/reports/tr36/tr36-7.html#Buffer_Overflows - // Characters with especially high expansion factors when they go through various unicode "normalizations" - 0x1F82, - 0xFDFA, - 0xFB2C, - 0x0390, - // 0x1D160, // hmm, need surrogates - // Characters with especially high expansion factors when lowercased or uppercased - 0x023A, - 0x0041, - 0xDC1D, // a low surrogate - 0xDB00, // a high surrogate - // UFFF0.pdf - 0xFFF9, // interlinear annotation anchor - 0xFFFA, // interlinear annotation seperator - 0xFFFB, // interlinear annotation terminator - 0xFFFC, // object replacement character - 0xFFFD, // replacement character - 0xFEFF, // zero width no-break space - 0xFFFF, // not a character - 0x00A0, // no-break space - 0x2426, - 0x003F, - 0x00BF, - 0xDC80, - 0xDCFF, - // http://en.wikipedia.org/wiki/Mapping_of_Unicode_characters - 0x205F, // mathematical space - 0x2061, // mathematical function application - 0x2064, // mathematical invisible separator - 0x2044 // fraction slash character - ]) + return String.fromCodePoint( + random.pick([ + 0, // null + 160, // non-breaking space + 0x005C, // backslash, but in some countries, represents local currency symbol (e.g. yen) + 0x00AD, // soft hyphen + 0x0BCC, // a Tamil character that is displayed as three glyphs + // http://unicode.org/charts/PDF/U2000.pdf + 0x200B, // zero-width space + 0x200C, // zero-width non-joiner + 0x200D, // zero-width joiner + 0x200E, // left-to-right mark + 0x200F, // right-to-left mark + 0x2011, // non-breaking hyphen + 0x2027, // hyphenation point + 0x2028, // line separator + 0x2029, // paragraph separator + 0x202A, // left-to-right embedding + 0x202B, // right-to-left embedding + 0x202C, // pop directional formatting + 0x202D, // left-to-right override + 0x202E, // right-to-left override + 0x202F, // narrow no-break space + 0x2060, // word joiner + 0x2061, // function application (one of several invisible mathematical operators) + // http://unicode.org/charts/PDF/U3000.pdf + 0x3000, // ideographic space (CJK) + // http://unicode.org/charts/PDF/U0300.pdf + 0x0301, // combining acute accent (if it appears after "a", it turns into "a" with an accent) + // Arabic has the interesting property that most letters connect to the next letter. + // Some code calls this "shaping". + 0x0643, // arabic letter kaf + 0x0645, // arabic letter meem + 0x06CD, // arabic letter yeh with tail + 0xFDDE, // invalid unicode? but somehow associated with arabic. + // http://unicode.org/reports/tr36/tr36-7.html#Buffer_Overflows + // Characters with especially high expansion factors when they go through various unicode "normalizations" + 0x1F82, + 0xFDFA, + 0xFB2C, + 0x0390, + // 0x1D160, // hmm, need surrogates + // Characters with especially high expansion factors when lowercased or uppercased + 0x023A, + 0x0041, + 0xDC1D, // a low surrogate + 0xDB00, // a high surrogate + // UFFF0.pdf + 0xFFF9, // interlinear annotation anchor + 0xFFFA, // interlinear annotation seperator + 0xFFFB, // interlinear annotation terminator + 0xFFFC, // object replacement character + 0xFFFD, // replacement character + 0xFEFF, // zero width no-break space + 0xFFFF, // not a character + 0x00A0, // no-break space + 0x2426, + 0x003F, + 0x00BF, + 0xDC80, + 0xDCFF, + // http://en.wikipedia.org/wiki/Mapping_of_Unicode_characters + 0x205F, // mathematical space + 0x2061, // mathematical function application + 0x2064, // mathematical invisible separator + 0x2044 // fraction slash character + ]) + ) } + /** + * Generate a random character that affects bidi layout + */ static bidiCharCodes () { - return random.pick([ - 0x0660, // START_HINDI_DIGITS - 0x0669, // END_HINDI_DIGITS - 0x066A, // START_ARABIC_SEPARATOR - 0x066B, // END_ARABIC_SEPARATOR - 0x0030, // START_ARABIC_DIGITS - 0x0039, // END_ARABIC_DIGITS - 0x06f0, // START_FARSI_DIGITS - 0x06f9 // END_FARSI_DIGITS - ]) + return String.fromCodePoint( + random.pick([ + 0x0660, // START_HINDI_DIGITS + 0x0669, // END_HINDI_DIGITS + 0x066A, // START_ARABIC_SEPARATOR + 0x066B, // END_ARABIC_SEPARATOR + 0x0030, // START_ARABIC_DIGITS + 0x0039, // END_ARABIC_DIGITS + 0x06f0, // START_FARSI_DIGITS + 0x06f9 // END_FARSI_DIGITS + ]) + ) } - // http://www.unicode.org/Public/6.0.0/ucd/UnicodeData.txt - static unicodeCombiningCharacters () { - return random.item([ - [0x0300, 0x036F], // Combining Diacritical Marks - [0x0483, 0x0489], - [0x07EB, 0x07F3], - [0x135D, 0x135F], - [0x1A7F, 0x1A7F], - [0x1B6B, 0x1B73], - [0x1DC0, 0x1DFF], // Combining Diacritical Marks Supplement - [0x20D0, 0x2DFF], - [0x3099, 0x309A], - [0xA66F, 0xA6F1], - [0xA8E0, 0xA8F1], - [0xFE20, 0xFE26], // Combining Half Marks - [0x101FD, 0x101FD], - [0x1D165, 0x1D169], - [0x1D16D, 0x1D172], - [0x1D17B, 0x1D18B], - [0x1D1AA, 0x1D1AD], - [0x1D242, 0x1D244] - ]) + /** + * Generate a random unicode combining character + * http://www.unicode.org/Public/6.0.0/ucd/UnicodeData.txt + */ + static unicodeCombiningCharacter () { + return String.fromCodePoint( + random.range( + ...random.item([ + [0x0300, 0x036F], // Combining Diacritical Marks + [0x0483, 0x0489], + [0x07EB, 0x07F3], + [0x135D, 0x135F], + [0x1A7F, 0x1A7F], + [0x1B6B, 0x1B73], + [0x1DC0, 0x1DFF], // Combining Diacritical Marks Supplement + [0x20D0, 0x2DFF], + [0x3099, 0x309A], + [0xA66F, 0xA6F1], + [0xA8E0, 0xA8F1], + [0xFE20, 0xFE26], // Combining Half Marks + [0x101FD, 0x101FD], + [0x1D165, 0x1D169], + [0x1D16D, 0x1D172], + [0x1D17B, 0x1D18B], + [0x1D1AA, 0x1D1AD], + [0x1D242, 0x1D244] + ]) + ) + ) } + /** + * Generate a random basic multilingual plane character + */ static unicodeBMP () { - return random.item([ - // BMP = Basic Multilingual Plane - [0x0000, 0xFFFF] - ]) + return String.fromCodePoint( + random.range(0x0000, 0xFFFF) + ) } + /** + * Generate a random supplementary multilingual plane character + */ static unicodeSMP () { - return random.item([ - // SMP = Supplementary Multilingual Plane - [0x10000, 0x13FFF], - [0x16000, 0x16FFF], - [0x1B000, 0x1BFFF], - [0x1D000, 0x1DFFF], - [0x1F000, 0x1FFFF] - ]) + return String.fromCodePoint( + random.range( + ...random.item([ + [0x10000, 0x13FFF], + [0x16000, 0x16FFF], + [0x1B000, 0x1BFFF], + [0x1D000, 0x1DFFF], + [0x1F000, 0x1FFFF] + ]) + ) + ) } + /** + * Generate a random supplementary ideographic plane character + */ static unicodeSIP () { - return random.item([ - // SIP = Supplementary Ideographic Plane - [0x20000, 0x2BFFF], - [0x2F000, 0x2FFFF] - ]) + return String.fromCodePoint( + random.range( + ...random.item([ + [0x20000, 0x2BFFF], + [0x2F000, 0x2FFFF] + ]) + ) + ) } + /** + * Generate a random supplementary special-purpose plane character + */ static unicodeSSP () { - return random.item([ - // SSP = Supplementary Special-purpose Plane - [0xE0000, 0xE0FFF] - ]) - } - - static assignmentOperator () { - return random.pick([ - '=', '+=', '-=', '*=', '/=', '%=', '**=', '<<=', '>>=', '>>>=', '&=', '^=', '|=' - ]) - } - - static arithmeticOperator () { - return random.pick([ - '%', '-', '+', '*', '/' - ]) + return String.fromCodePoint( + random.range(0xE0000, 0xE0FFF) + ) } static currency () { @@ -222,26 +291,48 @@ class text extends make { return utils.common.quote(text.any()) } - static chars () { - return random.pick([ - text.controlChar, - text.token, - text.assignmentOperator, - text.arithmeticOperator, - String.fromCharCode(text.layoutCharCodes()), - String.fromCharCode(text.bidiCharCodes()) + /** + * Wrapper for all text generators + * @returns {string} + */ + static random () { + return random.choose([ + [1, text.alpha], + [1, text.alphanum], + [1, text.arithmeticOperator], + [1, text.assignmentOperator], + [1, text.controlChar], + [1, text.digit], + [1, text.lineEnd], + [1, text.token], + [3, text.layoutCharCodes], + [3, text.bidiCharCodes], + [3, text.unicodeCombiningCharacter], + [3, text.unicodeBMP], + [3, text.unicodeSMP], + [3, text.unicodeSIP], + [3, text.unicodeSSP] ]) } + /** + * Generate a single character + */ + static character () { + return text.random().charAt(0) + } + + /** + * Generate string comprised of random generators + */ static any () { - // Generate a string compromised of random individual characters - // This might be too slow to used for all 'texts' uses let s = '' - // TODO: Len calculation take from DOMFuzz - maybe we should revise this? - let len = random.pick([make.number.tiny, make.number.range]) - for (let i = 0; i < len; i++) { - s += make.text.chars() + let len = random.range(1, 126) + + while (len--) { + s += make.text.random() } + return s } } From 195411fe8d5ad91d730df8138b8e407599aa9540 Mon Sep 17 00:00:00 2001 From: pyoor Date: Thu, 2 Aug 2018 14:21:27 -0400 Subject: [PATCH 57/68] Major rework of make.number --- lib/make/numbers.js | 91 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 89 insertions(+), 2 deletions(-) diff --git a/lib/make/numbers.js b/lib/make/numbers.js index d96b7f2..86a40f5 100644 --- a/lib/make/numbers.js +++ b/lib/make/numbers.js @@ -6,8 +6,94 @@ const make = require('../make') const random = require('../random') class number extends make { - static bool () { - return random.bool() + /** + * generate a number that exceeds the supplied boundary by +- 3 + * @param start + * @param end + * @private + */ + static _exceed (start, end) { + const value = random.item([start, end]) + const offset = random.range(-3, 3) + return value + offset + } + + /** + * Generate a int8 [-128, 127] + * @param bypass {boolean} - Determines if the range should be exceeded + * @returns {number} + */ + static int8 (bypass = false) { + if (bypass || random.chance(50)) { + return number._exceed(-128, 127) + } + + return random.range(-128, 127) + } + + /** + * Generate a uint8 [0, 255] + * @param bypass {boolean} - Determines if the range should be exceeded + * @returns {number} + */ + static uint8 (bypass = false) { + if (bypass || random.chance(50)) { + return number._exceed(0, 255) + } + + return random.range(0, 255) + } + + /** + * Generate a int16 [-32768, 32767] + * @param bypass {boolean} - Determines if the range should be exceeded + * @returns {number} + */ + static int16 (bypass = false) { + if (bypass || random.chance(50)) { + return number._exceed(-32768, 32767) + } + + return random.range(-32768, 32767) + } + + /** + * Generate a uint16 [0, 65535] + * @param bypass {boolean} - Determines if the range should be exceeded + * @returns {*} + */ + static uint16 (bypass = false) { + if (bypass || random.chance(50)) { + return number._exceed(0, 65535) + } + + return random.range(-0, 65535) + } + + /** + * Generate a int32 [-2147483648, 2147483647] + * @param bypass {boolean} - Determines if the range should be exceeded + * @returns {number} + */ + static int32 (bypass = false) { + if (bypass || random.chance(50)) { + return number._exceed(-2147483648, 2147483647) + } + + return random.range(-2147483648, 2147483647) + } + + /** + * Generate a uint32 [0, 4294967295] + * @param bypass {boolean} - Determines if the range should be exceeded + * @returns {number} + */ + static uint32 (bypass = false) { + if (bypass || random.chance(50)) { + return number._exceed(0, 4294967295) + } + + return random.range(0, 4294967295) } static float () { @@ -74,6 +160,7 @@ class number extends make { static any () { let value = random.choose([ + [1, number.interesting], [1, number.float], [1, number.unsigned], [1, [number.range, number.tiny]] From 80f16a4aaf26efe3b54ad731c4b0eafa6b1e8a9e Mon Sep 17 00:00:00 2001 From: pyoor Date: Thu, 2 Aug 2018 14:26:17 -0400 Subject: [PATCH 58/68] Only escape minimal characters and allow HTML escapes --- lib/utils/common.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/utils/common.js b/lib/utils/common.js index f9b3101..d30f0ed 100644 --- a/lib/utils/common.js +++ b/lib/utils/common.js @@ -30,11 +30,22 @@ class common extends utils { return list } - static quote (s) { + /** + * Escape and quote a string + * @param s {string} - String to be quoted + * @param html {boolean} - Identifies whether the string must be HTML safe + * @returns {*} + */ + static quote (s, html = false) { + const options = { + minimal: true, + isScriptContext: html + } + if (typeof s === 'string') { - return `'${jsesc(s)}'` + return `'${jsesc(s, options)}'` } else { - return jsesc(s) + return jsesc(s, options) } } From b47a281403db961fc928d1fb22abe2f8b4a3516f Mon Sep 17 00:00:00 2001 From: pyoor Date: Mon, 6 Aug 2018 10:22:21 -0400 Subject: [PATCH 59/68] Add additional strategies to make._exceed --- lib/make/numbers.js | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/lib/make/numbers.js b/lib/make/numbers.js index 86a40f5..0088850 100644 --- a/lib/make/numbers.js +++ b/lib/make/numbers.js @@ -7,15 +7,23 @@ const random = require('../random') class number extends make { /** - * generate a number that exceeds the supplied boundary by +- 3 - * @param start - * @param end + * Generate a number that is more likely to exceed the supplied boundary + * @param value {number} * @private */ - static _exceed (start, end) { - const value = random.item([start, end]) - const offset = random.range(-3, 3) - return value + offset + static _exceed (value) { + switch (random.number(4)) { + case 0: + // Divisions + return Math.ceil(value / random.range(2, 4)) + case 1: + // Powers + const offset = Math.pow(2, random.range(1, 7)) + return (value > 0) ? (value - offset) : value + offset + default: + // Slightly less than limit + return (value > 0) ? (value - random.number(3)) : value + random.number(3) + } } /** @@ -25,7 +33,10 @@ class number extends make { */ static int8 (bypass = false) { if (bypass || random.chance(50)) { - return number._exceed(-128, 127) + return number._exceed(random.choose([ + [1, -128], + [10, 127] + ])) } return random.range(-128, 127) @@ -38,7 +49,7 @@ class number extends make { */ static uint8 (bypass = false) { if (bypass || random.chance(50)) { - return number._exceed(0, 255) + return number._exceed(255) } return random.range(0, 255) @@ -51,7 +62,10 @@ class number extends make { */ static int16 (bypass = false) { if (bypass || random.chance(50)) { - return number._exceed(-32768, 32767) + return number._exceed(random.choose([ + [1, -32768], + [10, 32767] + ])) } return random.range(-32768, 32767) @@ -64,7 +78,7 @@ class number extends make { */ static uint16 (bypass = false) { if (bypass || random.chance(50)) { - return number._exceed(0, 65535) + return number._exceed(65535) } return random.range(-0, 65535) @@ -77,7 +91,10 @@ class number extends make { */ static int32 (bypass = false) { if (bypass || random.chance(50)) { - return number._exceed(-2147483648, 2147483647) + return number._exceed(random.choose([ + [1, -2147483648], + [10, 2147483647] + ])) } return random.range(-2147483648, 2147483647) @@ -90,7 +107,7 @@ class number extends make { */ static uint32 (bypass = false) { if (bypass || random.chance(50)) { - return number._exceed(0, 4294967295) + return number._exceed(4294967295) } return random.range(0, 4294967295) From e95c56bb7fa3fa099ac6bbc4666c93ab85a86bdd Mon Sep 17 00:00:00 2001 From: pyoor Date: Mon, 13 Aug 2018 09:35:47 -0400 Subject: [PATCH 60/68] Significantly reduce the weight of large int numbers --- lib/make/numbers.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/make/numbers.js b/lib/make/numbers.js index 0088850..99de227 100644 --- a/lib/make/numbers.js +++ b/lib/make/numbers.js @@ -169,8 +169,8 @@ class number extends make { static interesting () { return random.choose([ - [10, [-128, -1, 0, 1, 16, 32, 64, 100, 127]], - [7, [-32768, -129, 128, 255, 256, 512, 1000, 1024, 4096, 32767]], + [50, [-128, -1, 0, 1, 16, 32, 64, 100, 127]], + [30, [-32768, -129, 128, 255, 256, 512, 1000, 1024, 4096, 32767]], [1, [-2147483648, -100663046, -32769, 32768, 65535, 65536, 100663045, 2147483647]] ]) } From 68c606d0dd3c74f7b3a2b0408b9aa1654cbc3bfe Mon Sep 17 00:00:00 2001 From: pyoor Date: Mon, 13 Aug 2018 10:59:05 -0400 Subject: [PATCH 61/68] Additional JSDoc fixes --- lib/random/random.js | 2 +- lib/utils/common.js | 51 ++++++++++++++++++++++++++++++++++++++------ 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/lib/random/random.js b/lib/random/random.js index 3a86f64..ec87107 100644 --- a/lib/random/random.js +++ b/lib/random/random.js @@ -81,7 +81,7 @@ class random { /** * Returns a random index from a list * @param {Array} list - * @returns list[n] + * @returns {*} */ static item (list) { if (!Array.isArray(list)) { diff --git a/lib/utils/common.js b/lib/utils/common.js index d30f0ed..d35f2ef 100644 --- a/lib/utils/common.js +++ b/lib/utils/common.js @@ -5,6 +5,11 @@ const jsesc = require('jsesc') const utils = require('../utils') class common extends utils { + /** + * Return stringified object + * @param obj + * @returns {string} + */ static objToString (obj) { try { return `${obj}` @@ -13,6 +18,11 @@ class common extends utils { } } + /** + * Return enumerable properties recursively + * @param obj + * @returns {Array} + */ static getAllProperties (obj) { let list = [] while (obj) { @@ -22,6 +32,11 @@ class common extends utils { return list } + /** + * Return all properties (non-recursive) + * @param obj + * @returns {Array} + */ static getKeysFromHash (obj) { let list = [] for (let p in obj) { @@ -32,8 +47,8 @@ class common extends utils { /** * Escape and quote a string - * @param s {string} - String to be quoted - * @param html {boolean} - Identifies whether the string must be HTML safe + * @param s - String to be quoted + * @param {boolean} html - Identifies whether the string must be HTML safe * @returns {*} */ static quote (s, html = false) { @@ -49,9 +64,13 @@ class common extends utils { } } + /** + * Unicode safe b64 encoding + * https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#The_Unicode_Problem + * @param {string} str + * @returns {*} + */ static b64encode (str) { - // Unicode safe b64 encoding - // https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#The_Unicode_Problem if (process.browser) { return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function toSolidBytes (match, p1) { @@ -64,9 +83,13 @@ class common extends utils { } } + /** + * Unicode safe b64 decoding + * https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#The_Unicode_Problem + * @param {string} str + * @returns {*} + */ static b64decode (str) { - // Unicode safe b64 decoding - // https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#The_Unicode_Problem if (process.browser) { return decodeURIComponent(atob(str).split('').map(function (c) { return `%${('00' + c.charCodeAt(0).toString(16)).slice(-2)}` @@ -76,6 +99,11 @@ class common extends utils { } } + /** + * Remove duplicate items from a list + * @param {Array} list + * @returns {Array} + */ static uniqueList (list) { let tmp = {} let r = [] @@ -88,6 +116,12 @@ class common extends utils { return r } + /** + * Merge two objects recursively + * @param {Object} obj1 + * @param {Object} obj2 + * @returns {*} + */ static mergeHash (obj1, obj2) { for (let p in obj2) { try { @@ -103,6 +137,11 @@ class common extends utils { return obj1 } + /** + * Template string beautifier + * @param {Object} obj + * @returns {string} + */ static mockup (obj) { return obj.split('\n').map((ln) => ln.trim()).join('') } From 946e3224064a57e51aa5edc61383208c19082463 Mon Sep 17 00:00:00 2001 From: pyoor Date: Mon, 20 Aug 2018 12:20:36 -0400 Subject: [PATCH 62/68] Refactor make.arrays.filledArray --- lib/make/arrays.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/make/arrays.js b/lib/make/arrays.js index 639461e..0d05fb6 100644 --- a/lib/make/arrays.js +++ b/lib/make/arrays.js @@ -6,13 +6,18 @@ const make = require('../make') const random = require('../random') class arrays extends make { - static filledArray (fn, limit) { - let array = [] - let size = limit || random.number(make.number.tiny()) + 1 + /** + * Returns an array containing random values generated by the supplied function + * @param {Function} fn - Function used to generate values + * @param {number} limit - Length of the array + * @returns {Array} + */ + static filledArray (fn, limit = make.number.tiny()) { + const array = [] - for (let i = 0; i < size; i++) { - let value = random.pick(fn) - if (value !== undefined) { + for (let i = 0; i < limit; i++) { + const value = random.pick(fn) + if (value !== null) { array.push(value) } } From 0683dc88fb6aa3ab86196e5b278113b43ccdcf92 Mon Sep 17 00:00:00 2001 From: pyoor Date: Mon, 20 Aug 2018 12:21:12 -0400 Subject: [PATCH 63/68] Use make.number.tiny instead of make.number.range --- lib/make/network.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/make/network.js b/lib/make/network.js index ce4e233..f962479 100644 --- a/lib/make/network.js +++ b/lib/make/network.js @@ -141,7 +141,7 @@ class network extends make { } static dtmf () { - let count = make.number.range() + let count = make.number.tiny() const values = [] while (count--) { values.push(random.item(['*', '#', 'A', 'B', 'C', 'D', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'])) From fa47ea0d70b1f3ab68976d51ca2ad56ac4c03222 Mon Sep 17 00:00:00 2001 From: pyoor Date: Mon, 20 Aug 2018 12:21:37 -0400 Subject: [PATCH 64/68] Remove non-typed generators from make.typed.any --- lib/make/typed.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/make/typed.js b/lib/make/typed.js index 53bc4e1..2c5b953 100644 --- a/lib/make/typed.js +++ b/lib/make/typed.js @@ -82,8 +82,7 @@ class typed extends make { [1, [typed.short, typed.unsignedShort]], [1, [typed.long, typed.unsignedLong]], [1, [typed.float, typed.unrestrictedFloat]], - [1, [typed.double, typed.unrestrictedDouble]], - [1, [make.number.range, make.number.tiny]] + [1, [typed.double, typed.unrestrictedDouble]] ]) } From ad5ae5656162e5a609b8e3fa8c091c318a542eae Mon Sep 17 00:00:00 2001 From: pyoor Date: Mon, 20 Aug 2018 12:21:54 -0400 Subject: [PATCH 65/68] Use make.number.tiny instead of make.number.range --- lib/utils/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utils/script.js b/lib/utils/script.js index 81ef852..e73730f 100644 --- a/lib/utils/script.js +++ b/lib/utils/script.js @@ -43,7 +43,7 @@ class script extends utils { } static makeLoop (s, max) { - return `for (let i = 0; i < ${max || make.number.range()}; i++) {${s}}` + return `for (let i = 0; i < ${max || make.number.tiny()}; i++) {${s}}` } static makeRandomOptions (baseObject) { From e611cb8a1992e78255c9793e1fadc0eb7b9bd7e5 Mon Sep 17 00:00:00 2001 From: pyoor Date: Mon, 20 Aug 2018 12:22:16 -0400 Subject: [PATCH 66/68] Further refactoring of make.numbers --- lib/make/numbers.js | 117 ++++++++++++++++++++++++++++---------------- 1 file changed, 74 insertions(+), 43 deletions(-) diff --git a/lib/make/numbers.js b/lib/make/numbers.js index 99de227..cef5d97 100644 --- a/lib/make/numbers.js +++ b/lib/make/numbers.js @@ -7,7 +7,7 @@ const random = require('../random') class number extends make { /** - * Generate a number that is more likely to exceed the supplied boundary + * Returns a number that is more likely to exceed the supplied boundary * @param value {number} * @private */ @@ -27,7 +27,7 @@ class number extends make { } /** - * Generate a int8 [-128, 127] + * Returns a int8 [-128, 127] * @param bypass {boolean} - Determines if the range should be exceeded * @returns {number} */ @@ -43,7 +43,7 @@ class number extends make { } /** - * Generate a uint8 [0, 255] + * Returns a uint8 [0, 255] * @param bypass {boolean} - Determines if the range should be exceeded * @returns {number} */ @@ -56,7 +56,7 @@ class number extends make { } /** - * Generate a int16 [-32768, 32767] + * Returns a int16 [-32768, 32767] * @param bypass {boolean} - Determines if the range should be exceeded * @returns {number} */ @@ -72,7 +72,7 @@ class number extends make { } /** - * Generate a uint16 [0, 65535] + * Returns a uint16 [0, 65535] * @param bypass {boolean} - Determines if the range should be exceeded * @returns {*} */ @@ -85,7 +85,7 @@ class number extends make { } /** - * Generate a int32 [-2147483648, 2147483647] + * Returns a int32 [-2147483648, 2147483647] * @param bypass {boolean} - Determines if the range should be exceeded * @returns {number} */ @@ -101,7 +101,7 @@ class number extends make { } /** - * Generate a uint32 [0, 4294967295] + * Returns a uint32 [0, 4294967295] * @param bypass {boolean} - Determines if the range should be exceeded * @returns {number} */ @@ -113,36 +113,34 @@ class number extends make { return random.range(0, 4294967295) } + /** + * Returns a random floating point number + * @returns {number} + */ static float () { - let n - if (random.chance(32)) { + /* if (random.chance(32)) { switch (random.number(4)) { case 0: - n = random.range(Number.MIN_VALUE, Number.MAX_VALUE) - break + return random.range(Number.MIN_VALUE, Number.MAX_VALUE) case 1: - n = Math.pow(10, 1) / Math.pow(10, random.number(307)) - break + return Math.pow(10, 1) / Math.pow(10, random.number(307)) case 2: - n = Math.pow(2, random.float() * random.float() * 64) - break + return Math.pow(2, random.float() * random.float() * 64) case 3: - n = Math.pow(10, random.range(1, 9)) / Math.pow(10, random.range(1, 9)) - break + return Math.pow(10, random.range(1, 9)) / Math.pow(10, random.range(1, 9)) } - return n - } - switch (random.number(6)) { - default: - n = random.float() - } - return n - } - - static range () { - return random.pick([1, 2, 3, 4, 6, 8, 16, 32, 64, number.tiny]) + } */ + + return random.float() } + /** + * Returnss a float value within the supplied range + * @param {number} min - Start value + * @param {number} max - End value + * @param {number} precision + * @returns {number} + */ static frange (min, max, precision) { let x = Math.random() * (min - max) + max if (precision) { @@ -152,21 +150,28 @@ class number extends make { return x } + /** + * Returnss a random power of 2 between 1 and 2048 + * @returns {number} + */ static tiny () { - return Math.pow(2, random.number(12)) - } - - static unsigned () { - if (random.chance(2)) { - return Math.abs(number.any()) - } - return Math.pow(2, random.number(random.number(65))) + random.number(3) - 1 + // Calling random.number twice prefers lower values + return Math.pow(2, random.number(random.number(13))) } + /** + * Returns a random number adjacent to the supplied number + * @param {number} number + * @returns {number} + */ static even (number) { return number % 2 === 1 ? ++number : number } + /** + * Returns a random number that may be interesting + * @returns {number} + */ static interesting () { return random.choose([ [50, [-128, -1, 0, 1, 16, 32, 64, 100, 127]], @@ -175,14 +180,40 @@ class number extends make { ]) } - static any () { - let value = random.choose([ - [1, number.interesting], - [1, number.float], - [1, number.unsigned], - [1, [number.range, number.tiny]] + /** + * Returns a random signed number + * @returns {number} + */ + static signed () { + return random.choose([ + [50, [number.int8]], + [30, [number.int16]], + [1, [number.int32]] + ]) + } + + /** + * Returns a random unsigned number + * @returns {number} + */ + static unsigned () { + return random.choose([ + [50, [number.uint8]], + [30, [number.uint16]], + [1, [number.uint32]] + ]) + } + + /** + * Returns a random number using the type base number generators above + * @returns {number} + */ + static any () { + return random.choose([ + [50, [number.int8, number.uint8]], + [30, [number.int16, number.uint16]], + [1, [number.int32, number.uint32]] ]) - return random.chance(10) ? -value : value } } From 9ba9cf453b91b7b75a63785063412c538053f784 Mon Sep 17 00:00:00 2001 From: pyoor Date: Mon, 20 Aug 2018 12:54:21 -0400 Subject: [PATCH 67/68] Fix typos in docstring --- lib/make/numbers.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/make/numbers.js b/lib/make/numbers.js index cef5d97..8faab16 100644 --- a/lib/make/numbers.js +++ b/lib/make/numbers.js @@ -135,7 +135,7 @@ class number extends make { } /** - * Returnss a float value within the supplied range + * Returns a float value within the supplied range * @param {number} min - Start value * @param {number} max - End value * @param {number} precision @@ -151,7 +151,7 @@ class number extends make { } /** - * Returnss a random power of 2 between 1 and 2048 + * Returns a random power of 2 between 1 and 2048 * @returns {number} */ static tiny () { From 04fadae3faebcde874f770770784b5ebc5f1d140 Mon Sep 17 00:00:00 2001 From: posidron <1614333+posidron@users.noreply.github.com> Date: Tue, 21 Aug 2018 00:34:36 +0200 Subject: [PATCH 68/68] Add np for release managment --- package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 00efd83..f4f8a99 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,8 @@ "build": "webpack -p", "watch": "webpack --watch", "precommit": "npm run test:lint", - "postinstall": "npm run build" + "postinstall": "npm run build", + "release": "np" }, "standard": { "ignore": [ @@ -52,6 +53,7 @@ "karma-coverage": "*", "karma-firefox-launcher": "^1.1.0", "karma-qunit": "^2.0.1", + "np": "^3.0.4", "qunit": "^2.5.1", "qunitjs": "^2.4.1", "standard": "^11.0.1"