@adonis-agora/authkit-react
Version:
Frontend ergonomics over AuthKit for AdonisJS + Inertia + React apps: a typed useAuth() hook, role-gating hooks and gating components.
458 lines (457 loc) • 10.5 kB
TypeScript
export interface ApiErrorBody {
error: {
code: string;
message: string;
};
}
export interface AdminUser {
id: string;
email: string;
name: string | null;
avatarUrl: string | null;
globalRoles: string[];
disabled: boolean;
invited?: boolean;
}
export interface ListMeta {
page: number;
size: number;
total: number;
}
export interface AdminUserListResult {
meta: ListMeta;
data: AdminUser[];
}
export interface CreateUserInput {
email: string;
name?: string | null;
password?: string | null;
invite?: boolean;
}
export interface UpdateUserInput {
globalRoles?: string[];
name?: string | null;
avatarUrl?: string | null;
}
export interface AdminSessionEntry {
id: string;
accountId: string;
email: string | null;
loginTs: string | null;
amr: string[];
userAgent: string | null;
browser: string | null;
os: string | null;
ip: string | null;
location: string | null;
}
export interface AdminGrantEntry {
id: string;
accountId: string;
clientId: string | null;
accessTokens: number;
refreshTokens: number;
}
export interface UserSessionsResult {
supported: boolean;
truncated?: boolean;
sessions: AdminSessionEntry[];
grants: AdminGrantEntry[];
}
export interface RevokeSessionsResult {
revoked?: number;
[key: string]: unknown;
}
export interface AdminSessionListResult {
canList: boolean;
sessions: AdminSessionEntry[];
grants: AdminGrantEntry[];
}
export interface AdminClient {
clientId: string;
confidential: boolean;
grants: string[];
redirectUris: string[];
postLogoutRedirectUris: string[];
tokenEndpointAuthMethod: string;
backchannelLogoutUri: string | null;
backchannelLogoutSessionRequired: boolean;
}
export interface AdminClientListResult {
data: AdminClient[];
canList: boolean;
}
export interface CreatedClientResult {
clientId: string;
clientSecret: string | null;
}
export interface RegenerateSecretResult {
clientId: string;
clientSecret: string;
}
export interface CreateClientInput {
clientId?: string;
redirectUris?: string[];
postLogoutRedirectUris?: string[];
grantTypes?: string[];
tokenEndpointAuthMethod?: string;
backchannelLogoutUri?: string;
backchannelLogoutSessionRequired?: boolean;
}
export type UpdateClientInput = CreateClientInput;
export interface RoleCatalogEntry {
name: string;
description?: string;
}
export interface RoleListResult {
data: RoleCatalogEntry[];
}
export interface CreateRoleInput {
name: string;
description?: string;
}
export interface UpdateRoleInput {
description?: string;
}
export interface AdminOrgEntry {
id: string;
name: string;
slug: string;
logoUrl: string | null;
metadata: unknown | null;
createdAt: string;
memberCount?: number;
}
export interface AdminOrgMember {
accountId: string;
email: string | null;
role: string;
joinedAt: string;
}
export interface AdminOrgInvitation {
id: string;
organizationId: string;
email: string;
role: string;
invitedBy: string;
expiresAt: string;
acceptedAt: string | null;
createdAt: string;
}
export interface AdminOrgDetail extends AdminOrgEntry {
members: AdminOrgMember[];
pendingInvitations: AdminOrgInvitation[];
}
export interface AdminOrgListResult {
data: AdminOrgEntry[];
}
export interface CreateOrgInput {
name: string;
slug: string;
ownerAccountId: string;
logoUrl?: string | null;
}
export interface UpdateOrgInput {
name?: string;
logoUrl?: string | null;
}
export interface AuditEventEntry {
id: string;
type: string;
accountId: string | null;
email: string | null;
clientId: string | null;
actorId: string | null;
ip: string | null;
metadata: unknown | null;
createdAt: string;
}
export interface AuditListResult {
meta: ListMeta;
data: AuditEventEntry[];
}
export interface AuditListParams {
type?: string;
page?: number;
size?: number;
subject?: string;
}
export interface SettingEntry {
key: string;
organizationId: string | null;
value: unknown;
updatedAt: string | null;
updatedBy: string | null;
}
export interface SettingListResult {
data: SettingEntry[];
}
export interface ImpersonationPanel {
targetUserId: string;
targetEmail: string;
clientId: string;
tokenEndpoint: string;
grantType: string;
subjectTokenType: string;
requestedSubject: string;
curl: string;
}
export interface DailyPoint {
date: string;
count: number;
}
export interface AdminOverview {
usersTotal: number;
activeSessions: number | null;
mau: number;
signInsTotal: number;
signUpsTotal: number;
signInsPerDay: DailyPoint[];
signUpsPerDay: DailyPoint[];
windowDays: number;
auditSupported: boolean;
clientsCount: number;
auditTotal: number;
recentEvents: AuditEventEntry[];
}
export interface AccountCapabilities {
securitySupported: boolean;
profileSupported: boolean;
passkeysSupported: boolean;
orgsSupported: boolean;
tokensSupported: boolean;
avatarUploadSupported: boolean;
sessionsSupported: boolean;
}
export interface AccountMe {
id: string;
email: string;
emailVerified: boolean | null;
name: string | null;
avatarUrl: string | null;
globalRoles: string[];
hasPassword: boolean;
mfaEnabled: boolean;
passkeyCount: number;
sudoActive: boolean;
capabilities: AccountCapabilities;
}
export interface AccountSessionEntry {
id: string;
loginTs: string | null;
browser: string | null;
os: string | null;
ip: string | null;
location: string | null;
amr: string[];
}
export interface AccountSecurityOverview {
email: string;
pendingEmail: string | null;
securitySupported: boolean;
profileSupported: boolean;
sessionsSupported: boolean;
activeSessions: AccountSessionEntry[];
mfa: {
enabled: boolean;
totpEnrolled: boolean;
passkeyCount: number;
passkeysSupported: boolean;
};
}
export interface UserLoginMethodsInput {
password?: boolean;
magicLink?: boolean;
passkey?: boolean;
social?: boolean;
}
export interface AccountLoginMethodsResult {
supported: boolean;
methods: UserLoginMethodsInput | null;
available: {
password: boolean;
magicLink: boolean;
passkey: boolean;
social: string[];
forgotPassword: boolean;
} | null;
locked: {
password: boolean;
magicLink: boolean;
passkey: boolean;
social: boolean;
} | null;
}
export interface UpdateLoginMethodsResult {
ok: boolean;
methods: UserLoginMethodsInput;
}
export interface AccountSessionsResult {
supported: boolean;
sessions: AccountSessionEntry[];
}
export interface RevokeSessionResult {
ok: boolean;
revoked: string;
}
export interface RevokeOthersResult {
ok: boolean;
[key: string]: unknown;
}
export interface RevokeAllResult {
ok: boolean;
signedOut: boolean;
[key: string]: unknown;
}
export interface AccountAppEntry {
clientId: string;
accessTokens: number;
refreshTokens: number;
}
export interface AccountAppsResult {
supported: boolean;
apps: AccountAppEntry[];
}
export interface RevokeAppResult {
ok: boolean;
[key: string]: unknown;
}
export interface PasskeySummaryEntry {
id: string;
label: string | null;
createdAt: string | null;
}
export interface AccountMfaStatus {
enabled: boolean;
totp: {
enrolled: boolean;
};
passkeys: {
supported: boolean;
count: number;
items: PasskeySummaryEntry[];
};
recovery: {
available: boolean;
};
}
export interface AccountPasskeysResult {
supported: boolean;
passkeys: PasskeySummaryEntry[];
}
export interface RemovePasskeyResult {
ok: boolean;
removed: string;
}
export interface PatEntry {
id: string;
name: string;
scopes: string[];
audience: string | null;
lastUsedAt: string | null;
createdAt: string;
}
export interface CreatedPatResult extends PatEntry {
secret: string;
}
export interface AccountTokensResult {
supported: boolean;
tokens: PatEntry[];
}
export interface CreateTokenInput {
name?: string;
}
export interface RevokeTokenResult {
ok: boolean;
revoked: string;
}
export interface UpdateProfileInput {
name?: string | null;
avatarUrl?: string | null;
}
export interface UpdateProfileResult {
id: string;
name: string | null;
avatarUrl: string | null;
}
export interface ChangePasswordInput {
currentPassword: string;
newPassword: string;
}
export interface RequestEmailChangeInput {
newEmail: string;
currentPassword?: string;
}
export interface OkResult {
ok: boolean;
}
export interface EmailChangeResult {
ok: boolean;
email: string;
}
export interface AccountOrgEntry {
id: string;
name: string;
slug: string;
logoUrl: string | null;
role: string;
isActive: boolean;
}
export interface AccountOrgsResult {
supported: boolean;
activeOrgId: string | null;
orgs: AccountOrgEntry[];
}
export interface AccountOrgDetail {
id: string;
name: string;
slug: string;
logoUrl: string | null;
role: string;
canManage: boolean;
members: Array<{
accountId: string;
email: string | null;
role: string;
joinedAt: string;
}>;
}
export interface AccountOrgInvitationsResult {
supported: boolean;
invitations: Array<{
id: string;
organizationId: string;
orgName: string;
orgSlug: string;
email: string;
role: string;
expiresAt: string;
createdAt: string;
}>;
}
export interface ManagedKeyInfo {
kid: string;
alg: string;
ageDays: number;
active: boolean;
}
export interface KeysStatus {
ageDays: number;
policy: {
enabled: boolean;
maxAgeDays: number;
keep: number;
};
nextRotationInDays: number | null;
keys: ManagedKeyInfo[];
}
export interface KeysRotateInput {
retire?: boolean;
keep?: number;
}
export interface KeysRotateResult {
rotated: true;
newKid: string;
retiredKids: string[];
keptKids: string[];
}