ag-awsauth 0.0.285 → 0.0.287

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.
@@ -1,5 +1,3 @@
1
1
  import type { IAwsCreds, IAwsCredsRaw } from '../types';
2
2
  export declare const getAwsCredentials: () => Promise<Record<string, IAwsCredsRaw>>;
3
3
  export declare const updateAwsCredentials: (p: IAwsCreds | undefined) => Promise<void>;
4
- export declare const getLastSite: () => Promise<string | undefined>;
5
- export declare const setLastSite: (siteName: string) => Promise<void>;
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.setLastSite = exports.getLastSite = exports.updateAwsCredentials = exports.getAwsCredentials = void 0;
15
+ exports.updateAwsCredentials = exports.getAwsCredentials = void 0;
16
16
  const shared_ini_file_loader_1 = require("@aws-sdk/shared-ini-file-loader");
17
17
  const log_1 = require("ag-common/dist/common/helpers/log");
18
18
  const fs_1 = __importDefault(require("fs"));
@@ -50,16 +50,3 @@ const updateAwsCredentials = (p) => __awaiter(void 0, void 0, void 0, function*
50
50
  fs_1.default.writeFileSync(credspath, newcreds);
51
51
  });
52
52
  exports.updateAwsCredentials = updateAwsCredentials;
53
- const getLastSite = () => __awaiter(void 0, void 0, void 0, function* () {
54
- const creds = yield (0, exports.getAwsCredentials)();
55
- return creds.default.last_site;
56
- });
57
- exports.getLastSite = getLastSite;
58
- const setLastSite = (siteName) => __awaiter(void 0, void 0, void 0, function* () {
59
- const creds = yield (0, exports.getAwsCredentials)();
60
- creds.default.last_site = siteName;
61
- const newcreds = (0, ini_1.stringify)(creds);
62
- const credspath = (0, getCredentialsFilepath_1.getCredentialsFilepath)();
63
- fs_1.default.writeFileSync(credspath, newcreds);
64
- });
65
- exports.setLastSite = setLastSite;
@@ -12,7 +12,6 @@ export declare const getOIDCCredentialsFromAccessToken: (p: {
12
12
  }) => Promise<IAwsCreds>;
13
13
  export declare function appInstances(p: {
14
14
  ssoAuthn: string;
15
- lastSite?: string;
16
15
  }): Promise<IAppInstance[]>;
17
16
  export declare function getSamlAssertion(p: IAwsCreds, instance: IAppInstance): Promise<{
18
17
  samlAssertion: string;
@@ -72,16 +72,7 @@ function appInstances(p) {
72
72
  if (!ai.result) {
73
73
  throw new Error('appinstance error' + JSON.stringify(ai, null, 2));
74
74
  }
75
- // Sort alphabetically first, then move last_site to top if it exists
76
- const sorted = ai.result.sort((a, b) => (a.name < b.name ? -1 : 1));
77
- if (p.lastSite) {
78
- const lastSiteIndex = sorted.findIndex((a) => a.name === p.lastSite);
79
- if (lastSiteIndex > 0) {
80
- const [lastSiteItem] = sorted.splice(lastSiteIndex, 1);
81
- sorted.unshift(lastSiteItem);
82
- }
83
- }
84
- return sorted;
75
+ return ai.result.sort((a, b) => (a.name < b.name ? -1 : 1));
85
76
  });
86
77
  }
87
78
  function getSamlAssertion(p, instance) {
package/dist/index.js CHANGED
@@ -80,11 +80,8 @@ function main(args) {
80
80
  (0, log_1.info)('save aws creds to file');
81
81
  yield (0, awsconfig_1.updateAwsCredentials)(credentials);
82
82
  (0, log_1.info)('get app instances and display');
83
- const lastSite = yield (0, awsconfig_1.getLastSite)();
84
- const instances = yield (0, sso_1.appInstances)(Object.assign(Object.assign({}, credentials), { lastSite }));
83
+ const instances = yield (0, sso_1.appInstances)(credentials);
85
84
  const instance = yield (0, input_1.chooseAppInstance)(instances, args);
86
- // Save the selected site as last_site for next run
87
- yield (0, awsconfig_1.setLastSite)(instance.name);
88
85
  let debugRole = '';
89
86
  if (instance.searchMetadata) {
90
87
  (0, log_1.info)('account is native aws, directly connecting');
package/dist/types.d.ts CHANGED
@@ -14,7 +14,6 @@ export interface IAwsCredsRaw {
14
14
  aws_access_token: string;
15
15
  aws_sso_authn: string;
16
16
  aws_application_id: string;
17
- last_site: string;
18
17
  }
19
18
  export interface IAppInstances {
20
19
  result: IAppInstance[];
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "author": "andreigec@hotmail.com",
6
6
  "license": "ISC",
7
7
  "private": false,
8
- "version": "0.0.285",
8
+ "version": "0.0.287",
9
9
  "preferGlobal": true,
10
10
  "bin": {
11
11
  "ag-awsauth": "./bin/awsauth.js"