import * as React from 'react'; import { type IamAccount, type IamOrg, type IamProject } from './iam'; import type { WhiteLabel } from './white-label'; export type IdentityStatus = 'loading' | 'anonymous' | 'ready' | 'error'; /** * How the chrome gets a bearer and moves the user in and out of a session. * * Credentials are `@hanzo/iam`'s job, not the design system's — so this is the * seam, and a surface using the SDK supplies only the two verbs: * * auth={{ signIn: () => void startLogin(), signOut: () => void logout() }} * * The bearer itself needs no wiring: the default reads the SDK's own token * store, so there is exactly one token and one refresh timer per surface. */ export interface IdentityAuth { /** The IAM access token. Defaults to the `@hanzo/iam` SDK's token store. */ readonly token?: () => string | null | Promise; /** Start a sign-in. */ readonly signIn?: () => void; /** End the session. */ readonly signOut?: () => void; } export interface Identity { readonly status: IdentityStatus; /** The signed-in principal, or null. */ readonly account: IamAccount | null; /** Organizations the principal can act in. */ readonly orgs: ReadonlyArray; /** The organization the surface is currently scoped to, or null. */ readonly org: IamOrg | null; /** Projects in the current organization. */ readonly projects: ReadonlyArray; /** The project the surface is currently scoped to, or null. */ readonly project: IamProject | null; /** Why the reads failed, when status is 'error'. */ readonly error: string | null; /** Host-resolved brand, theme, issuer and IAM client. */ readonly whiteLabel: WhiteLabel; readonly setOrg: (name: string) => void; readonly setProject: (name: string) => void; readonly signIn: () => void; readonly signOut: () => void; readonly reload: () => void; } export interface IdentityProviderProps { readonly children: React.ReactNode; /** Bearer + sign-in/out. Defaults to the `@hanzo/iam` token store. */ readonly auth?: IdentityAuth; /** Where sign-in goes when `auth.signIn` is not supplied. */ readonly loginPath?: string; } export declare const IdentityProvider: ({ children, auth, loginPath, }: IdentityProviderProps) => React.ReactElement; /** * The current identity. * * Outside an `` this reports `anonymous` rather than * throwing: chrome that renders before a surface has wired identity should * offer sign-in, not crash the page. */ export declare function useIdentity(): Identity; //# sourceMappingURL=identity.d.ts.map