import { MsgHdrs } from '@nats-io/nats-core'; import { ActorRefFrom } from 'xstate'; import { type AuthConfig } from '../actions/types'; export interface NatsCredentials { auth?: AuthConfig; requestHeaders?: MsgHdrs; /** Epoch milliseconds after which these credentials must not be used. Use the earliest expiry. */ expiresAt?: number; } export interface NatsCredentialAdapter { load: () => Promise; refresh?: (current: NatsCredentials) => Promise; } export interface NatsCredentialConfig { adapter: NatsCredentialAdapter; /** Refresh this long before expiry. Defaults to 60 seconds. */ refreshBeforeExpiryMs?: number; /** Maximum duration of one adapter load or refresh. Defaults to 30 seconds. */ operationTimeoutMs?: number; /** Called when credentials expire or cannot be loaded/refreshed. */ onUnavailable?: (error: Error) => void; /** Emit sanitized credential lifecycle debug logs. */ diagnostics?: boolean; } type CredentialResult = { ok: true; credentials: NatsCredentials; } | { ok: false; error: Error; }; type Waiter = (result: CredentialResult) => void; export interface CredentialContext { config: NatsCredentialConfig; current?: NatsCredentials; waiters: Waiter[]; error?: Error; } export declare const credentialMachine: import("xstate").StateMachine | import("xstate").PromiseActorLogic> | undefined; }, { src: "load"; logic: import("xstate").PromiseActorLogic; id: string | undefined; } | { src: "refresh"; logic: import("xstate").PromiseActorLogic; id: string | undefined; }, { type: "acceptCredentials"; params: import("xstate").NonReducibleUnknown; } | { type: "markExpired"; params: import("xstate").NonReducibleUnknown; } | { type: "notifyUnavailable"; params: unknown; } | { type: "queue"; params: import("xstate").NonReducibleUnknown; } | { type: "rejectWaiters"; params: import("xstate").NonReducibleUnknown; } | { type: "replyReady"; params: unknown; } | { type: "storeCredentials"; params: import("xstate").NonReducibleUnknown; }, { type: "canRefresh"; params: unknown; } | { type: "hasExpiry"; params: unknown; } | { type: "isExpired"; params: unknown; } | { type: "outputExpired"; params: unknown; } | { type: "outputShouldRefresh"; params: unknown; } | { type: "shouldRefreshNow"; params: unknown; }, "credentialDeadline", "expired" | "failed" | "loading" | "ready" | "refreshing", string, NatsCredentialConfig, import("xstate").NonReducibleUnknown, import("xstate").EventObject, import("xstate").MetaObject, { id: "credentials"; states: { readonly loading: {}; readonly ready: {}; readonly refreshing: {}; readonly expired: {}; readonly failed: {}; }; }, import("xstate").MetaObject>; export type CredentialActor = ActorRefFrom; export declare function getCredentials(actor: CredentialActor): Promise; export {}; //# sourceMappingURL=credentials.d.ts.map