src/crypto/index.js
async function _uploadOneTimeKeys(crypto) {
    const oneTimeKeys = await crypto._olmDevice.getOneTimeKeys();
    const oneTimeJson = {};

    const promises = [];

    for (const keyId in oneTimeKeys.curve25519) {
        if (oneTimeKeys.curve25519.hasOwnProperty(keyId)) {
            const k = {
                key: oneTimeKeys.curve25519[keyId],
            };
            oneTimeJson["signed_curve25519:" + keyId] = k;
            promises.push(crypto._signObject(k));
        }
    }

    await Promise.all(promises);

    const res = await crypto._baseApis.uploadKeysRequest({
        one_time_keys: oneTimeJson,
    }, {
        // for now, we set the device id explicitly, as we may not be using the
        // same one as used in login.
        device_id: crypto._deviceId,
    });

    await crypto._olmDevice.markKeysAsPublished();
    return res;
}
async function _uploadOneTimeKeys(crypto) {
    const oneTimeKeys = await crypto._olmDevice.getOneTimeKeys();
    const oneTimeJson = {};

    const promises = [];

    for (const keyId in oneTimeKeys.curve25519) {
        if (oneTimeKeys.curve25519.hasOwnProperty(keyId)) {
            const k = {
                key: oneTimeKeys.curve25519[keyId],
            };
            oneTimeJson["signed_curve25519:" + keyId] = k;
            promises.push(crypto._signObject(k));
        }
    }

    await Promise.all(promises);

    const res = await crypto._baseApis.uploadKeysRequest({
        one_time_keys: oneTimeJson,
    }, {
        // for now, we set the device id explicitly, as we may not be using the
        // same one as used in login.
        device_id: crypto._deviceId,
    });

    await crypto._olmDevice.markKeysAsPublished();
    return res;
}
async function _uploadOneTimeKeys ( crypto ) { const oneTimeKeys = await crypto . _olmDevice . getOneTimeKeys ( ) ; const oneTimeJson = { } ; const promises = [ ] ; for ( const keyId in oneTimeKeys . curve25519 ) { if ( oneTimeKeys . curve25519 . hasOwnProperty ( keyId ) ) { const k = { key : oneTimeKeys . curve25519 [ keyId ] , } ; oneTimeJson [ "signed_curve25519:" + keyId ] = k ; promises . push ( crypto . _signObject ( k ) ) ; } } await Promise . all ( promises ) ; const res = await crypto . _baseApis . uploadKeysRequest ( { one_time_keys : oneTimeJson , } , { // for now, we set the device id explicitly, as we may not be using the // same one as used in login. device_id : crypto . _deviceId , } ) ; await crypto . _olmDevice . markKeysAsPublished ( ) ; return res ; }
returns a promise which resolves to the response
returns a promise which resolves to the response