@@ -37,14 +37,14 @@ import {
3737import { WITHHELD_MESSAGES } from '../OlmDevice' ;
3838
3939// determine whether the key can be shared with invitees
40- function isRoomKeyShareable ( room ) {
40+ function isRoomSharedHistory ( room ) {
4141 const visibilityEvent = room . currentState &&
4242 room . currentState . getStateEvents ( "m.room.history_visibility" , "" ) ;
4343 // NOTE: if the room visibility is unset, it would normally default to
4444 // "world_readable".
4545 // (https://spec.matrix.org/unstable/client-server-api/#server-behaviour-5)
46- // But we will be paranoid here, and treat it as a situation where the key
47- // should not be shareable
46+ // But we will be paranoid here, and treat it as a situation where the room
47+ // is not shared-history
4848 const visibility = visibilityEvent && visibilityEvent . getContent ( ) &&
4949 visibilityEvent . getContent ( ) . history_visibility ;
5050 return [ "world_readable" , "shared" ] . includes ( visibility ) ;
@@ -55,8 +55,8 @@ function isRoomKeyShareable(room) {
5555 * @constructor
5656 *
5757 * @param {string } sessionId
58- * @param {boolean } shareable whether the session can be freely shared with other
59- * group members, according to the room history visibility settings
58+ * @param {boolean } sharedHistory whether the session can be freely shared with
59+ * other group members, according to the room history visibility settings
6060 *
6161 * @property {string } sessionId
6262 * @property {Number } useCount number of times this session has been used
@@ -66,13 +66,13 @@ function isRoomKeyShareable(room) {
6666 * devices with which we have shared the session key
6767 * userId -> {deviceId -> msgindex}
6868 */
69- function OutboundSessionInfo ( sessionId , shareable = false ) {
69+ function OutboundSessionInfo ( sessionId , sharedHistory = false ) {
7070 this . sessionId = sessionId ;
7171 this . useCount = 0 ;
7272 this . creationTime = new Date ( ) . getTime ( ) ;
7373 this . sharedWithDevices = { } ;
7474 this . blockedDevicesNotified = { } ;
75- this . shareable = shareable ;
75+ this . sharedHistory = sharedHistory ;
7676}
7777
7878
@@ -222,10 +222,10 @@ MegolmEncryption.prototype._ensureOutboundSession = async function(
222222 const prepareSession = async ( oldSession ) => {
223223 session = oldSession ;
224224
225- const shareable = isRoomKeyShareable ( room ) ;
225+ const sharedHistory = isRoomSharedHistory ( room ) ;
226226
227227 // history visibility changed
228- if ( session && shareable !== session . shareable ) {
228+ if ( session && sharedHistory !== session . sharedHistory ) {
229229 session = null ;
230230 }
231231
@@ -244,7 +244,7 @@ MegolmEncryption.prototype._ensureOutboundSession = async function(
244244
245245 if ( ! session ) {
246246 logger . log ( `Starting new megolm session for room ${ this . _roomId } ` ) ;
247- session = await this . _prepareNewSession ( shareable ) ;
247+ session = await this . _prepareNewSession ( sharedHistory ) ;
248248 logger . log ( `Started new megolm session ${ session . sessionId } ` +
249249 `for room ${ this . _roomId } ` ) ;
250250 this . _outboundSessions [ session . sessionId ] = session ;
@@ -280,7 +280,7 @@ MegolmEncryption.prototype._ensureOutboundSession = async function(
280280 "session_id" : session . sessionId ,
281281 "session_key" : key . key ,
282282 "chain_index" : key . chain_index ,
283- "io.element.unstable.shareable " : shareable ,
283+ "org.matrix.msc3061.shared_history " : sharedHistory ,
284284 } ,
285285 } ;
286286 const [ devicesWithoutSession , olmSessions ] = await olmlib . getExistingOlmSessions (
@@ -400,18 +400,18 @@ MegolmEncryption.prototype._ensureOutboundSession = async function(
400400/**
401401 * @private
402402 *
403- * @param {boolean } shareable
403+ * @param {boolean } sharedHistory
404404 *
405405 * @return {module:crypto/algorithms/megolm.OutboundSessionInfo } session
406406 */
407- MegolmEncryption . prototype . _prepareNewSession = async function ( shareable ) {
407+ MegolmEncryption . prototype . _prepareNewSession = async function ( sharedHistory ) {
408408 const sessionId = this . _olmDevice . createOutboundGroupSession ( ) ;
409409 const key = this . _olmDevice . getOutboundGroupSessionKey ( sessionId ) ;
410410
411411 await this . _olmDevice . addInboundGroupSession (
412412 this . _roomId , this . _olmDevice . deviceCurve25519Key , [ ] , sessionId ,
413413 key . key , { ed25519 : this . _olmDevice . deviceEd25519Key } , false ,
414- { shareable : shareable } ,
414+ { sharedHistory : sharedHistory } ,
415415 ) ;
416416
417417 // don't wait for it to complete
@@ -420,7 +420,7 @@ MegolmEncryption.prototype._prepareNewSession = async function(shareable) {
420420 sessionId , key . key ,
421421 ) ;
422422
423- return new OutboundSessionInfo ( sessionId , shareable ) ;
423+ return new OutboundSessionInfo ( sessionId , sharedHistory ) ;
424424} ;
425425
426426/**
@@ -709,7 +709,7 @@ MegolmEncryption.prototype.reshareKeyWithDevice = async function(
709709 "sender_key" : senderKey ,
710710 "sender_claimed_ed25519_key" : key . sender_claimed_ed25519_key ,
711711 "forwarding_curve25519_key_chain" : key . forwarding_curve25519_key_chain ,
712- "io.element.unstable.shareable " : key . shareable || false ,
712+ "org.matrix.msc3061.shared_history " : key . shared_history || false ,
713713 } ,
714714 } ;
715715
@@ -1401,8 +1401,8 @@ MegolmDecryption.prototype.onRoomKeyEvent = function(event) {
14011401 }
14021402
14031403 const extraSessionData = { } ;
1404- if ( content [ "io.element.unstable.shareable " ] ) {
1405- extraSessionData . shareable = true ;
1404+ if ( content [ "org.matrix.msc3061.shared_history " ] ) {
1405+ extraSessionData . sharedHistory = true ;
14061406 }
14071407 return this . _olmDevice . addInboundGroupSession (
14081408 content . room_id , senderKey , forwardingKeyChain , sessionId ,
@@ -1615,7 +1615,7 @@ MegolmDecryption.prototype._buildKeyForwardingMessage = async function(
16151615 "session_key" : key . key ,
16161616 "chain_index" : key . chain_index ,
16171617 "forwarding_curve25519_key_chain" : key . forwarding_curve25519_key_chain ,
1618- "io.element.unstable.shareable " : key . shareable || false ,
1618+ "org.matrix.msc3061.shared_history " : key . shared_history || false ,
16191619 } ,
16201620 } ;
16211621} ;
@@ -1633,8 +1633,8 @@ MegolmDecryption.prototype.importRoomKey = function(session, opts = {}) {
16331633 if ( opts . untrusted ) {
16341634 extraSessionData . untrusted = true ;
16351635 }
1636- if ( session [ "io.element.unstable.shareable " ] ) {
1637- extraSessionData . shareable = true ;
1636+ if ( session [ "org.matrix.msc3061.shared_history " ] ) {
1637+ extraSessionData . sharedHistory = true ;
16381638 }
16391639 return this . _olmDevice . addInboundGroupSession (
16401640 session . room_id ,
@@ -1723,18 +1723,19 @@ MegolmDecryption.prototype.retryDecryptionFromSender = async function(senderKey)
17231723 return ! this . _pendingEvents [ senderKey ] ;
17241724} ;
17251725
1726- MegolmDecryption . prototype . sendShareableInboundSessions = async function ( devicesByUser ) {
1726+ MegolmDecryption . prototype . sendSharedHistoryInboundSessions = async function ( devicesByUser ) {
17271727 await olmlib . ensureOlmSessionsForDevices (
17281728 this . _olmDevice , this . _baseApis , devicesByUser ,
17291729 ) ;
17301730
1731- logger . log ( "sendShareableInboundSessions to users" , Object . keys ( devicesByUser ) ) ;
1731+ logger . log ( "sendSharedHistoryInboundSessions to users" , Object . keys ( devicesByUser ) ) ;
17321732
1733- const shareableSessions = await this . _olmDevice . getShareableInboundGroupSessions (
1734- this . _roomId ,
1735- ) ;
1736- logger . log ( "shareable sessions" , shareableSessions ) ;
1737- for ( const [ senderKey , sessionId ] of shareableSessions ) {
1733+ const sharedHistorySessions =
1734+ await this . _olmDevice . getSharedHistoryInboundGroupSessions (
1735+ this . _roomId ,
1736+ ) ;
1737+ logger . log ( "shared-history sessions" , sharedHistorySessions ) ;
1738+ for ( const [ senderKey , sessionId ] of sharedHistorySessions ) {
17381739 const payload = await this . _buildKeyForwardingMessage (
17391740 this . _roomId , senderKey , sessionId ,
17401741 ) ;
0 commit comments