@vizamodo/aws-sts-core 0.2.10 → 0.2.15

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.
@@ -3,6 +3,7 @@ export declare function buildFederationLoginUrl(input: {
3
3
  secretAccessKey: string;
4
4
  sessionToken: string;
5
5
  region: string;
6
+ intent?: "console" | "billing" | "dynamodb";
6
7
  }): Promise<{
7
8
  loginUrl: string;
8
9
  shortUrl: string;
@@ -10,10 +10,28 @@ export async function buildFederationLoginUrl(input) {
10
10
  const { SigninToken } = await tokenResp.json();
11
11
  if (!SigninToken)
12
12
  throw new Error("federation_failed");
13
- const loginUrl = `https://signin.aws.amazon.com/federation?Action=login` +
13
+ const baseLogin = `https://signin.aws.amazon.com/federation?Action=login` +
14
14
  `&Issuer=viza` +
15
- `&Destination=https://console.aws.amazon.com/?region=${input.region}` +
16
15
  `&SigninToken=${SigninToken}`;
16
+ const intent = input.intent ?? "console";
17
+ let destinationUrl;
18
+ switch (intent) {
19
+ case "billing":
20
+ destinationUrl =
21
+ `https://us-east-1.console.aws.amazon.com/costmanagement/home?region=${input.region}#/home`;
22
+ break;
23
+ case "dynamodb":
24
+ destinationUrl =
25
+ `https://${input.region}.console.aws.amazon.com/dynamodbv2/home?region=${input.region}#dashboard`;
26
+ break;
27
+ case "console":
28
+ default:
29
+ destinationUrl =
30
+ `https://console.aws.amazon.com/?region=${input.region}`;
31
+ break;
32
+ }
33
+ const encodedDestination = encodeURIComponent(destinationUrl);
34
+ const loginUrl = `${baseLogin}&Destination=${encodedDestination}`;
17
35
  const shortUrl = loginUrl.slice(0, 40) + "..." +
18
36
  loginUrl.slice(-60);
19
37
  return {
package/dist/sts/issue.js CHANGED
@@ -154,15 +154,6 @@ export async function issueAwsCredentials(input) {
154
154
  }
155
155
  const json = await res.json();
156
156
  const creds = json?.credentialSet?.[0]?.credentials;
157
- console.log("[issueAwsCredentials][aws-response]", {
158
- raw: json,
159
- });
160
- console.log("[issueAwsCredentials][parsed-credentials]", {
161
- accessKeyId: creds?.accessKeyId,
162
- secretAccessKey: creds.secretAccessKey,
163
- sessionToken: creds.sessionToken,
164
- expiration: creds?.expiration,
165
- });
166
157
  return {
167
158
  accessKeyId: creds.accessKeyId,
168
159
  secretAccessKey: creds.secretAccessKey,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizamodo/aws-sts-core",
3
- "version": "0.2.10",
3
+ "version": "0.2.15",
4
4
  "description": "Pure AWS STS + SigV4 (X509 Roles Anywhere) core logic",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",