identity-sync/github-identity-attestation-attempt-store
@sarj-ai/workspace-sync/identity-sync/github-identity-attestation-attempt-store ยท Source
import type { D1Database } from "@cloudflare/workers-types";import { z } from "zod";import { type GitHubIdentityAdminAttestationPlan } from "./github-identity-admin-attestation.ts";import { type ActiveResourceLease } from "./resource-lease.ts";declare const AttemptSchema: z.ZodObject<{ schemaVersion: z.ZodLiteral<"google-identity-attestation-attempt/v1">; plan: z.ZodReadonly<z.ZodObject<{ entries: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{ attestation: z.ZodReadonly<z.ZodObject<{ githubLogin: z.core.$ZodBranded<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, "GitHubLogin", "out">; subject: z.ZodDiscriminatedUnion<[z.ZodObject<{ googleUserId: z.core.$ZodBranded<z.ZodString, "GoogleUserId", "out">; kind: z.ZodLiteral<"google-user-id">; }, z.core.$strict>, z.ZodObject<{ kind: z.ZodLiteral<"primary-email">; primaryEmail: z.core.$ZodBranded<z.ZodPipe<z.ZodString, z.ZodEmail>, "PrimaryEmail", "out">; }, z.core.$strict>], "kind">; attestedAt: z.ZodISODateTime; attestedBy: z.core.$ZodBranded<z.ZodString, "AdminActorId", "out">; }, z.core.$strict>>; googlePlan: z.ZodUnion<readonly [z.ZodObject<{ current: z.ZodNullable<z.ZodObject<{ githubLogin: z.ZodOptional<z.core.$ZodBranded<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, "GitHubLogin", "out">>; githubUserId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "GitHubUserId", "out">>; }, z.core.$strict>>; desired: z.ZodObject<{ githubLogin: z.core.$ZodBranded<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, "GitHubLogin", "out">; githubUserId: z.core.$ZodBranded<z.ZodString, "GitHubUserId", "out">; }, z.core.$strict>; kind: z.ZodLiteral<"update">; user: z.ZodObject<{ etag: z.ZodString; id: z.core.$ZodBranded<z.ZodString, "GoogleUserId", "out">; primaryEmail: z.ZodEmail; }, z.core.$strict>; }, z.core.$strict>, z.ZodObject<{ identity: z.ZodObject<{ githubLogin: z.core.$ZodBranded<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, "GitHubLogin", "out">; githubUserId: z.core.$ZodBranded<z.ZodString, "GitHubUserId", "out">; }, z.core.$strict>; kind: z.ZodLiteral<"unchanged">; user: z.ZodObject<{ etag: z.ZodString; id: z.core.$ZodBranded<z.ZodString, "GoogleUserId", "out">; primaryEmail: z.ZodEmail; }, z.core.$strict>; }, z.core.$strict>]>; target: z.ZodObject<{ githubLogin: z.core.$ZodBranded<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, "GitHubLogin", "out">; githubUserId: z.core.$ZodBranded<z.ZodString, "GitHubUserId", "out">; }, z.core.$strict>; }, z.core.$strict>>>>; planHash: z.ZodString; schemaVersion: z.ZodLiteral<"github-identity-admin-attestation-plan/v1">; }, z.core.$strict>>; deadlineAtMs: z.ZodNumber; recoverAfterMs: z.ZodNumber; attemptedAtMs: z.ZodNumber;}, z.core.$strict>;declare const ObservationSchema: z.ZodObject<{ googleUserId: z.ZodString; primaryEmail: z.ZodEmail; identity: z.ZodNullable<z.ZodObject<{ githubLogin: z.core.$ZodBranded<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, "GitHubLogin", "out">; githubUserId: z.core.$ZodBranded<z.ZodString, "GitHubUserId", "out">; }, z.core.$strict>>;}, z.core.$strict>;export interface IdentityAttestationAttempt { attemptId: string; resolution: { kind: "observed-after" | "observed-before" | "write-verified"; observation: z.output<typeof ObservationSchema>; } | null; snapshot: z.output<typeof AttemptSchema>;}/** Append-only attempted writes remain admission debt until an exact provider observation is durably attached. */interface ResolveIdentityAttemptInput { attemptId: string; changeHash?: string; kind: "observed-after" | "observed-before" | "write-verified"; lease: ActiveResourceLease; wire: unknown;}export interface IGitHubIdentityAttestationAttemptStore { begin(plan: GitHubIdentityAdminAttestationPlan, lease: ActiveResourceLease, deadlineAtMs: number): Promise<string>; latest(): Promise<IdentityAttestationAttempt | null>; read(attemptId: string): Promise<IdentityAttestationAttempt>; resolve(input: ResolveIdentityAttemptInput): Promise<void>;}export declare class GitHubIdentityAttestationAttemptStore implements IGitHubIdentityAttestationAttemptStore { #private; constructor(database: D1Database, now?: () => number); begin(planInput: GitHubIdentityAdminAttestationPlan, lease: ActiveResourceLease, deadlineAtMs: number): Promise<string>; latest(): Promise<IdentityAttestationAttempt | null>; read(attemptId: string): Promise<IdentityAttestationAttempt>; resolve(input: ResolveIdentityAttemptInput): Promise<void>;}export declare function observeIdentityAttempt(attempt: IdentityAttestationAttempt, wire: unknown): z.output<typeof ObservationSchema>;export declare function classifyIdentityAttempt(attempt: IdentityAttestationAttempt, observation: z.output<typeof ObservationSchema>): "after" | "before" | "drifted";export {};