tlsd 2.4.0 → 2.5.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/inchtml.js +40 -0
- package/package.json +2 -1
- package/server_static/rpc/rpc.js +5 -8
- package/server_static/rpc/test.html +2 -2
- package/test.html +4 -0
- package/tlsd.js +14 -14
- package/foo/rpc/index.js +0 -13
- package/foo/static/index.html +0 -15
package/inchtml.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
|
|
2
|
+
const fs = require( "fs" );
|
|
3
|
+
|
|
4
|
+
const { log, o2j, } = require( "sleepless" );
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
function parse( text ) {
|
|
8
|
+
|
|
9
|
+
const lines = text.split( /\n/g );
|
|
10
|
+
|
|
11
|
+
const newlines = [];
|
|
12
|
+
|
|
13
|
+
let ln = 0;
|
|
14
|
+
for( let line of lines ) {
|
|
15
|
+
|
|
16
|
+
ln += 1;
|
|
17
|
+
|
|
18
|
+
const words = line.split( /\s+/ );
|
|
19
|
+
|
|
20
|
+
if( words.shift() != "#include" ) {
|
|
21
|
+
newlines.push( line );
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if( words.length < 1 ) {
|
|
26
|
+
throw new Error( "parse error on line "+ln );
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const path = words.join( " " );
|
|
30
|
+
|
|
31
|
+
newlines.push( "**** included from file "+o2j(path) );
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return newlines.join( "\n" );
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let text = fs.readFileSync( process.argv[ 2 ], "utf8" );
|
|
39
|
+
log( parse( text ) );
|
|
40
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tlsd",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "A server for web app prototyping with HTTPS and Websockets",
|
|
5
5
|
"main": "tlsd.js",
|
|
6
6
|
"bin": {
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"greenlock-express": "^4.0.3",
|
|
22
22
|
"serve-static": "^1.15.0",
|
|
23
23
|
"sleepless": "^5.7.0",
|
|
24
|
+
"tlsd": "^2.4.1",
|
|
24
25
|
"websocket": "^1.0.34"
|
|
25
26
|
}
|
|
26
27
|
}
|
package/server_static/rpc/rpc.js
CHANGED
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
// Send msg via Websocket if it's less than around 5K stringified, otherwise use POST
|
|
7
7
|
RPC( msg_object, okay, fail );
|
|
8
8
|
|
|
9
|
-
RPC.
|
|
9
|
+
RPC.connect( function() {
|
|
10
10
|
RPC( { action: "Hello, I'm a client" }, rsp => {
|
|
11
11
|
console.log( rsp ) // "Welcome client, I'm a server"
|
|
12
12
|
}, error => {
|
|
13
13
|
alert( error )
|
|
14
14
|
} );
|
|
15
|
-
};
|
|
15
|
+
} );
|
|
16
16
|
|
|
17
17
|
RPC.debug = true; // enable on console debug output
|
|
18
18
|
|
|
@@ -196,13 +196,10 @@
|
|
|
196
196
|
let xhr = new XMLHttpRequest();
|
|
197
197
|
xhr.onload = function() {
|
|
198
198
|
let r = j2o( xhr.responseText );
|
|
199
|
-
if(
|
|
199
|
+
if( r === null && xhr.responseText !== "null" ) {
|
|
200
200
|
return fail( "Error parsing response from server." );
|
|
201
201
|
}
|
|
202
|
-
|
|
203
|
-
return fail( r.error );
|
|
204
|
-
}
|
|
205
|
-
okay( r.data, xhr );
|
|
202
|
+
okay( r, xhr );
|
|
206
203
|
};
|
|
207
204
|
xhr.onerror = fail;
|
|
208
205
|
xhr.open( "POST", RPC_URL );
|
|
@@ -216,7 +213,7 @@
|
|
|
216
213
|
};
|
|
217
214
|
|
|
218
215
|
const connect = function( cb ) {
|
|
219
|
-
if( connected ) {
|
|
216
|
+
if( RPC.connected ) {
|
|
220
217
|
cb();
|
|
221
218
|
} else {
|
|
222
219
|
RPC.on_connect = cb;
|
package/test.html
ADDED
package/tlsd.js
CHANGED
|
@@ -46,34 +46,34 @@ const next_seq = function() {
|
|
|
46
46
|
// Tries to load the rpc handler module from root and if successful, passes the msg to it
|
|
47
47
|
const rpc_handler = function( root, msg, _okay, _fail ) {
|
|
48
48
|
|
|
49
|
-
D( "----------->>> RPC "+o2j( msg, null, 2 ));
|
|
49
|
+
D( "----------->>> RPC "+o2j( msg, null, 2 ) );
|
|
50
50
|
|
|
51
51
|
const okay = data => {
|
|
52
|
-
D( "<<<=========== RPC OKAY "+o2j(data, null, 2 ));
|
|
52
|
+
D( "<<<=========== RPC OKAY "+o2j( data, null, 2 ) );
|
|
53
53
|
_okay( data );
|
|
54
54
|
};
|
|
55
|
+
|
|
55
56
|
const fail = error => {
|
|
56
|
-
D( "
|
|
57
|
+
D( "<<<*********** RPC ERROR "+o2j( error, null, 2 ) );
|
|
57
58
|
_fail( error );
|
|
58
59
|
};
|
|
59
60
|
|
|
60
|
-
const ouch =
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
E( error.stack );
|
|
64
|
-
}
|
|
65
|
-
fail( "RPC error" );
|
|
61
|
+
const ouch = audit_error => {
|
|
62
|
+
//E( root + ": " + audit_error );
|
|
63
|
+
fail( "RPC error" ); // this is returned to browser
|
|
66
64
|
};
|
|
67
65
|
|
|
68
66
|
try {
|
|
69
67
|
const mod = require( root + "/rpc" );
|
|
70
68
|
try {
|
|
71
|
-
mod( msg, okay,
|
|
69
|
+
mod( msg, okay, ouch );
|
|
72
70
|
} catch( err ) {
|
|
73
|
-
|
|
71
|
+
E( err );
|
|
72
|
+
ouch( "RPC handler exception" );
|
|
74
73
|
}
|
|
75
74
|
} catch( err ) {
|
|
76
|
-
|
|
75
|
+
E( err );
|
|
76
|
+
ouch( "Error loading RPC handler" );
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
79
|
|
|
@@ -82,9 +82,9 @@ const rpc_handler = function( root, msg, _okay, _fail ) {
|
|
|
82
82
|
// via the websockets msg object
|
|
83
83
|
const ws_msg_handler = function( root, msg ) {
|
|
84
84
|
rpc_handler( root, msg.msg, data => {
|
|
85
|
-
msg.reply(
|
|
85
|
+
msg.reply( data );
|
|
86
86
|
}, error => {
|
|
87
|
-
|
|
87
|
+
E( "This shouldn't happen." );
|
|
88
88
|
} );
|
|
89
89
|
};
|
|
90
90
|
|
package/foo/rpc/index.js
DELETED