@jr2804/livesync-cli 1.0.0-cli → 1.0.16-cli.1

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.
Files changed (33) hide show
  1. package/README.md +44 -3
  2. package/dist/AwsRestJsonProtocol-BPmCQzXa.cjs +391 -0
  3. package/dist/CredentialsProviderError-DQ_v7TCm.cjs +45 -0
  4. package/dist/XmlShapeDeserializer-B1_gcW92.cjs +2097 -0
  5. package/dist/chain-D9g13I5f.cjs +21 -0
  6. package/dist/common-B3KclSP_.cjs +375 -0
  7. package/dist/configLoader-Cur07c2S.cjs +149 -0
  8. package/dist/date-utils-Dr5LXq4_.cjs +338 -0
  9. package/dist/dist-es-BU2b9jKG.cjs +274 -0
  10. package/dist/dist-es-CaaxKLO9.cjs +52 -0
  11. package/dist/dist-es-D7nIauPC.cjs +60 -0
  12. package/dist/dist-es-DhxfSNMj.cjs +128 -0
  13. package/dist/dist-es-FcX9AtZC.cjs +433 -0
  14. package/dist/dist-es-vq3O1QUl.cjs +331 -0
  15. package/dist/{index.browser-DZqJcWQp.cjs → event-streams-DmrxQXpO.cjs} +3 -3
  16. package/dist/extensions-DkDzTVCO.cjs +4823 -0
  17. package/dist/externalDataInterceptor-D7DaIG7M.cjs +24 -0
  18. package/dist/getSSOTokenFromFile-D0KPH2qZ.cjs +36 -0
  19. package/dist/httpRequest-C7Ex2WeE.cjs +59 -0
  20. package/dist/index.cjs +5949 -1556
  21. package/dist/loadSharedConfigFiles-CqEQHuLW.cjs +117 -0
  22. package/dist/loadSso-Dn78jIWR.cjs +639 -0
  23. package/dist/package-BC7A0_n0.cjs +158 -0
  24. package/dist/parseKnownFiles-DLeTaAhg.cjs +21 -0
  25. package/dist/readFile-B3ey_wDD.cjs +46 -0
  26. package/dist/sdk-stream-mixin-YBLWtp6l.cjs +146 -0
  27. package/dist/{index.browser-DbH0tIYi.cjs → serde-DtADB-gG.cjs} +178 -310
  28. package/dist/setCredentialFeature-qcUbSyqa.cjs +13 -0
  29. package/dist/signin-DHnd2WFx.cjs +715 -0
  30. package/dist/sso-oidc-B4fkm2gn.cjs +901 -0
  31. package/dist/stream-collector-jwXXBEUn.cjs +584 -0
  32. package/dist/sts-C9aqjeec.cjs +1531 -0
  33. package/package.json +8 -5
