slnodejs 6.1.128 → 6.1.129

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -83638,7 +83638,7 @@ module.exports = {
83638
83638
  return replace.call(value, percentTwenties, '+');
83639
83639
  },
83640
83640
  RFC3986: function (value) {
83641
- return value;
83641
+ return String(value);
83642
83642
  }
83643
83643
  },
83644
83644
  RFC1738: 'RFC1738',
@@ -83714,14 +83714,15 @@ var parseObject = function (chain, val, options) {
83714
83714
  var obj;
83715
83715
  var root = chain[i];
83716
83716
 
83717
- if (root === '[]') {
83718
- obj = [];
83719
- obj = obj.concat(leaf);
83717
+ if (root === '[]' && options.parseArrays) {
83718
+ obj = [].concat(leaf);
83720
83719
  } else {
83721
83720
  obj = options.plainObjects ? Object.create(null) : {};
83722
83721
  var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
83723
83722
  var index = parseInt(cleanRoot, 10);
83724
- if (
83723
+ if (!options.parseArrays && cleanRoot === '') {
83724
+ obj = { 0: leaf };
83725
+ } else if (
83725
83726
  !isNaN(index)
83726
83727
  && root !== cleanRoot
83727
83728
  && String(index) === cleanRoot
@@ -83730,7 +83731,7 @@ var parseObject = function (chain, val, options) {
83730
83731
  ) {
83731
83732
  obj = [];
83732
83733
  obj[index] = leaf;
83733
- } else {
83734
+ } else if (cleanRoot !== '__proto__') {
83734
83735
  obj[cleanRoot] = leaf;
83735
83736
  }
83736
83737
  }
@@ -83841,17 +83842,23 @@ var utils = require('./utils');
83841
83842
  var formats = require('./formats');
83842
83843
 
83843
83844
  var arrayPrefixGenerators = {
83844
- brackets: function brackets(prefix) { // eslint-disable-line func-name-matching
83845
+ brackets: function brackets(prefix) {
83845
83846
  return prefix + '[]';
83846
83847
  },
83847
- indices: function indices(prefix, key) { // eslint-disable-line func-name-matching
83848
+ indices: function indices(prefix, key) {
83848
83849
  return prefix + '[' + key + ']';
83849
83850
  },
83850
- repeat: function repeat(prefix) { // eslint-disable-line func-name-matching
83851
+ repeat: function repeat(prefix) {
83851
83852
  return prefix;
83852
83853
  }
83853
83854
  };
83854
83855
 
83856
+ var isArray = Array.isArray;
83857
+ var push = Array.prototype.push;
83858
+ var pushToArray = function (arr, valueOrArray) {
83859
+ push.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]);
83860
+ };
83861
+
83855
83862
  var toISO = Date.prototype.toISOString;
83856
83863
 
83857
83864
  var defaults = {
@@ -83859,14 +83866,14 @@ var defaults = {
83859
83866
  encode: true,
83860
83867
  encoder: utils.encode,
83861
83868
  encodeValuesOnly: false,
83862
- serializeDate: function serializeDate(date) { // eslint-disable-line func-name-matching
83869
+ serializeDate: function serializeDate(date) {
83863
83870
  return toISO.call(date);
83864
83871
  },
83865
83872
  skipNulls: false,
83866
83873
  strictNullHandling: false
83867
83874
  };
83868
83875
 
83869
- var stringify = function stringify( // eslint-disable-line func-name-matching
83876
+ var stringify = function stringify(
83870
83877
  object,
83871
83878
  prefix,
83872
83879
  generateArrayPrefix,
@@ -83885,7 +83892,9 @@ var stringify = function stringify( // eslint-disable-line func-name-matching
83885
83892
  obj = filter(prefix, obj);
83886
83893
  } else if (obj instanceof Date) {
83887
83894
  obj = serializeDate(obj);
83888
- } else if (obj === null) {
83895
+ }
83896
+
83897
+ if (obj === null) {
83889
83898
  if (strictNullHandling) {
83890
83899
  return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder) : prefix;
83891
83900
  }
@@ -83908,7 +83917,7 @@ var stringify = function stringify( // eslint-disable-line func-name-matching
83908
83917
  }
83909
83918
 
83910
83919
  var objKeys;
83911
- if (Array.isArray(filter)) {
83920
+ if (isArray(filter)) {
83912
83921
  objKeys = filter;
83913
83922
  } else {
83914
83923
  var keys = Object.keys(obj);
@@ -83922,8 +83931,8 @@ var stringify = function stringify( // eslint-disable-line func-name-matching
83922
83931
  continue;
83923
83932
  }
83924
83933
 
83925
- if (Array.isArray(obj)) {
83926
- values = values.concat(stringify(
83934
+ if (isArray(obj)) {
83935
+ pushToArray(values, stringify(
83927
83936
  obj[key],
83928
83937
  generateArrayPrefix(prefix, key),
83929
83938
  generateArrayPrefix,
@@ -83938,7 +83947,7 @@ var stringify = function stringify( // eslint-disable-line func-name-matching
83938
83947
  encodeValuesOnly
83939
83948
  ));
83940
83949
  } else {
83941
- values = values.concat(stringify(
83950
+ pushToArray(values, stringify(
83942
83951
  obj[key],
83943
83952
  prefix + (allowDots ? '.' + key : '[' + key + ']'),
83944
83953
  generateArrayPrefix,
@@ -83962,7 +83971,7 @@ module.exports = function (object, opts) {
83962
83971
  var obj = object;
83963
83972
  var options = opts ? utils.assign({}, opts) : {};
83964
83973
 
83965
- if (options.encoder !== null && options.encoder !== undefined && typeof options.encoder !== 'function') {
83974
+ if (options.encoder !== null && typeof options.encoder !== 'undefined' && typeof options.encoder !== 'function') {
83966
83975
  throw new TypeError('Encoder has to be a function.');
83967
83976
  }
83968
83977
 
@@ -83987,7 +83996,7 @@ module.exports = function (object, opts) {
83987
83996
  if (typeof options.filter === 'function') {
83988
83997
  filter = options.filter;
83989
83998
  obj = filter('', obj);
83990
- } else if (Array.isArray(options.filter)) {
83999
+ } else if (isArray(options.filter)) {
83991
84000
  filter = options.filter;
83992
84001
  objKeys = filter;
83993
84002
  }
@@ -84023,8 +84032,7 @@ module.exports = function (object, opts) {
84023
84032
  if (skipNulls && obj[key] === null) {
84024
84033
  continue;
84025
84034
  }
84026
-
84027
- keys = keys.concat(stringify(
84035
+ pushToArray(keys, stringify(
84028
84036
  obj[key],
84029
84037
  key,
84030
84038
  generateArrayPrefix,
@@ -84102,8 +84110,8 @@ var merge = function merge(target, source, options) {
84102
84110
  if (typeof source !== 'object') {
84103
84111
  if (Array.isArray(target)) {
84104
84112
  target.push(source);
84105
- } else if (typeof target === 'object') {
84106
- if (options.plainObjects || options.allowPrototypes || !has.call(Object.prototype, source)) {
84113
+ } else if (target && typeof target === 'object') {
84114
+ if ((options && (options.plainObjects || options.allowPrototypes)) || !has.call(Object.prototype, source)) {
84107
84115
  target[source] = true;
84108
84116
  }
84109
84117
  } else {
@@ -84113,7 +84121,7 @@ var merge = function merge(target, source, options) {
84113
84121
  return target;
84114
84122
  }
84115
84123
 
84116
- if (typeof target !== 'object') {
84124
+ if (!target || typeof target !== 'object') {
84117
84125
  return [target].concat(source);
84118
84126
  }
84119
84127
 
@@ -84125,8 +84133,9 @@ var merge = function merge(target, source, options) {
84125
84133
  if (Array.isArray(target) && Array.isArray(source)) {
84126
84134
  source.forEach(function (item, i) {
84127
84135
  if (has.call(target, i)) {
84128
- if (target[i] && typeof target[i] === 'object') {
84129
- target[i] = merge(target[i], item, options);
84136
+ var targetItem = target[i];
84137
+ if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
84138
+ target[i] = merge(targetItem, item, options);
84130
84139
  } else {
84131
84140
  target.push(item);
84132
84141
  }
@@ -84207,6 +84216,7 @@ var encode = function encode(str) {
84207
84216
 
84208
84217
  i += 1;
84209
84218
  c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF));
84219
+ /* eslint operator-linebreak: [2, "before"] */
84210
84220
  out += hexTable[0xF0 | (c >> 18)]
84211
84221
  + hexTable[0x80 | ((c >> 12) & 0x3F)]
84212
84222
  + hexTable[0x80 | ((c >> 6) & 0x3F)]
@@ -90926,20 +90936,30 @@ var assert = require('assert-plus');
90926
90936
  var Buffer = require('safer-buffer').Buffer;
90927
90937
  var rfc4253 = require('./rfc4253');
90928
90938
  var Key = require('../key');
90939
+ var SSHBuffer = require('../ssh-buffer');
90940
+ var crypto = require('crypto');
90941
+ var PrivateKey = require('../private-key');
90929
90942
 
90930
90943
  var errors = require('../errors');
90931
90944
 
90945
+ // https://tartarus.org/~simon/putty-prerel-snapshots/htmldoc/AppendixC.html
90932
90946
  function read(buf, options) {
90933
90947
  var lines = buf.toString('ascii').split(/[\r\n]+/);
90934
90948
  var found = false;
90935
90949
  var parts;
90936
90950
  var si = 0;
90951
+ var formatVersion;
90937
90952
  while (si < lines.length) {
90938
90953
  parts = splitHeader(lines[si++]);
90939
- if (parts &&
90940
- parts[0].toLowerCase() === 'putty-user-key-file-2') {
90941
- found = true;
90942
- break;
90954
+ if (parts) {
90955
+ formatVersion = {
90956
+ 'putty-user-key-file-2': 2,
90957
+ 'putty-user-key-file-3': 3
90958
+ }[parts[0].toLowerCase()];
90959
+ if (formatVersion) {
90960
+ found = true;
90961
+ break;
90962
+ }
90943
90963
  }
90944
90964
  }
90945
90965
  if (!found) {
@@ -90949,6 +90969,7 @@ function read(buf, options) {
90949
90969
 
90950
90970
  parts = splitHeader(lines[si++]);
90951
90971
  assert.equal(parts[0].toLowerCase(), 'encryption');
90972
+ var encryption = parts[1];
90952
90973
 
90953
90974
  parts = splitHeader(lines[si++]);
90954
90975
  assert.equal(parts[0].toLowerCase(), 'comment');
@@ -90969,10 +90990,94 @@ function read(buf, options) {
90969
90990
  if (key.type !== keyType) {
90970
90991
  throw (new Error('Outer key algorithm mismatch'));
90971
90992
  }
90993
+
90994
+ si += publicLines;
90995
+ if (lines[si]) {
90996
+ parts = splitHeader(lines[si++]);
90997
+ assert.equal(parts[0].toLowerCase(), 'private-lines');
90998
+ var privateLines = parseInt(parts[1], 10);
90999
+ if (!isFinite(privateLines) || privateLines < 0 ||
91000
+ privateLines > lines.length) {
91001
+ throw (new Error('Invalid private-lines count'));
91002
+ }
91003
+
91004
+ var privateBuf = Buffer.from(
91005
+ lines.slice(si, si + privateLines).join(''), 'base64');
91006
+
91007
+ if (encryption !== 'none' && formatVersion === 3) {
91008
+ throw new Error('Encrypted keys arenot supported for' +
91009
+ ' PuTTY format version 3');
91010
+ }
91011
+
91012
+ if (encryption === 'aes256-cbc') {
91013
+ if (!options.passphrase) {
91014
+ throw (new errors.KeyEncryptedError(
91015
+ options.filename, 'PEM'));
91016
+ }
91017
+
91018
+ var iv = Buffer.alloc(16, 0);
91019
+ var decipher = crypto.createDecipheriv(
91020
+ 'aes-256-cbc',
91021
+ derivePPK2EncryptionKey(options.passphrase),
91022
+ iv);
91023
+ decipher.setAutoPadding(false);
91024
+ privateBuf = Buffer.concat([
91025
+ decipher.update(privateBuf), decipher.final()]);
91026
+ }
91027
+
91028
+ key = new PrivateKey(key);
91029
+ if (key.type !== keyType) {
91030
+ throw (new Error('Outer key algorithm mismatch'));
91031
+ }
91032
+
91033
+ var sshbuf = new SSHBuffer({buffer: privateBuf});
91034
+ var privateKeyParts;
91035
+ if (alg === 'ssh-dss') {
91036
+ privateKeyParts = [ {
91037
+ name: 'x',
91038
+ data: sshbuf.readBuffer()
91039
+ }];
91040
+ } else if (alg === 'ssh-rsa') {
91041
+ privateKeyParts = [
91042
+ { name: 'd', data: sshbuf.readBuffer() },
91043
+ { name: 'p', data: sshbuf.readBuffer() },
91044
+ { name: 'q', data: sshbuf.readBuffer() },
91045
+ { name: 'iqmp', data: sshbuf.readBuffer() }
91046
+ ];
91047
+ } else if (alg.match(/^ecdsa-sha2-nistp/)) {
91048
+ privateKeyParts = [ {
91049
+ name: 'd', data: sshbuf.readBuffer()
91050
+ } ];
91051
+ } else if (alg === 'ssh-ed25519') {
91052
+ privateKeyParts = [ {
91053
+ name: 'k', data: sshbuf.readBuffer()
91054
+ } ];
91055
+ } else {
91056
+ throw new Error('Unsupported PPK key type: ' + alg);
91057
+ }
91058
+
91059
+ key = new PrivateKey({
91060
+ type: key.type,
91061
+ parts: key.parts.concat(privateKeyParts)
91062
+ });
91063
+ }
91064
+
90972
91065
  key.comment = comment;
90973
91066
  return (key);
90974
91067
  }
90975
91068
 
91069
+ function derivePPK2EncryptionKey(passphrase) {
91070
+ var hash1 = crypto.createHash('sha1').update(Buffer.concat([
91071
+ Buffer.from([0, 0, 0, 0]),
91072
+ Buffer.from(passphrase)
91073
+ ])).digest();
91074
+ var hash2 = crypto.createHash('sha1').update(Buffer.concat([
91075
+ Buffer.from([0, 0, 0, 1]),
91076
+ Buffer.from(passphrase)
91077
+ ])).digest();
91078
+ return (Buffer.concat([hash1, hash2]).slice(0, 32));
91079
+ }
91080
+
90976
91081
  function splitHeader(line) {
90977
91082
  var idx = line.indexOf(':');
90978
91083
  if (idx === -1)
@@ -91015,7 +91120,7 @@ function wrap(txt, len) {
91015
91120
  return (lines);
91016
91121
  }
91017
91122
 
91018
- },{"../errors":475,"../key":491,"./rfc4253":484,"assert-plus":387,"safer-buffer":470}],484:[function(require,module,exports){
91123
+ },{"../errors":475,"../key":491,"../private-key":492,"../ssh-buffer":494,"./rfc4253":484,"assert-plus":387,"crypto":81,"safer-buffer":470}],484:[function(require,module,exports){
91019
91124
  // Copyright 2015 Joyent, Inc.
91020
91125
 
91021
91126
  module.exports = {
@@ -93159,6 +93264,7 @@ formats['ssh-private'] = require('./formats/ssh-private');
93159
93264
  formats['openssh'] = formats['ssh-private'];
93160
93265
  formats['ssh'] = formats['ssh-private'];
93161
93266
  formats['dnssec'] = require('./formats/dnssec');
93267
+ formats['putty'] = require('./formats/putty');
93162
93268
 
93163
93269
  function PrivateKey(opts) {
93164
93270
  assert.object(opts, 'options');
@@ -93371,7 +93477,7 @@ PrivateKey._oldVersionDetect = function (obj) {
93371
93477
  return ([1, 0]);
93372
93478
  };
93373
93479
 
93374
- },{"./algs":471,"./dhe":473,"./ed-compat":474,"./errors":475,"./fingerprint":476,"./formats/auto":477,"./formats/dnssec":478,"./formats/pem":480,"./formats/pkcs1":481,"./formats/pkcs8":482,"./formats/rfc4253":484,"./formats/ssh-private":485,"./key":491,"./signature":493,"./utils":495,"assert-plus":387,"crypto":81,"safer-buffer":470,"tweetnacl":504,"util":243}],493:[function(require,module,exports){
93480
+ },{"./algs":471,"./dhe":473,"./ed-compat":474,"./errors":475,"./fingerprint":476,"./formats/auto":477,"./formats/dnssec":478,"./formats/pem":480,"./formats/pkcs1":481,"./formats/pkcs8":482,"./formats/putty":483,"./formats/rfc4253":484,"./formats/ssh-private":485,"./key":491,"./signature":493,"./utils":495,"assert-plus":387,"crypto":81,"safer-buffer":470,"tweetnacl":504,"util":243}],493:[function(require,module,exports){
93375
93481
  // Copyright 2015 Joyent, Inc.
93376
93482
 
93377
93483
  module.exports = Signature;