Skip to content

Commit 6381018

Browse files
committed
add jsdoc and implementation for memory crypto store
1 parent 1c191b2 commit 6381018

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/crypto/store/indexeddb-crypto-store.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,14 +582,25 @@ export class IndexedDBCryptoStore {
582582
return this._backend.markSessionsNeedingBackup(sessions, txn);
583583
}
584584

585-
/* FIXME: jsdoc
585+
/**
586+
* Add a shared-history group session for a room.
587+
* @param {string} roomId The room that the key belongs to
588+
* @param {string} senderKey The sender's curve 25519 key
589+
* @param {string} sessionId The ID of the session
590+
* @param {*} txn An active transaction. See doTxn(). (optional)
586591
*/
587592
addSharedHistoryInboundGroupSession(roomId, senderKey, sessionId, txn) {
588-
return this._backend.addSharedHistoryInboundGroupSession(
593+
this._backend.addSharedHistoryInboundGroupSession(
589594
roomId, senderKey, sessionId, txn,
590595
);
591596
}
592597

598+
/**
599+
* Get the shared-history group session for a room.
600+
* @param {string} roomId The room that the key belongs to
601+
* @param {*} txn An active transaction. See doTxn(). (optional)
602+
* @returns {Promise} Resolves to an array of [senderKey, sessionId]
603+
*/
593604
getSharedHistoryInboundGroupSessions(roomId, txn) {
594605
return this._backend.getSharedHistoryInboundGroupSessions(roomId, txn);
595606
}

src/crypto/store/memory-crypto-store.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ export class MemoryCryptoStore {
5151
this._rooms = {};
5252
// Set of {senderCurve25519Key+'/'+sessionId}
5353
this._sessionsNeedingBackup = {};
54+
// roomId -> array of [senderKey, sessionId]
55+
this._sharedHistoryInboundGroupSessions = {};
5456
}
5557

5658
/**
@@ -467,6 +469,16 @@ export class MemoryCryptoStore {
467469
return Promise.resolve();
468470
}
469471

472+
addSharedHistoryInboundGroupSession(roomId, senderKey, sessionId) {
473+
const sessions = this._sharedHistoryInboundGroupSessions[roomId] || [];
474+
sessions.push([senderKey, sessionId]);
475+
this._sharedHistoryInboundGroupSessions[roomId] = sessions;
476+
}
477+
478+
getSharedHistoryInboundGroupSessions(roomId) {
479+
return Promise.resolve(this._sharedHistoryInboundGroupSessions[roomId] || []);
480+
}
481+
470482
// Session key backups
471483

472484
doTxn(mode, stores, func) {

0 commit comments

Comments
 (0)