rascal 17.0.2 → 18.0.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,5 +1,10 @@
1
1
  # Change Log
2
2
 
3
+ ## 18.0.0
4
+
5
+ - Fixes https://github.com/onebeyond/rascal/issues/227 by requiring special characters to be URL encoded.
6
+ - Consolidated broker and management url configuration logic
7
+
3
8
  ## 17.0.2
4
9
 
5
10
  - Update guidesmiths references to onebeyond.
package/README.md CHANGED
@@ -47,9 +47,9 @@ Rascal extends the existing [RabbitMQ Concepts](https://www.rabbitmq.com/tutoria
47
47
 
48
48
  A **publication** is a named configuration for publishing a message, including the destination queue or exchange, routing configuration, encryption profile and reliability guarantees, message options, etc. A **subscription** is a named configuration for consuming messages, including the source queue, encryption profile, content encoding, delivery options (e.g. acknowledgement handling and prefetch), etc. These must be [configured](#configuration) and supplied when creating the Rascal broker. After the broker has been created the subscriptions and publications can be retrieved from the broker and used to publish and consume messages.
49
49
 
50
- ### Breaking Changes in Rascal@14
50
+ ### Breaking Changes
51
51
 
52
- Rascal@14 waits for inflight messages to be acknowledged before closing subscriber channels. Prior to this version Rascal just waited an arbitrary amount of time. If your application does not acknowledge a message for some reason (quite likely in tests) calling `subscription.cancel`, `broker.unsubscribeAll`, `broker.bounce`, `broker.shutdown` or `broker.nuke` will wait indefinitely. You can specify a `closeTimeout` in your subscription config, however if this is exceeded the `subscription.cancel` and `broker.unsubscribeAll` methods will yield an error via callback or rejection, while the `broker.bounce`, `broker.shutdown` and `broker.nuke` methods will emit an error event, but attempt to continue. In both cases the error will have a code of `ETIMEDOUT`.
52
+ Please refer to the [Change Log](https://github.com/onebeyond/rascal/blob/master/CHANGELOG.md)
53
53
 
54
54
  ### Special Note
55
55
 
@@ -318,6 +318,7 @@ The simplest way to specify a connection is with a url
318
318
  }
319
319
  }
320
320
  ```
321
+ As of Rascal v18.0.0 you must URL encode special characters appearing in the username, password and vhost, e.g. `amqp://guest:secr%23t@broker.example.com:5672/v1?heartbeat=10`
321
322
 
322
323
  Alternatively you can specify the individual connection details
323
324
 
@@ -345,6 +346,8 @@ Alternatively you can specify the individual connection details
345
346
  }
346
347
  ```
347
348
 
349
+ Special characters do not need to be encoded when specified in this form.
350
+
348
351
  Any attributes you add to the "options" sub document will be converted to query parameters. Any attributes you add in the "socketOptions" sub document will be passed directly to amqplib's connect method (which hands them off to `net` or `tls`. Providing you merge your configuration with the default configuration `rascal.withDefaultConfig(config)` you need only specify the attributes you want to override
349
352
 
350
353
  ```json
@@ -459,7 +462,7 @@ The AMQP protocol doesn't support assertion or checking of vhosts, so Rascal use
459
462
  }
460
463
  ```
461
464
 
462
- Rascal uses [superagent](https://github.com/visionmedia/superagent) under the hood. URL configuration is supported.
465
+ Rascal uses [superagent](https://github.com/visionmedia/superagent) under the hood. URL configuration is also supported.
463
466
 
464
467
  ```json
465
468
  {
@@ -91,7 +91,7 @@ module.exports = _.curry((rascalConfig, next) => {
91
91
  } = new URL(connectionString);
92
92
  const options = Array.from(searchParams).reduce((attributes, entry) => ({ ...attributes, [entry[0]]: entry[1] }), {});
93
93
  return {
94
- protocol, hostname, port, user, password, vhost, options,
94
+ protocol, hostname: decodeURIComponent(hostname), port, user: decodeURIComponent(user), password: decodeURIComponent(password), vhost: decodeURIComponent(vhost), options,
95
95
  };
96
96
  }
97
97
 
@@ -105,10 +105,14 @@ module.exports = _.curry((rascalConfig, next) => {
105
105
  }
106
106
 
107
107
  function configureManagementConnection(vhostConfig, vhostName, connection) {
108
- _.defaultsDeep(connection.management, { hostname: connection.hostname });
109
- const auth = connection.management.auth || getAuth(connection.management.user, connection.management.password) || getAuth(connection.user, connection.password);
110
- connection.management.url = connection.management.url || url.format({ ...connection.management, auth });
111
- connection.management.loggableUrl = connection.management.url.replace(/:[^:]*?@/, ':***@');
108
+ connection.management = _.isString(connection.management) ? { url: connection.management } : connection.management;
109
+ const attributesFromUrl = parseConnectionUrl(connection.management.url);
110
+ const attributesFromConfig = getConnectionAttributes(connection.management);
111
+ const defaults = { user: connection.user, password: connection.password, hostname: connection.hostname };
112
+
113
+ const connectionAttributes = _.defaultsDeep({ options: null }, attributesFromUrl, attributesFromConfig, defaults);
114
+ setConnectionAttributes(connection.management, connectionAttributes);
115
+ setConnectionUrls(connection.management);
112
116
  }
113
117
 
114
118
  function setConnectionAttributes(connection, attributes, defaults) {
@@ -120,7 +124,6 @@ module.exports = _.curry((rascalConfig, next) => {
120
124
  const auth = getAuth(connection.user, connection.password);
121
125
  const pathname = connection.vhost === '/' ? '' : connection.vhost;
122
126
  const query = connection.options;
123
-
124
127
  connection.url = url.format({
125
128
  slashes: true, ...connection, auth, pathname, query,
126
129
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rascal",
3
- "version": "17.0.2",
3
+ "version": "18.0.0",
4
4
  "description": "A config driven wrapper for amqplib supporting multi-host connections, automatic error recovery, redelivery flood protection, transparent encryption / decryption, channel pooling and publication timeouts",
5
5
  "main": "index.js",
6
6
  "dependencies": {