You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-28 05:03:59 +03:00
Refactor device key upload
Use another-json instead of awful manual json building. Sign the device keys at the point of upload, instead of having to keep the signed string in memory. Only upload device keys once (they are correctly merged with the one-time keys by synapse).
This commit is contained in:
@@ -696,6 +696,40 @@ MatrixBaseApis.prototype.search = function(opts, callback) {
|
||||
);
|
||||
};
|
||||
|
||||
// Crypto
|
||||
// ======
|
||||
|
||||
/**
|
||||
* Upload keys
|
||||
*
|
||||
* @param {Object} content body of upload request
|
||||
*
|
||||
* @param {Object=} opts
|
||||
|
||||
* @param {string=} opts.device_id explicit device_id to use for upload
|
||||
* (default is to use the same as that used during auth).
|
||||
*
|
||||
* @param {module:client.callback=} callback
|
||||
*
|
||||
* @return {module:client.Promise} Resolves: result object. Rejects: with
|
||||
* an error response ({@link module:http-api.MatrixError}).
|
||||
*/
|
||||
MatrixBaseApis.prototype.uploadKeysRequest = function(content, opts, callback) {
|
||||
opts = opts || {};
|
||||
var deviceId = opts.device_id;
|
||||
var path;
|
||||
if (deviceId) {
|
||||
path = utils.encodeUri("/keys/upload/$deviceId", {
|
||||
$deviceId: deviceId,
|
||||
});
|
||||
} else {
|
||||
path = "/keys/upload";
|
||||
}
|
||||
return this._http.authedRequestWithPrefix(
|
||||
callback, "POST", path, undefined, content, httpApi.PREFIX_UNSTABLE
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// Identity Server Operations
|
||||
// ==========================
|
||||
|
||||
Reference in New Issue
Block a user