From 04e9fe1682a62cce36ac7eb4fa03d004b360c9bb Mon Sep 17 00:00:00 2001 From: eldadfux Date: Sat, 2 Nov 2019 17:04:27 +0200 Subject: [PATCH] Updated SDKs --- app/sdks/dart/lib/services/auth.dart | 20 ++--- app/sdks/go/auth.go | 26 +++--- app/sdks/js/src/sdk.js | 86 +++++++++---------- app/sdks/js/src/sdk.min.js | 8 +- app/sdks/node/lib/services/auth.js | 48 +++++------ app/sdks/php/docs/auth.md | 34 ++++---- app/sdks/php/src/Appwrite/Services/Auth.php | 50 +++++------ app/sdks/python/appwrite/services/auth.py | 32 +++---- app/sdks/python/appwrite/services/database.py | 6 +- app/sdks/python/appwrite/services/teams.py | 3 +- app/sdks/ruby/lib/appwrite/services/auth.rb | 28 +++--- composer.lock | 4 +- 12 files changed, 171 insertions(+), 174 deletions(-) diff --git a/app/sdks/dart/lib/services/auth.dart b/app/sdks/dart/lib/services/auth.dart index f16ab607b8..f74121f933 100644 --- a/app/sdks/dart/lib/services/auth.dart +++ b/app/sdks/dart/lib/services/auth.dart @@ -31,6 +31,16 @@ class Auth extends Service { }; return await this.client.call('post', path: path, params: params); + } + Future oauth({provider, success, failure}) async { + String path = '/auth/login/oauth/{provider}'.replaceAll(RegExp('{provider}'), provider); + + Map params = { + 'success': success, + 'failure': failure, + }; + + return await this.client.call('get', path: path, params: params); } /// Use this endpoint to log out the currently logged in user from his account. /// When successful this endpoint will delete the user session and remove the @@ -53,16 +63,6 @@ class Auth extends Service { }; return await this.client.call('delete', path: path, params: params); - } - Future oauth({provider, success, failure}) async { - String path = '/auth/oauth/{provider}'.replaceAll(RegExp('{provider}'), provider); - - Map params = { - 'success': success, - 'failure': failure, - }; - - return await this.client.call('get', path: path, params: params); } /// Sends the user an email with a temporary secret token for password reset. /// When the user clicks the confirmation link he is redirected back to your diff --git a/app/sdks/go/auth.go b/app/sdks/go/auth.go index f538cd807a..6605aa9cd7 100644 --- a/app/sdks/go/auth.go +++ b/app/sdks/go/auth.go @@ -36,6 +36,19 @@ func (srv *Auth) Login(Email string, Password string, Success string, Failure st return srv.client.Call("POST", path, nil, params) } +// Oauth +func (srv *Auth) Oauth(Provider string, Success string, Failure string) (map[string]interface{}, error) { + r := strings.NewReplacer("{provider}", Provider) + path := r.Replace("/auth/login/oauth/{provider}") + + params := map[string]interface{}{ + "success": Success, + "failure": Failure, + } + + return srv.client.Call("GET", path, nil, params) +} + // Logout use this endpoint to log out the currently logged in user from his // account. When successful this endpoint will delete the user session and // remove the session secret cookie from the user client. @@ -62,19 +75,6 @@ func (srv *Auth) LogoutBySession(Id string) (map[string]interface{}, error) { return srv.client.Call("DELETE", path, nil, params) } -// Oauth -func (srv *Auth) Oauth(Provider string, Success string, Failure string) (map[string]interface{}, error) { - r := strings.NewReplacer("{provider}", Provider) - path := r.Replace("/auth/oauth/{provider}") - - params := map[string]interface{}{ - "success": Success, - "failure": Failure, - } - - return srv.client.Call("GET", path, nil, params) -} - // Recovery sends the user an email with a temporary secret token for password // reset. When the user clicks the confirmation link he is redirected back to // your app password reset redirect URL with a secret token and email address diff --git a/app/sdks/js/src/sdk.js b/app/sdks/js/src/sdk.js index 1608e3b497..1391649cb0 100644 --- a/app/sdks/js/src/sdk.js +++ b/app/sdks/js/src/sdk.js @@ -535,7 +535,7 @@ let auth = { /** - * Login User + * Login * * Allow the user to login into his account by providing a valid email and * password combination. Use the success and failure arguments to provide a @@ -593,6 +593,46 @@ return iframe('post', path, payload); }, + /** + * Login with OAuth + * + * + * @param {string} provider + * @param {string} success + * @param {string} failure + * @throws {Error} + * @return {null} + */ + oauth: function(provider, success, failure) { + if(provider === undefined) { + throw new Error('Missing required parameter: "provider"'); + } + + if(success === undefined) { + throw new Error('Missing required parameter: "success"'); + } + + if(failure === undefined) { + throw new Error('Missing required parameter: "failure"'); + } + + let path = '/auth/login/oauth/{provider}'.replace(new RegExp('{provider}', 'g'), provider); + + let payload = {}; + + if(success) { + payload['success'] = success; + } + + if(failure) { + payload['failure'] = failure; + } + + payload['project'] = config.project; + + return iframe('get', path, payload); + }, + /** * Logout Current Session * @@ -640,46 +680,6 @@ }, payload); }, - /** - * OAuth Login - * - * - * @param {string} provider - * @param {string} success - * @param {string} failure - * @throws {Error} - * @return {null} - */ - oauth: function(provider, success, failure) { - if(provider === undefined) { - throw new Error('Missing required parameter: "provider"'); - } - - if(success === undefined) { - throw new Error('Missing required parameter: "success"'); - } - - if(failure === undefined) { - throw new Error('Missing required parameter: "failure"'); - } - - let path = '/auth/oauth/{provider}'.replace(new RegExp('{provider}', 'g'), provider); - - let payload = {}; - - if(success) { - payload['success'] = success; - } - - if(failure) { - payload['failure'] = failure; - } - - payload['project'] = config.project; - - return iframe('get', path, payload); - }, - /** * Password Recovery * @@ -786,7 +786,7 @@ }, /** - * Register User + * Register * * Use this endpoint to allow a new user to register an account in your * project. Use the success and failure URLs to redirect users back to your @@ -865,7 +865,7 @@ }, /** - * Confirm User + * Confirmation * * Use this endpoint to complete the confirmation of the user account email * address. Both the **userId** and **token** arguments will be passed as diff --git a/app/sdks/js/src/sdk.min.js b/app/sdks/js/src/sdk.min.js index f4e06660ba..adba920a20 100644 --- a/app/sdks/js/src/sdk.min.js +++ b/app/sdks/js/src/sdk.min.js @@ -29,13 +29,13 @@ let path='/auth/login';let payload={};if(email){payload.email=email} if(password){payload.password=password} if(success){payload.success=success} if(failure){payload.failure=failure} -payload.project=config.project;return iframe('post',path,payload)},logout:function(){let path='/auth/logout';let payload={};return http.delete(path,{'content-type':'application/json',},payload)},logoutBySession:function(id){if(id===undefined){throw new Error('Missing required parameter: "id"')} -let path='/auth/logout/{id}'.replace(new RegExp('{id}','g'),id);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},oauth:function(provider,success,failure){if(provider===undefined){throw new Error('Missing required parameter: "provider"')} +payload.project=config.project;return iframe('post',path,payload)},oauth:function(provider,success,failure){if(provider===undefined){throw new Error('Missing required parameter: "provider"')} if(success===undefined){throw new Error('Missing required parameter: "success"')} if(failure===undefined){throw new Error('Missing required parameter: "failure"')} -let path='/auth/oauth/{provider}'.replace(new RegExp('{provider}','g'),provider);let payload={};if(success){payload.success=success} +let path='/auth/login/oauth/{provider}'.replace(new RegExp('{provider}','g'),provider);let payload={};if(success){payload.success=success} if(failure){payload.failure=failure} -payload.project=config.project;return iframe('get',path,payload)},recovery:function(email,reset){if(email===undefined){throw new Error('Missing required parameter: "email"')} +payload.project=config.project;return iframe('get',path,payload)},logout:function(){let path='/auth/logout';let payload={};return http.delete(path,{'content-type':'application/json',},payload)},logoutBySession:function(id){if(id===undefined){throw new Error('Missing required parameter: "id"')} +let path='/auth/logout/{id}'.replace(new RegExp('{id}','g'),id);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},recovery:function(email,reset){if(email===undefined){throw new Error('Missing required parameter: "email"')} if(reset===undefined){throw new Error('Missing required parameter: "reset"')} let path='/auth/recovery';let payload={};if(email){payload.email=email} if(reset){payload.reset=reset} diff --git a/app/sdks/node/lib/services/auth.js b/app/sdks/node/lib/services/auth.js index 03c2cf1e26..23652a326a 100644 --- a/app/sdks/node/lib/services/auth.js +++ b/app/sdks/node/lib/services/auth.js @@ -3,7 +3,7 @@ const Service = require('../service.js'); class Auth extends Service { /** - * Login User + * Login * * Allow the user to login into his account by providing a valid email and * password combination. Use the success and failure arguments to provide a @@ -41,6 +41,27 @@ class Auth extends Service { }); } + /** + * Login with OAuth + * + * @param string provider + * @param string success + * @param string failure + * @throws Exception + * @return {} + */ + async oauth(provider, success, failure) { + let path = '/auth/login/oauth/{provider}'.replace(new RegExp('{provider}', 'g'), provider); + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + 'success': success, + 'failure': failure + }); + } + /** * Logout Current Session * @@ -82,27 +103,6 @@ class Auth extends Service { }); } - /** - * OAuth Login - * - * @param string provider - * @param string success - * @param string failure - * @throws Exception - * @return {} - */ - async oauth(provider, success, failure) { - let path = '/auth/oauth/{provider}'.replace(new RegExp('{provider}', 'g'), provider); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - 'success': success, - 'failure': failure - }); - } - /** * Password Recovery * @@ -165,7 +165,7 @@ class Auth extends Service { } /** - * Register User + * Register * * Use this endpoint to allow a new user to register an account in your * project. Use the success and failure URLs to redirect users back to your @@ -214,7 +214,7 @@ class Auth extends Service { } /** - * Confirm User + * Confirmation * * Use this endpoint to complete the confirmation of the user account email * address. Both the **userId** and **token** arguments will be passed as diff --git a/app/sdks/php/docs/auth.md b/app/sdks/php/docs/auth.md index 611b5519c5..a3dd0e1cad 100644 --- a/app/sdks/php/docs/auth.md +++ b/app/sdks/php/docs/auth.md @@ -1,6 +1,6 @@ # Auth Service -## Login User +## Login ```http request POST https://appwrite.io/v1/auth/login @@ -21,6 +21,20 @@ When accessing this route using Javascript from the browser, success and failure | success | string | URL to redirect back to your app after a successful login attempt. | | | failure | string | URL to redirect back to your app after a failed login attempt. | | +## Login with OAuth + +```http request +GET https://appwrite.io/v1/auth/login/oauth/{provider} +``` + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| provider | string | **Required** OAuth Provider | | +| success | string | **Required** URL to redirect back to your app after a successful login attempt. | | +| failure | string | **Required** URL to redirect back to your app after a failed login attempt. | | + ## Logout Current Session ```http request @@ -43,20 +57,6 @@ DELETE https://appwrite.io/v1/auth/logout/{id} | --- | --- | --- | --- | | id | string | **Required** User specific session unique ID number. if 0 delete all sessions. | | -## OAuth Login - -```http request -GET https://appwrite.io/v1/auth/oauth/{provider} -``` - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| provider | string | **Required** OAuth Provider | | -| success | string | **Required** URL to redirect back to your app after a successful login attempt. | | -| failure | string | **Required** URL to redirect back to your app after a failed login attempt. | | - ## Password Recovery ```http request @@ -91,7 +91,7 @@ Please notice that in order to avoid a [Redirect Attack](https://github.com/OWAS | password-a | string | New password. | | | password-b | string | New password again. | | -## Register User +## Register ```http request POST https://appwrite.io/v1/auth/register @@ -116,7 +116,7 @@ When accessing this route using Javascript from the browser, success and failure | failure | string | Redirect when registration failed | | | name | string | User name | | -## Confirm User +## Confirmation ```http request POST https://appwrite.io/v1/auth/register/confirm diff --git a/app/sdks/php/src/Appwrite/Services/Auth.php b/app/sdks/php/src/Appwrite/Services/Auth.php index ed3f7d2e1a..980dbcd9b4 100644 --- a/app/sdks/php/src/Appwrite/Services/Auth.php +++ b/app/sdks/php/src/Appwrite/Services/Auth.php @@ -9,7 +9,7 @@ use Appwrite\Service; class Auth extends Service { /** - * Login User + * Login * * Allow the user to login into his account by providing a valid email and * password combination. Use the success and failure arguments to provide a @@ -48,6 +48,28 @@ class Auth extends Service ], $params); } + /** + * Login with OAuth + * + * @param string $provider + * @param string $success + * @param string $failure + * @throws Exception + * @return array + */ + public function oauth(string $provider, string $success, string $failure):array + { + $path = str_replace(['{provider}'], [$provider], '/auth/login/oauth/{provider}'); + $params = []; + + $params['success'] = $success; + $params['failure'] = $failure; + + return $this->client->call(Client::METHOD_GET, $path, [ + 'content-type' => 'application/json', + ], $params); + } + /** * Logout Current Session * @@ -91,28 +113,6 @@ class Auth extends Service ], $params); } - /** - * OAuth Login - * - * @param string $provider - * @param string $success - * @param string $failure - * @throws Exception - * @return array - */ - public function oauth(string $provider, string $success, string $failure):array - { - $path = str_replace(['{provider}'], [$provider], '/auth/oauth/{provider}'); - $params = []; - - $params['success'] = $success; - $params['failure'] = $failure; - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - /** * Password Recovery * @@ -177,7 +177,7 @@ class Auth extends Service } /** - * Register User + * Register * * Use this endpoint to allow a new user to register an account in your * project. Use the success and failure URLs to redirect users back to your @@ -227,7 +227,7 @@ class Auth extends Service } /** - * Confirm User + * Confirmation * * Use this endpoint to complete the confirmation of the user account email * address. Both the **userId** and **token** arguments will be passed as diff --git a/app/sdks/python/appwrite/services/auth.py b/app/sdks/python/appwrite/services/auth.py index c7a8341869..9f92b9cab7 100644 --- a/app/sdks/python/appwrite/services/auth.py +++ b/app/sdks/python/appwrite/services/auth.py @@ -4,7 +4,7 @@ from ..service import Service class Auth(Service): def login(self, email, password, success='', failure=''): - """Login User""" + """Login""" params = {} path = '/auth/login' @@ -17,6 +17,19 @@ class Auth(Service): 'content-type': 'application/json', }, params) + def oauth(self, provider, success, failure): + """Login with OAuth""" + + params = {} + path = '/auth/login/oauth/{provider}' + path.replace('{provider}', provider) + params['success'] = success + params['failure'] = failure + + return self.client.call('get', path, { + 'content-type': 'application/json', + }, params) + def logout(self): """Logout Current Session""" @@ -38,19 +51,6 @@ class Auth(Service): 'content-type': 'application/json', }, params) - def oauth(self, provider, success, failure): - """OAuth Login""" - - params = {} - path = '/auth/oauth/{provider}' - path.replace('{provider}', provider) - params['success'] = success - params['failure'] = failure - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - def recovery(self, email, reset): """Password Recovery""" @@ -78,7 +78,7 @@ class Auth(Service): }, params) def register(self, email, password, confirm, success='', failure='', name=''): - """Register User""" + """Register""" params = {} path = '/auth/register' @@ -94,7 +94,7 @@ class Auth(Service): }, params) def confirm(self, user_id, token): - """Confirm User""" + """Confirmation""" params = {} path = '/auth/register/confirm' diff --git a/app/sdks/python/appwrite/services/database.py b/app/sdks/python/appwrite/services/database.py index 55bd54f9f5..84149225c6 100644 --- a/app/sdks/python/appwrite/services/database.py +++ b/app/sdks/python/appwrite/services/database.py @@ -42,8 +42,7 @@ class Database(Service): 'content-type': 'application/json', }, params) - def update_collection(self, collection_id, name, read, write, rulesstring(4) ""[]"" -=[]): + def update_collection(self, collection_id, name, read, write, rules=[]): """Update Collection""" params = {} @@ -69,8 +68,7 @@ class Database(Service): 'content-type': 'application/json', }, params) - def list_documents(self, collection_id, filtersstring(4) ""[]"" -=[], offset=0, limit=50, order_field='$uid', order_type='ASC', order_cast='string', search='', first=0, last=0): + def list_documents(self, collection_id, filters=[], offset=0, limit=50, order_field='$uid', order_type='ASC', order_cast='string', search='', first=0, last=0): """List Documents""" params = {} diff --git a/app/sdks/python/appwrite/services/teams.py b/app/sdks/python/appwrite/services/teams.py index 85ae8f43ed..9a72a4d8c2 100644 --- a/app/sdks/python/appwrite/services/teams.py +++ b/app/sdks/python/appwrite/services/teams.py @@ -17,8 +17,7 @@ class Teams(Service): 'content-type': 'application/json', }, params) - def create_team(self, name, rolesstring(13) ""[\"owner\"]"" -=[]): + def create_team(self, name, roles=[]): """Create Team""" params = {} diff --git a/app/sdks/ruby/lib/appwrite/services/auth.rb b/app/sdks/ruby/lib/appwrite/services/auth.rb index 6cb2fb9289..bcf5e8906b 100644 --- a/app/sdks/ruby/lib/appwrite/services/auth.rb +++ b/app/sdks/ruby/lib/appwrite/services/auth.rb @@ -16,6 +16,20 @@ module Appwrite }, params); end + def oauth(provider:, success:, failure:) + path = '/auth/login/oauth/{provider}' + .gsub('{provider}', provider) + + params = { + 'success': success, + 'failure': failure + } + + return @client.call('get', path, { + 'content-type' => 'application/json', + }, params); + end + def logout() path = '/auth/logout' @@ -39,20 +53,6 @@ module Appwrite }, params); end - def oauth(provider:, success:, failure:) - path = '/auth/oauth/{provider}' - .gsub('{provider}', provider) - - params = { - 'success': success, - 'failure': failure - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - def recovery(email:, reset:) path = '/auth/recovery' diff --git a/composer.lock b/composer.lock index 213db786f8..a0a0e7f012 100644 --- a/composer.lock +++ b/composer.lock @@ -92,7 +92,7 @@ "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator", - "reference": "cd5376697e78c75bff0019c4fdb86a68271297a9" + "reference": "ea5bd009b92761af7ec3853c4a92d703e706d131" }, "require": { "ext-curl": "*", @@ -122,7 +122,7 @@ } ], "description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms", - "time": "2019-11-02 08:48:07" + "time": "2019-11-02 14:50:56" }, { "name": "bacon/bacon-qr-code",