Skip to content

Commit

Permalink
修复OpenWork中Authorization的错误引用 (#2584)
Browse files Browse the repository at this point in the history
* fix: 修复单元测试错误

* fix: 修复OpenWork中Authorization的错误引用

* style: fix style

Co-authored-by: karlfzwang <karlfzwang@tencent.com>
  • Loading branch information
wjfz and karlfzwang committed Aug 29, 2022
1 parent 74e8945 commit 9cc301d
Show file tree
Hide file tree
Showing 51 changed files with 65 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/Kernel/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
use EasyWeChat\Kernel\Support\Arr;
use JetBrains\PhpStorm\Pure;

use function join;
use function strval;

Expand Down
2 changes: 2 additions & 0 deletions src/Kernel/Encryptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use EasyWeChat\Kernel\Support\Xml;
use Exception;
use Throwable;

use function base64_decode;
use function base64_encode;
use function implode;
Expand All @@ -24,6 +25,7 @@
use function time;
use function trim;
use function unpack;

use const OPENSSL_NO_PADDING;
use const SORT_STRING;

Expand Down
2 changes: 2 additions & 0 deletions src/Kernel/Form/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
use EasyWeChat\Kernel\Exceptions\RuntimeException;
use Symfony\Component\Mime\MimeTypes;
use Symfony\Component\Mime\Part\DataPart;

use function file_put_contents;
use function md5;
use function pathinfo;
use function strtolower;
use function sys_get_temp_dir;
use function tempnam;

use const PATHINFO_EXTENSION;

class File extends DataPart
Expand Down
1 change: 1 addition & 0 deletions src/Kernel/HttpClient/AccessTokenAwareClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Symfony\Component\HttpClient\MockHttpClient;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;

use function array_merge;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Kernel/HttpClient/RequestUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
use Psr\Http\Message\ServerRequestInterface;
use Symfony\Component\HttpClient\Retry\GenericRetryStrategy;
use Symfony\Contracts\HttpClient\HttpClientInterface;

use function array_key_exists;
use function in_array;
use function is_array;
use function is_string;
use function json_encode;

use const ARRAY_FILTER_USE_KEY;
use const JSON_FORCE_OBJECT;
use const JSON_UNESCAPED_UNICODE;
Expand Down
1 change: 1 addition & 0 deletions src/Kernel/HttpClient/RequestWithPresets.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use EasyWeChat\Kernel\Form\File;
use EasyWeChat\Kernel\Form\Form;
use EasyWeChat\Kernel\Support\Str;

use function array_merge;
use function in_array;
use function is_file;
Expand Down
4 changes: 3 additions & 1 deletion src/Kernel/HttpClient/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\ResponseInterface;
use Throwable;

use function array_key_exists;
use function base64_encode;
use function file_put_contents;
Expand All @@ -32,6 +33,7 @@
use function str_contains;
use function str_starts_with;
use function strtolower;

use const JSON_UNESCAPED_UNICODE;

/**
Expand Down Expand Up @@ -186,7 +188,7 @@ public function toPsrResponse(ResponseFactoryInterface $responseFactory = null,
$responseFactory ??= $psr17Factory ?? Psr17FactoryDiscovery::findResponseFactory(); /** @phpstan-ignore-line */
$streamFactory ??= $psr17Factory ?? Psr17FactoryDiscovery::findStreamFactory(); /** @phpstan-ignore-line */

/** @phpstan-ignore-next-line */
/** @phpstan-ignore-next-line */
} catch (NotFoundException $e) {
throw new \LogicException('You cannot use the "Symfony\Component\HttpClient\HttplugClient" as no PSR-17 factories have been found. Try running "composer require nyholm/psr7".', 0, $e);
}
Expand Down
2 changes: 2 additions & 0 deletions src/Kernel/ServerResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
use JetBrains\PhpStorm\Pure;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;

use function array_keys;
use function array_map;
use function count;
use function header;
use function max;
use function sprintf;
use function ucwords;

use const PHP_OUTPUT_HANDLER_CLEANABLE;
use const PHP_OUTPUT_HANDLER_FLUSHABLE;
use const PHP_OUTPUT_HANDLER_REMOVABLE;
Expand Down
2 changes: 2 additions & 0 deletions src/Kernel/Support/AesCbc.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

use EasyWeChat\Kernel\Contracts\Aes;
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;

use function base64_decode;
use function openssl_decrypt;
use function openssl_error_string;

use const OPENSSL_RAW_DATA;

