The best way to control Claude Code, Codex and more from any computer or phone

main
ts 35 lines 1.19 KB
Raw
1 import { ConfigError } from "@distilled.cloud/core/errors";
2 import { Credentials } from "@distilled.cloud/stripe";
3 import { lazyCredentials } from "alchemy/Auth/Resolve";
4 import * as Layer from "effect/Layer";
5 import { STRIPE_AUTH_PROVIDER_NAME, type StripeResolvedCredentials } from "./AuthProvider.ts";
6
7 export {
8 Credentials,
9 CredentialsFromEnv,
10 credentials,
11 DEFAULT_API_BASE_URL,
12 type Config as CredentialsConfig,
13 } from "@distilled.cloud/stripe";
14
15 /**
16 * Build a Stripe `Credentials` layer that resolves credentials via the
17 * Alchemy AuthProvider using the configured profile (defaults to "default",
18 * overridable with the `ALCHEMY_PROFILE` env/config value).
19 *
20 * Maps onto `@distilled.cloud/stripe`'s `{ apiKey, apiBaseUrl }` shape.
21 * Distilled's `Credentials` service is an `Effect<Config>` resolved per
22 * request. Environment credentials (`STRIPE_API_KEY`) take precedence;
23 * otherwise the selected profile is used.
24 */
25 export const fromAuthProvider = () =>
26 Layer.effect(
27 Credentials,
28 lazyCredentials<StripeResolvedCredentials, ConfigError>()(
29 STRIPE_AUTH_PROVIDER_NAME,
30 (creds) => ({
31 apiKey: creds.apiKey,
32 apiBaseUrl: creds.apiBaseUrl,
33 }),
34 ),
35 );