alchemy 2.0.0-beta.34 → 2.0.0-beta.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +8 -7
- package/bin/exec.js +226 -52
- package/bin/exec.js.map +1 -1
- package/lib/AWS/AuthProvider.d.ts +7 -6
- package/lib/AWS/AuthProvider.d.ts.map +1 -1
- package/lib/AWS/AuthProvider.js +143 -134
- package/lib/AWS/AuthProvider.js.map +1 -1
- package/lib/AWS/Bootstrap.d.ts +2 -2
- package/lib/AWS/Bootstrap.d.ts.map +1 -1
- package/lib/AWS/EC2/hosted.d.ts +1 -1
- package/lib/AWS/Environment.d.ts +25 -3
- package/lib/AWS/Environment.d.ts.map +1 -1
- package/lib/AWS/Environment.js +47 -3
- package/lib/AWS/Environment.js.map +1 -1
- package/lib/AWS/IAM/OpenIDConnectProvider.d.ts +14 -6
- package/lib/AWS/IAM/OpenIDConnectProvider.d.ts.map +1 -1
- package/lib/AWS/IAM/OpenIDConnectProvider.js +6 -3
- package/lib/AWS/IAM/OpenIDConnectProvider.js.map +1 -1
- package/lib/AWS/IAM/Policy.d.ts +1 -1
- package/lib/AWS/IAM/Policy.d.ts.map +1 -1
- package/lib/AWS/IAM/Policy.js.map +1 -1
- package/lib/AWS/Lambda/BucketEventSource.d.ts +1 -1
- package/lib/AWS/Lambda/BucketEventSource.d.ts.map +1 -1
- package/lib/AWS/Lambda/EventBridgeEventSource.d.ts +1 -1
- package/lib/AWS/Lambda/EventBridgeEventSource.d.ts.map +1 -1
- package/lib/AWS/Lambda/QueueEventSource.d.ts +1 -1
- package/lib/AWS/Lambda/QueueEventSource.d.ts.map +1 -1
- package/lib/AWS/Lambda/StreamEventSource.d.ts +1 -1
- package/lib/AWS/Lambda/StreamEventSource.d.ts.map +1 -1
- package/lib/AWS/Lambda/TableEventSource.d.ts +1 -1
- package/lib/AWS/Lambda/TableEventSource.d.ts.map +1 -1
- package/lib/AWS/Lambda/TopicEventSource.d.ts +1 -1
- package/lib/AWS/Lambda/TopicEventSource.d.ts.map +1 -1
- package/lib/AWS/Providers.d.ts +1 -1
- package/lib/AWS/Providers.d.ts.map +1 -1
- package/lib/AWS/Providers.js +2 -1
- package/lib/AWS/Providers.js.map +1 -1
- package/lib/Auth/Credentials.d.ts +21 -6
- package/lib/Auth/Credentials.d.ts.map +1 -1
- package/lib/Auth/Credentials.js +30 -31
- package/lib/Auth/Credentials.js.map +1 -1
- package/lib/Auth/Profile.d.ts +31 -34
- package/lib/Auth/Profile.d.ts.map +1 -1
- package/lib/Auth/Profile.js +46 -31
- package/lib/Auth/Profile.js.map +1 -1
- package/lib/Axiom/AuthProvider.d.ts +2 -1
- package/lib/Axiom/AuthProvider.d.ts.map +1 -1
- package/lib/Axiom/AuthProvider.js +149 -143
- package/lib/Axiom/AuthProvider.js.map +1 -1
- package/lib/Axiom/Credentials.d.ts +2 -1
- package/lib/Axiom/Credentials.d.ts.map +1 -1
- package/lib/Axiom/Credentials.js +4 -4
- package/lib/Axiom/Credentials.js.map +1 -1
- package/lib/Axiom/Providers.d.ts +1 -1
- package/lib/Axiom/Providers.d.ts.map +1 -1
- package/lib/Axiom/Providers.js +3 -1
- package/lib/Axiom/Providers.js.map +1 -1
- package/lib/Cli/LoggingCli.d.ts.map +1 -1
- package/lib/Cli/LoggingCli.js +105 -7
- package/lib/Cli/LoggingCli.js.map +1 -1
- package/lib/Cli/checkVersion.d.ts +13 -0
- package/lib/Cli/checkVersion.d.ts.map +1 -0
- package/lib/Cli/checkVersion.js +47 -0
- package/lib/Cli/checkVersion.js.map +1 -0
- package/lib/Cli/commands/_shared.d.ts +2 -2
- package/lib/Cli/commands/_shared.d.ts.map +1 -1
- package/lib/Cli/commands/_shared.js +3 -3
- package/lib/Cli/commands/_shared.js.map +1 -1
- package/lib/Cli/commands/aws.d.ts +6 -0
- package/lib/Cli/commands/aws.d.ts.map +1 -0
- package/lib/Cli/commands/aws.js +63 -0
- package/lib/Cli/commands/aws.js.map +1 -0
- package/lib/Cli/commands/cloudflare.d.ts +17 -0
- package/lib/Cli/commands/cloudflare.d.ts.map +1 -0
- package/lib/Cli/commands/cloudflare.js +111 -0
- package/lib/Cli/commands/cloudflare.js.map +1 -0
- package/lib/Cli/commands/deploy.d.ts +6 -5
- package/lib/Cli/commands/deploy.d.ts.map +1 -1
- package/lib/Cli/commands/deploy.js +10 -10
- package/lib/Cli/commands/deploy.js.map +1 -1
- package/lib/Cli/commands/dev.d.ts.map +1 -1
- package/lib/Cli/commands/dev.js +16 -16
- package/lib/Cli/commands/dev.js.map +1 -1
- package/lib/Cli/commands/login.d.ts +2 -1
- package/lib/Cli/commands/login.d.ts.map +1 -1
- package/lib/Cli/commands/login.js +9 -8
- package/lib/Cli/commands/login.js.map +1 -1
- package/lib/Cli/commands/logs.d.ts +1 -1
- package/lib/Cli/commands/logs.d.ts.map +1 -1
- package/lib/Cli/commands/logs.js +7 -7
- package/lib/Cli/commands/logs.js.map +1 -1
- package/lib/Cli/commands/profile.d.ts +3 -1
- package/lib/Cli/commands/profile.d.ts.map +1 -1
- package/lib/Cli/commands/profile.js +14 -11
- package/lib/Cli/commands/profile.js.map +1 -1
- package/lib/Cli/commands/state.d.ts +1 -1
- package/lib/Cli/commands/state.d.ts.map +1 -1
- package/lib/Cli/commands/state.js +8 -8
- package/lib/Cli/commands/state.js.map +1 -1
- package/lib/Cli/commands/tail.d.ts +1 -1
- package/lib/Cli/commands/tail.d.ts.map +1 -1
- package/lib/Cli/commands/tail.js +7 -7
- package/lib/Cli/commands/tail.js.map +1 -1
- package/lib/Cli/exec.d.ts.map +1 -1
- package/lib/Cli/exec.js +5 -3
- package/lib/Cli/exec.js.map +1 -1
- package/lib/Cli/main.d.ts.map +1 -1
- package/lib/Cli/main.js +17 -5
- package/lib/Cli/main.js.map +1 -1
- package/lib/Cli/selectCli.d.ts +12 -0
- package/lib/Cli/selectCli.d.ts.map +1 -0
- package/lib/Cli/selectCli.js +32 -0
- package/lib/Cli/selectCli.js.map +1 -0
- package/lib/Cloudflare/Auth/AuthProvider.d.ts +2 -1
- package/lib/Cloudflare/Auth/AuthProvider.d.ts.map +1 -1
- package/lib/Cloudflare/Auth/AuthProvider.js +235 -214
- package/lib/Cloudflare/Auth/AuthProvider.js.map +1 -1
- package/lib/Cloudflare/CloudflareEnvironment.d.ts +2 -1
- package/lib/Cloudflare/CloudflareEnvironment.d.ts.map +1 -1
- package/lib/Cloudflare/CloudflareEnvironment.js +3 -2
- package/lib/Cloudflare/CloudflareEnvironment.js.map +1 -1
- package/lib/Cloudflare/Credentials.d.ts +2 -1
- package/lib/Cloudflare/Credentials.d.ts.map +1 -1
- package/lib/Cloudflare/Credentials.js +4 -4
- package/lib/Cloudflare/Credentials.js.map +1 -1
- package/lib/Cloudflare/D1/D1Clone.d.ts +2 -1
- package/lib/Cloudflare/D1/D1Clone.d.ts.map +1 -1
- package/lib/Cloudflare/D1/D1Database.d.ts +2 -1
- package/lib/Cloudflare/D1/D1Database.d.ts.map +1 -1
- package/lib/Cloudflare/D1/D1Import.d.ts +3 -1
- package/lib/Cloudflare/D1/D1Import.d.ts.map +1 -1
- package/lib/Cloudflare/Local/Sidecar.d.ts +11 -4
- package/lib/Cloudflare/Local/Sidecar.d.ts.map +1 -1
- package/lib/Cloudflare/Local/Sidecar.js +8 -6
- package/lib/Cloudflare/Local/Sidecar.js.map +1 -1
- package/lib/Cloudflare/Local/SidecarHandlers.d.ts.map +1 -1
- package/lib/Cloudflare/Local/SidecarHandlers.js +1 -5
- package/lib/Cloudflare/Local/SidecarHandlers.js.map +1 -1
- package/lib/Cloudflare/Local/SidecarServer.js +5 -2
- package/lib/Cloudflare/Local/SidecarServer.js.map +1 -1
- package/lib/Cloudflare/Logs.d.ts +5 -0
- package/lib/Cloudflare/Logs.d.ts.map +1 -1
- package/lib/Cloudflare/Logs.js +70 -1
- package/lib/Cloudflare/Logs.js.map +1 -1
- package/lib/Cloudflare/Providers.d.ts +1 -1
- package/lib/Cloudflare/Providers.d.ts.map +1 -1
- package/lib/Cloudflare/Providers.js +4 -1
- package/lib/Cloudflare/Providers.js.map +1 -1
- package/lib/Cloudflare/Queue/Queue.d.ts +1 -1
- package/lib/Cloudflare/Queue/Queue.js +1 -1
- package/lib/Cloudflare/Queue/QueueConsumer.d.ts +6 -2
- package/lib/Cloudflare/Queue/QueueConsumer.d.ts.map +1 -1
- package/lib/Cloudflare/Queue/QueueConsumer.js +194 -53
- package/lib/Cloudflare/Queue/QueueConsumer.js.map +1 -1
- package/lib/Cloudflare/Queue/QueueEventSource.d.ts +106 -0
- package/lib/Cloudflare/Queue/QueueEventSource.d.ts.map +1 -0
- package/lib/Cloudflare/Queue/QueueEventSource.js +145 -0
- package/lib/Cloudflare/Queue/QueueEventSource.js.map +1 -0
- package/lib/Cloudflare/Queue/index.d.ts +1 -0
- package/lib/Cloudflare/Queue/index.d.ts.map +1 -1
- package/lib/Cloudflare/Queue/index.js +1 -0
- package/lib/Cloudflare/Queue/index.js.map +1 -1
- package/lib/Cloudflare/R2/R2Bucket.d.ts +94 -0
- package/lib/Cloudflare/R2/R2Bucket.d.ts.map +1 -1
- package/lib/Cloudflare/R2/R2Bucket.js +186 -2
- package/lib/Cloudflare/R2/R2Bucket.js.map +1 -1
- package/lib/Cloudflare/StateStore/State.d.ts +4 -3
- package/lib/Cloudflare/StateStore/State.d.ts.map +1 -1
- package/lib/Cloudflare/StateStore/State.js +16 -8
- package/lib/Cloudflare/StateStore/State.js.map +1 -1
- package/lib/Cloudflare/VpcService/VpcServiceRef.d.ts +1 -1
- package/lib/Cloudflare/VpcService/VpcServiceRef.d.ts.map +1 -1
- package/lib/Cloudflare/Website/StaticSite.d.ts.map +1 -1
- package/lib/Cloudflare/Website/StaticSite.js +10 -1
- package/lib/Cloudflare/Website/StaticSite.js.map +1 -1
- package/lib/Cloudflare/Workers/Assets.d.ts +1 -1
- package/lib/Cloudflare/Workers/Assets.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/LocalWorkerProvider.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/LocalWorkerProvider.js +11 -1
- package/lib/Cloudflare/Workers/LocalWorkerProvider.js.map +1 -1
- package/lib/Cloudflare/Workers/Worker.d.ts +9 -7
- package/lib/Cloudflare/Workers/Worker.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/Worker.js +62 -142
- package/lib/Cloudflare/Workers/Worker.js.map +1 -1
- package/lib/Cloudflare/Workers/WorkerBundle.d.ts +2 -0
- package/lib/Cloudflare/Workers/WorkerBundle.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/WorkerBundle.js +21 -7
- package/lib/Cloudflare/Workers/WorkerBundle.js.map +1 -1
- package/lib/Cloudflare/Zone.d.ts +14 -0
- package/lib/Cloudflare/Zone.d.ts.map +1 -0
- package/lib/Cloudflare/Zone.js +44 -0
- package/lib/Cloudflare/Zone.js.map +1 -0
- package/lib/Drizzle/Schema.d.ts.map +1 -1
- package/lib/Drizzle/Schema.js +20 -5
- package/lib/Drizzle/Schema.js.map +1 -1
- package/lib/GitHub/AuthProvider.d.ts +3 -1
- package/lib/GitHub/AuthProvider.d.ts.map +1 -1
- package/lib/GitHub/AuthProvider.js +114 -108
- package/lib/GitHub/AuthProvider.js.map +1 -1
- package/lib/GitHub/Credentials.d.ts +2 -1
- package/lib/GitHub/Credentials.d.ts.map +1 -1
- package/lib/GitHub/Credentials.js +4 -4
- package/lib/GitHub/Credentials.js.map +1 -1
- package/lib/GitHub/Providers.d.ts +1 -1
- package/lib/GitHub/Providers.d.ts.map +1 -1
- package/lib/GitHub/Providers.js +3 -1
- package/lib/GitHub/Providers.js.map +1 -1
- package/lib/GitHub/Secrets.d.ts.map +1 -1
- package/lib/GitHub/Secrets.js +14 -1
- package/lib/GitHub/Secrets.js.map +1 -1
- package/lib/GitHub/Variables.d.ts +40 -0
- package/lib/GitHub/Variables.d.ts.map +1 -0
- package/lib/GitHub/Variables.js +28 -0
- package/lib/GitHub/Variables.js.map +1 -0
- package/lib/GitHub/index.d.ts +1 -0
- package/lib/GitHub/index.d.ts.map +1 -1
- package/lib/GitHub/index.js +1 -0
- package/lib/GitHub/index.js.map +1 -1
- package/lib/Neon/AuthProvider.d.ts +3 -1
- package/lib/Neon/AuthProvider.d.ts.map +1 -1
- package/lib/Neon/AuthProvider.js +87 -80
- package/lib/Neon/AuthProvider.js.map +1 -1
- package/lib/Neon/Credentials.d.ts +2 -1
- package/lib/Neon/Credentials.d.ts.map +1 -1
- package/lib/Neon/Credentials.js +4 -4
- package/lib/Neon/Credentials.js.map +1 -1
- package/lib/Neon/NeonEnvironment.d.ts +2 -1
- package/lib/Neon/NeonEnvironment.d.ts.map +1 -1
- package/lib/Neon/NeonEnvironment.js +3 -2
- package/lib/Neon/NeonEnvironment.js.map +1 -1
- package/lib/Neon/Project.d.ts +16 -0
- package/lib/Neon/Project.d.ts.map +1 -1
- package/lib/Neon/Project.js +25 -0
- package/lib/Neon/Project.js.map +1 -1
- package/lib/Neon/Providers.d.ts +1 -1
- package/lib/Neon/Providers.d.ts.map +1 -1
- package/lib/Neon/Providers.js +3 -1
- package/lib/Neon/Providers.js.map +1 -1
- package/lib/Neon/api.d.ts +1 -0
- package/lib/Neon/api.d.ts.map +1 -1
- package/lib/Neon/api.js +1 -0
- package/lib/Neon/api.js.map +1 -1
- package/lib/Sidecar/RpcClient.d.ts.map +1 -1
- package/lib/Sidecar/RpcClient.js +8 -5
- package/lib/Sidecar/RpcClient.js.map +1 -1
- package/lib/Sidecar/RpcPaths.d.ts +5 -0
- package/lib/Sidecar/RpcPaths.d.ts.map +1 -1
- package/lib/Sidecar/RpcPaths.js +10 -1
- package/lib/Sidecar/RpcPaths.js.map +1 -1
- package/lib/Sidecar/RpcServer.d.ts +24 -4
- package/lib/Sidecar/RpcServer.d.ts.map +1 -1
- package/lib/Sidecar/RpcServer.js +70 -15
- package/lib/Sidecar/RpcServer.js.map +1 -1
- package/lib/Sidecar/RpcServerBun.d.ts +4 -0
- package/lib/Sidecar/RpcServerBun.d.ts.map +1 -0
- package/lib/Sidecar/RpcServerBun.js +28 -0
- package/lib/Sidecar/RpcServerBun.js.map +1 -0
- package/lib/Sidecar/RpcServerNode.d.ts +4 -0
- package/lib/Sidecar/RpcServerNode.d.ts.map +1 -0
- package/lib/Sidecar/RpcServerNode.js +39 -0
- package/lib/Sidecar/RpcServerNode.js.map +1 -0
- package/lib/Sidecar/RpcServices.d.ts +6 -0
- package/lib/Sidecar/RpcServices.d.ts.map +1 -0
- package/lib/Sidecar/RpcServices.js +29 -0
- package/lib/Sidecar/RpcServices.js.map +1 -0
- package/lib/Stack.d.ts +5 -3
- package/lib/Stack.d.ts.map +1 -1
- package/lib/Stack.js +3 -1
- package/lib/Stack.js.map +1 -1
- package/lib/Test/Core.d.ts.map +1 -1
- package/lib/Test/Core.js +5 -4
- package/lib/Test/Core.js.map +1 -1
- package/lib/Util/PlatformServices.js +1 -1
- package/lib/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +15 -12
- package/src/AWS/AuthProvider.ts +269 -259
- package/src/AWS/Environment.ts +57 -3
- package/src/AWS/IAM/OpenIDConnectProvider.ts +19 -8
- package/src/AWS/IAM/Policy.ts +1 -1
- package/src/AWS/Providers.ts +2 -0
- package/src/Auth/Credentials.ts +82 -46
- package/src/Auth/Profile.ts +123 -69
- package/src/Axiom/AuthProvider.ts +263 -255
- package/src/Axiom/Credentials.ts +3 -4
- package/src/Axiom/Providers.ts +4 -0
- package/src/Cli/LoggingCli.ts +127 -11
- package/src/Cli/checkVersion.ts +57 -0
- package/src/Cli/commands/_shared.ts +4 -4
- package/src/Cli/commands/aws.ts +127 -0
- package/src/Cli/commands/cloudflare.ts +222 -0
- package/src/Cli/commands/deploy.ts +11 -10
- package/src/Cli/commands/dev.ts +28 -33
- package/src/Cli/commands/login.ts +9 -12
- package/src/Cli/commands/logs.ts +8 -8
- package/src/Cli/commands/profile.ts +14 -16
- package/src/Cli/commands/state.ts +8 -8
- package/src/Cli/commands/tail.ts +8 -8
- package/src/Cli/exec.ts +7 -3
- package/src/Cli/main.ts +20 -5
- package/src/Cli/selectCli.ts +33 -0
- package/src/Cloudflare/Auth/AuthProvider.ts +445 -430
- package/src/Cloudflare/CloudflareEnvironment.ts +3 -2
- package/src/Cloudflare/Credentials.ts +3 -4
- package/src/Cloudflare/Local/Sidecar.ts +13 -10
- package/src/Cloudflare/Local/SidecarHandlers.ts +8 -13
- package/src/Cloudflare/Local/SidecarServer.ts +6 -1
- package/src/Cloudflare/Logs.ts +115 -1
- package/src/Cloudflare/Providers.ts +6 -0
- package/src/Cloudflare/Queue/Queue.ts +1 -1
- package/src/Cloudflare/Queue/QueueConsumer.ts +262 -60
- package/src/Cloudflare/Queue/QueueEventSource.ts +234 -0
- package/src/Cloudflare/Queue/index.ts +1 -0
- package/src/Cloudflare/R2/R2Bucket.ts +337 -2
- package/src/Cloudflare/StateStore/State.ts +25 -16
- package/src/Cloudflare/Website/StaticSite.ts +11 -1
- package/src/Cloudflare/Workers/LocalWorkerProvider.ts +9 -1
- package/src/Cloudflare/Workers/Worker.ts +83 -203
- package/src/Cloudflare/Workers/WorkerBundle.ts +38 -12
- package/src/Cloudflare/Zone.ts +88 -0
- package/src/Drizzle/Schema.ts +21 -5
- package/src/GitHub/AuthProvider.ts +221 -217
- package/src/GitHub/Credentials.ts +3 -4
- package/src/GitHub/Providers.ts +4 -0
- package/src/GitHub/Secrets.ts +25 -1
- package/src/GitHub/Variables.ts +54 -0
- package/src/GitHub/index.ts +1 -0
- package/src/Neon/AuthProvider.ts +160 -154
- package/src/Neon/Credentials.ts +3 -4
- package/src/Neon/NeonEnvironment.ts +3 -2
- package/src/Neon/Project.ts +42 -0
- package/src/Neon/Providers.ts +4 -0
- package/src/Neon/api.ts +2 -0
- package/src/Sidecar/RpcClient.ts +8 -7
- package/src/Sidecar/RpcPaths.ts +11 -1
- package/src/Sidecar/RpcServer.ts +97 -24
- package/src/Sidecar/RpcServerBun.ts +41 -0
- package/src/Sidecar/RpcServerNode.ts +51 -0
- package/src/Sidecar/RpcServices.ts +48 -0
- package/src/Stack.ts +8 -0
- package/src/Test/Core.ts +10 -4
- package/src/Util/PlatformServices.ts +1 -1
- package/lib/Cli/commands/bootstrap.d.ts +0 -20
- package/lib/Cli/commands/bootstrap.d.ts.map +0 -1
- package/lib/Cli/commands/bootstrap.js +0 -107
- package/lib/Cli/commands/bootstrap.js.map +0 -1
- package/lib/Sidecar/RpcTransport.d.ts +0 -22
- package/lib/Sidecar/RpcTransport.d.ts.map +0 -1
- package/lib/Sidecar/RpcTransport.js +0 -81
- package/lib/Sidecar/RpcTransport.js.map +0 -1
- package/lib/Test/TestCli.d.ts +0 -19
- package/lib/Test/TestCli.d.ts.map +0 -1
- package/lib/Test/TestCli.js +0 -175
- package/lib/Test/TestCli.js.map +0 -1
- package/src/Cli/commands/bootstrap.ts +0 -216
- package/src/Sidecar/RpcTransport.ts +0 -85
- package/src/Test/TestCli.ts +0 -221
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alchemy",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.35",
|
|
4
4
|
"homepage": "https://alchemy.run",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Sam Goodwin <sam@alchemy.run>",
|
|
@@ -275,14 +275,14 @@
|
|
|
275
275
|
"@ai-sdk/provider": "^3.0.8",
|
|
276
276
|
"@aws-sdk/credential-providers": "^3.0.0",
|
|
277
277
|
"@clack/prompts": "^0.11.0",
|
|
278
|
-
"@distilled.cloud/aws": "^0.
|
|
279
|
-
"@distilled.cloud/axiom": "^0.
|
|
280
|
-
"@distilled.cloud/cloudflare": "^0.
|
|
278
|
+
"@distilled.cloud/aws": "^0.19.0",
|
|
279
|
+
"@distilled.cloud/axiom": "^0.19.0",
|
|
280
|
+
"@distilled.cloud/cloudflare": "^0.19.0",
|
|
281
281
|
"@distilled.cloud/cloudflare-rolldown-plugin": "0.3.0",
|
|
282
|
-
"@distilled.cloud/cloudflare-runtime": "0.2
|
|
282
|
+
"@distilled.cloud/cloudflare-runtime": "0.3.2",
|
|
283
283
|
"@distilled.cloud/cloudflare-vite-plugin": "0.2.0",
|
|
284
|
-
"@distilled.cloud/core": "^0.
|
|
285
|
-
"@distilled.cloud/neon": "^0.
|
|
284
|
+
"@distilled.cloud/core": "^0.19.0",
|
|
285
|
+
"@distilled.cloud/neon": "^0.19.0",
|
|
286
286
|
"pg": "^8.13.0",
|
|
287
287
|
"@effect/vitest": ">=4.0.0-beta.60 || >=4.0.0",
|
|
288
288
|
"@libsql/client": "^0.17.0",
|
|
@@ -294,9 +294,7 @@
|
|
|
294
294
|
"@types/libsodium-wrappers": "^0.8.2",
|
|
295
295
|
"ai": "^6.0.62",
|
|
296
296
|
"aws4fetch": "^1.0.20",
|
|
297
|
-
"capnp-es": "^0.0.14",
|
|
298
297
|
"capnweb": "^0.6.1",
|
|
299
|
-
"cloudflare": "^5.2.0",
|
|
300
298
|
"fast-glob": "^3.3.2",
|
|
301
299
|
"fast-xml-parser": "^5.3.4",
|
|
302
300
|
"foreground-child": "^4.0.3",
|
|
@@ -312,7 +310,6 @@
|
|
|
312
310
|
"rolldown": "1.0.0-rc.17",
|
|
313
311
|
"sonda": "^0.11.1",
|
|
314
312
|
"web-tree-sitter": "0.25.10",
|
|
315
|
-
"workerd": "1.20260417.1",
|
|
316
313
|
"yaml": "^2.0.0"
|
|
317
314
|
},
|
|
318
315
|
"devDependencies": {
|
|
@@ -329,6 +326,7 @@
|
|
|
329
326
|
"@types/picomatch": "^4.0.0",
|
|
330
327
|
"@types/proper-lockfile": "^4.1.4",
|
|
331
328
|
"@types/react": "^19.2.2",
|
|
329
|
+
"@types/ws": "^8.18.1",
|
|
332
330
|
"better-auth": "^1.6.2",
|
|
333
331
|
"effect": ">=4.0.0-beta.60 || >=4.0.0",
|
|
334
332
|
"react-devtools-core": "^7.0.1",
|
|
@@ -336,7 +334,8 @@
|
|
|
336
334
|
"tsconfig-paths": "^4.2.0",
|
|
337
335
|
"tsdown": "^0.15.4",
|
|
338
336
|
"tsx": "^4.20.6",
|
|
339
|
-
"typescript": "^6.0.3"
|
|
337
|
+
"typescript": "^6.0.3",
|
|
338
|
+
"ws": "^8.20.0"
|
|
340
339
|
},
|
|
341
340
|
"peerDependencies": {
|
|
342
341
|
"@effect/platform-bun": ">=4.0.0-beta.60 || >=4.0.0",
|
|
@@ -345,7 +344,8 @@
|
|
|
345
344
|
"drizzle-kit": ">=1.0.0-rc.1",
|
|
346
345
|
"drizzle-orm": ">=1.0.0-rc.1",
|
|
347
346
|
"effect": ">=4.0.0-beta.60 || >=4.0.0",
|
|
348
|
-
"vite": "^8.0.7"
|
|
347
|
+
"vite": "^8.0.7",
|
|
348
|
+
"ws": "^8.20.0"
|
|
349
349
|
},
|
|
350
350
|
"peerDependenciesMeta": {
|
|
351
351
|
"@effect/platform-node": {
|
|
@@ -365,6 +365,9 @@
|
|
|
365
365
|
},
|
|
366
366
|
"vite": {
|
|
367
367
|
"optional": true
|
|
368
|
+
},
|
|
369
|
+
"ws": {
|
|
370
|
+
"optional": true
|
|
368
371
|
}
|
|
369
372
|
}
|
|
370
373
|
}
|
package/src/AWS/AuthProvider.ts
CHANGED
|
@@ -13,12 +13,7 @@ import {
|
|
|
13
13
|
AuthProviderLayer,
|
|
14
14
|
type ConfigureContext,
|
|
15
15
|
} from "../Auth/AuthProvider.ts";
|
|
16
|
-
import {
|
|
17
|
-
deleteCredentials,
|
|
18
|
-
displayRedacted,
|
|
19
|
-
readCredentials,
|
|
20
|
-
writeCredentials,
|
|
21
|
-
} from "../Auth/Credentials.ts";
|
|
16
|
+
import { CredentialsStore, displayRedacted } from "../Auth/Credentials.ts";
|
|
22
17
|
import {
|
|
23
18
|
getEnv,
|
|
24
19
|
getEnvRedacted,
|
|
@@ -29,22 +24,6 @@ import * as Clank from "../Util/Clank.ts";
|
|
|
29
24
|
|
|
30
25
|
export const AWS_AUTH_PROVIDER_NAME = "AWS";
|
|
31
26
|
|
|
32
|
-
/**
|
|
33
|
-
* Layer that registers the AWS {@link AuthProvider} into the
|
|
34
|
-
* {@link AuthProviders} registry when built. Include this in the AWS
|
|
35
|
-
* `providers()` layer so `alchemy login` can discover it.
|
|
36
|
-
*/
|
|
37
|
-
export const AwsAuth = AuthProviderLayer<
|
|
38
|
-
AwsAuthConfig,
|
|
39
|
-
AwsResolvedCredentials
|
|
40
|
-
>()(AWS_AUTH_PROVIDER_NAME, {
|
|
41
|
-
configure: (profileName, ctx) => configureCredentials(profileName, ctx),
|
|
42
|
-
login: (profileName, config) => login(profileName, config),
|
|
43
|
-
logout: (profileName, config) => logout(profileName, config),
|
|
44
|
-
prettyPrint: (profileName, config) => prettyPrint(profileName, config),
|
|
45
|
-
read: (profileName, config) => resolveCredentials(profileName, config),
|
|
46
|
-
});
|
|
47
|
-
|
|
48
27
|
export type AwsAuthConfig =
|
|
49
28
|
| { method: "sso"; ssoProfile: string }
|
|
50
29
|
| { method: "stored" }
|
|
@@ -112,111 +91,15 @@ const runSsoCommand = (command: "login" | "logout", ssoProfile: string) =>
|
|
|
112
91
|
}
|
|
113
92
|
}).pipe(Effect.scoped);
|
|
114
93
|
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
.
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
"AWS_SECRET_ACCESS_KEY",
|
|
125
|
-
);
|
|
126
|
-
const sessionToken = yield* getEnvRedacted("AWS_SESSION_TOKEN");
|
|
127
|
-
const region = yield* (
|
|
128
|
-
getEnv("AWS_REGION") ?? getEnv("AWS_DEFAULT_REGION") ?? undefined
|
|
129
|
-
);
|
|
130
|
-
return {
|
|
131
|
-
accessKeyId,
|
|
132
|
-
secretAccessKey,
|
|
133
|
-
sessionToken,
|
|
134
|
-
region,
|
|
135
|
-
source: { type: "env" as const },
|
|
136
|
-
};
|
|
137
|
-
}),
|
|
138
|
-
),
|
|
139
|
-
Match.when({ method: "stored" }, () =>
|
|
140
|
-
readCredentials<AwsStoredCredentials>(profileName, "aws").pipe(
|
|
141
|
-
Effect.flatMap((creds) =>
|
|
142
|
-
creds == null
|
|
143
|
-
? Effect.fail(
|
|
144
|
-
new AuthError({
|
|
145
|
-
message:
|
|
146
|
-
"AWS stored credentials not found. Run: alchemy-effect login --configure",
|
|
147
|
-
}),
|
|
148
|
-
)
|
|
149
|
-
: Effect.succeed({
|
|
150
|
-
accessKeyId: Redacted.make(creds.accessKeyId),
|
|
151
|
-
secretAccessKey: Redacted.make(creds.secretAccessKey),
|
|
152
|
-
sessionToken: creds.sessionToken
|
|
153
|
-
? Redacted.make(creds.sessionToken)
|
|
154
|
-
: undefined,
|
|
155
|
-
region: creds.region,
|
|
156
|
-
source: { type: "stored" as const },
|
|
157
|
-
}),
|
|
158
|
-
),
|
|
159
|
-
),
|
|
160
|
-
),
|
|
161
|
-
Match.when({ method: "sso" }, (config) =>
|
|
162
|
-
Effect.gen(function* () {
|
|
163
|
-
const auth = yield* DistilledAuth.Default;
|
|
164
|
-
const creds = yield* auth
|
|
165
|
-
.loadProfileCredentials(config.ssoProfile)
|
|
166
|
-
.pipe(
|
|
167
|
-
Effect.mapError(
|
|
168
|
-
(e) =>
|
|
169
|
-
new AuthError({
|
|
170
|
-
message: "failed to load credentials",
|
|
171
|
-
cause: e,
|
|
172
|
-
}),
|
|
173
|
-
),
|
|
174
|
-
);
|
|
175
|
-
const profile = yield* auth
|
|
176
|
-
.loadProfile(config.ssoProfile)
|
|
177
|
-
.pipe(Effect.catch(() => Effect.succeed(undefined)));
|
|
178
|
-
return {
|
|
179
|
-
accessKeyId: creds.accessKeyId,
|
|
180
|
-
secretAccessKey: creds.secretAccessKey,
|
|
181
|
-
sessionToken: creds.sessionToken,
|
|
182
|
-
region: profile?.region,
|
|
183
|
-
source: { type: "sso" as const, details: config.ssoProfile },
|
|
184
|
-
};
|
|
185
|
-
}),
|
|
186
|
-
),
|
|
187
|
-
Match.exhaustive,
|
|
188
|
-
)
|
|
189
|
-
.pipe(
|
|
190
|
-
Effect.mapError(
|
|
191
|
-
(e) => new AuthError({ message: "login failed", cause: e }),
|
|
192
|
-
),
|
|
193
|
-
);
|
|
194
|
-
|
|
195
|
-
const prettyPrint = (profileName: string, config: AwsAuthConfig) =>
|
|
196
|
-
resolveCredentials(profileName, config).pipe(
|
|
197
|
-
Effect.tap((creds) =>
|
|
198
|
-
Effect.all([
|
|
199
|
-
Console.log(` accessKeyId: ${displayRedacted(creds.accessKeyId)}`),
|
|
200
|
-
Console.log(
|
|
201
|
-
` secretAccessKey: ${displayRedacted(creds.secretAccessKey)}`,
|
|
202
|
-
),
|
|
203
|
-
creds.sessionToken
|
|
204
|
-
? Console.log(
|
|
205
|
-
` sessionToken: ${displayRedacted(creds.sessionToken)}`,
|
|
206
|
-
)
|
|
207
|
-
: Effect.void,
|
|
208
|
-
creds.region
|
|
209
|
-
? Console.log(` region: ${creds.region}`)
|
|
210
|
-
: Effect.void,
|
|
211
|
-
Console.log(
|
|
212
|
-
//@ts-expect-error
|
|
213
|
-
` source: ${creds.source.details ? `${creds.source.type} - ${creds.source.details}` : creds.source.type}`,
|
|
214
|
-
),
|
|
215
|
-
]),
|
|
216
|
-
),
|
|
217
|
-
Effect.catch((e) =>
|
|
218
|
-
Console.error(` Failed to retrieve credentials: ${e}`),
|
|
219
|
-
),
|
|
94
|
+
const loginSSO = (config: Extract<AwsAuthConfig, { method: "sso" }>) =>
|
|
95
|
+
Clank.info(
|
|
96
|
+
`AWS SSO: running 'aws sso login --profile ${config.ssoProfile}'...`,
|
|
97
|
+
).pipe(
|
|
98
|
+
Effect.andThen(runSsoCommand("login", config.ssoProfile)),
|
|
99
|
+
Effect.matchEffect({
|
|
100
|
+
onSuccess: () => Clank.success("AWS SSO: login complete"),
|
|
101
|
+
onFailure: (e) => Clank.warn(`AWS SSO: login faield: \`${e.message}\``),
|
|
102
|
+
}),
|
|
220
103
|
);
|
|
221
104
|
|
|
222
105
|
/**
|
|
@@ -245,148 +128,275 @@ const clearDistilledSsoCache = (ssoProfile: string) =>
|
|
|
245
128
|
yield* fs.remove(cacheFile).pipe(Effect.catch(() => Effect.void));
|
|
246
129
|
}).pipe(Effect.catch(() => Effect.void));
|
|
247
130
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
Clank.warn(`AWS: SSO logout failed: \`${e.message}\``),
|
|
261
|
-
}),
|
|
262
|
-
),
|
|
263
|
-
),
|
|
264
|
-
Match.when({ method: "stored" }, () =>
|
|
265
|
-
deleteCredentials(profileName, "aws").pipe(
|
|
266
|
-
Effect.andThen(Clank.success("AWS: stored credentials removed")),
|
|
267
|
-
),
|
|
268
|
-
),
|
|
269
|
-
Match.exhaustive,
|
|
270
|
-
);
|
|
131
|
+
/**
|
|
132
|
+
* Layer that registers the AWS {@link AuthProvider} into the
|
|
133
|
+
* {@link AuthProviders} registry when built. Include this in the AWS
|
|
134
|
+
* `providers()` layer so `alchemy login` can discover it.
|
|
135
|
+
*/
|
|
136
|
+
export const AwsAuth = AuthProviderLayer<
|
|
137
|
+
AwsAuthConfig,
|
|
138
|
+
AwsResolvedCredentials
|
|
139
|
+
>()(
|
|
140
|
+
AWS_AUTH_PROVIDER_NAME,
|
|
141
|
+
Effect.gen(function* () {
|
|
142
|
+
const store = yield* CredentialsStore;
|
|
271
143
|
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
DistilledAuth.loadProfileCredentials(config.ssoProfile).pipe(
|
|
278
|
-
Effect.matchEffect({
|
|
279
|
-
onSuccess: () =>
|
|
280
|
-
Clank.info(
|
|
281
|
-
`AWS: SSO profile '${config.ssoProfile}' already has valid credentials`,
|
|
282
|
-
),
|
|
283
|
-
onFailure: () => loginSSO(config),
|
|
284
|
-
}),
|
|
285
|
-
),
|
|
286
|
-
),
|
|
287
|
-
Match.when({ method: "stored" }, () =>
|
|
288
|
-
readCredentials<AwsStoredCredentials>(profileName, "aws").pipe(
|
|
289
|
-
Effect.flatMap((creds) =>
|
|
290
|
-
creds == null ? loginStored(profileName) : Effect.void,
|
|
291
|
-
),
|
|
292
|
-
),
|
|
293
|
-
),
|
|
294
|
-
Match.exhaustive,
|
|
295
|
-
)
|
|
296
|
-
.pipe(
|
|
297
|
-
Effect.mapError(
|
|
298
|
-
(e) => new AuthError({ message: "login failed", cause: e }),
|
|
299
|
-
),
|
|
300
|
-
);
|
|
144
|
+
const loginStored = Effect.fnUntraced(function* (profileName: string) {
|
|
145
|
+
const accessKeyId = yield* Clank.text({
|
|
146
|
+
message: "AWS Access Key ID",
|
|
147
|
+
validate: (v) => (v.length === 0 ? "Required" : undefined),
|
|
148
|
+
}).pipe(retryOnce);
|
|
301
149
|
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
}
|
|
307
|
-
return yield* configureInteractive(profileName);
|
|
308
|
-
}).pipe(
|
|
309
|
-
Effect.mapError(
|
|
310
|
-
(e) =>
|
|
311
|
-
new AuthError({
|
|
312
|
-
message: "failed to configure credentials",
|
|
313
|
-
cause: e,
|
|
314
|
-
}),
|
|
315
|
-
),
|
|
316
|
-
);
|
|
150
|
+
const secretAccessKey = yield* Clank.password({
|
|
151
|
+
message: "AWS Secret Access Key",
|
|
152
|
+
validate: (v) => (v.length === 0 ? "Required" : undefined),
|
|
153
|
+
}).pipe(retryOnce);
|
|
317
154
|
|
|
318
|
-
const
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
}).pipe(
|
|
323
|
-
Effect.flatMap((method) =>
|
|
324
|
-
Match.value(method).pipe(
|
|
325
|
-
Match.when("env", () => Effect.succeed({ method: "env" as const })),
|
|
326
|
-
Match.when("sso", () =>
|
|
327
|
-
Effect.gen(function* () {
|
|
328
|
-
const ssoProfile = yield* Clank.text({
|
|
329
|
-
message: "AWS profile name (from ~/.aws/config)",
|
|
330
|
-
placeholder: "default",
|
|
331
|
-
defaultValue: "default",
|
|
332
|
-
});
|
|
155
|
+
const sessionToken = yield* Clank.text({
|
|
156
|
+
message: "AWS Session Token (optional — press Enter or Esc to skip)",
|
|
157
|
+
placeholder: "(none)",
|
|
158
|
+
}).pipe(Effect.catch(() => Effect.succeed("")));
|
|
333
159
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
160
|
+
const region = yield* Clank.text({
|
|
161
|
+
message: "AWS Region",
|
|
162
|
+
placeholder: "us-east-1",
|
|
163
|
+
defaultValue: "us-east-1",
|
|
164
|
+
}).pipe(retryOnce);
|
|
338
165
|
|
|
339
|
-
|
|
166
|
+
yield* store.write<AwsStoredCredentials>(profileName, "aws", {
|
|
167
|
+
accessKeyId,
|
|
168
|
+
secretAccessKey,
|
|
169
|
+
sessionToken,
|
|
170
|
+
region,
|
|
171
|
+
});
|
|
172
|
+
yield* Clank.success("AWS credentials saved.");
|
|
340
173
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
),
|
|
344
|
-
Match.when("stored", () => loginStored(profileName)),
|
|
345
|
-
Match.exhaustive,
|
|
346
|
-
),
|
|
347
|
-
),
|
|
348
|
-
);
|
|
174
|
+
return { method: "stored" as const };
|
|
175
|
+
});
|
|
349
176
|
|
|
350
|
-
const
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
177
|
+
const configureInteractive = (profileName: string) =>
|
|
178
|
+
Clank.select({
|
|
179
|
+
message: "AWS authentication method",
|
|
180
|
+
options,
|
|
181
|
+
}).pipe(
|
|
182
|
+
Effect.flatMap((method) =>
|
|
183
|
+
Match.value(method).pipe(
|
|
184
|
+
Match.when("env", () => Effect.succeed({ method: "env" as const })),
|
|
185
|
+
Match.when("sso", () =>
|
|
186
|
+
Effect.gen(function* () {
|
|
187
|
+
const ssoProfile = yield* Clank.text({
|
|
188
|
+
message: "AWS profile name (from ~/.aws/config)",
|
|
189
|
+
placeholder: "default",
|
|
190
|
+
defaultValue: "default",
|
|
191
|
+
});
|
|
360
192
|
|
|
361
|
-
const
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
}).pipe(retryOnce);
|
|
193
|
+
const config = {
|
|
194
|
+
method: "sso" as const,
|
|
195
|
+
ssoProfile: ssoProfile ?? "default",
|
|
196
|
+
};
|
|
366
197
|
|
|
367
|
-
|
|
368
|
-
message: "AWS Secret Access Key",
|
|
369
|
-
validate: (v) => (v.length === 0 ? "Required" : undefined),
|
|
370
|
-
}).pipe(retryOnce);
|
|
198
|
+
yield* loginSSO(config);
|
|
371
199
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
200
|
+
return config;
|
|
201
|
+
}),
|
|
202
|
+
),
|
|
203
|
+
Match.when("stored", () => loginStored(profileName)),
|
|
204
|
+
Match.exhaustive,
|
|
205
|
+
),
|
|
206
|
+
),
|
|
207
|
+
);
|
|
376
208
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
209
|
+
const configureCredentials = (profileName: string, ctx: ConfigureContext) =>
|
|
210
|
+
Effect.gen(function* () {
|
|
211
|
+
if (ctx.ci) {
|
|
212
|
+
return { method: "env" as const };
|
|
213
|
+
}
|
|
214
|
+
return yield* configureInteractive(profileName);
|
|
215
|
+
}).pipe(
|
|
216
|
+
Effect.mapError(
|
|
217
|
+
(e) =>
|
|
218
|
+
new AuthError({
|
|
219
|
+
message: "failed to configure credentials",
|
|
220
|
+
cause: e,
|
|
221
|
+
}),
|
|
222
|
+
),
|
|
223
|
+
);
|
|
382
224
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
225
|
+
const resolveCredentials = (profileName: string, config: AwsAuthConfig) =>
|
|
226
|
+
Match.value(config)
|
|
227
|
+
.pipe(
|
|
228
|
+
Match.when(
|
|
229
|
+
{ method: "env" },
|
|
230
|
+
Effect.fnUntraced(function* () {
|
|
231
|
+
const accessKeyId =
|
|
232
|
+
yield* getEnvRedactedRequired("AWS_ACCESS_KEY_ID");
|
|
233
|
+
const secretAccessKey = yield* getEnvRedactedRequired(
|
|
234
|
+
"AWS_SECRET_ACCESS_KEY",
|
|
235
|
+
);
|
|
236
|
+
const sessionToken = yield* getEnvRedacted("AWS_SESSION_TOKEN");
|
|
237
|
+
const region = yield* (
|
|
238
|
+
getEnv("AWS_REGION") ??
|
|
239
|
+
getEnv("AWS_DEFAULT_REGION") ??
|
|
240
|
+
undefined
|
|
241
|
+
);
|
|
242
|
+
return {
|
|
243
|
+
accessKeyId,
|
|
244
|
+
secretAccessKey,
|
|
245
|
+
sessionToken,
|
|
246
|
+
region,
|
|
247
|
+
source: { type: "env" as const },
|
|
248
|
+
};
|
|
249
|
+
}),
|
|
250
|
+
),
|
|
251
|
+
Match.when({ method: "stored" }, () =>
|
|
252
|
+
store.read<AwsStoredCredentials>(profileName, "aws").pipe(
|
|
253
|
+
Effect.flatMap((creds) =>
|
|
254
|
+
creds == null
|
|
255
|
+
? Effect.fail(
|
|
256
|
+
new AuthError({
|
|
257
|
+
message:
|
|
258
|
+
"AWS stored credentials not found. Run: alchemy-effect login --configure",
|
|
259
|
+
}),
|
|
260
|
+
)
|
|
261
|
+
: Effect.succeed({
|
|
262
|
+
accessKeyId: Redacted.make(creds.accessKeyId),
|
|
263
|
+
secretAccessKey: Redacted.make(creds.secretAccessKey),
|
|
264
|
+
sessionToken: creds.sessionToken
|
|
265
|
+
? Redacted.make(creds.sessionToken)
|
|
266
|
+
: undefined,
|
|
267
|
+
region: creds.region,
|
|
268
|
+
source: { type: "stored" as const },
|
|
269
|
+
}),
|
|
270
|
+
),
|
|
271
|
+
),
|
|
272
|
+
),
|
|
273
|
+
Match.when({ method: "sso" }, (config) =>
|
|
274
|
+
Effect.gen(function* () {
|
|
275
|
+
const auth = yield* DistilledAuth.Default;
|
|
276
|
+
const creds = yield* auth
|
|
277
|
+
.loadProfileCredentials(config.ssoProfile)
|
|
278
|
+
.pipe(
|
|
279
|
+
Effect.mapError(
|
|
280
|
+
(e) =>
|
|
281
|
+
new AuthError({
|
|
282
|
+
message: "failed to load credentials",
|
|
283
|
+
cause: e,
|
|
284
|
+
}),
|
|
285
|
+
),
|
|
286
|
+
);
|
|
287
|
+
const profile = yield* auth
|
|
288
|
+
.loadProfile(config.ssoProfile)
|
|
289
|
+
.pipe(Effect.catch(() => Effect.succeed(undefined)));
|
|
290
|
+
return {
|
|
291
|
+
accessKeyId: creds.accessKeyId,
|
|
292
|
+
secretAccessKey: creds.secretAccessKey,
|
|
293
|
+
sessionToken: creds.sessionToken,
|
|
294
|
+
region: profile?.region,
|
|
295
|
+
source: { type: "sso" as const, details: config.ssoProfile },
|
|
296
|
+
};
|
|
297
|
+
}),
|
|
298
|
+
),
|
|
299
|
+
Match.exhaustive,
|
|
300
|
+
)
|
|
301
|
+
.pipe(
|
|
302
|
+
Effect.mapError(
|
|
303
|
+
(e) => new AuthError({ message: "login failed", cause: e }),
|
|
304
|
+
),
|
|
305
|
+
);
|
|
306
|
+
|
|
307
|
+
const prettyPrint = (profileName: string, config: AwsAuthConfig) =>
|
|
308
|
+
resolveCredentials(profileName, config).pipe(
|
|
309
|
+
Effect.tap((creds) =>
|
|
310
|
+
Effect.all([
|
|
311
|
+
Console.log(
|
|
312
|
+
` accessKeyId: ${displayRedacted(creds.accessKeyId)}`,
|
|
313
|
+
),
|
|
314
|
+
Console.log(
|
|
315
|
+
` secretAccessKey: ${displayRedacted(creds.secretAccessKey)}`,
|
|
316
|
+
),
|
|
317
|
+
creds.sessionToken
|
|
318
|
+
? Console.log(
|
|
319
|
+
` sessionToken: ${displayRedacted(creds.sessionToken)}`,
|
|
320
|
+
)
|
|
321
|
+
: Effect.void,
|
|
322
|
+
creds.region
|
|
323
|
+
? Console.log(` region: ${creds.region}`)
|
|
324
|
+
: Effect.void,
|
|
325
|
+
Console.log(
|
|
326
|
+
//@ts-expect-error
|
|
327
|
+
` source: ${creds.source.details ? `${creds.source.type} - ${creds.source.details}` : creds.source.type}`,
|
|
328
|
+
),
|
|
329
|
+
]),
|
|
330
|
+
),
|
|
331
|
+
Effect.catch((e) =>
|
|
332
|
+
Console.error(` Failed to retrieve credentials: ${e}`),
|
|
333
|
+
),
|
|
334
|
+
);
|
|
335
|
+
|
|
336
|
+
const logout = (profileName: string, config: AwsAuthConfig) =>
|
|
337
|
+
Match.value(config).pipe(
|
|
338
|
+
Match.when({ method: "env" }, () => Effect.void),
|
|
339
|
+
Match.when({ method: "sso" }, (config) =>
|
|
340
|
+
Clank.info(
|
|
341
|
+
`AWS: running 'aws sso logout --profile ${config.ssoProfile}'...`,
|
|
342
|
+
).pipe(
|
|
343
|
+
Effect.zip(runSsoCommand("logout", config.ssoProfile)),
|
|
344
|
+
Effect.zip(clearDistilledSsoCache(config.ssoProfile)),
|
|
345
|
+
Effect.match({
|
|
346
|
+
onSuccess: () => Clank.success("AWS: SSO logout complete"),
|
|
347
|
+
onFailure: (e) =>
|
|
348
|
+
Clank.warn(`AWS: SSO logout failed: \`${e.message}\``),
|
|
349
|
+
}),
|
|
350
|
+
),
|
|
351
|
+
),
|
|
352
|
+
Match.when({ method: "stored" }, () =>
|
|
353
|
+
store
|
|
354
|
+
.delete(profileName, "aws")
|
|
355
|
+
.pipe(
|
|
356
|
+
Effect.andThen(Clank.success("AWS: stored credentials removed")),
|
|
357
|
+
),
|
|
358
|
+
),
|
|
359
|
+
Match.exhaustive,
|
|
360
|
+
);
|
|
361
|
+
|
|
362
|
+
const login = (profileName: string, config: AwsAuthConfig) =>
|
|
363
|
+
Match.value(config)
|
|
364
|
+
.pipe(
|
|
365
|
+
Match.when({ method: "env" }, () => Effect.void),
|
|
366
|
+
Match.when({ method: "sso" }, (config) =>
|
|
367
|
+
DistilledAuth.loadProfileCredentials(config.ssoProfile).pipe(
|
|
368
|
+
Effect.matchEffect({
|
|
369
|
+
onSuccess: () =>
|
|
370
|
+
Clank.info(
|
|
371
|
+
`AWS: SSO profile '${config.ssoProfile}' already has valid credentials`,
|
|
372
|
+
),
|
|
373
|
+
onFailure: () => loginSSO(config),
|
|
374
|
+
}),
|
|
375
|
+
),
|
|
376
|
+
),
|
|
377
|
+
Match.when({ method: "stored" }, () =>
|
|
378
|
+
store
|
|
379
|
+
.read<AwsStoredCredentials>(profileName, "aws")
|
|
380
|
+
.pipe(
|
|
381
|
+
Effect.flatMap((creds) =>
|
|
382
|
+
creds == null ? loginStored(profileName) : Effect.void,
|
|
383
|
+
),
|
|
384
|
+
),
|
|
385
|
+
),
|
|
386
|
+
Match.exhaustive,
|
|
387
|
+
)
|
|
388
|
+
.pipe(
|
|
389
|
+
Effect.mapError(
|
|
390
|
+
(e) => new AuthError({ message: "login failed", cause: e }),
|
|
391
|
+
),
|
|
392
|
+
);
|
|
390
393
|
|
|
391
|
-
|
|
392
|
-
|
|
394
|
+
return {
|
|
395
|
+
configure: configureCredentials,
|
|
396
|
+
login,
|
|
397
|
+
logout,
|
|
398
|
+
prettyPrint,
|
|
399
|
+
read: resolveCredentials,
|
|
400
|
+
};
|
|
401
|
+
}),
|
|
402
|
+
);
|