amqplib 0.5.2 → 0.5.3
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 +44 -0
- package/Makefile +2 -1
- package/README.md +2 -2
- package/lib/api_args.js +2 -0
- package/lib/channel.js +22 -10
- package/lib/connect.js +6 -16
- package/lib/connection.js +2 -1
- package/lib/credentials.js +14 -0
- package/lib/defs.js +128 -0
- package/package.json +9 -8
- package/test/channel.js +73 -61
- package/test/connect.js +32 -7
- package/test/connection.js +47 -47
- package/test/mux.js +10 -6
- package/test/util.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
# Change log for amqplib
|
|
2
2
|
|
|
3
|
+
## Changes in v0.5.3
|
|
4
|
+
|
|
5
|
+
git log v0.5.2..v0.5.3
|
|
6
|
+
|
|
7
|
+
* Bump bitsyntax to remove some `Buffer` misuse deprecation notices
|
|
8
|
+
([PR 480])(https://github.com/squaremo/amqp.node/pull/480)
|
|
9
|
+
* Test on node 11.1
|
|
10
|
+
([PR 473])(https://github.com/squaremo/amqp.node/pull/464); thanks
|
|
11
|
+
@kibertoad
|
|
12
|
+
* Updated various dependencies
|
|
13
|
+
* Support queue mode during assertQueue
|
|
14
|
+
([PR 464])(https://github.com/squaremo/amqp.node/pull/464); thanks
|
|
15
|
+
@JoeTheFkingFrypan
|
|
16
|
+
* Expose serverProperties in the connection object
|
|
17
|
+
([PR 452])(https://github.com/squaremo/amqp.node/pull/452); thanks
|
|
18
|
+
@jfromaniello
|
|
19
|
+
* Test on Node 10
|
|
20
|
+
([PR 454])(https://github.com/squaremo/amqp.node/pull/454); thanks
|
|
21
|
+
@kibertoad
|
|
22
|
+
* Support amqplain credentials
|
|
23
|
+
([PR 451])(https://github.com/squaremo/amqp.node/pull/451); thanks
|
|
24
|
+
@jfromaniello
|
|
25
|
+
* Decorate channel errors with methodId and classId
|
|
26
|
+
([PR 447])(https://github.com/squaremo/amqp.node/pull/447); thanks
|
|
27
|
+
@MitMaro
|
|
28
|
+
* Resolve issues caused by Node 10 `readable` changes
|
|
29
|
+
([PR 442])(https://github.com/squaremo/amqp.node/pull/442)
|
|
30
|
+
* Bump uglify to 2.6.x and node to 9.1 due to nodejs/node#16781.
|
|
31
|
+
([PR 439])(https://github.com/squaremo/amqp.node/pull/439)
|
|
32
|
+
* Updated README with more modern Buffer syntax
|
|
33
|
+
([PR 438](https://github.com/squaremo/amqp.node/pull/438); thanks
|
|
34
|
+
@ravshansbox
|
|
35
|
+
* Support overflow option to assert queue
|
|
36
|
+
([PR 436])(https://github.com/squaremo/amqp.node/pull/436); thanks
|
|
37
|
+
to @honestserpent
|
|
38
|
+
* Replace instances of keyword `await`
|
|
39
|
+
([PR 396])(https://github.com/squaremo/amqp.node/pull/396),
|
|
40
|
+
as discussed in
|
|
41
|
+
[issue 235](https://github.com/squaremo/amqp.node/issues/235)
|
|
42
|
+
* Use 3rd party url for better decoding of username/password
|
|
43
|
+
([PR 395])(https://github.com/squaremo/amqp.node/pull/395),
|
|
44
|
+
as discussed in
|
|
45
|
+
[issue 385](https://github.com/squaremo/amqp.node/issues/385))
|
|
46
|
+
|
|
3
47
|
## Changes in v0.5.2
|
|
4
48
|
|
|
5
49
|
git log v0.5.1..v0.5.2
|
package/Makefile
CHANGED
|
@@ -2,7 +2,8 @@ RABBITMQ_SRC_VERSION=rabbitmq_v3_2_1
|
|
|
2
2
|
JSON=amqp-rabbitmq-0.9.1.json
|
|
3
3
|
RABBITMQ_CODEGEN=https://raw.githubusercontent.com/rabbitmq/rabbitmq-codegen
|
|
4
4
|
AMQP_JSON=$(RABBITMQ_CODEGEN)/$(RABBITMQ_SRC_VERSION)/$(JSON)
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
NODEJS_VERSIONS='0.8' '0.9' '0.10' '0.11' '0.12' '1.6' '2.5' '3.3' '4.2' '5.5' '6.2' '8.9' '9.11' '10.7' '11.1'
|
|
6
7
|
|
|
7
8
|
MOCHA=./node_modules/.bin/mocha
|
|
8
9
|
_MOCHA=./node_modules/.bin/_mocha
|
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ function publisher(conn) {
|
|
|
47
47
|
function on_open(err, ch) {
|
|
48
48
|
if (err != null) bail(err);
|
|
49
49
|
ch.assertQueue(q);
|
|
50
|
-
ch.sendToQueue(q,
|
|
50
|
+
ch.sendToQueue(q, Buffer.from('something to do'));
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -86,7 +86,7 @@ open.then(function(conn) {
|
|
|
86
86
|
return conn.createChannel();
|
|
87
87
|
}).then(function(ch) {
|
|
88
88
|
return ch.assertQueue(q).then(function(ok) {
|
|
89
|
-
return ch.sendToQueue(q,
|
|
89
|
+
return ch.sendToQueue(q, Buffer.from('something to do'));
|
|
90
90
|
});
|
|
91
91
|
}).catch(console.warn);
|
|
92
92
|
|
package/lib/api_args.js
CHANGED
|
@@ -58,6 +58,8 @@ Args.assertQueue = function(queue, options) {
|
|
|
58
58
|
options.deadLetterRoutingKey);
|
|
59
59
|
setIfDefined(argt, 'x-max-length', options.maxLength);
|
|
60
60
|
setIfDefined(argt, 'x-max-priority', options.maxPriority);
|
|
61
|
+
setIfDefined(argt, 'x-overflow', options.overflow);
|
|
62
|
+
setIfDefined(argt, 'x-queue-mode', options.queueMode);
|
|
61
63
|
|
|
62
64
|
return {
|
|
63
65
|
queue: queue,
|
package/lib/channel.js
CHANGED
|
@@ -103,9 +103,10 @@ C._rpc = function(method, fields, expect, cb) {
|
|
|
103
103
|
// We have detected a problem, so it's up to us to close the
|
|
104
104
|
// channel
|
|
105
105
|
var expectedName = methodName(expect);
|
|
106
|
+
|
|
106
107
|
var e = new Error(fmt("Expected %s; got %s",
|
|
107
108
|
expectedName, inspect(f, false)));
|
|
108
|
-
self.closeWithError(fmt('Expected %s; got %s',
|
|
109
|
+
self.closeWithError(f.id, fmt('Expected %s; got %s',
|
|
109
110
|
expectedName, methodName(f.id)),
|
|
110
111
|
defs.constants.UNEXPECTED_FRAME, e);
|
|
111
112
|
return cb(e);
|
|
@@ -124,7 +125,11 @@ C._rpc = function(method, fields, expect, cb) {
|
|
|
124
125
|
? fmt("Operation failed: %s; %s",
|
|
125
126
|
methodName(method), closeMsg(err))
|
|
126
127
|
: fmt("Channel closed by server: %s", closeMsg(err));
|
|
127
|
-
|
|
128
|
+
var closeFrameError = new Error(e);
|
|
129
|
+
closeFrameError.code = err.fields.replyCode;
|
|
130
|
+
closeFrameError.classId = err.fields.classId;
|
|
131
|
+
closeFrameError.methodId = err.fields.methodId;
|
|
132
|
+
return cb(closeFrameError);
|
|
128
133
|
}
|
|
129
134
|
}
|
|
130
135
|
|
|
@@ -186,7 +191,7 @@ C.toClosing = function(capturedStack, k) {
|
|
|
186
191
|
};
|
|
187
192
|
|
|
188
193
|
C._rejectPending = function() {
|
|
189
|
-
function rej(r) {
|
|
194
|
+
function rej(r) {
|
|
190
195
|
r(new Error("Channel ended, no reply will be forthcoming"));
|
|
191
196
|
}
|
|
192
197
|
if (this.reply !== null) rej(this.reply);
|
|
@@ -210,10 +215,15 @@ C.closeBecause = function(reason, code, k) {
|
|
|
210
215
|
// If we close because there's been an error, we need to distinguish
|
|
211
216
|
// between what we tell the server (`reason`) and what we report as
|
|
212
217
|
// the cause in the client (`error`).
|
|
213
|
-
C.closeWithError = function(reason, code, error) {
|
|
218
|
+
C.closeWithError = function(id, reason, code, error) {
|
|
214
219
|
var self = this;
|
|
215
220
|
this.closeBecause(reason, code, function() {
|
|
216
221
|
error.code = code;
|
|
222
|
+
// content frames and consumer errors do not provide a method a class/method ID
|
|
223
|
+
if (id) {
|
|
224
|
+
error.classId = defs.info(id).classId;
|
|
225
|
+
error.methodId = defs.info(id).methodId;
|
|
226
|
+
}
|
|
217
227
|
self.emit('error', error);
|
|
218
228
|
});
|
|
219
229
|
};
|
|
@@ -232,15 +242,15 @@ C.acceptMessageFrame = function(f) {
|
|
|
232
242
|
}
|
|
233
243
|
catch (msg) {
|
|
234
244
|
if (typeof msg === 'string') {
|
|
235
|
-
this.closeWithError(msg, defs.constants.UNEXPECTED_FRAME,
|
|
245
|
+
this.closeWithError(f.id, msg, defs.constants.UNEXPECTED_FRAME,
|
|
236
246
|
new Error(msg));
|
|
237
247
|
}
|
|
238
248
|
else if (msg instanceof Error) {
|
|
239
|
-
this.closeWithError('Error while processing message',
|
|
249
|
+
this.closeWithError(f.id, 'Error while processing message',
|
|
240
250
|
defs.constants.INTERNAL_ERROR, msg);
|
|
241
251
|
}
|
|
242
252
|
else {
|
|
243
|
-
this.closeWithError('Internal error while processing message',
|
|
253
|
+
this.closeWithError(f.id, 'Internal error while processing message',
|
|
244
254
|
defs.constants.INTERNAL_ERROR,
|
|
245
255
|
new Error(msg.toString()));
|
|
246
256
|
}
|
|
@@ -283,7 +293,7 @@ function acceptMessage(continuation) {
|
|
|
283
293
|
if (f.id === defs.BasicProperties) {
|
|
284
294
|
message.properties = f.fields;
|
|
285
295
|
totalSize = remaining = f.size;
|
|
286
|
-
|
|
296
|
+
|
|
287
297
|
// for zero-length messages, content frames aren't required.
|
|
288
298
|
if (totalSize === 0) {
|
|
289
299
|
message.content = Buffer.alloc(0);
|
|
@@ -291,7 +301,7 @@ function acceptMessage(continuation) {
|
|
|
291
301
|
return acceptDeliveryOrReturn;
|
|
292
302
|
}
|
|
293
303
|
else {
|
|
294
|
-
return content;
|
|
304
|
+
return content;
|
|
295
305
|
}
|
|
296
306
|
}
|
|
297
307
|
else {
|
|
@@ -405,6 +415,8 @@ C.accept = function(f) {
|
|
|
405
415
|
|
|
406
416
|
var error = new Error(emsg);
|
|
407
417
|
error.code = f.fields.replyCode;
|
|
418
|
+
error.classId = f.fields.classId;
|
|
419
|
+
error.methodId = f.fields.methodId;
|
|
408
420
|
this.emit('error', error);
|
|
409
421
|
|
|
410
422
|
var s = stackCapture(emsg);
|
|
@@ -413,7 +425,7 @@ C.accept = function(f) {
|
|
|
413
425
|
|
|
414
426
|
case defs.BasicFlow:
|
|
415
427
|
// RabbitMQ doesn't send this, it just blocks the TCP socket
|
|
416
|
-
return this.closeWithError("Flow not implemented",
|
|
428
|
+
return this.closeWithError(f.id, "Flow not implemented",
|
|
417
429
|
defs.constants.NOT_IMPLEMENTED,
|
|
418
430
|
new Error('Flow not implemented'));
|
|
419
431
|
|
package/lib/connect.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
|
-
var URL = require('url');
|
|
9
|
+
var URL = require('url-parse');
|
|
10
10
|
var QS = require('querystring');
|
|
11
11
|
var Connection = require('./connection').Connection;
|
|
12
12
|
var fmt = require('util').format;
|
|
@@ -76,22 +76,12 @@ function openFrames(vhost, query, credentials, extraClientProperties) {
|
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
// Decide on credentials based on what we're supplied.
|
|
80
|
-
// parsed URL, the auth part is already URL-decoded, so e.g., '%3a' in
|
|
81
|
-
// the URL is already decoded to ':'. This is a bit unhelpful, as it
|
|
82
|
-
// means we can't tell whether a colon is a separator, or part of the
|
|
83
|
-
// username. Assume no colons in usernames.
|
|
79
|
+
// Decide on credentials based on what we're supplied.
|
|
84
80
|
function credentialsFromUrl(parts) {
|
|
85
81
|
var user = 'guest', passwd = 'guest';
|
|
86
|
-
if (parts.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
user = parts.auth;
|
|
90
|
-
passwd = '';
|
|
91
|
-
} else {
|
|
92
|
-
user = parts.auth.substring(0, colon);
|
|
93
|
-
passwd = parts.auth.substring(colon+1);
|
|
94
|
-
}
|
|
82
|
+
if (parts.username != '' || parts.password != '') {
|
|
83
|
+
user = (parts.username) ? unescape(parts.username) : '';
|
|
84
|
+
passwd = (parts.password) ? unescape(parts.password) : '';
|
|
95
85
|
}
|
|
96
86
|
return credentials.plain(user, passwd);
|
|
97
87
|
}
|
|
@@ -137,7 +127,7 @@ function connect(url, socketOptions, openCallback) {
|
|
|
137
127
|
|
|
138
128
|
fields = openFrames(url.vhost, config, sockopts.credentials || credentials.plain(user, pass), extraClientProperties);
|
|
139
129
|
} else {
|
|
140
|
-
var parts = URL
|
|
130
|
+
var parts = URL(url, true); // yes, parse the query string
|
|
141
131
|
protocol = parts.protocol;
|
|
142
132
|
sockopts.host = parts.hostname;
|
|
143
133
|
sockopts.port = parseInt(parts.port) || ((protocol === 'amqp:') ? 5672 : 5671);
|
package/lib/connection.js
CHANGED
|
@@ -205,6 +205,7 @@ C.open = function(allFields, openCallback0) {
|
|
|
205
205
|
allFields.mechanism)));
|
|
206
206
|
return;
|
|
207
207
|
}
|
|
208
|
+
self.serverProperties = start.fields.serverProperties;
|
|
208
209
|
send(defs.ConnectionStartOk);
|
|
209
210
|
wait(afterStartOk);
|
|
210
211
|
}
|
|
@@ -465,7 +466,7 @@ C.freshChannel = function(channel, options) {
|
|
|
465
466
|
C.releaseChannel = function(channel) {
|
|
466
467
|
this.freeChannels.clear(channel);
|
|
467
468
|
var buffer = this.channels[channel].buffer;
|
|
468
|
-
|
|
469
|
+
buffer.end(); // will also cause it to be unpiped
|
|
469
470
|
this.channels[channel] = null;
|
|
470
471
|
};
|
|
471
472
|
|
package/lib/credentials.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
// * EXTERNAL (assume the server will figure out who you are from
|
|
10
10
|
// context, i.e., your SSL certificate)
|
|
11
11
|
var Buffer = require('safe-buffer').Buffer
|
|
12
|
+
var codec = require('./codec')
|
|
12
13
|
|
|
13
14
|
module.exports.plain = function(user, passwd) {
|
|
14
15
|
return {
|
|
@@ -21,6 +22,19 @@ module.exports.plain = function(user, passwd) {
|
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
|
|
25
|
+
module.exports.amqplain = function(user, passwd) {
|
|
26
|
+
return {
|
|
27
|
+
mechanism: 'AMQPLAIN',
|
|
28
|
+
response: function() {
|
|
29
|
+
const buffer = Buffer.alloc(16384);
|
|
30
|
+
const size = codec.encodeTable(buffer, { LOGIN: user, PASSWORD: passwd}, 0);
|
|
31
|
+
return buffer.slice(4, size);
|
|
32
|
+
},
|
|
33
|
+
username: user,
|
|
34
|
+
password: passwd
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
24
38
|
module.exports.external = function() {
|
|
25
39
|
return {
|
|
26
40
|
mechanism: 'EXTERNAL',
|