Skip to content

Commit 1f54b2d

Browse files
committed
client side crypto
1 parent 31d3867 commit 1f54b2d

6 files changed

Lines changed: 16 additions & 9 deletions

File tree

src/comms/isocket-comms.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ class ISocketComms extends EventEmitter {
108108
const replyObj = JSON.parse(reply.data)
109109

110110
if(replyObj.enc && replyObj.sig){
111-
let msg = new Message(replyObj)
111+
let msg = new Message()
112+
msg.fromJSON(replyObj)
112113

113114
let content = await msg.decrypt(this.party.privateIdentity())
114115

@@ -172,7 +173,7 @@ class ISocketComms extends EventEmitter {
172173
debug('sending classic')
173174
const msg = new Message({msg: input})
174175
await msg.encrypt(this.party._identity, this.remoteIdentity.key)
175-
content = JSON.stringify(msg)
176+
content = JSON.stringify(msg.toJSON())
176177
}
177178

178179
await this.socket.send(content)

src/config/secure-config.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,8 @@ class SecureConfig extends IConfig {
372372

373373
this.content = await this.config.read(this.id+'.content')
374374

375-
const contentMsg = new dataparty_crypto.Message( this.content )
375+
const contentMsg = new dataparty_crypto.Message( )
376+
contentMsg.fromJSON(this.content)
376377

377378
//! Verify message
378379
await contentMsg.decrypt(pwIdentity)
@@ -467,7 +468,8 @@ class SecureConfig extends IConfig {
467468

468469
this.updateTimeout()
469470

470-
const decryptedContent = new dataparty_crypto.Message( this.content )
471+
const decryptedContent = new dataparty_crypto.Message( )
472+
decryptedContent.fromJSON(this.content)
471473
await decryptedContent.decrypt(this.identity)
472474

473475
return decryptedContent.msg

src/party/iparty.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ class IParty {
298298
const msg = new dataparty_crypto.Message({msg: data})
299299
await msg.encrypt(this._identity, to.key)
300300

301-
return msg
301+
return msg.toJSON()
302302
}
303303

304304
/**
@@ -311,7 +311,8 @@ class IParty {
311311
async decrypt(reply, expectedSender, expectClearTextReply = false){
312312
// if reply has ciphertext & sig attempt to decrypt
313313
if (reply.enc && reply.sig) {
314-
const msg = new dataparty_crypto.Message(reply)
314+
const msg = new dataparty_crypto.Message()
315+
msg.fromJSON(reply)
315316

316317
const replyContent = await msg.decrypt(this._identity)
317318

src/service/iauth.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,17 @@ module.exports = class IAuth {
2020
* @member module:Service.ITask.Name
2121
*/
2222
static get Name(){
23-
throw new Error('not implemented')
23+
return 'auth'
24+
//throw new Error('not implemented')
2425
}
2526

2627
/**
2728
* @type {string}
2829
* @member module:Service.ITask.Description
2930
*/
3031
static get Description(){
31-
throw new Error('not implemented')
32+
return 'default auth'
33+
//throw new Error('not implemented')
3234
}
3335

3436
async lookupIdentity(identity){

src/service/iservice.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ module.exports = class IService {
4848
},
4949
tasks: {},
5050
topics: {},
51-
auth: {}
51+
auth: null
5252
}
5353

5454
this.compiled = {

src/service/service-runner-node.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ class ServiceRunnerNode {
9999
async loadAuth(){
100100
if(this.auth){ return }
101101

102+
let name = 'auth'
102103
debug('loadAuth', name, 'useNative =',this.useNative)
103104

104105
let dt = new DeltaTime().start()

0 commit comments

Comments
 (0)