@@ -11,7 +11,7 @@ export function findProvider(
1111export const githubAuth = {
1212 url : ( clientId : string , state ?: string , redirectUri ?: string ) =>
1313 `https://github.com/login/oauth/authorize?client_id=${ clientId } &scope=read:user${
14- state ? `&state=${ state } ` : ''
14+ state ? `&state=${ encodeURIComponent ( state ) } ` : ''
1515 } ${ redirectUri ? `&redirect_uri=${ encodeURIComponent ( redirectUri ) } ` : '' } `,
1616 user : async ( accessToken : string ) => {
1717 const res = await fetch ( 'https://api.github.com/user' , {
@@ -29,7 +29,7 @@ export const discordAuth = {
2929 url : ( clientId : string , origin : string , state ?: string , redirectUri ?: string ) =>
3030 `https://discord.com/api/oauth2/authorize?client_id=${ clientId } &redirect_uri=${ encodeURIComponent (
3131 redirectUri ?? `${ origin } /api/auth/oauth/discord` ,
32- ) } &response_type=code&scope=identify${ state ? `&state=${ state } ` : '' } `,
32+ ) } &response_type=code&scope=identify${ state ? `&state=${ encodeURIComponent ( state ) } ` : '' } `,
3333 user : async ( accessToken : string ) => {
3434 const res = await fetch ( 'https://discord.com/api/users/@me' , {
3535 headers : {
@@ -47,7 +47,7 @@ export const googleAuth = {
4747 `https://accounts.google.com/o/oauth2/auth?client_id=${ clientId } &redirect_uri=${ encodeURIComponent (
4848 redirectUri ?? `${ origin } /api/auth/oauth/google` ,
4949 ) } &response_type=code&access_type=offline&scope=https://www.googleapis.com/auth/userinfo.profile${
50- state ? `&state=${ state } ` : ''
50+ state ? `&state=${ encodeURIComponent ( state ) } ` : ''
5151 } `,
5252 user : async ( accessToken : string ) => {
5353 const res = await fetch ( 'https://www.googleapis.com/oauth2/v1/userinfo?alt=json' , {
@@ -65,7 +65,7 @@ export const oidcAuth = {
6565 url : ( clientId : string , origin : string , authorizeUrl : string , state ?: string , redirectUri ?: string ) =>
6666 `${ authorizeUrl } ?client_id=${ clientId } &redirect_uri=${ encodeURIComponent (
6767 redirectUri ?? `${ origin } /api/auth/oauth/oidc` ,
68- ) } &response_type=code&scope=openid+email+profile+offline_access${ state ? `&state=${ state } ` : '' } `,
68+ ) } &response_type=code&scope=openid+email+profile+offline_access${ state ? `&state=${ encodeURIComponent ( state ) } ` : '' } `,
6969 user : async ( accessToken : string , userInfoUrl : string ) => {
7070 const res = await fetch ( userInfoUrl , {
7171 headers : {
0 commit comments