tlsd 2.6.3 → 2.6.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tlsd",
3
- "version": "2.6.3",
3
+ "version": "2.6.6",
4
4
  "description": "A server for web app prototyping with HTTPS and Websockets",
5
5
  "main": "tlsd.js",
6
6
  "bin": {
@@ -98,7 +98,7 @@
98
98
 
99
99
  const waiting = new WaitList()
100
100
 
101
- const send = function(m, cb) {
101
+ const send = function(m, cb, fail) {
102
102
  DBG( "send: " + o2j( m ) );
103
103
  if(m.msg_id === undefined) {
104
104
  m.msg_id = "CMID-" + next_seq(); // every message must have an id
@@ -106,7 +106,7 @@
106
106
 
107
107
  // put msg into waiting list if caller is expecting a reply
108
108
  if(cb) {
109
- waiting.ins( { msg: m, cb: cb }, m.msg_id );
109
+ waiting.ins( { msg: m, cb, fail }, m.msg_id );
110
110
  }
111
111
 
112
112
  DBG(">>---> server "+o2j( m ));
@@ -162,6 +162,24 @@
162
162
  return;
163
163
  }
164
164
 
165
+ if( typeof msg_in.error !== "undefined" ) {
166
+ // error response to a client initiated msg
167
+ var x = waiting.rem( msg_in.msg_id );
168
+ if( ! x ) {
169
+ cb_ctrl( "warning", "invalid reply", msg_in.msg_id );
170
+ return;
171
+ }
172
+
173
+ // route response to associated error call back
174
+ var m = x.msg
175
+ var fail = x.fail;
176
+ if( fail ) {
177
+ fail(msg_in.error);
178
+ }
179
+
180
+ return
181
+ }
182
+
165
183
  if( typeof msg_in.response !== "undefined" ) {
166
184
  // response to a client initiated msg
167
185
 
@@ -209,7 +227,7 @@
209
227
  };
210
228
 
211
229
  const via_ws = function( msg, okay = ()=>{}, fail = ()=>{} ) {
212
- conn.send( { msg }, okay );
230
+ conn.send( { msg }, okay, fail );
213
231
  };
214
232
 
215
233
  const connect = function( cb ) {
package/tlsd.js CHANGED
@@ -43,6 +43,7 @@ const next_seq = function() {
43
43
  // Tries to load the rpc handler module from root and if successful, passes the msg to it
44
44
  const rpc_handler = function( root, msg, xport, _okay, _fail ) {
45
45
 
46
+ V( "RPC " + o2j( msg ).abbr( 70 ) );
46
47
  D( "----------->>> "+xport+" "+o2j( msg, null, 2 ) );
47
48
 
48
49
  const okay = data => {
@@ -56,7 +57,7 @@ const rpc_handler = function( root, msg, xport, _okay, _fail ) {
56
57
  };
57
58
 
58
59
  const ouch = audit_error => {
59
- E( root + ": " + audit_error );
60
+ E( root + ": " + o2j(audit_error) );
60
61
  fail( "RPC error" ); // this is returned to browser
61
62
  };
62
63
 
@@ -65,11 +66,11 @@ const rpc_handler = function( root, msg, xport, _okay, _fail ) {
65
66
  try {
66
67
  mod( msg, okay, ouch );
67
68
  } catch( err ) {
68
- E( err );
69
+ E( (err instanceof Error ) ? err.stack : err );
69
70
  ouch( "RPC handler exception" );
70
71
  }
71
72
  } catch( err ) {
72
- E( err );
73
+ E( (err instanceof Error ) ? err.stack : err );
73
74
  ouch( "Error loading RPC handler" );
74
75
  }
75
76
  };
@@ -81,7 +82,8 @@ const ws_msg_handler = function( root, msg ) {
81
82
  rpc_handler( root, msg.msg, "WS", data => {
82
83
  msg.reply( data );
83
84
  }, error => {
84
- E( "This shouldn't happen: "+o2j(error,null,2) );
85
+ msg.error( { error } );
86
+ E( "Should this happen? "+o2j(error,null,2) );
85
87
  } );
86
88
  };
87
89
 
@@ -290,7 +292,6 @@ const ws_attach = function( httpServer, msg_handler ) {
290
292
 
291
293
  // -----------------------
292
294
 
293
-
294
295
  const argv = process.argv;
295
296
 
296
297
  if( argv.length == 2 ) {
@@ -309,7 +310,8 @@ if( argv.length == 2 ) {
309
310
  packageRoot: __dirname,
310
311
  maintainerEmail: MAINTAINER_EMAIL,
311
312
  configDir: "./greenlock.d",
312
- cluster: true
313
+ cluster: false,
314
+ //notify
313
315
  } ).ready( glx => {
314
316
 
315
317
  var httpd = glx.httpsServer();