@vizamodo/aws-sts-core 0.3.25 → 0.3.26

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.
@@ -21,7 +21,14 @@ export async function buildFederationLoginUrl(input) {
21
21
  throw new Error("federation_failed");
22
22
  // SigninToken TTL ~15 minutes (AWS behavior)
23
23
  const SIGNIN_TOKEN_TTL_SEC = 15 * 60;
24
- return wrapResult(token, new Date(Date.now() + SIGNIN_TOKEN_TTL_SEC * 1000).toISOString());
24
+ // derive effective TTL = min(tokenTTL, credentialTTL)
25
+ const credRemainingSec = Math.floor((Date.parse(input.expiration) - Date.now()) / 1000);
26
+ const effectiveTtlSec = Math.min(SIGNIN_TOKEN_TTL_SEC, credRemainingSec);
27
+ // if credential too close to expiry → skip caching
28
+ if (effectiveTtlSec <= 0) {
29
+ return token;
30
+ }
31
+ return wrapResult(token, new Date(Date.now() + effectiveTtlSec * 1000).toISOString());
25
32
  }, { ttlSec: 60 } // fallback only if expiration invalid
26
33
  );
27
34
  const baseLogin = `https://signin.aws.amazon.com/federation?Action=login` +
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizamodo/aws-sts-core",
3
- "version": "0.3.25",
3
+ "version": "0.3.26",
4
4
  "description": "Pure AWS STS + SigV4 (X509 Roles Anywhere) core logic",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",