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

main
ts 23 lines 871 Bytes
Raw
1 /**
2 * Shared scaffolding for Fly SecretKey HTTP bindings.
3 *
4 * NOT exported from `index.ts`.
5 */
6 import type * as Effect from "effect/Effect";
7 import type { SecretAuth } from "./SecretHttp.ts";
8 import { makeHttpSecretBinding } from "./SecretHttp.ts";
9 import type { SecretKey } from "./SecretKey.ts";
10
11 export const bytesToBase64 = (bytes: Uint8Array | ArrayLike<number>): string =>
12 Buffer.from(bytes instanceof Uint8Array ? bytes : Uint8Array.from(bytes)).toString("base64");
13
14 export const base64ToBytes = (value: string | undefined): Uint8Array =>
15 Uint8Array.from(Buffer.from(value ?? "", "base64"));
16
17 export const makeHttpSecretKeyBinding = <Client>(options: {
18 makeClient: (
19 auth: SecretAuth,
20 appName: Effect.Effect<string>,
21 secretName: Effect.Effect<string>,
22 ) => Client;
23 }) => makeHttpSecretBinding<SecretKey, Client>({ ...options, kms: true });