@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.
@@ -5,6 +5,7 @@ export declare function buildFederationLoginUrl(input: {
5
5
  region: string;
6
6
  expiration: string;
7
7
  intent?: "console" | "billing" | "dynamodb" | "ssm";
8
+ forceRefresh?: boolean;
8
9
  }): Promise<{
9
10
  ok: true;
10
11
  loginUrl: string;
@@ -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.SigninToken;
20
- if (!token)
21
- throw new Error("federation_failed");
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 } // fallback only if expiration invalid
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}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizamodo/aws-sts-core",
3
- "version": "0.3.26",
3
+ "version": "0.3.28",
4
4
  "description": "Pure AWS STS + SigV4 (X509 Roles Anywhere) core logic",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",