File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ async function main(){
6666 callTime2 . start ( )
6767
6868 const echoReply2 = await party . comms . call ( 'secure-echo' , { t :( new Date ( ) ) . getTime ( ) } , {
69- expectClearTextReply : true ,
69+ expectClearTextReply : false ,
7070 sendClearTextRequest : false ,
7171 useSessions : false
7272 } )
@@ -75,10 +75,11 @@ async function main(){
7575 complete ++
7676
7777 const text = `call deltaMs=<i>${ callTime2 . deltaMs } </i>ms complete ${ complete } `
78- document . getElementById ( "console " ) . innerHTML = text
78+ document . getElementById ( "secure-echo-speed " ) . innerHTML = text
7979
80- } , 150 )
80+ } , 250 )
8181
82+
8283 setInterval ( async ( ) => {
8384 //console.log('send')
8485
@@ -97,9 +98,9 @@ async function main(){
9798 complete ++
9899
99100 const text = `call deltaMs=<i>${ callTime2 . deltaMs } </i>ms complete ${ complete } `
100- document . getElementById ( "console " ) . innerHTML = text
101+ document . getElementById ( "echo-speed " ) . innerHTML = text
101102
102- } , 75 )
103+ } , 100 )
103104
104105}
105106
Original file line number Diff line number Diff line change 66
77
88 < body >
9- < p id ="console "> </ p >
9+ < div >
10+ < i > /echo</ i > < p id ="echo-speed "> </ p >
11+ </ div >
12+ < br />
13+ < div >
14+ < i > /secure-echo</ i > < p id ="secure-echo-speed "> </ p >
15+ </ div >
1016 </ body >
1117</ html >
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ module.exports = class SecureEchoEndpoint extends IEndpoint {
2323 validate : Joi . object ( ) . keys ( null ) . description ( 'any input allowed' ) ,
2424 } ,
2525 post : {
26- encrypt : false ,
26+ encrypt : true ,
2727 validate : Joi . object ( ) . keys ( null ) . description ( 'any output allowed' )
2828 }
2929 }
Original file line number Diff line number Diff line change 11const Joi = require ( '@hapi/joi' )
22const Hoek = require ( '@hapi/hoek' )
3- const { Message, Routines } = require ( '@dataparty/crypto' )
3+ const { Message, Identity } = require ( '@dataparty/crypto' )
44const debug = require ( 'debug' ) ( 'dataparty.middleware.post.encrypt' )
55
66const IMiddleware = require ( '../../imiddleware' )
@@ -27,25 +27,20 @@ module.exports = class Encrypt extends IMiddleware {
2727
2828 }
2929
30- static async run ( context ) {
30+ static async run ( ctx ) {
3131
32- if ( ! Hoek . reach ( context , 'endpoint.MiddlewareConfig.post.encrypt' , false ) ) {
33- return
34- }
32+ if ( ! Config ) { return }
3533
3634
37- const msg = new Message ( context . input )
38- const jsonContent = await msg . decrpyt ( this . serviceParty . privateIdentity )
39- const publicKeys = Routines . extractPublicKeys ( msg . enc )
35+ const senderStr = JSON . stringify ( { key : ctx . senderKey } )
4036
41- context . setInputSession ( jsonContent . session )
37+ const reply = new Message ( { msg : ctx . output } )
38+ const sender = Identity . fromString ( senderStr )
39+
40+ const payload = await reply . encrypt ( ctx . party . privateIdentity , sender . key )
41+
42+ ctx . debug ( 'setting payload' , payload )
43+ ctx . setOutput ( payload )
4244
43- return {
44- input : Hoek . reach ( content , 'data' ) ,
45- sender : {
46- type : 'ecdsa' ,
47- public : publicKeys
48- }
49- }
5045 }
5146}
Original file line number Diff line number Diff line change @@ -164,9 +164,10 @@ class ServiceRunner {
164164
165165 await this . runMiddleware ( middlewareCfg , context , 'post' )
166166
167- debug ( 'result' , result )
167+ /*debug('ctx.log', context._debugContent)*/
168+ debug ( 'result' , context . output )
168169
169- context . res . send ( result )
170+ context . res . send ( context . output )
170171
171172 }
172173 catch ( err ) {
You can’t perform that action at this time.
0 commit comments