@desplega.ai/agent-swarm 1.152.2 → 1.154.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.
Files changed (284) hide show
  1. package/README.md +2 -2
  2. package/dist/{acp-adapter-pfeje2v5.js → acp-adapter-eb2aj8xy.js} +4 -4
  3. package/dist/{actions-0sttc7f5.js → actions-kpnwp1kz.js} +31 -27
  4. package/dist/{anthropic-messages-2y8nktar.js → anthropic-messages-9vqsbznt.js} +112 -84
  5. package/dist/{app-p8teva95.js → app-zk1apkf6.js} +10 -7
  6. package/dist/{assistant-r45jnsrt.js → assistant-kwq4y50q.js} +32 -28
  7. package/dist/{azure-openai-responses-f38x2avq.js → azure-openai-responses-04qwdwfq.js} +27 -13
  8. package/dist/{boot-reembed-je26h5y7.js → boot-reembed-22hd3jjn.js} +9 -7
  9. package/dist/{boot-reembed-1qmybsd4.js → boot-reembed-qe168424.js} +10 -8
  10. package/dist/{boot-scrub-logs-gte3h1mm.js → boot-scrub-logs-pkdpsrjd.js} +7 -5
  11. package/dist/{claude-adapter-csc1mzka.js → claude-adapter-3fx90nww.js} +18 -16
  12. package/dist/{claude-managed-adapter-dsmkcrjy.js → claude-managed-adapter-ea2aga6w.js} +3 -3
  13. package/dist/{claude-sdk-session-fcd6f078.js → claude-sdk-session-z7fahf1k.js} +18 -16
  14. package/dist/{cli-r2fpe7cx.js → cli-00w2c66p.js} +61 -55
  15. package/dist/{cli-wbyk465z.js → cli-09y3tjxz.js} +1 -1
  16. package/dist/{cli-ht5rs63n.js → cli-0e31nm4n.js} +16 -7
  17. package/dist/cli-0x5qzvkg.js +4279 -0
  18. package/dist/{cli-d3p82erb.js → cli-18amys3y.js} +9 -9
  19. package/dist/{cli-4ahpr4sw.js → cli-1jpjafw4.js} +5 -5
  20. package/dist/{cli-jbmc0r7r.js → cli-243tzws8.js} +1 -1
  21. package/dist/{cli-ch38q5z4.js → cli-24k806sc.js} +6789 -2542
  22. package/dist/cli-3bkz2p7j.js +2828 -0
  23. package/dist/cli-3er6gcsn.js +1849 -0
  24. package/dist/cli-4k7jazkq.js +3339 -0
  25. package/dist/{cli-c4eeb5q2.js → cli-5b6b62tz.js} +1 -1
  26. package/dist/{cli-qd65dvr6.js → cli-5vs0nh43.js} +65 -44
  27. package/dist/{cli-z3wkng35.js → cli-6r3cgpk2.js} +224 -156
  28. package/dist/{cli-pgj4a5fb.js → cli-71cj99hx.js} +4 -3
  29. package/dist/cli-8sea27q4.js +14075 -0
  30. package/dist/{cli-jvy9qgjs.js → cli-913yakhv.js} +22 -7
  31. package/dist/{cli-pf9q3696.js → cli-927erqqt.js} +5 -2
  32. package/dist/cli-95jnpnqg.js +230 -0
  33. package/dist/{cli-wpv5rgg2.js → cli-abp3g4ax.js} +15 -2
  34. package/dist/{cli-ckz5t2hb.js → cli-acy6bfhr.js} +10 -7
  35. package/dist/{cli-4yc5d8fk.js → cli-avkd6mqv.js} +50 -0
  36. package/dist/{cli-8wrympd7.js → cli-bzr0ftht.js} +26 -7
  37. package/dist/{cli-qn042eh7.js → cli-c1v10xb2.js} +194 -1913
  38. package/dist/cli-cgj4hc12.js +18902 -0
  39. package/dist/{cli-2nnd56zt.js → cli-e0pg4zeh.js} +3 -2
  40. package/dist/{cli-r84ctdxn.js → cli-e31ehqwy.js} +2 -2
  41. package/dist/{cli-gphgnvpf.js → cli-e3229na9.js} +3 -3
  42. package/dist/{cli-gpqcs935.js → cli-e3cyf59d.js} +2 -2
  43. package/dist/{cli-s25avqg9.js → cli-e781c6f9.js} +1 -0
  44. package/dist/{cli-s2qjdd6z.js → cli-eetrvv91.js} +1 -1
  45. package/dist/{cli-j4nv2wqy.js → cli-fdzg6jhf.js} +10 -4
  46. package/dist/{cli-fm4ytsdk.js → cli-g2h29qar.js} +2 -2
  47. package/dist/{cli-zvgj5zg8.js → cli-ge67p080.js} +302 -3497
  48. package/dist/cli-h38x0qhg.js +6912 -0
  49. package/dist/{cli-9xvdm3bx.js → cli-h60qfasa.js} +742 -278
  50. package/dist/{cli-jew3jda5.js → cli-hws0vn86.js} +2 -2
  51. package/dist/{cli-j8dggbcr.js → cli-k0g1sjzm.js} +23 -31
  52. package/dist/{cli-xw7vak96.js → cli-kp3qs53m.js} +5 -5
  53. package/dist/{cli-rgvp6r2x.js → cli-mcnhgnn1.js} +193 -4
  54. package/dist/{cli-zvkq5csn.js → cli-myaxtgh8.js} +7 -6
  55. package/dist/{cli-56h18ng2.js → cli-n62atwh9.js} +1 -1
  56. package/dist/cli-n7h1kqpf.js +29 -0
  57. package/dist/{cli-fmy65jdn.js → cli-pf1v8xhb.js} +7 -5
  58. package/dist/{cli-xy1cchaf.js → cli-q85qhckh.js} +238 -11
  59. package/dist/{cli-3bpzj8me.js → cli-r1d3dzt6.js} +2 -2
  60. package/dist/{pi-mono-adapter-jcqt71cg.js → cli-rxkqvngf.js} +67343 -101083
  61. package/dist/{cli-kj76p1ez.js → cli-scwq51gn.js} +13 -7
  62. package/dist/{cli-b9dd0h3k.js → cli-stwsmd6k.js} +3 -2
  63. package/dist/{cli-c2mk1kgf.js → cli-v4en75c5.js} +8 -1
  64. package/dist/{cli-z61ykvam.js → cli-wg04s9kr.js} +4 -3
  65. package/dist/cli-yn0a417a.js +4069 -0
  66. package/dist/{cli-zfzznn7c.js → cli-ytxs7mn1.js} +26 -2
  67. package/dist/{cli-4j8k1m4w.js → cli-zt1227k1.js} +1162 -192
  68. package/dist/cli.js +28 -35
  69. package/dist/{codex-adapter-fxmpsabw.js → codex-adapter-ttdm995v.js} +12 -11
  70. package/dist/{codex-hook-8jexc34x.js → codex-hook-8gx7bcz0.js} +3 -3
  71. package/dist/{codex-session-runner-rr1e47ea.js → codex-session-runner-3v8nh4c8.js} +12 -11
  72. package/dist/{commands-0f5rxz51.js → commands-1cxwbhhq.js} +7 -5
  73. package/dist/{db-r3jxf3wy.js → db-y9zwsr79.js} +25 -5
  74. package/dist/{dispatcher-06vph6q4.js → dispatcher-9m9zss36.js} +30 -26
  75. package/dist/dsh-adapter-gsb2qqf9.js +19 -0
  76. package/dist/{e2b-413b8t4v.js → e2b-93x1k0j5.js} +6 -7
  77. package/dist/{google-generative-ai-ndjmj5fa.js → google-generative-ai-gwwrnzqn.js} +33 -73
  78. package/dist/{google-vertex-fr665tqs.js → google-vertex-5wfawpwz.js} +38 -68
  79. package/dist/{handlers-0hgtc910.js → handlers-36fm1bwn.js} +33 -29
  80. package/dist/{hook-9kvrv1er.js → hook-pntw4r8h.js} +12 -10
  81. package/dist/{hook-fbfhkat3.js → hook-vwq8y26p.js} +13 -11
  82. package/dist/{http-xbyx8k5j.js → http-20jesakk.js} +357 -261
  83. package/dist/{index-jsw3aynb.js → index-6artrehg.js} +30 -26
  84. package/dist/{cli-pdz9qde4.js → index-9ch1n761.js} +10 -11
  85. package/dist/{index-rnyahfn5.js → index-9n5z2492.js} +30 -26
  86. package/dist/{index-66xz5e9j.js → index-h5gs261z.js} +521 -9
  87. package/dist/{index-tfsdxyv6.js → index-j5wrf1yw.js} +40 -25
  88. package/dist/{index-2sp0384z.js → index-kkeftv5h.js} +738 -21
  89. package/dist/{index-sgk50mbg.js → index-m2xqpz5r.js} +31 -27
  90. package/dist/{index-gpfn1741.js → index-m9ks8a7t.js} +9 -7
  91. package/dist/index-w097eg0x.js +5 -0
  92. package/dist/jiti-loader-b4837mtm.js +34 -0
  93. package/dist/jiti-static-loader-q2g5ds0y.js +31267 -0
  94. package/dist/{keepalive-s3xpr7sw.js → keepalive-pwxvxd2c.js} +9 -7
  95. package/dist/{lead-rq4n5r16.js → lead-m789wqa3.js} +46 -41
  96. package/dist/{maintenance-f0atj1ab.js → maintenance-bvg6w7e2.js} +10 -8
  97. package/dist/{mistral-conversations-qhr84ph3.js → mistral-conversations-zx0kn554.js} +24 -18
  98. package/dist/{node-x1g4v0pq.js → node-5qtycf6a.js} +16 -11
  99. package/dist/{oauth-refresh-sweep-q0t3bxre.js → oauth-refresh-sweep-6v4bd737.js} +8 -6
  100. package/dist/{onboard-br5j1kch.js → onboard-snckpcj1.js} +115 -35
  101. package/dist/{openai-codex-responses-wy6a43wd.js → openai-codex-responses-4vjqzvjp.js} +33 -27
  102. package/dist/{openai-completions-32rdwmze.js → openai-completions-pxsmym7g.js} +52 -64
  103. package/dist/{openai-responses-6xwf7bzg.js → openai-responses-tmn0rqp0.js} +23 -24
  104. package/dist/{opencode-adapter-28axqa09.js → opencode-adapter-qbmv4tpy.js} +6 -6
  105. package/dist/{otel-impl-vdqge2nt.js → otel-impl-e0ytens5.js} +4 -4
  106. package/dist/{pi-messages-b1mbr6gp.js → pi-messages-txpjj39q.js} +3 -3
  107. package/dist/pi-mono-adapter-c4ggemhz.js +1316 -0
  108. package/dist/{pricing-refresh-hb3691fd.js → pricing-refresh-52g2ywrw.js} +9 -7
  109. package/dist/{rbac-roles-t78xt39b.js → rbac-roles-5455kfdn.js} +8 -6
  110. package/dist/{rbac-roles-jh280k9g.js → rbac-roles-hbf0xa52.js} +9 -7
  111. package/dist/{render-v2-7p8r2ymg.js → render-v2-npm8xdzh.js} +16 -9
  112. package/dist/{seed-pricing-hf889enh.js → seed-pricing-650wbr1n.js} +8 -6
  113. package/dist/{setup-w6mb03jv.js → setup-k1mew5rf.js} +4 -5
  114. package/dist/virtual-modules-2q5b2pk4.js +54 -0
  115. package/dist/{work-objects-nt8gy1kj.js → work-objects-2ea3kvwg.js} +33 -29
  116. package/dist/{worker-dwy617t0.js → worker-ec6hvc4m.js} +46 -41
  117. package/openapi.json +109 -16
  118. package/package.json +7 -6
  119. package/plugin/opencode-plugins/lib/memory-raters.ts +7 -0
  120. package/src/be/automation-preflight.ts +6 -4
  121. package/src/be/db/agents.ts +75 -2
  122. package/src/be/db/tasks/read.ts +2 -0
  123. package/src/be/db/tasks/write.ts +7 -1
  124. package/src/be/db.ts +140 -18
  125. package/src/be/extensions/db.ts +35 -4
  126. package/src/be/memory/raters/llm.ts +2 -6
  127. package/src/be/memory/raters/noop.ts +2 -3
  128. package/src/be/memory/raters/registry.ts +4 -10
  129. package/src/be/migrations/157_defer_provenance_and_marker.sql +27 -0
  130. package/src/be/models-catalog.ts +2 -0
  131. package/src/be/modelsdev-cache.json +213 -0
  132. package/src/be/rbac-audit.ts +2 -0
  133. package/src/be/seed/agent-fs-provision.ts +23 -0
  134. package/src/be/seed-pricing.ts +3 -1
  135. package/src/be/swarm-config-guard.ts +1 -0
  136. package/src/commands/onboard/compose-generator.ts +16 -1
  137. package/src/commands/onboard/env-generator.ts +14 -1
  138. package/src/commands/onboard/manifest.ts +1 -0
  139. package/src/commands/onboard/steps/integration-slack.tsx +56 -16
  140. package/src/commands/onboard/steps/review.tsx +5 -0
  141. package/src/commands/onboard/types.ts +6 -0
  142. package/src/commands/onboard.tsx +5 -1
  143. package/src/commands/provider-credentials.ts +14 -2
  144. package/src/commands/runner.ts +18 -2
  145. package/src/extensions/identity.ts +15 -7
  146. package/src/extensions/lifecycle.ts +15 -21
  147. package/src/hooks/codex-hook.ts +7 -1
  148. package/src/http/agents.ts +12 -4
  149. package/src/http/config.ts +1 -1
  150. package/src/http/core.ts +5 -3
  151. package/src/http/extensions.ts +108 -34
  152. package/src/http/poll.ts +7 -0
  153. package/src/http/schedules.ts +10 -0
  154. package/src/http/script-runs.ts +35 -26
  155. package/src/http/status.ts +24 -11
  156. package/src/http/tasks.ts +6 -1
  157. package/src/prompts/base-prompt.ts +15 -7
  158. package/src/prompts/memories.ts +5 -7
  159. package/src/prompts/session-templates.ts +3 -2
  160. package/src/prompts/steering-delivery.ts +2 -0
  161. package/src/providers/claude-managed-models.ts +8 -0
  162. package/src/providers/codex-adapter.ts +3 -6
  163. package/src/providers/codex-models.ts +15 -1
  164. package/src/providers/dsh-adapter.ts +248 -0
  165. package/src/providers/index.ts +5 -1
  166. package/src/providers/modelsdev-reasoning.json +50 -0
  167. package/src/providers/pi-mono-extension.ts +2 -5
  168. package/src/rbac/legacy-policy.ts +15 -1
  169. package/src/rbac/types.ts +2 -0
  170. package/src/server.ts +7 -1
  171. package/src/slack/ack.ts +43 -8
  172. package/src/slack/app.ts +32 -10
  173. package/src/slack/config.ts +29 -0
  174. package/src/slack/handlers.ts +7 -1
  175. package/src/slack/render-v2.ts +186 -17
  176. package/src/slack/responses.ts +1 -3
  177. package/src/slack/task-output.ts +66 -8
  178. package/src/slack/thread-buffer.ts +27 -3
  179. package/src/telemetry.ts +2 -3
  180. package/src/tests/agent-fs-provision-seeder.test.ts +56 -2
  181. package/src/tests/agents-harness-provider.test.ts +19 -0
  182. package/src/tests/agents-list-model-display.test.ts +60 -1
  183. package/src/tests/base-prompt.test.ts +25 -0
  184. package/src/tests/claude-managed-adapter.test.ts +6 -0
  185. package/src/tests/codex-gpt6-release.test.ts +97 -0
  186. package/src/tests/codex-steering-hook.test.ts +2 -2
  187. package/src/tests/config-api-only-keys.test.ts +9 -0
  188. package/src/tests/context-window.test.ts +1 -0
  189. package/src/tests/db-task-read-contract.test.ts +9 -0
  190. package/src/tests/db-task-write-contract.test.ts +9 -0
  191. package/src/tests/defer-task.test.ts +115 -16
  192. package/src/tests/dsh-adapter.test.ts +276 -0
  193. package/src/tests/e2e-nightly-report.test.ts +3 -3
  194. package/src/tests/e2e-redact.test.ts +2 -0
  195. package/src/tests/env-flag.test.ts +6 -0
  196. package/src/tests/extension-agent-visibility.test.ts +474 -0
  197. package/src/tests/extensions-db.test.ts +41 -0
  198. package/src/tests/extensions-http.test.ts +148 -4
  199. package/src/tests/extensions-lifecycle.test.ts +21 -1
  200. package/src/tests/extensions-mcp-tools.test.ts +9 -5
  201. package/src/tests/fetch-resolved-env.test.ts +43 -0
  202. package/src/tests/internal-ai/complete-structured.test.ts +32 -9
  203. package/src/tests/internal-ai/credentials.test.ts +4 -4
  204. package/src/tests/internal-ai/models.test.ts +20 -0
  205. package/src/tests/memory-rate-tool.test.ts +7 -10
  206. package/src/tests/memory-rater-defaults.test.ts +23 -0
  207. package/src/tests/memory-rater-e2e.test.ts +2 -3
  208. package/src/tests/migration-046-budgets.test.ts +2 -0
  209. package/src/tests/model-control.test.ts +2 -2
  210. package/src/tests/onboard-compose.test.ts +14 -0
  211. package/src/tests/onboard-env.test.ts +17 -0
  212. package/src/tests/onboard-manifest.test.ts +12 -0
  213. package/src/tests/opus-5-5-registry.test.ts +48 -0
  214. package/src/tests/pricing-refresh.test.ts +1 -1
  215. package/src/tests/pricing-routes.test.ts +15 -3
  216. package/src/tests/provider-registration.test.ts +5 -2
  217. package/src/tests/rbac-admission-e2e.test.ts +54 -0
  218. package/src/tests/rbac-e2e-helpers.ts +2 -0
  219. package/src/tests/rbac-engine.test.ts +32 -0
  220. package/src/tests/rbac-wire-e2e.test.ts +33 -0
  221. package/src/tests/reasoning-effort.test.ts +8 -0
  222. package/src/tests/reload-config.test.ts +33 -0
  223. package/src/tests/script-connections.test.ts +3 -0
  224. package/src/tests/session-costs-model-key-normalize.test.ts +1 -0
  225. package/src/tests/slack-config.test.ts +136 -0
  226. package/src/tests/slack-mode-lifecycle.test.ts +69 -0
  227. package/src/tests/slack-render-v2.test.ts +446 -16
  228. package/src/tests/slack-steering.test.ts +69 -1
  229. package/src/tests/slack-task-output.test.ts +33 -12
  230. package/src/tests/status.test.ts +22 -2
  231. package/src/tests/steering-core.test.ts +35 -0
  232. package/src/tests/steering-delivery.test.ts +39 -0
  233. package/src/tests/steering-transport.test.ts +2 -2
  234. package/src/tests/task-tool-preload-mcp.test.ts +3 -1
  235. package/src/tests/telemetry-init.test.ts +18 -0
  236. package/src/tests/workflow-live-recovery.test.ts +126 -0
  237. package/src/tests/workflow-llm.test.ts +3 -3
  238. package/src/tools/defer-task.ts +64 -26
  239. package/src/tools/extension-common.ts +4 -0
  240. package/src/tools/extension-install.ts +1 -1
  241. package/src/tools/extension-list.ts +4 -3
  242. package/src/tools/join-swarm.ts +1 -1
  243. package/src/tools/schedules/create-schedule.ts +11 -1
  244. package/src/tools/schedules/patch-schedule.ts +5 -0
  245. package/src/tools/schedules/update-schedule.ts +5 -0
  246. package/src/tools/send-task.ts +6 -0
  247. package/src/tools/utils.ts +1 -1
  248. package/src/types.ts +30 -8
  249. package/src/utils/context-window.ts +1 -0
  250. package/src/utils/credentials.ts +8 -0
  251. package/src/utils/internal-ai/complete-structured.ts +8 -0
  252. package/src/utils/internal-ai/models.ts +5 -5
  253. package/src/utils/memory-raters.ts +3 -0
  254. package/src/workflows/engine.ts +28 -0
  255. package/src/workflows/recovery.ts +7 -4
  256. package/templates/schedules/daily-status-report/content.md +25 -12
  257. package/templates/schedules/daily-workflow-health-audit/content.md +1 -1
  258. package/templates/skills/swarm-extensions/content.md +9 -5
  259. package/dist/cli-4wppfkcm.js +0 -16384
  260. package/dist/cli-55qrx3q8.js +0 -6041
  261. package/dist/cli-cg4vnyh4.js +0 -305
  262. package/dist/cli-jyetr64j.js +0 -52
  263. package/dist/cli-pp9ax9pa.js +0 -520
  264. package/dist/cli-qa66qaf0.js +0 -6076
  265. package/dist/cli-qghpvca2.js +0 -590
  266. package/dist/cli-rembwgt8.js +0 -861
  267. package/dist/cli-tcvj7j2r.js +0 -1971
  268. package/dist/cli-vfcth11k.js +0 -36
  269. package/dist/cli-w1d1bgkk.js +0 -1422
  270. package/dist/cli-y6x0gqtg.js +0 -5977
  271. package/dist/es5-tj3tn4jj.js +0 -844
  272. package/dist/index-1kq5hw2p.js +0 -467
  273. package/dist/index-1p8wdstt.js +0 -7
  274. package/dist/index-8fdjzb2f.js +0 -100
  275. package/dist/index-bxmwzbgw.js +0 -365
  276. package/dist/index-nzerxd5z.js +0 -7
  277. package/dist/index-pyymnzat.js +0 -1168
  278. package/dist/index-qv6atbab.js +0 -619
  279. package/dist/index-rja32qa7.js +0 -801
  280. package/dist/index-tzg5srfp.js +0 -211
  281. package/dist/index-vhncw983.js +0 -90
  282. package/dist/index-xk036zsk.js +0 -859
  283. package/dist/index-zyazbzcb.js +0 -6
  284. package/dist/{claude-managed-setup-48dwg9bv.js → claude-managed-setup-f5pmsyrp.js} +3 -3
