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

main
ts 47 lines 1.3 KB
Raw
1 import type { VerifySecretKeyError } from "@distilled.cloud/fly-io/machines";
2 import * as Binding from "alchemy/Binding";
3 import type { RuntimeContext } from "alchemy/RuntimeContext";
4 import type * as Effect from "effect/Effect";
5 import type { SecretKey } from "./SecretKey.ts";
6
7 export interface VerifyRequest {
8 /** Original payload. */
9 plaintext: Uint8Array | ArrayLike<number>;
10 /** Signature produced by {@link Sign}. */
11 signature: Uint8Array | ArrayLike<number>;
12 }
13
14 export interface VerifyResult {
15 /** Fly returns 200 only when the signature is valid. */
16 valid: true;
17 }
18
19 /**
20 * Verify a signature with a Fly {@link SecretKey}. The App and key
21 * name are fixed by `Verify(key)`.
22 *
23 *
24 * ### Verify a signature
25 * Provide {@link VerifyHttp}. A bad signature is a typed error from
26 * the Machines API, not `valid: false`.
27 *
28 * **Example:** Verify
29 * ```typescript
30 * const verify = yield* Fly.Verify(Signing);
31 * const { valid } = yield* verify({ plaintext, signature });
32 * ```
33 *
34 * @binding
35 * @product Secret Key
36 */
37 export interface Verify extends Binding.Service<
38 Verify,
39 "Fly.Verify",
40 (
41 key: SecretKey,
42 ) => Effect.Effect<
43 (request: VerifyRequest) => Effect.Effect<VerifyResult, VerifySecretKeyError, RuntimeContext>
44 >
45 > {}
46
47 export const Verify = Binding.Service<Verify>("Fly.Verify");