Compare commits

...

3 Commits

Author SHA1 Message Date
Balázs Orbán
f8a7a48996 simplify 2023-01-28 10:43:29 +01:00
Balázs Orbán
357c4b124e simplify 2023-01-28 10:39:23 +01:00
dawidos234
91f20fcad0 Pass oauth_token_secret in OAuth 1.0 calls 2023-01-25 22:34:21 +01:00
3 changed files with 8 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
import { openidClient } from "./client"
import { oAuth1Client } from "./client-legacy"
import { oAuth1Client, oAuth1TokenStore } from "./client-legacy"
import { createState } from "./state-handler"
import { createNonce } from "./nonce-handler"
import { createPKCE } from "./pkce-handler"
@@ -44,7 +44,7 @@ export default async function getAuthorizationUrl({
oauth_token_secret: tokens.oauth_token_secret,
...tokens.params,
})}`
oAuth1TokenStore.set(tokens.oauth_token, tokens.oauth_token_secret)
logger.debug("GET_AUTHORIZATION_URL", { url, provider })
return { redirect: url }
}

View File

@@ -1,6 +1,6 @@
import { TokenSet } from "openid-client"
import { openidClient } from "./client"
import { oAuth1Client } from "./client-legacy"
import { oAuth1Client, oAuth1TokenStore } from "./client-legacy"
import { useState } from "./state-handler"
import { usePKCECodeVerifier } from "./pkce-handler"
import { useNonce } from "./nonce-handler"
@@ -42,7 +42,7 @@ export default async function oAuthCallback(params: {
const { oauth_token, oauth_verifier } = query ?? {}
const tokens = (await (client as any).getOAuthAccessToken(
oauth_token,
null,
oAuth1TokenStore.get(oauth_token),
oauth_verifier
)) as TokenSet
let profile: Profile = await (client as any).get(
@@ -63,6 +63,8 @@ export default async function oAuthCallback(params: {
}
}
if (query?.oauth_token) oAuth1TokenStore.delete(query.oauth_token)
try {
const client = await openidClient(options)

View File

@@ -69,3 +69,5 @@ export function oAuth1Client(options: InternalOptions<"oauth">) {
}
return oauth1Client
}
export const oAuth1TokenStore = new Map()