1
0
Fork 0
mirror of synced 2024-06-26 10:10:57 +12:00

Updated SDKs

This commit is contained in:
eldadfux 2019-09-03 16:40:42 +03:00
parent 585b16559c
commit 11440f8bc1
15 changed files with 238 additions and 238 deletions

View file

@ -5,7 +5,7 @@ sdk
setKey('')
;
let promise = sdk.projects.updateTask('[PROJECT_ID]', '[TASK_ID]', '[NAME]', 'play', '', 0, 'GET', 'https://example.com');
let promise = sdk.projects.updateTask('[PROJECT_ID]', '[TASK_ID]', '[NAME]', 'play', '', 1, 'GET', 'https://example.com');
promise.then(function (response) {
console.log(response);

View file

@ -2,7 +2,7 @@
"name": "appwrite",
"homepage": "https://appwrite.io/support",
"description": "Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)",
"version": "v1.0.19",
"version": "v1.0.20",
"license": "BSD-3-Clause",
"main": "src/sdk.js",
"repository": {

View file

@ -138,7 +138,7 @@
globalParams.push({key: key, value: value});
};
addGlobalHeader('x-sdk-version', 'appwrite:javascript:v1.0.19');
addGlobalHeader('x-sdk-version', 'appwrite:javascript:v1.0.20');
addGlobalHeader('content-type', '');
/**
@ -572,6 +572,63 @@
});
},
/**
* OAuth Callback
*
*
* @param {string} projectId
* @param {string} provider
* @param {string} code
* @param {string} state
* @throws {Error}
* @return {Promise} */
oauthCallback: function(projectId, provider, code, state = '') {
if(projectId === undefined) {
throw new Error('Missing required parameter: "projectId"');
}
if(provider === undefined) {
throw new Error('Missing required parameter: "provider"');
}
if(code === undefined) {
throw new Error('Missing required parameter: "code"');
}
let path = '/auth/oauth/callback/{provider}/{projectId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{provider}', 'g'), provider);
return http
.get(path, {'content-type': 'application/json'},
{
'code': code,
'state': state
});
},
/**
* OAuth Login
*
*
* @param {string} provider
* @param {string} success
* @param {string} failure
* @throws {Error}
* @return {Promise} */
oauth: function(provider, success = '', failure = '') {
if(provider === undefined) {
throw new Error('Missing required parameter: "provider"');
}
let path = '/auth/oauth/{provider}'.replace(new RegExp('{provider}', 'g'), provider);
return http
.get(path, {'content-type': 'application/json'},
{
'success': success,
'failure': failure
});
},
/**
* Password Recovery
*
@ -768,63 +825,6 @@
{
'redirect': redirect
});
},
/**
* OAuth Callback
*
*
* @param {string} projectId
* @param {string} provider
* @param {string} code
* @param {string} state
* @throws {Error}
* @return {Promise} */
oauthCallback: function(projectId, provider, code, state = '') {
if(projectId === undefined) {
throw new Error('Missing required parameter: "projectId"');
}
if(provider === undefined) {
throw new Error('Missing required parameter: "provider"');
}
if(code === undefined) {
throw new Error('Missing required parameter: "code"');
}
let path = '/oauth/callback/{provider}/{projectId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{provider}', 'g'), provider);
return http
.get(path, {'content-type': 'application/json'},
{
'code': code,
'state': state
});
},
/**
* OAuth Login
*
*
* @param {string} provider
* @param {string} success
* @param {string} failure
* @throws {Error}
* @return {Promise} */
oauth: function(provider, success = '', failure = '') {
if(provider === undefined) {
throw new Error('Missing required parameter: "provider"');
}
let path = '/oauth/{provider}'.replace(new RegExp('{provider}', 'g'), provider);
return http
.get(path, {'content-type': 'application/json'},
{
'success': success,
'failure': failure
});
}
};

View file

