@adonis-agora/authkit-react
Version:
Frontend ergonomics over AuthKit for AdonisJS + Inertia + React apps: a typed useAuth() hook, role-gating hooks and gating components.
734 lines (733 loc) • 18.1 kB
TypeScript
import type { CursorPageResponse, OffsetPage } from '@adonis-agora/filter-client';
export type { CursorPageMeta, CursorPageResponse, OffsetPage, OffsetPageMeta, } from '@adonis-agora/filter-client';
export interface ApiErrorBody {
error: {
code: string;
message: string;
};
}
export interface AdminUser {
id: string;
email: string;
name: string | null;
avatarUrl: string | null;
globalRoles: string[];
roles?: string[];
disabled: boolean;
createdAt?: string | null;
updatedAt?: string | null;
invited?: boolean;
}
export interface AdminListParams {
search?: string;
sort?: string;
page?: number;
size?: number;
}
export interface CursorListParams {
after?: string;
before?: string;
first?: number;
last?: number;
}
export type AdminUserListResult = OffsetPage<AdminUser>;
export interface CreateUserInput {
email: string;
name?: string;
password?: string;
invite?: boolean;
}
export interface UpdateUserInput {
globalRoles?: string[];
}
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 AdminSessionListParams extends AdminListParams {
accountId?: string;
}
export interface AdminSessionListResult extends OffsetPage<AdminSessionEntry> {
supported: boolean;
truncated: boolean;
grants: AdminGrantEntry[];
}
export interface AdminRecentSessionsParams {
after?: string;
first?: number;
search?: string;
}
export interface AdminRecentSessionsResult extends CursorPageResponse<AdminSessionEntry> {
supported: boolean;
truncated: boolean;
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;
grantTypes: string[];
redirectUris: string[];
postLogoutRedirectUris: string[];
tokenEndpointAuthMethod: string;
applicationType?: 'web' | 'native';
backchannelLogoutUri: string | null;
backchannelLogoutSessionRequired: boolean;
clientName: string | null;
logoUri: string | null;
disabled?: boolean;
serviceTenant?: ServiceTenantSettings | null;
dynamicallyRegistered?: boolean;
registeredAt?: string | null;
createdAt?: string | null;
updatedAt?: string | null;
scope?: string | null;
}
export interface RevokeClientResult {
clientId: string;
stored: boolean;
sessions: number;
grants: number;
accessTokens: number;
refreshTokens: number;
}
export interface ServiceTenantSettings {
partition: string;
capabilities: string[];
environment?: string;
apps?: Record<string, string[]>;
}
export interface AdminClientListResult extends OffsetPage<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;
applicationType?: 'web' | 'native';
backchannelLogoutUri?: string;
backchannelLogoutSessionRequired?: boolean;
clientName?: string;
logoUri?: string;
scopes?: string[];
serviceTenant?: {
partition: string;
capabilities?: string[];
environment?: string;
apps?: Record<string, string[]>;
};
}
export type UpdateClientInput = Omit<CreateClientInput, 'backchannelLogoutUri' | 'clientName' | 'logoUri' | 'serviceTenant' | 'scopes'> & {
scopes?: string[] | null;
backchannelLogoutUri?: string | null;
clientName?: string | null;
logoUri?: string | null;
serviceTenant?: {
partition: string;
capabilities?: string[];
environment?: string | null;
apps?: Record<string, string[]> | null;
} | null;
};
export interface RoleCatalogEntry {
name: string;
description?: string;
createdAt?: string;
updatedAt?: 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;
updatedAt?: string | null;
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;
updatedAt?: string | null;
}
export interface AdminOrgDetail extends AdminOrgEntry {
members: AdminOrgMember[];
pendingInvitations: AdminOrgInvitation[];
}
export type AdminOrgListResult = OffsetPage<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 type AuditListResult = CursorPageResponse<AuditEventEntry>;
export interface AuditListParams extends CursorListParams {
type?: string | string[];
subject?: string;
}
export interface SettingEntry {
key: string;
organizationId: string | null;
value: unknown;
updatedAt: string | null;
updatedBy: string | null;
}
export interface SettingListResult {
data: SettingEntry[];
locked: string[];
}
export interface DeletedResult {
ok: true;
deleted: string;
}
export interface ResetPasswordResult {
ok: true;
email: string;
}
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 | null;
auditTotalCapped?: boolean;
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;
name: string;
logoUrl: string | null;
accessTokens: number;
refreshTokens: number;
}
export interface AccountAppsResult {
supported: boolean;
apps: AccountAppEntry[];
}
export interface AccountAgentGrant {
id: string;
clientId: string;
protocol: PersonalAgentProtocol;
scopes: Array<{
id: string;
description: string;
}>;
createdAt: string;
updatedAt: string;
expiresAt: string;
}
export interface AccountAgentsResult {
agents: AccountAgentGrant[];
}
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;
remaining: number | null;
regenerable: boolean;
};
}
export interface MfaEnrollResult {
secret: string;
otpauthUri: string;
qrDataUrl: string;
}
export interface MfaConfirmResult {
ok: boolean;
enabled: boolean;
recoveryCodes: string[];
}
export interface MfaDisableResult {
ok: boolean;
enabled: boolean;
}
export interface MfaRecoveryCodesResult {
ok: boolean;
recoveryCodes: string[];
}
export type PasskeyRegistrationOptions = Record<string, unknown>;
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 CreateAccountOrgInput {
name: string;
slug: string;
}
export interface CreatedAccountOrgResult {
id: string;
name: string;
slug: string;
logoUrl: string | null;
role: string;
}
export interface ActivateOrgResult {
ok: boolean;
activeOrgId: string;
slug: string;
role: string;
}
export interface DeactivateOrgResult {
ok: boolean;
activeOrgId: null;
}
export interface LeaveOrgResult {
ok: boolean;
orgId: string;
}
export interface InviteOrgMemberInput {
email: string;
role?: string;
}
export interface CreatedOrgInvitationResult {
id: string;
organizationId: string;
email: string;
role: string;
expiresAt: string | null;
createdAt: string | null;
}
export interface RevokeOrgInvitationResult {
ok: boolean;
revoked: string;
}
export interface UpdateOrgMemberRoleResult {
ok: boolean;
orgId: string;
accountId: string;
role: string;
}
export interface RemoveOrgMemberResult {
ok: boolean;
orgId: string;
accountId: string;
}
export interface AcceptOrgInvitationResult {
ok: boolean;
organizationId: string;
role: 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[];
readOnly?: boolean;
}
export interface KeysRotateInput {
retire?: boolean;
keep?: number;
}
export interface KeysRotateResult {
rotated: true;
newKid: string;
retiredKids: string[];
keptKids: string[];
}
export interface McpClientsSettingValue {
enabled: 'auto' | false;
dynamicRegistration: boolean;
metadataDocuments: boolean;
}
export interface McpClientsStatus {
enabled: boolean;
off: 'config' | 'setting' | 'no-resource' | null;
resources: string[];
dynamicRegistration: boolean;
metadataDocuments: boolean;
setting: McpClientsSettingValue;
lockedByConfig: boolean;
summary: string;
config: {
dynamicRegistration: 'mcp' | 'app' | 'off';
metadataDocuments: boolean;
allowHosts: string[] | null;
};
clients: {
dynamic: number | null;
metadataDocuments: number;
};
}
export interface McpClientsUpdateInput {
enabled: 'auto' | false;
dynamicRegistration?: boolean;
metadataDocuments?: boolean;
}
export type PersonalAgentProtocol = 'pact' | (string & {});
export type PersonalAgentListStatus = 'allowed' | 'blocked';
export interface PersonalAgentEntry {
protocol: PersonalAgentProtocol;
identifier: string;
name: string;
config: PersonalAgentListStatus | null;
console: {
id: string;
status: PersonalAgentListStatus;
updatedAt: string;
updatedBy: string | null;
} | null;
effective: PersonalAgentListStatus | 'unlisted';
jwksUri: string | null;
connections: number;
}
export interface PersonalAgentsOverview {
protocols: {
pact: PersonalAgentPactOverview | null;
[protocol: string]: PersonalAgentPactOverview | PersonalAgentExtensionOverview | null;
};
agents: PersonalAgentEntry[];
}
export interface PersonalAgentPactOverview {
open: boolean;
hostResolver: boolean;
}
export interface PersonalAgentExtensionOverview {
label: string;
requireRegistration: boolean;
hostResolver: boolean;
allowHttpIdentifiers: boolean;
identifierLabel: string;
identifierPlaceholder: string | null;
}
export interface PersonalAgentConnection {
id: string;
protocol: PersonalAgentProtocol;
clientId: string;
agentName: string;
accountId: string;
accountEmail: string | null;
scopes: string[];
createdAt: string;
updatedAt: string;
expiresAt: string;
}
export interface PersonalAgentConnectionsParams {
protocol?: PersonalAgentProtocol;
clientId?: string;
accountId?: string;
page?: number;
size?: number;
}
export type PersonalAgentConnectionsResult = OffsetPage<PersonalAgentConnection>;
export interface PersonalAgentRegistryInput {
protocol: PersonalAgentProtocol;
identifier: string;
status: PersonalAgentListStatus;
name?: string;
jwksUri?: string;
}
export interface PersonalAgentRegistryResult {
entry: {
id: string;
protocol: PersonalAgentProtocol;
identifier: string;
status: PersonalAgentListStatus;
name: string | null;
jwksUri: string | null;
updatedAt: string;
};
disconnected: number;
}