/* * Famedly Matrix SDK * Copyright (C) 2020 Famedly GmbH * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ class MatrixCrossSigningKey { String userId; List usage; Map keys; Map> signatures; Map unsigned; String get publicKey => keys?.values?.first; MatrixCrossSigningKey( this.userId, this.usage, this.keys, this.signatures, { this.unsigned, }); // This object is used for signing so we need the raw json too Map _json; MatrixCrossSigningKey.fromJson(Map json) { _json = json; userId = json['user_id']; usage = List.from(json['usage']); keys = Map.from(json['keys']); signatures = Map>.from( (json['signatures'] as Map) .map((k, v) => MapEntry(k, Map.from(v)))); unsigned = json['unsigned'] != null ? Map.from(json['unsigned']) : null; } Map toJson() { final data = _json ?? {}; data['user_id'] = userId; data['usage'] = usage; data['keys'] = keys; if (signatures != null) { data['signatures'] = signatures; } if (unsigned != null) { data['unsigned'] = unsigned; } return data; } }