publication-server
Advanced tools
Comparing version 1.9.2 to 2.0.0
{ | ||
"extends": "mixmax/node" | ||
} | ||
"extends": ["mixmax/node", "mixmax/prettier"] | ||
} |
## Release History | ||
* 2.0.0 Update primus to 8.0.1. You must now install your own transformer packages. | ||
* 1.9.2 Fix botched 1.9.1 publish to include primus and uws downgrades | ||
@@ -25,2 +27,18 @@ | ||
* 1.5.1 Fix Subscription initialization parameters | ||
* 1.5.1 Prevent `Subscription#whenReady` from resolving prematurely after the websocket connects; implement `PublicationClient#whenConnected` | ||
* 1.5.0 Use Yarn; fix `uws` dependency after previous versions were unpublished. | ||
* 1.4.4 Remove message field from nosub message. | ||
* 1.4.1 Handle subscription initialization errors. | ||
* 1.4.0 Handle custom event broadcasting (for shutdown message specifically). | ||
* 1.3.0 All shutdown options passed through to Primus. | ||
* 1.1.1 Fix bad ObjectUtils reference. | ||
* 1.1.0 Alter how we wrap the authentication function and make it required. | ||
* 1.0.0 Initial release |
{ | ||
"name": "publication-server", | ||
"version": "1.9.2", | ||
"version": "2.0.0", | ||
"description": "", | ||
@@ -20,3 +20,3 @@ "main": "src/index.js", | ||
"node-uuid": "^1.4.7", | ||
"primus": "^6.1.0", | ||
"primus": "^8.0.1", | ||
"underscore": "^1.8.3", | ||
@@ -26,4 +26,6 @@ "uws": "^0.14.1" | ||
"devDependencies": { | ||
"eslint": "^5.15.3", | ||
"eslint-config-mixmax": "^2.0.0" | ||
"@mixmaxhq/prettier-config": "^1.0.0", | ||
"eslint": "^6.8.0", | ||
"eslint-config-mixmax": "^4.8.0", | ||
"prettier": "^1.19.1" | ||
}, | ||
@@ -30,0 +32,0 @@ "repository": { |
@@ -132,21 +132,2 @@ publication-server | ||
See [publication-client](https://github.com/mixmaxhq/publication-server/blob/master/client/README.md) for the client for this server. | ||
### Server changelog | ||
May contain some client releases pre-1.5.0. | ||
* 1.5.1 Prevent `Subscription#whenReady` from resolving prematurely after the websocket connects; implement `PublicationClient#whenConnected` | ||
* 1.5.0 Use Yarn; fix `uws` dependency after previous versions were unpublished. | ||
* 1.4.5 `err._publicationName` -> `err.publicationName` | ||
* 1.4.4 Add the publication name to the error we emit on subscription errors. | ||
* 1.4.3 Delete subscription references client side when we unsubscribe from a publication. | ||
* 1.4.2 Fix typo with unsubscribe message. | ||
* 1.4.1 Handle subscription initialization errors. | ||
* 1.4.0 Handle custom event broadcasting (for shutdown message specifically). | ||
* 1.3.0 All shutdown options to be passed through to Primus. | ||
* 1.2.1 Enforce message ordering to the client. | ||
* 1.1.1 Fix bad ObjectUtils reference. | ||
* 1.1.0 Alter how we wrap the authentication function and make it required. | ||
* 1.0.0 Initial release of server and client | ||
See [publication-client](https://github.com/mixmaxhq/publication-client) for the client for this server. |
@@ -24,3 +24,3 @@ 'use strict'; | ||
*/ | ||
constructor({authFn, mountPath, errHandler, server, transformer} = {}) { | ||
constructor({ authFn, mountPath, errHandler, server, transformer } = {}) { | ||
assert(authFn, 'Must provide an authorization function'); | ||
@@ -44,7 +44,7 @@ | ||
transformer: transformer || 'uws', | ||
pingInterval: false | ||
pingInterval: false, | ||
}); | ||
this._primus.on('connection', (spark) => { | ||
new Session({server: this, spark}); | ||
new Session({ server: this, spark }); | ||
}); | ||
@@ -87,7 +87,9 @@ } | ||
shutdown(timeout, options) { | ||
this._primus.destroy(_.defaults(options, { | ||
// Don't force the HTTP server to close by default, that's not our job. | ||
close: false, | ||
timeout | ||
})); | ||
this._primus.destroy( | ||
_.defaults(options, { | ||
// Don't force the HTTP server to close by default, that's not our job. | ||
close: false, | ||
timeout, | ||
}) | ||
); | ||
} | ||
@@ -94,0 +96,0 @@ } |
@@ -1,2 +0,1 @@ | ||
/** | ||
@@ -38,2 +37,2 @@ * A publication error wraps the original error while also providing us with | ||
module.exports = PublicationError; | ||
module.exports = PublicationError; |
@@ -14,3 +14,2 @@ 'use strict'; | ||
class Session { | ||
/** | ||
@@ -22,3 +21,3 @@ * Constructs a session for a given Primus spark. | ||
*/ | ||
constructor({server, spark} = {}) { | ||
constructor({ server, spark } = {}) { | ||
this.server = server; | ||
@@ -32,3 +31,3 @@ this.spark = spark; | ||
connect: this.connect.bind(this), | ||
ping: this.ping.bind(this) | ||
ping: this.ping.bind(this), | ||
}; | ||
@@ -72,3 +71,3 @@ | ||
msg: 'failed', | ||
version: '1' | ||
version: '1', | ||
}); | ||
@@ -88,3 +87,3 @@ this.stop(); | ||
msg: 'connected', | ||
session: this._sessionId | ||
session: this._sessionId, | ||
}); | ||
@@ -98,3 +97,3 @@ } | ||
var resp = { | ||
msg: 'pong' | ||
msg: 'pong', | ||
}; | ||
@@ -122,3 +121,3 @@ if (msg.id) resp.id = msg.id; | ||
reason: 'connect-must-be-first', | ||
offendingMessage: msg | ||
offendingMessage: msg, | ||
}); | ||
@@ -143,3 +142,3 @@ return; | ||
reason: 'unable-to-parse-params', | ||
offendingMessage: msg | ||
offendingMessage: msg, | ||
}); | ||
@@ -154,3 +153,3 @@ return; | ||
reason: 'invalid-params', | ||
offendingMessage: msg | ||
offendingMessage: msg, | ||
}); | ||
@@ -166,3 +165,3 @@ return; | ||
id: msg.id, | ||
error: 'sub-not-found' | ||
error: 'sub-not-found', | ||
}); | ||
@@ -178,3 +177,3 @@ return; | ||
params, | ||
id: msg.id | ||
id: msg.id, | ||
}); | ||
@@ -204,3 +203,3 @@ this._subscriptions[msg.id] = subscription; | ||
reason: 'no-such-subscription-to-unsub', | ||
offendingMessage: msg | ||
offendingMessage: msg, | ||
}); | ||
@@ -233,3 +232,3 @@ return; | ||
reason: 'unknown-msg-type', | ||
offendingMessage: msg | ||
offendingMessage: msg, | ||
}); | ||
@@ -276,3 +275,3 @@ return; | ||
reason: 'must-provide-msg-type', | ||
offendingMessage: data | ||
offendingMessage: data, | ||
}); | ||
@@ -289,3 +288,2 @@ return; | ||
module.exports = Session; |
@@ -20,3 +20,3 @@ 'use strict'; | ||
*/ | ||
constructor({session, name, handler, params, id} = {}) { | ||
constructor({ session, name, handler, params, id } = {}) { | ||
this._session = session; | ||
@@ -48,61 +48,64 @@ this._name = name; | ||
_start() { | ||
this._handler.apply({ | ||
userId: this._session.userId, | ||
name: this._name, | ||
this._handler.apply( | ||
{ | ||
userId: this._session.userId, | ||
name: this._name, | ||
/** | ||
* Sends an added message adding an object with the given `id` to the given | ||
* `collection`. | ||
* | ||
* @param {String} collection The collection that the document is being added | ||
* to. | ||
* @param {String} id The ID of the document being added. | ||
* @param {Object} fields The fields that comprise the document being added. | ||
*/ | ||
added: (collection, id, fields) => { | ||
this._session.send({ | ||
msg: 'added', | ||
collection, | ||
id, | ||
fields | ||
}); | ||
}, | ||
/** | ||
* Sends an added message adding an object with the given `id` to the given | ||
* `collection`. | ||
* | ||
* @param {String} collection The collection that the document is being added | ||
* to. | ||
* @param {String} id The ID of the document being added. | ||
* @param {Object} fields The fields that comprise the document being added. | ||
*/ | ||
added: (collection, id, fields) => { | ||
this._session.send({ | ||
msg: 'added', | ||
collection, | ||
id, | ||
fields, | ||
}); | ||
}, | ||
/** | ||
* Sends a changed message changing the object with the given `id` in the | ||
* given `collection`. | ||
* | ||
* @param {String} collection The collection that the document that is being | ||
* changed is a member of. | ||
* @param {String} id The ID of the document being changed. | ||
* @param {Object} fields The fields that have been changed. | ||
*/ | ||
changed: (collection, id, fields) => { | ||
this._session.send({ | ||
msg: 'changed', | ||
collection, | ||
id, | ||
fields | ||
}); | ||
}, | ||
/** | ||
* Sends a changed message changing the object with the given `id` in the | ||
* given `collection`. | ||
* | ||
* @param {String} collection The collection that the document that is being | ||
* changed is a member of. | ||
* @param {String} id The ID of the document being changed. | ||
* @param {Object} fields The fields that have been changed. | ||
*/ | ||
changed: (collection, id, fields) => { | ||
this._session.send({ | ||
msg: 'changed', | ||
collection, | ||
id, | ||
fields, | ||
}); | ||
}, | ||
/** | ||
* Sends a removed message removing the object with the given `id` from the | ||
* given `collection`. | ||
* | ||
* @param {String} collection The collection that the document is being | ||
* removed from. | ||
* @param {String} id The ID of the document being removed. | ||
*/ | ||
removed: (collection, id) => { | ||
this._session.send({ | ||
msg: 'removed', | ||
collection, | ||
id | ||
}); | ||
/** | ||
* Sends a removed message removing the object with the given `id` from the | ||
* given `collection`. | ||
* | ||
* @param {String} collection The collection that the document is being | ||
* removed from. | ||
* @param {String} id The ID of the document being removed. | ||
*/ | ||
removed: (collection, id) => { | ||
this._session.send({ | ||
msg: 'removed', | ||
collection, | ||
id, | ||
}); | ||
}, | ||
onStop: this.onStop.bind(this), | ||
ready: this.ready.bind(this), | ||
error: this.error.bind(this), | ||
}, | ||
onStop: this.onStop.bind(this), | ||
ready: this.ready.bind(this), | ||
error: this.error.bind(this) | ||
}, this._params); | ||
this._params | ||
); | ||
} | ||
@@ -118,9 +121,11 @@ | ||
error(err) { | ||
this._session.server._errHandler(new PublicationError(err, { | ||
userId: this._session.userId, | ||
extra: { | ||
name: this._name, | ||
params: this._params | ||
} | ||
})); | ||
this._session.server._errHandler( | ||
new PublicationError(err, { | ||
userId: this._session.userId, | ||
extra: { | ||
name: this._name, | ||
params: this._params, | ||
}, | ||
}) | ||
); | ||
this._session.send({ | ||
@@ -130,4 +135,4 @@ msg: 'nosub', | ||
error: { | ||
error: err.message || '' | ||
} | ||
error: err.message || '', | ||
}, | ||
}); | ||
@@ -147,3 +152,3 @@ } | ||
msg: 'ready', | ||
subs: [this._id] | ||
subs: [this._id], | ||
}); | ||
@@ -170,3 +175,2 @@ } | ||
module.exports = Subscription; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
0
1
23204
4
14
517
133
+ Addeddiagnostics@2.0.2(transitive)
+ Addedenabled@2.0.0(transitive)
+ Addedeventemitter3@4.0.75.0.1(transitive)
+ Addedforwarded-for@1.1.0(transitive)
+ Addedkuler@2.0.0(transitive)
+ Addednanoid@3.3.8(transitive)
+ Addedprimus@8.0.9(transitive)
+ Addedstorage-engine@3.0.7(transitive)
- Removeddebug@0.7.4(transitive)
- Removedeventemitter3@2.0.3(transitive)
- Removedforwarded-for@1.0.1(transitive)
- Removedprimus@6.1.0(transitive)
- Removedsetheader@0.0.4(transitive)
- Removedyeast@0.1.2(transitive)
Updatedprimus@^8.0.1