format
This commit is contained in:
parent
2a6a19e2b0
commit
3825f7292f
|
@ -337,7 +337,8 @@ class KeyManager {
|
|||
|
||||
if (backupPubKey == null ||
|
||||
!(info.authData is RoomKeysAuthDataV1Curve25519AesSha2) ||
|
||||
(info.authData as RoomKeysAuthDataV1Curve25519AesSha2).publicKey != backupPubKey) {
|
||||
(info.authData as RoomKeysAuthDataV1Curve25519AesSha2).publicKey !=
|
||||
backupPubKey) {
|
||||
return;
|
||||
}
|
||||
for (final roomEntry in keys.rooms.entries) {
|
||||
|
@ -378,7 +379,8 @@ class KeyManager {
|
|||
|
||||
Future<void> loadSingleKey(String roomId, String sessionId) async {
|
||||
final info = await client.api.getRoomKeysBackup();
|
||||
final ret = await client.api.getRoomKeysSingleKey(roomId, sessionId, info.version);
|
||||
final ret =
|
||||
await client.api.getRoomKeysSingleKey(roomId, sessionId, info.version);
|
||||
final keys = RoomKeys.fromJson({
|
||||
'rooms': {
|
||||
roomId: {
|
||||
|
|
|
@ -2041,7 +2041,8 @@ class MatrixApi {
|
|||
|
||||
/// Create room keys backup
|
||||
/// https://matrix.org/docs/spec/client_server/unstable#post-matrix-client-r0-room-keys-version
|
||||
Future<String> createRoomKeysBackup(RoomKeysAlgorithmType algorithm, RoomKeysAuthData authData) async {
|
||||
Future<String> createRoomKeysBackup(
|
||||
RoomKeysAlgorithmType algorithm, RoomKeysAuthData authData) async {
|
||||
final ret = await request(
|
||||
RequestType.POST,
|
||||
'/client/unstable/room_keys/version',
|
||||
|
@ -2069,7 +2070,8 @@ class MatrixApi {
|
|||
|
||||
/// Updates a room key backup
|
||||
/// https://matrix.org/docs/spec/client_server/unstable#put-matrix-client-r0-room-keys-version-version
|
||||
Future<void> updateRoomKeysBackup(String version, RoomKeysAlgorithmType algorithm, RoomKeysAuthData authData) async {
|
||||
Future<void> updateRoomKeysBackup(String version,
|
||||
RoomKeysAlgorithmType algorithm, RoomKeysAuthData authData) async {
|
||||
await request(
|
||||
RequestType.PUT,
|
||||
'/client/unstable/room_keys/version/${Uri.encodeComponent(version)}',
|
||||
|
@ -2092,7 +2094,8 @@ class MatrixApi {
|
|||
|
||||
/// Stores a single room key
|
||||
/// https://matrix.org/docs/spec/client_server/unstable#put-matrix-client-r0-room-keys-keys-roomid-sessionid
|
||||
Future<RoomKeysUpdateResponse> storeRoomKeysSingleKey(String roomId, String sessionId, String version, RoomKeysSingleKey session) async {
|
||||
Future<RoomKeysUpdateResponse> storeRoomKeysSingleKey(String roomId,
|
||||
String sessionId, String version, RoomKeysSingleKey session) async {
|
||||
final ret = await request(
|
||||
RequestType.PUT,
|
||||
'/client/unstable/room_keys/keys/${Uri.encodeComponent(roomId)}/${Uri.encodeComponent(sessionId)}?version=${Uri.encodeComponent(version)}',
|
||||
|
@ -2103,7 +2106,8 @@ class MatrixApi {
|
|||
|
||||
/// Gets a single room key
|
||||
/// https://matrix.org/docs/spec/client_server/unstable#get-matrix-client-r0-room-keys-keys-roomid-sessionid
|
||||
Future<RoomKeysSingleKey> getRoomKeysSingleKey(String roomId, String sessionId, String version) async {
|
||||
Future<RoomKeysSingleKey> getRoomKeysSingleKey(
|
||||
String roomId, String sessionId, String version) async {
|
||||
final ret = await request(
|
||||
RequestType.GET,
|
||||
'/client/unstable/room_keys/keys/${Uri.encodeComponent(roomId)}/${Uri.encodeComponent(sessionId)}?version=${Uri.encodeComponent(version)}',
|
||||
|
@ -2113,7 +2117,8 @@ class MatrixApi {
|
|||
|
||||
/// Deletes a single room key
|
||||
/// https://matrix.org/docs/spec/client_server/unstable#delete-matrix-client-r0-room-keys-keys-roomid-sessionid
|
||||
Future<RoomKeysUpdateResponse> deleteRoomKeysSingleKey(String roomId, String sessionId, String version) async {
|
||||
Future<RoomKeysUpdateResponse> deleteRoomKeysSingleKey(
|
||||
String roomId, String sessionId, String version) async {
|
||||
final ret = await request(
|
||||
RequestType.DELETE,
|
||||
'/client/unstable/room_keys/keys/${Uri.encodeComponent(roomId)}/${Uri.encodeComponent(sessionId)}?version=${Uri.encodeComponent(version)}',
|
||||
|
@ -2123,7 +2128,8 @@ class MatrixApi {
|
|||
|
||||
/// Stores room keys for a room
|
||||
/// https://matrix.org/docs/spec/client_server/unstable#put-matrix-client-r0-room-keys-keys-roomid
|
||||
Future<RoomKeysUpdateResponse> storeRoomKeysRoom(String roomId, String version, RoomKeysRoom keys) async {
|
||||
Future<RoomKeysUpdateResponse> storeRoomKeysRoom(
|
||||
String roomId, String version, RoomKeysRoom keys) async {
|
||||
final ret = await request(
|
||||
RequestType.PUT,
|
||||
'/client/unstable/room_keys/keys/${Uri.encodeComponent(roomId)}?version=${Uri.encodeComponent(version)}',
|
||||
|
@ -2144,7 +2150,8 @@ class MatrixApi {
|
|||
|
||||
/// Deletes room ekys for a room
|
||||
/// https://matrix.org/docs/spec/client_server/unstable#delete-matrix-client-r0-room-keys-keys-roomid
|
||||
Future<RoomKeysUpdateResponse> deleteRoomKeysRoom(String roomId, String version) async {
|
||||
Future<RoomKeysUpdateResponse> deleteRoomKeysRoom(
|
||||
String roomId, String version) async {
|
||||
final ret = await request(
|
||||
RequestType.DELETE,
|
||||
'/client/unstable/room_keys/keys/${Uri.encodeComponent(roomId)}?version=${Uri.encodeComponent(version)}',
|
||||
|
@ -2154,7 +2161,8 @@ class MatrixApi {
|
|||
|
||||
/// Store multiple room keys
|
||||
/// https://matrix.org/docs/spec/client_server/unstable#put-matrix-client-r0-room-keys-keys
|
||||
Future<RoomKeysUpdateResponse> storeRoomKeys(String version, RoomKeys keys) async {
|
||||
Future<RoomKeysUpdateResponse> storeRoomKeys(
|
||||
String version, RoomKeys keys) async {
|
||||
final ret = await request(
|
||||
RequestType.PUT,
|
||||
'/client/unstable/room_keys/keys?version=${Uri.encodeComponent(version)}',
|
||||
|
|
|
@ -55,7 +55,8 @@ class RoomKeysAuthDataV1Curve25519AesSha2 extends RoomKeysAuthData {
|
|||
String publicKey;
|
||||
Map<String, Map<String, String>> signatures;
|
||||
|
||||
RoomKeysAuthDataV1Curve25519AesSha2.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
|
||||
RoomKeysAuthDataV1Curve25519AesSha2.fromJson(Map<String, dynamic> json)
|
||||
: super.fromJson(json) {
|
||||
publicKey = json['public_key'];
|
||||
signatures = json['signatures'] is Map
|
||||
? Map<String, Map<String, String>>.from((json['signatures'] as Map)
|
||||
|
@ -82,16 +83,19 @@ class RoomKeysVersionResponse {
|
|||
String version;
|
||||
|
||||
RoomKeysVersionResponse.fromJson(Map<String, dynamic> json) {
|
||||
algorithm = RoomKeysAlgorithmTypeExtension.fromAlgorithmString(json['algorithm']);
|
||||
algorithm =
|
||||
RoomKeysAlgorithmTypeExtension.fromAlgorithmString(json['algorithm']);
|
||||
switch (algorithm) {
|
||||
case RoomKeysAlgorithmType.v1Curve25519AesSha2:
|
||||
authData = RoomKeysAuthDataV1Curve25519AesSha2.fromJson(json['auth_data']);
|
||||
authData =
|
||||
RoomKeysAuthDataV1Curve25519AesSha2.fromJson(json['auth_data']);
|
||||
break;
|
||||
default:
|
||||
authData = null;
|
||||
}
|
||||
count = json['count'];
|
||||
etag = json['etag'].toString(); // synapse replies an int but docs say string?
|
||||
etag =
|
||||
json['etag'].toString(); // synapse replies an int but docs say string?
|
||||
version = json['version'];
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,8 @@ class RoomKeysRoom {
|
|||
Map<String, RoomKeysSingleKey> sessions;
|
||||
|
||||
RoomKeysRoom.fromJson(Map<String, dynamic> json) {
|
||||
sessions = (json['sessions'] as Map).map((k, v) => MapEntry(k, RoomKeysSingleKey.fromJson(v)));
|
||||
sessions = (json['sessions'] as Map)
|
||||
.map((k, v) => MapEntry(k, RoomKeysSingleKey.fromJson(v)));
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
|
@ -57,7 +58,8 @@ class RoomKeys {
|
|||
Map<String, RoomKeysRoom> rooms;
|
||||
|
||||
RoomKeys.fromJson(Map<String, dynamic> json) {
|
||||
rooms = (json['rooms'] as Map).map((k, v) => MapEntry(k, RoomKeysRoom.fromJson(v)));
|
||||
rooms = (json['rooms'] as Map)
|
||||
.map((k, v) => MapEntry(k, RoomKeysRoom.fromJson(v)));
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
|
|
Loading…
Reference in a new issue