Skip to content

Commit 26c8d72

Browse files
author
nullagent
committed
ephemeral sessions working now
1 parent 4a0d12f commit 26c8d72

5 files changed

Lines changed: 55 additions & 12 deletions

File tree

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@
6262
"mkssl": "openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem"
6363
},
6464
"dependencies": {
65+
"@babel/runtime": "^7.28.4",
6566
"@dataparty/bouncer-db": "1.0.1",
66-
"@dataparty/crypto": "github:datapartyjs/dataparty-crypto#postquantum-bson",
67+
"@dataparty/crypto": "github:datapartyjs/dataparty-crypto",
6768
"@dataparty/tasker": "^0.0.3",
6869
"@diva.exchange/i2p-sam": "^4.1.8",
6970
"@markwylde/liferaft": "^1.3.4",

src/comms/op/auth-op.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@ class AuthOp extends SocketOp {
1919
this.stream = aesStreamOffer.stream
2020

2121
const offer = {
22-
sender: aesStreamOffer.sender,
22+
sender: {
23+
id: aesStreamOffer.sender.key.id,
24+
key: {
25+
type: aesStreamOffer.sender.key.type,
26+
hash: aesStreamOffer.sender.key.hash,
27+
public: aesStreamOffer.sender.key.public
28+
}
29+
},
2330
pqCipherText: aesStreamOffer.pqCipherText,
2431
streamNonce: aesStreamOffer.streamNonce
2532
}

src/comms/rest-comms.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,20 @@ class RestComms extends EventEmitter {
4949
await this.loadCloud()
5050
await this.party.loadIdentity()
5151
await this.party.loadActor()
52-
await this.loadSession()
52+
//await this.loadSession()
5353

5454
if (this.authed) {
5555
return
5656
}
5757

5858
if (this.party.hasActor() && this.party.hasIdentity()) {
59-
if (this.hasSession()) {
59+
/*if (this.hasSession()) {
6060
debug('RECOVERING SESSION')
6161
return this.authRecover().catch(this.allocateSession.bind(this))
6262
}
6363
6464
debug('ALLOCATING SESSION')
65-
return this.allocateSession()
65+
return this.allocateSession()*/
6666
}
6767

6868
throw new Error('client needs to be enrolled')

src/party/peer/match-maker-client.js

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ class MatchMakerClient extends EventEmitter {
7575
party:this.restParty,
7676
config: this.restParty.config
7777
})
78+
79+
this.restParty.comms.sessionId = this.sessionKey.key.hash
7880
}
7981

8082
await this.announcePublicKeys()
@@ -86,7 +88,7 @@ class MatchMakerClient extends EventEmitter {
8688
uri: this.wsUrl,
8789
discoverRemoteIdentity: false,
8890
remoteIdentity: await this.restParty.comms.getServiceIdentity(),
89-
session: Math.random().toString(36).slice(2)
91+
session: this.sessionKey.key.hash
9092
}),
9193
config: this.restParty.config
9294
})
@@ -208,9 +210,13 @@ annoucement: {
208210
}
209211
}
210212

213+
211214
const actorSigMsg = await this.identity.sign(announceData.annoucement, true)
212215
const sessionSigMsg = await this.sessionKey.sign(announceData.annoucement, true)
213216

217+
debug('actorSigMsg', actorSigMsg)
218+
debug('sessionSigMsg', sessionSigMsg)
219+
214220
announceData.trust.actorSig = dataparty_crypto.Routines.Utils.base64.encode( actorSigMsg.sig )
215221
announceData.trust.sessionSig = dataparty_crypto.Routines.Utils.base64.encode( sessionSigMsg.sig )
216222

@@ -240,7 +246,7 @@ annoucement: {
240246
const lookupResult = await this.restParty.comms.call('key/lookup', lookupData, {
241247
expectClearTextReply: false,
242248
sendClearTextRequest: false,
243-
useSessions: false
249+
useSessions: true
244250
})
245251

246252
if(!lookupResult.done){
@@ -297,7 +303,7 @@ annoucement: {
297303
const inviteResult = await this.restParty.comms.call('invite/create', invitePostData, {
298304
expectClearTextReply: false,
299305
sendClearTextRequest: false,
300-
useSessions: false
306+
useSessions: true
301307
})
302308

303309
const inviteDoc = inviteResult.invite
@@ -328,7 +334,7 @@ annoucement: {
328334
const lookupResult = await this.restParty.comms.call('invite/lookup', lookup, {
329335
expectClearTextReply: false,
330336
sendClearTextRequest: false,
331-
useSessions: false
337+
useSessions: true
332338
})
333339

334340
if(!lookupResult.done){
@@ -387,14 +393,14 @@ annoucement: {
387393

388394
const inviteState = {
389395
invite: invite.inviteDoc.$meta.id,
390-
actor,
396+
//actor,
391397
state: newState
392398
}
393399

394400
const inviteStateResult = await this.restParty.comms.call('invite/set-state', inviteState, {
395401
expectClearTextReply: false,
396402
sendClearTextRequest: false,
397-
useSessions: false
403+
useSessions: true
398404
})
399405

400406
console.log('setInviteState result', inviteStateResult)
@@ -405,6 +411,35 @@ annoucement: {
405411

406412
return inviteStateResult.invite
407413
}
414+
415+
async createShortCode(uses=3, expiry){
416+
debug('setInviteState')
417+
let actor = this.identity.key.hash
418+
419+
const request = {
420+
invite: invite.inviteDoc.$meta.id,
421+
actor,
422+
state: newState
423+
}
424+
425+
const result = await this.restParty.comms.call('short-code/create', request, {
426+
expectClearTextReply: false,
427+
sendClearTextRequest: false,
428+
useSessions: true
429+
})
430+
431+
console.log('setInviteState result', result)
432+
433+
if(!result.done){
434+
return null
435+
}
436+
437+
return result.invite
438+
}
439+
440+
async lookupPublicKeyByShortCode( code ){
441+
//
442+
}
408443
}
409444

410445
module.exports = MatchMakerClient

src/venue/public/p2p-test.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ <h2>Offers recieved</h2>
260260

261261
await matchMaker.start()
262262

263-
let myHash = matchMaker.restParty.identity.key.hash
263+
let myHash = matchMaker.identity.key.hash
264264

265265
userHashInput.value = myHash
266266

0 commit comments

Comments
 (0)