// Generated by `cargo run --bin gen-shared-types`. DO NOT EDIT BY HAND.
//
// Source of truth is the Rust types in `crates/tonin-client/src/`.
// Any manual edit to this file will be reverted next time the
// generator runs.


/** Who is making the call. Lowercase values match the Rust enum. */
export enum PrincipalKind {
  USER = "user",
  SERVICE = "service",
  AGENT = "agent",
  ANONYMOUS = "anonymous",
}

/** A token as extracted from a request, before verification. */
export interface RawToken {
  /** The token string itself. */
  value: string;
  /** Conventions: bearer-jwt, api-key, session-cookie, basic-auth. Default: `"bearer-jwt"`. */
  kind: string;
}

/** Identity + claims for the current request. The single concrete type that flows through the framework across languages. */
export interface AuthCtx {
  /** `sub` JWT claim. User ID for users, service ID for services. Default: `""`. */
  subject: string;
  /** `iss` JWT claim. Default: `""`. */
  issuer: string;
  /** `aud` JWT claim. Default: `""`. */
  audience: string;
  /** OAuth-style scopes. Default: `[]`. */
  scopes: string[];
  /** Principal class. Default: `PrincipalKind.ANONYMOUS`. */
  kind: PrincipalKind;
  /** Verbatim token, used by `propagate` on outbound calls. Default: `""`. */
  raw_token: string;
  /** Unix-seconds expiry of the token. Default: `0`. */
  expires_at: number;
  /** Custom claims not mapped to typed fields. Default: `{}`. */
  extra: Record<string, unknown>;
}

/** Retry backoff strategy. */
export enum Backoff {
  EXPONENTIAL = "exponential",
  FIXED = "fixed",
}

/** Retry behavior for an outbound RPC. Same defaults as Rust. */
export interface RetryPolicy {
  /** Total attempts including the first. 1 = no retry. Default: `1`. */
  max_attempts: number;
  /** Delay before the first retry, in seconds. Default: `0`. */
  initial_backoff_secs: number;
  /** Backoff growth strategy. Default: `Backoff.FIXED`. */
  backoff: Backoff;
  /** Exponential multiplier; ignored when backoff == FIXED. Default: `2.0`. */
  multiplier: number;
  /** Cap on any single backoff interval, in seconds. Default: `1`. */
  max_backoff_secs: number;
}

/** Breaker config for outbound RPCs. Same defaults as Rust. */
export interface CircuitBreaker {
  /** Rolling window for failure-rate calculation. Default: `10`. */
  window_secs: number;
  /** Failure ratio in (0, 1] at which the breaker trips. Default: `0.5`. */
  trip_threshold: number;
  /** Minimum requests in the window before the breaker can trip. Default: `20`. */
  min_requests: number;
  /** How long the breaker stays Open before HalfOpen. Default: `30`. */
  reset_after_secs: number;
  /** Probe requests allowed through in HalfOpen. Default: `3`. */
  half_open_probes: number;
}
