Line data Source code
1 : /* MIT License 2 : * 3 : * Copyright (C) 2019, 2020, 2021 Famedly GmbH 4 : * 5 : * Permission is hereby granted, free of charge, to any person obtaining a copy 6 : * of this software and associated documentation files (the "Software"), to deal 7 : * in the Software without restriction, including without limitation the rights 8 : * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 : * copies of the Software, and to permit persons to whom the Software is 10 : * furnished to do so, subject to the following conditions: 11 : * 12 : * The above copyright notice and this permission notice shall be included in all 13 : * copies or substantial portions of the Software. 14 : * 15 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 : * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 : * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 : * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 : * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 : * SOFTWARE. 22 : */ 23 : 24 : import 'package:matrix/matrix_api_lite/model/auth/authentication_data.dart'; 25 : 26 : /// For email based identity: 27 : /// https://matrix.org/docs/spec/client_server/r0.6.1#email-based-identity-homeserver 28 : /// Or phone number based identity: 29 : /// https://matrix.org/docs/spec/client_server/r0.6.1#phone-number-msisdn-based-identity-homeserver 30 : class AuthenticationThreePidCreds extends AuthenticationData { 31 : late ThreepidCreds threepidCreds; 32 : 33 0 : AuthenticationThreePidCreds({ 34 : super.session, 35 : required String super.type, 36 : required this.threepidCreds, 37 : }); 38 : 39 0 : AuthenticationThreePidCreds.fromJson(Map<String, Object?> json) 40 0 : : super.fromJson(json) { 41 0 : final creds = json['threepid_creds']; 42 0 : if (creds is Map<String, Object?>) { 43 0 : threepidCreds = ThreepidCreds.fromJson(creds); 44 : } 45 : } 46 : 47 0 : @override 48 : Map<String, Object?> toJson() { 49 0 : final data = super.toJson(); 50 0 : data['threepid_creds'] = threepidCreds.toJson(); 51 : return data; 52 : } 53 : } 54 : 55 : class ThreepidCreds { 56 : String sid; 57 : String clientSecret; 58 : String? idServer; 59 : String? idAccessToken; 60 : 61 0 : ThreepidCreds({ 62 : required this.sid, 63 : required this.clientSecret, 64 : this.idServer, 65 : this.idAccessToken, 66 : }); 67 : 68 0 : ThreepidCreds.fromJson(Map<String, Object?> json) 69 0 : : sid = json['sid'] as String, 70 0 : clientSecret = json['client_secret'] as String, 71 0 : idServer = json['id_server'] as String?, 72 0 : idAccessToken = json['id_access_token'] as String?; 73 : 74 0 : Map<String, Object?> toJson() { 75 0 : final data = <String, Object?>{}; 76 0 : data['sid'] = sid; 77 0 : data['client_secret'] = clientSecret; 78 0 : if (idServer != null) data['id_server'] = idServer; 79 0 : if (idAccessToken != null) data['id_access_token'] = idAccessToken; 80 : return data; 81 : } 82 : }