提交的内容

This commit is contained in:
2025-05-12 15:45:02 +08:00
parent 629c4750da
commit b48c692775
3043 changed files with 34732 additions and 60810 deletions

3
vendor/overtrue/socialite/src/Config.php vendored Executable file → Normal file
View File

@ -9,9 +9,6 @@ class Config implements ArrayAccess, JsonSerializable
{
protected array $config;
/**
* @param array $config
*/
public function __construct(array $config)
{
$this->config = $config;

0
vendor/overtrue/socialite/src/Contracts/FactoryInterface.php vendored Executable file → Normal file
View File

0
vendor/overtrue/socialite/src/Contracts/ProviderInterface.php vendored Executable file → Normal file
View File

0
vendor/overtrue/socialite/src/Contracts/UserInterface.php vendored Executable file → Normal file
View File

View File

4
vendor/overtrue/socialite/src/Exceptions/BadRequestException.php vendored Executable file → Normal file
View File

@ -2,6 +2,4 @@
namespace Overtrue\Socialite\Exceptions;
class BadRequestException extends Exception
{
}
class BadRequestException extends Exception {}

0
vendor/overtrue/socialite/src/Exceptions/Exception.php vendored Executable file → Normal file
View File

View File

@ -4,6 +4,4 @@ namespace Overtrue\Socialite\Exceptions\FeiShu;
use Overtrue\Socialite\Exceptions;
class InvalidTicketException extends Exceptions\Exception
{
}
class InvalidTicketException extends Exceptions\Exception {}

View File

0
vendor/overtrue/socialite/src/Exceptions/InvalidTokenException.php vendored Executable file → Normal file
View File

View File

0
vendor/overtrue/socialite/src/Providers/Alipay.php vendored Executable file → Normal file
View File

0
vendor/overtrue/socialite/src/Providers/Azure.php vendored Executable file → Normal file
View File

0
vendor/overtrue/socialite/src/Providers/Baidu.php vendored Executable file → Normal file
View File

26
vendor/overtrue/socialite/src/Providers/Base.php vendored Executable file → Normal file
View File

@ -15,29 +15,29 @@ abstract class Base implements Contracts\ProviderInterface
{
public const NAME = null;
protected ?string $state = null;
protected ?string $state = null;
protected Config $config;
protected Config $config;
protected ?string $redirectUrl;
protected ?string $redirectUrl;
protected array $parameters = [];
protected array $parameters = [];
protected array $scopes = [];
protected array $scopes = [];
protected string $scopeSeparator = ',';
protected string $scopeSeparator = ',';
protected GuzzleClient $httpClient;
protected array $guzzleOptions = [];
protected array $guzzleOptions = [];
protected int $encodingType = PHP_QUERY_RFC1738;
protected int $encodingType = PHP_QUERY_RFC1738;
protected string $expiresInKey = Contracts\RFC6749_ABNF_EXPIRES_IN;
protected string $expiresInKey = Contracts\RFC6749_ABNF_EXPIRES_IN;
protected string $accessTokenKey = Contracts\RFC6749_ABNF_ACCESS_TOKEN;
protected string $accessTokenKey = Contracts\RFC6749_ABNF_ACCESS_TOKEN;
protected string $refreshTokenKey = Contracts\RFC6749_ABNF_REFRESH_TOKEN;
protected string $refreshTokenKey = Contracts\RFC6749_ABNF_REFRESH_TOKEN;
public function __construct(array $config)
{
@ -53,7 +53,7 @@ abstract class Base implements Contracts\ProviderInterface
// normalize Contracts\RFC6749_ABNF_CLIENT_ID
if (! $this->config->has(Contracts\RFC6749_ABNF_CLIENT_ID)) {
$id = $this->config->get(Contracts\ABNF_APP_ID);
if (null != $id) {
if ($id != null) {
$this->config->set(Contracts\RFC6749_ABNF_CLIENT_ID, $id);
}
}
@ -61,7 +61,7 @@ abstract class Base implements Contracts\ProviderInterface
// normalize Contracts\RFC6749_ABNF_CLIENT_SECRET
if (! $this->config->has(Contracts\RFC6749_ABNF_CLIENT_SECRET)) {
$secret = $this->config->get(Contracts\ABNF_APP_SECRET);
if (null != $secret) {
if ($secret != null) {
$this->config->set(Contracts\RFC6749_ABNF_CLIENT_SECRET, $secret);
}
}

2
vendor/overtrue/socialite/src/Providers/Coding.php vendored Executable file → Normal file
View File

@ -11,7 +11,7 @@ use Overtrue\Socialite\User;
class Coding extends Base
{
public const NAME = 'coding';
public const NAME = 'coding';
// example: https://{your-team}.coding.net
protected string $teamUrl;

0
vendor/overtrue/socialite/src/Providers/DingTalk.php vendored Executable file → Normal file
View File

0
vendor/overtrue/socialite/src/Providers/DouYin.php vendored Executable file → Normal file
View File

1
vendor/overtrue/socialite/src/Providers/Douban.php vendored Executable file → Normal file
View File

@ -25,7 +25,6 @@ class Douban extends Base
}
/**
* @param string $token
* @param ?array $query
*/
protected function getUserByToken(string $token, ?array $query = []): array

4
vendor/overtrue/socialite/src/Providers/Facebook.php vendored Executable file → Normal file
View File

@ -17,9 +17,9 @@ class Facebook extends Base
protected string $version = 'v3.3';
protected array $fields = ['first_name', 'last_name', 'email', 'gender', 'verified'];
protected array $fields = ['first_name', 'last_name', 'email', 'gender', 'verified', 'picture'];
protected array $scopes = ['email'];
protected array $scopes = [];
protected bool $popup = false;

2
vendor/overtrue/socialite/src/Providers/FeiShu.php vendored Executable file → Normal file
View File

@ -21,7 +21,7 @@ class FeiShu extends Base
protected string $expiresInKey = 'refresh_expires_in';
protected bool $isInternalApp = false;
protected bool $isInternalApp = false;
public function __construct(array $config)
{

0
vendor/overtrue/socialite/src/Providers/Figma.php vendored Executable file → Normal file
View File

4
vendor/overtrue/socialite/src/Providers/GitHub.php vendored Executable file → Normal file
View File

@ -9,9 +9,9 @@ use Overtrue\Socialite\User;
class GitHub extends Base
{
public const NAME = 'github';
public const NAME = 'github';
protected array $scopes = ['read:user'];
protected array $scopes = ['read:user'];
protected string $scopeSeparator = ' ';

0
vendor/overtrue/socialite/src/Providers/Gitee.php vendored Executable file → Normal file
View File

0
vendor/overtrue/socialite/src/Providers/Google.php vendored Executable file → Normal file
View File

0
vendor/overtrue/socialite/src/Providers/Lark.php vendored Executable file → Normal file
View File

0
vendor/overtrue/socialite/src/Providers/Line.php vendored Executable file → Normal file
View File

8
vendor/overtrue/socialite/src/Providers/Linkedin.php vendored Executable file → Normal file
View File

@ -51,7 +51,7 @@ class Linkedin extends Base
$response = $this->getHttpClient()->get($url, [
'headers' => [
'Authorization' => 'Bearer ' . $token,
'Authorization' => 'Bearer '.$token,
'X-RestLi-Protocol-Version' => '2.0.0',
],
]);
@ -65,7 +65,7 @@ class Linkedin extends Base
$response = $this->getHttpClient()->get($url, [
'headers' => [
'Authorization' => 'Bearer ' . $token,
'Authorization' => 'Bearer '.$token,
'X-RestLi-Protocol-Version' => '2.0.0',
],
]);
@ -75,11 +75,11 @@ class Linkedin extends Base
protected function mapUserToObject(array $user): Contracts\UserInterface
{
$preferredLocale = ($user['firstName']['preferredLocale']['language'] ?? null) . '_' .
$preferredLocale = ($user['firstName']['preferredLocale']['language'] ?? null).'_'.
($user['firstName']['preferredLocale']['country'] ?? null);
$firstName = $user['firstName']['localized'][$preferredLocale] ?? null;
$lastName = $user['lastName']['localized'][$preferredLocale] ?? null;
$name = $firstName . ' ' . $lastName;
$name = $firstName.' '.$lastName;
$images = $user['profilePicture']['displayImage~']['elements'] ?? [];
$avatars = \array_filter($images, static fn ($image) => ($image['data']['com.linkedin.digitalmedia.mediaartifact.StillImage']['storageSize']['width'] ?? 0) === 100);

0
vendor/overtrue/socialite/src/Providers/OpenWeWork.php vendored Executable file → Normal file
View File

0
vendor/overtrue/socialite/src/Providers/Outlook.php vendored Executable file → Normal file
View File

View File

@ -0,0 +1,150 @@
<?php
namespace Overtrue\Socialite\Providers;
use JetBrains\PhpStorm\Pure;
use Overtrue\Socialite\Contracts;
use Overtrue\Socialite\User;
/**
* Class PayPal
*
* @author zhiqiang
*
* @see https://developer.paypal.com/docs/log-in-with-paypal/
*/
class PayPal extends Base
{
public const NAME = 'paypal';
protected string $scopeSeparator = ' ';
/**
* @var string|null
* code or id_token
*/
protected ?string $responseType = Contracts\RFC6749_ABNF_CODE;
protected string $flowEntry = 'static';
protected string $authUrl = 'https://www.paypal.com/signin/authorize';
protected string $tokenURL = 'https://api-m.paypal.com/v1/oauth2/token';
protected string $userinfoURL = 'https://api.paypal.com/v1/identity/openidconnect/userinfo?schema=openid';
protected array $scopes = [
'openid', 'profile', 'email', 'address',
];
protected bool $sandbox = true;
public function __construct(array $config)
{
parent::__construct($config);
$this->sandbox = (bool)$this->config->get('sandbox', false);
if ($this->sandbox) {
$this->authUrl = 'https://www.sandbox.paypal.com/signin/authorize';
$this->tokenURL = 'https://api-m.sandbox.paypal.com/v1/oauth2/token';
$this->userinfoURL = 'https://api-m.sandbox.paypal.com/v1/identity/openidconnect/userinfo?schema=openid';
}
}
/**
* @return $this
*
* @see https://developer.paypal.com/docs/log-in-with-paypal/integrate/generate-button/
*/
public function withResponseType(?string $responseType)
{
$this->responseType = $responseType;
return $this;
}
protected function getAuthUrl(): string
{
return $this->buildAuthUrlFromBase($this->authUrl);
}
protected function getCodeFields(): array
{
$fields = \array_merge(
[
'flowEntry' => $this->flowEntry,
Contracts\RFC6749_ABNF_CLIENT_ID => $this->getClientId(),
Contracts\RFC6749_ABNF_RESPONSE_TYPE => $this->responseType,
Contracts\RFC6749_ABNF_SCOPE => $this->formatScopes($this->scopes, $this->scopeSeparator),
Contracts\RFC6749_ABNF_REDIRECT_URI => $this->redirectUrl,
],
$this->parameters
);
if ($this->state) {
$fields[Contracts\RFC6749_ABNF_STATE] = $this->state;
}
return $fields;
}
protected function getTokenUrl(): string
{
return $this->tokenURL;
}
/**
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \Overtrue\Socialite\Exceptions\AuthorizeFailedException
*
* @see https://developer.paypal.com/docs/log-in-with-paypal/integrate/#link-getaccesstoken
*
*/
public function tokenFromCode(string $code): array
{
$response = $this->getHttpClient()->post(
$this->getTokenUrl(),
[
'form_params' => [
Contracts\RFC6749_ABNF_GRANT_TYPE => Contracts\RFC6749_ABNF_CLIENT_CREDENTIALS,
Contracts\RFC6749_ABNF_CODE => $code,
],
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Basic ' . \base64_encode(\sprintf('%s:%s', $this->getClientId(), $this->getClientSecret())),
],
]
);
return $this->normalizeAccessTokenResponse((string)$response->getBody());
}
/**
* @throws \GuzzleHttp\Exception\GuzzleException
*
* @see https://developer.paypal.com/docs/api/identity/v1/#userinfo_get
*/
protected function getUserByToken(string $token): array
{
$response = $this->getHttpClient()->get(
$this->userinfoURL,
[
'headers' => [
'Content-Type' => 'application/x-www-form-urlencoded',
'Authorization' => 'Bearer ' . $token,
],
]
);
return $this->fromJsonBody($response);
}
#[Pure]
protected function mapUserToObject(array $user): Contracts\UserInterface
{
$user[Contracts\ABNF_ID] = $user['user_id'] ?? null;
$user[Contracts\ABNF_NICKNAME] = $user['given_name'] ?? $user['family_name'] ?? $user['middle_name'] ?? null;
$user[Contracts\ABNF_NAME] = $user['name'] ?? '';
$user[Contracts\ABNF_EMAIL] = $user[Contracts\ABNF_EMAIL] ?? null;
$user[Contracts\ABNF_AVATAR] = $user['picture'] ?? null;
return new User($user);
}
}

0
vendor/overtrue/socialite/src/Providers/QCloud.php vendored Executable file → Normal file
View File

0
vendor/overtrue/socialite/src/Providers/QQ.php vendored Executable file → Normal file
View File

0
vendor/overtrue/socialite/src/Providers/Taobao.php vendored Executable file → Normal file
View File

0
vendor/overtrue/socialite/src/Providers/Tapd.php vendored Executable file → Normal file
View File

0
vendor/overtrue/socialite/src/Providers/TouTiao.php vendored Executable file → Normal file
View File

19
vendor/overtrue/socialite/src/Providers/WeChat.php vendored Executable file → Normal file
View File

@ -114,7 +114,7 @@ class WeChat extends Base
public function userFromCode(string $code): Contracts\UserInterface
{
if (\in_array('snsapi_base', $this->scopes)) {
return $this->mapUserToObject($this->fromJsonBody($this->getTokenFromCode($code)));
return $this->getSnsapiBaseUserFromCode($code);
}
$token = $this->tokenFromCode($code);
@ -128,6 +128,19 @@ class WeChat extends Base
->setTokenResponse($token);
}
protected function getSnsapiBaseUserFromCode(string $code): Contracts\UserInterface
{
$token = $this->fromJsonBody($this->getTokenFromCode($code));
$user = [
'openid' => $token['openid'],
];
if (isset($token['unionid'])) {
$user['unionid'] = $token['unionid'];
}
return $this->mapUserToObject($token)->setProvider($this)->setRaw($user)->setAccessToken($token[$this->accessTokenKey]);
}
protected function getUserByToken(string $token): array
{
$language = $this->withCountryCode ? null : (isset($this->parameters['lang']) ? $this->parameters['lang'] : 'zh_CN');
@ -205,11 +218,11 @@ class WeChat extends Base
}
}
if (2 !== \count($config)) {
if (\count($config) !== 2) {
throw new Exceptions\InvalidArgumentException('Please check your config arguments were available.');
}
if (1 === \count($this->scopes) && \in_array('snsapi_login', $this->scopes)) {
if (\count($this->scopes) === 1 && \in_array('snsapi_login', $this->scopes)) {
$this->scopes = ['snsapi_base'];
}

0
vendor/overtrue/socialite/src/Providers/WeWork.php vendored Executable file → Normal file
View File

0
vendor/overtrue/socialite/src/Providers/Weibo.php vendored Executable file → Normal file
View File

0
vendor/overtrue/socialite/src/Providers/XiGua.php vendored Executable file → Normal file
View File

1
vendor/overtrue/socialite/src/SocialiteManager.php vendored Executable file → Normal file
View File

@ -40,6 +40,7 @@ class SocialiteManager implements Contracts\FactoryInterface
Providers\WeWork::NAME => Providers\WeWork::class,
Providers\Weibo::NAME => Providers\Weibo::class,
Providers\XiGua::NAME => Providers\XiGua::class,
Providers\PayPal::NAME => Providers\PayPal::class,
];
#[Pure]

2
vendor/overtrue/socialite/src/Traits/HasAttributes.php vendored Executable file → Normal file
View File

@ -68,7 +68,7 @@ trait HasAttributes
{
$result = \json_encode($this->getAttributes(), JSON_UNESCAPED_UNICODE);
false === $result && throw new Exceptions\Exception('Cannot Processing this instance as JSON stringify.');
$result === false && throw new Exceptions\Exception('Cannot Processing this instance as JSON stringify.');
return $result;
}

0
vendor/overtrue/socialite/src/User.php vendored Executable file → Normal file
View File