Skip to content

Commit e7da6f3

Browse files
committed
Add JSDoc to SessionState.js
1 parent b782a76 commit e7da6f3

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

src/SessionState.js

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,41 @@ var makeReadonly = (obj, key) => {
2424
});
2525
};
2626

27+
/**
28+
* A serialisable representation of a session.
29+
*/
2730
export default class SessionState {
31+
/**
32+
*
33+
* @param {object} parameters - initial parameters
34+
*/
2835
constructor(parameters) {
2936
Object.assign(this, {
3037
sessionVersion: 3,
3138
remoteIdentityKey: null,
3239
localIdentityKey: null,
40+
pendingPreKey: null,
41+
localRegistrationId: 0,
42+
theirBaseKey: null,
43+
// Ratchet parameters
3344
rootKey: null,
3445
sendingChain: null,
3546
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
4149
}, parameters);
4250
makeReadonly(this, "sessionVersion");
4351
makeReadonly(this, "remoteIdentityKey");
4452
makeReadonly(this, "localIdentityKey");
4553
Object.seal(this);
4654
}
4755

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+
*/
5162
findReceivingChain(theirEphemeralPublicKey) {
5263
for (var i = 0; i < this.receivingChains.length; i++) {
5364
var receivingChain = this.receivingChains[i];
@@ -58,7 +69,12 @@ export default class SessionState {
5869
return null;
5970
}
6071

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+
*/
6278
addReceivingChain(theirEphemeralPublicKey, chain) {
6379
this.receivingChains.push({
6480
theirEphemeralKey: theirEphemeralPublicKey,

0 commit comments

Comments
 (0)