jscrambler
Advanced tools
Comparing version 5.4.3 to 5.5.0
@@ -60,4 +60,17 @@ #!/usr/bin/env node | ||
_commander2.default.version(require('../../package.json').version).usage('[options] <file ...>').option('-a, --access-key <accessKey>', 'Access key').option('-c, --config <config>', 'Jscrambler configuration options').option('-H, --host <host>', 'Hostname').option('-i, --application-id <id>', 'Application ID').option('-o, --output-dir <dir>', 'Output directory').option('-p, --port <port>', 'Port').option('--protocol <protocol>', 'Protocol (http or https)').option('--cafile <path>', 'Internal certificate authority').option('-C, --cwd <dir>', 'Current Working Directory').option('-s, --secret-key <secretKey>', 'Secret key').option('-m, --source-maps <id>', 'Download source maps').option('-R, --randomization-seed <seed>', 'Set randomization seed').option('--code-hardening-threshold <threshold>', 'Set code hardening file size threshold. Format: {value}{unit="b,kb,mb"}. Example: 200kb', validateCodeHardeningThreshold).option('--recommended-order <bool>', 'Use recommended order', validateBool('recommended-order')).option('-W, --werror <bool>', 'Set werror flag value (default: true)', validateBool('werror')).option('--tolerate-minification <bool>', 'Don\'t detect minification as malicious tampering (default: true)', validateBool('tolerate-minification')).option('--use-profiling-data <bool>', 'Protection should use the existing profiling data (default: true)', validateBool('use-profiling-data')).option('--use-app-classification <bool>', 'Protection should use Application Classification metadata when protecting (default: true)', validateBool('--use-app-classification')).option('--jscramblerVersion <version>', 'Use a specific Jscrambler version').option('--debugMode', 'Protect in debug mode').parse(process.argv); | ||
var validateProfilingDataMode = function validateProfilingDataMode(mode) { | ||
var availableModes = ['automatic', 'annotations', 'off']; | ||
var normalizedMode = mode.toLowerCase(); | ||
if (!availableModes.includes(normalizedMode)) { | ||
console.error('*profiling-data-mode* requires one of the following modes: {' + availableModes.toString() + '}. Example: --profiling-data-mode ' + availableModes[0]); | ||
process.exit(1); | ||
} | ||
return normalizedMode; | ||
}; | ||
_commander2.default.version(require('../../package.json').version).usage('[options] <file ...>').option('-a, --access-key <accessKey>', 'Access key').option('-c, --config <config>', 'Jscrambler configuration options').option('-H, --host <host>', 'Hostname').option('-i, --application-id <id>', 'Application ID').option('-o, --output-dir <dir>', 'Output directory').option('-p, --port <port>', 'Port').option('--protocol <protocol>', 'Protocol (http or https)').option('--cafile <path>', 'Internal certificate authority').option('-C, --cwd <dir>', 'Current Working Directory').option('-s, --secret-key <secretKey>', 'Secret key').option('-m, --source-maps <id>', 'Download source maps').option('-R, --randomization-seed <seed>', 'Set randomization seed').option('--instrument', 'Instrument file(s) before start profiling. ATTENTION: previous profiling information will be deleted').option('--start-profiling', 'Starts profiling (assumes an already instrumented application)').option('--stop-profiling', 'Stops profiling').option('--code-hardening-threshold <threshold>', 'Set code hardening file size threshold. Format: {value}{unit="b,kb,mb"}. Example: 200kb', validateCodeHardeningThreshold).option('--recommended-order <bool>', 'Use recommended order', validateBool('recommended-order')).option('-W, --werror <bool>', 'Set werror flag value (default: true)', validateBool('werror')).option('--tolerate-minification <bool>', 'Don\'t detect minification as malicious tampering (default: true)', validateBool('tolerate-minification')).option('--use-profiling-data <bool>', '(version 6.2 only) Protection should use the existing profiling data (default: true)', validateBool('use-profiling-data')).option('--profiling-data-mode <mode>', '(version 6.3 and above) Select profiling mode (default: automatic)', validateProfilingDataMode).option('--use-app-classification <bool>', '(version 6.3 and above) Protection should use Application Classification metadata when protecting (default: true)', validateBool('--use-app-classification')).option('--jscramblerVersion <version>', 'Use a specific Jscrambler version').option('--debugMode', 'Protect in debug mode').parse(process.argv); | ||
var globSrc = void 0, | ||
@@ -92,2 +105,3 @@ filesSrc = void 0, | ||
config.debugMode = _commander2.default.debugMode || config.debugMode; | ||
// handle codeHardening = 0 | ||
@@ -100,5 +114,12 @@ if (typeof _commander2.default.codeHardeningThreshold === 'undefined') { | ||
if (_commander2.default.profilingDataMode) { | ||
config.profilingDataMode = _commander2.default.profilingDataMode; | ||
} else { | ||
config.profilingDataMode = config.profilingDataMode ? validateProfilingDataMode(config.profilingDataMode) : undefined; | ||
} | ||
if (_commander2.default.useProfilingData) { | ||
config.useProfilingData = _commander2.default.useProfilingData !== 'false'; | ||
} | ||
if (_commander2.default.useAppClassification) { | ||
@@ -115,2 +136,10 @@ config.useAppClassification = _commander2.default.useAppClassification !== 'false'; | ||
if (config.codeHardeningThreshold) { | ||
config.codeHardeningThreshold = validateCodeHardeningThreshold(config.codeHardeningThreshold); | ||
} | ||
if (config.profilingDataMode) { | ||
config.profilingDataMode = validateProfilingDataMode(config.profilingDataMode); | ||
} | ||
globSrc = config.filesSrc; | ||
@@ -188,2 +217,3 @@ // If src paths have been provided | ||
useProfilingData = _config2.useProfilingData, | ||
profilingDataMode = _config2.profilingDataMode, | ||
browsers = _config2.browsers, | ||
@@ -195,2 +225,49 @@ useAppClassification = _config2.useAppClassification; | ||
var incompatibleOptions = ['sourceMaps', 'instrument', 'startProfiling', 'stopProfiling']; | ||
var usedIncompatibleOptions = []; | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
try { | ||
for (var _iterator = incompatibleOptions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var incompatibleOption = _step.value; | ||
if (_commander2.default[incompatibleOption]) { | ||
usedIncompatibleOptions.push(incompatibleOption); | ||
} | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return) { | ||
_iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
if (usedIncompatibleOptions.length > 1) { | ||
console.error('Using mutually exclusive options:', usedIncompatibleOptions); | ||
process.exit(1); | ||
} | ||
var clientSettings = { | ||
keys: { | ||
accessKey: accessKey, | ||
secretKey: secretKey | ||
}, | ||
host: host, | ||
port: port, | ||
protocol: protocol, | ||
cafile: cafile, | ||
proxy: proxy, | ||
jscramblerVersion: jscramblerVersion | ||
}; | ||
if (_commander2.default.sourceMaps) { | ||
@@ -205,15 +282,7 @@ // Go, go, go download | ||
_context.next = 3; | ||
return _2.default.downloadSourceMaps({ | ||
keys: { | ||
accessKey: accessKey, | ||
secretKey: secretKey | ||
}, | ||
host: host, | ||
port: port, | ||
protocol: protocol, | ||
cafile: cafile, | ||
return _2.default.downloadSourceMaps(Object.assign({}, clientSettings, { | ||
filesDest: filesDest, | ||
filesSrc: filesSrc, | ||
protectionId: _commander2.default.sourceMaps | ||
}); | ||
})); | ||
@@ -228,3 +297,3 @@ case 3: | ||
console.error(_context.t0); | ||
console.error(debug ? _context.t0 : _context.t0.message || _context.t0); | ||
process.exit(1); | ||
@@ -239,2 +308,26 @@ | ||
}))(); | ||
} else if (_commander2.default.instrument) { | ||
_2.default.instrumentAndDownload(Object.assign({}, clientSettings, { | ||
applicationId: applicationId, | ||
filesSrc: filesSrc, | ||
filesDest: filesDest, | ||
cwd: cwd | ||
})).catch(function (error) { | ||
console.error(debug ? error : error.message || error); | ||
process.exit(1); | ||
}); | ||
} else if (_commander2.default.startProfiling) { | ||
_2.default.setProfilingState(Object.assign({}, clientSettings, { | ||
applicationId: applicationId | ||
}), 'RUNNING', 'STARTED').catch(function (error) { | ||
console.error(debug ? error : error.message || error); | ||
process.exit(1); | ||
}); | ||
} else if (_commander2.default.stopProfiling) { | ||
_2.default.setProfilingState(Object.assign({}, clientSettings, { | ||
applicationId: applicationId | ||
}), 'READY', 'STOPPED').catch(function (error) { | ||
console.error(debug ? error : error.message || error); | ||
process.exit(1); | ||
}); | ||
} else { | ||
@@ -248,11 +341,3 @@ // Go, go, go | ||
case 0: | ||
protectAndDownloadOptions = { | ||
keys: { | ||
accessKey: accessKey, | ||
secretKey: secretKey | ||
}, | ||
host: host, | ||
port: port, | ||
protocol: protocol, | ||
cafile: cafile, | ||
protectAndDownloadOptions = Object.assign({}, clientSettings, { | ||
applicationId: applicationId, | ||
@@ -270,10 +355,9 @@ filesSrc: filesSrc, | ||
tolerateMinification: tolerateMinification, | ||
jscramblerVersion: jscramblerVersion, | ||
debugMode: debugMode, | ||
proxy: proxy, | ||
codeHardeningThreshold: codeHardeningThreshold, | ||
useProfilingData: useProfilingData, | ||
profilingDataMode: profilingDataMode, | ||
browsers: browsers, | ||
useAppClassification: useAppClassification | ||
}; | ||
}); | ||
_context2.prev = 1; | ||
@@ -280,0 +364,0 @@ |
@@ -37,4 +37,25 @@ 'use strict'; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var debug = !!process.env.DEBUG; | ||
var ClientError = function (_Error) { | ||
_inherits(ClientError, _Error); | ||
function ClientError(message, statusCode) { | ||
_classCallCheck(this, ClientError); | ||
var _this = _possibleConstructorReturn(this, (ClientError.__proto__ || Object.getPrototypeOf(ClientError)).call(this, message)); | ||
_this.statusCode = statusCode; | ||
return _this; | ||
} | ||
return ClientError; | ||
}(Error); | ||
/** | ||
@@ -202,2 +223,3 @@ * @class JScramblerClient | ||
var errorMessage = 'Unexpected Response: '; | ||
var statusCode = 500; | ||
@@ -210,2 +232,3 @@ if (err.response) { | ||
errorMessage += err.response.status + ' ' + err.response.statusText; | ||
statusCode = err.response.status; | ||
@@ -215,2 +238,4 @@ // For when we have API error messages | ||
errorMessage += ' - ' + err.response.data.message; | ||
} else if (err.response.data && err.response.data.errors && err.response.data.errors.length > 0) { | ||
errorMessage += ' - ' + err.response.data.errors; | ||
} | ||
@@ -221,3 +246,3 @@ } else { | ||
throw new Error(errorMessage); | ||
throw new ClientError(errorMessage, statusCode); | ||
}); | ||
@@ -234,2 +259,10 @@ }; | ||
}; | ||
/** | ||
* Patch request. | ||
* @param {string} path | ||
* @param {object} params | ||
*/ | ||
JScramblerClient.prototype.patch = function (path, params) { | ||
return this.request('PATCH', path, params); | ||
}; | ||
@@ -236,0 +269,0 @@ var _token = void 0; |
1305
dist/index.js
@@ -68,2 +68,3 @@ 'use strict'; | ||
var debug = !!process.env.DEBUG; | ||
var APP_URL = 'https://app.jscrambler.com'; | ||
@@ -115,2 +116,8 @@ function errorHandler(res) { | ||
function buildFinalConfig(configPathOrObject) { | ||
var _config = typeof configPathOrObject === 'string' ? require(configPathOrObject) : configPathOrObject; | ||
return (0, _lodash2.default)(_config, _config3.default); | ||
} | ||
exports.default = { | ||
@@ -120,2 +127,136 @@ Client: _client2.default, | ||
generateSignedParams: _generateSignedParams2.default, | ||
/** | ||
* Remove and Add application sources | ||
* @param {object} client | ||
* @param {string} applicationId | ||
* @param {{ | ||
* sources: Array.<{filename: string, content: string}>, | ||
* filesSrc: Array.<string>, | ||
* cwd: string | ||
* }} opts | ||
* @returns {Promise<{extension: string, filename: string, content: *}>} | ||
*/ | ||
updateApplicationSources: function () { | ||
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(client, applicationId, _ref) { | ||
var sources = _ref.sources, | ||
filesSrc = _ref.filesSrc, | ||
cwd = _ref.cwd; | ||
var removeSourceRes, zipped, source, _filesSrc, i, l, content; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
if (!(sources || filesSrc && filesSrc.length)) { | ||
_context.next = 5; | ||
break; | ||
} | ||
_context.next = 3; | ||
return this.removeSourceFromApplication(client, '', applicationId); | ||
case 3: | ||
removeSourceRes = _context.sent; | ||
errorHandler(removeSourceRes); | ||
case 5: | ||
zipped = void 0; | ||
source = void 0; | ||
if (!(filesSrc && filesSrc.length)) { | ||
_context.next = 16; | ||
break; | ||
} | ||
_filesSrc = []; | ||
for (i = 0, l = filesSrc.length; i < l; i += 1) { | ||
if (typeof filesSrc[i] === 'string') { | ||
// TODO Replace `glob.sync` with async version | ||
_filesSrc = _filesSrc.concat(_glob2.default.sync(filesSrc[i], { | ||
dot: true | ||
})); | ||
} else { | ||
_filesSrc.push(filesSrc[i]); | ||
} | ||
} | ||
if (debug) { | ||
console.log('Creating zip from source files'); | ||
} | ||
_context.next = 13; | ||
return (0, _zip.zip)(_filesSrc, cwd); | ||
case 13: | ||
zipped = _context.sent; | ||
_context.next = 21; | ||
break; | ||
case 16: | ||
if (!sources) { | ||
_context.next = 21; | ||
break; | ||
} | ||
if (debug) { | ||
console.log('Creating zip from sources'); | ||
} | ||
_context.next = 20; | ||
return (0, _zip.zipSources)(sources); | ||
case 20: | ||
zipped = _context.sent; | ||
case 21: | ||
if (!zipped) { | ||
_context.next = 30; | ||
break; | ||
} | ||
content = zipped.generate({ | ||
type: 'nodebuffer' | ||
}).toString('base64'); | ||
if (debug) { | ||
console.log('Adding sources to application'); | ||
} | ||
source = { | ||
content: content, | ||
filename: 'application.zip', | ||
extension: 'zip' | ||
}; | ||
_context.t0 = errorHandler; | ||
_context.next = 28; | ||
return this.addApplicationSource(client, applicationId, source); | ||
case 28: | ||
_context.t1 = _context.sent; | ||
(0, _context.t0)(_context.t1); | ||
case 30: | ||
return _context.abrupt('return', source); | ||
case 31: | ||
case 'end': | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee, this); | ||
})); | ||
function updateApplicationSources(_x, _x2, _x3) { | ||
return _ref2.apply(this, arguments); | ||
} | ||
return updateApplicationSources; | ||
}(), | ||
// This method is a shortcut method that accepts an object with everything needed | ||
@@ -164,12 +305,11 @@ // for the entire process of requesting an application protection and downloading | ||
protectAndDownload: function () { | ||
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(configPathOrObject, destCallback) { | ||
var _config, finalConfig, applicationId, host, port, protocol, cafile, keys, sources, _finalConfig$stream, stream, cwd, params, applicationTypes, languageSpecifications, sourceMaps, randomizationSeed, areSubscribersOrdered, useRecommendedOrder, _finalConfig$bail, bail, jscramblerVersion, debugMode, proxy, clientId, tolerateMinification, codeHardeningThreshold, useProfilingData, browsers, useAppClassification, accessKey, secretKey, client, filesSrc, filesDest, source, removeSourceRes, zipped, _filesSrc, i, l, content, updateData, applicationUpdate, updateApplicationRes, createApplicationProtectionRes, protectionId, protection, url, sourcesErrors, _url, download; | ||
var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(configPathOrObject, destCallback) { | ||
var finalConfig, applicationId, host, port, protocol, cafile, keys, sources, _finalConfig$stream, stream, cwd, params, applicationTypes, languageSpecifications, sourceMaps, randomizationSeed, areSubscribersOrdered, useRecommendedOrder, _finalConfig$bail, bail, jscramblerVersion, debugMode, proxy, clientId, tolerateMinification, codeHardeningThreshold, useProfilingData, browsers, useAppClassification, profilingDataMode, accessKey, secretKey, client, filesSrc, filesDest, source, updateData, applicationUpdate, updateApplicationRes, createApplicationProtectionRes, protectionId, protection, sourcesErrors, download; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
return regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
_config = typeof configPathOrObject === 'string' ? require(configPathOrObject) : configPathOrObject; | ||
finalConfig = (0, _lodash2.default)(_config, _config3.default); | ||
applicationId = finalConfig.applicationId, host = finalConfig.host, port = finalConfig.port, protocol = finalConfig.protocol, cafile = finalConfig.cafile, keys = finalConfig.keys, sources = finalConfig.sources, _finalConfig$stream = finalConfig.stream, stream = _finalConfig$stream === undefined ? true : _finalConfig$stream, cwd = finalConfig.cwd, params = finalConfig.params, applicationTypes = finalConfig.applicationTypes, languageSpecifications = finalConfig.languageSpecifications, sourceMaps = finalConfig.sourceMaps, randomizationSeed = finalConfig.randomizationSeed, areSubscribersOrdered = finalConfig.areSubscribersOrdered, useRecommendedOrder = finalConfig.useRecommendedOrder, _finalConfig$bail = finalConfig.bail, bail = _finalConfig$bail === undefined ? true : _finalConfig$bail, jscramblerVersion = finalConfig.jscramblerVersion, debugMode = finalConfig.debugMode, proxy = finalConfig.proxy, clientId = finalConfig.clientId, tolerateMinification = finalConfig.tolerateMinification, codeHardeningThreshold = finalConfig.codeHardeningThreshold, useProfilingData = finalConfig.useProfilingData, browsers = finalConfig.browsers, useAppClassification = finalConfig.useAppClassification; | ||
finalConfig = buildFinalConfig(configPathOrObject); | ||
applicationId = finalConfig.applicationId, host = finalConfig.host, port = finalConfig.port, protocol = finalConfig.protocol, cafile = finalConfig.cafile, keys = finalConfig.keys, sources = finalConfig.sources, _finalConfig$stream = finalConfig.stream, stream = _finalConfig$stream === undefined ? true : _finalConfig$stream, cwd = finalConfig.cwd, params = finalConfig.params, applicationTypes = finalConfig.applicationTypes, languageSpecifications = finalConfig.languageSpecifications, sourceMaps = finalConfig.sourceMaps, randomizationSeed = finalConfig.randomizationSeed, areSubscribersOrdered = finalConfig.areSubscribersOrdered, useRecommendedOrder = finalConfig.useRecommendedOrder, _finalConfig$bail = finalConfig.bail, bail = _finalConfig$bail === undefined ? true : _finalConfig$bail, jscramblerVersion = finalConfig.jscramblerVersion, debugMode = finalConfig.debugMode, proxy = finalConfig.proxy, clientId = finalConfig.clientId, tolerateMinification = finalConfig.tolerateMinification, codeHardeningThreshold = finalConfig.codeHardeningThreshold, useProfilingData = finalConfig.useProfilingData, browsers = finalConfig.browsers, useAppClassification = finalConfig.useAppClassification, profilingDataMode = finalConfig.profilingDataMode; | ||
accessKey = keys.accessKey, secretKey = keys.secretKey; | ||
@@ -189,3 +329,2 @@ client = new this.Client({ | ||
filesDest = finalConfig.filesDest; | ||
source = void 0; | ||
@@ -202,3 +341,3 @@ | ||
if (applicationId) { | ||
_context.next = 12; | ||
_context2.next = 10; | ||
break; | ||
@@ -209,5 +348,5 @@ } | ||
case 12: | ||
case 10: | ||
if (!(!filesDest && !destCallback)) { | ||
_context.next = 14; | ||
_context2.next = 12; | ||
break; | ||
@@ -218,96 +357,12 @@ } | ||
case 12: | ||
_context2.next = 14; | ||
return this.updateApplicationSources(client, applicationId, { | ||
sources: sources, | ||
filesSrc: filesSrc, | ||
cwd: cwd | ||
}); | ||
case 14: | ||
if (!(sources || filesSrc && filesSrc.length)) { | ||
_context.next = 19; | ||
break; | ||
} | ||
_context.next = 17; | ||
return this.removeSourceFromApplication(client, '', applicationId); | ||
case 17: | ||
removeSourceRes = _context.sent; | ||
errorHandler(removeSourceRes); | ||
case 19: | ||
zipped = void 0; | ||
if (!(filesSrc && filesSrc.length)) { | ||
_context.next = 29; | ||
break; | ||
} | ||
_filesSrc = []; | ||
for (i = 0, l = filesSrc.length; i < l; i += 1) { | ||
if (typeof filesSrc[i] === 'string') { | ||
// TODO Replace `glob.sync` with async version | ||
_filesSrc = _filesSrc.concat(_glob2.default.sync(filesSrc[i], { | ||
dot: true | ||
})); | ||
} else { | ||
_filesSrc.push(filesSrc[i]); | ||
} | ||
} | ||
if (debug) { | ||
console.log('Creating zip from source files'); | ||
} | ||
_context.next = 26; | ||
return (0, _zip.zip)(_filesSrc, cwd); | ||
case 26: | ||
zipped = _context.sent; | ||
_context.next = 34; | ||
break; | ||
case 29: | ||
if (!sources) { | ||
_context.next = 34; | ||
break; | ||
} | ||
if (debug) { | ||
console.log('Creating zip from sources'); | ||
} | ||
_context.next = 33; | ||
return (0, _zip.zipSources)(sources); | ||
case 33: | ||
zipped = _context.sent; | ||
case 34: | ||
if (!zipped) { | ||
_context.next = 43; | ||
break; | ||
} | ||
content = zipped.generate({ | ||
type: 'nodebuffer' | ||
}).toString('base64'); | ||
if (debug) { | ||
console.log('Adding sources to application'); | ||
} | ||
source = { | ||
content: content, | ||
filename: 'application.zip', | ||
extension: 'zip' | ||
}; | ||
_context.t0 = errorHandler; | ||
_context.next = 41; | ||
return this.addApplicationSource(client, applicationId, source); | ||
case 41: | ||
_context.t1 = _context.sent; | ||
(0, _context.t0)(_context.t1); | ||
case 43: | ||
source = _context2.sent; | ||
updateData = { | ||
@@ -349,2 +404,5 @@ _id: applicationId, | ||
} | ||
if (profilingDataMode !== undefined) { | ||
updateData.profilingDataMode = profilingDataMode; | ||
} | ||
if (useAppClassification !== undefined) { | ||
@@ -359,3 +417,3 @@ updateData.useAppClassification = useAppClassification; | ||
if (!(updateData.parameters || updateData.applicationTypes || updateData.languageSpecifications || updateData.browsers || typeof updateData.areSubscribersOrdered !== 'undefined')) { | ||
_context.next = 63; | ||
_context2.next = 36; | ||
break; | ||
@@ -368,12 +426,12 @@ } | ||
_context.next = 57; | ||
_context2.next = 30; | ||
return intoObjectType(client, updateData, 'Application'); | ||
case 57: | ||
applicationUpdate = _context.sent; | ||
_context.next = 60; | ||
case 30: | ||
applicationUpdate = _context2.sent; | ||
_context2.next = 33; | ||
return this.updateApplication(client, applicationUpdate); | ||
case 60: | ||
updateApplicationRes = _context.sent; | ||
case 33: | ||
updateApplicationRes = _context2.sent; | ||
@@ -386,3 +444,3 @@ if (debug) { | ||
case 63: | ||
case 36: | ||
@@ -394,7 +452,7 @@ if (debug) { | ||
delete updateData._id; | ||
_context.next = 67; | ||
_context2.next = 40; | ||
return this.createApplicationProtection(client, applicationId, Object.assign({ bail: bail, randomizationSeed: randomizationSeed, tolerateMinification: tolerateMinification, source: source }, updateData)); | ||
case 67: | ||
createApplicationProtectionRes = _context.sent; | ||
case 40: | ||
createApplicationProtectionRes = _context2.sent; | ||
@@ -404,21 +462,19 @@ errorHandler(createApplicationProtectionRes); | ||
protectionId = createApplicationProtectionRes.data.createApplicationProtection._id; | ||
_context.t2 = this; | ||
_context.t3 = client; | ||
_context.t4 = applicationId; | ||
_context.t5 = protectionId; | ||
_context.next = 76; | ||
_context2.t0 = this; | ||
_context2.t1 = client; | ||
_context2.t2 = applicationId; | ||
_context2.t3 = protectionId; | ||
_context2.next = 49; | ||
return (0, _getProtectionDefaultFragments2.default)(client); | ||
case 76: | ||
_context.t6 = _context.sent; | ||
_context.next = 79; | ||
return _context.t2.pollProtection.call(_context.t2, _context.t3, _context.t4, _context.t5, _context.t6); | ||
case 49: | ||
_context2.t4 = _context2.sent; | ||
_context2.next = 52; | ||
return _context2.t0.pollProtection.call(_context2.t0, _context2.t1, _context2.t2, _context2.t3, _context2.t4); | ||
case 79: | ||
protection = _context.sent; | ||
case 52: | ||
protection = _context2.sent; | ||
if (protection.growthWarning) { | ||
url = 'https://app.jscrambler.com'; | ||
console.warn('Warning: Your protected application has surpassed a reasonable file growth.\nFor more information on what might have caused this, please see the Protection Report.\nLink: ' + url + '.'); | ||
console.warn('Warning: Your protected application has surpassed a reasonable file growth.\nFor more information on what might have caused this, please see the Protection Report.\nLink: ' + APP_URL + '.'); | ||
} | ||
@@ -453,3 +509,3 @@ if (debug) { | ||
if (!(protection.state === 'errored')) { | ||
_context.next = 94; | ||
_context2.next = 66; | ||
break; | ||
@@ -464,8 +520,7 @@ } | ||
} | ||
_url = 'https://app.jscrambler.com'; | ||
throw new Error('Protection failed. For more information visit: ' + _url + '.'); | ||
throw new Error('Protection failed. For more information visit: ' + APP_URL + '.'); | ||
case 94: | ||
case 66: | ||
if (!(sourcesErrors.length > 0)) { | ||
_context.next = 101; | ||
_context2.next = 73; | ||
break; | ||
@@ -475,3 +530,3 @@ } | ||
if (!protection.bail) { | ||
_context.next = 100; | ||
_context2.next = 72; | ||
break; | ||
@@ -483,3 +538,3 @@ } | ||
case 100: | ||
case 72: | ||
sourcesErrors.forEach(function (e) { | ||
@@ -489,3 +544,3 @@ return console.warn('Non-fatal error: "' + e.message + '" in ' + e.filename); | ||
case 101: | ||
case 73: | ||
@@ -495,7 +550,7 @@ if (debug) { | ||
} | ||
_context.next = 104; | ||
_context2.next = 76; | ||
return this.downloadApplicationProtection(client, protectionId); | ||
case 104: | ||
download = _context.sent; | ||
case 76: | ||
download = _context2.sent; | ||
@@ -517,14 +572,14 @@ | ||
return _context.abrupt('return', protectionId); | ||
return _context2.abrupt('return', protectionId); | ||
case 111: | ||
case 83: | ||
case 'end': | ||
return _context.stop(); | ||
return _context2.stop(); | ||
} | ||
} | ||
}, _callee, this); | ||
}, _callee2, this); | ||
})); | ||
function protectAndDownload(_x, _x2) { | ||
return _ref.apply(this, arguments); | ||
function protectAndDownload(_x4, _x5) { | ||
return _ref3.apply(this, arguments); | ||
} | ||
@@ -534,9 +589,209 @@ | ||
}(), | ||
/** | ||
* Instrument and download application sources for profiling purposes | ||
* @param {object} configPathOrObject | ||
* @param {function} [destCallback] | ||
* @returns {Promise<string>} | ||
*/ | ||
instrumentAndDownload: function () { | ||
var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(configPathOrObject, destCallback) { | ||
var finalConfig, applicationId, host, port, protocol, cafile, keys, sources, _finalConfig$stream2, stream, cwd, jscramblerVersion, proxy, clientId, accessKey, secretKey, client, filesSrc, filesDest, instrumentation, download; | ||
return regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
finalConfig = buildFinalConfig(configPathOrObject); | ||
applicationId = finalConfig.applicationId, host = finalConfig.host, port = finalConfig.port, protocol = finalConfig.protocol, cafile = finalConfig.cafile, keys = finalConfig.keys, sources = finalConfig.sources, _finalConfig$stream2 = finalConfig.stream, stream = _finalConfig$stream2 === undefined ? true : _finalConfig$stream2, cwd = finalConfig.cwd, jscramblerVersion = finalConfig.jscramblerVersion, proxy = finalConfig.proxy, clientId = finalConfig.clientId; | ||
accessKey = keys.accessKey, secretKey = keys.secretKey; | ||
client = new this.Client({ | ||
accessKey: accessKey, | ||
secretKey: secretKey, | ||
host: host, | ||
port: port, | ||
protocol: protocol, | ||
cafile: cafile, | ||
jscramblerVersion: jscramblerVersion, | ||
proxy: proxy, | ||
clientId: clientId | ||
}); | ||
filesSrc = finalConfig.filesSrc, filesDest = finalConfig.filesDest; | ||
if (sources) { | ||
filesSrc = undefined; | ||
} | ||
if (destCallback) { | ||
filesDest = undefined; | ||
} | ||
if (applicationId) { | ||
_context3.next = 9; | ||
break; | ||
} | ||
throw new Error('Required *applicationId* not provided'); | ||
case 9: | ||
if (!(!filesDest && !destCallback)) { | ||
_context3.next = 11; | ||
break; | ||
} | ||
throw new Error('Required *filesDest* not provided'); | ||
case 11: | ||
_context3.next = 13; | ||
return this.updateApplicationSources(client, applicationId, { | ||
sources: sources, | ||
filesSrc: filesSrc, | ||
cwd: cwd | ||
}); | ||
case 13: | ||
_context3.next = 15; | ||
return this.startInstrumentation(client, applicationId); | ||
case 15: | ||
instrumentation = _context3.sent; | ||
errorHandler(instrumentation); | ||
_context3.next = 19; | ||
return this.pollInstrumentation(client, instrumentation.data.id); | ||
case 19: | ||
instrumentation = _context3.sent; | ||
if (debug) { | ||
console.log('Finished instrumention with id ' + instrumentation.data.id + '. Downloading...'); | ||
} | ||
_context3.next = 23; | ||
return this.downloadApplicationInstrumented(client, instrumentation.data.id); | ||
case 23: | ||
download = _context3.sent; | ||
errorHandler(download); | ||
if (debug) { | ||
console.log('Unzipping files'); | ||
} | ||
(0, _zip.unzip)(download, filesDest || destCallback, stream); | ||
if (debug) { | ||
console.log('Finished unzipping files'); | ||
} | ||
console.warn('\n WARNING: DO NOT SEND THIS CODE TO PRODUCTION AS IT IS NOT PROTECTED\n '); | ||
console.log('Application ' + applicationId + ' was instrumented. Bootstrap your application, go to ' + APP_URL + ' and start profiling!'); | ||
return _context3.abrupt('return', instrumentation.data.id); | ||
case 31: | ||
case 'end': | ||
return _context3.stop(); | ||
} | ||
} | ||
}, _callee3, this); | ||
})); | ||
function instrumentAndDownload(_x6, _x7) { | ||
return _ref4.apply(this, arguments); | ||
} | ||
return instrumentAndDownload; | ||
}(), | ||
/** | ||
* Change the profiling run stat. | ||
* @param configPathOrObject | ||
* @param state | ||
* @param label | ||
* @returns {Promise<string>} The previous state | ||
*/ | ||
setProfilingState: function () { | ||
var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(configPathOrObject, state, label) { | ||
var finalConfig, keys, host, port, protocol, cafile, applicationId, proxy, jscramblerVersion, clientId, accessKey, secretKey, client, instrumentation, previousState; | ||
return regeneratorRuntime.wrap(function _callee4$(_context4) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
case 0: | ||
finalConfig = buildFinalConfig(configPathOrObject); | ||
keys = finalConfig.keys, host = finalConfig.host, port = finalConfig.port, protocol = finalConfig.protocol, cafile = finalConfig.cafile, applicationId = finalConfig.applicationId, proxy = finalConfig.proxy, jscramblerVersion = finalConfig.jscramblerVersion, clientId = finalConfig.clientId; | ||
accessKey = keys.accessKey, secretKey = keys.secretKey; | ||
client = new this.Client({ | ||
accessKey: accessKey, | ||
secretKey: secretKey, | ||
host: host, | ||
port: port, | ||
protocol: protocol, | ||
cafile: cafile, | ||
proxy: proxy, | ||
jscramblerVersion: jscramblerVersion, | ||
clientId: clientId | ||
}); | ||
_context4.next = 6; | ||
return client.get('/profiling-run', { applicationId: applicationId }).catch(function (e) { | ||
if (e.statusCode !== 404) throw e; | ||
}); | ||
case 6: | ||
instrumentation = _context4.sent; | ||
if (instrumentation) { | ||
_context4.next = 9; | ||
break; | ||
} | ||
throw new Error('There is no active profiling run. Instrument your application first.'); | ||
case 9: | ||
previousState = instrumentation.data.state; | ||
if (!(previousState === state)) { | ||
_context4.next = 13; | ||
break; | ||
} | ||
console.log('Profiling was already ' + label + ' for application ' + applicationId + '.'); | ||
return _context4.abrupt('return'); | ||
case 13: | ||
_context4.next = 15; | ||
return client.patch('/profiling-run/' + instrumentation.data.id, { | ||
state: state | ||
}); | ||
case 15: | ||
console.log('Profiling was ' + label + ' for application ' + applicationId + '.'); | ||
case 16: | ||
case 'end': | ||
return _context4.stop(); | ||
} | ||
} | ||
}, _callee4, this); | ||
})); | ||
function setProfilingState(_x8, _x9, _x10) { | ||
return _ref5.apply(this, arguments); | ||
} | ||
return setProfilingState; | ||
}(), | ||
downloadSourceMaps: function () { | ||
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(configs, destCallback) { | ||
var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(configs, destCallback) { | ||
var keys, host, port, protocol, cafile, _configs$stream, stream, filesDest, filesSrc, protectionId, proxy, accessKey, secretKey, client, download; | ||
return regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
return regeneratorRuntime.wrap(function _callee5$(_context5) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
switch (_context5.prev = _context5.next) { | ||
case 0: | ||
@@ -556,3 +811,3 @@ keys = configs.keys, host = configs.host, port = configs.port, protocol = configs.protocol, cafile = configs.cafile, _configs$stream = configs.stream, stream = _configs$stream === undefined ? true : _configs$stream, filesDest = configs.filesDest, filesSrc = configs.filesSrc, protectionId = configs.protectionId, proxy = configs.proxy; | ||
if (!(!filesDest && !destCallback)) { | ||
_context2.next = 5; | ||
_context5.next = 5; | ||
break; | ||
@@ -565,3 +820,3 @@ } | ||
if (protectionId) { | ||
_context2.next = 7; | ||
_context5.next = 7; | ||
break; | ||
@@ -578,16 +833,16 @@ } | ||
download = void 0; | ||
_context2.prev = 9; | ||
_context2.next = 12; | ||
_context5.prev = 9; | ||
_context5.next = 12; | ||
return this.downloadSourceMapsRequest(client, protectionId); | ||
case 12: | ||
download = _context2.sent; | ||
_context2.next = 18; | ||
download = _context5.sent; | ||
_context5.next = 18; | ||
break; | ||
case 15: | ||
_context2.prev = 15; | ||
_context2.t0 = _context2['catch'](9); | ||
_context5.prev = 15; | ||
_context5.t0 = _context5['catch'](9); | ||
errorHandler(_context2.t0); | ||
errorHandler(_context5.t0); | ||
@@ -599,10 +854,10 @@ case 18: | ||
case 'end': | ||
return _context2.stop(); | ||
return _context5.stop(); | ||
} | ||
} | ||
}, _callee2, this, [[9, 15]]); | ||
}, _callee5, this, [[9, 15]]); | ||
})); | ||
function downloadSourceMaps(_x3, _x4) { | ||
return _ref2.apply(this, arguments); | ||
function downloadSourceMaps(_x11, _x12) { | ||
return _ref6.apply(this, arguments); | ||
} | ||
@@ -612,27 +867,112 @@ | ||
}(), | ||
pollProtection: function () { | ||
var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(client, applicationId, protectionId, fragments) { | ||
/** | ||
* Polls a instrumentation every 500ms until the state be equal to | ||
* FINISHED_INSTRUMENTATION, FAILED_INSTRUMENTATION or DELETED | ||
* @param {object} client | ||
* @param {string} instrumentationId | ||
* @returns {Promise<object>} | ||
* @throws {Error} due to errors in instrumentation process or user cancel the operation | ||
*/ | ||
pollInstrumentation: function () { | ||
var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(client, instrumentationId) { | ||
var _this = this; | ||
var poll; | ||
return regeneratorRuntime.wrap(function _callee4$(_context4) { | ||
return regeneratorRuntime.wrap(function _callee7$(_context7) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
switch (_context7.prev = _context7.next) { | ||
case 0: | ||
poll = function () { | ||
var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() { | ||
var applicationProtection, url, state; | ||
return regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
var _ref8 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() { | ||
var instrumentation; | ||
return regeneratorRuntime.wrap(function _callee6$(_context6) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
switch (_context6.prev = _context6.next) { | ||
case 0: | ||
_context3.next = 2; | ||
return _this.getApplicationProtection(client, applicationId, protectionId, fragments); | ||
_context6.next = 2; | ||
return _this.getInstrumentation(client, instrumentationId); | ||
case 2: | ||
applicationProtection = _context3.sent; | ||
url = 'https://app.jscrambler.com'; | ||
instrumentation = _context6.sent; | ||
_context6.t0 = instrumentation.data.state; | ||
_context6.next = _context6.t0 === 'DELETED' ? 6 : _context6.t0 === 'FAILED_INSTRUMENTATION' ? 7 : _context6.t0 === 'FINISHED_INSTRUMENTATION' ? 9 : 10; | ||
break; | ||
case 6: | ||
throw new Error('Protection canceled by user'); | ||
case 7: | ||
instrumentation.errors = instrumentation.errors.concat(instrumentation.data.instrumentationErrors.map(function (e) { | ||
return { | ||
message: e.message + ' at ' + e.fileName + ':' + e.lineNumber | ||
}; | ||
})); | ||
return _context6.abrupt('return', errorHandler(instrumentation)); | ||
case 9: | ||
return _context6.abrupt('return', instrumentation); | ||
case 10: | ||
_context6.next = 12; | ||
return new Promise(function (resolve) { | ||
return setTimeout(resolve, 500); | ||
}); | ||
case 12: | ||
return _context6.abrupt('return', poll()); | ||
case 13: | ||
case 'end': | ||
return _context6.stop(); | ||
} | ||
} | ||
}, _callee6, _this); | ||
})); | ||
return function poll() { | ||
return _ref8.apply(this, arguments); | ||
}; | ||
}(); | ||
return _context7.abrupt('return', poll()); | ||
case 2: | ||
case 'end': | ||
return _context7.stop(); | ||
} | ||
} | ||
}, _callee7, this); | ||
})); | ||
function pollInstrumentation(_x13, _x14) { | ||
return _ref7.apply(this, arguments); | ||
} | ||
return pollInstrumentation; | ||
}(), | ||
pollProtection: function () { | ||
var _ref9 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9(client, applicationId, protectionId, fragments) { | ||
var _this2 = this; | ||
var poll; | ||
return regeneratorRuntime.wrap(function _callee9$(_context9) { | ||
while (1) { | ||
switch (_context9.prev = _context9.next) { | ||
case 0: | ||
poll = function () { | ||
var _ref10 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8() { | ||
var applicationProtection, state; | ||
return regeneratorRuntime.wrap(function _callee8$(_context8) { | ||
while (1) { | ||
switch (_context8.prev = _context8.next) { | ||
case 0: | ||
_context8.next = 2; | ||
return _this2.getApplicationProtection(client, applicationId, protectionId, fragments); | ||
case 2: | ||
applicationProtection = _context8.sent; | ||
if (!applicationProtection.errors) { | ||
_context3.next = 9; | ||
_context8.next = 8; | ||
break; | ||
@@ -643,13 +983,13 @@ } | ||
throw new Error('Protection failed. For more information visit: ' + url + '.'); | ||
throw new Error('Protection failed. For more information visit: ' + APP_URL + '.'); | ||
case 9: | ||
case 8: | ||
state = applicationProtection.data.applicationProtection.state; | ||
if (!(state !== 'finished' && state !== 'errored' && state !== 'canceled')) { | ||
_context3.next = 16; | ||
_context8.next = 15; | ||
break; | ||
} | ||
_context3.next = 13; | ||
_context8.next = 12; | ||
return new Promise(function (resolve) { | ||
@@ -659,8 +999,8 @@ return setTimeout(resolve, 500); | ||
case 13: | ||
return _context3.abrupt('return', poll()); | ||
case 12: | ||
return _context8.abrupt('return', poll()); | ||
case 16: | ||
case 15: | ||
if (!(state === 'canceled')) { | ||
_context3.next = 20; | ||
_context8.next = 19; | ||
break; | ||
@@ -671,30 +1011,30 @@ } | ||
case 19: | ||
return _context8.abrupt('return', applicationProtection.data.applicationProtection); | ||
case 20: | ||
return _context3.abrupt('return', applicationProtection.data.applicationProtection); | ||
case 21: | ||
case 'end': | ||
return _context3.stop(); | ||
return _context8.stop(); | ||
} | ||
} | ||
}, _callee3, _this); | ||
}, _callee8, _this2); | ||
})); | ||
return function poll() { | ||
return _ref4.apply(this, arguments); | ||
return _ref10.apply(this, arguments); | ||
}; | ||
}(); | ||
return _context4.abrupt('return', poll()); | ||
return _context9.abrupt('return', poll()); | ||
case 2: | ||
case 'end': | ||
return _context4.stop(); | ||
return _context9.stop(); | ||
} | ||
} | ||
}, _callee4, this); | ||
}, _callee9, this); | ||
})); | ||
function pollProtection(_x5, _x6, _x7, _x8) { | ||
return _ref3.apply(this, arguments); | ||
function pollProtection(_x15, _x16, _x17, _x18) { | ||
return _ref9.apply(this, arguments); | ||
} | ||
@@ -707,19 +1047,19 @@ | ||
createApplication: function () { | ||
var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(client, data, fragments) { | ||
return regeneratorRuntime.wrap(function _callee5$(_context5) { | ||
var _ref11 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee10(client, data, fragments) { | ||
return regeneratorRuntime.wrap(function _callee10$(_context10) { | ||
while (1) { | ||
switch (_context5.prev = _context5.next) { | ||
switch (_context10.prev = _context10.next) { | ||
case 0: | ||
return _context5.abrupt('return', client.post('/application', mutations.createApplication(data, fragments))); | ||
return _context10.abrupt('return', client.post('/application', mutations.createApplication(data, fragments))); | ||
case 1: | ||
case 'end': | ||
return _context5.stop(); | ||
return _context10.stop(); | ||
} | ||
} | ||
}, _callee5, this); | ||
}, _callee10, this); | ||
})); | ||
function createApplication(_x9, _x10, _x11) { | ||
return _ref5.apply(this, arguments); | ||
function createApplication(_x19, _x20, _x21) { | ||
return _ref11.apply(this, arguments); | ||
} | ||
@@ -732,19 +1072,19 @@ | ||
duplicateApplication: function () { | ||
var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(client, data, fragments) { | ||
return regeneratorRuntime.wrap(function _callee6$(_context6) { | ||
var _ref12 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee11(client, data, fragments) { | ||
return regeneratorRuntime.wrap(function _callee11$(_context11) { | ||
while (1) { | ||
switch (_context6.prev = _context6.next) { | ||
switch (_context11.prev = _context11.next) { | ||
case 0: | ||
return _context6.abrupt('return', client.post('/application', mutations.duplicateApplication(data, fragments))); | ||
return _context11.abrupt('return', client.post('/application', mutations.duplicateApplication(data, fragments))); | ||
case 1: | ||
case 'end': | ||
return _context6.stop(); | ||
return _context11.stop(); | ||
} | ||
} | ||
}, _callee6, this); | ||
}, _callee11, this); | ||
})); | ||
function duplicateApplication(_x12, _x13, _x14) { | ||
return _ref6.apply(this, arguments); | ||
function duplicateApplication(_x22, _x23, _x24) { | ||
return _ref12.apply(this, arguments); | ||
} | ||
@@ -757,19 +1097,19 @@ | ||
removeApplication: function () { | ||
var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(client, id) { | ||
return regeneratorRuntime.wrap(function _callee7$(_context7) { | ||
var _ref13 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12(client, id) { | ||
return regeneratorRuntime.wrap(function _callee12$(_context12) { | ||
while (1) { | ||
switch (_context7.prev = _context7.next) { | ||
switch (_context12.prev = _context12.next) { | ||
case 0: | ||
return _context7.abrupt('return', client.post('/application', mutations.removeApplication(id))); | ||
return _context12.abrupt('return', client.post('/application', mutations.removeApplication(id))); | ||
case 1: | ||
case 'end': | ||
return _context7.stop(); | ||
return _context12.stop(); | ||
} | ||
} | ||
}, _callee7, this); | ||
}, _callee12, this); | ||
})); | ||
function removeApplication(_x15, _x16) { | ||
return _ref7.apply(this, arguments); | ||
function removeApplication(_x25, _x26) { | ||
return _ref13.apply(this, arguments); | ||
} | ||
@@ -782,19 +1122,19 @@ | ||
removeProtection: function () { | ||
var _ref8 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8(client, id, appId, fragments) { | ||
return regeneratorRuntime.wrap(function _callee8$(_context8) { | ||
var _ref14 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee13(client, id, appId, fragments) { | ||
return regeneratorRuntime.wrap(function _callee13$(_context13) { | ||
while (1) { | ||
switch (_context8.prev = _context8.next) { | ||
switch (_context13.prev = _context13.next) { | ||
case 0: | ||
return _context8.abrupt('return', client.post('/application', mutations.removeProtection(id, appId, fragments))); | ||
return _context13.abrupt('return', client.post('/application', mutations.removeProtection(id, appId, fragments))); | ||
case 1: | ||
case 'end': | ||
return _context8.stop(); | ||
return _context13.stop(); | ||
} | ||
} | ||
}, _callee8, this); | ||
}, _callee13, this); | ||
})); | ||
function removeProtection(_x17, _x18, _x19, _x20) { | ||
return _ref8.apply(this, arguments); | ||
function removeProtection(_x27, _x28, _x29, _x30) { | ||
return _ref14.apply(this, arguments); | ||
} | ||
@@ -807,25 +1147,25 @@ | ||
cancelProtection: function () { | ||
var _ref9 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9(client, id, appId, fragments) { | ||
var _ref15 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee14(client, id, appId, fragments) { | ||
var mutation; | ||
return regeneratorRuntime.wrap(function _callee9$(_context9) { | ||
return regeneratorRuntime.wrap(function _callee14$(_context14) { | ||
while (1) { | ||
switch (_context9.prev = _context9.next) { | ||
switch (_context14.prev = _context14.next) { | ||
case 0: | ||
_context9.next = 2; | ||
_context14.next = 2; | ||
return mutations.cancelProtection(id, appId, fragments); | ||
case 2: | ||
mutation = _context9.sent; | ||
return _context9.abrupt('return', client.post('/application', mutation)); | ||
mutation = _context14.sent; | ||
return _context14.abrupt('return', client.post('/application', mutation)); | ||
case 4: | ||
case 'end': | ||
return _context9.stop(); | ||
return _context14.stop(); | ||
} | ||
} | ||
}, _callee9, this); | ||
}, _callee14, this); | ||
})); | ||
function cancelProtection(_x21, _x22, _x23, _x24) { | ||
return _ref9.apply(this, arguments); | ||
function cancelProtection(_x31, _x32, _x33, _x34) { | ||
return _ref15.apply(this, arguments); | ||
} | ||
@@ -838,25 +1178,25 @@ | ||
updateApplication: function () { | ||
var _ref10 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee10(client, application, fragments) { | ||
var _ref16 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee15(client, application, fragments) { | ||
var mutation; | ||
return regeneratorRuntime.wrap(function _callee10$(_context10) { | ||
return regeneratorRuntime.wrap(function _callee15$(_context15) { | ||
while (1) { | ||
switch (_context10.prev = _context10.next) { | ||
switch (_context15.prev = _context15.next) { | ||
case 0: | ||
_context10.next = 2; | ||
_context15.next = 2; | ||
return mutations.updateApplication(application, fragments); | ||
case 2: | ||
mutation = _context10.sent; | ||
return _context10.abrupt('return', client.post('/application', mutation)); | ||
mutation = _context15.sent; | ||
return _context15.abrupt('return', client.post('/application', mutation)); | ||
case 4: | ||
case 'end': | ||
return _context10.stop(); | ||
return _context15.stop(); | ||
} | ||
} | ||
}, _callee10, this); | ||
}, _callee15, this); | ||
})); | ||
function updateApplication(_x25, _x26, _x27) { | ||
return _ref10.apply(this, arguments); | ||
function updateApplication(_x35, _x36, _x37) { | ||
return _ref16.apply(this, arguments); | ||
} | ||
@@ -869,25 +1209,25 @@ | ||
unlockApplication: function () { | ||
var _ref11 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee11(client, application, fragments) { | ||
var _ref17 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee16(client, application, fragments) { | ||
var mutation; | ||
return regeneratorRuntime.wrap(function _callee11$(_context11) { | ||
return regeneratorRuntime.wrap(function _callee16$(_context16) { | ||
while (1) { | ||
switch (_context11.prev = _context11.next) { | ||
switch (_context16.prev = _context16.next) { | ||
case 0: | ||
_context11.next = 2; | ||
_context16.next = 2; | ||
return mutations.unlockApplication(application, fragments); | ||
case 2: | ||
mutation = _context11.sent; | ||
return _context11.abrupt('return', client.post('/application', mutation)); | ||
mutation = _context16.sent; | ||
return _context16.abrupt('return', client.post('/application', mutation)); | ||
case 4: | ||
case 'end': | ||
return _context11.stop(); | ||
return _context16.stop(); | ||
} | ||
} | ||
}, _callee11, this); | ||
}, _callee16, this); | ||
})); | ||
function unlockApplication(_x28, _x29, _x30) { | ||
return _ref11.apply(this, arguments); | ||
function unlockApplication(_x38, _x39, _x40) { | ||
return _ref17.apply(this, arguments); | ||
} | ||
@@ -900,25 +1240,25 @@ | ||
getApplication: function () { | ||
var _ref12 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12(client, applicationId, fragments, params) { | ||
var _ref18 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee17(client, applicationId, fragments, params) { | ||
var query; | ||
return regeneratorRuntime.wrap(function _callee12$(_context12) { | ||
return regeneratorRuntime.wrap(function _callee17$(_context17) { | ||
while (1) { | ||
switch (_context12.prev = _context12.next) { | ||
switch (_context17.prev = _context17.next) { | ||
case 0: | ||
_context12.next = 2; | ||
_context17.next = 2; | ||
return queries.getApplication(applicationId, fragments, params); | ||
case 2: | ||
query = _context12.sent; | ||
return _context12.abrupt('return', client.get('/application', query)); | ||
query = _context17.sent; | ||
return _context17.abrupt('return', client.get('/application', query)); | ||
case 4: | ||
case 'end': | ||
return _context12.stop(); | ||
return _context17.stop(); | ||
} | ||
} | ||
}, _callee12, this); | ||
}, _callee17, this); | ||
})); | ||
function getApplication(_x31, _x32, _x33, _x34) { | ||
return _ref12.apply(this, arguments); | ||
function getApplication(_x41, _x42, _x43, _x44) { | ||
return _ref18.apply(this, arguments); | ||
} | ||
@@ -931,25 +1271,25 @@ | ||
getApplicationSource: function () { | ||
var _ref13 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee13(client, sourceId, fragments, limits) { | ||
var _ref19 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee18(client, sourceId, fragments, limits) { | ||
var query; | ||
return regeneratorRuntime.wrap(function _callee13$(_context13) { | ||
return regeneratorRuntime.wrap(function _callee18$(_context18) { | ||
while (1) { | ||
switch (_context13.prev = _context13.next) { | ||
switch (_context18.prev = _context18.next) { | ||
case 0: | ||
_context13.next = 2; | ||
_context18.next = 2; | ||
return queries.getApplicationSource(sourceId, fragments, limits); | ||
case 2: | ||
query = _context13.sent; | ||
return _context13.abrupt('return', client.get('/application', query)); | ||
query = _context18.sent; | ||
return _context18.abrupt('return', client.get('/application', query)); | ||
case 4: | ||
case 'end': | ||
return _context13.stop(); | ||
return _context18.stop(); | ||
} | ||
} | ||
}, _callee13, this); | ||
}, _callee18, this); | ||
})); | ||
function getApplicationSource(_x35, _x36, _x37, _x38) { | ||
return _ref13.apply(this, arguments); | ||
function getApplicationSource(_x45, _x46, _x47, _x48) { | ||
return _ref19.apply(this, arguments); | ||
} | ||
@@ -962,25 +1302,25 @@ | ||
getApplicationProtections: function () { | ||
var _ref14 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee14(client, applicationId, params, fragments) { | ||
var _ref20 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee19(client, applicationId, params, fragments) { | ||
var query; | ||
return regeneratorRuntime.wrap(function _callee14$(_context14) { | ||
return regeneratorRuntime.wrap(function _callee19$(_context19) { | ||
while (1) { | ||
switch (_context14.prev = _context14.next) { | ||
switch (_context19.prev = _context19.next) { | ||
case 0: | ||
_context14.next = 2; | ||
_context19.next = 2; | ||
return queries.getApplicationProtections(applicationId, params, fragments); | ||
case 2: | ||
query = _context14.sent; | ||
return _context14.abrupt('return', client.get('/application', query)); | ||
query = _context19.sent; | ||
return _context19.abrupt('return', client.get('/application', query)); | ||
case 4: | ||
case 'end': | ||
return _context14.stop(); | ||
return _context19.stop(); | ||
} | ||
} | ||
}, _callee14, this); | ||
}, _callee19, this); | ||
})); | ||
function getApplicationProtections(_x39, _x40, _x41, _x42) { | ||
return _ref14.apply(this, arguments); | ||
function getApplicationProtections(_x49, _x50, _x51, _x52) { | ||
return _ref20.apply(this, arguments); | ||
} | ||
@@ -993,25 +1333,25 @@ | ||
getApplicationProtectionsCount: function () { | ||
var _ref15 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee15(client, applicationId, fragments) { | ||
var _ref21 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee20(client, applicationId, fragments) { | ||
var query; | ||
return regeneratorRuntime.wrap(function _callee15$(_context15) { | ||
return regeneratorRuntime.wrap(function _callee20$(_context20) { | ||
while (1) { | ||
switch (_context15.prev = _context15.next) { | ||
switch (_context20.prev = _context20.next) { | ||
case 0: | ||
_context15.next = 2; | ||
_context20.next = 2; | ||
return queries.getApplicationProtectionsCount(applicationId, fragments); | ||
case 2: | ||
query = _context15.sent; | ||
return _context15.abrupt('return', client.get('/application', query)); | ||
query = _context20.sent; | ||
return _context20.abrupt('return', client.get('/application', query)); | ||
case 4: | ||
case 'end': | ||
return _context15.stop(); | ||
return _context20.stop(); | ||
} | ||
} | ||
}, _callee15, this); | ||
}, _callee20, this); | ||
})); | ||
function getApplicationProtectionsCount(_x43, _x44, _x45) { | ||
return _ref15.apply(this, arguments); | ||
function getApplicationProtectionsCount(_x53, _x54, _x55) { | ||
return _ref21.apply(this, arguments); | ||
} | ||
@@ -1024,25 +1364,25 @@ | ||
createTemplate: function () { | ||
var _ref16 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee16(client, template, fragments) { | ||
var _ref22 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee21(client, template, fragments) { | ||
var mutation; | ||
return regeneratorRuntime.wrap(function _callee16$(_context16) { | ||
return regeneratorRuntime.wrap(function _callee21$(_context21) { | ||
while (1) { | ||
switch (_context16.prev = _context16.next) { | ||
switch (_context21.prev = _context21.next) { | ||
case 0: | ||
_context16.next = 2; | ||
_context21.next = 2; | ||
return mutations.createTemplate(template, fragments); | ||
case 2: | ||
mutation = _context16.sent; | ||
return _context16.abrupt('return', client.post('/application', mutation)); | ||
mutation = _context21.sent; | ||
return _context21.abrupt('return', client.post('/application', mutation)); | ||
case 4: | ||
case 'end': | ||
return _context16.stop(); | ||
return _context21.stop(); | ||
} | ||
} | ||
}, _callee16, this); | ||
}, _callee21, this); | ||
})); | ||
function createTemplate(_x46, _x47, _x48) { | ||
return _ref16.apply(this, arguments); | ||
function createTemplate(_x56, _x57, _x58) { | ||
return _ref22.apply(this, arguments); | ||
} | ||
@@ -1055,25 +1395,25 @@ | ||
removeTemplate: function () { | ||
var _ref17 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee17(client, id) { | ||
var _ref23 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee22(client, id) { | ||
var mutation; | ||
return regeneratorRuntime.wrap(function _callee17$(_context17) { | ||
return regeneratorRuntime.wrap(function _callee22$(_context22) { | ||
while (1) { | ||
switch (_context17.prev = _context17.next) { | ||
switch (_context22.prev = _context22.next) { | ||
case 0: | ||
_context17.next = 2; | ||
_context22.next = 2; | ||
return mutations.removeTemplate(id); | ||
case 2: | ||
mutation = _context17.sent; | ||
return _context17.abrupt('return', client.post('/application', mutation)); | ||
mutation = _context22.sent; | ||
return _context22.abrupt('return', client.post('/application', mutation)); | ||
case 4: | ||
case 'end': | ||
return _context17.stop(); | ||
return _context22.stop(); | ||
} | ||
} | ||
}, _callee17, this); | ||
}, _callee22, this); | ||
})); | ||
function removeTemplate(_x49, _x50) { | ||
return _ref17.apply(this, arguments); | ||
function removeTemplate(_x59, _x60) { | ||
return _ref23.apply(this, arguments); | ||
} | ||
@@ -1086,25 +1426,25 @@ | ||
getTemplates: function () { | ||
var _ref18 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee18(client, fragments) { | ||
var _ref24 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee23(client, fragments) { | ||
var query; | ||
return regeneratorRuntime.wrap(function _callee18$(_context18) { | ||
return regeneratorRuntime.wrap(function _callee23$(_context23) { | ||
while (1) { | ||
switch (_context18.prev = _context18.next) { | ||
switch (_context23.prev = _context23.next) { | ||
case 0: | ||
_context18.next = 2; | ||
_context23.next = 2; | ||
return queries.getTemplates(fragments); | ||
case 2: | ||
query = _context18.sent; | ||
return _context18.abrupt('return', client.get('/application', query)); | ||
query = _context23.sent; | ||
return _context23.abrupt('return', client.get('/application', query)); | ||
case 4: | ||
case 'end': | ||
return _context18.stop(); | ||
return _context23.stop(); | ||
} | ||
} | ||
}, _callee18, this); | ||
}, _callee23, this); | ||
})); | ||
function getTemplates(_x51, _x52) { | ||
return _ref18.apply(this, arguments); | ||
function getTemplates(_x61, _x62) { | ||
return _ref24.apply(this, arguments); | ||
} | ||
@@ -1117,25 +1457,25 @@ | ||
getApplications: function () { | ||
var _ref19 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee19(client, fragments, params) { | ||
var _ref25 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee24(client, fragments, params) { | ||
var query; | ||
return regeneratorRuntime.wrap(function _callee19$(_context19) { | ||
return regeneratorRuntime.wrap(function _callee24$(_context24) { | ||
while (1) { | ||
switch (_context19.prev = _context19.next) { | ||
switch (_context24.prev = _context24.next) { | ||
case 0: | ||
_context19.next = 2; | ||
_context24.next = 2; | ||
return queries.getApplications(fragments, params); | ||
case 2: | ||
query = _context19.sent; | ||
return _context19.abrupt('return', client.get('/application', query)); | ||
query = _context24.sent; | ||
return _context24.abrupt('return', client.get('/application', query)); | ||
case 4: | ||
case 'end': | ||
return _context19.stop(); | ||
return _context24.stop(); | ||
} | ||
} | ||
}, _callee19, this); | ||
}, _callee24, this); | ||
})); | ||
function getApplications(_x53, _x54, _x55) { | ||
return _ref19.apply(this, arguments); | ||
function getApplications(_x63, _x64, _x65) { | ||
return _ref25.apply(this, arguments); | ||
} | ||
@@ -1148,25 +1488,25 @@ | ||
addApplicationSource: function () { | ||
var _ref20 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee20(client, applicationId, applicationSource, fragments) { | ||
var _ref26 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee25(client, applicationId, applicationSource, fragments) { | ||
var mutation; | ||
return regeneratorRuntime.wrap(function _callee20$(_context20) { | ||
return regeneratorRuntime.wrap(function _callee25$(_context25) { | ||
while (1) { | ||
switch (_context20.prev = _context20.next) { | ||
switch (_context25.prev = _context25.next) { | ||
case 0: | ||
_context20.next = 2; | ||
_context25.next = 2; | ||
return mutations.addApplicationSource(applicationId, applicationSource, fragments); | ||
case 2: | ||
mutation = _context20.sent; | ||
return _context20.abrupt('return', client.post('/application', mutation)); | ||
mutation = _context25.sent; | ||
return _context25.abrupt('return', client.post('/application', mutation)); | ||
case 4: | ||
case 'end': | ||
return _context20.stop(); | ||
return _context25.stop(); | ||
} | ||
} | ||
}, _callee20, this); | ||
}, _callee25, this); | ||
})); | ||
function addApplicationSource(_x56, _x57, _x58, _x59) { | ||
return _ref20.apply(this, arguments); | ||
function addApplicationSource(_x66, _x67, _x68, _x69) { | ||
return _ref26.apply(this, arguments); | ||
} | ||
@@ -1179,30 +1519,30 @@ | ||
addApplicationSourceFromURL: function () { | ||
var _ref21 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee21(client, applicationId, url, fragments) { | ||
var _ref27 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee26(client, applicationId, url, fragments) { | ||
var file, mutation; | ||
return regeneratorRuntime.wrap(function _callee21$(_context21) { | ||
return regeneratorRuntime.wrap(function _callee26$(_context26) { | ||
while (1) { | ||
switch (_context21.prev = _context21.next) { | ||
switch (_context26.prev = _context26.next) { | ||
case 0: | ||
_context21.next = 2; | ||
_context26.next = 2; | ||
return getFileFromUrl(client, url); | ||
case 2: | ||
file = _context21.sent; | ||
_context21.next = 5; | ||
file = _context26.sent; | ||
_context26.next = 5; | ||
return mutations.addApplicationSource(applicationId, file, fragments); | ||
case 5: | ||
mutation = _context21.sent; | ||
return _context21.abrupt('return', client.post('/application', mutation)); | ||
mutation = _context26.sent; | ||
return _context26.abrupt('return', client.post('/application', mutation)); | ||
case 7: | ||
case 'end': | ||
return _context21.stop(); | ||
return _context26.stop(); | ||
} | ||
} | ||
}, _callee21, this); | ||
}, _callee26, this); | ||
})); | ||
function addApplicationSourceFromURL(_x60, _x61, _x62, _x63) { | ||
return _ref21.apply(this, arguments); | ||
function addApplicationSourceFromURL(_x70, _x71, _x72, _x73) { | ||
return _ref27.apply(this, arguments); | ||
} | ||
@@ -1215,25 +1555,25 @@ | ||
updateApplicationSource: function () { | ||
var _ref22 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee22(client, applicationSource, fragments) { | ||
var _ref28 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee27(client, applicationSource, fragments) { | ||
var mutation; | ||
return regeneratorRuntime.wrap(function _callee22$(_context22) { | ||
return regeneratorRuntime.wrap(function _callee27$(_context27) { | ||
while (1) { | ||
switch (_context22.prev = _context22.next) { | ||
switch (_context27.prev = _context27.next) { | ||
case 0: | ||
_context22.next = 2; | ||
_context27.next = 2; | ||
return mutations.updateApplicationSource(applicationSource, fragments); | ||
case 2: | ||
mutation = _context22.sent; | ||
return _context22.abrupt('return', client.post('/application', mutation)); | ||
mutation = _context27.sent; | ||
return _context27.abrupt('return', client.post('/application', mutation)); | ||
case 4: | ||
case 'end': | ||
return _context22.stop(); | ||
return _context27.stop(); | ||
} | ||
} | ||
}, _callee22, this); | ||
}, _callee27, this); | ||
})); | ||
function updateApplicationSource(_x64, _x65, _x66) { | ||
return _ref22.apply(this, arguments); | ||
function updateApplicationSource(_x74, _x75, _x76) { | ||
return _ref28.apply(this, arguments); | ||
} | ||
@@ -1246,25 +1586,25 @@ | ||
removeSourceFromApplication: function () { | ||
var _ref23 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee23(client, sourceId, applicationId, fragments) { | ||
var _ref29 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee28(client, sourceId, applicationId, fragments) { | ||
var mutation; | ||
return regeneratorRuntime.wrap(function _callee23$(_context23) { | ||
return regeneratorRuntime.wrap(function _callee28$(_context28) { | ||
while (1) { | ||
switch (_context23.prev = _context23.next) { | ||
switch (_context28.prev = _context28.next) { | ||
case 0: | ||
_context23.next = 2; | ||
_context28.next = 2; | ||
return mutations.removeSourceFromApplication(sourceId, applicationId, fragments); | ||
case 2: | ||
mutation = _context23.sent; | ||
return _context23.abrupt('return', client.post('/application', mutation)); | ||
mutation = _context28.sent; | ||
return _context28.abrupt('return', client.post('/application', mutation)); | ||
case 4: | ||
case 'end': | ||
return _context23.stop(); | ||
return _context28.stop(); | ||
} | ||
} | ||
}, _callee23, this); | ||
}, _callee28, this); | ||
})); | ||
function removeSourceFromApplication(_x67, _x68, _x69, _x70) { | ||
return _ref23.apply(this, arguments); | ||
function removeSourceFromApplication(_x77, _x78, _x79, _x80) { | ||
return _ref29.apply(this, arguments); | ||
} | ||
@@ -1277,25 +1617,25 @@ | ||
applyTemplate: function () { | ||
var _ref24 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee24(client, templateId, appId, fragments) { | ||
var _ref30 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee29(client, templateId, appId, fragments) { | ||
var mutation; | ||
return regeneratorRuntime.wrap(function _callee24$(_context24) { | ||
return regeneratorRuntime.wrap(function _callee29$(_context29) { | ||
while (1) { | ||
switch (_context24.prev = _context24.next) { | ||
switch (_context29.prev = _context29.next) { | ||
case 0: | ||
_context24.next = 2; | ||
_context29.next = 2; | ||
return mutations.applyTemplate(templateId, appId, fragments); | ||
case 2: | ||
mutation = _context24.sent; | ||
return _context24.abrupt('return', client.post('/application', mutation)); | ||
mutation = _context29.sent; | ||
return _context29.abrupt('return', client.post('/application', mutation)); | ||
case 4: | ||
case 'end': | ||
return _context24.stop(); | ||
return _context29.stop(); | ||
} | ||
} | ||
}, _callee24, this); | ||
}, _callee29, this); | ||
})); | ||
function applyTemplate(_x71, _x72, _x73, _x74) { | ||
return _ref24.apply(this, arguments); | ||
function applyTemplate(_x81, _x82, _x83, _x84) { | ||
return _ref30.apply(this, arguments); | ||
} | ||
@@ -1308,25 +1648,25 @@ | ||
updateTemplate: function () { | ||
var _ref25 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee25(client, template, fragments) { | ||
var _ref31 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee30(client, template, fragments) { | ||
var mutation; | ||
return regeneratorRuntime.wrap(function _callee25$(_context25) { | ||
return regeneratorRuntime.wrap(function _callee30$(_context30) { | ||
while (1) { | ||
switch (_context25.prev = _context25.next) { | ||
switch (_context30.prev = _context30.next) { | ||
case 0: | ||
_context25.next = 2; | ||
_context30.next = 2; | ||
return mutations.updateTemplate(template, fragments); | ||
case 2: | ||
mutation = _context25.sent; | ||
return _context25.abrupt('return', client.post('/application', mutation)); | ||
mutation = _context30.sent; | ||
return _context30.abrupt('return', client.post('/application', mutation)); | ||
case 4: | ||
case 'end': | ||
return _context25.stop(); | ||
return _context30.stop(); | ||
} | ||
} | ||
}, _callee25, this); | ||
}, _callee30, this); | ||
})); | ||
function updateTemplate(_x75, _x76, _x77) { | ||
return _ref25.apply(this, arguments); | ||
function updateTemplate(_x85, _x86, _x87) { | ||
return _ref31.apply(this, arguments); | ||
} | ||
@@ -1337,34 +1677,84 @@ | ||
/** | ||
* Starts a new instrumentation process. | ||
* Previous instrumentation must be deleted, before starting a new one. | ||
* @param client | ||
* @param applicationId | ||
* @returns {Promise<*>} | ||
*/ | ||
startInstrumentation: function () { | ||
var _ref32 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee31(client, applicationId) { | ||
var instrumentation; | ||
return regeneratorRuntime.wrap(function _callee31$(_context31) { | ||
while (1) { | ||
switch (_context31.prev = _context31.next) { | ||
case 0: | ||
_context31.next = 2; | ||
return client.get('/profiling-run', { applicationId: applicationId }).catch(function (e) { | ||
if (e.statusCode !== 404) throw e; | ||
}); | ||
case 2: | ||
instrumentation = _context31.sent; | ||
if (!instrumentation) { | ||
_context31.next = 6; | ||
break; | ||
} | ||
_context31.next = 6; | ||
return client.patch('/profiling-run/' + instrumentation.data.id, { | ||
state: 'DELETED' | ||
}); | ||
case 6: | ||
return _context31.abrupt('return', client.post('/profiling-run', { applicationId: applicationId })); | ||
case 7: | ||
case 'end': | ||
return _context31.stop(); | ||
} | ||
} | ||
}, _callee31, this); | ||
})); | ||
function startInstrumentation(_x88, _x89) { | ||
return _ref32.apply(this, arguments); | ||
} | ||
return startInstrumentation; | ||
}(), | ||
// | ||
createApplicationProtection: function () { | ||
var _ref26 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee26(client, applicationId, protectionOptions, fragments) { | ||
var _ref27, args, mutation; | ||
var _ref33 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee32(client, applicationId, protectionOptions, fragments) { | ||
var _ref34, args, mutation; | ||
return regeneratorRuntime.wrap(function _callee26$(_context26) { | ||
return regeneratorRuntime.wrap(function _callee32$(_context32) { | ||
while (1) { | ||
switch (_context26.prev = _context26.next) { | ||
switch (_context32.prev = _context32.next) { | ||
case 0: | ||
_context26.next = 2; | ||
_context32.next = 2; | ||
return introspection.mutation(client, 'createApplicationProtection'); | ||
case 2: | ||
_ref27 = _context26.sent; | ||
args = _ref27.args; | ||
_context26.next = 6; | ||
_ref34 = _context32.sent; | ||
args = _ref34.args; | ||
_context32.next = 6; | ||
return mutations.createApplicationProtection(applicationId, fragments, protectionOptions, args); | ||
case 6: | ||
mutation = _context26.sent; | ||
return _context26.abrupt('return', client.post('/application', mutation)); | ||
mutation = _context32.sent; | ||
return _context32.abrupt('return', client.post('/application', mutation)); | ||
case 8: | ||
case 'end': | ||
return _context26.stop(); | ||
return _context32.stop(); | ||
} | ||
} | ||
}, _callee26, this); | ||
}, _callee32, this); | ||
})); | ||
function createApplicationProtection(_x78, _x79, _x80, _x81) { | ||
return _ref26.apply(this, arguments); | ||
function createApplicationProtection(_x90, _x91, _x92, _x93) { | ||
return _ref33.apply(this, arguments); | ||
} | ||
@@ -1375,27 +1765,55 @@ | ||
/** | ||
* @param {object} client | ||
* @param {string} instrumentationId | ||
* @returns {Promise<object>} | ||
*/ | ||
getInstrumentation: function () { | ||
var _ref35 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee33(client, instrumentationId) { | ||
return regeneratorRuntime.wrap(function _callee33$(_context33) { | ||
while (1) { | ||
switch (_context33.prev = _context33.next) { | ||
case 0: | ||
return _context33.abrupt('return', client.get('/profiling-run/' + instrumentationId)); | ||
case 1: | ||
case 'end': | ||
return _context33.stop(); | ||
} | ||
} | ||
}, _callee33, this); | ||
})); | ||
function getInstrumentation(_x94, _x95) { | ||
return _ref35.apply(this, arguments); | ||
} | ||
return getInstrumentation; | ||
}(), | ||
// | ||
getApplicationProtection: function () { | ||
var _ref28 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee27(client, applicationId, protectionId, fragments) { | ||
var _ref36 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee34(client, applicationId, protectionId, fragments) { | ||
var query; | ||
return regeneratorRuntime.wrap(function _callee27$(_context27) { | ||
return regeneratorRuntime.wrap(function _callee34$(_context34) { | ||
while (1) { | ||
switch (_context27.prev = _context27.next) { | ||
switch (_context34.prev = _context34.next) { | ||
case 0: | ||
_context27.next = 2; | ||
_context34.next = 2; | ||
return queries.getProtection(applicationId, protectionId, fragments); | ||
case 2: | ||
query = _context27.sent; | ||
return _context27.abrupt('return', client.get('/application', query)); | ||
query = _context34.sent; | ||
return _context34.abrupt('return', client.get('/application', query)); | ||
case 4: | ||
case 'end': | ||
return _context27.stop(); | ||
return _context34.stop(); | ||
} | ||
} | ||
}, _callee27, this); | ||
}, _callee34, this); | ||
})); | ||
function getApplicationProtection(_x82, _x83, _x84, _x85) { | ||
return _ref28.apply(this, arguments); | ||
function getApplicationProtection(_x96, _x97, _x98, _x99) { | ||
return _ref36.apply(this, arguments); | ||
} | ||
@@ -1408,19 +1826,19 @@ | ||
downloadSourceMapsRequest: function () { | ||
var _ref29 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee28(client, protectionId) { | ||
return regeneratorRuntime.wrap(function _callee28$(_context28) { | ||
var _ref37 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee35(client, protectionId) { | ||
return regeneratorRuntime.wrap(function _callee35$(_context35) { | ||
while (1) { | ||
switch (_context28.prev = _context28.next) { | ||
switch (_context35.prev = _context35.next) { | ||
case 0: | ||
return _context28.abrupt('return', client.get('/application/sourceMaps/' + protectionId, null, false)); | ||
return _context35.abrupt('return', client.get('/application/sourceMaps/' + protectionId, null, false)); | ||
case 1: | ||
case 'end': | ||
return _context28.stop(); | ||
return _context35.stop(); | ||
} | ||
} | ||
}, _callee28, this); | ||
}, _callee35, this); | ||
})); | ||
function downloadSourceMapsRequest(_x86, _x87) { | ||
return _ref29.apply(this, arguments); | ||
function downloadSourceMapsRequest(_x100, _x101) { | ||
return _ref37.apply(this, arguments); | ||
} | ||
@@ -1433,23 +1851,32 @@ | ||
downloadApplicationProtection: function () { | ||
var _ref30 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee29(client, protectionId) { | ||
return regeneratorRuntime.wrap(function _callee29$(_context29) { | ||
var _ref38 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee36(client, protectionId) { | ||
return regeneratorRuntime.wrap(function _callee36$(_context36) { | ||
while (1) { | ||
switch (_context29.prev = _context29.next) { | ||
switch (_context36.prev = _context36.next) { | ||
case 0: | ||
return _context29.abrupt('return', client.get('/application/download/' + protectionId, null, false)); | ||
return _context36.abrupt('return', client.get('/application/download/' + protectionId, null, false)); | ||
case 1: | ||
case 'end': | ||
return _context29.stop(); | ||
return _context36.stop(); | ||
} | ||
} | ||
}, _callee29, this); | ||
}, _callee36, this); | ||
})); | ||
function downloadApplicationProtection(_x88, _x89) { | ||
return _ref30.apply(this, arguments); | ||
function downloadApplicationProtection(_x102, _x103) { | ||
return _ref38.apply(this, arguments); | ||
} | ||
return downloadApplicationProtection; | ||
}() | ||
}(), | ||
/** | ||
* @param {object} client | ||
* @param {string} instrumentationId | ||
* @returns {*} | ||
*/ | ||
downloadApplicationInstrumented: function downloadApplicationInstrumented(client, instrumentationId) { | ||
return client.get('/profiling-run/' + instrumentationId + '/instrumented-bundle', null, false); | ||
} | ||
}; | ||
@@ -1456,0 +1883,0 @@ |
{ | ||
"name": "jscrambler", | ||
"description": "Jscrambler API client.", | ||
"version": "5.4.3", | ||
"version": "5.5.0", | ||
"homepage": "https://github.com/jscrambler/jscrambler", | ||
@@ -6,0 +6,0 @@ "author": { |
108
README.md
# [![Jscrambler](https://media.jscrambler.com/images/logo_500px.png)](https://jscrambler.com/?utm_source=github.com&utm_medium=referral) | ||
Jscrambler Client for Browser and Node.js | ||
- [RC configuration](#rc-configuration) | ||
- [CLI](#cli) | ||
- [Required Fields](#required-fields) | ||
- [Output to a single file](#output-to-a-single-file) | ||
- [Output multiple files to a directory](#output-multiple-files-to-a-directory) | ||
- [Using minimatch](#using-minimatch) | ||
- [Using configuration file](#using-configuration-file) | ||
- [Jscrambler](https://jscrambler.com/?utm_source=github.com&utm_medium=referral) | ||
- [Installation](#installation) | ||
- [RC configuration](#rc-configuration) | ||
- [CLI](#cli) | ||
- [Required Fields](#required-fields) | ||
- [Output to a single file](#output-to-a-single-file) | ||
- [Output multiple files to a directory](#output-multiple-files-to-a-directory) | ||
- [Using minimatch](#using-minimatch) | ||
- [Using configuration file](#using-configuration-file) | ||
- [Options](#options) | ||
- [API](#api) | ||
- [Quick example](#quick-example) | ||
- [Jscrambler Parameters](#jscrambler-parameters) | ||
- [Current working directory (--cwd)](#current-working-directory---cwd) | ||
- [Flag -W / --werror (default: **true**)](#flag--w----werror-default-true) | ||
- [Using a proxy to make requests](#using-a-proxy-to-make-requests) | ||
- [Recommended Order (default: **false**)](#recommended-order-default-false) | ||
- [Profiling Data Mode (default: **automatic**)](#profiling-data-mode-default-automatic) | ||
- [Instrument (`--instrument`)](#instrument---instrument) | ||
- [API](#api) | ||
- [Quick example](#quick-example) | ||
- [Jscrambler Parameters](#jscrambler-parameters) | ||
@@ -71,27 +79,31 @@ ## Installation | ||
``` | ||
Usage: jscrambler [options] <file ...> | ||
Usage: jscrambler [options] <file ...> | ||
Options: | ||
-V, --version output the version number | ||
-a, --access-key <accessKey> Access key | ||
-c, --config <config> Jscrambler configuration options | ||
-H, --host <host> Hostname | ||
-i, --application-id <id> Application ID | ||
-o, --output-dir <dir> Output directory | ||
-p, --port <port> Port | ||
--protocol <protocol> Protocol (http or https) | ||
--cafile <path> Internal certificate authority | ||
-C, --cwd <dir> Current Working Directory | ||
-s, --secret-key <secretKey> Secret key | ||
-m, --source-maps <id> Download source maps | ||
-R, --randomization-seed <seed> Set randomization seed | ||
--recommended-order <bool> Use recommended order | ||
-W, --werror <bool> Set werror flag value (default: true) | ||
--tolerate-minification <bool> Don't detect minification as malicious tampering (default: true) | ||
--use-profiling-data <bool> Protection should use the existing profiling data (default: true) | ||
--use-app-classification <bool> Protection should use Application Classification metadata when protecting (default: true) | ||
--jscramblerVersion <version> Use a specific Jscrambler version | ||
--debugMode Protect in debug mode | ||
-h, --help output usage information | ||
Options: | ||
-V, --version output the version number | ||
-a, --access-key <accessKey> Access key | ||
-c, --config <config> Jscrambler configuration options | ||
-H, --host <host> Hostname | ||
-i, --application-id <id> Application ID | ||
-o, --output-dir <dir> Output directory | ||
-p, --port <port> Port | ||
--protocol <protocol> Protocol (http or https) | ||
--cafile <path> Internal certificate authority | ||
-C, --cwd <dir> Current Working Directory | ||
-s, --secret-key <secretKey> Secret key | ||
-m, --source-maps <id> Download source maps | ||
-R, --randomization-seed <seed> Set randomization seed | ||
--instrument Instrument file(s) before start profiling. ATTENTION: previous profiling information will be deleted | ||
--start-profiling Starts profiling (assumes an already instrumented application) | ||
--stop-profiling Stops profiling | ||
--code-hardening-threshold <threshold> Set code hardening file size threshold. Format: {value}{unit="b,kb,mb"}. Example: 200kb | ||
--recommended-order <bool> Use recommended order | ||
-W, --werror <bool> Set werror flag value (default: true) | ||
--tolerate-minification <bool> Don't detect minification as malicious tampering (default: true) | ||
--use-profiling-data <bool> (version 6.2 only) Protection should use the existing profiling data (default: true) | ||
--profiling-data-mode <mode> (version 6.3 and above) Select profiling mode (default: automatic) | ||
--use-app-classification <bool> (version 6.3 and above) Protection should use Application Classification metadata when protecting (default: true) | ||
--jscramblerVersion <version> Use a specific Jscrambler version | ||
--debugMode Protect in debug mode | ||
-h, --help output usage information | ||
``` | ||
@@ -266,2 +278,30 @@ | ||
### Profiling Data Mode (default: **automatic**) | ||
**Note**: This option was introduced in the version 6.3 and should be used instead of **use-profiling-data** which is deprecated. | ||
The **profiling-data-mode** option can be set to three different modes: | ||
* **Annotations**: considers only the profiling annotations; | ||
* **Automatic (default)**: ignores the existing profiling annotations and only considers the application's profiling data; | ||
* **Off**: uses neither profiling data nor profiling annotations. | ||
The following behaviour: | ||
``` | ||
jscrambler --profiling-data-mode off ... | ||
``` | ||
Has the same effect as: | ||
``` | ||
jscrambler --use-profiling-data false ... | ||
``` | ||
### Instrument (`--instrument`) | ||
Instrument is used when you want to [Profile](https://docs.jscrambler.com/code-integrity/documentation/profiling) your application. It is a similar process as protecting your application, but it will just instrument your application so that we can collect some data about how it runs. When you instrument an application, `jscrambler` will output the instrumented version of that application to the specified file/directory. Check our [documentation](https://docs.jscrambler.com/code-integrity/documentation/profiling) for more detailed information. | ||
**NOTE**: When you run this command, the existing profiling information will be **deleted** (if any). | ||
**WARNING:** DO NOT SEND THIS CODE TO PRODUCTION AS IT IS NOT PROTECTED | ||
## API | ||
@@ -268,0 +308,0 @@ ```bash |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
349
142290
18
3009