Merge branch 'krille/remove-auth-object' into 'main'
chore: Move auth object passing to external msc implementations See merge request famedly/company/frontend/famedlysdk!1030
This commit is contained in:
commit
d09ed915bc
|
|
@ -1,4 +1,8 @@
|
|||
## [0.9.0] - 4th Mai 2022
|
||||
## [0.9.1] - 9th May 2022
|
||||
- feat: Store timestamp in the presence events
|
||||
- chore: Move auth object passing to external msc implementations
|
||||
|
||||
## [0.9.0] - 4th May 2022
|
||||
|
||||
- refactor: Get rid of dynamic input in checkHomeserver (Christian Pauly)
|
||||
- feat: Make image size editable (Henri Carnot)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
library msc_2835_uia_login;
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart' hide Client;
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
extension UiaLogin on Client {
|
||||
/// Implementation of MSC2835:
|
||||
/// https://github.com/Sorunome/matrix-doc/blob/soru/uia-on-login/proposals/2835-uia-on-login.md
|
||||
Future<LoginResponse> uiaLogin(
|
||||
LoginType type, {
|
||||
String? address,
|
||||
String? deviceId,
|
||||
AuthenticationIdentifier? identifier,
|
||||
String? initialDeviceDisplayName,
|
||||
String? medium,
|
||||
String? password,
|
||||
String? token,
|
||||
String? user,
|
||||
AuthenticationData? auth,
|
||||
}) async {
|
||||
final requestUri = Uri(path: '_matrix/client/v3/login');
|
||||
final request = Request('POST', baseUri!.resolveUri(requestUri));
|
||||
request.headers['content-type'] = 'application/json';
|
||||
request.bodyBytes = utf8.encode(jsonEncode({
|
||||
if (address != null) 'address': address,
|
||||
if (deviceId != null) 'device_id': deviceId,
|
||||
if (identifier != null) 'identifier': identifier.toJson(),
|
||||
if (initialDeviceDisplayName != null)
|
||||
'initial_device_display_name': initialDeviceDisplayName,
|
||||
if (medium != null) 'medium': medium,
|
||||
if (password != null) 'password': password,
|
||||
if (token != null) 'token': token,
|
||||
'type': {
|
||||
LoginType.mLoginPassword: 'm.login.password',
|
||||
LoginType.mLoginToken: 'm.login.token'
|
||||
}[type]!,
|
||||
if (user != null) 'user': user,
|
||||
if (auth != null) 'auth': auth.toJson(),
|
||||
}));
|
||||
final response = await httpClient.send(request);
|
||||
final responseBody = await response.stream.toBytes();
|
||||
if (response.statusCode != 200) unexpectedResponse(response, responseBody);
|
||||
final responseString = utf8.decode(responseBody);
|
||||
final json = jsonDecode(responseString);
|
||||
return LoginResponse.fromJson(json);
|
||||
}
|
||||
}
|
||||
|
|
@ -451,7 +451,6 @@ class Client extends MatrixApi {
|
|||
String? token,
|
||||
String? deviceId,
|
||||
String? initialDeviceDisplayName,
|
||||
AuthenticationData? auth,
|
||||
@Deprecated('Deprecated in favour of identifier.') String? user,
|
||||
@Deprecated('Deprecated in favour of identifier.') String? medium,
|
||||
@Deprecated('Deprecated in favour of identifier.') String? address,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
name: matrix
|
||||
description: Matrix Dart SDK
|
||||
version: 0.9.0
|
||||
version: 0.9.1
|
||||
homepage: https://famedly.com
|
||||
repository: https://gitlab.com/famedly/company/frontend/famedlysdk.git
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue