cdk-local 0.164.2 → 0.164.3

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.
@@ -0,0 +1,1614 @@
1
+ import { t as getLogger } from "./logger-uzapot2X.js";
2
+ import { readFileSync, readlinkSync, realpathSync, statSync } from "node:fs";
3
+ import { Agent, request } from "node:http";
4
+ import { Agent as Agent$1, request as request$1 } from "node:https";
5
+ import { rootCertificates } from "node:tls";
6
+ import { brotliDecompressSync, gunzipSync, inflateSync } from "node:zlib";
7
+ import { NodeHttpHandler } from "@smithy/node-http-handler";
8
+ import { Agent as Agent$2 } from "agent-base";
9
+ import { HttpProxyAgent } from "http-proxy-agent";
10
+ import { HttpsProxyAgent } from "https-proxy-agent";
11
+ import { getProxyForUrl } from "proxy-from-env";
12
+ import * as path$1 from "node:path";
13
+ import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
14
+
15
+ //#region src/utils/url-authority.ts
16
+ const IPV6_LITERAL_CHARS = /^[0-9A-Fa-f:.]+$/;
17
+ function formatHostForAuthority(host) {
18
+ const inner = host.length > 1 && host.startsWith("[") && host.endsWith("]") ? host.slice(1, -1) : host;
19
+ if (!inner.includes(":")) return host;
20
+ const zoneAt = inner.indexOf("%");
21
+ const literal = zoneAt === -1 ? inner : inner.slice(0, zoneAt);
22
+ if (!IPV6_LITERAL_CHARS.test(literal)) return host;
23
+ return `[${literal}]`;
24
+ }
25
+ function formatAuthority(host, port) {
26
+ return `${formatHostForAuthority(host)}:${port}`;
27
+ }
28
+ function hostFromAuthority(authority) {
29
+ if (authority.startsWith("[")) {
30
+ const close = authority.indexOf("]");
31
+ if (close === -1) return "";
32
+ const afterBracket = authority.slice(close + 1);
33
+ if (afterBracket !== "" && !/^:\d+$/.test(afterBracket)) return "";
34
+ return authority.slice(1, close);
35
+ }
36
+ const firstColon = authority.indexOf(":");
37
+ if (firstColon === -1) return authority;
38
+ if (authority.includes(":", firstColon + 1)) return "";
39
+ return authority.slice(0, firstColon);
40
+ }
41
+
42
+ //#endregion
43
+ //#region src/utils/loopback-host.ts
44
+ function normaliseHostLiteral(hostname) {
45
+ return hostname.trim().replace(/^\[/, "").replace(/\]$/, "").toLowerCase();
46
+ }
47
+ function isLoopbackLiteral(h) {
48
+ if (h === "localhost") return true;
49
+ if (h === "::1" || h === "0:0:0:0:0:0:0:1") return true;
50
+ const mapped = /^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/.exec(h);
51
+ if (mapped) return parseInt(mapped[1], 16) >> 8 === 127;
52
+ const dotted = /^(?:::ffff:)?(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(h);
53
+ if (!dotted) return false;
54
+ const octets = dotted.slice(1).map(Number);
55
+ if (octets.some((o) => o > 255)) return false;
56
+ return octets[0] === 127;
57
+ }
58
+ function isWildcardLiteral(h) {
59
+ return h === "0.0.0.0" || h === "::" || h === "0:0:0:0:0:0:0:0" || h === "::ffff:0.0.0.0" || h === "::ffff:0:0";
60
+ }
61
+ function isLoopbackHostname(hostname) {
62
+ return isLoopbackLiteral(normaliseHostLiteral(hostname));
63
+ }
64
+ function isWildcardHostname(hostname) {
65
+ return isWildcardLiteral(normaliseHostLiteral(hostname));
66
+ }
67
+ function isLoopbackHost(hostname) {
68
+ const h = normaliseHostLiteral(hostname).replace(/\.$/, "");
69
+ return h.endsWith(".localhost") || isLoopbackLiteral(h) || isWildcardLiteral(h);
70
+ }
71
+
72
+ //#endregion
73
+ //#region src/utils/own-keys.ts
74
+ function defineOwnKey(target, key, value) {
75
+ Object.defineProperty(target, key, {
76
+ value,
77
+ writable: true,
78
+ enumerable: true,
79
+ configurable: true
80
+ });
81
+ }
82
+
83
+ //#endregion
84
+ //#region src/local/env-resolver.ts
85
+ const pipeTexts = /* @__PURE__ */ new Map();
86
+ function readEnvVarsFileText(filePath) {
87
+ let regular = !/^\/(?:dev|proc)\//.test(path$1.resolve(filePath));
88
+ try {
89
+ regular &&= statSync(filePath).isFile();
90
+ } catch {}
91
+ if (regular) return readFileSync(filePath, "utf-8");
92
+ const kept = pipeTexts.get(filePath);
93
+ if (kept !== void 0) return kept;
94
+ const text = readFileSync(filePath, "utf-8");
95
+ pipeTexts.set(filePath, text);
96
+ return text;
97
+ }
98
+ function resolveEnvVars(logicalId, displayPath, templateEnv, overrides) {
99
+ const resolved = {};
100
+ const unresolved = [];
101
+ if (templateEnv) for (const [key, value] of Object.entries(templateEnv)) if (isLiteralEnvValue(value)) defineOwnKey(resolved, key, String(value));
102
+ else unresolved.push(key);
103
+ if (overrides) {
104
+ applyEnvOverrideMap(resolved, overrides.Parameters);
105
+ for (const [key, val] of Object.entries(overrides)) {
106
+ if (key === "Parameters") continue;
107
+ if (!val || typeof val !== "object") continue;
108
+ if (key === logicalId) {
109
+ applyEnvOverrideMap(resolved, val);
110
+ continue;
111
+ }
112
+ if (displayPath && (displayPath === key || displayPath.startsWith(`${key}/`))) applyEnvOverrideMap(resolved, val);
113
+ }
114
+ }
115
+ return {
116
+ resolved,
117
+ unresolved
118
+ };
119
+ }
120
+ function applyEnvOverrideMap(acc, map) {
121
+ if (!map) return;
122
+ for (const [key, value] of Object.entries(map)) if (value === null) delete acc[key];
123
+ else if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") defineOwnKey(acc, key, String(value));
124
+ }
125
+ function isLiteralEnvValue(value) {
126
+ return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
127
+ }
128
+
129
+ //#endregion
130
+ //#region src/local/aws-endpoint-service-ids.ts
131
+ const AWS_ENDPOINT_SERVICE_IDS = /* @__PURE__ */ new Set([
132
+ "ACCESSANALYZER",
133
+ "ACCOUNT",
134
+ "ACCOUNT_ACCESS",
135
+ "ACM",
136
+ "ACM_PCA",
137
+ "AGENTTOOLKIT",
138
+ "AGENT_REGISTRY",
139
+ "AGENT_REGISTRY_CONTROL",
140
+ "AIOPS",
141
+ "AMP",
142
+ "AMPLIFY",
143
+ "AMPLIFYBACKEND",
144
+ "AMPLIFYUIBUILDER",
145
+ "APIGATEWAYMANAGEMENTAPI",
146
+ "APIGATEWAYV2",
147
+ "API_GATEWAY",
148
+ "APPCONFIG",
149
+ "APPCONFIGDATA",
150
+ "APPFABRIC",
151
+ "APPFLOW",
152
+ "APPINTEGRATIONS",
153
+ "APPLICATIONCOSTPROFILER",
154
+ "APPLICATION_AUTO_SCALING",
155
+ "APPLICATION_DISCOVERY_SERVICE",
156
+ "APPLICATION_INSIGHTS",
157
+ "APPLICATION_SIGNALS",
158
+ "APPRUNNER",
159
+ "APPSTREAM",
160
+ "APPSYNC",
161
+ "APP_MESH",
162
+ "ARC_REGION_SWITCH",
163
+ "ARC_ZONAL_SHIFT",
164
+ "ARTIFACT",
165
+ "ATHENA",
166
+ "AUDITMANAGER",
167
+ "AUTO_SCALING",
168
+ "AUTO_SCALING_PLANS",
169
+ "B2BI",
170
+ "BACKUP",
171
+ "BACKUPSEARCH",
172
+ "BACKUP_GATEWAY",
173
+ "BATCH",
174
+ "BCM_DASHBOARDS",
175
+ "BCM_DATA_EXPORTS",
176
+ "BCM_PRICING_CALCULATOR",
177
+ "BCM_RECOMMENDED_ACTIONS",
178
+ "BEDROCK",
179
+ "BEDROCK_AGENT",
180
+ "BEDROCK_AGENTCORE",
181
+ "BEDROCK_AGENTCORE_CONTROL",
182
+ "BEDROCK_AGENT_RUNTIME",
183
+ "BEDROCK_DATA_AUTOMATION",
184
+ "BEDROCK_DATA_AUTOMATION_RUNTIME",
185
+ "BEDROCK_RUNTIME",
186
+ "BILLING",
187
+ "BILLINGCONDUCTOR",
188
+ "BRAKET",
189
+ "BUDGETS",
190
+ "CHATBOT",
191
+ "CHIME",
192
+ "CHIME_SDK_IDENTITY",
193
+ "CHIME_SDK_MEDIA_PIPELINES",
194
+ "CHIME_SDK_MEETINGS",
195
+ "CHIME_SDK_MESSAGING",
196
+ "CHIME_SDK_VOICE",
197
+ "CLEANROOMS",
198
+ "CLEANROOMSML",
199
+ "CLOUD9",
200
+ "CLOUDCONTROL",
201
+ "CLOUDDIRECTORY",
202
+ "CLOUDFORMATION",
203
+ "CLOUDFRONT",
204
+ "CLOUDFRONT_KEYVALUESTORE",
205
+ "CLOUDHSM",
206
+ "CLOUDHSM_V2",
207
+ "CLOUDSEARCH",
208
+ "CLOUDSEARCH_DOMAIN",
209
+ "CLOUDTRAIL",
210
+ "CLOUDTRAIL_DATA",
211
+ "CLOUDWATCH",
212
+ "CLOUDWATCHOMNI",
213
+ "CLOUDWATCH_LOGS",
214
+ "CODEARTIFACT",
215
+ "CODEBUILD",
216
+ "CODECATALYST",
217
+ "CODECOMMIT",
218
+ "CODECONNECTIONS",
219
+ "CODEDEPLOY",
220
+ "CODEGURUPROFILER",
221
+ "CODEGURU_REVIEWER",
222
+ "CODEGURU_SECURITY",
223
+ "CODEPIPELINE",
224
+ "CODESTAR_CONNECTIONS",
225
+ "CODESTAR_NOTIFICATIONS",
226
+ "COGNITO_IDENTITY",
227
+ "COGNITO_IDENTITY_PROVIDER",
228
+ "COGNITO_SYNC",
229
+ "COMPREHEND",
230
+ "COMPREHENDMEDICAL",
231
+ "COMPUTE_OPTIMIZER",
232
+ "COMPUTE_OPTIMIZER_AUTOMATION",
233
+ "CONFIG_SERVICE",
234
+ "CONNECT",
235
+ "CONNECTCAMPAIGNS",
236
+ "CONNECTCAMPAIGNSV2",
237
+ "CONNECTCASES",
238
+ "CONNECTHEALTH",
239
+ "CONNECTPARTICIPANT",
240
+ "CONNECT_CONTACT_LENS",
241
+ "CONTROLCATALOG",
242
+ "CONTROLTOWER",
243
+ "COST_AND_USAGE_REPORT_SERVICE",
244
+ "COST_EXPLORER",
245
+ "COST_OPTIMIZATION_HUB",
246
+ "CUSTOMER_PROFILES",
247
+ "DATABASE_MIGRATION_SERVICE",
248
+ "DATABREW",
249
+ "DATAEXCHANGE",
250
+ "DATASYNC",
251
+ "DATAZONE",
252
+ "DATA_PIPELINE",
253
+ "DAX",
254
+ "DEADLINE",
255
+ "DETECTIVE",
256
+ "DEVICE_FARM",
257
+ "DEVOPS_AGENT",
258
+ "DEVOPS_GURU",
259
+ "DIRECTORY_SERVICE",
260
+ "DIRECTORY_SERVICE_DATA",
261
+ "DIRECT_CONNECT",
262
+ "DLM",
263
+ "DOCDB",
264
+ "DOCDB_ELASTIC",
265
+ "DRS",
266
+ "DSQL",
267
+ "DYNAMODB",
268
+ "DYNAMODB_STREAMS",
269
+ "EBS",
270
+ "EC2",
271
+ "EC2_INSTANCE_CONNECT",
272
+ "ECR",
273
+ "ECR_PUBLIC",
274
+ "ECS",
275
+ "EFS",
276
+ "EKS",
277
+ "EKS_AUTH",
278
+ "ELASTICACHE",
279
+ "ELASTICSEARCH_SERVICE",
280
+ "ELASTIC_BEANSTALK",
281
+ "ELASTIC_LOAD_BALANCING",
282
+ "ELASTIC_LOAD_BALANCING_V2",
283
+ "ELEMENTALINFERENCE",
284
+ "EMR",
285
+ "EMR_CONTAINERS",
286
+ "EMR_SERVERLESS",
287
+ "ENDUSERMESSAGING",
288
+ "ENTITYRESOLUTION",
289
+ "EVENTBRIDGE",
290
+ "EVENTBRIDGEV2",
291
+ "EVS",
292
+ "FIREHOSE",
293
+ "FIS",
294
+ "FMS",
295
+ "FORECAST",
296
+ "FORECASTQUERY",
297
+ "FRAUDDETECTOR",
298
+ "FREETIER",
299
+ "FSX",
300
+ "GAMELIFT",
301
+ "GAMELIFTSTREAMS",
302
+ "GEO_MAPS",
303
+ "GEO_PLACES",
304
+ "GEO_ROUTES",
305
+ "GLACIER",
306
+ "GLOBAL_ACCELERATOR",
307
+ "GLUE",
308
+ "GRAFANA",
309
+ "GREENGRASS",
310
+ "GREENGRASSV2",
311
+ "GROUNDSTATION",
312
+ "GUARDDUTY",
313
+ "HEALTH",
314
+ "HEALTHLAKE",
315
+ "IAM",
316
+ "IAM_TOOLBOX",
317
+ "IDENTITYSTORE",
318
+ "IMAGEBUILDER",
319
+ "IMPORTEXPORT",
320
+ "INSPECTOR",
321
+ "INSPECTOR2",
322
+ "INSPECTOR_SCAN",
323
+ "INTERCONNECT",
324
+ "INTERNETMONITOR",
325
+ "INVOICING",
326
+ "IOT",
327
+ "IOTDEVICEADVISOR",
328
+ "IOTFLEETWISE",
329
+ "IOTSECURETUNNELING",
330
+ "IOTSITEWISE",
331
+ "IOTTHINGSGRAPH",
332
+ "IOTTWINMAKER",
333
+ "IOT_DATA_PLANE",
334
+ "IOT_JOBS_DATA_PLANE",
335
+ "IOT_MANAGED_INTEGRATIONS",
336
+ "IOT_WIRELESS",
337
+ "IVS",
338
+ "IVSCHAT",
339
+ "IVS_REALTIME",
340
+ "KAFKA",
341
+ "KAFKACONNECT",
342
+ "KENDRA",
343
+ "KENDRA_RANKING",
344
+ "KEYSPACES",
345
+ "KEYSPACESSTREAMS",
346
+ "KINESIS",
347
+ "KINESIS_ANALYTICS",
348
+ "KINESIS_ANALYTICS_V2",
349
+ "KINESIS_VIDEO",
350
+ "KINESIS_VIDEO_ARCHIVED_MEDIA",
351
+ "KINESIS_VIDEO_MEDIA",
352
+ "KINESIS_VIDEO_SIGNALING",
353
+ "KINESIS_VIDEO_WEBRTC_STORAGE",
354
+ "KMS",
355
+ "LAKEFORMATION",
356
+ "LAMBDA",
357
+ "LAMBDA_CORE",
358
+ "LAMBDA_MICROVMS",
359
+ "LAMBDA_WEB",
360
+ "LAUNCH_WIZARD",
361
+ "LEX_MODELS_V2",
362
+ "LEX_MODEL_BUILDING_SERVICE",
363
+ "LEX_RUNTIME_SERVICE",
364
+ "LEX_RUNTIME_V2",
365
+ "LICENSE_MANAGER",
366
+ "LICENSE_MANAGER_LINUX_SUBSCRIPTIONS",
367
+ "LICENSE_MANAGER_USER_SUBSCRIPTIONS",
368
+ "LIGHTSAIL",
369
+ "LOCATION",
370
+ "LOOKOUTEQUIPMENT",
371
+ "M2",
372
+ "MACHINE_LEARNING",
373
+ "MACIE2",
374
+ "MAILMANAGER",
375
+ "MANAGEDBLOCKCHAIN",
376
+ "MANAGEDBLOCKCHAIN_QUERY",
377
+ "MARKETPLACE_AGREEMENT",
378
+ "MARKETPLACE_CATALOG",
379
+ "MARKETPLACE_COMMERCE_ANALYTICS",
380
+ "MARKETPLACE_DEPLOYMENT",
381
+ "MARKETPLACE_DISCOVERY",
382
+ "MARKETPLACE_ENTITLEMENT_SERVICE",
383
+ "MARKETPLACE_METERING",
384
+ "MARKETPLACE_REPORTING",
385
+ "MEDIACONNECT",
386
+ "MEDIACONVERT",
387
+ "MEDIALIVE",
388
+ "MEDIAPACKAGE",
389
+ "MEDIAPACKAGEV2",
390
+ "MEDIAPACKAGE_VOD",
391
+ "MEDIASTORE",
392
+ "MEDIASTORE_DATA",
393
+ "MEDIATAILOR",
394
+ "MEDICAL_IMAGING",
395
+ "MEMORYDB",
396
+ "MGN",
397
+ "MIGRATIONHUBORCHESTRATOR",
398
+ "MIGRATIONHUBSTRATEGY",
399
+ "MIGRATIONHUB_CONFIG",
400
+ "MIGRATION_HUB",
401
+ "MIGRATION_HUB_REFACTOR_SPACES",
402
+ "MPA",
403
+ "MQ",
404
+ "MTURK",
405
+ "MWAA",
406
+ "MWAA_SERVERLESS",
407
+ "NEPTUNE",
408
+ "NEPTUNEDATA",
409
+ "NEPTUNE_GRAPH",
410
+ "NETWORKFLOWMONITOR",
411
+ "NETWORKMANAGER",
412
+ "NETWORKMONITOR",
413
+ "NETWORK_FIREWALL",
414
+ "NETWORK_SECURITY_MANAGER",
415
+ "NOTIFICATIONS",
416
+ "NOTIFICATIONSCONTACTS",
417
+ "NOVA_ACT",
418
+ "OAM",
419
+ "OBSERVABILITYADMIN",
420
+ "ODB",
421
+ "OMICS",
422
+ "OPENSEARCH",
423
+ "OPENSEARCHSERVERLESS",
424
+ "ORGANIZATIONS",
425
+ "OSIS",
426
+ "OUTPOSTS",
427
+ "PARTNERCENTRAL_ACCOUNT",
428
+ "PARTNERCENTRAL_BENEFITS",
429
+ "PARTNERCENTRAL_CHANNEL",
430
+ "PARTNERCENTRAL_REVENUE_MEASUREMENT",
431
+ "PARTNERCENTRAL_SELLING",
432
+ "PAYMENT_CRYPTOGRAPHY",
433
+ "PAYMENT_CRYPTOGRAPHY_DATA",
434
+ "PCA_CONNECTOR_AD",
435
+ "PCA_CONNECTOR_SCEP",
436
+ "PCS",
437
+ "PERSONALIZE",
438
+ "PERSONALIZE_EVENTS",
439
+ "PERSONALIZE_RUNTIME",
440
+ "PI",
441
+ "PINPOINT",
442
+ "PINPOINT_EMAIL",
443
+ "PINPOINT_SMS_VOICE",
444
+ "PINPOINT_SMS_VOICE_V2",
445
+ "PIPES",
446
+ "POLLY",
447
+ "PRICING",
448
+ "PRICING_PLAN_MANAGER",
449
+ "PROTON",
450
+ "QAPPS",
451
+ "QBUSINESS",
452
+ "QCONNECT",
453
+ "QUICKSIGHT",
454
+ "RAM",
455
+ "RBIN",
456
+ "RDS",
457
+ "RDS_DATA",
458
+ "REDSHIFT",
459
+ "REDSHIFT_DATA",
460
+ "REDSHIFT_SERVERLESS",
461
+ "REKOGNITION",
462
+ "REPOSTSPACE",
463
+ "RESILIENCEHUB",
464
+ "RESILIENCEHUBV2",
465
+ "RESOURCE_EXPLORER_2",
466
+ "RESOURCE_GROUPS",
467
+ "RESOURCE_GROUPS_TAGGING_API",
468
+ "ROLESANYWHERE",
469
+ "ROUTE53GLOBALRESOLVER",
470
+ "ROUTE53PROFILES",
471
+ "ROUTE53RESOLVER",
472
+ "ROUTE53_RECOVERY_CLUSTER",
473
+ "ROUTE53_RECOVERY_CONTROL_CONFIG",
474
+ "ROUTE53_RECOVERY_READINESS",
475
+ "ROUTE_53",
476
+ "ROUTE_53_DOMAINS",
477
+ "RTBFABRIC",
478
+ "RUM",
479
+ "S3",
480
+ "S3FILES",
481
+ "S3OUTPOSTS",
482
+ "S3TABLES",
483
+ "S3VECTORS",
484
+ "S3_CONTROL",
485
+ "SAGEMAKER",
486
+ "SAGEMAKERJOBRUNTIME",
487
+ "SAGEMAKERTRAININGSESSIONRUNTIME",
488
+ "SAGEMAKER_A2I_RUNTIME",
489
+ "SAGEMAKER_EDGE",
490
+ "SAGEMAKER_FEATURESTORE_RUNTIME",
491
+ "SAGEMAKER_GEOSPATIAL",
492
+ "SAGEMAKER_METRICS",
493
+ "SAGEMAKER_RUNTIME",
494
+ "SAVINGSPLANS",
495
+ "SCHEDULER",
496
+ "SCHEMAS",
497
+ "SECRETS_MANAGER",
498
+ "SECURITYAGENT",
499
+ "SECURITYHUB",
500
+ "SECURITYLAKE",
501
+ "SECURITY_IR",
502
+ "SERVERLESSAPPLICATIONREPOSITORY",
503
+ "SERVICEDISCOVERY",
504
+ "SERVICE_CATALOG",
505
+ "SERVICE_CATALOG_APPREGISTRY",
506
+ "SERVICE_QUOTAS",
507
+ "SES",
508
+ "SESV2",
509
+ "SFN",
510
+ "SHIELD",
511
+ "SIGNER",
512
+ "SIGNER_DATA",
513
+ "SIGNIN",
514
+ "SIMPLEDB",
515
+ "SIMPLEDBV2",
516
+ "SNOWBALL",
517
+ "SNOW_DEVICE_MANAGEMENT",
518
+ "SNS",
519
+ "SOCIALMESSAGING",
520
+ "SQS",
521
+ "SSM",
522
+ "SSM_CONTACTS",
523
+ "SSM_GUICONNECT",
524
+ "SSM_INCIDENTS",
525
+ "SSM_QUICKSETUP",
526
+ "SSM_SAP",
527
+ "SSO",
528
+ "SSO_ADMIN",
529
+ "SSO_OIDC",
530
+ "STORAGE_GATEWAY",
531
+ "STS",
532
+ "SUPPLYCHAIN",
533
+ "SUPPORT",
534
+ "SUPPORTAUTHZ",
535
+ "SUPPORT_APP",
536
+ "SUSTAINABILITY",
537
+ "SWF",
538
+ "SYNTHETICS",
539
+ "TAXSETTINGS",
540
+ "TEXTRACT",
541
+ "TIMESTREAM_INFLUXDB",
542
+ "TIMESTREAM_QUERY",
543
+ "TIMESTREAM_WRITE",
544
+ "TRANSCRIBE",
545
+ "TRANSFER",
546
+ "TRANSLATE",
547
+ "TRUSTEDADVISOR",
548
+ "UXC",
549
+ "VERIFIEDPERMISSIONS",
550
+ "VOICE_ID",
551
+ "VPC_LATTICE",
552
+ "WAF",
553
+ "WAFV2",
554
+ "WAF_REGIONAL",
555
+ "WELLARCHITECTED",
556
+ "WICKR",
557
+ "WISDOM",
558
+ "WORKDOCS",
559
+ "WORKMAIL",
560
+ "WORKMAILMESSAGEFLOW",
561
+ "WORKSPACES",
562
+ "WORKSPACES_INSTANCES",
563
+ "WORKSPACES_THIN_CLIENT",
564
+ "WORKSPACES_WEB",
565
+ "XRAY"
566
+ ]);
567
+
568
+ //#endregion
569
+ //#region src/local/aws-real-endpoints.ts
570
+ const AWS_ENDPOINT_PREFIX_OVERRIDES = {
571
+ ACCESSANALYZER: "access-analyzer",
572
+ ACCOUNT_ACCESS: "account-access",
573
+ ACM_PCA: "acm-pca",
574
+ AGENT_REGISTRY: "agent-registry",
575
+ AGENT_REGISTRY_CONTROL: "agent-registry-control",
576
+ AMP: "aps",
577
+ APIGATEWAYMANAGEMENTAPI: "execute-api",
578
+ APIGATEWAYV2: "apigateway",
579
+ APPINTEGRATIONS: "app-integrations",
580
+ APPLICATIONCOSTPROFILER: "application-cost-profiler",
581
+ APPLICATION_AUTO_SCALING: "application-autoscaling",
582
+ APPLICATION_DISCOVERY_SERVICE: "discovery",
583
+ APPLICATION_SIGNALS: "application-signals",
584
+ APPSTREAM: "appstream2",
585
+ ARC_REGION_SWITCH: "arc-region-switch",
586
+ ARC_ZONAL_SHIFT: "arc-zonal-shift",
587
+ AUTO_SCALING_PLANS: "autoscaling-plans",
588
+ BACKUPSEARCH: "backup-search",
589
+ BACKUP_GATEWAY: "backup-gateway",
590
+ BCM_DASHBOARDS: "bcm-dashboards",
591
+ BCM_DATA_EXPORTS: "bcm-data-exports",
592
+ BCM_PRICING_CALCULATOR: "bcm-pricing-calculator",
593
+ BCM_RECOMMENDED_ACTIONS: "bcm-recommended-actions",
594
+ BEDROCK_AGENT: "bedrock-agent",
595
+ BEDROCK_AGENTCORE: "bedrock-agentcore",
596
+ BEDROCK_AGENTCORE_CONTROL: "bedrock-agentcore-control",
597
+ BEDROCK_AGENT_RUNTIME: "bedrock-agent-runtime",
598
+ BEDROCK_DATA_AUTOMATION: "bedrock-data-automation",
599
+ BEDROCK_DATA_AUTOMATION_RUNTIME: "bedrock-data-automation-runtime",
600
+ BEDROCK_RUNTIME: "bedrock-runtime",
601
+ CHIME_SDK_IDENTITY: "identity-chime",
602
+ CHIME_SDK_MEDIA_PIPELINES: "media-pipelines-chime",
603
+ CHIME_SDK_MEETINGS: "meetings-chime",
604
+ CHIME_SDK_MESSAGING: "messaging-chime",
605
+ CHIME_SDK_VOICE: "voice-chime",
606
+ CLEANROOMSML: "cleanrooms-ml",
607
+ CLOUDCONTROL: "cloudcontrolapi",
608
+ CLOUDFRONT_KEYVALUESTORE: "cloudfront-keyvaluestore",
609
+ CLOUDTRAIL_DATA: "cloudtrail-data",
610
+ CLOUDWATCH: "monitoring",
611
+ CLOUDWATCHOMNI: "cloudwatch-omni",
612
+ CLOUDWATCH_LOGS: "logs",
613
+ CODEGURUPROFILER: "codeguru-profiler",
614
+ CODEGURU_REVIEWER: "codeguru-reviewer",
615
+ CODEGURU_SECURITY: "codeguru-security",
616
+ CODESTAR_CONNECTIONS: "codestar-connections",
617
+ CODESTAR_NOTIFICATIONS: "codestar-notifications",
618
+ COGNITO_IDENTITY: "cognito-identity",
619
+ COGNITO_IDENTITY_PROVIDER: "cognito-idp",
620
+ COGNITO_SYNC: "cognito-sync",
621
+ COMPUTE_OPTIMIZER: "compute-optimizer",
622
+ COMPUTE_OPTIMIZER_AUTOMATION: "aco-automation",
623
+ CONFIG_SERVICE: "config",
624
+ CONNECTCAMPAIGNS: "connect-campaigns",
625
+ CONNECTCAMPAIGNSV2: "connect-campaigns",
626
+ CONNECTCASES: "cases",
627
+ CONNECTHEALTH: "health-agent",
628
+ CONNECTPARTICIPANT: "participant.connect",
629
+ CONNECT_CONTACT_LENS: "contact-lens",
630
+ COST_AND_USAGE_REPORT_SERVICE: "cur",
631
+ COST_EXPLORER: "ce",
632
+ COST_OPTIMIZATION_HUB: "cost-optimization-hub",
633
+ CUSTOMER_PROFILES: "profile",
634
+ DATABASE_MIGRATION_SERVICE: "dms",
635
+ DETECTIVE: "api.detective",
636
+ DEVOPS_AGENT: "aidevops",
637
+ DEVOPS_GURU: "devops-guru",
638
+ DIRECTORY_SERVICE: "ds",
639
+ DIRECTORY_SERVICE_DATA: "ds-data",
640
+ DOCDB: "rds",
641
+ DOCDB_ELASTIC: "docdb-elastic",
642
+ DYNAMODB_STREAMS: "streams.dynamodb",
643
+ EC2_INSTANCE_CONNECT: "ec2-instance-connect",
644
+ ECR: "api.ecr",
645
+ ECR_PUBLIC: "api.ecr-public",
646
+ EFS: "elasticfilesystem",
647
+ EKS_AUTH: "eks-auth",
648
+ ELASTICSEARCH_SERVICE: "es",
649
+ ELASTIC_LOAD_BALANCING_V2: "elasticloadbalancing",
650
+ ELEMENTALINFERENCE: "elemental-inference",
651
+ EMR: "elasticmapreduce",
652
+ EMR_CONTAINERS: "emr-containers",
653
+ EMR_SERVERLESS: "emr-serverless",
654
+ ENDUSERMESSAGING: "end-user-messaging",
655
+ EVENTBRIDGE: "events",
656
+ EVENTBRIDGEV2: "eventsv2",
657
+ GEO_MAPS: "geo-maps",
658
+ GEO_PLACES: "geo-places",
659
+ GEO_ROUTES: "geo-routes",
660
+ GREENGRASSV2: "greengrass",
661
+ IAM_TOOLBOX: "iam-toolbox",
662
+ INSPECTOR_SCAN: "inspector-scan",
663
+ IOTDEVICEADVISOR: "api.iotdeviceadvisor",
664
+ IOTSECURETUNNELING: "api.tunneling.iot",
665
+ IOT_DATA_PLANE: "data-ats.iot",
666
+ IOT_JOBS_DATA_PLANE: "data.jobs.iot",
667
+ IOT_MANAGED_INTEGRATIONS: "api.iotmanagedintegrations",
668
+ IOT_WIRELESS: "api.iotwireless",
669
+ KENDRA_RANKING: "kendra-ranking",
670
+ KEYSPACES: "cassandra",
671
+ KEYSPACESSTREAMS: "cassandra-streams",
672
+ KINESIS_ANALYTICS_V2: "kinesisanalytics",
673
+ KINESIS_VIDEO_ARCHIVED_MEDIA: "kinesisvideo",
674
+ KINESIS_VIDEO_MEDIA: "kinesisvideo",
675
+ KINESIS_VIDEO_SIGNALING: "kinesisvideo",
676
+ KINESIS_VIDEO_WEBRTC_STORAGE: "kinesisvideo",
677
+ LAMBDA_CORE: "lambda",
678
+ LAMBDA_MICROVMS: "lambda",
679
+ LAMBDA_WEB: "lambda",
680
+ LEX_MODELS_V2: "models-v2-lex",
681
+ LEX_MODEL_BUILDING_SERVICE: "models.lex",
682
+ LEX_RUNTIME_SERVICE: "runtime.lex",
683
+ LEX_RUNTIME_V2: "runtime-v2-lex",
684
+ LICENSE_MANAGER: "license-manager",
685
+ LICENSE_MANAGER_LINUX_SUBSCRIPTIONS: "license-manager-linux-subscriptions",
686
+ LICENSE_MANAGER_USER_SUBSCRIPTIONS: "license-manager-user-subscriptions",
687
+ LOCATION: "geo",
688
+ MAILMANAGER: "mail-manager",
689
+ MANAGEDBLOCKCHAIN_QUERY: "managedblockchain-query",
690
+ MARKETPLACE_AGREEMENT: "agreement-marketplace",
691
+ MARKETPLACE_CATALOG: "catalog.marketplace",
692
+ MARKETPLACE_DEPLOYMENT: "deployment-marketplace",
693
+ MARKETPLACE_DISCOVERY: "discovery-marketplace",
694
+ MARKETPLACE_ENTITLEMENT_SERVICE: "entitlement.marketplace",
695
+ MARKETPLACE_METERING: "metering.marketplace",
696
+ MARKETPLACE_REPORTING: "reporting-marketplace",
697
+ MEDIAPACKAGE_VOD: "mediapackage-vod",
698
+ MEDIASTORE_DATA: "data.mediastore",
699
+ MEDIATAILOR: "api.mediatailor",
700
+ MEDICAL_IMAGING: "medical-imaging",
701
+ MEMORYDB: "memory-db",
702
+ MIGRATIONHUBORCHESTRATOR: "migrationhub-orchestrator",
703
+ MIGRATIONHUBSTRATEGY: "migrationhub-strategy",
704
+ MIGRATIONHUB_CONFIG: "migrationhub-config",
705
+ MIGRATION_HUB: "mgh",
706
+ MIGRATION_HUB_REFACTOR_SPACES: "refactor-spaces",
707
+ MTURK: "mturk-requester",
708
+ MWAA: "airflow",
709
+ MWAA_SERVERLESS: "airflow-serverless",
710
+ NEPTUNE: "rds",
711
+ NEPTUNEDATA: "neptune-db",
712
+ NEPTUNE_GRAPH: "neptune-graph",
713
+ NETWORK_FIREWALL: "network-firewall",
714
+ NETWORK_SECURITY_MANAGER: "network-security-manager",
715
+ NOTIFICATIONSCONTACTS: "notifications-contacts",
716
+ NOVA_ACT: "nova-act",
717
+ OPENSEARCH: "es",
718
+ OPENSEARCHSERVERLESS: "aoss",
719
+ PARTNERCENTRAL_ACCOUNT: "partnercentral-account",
720
+ PARTNERCENTRAL_BENEFITS: "partnercentral-benefits",
721
+ PARTNERCENTRAL_CHANNEL: "partnercentral-channel",
722
+ PARTNERCENTRAL_REVENUE_MEASUREMENT: "partnercentral-prm",
723
+ PARTNERCENTRAL_SELLING: "partnercentral-selling",
724
+ PAYMENT_CRYPTOGRAPHY: "controlplane.payment-cryptography",
725
+ PAYMENT_CRYPTOGRAPHY_DATA: "dataplane.payment-cryptography",
726
+ PCA_CONNECTOR_AD: "pca-connector-ad",
727
+ PCA_CONNECTOR_SCEP: "pca-connector-scep",
728
+ PERSONALIZE_EVENTS: "personalize-events",
729
+ PERSONALIZE_RUNTIME: "personalize-runtime",
730
+ PINPOINT_EMAIL: "email",
731
+ PINPOINT_SMS_VOICE: "sms-voice.pinpoint",
732
+ PINPOINT_SMS_VOICE_V2: "sms-voice",
733
+ PRICING: "api.pricing",
734
+ QAPPS: "data.qapps",
735
+ QCONNECT: "wisdom",
736
+ RDS_DATA: "rds-data",
737
+ REDSHIFT_DATA: "redshift-data",
738
+ REDSHIFT_SERVERLESS: "redshift-serverless",
739
+ RESILIENCEHUBV2: "resiliencehub",
740
+ RESOURCE_EXPLORER_2: "resource-explorer-2",
741
+ RESOURCE_GROUPS: "resource-groups",
742
+ RESOURCE_GROUPS_TAGGING_API: "tagging",
743
+ ROUTE53_RECOVERY_CLUSTER: "route53-recovery-cluster",
744
+ ROUTE53_RECOVERY_CONTROL_CONFIG: "route53-recovery-control-config",
745
+ ROUTE53_RECOVERY_READINESS: "route53-recovery-readiness",
746
+ S3OUTPOSTS: "s3-outposts",
747
+ S3_CONTROL: "s3-control",
748
+ SAGEMAKER: "api.sagemaker",
749
+ SAGEMAKERJOBRUNTIME: "job-runtime.sagemaker",
750
+ SAGEMAKERTRAININGSESSIONRUNTIME: "training-session-runtime.sagemaker",
751
+ SAGEMAKER_A2I_RUNTIME: "a2i-runtime.sagemaker",
752
+ SAGEMAKER_EDGE: "edge.sagemaker",
753
+ SAGEMAKER_FEATURESTORE_RUNTIME: "featurestore-runtime.sagemaker",
754
+ SAGEMAKER_GEOSPATIAL: "sagemaker-geospatial",
755
+ SAGEMAKER_METRICS: "metrics.sagemaker",
756
+ SAGEMAKER_RUNTIME: "runtime.sagemaker",
757
+ SECURITY_IR: "security-ir",
758
+ SERVERLESSAPPLICATIONREPOSITORY: "serverlessrepo",
759
+ SERVICE_CATALOG_APPREGISTRY: "servicecatalog-appregistry",
760
+ SES: "email",
761
+ SESV2: "email",
762
+ SFN: "states",
763
+ SIGNER_DATA: "data-signer",
764
+ SIMPLEDB: "sdb",
765
+ SIMPLEDBV2: "sdb",
766
+ SNOW_DEVICE_MANAGEMENT: "snow-device-management",
767
+ SOCIALMESSAGING: "social-messaging",
768
+ SSM_CONTACTS: "ssm-contacts",
769
+ SSM_GUICONNECT: "ssm-guiconnect",
770
+ SSM_INCIDENTS: "ssm-incidents",
771
+ SSM_QUICKSETUP: "ssm-quicksetup",
772
+ SSM_SAP: "ssm-sap",
773
+ SSO: "portal.sso",
774
+ SSO_ADMIN: "sso",
775
+ SSO_OIDC: "oidc",
776
+ SUPPLYCHAIN: "scn",
777
+ TAXSETTINGS: "tax",
778
+ TIMESTREAM_INFLUXDB: "timestream-influxdb",
779
+ TIMESTREAM_QUERY: "query.timestream",
780
+ TIMESTREAM_WRITE: "ingest.timestream",
781
+ VPC_LATTICE: "vpc-lattice",
782
+ WAF_REGIONAL: "waf-regional",
783
+ WICKR: "admin.wickr",
784
+ WORKSPACES_INSTANCES: "workspaces-instances",
785
+ WORKSPACES_THIN_CLIENT: "thinclient",
786
+ WORKSPACES_WEB: "workspaces-web"
787
+ };
788
+ const AWS_GLOBAL_ENDPOINTS = {
789
+ account: {
790
+ hostname: "account.us-east-1.amazonaws.com",
791
+ signingRegion: "us-east-1"
792
+ },
793
+ billingconductor: {
794
+ hostname: "billingconductor.us-east-1.amazonaws.com",
795
+ signingRegion: "us-east-1"
796
+ },
797
+ budgets: {
798
+ hostname: "budgets.amazonaws.com",
799
+ signingRegion: "us-east-1"
800
+ },
801
+ ce: {
802
+ hostname: "ce.us-east-1.amazonaws.com",
803
+ signingRegion: "us-east-1"
804
+ },
805
+ chime: {
806
+ hostname: "chime.us-east-1.amazonaws.com",
807
+ signingRegion: "us-east-1"
808
+ },
809
+ cloudfront: {
810
+ hostname: "cloudfront.amazonaws.com",
811
+ signingRegion: "us-east-1"
812
+ },
813
+ health: {
814
+ hostname: "global.health.amazonaws.com",
815
+ signingRegion: "us-east-1"
816
+ },
817
+ iam: {
818
+ hostname: "iam.amazonaws.com",
819
+ signingRegion: "us-east-1"
820
+ },
821
+ importexport: {
822
+ hostname: "importexport.amazonaws.com",
823
+ signingRegion: "us-east-1"
824
+ },
825
+ networkmanager: {
826
+ hostname: "networkmanager.us-west-2.amazonaws.com",
827
+ signingRegion: "us-west-2"
828
+ },
829
+ "notifications-contacts": {
830
+ hostname: "notifications-contacts.us-east-1.api.aws",
831
+ signingRegion: "us-east-1"
832
+ },
833
+ organizations: {
834
+ hostname: "organizations.us-east-1.amazonaws.com",
835
+ signingRegion: "us-east-1"
836
+ },
837
+ route53: {
838
+ hostname: "route53.amazonaws.com",
839
+ signingRegion: "us-east-1"
840
+ },
841
+ savingsplans: {
842
+ hostname: "savingsplans.amazonaws.com",
843
+ signingRegion: "us-east-1"
844
+ },
845
+ shield: {
846
+ hostname: "shield.us-east-1.amazonaws.com",
847
+ signingRegion: "us-east-1"
848
+ },
849
+ tax: {
850
+ hostname: "tax.us-east-1.amazonaws.com",
851
+ signingRegion: "us-east-1"
852
+ },
853
+ waf: {
854
+ hostname: "waf.amazonaws.com",
855
+ signingRegion: "us-east-1"
856
+ }
857
+ };
858
+
859
+ //#endregion
860
+ //#region src/local/credential-error.ts
861
+ const SERVICE_MESSAGE_MAX = 512;
862
+ function stringifyThrown(err) {
863
+ try {
864
+ return err instanceof Error ? String(err.message) : String(err);
865
+ } catch {
866
+ return "[unstringifiable throw]";
867
+ }
868
+ }
869
+ function clampErrorName(err) {
870
+ let rawKind;
871
+ try {
872
+ rawKind = err instanceof Error ? err.name : "unknown";
873
+ } catch {
874
+ return "unknown";
875
+ }
876
+ return typeof rawKind === "string" && /^[A-Za-z0-9_.-]{1,64}$/.test(rawKind) ? rawKind : "unknown";
877
+ }
878
+ function clampErrorCode(err) {
879
+ if (!err || typeof err !== "object") return void 0;
880
+ let raw;
881
+ try {
882
+ raw = err.code;
883
+ } catch {
884
+ return;
885
+ }
886
+ if (typeof raw !== "string") return void 0;
887
+ return /^[A-Za-z0-9_.-]{1,64}$/.test(raw) ? raw : void 0;
888
+ }
889
+ function isAwsServiceException(err) {
890
+ if (!err || typeof err !== "object") return false;
891
+ const candidate = err;
892
+ try {
893
+ return Boolean(candidate.$metadata) && (candidate.$fault === "client" || candidate.$fault === "server");
894
+ } catch {
895
+ return false;
896
+ }
897
+ }
898
+ function flattenToOneLine(message) {
899
+ return message.replace(/[\p{Cc}\p{Cf}\p{Zl}\p{Zp}\p{Cs}]/gu, " ");
900
+ }
901
+ function sanitizeServiceExceptionMessage(message) {
902
+ const points = [...flattenToOneLine(message)];
903
+ if (points.length <= SERVICE_MESSAGE_MAX) return points.join("");
904
+ return `${points.slice(0, SERVICE_MESSAGE_MAX).join("")}[... truncated; ${points.length}-character message]`;
905
+ }
906
+ function describeCredentialLoadFailure(err) {
907
+ const code = clampErrorCode(err);
908
+ return `${code === void 0 ? clampErrorName(err) : `${clampErrorName(err)} ${code}`}; ${stringifyThrown(err).length}-character message withheld, logged at debug level under --verbose`;
909
+ }
910
+ function describeAwsFailureForWarn(err, operation) {
911
+ if (isAwsServiceException(err)) return `${clampErrorName(err)}: ${sanitizeServiceExceptionMessage(stringifyThrown(err))}`;
912
+ getLogger().debug(`${operation}: the AWS SDK's own failure message was: ${flattenToOneLine(stringifyThrown(err))}`);
913
+ return describeCredentialLoadFailure(err);
914
+ }
915
+
916
+ //#endregion
917
+ //#region src/utils/assembly-path.ts
918
+ function isInside(base, candidate) {
919
+ const rel = relative(base, candidate);
920
+ if (rel === "" || rel === "..") return false;
921
+ if (rel.startsWith(`..${sep}`)) return false;
922
+ return !isAbsolute(rel);
923
+ }
924
+ function tryRealpath(p) {
925
+ try {
926
+ return realpathSync.native(p);
927
+ } catch {
928
+ return;
929
+ }
930
+ }
931
+ function tryReadlink(p) {
932
+ try {
933
+ return readlinkSync(p);
934
+ } catch {
935
+ return;
936
+ }
937
+ }
938
+ const MAX_LINK_HOPS = 40;
939
+ const MAX_PATH_COMPONENTS = 1e3;
940
+ function resolveThroughLinks(target, hops = 0, climbs = 0) {
941
+ const direct = tryRealpath(target);
942
+ if (direct !== void 0) return direct;
943
+ if (hops >= MAX_LINK_HOPS) return void 0;
944
+ if (climbs >= MAX_PATH_COMPONENTS) return void 0;
945
+ const parent = dirname(target);
946
+ if (parent === target) return void 0;
947
+ const realParent = resolveThroughLinks(parent, hops, climbs + 1);
948
+ if (realParent === void 0) return void 0;
949
+ const link = tryReadlink(target);
950
+ if (link === void 0) return join(realParent, basename(target));
951
+ return resolveThroughLinks(resolve(realParent, link), hops + 1, climbs);
952
+ }
953
+ function resolveAssemblyPath(dir, candidate, options) {
954
+ const base = resolve(dir);
955
+ const bound = options?.containWithin === void 0 ? base : resolve(options.containWithin);
956
+ const joined = resolve(join(base, candidate));
957
+ if (!isInside(bound, joined)) return {
958
+ contained: false,
959
+ escape: "lexical",
960
+ path: joined
961
+ };
962
+ const realBound = resolveThroughLinks(bound);
963
+ if (realBound !== void 0) {
964
+ const realTarget = resolveThroughLinks(joined);
965
+ if (realTarget !== void 0 && !isInside(realBound, realTarget)) return {
966
+ contained: false,
967
+ escape: "symlink",
968
+ path: joined,
969
+ realPath: realTarget
970
+ };
971
+ }
972
+ return {
973
+ contained: true,
974
+ path: joined
975
+ };
976
+ }
977
+ function absoluteAssemblyPathEscape(bound, absolutePath) {
978
+ const resolvedBound = resolve(bound);
979
+ const target = resolve(absolutePath);
980
+ const lexicallyOutside = !isInside(resolvedBound, target) && target !== resolvedBound;
981
+ const realBound = resolveThroughLinks(resolvedBound);
982
+ const realTarget = resolveThroughLinks(target);
983
+ const reallyOutside = realBound === void 0 || realTarget === void 0 ? void 0 : !isInside(realBound, realTarget) && realTarget !== realBound;
984
+ if (lexicallyOutside) {
985
+ if (reallyOutside === false) return void 0;
986
+ return {
987
+ contained: false,
988
+ escape: "lexical",
989
+ path: target
990
+ };
991
+ }
992
+ if (reallyOutside === true) return {
993
+ contained: false,
994
+ escape: "symlink",
995
+ path: target,
996
+ realPath: realTarget
997
+ };
998
+ }
999
+ function namesTheSameDirectory(bound, candidate) {
1000
+ const resolvedBound = resolve(bound);
1001
+ const target = resolve(candidate);
1002
+ if (target === resolvedBound) return true;
1003
+ const realBound = resolveThroughLinks(resolvedBound);
1004
+ const realTarget = resolveThroughLinks(target);
1005
+ return realBound !== void 0 && realTarget !== void 0 && realBound === realTarget;
1006
+ }
1007
+ function assemblyPathEscape(base, bound, candidate) {
1008
+ if (isAbsolute(candidate)) return absoluteAssemblyPathEscape(bound, candidate);
1009
+ const resolved = resolveAssemblyPath(base, candidate, { containWithin: bound });
1010
+ if (resolved.contained || namesTheSameDirectory(bound, resolved.path)) return void 0;
1011
+ return resolved;
1012
+ }
1013
+ function renderAssemblyPathEscape(escape, dir, action, provenanceOverride) {
1014
+ const provenance = provenanceOverride ?? `CDK emits assembly paths that stay inside the assembly directory; one that leaves it indicates the synth output was hand-modified or generated by a non-CDK toolchain. Refusing to ${action}.`;
1015
+ const base = resolve(dir);
1016
+ const realBase = resolveThroughLinks(base) ?? base;
1017
+ const shownPath = displayUntrustedValue(escape.path);
1018
+ const shownBase = displayUntrustedValue(base);
1019
+ if (escape.escape === "symlink") {
1020
+ if (escape.realPath === realBase) return `resolves to ${shownPath}, a symbolic link to the directory ${shownBase} itself rather than to a path inside it. ${provenance}`;
1021
+ return `resolves to ${shownPath}, which leads through a symbolic link to ${displayUntrustedValue(escape.realPath)}, outside ${shownBase}. ${provenance}`;
1022
+ }
1023
+ if (escape.path === base) return `names the directory ${shownBase} itself rather than a path inside it. ${provenance}`;
1024
+ return `resolves to ${shownPath}, outside ${shownBase}. ${provenance}`;
1025
+ }
1026
+ const VISIBLE_LETTER = new RegExp(String.raw`^(?![\p{Default_Ignorable_Code_Point}\u02b0-\u02ff\u0374\u0559\u07f4\u07f5\ua78b\ua78c\uff9e\uff9f])[\p{L}\p{N}]$`, "u");
1027
+ const COMBINING_MARK = /^\p{M}$/u;
1028
+ const DEFAULT_IGNORABLE = /^\p{Default_Ignorable_Code_Point}$/u;
1029
+ const BARE_PUNCTUATION = /^[/\\._~+@:=-]$/;
1030
+ function classify(chars) {
1031
+ let afterLetter = false;
1032
+ return chars.map((ch) => {
1033
+ if (DEFAULT_IGNORABLE.test(ch)) {
1034
+ afterLetter = false;
1035
+ return "escaped";
1036
+ }
1037
+ if (COMBINING_MARK.test(ch)) return afterLetter ? "bare" : "escaped";
1038
+ afterLetter = VISIBLE_LETTER.test(ch);
1039
+ if (afterLetter || BARE_PUNCTUATION.test(ch)) return "bare";
1040
+ return ch >= " " && ch <= "~" ? "shown" : "escaped";
1041
+ });
1042
+ }
1043
+ function displayUntrustedValue(value) {
1044
+ const clean = sanitizeServiceExceptionMessage(value);
1045
+ const chars = Array.from(clean);
1046
+ const kinds = classify(chars);
1047
+ if (clean === value && chars.length > 0 && kinds.every((k) => k === "bare")) return clean;
1048
+ let body = "";
1049
+ chars.forEach((ch, i) => {
1050
+ if (ch === "\"" || ch === "\\") body += `\\${ch}`;
1051
+ else if (kinds[i] !== "escaped") body += ch;
1052
+ else for (let u = 0; u < ch.length; u++) body += `\\u${ch.charCodeAt(u).toString(16).padStart(4, "0")}`;
1053
+ });
1054
+ return `"${body}"`;
1055
+ }
1056
+ const PASTEABLE_COMMAND_ARG = /^[A-Za-z0-9][A-Za-z0-9~_.-]*$/;
1057
+ function isPasteableCommandArg(value) {
1058
+ return PASTEABLE_COMMAND_ARG.test(value) && displayUntrustedValue(value) === value;
1059
+ }
1060
+
1061
+ //#endregion
1062
+ //#region src/local/aws-emulator-mixed-mode.ts
1063
+ const REAL_AWS_SENTINEL = "real-aws";
1064
+ const LEGACY_AWS_EMULATOR_SENTINEL = "aws-emulator";
1065
+ const MIXED_MODE_RESIGN_PORT = 47297;
1066
+ const ENDPOINT_KEY = /^AWS_ENDPOINT_URL(?:_([A-Z0-9_]+))?$/;
1067
+ function isSentinel(key, value, sentinel) {
1068
+ return typeof value === "string" && value.trim() === sentinel && ENDPOINT_KEY.test(key);
1069
+ }
1070
+ function isRealAwsSentinel(key, value) {
1071
+ return isSentinel(key, value, REAL_AWS_SENTINEL);
1072
+ }
1073
+ function isLegacyAwsEmulatorSentinel(key, value) {
1074
+ return isSentinel(key, value, LEGACY_AWS_EMULATOR_SENTINEL);
1075
+ }
1076
+ function findSentinels(overrides, match) {
1077
+ const found = [];
1078
+ if (!overrides || typeof overrides !== "object") return found;
1079
+ for (const [section, map] of Object.entries(overrides)) {
1080
+ if (!map || typeof map !== "object" || Array.isArray(map)) continue;
1081
+ for (const [key, value] of Object.entries(map)) {
1082
+ if (!match(key, value)) continue;
1083
+ found.push({
1084
+ section,
1085
+ key,
1086
+ service: ENDPOINT_KEY.exec(key)[1] ?? ""
1087
+ });
1088
+ }
1089
+ }
1090
+ return found;
1091
+ }
1092
+ function findRealAwsExceptions(overrides) {
1093
+ return findSentinels(overrides, isRealAwsSentinel);
1094
+ }
1095
+ function findLegacyAwsEmulatorSentinels(overrides) {
1096
+ return findSentinels(overrides, isLegacyAwsEmulatorSentinel);
1097
+ }
1098
+ function readAwsEmulatorEnvVarsFile(filePath) {
1099
+ const none = {
1100
+ overrides: void 0,
1101
+ exceptions: [],
1102
+ legacySentinels: []
1103
+ };
1104
+ if (!filePath) return none;
1105
+ let parsed;
1106
+ try {
1107
+ parsed = JSON.parse(readEnvVarsFileText(filePath));
1108
+ } catch {
1109
+ return none;
1110
+ }
1111
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return none;
1112
+ const overrides = parsed;
1113
+ return {
1114
+ overrides,
1115
+ exceptions: findRealAwsExceptions(overrides),
1116
+ legacySentinels: findLegacyAwsEmulatorSentinels(overrides)
1117
+ };
1118
+ }
1119
+ function sectionAppliesTo(section, workload) {
1120
+ if (section === "Parameters") return false;
1121
+ if (workload.logicalId !== void 0 && section === workload.logicalId) return true;
1122
+ if (workload.containerName !== void 0 && section === workload.containerName) return true;
1123
+ const path = workload.cdkPath;
1124
+ return path !== void 0 && (path === section || path.startsWith(`${section}/`));
1125
+ }
1126
+ function realAwsServicesForWorkload(overrides, workload) {
1127
+ const out = /* @__PURE__ */ new Set();
1128
+ const apply = (map) => {
1129
+ if (!map || typeof map !== "object" || Array.isArray(map)) return;
1130
+ for (const [key, value] of Object.entries(map)) {
1131
+ const service = ENDPOINT_KEY.exec(key)?.[1];
1132
+ if (service === void 0) continue;
1133
+ if (isRealAwsSentinel(key, value)) out.add(service);
1134
+ else if (value === null || [
1135
+ "string",
1136
+ "number",
1137
+ "boolean"
1138
+ ].includes(typeof value)) out.delete(service);
1139
+ }
1140
+ };
1141
+ if (!overrides) return [];
1142
+ apply(overrides["Parameters"]);
1143
+ for (const [section, map] of Object.entries(overrides)) if (sectionAppliesTo(section, workload)) apply(map);
1144
+ return [...out].sort();
1145
+ }
1146
+ function correctServiceIdSpelling(service) {
1147
+ const bare = service.replace(/_/g, "");
1148
+ for (const id of AWS_ENDPOINT_SERVICE_IDS) if (id.replace(/_/g, "") === bare) return id;
1149
+ }
1150
+ function legacyAwsEmulatorSentinelMessage(s) {
1151
+ return `--env-vars sets ${s.key} under ${displayUntrustedValue(s.section)} to "${LEGACY_AWS_EMULATOR_SENTINEL}", which is no longer supported: --aws-emulator now sends EVERY service to AWS Emulator, and the --env-vars file marks only the exceptions that must reach real AWS, with "${REAL_AWS_SENTINEL}". Remove the "${LEGACY_AWS_EMULATOR_SENTINEL}" entries, and mark each service that must stay on real AWS instead, e.g. "AWS_ENDPOINT_URL_SECRETS_MANAGER": "${REAL_AWS_SENTINEL}".`;
1152
+ }
1153
+ function validateAwsEmulatorEnvVars(scan, awsEmulatorOn) {
1154
+ const legacy = scan.legacySentinels[0];
1155
+ if (legacy) throw new Error(legacyAwsEmulatorSentinelMessage(legacy));
1156
+ if (!awsEmulatorOn) return;
1157
+ if (scan.exceptions.some((s) => s.service === "")) throw new Error(`--env-vars: "AWS_ENDPOINT_URL": "${REAL_AWS_SENTINEL}" would send every AWS call to real AWS, which is what running without --aws-emulator does. Remove --aws-emulator to run against real AWS, or keep it and mark only the services that must reach real AWS, e.g. "AWS_ENDPOINT_URL_SECRETS_MANAGER": "${REAL_AWS_SENTINEL}".`);
1158
+ const unknown = scan.exceptions.find((s) => !AWS_ENDPOINT_SERVICE_IDS.has(s.service));
1159
+ if (unknown) {
1160
+ const fix = correctServiceIdSpelling(unknown.service);
1161
+ throw new Error(`--env-vars sets ${unknown.key} under ${displayUntrustedValue(unknown.section)} to "${REAL_AWS_SENTINEL}", but the AWS SDKs do not read ${unknown.key}, so the workload's calls would still go to AWS Emulator. ` + (fix ? `Use AWS_ENDPOINT_URL_${fix}.` : "The suffix must be the service's SDK endpoint id (its serviceId, uppercased, spaces as underscores)."));
1162
+ }
1163
+ }
1164
+ function realAwsServicesOf(exceptions) {
1165
+ return [...new Set(exceptions.map((s) => s.service).filter((s) => s !== ""))].sort();
1166
+ }
1167
+ const NO_REGIONAL_ENDPOINT = /* @__PURE__ */ new Set(["APIGATEWAYMANAGEMENTAPI", "CLOUDFRONT_KEYVALUESTORE"]);
1168
+ const REGION_SHAPE = /^[a-z]{2}(-[a-z]+)+-\d+$/;
1169
+ function realAwsEndpointFor(service, region) {
1170
+ if (!REGION_SHAPE.test(region)) throw new Error(`--env-vars marks AWS_ENDPOINT_URL_${service} "${REAL_AWS_SENTINEL}", but the workload's region ${displayUntrustedValue(region)} is not an AWS region name.`);
1171
+ if (NO_REGIONAL_ENDPOINT.has(service)) throw new Error(`--env-vars marks AWS_ENDPOINT_URL_${service} "${REAL_AWS_SENTINEL}", but ${service} has no regional endpoint to name. Set AWS_ENDPOINT_URL_${service} to the real endpoint URL instead (a literal URL is passed through as-is).`);
1172
+ const prefix = AWS_ENDPOINT_PREFIX_OVERRIDES[service] ?? service.toLowerCase().replace(/_/g, "");
1173
+ const isolated = /^(us|eu)-iso[a-z]*-/.test(region);
1174
+ const china = region.startsWith("cn-");
1175
+ const gov = region.startsWith("us-gov-");
1176
+ const global = AWS_GLOBAL_ENDPOINTS[prefix];
1177
+ if (isolated || global && (china || gov)) throw new Error(`--env-vars marks AWS_ENDPOINT_URL_${service} "${REAL_AWS_SENTINEL}", but ${displayUntrustedValue(region)} has no known real ${service} endpoint. Set AWS_ENDPOINT_URL_${service} to the real endpoint URL instead (a literal URL is passed through as-is).`);
1178
+ if (global) {
1179
+ if (global.signingRegion !== region) throw new Error(`--env-vars marks AWS_ENDPOINT_URL_${service} "${REAL_AWS_SENTINEL}", but ${service} is served by one global endpoint (https://${global.hostname}) that accepts only requests signed for ${global.signingRegion}, and an SDK signs a request to an explicit endpoint for the workload's region (${displayUntrustedValue(region)}), which that endpoint refuses. Leave ${service} on AWS Emulator, or run the workload in ${global.signingRegion}.`);
1180
+ return `https://${global.hostname}`;
1181
+ }
1182
+ return `https://${prefix}.${region}.${china ? "amazonaws.com.cn" : "amazonaws.com"}`;
1183
+ }
1184
+ const SERVICE_NAMESPACE_ALIASES = {
1185
+ EVENTBRIDGE: ["EVENTS"],
1186
+ SFN: ["STEPFUNCTIONS"],
1187
+ CLOUDWATCHLOGS: ["LOGS"],
1188
+ COGNITOIDENTITYPROVIDER: ["COGNITO"],
1189
+ COGNITOIDENTITY: ["COGNITO"],
1190
+ FIREHOSE: ["KINESISFIREHOSE"],
1191
+ OPENSEARCH: ["OPENSEARCHSERVICE"],
1192
+ ELASTICSEARCHSERVICE: ["ELASTICSEARCH"]
1193
+ };
1194
+ function resourceTypeMatchesService(resourceType, services) {
1195
+ const ns = /^AWS::([A-Za-z0-9]+)::/.exec(resourceType)?.[1]?.toUpperCase();
1196
+ if (!ns) return false;
1197
+ return services.some((s) => {
1198
+ const id = s.replace(/_/g, "").toUpperCase();
1199
+ return id === ns || (SERVICE_NAMESPACE_ALIASES[id] ?? []).includes(ns);
1200
+ });
1201
+ }
1202
+ const MISSING_LIST_LIMIT = 10;
1203
+ function createMixedModeStateProvider(opts) {
1204
+ const { real, emulator, realServices } = opts;
1205
+ const swaps = /* @__PURE__ */ new Map();
1206
+ const toReal = /* @__PURE__ */ new Map();
1207
+ const warned = /* @__PURE__ */ new Set();
1208
+ const warnedEmulator = /* @__PURE__ */ new Set();
1209
+ const swap = (v) => swaps.get(v) ?? v;
1210
+ const excepted = (res) => resourceTypeMatchesService(res.resourceType, realServices);
1211
+ const provider = {
1212
+ label: emulator.label,
1213
+ async load(stackName, synthRegion) {
1214
+ const [e, r] = await Promise.all([emulator.load(stackName, synthRegion), real.load(stackName, synthRegion)]);
1215
+ if (!r) {
1216
+ if (e && !warned.has(stackName) && Object.values(e.resources).some(excepted)) {
1217
+ warned.add(stackName);
1218
+ const why = real.getLastLoadError?.();
1219
+ getLogger().warn(`${emulator.label}: stack ${displayUntrustedValue(stackName)} could not be read from real AWS${why ? ` (${why})` : ""}; resources of the services marked "${REAL_AWS_SENTINEL}" (${realServices.join(", ")}) keep their AWS Emulator names. Override them with --env-vars, or deploy the stack to real AWS too.`);
1220
+ }
1221
+ return e;
1222
+ }
1223
+ if (!e) {
1224
+ const resources = {};
1225
+ const dropped = [];
1226
+ for (const [id, res] of Object.entries(r.resources)) if (excepted(res)) resources[id] = res;
1227
+ else dropped.push(`${displayUntrustedValue(id)} (${displayUntrustedValue(res.resourceType)})`);
1228
+ if (dropped.length > 0 && !warnedEmulator.has(stackName)) {
1229
+ warnedEmulator.add(stackName);
1230
+ const why = emulator.getLastLoadError?.();
1231
+ const shown = dropped.slice(0, MISSING_LIST_LIMIT).join(", ");
1232
+ const more = dropped.length > MISSING_LIST_LIMIT ? ` and ${dropped.length - MISSING_LIST_LIMIT} more` : "";
1233
+ getLogger().warn(`${emulator.label}: stack ${displayUntrustedValue(stackName)} could not be read from AWS Emulator${why ? ` (${why})` : ""}, only from real AWS; resources outside the services marked "${REAL_AWS_SENTINEL}" (${realServices.join(", ")}) stay unresolved: ${shown}${more}. Deploy the stack into AWS Emulator under the same stack name (the same CDK context, e.g. -c stage=dev), or override them with --env-vars.`);
1234
+ }
1235
+ return {
1236
+ resources,
1237
+ outputs: {},
1238
+ region: r.region
1239
+ };
1240
+ }
1241
+ const resources = { ...e.resources };
1242
+ for (const [id, res] of Object.entries(r.resources)) {
1243
+ const emuId = e.resources[id]?.physicalId;
1244
+ if (emuId && res.physicalId) toReal.set(emuId, res.physicalId);
1245
+ if (!excepted(res)) continue;
1246
+ const emuRes = e.resources[id];
1247
+ if (emuRes?.physicalId && res.physicalId && emuRes.physicalId !== res.physicalId) swaps.set(emuRes.physicalId, res.physicalId);
1248
+ resources[id] = res;
1249
+ }
1250
+ const outputs = {};
1251
+ for (const [k, v] of Object.entries(e.outputs)) outputs[k] = swap(v);
1252
+ return {
1253
+ resources,
1254
+ outputs,
1255
+ region: e.region
1256
+ };
1257
+ },
1258
+ buildCrossStackResolver: (region) => emulator.buildCrossStackResolver(region),
1259
+ dispose() {
1260
+ try {
1261
+ emulator.dispose();
1262
+ } finally {
1263
+ real.dispose();
1264
+ }
1265
+ }
1266
+ };
1267
+ if (emulator.resolveDeployedFunctionEnv) {
1268
+ const fn = emulator.resolveDeployedFunctionEnv.bind(emulator);
1269
+ provider.resolveDeployedFunctionEnv = async (id) => {
1270
+ const env = await fn(id);
1271
+ if (!env) return env;
1272
+ const out = {};
1273
+ for (const [k, v] of Object.entries(env)) out[k] = swap(v);
1274
+ return out;
1275
+ };
1276
+ }
1277
+ if (real.resolveLambdaExecutionRoleArn) {
1278
+ const fn = real.resolveLambdaExecutionRoleArn.bind(real);
1279
+ provider.resolveLambdaExecutionRoleArn = (id) => fn(toReal.get(id) ?? id);
1280
+ }
1281
+ if (real.resolveAgentCoreRuntimeRoleArn) {
1282
+ const fn = real.resolveAgentCoreRuntimeRoleArn.bind(real);
1283
+ provider.resolveAgentCoreRuntimeRoleArn = (id) => fn(toReal.get(id) ?? id);
1284
+ }
1285
+ if (real.resolveTemplateSsmParameters) provider.resolveTemplateSsmParameters = real.resolveTemplateSsmParameters.bind(real);
1286
+ if (emulator.getLastLoadError) provider.getLastLoadError = emulator.getLastLoadError.bind(emulator);
1287
+ return provider;
1288
+ }
1289
+
1290
+ //#endregion
1291
+ //#region src/utils/aws-proxy.ts
1292
+ const AGENT_OPTS = {
1293
+ keepAlive: true,
1294
+ maxSockets: 50
1295
+ };
1296
+ function isProxyEnvConfigured() {
1297
+ return PROXY_ENV_VARIABLES.some((key) => Boolean(process.env[key]));
1298
+ }
1299
+ const PROXY_ENV_VARIABLES = [
1300
+ "https_proxy",
1301
+ "HTTPS_PROXY",
1302
+ "http_proxy",
1303
+ "HTTP_PROXY",
1304
+ "all_proxy",
1305
+ "ALL_PROXY"
1306
+ ];
1307
+ function isSpeakableProxyEnvValue(value) {
1308
+ return !value.includes("://") || isSpeakableProxy(value.trim());
1309
+ }
1310
+ const AWS_ENDPOINT_PROBES = ["https://sts.amazonaws.com", "http://sts.amazonaws.com"];
1311
+ function everySetProxyEnvValueIsUnspeakable() {
1312
+ const set = PROXY_ENV_VARIABLES.map((key) => process.env[key] ?? "").filter((v) => v !== "");
1313
+ return set.length > 0 && !set.some(isSpeakableProxyEnvValue);
1314
+ }
1315
+ const warnedProxySchemes = /* @__PURE__ */ new Set();
1316
+ function proxySchemeOf(proxyUrl) {
1317
+ const match = /^([a-z][a-z0-9+.-]{0,31}):\/\//i.exec(proxyUrl);
1318
+ return match ? match[1].toLowerCase() : "(unrecognized)";
1319
+ }
1320
+ function isSpeakableProxy(proxyUrl) {
1321
+ return /^https?:\/\//i.test(proxyUrl);
1322
+ }
1323
+ function warnUnspeakableProxy(proxyUrl) {
1324
+ const scheme = proxySchemeOf(proxyUrl);
1325
+ if (warnedProxySchemes.has(scheme)) return;
1326
+ try {
1327
+ getLogger().child("aws-proxy").warn(`Unsupported proxy scheme "${scheme}" — cdk-local speaks HTTP CONNECT proxies only, so requests it would carry go DIRECT instead of through the proxy. Set HTTPS_PROXY / HTTP_PROXY / ALL_PROXY to an http:// or https:// proxy URL. (The proxy URL is withheld here: it can carry credentials.)`);
1328
+ } catch {
1329
+ return;
1330
+ }
1331
+ warnedProxySchemes.add(scheme);
1332
+ }
1333
+ function resolveProxyForTarget(targetHref) {
1334
+ const proxyUrl = getProxyForUrl(targetHref).trim();
1335
+ if (proxyUrl === "") return "";
1336
+ if (isSpeakableProxy(proxyUrl)) return proxyUrl;
1337
+ warnUnspeakableProxy(proxyUrl);
1338
+ return "";
1339
+ }
1340
+ var EnvRoutingProxyAgent = class extends Agent$2 {
1341
+ proxyAgents = /* @__PURE__ */ new Map();
1342
+ directHttpAgent = new Agent(AGENT_OPTS);
1343
+ directHttpsAgent = new Agent$1(AGENT_OPTS);
1344
+ constructor() {
1345
+ super(AGENT_OPTS);
1346
+ }
1347
+ connect(_req, options) {
1348
+ const secure = options.secureEndpoint;
1349
+ const host = options.host ?? "localhost";
1350
+ const port = options.port || (secure ? 443 : 80);
1351
+ const proxyUrl = resolveProxyForTarget(`${secure ? "https" : "http"}://${formatAuthority(host, port)}`);
1352
+ if (!proxyUrl) return secure ? this.directHttpsAgent : this.directHttpAgent;
1353
+ const key = `${secure ? "https" : "http"}|${proxyUrl}`;
1354
+ let agent = this.proxyAgents.get(key);
1355
+ if (!agent) {
1356
+ agent = secure ? new HttpsProxyAgent(proxyUrl, AGENT_OPTS) : new HttpProxyAgent(proxyUrl, AGENT_OPTS);
1357
+ this.proxyAgents.set(key, agent);
1358
+ }
1359
+ return agent;
1360
+ }
1361
+ destroy() {
1362
+ for (const agent of this.proxyAgents.values()) agent.destroy();
1363
+ this.proxyAgents.clear();
1364
+ this.directHttpAgent.destroy();
1365
+ this.directHttpsAgent.destroy();
1366
+ super.destroy();
1367
+ }
1368
+ };
1369
+ let endpointOverride;
1370
+ function setAwsEndpointOverride(o) {
1371
+ endpointOverride = o;
1372
+ }
1373
+ function getAwsEndpointOverride() {
1374
+ return endpointOverride;
1375
+ }
1376
+ let serviceRouting;
1377
+ function normalizeAwsEndpointServiceId(serviceId) {
1378
+ return serviceId.trim().replace(/ /g, "_").toUpperCase();
1379
+ }
1380
+ function setAwsEmulatorServiceRouting(r) {
1381
+ serviceRouting = r ? {
1382
+ realServices: new Set(r.realServices.map(normalizeAwsEndpointServiceId)),
1383
+ override: r.override,
1384
+ envOverrides: r.envOverrides
1385
+ } : void 0;
1386
+ }
1387
+ function getAwsEmulatorServiceRouting() {
1388
+ return serviceRouting ? {
1389
+ realServices: [...serviceRouting.realServices].sort(),
1390
+ override: serviceRouting.override,
1391
+ ...serviceRouting.envOverrides && { envOverrides: serviceRouting.envOverrides }
1392
+ } : void 0;
1393
+ }
1394
+ function awsEmulatorRealServices(workload) {
1395
+ if (!serviceRouting) return void 0;
1396
+ if (serviceRouting.envOverrides === void 0) return [...serviceRouting.realServices].sort();
1397
+ return realAwsServicesForWorkload(serviceRouting.envOverrides, workload ?? {});
1398
+ }
1399
+ function mixedModeRoutes(serviceId, workload) {
1400
+ const real = awsEmulatorRealServices(workload);
1401
+ return real !== void 0 && !real.includes(normalizeAwsEndpointServiceId(serviceId));
1402
+ }
1403
+ function isAwsServiceRoutedToEmulator(serviceId, workload) {
1404
+ if (endpointOverride) return true;
1405
+ return mixedModeRoutes(serviceId, workload);
1406
+ }
1407
+ function awsClientConfigForService(serviceId, opts = {}) {
1408
+ return buildProxyClientConfig({
1409
+ ...opts,
1410
+ service: serviceId
1411
+ });
1412
+ }
1413
+ function awsEndpointOverrideClientConfig(o) {
1414
+ return endpointOverrideClientConfig(o);
1415
+ }
1416
+ function deployArtifactsReadEmulator(service, workload) {
1417
+ return isAwsServiceRoutedToEmulator(service, workload);
1418
+ }
1419
+ function deployArtifactClientConfig(opts) {
1420
+ return buildProxyClientConfig(opts);
1421
+ }
1422
+ function endpointOverrideClientConfig(o) {
1423
+ const httpsAgent = new Agent$1({
1424
+ keepAlive: true,
1425
+ ...o.caPem ? { ca: [...rootCertificates, o.caPem] } : {}
1426
+ });
1427
+ const creds = o.credentials;
1428
+ return {
1429
+ endpoint: o.endpoint,
1430
+ requestHandler: new NodeHttpHandler({ httpsAgent }),
1431
+ ...creds ? { credentials: async () => ({
1432
+ accessKeyId: creds.accessKeyId,
1433
+ secretAccessKey: creds.secretAccessKey,
1434
+ ...creds.sessionToken ? { sessionToken: creds.sessionToken } : {}
1435
+ }) } : {}
1436
+ };
1437
+ }
1438
+ function buildProxyRequestHandler() {
1439
+ const agent = new EnvRoutingProxyAgent();
1440
+ return new NodeHttpHandler({
1441
+ httpAgent: agent,
1442
+ httpsAgent: agent
1443
+ });
1444
+ }
1445
+ function buildProxyClientConfig(opts = {}) {
1446
+ if (endpointOverride) return endpointOverrideClientConfig(endpointOverride);
1447
+ if (serviceRouting && opts.service !== void 0 && mixedModeRoutes(opts.service, opts.workload)) return endpointOverrideClientConfig(serviceRouting.override);
1448
+ if (!isProxyEnvConfigured()) return {};
1449
+ if (everySetProxyEnvValueIsUnspeakable()) {
1450
+ for (const probe of AWS_ENDPOINT_PROBES) resolveProxyForTarget(probe);
1451
+ return {};
1452
+ }
1453
+ const profile = opts.profile;
1454
+ let chain;
1455
+ const credentials = async (identityProperties) => {
1456
+ chain ??= (async () => {
1457
+ const { defaultProvider } = await import("@aws-sdk/credential-provider-node");
1458
+ return defaultProvider({
1459
+ ...profile ? { profile } : {},
1460
+ clientConfig: { requestHandler: buildProxyRequestHandler() }
1461
+ });
1462
+ })().catch((err) => {
1463
+ chain = void 0;
1464
+ throw err;
1465
+ });
1466
+ return (await chain)(identityProperties);
1467
+ };
1468
+ return {
1469
+ requestHandler: buildProxyRequestHandler(),
1470
+ credentials
1471
+ };
1472
+ }
1473
+ const MAX_FETCH_REDIRECTS = 20;
1474
+ const NULL_BODY_STATUSES = /* @__PURE__ */ new Set([
1475
+ 204,
1476
+ 205,
1477
+ 304
1478
+ ]);
1479
+ const REQUEST_STALL_TIMEOUT_MS = 3e5;
1480
+ function isRedirectStatus(status) {
1481
+ return status === 301 || status === 302 || status === 303 || status === 307 || status === 308;
1482
+ }
1483
+ function parseHttpUrl(href) {
1484
+ const parsed = new URL(href);
1485
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw new TypeError(`Unsupported protocol for a proxied request: "${parsed.protocol}"`);
1486
+ return parsed;
1487
+ }
1488
+ function getThroughAgent(url, agent, timeoutMs = REQUEST_STALL_TIMEOUT_MS) {
1489
+ return new Promise((resolve, reject) => {
1490
+ let settled = false;
1491
+ let timer;
1492
+ let rearm = () => void 0;
1493
+ const succeed = (value) => {
1494
+ if (settled) return;
1495
+ settled = true;
1496
+ if (timer) clearTimeout(timer);
1497
+ resolve(value);
1498
+ };
1499
+ const fail = (err) => {
1500
+ if (settled) return;
1501
+ settled = true;
1502
+ if (timer) clearTimeout(timer);
1503
+ reject(err);
1504
+ };
1505
+ const req = (url.protocol === "https:" ? request$1 : request)(url, {
1506
+ agent,
1507
+ headers: {
1508
+ accept: "*/*",
1509
+ "accept-encoding": "identity"
1510
+ }
1511
+ }, (res) => {
1512
+ rearm();
1513
+ const chunks = [];
1514
+ res.on("data", (chunk) => {
1515
+ rearm();
1516
+ chunks.push(chunk);
1517
+ });
1518
+ res.on("error", fail);
1519
+ res.on("end", () => {
1520
+ if (res.statusCode === void 0) {
1521
+ fail(/* @__PURE__ */ new Error("Malformed HTTP response: no status code"));
1522
+ return;
1523
+ }
1524
+ succeed({
1525
+ status: res.statusCode,
1526
+ statusText: res.statusMessage ?? "",
1527
+ headers: res.headers,
1528
+ body: Buffer.concat(chunks)
1529
+ });
1530
+ });
1531
+ });
1532
+ req.on("error", fail);
1533
+ rearm = () => {
1534
+ if (settled) return;
1535
+ if (timer) clearTimeout(timer);
1536
+ timer = setTimeout(() => {
1537
+ req.destroy();
1538
+ fail(/* @__PURE__ */ new Error(`Proxied request stalled for ${timeoutMs} ms with no progress`));
1539
+ }, timeoutMs);
1540
+ timer.unref?.();
1541
+ };
1542
+ rearm();
1543
+ req.end();
1544
+ });
1545
+ }
1546
+ function decodeContentEncoding(raw) {
1547
+ const header = raw.headers["content-encoding"];
1548
+ const encoding = (Array.isArray(header) ? header.join(",") : header ?? "").trim().toLowerCase();
1549
+ if (encoding === "" || encoding === "identity") return {
1550
+ body: raw.body,
1551
+ decoded: false
1552
+ };
1553
+ try {
1554
+ if (encoding === "gzip" || encoding === "x-gzip") return {
1555
+ body: gunzipSync(raw.body),
1556
+ decoded: true
1557
+ };
1558
+ if (encoding === "deflate" || encoding === "x-deflate") return {
1559
+ body: inflateSync(raw.body),
1560
+ decoded: true
1561
+ };
1562
+ if (encoding === "br") return {
1563
+ body: brotliDecompressSync(raw.body),
1564
+ decoded: true
1565
+ };
1566
+ } catch {
1567
+ return {
1568
+ body: raw.body,
1569
+ decoded: false
1570
+ };
1571
+ }
1572
+ return {
1573
+ body: raw.body,
1574
+ decoded: false
1575
+ };
1576
+ }
1577
+ function toWebResponse(raw) {
1578
+ if (raw.status < 200 || raw.status > 599) throw new Error(`Unsupported HTTP status in response: ${raw.status}`);
1579
+ const { body, decoded } = decodeContentEncoding(raw);
1580
+ const headers = new Headers();
1581
+ for (const [name, value] of Object.entries(raw.headers)) {
1582
+ if (value === void 0) continue;
1583
+ if (decoded && (name === "content-encoding" || name === "content-length")) continue;
1584
+ if (Array.isArray(value)) for (const one of value) headers.append(name, one);
1585
+ else headers.append(name, value);
1586
+ }
1587
+ return new Response(NULL_BODY_STATUSES.has(raw.status) ? null : body, {
1588
+ status: raw.status,
1589
+ statusText: raw.statusText.replace(/[^\t\x20-\x7e\x80-\xff]/g, ""),
1590
+ headers
1591
+ });
1592
+ }
1593
+ async function proxyAwareFetch(url, opts = {}) {
1594
+ if (!isProxyEnvConfigured()) return globalThis.fetch(url);
1595
+ let target = parseHttpUrl(url);
1596
+ for (let hop = 0;; hop++) {
1597
+ if (isLoopbackHost(target.hostname) || resolveProxyForTarget(target.href) === "") return globalThis.fetch(target.href);
1598
+ const agent = new EnvRoutingProxyAgent();
1599
+ let raw;
1600
+ try {
1601
+ raw = await getThroughAgent(target, agent, opts.timeoutMs);
1602
+ } finally {
1603
+ agent.destroy();
1604
+ }
1605
+ const location = raw.headers["location"];
1606
+ if (!isRedirectStatus(raw.status) || typeof location !== "string" || location === "") return toWebResponse(raw);
1607
+ if (hop >= MAX_FETCH_REDIRECTS) throw new Error(`Too many redirects (more than ${MAX_FETCH_REDIRECTS})`);
1608
+ target = parseHttpUrl(new URL(location, target).href);
1609
+ }
1610
+ }
1611
+
1612
+ //#endregion
1613
+ export { formatHostForAuthority as $, validateAwsEmulatorEnvVars as A, describeCredentialLoadFailure as B, isRealAwsSentinel as C, realAwsServicesForWorkload as D, realAwsEndpointFor as E, namesTheSameDirectory as F, AWS_ENDPOINT_SERVICE_IDS as G, isAwsServiceException as H, renderAssemblyPathEscape as I, resolveEnvVars as J, applyEnvOverrideMap as K, resolveAssemblyPath as L, assemblyPathEscape as M, displayUntrustedValue as N, realAwsServicesOf as O, isPasteableCommandArg as P, formatAuthority as Q, clampErrorName as R, isLegacyAwsEmulatorSentinel as S, readAwsEmulatorEnvVarsFile as T, sanitizeServiceExceptionMessage as U, flattenToOneLine as V, stringifyThrown as W, isLoopbackHostname as X, defineOwnKey as Y, isWildcardHostname as Z, MIXED_MODE_RESIGN_PORT as _, buildProxyRequestHandler as a, findLegacyAwsEmulatorSentinels as b, getAwsEmulatorServiceRouting as c, isProxyEnvConfigured as d, hostFromAuthority as et, normalizeAwsEndpointServiceId as f, LEGACY_AWS_EMULATOR_SENTINEL as g, setAwsEndpointOverride as h, buildProxyClientConfig as i, absoluteAssemblyPathEscape as j, resourceTypeMatchesService as k, getAwsEndpointOverride as l, setAwsEmulatorServiceRouting as m, awsEmulatorRealServices as n, deployArtifactClientConfig as o, proxyAwareFetch as p, readEnvVarsFileText as q, awsEndpointOverrideClientConfig as r, deployArtifactsReadEmulator as s, awsClientConfigForService as t, isAwsServiceRoutedToEmulator as u, REAL_AWS_SENTINEL as v, legacyAwsEmulatorSentinelMessage as w, findRealAwsExceptions as x, createMixedModeStateProvider as y, describeAwsFailureForWarn as z };
1614
+ //# sourceMappingURL=aws-proxy-CtjweaLu.js.map