From bf9f20f692ea5c90af2cc94b722ac6e0cdc0d5af Mon Sep 17 00:00:00 2001 From: Daniel Hougaard Date: Mon, 23 Sep 2024 23:14:26 +0400 Subject: [PATCH] Update util.ts --- src/custom/util.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/custom/util.ts b/src/custom/util.ts index 77bd8c5..967e316 100644 --- a/src/custom/util.ts +++ b/src/custom/util.ts @@ -34,11 +34,20 @@ export const getAwsRegion = async () => { export const performAwsIamLogin = async (baseUrl: string, identityId: string, region: string) => { const body = "Action=GetCallerIdentity&Version=2011-06-15"; - AWS.config.update({ - region: region + const creds = await new Promise<{ sessionToken?: string; accessKeyId: string; secretAccessKey: string }>((resolve, reject) => { + AWS.config.getCredentials((err, res) => { + if (err) { + throw err; + } else { + if (!res) { + throw new Error("Credentials not found"); + } + return resolve(res); + } + }); }); - console.log("creds", AWS.config.credentials); + console.log("creds", creds); const signOpts = aws4.sign( { @@ -47,8 +56,8 @@ export const performAwsIamLogin = async (baseUrl: string, identityId: string, re region }, { - accessKeyId: AWS.config.credentials?.accessKeyId, - secretAccessKey: AWS.config.credentials?.secretAccessKey + accessKeyId: creds.accessKeyId, + secretAccessKey: creds.secretAccessKey } );