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

This commit is contained in:
Sadrinho27 2025-09-12 14:29:28 +02:00
parent a81662a697
commit abdc383ae1

View File

@ -5,20 +5,28 @@ dotenv.config();
export class IdNotService {
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 = {
client_id: process.env.IDNOT_CLIENT_ID,
client_secret: process.env.IDNOT_CLIENT_SECRET,
redirect_uri: process.env.IDNOT_REDIRECT_URI,
grant_type: 'authorization_code',
client_id: clientId,
client_secret: clientSecret,
redirect_uri: redirectUri,
grant_type: "authorization_code",
code: code
};
const tokens = await (
await fetch(process.env.IDNOT_TOKEN_URL, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
await fetch(tokenUrl, {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams(params).toString()
})
).json();