diff --git a/CHANGELOG.md b/CHANGELOG.md
index a085b65..9e4a08c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# Changelog
+## v0.7.2
+
+Removed superfluous console.log
+
## v0.7.1
Show additional defaults in CLI help
diff --git a/README.md b/README.md
index 051f453..579f200 100644
--- a/README.md
+++ b/README.md
@@ -72,7 +72,7 @@ jobs:
steps:
- name: Tangle Release
id: tangle_release
- uses: iotaledger/gh-tangle-release@v0.7.1
+ uses: iotaledger/gh-tangle-release@v0.7.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IOTA_SEED: ${{ secrets.IOTA_SEED }}
@@ -107,7 +107,7 @@ gh-tangle-release
You will then be presented with the following options.
```shell
-GitHub Tangle Release v0.7.1 🚀
+GitHub Tangle Release v0.7.2 🚀
Usage: gh-tangle-release [options]
diff --git a/action/index.js b/action/index.js
index 4055911..97f86cc 100644
--- a/action/index.js
+++ b/action/index.js
@@ -722,233 +722,232 @@ module.exports = eval("require")("encoding");
/* 23 */,
/* 24 */,
/* 25 */
-/***/ (function(module, exports, __webpack_require__) {
-
-
-/**
- * This is the common logic for both the Node.js and web browser
- * implementations of `debug()`.
- *
- * Expose `debug()` as the module.
- */
-
-exports = module.exports = createDebug.debug = createDebug['default'] = createDebug;
-exports.coerce = coerce;
-exports.disable = disable;
-exports.enable = enable;
-exports.enabled = enabled;
-exports.humanize = __webpack_require__(317);
-
-/**
- * Active `debug` instances.
- */
-exports.instances = [];
-
-/**
- * The currently active debug mode names, and names to skip.
- */
-
-exports.names = [];
-exports.skips = [];
-
-/**
- * Map of special "%n" handling functions, for the debug "format" argument.
- *
- * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
- */
-
-exports.formatters = {};
-
-/**
- * Select a color.
- * @param {String} namespace
- * @return {Number}
- * @api private
- */
+/***/ (function(module, __unusedexports, __webpack_require__) {
-function selectColor(namespace) {
- var hash = 0, i;
+"use strict";
- for (i in namespace) {
- hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
- hash |= 0; // Convert to 32bit integer
- }
+module.exports = function(Promise,
+ apiRejection,
+ INTERNAL,
+ tryConvertToPromise,
+ Proxyable,
+ debug) {
+var errors = __webpack_require__(607);
+var TypeError = errors.TypeError;
+var util = __webpack_require__(248);
+var errorObj = util.errorObj;
+var tryCatch = util.tryCatch;
+var yieldHandlers = [];
- return exports.colors[Math.abs(hash) % exports.colors.length];
+function promiseFromYieldHandler(value, yieldHandlers, traceParent) {
+ for (var i = 0; i < yieldHandlers.length; ++i) {
+ traceParent._pushContext();
+ var result = tryCatch(yieldHandlers[i])(value);
+ traceParent._popContext();
+ if (result === errorObj) {
+ traceParent._pushContext();
+ var ret = Promise.reject(errorObj.e);
+ traceParent._popContext();
+ return ret;
+ }
+ var maybePromise = tryConvertToPromise(result, traceParent);
+ if (maybePromise instanceof Promise) return maybePromise;
+ }
+ return null;
}
-/**
- * Create a debugger with the given `namespace`.
- *
- * @param {String} namespace
- * @return {Function}
- * @api public
- */
-
-function createDebug(namespace) {
-
- var prevTime;
-
- function debug() {
- // disabled?
- if (!debug.enabled) return;
-
- var self = debug;
-
- // set `diff` timestamp
- var curr = +new Date();
- var ms = curr - (prevTime || curr);
- self.diff = ms;
- self.prev = prevTime;
- self.curr = curr;
- prevTime = curr;
-
- // turn the `arguments` into a proper Array
- var args = new Array(arguments.length);
- for (var i = 0; i < args.length; i++) {
- args[i] = arguments[i];
+function PromiseSpawn(generatorFunction, receiver, yieldHandler, stack) {
+ if (debug.cancellation()) {
+ var internal = new Promise(INTERNAL);
+ var _finallyPromise = this._finallyPromise = new Promise(INTERNAL);
+ this._promise = internal.lastly(function() {
+ return _finallyPromise;
+ });
+ internal._captureStackTrace();
+ internal._setOnCancel(this);
+ } else {
+ var promise = this._promise = new Promise(INTERNAL);
+ promise._captureStackTrace();
}
+ this._stack = stack;
+ this._generatorFunction = generatorFunction;
+ this._receiver = receiver;
+ this._generator = undefined;
+ this._yieldHandlers = typeof yieldHandler === "function"
+ ? [yieldHandler].concat(yieldHandlers)
+ : yieldHandlers;
+ this._yieldedPromise = null;
+ this._cancellationPhase = false;
+}
+util.inherits(PromiseSpawn, Proxyable);
- args[0] = exports.coerce(args[0]);
+PromiseSpawn.prototype._isResolved = function() {
+ return this._promise === null;
+};
- if ('string' !== typeof args[0]) {
- // anything else let's inspect with %O
- args.unshift('%O');
+PromiseSpawn.prototype._cleanup = function() {
+ this._promise = this._generator = null;
+ if (debug.cancellation() && this._finallyPromise !== null) {
+ this._finallyPromise._fulfill();
+ this._finallyPromise = null;
}
+};
- // apply any `formatters` transformations
- var index = 0;
- args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
- // if we encounter an escaped % then don't increase the array index
- if (match === '%%') return match;
- index++;
- var formatter = exports.formatters[format];
- if ('function' === typeof formatter) {
- var val = args[index];
- match = formatter.call(self, val);
-
- // now we need to remove `args[index]` since it's inlined in the `format`
- args.splice(index, 1);
- index--;
- }
- return match;
- });
-
- // apply env-specific formatting (colors, etc.)
- exports.formatArgs.call(self, args);
-
- var logFn = debug.log || exports.log || console.log.bind(console);
- logFn.apply(self, args);
- }
-
- debug.namespace = namespace;
- debug.enabled = exports.enabled(namespace);
- debug.useColors = exports.useColors();
- debug.color = selectColor(namespace);
- debug.destroy = destroy;
+PromiseSpawn.prototype._promiseCancelled = function() {
+ if (this._isResolved()) return;
+ var implementsReturn = typeof this._generator["return"] !== "undefined";
- // env-specific initialization logic for debug instances
- if ('function' === typeof exports.init) {
- exports.init(debug);
- }
+ var result;
+ if (!implementsReturn) {
+ var reason = new Promise.CancellationError(
+ "generator .return() sentinel");
+ Promise.coroutine.returnSentinel = reason;
+ this._promise._attachExtraTrace(reason);
+ this._promise._pushContext();
+ result = tryCatch(this._generator["throw"]).call(this._generator,
+ reason);
+ this._promise._popContext();
+ } else {
+ this._promise._pushContext();
+ result = tryCatch(this._generator["return"]).call(this._generator,
+ undefined);
+ this._promise._popContext();
+ }
+ this._cancellationPhase = true;
+ this._yieldedPromise = null;
+ this._continue(result);
+};
- exports.instances.push(debug);
+PromiseSpawn.prototype._promiseFulfilled = function(value) {
+ this._yieldedPromise = null;
+ this._promise._pushContext();
+ var result = tryCatch(this._generator.next).call(this._generator, value);
+ this._promise._popContext();
+ this._continue(result);
+};
- return debug;
-}
+PromiseSpawn.prototype._promiseRejected = function(reason) {
+ this._yieldedPromise = null;
+ this._promise._attachExtraTrace(reason);
+ this._promise._pushContext();
+ var result = tryCatch(this._generator["throw"])
+ .call(this._generator, reason);
+ this._promise._popContext();
+ this._continue(result);
+};
-function destroy () {
- var index = exports.instances.indexOf(this);
- if (index !== -1) {
- exports.instances.splice(index, 1);
- return true;
- } else {
- return false;
- }
-}
+PromiseSpawn.prototype._resultCancelled = function() {
+ if (this._yieldedPromise instanceof Promise) {
+ var promise = this._yieldedPromise;
+ this._yieldedPromise = null;
+ promise.cancel();
+ }
+};
-/**
- * Enables a debug mode by namespaces. This can include modes
- * separated by a colon and wildcards.
- *
- * @param {String} namespaces
- * @api public
- */
+PromiseSpawn.prototype.promise = function () {
+ return this._promise;
+};
-function enable(namespaces) {
- exports.save(namespaces);
+PromiseSpawn.prototype._run = function () {
+ this._generator = this._generatorFunction.call(this._receiver);
+ this._receiver =
+ this._generatorFunction = undefined;
+ this._promiseFulfilled(undefined);
+};
- exports.names = [];
- exports.skips = [];
+PromiseSpawn.prototype._continue = function (result) {
+ var promise = this._promise;
+ if (result === errorObj) {
+ this._cleanup();
+ if (this._cancellationPhase) {
+ return promise.cancel();
+ } else {
+ return promise._rejectCallback(result.e, false);
+ }
+ }
- var i;
- var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
- var len = split.length;
-
- for (i = 0; i < len; i++) {
- if (!split[i]) continue; // ignore empty strings
- namespaces = split[i].replace(/\*/g, '.*?');
- if (namespaces[0] === '-') {
- exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
+ var value = result.value;
+ if (result.done === true) {
+ this._cleanup();
+ if (this._cancellationPhase) {
+ return promise.cancel();
+ } else {
+ return promise._resolveCallback(value);
+ }
} else {
- exports.names.push(new RegExp('^' + namespaces + '$'));
+ var maybePromise = tryConvertToPromise(value, this._promise);
+ if (!(maybePromise instanceof Promise)) {
+ maybePromise =
+ promiseFromYieldHandler(maybePromise,
+ this._yieldHandlers,
+ this._promise);
+ if (maybePromise === null) {
+ this._promiseRejected(
+ new TypeError(
+ "A value %s was yielded that could not be treated as a promise\u000a\u000a See http://goo.gl/MqrFmX\u000a\u000a".replace("%s", String(value)) +
+ "From coroutine:\u000a" +
+ this._stack.split("\n").slice(1, -7).join("\n")
+ )
+ );
+ return;
+ }
+ }
+ maybePromise = maybePromise._target();
+ var bitField = maybePromise._bitField;
+ ;
+ if (((bitField & 50397184) === 0)) {
+ this._yieldedPromise = maybePromise;
+ maybePromise._proxy(this, null);
+ } else if (((bitField & 33554432) !== 0)) {
+ Promise._async.invoke(
+ this._promiseFulfilled, this, maybePromise._value()
+ );
+ } else if (((bitField & 16777216) !== 0)) {
+ Promise._async.invoke(
+ this._promiseRejected, this, maybePromise._reason()
+ );
+ } else {
+ this._promiseCancelled();
+ }
}
- }
-
- for (i = 0; i < exports.instances.length; i++) {
- var instance = exports.instances[i];
- instance.enabled = exports.enabled(instance.namespace);
- }
-}
-
-/**
- * Disable debug output.
- *
- * @api public
- */
-
-function disable() {
- exports.enable('');
-}
-
-/**
- * Returns true if the given mode name is enabled, false otherwise.
- *
- * @param {String} name
- * @return {Boolean}
- * @api public
- */
+};
-function enabled(name) {
- if (name[name.length - 1] === '*') {
- return true;
- }
- var i, len;
- for (i = 0, len = exports.skips.length; i < len; i++) {
- if (exports.skips[i].test(name)) {
- return false;
- }
- }
- for (i = 0, len = exports.names.length; i < len; i++) {
- if (exports.names[i].test(name)) {
- return true;
+Promise.coroutine = function (generatorFunction, options) {
+ if (typeof generatorFunction !== "function") {
+ throw new TypeError("generatorFunction must be a function\u000a\u000a See http://goo.gl/MqrFmX\u000a");
}
- }
- return false;
-}
+ var yieldHandler = Object(options).yieldHandler;
+ var PromiseSpawn$ = PromiseSpawn;
+ var stack = new Error().stack;
+ return function () {
+ var generator = generatorFunction.apply(this, arguments);
+ var spawn = new PromiseSpawn$(undefined, undefined, yieldHandler,
+ stack);
+ var ret = spawn.promise();
+ spawn._generator = generator;
+ spawn._promiseFulfilled(undefined);
+ return ret;
+ };
+};
-/**
- * Coerce `val`.
- *
- * @param {Mixed} val
- * @return {Mixed}
- * @api private
- */
+Promise.coroutine.addYieldHandler = function(fn) {
+ if (typeof fn !== "function") {
+ throw new TypeError("expecting a function but got " + util.classString(fn));
+ }
+ yieldHandlers.push(fn);
+};
-function coerce(val) {
- if (val instanceof Error) return val.stack || val.message;
- return val;
-}
+Promise.spawn = function (generatorFunction) {
+ debug.deprecated("Promise.spawn()", "Promise.coroutine()");
+ if (typeof generatorFunction !== "function") {
+ return apiRejection("generatorFunction must be a function\u000a\u000a See http://goo.gl/MqrFmX\u000a");
+ }
+ var spawn = new PromiseSpawn(generatorFunction, this);
+ var ret = spawn.promise();
+ spawn._run(Promise.spawn);
+ return ret;
+};
+};
/***/ }),
@@ -1175,6 +1174,21 @@ function isObject(val) {
return val !== null && typeof val === 'object';
}
+/**
+ * Determine if a value is a plain Object
+ *
+ * @param {Object} val The value to test
+ * @return {boolean} True if value is a plain Object, otherwise false
+ */
+function isPlainObject(val) {
+ if (toString.call(val) !== '[object Object]') {
+ return false;
+ }
+
+ var prototype = Object.getPrototypeOf(val);
+ return prototype === null || prototype === Object.prototype;
+}
+
/**
* Determine if a value is a Date
*
@@ -1331,34 +1345,12 @@ function forEach(obj, fn) {
function merge(/* obj1, obj2, obj3, ... */) {
var result = {};
function assignValue(val, key) {
- if (typeof result[key] === 'object' && typeof val === 'object') {
+ if (isPlainObject(result[key]) && isPlainObject(val)) {
result[key] = merge(result[key], val);
- } else {
- result[key] = val;
- }
- }
-
- for (var i = 0, l = arguments.length; i < l; i++) {
- forEach(arguments[i], assignValue);
- }
- return result;
-}
-
-/**
- * Function equal to merge with the difference being that no reference
- * to original objects is kept.
- *
- * @see merge
- * @param {Object} obj1 Object to merge
- * @returns {Object} Result of all merge properties
- */
-function deepMerge(/* obj1, obj2, obj3, ... */) {
- var result = {};
- function assignValue(val, key) {
- if (typeof result[key] === 'object' && typeof val === 'object') {
- result[key] = deepMerge(result[key], val);
- } else if (typeof val === 'object') {
- result[key] = deepMerge({}, val);
+ } else if (isPlainObject(val)) {
+ result[key] = merge({}, val);
+ } else if (isArray(val)) {
+ result[key] = val.slice();
} else {
result[key] = val;
}
@@ -1389,6 +1381,19 @@ function extend(a, b, thisArg) {
return a;
}
+/**
+ * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
+ *
+ * @param {string} content with BOM
+ * @return {string} content value without BOM
+ */
+function stripBOM(content) {
+ if (content.charCodeAt(0) === 0xFEFF) {
+ content = content.slice(1);
+ }
+ return content;
+}
+
module.exports = {
isArray: isArray,
isArrayBuffer: isArrayBuffer,
@@ -1398,6 +1403,7 @@ module.exports = {
isString: isString,
isNumber: isNumber,
isObject: isObject,
+ isPlainObject: isPlainObject,
isUndefined: isUndefined,
isDate: isDate,
isFile: isFile,
@@ -1408,9 +1414,9 @@ module.exports = {
isStandardBrowserEnv: isStandardBrowserEnv,
forEach: forEach,
merge: merge,
- deepMerge: deepMerge,
extend: extend,
- trim: trim
+ trim: trim,
+ stripBOM: stripBOM
};
@@ -2143,16 +2149,13 @@ exports.increment = function (value) { return add(value, new Int8Array(1).fill(1
* Module dependencies.
*/
-var tty = __webpack_require__(867);
-var util = __webpack_require__(669);
+const tty = __webpack_require__(867);
+const util = __webpack_require__(669);
/**
* This is the Node.js implementation of `debug()`.
- *
- * Expose `debug()` as the module.
*/
-exports = module.exports = __webpack_require__(25);
exports.init = init;
exports.log = log;
exports.formatArgs = formatArgs;
@@ -2164,21 +2167,95 @@ exports.useColors = useColors;
* Colors.
*/
-exports.colors = [ 6, 2, 3, 4, 5, 1 ];
+exports.colors = [6, 2, 3, 4, 5, 1];
try {
- var supportsColor = __webpack_require__(247);
- if (supportsColor && supportsColor.level >= 2) {
- exports.colors = [
- 20, 21, 26, 27, 32, 33, 38, 39, 40, 41, 42, 43, 44, 45, 56, 57, 62, 63, 68,
- 69, 74, 75, 76, 77, 78, 79, 80, 81, 92, 93, 98, 99, 112, 113, 128, 129, 134,
- 135, 148, 149, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171,
- 172, 173, 178, 179, 184, 185, 196, 197, 198, 199, 200, 201, 202, 203, 204,
- 205, 206, 207, 208, 209, 214, 215, 220, 221
- ];
- }
-} catch (err) {
- // swallow - we only care if `supports-color` is available; it doesn't have to be.
+ // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
+ // eslint-disable-next-line import/no-extraneous-dependencies
+ const supportsColor = __webpack_require__(247);
+
+ if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
+ exports.colors = [
+ 20,
+ 21,
+ 26,
+ 27,
+ 32,
+ 33,
+ 38,
+ 39,
+ 40,
+ 41,
+ 42,
+ 43,
+ 44,
+ 45,
+ 56,
+ 57,
+ 62,
+ 63,
+ 68,
+ 69,
+ 74,
+ 75,
+ 76,
+ 77,
+ 78,
+ 79,
+ 80,
+ 81,
+ 92,
+ 93,
+ 98,
+ 99,
+ 112,
+ 113,
+ 128,
+ 129,
+ 134,
+ 135,
+ 148,
+ 149,
+ 160,
+ 161,
+ 162,
+ 163,
+ 164,
+ 165,
+ 166,
+ 167,
+ 168,
+ 169,
+ 170,
+ 171,
+ 172,
+ 173,
+ 178,
+ 179,
+ 184,
+ 185,
+ 196,
+ 197,
+ 198,
+ 199,
+ 200,
+ 201,
+ 202,
+ 203,
+ 204,
+ 205,
+ 206,
+ 207,
+ 208,
+ 209,
+ 214,
+ 215,
+ 220,
+ 221
+ ];
+ }
+} catch (error) {
+ // Swallow - we only care if `supports-color` is available; it doesn't have to be.
}
/**
@@ -2187,24 +2264,31 @@ try {
* $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
*/
-exports.inspectOpts = Object.keys(process.env).filter(function (key) {
- return /^debug_/i.test(key);
-}).reduce(function (obj, key) {
- // camel-case
- var prop = key
- .substring(6)
- .toLowerCase()
- .replace(/_([a-z])/g, function (_, k) { return k.toUpperCase() });
+exports.inspectOpts = Object.keys(process.env).filter(key => {
+ return /^debug_/i.test(key);
+}).reduce((obj, key) => {
+ // Camel-case
+ const prop = key
+ .substring(6)
+ .toLowerCase()
+ .replace(/_([a-z])/g, (_, k) => {
+ return k.toUpperCase();
+ });
- // coerce string value into JS value
- var val = process.env[key];
- if (/^(yes|on|true|enabled)$/i.test(val)) val = true;
- else if (/^(no|off|false|disabled)$/i.test(val)) val = false;
- else if (val === 'null') val = null;
- else val = Number(val);
+ // Coerce string value into JS value
+ let val = process.env[key];
+ if (/^(yes|on|true|enabled)$/i.test(val)) {
+ val = true;
+ } else if (/^(no|off|false|disabled)$/i.test(val)) {
+ val = false;
+ } else if (val === 'null') {
+ val = null;
+ } else {
+ val = Number(val);
+ }
- obj[prop] = val;
- return obj;
+ obj[prop] = val;
+ return obj;
}, {});
/**
@@ -2212,32 +2296,11 @@ exports.inspectOpts = Object.keys(process.env).filter(function (key) {
*/
function useColors() {
- return 'colors' in exports.inspectOpts
- ? Boolean(exports.inspectOpts.colors)
- : tty.isatty(process.stderr.fd);
+ return 'colors' in exports.inspectOpts ?
+ Boolean(exports.inspectOpts.colors) :
+ tty.isatty(process.stderr.fd);
}
-/**
- * Map %o to `util.inspect()`, all on a single line.
- */
-
-exports.formatters.o = function(v) {
- this.inspectOpts.colors = this.useColors;
- return util.inspect(v, this.inspectOpts)
- .split('\n').map(function(str) {
- return str.trim()
- }).join(' ');
-};
-
-/**
- * Map %o to `util.inspect()`, allowing multiple lines if needed.
- */
-
-exports.formatters.O = function(v) {
- this.inspectOpts.colors = this.useColors;
- return util.inspect(v, this.inspectOpts);
-};
-
/**
* Adds ANSI color escape codes if enabled.
*
@@ -2245,35 +2308,33 @@ exports.formatters.O = function(v) {
*/
function formatArgs(args) {
- var name = this.namespace;
- var useColors = this.useColors;
+ const {namespace: name, useColors} = this;
- if (useColors) {
- var c = this.color;
- var colorCode = '\u001b[3' + (c < 8 ? c : '8;5;' + c);
- var prefix = ' ' + colorCode + ';1m' + name + ' ' + '\u001b[0m';
+ if (useColors) {
+ const c = this.color;
+ const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
+ const prefix = ` ${colorCode};1m${name} \u001B[0m`;
- args[0] = prefix + args[0].split('\n').join('\n' + prefix);
- args.push(colorCode + 'm+' + exports.humanize(this.diff) + '\u001b[0m');
- } else {
- args[0] = getDate() + name + ' ' + args[0];
- }
+ args[0] = prefix + args[0].split('\n').join('\n' + prefix);
+ args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
+ } else {
+ args[0] = getDate() + name + ' ' + args[0];
+ }
}
function getDate() {
- if (exports.inspectOpts.hideDate) {
- return '';
- } else {
- return new Date().toISOString() + ' ';
- }
+ if (exports.inspectOpts.hideDate) {
+ return '';
+ }
+ return new Date().toISOString() + ' ';
}
/**
* Invokes `util.format()` with the specified arguments and writes to stderr.
*/
-function log() {
- return process.stderr.write(util.format.apply(util, arguments) + '\n');
+function log(...args) {
+ return process.stderr.write(util.format(...args) + '\n');
}
/**
@@ -2282,15 +2343,14 @@ function log() {
* @param {String} namespaces
* @api private
*/
-
function save(namespaces) {
- if (null == namespaces) {
- // If you set a process.env field to null or undefined, it gets cast to the
- // string 'null' or 'undefined'. Just delete instead.
- delete process.env.DEBUG;
- } else {
- process.env.DEBUG = namespaces;
- }
+ if (namespaces) {
+ process.env.DEBUG = namespaces;
+ } else {
+ // If you set a process.env field to null or undefined, it gets cast to the
+ // string 'null' or 'undefined'. Just delete instead.
+ delete process.env.DEBUG;
+ }
}
/**
@@ -2301,7 +2361,7 @@ function save(namespaces) {
*/
function load() {
- return process.env.DEBUG;
+ return process.env.DEBUG;
}
/**
@@ -2311,20 +2371,37 @@ function load() {
* differently for a particular `debug` instance.
*/
-function init (debug) {
- debug.inspectOpts = {};
+function init(debug) {
+ debug.inspectOpts = {};
- var keys = Object.keys(exports.inspectOpts);
- for (var i = 0; i < keys.length; i++) {
- debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
- }
+ const keys = Object.keys(exports.inspectOpts);
+ for (let i = 0; i < keys.length; i++) {
+ debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
+ }
}
+module.exports = __webpack_require__(486)(exports);
+
+const {formatters} = module.exports;
+
/**
- * Enable namespaces listed in `process.env.DEBUG` initially.
+ * Map %o to `util.inspect()`, all on a single line.
*/
-exports.enable(load());
+formatters.o = function (v) {
+ this.inspectOpts.colors = this.useColors;
+ return util.inspect(v, this.inspectOpts)
+ .replace(/\s*\n\s*/g, ' ');
+};
+
+/**
+ * Map %O to `util.inspect()`, allowing multiple lines if needed.
+ */
+
+formatters.O = function (v) {
+ this.inspectOpts.colors = this.useColors;
+ return util.inspect(v, this.inspectOpts);
+};
/***/ }),
@@ -3519,7 +3596,6 @@ var utils = __webpack_require__(35);
function encode(val) {
return encodeURIComponent(val).
- replace(/%40/gi, '@').
replace(/%3A/gi, ':').
replace(/%24/g, '$').
replace(/%2C/gi, ',').
@@ -4599,7 +4675,7 @@ Promise.prototype.settle = function () {
"use strict";
exports.__esModule = true;
-var httpClient_1 = __webpack_require__(900);
+var httpClient_1 = __webpack_require__(396);
exports.createHttpClient = httpClient_1.createHttpClient;
var types_1 = __webpack_require__(833);
exports.IRICommand = types_1.IRICommand;
@@ -5640,6 +5716,7 @@ module.exports = require("https");
var utils = __webpack_require__(35);
var settle = __webpack_require__(564);
+var cookies = __webpack_require__(864);
var buildURL = __webpack_require__(133);
var buildFullPath = __webpack_require__(138);
var parseHeaders = __webpack_require__(333);
@@ -5655,12 +5732,19 @@ module.exports = function xhrAdapter(config) {
delete requestHeaders['Content-Type']; // Let the browser set it
}
+ if (
+ (utils.isBlob(requestData) || utils.isFile(requestData)) &&
+ requestData.type
+ ) {
+ delete requestHeaders['Content-Type']; // Let the browser set it
+ }
+
var request = new XMLHttpRequest();
// HTTP basic authentication
if (config.auth) {
var username = config.auth.username || '';
- var password = config.auth.password || '';
+ var password = unescape(encodeURIComponent(config.auth.password)) || '';
requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
}
@@ -5741,8 +5825,6 @@ module.exports = function xhrAdapter(config) {
// This is only done if running in a standard browser environment.
// Specifically not if we're in a web worker, or react-native.
if (utils.isStandardBrowserEnv()) {
- var cookies = __webpack_require__(864);
-
// Add xsrf header
var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
cookies.read(config.xsrfCookieName) :
@@ -5808,7 +5890,7 @@ module.exports = function xhrAdapter(config) {
});
}
- if (requestData === undefined) {
+ if (!requestData) {
requestData = null;
}
@@ -10070,225 +10152,68 @@ module.exports = require("async_hooks");
return plaintext;
}
});
- }());
-
-
-}));
-
-/***/ }),
-/* 314 */,
-/* 315 */
-/***/ (function(module) {
-
-"use strict";
-
-module.exports = function(Promise) {
-function returner() {
- return this.value;
-}
-function thrower() {
- throw this.reason;
-}
-
-Promise.prototype["return"] =
-Promise.prototype.thenReturn = function (value) {
- if (value instanceof Promise) value.suppressUnhandledRejections();
- return this._then(
- returner, undefined, undefined, {value: value}, undefined);
-};
-
-Promise.prototype["throw"] =
-Promise.prototype.thenThrow = function (reason) {
- return this._then(
- thrower, undefined, undefined, {reason: reason}, undefined);
-};
-
-Promise.prototype.catchThrow = function (reason) {
- if (arguments.length <= 1) {
- return this._then(
- undefined, thrower, undefined, {reason: reason}, undefined);
- } else {
- var _reason = arguments[1];
- var handler = function() {throw _reason;};
- return this.caught(reason, handler);
- }
-};
-
-Promise.prototype.catchReturn = function (value) {
- if (arguments.length <= 1) {
- if (value instanceof Promise) value.suppressUnhandledRejections();
- return this._then(
- undefined, returner, undefined, {value: value}, undefined);
- } else {
- var _value = arguments[1];
- if (_value instanceof Promise) _value.suppressUnhandledRejections();
- var handler = function() {return _value;};
- return this.caught(value, handler);
- }
-};
-};
-
-
-/***/ }),
-/* 316 */,
-/* 317 */
-/***/ (function(module) {
-
-/**
- * Helpers.
- */
-
-var s = 1000;
-var m = s * 60;
-var h = m * 60;
-var d = h * 24;
-var y = d * 365.25;
-
-/**
- * Parse or format the given `val`.
- *
- * Options:
- *
- * - `long` verbose formatting [false]
- *
- * @param {String|Number} val
- * @param {Object} [options]
- * @throws {Error} throw an error if val is not a non-empty string or a number
- * @return {String|Number}
- * @api public
- */
-
-module.exports = function(val, options) {
- options = options || {};
- var type = typeof val;
- if (type === 'string' && val.length > 0) {
- return parse(val);
- } else if (type === 'number' && isNaN(val) === false) {
- return options.long ? fmtLong(val) : fmtShort(val);
- }
- throw new Error(
- 'val is not a non-empty string or a valid number. val=' +
- JSON.stringify(val)
- );
-};
+ }());
-/**
- * Parse the given `str` and return milliseconds.
- *
- * @param {String} str
- * @return {Number}
- * @api private
- */
-function parse(str) {
- str = String(str);
- if (str.length > 100) {
- return;
- }
- var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(
- str
- );
- if (!match) {
- return;
- }
- var n = parseFloat(match[1]);
- var type = (match[2] || 'ms').toLowerCase();
- switch (type) {
- case 'years':
- case 'year':
- case 'yrs':
- case 'yr':
- case 'y':
- return n * y;
- case 'days':
- case 'day':
- case 'd':
- return n * d;
- case 'hours':
- case 'hour':
- case 'hrs':
- case 'hr':
- case 'h':
- return n * h;
- case 'minutes':
- case 'minute':
- case 'mins':
- case 'min':
- case 'm':
- return n * m;
- case 'seconds':
- case 'second':
- case 'secs':
- case 'sec':
- case 's':
- return n * s;
- case 'milliseconds':
- case 'millisecond':
- case 'msecs':
- case 'msec':
- case 'ms':
- return n;
- default:
- return undefined;
- }
-}
+}));
-/**
- * Short format for `ms`.
- *
- * @param {Number} ms
- * @return {String}
- * @api private
- */
+/***/ }),
+/* 314 */,
+/* 315 */
+/***/ (function(module) {
-function fmtShort(ms) {
- if (ms >= d) {
- return Math.round(ms / d) + 'd';
- }
- if (ms >= h) {
- return Math.round(ms / h) + 'h';
- }
- if (ms >= m) {
- return Math.round(ms / m) + 'm';
- }
- if (ms >= s) {
- return Math.round(ms / s) + 's';
- }
- return ms + 'ms';
+"use strict";
+
+module.exports = function(Promise) {
+function returner() {
+ return this.value;
+}
+function thrower() {
+ throw this.reason;
}
-/**
- * Long format for `ms`.
- *
- * @param {Number} ms
- * @return {String}
- * @api private
- */
+Promise.prototype["return"] =
+Promise.prototype.thenReturn = function (value) {
+ if (value instanceof Promise) value.suppressUnhandledRejections();
+ return this._then(
+ returner, undefined, undefined, {value: value}, undefined);
+};
-function fmtLong(ms) {
- return plural(ms, d, 'day') ||
- plural(ms, h, 'hour') ||
- plural(ms, m, 'minute') ||
- plural(ms, s, 'second') ||
- ms + ' ms';
-}
+Promise.prototype["throw"] =
+Promise.prototype.thenThrow = function (reason) {
+ return this._then(
+ thrower, undefined, undefined, {reason: reason}, undefined);
+};
-/**
- * Pluralization helper.
- */
+Promise.prototype.catchThrow = function (reason) {
+ if (arguments.length <= 1) {
+ return this._then(
+ undefined, thrower, undefined, {reason: reason}, undefined);
+ } else {
+ var _reason = arguments[1];
+ var handler = function() {throw _reason;};
+ return this.caught(reason, handler);
+ }
+};
-function plural(ms, n, name) {
- if (ms < n) {
- return;
- }
- if (ms < n * 1.5) {
- return Math.floor(ms / n) + ' ' + name;
- }
- return Math.ceil(ms / n) + ' ' + name + 's';
-}
+Promise.prototype.catchReturn = function (value) {
+ if (arguments.length <= 1) {
+ if (value instanceof Promise) value.suppressUnhandledRejections();
+ return this._then(
+ undefined, returner, undefined, {value: value}, undefined);
+ } else {
+ var _value = arguments[1];
+ if (_value instanceof Promise) _value.suppressUnhandledRejections();
+ var handler = function() {return _value;};
+ return this.caught(value, handler);
+ }
+};
+};
/***/ }),
+/* 316 */,
+/* 317 */,
/* 318 */,
/* 319 */,
/* 320 */,
@@ -11646,7 +11571,7 @@ module.exports = require("assert");
/* 361 */
/***/ (function(module) {
-module.exports = {"_from":"axios@^0.19.2","_id":"axios@0.19.2","_inBundle":false,"_integrity":"sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==","_location":"/axios","_phantomChildren":{},"_requested":{"type":"range","registry":true,"raw":"axios@^0.19.2","name":"axios","escapedName":"axios","rawSpec":"^0.19.2","saveSpec":null,"fetchSpec":"^0.19.2"},"_requiredBy":["/"],"_resolved":"https://registry.npmjs.org/axios/-/axios-0.19.2.tgz","_shasum":"3ea36c5d8818d0d5f8a8a97a6d36b86cdc00cb27","_spec":"axios@^0.19.2","_where":"D:\\Workarea\\iota.org\\gh-tangle-release","author":{"name":"Matt Zabriskie"},"browser":{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},"bugs":{"url":"https://github.com/axios/axios/issues"},"bundleDependencies":false,"bundlesize":[{"path":"./dist/axios.min.js","threshold":"5kB"}],"dependencies":{"follow-redirects":"1.5.10"},"deprecated":false,"description":"Promise based HTTP client for the browser and node.js","devDependencies":{"bundlesize":"^0.17.0","coveralls":"^3.0.0","es6-promise":"^4.2.4","grunt":"^1.0.2","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^20.1.0","grunt-karma":"^2.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^1.0.18","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1","karma":"^1.3.0","karma-chrome-launcher":"^2.2.0","karma-coverage":"^1.1.1","karma-firefox-launcher":"^1.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-opera-launcher":"^1.0.0","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^1.2.0","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.7","karma-webpack":"^1.7.0","load-grunt-tasks":"^3.5.2","minimist":"^1.2.0","mocha":"^5.2.0","sinon":"^4.5.0","typescript":"^2.8.1","url-search-params":"^0.10.0","webpack":"^1.13.1","webpack-dev-server":"^1.14.1"},"homepage":"https://github.com/axios/axios","keywords":["xhr","http","ajax","promise","node"],"license":"MIT","main":"index.js","name":"axios","repository":{"type":"git","url":"git+https://github.com/axios/axios.git"},"scripts":{"build":"NODE_ENV=production grunt build","coveralls":"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js","examples":"node ./examples/server.js","fix":"eslint --fix lib/**/*.js","postversion":"git push && git push --tags","preversion":"npm test","start":"node ./sandbox/server.js","test":"grunt test && bundlesize","version":"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json"},"typings":"./index.d.ts","version":"0.19.2"};
+module.exports = {"_from":"axios@0.20.0","_id":"axios@0.20.0","_inBundle":false,"_integrity":"sha512-ANA4rr2BDcmmAQLOKft2fufrtuvlqR+cXNNinUmvfeSNCOF98PZL+7M/v1zIdGo7OLjEA9J2gXJL+j4zGsl0bA==","_location":"/axios","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"axios@0.20.0","name":"axios","escapedName":"axios","rawSpec":"0.20.0","saveSpec":null,"fetchSpec":"0.20.0"},"_requiredBy":["#USER","/"],"_resolved":"https://registry.npmjs.org/axios/-/axios-0.20.0.tgz","_shasum":"057ba30f04884694993a8cd07fa394cff11c50bd","_spec":"axios@0.20.0","_where":"D:\\Workarea\\iota.org\\gh-tangle-release","author":{"name":"Matt Zabriskie"},"browser":{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},"bugs":{"url":"https://github.com/axios/axios/issues"},"bundleDependencies":false,"bundlesize":[{"path":"./dist/axios.min.js","threshold":"5kB"}],"dependencies":{"follow-redirects":"^1.10.0"},"deprecated":false,"description":"Promise based HTTP client for the browser and node.js","devDependencies":{"bundlesize":"^0.17.0","coveralls":"^3.0.0","es6-promise":"^4.2.4","grunt":"^1.0.2","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^20.1.0","grunt-karma":"^2.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^1.0.18","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1","karma":"^1.3.0","karma-chrome-launcher":"^2.2.0","karma-coverage":"^1.1.1","karma-firefox-launcher":"^1.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-opera-launcher":"^1.0.0","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^1.2.0","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.7","karma-webpack":"^1.7.0","load-grunt-tasks":"^3.5.2","minimist":"^1.2.0","mocha":"^5.2.0","sinon":"^4.5.0","typescript":"^2.8.1","url-search-params":"^0.10.0","webpack":"^1.13.1","webpack-dev-server":"^1.14.1"},"homepage":"https://github.com/axios/axios","jsdelivr":"dist/axios.min.js","keywords":["xhr","http","ajax","promise","node"],"license":"MIT","main":"index.js","name":"axios","repository":{"type":"git","url":"git+https://github.com/axios/axios.git"},"scripts":{"build":"NODE_ENV=production grunt build","coveralls":"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js","examples":"node ./examples/server.js","fix":"eslint --fix lib/**/*.js","postversion":"git push && git push --tags","preversion":"npm test","start":"node ./sandbox/server.js","test":"grunt test && bundlesize","version":"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json"},"typings":"./index.d.ts","unpkg":"dist/axios.min.js","version":"0.20.0"};
/***/ }),
/* 362 */,
@@ -11978,7 +11903,7 @@ module.exports = function enhanceError(error, config, code, request, response) {
error.response = response;
error.isAxiosError = true;
- error.toJSON = function() {
+ error.toJSON = function toJSON() {
return {
// Standard
message: this.message,
@@ -12751,27 +12676,194 @@ if (!Int8Array.prototype.fill) {
// Step 13.
return O;
}
- });
-}
-if (!Uint32Array.prototype.slice) {
- Object.defineProperty(Uint8Array.prototype, 'slice', {
- value: Array.prototype.slice
- });
-}
-if (!Uint32Array.prototype.reverse) {
- Object.defineProperty(Uint8Array.prototype, 'reverse', {
- value: Array.prototype.reverse
- });
-}
-//# sourceMappingURL=typed-array.js.map
+ });
+}
+if (!Uint32Array.prototype.slice) {
+ Object.defineProperty(Uint8Array.prototype, 'slice', {
+ value: Array.prototype.slice
+ });
+}
+if (!Uint32Array.prototype.reverse) {
+ Object.defineProperty(Uint8Array.prototype, 'reverse', {
+ value: Array.prototype.reverse
+ });
+}
+//# sourceMappingURL=typed-array.js.map
+
+/***/ }),
+/* 391 */,
+/* 392 */,
+/* 393 */,
+/* 394 */,
+/* 395 */,
+/* 396 */
+/***/ (function(__unusedmodule, exports, __webpack_require__) {
+
+"use strict";
+
+/** @module http-client */
+var __assign = (this && this.__assign) || function () {
+ __assign = Object.assign || function(t) {
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
+ s = arguments[i];
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
+ t[p] = s[p];
+ }
+ return t;
+ };
+ return __assign.apply(this, arguments);
+};
+exports.__esModule = true;
+var _a;
+var Promise = __webpack_require__(440);
+var types_1 = __webpack_require__(833);
+var request_1 = __webpack_require__(633);
+var settings_1 = __webpack_require__(969);
+var BATCH_SIZE = 1000;
+/* Batchable keys for each command */
+exports.batchableKeys = (_a = {},
+ _a[types_1.IRICommand.FIND_TRANSACTIONS] = ['addresses', 'approvees', 'bundles', 'tags'],
+ _a[types_1.IRICommand.GET_BALANCES] = ['addresses'],
+ _a[types_1.IRICommand.GET_INCLUSION_STATES] = ['tips', 'transactions'],
+ _a[types_1.IRICommand.GET_TRYTES] = ['hashes'],
+ _a);
+exports.isBatchableCommand = function (command) {
+ return command.command === types_1.IRICommand.FIND_TRANSACTIONS ||
+ command.command === types_1.IRICommand.GET_BALANCES ||
+ command.command === types_1.IRICommand.GET_INCLUSION_STATES ||
+ command.command === types_1.IRICommand.GET_TRYTES;
+};
+exports.getKeysToBatch = function (command, batchSize) {
+ if (batchSize === void 0) { batchSize = BATCH_SIZE; }
+ return Object.keys(command).filter(function (key) {
+ return exports.batchableKeys[command.command].indexOf(key) > -1 &&
+ Array.isArray(command[key]) &&
+ command[key].length > batchSize;
+ });
+};
+/**
+ * This method creates an HTTP client that you can use to send requests to the [IRI API endpoints](https://docs.iota.org/docs/node-software/0.1/iri/references/api-reference).
+ *
+ * ## Related methods
+ *
+ * To send requests to the IRI node, use the [`send()`]{@link #module_http-client.send} method.
+ *
+ * @method createHttpClient
+ *
+ * @summary Creates an HTTP client to access the IRI API.
+ *
+ * @memberof module:http-client
+ *
+ * @param {Object} [settings={}]
+ * @param {String} [settings.provider=http://localhost:14265] URI of an IRI node to connect to
+ * @param {String | number} [settings.apiVersion=1] - IOTA API version to be sent in the `X-IOTA-API-Version` header.
+ * @param {number} [settings.requestBatchSize=1000] - Number of search values per request
+ *
+ * @example
+ * ```js
+ * let settings = {
+ * provider: 'http://mynode.eu:14265'
+ * }
+ *
+ * let httpClient = HttpClient.createHttpClient(settings);
+ * ```
+ *
+ * @return HTTP client object
+ */
+exports.createHttpClient = function (settings) {
+ var currentSettings = settings_1.getSettingsWithDefaults(__assign({}, settings));
+ return {
+ /**
+ * This method uses the HTTP client to send requests to the [IRI API endpoints](https://docs.iota.org/docs/node-software/0.1/iri/references/api-reference).
+ *
+ * ## Related methods
+ *
+ * To create an HTTP client, use the [`createHttpClient()`]{@link #module_http-client.createHttpClient} method.
+ *
+ * @method createHttpClient
+ *
+ * @summary Sends an API request to the connected IRI node.
+ *
+ * @param {Object} command - The request body for the API endpoint
+ *
+ * @example
+ * ```js
+ * let httpClient = HttpClient.createHttpClient(settings);
+ * httpClient.send({command:'getNodeInfo'})
+ * .then(response => {
+ * console.log(response);
+ * })
+ * .catch(error => {
+ * console.log(error);
+ * })
+ * ```
+ *
+ * @return {Promise}
+ *
+ * @fulfil {Object} response - The response from the IRI node
+ *
+ * @reject {Object} error - The connected IOTA node's API returned an error. See the [list of error messages](https://docs.iota.org/docs/node-software/0.1/iri/references/api-errors)
+ */
+ send: function (command) {
+ return Promise["try"](function () {
+ var provider = currentSettings.provider, user = currentSettings.user, password = currentSettings.password, requestBatchSize = currentSettings.requestBatchSize, apiVersion = currentSettings.apiVersion, agent = currentSettings.agent;
+ if (exports.isBatchableCommand(command)) {
+ var keysToBatch = exports.getKeysToBatch(command, requestBatchSize);
+ if (keysToBatch.length) {
+ return request_1.batchedSend({ command: command, uri: provider, user: user, password: password, apiVersion: apiVersion, agent: agent }, keysToBatch, requestBatchSize);
+ }
+ }
+ return request_1.send({ command: command, uri: provider, user: user, password: password, apiVersion: apiVersion, agent: agent });
+ });
+ },
+ /**
+ * This method updates the settings of an existing HTTP client.
+ *
+ * ## Related methods
+ *
+ * To create an HTTP client, use the [`createHttpClient()`]{@link #module_http-client.createHttpClient} method.
+ *
+ * @method setSettings
+ *
+ * @summary Updates the settings of an existing HTTP client.
+ *
+ * @param {Object} [settings={}]
+ * @param {String} [settings.provider=http://localhost:14265] URI of an IRI node to connect to
+ * @param {String | number} [settings.apiVersion=1] - IOTA API version to be sent in the `X-IOTA-API-Version` header.
+ * @param {number} [settings.requestBatchSize=1000] - Number of search values per request.
+ *
+ * @example
+ * ```js
+ * let settings = {
+ * provider: 'https://nodes.devnet.thetangle.org:443'
+ * }
+ *
+ * let httpClient = http.createHttpClient(settings);
+ * httpClient.send({command:'getNodeInfo'}).then(res => {
+ * console.log(res)
+ * }).catch(err => {
+ * console.log(err)
+ * });
+ *
+ * httpClient.setSettings({provider:'http://newnode.org:14265'});
+ *
+ * httpClient.send({command:'getNodeInfo'}).then(res => {
+ * console.log(res)
+ * }).catch(err => {
+ * console.log(err)
+ * })
+ * ```
+ *
+ * @return {void}
+ */
+ setSettings: function (newSettings) {
+ currentSettings = settings_1.getSettingsWithDefaults(__assign({}, currentSettings, newSettings));
+ }
+ };
+};
+//# sourceMappingURL=httpClient.js.map
/***/ }),
-/* 391 */,
-/* 392 */,
-/* 393 */,
-/* 394 */,
-/* 395 */,
-/* 396 */,
/* 397 */
/***/ (function(__unusedmodule, exports) {
@@ -13004,39 +13096,100 @@ exports.createAttachToTangle = function (_a) {
/* 408 */
/***/ (function(module, exports, __webpack_require__) {
+/* eslint-env browser */
+
/**
* This is the web browser implementation of `debug()`.
- *
- * Expose `debug()` as the module.
*/
-exports = module.exports = __webpack_require__(25);
exports.log = log;
exports.formatArgs = formatArgs;
exports.save = save;
exports.load = load;
exports.useColors = useColors;
-exports.storage = 'undefined' != typeof chrome
- && 'undefined' != typeof chrome.storage
- ? chrome.storage.local
- : localstorage();
+exports.storage = localstorage();
/**
* Colors.
*/
exports.colors = [
- '#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC',
- '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF',
- '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC',
- '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF',
- '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC',
- '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033',
- '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366',
- '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933',
- '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC',
- '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF',
- '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'
+ '#0000CC',
+ '#0000FF',
+ '#0033CC',
+ '#0033FF',
+ '#0066CC',
+ '#0066FF',
+ '#0099CC',
+ '#0099FF',
+ '#00CC00',
+ '#00CC33',
+ '#00CC66',
+ '#00CC99',
+ '#00CCCC',
+ '#00CCFF',
+ '#3300CC',
+ '#3300FF',
+ '#3333CC',
+ '#3333FF',
+ '#3366CC',
+ '#3366FF',
+ '#3399CC',
+ '#3399FF',
+ '#33CC00',
+ '#33CC33',
+ '#33CC66',
+ '#33CC99',
+ '#33CCCC',
+ '#33CCFF',
+ '#6600CC',
+ '#6600FF',
+ '#6633CC',
+ '#6633FF',
+ '#66CC00',
+ '#66CC33',
+ '#9900CC',
+ '#9900FF',
+ '#9933CC',
+ '#9933FF',
+ '#99CC00',
+ '#99CC33',
+ '#CC0000',
+ '#CC0033',
+ '#CC0066',
+ '#CC0099',
+ '#CC00CC',
+ '#CC00FF',
+ '#CC3300',
+ '#CC3333',
+ '#CC3366',
+ '#CC3399',
+ '#CC33CC',
+ '#CC33FF',
+ '#CC6600',
+ '#CC6633',
+ '#CC9900',
+ '#CC9933',
+ '#CCCC00',
+ '#CCCC33',
+ '#FF0000',
+ '#FF0033',
+ '#FF0066',
+ '#FF0099',
+ '#FF00CC',
+ '#FF00FF',
+ '#FF3300',
+ '#FF3333',
+ '#FF3366',
+ '#FF3399',
+ '#FF33CC',
+ '#FF33FF',
+ '#FF6600',
+ '#FF6633',
+ '#FF9900',
+ '#FF9933',
+ '#FFCC00',
+ '#FFCC33'
];
/**
@@ -13047,44 +13200,32 @@ exports.colors = [
* TODO: add a `localStorage` variable to explicitly enable/disable colors
*/
+// eslint-disable-next-line complexity
function useColors() {
- // NB: In an Electron preload script, document will be defined but not fully
- // initialized. Since we know we're in Chrome, we'll just detect this case
- // explicitly
- if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
- return true;
- }
+ // NB: In an Electron preload script, document will be defined but not fully
+ // initialized. Since we know we're in Chrome, we'll just detect this case
+ // explicitly
+ if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
+ return true;
+ }
- // Internet Explorer and Edge do not support colors.
- if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
- return false;
- }
+ // Internet Explorer and Edge do not support colors.
+ if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
+ return false;
+ }
- // is webkit? http://stackoverflow.com/a/16459606/376773
- // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
- return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
- // is firebug? http://stackoverflow.com/a/398120/376773
- (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
- // is firefox >= v31?
- // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
- (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
- // double check webkit in userAgent just in case we are in a worker
- (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
+ // Is webkit? http://stackoverflow.com/a/16459606/376773
+ // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
+ return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
+ // Is firebug? http://stackoverflow.com/a/398120/376773
+ (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
+ // Is firefox >= v31?
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
+ (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
+ // Double check webkit in userAgent just in case we are in a worker
+ (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
}
-/**
- * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
- */
-
-exports.formatters.j = function(v) {
- try {
- return JSON.stringify(v);
- } catch (err) {
- return '[UnexpectedJSONParseError]: ' + err.message;
- }
-};
-
-
/**
* Colorize log arguments if enabled.
*
@@ -13092,36 +13233,38 @@ exports.formatters.j = function(v) {
*/
function formatArgs(args) {
- var useColors = this.useColors;
-
- args[0] = (useColors ? '%c' : '')
- + this.namespace
- + (useColors ? ' %c' : ' ')
- + args[0]
- + (useColors ? '%c ' : ' ')
- + '+' + exports.humanize(this.diff);
-
- if (!useColors) return;
-
- var c = 'color: ' + this.color;
- args.splice(1, 0, c, 'color: inherit')
-
- // the final "%c" is somewhat tricky, because there could be other
- // arguments passed either before or after the %c, so we need to
- // figure out the correct index to insert the CSS into
- var index = 0;
- var lastC = 0;
- args[0].replace(/%[a-zA-Z%]/g, function(match) {
- if ('%%' === match) return;
- index++;
- if ('%c' === match) {
- // we only are interested in the *last* %c
- // (the user may have provided their own)
- lastC = index;
- }
- });
+ args[0] = (this.useColors ? '%c' : '') +
+ this.namespace +
+ (this.useColors ? ' %c' : ' ') +
+ args[0] +
+ (this.useColors ? '%c ' : ' ') +
+ '+' + module.exports.humanize(this.diff);
+
+ if (!this.useColors) {
+ return;
+ }
+
+ const c = 'color: ' + this.color;
+ args.splice(1, 0, c, 'color: inherit');
+
+ // The final "%c" is somewhat tricky, because there could be other
+ // arguments passed either before or after the %c, so we need to
+ // figure out the correct index to insert the CSS into
+ let index = 0;
+ let lastC = 0;
+ args[0].replace(/%[a-zA-Z%]/g, match => {
+ if (match === '%%') {
+ return;
+ }
+ index++;
+ if (match === '%c') {
+ // We only are interested in the *last* %c
+ // (the user may have provided their own)
+ lastC = index;
+ }
+ });
- args.splice(lastC, 0, c);
+ args.splice(lastC, 0, c);
}
/**
@@ -13130,13 +13273,12 @@ function formatArgs(args) {
*
* @api public
*/
-
-function log() {
- // this hackery is required for IE8/9, where
- // the `console.log` function doesn't have 'apply'
- return 'object' === typeof console
- && console.log
- && Function.prototype.apply.call(console.log, console, arguments);
+function log(...args) {
+ // This hackery is required for IE8/9, where
+ // the `console.log` function doesn't have 'apply'
+ return typeof console === 'object' &&
+ console.log &&
+ console.log(...args);
}
/**
@@ -13145,15 +13287,17 @@ function log() {
* @param {String} namespaces
* @api private
*/
-
function save(namespaces) {
- try {
- if (null == namespaces) {
- exports.storage.removeItem('debug');
- } else {
- exports.storage.debug = namespaces;
- }
- } catch(e) {}
+ try {
+ if (namespaces) {
+ exports.storage.setItem('debug', namespaces);
+ } else {
+ exports.storage.removeItem('debug');
+ }
+ } catch (error) {
+ // Swallow
+ // XXX (@Qix-) should we be logging these?
+ }
}
/**
@@ -13162,27 +13306,23 @@ function save(namespaces) {
* @return {String} returns the previously persisted debug modes
* @api private
*/
-
function load() {
- var r;
- try {
- r = exports.storage.debug;
- } catch(e) {}
+ let r;
+ try {
+ r = exports.storage.getItem('debug');
+ } catch (error) {
+ // Swallow
+ // XXX (@Qix-) should we be logging these?
+ }
- // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
- if (!r && typeof process !== 'undefined' && 'env' in process) {
- r = process.env.DEBUG;
- }
+ // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
+ if (!r && typeof process !== 'undefined' && 'env' in process) {
+ r = process.env.DEBUG;
+ }
- return r;
+ return r;
}
-/**
- * Enable namespaces listed in `localStorage.debug` initially.
- */
-
-exports.enable(load());
-
/**
* Localstorage attempts to return the localstorage.
*
@@ -13195,11 +13335,32 @@ exports.enable(load());
*/
function localstorage() {
- try {
- return window.localStorage;
- } catch (e) {}
+ try {
+ // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
+ // The Browser also has localStorage in the global context.
+ return localStorage;
+ } catch (error) {
+ // Swallow
+ // XXX (@Qix-) should we be logging these?
+ }
}
+module.exports = __webpack_require__(486)(exports);
+
+const {formatters} = module.exports;
+
+/**
+ * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
+ */
+
+formatters.j = function (v) {
+ try {
+ return JSON.stringify(v);
+ } catch (error) {
+ return '[UnexpectedJSONParseError]: ' + error.message;
+ }
+};
+
/***/ }),
/* 409 */
@@ -14481,6 +14642,12 @@ function convertBody(buffer, headers) {
// html4
if (!res && str) {
res = / {
+ createDebug[key] = env[key];
+ });
+
+ /**
+ * Active `debug` instances.
+ */
+ createDebug.instances = [];
+
+ /**
+ * The currently active debug mode names, and names to skip.
+ */
+
+ createDebug.names = [];
+ createDebug.skips = [];
+
+ /**
+ * Map of special "%n" handling functions, for the debug "format" argument.
+ *
+ * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
+ */
+ createDebug.formatters = {};
+
+ /**
+ * Selects a color for a debug namespace
+ * @param {String} namespace The namespace string for the for the debug instance to be colored
+ * @return {Number|String} An ANSI color code for the given namespace
+ * @api private
+ */
+ function selectColor(namespace) {
+ let hash = 0;
+
+ for (let i = 0; i < namespace.length; i++) {
+ hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
+ hash |= 0; // Convert to 32bit integer
+ }
+
+ return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
+ }
+ createDebug.selectColor = selectColor;
+
+ /**
+ * Create a debugger with the given `namespace`.
+ *
+ * @param {String} namespace
+ * @return {Function}
+ * @api public
+ */
+ function createDebug(namespace) {
+ let prevTime;
+
+ function debug(...args) {
+ // Disabled?
+ if (!debug.enabled) {
+ return;
+ }
+
+ const self = debug;
+
+ // Set `diff` timestamp
+ const curr = Number(new Date());
+ const ms = curr - (prevTime || curr);
+ self.diff = ms;
+ self.prev = prevTime;
+ self.curr = curr;
+ prevTime = curr;
+
+ args[0] = createDebug.coerce(args[0]);
+
+ if (typeof args[0] !== 'string') {
+ // Anything else let's inspect with %O
+ args.unshift('%O');
+ }
+
+ // Apply any `formatters` transformations
+ let index = 0;
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
+ // If we encounter an escaped % then don't increase the array index
+ if (match === '%%') {
+ return match;
+ }
+ index++;
+ const formatter = createDebug.formatters[format];
+ if (typeof formatter === 'function') {
+ const val = args[index];
+ match = formatter.call(self, val);
+
+ // Now we need to remove `args[index]` since it's inlined in the `format`
+ args.splice(index, 1);
+ index--;
+ }
+ return match;
+ });
+
+ // Apply env-specific formatting (colors, etc.)
+ createDebug.formatArgs.call(self, args);
+
+ const logFn = self.log || createDebug.log;
+ logFn.apply(self, args);
+ }
+
+ debug.namespace = namespace;
+ debug.enabled = createDebug.enabled(namespace);
+ debug.useColors = createDebug.useColors();
+ debug.color = selectColor(namespace);
+ debug.destroy = destroy;
+ debug.extend = extend;
+ // Debug.formatArgs = formatArgs;
+ // debug.rawLog = rawLog;
+
+ // env-specific initialization logic for debug instances
+ if (typeof createDebug.init === 'function') {
+ createDebug.init(debug);
+ }
+
+ createDebug.instances.push(debug);
+
+ return debug;
+ }
+
+ function destroy() {
+ const index = createDebug.instances.indexOf(this);
+ if (index !== -1) {
+ createDebug.instances.splice(index, 1);
+ return true;
+ }
+ return false;
+ }
+
+ function extend(namespace, delimiter) {
+ const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
+ newDebug.log = this.log;
+ return newDebug;
+ }
+
+ /**
+ * Enables a debug mode by namespaces. This can include modes
+ * separated by a colon and wildcards.
+ *
+ * @param {String} namespaces
+ * @api public
+ */
+ function enable(namespaces) {
+ createDebug.save(namespaces);
+
+ createDebug.names = [];
+ createDebug.skips = [];
+
+ let i;
+ const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
+ const len = split.length;
+
+ for (i = 0; i < len; i++) {
+ if (!split[i]) {
+ // ignore empty strings
+ continue;
+ }
+
+ namespaces = split[i].replace(/\*/g, '.*?');
+
+ if (namespaces[0] === '-') {
+ createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
+ } else {
+ createDebug.names.push(new RegExp('^' + namespaces + '$'));
+ }
+ }
+
+ for (i = 0; i < createDebug.instances.length; i++) {
+ const instance = createDebug.instances[i];
+ instance.enabled = createDebug.enabled(instance.namespace);
+ }
+ }
+
+ /**
+ * Disable debug output.
+ *
+ * @return {String} namespaces
+ * @api public
+ */
+ function disable() {
+ const namespaces = [
+ ...createDebug.names.map(toNamespace),
+ ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
+ ].join(',');
+ createDebug.enable('');
+ return namespaces;
+ }
+
+ /**
+ * Returns true if the given mode name is enabled, false otherwise.
+ *
+ * @param {String} name
+ * @return {Boolean}
+ * @api public
+ */
+ function enabled(name) {
+ if (name[name.length - 1] === '*') {
+ return true;
+ }
+
+ let i;
+ let len;
+
+ for (i = 0, len = createDebug.skips.length; i < len; i++) {
+ if (createDebug.skips[i].test(name)) {
+ return false;
+ }
+ }
+
+ for (i = 0, len = createDebug.names.length; i < len; i++) {
+ if (createDebug.names[i].test(name)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Convert regexp to namespace
+ *
+ * @param {RegExp} regxep
+ * @return {String} namespace
+ * @api private
+ */
+ function toNamespace(regexp) {
+ return regexp.toString()
+ .substring(2, regexp.toString().length - 2)
+ .replace(/\.\*\?$/, '*');
+ }
+
+ /**
+ * Coerce `val`.
+ *
+ * @param {Mixed} val
+ * @return {Mixed}
+ * @api private
+ */
+ function coerce(val) {
+ if (val instanceof Error) {
+ return val.stack || val.message;
+ }
+ return val;
+ }
+
+ createDebug.enable(createDebug.load());
+
+ return createDebug;
+}
+
+module.exports = setup;
+
+
+/***/ }),
/* 487 */,
/* 488 */,
/* 489 */,
@@ -17916,6 +18355,7 @@ var defaults = {
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
+ maxBodyLength: -1,
validateStatus: function validateStatus(status) {
return status >= 200 && status < 300;
@@ -19037,46 +19477,52 @@ exports.stringify = function (value) {
/***/ (function(module, __unusedexports, __webpack_require__) {
var url = __webpack_require__(835);
+var URL = url.URL;
var http = __webpack_require__(605);
var https = __webpack_require__(211);
-var assert = __webpack_require__(357);
var Writable = __webpack_require__(794).Writable;
-var debug = __webpack_require__(784)("follow-redirects");
-
-// RFC7231§4.2.1: Of the request methods defined by this specification,
-// the GET, HEAD, OPTIONS, and TRACE methods are defined to be safe.
-var SAFE_METHODS = { GET: true, HEAD: true, OPTIONS: true, TRACE: true };
+var assert = __webpack_require__(357);
+var debug = __webpack_require__(900);
// Create handlers that pass events from native requests
var eventHandlers = Object.create(null);
-["abort", "aborted", "error", "socket", "timeout"].forEach(function (event) {
- eventHandlers[event] = function (arg) {
- this._redirectable.emit(event, arg);
+["abort", "aborted", "connect", "error", "socket", "timeout"].forEach(function (event) {
+ eventHandlers[event] = function (arg1, arg2, arg3) {
+ this._redirectable.emit(event, arg1, arg2, arg3);
};
});
+// Error types with codes
+var RedirectionError = createErrorType(
+ "ERR_FR_REDIRECTION_FAILURE",
+ ""
+);
+var TooManyRedirectsError = createErrorType(
+ "ERR_FR_TOO_MANY_REDIRECTS",
+ "Maximum number of redirects exceeded"
+);
+var MaxBodyLengthExceededError = createErrorType(
+ "ERR_FR_MAX_BODY_LENGTH_EXCEEDED",
+ "Request body larger than maxBodyLength limit"
+);
+var WriteAfterEndError = createErrorType(
+ "ERR_STREAM_WRITE_AFTER_END",
+ "write after end"
+);
+
// An HTTP(S) request that can be redirected
function RedirectableRequest(options, responseCallback) {
// Initialize the request
Writable.call(this);
- options.headers = options.headers || {};
+ this._sanitizeOptions(options);
this._options = options;
+ this._ended = false;
+ this._ending = false;
this._redirectCount = 0;
this._redirects = [];
this._requestBodyLength = 0;
this._requestBodyBuffers = [];
- // Since http.request treats host as an alias of hostname,
- // but the url module interprets host as hostname plus port,
- // eliminate the host property to avoid confusion.
- if (options.host) {
- // Use hostname if set, because it has precedence
- if (!options.hostname) {
- options.hostname = options.host;
- }
- delete options.host;
- }
-
// Attach a callback if passed
if (responseCallback) {
this.on("response", responseCallback);
@@ -19088,18 +19534,6 @@ function RedirectableRequest(options, responseCallback) {
self._processResponse(response);
};
- // Complete the URL object when necessary
- if (!options.pathname && options.path) {
- var searchPos = options.path.indexOf("?");
- if (searchPos < 0) {
- options.pathname = options.path;
- }
- else {
- options.pathname = options.path.substring(0, searchPos);
- options.search = options.path.substring(searchPos);
- }
- }
-
// Perform the first request
this._performRequest();
}
@@ -19107,9 +19541,14 @@ RedirectableRequest.prototype = Object.create(Writable.prototype);
// Writes buffered data to the current native request
RedirectableRequest.prototype.write = function (data, encoding, callback) {
+ // Writing is not allowed if end has been called
+ if (this._ending) {
+ throw new WriteAfterEndError();
+ }
+
// Validate input and shift parameters if necessary
if (!(typeof data === "string" || typeof data === "object" && ("length" in data))) {
- throw new Error("data should be a string, Buffer or Uint8Array");
+ throw new TypeError("data should be a string, Buffer or Uint8Array");
}
if (typeof encoding === "function") {
callback = encoding;
@@ -19132,7 +19571,7 @@ RedirectableRequest.prototype.write = function (data, encoding, callback) {
}
// Error when we exceed the maximum body length
else {
- this.emit("error", new Error("Request body larger than maxBodyLength limit"));
+ this.emit("error", new MaxBodyLengthExceededError());
this.abort();
}
};
@@ -19149,11 +19588,20 @@ RedirectableRequest.prototype.end = function (data, encoding, callback) {
encoding = null;
}
- // Write data and end
- var currentRequest = this._currentRequest;
- this.write(data || "", encoding, function () {
- currentRequest.end(null, null, callback);
- });
+ // Write data if needed and end
+ if (!data) {
+ this._ended = this._ending = true;
+ this._currentRequest.end(null, null, callback);
+ }
+ else {
+ var self = this;
+ var currentRequest = this._currentRequest;
+ this.write(data, encoding, function () {
+ self._ended = true;
+ currentRequest.end(null, null, callback);
+ });
+ this._ending = true;
+ }
};
// Sets a header value on the current native request
@@ -19168,10 +19616,43 @@ RedirectableRequest.prototype.removeHeader = function (name) {
this._currentRequest.removeHeader(name);
};
+// Global timeout for all underlying requests
+RedirectableRequest.prototype.setTimeout = function (msecs, callback) {
+ if (callback) {
+ this.once("timeout", callback);
+ }
+
+ if (this.socket) {
+ startTimer(this, msecs);
+ }
+ else {
+ var self = this;
+ this._currentRequest.once("socket", function () {
+ startTimer(self, msecs);
+ });
+ }
+
+ this.once("response", clearTimer);
+ this.once("error", clearTimer);
+
+ return this;
+};
+
+function startTimer(request, msecs) {
+ clearTimeout(request._timeout);
+ request._timeout = setTimeout(function () {
+ request.emit("timeout");
+ }, msecs);
+}
+
+function clearTimer() {
+ clearTimeout(this._timeout);
+}
+
// Proxy all other public ClientRequest methods
[
"abort", "flushHeaders", "getHeader",
- "setNoDelay", "setSocketKeepAlive", "setTimeout",
+ "setNoDelay", "setSocketKeepAlive",
].forEach(function (method) {
RedirectableRequest.prototype[method] = function (a, b) {
return this._currentRequest[method](a, b);
@@ -19185,13 +19666,44 @@ RedirectableRequest.prototype.removeHeader = function (name) {
});
});
+RedirectableRequest.prototype._sanitizeOptions = function (options) {
+ // Ensure headers are always present
+ if (!options.headers) {
+ options.headers = {};
+ }
+
+ // Since http.request treats host as an alias of hostname,
+ // but the url module interprets host as hostname plus port,
+ // eliminate the host property to avoid confusion.
+ if (options.host) {
+ // Use hostname if set, because it has precedence
+ if (!options.hostname) {
+ options.hostname = options.host;
+ }
+ delete options.host;
+ }
+
+ // Complete the URL object when necessary
+ if (!options.pathname && options.path) {
+ var searchPos = options.path.indexOf("?");
+ if (searchPos < 0) {
+ options.pathname = options.path;
+ }
+ else {
+ options.pathname = options.path.substring(0, searchPos);
+ options.search = options.path.substring(searchPos);
+ }
+ }
+};
+
+
// Executes the next native request (initial or redirect)
RedirectableRequest.prototype._performRequest = function () {
// Load the native protocol
var protocol = this._options.protocol;
var nativeProtocol = this._options.nativeProtocols[protocol];
if (!nativeProtocol) {
- this.emit("error", new Error("Unsupported protocol " + protocol));
+ this.emit("error", new TypeError("Unsupported protocol " + protocol));
return;
}
@@ -19221,14 +19733,29 @@ RedirectableRequest.prototype._performRequest = function () {
if (this._isRedirect) {
// Write the request entity and end.
var i = 0;
+ var self = this;
var buffers = this._requestBodyBuffers;
- (function writeNext() {
- if (i < buffers.length) {
- var buffer = buffers[i++];
- request.write(buffer.data, buffer.encoding, writeNext);
- }
- else {
- request.end();
+ (function writeNext(error) {
+ // Only write if this request has not been redirected yet
+ /* istanbul ignore else */
+ if (request === self._currentRequest) {
+ // Report any write errors
+ /* istanbul ignore if */
+ if (error) {
+ self.emit("error", error);
+ }
+ // Write the next buffer if there are still left
+ else if (i < buffers.length) {
+ var buffer = buffers[i++];
+ /* istanbul ignore else */
+ if (!request.finished) {
+ request.write(buffer.data, buffer.encoding, writeNext);
+ }
+ }
+ // End the request if `end` has been called on us
+ else if (self._ended) {
+ request.end();
+ }
}
}());
}
@@ -19237,11 +19764,12 @@ RedirectableRequest.prototype._performRequest = function () {
// Processes a response from the current native request
RedirectableRequest.prototype._processResponse = function (response) {
// Store the redirected response
+ var statusCode = response.statusCode;
if (this._options.trackRedirects) {
this._redirects.push({
url: this._currentUrl,
headers: response.headers,
- statusCode: response.statusCode,
+ statusCode: statusCode,
});
}
@@ -19253,52 +19781,75 @@ RedirectableRequest.prototype._processResponse = function (response) {
// even if the specific status code is not understood.
var location = response.headers.location;
if (location && this._options.followRedirects !== false &&
- response.statusCode >= 300 && response.statusCode < 400) {
+ statusCode >= 300 && statusCode < 400) {
+ // Abort the current request
+ this._currentRequest.removeAllListeners();
+ this._currentRequest.on("error", noop);
+ this._currentRequest.abort();
+ // Discard the remainder of the response to avoid waiting for data
+ response.destroy();
+
// RFC7231§6.4: A client SHOULD detect and intervene
// in cyclical redirections (i.e., "infinite" redirection loops).
if (++this._redirectCount > this._options.maxRedirects) {
- this.emit("error", new Error("Max redirects exceeded."));
+ this.emit("error", new TooManyRedirectsError());
return;
}
// RFC7231§6.4: Automatic redirection needs to done with
- // care for methods not known to be safe […],
- // since the user might not wish to redirect an unsafe request.
- // RFC7231§6.4.7: The 307 (Temporary Redirect) status code indicates
- // that the target resource resides temporarily under a different URI
- // and the user agent MUST NOT change the request method
- // if it performs an automatic redirection to that URI.
- var header;
- var headers = this._options.headers;
- if (response.statusCode !== 307 && !(this._options.method in SAFE_METHODS)) {
+ // care for methods not known to be safe, […]
+ // RFC7231§6.4.2–3: For historical reasons, a user agent MAY change
+ // the request method from POST to GET for the subsequent request.
+ if ((statusCode === 301 || statusCode === 302) && this._options.method === "POST" ||
+ // RFC7231§6.4.4: The 303 (See Other) status code indicates that
+ // the server is redirecting the user agent to a different resource […]
+ // A user agent can perform a retrieval request targeting that URI
+ // (a GET or HEAD request if using HTTP) […]
+ (statusCode === 303) && !/^(?:GET|HEAD)$/.test(this._options.method)) {
this._options.method = "GET";
// Drop a possible entity and headers related to it
this._requestBodyBuffers = [];
- for (header in headers) {
- if (/^content-/i.test(header)) {
- delete headers[header];
- }
- }
+ removeMatchingHeaders(/^content-/i, this._options.headers);
}
// Drop the Host header, as the redirect might lead to a different host
- if (!this._isRedirect) {
- for (header in headers) {
- if (/^host$/i.test(header)) {
- delete headers[header];
- }
- }
- }
+ var previousHostName = removeMatchingHeaders(/^host$/i, this._options.headers) ||
+ url.parse(this._currentUrl).hostname;
- // Perform the redirected request
+ // Create the redirected request
var redirectUrl = url.resolve(this._currentUrl, location);
debug("redirecting to", redirectUrl);
- Object.assign(this._options, url.parse(redirectUrl));
this._isRedirect = true;
- this._performRequest();
+ var redirectUrlParts = url.parse(redirectUrl);
+ Object.assign(this._options, redirectUrlParts);
- // Discard the remainder of the response to avoid waiting for data
- response.destroy();
+ // Drop the Authorization header if redirecting to another host
+ if (redirectUrlParts.hostname !== previousHostName) {
+ removeMatchingHeaders(/^authorization$/i, this._options.headers);
+ }
+
+ // Evaluate the beforeRedirect callback
+ if (typeof this._options.beforeRedirect === "function") {
+ var responseDetails = { headers: response.headers };
+ try {
+ this._options.beforeRedirect.call(null, this._options, responseDetails);
+ }
+ catch (err) {
+ this.emit("error", err);
+ return;
+ }
+ this._sanitizeOptions(this._options);
+ }
+
+ // Perform the redirected request
+ try {
+ this._performRequest();
+ }
+ catch (cause) {
+ var error = new RedirectionError("Redirected request failed: " + cause.message);
+ error.cause = cause;
+ this.emit("error", error);
+ }
}
else {
// The response is not a redirect; return it as-is
@@ -19327,27 +19878,46 @@ function wrap(protocols) {
var wrappedProtocol = exports[scheme] = Object.create(nativeProtocol);
// Executes a request, following redirects
- wrappedProtocol.request = function (options, callback) {
- if (typeof options === "string") {
- options = url.parse(options);
- options.maxRedirects = exports.maxRedirects;
+ wrappedProtocol.request = function (input, options, callback) {
+ // Parse parameters
+ if (typeof input === "string") {
+ var urlStr = input;
+ try {
+ input = urlToOptions(new URL(urlStr));
+ }
+ catch (err) {
+ /* istanbul ignore next */
+ input = url.parse(urlStr);
+ }
+ }
+ else if (URL && (input instanceof URL)) {
+ input = urlToOptions(input);
}
else {
- options = Object.assign({
- protocol: protocol,
- maxRedirects: exports.maxRedirects,
- maxBodyLength: exports.maxBodyLength,
- }, options);
+ callback = options;
+ options = input;
+ input = { protocol: protocol };
+ }
+ if (typeof options === "function") {
+ callback = options;
+ options = null;
}
+
+ // Set defaults
+ options = Object.assign({
+ maxRedirects: exports.maxRedirects,
+ maxBodyLength: exports.maxBodyLength,
+ }, input, options);
options.nativeProtocols = nativeProtocols;
+
assert.equal(options.protocol, protocol, "protocol mismatch");
debug("options", options);
return new RedirectableRequest(options, callback);
};
// Executes a GET request, following redirects
- wrappedProtocol.get = function (options, callback) {
- var request = wrappedProtocol.request(options, callback);
+ wrappedProtocol.get = function (input, options, callback) {
+ var request = wrappedProtocol.request(input, options, callback);
request.end();
return request;
};
@@ -19355,6 +19925,52 @@ function wrap(protocols) {
return exports;
}
+/* istanbul ignore next */
+function noop() { /* empty */ }
+
+// from https://github.com/nodejs/node/blob/master/lib/internal/url.js
+function urlToOptions(urlObject) {
+ var options = {
+ protocol: urlObject.protocol,
+ hostname: urlObject.hostname.startsWith("[") ?
+ /* istanbul ignore next */
+ urlObject.hostname.slice(1, -1) :
+ urlObject.hostname,
+ hash: urlObject.hash,
+ search: urlObject.search,
+ pathname: urlObject.pathname,
+ path: urlObject.pathname + urlObject.search,
+ href: urlObject.href,
+ };
+ if (urlObject.port !== "") {
+ options.port = Number(urlObject.port);
+ }
+ return options;
+}
+
+function removeMatchingHeaders(regex, headers) {
+ var lastValue;
+ for (var header in headers) {
+ if (regex.test(header)) {
+ lastValue = headers[header];
+ delete headers[header];
+ }
+ }
+ return lastValue;
+}
+
+function createErrorType(code, defaultMessage) {
+ function CustomError(message) {
+ Error.captureStackTrace(this, this.constructor);
+ this.message = message || defaultMessage;
+ }
+ CustomError.prototype = new Error();
+ CustomError.prototype.constructor = CustomError;
+ CustomError.prototype.name = "Error [" + code + "]";
+ CustomError.prototype.code = code;
+ return CustomError;
+}
+
// Exports
module.exports = wrap({ http: http, https: https });
module.exports.wrap = wrap;
@@ -19756,7 +20372,7 @@ var createError = __webpack_require__(26);
*/
module.exports = function settle(resolve, reject, response) {
var validateStatus = response.config.validateStatus;
- if (!validateStatus || validateStatus(response.status)) {
+ if (!response.status || !validateStatus || validateStatus(response.status)) {
resolve(response);
} else {
reject(createError(
@@ -21096,8 +21712,8 @@ module.exports = function httpAdapter(config) {
transport = isHttpsProxy ? httpsFollow : httpFollow;
}
- if (config.maxContentLength && config.maxContentLength > -1) {
- options.maxBodyLength = config.maxContentLength;
+ if (config.maxBodyLength > -1) {
+ options.maxBodyLength = config.maxBodyLength;
}
// Create the request
@@ -21106,22 +21722,27 @@ module.exports = function httpAdapter(config) {
// uncompress the response body transparently if required
var stream = res;
- switch (res.headers['content-encoding']) {
- /*eslint default-case:0*/
- case 'gzip':
- case 'compress':
- case 'deflate':
- // add the unzipper to the body stream processing pipeline
- stream = (res.statusCode === 204) ? stream : stream.pipe(zlib.createUnzip());
-
- // remove the content-encoding in order to not confuse downstream operations
- delete res.headers['content-encoding'];
- break;
- }
// return the last request in case of redirects
var lastRequest = res.req || req;
+
+ // if no content, is HEAD request or decompress disabled we should not decompress
+ if (res.statusCode !== 204 && lastRequest.method !== 'HEAD' && config.decompress !== false) {
+ switch (res.headers['content-encoding']) {
+ /*eslint default-case:0*/
+ case 'gzip':
+ case 'compress':
+ case 'deflate':
+ // add the unzipper to the body stream processing pipeline
+ stream = stream.pipe(zlib.createUnzip());
+
+ // remove the content-encoding in order to not confuse downstream operations
+ delete res.headers['content-encoding'];
+ break;
+ }
+ }
+
var response = {
status: res.statusCode,
statusText: res.statusMessage,
@@ -21155,6 +21776,9 @@ module.exports = function httpAdapter(config) {
var responseData = Buffer.concat(responseBuffer);
if (config.responseType !== 'arraybuffer') {
responseData = responseData.toString(config.responseEncoding);
+ if (!config.responseEncoding || config.responseEncoding === 'utf8') {
+ responseData = utils.stripBOM(responseData);
+ }
}
response.data = responseData;
@@ -21165,7 +21789,7 @@ module.exports = function httpAdapter(config) {
// Handle errors
req.on('error', function handleRequestError(err) {
- if (req.aborted) return;
+ if (req.aborted && err.code !== 'ERR_FR_TOO_MANY_REDIRECTS') return;
reject(enhanceError(err, config, null, req));
});
@@ -21667,244 +22291,52 @@ exports.INVALID_ASCII_INPUT = 'Conversion to trytes requires type of input to be
exports.INVALID_ODD_LENGTH = 'Conversion from trytes requires length of trytes to be even.';
exports.INVALID_TRYTE_ENCODED_JSON = 'Invalid tryte encoded JSON message';
exports.NOT_INT = 'One of the inputs is not integer';
-exports.SENDING_BACK_TO_INPUTS = 'One of the transaction inputs is used as output.';
-exports.INVALID_TRANSACTIONS_TO_APPROVE = 'Invalid transactions to approve.';
-exports.NO_INPUTS = 'Could not find any available inputs.';
-exports.invalidChecksum = function (address) { return "Invalid Checksum: " + address; };
-exports.inconsistentTransaction = function (reason) { return "Transaction is inconsistent. Reason: " + reason; };
-exports.INVALID_DELAY = 'Invalid delay.';
-//# sourceMappingURL=errors.js.map
-
-/***/ }),
-/* 690 */,
-/* 691 */
-/***/ (function(module, __unusedexports, __webpack_require__) {
-
-"use strict";
-
-module.exports = function(Promise,
- apiRejection,
- INTERNAL,
- tryConvertToPromise,
- Proxyable,
- debug) {
-var errors = __webpack_require__(607);
-var TypeError = errors.TypeError;
-var util = __webpack_require__(248);
-var errorObj = util.errorObj;
-var tryCatch = util.tryCatch;
-var yieldHandlers = [];
-
-function promiseFromYieldHandler(value, yieldHandlers, traceParent) {
- for (var i = 0; i < yieldHandlers.length; ++i) {
- traceParent._pushContext();
- var result = tryCatch(yieldHandlers[i])(value);
- traceParent._popContext();
- if (result === errorObj) {
- traceParent._pushContext();
- var ret = Promise.reject(errorObj.e);
- traceParent._popContext();
- return ret;
- }
- var maybePromise = tryConvertToPromise(result, traceParent);
- if (maybePromise instanceof Promise) return maybePromise;
- }
- return null;
-}
-
-function PromiseSpawn(generatorFunction, receiver, yieldHandler, stack) {
- if (debug.cancellation()) {
- var internal = new Promise(INTERNAL);
- var _finallyPromise = this._finallyPromise = new Promise(INTERNAL);
- this._promise = internal.lastly(function() {
- return _finallyPromise;
- });
- internal._captureStackTrace();
- internal._setOnCancel(this);
- } else {
- var promise = this._promise = new Promise(INTERNAL);
- promise._captureStackTrace();
- }
- this._stack = stack;
- this._generatorFunction = generatorFunction;
- this._receiver = receiver;
- this._generator = undefined;
- this._yieldHandlers = typeof yieldHandler === "function"
- ? [yieldHandler].concat(yieldHandlers)
- : yieldHandlers;
- this._yieldedPromise = null;
- this._cancellationPhase = false;
-}
-util.inherits(PromiseSpawn, Proxyable);
-
-PromiseSpawn.prototype._isResolved = function() {
- return this._promise === null;
-};
-
-PromiseSpawn.prototype._cleanup = function() {
- this._promise = this._generator = null;
- if (debug.cancellation() && this._finallyPromise !== null) {
- this._finallyPromise._fulfill();
- this._finallyPromise = null;
- }
-};
-
-PromiseSpawn.prototype._promiseCancelled = function() {
- if (this._isResolved()) return;
- var implementsReturn = typeof this._generator["return"] !== "undefined";
-
- var result;
- if (!implementsReturn) {
- var reason = new Promise.CancellationError(
- "generator .return() sentinel");
- Promise.coroutine.returnSentinel = reason;
- this._promise._attachExtraTrace(reason);
- this._promise._pushContext();
- result = tryCatch(this._generator["throw"]).call(this._generator,
- reason);
- this._promise._popContext();
- } else {
- this._promise._pushContext();
- result = tryCatch(this._generator["return"]).call(this._generator,
- undefined);
- this._promise._popContext();
- }
- this._cancellationPhase = true;
- this._yieldedPromise = null;
- this._continue(result);
-};
-
-PromiseSpawn.prototype._promiseFulfilled = function(value) {
- this._yieldedPromise = null;
- this._promise._pushContext();
- var result = tryCatch(this._generator.next).call(this._generator, value);
- this._promise._popContext();
- this._continue(result);
-};
-
-PromiseSpawn.prototype._promiseRejected = function(reason) {
- this._yieldedPromise = null;
- this._promise._attachExtraTrace(reason);
- this._promise._pushContext();
- var result = tryCatch(this._generator["throw"])
- .call(this._generator, reason);
- this._promise._popContext();
- this._continue(result);
-};
+exports.SENDING_BACK_TO_INPUTS = 'One of the transaction inputs is used as output.';
+exports.INVALID_TRANSACTIONS_TO_APPROVE = 'Invalid transactions to approve.';
+exports.NO_INPUTS = 'Could not find any available inputs.';
+exports.invalidChecksum = function (address) { return "Invalid Checksum: " + address; };
+exports.inconsistentTransaction = function (reason) { return "Transaction is inconsistent. Reason: " + reason; };
+exports.INVALID_DELAY = 'Invalid delay.';
+//# sourceMappingURL=errors.js.map
-PromiseSpawn.prototype._resultCancelled = function() {
- if (this._yieldedPromise instanceof Promise) {
- var promise = this._yieldedPromise;
- this._yieldedPromise = null;
- promise.cancel();
- }
-};
+/***/ }),
+/* 690 */,
+/* 691 */
+/***/ (function(module, exports, __webpack_require__) {
-PromiseSpawn.prototype.promise = function () {
- return this._promise;
-};
+;(function (root, factory, undef) {
+ if (true) {
+ // CommonJS
+ module.exports = exports = factory(__webpack_require__(802), __webpack_require__(313));
+ }
+ else {}
+}(this, function (CryptoJS) {
-PromiseSpawn.prototype._run = function () {
- this._generator = this._generatorFunction.call(this._receiver);
- this._receiver =
- this._generatorFunction = undefined;
- this._promiseFulfilled(undefined);
-};
+ /**
+ * ISO/IEC 9797-1 Padding Method 2.
+ */
+ CryptoJS.pad.Iso97971 = {
+ pad: function (data, blockSize) {
+ // Add 0x80 byte
+ data.concat(CryptoJS.lib.WordArray.create([0x80000000], 1));
-PromiseSpawn.prototype._continue = function (result) {
- var promise = this._promise;
- if (result === errorObj) {
- this._cleanup();
- if (this._cancellationPhase) {
- return promise.cancel();
- } else {
- return promise._rejectCallback(result.e, false);
- }
- }
+ // Zero pad the rest
+ CryptoJS.pad.ZeroPadding.pad(data, blockSize);
+ },
- var value = result.value;
- if (result.done === true) {
- this._cleanup();
- if (this._cancellationPhase) {
- return promise.cancel();
- } else {
- return promise._resolveCallback(value);
- }
- } else {
- var maybePromise = tryConvertToPromise(value, this._promise);
- if (!(maybePromise instanceof Promise)) {
- maybePromise =
- promiseFromYieldHandler(maybePromise,
- this._yieldHandlers,
- this._promise);
- if (maybePromise === null) {
- this._promiseRejected(
- new TypeError(
- "A value %s was yielded that could not be treated as a promise\u000a\u000a See http://goo.gl/MqrFmX\u000a\u000a".replace("%s", String(value)) +
- "From coroutine:\u000a" +
- this._stack.split("\n").slice(1, -7).join("\n")
- )
- );
- return;
- }
- }
- maybePromise = maybePromise._target();
- var bitField = maybePromise._bitField;
- ;
- if (((bitField & 50397184) === 0)) {
- this._yieldedPromise = maybePromise;
- maybePromise._proxy(this, null);
- } else if (((bitField & 33554432) !== 0)) {
- Promise._async.invoke(
- this._promiseFulfilled, this, maybePromise._value()
- );
- } else if (((bitField & 16777216) !== 0)) {
- Promise._async.invoke(
- this._promiseRejected, this, maybePromise._reason()
- );
- } else {
- this._promiseCancelled();
- }
- }
-};
+ unpad: function (data) {
+ // Remove zero padding
+ CryptoJS.pad.ZeroPadding.unpad(data);
-Promise.coroutine = function (generatorFunction, options) {
- if (typeof generatorFunction !== "function") {
- throw new TypeError("generatorFunction must be a function\u000a\u000a See http://goo.gl/MqrFmX\u000a");
- }
- var yieldHandler = Object(options).yieldHandler;
- var PromiseSpawn$ = PromiseSpawn;
- var stack = new Error().stack;
- return function () {
- var generator = generatorFunction.apply(this, arguments);
- var spawn = new PromiseSpawn$(undefined, undefined, yieldHandler,
- stack);
- var ret = spawn.promise();
- spawn._generator = generator;
- spawn._promiseFulfilled(undefined);
- return ret;
- };
-};
+ // Remove one more byte -- the 0x80 byte
+ data.sigBytes--;
+ }
+ };
-Promise.coroutine.addYieldHandler = function(fn) {
- if (typeof fn !== "function") {
- throw new TypeError("expecting a function but got " + util.classString(fn));
- }
- yieldHandlers.push(fn);
-};
-Promise.spawn = function (generatorFunction) {
- debug.deprecated("Promise.spawn()", "Promise.coroutine()");
- if (typeof generatorFunction !== "function") {
- return apiRejection("generatorFunction must be a function\u000a\u000a See http://goo.gl/MqrFmX\u000a");
- }
- var spawn = new PromiseSpawn(generatorFunction, this);
- var ret = spawn.promise();
- spawn._run(Promise.spawn);
- return ret;
-};
-};
+ return CryptoJS.pad.Iso97971;
+}));
/***/ }),
/* 692 */
@@ -23931,7 +24363,7 @@ Axios.prototype.getUri = function getUri(config) {
utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
/*eslint func-names:0*/
Axios.prototype[method] = function(url, config) {
- return this.request(utils.merge(config || {}, {
+ return this.request(mergeConfig(config || {}, {
method: method,
url: url
}));
@@ -23941,7 +24373,7 @@ utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
/*eslint func-names:0*/
Axios.prototype[method] = function(url, data, config) {
- return this.request(utils.merge(config || {}, {
+ return this.request(mergeConfig(config || {}, {
method: method,
url: url,
data: data
@@ -24262,14 +24694,14 @@ exports.createGetTransactionObjects = function (provider) {
/***/ (function(module, __unusedexports, __webpack_require__) {
/**
- * Detect Electron renderer process, which is node, but we should
+ * Detect Electron renderer / nwjs process, which is node, but we should
* treat as a browser.
*/
-if (typeof process === 'undefined' || process.type === 'renderer') {
- module.exports = __webpack_require__(408);
+if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
+ module.exports = __webpack_require__(408);
} else {
- module.exports = __webpack_require__(81);
+ module.exports = __webpack_require__(81);
}
@@ -24280,7 +24712,7 @@ if (typeof process === 'undefined' || process.type === 'renderer') {
;(function (root, factory, undef) {
if (true) {
// CommonJS
- module.exports = exports = factory(__webpack_require__(802), __webpack_require__(899), __webpack_require__(61), __webpack_require__(336), __webpack_require__(174), __webpack_require__(367), __webpack_require__(169), __webpack_require__(834), __webpack_require__(919), __webpack_require__(735), __webpack_require__(134), __webpack_require__(818), __webpack_require__(509), __webpack_require__(340), __webpack_require__(154), __webpack_require__(988), __webpack_require__(313), __webpack_require__(786), __webpack_require__(20), __webpack_require__(261), __webpack_require__(354), __webpack_require__(387), __webpack_require__(205), __webpack_require__(0), __webpack_require__(973), __webpack_require__(673), __webpack_require__(723), __webpack_require__(712), __webpack_require__(177), __webpack_require__(110), __webpack_require__(905), __webpack_require__(507), __webpack_require__(975));
+ module.exports = exports = factory(__webpack_require__(802), __webpack_require__(899), __webpack_require__(61), __webpack_require__(336), __webpack_require__(174), __webpack_require__(367), __webpack_require__(169), __webpack_require__(834), __webpack_require__(919), __webpack_require__(735), __webpack_require__(134), __webpack_require__(818), __webpack_require__(509), __webpack_require__(340), __webpack_require__(154), __webpack_require__(988), __webpack_require__(313), __webpack_require__(786), __webpack_require__(20), __webpack_require__(261), __webpack_require__(354), __webpack_require__(387), __webpack_require__(205), __webpack_require__(0), __webpack_require__(691), __webpack_require__(673), __webpack_require__(723), __webpack_require__(712), __webpack_require__(177), __webpack_require__(110), __webpack_require__(905), __webpack_require__(507), __webpack_require__(975));
}
else {}
}(this, function (CryptoJS) {
@@ -26555,59 +26987,73 @@ module.exports = function mergeConfig(config1, config2) {
config2 = config2 || {};
var config = {};
- var valueFromConfig2Keys = ['url', 'method', 'params', 'data'];
- var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy'];
+ var valueFromConfig2Keys = ['url', 'method', 'data'];
+ var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params'];
var defaultToConfig2Keys = [
- 'baseURL', 'url', 'transformRequest', 'transformResponse', 'paramsSerializer',
- 'timeout', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
- 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress',
- 'maxContentLength', 'validateStatus', 'maxRedirects', 'httpAgent',
- 'httpsAgent', 'cancelToken', 'socketPath'
+ 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
+ 'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
+ 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress',
+ 'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent',
+ 'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding'
];
+ var directMergeKeys = ['validateStatus'];
+
+ function getMergedValue(target, source) {
+ if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
+ return utils.merge(target, source);
+ } else if (utils.isPlainObject(source)) {
+ return utils.merge({}, source);
+ } else if (utils.isArray(source)) {
+ return source.slice();
+ }
+ return source;
+ }
+
+ function mergeDeepProperties(prop) {
+ if (!utils.isUndefined(config2[prop])) {
+ config[prop] = getMergedValue(config1[prop], config2[prop]);
+ } else if (!utils.isUndefined(config1[prop])) {
+ config[prop] = getMergedValue(undefined, config1[prop]);
+ }
+ }
utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
- if (typeof config2[prop] !== 'undefined') {
- config[prop] = config2[prop];
+ if (!utils.isUndefined(config2[prop])) {
+ config[prop] = getMergedValue(undefined, config2[prop]);
}
});
- utils.forEach(mergeDeepPropertiesKeys, function mergeDeepProperties(prop) {
- if (utils.isObject(config2[prop])) {
- config[prop] = utils.deepMerge(config1[prop], config2[prop]);
- } else if (typeof config2[prop] !== 'undefined') {
- config[prop] = config2[prop];
- } else if (utils.isObject(config1[prop])) {
- config[prop] = utils.deepMerge(config1[prop]);
- } else if (typeof config1[prop] !== 'undefined') {
- config[prop] = config1[prop];
+ utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties);
+
+ utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
+ if (!utils.isUndefined(config2[prop])) {
+ config[prop] = getMergedValue(undefined, config2[prop]);
+ } else if (!utils.isUndefined(config1[prop])) {
+ config[prop] = getMergedValue(undefined, config1[prop]);
}
});
- utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
- if (typeof config2[prop] !== 'undefined') {
- config[prop] = config2[prop];
- } else if (typeof config1[prop] !== 'undefined') {
- config[prop] = config1[prop];
+ utils.forEach(directMergeKeys, function merge(prop) {
+ if (prop in config2) {
+ config[prop] = getMergedValue(config1[prop], config2[prop]);
+ } else if (prop in config1) {
+ config[prop] = getMergedValue(undefined, config1[prop]);
}
});
var axiosKeys = valueFromConfig2Keys
.concat(mergeDeepPropertiesKeys)
- .concat(defaultToConfig2Keys);
+ .concat(defaultToConfig2Keys)
+ .concat(directMergeKeys);
var otherKeys = Object
- .keys(config2)
+ .keys(config1)
+ .concat(Object.keys(config2))
.filter(function filterAxiosKeys(key) {
return axiosKeys.indexOf(key) === -1;
});
- utils.forEach(otherKeys, function otherKeysDefaultToConfig2(prop) {
- if (typeof config2[prop] !== 'undefined') {
- config[prop] = config2[prop];
- } else if (typeof config1[prop] !== 'undefined') {
- config[prop] = config1[prop];
- }
- });
+ utils.forEach(otherKeys, mergeDeepProperties);
return config;
};
@@ -28478,15 +28924,182 @@ function isBundle(bundle) {
}
return exports.validateBundleSignatures(bundle);
}
-exports["default"] = isBundle;
-exports.bundleValidator = function (bundle) { return [bundle, isBundle, errors_1.INVALID_BUNDLE]; };
-//# sourceMappingURL=index.js.map
+exports["default"] = isBundle;
+exports.bundleValidator = function (bundle) { return [bundle, isBundle, errors_1.INVALID_BUNDLE]; };
+//# sourceMappingURL=index.js.map
+
+/***/ }),
+/* 851 */,
+/* 852 */,
+/* 853 */,
+/* 854 */
+/***/ (function(module) {
+
+/**
+ * Helpers.
+ */
+
+var s = 1000;
+var m = s * 60;
+var h = m * 60;
+var d = h * 24;
+var w = d * 7;
+var y = d * 365.25;
+
+/**
+ * Parse or format the given `val`.
+ *
+ * Options:
+ *
+ * - `long` verbose formatting [false]
+ *
+ * @param {String|Number} val
+ * @param {Object} [options]
+ * @throws {Error} throw an error if val is not a non-empty string or a number
+ * @return {String|Number}
+ * @api public
+ */
+
+module.exports = function(val, options) {
+ options = options || {};
+ var type = typeof val;
+ if (type === 'string' && val.length > 0) {
+ return parse(val);
+ } else if (type === 'number' && isFinite(val)) {
+ return options.long ? fmtLong(val) : fmtShort(val);
+ }
+ throw new Error(
+ 'val is not a non-empty string or a valid number. val=' +
+ JSON.stringify(val)
+ );
+};
+
+/**
+ * Parse the given `str` and return milliseconds.
+ *
+ * @param {String} str
+ * @return {Number}
+ * @api private
+ */
+
+function parse(str) {
+ str = String(str);
+ if (str.length > 100) {
+ return;
+ }
+ var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
+ str
+ );
+ if (!match) {
+ return;
+ }
+ var n = parseFloat(match[1]);
+ var type = (match[2] || 'ms').toLowerCase();
+ switch (type) {
+ case 'years':
+ case 'year':
+ case 'yrs':
+ case 'yr':
+ case 'y':
+ return n * y;
+ case 'weeks':
+ case 'week':
+ case 'w':
+ return n * w;
+ case 'days':
+ case 'day':
+ case 'd':
+ return n * d;
+ case 'hours':
+ case 'hour':
+ case 'hrs':
+ case 'hr':
+ case 'h':
+ return n * h;
+ case 'minutes':
+ case 'minute':
+ case 'mins':
+ case 'min':
+ case 'm':
+ return n * m;
+ case 'seconds':
+ case 'second':
+ case 'secs':
+ case 'sec':
+ case 's':
+ return n * s;
+ case 'milliseconds':
+ case 'millisecond':
+ case 'msecs':
+ case 'msec':
+ case 'ms':
+ return n;
+ default:
+ return undefined;
+ }
+}
+
+/**
+ * Short format for `ms`.
+ *
+ * @param {Number} ms
+ * @return {String}
+ * @api private
+ */
+
+function fmtShort(ms) {
+ var msAbs = Math.abs(ms);
+ if (msAbs >= d) {
+ return Math.round(ms / d) + 'd';
+ }
+ if (msAbs >= h) {
+ return Math.round(ms / h) + 'h';
+ }
+ if (msAbs >= m) {
+ return Math.round(ms / m) + 'm';
+ }
+ if (msAbs >= s) {
+ return Math.round(ms / s) + 's';
+ }
+ return ms + 'ms';
+}
+
+/**
+ * Long format for `ms`.
+ *
+ * @param {Number} ms
+ * @return {String}
+ * @api private
+ */
+
+function fmtLong(ms) {
+ var msAbs = Math.abs(ms);
+ if (msAbs >= d) {
+ return plural(ms, msAbs, d, 'day');
+ }
+ if (msAbs >= h) {
+ return plural(ms, msAbs, h, 'hour');
+ }
+ if (msAbs >= m) {
+ return plural(ms, msAbs, m, 'minute');
+ }
+ if (msAbs >= s) {
+ return plural(ms, msAbs, s, 'second');
+ }
+ return ms + ' ms';
+}
+
+/**
+ * Pluralization helper.
+ */
+
+function plural(ms, msAbs, n, name) {
+ var isPlural = msAbs >= n * 1.5;
+ return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
+}
+
/***/ }),
-/* 851 */,
-/* 852 */,
-/* 853 */,
-/* 854 */,
/* 855 */,
/* 856 */,
/* 857 */
@@ -29640,171 +30253,18 @@ exports.withCustomRequest = withCustomRequest;
/***/ }),
/* 900 */
-/***/ (function(__unusedmodule, exports, __webpack_require__) {
+/***/ (function(module, __unusedexports, __webpack_require__) {
-"use strict";
+var debug;
+try {
+ /* eslint global-require: off */
+ debug = __webpack_require__(784)("follow-redirects");
+}
+catch (error) {
+ debug = function () { /* */ };
+}
+module.exports = debug;
-/** @module http-client */
-var __assign = (this && this.__assign) || function () {
- __assign = Object.assign || function(t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
- t[p] = s[p];
- }
- return t;
- };
- return __assign.apply(this, arguments);
-};
-exports.__esModule = true;
-var _a;
-var Promise = __webpack_require__(440);
-var types_1 = __webpack_require__(833);
-var request_1 = __webpack_require__(633);
-var settings_1 = __webpack_require__(969);
-var BATCH_SIZE = 1000;
-/* Batchable keys for each command */
-exports.batchableKeys = (_a = {},
- _a[types_1.IRICommand.FIND_TRANSACTIONS] = ['addresses', 'approvees', 'bundles', 'tags'],
- _a[types_1.IRICommand.GET_BALANCES] = ['addresses'],
- _a[types_1.IRICommand.GET_INCLUSION_STATES] = ['tips', 'transactions'],
- _a[types_1.IRICommand.GET_TRYTES] = ['hashes'],
- _a);
-exports.isBatchableCommand = function (command) {
- return command.command === types_1.IRICommand.FIND_TRANSACTIONS ||
- command.command === types_1.IRICommand.GET_BALANCES ||
- command.command === types_1.IRICommand.GET_INCLUSION_STATES ||
- command.command === types_1.IRICommand.GET_TRYTES;
-};
-exports.getKeysToBatch = function (command, batchSize) {
- if (batchSize === void 0) { batchSize = BATCH_SIZE; }
- return Object.keys(command).filter(function (key) {
- return exports.batchableKeys[command.command].indexOf(key) > -1 &&
- Array.isArray(command[key]) &&
- command[key].length > batchSize;
- });
-};
-/**
- * This method creates an HTTP client that you can use to send requests to the [IRI API endpoints](https://docs.iota.org/docs/node-software/0.1/iri/references/api-reference).
- *
- * ## Related methods
- *
- * To send requests to the IRI node, use the [`send()`]{@link #module_http-client.send} method.
- *
- * @method createHttpClient
- *
- * @summary Creates an HTTP client to access the IRI API.
- *
- * @memberof module:http-client
- *
- * @param {Object} [settings={}]
- * @param {String} [settings.provider=http://localhost:14265] URI of an IRI node to connect to
- * @param {String | number} [settings.apiVersion=1] - IOTA API version to be sent in the `X-IOTA-API-Version` header.
- * @param {number} [settings.requestBatchSize=1000] - Number of search values per request
- *
- * @example
- * ```js
- * let settings = {
- * provider: 'http://mynode.eu:14265'
- * }
- *
- * let httpClient = HttpClient.createHttpClient(settings);
- * ```
- *
- * @return HTTP client object
- */
-exports.createHttpClient = function (settings) {
- var currentSettings = settings_1.getSettingsWithDefaults(__assign({}, settings));
- return {
- /**
- * This method uses the HTTP client to send requests to the [IRI API endpoints](https://docs.iota.org/docs/node-software/0.1/iri/references/api-reference).
- *
- * ## Related methods
- *
- * To create an HTTP client, use the [`createHttpClient()`]{@link #module_http-client.createHttpClient} method.
- *
- * @method createHttpClient
- *
- * @summary Sends an API request to the connected IRI node.
- *
- * @param {Object} command - The request body for the API endpoint
- *
- * @example
- * ```js
- * let httpClient = HttpClient.createHttpClient(settings);
- * httpClient.send({command:'getNodeInfo'})
- * .then(response => {
- * console.log(response);
- * })
- * .catch(error => {
- * console.log(error);
- * })
- * ```
- *
- * @return {Promise}
- *
- * @fulfil {Object} response - The response from the IRI node
- *
- * @reject {Object} error - The connected IOTA node's API returned an error. See the [list of error messages](https://docs.iota.org/docs/node-software/0.1/iri/references/api-errors)
- */
- send: function (command) {
- return Promise["try"](function () {
- var provider = currentSettings.provider, user = currentSettings.user, password = currentSettings.password, requestBatchSize = currentSettings.requestBatchSize, apiVersion = currentSettings.apiVersion, agent = currentSettings.agent;
- if (exports.isBatchableCommand(command)) {
- var keysToBatch = exports.getKeysToBatch(command, requestBatchSize);
- if (keysToBatch.length) {
- return request_1.batchedSend({ command: command, uri: provider, user: user, password: password, apiVersion: apiVersion, agent: agent }, keysToBatch, requestBatchSize);
- }
- }
- return request_1.send({ command: command, uri: provider, user: user, password: password, apiVersion: apiVersion, agent: agent });
- });
- },
- /**
- * This method updates the settings of an existing HTTP client.
- *
- * ## Related methods
- *
- * To create an HTTP client, use the [`createHttpClient()`]{@link #module_http-client.createHttpClient} method.
- *
- * @method setSettings
- *
- * @summary Updates the settings of an existing HTTP client.
- *
- * @param {Object} [settings={}]
- * @param {String} [settings.provider=http://localhost:14265] URI of an IRI node to connect to
- * @param {String | number} [settings.apiVersion=1] - IOTA API version to be sent in the `X-IOTA-API-Version` header.
- * @param {number} [settings.requestBatchSize=1000] - Number of search values per request.
- *
- * @example
- * ```js
- * let settings = {
- * provider: 'https://nodes.devnet.thetangle.org:443'
- * }
- *
- * let httpClient = http.createHttpClient(settings);
- * httpClient.send({command:'getNodeInfo'}).then(res => {
- * console.log(res)
- * }).catch(err => {
- * console.log(err)
- * });
- *
- * httpClient.setSettings({provider:'http://newnode.org:14265'});
- *
- * httpClient.send({command:'getNodeInfo'}).then(res => {
- * console.log(res)
- * }).catch(err => {
- * console.log(err)
- * })
- * ```
- *
- * @return {void}
- */
- setSettings: function (newSettings) {
- currentSettings = settings_1.getSettingsWithDefaults(__assign({}, currentSettings, newSettings));
- }
- };
-};
-//# sourceMappingURL=httpClient.js.map
/***/ }),
/* 901 */,
@@ -31763,44 +32223,7 @@ exports.getSettingsWithDefaults = function (settings) {
/* 970 */,
/* 971 */,
/* 972 */,
-/* 973 */
-/***/ (function(module, exports, __webpack_require__) {
-
-;(function (root, factory, undef) {
- if (true) {
- // CommonJS
- module.exports = exports = factory(__webpack_require__(802), __webpack_require__(313));
- }
- else {}
-}(this, function (CryptoJS) {
-
- /**
- * ISO/IEC 9797-1 Padding Method 2.
- */
- CryptoJS.pad.Iso97971 = {
- pad: function (data, blockSize) {
- // Add 0x80 byte
- data.concat(CryptoJS.lib.WordArray.create([0x80000000], 1));
-
- // Zero pad the rest
- CryptoJS.pad.ZeroPadding.pad(data, blockSize);
- },
-
- unpad: function (data) {
- // Remove zero padding
- CryptoJS.pad.ZeroPadding.unpad(data);
-
- // Remove one more byte -- the 0x80 byte
- data.sigBytes--;
- }
- };
-
-
- return CryptoJS.pad.Iso97971;
-
-}));
-
-/***/ }),
+/* 973 */,
/* 974 */,
/* 975 */
/***/ (function(module, exports, __webpack_require__) {
@@ -32934,7 +33357,7 @@ __webpack_require__(809)(
Promise.Promise = Promise;
Promise.version = "3.7.2";
__webpack_require__(414)(Promise);
-__webpack_require__(691)(Promise, apiRejection, INTERNAL, tryConvertToPromise, Proxyable, debug);
+__webpack_require__(25)(Promise, apiRejection, INTERNAL, tryConvertToPromise, Proxyable, debug);
__webpack_require__(220)(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL, debug);
__webpack_require__(694)(Promise);
__webpack_require__(948)(Promise, INTERNAL);
diff --git a/dist/action.js b/dist/action.js
index fe1eb49..df449d1 100644
--- a/dist/action.js
+++ b/dist/action.js
@@ -1,38 +1,38 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-const core_1 = require("@actions/core");
-const github_1 = require("@actions/github");
-const core_2 = require("./core");
-if (require.main === module) {
- console.log("Tangle Release Starting");
- const releaseTag = core_1.getInput("tag_name", { required: true });
- const comment = core_1.getInput("comment", { required: false });
- const { owner, repo } = github_1.context.repo;
- const envConfig = {
- githubToken: process.env.GITHUB_TOKEN,
- owner,
- repository: repo,
- releaseTag,
- node: process.env.IOTA_NODE,
- depth: process.env.IOTA_DEPTH,
- mwm: process.env.IOTA_MWM,
- seed: process.env.IOTA_SEED,
- addressIndex: process.env.IOTA_ADDRESS_INDEX,
- transactionTag: process.env.IOTA_TAG,
- comment,
- explorerUrl: process.env.IOTA_TANGLE_EXPLORER
- };
- const config = core_2.sanitizeInput(envConfig);
- core_2.tangleRelease(config, message => console.log(message))
- .then(transactionDetails => {
- core_1.setOutput("tx_hash", transactionDetails.hash);
- core_1.setOutput("tx_explore_url", transactionDetails.url);
- console.log("Transaction Hash:", transactionDetails.hash);
- console.log("You can view the transaction on the tangle at:", transactionDetails.url);
- console.log("Complete");
- })
- .catch(err => {
- core_1.setFailed(err.message);
- console.log(err);
- });
-}
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+const core_1 = require("@actions/core");
+const github_1 = require("@actions/github");
+const core_2 = require("./core");
+if (require.main === module) {
+ console.log("Tangle Release Starting");
+ const releaseTag = core_1.getInput("tag_name", { required: true });
+ const comment = core_1.getInput("comment", { required: false });
+ const { owner, repo } = github_1.context.repo;
+ const envConfig = {
+ githubToken: process.env.GITHUB_TOKEN,
+ owner,
+ repository: repo,
+ releaseTag,
+ node: process.env.IOTA_NODE,
+ depth: process.env.IOTA_DEPTH,
+ mwm: process.env.IOTA_MWM,
+ seed: process.env.IOTA_SEED,
+ addressIndex: process.env.IOTA_ADDRESS_INDEX,
+ transactionTag: process.env.IOTA_TAG,
+ comment,
+ explorerUrl: process.env.IOTA_TANGLE_EXPLORER
+ };
+ const config = core_2.sanitizeInput(envConfig);
+ core_2.tangleRelease(config, message => console.log(message))
+ .then(transactionDetails => {
+ core_1.setOutput("tx_hash", transactionDetails.hash);
+ core_1.setOutput("tx_explore_url", transactionDetails.url);
+ console.log("Transaction Hash:", transactionDetails.hash);
+ console.log("You can view the transaction on the tangle at:", transactionDetails.url);
+ console.log("Complete");
+ })
+ .catch(err => {
+ core_1.setFailed(err.message);
+ console.log(err);
+ });
+}
diff --git a/dist/cli-core.js b/dist/cli-core.js
index 0c65b71..7576422 100644
--- a/dist/cli-core.js
+++ b/dist/cli-core.js
@@ -1,124 +1,123 @@
-"use strict";
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
-};
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.cliCore = void 0;
-const chalk_1 = __importDefault(require("chalk"));
-const commander_1 = require("commander");
-const node_emoji_1 = __importDefault(require("node-emoji"));
-const core_1 = require("./core");
-/**
- * Execute the cli core.
- * @param argv The command line arguments.
- * @param env The environment variables.
- * @param display Method to output display.
- */
-function cliCore(argv, env, display) {
- return __awaiter(this, void 0, void 0, function* () {
- const program = new commander_1.Command();
- try {
- const version = "0.7.1";
- program
- .storeOptionsAsProperties(false)
- .passCommandToAction(false)
- .name(chalk_1.default.yellowBright("gh-tangle-release"))
- .version(version, "-v, --version", chalk_1.default.yellowBright("output the current version"))
- .description(chalk_1.default.cyan("An application for creating a transaction on the IOTA Tangle from a GitHub release."))
- .option("--github-token ", chalk_1.default.yellowBright("GitHub token for accessing your repository (required)"))
- .option("--owner ", chalk_1.default.yellowBright("GitHub repository owner (required)"))
- .option("--repository ", chalk_1.default.yellowBright("GitHub repository (required)"))
- .option("--release-tag ", chalk_1.default.yellowBright("The release tag from the GitHub repository (required)"))
- .option("--node ", chalk_1.default.yellowBright("Url of the node to use for attaching the transaction to the tangle"), "https://nodes.iota.cafe:443")
- .option("--depth ", chalk_1.default.yellowBright("Depth to use for attaching the transaction to the tangle"), "3")
- .option("--mwm ", chalk_1.default.yellowBright("Minimum weight magnitude to use for attaching the transaction to the tangle"), "14")
- .option("--seed ", chalk_1.default.yellowBright("81 Tryte seed used to generate addresses (required)"))
- .option("--address-index ", chalk_1.default.yellowBright("Index number used to generate addresses"), "0")
- .option("--transaction-tag ", chalk_1.default.yellowBright("Tag to apply to the Tangle transaction"), "GITHUB9RELEASE")
- .option("--comment ", chalk_1.default.yellowBright("An optional comment to include in the Tangle transaction payload"))
- .option("--explorer-url ", chalk_1.default.yellowBright("Url of the explorer to use for exploration link"), "https://utils.iota.org/transaction/:hash")
- .option("--no-color", chalk_1.default.yellowBright("Disable colored output"))
- .helpOption("--help", chalk_1.default.yellowBright("Display help"));
- program.parse(argv);
- const opts = program.opts();
- console.log(opts);
- display(chalk_1.default.green(`GitHub Tangle Release v${version} ${opts.color === false ? "" : node_emoji_1.default.get("rocket")}\n`));
- const envRepo = env.GITHUB_REPOSITORY ? env.GITHUB_REPOSITORY.split("/") : [];
- if (envRepo.length === 2) {
- opts.owner = opts.owner || envRepo[0];
- opts.repository = opts.repository || envRepo[1];
- }
- const config = core_1.sanitizeInput({
- githubToken: opts.githubToken || env.GITHUB_TOKEN,
- owner: opts.owner,
- repository: opts.repository,
- releaseTag: opts.releaseTag || env.GITHUB_REF,
- node: opts.node,
- depth: opts.depth,
- mwm: opts.mwm,
- seed: opts.seed || env.GTR_SEED,
- addressIndex: opts.addressIndex,
- transactionTag: opts.transactionTag,
- comment: opts.comment,
- explorerUrl: opts.explorerUrl
- });
- display("Options:");
- display(chalk_1.default.cyan("\tGitHub Token"), chalk_1.default.white("*******"));
- display(chalk_1.default.cyan("\tOwner"), chalk_1.default.white(config.owner));
- display(chalk_1.default.cyan("\tRepository"), chalk_1.default.white(config.repository));
- display(chalk_1.default.cyan("\tRelease Tag"), chalk_1.default.white(config.releaseTag));
- display(chalk_1.default.cyan("\tNode"), chalk_1.default.white(config.node));
- display(chalk_1.default.cyan("\tDepth"), chalk_1.default.white(config.depth));
- display(chalk_1.default.cyan("\tMWM"), chalk_1.default.white(config.mwm));
- display(chalk_1.default.cyan("\tSeed"), chalk_1.default.white("*******"));
- display(chalk_1.default.cyan("\tAddress Index"), chalk_1.default.white(config.addressIndex));
- display(chalk_1.default.cyan("\tTransaction Tag"), chalk_1.default.white(config.transactionTag));
- if (config.comment) {
- display(chalk_1.default.cyan("\tComment"), chalk_1.default.white(config.comment));
- }
- display(chalk_1.default.cyan("\tExplorer Url"), chalk_1.default.white(config.explorerUrl));
- display("");
- try {
- const transactionDetails = yield core_1.tangleRelease(config, message => display(chalk_1.default.green(message)));
- display("Transaction Hash:", chalk_1.default.cyan(transactionDetails.hash));
- display("You can view the transaction on the tangle at:", chalk_1.default.cyan(transactionDetails.url));
- display(chalk_1.default.green("Complete"));
- }
- catch (err) {
- display("");
- display(createErrors(err));
- process.exit(1);
- }
- }
- catch (err) {
- program.help(str => `${str}${createEnvHelp()}${createExample()}${createErrors(err)}`);
- process.exit(1);
- }
- });
-}
-exports.cliCore = cliCore;
-/**
- * Show an example on the console.
- * @returns The example text.
- */
-function createExample() {
- // eslint-disable-next-line max-len
- return chalk_1.default.magenta("\nExample: gh-tangle-release --github-token a4d936470cb3d66f5434f787c2500bde9764f --owner my-org --repository my-repo --release-tag v1.0.1 --seed AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n\n");
-}
-/**
- * Show additional info about env vars.
- * @returns The additional information.
- */
-function createEnvHelp() {
+"use strict";
+var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
+ return new (P || (P = Promise))(function (resolve, reject) {
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
+ });
+};
+var __importDefault = (this && this.__importDefault) || function (mod) {
+ return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.cliCore = void 0;
+const chalk_1 = __importDefault(require("chalk"));
+const commander_1 = require("commander");
+const node_emoji_1 = __importDefault(require("node-emoji"));
+const core_1 = require("./core");
+/**
+ * Execute the cli core.
+ * @param argv The command line arguments.
+ * @param env The environment variables.
+ * @param display Method to output display.
+ */
+function cliCore(argv, env, display) {
+ return __awaiter(this, void 0, void 0, function* () {
+ const program = new commander_1.Command();
+ try {
+ const version = "0.7.2";
+ program
+ .storeOptionsAsProperties(false)
+ .passCommandToAction(false)
+ .name(chalk_1.default.yellowBright("gh-tangle-release"))
+ .version(version, "-v, --version", chalk_1.default.yellowBright("output the current version"))
+ .description(chalk_1.default.cyan("An application for creating a transaction on the IOTA Tangle from a GitHub release."))
+ .option("--github-token ", chalk_1.default.yellowBright("GitHub token for accessing your repository (required)"))
+ .option("--owner ", chalk_1.default.yellowBright("GitHub repository owner (required)"))
+ .option("--repository ", chalk_1.default.yellowBright("GitHub repository (required)"))
+ .option("--release-tag ", chalk_1.default.yellowBright("The release tag from the GitHub repository (required)"))
+ .option("--node ", chalk_1.default.yellowBright("Url of the node to use for attaching the transaction to the tangle"), "https://nodes.iota.cafe:443")
+ .option("--depth ", chalk_1.default.yellowBright("Depth to use for attaching the transaction to the tangle"), "3")
+ .option("--mwm ", chalk_1.default.yellowBright("Minimum weight magnitude to use for attaching the transaction to the tangle"), "14")
+ .option("--seed ", chalk_1.default.yellowBright("81 Tryte seed used to generate addresses (required)"))
+ .option("--address-index ", chalk_1.default.yellowBright("Index number used to generate addresses"), "0")
+ .option("--transaction-tag ", chalk_1.default.yellowBright("Tag to apply to the Tangle transaction"), "GITHUB9RELEASE")
+ .option("--comment ", chalk_1.default.yellowBright("An optional comment to include in the Tangle transaction payload"))
+ .option("--explorer-url ", chalk_1.default.yellowBright("Url of the explorer to use for exploration link"), "https://utils.iota.org/transaction/:hash")
+ .option("--no-color", chalk_1.default.yellowBright("Disable colored output"))
+ .helpOption("--help", chalk_1.default.yellowBright("Display help"));
+ program.parse(argv);
+ const opts = program.opts();
+ display(chalk_1.default.green(`GitHub Tangle Release v${version} ${opts.color === false ? "" : node_emoji_1.default.get("rocket")}\n`));
+ const envRepo = env.GITHUB_REPOSITORY ? env.GITHUB_REPOSITORY.split("/") : [];
+ if (envRepo.length === 2) {
+ opts.owner = opts.owner || envRepo[0];
+ opts.repository = opts.repository || envRepo[1];
+ }
+ const config = core_1.sanitizeInput({
+ githubToken: opts.githubToken || env.GITHUB_TOKEN,
+ owner: opts.owner,
+ repository: opts.repository,
+ releaseTag: opts.releaseTag || env.GITHUB_REF,
+ node: opts.node,
+ depth: opts.depth,
+ mwm: opts.mwm,
+ seed: opts.seed || env.GTR_SEED,
+ addressIndex: opts.addressIndex,
+ transactionTag: opts.transactionTag,
+ comment: opts.comment,
+ explorerUrl: opts.explorerUrl
+ });
+ display("Options:");
+ display(chalk_1.default.cyan("\tGitHub Token"), chalk_1.default.white("*******"));
+ display(chalk_1.default.cyan("\tOwner"), chalk_1.default.white(config.owner));
+ display(chalk_1.default.cyan("\tRepository"), chalk_1.default.white(config.repository));
+ display(chalk_1.default.cyan("\tRelease Tag"), chalk_1.default.white(config.releaseTag));
+ display(chalk_1.default.cyan("\tNode"), chalk_1.default.white(config.node));
+ display(chalk_1.default.cyan("\tDepth"), chalk_1.default.white(config.depth));
+ display(chalk_1.default.cyan("\tMWM"), chalk_1.default.white(config.mwm));
+ display(chalk_1.default.cyan("\tSeed"), chalk_1.default.white("*******"));
+ display(chalk_1.default.cyan("\tAddress Index"), chalk_1.default.white(config.addressIndex));
+ display(chalk_1.default.cyan("\tTransaction Tag"), chalk_1.default.white(config.transactionTag));
+ if (config.comment) {
+ display(chalk_1.default.cyan("\tComment"), chalk_1.default.white(config.comment));
+ }
+ display(chalk_1.default.cyan("\tExplorer Url"), chalk_1.default.white(config.explorerUrl));
+ display("");
+ try {
+ const transactionDetails = yield core_1.tangleRelease(config, message => display(chalk_1.default.green(message)));
+ display("Transaction Hash:", chalk_1.default.cyan(transactionDetails.hash));
+ display("You can view the transaction on the tangle at:", chalk_1.default.cyan(transactionDetails.url));
+ display(chalk_1.default.green("Complete"));
+ }
+ catch (err) {
+ display("");
+ display(createErrors(err));
+ process.exit(1);
+ }
+ }
+ catch (err) {
+ program.help(str => `${str}${createEnvHelp()}${createExample()}${createErrors(err)}`);
+ process.exit(1);
+ }
+ });
+}
+exports.cliCore = cliCore;
+/**
+ * Show an example on the console.
+ * @returns The example text.
+ */
+function createExample() {
+ // eslint-disable-next-line max-len
+ return chalk_1.default.magenta("\nExample: gh-tangle-release --github-token a4d936470cb3d66f5434f787c2500bde9764f --owner my-org --repository my-repo --release-tag v1.0.1 --seed AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n\n");
+}
+/**
+ * Show additional info about env vars.
+ * @returns The additional information.
+ */
+function createEnvHelp() {
return `
${chalk_1.default.cyan("You can also supply some of the options through environment variables:")}
${chalk_1.default.cyan("--github-token: GITHUB_TOKEN")}
@@ -126,13 +125,13 @@ ${chalk_1.default.cyan("You can also supply some of the options through environm
${chalk_1.default.cyan("--repository: GITHUB_REPOSITORY[1]")}
${chalk_1.default.cyan(" where GITHUB_REPOSITORY is formatted owner/repository")}
${chalk_1.default.cyan("--release-tag: GITHUB_REF")}
- ${chalk_1.default.cyan("--seed: GTR_SEED")}\n\n`;
-}
-/**
- * Show the errors.
- * @param error The error that was thrown.
- * @returns The formatted errors.
- */
-function createErrors(error) {
- return chalk_1.default.red(`The following errors occurred:\n ${error.message.replace(/\n/g, "\n ")}`);
-}
+ ${chalk_1.default.cyan("--seed: GTR_SEED")}\n\n`;
+}
+/**
+ * Show the errors.
+ * @param error The error that was thrown.
+ * @returns The formatted errors.
+ */
+function createErrors(error) {
+ return chalk_1.default.red(`The following errors occurred:\n ${error.message.replace(/\n/g, "\n ")}`);
+}
diff --git a/dist/cli.js b/dist/cli.js
index af0bb0f..472e37b 100644
--- a/dist/cli.js
+++ b/dist/cli.js
@@ -1,11 +1,11 @@
-#!/usr/bin/env node
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-const cli_core_1 = require("./cli-core");
-cli_core_1.cliCore(process.argv, process.env, (message, param) => {
- process.stdout.write(message);
- if (param) {
- process.stdout.write(` ${param}`);
- }
- process.stdout.write("\n");
-}).catch(err => process.stderr.write(err.message));
+#!/usr/bin/env node
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+const cli_core_1 = require("./cli-core");
+cli_core_1.cliCore(process.argv, process.env, (message, param) => {
+ process.stdout.write(message);
+ if (param) {
+ process.stdout.write(` ${param}`);
+ }
+ process.stdout.write("\n");
+}).catch(err => process.stderr.write(err.message));
diff --git a/dist/core.js b/dist/core.js
index 1d08179..8420601 100644
--- a/dist/core.js
+++ b/dist/core.js
@@ -1,171 +1,171 @@
-"use strict";
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.tangleRelease = exports.sanitizeInput = void 0;
-/* eslint-disable camelcase */
-const github_1 = require("@actions/github");
-const crypto_1 = require("./crypto");
-const iota_1 = require("./iota");
-/**
- * Santirize the input parameters.
- * @param config The config for the release.
- * @returns The config as non partial.
- */
-function sanitizeInput(config) {
- const errors = [];
- if (!config.githubToken) {
- errors.push("You must provide the GitHub token option");
- }
- if (!config.owner) {
- errors.push("You must provide the owner option");
- }
- if (!config.repository) {
- errors.push("You must provide the repository option");
- }
- if (!config.releaseTag) {
- errors.push("You must provide the release tag option");
- }
- if (!config.seed) {
- errors.push("You must provide the seed option");
- }
- else if (!/[9A-Z]/.test(config.seed)) {
- errors.push("The seed option must be 81 trytes [A-Z9]");
- }
- else if (config.seed.length !== 81) {
- errors.push(`The seed option must be 81 trytes [A-Z9], it is ${config.seed.length}`);
- }
- config.transactionTag = config.transactionTag || "GITHUB9RELEASE";
- if (!/[9A-Z]/.test(config.transactionTag)) {
- errors.push("The transaction tag option must be 27 trytes [A-Z9] or less");
- }
- if (config.transactionTag.length > 27) {
- errors.push(`The transaction tag option must be 27 trytes [A-Z9] or less, it is ${config.transactionTag.length}`);
- }
- config.explorerUrl = config.explorerUrl || "https://utils.iota.org/transaction/:hash";
- config.node = config.node || "https://nodes.iota.cafe:443";
- let addressIndex;
- let depth;
- let mwm;
- if (typeof config.addressIndex === "string") {
- addressIndex = config.addressIndex.length > 0 ? Number.parseInt(config.addressIndex, 10) : 0;
- }
- else if (config.addressIndex === undefined || config.addressIndex === null) {
- addressIndex = 0;
- }
- else {
- addressIndex = config.addressIndex;
- }
- if (typeof config.depth === "string") {
- depth = config.depth.length > 0 ? Number.parseInt(config.depth, 10) : 3;
- }
- else if (config.depth === undefined || config.depth === null) {
- depth = 3;
- }
- else {
- depth = config.depth;
- }
- if (typeof config.mwm === "string") {
- mwm = config.mwm.length > 0 ? Number.parseInt(config.mwm, 10) : 14;
- }
- else if (config.mwm === undefined || config.mwm === null) {
- mwm = 14;
- }
- else {
- mwm = config.mwm;
- }
- if (errors.length > 0) {
- throw new Error(errors.join("\n"));
- }
- return {
- githubToken: config.githubToken || "",
- owner: config.owner || "",
- repository: config.repository || "",
- releaseTag: config.releaseTag || "",
- node: config.node,
- depth,
- mwm,
- seed: config.seed || "",
- addressIndex,
- transactionTag: config.transactionTag,
- comment: config.comment,
- explorerUrl: config.explorerUrl
- };
-}
-exports.sanitizeInput = sanitizeInput;
-/**
- * Create a tangle payload for a GitHub release.
- * @param config The config for the release.
- * @param progress Callback to send progress to.
- * @returns The hash of the transaction and an explorer url.
- */
-function tangleRelease(config, progress) {
- return __awaiter(this, void 0, void 0, function* () {
- progress("Connecting to GitHub");
- let release;
- try {
- const octokit = github_1.getOctokit(config.githubToken);
- release = yield octokit.repos.getReleaseByTag({
- owner: config.owner,
- repo: config.repository,
- tag: config.releaseTag.replace("refs/tags/", "")
- });
- if (!release) {
- throw new Error("Unable to retrieve release");
- }
- }
- catch (err) {
- if (!err.toString().includes("Not Found")) {
- throw err;
- }
- }
- if (!release) {
- throw new Error(`Can not find the release https://github.com/${config.owner}/${config.repository}/releases/tag/${config.releaseTag}`);
- }
- progress("Downloading tarball");
- const tarBallHash = yield crypto_1.downloadAndHash(release.data.tarball_url, config.githubToken);
- progress("Downloading zipball");
- const zipBallHash = yield crypto_1.downloadAndHash(release.data.zipball_url, config.githubToken);
- progress("Constructing payload");
- const payload = {
- owner: config.owner || "",
- repo: config.repository || "",
- tag_name: release.data.tag_name,
- name: release.data.name,
- comment: config.comment,
- body: release.data.body,
- tarball_url: release.data.tarball_url,
- tarball_sig: tarBallHash,
- zipball_url: release.data.zipball_url,
- zipball_sig: zipBallHash,
- assets: undefined
- };
- progress("Processing assets");
- if (release.data.assets && release.data.assets.length > 0) {
- payload.assets = [];
- for (let i = 0; i < release.data.assets.length; i++) {
- const assetHash = yield crypto_1.downloadAndHash(release.data.assets[i].browser_download_url, config.githubToken);
- payload.assets.push({
- name: release.data.assets[i].name,
- size: release.data.assets[i].size,
- url: release.data.assets[i].browser_download_url,
- sig: assetHash
- });
- }
- }
- progress("Attaching to tangle");
- const txHash = yield iota_1.attachToTangle(config.node, config.depth, config.mwm, config.seed, config.addressIndex, config.transactionTag, payload, progress);
- return {
- hash: txHash,
- url: config.explorerUrl.replace(":hash", txHash)
- };
- });
-}
-exports.tangleRelease = tangleRelease;
+"use strict";
+var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
+ return new (P || (P = Promise))(function (resolve, reject) {
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
+ });
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.tangleRelease = exports.sanitizeInput = void 0;
+/* eslint-disable camelcase */
+const github_1 = require("@actions/github");
+const crypto_1 = require("./crypto");
+const iota_1 = require("./iota");
+/**
+ * Santirize the input parameters.
+ * @param config The config for the release.
+ * @returns The config as non partial.
+ */
+function sanitizeInput(config) {
+ const errors = [];
+ if (!config.githubToken) {
+ errors.push("You must provide the GitHub token option");
+ }
+ if (!config.owner) {
+ errors.push("You must provide the owner option");
+ }
+ if (!config.repository) {
+ errors.push("You must provide the repository option");
+ }
+ if (!config.releaseTag) {
+ errors.push("You must provide the release tag option");
+ }
+ if (!config.seed) {
+ errors.push("You must provide the seed option");
+ }
+ else if (!/[9A-Z]/.test(config.seed)) {
+ errors.push("The seed option must be 81 trytes [A-Z9]");
+ }
+ else if (config.seed.length !== 81) {
+ errors.push(`The seed option must be 81 trytes [A-Z9], it is ${config.seed.length}`);
+ }
+ config.transactionTag = config.transactionTag || "GITHUB9RELEASE";
+ if (!/[9A-Z]/.test(config.transactionTag)) {
+ errors.push("The transaction tag option must be 27 trytes [A-Z9] or less");
+ }
+ if (config.transactionTag.length > 27) {
+ errors.push(`The transaction tag option must be 27 trytes [A-Z9] or less, it is ${config.transactionTag.length}`);
+ }
+ config.explorerUrl = config.explorerUrl || "https://utils.iota.org/transaction/:hash";
+ config.node = config.node || "https://nodes.iota.cafe:443";
+ let addressIndex;
+ let depth;
+ let mwm;
+ if (typeof config.addressIndex === "string") {
+ addressIndex = config.addressIndex.length > 0 ? Number.parseInt(config.addressIndex, 10) : 0;
+ }
+ else if (config.addressIndex === undefined || config.addressIndex === null) {
+ addressIndex = 0;
+ }
+ else {
+ addressIndex = config.addressIndex;
+ }
+ if (typeof config.depth === "string") {
+ depth = config.depth.length > 0 ? Number.parseInt(config.depth, 10) : 3;
+ }
+ else if (config.depth === undefined || config.depth === null) {
+ depth = 3;
+ }
+ else {
+ depth = config.depth;
+ }
+ if (typeof config.mwm === "string") {
+ mwm = config.mwm.length > 0 ? Number.parseInt(config.mwm, 10) : 14;
+ }
+ else if (config.mwm === undefined || config.mwm === null) {
+ mwm = 14;
+ }
+ else {
+ mwm = config.mwm;
+ }
+ if (errors.length > 0) {
+ throw new Error(errors.join("\n"));
+ }
+ return {
+ githubToken: config.githubToken || "",
+ owner: config.owner || "",
+ repository: config.repository || "",
+ releaseTag: config.releaseTag || "",
+ node: config.node,
+ depth,
+ mwm,
+ seed: config.seed || "",
+ addressIndex,
+ transactionTag: config.transactionTag,
+ comment: config.comment,
+ explorerUrl: config.explorerUrl
+ };
+}
+exports.sanitizeInput = sanitizeInput;
+/**
+ * Create a tangle payload for a GitHub release.
+ * @param config The config for the release.
+ * @param progress Callback to send progress to.
+ * @returns The hash of the transaction and an explorer url.
+ */
+function tangleRelease(config, progress) {
+ return __awaiter(this, void 0, void 0, function* () {
+ progress("Connecting to GitHub");
+ let release;
+ try {
+ const octokit = github_1.getOctokit(config.githubToken);
+ release = yield octokit.repos.getReleaseByTag({
+ owner: config.owner,
+ repo: config.repository,
+ tag: config.releaseTag.replace("refs/tags/", "")
+ });
+ if (!release) {
+ throw new Error("Unable to retrieve release");
+ }
+ }
+ catch (err) {
+ if (!err.toString().includes("Not Found")) {
+ throw err;
+ }
+ }
+ if (!release) {
+ throw new Error(`Can not find the release https://github.com/${config.owner}/${config.repository}/releases/tag/${config.releaseTag}`);
+ }
+ progress("Downloading tarball");
+ const tarBallHash = yield crypto_1.downloadAndHash(release.data.tarball_url, config.githubToken);
+ progress("Downloading zipball");
+ const zipBallHash = yield crypto_1.downloadAndHash(release.data.zipball_url, config.githubToken);
+ progress("Constructing payload");
+ const payload = {
+ owner: config.owner || "",
+ repo: config.repository || "",
+ tag_name: release.data.tag_name,
+ name: release.data.name,
+ comment: config.comment,
+ body: release.data.body,
+ tarball_url: release.data.tarball_url,
+ tarball_sig: tarBallHash,
+ zipball_url: release.data.zipball_url,
+ zipball_sig: zipBallHash,
+ assets: undefined
+ };
+ progress("Processing assets");
+ if (release.data.assets && release.data.assets.length > 0) {
+ payload.assets = [];
+ for (let i = 0; i < release.data.assets.length; i++) {
+ const assetHash = yield crypto_1.downloadAndHash(release.data.assets[i].browser_download_url, config.githubToken);
+ payload.assets.push({
+ name: release.data.assets[i].name,
+ size: release.data.assets[i].size,
+ url: release.data.assets[i].browser_download_url,
+ sig: assetHash
+ });
+ }
+ }
+ progress("Attaching to tangle");
+ const txHash = yield iota_1.attachToTangle(config.node, config.depth, config.mwm, config.seed, config.addressIndex, config.transactionTag, payload, progress);
+ return {
+ hash: txHash,
+ url: config.explorerUrl.replace(":hash", txHash)
+ };
+ });
+}
+exports.tangleRelease = tangleRelease;
diff --git a/dist/crypto.js b/dist/crypto.js
index 3e64acb..7e9538e 100644
--- a/dist/crypto.js
+++ b/dist/crypto.js
@@ -1,45 +1,45 @@
-"use strict";
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
-};
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.downloadAndHash = void 0;
-const axios_1 = __importDefault(require("axios"));
-const crypto_1 = require("crypto");
-/**
- * Download a file and return the sha256 hash of it.
- * @param url The url of the file to download.
- * @param githubToken The access token.
- * @returns The sha256 hash of the file.
- */
-function downloadAndHash(url, githubToken) {
- return __awaiter(this, void 0, void 0, function* () {
- try {
- const response = yield axios_1.default.get(url, {
- headers: {
- Authorization: `token ${githubToken}`
- },
- responseType: "arraybuffer"
- });
- if (response.data) {
- const hash = crypto_1.createHash("sha256");
- hash.update(Buffer.from(response.data, "binary"));
- return hash.digest("base64");
- }
- throw new Error(`No data in asset ${url}`);
- }
- catch (err) {
- throw new Error(`Failed retrieving asset ${url}\n${err.msg}`);
- }
- });
-}
-exports.downloadAndHash = downloadAndHash;
+"use strict";
+var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
+ return new (P || (P = Promise))(function (resolve, reject) {
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
+ });
+};
+var __importDefault = (this && this.__importDefault) || function (mod) {
+ return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.downloadAndHash = void 0;
+const axios_1 = __importDefault(require("axios"));
+const crypto_1 = require("crypto");
+/**
+ * Download a file and return the sha256 hash of it.
+ * @param url The url of the file to download.
+ * @param githubToken The access token.
+ * @returns The sha256 hash of the file.
+ */
+function downloadAndHash(url, githubToken) {
+ return __awaiter(this, void 0, void 0, function* () {
+ try {
+ const response = yield axios_1.default.get(url, {
+ headers: {
+ Authorization: `token ${githubToken}`
+ },
+ responseType: "arraybuffer"
+ });
+ if (response.data) {
+ const hash = crypto_1.createHash("sha256");
+ hash.update(Buffer.from(response.data, "binary"));
+ return hash.digest("base64");
+ }
+ throw new Error(`No data in asset ${url}`);
+ }
+ catch (err) {
+ throw new Error(`Failed retrieving asset ${url}\n${err.msg}`);
+ }
+ });
+}
+exports.downloadAndHash = downloadAndHash;
diff --git a/dist/index.js b/dist/index.js
index 6b7af4b..c5e6286 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -1,13 +1,13 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __exportStar = (this && this.__exportStar) || function(m, exports) {
- for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-__exportStar(require("./core"), exports);
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+}));
+var __exportStar = (this && this.__exportStar) || function(m, exports) {
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+__exportStar(require("./core"), exports);
diff --git a/dist/iota.js b/dist/iota.js
index 681cd32..e1e5775 100644
--- a/dist/iota.js
+++ b/dist/iota.js
@@ -1,68 +1,68 @@
-"use strict";
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.attachToTangle = void 0;
-const converter_1 = require("@iota/converter");
-const core_1 = require("@iota/core");
-/**
- * Attach a payload to the tangle.
- * @param provider The node to use for attaching.
- * @param depth The depth for the attach.
- * @param mwm The minimum weight magniture for the attach.
- * @param seed The seed to generate the address.
- * @param addressIndex The address index to generate.
- * @param tag The tag for the payload.
- * @param payload The payload contents.
- * @param progress Callback to send progress to.
- * @returns The transaction hash that was attached.
- */
-function attachToTangle(provider, depth, mwm, seed, addressIndex, tag, payload, progress) {
- return __awaiter(this, void 0, void 0, function* () {
- const json = JSON.stringify(payload);
- const ascii = encodeNonASCII(json);
- const messageTrytes = converter_1.asciiToTrytes(ascii);
- progress("Preparing transactions");
- progress(`\tMessage Trytes Length: ${messageTrytes.length}`);
- progress(`\tNumber of Transactions: ${Math.ceil(messageTrytes.length / 2187)}`);
- try {
- const iota = core_1.composeAPI({
- provider
- });
- const address = core_1.generateAddress(seed, addressIndex);
- const trytes = yield iota.prepareTransfers("9".repeat(81), [
- {
- address,
- value: 0,
- message: messageTrytes,
- tag
- }
- ]);
- progress("Sending trytes");
- const bundles = yield iota.sendTrytes(trytes, depth, mwm);
- return bundles[0].hash;
- }
- catch (err) {
- const msg = err instanceof Error ? err.message : err;
- throw new Error(`Sending trytes failed.\n${msg.replace("Error: ", "")}`);
- }
- });
-}
-exports.attachToTangle = attachToTangle;
-/**
- * Replace non ascii characters with their equivalent.
- * @param value The value to convert.
- * @returns The converted value.
- */
-function encodeNonASCII(value) {
- return value
- ? value.replace(/[\u007F-\uFFFF]/g, chr => `\\u${`0000${chr.charCodeAt(0).toString(16)}`.slice(-4)}`)
- : "";
-}
+"use strict";
+var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
+ return new (P || (P = Promise))(function (resolve, reject) {
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
+ });
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.attachToTangle = void 0;
+const converter_1 = require("@iota/converter");
+const core_1 = require("@iota/core");
+/**
+ * Attach a payload to the tangle.
+ * @param provider The node to use for attaching.
+ * @param depth The depth for the attach.
+ * @param mwm The minimum weight magniture for the attach.
+ * @param seed The seed to generate the address.
+ * @param addressIndex The address index to generate.
+ * @param tag The tag for the payload.
+ * @param payload The payload contents.
+ * @param progress Callback to send progress to.
+ * @returns The transaction hash that was attached.
+ */
+function attachToTangle(provider, depth, mwm, seed, addressIndex, tag, payload, progress) {
+ return __awaiter(this, void 0, void 0, function* () {
+ const json = JSON.stringify(payload);
+ const ascii = encodeNonASCII(json);
+ const messageTrytes = converter_1.asciiToTrytes(ascii);
+ progress("Preparing transactions");
+ progress(`\tMessage Trytes Length: ${messageTrytes.length}`);
+ progress(`\tNumber of Transactions: ${Math.ceil(messageTrytes.length / 2187)}`);
+ try {
+ const iota = core_1.composeAPI({
+ provider
+ });
+ const address = core_1.generateAddress(seed, addressIndex);
+ const trytes = yield iota.prepareTransfers("9".repeat(81), [
+ {
+ address,
+ value: 0,
+ message: messageTrytes,
+ tag
+ }
+ ]);
+ progress("Sending trytes");
+ const bundles = yield iota.sendTrytes(trytes, depth, mwm);
+ return bundles[0].hash;
+ }
+ catch (err) {
+ const msg = err instanceof Error ? err.message : err;
+ throw new Error(`Sending trytes failed.\n${msg.replace("Error: ", "")}`);
+ }
+ });
+}
+exports.attachToTangle = attachToTangle;
+/**
+ * Replace non ascii characters with their equivalent.
+ * @param value The value to convert.
+ * @returns The converted value.
+ */
+function encodeNonASCII(value) {
+ return value
+ ? value.replace(/[\u007F-\uFFFF]/g, chr => `\\u${`0000${chr.charCodeAt(0).toString(16)}`.slice(-4)}`)
+ : "";
+}
diff --git a/dist/models/IConfig.js b/dist/models/IConfig.js
index c8ad2e5..ce03781 100644
--- a/dist/models/IConfig.js
+++ b/dist/models/IConfig.js
@@ -1,2 +1,2 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
diff --git a/dist/models/IPartialConfig.js b/dist/models/IPartialConfig.js
index c8ad2e5..ce03781 100644
--- a/dist/models/IPartialConfig.js
+++ b/dist/models/IPartialConfig.js
@@ -1,2 +1,2 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
diff --git a/dist/models/IPayload.js b/dist/models/IPayload.js
index c8ad2e5..ce03781 100644
--- a/dist/models/IPayload.js
+++ b/dist/models/IPayload.js
@@ -1,2 +1,2 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
diff --git a/src/cli-core.ts b/src/cli-core.ts
index cc176b5..cc15ca5 100644
--- a/src/cli-core.ts
+++ b/src/cli-core.ts
@@ -16,7 +16,7 @@ export async function cliCore(
const program = new Command();
try {
- const version = "0.7.1";
+ const version = "0.7.2";
program
.storeOptionsAsProperties(false)
@@ -54,8 +54,6 @@ export async function cliCore(
program.parse(argv);
const opts = program.opts();
- console.log(opts);
-
display(chalk.green(`GitHub Tangle Release v${version} ${
opts.color === false ? "" : emoji.get("rocket")}\n`));