diff --git a/lib/models/api/user/srp.dart b/lib/models/api/user/srp.dart new file mode 100644 index 0000000000..0bea9dbfbe --- /dev/null +++ b/lib/models/api/user/srp.dart @@ -0,0 +1,132 @@ +class SetupSRPRequest { + final String srpUserID; + final String srpSalt; + final String srpVerifier; + final String srpA; + final bool isUpdate; + + SetupSRPRequest({ + required this.srpUserID, + required this.srpSalt, + required this.srpVerifier, + required this.srpA, + required this.isUpdate, + }); + + Map toMap() { + return { + 'srpUserID': srpUserID.toString(), + 'srpSalt': srpSalt, + 'srpVerifier': srpVerifier, + 'srpA': srpA, + 'isUpdate': isUpdate, + }; + } + + factory SetupSRPRequest.fromJson(Map json) { + return SetupSRPRequest( + srpUserID: json['srpUserID'], + srpSalt: json['srpSalt'], + srpVerifier: json['srpVerifier'], + srpA: json['srpA'], + isUpdate: json['isUpdate'], + ); + } +} + +class SetupSRPResponse { + final String setupID; + final String srpB; + + SetupSRPResponse({ + required this.setupID, + required this.srpB, + }); + + Map toMap() { + return { + 'setupID': setupID.toString(), + 'srpB': srpB, + }; + } + + factory SetupSRPResponse.fromJson(Map json) { + return SetupSRPResponse( + setupID: json['setupID'], + srpB: json['srpB'], + ); + } +} + +class CompleteSRPSetupRequest { + final String setupID; + final String srpM1; + + CompleteSRPSetupRequest({ + required this.setupID, + required this.srpM1, + }); + + Map toMap() { + return { + 'setupID': setupID.toString(), + 'srpM1': srpM1, + }; + } + + factory CompleteSRPSetupRequest.fromJson(Map json) { + return CompleteSRPSetupRequest( + setupID: json['setupID'], + srpM1: json['srpM1'], + ); + } +} +class SrpAttributes { + final String srpUserID; + final String srpSalt; + final int memLimit; + final int opsLimit; + final String kekSalt; + + SrpAttributes({ + required this.srpUserID, + required this.srpSalt, + required this.memLimit, + required this.opsLimit, + required this.kekSalt, + }); + + factory SrpAttributes.fromMap(Map map) { + return SrpAttributes( + srpUserID: map['attributes']['srpUserID'], + srpSalt: map['attributes']['srpSalt'], + memLimit: map['attributes']['memLimit'], + opsLimit: map['attributes']['opsLimit'], + kekSalt: map['attributes']['kekSalt'], + ); + } +} + +class CompleteSRPSetupResponse { + final String setupID; + final String srpM2; + + CompleteSRPSetupResponse({ + required this.setupID, + required this.srpM2, + }); + + Map toMap() { + return { + 'setupID': setupID, + 'srpM2': srpM2, + }; + } + + factory CompleteSRPSetupResponse.fromJson(Map json) { + return CompleteSRPSetupResponse( + setupID: json['setupID'], + srpM2: json['srpM2'], + ); + } +}