auth-backend: read and encode the entire state object in encodeState and readState
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -29,18 +29,14 @@ export const readState = (stateString: string): OAuthState => {
|
||||
) {
|
||||
throw Error(`Invalid state passed via request`);
|
||||
}
|
||||
return {
|
||||
nonce: state.nonce,
|
||||
env: state.env,
|
||||
};
|
||||
|
||||
return state as OAuthState;
|
||||
};
|
||||
|
||||
export const encodeState = (state: OAuthState): string => {
|
||||
const searchParams = new URLSearchParams();
|
||||
searchParams.append('nonce', state.nonce);
|
||||
searchParams.append('env', state.env);
|
||||
const stateString = new URLSearchParams(state).toString();
|
||||
|
||||
return Buffer.from(searchParams.toString(), 'utf-8').toString('hex');
|
||||
return Buffer.from(stateString, 'utf-8').toString('hex');
|
||||
};
|
||||
|
||||
export const verifyNonce = (req: express.Request, providerId: string) => {
|
||||
|
||||
Reference in New Issue
Block a user