friendship ended with social-app. php is my new best friend

jwts????

Changed files
+25 -9
+25 -9
index.php
···
'dns' => '1.1.1.1'
]);
$http = new React\Http\Browser($connector);
+
$httpFactory = new HttpFactory();
$client = new GuzzleHttp\Client([
'verify' => true,
'headers' => [
'User-Agent' => USER_AGENT_STR
]
]);
-
$httpFactory = new HttpFactory();
$provider = new BskyProvider($options, $client, $httpFactory, $httpFactory, $httpFactory);
$name = $provider->getName();
+
$username = $_GET['username'];
+
$bskyToucher = new BskyToucher();
+
$userInfo = $bskyToucher->getUserInfo($username);
+
if (!$userInfo) die(1);
+
$pds = $userInfo->pds;
+
$provider->setPds($pds);
+
$jwt_header = base64_encode(json_encode([
+
'alg' => 'ES256',
+
'typ' => 'JWT'
+
]));
+
$jwt_body = base64_encode(json_encode([
+
'iss' => $userInfo->did,
+
'sub' => 'https://'.SITE_DOMAIN.CLIENT_ID,
+
'aud' => 'did:web:'.str_replace("/", str_replace("https://", $pds)),
+
'jti' => hash('sha512', bin2hex(random_bytes(256 / 2))),
+
'iat' => strtotime('now')
+
]));
+
$jwt = $jwt_header.$jwt_body.base64_encode(CERT);
+
$client->setDefaultOption('headers', [
+
'User-Agent' => USER_AGENT_STR,
+
'Authorization' => 'Bearer: '.$jwt
+
]);
if (isset($_GET['login']) && $_GET['login'] === $name) {
-
$username = $_GET['username'];
-
$bskyToucher = new BskyToucher();
-
$userInfo = $bskyToucher->getUserInfo($username);
-
if (!$userInfo) die(1);
-
$pds = $userInfo->pds;
-
$provider->setPds($pds);
-
$authUrl = $provider->getAuthorizationUrl();
-
header('Location: '.$authUrl);
+
$auth_url = $provider->getAuthorizationUrl();
+
header('Location: '.$auth_url);
die(1);
} else if (isset($_GET['code'], $_GET['state'])) {
$token = $provider->getAccessToken($_GET['code'], $_GET['state']);