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