import { O as OAuthResponse, bm as AuthenticationRequestSchema, ld as PhoneNumberSchema, cp as ChallengeResonse, bn as AuthenticationResponse, bi as AuthResponse, ip as Login, py as ServiceDescriptors } from './services-Dj0Rx7KU.js';
import { MessageInitShape } from '@bufbuild/protobuf';
import { Client } from '@connectrpc/connect';

type MaybePromise<T> = T | Promise<T>;
interface TokenStore {
    get(): MaybePromise<OAuthResponse | undefined>;
    set(token: OAuthResponse): MaybePromise<void>;
    clear(): MaybePromise<void>;
}
interface CachedIdentity {
    userId: string;
    displayName?: string;
    updatedAt: string;
}
interface IdentityStore {
    get(): MaybePromise<CachedIdentity | undefined>;
    set(identity: CachedIdentity): MaybePromise<void>;
    clear(): MaybePromise<void>;
}
declare function createMemoryTokenStore(initialToken?: OAuthResponse): TokenStore;
declare function createMemoryIdentityStore(initialIdentity?: CachedIdentity): IdentityStore;
interface BrowserIdentityStoreOptions {
    storageKey?: string;
}
declare const defaultBrowserIdentityStorageKey = "orderly.identity";
declare function createBrowserLocalStorageIdentityStore(options?: BrowserIdentityStoreOptions): IdentityStore;
declare function sanitizeCachedIdentity(identity: Partial<CachedIdentity> | undefined | null): CachedIdentity | undefined;

type OrderlyServices = {
    readonly [K in keyof ServiceDescriptors]: Client<ServiceDescriptors[K]>;
};
type PhoneNumberInput = MessageInitShape<typeof PhoneNumberSchema>;
type AuthenticationRequestInput = MessageInitShape<typeof AuthenticationRequestSchema>;
type OrderlyAuthConfig = {
    type: "none";
} | {
    type: "apiKey";
    apiKey: string;
} | {
    type: "bearer";
    token: string;
} | {
    type: "oauth";
    token: OAuthResponse;
} | {
    type: "cookie";
};
interface CreateChallengeOptions {
    phoneNumber: PhoneNumberInput;
    apiKey?: string;
}
interface SmsChallengeOptions {
    phoneNumber: PhoneNumberInput;
    code: string;
}
interface PasswordCredentialsOptions {
    username: string;
    password: string;
}
interface AccessKeyCredentialsOptions {
    key: string;
}
interface PinCodeCredentialsOptions {
    employeeId: string;
    pin: number;
}
interface OrderlyAuthHelpers {
    createChallenge(options: CreateChallengeOptions): Promise<ChallengeResonse>;
    authenticate(request: AuthenticationRequestInput): Promise<AuthenticationResponse>;
    authenticateWithSmsChallenge(options: SmsChallengeOptions): Promise<AuthenticationResponse>;
    authenticateWithPassword(options: PasswordCredentialsOptions): Promise<AuthenticationResponse>;
    authenticateWithAccessKey(options: AccessKeyCredentialsOptions): Promise<AuthenticationResponse>;
    authenticateWithPinCode(options: PinCodeCredentialsOptions): Promise<AuthenticationResponse>;
    acceptChallengeLegacy(options: SmsChallengeOptions): Promise<AuthResponse>;
    refresh(): Promise<OAuthResponse | undefined>;
    logout(): Promise<void>;
    getCachedIdentity(): Promise<CachedIdentity | undefined>;
    getCurrentLogin(): Promise<Login>;
    verifySession(): Promise<boolean>;
}
interface OrderlyClient {
    services: OrderlyServices;
    auth: OrderlyAuthHelpers;
    setApiKey(apiKey: string): Promise<void>;
    setBearerToken(token: string): Promise<void>;
    setOAuthResponse(token: OAuthResponse): Promise<void>;
    clearAuth(): Promise<void>;
    getOAuthResponse(): Promise<OAuthResponse | undefined>;
    getCachedIdentity(): Promise<CachedIdentity | undefined>;
    getCurrentLogin(): Promise<Login>;
}
interface BaseOrderlyClientOptions {
    baseUrl: string;
    auth?: OrderlyAuthConfig;
    headers?: HeadersInit;
    tokenStore?: TokenStore;
    identityStore?: IdentityStore;
}
interface CreateOrderlyNodeClientOptions extends BaseOrderlyClientOptions {
    protocol?: "grpc" | "grpc-web";
}
interface CreateOrderlyWebClientOptions extends BaseOrderlyClientOptions {
    credentials?: RequestCredentials;
}

export { type AccessKeyCredentialsOptions as A, type BaseOrderlyClientOptions as B, type CreateOrderlyNodeClientOptions as C, type IdentityStore as I, type MaybePromise as M, type OrderlyClient as O, type PasswordCredentialsOptions as P, type SmsChallengeOptions as S, type TokenStore as T, type CreateOrderlyWebClientOptions as a, type OrderlyServices as b, type AuthenticationRequestInput as c, type BrowserIdentityStoreOptions as d, type CachedIdentity as e, type CreateChallengeOptions as f, type OrderlyAuthConfig as g, type OrderlyAuthHelpers as h, type PhoneNumberInput as i, type PinCodeCredentialsOptions as j, createBrowserLocalStorageIdentityStore as k, createMemoryIdentityStore as l, createMemoryTokenStore as m, defaultBrowserIdentityStorageKey as n, sanitizeCachedIdentity as s };