@ -1,5 +1,5 @@
(function(window){window.Appwrite=function(){let config={endpoint:'https://appwrite.test/v1',project:'',key:'',locale:'',mode:'',};let setEndpoint=function(endpoint){config.endpoint=endpoint;return this};let setProject=function(value){http.addGlobalHeader('X-Appwrite-Project',value);config.project=value;return this};let setKey=function(value){http.addGlobalHeader('X-Appwrite-Key',value);config.key=value;return this};let setLocale=function(value){http.addGlobalHeader('X-Appwrite-Locale',value);config.locale=value;return this};let setMode=function(value){http.addGlobalHeader('X-Appwrite-Mode',value);config.mode=value;return this};let http=function(document){let globalParams=[],globalHeaders=[];let addParam=function(url,param,value){let a=document.createElement('a'),regex=/(?:\?|&amp;|&)+([^=]+)(?:=([^&]*))*/g;let match,str=[];a.href=url;param=encodeURIComponent(param);while(match=regex.exec(a.search))if(param!==match[1])str.push(match[1]+(match[2]?"="+match[2]:""));str.push(param+(value?"="+encodeURIComponent(value):""));a.search=str.join("&");return a.href};let buildQuery=function(params){let str=[];for(let p in params){if(Array.isArray(params[p])){for(let index=0;index<params[p].length;index++){let param=params[p][index];str.push(encodeURIComponent(p+'[]')+"="+encodeURIComponent(param))}}else{str.push(encodeURIComponent(p)+"="+encodeURIComponent(params[p]))}}
return str.join("&")};let addGlobalHeader=function(key,value){globalHeaders[key]={key:key.toLowerCase(),value:value.toLowerCase()}};let addGlobalParam=function(key,value){globalParams.push({key:key,value:value})};addGlobalHeader('x-sdk-version','appwrite:javascript:v1.0.19');addGlobalHeader('content-type','');let call=function(method,path,headers={},params={},progress=null){let i;path=config.endpoint+path;if(-1===['GET','POST','PUT','DELETE','TRACE','HEAD','OPTIONS','CONNECT','PATCH'].indexOf(method)){throw new Error('var method must contain a valid HTTP method name')}
return str.join("&")};let addGlobalHeader=function(key,value){globalHeaders[key]={key:key.toLowerCase(),value:value.toLowerCase()}};let addGlobalParam=function(key,value){globalParams.push({key:key,value:value})};addGlobalHeader('x-sdk-version','appwrite:javascript:v1.0.20');addGlobalHeader('content-type','');let call=function(method,path,headers={},params={},progress=null){let i;path=config.endpoint+path;if(-1===['GET','POST','PUT','DELETE','TRACE','HEAD','OPTIONS','CONNECT','PATCH'].indexOf(method)){throw new Error('var method must contain a valid HTTP method name')}
if(typeof path!=='string'){throw new Error('var path must be of type string')}
if(typeof headers!=='object'){throw new Error('var headers must be of type object')}
for(i=0;i<globalParams.length;i++){path=addParam(path,globalParams[i].key,globalParams[i].value)}
@ -20,7 +20,11 @@ let path='/account/password';return http.patch(path,{'content-type':'application
let path='/account/prefs';return http.patch(path,{'content-type':'application/json'},{'prefs':prefs})},getSecurity:function(){let path='/account/security';return http.get(path,{'content-type':'application/json'},{})},getSessions:function(){let path='/account/sessions';return http.get(path,{'content-type':'application/json'},{})}};let auth={login:function(email,password,success='',failure=''){if(email===undefined){throw new Error('Missing required parameter: "email"')}
if(password===undefined){throw new Error('Missing required parameter: "password"')}
let path='/auth/login';return iframe('post',path,{project:config.project,'email':email,'password':password,'success':success,'failure':failure})},logout:function(){let path='/auth/logout';return http.delete(path,{'content-type':'application/json'},{})},logoutBySession:function(id){if(id===undefined){throw new Error('Missing required parameter: "id"')}
let path='/auth/logout/{id}'.replace(new RegExp('{id}','g'),id);return http.delete(path,{'content-type':'application/json'},{})},recovery:function(email,redirect){if(email===undefined){throw new Error('Missing required parameter: "email"')}
let path='/auth/logout/{id}'.replace(new RegExp('{id}','g'),id);return http.delete(path,{'content-type':'application/json'},{})},oauthCallback:function(projectId,provider,code,state=''){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')}
if(provider===undefined){throw new Error('Missing required parameter: "provider"')}
if(code===undefined){throw new Error('Missing required parameter: "code"')}
let path='/auth/oauth/callback/{provider}/{projectId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{provider}','g'),provider);return http.get(path,{'content-type':'application/json'},{'code':code,'state':state})},oauth:function(provider,success='',failure=''){if(provider===undefined){throw new Error('Missing required parameter: "provider"')}
let path='/auth/oauth/{provider}'.replace(new RegExp('{provider}','g'),provider);return http.get(path,{'content-type':'application/json'},{'success':success,'failure':failure})},recovery:function(email,redirect){if(email===undefined){throw new Error('Missing required parameter: "email"')}
if(redirect===undefined){throw new Error('Missing required parameter: "redirect"')}
let path='/auth/recovery';return http.post(path,{'content-type':'application/json'},{'email':email,'redirect':redirect})},recoveryReset:function(userId,token,passwordA,passwordB){if(userId===undefined){throw new Error('Missing required parameter: "userId"')}
if(token===undefined){throw new Error('Missing required parameter: "token"')}
@ -32,11 +36,7 @@ if(redirect===undefined){throw new Error('Missing required parameter: "redirect"
let path='/auth/register';return iframe('post',path,{project:config.project,'email':email,'password':password,'name':name,'redirect':redirect,'success':success,'failure':failure})},confirm:function(userId,token){if(userId===undefined){throw new Error('Missing required parameter: "userId"')}
if(token===undefined){throw new Error('Missing required parameter: "token"')}
let path='/auth/register/confirm';return http.post(path,{'content-type':'application/json'},{'userId':userId,'token':token})},confirmResend:function(redirect){if(redirect===undefined){throw new Error('Missing required parameter: "redirect"')}
let path='/auth/register/confirm/resend';return http.post(path,{'content-type':'application/json'},{'redirect':redirect})},oauthCallback:function(projectId,provider,code,state=''){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')}
if(provider===undefined){throw new Error('Missing required parameter: "provider"')}
if(code===undefined){throw new Error('Missing required parameter: "code"')}
let path='/oauth/callback/{provider}/{projectId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{provider}','g'),provider);return http.get(path,{'content-type':'application/json'},{'code':code,'state':state})},oauth:function(provider,success='',failure=''){if(provider===undefined){throw new Error('Missing required parameter: "provider"')}
let path='/oauth/{provider}'.replace(new RegExp('{provider}','g'),provider);return http.get(path,{'content-type':'application/json'},{'success':success,'failure':failure})}};let avatars={getBrowser:function(code,width=100,height=100,quality=100){if(code===undefined){throw new Error('Missing required parameter: "code"')}
let path='/auth/register/confirm/resend';return http.post(path,{'content-type':'application/json'},{'redirect':redirect})}};let avatars={getBrowser:function(code,width=100,height=100,quality=100){if(code===undefined){throw new Error('Missing required parameter: "code"')}
let path='/avatars/browsers/{code}'.replace(new RegExp('{code}','g'),code);return http.get(path,{'content-type':'application/json'},{'width':width,'height':height,'quality':quality})},getCreditCard:function(code,width=100,height=100,quality=100){if(code===undefined){throw new Error('Missing required parameter: "code"')}
let path='/avatars/credit-cards/{code}'.replace(new RegExp('{code}','g'),code);return http.get(path,{'content-type':'application/json'},{'width':width,'height':height,'quality':quality})},getFavicon:function(url){if(url===undefined){throw new Error('Missing required parameter: "url"')}
let path='/avatars/favicon';return http.get(path,{'content-type':'application/json'},{'url':url})},getFlag:function(code,width=100,height=100,quality=100){if(code===undefined){throw new Error('Missing required parameter: "code"')}

View file

@ -5,7 +5,7 @@ sdk
setKey('')
;
let promise = sdk.projects.updateTask('[PROJECT_ID]', '[TASK_ID]', '[NAME]', 'play', '', 0, 'GET', 'https://example.com');
let promise = sdk.projects.updateTask('[PROJECT_ID]', '[TASK_ID]', '[NAME]', 'play', '', 1, 'GET', 'https://example.com');
promise.then(function (response) {
console.log(response);

View file

@ -7,7 +7,7 @@ class Client {
this.endpoint = 'https://appwrite.test/v1';
this.headers = {
'content-type': '',
'x-sdk-version': 'appwrite:nodejs:v1.0.23',
'x-sdk-version': 'appwrite:nodejs:v1.0.24',
};
this.selfSigned = false;
}

View file

@ -76,6 +76,45 @@ class Auth extends Service {
});
}
/**
* OAuth Callback
*
* @param string projectId
* @param string provider
* @param string code
* @param string state
* @throws Exception
* @return {}
*/
async oauthCallback(projectId, provider, code, state = '') {
let path = '/auth/oauth/callback/{provider}/{projectId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{provider}', 'g'), provider);
return await this.client.call('get', path, {'content-type': 'application/json'},
{
'code': code,
'state': state
});
}
/**
* 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
*
@ -227,45 +266,6 @@ class Auth extends Service {
'redirect': redirect
});
}
/**
* OAuth Callback
*
* @param string projectId
* @param string provider
* @param string code
* @param string state
* @throws Exception
* @return {}
*/
async oauthCallback(projectId, provider, code, state = '') {
let path = '/oauth/callback/{provider}/{projectId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{provider}', 'g'), provider);
return await this.client.call('get', path, {'content-type': 'application/json'},
{
'code': code,
'state': state
});
}
/**
* OAuth Login
*
* @param string provider
* @param string success
* @param string failure
* @throws Exception
* @return {}
*/
async oauth(provider, success = '', failure = '') {
let path = '/oauth/{provider}'.replace(new RegExp('{provider}', 'g'), provider);
return await this.client.call('get', path, {'content-type': 'application/json'},
{
'success': success,
'failure': failure
});
}
}
module.exports = Auth;

