I don't want to talk about it.
This commit is contained in:
parent
ff9901cc8f
commit
7b2dc2daf0
2 changed files with 8 additions and 7 deletions
|
@ -37,12 +37,12 @@ export async function CreatePKCECodeChallenge(CodeVerifier) {
|
|||
}
|
||||
|
||||
// Component 3/4
|
||||
export async function PARrequest(PAREndpoint, State) {
|
||||
return fetch(PAREndpoint, {method: "POST", body: new URLSearchParams({ response_type: "code", code_challenge_method: "S256", scope: "atproto transition:generic", client_id: "https://fedi.crowdedgames.group/oauth/client-metadata.json", redirect_uri: "https://fedi.crowdedgames.group/HTML/setting.html", code_challenge: Cookie.BlueskyPKCEChallengeCookie, state: State, login_hint: "crowdedgames.group" }), headers: {"Content-Type": "application/x-www-form-urlencoded"}});
|
||||
export async function PARrequest(PAREndpoint, State, Challenge) {
|
||||
return fetch(PAREndpoint, {method: "POST", body: new URLSearchParams({ response_type: "code", code_challenge_method: "S256", scope: "atproto transition:generic", client_id: "https://fedi.crowdedgames.group/oauth/client-metadata.json", redirect_uri: "https://fedi.crowdedgames.group/HTML/setting.html", code_challenge: Challenge, state: State, login_hint: "crowdedgames.group" }), headers: {"Content-Type": "application/x-www-form-urlencoded"}});
|
||||
}
|
||||
|
||||
export async function AuthRequest(TokenEndpoint, code, DPoP) {
|
||||
return fetch(TokenEndpoint, {method: "POST", body: new URLSearchParams({ grant_type: "authorization_code", code: code, client_id: "https://fedi.crowdedgames.group/oauth/client-metadata.json", redirect_uri: "https://fedi.crowdedgames.group/HTML/setting.html", code_verifier: Cookie.BlueskyPKCEVeriferCookie}), headers: { "DPoP": DPoP, "Content-Type": "application/x-www-form-urlencoded"}})
|
||||
export async function AuthRequest(TokenEndpoint, code, DPoP, Verify) {
|
||||
return fetch(TokenEndpoint, {method: "POST", body: new URLSearchParams({ grant_type: "authorization_code", code: code, client_id: "https://fedi.crowdedgames.group/oauth/client-metadata.json", redirect_uri: "https://fedi.crowdedgames.group/HTML/setting.html", code_verifier: Verify}), headers: { "DPoP": DPoP, "Content-Type": "application/x-www-form-urlencoded"}})
|
||||
.then((response) => response.json());
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ export async function HandleAuthorization() {
|
|||
Cookie.InputCookie(Cookie.BlueskyPKCEVeriferName, PKCEverifier);
|
||||
Cookie.InputCookie(Cookie.BlueskyPKCEChallengeName, PKCEchallenge);
|
||||
// PAR request (beginning)
|
||||
let PAR = PARrequest(WellKnown.pushed_authorization_request_endpoint, State);
|
||||
let PAR = PARrequest(WellKnown.pushed_authorization_request_endpoint, State, PKCEchallenge);
|
||||
let body = await PAR.then((response) => response.json());
|
||||
let nonce = await PAR.then((response) => response.headers.get("dpop-nonce"));
|
||||
// Save nonce
|
||||
|
@ -155,7 +155,8 @@ export async function GainTokens() {
|
|||
let DPoP = await ClientDPoPToken("POST", WellKnown.token_endpoint);
|
||||
let code = document.location.href.split("code=")[1];
|
||||
// Authentication
|
||||
let Auth = await AuthRequest(WellKnown.token_endpoint, code, DPoP);
|
||||
let cookie = await Cookie.BlueskyPKCEVeriferCookie;
|
||||
let Auth = await AuthRequest(WellKnown.token_endpoint, code, DPoP, cookie);
|
||||
// Save the tokens and be done
|
||||
Cookie.InputCookie(Cookie.BlueskyAccessTokenName, Auth.access_token);
|
||||
Cookie.InputCookie(Cookie.BlueskyRefreshTokenName, Auth.refresh_token);
|
||||
|
|
|
@ -95,4 +95,4 @@ async function CheckLogin() {
|
|||
CheckLogin();
|
||||
|
||||
// TESTING!
|
||||
// BlueskyAPI.GetBlueskyDID(Cookie.BlueskyPDSName, "crowdedgames.group");
|
||||
BlueskyAPI.GetBlueskyDID(Cookie.BlueskyPDSName, "crowdedgames.group");
|
||||
|
|
Loading…
Add table
Reference in a new issue