class AesCbc implements Aes
Expand Down
2 changes: 2 additions & 0 deletions src/Kernel/Support/AesEcb.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

use EasyWeChat\Kernel\Contracts\Aes;
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;

use function base64_decode;
use function openssl_decrypt;
use function openssl_error_string;

use const OPENSSL_RAW_DATA;

class AesEcb implements Aes
Expand Down
2 changes: 2 additions & 0 deletions src/Kernel/Support/AesGcm.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

use EasyWeChat\Kernel\Contracts\Aes;
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;

use function base64_decode;
use function base64_encode;
use function openssl_decrypt;
use function openssl_encrypt;
use function openssl_error_string;

use const OPENSSL_RAW_DATA;

class AesGcm implements Aes
Expand Down
1 change: 1 addition & 0 deletions src/Kernel/Support/Arr.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace EasyWeChat\Kernel\Support;

use JetBrains\PhpStorm\Pure;

use function is_string;

class Arr
Expand Down
1 change: 1 addition & 0 deletions src/Kernel/Support/PrivateKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace EasyWeChat\Kernel\Support;

use JetBrains\PhpStorm\Pure;

use function file_exists;
use function file_get_contents;
use function str_starts_with;
Expand Down
1 change: 1 addition & 0 deletions src/Kernel/Support/PublicKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace EasyWeChat\Kernel\Support;

use EasyWeChat\Kernel\Exceptions\InvalidConfigException;

use function file_exists;
use function file_get_contents;
use function openssl_x509_parse;
Expand Down
1 change: 1 addition & 0 deletions src/Kernel/Support/Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace EasyWeChat\Kernel\Support;

use Exception;

use function base64_encode;
use function preg_replace;
use function random_bytes;
Expand Down
1 change: 1 addition & 0 deletions src/Kernel/Support/UserAgent.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace EasyWeChat\Kernel\Support;

use Composer\InstalledVersions;

use function array_map;
use function array_unshift;
use function class_exists;
Expand Down
1 change: 1 addition & 0 deletions src/Kernel/Support/Xml.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use InvalidArgumentException;
use SimpleXMLElement;

use function is_object;

class Xml
Expand Down
1 change: 1 addition & 0 deletions src/Kernel/Traits/InteractWithConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use EasyWeChat\Kernel\Config;
use EasyWeChat\Kernel\Contracts\Config as ConfigInterface;
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;

use function is_array;

trait InteractWithConfig
Expand Down
1 change: 1 addition & 0 deletions src/Kernel/Traits/InteractWithHandlers.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Closure;
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
use JetBrains\PhpStorm\ArrayShape;

use function array_reverse;
use function array_unshift;
use function call_user_func;
Expand Down
1 change: 1 addition & 0 deletions src/Kernel/Traits/InteractWithHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Psr\Log\LoggerAwareInterface;
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Contracts\HttpClient\HttpClientInterface;

use function property_exists;

trait InteractWithHttpClient
Expand Down
1 change: 1 addition & 0 deletions src/Kernel/Traits/RespondXmlMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use EasyWeChat\Kernel\Support\Xml;
use Nyholm\Psr7\Response;
use Psr\Http\Message\ResponseInterface;

use function array_merge;
use function is_array;
use function is_callable;
Expand Down
1 change: 1 addition & 0 deletions src/MiniApp/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Psr\Log\LoggerAwareTrait;
use Symfony\Component\HttpClient\Response\AsyncContext;
use Symfony\Component\HttpClient\RetryableHttpClient;

use function array_merge;
use function is_null;
use function str_contains;
Expand Down
1 change: 1 addition & 0 deletions src/MiniApp/Decryptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use EasyWeChat\Kernel\Exceptions\DecryptException;
use EasyWeChat\Kernel\Support\AesCbc;
use Throwable;

use function base64_decode;
use function is_array;
use function json_decode;
Expand Down
1 change: 1 addition & 0 deletions src/OfficialAccount/AccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;

use function intval;
use function is_string;
use function json_encode;
Expand Down
1 change: 1 addition & 0 deletions src/OfficialAccount/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use Psr\Log\LoggerAwareTrait;
use Symfony\Component\HttpClient\Response\AsyncContext;
use Symfony\Component\HttpClient\RetryableHttpClient;

use function array_merge;
use function call_user_func;
use function sprintf;
Expand Down
1 change: 1 addition & 0 deletions src/OfficialAccount/JsApiTicket.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use EasyWeChat\Kernel\Exceptions\HttpException;
use JetBrains\PhpStorm\ArrayShape;

use function sprintf;

