Skip to content

Commit

Permalink
refactor(js): replace specific strings with QueryKey.* (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
IceHe authored Feb 9, 2022
1 parent 1b963b9 commit 5d950ea
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/js/src/consts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export enum QueryKey {
ErrorDescription = 'error_description',
GrantType = 'grant_type',
IdToken = 'id_token',
IdTokenHint = 'id_token_hint',
PostLogoutRedirectUri = 'post_logout_redirect_uri',
Prompt = 'prompt',
RedirectUri = 'redirect_uri',
Expand All @@ -25,4 +26,5 @@ export enum QueryKey {
ResponseType = 'response_type',
Scope = 'scope',
State = 'state',
Token = 'token',
}
7 changes: 5 additions & 2 deletions packages/js/src/core/revoke.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ContentType } from '../consts';
import { ContentType, QueryKey } from '../consts';
import { Requester } from '../utils';

export const revoke = async (
Expand All @@ -10,5 +10,8 @@ export const revoke = async (
requester<void>(revocationEndpoint, {
method: 'POST',
headers: ContentType.formUrlEncoded,
body: new URLSearchParams({ client_id: clientId, token }),
body: new URLSearchParams({
[QueryKey.ClientId]: clientId,
[QueryKey.Token]: token,
}),
});
2 changes: 1 addition & 1 deletion packages/js/src/core/sign-out.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const generateSignOutUri = ({
idToken,
postLogoutRedirectUri,
}: SignOutUriParameters) => {
const urlSearchParameters = new URLSearchParams({ id_token_hint: idToken });
const urlSearchParameters = new URLSearchParams({ [QueryKey.IdTokenHint]: idToken });

if (postLogoutRedirectUri) {
urlSearchParameters.append(QueryKey.PostLogoutRedirectUri, postLogoutRedirectUri);
Expand Down

0 comments on commit 5d950ea

Please sign in to comment.