src/crypto/algorithms/megolm.js
function MegolmEncryption(params) {
    base.EncryptionAlgorithm.call(this, params);

    // the most recent attempt to set up a session. This is used to serialise
    // the session setups, so that we have a race-free view of which session we
    // are using, and which devices we have shared the keys with. It resolves
    // with an OutboundSessionInfo (or undefined, for the first message in the
    // room).
    this._setupPromise = Promise.resolve();

    // Map of outbound sessions by sessions ID. Used if we need a particular
    // session (the session we're currently using to send is always obtained
    // using _setupPromise).
    this._outboundSessions = {};

    // default rotation periods
    this._sessionRotationPeriodMsgs = 100;
    this._sessionRotationPeriodMs = 7 * 24 * 3600 * 1000;

    if (params.config.rotation_period_ms !== undefined) {
        this._sessionRotationPeriodMs = params.config.rotation_period_ms;
    }

    if (params.config.rotation_period_msgs !== undefined) {
        this._sessionRotationPeriodMsgs = params.config.rotation_period_msgs;
    }
}
function MegolmEncryption(params) {
    base.EncryptionAlgorithm.call(this, params);

    // the most recent attempt to set up a session. This is used to serialise
    // the session setups, so that we have a race-free view of which session we
    // are using, and which devices we have shared the keys with. It resolves
    // with an OutboundSessionInfo (or undefined, for the first message in the
    // room).
    this._setupPromise = Promise.resolve();

    // Map of outbound sessions by sessions ID. Used if we need a particular
    // session (the session we're currently using to send is always obtained
    // using _setupPromise).
    this._outboundSessions = {};

    // default rotation periods
    this._sessionRotationPeriodMsgs = 100;
    this._sessionRotationPeriodMs = 7 * 24 * 3600 * 1000;

    if (params.config.rotation_period_ms !== undefined) {
        this._sessionRotationPeriodMs = params.config.rotation_period_ms;
    }

    if (params.config.rotation_period_msgs !== undefined) {
        this._sessionRotationPeriodMsgs = params.config.rotation_period_msgs;
    }
}
function MegolmEncryption ( params ) { base . EncryptionAlgorithm . call ( this , params ) ; // the most recent attempt to set up a session. This is used to serialise // the session setups, so that we have a race-free view of which session we // are using, and which devices we have shared the keys with. It resolves // with an OutboundSessionInfo (or undefined, for the first message in the // room). this . _setupPromise = Promise . resolve ( ) ; // Map of outbound sessions by sessions ID. Used if we need a particular // session (the session we're currently using to send is always obtained // using _setupPromise). this . _outboundSessions = { } ; // default rotation periods this . _sessionRotationPeriodMsgs = 100 ; this . _sessionRotationPeriodMs = 7 * 24 * 3600 * 1000 ; if ( params . config . rotation_period_ms !== undefined ) { this . _sessionRotationPeriodMs = params . config . rotation_period_ms ; } if ( params . config . rotation_period_msgs !== undefined ) { this . _sessionRotationPeriodMsgs = params . config . rotation_period_msgs ; } }
Megolm encryption implementation

@constructor
@extends {module:crypto/algorithms/base.EncryptionAlgorithm}

@param {object} params parameters, as per
{@link module:crypto/algorithms/base.EncryptionAlgorithm}
Megolm encryption implementation