Skip to content

Commit 5b254a1

Browse files
committed
Fix for self-signed cert error on Web
1 parent 9a0322a commit 5b254a1

File tree

12 files changed

+118
-16
lines changed

12 files changed

+118
-16
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.3.0-dev.2
2+
3+
- Fix for an error when using a self-signed certificate for Web
4+
15
## 0.3.0-dev.1
26

37
- Updated package dependencies (@lohanidamodar)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Add this to your package's `pubspec.yaml` file:
2020

2121
```yml
2222
dependencies:
23-
appwrite: ^0.3.0-dev.1
23+
appwrite: ^0.3.0-dev.2
2424
```
2525
2626
You can install packages from the command line:

docs/examples/account/create-o-auth2session.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ void main() { // Init SDK
1010
;
1111

1212
Future result = account.createOAuth2Session(
13-
provider: 'bitbucket',
13+
provider: 'amazon',
1414
);
1515

1616
result
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import 'package:appwrite/appwrite.dart';
2+
3+
void main() { // Init SDK
4+
Client client = Client();
5+
Avatars avatars = Avatars(client);
6+
7+
client
8+
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
9+
.setProject('5df5acd0d48c2') // Your project ID
10+
;
11+
12+
String result = avatars.getInitials(
13+
);
14+
15+
print(result); // Resource URL string
16+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import 'package:appwrite/appwrite.dart';
2+
3+
void main() { // Init SDK
4+
Client client = Client();
5+
Locale locale = Locale(client);
6+
7+
client
8+
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
9+
.setProject('5df5acd0d48c2') // Your project ID
10+
;
11+
12+
Future result = locale.getLanguages( );
13+
14+
result
15+
.then((response) {
16+
print(response);
17+
}).catchError((error) {
18+
print(error.response);
19+
});
20+
}

lib/client.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Client {
3535

3636
this.headers = {
3737
'content-type': 'application/json',
38-
'x-sdk-version': 'appwrite:flutter:0.3.0-dev.1',
38+
'x-sdk-version': 'appwrite:flutter:0.3.0-dev.2',
3939
};
4040

4141
this.config = {};

lib/services/account.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,12 +305,13 @@ class Account extends Service {
305305
/// first. Use the success and failure arguments to provide a redirect URL's
306306
/// back to your app when login is completed.
307307
///
308-
Future createOAuth2Session({@required String provider, String success = 'https://appwrite.io/auth/oauth2/success', String failure = 'https://appwrite.io/auth/oauth2/failure'}) {
308+
Future createOAuth2Session({@required String provider, String success = 'https://appwrite.io/auth/oauth2/success', String failure = 'https://appwrite.io/auth/oauth2/failure', List scopes = const []}) {
309309
final String path = '/account/sessions/oauth2/{provider}'.replaceAll(RegExp('{provider}'), provider);
310310

311311
final Map<String, dynamic> params = {
312312
'success': success,
313313
'failure': failure,
314+
'scopes': scopes,
314315
'project': client.config['project'],
315316
};
316317

@@ -375,16 +376,17 @@ class Account extends Service {
375376
/// Use this endpoint to send a verification message to your user email address
376377
/// to confirm they are the valid owners of that address. Both the **userId**
377378
/// and **secret** arguments will be passed as query parameters to the URL you
378-
/// have provider to be attached to the verification email. The provided URL
379-
/// should redirect the user back for your app and allow you to complete the
379+
/// have provided to be attached to the verification email. The provided URL
380+
/// should redirect the user back to your app and allow you to complete the
380381
/// verification process by verifying both the **userId** and **secret**
381382
/// parameters. Learn more about how to [complete the verification
382383
/// process](/docs/client/account#updateAccountVerification).
383384
///
384385
/// Please note that in order to avoid a [Redirect
385-
/// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
386+
/// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md),
386387
/// the only valid redirect URLs are the ones from domains you have set when
387388
/// adding your platforms in the console interface.
389+
///
388390
///
389391
Future<Response> createVerification({@required String url}) {
390392
final String path = '/account/verification';

lib/services/avatars.dart

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,52 @@ class Avatars extends Service {
165165
return location.toString();
166166
}
167167

168+
/// Get User Initials
169+
///
170+
/// Use this endpoint to show your user initials avatar icon on your website or
171+
/// app. By default, this route will try to print your logged-in user name or
172+
/// email initials. You can also overwrite the user name if you pass the 'name'
173+
/// parameter. If no name is given and no user is logged, an empty avatar will
174+
/// be returned.
175+
///
176+
/// You can use the color and background params to change the avatar colors. By
177+
/// default, a random theme will be selected. The random theme will persist for
178+
/// the user's initials when reloading the same theme will always return for
179+
/// the same initials.
180+
///
181+
String getInitials({String name = '', int width = 500, int height = 500, String color = '', String background = ''}) {
182+
final String path = '/avatars/initials';
183+
184+
final Map<String, dynamic> params = {
185+
'name': name,
186+
'width': width,
187+
'height': height,
188+
'color': color,
189+
'background': background,
190+
'project': client.config['project'],
191+
};
192+
193+
params.keys.forEach((key) {if (params[key] is int || params[key] is double) {
194+
params[key] = params[key].toString();
195+
}});
196+
197+
Uri endpoint = Uri.parse(client.endPoint);
198+
Uri location = new Uri(scheme: endpoint.scheme,
199+
host: endpoint.host,
200+
port: endpoint.port,
201+
path: endpoint.path + path,
202+
queryParameters:params,
203+
);
204+
205+
return location.toString();
206+
}
207+
168208
/// Get QR Code
169209
///
170210
/// Converts a given plain text to a QR code image. You can use the query
171211
/// parameters to change the size and style of the resulting image.
172212
///
173-
String getQR({@required String text, int size = 400, int margin = 1, int download = 0}) {
213+
String getQR({@required String text, int size = 400, int margin = 1, bool download = false}) {
174214
final String path = '/avatars/qr';
175215

176216
final Map<String, dynamic> params = {

lib/services/database.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Database extends Service {
1717
/// of the project documents. [Learn more about different API
1818
/// modes](/docs/admin).
1919
///
20-
Future<Response> 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}) {
20+
Future<Response> 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 = ''}) {
2121
final String path = '/database/collections/{collectionId}/documents'.replaceAll(RegExp('{collectionId}'), collectionId);
2222

2323
final Map<String, dynamic> params = {
@@ -28,8 +28,6 @@ class Database extends Service {
2828
'orderType': orderType.name(),
2929
'orderCast': orderCast,
3030
'search': search,
31-
'first': first,
32-
'last': last,
3331
};
3432

3533
final Map<String, String> headers = {

lib/services/locale.dart

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ class Locale extends Service {
106106

107107
/// List Currencies
108108
///
109-
/// List of all currencies, including currency symol, name, plural, and decimal
110-
/// digits for all major and minor currencies. You can use the locale header to
111-
/// get the data in a supported language.
109+
/// List of all currencies, including currency symbol, name, plural, and
110+
/// decimal digits for all major and minor currencies. You can use the locale
111+
/// header to get the data in a supported language.
112112
///
113113
Future<Response> getCurrencies() {
114114
final String path = '/locale/currencies';
@@ -120,6 +120,24 @@ class Locale extends Service {
120120
'content-type': 'application/json',
121121
};
122122

123+
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
124+
}
125+
126+
/// List Languages
127+
///
128+
/// List of all languages classified by ISO 639-1 including 2-letter code, name
129+
/// in English, and name in the respective language.
130+
///
131+
Future<Response> getLanguages() {
132+
final String path = '/locale/languages';
133+
134+
final Map<String, dynamic> params = {
135+
};
136+
137+
final Map<String, String> headers = {
138+
'content-type': 'application/json',
139+
};
140+
123141
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
124142
}
125143
}

0 commit comments

Comments
 (0)