piclaw 0.0.20 → 0.0.21
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/.output/nitro.json +1 -1
- package/.output/public/assets/defult-D5RLDUrI.js +1 -0
- package/.output/public/assets/{dist-D-Hc5HbQ.js → dist-BH_oa-kv.js} +1 -1
- package/.output/public/assets/index-7JvURuHy.js +204 -0
- package/.output/public/assets/index-K43slwjJ.css +1 -0
- package/.output/public/index.html +11 -2
- package/.output/server/_chunks/app.mjs +138 -104
- package/.output/server/_chunks/config.mjs +4 -0
- package/.output/server/_chunks/dummy.mjs +1 -1
- package/.output/server/_chunks/logger.mjs +1 -1
- package/.output/server/_chunks/notes.mjs +1 -3
- package/.output/server/_chunks/renderer-template.mjs +1 -1
- package/.output/server/_chunks/sandbox.mjs +217 -0
- package/.output/server/_chunks/server.mjs +411 -291
- package/.output/server/_chunks/terminal.mjs +47 -8
- package/.output/server/_chunks/virtual.mjs +192 -54
- package/.output/server/_id_.delete.mjs +5 -2
- package/.output/server/_id_2.delete.mjs +8 -0
- package/.output/server/_jid_.delete.mjs +0 -1
- package/.output/server/_jid_.patch.mjs +21 -3
- package/.output/server/_jid_2.delete.mjs +0 -1
- package/.output/server/_libs/@acemir/cssom+[...].mjs +2269 -1137
- package/.output/server/_libs/@google/genai.mjs +348 -284
- package/.output/server/_libs/@mariozechner/pi-agent-core+[...].mjs +381 -2073
- package/.output/server/_libs/@mariozechner/pi-coding-agent+[...].mjs +236 -136
- package/.output/server/_libs/_.mjs +3 -2
- package/.output/server/_libs/_10.mjs +2 -4
- package/.output/server/_libs/_11.mjs +2 -4
- package/.output/server/_libs/_12.mjs +2 -3
- package/.output/server/_libs/_13.mjs +2 -3
- package/.output/server/_libs/_14.mjs +2 -4
- package/.output/server/_libs/_15.mjs +2 -4
- package/.output/server/_libs/_16.mjs +2 -3
- package/.output/server/_libs/_17.mjs +2 -4
- package/.output/server/_libs/_18.mjs +2 -2
- package/.output/server/_libs/_19.mjs +2 -2
- package/.output/server/_libs/_2.mjs +3 -3
- package/.output/server/_libs/_20.mjs +2 -2
- package/.output/server/_libs/_21.mjs +2 -2
- package/.output/server/_libs/_22.mjs +2 -2
- package/.output/server/_libs/_23.mjs +2 -2
- package/.output/server/_libs/_24.mjs +2 -2
- package/.output/server/_libs/_25.mjs +2 -2
- package/.output/server/_libs/_26.mjs +2 -2
- package/.output/server/_libs/_27.mjs +2 -2
- package/.output/server/_libs/_28.mjs +2 -2
- package/.output/server/_libs/_29.mjs +2 -2
- package/.output/server/_libs/_3.mjs +3 -3
- package/.output/server/_libs/_30.mjs +2 -2
- package/.output/server/_libs/_31.mjs +2 -2
- package/.output/server/_libs/_32.mjs +2 -2
- package/.output/server/_libs/_33.mjs +2 -2
- package/.output/server/_libs/_34.mjs +2 -2
- package/.output/server/_libs/_35.mjs +2 -2
- package/.output/server/_libs/_36.mjs +2 -2
- package/.output/server/_libs/_37.mjs +2 -2
- package/.output/server/_libs/_38.mjs +2 -2
- package/.output/server/_libs/_39.mjs +2 -2
- package/.output/server/_libs/_4.mjs +4 -3
- package/.output/server/_libs/_40.mjs +2 -2
- package/.output/server/_libs/_41.mjs +2 -2
- package/.output/server/_libs/_42.mjs +2 -2
- package/.output/server/_libs/_43.mjs +2 -2
- package/.output/server/_libs/_44.mjs +2 -2
- package/.output/server/_libs/_45.mjs +2 -2
- package/.output/server/_libs/_46.mjs +2 -2
- package/.output/server/_libs/_47.mjs +2 -2
- package/.output/server/_libs/_48.mjs +2 -2
- package/.output/server/_libs/_49.mjs +2 -2
- package/.output/server/_libs/_5.mjs +2 -3
- package/.output/server/_libs/_50.mjs +2 -2
- package/.output/server/_libs/_51.mjs +2 -2
- package/.output/server/_libs/_52.mjs +2 -2
- package/.output/server/_libs/_53.mjs +2 -2
- package/.output/server/_libs/_54.mjs +2 -2
- package/.output/server/_libs/_55.mjs +2 -2
- package/.output/server/_libs/_56.mjs +2 -2
- package/.output/server/_libs/_57.mjs +2 -2
- package/.output/server/_libs/_58.mjs +2 -2
- package/.output/server/_libs/_59.mjs +2 -2
- package/.output/server/_libs/_6.mjs +2 -3
- package/.output/server/_libs/_60.mjs +2 -2
- package/.output/server/_libs/_61.mjs +2 -2
- package/.output/server/_libs/_62.mjs +2 -2
- package/.output/server/_libs/_63.mjs +2 -2
- package/.output/server/_libs/_64.mjs +2 -2
- package/.output/server/_libs/_65.mjs +2 -2
- package/.output/server/_libs/_66.mjs +2 -2
- package/.output/server/_libs/_67.mjs +2 -2
- package/.output/server/_libs/_68.mjs +2 -2
- package/.output/server/_libs/_69.mjs +2 -2
- package/.output/server/_libs/_7.mjs +2 -5
- package/.output/server/_libs/_70.mjs +2 -2
- package/.output/server/_libs/_71.mjs +2 -2
- package/.output/server/_libs/_72.mjs +2 -2
- package/.output/server/_libs/_73.mjs +2 -2
- package/.output/server/_libs/_74.mjs +2 -2
- package/.output/server/_libs/_75.mjs +2 -2
- package/.output/server/_libs/_76.mjs +2 -2
- package/.output/server/_libs/_77.mjs +2 -2
- package/.output/server/_libs/_78.mjs +2 -2
- package/.output/server/_libs/_79.mjs +2 -2
- package/.output/server/_libs/_8.mjs +2 -3
- package/.output/server/_libs/_80.mjs +2 -2
- package/.output/server/_libs/_81.mjs +2 -2
- package/.output/server/_libs/_82.mjs +2 -2
- package/.output/server/_libs/_83.mjs +2 -2
- package/.output/server/_libs/_84.mjs +2 -2
- package/.output/server/_libs/_85.mjs +2 -2
- package/.output/server/_libs/_86.mjs +2 -2
- package/.output/server/_libs/_87.mjs +2 -2
- package/.output/server/_libs/_88.mjs +2 -2
- package/.output/server/_libs/_89.mjs +2 -2
- package/.output/server/_libs/_9.mjs +2 -4
- package/.output/server/_libs/_90.mjs +5 -2
- package/.output/server/_libs/_91.mjs +3 -2
- package/.output/server/_libs/_92.mjs +2 -2
- package/.output/server/_libs/_93.mjs +2 -2
- package/.output/server/_libs/_94.mjs +2 -2
- package/.output/server/_libs/agent-base.mjs +1 -1
- package/.output/server/_libs/cheerio+[...].mjs +1 -1
- package/.output/server/_libs/data-uri-to-buffer.mjs +2 -67
- package/.output/server/_libs/data-urls+[...].mjs +1 -1
- package/.output/server/_libs/diff.mjs +1 -1
- package/.output/server/_libs/exodus__bytes.mjs +99 -81
- package/.output/server/_libs/fetch-blob+node-domexception.mjs +1 -1
- package/.output/server/_libs/h3+rou3+srvx.mjs +34 -4
- package/.output/server/_libs/html-encoding-sniffer.mjs +1 -1
- package/.output/server/_libs/https-proxy-agent.mjs +2 -2
- package/.output/server/_libs/jsdom.mjs +1 -1
- package/.output/server/_libs/just-bash+[...].mjs +4676 -3916
- package/.output/server/_libs/mariozechner__jiti.mjs +1 -1
- package/.output/server/_libs/mariozechner__pi-ai.mjs +1472 -0
- package/.output/server/_libs/md4x.mjs +1 -1
- package/.output/server/_libs/node-fetch.mjs +14 -14
- package/.output/server/_libs/node-liblzma.mjs +1 -1
- package/.output/server/_libs/silvia-odwyer__photon-node.mjs +1 -1
- package/.output/server/_routes/api/auth/status.mjs +25 -6
- package/.output/server/_routes/api/config2.mjs +2 -0
- package/.output/server/_routes/api/files/groups.mjs +0 -1
- package/.output/server/_routes/api/groups.mjs +4 -2
- package/.output/server/_routes/api/groups2.mjs +14 -5
- package/.output/server/_routes/api/health.mjs +0 -1
- package/.output/server/_routes/api/pi/apikey.mjs +0 -1
- package/.output/server/_routes/api/pi/apikey_providers.mjs +0 -1
- package/.output/server/_routes/api/pi/commands.mjs +1 -2
- package/.output/server/_routes/api/pi/login/events.mjs +0 -1
- package/.output/server/_routes/api/pi/login/respond.mjs +0 -1
- package/.output/server/_routes/api/pi/login.mjs +0 -1
- package/.output/server/_routes/api/pi/logout.mjs +0 -1
- package/.output/server/_routes/api/pi/models.mjs +0 -1
- package/.output/server/_routes/api/pi/status.mjs +0 -1
- package/.output/server/_routes/api/sandbox.mjs +26 -0
- package/.output/server/_routes/api/sandbox2.mjs +17 -0
- package/.output/server/_routes/api/send.mjs +12 -12
- package/.output/server/_routes/api/status.mjs +0 -1
- package/.output/server/_routes/api/stop.mjs +0 -1
- package/.output/server/_routes/api/tasks2.mjs +0 -1
- package/.output/server/_routes/api/telegram/setup.mjs +0 -1
- package/.output/server/_routes/api/telegram/status.mjs +0 -1
- package/.output/server/_routes/api/terminal2.mjs +2 -1
- package/.output/server/_routes/api/tunnel/setup.mjs +0 -1
- package/.output/server/_runtime.mjs +1 -2
- package/.output/server/index.mjs +1 -1
- package/.output/server/node_modules/amdefine/amdefine.js +301 -0
- package/.output/server/node_modules/amdefine/package.json +16 -0
- package/.output/server/node_modules/compressjs/lib/BWT.js +420 -0
- package/.output/server/node_modules/compressjs/lib/BWTC.js +234 -0
- package/.output/server/node_modules/compressjs/lib/BitStream.js +108 -0
- package/.output/server/node_modules/compressjs/lib/Bzip2.js +936 -0
- package/.output/server/node_modules/compressjs/lib/CRC32.js +105 -0
- package/.output/server/node_modules/compressjs/lib/Context1Model.js +56 -0
- package/.output/server/node_modules/compressjs/lib/DefSumModel.js +152 -0
- package/.output/server/node_modules/compressjs/lib/DeflateDistanceModel.js +55 -0
- package/.output/server/node_modules/compressjs/lib/Dmc.js +197 -0
- package/.output/server/node_modules/compressjs/lib/DummyRangeCoder.js +81 -0
- package/.output/server/node_modules/compressjs/lib/FenwickModel.js +194 -0
- package/.output/server/node_modules/compressjs/lib/Huffman.js +514 -0
- package/.output/server/node_modules/compressjs/lib/HuffmanAllocator.js +227 -0
- package/.output/server/node_modules/compressjs/lib/LogDistanceModel.js +46 -0
- package/.output/server/node_modules/compressjs/lib/Lzjb.js +300 -0
- package/.output/server/node_modules/compressjs/lib/LzjbR.js +241 -0
- package/.output/server/node_modules/compressjs/lib/Lzp3.js +273 -0
- package/.output/server/node_modules/compressjs/lib/MTFModel.js +208 -0
- package/.output/server/node_modules/compressjs/lib/NoModel.js +46 -0
- package/.output/server/node_modules/compressjs/lib/PPM.js +343 -0
- package/.output/server/node_modules/compressjs/lib/RangeCoder.js +238 -0
- package/.output/server/node_modules/compressjs/lib/Simple.js +111 -0
- package/.output/server/node_modules/compressjs/lib/Stream.js +53 -0
- package/.output/server/node_modules/compressjs/lib/Util.js +324 -0
- package/.output/server/node_modules/compressjs/lib/freeze.js +14 -0
- package/.output/server/node_modules/compressjs/main.js +29 -0
- package/.output/server/node_modules/compressjs/package.json +35 -0
- package/.output/server/package.json +2 -1
- package/README.md +10 -1
- package/lib/index.d.mts +1 -0
- package/lib/index.mjs +1 -0
- package/lib/piclaw.mjs +100 -0
- package/lib/utils.mjs +96 -0
- package/package.json +16 -11
- package/.output/public/assets/defult-DtwgaiMA.js +0 -1
- package/.output/public/assets/index-B5n0eraW.css +0 -1
- package/.output/public/assets/index-DUbn6fuj.js +0 -205
- package/.output/server/_libs/@aws-crypto/crc32+[...].mjs +0 -299
- package/.output/server/_libs/@aws-sdk/client-bedrock-runtime+[...].mjs +0 -17828
- package/.output/server/_libs/@aws-sdk/credential-provider-http+[...].mjs +0 -122
- package/.output/server/_libs/@aws-sdk/credential-provider-ini+[...].mjs +0 -417
- package/.output/server/_libs/@aws-sdk/credential-provider-process+[...].mjs +0 -54
- package/.output/server/_libs/@aws-sdk/credential-provider-sso+[...].mjs +0 -1151
- package/.output/server/_libs/@aws-sdk/credential-provider-web-identity+[...].mjs +0 -50
- package/.output/server/_libs/@smithy/credential-provider-imds+[...].mjs +0 -369
- package/.output/server/_libs/@tootallnate/quickjs-emscripten+[...].mjs +0 -3011
- package/.output/server/_libs/_100.mjs +0 -2
- package/.output/server/_libs/_101.mjs +0 -2
- package/.output/server/_libs/_102.mjs +0 -2
- package/.output/server/_libs/_103.mjs +0 -5
- package/.output/server/_libs/_104.mjs +0 -3
- package/.output/server/_libs/_105.mjs +0 -2
- package/.output/server/_libs/_106.mjs +0 -3
- package/.output/server/_libs/_107.mjs +0 -2
- package/.output/server/_libs/_108.mjs +0 -2
- package/.output/server/_libs/_95.mjs +0 -2
- package/.output/server/_libs/_96.mjs +0 -2
- package/.output/server/_libs/_97.mjs +0 -2
- package/.output/server/_libs/_98.mjs +0 -2
- package/.output/server/_libs/_99.mjs +0 -2
- package/.output/server/_libs/amdefine.mjs +0 -188
- package/.output/server/_libs/ast-types.mjs +0 -2270
- package/.output/server/_libs/aws-sdk__nested-clients.mjs +0 -3141
- package/.output/server/_libs/basic-ftp.mjs +0 -1906
- package/.output/server/_libs/compressjs.mjs +0 -50
- package/.output/server/_libs/degenerator+[...].mjs +0 -9964
- package/.output/server/_libs/get-uri.mjs +0 -413
- package/.output/server/_libs/http-proxy-agent.mjs +0 -123
- package/.output/server/_libs/ip-address.mjs +0 -1423
- package/.output/server/_libs/lru-cache.mjs +0 -732
- package/.output/server/_libs/netmask.mjs +0 -139
- package/.output/server/_libs/pac-proxy-agent+[...].mjs +0 -3104
- package/.output/server/_libs/proxy-agent+proxy-from-env.mjs +0 -204
- package/.output/server/_libs/smithy__core.mjs +0 -192
- package/.output/server/node_modules/tslib/modules/index.js +0 -70
- package/.output/server/node_modules/tslib/modules/package.json +0 -3
- package/.output/server/node_modules/tslib/package.json +0 -47
- package/.output/server/node_modules/tslib/tslib.js +0 -484
- package/bin/piclaw.mjs +0 -195
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { At as init_dist_es, Ft as require_client, Nt as CredentialsProviderError, St as HttpRequest, at as init_dist_es$2, gt as init_dist_es$4, it as dist_es_exports, lt as init_dist_es$3, ut as sdkStreamMixin, xt as init_dist_es$1, yt as NodeHttpHandler } from "./client-bedrock-runtime+[...].mjs";
|
|
2
|
-
import fs from "node:fs/promises";
|
|
3
|
-
init_dist_es();
|
|
4
|
-
var ECS_CONTAINER_HOST = "169.254.170.2";
|
|
5
|
-
var EKS_CONTAINER_HOST_IPv4 = "169.254.170.23";
|
|
6
|
-
var EKS_CONTAINER_HOST_IPv6 = "[fd00:ec2::23]";
|
|
7
|
-
const checkUrl = (url, logger) => {
|
|
8
|
-
if (url.protocol === "https:") return;
|
|
9
|
-
if (url.hostname === ECS_CONTAINER_HOST || url.hostname === EKS_CONTAINER_HOST_IPv4 || url.hostname === EKS_CONTAINER_HOST_IPv6) return;
|
|
10
|
-
if (url.hostname.includes("[")) {
|
|
11
|
-
if (url.hostname === "[::1]" || url.hostname === "[0000:0000:0000:0000:0000:0000:0000:0001]") return;
|
|
12
|
-
} else {
|
|
13
|
-
if (url.hostname === "localhost") return;
|
|
14
|
-
const ipComponents = url.hostname.split(".");
|
|
15
|
-
const inRange = (component) => {
|
|
16
|
-
const num = parseInt(component, 10);
|
|
17
|
-
return 0 <= num && num <= 255;
|
|
18
|
-
};
|
|
19
|
-
if (ipComponents[0] === "127" && inRange(ipComponents[1]) && inRange(ipComponents[2]) && inRange(ipComponents[3]) && ipComponents.length === 4) return;
|
|
20
|
-
}
|
|
21
|
-
throw new CredentialsProviderError(`URL not accepted. It must either be HTTPS or match one of the following:
|
|
22
|
-
- loopback CIDR 127.0.0.0/8 or [::1/128]
|
|
23
|
-
- ECS container host 169.254.170.2
|
|
24
|
-
- EKS container host 169.254.170.23 or [fd00:ec2::23]`, { logger });
|
|
25
|
-
};
|
|
26
|
-
init_dist_es();
|
|
27
|
-
init_dist_es$1();
|
|
28
|
-
init_dist_es$2();
|
|
29
|
-
init_dist_es$3();
|
|
30
|
-
function createGetRequest(url) {
|
|
31
|
-
return new HttpRequest({
|
|
32
|
-
protocol: url.protocol,
|
|
33
|
-
hostname: url.hostname,
|
|
34
|
-
port: Number(url.port),
|
|
35
|
-
path: url.pathname,
|
|
36
|
-
query: Array.from(url.searchParams.entries()).reduce((acc, [k, v]) => {
|
|
37
|
-
acc[k] = v;
|
|
38
|
-
return acc;
|
|
39
|
-
}, {}),
|
|
40
|
-
fragment: url.hash
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
async function getCredentials(response, logger) {
|
|
44
|
-
const str = await sdkStreamMixin(response.body).transformToString();
|
|
45
|
-
if (response.statusCode === 200) {
|
|
46
|
-
const parsed = JSON.parse(str);
|
|
47
|
-
if (typeof parsed.AccessKeyId !== "string" || typeof parsed.SecretAccessKey !== "string" || typeof parsed.Token !== "string" || typeof parsed.Expiration !== "string") throw new CredentialsProviderError("HTTP credential provider response not of the required format, an object matching: { AccessKeyId: string, SecretAccessKey: string, Token: string, Expiration: string(rfc3339) }", { logger });
|
|
48
|
-
return {
|
|
49
|
-
accessKeyId: parsed.AccessKeyId,
|
|
50
|
-
secretAccessKey: parsed.SecretAccessKey,
|
|
51
|
-
sessionToken: parsed.Token,
|
|
52
|
-
expiration: (0, dist_es_exports.parseRfc3339DateTime)(parsed.Expiration)
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
if (response.statusCode >= 400 && response.statusCode < 500) {
|
|
56
|
-
let parsedBody = {};
|
|
57
|
-
try {
|
|
58
|
-
parsedBody = JSON.parse(str);
|
|
59
|
-
} catch (e) {}
|
|
60
|
-
throw Object.assign(new CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger }), {
|
|
61
|
-
Code: parsedBody.Code,
|
|
62
|
-
Message: parsedBody.Message
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
throw new CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger });
|
|
66
|
-
}
|
|
67
|
-
const retryWrapper = (toRetry, maxRetries, delayMs) => {
|
|
68
|
-
return async () => {
|
|
69
|
-
for (let i = 0; i < maxRetries; ++i) try {
|
|
70
|
-
return await toRetry();
|
|
71
|
-
} catch (e) {
|
|
72
|
-
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
73
|
-
}
|
|
74
|
-
return await toRetry();
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
var import_client = require_client();
|
|
78
|
-
init_dist_es$4();
|
|
79
|
-
init_dist_es();
|
|
80
|
-
var AWS_CONTAINER_CREDENTIALS_RELATIVE_URI = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI";
|
|
81
|
-
var DEFAULT_LINK_LOCAL_HOST = "http://169.254.170.2";
|
|
82
|
-
var AWS_CONTAINER_CREDENTIALS_FULL_URI = "AWS_CONTAINER_CREDENTIALS_FULL_URI";
|
|
83
|
-
var AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE = "AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE";
|
|
84
|
-
var AWS_CONTAINER_AUTHORIZATION_TOKEN = "AWS_CONTAINER_AUTHORIZATION_TOKEN";
|
|
85
|
-
const fromHttp = (options = {}) => {
|
|
86
|
-
options.logger?.debug("@aws-sdk/credential-provider-http - fromHttp");
|
|
87
|
-
let host;
|
|
88
|
-
const relative = options.awsContainerCredentialsRelativeUri ?? process.env[AWS_CONTAINER_CREDENTIALS_RELATIVE_URI];
|
|
89
|
-
const full = options.awsContainerCredentialsFullUri ?? process.env[AWS_CONTAINER_CREDENTIALS_FULL_URI];
|
|
90
|
-
const token = options.awsContainerAuthorizationToken ?? process.env[AWS_CONTAINER_AUTHORIZATION_TOKEN];
|
|
91
|
-
const tokenFile = options.awsContainerAuthorizationTokenFile ?? process.env[AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE];
|
|
92
|
-
const warn = options.logger?.constructor?.name === "NoOpLogger" || !options.logger?.warn ? console.warn : options.logger.warn.bind(options.logger);
|
|
93
|
-
if (relative && full) {
|
|
94
|
-
warn("@aws-sdk/credential-provider-http: you have set both awsContainerCredentialsRelativeUri and awsContainerCredentialsFullUri.");
|
|
95
|
-
warn("awsContainerCredentialsFullUri will take precedence.");
|
|
96
|
-
}
|
|
97
|
-
if (token && tokenFile) {
|
|
98
|
-
warn("@aws-sdk/credential-provider-http: you have set both awsContainerAuthorizationToken and awsContainerAuthorizationTokenFile.");
|
|
99
|
-
warn("awsContainerAuthorizationToken will take precedence.");
|
|
100
|
-
}
|
|
101
|
-
if (full) host = full;
|
|
102
|
-
else if (relative) host = `${DEFAULT_LINK_LOCAL_HOST}${relative}`;
|
|
103
|
-
else throw new CredentialsProviderError(`No HTTP credential provider host provided.
|
|
104
|
-
Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI.`, { logger: options.logger });
|
|
105
|
-
const url = new URL(host);
|
|
106
|
-
checkUrl(url, options.logger);
|
|
107
|
-
const requestHandler = NodeHttpHandler.create({
|
|
108
|
-
requestTimeout: options.timeout ?? 1e3,
|
|
109
|
-
connectionTimeout: options.timeout ?? 1e3
|
|
110
|
-
});
|
|
111
|
-
return retryWrapper(async () => {
|
|
112
|
-
const request = createGetRequest(url);
|
|
113
|
-
if (token) request.headers.Authorization = token;
|
|
114
|
-
else if (tokenFile) request.headers.Authorization = (await fs.readFile(tokenFile)).toString();
|
|
115
|
-
try {
|
|
116
|
-
return getCredentials((await requestHandler.handle(request)).response).then((creds) => (0, import_client.setCredentialFeature)(creds, "CREDENTIALS_HTTP", "z"));
|
|
117
|
-
} catch (e) {
|
|
118
|
-
throw new CredentialsProviderError(String(e), { logger: options.logger });
|
|
119
|
-
}
|
|
120
|
-
}, options.maxRetries ?? 3, options.timeout ?? 1e3);
|
|
121
|
-
};
|
|
122
|
-
export { fromHttp as t };
|
|
@@ -1,417 +0,0 @@
|
|
|
1
|
-
import { s as __toESM } from "../../_runtime.mjs";
|
|
2
|
-
import { At as init_dist_es, Ft as require_client, Nt as CredentialsProviderError, Q as parseKnownFiles, St as HttpRequest, X as init_dist_es$1, et as readFile, jt as chain, rt as getProfileName, xt as init_dist_es$2 } from "./client-bedrock-runtime+[...].mjs";
|
|
3
|
-
import { promises } from "node:fs";
|
|
4
|
-
import { dirname, join } from "node:path";
|
|
5
|
-
import { createHash, createPrivateKey, createPublicKey, sign } from "node:crypto";
|
|
6
|
-
import { homedir } from "node:os";
|
|
7
|
-
var import_client = require_client();
|
|
8
|
-
init_dist_es();
|
|
9
|
-
const resolveCredentialSource = (credentialSource, profileName, logger) => {
|
|
10
|
-
const sourceProvidersMap = {
|
|
11
|
-
EcsContainer: async (options) => {
|
|
12
|
-
const { fromHttp } = await import("../_3.mjs");
|
|
13
|
-
const { fromContainerMetadata } = await import("../_15.mjs");
|
|
14
|
-
logger?.debug("@aws-sdk/credential-provider-ini - credential_source is EcsContainer");
|
|
15
|
-
return async () => chain(fromHttp(options ?? {}), fromContainerMetadata(options))().then(setNamedProvider);
|
|
16
|
-
},
|
|
17
|
-
Ec2InstanceMetadata: async (options) => {
|
|
18
|
-
logger?.debug("@aws-sdk/credential-provider-ini - credential_source is Ec2InstanceMetadata");
|
|
19
|
-
const { fromInstanceMetadata } = await import("../_15.mjs");
|
|
20
|
-
return async () => fromInstanceMetadata(options)().then(setNamedProvider);
|
|
21
|
-
},
|
|
22
|
-
Environment: async (options) => {
|
|
23
|
-
logger?.debug("@aws-sdk/credential-provider-ini - credential_source is Environment");
|
|
24
|
-
const { fromEnv } = await import("../_.mjs");
|
|
25
|
-
return async () => fromEnv(options)().then(setNamedProvider);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
if (credentialSource in sourceProvidersMap) return sourceProvidersMap[credentialSource];
|
|
29
|
-
else throw new CredentialsProviderError(`Unsupported credential source in profile ${profileName}. Got ${credentialSource}, expected EcsContainer or Ec2InstanceMetadata or Environment.`, { logger });
|
|
30
|
-
};
|
|
31
|
-
var setNamedProvider = (creds) => (0, import_client.setCredentialFeature)(creds, "CREDENTIALS_PROFILE_NAMED_PROVIDER", "p");
|
|
32
|
-
init_dist_es();
|
|
33
|
-
init_dist_es$1();
|
|
34
|
-
const isAssumeRoleProfile = (arg, { profile = "default", logger } = {}) => {
|
|
35
|
-
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, {
|
|
36
|
-
profile,
|
|
37
|
-
logger
|
|
38
|
-
}) || isCredentialSourceProfile(arg, {
|
|
39
|
-
profile,
|
|
40
|
-
logger
|
|
41
|
-
}));
|
|
42
|
-
};
|
|
43
|
-
var isAssumeRoleWithSourceProfile = (arg, { profile, logger }) => {
|
|
44
|
-
const withSourceProfile = typeof arg.source_profile === "string" && typeof arg.credential_source === "undefined";
|
|
45
|
-
if (withSourceProfile) logger?.debug?.(` ${profile} isAssumeRoleWithSourceProfile source_profile=${arg.source_profile}`);
|
|
46
|
-
return withSourceProfile;
|
|
47
|
-
};
|
|
48
|
-
var isCredentialSourceProfile = (arg, { profile, logger }) => {
|
|
49
|
-
const withProviderProfile = typeof arg.credential_source === "string" && typeof arg.source_profile === "undefined";
|
|
50
|
-
if (withProviderProfile) logger?.debug?.(` ${profile} isCredentialSourceProfile credential_source=${arg.credential_source}`);
|
|
51
|
-
return withProviderProfile;
|
|
52
|
-
};
|
|
53
|
-
const resolveAssumeRoleCredentials = async (profileName, profiles, options, callerClientConfig, visitedProfiles = {}, resolveProfileData) => {
|
|
54
|
-
options.logger?.debug("@aws-sdk/credential-provider-ini - resolveAssumeRoleCredentials (STS)");
|
|
55
|
-
const profileData = profiles[profileName];
|
|
56
|
-
const { source_profile, region } = profileData;
|
|
57
|
-
if (!options.roleAssumer) {
|
|
58
|
-
const { getDefaultRoleAssumer } = await import("../_11.mjs").then((m) => /* @__PURE__ */ __toESM(m.default));
|
|
59
|
-
options.roleAssumer = getDefaultRoleAssumer({
|
|
60
|
-
...options.clientConfig,
|
|
61
|
-
credentialProviderLogger: options.logger,
|
|
62
|
-
parentClientConfig: {
|
|
63
|
-
...callerClientConfig,
|
|
64
|
-
...options?.parentClientConfig,
|
|
65
|
-
region: region ?? options?.parentClientConfig?.region ?? callerClientConfig?.region
|
|
66
|
-
}
|
|
67
|
-
}, options.clientPlugins);
|
|
68
|
-
}
|
|
69
|
-
if (source_profile && source_profile in visitedProfiles) throw new CredentialsProviderError(`Detected a cycle attempting to resolve credentials for profile ${getProfileName(options)}. Profiles visited: ` + Object.keys(visitedProfiles).join(", "), { logger: options.logger });
|
|
70
|
-
options.logger?.debug(`@aws-sdk/credential-provider-ini - finding credential resolver using ${source_profile ? `source_profile=[${source_profile}]` : `profile=[${profileName}]`}`);
|
|
71
|
-
const sourceCredsProvider = source_profile ? resolveProfileData(source_profile, profiles, options, callerClientConfig, {
|
|
72
|
-
...visitedProfiles,
|
|
73
|
-
[source_profile]: true
|
|
74
|
-
}, isCredentialSourceWithoutRoleArn(profiles[source_profile] ?? {})) : (await resolveCredentialSource(profileData.credential_source, profileName, options.logger)(options))();
|
|
75
|
-
if (isCredentialSourceWithoutRoleArn(profileData)) return sourceCredsProvider.then((creds) => (0, import_client.setCredentialFeature)(creds, "CREDENTIALS_PROFILE_SOURCE_PROFILE", "o"));
|
|
76
|
-
else {
|
|
77
|
-
const params = {
|
|
78
|
-
RoleArn: profileData.role_arn,
|
|
79
|
-
RoleSessionName: profileData.role_session_name || `aws-sdk-js-${Date.now()}`,
|
|
80
|
-
ExternalId: profileData.external_id,
|
|
81
|
-
DurationSeconds: parseInt(profileData.duration_seconds || "3600", 10)
|
|
82
|
-
};
|
|
83
|
-
const { mfa_serial } = profileData;
|
|
84
|
-
if (mfa_serial) {
|
|
85
|
-
if (!options.mfaCodeProvider) throw new CredentialsProviderError(`Profile ${profileName} requires multi-factor authentication, but no MFA code callback was provided.`, {
|
|
86
|
-
logger: options.logger,
|
|
87
|
-
tryNextLink: false
|
|
88
|
-
});
|
|
89
|
-
params.SerialNumber = mfa_serial;
|
|
90
|
-
params.TokenCode = await options.mfaCodeProvider(mfa_serial);
|
|
91
|
-
}
|
|
92
|
-
const sourceCreds = await sourceCredsProvider;
|
|
93
|
-
return options.roleAssumer(sourceCreds, params).then((creds) => (0, import_client.setCredentialFeature)(creds, "CREDENTIALS_PROFILE_SOURCE_PROFILE", "o"));
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
var isCredentialSourceWithoutRoleArn = (section) => {
|
|
97
|
-
return !section.role_arn && !!section.credential_source;
|
|
98
|
-
};
|
|
99
|
-
init_dist_es();
|
|
100
|
-
init_dist_es$2();
|
|
101
|
-
init_dist_es$1();
|
|
102
|
-
var LoginCredentialsFetcher = class LoginCredentialsFetcher {
|
|
103
|
-
profileData;
|
|
104
|
-
init;
|
|
105
|
-
callerClientConfig;
|
|
106
|
-
static REFRESH_THRESHOLD = 300 * 1e3;
|
|
107
|
-
constructor(profileData, init, callerClientConfig) {
|
|
108
|
-
this.profileData = profileData;
|
|
109
|
-
this.init = init;
|
|
110
|
-
this.callerClientConfig = callerClientConfig;
|
|
111
|
-
}
|
|
112
|
-
async loadCredentials() {
|
|
113
|
-
const token = await this.loadToken();
|
|
114
|
-
if (!token) throw new CredentialsProviderError(`Failed to load a token for session ${this.loginSession}, please re-authenticate using aws login`, {
|
|
115
|
-
tryNextLink: false,
|
|
116
|
-
logger: this.logger
|
|
117
|
-
});
|
|
118
|
-
const accessToken = token.accessToken;
|
|
119
|
-
const now = Date.now();
|
|
120
|
-
if (new Date(accessToken.expiresAt).getTime() - now <= LoginCredentialsFetcher.REFRESH_THRESHOLD) return this.refresh(token);
|
|
121
|
-
return {
|
|
122
|
-
accessKeyId: accessToken.accessKeyId,
|
|
123
|
-
secretAccessKey: accessToken.secretAccessKey,
|
|
124
|
-
sessionToken: accessToken.sessionToken,
|
|
125
|
-
accountId: accessToken.accountId,
|
|
126
|
-
expiration: new Date(accessToken.expiresAt)
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
get logger() {
|
|
130
|
-
return this.init?.logger;
|
|
131
|
-
}
|
|
132
|
-
get loginSession() {
|
|
133
|
-
return this.profileData.login_session;
|
|
134
|
-
}
|
|
135
|
-
async refresh(token) {
|
|
136
|
-
const { SigninClient, CreateOAuth2TokenCommand } = await import("../_9.mjs").then((m) => /* @__PURE__ */ __toESM(m.default));
|
|
137
|
-
const { logger, userAgentAppId } = this.callerClientConfig ?? {};
|
|
138
|
-
const isH2 = (requestHandler) => {
|
|
139
|
-
return requestHandler?.metadata?.handlerProtocol === "h2";
|
|
140
|
-
};
|
|
141
|
-
const requestHandler = isH2(this.callerClientConfig?.requestHandler) ? void 0 : this.callerClientConfig?.requestHandler;
|
|
142
|
-
const client = new SigninClient({
|
|
143
|
-
credentials: {
|
|
144
|
-
accessKeyId: "",
|
|
145
|
-
secretAccessKey: ""
|
|
146
|
-
},
|
|
147
|
-
region: this.profileData.region ?? await this.callerClientConfig?.region?.() ?? process.env.AWS_REGION,
|
|
148
|
-
requestHandler,
|
|
149
|
-
logger,
|
|
150
|
-
userAgentAppId,
|
|
151
|
-
...this.init?.clientConfig
|
|
152
|
-
});
|
|
153
|
-
this.createDPoPInterceptor(client.middlewareStack);
|
|
154
|
-
const commandInput = { tokenInput: {
|
|
155
|
-
clientId: token.clientId,
|
|
156
|
-
refreshToken: token.refreshToken,
|
|
157
|
-
grantType: "refresh_token"
|
|
158
|
-
} };
|
|
159
|
-
try {
|
|
160
|
-
const response = await client.send(new CreateOAuth2TokenCommand(commandInput));
|
|
161
|
-
const { accessKeyId, secretAccessKey, sessionToken } = response.tokenOutput?.accessToken ?? {};
|
|
162
|
-
const { refreshToken, expiresIn } = response.tokenOutput ?? {};
|
|
163
|
-
if (!accessKeyId || !secretAccessKey || !sessionToken || !refreshToken) throw new CredentialsProviderError("Token refresh response missing required fields", {
|
|
164
|
-
logger: this.logger,
|
|
165
|
-
tryNextLink: false
|
|
166
|
-
});
|
|
167
|
-
const expiresInMs = (expiresIn ?? 900) * 1e3;
|
|
168
|
-
const expiration = new Date(Date.now() + expiresInMs);
|
|
169
|
-
const updatedToken = {
|
|
170
|
-
...token,
|
|
171
|
-
accessToken: {
|
|
172
|
-
...token.accessToken,
|
|
173
|
-
accessKeyId,
|
|
174
|
-
secretAccessKey,
|
|
175
|
-
sessionToken,
|
|
176
|
-
expiresAt: expiration.toISOString()
|
|
177
|
-
},
|
|
178
|
-
refreshToken
|
|
179
|
-
};
|
|
180
|
-
await this.saveToken(updatedToken);
|
|
181
|
-
const newAccessToken = updatedToken.accessToken;
|
|
182
|
-
return {
|
|
183
|
-
accessKeyId: newAccessToken.accessKeyId,
|
|
184
|
-
secretAccessKey: newAccessToken.secretAccessKey,
|
|
185
|
-
sessionToken: newAccessToken.sessionToken,
|
|
186
|
-
accountId: newAccessToken.accountId,
|
|
187
|
-
expiration
|
|
188
|
-
};
|
|
189
|
-
} catch (error) {
|
|
190
|
-
if (error.name === "AccessDeniedException") {
|
|
191
|
-
const errorType = error.error;
|
|
192
|
-
let message;
|
|
193
|
-
switch (errorType) {
|
|
194
|
-
case "TOKEN_EXPIRED":
|
|
195
|
-
message = "Your session has expired. Please reauthenticate.";
|
|
196
|
-
break;
|
|
197
|
-
case "USER_CREDENTIALS_CHANGED":
|
|
198
|
-
message = "Unable to refresh credentials because of a change in your password. Please reauthenticate with your new password.";
|
|
199
|
-
break;
|
|
200
|
-
case "INSUFFICIENT_PERMISSIONS":
|
|
201
|
-
message = "Unable to refresh credentials due to insufficient permissions. You may be missing permission for the 'CreateOAuth2Token' action.";
|
|
202
|
-
break;
|
|
203
|
-
default: message = `Failed to refresh token: ${String(error)}. Please re-authenticate using \`aws login\``;
|
|
204
|
-
}
|
|
205
|
-
throw new CredentialsProviderError(message, {
|
|
206
|
-
logger: this.logger,
|
|
207
|
-
tryNextLink: false
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
throw new CredentialsProviderError(`Failed to refresh token: ${String(error)}. Please re-authenticate using aws login`, { logger: this.logger });
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
async loadToken() {
|
|
214
|
-
const tokenFilePath = this.getTokenFilePath();
|
|
215
|
-
try {
|
|
216
|
-
let tokenData;
|
|
217
|
-
try {
|
|
218
|
-
tokenData = await readFile(tokenFilePath, { ignoreCache: this.init?.ignoreCache });
|
|
219
|
-
} catch {
|
|
220
|
-
tokenData = await promises.readFile(tokenFilePath, "utf8");
|
|
221
|
-
}
|
|
222
|
-
const token = JSON.parse(tokenData);
|
|
223
|
-
const missingFields = [
|
|
224
|
-
"accessToken",
|
|
225
|
-
"clientId",
|
|
226
|
-
"refreshToken",
|
|
227
|
-
"dpopKey"
|
|
228
|
-
].filter((k) => !token[k]);
|
|
229
|
-
if (!token.accessToken?.accountId) missingFields.push("accountId");
|
|
230
|
-
if (missingFields.length > 0) throw new CredentialsProviderError(`Token validation failed, missing fields: ${missingFields.join(", ")}`, {
|
|
231
|
-
logger: this.logger,
|
|
232
|
-
tryNextLink: false
|
|
233
|
-
});
|
|
234
|
-
return token;
|
|
235
|
-
} catch (error) {
|
|
236
|
-
throw new CredentialsProviderError(`Failed to load token from ${tokenFilePath}: ${String(error)}`, {
|
|
237
|
-
logger: this.logger,
|
|
238
|
-
tryNextLink: false
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
async saveToken(token) {
|
|
243
|
-
const tokenFilePath = this.getTokenFilePath();
|
|
244
|
-
const directory = dirname(tokenFilePath);
|
|
245
|
-
try {
|
|
246
|
-
await promises.mkdir(directory, { recursive: true });
|
|
247
|
-
} catch (error) {}
|
|
248
|
-
await promises.writeFile(tokenFilePath, JSON.stringify(token, null, 2), "utf8");
|
|
249
|
-
}
|
|
250
|
-
getTokenFilePath() {
|
|
251
|
-
const directory = process.env.AWS_LOGIN_CACHE_DIRECTORY ?? join(homedir(), ".aws", "login", "cache");
|
|
252
|
-
const loginSessionBytes = Buffer.from(this.loginSession, "utf8");
|
|
253
|
-
return join(directory, `${createHash("sha256").update(loginSessionBytes).digest("hex")}.json`);
|
|
254
|
-
}
|
|
255
|
-
derToRawSignature(derSignature) {
|
|
256
|
-
let offset = 2;
|
|
257
|
-
if (derSignature[offset] !== 2) throw new Error("Invalid DER signature");
|
|
258
|
-
offset++;
|
|
259
|
-
const rLength = derSignature[offset++];
|
|
260
|
-
let r = derSignature.subarray(offset, offset + rLength);
|
|
261
|
-
offset += rLength;
|
|
262
|
-
if (derSignature[offset] !== 2) throw new Error("Invalid DER signature");
|
|
263
|
-
offset++;
|
|
264
|
-
const sLength = derSignature[offset++];
|
|
265
|
-
let s = derSignature.subarray(offset, offset + sLength);
|
|
266
|
-
r = r[0] === 0 ? r.subarray(1) : r;
|
|
267
|
-
s = s[0] === 0 ? s.subarray(1) : s;
|
|
268
|
-
const rPadded = Buffer.concat([Buffer.alloc(32 - r.length), r]);
|
|
269
|
-
const sPadded = Buffer.concat([Buffer.alloc(32 - s.length), s]);
|
|
270
|
-
return Buffer.concat([rPadded, sPadded]);
|
|
271
|
-
}
|
|
272
|
-
createDPoPInterceptor(middlewareStack) {
|
|
273
|
-
middlewareStack.add((next) => async (args) => {
|
|
274
|
-
if (HttpRequest.isInstance(args.request)) {
|
|
275
|
-
const request = args.request;
|
|
276
|
-
const actualEndpoint = `${request.protocol}//${request.hostname}${request.port ? `:${request.port}` : ""}${request.path}`;
|
|
277
|
-
const dpop = await this.generateDpop(request.method, actualEndpoint);
|
|
278
|
-
request.headers = {
|
|
279
|
-
...request.headers,
|
|
280
|
-
DPoP: dpop
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
return next(args);
|
|
284
|
-
}, {
|
|
285
|
-
step: "finalizeRequest",
|
|
286
|
-
name: "dpopInterceptor",
|
|
287
|
-
override: true
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
async generateDpop(method = "POST", endpoint) {
|
|
291
|
-
const token = await this.loadToken();
|
|
292
|
-
try {
|
|
293
|
-
const privateKey = createPrivateKey({
|
|
294
|
-
key: token.dpopKey,
|
|
295
|
-
format: "pem",
|
|
296
|
-
type: "sec1"
|
|
297
|
-
});
|
|
298
|
-
const publicDer = createPublicKey(privateKey).export({
|
|
299
|
-
format: "der",
|
|
300
|
-
type: "spki"
|
|
301
|
-
});
|
|
302
|
-
let pointStart = -1;
|
|
303
|
-
for (let i = 0; i < publicDer.length; i++) if (publicDer[i] === 4) {
|
|
304
|
-
pointStart = i;
|
|
305
|
-
break;
|
|
306
|
-
}
|
|
307
|
-
const x = publicDer.slice(pointStart + 1, pointStart + 33);
|
|
308
|
-
const y = publicDer.slice(pointStart + 33, pointStart + 65);
|
|
309
|
-
const header = {
|
|
310
|
-
alg: "ES256",
|
|
311
|
-
typ: "dpop+jwt",
|
|
312
|
-
jwk: {
|
|
313
|
-
kty: "EC",
|
|
314
|
-
crv: "P-256",
|
|
315
|
-
x: x.toString("base64url"),
|
|
316
|
-
y: y.toString("base64url")
|
|
317
|
-
}
|
|
318
|
-
};
|
|
319
|
-
const payload = {
|
|
320
|
-
jti: crypto.randomUUID(),
|
|
321
|
-
htm: method,
|
|
322
|
-
htu: endpoint,
|
|
323
|
-
iat: Math.floor(Date.now() / 1e3)
|
|
324
|
-
};
|
|
325
|
-
const message = `${Buffer.from(JSON.stringify(header)).toString("base64url")}.${Buffer.from(JSON.stringify(payload)).toString("base64url")}`;
|
|
326
|
-
const asn1Signature = sign("sha256", Buffer.from(message), privateKey);
|
|
327
|
-
return `${message}.${this.derToRawSignature(asn1Signature).toString("base64url")}`;
|
|
328
|
-
} catch (error) {
|
|
329
|
-
throw new CredentialsProviderError(`Failed to generate Dpop proof: ${error instanceof Error ? error.message : String(error)}`, {
|
|
330
|
-
logger: this.logger,
|
|
331
|
-
tryNextLink: false
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
};
|
|
336
|
-
init_dist_es();
|
|
337
|
-
init_dist_es$1();
|
|
338
|
-
const fromLoginCredentials = (init) => async ({ callerClientConfig } = {}) => {
|
|
339
|
-
init?.logger?.debug?.("@aws-sdk/credential-providers - fromLoginCredentials");
|
|
340
|
-
const profiles = await parseKnownFiles(init || {});
|
|
341
|
-
const profileName = getProfileName({ profile: init?.profile ?? callerClientConfig?.profile });
|
|
342
|
-
const profile = profiles[profileName];
|
|
343
|
-
if (!profile?.login_session) throw new CredentialsProviderError(`Profile ${profileName} does not contain login_session.`, {
|
|
344
|
-
tryNextLink: true,
|
|
345
|
-
logger: init?.logger
|
|
346
|
-
});
|
|
347
|
-
return (0, import_client.setCredentialFeature)(await new LoginCredentialsFetcher(profile, init, callerClientConfig).loadCredentials(), "CREDENTIALS_LOGIN", "AD");
|
|
348
|
-
};
|
|
349
|
-
const isLoginProfile = (data) => {
|
|
350
|
-
return Boolean(data && data.login_session);
|
|
351
|
-
};
|
|
352
|
-
const resolveLoginCredentials = async (profileName, options, callerClientConfig) => {
|
|
353
|
-
return (0, import_client.setCredentialFeature)(await fromLoginCredentials({
|
|
354
|
-
...options,
|
|
355
|
-
profile: profileName
|
|
356
|
-
})({ callerClientConfig }), "CREDENTIALS_PROFILE_LOGIN", "AC");
|
|
357
|
-
};
|
|
358
|
-
const isProcessProfile = (arg) => Boolean(arg) && typeof arg === "object" && typeof arg.credential_process === "string";
|
|
359
|
-
const resolveProcessCredentials = async (options, profile) => import("../_5.mjs").then(({ fromProcess }) => fromProcess({
|
|
360
|
-
...options,
|
|
361
|
-
profile
|
|
362
|
-
})().then((creds) => (0, import_client.setCredentialFeature)(creds, "CREDENTIALS_PROFILE_PROCESS", "v")));
|
|
363
|
-
const resolveSsoCredentials = async (profile, profileData, options = {}, callerClientConfig) => {
|
|
364
|
-
const { fromSSO } = await import("../_6.mjs");
|
|
365
|
-
return fromSSO({
|
|
366
|
-
profile,
|
|
367
|
-
logger: options.logger,
|
|
368
|
-
parentClientConfig: options.parentClientConfig,
|
|
369
|
-
clientConfig: options.clientConfig
|
|
370
|
-
})({ callerClientConfig }).then((creds) => {
|
|
371
|
-
if (profileData.sso_session) return (0, import_client.setCredentialFeature)(creds, "CREDENTIALS_PROFILE_SSO", "r");
|
|
372
|
-
else return (0, import_client.setCredentialFeature)(creds, "CREDENTIALS_PROFILE_SSO_LEGACY", "t");
|
|
373
|
-
});
|
|
374
|
-
};
|
|
375
|
-
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");
|
|
376
|
-
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;
|
|
377
|
-
const resolveStaticCredentials = async (profile, options) => {
|
|
378
|
-
options?.logger?.debug("@aws-sdk/credential-provider-ini - resolveStaticCredentials");
|
|
379
|
-
return (0, import_client.setCredentialFeature)({
|
|
380
|
-
accessKeyId: profile.aws_access_key_id,
|
|
381
|
-
secretAccessKey: profile.aws_secret_access_key,
|
|
382
|
-
sessionToken: profile.aws_session_token,
|
|
383
|
-
...profile.aws_credential_scope && { credentialScope: profile.aws_credential_scope },
|
|
384
|
-
...profile.aws_account_id && { accountId: profile.aws_account_id }
|
|
385
|
-
}, "CREDENTIALS_PROFILE", "n");
|
|
386
|
-
};
|
|
387
|
-
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;
|
|
388
|
-
const resolveWebIdentityCredentials = async (profile, options, callerClientConfig) => import("../_8.mjs").then(({ fromTokenFile }) => fromTokenFile({
|
|
389
|
-
webIdentityTokenFile: profile.web_identity_token_file,
|
|
390
|
-
roleArn: profile.role_arn,
|
|
391
|
-
roleSessionName: profile.role_session_name,
|
|
392
|
-
roleAssumerWithWebIdentity: options.roleAssumerWithWebIdentity,
|
|
393
|
-
logger: options.logger,
|
|
394
|
-
parentClientConfig: options.parentClientConfig
|
|
395
|
-
})({ callerClientConfig }).then((creds) => (0, import_client.setCredentialFeature)(creds, "CREDENTIALS_PROFILE_STS_WEB_ID_TOKEN", "q")));
|
|
396
|
-
init_dist_es();
|
|
397
|
-
const resolveProfileData = async (profileName, profiles, options, callerClientConfig, visitedProfiles = {}, isAssumeRoleRecursiveCall = false) => {
|
|
398
|
-
const data = profiles[profileName];
|
|
399
|
-
if (Object.keys(visitedProfiles).length > 0 && isStaticCredsProfile(data)) return resolveStaticCredentials(data, options);
|
|
400
|
-
if (isAssumeRoleRecursiveCall || isAssumeRoleProfile(data, {
|
|
401
|
-
profile: profileName,
|
|
402
|
-
logger: options.logger
|
|
403
|
-
})) return resolveAssumeRoleCredentials(profileName, profiles, options, callerClientConfig, visitedProfiles, resolveProfileData);
|
|
404
|
-
if (isStaticCredsProfile(data)) return resolveStaticCredentials(data, options);
|
|
405
|
-
if (isWebIdentityProfile(data)) return resolveWebIdentityCredentials(data, options, callerClientConfig);
|
|
406
|
-
if (isProcessProfile(data)) return resolveProcessCredentials(options, profileName);
|
|
407
|
-
if (isSsoProfile(data)) return await resolveSsoCredentials(profileName, data, options, callerClientConfig);
|
|
408
|
-
if (isLoginProfile(data)) return resolveLoginCredentials(profileName, options, callerClientConfig);
|
|
409
|
-
throw new CredentialsProviderError(`Could not resolve credentials using profile: [${profileName}] in configuration/credentials file(s).`, { logger: options.logger });
|
|
410
|
-
};
|
|
411
|
-
init_dist_es$1();
|
|
412
|
-
const fromIni = (init = {}) => async ({ callerClientConfig } = {}) => {
|
|
413
|
-
init.logger?.debug("@aws-sdk/credential-provider-ini - fromIni");
|
|
414
|
-
const profiles = await parseKnownFiles(init);
|
|
415
|
-
return resolveProfileData(getProfileName({ profile: init.profile ?? callerClientConfig?.profile }), profiles, init, callerClientConfig);
|
|
416
|
-
};
|
|
417
|
-
export { fromIni as t };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { At as init_dist_es, Ft as require_client, Nt as CredentialsProviderError, Q as parseKnownFiles, X as init_dist_es$1, Z as externalDataInterceptor, rt as getProfileName } from "./client-bedrock-runtime+[...].mjs";
|
|
2
|
-
import { exec } from "node:child_process";
|
|
3
|
-
import { promisify } from "node:util";
|
|
4
|
-
var import_client = require_client();
|
|
5
|
-
const getValidatedProcessCredentials = (profileName, data, profiles) => {
|
|
6
|
-
if (data.Version !== 1) throw Error(`Profile ${profileName} credential_process did not return Version 1.`);
|
|
7
|
-
if (data.AccessKeyId === void 0 || data.SecretAccessKey === void 0) throw Error(`Profile ${profileName} credential_process returned invalid credentials.`);
|
|
8
|
-
if (data.Expiration) {
|
|
9
|
-
const currentTime = /* @__PURE__ */ new Date();
|
|
10
|
-
if (new Date(data.Expiration) < currentTime) throw Error(`Profile ${profileName} credential_process returned expired credentials.`);
|
|
11
|
-
}
|
|
12
|
-
let accountId = data.AccountId;
|
|
13
|
-
if (!accountId && profiles?.[profileName]?.aws_account_id) accountId = profiles[profileName].aws_account_id;
|
|
14
|
-
const credentials = {
|
|
15
|
-
accessKeyId: data.AccessKeyId,
|
|
16
|
-
secretAccessKey: data.SecretAccessKey,
|
|
17
|
-
...data.SessionToken && { sessionToken: data.SessionToken },
|
|
18
|
-
...data.Expiration && { expiration: new Date(data.Expiration) },
|
|
19
|
-
...data.CredentialScope && { credentialScope: data.CredentialScope },
|
|
20
|
-
...accountId && { accountId }
|
|
21
|
-
};
|
|
22
|
-
(0, import_client.setCredentialFeature)(credentials, "CREDENTIALS_PROCESS", "w");
|
|
23
|
-
return credentials;
|
|
24
|
-
};
|
|
25
|
-
init_dist_es();
|
|
26
|
-
init_dist_es$1();
|
|
27
|
-
const resolveProcessCredentials = async (profileName, profiles, logger) => {
|
|
28
|
-
const profile = profiles[profileName];
|
|
29
|
-
if (profiles[profileName]) {
|
|
30
|
-
const credentialProcess = profile["credential_process"];
|
|
31
|
-
if (credentialProcess !== void 0) {
|
|
32
|
-
const execPromise = promisify(externalDataInterceptor?.getTokenRecord?.().exec ?? exec);
|
|
33
|
-
try {
|
|
34
|
-
const { stdout } = await execPromise(credentialProcess);
|
|
35
|
-
let data;
|
|
36
|
-
try {
|
|
37
|
-
data = JSON.parse(stdout.trim());
|
|
38
|
-
} catch {
|
|
39
|
-
throw Error(`Profile ${profileName} credential_process returned invalid JSON.`);
|
|
40
|
-
}
|
|
41
|
-
return getValidatedProcessCredentials(profileName, data, profiles);
|
|
42
|
-
} catch (error) {
|
|
43
|
-
throw new CredentialsProviderError(error.message, { logger });
|
|
44
|
-
}
|
|
45
|
-
} else throw new CredentialsProviderError(`Profile ${profileName} did not contain credential_process.`, { logger });
|
|
46
|
-
} else throw new CredentialsProviderError(`Profile ${profileName} could not be found in shared credentials file.`, { logger });
|
|
47
|
-
};
|
|
48
|
-
init_dist_es$1();
|
|
49
|
-
const fromProcess = (init = {}) => async ({ callerClientConfig } = {}) => {
|
|
50
|
-
init.logger?.debug("@aws-sdk/credential-provider-process - fromProcess");
|
|
51
|
-
const profiles = await parseKnownFiles(init);
|
|
52
|
-
return resolveProcessCredentials(getProfileName({ profile: init.profile ?? callerClientConfig?.profile }), profiles, init.logger);
|
|
53
|
-
};
|
|
54
|
-
export { fromProcess as t };
|