import type { TBreakGlassEligibleGlobalCapability, TDelegableGlobalCapability } from './authorization.js'; export type TBreakGlassJustificationCode = 'access_recovery' | 'security_incident' | 'service_outage'; export type TBreakGlassReviewOutcome = 'confirmed' | 'escalated'; interface IBreakGlassAccessBase { operationId: string; capabilities: TBreakGlassEligibleGlobalCapability[]; justificationCode: TBreakGlassJustificationCode; requestedAt: number; approvalExpiresAt: number; activationDurationSeconds: number; } export type TBreakGlassAccess = IBreakGlassAccessBase & ({ status: 'pending'; } | { status: 'active'; approvedByUserRef: string; approvedAt: number; activeUntil: number; firstUsedAt: number | null; } | { status: 'reviewed'; approvedByUserRef: string; approvedAt: number; activeUntil: number; firstUsedAt: number | null; reviewedByUserRef: string; reviewedAt: number; reviewOutcome: TBreakGlassReviewOutcome; }); interface IAdministratorRecoveryBase { operationId: string; /** Custody-protected binding to the recovery-authenticated login session. */ requestingSessionRef: string; requestedAt: number; approvalExpiresAt: number; } export type TAdministratorRecovery = IAdministratorRecoveryBase & ({ status: 'pending'; } | { status: 'active'; approvedByUserRef: string; approvedAt: number; activeUntil: number; } | { status: 'completed'; approvedByUserRef: string; approvedAt: number; activeUntil: number; completedAt: number; passkeyCredentialRef: string; }); export interface IUser { id: string; data: { name: string; username: string; email: string; /** * mobile number used for verification */ mobileNumber?: string | null; /** * used for validation of passwords */ passwordHash?: string | null; status: 'new' | 'active' | 'deleted' | 'suspended'; /** epoch ms of account creation */ createdAt: number; /** * present while an account deletion is pending: the account is locked * (status 'deleted') and housekeeping purges it after purgeAt. * A global admin can cancel by reactivating the account within the window. */ deletion?: { requestedAt: number; purgeAt: number; }; /** * a quick ref for which organizations might have roles for this user * speeds up lookup */ connectedOrgs: string[]; /** * Platform-level admin flag * Users with this flag can access the global admin panel * to manage global apps, view platform stats, etc. */ isGlobalAdmin?: boolean | null; /** Sorted, explicit platform capabilities for a non-administrator. */ globalCapabilities?: TDelegableGlobalCapability[] | null; /** * Current break-glass request/grant state. Active authority is always * time-bounded and a reviewed record is retained until the next request. */ breakGlassAccess?: TBreakGlassAccess | null; /** * Controlled, one-time replacement-passkey enrollment for a global * administrator. Approval never grants ordinary administrator authority. */ administratorRecovery?: TAdministratorRecovery | null; /** * Links to external identities established via enterprise SSO. * One entry per SSO connection the user has signed in through. */ externalIdentities?: { /** The ISsoConnection id this identity belongs to */ connectionId: string; /** Stable subject identifier at the customer IdP (SAML NameID) */ subjectId: string; }[] | null; }; } export {};