···
$http = new React\Http\Browser($connector);
183
+
$httpFactory = new HttpFactory();
$client = new GuzzleHttp\Client([
'User-Agent' => USER_AGENT_STR
189
-
$httpFactory = new HttpFactory();
$provider = new BskyProvider($options, $client, $httpFactory, $httpFactory, $httpFactory);
$name = $provider->getName();
192
+
$username = $_GET['username'];
193
+
$bskyToucher = new BskyToucher();
194
+
$userInfo = $bskyToucher->getUserInfo($username);
195
+
if (!$userInfo) die(1);
196
+
$pds = $userInfo->pds;
197
+
$provider->setPds($pds);
198
+
$jwt_header = base64_encode(json_encode([
202
+
$jwt_body = base64_encode(json_encode([
203
+
'iss' => $userInfo->did,
204
+
'sub' => 'https://'.SITE_DOMAIN.CLIENT_ID,
205
+
'aud' => 'did:web:'.str_replace("/", str_replace("https://", $pds)),
206
+
'jti' => hash('sha512', bin2hex(random_bytes(256 / 2))),
207
+
'iat' => strtotime('now')
209
+
$jwt = $jwt_header.$jwt_body.base64_encode(CERT);
210
+
$client->setDefaultOption('headers', [
211
+
'User-Agent' => USER_AGENT_STR,
212
+
'Authorization' => 'Bearer: '.$jwt
if (isset($_GET['login']) && $_GET['login'] === $name) {
193
-
$username = $_GET['username'];
194
-
$bskyToucher = new BskyToucher();
195
-
$userInfo = $bskyToucher->getUserInfo($username);
196
-
if (!$userInfo) die(1);
197
-
$pds = $userInfo->pds;
198
-
$provider->setPds($pds);
199
-
$authUrl = $provider->getAuthorizationUrl();
200
-
header('Location: '.$authUrl);
215
+
$auth_url = $provider->getAuthorizationUrl();
216
+
header('Location: '.$auth_url);
} else if (isset($_GET['code'], $_GET['state'])) {
$token = $provider->getAccessToken($_GET['code'], $_GET['state']);