@karmaniverous/get-dotenv 6.2.2 → 6.2.4
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/dist/chunks/AwsRestJsonProtocol-Bq1HE-Ln.mjs +932 -0
- package/dist/chunks/createCli-BY6_cfZr.mjs +439 -0
- package/dist/chunks/externalDataInterceptor-CbsdEYa-.mjs +19 -0
- package/dist/chunks/getSSOTokenFromFile-hUSpR7Wf.mjs +22 -0
- package/dist/chunks/helpConfig-CGejgwWW.mjs +12 -0
- package/dist/chunks/index-B5JKTBOL.mjs +443 -0
- package/dist/chunks/index-BEJFiHMX.mjs +522 -0
- package/dist/chunks/index-BPYF6K_G.mjs +82 -0
- package/dist/chunks/index-Bc3h0a95.mjs +374 -0
- package/dist/chunks/index-BpCF5UKx.mjs +272 -0
- package/dist/chunks/index-C_wqbTwI.mjs +187 -0
- package/dist/chunks/index-CeCufHlm.mjs +9374 -0
- package/dist/chunks/index-Cu7rdyqN.mjs +102 -0
- package/dist/chunks/index-DWAtHEA-.mjs +379 -0
- package/dist/chunks/index-Dp1Ip6Ra.mjs +354 -0
- package/dist/chunks/index-DyU5pKKi.mjs +24 -0
- package/dist/chunks/index-c7zKtEuy.mjs +578 -0
- package/dist/chunks/index-cIunyiUQ.mjs +702 -0
- package/dist/chunks/invoke-DuRPU1oC.mjs +60 -0
- package/dist/chunks/loadModuleDefault-Dj8B3Stt.mjs +123 -0
- package/dist/chunks/loadSso-w1eTVg0O.mjs +412 -0
- package/dist/chunks/loader-DnhPeGfq.mjs +346 -0
- package/dist/chunks/overlayEnv-Bs2kVayG.mjs +234 -0
- package/dist/chunks/package-boo9EyYs.mjs +5 -0
- package/dist/chunks/parseKnownFiles-B9cDK21V.mjs +23 -0
- package/dist/chunks/readMergedOptions-Nt0TR7dX.mjs +1626 -0
- package/dist/chunks/resolveCliOptions-TFRzhB2c.mjs +138 -0
- package/dist/chunks/sdk-stream-mixin-BZoJ5jy9.mjs +167 -0
- package/dist/chunks/spawnEnv-CN8a7cNR.mjs +306 -0
- package/dist/chunks/types-DJ-BGABd.mjs +59 -0
- package/dist/chunks/validate-CDl0rE6k.mjs +61 -0
- package/dist/cli.mjs +39 -19307
- package/dist/cliHost.mjs +20 -2800
- package/dist/config.mjs +10 -509
- package/dist/env-overlay.mjs +6 -337
- package/dist/getdotenv.cli.mjs +39 -19305
- package/dist/index.mjs +39 -19396
- package/dist/plugins-aws.d.ts +1 -4
- package/dist/plugins-aws.mjs +65 -2568
- package/dist/plugins-batch.mjs +16 -2573
- package/dist/plugins-cmd.mjs +19 -3094
- package/dist/plugins-init.d.ts +8 -0
- package/dist/plugins-init.mjs +85 -2297
- package/dist/plugins.mjs +36 -18817
- package/package.json +1 -2
- package/dist/templates/cli/index.ts +0 -25
- package/dist/templates/cli/plugins/hello/defaultAction.ts +0 -27
- package/dist/templates/cli/plugins/hello/index.ts +0 -26
- package/dist/templates/cli/plugins/hello/options.ts +0 -31
- package/dist/templates/cli/plugins/hello/strangerAction.ts +0 -20
- package/dist/templates/cli/plugins/hello/types.ts +0 -13
- package/dist/templates/config/js/getdotenv.config.js +0 -20
- package/dist/templates/config/json/local/getdotenv.config.local.json +0 -7
- package/dist/templates/config/json/public/getdotenv.config.json +0 -9
- package/dist/templates/config/public/getdotenv.config.json +0 -8
- package/dist/templates/config/ts/getdotenv.config.ts +0 -28
- package/dist/templates/config/yaml/local/getdotenv.config.local.yaml +0 -7
- package/dist/templates/config/yaml/public/getdotenv.config.yaml +0 -7
- package/dist/templates/defaultAction.ts +0 -27
- package/dist/templates/getdotenv.config.js +0 -20
- package/dist/templates/getdotenv.config.json +0 -9
- package/dist/templates/getdotenv.config.local.json +0 -7
- package/dist/templates/getdotenv.config.local.yaml +0 -7
- package/dist/templates/getdotenv.config.ts +0 -28
- package/dist/templates/getdotenv.config.yaml +0 -7
- package/dist/templates/hello/defaultAction.ts +0 -27
- package/dist/templates/hello/index.ts +0 -26
- package/dist/templates/hello/options.ts +0 -31
- package/dist/templates/hello/strangerAction.ts +0 -20
- package/dist/templates/hello/types.ts +0 -13
- package/dist/templates/index.ts +0 -26
- package/dist/templates/js/getdotenv.config.js +0 -20
- package/dist/templates/json/local/getdotenv.config.local.json +0 -7
- package/dist/templates/json/public/getdotenv.config.json +0 -9
- package/dist/templates/local/getdotenv.config.local.json +0 -7
- package/dist/templates/local/getdotenv.config.local.yaml +0 -7
- package/dist/templates/options.ts +0 -31
- package/dist/templates/plugins/hello/defaultAction.ts +0 -27
- package/dist/templates/plugins/hello/index.ts +0 -26
- package/dist/templates/plugins/hello/options.ts +0 -31
- package/dist/templates/plugins/hello/strangerAction.ts +0 -20
- package/dist/templates/plugins/hello/types.ts +0 -13
- package/dist/templates/public/getdotenv.config.json +0 -9
- package/dist/templates/public/getdotenv.config.yaml +0 -7
- package/dist/templates/strangerAction.ts +0 -20
- package/dist/templates/ts/getdotenv.config.ts +0 -28
- package/dist/templates/types.ts +0 -13
- package/dist/templates/yaml/local/getdotenv.config.local.yaml +0 -7
- package/dist/templates/yaml/public/getdotenv.config.yaml +0 -7
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compose a child-process env overlay from dotenv and the merged CLI options bag.
|
|
3
|
+
* Returns a shallow object including getDotenvCliOptions when serializable.
|
|
4
|
+
*
|
|
5
|
+
* @param merged - Resolved CLI options bag (or a JSON-serializable subset).
|
|
6
|
+
* @param dotenv - Composed dotenv variables for the current invocation.
|
|
7
|
+
* @returns A string-only env overlay suitable for child process spawning.
|
|
8
|
+
*/
|
|
9
|
+
function composeNestedEnv(merged, dotenv) {
|
|
10
|
+
const out = {};
|
|
11
|
+
for (const [k, v] of Object.entries(dotenv)) {
|
|
12
|
+
if (typeof v === 'string')
|
|
13
|
+
out[k] = v;
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
const { logger: _omit, ...bag } = merged;
|
|
17
|
+
const txt = JSON.stringify(bag);
|
|
18
|
+
if (typeof txt === 'string')
|
|
19
|
+
out.getDotenvCliOptions = txt;
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
/* best-effort only */
|
|
23
|
+
}
|
|
24
|
+
return out;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Strip one layer of symmetric outer quotes (single or double) from a string.
|
|
28
|
+
*
|
|
29
|
+
* @param s - Input string.
|
|
30
|
+
* @returns `s` without one symmetric outer quote pair (when present).
|
|
31
|
+
*/
|
|
32
|
+
const stripOne = (s) => {
|
|
33
|
+
if (s.length < 2)
|
|
34
|
+
return s;
|
|
35
|
+
const a = s.charAt(0);
|
|
36
|
+
const b = s.charAt(s.length - 1);
|
|
37
|
+
const symmetric = (a === '"' && b === '"') || (a === "'" && b === "'");
|
|
38
|
+
return symmetric ? s.slice(1, -1) : s;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Preserve argv array for Node -e/--eval payloads under shell-off and
|
|
42
|
+
* peel one symmetric outer quote layer from the code argument.
|
|
43
|
+
*
|
|
44
|
+
* @param args - Argument vector intended for direct execution (shell-off).
|
|
45
|
+
* @returns Either the original `args` or a modified copy with a normalized eval payload.
|
|
46
|
+
*/
|
|
47
|
+
function maybePreserveNodeEvalArgv(args) {
|
|
48
|
+
if (args.length >= 3) {
|
|
49
|
+
const first = (args[0] ?? '').toLowerCase();
|
|
50
|
+
const hasEval = args[1] === '-e' || args[1] === '--eval';
|
|
51
|
+
if (first === 'node' && hasEval) {
|
|
52
|
+
const copy = args.slice();
|
|
53
|
+
copy[2] = stripOne(copy[2] ?? '');
|
|
54
|
+
return copy;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return args;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export { composeNestedEnv as c, maybePreserveNodeEvalArgv as m, stripOne as s };
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { createHash } from 'crypto';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import url from 'url';
|
|
5
|
+
|
|
6
|
+
const importDefault = async (fileUrl) => {
|
|
7
|
+
const mod = (await import(fileUrl));
|
|
8
|
+
return mod.default;
|
|
9
|
+
};
|
|
10
|
+
const cacheHash = (absPath, mtimeMs) => createHash('sha1')
|
|
11
|
+
.update(absPath)
|
|
12
|
+
.update(String(mtimeMs))
|
|
13
|
+
.digest('hex')
|
|
14
|
+
.slice(0, 12);
|
|
15
|
+
/**
|
|
16
|
+
* Remove older compiled cache files for a given source base name, keeping
|
|
17
|
+
* at most `keep` most-recent files. Errors are ignored by design.
|
|
18
|
+
*/
|
|
19
|
+
const cleanupOldCacheFiles = async (cacheDir, baseName, keep = Math.max(1, Number.parseInt(process.env.GETDOTENV_CACHE_KEEP ?? '2'))) => {
|
|
20
|
+
try {
|
|
21
|
+
const entries = await fs.readdir(cacheDir);
|
|
22
|
+
const mine = entries
|
|
23
|
+
.filter((f) => f.startsWith(`${baseName}.`) && f.endsWith('.mjs'))
|
|
24
|
+
.map((f) => path.join(cacheDir, f));
|
|
25
|
+
if (mine.length <= keep)
|
|
26
|
+
return;
|
|
27
|
+
const stats = await Promise.all(mine.map(async (p) => ({ p, mtimeMs: (await fs.stat(p)).mtimeMs })));
|
|
28
|
+
stats.sort((a, b) => b.mtimeMs - a.mtimeMs);
|
|
29
|
+
const toDelete = stats.slice(keep).map((s) => s.p);
|
|
30
|
+
await Promise.all(toDelete.map(async (p) => {
|
|
31
|
+
try {
|
|
32
|
+
await fs.remove(p);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
// best-effort cleanup
|
|
36
|
+
}
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
// best-effort cleanup
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Load a module default export from a JS/TS file with robust fallbacks.
|
|
45
|
+
*
|
|
46
|
+
* Behavior by extension:
|
|
47
|
+
*
|
|
48
|
+
* - `.js`/`.mjs`/`.cjs`: direct dynamic import.
|
|
49
|
+
* - `.ts`/`.mts`/`.cts`/`.tsx`:
|
|
50
|
+
* - try direct dynamic import (when a TS loader is active),
|
|
51
|
+
* - else compile via `esbuild` to a cached `.mjs` file and import,
|
|
52
|
+
* - else fallback to `typescript.transpileModule` for simple modules.
|
|
53
|
+
*
|
|
54
|
+
* @typeParam T - Type of the expected default export.
|
|
55
|
+
* @param absPath - Absolute path to the source file.
|
|
56
|
+
* @param cacheDirName - Cache subfolder under `.tsbuild/`.
|
|
57
|
+
* @returns A `Promise\<T | undefined\>` resolving to the default export (if any).
|
|
58
|
+
*/
|
|
59
|
+
const loadModuleDefault = async (absPath, cacheDirName) => {
|
|
60
|
+
const ext = path.extname(absPath).toLowerCase();
|
|
61
|
+
const fileUrl = url.pathToFileURL(absPath).toString();
|
|
62
|
+
if (!['.ts', '.mts', '.cts', '.tsx'].includes(ext)) {
|
|
63
|
+
return importDefault(fileUrl);
|
|
64
|
+
}
|
|
65
|
+
// Try direct import first (TS loader active)
|
|
66
|
+
try {
|
|
67
|
+
const dyn = await importDefault(fileUrl);
|
|
68
|
+
if (dyn)
|
|
69
|
+
return dyn;
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
/* fall through */
|
|
73
|
+
}
|
|
74
|
+
const stat = await fs.stat(absPath);
|
|
75
|
+
const hash = cacheHash(absPath, stat.mtimeMs);
|
|
76
|
+
const cacheDir = path.resolve('.tsbuild', cacheDirName);
|
|
77
|
+
await fs.ensureDir(cacheDir);
|
|
78
|
+
const cacheFile = path.join(cacheDir, `${path.basename(absPath)}.${hash}.mjs`);
|
|
79
|
+
// Try esbuild
|
|
80
|
+
try {
|
|
81
|
+
const esbuild = (await import('esbuild'));
|
|
82
|
+
await esbuild.build({
|
|
83
|
+
entryPoints: [absPath],
|
|
84
|
+
bundle: true,
|
|
85
|
+
platform: 'node',
|
|
86
|
+
format: 'esm',
|
|
87
|
+
target: 'node20',
|
|
88
|
+
outfile: cacheFile,
|
|
89
|
+
sourcemap: false,
|
|
90
|
+
logLevel: 'silent',
|
|
91
|
+
});
|
|
92
|
+
const result = await importDefault(url.pathToFileURL(cacheFile).toString());
|
|
93
|
+
// Best-effort: trim older cache files for this source.
|
|
94
|
+
await cleanupOldCacheFiles(cacheDir, path.basename(absPath));
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
/* fall through to TS transpile */
|
|
99
|
+
}
|
|
100
|
+
// TypeScript transpile fallback
|
|
101
|
+
try {
|
|
102
|
+
const ts = (await import('typescript'));
|
|
103
|
+
const code = await fs.readFile(absPath, 'utf-8');
|
|
104
|
+
const out = ts.transpileModule(code, {
|
|
105
|
+
compilerOptions: {
|
|
106
|
+
module: 'ESNext',
|
|
107
|
+
target: 'ES2022',
|
|
108
|
+
moduleResolution: 'NodeNext',
|
|
109
|
+
},
|
|
110
|
+
}).outputText;
|
|
111
|
+
await fs.writeFile(cacheFile, out, 'utf-8');
|
|
112
|
+
const result = await importDefault(url.pathToFileURL(cacheFile).toString());
|
|
113
|
+
// Best-effort: trim older cache files for this source.
|
|
114
|
+
await cleanupOldCacheFiles(cacheDir, path.basename(absPath));
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
// Caller decides final error wording; rethrow for upstream mapping.
|
|
119
|
+
throw new Error(`Unable to load JS/TS module: ${absPath}. Install 'esbuild' or ensure a TS loader.`);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export { loadModuleDefault as l };
|
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
import { w as resolveAwsSdkSigV4Config, x as normalizeProvider, y as getSmithyContext, z as EndpointCache, A as resolveEndpoint, B as awsEndpointFunctions, D as customEndpointFunctions, t as toUtf8, i as fromUtf8, F as parseUrl, G as NoOpLogger, I as AwsSdkSigV4Signer, J as NoAuthSigner, n as toBase64, m as fromBase64, K as emitWarningIfUnsupportedVersion, L as resolveDefaultsModeConfig, M as emitWarningIfUnsupportedVersion$1, O as loadConfig, r as streamCollector, P as Hash, N as NodeHttpHandler, Q as createDefaultUserAgentProvider, R as calculateBodyLength, S as NODE_APP_ID_CONFIG_OPTIONS, T as NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS, U as NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS, V as NODE_RETRY_MODE_CONFIG_OPTIONS, W as DEFAULT_RETRY_MODE, X as NODE_REGION_CONFIG_FILE_OPTIONS, Y as NODE_REGION_CONFIG_OPTIONS, Z as NODE_MAX_ATTEMPT_CONFIG_OPTIONS, _ as NODE_AUTH_SCHEME_PREFERENCE_OPTIONS, $ as loadConfigsForDefaultMode, a0 as getAwsRegionExtensionConfiguration, a1 as getDefaultExtensionConfiguration, a2 as getHttpHandlerExtensionConfiguration, a3 as resolveAwsRegionExtensionConfiguration, a4 as resolveDefaultRuntimeConfig, a5 as resolveHttpHandlerRuntimeConfig, a6 as Client, a7 as resolveUserAgentConfig, a8 as resolveRetryConfig, a9 as resolveRegionConfig, aa as resolveEndpointConfig, ab as resolveHostHeaderConfig, ac as getSchemaSerdePlugin, ad as getUserAgentPlugin, ae as getRetryPlugin, af as getContentLengthPlugin, ag as getHostHeaderPlugin, ah as getLoggerPlugin, ai as getRecursionDetectionPlugin, aj as getHttpAuthSchemeEndpointRuleSetPlugin, ak as DefaultIdentityProviderConfig, al as getHttpSigningPlugin, am as ServiceException, an as TypeRegistry, ao as Command, ap as getEndpointPlugin } from './index-CeCufHlm.mjs';
|
|
2
|
+
import { A as AwsRestJsonProtocol } from './AwsRestJsonProtocol-Bq1HE-Ln.mjs';
|
|
3
|
+
import './readMergedOptions-Nt0TR7dX.mjs';
|
|
4
|
+
import 'zod';
|
|
5
|
+
import '@commander-js/extra-typings';
|
|
6
|
+
import './overlayEnv-Bs2kVayG.mjs';
|
|
7
|
+
import 'fs-extra';
|
|
8
|
+
import './loadModuleDefault-Dj8B3Stt.mjs';
|
|
9
|
+
import 'crypto';
|
|
10
|
+
import 'path';
|
|
11
|
+
import 'url';
|
|
12
|
+
import 'nanoid';
|
|
13
|
+
import 'dotenv';
|
|
14
|
+
import './loader-DnhPeGfq.mjs';
|
|
15
|
+
import 'package-directory';
|
|
16
|
+
import 'yaml';
|
|
17
|
+
import 'execa';
|
|
18
|
+
import 'buffer';
|
|
19
|
+
import 'os';
|
|
20
|
+
import 'node:fs/promises';
|
|
21
|
+
import 'http';
|
|
22
|
+
import 'https';
|
|
23
|
+
import 'stream';
|
|
24
|
+
import 'process';
|
|
25
|
+
import 'node:fs';
|
|
26
|
+
import './sdk-stream-mixin-BZoJ5jy9.mjs';
|
|
27
|
+
|
|
28
|
+
const defaultSSOHttpAuthSchemeParametersProvider = async (config, context, input) => {
|
|
29
|
+
return {
|
|
30
|
+
operation: getSmithyContext(context).operation,
|
|
31
|
+
region: (await normalizeProvider(config.region)()) ||
|
|
32
|
+
(() => {
|
|
33
|
+
throw new Error("expected `region` to be configured for `aws.auth#sigv4`");
|
|
34
|
+
})(),
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
function createAwsAuthSigv4HttpAuthOption(authParameters) {
|
|
38
|
+
return {
|
|
39
|
+
schemeId: "aws.auth#sigv4",
|
|
40
|
+
signingProperties: {
|
|
41
|
+
name: "awsssoportal",
|
|
42
|
+
region: authParameters.region,
|
|
43
|
+
},
|
|
44
|
+
propertiesExtractor: (config, context) => ({
|
|
45
|
+
signingProperties: {
|
|
46
|
+
config,
|
|
47
|
+
context,
|
|
48
|
+
},
|
|
49
|
+
}),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function createSmithyApiNoAuthHttpAuthOption(authParameters) {
|
|
53
|
+
return {
|
|
54
|
+
schemeId: "smithy.api#noAuth",
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const defaultSSOHttpAuthSchemeProvider = (authParameters) => {
|
|
58
|
+
const options = [];
|
|
59
|
+
switch (authParameters.operation) {
|
|
60
|
+
case "GetRoleCredentials": {
|
|
61
|
+
options.push(createSmithyApiNoAuthHttpAuthOption());
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
case "ListAccountRoles": {
|
|
65
|
+
options.push(createSmithyApiNoAuthHttpAuthOption());
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
case "ListAccounts": {
|
|
69
|
+
options.push(createSmithyApiNoAuthHttpAuthOption());
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
case "Logout": {
|
|
73
|
+
options.push(createSmithyApiNoAuthHttpAuthOption());
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
default: {
|
|
77
|
+
options.push(createAwsAuthSigv4HttpAuthOption(authParameters));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return options;
|
|
81
|
+
};
|
|
82
|
+
const resolveHttpAuthSchemeConfig = (config) => {
|
|
83
|
+
const config_0 = resolveAwsSdkSigV4Config(config);
|
|
84
|
+
return Object.assign(config_0, {
|
|
85
|
+
authSchemePreference: normalizeProvider(config.authSchemePreference ?? []),
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const resolveClientEndpointParameters = (options) => {
|
|
90
|
+
return Object.assign(options, {
|
|
91
|
+
useDualstackEndpoint: options.useDualstackEndpoint ?? false,
|
|
92
|
+
useFipsEndpoint: options.useFipsEndpoint ?? false,
|
|
93
|
+
defaultSigningName: "awsssoportal",
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
const commonParams = {
|
|
97
|
+
UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" },
|
|
98
|
+
Endpoint: { type: "builtInParams", name: "endpoint" },
|
|
99
|
+
Region: { type: "builtInParams", name: "region" },
|
|
100
|
+
UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" },
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
var version = "3.948.0";
|
|
104
|
+
var packageInfo = {
|
|
105
|
+
version: version};
|
|
106
|
+
|
|
107
|
+
const u = "required", v = "fn", w = "argv", x = "ref";
|
|
108
|
+
const a = true, b = "isSet", c = "booleanEquals", d = "error", e = "endpoint", f = "tree", g = "PartitionResult", h = "getAttr", i = { [u]: false, "type": "string" }, j = { [u]: true, "default": false, "type": "boolean" }, k = { [x]: "Endpoint" }, l = { [v]: c, [w]: [{ [x]: "UseFIPS" }, true] }, m = { [v]: c, [w]: [{ [x]: "UseDualStack" }, true] }, n = {}, o = { [v]: h, [w]: [{ [x]: g }, "supportsFIPS"] }, p = { [x]: g }, q = { [v]: c, [w]: [true, { [v]: h, [w]: [p, "supportsDualStack"] }] }, r = [l], s = [m], t = [{ [x]: "Region" }];
|
|
109
|
+
const _data = { parameters: { Region: i, UseDualStack: j, UseFIPS: j, Endpoint: i }, rules: [{ conditions: [{ [v]: b, [w]: [k] }], rules: [{ conditions: r, error: "Invalid Configuration: FIPS and custom endpoint are not supported", type: d }, { conditions: s, error: "Invalid Configuration: Dualstack and custom endpoint are not supported", type: d }, { endpoint: { url: k, properties: n, headers: n }, type: e }], type: f }, { conditions: [{ [v]: b, [w]: t }], rules: [{ conditions: [{ [v]: "aws.partition", [w]: t, assign: g }], rules: [{ conditions: [l, m], rules: [{ conditions: [{ [v]: c, [w]: [a, o] }, q], rules: [{ endpoint: { url: "https://portal.sso-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", properties: n, headers: n }, type: e }], type: f }, { error: "FIPS and DualStack are enabled, but this partition does not support one or both", type: d }], type: f }, { conditions: r, rules: [{ conditions: [{ [v]: c, [w]: [o, a] }], rules: [{ conditions: [{ [v]: "stringEquals", [w]: [{ [v]: h, [w]: [p, "name"] }, "aws-us-gov"] }], endpoint: { url: "https://portal.sso.{Region}.amazonaws.com", properties: n, headers: n }, type: e }, { endpoint: { url: "https://portal.sso-fips.{Region}.{PartitionResult#dnsSuffix}", properties: n, headers: n }, type: e }], type: f }, { error: "FIPS is enabled but this partition does not support FIPS", type: d }], type: f }, { conditions: s, rules: [{ conditions: [q], rules: [{ endpoint: { url: "https://portal.sso.{Region}.{PartitionResult#dualStackDnsSuffix}", properties: n, headers: n }, type: e }], type: f }, { error: "DualStack is enabled but this partition does not support DualStack", type: d }], type: f }, { endpoint: { url: "https://portal.sso.{Region}.{PartitionResult#dnsSuffix}", properties: n, headers: n }, type: e }], type: f }], type: f }, { error: "Invalid Configuration: Missing Region", type: d }] };
|
|
110
|
+
const ruleSet = _data;
|
|
111
|
+
|
|
112
|
+
const cache = new EndpointCache({
|
|
113
|
+
size: 50,
|
|
114
|
+
params: ["Endpoint", "Region", "UseDualStack", "UseFIPS"],
|
|
115
|
+
});
|
|
116
|
+
const defaultEndpointResolver = (endpointParams, context = {}) => {
|
|
117
|
+
return cache.get(endpointParams, () => resolveEndpoint(ruleSet, {
|
|
118
|
+
endpointParams: endpointParams,
|
|
119
|
+
logger: context.logger,
|
|
120
|
+
}));
|
|
121
|
+
};
|
|
122
|
+
customEndpointFunctions.aws = awsEndpointFunctions;
|
|
123
|
+
|
|
124
|
+
const getRuntimeConfig$1 = (config) => {
|
|
125
|
+
return {
|
|
126
|
+
apiVersion: "2019-06-10",
|
|
127
|
+
base64Decoder: config?.base64Decoder ?? fromBase64,
|
|
128
|
+
base64Encoder: config?.base64Encoder ?? toBase64,
|
|
129
|
+
disableHostPrefix: config?.disableHostPrefix ?? false,
|
|
130
|
+
endpointProvider: config?.endpointProvider ?? defaultEndpointResolver,
|
|
131
|
+
extensions: config?.extensions ?? [],
|
|
132
|
+
httpAuthSchemeProvider: config?.httpAuthSchemeProvider ?? defaultSSOHttpAuthSchemeProvider,
|
|
133
|
+
httpAuthSchemes: config?.httpAuthSchemes ?? [
|
|
134
|
+
{
|
|
135
|
+
schemeId: "aws.auth#sigv4",
|
|
136
|
+
identityProvider: (ipc) => ipc.getIdentityProvider("aws.auth#sigv4"),
|
|
137
|
+
signer: new AwsSdkSigV4Signer(),
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
schemeId: "smithy.api#noAuth",
|
|
141
|
+
identityProvider: (ipc) => ipc.getIdentityProvider("smithy.api#noAuth") || (async () => ({})),
|
|
142
|
+
signer: new NoAuthSigner(),
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
logger: config?.logger ?? new NoOpLogger(),
|
|
146
|
+
protocol: config?.protocol ?? new AwsRestJsonProtocol({ defaultNamespace: "com.amazonaws.sso" }),
|
|
147
|
+
serviceId: config?.serviceId ?? "SSO",
|
|
148
|
+
urlParser: config?.urlParser ?? parseUrl,
|
|
149
|
+
utf8Decoder: config?.utf8Decoder ?? fromUtf8,
|
|
150
|
+
utf8Encoder: config?.utf8Encoder ?? toUtf8,
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const getRuntimeConfig = (config) => {
|
|
155
|
+
emitWarningIfUnsupportedVersion(process.version);
|
|
156
|
+
const defaultsMode = resolveDefaultsModeConfig(config);
|
|
157
|
+
const defaultConfigProvider = () => defaultsMode().then(loadConfigsForDefaultMode);
|
|
158
|
+
const clientSharedValues = getRuntimeConfig$1(config);
|
|
159
|
+
emitWarningIfUnsupportedVersion$1(process.version);
|
|
160
|
+
const loaderConfig = {
|
|
161
|
+
profile: config?.profile,
|
|
162
|
+
logger: clientSharedValues.logger,
|
|
163
|
+
};
|
|
164
|
+
return {
|
|
165
|
+
...clientSharedValues,
|
|
166
|
+
...config,
|
|
167
|
+
runtime: "node",
|
|
168
|
+
defaultsMode,
|
|
169
|
+
authSchemePreference: config?.authSchemePreference ?? loadConfig(NODE_AUTH_SCHEME_PREFERENCE_OPTIONS, loaderConfig),
|
|
170
|
+
bodyLengthChecker: config?.bodyLengthChecker ?? calculateBodyLength,
|
|
171
|
+
defaultUserAgentProvider: config?.defaultUserAgentProvider ??
|
|
172
|
+
createDefaultUserAgentProvider({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }),
|
|
173
|
+
maxAttempts: config?.maxAttempts ?? loadConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS, config),
|
|
174
|
+
region: config?.region ??
|
|
175
|
+
loadConfig(NODE_REGION_CONFIG_OPTIONS, { ...NODE_REGION_CONFIG_FILE_OPTIONS, ...loaderConfig }),
|
|
176
|
+
requestHandler: NodeHttpHandler.create(config?.requestHandler ?? defaultConfigProvider),
|
|
177
|
+
retryMode: config?.retryMode ??
|
|
178
|
+
loadConfig({
|
|
179
|
+
...NODE_RETRY_MODE_CONFIG_OPTIONS,
|
|
180
|
+
default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE,
|
|
181
|
+
}, config),
|
|
182
|
+
sha256: config?.sha256 ?? Hash.bind(null, "sha256"),
|
|
183
|
+
streamCollector: config?.streamCollector ?? streamCollector,
|
|
184
|
+
useDualstackEndpoint: config?.useDualstackEndpoint ?? loadConfig(NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS, loaderConfig),
|
|
185
|
+
useFipsEndpoint: config?.useFipsEndpoint ?? loadConfig(NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS, loaderConfig),
|
|
186
|
+
userAgentAppId: config?.userAgentAppId ?? loadConfig(NODE_APP_ID_CONFIG_OPTIONS, loaderConfig),
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
const getHttpAuthExtensionConfiguration = (runtimeConfig) => {
|
|
191
|
+
const _httpAuthSchemes = runtimeConfig.httpAuthSchemes;
|
|
192
|
+
let _httpAuthSchemeProvider = runtimeConfig.httpAuthSchemeProvider;
|
|
193
|
+
let _credentials = runtimeConfig.credentials;
|
|
194
|
+
return {
|
|
195
|
+
setHttpAuthScheme(httpAuthScheme) {
|
|
196
|
+
const index = _httpAuthSchemes.findIndex((scheme) => scheme.schemeId === httpAuthScheme.schemeId);
|
|
197
|
+
if (index === -1) {
|
|
198
|
+
_httpAuthSchemes.push(httpAuthScheme);
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
_httpAuthSchemes.splice(index, 1, httpAuthScheme);
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
httpAuthSchemes() {
|
|
205
|
+
return _httpAuthSchemes;
|
|
206
|
+
},
|
|
207
|
+
setHttpAuthSchemeProvider(httpAuthSchemeProvider) {
|
|
208
|
+
_httpAuthSchemeProvider = httpAuthSchemeProvider;
|
|
209
|
+
},
|
|
210
|
+
httpAuthSchemeProvider() {
|
|
211
|
+
return _httpAuthSchemeProvider;
|
|
212
|
+
},
|
|
213
|
+
setCredentials(credentials) {
|
|
214
|
+
_credentials = credentials;
|
|
215
|
+
},
|
|
216
|
+
credentials() {
|
|
217
|
+
return _credentials;
|
|
218
|
+
},
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
const resolveHttpAuthRuntimeConfig = (config) => {
|
|
222
|
+
return {
|
|
223
|
+
httpAuthSchemes: config.httpAuthSchemes(),
|
|
224
|
+
httpAuthSchemeProvider: config.httpAuthSchemeProvider(),
|
|
225
|
+
credentials: config.credentials(),
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
const resolveRuntimeExtensions = (runtimeConfig, extensions) => {
|
|
230
|
+
const extensionConfiguration = Object.assign(getAwsRegionExtensionConfiguration(runtimeConfig), getDefaultExtensionConfiguration(runtimeConfig), getHttpHandlerExtensionConfiguration(runtimeConfig), getHttpAuthExtensionConfiguration(runtimeConfig));
|
|
231
|
+
extensions.forEach((extension) => extension.configure(extensionConfiguration));
|
|
232
|
+
return Object.assign(runtimeConfig, resolveAwsRegionExtensionConfiguration(extensionConfiguration), resolveDefaultRuntimeConfig(extensionConfiguration), resolveHttpHandlerRuntimeConfig(extensionConfiguration), resolveHttpAuthRuntimeConfig(extensionConfiguration));
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
class SSOClient extends Client {
|
|
236
|
+
config;
|
|
237
|
+
constructor(...[configuration]) {
|
|
238
|
+
const _config_0 = getRuntimeConfig(configuration || {});
|
|
239
|
+
super(_config_0);
|
|
240
|
+
this.initConfig = _config_0;
|
|
241
|
+
const _config_1 = resolveClientEndpointParameters(_config_0);
|
|
242
|
+
const _config_2 = resolveUserAgentConfig(_config_1);
|
|
243
|
+
const _config_3 = resolveRetryConfig(_config_2);
|
|
244
|
+
const _config_4 = resolveRegionConfig(_config_3);
|
|
245
|
+
const _config_5 = resolveHostHeaderConfig(_config_4);
|
|
246
|
+
const _config_6 = resolveEndpointConfig(_config_5);
|
|
247
|
+
const _config_7 = resolveHttpAuthSchemeConfig(_config_6);
|
|
248
|
+
const _config_8 = resolveRuntimeExtensions(_config_7, configuration?.extensions || []);
|
|
249
|
+
this.config = _config_8;
|
|
250
|
+
this.middlewareStack.use(getSchemaSerdePlugin(this.config));
|
|
251
|
+
this.middlewareStack.use(getUserAgentPlugin(this.config));
|
|
252
|
+
this.middlewareStack.use(getRetryPlugin(this.config));
|
|
253
|
+
this.middlewareStack.use(getContentLengthPlugin(this.config));
|
|
254
|
+
this.middlewareStack.use(getHostHeaderPlugin(this.config));
|
|
255
|
+
this.middlewareStack.use(getLoggerPlugin(this.config));
|
|
256
|
+
this.middlewareStack.use(getRecursionDetectionPlugin(this.config));
|
|
257
|
+
this.middlewareStack.use(getHttpAuthSchemeEndpointRuleSetPlugin(this.config, {
|
|
258
|
+
httpAuthSchemeParametersProvider: defaultSSOHttpAuthSchemeParametersProvider,
|
|
259
|
+
identityProviderConfigProvider: async (config) => new DefaultIdentityProviderConfig({
|
|
260
|
+
"aws.auth#sigv4": config.credentials,
|
|
261
|
+
}),
|
|
262
|
+
}));
|
|
263
|
+
this.middlewareStack.use(getHttpSigningPlugin(this.config));
|
|
264
|
+
}
|
|
265
|
+
destroy() {
|
|
266
|
+
super.destroy();
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
let SSOServiceException$1 = class SSOServiceException extends ServiceException {
|
|
271
|
+
constructor(options) {
|
|
272
|
+
super(options);
|
|
273
|
+
Object.setPrototypeOf(this, SSOServiceException.prototype);
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
let InvalidRequestException$1 = class InvalidRequestException extends SSOServiceException$1 {
|
|
278
|
+
name = "InvalidRequestException";
|
|
279
|
+
$fault = "client";
|
|
280
|
+
constructor(opts) {
|
|
281
|
+
super({
|
|
282
|
+
name: "InvalidRequestException",
|
|
283
|
+
$fault: "client",
|
|
284
|
+
...opts,
|
|
285
|
+
});
|
|
286
|
+
Object.setPrototypeOf(this, InvalidRequestException.prototype);
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
let ResourceNotFoundException$1 = class ResourceNotFoundException extends SSOServiceException$1 {
|
|
290
|
+
name = "ResourceNotFoundException";
|
|
291
|
+
$fault = "client";
|
|
292
|
+
constructor(opts) {
|
|
293
|
+
super({
|
|
294
|
+
name: "ResourceNotFoundException",
|
|
295
|
+
$fault: "client",
|
|
296
|
+
...opts,
|
|
297
|
+
});
|
|
298
|
+
Object.setPrototypeOf(this, ResourceNotFoundException.prototype);
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
let TooManyRequestsException$1 = class TooManyRequestsException extends SSOServiceException$1 {
|
|
302
|
+
name = "TooManyRequestsException";
|
|
303
|
+
$fault = "client";
|
|
304
|
+
constructor(opts) {
|
|
305
|
+
super({
|
|
306
|
+
name: "TooManyRequestsException",
|
|
307
|
+
$fault: "client",
|
|
308
|
+
...opts,
|
|
309
|
+
});
|
|
310
|
+
Object.setPrototypeOf(this, TooManyRequestsException.prototype);
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
let UnauthorizedException$1 = class UnauthorizedException extends SSOServiceException$1 {
|
|
314
|
+
name = "UnauthorizedException";
|
|
315
|
+
$fault = "client";
|
|
316
|
+
constructor(opts) {
|
|
317
|
+
super({
|
|
318
|
+
name: "UnauthorizedException",
|
|
319
|
+
$fault: "client",
|
|
320
|
+
...opts,
|
|
321
|
+
});
|
|
322
|
+
Object.setPrototypeOf(this, UnauthorizedException.prototype);
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
const _ATT = "AccessTokenType";
|
|
327
|
+
const _GRC = "GetRoleCredentials";
|
|
328
|
+
const _GRCR = "GetRoleCredentialsRequest";
|
|
329
|
+
const _GRCRe = "GetRoleCredentialsResponse";
|
|
330
|
+
const _IRE = "InvalidRequestException";
|
|
331
|
+
const _RC = "RoleCredentials";
|
|
332
|
+
const _RNFE = "ResourceNotFoundException";
|
|
333
|
+
const _SAKT = "SecretAccessKeyType";
|
|
334
|
+
const _STT = "SessionTokenType";
|
|
335
|
+
const _TMRE = "TooManyRequestsException";
|
|
336
|
+
const _UE = "UnauthorizedException";
|
|
337
|
+
const _aI = "accountId";
|
|
338
|
+
const _aKI = "accessKeyId";
|
|
339
|
+
const _aT = "accessToken";
|
|
340
|
+
const _ai = "account_id";
|
|
341
|
+
const _c = "client";
|
|
342
|
+
const _e = "error";
|
|
343
|
+
const _ex = "expiration";
|
|
344
|
+
const _h = "http";
|
|
345
|
+
const _hE = "httpError";
|
|
346
|
+
const _hH = "httpHeader";
|
|
347
|
+
const _hQ = "httpQuery";
|
|
348
|
+
const _m = "message";
|
|
349
|
+
const _rC = "roleCredentials";
|
|
350
|
+
const _rN = "roleName";
|
|
351
|
+
const _rn = "role_name";
|
|
352
|
+
const _s = "smithy.ts.sdk.synthetic.com.amazonaws.sso";
|
|
353
|
+
const _sAK = "secretAccessKey";
|
|
354
|
+
const _sT = "sessionToken";
|
|
355
|
+
const _xasbt = "x-amz-sso_bearer_token";
|
|
356
|
+
const n0 = "com.amazonaws.sso";
|
|
357
|
+
var AccessTokenType = [0, n0, _ATT, 8, 0];
|
|
358
|
+
var SecretAccessKeyType = [0, n0, _SAKT, 8, 0];
|
|
359
|
+
var SessionTokenType = [0, n0, _STT, 8, 0];
|
|
360
|
+
var GetRoleCredentialsRequest = [
|
|
361
|
+
3,
|
|
362
|
+
n0,
|
|
363
|
+
_GRCR,
|
|
364
|
+
0,
|
|
365
|
+
[_rN, _aI, _aT],
|
|
366
|
+
[
|
|
367
|
+
[0, { [_hQ]: _rn }],
|
|
368
|
+
[0, { [_hQ]: _ai }],
|
|
369
|
+
[() => AccessTokenType, { [_hH]: _xasbt }],
|
|
370
|
+
],
|
|
371
|
+
];
|
|
372
|
+
var GetRoleCredentialsResponse = [3, n0, _GRCRe, 0, [_rC], [[() => RoleCredentials, 0]]];
|
|
373
|
+
var InvalidRequestException = [-3, n0, _IRE, { [_e]: _c, [_hE]: 400 }, [_m], [0]];
|
|
374
|
+
TypeRegistry.for(n0).registerError(InvalidRequestException, InvalidRequestException$1);
|
|
375
|
+
var ResourceNotFoundException = [-3, n0, _RNFE, { [_e]: _c, [_hE]: 404 }, [_m], [0]];
|
|
376
|
+
TypeRegistry.for(n0).registerError(ResourceNotFoundException, ResourceNotFoundException$1);
|
|
377
|
+
var RoleCredentials = [
|
|
378
|
+
3,
|
|
379
|
+
n0,
|
|
380
|
+
_RC,
|
|
381
|
+
0,
|
|
382
|
+
[_aKI, _sAK, _sT, _ex],
|
|
383
|
+
[0, [() => SecretAccessKeyType, 0], [() => SessionTokenType, 0], 1],
|
|
384
|
+
];
|
|
385
|
+
var TooManyRequestsException = [-3, n0, _TMRE, { [_e]: _c, [_hE]: 429 }, [_m], [0]];
|
|
386
|
+
TypeRegistry.for(n0).registerError(TooManyRequestsException, TooManyRequestsException$1);
|
|
387
|
+
var UnauthorizedException = [-3, n0, _UE, { [_e]: _c, [_hE]: 401 }, [_m], [0]];
|
|
388
|
+
TypeRegistry.for(n0).registerError(UnauthorizedException, UnauthorizedException$1);
|
|
389
|
+
var SSOServiceException = [-3, _s, "SSOServiceException", 0, [], []];
|
|
390
|
+
TypeRegistry.for(_s).registerError(SSOServiceException, SSOServiceException$1);
|
|
391
|
+
var GetRoleCredentials = [
|
|
392
|
+
9,
|
|
393
|
+
n0,
|
|
394
|
+
_GRC,
|
|
395
|
+
{ [_h]: ["GET", "/federation/credentials", 200] },
|
|
396
|
+
() => GetRoleCredentialsRequest,
|
|
397
|
+
() => GetRoleCredentialsResponse,
|
|
398
|
+
];
|
|
399
|
+
|
|
400
|
+
class GetRoleCredentialsCommand extends Command
|
|
401
|
+
.classBuilder()
|
|
402
|
+
.ep(commonParams)
|
|
403
|
+
.m(function (Command, cs, config, o) {
|
|
404
|
+
return [getEndpointPlugin(config, Command.getEndpointParameterInstructions())];
|
|
405
|
+
})
|
|
406
|
+
.s("SWBPortalService", "GetRoleCredentials", {})
|
|
407
|
+
.n("SSOClient", "GetRoleCredentialsCommand")
|
|
408
|
+
.sc(GetRoleCredentials)
|
|
409
|
+
.build() {
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
export { GetRoleCredentialsCommand, SSOClient };
|