alchemy 0.66.0 → 0.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/alchemy.js +25554 -26250
- package/bin/alchemy.ts +6 -2
- package/bin/commands/configure.ts +194 -0
- package/bin/commands/login.ts +99 -55
- package/bin/commands/logout.ts +66 -0
- package/bin/services/find-workspace-root.ts +1 -1
- package/bin/trpc.ts +27 -2
- package/lib/alchemy.d.ts +6 -0
- package/lib/alchemy.d.ts.map +1 -1
- package/lib/alchemy.js +1 -0
- package/lib/alchemy.js.map +1 -1
- package/lib/apply.d.ts +2 -2
- package/lib/apply.d.ts.map +1 -1
- package/lib/apply.js +18 -15
- package/lib/apply.js.map +1 -1
- package/lib/auth.d.ts +72 -0
- package/lib/auth.d.ts.map +1 -0
- package/lib/auth.js +163 -0
- package/lib/auth.js.map +1 -0
- package/lib/aws/bucket.d.ts +12 -3
- package/lib/aws/bucket.d.ts.map +1 -1
- package/lib/aws/bucket.js +2 -2
- package/lib/aws/bucket.js.map +1 -1
- package/lib/aws/control/resource.d.ts +34 -3
- package/lib/aws/control/resource.d.ts.map +1 -1
- package/lib/aws/control/resource.js +3 -3
- package/lib/aws/control/resource.js.map +1 -1
- package/lib/aws/ec2/internet-gateway-attachment.d.ts +1 -2
- package/lib/aws/ec2/internet-gateway-attachment.d.ts.map +1 -1
- package/lib/aws/ec2/internet-gateway-attachment.js +4 -4
- package/lib/aws/ec2/internet-gateway-attachment.js.map +1 -1
- package/lib/aws/ec2/internet-gateway.d.ts +1 -2
- package/lib/aws/ec2/internet-gateway.d.ts.map +1 -1
- package/lib/aws/ec2/internet-gateway.js +2 -2
- package/lib/aws/ec2/internet-gateway.js.map +1 -1
- package/lib/aws/ec2/nat-gateway.d.ts +1 -2
- package/lib/aws/ec2/nat-gateway.d.ts.map +1 -1
- package/lib/aws/ec2/nat-gateway.js +2 -2
- package/lib/aws/ec2/nat-gateway.js.map +1 -1
- package/lib/aws/ec2/route-table-association.d.ts +1 -2
- package/lib/aws/ec2/route-table-association.d.ts.map +1 -1
- package/lib/aws/ec2/route-table-association.js +2 -2
- package/lib/aws/ec2/route-table-association.js.map +1 -1
- package/lib/aws/ec2/route-table.d.ts +1 -2
- package/lib/aws/ec2/route-table.d.ts.map +1 -1
- package/lib/aws/ec2/route-table.js +2 -2
- package/lib/aws/ec2/route-table.js.map +1 -1
- package/lib/aws/ec2/route.d.ts +1 -2
- package/lib/aws/ec2/route.d.ts.map +1 -1
- package/lib/aws/ec2/route.js +2 -2
- package/lib/aws/ec2/route.js.map +1 -1
- package/lib/aws/ec2/security-group-rule.d.ts +1 -2
- package/lib/aws/ec2/security-group-rule.d.ts.map +1 -1
- package/lib/aws/ec2/security-group-rule.js +2 -2
- package/lib/aws/ec2/security-group-rule.js.map +1 -1
- package/lib/aws/ec2/security-group.d.ts +1 -2
- package/lib/aws/ec2/security-group.d.ts.map +1 -1
- package/lib/aws/ec2/security-group.js +2 -2
- package/lib/aws/ec2/security-group.js.map +1 -1
- package/lib/aws/ec2/subnet.d.ts +1 -2
- package/lib/aws/ec2/subnet.d.ts.map +1 -1
- package/lib/aws/ec2/subnet.js +2 -2
- package/lib/aws/ec2/subnet.js.map +1 -1
- package/lib/aws/ec2/vpc.d.ts +1 -2
- package/lib/aws/ec2/vpc.d.ts.map +1 -1
- package/lib/aws/ec2/vpc.js +2 -2
- package/lib/aws/ec2/vpc.js.map +1 -1
- package/lib/aws/function.d.ts +116 -3
- package/lib/aws/function.d.ts.map +1 -1
- package/lib/aws/function.js +2 -2
- package/lib/aws/function.js.map +1 -1
- package/lib/aws/oidc/github-oidc-provider.d.ts +13 -2
- package/lib/aws/oidc/github-oidc-provider.d.ts.map +1 -1
- package/lib/aws/oidc/oidc-provider.d.ts +48 -3
- package/lib/aws/oidc/oidc-provider.d.ts.map +1 -1
- package/lib/aws/oidc/oidc-provider.js +2 -2
- package/lib/aws/oidc/oidc-provider.js.map +1 -1
- package/lib/aws/policy-attachment.d.ts +2 -3
- package/lib/aws/policy-attachment.d.ts.map +1 -1
- package/lib/aws/policy-attachment.js +1 -1
- package/lib/aws/policy-attachment.js.map +1 -1
- package/lib/aws/policy.d.ts +1 -2
- package/lib/aws/policy.d.ts.map +1 -1
- package/lib/aws/policy.js +4 -4
- package/lib/aws/policy.js.map +1 -1
- package/lib/aws/queue.d.ts +1 -2
- package/lib/aws/queue.d.ts.map +1 -1
- package/lib/aws/queue.js +4 -4
- package/lib/aws/queue.js.map +1 -1
- package/lib/aws/role.d.ts +1 -2
- package/lib/aws/role.d.ts.map +1 -1
- package/lib/aws/role.js +2 -2
- package/lib/aws/role.js.map +1 -1
- package/lib/aws/ses.d.ts +1 -2
- package/lib/aws/ses.d.ts.map +1 -1
- package/lib/aws/ses.js +2 -2
- package/lib/aws/ses.js.map +1 -1
- package/lib/aws/ssm-parameter.d.ts +1 -2
- package/lib/aws/ssm-parameter.d.ts.map +1 -1
- package/lib/aws/ssm-parameter.js +2 -2
- package/lib/aws/ssm-parameter.js.map +1 -1
- package/lib/aws/table.d.ts +1 -2
- package/lib/aws/table.d.ts.map +1 -1
- package/lib/aws/table.js +2 -2
- package/lib/aws/table.js.map +1 -1
- package/lib/cloudflare/account-api-token.d.ts +1 -2
- package/lib/cloudflare/account-api-token.d.ts.map +1 -1
- package/lib/cloudflare/account-api-token.js +2 -2
- package/lib/cloudflare/account-api-token.js.map +1 -1
- package/lib/cloudflare/ai-gateway.d.ts +1 -2
- package/lib/cloudflare/ai-gateway.d.ts.map +1 -1
- package/lib/cloudflare/ai-gateway.js +2 -2
- package/lib/cloudflare/ai-gateway.js.map +1 -1
- package/lib/cloudflare/api-gateway-operation.d.ts +1 -2
- package/lib/cloudflare/api-gateway-operation.d.ts.map +1 -1
- package/lib/cloudflare/api-gateway-operation.js +2 -2
- package/lib/cloudflare/api-gateway-operation.js.map +1 -1
- package/lib/cloudflare/api-schema.d.ts +1 -2
- package/lib/cloudflare/api-schema.d.ts.map +1 -1
- package/lib/cloudflare/api-schema.js +2 -2
- package/lib/cloudflare/api-schema.js.map +1 -1
- package/lib/cloudflare/api-shield.d.ts +1 -2
- package/lib/cloudflare/api-shield.d.ts.map +1 -1
- package/lib/cloudflare/api-shield.js +2 -2
- package/lib/cloudflare/api-shield.js.map +1 -1
- package/lib/cloudflare/api.d.ts +18 -10
- package/lib/cloudflare/api.d.ts.map +1 -1
- package/lib/cloudflare/api.js +93 -38
- package/lib/cloudflare/api.js.map +1 -1
- package/lib/cloudflare/assets.d.ts +21 -43
- package/lib/cloudflare/assets.d.ts.map +1 -1
- package/lib/cloudflare/assets.js +78 -70
- package/lib/cloudflare/assets.js.map +1 -1
- package/lib/cloudflare/auth.d.ts +91 -17
- package/lib/cloudflare/auth.d.ts.map +1 -1
- package/lib/cloudflare/auth.js +141 -62
- package/lib/cloudflare/auth.js.map +1 -1
- package/lib/cloudflare/bindings.d.ts +17 -5
- package/lib/cloudflare/bindings.d.ts.map +1 -1
- package/lib/cloudflare/bindings.js +3 -1
- package/lib/cloudflare/bindings.js.map +1 -1
- package/lib/cloudflare/bound.d.ts +4 -3
- package/lib/cloudflare/bound.d.ts.map +1 -1
- package/lib/cloudflare/bucket.d.ts +60 -8
- package/lib/cloudflare/bucket.d.ts.map +1 -1
- package/lib/cloudflare/bucket.js +161 -18
- package/lib/cloudflare/bucket.js.map +1 -1
- package/lib/cloudflare/bundle/internal-worker-bundle.d.ts +1 -1
- package/lib/cloudflare/bundle/internal-worker-bundle.d.ts.map +1 -1
- package/lib/cloudflare/bundle/internal-worker-bundle.js.map +1 -1
- package/lib/cloudflare/bundle/plugin-wasm.js +4 -2
- package/lib/cloudflare/bundle/plugin-wasm.js.map +1 -1
- package/lib/cloudflare/certificate-pack.d.ts +1 -2
- package/lib/cloudflare/certificate-pack.d.ts.map +1 -1
- package/lib/cloudflare/certificate-pack.js +4 -4
- package/lib/cloudflare/certificate-pack.js.map +1 -1
- package/lib/cloudflare/compatibility-date.gen.d.ts +1 -1
- package/lib/cloudflare/compatibility-date.gen.js +1 -1
- package/lib/cloudflare/container.d.ts +1 -2
- package/lib/cloudflare/container.d.ts.map +1 -1
- package/lib/cloudflare/container.js +6 -6
- package/lib/cloudflare/container.js.map +1 -1
- package/lib/cloudflare/custom-domain.d.ts +1 -2
- package/lib/cloudflare/custom-domain.d.ts.map +1 -1
- package/lib/cloudflare/custom-domain.js +2 -2
- package/lib/cloudflare/custom-domain.js.map +1 -1
- package/lib/cloudflare/d1-database.d.ts +2 -3
- package/lib/cloudflare/d1-database.d.ts.map +1 -1
- package/lib/cloudflare/d1-database.js +5 -5
- package/lib/cloudflare/d1-database.js.map +1 -1
- package/lib/cloudflare/dispatch-namespace.d.ts +2 -3
- package/lib/cloudflare/dispatch-namespace.d.ts.map +1 -1
- package/lib/cloudflare/dispatch-namespace.js +3 -3
- package/lib/cloudflare/dispatch-namespace.js.map +1 -1
- package/lib/cloudflare/dns-records.d.ts +1 -2
- package/lib/cloudflare/dns-records.d.ts.map +1 -1
- package/lib/cloudflare/dns-records.js +4 -4
- package/lib/cloudflare/dns-records.js.map +1 -1
- package/lib/cloudflare/email-address.d.ts +1 -2
- package/lib/cloudflare/email-address.d.ts.map +1 -1
- package/lib/cloudflare/email-address.js +6 -6
- package/lib/cloudflare/email-address.js.map +1 -1
- package/lib/cloudflare/email-catch-all.d.ts +1 -2
- package/lib/cloudflare/email-catch-all.d.ts.map +1 -1
- package/lib/cloudflare/email-catch-all.js +4 -4
- package/lib/cloudflare/email-catch-all.js.map +1 -1
- package/lib/cloudflare/email-routing.d.ts +1 -2
- package/lib/cloudflare/email-routing.d.ts.map +1 -1
- package/lib/cloudflare/email-routing.js +4 -4
- package/lib/cloudflare/email-routing.js.map +1 -1
- package/lib/cloudflare/email-rule.d.ts +1 -2
- package/lib/cloudflare/email-rule.d.ts.map +1 -1
- package/lib/cloudflare/email-rule.js +4 -4
- package/lib/cloudflare/email-rule.js.map +1 -1
- package/lib/cloudflare/hyperdrive-ref.d.ts +23 -0
- package/lib/cloudflare/hyperdrive-ref.d.ts.map +1 -0
- package/lib/cloudflare/hyperdrive-ref.js +52 -0
- package/lib/cloudflare/hyperdrive-ref.js.map +1 -0
- package/lib/cloudflare/hyperdrive.d.ts +1 -2
- package/lib/cloudflare/hyperdrive.d.ts.map +1 -1
- package/lib/cloudflare/hyperdrive.js +4 -4
- package/lib/cloudflare/hyperdrive.js.map +1 -1
- package/lib/cloudflare/index.d.ts +2 -0
- package/lib/cloudflare/index.d.ts.map +1 -1
- package/lib/cloudflare/index.js +2 -0
- package/lib/cloudflare/index.js.map +1 -1
- package/lib/cloudflare/kv-namespace.d.ts +2 -3
- package/lib/cloudflare/kv-namespace.d.ts.map +1 -1
- package/lib/cloudflare/kv-namespace.js +5 -5
- package/lib/cloudflare/kv-namespace.js.map +1 -1
- package/lib/cloudflare/miniflare/build-worker-options.d.ts +2 -1
- package/lib/cloudflare/miniflare/build-worker-options.d.ts.map +1 -1
- package/lib/cloudflare/miniflare/build-worker-options.js +11 -6
- package/lib/cloudflare/miniflare/build-worker-options.js.map +1 -1
- package/lib/cloudflare/miniflare/delete.js +1 -1
- package/lib/cloudflare/miniflare/delete.js.map +1 -1
- package/lib/cloudflare/miniflare/miniflare-controller.d.ts +3 -1
- package/lib/cloudflare/miniflare/miniflare-controller.d.ts.map +1 -1
- package/lib/cloudflare/miniflare/miniflare-controller.js +24 -9
- package/lib/cloudflare/miniflare/miniflare-controller.js.map +1 -1
- package/lib/cloudflare/miniflare/miniflare-worker-proxy.d.ts +24 -13
- package/lib/cloudflare/miniflare/miniflare-worker-proxy.d.ts.map +1 -1
- package/lib/cloudflare/miniflare/miniflare-worker-proxy.js +90 -79
- package/lib/cloudflare/miniflare/miniflare-worker-proxy.js.map +1 -1
- package/lib/cloudflare/miniflare/remote-binding-proxy.d.ts.map +1 -1
- package/lib/cloudflare/miniflare/remote-binding-proxy.js +15 -4
- package/lib/cloudflare/miniflare/remote-binding-proxy.js.map +1 -1
- package/lib/cloudflare/miniflare/tunnel.d.ts +18 -0
- package/lib/cloudflare/miniflare/tunnel.d.ts.map +1 -0
- package/lib/cloudflare/miniflare/tunnel.js +79 -0
- package/lib/cloudflare/miniflare/tunnel.js.map +1 -0
- package/lib/cloudflare/next.d.ts.map +1 -1
- package/lib/cloudflare/next.js +3 -0
- package/lib/cloudflare/next.js.map +1 -1
- package/lib/cloudflare/permission-groups.d.ts +1 -2
- package/lib/cloudflare/permission-groups.d.ts.map +1 -1
- package/lib/cloudflare/permission-groups.js +1 -1
- package/lib/cloudflare/permission-groups.js.map +1 -1
- package/lib/cloudflare/pipeline.d.ts +2 -3
- package/lib/cloudflare/pipeline.d.ts.map +1 -1
- package/lib/cloudflare/pipeline.js +5 -5
- package/lib/cloudflare/pipeline.js.map +1 -1
- package/lib/cloudflare/queue-consumer.d.ts +1 -2
- package/lib/cloudflare/queue-consumer.d.ts.map +1 -1
- package/lib/cloudflare/queue-consumer.js +4 -4
- package/lib/cloudflare/queue-consumer.js.map +1 -1
- package/lib/cloudflare/queue.d.ts +1 -2
- package/lib/cloudflare/queue.d.ts.map +1 -1
- package/lib/cloudflare/queue.js +4 -4
- package/lib/cloudflare/queue.js.map +1 -1
- package/lib/cloudflare/quick-tunnel.d.ts +1 -1
- package/lib/cloudflare/react-router/plugin.d.ts.map +1 -1
- package/lib/cloudflare/react-router/plugin.js +13 -0
- package/lib/cloudflare/react-router/plugin.js.map +1 -1
- package/lib/cloudflare/redirect-rule.d.ts +1 -2
- package/lib/cloudflare/redirect-rule.d.ts.map +1 -1
- package/lib/cloudflare/redirect-rule.js +4 -4
- package/lib/cloudflare/redirect-rule.js.map +1 -1
- package/lib/cloudflare/route.d.ts +1 -2
- package/lib/cloudflare/route.d.ts.map +1 -1
- package/lib/cloudflare/route.js +4 -4
- package/lib/cloudflare/route.js.map +1 -1
- package/lib/cloudflare/ruleset.d.ts +1 -2
- package/lib/cloudflare/ruleset.d.ts.map +1 -1
- package/lib/cloudflare/ruleset.js +2 -2
- package/lib/cloudflare/ruleset.js.map +1 -1
- package/lib/cloudflare/secret-ref.d.ts +38 -0
- package/lib/cloudflare/secret-ref.d.ts.map +1 -0
- package/lib/cloudflare/secret-ref.js +38 -0
- package/lib/cloudflare/secret-ref.js.map +1 -0
- package/lib/cloudflare/secret.d.ts +2 -3
- package/lib/cloudflare/secret.d.ts.map +1 -1
- package/lib/cloudflare/secret.js +3 -3
- package/lib/cloudflare/secret.js.map +1 -1
- package/lib/cloudflare/secrets-store.d.ts +2 -3
- package/lib/cloudflare/secrets-store.d.ts.map +1 -1
- package/lib/cloudflare/secrets-store.js +3 -3
- package/lib/cloudflare/secrets-store.js.map +1 -1
- package/lib/cloudflare/tunnel.d.ts +2 -3
- package/lib/cloudflare/tunnel.d.ts.map +1 -1
- package/lib/cloudflare/tunnel.js +3 -3
- package/lib/cloudflare/tunnel.js.map +1 -1
- package/lib/cloudflare/user.d.ts +3 -2
- package/lib/cloudflare/user.d.ts.map +1 -1
- package/lib/cloudflare/user.js +7 -5
- package/lib/cloudflare/user.js.map +1 -1
- package/lib/cloudflare/vectorize-index.d.ts +2 -3
- package/lib/cloudflare/vectorize-index.d.ts.map +1 -1
- package/lib/cloudflare/vectorize-index.js +6 -6
- package/lib/cloudflare/vectorize-index.js.map +1 -1
- package/lib/cloudflare/vectorize-metadata-index.d.ts +2 -3
- package/lib/cloudflare/vectorize-metadata-index.d.ts.map +1 -1
- package/lib/cloudflare/vectorize-metadata-index.js +4 -4
- package/lib/cloudflare/vectorize-metadata-index.js.map +1 -1
- package/lib/cloudflare/website.js +1 -1
- package/lib/cloudflare/website.js.map +1 -1
- package/lib/cloudflare/worker-assets.d.ts +1 -29
- package/lib/cloudflare/worker-assets.d.ts.map +1 -1
- package/lib/cloudflare/worker-assets.js +9 -42
- package/lib/cloudflare/worker-assets.js.map +1 -1
- package/lib/cloudflare/worker-metadata.d.ts +1 -1
- package/lib/cloudflare/worker-metadata.d.ts.map +1 -1
- package/lib/cloudflare/worker-metadata.js +7 -9
- package/lib/cloudflare/worker-metadata.js.map +1 -1
- package/lib/cloudflare/worker-stub.d.ts +2 -3
- package/lib/cloudflare/worker-stub.d.ts.map +1 -1
- package/lib/cloudflare/worker-stub.js +3 -3
- package/lib/cloudflare/worker-stub.js.map +1 -1
- package/lib/cloudflare/worker-subdomain.d.ts +4 -3
- package/lib/cloudflare/worker-subdomain.d.ts.map +1 -1
- package/lib/cloudflare/worker-subdomain.js +5 -5
- package/lib/cloudflare/worker-subdomain.js.map +1 -1
- package/lib/cloudflare/worker.d.ts +19 -5
- package/lib/cloudflare/worker.d.ts.map +1 -1
- package/lib/cloudflare/worker.js +18 -5
- package/lib/cloudflare/worker.js.map +1 -1
- package/lib/cloudflare/wrangler.json.d.ts +2 -1
- package/lib/cloudflare/wrangler.json.d.ts.map +1 -1
- package/lib/cloudflare/wrangler.json.js +4 -6
- package/lib/cloudflare/wrangler.json.js.map +1 -1
- package/lib/cloudflare/zone.d.ts +1 -2
- package/lib/cloudflare/zone.d.ts.map +1 -1
- package/lib/cloudflare/zone.js +2 -2
- package/lib/cloudflare/zone.js.map +1 -1
- package/lib/context.d.ts +8 -8
- package/lib/context.d.ts.map +1 -1
- package/lib/context.js.map +1 -1
- package/lib/destroy.d.ts +1 -1
- package/lib/destroy.d.ts.map +1 -1
- package/lib/destroy.js.map +1 -1
- package/lib/dns/import-dns.d.ts +1 -2
- package/lib/dns/import-dns.d.ts.map +1 -1
- package/lib/dns/import-dns.js +2 -2
- package/lib/dns/import-dns.js.map +1 -1
- package/lib/docker/container.d.ts +1 -2
- package/lib/docker/container.d.ts.map +1 -1
- package/lib/docker/container.js +2 -3
- package/lib/docker/container.js.map +1 -1
- package/lib/docker/image.d.ts +1 -2
- package/lib/docker/image.d.ts.map +1 -1
- package/lib/docker/image.js +9 -9
- package/lib/docker/image.js.map +1 -1
- package/lib/docker/network.d.ts +1 -2
- package/lib/docker/network.d.ts.map +1 -1
- package/lib/docker/network.js +2 -3
- package/lib/docker/network.js.map +1 -1
- package/lib/docker/remote-image.d.ts +1 -2
- package/lib/docker/remote-image.d.ts.map +1 -1
- package/lib/docker/remote-image.js +2 -3
- package/lib/docker/remote-image.js.map +1 -1
- package/lib/docker/volume.d.ts +1 -2
- package/lib/docker/volume.d.ts.map +1 -1
- package/lib/docker/volume.js +2 -3
- package/lib/docker/volume.js.map +1 -1
- package/lib/esbuild/bundle.d.ts +1 -2
- package/lib/esbuild/bundle.d.ts.map +1 -1
- package/lib/esbuild/bundle.js +4 -4
- package/lib/esbuild/bundle.js.map +1 -1
- package/lib/fs/copy-file.d.ts +1 -2
- package/lib/fs/copy-file.d.ts.map +1 -1
- package/lib/fs/copy-file.js +2 -2
- package/lib/fs/copy-file.js.map +1 -1
- package/lib/fs/file.d.ts +1 -2
- package/lib/fs/file.d.ts.map +1 -1
- package/lib/fs/file.js +2 -2
- package/lib/fs/file.js.map +1 -1
- package/lib/fs/folder.d.ts +1 -2
- package/lib/fs/folder.d.ts.map +1 -1
- package/lib/fs/folder.js +2 -2
- package/lib/fs/folder.js.map +1 -1
- package/lib/github/comment.d.ts +1 -2
- package/lib/github/comment.d.ts.map +1 -1
- package/lib/github/comment.js +4 -4
- package/lib/github/comment.js.map +1 -1
- package/lib/github/repository-environment.d.ts +1 -2
- package/lib/github/repository-environment.d.ts.map +1 -1
- package/lib/github/repository-environment.js +2 -2
- package/lib/github/repository-environment.js.map +1 -1
- package/lib/github/repository-webhook.d.ts +1 -2
- package/lib/github/repository-webhook.d.ts.map +1 -1
- package/lib/github/repository-webhook.js +2 -2
- package/lib/github/repository-webhook.js.map +1 -1
- package/lib/github/secret.d.ts +1 -2
- package/lib/github/secret.d.ts.map +1 -1
- package/lib/github/secret.js +2 -2
- package/lib/github/secret.js.map +1 -1
- package/lib/llms.cloudflare.txt +1 -1
- package/lib/neon/api/client.gen.d.ts +13 -0
- package/lib/neon/api/client.gen.d.ts.map +1 -0
- package/lib/neon/api/client.gen.js +7 -0
- package/lib/neon/api/client.gen.js.map +1 -0
- package/lib/neon/api/sdk.gen.d.ts +880 -0
- package/lib/neon/api/sdk.gen.d.ts.map +1 -0
- package/lib/neon/api/sdk.gen.js +1527 -0
- package/lib/neon/api/sdk.gen.js.map +1 -0
- package/lib/neon/api/types.gen.d.ts +7250 -0
- package/lib/neon/api/types.gen.d.ts.map +1 -0
- package/lib/neon/api/types.gen.js +2 -0
- package/lib/neon/api/types.gen.js.map +1 -0
- package/lib/neon/api.d.ts +14 -49
- package/lib/neon/api.d.ts.map +1 -1
- package/lib/neon/api.js +36 -114
- package/lib/neon/api.js.map +1 -1
- package/lib/neon/branch.d.ts +141 -0
- package/lib/neon/branch.d.ts.map +1 -0
- package/lib/neon/branch.js +112 -0
- package/lib/neon/branch.js.map +1 -0
- package/lib/neon/index.d.ts +1 -1
- package/lib/neon/index.d.ts.map +1 -1
- package/lib/neon/index.js +1 -1
- package/lib/neon/index.js.map +1 -1
- package/lib/neon/project.d.ts +32 -242
- package/lib/neon/project.d.ts.map +1 -1
- package/lib/neon/project.js +90 -269
- package/lib/neon/project.js.map +1 -1
- package/lib/neon/utils.d.ts +49 -0
- package/lib/neon/utils.d.ts.map +1 -0
- package/lib/neon/utils.js +44 -0
- package/lib/neon/utils.js.map +1 -0
- package/lib/os/exec.d.ts +1 -2
- package/lib/os/exec.d.ts.map +1 -1
- package/lib/os/exec.js +2 -2
- package/lib/os/exec.js.map +1 -1
- package/lib/planetscale/api/client.gen.d.ts +12 -1749
- package/lib/planetscale/api/client.gen.d.ts.map +1 -1
- package/lib/planetscale/api/client.gen.js +6 -2400
- package/lib/planetscale/api/client.gen.js.map +1 -1
- package/lib/planetscale/api/sdk.gen.d.ts +1582 -0
- package/lib/planetscale/api/sdk.gen.d.ts.map +1 -0
- package/lib/planetscale/api/sdk.gen.js +2219 -0
- package/lib/planetscale/api/sdk.gen.js.map +1 -0
- package/lib/planetscale/api/types.gen.d.ts +594 -449
- package/lib/planetscale/api/types.gen.d.ts.map +1 -1
- package/lib/planetscale/api.d.ts +43 -0
- package/lib/planetscale/api.d.ts.map +1 -0
- package/lib/planetscale/api.js +53 -0
- package/lib/planetscale/api.js.map +1 -0
- package/lib/planetscale/branch.d.ts +2 -3
- package/lib/planetscale/branch.d.ts.map +1 -1
- package/lib/planetscale/branch.js +17 -15
- package/lib/planetscale/branch.js.map +1 -1
- package/lib/planetscale/database.d.ts +2 -3
- package/lib/planetscale/database.d.ts.map +1 -1
- package/lib/planetscale/database.js +34 -34
- package/lib/planetscale/database.js.map +1 -1
- package/lib/planetscale/index.d.ts +1 -1
- package/lib/planetscale/index.d.ts.map +1 -1
- package/lib/planetscale/index.js +1 -1
- package/lib/planetscale/index.js.map +1 -1
- package/lib/planetscale/password.d.ts +2 -3
- package/lib/planetscale/password.d.ts.map +1 -1
- package/lib/planetscale/password.js +11 -11
- package/lib/planetscale/password.js.map +1 -1
- package/lib/planetscale/role.d.ts +2 -3
- package/lib/planetscale/role.d.ts.map +1 -1
- package/lib/planetscale/role.js +18 -18
- package/lib/planetscale/role.js.map +1 -1
- package/lib/planetscale/utils.d.ts +1 -1
- package/lib/planetscale/utils.d.ts.map +1 -1
- package/lib/planetscale/utils.js +17 -33
- package/lib/planetscale/utils.js.map +1 -1
- package/lib/random/random-string.d.ts +1 -2
- package/lib/random/random-string.d.ts.map +1 -1
- package/lib/random/random-string.js +3 -3
- package/lib/random/random-string.js.map +1 -1
- package/lib/resource.d.ts +4 -1
- package/lib/resource.d.ts.map +1 -1
- package/lib/resource.js.map +1 -1
- package/lib/scope.d.ts +10 -1
- package/lib/scope.d.ts.map +1 -1
- package/lib/scope.js +3 -1
- package/lib/scope.js.map +1 -1
- package/lib/sentry/client-key.d.ts +1 -2
- package/lib/sentry/client-key.d.ts.map +1 -1
- package/lib/sentry/client-key.js +2 -2
- package/lib/sentry/client-key.js.map +1 -1
- package/lib/sentry/project.d.ts +1 -2
- package/lib/sentry/project.d.ts.map +1 -1
- package/lib/sentry/project.js +2 -2
- package/lib/sentry/project.js.map +1 -1
- package/lib/sentry/team.d.ts +1 -2
- package/lib/sentry/team.d.ts.map +1 -1
- package/lib/sentry/team.js +2 -2
- package/lib/sentry/team.js.map +1 -1
- package/lib/state/r2-rest-state-store.d.ts +1 -0
- package/lib/state/r2-rest-state-store.d.ts.map +1 -1
- package/lib/state/r2-rest-state-store.js +15 -34
- package/lib/state/r2-rest-state-store.js.map +1 -1
- package/lib/stripe/card.d.ts +1 -2
- package/lib/stripe/card.d.ts.map +1 -1
- package/lib/stripe/card.js +2 -2
- package/lib/stripe/card.js.map +1 -1
- package/lib/stripe/coupon.d.ts +1 -2
- package/lib/stripe/coupon.d.ts.map +1 -1
- package/lib/stripe/coupon.js +2 -2
- package/lib/stripe/coupon.js.map +1 -1
- package/lib/stripe/customer.d.ts +1 -2
- package/lib/stripe/customer.d.ts.map +1 -1
- package/lib/stripe/customer.js +2 -2
- package/lib/stripe/customer.js.map +1 -1
- package/lib/stripe/entitlements-feature.d.ts +1 -2
- package/lib/stripe/entitlements-feature.d.ts.map +1 -1
- package/lib/stripe/entitlements-feature.js +2 -2
- package/lib/stripe/entitlements-feature.js.map +1 -1
- package/lib/stripe/file.d.ts +1 -2
- package/lib/stripe/file.d.ts.map +1 -1
- package/lib/stripe/file.js +2 -2
- package/lib/stripe/file.js.map +1 -1
- package/lib/stripe/meter.d.ts +1 -2
- package/lib/stripe/meter.d.ts.map +1 -1
- package/lib/stripe/meter.js +1 -1
- package/lib/stripe/meter.js.map +1 -1
- package/lib/stripe/portal-configuration.d.ts +1 -2
- package/lib/stripe/portal-configuration.d.ts.map +1 -1
- package/lib/stripe/portal-configuration.js +2 -2
- package/lib/stripe/portal-configuration.js.map +1 -1
- package/lib/stripe/price.d.ts +1 -2
- package/lib/stripe/price.d.ts.map +1 -1
- package/lib/stripe/price.js +2 -2
- package/lib/stripe/price.js.map +1 -1
- package/lib/stripe/product-feature.d.ts +1 -2
- package/lib/stripe/product-feature.d.ts.map +1 -1
- package/lib/stripe/product-feature.js +2 -2
- package/lib/stripe/product-feature.js.map +1 -1
- package/lib/stripe/product.d.ts +1 -2
- package/lib/stripe/product.d.ts.map +1 -1
- package/lib/stripe/product.js +2 -2
- package/lib/stripe/product.js.map +1 -1
- package/lib/stripe/promotion-code.d.ts +1 -2
- package/lib/stripe/promotion-code.d.ts.map +1 -1
- package/lib/stripe/promotion-code.js +2 -2
- package/lib/stripe/promotion-code.js.map +1 -1
- package/lib/stripe/shipping-rate.d.ts +1 -2
- package/lib/stripe/shipping-rate.d.ts.map +1 -1
- package/lib/stripe/shipping-rate.js +2 -2
- package/lib/stripe/shipping-rate.js.map +1 -1
- package/lib/stripe/tax-rate.d.ts +1 -2
- package/lib/stripe/tax-rate.d.ts.map +1 -1
- package/lib/stripe/tax-rate.js +2 -2
- package/lib/stripe/tax-rate.js.map +1 -1
- package/lib/stripe/webhook.d.ts +16 -3
- package/lib/stripe/webhook.d.ts.map +1 -1
- package/lib/stripe/webhook.js +2 -2
- package/lib/stripe/webhook.js.map +1 -1
- package/lib/test/bun.d.ts.map +1 -1
- package/lib/test/bun.js +1 -0
- package/lib/test/bun.js.map +1 -1
- package/lib/test/options.d.ts +5 -0
- package/lib/test/options.d.ts.map +1 -1
- package/lib/test/vitest.d.ts.map +1 -1
- package/lib/test/vitest.js +1 -0
- package/lib/test/vitest.js.map +1 -1
- package/lib/upstash/redis.d.ts +1 -2
- package/lib/upstash/redis.d.ts.map +1 -1
- package/lib/upstash/redis.js.map +1 -1
- package/lib/util/api/client/client.gen.d.ts +3 -0
- package/lib/util/api/client/client.gen.d.ts.map +1 -0
- package/lib/util/api/client/client.gen.js +205 -0
- package/lib/util/api/client/client.gen.js.map +1 -0
- package/lib/util/api/client/index.d.ts +8 -0
- package/lib/util/api/client/index.d.ts.map +1 -0
- package/lib/util/api/client/index.js +6 -0
- package/lib/util/api/client/index.js.map +1 -0
- package/lib/util/api/client/types.gen.d.ts +125 -0
- package/lib/util/api/client/types.gen.d.ts.map +1 -0
- package/lib/util/api/client/types.gen.js +2 -0
- package/lib/util/api/client/types.gen.js.map +1 -0
- package/lib/util/api/client/utils.gen.d.ts +34 -0
- package/lib/util/api/client/utils.gen.d.ts.map +1 -0
- package/lib/util/api/client/utils.gen.js +231 -0
- package/lib/util/api/client/utils.gen.js.map +1 -0
- package/lib/util/api/core/auth.gen.d.ts +19 -0
- package/lib/util/api/core/auth.gen.d.ts.map +1 -0
- package/lib/util/api/core/auth.gen.js +15 -0
- package/lib/util/api/core/auth.gen.js.map +1 -0
- package/lib/util/api/core/bodySerializer.gen.d.ts +18 -0
- package/lib/util/api/core/bodySerializer.gen.d.ts.map +1 -0
- package/lib/util/api/core/bodySerializer.gen.js +58 -0
- package/lib/util/api/core/bodySerializer.gen.js.map +1 -0
- package/lib/util/api/core/params.gen.d.ts +34 -0
- package/lib/util/api/core/params.gen.d.ts.map +1 -0
- package/lib/util/api/core/params.gen.js +89 -0
- package/lib/util/api/core/params.gen.js.map +1 -0
- package/lib/util/api/core/pathSerializer.gen.d.ts +34 -0
- package/lib/util/api/core/pathSerializer.gen.d.ts.map +1 -0
- package/lib/util/api/core/pathSerializer.gen.js +115 -0
- package/lib/util/api/core/pathSerializer.gen.js.map +1 -0
- package/lib/util/api/core/serverSentEvents.gen.d.ts +72 -0
- package/lib/util/api/core/serverSentEvents.gen.d.ts.map +1 -0
- package/lib/util/api/core/serverSentEvents.gen.js +136 -0
- package/lib/util/api/core/serverSentEvents.gen.js.map +1 -0
- package/lib/util/api/core/types.gen.d.ts +79 -0
- package/lib/util/api/core/types.gen.d.ts.map +1 -0
- package/lib/util/api/core/types.gen.js +2 -0
- package/lib/util/api/core/types.gen.js.map +1 -0
- package/lib/util/api/core/utils.gen.d.ts +20 -0
- package/lib/util/api/core/utils.gen.d.ts.map +1 -0
- package/lib/util/api/core/utils.gen.js +88 -0
- package/lib/util/api/core/utils.gen.js.map +1 -0
- package/lib/util/http.d.ts +7 -2
- package/lib/util/http.d.ts.map +1 -1
- package/lib/util/http.js +29 -11
- package/lib/util/http.js.map +1 -1
- package/lib/util/idempotent-spawn.d.ts.map +1 -1
- package/lib/util/idempotent-spawn.js +5 -8
- package/lib/util/idempotent-spawn.js.map +1 -1
- package/lib/util/lock.d.ts +20 -0
- package/lib/util/lock.d.ts.map +1 -0
- package/lib/util/lock.js +45 -0
- package/lib/util/lock.js.map +1 -0
- package/lib/util/memoize.d.ts +6 -0
- package/lib/util/memoize.d.ts.map +1 -1
- package/lib/util/memoize.js +23 -0
- package/lib/util/memoize.js.map +1 -1
- package/lib/util/oauth-client.d.ts +71 -0
- package/lib/util/oauth-client.d.ts.map +1 -0
- package/lib/util/oauth-client.js +188 -0
- package/lib/util/oauth-client.js.map +1 -0
- package/lib/util/poll.d.ts +33 -0
- package/lib/util/poll.d.ts.map +1 -0
- package/lib/util/poll.js +19 -0
- package/lib/util/poll.js.map +1 -0
- package/lib/vercel/project-domain.d.ts +1 -2
- package/lib/vercel/project-domain.d.ts.map +1 -1
- package/lib/vercel/project-domain.js.map +1 -1
- package/lib/vercel/project.d.ts +1 -2
- package/lib/vercel/project.d.ts.map +1 -1
- package/lib/vercel/project.js +2 -2
- package/lib/vercel/project.js.map +1 -1
- package/package.json +5 -1
- package/src/alchemy.ts +7 -0
- package/src/apply.ts +32 -29
- package/src/auth.ts +253 -0
- package/src/aws/bucket.ts +3 -3
- package/src/aws/control/resource.ts +4 -6
- package/src/aws/ec2/internet-gateway-attachment.ts +5 -6
- package/src/aws/ec2/internet-gateway.ts +3 -5
- package/src/aws/ec2/nat-gateway.ts +3 -5
- package/src/aws/ec2/route-table-association.ts +3 -5
- package/src/aws/ec2/route-table.ts +3 -5
- package/src/aws/ec2/route.ts +3 -3
- package/src/aws/ec2/security-group-rule.ts +3 -5
- package/src/aws/ec2/security-group.ts +3 -5
- package/src/aws/ec2/subnet.ts +3 -3
- package/src/aws/ec2/vpc.ts +3 -3
- package/src/aws/function.ts +3 -3
- package/src/aws/oidc/oidc-provider.ts +3 -5
- package/src/aws/policy-attachment.ts +2 -4
- package/src/aws/policy.ts +5 -5
- package/src/aws/queue.ts +5 -5
- package/src/aws/role.ts +3 -3
- package/src/aws/ses.ts +3 -3
- package/src/aws/ssm-parameter.ts +3 -3
- package/src/aws/table.ts +3 -3
- package/src/cloudflare/account-api-token.ts +3 -4
- package/src/cloudflare/ai-gateway.ts +3 -5
- package/src/cloudflare/api-gateway-operation.ts +3 -4
- package/src/cloudflare/api-schema.ts +25 -26
- package/src/cloudflare/api-shield.ts +3 -4
- package/src/cloudflare/api.ts +122 -57
- package/src/cloudflare/assets.ts +95 -136
- package/src/cloudflare/auth.ts +160 -95
- package/src/cloudflare/bindings.ts +21 -4
- package/src/cloudflare/bound.ts +50 -52
- package/src/cloudflare/bucket.ts +321 -58
- package/src/cloudflare/bundle/internal-worker-bundle.ts +2 -1
- package/src/cloudflare/bundle/plugin-wasm.ts +5 -5
- package/src/cloudflare/certificate-pack.ts +5 -6
- package/src/cloudflare/compatibility-date.gen.ts +1 -1
- package/src/cloudflare/container.ts +7 -8
- package/src/cloudflare/custom-domain.ts +3 -5
- package/src/cloudflare/d1-database.ts +33 -34
- package/src/cloudflare/dispatch-namespace.ts +5 -6
- package/src/cloudflare/dns-records.ts +5 -5
- package/src/cloudflare/email-address.ts +7 -7
- package/src/cloudflare/email-catch-all.ts +6 -6
- package/src/cloudflare/email-routing.ts +5 -5
- package/src/cloudflare/email-rule.ts +5 -5
- package/src/cloudflare/hyperdrive-ref.ts +98 -0
- package/src/cloudflare/hyperdrive.ts +35 -36
- package/src/cloudflare/index.ts +2 -0
- package/src/cloudflare/kv-namespace.ts +31 -32
- package/src/cloudflare/miniflare/build-worker-options.ts +21 -12
- package/src/cloudflare/miniflare/delete.ts +1 -1
- package/src/cloudflare/miniflare/miniflare-controller.ts +27 -12
- package/src/cloudflare/miniflare/miniflare-worker-proxy.ts +117 -102
- package/src/cloudflare/miniflare/remote-binding-proxy.ts +16 -4
- package/src/cloudflare/miniflare/tunnel.ts +116 -0
- package/src/cloudflare/next.ts +3 -0
- package/src/cloudflare/permission-groups.ts +4 -6
- package/src/cloudflare/pipeline.ts +29 -30
- package/src/cloudflare/queue-consumer.ts +5 -7
- package/src/cloudflare/queue.ts +42 -43
- package/src/cloudflare/react-router/plugin.ts +20 -0
- package/src/cloudflare/redirect-rule.ts +5 -5
- package/src/cloudflare/route.ts +5 -5
- package/src/cloudflare/ruleset.ts +3 -4
- package/src/cloudflare/secret-ref.ts +56 -0
- package/src/cloudflare/secret.ts +35 -36
- package/src/cloudflare/secrets-store.ts +5 -8
- package/src/cloudflare/tunnel.ts +5 -7
- package/src/cloudflare/user.ts +12 -9
- package/src/cloudflare/vectorize-index.ts +8 -12
- package/src/cloudflare/vectorize-metadata-index.ts +6 -8
- package/src/cloudflare/website.ts +1 -1
- package/src/cloudflare/worker-assets.ts +10 -56
- package/src/cloudflare/worker-metadata.ts +14 -12
- package/src/cloudflare/worker-stub.ts +5 -5
- package/src/cloudflare/worker-subdomain.ts +6 -7
- package/src/cloudflare/worker.ts +123 -92
- package/src/cloudflare/wrangler.json.ts +13 -11
- package/src/cloudflare/zone.ts +3 -3
- package/src/context.ts +9 -7
- package/src/destroy.ts +2 -2
- package/src/dns/import-dns.ts +3 -5
- package/src/docker/container.ts +3 -6
- package/src/docker/image.ts +13 -13
- package/src/docker/network.ts +3 -4
- package/src/docker/remote-image.ts +3 -6
- package/src/docker/volume.ts +3 -4
- package/src/esbuild/bundle.ts +10 -8
- package/src/fs/copy-file.ts +3 -3
- package/src/fs/file.ts +3 -3
- package/src/fs/folder.ts +3 -3
- package/src/github/comment.ts +5 -7
- package/src/github/repository-environment.ts +3 -5
- package/src/github/repository-webhook.ts +3 -5
- package/src/github/secret.ts +3 -5
- package/src/llms.cloudflare.txt +1 -1
- package/src/neon/api/client.gen.ts +28 -0
- package/src/neon/api/sdk.gen.ts +2596 -0
- package/src/neon/api/types.gen.ts +8287 -0
- package/src/neon/api.ts +51 -147
- package/src/neon/branch.ts +278 -0
- package/src/neon/index.ts +1 -1
- package/src/neon/project.ts +136 -721
- package/src/neon/utils.ts +105 -0
- package/src/os/exec.ts +3 -3
- package/src/planetscale/api/client.gen.ts +28 -2882
- package/src/planetscale/api/sdk.gen.ts +3336 -0
- package/src/planetscale/api/types.gen.ts +778 -450
- package/src/planetscale/api.ts +101 -0
- package/src/planetscale/branch.ts +20 -19
- package/src/planetscale/database.ts +69 -70
- package/src/planetscale/index.ts +1 -1
- package/src/planetscale/password.ts +18 -22
- package/src/planetscale/role.ts +21 -21
- package/src/planetscale/utils.ts +20 -74
- package/src/random/random-string.ts +4 -4
- package/src/resource.ts +6 -2
- package/src/scope.ts +12 -1
- package/src/sentry/client-key.ts +3 -5
- package/src/sentry/project.ts +3 -5
- package/src/sentry/team.ts +3 -3
- package/src/state/r2-rest-state-store.ts +15 -57
- package/src/stripe/card.ts +3 -3
- package/src/stripe/coupon.ts +3 -3
- package/src/stripe/customer.ts +3 -3
- package/src/stripe/entitlements-feature.ts +3 -5
- package/src/stripe/file.ts +3 -3
- package/src/stripe/meter.ts +3 -3
- package/src/stripe/portal-configuration.ts +3 -5
- package/src/stripe/price.ts +3 -3
- package/src/stripe/product-feature.ts +3 -5
- package/src/stripe/product.ts +3 -3
- package/src/stripe/promotion-code.ts +3 -5
- package/src/stripe/shipping-rate.ts +3 -5
- package/src/stripe/tax-rate.ts +3 -3
- package/src/stripe/webhook.ts +3 -5
- package/src/test/bun.ts +1 -0
- package/src/test/options.ts +6 -0
- package/src/test/vitest.ts +1 -0
- package/src/upstash/redis.ts +1 -3
- package/src/util/api/client/client.gen.ts +268 -0
- package/src/util/api/client/index.ts +25 -0
- package/src/util/api/client/types.gen.ts +268 -0
- package/src/util/api/client/utils.gen.ts +331 -0
- package/src/util/api/core/auth.gen.ts +42 -0
- package/src/util/api/core/bodySerializer.gen.ts +92 -0
- package/src/util/api/core/params.gen.ts +153 -0
- package/src/util/api/core/pathSerializer.gen.ts +181 -0
- package/src/util/api/core/serverSentEvents.gen.ts +264 -0
- package/src/util/api/core/types.gen.ts +118 -0
- package/src/util/api/core/utils.gen.ts +143 -0
- package/src/util/http.ts +38 -11
- package/src/util/idempotent-spawn.ts +5 -6
- package/src/util/lock.ts +48 -0
- package/src/util/memoize.ts +26 -0
- package/src/util/oauth-client.ts +238 -0
- package/src/util/poll.ts +55 -0
- package/src/vercel/project-domain.ts +1 -3
- package/src/vercel/project.ts +3 -3
- package/templates/rwsdk/.cursor/rules/alchemy_cloudflare.mdc +1 -1
- package/templates/rwsdk/package.json +3 -3
- package/workers/cloudflare-state-store.js +8 -5619
- package/workers/dofs-state-store.js +2 -802
- package/workers/remote-binding-proxy.js +3 -39
- package/workers/remote-binding-proxy.ts +126 -35
- package/workers/tunnel-proxy.js +43 -0
- package/workers/tunnel-proxy.ts +121 -0
- package/lib/cloudflare/asset-manifest.d.ts +0 -15
- package/lib/cloudflare/asset-manifest.d.ts.map +0 -1
- package/lib/cloudflare/asset-manifest.js +0 -1
- package/lib/cloudflare/asset-manifest.js.map +0 -1
- package/lib/cloudflare/oauth.d.ts +0 -22
- package/lib/cloudflare/oauth.d.ts.map +0 -1
- package/lib/cloudflare/oauth.js +0 -214
- package/lib/cloudflare/oauth.js.map +0 -1
- package/lib/neon/api-error.d.ts +0 -31
- package/lib/neon/api-error.d.ts.map +0 -1
- package/lib/neon/api-error.js +0 -73
- package/lib/neon/api-error.js.map +0 -1
- package/lib/planetscale/api/index.d.ts +0 -3
- package/lib/planetscale/api/index.d.ts.map +0 -1
- package/lib/planetscale/api/index.js +0 -4
- package/lib/planetscale/api/index.js.map +0 -1
- package/lib/util/neverthrow.d.ts +0 -16
- package/lib/util/neverthrow.d.ts.map +0 -1
- package/lib/util/neverthrow.js +0 -46
- package/lib/util/neverthrow.js.map +0 -1
- package/src/cloudflare/asset-manifest.ts +0 -16
- package/src/cloudflare/oauth.ts +0 -301
- package/src/neon/api-error.ts +0 -81
- package/src/planetscale/api/index.ts +0 -4
- package/src/util/neverthrow.ts +0 -64
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
import type { Auth, AuthToken } from './auth.gen';
|
|
4
|
+
import type {
|
|
5
|
+
BodySerializer,
|
|
6
|
+
QuerySerializer,
|
|
7
|
+
QuerySerializerOptions,
|
|
8
|
+
} from './bodySerializer.gen';
|
|
9
|
+
|
|
10
|
+
export type HttpMethod =
|
|
11
|
+
| 'connect'
|
|
12
|
+
| 'delete'
|
|
13
|
+
| 'get'
|
|
14
|
+
| 'head'
|
|
15
|
+
| 'options'
|
|
16
|
+
| 'patch'
|
|
17
|
+
| 'post'
|
|
18
|
+
| 'put'
|
|
19
|
+
| 'trace';
|
|
20
|
+
|
|
21
|
+
export type Client<
|
|
22
|
+
RequestFn = never,
|
|
23
|
+
Config = unknown,
|
|
24
|
+
MethodFn = never,
|
|
25
|
+
BuildUrlFn = never,
|
|
26
|
+
SseFn = never,
|
|
27
|
+
> = {
|
|
28
|
+
/**
|
|
29
|
+
* Returns the final request URL.
|
|
30
|
+
*/
|
|
31
|
+
buildUrl: BuildUrlFn;
|
|
32
|
+
getConfig: () => Config;
|
|
33
|
+
request: RequestFn;
|
|
34
|
+
setConfig: (config: Config) => Config;
|
|
35
|
+
} & {
|
|
36
|
+
[K in HttpMethod]: MethodFn;
|
|
37
|
+
} & ([SseFn] extends [never]
|
|
38
|
+
? { sse?: never }
|
|
39
|
+
: { sse: { [K in HttpMethod]: SseFn } });
|
|
40
|
+
|
|
41
|
+
export interface Config {
|
|
42
|
+
/**
|
|
43
|
+
* Auth token or a function returning auth token. The resolved value will be
|
|
44
|
+
* added to the request payload as defined by its `security` array.
|
|
45
|
+
*/
|
|
46
|
+
auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
|
|
47
|
+
/**
|
|
48
|
+
* A function for serializing request body parameter. By default,
|
|
49
|
+
* {@link JSON.stringify()} will be used.
|
|
50
|
+
*/
|
|
51
|
+
bodySerializer?: BodySerializer | null;
|
|
52
|
+
/**
|
|
53
|
+
* An object containing any HTTP headers that you want to pre-populate your
|
|
54
|
+
* `Headers` object with.
|
|
55
|
+
*
|
|
56
|
+
* {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
|
|
57
|
+
*/
|
|
58
|
+
headers?:
|
|
59
|
+
| RequestInit['headers']
|
|
60
|
+
| Record<
|
|
61
|
+
string,
|
|
62
|
+
| string
|
|
63
|
+
| number
|
|
64
|
+
| boolean
|
|
65
|
+
| (string | number | boolean)[]
|
|
66
|
+
| null
|
|
67
|
+
| undefined
|
|
68
|
+
| unknown
|
|
69
|
+
>;
|
|
70
|
+
/**
|
|
71
|
+
* The request method.
|
|
72
|
+
*
|
|
73
|
+
* {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
|
|
74
|
+
*/
|
|
75
|
+
method?: Uppercase<HttpMethod>;
|
|
76
|
+
/**
|
|
77
|
+
* A function for serializing request query parameters. By default, arrays
|
|
78
|
+
* will be exploded in form style, objects will be exploded in deepObject
|
|
79
|
+
* style, and reserved characters are percent-encoded.
|
|
80
|
+
*
|
|
81
|
+
* This method will have no effect if the native `paramsSerializer()` Axios
|
|
82
|
+
* API function is used.
|
|
83
|
+
*
|
|
84
|
+
* {@link https://swagger.io/docs/specification/serialization/#query View examples}
|
|
85
|
+
*/
|
|
86
|
+
querySerializer?: QuerySerializer | QuerySerializerOptions;
|
|
87
|
+
/**
|
|
88
|
+
* A function validating request data. This is useful if you want to ensure
|
|
89
|
+
* the request conforms to the desired shape, so it can be safely sent to
|
|
90
|
+
* the server.
|
|
91
|
+
*/
|
|
92
|
+
requestValidator?: (data: unknown) => Promise<unknown>;
|
|
93
|
+
/**
|
|
94
|
+
* A function transforming response data before it's returned. This is useful
|
|
95
|
+
* for post-processing data, e.g. converting ISO strings into Date objects.
|
|
96
|
+
*/
|
|
97
|
+
responseTransformer?: (data: unknown) => Promise<unknown>;
|
|
98
|
+
/**
|
|
99
|
+
* A function validating response data. This is useful if you want to ensure
|
|
100
|
+
* the response conforms to the desired shape, so it can be safely passed to
|
|
101
|
+
* the transformers and returned to the user.
|
|
102
|
+
*/
|
|
103
|
+
responseValidator?: (data: unknown) => Promise<unknown>;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never]
|
|
107
|
+
? true
|
|
108
|
+
: [T] extends [never | undefined]
|
|
109
|
+
? [undefined] extends [T]
|
|
110
|
+
? false
|
|
111
|
+
: true
|
|
112
|
+
: false;
|
|
113
|
+
|
|
114
|
+
export type OmitNever<T extends Record<string, unknown>> = {
|
|
115
|
+
[K in keyof T as IsExactlyNeverOrNeverUndefined<T[K]> extends true
|
|
116
|
+
? never
|
|
117
|
+
: K]: T[K];
|
|
118
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
import type { BodySerializer, QuerySerializer } from './bodySerializer.gen';
|
|
4
|
+
import {
|
|
5
|
+
type ArraySeparatorStyle,
|
|
6
|
+
serializeArrayParam,
|
|
7
|
+
serializeObjectParam,
|
|
8
|
+
serializePrimitiveParam,
|
|
9
|
+
} from './pathSerializer.gen';
|
|
10
|
+
|
|
11
|
+
export interface PathSerializer {
|
|
12
|
+
path: Record<string, unknown>;
|
|
13
|
+
url: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
17
|
+
|
|
18
|
+
export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
|
|
19
|
+
let url = _url;
|
|
20
|
+
const matches = _url.match(PATH_PARAM_RE);
|
|
21
|
+
if (matches) {
|
|
22
|
+
for (const match of matches) {
|
|
23
|
+
let explode = false;
|
|
24
|
+
let name = match.substring(1, match.length - 1);
|
|
25
|
+
let style: ArraySeparatorStyle = 'simple';
|
|
26
|
+
|
|
27
|
+
if (name.endsWith('*')) {
|
|
28
|
+
explode = true;
|
|
29
|
+
name = name.substring(0, name.length - 1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (name.startsWith('.')) {
|
|
33
|
+
name = name.substring(1);
|
|
34
|
+
style = 'label';
|
|
35
|
+
} else if (name.startsWith(';')) {
|
|
36
|
+
name = name.substring(1);
|
|
37
|
+
style = 'matrix';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const value = path[name];
|
|
41
|
+
|
|
42
|
+
if (value === undefined || value === null) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (Array.isArray(value)) {
|
|
47
|
+
url = url.replace(
|
|
48
|
+
match,
|
|
49
|
+
serializeArrayParam({ explode, name, style, value }),
|
|
50
|
+
);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (typeof value === 'object') {
|
|
55
|
+
url = url.replace(
|
|
56
|
+
match,
|
|
57
|
+
serializeObjectParam({
|
|
58
|
+
explode,
|
|
59
|
+
name,
|
|
60
|
+
style,
|
|
61
|
+
value: value as Record<string, unknown>,
|
|
62
|
+
valueOnly: true,
|
|
63
|
+
}),
|
|
64
|
+
);
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (style === 'matrix') {
|
|
69
|
+
url = url.replace(
|
|
70
|
+
match,
|
|
71
|
+
`;${serializePrimitiveParam({
|
|
72
|
+
name,
|
|
73
|
+
value: value as string,
|
|
74
|
+
})}`,
|
|
75
|
+
);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const replaceValue = encodeURIComponent(
|
|
80
|
+
style === 'label' ? `.${value as string}` : (value as string),
|
|
81
|
+
);
|
|
82
|
+
url = url.replace(match, replaceValue);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return url;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export const getUrl = ({
|
|
89
|
+
baseUrl,
|
|
90
|
+
path,
|
|
91
|
+
query,
|
|
92
|
+
querySerializer,
|
|
93
|
+
url: _url,
|
|
94
|
+
}: {
|
|
95
|
+
baseUrl?: string;
|
|
96
|
+
path?: Record<string, unknown>;
|
|
97
|
+
query?: Record<string, unknown>;
|
|
98
|
+
querySerializer: QuerySerializer;
|
|
99
|
+
url: string;
|
|
100
|
+
}) => {
|
|
101
|
+
const pathUrl = _url.startsWith('/') ? _url : `/${_url}`;
|
|
102
|
+
let url = (baseUrl ?? '') + pathUrl;
|
|
103
|
+
if (path) {
|
|
104
|
+
url = defaultPathSerializer({ path, url });
|
|
105
|
+
}
|
|
106
|
+
let search = query ? querySerializer(query) : '';
|
|
107
|
+
if (search.startsWith('?')) {
|
|
108
|
+
search = search.substring(1);
|
|
109
|
+
}
|
|
110
|
+
if (search) {
|
|
111
|
+
url += `?${search}`;
|
|
112
|
+
}
|
|
113
|
+
return url;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export function getValidRequestBody(options: {
|
|
117
|
+
body?: unknown;
|
|
118
|
+
bodySerializer?: BodySerializer | null;
|
|
119
|
+
serializedBody?: unknown;
|
|
120
|
+
}) {
|
|
121
|
+
const hasBody = options.body !== undefined;
|
|
122
|
+
const isSerializedBody = hasBody && options.bodySerializer;
|
|
123
|
+
|
|
124
|
+
if (isSerializedBody) {
|
|
125
|
+
if ('serializedBody' in options) {
|
|
126
|
+
const hasSerializedBody =
|
|
127
|
+
options.serializedBody !== undefined && options.serializedBody !== '';
|
|
128
|
+
|
|
129
|
+
return hasSerializedBody ? options.serializedBody : null;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// not all clients implement a serializedBody property (i.e. client-axios)
|
|
133
|
+
return options.body !== '' ? options.body : null;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// plain/text body
|
|
137
|
+
if (hasBody) {
|
|
138
|
+
return options.body;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// no body was provided
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
package/src/util/http.ts
CHANGED
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
import http from "node:http";
|
|
2
2
|
import type { AddressInfo } from "node:net";
|
|
3
|
-
import { Readable } from "node:stream";
|
|
3
|
+
import { Readable, type Duplex } from "node:stream";
|
|
4
|
+
import { WebSocketServer, type WebSocket } from "ws";
|
|
4
5
|
|
|
5
6
|
export class HTTPServer {
|
|
6
|
-
httpServer
|
|
7
|
+
httpServer = http.createServer();
|
|
8
|
+
webSocketServer?: WebSocketServer;
|
|
7
9
|
|
|
8
10
|
constructor(options: {
|
|
11
|
+
websocket?: (request: Request) => Promise<WebSocket>;
|
|
9
12
|
fetch: (request: Request) => Promise<Response>;
|
|
10
13
|
}) {
|
|
11
|
-
this.httpServer = http.createServer();
|
|
12
14
|
this.httpServer.on("request", async (req, res) => {
|
|
13
15
|
const response = await options.fetch(toWebRequest(req));
|
|
14
16
|
await writeNodeResponse(res, response);
|
|
15
17
|
});
|
|
18
|
+
const websocket = options.websocket;
|
|
19
|
+
if (websocket) {
|
|
20
|
+
const webSocketServer = new WebSocketServer({ noServer: true });
|
|
21
|
+
this.webSocketServer = webSocketServer;
|
|
22
|
+
this.httpServer.on("upgrade", async (req, socket, head) => {
|
|
23
|
+
const ws = await websocket(toWebRequest(req));
|
|
24
|
+
coupleWebSocket(webSocketServer, req, socket, head, ws);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
16
27
|
}
|
|
17
28
|
|
|
18
29
|
listen(port?: number) {
|
|
@@ -36,19 +47,35 @@ export class HTTPServer {
|
|
|
36
47
|
return `http://${hostname}:${address.port}`;
|
|
37
48
|
}
|
|
38
49
|
|
|
39
|
-
close() {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
} else {
|
|
45
|
-
resolve(undefined);
|
|
46
|
-
}
|
|
50
|
+
async close() {
|
|
51
|
+
const webSocketServer = this.webSocketServer;
|
|
52
|
+
if (webSocketServer) {
|
|
53
|
+
await new Promise<void>((resolve, reject) => {
|
|
54
|
+
webSocketServer.close((err) => (err ? reject(err) : resolve()));
|
|
47
55
|
});
|
|
56
|
+
}
|
|
57
|
+
await new Promise<void>((resolve, reject) => {
|
|
58
|
+
this.httpServer.close((err) => (err ? reject(err) : resolve()));
|
|
48
59
|
});
|
|
49
60
|
}
|
|
50
61
|
}
|
|
51
62
|
|
|
63
|
+
export function coupleWebSocket(
|
|
64
|
+
wss: WebSocketServer,
|
|
65
|
+
req: http.IncomingMessage,
|
|
66
|
+
socket: Duplex,
|
|
67
|
+
head: Buffer,
|
|
68
|
+
server: WebSocket,
|
|
69
|
+
) {
|
|
70
|
+
wss.handleUpgrade(req, socket, head, (client) => {
|
|
71
|
+
client.on("message", (event, binary) => server.send(event, { binary }));
|
|
72
|
+
client.on("close", (code, reason) => server.close(code, reason));
|
|
73
|
+
server.on("message", (event, binary) => client.send(event, { binary }));
|
|
74
|
+
server.on("close", (code, reason) => client.close(code, reason));
|
|
75
|
+
wss.emit("connection", client, req);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
52
79
|
export function toWebRequest(
|
|
53
80
|
req: http.IncomingMessage,
|
|
54
81
|
host?: string,
|
|
@@ -161,7 +161,7 @@ export async function idempotentSpawn({
|
|
|
161
161
|
{
|
|
162
162
|
write,
|
|
163
163
|
chunkSize = 64 * 1024,
|
|
164
|
-
|
|
164
|
+
tickMs = 100,
|
|
165
165
|
}: {
|
|
166
166
|
stateKey: string;
|
|
167
167
|
write: (buf: Buffer) => boolean;
|
|
@@ -229,15 +229,14 @@ export async function idempotentSpawn({
|
|
|
229
229
|
await drain();
|
|
230
230
|
});
|
|
231
231
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
// }, tickMs);
|
|
232
|
+
const tick = setInterval(() => {
|
|
233
|
+
drain().catch(() => {});
|
|
234
|
+
}, tickMs);
|
|
236
235
|
|
|
237
236
|
return async function stop() {
|
|
238
237
|
closed = true;
|
|
239
238
|
watcher.close();
|
|
240
|
-
|
|
239
|
+
clearInterval(tick);
|
|
241
240
|
await fh.close().catch(() => {});
|
|
242
241
|
await persist();
|
|
243
242
|
};
|
package/src/util/lock.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import lockfile from "proper-lockfile";
|
|
5
|
+
|
|
6
|
+
const LOCK_DIR = path.join(os.homedir(), ".alchemy", "lock");
|
|
7
|
+
|
|
8
|
+
export class Lock {
|
|
9
|
+
private path: string;
|
|
10
|
+
constructor(key: string) {
|
|
11
|
+
this.path = path.join(LOCK_DIR, encodeURIComponent(key));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Acquires the lock.
|
|
16
|
+
* @returns A function to release the lock, or null if the lock is already acquired.
|
|
17
|
+
*/
|
|
18
|
+
async acquire() {
|
|
19
|
+
try {
|
|
20
|
+
await fs.mkdir(LOCK_DIR, { recursive: true });
|
|
21
|
+
return await lockfile.lock(LOCK_DIR, {
|
|
22
|
+
lockfilePath: this.path,
|
|
23
|
+
});
|
|
24
|
+
} catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Checks if the lock is active.
|
|
31
|
+
* @returns True if the lock is active, false otherwise.
|
|
32
|
+
*/
|
|
33
|
+
async check() {
|
|
34
|
+
return await lockfile.check(LOCK_DIR, {
|
|
35
|
+
lockfilePath: this.path,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Waits for the lock to be released.
|
|
41
|
+
* @param interval The interval to wait between checks.
|
|
42
|
+
*/
|
|
43
|
+
async wait(interval = 100) {
|
|
44
|
+
while (await this.check()) {
|
|
45
|
+
await new Promise((resolve) => setTimeout(resolve, interval));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
package/src/util/memoize.ts
CHANGED
|
@@ -25,6 +25,32 @@ export function memoize<F extends (...args: any[]) => Promise<any>>(
|
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Single flight memoization.
|
|
30
|
+
* Ensures only one instance of the function is executed at a time.
|
|
31
|
+
* If another instance is already executing, returns the in-flight promise.
|
|
32
|
+
*/
|
|
33
|
+
export function singleFlight<F extends (...args: any[]) => Promise<any>>(
|
|
34
|
+
fn: F,
|
|
35
|
+
keyFn: (...args: Parameters<F>) => string = defaultKeyFn,
|
|
36
|
+
) {
|
|
37
|
+
const cache = new Map<string, Promise<AsyncReturnType<F>>>();
|
|
38
|
+
return async (...args: Parameters<F>): Promise<AsyncReturnType<F>> => {
|
|
39
|
+
const key = keyFn(...args);
|
|
40
|
+
const cached = cache.get(key);
|
|
41
|
+
if (cached) {
|
|
42
|
+
return await cached;
|
|
43
|
+
}
|
|
44
|
+
const promise = fn(...args);
|
|
45
|
+
cache.set(key, promise);
|
|
46
|
+
try {
|
|
47
|
+
return await promise;
|
|
48
|
+
} finally {
|
|
49
|
+
cache.delete(key);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
28
54
|
export function defaultKeyFn(...args: any[]): string {
|
|
29
55
|
return createHash("sha256")
|
|
30
56
|
.update(
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
import type { Credentials } from "../auth.ts";
|
|
3
|
+
import { DeferredPromise } from "./deferred-promise.ts";
|
|
4
|
+
import { HTTPServer } from "./http.ts";
|
|
5
|
+
|
|
6
|
+
export class OAuthError extends Error {
|
|
7
|
+
readonly error: string;
|
|
8
|
+
constructor({
|
|
9
|
+
error,
|
|
10
|
+
error_description,
|
|
11
|
+
...rest
|
|
12
|
+
}: OAuthClient.ErrorResponse) {
|
|
13
|
+
super(error_description);
|
|
14
|
+
this.error = error;
|
|
15
|
+
this.name = "OAuthError";
|
|
16
|
+
Object.assign(this, rest);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Generic OAuth 2.0 client.
|
|
22
|
+
*
|
|
23
|
+
* Currently only handles the subset required for Cloudflare, but can be modified easily:
|
|
24
|
+
* - authorization and refresh code flow
|
|
25
|
+
* - S256 code challenge
|
|
26
|
+
* - no client secret
|
|
27
|
+
*/
|
|
28
|
+
export class OAuthClient {
|
|
29
|
+
constructor(
|
|
30
|
+
private readonly options: {
|
|
31
|
+
clientId: string;
|
|
32
|
+
redirectUri: string;
|
|
33
|
+
endpoints: {
|
|
34
|
+
authorize: string;
|
|
35
|
+
token: string;
|
|
36
|
+
revoke: string;
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
) {}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Generate an authorization URL, state, and verifier for the given scopes.
|
|
43
|
+
*/
|
|
44
|
+
authorize(scopes: string[]): OAuthClient.Authorization {
|
|
45
|
+
const state = generateState();
|
|
46
|
+
const pkce = generatePKCE();
|
|
47
|
+
const url = new URL(this.options.endpoints.authorize);
|
|
48
|
+
url.searchParams.set("client_id", this.options.clientId);
|
|
49
|
+
url.searchParams.set("redirect_uri", this.options.redirectUri);
|
|
50
|
+
url.searchParams.set("response_type", "code");
|
|
51
|
+
url.searchParams.set("scope", scopes.join(" "));
|
|
52
|
+
url.searchParams.set("state", state);
|
|
53
|
+
url.searchParams.set("code_challenge", pkce.challenge);
|
|
54
|
+
url.searchParams.set("code_challenge_method", "S256");
|
|
55
|
+
return { url: url.toString(), state, verifier: pkce.verifier };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Exchange an authorization code for credentials.
|
|
60
|
+
*/
|
|
61
|
+
async exchange(code: string, verifier: string): Promise<Credentials.OAuth> {
|
|
62
|
+
const res = await this.request(this.options.endpoints.token, {
|
|
63
|
+
grant_type: "authorization_code",
|
|
64
|
+
code,
|
|
65
|
+
code_verifier: verifier,
|
|
66
|
+
client_id: this.options.clientId,
|
|
67
|
+
redirect_uri: this.options.redirectUri,
|
|
68
|
+
});
|
|
69
|
+
return await extractCredentialsFromResponse(res);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Refresh OAuth 2.0 credentials.
|
|
74
|
+
*/
|
|
75
|
+
async refresh(credentials: Credentials.OAuth): Promise<Credentials.OAuth> {
|
|
76
|
+
const res = await this.request(this.options.endpoints.token, {
|
|
77
|
+
grant_type: "refresh_token",
|
|
78
|
+
refresh_token: credentials.refresh,
|
|
79
|
+
client_id: this.options.clientId,
|
|
80
|
+
redirect_uri: this.options.redirectUri,
|
|
81
|
+
});
|
|
82
|
+
return await extractCredentialsFromResponse(res);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Revoke OAuth 2.0 credentials.
|
|
87
|
+
*/
|
|
88
|
+
async revoke(credentials: Credentials.OAuth): Promise<void> {
|
|
89
|
+
await this.request(this.options.endpoints.revoke, {
|
|
90
|
+
refresh_token: credentials.refresh,
|
|
91
|
+
client_id: this.options.clientId,
|
|
92
|
+
redirect_uri: this.options.redirectUri,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Make a POST request to the OAuth provider with the given urlencoded body.
|
|
98
|
+
*/
|
|
99
|
+
private async request(url: string, body: Record<string, string>) {
|
|
100
|
+
const res = await fetch(url, {
|
|
101
|
+
method: "POST",
|
|
102
|
+
headers: {
|
|
103
|
+
Accept: "application/json",
|
|
104
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
105
|
+
},
|
|
106
|
+
body: new URLSearchParams(body).toString(),
|
|
107
|
+
});
|
|
108
|
+
if (!res.ok) {
|
|
109
|
+
const json = await res.json();
|
|
110
|
+
throw new OAuthError(json as OAuthClient.ErrorResponse);
|
|
111
|
+
}
|
|
112
|
+
return res;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Listens for the callback from the provider by starting a local HTTP server and exchanges the authorization code for credentials.
|
|
117
|
+
* Should be called with the authorization object returned by {@link authorize}.
|
|
118
|
+
* Listens for the callback on the client's redirect URI.
|
|
119
|
+
* Throws if the request is invalid, the code exchange fails, or if no callback is received within 5 minutes.
|
|
120
|
+
*/
|
|
121
|
+
async callback(
|
|
122
|
+
authorization: OAuthClient.Authorization,
|
|
123
|
+
): Promise<Credentials.OAuth> {
|
|
124
|
+
const { pathname, port } = new URL(this.options.redirectUri);
|
|
125
|
+
const promise = new DeferredPromise<Credentials.OAuth>();
|
|
126
|
+
const handle = async (request: Request) => {
|
|
127
|
+
const url = new URL(request.url);
|
|
128
|
+
if (url.pathname !== pathname) {
|
|
129
|
+
throw new OAuthError({
|
|
130
|
+
error: "invalid_request",
|
|
131
|
+
error_description: "Invalid redirect URI",
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
const error = url.searchParams.get("error");
|
|
135
|
+
const errorDescription = url.searchParams.get("error_description");
|
|
136
|
+
if (error) {
|
|
137
|
+
throw new OAuthError({
|
|
138
|
+
error,
|
|
139
|
+
error_description: errorDescription ?? "An unknown error occurred.",
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
const code = url.searchParams.get("code");
|
|
143
|
+
const state = url.searchParams.get("state");
|
|
144
|
+
if (!code || !state) {
|
|
145
|
+
throw new OAuthError({
|
|
146
|
+
error: "invalid_request",
|
|
147
|
+
error_description: "Missing code or state",
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
if (state !== authorization.state) {
|
|
151
|
+
throw new OAuthError({
|
|
152
|
+
error: "invalid_request",
|
|
153
|
+
error_description: "Invalid state",
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
return await this.exchange(code, authorization.verifier);
|
|
157
|
+
};
|
|
158
|
+
const server = new HTTPServer({
|
|
159
|
+
fetch: async (req) => {
|
|
160
|
+
try {
|
|
161
|
+
const result = await handle(req);
|
|
162
|
+
promise.resolve(result);
|
|
163
|
+
return Response.redirect("http://alchemy.run/auth/success");
|
|
164
|
+
} catch (error) {
|
|
165
|
+
promise.reject(error);
|
|
166
|
+
return Response.redirect("http://alchemy.run/auth/error");
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
await server.listen(Number(port));
|
|
171
|
+
const timeout = setTimeout(
|
|
172
|
+
() => {
|
|
173
|
+
promise.reject(
|
|
174
|
+
new OAuthError({
|
|
175
|
+
error: "timeout",
|
|
176
|
+
error_description: "The authorization process timed out.",
|
|
177
|
+
}),
|
|
178
|
+
);
|
|
179
|
+
},
|
|
180
|
+
1000 * 60 * 5,
|
|
181
|
+
);
|
|
182
|
+
try {
|
|
183
|
+
const result = await promise.value;
|
|
184
|
+
clearTimeout(timeout);
|
|
185
|
+
return result;
|
|
186
|
+
} finally {
|
|
187
|
+
// Not awaited because the server can take a few seconds to close, don't want to block the login process from completing
|
|
188
|
+
void server.close();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export declare namespace OAuthClient {
|
|
194
|
+
export interface ErrorResponse {
|
|
195
|
+
error: string;
|
|
196
|
+
error_description: string;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export interface SuccessResponse {
|
|
200
|
+
access_token: string;
|
|
201
|
+
refresh_token: string;
|
|
202
|
+
expires_in: number;
|
|
203
|
+
scope: string;
|
|
204
|
+
token_type: string;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export interface Authorization {
|
|
208
|
+
url: string;
|
|
209
|
+
state: string;
|
|
210
|
+
verifier: string;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
async function extractCredentialsFromResponse(
|
|
215
|
+
response: Response,
|
|
216
|
+
): Promise<Credentials.OAuth> {
|
|
217
|
+
const json = (await response.json()) as OAuthClient.SuccessResponse;
|
|
218
|
+
return {
|
|
219
|
+
type: "oauth",
|
|
220
|
+
access: json.access_token,
|
|
221
|
+
refresh: json.refresh_token,
|
|
222
|
+
expires: Date.now() + json.expires_in * 1000,
|
|
223
|
+
scopes: json.scope.split(" "),
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function generateState(length = 32) {
|
|
228
|
+
return crypto.randomBytes(length).toString("base64url");
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function generatePKCE(length = 96) {
|
|
232
|
+
const verifier = crypto.randomBytes(length).toString("base64url");
|
|
233
|
+
const challenge = crypto
|
|
234
|
+
.createHash("sha256")
|
|
235
|
+
.update(verifier)
|
|
236
|
+
.digest("base64url");
|
|
237
|
+
return { verifier, challenge };
|
|
238
|
+
}
|