Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2024 Appwrite (https://appwrite.io) and individual contributors.
Copyright (c) 2025 Appwrite (https://appwrite.io) and individual contributors.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Add this to your package's `pubspec.yaml` file:

```yml
dependencies:
appwrite: ^13.1.1
appwrite: ^13.1.2
```

You can install packages from the command line:
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/update-mfa-challenge.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Client client = Client()

Account account = Account(client);

result = await account.updateMfaChallenge(
Session result = await account.updateMfaChallenge(
challengeId: '<CHALLENGE_ID>',
otp: '<OTP>',
);
21 changes: 16 additions & 5 deletions lib/services/account.dart
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ class Account extends Service {
/// the flow, use
/// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge)
/// method.
Future updateMfaChallenge(
Future<models.Session> updateMfaChallenge(
{required String challengeId, required String otp}) async {
const String apiPath = '/account/mfa/challenge';

Expand All @@ -299,7 +299,7 @@ class Account extends Service {
final res = await client.call(HttpMethod.put,
path: apiPath, params: apiParams, headers: apiHeaders);

return res.data;
return models.Session.fromMap(res.data);
}

/// List factors
Expand Down Expand Up @@ -862,6 +862,11 @@ class Account extends Service {

/// Create push target
///
/// Use this endpoint to register a device for push notifications. Provide a
/// target ID (custom or generated using ID.unique()), a device identifier
/// (usually a device token), and optionally specify which provider should send
/// notifications to this target. The target is automatically linked to the
/// current session and includes device information like brand and model.
Future<models.Target> createPushTarget(
{required String targetId,
required String identifier,
Expand All @@ -886,6 +891,11 @@ class Account extends Service {

/// Update push target
///
/// Update the currently logged in user's push notification target. You can
/// modify the target's identifier (device token) and provider ID (token,
/// email, phone etc.). The target must exist and belong to the current user.
/// If you change the provider ID, notifications will be sent through the new
/// messaging provider instead.
Future<models.Target> updatePushTarget(
{required String targetId, required String identifier}) async {
final String apiPath =
Expand All @@ -907,6 +917,9 @@ class Account extends Service {

/// Delete push target
///
/// Delete a push notification target for the currently logged in user. After
/// deletion, the device will no longer receive push notifications. The target
/// must exist and belong to the current user.
Future deletePushTarget({required String targetId}) async {
final String apiPath =
'/account/targets/{targetId}/push'.replaceAll('{targetId}', targetId);
Expand Down Expand Up @@ -965,9 +978,7 @@ class Account extends Service {
/// [POST
/// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
/// endpoint to complete the login process. The link sent to the user's email
/// address is valid for 1 hour. If you are on a mobile device you can leave
/// the URL parameter empty, so that the login completion will be handled by
/// your Appwrite instance by default.
/// address is valid for 1 hour.
///
/// A user is limited to 10 active sessions at a time by default. [Learn more
/// about session
Expand Down
4 changes: 2 additions & 2 deletions lib/src/client_browser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ClientBrowser extends ClientBase with ClientMixin {
'x-sdk-name': 'Flutter',
'x-sdk-platform': 'client',
'x-sdk-language': 'flutter',
'x-sdk-version': '13.1.1',
'x-sdk-version': '13.1.2',
'X-Appwrite-Response-Format': '1.6.0',
};

Expand Down Expand Up @@ -161,7 +161,7 @@ class ClientBrowser extends ClientBase with ClientMixin {
}

var offset = 0;
if (idParamName.isNotEmpty && params[idParamName] != 'unique()') {
if (idParamName.isNotEmpty) {
//make a request to check if a file already exists
try {
res = await call(
Expand Down
4 changes: 2 additions & 2 deletions lib/src/client_io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ClientIO extends ClientBase with ClientMixin {
'x-sdk-name': 'Flutter',
'x-sdk-platform': 'client',
'x-sdk-language': 'flutter',
'x-sdk-version': '13.1.1',
'x-sdk-version': '13.1.2',
'X-Appwrite-Response-Format': '1.6.0',
};

Expand Down Expand Up @@ -279,7 +279,7 @@ class ClientIO extends ClientBase with ClientMixin {
}

var offset = 0;
if (idParamName.isNotEmpty && params[idParamName] != 'unique()') {
if (idParamName.isNotEmpty) {
//make a request to check if a file already exists
try {
res = await call(
Expand Down
1 change: 1 addition & 0 deletions lib/src/enums/image_format.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ enum ImageFormat {
gif(value: 'gif'),
png(value: 'png'),
webp(value: 'webp'),
heic(value: 'heic'),
avif(value: 'avif');

const ImageFormat({required this.value});
Expand Down
2 changes: 1 addition & 1 deletion lib/src/realtime_response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class RealtimeResponse {
factory RealtimeResponse.fromMap(Map<String, dynamic> map) {
return RealtimeResponse(
type: map['type'],
data: Map<String, dynamic>.from(map['data']),
data: Map<String, dynamic>.from(map['data'] ?? {}),
);
}

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: appwrite
version: 13.1.1
version: 13.1.2
description: Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API
homepage: https://appwrite.io
repository: https://github.com/appwrite/sdk-for-flutter
Expand Down
34 changes: 33 additions & 1 deletion test/services/account_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,37 @@ void main() {
});

test('test method updateMfaChallenge()', () async {
final data = '';
final Map<String, dynamic> data = {
'\$id': '5e5ea5c16897e',
'\$createdAt': '2020-10-15T06:38:00.000+00:00',
'\$updatedAt': '2020-10-15T06:38:00.000+00:00',
'userId': '5e5bb8c16897e',
'expire': '2020-10-15T06:38:00.000+00:00',
'provider': 'email',
'providerUid': '[email protected]',
'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3',
'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00',
'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3',
'ip': '127.0.0.1',
'osCode': 'Mac',
'osName': 'Mac',
'osVersion': 'Mac',
'clientType': 'browser',
'clientCode': 'CM',
'clientName': 'Chrome Mobile iOS',
'clientVersion': '84.0',
'clientEngine': 'WebKit',
'clientEngineVersion': '605.1.15',
'deviceName': 'smartphone',
'deviceBrand': 'Google',
'deviceModel': 'Nexus 5',
'countryCode': 'US',
'countryName': 'United States',
'current': true,
'factors': [],
'secret': '5e5bb8c16897e',
'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',};


when(client.call(
HttpMethod.put,
Expand All @@ -343,6 +373,8 @@ void main() {
challengeId: '<CHALLENGE_ID>',
otp: '<OTP>',
);
expect(response, isA<models.Session>());

});

test('test method listMfaFactors()', () async {
Expand Down