Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3 exception classes are missing. #1

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions ASDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use AppleSignIn\Vendor\JWT;

use Exception;
use stdClass;

/**
* Decode Sign In with Apple identity token, and produce an ASPayload for
Expand All @@ -21,9 +22,9 @@ class ASDecoder {
* Parse a provided Sign In with Apple identity token.
*
* @param string $identityToken
* @return object|null
* @return ASPayload|null
*/
public static function getAppleSignInPayload(string $identityToken) : ?object
public static function getAppleSignInPayload(string $identityToken) : ?ASPayload
{
$identityPayload = self::decodeIdentityToken($identityToken);
return new ASPayload($identityPayload);
Expand All @@ -33,14 +34,15 @@ public static function getAppleSignInPayload(string $identityToken) : ?object
* Decode the Apple encoded JWT using Apple's public key for the signing.
*
* @param string $identityToken
* @return object
* @return stdClass
*/
public static function decodeIdentityToken(string $identityToken) : object {
public static function decodeIdentityToken(string $identityToken) : stdClass {
$publicKeyData = self::fetchPublicKey();

$publicKey = $publicKeyData['publicKey'];
$alg = $publicKeyData['alg'];

JWT::$leeway = 60;
$payload = JWT::decode($identityToken, $publicKey, [$alg]);

return $payload;
Expand Down Expand Up @@ -82,7 +84,7 @@ public static function fetchPublicKey() : array {
class ASPayload {
protected $_instance;

public function __construct(?object $instance) {
public function __construct(?stdClass $instance) {
if(is_null($instance)) {
throw new Exception('ASPayload received null instance.');
}
Expand Down
7 changes: 7 additions & 0 deletions Vendor/BeforeValidException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
namespace AppleSignIn\Vendor;

class BeforeValidException extends \UnexpectedValueException
{

}
7 changes: 7 additions & 0 deletions Vendor/ExpiredException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
namespace AppleSignIn\Vendor;

class ExpiredException extends \UnexpectedValueException
{

}
7 changes: 7 additions & 0 deletions Vendor/SignatureInvalidException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
namespace AppleSignIn\Vendor;

class SignatureInvalidException extends \UnexpectedValueException
{

}