@@ -0,0 +1,60 @@
1
+ const require_loadSharedConfigFiles = require("./loadSharedConfigFiles-CqEQHuLW.cjs");
2
+ const require_setCredentialFeature = require("./setCredentialFeature-qcUbSyqa.cjs");
3
+ const require_CredentialsProviderError = require("./CredentialsProviderError-DQ_v7TCm.cjs");
4
+ const require_parseKnownFiles = require("./parseKnownFiles-DLeTaAhg.cjs");
5
+ const require_externalDataInterceptor = require("./externalDataInterceptor-D7DaIG7M.cjs");
6
+ let node_child_process = require("node:child_process");
7
+ let node_util = require("node:util");
8
+ //#region ../../../node_modules/@aws-sdk/credential-provider-process/dist-es/getValidatedProcessCredentials.js
9
+ var getValidatedProcessCredentials = (profileName, data, profiles) => {
10
+ if (data.Version !== 1) throw Error(`Profile ${profileName} credential_process did not return Version 1.`);
11
+ if (data.AccessKeyId === void 0 || data.SecretAccessKey === void 0) throw Error(`Profile ${profileName} credential_process returned invalid credentials.`);
12
+ if (data.Expiration) {
13
+ const currentTime = /* @__PURE__ */ new Date();
14
+ if (new Date(data.Expiration) < currentTime) throw Error(`Profile ${profileName} credential_process returned expired credentials.`);
15
+ }
16
+ let accountId = data.AccountId;
17
+ if (!accountId && profiles?.[profileName]?.aws_account_id) accountId = profiles[profileName].aws_account_id;
18
+ const credentials = {
19
+ accessKeyId: data.AccessKeyId,
20
+ secretAccessKey: data.SecretAccessKey,
21
+ ...data.SessionToken && { sessionToken: data.SessionToken },
22
+ ...data.Expiration && { expiration: new Date(data.Expiration) },
23
+ ...data.CredentialScope && { credentialScope: data.CredentialScope },
24
+ ...accountId && { accountId }
25
+ };
26
+ require_setCredentialFeature.setCredentialFeature(credentials, "CREDENTIALS_PROCESS", "w");
27
+ return credentials;
28
+ };
29
+ //#endregion
30
+ //#region ../../../node_modules/@aws-sdk/credential-provider-process/dist-es/resolveProcessCredentials.js
31
+ var resolveProcessCredentials = async (profileName, profiles, logger) => {
32
+ const profile = profiles[profileName];
33
+ if (profiles[profileName]) {
34
+ const credentialProcess = profile["credential_process"];
35
+ if (credentialProcess !== void 0) {
36
+ const execPromise = (0, node_util.promisify)(require_externalDataInterceptor.externalDataInterceptor?.getTokenRecord?.().exec ?? node_child_process.exec);
37
+ try {
38
+ const { stdout } = await execPromise(credentialProcess);
39
+ let data;
40
+ try {
41
+ data = JSON.parse(stdout.trim());
42
+ } catch {
43
+ throw Error(`Profile ${profileName} credential_process returned invalid JSON.`);
44
+ }
45
+ return getValidatedProcessCredentials(profileName, data, profiles);
46
+ } catch (error) {
47
+ throw new require_CredentialsProviderError.CredentialsProviderError(error.message, { logger });
48
+ }
49
+ } else throw new require_CredentialsProviderError.CredentialsProviderError(`Profile ${profileName} did not contain credential_process.`, { logger });
50
+ } else throw new require_CredentialsProviderError.CredentialsProviderError(`Profile ${profileName} could not be found in shared credentials file.`, { logger });
51
+ };
52
+ //#endregion
53
+ //#region ../../../node_modules/@aws-sdk/credential-provider-process/dist-es/fromProcess.js
54
+ var fromProcess = (init = {}) => async ({ callerClientConfig } = {}) => {
55
+ init.logger?.debug("@aws-sdk/credential-provider-process - fromProcess");
56
+ const profiles = await require_parseKnownFiles.parseKnownFiles(init);
57
+ return resolveProcessCredentials(require_loadSharedConfigFiles.getProfileName({ profile: init.profile ?? callerClientConfig?.profile }), profiles, init.logger);
58
+ };
59
+ //#endregion
60
+ exports.fromProcess = fromProcess;
@@ -0,0 +1,128 @@
1
+ const require_stream_collector = require("./stream-collector-jwXXBEUn.cjs");
2
+ const require_httpRequest = require("./httpRequest-C7Ex2WeE.cjs");
3
+ const require_setCredentialFeature = require("./setCredentialFeature-qcUbSyqa.cjs");
4
+ const require_date_utils = require("./date-utils-Dr5LXq4_.cjs");
5
+ const require_CredentialsProviderError = require("./CredentialsProviderError-DQ_v7TCm.cjs");
6
+ const require_sdk_stream_mixin = require("./sdk-stream-mixin-YBLWtp6l.cjs");
7
+ let node_fs_promises = require("node:fs/promises");
8
+ node_fs_promises = require_stream_collector.__toESM(node_fs_promises);
9
+ //#region ../../../node_modules/@aws-sdk/credential-provider-http/dist-es/fromHttp/checkUrl.js
10
+ var ECS_CONTAINER_HOST = "169.254.170.2";
11
+ var EKS_CONTAINER_HOST_IPv4 = "169.254.170.23";
12
+ var EKS_CONTAINER_HOST_IPv6 = "[fd00:ec2::23]";
13
+ var checkUrl = (url, logger) => {
14
+ if (url.protocol === "https:") return;
15
+ if (url.hostname === ECS_CONTAINER_HOST || url.hostname === EKS_CONTAINER_HOST_IPv4 || url.hostname === EKS_CONTAINER_HOST_IPv6) return;
16
+ if (url.hostname.includes("[")) {
17
+ if (url.hostname === "[::1]" || url.hostname === "[0000:0000:0000:0000:0000:0000:0000:0001]") return;
18
+ } else {
19
+ if (url.hostname === "localhost") return;
20
+ const ipComponents = url.hostname.split(".");
21
+ const inRange = (component) => {
22
+ const num = parseInt(component, 10);
23
+ return 0 <= num && num <= 255;
24
+ };
25
+ if (ipComponents[0] === "127" && inRange(ipComponents[1]) && inRange(ipComponents[2]) && inRange(ipComponents[3]) && ipComponents.length === 4) return;
26
+ }
27
+ throw new require_CredentialsProviderError.CredentialsProviderError(`URL not accepted. It must either be HTTPS or match one of the following:
28
+ - loopback CIDR 127.0.0.0/8 or [::1/128]
29
+ - ECS container host 169.254.170.2
30
+ - EKS container host 169.254.170.23 or [fd00:ec2::23]`, { logger });
31
+ };
32
+ //#endregion
33
+ //#region ../../../node_modules/@aws-sdk/credential-provider-http/dist-es/fromHttp/requestHelpers.js
34
+ function createGetRequest(url) {
35
+ return new require_httpRequest.HttpRequest({
36
+ protocol: url.protocol,
37
+ hostname: url.hostname,
38
+ port: Number(url.port),
39
+ path: url.pathname,
40
+ query: Array.from(url.searchParams.entries()).reduce((acc, [k, v]) => {
41
+ acc[k] = v;
42
+ return acc;
43
+ }, {}),
44
+ fragment: url.hash
45
+ });
46
+ }
47
+ async function getCredentials(response, logger) {
48
+ const str = await require_sdk_stream_mixin.sdkStreamMixin(response.body).transformToString();
49
+ if (response.statusCode === 200) {
50
+ const parsed = JSON.parse(str);
51
+ if (typeof parsed.AccessKeyId !== "string" || typeof parsed.SecretAccessKey !== "string" || typeof parsed.Token !== "string" || typeof parsed.Expiration !== "string") throw new require_CredentialsProviderError.CredentialsProviderError("HTTP credential provider response not of the required format, an object matching: { AccessKeyId: string, SecretAccessKey: string, Token: string, Expiration: string(rfc3339) }", { logger });
52
+ return {
53
+ accessKeyId: parsed.AccessKeyId,
54
+ secretAccessKey: parsed.SecretAccessKey,
55
+ sessionToken: parsed.Token,
56
+ expiration: require_date_utils.parseRfc3339DateTime(parsed.Expiration)
57
+ };
58
+ }
59
+ if (response.statusCode >= 400 && response.statusCode < 500) {
60
+ let parsedBody = {};
61
+ try {
62
+ parsedBody = JSON.parse(str);
63
+ } catch (e) {}
64
+ throw Object.assign(new require_CredentialsProviderError.CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger }), {
65
+ Code: parsedBody.Code,
66
+ Message: parsedBody.Message
67
+ });
68
+ }
69
+ throw new require_CredentialsProviderError.CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger });
70
+ }
71
+ //#endregion
72
+ //#region ../../../node_modules/@aws-sdk/credential-provider-http/dist-es/fromHttp/retry-wrapper.js
73
+ var retryWrapper = (toRetry, maxRetries, delayMs) => {
74
+ return async () => {
75
+ for (let i = 0; i < maxRetries; ++i) try {
76
+ return await toRetry();
77
+ } catch (e) {
78
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
79
+ }
80
+ return await toRetry();
81
+ };
82
+ };
83
+ //#endregion
84
+ //#region ../../../node_modules/@aws-sdk/credential-provider-http/dist-es/fromHttp/fromHttp.js
85
+ var AWS_CONTAINER_CREDENTIALS_RELATIVE_URI = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI";
86
+ var DEFAULT_LINK_LOCAL_HOST = "http://169.254.170.2";
87
+ var AWS_CONTAINER_CREDENTIALS_FULL_URI = "AWS_CONTAINER_CREDENTIALS_FULL_URI";
88
+ var AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE = "AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE";
89
+ var AWS_CONTAINER_AUTHORIZATION_TOKEN = "AWS_CONTAINER_AUTHORIZATION_TOKEN";
90
+ var fromHttp = (options = {}) => {
91
+ options.logger?.debug("@aws-sdk/credential-provider-http - fromHttp");
92
+ let host;
93
+ const relative = options.awsContainerCredentialsRelativeUri ?? process.env[AWS_CONTAINER_CREDENTIALS_RELATIVE_URI];
94
+ const full = options.awsContainerCredentialsFullUri ?? process.env[AWS_CONTAINER_CREDENTIALS_FULL_URI];
95
+ const token = options.awsContainerAuthorizationToken ?? process.env[AWS_CONTAINER_AUTHORIZATION_TOKEN];
96
+ const tokenFile = options.awsContainerAuthorizationTokenFile ?? process.env[AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE];
97
+ const warn = options.logger?.constructor?.name === "NoOpLogger" || !options.logger?.warn ? console.warn : options.logger.warn.bind(options.logger);
98
+ if (relative && full) {
99
+ warn("@aws-sdk/credential-provider-http: you have set both awsContainerCredentialsRelativeUri and awsContainerCredentialsFullUri.");
100
+ warn("awsContainerCredentialsFullUri will take precedence.");
101
+ }
102
+ if (token && tokenFile) {
103
+ warn("@aws-sdk/credential-provider-http: you have set both awsContainerAuthorizationToken and awsContainerAuthorizationTokenFile.");
104
+ warn("awsContainerAuthorizationToken will take precedence.");
105
+ }
106
+ if (full) host = full;
107
+ else if (relative) host = `${DEFAULT_LINK_LOCAL_HOST}${relative}`;
108
+ else throw new require_CredentialsProviderError.CredentialsProviderError(`No HTTP credential provider host provided.
109
+ Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI.`, { logger: options.logger });
110
+ const url = new URL(host);
111
+ checkUrl(url, options.logger);
112
+ const requestHandler = require_stream_collector.NodeHttpHandler.create({
113
+ requestTimeout: options.timeout ?? 1e3,
114
+ connectionTimeout: options.timeout ?? 1e3
115
+ });
116
+ return retryWrapper(async () => {
117
+ const request = createGetRequest(url);
118
+ if (token) request.headers.Authorization = token;
119
+ else if (tokenFile) request.headers.Authorization = (await node_fs_promises.default.readFile(tokenFile)).toString();
120
+ try {
121
+ return getCredentials((await requestHandler.handle(request)).response).then((creds) => require_setCredentialFeature.setCredentialFeature(creds, "CREDENTIALS_HTTP", "z"));
122
+ } catch (e) {
123
+ throw new require_CredentialsProviderError.CredentialsProviderError(String(e), { logger: options.logger });
124
+ }
125
+ }, options.maxRetries ?? 3, options.timeout ?? 1e3);
126
+ };
127
+ //#endregion
128
+ exports.fromHttp = fromHttp;
@@ -0,0 +1,433 @@
1
+ const require_loadSharedConfigFiles = require("./loadSharedConfigFiles-CqEQHuLW.cjs");
2
+ const require_httpRequest = require("./httpRequest-C7Ex2WeE.cjs");
3
+ const require_setCredentialFeature = require("./setCredentialFeature-qcUbSyqa.cjs");
4
+ const require_CredentialsProviderError = require("./CredentialsProviderError-DQ_v7TCm.cjs");
5
+ const require_chain = require("./chain-D9g13I5f.cjs");
6
+ const require_readFile = require("./readFile-B3ey_wDD.cjs");
7
+ const require_parseKnownFiles = require("./parseKnownFiles-DLeTaAhg.cjs");
8
+ let node_crypto = require("node:crypto");
9
+ let node_fs = require("node:fs");
10
+ let node_path = require("node:path");
11
+ let node_os = require("node:os");
12
+ //#region ../../../node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveCredentialSource.js
13
+ var resolveCredentialSource = (credentialSource, profileName, logger) => {
14
+ const sourceProvidersMap = {
15
+ EcsContainer: async (options) => {
16
+ const { fromHttp } = await Promise.resolve().then(() => require("./dist-es-DhxfSNMj.cjs"));
17
+ const { fromContainerMetadata } = await Promise.resolve().then(() => require("./dist-es-vq3O1QUl.cjs"));
18
+ logger?.debug("@aws-sdk/credential-provider-ini - credential_source is EcsContainer");
19
+ return async () => require_chain.chain(fromHttp(options ?? {}), fromContainerMetadata(options))().then(setNamedProvider);
20
+ },
21
+ Ec2InstanceMetadata: async (options) => {
22
+ logger?.debug("@aws-sdk/credential-provider-ini - credential_source is Ec2InstanceMetadata");
23
+ const { fromInstanceMetadata } = await Promise.resolve().then(() => require("./dist-es-vq3O1QUl.cjs"));
24
+ return async () => fromInstanceMetadata(options)().then(setNamedProvider);
25
+ },
26
+ Environment: async (options) => {
27
+ logger?.debug("@aws-sdk/credential-provider-ini - credential_source is Environment");
28
+ const { fromEnv } = await Promise.resolve().then(() => require("./index.cjs")).then((n) => n.dist_es_exports);
29
+ return async () => fromEnv(options)().then(setNamedProvider);
30
+ }
31
+ };
32
+ if (credentialSource in sourceProvidersMap) return sourceProvidersMap[credentialSource];
33
+ else throw new require_CredentialsProviderError.CredentialsProviderError(`Unsupported credential source in profile ${profileName}. Got ${credentialSource}, expected EcsContainer or Ec2InstanceMetadata or Environment.`, { logger });
34
+ };
35
+ var setNamedProvider = (creds) => require_setCredentialFeature.setCredentialFeature(creds, "CREDENTIALS_PROFILE_NAMED_PROVIDER", "p");
36
+ //#endregion
37
+ //#region ../../../node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveAssumeRoleCredentials.js
38
+ var isAssumeRoleProfile = (arg, { profile = "default", logger } = {}) => {
39
+ return Boolean(arg) && typeof arg === "object" && typeof arg.role_arn === "string" && ["undefined", "string"].indexOf(typeof arg.role_session_name) > -1 && ["undefined", "string"].indexOf(typeof arg.external_id) > -1 && ["undefined", "string"].indexOf(typeof arg.mfa_serial) > -1 && (isAssumeRoleWithSourceProfile(arg, {
40
+ profile,
41
+ logger
42
+ }) || isCredentialSourceProfile(arg, {
43
+ profile,
44
+ logger
45
+ }));
46
+ };
47
+ var isAssumeRoleWithSourceProfile = (arg, { profile, logger }) => {
48
+ const withSourceProfile = typeof arg.source_profile === "string" && typeof arg.credential_source === "undefined";
49
+ if (withSourceProfile) logger?.debug?.(` ${profile} isAssumeRoleWithSourceProfile source_profile=${arg.source_profile}`);
50
+ return withSourceProfile;
51
+ };
52
+ var isCredentialSourceProfile = (arg, { profile, logger }) => {
53
+ const withProviderProfile = typeof arg.credential_source === "string" && typeof arg.source_profile === "undefined";
54
+ if (withProviderProfile) logger?.debug?.(` ${profile} isCredentialSourceProfile credential_source=${arg.credential_source}`);
55
+ return withProviderProfile;
56
+ };
57
+ var resolveAssumeRoleCredentials = async (profileName, profiles, options, callerClientConfig, visitedProfiles = {}, resolveProfileData) => {
58
+ options.logger?.debug("@aws-sdk/credential-provider-ini - resolveAssumeRoleCredentials (STS)");
59
+ const profileData = profiles[profileName];
60
+ const { source_profile, region } = profileData;
61
+ if (!options.roleAssumer) {
62
+ const { getDefaultRoleAssumer } = await Promise.resolve().then(() => require("./sts-C9aqjeec.cjs"));
63
+ options.roleAssumer = getDefaultRoleAssumer({
64
+ ...options.clientConfig,
65
+ credentialProviderLogger: options.logger,
66
+ parentClientConfig: {
67
+ ...callerClientConfig,
68
+ ...options?.parentClientConfig,
69
+ region: region ?? options?.parentClientConfig?.region ?? callerClientConfig?.region
70
+ }
71
+ }, options.clientPlugins);
72
+ }
73
+ if (source_profile && source_profile in visitedProfiles) throw new require_CredentialsProviderError.CredentialsProviderError(`Detected a cycle attempting to resolve credentials for profile ${require_loadSharedConfigFiles.getProfileName(options)}. Profiles visited: ` + Object.keys(visitedProfiles).join(", "), { logger: options.logger });
74
+ options.logger?.debug(`@aws-sdk/credential-provider-ini - finding credential resolver using ${source_profile ? `source_profile=[${source_profile}]` : `profile=[${profileName}]`}`);
75
+ const sourceCredsProvider = source_profile ? resolveProfileData(source_profile, profiles, options, callerClientConfig, {
76
+ ...visitedProfiles,
77
+ [source_profile]: true
78
+ }, isCredentialSourceWithoutRoleArn(profiles[source_profile] ?? {})) : (await resolveCredentialSource(profileData.credential_source, profileName, options.logger)(options))();
79
+ if (isCredentialSourceWithoutRoleArn(profileData)) return sourceCredsProvider.then((creds) => require_setCredentialFeature.setCredentialFeature(creds, "CREDENTIALS_PROFILE_SOURCE_PROFILE", "o"));
80
+ else {
81
+ const params = {
82
+ RoleArn: profileData.role_arn,
83
+ RoleSessionName: profileData.role_session_name || `aws-sdk-js-${Date.now()}`,
84
+ ExternalId: profileData.external_id,
85
+ DurationSeconds: parseInt(profileData.duration_seconds || "3600", 10)
86
+ };
87
+ const { mfa_serial } = profileData;
88
+ if (mfa_serial) {
89
+ if (!options.mfaCodeProvider) throw new require_CredentialsProviderError.CredentialsProviderError(`Profile ${profileName} requires multi-factor authentication, but no MFA code callback was provided.`, {
90
+ logger: options.logger,
91
+ tryNextLink: false
92
+ });
93
+ params.SerialNumber = mfa_serial;
94
+ params.TokenCode = await options.mfaCodeProvider(mfa_serial);
95
+ }
96
+ const sourceCreds = await sourceCredsProvider;
97
+ return options.roleAssumer(sourceCreds, params).then((creds) => require_setCredentialFeature.setCredentialFeature(creds, "CREDENTIALS_PROFILE_SOURCE_PROFILE", "o"));
98
+ }
99
+ };
100
+ var isCredentialSourceWithoutRoleArn = (section) => {
101
+ return !section.role_arn && !!section.credential_source;
102
+ };
103
+ //#endregion
104
+ //#region ../../../node_modules/@aws-sdk/credential-provider-login/dist-es/LoginCredentialsFetcher.js
105
+ var LoginCredentialsFetcher = class LoginCredentialsFetcher {
106
+ profileData;
107
+ init;
108
+ callerClientConfig;
109
+ static REFRESH_THRESHOLD = 300 * 1e3;
110
+ constructor(profileData, init, callerClientConfig) {
111
+ this.profileData = profileData;
112
+ this.init = init;
113
+ this.callerClientConfig = callerClientConfig;
114
+ }
115
+ async loadCredentials() {
116
+ const token = await this.loadToken();
117
+ if (!token) throw new require_CredentialsProviderError.CredentialsProviderError(`Failed to load a token for session ${this.loginSession}, please re-authenticate using aws login`, {
118
+ tryNextLink: false,
119
+ logger: this.logger
120
+ });
121
+ const accessToken = token.accessToken;
122
+ const now = Date.now();
123
+ if (new Date(accessToken.expiresAt).getTime() - now <= LoginCredentialsFetcher.REFRESH_THRESHOLD) return this.refresh(token);
124
+ return {
125
+ accessKeyId: accessToken.accessKeyId,
126
+ secretAccessKey: accessToken.secretAccessKey,
127
+ sessionToken: accessToken.sessionToken,
128
+ accountId: accessToken.accountId,
129
+ expiration: new Date(accessToken.expiresAt)
130
+ };
131
+ }
132
+ get logger() {
133
+ return this.init?.logger;
134
+ }
135
+ get loginSession() {
136
+ return this.profileData.login_session;
137
+ }
138
+ async refresh(token) {
139
+ const { SigninClient, CreateOAuth2TokenCommand } = await Promise.resolve().then(() => require("./signin-DHnd2WFx.cjs"));
140
+ const { logger, userAgentAppId } = this.callerClientConfig ?? {};
141
+ const isH2 = (requestHandler) => {
142
+ return requestHandler?.metadata?.handlerProtocol === "h2";
143
+ };
144
+ const requestHandler = isH2(this.callerClientConfig?.requestHandler) ? void 0 : this.callerClientConfig?.requestHandler;
145
+ const client = new SigninClient({
146
+ credentials: {
147
+ accessKeyId: "",
148
+ secretAccessKey: ""
149
+ },
150
+ region: this.profileData.region ?? await this.callerClientConfig?.region?.() ?? process.env.AWS_REGION,
151
+ requestHandler,
152
+ logger,
153
+ userAgentAppId,
154
+ ...this.init?.clientConfig
155
+ });
156
+ this.createDPoPInterceptor(client.middlewareStack);
157
+ const commandInput = { tokenInput: {
158
+ clientId: token.clientId,
159
+ refreshToken: token.refreshToken,
160
+ grantType: "refresh_token"
161
+ } };
162
+ try {
163
+ const response = await client.send(new CreateOAuth2TokenCommand(commandInput));
164
+ const { accessKeyId, secretAccessKey, sessionToken } = response.tokenOutput?.accessToken ?? {};
165
+ const { refreshToken, expiresIn } = response.tokenOutput ?? {};
166
+ if (!accessKeyId || !secretAccessKey || !sessionToken || !refreshToken) throw new require_CredentialsProviderError.CredentialsProviderError("Token refresh response missing required fields", {
167
+ logger: this.logger,
168
+ tryNextLink: false
169
+ });
170
+ const expiresInMs = (expiresIn ?? 900) * 1e3;
171
+ const expiration = new Date(Date.now() + expiresInMs);
172
+ const updatedToken = {
173
+ ...token,
174
+ accessToken: {
175
+ ...token.accessToken,
176
+ accessKeyId,
177
+ secretAccessKey,
178
+ sessionToken,
179
+ expiresAt: expiration.toISOString()
180
+ },
181
+ refreshToken
182
+ };
183
+ await this.saveToken(updatedToken);
184
+ const newAccessToken = updatedToken.accessToken;
185
+ return {
186
+ accessKeyId: newAccessToken.accessKeyId,
187
+ secretAccessKey: newAccessToken.secretAccessKey,
188
+ sessionToken: newAccessToken.sessionToken,
189
+ accountId: newAccessToken.accountId,
190
+ expiration
191
+ };
192
+ } catch (error) {
193
+ if (error.name === "AccessDeniedException") {
194
+ const errorType = error.error;
195
+ let message;
196
+ switch (errorType) {
197
+ case "TOKEN_EXPIRED":
198
+ message = "Your session has expired. Please reauthenticate.";
199
+ break;
200
+ case "USER_CREDENTIALS_CHANGED":
201
+ message = "Unable to refresh credentials because of a change in your password. Please reauthenticate with your new password.";
202
+ break;
203
+ case "INSUFFICIENT_PERMISSIONS":
204
+ message = "Unable to refresh credentials due to insufficient permissions. You may be missing permission for the 'CreateOAuth2Token' action.";
205
+ break;
206
+ default: message = `Failed to refresh token: ${String(error)}. Please re-authenticate using \`aws login\``;
207
+ }
208
+ throw new require_CredentialsProviderError.CredentialsProviderError(message, {
209
+ logger: this.logger,
210
+ tryNextLink: false
211
+ });
212
+ }
213
+ throw new require_CredentialsProviderError.CredentialsProviderError(`Failed to refresh token: ${String(error)}. Please re-authenticate using aws login`, { logger: this.logger });
214
+ }
215
+ }
216
+ async loadToken() {
217
+ const tokenFilePath = this.getTokenFilePath();
218
+ try {
219
+ let tokenData;
220
+ try {
221
+ tokenData = await require_readFile.readFile(tokenFilePath, { ignoreCache: this.init?.ignoreCache });
222
+ } catch {
223
+ tokenData = await node_fs.promises.readFile(tokenFilePath, "utf8");
224
+ }
225
+ const token = JSON.parse(tokenData);
226
+ const missingFields = [
227
+ "accessToken",
228
+ "clientId",
229
+ "refreshToken",
230
+ "dpopKey"
231
+ ].filter((k) => !token[k]);
232
+ if (!token.accessToken?.accountId) missingFields.push("accountId");
233
+ if (missingFields.length > 0) throw new require_CredentialsProviderError.CredentialsProviderError(`Token validation failed, missing fields: ${missingFields.join(", ")}`, {
234
+ logger: this.logger,
235
+ tryNextLink: false
236
+ });
237
+ return token;
238
+ } catch (error) {
239
+ throw new require_CredentialsProviderError.CredentialsProviderError(`Failed to load token from ${tokenFilePath}: ${String(error)}`, {
240
+ logger: this.logger,
241
+ tryNextLink: false
242
+ });
243
+ }
244
+ }
245
+ async saveToken(token) {
246
+ const tokenFilePath = this.getTokenFilePath();
247
+ const directory = (0, node_path.dirname)(tokenFilePath);
248
+ try {
249
+ await node_fs.promises.mkdir(directory, { recursive: true });
250
+ } catch (error) {}
251
+ await node_fs.promises.writeFile(tokenFilePath, JSON.stringify(token, null, 2), "utf8");
252
+ }
253
+ getTokenFilePath() {
254
+ const directory = process.env.AWS_LOGIN_CACHE_DIRECTORY ?? (0, node_path.join)((0, node_os.homedir)(), ".aws", "login", "cache");
255
+ const loginSessionBytes = Buffer.from(this.loginSession, "utf8");
256
+ return (0, node_path.join)(directory, `${(0, node_crypto.createHash)("sha256").update(loginSessionBytes).digest("hex")}.json`);
257
+ }
258
+ derToRawSignature(derSignature) {
259
+ let offset = 2;
260
+ if (derSignature[offset] !== 2) throw new Error("Invalid DER signature");
261
+ offset++;
262
+ const rLength = derSignature[offset++];
263
+ let r = derSignature.subarray(offset, offset + rLength);
264
+ offset += rLength;
265
+ if (derSignature[offset] !== 2) throw new Error("Invalid DER signature");
266
+ offset++;
267
+ const sLength = derSignature[offset++];
268
+ let s = derSignature.subarray(offset, offset + sLength);
269
+ r = r[0] === 0 ? r.subarray(1) : r;
270
+ s = s[0] === 0 ? s.subarray(1) : s;
271
+ const rPadded = Buffer.concat([Buffer.alloc(32 - r.length), r]);
272
+ const sPadded = Buffer.concat([Buffer.alloc(32 - s.length), s]);
273
+ return Buffer.concat([rPadded, sPadded]);
274
+ }
275
+ createDPoPInterceptor(middlewareStack) {
276
+ middlewareStack.add((next) => async (args) => {
277
+ if (require_httpRequest.HttpRequest.isInstance(args.request)) {
278
+ const request = args.request;
279
+ const actualEndpoint = `${request.protocol}//${request.hostname}${request.port ? `:${request.port}` : ""}${request.path}`;
280
+ const dpop = await this.generateDpop(request.method, actualEndpoint);
281
+ request.headers = {
282
+ ...request.headers,
283
+ DPoP: dpop
284
+ };
285
+ }
286
+ return next(args);
287
+ }, {
288
+ step: "finalizeRequest",
289
+ name: "dpopInterceptor",
290
+ override: true
291
+ });
292
+ }
293
+ async generateDpop(method = "POST", endpoint) {
294
+ const token = await this.loadToken();
295
+ try {
296
+ const privateKey = (0, node_crypto.createPrivateKey)({
297
+ key: token.dpopKey,
298
+ format: "pem",
299
+ type: "sec1"
300
+ });
301
+ const publicDer = (0, node_crypto.createPublicKey)(privateKey).export({
302
+ format: "der",
303
+ type: "spki"
304
+ });
305
+ let pointStart = -1;
306
+ for (let i = 0; i < publicDer.length; i++) if (publicDer[i] === 4) {
307
+ pointStart = i;
308
+ break;
309
+ }
310
+ const x = publicDer.slice(pointStart + 1, pointStart + 33);
311
+ const y = publicDer.slice(pointStart + 33, pointStart + 65);
312
+ const header = {
313
+ alg: "ES256",
314
+ typ: "dpop+jwt",
315
+ jwk: {
316
+ kty: "EC",
317
+ crv: "P-256",
318
+ x: x.toString("base64url"),
319
+ y: y.toString("base64url")
320
+ }
321
+ };
322
+ const payload = {
323
+ jti: crypto.randomUUID(),
324
+ htm: method,
325
+ htu: endpoint,
326
+ iat: Math.floor(Date.now() / 1e3)
327
+ };
328
+ const message = `${Buffer.from(JSON.stringify(header)).toString("base64url")}.${Buffer.from(JSON.stringify(payload)).toString("base64url")}`;
329
+ const asn1Signature = (0, node_crypto.sign)("sha256", Buffer.from(message), privateKey);
330
+ return `${message}.${this.derToRawSignature(asn1Signature).toString("base64url")}`;
331
+ } catch (error) {
332
+ throw new require_CredentialsProviderError.CredentialsProviderError(`Failed to generate Dpop proof: ${error instanceof Error ? error.message : String(error)}`, {
333
+ logger: this.logger,
334
+ tryNextLink: false
335
+ });
336
+ }
337
+ }
338
+ };
339
+ //#endregion
340
+ //#region ../../../node_modules/@aws-sdk/credential-provider-login/dist-es/fromLoginCredentials.js
341
+ var fromLoginCredentials = (init) => async ({ callerClientConfig } = {}) => {
342
+ init?.logger?.debug?.("@aws-sdk/credential-providers - fromLoginCredentials");
343
+ const profiles = await require_parseKnownFiles.parseKnownFiles(init || {});
344
+ const profileName = require_loadSharedConfigFiles.getProfileName({ profile: init?.profile ?? callerClientConfig?.profile });
345
+ const profile = profiles[profileName];
346
+ if (!profile?.login_session) throw new require_CredentialsProviderError.CredentialsProviderError(`Profile ${profileName} does not contain login_session.`, {
347
+ tryNextLink: true,
348
+ logger: init?.logger
349
+ });
350
+ return require_setCredentialFeature.setCredentialFeature(await new LoginCredentialsFetcher(profile, init, callerClientConfig).loadCredentials(), "CREDENTIALS_LOGIN", "AD");
351
+ };
352
+ //#endregion
353
+ //#region ../../../node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveLoginCredentials.js
354
+ var isLoginProfile = (data) => {
355
+ return Boolean(data && data.login_session);
356
+ };
357
+ var resolveLoginCredentials = async (profileName, options, callerClientConfig) => {
358
+ return require_setCredentialFeature.setCredentialFeature(await fromLoginCredentials({
359
+ ...options,
360
+ profile: profileName
361
+ })({ callerClientConfig }), "CREDENTIALS_PROFILE_LOGIN", "AC");
362
+ };
363
+ //#endregion
364
+ //#region ../../../node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveProcessCredentials.js
365
+ var isProcessProfile = (arg) => Boolean(arg) && typeof arg === "object" && typeof arg.credential_process === "string";
366
+ var resolveProcessCredentials = async (options, profile) => Promise.resolve().then(() => require("./dist-es-D7nIauPC.cjs")).then(({ fromProcess }) => fromProcess({
367
+ ...options,
368
+ profile
369
+ })().then((creds) => require_setCredentialFeature.setCredentialFeature(creds, "CREDENTIALS_PROFILE_PROCESS", "v")));
370
+ //#endregion
371
+ //#region ../../../node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveSsoCredentials.js
372
+ var resolveSsoCredentials = async (profile, profileData, options = {}, callerClientConfig) => {
373
+ const { fromSSO } = await Promise.resolve().then(() => require("./dist-es-BU2b9jKG.cjs"));
374
+ return fromSSO({
375
+ profile,
376
+ logger: options.logger,
377
+ parentClientConfig: options.parentClientConfig,
378
+ clientConfig: options.clientConfig
379
+ })({ callerClientConfig }).then((creds) => {
380
+ if (profileData.sso_session) return require_setCredentialFeature.setCredentialFeature(creds, "CREDENTIALS_PROFILE_SSO", "r");
381
+ else return require_setCredentialFeature.setCredentialFeature(creds, "CREDENTIALS_PROFILE_SSO_LEGACY", "t");
382
+ });
383
+ };
384
+ var isSsoProfile = (arg) => arg && (typeof arg.sso_start_url === "string" || typeof arg.sso_account_id === "string" || typeof arg.sso_session === "string" || typeof arg.sso_region === "string" || typeof arg.sso_role_name === "string");
385
+ //#endregion
386
+ //#region ../../../node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveStaticCredentials.js
387
+ var isStaticCredsProfile = (arg) => Boolean(arg) && typeof arg === "object" && typeof arg.aws_access_key_id === "string" && typeof arg.aws_secret_access_key === "string" && ["undefined", "string"].indexOf(typeof arg.aws_session_token) > -1 && ["undefined", "string"].indexOf(typeof arg.aws_account_id) > -1;
388
+ var resolveStaticCredentials = async (profile, options) => {
389
+ options?.logger?.debug("@aws-sdk/credential-provider-ini - resolveStaticCredentials");
390
+ return require_setCredentialFeature.setCredentialFeature({
391
+ accessKeyId: profile.aws_access_key_id,
392
+ secretAccessKey: profile.aws_secret_access_key,
393
+ sessionToken: profile.aws_session_token,
394
+ ...profile.aws_credential_scope && { credentialScope: profile.aws_credential_scope },
395
+ ...profile.aws_account_id && { accountId: profile.aws_account_id }
396
+ }, "CREDENTIALS_PROFILE", "n");
397
+ };
398
+ //#endregion
399
+ //#region ../../../node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveWebIdentityCredentials.js
400
+ var isWebIdentityProfile = (arg) => Boolean(arg) && typeof arg === "object" && typeof arg.web_identity_token_file === "string" && typeof arg.role_arn === "string" && ["undefined", "string"].indexOf(typeof arg.role_session_name) > -1;
401
+ var resolveWebIdentityCredentials = async (profile, options, callerClientConfig) => Promise.resolve().then(() => require("./dist-es-CaaxKLO9.cjs")).then(({ fromTokenFile }) => fromTokenFile({
402
+ webIdentityTokenFile: profile.web_identity_token_file,
403
+ roleArn: profile.role_arn,
404
+ roleSessionName: profile.role_session_name,
405
+ roleAssumerWithWebIdentity: options.roleAssumerWithWebIdentity,
406
+ logger: options.logger,
407
+ parentClientConfig: options.parentClientConfig
408
+ })({ callerClientConfig }).then((creds) => require_setCredentialFeature.setCredentialFeature(creds, "CREDENTIALS_PROFILE_STS_WEB_ID_TOKEN", "q")));
409
+ //#endregion
410
+ //#region ../../../node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveProfileData.js
411
+ var resolveProfileData = async (profileName, profiles, options, callerClientConfig, visitedProfiles = {}, isAssumeRoleRecursiveCall = false) => {
412
+ const data = profiles[profileName];
413
+ if (Object.keys(visitedProfiles).length > 0 && isStaticCredsProfile(data)) return resolveStaticCredentials(data, options);
414
+ if (isAssumeRoleRecursiveCall || isAssumeRoleProfile(data, {
415
+ profile: profileName,
416
+ logger: options.logger
417
+ })) return resolveAssumeRoleCredentials(profileName, profiles, options, callerClientConfig, visitedProfiles, resolveProfileData);
418
+ if (isStaticCredsProfile(data)) return resolveStaticCredentials(data, options);
419
+ if (isWebIdentityProfile(data)) return resolveWebIdentityCredentials(data, options, callerClientConfig);
420
+ if (isProcessProfile(data)) return resolveProcessCredentials(options, profileName);
421
+ if (isSsoProfile(data)) return await resolveSsoCredentials(profileName, data, options, callerClientConfig);
422
+ if (isLoginProfile(data)) return resolveLoginCredentials(profileName, options, callerClientConfig);
423
+ throw new require_CredentialsProviderError.CredentialsProviderError(`Could not resolve credentials using profile: [${profileName}] in configuration/credentials file(s).`, { logger: options.logger });
424
+ };
425
+ //#endregion
426
+ //#region ../../../node_modules/@aws-sdk/credential-provider-ini/dist-es/fromIni.js
427
+ var fromIni = (init = {}) => async ({ callerClientConfig } = {}) => {
428
+ init.logger?.debug("@aws-sdk/credential-provider-ini - fromIni");
429
+ const profiles = await require_parseKnownFiles.parseKnownFiles(init);
430
+ return resolveProfileData(require_loadSharedConfigFiles.getProfileName({ profile: init.profile ?? callerClientConfig?.profile }), profiles, init, callerClientConfig);
431
+ };
432
+ //#endregion
433
+ exports.fromIni = fromIni;