diff --git a/README.md b/README.md
index a25dd386d0..c8fbdc3d39 100644
--- a/README.md
+++ b/README.md
@@ -124,29 +124,35 @@ Below is a list of currently supported platforms and languages. If you wish to h
- | * |
+ [ANY] |
PHP |
Appwrite Team |
✅ |
- | * |
+ [ANY] |
Javascript |
Appwrite Team |
✅ |
- | * |
+ [ANY] |
Ruby |
Appwrite Team |
✅ |
- | * |
+ [ANY] |
Python |
Appwrite Team |
✅ |
+
+ | [ANY] |
+ Node JS |
+ Appwrite Team |
+ ✅ |
+
diff --git a/app/tasks/sdks.php b/app/tasks/sdks.php
index 42bb8668af..d98c107aeb 100644
--- a/app/tasks/sdks.php
+++ b/app/tasks/sdks.php
@@ -54,7 +54,7 @@ $cli
'gitUserName' => 'appwrite',
],
'node' => [
- 'version' => 'v1.0.9',
+ 'version' => 'v1.0.10',
'result' => __DIR__ . '/../sdks/node/',
'gitURL' => 'https://github.com/appwrite/sdk-for-node.git',
'gitRepo' => 'git@github.com:appwrite/sdk-for-node.git',
diff --git a/composer.lock b/composer.lock
index 9ea992634c..088a7898e2 100644
--- a/composer.lock
+++ b/composer.lock
@@ -57,12 +57,12 @@
"source": {
"type": "git",
"url": "https://github.com/appwrite/sdk-generator.git",
- "reference": "a345962813f3e5d64f18e7f733a2d77b8fd85603"
+ "reference": "541dae92637c36668b7e0a78e248f6aec4630bd3"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/a345962813f3e5d64f18e7f733a2d77b8fd85603",
- "reference": "a345962813f3e5d64f18e7f733a2d77b8fd85603",
+ "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/541dae92637c36668b7e0a78e248f6aec4630bd3",
+ "reference": "541dae92637c36668b7e0a78e248f6aec4630bd3",
"shasum": ""
},
"require": {
@@ -94,7 +94,7 @@
}
],
"description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms",
- "time": "2019-06-05 06:46:55"
+ "time": "2019-06-06 06:22:01"
},
{
"name": "bacon/bacon-qr-code",
@@ -741,12 +741,12 @@
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
- "reference": "dd1ba1de1234e5e8939809bbd9e103e7aeebf0d5"
+ "reference": "c5aea30ff82a3565e6d3decd18d74257c033daf6"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/guzzle/psr7/zipball/dd1ba1de1234e5e8939809bbd9e103e7aeebf0d5",
- "reference": "dd1ba1de1234e5e8939809bbd9e103e7aeebf0d5",
+ "url": "https://api.github.com/repos/guzzle/psr7/zipball/c5aea30ff82a3565e6d3decd18d74257c033daf6",
+ "reference": "c5aea30ff82a3565e6d3decd18d74257c033daf6",
"shasum": ""
},
"require": {
@@ -804,7 +804,7 @@
"uri",
"url"
],
- "time": "2019-05-26 12:43:51"
+ "time": "2019-06-05 23:31:57"
},
{
"name": "influxdb/influxdb-php",
diff --git a/src/Auth/OAuth/Apple.php b/src/Auth/OAuth/Apple.php
index 37c32107e4..371bc5057f 100644
--- a/src/Auth/OAuth/Apple.php
+++ b/src/Auth/OAuth/Apple.php
@@ -8,55 +8,113 @@ class Apple extends OAuth
{
//READ THE DOCS HERE: https://developer.apple.com/documentation/signinwithapplerestapi
+//https://appleid.apple.com/auth/token
+ /**
+ * @var string
+ */
+ protected $version = 'v2.8';
+
+ /**
+ * @var array
+ */
+ protected $user = [];
+
/**
* @return string
*/
- public function getName(): string
+ public function getName():string
{
- // TODO: Implement getName() method.
+ return 'facebook';
}
/**
* @return string
*/
- public function getLoginURL(): string
+ public function getLoginURL():string
{
- // TODO: Implement getLoginURL() method.
+ return '?client_id=' . urlencode($this->appID) . '&redirect_uri=' . urlencode($this->callback) . '&scope=email&state=' . urlencode(json_encode($this->state));
}
/**
* @param string $code
* @return string
*/
- public function getAccessToken(string $code): string
+ public function getAccessToken(string $code):string
{
- // TODO: Implement getAccessToken() method.
+ $accessToken = $this->request('GET', 'https://appleid.apple.com/auth/token' .
+ 'client_id=' . urlencode($this->appID) .
+ '&client_secret=' . urlencode($this->appSecret) .
+ '&redirect_uri=' . urlencode($this->callback) .
+ '&code=' . urlencode($code) .
+ '&grant_type=authorization_token'
+ );
+
+ $accessToken = json_decode($accessToken, true); //
+
+ if(isset($accessToken['access_token'])) {
+ return $accessToken['access_token'];
+ }
+
+ return '';
}
/**
- * @param $accessToken
+ * @param string $accessToken
* @return string
*/
- public function getUserID(string $accessToken): string
+ public function getUserID(string $accessToken):string
{
- // TODO: Implement getUserID() method.
+ $user = $this->getUser($accessToken);
+
+ if(isset($user['id'])) {
+ return $user['id'];
+ }
+
+ return '';
}
/**
- * @param $accessToken
+ * @param string $accessToken
* @return string
*/
- public function getUserEmail(string $accessToken): string
+ public function getUserEmail(string $accessToken):string
{
- // TODO: Implement getUserEmail() method.
+ $user = $this->getUser($accessToken);
+
+ if(isset($user['email'])) {
+ return $user['email'];
+ }
+
+ return '';
}
/**
- * @param $accessToken
+ * @param string $accessToken
* @return string
*/
- public function getUserName(string $accessToken): string
+ public function getUserName(string $accessToken):string
{
- // TODO: Implement getUserName() method.
+ $user = $this->getUser($accessToken);
+
+ if(isset($user['name'])) {
+ return $user['name'];
+ }
+
+ return '';
+ }
+
+ /**
+ * @param string $accessToken
+ * @return array
+ */
+ protected function getUser(string $accessToken):array
+ {
+ if(empty($this->user)) {
+ $user = $this->request('GET', 'https://graph.facebook.com/' . $this->version . '/me?fields=email,name&access_token=' . urlencode($accessToken));
+
+ $this->user = json_decode($user, true);
+ }
+
+ return $this->user;
}
}
\ No newline at end of file