ioredis 4.27.8 → 4.28.0

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.
package/Changelog.md CHANGED
@@ -1,3 +1,32 @@
1
+ # [4.28.0](https://github.com/luin/ioredis/compare/v4.27.11...v4.28.0) (2021-10-13)
2
+
3
+
4
+ ### Features
5
+
6
+ * **tls:** add TLS profiles for easier configuration ([#1441](https://github.com/luin/ioredis/issues/1441)) ([4680211](https://github.com/luin/ioredis/commit/4680211fe853831f9ff3a3eb69f16d5db6bfbabd))
7
+
8
+ ## [4.27.11](https://github.com/luin/ioredis/compare/v4.27.10...v4.27.11) (2021-10-11)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * make export interface compatible with jest ([#1445](https://github.com/luin/ioredis/issues/1445)) ([2728dbe](https://github.com/luin/ioredis/commit/2728dbe5289ebc8603484bc85c01632cfab98204))
14
+
15
+ ## [4.27.10](https://github.com/luin/ioredis/compare/v4.27.9...v4.27.10) (2021-10-04)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * **cluster:** lazyConnect with pipeline ([#1408](https://github.com/luin/ioredis/issues/1408)) ([b798107](https://github.com/luin/ioredis/commit/b798107e4123d0027ef1bdb3319cd00516221f3b))
21
+
22
+ ## [4.27.9](https://github.com/luin/ioredis/compare/v4.27.8...v4.27.9) (2021-08-30)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * Fix undefined property warning in executeAutoPipeline ([#1425](https://github.com/luin/ioredis/issues/1425)) ([f898672](https://github.com/luin/ioredis/commit/f898672a29753774eeb6e166c28ed6f548533517))
28
+ * improve proto checking for hgetall [skip ci] ([#1418](https://github.com/luin/ioredis/issues/1418)) ([cba83cb](https://github.com/luin/ioredis/commit/cba83cba2dba25e59ad87c85d740f15f78e45e14))
29
+
1
30
  ## [4.27.8](https://github.com/luin/ioredis/compare/v4.27.7...v4.27.8) (2021-08-18)
2
31
 
3
32
 
package/README.md CHANGED
@@ -578,7 +578,7 @@ redis.get("k3", (err, result) => {
578
578
  });
579
579
  ```
580
580
 
581
- Another useful example of a reply transformer is one that changes `hgetall` to return array of arrays instead of objects which avoids a unwanted conversation of hash keys to strings when dealing with binary hash keys:
581
+ Another useful example of a reply transformer is one that changes `hgetall` to return array of arrays instead of objects which avoids an unwanted conversation of hash keys to strings when dealing with binary hash keys:
582
582
 
583
583
  ```javascript
584
584
  Redis.Command.setReplyTransformer("hgetall", (result) => {
@@ -791,7 +791,7 @@ const redis = new Redis({ enableOfflineQueue: false });
791
791
 
792
792
  ## TLS Options
793
793
 
794
- Redis doesn't support TLS natively, however if the redis server you want to connect to is hosted behind a TLS proxy (e.g. [stunnel](https://www.stunnel.org/)) or is offered by a PaaS service that supports TLS connection (e.g. [Redis Labs](https://redislabs.com/)), you can set the `tls` option:
794
+ Redis doesn't support TLS natively, however if the redis server you want to connect to is hosted behind a TLS proxy (e.g. [stunnel](https://www.stunnel.org/)) or is offered by a PaaS service that supports TLS connection (e.g. [Redis.com](https://redis.com/)), you can set the `tls` option:
795
795
 
796
796
  ```javascript
797
797
  const redis = new Redis({
@@ -811,6 +811,30 @@ Alternatively, specify the connection through a [`rediss://` URL](https://www.ia
811
811
  const redis = new Redis("rediss://redis.my-service.com");
812
812
  ```
813
813
 
814
+ ### TLS Profiles
815
+
816
+ To make it easier to configure we provide a few pre-configured TLS profiles that can be specified by setting the `tls` option to the profile's name or specifying a `tls.profile` option in case you need to customize some values of the profile.
817
+
818
+ Profiles:
819
+
820
+ - `RedisCloudFixed`: Contains the CA for [Redis.com](https://redis.com/) Cloud fixed subscriptions
821
+ - `RedisCloudFlexible`: Contains the CA for [Redis.com](https://redis.com/) Cloud flexible subscriptions
822
+
823
+ ```javascript
824
+ const redis = new Redis({
825
+ host: "localhost",
826
+ tls: "RedisCloudFixed",
827
+ });
828
+
829
+ const redisWithClientCertificate = new Redis({
830
+ host: "localhost",
831
+ tls: {
832
+ profile: "RedisCloudFixed",
833
+ key: "123",
834
+ },
835
+ });
836
+ ```
837
+
814
838
  <hr>
815
839
 
816
840
  ## Sentinel
@@ -27,6 +27,16 @@ function executeAutoPipeline(client, slotKey) {
27
27
  if (client._runningAutoPipelines.has(slotKey)) {
28
28
  return;
29
29
  }
30
+ if (!client._autoPipelines.has(slotKey)) {
31
+ /*
32
+ Rare edge case. Somehow, something has deleted this running autopipeline in an immediate
33
+ call to executeAutoPipeline.
34
+
35
+ Maybe the callback in the pipeline.exec is sometimes called in the same tick,
36
+ e.g. if redis is disconnected?
37
+ */
38
+ return;
39
+ }
30
40
  client._runningAutoPipelines.add(slotKey);
31
41
  // Get the pipeline and immediately delete it so that new commands are queued on a new pipeline
32
42
  const pipeline = client._autoPipelines.get(slotKey);
@@ -90,6 +100,8 @@ function executeWithAutoPipelining(client, functionName, commandName, args, call
90
100
  const CustomPromise = PromiseContainer.get();
91
101
  // On cluster mode let's wait for slots to be available
92
102
  if (client.isCluster && !client.slots.length) {
103
+ if (client.status === "wait")
104
+ client.connect().catch(lodash_1.noop);
93
105
  return new CustomPromise(function (resolve, reject) {
94
106
  client.delayUntilReady((err) => {
95
107
  if (err) {
@@ -45,7 +45,7 @@ function normalizeNodeOptions(nodes) {
45
45
  if (!options.host) {
46
46
  options.host = "127.0.0.1";
47
47
  }
48
- return options;
48
+ return utils_1.resolveTLSProfile(options);
49
49
  });
50
50
  }
51
51
  exports.normalizeNodeOptions = normalizeNodeOptions;
package/built/command.js CHANGED
@@ -315,7 +315,7 @@ Command.setReplyTransformer("hgetall", function (result) {
315
315
  for (let i = 0; i < result.length; i += 2) {
316
316
  const key = result[i];
317
317
  const value = result[i + 1];
318
- if (obj[key]) {
318
+ if (key in obj) {
319
319
  // can only be truthy if the property is special somehow, like '__proto__' or 'constructor'
320
320
  // https://github.com/luin/ioredis/issues/1267
321
321
  Object.defineProperty(obj, key, {
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ /**
5
+ * TLS settings for Redis.com Cloud Fixed plan. Updated on 2021-10-06.
6
+ */
7
+ RedisCloudFixed: {
8
+ ca: "-----BEGIN CERTIFICATE-----\n" +
9
+ "MIIDTzCCAjegAwIBAgIJAKSVpiDswLcwMA0GCSqGSIb3DQEBBQUAMD4xFjAUBgNV\n" +
10
+ "BAoMDUdhcmFudGlhIERhdGExJDAiBgNVBAMMG1NTTCBDZXJ0aWZpY2F0aW9uIEF1\n" +
11
+ "dGhvcml0eTAeFw0xMzEwMDExMjE0NTVaFw0yMzA5MjkxMjE0NTVaMD4xFjAUBgNV\n" +
12
+ "BAoMDUdhcmFudGlhIERhdGExJDAiBgNVBAMMG1NTTCBDZXJ0aWZpY2F0aW9uIEF1\n" +
13
+ "dGhvcml0eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALZqkh/DczWP\n" +
14
+ "JnxnHLQ7QL0T4B4CDKWBKCcisriGbA6ZePWVNo4hfKQC6JrzfR+081NeD6VcWUiz\n" +
15
+ "rmd+jtPhIY4c+WVQYm5PKaN6DT1imYdxQw7aqO5j2KUCEh/cznpLxeSHoTxlR34E\n" +
16
+ "QwF28Wl3eg2vc5ct8LjU3eozWVk3gb7alx9mSA2SgmuX5lEQawl++rSjsBStemY2\n" +
17
+ "BDwOpAMXIrdEyP/cVn8mkvi/BDs5M5G+09j0gfhyCzRWMQ7Hn71u1eolRxwVxgi3\n" +
18
+ "TMn+/vTaFSqxKjgck6zuAYjBRPaHe7qLxHNr1So/Mc9nPy+3wHebFwbIcnUojwbp\n" +
19
+ "4nctkWbjb2cCAwEAAaNQME4wHQYDVR0OBBYEFP1whtcrydmW3ZJeuSoKZIKjze3w\n" +
20
+ "MB8GA1UdIwQYMBaAFP1whtcrydmW3ZJeuSoKZIKjze3wMAwGA1UdEwQFMAMBAf8w\n" +
21
+ "DQYJKoZIhvcNAQEFBQADggEBAG2erXhwRAa7+ZOBs0B6X57Hwyd1R4kfmXcs0rta\n" +
22
+ "lbPpvgULSiB+TCbf3EbhJnHGyvdCY1tvlffLjdA7HJ0PCOn+YYLBA0pTU/dyvrN6\n" +
23
+ "Su8NuS5yubnt9mb13nDGYo1rnt0YRfxN+8DM3fXIVr038A30UlPX2Ou1ExFJT0MZ\n" +
24
+ "uFKY6ZvLdI6/1cbgmguMlAhM+DhKyV6Sr5699LM3zqeI816pZmlREETYkGr91q7k\n" +
25
+ "BpXJu/dtHaGxg1ZGu6w/PCsYGUcECWENYD4VQPd8N32JjOfu6vEgoEAwfPP+3oGp\n" +
26
+ "Z4m3ewACcWOAenqflb+cQYC4PsF7qbXDmRaWrbKntOlZ3n0=\n" +
27
+ "-----END CERTIFICATE-----\n",
28
+ },
29
+ /**
30
+ * TLS settings for Redis.com Cloud Flexible plan. Updated on 2021-10-06.
31
+ */
32
+ RedisCloudFlexible: {
33
+ ca: "-----BEGIN CERTIFICATE-----\n" +
34
+ "MIIGMTCCBBmgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwajELMAkGA1UEBhMCVVMx\n" +
35
+ "CzAJBgNVBAgMAkNBMQswCQYDVQQHDAJDQTESMBAGA1UECgwJUmVkaXNMYWJzMS0w\n" +
36
+ "KwYDVQQDDCRSZWRpc0xhYnMgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcN\n" +
37
+ "MTgwMjI1MTUzNzM3WhcNMjgwMjIzMTUzNzM3WjBfMQswCQYDVQQGEwJVUzELMAkG\n" +
38
+ "A1UECAwCQ0ExEjAQBgNVBAoMCVJlZGlzTGFiczEvMC0GA1UEAwwmUkNQIEludGVy\n" +
39
+ "bWVkaWF0ZSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUA\n" +
40
+ "A4ICDwAwggIKAoICAQDf9dqbxc8Bq7Ctq9rWcxrGNKKHivqLAFpPq02yLPx6fsOv\n" +
41
+ "Tq7GsDChAYBBc4v7Y2Ap9RD5Vs3dIhEANcnolf27QwrG9RMnnvzk8pCvp1o6zSU4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87
+ "cS+jZHFGzD7PUVGQD01nOQIDAQABo2MwYTAdBgNVHQ4EFgQUIuNsB+oTOC9rLoxL\n" +
88
+ "yzNP7vJUV08wHwYDVR0jBBgwFoAUIuNsB+oTOC9rLoxLyzNP7vJUV08wDwYDVR0T\n" +
89
+ "AQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQELBQADggIBAHfg\n" +
90
+ "z5pMNUAKdMzK1aS1EDdK9yKz4qicILz5czSLj1mC7HKDRy8cVADUxEICis++CsCu\n" +
91
+ "rYOvyCVergHQLREcxPq4rc5Nq1uj6J6649NEeh4WazOOjL4ZfQ1jVznMbGy+fJm3\n" +
92
+ "3Hoelv6jWRG9iqeJZja7/1s6YC6bWymI/OY1e4wUKeNHAo+Vger7MlHV+RuabaX+\n" +
93
+ "hSJ8bJAM59NCM7AgMTQpJCncrcdLeceYniGy5Q/qt2b5mJkQVkIdy4TPGGB+AXDJ\n" +
94
+ "D0q3I/JDRkDUFNFdeW0js7fHdsvCR7O3tJy5zIgEV/o/BCkmJVtuwPYOrw/yOlKj\n" +
95
+ "TY/U7ATAx9VFF6/vYEOMYSmrZlFX+98L6nJtwDqfLB5VTltqZ4H/KBxGE3IRSt9l\n" +
96
+ "FXy40U+LnXzhhW+7VBAvyYX8GEXhHkKU8Gqk1xitrqfBXY74xKgyUSTolFSfFVgj\n" +
97
+ "mcM/X4K45bka+qpkj7Kfv/8D4j6aZekwhN2ly6hhC1SmQ8qjMjpG/mrWOSSHZFmf\n" +
98
+ "ybu9iD2AYHeIOkshIl6xYIa++Q/00/vs46IzAbQyriOi0XxlSMMVtPx0Q3isp+ji\n" +
99
+ "n8Mq9eOuxYOEQ4of8twUkUDd528iwGtEdwf0Q01UyT84S62N8AySl1ZBKXJz6W4F\n" +
100
+ "UhWfa/HQYOAPDdEjNgnVwLI23b8t0TozyCWw7q8h\n" +
101
+ "-----END CERTIFICATE-----\n",
102
+ },
103
+ };
package/built/pipeline.js CHANGED
@@ -8,6 +8,7 @@ const calculateSlot = require("cluster-key-slot");
8
8
  const pMap = require("p-map");
9
9
  const PromiseContainer = require("./promiseContainer");
10
10
  const commander_1 = require("./commander");
11
+ const utils_1 = require("./utils");
11
12
  /*
12
13
  This function derives from the cluster-key-slot implementation.
13
14
  Instead of checking that all keys have the same slot, it checks that all slots are served by the same set of nodes.
@@ -140,7 +141,8 @@ Pipeline.prototype.fillResult = function (value, position) {
140
141
  moved: function (slot, key) {
141
142
  _this.preferKey = key;
142
143
  _this.redis.slots[errv[1]] = [key];
143
- _this.redis._groupsBySlot[errv[1]] = _this.redis._groupsIds[_this.redis.slots[errv[1]].join(";")];
144
+ _this.redis._groupsBySlot[errv[1]] =
145
+ _this.redis._groupsIds[_this.redis.slots[errv[1]].join(";")];
144
146
  _this.redis.refreshSlotsCache();
145
147
  _this.exec();
146
148
  },
@@ -214,6 +216,8 @@ Pipeline.prototype.execBuffer = util_1.deprecate(function () {
214
216
  Pipeline.prototype.exec = function (callback) {
215
217
  // Wait for the cluster to be connected, since we need nodes information before continuing
216
218
  if (this.isCluster && !this.redis.slots.length) {
219
+ if (this.redis.status === "wait")
220
+ this.redis.connect().catch(utils_1.noop);
217
221
  this.redis.delayUntilReady((err) => {
218
222
  if (err) {
219
223
  callback(err);
@@ -229,6 +229,7 @@ Redis.prototype.parseOptions = function () {
229
229
  if (this.options.parser === "hiredis") {
230
230
  console.warn("Hiredis parser is abandoned since ioredis v3.0, and JavaScript parser will be used");
231
231
  }
232
+ this.options = utils_1.resolveTLSProfile(this.options);
232
233
  };
233
234
  /**
234
235
  * Change instance's status
@@ -29,6 +29,8 @@ function addTransactionSupport(redis) {
29
29
  pipeline.exec = function (callback) {
30
30
  // Wait for the cluster to be connected, since we need nodes information before continuing
31
31
  if (this.isCluster && !this.redis.slots.length) {
32
+ if (this.redis.status === "wait")
33
+ this.redis.connect().catch(utils_1.noop);
32
34
  return standard_as_callback_1.default(new Promise((resolve, reject) => {
33
35
  this.redis.delayUntilReady((err) => {
34
36
  if (err) {
@@ -7,6 +7,7 @@ exports.noop = lodash_1.noop;
7
7
  exports.flatten = lodash_1.flatten;
8
8
  const debug_1 = require("./debug");
9
9
  exports.Debug = debug_1.default;
10
+ const TLSProfiles_1 = require("../constants/TLSProfiles");
10
11
  /**
11
12
  * Test if two buffers are equal
12
13
  *
@@ -286,6 +287,25 @@ function parseURL(url) {
286
287
  return result;
287
288
  }
288
289
  exports.parseURL = parseURL;
290
+ /**
291
+ * Resolve TLS profile shortcut in connection options
292
+ *
293
+ * @param {Object} options - the redis connection options
294
+ * @return {Object}
295
+ */
296
+ function resolveTLSProfile(options) {
297
+ let tls = options === null || options === void 0 ? void 0 : options.tls;
298
+ if (typeof tls === "string")
299
+ tls = { profile: tls };
300
+ const profile = TLSProfiles_1.default[tls === null || tls === void 0 ? void 0 : tls.profile];
301
+ if (profile) {
302
+ tls = Object.assign({}, profile, tls);
303
+ delete tls.profile;
304
+ options = Object.assign({}, options, { tls });
305
+ }
306
+ return options;
307
+ }
308
+ exports.resolveTLSProfile = resolveTLSProfile;
289
309
  /**
290
310
  * Get a random element from `array`
291
311
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ioredis",
3
- "version": "4.27.8",
3
+ "version": "4.28.0",
4
4
  "description": "A robust, performance-focused and full-featured Redis client for Node.js.",
5
5
  "main": "built/index.js",
6
6
  "files": [
@@ -76,7 +76,7 @@
76
76
  "server-destroy": "^1.0.1",
77
77
  "sinon": "^9.0.1",
78
78
  "ts-node": "^8.8.1",
79
- "typescript": "^3.8.3",
79
+ "typescript": "3.8.3",
80
80
  "uuid": "^8.3.0"
81
81
  },
82
82
  "engines": {