Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

exorelay

Package Overview
Dependencies
Maintainers
4
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

exorelay - npm Package Compare versions

Comparing version 0.22.1 to 0.23.0

10

dist/exorelay.js

@@ -47,3 +47,3 @@ // Generated by LiveScript 1.5.0

ExoRelay.prototype.send = function(messageName, payload, replyHandler){
var messageId;
var message;
switch (false) {

@@ -53,7 +53,7 @@ case !(replyHandler && typeof replyHandler !== 'function'):

}
messageId = this.websocketConnector.send(messageName, payload);
message = this.websocketConnector.send(messageName, payload);
if (replyHandler) {
this.messageHandler.registerReplyHandler(messageId, replyHandler);
this.messageHandler.registerReplyHandler(message.activityId, replyHandler);
}
return messageId;
return message;
};

@@ -66,3 +66,3 @@ ExoRelay.prototype._onIncomingMessage = function(requestData){

return this.messageHandler.handleRequest(requestData, {
reply: this.websocketConnector.replyMethodFor(requestData.id),
reply: this.websocketConnector.replyMethodFor(requestData.id, requestData.sessionId),
send: this.send

@@ -69,0 +69,0 @@ });

@@ -32,6 +32,6 @@ // Generated by LiveScript 1.5.0

HandlerRegistry.prototype.handleReply = function(arg$){
var messageName, responseTo, payload, handler, e;
messageName = arg$.messageName, responseTo = arg$.responseTo, payload = arg$.payload;
if (handler = this.getHandler(responseTo)) {
debug("handling message '" + messageName + "' in response to '" + responseTo + "'");
var messageName, activityId, payload, handler, e;
messageName = arg$.messageName, activityId = arg$.activityId, payload = arg$.payload;
if (handler = this.getHandler(activityId)) {
debug("handling message '" + messageName + "' in discussion of activity '" + activityId + "'");
try {

@@ -38,0 +38,0 @@ handler(payload, {

@@ -20,4 +20,4 @@ // Generated by LiveScript 1.5.0

});
afterEach(function(){
return this.websocketConnector.close();
afterEach(function(done){
return this.websocketConnector.close(done);
});

@@ -27,3 +27,3 @@ return describe('reply-method-for', function(){

this.websocketConnector.send = sinon.stub();
return this.replyMethod = this.websocketConnector.replyMethodFor('123');
return this.replyMethod = this.websocketConnector.replyMethodFor('123', '1');
});

@@ -35,7 +35,8 @@ it('returns a function that calls @send prebound to the response id', function(){

'reply-message', 'payload', {
responseTo: '123'
activityId: '123',
sessionId: '1'
}
]);
});
return context('missing id', function(){
return context('missing activity-id', function(){
beforeEach(function(){

@@ -45,3 +46,3 @@ return this.websocketConnector.replyMethodFor(null);

return it('emits an error', function(done){
expect(this.error.message).to.eql('WebSocketConnector.replyMethodFor needs an id');
expect(this.error.message).to.eql('WebSocketConnector.replyMethodFor needs an activity-id');
return done();

@@ -48,0 +49,0 @@ });

@@ -18,22 +18,31 @@ // Generated by LiveScript 1.5.0

this._onSocketOpen = bind$(this, '_onSocketOpen', prototype);
this._onSocketClose = bind$(this, '_onSocketClose', prototype);
this.connect = bind$(this, 'connect', prototype);
this.exocomPort = +this.exocomPort;
this.lastSentId = null;
this.lastSentMessage = null;
}
WebSocketConnector.prototype.close = function(){
var ref$;
WebSocketConnector.prototype.close = function(done){
if (!this.socket) {
return;
return done();
}
debug("no longer connected at 'ws://" + this.exocomHost + "/" + this.exocomPort + "'");
if ((ref$ = this.socket) != null) {
ref$.close();
this.shouldReconnectOnSocketClosed = false;
switch (this.socket.readyState) {
case WebSocket.CONNECTING:
this.socket.terminate();
return done();
case WebSocket.OPEN:
this.socket.on('close', done);
return this.socket.close();
case WebSocket.CLOSING:
return this.socket.on('close', done);
case WebSocket.CLOSED:
return done();
}
return this.emit('offline');
};
WebSocketConnector.prototype.replyMethodFor = function(id){
WebSocketConnector.prototype.replyMethodFor = function(activityId, sessionId){
var this$ = this;
switch (false) {
case !!id:
return this.emit('error', new Error('WebSocketConnector.replyMethodFor needs an id'));
case !!activityId:
return this.emit('error', new Error('WebSocketConnector.replyMethodFor needs an activity-id'));
}

@@ -43,3 +52,4 @@ return function(messageName, payload){

return this$.send(messageName, payload, {
responseTo: id
activityId: activityId,
sessionId: sessionId
});

@@ -63,3 +73,4 @@ };

sender: this.role,
id: uuid.v1()
id: uuid.v1(),
activityId: options.activityId || uuid.v1()
};

@@ -69,10 +80,11 @@ if (payload != null) {

}
if (options.responseTo) {
requestData.responseTo = options.responseTo;
if (options.sessionId) {
requestData.sessionId = options.sessionId;
}
this.socket.send(JSON.stringify(requestData));
return this.lastSentId = requestData.id;
return this.lastSentMessage = requestData;
};
WebSocketConnector.prototype.connect = function(){
var x$;
this.shouldReconnectOnSocketClosed = true;
x$ = this.socket = new WebSocket("ws://" + this.exocomHost + ":" + this.exocomPort + "/services");

@@ -82,4 +94,11 @@ x$.on('open', this._onSocketOpen);

x$.on('error', this._onSocketError);
x$.on('close', this._onSocketClose);
return x$;
};
WebSocketConnector.prototype._onSocketClose = function(){
this.emit('offline');
if (this.shouldReconnectOnSocketClosed) {
return this.connect();
}
};
WebSocketConnector.prototype._onSocketOpen = function(){

@@ -92,4 +111,2 @@ return this.emit('online');

return this.emit('error', "port " + this.exocomPort + " is already in use");
case error.errno !== 'ECONNREFUSED':
return wait(1000, this.connect);
default:

@@ -117,18 +134,8 @@ return this.emit('error', error);

WebSocketConnector.prototype._logReceived = function(arg$){
var messageName, id, responseTo;
messageName = arg$.messageName, id = arg$.id, responseTo = arg$.responseTo;
switch (false) {
case !responseTo:
return debug(" received message '" + messageName + "' with id '" + id + "' in response to '" + responseTo + "'");
default:
return debug("received message '" + messageName + "' with id '" + id + "'");
}
var messageName, id, activityId;
messageName = arg$.messageName, id = arg$.id, activityId = arg$.activityId;
return debug("received message '" + messageName + "' with id '" + id + "' in discussion of '" + activityId + "'");
};
WebSocketConnector.prototype._logSending = function(messageName, options){
switch (false) {
case !options.responseTo:
return debug("sending message '" + messageName + "' in response to '" + options.responseTo + "'");
default:
return debug("sending message '" + messageName + "'");
}
return debug("sending message '" + messageName + "' in discussion of '" + options.activityId + "'");
};

@@ -139,4 +146,5 @@ WebSocketConnector.prototype._parseRequest = function(req){

payload: req.payload,
responseTo: req.responseTo,
id: req.id
activityId: req.activityId,
id: req.id,
sessionId: req.sessionId
};

@@ -143,0 +151,0 @@ };

{
"name": "exorelay",
"version": "0.22.1",
"version": "0.23.0",
"author": "Kevin Goslar",

@@ -16,3 +16,3 @@ "dependencies": {

"chai": "3.5.0",
"cucumber": "1.3.1",
"cucumber": "2.3.1",
"cucumber-snippets-livescript": "1.0.1",

@@ -22,3 +22,2 @@ "dependency-lint": "5.0.1",

"exocom-mock": "0.21.4",
"ip": "1.1.5",
"jsdiff-console": "2.2.1",

@@ -25,0 +24,0 @@ "livescript": "1.5.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc