@@ -24,30 +24,41 @@ var makeReadonly = (obj, key) => {
24
24
} ) ;
25
25
} ;
26
26
27
+ /**
28
+ * A serialisable representation of a session.
29
+ */
27
30
export default class SessionState {
31
+ /**
32
+ *
33
+ * @param {object } parameters - initial parameters
34
+ */
28
35
constructor ( parameters ) {
29
36
Object . assign ( this , {
30
37
sessionVersion : 3 ,
31
38
remoteIdentityKey : null ,
32
39
localIdentityKey : null ,
40
+ pendingPreKey : null ,
41
+ localRegistrationId : 0 ,
42
+ theirBaseKey : null ,
43
+ // Ratchet parameters
33
44
rootKey : null ,
34
45
sendingChain : null ,
35
46
senderRatchetKeyPair : null ,
36
- previousCounter : 0 ,
37
- receivingChains : [ ] ,
38
- pendingPreKey : null ,
39
- localRegistrationId : 0 ,
40
- theirBaseKey : null
47
+ receivingChains : [ ] , // Keep a small list of chain keys to allow for out of order message delivery.
48
+ previousCounter : 0
41
49
} , parameters ) ;
42
50
makeReadonly ( this , "sessionVersion" ) ;
43
51
makeReadonly ( this , "remoteIdentityKey" ) ;
44
52
makeReadonly ( this , "localIdentityKey" ) ;
45
53
Object . seal ( this ) ;
46
54
}
47
55
48
- // Search the entire list so that we can deal with out of order messages.
49
- // i.e. messages that were sent with older chain keys because the sender
50
- // has not received our latest message and so hasn't clicked their ratchet.
56
+ /**
57
+ * Find a chain for decryption by an ephemeral key.
58
+ *
59
+ * @param {ArrayBuffer } theirEphemeralPublicKey
60
+ * @returns {Chain }
61
+ */
51
62
findReceivingChain ( theirEphemeralPublicKey ) {
52
63
for ( var i = 0 ; i < this . receivingChains . length ; i ++ ) {
53
64
var receivingChain = this . receivingChains [ i ] ;
@@ -58,7 +69,12 @@ export default class SessionState {
58
69
return null ;
59
70
}
60
71
61
- // Keep a small list of chain keys to allow for out of order message delivery.
72
+ /**
73
+ * Add a chain for decryption with an associated ephemeral key.
74
+ *
75
+ * @param {ArrayBuffer } theirEphemeralPublicKey
76
+ * @param {Chain } chain
77
+ */
62
78
addReceivingChain ( theirEphemeralPublicKey , chain ) {
63
79
this . receivingChains . push ( {
64
80
theirEphemeralKey : theirEphemeralPublicKey ,
0 commit comments