@vizamodo/aws-sts-core 0.3.26 → 0.3.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/federation/login.js
CHANGED
|
@@ -15,10 +15,16 @@ export async function buildFederationLoginUrl(input) {
|
|
|
15
15
|
const encoded = encodeURIComponent(sessionJson);
|
|
16
16
|
const SigninToken = await getCachedOrFetch(cacheKey, async () => {
|
|
17
17
|
const tokenResp = await fetch(`https://signin.aws.amazon.com/federation?Action=getSigninToken&Session=${encoded}`);
|
|
18
|
+
if (!tokenResp.ok) {
|
|
19
|
+
// best-effort: skip cache, let caller retry upstream if needed
|
|
20
|
+
return "";
|
|
21
|
+
}
|
|
18
22
|
const json = await tokenResp.json();
|
|
19
|
-
const token = json
|
|
20
|
-
if (!token)
|
|
21
|
-
|
|
23
|
+
const token = json?.SigninToken;
|
|
24
|
+
if (!token) {
|
|
25
|
+
// best-effort: skip cache
|
|
26
|
+
return "";
|
|
27
|
+
}
|
|
22
28
|
// SigninToken TTL ~15 minutes (AWS behavior)
|
|
23
29
|
const SIGNIN_TOKEN_TTL_SEC = 15 * 60;
|
|
24
30
|
// derive effective TTL = min(tokenTTL, credentialTTL)
|
|
@@ -29,8 +35,11 @@ export async function buildFederationLoginUrl(input) {
|
|
|
29
35
|
return token;
|
|
30
36
|
}
|
|
31
37
|
return wrapResult(token, new Date(Date.now() + effectiveTtlSec * 1000).toISOString());
|
|
32
|
-
}, { ttlSec: 60 } //
|
|
38
|
+
}, { ttlSec: 60, forceRefresh: input.forceRefresh } // allow caller-controlled retry
|
|
33
39
|
);
|
|
40
|
+
if (!SigninToken) {
|
|
41
|
+
throw new Error("[federation] unable to obtain SigninToken");
|
|
42
|
+
}
|
|
34
43
|
const baseLogin = `https://signin.aws.amazon.com/federation?Action=login` +
|
|
35
44
|
`&Issuer=viza` +
|
|
36
45
|
`&SigninToken=${SigninToken}`;
|