View file

@ -2,7 +2,7 @@
"name": "node-appwrite",
"homepage": "https://appwrite.io/support",
"description": "Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)",
"version": "v1.0.23",
"version": "v1.0.24",
"license": "BSD-3-Clause",
"main": "index.js",
"repository": {

View file

@ -43,6 +43,35 @@ DELETE https://appwrite.test/v1/auth/logout/{id}
| --- | --- | --- | --- |
| id | string | **Required** User specific session unique ID number. if 0 delete all sessions. | |
## OAuth Callback
```http request
GET https://appwrite.test/v1/auth/oauth/callback/{provider}/{projectId}
```
### Parameters
| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| projectId | string | **Required** Project unique ID | |
| provider | string | **Required** OAuth provider | |
| code | string | **Required** OAuth code | |
| state | string | Login state params | |
## OAuth Login
```http request
GET https://appwrite.test/v1/auth/oauth/{provider}
```
### Parameters
| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| provider | string | **Required** OAuth Provider | |
| 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. | |
## Password Recovery
```http request
@ -133,32 +162,3 @@ Please notice that in order to avoid a [Redirect Attacks](https://github.com/OWA
| --- | --- | --- | --- |
| redirect | string | Confirmation page to redirect user to your app after confirm token has been sent to user email. | |
## OAuth Callback
```http request
GET https://appwrite.test/v1/oauth/callback/{provider}/{projectId}
```
### Parameters
| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| projectId | string | **Required** Project unique ID | |
| provider | string | **Required** OAuth provider | |
| code | string | **Required** OAuth code | |
| state | string | Login state params | |
## OAuth Login
```http request
GET https://appwrite.test/v1/oauth/{provider}
```
### Parameters
| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| provider | string | **Required** OAuth Provider | |
| 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. | |

View file

@ -12,4 +12,4 @@ $client
$projects = new Projects($client);
$result = $projects->updateTask('[PROJECT_ID]', '[TASK_ID]', '[NAME]', 'play', '', 0, 'GET', 'https://example.com');
$result = $projects->updateTask('[PROJECT_ID]', '[TASK_ID]', '[NAME]', 'play', '', 1, 'GET', 'https://example.com');

View file

@ -37,7 +37,7 @@ class Client
*/
protected $headers = [
'content-type' => '',
'x-sdk-version' => 'appwrite:php:v1.0.6',
'x-sdk-version' => 'appwrite:php:v1.0.7',
];
/**

View file

@ -88,6 +88,49 @@ class Auth extends Service
], $params);
}
/**
* OAuth Callback
*
* @param string $projectId
* @param string $provider
* @param string $code
* @param string $state
* @throws Exception
* @return array
*/
public function oauthCallback($projectId, $provider, $code, $state = '')
{
$path = str_replace(['{projectId}', '{provider}'], [$projectId, $provider], '/auth/oauth/callback/{provider}/{projectId}');
$params = [];
$params['code'] = $code;
$params['state'] = $state;
return $this->client->call(Client::METHOD_GET, $path, [
], $params);
}
/**
* OAuth Login
*
* @param string $provider
* @param string $success
* @param string $failure
* @throws Exception
* @return array
*/
public function oauth($provider, $success = '', $failure = '')
{
$path = str_replace(['{provider}'], [$provider], '/auth/oauth/{provider}');
$params = [];
$params['success'] = $success;
$params['failure'] = $failure;
return $this->client->call(Client::METHOD_GET, $path, [
], $params);
}
/**
* Password Recovery
*
@ -250,47 +293,4 @@ class Auth extends Service
], $params);
}
/**
* OAuth Callback
*
* @param string $projectId
* @param string $provider
* @param string $code
* @param string $state
* @throws Exception
* @return array
*/
public function oauthCallback($projectId, $provider, $code, $state = '')
{
$path = str_replace(['{projectId}', '{provider}'], [$projectId, $provider], '/oauth/callback/{provider}/{projectId}');
$params = [];
$params['code'] = $code;
$params['state'] = $state;
return $this->client->call(Client::METHOD_GET, $path, [
], $params);
}
/**
* OAuth Login
*
* @param string $provider
* @param string $success
* @param string $failure
* @throws Exception
* @return array
*/
public function oauth($provider, $success = '', $failure = '')
{
$path = str_replace(['{provider}'], [$provider], '/oauth/{provider}');
$params = [];
$params['success'] = $success;
$params['failure'] = $failure;
return $this->client->call(Client::METHOD_GET, $path, [
], $params);
}
}

View file

@ -35,6 +35,31 @@ class Auth(Service):
return self.client.call('delete', path, {
}, params)
def oauth_callback(self, project_id, provider, code, state=''):
"""OAuth Callback"""
params = {}
path = '/auth/oauth/callback/{provider}/{projectId}'
path.replace('{projectId}', project_id)
path.replace('{provider}', provider)
params['code'] = code
params['state'] = state
return self.client.call('get', path, {
}, 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, {
}, params)
def recovery(self, email, redirect):
"""Password Recovery"""
@ -94,28 +119,3 @@ class Auth(Service):
return self.client.call('post', path, {
}, params)
def oauth_callback(self, project_id, provider, code, state=''):
"""OAuth Callback"""
params = {}
path = '/oauth/callback/{provider}/{projectId}'
path.replace('{projectId}', project_id)
path.replace('{provider}', provider)
params['code'] = code
params['state'] = state
return self.client.call('get', path, {
}, params)
def oauth(self, provider, success='', failure=''):
"""OAuth Login"""
params = {}
path = '/oauth/{provider}'
path.replace('{provider}', provider)
params['success'] = success
params['failure'] = failure
return self.client.call('get', path, {
}, params)

View file

@ -36,6 +36,33 @@ module Appwrite
}, params);
end
def oauth_callback(project_id:, provider:, code:, state: '')
path = '/auth/oauth/callback/{provider}/{projectId}'
.gsub('{project_id}', project_id)
.gsub('{provider}', provider)
params = {
'code': code,
'state': state
}
return @client.call('get', path, {
}, params);
end
def oauth(provider:, success: '', failure: '')
path = '/auth/oauth/{provider}'
.gsub('{provider}', provider)
params = {
'success': success,
'failure': failure
}
return @client.call('get', path, {
}, params);
end
def recovery(email:, redirect:)
path = '/auth/recovery'
@ -101,33 +128,6 @@ module Appwrite
}, params);
end
def oauth_callback(project_id:, provider:, code:, state: '')
path = '/oauth/callback/{provider}/{projectId}'
.gsub('{project_id}', project_id)
.gsub('{provider}', provider)
params = {
'code': code,
'state': state
}
return @client.call('get', path, {
}, params);
end
def oauth(provider:, success: '', failure: '')
path = '/oauth/{provider}'
.gsub('{provider}', provider)
params = {
'success': success,
'failure': failure
}
return @client.call('get', path, {
}, params);
end
protected

View file

@ -38,7 +38,7 @@ $cli
$clients = [
'php' => [
'version' => 'v1.0.6',
'version' => 'v1.0.7',
'result' => __DIR__ . '/../sdks/php/',
'gitURL' => 'https://github.com/appwrite/sdk-for-php.git',
'gitRepo' => 'git@github.com:appwrite/sdk-for-php.git',
@ -47,7 +47,7 @@ $cli
'warning' => '',
],
'js' => [
'version' => 'v1.0.19',
'version' => 'v1.0.20',
'result' => __DIR__ . '/../sdks/js/',
'gitURL' => 'https://github.com/appwrite/sdk-for-js.git',
'gitRepo' => 'git@github.com:appwrite/sdk-for-js.git',
@ -56,7 +56,7 @@ $cli
'warning' => '',
],
'node' => [
'version' => 'v1.0.23',
'version' => 'v1.0.24',
'result' => __DIR__ . '/../sdks/node/',
'gitURL' => 'https://github.com/appwrite/sdk-for-node.git',
'gitRepo' => 'git@github.com:appwrite/sdk-for-node.git',