Leaving this here as reference for @todo
-
make the parsedState data more predictable (order by path, redirect)
The intention of this is to avoid unpredictability in the value of the parsedState computed from...
const parsedState = String(Object.keys(state).map(key => key + ":" + state[key]).join("|"));
... the value is expected to look like path:[value]|redirect:[value], and be ordered by path first, the redirect next (in cases where redirect is present in state) in order to allow correct consumption in the github oauth callback handler
// src/pages/api/github/oauth/callback.js
const path = state.includes("path") && state.split("|")[0].split(":")[1];
const isRedirect = state.includes("redirect") ? state.split("|")[1].split(":")[1] : false;
...failure to adhere to this order will cause failure; the point of initialization where this order can be inputted in the wrong order is in the login page
// src/pages/login.astro
const authUrl = getAuthUrl({
path: searchParams.get("redirect"),
redirect: true
});
... in cases where the path isn't stated as first value on the getAuthUrl argument object before the redirect; this will cause the error.
Originally posted by @babblebey in https://github.com/babblebey/jargons.dev/pull/8#discussion_r1545383948
Leaving this here as reference for
@todomake the
parsedStatedata more predictable (order by path, redirect)The intention of this is to avoid unpredictability in the value of the
parsedStatecomputed from...... the value is expected to look like
path:[value]|redirect:[value], and be ordered bypathfirst, theredirectnext (in cases whereredirectis present in state) in order to allow correct consumption in the github oauth callback handler...failure to adhere to this order will cause failure; the point of initialization where this order can be inputted in the wrong order is in the
loginpage... in cases where the
pathisn't stated as first value on thegetAuthUrlargument object before theredirect; this will cause the error.Originally posted by @babblebey in https://github.com/babblebey/jargons.dev/pull/8#discussion_r1545383948