appos 0.1.0
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/README.md +399 -0
- package/build/client/assets/IconMail-BZadZvAd.js +1 -0
- package/build/client/assets/_-CgPm6_fJ.js +1 -0
- package/build/client/assets/_index-BCLDp_mg.js +1 -0
- package/build/client/assets/_layout-CTmjtKOZ.js +1 -0
- package/build/client/assets/_layout-HsJ3Zu5t.js +1 -0
- package/build/client/assets/_layout-OcS85aOt.js +1 -0
- package/build/client/assets/app-sidebar-Bm6e4kn_.js +1 -0
- package/build/client/assets/app-sidebar-D2Nsi85j.js +1 -0
- package/build/client/assets/auth-provider-rkzBVtYX.js +1 -0
- package/build/client/assets/brand-CbTWw97e.js +1 -0
- package/build/client/assets/browser-ponyfill-D3yQFvRu.js +2 -0
- package/build/client/assets/button-DtZhoqpk.js +1 -0
- package/build/client/assets/check-D5D2EGI4.js +1 -0
- package/build/client/assets/checkbox-B35Nn166.js +1 -0
- package/build/client/assets/chunk-JG3XND5A-BetDbdG0.js +1 -0
- package/build/client/assets/chunk-UIGDSWPH-DeiamgQc.js +26 -0
- package/build/client/assets/chunk-vBKQ29Cd.js +1 -0
- package/build/client/assets/circle-alert-DB4JluX5.js +1 -0
- package/build/client/assets/compare-Br3z3FUS-BXkA2ojG.js +2 -0
- package/build/client/assets/compiler-runtime-Co9svCia.js +1 -0
- package/build/client/assets/config-ChcA_Pkv.js +1 -0
- package/build/client/assets/createReactComponent-C2TSpqC7.js +1 -0
- package/build/client/assets/dialog-CQrpvURm.js +1 -0
- package/build/client/assets/dist-B6TkSbxV.js +1 -0
- package/build/client/assets/dist-BNO39Rfs.js +1 -0
- package/build/client/assets/dist-BWnI-4xl.js +1 -0
- package/build/client/assets/dist-CA21wN5I.js +1 -0
- package/build/client/assets/dist-CBNvQRbZ.js +1 -0
- package/build/client/assets/dist-CYRPrwOb.js +1 -0
- package/build/client/assets/dist-DKtC0FSi.js +1 -0
- package/build/client/assets/dist-DhfcebhF.js +1 -0
- package/build/client/assets/dist-VqaKdvZu.js +1 -0
- package/build/client/assets/dist-Yn6lj8QC.js +5 -0
- package/build/client/assets/dropdown-menu-CbzduuDa.js +1 -0
- package/build/client/assets/empty-DQRarCKT.js +1 -0
- package/build/client/assets/entry.client-BN1GPjAL.js +10 -0
- package/build/client/assets/es2015-BJguufLZ.js +41 -0
- package/build/client/assets/eye-Ctrln70x.js +1 -0
- package/build/client/assets/file-preview-dialog-BRkWSRN4.js +14 -0
- package/build/client/assets/index-Del2yBnb.js +1 -0
- package/build/client/assets/initReactI18next-CyHiepAw.js +1 -0
- package/build/client/assets/input-V1lM1yoz.js +1 -0
- package/build/client/assets/jsx-runtime-SCjaiuzT.js +1 -0
- package/build/client/assets/lock-Bj7dxHab.js +1 -0
- package/build/client/assets/manifest-ca813980.js +1 -0
- package/build/client/assets/nav-user-BqPUBe9x.js +1 -0
- package/build/client/assets/nav-user-Yu7wt7b_.js +1 -0
- package/build/client/assets/org-switcher-BIuearbE.js +1 -0
- package/build/client/assets/password-input-bor7e4TM.js +1 -0
- package/build/client/assets/react-dom-Bhi-1tDD.js +1 -0
- package/build/client/assets/realtime-BmU1LPhx.js +1 -0
- package/build/client/assets/root-CS5YIV-V.js +3 -0
- package/build/client/assets/root-D0CFuQYc.css +2 -0
- package/build/client/assets/route-B9cwW-UK.js +1 -0
- package/build/client/assets/route-BD2nV1q2.js +1 -0
- package/build/client/assets/route-BEnDcljt.js +1 -0
- package/build/client/assets/route-BR4LdxHR.js +1 -0
- package/build/client/assets/route-BU5TYmVE.js +0 -0
- package/build/client/assets/route-BVmIPEvK.js +11 -0
- package/build/client/assets/route-BY244T48.js +1 -0
- package/build/client/assets/route-Bwd903CU.js +1 -0
- package/build/client/assets/route-CN9iChOk.js +1 -0
- package/build/client/assets/route-CQ3p9Qb1.js +1 -0
- package/build/client/assets/route-CVLnTONw.js +1 -0
- package/build/client/assets/route-CoMZag4T.js +1 -0
- package/build/client/assets/route-CsYSLbnx.js +1 -0
- package/build/client/assets/route-DWNrq2GE.js +1 -0
- package/build/client/assets/route-Dxfmap_u.js +1 -0
- package/build/client/assets/route-Gnx1fkRX.js +0 -0
- package/build/client/assets/route-NduA4SS_.js +1 -0
- package/build/client/assets/route-u2hskgE_.js +1 -0
- package/build/client/assets/route-v9Jwv-AW.js +1 -0
- package/build/client/assets/select-DATRE76_.js +1 -0
- package/build/client/assets/separator-Cla0V581.js +1 -0
- package/build/client/assets/shim-TRiHENXu.js +1 -0
- package/build/client/assets/sidebar-CqrdL512.js +1 -0
- package/build/client/assets/site-header-CZO3qBhf.js +1 -0
- package/build/client/assets/site-header-CwidwSv1.js +1 -0
- package/build/client/assets/social-providers-Bz7f1_yd.js +1 -0
- package/build/client/assets/test-WdoqKbLa.js +1 -0
- package/build/client/assets/tooltip-BeDraHQn.js +1 -0
- package/build/client/assets/trpc-C1CjVipH.js +6 -0
- package/build/client/assets/trust-indicator-D4tEs4Dr.js +20 -0
- package/build/client/assets/use-file-upload-CNPfWC6W.js +1 -0
- package/build/client/assets/useTranslation-Bz7VuQ7j.js +1 -0
- package/build/client/assets/utils-InBzhUf_.js +1 -0
- package/build/client/assets/x-4CC8aqOW.js +1 -0
- package/build/client/favicon.ico +0 -0
- package/build/client/locales/en/emails.json +11 -0
- package/build/client/locales/en/translation.json +411 -0
- package/build/client/locales/zh-CN/emails.json +11 -0
- package/build/client/locales/zh-CN/translation.json +1 -0
- package/build/client/locales/zh-TW/emails.json +11 -0
- package/build/client/locales/zh-TW/translation.json +1 -0
- package/build/client/logo-invert.png +0 -0
- package/build/client/logo.png +0 -0
- package/build/lib/adapter-factory-CLtf7vT5-CTKiMV2u.mjs +19675 -0
- package/build/lib/bun-sqlite-dialect-DN7EKoIB-0pWIoG0L.mjs +155 -0
- package/build/lib/chunk-BYI67GdN.mjs +1 -0
- package/build/lib/chunk-CkKlU7xI.mjs +44 -0
- package/build/lib/client-BtuhFgvy.mjs +65 -0
- package/build/lib/client.d.ts +2272 -0
- package/build/lib/client.js +24 -0
- package/build/lib/date.d.ts +1 -0
- package/build/lib/date.js +1 -0
- package/build/lib/dialect-BeMwdQoz-D41NdSow.mjs +72 -0
- package/build/lib/dist-cjs-B43A5HXv.mjs +169 -0
- package/build/lib/dist-cjs-B_wkbabY.mjs +214 -0
- package/build/lib/dist-cjs-BmbYbMhp.mjs +143 -0
- package/build/lib/dist-cjs-Cc337rwW.mjs +7 -0
- package/build/lib/dist-cjs-CgzfN8xY.mjs +4974 -0
- package/build/lib/dist-cjs-DBFcizQf.mjs +50 -0
- package/build/lib/dist-cjs-DC-UL-xx.mjs +97 -0
- package/build/lib/dist-cjs-DHlTgXUO.mjs +6975 -0
- package/build/lib/dist-cjs-DYAmJYzN.mjs +323 -0
- package/build/lib/dist-cjs-Ddm6Stp9.mjs +1294 -0
- package/build/lib/dist-cjs-GFGBhaZg.mjs +84 -0
- package/build/lib/dist-cjs-ieCOxrOi.mjs +181 -0
- package/build/lib/dist-cjs-nbOGa7i_.mjs +47 -0
- package/build/lib/dist-cjs-pN6ekzMW.mjs +66 -0
- package/build/lib/dist-cjs-yYlQ1OiO.mjs +102 -0
- package/build/lib/esm-DPet4lFW.mjs +15816 -0
- package/build/lib/event-streams-x9fP9BzF.mjs +185 -0
- package/build/lib/file-preview-dialog-Cugg8tEc.mjs +59 -0
- package/build/lib/kysely-adapter-BTWfu5rn.mjs +183 -0
- package/build/lib/magic-string.es-jZcifc5m.mjs +1013 -0
- package/build/lib/memory-adapter-DiU519m9.mjs +147 -0
- package/build/lib/node-ponyfill-Dmm1SWTU.mjs +38212 -0
- package/build/lib/node-sqlite-dialect-BqISUSC3-DYvTLBpY.mjs +155 -0
- package/build/lib/package-DfozRyK6.mjs +5 -0
- package/build/lib/react-dom-CPjM_WCt.mjs +42 -0
- package/build/lib/server.d.mts +76273 -0
- package/build/lib/server.mjs +325 -0
- package/build/lib/sso-oidc-Qom0PEDW.mjs +1036 -0
- package/build/lib/sts-CLRaHSW_.mjs +13 -0
- package/build/lib/sts-Dl7yZqX1.mjs +1405 -0
- package/build/lib/test.d.mts +8922 -0
- package/build/lib/test.mjs +175650 -0
- package/build/lib/ui/index.d.ts +1643 -0
- package/build/lib/ui/index.js +160 -0
- package/build/lib/utils.d.ts +21 -0
- package/build/lib/utils.js +1 -0
- package/build/lib/zod.d.ts +1 -0
- package/build/lib/zod.js +23 -0
- package/build/main.js +2383 -0
- package/build/server/assets/context-BoNg86Eh.js +35 -0
- package/build/server/assets/dialog-B8YbGNaz.js +54 -0
- package/build/server/assets/file-preview-dialog-qWSViOWQ.js +15 -0
- package/build/server/assets/react-CFQ4y0AA.js +13 -0
- package/build/server/assets/react-dom-Ca1YUVo2.js +5 -0
- package/build/server/assets/server-build-BMOfm0ad.js +118 -0
- package/build/server/assets/server.node-B2oksIp8.js +196 -0
- package/build/server/assets/server.node-VQzoub0A.js +1 -0
- package/build/server/index.js +123 -0
- package/package.json +224 -0
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { a as __require, t as __commonJS } from "./chunk-CkKlU7xI.mjs";
|
|
2
|
+
import { t as require_dist_cjs$1 } from "./dist-cjs-DC-UL-xx.mjs";
|
|
3
|
+
import "./dist-cjs-B_wkbabY.mjs";
|
|
4
|
+
import "./dist-cjs-GFGBhaZg.mjs";
|
|
5
|
+
import { n as require_dist_cjs$2, t as require_dist_cjs$3 } from "./dist-cjs-yYlQ1OiO.mjs";
|
|
6
|
+
|
|
7
|
+
//#region node_modules/@smithy/credential-provider-imds/dist-cjs/index.js
|
|
8
|
+
var require_dist_cjs = /* @__PURE__ */ __commonJS({ "node_modules/@smithy/credential-provider-imds/dist-cjs/index.js": ((exports) => {
|
|
9
|
+
var propertyProvider = require_dist_cjs$1();
|
|
10
|
+
var url = __require("url");
|
|
11
|
+
var buffer = __require("buffer");
|
|
12
|
+
var http = __require("http");
|
|
13
|
+
var nodeConfigProvider = require_dist_cjs$2();
|
|
14
|
+
var urlParser = require_dist_cjs$3();
|
|
15
|
+
function httpRequest(options) {
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
const req = http.request({
|
|
18
|
+
method: "GET",
|
|
19
|
+
...options,
|
|
20
|
+
hostname: options.hostname?.replace(/^\[(.+)\]$/, "$1")
|
|
21
|
+
});
|
|
22
|
+
req.on("error", (err) => {
|
|
23
|
+
reject(Object.assign(new propertyProvider.ProviderError("Unable to connect to instance metadata service"), err));
|
|
24
|
+
req.destroy();
|
|
25
|
+
});
|
|
26
|
+
req.on("timeout", () => {
|
|
27
|
+
reject(new propertyProvider.ProviderError("TimeoutError from instance metadata service"));
|
|
28
|
+
req.destroy();
|
|
29
|
+
});
|
|
30
|
+
req.on("response", (res) => {
|
|
31
|
+
const { statusCode = 400 } = res;
|
|
32
|
+
if (statusCode < 200 || 300 <= statusCode) {
|
|
33
|
+
reject(Object.assign(new propertyProvider.ProviderError("Error response received from instance metadata service"), { statusCode }));
|
|
34
|
+
req.destroy();
|
|
35
|
+
}
|
|
36
|
+
const chunks = [];
|
|
37
|
+
res.on("data", (chunk) => {
|
|
38
|
+
chunks.push(chunk);
|
|
39
|
+
});
|
|
40
|
+
res.on("end", () => {
|
|
41
|
+
resolve(buffer.Buffer.concat(chunks));
|
|
42
|
+
req.destroy();
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
req.end();
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
const isImdsCredentials = (arg) => Boolean(arg) && typeof arg === "object" && typeof arg.AccessKeyId === "string" && typeof arg.SecretAccessKey === "string" && typeof arg.Token === "string" && typeof arg.Expiration === "string";
|
|
49
|
+
const fromImdsCredentials = (creds) => ({
|
|
50
|
+
accessKeyId: creds.AccessKeyId,
|
|
51
|
+
secretAccessKey: creds.SecretAccessKey,
|
|
52
|
+
sessionToken: creds.Token,
|
|
53
|
+
expiration: new Date(creds.Expiration),
|
|
54
|
+
...creds.AccountId && { accountId: creds.AccountId }
|
|
55
|
+
});
|
|
56
|
+
const DEFAULT_TIMEOUT = 1e3;
|
|
57
|
+
const DEFAULT_MAX_RETRIES = 0;
|
|
58
|
+
const providerConfigFromInit = ({ maxRetries = DEFAULT_MAX_RETRIES, timeout = DEFAULT_TIMEOUT }) => ({
|
|
59
|
+
maxRetries,
|
|
60
|
+
timeout
|
|
61
|
+
});
|
|
62
|
+
const retry = (toRetry, maxRetries) => {
|
|
63
|
+
let promise = toRetry();
|
|
64
|
+
for (let i = 0; i < maxRetries; i++) promise = promise.catch(toRetry);
|
|
65
|
+
return promise;
|
|
66
|
+
};
|
|
67
|
+
const ENV_CMDS_FULL_URI = "AWS_CONTAINER_CREDENTIALS_FULL_URI";
|
|
68
|
+
const ENV_CMDS_RELATIVE_URI = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI";
|
|
69
|
+
const ENV_CMDS_AUTH_TOKEN = "AWS_CONTAINER_AUTHORIZATION_TOKEN";
|
|
70
|
+
const fromContainerMetadata = (init = {}) => {
|
|
71
|
+
const { timeout, maxRetries } = providerConfigFromInit(init);
|
|
72
|
+
return () => retry(async () => {
|
|
73
|
+
const requestOptions = await getCmdsUri({ logger: init.logger });
|
|
74
|
+
const credsResponse = JSON.parse(await requestFromEcsImds(timeout, requestOptions));
|
|
75
|
+
if (!isImdsCredentials(credsResponse)) throw new propertyProvider.CredentialsProviderError("Invalid response received from instance metadata service.", { logger: init.logger });
|
|
76
|
+
return fromImdsCredentials(credsResponse);
|
|
77
|
+
}, maxRetries);
|
|
78
|
+
};
|
|
79
|
+
const requestFromEcsImds = async (timeout, options) => {
|
|
80
|
+
if (process.env[ENV_CMDS_AUTH_TOKEN]) options.headers = {
|
|
81
|
+
...options.headers,
|
|
82
|
+
Authorization: process.env[ENV_CMDS_AUTH_TOKEN]
|
|
83
|
+
};
|
|
84
|
+
return (await httpRequest({
|
|
85
|
+
...options,
|
|
86
|
+
timeout
|
|
87
|
+
})).toString();
|
|
88
|
+
};
|
|
89
|
+
const CMDS_IP = "169.254.170.2";
|
|
90
|
+
const GREENGRASS_HOSTS = {
|
|
91
|
+
localhost: true,
|
|
92
|
+
"127.0.0.1": true
|
|
93
|
+
};
|
|
94
|
+
const GREENGRASS_PROTOCOLS = {
|
|
95
|
+
"http:": true,
|
|
96
|
+
"https:": true
|
|
97
|
+
};
|
|
98
|
+
const getCmdsUri = async ({ logger }) => {
|
|
99
|
+
if (process.env[ENV_CMDS_RELATIVE_URI]) return {
|
|
100
|
+
hostname: CMDS_IP,
|
|
101
|
+
path: process.env[ENV_CMDS_RELATIVE_URI]
|
|
102
|
+
};
|
|
103
|
+
if (process.env[ENV_CMDS_FULL_URI]) {
|
|
104
|
+
const parsed = url.parse(process.env[ENV_CMDS_FULL_URI]);
|
|
105
|
+
if (!parsed.hostname || !(parsed.hostname in GREENGRASS_HOSTS)) throw new propertyProvider.CredentialsProviderError(`${parsed.hostname} is not a valid container metadata service hostname`, {
|
|
106
|
+
tryNextLink: false,
|
|
107
|
+
logger
|
|
108
|
+
});
|
|
109
|
+
if (!parsed.protocol || !(parsed.protocol in GREENGRASS_PROTOCOLS)) throw new propertyProvider.CredentialsProviderError(`${parsed.protocol} is not a valid container metadata service protocol`, {
|
|
110
|
+
tryNextLink: false,
|
|
111
|
+
logger
|
|
112
|
+
});
|
|
113
|
+
return {
|
|
114
|
+
...parsed,
|
|
115
|
+
port: parsed.port ? parseInt(parsed.port, 10) : void 0
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
throw new propertyProvider.CredentialsProviderError(`The container metadata credential provider cannot be used unless the ${ENV_CMDS_RELATIVE_URI} or ${ENV_CMDS_FULL_URI} environment variable is set`, {
|
|
119
|
+
tryNextLink: false,
|
|
120
|
+
logger
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
var InstanceMetadataV1FallbackError = class InstanceMetadataV1FallbackError extends propertyProvider.CredentialsProviderError {
|
|
124
|
+
tryNextLink;
|
|
125
|
+
name = "InstanceMetadataV1FallbackError";
|
|
126
|
+
constructor(message, tryNextLink = true) {
|
|
127
|
+
super(message, tryNextLink);
|
|
128
|
+
this.tryNextLink = tryNextLink;
|
|
129
|
+
Object.setPrototypeOf(this, InstanceMetadataV1FallbackError.prototype);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
exports.Endpoint = void 0;
|
|
133
|
+
(function(Endpoint) {
|
|
134
|
+
Endpoint["IPv4"] = "http://169.254.169.254";
|
|
135
|
+
Endpoint["IPv6"] = "http://[fd00:ec2::254]";
|
|
136
|
+
})(exports.Endpoint || (exports.Endpoint = {}));
|
|
137
|
+
const ENV_ENDPOINT_NAME = "AWS_EC2_METADATA_SERVICE_ENDPOINT";
|
|
138
|
+
const CONFIG_ENDPOINT_NAME = "ec2_metadata_service_endpoint";
|
|
139
|
+
const ENDPOINT_CONFIG_OPTIONS = {
|
|
140
|
+
environmentVariableSelector: (env) => env[ENV_ENDPOINT_NAME],
|
|
141
|
+
configFileSelector: (profile) => profile[CONFIG_ENDPOINT_NAME],
|
|
142
|
+
default: void 0
|
|
143
|
+
};
|
|
144
|
+
var EndpointMode;
|
|
145
|
+
(function(EndpointMode$1) {
|
|
146
|
+
EndpointMode$1["IPv4"] = "IPv4";
|
|
147
|
+
EndpointMode$1["IPv6"] = "IPv6";
|
|
148
|
+
})(EndpointMode || (EndpointMode = {}));
|
|
149
|
+
const ENV_ENDPOINT_MODE_NAME = "AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE";
|
|
150
|
+
const CONFIG_ENDPOINT_MODE_NAME = "ec2_metadata_service_endpoint_mode";
|
|
151
|
+
const ENDPOINT_MODE_CONFIG_OPTIONS = {
|
|
152
|
+
environmentVariableSelector: (env) => env[ENV_ENDPOINT_MODE_NAME],
|
|
153
|
+
configFileSelector: (profile) => profile[CONFIG_ENDPOINT_MODE_NAME],
|
|
154
|
+
default: EndpointMode.IPv4
|
|
155
|
+
};
|
|
156
|
+
const getInstanceMetadataEndpoint = async () => urlParser.parseUrl(await getFromEndpointConfig() || await getFromEndpointModeConfig());
|
|
157
|
+
const getFromEndpointConfig = async () => nodeConfigProvider.loadConfig(ENDPOINT_CONFIG_OPTIONS)();
|
|
158
|
+
const getFromEndpointModeConfig = async () => {
|
|
159
|
+
const endpointMode = await nodeConfigProvider.loadConfig(ENDPOINT_MODE_CONFIG_OPTIONS)();
|
|
160
|
+
switch (endpointMode) {
|
|
161
|
+
case EndpointMode.IPv4: return exports.Endpoint.IPv4;
|
|
162
|
+
case EndpointMode.IPv6: return exports.Endpoint.IPv6;
|
|
163
|
+
default: throw new Error(`Unsupported endpoint mode: ${endpointMode}. Select from ${Object.values(EndpointMode)}`);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
const STATIC_STABILITY_REFRESH_INTERVAL_SECONDS = 300;
|
|
167
|
+
const STATIC_STABILITY_REFRESH_INTERVAL_JITTER_WINDOW_SECONDS = 300;
|
|
168
|
+
const getExtendedInstanceMetadataCredentials = (credentials, logger) => {
|
|
169
|
+
const refreshInterval = STATIC_STABILITY_REFRESH_INTERVAL_SECONDS + Math.floor(Math.random() * STATIC_STABILITY_REFRESH_INTERVAL_JITTER_WINDOW_SECONDS);
|
|
170
|
+
const newExpiration = new Date(Date.now() + refreshInterval * 1e3);
|
|
171
|
+
logger.warn(`Attempting credential expiration extension due to a credential service availability issue. A refresh of these credentials will be attempted after ${new Date(newExpiration)}.\nFor more information, please visit: https://docs.aws.amazon.com/sdkref/latest/guide/feature-static-credentials.html`);
|
|
172
|
+
const originalExpiration = credentials.originalExpiration ?? credentials.expiration;
|
|
173
|
+
return {
|
|
174
|
+
...credentials,
|
|
175
|
+
...originalExpiration ? { originalExpiration } : {},
|
|
176
|
+
expiration: newExpiration
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
const staticStabilityProvider = (provider, options = {}) => {
|
|
180
|
+
const logger = options?.logger || console;
|
|
181
|
+
let pastCredentials;
|
|
182
|
+
return async () => {
|
|
183
|
+
let credentials;
|
|
184
|
+
try {
|
|
185
|
+
credentials = await provider();
|
|
186
|
+
if (credentials.expiration && credentials.expiration.getTime() < Date.now()) credentials = getExtendedInstanceMetadataCredentials(credentials, logger);
|
|
187
|
+
} catch (e) {
|
|
188
|
+
if (pastCredentials) {
|
|
189
|
+
logger.warn("Credential renew failed: ", e);
|
|
190
|
+
credentials = getExtendedInstanceMetadataCredentials(pastCredentials, logger);
|
|
191
|
+
} else throw e;
|
|
192
|
+
}
|
|
193
|
+
pastCredentials = credentials;
|
|
194
|
+
return credentials;
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
const IMDS_PATH = "/latest/meta-data/iam/security-credentials/";
|
|
198
|
+
const IMDS_TOKEN_PATH = "/latest/api/token";
|
|
199
|
+
const AWS_EC2_METADATA_V1_DISABLED = "AWS_EC2_METADATA_V1_DISABLED";
|
|
200
|
+
const PROFILE_AWS_EC2_METADATA_V1_DISABLED = "ec2_metadata_v1_disabled";
|
|
201
|
+
const X_AWS_EC2_METADATA_TOKEN = "x-aws-ec2-metadata-token";
|
|
202
|
+
const fromInstanceMetadata = (init = {}) => staticStabilityProvider(getInstanceMetadataProvider(init), { logger: init.logger });
|
|
203
|
+
const getInstanceMetadataProvider = (init = {}) => {
|
|
204
|
+
let disableFetchToken = false;
|
|
205
|
+
const { logger, profile } = init;
|
|
206
|
+
const { timeout, maxRetries } = providerConfigFromInit(init);
|
|
207
|
+
const getCredentials = async (maxRetries$1, options) => {
|
|
208
|
+
if (disableFetchToken || options.headers?.[X_AWS_EC2_METADATA_TOKEN] == null) {
|
|
209
|
+
let fallbackBlockedFromProfile = false;
|
|
210
|
+
let fallbackBlockedFromProcessEnv = false;
|
|
211
|
+
const configValue = await nodeConfigProvider.loadConfig({
|
|
212
|
+
environmentVariableSelector: (env) => {
|
|
213
|
+
const envValue = env[AWS_EC2_METADATA_V1_DISABLED];
|
|
214
|
+
fallbackBlockedFromProcessEnv = !!envValue && envValue !== "false";
|
|
215
|
+
if (envValue === void 0) throw new propertyProvider.CredentialsProviderError(`${AWS_EC2_METADATA_V1_DISABLED} not set in env, checking config file next.`, { logger: init.logger });
|
|
216
|
+
return fallbackBlockedFromProcessEnv;
|
|
217
|
+
},
|
|
218
|
+
configFileSelector: (profile$1) => {
|
|
219
|
+
const profileValue = profile$1[PROFILE_AWS_EC2_METADATA_V1_DISABLED];
|
|
220
|
+
fallbackBlockedFromProfile = !!profileValue && profileValue !== "false";
|
|
221
|
+
return fallbackBlockedFromProfile;
|
|
222
|
+
},
|
|
223
|
+
default: false
|
|
224
|
+
}, { profile })();
|
|
225
|
+
if (init.ec2MetadataV1Disabled || configValue) {
|
|
226
|
+
const causes = [];
|
|
227
|
+
if (init.ec2MetadataV1Disabled) causes.push("credential provider initialization (runtime option ec2MetadataV1Disabled)");
|
|
228
|
+
if (fallbackBlockedFromProfile) causes.push(`config file profile (${PROFILE_AWS_EC2_METADATA_V1_DISABLED})`);
|
|
229
|
+
if (fallbackBlockedFromProcessEnv) causes.push(`process environment variable (${AWS_EC2_METADATA_V1_DISABLED})`);
|
|
230
|
+
throw new InstanceMetadataV1FallbackError(`AWS EC2 Metadata v1 fallback has been blocked by AWS SDK configuration in the following: [${causes.join(", ")}].`);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
const imdsProfile = (await retry(async () => {
|
|
234
|
+
let profile$1;
|
|
235
|
+
try {
|
|
236
|
+
profile$1 = await getProfile(options);
|
|
237
|
+
} catch (err) {
|
|
238
|
+
if (err.statusCode === 401) disableFetchToken = false;
|
|
239
|
+
throw err;
|
|
240
|
+
}
|
|
241
|
+
return profile$1;
|
|
242
|
+
}, maxRetries$1)).trim();
|
|
243
|
+
return retry(async () => {
|
|
244
|
+
let creds;
|
|
245
|
+
try {
|
|
246
|
+
creds = await getCredentialsFromProfile(imdsProfile, options, init);
|
|
247
|
+
} catch (err) {
|
|
248
|
+
if (err.statusCode === 401) disableFetchToken = false;
|
|
249
|
+
throw err;
|
|
250
|
+
}
|
|
251
|
+
return creds;
|
|
252
|
+
}, maxRetries$1);
|
|
253
|
+
};
|
|
254
|
+
return async () => {
|
|
255
|
+
const endpoint = await getInstanceMetadataEndpoint();
|
|
256
|
+
if (disableFetchToken) {
|
|
257
|
+
logger?.debug("AWS SDK Instance Metadata", "using v1 fallback (no token fetch)");
|
|
258
|
+
return getCredentials(maxRetries, {
|
|
259
|
+
...endpoint,
|
|
260
|
+
timeout
|
|
261
|
+
});
|
|
262
|
+
} else {
|
|
263
|
+
let token;
|
|
264
|
+
try {
|
|
265
|
+
token = (await getMetadataToken({
|
|
266
|
+
...endpoint,
|
|
267
|
+
timeout
|
|
268
|
+
})).toString();
|
|
269
|
+
} catch (error) {
|
|
270
|
+
if (error?.statusCode === 400) throw Object.assign(error, { message: "EC2 Metadata token request returned error" });
|
|
271
|
+
else if (error.message === "TimeoutError" || [
|
|
272
|
+
403,
|
|
273
|
+
404,
|
|
274
|
+
405
|
|
275
|
+
].includes(error.statusCode)) disableFetchToken = true;
|
|
276
|
+
logger?.debug("AWS SDK Instance Metadata", "using v1 fallback (initial)");
|
|
277
|
+
return getCredentials(maxRetries, {
|
|
278
|
+
...endpoint,
|
|
279
|
+
timeout
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
return getCredentials(maxRetries, {
|
|
283
|
+
...endpoint,
|
|
284
|
+
headers: { [X_AWS_EC2_METADATA_TOKEN]: token },
|
|
285
|
+
timeout
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
};
|
|
290
|
+
const getMetadataToken = async (options) => httpRequest({
|
|
291
|
+
...options,
|
|
292
|
+
path: IMDS_TOKEN_PATH,
|
|
293
|
+
method: "PUT",
|
|
294
|
+
headers: { "x-aws-ec2-metadata-token-ttl-seconds": "21600" }
|
|
295
|
+
});
|
|
296
|
+
const getProfile = async (options) => (await httpRequest({
|
|
297
|
+
...options,
|
|
298
|
+
path: IMDS_PATH
|
|
299
|
+
})).toString();
|
|
300
|
+
const getCredentialsFromProfile = async (profile, options, init) => {
|
|
301
|
+
const credentialsResponse = JSON.parse((await httpRequest({
|
|
302
|
+
...options,
|
|
303
|
+
path: IMDS_PATH + profile
|
|
304
|
+
})).toString());
|
|
305
|
+
if (!isImdsCredentials(credentialsResponse)) throw new propertyProvider.CredentialsProviderError("Invalid response received from instance metadata service.", { logger: init.logger });
|
|
306
|
+
return fromImdsCredentials(credentialsResponse);
|
|
307
|
+
};
|
|
308
|
+
exports.DEFAULT_MAX_RETRIES = DEFAULT_MAX_RETRIES;
|
|
309
|
+
exports.DEFAULT_TIMEOUT = DEFAULT_TIMEOUT;
|
|
310
|
+
exports.ENV_CMDS_AUTH_TOKEN = ENV_CMDS_AUTH_TOKEN;
|
|
311
|
+
exports.ENV_CMDS_FULL_URI = ENV_CMDS_FULL_URI;
|
|
312
|
+
exports.ENV_CMDS_RELATIVE_URI = ENV_CMDS_RELATIVE_URI;
|
|
313
|
+
exports.fromContainerMetadata = fromContainerMetadata;
|
|
314
|
+
exports.fromInstanceMetadata = fromInstanceMetadata;
|
|
315
|
+
exports.getInstanceMetadataEndpoint = getInstanceMetadataEndpoint;
|
|
316
|
+
exports.httpRequest = httpRequest;
|
|
317
|
+
exports.providerConfigFromInit = providerConfigFromInit;
|
|
318
|
+
}) });
|
|
319
|
+
|
|
320
|
+
//#endregion
|
|
321
|
+
export default require_dist_cjs();
|
|
322
|
+
|
|
323
|
+
export { };
|