fix(idnot): ensure env variables are treated as strings for fetch and URLSearchParams
All checks were successful
Build and Push to Registry / build-and-push (push) Successful in 53s
All checks were successful
Build and Push to Registry / build-and-push (push) Successful in 53s
This commit is contained in:
parent
a81662a697
commit
abdc383ae1
@ -5,20 +5,28 @@ dotenv.config();
|
|||||||
|
|
||||||
export class IdNotService {
|
export class IdNotService {
|
||||||
static async exchangeCodeForTokens(code: string) {
|
static async exchangeCodeForTokens(code: string) {
|
||||||
|
|
||||||
|
const tokenUrl = process.env.IDNOT_TOKEN_URL;
|
||||||
|
const clientId = process.env.IDNOT_CLIENT_ID;
|
||||||
|
const clientSecret = process.env.IDNOT_CLIENT_SECRET;
|
||||||
|
const redirectUri = process.env.IDNOT_REDIRECT_URI;
|
||||||
|
|
||||||
|
if (!tokenUrl || !clientId || !clientSecret || !redirectUri) {
|
||||||
|
throw new Error("Missing required IDNOT environment variables");
|
||||||
|
}
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
client_id: process.env.IDNOT_CLIENT_ID,
|
client_id: clientId,
|
||||||
client_secret: process.env.IDNOT_CLIENT_SECRET,
|
client_secret: clientSecret,
|
||||||
redirect_uri: process.env.IDNOT_REDIRECT_URI,
|
redirect_uri: redirectUri,
|
||||||
grant_type: 'authorization_code',
|
grant_type: "authorization_code",
|
||||||
code: code
|
code: code
|
||||||
};
|
};
|
||||||
|
|
||||||
const tokens = await (
|
const tokens = await (
|
||||||
await fetch(process.env.IDNOT_TOKEN_URL, {
|
await fetch(tokenUrl, {
|
||||||
method: 'POST',
|
method: "POST",
|
||||||
headers: {
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
||||||
'Content-Type': 'application/x-www-form-urlencoded',
|
|
||||||
},
|
|
||||||
body: new URLSearchParams(params).toString()
|
body: new URLSearchParams(params).toString()
|
||||||
})
|
})
|
||||||
).json();
|
).json();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user