refactor: flatten src/AKSRT → src (drop theme-identifier dir)

Move all domain folders from src/AKSRT/{Domain} to src/{Domain}; remap
Composer PSR-4 "AKSRT\\": "src/"; update audit script + README + ADR
paths; remove dead tools/build-psr4-map.php (scanned deleted inc/classes).
This commit is contained in:
kate522 committed 2026-08-02 22:06:06 +08:00
1 parent 56f1a8175f
commit 8c5b1555c9
285 files changed
+26 -3600

No files matched your search

+106
View File
@@ -0,0 +1,106 @@
<?php
/**
* CaiHong / rainbow aggregate OAuth client (zibll clogin parity).
*
* @package AKSRT
*/
namespace AKSRT\Auth;
defined('ABSPATH') || exit;
class CLoginClient {
private string $apiurl;
private string $appid;
private string $appkey;
private string $callback;
public string $state = '';
/**
* @param array{apiurl:string,appid:string,appkey:string,callback?:string} $config
*/
public function __construct(array $config) {
$this->apiurl = rtrim((string) ($config['apiurl'] ?? ''), '/') . '/connect.php';
$this->appid = (string) ($config['appid'] ?? '');
$this->appkey = (string) ($config['appkey'] ?? '');
$this->callback = (string) ($config['callback'] ?? '');
}
/**
* @return array<string,mixed>
*/
public function login(string $type): array {
$this->state = md5(uniqid((string) wp_rand(), true));
$params = [
'act' => 'login',
'appid' => $this->appid,
'appkey' => $this->appkey,
'type' => $this->to_api_type($type),
'redirect_uri' => $this->callback,
'state' => $this->state,
];
return $this->request($params);
}
/**
* @return array<string,mixed>
*/
public function callback(string $code): array {
return $this->request([
'act' => 'callback',
'appid' => $this->appid,
'appkey' => $this->appkey,
'code' => $code,
]);
}
public function to_api_type(string $type): string {
switch (sanitize_key($type)) {
case 'weixin':
case 'wechat':
return 'wx';
case 'weibo':
return 'sina';
default:
return sanitize_key($type);
}
}
public function from_api_type(string $type): string {
switch (sanitize_key($type)) {
case 'wx':
return 'weixin';
case 'sina':
return 'weibo';
default:
return sanitize_key($type);
}
}
/**
* @param array<string,string> $params
* @return array<string,mixed>
*/
private function request(array $params): array {
$url = $this->apiurl . '?' . http_build_query($params);
$response = wp_remote_get($url, [
'timeout' => 15,
'headers' => [
'User-Agent' => 'AKSRT-CLogin/1.0',
],
]);
if (is_wp_error($response)) {
return [
'code' => 1,
'msg' => $response->get_error_message(),
];
}
$body = (string) wp_remote_retrieve_body($response);
$data = json_decode($body, true);
return is_array($data) ? $data : [
'code' => 1,
'msg' => __('聚合登录接口返回异常', 'aksrt'),
];
}
}