class JsApiTicket extends AccessToken
Expand Down
1 change: 1 addition & 0 deletions src/OfficialAccount/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;

use function time;

class Utils
Expand Down
1 change: 1 addition & 0 deletions src/OpenPlatform/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;

use function array_merge;
use function is_string;
use function md5;
Expand Down
2 changes: 1 addition & 1 deletion src/OpenPlatform/Authorization.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function getAppId(): string
public function getAccessToken(): AuthorizerAccessToken
{
return new AuthorizerAccessToken(
/** @phpstan-ignore-next-line */
/** @phpstan-ignore-next-line */
$this->attributes['authorization_info']['authorizer_appid'] ?? '',

/** @phpstan-ignore-next-line */
Expand Down
1 change: 1 addition & 0 deletions src/OpenPlatform/ComponentAccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Symfony\Component\Cache\Psr16Cache;
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Contracts\HttpClient\HttpClientInterface;

use function abs;
use function intval;
use function json_encode;
Expand Down
1 change: 1 addition & 0 deletions src/OpenPlatform/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Nyholm\Psr7\Response;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

use function func_get_args;

class Server implements ServerInterface
Expand Down
1 change: 1 addition & 0 deletions src/OpenPlatform/VerifyTicket.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Psr\SimpleCache\InvalidArgumentException;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Component\Cache\Psr16Cache;

use function is_string;
use function sprintf;

Expand Down
2 changes: 1 addition & 1 deletion src/OpenWork/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
use EasyWeChat\Kernel\Traits\InteractWithConfig;
use EasyWeChat\Kernel\Traits\InteractWithHttpClient;
use EasyWeChat\Kernel\Traits\InteractWithServerRequest;
use EasyWeChat\OpenPlatform\Authorization;
use EasyWeChat\OpenWork\Contracts\Account as AccountInterface;
use EasyWeChat\OpenWork\Contracts\Application as ApplicationInterface;
use EasyWeChat\OpenWork\Contracts\SuiteTicket as SuiteTicketInterface;
use Overtrue\Socialite\Contracts\ProviderInterface as SocialiteProviderInterface;
use Overtrue\Socialite\Providers\OpenWeWork;

use function array_merge;

class Application implements ApplicationInterface
Expand Down
2 changes: 2 additions & 0 deletions src/OpenWork/ProviderAccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
use Symfony\Component\Cache\Psr16Cache;
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Contracts\HttpClient\HttpClientInterface;

use function intval;

use const JSON_UNESCAPED_UNICODE;

class ProviderAccessToken implements RefreshableAccessTokenInterface
Expand Down
1 change: 1 addition & 0 deletions src/OpenWork/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Nyholm\Psr7\Response;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

use function func_get_args;

class Server implements ServerInterface
Expand Down
2 changes: 2 additions & 0 deletions src/OpenWork/SuiteAccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
use Symfony\Component\Cache\Psr16Cache;
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Contracts\HttpClient\HttpClientInterface;

use function abs;
use function intval;
use function json_encode;

use const JSON_UNESCAPED_UNICODE;

class SuiteAccessToken implements RefreshableAccessTokenInterface
Expand Down
1 change: 1 addition & 0 deletions src/OpenWork/SuiteTicket.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Psr\SimpleCache\InvalidArgumentException;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Component\Cache\Psr16Cache;

use function is_string;
use function sprintf;

Expand Down
1 change: 1 addition & 0 deletions src/Pay/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use Symfony\Contracts\HttpClient\ResponseInterface;

use function is_array;
use function is_string;
use function str_starts_with;
Expand Down
1 change: 1 addition & 0 deletions src/Pay/LegacySignature.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use EasyWeChat\Kernel\Exceptions\RuntimeException;
use EasyWeChat\Kernel\Support\Str;
use EasyWeChat\Pay\Contracts\Merchant as MerchantInterface;

use function call_user_func_array;
use function hash_hmac;
use function http_build_query;
Expand Down
1 change: 1 addition & 0 deletions src/Pay/Merchant.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use EasyWeChat\Kernel\Support\PrivateKey;
use EasyWeChat\Kernel\Support\PublicKey;
use EasyWeChat\Pay\Contracts\Merchant as MerchantInterface;

use function array_is_list;
use function intval;
use function is_string;
Expand Down

1 comment on commit 9cc301d

@vercel
Copy link

@vercel vercel bot commented on 9cc301d Aug 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

easywechat – ./

easywechat-git-6x-overtrue.vercel.app
easywechat-overtrue.vercel.app
easywechat.vercel.app

Please sign in to comment.