@@ -0,0 +1,4069 @@
1
+ import {
2
+ require_checksum,
3
+ require_client,
4
+ require_client1 as require_client2,
5
+ require_config,
6
+ require_dist_cjs,
7
+ require_dist_cjs1 as require_dist_cjs2,
8
+ require_dist_cjs2 as require_dist_cjs3,
9
+ require_endpoints,
10
+ require_httpAuthSchemes,
11
+ require_protocols,
12
+ require_protocols1 as require_protocols2,
13
+ require_retry,
14
+ require_schema,
15
+ require_serde,
16
+ require_sso_oidc
17
+ } from "./cli-cgj4hc12.js";
18
+ import {
19
+ __commonJS,
20
+ __require
21
+ } from "./cli-bc05qbss.js";
22
+
23
+ // node_modules/@aws-sdk/credential-provider-env/dist-cjs/index.js
24
+ var require_dist_cjs4 = __commonJS(function(exports) {
25
+ var { setCredentialFeature } = require_client2();
26
+ var { CredentialsProviderError } = require_config();
27
+ var ENV_KEY = "AWS_ACCESS_KEY_ID";
28
+ var ENV_SECRET = "AWS_SECRET_ACCESS_KEY";
29
+ var ENV_SESSION = "AWS_SESSION_TOKEN";
30
+ var ENV_EXPIRATION = "AWS_CREDENTIAL_EXPIRATION";
31
+ var ENV_CREDENTIAL_SCOPE = "AWS_CREDENTIAL_SCOPE";
32
+ var ENV_ACCOUNT_ID = "AWS_ACCOUNT_ID";
33
+ var fromEnv = (init) => async () => {
34
+ init?.logger?.debug("@aws-sdk/credential-provider-env - fromEnv");
35
+ const accessKeyId = process.env[ENV_KEY];
36
+ const secretAccessKey = process.env[ENV_SECRET];
37
+ const sessionToken = process.env[ENV_SESSION];
38
+ const expiry = process.env[ENV_EXPIRATION];
39
+ const credentialScope = process.env[ENV_CREDENTIAL_SCOPE];
40
+ const accountId = process.env[ENV_ACCOUNT_ID];
41
+ if (accessKeyId && secretAccessKey) {
42
+ const credentials = {
43
+ accessKeyId,
44
+ secretAccessKey,
45
+ ...sessionToken && { sessionToken },
46
+ ...expiry && { expiration: new Date(expiry) },
47
+ ...credentialScope && { credentialScope },
48
+ ...accountId && { accountId }
49
+ };
50
+ setCredentialFeature(credentials, "CREDENTIALS_ENV_VARS", "g");
51
+ return credentials;
52
+ }
53
+ throw new CredentialsProviderError("Unable to find environment variable credentials.", { logger: init?.logger });
54
+ };
55
+ exports.ENV_ACCOUNT_ID = ENV_ACCOUNT_ID;
56
+ exports.ENV_CREDENTIAL_SCOPE = ENV_CREDENTIAL_SCOPE;
57
+ exports.ENV_EXPIRATION = ENV_EXPIRATION;
58
+ exports.ENV_KEY = ENV_KEY;
59
+ exports.ENV_SECRET = ENV_SECRET;
60
+ exports.ENV_SESSION = ENV_SESSION;
61
+ exports.fromEnv = fromEnv;
62
+ });
63
+
64
+ // node_modules/@smithy/credential-provider-imds/dist-cjs/index.js
65
+ var require_dist_cjs5 = __commonJS(function(exports) {
66
+ var { ProviderError, CredentialsProviderError, loadConfig } = require_config();
67
+ var node_http = __require("node:http");
68
+ var { parseUrl } = require_protocols();
69
+ var isImdsCredentials = (arg) => Boolean(arg) && typeof arg === "object" && typeof arg.AccessKeyId === "string" && typeof arg.SecretAccessKey === "string" && typeof arg.Token === "string" && typeof arg.Expiration === "string";
70
+ var fromImdsCredentials = (creds) => ({
71
+ accessKeyId: creds.AccessKeyId,
72
+ secretAccessKey: creds.SecretAccessKey,
73
+ sessionToken: creds.Token,
74
+ expiration: new Date(creds.Expiration),
75
+ ...creds.AccountId && { accountId: creds.AccountId }
76
+ });
77
+ var DEFAULT_TIMEOUT = 1000;
78
+ var DEFAULT_MAX_RETRIES = 0;
79
+ var providerConfigFromInit = ({ maxRetries = DEFAULT_MAX_RETRIES, timeout = DEFAULT_TIMEOUT }) => ({ maxRetries, timeout });
80
+ function httpRequest(options) {
81
+ return new Promise((resolve, reject) => {
82
+ const req = node_http.request({
83
+ method: "GET",
84
+ ...options,
85
+ hostname: options.hostname?.replace(/^\[(.+)\]$/, "$1")
86
+ });
87
+ req.on("error", (err) => {
88
+ reject(Object.assign(new ProviderError("Unable to connect to instance metadata service"), err));
89
+ req.destroy();
90
+ });
91
+ req.on("timeout", () => {
92
+ reject(new ProviderError("TimeoutError from instance metadata service"));
93
+ req.destroy();
94
+ });
95
+ req.on("response", (res) => {
96
+ const { statusCode = 400 } = res;
97
+ if (statusCode < 200 || 300 <= statusCode) {
98
+ reject(Object.assign(new ProviderError("Error response received from instance metadata service"), { statusCode }));
99
+ req.destroy();
100
+ }
101
+ const chunks = [];
102
+ res.on("data", (chunk) => {
103
+ chunks.push(chunk);
104
+ });
105
+ res.on("end", () => {
106
+ resolve(Buffer.concat(chunks));
107
+ req.destroy();
108
+ });
109
+ });
110
+ req.end();
111
+ });
112
+ }
113
+ var retry = (toRetry, maxRetries) => {
114
+ let promise = toRetry();
115
+ for (let i = 0;i < maxRetries; i++) {
116
+ promise = promise.catch(toRetry);
117
+ }
118
+ return promise;
119
+ };
120
+ var ENV_CMDS_FULL_URI = "AWS_CONTAINER_CREDENTIALS_FULL_URI";
121
+ var ENV_CMDS_RELATIVE_URI = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI";
122
+ var ENV_CMDS_AUTH_TOKEN = "AWS_CONTAINER_AUTHORIZATION_TOKEN";
123
+ var fromContainerMetadata = (init = {}) => {
124
+ const { timeout, maxRetries } = providerConfigFromInit(init);
125
+ return () => retry(async () => {
126
+ const requestOptions = await getCmdsUri({ logger: init.logger });
127
+ const credsResponse = JSON.parse(await requestFromEcsImds(timeout, requestOptions));
128
+ if (!isImdsCredentials(credsResponse)) {
129
+ throw new CredentialsProviderError("Invalid response received from instance metadata service.", {
130
+ logger: init.logger
131
+ });
132
+ }
133
+ return fromImdsCredentials(credsResponse);
134
+ }, maxRetries);
135
+ };
136
+ var requestFromEcsImds = async (timeout, options) => {
137
+ if (process.env[ENV_CMDS_AUTH_TOKEN]) {
138
+ options.headers = {
139
+ ...options.headers,
140
+ Authorization: process.env[ENV_CMDS_AUTH_TOKEN]
141
+ };
142
+ }
143
+ const buffer = await httpRequest({
144
+ ...options,
145
+ timeout
146
+ });
147
+ return buffer.toString();
148
+ };
149
+ var CMDS_IP = "169.254.170.2";
150
+ var GREENGRASS_HOSTS = new Set(["localhost", "127.0.0.1"]);
151
+ var GREENGRASS_PROTOCOLS = new Set(["http:", "https:"]);
152
+ var getCmdsUri = async ({ logger }) => {
153
+ if (process.env[ENV_CMDS_RELATIVE_URI]) {
154
+ return {
155
+ hostname: CMDS_IP,
156
+ path: process.env[ENV_CMDS_RELATIVE_URI]
157
+ };
158
+ }
159
+ if (process.env[ENV_CMDS_FULL_URI]) {
160
+ let parsed;
161
+ try {
162
+ parsed = new URL(process.env[ENV_CMDS_FULL_URI]);
163
+ } catch {
164
+ throw new CredentialsProviderError(`${process.env[ENV_CMDS_FULL_URI]} is not a valid container metadata service URL`, { tryNextLink: false, logger });
165
+ }
166
+ if (!parsed.hostname || !GREENGRASS_HOSTS.has(parsed.hostname)) {
167
+ throw new CredentialsProviderError(`${parsed.hostname} is not a valid container metadata service hostname`, {
168
+ tryNextLink: false,
169
+ logger
170
+ });
171
+ }
172
+ if (!parsed.protocol || !GREENGRASS_PROTOCOLS.has(parsed.protocol)) {
173
+ throw new CredentialsProviderError(`${parsed.protocol} is not a valid container metadata service protocol`, {
174
+ tryNextLink: false,
175
+ logger
176
+ });
177
+ }
178
+ return {
179
+ protocol: parsed.protocol,
180
+ hostname: parsed.hostname,
181
+ path: parsed.pathname + parsed.search,
182
+ port: parsed.port ? parseInt(parsed.port, 10) : undefined
183
+ };
184
+ }
185
+ throw new CredentialsProviderError("The container metadata credential provider cannot be used unless" + ` the ${ENV_CMDS_RELATIVE_URI} or ${ENV_CMDS_FULL_URI} environment` + " variable is set", {
186
+ tryNextLink: false,
187
+ logger
188
+ });
189
+ };
190
+
191
+ class InstanceMetadataV1FallbackError extends CredentialsProviderError {
192
+ tryNextLink;
193
+ name = "InstanceMetadataV1FallbackError";
194
+ constructor(message, tryNextLink = true) {
195
+ super(message, tryNextLink);
196
+ this.tryNextLink = tryNextLink;
197
+ Object.setPrototypeOf(this, InstanceMetadataV1FallbackError.prototype);
198
+ }
199
+ }
200
+ var Endpoint;
201
+ (function(Endpoint2) {
202
+ Endpoint2["IPv4"] = "http://169.254.169.254";
203
+ Endpoint2["IPv6"] = "http://[fd00:ec2::254]";
204
+ })(Endpoint || (Endpoint = {}));
205
+ var ENV_ENDPOINT_NAME = "AWS_EC2_METADATA_SERVICE_ENDPOINT";
206
+ var CONFIG_ENDPOINT_NAME = "ec2_metadata_service_endpoint";
207
+ var ENDPOINT_CONFIG_OPTIONS = {
208
+ environmentVariableSelector: (env) => env[ENV_ENDPOINT_NAME],
209
+ configFileSelector: (profile) => profile[CONFIG_ENDPOINT_NAME],
210
+ default: undefined
211
+ };
212
+ var EndpointMode;
213
+ (function(EndpointMode2) {
214
+ EndpointMode2["IPv4"] = "IPv4";
215
+ EndpointMode2["IPv6"] = "IPv6";
216
+ })(EndpointMode || (EndpointMode = {}));
217
+ var ENV_ENDPOINT_MODE_NAME = "AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE";
218
+ var CONFIG_ENDPOINT_MODE_NAME = "ec2_metadata_service_endpoint_mode";
219
+ var ENDPOINT_MODE_CONFIG_OPTIONS = {
220
+ environmentVariableSelector: (env) => env[ENV_ENDPOINT_MODE_NAME],
221
+ configFileSelector: (profile) => profile[CONFIG_ENDPOINT_MODE_NAME],
222
+ default: EndpointMode.IPv4
223
+ };
224
+ var getInstanceMetadataEndpoint = async () => parseUrl(await getFromEndpointConfig() || await getFromEndpointModeConfig());
225
+ var getFromEndpointConfig = async () => loadConfig(ENDPOINT_CONFIG_OPTIONS)();
226
+ var getFromEndpointModeConfig = async () => {
227
+ const endpointMode = await loadConfig(ENDPOINT_MODE_CONFIG_OPTIONS)();
228
+ switch (endpointMode) {
229
+ case EndpointMode.IPv4:
230
+ return Endpoint.IPv4;
231
+ case EndpointMode.IPv6:
232
+ return Endpoint.IPv6;
233
+ default:
234
+ throw new Error(`Unsupported endpoint mode: ${endpointMode}.` + ` Select from ${Object.values(EndpointMode)}`);
235
+ }
236
+ };
237
+ var STATIC_STABILITY_REFRESH_INTERVAL_SECONDS = 5 * 60;
238
+ var STATIC_STABILITY_REFRESH_INTERVAL_JITTER_WINDOW_SECONDS = 5 * 60;
239
+ var STATIC_STABILITY_DOC_URL = "https://docs.aws.amazon.com/sdkref/latest/guide/feature-static-credentials.html";
240
+ var getExtendedInstanceMetadataCredentials = (credentials, logger) => {
241
+ const refreshInterval = STATIC_STABILITY_REFRESH_INTERVAL_SECONDS + Math.floor(Math.random() * STATIC_STABILITY_REFRESH_INTERVAL_JITTER_WINDOW_SECONDS);
242
+ const newExpiration = new Date(Date.now() + refreshInterval * 1000);
243
+ 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)}.
244
+ For more information, please visit: ` + STATIC_STABILITY_DOC_URL);
245
+ const originalExpiration = credentials.originalExpiration ?? credentials.expiration;
246
+ return {
247
+ ...credentials,
248
+ ...originalExpiration ? { originalExpiration } : {},
249
+ expiration: newExpiration
250
+ };
251
+ };
252
+ var staticStabilityProvider = (provider, options = {}) => {
253
+ const logger = options?.logger || console;
254
+ let pastCredentials;
255
+ return async () => {
256
+ let credentials;
257
+ try {
258
+ credentials = await provider();
259
+ if (credentials.expiration && credentials.expiration.getTime() < Date.now()) {
260
+ credentials = getExtendedInstanceMetadataCredentials(credentials, logger);
261
+ }
262
+ } catch (e) {
263
+ if (pastCredentials) {
264
+ logger.warn("Credential renew failed: ", e);
265
+ credentials = getExtendedInstanceMetadataCredentials(pastCredentials, logger);
266
+ } else {
267
+ throw e;
268
+ }
269
+ }
270
+ pastCredentials = credentials;
271
+ return credentials;
272
+ };
273
+ };
274
+ var IMDS_PATH = "/latest/meta-data/iam/security-credentials/";
275
+ var IMDS_TOKEN_PATH = "/latest/api/token";
276
+ var AWS_EC2_METADATA_V1_DISABLED = "AWS_EC2_METADATA_V1_DISABLED";
277
+ var PROFILE_AWS_EC2_METADATA_V1_DISABLED = "ec2_metadata_v1_disabled";
278
+ var X_AWS_EC2_METADATA_TOKEN = "x-aws-ec2-metadata-token";
279
+ var fromInstanceMetadata = (init = {}) => staticStabilityProvider(getInstanceMetadataProvider(init), { logger: init.logger });
280
+ var getInstanceMetadataProvider = (init = {}) => {
281
+ let disableFetchToken = false;
282
+ const { logger, profile } = init;
283
+ const { timeout, maxRetries } = providerConfigFromInit(init);
284
+ const getCredentials = async (maxRetries2, options) => {
285
+ const isImdsV1Fallback = disableFetchToken || options.headers?.[X_AWS_EC2_METADATA_TOKEN] == null;
286
+ if (isImdsV1Fallback) {
287
+ let fallbackBlockedFromProfile = false;
288
+ let fallbackBlockedFromProcessEnv = false;
289
+ const configValue = await loadConfig({
290
+ environmentVariableSelector: (env) => {
291
+ const envValue = env[AWS_EC2_METADATA_V1_DISABLED];
292
+ fallbackBlockedFromProcessEnv = !!envValue && envValue !== "false";
293
+ if (envValue === undefined) {
294
+ throw new CredentialsProviderError(`${AWS_EC2_METADATA_V1_DISABLED} not set in env, checking config file next.`, { logger: init.logger });
295
+ }
296
+ return fallbackBlockedFromProcessEnv;
297
+ },
298
+ configFileSelector: (profile2) => {
299
+ const profileValue = profile2[PROFILE_AWS_EC2_METADATA_V1_DISABLED];
300
+ fallbackBlockedFromProfile = !!profileValue && profileValue !== "false";
301
+ return fallbackBlockedFromProfile;
302
+ },
303
+ default: false
304
+ }, {
305
+ profile
306
+ })();
307
+ if (init.ec2MetadataV1Disabled || configValue) {
308
+ const causes = [];
309
+ if (init.ec2MetadataV1Disabled)
310
+ causes.push("credential provider initialization (runtime option ec2MetadataV1Disabled)");
311
+ if (fallbackBlockedFromProfile)
312
+ causes.push(`config file profile (${PROFILE_AWS_EC2_METADATA_V1_DISABLED})`);
313
+ if (fallbackBlockedFromProcessEnv)
314
+ causes.push(`process environment variable (${AWS_EC2_METADATA_V1_DISABLED})`);
315
+ throw new InstanceMetadataV1FallbackError(`AWS EC2 Metadata v1 fallback has been blocked by AWS SDK configuration in the following: [${causes.join(", ")}].`);
316
+ }
317
+ }
318
+ const imdsProfile = (await retry(async () => {
319
+ let profile2;
320
+ try {
321
+ profile2 = await getProfile(options);
322
+ } catch (err) {
323
+ if (err.statusCode === 401) {
324
+ disableFetchToken = false;
325
+ }
326
+ throw err;
327
+ }
328
+ return profile2;
329
+ }, maxRetries2)).trim();
330
+ return retry(async () => {
331
+ let creds;
332
+ try {
333
+ creds = await getCredentialsFromProfile(imdsProfile, options, init);
334
+ } catch (err) {
335
+ if (err.statusCode === 401) {
336
+ disableFetchToken = false;
337
+ }
338
+ throw err;
339
+ }
340
+ return creds;
341
+ }, maxRetries2);
342
+ };
343
+ return async () => {
344
+ const endpoint = await getInstanceMetadataEndpoint();
345
+ if (disableFetchToken) {
346
+ logger?.debug("AWS SDK Instance Metadata", "using v1 fallback (no token fetch)");
347
+ return getCredentials(maxRetries, { ...endpoint, timeout });
348
+ } else {
349
+ let token;
350
+ try {
351
+ token = (await getMetadataToken({ ...endpoint, timeout })).toString();
352
+ } catch (error) {
353
+ if (error?.statusCode === 400) {
354
+ throw Object.assign(error, {
355
+ message: "EC2 Metadata token request returned error"
356
+ });
357
+ } else if (error.message === "TimeoutError" || [403, 404, 405].includes(error.statusCode)) {
358
+ disableFetchToken = true;
359
+ }
360
+ logger?.debug("AWS SDK Instance Metadata", "using v1 fallback (initial)");
361
+ return getCredentials(maxRetries, { ...endpoint, timeout });
362
+ }
363
+ return getCredentials(maxRetries, {
364
+ ...endpoint,
365
+ headers: {
366
+ [X_AWS_EC2_METADATA_TOKEN]: token
367
+ },
368
+ timeout
369
+ });
370
+ }
371
+ };
372
+ };
373
+ var getMetadataToken = async (options) => httpRequest({
374
+ ...options,
375
+ path: IMDS_TOKEN_PATH,
376
+ method: "PUT",
377
+ headers: {
378
+ "x-aws-ec2-metadata-token-ttl-seconds": "21600"
379
+ }
380
+ });
381
+ var getProfile = async (options) => (await httpRequest({ ...options, path: IMDS_PATH })).toString();
382
+ var getCredentialsFromProfile = async (profile, options, init) => {
383
+ const credentialsResponse = JSON.parse((await httpRequest({
384
+ ...options,
385
+ path: IMDS_PATH + profile
386
+ })).toString());
387
+ if (!isImdsCredentials(credentialsResponse)) {
388
+ throw new CredentialsProviderError("Invalid response received from instance metadata service.", {
389
+ logger: init.logger
390
+ });
391
+ }
392
+ return fromImdsCredentials(credentialsResponse);
393
+ };
394
+ exports.DEFAULT_MAX_RETRIES = DEFAULT_MAX_RETRIES;
395
+ exports.DEFAULT_TIMEOUT = DEFAULT_TIMEOUT;
396
+ exports.ENV_CMDS_AUTH_TOKEN = ENV_CMDS_AUTH_TOKEN;
397
+ exports.ENV_CMDS_FULL_URI = ENV_CMDS_FULL_URI;
398
+ exports.ENV_CMDS_RELATIVE_URI = ENV_CMDS_RELATIVE_URI;
399
+ exports.Endpoint = Endpoint;
400
+ exports.fromContainerMetadata = fromContainerMetadata;
401
+ exports.fromInstanceMetadata = fromInstanceMetadata;
402
+ exports.getInstanceMetadataEndpoint = getInstanceMetadataEndpoint;
403
+ exports.httpRequest = httpRequest;
404
+ exports.providerConfigFromInit = providerConfigFromInit;
405
+ });
406
+
407
+ // node_modules/@aws-sdk/credential-provider-http/dist-cjs/index.js
408
+ var require_dist_cjs6 = __commonJS(function(exports) {
409
+ var { setCredentialFeature } = require_client2();
410
+ var { CredentialsProviderError } = require_config();
411
+ var { NodeHttpHandler } = require_dist_cjs3();
412
+ var fs = __require("node:fs/promises");
413
+ var { HttpRequest } = require_protocols();
414
+ var { sdkStreamMixin, parseRfc3339DateTime } = require_serde();
415
+ var ECS_CONTAINER_HOST = "169.254.170.2";
416
+ var EKS_CONTAINER_HOST_IPv4 = "169.254.170.23";
417
+ var EKS_CONTAINER_HOST_IPv6 = "[fd00:ec2::23]";
418
+ var checkUrl = (url, logger) => {
419
+ if (url.protocol === "https:") {
420
+ return;
421
+ }
422
+ if (url.hostname === ECS_CONTAINER_HOST || url.hostname === EKS_CONTAINER_HOST_IPv4 || url.hostname === EKS_CONTAINER_HOST_IPv6) {
423
+ return;
424
+ }
425
+ if (url.hostname.includes("[")) {
426
+ if (url.hostname === "[::1]" || url.hostname === "[0000:0000:0000:0000:0000:0000:0000:0001]") {
427
+ return;
428
+ }
429
+ } else {
430
+ if (url.hostname === "localhost") {
431
+ return;
432
+ }
433
+ const ipComponents = url.hostname.split(".");
434
+ const inRange = (component) => {
435
+ const num = parseInt(component, 10);
436
+ return 0 <= num && num <= 255;
437
+ };
438
+ if (ipComponents[0] === "127" && inRange(ipComponents[1]) && inRange(ipComponents[2]) && inRange(ipComponents[3]) && ipComponents.length === 4) {
439
+ return;
440
+ }
441
+ }
442
+ throw new CredentialsProviderError(`URL not accepted. It must either be HTTPS or match one of the following:
443
+ - loopback CIDR 127.0.0.0/8 or [::1/128]
444
+ - ECS container host 169.254.170.2
445
+ - EKS container host 169.254.170.23 or [fd00:ec2::23]`, { logger });
446
+ };
447
+ function createGetRequest(url) {
448
+ return new HttpRequest({
449
+ protocol: url.protocol,
450
+ hostname: url.hostname,
451
+ port: Number(url.port),
452
+ path: url.pathname,
453
+ query: Array.from(url.searchParams.entries()).reduce((acc, [k, v]) => {
454
+ acc[k] = v;
455
+ return acc;
456
+ }, {}),
457
+ fragment: url.hash
458
+ });
459
+ }
460
+ async function getCredentials(response, logger) {
461
+ const stream = sdkStreamMixin(response.body);
462
+ const str = await stream.transformToString();
463
+ if (response.statusCode === 200) {
464
+ const parsed = JSON.parse(str);
465
+ if (typeof parsed.AccessKeyId !== "string" || typeof parsed.SecretAccessKey !== "string" || typeof parsed.Token !== "string" || typeof parsed.Expiration !== "string") {
466
+ 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 });
467
+ }
468
+ return {
469
+ accessKeyId: parsed.AccessKeyId,
470
+ secretAccessKey: parsed.SecretAccessKey,
471
+ sessionToken: parsed.Token,
472
+ expiration: parseRfc3339DateTime(parsed.Expiration)
473
+ };
474
+ }
475
+ if (response.statusCode >= 400 && response.statusCode < 500) {
476
+ let parsedBody = {};
477
+ try {
478
+ parsedBody = JSON.parse(str);
479
+ } catch (e) {}
480
+ throw Object.assign(new CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger }), {
481
+ Code: parsedBody.Code,
482
+ Message: parsedBody.Message
483
+ });
484
+ }
485
+ throw new CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger });
486
+ }
487
+ var retryWrapper = (toRetry, maxRetries, delayMs) => {
488
+ return async () => {
489
+ for (let i = 0;i < maxRetries; ++i) {
490
+ try {
491
+ return await toRetry();
492
+ } catch (e) {
493
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
494
+ }
495
+ }
496
+ return await toRetry();
497
+ };
498
+ };
499
+ var AWS_CONTAINER_CREDENTIALS_RELATIVE_URI = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI";
500
+ var DEFAULT_LINK_LOCAL_HOST = "http://169.254.170.2";
501
+ var AWS_CONTAINER_CREDENTIALS_FULL_URI = "AWS_CONTAINER_CREDENTIALS_FULL_URI";
502
+ var AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE = "AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE";
503
+ var AWS_CONTAINER_AUTHORIZATION_TOKEN = "AWS_CONTAINER_AUTHORIZATION_TOKEN";
504
+ var fromHttp = (options = {}) => {
505
+ options.logger?.debug("@aws-sdk/credential-provider-http - fromHttp");
506
+ let host;
507
+ const relative = options.awsContainerCredentialsRelativeUri ?? process.env[AWS_CONTAINER_CREDENTIALS_RELATIVE_URI];
508
+ const full = options.awsContainerCredentialsFullUri ?? process.env[AWS_CONTAINER_CREDENTIALS_FULL_URI];
509
+ const token = options.awsContainerAuthorizationToken ?? process.env[AWS_CONTAINER_AUTHORIZATION_TOKEN];
510
+ const tokenFile = options.awsContainerAuthorizationTokenFile ?? process.env[AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE];
511
+ const warn = options.logger?.constructor?.name === "NoOpLogger" || !options.logger?.warn ? console.warn : options.logger.warn.bind(options.logger);
512
+ if (relative && full) {
513
+ warn("@aws-sdk/credential-provider-http: " + "you have set both awsContainerCredentialsRelativeUri and awsContainerCredentialsFullUri.");
514
+ warn("awsContainerCredentialsRelativeUri will take precedence.");
515
+ }
516
+ if (token && tokenFile) {
517
+ warn("@aws-sdk/credential-provider-http: " + "you have set both awsContainerAuthorizationToken and awsContainerAuthorizationTokenFile.");
518
+ warn("awsContainerAuthorizationTokenFile will take precedence.");
519
+ }
520
+ if (relative) {
521
+ host = `${DEFAULT_LINK_LOCAL_HOST}${relative}`;
522
+ } else if (full) {
523
+ host = full;
524
+ } else {
525
+ throw new CredentialsProviderError(`No HTTP credential provider host provided.
526
+ Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI.`, { logger: options.logger });
527
+ }
528
+ const url = new URL(host);
529
+ checkUrl(url, options.logger);
530
+ const requestHandler = NodeHttpHandler.create({ connectionTimeout: options.timeout ?? 1000 });
531
+ const requestTimeout = options.timeout ?? 1000;
532
+ const provider = retryWrapper(async () => {
533
+ const request = createGetRequest(url);
534
+ if (tokenFile) {
535
+ request.headers.Authorization = validateToken((await fs.readFile(tokenFile)).toString());
536
+ } else if (token) {
537
+ request.headers.Authorization = validateToken(token);
538
+ }
539
+ try {
540
+ const result = await requestHandler.handle(request, { requestTimeout });
541
+ return getCredentials(result.response).then((creds) => setCredentialFeature(creds, "CREDENTIALS_HTTP", "z"));
542
+ } catch (e) {
543
+ throw new CredentialsProviderError(String(e), { logger: options.logger });
544
+ }
545
+ }, options.maxRetries ?? 3, options.timeout ?? 1000);
546
+ return async () => {
547
+ try {
548
+ return await provider();
549
+ } finally {
550
+ requestHandler.destroy?.();
551
+ }
552
+ };
553
+ };
554
+ var validateToken = (token) => {
555
+ if (token.includes(`\r
556
+ `)) {
557
+ throw new CredentialsProviderError("Authorization token contains invalid \\r\\n sequence.");
558
+ }
559
+ return token;
560
+ };
561
+ exports.fromHttp = fromHttp;
562
+ });
563
+
564
+ // node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-cjs/index.js
565
+ var require_dist_cjs7 = __commonJS(function(exports) {
566
+ var { setTokenFeature } = require_client2();
567
+ var { getBearerTokenEnvKey } = require_httpAuthSchemes();
568
+ var { TokenProviderError, getSSOTokenFilepath, parseKnownFiles, getProfileName, loadSsoSessionData, getSSOTokenFromFile, memoize, chain } = require_config();
569
+ var { promises } = __require("node:fs");
570
+ var fromEnvSigningName = ({ logger, signingName } = {}) => async () => {
571
+ logger?.debug?.("@aws-sdk/token-providers - fromEnvSigningName");
572
+ if (!signingName) {
573
+ throw new TokenProviderError("Please pass 'signingName' to compute environment variable key", { logger });
574
+ }
575
+ const bearerTokenKey = getBearerTokenEnvKey(signingName);
576
+ if (!(bearerTokenKey in process.env)) {
577
+ throw new TokenProviderError(`Token not present in '${bearerTokenKey}' environment variable`, { logger });
578
+ }
579
+ const token = { token: process.env[bearerTokenKey] };
580
+ setTokenFeature(token, "BEARER_SERVICE_ENV_VARS", "3");
581
+ return token;
582
+ };
583
+ var EXPIRE_WINDOW_MS = 5 * 60 * 1000;
584
+ var REFRESH_MESSAGE = `To refresh this SSO session run 'aws sso login' with the corresponding profile.`;
585
+ var getSsoOidcClient = async (ssoRegion, init = {}, callerClientConfig) => {
586
+ const { SSOOIDCClient } = require_sso_oidc();
587
+ const coalesce = (prop) => init.clientConfig?.[prop] ?? init.parentClientConfig?.[prop] ?? callerClientConfig?.[prop];
588
+ const ssoOidcClient = new SSOOIDCClient(Object.assign({}, init.clientConfig ?? {}, {
589
+ region: ssoRegion ?? init.clientConfig?.region,
590
+ logger: coalesce("logger"),
591
+ userAgentAppId: coalesce("userAgentAppId")
592
+ }));
593
+ return ssoOidcClient;
594
+ };
595
+ var getNewSsoOidcToken = async (ssoToken, ssoRegion, init = {}, callerClientConfig) => {
596
+ const { CreateTokenCommand } = require_sso_oidc();
597
+ const ssoOidcClient = await getSsoOidcClient(ssoRegion, init, callerClientConfig);
598
+ return ssoOidcClient.send(new CreateTokenCommand({
599
+ clientId: ssoToken.clientId,
600
+ clientSecret: ssoToken.clientSecret,
601
+ refreshToken: ssoToken.refreshToken,
602
+ grantType: "refresh_token"
603
+ }));
604
+ };
605
+ var validateTokenExpiry = (token) => {
606
+ if (token.expiration && token.expiration.getTime() < Date.now()) {
607
+ throw new TokenProviderError(`Token is expired. ${REFRESH_MESSAGE}`, false);
608
+ }
609
+ };
610
+ var validateTokenKey = (key, value, forRefresh = false) => {
611
+ if (typeof value === "undefined") {
612
+ throw new TokenProviderError(`Value not present for '${key}' in SSO Token${forRefresh ? ". Cannot refresh" : ""}. ${REFRESH_MESSAGE}`, false);
613
+ }
614
+ };
615
+ var { writeFile } = promises;
616
+ var writeSSOTokenToFile = (id, ssoToken) => {
617
+ const tokenFilepath = getSSOTokenFilepath(id);
618
+ const tokenString = JSON.stringify(ssoToken, null, 2);
619
+ return writeFile(tokenFilepath, tokenString);
620
+ };
621
+ var lastRefreshAttemptTimes = new Map;
622
+ var fromSso = (init = {}) => async ({ callerClientConfig } = {}) => {
623
+ init.logger?.debug("@aws-sdk/token-providers - fromSso");
624
+ const profiles = await parseKnownFiles(init);
625
+ const profileName = getProfileName({
626
+ profile: init.profile ?? callerClientConfig?.profile
627
+ });
628
+ const profile = profiles[profileName];
629
+ if (!profile) {
630
+ throw new TokenProviderError(`Profile '${profileName}' could not be found in shared credentials file.`, false);
631
+ } else if (!profile["sso_session"]) {
632
+ throw new TokenProviderError(`Profile '${profileName}' is missing required property 'sso_session'.`);
633
+ }
634
+ const ssoSessionName = profile["sso_session"];
635
+ const ssoSessions = await loadSsoSessionData(init);
636
+ const ssoSession = ssoSessions[ssoSessionName];
637
+ if (!ssoSession) {
638
+ throw new TokenProviderError(`Sso session '${ssoSessionName}' could not be found in shared credentials file.`, false);
639
+ }
640
+ for (const ssoSessionRequiredKey of ["sso_start_url", "sso_region"]) {
641
+ if (!ssoSession[ssoSessionRequiredKey]) {
642
+ throw new TokenProviderError(`Sso session '${ssoSessionName}' is missing required property '${ssoSessionRequiredKey}'.`, false);
643
+ }
644
+ }
645
+ ssoSession["sso_start_url"];
646
+ const ssoRegion = ssoSession["sso_region"];
647
+ let ssoToken;
648
+ try {
649
+ ssoToken = await getSSOTokenFromFile(ssoSessionName);
650
+ } catch (e) {
651
+ throw new TokenProviderError(`The SSO session token associated with profile=${profileName} was not found or is invalid. ${REFRESH_MESSAGE}`, false);
652
+ }
653
+ validateTokenKey("accessToken", ssoToken.accessToken);
654
+ validateTokenKey("expiresAt", ssoToken.expiresAt);
655
+ const { accessToken, expiresAt } = ssoToken;
656
+ const existingToken = {
657
+ token: accessToken,
658
+ expiration: new Date(expiresAt)
659
+ };
660
+ if (existingToken.expiration.getTime() - Date.now() > EXPIRE_WINDOW_MS) {
661
+ return existingToken;
662
+ }
663
+ const lastRefreshAttemptTime = lastRefreshAttemptTimes.get(ssoSessionName) ?? 0;
664
+ if (Date.now() - lastRefreshAttemptTime < 30 * 1000) {
665
+ validateTokenExpiry(existingToken);
666
+ return existingToken;
667
+ }
668
+ validateTokenKey("clientId", ssoToken.clientId, true);
669
+ validateTokenKey("clientSecret", ssoToken.clientSecret, true);
670
+ validateTokenKey("refreshToken", ssoToken.refreshToken, true);
671
+ try {
672
+ lastRefreshAttemptTimes.set(ssoSessionName, Date.now());
673
+ const newSsoOidcToken = await getNewSsoOidcToken(ssoToken, ssoRegion, init, callerClientConfig);
674
+ validateTokenKey("accessToken", newSsoOidcToken.accessToken);
675
+ validateTokenKey("expiresIn", newSsoOidcToken.expiresIn);
676
+ const newTokenExpiration = new Date(Date.now() + newSsoOidcToken.expiresIn * 1000);
677
+ try {
678
+ await writeSSOTokenToFile(ssoSessionName, {
679
+ ...ssoToken,
680
+ accessToken: newSsoOidcToken.accessToken,
681
+ expiresAt: newTokenExpiration.toISOString(),
682
+ refreshToken: newSsoOidcToken.refreshToken
683
+ });
684
+ } catch (error) {}
685
+ return {
686
+ token: newSsoOidcToken.accessToken,
687
+ expiration: newTokenExpiration
688
+ };
689
+ } catch (error) {
690
+ validateTokenExpiry(existingToken);
691
+ return existingToken;
692
+ }
693
+ };
694
+ var fromStatic = ({ token, logger }) => async () => {
695
+ logger?.debug("@aws-sdk/token-providers - fromStatic");
696
+ if (!token || !token.token) {
697
+ throw new TokenProviderError(`Please pass a valid token to fromStatic`, false);
698
+ }
699
+ return token;
700
+ };
701
+ var nodeProvider = (init = {}) => memoize(chain(fromSso(init), async () => {
702
+ throw new TokenProviderError("Could not load token from any providers", false);
703
+ }), (token) => token.expiration !== undefined && token.expiration.getTime() - Date.now() < 300000, (token) => token.expiration !== undefined);
704
+ exports.fromEnvSigningName = fromEnvSigningName;
705
+ exports.fromSso = fromSso;
706
+ exports.fromStatic = fromStatic;
707
+ exports.nodeProvider = nodeProvider;
708
+ });
709
+
710
+ // node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js
711
+ var require_sso = __commonJS(function(exports) {
712
+ var { awsEndpointFunctions, emitWarningIfUnsupportedVersion: emitWarningIfUnsupportedVersion$1, createDefaultUserAgentProvider, NODE_APP_ID_CONFIG_OPTIONS, getAwsRegionExtensionConfiguration, resolveAwsRegionExtensionConfiguration, resolveUserAgentConfig, resolveHostHeaderConfig, getUserAgentPlugin, getHostHeaderPlugin, getLoggerPlugin, getRecursionDetectionPlugin } = require_client2();
713
+ var { NoAuthSigner, getHttpAuthSchemeEndpointRuleSetPlugin, DefaultIdentityProviderConfig, getHttpSigningPlugin } = require_dist_cjs();
714
+ var { normalizeProvider, getSmithyContext, ServiceException, NoOpLogger, emitWarningIfUnsupportedVersion, loadConfigsForDefaultMode, getDefaultExtensionConfiguration, resolveDefaultRuntimeConfig, Client, makeBuilder, createAggregatedClient } = require_client();
715
+ var { Command: $Command } = require_client();
716
+ exports.$Command = $Command;
717
+ exports.__Client = Client;
718
+ var { resolveDefaultsModeConfig, loadConfig, NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS, NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS, NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS, resolveRegionConfig } = require_config();
719
+ var { BinaryDecisionDiagram, EndpointCache, decideEndpoint, customEndpointFunctions, resolveEndpointConfig, getEndpointPlugin } = require_endpoints();
720
+ var { parseUrl, getHttpHandlerExtensionConfiguration, resolveHttpHandlerRuntimeConfig, getContentLengthPlugin } = require_protocols();
721
+ var { DEFAULT_RETRY_MODE, NODE_RETRY_MODE_CONFIG_OPTIONS, NODE_MAX_ATTEMPT_CONFIG_OPTIONS, resolveRetryConfig, getRetryPlugin } = require_retry();
722
+ var { TypeRegistry, getSchemaSerdePlugin } = require_schema();
723
+ var { resolveAwsSdkSigV4Config, AwsSdkSigV4Signer, NODE_AUTH_SCHEME_PREFERENCE_OPTIONS } = require_httpAuthSchemes();
724
+ var { toUtf8, fromUtf8, toBase64, fromBase64, calculateBodyLength } = require_serde();
725
+ var { streamCollector, NodeHttpHandler } = require_dist_cjs3();
726
+ var { AwsRestJsonProtocol } = require_protocols2();
727
+ var { Sha256 } = require_checksum();
728
+ var defaultSSOHttpAuthSchemeParametersProvider = async (config, context, input) => {
729
+ return {
730
+ operation: getSmithyContext(context).operation,
731
+ region: await normalizeProvider(config.region)() || (() => {
732
+ throw new Error("expected `region` to be configured for `aws.auth#sigv4`");
733
+ })()
734
+ };
735
+ };
736
+ function createAwsAuthSigv4HttpAuthOption(authParameters) {
737
+ return {
738
+ schemeId: "aws.auth#sigv4",
739
+ signingProperties: {
740
+ name: "awsssoportal",
741
+ region: authParameters.region
742
+ },
743
+ propertiesExtractor: (config, context) => ({
744
+ signingProperties: {
745
+ config,
746
+ context
747
+ }
748
+ })
749
+ };
750
+ }
751
+ function createSmithyApiNoAuthHttpAuthOption(authParameters) {
752
+ return {
753
+ schemeId: "smithy.api#noAuth"
754
+ };
755
+ }
756
+ var defaultSSOHttpAuthSchemeProvider = (authParameters) => {
757
+ const options = [];
758
+ switch (authParameters.operation) {
759
+ case "GetRoleCredentials": {
760
+ options.push(createSmithyApiNoAuthHttpAuthOption());
761
+ break;
762
+ }
763
+ default: {
764
+ options.push(createAwsAuthSigv4HttpAuthOption(authParameters));
765
+ }
766
+ }
767
+ return options;
768
+ };
769
+ var resolveHttpAuthSchemeConfig = (config) => {
770
+ const config_0 = resolveAwsSdkSigV4Config(config);
771
+ return Object.assign(config_0, {
772
+ authSchemePreference: normalizeProvider(config.authSchemePreference ?? [])
773
+ });
774
+ };
775
+ var resolveClientEndpointParameters = (options) => {
776
+ return Object.assign(options, {
777
+ useDualstackEndpoint: options.useDualstackEndpoint ?? false,
778
+ useFipsEndpoint: options.useFipsEndpoint ?? false,
779
+ defaultSigningName: "awsssoportal"
780
+ });
781
+ };
782
+ var commonParams = {
783
+ UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" },
784
+ Endpoint: { type: "builtInParams", name: "endpoint" },
785
+ Region: { type: "builtInParams", name: "region" },
786
+ UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }
787
+ };
788
+ var version = "3.997.45";
789
+ var packageInfo = {
790
+ version
791
+ };
792
+ var k = "ref";
793
+ var a = -1;
794
+ var b = true;
795
+ var c = "isSet";
796
+ var d = "PartitionResult";
797
+ var e = "booleanEquals";
798
+ var f = "getAttr";
799
+ var g = { [k]: "Endpoint" };
800
+ var h = { [k]: d };
801
+ var i = {};
802
+ var j = [{ [k]: "Region" }];
803
+ var _data = {
804
+ conditions: [
805
+ [c, [g]],
806
+ [c, j],
807
+ ["aws.partition", j, d],
808
+ [e, [{ [k]: "UseFIPS" }, b]],
809
+ [e, [{ [k]: "UseDualStack" }, b]],
810
+ [e, [{ fn: f, argv: [h, "supportsDualStack"] }, b]],
811
+ [e, [{ fn: f, argv: [h, "supportsFIPS"] }, b]],
812
+ ["stringEquals", [{ fn: f, argv: [h, "name"] }, "aws-us-gov"]]
813
+ ],
814
+ results: [
815
+ [a],
816
+ [a, "Invalid Configuration: FIPS and custom endpoint are not supported"],
817
+ [a, "Invalid Configuration: Dualstack and custom endpoint are not supported"],
818
+ [g, i],
819
+ ["https://portal.sso-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", i],
820
+ [a, "FIPS and DualStack are enabled, but this partition does not support one or both"],
821
+ ["https://portal.sso.{Region}.amazonaws.com", i],
822
+ ["https://portal.sso-fips.{Region}.{PartitionResult#dnsSuffix}", i],
823
+ [a, "FIPS is enabled but this partition does not support FIPS"],
824
+ ["https://portal.sso.{Region}.{PartitionResult#dualStackDnsSuffix}", i],
825
+ [a, "DualStack is enabled but this partition does not support DualStack"],
826
+ ["https://portal.sso.{Region}.{PartitionResult#dnsSuffix}", i],
827
+ [a, "Invalid Configuration: Missing Region"]
828
+ ]
829
+ };
830
+ var root = 2;
831
+ var r = 1e8;
832
+ var nodes = new Int32Array([
833
+ -1,
834
+ 1,
835
+ -1,
836
+ 0,
837
+ 13,
838
+ 3,
839
+ 1,
840
+ 4,
841
+ r + 12,
842
+ 2,
843
+ 5,
844
+ r + 12,
845
+ 3,
846
+ 8,
847
+ 6,
848
+ 4,
849
+ 7,
850
+ r + 11,
851
+ 5,
852
+ r + 9,
853
+ r + 10,
854
+ 4,
855
+ 11,
856
+ 9,
857
+ 6,
858
+ 10,
859
+ r + 8,
860
+ 7,
861
+ r + 6,
862
+ r + 7,
863
+ 5,
864
+ 12,
865
+ r + 5,
866
+ 6,
867
+ r + 4,
868
+ r + 5,
869
+ 3,
870
+ r + 1,
871
+ 14,
872
+ 4,
873
+ r + 2,
874
+ r + 3
875
+ ]);
876
+ var bdd = BinaryDecisionDiagram.from(nodes, root, _data.conditions, _data.results);
877
+ var cache = new EndpointCache({
878
+ size: 50,
879
+ params: ["Endpoint", "Region", "UseDualStack", "UseFIPS"]
880
+ });
881
+ var defaultEndpointResolver = (endpointParams, context = {}) => {
882
+ return cache.get(endpointParams, () => decideEndpoint(bdd, {
883
+ endpointParams,
884
+ logger: context.logger
885
+ }));
886
+ };
887
+ customEndpointFunctions.aws = awsEndpointFunctions;
888
+
889
+ class SSOServiceException extends ServiceException {
890
+ constructor(options) {
891
+ super(options);
892
+ Object.setPrototypeOf(this, SSOServiceException.prototype);
893
+ }
894
+ }
895
+
896
+ class InvalidRequestException extends SSOServiceException {
897
+ name = "InvalidRequestException";
898
+ $fault = "client";
899
+ constructor(opts) {
900
+ super({
901
+ name: "InvalidRequestException",
902
+ $fault: "client",
903
+ ...opts
904
+ });
905
+ Object.setPrototypeOf(this, InvalidRequestException.prototype);
906
+ }
907
+ }
908
+
909
+ class ResourceNotFoundException extends SSOServiceException {
910
+ name = "ResourceNotFoundException";
911
+ $fault = "client";
912
+ constructor(opts) {
913
+ super({
914
+ name: "ResourceNotFoundException",
915
+ $fault: "client",
916
+ ...opts
917
+ });
918
+ Object.setPrototypeOf(this, ResourceNotFoundException.prototype);
919
+ }
920
+ }
921
+
922
+ class TooManyRequestsException extends SSOServiceException {
923
+ name = "TooManyRequestsException";
924
+ $fault = "client";
925
+ constructor(opts) {
926
+ super({
927
+ name: "TooManyRequestsException",
928
+ $fault: "client",
929
+ ...opts
930
+ });
931
+ Object.setPrototypeOf(this, TooManyRequestsException.prototype);
932
+ }
933
+ }
934
+
935
+ class UnauthorizedException extends SSOServiceException {
936
+ name = "UnauthorizedException";
937
+ $fault = "client";
938
+ constructor(opts) {
939
+ super({
940
+ name: "UnauthorizedException",
941
+ $fault: "client",
942
+ ...opts
943
+ });
944
+ Object.setPrototypeOf(this, UnauthorizedException.prototype);
945
+ }
946
+ }
947
+ var _ATT = "AccessTokenType";
948
+ var _GRC = "GetRoleCredentials";
949
+ var _GRCR = "GetRoleCredentialsRequest";
950
+ var _GRCRe = "GetRoleCredentialsResponse";
951
+ var _IRE = "InvalidRequestException";
952
+ var _RC = "RoleCredentials";
953
+ var _RNFE = "ResourceNotFoundException";
954
+ var _SAKT = "SecretAccessKeyType";
955
+ var _STT = "SessionTokenType";
956
+ var _TMRE = "TooManyRequestsException";
957
+ var _UE = "UnauthorizedException";
958
+ var _aI = "accountId";
959
+ var _aKI = "accessKeyId";
960
+ var _aT = "accessToken";
961
+ var _ai = "account_id";
962
+ var _c = "client";
963
+ var _e = "error";
964
+ var _ex = "expiration";
965
+ var _h = "http";
966
+ var _hE = "httpError";
967
+ var _hH = "httpHeader";
968
+ var _hQ = "httpQuery";
969
+ var _m = "message";
970
+ var _rC = "roleCredentials";
971
+ var _rN = "roleName";
972
+ var _rn = "role_name";
973
+ var _s = "smithy.ts.sdk.synthetic.com.amazonaws.sso";
974
+ var _sAK = "secretAccessKey";
975
+ var _sT = "sessionToken";
976
+ var _xasbt = "x-amz-sso_bearer_token";
977
+ var n0 = "com.amazonaws.sso";
978
+ var _s_registry = new TypeRegistry(_s);
979
+ var SSOServiceException$ = [-3, _s, "SSOServiceException", 0, [], []];
980
+ _s_registry.registerError(SSOServiceException$, SSOServiceException);
981
+ var n0_registry = new TypeRegistry(n0);
982
+ var InvalidRequestException$ = [
983
+ -3,
984
+ n0,
985
+ _IRE,
986
+ { [_e]: _c, [_hE]: 400 },
987
+ [_m],
988
+ [0]
989
+ ];
990
+ n0_registry.registerError(InvalidRequestException$, InvalidRequestException);
991
+ var ResourceNotFoundException$ = [
992
+ -3,
993
+ n0,
994
+ _RNFE,
995
+ { [_e]: _c, [_hE]: 404 },
996
+ [_m],
997
+ [0]
998
+ ];
999
+ n0_registry.registerError(ResourceNotFoundException$, ResourceNotFoundException);
1000
+ var TooManyRequestsException$ = [
1001
+ -3,
1002
+ n0,
1003
+ _TMRE,
1004
+ { [_e]: _c, [_hE]: 429 },
1005
+ [_m],
1006
+ [0]
1007
+ ];
1008
+ n0_registry.registerError(TooManyRequestsException$, TooManyRequestsException);
1009
+ var UnauthorizedException$ = [
1010
+ -3,
1011
+ n0,
1012
+ _UE,
1013
+ { [_e]: _c, [_hE]: 401 },
1014
+ [_m],
1015
+ [0]
1016
+ ];
1017
+ n0_registry.registerError(UnauthorizedException$, UnauthorizedException);
1018
+ var errorTypeRegistries = [
1019
+ _s_registry,
1020
+ n0_registry
1021
+ ];
1022
+ var AccessTokenType = [0, n0, _ATT, 8, 0];
1023
+ var SecretAccessKeyType = [0, n0, _SAKT, 8, 0];
1024
+ var SessionTokenType = [0, n0, _STT, 8, 0];
1025
+ var GetRoleCredentialsRequest$ = [
1026
+ 3,
1027
+ n0,
1028
+ _GRCR,
1029
+ 0,
1030
+ [_rN, _aI, _aT],
1031
+ [[0, { [_hQ]: _rn }], [0, { [_hQ]: _ai }], [() => AccessTokenType, { [_hH]: _xasbt }]],
1032
+ 3
1033
+ ];
1034
+ var GetRoleCredentialsResponse$ = [
1035
+ 3,
1036
+ n0,
1037
+ _GRCRe,
1038
+ 0,
1039
+ [_rC],
1040
+ [[() => RoleCredentials$, 0]]
1041
+ ];
1042
+ var RoleCredentials$ = [
1043
+ 3,
1044
+ n0,
1045
+ _RC,
1046
+ 0,
1047
+ [_aKI, _sAK, _sT, _ex],
1048
+ [0, [() => SecretAccessKeyType, 0], [() => SessionTokenType, 0], 1]
1049
+ ];
1050
+ var GetRoleCredentials$ = [
1051
+ 9,
1052
+ n0,
1053
+ _GRC,
1054
+ { [_h]: ["GET", "/federation/credentials", 200] },
1055
+ () => GetRoleCredentialsRequest$,
1056
+ () => GetRoleCredentialsResponse$
1057
+ ];
1058
+ var getRuntimeConfig$1 = (config) => {
1059
+ return {
1060
+ apiVersion: "2019-06-10",
1061
+ base64Decoder: config?.base64Decoder ?? fromBase64,
1062
+ base64Encoder: config?.base64Encoder ?? toBase64,
1063
+ disableHostPrefix: config?.disableHostPrefix ?? false,
1064
+ endpointProvider: config?.endpointProvider ?? defaultEndpointResolver,
1065
+ extensions: config?.extensions ?? [],
1066
+ httpAuthSchemeProvider: config?.httpAuthSchemeProvider ?? defaultSSOHttpAuthSchemeProvider,
1067
+ httpAuthSchemes: config?.httpAuthSchemes ?? [
1068
+ {
1069
+ schemeId: "aws.auth#sigv4",
1070
+ identityProvider: (ipc) => ipc.getIdentityProvider("aws.auth#sigv4"),
1071
+ signer: new AwsSdkSigV4Signer
1072
+ },
1073
+ {
1074
+ schemeId: "smithy.api#noAuth",
1075
+ identityProvider: (ipc) => ipc.getIdentityProvider("smithy.api#noAuth") || (async () => ({})),
1076
+ signer: new NoAuthSigner
1077
+ }
1078
+ ],
1079
+ logger: config?.logger ?? new NoOpLogger,
1080
+ protocol: config?.protocol ?? AwsRestJsonProtocol,
1081
+ protocolSettings: config?.protocolSettings ?? {
1082
+ defaultNamespace: "com.amazonaws.sso",
1083
+ errorTypeRegistries,
1084
+ version: "2019-06-10",
1085
+ serviceTarget: "SWBPortalService"
1086
+ },
1087
+ serviceId: config?.serviceId ?? "SSO",
1088
+ sha256: config?.sha256 ?? Sha256,
1089
+ urlParser: config?.urlParser ?? parseUrl,
1090
+ utf8Decoder: config?.utf8Decoder ?? fromUtf8,
1091
+ utf8Encoder: config?.utf8Encoder ?? toUtf8
1092
+ };
1093
+ };
1094
+ var getRuntimeConfig = (config) => {
1095
+ emitWarningIfUnsupportedVersion(process.version);
1096
+ const defaultsMode = resolveDefaultsModeConfig(config);
1097
+ const defaultConfigProvider = () => defaultsMode().then(loadConfigsForDefaultMode);
1098
+ const clientSharedValues = getRuntimeConfig$1(config);
1099
+ emitWarningIfUnsupportedVersion$1(process.version);
1100
+ const loaderConfig = {
1101
+ profile: config?.profile,
1102
+ logger: clientSharedValues.logger
1103
+ };
1104
+ return {
1105
+ ...clientSharedValues,
1106
+ ...config,
1107
+ runtime: "node",
1108
+ defaultsMode,
1109
+ authSchemePreference: config?.authSchemePreference ?? loadConfig(NODE_AUTH_SCHEME_PREFERENCE_OPTIONS, loaderConfig),
1110
+ bodyLengthChecker: config?.bodyLengthChecker ?? calculateBodyLength,
1111
+ defaultUserAgentProvider: config?.defaultUserAgentProvider ?? createDefaultUserAgentProvider({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }),
1112
+ maxAttempts: config?.maxAttempts ?? loadConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS, config),
1113
+ region: config?.region ?? loadConfig(NODE_REGION_CONFIG_OPTIONS, { ...NODE_REGION_CONFIG_FILE_OPTIONS, ...loaderConfig }),
1114
+ requestHandler: NodeHttpHandler.create(config?.requestHandler ?? defaultConfigProvider),
1115
+ retryMode: config?.retryMode ?? loadConfig({
1116
+ ...NODE_RETRY_MODE_CONFIG_OPTIONS,
1117
+ default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE
1118
+ }, config),
1119
+ streamCollector: config?.streamCollector ?? streamCollector,
1120
+ useDualstackEndpoint: config?.useDualstackEndpoint ?? loadConfig(NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS, loaderConfig),
1121
+ useFipsEndpoint: config?.useFipsEndpoint ?? loadConfig(NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS, loaderConfig),
1122
+ userAgentAppId: config?.userAgentAppId ?? loadConfig(NODE_APP_ID_CONFIG_OPTIONS, loaderConfig)
1123
+ };
1124
+ };
1125
+ var getHttpAuthExtensionConfiguration = (runtimeConfig) => {
1126
+ const _httpAuthSchemes = runtimeConfig.httpAuthSchemes;
1127
+ let _httpAuthSchemeProvider = runtimeConfig.httpAuthSchemeProvider;
1128
+ let _credentials = runtimeConfig.credentials;
1129
+ return {
1130
+ setHttpAuthScheme(httpAuthScheme) {
1131
+ const index = _httpAuthSchemes.findIndex((scheme) => scheme.schemeId === httpAuthScheme.schemeId);
1132
+ if (index === -1) {
1133
+ _httpAuthSchemes.push(httpAuthScheme);
1134
+ } else {
1135
+ _httpAuthSchemes.splice(index, 1, httpAuthScheme);
1136
+ }
1137
+ },
1138
+ httpAuthSchemes() {
1139
+ return _httpAuthSchemes;
1140
+ },
1141
+ setHttpAuthSchemeProvider(httpAuthSchemeProvider) {
1142
+ _httpAuthSchemeProvider = httpAuthSchemeProvider;
1143
+ },
1144
+ httpAuthSchemeProvider() {
1145
+ return _httpAuthSchemeProvider;
1146
+ },
1147
+ setCredentials(credentials) {
1148
+ _credentials = credentials;
1149
+ },
1150
+ credentials() {
1151
+ return _credentials;
1152
+ }
1153
+ };
1154
+ };
1155
+ var resolveHttpAuthRuntimeConfig = (config) => {
1156
+ return {
1157
+ httpAuthSchemes: config.httpAuthSchemes(),
1158
+ httpAuthSchemeProvider: config.httpAuthSchemeProvider(),
1159
+ credentials: config.credentials()
1160
+ };
1161
+ };
1162
+ var resolveRuntimeExtensions = (runtimeConfig, extensions) => {
1163
+ const extensionConfiguration = Object.assign(getAwsRegionExtensionConfiguration(runtimeConfig), getDefaultExtensionConfiguration(runtimeConfig), getHttpHandlerExtensionConfiguration(runtimeConfig), getHttpAuthExtensionConfiguration(runtimeConfig));
1164
+ extensions.forEach((extension) => extension.configure(extensionConfiguration));
1165
+ return Object.assign(runtimeConfig, resolveAwsRegionExtensionConfiguration(extensionConfiguration), resolveDefaultRuntimeConfig(extensionConfiguration), resolveHttpHandlerRuntimeConfig(extensionConfiguration), resolveHttpAuthRuntimeConfig(extensionConfiguration));
1166
+ };
1167
+
1168
+ class SSOClient extends Client {
1169
+ config;
1170
+ constructor(...[configuration]) {
1171
+ const _config_0 = getRuntimeConfig(configuration || {});
1172
+ super(_config_0);
1173
+ this.initConfig = _config_0;
1174
+ const _config_1 = resolveClientEndpointParameters(_config_0);
1175
+ const _config_2 = resolveUserAgentConfig(_config_1);
1176
+ const _config_3 = resolveRetryConfig(_config_2);
1177
+ const _config_4 = resolveRegionConfig(_config_3);
1178
+ const _config_5 = resolveHostHeaderConfig(_config_4);
1179
+ const _config_6 = resolveEndpointConfig(_config_5);
1180
+ const _config_7 = resolveHttpAuthSchemeConfig(_config_6);
1181
+ const _config_8 = resolveRuntimeExtensions(_config_7, configuration?.extensions || []);
1182
+ this.config = _config_8;
1183
+ this.middlewareStack.use(getSchemaSerdePlugin(this.config));
1184
+ this.middlewareStack.use(getUserAgentPlugin(this.config));
1185
+ this.middlewareStack.use(getRetryPlugin(this.config));
1186
+ this.middlewareStack.use(getContentLengthPlugin(this.config));
1187
+ this.middlewareStack.use(getHostHeaderPlugin(this.config));
1188
+ this.middlewareStack.use(getLoggerPlugin(this.config));
1189
+ this.middlewareStack.use(getRecursionDetectionPlugin(this.config));
1190
+ this.middlewareStack.use(getHttpAuthSchemeEndpointRuleSetPlugin(this.config, {
1191
+ httpAuthSchemeParametersProvider: defaultSSOHttpAuthSchemeParametersProvider,
1192
+ identityProviderConfigProvider: async (config) => new DefaultIdentityProviderConfig({
1193
+ "aws.auth#sigv4": config.credentials
1194
+ })
1195
+ }));
1196
+ this.middlewareStack.use(getHttpSigningPlugin(this.config));
1197
+ }
1198
+ destroy() {
1199
+ super.destroy();
1200
+ }
1201
+ }
1202
+ var command = makeBuilder(commonParams, "SWBPortalService", "SSOClient", getEndpointPlugin);
1203
+ var _ep0 = {};
1204
+ var _mw0 = (Command, cs, config, o) => [];
1205
+
1206
+ class GetRoleCredentialsCommand extends command(_ep0, _mw0, "GetRoleCredentials", GetRoleCredentials$) {
1207
+ }
1208
+ var commands = {
1209
+ GetRoleCredentialsCommand
1210
+ };
1211
+
1212
+ class SSO extends SSOClient {
1213
+ }
1214
+ createAggregatedClient(commands, SSO);
1215
+ exports.GetRoleCredentials$ = GetRoleCredentials$;
1216
+ exports.GetRoleCredentialsCommand = GetRoleCredentialsCommand;
1217
+ exports.GetRoleCredentialsRequest$ = GetRoleCredentialsRequest$;
1218
+ exports.GetRoleCredentialsResponse$ = GetRoleCredentialsResponse$;
1219
+ exports.InvalidRequestException = InvalidRequestException;
1220
+ exports.InvalidRequestException$ = InvalidRequestException$;
1221
+ exports.ResourceNotFoundException = ResourceNotFoundException;
1222
+ exports.ResourceNotFoundException$ = ResourceNotFoundException$;
1223
+ exports.RoleCredentials$ = RoleCredentials$;
1224
+ exports.SSO = SSO;
1225
+ exports.SSOClient = SSOClient;
1226
+ exports.SSOServiceException = SSOServiceException;
1227
+ exports.SSOServiceException$ = SSOServiceException$;
1228
+ exports.TooManyRequestsException = TooManyRequestsException;
1229
+ exports.TooManyRequestsException$ = TooManyRequestsException$;
1230
+ exports.UnauthorizedException = UnauthorizedException;
1231
+ exports.UnauthorizedException$ = UnauthorizedException$;
1232
+ exports.errorTypeRegistries = errorTypeRegistries;
1233
+ });
1234
+
1235
+ // node_modules/@aws-sdk/credential-provider-sso/dist-cjs/loadSso-BGYXHf8s.js
1236
+ var require_loadSso_BGYXHf8s = __commonJS(function(exports) {
1237
+ var { GetRoleCredentialsCommand, SSOClient } = require_sso();
1238
+ exports.GetRoleCredentialsCommand = GetRoleCredentialsCommand;
1239
+ exports.SSOClient = SSOClient;
1240
+ });
1241
+
1242
+ // node_modules/@aws-sdk/credential-provider-sso/dist-cjs/index.js
1243
+ var require_dist_cjs8 = __commonJS(function(exports) {
1244
+ var { CredentialsProviderError, getSSOTokenFromFile, getProfileName, parseKnownFiles, loadSsoSessionData } = require_config();
1245
+ var { setCredentialFeature } = require_client2();
1246
+ var { fromSso } = require_dist_cjs7();
1247
+ var isSsoProfile = (arg) => arg && (typeof arg.sso_start_url === "string" || typeof arg.sso_account_id === "string" || typeof arg.sso_session === "string" || typeof arg.sso_region === "string" || typeof arg.sso_role_name === "string");
1248
+ var SHOULD_FAIL_CREDENTIAL_CHAIN = false;
1249
+ var resolveSSOCredentials = async ({ ssoStartUrl, ssoSession, ssoAccountId, ssoRegion, ssoRoleName, ssoClient, clientConfig, parentClientConfig, callerClientConfig, profile, filepath, configFilepath, ignoreCache, logger }) => {
1250
+ let token;
1251
+ const refreshMessage = `To refresh this SSO session run aws sso login with the corresponding profile.`;
1252
+ if (ssoSession) {
1253
+ try {
1254
+ const _token = await fromSso({
1255
+ profile,
1256
+ filepath,
1257
+ configFilepath,
1258
+ ignoreCache,
1259
+ clientConfig,
1260
+ parentClientConfig,
1261
+ logger
1262
+ })({ callerClientConfig });
1263
+ token = {
1264
+ accessToken: _token.token,
1265
+ expiresAt: new Date(_token.expiration).toISOString()
1266
+ };
1267
+ } catch (e) {
1268
+ throw new CredentialsProviderError(e.message, {
1269
+ tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
1270
+ logger
1271
+ });
1272
+ }
1273
+ } else {
1274
+ try {
1275
+ token = await getSSOTokenFromFile(ssoStartUrl);
1276
+ } catch (e) {
1277
+ throw new CredentialsProviderError(`The SSO session associated with this profile is invalid. ${refreshMessage}`, {
1278
+ tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
1279
+ logger
1280
+ });
1281
+ }
1282
+ }
1283
+ if (new Date(token.expiresAt).getTime() - Date.now() <= 0) {
1284
+ throw new CredentialsProviderError(`The SSO session associated with this profile has expired. ${refreshMessage}`, {
1285
+ tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
1286
+ logger
1287
+ });
1288
+ }
1289
+ const { accessToken } = token;
1290
+ const { SSOClient, GetRoleCredentialsCommand } = require_loadSso_BGYXHf8s();
1291
+ const sso = ssoClient || new SSOClient(Object.assign({}, clientConfig ?? {}, {
1292
+ logger: clientConfig?.logger ?? callerClientConfig?.logger ?? parentClientConfig?.logger,
1293
+ region: clientConfig?.region ?? ssoRegion,
1294
+ userAgentAppId: clientConfig?.userAgentAppId ?? callerClientConfig?.userAgentAppId ?? parentClientConfig?.userAgentAppId
1295
+ }));
1296
+ let ssoResp;
1297
+ try {
1298
+ ssoResp = await sso.send(new GetRoleCredentialsCommand({
1299
+ accountId: ssoAccountId,
1300
+ roleName: ssoRoleName,
1301
+ accessToken
1302
+ }));
1303
+ } catch (e) {
1304
+ throw new CredentialsProviderError(e, {
1305
+ tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
1306
+ logger
1307
+ });
1308
+ }
1309
+ const { roleCredentials: { accessKeyId, secretAccessKey, sessionToken, expiration, credentialScope, accountId } = {} } = ssoResp;
1310
+ if (!accessKeyId || !secretAccessKey || !sessionToken || !expiration) {
1311
+ throw new CredentialsProviderError("SSO returns an invalid temporary credential.", {
1312
+ tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
1313
+ logger
1314
+ });
1315
+ }
1316
+ const credentials = {
1317
+ accessKeyId,
1318
+ secretAccessKey,
1319
+ sessionToken,
1320
+ expiration: new Date(expiration),
1321
+ ...credentialScope && { credentialScope },
1322
+ ...accountId && { accountId }
1323
+ };
1324
+ if (ssoSession) {
1325
+ setCredentialFeature(credentials, "CREDENTIALS_SSO", "s");
1326
+ } else {
1327
+ setCredentialFeature(credentials, "CREDENTIALS_SSO_LEGACY", "u");
1328
+ }
1329
+ return credentials;
1330
+ };
1331
+ var validateSsoProfile = (profile, logger) => {
1332
+ const { sso_start_url, sso_account_id, sso_region, sso_role_name } = profile;
1333
+ if (!sso_start_url || !sso_account_id || !sso_region || !sso_role_name) {
1334
+ throw new CredentialsProviderError(`Profile is configured with invalid SSO credentials. Required parameters "sso_account_id", ` + `"sso_region", "sso_role_name", "sso_start_url". Got ${Object.keys(profile).join(", ")}
1335
+ Reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html`, { tryNextLink: false, logger });
1336
+ }
1337
+ return profile;
1338
+ };
1339
+ var fromSSO = (init = {}) => async ({ callerClientConfig } = {}) => {
1340
+ init.logger?.debug("@aws-sdk/credential-provider-sso - fromSSO");
1341
+ const { ssoStartUrl, ssoAccountId, ssoRegion, ssoRoleName, ssoSession } = init;
1342
+ const { ssoClient } = init;
1343
+ const profileName = getProfileName({
1344
+ profile: init.profile ?? callerClientConfig?.profile
1345
+ });
1346
+ if (!ssoStartUrl && !ssoAccountId && !ssoRegion && !ssoRoleName && !ssoSession) {
1347
+ const profiles = await parseKnownFiles(init);
1348
+ const profile = profiles[profileName];
1349
+ if (!profile) {
1350
+ throw new CredentialsProviderError(`Profile ${profileName} was not found.`, { logger: init.logger });
1351
+ }
1352
+ if (!isSsoProfile(profile)) {
1353
+ throw new CredentialsProviderError(`Profile ${profileName} is not configured with SSO credentials.`, {
1354
+ logger: init.logger
1355
+ });
1356
+ }
1357
+ if (profile?.sso_session) {
1358
+ const ssoSessions = await loadSsoSessionData(init);
1359
+ const session = ssoSessions[profile.sso_session];
1360
+ const conflictMsg = ` configurations in profile ${profileName} and sso-session ${profile.sso_session}`;
1361
+ if (ssoRegion && ssoRegion !== session.sso_region) {
1362
+ throw new CredentialsProviderError(`Conflicting SSO region` + conflictMsg, {
1363
+ tryNextLink: false,
1364
+ logger: init.logger
1365
+ });
1366
+ }
1367
+ if (ssoStartUrl && ssoStartUrl !== session.sso_start_url) {
1368
+ throw new CredentialsProviderError(`Conflicting SSO start_url` + conflictMsg, {
1369
+ tryNextLink: false,
1370
+ logger: init.logger
1371
+ });
1372
+ }
1373
+ profile.sso_region = session.sso_region;
1374
+ profile.sso_start_url = session.sso_start_url;
1375
+ }
1376
+ const { sso_start_url, sso_account_id, sso_region, sso_role_name, sso_session } = validateSsoProfile(profile, init.logger);
1377
+ return resolveSSOCredentials({
1378
+ ssoStartUrl: sso_start_url,
1379
+ ssoSession: sso_session,
1380
+ ssoAccountId: sso_account_id,
1381
+ ssoRegion: sso_region,
1382
+ ssoRoleName: sso_role_name,
1383
+ ssoClient,
1384
+ clientConfig: init.clientConfig,
1385
+ parentClientConfig: init.parentClientConfig,
1386
+ callerClientConfig: init.callerClientConfig,
1387
+ profile: profileName,
1388
+ filepath: init.filepath,
1389
+ configFilepath: init.configFilepath,
1390
+ ignoreCache: init.ignoreCache,
1391
+ logger: init.logger
1392
+ });
1393
+ } else if (!ssoStartUrl || !ssoAccountId || !ssoRegion || !ssoRoleName) {
1394
+ throw new CredentialsProviderError("Incomplete configuration. The fromSSO() argument hash must include " + '"ssoStartUrl", "ssoAccountId", "ssoRegion", "ssoRoleName"', { tryNextLink: false, logger: init.logger });
1395
+ } else {
1396
+ return resolveSSOCredentials({
1397
+ ssoStartUrl,
1398
+ ssoSession,
1399
+ ssoAccountId,
1400
+ ssoRegion,
1401
+ ssoRoleName,
1402
+ ssoClient,
1403
+ clientConfig: init.clientConfig,
1404
+ parentClientConfig: init.parentClientConfig,
1405
+ callerClientConfig: init.callerClientConfig,
1406
+ profile: profileName,
1407
+ filepath: init.filepath,
1408
+ configFilepath: init.configFilepath,
1409
+ ignoreCache: init.ignoreCache,
1410
+ logger: init.logger
1411
+ });
1412
+ }
1413
+ };
1414
+ exports.fromSSO = fromSSO;
1415
+ exports.isSsoProfile = isSsoProfile;
1416
+ exports.validateSsoProfile = validateSsoProfile;
1417
+ });
1418
+
1419
+ // node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/index.js
1420
+ var require_dist_cjs9 = __commonJS(function(exports) {
1421
+ var { SignatureV4, signatureV4aContainer } = require_dist_cjs2();
1422
+ var signatureV4CrtContainer = {
1423
+ CrtSignerV4: null
1424
+ };
1425
+ var SESSION_TOKEN_QUERY_PARAM = "X-Amz-S3session-Token";
1426
+ var SESSION_TOKEN_HEADER = SESSION_TOKEN_QUERY_PARAM.toLowerCase();
1427
+
1428
+ class SignatureV4SignWithCredentials extends SignatureV4 {
1429
+ async signWithCredentials(requestToSign, credentials, options) {
1430
+ const credentialsWithoutSessionToken = getCredentialsWithoutSessionToken(credentials);
1431
+ requestToSign.headers[SESSION_TOKEN_HEADER] = credentials.sessionToken;
1432
+ const privateAccess = this;
1433
+ setSingleOverride(privateAccess, credentialsWithoutSessionToken);
1434
+ return privateAccess.signRequest(requestToSign, options ?? {});
1435
+ }
1436
+ async presignWithCredentials(requestToSign, credentials, options) {
1437
+ const credentialsWithoutSessionToken = getCredentialsWithoutSessionToken(credentials);
1438
+ delete requestToSign.headers[SESSION_TOKEN_HEADER];
1439
+ requestToSign.headers[SESSION_TOKEN_QUERY_PARAM] = credentials.sessionToken;
1440
+ requestToSign.query = requestToSign.query ?? {};
1441
+ requestToSign.query[SESSION_TOKEN_QUERY_PARAM] = credentials.sessionToken;
1442
+ const privateAccess = this;
1443
+ setSingleOverride(privateAccess, credentialsWithoutSessionToken);
1444
+ return this.presign(requestToSign, options);
1445
+ }
1446
+ }
1447
+ function getCredentialsWithoutSessionToken(credentials) {
1448
+ return {
1449
+ accessKeyId: credentials.accessKeyId,
1450
+ secretAccessKey: credentials.secretAccessKey,
1451
+ expiration: credentials.expiration
1452
+ };
1453
+ }
1454
+ function setSingleOverride(privateAccess, credentialsWithoutSessionToken) {
1455
+ const currentCredentialProvider = privateAccess.credentialProvider;
1456
+ privateAccess.credentialProvider = () => {
1457
+ privateAccess.credentialProvider = currentCredentialProvider;
1458
+ return Promise.resolve(credentialsWithoutSessionToken);
1459
+ };
1460
+ }
1461
+
1462
+ class SignatureV4MultiRegion {
1463
+ sigv4aSigner;
1464
+ sigv4Signer;
1465
+ signerOptions;
1466
+ static sigv4aDependency() {
1467
+ if (typeof signatureV4CrtContainer.CrtSignerV4 === "function") {
1468
+ return "crt";
1469
+ } else if (typeof signatureV4aContainer.SignatureV4a === "function") {
1470
+ return "js";
1471
+ }
1472
+ return "none";
1473
+ }
1474
+ constructor(options) {
1475
+ this.sigv4Signer = new SignatureV4SignWithCredentials(options);
1476
+ this.signerOptions = options;
1477
+ }
1478
+ async sign(requestToSign, options = {}) {
1479
+ if (options.signingRegion === "*") {
1480
+ return this.getSigv4aSigner().sign(requestToSign, options);
1481
+ }
1482
+ return this.sigv4Signer.sign(requestToSign, options);
1483
+ }
1484
+ async signWithCredentials(requestToSign, credentials, options = {}) {
1485
+ if (options.signingRegion === "*") {
1486
+ const signer = this.getSigv4aSigner();
1487
+ const CrtSignerV4 = signatureV4CrtContainer.CrtSignerV4;
1488
+ if (CrtSignerV4 && signer instanceof CrtSignerV4) {
1489
+ return signer.signWithCredentials(requestToSign, credentials, options);
1490
+ } else {
1491
+ throw new Error(`signWithCredentials with signingRegion '*' is only supported when using the CRT dependency @aws-sdk/signature-v4-crt. ` + `Please check whether you have installed the "@aws-sdk/signature-v4-crt" package explicitly. ` + `You must also register the package by calling [require("@aws-sdk/signature-v4-crt");] ` + `or an ESM equivalent such as [import "@aws-sdk/signature-v4-crt";]. ` + `For more information please go to https://github.com/aws/aws-sdk-js-v3#functionality-requiring-aws-common-runtime-crt`);
1492
+ }
1493
+ }
1494
+ return this.sigv4Signer.signWithCredentials(requestToSign, credentials, options);
1495
+ }
1496
+ async presign(originalRequest, options = {}) {
1497
+ if (options.signingRegion === "*") {
1498
+ const signer = this.getSigv4aSigner();
1499
+ const CrtSignerV4 = signatureV4CrtContainer.CrtSignerV4;
1500
+ if (CrtSignerV4 && signer instanceof CrtSignerV4) {
1501
+ return signer.presign(originalRequest, options);
1502
+ } else {
1503
+ throw new Error(`presign with signingRegion '*' is only supported when using the CRT dependency @aws-sdk/signature-v4-crt. ` + `Please check whether you have installed the "@aws-sdk/signature-v4-crt" package explicitly. ` + `You must also register the package by calling [require("@aws-sdk/signature-v4-crt");] ` + `or an ESM equivalent such as [import "@aws-sdk/signature-v4-crt";]. ` + `For more information please go to https://github.com/aws/aws-sdk-js-v3#functionality-requiring-aws-common-runtime-crt`);
1504
+ }
1505
+ }
1506
+ return this.sigv4Signer.presign(originalRequest, options);
1507
+ }
1508
+ async presignWithCredentials(originalRequest, credentials, options = {}) {
1509
+ if (options.signingRegion === "*") {
1510
+ throw new Error("Method presignWithCredentials is not supported for [signingRegion=*].");
1511
+ }
1512
+ return this.sigv4Signer.presignWithCredentials(originalRequest, credentials, options);
1513
+ }
1514
+ getSigv4aSigner() {
1515
+ if (!this.sigv4aSigner) {
1516
+ const CrtSignerV4 = signatureV4CrtContainer.CrtSignerV4;
1517
+ const JsSigV4aSigner = signatureV4aContainer.SignatureV4a;
1518
+ if (this.signerOptions.runtime === "node") {
1519
+ if (!CrtSignerV4 && !JsSigV4aSigner) {
1520
+ throw new Error("Neither CRT nor JS SigV4a implementation is available. " + "Please load either @aws-sdk/signature-v4-crt or @aws-sdk/signature-v4a. " + "For more information please go to " + "https://github.com/aws/aws-sdk-js-v3#functionality-requiring-aws-common-runtime-crt");
1521
+ }
1522
+ if (CrtSignerV4 && typeof CrtSignerV4 === "function") {
1523
+ this.sigv4aSigner = new CrtSignerV4({
1524
+ ...this.signerOptions,
1525
+ signingAlgorithm: 1
1526
+ });
1527
+ } else if (JsSigV4aSigner && typeof JsSigV4aSigner === "function") {
1528
+ this.sigv4aSigner = new JsSigV4aSigner({
1529
+ ...this.signerOptions
1530
+ });
1531
+ } else {
1532
+ throw new Error("Available SigV4a implementation is not a valid constructor. " + "Please ensure you've properly imported @aws-sdk/signature-v4-crt or @aws-sdk/signature-v4a." + "For more information please go to " + "https://github.com/aws/aws-sdk-js-v3#functionality-requiring-aws-common-runtime-crt");
1533
+ }
1534
+ } else {
1535
+ if (!JsSigV4aSigner || typeof JsSigV4aSigner !== "function") {
1536
+ throw new Error("JS SigV4a implementation is not available or not a valid constructor. " + "Please check whether you have installed the @aws-sdk/signature-v4a package explicitly. The CRT implementation is not available for browsers. " + "You must also register the package by calling [require('@aws-sdk/signature-v4a');] " + "or an ESM equivalent such as [import '@aws-sdk/signature-v4a';]. " + "For more information please go to " + "https://github.com/aws/aws-sdk-js-v3#using-javascript-non-crt-implementation-of-sigv4a");
1537
+ }
1538
+ this.sigv4aSigner = new JsSigV4aSigner({
1539
+ ...this.signerOptions
1540
+ });
1541
+ }
1542
+ }
1543
+ return this.sigv4aSigner;
1544
+ }
1545
+ }
1546
+ exports.SignatureV4MultiRegion = SignatureV4MultiRegion;
1547
+ exports.SignatureV4SignWithCredentials = SignatureV4SignWithCredentials;
1548
+ exports.signatureV4CrtContainer = signatureV4CrtContainer;
1549
+ });
1550
+
1551
+ // node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js
1552
+ var require_sts = __commonJS(function(exports) {
1553
+ var { awsEndpointFunctions, emitWarningIfUnsupportedVersion: emitWarningIfUnsupportedVersion$1, createDefaultUserAgentProvider, NODE_APP_ID_CONFIG_OPTIONS, getAwsRegionExtensionConfiguration, resolveAwsRegionExtensionConfiguration, resolveUserAgentConfig, resolveHostHeaderConfig, getUserAgentPlugin, getHostHeaderPlugin, getLoggerPlugin, getRecursionDetectionPlugin, setCredentialFeature, stsRegionDefaultResolver } = require_client2();
1554
+ var { NoAuthSigner, getHttpAuthSchemeEndpointRuleSetPlugin, DefaultIdentityProviderConfig, getHttpSigningPlugin } = require_dist_cjs();
1555
+ var { normalizeProvider, getSmithyContext, ServiceException, NoOpLogger, emitWarningIfUnsupportedVersion, loadConfigsForDefaultMode, getDefaultExtensionConfiguration, resolveDefaultRuntimeConfig, Client, makeBuilder, createAggregatedClient } = require_client();
1556
+ var { Command: $Command } = require_client();
1557
+ exports.$Command = $Command;
1558
+ exports.__Client = Client;
1559
+ var { resolveDefaultsModeConfig, loadConfig, NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS, NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS, NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS, resolveRegionConfig } = require_config();
1560
+ var { BinaryDecisionDiagram, EndpointCache, decideEndpoint, customEndpointFunctions, resolveParams, resolveEndpointConfig, getEndpointPlugin } = require_endpoints();
1561
+ var { parseUrl, getHttpHandlerExtensionConfiguration, resolveHttpHandlerRuntimeConfig, getContentLengthPlugin } = require_protocols();
1562
+ var { DEFAULT_RETRY_MODE, NODE_RETRY_MODE_CONFIG_OPTIONS, NODE_MAX_ATTEMPT_CONFIG_OPTIONS, resolveRetryConfig, getRetryPlugin } = require_retry();
1563
+ var { TypeRegistry, getSchemaSerdePlugin } = require_schema();
1564
+ var { resolveAwsSdkSigV4Config, resolveAwsSdkSigV4AConfig, AwsSdkSigV4Signer, AwsSdkSigV4ASigner, NODE_SIGV4A_CONFIG_OPTIONS, NODE_AUTH_SCHEME_PREFERENCE_OPTIONS } = require_httpAuthSchemes();
1565
+ var { SignatureV4MultiRegion } = require_dist_cjs9();
1566
+ var { toUtf8, fromUtf8, toBase64, fromBase64, calculateBodyLength } = require_serde();
1567
+ var { streamCollector, NodeHttpHandler } = require_dist_cjs3();
1568
+ var { AwsQueryProtocol } = require_protocols2();
1569
+ var { Sha256 } = require_checksum();
1570
+ var q = "ref";
1571
+ var a = -1;
1572
+ var b = true;
1573
+ var c = "isSet";
1574
+ var d = "PartitionResult";
1575
+ var e = "booleanEquals";
1576
+ var f = "stringEquals";
1577
+ var g = "getAttr";
1578
+ var h = "us-east-1";
1579
+ var i = "sigv4";
1580
+ var j = "sts";
1581
+ var k = "https://sts.{Region}.{PartitionResult#dnsSuffix}";
1582
+ var l = { [q]: "Endpoint" };
1583
+ var m = { [q]: "Region" };
1584
+ var n = { [q]: d };
1585
+ var o = {};
1586
+ var p = [m];
1587
+ var _data = {
1588
+ conditions: [
1589
+ [c, [l]],
1590
+ [c, p],
1591
+ ["aws.partition", p, d],
1592
+ [e, [{ [q]: "UseFIPS" }, b]],
1593
+ [e, [{ [q]: "UseDualStack" }, b]],
1594
+ [f, [m, "aws-global"]],
1595
+ [e, [{ [q]: "UseGlobalEndpoint" }, b]],
1596
+ [f, [m, "eu-central-1"]],
1597
+ [e, [{ fn: g, argv: [n, "supportsDualStack"] }, b]],
1598
+ [e, [{ fn: g, argv: [n, "supportsFIPS"] }, b]],
1599
+ [f, [m, "ap-south-1"]],
1600
+ [f, [m, "eu-north-1"]],
1601
+ [f, [m, "eu-west-1"]],
1602
+ [f, [m, "eu-west-2"]],
1603
+ [f, [m, "eu-west-3"]],
1604
+ [f, [m, "sa-east-1"]],
1605
+ [f, [m, h]],
1606
+ [f, [m, "us-east-2"]],
1607
+ [f, [m, "us-west-2"]],
1608
+ [f, [m, "us-west-1"]],
1609
+ [f, [m, "ca-central-1"]],
1610
+ [f, [m, "ap-southeast-1"]],
1611
+ [f, [m, "ap-northeast-1"]],
1612
+ [f, [m, "ap-southeast-2"]],
1613
+ [f, [{ fn: g, argv: [n, "name"] }, "aws-us-gov"]]
1614
+ ],
1615
+ results: [
1616
+ [a],
1617
+ ["https://sts.amazonaws.com", { authSchemes: [{ name: i, signingName: j, signingRegion: h }] }],
1618
+ [k, { authSchemes: [{ name: i, signingName: j, signingRegion: "{Region}" }] }],
1619
+ [a, "Invalid Configuration: FIPS and custom endpoint are not supported"],
1620
+ [a, "Invalid Configuration: Dualstack and custom endpoint are not supported"],
1621
+ [l, o],
1622
+ ["https://sts-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", o],
1623
+ [a, "FIPS and DualStack are enabled, but this partition does not support one or both"],
1624
+ ["https://sts.{Region}.amazonaws.com", o],
1625
+ ["https://sts-fips.{Region}.{PartitionResult#dnsSuffix}", o],
1626
+ [a, "FIPS is enabled but this partition does not support FIPS"],
1627
+ ["https://sts.{Region}.{PartitionResult#dualStackDnsSuffix}", o],
1628
+ [a, "DualStack is enabled but this partition does not support DualStack"],
1629
+ [k, o],
1630
+ [a, "Invalid Configuration: Missing Region"]
1631
+ ]
1632
+ };
1633
+ var root = 2;
1634
+ var r = 1e8;
1635
+ var nodes = new Int32Array([
1636
+ -1,
1637
+ 1,
1638
+ -1,
1639
+ 0,
1640
+ 30,
1641
+ 3,
1642
+ 1,
1643
+ 4,
1644
+ r + 14,
1645
+ 2,
1646
+ 5,
1647
+ r + 14,
1648
+ 3,
1649
+ 25,
1650
+ 6,
1651
+ 4,
1652
+ 24,
1653
+ 7,
1654
+ 5,
1655
+ r + 1,
1656
+ 8,
1657
+ 6,
1658
+ 9,
1659
+ r + 13,
1660
+ 7,
1661
+ r + 1,
1662
+ 10,
1663
+ 10,
1664
+ r + 1,
1665
+ 11,
1666
+ 11,
1667
+ r + 1,
1668
+ 12,
1669
+ 12,
1670
+ r + 1,
1671
+ 13,
1672
+ 13,
1673
+ r + 1,
1674
+ 14,
1675
+ 14,
1676
+ r + 1,
1677
+ 15,
1678
+ 15,
1679
+ r + 1,
1680
+ 16,
1681
+ 16,
1682
+ r + 1,
1683
+ 17,
1684
+ 17,
1685
+ r + 1,
1686
+ 18,
1687
+ 18,
1688
+ r + 1,
1689
+ 19,
1690
+ 19,
1691
+ r + 1,
1692
+ 20,
1693
+ 20,
1694
+ r + 1,
1695
+ 21,
1696
+ 21,
1697
+ r + 1,
1698
+ 22,
1699
+ 22,
1700
+ r + 1,
1701
+ 23,
1702
+ 23,
1703
+ r + 1,
1704
+ r + 2,
1705
+ 8,
1706
+ r + 11,
1707
+ r + 12,
1708
+ 4,
1709
+ 28,
1710
+ 26,
1711
+ 9,
1712
+ 27,
1713
+ r + 10,
1714
+ 24,
1715
+ r + 8,
1716
+ r + 9,
1717
+ 8,
1718
+ 29,
1719
+ r + 7,
1720
+ 9,
1721
+ r + 6,
1722
+ r + 7,
1723
+ 3,
1724
+ r + 3,
1725
+ 31,
1726
+ 4,
1727
+ r + 4,
1728
+ r + 5
1729
+ ]);
1730
+ var bdd = BinaryDecisionDiagram.from(nodes, root, _data.conditions, _data.results);
1731
+ var cache = new EndpointCache({
1732
+ size: 50,
1733
+ params: ["Endpoint", "Region", "UseDualStack", "UseFIPS", "UseGlobalEndpoint"]
1734
+ });
1735
+ var defaultEndpointResolver = (endpointParams, context = {}) => {
1736
+ return cache.get(endpointParams, () => decideEndpoint(bdd, {
1737
+ endpointParams,
1738
+ logger: context.logger
1739
+ }));
1740
+ };
1741
+ customEndpointFunctions.aws = awsEndpointFunctions;
1742
+ var createEndpointRuleSetHttpAuthSchemeParametersProvider = (defaultHttpAuthSchemeParametersProvider) => async (config, context, input) => {
1743
+ if (!input) {
1744
+ throw new Error("Could not find `input` for `defaultEndpointRuleSetHttpAuthSchemeParametersProvider`");
1745
+ }
1746
+ const defaultParameters = await defaultHttpAuthSchemeParametersProvider(config, context, input);
1747
+ const instructionsFn = getSmithyContext(context)?.commandInstance?.constructor?.getEndpointParameterInstructions;
1748
+ if (!instructionsFn) {
1749
+ throw new Error(`getEndpointParameterInstructions() is not defined on '${context.commandName}'`);
1750
+ }
1751
+ const endpointParameters = await resolveParams(input, { getEndpointParameterInstructions: instructionsFn }, config);
1752
+ return Object.assign(defaultParameters, endpointParameters);
1753
+ };
1754
+ var _defaultSTSHttpAuthSchemeParametersProvider = async (config, context, input) => {
1755
+ return {
1756
+ operation: getSmithyContext(context).operation,
1757
+ region: await normalizeProvider(config.region)() || (() => {
1758
+ throw new Error("expected `region` to be configured for `aws.auth#sigv4`");
1759
+ })()
1760
+ };
1761
+ };
1762
+ var defaultSTSHttpAuthSchemeParametersProvider = createEndpointRuleSetHttpAuthSchemeParametersProvider(_defaultSTSHttpAuthSchemeParametersProvider);
1763
+ function createAwsAuthSigv4HttpAuthOption(authParameters) {
1764
+ return {
1765
+ schemeId: "aws.auth#sigv4",
1766
+ signingProperties: {
1767
+ name: "sts",
1768
+ region: authParameters.region
1769
+ },
1770
+ propertiesExtractor: (config, context) => ({
1771
+ signingProperties: {
1772
+ config,
1773
+ context
1774
+ }
1775
+ })
1776
+ };
1777
+ }
1778
+ function createAwsAuthSigv4aHttpAuthOption(authParameters) {
1779
+ return {
1780
+ schemeId: "aws.auth#sigv4a",
1781
+ signingProperties: {
1782
+ name: "sts",
1783
+ region: authParameters.region
1784
+ },
1785
+ propertiesExtractor: (config, context) => ({
1786
+ signingProperties: {
1787
+ config,
1788
+ context
1789
+ }
1790
+ })
1791
+ };
1792
+ }
1793
+ function createSmithyApiNoAuthHttpAuthOption(authParameters) {
1794
+ return {
1795
+ schemeId: "smithy.api#noAuth"
1796
+ };
1797
+ }
1798
+ var createEndpointRuleSetHttpAuthSchemeProvider = (defaultEndpointResolver2, defaultHttpAuthSchemeResolver, createHttpAuthOptionFunctions) => {
1799
+ const endpointRuleSetHttpAuthSchemeProvider = (authParameters) => {
1800
+ const endpoint = defaultEndpointResolver2(authParameters);
1801
+ const authSchemes = endpoint.properties?.authSchemes;
1802
+ if (!authSchemes) {
1803
+ return defaultHttpAuthSchemeResolver(authParameters);
1804
+ }
1805
+ const options = [];
1806
+ for (const scheme of authSchemes) {
1807
+ const { name: resolvedName, properties = {}, ...rest } = scheme;
1808
+ const name = resolvedName.toLowerCase();
1809
+ if (resolvedName !== name) {
1810
+ console.warn(`HttpAuthScheme has been normalized with lowercasing: '${resolvedName}' to '${name}'`);
1811
+ }
1812
+ let schemeId;
1813
+ if (name === "sigv4a") {
1814
+ schemeId = "aws.auth#sigv4a";
1815
+ const sigv4Present = authSchemes.find((s) => {
1816
+ const name2 = s.name.toLowerCase();
1817
+ return name2 !== "sigv4a" && name2.startsWith("sigv4");
1818
+ });
1819
+ if (SignatureV4MultiRegion.sigv4aDependency() === "none" && sigv4Present) {
1820
+ continue;
1821
+ }
1822
+ } else if (name.startsWith("sigv4")) {
1823
+ schemeId = "aws.auth#sigv4";
1824
+ } else {
1825
+ throw new Error(`Unknown HttpAuthScheme found in '@smithy.rules#endpointRuleSet': '${name}'`);
1826
+ }
1827
+ const createOption = createHttpAuthOptionFunctions[schemeId];
1828
+ if (!createOption) {
1829
+ throw new Error(`Could not find HttpAuthOption create function for '${schemeId}'`);
1830
+ }
1831
+ const option = createOption(authParameters);
1832
+ option.schemeId = schemeId;
1833
+ option.signingProperties = { ...option.signingProperties || {}, ...rest, ...properties };
1834
+ options.push(option);
1835
+ }
1836
+ return options;
1837
+ };
1838
+ return endpointRuleSetHttpAuthSchemeProvider;
1839
+ };
1840
+ var _defaultSTSHttpAuthSchemeProvider = (authParameters) => {
1841
+ const options = [];
1842
+ switch (authParameters.operation) {
1843
+ case "AssumeRoleWithWebIdentity": {
1844
+ options.push(createSmithyApiNoAuthHttpAuthOption());
1845
+ options.push(createAwsAuthSigv4aHttpAuthOption(authParameters));
1846
+ break;
1847
+ }
1848
+ default: {
1849
+ options.push(createAwsAuthSigv4HttpAuthOption(authParameters));
1850
+ options.push(createAwsAuthSigv4aHttpAuthOption(authParameters));
1851
+ }
1852
+ }
1853
+ return options;
1854
+ };
1855
+ var defaultSTSHttpAuthSchemeProvider = createEndpointRuleSetHttpAuthSchemeProvider(defaultEndpointResolver, _defaultSTSHttpAuthSchemeProvider, {
1856
+ "aws.auth#sigv4": createAwsAuthSigv4HttpAuthOption,
1857
+ "aws.auth#sigv4a": createAwsAuthSigv4aHttpAuthOption,
1858
+ "smithy.api#noAuth": createSmithyApiNoAuthHttpAuthOption
1859
+ });
1860
+ var resolveHttpAuthSchemeConfig = (config) => {
1861
+ const config_0 = resolveAwsSdkSigV4Config(config);
1862
+ const config_1 = resolveAwsSdkSigV4AConfig(config_0);
1863
+ return Object.assign(config_1, {
1864
+ authSchemePreference: normalizeProvider(config.authSchemePreference ?? [])
1865
+ });
1866
+ };
1867
+ var resolveClientEndpointParameters = (options) => {
1868
+ return Object.assign(options, {
1869
+ useDualstackEndpoint: options.useDualstackEndpoint ?? false,
1870
+ useFipsEndpoint: options.useFipsEndpoint ?? false,
1871
+ useGlobalEndpoint: options.useGlobalEndpoint ?? false,
1872
+ defaultSigningName: "sts"
1873
+ });
1874
+ };
1875
+ var commonParams = {
1876
+ UseGlobalEndpoint: { type: "builtInParams", name: "useGlobalEndpoint" },
1877
+ UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" },
1878
+ Endpoint: { type: "builtInParams", name: "endpoint" },
1879
+ Region: { type: "builtInParams", name: "region" },
1880
+ UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }
1881
+ };
1882
+ var version = "3.997.45";
1883
+ var packageInfo = {
1884
+ version
1885
+ };
1886
+
1887
+ class STSServiceException extends ServiceException {
1888
+ constructor(options) {
1889
+ super(options);
1890
+ Object.setPrototypeOf(this, STSServiceException.prototype);
1891
+ }
1892
+ }
1893
+
1894
+ class ExpiredTokenException extends STSServiceException {
1895
+ name = "ExpiredTokenException";
1896
+ $fault = "client";
1897
+ constructor(opts) {
1898
+ super({
1899
+ name: "ExpiredTokenException",
1900
+ $fault: "client",
1901
+ ...opts
1902
+ });
1903
+ Object.setPrototypeOf(this, ExpiredTokenException.prototype);
1904
+ }
1905
+ }
1906
+
1907
+ class MalformedPolicyDocumentException extends STSServiceException {
1908
+ name = "MalformedPolicyDocumentException";
1909
+ $fault = "client";
1910
+ constructor(opts) {
1911
+ super({
1912
+ name: "MalformedPolicyDocumentException",
1913
+ $fault: "client",
1914
+ ...opts
1915
+ });
1916
+ Object.setPrototypeOf(this, MalformedPolicyDocumentException.prototype);
1917
+ }
1918
+ }
1919
+
1920
+ class PackedPolicyTooLargeException extends STSServiceException {
1921
+ name = "PackedPolicyTooLargeException";
1922
+ $fault = "client";
1923
+ constructor(opts) {
1924
+ super({
1925
+ name: "PackedPolicyTooLargeException",
1926
+ $fault: "client",
1927
+ ...opts
1928
+ });
1929
+ Object.setPrototypeOf(this, PackedPolicyTooLargeException.prototype);
1930
+ }
1931
+ }
1932
+
1933
+ class RegionDisabledException extends STSServiceException {
1934
+ name = "RegionDisabledException";
1935
+ $fault = "client";
1936
+ constructor(opts) {
1937
+ super({
1938
+ name: "RegionDisabledException",
1939
+ $fault: "client",
1940
+ ...opts
1941
+ });
1942
+ Object.setPrototypeOf(this, RegionDisabledException.prototype);
1943
+ }
1944
+ }
1945
+
1946
+ class IDPRejectedClaimException extends STSServiceException {
1947
+ name = "IDPRejectedClaimException";
1948
+ $fault = "client";
1949
+ constructor(opts) {
1950
+ super({
1951
+ name: "IDPRejectedClaimException",
1952
+ $fault: "client",
1953
+ ...opts
1954
+ });
1955
+ Object.setPrototypeOf(this, IDPRejectedClaimException.prototype);
1956
+ }
1957
+ }
1958
+
1959
+ class InvalidIdentityTokenException extends STSServiceException {
1960
+ name = "InvalidIdentityTokenException";
1961
+ $fault = "client";
1962
+ constructor(opts) {
1963
+ super({
1964
+ name: "InvalidIdentityTokenException",
1965
+ $fault: "client",
1966
+ ...opts
1967
+ });
1968
+ Object.setPrototypeOf(this, InvalidIdentityTokenException.prototype);
1969
+ }
1970
+ }
1971
+
1972
+ class IDPCommunicationErrorException extends STSServiceException {
1973
+ name = "IDPCommunicationErrorException";
1974
+ $fault = "client";
1975
+ $retryable = {};
1976
+ constructor(opts) {
1977
+ super({
1978
+ name: "IDPCommunicationErrorException",
1979
+ $fault: "client",
1980
+ ...opts
1981
+ });
1982
+ Object.setPrototypeOf(this, IDPCommunicationErrorException.prototype);
1983
+ }
1984
+ }
1985
+ var _A = "Arn";
1986
+ var _AKI = "AccessKeyId";
1987
+ var _AR = "AssumeRole";
1988
+ var _ARI = "AssumedRoleId";
1989
+ var _ARR = "AssumeRoleRequest";
1990
+ var _ARRs = "AssumeRoleResponse";
1991
+ var _ARU = "AssumedRoleUser";
1992
+ var _ARWWI = "AssumeRoleWithWebIdentity";
1993
+ var _ARWWIR = "AssumeRoleWithWebIdentityRequest";
1994
+ var _ARWWIRs = "AssumeRoleWithWebIdentityResponse";
1995
+ var _Au = "Audience";
1996
+ var _C = "Credentials";
1997
+ var _CA = "ContextAssertion";
1998
+ var _DS = "DurationSeconds";
1999
+ var _E = "Expiration";
2000
+ var _EI = "ExternalId";
2001
+ var _ETE = "ExpiredTokenException";
2002
+ var _IDPCEE = "IDPCommunicationErrorException";
2003
+ var _IDPRCE = "IDPRejectedClaimException";
2004
+ var _IITE = "InvalidIdentityTokenException";
2005
+ var _K = "Key";
2006
+ var _MPDE = "MalformedPolicyDocumentException";
2007
+ var _MSTS = "MinimumSessionTokenSize";
2008
+ var _P = "Policy";
2009
+ var _PA = "PolicyArns";
2010
+ var _PAr = "ProviderArn";
2011
+ var _PC = "ProvidedContexts";
2012
+ var _PCLT = "ProvidedContextsListType";
2013
+ var _PCr = "ProvidedContext";
2014
+ var _PDT = "PolicyDescriptorType";
2015
+ var _PI = "ProviderId";
2016
+ var _PPS = "PackedPolicySize";
2017
+ var _PPTLE = "PackedPolicyTooLargeException";
2018
+ var _Pr = "Provider";
2019
+ var _RA = "RoleArn";
2020
+ var _RDE = "RegionDisabledException";
2021
+ var _RSN = "RoleSessionName";
2022
+ var _SAK = "SecretAccessKey";
2023
+ var _SFWIT = "SubjectFromWebIdentityToken";
2024
+ var _SI = "SourceIdentity";
2025
+ var _SN = "SerialNumber";
2026
+ var _ST = "SessionToken";
2027
+ var _STS = "SessionTokenSize";
2028
+ var _STU = "SessionTokenUtilization";
2029
+ var _T = "Tags";
2030
+ var _TC = "TokenCode";
2031
+ var _TTK = "TransitiveTagKeys";
2032
+ var _Ta = "Tag";
2033
+ var _V = "Value";
2034
+ var _WIT = "WebIdentityToken";
2035
+ var _a = "arn";
2036
+ var _aKST = "accessKeySecretType";
2037
+ var _aQE = "awsQueryError";
2038
+ var _c = "client";
2039
+ var _cTT = "clientTokenType";
2040
+ var _e = "error";
2041
+ var _hE = "httpError";
2042
+ var _m = "message";
2043
+ var _pDLT = "policyDescriptorListType";
2044
+ var _s = "smithy.ts.sdk.synthetic.com.amazonaws.sts";
2045
+ var _tLT = "tagListType";
2046
+ var n0 = "com.amazonaws.sts";
2047
+ var _s_registry = new TypeRegistry(_s);
2048
+ var STSServiceException$ = [-3, _s, "STSServiceException", 0, [], []];
2049
+ _s_registry.registerError(STSServiceException$, STSServiceException);
2050
+ var n0_registry = new TypeRegistry(n0);
2051
+ var ExpiredTokenException$ = [
2052
+ -3,
2053
+ n0,
2054
+ _ETE,
2055
+ { [_aQE]: [`ExpiredTokenException`, 400], [_e]: _c, [_hE]: 400 },
2056
+ [_m],
2057
+ [0]
2058
+ ];
2059
+ n0_registry.registerError(ExpiredTokenException$, ExpiredTokenException);
2060
+ var IDPCommunicationErrorException$ = [
2061
+ -3,
2062
+ n0,
2063
+ _IDPCEE,
2064
+ { [_aQE]: [`IDPCommunicationError`, 400], [_e]: _c, [_hE]: 400 },
2065
+ [_m],
2066
+ [0]
2067
+ ];
2068
+ n0_registry.registerError(IDPCommunicationErrorException$, IDPCommunicationErrorException);
2069
+ var IDPRejectedClaimException$ = [
2070
+ -3,
2071
+ n0,
2072
+ _IDPRCE,
2073
+ { [_aQE]: [`IDPRejectedClaim`, 403], [_e]: _c, [_hE]: 403 },
2074
+ [_m],
2075
+ [0]
2076
+ ];
2077
+ n0_registry.registerError(IDPRejectedClaimException$, IDPRejectedClaimException);
2078
+ var InvalidIdentityTokenException$ = [
2079
+ -3,
2080
+ n0,
2081
+ _IITE,
2082
+ { [_aQE]: [`InvalidIdentityToken`, 400], [_e]: _c, [_hE]: 400 },
2083
+ [_m],
2084
+ [0]
2085
+ ];
2086
+ n0_registry.registerError(InvalidIdentityTokenException$, InvalidIdentityTokenException);
2087
+ var MalformedPolicyDocumentException$ = [
2088
+ -3,
2089
+ n0,
2090
+ _MPDE,
2091
+ { [_aQE]: [`MalformedPolicyDocument`, 400], [_e]: _c, [_hE]: 400 },
2092
+ [_m],
2093
+ [0]
2094
+ ];
2095
+ n0_registry.registerError(MalformedPolicyDocumentException$, MalformedPolicyDocumentException);
2096
+ var PackedPolicyTooLargeException$ = [
2097
+ -3,
2098
+ n0,
2099
+ _PPTLE,
2100
+ { [_aQE]: [`PackedPolicyTooLarge`, 400], [_e]: _c, [_hE]: 400 },
2101
+ [_m],
2102
+ [0]
2103
+ ];
2104
+ n0_registry.registerError(PackedPolicyTooLargeException$, PackedPolicyTooLargeException);
2105
+ var RegionDisabledException$ = [
2106
+ -3,
2107
+ n0,
2108
+ _RDE,
2109
+ { [_aQE]: [`RegionDisabledException`, 403], [_e]: _c, [_hE]: 403 },
2110
+ [_m],
2111
+ [0]
2112
+ ];
2113
+ n0_registry.registerError(RegionDisabledException$, RegionDisabledException);
2114
+ var errorTypeRegistries = [
2115
+ _s_registry,
2116
+ n0_registry
2117
+ ];
2118
+ var accessKeySecretType = [0, n0, _aKST, 8, 0];
2119
+ var clientTokenType = [0, n0, _cTT, 8, 0];
2120
+ var AssumedRoleUser$ = [
2121
+ 3,
2122
+ n0,
2123
+ _ARU,
2124
+ 0,
2125
+ [_ARI, _A],
2126
+ [0, 0],
2127
+ 2
2128
+ ];
2129
+ var AssumeRoleRequest$ = [
2130
+ 3,
2131
+ n0,
2132
+ _ARR,
2133
+ 0,
2134
+ [_RA, _RSN, _PA, _P, _DS, _T, _TTK, _EI, _SN, _TC, _SI, _PC, _MSTS],
2135
+ [0, 0, () => policyDescriptorListType, 0, 1, () => tagListType, 64 | 0, 0, 0, 0, 0, () => ProvidedContextsListType, 1],
2136
+ 2
2137
+ ];
2138
+ var AssumeRoleResponse$ = [
2139
+ 3,
2140
+ n0,
2141
+ _ARRs,
2142
+ 0,
2143
+ [_C, _ARU, _PPS, _SI, _STU, _STS],
2144
+ [[() => Credentials$, 0], () => AssumedRoleUser$, 1, 0, 1, 1]
2145
+ ];
2146
+ var AssumeRoleWithWebIdentityRequest$ = [
2147
+ 3,
2148
+ n0,
2149
+ _ARWWIR,
2150
+ 0,
2151
+ [_RA, _RSN, _WIT, _PI, _PA, _P, _DS, _MSTS],
2152
+ [0, 0, [() => clientTokenType, 0], 0, () => policyDescriptorListType, 0, 1, 1],
2153
+ 3
2154
+ ];
2155
+ var AssumeRoleWithWebIdentityResponse$ = [
2156
+ 3,
2157
+ n0,
2158
+ _ARWWIRs,
2159
+ 0,
2160
+ [_C, _SFWIT, _ARU, _PPS, _Pr, _Au, _SI, _STU, _STS],
2161
+ [[() => Credentials$, 0], 0, () => AssumedRoleUser$, 1, 0, 0, 0, 1, 1]
2162
+ ];
2163
+ var Credentials$ = [
2164
+ 3,
2165
+ n0,
2166
+ _C,
2167
+ 0,
2168
+ [_AKI, _SAK, _ST, _E],
2169
+ [0, [() => accessKeySecretType, 0], 0, 4],
2170
+ 4
2171
+ ];
2172
+ var PolicyDescriptorType$ = [
2173
+ 3,
2174
+ n0,
2175
+ _PDT,
2176
+ 0,
2177
+ [_a],
2178
+ [0]
2179
+ ];
2180
+ var ProvidedContext$ = [
2181
+ 3,
2182
+ n0,
2183
+ _PCr,
2184
+ 0,
2185
+ [_PAr, _CA],
2186
+ [0, 0]
2187
+ ];
2188
+ var Tag$ = [
2189
+ 3,
2190
+ n0,
2191
+ _Ta,
2192
+ 0,
2193
+ [_K, _V],
2194
+ [0, 0],
2195
+ 2
2196
+ ];
2197
+ var policyDescriptorListType = [
2198
+ 1,
2199
+ n0,
2200
+ _pDLT,
2201
+ 0,
2202
+ () => PolicyDescriptorType$
2203
+ ];
2204
+ var ProvidedContextsListType = [
2205
+ 1,
2206
+ n0,
2207
+ _PCLT,
2208
+ 0,
2209
+ () => ProvidedContext$
2210
+ ];
2211
+ var tagListType = [
2212
+ 1,
2213
+ n0,
2214
+ _tLT,
2215
+ 0,
2216
+ () => Tag$
2217
+ ];
2218
+ var AssumeRole$ = [
2219
+ 9,
2220
+ n0,
2221
+ _AR,
2222
+ 0,
2223
+ () => AssumeRoleRequest$,
2224
+ () => AssumeRoleResponse$
2225
+ ];
2226
+ var AssumeRoleWithWebIdentity$ = [
2227
+ 9,
2228
+ n0,
2229
+ _ARWWI,
2230
+ 0,
2231
+ () => AssumeRoleWithWebIdentityRequest$,
2232
+ () => AssumeRoleWithWebIdentityResponse$
2233
+ ];
2234
+ var getRuntimeConfig$1 = (config) => {
2235
+ return {
2236
+ apiVersion: "2011-06-15",
2237
+ base64Decoder: config?.base64Decoder ?? fromBase64,
2238
+ base64Encoder: config?.base64Encoder ?? toBase64,
2239
+ disableHostPrefix: config?.disableHostPrefix ?? false,
2240
+ endpointProvider: config?.endpointProvider ?? defaultEndpointResolver,
2241
+ extensions: config?.extensions ?? [],
2242
+ httpAuthSchemeProvider: config?.httpAuthSchemeProvider ?? defaultSTSHttpAuthSchemeProvider,
2243
+ httpAuthSchemes: config?.httpAuthSchemes ?? [
2244
+ {
2245
+ schemeId: "aws.auth#sigv4",
2246
+ identityProvider: (ipc) => ipc.getIdentityProvider("aws.auth#sigv4"),
2247
+ signer: new AwsSdkSigV4Signer
2248
+ },
2249
+ {
2250
+ schemeId: "aws.auth#sigv4a",
2251
+ identityProvider: (ipc) => ipc.getIdentityProvider("aws.auth#sigv4a"),
2252
+ signer: new AwsSdkSigV4ASigner
2253
+ },
2254
+ {
2255
+ schemeId: "smithy.api#noAuth",
2256
+ identityProvider: (ipc) => ipc.getIdentityProvider("smithy.api#noAuth") || (async () => ({})),
2257
+ signer: new NoAuthSigner
2258
+ }
2259
+ ],
2260
+ logger: config?.logger ?? new NoOpLogger,
2261
+ protocol: config?.protocol ?? AwsQueryProtocol,
2262
+ protocolSettings: config?.protocolSettings ?? {
2263
+ defaultNamespace: "com.amazonaws.sts",
2264
+ errorTypeRegistries,
2265
+ xmlNamespace: "https://sts.amazonaws.com/doc/2011-06-15/",
2266
+ version: "2011-06-15",
2267
+ serviceTarget: "AWSSecurityTokenServiceV20110615"
2268
+ },
2269
+ serviceId: config?.serviceId ?? "STS",
2270
+ sha256: config?.sha256 ?? Sha256,
2271
+ signerConstructor: config?.signerConstructor ?? SignatureV4MultiRegion,
2272
+ urlParser: config?.urlParser ?? parseUrl,
2273
+ utf8Decoder: config?.utf8Decoder ?? fromUtf8,
2274
+ utf8Encoder: config?.utf8Encoder ?? toUtf8
2275
+ };
2276
+ };
2277
+ var getRuntimeConfig = (config) => {
2278
+ emitWarningIfUnsupportedVersion(process.version);
2279
+ const defaultsMode = resolveDefaultsModeConfig(config);
2280
+ const defaultConfigProvider = () => defaultsMode().then(loadConfigsForDefaultMode);
2281
+ const clientSharedValues = getRuntimeConfig$1(config);
2282
+ emitWarningIfUnsupportedVersion$1(process.version);
2283
+ const loaderConfig = {
2284
+ profile: config?.profile,
2285
+ logger: clientSharedValues.logger
2286
+ };
2287
+ return {
2288
+ ...clientSharedValues,
2289
+ ...config,
2290
+ runtime: "node",
2291
+ defaultsMode,
2292
+ authSchemePreference: config?.authSchemePreference ?? loadConfig(NODE_AUTH_SCHEME_PREFERENCE_OPTIONS, loaderConfig),
2293
+ bodyLengthChecker: config?.bodyLengthChecker ?? calculateBodyLength,
2294
+ defaultUserAgentProvider: config?.defaultUserAgentProvider ?? createDefaultUserAgentProvider({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }),
2295
+ httpAuthSchemes: config?.httpAuthSchemes ?? [
2296
+ {
2297
+ schemeId: "aws.auth#sigv4",
2298
+ identityProvider: (ipc) => ipc.getIdentityProvider("aws.auth#sigv4") || (async (idProps) => await config.credentialDefaultProvider(idProps?.__config || {})()),
2299
+ signer: new AwsSdkSigV4Signer
2300
+ },
2301
+ {
2302
+ schemeId: "aws.auth#sigv4a",
2303
+ identityProvider: (ipc) => ipc.getIdentityProvider("aws.auth#sigv4a"),
2304
+ signer: new AwsSdkSigV4ASigner
2305
+ },
2306
+ {
2307
+ schemeId: "smithy.api#noAuth",
2308
+ identityProvider: (ipc) => ipc.getIdentityProvider("smithy.api#noAuth") || (async () => ({})),
2309
+ signer: new NoAuthSigner
2310
+ }
2311
+ ],
2312
+ maxAttempts: config?.maxAttempts ?? loadConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS, config),
2313
+ region: config?.region ?? loadConfig(NODE_REGION_CONFIG_OPTIONS, { ...NODE_REGION_CONFIG_FILE_OPTIONS, ...loaderConfig }),
2314
+ requestHandler: NodeHttpHandler.create(config?.requestHandler ?? defaultConfigProvider),
2315
+ retryMode: config?.retryMode ?? loadConfig({
2316
+ ...NODE_RETRY_MODE_CONFIG_OPTIONS,
2317
+ default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE
2318
+ }, config),
2319
+ sigv4aSigningRegionSet: config?.sigv4aSigningRegionSet ?? loadConfig(NODE_SIGV4A_CONFIG_OPTIONS, loaderConfig),
2320
+ streamCollector: config?.streamCollector ?? streamCollector,
2321
+ useDualstackEndpoint: config?.useDualstackEndpoint ?? loadConfig(NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS, loaderConfig),
2322
+ useFipsEndpoint: config?.useFipsEndpoint ?? loadConfig(NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS, loaderConfig),
2323
+ userAgentAppId: config?.userAgentAppId ?? loadConfig(NODE_APP_ID_CONFIG_OPTIONS, loaderConfig)
2324
+ };
2325
+ };
2326
+ var getHttpAuthExtensionConfiguration = (runtimeConfig) => {
2327
+ const _httpAuthSchemes = runtimeConfig.httpAuthSchemes;
2328
+ let _httpAuthSchemeProvider = runtimeConfig.httpAuthSchemeProvider;
2329
+ let _credentials = runtimeConfig.credentials;
2330
+ return {
2331
+ setHttpAuthScheme(httpAuthScheme) {
2332
+ const index = _httpAuthSchemes.findIndex((scheme) => scheme.schemeId === httpAuthScheme.schemeId);
2333
+ if (index === -1) {
2334
+ _httpAuthSchemes.push(httpAuthScheme);
2335
+ } else {
2336
+ _httpAuthSchemes.splice(index, 1, httpAuthScheme);
2337
+ }
2338
+ },
2339
+ httpAuthSchemes() {
2340
+ return _httpAuthSchemes;
2341
+ },
2342
+ setHttpAuthSchemeProvider(httpAuthSchemeProvider) {
2343
+ _httpAuthSchemeProvider = httpAuthSchemeProvider;
2344
+ },
2345
+ httpAuthSchemeProvider() {
2346
+ return _httpAuthSchemeProvider;
2347
+ },
2348
+ setCredentials(credentials) {
2349
+ _credentials = credentials;
2350
+ },
2351
+ credentials() {
2352
+ return _credentials;
2353
+ }
2354
+ };
2355
+ };
2356
+ var resolveHttpAuthRuntimeConfig = (config) => {
2357
+ return {
2358
+ httpAuthSchemes: config.httpAuthSchemes(),
2359
+ httpAuthSchemeProvider: config.httpAuthSchemeProvider(),
2360
+ credentials: config.credentials()
2361
+ };
2362
+ };
2363
+ var resolveRuntimeExtensions = (runtimeConfig, extensions) => {
2364
+ const extensionConfiguration = Object.assign(getAwsRegionExtensionConfiguration(runtimeConfig), getDefaultExtensionConfiguration(runtimeConfig), getHttpHandlerExtensionConfiguration(runtimeConfig), getHttpAuthExtensionConfiguration(runtimeConfig));
2365
+ extensions.forEach((extension) => extension.configure(extensionConfiguration));
2366
+ return Object.assign(runtimeConfig, resolveAwsRegionExtensionConfiguration(extensionConfiguration), resolveDefaultRuntimeConfig(extensionConfiguration), resolveHttpHandlerRuntimeConfig(extensionConfiguration), resolveHttpAuthRuntimeConfig(extensionConfiguration));
2367
+ };
2368
+
2369
+ class STSClient extends Client {
2370
+ config;
2371
+ constructor(...[configuration]) {
2372
+ const _config_0 = getRuntimeConfig(configuration || {});
2373
+ super(_config_0);
2374
+ this.initConfig = _config_0;
2375
+ const _config_1 = resolveClientEndpointParameters(_config_0);
2376
+ const _config_2 = resolveUserAgentConfig(_config_1);
2377
+ const _config_3 = resolveRetryConfig(_config_2);
2378
+ const _config_4 = resolveRegionConfig(_config_3);
2379
+ const _config_5 = resolveHostHeaderConfig(_config_4);
2380
+ const _config_6 = resolveEndpointConfig(_config_5);
2381
+ const _config_7 = resolveHttpAuthSchemeConfig(_config_6);
2382
+ const _config_8 = resolveRuntimeExtensions(_config_7, configuration?.extensions || []);
2383
+ this.config = _config_8;
2384
+ this.middlewareStack.use(getSchemaSerdePlugin(this.config));
2385
+ this.middlewareStack.use(getUserAgentPlugin(this.config));
2386
+ this.middlewareStack.use(getRetryPlugin(this.config));
2387
+ this.middlewareStack.use(getContentLengthPlugin(this.config));
2388
+ this.middlewareStack.use(getHostHeaderPlugin(this.config));
2389
+ this.middlewareStack.use(getLoggerPlugin(this.config));
2390
+ this.middlewareStack.use(getRecursionDetectionPlugin(this.config));
2391
+ this.middlewareStack.use(getHttpAuthSchemeEndpointRuleSetPlugin(this.config, {
2392
+ httpAuthSchemeParametersProvider: defaultSTSHttpAuthSchemeParametersProvider,
2393
+ identityProviderConfigProvider: async (config) => new DefaultIdentityProviderConfig({
2394
+ "aws.auth#sigv4": config.credentials,
2395
+ "aws.auth#sigv4a": config.credentials
2396
+ })
2397
+ }));
2398
+ this.middlewareStack.use(getHttpSigningPlugin(this.config));
2399
+ }
2400
+ destroy() {
2401
+ super.destroy();
2402
+ }
2403
+ }
2404
+ var command = makeBuilder(commonParams, "AWSSecurityTokenServiceV20110615", "STSClient", getEndpointPlugin);
2405
+ var _ep0 = {};
2406
+ var _mw0 = (Command, cs, config, o2) => [];
2407
+
2408
+ class AssumeRoleCommand extends command(_ep0, _mw0, "AssumeRole", AssumeRole$) {
2409
+ }
2410
+
2411
+ class AssumeRoleWithWebIdentityCommand extends command(_ep0, _mw0, "AssumeRoleWithWebIdentity", AssumeRoleWithWebIdentity$) {
2412
+ }
2413
+ var commands = {
2414
+ AssumeRoleCommand,
2415
+ AssumeRoleWithWebIdentityCommand
2416
+ };
2417
+
2418
+ class STS extends STSClient {
2419
+ }
2420
+ createAggregatedClient(commands, STS);
2421
+ var getAccountIdFromAssumedRoleUser = (assumedRoleUser) => {
2422
+ if (typeof assumedRoleUser?.Arn === "string") {
2423
+ const arnComponents = assumedRoleUser.Arn.split(":");
2424
+ if (arnComponents.length > 4 && arnComponents[4] !== "") {
2425
+ return arnComponents[4];
2426
+ }
2427
+ }
2428
+ return;
2429
+ };
2430
+ var resolveRegion = async (_region, _parentRegion, credentialProviderLogger, loaderConfig = {}) => {
2431
+ const region = typeof _region === "function" ? await _region() : _region;
2432
+ const parentRegion = typeof _parentRegion === "function" ? await _parentRegion() : _parentRegion;
2433
+ let stsDefaultRegion = "";
2434
+ const resolvedRegion = region ?? parentRegion ?? (stsDefaultRegion = await stsRegionDefaultResolver(loaderConfig)());
2435
+ credentialProviderLogger?.debug?.("@aws-sdk/client-sts::resolveRegion", "accepting first of:", `${region} (credential provider clientConfig)`, `${parentRegion} (contextual client)`, `${stsDefaultRegion} (STS default: AWS_REGION, profile region, or us-east-1)`);
2436
+ return resolvedRegion;
2437
+ };
2438
+ var getDefaultRoleAssumer$1 = (stsOptions, STSClient2) => {
2439
+ let stsClient;
2440
+ let closureSourceCreds;
2441
+ return async (sourceCreds, params) => {
2442
+ closureSourceCreds = sourceCreds;
2443
+ if (!stsClient) {
2444
+ const { logger = stsOptions?.parentClientConfig?.logger, profile = stsOptions?.parentClientConfig?.profile, region, requestHandler = stsOptions?.parentClientConfig?.requestHandler, credentialProviderLogger, userAgentAppId = stsOptions?.parentClientConfig?.userAgentAppId } = stsOptions;
2445
+ const resolvedRegion = await resolveRegion(region, stsOptions?.parentClientConfig?.region, credentialProviderLogger, {
2446
+ logger,
2447
+ profile
2448
+ });
2449
+ const isCompatibleRequestHandler = !isH2(requestHandler);
2450
+ stsClient = new STSClient2({
2451
+ ...stsOptions,
2452
+ userAgentAppId,
2453
+ profile,
2454
+ credentialDefaultProvider: () => async () => closureSourceCreds,
2455
+ region: resolvedRegion,
2456
+ requestHandler: isCompatibleRequestHandler ? requestHandler : undefined,
2457
+ logger
2458
+ });
2459
+ }
2460
+ const { Credentials, AssumedRoleUser } = await stsClient.send(new AssumeRoleCommand(params));
2461
+ if (!Credentials || !Credentials.AccessKeyId || !Credentials.SecretAccessKey) {
2462
+ throw new Error(`Invalid response from STS.assumeRole call with role ${params.RoleArn}`);
2463
+ }
2464
+ const accountId = getAccountIdFromAssumedRoleUser(AssumedRoleUser);
2465
+ const credentials = {
2466
+ accessKeyId: Credentials.AccessKeyId,
2467
+ secretAccessKey: Credentials.SecretAccessKey,
2468
+ sessionToken: Credentials.SessionToken,
2469
+ expiration: Credentials.Expiration,
2470
+ ...Credentials.CredentialScope && { credentialScope: Credentials.CredentialScope },
2471
+ ...accountId && { accountId }
2472
+ };
2473
+ setCredentialFeature(credentials, "CREDENTIALS_STS_ASSUME_ROLE", "i");
2474
+ return credentials;
2475
+ };
2476
+ };
2477
+ var getDefaultRoleAssumerWithWebIdentity$1 = (stsOptions, STSClient2) => {
2478
+ let stsClient;
2479
+ return async (params) => {
2480
+ if (!stsClient) {
2481
+ const { logger = stsOptions?.parentClientConfig?.logger, profile = stsOptions?.parentClientConfig?.profile, region, requestHandler = stsOptions?.parentClientConfig?.requestHandler, credentialProviderLogger, userAgentAppId = stsOptions?.parentClientConfig?.userAgentAppId } = stsOptions;
2482
+ const resolvedRegion = await resolveRegion(region, stsOptions?.parentClientConfig?.region, credentialProviderLogger, {
2483
+ logger,
2484
+ profile
2485
+ });
2486
+ const isCompatibleRequestHandler = !isH2(requestHandler);
2487
+ stsClient = new STSClient2({
2488
+ ...stsOptions,
2489
+ userAgentAppId,
2490
+ profile,
2491
+ region: resolvedRegion,
2492
+ requestHandler: isCompatibleRequestHandler ? requestHandler : undefined,
2493
+ logger
2494
+ });
2495
+ }
2496
+ const { Credentials, AssumedRoleUser } = await stsClient.send(new AssumeRoleWithWebIdentityCommand(params));
2497
+ if (!Credentials || !Credentials.AccessKeyId || !Credentials.SecretAccessKey) {
2498
+ throw new Error(`Invalid response from STS.assumeRoleWithWebIdentity call with role ${params.RoleArn}`);
2499
+ }
2500
+ const accountId = getAccountIdFromAssumedRoleUser(AssumedRoleUser);
2501
+ const credentials = {
2502
+ accessKeyId: Credentials.AccessKeyId,
2503
+ secretAccessKey: Credentials.SecretAccessKey,
2504
+ sessionToken: Credentials.SessionToken,
2505
+ expiration: Credentials.Expiration,
2506
+ ...Credentials.CredentialScope && { credentialScope: Credentials.CredentialScope },
2507
+ ...accountId && { accountId }
2508
+ };
2509
+ if (accountId) {
2510
+ setCredentialFeature(credentials, "RESOLVED_ACCOUNT_ID", "T");
2511
+ }
2512
+ setCredentialFeature(credentials, "CREDENTIALS_STS_ASSUME_ROLE_WEB_ID", "k");
2513
+ return credentials;
2514
+ };
2515
+ };
2516
+ var isH2 = (requestHandler) => {
2517
+ return requestHandler?.metadata?.handlerProtocol === "h2";
2518
+ };
2519
+ var getCustomizableStsClientCtor = (baseCtor, customizations) => {
2520
+ if (!customizations)
2521
+ return baseCtor;
2522
+ else
2523
+ return class CustomizableSTSClient extends baseCtor {
2524
+ constructor(config) {
2525
+ super(config);
2526
+ for (const customization of customizations) {
2527
+ this.middlewareStack.use(customization);
2528
+ }
2529
+ }
2530
+ };
2531
+ };
2532
+ var getDefaultRoleAssumer = (stsOptions = {}, stsPlugins) => getDefaultRoleAssumer$1(stsOptions, getCustomizableStsClientCtor(STSClient, stsPlugins));
2533
+ var getDefaultRoleAssumerWithWebIdentity = (stsOptions = {}, stsPlugins) => getDefaultRoleAssumerWithWebIdentity$1(stsOptions, getCustomizableStsClientCtor(STSClient, stsPlugins));
2534
+ var decorateDefaultCredentialProvider = (provider) => (input) => provider({
2535
+ roleAssumer: getDefaultRoleAssumer(input),
2536
+ roleAssumerWithWebIdentity: getDefaultRoleAssumerWithWebIdentity(input),
2537
+ ...input
2538
+ });
2539
+ exports.AssumeRole$ = AssumeRole$;
2540
+ exports.AssumeRoleCommand = AssumeRoleCommand;
2541
+ exports.AssumeRoleRequest$ = AssumeRoleRequest$;
2542
+ exports.AssumeRoleResponse$ = AssumeRoleResponse$;
2543
+ exports.AssumeRoleWithWebIdentity$ = AssumeRoleWithWebIdentity$;
2544
+ exports.AssumeRoleWithWebIdentityCommand = AssumeRoleWithWebIdentityCommand;
2545
+ exports.AssumeRoleWithWebIdentityRequest$ = AssumeRoleWithWebIdentityRequest$;
2546
+ exports.AssumeRoleWithWebIdentityResponse$ = AssumeRoleWithWebIdentityResponse$;
2547
+ exports.AssumedRoleUser$ = AssumedRoleUser$;
2548
+ exports.Credentials$ = Credentials$;
2549
+ exports.ExpiredTokenException = ExpiredTokenException;
2550
+ exports.ExpiredTokenException$ = ExpiredTokenException$;
2551
+ exports.IDPCommunicationErrorException = IDPCommunicationErrorException;
2552
+ exports.IDPCommunicationErrorException$ = IDPCommunicationErrorException$;
2553
+ exports.IDPRejectedClaimException = IDPRejectedClaimException;
2554
+ exports.IDPRejectedClaimException$ = IDPRejectedClaimException$;
2555
+ exports.InvalidIdentityTokenException = InvalidIdentityTokenException;
2556
+ exports.InvalidIdentityTokenException$ = InvalidIdentityTokenException$;
2557
+ exports.MalformedPolicyDocumentException = MalformedPolicyDocumentException;
2558
+ exports.MalformedPolicyDocumentException$ = MalformedPolicyDocumentException$;
2559
+ exports.PackedPolicyTooLargeException = PackedPolicyTooLargeException;
2560
+ exports.PackedPolicyTooLargeException$ = PackedPolicyTooLargeException$;
2561
+ exports.PolicyDescriptorType$ = PolicyDescriptorType$;
2562
+ exports.ProvidedContext$ = ProvidedContext$;
2563
+ exports.RegionDisabledException = RegionDisabledException;
2564
+ exports.RegionDisabledException$ = RegionDisabledException$;
2565
+ exports.STS = STS;
2566
+ exports.STSClient = STSClient;
2567
+ exports.STSServiceException = STSServiceException;
2568
+ exports.STSServiceException$ = STSServiceException$;
2569
+ exports.Tag$ = Tag$;
2570
+ exports.decorateDefaultCredentialProvider = decorateDefaultCredentialProvider;
2571
+ exports.errorTypeRegistries = errorTypeRegistries;
2572
+ exports.getDefaultRoleAssumer = getDefaultRoleAssumer;
2573
+ exports.getDefaultRoleAssumerWithWebIdentity = getDefaultRoleAssumerWithWebIdentity;
2574
+ });
2575
+
2576
+ // node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js
2577
+ var require_signin = __commonJS(function(exports) {
2578
+ var { awsEndpointFunctions, emitWarningIfUnsupportedVersion: emitWarningIfUnsupportedVersion$1, createDefaultUserAgentProvider, NODE_APP_ID_CONFIG_OPTIONS, getAwsRegionExtensionConfiguration, resolveAwsRegionExtensionConfiguration, resolveUserAgentConfig, resolveHostHeaderConfig, getUserAgentPlugin, getHostHeaderPlugin, getLoggerPlugin, getRecursionDetectionPlugin } = require_client2();
2579
+ var { NoAuthSigner, getHttpAuthSchemeEndpointRuleSetPlugin, DefaultIdentityProviderConfig, getHttpSigningPlugin } = require_dist_cjs();
2580
+ var { normalizeProvider, getSmithyContext, ServiceException, NoOpLogger, emitWarningIfUnsupportedVersion, loadConfigsForDefaultMode, getDefaultExtensionConfiguration, resolveDefaultRuntimeConfig, Client, makeBuilder, createAggregatedClient } = require_client();
2581
+ var { Command: $Command } = require_client();
2582
+ exports.$Command = $Command;
2583
+ exports.__Client = Client;
2584
+ var { resolveDefaultsModeConfig, loadConfig, NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS, NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS, NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS, resolveRegionConfig } = require_config();
2585
+ var { BinaryDecisionDiagram, EndpointCache, decideEndpoint, customEndpointFunctions, resolveEndpointConfig, getEndpointPlugin } = require_endpoints();
2586
+ var { parseUrl, getHttpHandlerExtensionConfiguration, resolveHttpHandlerRuntimeConfig, getContentLengthPlugin } = require_protocols();
2587
+ var { DEFAULT_RETRY_MODE, NODE_RETRY_MODE_CONFIG_OPTIONS, NODE_MAX_ATTEMPT_CONFIG_OPTIONS, resolveRetryConfig, getRetryPlugin } = require_retry();
2588
+ var { TypeRegistry, getSchemaSerdePlugin } = require_schema();
2589
+ var { resolveAwsSdkSigV4Config, AwsSdkSigV4Signer, NODE_AUTH_SCHEME_PREFERENCE_OPTIONS } = require_httpAuthSchemes();
2590
+ var { toUtf8, fromUtf8, toBase64, fromBase64, calculateBodyLength } = require_serde();
2591
+ var { streamCollector, NodeHttpHandler } = require_dist_cjs3();
2592
+ var { AwsRestJsonProtocol } = require_protocols2();
2593
+ var { Sha256 } = require_checksum();
2594
+ var defaultSigninHttpAuthSchemeParametersProvider = async (config, context, input) => {
2595
+ return {
2596
+ operation: getSmithyContext(context).operation,
2597
+ region: await normalizeProvider(config.region)() || (() => {
2598
+ throw new Error("expected `region` to be configured for `aws.auth#sigv4`");
2599
+ })()
2600
+ };
2601
+ };
2602
+ function createAwsAuthSigv4HttpAuthOption(authParameters) {
2603
+ return {
2604
+ schemeId: "aws.auth#sigv4",
2605
+ signingProperties: {
2606
+ name: "signin",
2607
+ region: authParameters.region
2608
+ },
2609
+ propertiesExtractor: (config, context) => ({
2610
+ signingProperties: {
2611
+ config,
2612
+ context
2613
+ }
2614
+ })
2615
+ };
2616
+ }
2617
+ function createSmithyApiNoAuthHttpAuthOption(authParameters) {
2618
+ return {
2619
+ schemeId: "smithy.api#noAuth"
2620
+ };
2621
+ }
2622
+ var defaultSigninHttpAuthSchemeProvider = (authParameters) => {
2623
+ const options = [];
2624
+ switch (authParameters.operation) {
2625
+ case "CreateOAuth2Token": {
2626
+ options.push(createSmithyApiNoAuthHttpAuthOption());
2627
+ break;
2628
+ }
2629
+ default: {
2630
+ options.push(createAwsAuthSigv4HttpAuthOption(authParameters));
2631
+ }
2632
+ }
2633
+ return options;
2634
+ };
2635
+ var resolveHttpAuthSchemeConfig = (config) => {
2636
+ const config_0 = resolveAwsSdkSigV4Config(config);
2637
+ return Object.assign(config_0, {
2638
+ authSchemePreference: normalizeProvider(config.authSchemePreference ?? [])
2639
+ });
2640
+ };
2641
+ var resolveClientEndpointParameters = (options) => {
2642
+ return Object.assign(options, {
2643
+ useDualstackEndpoint: options.useDualstackEndpoint ?? false,
2644
+ useFipsEndpoint: options.useFipsEndpoint ?? false,
2645
+ defaultSigningName: "signin"
2646
+ });
2647
+ };
2648
+ var commonParams = {
2649
+ UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" },
2650
+ Endpoint: { type: "builtInParams", name: "endpoint" },
2651
+ Region: { type: "builtInParams", name: "region" },
2652
+ UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }
2653
+ };
2654
+ var version = "3.997.45";
2655
+ var packageInfo = {
2656
+ version
2657
+ };
2658
+ var s = "ref";
2659
+ var a = -1;
2660
+ var b = false;
2661
+ var c = true;
2662
+ var d = "isSet";
2663
+ var e = "booleanEquals";
2664
+ var f = "coalesce";
2665
+ var g = "PartitionResult";
2666
+ var h = "stringEquals";
2667
+ var i = "getAttr";
2668
+ var j = "https://signin.{Region}.{PartitionResult#dualStackDnsSuffix}";
2669
+ var k = { [s]: "Endpoint" };
2670
+ var l = { fn: i, argv: [{ [s]: g }, "name"] };
2671
+ var m = { [s]: "Region" };
2672
+ var n = { [s]: g };
2673
+ var o = { authSchemes: [{ name: "sigv4", signingName: "signin", signingRegion: "{Region}" }] };
2674
+ var p = {};
2675
+ var q = [m];
2676
+ var _data = {
2677
+ conditions: [
2678
+ [d, q],
2679
+ [e, [{ fn: f, argv: [{ [s]: "IsControlPlane" }, b] }, c]],
2680
+ [d, [k]],
2681
+ ["aws.partition", q, g],
2682
+ [e, [{ [s]: "UseFIPS" }, c]],
2683
+ [h, [l, "aws"]],
2684
+ [e, [{ fn: f, argv: [{ [s]: "IsOAuthEndpoint" }, b] }, c]],
2685
+ [e, [{ [s]: "UseDualStack" }, c]],
2686
+ [h, [l, "aws-cn"]],
2687
+ [h, [m, "us-gov-west-1"]],
2688
+ [h, [l, "aws-us-gov"]],
2689
+ [e, [{ fn: i, argv: [n, "supportsFIPS"] }, c]],
2690
+ [h, [l, "aws-iso"]],
2691
+ [h, [l, "aws-iso-b"]],
2692
+ [h, [l, "aws-iso-f"]],
2693
+ [h, [l, "aws-iso-e"]],
2694
+ [h, [l, "aws-eusc"]],
2695
+ [e, [{ fn: i, argv: [n, "supportsDualStack"] }, c]]
2696
+ ],
2697
+ results: [
2698
+ [a],
2699
+ ["https://signin.{Region}.api.aws", o],
2700
+ ["https://signin.{Region}.api.amazonwebservices.com.cn", o],
2701
+ [j, o],
2702
+ [a, "FIPS endpoints are not supported for OAuth operations. Disable FIPS or use a non-OAuth operation."],
2703
+ ["https://{Region}.oauth.signin.aws", o],
2704
+ ["https://{Region}.signin.aws.amazon.com", p],
2705
+ ["https://{Region}.signin.amazonaws.cn", p],
2706
+ ["https://{Region}.signin.amazonaws-us-gov.com", p],
2707
+ ["https://{Region}.signin.c2shome.ic.gov", p],
2708
+ ["https://{Region}.signin.sc2shome.sgov.gov", p],
2709
+ ["https://{Region}.signin.csphome.hci.ic.gov", p],
2710
+ ["https://{Region}.signin.csphome.adc-e.uk", p],
2711
+ ["https://{Region}.signin.amazonaws-eusc.eu", p],
2712
+ ["https://signin-fips.amazonaws-us-gov.com", p],
2713
+ ["https://{Region}.signin-fips.amazonaws-us-gov.com", p],
2714
+ ["https://{Region}.signin.{PartitionResult#dnsSuffix}", p],
2715
+ [a, "Invalid Configuration: FIPS and custom endpoint are not supported"],
2716
+ [a, "Invalid Configuration: Dualstack and custom endpoint are not supported"],
2717
+ [k, p],
2718
+ ["https://signin-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", p],
2719
+ [a, "FIPS and DualStack are enabled, but this partition does not support one or both"],
2720
+ ["https://signin-fips.{Region}.{PartitionResult#dnsSuffix}", p],
2721
+ [a, "FIPS is enabled but this partition does not support FIPS"],
2722
+ [j, p],
2723
+ [a, "DualStack is enabled but this partition does not support DualStack"],
2724
+ ["https://signin.{Region}.{PartitionResult#dnsSuffix}", p],
2725
+ [a, "Invalid Configuration: Missing Region"]
2726
+ ]
2727
+ };
2728
+ var root = 2;
2729
+ var r = 1e8;
2730
+ var nodes = new Int32Array([
2731
+ -1,
2732
+ 1,
2733
+ -1,
2734
+ 0,
2735
+ 6,
2736
+ 3,
2737
+ 2,
2738
+ 36,
2739
+ 4,
2740
+ 4,
2741
+ 5,
2742
+ r + 27,
2743
+ 6,
2744
+ r + 4,
2745
+ r + 27,
2746
+ 1,
2747
+ 29,
2748
+ 7,
2749
+ 2,
2750
+ 36,
2751
+ 8,
2752
+ 3,
2753
+ 9,
2754
+ 31,
2755
+ 4,
2756
+ 22,
2757
+ 10,
2758
+ 5,
2759
+ 19,
2760
+ 11,
2761
+ 7,
2762
+ 21,
2763
+ 12,
2764
+ 8,
2765
+ r + 7,
2766
+ 13,
2767
+ 10,
2768
+ r + 8,
2769
+ 14,
2770
+ 12,
2771
+ r + 9,
2772
+ 15,
2773
+ 13,
2774
+ r + 10,
2775
+ 16,
2776
+ 14,
2777
+ r + 11,
2778
+ 17,
2779
+ 15,
2780
+ r + 12,
2781
+ 18,
2782
+ 16,
2783
+ r + 13,
2784
+ r + 16,
2785
+ 6,
2786
+ r + 5,
2787
+ 20,
2788
+ 7,
2789
+ 21,
2790
+ r + 6,
2791
+ 17,
2792
+ r + 24,
2793
+ r + 25,
2794
+ 6,
2795
+ r + 4,
2796
+ 23,
2797
+ 7,
2798
+ 27,
2799
+ 24,
2800
+ 9,
2801
+ r + 14,
2802
+ 25,
2803
+ 10,
2804
+ r + 15,
2805
+ 26,
2806
+ 11,
2807
+ r + 22,
2808
+ r + 23,
2809
+ 11,
2810
+ 28,
2811
+ r + 21,
2812
+ 17,
2813
+ r + 20,
2814
+ r + 21,
2815
+ 2,
2816
+ 35,
2817
+ 30,
2818
+ 3,
2819
+ 39,
2820
+ 31,
2821
+ 4,
2822
+ 32,
2823
+ r + 27,
2824
+ 6,
2825
+ r + 4,
2826
+ 33,
2827
+ 7,
2828
+ r + 27,
2829
+ 34,
2830
+ 9,
2831
+ r + 14,
2832
+ r + 27,
2833
+ 3,
2834
+ 39,
2835
+ 36,
2836
+ 4,
2837
+ 38,
2838
+ 37,
2839
+ 7,
2840
+ r + 18,
2841
+ r + 19,
2842
+ 6,
2843
+ r + 4,
2844
+ r + 17,
2845
+ 5,
2846
+ r + 1,
2847
+ 40,
2848
+ 8,
2849
+ r + 2,
2850
+ r + 3
2851
+ ]);
2852
+ var bdd = BinaryDecisionDiagram.from(nodes, root, _data.conditions, _data.results);
2853
+ var cache = new EndpointCache({
2854
+ size: 50,
2855
+ params: ["Endpoint", "IsControlPlane", "IsOAuthEndpoint", "Region", "UseDualStack", "UseFIPS"]
2856
+ });
2857
+ var defaultEndpointResolver = (endpointParams, context = {}) => {
2858
+ return cache.get(endpointParams, () => decideEndpoint(bdd, {
2859
+ endpointParams,
2860
+ logger: context.logger
2861
+ }));
2862
+ };
2863
+ customEndpointFunctions.aws = awsEndpointFunctions;
2864
+
2865
+ class SigninServiceException extends ServiceException {
2866
+ constructor(options) {
2867
+ super(options);
2868
+ Object.setPrototypeOf(this, SigninServiceException.prototype);
2869
+ }
2870
+ }
2871
+
2872
+ class AccessDeniedException extends SigninServiceException {
2873
+ name = "AccessDeniedException";
2874
+ $fault = "client";
2875
+ error;
2876
+ constructor(opts) {
2877
+ super({
2878
+ name: "AccessDeniedException",
2879
+ $fault: "client",
2880
+ ...opts
2881
+ });
2882
+ Object.setPrototypeOf(this, AccessDeniedException.prototype);
2883
+ this.error = opts.error;
2884
+ }
2885
+ }
2886
+
2887
+ class InternalServerException extends SigninServiceException {
2888
+ name = "InternalServerException";
2889
+ $fault = "server";
2890
+ error;
2891
+ constructor(opts) {
2892
+ super({
2893
+ name: "InternalServerException",
2894
+ $fault: "server",
2895
+ ...opts
2896
+ });
2897
+ Object.setPrototypeOf(this, InternalServerException.prototype);
2898
+ this.error = opts.error;
2899
+ }
2900
+ }
2901
+
2902
+ class TooManyRequestsError extends SigninServiceException {
2903
+ name = "TooManyRequestsError";
2904
+ $fault = "client";
2905
+ error;
2906
+ constructor(opts) {
2907
+ super({
2908
+ name: "TooManyRequestsError",
2909
+ $fault: "client",
2910
+ ...opts
2911
+ });
2912
+ Object.setPrototypeOf(this, TooManyRequestsError.prototype);
2913
+ this.error = opts.error;
2914
+ }
2915
+ }
2916
+
2917
+ class ValidationException extends SigninServiceException {
2918
+ name = "ValidationException";
2919
+ $fault = "client";
2920
+ error;
2921
+ constructor(opts) {
2922
+ super({
2923
+ name: "ValidationException",
2924
+ $fault: "client",
2925
+ ...opts
2926
+ });
2927
+ Object.setPrototypeOf(this, ValidationException.prototype);
2928
+ this.error = opts.error;
2929
+ }
2930
+ }
2931
+ var _ADE = "AccessDeniedException";
2932
+ var _AT = "AccessToken";
2933
+ var _COAT = "CreateOAuth2Token";
2934
+ var _COATR = "CreateOAuth2TokenRequest";
2935
+ var _COATRB = "CreateOAuth2TokenRequestBody";
2936
+ var _COATRBr = "CreateOAuth2TokenResponseBody";
2937
+ var _COATRr = "CreateOAuth2TokenResponse";
2938
+ var _COATWIAM = "CreateOAuth2TokenWithIAM";
2939
+ var _COATWIAMR = "CreateOAuth2TokenWithIAMRequest";
2940
+ var _COATWIAMRr = "CreateOAuth2TokenWithIAMResponse";
2941
+ var _ISE = "InternalServerException";
2942
+ var _OAAT = "OAuthAccessToken";
2943
+ var _RT = "RefreshToken";
2944
+ var _TMRE = "TooManyRequestsError";
2945
+ var _VE = "ValidationException";
2946
+ var _aKI = "accessKeyId";
2947
+ var _aT = "accessToken";
2948
+ var _at = "access_token";
2949
+ var _c = "client";
2950
+ var _cI = "clientId";
2951
+ var _cV = "codeVerifier";
2952
+ var _co = "code";
2953
+ var _e = "error";
2954
+ var _eI = "expiresIn";
2955
+ var _ei = "expires_in";
2956
+ var _gT = "grantType";
2957
+ var _gt = "grant_type";
2958
+ var _h = "http";
2959
+ var _hE = "httpError";
2960
+ var _iT = "idToken";
2961
+ var _jN = "jsonName";
2962
+ var _m = "message";
2963
+ var _r = "resource";
2964
+ var _rT = "refreshToken";
2965
+ var _rU = "redirectUri";
2966
+ var _s = "smithy.ts.sdk.synthetic.com.amazonaws.signin";
2967
+ var _sAK = "secretAccessKey";
2968
+ var _sT = "sessionToken";
2969
+ var _se = "server";
2970
+ var _tI = "tokenInput";
2971
+ var _tO = "tokenOutput";
2972
+ var _tT = "tokenType";
2973
+ var _tt = "token_type";
2974
+ var n0 = "com.amazonaws.signin";
2975
+ var _s_registry = new TypeRegistry(_s);
2976
+ var SigninServiceException$ = [-3, _s, "SigninServiceException", 0, [], []];
2977
+ _s_registry.registerError(SigninServiceException$, SigninServiceException);
2978
+ var n0_registry = new TypeRegistry(n0);
2979
+ var AccessDeniedException$ = [
2980
+ -3,
2981
+ n0,
2982
+ _ADE,
2983
+ { [_e]: _c },
2984
+ [_e, _m],
2985
+ [0, 0],
2986
+ 2
2987
+ ];
2988
+ n0_registry.registerError(AccessDeniedException$, AccessDeniedException);
2989
+ var InternalServerException$ = [
2990
+ -3,
2991
+ n0,
2992
+ _ISE,
2993
+ { [_e]: _se, [_hE]: 500 },
2994
+ [_e, _m],
2995
+ [0, 0],
2996
+ 2
2997
+ ];
2998
+ n0_registry.registerError(InternalServerException$, InternalServerException);
2999
+ var TooManyRequestsError$ = [
3000
+ -3,
3001
+ n0,
3002
+ _TMRE,
3003
+ { [_e]: _c, [_hE]: 429 },
3004
+ [_e, _m],
3005
+ [0, 0],
3006
+ 2
3007
+ ];
3008
+ n0_registry.registerError(TooManyRequestsError$, TooManyRequestsError);
3009
+ var ValidationException$ = [
3010
+ -3,
3011
+ n0,
3012
+ _VE,
3013
+ { [_e]: _c, [_hE]: 400 },
3014
+ [_e, _m],
3015
+ [0, 0],
3016
+ 2
3017
+ ];
3018
+ n0_registry.registerError(ValidationException$, ValidationException);
3019
+ var errorTypeRegistries = [
3020
+ _s_registry,
3021
+ n0_registry
3022
+ ];
3023
+ var OAuthAccessToken = [0, n0, _OAAT, 8, 0];
3024
+ var RefreshToken = [0, n0, _RT, 8, 0];
3025
+ var AccessToken$ = [
3026
+ 3,
3027
+ n0,
3028
+ _AT,
3029
+ 8,
3030
+ [_aKI, _sAK, _sT],
3031
+ [[0, { [_jN]: _aKI }], [0, { [_jN]: _sAK }], [0, { [_jN]: _sT }]],
3032
+ 3
3033
+ ];
3034
+ var CreateOAuth2TokenRequest$ = [
3035
+ 3,
3036
+ n0,
3037
+ _COATR,
3038
+ 0,
3039
+ [_tI],
3040
+ [[() => CreateOAuth2TokenRequestBody$, 16]],
3041
+ 1
3042
+ ];
3043
+ var CreateOAuth2TokenRequestBody$ = [
3044
+ 3,
3045
+ n0,
3046
+ _COATRB,
3047
+ 0,
3048
+ [_cI, _gT, _co, _rU, _cV, _rT],
3049
+ [[0, { [_jN]: _cI }], [0, { [_jN]: _gT }], 0, [0, { [_jN]: _rU }], [0, { [_jN]: _cV }], [() => RefreshToken, { [_jN]: _rT }]],
3050
+ 2
3051
+ ];
3052
+ var CreateOAuth2TokenResponse$ = [
3053
+ 3,
3054
+ n0,
3055
+ _COATRr,
3056
+ 0,
3057
+ [_tO],
3058
+ [[() => CreateOAuth2TokenResponseBody$, 16]],
3059
+ 1
3060
+ ];
3061
+ var CreateOAuth2TokenResponseBody$ = [
3062
+ 3,
3063
+ n0,
3064
+ _COATRBr,
3065
+ 0,
3066
+ [_aT, _tT, _eI, _rT, _iT],
3067
+ [[() => AccessToken$, { [_jN]: _aT }], [0, { [_jN]: _tT }], [1, { [_jN]: _eI }], [() => RefreshToken, { [_jN]: _rT }], [0, { [_jN]: _iT }]],
3068
+ 4
3069
+ ];
3070
+ var CreateOAuth2TokenWithIAMRequest$ = [
3071
+ 3,
3072
+ n0,
3073
+ _COATWIAMR,
3074
+ 0,
3075
+ [_gT, _r],
3076
+ [[0, { [_jN]: _gt }], 0],
3077
+ 2
3078
+ ];
3079
+ var CreateOAuth2TokenWithIAMResponse$ = [
3080
+ 3,
3081
+ n0,
3082
+ _COATWIAMRr,
3083
+ 0,
3084
+ [_aT, _tT, _eI],
3085
+ [[() => OAuthAccessToken, { [_jN]: _at }], [0, { [_jN]: _tt }], [1, { [_jN]: _ei }]],
3086
+ 3
3087
+ ];
3088
+ var CreateOAuth2Token$ = [
3089
+ 9,
3090
+ n0,
3091
+ _COAT,
3092
+ { [_h]: ["POST", "/v1/token", 200] },
3093
+ () => CreateOAuth2TokenRequest$,
3094
+ () => CreateOAuth2TokenResponse$
3095
+ ];
3096
+ var CreateOAuth2TokenWithIAM$ = [
3097
+ 9,
3098
+ n0,
3099
+ _COATWIAM,
3100
+ { [_h]: ["POST", "/v1/token?x-amz-client-auth-method=iam", 200] },
3101
+ () => CreateOAuth2TokenWithIAMRequest$,
3102
+ () => CreateOAuth2TokenWithIAMResponse$
3103
+ ];
3104
+ var getRuntimeConfig$1 = (config) => {
3105
+ return {
3106
+ apiVersion: "2023-01-01",
3107
+ base64Decoder: config?.base64Decoder ?? fromBase64,
3108
+ base64Encoder: config?.base64Encoder ?? toBase64,
3109
+ disableHostPrefix: config?.disableHostPrefix ?? false,
3110
+ endpointProvider: config?.endpointProvider ?? defaultEndpointResolver,
3111
+ extensions: config?.extensions ?? [],
3112
+ httpAuthSchemeProvider: config?.httpAuthSchemeProvider ?? defaultSigninHttpAuthSchemeProvider,
3113
+ httpAuthSchemes: config?.httpAuthSchemes ?? [
3114
+ {
3115
+ schemeId: "aws.auth#sigv4",
3116
+ identityProvider: (ipc) => ipc.getIdentityProvider("aws.auth#sigv4"),
3117
+ signer: new AwsSdkSigV4Signer
3118
+ },
3119
+ {
3120
+ schemeId: "smithy.api#noAuth",
3121
+ identityProvider: (ipc) => ipc.getIdentityProvider("smithy.api#noAuth") || (async () => ({})),
3122
+ signer: new NoAuthSigner
3123
+ }
3124
+ ],
3125
+ logger: config?.logger ?? new NoOpLogger,
3126
+ protocol: config?.protocol ?? AwsRestJsonProtocol,
3127
+ protocolSettings: config?.protocolSettings ?? {
3128
+ defaultNamespace: "com.amazonaws.signin",
3129
+ errorTypeRegistries,
3130
+ version: "2023-01-01",
3131
+ serviceTarget: "Signin"
3132
+ },
3133
+ serviceId: config?.serviceId ?? "Signin",
3134
+ sha256: config?.sha256 ?? Sha256,
3135
+ urlParser: config?.urlParser ?? parseUrl,
3136
+ utf8Decoder: config?.utf8Decoder ?? fromUtf8,
3137
+ utf8Encoder: config?.utf8Encoder ?? toUtf8
3138
+ };
3139
+ };
3140
+ var getRuntimeConfig = (config) => {
3141
+ emitWarningIfUnsupportedVersion(process.version);
3142
+ const defaultsMode = resolveDefaultsModeConfig(config);
3143
+ const defaultConfigProvider = () => defaultsMode().then(loadConfigsForDefaultMode);
3144
+ const clientSharedValues = getRuntimeConfig$1(config);
3145
+ emitWarningIfUnsupportedVersion$1(process.version);
3146
+ const loaderConfig = {
3147
+ profile: config?.profile,
3148
+ logger: clientSharedValues.logger
3149
+ };
3150
+ return {
3151
+ ...clientSharedValues,
3152
+ ...config,
3153
+ runtime: "node",
3154
+ defaultsMode,
3155
+ authSchemePreference: config?.authSchemePreference ?? loadConfig(NODE_AUTH_SCHEME_PREFERENCE_OPTIONS, loaderConfig),
3156
+ bodyLengthChecker: config?.bodyLengthChecker ?? calculateBodyLength,
3157
+ defaultUserAgentProvider: config?.defaultUserAgentProvider ?? createDefaultUserAgentProvider({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }),
3158
+ maxAttempts: config?.maxAttempts ?? loadConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS, config),
3159
+ region: config?.region ?? loadConfig(NODE_REGION_CONFIG_OPTIONS, { ...NODE_REGION_CONFIG_FILE_OPTIONS, ...loaderConfig }),
3160
+ requestHandler: NodeHttpHandler.create(config?.requestHandler ?? defaultConfigProvider),
3161
+ retryMode: config?.retryMode ?? loadConfig({
3162
+ ...NODE_RETRY_MODE_CONFIG_OPTIONS,
3163
+ default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE
3164
+ }, config),
3165
+ streamCollector: config?.streamCollector ?? streamCollector,
3166
+ useDualstackEndpoint: config?.useDualstackEndpoint ?? loadConfig(NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS, loaderConfig),
3167
+ useFipsEndpoint: config?.useFipsEndpoint ?? loadConfig(NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS, loaderConfig),
3168
+ userAgentAppId: config?.userAgentAppId ?? loadConfig(NODE_APP_ID_CONFIG_OPTIONS, loaderConfig)
3169
+ };
3170
+ };
3171
+ var getHttpAuthExtensionConfiguration = (runtimeConfig) => {
3172
+ const _httpAuthSchemes = runtimeConfig.httpAuthSchemes;
3173
+ let _httpAuthSchemeProvider = runtimeConfig.httpAuthSchemeProvider;
3174
+ let _credentials = runtimeConfig.credentials;
3175
+ return {
3176
+ setHttpAuthScheme(httpAuthScheme) {
3177
+ const index = _httpAuthSchemes.findIndex((scheme) => scheme.schemeId === httpAuthScheme.schemeId);
3178
+ if (index === -1) {
3179
+ _httpAuthSchemes.push(httpAuthScheme);
3180
+ } else {
3181
+ _httpAuthSchemes.splice(index, 1, httpAuthScheme);
3182
+ }
3183
+ },
3184
+ httpAuthSchemes() {
3185
+ return _httpAuthSchemes;
3186
+ },
3187
+ setHttpAuthSchemeProvider(httpAuthSchemeProvider) {
3188
+ _httpAuthSchemeProvider = httpAuthSchemeProvider;
3189
+ },
3190
+ httpAuthSchemeProvider() {
3191
+ return _httpAuthSchemeProvider;
3192
+ },
3193
+ setCredentials(credentials) {
3194
+ _credentials = credentials;
3195
+ },
3196
+ credentials() {
3197
+ return _credentials;
3198
+ }
3199
+ };
3200
+ };
3201
+ var resolveHttpAuthRuntimeConfig = (config) => {
3202
+ return {
3203
+ httpAuthSchemes: config.httpAuthSchemes(),
3204
+ httpAuthSchemeProvider: config.httpAuthSchemeProvider(),
3205
+ credentials: config.credentials()
3206
+ };
3207
+ };
3208
+ var resolveRuntimeExtensions = (runtimeConfig, extensions) => {
3209
+ const extensionConfiguration = Object.assign(getAwsRegionExtensionConfiguration(runtimeConfig), getDefaultExtensionConfiguration(runtimeConfig), getHttpHandlerExtensionConfiguration(runtimeConfig), getHttpAuthExtensionConfiguration(runtimeConfig));
3210
+ extensions.forEach((extension) => extension.configure(extensionConfiguration));
3211
+ return Object.assign(runtimeConfig, resolveAwsRegionExtensionConfiguration(extensionConfiguration), resolveDefaultRuntimeConfig(extensionConfiguration), resolveHttpHandlerRuntimeConfig(extensionConfiguration), resolveHttpAuthRuntimeConfig(extensionConfiguration));
3212
+ };
3213
+
3214
+ class SigninClient extends Client {
3215
+ config;
3216
+ constructor(...[configuration]) {
3217
+ const _config_0 = getRuntimeConfig(configuration || {});
3218
+ super(_config_0);
3219
+ this.initConfig = _config_0;
3220
+ const _config_1 = resolveClientEndpointParameters(_config_0);
3221
+ const _config_2 = resolveUserAgentConfig(_config_1);
3222
+ const _config_3 = resolveRetryConfig(_config_2);
3223
+ const _config_4 = resolveRegionConfig(_config_3);
3224
+ const _config_5 = resolveHostHeaderConfig(_config_4);
3225
+ const _config_6 = resolveEndpointConfig(_config_5);
3226
+ const _config_7 = resolveHttpAuthSchemeConfig(_config_6);
3227
+ const _config_8 = resolveRuntimeExtensions(_config_7, configuration?.extensions || []);
3228
+ this.config = _config_8;
3229
+ this.middlewareStack.use(getSchemaSerdePlugin(this.config));
3230
+ this.middlewareStack.use(getUserAgentPlugin(this.config));
3231
+ this.middlewareStack.use(getRetryPlugin(this.config));
3232
+ this.middlewareStack.use(getContentLengthPlugin(this.config));
3233
+ this.middlewareStack.use(getHostHeaderPlugin(this.config));
3234
+ this.middlewareStack.use(getLoggerPlugin(this.config));
3235
+ this.middlewareStack.use(getRecursionDetectionPlugin(this.config));
3236
+ this.middlewareStack.use(getHttpAuthSchemeEndpointRuleSetPlugin(this.config, {
3237
+ httpAuthSchemeParametersProvider: defaultSigninHttpAuthSchemeParametersProvider,
3238
+ identityProviderConfigProvider: async (config) => new DefaultIdentityProviderConfig({
3239
+ "aws.auth#sigv4": config.credentials
3240
+ })
3241
+ }));
3242
+ this.middlewareStack.use(getHttpSigningPlugin(this.config));
3243
+ }
3244
+ destroy() {
3245
+ super.destroy();
3246
+ }
3247
+ }
3248
+ var command = makeBuilder(commonParams, "Signin", "SigninClient", getEndpointPlugin);
3249
+ var _ep0 = {
3250
+ IsControlPlane: { type: "staticContextParams", value: false }
3251
+ };
3252
+ var _ep1 = {
3253
+ IsOAuthEndpoint: { type: "staticContextParams", value: true }
3254
+ };
3255
+ var _mw0 = (Command, cs, config, o2) => [];
3256
+
3257
+ class CreateOAuth2TokenCommand extends command(_ep0, _mw0, "CreateOAuth2Token", CreateOAuth2Token$) {
3258
+ }
3259
+
3260
+ class CreateOAuth2TokenWithIAMCommand extends command(_ep1, _mw0, "CreateOAuth2TokenWithIAM", CreateOAuth2TokenWithIAM$) {
3261
+ }
3262
+ var commands = {
3263
+ CreateOAuth2TokenCommand,
3264
+ CreateOAuth2TokenWithIAMCommand
3265
+ };
3266
+
3267
+ class Signin extends SigninClient {
3268
+ }
3269
+ createAggregatedClient(commands, Signin);
3270
+ var OAuth2ErrorCode = {
3271
+ AUTHCODE_EXPIRED: "AUTHCODE_EXPIRED",
3272
+ CONFLICT: "CONFLICT",
3273
+ INSUFFICIENT_PERMISSIONS: "INSUFFICIENT_PERMISSIONS",
3274
+ INVALID_REQUEST: "INVALID_REQUEST",
3275
+ RESOURCE_NOT_FOUND: "RESOURCE_NOT_FOUND",
3276
+ SERVER_ERROR: "server_error",
3277
+ SERVICE_QUOTA_EXCEEDED: "SERVICE_QUOTA_EXCEEDED",
3278
+ TOKEN_EXPIRED: "TOKEN_EXPIRED",
3279
+ USER_CREDENTIALS_CHANGED: "USER_CREDENTIALS_CHANGED"
3280
+ };
3281
+ exports.AccessDeniedException = AccessDeniedException;
3282
+ exports.AccessDeniedException$ = AccessDeniedException$;
3283
+ exports.AccessToken$ = AccessToken$;
3284
+ exports.CreateOAuth2Token$ = CreateOAuth2Token$;
3285
+ exports.CreateOAuth2TokenCommand = CreateOAuth2TokenCommand;
3286
+ exports.CreateOAuth2TokenRequest$ = CreateOAuth2TokenRequest$;
3287
+ exports.CreateOAuth2TokenRequestBody$ = CreateOAuth2TokenRequestBody$;
3288
+ exports.CreateOAuth2TokenResponse$ = CreateOAuth2TokenResponse$;
3289
+ exports.CreateOAuth2TokenResponseBody$ = CreateOAuth2TokenResponseBody$;
3290
+ exports.CreateOAuth2TokenWithIAM$ = CreateOAuth2TokenWithIAM$;
3291
+ exports.CreateOAuth2TokenWithIAMCommand = CreateOAuth2TokenWithIAMCommand;
3292
+ exports.CreateOAuth2TokenWithIAMRequest$ = CreateOAuth2TokenWithIAMRequest$;
3293
+ exports.CreateOAuth2TokenWithIAMResponse$ = CreateOAuth2TokenWithIAMResponse$;
3294
+ exports.InternalServerException = InternalServerException;
3295
+ exports.InternalServerException$ = InternalServerException$;
3296
+ exports.OAuth2ErrorCode = OAuth2ErrorCode;
3297
+ exports.Signin = Signin;
3298
+ exports.SigninClient = SigninClient;
3299
+ exports.SigninServiceException = SigninServiceException;
3300
+ exports.SigninServiceException$ = SigninServiceException$;
3301
+ exports.TooManyRequestsError = TooManyRequestsError;
3302
+ exports.TooManyRequestsError$ = TooManyRequestsError$;
3303
+ exports.ValidationException = ValidationException;
3304
+ exports.ValidationException$ = ValidationException$;
3305
+ exports.errorTypeRegistries = errorTypeRegistries;
3306
+ });
3307
+
3308
+ // node_modules/@aws-sdk/credential-provider-login/dist-cjs/index.js
3309
+ var require_dist_cjs10 = __commonJS(function(exports) {
3310
+ var { setCredentialFeature } = require_client2();
3311
+ var { CredentialsProviderError, parseKnownFiles, getProfileName } = require_config();
3312
+ var { HttpRequest } = require_protocols();
3313
+ var { createHash, createPrivateKey, createPublicKey, sign } = __require("node:crypto");
3314
+ var { promises } = __require("node:fs");
3315
+ var { homedir } = __require("node:os");
3316
+ var { dirname, join } = __require("node:path");
3317
+
3318
+ class LoginCredentialsFetcher {
3319
+ profileData;
3320
+ init;
3321
+ callerClientConfig;
3322
+ static REFRESH_THRESHOLD = 5 * 60 * 1000;
3323
+ constructor(profileData, init, callerClientConfig) {
3324
+ this.profileData = profileData;
3325
+ this.init = init;
3326
+ this.callerClientConfig = callerClientConfig;
3327
+ }
3328
+ async loadCredentials() {
3329
+ const token = await this.loadToken();
3330
+ if (!token) {
3331
+ throw new CredentialsProviderError(`Failed to load a token for session ${this.loginSession}, please re-authenticate using aws login`, { tryNextLink: false, logger: this.logger });
3332
+ }
3333
+ const accessToken = token.accessToken;
3334
+ const now = Date.now();
3335
+ const expiryTime = new Date(accessToken.expiresAt).getTime();
3336
+ const timeUntilExpiry = expiryTime - now;
3337
+ if (timeUntilExpiry <= LoginCredentialsFetcher.REFRESH_THRESHOLD) {
3338
+ return this.refresh(token);
3339
+ }
3340
+ return this.toCredentials(token.accessToken);
3341
+ }
3342
+ get logger() {
3343
+ return this.init?.logger;
3344
+ }
3345
+ get loginSession() {
3346
+ return this.profileData.login_session;
3347
+ }
3348
+ toCredentials(token) {
3349
+ return {
3350
+ accessKeyId: token.accessKeyId,
3351
+ secretAccessKey: token.secretAccessKey,
3352
+ sessionToken: token.sessionToken,
3353
+ accountId: token.accountId,
3354
+ expiration: new Date(token.expiresAt)
3355
+ };
3356
+ }
3357
+ async refresh(token) {
3358
+ const diskToken = await this.loadToken().catch(() => token);
3359
+ const now = Date.now();
3360
+ const diskExpiry = new Date(diskToken.accessToken.expiresAt).getTime();
3361
+ const tokenExpiry = new Date(token.accessToken.expiresAt).getTime();
3362
+ const freshToken = diskExpiry <= now && tokenExpiry > now ? token : diskToken;
3363
+ const freshExpiry = new Date(freshToken.accessToken.expiresAt).getTime();
3364
+ if (freshExpiry - Date.now() > LoginCredentialsFetcher.REFRESH_THRESHOLD) {
3365
+ return this.toCredentials(freshToken.accessToken);
3366
+ }
3367
+ const { SigninClient, CreateOAuth2TokenCommand } = require_signin();
3368
+ const { logger, userAgentAppId } = this.callerClientConfig ?? {};
3369
+ const isH2 = (requestHandler2) => {
3370
+ return requestHandler2?.metadata?.handlerProtocol === "h2";
3371
+ };
3372
+ const requestHandler = isH2(this.callerClientConfig?.requestHandler) ? undefined : this.callerClientConfig?.requestHandler;
3373
+ const region = this.profileData.region ?? await this.callerClientConfig?.region?.() ?? process.env.AWS_REGION;
3374
+ const client = new SigninClient({
3375
+ credentials: {
3376
+ accessKeyId: "",
3377
+ secretAccessKey: ""
3378
+ },
3379
+ region,
3380
+ requestHandler,
3381
+ logger,
3382
+ userAgentAppId,
3383
+ ...this.init?.clientConfig
3384
+ });
3385
+ this.createDPoPInterceptor(client.middlewareStack);
3386
+ const commandInput = {
3387
+ tokenInput: {
3388
+ clientId: freshToken.clientId,
3389
+ refreshToken: freshToken.refreshToken,
3390
+ grantType: "refresh_token"
3391
+ }
3392
+ };
3393
+ try {
3394
+ const response = await client.send(new CreateOAuth2TokenCommand(commandInput));
3395
+ const { accessKeyId, secretAccessKey, sessionToken } = response.tokenOutput?.accessToken ?? {};
3396
+ const { refreshToken, expiresIn } = response.tokenOutput ?? {};
3397
+ if (!accessKeyId || !secretAccessKey || !sessionToken || !refreshToken) {
3398
+ throw new CredentialsProviderError("Token refresh response missing required fields", {
3399
+ logger: this.logger,
3400
+ tryNextLink: false
3401
+ });
3402
+ }
3403
+ const expiresInMs = (expiresIn ?? 900) * 1000;
3404
+ const expiration = new Date(Date.now() + expiresInMs);
3405
+ const updatedToken = {
3406
+ ...freshToken,
3407
+ accessToken: {
3408
+ ...freshToken.accessToken,
3409
+ accessKeyId,
3410
+ secretAccessKey,
3411
+ sessionToken,
3412
+ expiresAt: expiration.toISOString()
3413
+ },
3414
+ refreshToken
3415
+ };
3416
+ await this.saveToken(updatedToken);
3417
+ return this.toCredentials(updatedToken.accessToken);
3418
+ } catch (error) {
3419
+ if (error.name === "AccessDeniedException") {
3420
+ const errorType = error.error;
3421
+ let message;
3422
+ switch (errorType) {
3423
+ case "TOKEN_EXPIRED":
3424
+ message = "Your session has expired. Please reauthenticate.";
3425
+ break;
3426
+ case "USER_CREDENTIALS_CHANGED":
3427
+ message = "Unable to refresh credentials because of a change in your password. Please reauthenticate with your new password.";
3428
+ break;
3429
+ case "INSUFFICIENT_PERMISSIONS":
3430
+ message = "Unable to refresh credentials due to insufficient permissions. You may be missing permission for the 'CreateOAuth2Token' action.";
3431
+ break;
3432
+ default:
3433
+ message = `Failed to refresh token: ${String(error)}. Please re-authenticate using \`aws login\``;
3434
+ }
3435
+ throw new CredentialsProviderError(message, {
3436
+ logger: this.logger,
3437
+ tryNextLink: false
3438
+ });
3439
+ }
3440
+ const tokenExpiry2 = new Date(freshToken.accessToken.expiresAt).getTime();
3441
+ if (tokenExpiry2 > Date.now()) {
3442
+ this.logger?.warn?.(`Failed to refresh token: ${String(error)}. Using existing token until expiry.`);
3443
+ return this.toCredentials(freshToken.accessToken);
3444
+ }
3445
+ throw new CredentialsProviderError(`Failed to refresh token: ${String(error)}. Please re-authenticate using aws login`, { logger: this.logger });
3446
+ }
3447
+ }
3448
+ async loadToken() {
3449
+ const tokenFilePath = this.getTokenFilePath();
3450
+ try {
3451
+ const tokenData = await promises.readFile(tokenFilePath, "utf8");
3452
+ const token = JSON.parse(tokenData);
3453
+ const missingFields = ["accessToken", "clientId", "refreshToken", "dpopKey"].filter((k) => !token[k]);
3454
+ if (!token.accessToken?.accountId) {
3455
+ missingFields.push("accountId");
3456
+ }
3457
+ if (missingFields.length > 0) {
3458
+ throw new CredentialsProviderError(`Token validation failed, missing fields: ${missingFields.join(", ")}`, {
3459
+ logger: this.logger,
3460
+ tryNextLink: false
3461
+ });
3462
+ }
3463
+ return token;
3464
+ } catch (error) {
3465
+ throw new CredentialsProviderError(`Failed to load token from ${tokenFilePath}: ${String(error)}`, {
3466
+ logger: this.logger,
3467
+ tryNextLink: false
3468
+ });
3469
+ }
3470
+ }
3471
+ async saveToken(token) {
3472
+ const tokenFilePath = this.getTokenFilePath();
3473
+ const directory = dirname(tokenFilePath);
3474
+ try {
3475
+ await promises.mkdir(directory, { recursive: true });
3476
+ } catch (error) {}
3477
+ await promises.writeFile(tokenFilePath, JSON.stringify(token, null, 2), "utf8");
3478
+ }
3479
+ getTokenFilePath() {
3480
+ const directory = process.env.AWS_LOGIN_CACHE_DIRECTORY ?? join(homedir(), ".aws", "login", "cache");
3481
+ const loginSessionBytes = Buffer.from(this.loginSession, "utf8");
3482
+ const loginSessionSha256 = createHash("sha256").update(loginSessionBytes).digest("hex");
3483
+ return join(directory, `${loginSessionSha256}.json`);
3484
+ }
3485
+ derToRawSignature(derSignature) {
3486
+ let offset = 2;
3487
+ if (derSignature[offset] !== 2) {
3488
+ throw new Error("Invalid DER signature");
3489
+ }
3490
+ offset++;
3491
+ const rLength = derSignature[offset++];
3492
+ let r = derSignature.subarray(offset, offset + rLength);
3493
+ offset += rLength;
3494
+ if (derSignature[offset] !== 2) {
3495
+ throw new Error("Invalid DER signature");
3496
+ }
3497
+ offset++;
3498
+ const sLength = derSignature[offset++];
3499
+ let s = derSignature.subarray(offset, offset + sLength);
3500
+ r = r[0] === 0 ? r.subarray(1) : r;
3501
+ s = s[0] === 0 ? s.subarray(1) : s;
3502
+ const rPadded = Buffer.concat([Buffer.alloc(32 - r.length), r]);
3503
+ const sPadded = Buffer.concat([Buffer.alloc(32 - s.length), s]);
3504
+ return Buffer.concat([rPadded, sPadded]);
3505
+ }
3506
+ createDPoPInterceptor(middlewareStack) {
3507
+ middlewareStack.add((next) => async (args) => {
3508
+ if (HttpRequest.isInstance(args.request)) {
3509
+ const request = args.request;
3510
+ const actualEndpoint = `${request.protocol}//${request.hostname}${request.port ? `:${request.port}` : ""}${request.path}`;
3511
+ const dpop = await this.generateDpop(request.method, actualEndpoint);
3512
+ request.headers = {
3513
+ ...request.headers,
3514
+ DPoP: dpop
3515
+ };
3516
+ }
3517
+ return next(args);
3518
+ }, {
3519
+ step: "finalizeRequest",
3520
+ name: "dpopInterceptor",
3521
+ override: true
3522
+ });
3523
+ }
3524
+ async generateDpop(method = "POST", endpoint) {
3525
+ const token = await this.loadToken();
3526
+ try {
3527
+ const privateKey = createPrivateKey({
3528
+ key: token.dpopKey,
3529
+ format: "pem",
3530
+ type: "sec1"
3531
+ });
3532
+ const publicKey = createPublicKey(privateKey);
3533
+ const publicDer = publicKey.export({ format: "der", type: "spki" });
3534
+ let pointStart = -1;
3535
+ for (let i = 0;i < publicDer.length; i++) {
3536
+ if (publicDer[i] === 4) {
3537
+ pointStart = i;
3538
+ break;
3539
+ }
3540
+ }
3541
+ const x = publicDer.slice(pointStart + 1, pointStart + 33);
3542
+ const y = publicDer.slice(pointStart + 33, pointStart + 65);
3543
+ const header = {
3544
+ alg: "ES256",
3545
+ typ: "dpop+jwt",
3546
+ jwk: {
3547
+ kty: "EC",
3548
+ crv: "P-256",
3549
+ x: x.toString("base64url"),
3550
+ y: y.toString("base64url")
3551
+ }
3552
+ };
3553
+ const payload = {
3554
+ jti: crypto.randomUUID(),
3555
+ htm: method,
3556
+ htu: endpoint,
3557
+ iat: Math.floor(Date.now() / 1000)
3558
+ };
3559
+ const headerB64 = Buffer.from(JSON.stringify(header)).toString("base64url");
3560
+ const payloadB64 = Buffer.from(JSON.stringify(payload)).toString("base64url");
3561
+ const message = `${headerB64}.${payloadB64}`;
3562
+ const asn1Signature = sign("sha256", Buffer.from(message), privateKey);
3563
+ const rawSignature = this.derToRawSignature(asn1Signature);
3564
+ const signatureB64 = rawSignature.toString("base64url");
3565
+ return `${message}.${signatureB64}`;
3566
+ } catch (error) {
3567
+ throw new CredentialsProviderError(`Failed to generate Dpop proof: ${error instanceof Error ? error.message : String(error)}`, { logger: this.logger, tryNextLink: false });
3568
+ }
3569
+ }
3570
+ }
3571
+ var fromLoginCredentials = (init) => async ({ callerClientConfig } = {}) => {
3572
+ init?.logger?.debug?.("@aws-sdk/credential-providers - fromLoginCredentials");
3573
+ const profiles = await parseKnownFiles(init || {});
3574
+ const profileName = getProfileName({
3575
+ profile: init?.profile ?? callerClientConfig?.profile
3576
+ });
3577
+ const profile = profiles[profileName];
3578
+ if (!profile?.login_session) {
3579
+ throw new CredentialsProviderError(`Profile ${profileName} does not contain login_session.`, {
3580
+ tryNextLink: true,
3581
+ logger: init?.logger
3582
+ });
3583
+ }
3584
+ const fetcher = new LoginCredentialsFetcher(profile, init, callerClientConfig);
3585
+ const credentials = await fetcher.loadCredentials();
3586
+ return setCredentialFeature(credentials, "CREDENTIALS_LOGIN", "AD");
3587
+ };
3588
+ exports.fromLoginCredentials = fromLoginCredentials;
3589
+ });
3590
+
3591
+ // node_modules/@aws-sdk/credential-provider-process/dist-cjs/index.js
3592
+ var require_dist_cjs11 = __commonJS(function(exports) {
3593
+ var { externalDataInterceptor, CredentialsProviderError, parseKnownFiles, getProfileName } = require_config();
3594
+ var { exec } = __require("node:child_process");
3595
+ var { promisify } = __require("node:util");
3596
+ var { setCredentialFeature } = require_client2();
3597
+ var getValidatedProcessCredentials = (profileName, data, profiles) => {
3598
+ if (data.Version !== 1) {
3599
+ throw Error(`Profile ${profileName} credential_process did not return Version 1.`);
3600
+ }
3601
+ if (data.AccessKeyId === undefined || data.SecretAccessKey === undefined) {
3602
+ throw Error(`Profile ${profileName} credential_process returned invalid credentials.`);
3603
+ }
3604
+ if (data.Expiration) {
3605
+ const currentTime = new Date;
3606
+ const expireTime = new Date(data.Expiration);
3607
+ if (expireTime < currentTime) {
3608
+ throw Error(`Profile ${profileName} credential_process returned expired credentials.`);
3609
+ }
3610
+ }
3611
+ let accountId = data.AccountId;
3612
+ if (!accountId && profiles?.[profileName]?.aws_account_id) {
3613
+ accountId = profiles[profileName].aws_account_id;
3614
+ }
3615
+ const credentials = {
3616
+ accessKeyId: data.AccessKeyId,
3617
+ secretAccessKey: data.SecretAccessKey,
3618
+ ...data.SessionToken && { sessionToken: data.SessionToken },
3619
+ ...data.Expiration && { expiration: new Date(data.Expiration) },
3620
+ ...data.CredentialScope && { credentialScope: data.CredentialScope },
3621
+ ...accountId && { accountId }
3622
+ };
3623
+ setCredentialFeature(credentials, "CREDENTIALS_PROCESS", "w");
3624
+ return credentials;
3625
+ };
3626
+ var resolveProcessCredentials = async (profileName, profiles, logger) => {
3627
+ const profile = profiles[profileName];
3628
+ if (profiles[profileName]) {
3629
+ const credentialProcess = profile["credential_process"];
3630
+ if (credentialProcess !== undefined) {
3631
+ const execPromise = promisify(externalDataInterceptor?.getTokenRecord?.().exec ?? exec);
3632
+ try {
3633
+ const { stdout } = await execPromise(credentialProcess);
3634
+ let data;
3635
+ try {
3636
+ data = JSON.parse(stdout.trim());
3637
+ } catch {
3638
+ throw Error(`Profile ${profileName} credential_process returned invalid JSON.`);
3639
+ }
3640
+ return getValidatedProcessCredentials(profileName, data, profiles);
3641
+ } catch (error) {
3642
+ throw new CredentialsProviderError(error.message, { logger });
3643
+ }
3644
+ } else {
3645
+ throw new CredentialsProviderError(`Profile ${profileName} did not contain credential_process.`, { logger });
3646
+ }
3647
+ } else {
3648
+ throw new CredentialsProviderError(`Profile ${profileName} could not be found in shared credentials file.`, {
3649
+ logger
3650
+ });
3651
+ }
3652
+ };
3653
+ var fromProcess = (init = {}) => async ({ callerClientConfig } = {}) => {
3654
+ init.logger?.debug("@aws-sdk/credential-provider-process - fromProcess");
3655
+ const profiles = await parseKnownFiles(init);
3656
+ return resolveProcessCredentials(getProfileName({
3657
+ profile: init.profile ?? callerClientConfig?.profile
3658
+ }), profiles, init.logger);
3659
+ };
3660
+ exports.fromProcess = fromProcess;
3661
+ });
3662
+
3663
+ // node_modules/@aws-sdk/credential-provider-web-identity/dist-cjs/index.js
3664
+ var require_dist_cjs12 = __commonJS(function(exports) {
3665
+ var { setCredentialFeature } = require_client2();
3666
+ var { CredentialsProviderError, externalDataInterceptor } = require_config();
3667
+ var { readFileSync } = __require("node:fs");
3668
+ var fromWebToken = (init) => async (awsIdentityProperties) => {
3669
+ init.logger?.debug("@aws-sdk/credential-provider-web-identity - fromWebToken");
3670
+ const { roleArn, roleSessionName, webIdentityToken, providerId, policyArns, policy, durationSeconds } = init;
3671
+ let { roleAssumerWithWebIdentity } = init;
3672
+ if (!roleAssumerWithWebIdentity) {
3673
+ const { getDefaultRoleAssumerWithWebIdentity } = require_sts();
3674
+ roleAssumerWithWebIdentity = getDefaultRoleAssumerWithWebIdentity({
3675
+ ...init.clientConfig,
3676
+ credentialProviderLogger: init.logger,
3677
+ parentClientConfig: {
3678
+ ...awsIdentityProperties?.callerClientConfig,
3679
+ ...init.parentClientConfig
3680
+ }
3681
+ }, init.clientPlugins);
3682
+ }
3683
+ return roleAssumerWithWebIdentity({
3684
+ RoleArn: roleArn,
3685
+ RoleSessionName: roleSessionName ?? `aws-sdk-js-session-${Date.now()}`,
3686
+ WebIdentityToken: webIdentityToken,
3687
+ ProviderId: providerId,
3688
+ PolicyArns: policyArns,
3689
+ Policy: policy,
3690
+ DurationSeconds: durationSeconds
3691
+ });
3692
+ };
3693
+ var ENV_TOKEN_FILE = "AWS_WEB_IDENTITY_TOKEN_FILE";
3694
+ var ENV_ROLE_ARN = "AWS_ROLE_ARN";
3695
+ var ENV_ROLE_SESSION_NAME = "AWS_ROLE_SESSION_NAME";
3696
+ var fromTokenFile = (init = {}) => async (awsIdentityProperties) => {
3697
+ init.logger?.debug("@aws-sdk/credential-provider-web-identity - fromTokenFile");
3698
+ const webIdentityTokenFile = init?.webIdentityTokenFile ?? process.env[ENV_TOKEN_FILE];
3699
+ const roleArn = init?.roleArn ?? process.env[ENV_ROLE_ARN];
3700
+ const roleSessionName = init?.roleSessionName ?? process.env[ENV_ROLE_SESSION_NAME];
3701
+ if (!webIdentityTokenFile || !roleArn) {
3702
+ throw new CredentialsProviderError("Web identity configuration not specified", {
3703
+ logger: init.logger
3704
+ });
3705
+ }
3706
+ const credentials = await fromWebToken({
3707
+ ...init,
3708
+ webIdentityToken: externalDataInterceptor?.getTokenRecord?.()[webIdentityTokenFile] ?? readFileSync(webIdentityTokenFile, { encoding: "ascii" }),
3709
+ roleArn,
3710
+ roleSessionName
3711
+ })(awsIdentityProperties);
3712
+ if (webIdentityTokenFile === process.env[ENV_TOKEN_FILE]) {
3713
+ setCredentialFeature(credentials, "CREDENTIALS_ENV_VARS_STS_WEB_ID_TOKEN", "h");
3714
+ }
3715
+ return credentials;
3716
+ };
3717
+ exports.fromTokenFile = fromTokenFile;
3718
+ exports.fromWebToken = fromWebToken;
3719
+ });
3720
+
3721
+ // node_modules/@aws-sdk/credential-provider-ini/dist-cjs/index.js
3722
+ var require_dist_cjs13 = __commonJS(function(exports) {
3723
+ var { CredentialsProviderError, chain, getProfileName, parseKnownFiles } = require_config();
3724
+ var { setCredentialFeature } = require_client2();
3725
+ var resolveCredentialSource = (credentialSource, profileName, logger) => {
3726
+ const sourceProvidersMap = {
3727
+ EcsContainer: async (options) => {
3728
+ const { fromHttp } = require_dist_cjs6();
3729
+ const { fromContainerMetadata } = require_dist_cjs5();
3730
+ logger?.debug("@aws-sdk/credential-provider-ini - credential_source is EcsContainer");
3731
+ return async () => chain(fromHttp(options ?? {}), fromContainerMetadata(options))().then(setNamedProvider);
3732
+ },
3733
+ Ec2InstanceMetadata: async (options) => {
3734
+ logger?.debug("@aws-sdk/credential-provider-ini - credential_source is Ec2InstanceMetadata");
3735
+ const { fromInstanceMetadata } = require_dist_cjs5();
3736
+ return async () => fromInstanceMetadata(options)().then(setNamedProvider);
3737
+ },
3738
+ Environment: async (options) => {
3739
+ logger?.debug("@aws-sdk/credential-provider-ini - credential_source is Environment");
3740
+ const { fromEnv } = require_dist_cjs4();
3741
+ return async () => fromEnv(options)().then(setNamedProvider);
3742
+ }
3743
+ };
3744
+ if (credentialSource in sourceProvidersMap) {
3745
+ return sourceProvidersMap[credentialSource];
3746
+ } else {
3747
+ throw new CredentialsProviderError(`Unsupported credential source in profile ${profileName}. Got ${credentialSource}, ` + `expected EcsContainer or Ec2InstanceMetadata or Environment.`, { logger });
3748
+ }
3749
+ };
3750
+ var setNamedProvider = (creds) => setCredentialFeature(creds, "CREDENTIALS_PROFILE_NAMED_PROVIDER", "p");
3751
+ var isAssumeRoleProfile = (arg, { profile = "default", logger } = {}) => {
3752
+ 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, { profile, logger }) || isCredentialSourceProfile(arg, { profile, logger }));
3753
+ };
3754
+ var isAssumeRoleWithSourceProfile = (arg, { profile, logger }) => {
3755
+ const withSourceProfile = typeof arg.source_profile === "string" && typeof arg.credential_source === "undefined";
3756
+ if (withSourceProfile) {
3757
+ logger?.debug?.(` ${profile} isAssumeRoleWithSourceProfile source_profile=${arg.source_profile}`);
3758
+ }
3759
+ return withSourceProfile;
3760
+ };
3761
+ var isCredentialSourceProfile = (arg, { profile, logger }) => {
3762
+ const withProviderProfile = typeof arg.credential_source === "string" && typeof arg.source_profile === "undefined";
3763
+ if (withProviderProfile) {
3764
+ logger?.debug?.(` ${profile} isCredentialSourceProfile credential_source=${arg.credential_source}`);
3765
+ }
3766
+ return withProviderProfile;
3767
+ };
3768
+ var resolveAssumeRoleCredentials = async (profileName, profiles, options, callerClientConfig, visitedProfiles = {}, resolveProfileData2) => {
3769
+ options.logger?.debug("@aws-sdk/credential-provider-ini - resolveAssumeRoleCredentials (STS)");
3770
+ const profileData = profiles[profileName];
3771
+ const { source_profile, region } = profileData;
3772
+ if (!options.roleAssumer) {
3773
+ const { getDefaultRoleAssumer } = require_sts();
3774
+ options.roleAssumer = getDefaultRoleAssumer({
3775
+ ...options.clientConfig,
3776
+ credentialProviderLogger: options.logger,
3777
+ parentClientConfig: {
3778
+ ...callerClientConfig,
3779
+ ...options?.parentClientConfig,
3780
+ region: region ?? options?.parentClientConfig?.region ?? callerClientConfig?.region
3781
+ }
3782
+ }, options.clientPlugins);
3783
+ }
3784
+ if (source_profile && source_profile in visitedProfiles) {
3785
+ throw new CredentialsProviderError(`Detected a cycle attempting to resolve credentials for profile` + ` ${getProfileName(options)}. Profiles visited: ` + Object.keys(visitedProfiles).join(", "), { logger: options.logger });
3786
+ }
3787
+ options.logger?.debug(`@aws-sdk/credential-provider-ini - finding credential resolver using ${source_profile ? `source_profile=[${source_profile}]` : `profile=[${profileName}]`}`);
3788
+ const sourceCredsProvider = source_profile ? resolveProfileData2(source_profile, profiles, options, callerClientConfig, {
3789
+ ...visitedProfiles,
3790
+ [source_profile]: true
3791
+ }, isCredentialSourceWithoutRoleArn(profiles[source_profile] ?? {})) : (await resolveCredentialSource(profileData.credential_source, profileName, options.logger)(options))();
3792
+ if (isCredentialSourceWithoutRoleArn(profileData)) {
3793
+ return sourceCredsProvider.then((creds) => setCredentialFeature(creds, "CREDENTIALS_PROFILE_SOURCE_PROFILE", "o"));
3794
+ } else {
3795
+ const params = {
3796
+ RoleArn: profileData.role_arn,
3797
+ RoleSessionName: profileData.role_session_name || `aws-sdk-js-${Date.now()}`,
3798
+ ExternalId: profileData.external_id,
3799
+ DurationSeconds: parseInt(profileData.duration_seconds || "3600", 10)
3800
+ };
3801
+ const { mfa_serial } = profileData;
3802
+ if (mfa_serial) {
3803
+ if (!options.mfaCodeProvider) {
3804
+ throw new CredentialsProviderError(`Profile ${profileName} requires multi-factor authentication, but no MFA code callback was provided.`, { logger: options.logger, tryNextLink: false });
3805
+ }
3806
+ params.SerialNumber = mfa_serial;
3807
+ params.TokenCode = await options.mfaCodeProvider(mfa_serial);
3808
+ }
3809
+ const sourceCreds = await sourceCredsProvider;
3810
+ return options.roleAssumer(sourceCreds, params).then((creds) => setCredentialFeature(creds, "CREDENTIALS_PROFILE_SOURCE_PROFILE", "o"));
3811
+ }
3812
+ };
3813
+ var isCredentialSourceWithoutRoleArn = (section) => {
3814
+ return !section.role_arn && !!section.credential_source;
3815
+ };
3816
+ var isLoginProfile = (data) => {
3817
+ return Boolean(data && data.login_session);
3818
+ };
3819
+ var resolveLoginCredentials = async (profileName, options, callerClientConfig) => {
3820
+ const { fromLoginCredentials } = require_dist_cjs10();
3821
+ const credentials = await fromLoginCredentials({
3822
+ ...options,
3823
+ profile: profileName
3824
+ })({ callerClientConfig });
3825
+ return setCredentialFeature(credentials, "CREDENTIALS_PROFILE_LOGIN", "AC");
3826
+ };
3827
+ var isProcessProfile = (arg) => Boolean(arg) && typeof arg === "object" && typeof arg.credential_process === "string";
3828
+ var resolveProcessCredentials = async (options, profile) => {
3829
+ const { fromProcess } = require_dist_cjs11();
3830
+ const credentials = await fromProcess({
3831
+ ...options,
3832
+ profile
3833
+ })();
3834
+ return setCredentialFeature(credentials, "CREDENTIALS_PROFILE_PROCESS", "v");
3835
+ };
3836
+ var resolveSsoCredentials = async (profile, profileData, options = {}, callerClientConfig) => {
3837
+ const { fromSSO } = require_dist_cjs8();
3838
+ return fromSSO({
3839
+ profile,
3840
+ logger: options.logger,
3841
+ parentClientConfig: options.parentClientConfig,
3842
+ clientConfig: options.clientConfig
3843
+ })({
3844
+ callerClientConfig
3845
+ }).then((creds) => {
3846
+ if (profileData.sso_session) {
3847
+ return setCredentialFeature(creds, "CREDENTIALS_PROFILE_SSO", "r");
3848
+ } else {
3849
+ return setCredentialFeature(creds, "CREDENTIALS_PROFILE_SSO_LEGACY", "t");
3850
+ }
3851
+ });
3852
+ };
3853
+ var isSsoProfile = (arg) => arg && (typeof arg.sso_start_url === "string" || typeof arg.sso_account_id === "string" || typeof arg.sso_session === "string" || typeof arg.sso_region === "string" || typeof arg.sso_role_name === "string");
3854
+ var isStaticCredsProfile = (arg) => Boolean(arg) && typeof arg === "object" && typeof arg.aws_access_key_id === "string" && typeof arg.aws_secret_access_key === "string" && ["undefined", "string"].indexOf(typeof arg.aws_session_token) > -1 && ["undefined", "string"].indexOf(typeof arg.aws_account_id) > -1;
3855
+ var resolveStaticCredentials = async (profile, options) => {
3856
+ options?.logger?.debug("@aws-sdk/credential-provider-ini - resolveStaticCredentials");
3857
+ const credentials = {
3858
+ accessKeyId: profile.aws_access_key_id,
3859
+ secretAccessKey: profile.aws_secret_access_key,
3860
+ sessionToken: profile.aws_session_token,
3861
+ ...profile.aws_credential_scope && { credentialScope: profile.aws_credential_scope },
3862
+ ...profile.aws_account_id && { accountId: profile.aws_account_id }
3863
+ };
3864
+ return setCredentialFeature(credentials, "CREDENTIALS_PROFILE", "n");
3865
+ };
3866
+ var isWebIdentityProfile = (arg) => Boolean(arg) && typeof arg === "object" && typeof arg.web_identity_token_file === "string" && typeof arg.role_arn === "string" && ["undefined", "string"].indexOf(typeof arg.role_session_name) > -1;
3867
+ var resolveWebIdentityCredentials = async (profile, options, callerClientConfig) => {
3868
+ const { fromTokenFile } = require_dist_cjs12();
3869
+ const credentials = await fromTokenFile({
3870
+ webIdentityTokenFile: profile.web_identity_token_file,
3871
+ roleArn: profile.role_arn,
3872
+ roleSessionName: profile.role_session_name,
3873
+ roleAssumerWithWebIdentity: options.roleAssumerWithWebIdentity,
3874
+ logger: options.logger,
3875
+ parentClientConfig: options.parentClientConfig
3876
+ })({
3877
+ callerClientConfig
3878
+ });
3879
+ return setCredentialFeature(credentials, "CREDENTIALS_PROFILE_STS_WEB_ID_TOKEN", "q");
3880
+ };
3881
+ var resolveProfileData = async (profileName, profiles, options, callerClientConfig, visitedProfiles = {}, isAssumeRoleRecursiveCall = false) => {
3882
+ const data = profiles[profileName];
3883
+ if (Object.keys(visitedProfiles).length > 0 && isStaticCredsProfile(data)) {
3884
+ return resolveStaticCredentials(data, options);
3885
+ }
3886
+ if (isAssumeRoleRecursiveCall || isAssumeRoleProfile(data, { profile: profileName, logger: options.logger })) {
3887
+ return resolveAssumeRoleCredentials(profileName, profiles, options, callerClientConfig, visitedProfiles, resolveProfileData);
3888
+ }
3889
+ if (isStaticCredsProfile(data)) {
3890
+ return resolveStaticCredentials(data, options);
3891
+ }
3892
+ if (isWebIdentityProfile(data)) {
3893
+ return resolveWebIdentityCredentials(data, options, callerClientConfig);
3894
+ }
3895
+ if (isProcessProfile(data)) {
3896
+ return resolveProcessCredentials(options, profileName);
3897
+ }
3898
+ if (isSsoProfile(data)) {
3899
+ return await resolveSsoCredentials(profileName, data, options, callerClientConfig);
3900
+ }
3901
+ if (isLoginProfile(data)) {
3902
+ return resolveLoginCredentials(profileName, options, callerClientConfig);
3903
+ }
3904
+ throw new CredentialsProviderError(`Could not resolve credentials using profile: [${profileName}] in configuration/credentials file(s).`, { logger: options.logger });
3905
+ };
3906
+ var fromIni = (init = {}) => async ({ callerClientConfig } = {}) => {
3907
+ init.logger?.debug("@aws-sdk/credential-provider-ini - fromIni");
3908
+ const profiles = await parseKnownFiles(init);
3909
+ return resolveProfileData(getProfileName({
3910
+ profile: init.profile ?? callerClientConfig?.profile
3911
+ }), profiles, init, callerClientConfig);
3912
+ };
3913
+ exports.fromIni = fromIni;
3914
+ });
3915
+
3916
+ // node_modules/@aws-sdk/credential-provider-node/dist-cjs/index.js
3917
+ var require_dist_cjs14 = __commonJS(function(exports) {
3918
+ var { ENV_KEY, ENV_SECRET, fromEnv } = require_dist_cjs4();
3919
+ var { chain, CredentialsProviderError, ENV_PROFILE } = require_config();
3920
+ var ENV_IMDS_DISABLED = "AWS_EC2_METADATA_DISABLED";
3921
+ var remoteProvider = async (init) => {
3922
+ const { ENV_CMDS_FULL_URI, ENV_CMDS_RELATIVE_URI, fromContainerMetadata, fromInstanceMetadata } = require_dist_cjs5();
3923
+ if (process.env[ENV_CMDS_RELATIVE_URI] || process.env[ENV_CMDS_FULL_URI]) {
3924
+ init.logger?.debug("@aws-sdk/credential-provider-node - remoteProvider::fromHttp/fromContainerMetadata");
3925
+ const { fromHttp } = require_dist_cjs6();
3926
+ return chain(fromHttp(init), fromContainerMetadata(init));
3927
+ }
3928
+ if (process.env[ENV_IMDS_DISABLED] && process.env[ENV_IMDS_DISABLED] !== "false") {
3929
+ return async () => {
3930
+ throw new CredentialsProviderError("EC2 Instance Metadata Service access disabled", { logger: init.logger });
3931
+ };
3932
+ }
3933
+ init.logger?.debug("@aws-sdk/credential-provider-node - remoteProvider::fromInstanceMetadata");
3934
+ return fromInstanceMetadata(init);
3935
+ };
3936
+ function memoizeChain(providers, treatAsExpired) {
3937
+ const chain2 = internalCreateChain(providers);
3938
+ let activeLock;
3939
+ let passiveLock;
3940
+ let credentials;
3941
+ let forceRefreshLock;
3942
+ const provider = async (options) => {
3943
+ if (options?.forceRefresh) {
3944
+ if (!forceRefreshLock) {
3945
+ forceRefreshLock = chain2(options).then((c) => {
3946
+ credentials = c;
3947
+ }).finally(() => {
3948
+ forceRefreshLock = undefined;
3949
+ });
3950
+ }
3951
+ await forceRefreshLock;
3952
+ return credentials;
3953
+ }
3954
+ if (credentials?.expiration) {
3955
+ if (credentials?.expiration?.getTime() < Date.now()) {
3956
+ credentials = undefined;
3957
+ }
3958
+ }
3959
+ if (activeLock) {
3960
+ await activeLock;
3961
+ } else if (!credentials || treatAsExpired?.(credentials)) {
3962
+ if (credentials) {
3963
+ if (!passiveLock) {
3964
+ passiveLock = chain2(options).then((c) => {
3965
+ credentials = c;
3966
+ }).catch(() => {}).finally(() => {
3967
+ passiveLock = undefined;
3968
+ });
3969
+ }
3970
+ } else {
3971
+ activeLock = chain2(options).then((c) => {
3972
+ credentials = c;
3973
+ }).finally(() => {
3974
+ activeLock = undefined;
3975
+ });
3976
+ return provider(options);
3977
+ }
3978
+ }
3979
+ return credentials;
3980
+ };
3981
+ return provider;
3982
+ }
3983
+ var internalCreateChain = (providers) => async (awsIdentityProperties) => {
3984
+ let lastProviderError;
3985
+ for (const provider of providers) {
3986
+ try {
3987
+ return await provider(awsIdentityProperties);
3988
+ } catch (err) {
3989
+ lastProviderError = err;
3990
+ if (err?.tryNextLink) {
3991
+ continue;
3992
+ }
3993
+ throw err;
3994
+ }
3995
+ }
3996
+ throw lastProviderError;
3997
+ };
3998
+ var multipleCredentialSourceWarningEmitted = false;
3999
+ var defaultProvider = (init = {}) => memoizeChain([
4000
+ async () => {
4001
+ const profile = init.profile ?? process.env[ENV_PROFILE];
4002
+ if (profile) {
4003
+ const envStaticCredentialsAreSet = process.env[ENV_KEY] && process.env[ENV_SECRET];
4004
+ if (envStaticCredentialsAreSet) {
4005
+ if (!multipleCredentialSourceWarningEmitted) {
4006
+ const warnFn = init.logger?.warn && init.logger?.constructor?.name !== "NoOpLogger" ? init.logger.warn.bind(init.logger) : console.warn;
4007
+ warnFn(`@aws-sdk/credential-provider-node - defaultProvider::fromEnv WARNING:
4008
+ Multiple credential sources detected:
4009
+ Both AWS_PROFILE and the pair AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY static credentials are set.
4010
+ This SDK will proceed with the AWS_PROFILE value.
4011
+
4012
+ However, a future version may change this behavior to prefer the ENV static credentials.
4013
+ Please ensure that your environment only sets either the AWS_PROFILE or the
4014
+ AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY pair.
4015
+ `);
4016
+ multipleCredentialSourceWarningEmitted = true;
4017
+ }
4018
+ }
4019
+ throw new CredentialsProviderError("AWS_PROFILE is set, skipping fromEnv provider.", {
4020
+ logger: init.logger,
4021
+ tryNextLink: true
4022
+ });
4023
+ }
4024
+ init.logger?.debug("@aws-sdk/credential-provider-node - defaultProvider::fromEnv");
4025
+ return fromEnv(init)();
4026
+ },
4027
+ async (awsIdentityProperties) => {
4028
+ init.logger?.debug("@aws-sdk/credential-provider-node - defaultProvider::fromSSO");
4029
+ const { ssoStartUrl, ssoAccountId, ssoRegion, ssoRoleName, ssoSession } = init;
4030
+ if (!ssoStartUrl && !ssoAccountId && !ssoRegion && !ssoRoleName && !ssoSession) {
4031
+ throw new CredentialsProviderError("Skipping SSO provider in default chain (inputs do not include SSO fields).", { logger: init.logger });
4032
+ }
4033
+ const { fromSSO } = require_dist_cjs8();
4034
+ return fromSSO(init)(awsIdentityProperties);
4035
+ },
4036
+ async (awsIdentityProperties) => {
4037
+ init.logger?.debug("@aws-sdk/credential-provider-node - defaultProvider::fromIni");
4038
+ const { fromIni } = require_dist_cjs13();
4039
+ return fromIni(init)(awsIdentityProperties);
4040
+ },
4041
+ async (awsIdentityProperties) => {
4042
+ init.logger?.debug("@aws-sdk/credential-provider-node - defaultProvider::fromProcess");
4043
+ const { fromProcess } = require_dist_cjs11();
4044
+ return fromProcess(init)(awsIdentityProperties);
4045
+ },
4046
+ async (awsIdentityProperties) => {
4047
+ init.logger?.debug("@aws-sdk/credential-provider-node - defaultProvider::fromTokenFile");
4048
+ const { fromTokenFile } = require_dist_cjs12();
4049
+ return fromTokenFile(init)(awsIdentityProperties);
4050
+ },
4051
+ async () => {
4052
+ init.logger?.debug("@aws-sdk/credential-provider-node - defaultProvider::remoteProvider");
4053
+ return (await remoteProvider(init))();
4054
+ },
4055
+ async () => {
4056
+ throw new CredentialsProviderError("Could not load credentials from any providers", {
4057
+ tryNextLink: false,
4058
+ logger: init.logger
4059
+ });
4060
+ }
4061
+ ], credentialsTreatedAsExpired);
4062
+ var credentialsWillNeedRefresh = (credentials) => credentials?.expiration !== undefined;
4063
+ var credentialsTreatedAsExpired = (credentials) => credentials?.expiration !== undefined && credentials.expiration.getTime() - Date.now() < 300000;
4064
+ exports.credentialsTreatedAsExpired = credentialsTreatedAsExpired;
4065
+ exports.credentialsWillNeedRefresh = credentialsWillNeedRefresh;
4066
+ exports.defaultProvider = defaultProvider;
4067
+ });
4068
+
4069
+ export { require_dist_cjs14 as require_dist_cjs };