ag-awsauth 0.0.281 → 0.0.285
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/bin/awsauth.js +0 -0
- package/dist/helpers/awsconfig.d.ts +2 -0
- package/dist/helpers/awsconfig.js +14 -1
- package/dist/helpers/browser.js +1 -1
- package/dist/helpers/sso.d.ts +1 -0
- package/dist/helpers/sso.js +10 -1
- package/dist/index.js +4 -1
- package/dist/types.d.ts +1 -0
- package/package.json +18 -18
package/bin/awsauth.js
CHANGED
|
File without changes
|
|
@@ -1,3 +1,5 @@
|
|
|
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.updateAwsCredentials = exports.getAwsCredentials = void 0;
|
|
15
|
+
exports.setLastSite = exports.getLastSite = 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,3 +50,16 @@ 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;
|
package/dist/helpers/browser.js
CHANGED
|
@@ -128,7 +128,7 @@ function getMFA(p) {
|
|
|
128
128
|
}
|
|
129
129
|
catch (e) {
|
|
130
130
|
const em = e.toString();
|
|
131
|
-
if (!em.includes('exceeded')) {
|
|
131
|
+
if (!em.includes('exceeded') && !em.includes('Waiting for selector')) {
|
|
132
132
|
const em2 = `creds error:` + em;
|
|
133
133
|
(0, log_1.error)(em2);
|
|
134
134
|
throw new Error(em2);
|
package/dist/helpers/sso.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare const getOIDCCredentialsFromAccessToken: (p: {
|
|
|
12
12
|
}) => Promise<IAwsCreds>;
|
|
13
13
|
export declare function appInstances(p: {
|
|
14
14
|
ssoAuthn: string;
|
|
15
|
+
lastSite?: string;
|
|
15
16
|
}): Promise<IAppInstance[]>;
|
|
16
17
|
export declare function getSamlAssertion(p: IAwsCreds, instance: IAppInstance): Promise<{
|
|
17
18
|
samlAssertion: string;
|
package/dist/helpers/sso.js
CHANGED
|
@@ -72,7 +72,16 @@ function appInstances(p) {
|
|
|
72
72
|
if (!ai.result) {
|
|
73
73
|
throw new Error('appinstance error' + JSON.stringify(ai, null, 2));
|
|
74
74
|
}
|
|
75
|
-
|
|
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;
|
|
76
85
|
});
|
|
77
86
|
}
|
|
78
87
|
function getSamlAssertion(p, instance) {
|
package/dist/index.js
CHANGED
|
@@ -80,8 +80,11 @@ 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
|
|
83
|
+
const lastSite = yield (0, awsconfig_1.getLastSite)();
|
|
84
|
+
const instances = yield (0, sso_1.appInstances)(Object.assign(Object.assign({}, credentials), { lastSite }));
|
|
84
85
|
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);
|
|
85
88
|
let debugRole = '';
|
|
86
89
|
if (instance.searchMetadata) {
|
|
87
90
|
(0, log_1.info)('account is native aws, directly connecting');
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -5,14 +5,8 @@
|
|
|
5
5
|
"author": "andreigec@hotmail.com",
|
|
6
6
|
"license": "ISC",
|
|
7
7
|
"private": false,
|
|
8
|
-
"version": "0.0.
|
|
8
|
+
"version": "0.0.285",
|
|
9
9
|
"preferGlobal": true,
|
|
10
|
-
"scripts": {
|
|
11
|
-
"lint": "next lint",
|
|
12
|
-
"format": "eslint src --fix",
|
|
13
|
-
"start": "tsc && node bin/awsauth.js",
|
|
14
|
-
"build": "tsc"
|
|
15
|
-
},
|
|
16
10
|
"bin": {
|
|
17
11
|
"ag-awsauth": "./bin/awsauth.js"
|
|
18
12
|
},
|
|
@@ -23,28 +17,28 @@
|
|
|
23
17
|
"LICENSE.md"
|
|
24
18
|
],
|
|
25
19
|
"dependencies": {
|
|
26
|
-
"@aws-sdk/client-sso": "3.
|
|
27
|
-
"@aws-sdk/client-sso-oidc": "3.
|
|
28
|
-
"@aws-sdk/client-sts": "3.
|
|
20
|
+
"@aws-sdk/client-sso": "3.972.0",
|
|
21
|
+
"@aws-sdk/client-sso-oidc": "3.972.0",
|
|
22
|
+
"@aws-sdk/client-sts": "3.972.0",
|
|
29
23
|
"@aws-sdk/shared-ini-file-loader": "3.374.0",
|
|
30
|
-
"ag-common": "0.0.
|
|
24
|
+
"ag-common": "0.0.861",
|
|
31
25
|
"cli-select": "1.1.2",
|
|
32
|
-
"dotenv": "17.2.
|
|
26
|
+
"dotenv": "17.2.3",
|
|
33
27
|
"envfile": "7.1.0",
|
|
34
|
-
"eslint-config-e7npm": "0.1.
|
|
28
|
+
"eslint-config-e7npm": "0.1.31",
|
|
35
29
|
"ini": "5.0.0",
|
|
36
30
|
"node-fetch": "3.3.2",
|
|
37
|
-
"puppeteer": "24.
|
|
31
|
+
"puppeteer": "24.35.0",
|
|
38
32
|
"readline-sync": "1.4.10",
|
|
39
|
-
"typescript": "5.9.
|
|
33
|
+
"typescript": "5.9.3",
|
|
40
34
|
"yargs": "18.0.0"
|
|
41
35
|
},
|
|
42
36
|
"devDependencies": {
|
|
43
37
|
"@types/ini": "4.1.1",
|
|
44
|
-
"@types/node": "24.
|
|
38
|
+
"@types/node": "24.10.9",
|
|
45
39
|
"@types/node-fetch": "2.6.13",
|
|
46
40
|
"@types/readline-sync": "1.4.8",
|
|
47
|
-
"@types/yargs": "17.0.
|
|
41
|
+
"@types/yargs": "17.0.35"
|
|
48
42
|
},
|
|
49
43
|
"resolutions": {
|
|
50
44
|
"ws": ">=8.17.1"
|
|
@@ -54,5 +48,11 @@
|
|
|
54
48
|
"yarn": "use pnpm",
|
|
55
49
|
"npm": "use pnpm",
|
|
56
50
|
"pnpm": ">=8"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"lint": "eslint src",
|
|
54
|
+
"format": "eslint src --fix",
|
|
55
|
+
"start": "tsc && node bin/awsauth.js",
|
|
56
|
+
"build": "tsc"
|
|
57
57
|
}
|
|
58
|
-
}
|
|
58
|
+
}
|