@vizamodo/aws-sts-core 0.3.37 → 0.3.39
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 +7 -7
- package/package.json +1 -1
package/dist/federation/login.js
CHANGED
|
@@ -13,26 +13,26 @@ export async function buildFederationLoginUrl(input) {
|
|
|
13
13
|
const tokenHash = await sha256Hex(input.sessionToken);
|
|
14
14
|
console.debug("[signin] key input", {
|
|
15
15
|
accessKeyId: input.accessKeyId,
|
|
16
|
-
sessionKey: input.secretAccessKey,
|
|
17
16
|
tokenHash,
|
|
18
17
|
intent: input.intent,
|
|
19
18
|
region: input.region,
|
|
20
19
|
forceRefresh: input.forceRefresh
|
|
21
20
|
});
|
|
22
|
-
|
|
21
|
+
// TEMP DEBUG: force static key to verify cache behavior
|
|
22
|
+
const cacheKey = `aws-signin:test`;
|
|
23
23
|
const sessionJson = JSON.stringify(session);
|
|
24
24
|
const encoded = encodeURIComponent(sessionJson);
|
|
25
25
|
const SigninToken = await getCachedOrFetch(cacheKey, async () => {
|
|
26
26
|
const tokenResp = await fetch(`https://signin.aws.amazon.com/federation?Action=getSigninToken&Session=${encoded}`);
|
|
27
27
|
if (!tokenResp.ok) {
|
|
28
|
-
// best-effort:
|
|
29
|
-
|
|
28
|
+
// best-effort: do not cache failures
|
|
29
|
+
throw new Error("[signin] failed to fetch SigninToken");
|
|
30
30
|
}
|
|
31
31
|
const json = await tokenResp.json();
|
|
32
32
|
const token = json?.SigninToken;
|
|
33
33
|
if (!token) {
|
|
34
|
-
//
|
|
35
|
-
|
|
34
|
+
// do not cache invalid response
|
|
35
|
+
throw new Error("[signin] empty SigninToken");
|
|
36
36
|
}
|
|
37
37
|
// SigninToken TTL ~15 minutes (AWS behavior)
|
|
38
38
|
const SIGNIN_TOKEN_TTL_SEC = 15 * 60;
|
|
@@ -44,7 +44,7 @@ export async function buildFederationLoginUrl(input) {
|
|
|
44
44
|
return token;
|
|
45
45
|
}
|
|
46
46
|
return wrapResult(token, new Date(Date.now() + effectiveTtlSec * 1000).toISOString());
|
|
47
|
-
}, { ttlSec: 60, forceRefresh: input.forceRefresh } // allow caller-controlled retry
|
|
47
|
+
}, { ttlSec: 60, ...(input.forceRefresh !== undefined ? { forceRefresh: input.forceRefresh } : {}) } // allow caller-controlled retry
|
|
48
48
|
);
|
|
49
49
|
if (!SigninToken) {
|
|
50
50
|
throw new Error("[federation] unable to obtain SigninToken");
|