diff --git a/app/sdks/client-flutter/CHANGELOG.md b/app/sdks/client-flutter/CHANGELOG.md index 638d0882d..a584ad8b9 100644 --- a/app/sdks/client-flutter/CHANGELOG.md +++ b/app/sdks/client-flutter/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.0-dev.2 + +- Fix for an error when using a self-signed certificate for Web + ## 0.3.0-dev.1 - Updated package dependencies (@lohanidamodar) diff --git a/app/sdks/client-flutter/README.md b/app/sdks/client-flutter/README.md index 95cdeae64..d272426ee 100644 --- a/app/sdks/client-flutter/README.md +++ b/app/sdks/client-flutter/README.md @@ -20,7 +20,7 @@ Add this to your package's `pubspec.yaml` file: ```yml dependencies: - appwrite: ^0.3.0-dev.1 + appwrite: ^0.3.0-dev.2 ``` You can install packages from the command line: diff --git a/app/sdks/client-flutter/lib/client.dart b/app/sdks/client-flutter/lib/client.dart index 1cf3ac8f0..ee55d8ba1 100644 --- a/app/sdks/client-flutter/lib/client.dart +++ b/app/sdks/client-flutter/lib/client.dart @@ -35,7 +35,7 @@ class Client { this.headers = { 'content-type': 'application/json', - 'x-sdk-version': 'appwrite:flutter:0.3.0-dev.1', + 'x-sdk-version': 'appwrite:flutter:0.3.0-dev.2', }; this.config = {}; @@ -101,7 +101,7 @@ class Client { } Future call(HttpMethod method, {String path = '', Map headers = const {}, Map params = const {}}) async { - if(selfSigned) { + if(selfSigned && !kIsWeb) { // Allow self signed requests (http.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (HttpClient client) { client.badCertificateCallback = (X509Certificate cert, String host, int port) => true; diff --git a/app/sdks/client-flutter/lib/services/account.dart b/app/sdks/client-flutter/lib/services/account.dart index 617ea83b9..cca5cb5a2 100644 --- a/app/sdks/client-flutter/lib/services/account.dart +++ b/app/sdks/client-flutter/lib/services/account.dart @@ -1,5 +1,6 @@ import 'dart:io'; +import 'package:universal_html/html.dart' as html; import 'package:dio/dio.dart'; import 'package:meta/meta.dart'; @@ -337,19 +338,26 @@ class Account extends Service { query: query.join('&') ); - return FlutterWebAuth.authenticate( - url: url.toString(), - callbackUrlScheme: "appwrite-callback-" + client.config['project'] - ).then((value) async { - Uri url = Uri.parse(value); - Cookie cookie = new Cookie(url.queryParameters['key'], url.queryParameters['secret']); - cookie.domain = Uri.parse(client.endPoint).host; - cookie.httpOnly = true; - cookie.path = '/'; - List cookies = [cookie]; - await client.init(); - client.cookieJar.saveFromResponse(Uri.parse(client.endPoint), cookies); - }); + if(kIsWeb) { + html.window.location.href = url.toString(); + return null; + }else{ + + return FlutterWebAuth.authenticate( + url: url.toString(), + callbackUrlScheme: "appwrite-callback-" + client.config['project'] + ).then((value) async { + Uri url = Uri.parse(value); + Cookie cookie = new Cookie(url.queryParameters['key'], url.queryParameters['secret']); + cookie.domain = Uri.parse(client.endPoint).host; + cookie.httpOnly = true; + cookie.path = '/'; + List cookies = [cookie]; + await client.init(); + client.cookieJar.saveFromResponse(Uri.parse(client.endPoint), cookies); + }); + } + } /// Delete Account Session @@ -376,16 +384,17 @@ class Account extends Service { /// Use this endpoint to send a verification message to your user email address /// to confirm they are the valid owners of that address. Both the **userId** /// and **secret** arguments will be passed as query parameters to the URL you - /// have provider to be attached to the verification email. The provided URL - /// should redirect the user back for your app and allow you to complete the + /// have provided to be attached to the verification email. The provided URL + /// should redirect the user back to your app and allow you to complete the /// verification process by verifying both the **userId** and **secret** /// parameters. Learn more about how to [complete the verification /// process](/docs/client/account#updateAccountVerification). /// /// Please note that in order to avoid a [Redirect - /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) + /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), /// the only valid redirect URLs are the ones from domains you have set when /// adding your platforms in the console interface. + /// /// Future createVerification({@required String url}) { final String path = '/account/verification'; diff --git a/app/sdks/client-flutter/lib/services/avatars.dart b/app/sdks/client-flutter/lib/services/avatars.dart index a57b3b564..b7fa6393e 100644 --- a/app/sdks/client-flutter/lib/services/avatars.dart +++ b/app/sdks/client-flutter/lib/services/avatars.dart @@ -190,6 +190,10 @@ class Avatars extends Service { 'project': client.config['project'], }; + params.keys.forEach((key) {if (params[key] is int || params[key] is double) { + params[key] = params[key].toString(); + }}); + Uri endpoint = Uri.parse(client.endPoint); Uri location = new Uri(scheme: endpoint.scheme, host: endpoint.host, @@ -206,7 +210,7 @@ class Avatars extends Service { /// Converts a given plain text to a QR code image. You can use the query /// parameters to change the size and style of the resulting image. /// - String getQR({@required String text, int size = 400, int margin = 1, int download = 0}) { + String getQR({@required String text, int size = 400, int margin = 1, bool download = false}) { final String path = '/avatars/qr'; final Map params = { diff --git a/app/sdks/client-flutter/lib/services/database.dart b/app/sdks/client-flutter/lib/services/database.dart index 88082feef..0fec1fb4d 100644 --- a/app/sdks/client-flutter/lib/services/database.dart +++ b/app/sdks/client-flutter/lib/services/database.dart @@ -17,7 +17,7 @@ class Database extends Service { /// of the project documents. [Learn more about different API /// modes](/docs/admin). /// - Future listDocuments({@required String collectionId, List filters = const [], int offset = 0, int limit = 50, String orderField = '\$id', OrderType orderType = OrderType.asc, String orderCast = 'string', String search = '', int first = 0, int last = 0}) { + Future listDocuments({@required String collectionId, List filters = const [], int offset = 0, int limit = 50, String orderField = '\$id', OrderType orderType = OrderType.asc, String orderCast = 'string', String search = ''}) { final String path = '/database/collections/{collectionId}/documents'.replaceAll(RegExp('{collectionId}'), collectionId); final Map params = { @@ -28,8 +28,6 @@ class Database extends Service { 'orderType': orderType.name(), 'orderCast': orderCast, 'search': search, - 'first': first, - 'last': last, }; final Map headers = { diff --git a/app/sdks/client-flutter/pubspec.yaml b/app/sdks/client-flutter/pubspec.yaml index 2d0c2fe41..cabc271c5 100644 --- a/app/sdks/client-flutter/pubspec.yaml +++ b/app/sdks/client-flutter/pubspec.yaml @@ -1,5 +1,5 @@ name: appwrite -version: 0.3.0-dev.1 +version: 0.3.0-dev.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 @@ -15,6 +15,7 @@ dependencies: cookie_jar: ^1.0.1 dio_cookie_manager: ^1.0.0 flutter_web_auth: ^0.2.4 + universal_html: ^1.2.3 flutter: sdk: flutter diff --git a/composer.lock b/composer.lock index 341732c07..bf7bb614b 100644 --- a/composer.lock +++ b/composer.lock @@ -1952,7 +1952,7 @@ "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator", - "reference": "506b82a20a004724d88c3c95a090de30a2479a93" + "reference": "73ed2ea946b71c69a1038d0fee066aa5bcb0d804" }, "require": { "ext-curl": "*", @@ -1982,7 +1982,7 @@ } ], "description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms", - "time": "2020-08-30T05:15:19+00:00" + "time": "2020-09-08T05:15:17+00:00" }, { "name": "doctrine/instantiator", @@ -2374,12 +2374,12 @@ "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "13d9a6bb0b5bbb89d085c7d557c4b55499128eb9" + "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/13d9a6bb0b5bbb89d085c7d557c4b55499128eb9", - "reference": "13d9a6bb0b5bbb89d085c7d557c4b55499128eb9", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/069a785b2141f5bcf49f3e353548dc1cce6df556", + "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556", "shasum": "" }, "require": { @@ -2418,7 +2418,7 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2020-08-22T07:19:02+00:00" + "time": "2020-09-03T19:13:55+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -2426,12 +2426,12 @@ "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "e878a14a65245fbe78f8080eba03b47c3b705651" + "reference": "e21c0bd532911ec05ebc258e4086ea61c86e0750" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e878a14a65245fbe78f8080eba03b47c3b705651", - "reference": "e878a14a65245fbe78f8080eba03b47c3b705651", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e21c0bd532911ec05ebc258e4086ea61c86e0750", + "reference": "e21c0bd532911ec05ebc258e4086ea61c86e0750", "shasum": "" }, "require": { @@ -2463,7 +2463,7 @@ } ], "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "time": "2020-06-27T10:12:23+00:00" + "time": "2020-09-02T21:29:45+00:00" }, { "name": "phpspec/prophecy",