Skip to content

Commit

Permalink
fixed linter
Browse files Browse the repository at this point in the history
  • Loading branch information
gaokevin1 committed Dec 23, 2024
1 parent 2333751 commit 957ce83
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 29 deletions.
42 changes: 21 additions & 21 deletions src/SDK/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class API
/**
* Constructor for API class.
*
* @param string $projectId
* @param string $projectId
* @param string|null $managementKey Management key for authentication.
*/
public function __construct(string $projectId, ?string $managementKey)
Expand Down Expand Up @@ -52,7 +52,7 @@ public function __construct(string $projectId, ?string $managementKey)
* This function ensures that empty arrays in the input data are
* converted to empty objects (stdClass) before being JSON encoded.
*
* @param mixed $data The data to transform, which can be an array or any other type.
* @param mixed $data The data to transform, which can be an array or any other type.
* @return mixed The transformed data with empty arrays replaced by empty objects.
*/
private function transformEmptyArraysToObjects($data)
Expand All @@ -76,9 +76,9 @@ private function transformEmptyArraysToObjects($data)
/**
* Requests JwtResponse from Descope APIs with the given body and auth token.
*
* @param string $uri URI endpoint.
* @param array $body Request body.
* @param bool $useManagementKey Whether to use the management key for authentication.
* @param string $uri URI endpoint.
* @param array $body Request body.
* @param bool $useManagementKey Whether to use the management key for authentication.
* @return array JWT response array.
* @throws AuthException|GuzzleException|\JsonException If the request fails.
*/
Expand Down Expand Up @@ -130,8 +130,8 @@ public function doPost(string $uri, array $body, ?bool $useManagementKey = false
/**
* Sends a GET request to the specified URI with an optional auth token.
*
* @param string $uri URI endpoint.
* @param bool $useManagementKey Whether to use the management key for authentication.
* @param string $uri URI endpoint.
* @param bool $useManagementKey Whether to use the management key for authentication.
* @return array JWT response array.
* @throws AuthException|GuzzleException|\JsonException If the request fails.
*/
Expand Down Expand Up @@ -178,7 +178,7 @@ public function doGet(string $uri, bool $useManagementKey, ?string $refreshToken
/**
* Sends a DELETE request to the specified URI with an auth token.
*
* @param string $uri URI endpoint.
* @param string $uri URI endpoint.
* @return array JWT response array.
* @throws AuthException|GuzzleException|\JsonException If the request fails.
*/
Expand Down Expand Up @@ -219,9 +219,9 @@ public function doDelete(string $uri): array
/**
* Generates a JWT response array with the given parameters.
*
* @param array $responseBody
* @param string|null $refreshToken Refresh token.
* @param string|null $audience Audience.
* @param array $responseBody
* @param string|null $refreshToken Refresh token.
* @param string|null $audience Audience.
* @return array JWT response array.
*/
public function generateJwtResponse(array $responseBody, ?string $refreshToken = null, ?string $audience = null): array
Expand All @@ -237,7 +237,7 @@ public function generateJwtResponse(array $responseBody, ?string $refreshToken =
/**
* Generates headers for the HTTP request.
*
* @param string|null $authToken Authentication token.
* @param string|null $authToken Authentication token.
* @return array Headers array.
*/
private function getHeaders(string $authToken): array
Expand All @@ -255,7 +255,7 @@ private function getHeaders(string $authToken): array
/**
* Constructs the auth token based on whether the management key is used.
*
* @param bool $useManagementKey Whether to use the management key for authentication.
* @param bool $useManagementKey Whether to use the management key for authentication.
* @return string The constructed auth token.
*/
private function getAuthToken(bool $useManagementKey, ?string $refreshToken = null): string
Expand All @@ -277,12 +277,12 @@ private function getAuthToken(bool $useManagementKey, ?string $refreshToken = nu
* This method processes the response body to extract JWTs, session data,
* and cookie settings, and adjusts properties based on the token type.
*
* @param array $responseBody The API response body containing JWTs and user data.
* @param string|null $refreshToken Optional refresh token.
* @param bool $userJwt Indicates if user-related JWT information should be processed.
* @param string|null $audience Optional audience identifier.
* @param array $responseBody The API response body containing JWTs and user data.
* @param string|null $refreshToken Optional refresh token.
* @param bool $userJwt Indicates if user-related JWT information should be processed.
* @param string|null $audience Optional audience identifier.
* @return array The structured JWT response array containing session and user data.
*/
*/
private function generateAuthInfo(array $responseBody, ?string $refreshToken, bool $userJwt, ?string $audience): array
{
$jwtResponse = [];
Expand Down Expand Up @@ -320,10 +320,10 @@ private function generateAuthInfo(array $responseBody, ?string $refreshToken, bo
* This method sets permissions, roles, and tenant data from the JWT
* and processes the issuer and subject values to extract project and user IDs.
*
* @param array $jwtResponse The JWT response array to adjust.
* @param bool $userJwt Indicates if user-related JWT information should be processed.
* @param array $jwtResponse The JWT response array to adjust.
* @param bool $userJwt Indicates if user-related JWT information should be processed.
* @return array The adjusted JWT response array with updated properties.
*/
*/
private function adjustProperties(array $jwtResponse, bool $userJwt): array
{
if (isset($jwtResponse[EndpointsV1::$SESSION_TOKEN_NAME])) {
Expand Down
12 changes: 6 additions & 6 deletions src/SDK/Auth/SSO.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function signIn(?string $tenant = null, ?string $redirectUrl = null, ?str
/**
* Exchanges SSO code for authentication.
*
* @param string|null $code The exchange code.
* @param string|null $code The exchange code.
* @return array Response array.
*/
public function exchangeToken(?string $code = null): array
Expand All @@ -77,9 +77,9 @@ public function exchangeToken(?string $code = null): array
/**
* Composes the SSO sign-in URL.
*
* @param string|null $tenant Tenant identifier.
* @param string|null $redirectUrl Redirect URL.
* @param string|null $prompt Prompt parameter.
* @param string|null $tenant Tenant identifier.
* @param string|null $redirectUrl Redirect URL.
* @param string|null $prompt Prompt parameter.
* @return string Composed URL.
*/
private function composeSignInUrl(?string $tenant, ?string $redirectUrl, ?string $prompt): string
Expand All @@ -104,7 +104,7 @@ private function composeSignInUrl(?string $tenant, ?string $redirectUrl, ?string
/**
* Validates the tenant parameter.
*
* @param string|null $tenant The tenant identifier.
* @param string|null $tenant The tenant identifier.
* @throws AuthException
*/
private function validateTenant(?string $tenant): void
Expand All @@ -117,7 +117,7 @@ private function validateTenant(?string $tenant): void
/**
* Validates the redirect URL parameter.
*
* @param string|null $redirectUrl The redirect URL.
* @param string|null $redirectUrl The redirect URL.
* @throws AuthException
*/
private function validateRedirectUrl(?string $redirectUrl): void
Expand Down
1 change: 0 additions & 1 deletion src/SDK/Management/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,4 @@ public function validateTenantRoles(array $jwtResponse, string $tenant, array $r

return empty(array_diff($roles, $grantedRoles));
}

}
2 changes: 1 addition & 1 deletion src/tests/DescopeSDKTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ public function testRefreshSessionThrowsExceptionWithoutToken()
$this->expectException(\InvalidArgumentException::class);
$this->sdk->refreshSession(null);
}
}
}

0 comments on commit 957ce83

Please sign in to comment.